/*******************************************************************************
- * Copyright (c) 2010 Ericsson
- *
+ * Copyright (c) 2010, 2013 Ericsson
+ *
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
* accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
+ *
* Contributors:
* Patrick Tasse - Initial API and implementation
*******************************************************************************/
private TreeViewer fViewer;
private Composite fComposite;
-
+
public FilterViewer(Composite parent, int style) {
super(parent, style);
setLayout(new FillLayout());
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
setLayoutData(gd);
-
+
final SashForm sash = new SashForm(this, SWT.HORIZONTAL);
// Create the tree viewer to display the filter tree
fViewer.setContentProvider(new FilterTreeContentProvider());
fViewer.setLabelProvider(new FilterTreeLabelProvider());
fViewer.setInput(new TmfFilterRootNode());
-
+
// Create the empty filter node properties panel
fComposite = new Composite(sash, SWT.NONE);
GridLayout gl = new GridLayout();
fComposite.setLayout(gl);
createContextMenu();
-
+
fViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
}
});
}
-
+
/**
* Create the context menu for the tree viewer
*/
// Publish it
fViewer.getTree().setMenu(contextMenu);
}
-
+
/**
- * Fill the context menu for the tree viewer
+ * Fill the context menu for the tree viewer.
+ *
+ * @param manager
+ * The menu manager
*/
protected void fillContextMenu(IMenuManager manager) {
final ISelection selection = fViewer.getSelection();
}
final ITmfFilterTreeNode selectedNode = filterTreeNode;
-
+
if (selectedNode != null) {
-
+
fillContextMenuForNode(selectedNode, manager);
-
+
if (selectedNode.getValidChildren().size() > 0) {
manager.add(new Separator());
}
};
deleteAction.setText(Messages.FilterViewer_DeleteActionText);
manager.add(deleteAction);
-
+
manager.add(new Separator());
}
if (fViewer.getInput() instanceof TmfFilterRootNode || selectedNode == null) {
final ITmfFilterTreeNode root = (ITmfFilterTreeNode) fViewer.getInput();
-
+
fillContextMenuForNode(root, manager);
}
}
-
+
/**
* Fill the context menu with the valid children of the provided node
+ *
+ * @param node
+ * The target node
+ * @param manager
+ * The menu manager
*/
protected void fillContextMenuForNode(final ITmfFilterTreeNode node, IMenuManager manager) {
for (final String child : node.getValidChildren()) {
manager.add(action);
}
}
-
+
/**
* Create the appropriate filter node properties composite
*/
for (Control control : fComposite.getChildren()) {
control.dispose();
}
-
+
if (node instanceof TmfFilterNode) {
new FilterNodeComposite(fComposite, (TmfFilterNode) node);
} else if (node instanceof TmfFilterEventTypeNode) {
}
fComposite.layout();
}
-
+
/**
* Highlight the provided tree items
*/
}
}
-
+
/**
* Reset the provided tree items (remove highlight)
*/
resetTreeItems(item.getItems());
}
}
-
+
public void setInput(ITmfFilterTreeNode root) {
fViewer.setInput(root);
fViewer.expandAll();
-
+
updateFilterNodeComposite(null);
}
-
+
public ITmfFilterTreeNode getInput() {
return (ITmfFilterTreeNode) fViewer.getInput();
}
-
+
public void refresh() {
fViewer.refresh();
}
public void setSelection(ITmfFilterTreeNode node) {
fViewer.setSelection(new StructuredSelection(node));
}
-
+
public ITmfFilterTreeNode getSelection() {
final ISelection selection = fViewer.getSelection();
ITmfFilterTreeNode filterTreeNode = null;
final ITmfFilterTreeNode selectedNode = filterTreeNode;
return selectedNode;
}
-
+
public void addSelectionChangedListener(ISelectionChangedListener listener) {
fViewer.addSelectionChangedListener(listener);
}
-
+
public void removeSelectionChangedListener(ISelectionChangedListener listener) {
fViewer.removeSelectionChangedListener(listener);
}
-
+
private class FilterBaseNodeComposite extends Composite {
-
+
FilterBaseNodeComposite(Composite parent) {
super(parent, SWT.NONE);
setLayout(new GridLayout(2, false));
setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
}
-
+
protected String[] getFieldsList(ITmfFilterTreeNode node) {
ArrayList<String> fieldsList = new ArrayList<String>();
- while (node != null) {
- if (node instanceof TmfFilterEventTypeNode) {
- TmfFilterEventTypeNode eventTypeNode = (TmfFilterEventTypeNode) node;
+ ITmfFilterTreeNode curNode = node;
+ while (curNode != null) {
+ if (curNode instanceof TmfFilterEventTypeNode) {
+ TmfFilterEventTypeNode eventTypeNode = (TmfFilterEventTypeNode) curNode;
for (IConfigurationElement ce : TmfTraceType.getTypeElements()) {
if (ce.getAttribute(TmfTraceType.EVENT_TYPE_ATTR).equals(eventTypeNode.getEventType())) {
try {
}
}
}
- node = node.getParent();
+ curNode = curNode.getParent();
}
fieldsList.add(Messages.FilterViewer_CommonCategory);
private class FilterNodeComposite extends FilterBaseNodeComposite {
TmfFilterNode fNode;
Text fNameText;
-
+
FilterNodeComposite(Composite parent, TmfFilterNode node) {
super(parent);
fNode = node;
-
+
Label label = new Label(this, SWT.NONE);
label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
label.setText(Messages.FilterViewer_NameLabel);
-
+
fNameText = new Text(this, SWT.BORDER);
fNameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
if (node.getFilterName() != null && node.getFilterName().length() > 0) {
TmfFilterEventTypeNode fNode;
Combo fTypeCombo;
Map<String, Object> fEventsTypeMap;
-
+
FilterEventTypeNodeComposite(Composite parent, TmfFilterEventTypeNode node) {
super(parent);
fNode = node;
Label label = new Label(this, SWT.NONE);
label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
label.setText(Messages.FilterViewer_TypeLabel);
-
+
fTypeCombo = new Combo(this, SWT.DROP_DOWN | SWT.READ_ONLY);
fTypeCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
fTypeCombo.setItems(fEventsTypeMap.keySet().toArray(new String[0]));
return eventsTypeMap;
}
}
-
+
private class FilterAndNodeComposite extends FilterBaseNodeComposite {
TmfFilterAndNode fNode;
Button fNotButton;
-
+
FilterAndNodeComposite(Composite parent, TmfFilterAndNode node) {
super(parent);
fNode = node;
-
+
Label label = new Label(this, SWT.NONE);
label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
label.setText(Messages.FilterViewer_NotLabel);
-
+
fNotButton = new Button(this, SWT.CHECK);
fNotButton.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
fNotButton.setSelection(fNode.isNot());
private class FilterOrNodeComposite extends FilterBaseNodeComposite {
TmfFilterOrNode fNode;
Button fNotButton;
-
+
FilterOrNodeComposite(Composite parent, TmfFilterOrNode node) {
super(parent);
fNode = node;
-
+
Label label = new Label(this, SWT.NONE);
label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
label.setText(Messages.FilterViewer_NotLabel);
-
+
fNotButton = new Button(this, SWT.CHECK);
fNotButton.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
fNotButton.setSelection(fNode.isNot());
});
}
}
-
+
private class FilterContainsNodeComposite extends FilterBaseNodeComposite {
TmfFilterContainsNode fNode;
Button fNotButton;
Combo fFieldCombo;
Text fValueText;
Button fIgnoreCaseButton;
-
+
FilterContainsNodeComposite(Composite parent, TmfFilterContainsNode node) {
super(parent);
fNode = node;
-
+
Label label = new Label(this, SWT.NONE);
label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
label.setText(Messages.FilterViewer_NotLabel);
-
+
fNotButton = new Button(this, SWT.CHECK);
fNotButton.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
fNotButton.setSelection(fNode.isNot());
fViewer.refresh(fNode);
}
});
-
+
label = new Label(this, SWT.NONE);
label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
label.setText(Messages.FilterViewer_FieldLabel);
-
+
fFieldCombo = new Combo(this, SWT.DROP_DOWN);
fFieldCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
fFieldCombo.setItems(getFieldsList(fNode));
fViewer.refresh(fNode);
}
});
-
+
label = new Label(this, SWT.NONE);
label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
label.setText(Messages.FilterViewer_ValueLabel);
-
+
fValueText = new Text(this, SWT.BORDER);
fValueText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
if (node.getValue() != null && node.getValue().length() > 0) {
}
}
});
-
+
label = new Label(this, SWT.NONE);
label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
-
+
fIgnoreCaseButton = new Button(this, SWT.CHECK);
fIgnoreCaseButton.setSelection(fNode.isIgnoreCase());
fIgnoreCaseButton.setText(Messages.FilterViewer_IgnoreCaseButtonText);
Combo fFieldCombo;
Text fValueText;
Button fIgnoreCaseButton;
-
+
FilterEqualsNodeComposite(Composite parent, TmfFilterEqualsNode node) {
super(parent);
fNode = node;
-
+
Label label = new Label(this, SWT.NONE);
label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
label.setText(Messages.FilterViewer_NotLabel);
-
+
fNotButton = new Button(this, SWT.CHECK);
fNotButton.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
fNotButton.setSelection(fNode.isNot());
fViewer.refresh(fNode);
}
});
-
+
label = new Label(this, SWT.NONE);
label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
label.setText(Messages.FilterViewer_FieldLabel);
-
+
fFieldCombo = new Combo(this, SWT.DROP_DOWN);
fFieldCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
fFieldCombo.setItems(getFieldsList(fNode));
fViewer.refresh(fNode);
}
});
-
+
label = new Label(this, SWT.NONE);
label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
label.setText(Messages.FilterViewer_ValueLabel);
-
+
fValueText = new Text(this, SWT.BORDER);
fValueText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
if (node.getValue() != null && node.getValue().length() > 0) {
}
}
});
-
+
label = new Label(this, SWT.NONE);
label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
-
+
fIgnoreCaseButton = new Button(this, SWT.CHECK);
fIgnoreCaseButton.setSelection(fNode.isIgnoreCase());
fIgnoreCaseButton.setText(Messages.FilterViewer_IgnoreCaseButtonText);
Button fNotButton;
Combo fFieldCombo;
Text fRegexText;
-
+
FilterMatchesNodeComposite(Composite parent, TmfFilterMatchesNode node) {
super(parent);
fNode = node;
-
+
Label label = new Label(this, SWT.NONE);
label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
label.setText(Messages.FilterViewer_NotLabel);
-
+
fNotButton = new Button(this, SWT.CHECK);
fNotButton.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
fNotButton.setSelection(fNode.isNot());
fViewer.refresh(fNode);
}
});
-
+
label = new Label(this, SWT.NONE);
label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
label.setText(Messages.FilterViewer_FieldLabel);
-
+
fFieldCombo = new Combo(this, SWT.DROP_DOWN);
fFieldCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
fFieldCombo.setItems(getFieldsList(fNode));
fViewer.refresh(fNode);
}
});
-
+
label = new Label(this, SWT.NONE);
label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
label.setText(Messages.FilterViewer_RegexLabel);
-
+
fRegexText = new Text(this, SWT.BORDER);
fRegexText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
if (node.getRegex() != null && node.getRegex().length() > 0) {
Button fNumButton;
Button fAlphaButton;
Button fTimestampButton;
-
+
FilterCompareNodeComposite(Composite parent, TmfFilterCompareNode node) {
super(parent);
fNode = node;
-
+
Label label = new Label(this, SWT.NONE);
label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
label.setText(Messages.FilterViewer_NotLabel);
-
+
fNotButton = new Button(this, SWT.CHECK);
fNotButton.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
fNotButton.setSelection(fNode.isNot());
fViewer.refresh(fNode);
}
});
-
+
label = new Label(this, SWT.NONE);
label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
label.setText(Messages.FilterViewer_FieldLabel);
-
+
fFieldCombo = new Combo(this, SWT.DROP_DOWN);
fFieldCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
fFieldCombo.setItems(getFieldsList(fNode));
fViewer.refresh(fNode);
}
});
-
+
label = new Label(this, SWT.NONE);
label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
label.setText(Messages.FilterViewer_ResultLabel);
-
+
Composite resultGroup = new Composite(this, SWT.NONE);
GridLayout rggl = new GridLayout(3, true);
rggl.marginHeight = 0;
rggl.marginWidth = 0;
resultGroup.setLayout(rggl);
resultGroup.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
-
+
fLTButton = new Button(resultGroup, SWT.RADIO);
fLTButton.setSelection(fNode.getResult() < 0);
fLTButton.setText("<"); //$NON-NLS-1$
fViewer.refresh(fNode);
}
});
-
+
fEQButton = new Button(resultGroup, SWT.RADIO);
fEQButton.setSelection(fNode.getResult() == 0);
fEQButton.setText("="); //$NON-NLS-1$
fViewer.refresh(fNode);
}
});
-
+
fGTButton = new Button(resultGroup, SWT.RADIO);
fGTButton.setSelection(fNode.getResult() > 0);
fGTButton.setText(">"); //$NON-NLS-1$
fViewer.refresh(fNode);
}
});
-
+
label = new Label(this, SWT.NONE);
label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
label.setText(Messages.FilterViewer_TypeLabel);
-
+
Composite typeGroup = new Composite(this, SWT.NONE);
GridLayout tggl = new GridLayout(3, false);
tggl.marginHeight = 0;
tggl.marginWidth = 0;
typeGroup.setLayout(tggl);
typeGroup.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
-
+
fNumButton = new Button(typeGroup, SWT.RADIO);
fNumButton.setSelection(fNode.getType() == Type.NUM);
fNumButton.setText(Messages.FilterViewer_NumButtonText);
fViewer.refresh(fNode);
}
});
-
+
fAlphaButton = new Button(typeGroup, SWT.RADIO);
fAlphaButton.setSelection(fNode.getType() == Type.ALPHA);
fAlphaButton.setText(Messages.FilterViewer_AlphaButtonText);
fViewer.refresh(fNode);
}
});
-
+
fTimestampButton = new Button(typeGroup, SWT.RADIO);
fTimestampButton.setSelection(fNode.getType() == Type.TIMESTAMP);
fTimestampButton.setText(Messages.FilterViewer_TimestampButtonText);
fViewer.refresh(fNode);
}
});
-
+
label = new Label(this, SWT.NONE);
label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
label.setText(Messages.FilterViewer_ValueLabel);
-
+
fValueText = new Text(this, SWT.BORDER);
fValueText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
if (node.getValue() != null && node.getValue().length() > 0) {