public String getText(Object obj) { if (!(obj instanceof ISecurePreferences)) return obj.toString(); ISecurePreferences node = (ISecurePreferences) obj; if (node.parent() == null) return '[' + SecUIMessages.rootNodeName + ']'; return node.name(); }
public String getText(Object obj) { if (!(obj instanceof ISecurePreferences)) return obj.toString(); ISecurePreferences node = (ISecurePreferences) obj; if (node.parent() == null) return '[' + SecUIMessages.rootNodeName + ']'; return node.name(); }
public void menuAboutToShow(IMenuManager manager) { boolean canRemove = false; boolean canAdd = false; TreeSelection selection = (TreeSelection) nodeTreeViewer.getSelection(); Object selected = selection.getFirstElement(); if (selected instanceof ISecurePreferences) { ISecurePreferences node = (ISecurePreferences) selected; boolean isRoot = (node.parent() == null); boolean isInternal = node.absolutePath().startsWith(IStorageConst.PROVIDER_NODE); canRemove = (!isRoot && !isInternal); canAdd = !isInternal; } removeNodeAction.setEnabled(canRemove); addNodeAction.setEnabled(canAdd); } });
public void run() { TreeSelection selection = (TreeSelection) nodeTreeViewer.getSelection(); Object selected = selection.getFirstElement(); if (selected instanceof ISecurePreferences) { ISecurePreferences node = (ISecurePreferences) selected; ISecurePreferences parentNode = node.parent(); if (parentNode == null) return; // can't remove root node node.removeNode(); parentView.modified(); // refresh parent node and select it nodeTreeViewer.refresh(parentNode, false); nodeTreeViewer.setSelection(new StructuredSelection(parentNode), true); } } };
public void run() { TreeSelection selection = (TreeSelection) nodeTreeViewer.getSelection(); Object selected = selection.getFirstElement(); if (selected instanceof ISecurePreferences) { ISecurePreferences node = (ISecurePreferences) selected; ISecurePreferences parentNode = node.parent(); if (parentNode == null) return; // can't remove root node node.removeNode(); parentView.modified(); // refresh parent node and select it nodeTreeViewer.refresh(parentNode, false); nodeTreeViewer.setSelection(new StructuredSelection(parentNode), true); } } };
private void hookContextMenu() { MenuManager menuMgr = new MenuManager(SecUIMessages.nodesContextMenu); menuMgr.addMenuListener(manager -> { boolean canRemove = false; boolean canAdd = false; TreeSelection selection = (TreeSelection) nodeTreeViewer.getSelection(); Object selected = selection.getFirstElement(); if (selected instanceof ISecurePreferences) { ISecurePreferences node = (ISecurePreferences) selected; boolean isRoot = (node.parent() == null); boolean isInternal = node.absolutePath().startsWith(IStorageConst.PROVIDER_NODE); canRemove = (!isRoot && !isInternal); canAdd = !isInternal; } removeNodeAction.setEnabled(canRemove); addNodeAction.setEnabled(canAdd); }); Menu menu = menuMgr.createContextMenu(nodeTreeViewer.getControl()); nodeTreeViewer.getControl().setMenu(menu); // fill context menu menuMgr.add(refreshNodesAction); menuMgr.add(new Separator()); menuMgr.add(addNodeAction); menuMgr.add(removeNodeAction); }
public void run() { TreeSelection selection = (TreeSelection) nodeTreeViewer.getSelection(); Object selected = selection.getFirstElement(); if (selected instanceof ISecurePreferences) { ISecurePreferences node = (ISecurePreferences) selected; NewNodeDialog nodeDialog = new NewNodeDialog(nodeTreeViewer.getControl().getShell()); if (nodeDialog.open() != Window.OK) return; String name = nodeDialog.getNodeName(); ISecurePreferences child = node.node(name); parentView.modified(); // expand and select new node ISecurePreferences parentNode = child.parent(); if (parentNode != null) nodeTreeViewer.refresh(parentNode, false); else nodeTreeViewer.refresh(false); nodeTreeViewer.expandToLevel(child, 0); nodeTreeViewer.setSelection(new StructuredSelection(child), true); } } };
public void run() { TreeSelection selection = (TreeSelection) nodeTreeViewer.getSelection(); Object selected = selection.getFirstElement(); if (selected instanceof ISecurePreferences) { ISecurePreferences node = (ISecurePreferences) selected; NewNodeDialog nodeDialog = new NewNodeDialog(nodeTreeViewer.getControl().getShell()); if (nodeDialog.open() != Window.OK) return; String name = nodeDialog.getNodeName(); ISecurePreferences child = node.node(name); parentView.modified(); // expand and select new node ISecurePreferences parentNode = child.parent(); if (parentNode != null) nodeTreeViewer.refresh(parentNode, false); else nodeTreeViewer.refresh(false); nodeTreeViewer.expandToLevel(child, 0); nodeTreeViewer.setSelection(new StructuredSelection(child), true); } } };