[prev in list] [next in list] [prev in thread] [next in thread]
List: rhq-commits
Subject: [rhq] modules/enterprise
From: jshaughn () fedoraproject ! org (Jay Shaughnessy)
Date: 2010-09-27 20:36:44
Message-ID: 20100927203644.45B27120217 () lists ! fedorahosted ! org
[Download RAW message or body]
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupContextMenu.java \
| 306 +++++++++ modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeContextMenu.java \
| 313 ---------- modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java \
| 61 + 3 files changed, 365 insertions(+), 315 deletions(-)
New commits:
commit 2deb29dd26fec00c9d28c6b6d75a823252f9c1c6
Author: Jay Shaughnessy <jshaughn at redhat.com>
Date: Mon Sep 27 16:35:32 2010 -0400
Introduce AutoGroup Context Menu.
- Extracted ResourceGroupContextMenu out of ResourceGroupTreeContextMenu so
that both autogroup and clustergroup backing groups could utilize the
same ResourceGroup context menu code.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupContextMenu.java \
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupContextMenu.java
new file mode 100644
index 0000000..b31c33e
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupContextMenu.java
@@ -0,0 +1,306 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail;
+
+import java.util.EnumSet;
+import java.util.List;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.widgets.Window;
+import com.smartgwt.client.widgets.events.CloseClickHandler;
+import com.smartgwt.client.widgets.events.CloseClientEvent;
+import com.smartgwt.client.widgets.menu.Menu;
+import com.smartgwt.client.widgets.menu.MenuItem;
+import com.smartgwt.client.widgets.menu.MenuItemSeparator;
+import com.smartgwt.client.widgets.menu.events.ClickHandler;
+import com.smartgwt.client.widgets.menu.events.MenuItemClickEvent;
+
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.criteria.ResourceTypeCriteria;
+import org.rhq.core.domain.dashboard.Dashboard;
+import org.rhq.core.domain.dashboard.DashboardPortlet;
+import org.rhq.core.domain.measurement.MeasurementDefinition;
+import org.rhq.core.domain.operation.OperationDefinition;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.domain.resource.group.ResourceGroup;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.resource.graph.GraphPortlet;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.gwt.ResourceTypeGWTServiceAsync;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
+import org.rhq.enterprise.gui.coregui.client.util.message.Message;
+
+/**
+ * @author Greg Hinkle
+ */
+public class ResourceGroupContextMenu extends Menu {
+
+ private ResourceType currentType;
+ //private ResourceGroup group;
+ private ResourceGroup currentGroup;
+
+ public void showContextMenu(ResourceGroup compatibleGroup) {
+ this.currentType = compatibleGroup.getResourceType();
+ this.currentGroup = compatibleGroup;
+
+ ResourceTypeRepository.Cache.getInstance().getResourceTypes(
+ currentType.getId(),
+ EnumSet.of(ResourceTypeRepository.MetadataType.operations, \
ResourceTypeRepository.MetadataType.children, + \
ResourceTypeRepository.MetadataType.subCategory, + \
ResourceTypeRepository.MetadataType.pluginConfigurationDefinition, + \
ResourceTypeRepository.MetadataType.resourceConfigurationDefinition), + \
new ResourceTypeRepository.TypeLoadedCallback() { + public void \
onTypesLoaded(ResourceType type) { +
+ currentType = type;
+
+ buildResourceGroupContextMenu(currentGroup, type);
+ showContextMenu();
+ }
+ });
+
+ }
+
+ private void buildResourceGroupContextMenu(final ResourceGroup group, final \
ResourceType resourceType) { + setItems(new MenuItem(group.getName()));
+
+ addItem(new MenuItem("Type: " + resourceType.getName()));
+
+ MenuItem editPluginConfiguration = new MenuItem("Plugin Configuration");
+ editPluginConfiguration.addClickHandler(new ClickHandler() {
+ public void onClick(MenuItemClickEvent event) {
+ int groupId = group.getId();
+ int resourceTypeId = resourceType.getId();
+
+ Window configEditor = new Window();
+ // configEditor.setTitle("Edit " + group.getName() + \
" plugin configuration"); + configEditor.setWidth(800);
+ configEditor.setHeight(800);
+ configEditor.setIsModal(true);
+ configEditor.setShowModalMask(true);
+ configEditor.setCanDragResize(true);
+ configEditor.centerInPage();
+ // TODO Group config editor
+ // configEditor.addItem(new \
ConfigurationEditor(resourceId, resourceTypeId, + // \
ConfigurationEditor.ConfigType.plugin)); + configEditor.show();
+
+ }
+ });
+ editPluginConfiguration.setEnabled(resourceType.getPluginConfigurationDefinition() \
!= null); + addItem(editPluginConfiguration);
+
+ MenuItem editResourceConfiguration = new MenuItem("Resource Configuration");
+ editResourceConfiguration.addClickHandler(new ClickHandler() {
+ public void onClick(MenuItemClickEvent event) {
+ int groupId = group.getId();
+ int resourceTypeId = resourceType.getId();
+
+ final Window configEditor = new Window();
+ configEditor.setTitle("Edit " + group.getName() + " resource \
configuration"); + configEditor.setWidth(800);
+ configEditor.setHeight(800);
+ configEditor.setIsModal(true);
+ configEditor.setShowModalMask(true);
+ configEditor.setCanDragResize(true);
+ configEditor.setShowResizer(true);
+ configEditor.centerInPage();
+ configEditor.addCloseClickHandler(new CloseClickHandler() {
+ public void onCloseClick(CloseClientEvent closeClientEvent) {
+ configEditor.destroy();
+ }
+ });
+ // TODO group config editor
+ // configEditor.addItem(new \
ConfigurationEditor(resourceId, resourceTypeId, + // \
ConfigurationEditor.ConfigType.resource)); + configEditor.show();
+
+ }
+ });
+ editResourceConfiguration.setEnabled(resourceType.getResourceConfigurationDefinition() \
!= null); + addItem(editResourceConfiguration);
+
+ addItem(new MenuItemSeparator());
+
+ // Operations Menu
+ MenuItem operations = new MenuItem("Operations");
+ Menu opSubMenu = new Menu();
+ if (resourceType.getOperationDefinitions() != null) {
+ for (final OperationDefinition operationDefinition : \
resourceType.getOperationDefinitions()) { + MenuItem operationItem = \
new MenuItem(operationDefinition.getDisplayName()); + \
operationItem.addClickHandler(new ClickHandler() { + public void \
onClick(MenuItemClickEvent event) { +
+ // TODO Group version
+ // ResourceCriteria criteria = new \
ResourceCriteria(); + // \
criteria.addFilterId(selectedResourceId); + //
+ // \
GWTServiceLookup.getResourceService().findResourcesByCriteria(criteria, + \
// new AsyncCallback<PageList<Resource>>() { + \
// public void onFailure(Throwable caught) { + \
// CoreGUI.getErrorHandler() + \
// .handleError("Failed to get resource to run \
operation", caught); + // }
+ //
+ // public void \
onSuccess(PageList<Resource> result) { + // \
new OperationCreateWizard(result.get(0), operationDefinition).startOperationWizard(); \
+ // } + // \
}); +
+ }
+ });
+ opSubMenu.addItem(operationItem);
+ }
+ }
+ operations.setEnabled(resourceType.getOperationDefinitions() != null
+ && !resourceType.getOperationDefinitions().isEmpty());
+ operations.setSubmenu(opSubMenu);
+ addItem(operations);
+
+ addItem(buildMetricsMenu(resourceType));
+
+ /* TODO: We don't support group factory create
+ // Create Menu
+ MenuItem createChildMenu = new MenuItem("Create Child");
+ Menu createChildSubMenu = new Menu();
+ for (final ResourceType childType : resourceType.getChildResourceTypes()) {
+ if (childType.isCreatable()) {
+ MenuItem createItem = new MenuItem(childType.getName());
+ createChildSubMenu.addItem(createItem);
+ createItem.addClickHandler(new ClickHandler() {
+ public void onClick(MenuItemClickEvent event) {
+ ResourceFactoryCreateWizard.showCreateWizard(resource, \
childType); + }
+ });
+
+ }
+ }
+ createChildMenu.setSubmenu(createChildSubMenu);
+ createChildMenu.setEnabled(createChildSubMenu.getItems().length > 0);
+ contextMenu.addItem(createChildMenu);*/
+
+ /*
+ // TODO We don't group manual import
+ // Manually Add Menu
+ MenuItem importChildMenu = new MenuItem("Import");
+ Menu importChildSubMenu = new Menu();
+ for (ResourceType childType : resourceType.getChildResourceTypes()) {
+ if (childType.isSupportsManualAdd()) {
+ importChildSubMenu.addItem(new MenuItem(childType.getName()));
+ }
+ }
+ if (resourceType.getCategory() == ResourceCategory.PLATFORM) {
+ loadManuallyAddServersToPlatforms(importChildSubMenu);
+ }
+ importChildMenu.setSubmenu(importChildSubMenu);
+ importChildMenu.setEnabled(importChildSubMenu.getItems().length > 0);
+ addItem(importChildMenu);
+ */
+ }
+
+ private void loadManuallyAddServersToPlatforms(final Menu manuallyAddMenu) {
+ ResourceTypeGWTServiceAsync rts = \
GWTServiceLookup.getResourceTypeGWTService(); +
+ ResourceTypeCriteria criteria = new ResourceTypeCriteria();
+ criteria.addFilterSupportsManualAdd(true);
+ criteria.fetchParentResourceTypes(true);
+ rts.findResourceTypesByCriteria(criteria, new \
AsyncCallback<PageList<ResourceType>>() { + public void \
onFailure(Throwable caught) { + \
CoreGUI.getErrorHandler().handleError("Failed to load platform manual add children", \
caught); + }
+
+ public void onSuccess(PageList<ResourceType> result) {
+ for (ResourceType type : result) {
+ if (type.getParentResourceTypes() == null || \
type.getParentResourceTypes().isEmpty()) { + MenuItem item = \
new MenuItem(type.getName()); + manuallyAddMenu.addItem(item);
+ }
+ }
+ }
+ });
+ }
+
+ private MenuItem buildMetricsMenu(final ResourceType type) {
+ MenuItem measurements = new MenuItem("Measurements");
+ final Menu measurementsSubMenu = new Menu();
+
+ GWTServiceLookup.getDashboardService().findDashboardsForSubject(new \
AsyncCallback<List<Dashboard>>() { + public void onFailure(Throwable \
caught) { + CoreGUI.getErrorHandler().handleError("Failed to load user \
dashboards", caught); + }
+
+ public void onSuccess(List<Dashboard> result) {
+
+ if (type.getMetricDefinitions() != null) {
+ for (final MeasurementDefinition def : \
type.getMetricDefinitions()) { +
+ MenuItem defItem = new MenuItem(def.getDisplayName());
+ measurementsSubMenu.addItem(defItem);
+ Menu defSubItem = new Menu();
+ defItem.setSubmenu(defSubItem);
+
+ for (final Dashboard d : result) {
+ MenuItem addToDBItem = new MenuItem("Add chart to \
Dashboard: " + d.getName()); + \
defSubItem.addItem(addToDBItem); +
+ addToDBItem.addClickHandler(new ClickHandler() {
+ public void onClick(MenuItemClickEvent \
menuItemClickEvent) { +
+ DashboardPortlet p = new \
DashboardPortlet(def.getDisplayName() + " Chart", + \
GraphPortlet.KEY, 250); + \
p.getConfiguration().put( + new \
PropertySimple(GraphPortlet.CFG_RESOURCE_GROUP_ID, currentGroup.getId())); + \
p.getConfiguration().put( + new \
PropertySimple(GraphPortlet.CFG_DEFINITION_ID, def.getId())); +
+ d.addPortlet(p, 0, 0);
+
+ \
GWTServiceLookup.getDashboardService().storeDashboard(d, + \
new AsyncCallback<Dashboard>() { + public \
void onFailure(Throwable caught) { + \
CoreGUI.getErrorHandler().handleError( + \
"Failed to save dashboard to server", caught); + \
} +
+ public void onSuccess(Dashboard result) \
{ + CoreGUI.getMessageCenter().notify(
+ new Message("Saved dashboard " + \
result.getName() + " to server", + \
Message.Severity.Info)); + }
+ });
+
+ }
+ });
+
+ }
+
+ }
+ }
+
+ }
+ });
+ measurements.setSubmenu(measurementsSubMenu);
+ return measurements;
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeContextMenu.java \
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeContextMenu.java
index 8e1e178..16c6369 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeContextMenu.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeContextMenu.java
@@ -22,328 +22,53 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail;
-import java.util.EnumSet;
-import java.util.List;
-
import com.google.gwt.user.client.rpc.AsyncCallback;
-import com.smartgwt.client.widgets.Window;
-import com.smartgwt.client.widgets.events.CloseClickHandler;
-import com.smartgwt.client.widgets.events.CloseClientEvent;
-import com.smartgwt.client.widgets.menu.Menu;
-import com.smartgwt.client.widgets.menu.MenuItem;
-import com.smartgwt.client.widgets.menu.MenuItemSeparator;
-import com.smartgwt.client.widgets.menu.events.ClickHandler;
-import com.smartgwt.client.widgets.menu.events.MenuItemClickEvent;
import com.smartgwt.client.widgets.tree.TreeNode;
-import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.criteria.ResourceGroupCriteria;
-import org.rhq.core.domain.criteria.ResourceTypeCriteria;
-import org.rhq.core.domain.dashboard.Dashboard;
-import org.rhq.core.domain.dashboard.DashboardPortlet;
-import org.rhq.core.domain.measurement.MeasurementDefinition;
-import org.rhq.core.domain.operation.OperationDefinition;
-import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.resource.group.ClusterKey;
import org.rhq.core.domain.resource.group.ResourceGroup;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
-import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.resource.graph.GraphPortlet;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
-import org.rhq.enterprise.gui.coregui.client.gwt.ResourceTypeGWTServiceAsync;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
-import org.rhq.enterprise.gui.coregui.client.util.message.Message;
/**
* @author Greg Hinkle
*/
-public class ResourceGroupTreeContextMenu extends Menu {
-
- private ResourceType currentType;
- private ResourceGroup group;
- private ResourceGroup currentGroup;
+public class ResourceGroupTreeContextMenu extends ResourceGroupContextMenu {
public void showContextMenu(TreeNode node) {
- currentType = (ResourceType) node.getAttributeAsObject("resourceType");
-
-
final ClusterKey clusterKey = (ClusterKey) node.getAttributeAsObject("key");
if (clusterKey != null) {
GWTServiceLookup.getClusterService().createAutoClusterBackingGroup(clusterKey, \
true,
- new AsyncCallback<ResourceGroup>() {
- @Override
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to create \
or update auto-cluster group: " + clusterKey, caught);
- }
+ new AsyncCallback<ResourceGroup>() {
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(
+ "Failed to create or update auto-cluster group: " + \
clusterKey, caught); + }
- @Override
- public void onSuccess(ResourceGroup result) {
- showContextMenu(result);
- }
- });
+ @Override
+ public void onSuccess(ResourceGroup result) {
+ showContextMenu(result);
+ }
+ });
} else {
ResourceGroupCriteria criteria = new ResourceGroupCriteria();
criteria.addFilterId(Integer.parseInt(node.getAttribute("id")));
GWTServiceLookup.getResourceGroupService().findResourceGroupsByCriteria(criteria,
- new AsyncCallback<PageList<ResourceGroup>>() {
- @Override
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to load \
group for context menu", caught);
- }
-
- @Override
- public void onSuccess(PageList<ResourceGroup> result) {
- showContextMenu(result.get(0));
- }
- });
- }
-
-
- }
-
- private void showContextMenu(ResourceGroup group) {
- this.currentGroup = group;
-
- ResourceTypeRepository.Cache.getInstance().getResourceTypes(
- currentType.getId(),
- EnumSet.of(ResourceTypeRepository.MetadataType.operations,
- ResourceTypeRepository.MetadataType.children,
- ResourceTypeRepository.MetadataType.subCategory,
- \
ResourceTypeRepository.MetadataType.pluginConfigurationDefinition,
- \
ResourceTypeRepository.MetadataType.resourceConfigurationDefinition),
- new ResourceTypeRepository.TypeLoadedCallback() {
- public void onTypesLoaded(ResourceType type) {
-
- currentType = type;
-
-
- buildResourceGroupContextMenu(currentGroup, type);
- showContextMenu();
+ new AsyncCallback<PageList<ResourceGroup>>() {
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to load group \
for context menu", caught); }
- });
-
- }
-
-
- private void buildResourceGroupContextMenu(final ResourceGroup group, final \
ResourceType resourceType) {
- setItems(new MenuItem(group.getName()));
-
- addItem(new MenuItem("Type: " + resourceType.getName()));
-
- MenuItem editPluginConfiguration = new MenuItem("Plugin Configuration");
- editPluginConfiguration.addClickHandler(new ClickHandler() {
- public void onClick(MenuItemClickEvent event) {
- int groupId = group.getId();
- int resourceTypeId = resourceType.getId();
-
- Window configEditor = new Window();
-// configEditor.setTitle("Edit " + group.getName() + " plugin \
configuration");
- configEditor.setWidth(800);
- configEditor.setHeight(800);
- configEditor.setIsModal(true);
- configEditor.setShowModalMask(true);
- configEditor.setCanDragResize(true);
- configEditor.centerInPage();
- // TODO Group config editor
-// configEditor.addItem(new ConfigurationEditor(resourceId, \
resourceTypeId,
-// ConfigurationEditor.ConfigType.plugin));
- configEditor.show();
- }
- });
- editPluginConfiguration.setEnabled(resourceType.getPluginConfigurationDefinition() \
!= null);
- addItem(editPluginConfiguration);
-
- MenuItem editResourceConfiguration = new MenuItem("Resource Configuration");
- editResourceConfiguration.addClickHandler(new ClickHandler() {
- public void onClick(MenuItemClickEvent event) {
- int groupId = group.getId();
- int resourceTypeId = resourceType.getId();
-
- final Window configEditor = new Window();
- configEditor.setTitle("Edit " + group.getName() + " resource \
configuration");
- configEditor.setWidth(800);
- configEditor.setHeight(800);
- configEditor.setIsModal(true);
- configEditor.setShowModalMask(true);
- configEditor.setCanDragResize(true);
- configEditor.setShowResizer(true);
- configEditor.centerInPage();
- configEditor.addCloseClickHandler(new CloseClickHandler() {
- public void onCloseClick(CloseClientEvent closeClientEvent) {
- configEditor.destroy();
+ @Override
+ public void onSuccess(PageList<ResourceGroup> result) {
+ showContextMenu(result.get(0));
}
});
- // TODO group config editor
-// configEditor.addItem(new ConfigurationEditor(resourceId, \
resourceTypeId,
-// ConfigurationEditor.ConfigType.resource));
- configEditor.show();
-
- }
- });
- editResourceConfiguration.setEnabled(resourceType.getResourceConfigurationDefinition() \
!= null);
- addItem(editResourceConfiguration);
-
- addItem(new MenuItemSeparator());
-
- // Operations Menu
- MenuItem operations = new MenuItem("Operations");
- Menu opSubMenu = new Menu();
- if (resourceType.getOperationDefinitions() != null) {
- for (final OperationDefinition operationDefinition : \
resourceType.getOperationDefinitions()) {
- MenuItem operationItem = new \
MenuItem(operationDefinition.getDisplayName());
- operationItem.addClickHandler(new ClickHandler() {
- public void onClick(MenuItemClickEvent event) {
-
- // TODO Group version
-// ResourceCriteria criteria = new ResourceCriteria();
-// criteria.addFilterId(selectedResourceId);
-//
-// \
GWTServiceLookup.getResourceService().findResourcesByCriteria(criteria,
-// new AsyncCallback<PageList<Resource>>() {
-// public void onFailure(Throwable caught) {
-// CoreGUI.getErrorHandler()
-// .handleError("Failed to get resource to run \
operation", caught);
-// }
-//
-// public void onSuccess(PageList<Resource> result) {
-// new OperationCreateWizard(result.get(0), \
operationDefinition).startOperationWizard();
-// }
-// });
-
- }
- });
- opSubMenu.addItem(operationItem);
- }
- }
- operations.setEnabled(resourceType.getOperationDefinitions() != null && \
!resourceType.getOperationDefinitions().isEmpty());
- operations.setSubmenu(opSubMenu);
- addItem(operations);
-
- addItem(buildMetricsMenu(resourceType));
-
- /* TODO: We don't support group factory create
- // Create Menu
- MenuItem createChildMenu = new MenuItem("Create Child");
- Menu createChildSubMenu = new Menu();
- for (final ResourceType childType : resourceType.getChildResourceTypes()) {
- if (childType.isCreatable()) {
- MenuItem createItem = new MenuItem(childType.getName());
- createChildSubMenu.addItem(createItem);
- createItem.addClickHandler(new ClickHandler() {
- public void onClick(MenuItemClickEvent event) {
- ResourceFactoryCreateWizard.showCreateWizard(resource, \
childType);
- }
- });
-
- }
- }
- createChildMenu.setSubmenu(createChildSubMenu);
- createChildMenu.setEnabled(createChildSubMenu.getItems().length > 0);
- contextMenu.addItem(createChildMenu);*/
-
- /*
- // TODO We don't group manual import
- // Manually Add Menu
- MenuItem importChildMenu = new MenuItem("Import");
- Menu importChildSubMenu = new Menu();
- for (ResourceType childType : resourceType.getChildResourceTypes()) {
- if (childType.isSupportsManualAdd()) {
- importChildSubMenu.addItem(new MenuItem(childType.getName()));
- }
- }
- if (resourceType.getCategory() == ResourceCategory.PLATFORM) {
- loadManuallyAddServersToPlatforms(importChildSubMenu);
}
- importChildMenu.setSubmenu(importChildSubMenu);
- importChildMenu.setEnabled(importChildSubMenu.getItems().length > 0);
- addItem(importChildMenu);
- */
- }
-
- private void loadManuallyAddServersToPlatforms(final Menu manuallyAddMenu) {
- ResourceTypeGWTServiceAsync rts = \
GWTServiceLookup.getResourceTypeGWTService();
-
- ResourceTypeCriteria criteria = new ResourceTypeCriteria();
- criteria.addFilterSupportsManualAdd(true);
- criteria.fetchParentResourceTypes(true);
- rts.findResourceTypesByCriteria(criteria, new \
AsyncCallback<PageList<ResourceType>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to load platform \
manual add children", caught);
- }
-
- public void onSuccess(PageList<ResourceType> result) {
- for (ResourceType type : result) {
- if (type.getParentResourceTypes() == null || \
type.getParentResourceTypes().isEmpty()) {
- MenuItem item = new MenuItem(type.getName());
- manuallyAddMenu.addItem(item);
- }
- }
- }
- });
- }
-
- private MenuItem buildMetricsMenu(final ResourceType type) {
- MenuItem measurements = new MenuItem("Measurements");
- final Menu measurementsSubMenu = new Menu();
-
- GWTServiceLookup.getDashboardService().findDashboardsForSubject(new \
AsyncCallback<List<Dashboard>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to load user \
dashboards", caught);
- }
-
- public void onSuccess(List<Dashboard> result) {
-
- if (type.getMetricDefinitions() != null) {
- for (final MeasurementDefinition def : \
type.getMetricDefinitions()) {
-
- MenuItem defItem = new MenuItem(def.getDisplayName());
- measurementsSubMenu.addItem(defItem);
- Menu defSubItem = new Menu();
- defItem.setSubmenu(defSubItem);
-
- for (final Dashboard d : result) {
- MenuItem addToDBItem = new MenuItem("Add chart to \
Dashboard: " + d.getName());
- defSubItem.addItem(addToDBItem);
-
- addToDBItem.addClickHandler(new ClickHandler() {
- public void onClick(MenuItemClickEvent \
menuItemClickEvent) {
-
- DashboardPortlet p = new \
DashboardPortlet(def.getDisplayName() + " Chart",
- GraphPortlet.KEY, 250);
- p.getConfiguration().put(
- new \
PropertySimple(GraphPortlet.CFG_RESOURCE_GROUP_ID, group.getId()));
- p.getConfiguration().put(
- new \
PropertySimple(GraphPortlet.CFG_DEFINITION_ID, def.getId()));
-
- d.addPortlet(p, 0, 0);
-
- \
GWTServiceLookup.getDashboardService().storeDashboard(d,
- new AsyncCallback<Dashboard>() {
- public void onFailure(Throwable \
caught) {
- \
CoreGUI.getErrorHandler().handleError("Failed to save dashboard to \
server",
- caught);
- }
-
- public void onSuccess(Dashboard \
result) {
- \
CoreGUI.getMessageCenter().notify(
- new Message("Saved \
dashboard " + result.getName() + " to server",
- \
Message.Severity.Info));
- }
- });
-
- }
- });
-
- }
-
- }
- }
-
- }
- });
- measurements.setSubmenu(measurementsSubMenu);
- return measurements;
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java \
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
index 2c7a973..6a7cba9 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
@@ -75,6 +75,7 @@ import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGroupGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.gwt.ResourceTypeGWTServiceAsync;
+import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.ResourceGroupContextMenu;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceSelectListener;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.ResourceTreeDatasource.AutoGroupTreeNode;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.ResourceTreeDatasource.ResourceTreeNode;
@@ -91,12 +92,14 @@ public class ResourceTreeView extends LocatableVLayout {
private TreeGrid treeGrid;
private String selectedNodeId;
- private Menu contextMenu;
private Resource rootResource;
private ViewId currentViewId;
+ private Menu resourceContextMenu;
+ private ResourceGroupContextMenu autoGroupContextMenu;
+
private List<ResourceSelectListener> selectListeners = new \
ArrayList<ResourceSelectListener>();
// Maps autogroup/type backing group ids to the corresponding autogroup/type \
nodes. @@ -131,7 +134,8 @@ public class ResourceTreeView extends LocatableVLayout {
treeGrid.setLeaveScrollbarGap(false);
- contextMenu = new Menu();
+ resourceContextMenu = new Menu();
+ autoGroupContextMenu = new ResourceGroupContextMenu();
treeGrid.addSelectionChangedHandler(new SelectionChangedHandler() {
public void onSelectionChanged(SelectionEvent selectionEvent) {
@@ -152,7 +156,15 @@ public class ResourceTreeView extends LocatableVLayout {
AutoGroupTreeNode agNode = (AutoGroupTreeNode) \
selectedRecord; selectedNodeId = agNode.getID();
- handleSelectedAutoGroupNode(agNode);
+ getAutoGroupBackingGroup(agNode, new \
AsyncCallback<ResourceGroup>() { + public void \
onFailure(Throwable caught) { + \
CoreGUI.getErrorHandler().handleError("Failed to select autogroup node", caught); + \
} +
+ public void onSuccess(ResourceGroup result) {
+ renderAutoGroup(result);
+ }
+ });
} else {
System.out.println("Unhandled Node selected in tree: " + \
selectedRecord); }
@@ -161,7 +173,7 @@ public class ResourceTreeView extends LocatableVLayout {
});
// This constructs the context menu for the resource at the time of the \
click.
- setContextMenu(contextMenu);
+ // setContextMenu(resourceContextMenu);
treeGrid.addNodeContextClickHandler(new NodeContextClickHandler() {
public void onNodeContextClick(final NodeContextClickEvent event) {
@@ -183,7 +195,7 @@ public class ResourceTreeView extends LocatableVLayout {
});
}
- private void handleSelectedAutoGroupNode(final AutoGroupTreeNode agNode) {
+ private void getAutoGroupBackingGroup(final AutoGroupTreeNode agNode, final \
AsyncCallback<ResourceGroup> callback) {
final ResourceGroupGWTServiceAsync resourceGroupService = \
GWTServiceLookup.getResourceGroupService();
// get the children tree nodes and build a child resourceId array
@@ -223,7 +235,8 @@ public class ResourceTreeView extends LocatableVLayout {
// store a map entry from backingGroupId to \
AGTreeNode so we can easily
// get back to this node given the id of the backing \
group (from the viewpath)
autoGroupNodeMap.put(result.getId(), agNode);
- renderAutoGroup(result);
+ callback.onSuccess(result);
+ //renderAutoGroup(result);
}
});
} else {
@@ -243,13 +256,12 @@ public class ResourceTreeView extends LocatableVLayout {
}
public void onSuccess(Void result) {
- renderAutoGroup(backingGroup);
+ callback.onSuccess(backingGroup);
}
});
}
}
});
-
}
private void renderAutoGroup(ResourceGroup backingGroup) {
@@ -290,9 +302,16 @@ public class ResourceTreeView extends LocatableVLayout {
}
}
- private void showContextMenu(AutoGroupTreeNode node) {
- contextMenu.setItems(new MenuItem(node.getName()));
- contextMenu.showContextMenu();
+ private void showContextMenu(AutoGroupTreeNode agNode) {
+ getAutoGroupBackingGroup(agNode, new AsyncCallback<ResourceGroup>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to select AutoGroup \
node", caught); + }
+
+ public void onSuccess(ResourceGroup result) {
+ autoGroupContextMenu.showContextMenu(result);
+ }
+ });
}
private void showContextMenu(final ResourceTreeNode node) {
@@ -306,15 +325,15 @@ public class ResourceTreeView extends LocatableVLayout {
new ResourceTypeRepository.TypeLoadedCallback() {
public void onTypesLoaded(ResourceType type) {
buildResourceContextMenu(node.getResource(), type);
- contextMenu.showContextMenu();
+ resourceContextMenu.showContextMenu();
}
});
}
private void buildResourceContextMenu(final Resource resource, final \
ResourceType resourceType) {
- contextMenu.setItems(new MenuItem(resource.getName()));
+ resourceContextMenu.setItems(new MenuItem(resource.getName()));
- contextMenu.addItem(new MenuItem("Type: " + resourceType.getName()));
+ resourceContextMenu.addItem(new MenuItem("Type: " + \
resourceType.getName()));
MenuItem editPluginConfiguration = new MenuItem("Plugin Configuration");
editPluginConfiguration.addClickHandler(new ClickHandler() {
@@ -337,7 +356,7 @@ public class ResourceTreeView extends LocatableVLayout {
}
});
editPluginConfiguration.setEnabled(resourceType.getPluginConfigurationDefinition() \
!= null);
- contextMenu.addItem(editPluginConfiguration);
+ resourceContextMenu.addItem(editPluginConfiguration);
MenuItem editResourceConfiguration = new MenuItem("Resource Configuration");
editResourceConfiguration.addClickHandler(new ClickHandler() {
@@ -366,9 +385,9 @@ public class ResourceTreeView extends LocatableVLayout {
}
});
editResourceConfiguration.setEnabled(resourceType.getResourceConfigurationDefinition() \
!= null);
- contextMenu.addItem(editResourceConfiguration);
+ resourceContextMenu.addItem(editResourceConfiguration);
- contextMenu.addItem(new MenuItemSeparator());
+ resourceContextMenu.addItem(new MenuItemSeparator());
// Operations Menu
MenuItem operations = new MenuItem("Operations");
@@ -402,9 +421,9 @@ public class ResourceTreeView extends LocatableVLayout {
}
operations.setEnabled(!resourceType.getOperationDefinitions().isEmpty());
operations.setSubmenu(opSubMenu);
- contextMenu.addItem(operations);
+ resourceContextMenu.addItem(operations);
- contextMenu.addItem(buildMetricsMenu(resourceType));
+ resourceContextMenu.addItem(buildMetricsMenu(resourceType));
// Create Menu
MenuItem createChildMenu = new MenuItem("Create Child");
@@ -423,7 +442,7 @@ public class ResourceTreeView extends LocatableVLayout {
}
createChildMenu.setSubmenu(createChildSubMenu);
createChildMenu.setEnabled(createChildSubMenu.getItems().length > 0);
- contextMenu.addItem(createChildMenu);
+ resourceContextMenu.addItem(createChildMenu);
// Manually Add Menu
MenuItem importChildMenu = new MenuItem("Import");
@@ -439,7 +458,7 @@ public class ResourceTreeView extends LocatableVLayout {
}
importChildMenu.setSubmenu(importChildSubMenu);
importChildMenu.setEnabled(importChildSubMenu.getItems().length > 0);
- contextMenu.addItem(importChildMenu);
+ resourceContextMenu.addItem(importChildMenu);
}
private void loadManuallyAddServersToPlatforms(final Menu manuallyAddMenu) {
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic