modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/ResourceGroup.java | 4 modules/core/domain/src/test/java/org/rhq/core/domain/configuration/test/DataSourceExample.java | 2 modules/enterprise/gui/coregui/pom.xml | 2 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java | 4 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java | 2 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/EnhancedDynamicForm.java | 36 - modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/TogglableTextItem.java | 3 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java | 12 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/OverviewView.java | 241 ------- modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/OverviewView.java | 241 +++++++ modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java | 8 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTopView.java | 160 +++++ modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceView.java | 160 ----- modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/overview/ResourceOverviewView.java | 61 -- modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/overview/ResourceSummaryView.java | 289 --------- modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/DashboardView.java | 52 + modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/OverviewView.java | 302 ++++++++++ modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/tag/FunctionTagLibrary.java | 2 modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/DisambiguatedResourceLineageRenderer.java | 2 modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/ResourceLineageRenderer.java | 2 modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/taglib/InventoryHierarchyTag.java | 2 modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/taglib/display/DisambiguatedResourceNameTag.java | 2 modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/group/ResourceGroupTreeContextMenuUIBean.java | 2 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/PerspectiveTarget.java | 2 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java | 4 modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronComponent.java | 2 modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/serviceBinding/SetComponent.java | 2 27 files changed, 816 insertions(+), 785 deletions(-)
New commits: commit 2d5cada01618a79e2819b7dbfeb763bc32a1620d Author: Ian Springer ian.springer@redhat.com Date: Fri Aug 13 18:56:30 2010 -0400
change how togglable form items are rendered (edit icon now only appears when you hover over the item); add missing updateResource() method to WebServicesManagerBean; move group Overview subtab from Inventory tab to Summary tab; rename some classes to make resource and group View classnames more consistent witheach other
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/ResourceGroup.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/ResourceGroup.java index 9a8ff9d..d9ca343 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/ResourceGroup.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/ResourceGroup.java @@ -74,7 +74,7 @@ import org.rhq.core.domain.tagging.Tag; @NamedQuery(name = ResourceGroup.QUERY_FIND_ALL_FILTERED_COUNT, query = "SELECT count(DISTINCT g) " + "FROM ResourceGroup g JOIN g.roles r JOIN r.subjects s " // + "LEFT JOIN g.resourceType type " // - + "LEFT JOIN g.implicitResources res " // used for inventory>overview "member in groups" section, authz-related + + "LEFT JOIN g.implicitResources res " // used for inventory>summary "member in groups" section, authz-related + "WHERE s = :subject " // + " AND g.visible = true " + " AND ( res.id = :resourceId OR :resourceId is null ) " @@ -89,7 +89,7 @@ import org.rhq.core.domain.tagging.Tag; + " AND (type.category = :category OR :category is null) ) ) "), @NamedQuery(name = ResourceGroup.QUERY_FIND_ALL_FILTERED_COUNT_ADMIN, query = "SELECT count(DISTINCT g) FROM ResourceGroup g " + "LEFT JOIN g.resourceType type " - + "LEFT JOIN g.implicitResources res " // used for inventory>overview "member in groups" section, authz-related + + "LEFT JOIN g.implicitResources res " // used for inventory>summary "member in groups" section, authz-related + "WHERE ( g.groupCategory = :groupCategory OR :groupCategory is null ) " + " AND g.visible = true " + " AND ( res.id = :resourceId OR :resourceId is null ) " diff --git a/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/test/DataSourceExample.java b/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/test/DataSourceExample.java index a9ca740..2f270a4 100644 --- a/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/test/DataSourceExample.java +++ b/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/test/DataSourceExample.java @@ -30,7 +30,7 @@ import org.rhq.core.domain.configuration.PropertySimple;
public class DataSourceExample { /* This class exercises the Configuration domain model from a number of different actors and goals. - * The following overview describes the different use cases of the domain model: + * The following summary describes the different use cases of the domain model: * * 1. Plugin populating a value set to describe the resource's current state 2. Plugin reading a value set to write * the changes to the resource 3. Plugin Container creating a definition 4. Server storing a value set to the diff --git a/modules/enterprise/gui/coregui/pom.xml b/modules/enterprise/gui/coregui/pom.xml index ce9dfca..37e1993 100644 --- a/modules/enterprise/gui/coregui/pom.xml +++ b/modules/enterprise/gui/coregui/pom.xml @@ -27,7 +27,7 @@
<!-- If this is too much memory to allocate to your gwt:debug process then override this property in in your settings.xml --> - <gwt-plugin.extraJvmArgs>-Xms512M -Xmx512M</gwt-plugin.extraJvmArgs> + <gwt-plugin.extraJvmArgs>-Xms512M -Xmx512M -XX:PermSize=128M -XX:MaxPermSize=256M</gwt-plugin.extraJvmArgs> <gwt-plugin.localWorkers>2</gwt-plugin.localWorkers> </properties>
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java index 7cd621b..aa6c084 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java @@ -51,7 +51,7 @@ import org.rhq.enterprise.gui.coregui.client.dashboard.DashboardsView; import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.ResourceGroupTopView; import org.rhq.enterprise.gui.coregui.client.inventory.resource.InventoryView; -import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.ResourceView; +import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.ResourceTopView; import org.rhq.enterprise.gui.coregui.client.menu.MenuBarView; import org.rhq.enterprise.gui.coregui.client.report.ReportTopView; import org.rhq.enterprise.gui.coregui.client.report.tag.TaggedView; @@ -264,7 +264,7 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String> { } else if (breadcrumbName.equals("Inventory")) { canvas = new InventoryView(); } else if (breadcrumbName.equals("Resource")) { - canvas = new ResourceView(); + canvas = new ResourceTopView(); } else if (breadcrumbName.equals("ResourceGroup")) { canvas = new ResourceGroupTopView(); } else if (breadcrumbName.equals("Dashboard")) { diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java index fc93906..0375213 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java @@ -35,7 +35,7 @@ public class LinkManager { if (GWT) { return "#Resource/" + resourceId; } else { - return "/rhq/resource/summary/overview.xhtml?id=" + resourceId; + return "/rhq/resource/summary/summary.xhtml?id=" + resourceId; } }
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/EnhancedDynamicForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/EnhancedDynamicForm.java index 02185e7..0ae01ce 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/EnhancedDynamicForm.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/EnhancedDynamicForm.java @@ -23,16 +23,18 @@ package org.rhq.enterprise.gui.coregui.client.components.form;
import com.google.gwt.core.client.JavaScriptObject; +import com.google.gwt.user.client.Timer; import com.smartgwt.client.widgets.form.DynamicForm; import com.smartgwt.client.widgets.form.FormItemIfFunction; import com.smartgwt.client.widgets.form.fields.FormItem; import com.smartgwt.client.widgets.form.fields.FormItemIcon; import com.smartgwt.client.widgets.form.fields.StaticTextItem; -import com.smartgwt.client.widgets.form.fields.TextItem; import com.smartgwt.client.widgets.form.fields.events.BlurEvent; import com.smartgwt.client.widgets.form.fields.events.BlurHandler; import com.smartgwt.client.widgets.form.fields.events.IconClickEvent; import com.smartgwt.client.widgets.form.fields.events.IconClickHandler; +import com.smartgwt.client.widgets.form.fields.events.ItemHoverEvent; +import com.smartgwt.client.widgets.form.fields.events.ItemHoverHandler; import com.smartgwt.client.widgets.form.fields.events.KeyPressEvent; import com.smartgwt.client.widgets.form.fields.events.KeyPressHandler;
@@ -40,7 +42,12 @@ import java.util.ArrayList; import java.util.List;
/** - * TODO + * A subclass of SmartGWT's DynamicForm widget that provides the following additional feature: + * + * If any {@link TogglableTextItem}s are added to the form, they will initially be rendered as static text items, except + * when the user hovers over one of them, an edit icon will be displayed immediately to the right of it for five seconds. + * If the user clicks this icon, the form item will become editable and the user can update its value. Once the user + * hits Enter or switches focus somewhere outside the form item, the form item will become static again. * * @author Ian Springer */ @@ -80,20 +87,33 @@ public class EnhancedDynamicForm extends DynamicForm { editIcon.setName("Edit"); editIcon.setSrc("[SKIN]/actions/edit.png"); staticTextItem.setIcons(editIcon); - staticTextItem.setShowIcons(true); + staticTextItem.setShowIcons(false);
+ staticTextItem.setShowIfCondition(new FormItemIfFunction() { + public boolean execute(FormItem formItem, Object o, DynamicForm dynamicForm) { + boolean editing = staticTextItem.getAttributeAsBoolean("editing"); + return !editing; + } + }); staticTextItem.addIconClickHandler(new IconClickHandler() { public void onIconClick(IconClickEvent iconClickEvent) { if ("Edit".equals(iconClickEvent.getIcon().getName())) { staticTextItem.setAttribute("editing", true); + staticTextItem.setShowIcons(false); markForRedraw(); } } }); - staticTextItem.setShowIfCondition(new FormItemIfFunction() { - public boolean execute(FormItem formItem, Object o, DynamicForm dynamicForm) { - boolean editing = staticTextItem.getAttributeAsBoolean("editing"); - return !editing; + staticTextItem.addItemHoverHandler(new ItemHoverHandler() { + public void onItemHover(ItemHoverEvent itemHoverEvent) { + staticTextItem.setShowIcons(true); + markForRedraw(); + new Timer() { + public void run() { + staticTextItem.setShowIcons(false); + markForRedraw(); + } + }.schedule(5000); } }); staticTextItem.addClickHandler(new com.smartgwt.client.widgets.form.fields.events.ClickHandler() { @@ -126,7 +146,7 @@ public class EnhancedDynamicForm extends DynamicForm { itemsList.add(togglableTextItem); } else { itemsList.add(item); - } + } }
super.setItems((FormItem[]) itemsList.toArray(new FormItem[itemsList.size()])); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/TogglableTextItem.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/TogglableTextItem.java index 399cb7e..9807b35 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/TogglableTextItem.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/TogglableTextItem.java @@ -29,7 +29,8 @@ import java.util.ArrayList; import java.util.List;
/** - * TODO + * This class should only be used on conjunction with an {@link EnhancedDynamicForm}. See that class's Javadoc for + * all the details. * * @author Ian Springer */ diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java index 8fff6e2..e6b208c 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java @@ -23,6 +23,7 @@ import java.util.Set;
import com.google.gwt.user.client.History; import com.google.gwt.user.client.rpc.AsyncCallback; +import com.smartgwt.client.docs.Members; import com.smartgwt.client.types.Side; import com.smartgwt.client.widgets.layout.VLayout;
@@ -42,7 +43,7 @@ import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTabSelectedE import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTabSelectedHandler; import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTabSet; import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; -import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.inventory.OverviewView; +import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.summary.OverviewView; import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceSearchView; import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
@@ -93,7 +94,7 @@ public class ResourceGroupDetailView extends VLayout implements BookmarkableView monitoringTab.registerSubTabs("Graphs", "Tables", "Schedules", "Call Time");
inventoryTab = new TwoLevelTab("Inventory", "/images/icons/Inventory_grey_16.png"); - inventoryTab.registerSubTabs("Overview", "Members", "Connection Settings"); + inventoryTab.registerSubTabs("Members", "Connection Settings");
operationsTab = new TwoLevelTab("Operations", "/images/icons/Operation_grey_16.png"); operationsTab.registerSubTabs("History", "Scheduled"); @@ -126,11 +127,11 @@ public class ResourceGroupDetailView extends VLayout implements BookmarkableView
this.titleBar.setGroup(groupComposite.getResourceGroup());
- // TODO: Implement the rest of the tabs. - // FullHTMLPane timelinePane = new FullHTMLPane("/rhq/resource/summary/timeline-plain.xhtml?id=" + resource.getId()); - // summaryTab.updateSubTab("Overview", new ResourceOverviewView(resource)); + // summaryTab.updateSubTab("Overview", new DashboardView(resource)); // summaryTab.updateSubTab("Timeline", timelinePane); + summaryTab.updateSubTab("Overview", new OverviewView(this.groupComposite)); + int groupId = this.groupComposite.getResourceGroup().getId();
monitoringTab.updateSubTab("Graphs", new FullHTMLPane("/rhq/group/monitor/graphs-plain.xhtml?groupId=" @@ -142,7 +143,6 @@ public class ResourceGroupDetailView extends VLayout implements BookmarkableView monitoringTab.updateSubTab("Call Time", new FullHTMLPane("/rhq/group/monitor/response-plain.xhtml?groupId=" + groupId));
- inventoryTab.updateSubTab("Overview", new OverviewView(this.groupComposite)); inventoryTab.updateSubTab("Members", ResourceSearchView.getMembersOf(groupId)); // inventoryTab.updateSubTab("Connection Settings", new GroupPluginConfigurationEditView(this.group.getId(), this.group.getResourceType().getId(), ConfigurationEditor.ConfigType.plugin));
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/OverviewView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/OverviewView.java deleted file mode 100644 index 01faa2d..0000000 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/OverviewView.java +++ /dev/null @@ -1,241 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 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 as published by - * the Free Software Foundation version 2 of the License. - * - * 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 for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.inventory; - -import com.google.gwt.user.client.rpc.AsyncCallback; -import com.smartgwt.client.types.Alignment; -import com.smartgwt.client.widgets.HTMLFlow; -import com.smartgwt.client.widgets.form.fields.FormItem; -import com.smartgwt.client.widgets.form.fields.StaticTextItem; -import com.smartgwt.client.widgets.layout.HLayout; -import com.smartgwt.client.widgets.layout.VLayout; -import org.rhq.core.domain.resource.ResourceType; -import org.rhq.core.domain.resource.group.GroupDefinition; -import org.rhq.core.domain.resource.group.ResourceGroup; -import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite; -import org.rhq.enterprise.gui.coregui.client.CoreGUI; -import org.rhq.enterprise.gui.coregui.client.components.form.EnhancedDynamicForm; -import org.rhq.enterprise.gui.coregui.client.components.form.TogglableTextItem; -import org.rhq.enterprise.gui.coregui.client.components.form.ValueUpdatedHandler; -import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; -import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGroupGWTServiceAsync; -import org.rhq.enterprise.gui.coregui.client.util.message.Message; - -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -/** - * The group Inventory>Overview subtab. - * - * @author Ian Springer - */ -public class OverviewView extends VLayout { - private ResourceGroupGWTServiceAsync resourceGroupService = GWTServiceLookup.getResourceGroupService(); - private ResourceGroupComposite groupComposite; - - public OverviewView(ResourceGroupComposite groupComposite) { - super(); - this.groupComposite = groupComposite; - } - - @Override - protected void onInit() { - super.onInit(); - - final ResourceGroup group = this.groupComposite.getResourceGroup(); - - HLayout spacer = new HLayout(); - spacer.setHeight(15); - addMember(spacer); - - final EnhancedDynamicForm generalPropsForm = new EnhancedDynamicForm(); - - List<FormItem> formItems = new ArrayList<FormItem>(); - - // TODO: Uncomment the below header if we decide to add other stuff to this page besides the general props. - //HeaderItem headerItem = new HeaderItem("header", "General Properties"); - //headerItem.setValue("General Properties"); - //formItems.add(headerItem); - - boolean dynamic = (group.getGroupDefinition() != null); - - final FormItem nameItem = (dynamic) ? new StaticTextItem() : new TogglableTextItem(); - nameItem.setName("name"); - nameItem.setTitle("Name"); - nameItem.setValue(group.getName()); - if (nameItem instanceof TogglableTextItem) { - final TogglableTextItem togglableNameItem = (TogglableTextItem) nameItem; - togglableNameItem.addValueUpdatedHandler(new ValueUpdatedHandler() { - public void onValueUpdated(final String newName) { - final String oldName = group.getName(); - if (newName.equals(oldName)) { - return; - } - group.setName(newName); - OverviewView.this.resourceGroupService.updateResourceGroup(group, new AsyncCallback<Void>() { - public void onFailure(Throwable caught) { - CoreGUI.getErrorHandler().handleError("Failed to change name of Resource group with id " - + group.getId() - + " from "" + oldName + "" to "" + newName + "".", caught); - // We failed to update it on the Server, so change back the ResourceGroup and the form item - // to the original value. - group.setName(oldName); - nameItem.setValue(oldName); - } - - public void onSuccess(Void result) { - CoreGUI.getMessageCenter().notify(new Message("Name of Resource group with id " - + group.getId() + " was changed from "" - + oldName + "" to "" + newName + "".", Message.Severity.Info)); - } - }); - } - }); - } - formItems.add(nameItem); - - StaticTextItem typeItem = new StaticTextItem("memberType", "Member Type"); - ResourceType type = group.getResourceType(); - if (type != null) { - typeItem.setTooltip("Plugin: " + type.getPlugin() + "\n<br>" + "Type: " + type.getName()); - typeItem.setValue(type.getName() + " (" + type.getPlugin() + ")"); - } else { - typeItem.setValue("<i>Mixed</i>"); - } - formItems.add(typeItem); - - StaticTextItem countItem = new StaticTextItem("memberCount", "Member Count"); - long memberCount = this.groupComposite.getImplicitUp() + this.groupComposite.getImplicitDown(); - countItem.setValue(memberCount); - formItems.add(countItem); - - final FormItem descriptionItem = (dynamic) ? new StaticTextItem() : new TogglableTextItem(); - descriptionItem.setName("description"); - descriptionItem.setTitle("Description"); - descriptionItem.setValue(group.getDescription()); - if (descriptionItem instanceof TogglableTextItem) { - final TogglableTextItem togglableDescriptionItem = (TogglableTextItem) descriptionItem; - togglableDescriptionItem.addValueUpdatedHandler(new ValueUpdatedHandler() { - public void onValueUpdated(final String newDescription) { - final String oldDescription = group.getDescription(); - if (newDescription.equals(oldDescription)) { - return; - } - group.setDescription(newDescription); - OverviewView.this.resourceGroupService.updateResourceGroup(group, new AsyncCallback<Void>() { - public void onFailure(Throwable caught) { - CoreGUI.getErrorHandler().handleError("Failed to change description of Resource group with id " - + group.getId() - + " from "" + oldDescription + "" to "" + newDescription + "".", caught); - // We failed to update it on the Server, so change back the ResourceGroup and the form item - // to the original value. - group.setDescription(oldDescription); - descriptionItem.setValue(oldDescription); - } - - public void onSuccess(Void result) { - CoreGUI.getMessageCenter().notify(new Message("Description of Resource group with id " - + group.getId() + " was changed from "" - + oldDescription + "" to "" + newDescription + "".", Message.Severity.Info)); - } - }); - } - }); - } - formItems.add(descriptionItem); - - final FormItem locationItem = (dynamic) ? new StaticTextItem() : new TogglableTextItem(); - locationItem.setName("location"); - locationItem.setTitle("Location"); - locationItem.setValue(group.getLocation()); - if (locationItem instanceof TogglableTextItem) { - final TogglableTextItem togglableLocationItem = (TogglableTextItem) locationItem; - togglableLocationItem.addValueUpdatedHandler(new ValueUpdatedHandler() { - public void onValueUpdated(final String newLocation) { - final String oldLocation = group.getLocation(); - if (newLocation.equals(oldLocation)) { - return; - } - group.setLocation(newLocation); - OverviewView.this.resourceGroupService.updateResourceGroup(group, new AsyncCallback<Void>() { - public void onFailure(Throwable caught) { - CoreGUI.getErrorHandler().handleError("Failed to change location of Resource group with id " - + group.getId() - + " from "" + oldLocation + "" to "" + newLocation + "".", caught); - // We failed to update it on the Server, so change back the ResourceGroup and the form item - // to the original value. - group.setLocation(oldLocation); - locationItem.setValue(oldLocation); - } - - public void onSuccess(Void result) { - CoreGUI.getMessageCenter().notify(new Message("Location of Resource group with id " - + group.getId() + " was changed from "" - + oldLocation + "" to "" + newLocation + "".", Message.Severity.Info)); - } - }); - } - }); - } - formItems.add(locationItem); - - StaticTextItem dynamicItem = new StaticTextItem("dynamic", "Dynamic?"); - dynamicItem.setValue(dynamic ? "yes" : "no"); - formItems.add(dynamicItem); - - StaticTextItem recursiveItem = new StaticTextItem("recursive", "Recursive?"); - recursiveItem.setValue((group.isRecursive()) ? "yes" : "no"); - formItems.add(recursiveItem); - - StaticTextItem createdItem = new StaticTextItem("created", "Created"); - createdItem.setValue(new Date(group.getCtime())); - formItems.add(createdItem); - - StaticTextItem lastModifiedItem = new StaticTextItem("lastModified", "Last Modified"); - lastModifiedItem.setValue(new Date(group.getMtime())); - formItems.add(lastModifiedItem); - - StaticTextItem lastModifiedByItem = new StaticTextItem("lastModifiedBy", "Last Modified By"); - lastModifiedByItem.setValue(group.getModifiedBy()); - formItems.add(lastModifiedByItem); - - if (dynamic) { - StaticTextItem groupDefinitionItem = new StaticTextItem("groupDefinition", "Group Definition"); - GroupDefinition groupDefinition = group.getGroupDefinition(); - // TODO (ips): Make this a link to the group def. - groupDefinitionItem.setValue(groupDefinition.getName()); - formItems.add(groupDefinitionItem); - } - - generalPropsForm.setItems(formItems.toArray(new FormItem[formItems.size()])); - addMember(generalPropsForm); - - if (dynamic) { - spacer = new HLayout(); - spacer.setHeight(10); - addMember(spacer); - - HTMLFlow note = new HTMLFlow(); - note.setContents("<b>*</b> Dynamic group names and descriptions are managed, and therefore are not editable."); - note.setAlign(Alignment.CENTER); - addMember(note); - } - } -} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/OverviewView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/OverviewView.java new file mode 100644 index 0000000..41de300 --- /dev/null +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/OverviewView.java @@ -0,0 +1,241 @@ +/* + * RHQ Management Platform + * Copyright (C) 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 as published by + * the Free Software Foundation version 2 of the License. + * + * 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.summary; + +import com.google.gwt.user.client.rpc.AsyncCallback; +import com.smartgwt.client.types.Alignment; +import com.smartgwt.client.widgets.HTMLFlow; +import com.smartgwt.client.widgets.form.fields.FormItem; +import com.smartgwt.client.widgets.form.fields.StaticTextItem; +import com.smartgwt.client.widgets.layout.HLayout; +import com.smartgwt.client.widgets.layout.VLayout; +import org.rhq.core.domain.resource.ResourceType; +import org.rhq.core.domain.resource.group.GroupDefinition; +import org.rhq.core.domain.resource.group.ResourceGroup; +import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite; +import org.rhq.enterprise.gui.coregui.client.CoreGUI; +import org.rhq.enterprise.gui.coregui.client.components.form.EnhancedDynamicForm; +import org.rhq.enterprise.gui.coregui.client.components.form.TogglableTextItem; +import org.rhq.enterprise.gui.coregui.client.components.form.ValueUpdatedHandler; +import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; +import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGroupGWTServiceAsync; +import org.rhq.enterprise.gui.coregui.client.util.message.Message; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +/** + * The group Inventory>Overview subtab. + * + * @author Ian Springer + */ +public class OverviewView extends VLayout { + private ResourceGroupGWTServiceAsync resourceGroupService = GWTServiceLookup.getResourceGroupService(); + private ResourceGroupComposite groupComposite; + + public OverviewView(ResourceGroupComposite groupComposite) { + super(); + this.groupComposite = groupComposite; + } + + @Override + protected void onInit() { + super.onInit(); + + final ResourceGroup group = this.groupComposite.getResourceGroup(); + + HLayout spacer = new HLayout(); + spacer.setHeight(15); + addMember(spacer); + + final EnhancedDynamicForm generalPropsForm = new EnhancedDynamicForm(); + + List<FormItem> formItems = new ArrayList<FormItem>(); + + // TODO: Uncomment the below header if we decide to add other stuff to this page besides the general props. + //HeaderItem headerItem = new HeaderItem("header", "General Properties"); + //headerItem.setValue("General Properties"); + //formItems.add(headerItem); + + boolean dynamic = (group.getGroupDefinition() != null); + + final FormItem nameItem = (dynamic) ? new StaticTextItem() : new TogglableTextItem(); + nameItem.setName("name"); + nameItem.setTitle("Name"); + nameItem.setValue(group.getName()); + if (nameItem instanceof TogglableTextItem) { + final TogglableTextItem togglableNameItem = (TogglableTextItem) nameItem; + togglableNameItem.addValueUpdatedHandler(new ValueUpdatedHandler() { + public void onValueUpdated(final String newName) { + final String oldName = group.getName(); + if (newName.equals(oldName)) { + return; + } + group.setName(newName); + OverviewView.this.resourceGroupService.updateResourceGroup(group, new AsyncCallback<Void>() { + public void onFailure(Throwable caught) { + CoreGUI.getErrorHandler().handleError("Failed to change name of Resource group with id " + + group.getId() + + " from "" + oldName + "" to "" + newName + "".", caught); + // We failed to update it on the Server, so change back the ResourceGroup and the form item + // to the original value. + group.setName(oldName); + nameItem.setValue(oldName); + } + + public void onSuccess(Void result) { + CoreGUI.getMessageCenter().notify(new Message("Name of Resource group with id " + + group.getId() + " was changed from "" + + oldName + "" to "" + newName + "".", Message.Severity.Info)); + } + }); + } + }); + } + formItems.add(nameItem); + + StaticTextItem typeItem = new StaticTextItem("memberType", "Member Type"); + ResourceType type = group.getResourceType(); + if (type != null) { + typeItem.setTooltip("Plugin: " + type.getPlugin() + "\n<br>" + "Type: " + type.getName()); + typeItem.setValue(type.getName() + " (" + type.getPlugin() + ")"); + } else { + typeItem.setValue("<i>Mixed</i>"); + } + formItems.add(typeItem); + + StaticTextItem countItem = new StaticTextItem("memberCount", "Member Count"); + long memberCount = this.groupComposite.getImplicitUp() + this.groupComposite.getImplicitDown(); + countItem.setValue(memberCount); + formItems.add(countItem); + + final FormItem descriptionItem = (dynamic) ? new StaticTextItem() : new TogglableTextItem(); + descriptionItem.setName("description"); + descriptionItem.setTitle("Description"); + descriptionItem.setValue(group.getDescription()); + if (descriptionItem instanceof TogglableTextItem) { + final TogglableTextItem togglableDescriptionItem = (TogglableTextItem) descriptionItem; + togglableDescriptionItem.addValueUpdatedHandler(new ValueUpdatedHandler() { + public void onValueUpdated(final String newDescription) { + final String oldDescription = group.getDescription(); + if (newDescription.equals(oldDescription)) { + return; + } + group.setDescription(newDescription); + OverviewView.this.resourceGroupService.updateResourceGroup(group, new AsyncCallback<Void>() { + public void onFailure(Throwable caught) { + CoreGUI.getErrorHandler().handleError("Failed to change description of Resource group with id " + + group.getId() + + " from "" + oldDescription + "" to "" + newDescription + "".", caught); + // We failed to update it on the Server, so change back the ResourceGroup and the form item + // to the original value. + group.setDescription(oldDescription); + descriptionItem.setValue(oldDescription); + } + + public void onSuccess(Void result) { + CoreGUI.getMessageCenter().notify(new Message("Description of Resource group with id " + + group.getId() + " was changed from "" + + oldDescription + "" to "" + newDescription + "".", Message.Severity.Info)); + } + }); + } + }); + } + formItems.add(descriptionItem); + + final FormItem locationItem = (dynamic) ? new StaticTextItem() : new TogglableTextItem(); + locationItem.setName("location"); + locationItem.setTitle("Location"); + locationItem.setValue(group.getLocation()); + if (locationItem instanceof TogglableTextItem) { + final TogglableTextItem togglableLocationItem = (TogglableTextItem) locationItem; + togglableLocationItem.addValueUpdatedHandler(new ValueUpdatedHandler() { + public void onValueUpdated(final String newLocation) { + final String oldLocation = group.getLocation(); + if (newLocation.equals(oldLocation)) { + return; + } + group.setLocation(newLocation); + OverviewView.this.resourceGroupService.updateResourceGroup(group, new AsyncCallback<Void>() { + public void onFailure(Throwable caught) { + CoreGUI.getErrorHandler().handleError("Failed to change location of Resource group with id " + + group.getId() + + " from "" + oldLocation + "" to "" + newLocation + "".", caught); + // We failed to update it on the Server, so change back the ResourceGroup and the form item + // to the original value. + group.setLocation(oldLocation); + locationItem.setValue(oldLocation); + } + + public void onSuccess(Void result) { + CoreGUI.getMessageCenter().notify(new Message("Location of Resource group with id " + + group.getId() + " was changed from "" + + oldLocation + "" to "" + newLocation + "".", Message.Severity.Info)); + } + }); + } + }); + } + formItems.add(locationItem); + + StaticTextItem dynamicItem = new StaticTextItem("dynamic", "Dynamic?"); + dynamicItem.setValue(dynamic ? "yes" : "no"); + formItems.add(dynamicItem); + + StaticTextItem recursiveItem = new StaticTextItem("recursive", "Recursive?"); + recursiveItem.setValue((group.isRecursive()) ? "yes" : "no"); + formItems.add(recursiveItem); + + StaticTextItem createdItem = new StaticTextItem("created", "Created"); + createdItem.setValue(new Date(group.getCtime())); + formItems.add(createdItem); + + StaticTextItem lastModifiedItem = new StaticTextItem("lastModified", "Last Modified"); + lastModifiedItem.setValue(new Date(group.getMtime())); + formItems.add(lastModifiedItem); + + StaticTextItem lastModifiedByItem = new StaticTextItem("lastModifiedBy", "Last Modified By"); + lastModifiedByItem.setValue(group.getModifiedBy()); + formItems.add(lastModifiedByItem); + + if (dynamic) { + StaticTextItem groupDefinitionItem = new StaticTextItem("groupDefinition", "Group Definition"); + GroupDefinition groupDefinition = group.getGroupDefinition(); + // TODO (ips): Make this a link to the group def. + groupDefinitionItem.setValue(groupDefinition.getName()); + formItems.add(groupDefinitionItem); + } + + generalPropsForm.setItems(formItems.toArray(new FormItem[formItems.size()])); + addMember(generalPropsForm); + + if (dynamic) { + spacer = new HLayout(); + spacer.setHeight(10); + addMember(spacer); + + HTMLFlow note = new HTMLFlow(); + note.setContents("<b>*</b> Dynamic group names and descriptions are managed, and therefore are not editable."); + note.setAlign(Alignment.CENTER); + addMember(note); + } + } +} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java index 2a7183e..24c2e00 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java @@ -41,7 +41,8 @@ import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.configura import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.configuration.ResourceConfigurationEditView; import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.inventory.PluginConfigurationEditView; import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.GraphListView; -import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.overview.ResourceOverviewView; +import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.summary.DashboardView; +import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.summary.OverviewView;
import java.util.Set;
@@ -88,7 +89,7 @@ public class ResourceDetailView extends VLayout implements BookmarkableView, Res topTabSet.setEdgeSize(0);
summaryTab = new TwoLevelTab("Summary", "/images/icons/Service_up_16.png"); - summaryTab.registerSubTabs("Overview", "Timeline"); + summaryTab.registerSubTabs("Overview", "Dashboard", "Timeline");
monitoringTab = new TwoLevelTab("Monitoring", "/images/icons/Monitor_grey_16.png"); monitoringTab.registerSubTabs("Graphs", "Tables", "Traits", "Availability", "Schedules", "Call Time"); @@ -131,7 +132,8 @@ public class ResourceDetailView extends VLayout implements BookmarkableView, Res final Resource resource = this.resourceComposite.getResource(); this.titleBar.setResource(resource);
- summaryTab.updateSubTab("Overview", new ResourceOverviewView(this.resourceComposite)); + summaryTab.updateSubTab("Overview", new OverviewView(this.resourceComposite)); + summaryTab.updateSubTab("Dashboard", new DashboardView(this.resourceComposite)); summaryTab.updateSubTab("Timeline", new FullHTMLPane("/rhq/resource/summary/timeline-plain.xhtml?id=" + resource.getId()));
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTopView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTopView.java new file mode 100644 index 0000000..efed5ff --- /dev/null +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTopView.java @@ -0,0 +1,160 @@ +/* + * 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 as published by + * the Free Software Foundation version 2 of the License. + * + * 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail; + +import com.google.gwt.user.client.rpc.AsyncCallback; +import com.smartgwt.client.widgets.Canvas; +import com.smartgwt.client.widgets.layout.HLayout; + +import org.rhq.core.domain.criteria.ResourceCriteria; +import org.rhq.core.domain.resource.Resource; +import org.rhq.core.domain.resource.ResourceType; +import org.rhq.core.domain.resource.composite.ResourceComposite; +import org.rhq.core.domain.util.PageList; +import org.rhq.enterprise.gui.coregui.client.BookmarkableView; +import org.rhq.enterprise.gui.coregui.client.CoreGUI; +import org.rhq.enterprise.gui.coregui.client.ViewId; +import org.rhq.enterprise.gui.coregui.client.ViewPath; +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.inventory.resource.InventoryView; +import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository; +import org.rhq.enterprise.gui.coregui.client.util.message.Message; + +import java.util.EnumSet; + +/** + * @author Greg Hinkle + */ +public class ResourceTopView extends HLayout implements BookmarkableView { + + private Canvas contentCanvas; + + private ResourceComposite currentResource; + //private Resource resourcePlatform; + + private ResourceTreeView treeView; + private ResourceDetailView detailView = new ResourceDetailView(); + + private ResourceGWTServiceAsync resourceService = GWTServiceLookup.getResourceService(); + + + public ResourceTopView() { + + } + + @Override + protected void onInit() { + super.onInit(); + + setWidth100(); + setHeight100(); + + treeView = new ResourceTreeView(); + addMember(treeView); + + contentCanvas = new Canvas(); + addMember(contentCanvas); + + // created above +// detailView = new ResourceDetailView(); + + treeView.addResourceSelectListener(detailView); + + setContent(detailView); + } + + + public void setSelectedResource(final int resourceId, final ViewPath view) { + ResourceCriteria criteria = new ResourceCriteria(); + criteria.addFilterId(resourceId); + criteria.fetchTags(true); + //criteria.fetchParentResource(true); + resourceService.findResourceCompositesByCriteria(criteria, new AsyncCallback<PageList<ResourceComposite>>() { + public void onFailure(Throwable caught) { + CoreGUI.getMessageCenter().notify(new Message("Resource with id [" + resourceId + + "] does not exist or is not accessible.", Message.Severity.Warning)); + + CoreGUI.goTo(InventoryView.VIEW_PATH); + } + + public void onSuccess(PageList<ResourceComposite> result) { + if (result.isEmpty()) { + //noinspection ThrowableInstanceNeverThrown + onFailure(new Exception("Resource with id [" + resourceId + "] does not exist.")); + } else { + final ResourceComposite resourceComposite = result.get(0); + loadResourceType(resourceComposite, view); + } + } + }); + } + + + private void loadResourceType(final ResourceComposite resourceComposite, final ViewPath view) { + final Resource resource = resourceComposite.getResource(); + ResourceTypeRepository.Cache.getInstance().getResourceTypes( + resource.getResourceType().getId(), + EnumSet.of(ResourceTypeRepository.MetadataType.content, ResourceTypeRepository.MetadataType.operations, + ResourceTypeRepository.MetadataType.events, + ResourceTypeRepository.MetadataType.resourceConfigurationDefinition), + new ResourceTypeRepository.TypeLoadedCallback() { + public void onTypesLoaded(ResourceType type) { + resource.setResourceType(type); + completeSetSelectedResource(resourceComposite, view); + } + }); + } + + + private void completeSetSelectedResource(ResourceComposite resourceComposite, ViewPath viewPath) { + this.currentResource = resourceComposite; + this.treeView.setSelectedResource(resourceComposite.getResource(), viewPath.getCurrent()); + this.detailView.onResourceSelected(resourceComposite); + } + + + public void setContent(Canvas newContent) { + if (contentCanvas.getChildren().length > 0) + contentCanvas.getChildren()[0].destroy(); + contentCanvas.addChild(newContent); + contentCanvas.markForRedraw(); + } + + + public void renderView(ViewPath viewPath) { + if (viewPath.isEnd()) { + // default detail view + viewPath.getViewPath().add(new ViewId("Summary")); + viewPath.getViewPath().add(new ViewId("Overview")); + } + + Integer resourceId = Integer.parseInt(viewPath.getCurrent().getPath()); + + if (currentResource == null || currentResource.getResource().getId() != resourceId) { + // The previous history item did not already point to this Resource. + setSelectedResource(resourceId, viewPath); + } + + viewPath.next(); + this.treeView.renderView(viewPath); + this.detailView.renderView(viewPath); + } + +} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceView.java deleted file mode 100644 index 39e748f..0000000 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceView.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * 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 as published by - * the Free Software Foundation version 2 of the License. - * - * 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 for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail; - -import com.google.gwt.user.client.rpc.AsyncCallback; -import com.smartgwt.client.widgets.Canvas; -import com.smartgwt.client.widgets.layout.HLayout; - -import org.rhq.core.domain.criteria.ResourceCriteria; -import org.rhq.core.domain.resource.Resource; -import org.rhq.core.domain.resource.ResourceType; -import org.rhq.core.domain.resource.composite.ResourceComposite; -import org.rhq.core.domain.util.PageList; -import org.rhq.enterprise.gui.coregui.client.BookmarkableView; -import org.rhq.enterprise.gui.coregui.client.CoreGUI; -import org.rhq.enterprise.gui.coregui.client.ViewId; -import org.rhq.enterprise.gui.coregui.client.ViewPath; -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.inventory.resource.InventoryView; -import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository; -import org.rhq.enterprise.gui.coregui.client.util.message.Message; - -import java.util.EnumSet; - -/** - * @author Greg Hinkle - */ -public class ResourceView extends HLayout implements BookmarkableView { - - private Canvas contentCanvas; - - private ResourceComposite currentResource; - //private Resource resourcePlatform; - - private ResourceTreeView treeView; - private ResourceDetailView detailView = new ResourceDetailView(); - - private ResourceGWTServiceAsync resourceService = GWTServiceLookup.getResourceService(); - - - public ResourceView() { - - } - - @Override - protected void onInit() { - super.onInit(); - - setWidth100(); - setHeight100(); - - treeView = new ResourceTreeView(); - addMember(treeView); - - contentCanvas = new Canvas(); - addMember(contentCanvas); - - // created above -// detailView = new ResourceDetailView(); - - treeView.addResourceSelectListener(detailView); - - setContent(detailView); - } - - - public void setSelectedResource(final int resourceId, final ViewPath view) { - ResourceCriteria criteria = new ResourceCriteria(); - criteria.addFilterId(resourceId); - criteria.fetchTags(true); - //criteria.fetchParentResource(true); - resourceService.findResourceCompositesByCriteria(criteria, new AsyncCallback<PageList<ResourceComposite>>() { - public void onFailure(Throwable caught) { - CoreGUI.getMessageCenter().notify(new Message("Resource with id [" + resourceId + - "] does not exist or is not accessible.", Message.Severity.Warning)); - - CoreGUI.goTo(InventoryView.VIEW_PATH); - } - - public void onSuccess(PageList<ResourceComposite> result) { - if (result.isEmpty()) { - //noinspection ThrowableInstanceNeverThrown - onFailure(new Exception("Resource with id [" + resourceId + "] does not exist.")); - } else { - final ResourceComposite resourceComposite = result.get(0); - loadResourceType(resourceComposite, view); - } - } - }); - } - - - private void loadResourceType(final ResourceComposite resourceComposite, final ViewPath view) { - final Resource resource = resourceComposite.getResource(); - ResourceTypeRepository.Cache.getInstance().getResourceTypes( - resource.getResourceType().getId(), - EnumSet.of(ResourceTypeRepository.MetadataType.content, ResourceTypeRepository.MetadataType.operations, - ResourceTypeRepository.MetadataType.events, - ResourceTypeRepository.MetadataType.resourceConfigurationDefinition), - new ResourceTypeRepository.TypeLoadedCallback() { - public void onTypesLoaded(ResourceType type) { - resource.setResourceType(type); - completeSetSelectedResource(resourceComposite, view); - } - }); - } - - - private void completeSetSelectedResource(ResourceComposite resourceComposite, ViewPath viewPath) { - this.currentResource = resourceComposite; - this.treeView.setSelectedResource(resourceComposite.getResource(), viewPath.getCurrent()); - this.detailView.onResourceSelected(resourceComposite); - } - - - public void setContent(Canvas newContent) { - if (contentCanvas.getChildren().length > 0) - contentCanvas.getChildren()[0].destroy(); - contentCanvas.addChild(newContent); - contentCanvas.markForRedraw(); - } - - - public void renderView(ViewPath viewPath) { - if (viewPath.isEnd()) { - // default detail view - viewPath.getViewPath().add(new ViewId("Summary")); - viewPath.getViewPath().add(new ViewId("Overview")); - } - - Integer resourceId = Integer.parseInt(viewPath.getCurrent().getPath()); - - if (currentResource == null || currentResource.getResource().getId() != resourceId) { - // The previous history item did not already point to this Resource. - setSelectedResource(resourceId, viewPath); - } - - viewPath.next(); - this.treeView.renderView(viewPath); - this.detailView.renderView(viewPath); - } - -} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/overview/ResourceOverviewView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/overview/ResourceOverviewView.java deleted file mode 100644 index 92cd3ff..0000000 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/overview/ResourceOverviewView.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * 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 as published by - * the Free Software Foundation version 2 of the License. - * - * 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 for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.overview; - -import com.smartgwt.client.widgets.layout.VLayout; - -import org.rhq.core.domain.resource.composite.ResourceComposite; -import org.rhq.enterprise.gui.coregui.client.components.FullHTMLPane; -import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceSelectListener; - -/** - * @author Greg Hinkle - */ -public class ResourceOverviewView extends VLayout implements ResourceSelectListener { - private ResourceSummaryView summaryView; - private FullHTMLPane summaryPane; - private ResourceComposite resourceComposite; - - public ResourceOverviewView(ResourceComposite resourceComposite) { - this.resourceComposite = resourceComposite; - } - - @Override - protected void onDraw() { - super.onDraw(); - - this.summaryView = new ResourceSummaryView(); - addMember(this.summaryView); - - this.summaryPane = new FullHTMLPane(); - addMember(this.summaryPane); - - if (this.resourceComposite != null) { - onResourceSelected(this.resourceComposite); - } - } - - @Override - public void onResourceSelected(ResourceComposite resourceComposite) { - this.resourceComposite = resourceComposite; - this.summaryView.onResourceSelected(resourceComposite); - this.summaryPane.setContentsURL("/rhq/resource/summary/overview-plain.xhtml?id=" - + resourceComposite.getResource().getId()); - } -} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/overview/ResourceSummaryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/overview/ResourceSummaryView.java deleted file mode 100644 index 4d98f82..0000000 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/overview/ResourceSummaryView.java +++ /dev/null @@ -1,289 +0,0 @@ -/* - * 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 as published by - * the Free Software Foundation version 2 of the License. - * - * 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 for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.overview; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.EnumSet; -import java.util.List; - -import com.google.gwt.user.client.rpc.AsyncCallback; -import com.smartgwt.client.util.SC; -import com.smartgwt.client.widgets.form.fields.FormItem; -import com.smartgwt.client.widgets.form.fields.HeaderItem; -import com.smartgwt.client.widgets.form.fields.SpacerItem; -import com.smartgwt.client.widgets.form.fields.StaticTextItem; - -import org.rhq.core.domain.measurement.DataType; -import org.rhq.core.domain.measurement.DisplayType; -import org.rhq.core.domain.measurement.MeasurementDataTrait; -import org.rhq.core.domain.measurement.MeasurementDefinition; -import org.rhq.core.domain.resource.Resource; -import org.rhq.core.domain.resource.ResourceType; -import org.rhq.core.domain.resource.composite.ResourceComposite; -import org.rhq.enterprise.gui.coregui.client.CoreGUI; -import org.rhq.enterprise.gui.coregui.client.components.form.EnhancedDynamicForm; -import org.rhq.enterprise.gui.coregui.client.components.form.TogglableTextItem; -import org.rhq.enterprise.gui.coregui.client.components.form.ValueUpdatedHandler; -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.inventory.resource.ResourceSelectListener; -import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository; -import org.rhq.enterprise.gui.coregui.client.util.message.Message; - -/** - * @author Greg Hinkle - * @author Ian Springer - */ -public class ResourceSummaryView extends EnhancedDynamicForm implements ResourceSelectListener { - - private ResourceGWTServiceAsync resourceService = GWTServiceLookup.getResourceService(); - private ResourceComposite resourceComposite; - - @Override - protected void onDraw() { - super.onDraw(); - - setLeft("10%"); - setWidth("80%"); - } - - - public void onResourceSelected(ResourceComposite resourceComposite) { - - this.resourceComposite = resourceComposite; - Resource resource = resourceComposite.getResource(); - - // Load metric defs. - ResourceTypeRepository.Cache.getInstance().getResourceTypes(resource.getResourceType().getId(), - EnumSet.of(ResourceTypeRepository.MetadataType.measurements), - new ResourceTypeRepository.TypeLoadedCallback() { - public void onTypesLoaded(ResourceType type) { - try { - buildForm(type); - loadTraitValues(); - } catch (Exception e) { - SC.say("Form load failure"); - e.printStackTrace(); - } - } - }); - } - - private void loadTraitValues() { - final Resource resource = resourceComposite.getResource(); - GWTServiceLookup.getMeasurementDataService().findCurrentTraitsForResource( - resource.getId(), - DisplayType.SUMMARY, - new AsyncCallback<List<MeasurementDataTrait>>() { - public void onFailure(Throwable caught) { - CoreGUI.getErrorHandler().handleError("Failed to load traits for " + resource + ".", - caught); - } - - public void onSuccess(List<MeasurementDataTrait> result) { - // TODO: Implement this method. - for (MeasurementDataTrait trait : result) { - String formId = trait.getName().replaceAll("\.", "_").replaceAll(" ", "__"); - FormItem item = getItem(formId); - - if (item != null) { - setValue(formId, trait.getValue()); - } - } - markForRedraw(); - } - } - ); - - } - - private void buildForm(ResourceType type) { - List<MeasurementDefinition> traits = new ArrayList<MeasurementDefinition>(); - - for (MeasurementDefinition measurement : type.getMetricDefinitions()) { - if (measurement.getDataType() == DataType.TRAIT && measurement.getDisplayType() == DisplayType.SUMMARY) { - traits.add(measurement); - } - } - - Collections.sort(traits, new Comparator<MeasurementDefinition>() { - public int compare(MeasurementDefinition o1, MeasurementDefinition o2) { - return new Integer(o1.getDisplayOrder()).compareTo(o2.getDisplayOrder()); - } - }); - - List<FormItem> formItems = new ArrayList<FormItem>(); - - HeaderItem headerItem = new HeaderItem("header", "Summary"); - headerItem.setValue("Summary"); - formItems.add(headerItem); - - StaticTextItem typeItem = new StaticTextItem("type", "Type"); - typeItem.setTooltip("Plugin: " + type.getPlugin() + "\n<br>" + "Type: " + type.getName()); - typeItem.setValue(type.getName() + " (" + type.getPlugin() + ")"); - formItems.add(typeItem); - - final Resource resource = this.resourceComposite.getResource(); - boolean modifiable = this.resourceComposite.getResourcePermission().isInventory(); - - final FormItem nameItem = (modifiable) ? new TogglableTextItem() : new StaticTextItem(); - nameItem.setName("name"); - nameItem.setTitle("Name"); - nameItem.setValue(resource.getName()); - if (nameItem instanceof TogglableTextItem) { - TogglableTextItem togglableNameItem = (TogglableTextItem) nameItem; - togglableNameItem.addValueUpdatedHandler(new ValueUpdatedHandler() { - public void onValueUpdated(final String newName) { - final String oldName = resource.getName(); - if (newName.equals(oldName)) { - return; - } - resource.setName(newName); - ResourceSummaryView.this.resourceService.updateResource(resource, new AsyncCallback<Void>() { - public void onFailure(Throwable caught) { - CoreGUI.getErrorHandler().handleError("Failed to change name of Resource with id " - + resource.getId() - + " from "" + oldName + "" to "" + newName + "".", caught); - // We failed to update it on the Server, so change back the Resource and the form item to - // the original value. - resource.setName(oldName); - nameItem.setValue(oldName); - } - - public void onSuccess(Void result) { - CoreGUI.getMessageCenter().notify(new Message("Name of Resource with id " - + resource.getId() + " was changed from "" - + oldName + "" to "" + newName + "".", Message.Severity.Info)); - } - }); - } - }); - } - formItems.add(nameItem); - - final FormItem descriptionItem = (modifiable) ? new TogglableTextItem() : new StaticTextItem(); - descriptionItem.setName("description"); - descriptionItem.setTitle("Description"); - descriptionItem.setValue(resource.getDescription()); - if (descriptionItem instanceof TogglableTextItem) { - TogglableTextItem togglableDescriptionItem = (TogglableTextItem) descriptionItem; - togglableDescriptionItem.addValueUpdatedHandler(new ValueUpdatedHandler() { - public void onValueUpdated(final String newDescription) { - final String oldDescription = resource.getDescription(); - if (newDescription.equals(oldDescription)) { - return; - } - resource.setDescription(newDescription); - ResourceSummaryView.this.resourceService.updateResource(resource, new AsyncCallback<Void>() { - public void onFailure(Throwable caught) { - CoreGUI.getErrorHandler().handleError("Failed to change description of Resource with id " - + resource.getId() - + " from "" + oldDescription + "" to "" + newDescription + "".", caught); - // We failed to update it on the Server, so change back the Resource and the form item to - // the original value. - resource.setDescription(oldDescription); - descriptionItem.setValue(oldDescription); - } - - public void onSuccess(Void result) { - CoreGUI.getMessageCenter().notify(new Message("Description of Resource with id " - + resource.getId() + " was changed from "" - + oldDescription + "" to "" + newDescription + "".", Message.Severity.Info)); - } - }); - } - }); - } - formItems.add(descriptionItem); - - final FormItem locationItem = (modifiable) ? new TogglableTextItem() : new StaticTextItem(); - locationItem.setName("location"); - locationItem.setTitle("Location"); - locationItem.setValue(resource.getLocation()); - if (locationItem instanceof TogglableTextItem) { - TogglableTextItem togglableNameItem = (TogglableTextItem) locationItem; - togglableNameItem.addValueUpdatedHandler(new ValueUpdatedHandler() { - public void onValueUpdated(final String newLocation) { - final String oldLocation = resource.getLocation(); - if (newLocation.equals(oldLocation)) { - return; - } - resource.setLocation(newLocation); - ResourceSummaryView.this.resourceService.updateResource(resource, new AsyncCallback<Void>() { - public void onFailure(Throwable caught) { - CoreGUI.getErrorHandler().handleError("Failed to change location of Resource with id " - + resource.getId() - + " from "" + oldLocation + "" to "" + newLocation + "".", caught); - // We failed to update it on the Server, so change back the Resource and the form item to - // the original value. - resource.setLocation(oldLocation); - locationItem.setValue(oldLocation); - } - - public void onSuccess(Void result) { - CoreGUI.getMessageCenter().notify(new Message("Location of Resource with id " - + resource.getId() + " was changed from "" - + oldLocation + "" to "" + newLocation + "".", Message.Severity.Info)); - } - }); - } - }); - } - formItems.add(locationItem); - - - StaticTextItem versionItem = new StaticTextItem("version", "Version"); - formItems.add(versionItem); - - StaticTextItem parentItem = new StaticTextItem("parent", "Parent"); - formItems.add(parentItem); - - for (MeasurementDefinition trait : traits) { - String id = trait.getDisplayName().replaceAll("\.", "_").replaceAll(" ", "__"); - - StaticTextItem item = new StaticTextItem(id, trait.getDisplayName()); - item.setTooltip(trait.getDescription()); - formItems.add(item); -// item.setValue("?"); - } - -// SectionItem section = new SectionItem("Summary", "Summary"); -// section.setTitle("Summary"); -// section.setDefaultValue("Summary"); -// section.setCanCollapse(true); -// section.setCellStyle("HidablePlainSectionHeader"); -// section.setItemIds(itemIds.toArray(new String[itemIds.size()])); -// formItems.add(0, section); - - formItems.add(new SpacerItem()); - setItems(formItems.toArray(new FormItem[formItems.size()])); - - setValue("type", type.getName() + " (" + type.getPlugin() + ")"); - setValue("name", resource.getName()); - setValue("description", resource.getDescription()); - setValue("location", resource.getLocation()); - setValue("version", (resource.getVersion() != null) ? resource.getVersion() : "<i>none</i>"); - Resource parentResource = resource.getParentResource(); - setValue("parent", parentResource != null ? - ("<a href="#Resource/" + parentResource.getId() + "">" + - parentResource.getName() + "</a>") : "<i>none</i>"); - } -} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/DashboardView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/DashboardView.java new file mode 100644 index 0000000..c29deec --- /dev/null +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/DashboardView.java @@ -0,0 +1,52 @@ +/* + * 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 as published by + * the Free Software Foundation version 2 of the License. + * + * 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.summary; + +import org.rhq.core.domain.resource.composite.ResourceComposite; +import org.rhq.enterprise.gui.coregui.client.components.FullHTMLPane; +import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceSelectListener; + +/** + * The Resource Summary>Dashboard tab. + * + * @author Greg Hinkle + */ +public class DashboardView extends FullHTMLPane implements ResourceSelectListener { + private ResourceComposite resourceComposite; + + public DashboardView(ResourceComposite resourceComposite) { + this.resourceComposite = resourceComposite; + } + + @Override + protected void onDraw() { + super.onDraw(); + + if (this.resourceComposite != null) { + onResourceSelected(this.resourceComposite); + } + } + + @Override + public void onResourceSelected(ResourceComposite resourceComposite) { + this.resourceComposite = resourceComposite; + setContentsURL("/rhq/resource/summary/summary-plain.xhtml?id=" + + resourceComposite.getResource().getId()); + } +} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/OverviewView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/OverviewView.java new file mode 100644 index 0000000..ac2abc2 --- /dev/null +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/OverviewView.java @@ -0,0 +1,302 @@ +/* + * 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 as published by + * the Free Software Foundation version 2 of the License. + * + * 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.summary; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.EnumSet; +import java.util.List; + +import com.google.gwt.user.client.rpc.AsyncCallback; +import com.smartgwt.client.util.SC; +import com.smartgwt.client.widgets.form.fields.FormItem; +import com.smartgwt.client.widgets.form.fields.HeaderItem; +import com.smartgwt.client.widgets.form.fields.SpacerItem; +import com.smartgwt.client.widgets.form.fields.StaticTextItem; + +import org.rhq.core.domain.measurement.DataType; +import org.rhq.core.domain.measurement.DisplayType; +import org.rhq.core.domain.measurement.MeasurementDataTrait; +import org.rhq.core.domain.measurement.MeasurementDefinition; +import org.rhq.core.domain.resource.Resource; +import org.rhq.core.domain.resource.ResourceType; +import org.rhq.core.domain.resource.composite.ResourceComposite; +import org.rhq.enterprise.gui.coregui.client.CoreGUI; +import org.rhq.enterprise.gui.coregui.client.components.form.EnhancedDynamicForm; +import org.rhq.enterprise.gui.coregui.client.components.form.TogglableTextItem; +import org.rhq.enterprise.gui.coregui.client.components.form.ValueUpdatedHandler; +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.inventory.resource.ResourceSelectListener; +import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository; +import org.rhq.enterprise.gui.coregui.client.util.message.Message; + +/** + * The Resource Summary>Overview tab. + * + * @author Greg Hinkle + * @author Ian Springer + */ +public class OverviewView extends EnhancedDynamicForm implements ResourceSelectListener { + + private ResourceGWTServiceAsync resourceService = GWTServiceLookup.getResourceService(); + private ResourceComposite resourceComposite; + + + public OverviewView(ResourceComposite resourceComposite) { + super(); + this.resourceComposite = resourceComposite; + } + + + @Override + protected void onDraw() { + super.onDraw(); + + setLeft("10%"); + setWidth("80%"); + + if (this.resourceComposite != null) { + onResourceSelected(this.resourceComposite); + } + } + + + public void onResourceSelected(ResourceComposite resourceComposite) { + + this.resourceComposite = resourceComposite; + Resource resource = resourceComposite.getResource(); + + // Load metric defs. + ResourceTypeRepository.Cache.getInstance().getResourceTypes(resource.getResourceType().getId(), + EnumSet.of(ResourceTypeRepository.MetadataType.measurements), + new ResourceTypeRepository.TypeLoadedCallback() { + public void onTypesLoaded(ResourceType type) { + try { + buildForm(type); + loadTraitValues(); + } catch (Exception e) { + SC.say("Form load failure"); + e.printStackTrace(); + } + } + }); + } + + private void loadTraitValues() { + final Resource resource = resourceComposite.getResource(); + GWTServiceLookup.getMeasurementDataService().findCurrentTraitsForResource( + resource.getId(), + DisplayType.SUMMARY, + new AsyncCallback<List<MeasurementDataTrait>>() { + public void onFailure(Throwable caught) { + CoreGUI.getErrorHandler().handleError("Failed to load traits for " + resource + ".", + caught); + } + + public void onSuccess(List<MeasurementDataTrait> result) { + // TODO: Implement this method. + for (MeasurementDataTrait trait : result) { + String formId = trait.getName().replaceAll("\.", "_").replaceAll(" ", "__"); + FormItem item = getItem(formId); + + if (item != null) { + setValue(formId, trait.getValue()); + } + } + markForRedraw(); + } + } + ); + + } + + private void buildForm(ResourceType type) { + List<MeasurementDefinition> traits = new ArrayList<MeasurementDefinition>(); + + for (MeasurementDefinition measurement : type.getMetricDefinitions()) { + if (measurement.getDataType() == DataType.TRAIT && measurement.getDisplayType() == DisplayType.SUMMARY) { + traits.add(measurement); + } + } + + Collections.sort(traits, new Comparator<MeasurementDefinition>() { + public int compare(MeasurementDefinition o1, MeasurementDefinition o2) { + return new Integer(o1.getDisplayOrder()).compareTo(o2.getDisplayOrder()); + } + }); + + List<FormItem> formItems = new ArrayList<FormItem>(); + + HeaderItem headerItem = new HeaderItem("header", "Summary"); + headerItem.setValue("Summary"); + formItems.add(headerItem); + + StaticTextItem typeItem = new StaticTextItem("type", "Type"); + typeItem.setTooltip("Plugin: " + type.getPlugin() + "\n<br>" + "Type: " + type.getName()); + typeItem.setValue(type.getName() + " (" + type.getPlugin() + ")"); + formItems.add(typeItem); + + final Resource resource = this.resourceComposite.getResource(); + boolean modifiable = this.resourceComposite.getResourcePermission().isInventory(); + + final FormItem nameItem = (modifiable) ? new TogglableTextItem() : new StaticTextItem(); + nameItem.setName("name"); + nameItem.setTitle("Name"); + nameItem.setValue(resource.getName()); + if (nameItem instanceof TogglableTextItem) { + TogglableTextItem togglableNameItem = (TogglableTextItem) nameItem; + togglableNameItem.addValueUpdatedHandler(new ValueUpdatedHandler() { + public void onValueUpdated(final String newName) { + final String oldName = resource.getName(); + if (newName.equals(oldName)) { + return; + } + resource.setName(newName); + OverviewView.this.resourceService.updateResource(resource, new AsyncCallback<Void>() { + public void onFailure(Throwable caught) { + CoreGUI.getErrorHandler().handleError("Failed to change name of Resource with id " + + resource.getId() + + " from "" + oldName + "" to "" + newName + "".", caught); + // We failed to update it on the Server, so change back the Resource and the form item to + // the original value. + resource.setName(oldName); + nameItem.setValue(oldName); + } + + public void onSuccess(Void result) { + CoreGUI.getMessageCenter().notify(new Message("Name of Resource with id " + + resource.getId() + " was changed from "" + + oldName + "" to "" + newName + "".", Message.Severity.Info)); + } + }); + } + }); + } + formItems.add(nameItem); + + final FormItem descriptionItem = (modifiable) ? new TogglableTextItem() : new StaticTextItem(); + descriptionItem.setName("description"); + descriptionItem.setTitle("Description"); + descriptionItem.setValue(resource.getDescription()); + if (descriptionItem instanceof TogglableTextItem) { + TogglableTextItem togglableDescriptionItem = (TogglableTextItem) descriptionItem; + togglableDescriptionItem.addValueUpdatedHandler(new ValueUpdatedHandler() { + public void onValueUpdated(final String newDescription) { + final String oldDescription = resource.getDescription(); + if (newDescription.equals(oldDescription)) { + return; + } + resource.setDescription(newDescription); + OverviewView.this.resourceService.updateResource(resource, new AsyncCallback<Void>() { + public void onFailure(Throwable caught) { + CoreGUI.getErrorHandler().handleError("Failed to change description of Resource with id " + + resource.getId() + + " from "" + oldDescription + "" to "" + newDescription + "".", caught); + // We failed to update it on the Server, so change back the Resource and the form item to + // the original value. + resource.setDescription(oldDescription); + descriptionItem.setValue(oldDescription); + } + + public void onSuccess(Void result) { + CoreGUI.getMessageCenter().notify(new Message("Description of Resource with id " + + resource.getId() + " was changed from "" + + oldDescription + "" to "" + newDescription + "".", Message.Severity.Info)); + } + }); + } + }); + } + formItems.add(descriptionItem); + + final FormItem locationItem = (modifiable) ? new TogglableTextItem() : new StaticTextItem(); + locationItem.setName("location"); + locationItem.setTitle("Location"); + locationItem.setValue(resource.getLocation()); + if (locationItem instanceof TogglableTextItem) { + TogglableTextItem togglableNameItem = (TogglableTextItem) locationItem; + togglableNameItem.addValueUpdatedHandler(new ValueUpdatedHandler() { + public void onValueUpdated(final String newLocation) { + final String oldLocation = resource.getLocation(); + if (newLocation.equals(oldLocation)) { + return; + } + resource.setLocation(newLocation); + OverviewView.this.resourceService.updateResource(resource, new AsyncCallback<Void>() { + public void onFailure(Throwable caught) { + CoreGUI.getErrorHandler().handleError("Failed to change location of Resource with id " + + resource.getId() + + " from "" + oldLocation + "" to "" + newLocation + "".", caught); + // We failed to update it on the Server, so change back the Resource and the form item to + // the original value. + resource.setLocation(oldLocation); + locationItem.setValue(oldLocation); + } + + public void onSuccess(Void result) { + CoreGUI.getMessageCenter().notify(new Message("Location of Resource with id " + + resource.getId() + " was changed from "" + + oldLocation + "" to "" + newLocation + "".", Message.Severity.Info)); + } + }); + } + }); + } + formItems.add(locationItem); + + + StaticTextItem versionItem = new StaticTextItem("version", "Version"); + formItems.add(versionItem); + + StaticTextItem parentItem = new StaticTextItem("parent", "Parent"); + formItems.add(parentItem); + + for (MeasurementDefinition trait : traits) { + String id = trait.getDisplayName().replaceAll("\.", "_").replaceAll(" ", "__"); + + StaticTextItem item = new StaticTextItem(id, trait.getDisplayName()); + item.setTooltip(trait.getDescription()); + formItems.add(item); +// item.setValue("?"); + } + +// SectionItem section = new SectionItem("Summary", "Summary"); +// section.setTitle("Summary"); +// section.setDefaultValue("Summary"); +// section.setCanCollapse(true); +// section.setCellStyle("HidablePlainSectionHeader"); +// section.setItemIds(itemIds.toArray(new String[itemIds.size()])); +// formItems.add(0, section); + + formItems.add(new SpacerItem()); + setItems(formItems.toArray(new FormItem[formItems.size()])); + + setValue("type", type.getName() + " (" + type.getPlugin() + ")"); + setValue("name", resource.getName()); + setValue("description", resource.getDescription()); + setValue("location", resource.getLocation()); + setValue("version", (resource.getVersion() != null) ? resource.getVersion() : "<i>none</i>"); + Resource parentResource = resource.getParentResource(); + setValue("parent", parentResource != null ? + ("<a href="#Resource/" + parentResource.getId() + "">" + + parentResource.getName() + "</a>") : "<i>none</i>"); + } +} diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/tag/FunctionTagLibrary.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/tag/FunctionTagLibrary.java index 7a5a8d5..e9f24fa 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/tag/FunctionTagLibrary.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/tag/FunctionTagLibrary.java @@ -351,7 +351,7 @@ public class FunctionTagLibrary extends AbstractTagLibrary {
// needs to exist separately from getDefaultContextTabURL because only some facelets understand EntityContext public static String getDefaultResourceTabURL() { - return "/rhq/resource/summary/overview.xhtml"; + return "/rhq/resource/summary/summary.xhtml"; }
public static String getDefaultGroupTabURL() { diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/DisambiguatedResourceLineageRenderer.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/DisambiguatedResourceLineageRenderer.java index 60f5031..56d5465 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/DisambiguatedResourceLineageRenderer.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/DisambiguatedResourceLineageRenderer.java @@ -40,7 +40,7 @@ import org.rhq.core.domain.resource.composite.DisambiguationReport; * @author Lukas Krejci */ public class DisambiguatedResourceLineageRenderer extends Renderer { - private static final String RESOURCE_URL = "/rhq/resource/summary/overview.xhtml"; + private static final String RESOURCE_URL = "/rhq/resource/summary/summary.xhtml";
@Override public void encodeBegin(FacesContext context, UIComponent component) throws IOException { diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/ResourceLineageRenderer.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/ResourceLineageRenderer.java index 94e6614..33310b6 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/ResourceLineageRenderer.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/ResourceLineageRenderer.java @@ -37,7 +37,7 @@ import org.rhq.enterprise.server.util.LookupUtil; * @author Ian Springer */ public class ResourceLineageRenderer extends Renderer { - private static final String BASE_RESOURCE_URL = "/rhq/resource/summary/overview.xhtml"; + private static final String BASE_RESOURCE_URL = "/rhq/resource/summary/summary.xhtml"; private static final String SEPARATOR = " > ";
private ResourceManagerLocal resourceManager = LookupUtil.getResourceManager(); diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/taglib/InventoryHierarchyTag.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/taglib/InventoryHierarchyTag.java index 5e02e32..4f5bfa9 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/taglib/InventoryHierarchyTag.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/taglib/InventoryHierarchyTag.java @@ -46,7 +46,7 @@ import org.rhq.enterprise.server.util.LookupUtil; * @author Ian Springer */ public class InventoryHierarchyTag extends TagSupport { - private static final String BASE_RESOURCE_URL = "/rhq/resource/summary/overview.xhtml"; + private static final String BASE_RESOURCE_URL = "/rhq/resource/summary/summary.xhtml";
//private static final String BASE_GROUP_URL = "/Resource.do?type=GROUP"; private static final String BASE_GROUP_URL = "/rhq/group/inventory/view.xhtml"; diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/taglib/display/DisambiguatedResourceNameTag.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/taglib/display/DisambiguatedResourceNameTag.java index 1077aab..2efedc9 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/taglib/display/DisambiguatedResourceNameTag.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/taglib/display/DisambiguatedResourceNameTag.java @@ -170,6 +170,6 @@ public class DisambiguatedResourceNameTag extends TagSupport { }
public static String getDefaultResourceUrl(int resourceId) { - return "/rhq/resource/summary/overview.xhtml?id=" + resourceId; + return "/rhq/resource/summary/summary.xhtml?id=" + resourceId; } } diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/group/ResourceGroupTreeContextMenuUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/group/ResourceGroupTreeContextMenuUIBean.java index 34fb0a6..4650eef 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/group/ResourceGroupTreeContextMenuUIBean.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/group/ResourceGroupTreeContextMenuUIBean.java @@ -175,7 +175,7 @@ public class ResourceGroupTreeContextMenuUIBean extends TreeContextMenuBase { menuItem.setValue(res.getName()); menuItem.setId("groupMember_" + res.getId());
- String url = "/rhq/resource/summary/overview.xhtml?id=" + res.getId(); + String url = "/rhq/resource/summary/summary.xhtml?id=" + res.getId();
menuItem.setSubmitMode("none"); menuItem.setOnclick("document.location.href='" + url + "'"); diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/PerspectiveTarget.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/PerspectiveTarget.java index 3bf4596..0ea233b 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/PerspectiveTarget.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/PerspectiveTarget.java @@ -33,7 +33,7 @@ public enum PerspectiveTarget { GROUP_MIXED("/rhq/group/inventory/view.xhtml?category=MIXED&groupId="), // METRIC_TEMPLATE("/admin/platform/monitor/Config.do?mode=configure&id=", false, true), // REPO("/rhq/content/repo.xhtml?mode=view&id="), // - RESOURCE("/rhq/resource/summary/overview.xhtml?id="), // + RESOURCE("/rhq/resource/summary/summary.xhtml?id="), // ROLE("/admin/role/RoleAdmin.do?mode=view&r="), // SERVER("/rhq/ha/viewServer.xhtml?mode=view&serverId="), // USER("/admin/user/UserAdmin.do?mode=view&u="); diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java index e5f2802..25ffa7b 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java @@ -835,6 +835,10 @@ public class WebservicesManagerBean implements WebservicesRemote { return resourceManager.uninventoryResources(subject, resourceIds); }
+ public Resource updateResource(Subject subject, Resource resource) { + return resourceManager.updateResource(subject, resource); + } + //RESOURCEMANAGER: END ----------------------------------
//RESOURCEGROUPMANAGER: BEGIN ---------------------------------- diff --git a/modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronComponent.java b/modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronComponent.java index ae22c2f..a7cdba4 100644 --- a/modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronComponent.java +++ b/modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronComponent.java @@ -45,7 +45,7 @@ import org.rhq.augeas.util.GlobFilter; import org.rhq.plugins.platform.PlatformComponent;
/** - * Provides an overview of all entries in the crontabs split into hourly/daily/weekly/monthly entries. + * Provides an summary of all entries in the crontabs split into hourly/daily/weekly/monthly entries. * Is able to create new cron tabs. * * @author Lukas Krejci diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/serviceBinding/SetComponent.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/serviceBinding/SetComponent.java index 5e02571..024d60d 100644 --- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/serviceBinding/SetComponent.java +++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/serviceBinding/SetComponent.java @@ -192,7 +192,7 @@ public class SetComponent implements ResourceComponent<ManagerComponent>, Config
Configuration bindings = result.getComplexResults();
- //populate the resulting binding map so that the users have overview what the + //populate the resulting binding map so that the users have summary what the //the bindings would look like if this binding set was active. PropertyList resultingBindings = new PropertyList(RESULTING_BINDINGS_PROPERTY); bindings.put(resultingBindings);
rhq-commits@lists.fedorahosted.org