| 1 | /********************************************************************** |
| 2 | * Copyright (c) 2012, 2013 Ericsson |
| 3 | * |
| 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 |
| 8 | * |
| 9 | * Contributors: |
| 10 | * Bernd Hufmann - Initial API and implementation |
| 11 | * Bernd Hufmann - Updated for support of LTTng Tools 2.1 |
| 12 | **********************************************************************/ |
| 13 | package org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs; |
| 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; |
| 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; |
| 27 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent; |
| 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; |
| 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; |
| 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; |
| 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 | /** |
| 48 | * <p> |
| 49 | * A composite for collecting information about UST events to be enabled. |
| 50 | * </p> |
| 51 | * |
| 52 | * @author Bernd Hufmann |
| 53 | */ |
| 54 | public class EnableUstEventsComposite extends Composite implements IEnableUstEvents { |
| 55 | |
| 56 | // ------------------------------------------------------------------------ |
| 57 | // Constants |
| 58 | // ------------------------------------------------------------------------ |
| 59 | |
| 60 | private enum GroupEnum { TRACEPOINTS, WILDCARD, LOGLEVEL } |
| 61 | |
| 62 | // ------------------------------------------------------------------------ |
| 63 | // Attributes |
| 64 | // ------------------------------------------------------------------------ |
| 65 | |
| 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; |
| 102 | /** |
| 103 | * The filter text |
| 104 | */ |
| 105 | private Text fFilterText; |
| 106 | |
| 107 | /** |
| 108 | * The referenced trace provider group containing the UST providers |
| 109 | * component which contains a list of available tracepoints. |
| 110 | */ |
| 111 | private final TraceProviderGroup fProviderGroup; |
| 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 | /** |
| 125 | * The flag indicating that all wildcard are selected.. |
| 126 | */ |
| 127 | private boolean fIsWildcard; |
| 128 | /** |
| 129 | * The wildcard if wildcard is selected. |
| 130 | */ |
| 131 | private String fWildcard; |
| 132 | /** |
| 133 | *The flag indicating that all log level are selected. |
| 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; |
| 148 | /** |
| 149 | * The filter expression |
| 150 | */ |
| 151 | private String fFilterExpression; |
| 152 | |
| 153 | // ------------------------------------------------------------------------ |
| 154 | // Constructors |
| 155 | // ------------------------------------------------------------------------ |
| 156 | /** |
| 157 | * Constructor |
| 158 | * @param parent - a parent composite |
| 159 | * @param style - a composite style |
| 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 | |
| 171 | @Override |
| 172 | public boolean isTracepoints() { |
| 173 | return fIsTracepoints; |
| 174 | } |
| 175 | |
| 176 | @Override |
| 177 | public boolean isAllTracePoints() { |
| 178 | return fIsAllTracepoints; |
| 179 | } |
| 180 | |
| 181 | @Override |
| 182 | public List<String> getEventNames() { |
| 183 | return new ArrayList<>(fSelectedEvents); |
| 184 | } |
| 185 | |
| 186 | @Override |
| 187 | public boolean isWildcard() { |
| 188 | return fIsWildcard; |
| 189 | } |
| 190 | |
| 191 | @Override |
| 192 | public String getWildcard() { |
| 193 | return fWildcard; |
| 194 | } |
| 195 | |
| 196 | @Override |
| 197 | public boolean isLogLevel() { |
| 198 | return fIsLogLevel; |
| 199 | } |
| 200 | |
| 201 | @Override |
| 202 | public LogLevelType getLogLevelType() { |
| 203 | return fLogLevelType; |
| 204 | } |
| 205 | |
| 206 | @Override |
| 207 | public TraceLogLevel getLogLevel() { |
| 208 | return fLogLevel; |
| 209 | } |
| 210 | |
| 211 | @Override |
| 212 | public String getLogLevelEventName() { |
| 213 | return fLogLevelEventName; |
| 214 | } |
| 215 | |
| 216 | @Override |
| 217 | public String getFilterExpression() { |
| 218 | return fFilterExpression; |
| 219 | } |
| 220 | |
| 221 | // ------------------------------------------------------------------------ |
| 222 | // Operations |
| 223 | // ------------------------------------------------------------------------ |
| 224 | |
| 225 | /** |
| 226 | * Create the contents of this event composite |
| 227 | */ |
| 228 | public void createContent() { |
| 229 | |
| 230 | // Tracepoints Group |
| 231 | createTracepointsGroup(); |
| 232 | |
| 233 | // Wildcard Group |
| 234 | createWildCardGroup(); |
| 235 | |
| 236 | // Log Level Group |
| 237 | createLogLevelGroup(); |
| 238 | |
| 239 | // Filter Group |
| 240 | createFilterGroup(); |
| 241 | |
| 242 | // Set default enablements |
| 243 | setEnablements(GroupEnum.TRACEPOINTS); |
| 244 | } |
| 245 | |
| 246 | /** |
| 247 | * Validates the UST composite input data. |
| 248 | * |
| 249 | * @return true if configured data is valid and can be retrieved. |
| 250 | */ |
| 251 | public boolean isValid() { |
| 252 | |
| 253 | fIsTracepoints = fTracepointsActivateButton.getSelection(); |
| 254 | fIsWildcard = fWildcardActivateButton.getSelection(); |
| 255 | fIsLogLevel = fLogLevelActivateButton.getSelection(); |
| 256 | |
| 257 | // initialize tracepoint fields |
| 258 | fIsAllTracepoints = false; |
| 259 | fSelectedEvents = new ArrayList<>(); |
| 260 | if (fIsTracepoints) { |
| 261 | fIsAllTracepoints = fTracepointsViewer.getChecked(fProviderGroup); |
| 262 | Set<String> set = new HashSet<>(); |
| 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 | } |
| 270 | } |
| 271 | } |
| 272 | |
| 273 | // initialize log level event name string |
| 274 | fLogLevelType = LogLevelType.LOGLEVEL_NONE; |
| 275 | fLogLevelEventName = null; |
| 276 | |
| 277 | if (fIsLogLevel) { |
| 278 | if (fLogLevelButton.getSelection()) { |
| 279 | fLogLevelType = LogLevelType.LOGLEVEL; |
| 280 | } else if (fLogLevelOnlyButton.getSelection()) { |
| 281 | fLogLevelType = LogLevelType.LOGLEVEL_ONLY; |
| 282 | } |
| 283 | |
| 284 | String temp = fLogLevelEventNameText.getText(); |
| 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$ |
| 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 | |
| 295 | fLogLevelEventName = temp; |
| 296 | |
| 297 | TraceLogLevel[] levels = TraceLogLevel.values(); |
| 298 | int id = fLogLevelCombo.getSelectionIndex(); |
| 299 | |
| 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; |
| 306 | } |
| 307 | fLogLevel = levels[id]; |
| 308 | } |
| 309 | |
| 310 | // initialize wildcard with null |
| 311 | fWildcard = null; |
| 312 | if (fIsWildcard) { |
| 313 | String tempWildcard = fWildcardText.getText(); |
| 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$ |
| 317 | MessageDialog.openError(getShell(), |
| 318 | Messages.TraceControl_EnableEventsDialogTitle, |
| 319 | Messages.TraceControl_InvalidWildcardError + " (" + tempWildcard + ") \n"); //$NON-NLS-1$ //$NON-NLS-2$ |
| 320 | |
| 321 | return false; |
| 322 | } |
| 323 | |
| 324 | fWildcard = tempWildcard; |
| 325 | } |
| 326 | |
| 327 | // initialize filter with null |
| 328 | fFilterExpression = null; |
| 329 | if (fProviderGroup.isEventFilteringSupported()) { |
| 330 | String tempFilter = fFilterText.getText(); |
| 331 | |
| 332 | if(!tempFilter.isEmpty() && !tempFilter.matches("\\s*")) { //$NON-NLS-1$ |
| 333 | fFilterExpression = tempFilter; |
| 334 | } |
| 335 | } |
| 336 | |
| 337 | // validation successful -> call super.okPressed() |
| 338 | return true; |
| 339 | } |
| 340 | |
| 341 | // ------------------------------------------------------------------------ |
| 342 | // Helper methods |
| 343 | // ------------------------------------------------------------------------ |
| 344 | |
| 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); |
| 355 | |
| 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 | }); |
| 372 | |
| 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); |
| 378 | |
| 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 | } |
| 389 | |
| 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); |
| 400 | |
| 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 | }); |
| 418 | |
| 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); |
| 424 | |
| 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); |
| 430 | |
| 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 | } |
| 437 | |
| 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); |
| 448 | |
| 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(); |
| 486 | |
| 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); |
| 507 | fLogLevelButton.setSelection(true); |
| 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 | } |
| 515 | |
| 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 | |
| 532 | /** |
| 533 | * Enable/selects widgets depending on the group specified. |
| 534 | * @param group - group to enable. |
| 535 | */ |
| 536 | private void setEnablements(GroupEnum group) { |
| 537 | |
| 538 | // Enable/disable trace point items |
| 539 | fTracepointsActivateButton.setSelection(group == GroupEnum.TRACEPOINTS); |
| 540 | fTracepointsViewer.getTree().setEnabled(group == GroupEnum.TRACEPOINTS); |
| 541 | |
| 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 | /** |
| 558 | * Content provider for the tracepoints tree. |
| 559 | */ |
| 560 | public static final class UstContentProvider extends TraceControlContentProvider { |
| 561 | @Override |
| 562 | public Object[] getChildren(Object parentElement) { |
| 563 | if (parentElement instanceof TargetNodeComponent) { |
| 564 | List<ITraceControlComponent> children = ((ITraceControlComponent)parentElement).getChildren(TraceProviderGroup.class); |
| 565 | return children.toArray(new ITraceControlComponent[children.size()]); |
| 566 | } |
| 567 | if (parentElement instanceof TraceProviderGroup) { |
| 568 | List<ITraceControlComponent> children = ((ITraceControlComponent)parentElement).getChildren(UstProviderComponent.class); |
| 569 | return children.toArray(new ITraceControlComponent[children.size()]); |
| 570 | } |
| 571 | if (parentElement instanceof ITraceControlComponent) { |
| 572 | return ((ITraceControlComponent)parentElement).getChildren(); |
| 573 | } |
| 574 | return new Object[0]; |
| 575 | } |
| 576 | } |
| 577 | |
| 578 | /** |
| 579 | * Content label for the tracepoints tree. |
| 580 | */ |
| 581 | public static final class UstLabelProvider extends TraceControlLabelProvider { |
| 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 | /** |
| 600 | * Check state listener for the tracepoints tree. |
| 601 | */ |
| 602 | public final class UstCheckStateListener implements ICheckStateListener { |
| 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); |
| 611 | } |
| 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 | } |