control: command support for enabling all tracepoints/syscalls
[deliverable/tracecompass.git] / lttng / org.eclipse.tracecompass.lttng2.control.ui / src / org / eclipse / tracecompass / internal / lttng2 / control / ui / views / dialogs / EnableEventsDialog.java
CommitLineData
ccc66d01 1/**********************************************************************
ed902a2b 2 * Copyright (c) 2012, 2014 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 **********************************************************************/
9bc60be7 13package org.eclipse.tracecompass.internal.lttng2.control.ui.views.dialogs;
ccc66d01
BH
14
15import java.util.List;
16
17import org.eclipse.jface.dialogs.Dialog;
18import org.eclipse.jface.dialogs.IDialogConstants;
ccc66d01
BH
19import org.eclipse.swt.SWT;
20import org.eclipse.swt.events.SelectionAdapter;
21import org.eclipse.swt.events.SelectionEvent;
22import org.eclipse.swt.graphics.Point;
23import org.eclipse.swt.layout.GridData;
24import org.eclipse.swt.layout.GridLayout;
25import org.eclipse.swt.widgets.Button;
26import org.eclipse.swt.widgets.Composite;
27import org.eclipse.swt.widgets.Control;
28import org.eclipse.swt.widgets.Group;
29import org.eclipse.swt.widgets.Shell;
9bc60be7
AM
30import org.eclipse.tracecompass.internal.lttng2.control.core.model.LogLevelType;
31import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceLogLevel;
32import org.eclipse.tracecompass.internal.lttng2.control.ui.Activator;
33import org.eclipse.tracecompass.internal.lttng2.control.ui.views.messages.Messages;
34import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TraceDomainComponent;
35import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TraceProviderGroup;
ccc66d01
BH
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);
8a396998 102 setShellStyle(SWT.RESIZE | getShellStyle());
ccc66d01 103 }
cfdb727a 104
ccc66d01
BH
105 // ------------------------------------------------------------------------
106 // Accessors
107 // ------------------------------------------------------------------------
9ee91a86
BH
108 @Override
109 public boolean isAllEvents() {
110 if (fIsKernel) {
111 return fKernelComposite.isAllEvents();
112 }
113 return false;
114 }
cfdb727a 115
ccc66d01
BH
116 @Override
117 public boolean isTracepoints() {
118 if (fIsKernel) {
119 return fKernelComposite.isTracepoints();
120 }
121 return fUstComposite.isTracepoints();
122 }
cfdb727a 123
ccc66d01
BH
124 @Override
125 public boolean isAllTracePoints() {
126 if (fIsKernel) {
127 return fKernelComposite.isAllTracePoints();
128 }
129 return fUstComposite.isAllTracePoints();
130 }
cfdb727a 131
ccc66d01
BH
132 @Override
133 public boolean isSysCalls() {
134 if (fIsKernel) {
135 return fKernelComposite.isSysCalls();
136 }
137 return false;
138 }
cfdb727a 139
ccc66d01
BH
140 @Override
141 public boolean isAllSysCalls() {
142 if (fIsKernel) {
143 return fKernelComposite.isSysCalls();
144 }
145 return false;
146 }
cfdb727a 147
ccc66d01
BH
148 @Override
149 public List<String> getEventNames() {
150 if (fIsKernel) {
151 return fKernelComposite.getEventNames();
152 }
153 return fUstComposite.getEventNames();
154 }
11252342 155
ccc66d01
BH
156 @Override
157 public boolean isDynamicProbe() {
158 if (fIsKernel) {
159 return fKernelComposite.isDynamicProbe();
160 }
161 return false;
162 }
cfdb727a 163
ccc66d01
BH
164 @Override
165 public String getProbeName() {
166 if (fIsKernel) {
167 return fKernelComposite.getProbeName();
168 }
169 return null;
170 }
cfdb727a 171
ccc66d01
BH
172 @Override
173 public String getProbeEventName() {
174 if (fIsKernel) {
175 return fKernelComposite.getProbeEventName();
176 }
177 return null;
178 }
cfdb727a 179
ccc66d01
BH
180 @Override
181 public boolean isDynamicFunctionProbe() {
182 if (fIsKernel) {
183 return fKernelComposite.isDynamicFunctionProbe();
184 }
185 return false;
186 }
cfdb727a 187
ccc66d01
BH
188 @Override
189 public String getFunctionEventName() {
190 if (fIsKernel) {
191 return fKernelComposite.getFunctionEventName();
192 }
193 return null;
194 }
cfdb727a 195
ccc66d01
BH
196 @Override
197 public String getFunction() {
198 if (fIsKernel) {
199 return fKernelComposite.getFunction();
200 }
201 return null;
202 }
cfdb727a 203
ccc66d01
BH
204 @Override
205 public boolean isWildcard() {
206 if (!fIsKernel) {
207 return fUstComposite.isWildcard();
208 }
209 return false;
210 }
211
ccc66d01
BH
212 @Override
213 public String getWildcard() {
214 if (!fIsKernel) {
215 return fUstComposite.getWildcard();
216 }
217 return null;
ccc66d01
BH
218 }
219
ccc66d01
BH
220 @Override
221 public boolean isLogLevel() {
222 if (!fIsKernel) {
223 return fUstComposite.isLogLevel();
224 }
225 return false;
ccc66d01
BH
226 }
227
ccc66d01
BH
228 @Override
229 public LogLevelType getLogLevelType() {
230 if (!fIsKernel) {
231 return fUstComposite.getLogLevelType();
232 }
233 return null;
ccc66d01 234 }
cfdb727a 235
ccc66d01
BH
236 @Override
237 public TraceLogLevel getLogLevel() {
238 if (!fIsKernel) {
239 return fUstComposite.getLogLevel();
240 }
241 return null;
ccc66d01
BH
242 }
243
ccc66d01
BH
244 @Override
245 public String getLogLevelEventName() {
246 if (!fIsKernel) {
247 return fUstComposite.getLogLevelEventName();
248 }
249 return null;
250 }
cfdb727a 251
ccc66d01
BH
252 @Override
253 public boolean isKernel() {
254 return fIsKernel;
255 }
cfdb727a 256
d132bcc7
BH
257 @Override
258 public void setTraceProviderGroup(TraceProviderGroup providerGroup) {
259 fProviderGroup = providerGroup;
260 }
261
d132bcc7
BH
262 @Override
263 public void setTraceDomainComponent(TraceDomainComponent domain) {
264 fDomain = domain;
265 if (fDomain != null) {
266 fIsKernel = fDomain.isKernel();
267 } else {
a07c7629 268 fIsKernel = fProviderGroup != null ? fProviderGroup.hasKernelProvider() : true;
d132bcc7
BH
269 }
270 }
ccc66d01 271
d4514365
BH
272 @Override
273 public String getFilterExpression() {
f0584d20
BH
274 if (fIsKernel) {
275 return fKernelComposite.getFilterExpression();
d4514365 276 }
f0584d20 277 return fUstComposite.getFilterExpression();
d4514365
BH
278 }
279
ccc66d01
BH
280 // ------------------------------------------------------------------------
281 // Operations
282 // ------------------------------------------------------------------------
11252342 283
ccc66d01
BH
284 @Override
285 protected void configureShell(Shell newShell) {
286 super.configureShell(newShell);
287 newShell.setText(Messages.TraceControl_EnableEventsDialogTitle);
31a6a4e4 288 newShell.setImage(Activator.getDefault().loadIcon(ENABLE_EVENT_ICON_FILE));
ccc66d01
BH
289 }
290
ccc66d01
BH
291 @Override
292 protected Control createDialogArea(Composite parent) {
cfdb727a 293
ccc66d01
BH
294 // Main dialog panel
295 fDialogComposite = new Composite(parent, SWT.NONE);
296 GridLayout layout = new GridLayout(1, true);
297 fDialogComposite.setLayout(layout);
298 fDialogComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
299
300 // ------------------------------------------------------------------------
cfdb727a 301 // Domain Group
ccc66d01
BH
302 // ------------------------------------------------------------------------
303 Group domainGroup = new Group(fDialogComposite, SWT.SHADOW_NONE);
304 domainGroup.setText(Messages.TraceControl_DomainDisplayName);
305 layout = new GridLayout(2, true);
cfdb727a
AM
306 domainGroup.setLayout(layout);
307
ccc66d01
BH
308 fKernelButton = new Button(domainGroup, SWT.RADIO);
309 fKernelButton.setText(Messages.TraceControl_KernelDomainDisplayName);
310 fKernelButton.setSelection(fIsKernel);
311 fUstButton = new Button(domainGroup, SWT.RADIO);
312 fUstButton.setText(Messages.TraceControl_UstDisplayName);
313 fUstButton.setSelection(!fIsKernel);
314
a07c7629 315 if ((fDomain != null) || ((fProviderGroup != null) && (!fProviderGroup.hasKernelProvider()))) {
ccc66d01
BH
316 fKernelButton.setEnabled(false);
317 fUstButton.setEnabled(false);
318 }
319
320 // layout widgets
321 GridData data = new GridData(GridData.FILL_HORIZONTAL);
322 domainGroup.setLayoutData(data);
323
324 data = new GridData(SWT.BEGINNING, SWT.BEGINNING, true, true);
325 fKernelButton.setLayoutData(data);
326 data = new GridData(SWT.BEGINNING, SWT.BEGINNING, true, true);
327 fUstButton.setLayoutData(data);
328
329 // ------------------------------------------------------------------------
cfdb727a 330 // Kernel or UST event data group
ccc66d01 331 // ------------------------------------------------------------------------
d132bcc7
BH
332 fUstComposite = null;
333 fKernelComposite = null;
ccc66d01
BH
334 if (fIsKernel) {
335 createKernelComposite();
d132bcc7 336 fUstComposite = null;
ccc66d01
BH
337 } else {
338 createUstComposite();
339 }
cfdb727a 340
ccc66d01
BH
341 fKernelButton.addSelectionListener(new SelectionAdapter() {
342 @Override
343 public void widgetSelected(SelectionEvent e) {
344 if (fKernelButton.getSelection()) {
345 disposeUstComposite();
346 createKernelComposite();
347 fDialogComposite.layout();
348 }
349 }
350 });
351
352 fUstButton.addSelectionListener(new SelectionAdapter() {
353 @Override
354 public void widgetSelected(SelectionEvent e) {
355 if (fUstButton.getSelection()) {
356 disposeKernelComposite();
357 createUstComposite();
358 fDialogComposite.layout();
359 }
360 }
361 });
cfdb727a 362
9ee91a86 363 getShell().setMinimumSize(new Point(550, 750));
cfdb727a 364
ccc66d01
BH
365 return fDialogComposite;
366 }
cfdb727a 367
ccc66d01
BH
368 @Override
369 protected void createButtonsForButtonBar(Composite parent) {
79c3db85 370 createButton(parent, IDialogConstants.CANCEL_ID, "&Cancel", true); //$NON-NLS-1$
ccc66d01
BH
371 createButton(parent, IDialogConstants.OK_ID, "&Ok", true); //$NON-NLS-1$
372 }
373
ccc66d01
BH
374 @Override
375 protected void okPressed() {
c56972bb 376 fIsKernel = fKernelButton.getSelection();
ccc66d01
BH
377
378 // Validate kernel composite in case of kernel domain
379 if (fKernelComposite != null && !fKernelComposite.isValid()) {
380 return;
381 }
cfdb727a 382
ccc66d01
BH
383 // Validate UST composite in case of UST domain
384 if (fUstComposite != null && !fUstComposite.isValid()) {
385 return;
386 }
cfdb727a 387
ccc66d01
BH
388 // validation successful -> call super.okPressed()
389 super.okPressed();
390 }
cfdb727a 391
ccc66d01
BH
392 // ------------------------------------------------------------------------
393 // Helper methods
394 // ------------------------------------------------------------------------
11252342 395
ccc66d01
BH
396 /**
397 * Creates the kernel composite (if not existing)
398 */
399 private void createKernelComposite() {
400 if (fKernelComposite == null) {
401 fKernelComposite = new EnableKernelEventComposite(fDialogComposite, SWT.NONE, fProviderGroup);
402 GridLayout layout = new GridLayout(1, true);
403 fKernelComposite.setLayout(layout);
404 fKernelComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
405
406 fKernelComposite.createContent();
407 }
408 }
409
410 /**
411 * Disposes the kernel composite (if existing)
412 */
413 private void disposeKernelComposite() {
414 if (fKernelComposite != null) {
415 fKernelComposite.dispose();
416 fKernelComposite = null;
417 }
418 }
419
420 /**
421 * Creates the UST composite (if not existing)
422 */
423 private void createUstComposite() {
cfdb727a 424 if (fUstComposite == null) {
ccc66d01
BH
425 fUstComposite = new EnableUstEventsComposite(fDialogComposite, SWT.NONE, fProviderGroup);
426 GridLayout layout = new GridLayout(1, true);
427 fUstComposite.setLayout(layout);
428 fUstComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
429
430 fUstComposite.createContent();
431 }
432 }
433
434 /**
435 * Disposes the UST composite (if existing)
436 */
437 private void disposeUstComposite() {
438 if (fUstComposite != null) {
439 fUstComposite.dispose();
440 fUstComposite = null;
441 }
442 }
443}
This page took 0.134565 seconds and 5 git commands to generate.