}
private void buildResourceGroupContextMenu(final VLayout treeView, final TreeGrid treeGrid, final TreeNode node,
final ResourceGroup group, final ResourceType resourceType) {
// name
setItems(new MenuItem(group.getName()));
// type name
addItem(new MenuItem("Type: " + resourceType.getName()));
// Mixed group refresh is not needed as there is only a single top node. Compat group
// refresh makes sense after a group membership change but we already perform a CoreGUI refresh to
// reset the whole detail view after that user action. So, only support refresh for autogroup nodes
// in the resource tree.
if (node instanceof AutoGroupTreeNode) {
// separator
addItem(new MenuItemSeparator());
// refresh node
MenuItem refresh = new MenuItem(MSG.common_button_refresh());
refresh.addClickHandler(new ClickHandler() {
public void onClick(MenuItemClickEvent event) {
// refresh the tree and detail
((ResourceTreeView) treeView).contextMenuRefresh(treeGrid, node, false);
}
});
addItem(refresh);
}
// separator
addItem(new MenuItemSeparator());
// 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.getEntityTabLink(EntityContext.forGroup(group), "Inventory",
"ConnectionSettings"));
}
});
}
addItem(pluginConfiguration);
// resource config
MenuItem resourceConfiguration = new MenuItem(MSG.view_tree_common_contextMenu_resourceConfiguration());
boolean resourceConfigEnabled = groupComposite.getResourcePermission().isConfigureRead()
&& resourceType.getResourceConfigurationDefinition() != null;
resourceConfiguration.setEnabled(resourceConfigEnabled);
if (resourceConfigEnabled) {
resourceConfiguration.addClickHandler(new ClickHandler() {
public void onClick(MenuItemClickEvent event) {
CoreGUI.goToView(LinkManager.getEntityTabLink(EntityContext.forGroup(group), "Configuration",
"Current"));
}
});
}
addItem(resourceConfiguration);
// separator
addItem(new MenuItemSeparator());
// Operations Menu
MenuItem operations = new MenuItem(MSG.common_title_operations());
boolean operationsEnabled = (groupComposite.getResourcePermission().isControl()
&& null != resourceType.getOperationDefinitions() && !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.getEntityTabLink(EntityContext.forGroup(group),
ResourceDetailView.Tab.Operations.NAME, "Schedules")
+ "/0/"
+ operationDefinition.getId();