use of org.eclipse.tracecompass.tmf.core.filter.model.ITmfFilterTreeNode in project tracecompass by tracecompass.
the class FilterView method addFilter.
/**
* Add a filter to the FilterView and select it. This does not modify the
* XML, which must be done manually. If an equivalent filter is already in
* the FilterView, it is not added.
*
* @param filter
* The filter to add.
*/
public void addFilter(ITmfFilterTreeNode filter) {
if (filter == null) {
return;
}
ITmfFilterTreeNode root = fViewer.getInput();
for (ITmfFilterTreeNode node : root.getChildren()) {
// Use toString(explicit) equality because equals() is not implemented
if (node.toString(true).equals(filter.toString(true))) {
fViewer.setSelection(node);
return;
}
}
root.addChild(filter.clone());
fViewer.setInput(root);
fViewer.setSelection(filter);
}
use of org.eclipse.tracecompass.tmf.core.filter.model.ITmfFilterTreeNode in project tracecompass by tracecompass.
the class FilterViewer method fillContextMenu.
/**
* Fill the context menu for the tree viewer.
*
* @param manager
* The menu manager
*/
protected void fillContextMenu(IMenuManager manager) {
final ISelection selection = fViewer.getSelection();
ITmfFilterTreeNode filterTreeNode = null;
if (selection instanceof StructuredSelection) {
Object element = ((StructuredSelection) selection).getFirstElement();
if (element instanceof ITmfFilterTreeNode) {
filterTreeNode = (ITmfFilterTreeNode) element;
}
}
final ITmfFilterTreeNode selectedNode = filterTreeNode;
if (selectedNode != null) {
fillContextMenuForNode(selectedNode, manager);
}
// $NON-NLS-1$
manager.add(new Separator("delete"));
if (fIsDialog && (selectedNode != null)) {
Action deleteAction = new Action(Messages.FilterViewer_DeleteActionText) {
@Override
public void run() {
selectedNode.remove();
fViewer.refresh();
}
};
deleteAction.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_DELETE));
manager.add(deleteAction);
}
// $NON-NLS-1$
manager.add(new Separator("edit"));
if (fViewer.getInput() instanceof TmfFilterRootNode || filterTreeNode == null) {
manager.add(new Separator());
ITmfFilterTreeNode root = (ITmfFilterTreeNode) fViewer.getInput();
fillContextMenuForNode(root, manager);
}
}
use of org.eclipse.tracecompass.tmf.core.filter.model.ITmfFilterTreeNode in project tracecompass by tracecompass.
the class FilterViewer method getSelection.
public ITmfFilterTreeNode getSelection() {
final ISelection selection = fViewer.getSelection();
ITmfFilterTreeNode filterTreeNode = null;
if (selection instanceof StructuredSelection) {
Object element = ((StructuredSelection) selection).getFirstElement();
if (element instanceof ITmfFilterTreeNode) {
filterTreeNode = (ITmfFilterTreeNode) element;
}
}
final ITmfFilterTreeNode selectedNode = filterTreeNode;
return selectedNode;
}
use of org.eclipse.tracecompass.tmf.core.filter.model.ITmfFilterTreeNode in project tracecompass by tracecompass.
the class PasteHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
// Check if we are closing down
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window == null) {
return null;
}
// Get the selection
IWorkbenchPage page = window.getActivePage();
IWorkbenchPart part = page.getActivePart();
if (!(part instanceof FilterView)) {
return null;
}
FilterView v = (FilterView) part;
ITmfFilterTreeNode objectToPaste = FilterEditUtils.getTransferredTreeNode();
objectToPaste = objectToPaste.clone();
ITmfFilterTreeNode sel = v.getSelection();
if (sel == null || TmfFilterNode.NODE_NAME.equals(objectToPaste.getNodeName())) {
sel = v.getFilterRoot();
}
sel.addChild(objectToPaste);
v.refresh();
v.setSelection(objectToPaste);
return null;
}
use of org.eclipse.tracecompass.tmf.core.filter.model.ITmfFilterTreeNode in project tracecompass by tracecompass.
the class PasteHandler method isEnabled.
@Override
public boolean isEnabled() {
// Check if we are closing down
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window == null) {
return false;
}
// Get the selection
IWorkbenchPage page = window.getActivePage();
IWorkbenchPart part = page.getActivePart();
if (!(part instanceof FilterView)) {
return false;
}
FilterView v = (FilterView) part;
ITmfFilterTreeNode sel = v.getSelection();
if (sel == null) {
sel = v.getFilterRoot();
}
ITmfFilterTreeNode objectToPaste = FilterEditUtils.getTransferredTreeNode();
return (v.isTreeInFocus() && objectToPaste != null && (sel.getValidChildren().contains(objectToPaste.getNodeName()) || TmfFilterNode.NODE_NAME.equals(objectToPaste.getNodeName())));
}
Aggregations