TMF: Add supplementary folder to experiments
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.ui / src / org / eclipse / linuxtools / internal / lttng2 / ui / views / control / dialogs / EnableEventsDialog.java
CommitLineData
ccc66d01
BH
1/**********************************************************************
2 * Copyright (c) 2012 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
BH
10 * Bernd Hufmann - Initial API and implementation
11 **********************************************************************/
115b4a01 12package org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs;
ccc66d01
BH
13
14import java.util.List;
15
16import org.eclipse.jface.dialogs.Dialog;
17import org.eclipse.jface.dialogs.IDialogConstants;
9315aeee
BH
18import org.eclipse.linuxtools.internal.lttng2.core.control.model.LogLevelType;
19import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceLogLevel;
115b4a01 20import org.eclipse.linuxtools.internal.lttng2.ui.Activator;
9315aeee 21import org.eclipse.linuxtools.internal.lttng2.ui.views.control.messages.Messages;
115b4a01
BH
22import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceDomainComponent;
23import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceProviderGroup;
ccc66d01
BH
24import org.eclipse.swt.SWT;
25import org.eclipse.swt.events.SelectionAdapter;
26import org.eclipse.swt.events.SelectionEvent;
27import org.eclipse.swt.graphics.Point;
28import org.eclipse.swt.layout.GridData;
29import org.eclipse.swt.layout.GridLayout;
30import org.eclipse.swt.widgets.Button;
31import org.eclipse.swt.widgets.Composite;
32import org.eclipse.swt.widgets.Control;
33import org.eclipse.swt.widgets.Group;
34import org.eclipse.swt.widgets.Shell;
35
36/**
ccc66d01
BH
37 * <p>
38 * Dialog box for collecting information events to be enabled.
39 * </p>
cfdb727a 40 *
dbd4432d 41 * @author Bernd Hufmann
ccc66d01
BH
42 */
43public class EnableEventsDialog extends Dialog implements IEnableEventsDialog {
44
45 // ------------------------------------------------------------------------
46 // Constants
47 // ------------------------------------------------------------------------
cfdb727a 48
ccc66d01
BH
49 /**
50 * The icon file for this dialog box.
51 */
cfdb727a 52 public static final String ENABLE_EVENT_ICON_FILE = "icons/elcl16/enable_event.gif"; //$NON-NLS-1$
ccc66d01
BH
53
54 // ------------------------------------------------------------------------
55 // Attributes
56 // ------------------------------------------------------------------------
57 /**
58 * The dialog composite.
59 */
60 private Composite fDialogComposite;
61 /**
62 * The composite with widgets for collecting information about kernel events.
63 */
64 private EnableKernelEventComposite fKernelComposite;
65 /**
cfdb727a 66 * The composite with widgets for collecting information about UST events.
ccc66d01
BH
67 */
68 private EnableUstEventsComposite fUstComposite;
69 /**
70 * Radio button for selecting kernel domain.
71 */
72 private Button fKernelButton;
73 /**
74 * Radio button for selecting UST domain.
75 */
76 private Button fUstButton;
77 /**
cfdb727a 78 * The referenced trace provider group containing the kernel provider and UST
ccc66d01
BH
79 * provider component which contains a list of available tracepoints.
80 */
81 private TraceProviderGroup fProviderGroup;
82 /**
cfdb727a 83 * The parent domain component where the channel node should be added.
ccc66d01
BH
84 * Null in case the domain is not known (i.e. on session level).
85 */
86 private TraceDomainComponent fDomain;
87 /**
cfdb727a 88 * Output domain information. True in case of Kernel domain. False for UST.
ccc66d01
BH
89 */
90 private boolean fIsKernel;
91
92 // ------------------------------------------------------------------------
93 // Constructors
94 // ------------------------------------------------------------------------
95 /**
96 * Constructor
97 * @param shell - a shell for the display of the dialog
ccc66d01 98 */
d132bcc7 99 public EnableEventsDialog(Shell shell) {
ccc66d01 100 super(shell);
ccc66d01 101 setShellStyle(SWT.RESIZE);
ccc66d01 102 }
cfdb727a 103
ccc66d01
BH
104 // ------------------------------------------------------------------------
105 // Accessors
106 // ------------------------------------------------------------------------
cfdb727a 107
ccc66d01
BH
108 /*
109 * (non-Javadoc)
115b4a01 110 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableKernelEvents#isTracpoints()
ccc66d01
BH
111 */
112 @Override
113 public boolean isTracepoints() {
114 if (fIsKernel) {
115 return fKernelComposite.isTracepoints();
116 }
117 return fUstComposite.isTracepoints();
118 }
cfdb727a 119
ccc66d01 120 /* (non-Javadoc)
115b4a01 121 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableKernelEvents#isAllTracePoints()
ccc66d01
BH
122 */
123 @Override
124 public boolean isAllTracePoints() {
125 if (fIsKernel) {
126 return fKernelComposite.isAllTracePoints();
127 }
128 return fUstComposite.isAllTracePoints();
129 }
cfdb727a 130
ccc66d01
BH
131 /*
132 * (non-Javadoc)
115b4a01 133 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableKernelEvents#isSysCalls()
ccc66d01
BH
134 */
135 @Override
136 public boolean isSysCalls() {
137 if (fIsKernel) {
138 return fKernelComposite.isSysCalls();
139 }
140 return false;
141 }
cfdb727a 142
ccc66d01 143 /* (non-Javadoc)
115b4a01 144 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableKernelEvents#isAllSysCalls()
ccc66d01
BH
145 */
146 @Override
147 public boolean isAllSysCalls() {
148 if (fIsKernel) {
149 return fKernelComposite.isSysCalls();
150 }
151 return false;
152 }
cfdb727a 153
ccc66d01 154 /* (non-Javadoc)
115b4a01 155 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableKernelEvents#getEventNames()
ccc66d01
BH
156 */
157 @Override
158 public List<String> getEventNames() {
159 if (fIsKernel) {
160 return fKernelComposite.getEventNames();
161 }
162 return fUstComposite.getEventNames();
163 }
164 /*
165 * (non-Javadoc)
115b4a01 166 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableKernelEvents#isDynamicProbe()
ccc66d01
BH
167 */
168 @Override
169 public boolean isDynamicProbe() {
170 if (fIsKernel) {
171 return fKernelComposite.isDynamicProbe();
172 }
173 return false;
174 }
cfdb727a 175
ccc66d01 176 /* (non-Javadoc)
115b4a01 177 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableKernelEvents#getProbeName()
ccc66d01
BH
178 */
179 @Override
180 public String getProbeName() {
181 if (fIsKernel) {
182 return fKernelComposite.getProbeName();
183 }
184 return null;
185 }
cfdb727a 186
ccc66d01 187 /* (non-Javadoc)
115b4a01 188 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableKernelEvents#getProbeEventName()
ccc66d01
BH
189 */
190 @Override
191 public String getProbeEventName() {
192 if (fIsKernel) {
193 return fKernelComposite.getProbeEventName();
194 }
195 return null;
196 }
cfdb727a 197
ccc66d01
BH
198 /*
199 * (non-Javadoc)
115b4a01 200 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableKernelEvents#isDynamicFunctionProbe()
ccc66d01
BH
201 */
202 @Override
203 public boolean isDynamicFunctionProbe() {
204 if (fIsKernel) {
205 return fKernelComposite.isDynamicFunctionProbe();
206 }
207 return false;
208 }
cfdb727a 209
ccc66d01 210 /* (non-Javadoc)
115b4a01 211 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableKernelEvents#getFunctionEventName()
ccc66d01
BH
212 */
213 @Override
214 public String getFunctionEventName() {
215 if (fIsKernel) {
216 return fKernelComposite.getFunctionEventName();
217 }
218 return null;
219 }
cfdb727a 220
ccc66d01
BH
221 /*
222 * (non-Javadoc)
115b4a01 223 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableKernelEvents#getFunction()
ccc66d01
BH
224 */
225 @Override
226 public String getFunction() {
227 if (fIsKernel) {
228 return fKernelComposite.getFunction();
229 }
230 return null;
231 }
cfdb727a 232
ccc66d01
BH
233 /*
234 * (non-Javadoc)
115b4a01 235 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableUstEvents#isWildcard()
ccc66d01
BH
236 */
237 @Override
238 public boolean isWildcard() {
239 if (!fIsKernel) {
240 return fUstComposite.isWildcard();
241 }
242 return false;
243 }
244
245 /*
246 * (non-Javadoc)
115b4a01 247 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableUstEvents#getWildcard()
ccc66d01
BH
248 */
249 @Override
250 public String getWildcard() {
251 if (!fIsKernel) {
252 return fUstComposite.getWildcard();
253 }
254 return null;
cfdb727a 255
ccc66d01
BH
256 }
257
258 /*
259 * (non-Javadoc)
115b4a01 260 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableUstEvents#isLogLevel()
ccc66d01
BH
261 */
262 @Override
263 public boolean isLogLevel() {
264 if (!fIsKernel) {
265 return fUstComposite.isLogLevel();
266 }
267 return false;
cfdb727a 268
ccc66d01
BH
269 }
270
271 /*
272 * (non-Javadoc)
115b4a01 273 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableUstEvents#getLogLevelType()
ccc66d01
BH
274 */
275 @Override
276 public LogLevelType getLogLevelType() {
277 if (!fIsKernel) {
278 return fUstComposite.getLogLevelType();
279 }
280 return null;
cfdb727a 281
ccc66d01 282 }
cfdb727a 283
ccc66d01
BH
284 /*
285 * (non-Javadoc)
115b4a01 286 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableUstEvents#getLogLevel()
ccc66d01
BH
287 */
288 @Override
289 public TraceLogLevel getLogLevel() {
290 if (!fIsKernel) {
291 return fUstComposite.getLogLevel();
292 }
293 return null;
cfdb727a 294
ccc66d01
BH
295 }
296
297 /*
298 * (non-Javadoc)
115b4a01 299 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableUstEvents#getLogLevelEventName()
ccc66d01
BH
300 */
301 @Override
302 public String getLogLevelEventName() {
303 if (!fIsKernel) {
304 return fUstComposite.getLogLevelEventName();
305 }
306 return null;
307 }
cfdb727a 308
ccc66d01
BH
309 /*
310 * (non-Javadoc)
115b4a01 311 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableEventsDialog#isKernel()
ccc66d01
BH
312 */
313 @Override
314 public boolean isKernel() {
315 return fIsKernel;
316 }
cfdb727a 317
d132bcc7
BH
318 /*
319 * (non-Javadoc)
115b4a01 320 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableEventsDialog#setTraceProviderGroup(org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceProviderGroup)
d132bcc7
BH
321 */
322 @Override
323 public void setTraceProviderGroup(TraceProviderGroup providerGroup) {
324 fProviderGroup = providerGroup;
325 }
326
327 /*
328 * (non-Javadoc)
115b4a01 329 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableEventsDialog#setTraceDomainComponent(org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceDomainComponent)
d132bcc7
BH
330 */
331 @Override
332 public void setTraceDomainComponent(TraceDomainComponent domain) {
333 fDomain = domain;
334 if (fDomain != null) {
335 fIsKernel = fDomain.isKernel();
336 } else {
a07c7629 337 fIsKernel = fProviderGroup != null ? fProviderGroup.hasKernelProvider() : true;
d132bcc7
BH
338 }
339 }
ccc66d01 340
d4514365
BH
341 /*
342 * (non-Javadoc)
343 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableUstEvents#getFilterExpression()
344 */
345 @Override
346 public String getFilterExpression() {
347 if (!fIsKernel) {
348 return fUstComposite.getFilterExpression();
349 }
350 return null;
351 }
352
ccc66d01
BH
353 // ------------------------------------------------------------------------
354 // Operations
355 // ------------------------------------------------------------------------
356 /*
357 * (non-Javadoc)
358 * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
359 */
360 @Override
361 protected void configureShell(Shell newShell) {
362 super.configureShell(newShell);
363 newShell.setText(Messages.TraceControl_EnableEventsDialogTitle);
31a6a4e4 364 newShell.setImage(Activator.getDefault().loadIcon(ENABLE_EVENT_ICON_FILE));
ccc66d01
BH
365 }
366
367 /*
368 * (non-Javadoc)
369 * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
370 */
371 @Override
372 protected Control createDialogArea(Composite parent) {
cfdb727a 373
ccc66d01
BH
374 // Main dialog panel
375 fDialogComposite = new Composite(parent, SWT.NONE);
376 GridLayout layout = new GridLayout(1, true);
377 fDialogComposite.setLayout(layout);
378 fDialogComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
379
380 // ------------------------------------------------------------------------
cfdb727a 381 // Domain Group
ccc66d01
BH
382 // ------------------------------------------------------------------------
383 Group domainGroup = new Group(fDialogComposite, SWT.SHADOW_NONE);
384 domainGroup.setText(Messages.TraceControl_DomainDisplayName);
385 layout = new GridLayout(2, true);
cfdb727a
AM
386 domainGroup.setLayout(layout);
387
ccc66d01
BH
388 fKernelButton = new Button(domainGroup, SWT.RADIO);
389 fKernelButton.setText(Messages.TraceControl_KernelDomainDisplayName);
390 fKernelButton.setSelection(fIsKernel);
391 fUstButton = new Button(domainGroup, SWT.RADIO);
392 fUstButton.setText(Messages.TraceControl_UstDisplayName);
393 fUstButton.setSelection(!fIsKernel);
394
a07c7629 395 if ((fDomain != null) || ((fProviderGroup != null) && (!fProviderGroup.hasKernelProvider()))) {
ccc66d01
BH
396 fKernelButton.setEnabled(false);
397 fUstButton.setEnabled(false);
398 }
399
400 // layout widgets
401 GridData data = new GridData(GridData.FILL_HORIZONTAL);
402 domainGroup.setLayoutData(data);
403
404 data = new GridData(SWT.BEGINNING, SWT.BEGINNING, true, true);
405 fKernelButton.setLayoutData(data);
406 data = new GridData(SWT.BEGINNING, SWT.BEGINNING, true, true);
407 fUstButton.setLayoutData(data);
408
409 // ------------------------------------------------------------------------
cfdb727a 410 // Kernel or UST event data group
ccc66d01 411 // ------------------------------------------------------------------------
d132bcc7
BH
412 fUstComposite = null;
413 fKernelComposite = null;
ccc66d01
BH
414 if (fIsKernel) {
415 createKernelComposite();
d132bcc7 416 fUstComposite = null;
ccc66d01
BH
417 } else {
418 createUstComposite();
419 }
cfdb727a 420
ccc66d01
BH
421 fKernelButton.addSelectionListener(new SelectionAdapter() {
422 @Override
423 public void widgetSelected(SelectionEvent e) {
424 if (fKernelButton.getSelection()) {
425 disposeUstComposite();
426 createKernelComposite();
427 fDialogComposite.layout();
428 }
429 }
430 });
431
432 fUstButton.addSelectionListener(new SelectionAdapter() {
433 @Override
434 public void widgetSelected(SelectionEvent e) {
435 if (fUstButton.getSelection()) {
436 disposeKernelComposite();
437 createUstComposite();
438 fDialogComposite.layout();
439 }
440 }
441 });
cfdb727a 442
ccc66d01 443 fDialogComposite.layout();
cfdb727a 444
ccc66d01 445 getShell().setMinimumSize(new Point(500, 650));
cfdb727a 446
ccc66d01
BH
447 return fDialogComposite;
448 }
cfdb727a 449
ccc66d01
BH
450
451 /*
452 * (non-Javadoc)
453 * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
454 */
455 @Override
456 protected void createButtonsForButtonBar(Composite parent) {
79c3db85 457 createButton(parent, IDialogConstants.CANCEL_ID, "&Cancel", true); //$NON-NLS-1$
ccc66d01
BH
458 createButton(parent, IDialogConstants.OK_ID, "&Ok", true); //$NON-NLS-1$
459 }
460
461 /*
462 * (non-Javadoc)
463 * @see org.eclipse.jface.dialogs.Dialog#okPressed()
464 */
465 @Override
466 protected void okPressed() {
c56972bb 467 fIsKernel = fKernelButton.getSelection();
ccc66d01
BH
468
469 // Validate kernel composite in case of kernel domain
470 if (fKernelComposite != null && !fKernelComposite.isValid()) {
471 return;
472 }
cfdb727a 473
ccc66d01
BH
474 // Validate UST composite in case of UST domain
475 if (fUstComposite != null && !fUstComposite.isValid()) {
476 return;
477 }
cfdb727a 478
ccc66d01
BH
479 // validation successful -> call super.okPressed()
480 super.okPressed();
481 }
cfdb727a 482
ccc66d01
BH
483 // ------------------------------------------------------------------------
484 // Helper methods
485 // ------------------------------------------------------------------------
486 /**
487 * Creates the kernel composite (if not existing)
488 */
489 private void createKernelComposite() {
490 if (fKernelComposite == null) {
491 fKernelComposite = new EnableKernelEventComposite(fDialogComposite, SWT.NONE, fProviderGroup);
492 GridLayout layout = new GridLayout(1, true);
493 fKernelComposite.setLayout(layout);
494 fKernelComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
495
496 fKernelComposite.createContent();
497 }
498 }
499
500 /**
501 * Disposes the kernel composite (if existing)
502 */
503 private void disposeKernelComposite() {
504 if (fKernelComposite != null) {
505 fKernelComposite.dispose();
506 fKernelComposite = null;
507 }
508 }
509
510 /**
511 * Creates the UST composite (if not existing)
512 */
513 private void createUstComposite() {
cfdb727a 514 if (fUstComposite == null) {
ccc66d01
BH
515 fUstComposite = new EnableUstEventsComposite(fDialogComposite, SWT.NONE, fProviderGroup);
516 GridLayout layout = new GridLayout(1, true);
517 fUstComposite.setLayout(layout);
518 fUstComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
519
520 fUstComposite.createContent();
521 }
522 }
523
524 /**
525 * Disposes the UST composite (if existing)
526 */
527 private void disposeUstComposite() {
528 if (fUstComposite != null) {
529 fUstComposite.dispose();
530 fUstComposite = null;
531 }
532 }
533}
This page took 0.056391 seconds and 5 git commands to generate.