// separator
resourceContextMenu.addItem(new MenuItemSeparator());
// refresh node
MenuItem refresh = new MenuItem(MSG.common_button_refresh());
refresh.addClickHandler(new ClickHandler() {
public void onClick(MenuItemClickEvent event) {
contextMenuRefresh(treeGrid, node, false);
}
});
resourceContextMenu.addItem(refresh);
// separator
resourceContextMenu.addItem(new MenuItemSeparator());
// child resources
MenuItem childResources = new MenuItem(MSG.view_tabs_common_child_resources());
boolean childResourcesEnabled = resourceType.getChildResourceTypes() != null
&& !resourceType.getChildResourceTypes().isEmpty();
childResources.setEnabled(childResourcesEnabled);
if (childResourcesEnabled) {
childResources.addClickHandler(new ClickHandler() {
public void onClick(MenuItemClickEvent event) {
CoreGUI.goToView(LinkManager.getResourceTabLink(resource.getId(), "Inventory", "Children"));
}
});
}
resourceContextMenu.addItem(childResources);
// plugin config
MenuItem pluginConfiguration = new MenuItem(MSG.view_tabs_common_connectionSettings());
boolean pluginConfigEnabled = resourceType.getPluginConfigurationDefinition() != null;
pluginConfiguration.setEnabled(pluginConfigEnabled);
if (pluginConfigEnabled) {
pluginConfiguration.addClickHandler(new ClickHandler() {
public void onClick(MenuItemClickEvent event) {
CoreGUI.goToView(LinkManager.getResourceTabLink(resource.getId(), "Inventory", "ConnectionSettings"));
}
});
}
resourceContextMenu.addItem(pluginConfiguration);
// resource config
MenuItem resourceConfiguration = new MenuItem(MSG.view_tree_common_contextMenu_resourceConfiguration());
boolean resourceConfigEnabled = resourcePermission.isConfigureRead()
&& resourceType.getResourceConfigurationDefinition() != null;
resourceConfiguration.setEnabled(resourceConfigEnabled);
if (resourceConfigEnabled) {
resourceConfiguration.addClickHandler(new ClickHandler() {
public void onClick(MenuItemClickEvent event) {
CoreGUI.goToView(LinkManager.getResourceTabLink(resource.getId(), "Configuration", "Current"));
}
});
}
resourceContextMenu.addItem(resourceConfiguration);
// separator
resourceContextMenu.addItem(new MenuItemSeparator());
// Operations Menu
MenuItem operations = new MenuItem(MSG.common_title_operations());
boolean operationsEnabled = (resourcePermission.isControl() && (resourceType.getOperationDefinitions() != null) && !resourceType
.getOperationDefinitions().isEmpty());
operations.setEnabled(operationsEnabled);
if (operationsEnabled) {
Menu opSubMenu = new Menu();
//sort the display items alphabetically
TreeSet<String> ordered = new TreeSet<String>();
Map<String, OperationDefinition> definitionMap = new HashMap<String, OperationDefinition>();
for (OperationDefinition o : resourceType.getOperationDefinitions()) {
ordered.add(o.getDisplayName());
definitionMap.put(o.getDisplayName(), o);
}
for (String displayName : ordered) {
final OperationDefinition operationDefinition = definitionMap.get(displayName);
MenuItem operationItem = new MenuItem(operationDefinition.getDisplayName());
operationItem.addClickHandler(new ClickHandler() {
public void onClick(MenuItemClickEvent event) {
String viewPath = LinkManager.getResourceTabLink(resource.getId(),
ResourceDetailView.Tab.Operations.NAME, "Schedules") + "/0/" + operationDefinition.getId();
CoreGUI.goToView(viewPath);