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