Commit | Line | Data |
---|---|---|
ccc66d01 | 1 | /********************************************************************** |
60ae41e1 | 2 | * Copyright (c) 2012, 2014 Ericsson |
cfdb727a | 3 | * |
ccc66d01 BH |
4 | * All rights reserved. This program and the accompanying materials are |
5 | * made available under the terms of the Eclipse Public License v1.0 which | |
6 | * accompanies this distribution, and is available at | |
7 | * http://www.eclipse.org/legal/epl-v10.html | |
cfdb727a AM |
8 | * |
9 | * Contributors: | |
ccc66d01 | 10 | * Bernd Hufmann - Initial API and implementation |
ba3a9bd2 | 11 | * Bernd Hufmann - Updated for support of LTTng Tools 2.1 |
d4489ec9 | 12 | * Marc-Andre Laperle - Add filtering textbox |
ccc66d01 | 13 | **********************************************************************/ |
8e8c0226 | 14 | package org.eclipse.linuxtools.internal.lttng2.control.ui.views.dialogs; |
ccc66d01 BH |
15 | |
16 | import java.util.ArrayList; | |
17 | import java.util.HashSet; | |
18 | import java.util.List; | |
19 | import java.util.Set; | |
20 | ||
21 | import org.eclipse.jface.dialogs.MessageDialog; | |
22 | import org.eclipse.jface.viewers.CheckStateChangedEvent; | |
23 | import org.eclipse.jface.viewers.CheckboxTreeViewer; | |
24 | import org.eclipse.jface.viewers.ICheckStateListener; | |
d4489ec9 | 25 | import org.eclipse.jface.viewers.TreeViewer; |
8e8c0226 AM |
26 | import org.eclipse.linuxtools.internal.lttng2.control.core.model.LogLevelType; |
27 | import org.eclipse.linuxtools.internal.lttng2.control.core.model.TraceLogLevel; | |
28 | import org.eclipse.linuxtools.internal.lttng2.control.ui.views.messages.Messages; | |
29 | import org.eclipse.linuxtools.internal.lttng2.control.ui.views.model.ITraceControlComponent; | |
30 | import org.eclipse.linuxtools.internal.lttng2.control.ui.views.model.impl.BaseEventComponent; | |
31 | import org.eclipse.linuxtools.internal.lttng2.control.ui.views.model.impl.TargetNodeComponent; | |
32 | import org.eclipse.linuxtools.internal.lttng2.control.ui.views.model.impl.TraceControlContentProvider; | |
33 | import org.eclipse.linuxtools.internal.lttng2.control.ui.views.model.impl.TraceControlLabelProvider; | |
34 | import org.eclipse.linuxtools.internal.lttng2.control.ui.views.model.impl.TraceProviderGroup; | |
35 | import org.eclipse.linuxtools.internal.lttng2.control.ui.views.model.impl.UstProviderComponent; | |
ccc66d01 BH |
36 | import org.eclipse.swt.SWT; |
37 | import org.eclipse.swt.custom.CCombo; | |
38 | import org.eclipse.swt.events.SelectionAdapter; | |
39 | import org.eclipse.swt.events.SelectionEvent; | |
40 | import org.eclipse.swt.graphics.Image; | |
41 | import org.eclipse.swt.layout.GridData; | |
42 | import org.eclipse.swt.layout.GridLayout; | |
43 | import org.eclipse.swt.widgets.Button; | |
44 | import org.eclipse.swt.widgets.Composite; | |
45 | import org.eclipse.swt.widgets.Group; | |
46 | import org.eclipse.swt.widgets.Label; | |
47 | import org.eclipse.swt.widgets.Text; | |
d4489ec9 MAL |
48 | import org.eclipse.ui.dialogs.FilteredTree; |
49 | import org.eclipse.ui.dialogs.PatternFilter; | |
ccc66d01 BH |
50 | |
51 | /** | |
ccc66d01 BH |
52 | * <p> |
53 | * A composite for collecting information about UST events to be enabled. | |
54 | * </p> | |
cfdb727a | 55 | * |
dbd4432d | 56 | * @author Bernd Hufmann |
ccc66d01 BH |
57 | */ |
58 | public class EnableUstEventsComposite extends Composite implements IEnableUstEvents { | |
59 | ||
60 | // ------------------------------------------------------------------------ | |
61 | // Constants | |
62 | // ------------------------------------------------------------------------ | |
cfdb727a AM |
63 | |
64 | private enum GroupEnum { TRACEPOINTS, WILDCARD, LOGLEVEL } | |
65 | ||
ccc66d01 BH |
66 | // ------------------------------------------------------------------------ |
67 | // Attributes | |
68 | // ------------------------------------------------------------------------ | |
cfdb727a | 69 | |
ccc66d01 BH |
70 | /** |
71 | * A button to enable/disable the tracepoints group | |
72 | */ | |
73 | private Button fTracepointsActivateButton; | |
74 | /** | |
75 | * A tree viewer for diplaying and selection of available tracepoints. | |
76 | */ | |
77 | private CheckboxTreeViewer fTracepointsViewer; | |
78 | /** | |
79 | * A button to enable/disable the wildcard group | |
80 | */ | |
81 | private Button fWildcardActivateButton; | |
82 | /** | |
83 | * A Text field for the event's wildcard. | |
84 | */ | |
85 | private Text fWildcardText; | |
86 | /** | |
87 | * A button to enable/disable the log level group | |
88 | */ | |
89 | private Button fLogLevelActivateButton; | |
90 | /** | |
91 | * A Text field for the event name for the log level enablement. | |
92 | */ | |
93 | private Text fLogLevelEventNameText; | |
94 | /** | |
95 | * A Combo box for selecting the log level. | |
96 | */ | |
97 | private CCombo fLogLevelCombo; | |
98 | /** | |
99 | * A button for selecting the log level (range 0 to level). | |
100 | */ | |
101 | private Button fLogLevelButton; | |
102 | /** | |
103 | * A button for selecting the specified log level only. | |
104 | */ | |
105 | private Button fLogLevelOnlyButton; | |
d4514365 BH |
106 | /** |
107 | * The filter text | |
108 | */ | |
109 | private Text fFilterText; | |
110 | ||
ccc66d01 | 111 | /** |
cfdb727a | 112 | * The referenced trace provider group containing the UST providers |
ccc66d01 BH |
113 | * component which contains a list of available tracepoints. |
114 | */ | |
cfdb727a | 115 | private final TraceProviderGroup fProviderGroup; |
ccc66d01 BH |
116 | /** |
117 | * The flag indicating that tracepoints are selected. | |
118 | */ | |
119 | private boolean fIsTracepoints; | |
120 | /** | |
121 | * The flag indicating that all tracepoints (across providers) are selected. | |
122 | */ | |
123 | private boolean fIsAllTracepoints; | |
124 | /** | |
125 | * The list of tracepoints to be enabled. | |
126 | */ | |
127 | private List<String> fSelectedEvents; | |
128 | /** | |
cfdb727a | 129 | * The flag indicating that all wildcard are selected.. |
ccc66d01 BH |
130 | */ |
131 | private boolean fIsWildcard; | |
132 | /** | |
cfdb727a | 133 | * The wildcard if wildcard is selected. |
ccc66d01 BH |
134 | */ |
135 | private String fWildcard; | |
136 | /** | |
cfdb727a | 137 | *The flag indicating that all log level are selected. |
ccc66d01 BH |
138 | */ |
139 | private boolean fIsLogLevel; | |
140 | /** | |
141 | * The event name for the log level enablement. | |
142 | */ | |
143 | private String fLogLevelEventName; | |
144 | /** | |
145 | * The type of the log level (loglevel or loglevel-only) | |
146 | */ | |
147 | private LogLevelType fLogLevelType; | |
148 | /** | |
149 | * The actual selected log level. | |
150 | */ | |
151 | private TraceLogLevel fLogLevel; | |
d4514365 BH |
152 | /** |
153 | * The filter expression | |
154 | */ | |
155 | private String fFilterExpression; | |
ccc66d01 BH |
156 | |
157 | // ------------------------------------------------------------------------ | |
158 | // Constructors | |
159 | // ------------------------------------------------------------------------ | |
160 | /** | |
161 | * Constructor | |
162 | * @param parent - a parent composite | |
cfdb727a | 163 | * @param style - a composite style |
ccc66d01 BH |
164 | * @param providerGroup - the trace provider group |
165 | */ | |
166 | public EnableUstEventsComposite(Composite parent, int style, TraceProviderGroup providerGroup) { | |
167 | super(parent, style); | |
168 | fProviderGroup = providerGroup; | |
169 | } | |
170 | ||
171 | // ------------------------------------------------------------------------ | |
172 | // Accessors | |
173 | // ------------------------------------------------------------------------ | |
174 | ||
ccc66d01 BH |
175 | @Override |
176 | public boolean isTracepoints() { | |
177 | return fIsTracepoints; | |
178 | } | |
cfdb727a | 179 | |
ccc66d01 BH |
180 | @Override |
181 | public boolean isAllTracePoints() { | |
182 | return fIsAllTracepoints; | |
183 | } | |
cfdb727a | 184 | |
ccc66d01 BH |
185 | @Override |
186 | public List<String> getEventNames() { | |
e0838ca1 | 187 | return new ArrayList<>(fSelectedEvents); |
ccc66d01 BH |
188 | } |
189 | ||
ccc66d01 BH |
190 | @Override |
191 | public boolean isWildcard() { | |
192 | return fIsWildcard; | |
193 | } | |
194 | ||
ccc66d01 BH |
195 | @Override |
196 | public String getWildcard() { | |
7a6e4bfd | 197 | return fWildcard; |
ccc66d01 BH |
198 | } |
199 | ||
ccc66d01 BH |
200 | @Override |
201 | public boolean isLogLevel() { | |
202 | return fIsLogLevel; | |
203 | } | |
204 | ||
ccc66d01 BH |
205 | @Override |
206 | public LogLevelType getLogLevelType() { | |
207 | return fLogLevelType; | |
208 | } | |
209 | ||
ccc66d01 BH |
210 | @Override |
211 | public TraceLogLevel getLogLevel() { | |
212 | return fLogLevel; | |
213 | } | |
214 | ||
ccc66d01 BH |
215 | @Override |
216 | public String getLogLevelEventName() { | |
217 | return fLogLevelEventName; | |
218 | } | |
cfdb727a | 219 | |
d4514365 BH |
220 | @Override |
221 | public String getFilterExpression() { | |
222 | return fFilterExpression; | |
223 | } | |
224 | ||
ccc66d01 BH |
225 | // ------------------------------------------------------------------------ |
226 | // Operations | |
227 | // ------------------------------------------------------------------------ | |
228 | ||
cfdb727a AM |
229 | /** |
230 | * Create the contents of this event composite | |
231 | */ | |
ccc66d01 | 232 | public void createContent() { |
cfdb727a AM |
233 | |
234 | // Tracepoints Group | |
ccc66d01 BH |
235 | createTracepointsGroup(); |
236 | ||
cfdb727a | 237 | // Wildcard Group |
ccc66d01 BH |
238 | createWildCardGroup(); |
239 | ||
cfdb727a | 240 | // Log Level Group |
ccc66d01 | 241 | createLogLevelGroup(); |
cfdb727a | 242 | |
d4514365 BH |
243 | // Filter Group |
244 | createFilterGroup(); | |
245 | ||
ccc66d01 BH |
246 | // Set default enablements |
247 | setEnablements(GroupEnum.TRACEPOINTS); | |
248 | } | |
249 | ||
250 | /** | |
11252342 AM |
251 | * Validates the UST composite input data. |
252 | * | |
253 | * @return true if configured data is valid and can be retrieved. | |
254 | */ | |
ccc66d01 | 255 | public boolean isValid() { |
cfdb727a | 256 | |
ccc66d01 BH |
257 | fIsTracepoints = fTracepointsActivateButton.getSelection(); |
258 | fIsWildcard = fWildcardActivateButton.getSelection(); | |
259 | fIsLogLevel = fLogLevelActivateButton.getSelection(); | |
cfdb727a | 260 | |
5f1f22f8 BH |
261 | // initialize tracepoint fields |
262 | fIsAllTracepoints = false; | |
e0838ca1 | 263 | fSelectedEvents = new ArrayList<>(); |
5f1f22f8 BH |
264 | if (fIsTracepoints) { |
265 | fIsAllTracepoints = fTracepointsViewer.getChecked(fProviderGroup); | |
e0838ca1 | 266 | Set<String> set = new HashSet<>(); |
5f1f22f8 BH |
267 | Object[] checkedElements = fTracepointsViewer.getCheckedElements(); |
268 | for (int i = 0; i < checkedElements.length; i++) { | |
269 | ITraceControlComponent component = (ITraceControlComponent)checkedElements[i]; | |
270 | if (!set.contains(component.getName()) && (component instanceof BaseEventComponent)) { | |
271 | set.add(component.getName()); | |
272 | fSelectedEvents.add(component.getName()); | |
273 | } | |
ccc66d01 BH |
274 | } |
275 | } | |
276 | ||
ccc66d01 | 277 | // initialize log level event name string |
5f1f22f8 | 278 | fLogLevelType = LogLevelType.LOGLEVEL_NONE; |
ccc66d01 | 279 | fLogLevelEventName = null; |
ccc66d01 | 280 | |
5f1f22f8 BH |
281 | if (fIsLogLevel) { |
282 | if (fLogLevelButton.getSelection()) { | |
283 | fLogLevelType = LogLevelType.LOGLEVEL; | |
284 | } else if (fLogLevelOnlyButton.getSelection()) { | |
285 | fLogLevelType = LogLevelType.LOGLEVEL_ONLY; | |
286 | } | |
ccc66d01 | 287 | |
5f1f22f8 | 288 | String temp = fLogLevelEventNameText.getText(); |
c371fa43 BH |
289 | if (temp.isEmpty() || |
290 | temp.matches("\\s*") || //$NON-NLS-1$ | |
291 | (!temp.matches("^[\\s]{0,}$") && !temp.matches("^[a-zA-Z0-9\\-\\_]{1,}$"))) { //$NON-NLS-1$ //$NON-NLS-2$ | |
5f1f22f8 BH |
292 | MessageDialog.openError(getShell(), |
293 | Messages.TraceControl_EnableEventsDialogTitle, | |
294 | Messages.TraceControl_InvalidLogLevelEventNameError + " (" + temp + ") \n"); //$NON-NLS-1$ //$NON-NLS-2$ | |
295 | ||
296 | return false; | |
297 | } | |
298 | ||
c371fa43 | 299 | fLogLevelEventName = temp; |
ccc66d01 | 300 | |
5f1f22f8 BH |
301 | TraceLogLevel[] levels = TraceLogLevel.values(); |
302 | int id = fLogLevelCombo.getSelectionIndex(); | |
c56972bb | 303 | |
5f1f22f8 BH |
304 | if (id < 0) { |
305 | MessageDialog.openError(getShell(), | |
306 | Messages.TraceControl_EnableEventsDialogTitle, | |
307 | Messages.TraceControl_InvalidLogLevel + " (" + temp + ") \n"); //$NON-NLS-1$ //$NON-NLS-2$ | |
308 | ||
309 | return false; | |
5f1f22f8 | 310 | } |
cfdb727a | 311 | fLogLevel = levels[id]; |
c56972bb BH |
312 | } |
313 | ||
d4514365 | 314 | // initialize wildcard with null |
ccc66d01 | 315 | fWildcard = null; |
5f1f22f8 BH |
316 | if (fIsWildcard) { |
317 | String tempWildcard = fWildcardText.getText(); | |
c371fa43 BH |
318 | if (tempWildcard.isEmpty() || |
319 | tempWildcard.matches("\\s*") || //$NON-NLS-1$ | |
320 | (!tempWildcard.matches("^[\\s]{0,}$") && !tempWildcard.matches("^[a-zA-Z0-9\\-\\_\\*]{1,}$"))) { //$NON-NLS-1$ //$NON-NLS-2$ | |
5f1f22f8 BH |
321 | MessageDialog.openError(getShell(), |
322 | Messages.TraceControl_EnableEventsDialogTitle, | |
323 | Messages.TraceControl_InvalidWildcardError + " (" + tempWildcard + ") \n"); //$NON-NLS-1$ //$NON-NLS-2$ | |
ccc66d01 | 324 | |
5f1f22f8 BH |
325 | return false; |
326 | } | |
327 | ||
c371fa43 | 328 | fWildcard = tempWildcard; |
ccc66d01 | 329 | } |
5f1f22f8 | 330 | |
d4514365 BH |
331 | // initialize filter with null |
332 | fFilterExpression = null; | |
333 | if (fProviderGroup.isEventFilteringSupported()) { | |
334 | String tempFilter = fFilterText.getText(); | |
335 | ||
c371fa43 | 336 | if(!tempFilter.isEmpty() && !tempFilter.matches("\\s*")) { //$NON-NLS-1$ |
d4514365 BH |
337 | fFilterExpression = tempFilter; |
338 | } | |
339 | } | |
340 | ||
ccc66d01 BH |
341 | // validation successful -> call super.okPressed() |
342 | return true; | |
343 | } | |
cfdb727a | 344 | |
ccc66d01 BH |
345 | // ------------------------------------------------------------------------ |
346 | // Helper methods | |
347 | // ------------------------------------------------------------------------ | |
cfdb727a | 348 | |
ccc66d01 BH |
349 | /** |
350 | * Creates tracepoints group. | |
351 | */ | |
352 | private void createTracepointsGroup() { | |
353 | Group tpMainGroup = new Group(this, SWT.SHADOW_NONE); | |
354 | tpMainGroup.setText(Messages.TraceControl_EnableEventsTracepointGroupName); | |
355 | GridLayout layout = new GridLayout(2, false); | |
356 | tpMainGroup.setLayout(layout); | |
357 | GridData data = new GridData(GridData.FILL_BOTH); | |
358 | tpMainGroup.setLayoutData(data); | |
cfdb727a | 359 | |
ccc66d01 BH |
360 | Composite buttonComposite = new Composite(tpMainGroup, SWT.NONE); |
361 | layout = new GridLayout(1, true); | |
362 | buttonComposite.setLayout(layout); | |
363 | data = new GridData(SWT.BEGINNING, SWT.CENTER, false, true); | |
364 | buttonComposite.setLayoutData(data); | |
365 | ||
366 | fTracepointsActivateButton = new Button(buttonComposite, SWT.RADIO); | |
367 | fTracepointsActivateButton.setText(Messages.TraceControl_EnableGroupSelectionName); | |
368 | data = new GridData(GridData.FILL_HORIZONTAL); | |
369 | fTracepointsActivateButton.setLayoutData(data); | |
370 | fTracepointsActivateButton.addSelectionListener(new SelectionAdapter() { | |
371 | @Override | |
372 | public void widgetSelected(SelectionEvent e) { | |
373 | setEnablements(GroupEnum.TRACEPOINTS); | |
374 | } | |
375 | }); | |
cfdb727a | 376 | |
ccc66d01 BH |
377 | Group tpGroup = new Group(tpMainGroup, SWT.SHADOW_NONE); |
378 | layout = new GridLayout(1, true); | |
379 | tpGroup.setLayout(layout); | |
380 | data = new GridData(GridData.FILL_BOTH); | |
381 | tpGroup.setLayoutData(data); | |
d4489ec9 MAL |
382 | new FilteredTree(tpGroup, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER, new PatternFilter(), true) { |
383 | @Override | |
384 | protected TreeViewer doCreateTreeViewer(Composite aparent, int style) { | |
385 | fTracepointsViewer = new CheckboxTreeViewer(aparent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); | |
386 | fTracepointsViewer.getTree().setToolTipText(Messages.TraceControl_EnableEventsTracepointTreeTooltip); | |
387 | fTracepointsViewer.setContentProvider(new UstContentProvider()); | |
cfdb727a | 388 | |
d4489ec9 MAL |
389 | fTracepointsViewer.setLabelProvider(new UstLabelProvider()); |
390 | fTracepointsViewer.addCheckStateListener(new UstCheckStateListener()); | |
ccc66d01 | 391 | |
d4489ec9 MAL |
392 | fTracepointsViewer.setInput(fProviderGroup.getParent()); |
393 | fTracepointsViewer.getTree().setLayoutData(new GridData(GridData.FILL_BOTH)); | |
394 | return fTracepointsViewer; | |
395 | } | |
396 | }; | |
ccc66d01 | 397 | } |
cfdb727a | 398 | |
ccc66d01 BH |
399 | /** |
400 | * Creates wildcard group. | |
401 | */ | |
402 | private void createWildCardGroup() { | |
403 | Group wildcardMainGroup = new Group(this, SWT.SHADOW_NONE); | |
404 | wildcardMainGroup.setText(Messages.TraceControl_EnableEventsWildcardGroupName); | |
405 | GridLayout layout = new GridLayout(2, false); | |
406 | wildcardMainGroup.setLayout(layout); | |
407 | GridData data = new GridData(GridData.FILL_HORIZONTAL); | |
408 | wildcardMainGroup.setLayoutData(data); | |
cfdb727a | 409 | |
ccc66d01 BH |
410 | Composite buttonComposite = new Composite(wildcardMainGroup, SWT.NONE); |
411 | layout = new GridLayout(1, false); | |
412 | buttonComposite.setLayout(layout); | |
413 | data = new GridData(SWT.BEGINNING, SWT.CENTER, false, true); | |
414 | buttonComposite.setLayoutData(data); | |
415 | ||
416 | fWildcardActivateButton = new Button(buttonComposite, SWT.RADIO); | |
417 | fWildcardActivateButton.setText(Messages.TraceControl_EnableGroupSelectionName); | |
418 | fWildcardActivateButton.setSelection(false); | |
419 | data = new GridData(GridData.FILL_HORIZONTAL); | |
420 | fWildcardActivateButton.setLayoutData(data); | |
421 | fWildcardActivateButton.addSelectionListener(new SelectionAdapter() { | |
422 | @Override | |
423 | public void widgetSelected(SelectionEvent e) { | |
424 | setEnablements(GroupEnum.WILDCARD); | |
425 | } | |
426 | }); | |
cfdb727a | 427 | |
ccc66d01 BH |
428 | Group wildcardGroup = new Group(wildcardMainGroup, SWT.SHADOW_NONE); |
429 | layout = new GridLayout(3, true); | |
430 | wildcardGroup.setLayout(layout); | |
431 | data = new GridData(GridData.FILL_HORIZONTAL); | |
432 | wildcardGroup.setLayoutData(data); | |
cfdb727a | 433 | |
ccc66d01 BH |
434 | Label wildcardLabel = new Label(wildcardGroup, SWT.LEFT); |
435 | wildcardLabel.setText(Messages.TraceControl_EnableEventsWildcardLabel); | |
436 | data = new GridData(GridData.FILL_HORIZONTAL); | |
437 | data.horizontalSpan = 1; | |
438 | wildcardLabel.setLayoutData(data); | |
cfdb727a | 439 | |
ccc66d01 BH |
440 | fWildcardText = new Text(wildcardGroup, SWT.LEFT); |
441 | fWildcardText.setToolTipText(Messages.TraceControl_EnableEventsWildcardTooltip); | |
442 | data = new GridData(GridData.FILL_HORIZONTAL); | |
443 | data.horizontalSpan = 2; | |
444 | fWildcardText.setLayoutData(data); | |
445 | } | |
cfdb727a | 446 | |
ccc66d01 BH |
447 | /** |
448 | * Creates log level group. | |
449 | */ | |
450 | private void createLogLevelGroup() { | |
451 | Group logLevelMainGroup = new Group(this, SWT.SHADOW_NONE); | |
452 | logLevelMainGroup.setText(Messages.TraceControl_EnableEventsLogLevelGroupName); | |
453 | GridLayout layout = new GridLayout(2, false); | |
454 | logLevelMainGroup.setLayout(layout); | |
455 | GridData data = new GridData(GridData.FILL_HORIZONTAL); | |
456 | logLevelMainGroup.setLayoutData(data); | |
cfdb727a | 457 | |
ccc66d01 BH |
458 | Composite buttonComposite = new Composite(logLevelMainGroup, SWT.NONE); |
459 | layout = new GridLayout(1, false); | |
460 | buttonComposite.setLayout(layout); | |
461 | data = new GridData(SWT.BEGINNING, SWT.CENTER, false, true); | |
462 | buttonComposite.setLayoutData(data); | |
463 | ||
464 | fLogLevelActivateButton = new Button(buttonComposite, SWT.RADIO); | |
465 | fLogLevelActivateButton.setText(Messages.TraceControl_EnableGroupSelectionName); | |
466 | fLogLevelActivateButton.setSelection(false); | |
467 | data = new GridData(GridData.FILL_HORIZONTAL); | |
468 | fLogLevelActivateButton.setLayoutData(data); | |
469 | fLogLevelActivateButton.addSelectionListener(new SelectionAdapter() { | |
470 | @Override | |
471 | public void widgetSelected(SelectionEvent e) { | |
472 | setEnablements(GroupEnum.LOGLEVEL); | |
473 | } | |
474 | }); | |
475 | ||
476 | Group logLevelGroup = new Group(logLevelMainGroup, SWT.SHADOW_NONE); | |
477 | layout = new GridLayout(3, true); | |
478 | logLevelGroup.setLayout(layout); | |
479 | logLevelGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); | |
480 | ||
481 | Label logLevelEventNameLabel = new Label(logLevelGroup, SWT.LEFT); | |
482 | logLevelEventNameLabel.setText(Messages.TraceControl_EnableEventsEventNameLabel); | |
483 | ||
484 | data = new GridData(GridData.FILL_BOTH); | |
485 | data.horizontalSpan = 1; | |
486 | logLevelEventNameLabel.setLayoutData(data); | |
487 | ||
488 | fLogLevelEventNameText = new Text(logLevelGroup, SWT.LEFT); | |
489 | fLogLevelEventNameText.setToolTipText(Messages.TraceControl_EnableEventsLoglevelEventNameTooltip); | |
490 | data = new GridData(GridData.FILL_BOTH); | |
491 | data.horizontalSpan = 2; | |
492 | fLogLevelEventNameText.setLayoutData(data); | |
493 | ||
494 | TraceLogLevel[] levels = TraceLogLevel.values(); | |
cfdb727a | 495 | |
ccc66d01 BH |
496 | String[] levelNames = new String[levels.length - 1]; |
497 | int k = 0; | |
498 | for (int i = 0; i < levels.length; i++) { | |
499 | if (levels[i] != TraceLogLevel.LEVEL_UNKNOWN) { | |
500 | levelNames[k++] = levels[i].getInName(); | |
501 | } | |
502 | } | |
503 | ||
504 | fLogLevelCombo = new CCombo(logLevelGroup, SWT.READ_ONLY); | |
505 | fLogLevelCombo.setItems(levelNames); | |
506 | fLogLevelCombo.setToolTipText(Messages.TraceControl_EnableEventsLogLevelTooltip); | |
507 | data = new GridData(GridData.FILL_HORIZONTAL); | |
508 | data.horizontalSpan = 4; | |
509 | fLogLevelCombo.setLayoutData(data); | |
510 | ||
511 | fLogLevelButton = new Button(logLevelGroup, SWT.RADIO); | |
512 | fLogLevelButton.setText(Messages.TraceControl_EnableEventsLogLevelTypeName); | |
513 | fLogLevelButton.setToolTipText(Messages.TraceControl_EnableEventsLogLevelTypeTooltip); | |
514 | data = new GridData(GridData.FILL_BOTH); | |
515 | fLogLevelButton.setLayoutData(data); | |
23839724 | 516 | fLogLevelButton.setSelection(true); |
ccc66d01 BH |
517 | |
518 | fLogLevelOnlyButton = new Button(logLevelGroup, SWT.RADIO); | |
519 | fLogLevelOnlyButton.setText(Messages.TraceControl_EnableEventsLogLevelOnlyTypeName); | |
520 | fLogLevelOnlyButton.setToolTipText(Messages.TraceControl_EnableEventsLogLevelOnlyTypeTooltip); | |
521 | data = new GridData(GridData.FILL_BOTH); | |
522 | fLogLevelButton.setLayoutData(data); | |
523 | } | |
cfdb727a | 524 | |
d4514365 BH |
525 | void createFilterGroup() { |
526 | if (fProviderGroup.isEventFilteringSupported()) { | |
527 | Group filterMainGroup = new Group(this, SWT.SHADOW_NONE); | |
528 | filterMainGroup.setText(Messages.TraceControl_EnableEventsFilterGroupName); | |
529 | GridLayout layout = new GridLayout(3, false); | |
530 | filterMainGroup.setLayout(layout); | |
531 | GridData data = new GridData(GridData.FILL_HORIZONTAL); | |
532 | filterMainGroup.setLayoutData(data); | |
533 | ||
534 | fFilterText = new Text(filterMainGroup, SWT.LEFT); | |
535 | fFilterText.setToolTipText(Messages.TraceControl_EnableEventsFilterTooltip); | |
536 | data = new GridData(GridData.FILL_HORIZONTAL); | |
537 | fFilterText.setLayoutData(data); | |
538 | } | |
539 | } | |
540 | ||
ccc66d01 BH |
541 | /** |
542 | * Enable/selects widgets depending on the group specified. | |
543 | * @param group - group to enable. | |
544 | */ | |
545 | private void setEnablements(GroupEnum group) { | |
cfdb727a | 546 | |
ccc66d01 BH |
547 | // Enable/disable trace point items |
548 | fTracepointsActivateButton.setSelection(group == GroupEnum.TRACEPOINTS); | |
549 | fTracepointsViewer.getTree().setEnabled(group == GroupEnum.TRACEPOINTS); | |
cfdb727a | 550 | |
ccc66d01 BH |
551 | // Enable/disable wildcard items |
552 | fWildcardActivateButton.setSelection(group == GroupEnum.WILDCARD); | |
553 | fWildcardText.setEnabled(group == GroupEnum.WILDCARD); | |
554 | ||
555 | // Enable/disable log level items | |
556 | fLogLevelActivateButton.setSelection(group == GroupEnum.LOGLEVEL); | |
557 | fLogLevelEventNameText.setEnabled(group == GroupEnum.LOGLEVEL); | |
558 | fLogLevelCombo.setEnabled(group == GroupEnum.LOGLEVEL); | |
559 | fLogLevelButton.setEnabled(group == GroupEnum.LOGLEVEL); | |
560 | fLogLevelOnlyButton.setEnabled(group == GroupEnum.LOGLEVEL); | |
561 | } | |
562 | ||
563 | // ------------------------------------------------------------------------ | |
564 | // Local classes | |
565 | // ------------------------------------------------------------------------ | |
566 | /** | |
cfdb727a | 567 | * Content provider for the tracepoints tree. |
ccc66d01 | 568 | */ |
77735e82 | 569 | public static final class UstContentProvider extends TraceControlContentProvider { |
ccc66d01 BH |
570 | @Override |
571 | public Object[] getChildren(Object parentElement) { | |
572 | if (parentElement instanceof TargetNodeComponent) { | |
573 | List<ITraceControlComponent> children = ((ITraceControlComponent)parentElement).getChildren(TraceProviderGroup.class); | |
cfdb727a | 574 | return children.toArray(new ITraceControlComponent[children.size()]); |
ccc66d01 BH |
575 | } |
576 | if (parentElement instanceof TraceProviderGroup) { | |
577 | List<ITraceControlComponent> children = ((ITraceControlComponent)parentElement).getChildren(UstProviderComponent.class); | |
cfdb727a | 578 | return children.toArray(new ITraceControlComponent[children.size()]); |
ccc66d01 BH |
579 | } |
580 | if (parentElement instanceof ITraceControlComponent) { | |
581 | return ((ITraceControlComponent)parentElement).getChildren(); | |
582 | } | |
583 | return new Object[0]; | |
584 | } | |
585 | } | |
cfdb727a | 586 | |
ccc66d01 | 587 | /** |
cfdb727a | 588 | * Content label for the tracepoints tree. |
ccc66d01 | 589 | */ |
77735e82 | 590 | public static final class UstLabelProvider extends TraceControlLabelProvider { |
ccc66d01 BH |
591 | @Override |
592 | public Image getImage(Object element) { | |
593 | return null; | |
594 | } | |
595 | @Override | |
596 | public String getText(Object element) { | |
597 | if ((element != null) && (element instanceof TraceProviderGroup)) { | |
598 | return Messages.TraceControl_EnableEventsTracepointTreeAllLabel; | |
599 | } | |
600 | ||
601 | if ((element != null) && (element instanceof UstProviderComponent)) { | |
602 | return Messages.TraceControl_EnableEventsTracepointTreeAllLabel + " - " + ((UstProviderComponent)element).getName(); //$NON-NLS-1$ | |
603 | } | |
604 | return super.getText(element); | |
605 | } | |
606 | } | |
607 | ||
608 | /** | |
cfdb727a | 609 | * Check state listener for the tracepoints tree. |
ccc66d01 | 610 | */ |
77735e82 | 611 | public final class UstCheckStateListener implements ICheckStateListener { |
ccc66d01 BH |
612 | @Override |
613 | public void checkStateChanged(CheckStateChangedEvent event) { | |
614 | if (event.getChecked()) { | |
615 | if (event.getElement() instanceof TraceProviderGroup) { | |
616 | fTracepointsViewer.setSubtreeChecked(event.getElement(), true); | |
617 | } | |
618 | if (event.getElement() instanceof UstProviderComponent) { | |
619 | fTracepointsViewer.setSubtreeChecked(event.getElement(), true); | |
cfdb727a | 620 | } |
ccc66d01 BH |
621 | } else { |
622 | if (event.getElement() instanceof TraceProviderGroup) { | |
623 | fTracepointsViewer.setSubtreeChecked(event.getElement(), true); | |
624 | } | |
625 | if (event.getElement() instanceof UstProviderComponent) { | |
626 | ITraceControlComponent component = (ITraceControlComponent) event.getElement(); | |
627 | fTracepointsViewer.setSubtreeChecked(event.getElement(), false); | |
628 | fTracepointsViewer.setChecked(component.getParent(), false); | |
629 | } else { | |
630 | ITraceControlComponent component = (ITraceControlComponent) event.getElement(); | |
631 | fTracepointsViewer.setChecked(component.getParent(), false); | |
632 | fTracepointsViewer.setChecked(component.getParent().getParent(), false); | |
633 | } | |
634 | } | |
635 | } | |
636 | } | |
637 | } |