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