d573c1760d03606aa491cf684eeb332c9a6b64fd
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / views / filter / FilterDialog.java
1 /*******************************************************************************
2 * Copyright (c) 2010, 2013 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.internal.tmf.ui.Messages;
17 import org.eclipse.linuxtools.tmf.core.filter.model.ITmfFilterTreeNode;
18 import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterNode;
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 /**
25 * The dialog for user-defined filters.
26 *
27 * @version 1.0
28 * @author Patrick Tasse
29 */
30 public class FilterDialog extends Dialog {
31
32 TmfFilterNode fRoot;
33 FilterViewer fViewer;
34
35 /**
36 * Constructor.
37 *
38 * @param shell
39 * The shell to which this dialog is attached
40 */
41 public FilterDialog(Shell shell) {
42 super(shell);
43 setShellStyle(getShellStyle() | SWT.RESIZE | SWT.MAX);
44 }
45
46 @Override
47 protected Control createDialogArea(Composite parent) {
48 getShell().setText(Messages.FilterDialog_FilterDialogTitle);
49 getShell().setMinimumSize(getShell().computeSize(500, 200));
50 Composite composite = (Composite) super.createDialogArea(parent);
51
52 fViewer = new FilterViewer(composite, SWT.BORDER);
53 fViewer.setInput(fRoot);
54 return composite;
55 }
56
57 /**
58 * @param filter
59 * the filter to set
60 */
61 public void setFilter(ITmfFilterTreeNode filter) {
62 fRoot = new TmfFilterNode(null);
63 if (filter != null) {
64 fRoot.addChild(filter.clone());
65 }
66 if (fViewer != null) {
67 fViewer.setInput(fRoot);
68 }
69 }
70
71 /**
72 * @return the filter
73 */
74 public ITmfFilterTreeNode getFilter() {
75 if (fRoot != null && fRoot.hasChildren()) {
76 return fRoot.getChild(0).clone();
77 }
78 return null;
79 }
80
81 }
This page took 0.033323 seconds and 4 git commands to generate.