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