Re-structure LTTng sub-project as per the Linux Tools guidelines
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / views / filter / FilterDialog.java
1 /*******************************************************************************
2 * Copyright (c) 2010 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 * Patrick Tasse - Initial API and implementation
11 *******************************************************************************/
12
13 package org.eclipse.linuxtools.tmf.ui.views.filter;
14
15 import org.eclipse.jface.dialogs.Dialog;
16 import org.eclipse.linuxtools.tmf.core.filter.model.ITmfFilterTreeNode;
17 import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterNode;
18 import org.eclipse.linuxtools.tmf.ui.internal.Messages;
19 import org.eclipse.swt.SWT;
20 import org.eclipse.swt.widgets.Composite;
21 import org.eclipse.swt.widgets.Control;
22 import org.eclipse.swt.widgets.Shell;
23
24 public class FilterDialog extends Dialog {
25
26 TmfFilterNode fRoot;
27 FilterViewer fViewer;
28
29 public FilterDialog(Shell shell) {
30 super(shell);
31 setShellStyle(getShellStyle() | SWT.RESIZE | SWT.MAX);
32 }
33
34 /* (non-Javadoc)
35 * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
36 */
37 @Override
38 protected Control createDialogArea(Composite parent) {
39 getShell().setText(Messages.FilterDialog_FilterDialogTitle);
40 getShell().setMinimumSize(getShell().computeSize(500, 200));
41 Composite composite = (Composite) super.createDialogArea(parent);
42
43 fViewer = new FilterViewer(composite, SWT.BORDER);
44 fViewer.setInput(fRoot);
45 return composite;
46 }
47
48 /**
49 * @param fFilter the filter to set
50 */
51 public void setFilter(ITmfFilterTreeNode filter) {
52 fRoot = new TmfFilterNode(null);
53 if (filter != null) {
54 fRoot.addChild(filter.clone());
55 }
56 if (fViewer != null) {
57 fViewer.setInput(fRoot);
58 }
59 }
60
61 /**
62 * @return the fFilter
63 */
64 public ITmfFilterTreeNode getFilter() {
65 if (fRoot != null && fRoot.hasChildren()) {
66 return fRoot.getChild(0).clone();
67 }
68 return null;
69 }
70
71 }
This page took 0.042581 seconds and 5 git commands to generate.