| 1 | /********************************************************************** |
| 2 | * Copyright (c) 2012, 2014 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 | **********************************************************************/ |
| 12 | package org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs; |
| 13 | |
| 14 | import java.util.ArrayList; |
| 15 | import java.util.List; |
| 16 | |
| 17 | import org.eclipse.jface.dialogs.MessageDialog; |
| 18 | import org.eclipse.jface.viewers.CheckStateChangedEvent; |
| 19 | import org.eclipse.jface.viewers.CheckboxTreeViewer; |
| 20 | import org.eclipse.jface.viewers.ICheckStateListener; |
| 21 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.messages.Messages; |
| 22 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent; |
| 23 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.BaseEventComponent; |
| 24 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.KernelProviderComponent; |
| 25 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceControlContentProvider; |
| 26 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceControlLabelProvider; |
| 27 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceProviderGroup; |
| 28 | import org.eclipse.swt.SWT; |
| 29 | import org.eclipse.swt.events.SelectionAdapter; |
| 30 | import org.eclipse.swt.events.SelectionEvent; |
| 31 | import org.eclipse.swt.graphics.Image; |
| 32 | import org.eclipse.swt.layout.GridData; |
| 33 | import org.eclipse.swt.layout.GridLayout; |
| 34 | import org.eclipse.swt.widgets.Button; |
| 35 | import org.eclipse.swt.widgets.Composite; |
| 36 | import org.eclipse.swt.widgets.Group; |
| 37 | import org.eclipse.swt.widgets.Label; |
| 38 | import org.eclipse.swt.widgets.Text; |
| 39 | |
| 40 | /** |
| 41 | * <p> |
| 42 | * A composite for collecting information about kernel events to be enabled. |
| 43 | * </p> |
| 44 | * |
| 45 | * @author Bernd Hufmann |
| 46 | */ |
| 47 | public class EnableKernelEventComposite extends Composite implements IEnableKernelEvents { |
| 48 | |
| 49 | // ------------------------------------------------------------------------ |
| 50 | // Constants |
| 51 | // ------------------------------------------------------------------------ |
| 52 | private enum KernelGroupEnum { TRACEPOINTS, SYSCALLS, PROBE, FUNCTION } |
| 53 | |
| 54 | // ------------------------------------------------------------------------ |
| 55 | // Attributes |
| 56 | // ------------------------------------------------------------------------ |
| 57 | |
| 58 | /** |
| 59 | * A button to enable/disable the tracepoints group |
| 60 | */ |
| 61 | private Button fTracepointsActivateButton; |
| 62 | /** |
| 63 | * A tree viewer for displaying and selection of available tracepoints. |
| 64 | */ |
| 65 | private CheckboxTreeViewer fTracepointsViewer; |
| 66 | /** |
| 67 | * A button to enable/disable the syscalls group |
| 68 | */ |
| 69 | private Button fSysCallsActivateButton; |
| 70 | /** |
| 71 | * A button to enable or disable the dynamic probe group. |
| 72 | */ |
| 73 | private Button fProbeActivateButton; |
| 74 | /** |
| 75 | * The text field for the event name for the dynamic probe. |
| 76 | */ |
| 77 | private Text fProbeEventNameText; |
| 78 | /** |
| 79 | * The text field for the dynamic probe. |
| 80 | */ |
| 81 | private Text fProbeText; |
| 82 | /** |
| 83 | * A button to enable or disable the dynamic function probe group. |
| 84 | */ |
| 85 | private Button fFunctionActivateButton; |
| 86 | /** |
| 87 | * The text field for the event name for the dynamic probe. |
| 88 | */ |
| 89 | private Text fFunctionEventNameText; |
| 90 | /** |
| 91 | * The text field for the dynamic function entry/return probe. |
| 92 | */ |
| 93 | private Text fFunctionText; |
| 94 | /** |
| 95 | * The referenced trace provider group containing the kernel provider |
| 96 | * component which contains a list of available tracepoints. |
| 97 | */ |
| 98 | private final TraceProviderGroup fProviderGroup; |
| 99 | /** |
| 100 | * The flag indicating that tracepoints are selected. |
| 101 | */ |
| 102 | private boolean fIsTracepoints; |
| 103 | /** |
| 104 | * The flag indicating that all tracepoints are selected. |
| 105 | */ |
| 106 | private boolean fIsAllTracepoints; |
| 107 | /** |
| 108 | * The flag indicating that syscalls are selected. |
| 109 | */ |
| 110 | private boolean fIsSysCalls; |
| 111 | /** |
| 112 | * The list of tracepoints to be enabled. |
| 113 | */ |
| 114 | private List<String> fSelectedEvents; |
| 115 | /** |
| 116 | * The flag indicating that dynamic probe is selected. |
| 117 | */ |
| 118 | private boolean fIsDynamicProbe; |
| 119 | /** |
| 120 | * The event name of the dynamic probe. |
| 121 | */ |
| 122 | private String fProbeEventName; |
| 123 | /** |
| 124 | * The dynamic probe. |
| 125 | */ |
| 126 | private String fProbeString; |
| 127 | /** |
| 128 | * The flag indicating that the dynamic function probe is selected. |
| 129 | */ |
| 130 | private boolean fIsDynamicFunctionProbe; |
| 131 | /** |
| 132 | * The event name of the dynamic function entry/return probe. |
| 133 | */ |
| 134 | private String fFunctionEventName; |
| 135 | /** |
| 136 | * The dynamic function entry/return probe. |
| 137 | */ |
| 138 | private String fFunctionString; |
| 139 | |
| 140 | // ------------------------------------------------------------------------ |
| 141 | // Constructors |
| 142 | // ------------------------------------------------------------------------ |
| 143 | |
| 144 | /** |
| 145 | * Constructor |
| 146 | * |
| 147 | * @param parent |
| 148 | * The parent composite |
| 149 | * @param style |
| 150 | * The index of the style for this event composite |
| 151 | * @param providerGroup |
| 152 | * The trace provider group |
| 153 | */ |
| 154 | public EnableKernelEventComposite(Composite parent, int style, TraceProviderGroup providerGroup) { |
| 155 | super(parent, style); |
| 156 | fProviderGroup = providerGroup; |
| 157 | } |
| 158 | |
| 159 | // ------------------------------------------------------------------------ |
| 160 | // Acessors |
| 161 | // ------------------------------------------------------------------------ |
| 162 | |
| 163 | @Override |
| 164 | public boolean isTracepoints() { |
| 165 | return fIsTracepoints; |
| 166 | } |
| 167 | |
| 168 | @Override |
| 169 | public boolean isAllTracePoints() { |
| 170 | return fIsAllTracepoints; |
| 171 | } |
| 172 | |
| 173 | @Override |
| 174 | public boolean isSysCalls() { |
| 175 | return fIsSysCalls; |
| 176 | } |
| 177 | |
| 178 | @Override |
| 179 | public boolean isAllSysCalls() { |
| 180 | return fIsSysCalls; |
| 181 | } |
| 182 | |
| 183 | @Override |
| 184 | public List<String> getEventNames() { |
| 185 | return new ArrayList<>(fSelectedEvents); |
| 186 | } |
| 187 | |
| 188 | @Override |
| 189 | public boolean isDynamicProbe() { |
| 190 | return fIsDynamicProbe; |
| 191 | } |
| 192 | |
| 193 | @Override |
| 194 | public String getProbeName() { |
| 195 | return fProbeString; |
| 196 | } |
| 197 | |
| 198 | @Override |
| 199 | public String getProbeEventName() { |
| 200 | return fProbeEventName; |
| 201 | } |
| 202 | |
| 203 | @Override |
| 204 | public boolean isDynamicFunctionProbe() { |
| 205 | return fIsDynamicFunctionProbe; |
| 206 | } |
| 207 | |
| 208 | @Override |
| 209 | public String getFunctionEventName() { |
| 210 | return fFunctionEventName; |
| 211 | } |
| 212 | |
| 213 | @Override |
| 214 | public String getFunction() { |
| 215 | return fFunctionString; |
| 216 | } |
| 217 | |
| 218 | // ------------------------------------------------------------------------ |
| 219 | // Operations |
| 220 | // ------------------------------------------------------------------------ |
| 221 | |
| 222 | /** |
| 223 | * Creates the composite content |
| 224 | */ |
| 225 | public void createContent() { |
| 226 | |
| 227 | // Tracepoints Group |
| 228 | createTracepointsGroup(); |
| 229 | |
| 230 | // Syscalls Group |
| 231 | createSysCallsGroup(); |
| 232 | |
| 233 | // Dynamic Probe Group |
| 234 | createDynamicProbeGroup(); |
| 235 | |
| 236 | // Dynamic Function Probe Group |
| 237 | createDynamicFunctionPropeGroup(); |
| 238 | |
| 239 | // Set default enablements |
| 240 | setKernelEnablements(KernelGroupEnum.TRACEPOINTS); |
| 241 | } |
| 242 | |
| 243 | /** |
| 244 | * Validates the kernel composite input data. |
| 245 | * @return true if configured data is valid and can be retrieved. |
| 246 | */ |
| 247 | public boolean isValid() { |
| 248 | fIsTracepoints = fTracepointsActivateButton.getSelection(); |
| 249 | fIsSysCalls = fSysCallsActivateButton.getSelection(); |
| 250 | fIsDynamicProbe = fProbeActivateButton.getSelection(); |
| 251 | fIsDynamicFunctionProbe = fFunctionActivateButton.getSelection(); |
| 252 | |
| 253 | // initialize tracepoint fields |
| 254 | fIsAllTracepoints = false; |
| 255 | fSelectedEvents = new ArrayList<>(); |
| 256 | |
| 257 | if (fIsTracepoints) { |
| 258 | List<ITraceControlComponent> comps = fProviderGroup.getChildren(KernelProviderComponent.class); |
| 259 | fIsAllTracepoints = fTracepointsViewer.getChecked(comps.get(0)); |
| 260 | |
| 261 | Object[] checkedElements = fTracepointsViewer.getCheckedElements(); |
| 262 | for (int i = 0; i < checkedElements.length; i++) { |
| 263 | ITraceControlComponent component = (ITraceControlComponent)checkedElements[i]; |
| 264 | if (component instanceof BaseEventComponent) { |
| 265 | fSelectedEvents.add(component.getName()); |
| 266 | } |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | if (fIsDynamicProbe) { |
| 271 | String temp = fProbeEventNameText.getText(); |
| 272 | if (temp.isEmpty() || |
| 273 | fProbeText.getText().matches("\\s*") || //$NON-NLS-1$ |
| 274 | (!temp.matches("^[\\s]{0,}$") && !temp.matches("^[a-zA-Z0-9\\-\\_]{1,}$"))) { //$NON-NLS-1$ //$NON-NLS-2$ |
| 275 | MessageDialog.openError(getShell(), |
| 276 | Messages.TraceControl_EnableEventsDialogTitle, |
| 277 | Messages.TraceControl_InvalidProbeNameError + " (" + temp + ") \n"); //$NON-NLS-1$ //$NON-NLS-2$ |
| 278 | |
| 279 | return false; |
| 280 | } |
| 281 | |
| 282 | fProbeEventName = temp; |
| 283 | // fProbeString will be validated by lttng-tools |
| 284 | fProbeString = fProbeText.getText(); |
| 285 | } |
| 286 | |
| 287 | // initialize function string |
| 288 | fFunctionEventName = null; |
| 289 | fFunctionString = null; |
| 290 | if (fIsDynamicFunctionProbe) { |
| 291 | String functionTemp = fFunctionEventNameText.getText(); |
| 292 | if (functionTemp.isEmpty() || |
| 293 | functionTemp.matches("\\s*") || //$NON-NLS-1$ |
| 294 | (!functionTemp.matches("^[\\s]{0,}$") && !functionTemp.matches("^[a-zA-Z0-9\\-\\_]{1,}$"))) { //$NON-NLS-1$ //$NON-NLS-2$ |
| 295 | MessageDialog.openError(getShell(), |
| 296 | Messages.TraceControl_EnableEventsDialogTitle, |
| 297 | Messages.TraceControl_InvalidProbeNameError + " (" + functionTemp + ") \n"); //$NON-NLS-1$ //$NON-NLS-2$ |
| 298 | |
| 299 | return false; |
| 300 | } |
| 301 | |
| 302 | fFunctionEventName = functionTemp; |
| 303 | // fFunctionString will be validated by lttng-tools |
| 304 | fFunctionString = fFunctionText.getText(); |
| 305 | } |
| 306 | |
| 307 | return true; |
| 308 | } |
| 309 | |
| 310 | /** |
| 311 | * Creates tracepoints group. |
| 312 | */ |
| 313 | private void createTracepointsGroup() { |
| 314 | |
| 315 | GridLayout layout; |
| 316 | GridData data; |
| 317 | Group tpMainGroup = new Group(this, SWT.SHADOW_NONE); |
| 318 | tpMainGroup.setText(Messages.TraceControl_EnableEventsTracepointGroupName); |
| 319 | layout = new GridLayout(2, false); |
| 320 | tpMainGroup.setLayout(layout); |
| 321 | data = new GridData(GridData.FILL_BOTH); |
| 322 | tpMainGroup.setLayoutData(data); |
| 323 | |
| 324 | Composite buttonComposite = new Composite(tpMainGroup, SWT.NONE); |
| 325 | layout = new GridLayout(1, true); |
| 326 | buttonComposite.setLayout(layout); |
| 327 | data = new GridData(SWT.BEGINNING, SWT.CENTER, false, true); |
| 328 | buttonComposite.setLayoutData(data); |
| 329 | |
| 330 | fTracepointsActivateButton = new Button(buttonComposite, SWT.RADIO); |
| 331 | fTracepointsActivateButton.setText(Messages.TraceControl_EnableGroupSelectionName); |
| 332 | data = new GridData(GridData.FILL_HORIZONTAL); |
| 333 | fTracepointsActivateButton.setLayoutData(data); |
| 334 | fTracepointsActivateButton.addSelectionListener(new SelectionAdapter() { |
| 335 | @Override |
| 336 | public void widgetSelected(SelectionEvent e) { |
| 337 | setKernelEnablements(KernelGroupEnum.TRACEPOINTS); |
| 338 | } |
| 339 | }); |
| 340 | |
| 341 | Group tracepointsGroup = new Group(tpMainGroup, SWT.SHADOW_NONE); |
| 342 | layout = new GridLayout(1, true); |
| 343 | tracepointsGroup.setLayout(layout); |
| 344 | data = new GridData(GridData.FILL_BOTH); |
| 345 | tracepointsGroup.setLayoutData(data); |
| 346 | |
| 347 | fTracepointsViewer = new CheckboxTreeViewer(tracepointsGroup, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); |
| 348 | fTracepointsViewer.getTree().setToolTipText(Messages.TraceControl_EnableEventsTracepointTreeTooltip); |
| 349 | |
| 350 | fTracepointsViewer.setContentProvider(new KernelContentProvider()); |
| 351 | fTracepointsViewer.setLabelProvider(new KernelLabelProvider()); |
| 352 | fTracepointsViewer.addCheckStateListener(new KernelCheckListener()); |
| 353 | fTracepointsViewer.setInput(fProviderGroup); |
| 354 | |
| 355 | fTracepointsViewer.getTree().setLayoutData(new GridData(GridData.FILL_BOTH)); |
| 356 | } |
| 357 | |
| 358 | /** |
| 359 | * Creates syscalls group. |
| 360 | */ |
| 361 | private void createSysCallsGroup() { |
| 362 | GridLayout layout; |
| 363 | GridData data; |
| 364 | Group sysCallsMainGroup = new Group(this, SWT.SHADOW_NONE); |
| 365 | sysCallsMainGroup.setText(Messages.TraceControl_EnableEventsSyscallName); |
| 366 | sysCallsMainGroup.setToolTipText(Messages.TraceControl_EnableEventsSyscallTooltip); |
| 367 | layout = new GridLayout(2, false); |
| 368 | sysCallsMainGroup.setLayout(layout); |
| 369 | data = new GridData(GridData.FILL_HORIZONTAL); |
| 370 | sysCallsMainGroup.setLayoutData(data); |
| 371 | |
| 372 | Composite buttonComposite = new Composite(sysCallsMainGroup, SWT.NONE); |
| 373 | layout = new GridLayout(1, false); |
| 374 | buttonComposite.setLayout(layout); |
| 375 | data = new GridData(SWT.BEGINNING, SWT.CENTER, false, true); |
| 376 | buttonComposite.setLayoutData(data); |
| 377 | |
| 378 | fSysCallsActivateButton = new Button(buttonComposite, SWT.RADIO); |
| 379 | fSysCallsActivateButton.setText(Messages.TraceControl_EnableGroupSelectionName); |
| 380 | fSysCallsActivateButton.setToolTipText(Messages.TraceControl_EnableEventsSyscallTooltip); |
| 381 | fSysCallsActivateButton.setSelection(false); |
| 382 | data = new GridData(GridData.FILL_HORIZONTAL); |
| 383 | fSysCallsActivateButton.setLayoutData(data); |
| 384 | fSysCallsActivateButton.addSelectionListener(new SelectionAdapter() { |
| 385 | @Override |
| 386 | public void widgetSelected(SelectionEvent e) { |
| 387 | setKernelEnablements(KernelGroupEnum.SYSCALLS); |
| 388 | } |
| 389 | }); |
| 390 | } |
| 391 | |
| 392 | /** |
| 393 | * Creates dynamic probe group. |
| 394 | */ |
| 395 | private void createDynamicProbeGroup() { |
| 396 | GridLayout layout; |
| 397 | GridData data; |
| 398 | Group probeMainGroup = new Group(this, SWT.SHADOW_NONE); |
| 399 | probeMainGroup.setText(Messages.TraceControl_EnableEventsProbeGroupName); |
| 400 | layout = new GridLayout(2, false); |
| 401 | probeMainGroup.setLayout(layout); |
| 402 | data = new GridData(GridData.FILL_HORIZONTAL); |
| 403 | probeMainGroup.setLayoutData(data); |
| 404 | |
| 405 | Composite buttonComposite = new Composite(probeMainGroup, SWT.NONE); |
| 406 | layout = new GridLayout(1, false); |
| 407 | buttonComposite.setLayout(layout); |
| 408 | data = new GridData(SWT.BEGINNING, SWT.CENTER, false, true); |
| 409 | buttonComposite.setLayoutData(data); |
| 410 | |
| 411 | fProbeActivateButton = new Button(buttonComposite, SWT.RADIO); |
| 412 | fProbeActivateButton.setText(Messages.TraceControl_EnableGroupSelectionName); |
| 413 | fProbeActivateButton.setSelection(false); |
| 414 | data = new GridData(GridData.FILL_HORIZONTAL); |
| 415 | fProbeActivateButton.setLayoutData(data); |
| 416 | fProbeActivateButton.addSelectionListener(new SelectionAdapter() { |
| 417 | @Override |
| 418 | public void widgetSelected(SelectionEvent e) { |
| 419 | setKernelEnablements(KernelGroupEnum.PROBE); |
| 420 | } |
| 421 | }); |
| 422 | |
| 423 | Group probeGroup = new Group(probeMainGroup, SWT.SHADOW_NONE); |
| 424 | layout = new GridLayout(4, true); |
| 425 | probeGroup.setLayout(layout); |
| 426 | probeGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); |
| 427 | |
| 428 | Label probeNameLabel = new Label(probeGroup, SWT.LEFT); |
| 429 | probeNameLabel.setText(Messages.TraceControl_EnableEventsEventNameLabel); |
| 430 | data = new GridData(GridData.FILL_BOTH); |
| 431 | data.horizontalSpan = 1; |
| 432 | probeNameLabel.setLayoutData(data); |
| 433 | |
| 434 | fProbeEventNameText = new Text(probeGroup, SWT.LEFT); |
| 435 | fProbeEventNameText.setToolTipText(Messages.TraceControl_EnableEventsProbeEventNameTooltip); |
| 436 | |
| 437 | data = new GridData(GridData.FILL_BOTH); |
| 438 | data.horizontalSpan = 3; |
| 439 | fProbeEventNameText.setLayoutData(data); |
| 440 | |
| 441 | Label probeLabel = new Label(probeGroup, SWT.LEFT); |
| 442 | probeLabel.setText(Messages.TraceControl_EnableEventsProbeNameLabel); |
| 443 | data = new GridData(GridData.FILL_BOTH); |
| 444 | data.horizontalSpan = 1; |
| 445 | probeLabel.setLayoutData(data); |
| 446 | |
| 447 | fProbeText = new Text(probeGroup, SWT.LEFT); |
| 448 | fProbeText.setToolTipText(Messages.TraceControl_EnableEventsProbeNameTooltip); |
| 449 | data = new GridData(GridData.FILL_BOTH); |
| 450 | data.horizontalSpan = 3; |
| 451 | fProbeText.setLayoutData(data); |
| 452 | } |
| 453 | |
| 454 | /** |
| 455 | * Creates dynamic function entry/return probe group. |
| 456 | */ |
| 457 | private void createDynamicFunctionPropeGroup() { |
| 458 | GridLayout layout; |
| 459 | GridData data; |
| 460 | Group functionMainGroup = new Group(this, SWT.SHADOW_NONE); |
| 461 | functionMainGroup.setText(Messages.TraceControl_EnableEventsFucntionGroupName); |
| 462 | layout = new GridLayout(2, false); |
| 463 | functionMainGroup.setLayout(layout); |
| 464 | data = new GridData(GridData.FILL_HORIZONTAL); |
| 465 | functionMainGroup.setLayoutData(data); |
| 466 | |
| 467 | Composite buttonComposite = new Composite(functionMainGroup, SWT.NONE); |
| 468 | layout = new GridLayout(1, false); |
| 469 | buttonComposite.setLayout(layout); |
| 470 | data = new GridData(SWT.BEGINNING, SWT.CENTER, false, true); |
| 471 | buttonComposite.setLayoutData(data); |
| 472 | |
| 473 | fFunctionActivateButton = new Button(buttonComposite, SWT.RADIO); |
| 474 | fFunctionActivateButton.setText(Messages.TraceControl_EnableGroupSelectionName); |
| 475 | fFunctionActivateButton.setSelection(false); |
| 476 | data = new GridData(GridData.FILL_HORIZONTAL); |
| 477 | fFunctionActivateButton.setLayoutData(data); |
| 478 | fFunctionActivateButton.addSelectionListener(new SelectionAdapter() { |
| 479 | @Override |
| 480 | public void widgetSelected(SelectionEvent e) { |
| 481 | setKernelEnablements(KernelGroupEnum.FUNCTION); |
| 482 | } |
| 483 | }); |
| 484 | |
| 485 | Group functionGroup = new Group(functionMainGroup, SWT.SHADOW_NONE); |
| 486 | layout = new GridLayout(4, true); |
| 487 | functionGroup.setLayout(layout); |
| 488 | functionGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); |
| 489 | |
| 490 | Label functionNameLabel = new Label(functionGroup, SWT.LEFT); |
| 491 | functionNameLabel.setText(Messages.TraceControl_EnableEventsEventNameLabel); |
| 492 | data = new GridData(GridData.FILL_BOTH); |
| 493 | data.horizontalSpan = 1; |
| 494 | functionNameLabel.setLayoutData(data); |
| 495 | |
| 496 | fFunctionEventNameText = new Text(functionGroup, SWT.LEFT); |
| 497 | fFunctionEventNameText.setToolTipText(Messages.TraceControl_EnableEventsFunctionEventNameTooltip); |
| 498 | data = new GridData(GridData.FILL_BOTH); |
| 499 | data.horizontalSpan = 3; |
| 500 | fFunctionEventNameText.setLayoutData(data); |
| 501 | |
| 502 | Label functionLabel = new Label(functionGroup, SWT.LEFT); |
| 503 | functionLabel.setText(Messages.TraceControl_EnableEventsFunctionNameLabel); |
| 504 | data = new GridData(GridData.FILL_BOTH); |
| 505 | data.horizontalSpan = 1; |
| 506 | functionLabel.setLayoutData(data); |
| 507 | |
| 508 | fFunctionText = new Text(functionGroup, SWT.LEFT); |
| 509 | fFunctionText.setToolTipText(Messages.TraceControl_EnableEventsProbeNameTooltip); |
| 510 | data = new GridData(GridData.FILL_BOTH); |
| 511 | data.horizontalSpan = 3; |
| 512 | fFunctionText.setLayoutData(data); |
| 513 | } |
| 514 | |
| 515 | /** |
| 516 | * Enable/selects widgets depending on the group specified. |
| 517 | * @param group - group to enable. |
| 518 | */ |
| 519 | private void setKernelEnablements(KernelGroupEnum group) { |
| 520 | fTracepointsActivateButton.setSelection(group == KernelGroupEnum.TRACEPOINTS); |
| 521 | fTracepointsViewer.getTree().setEnabled(group == KernelGroupEnum.TRACEPOINTS); |
| 522 | |
| 523 | fSysCallsActivateButton.setSelection(group == KernelGroupEnum.SYSCALLS); |
| 524 | |
| 525 | fProbeActivateButton.setSelection(group == KernelGroupEnum.PROBE); |
| 526 | fProbeEventNameText.setEnabled(group == KernelGroupEnum.PROBE); |
| 527 | fProbeText.setEnabled(group == KernelGroupEnum.PROBE); |
| 528 | |
| 529 | fFunctionActivateButton.setSelection(group == KernelGroupEnum.FUNCTION); |
| 530 | fFunctionEventNameText.setEnabled(group == KernelGroupEnum.FUNCTION); |
| 531 | fFunctionText.setEnabled(group == KernelGroupEnum.FUNCTION); |
| 532 | } |
| 533 | |
| 534 | // ------------------------------------------------------------------------ |
| 535 | // Local classes |
| 536 | // ------------------------------------------------------------------------ |
| 537 | /** |
| 538 | * Content provider for the tracepoints tree. |
| 539 | */ |
| 540 | public static final class KernelContentProvider extends TraceControlContentProvider { |
| 541 | @Override |
| 542 | public Object[] getChildren(Object parentElement) { |
| 543 | if (parentElement instanceof TraceProviderGroup) { |
| 544 | List<ITraceControlComponent> children = ((ITraceControlComponent)parentElement).getChildren(KernelProviderComponent.class); |
| 545 | return children.toArray(new ITraceControlComponent[children.size()]); |
| 546 | } |
| 547 | if (parentElement instanceof ITraceControlComponent) { |
| 548 | return ((ITraceControlComponent)parentElement).getChildren(); |
| 549 | } |
| 550 | return new Object[0]; |
| 551 | } |
| 552 | } |
| 553 | |
| 554 | /** |
| 555 | * Content label for the tracepoints tree. |
| 556 | */ |
| 557 | public static final class KernelLabelProvider extends TraceControlLabelProvider { |
| 558 | @Override |
| 559 | public Image getImage(Object element) { |
| 560 | return null; |
| 561 | } |
| 562 | @Override |
| 563 | public String getText(Object element) { |
| 564 | if ((element != null) && (element instanceof KernelProviderComponent)) { |
| 565 | return Messages.TraceControl_EnableEventsTracepointTreeAllLabel; |
| 566 | } |
| 567 | return super.getText(element); |
| 568 | } |
| 569 | } |
| 570 | |
| 571 | /** |
| 572 | * Check state listener for the tracepoints tree. |
| 573 | */ |
| 574 | public final class KernelCheckListener implements ICheckStateListener { |
| 575 | @Override |
| 576 | public void checkStateChanged(CheckStateChangedEvent event) { |
| 577 | if (event.getChecked()) { |
| 578 | if (event.getElement() instanceof KernelProviderComponent) { |
| 579 | fTracepointsViewer.setSubtreeChecked(event.getElement(), true); |
| 580 | } |
| 581 | } else { |
| 582 | if (event.getElement() instanceof KernelProviderComponent) { |
| 583 | fTracepointsViewer.setSubtreeChecked(event.getElement(), false); |
| 584 | } else { |
| 585 | ITraceControlComponent component = (ITraceControlComponent) event.getElement(); |
| 586 | fTracepointsViewer.setChecked(component.getParent(), false); |
| 587 | } |
| 588 | } |
| 589 | } |
| 590 | } |
| 591 | } |