1 /*******************************************************************************
2 * Copyright (c) 2010, 2012 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 * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
50 protected Control
createDialogArea(Composite parent
) {
51 getShell().setText(Messages
.FilterDialog_FilterDialogTitle
);
52 getShell().setMinimumSize(getShell().computeSize(500, 200));
53 Composite composite
= (Composite
) super.createDialogArea(parent
);
55 fViewer
= new FilterViewer(composite
, SWT
.BORDER
);
56 fViewer
.setInput(fRoot
);
61 * @param filter the filter to set
63 public void setFilter(ITmfFilterTreeNode filter
) {
64 fRoot
= new TmfFilterNode(null);
66 fRoot
.addChild(filter
.clone());
68 if (fViewer
!= null) {
69 fViewer
.setInput(fRoot
);
76 public ITmfFilterTreeNode
getFilter() {
77 if (fRoot
!= null && fRoot
.hasChildren()) {
78 return fRoot
.getChild(0).clone();