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