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 * Yuriy Vashchuk - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.tmf
.ui
.views
.filter
;
15 import org
.eclipse
.jface
.viewers
.ILabelProvider
;
16 import org
.eclipse
.jface
.viewers
.ILabelProviderListener
;
17 import org
.eclipse
.linuxtools
.tmf
.core
.filter
.model
.TmfFilterAndNode
;
18 import org
.eclipse
.linuxtools
.tmf
.core
.filter
.model
.TmfFilterCompareNode
;
19 import org
.eclipse
.linuxtools
.tmf
.core
.filter
.model
.TmfFilterCompareNode
.Type
;
20 import org
.eclipse
.linuxtools
.tmf
.core
.filter
.model
.TmfFilterContainsNode
;
21 import org
.eclipse
.linuxtools
.tmf
.core
.filter
.model
.TmfFilterEqualsNode
;
22 import org
.eclipse
.linuxtools
.tmf
.core
.filter
.model
.TmfFilterEventTypeNode
;
23 import org
.eclipse
.linuxtools
.tmf
.core
.filter
.model
.TmfFilterMatchesNode
;
24 import org
.eclipse
.linuxtools
.tmf
.core
.filter
.model
.TmfFilterNode
;
25 import org
.eclipse
.linuxtools
.tmf
.core
.filter
.model
.TmfFilterOrNode
;
26 import org
.eclipse
.swt
.graphics
.Image
;
29 * This is the Label Provider for our Filter Tree
32 * @author Yuriy Vashchuk
34 public class FilterTreeLabelProvider
implements ILabelProvider
{
37 public void addListener(ILabelProviderListener listener
) {
38 // TODO Auto-generated method stub
42 public void dispose() {
43 // TODO Auto-generated method stub
47 public boolean isLabelProperty(Object element
, String property
) {
48 // TODO Auto-generated method stub
53 public void removeListener(ILabelProviderListener listener
) {
54 // TODO Auto-generated method stub
58 public Image
getImage(Object element
) {
59 // TODO Auto-generated method stub
64 public String
getText(Object element
) {
67 if (element
instanceof TmfFilterNode
) {
69 TmfFilterNode node
= (TmfFilterNode
) element
;
70 label
= node
.getNodeName() + " " + node
.getFilterName(); //$NON-NLS-1$
72 } else if (element
instanceof TmfFilterEventTypeNode
) {
74 TmfFilterEventTypeNode node
= (TmfFilterEventTypeNode
) element
;
75 label
= "WITH " + node
.getNodeName() + (node
.getName() != null ?
" " + node
.getName() : ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
77 } else if (element
instanceof TmfFilterAndNode
) {
79 TmfFilterAndNode node
= (TmfFilterAndNode
) element
;
80 label
= (node
.isNot() ?
"NOT " : "") + node
.getNodeName(); //$NON-NLS-1$ //$NON-NLS-2$
82 } else if (element
instanceof TmfFilterOrNode
) {
84 TmfFilterOrNode node
= (TmfFilterOrNode
) element
;
85 label
= (node
.isNot() ?
"NOT " : "") + node
.getNodeName(); //$NON-NLS-1$ //$NON-NLS-2$
87 } else if (element
instanceof TmfFilterContainsNode
) {
89 TmfFilterContainsNode node
= (TmfFilterContainsNode
) element
;
90 label
= (node
.isNot() ?
"NOT " : "") + //$NON-NLS-1$ //$NON-NLS-2$
91 (node
.getField() != null ? node
.getField() + " " : "") + //$NON-NLS-1$ //$NON-NLS-2$
93 (node
.getValue() != null && node
.getValue().length() > 0 ?
" \"" + node
.getValue() + "\"" : ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
95 } else if (element
instanceof TmfFilterEqualsNode
) {
97 TmfFilterEqualsNode node
= (TmfFilterEqualsNode
) element
;
98 label
= (node
.isNot() ?
"NOT " : "") + //$NON-NLS-1$ //$NON-NLS-2$
99 (node
.getField() != null ? node
.getField() + " " : "") + //$NON-NLS-1$ //$NON-NLS-2$
101 (node
.getValue() != null && node
.getValue().length() > 0 ?
" \"" + node
.getValue() + "\"" : ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
103 } else if (element
instanceof TmfFilterMatchesNode
) {
105 TmfFilterMatchesNode node
= (TmfFilterMatchesNode
) element
;
106 label
= (node
.isNot() ?
"NOT " : "") + //$NON-NLS-1$ //$NON-NLS-2$
107 (node
.getField() != null ? node
.getField() + " " : "") + //$NON-NLS-1$ //$NON-NLS-2$
109 (node
.getRegex() != null && node
.getRegex().length() > 0 ?
" \"" + node
.getRegex() + "\"" : ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
111 } else if (element
instanceof TmfFilterCompareNode
) {
113 TmfFilterCompareNode node
= (TmfFilterCompareNode
) element
;
114 label
= (node
.isNot() ?
"NOT " : "") + //$NON-NLS-1$ //$NON-NLS-2$
115 (node
.getField() != null ? node
.getField() + " " : "") + //$NON-NLS-1$ //$NON-NLS-2$
116 (node
.getResult() < 0 ?
"<" : (node
.getResult() > 0 ?
">" : "=")) + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
117 (node
.getValue() != null && node
.getValue().length() > 0 ?
118 (node
.getType() == Type
.ALPHA ?
" \"" + node
.getValue() + "\"" : //$NON-NLS-1$ //$NON-NLS-2$
119 (node
.getType() == Type
.TIMESTAMP ?
" [" + node
.getValue() + "]" : //$NON-NLS-1$ //$NON-NLS-2$
120 " " + node
.getValue())) : ""); //$NON-NLS-1$//$NON-NLS-2$