1 /*******************************************************************************
2 * Copyright (c) 2010, 2013 Ericsson
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
10 * Patrick Tasse - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.tmf
.ui
.views
.filter
;
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
;
25 * The dialog for user-defined filters.
28 * @author Patrick Tasse
30 public class FilterDialog
extends Dialog
{
39 * The shell to which this dialog is attached
41 public FilterDialog(Shell shell
) {
43 setShellStyle(getShellStyle() | SWT
.RESIZE
| SWT
.MAX
);
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
);
52 fViewer
= new FilterViewer(composite
, SWT
.BORDER
);
53 fViewer
.setInput(fRoot
);
61 public void setFilter(ITmfFilterTreeNode filter
) {
62 fRoot
= new TmfFilterNode(null);
64 fRoot
.addChild(filter
.clone());
66 if (fViewer
!= null) {
67 fViewer
.setInput(fRoot
);
74 public ITmfFilterTreeNode
getFilter() {
75 if (fRoot
!= null && fRoot
.hasChildren()) {
76 return fRoot
.getChild(0).clone();