use of com.microsoft.tooling.msservices.serviceexplorer.NodeAction in project azure-tools-for-java by Microsoft.
the class ServerExplorerToolWindowFactory method createPopupMenuForNode.
private JPopupMenu createPopupMenuForNode(Node node) {
JPopupMenu menu = new JPopupMenu();
for (final NodeAction nodeAction : node.getNodeActions()) {
JMenuItem menuItem = new JMenuItem(nodeAction.getName());
// menuItem.setIconTextGap(16);
menuItem.setEnabled(nodeAction.isEnabled());
if (nodeAction.getIconPath() != null) {
menuItem.setIcon(UIHelperImpl.loadIcon(nodeAction.getIconPath()));
}
// delegate the menu item click to the node action's listeners
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
nodeAction.fireNodeActionEvent();
}
});
menu.add(menuItem);
}
return menu;
}
use of com.microsoft.tooling.msservices.serviceexplorer.NodeAction in project azure-tools-for-java by Microsoft.
the class FileEditorVirtualNode method createJMenuItem.
public JMenuItem createJMenuItem(final String actionName) {
final JMenuItem menuItem = new JMenuItem(actionName);
final NodeAction nodeAction = getNodeActionByName(actionName);
if (nodeAction != null) {
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
nodeAction.fireNodeActionEvent();
}
});
}
return menuItem;
}
use of com.microsoft.tooling.msservices.serviceexplorer.NodeAction in project azure-tools-for-java by Microsoft.
the class ExternalStorageNode method refreshItems.
@Override
protected void refreshItems() throws AzureCmdException {
if (storageAccount.getPrimaryKey().isEmpty()) {
try {
NodeActionListener listener = node2Actions.get(this.getClass()).get(0).getConstructor().newInstance();
listener.actionPerformedAsync(new NodeActionEvent(new NodeAction(this, this.getName()))).get();
} catch (Throwable t) {
throw new AzureCmdException("Error opening external storage", t);
}
} else {
fillChildren();
}
}
use of com.microsoft.tooling.msservices.serviceexplorer.NodeAction in project azure-tools-for-java by Microsoft.
the class ServiceExplorerView method hookContextMenu.
private void hookContextMenu() {
MenuManager menuMgr = new MenuManager("#PopupMenu");
menuMgr.setRemoveAllWhenShown(true);
menuMgr.addMenuListener(new IMenuListener() {
@Override
public void menuAboutToShow(IMenuManager manager) {
if (viewer.getSelection().isEmpty()) {
return;
}
if (viewer.getSelection() instanceof IStructuredSelection) {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
Node node = ((TreeNode) selection.getFirstElement()).node;
if (node.hasNodeActions()) {
for (final NodeAction nodeAction : node.getNodeActions()) {
ImageDescriptor imageDescriptor = nodeAction.getIconPath() != null ? Activator.getImageDescriptor("icons/" + nodeAction.getIconPath()) : null;
Action action = new Action(nodeAction.getName(), imageDescriptor) {
@Override
public void run() {
nodeAction.fireNodeActionEvent();
}
};
action.setEnabled(nodeAction.isEnabled());
manager.add(action);
}
}
}
}
});
Menu menu = menuMgr.createContextMenu(viewer.getControl());
viewer.getControl().setMenu(menu);
}
Aggregations