1 /*******************************************************************************
2 * Copyright (c) 2010 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
{
38 * @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener)
41 public void addListener(ILabelProviderListener listener
) {
42 // TODO Auto-generated method stub
47 * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose()
50 public void dispose() {
51 // TODO Auto-generated method stub
56 * @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object, java.lang.String)
59 public boolean isLabelProperty(Object element
, String property
) {
60 // TODO Auto-generated method stub
66 * @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener)
69 public void removeListener(ILabelProviderListener listener
) {
70 // TODO Auto-generated method stub
75 * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
78 public Image
getImage(Object element
) {
79 // TODO Auto-generated method stub
85 * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
88 public String
getText(Object element
) {
91 if (element
instanceof TmfFilterNode
) {
93 TmfFilterNode node
= (TmfFilterNode
) element
;
94 label
= node
.getNodeName() + " " + node
.getFilterName(); //$NON-NLS-1$
96 } else if (element
instanceof TmfFilterEventTypeNode
) {
98 TmfFilterEventTypeNode node
= (TmfFilterEventTypeNode
) element
;
99 label
= "WITH " + node
.getNodeName() + (node
.getName() != null ?
" " + node
.getName() : ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
101 } else if (element
instanceof TmfFilterAndNode
) {
103 TmfFilterAndNode node
= (TmfFilterAndNode
) element
;
104 label
= (node
.isNot() ?
"NOT " : "") + node
.getNodeName(); //$NON-NLS-1$ //$NON-NLS-2$
106 } else if (element
instanceof TmfFilterOrNode
) {
108 TmfFilterOrNode node
= (TmfFilterOrNode
) element
;
109 label
= (node
.isNot() ?
"NOT " : "") + node
.getNodeName(); //$NON-NLS-1$ //$NON-NLS-2$
111 } else if (element
instanceof TmfFilterContainsNode
) {
113 TmfFilterContainsNode node
= (TmfFilterContainsNode
) element
;
114 label
= (node
.isNot() ?
"NOT " : "") + //$NON-NLS-1$ //$NON-NLS-2$
115 (node
.getField() != null ? node
.getField() + " " : "") + //$NON-NLS-1$ //$NON-NLS-2$
117 (node
.getValue() != null && node
.getValue().length() > 0 ?
" \"" + node
.getValue() + "\"" : ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
119 } else if (element
instanceof TmfFilterEqualsNode
) {
121 TmfFilterEqualsNode node
= (TmfFilterEqualsNode
) element
;
122 label
= (node
.isNot() ?
"NOT " : "") + //$NON-NLS-1$ //$NON-NLS-2$
123 (node
.getField() != null ? node
.getField() + " " : "") + //$NON-NLS-1$ //$NON-NLS-2$
125 (node
.getValue() != null && node
.getValue().length() > 0 ?
" \"" + node
.getValue() + "\"" : ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
127 } else if (element
instanceof TmfFilterMatchesNode
) {
129 TmfFilterMatchesNode node
= (TmfFilterMatchesNode
) element
;
130 label
= (node
.isNot() ?
"NOT " : "") + //$NON-NLS-1$ //$NON-NLS-2$
131 (node
.getField() != null ? node
.getField() + " " : "") + //$NON-NLS-1$ //$NON-NLS-2$
133 (node
.getRegex() != null && node
.getRegex().length() > 0 ?
" \"" + node
.getRegex() + "\"" : ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
135 } else if (element
instanceof TmfFilterCompareNode
) {
137 TmfFilterCompareNode node
= (TmfFilterCompareNode
) element
;
138 label
= (node
.isNot() ?
"NOT " : "") + //$NON-NLS-1$ //$NON-NLS-2$
139 (node
.getField() != null ? node
.getField() + " " : "") + //$NON-NLS-1$ //$NON-NLS-2$
140 (node
.getResult() < 0 ?
"<" : (node
.getResult() > 0 ?
">" : "=")) + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
141 (node
.getValue() != null && node
.getValue().length() > 0 ?
142 (node
.getType() == Type
.ALPHA ?
" \"" + node
.getValue() + "\"" : //$NON-NLS-1$ //$NON-NLS-2$
143 (node
.getType() == Type
.TIMESTAMP ?
" [" + node
.getValue() + "]" : //$NON-NLS-1$ //$NON-NLS-2$
144 " " + node
.getValue())) : ""); //$NON-NLS-1$//$NON-NLS-2$