use of org.eclipse.tracecompass.tmf.core.filter.model.ITmfFilterTreeNode in project tracecompass by tracecompass.
the class FilterViewer method fillContextMenuForNode.
/**
* 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()) {
final Action action = new Action() {
@Override
public void run() {
ITmfFilterTreeNode newNode = null;
if (TmfFilterNode.NODE_NAME.equals(child)) {
// $NON-NLS-1$
newNode = new TmfFilterNode(node, "");
} else if (TmfFilterTraceTypeNode.NODE_NAME.equals(child)) {
newNode = new TmfFilterTraceTypeNode(node);
} else if (TmfFilterAndNode.NODE_NAME.equals(child)) {
newNode = new TmfFilterAndNode(node);
} else if (TmfFilterOrNode.NODE_NAME.equals(child)) {
newNode = new TmfFilterOrNode(node);
} else if (TmfFilterContainsNode.NODE_NAME.equals(child)) {
newNode = new TmfFilterContainsNode(node);
} else if (TmfFilterEqualsNode.NODE_NAME.equals(child)) {
newNode = new TmfFilterEqualsNode(node);
} else if (TmfFilterMatchesNode.NODE_NAME.equals(child)) {
newNode = new TmfFilterMatchesNode(node);
} else if (TmfFilterCompareNode.NODE_NAME.equals(child)) {
newNode = new TmfFilterCompareNode(node);
}
if (newNode != null) {
fViewer.refresh();
fViewer.setSelection(new StructuredSelection(newNode), true);
}
}
};
if (TmfFilterNode.NODE_NAME.equals(child)) {
// $NON-NLS-1$
action.setText(Messages.FilterViewer_NewPrefix + " " + child);
} else {
action.setText(child);
}
manager.add(action);
}
}
use of org.eclipse.tracecompass.tmf.core.filter.model.ITmfFilterTreeNode in project tracecompass by tracecompass.
the class FilterDragSourceAdapter method dragFinished.
@Override
public void dragFinished(DragSourceEvent event) {
if (event.detail == DND.DROP_MOVE) {
IStructuredSelection selection = (IStructuredSelection) LocalSelectionTransfer.getTransfer().getSelection();
for (Object data : selection.toList()) {
if (data instanceof ITmfFilterTreeNode) {
ITmfFilterTreeNode e = (ITmfFilterTreeNode) data;
e.remove();
fViewer.refresh();
}
}
}
LocalSelectionTransfer.getTransfer().setSelection(null);
LocalSelectionTransfer.getTransfer().setSelectionSetTime(0);
}
use of org.eclipse.tracecompass.tmf.core.filter.model.ITmfFilterTreeNode in project tracecompass by tracecompass.
the class FilterDropTargetAdapter method drop.
@Override
public void drop(DropTargetEvent event) {
ITmfFilterTreeNode treeNodeToDrop = FilterEditUtils.getTransferredTreeNode();
if (event.item instanceof TreeItem) {
Object data = event.item.getData();
if (data instanceof ITmfFilterTreeNode) {
ITmfFilterTreeNode node = (ITmfFilterTreeNode) data;
if (node.getValidChildren().contains(treeNodeToDrop.getNodeName())) {
treeNodeToDrop = treeNodeToDrop.clone();
node.addChild(treeNodeToDrop);
fViewer.refresh();
fViewer.setSelection(treeNodeToDrop, true);
return;
}
}
} else {
// accept only TmfFilterNode
if (TmfFilterNode.NODE_NAME.equals(treeNodeToDrop.getNodeName())) {
ITmfFilterTreeNode root = fViewer.getInput();
treeNodeToDrop = treeNodeToDrop.clone();
root.addChild(treeNodeToDrop);
fViewer.refresh();
fViewer.setSelection(treeNodeToDrop, true);
return;
}
}
}
use of org.eclipse.tracecompass.tmf.core.filter.model.ITmfFilterTreeNode in project tracecompass by tracecompass.
the class FilterEditUtils method getTransferredTreeNode.
/**
* Gets the ITmfFilterTreeNode in LocalSelectionTransfer, if any
* @return a ITmfFilterTreeNode or <code>null</code>
*/
public static ITmfFilterTreeNode getTransferredTreeNode() {
ITmfFilterTreeNode treeNodeToDrop = null;
ISelection sel = LocalSelectionTransfer.getTransfer().getSelection();
if (sel instanceof IStructuredSelection) {
IStructuredSelection selection = (IStructuredSelection) sel;
for (Object data : selection.toList()) {
if (!(data instanceof ITmfFilterTreeNode)) {
return null;
} else if (treeNodeToDrop != null) {
// should never occur, since tree has SWT.SINGLE style
return null;
} else {
treeNodeToDrop = (ITmfFilterTreeNode) data;
}
}
}
return treeNodeToDrop;
}
use of org.eclipse.tracecompass.tmf.core.filter.model.ITmfFilterTreeNode in project tracecompass by tracecompass.
the class TmfFilterTreeNodeTestBase method testClone.
@Test
public void testClone() {
ITmfFilterTreeNode clone = fFilterNode.clone();
assertFalse("clone().equals()", fFilterNode.equals(clone));
assertFalse("clone() ==", fFilterNode == clone);
assertEquals("clone().toString.equals()", fFilterNode.toString(), clone.toString());
assertNull("clone().getParent()", clone.getParent());
}
Aggregations