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
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 * Bernd Hufmann - Updated for support of LTTng Tools 2.1
12 **********************************************************************/
13 package org.eclipse.tracecompass.internal.lttng2.control.ui.views.dialogs;
14
15 import java.util.List;
16
17 import org.eclipse.jface.dialogs.Dialog;
18 import org.eclipse.jface.dialogs.IDialogConstants;
19 import org.eclipse.swt.SWT;
20 import org.eclipse.swt.events.SelectionAdapter;
21 import org.eclipse.swt.events.SelectionEvent;
22 import org.eclipse.swt.graphics.Point;
23 import org.eclipse.swt.layout.GridData;
24 import org.eclipse.swt.layout.GridLayout;
25 import org.eclipse.swt.widgets.Button;
26 import org.eclipse.swt.widgets.Composite;
27 import org.eclipse.swt.widgets.Control;
28 import org.eclipse.swt.widgets.Group;
29 import org.eclipse.swt.widgets.Shell;
30 import org.eclipse.tracecompass.internal.lttng2.control.core.model.LogLevelType;
31 import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceLogLevel;
32 import org.eclipse.tracecompass.internal.lttng2.control.ui.Activator;
33 import org.eclipse.tracecompass.internal.lttng2.control.ui.views.messages.Messages;
34 import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TraceDomainComponent;
35 import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TraceProviderGroup;
36
37 /**
38 * <p>
39 * Dialog box for collecting information events to be enabled.
40 * </p>
41 *
42 * @author Bernd Hufmann
43 */
44 public class EnableEventsDialog extends Dialog implements IEnableEventsDialog {
45
46 // ------------------------------------------------------------------------
47 // Constants
48 // ------------------------------------------------------------------------
49
50 /**
51 * The icon file for this dialog box.
52 */
53 public static final String ENABLE_EVENT_ICON_FILE = "icons/elcl16/enable_event.gif"; //$NON-NLS-1$
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 /**
67 * The composite with widgets for collecting information about UST events.
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 /**
79 * The referenced trace provider group containing the kernel provider and UST
80 * provider component which contains a list of available tracepoints.
81 */
82 private TraceProviderGroup fProviderGroup;
83 /**
84 * The parent domain component where the channel node should be added.
85 * Null in case the domain is not known (i.e. on session level).
86 */
87 private TraceDomainComponent fDomain;
88 /**
89 * Output domain information. True in case of Kernel domain. False for UST.
90 */
91 private boolean fIsKernel;
92
93 // ------------------------------------------------------------------------
94 // Constructors
95 // ------------------------------------------------------------------------
96 /**
97 * Constructor
98 * @param shell - a shell for the display of the dialog
99 */
100 public EnableEventsDialog(Shell shell) {
101 super(shell);
102 setShellStyle(SWT.RESIZE | getShellStyle());
103 }
104
105 // ------------------------------------------------------------------------
106 // Accessors
107 // ------------------------------------------------------------------------
108 @Override
109 public boolean isAllEvents() {
110 if (fIsKernel) {
111 return fKernelComposite.isAllEvents();
112 }
113 return false;
114 }
115
116 @Override
117 public boolean isTracepoints() {
118 if (fIsKernel) {
119 return fKernelComposite.isTracepoints();
120 }
121 return fUstComposite.isTracepoints();
122 }
123
124 @Override
125 public boolean isAllTracePoints() {
126 if (fIsKernel) {
127 return fKernelComposite.isAllTracePoints();
128 }
129 return fUstComposite.isAllTracePoints();
130 }
131
132 @Override
133 public boolean isSysCalls() {
134 if (fIsKernel) {
135 return fKernelComposite.isSysCalls();
136 }
137 return false;
138 }
139
140 @Override
141 public boolean isAllSysCalls() {
142 if (fIsKernel) {
143 return fKernelComposite.isSysCalls();
144 }
145 return false;
146 }
147
148 @Override
149 public List<String> getEventNames() {
150 if (fIsKernel) {
151 return fKernelComposite.getEventNames();
152 }
153 return fUstComposite.getEventNames();
154 }
155
156 @Override
157 public boolean isDynamicProbe() {
158 if (fIsKernel) {
159 return fKernelComposite.isDynamicProbe();
160 }
161 return false;
162 }
163
164 @Override
165 public String getProbeName() {
166 if (fIsKernel) {
167 return fKernelComposite.getProbeName();
168 }
169 return null;
170 }
171
172 @Override
173 public String getProbeEventName() {
174 if (fIsKernel) {
175 return fKernelComposite.getProbeEventName();
176 }
177 return null;
178 }
179
180 @Override
181 public boolean isDynamicFunctionProbe() {
182 if (fIsKernel) {
183 return fKernelComposite.isDynamicFunctionProbe();
184 }
185 return false;
186 }
187
188 @Override
189 public String getFunctionEventName() {
190 if (fIsKernel) {
191 return fKernelComposite.getFunctionEventName();
192 }
193 return null;
194 }
195
196 @Override
197 public String getFunction() {
198 if (fIsKernel) {
199 return fKernelComposite.getFunction();
200 }
201 return null;
202 }
203
204 @Override
205 public boolean isWildcard() {
206 if (!fIsKernel) {
207 return fUstComposite.isWildcard();
208 }
209 return false;
210 }
211
212 @Override
213 public String getWildcard() {
214 if (!fIsKernel) {
215 return fUstComposite.getWildcard();
216 }
217 return null;
218 }
219
220 @Override
221 public boolean isLogLevel() {
222 if (!fIsKernel) {
223 return fUstComposite.isLogLevel();
224 }
225 return false;
226 }
227
228 @Override
229 public LogLevelType getLogLevelType() {
230 if (!fIsKernel) {
231 return fUstComposite.getLogLevelType();
232 }
233 return null;
234 }
235
236 @Override
237 public TraceLogLevel getLogLevel() {
238 if (!fIsKernel) {
239 return fUstComposite.getLogLevel();
240 }
241 return null;
242 }
243
244 @Override
245 public String getLogLevelEventName() {
246 if (!fIsKernel) {
247 return fUstComposite.getLogLevelEventName();
248 }
249 return null;
250 }
251
252 @Override
253 public boolean isKernel() {
254 return fIsKernel;
255 }
256
257 @Override
258 public void setTraceProviderGroup(TraceProviderGroup providerGroup) {
259 fProviderGroup = providerGroup;
260 }
261
262 @Override
263 public void setTraceDomainComponent(TraceDomainComponent domain) {
264 fDomain = domain;
265 if (fDomain != null) {
266 fIsKernel = fDomain.isKernel();
267 } else {
268 fIsKernel = fProviderGroup != null ? fProviderGroup.hasKernelProvider() : true;
269 }
270 }
271
272 @Override
273 public String getFilterExpression() {
274 if (fIsKernel) {
275 return fKernelComposite.getFilterExpression();
276 }
277 return fUstComposite.getFilterExpression();
278 }
279
280 // ------------------------------------------------------------------------
281 // Operations
282 // ------------------------------------------------------------------------
283
284 @Override
285 protected void configureShell(Shell newShell) {
286 super.configureShell(newShell);
287 newShell.setText(Messages.TraceControl_EnableEventsDialogTitle);
288 newShell.setImage(Activator.getDefault().loadIcon(ENABLE_EVENT_ICON_FILE));
289 }
290
291 @Override
292 protected Control createDialogArea(Composite parent) {
293
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 // ------------------------------------------------------------------------
301 // Domain Group
302 // ------------------------------------------------------------------------
303 Group domainGroup = new Group(fDialogComposite, SWT.SHADOW_NONE);
304 domainGroup.setText(Messages.TraceControl_DomainDisplayName);
305 layout = new GridLayout(2, true);
306 domainGroup.setLayout(layout);
307
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
315 if ((fDomain != null) || ((fProviderGroup != null) && (!fProviderGroup.hasKernelProvider()))) {
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 // ------------------------------------------------------------------------
330 // Kernel or UST event data group
331 // ------------------------------------------------------------------------
332 fUstComposite = null;
333 fKernelComposite = null;
334 if (fIsKernel) {
335 createKernelComposite();
336 fUstComposite = null;
337 } else {
338 createUstComposite();
339 }
340
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 });
362
363 getShell().setMinimumSize(new Point(550, 750));
364
365 return fDialogComposite;
366 }
367
368 @Override
369 protected void createButtonsForButtonBar(Composite parent) {
370 createButton(parent, IDialogConstants.CANCEL_ID, "&Cancel", true); //$NON-NLS-1$
371 createButton(parent, IDialogConstants.OK_ID, "&Ok", true); //$NON-NLS-1$
372 }
373
374 @Override
375 protected void okPressed() {
376 fIsKernel = fKernelButton.getSelection();
377
378 // Validate kernel composite in case of kernel domain
379 if (fKernelComposite != null && !fKernelComposite.isValid()) {
380 return;
381 }
382
383 // Validate UST composite in case of UST domain
384 if (fUstComposite != null && !fUstComposite.isValid()) {
385 return;
386 }
387
388 // validation successful -> call super.okPressed()
389 super.okPressed();
390 }
391
392 // ------------------------------------------------------------------------
393 // Helper methods
394 // ------------------------------------------------------------------------
395
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() {
424 if (fUstComposite == null) {
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.041 seconds and 5 git commands to generate.