modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ViewId.java
| 7
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/AbstractTwoLevelTabSetView.java
| 198 +++++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
| 199 ++--------
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
| 195 ++-------
4 files changed, 294 insertions(+), 305 deletions(-)
New commits:
commit 4b78144546207ab92eddf048699a3a46fbb1434b
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Sat Sep 11 16:29:57 2010 -0400
extract superclass for resource and group detail view classes
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ViewId.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ViewId.java
index 1302774..cba747e 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ViewId.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ViewId.java
@@ -35,7 +35,7 @@ public class ViewId {
public ViewId(String path, Breadcrumb... breadcrumbs) {
this.path = path;
if ( breadcrumbs != null) {
- this.breadcrumbs = Arrays.asList(breadcrumbs);
+ this.breadcrumbs = Arrays.asList(breadcrumbs);
} else {
this.breadcrumbs = new ArrayList<Breadcrumb>();
}
@@ -57,6 +57,11 @@ public class ViewId {
}
@Override
+ public String toString() {
+ return this.path;
+ }
+
+ @Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/AbstractTwoLevelTabSetView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/AbstractTwoLevelTabSetView.java
new file mode 100644
index 0000000..bdd1981
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/AbstractTwoLevelTabSetView.java
@@ -0,0 +1,198 @@
+/*
+ * 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.common.detail;
+
+import com.google.gwt.user.client.History;
+import com.smartgwt.client.types.Side;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.layout.Layout;
+import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.ViewPath;
+import org.rhq.enterprise.gui.coregui.client.components.tab.SubTab;
+import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTab;
+import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTabSelectedEvent;
+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.util.selenium.LocatableVLayout;
+
+import java.util.List;
+
+/**
+ * @author Greg Hinkle
+ * @author Ian Springer
+ */
+public abstract class AbstractTwoLevelTabSetView<T, U extends Layout> extends
LocatableVLayout
+ implements BookmarkableView, TwoLevelTabSelectedHandler {
+ private String baseViewPath;
+ private TwoLevelTabSet tabSet;
+ private String tabName;
+ private String subTabName;
+ private U titleBar;
+
+ public AbstractTwoLevelTabSetView(String locatorId, String baseViewPath) {
+ super(locatorId);
+ this.baseViewPath = baseViewPath;
+
+ setWidth100();
+ setHeight100();
+
+ this.titleBar = createTitleBar();
+ addMember(this.titleBar);
+
+ this.tabSet = new TwoLevelTabSet(extendLocatorId("TabSet"));
+ this.tabSet.setTabBarPosition(Side.TOP);
+ this.tabSet.setWidth100();
+ this.tabSet.setHeight100();
+ this.tabSet.setEdgeMarginSize(0);
+ this.tabSet.setEdgeSize(0);
+
+ List<TwoLevelTab> tabsList = createTabs();
+ this.tabSet.setTabs(tabsList.toArray(new TwoLevelTab[tabsList.size()]));
+
+ this.tabSet.addTwoLevelTabSelectedHandler(this);
+
+ addMember(this.tabSet);
+ }
+
+ // ------------------ Abstract Methods --------------------
+ public abstract Integer getSelectedItemId();
+
+ protected abstract U createTitleBar();
+
+ protected abstract List<TwoLevelTab> createTabs();
+
+ protected abstract void loadSelectedItem(int itemId, ViewPath viewPath);
+
+ protected abstract void updateTabContent(T selectedItem);
+ // ---------------------------------------------------------
+
+ protected U getTitleBar() {
+ return this.titleBar;
+ }
+
+ public void onTabSelected(TwoLevelTabSelectedEvent tabSelectedEvent) {
+ //CoreGUI.printWidgetTree();
+
+ if (getSelectedItemId() == null) {
+ // History.fireCurrentHistoryState();
+ } else {
+ // Switch tabs directly, rather than letting the history framework do it, to
avoid redrawing the outer views.
+ // selectSubTabByTitle(tabSelectedEvent.getId(),
tabSelectedEvent.getSubTabId());
+ String tabPath = "/" + tabSelectedEvent.getId() + "/" +
tabSelectedEvent.getSubTabId();
+ String path = this.baseViewPath + "/" + getSelectedItemId() +
tabPath;
+
+ // If the tab that was selected is not already the current history item, the
user clicked on the tab, rather
+ // than going directly to the tab's URL. In this case, fire a history
event to go to the tab and make it the
+ // current history item.
+ if (!History.getToken().equals(path)) {
+ History.newItem(path, true);
+ }
+ }
+ }
+
+ public void renderView(ViewPath viewPath) {
+ // e.g. #Resource/10010/Summary/Overview
+ // ^ current path
+ int id = Integer.parseInt(viewPath.getCurrent().getPath());
+ viewPath.next();
+
+ if (!viewPath.isEnd()) {
+ // e.g. #Resource/10010/Summary/Overview
+ // ^ current path
+ this.tabName = viewPath.getCurrent().getPath();
+ viewPath.next();
+ if (!viewPath.isEnd()) {
+ // e.g. #Resource/10010/Summary/Overview
+ // ^ current path
+ this.subTabName = viewPath.getCurrent().getPath();
+ viewPath.next();
+ } else {
+ this.subTabName = null;
+ }
+ } else {
+ this.tabName = null;
+ }
+
+ if (getSelectedItemId() == null || getSelectedItemId() != id) {
+ // A different Resource or first load - go get data.
+ loadSelectedItem(id, viewPath);
+ } else {
+ // Same Resource - just switch tabs.
+ selectTab(this.tabName, this.subTabName, viewPath);
+ }
+ }
+
+ /**
+ * Select the tab/subtab with the specified titles (e.g. "Monitoring",
"Graphs").
+ *
+ * @param tabTitle the title of the tab to select - if null, the default tab (the
leftmost non-disabled one) will be selected
+ * @param subtabTitle the title of the subtab to select - if null, the default subtab
(the leftmost non-disabled one) will be selected
+ * @param viewPath the view path, which may have additional view items to be
rendered
+ */
+ public void selectTab(String tabTitle, String subtabTitle, ViewPath viewPath) {
+ try {
+ TwoLevelTab tab = (tabTitle != null) ? this.tabSet.getTabByTitle(tabTitle) :
+ this.tabSet.getDefaultTab();
+ if (tab == null || tab.getDisabled()) {
+ CoreGUI.getErrorHandler().handleError("Invalid tab name: " +
tabTitle);
+ // TODO: Should we fire a history event here to redirect to a valid
bookmark?
+ tab = this.tabSet.getDefaultTab();
+ if (tab == null) {
+ throw new IllegalStateException("No default tab is
defined.");
+ }
+ subtabTitle = null;
+ }
+ // Do *not* select the tab and trigger the tab selected event until the
subtab has been selected first.
+
+ SubTab subtab = (subtabTitle != null) ? tab.getSubTabByTitle(subtabTitle) :
tab.getDefaultSubTab();
+ if (subtab == null || tab.getLayout().isDisabled()) {
+ CoreGUI.getErrorHandler().handleError("Invalid subtab name: " +
subtabTitle);
+ // TODO: Should we fire a history event here to redirect to a valid
bookmark?
+ subtab = tab.getLayout().getDefaultSubTab();
+ }
+ tab.getLayout().selectSubTab(subtab);
+
+ // Now that the subtab has been selected, select the tab (this will cause a
tab selected event to fire).
+ this.tabSet.selectTab(tab);
+
+ // Handle any remaining view items (e.g. id of a selected item in a subtab
that contains a Master-Details view).
+ Canvas subView = subtab.getCanvas();
+ if (subView instanceof BookmarkableView) {
+ ((BookmarkableView) subView).renderView(viewPath);
+ }
+
+ this.tabSet.markForRedraw();
+ } catch (Exception e) {
+ System.err.println("Failed to select tab " + tabTitle +
"/" + subtabTitle + ": " + e);
+ }
+ }
+
+ public TwoLevelTabSet getTabSet() {
+ return tabSet;
+ }
+
+ public String getTabName() {
+ return tabName;
+ }
+
+ public String getSubTabName() {
+ return subTabName;
+ }
+}
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 9d289ca..b51bc00 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
@@ -18,13 +18,12 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail;
+import java.util.ArrayList;
import java.util.EnumSet;
+import java.util.List;
import java.util.Set;
-import com.google.gwt.user.client.History;
import com.google.gwt.user.client.rpc.AsyncCallback;
-import com.smartgwt.client.types.Side;
-import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.tab.Tab;
import org.rhq.core.domain.authz.Permission;
@@ -38,23 +37,19 @@ import org.rhq.core.domain.resource.group.GroupCategory;
import org.rhq.core.domain.resource.group.ResourceGroup;
import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite;
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.ViewPath;
import org.rhq.enterprise.gui.coregui.client.components.FullHTMLPane;
import org.rhq.enterprise.gui.coregui.client.components.tab.SubTab;
import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTab;
-import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTabSelectedEvent;
-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.common.detail.AbstractTwoLevelTabSetView;
import
org.rhq.enterprise.gui.coregui.client.inventory.common.event.EventCompositeHistoryView;
import
org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.schedules.SchedulesView;
import
org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.traits.TraitsView;
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;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
/**
* Right panel of the group view.
@@ -62,13 +57,14 @@ import
org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
* @author Greg Hinkle
* @author Ian Springer
*/
-public class ResourceGroupDetailView extends LocatableVLayout implements
BookmarkableView, TwoLevelTabSelectedHandler {
- private static final String DEFAULT_TAB_NAME = "Inventory";
+public class ResourceGroupDetailView extends
AbstractTwoLevelTabSetView<ResourceGroupComposite, ResourceGroupTitleBar> {
+ private static final String BASE_VIEW_PATH = "ResourceGroup";
- private int groupId;
+ private Integer groupId;
private ResourceGroupComposite groupComposite;
private ResourcePermission permissions;
+ // tabs
private TwoLevelTab summaryTab;
private TwoLevelTab monitoringTab;
private TwoLevelTab inventoryTab;
@@ -77,8 +73,7 @@ public class ResourceGroupDetailView extends LocatableVLayout implements
Bookmar
private TwoLevelTab configurationTab;
private TwoLevelTab eventsTab;
- private TwoLevelTabSet topTabSet;
-
+ // subtabs
private SubTab summaryOverview;
private SubTab summaryTimeline;
private SubTab monitorGraphs;
@@ -96,32 +91,30 @@ public class ResourceGroupDetailView extends LocatableVLayout
implements Bookmar
private SubTab configHistory;
private SubTab eventHistory;
- private ResourceGroupTitleBar titleBar;
-
- private String tabName;
- private String subTabName;
-
public ResourceGroupDetailView(String locatorId) {
- super(locatorId);
+ super(locatorId, BASE_VIEW_PATH);
+ }
- setWidth100();
- setHeight100();
+ @Override
+ public Integer getSelectedItemId() {
+ return this.groupId;
+ }
- // The Tabs section
+ @Override
+ protected ResourceGroupTitleBar createTitleBar() {
+ return new ResourceGroupTitleBar(getLocatorId());
+ }
- topTabSet = new TwoLevelTabSet(getLocatorId());
- topTabSet.setTabBarPosition(Side.TOP);
- topTabSet.setWidth100();
- topTabSet.setHeight100();
- topTabSet.setEdgeMarginSize(0);
- topTabSet.setEdgeSize(0);
+ protected List<TwoLevelTab> createTabs() {
+ List<TwoLevelTab> tabs = new ArrayList<TwoLevelTab>();
- summaryTab = new TwoLevelTab(topTabSet.extendLocatorId("Summary"),
"Summary", "/images/icons/Service_up_16.png");
+ summaryTab = new TwoLevelTab(getTabSet().extendLocatorId("Summary"),
"Summary", "/images/icons/Service_up_16.png");
summaryOverview = new SubTab(summaryTab.extendLocatorId("Overview"),
"Overview", null);
summaryTimeline = new SubTab(summaryTab.extendLocatorId("Timeline"),
"Timeline", null);
summaryTab.registerSubTabs(summaryOverview, summaryTimeline);
+ tabs.add(summaryTab);
- monitoringTab = new
TwoLevelTab(topTabSet.extendLocatorId("Monitoring"), "Monitoring",
+ monitoringTab = new
TwoLevelTab(getTabSet().extendLocatorId("Monitoring"), "Monitoring",
"/images/icons/Monitor_grey_16.png");
monitorGraphs = new SubTab(monitoringTab.extendLocatorId("Graphs"),
"Graphs", null);
monitorTables = new SubTab(monitoringTab.extendLocatorId("Tables"),
"Tables", null);
@@ -130,54 +123,49 @@ public class ResourceGroupDetailView extends LocatableVLayout
implements Bookmar
monitorSched = new SubTab(monitoringTab.extendLocatorId("Schedules"),
"Schedules", null);
monitorCallTime = new SubTab(monitoringTab.extendLocatorId("CallTime"),
"Call Time", null);
monitoringTab.registerSubTabs(monitorGraphs, monitorTables, monitorTraits,
monitorSched, monitorCallTime);
+ tabs.add(monitoringTab);
- inventoryTab = new TwoLevelTab(topTabSet.extendLocatorId("Inventory"),
"Inventory",
+ inventoryTab = new
TwoLevelTab(getTabSet().extendLocatorId("Inventory"), "Inventory",
"/images/icons/Inventory_grey_16.png");
inventoryMembers = new SubTab(inventoryTab.extendLocatorId("Members"),
"Members", null);
inventoryConn = new
SubTab(inventoryTab.extendLocatorId("ConnectionSettings"), "Connection
Settings", null);
inventoryTab.registerSubTabs(this.inventoryMembers, this.inventoryConn);
+ tabs.add(inventoryTab);
- operationsTab = new
TwoLevelTab(topTabSet.extendLocatorId("Operations"), "Operations",
+ operationsTab = new
TwoLevelTab(getTabSet().extendLocatorId("Operations"), "Operations",
"/images/icons/Operation_grey_16.png");
this.opHistory = new SubTab(operationsTab.extendLocatorId("History"),
"History", null);
this.opSched = new SubTab(operationsTab.extendLocatorId("Scheduled"),
"Scheduled", null);
operationsTab.registerSubTabs(this.opHistory, this.opSched);
+ tabs.add(operationsTab);
- alertsTab = new TwoLevelTab(topTabSet.extendLocatorId("Alerts"),
"Alerts", "/images/icons/Alert_grey_16.png");
+ alertsTab = new TwoLevelTab(getTabSet().extendLocatorId("Alerts"),
"Alerts", "/images/icons/Alert_grey_16.png");
this.alertHistory = new SubTab(alertsTab.extendLocatorId("History"),
"History", null);
this.alertDef = new SubTab(alertsTab.extendLocatorId("Definitions"),
"Definitions", null);
alertsTab.registerSubTabs(alertHistory, alertDef);
+ tabs.add(alertsTab);
- configurationTab = new
TwoLevelTab(topTabSet.extendLocatorId("Configuration"),
"Configuration",
+ configurationTab = new
TwoLevelTab(getTabSet().extendLocatorId("Configuration"),
"Configuration",
"/images/icons/Configure_grey_16.png");
this.configCurrent = new
SubTab(configurationTab.extendLocatorId("Current"), "Current", null);
this.configHistory = new
SubTab(configurationTab.extendLocatorId("History"), "History", null);
configurationTab.registerSubTabs(this.configCurrent, this.configHistory);
+ tabs.add(configurationTab);
- eventsTab = new TwoLevelTab(topTabSet.extendLocatorId("Events"),
"Events", "/images/icons/Events_grey_16.png");
+ eventsTab = new TwoLevelTab(getTabSet().extendLocatorId("Events"),
"Events", "/images/icons/Events_grey_16.png");
this.eventHistory = new SubTab(eventsTab.extendLocatorId("History"),
"History", null);
eventsTab.registerSubTabs(eventHistory);
+ tabs.add(eventsTab);
- topTabSet.setTabs(summaryTab, monitoringTab, inventoryTab, operationsTab,
alertsTab, configurationTab,
- eventsTab);
-
- topTabSet.addTwoLevelTabSelectedHandler(this);
-
- titleBar = new ResourceGroupTitleBar(getLocatorId());
- addMember(titleBar);
-
- addMember(topTabSet);
-
- // CoreGUI.addBreadCrumb(getPlace());
+ return tabs;
}
- public void updateDetailViews(ResourceGroupComposite groupComposite) {
-
+ protected void updateTabContent(ResourceGroupComposite groupComposite) {
this.groupComposite = groupComposite;
- this.titleBar.setGroup(groupComposite.getResourceGroup());
+ getTitleBar().setGroup(groupComposite.getResourceGroup());
- for (Tab top : this.topTabSet.getTabs()) {
+ for (Tab top : this.getTabSet().getTabs()) {
((TwoLevelTab) top).getLayout().destroyViews();
}
@@ -218,7 +206,6 @@ public class ResourceGroupDetailView extends LocatableVLayout
implements Bookmar
updateTabEnablement();
}
-
private void updateTabEnablement() {
GroupCategory groupCategory =
groupComposite.getResourceGroup().getGroupCategory();
Set<ResourceTypeFacet> facets =
groupComposite.getResourceFacets().getFacets();
@@ -235,74 +222,22 @@ public class ResourceGroupDetailView extends LocatableVLayout
implements Bookmar
// Monitoring and Alerts tabs are always enabled for compatible groups and always
disabled for mixed groups.
// TODO (ips): Break out mixed groups into a separate view.
- this.topTabSet.setTabEnabled(this.monitoringTab, groupCategory ==
GroupCategory.COMPATIBLE);
- this.topTabSet.setTabEnabled(this.alertsTab, groupCategory ==
GroupCategory.COMPATIBLE);
+ getTabSet().setTabEnabled(this.monitoringTab, groupCategory ==
GroupCategory.COMPATIBLE);
+ getTabSet().setTabEnabled(this.alertsTab, groupCategory ==
GroupCategory.COMPATIBLE);
// Operations tab is only enabled for compatible groups of a type that supports
the Operations facet.
- this.topTabSet.setTabEnabled(this.operationsTab,
facets.contains(ResourceTypeFacet.OPERATION));
+ getTabSet().setTabEnabled(this.operationsTab,
facets.contains(ResourceTypeFacet.OPERATION));
// Configuration tab is only enabled for compatible groups of a type that
supports the Configuration facet
// and when the current user has the CONFIGURE_READ permission.
- this.topTabSet.setTabEnabled(this.configurationTab,
facets.contains(ResourceTypeFacet.CONFIGURATION)
+ getTabSet().setTabEnabled(this.configurationTab,
facets.contains(ResourceTypeFacet.CONFIGURATION)
&& this.permissions.isConfigureRead());
// Events tab is only enabled for compatible groups of a type that supports the
Events facet.
- this.topTabSet.setTabEnabled(this.eventsTab,
facets.contains(ResourceTypeFacet.EVENT));
- }
-
- public void onTabSelected(TwoLevelTabSelectedEvent tabSelectedEvent) {
- //CoreGUI.printWidgetTree();
-
- if (this.groupComposite == null) {
- // History.fireCurrentHistoryState();
- } else {
- String tabPath = "/" + tabSelectedEvent.getId() + "/" +
tabSelectedEvent.getSubTabId();
- String path = "ResourceGroup/" +
this.groupComposite.getResourceGroup().getId() + tabPath;
-
- // If the tab that was selected is not already the current history item, the
user clicked on the tab, rather
- // than going directly to the tab's URL. In this case, fire a history
event to go to the tab and make it the
- // current history item.
- if (!History.getToken().equals(path)) {
- //System.out.println("Firing History event [" + path +
"]...");
- History.newItem(path, true);
- }
- }
+ getTabSet().setTabEnabled(this.eventsTab,
facets.contains(ResourceTypeFacet.EVENT));
}
- public void renderView(ViewPath viewPath) {
- // e.g. #ResourceGroup/10010/Summary/Overview
- // ^ current path
- int groupId = Integer.parseInt(viewPath.getCurrent().getPath());
- viewPath.next();
-
- if (!viewPath.isEnd()) {
- // e.g. #ResourceGroup/10010/Summary/Overview
- // ^ current path
- this.tabName = viewPath.getCurrent().getPath();
- viewPath.next();
- if (!viewPath.isEnd()) {
- // e.g. #ResourceGroup/10010/Summary/Overview
- // ^ current path
- this.subTabName = viewPath.getCurrent().getPath();
- viewPath.next();
- } else {
- this.subTabName = null;
- }
- } else {
- this.tabName = null;
- }
-
- if (this.groupId != groupId) {
- // A different group or first load - go get data.
- loadSelectedGroup(groupId, viewPath);
- } else {
- // Same group - just switch tabs.
- selectTab(this.tabName, this.subTabName, viewPath);
- }
-
- }
-
- public void loadSelectedGroup(final int groupId, final ViewPath viewPath) {
+ protected void loadSelectedItem(final int groupId, final ViewPath viewPath) {
this.groupId = groupId;
ResourceGroupCriteria criteria = new ResourceGroupCriteria();
@@ -348,8 +283,8 @@ public class ResourceGroupDetailView extends LocatableVLayout
implements Bookmar
public void onSuccess(Set<Permission>
result) {
ResourceGroupDetailView.this.permissions =
new ResourcePermission(result);
- updateDetailViews(groupComposite);
- selectTab(tabName, subTabName, viewPath);
+ updateTabContent(groupComposite);
+ selectTab(getTabName(), getSubTabName(),
viewPath);
}
});
}
@@ -357,48 +292,6 @@ public class ResourceGroupDetailView extends LocatableVLayout
implements Bookmar
}
}
- /**
- * Select the tab/subtab with the specified titles (e.g. "Monitoring",
"Graphs").
- *
- * @param tabTitle the title of the tab to select - if null, the default tab (the
leftmost non-disabled one) will be selected
- * @param subtabTitle the title of the subtab to select - if null, the default subtab
(the leftmost non-disabled one) will be selected
- * @param viewPath the view path, which may have additional view items to be
rendered
- */
- public void selectTab(String tabTitle, String subtabTitle, ViewPath viewPath) {
- try {
- TwoLevelTab tab = (tabTitle != null) ? this.topTabSet.getTabByTitle(tabTitle)
:
- this.topTabSet.getDefaultTab();
- if (tab == null || tab.getDisabled()) {
- CoreGUI.getErrorHandler().handleError("Invalid tab name: " +
tabTitle);
- // TODO: Should we fire a history event here to redirect to a valid
bookmark?
- tab = this.topTabSet.getDefaultTab();
- subtabTitle = null;
- }
- // Do *not* select the tab and trigger the tab selected event until the
subtab has been selected first.
-
- SubTab subtab = (subtabTitle != null) ? tab.getSubTabByTitle(subtabTitle) :
tab.getDefaultSubTab();
- if (subtab == null || tab.getLayout().isDisabled()) {
- CoreGUI.getErrorHandler().handleError("Invalid subtab name: " +
subtabTitle);
- // TODO: Should we fire a history event here to redirect to a valid
bookmark?
- subtab = tab.getLayout().getDefaultSubTab();
- }
- tab.getLayout().selectSubTab(subtab);
-
- // Now that the subtab has been selected, select the tab (this will cause a
tab selected event to fire).
- this.topTabSet.selectTab(tab);
-
- // Handle any remaining view items (e.g. id of a selected item in a subtab
that contains a Master-Details view).
- Canvas subView = subtab.getCanvas();
- if (subView instanceof BookmarkableView) {
- ((BookmarkableView) subView).renderView(viewPath);
- }
-
- this.topTabSet.markForRedraw();
- } catch (Exception e) {
- System.err.println("Failed to select tab " + tabTitle +
"/" + subtabTitle + ": " + e);
- }
- }
-
private static boolean hasTraits(ResourceGroupComposite groupComposite) {
ResourceType type = groupComposite.getResourceGroup().getResourceType();
if (type != null) {
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 2451e4b..e4bb9fd 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
@@ -18,13 +18,12 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail;
+import java.util.ArrayList;
import java.util.EnumSet;
+import java.util.List;
import java.util.Set;
-import com.google.gwt.user.client.History;
import com.google.gwt.user.client.rpc.AsyncCallback;
-import com.smartgwt.client.types.Side;
-import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.tab.Tab;
import org.rhq.core.domain.criteria.ResourceCriteria;
@@ -36,17 +35,14 @@ import org.rhq.core.domain.resource.ResourceTypeFacet;
import org.rhq.core.domain.resource.composite.ResourceComposite;
import org.rhq.core.domain.resource.composite.ResourcePermission;
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.ViewPath;
import
org.rhq.enterprise.gui.coregui.client.alert.definitions.ResourceAlertDefinitionsView;
import org.rhq.enterprise.gui.coregui.client.components.FullHTMLPane;
import org.rhq.enterprise.gui.coregui.client.components.tab.SubTab;
import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTab;
-import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTabSelectedEvent;
-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.common.detail.AbstractTwoLevelTabSetView;
import
org.rhq.enterprise.gui.coregui.client.inventory.common.event.EventCompositeHistoryView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.InventoryView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceSearchView;
@@ -61,7 +57,6 @@ import
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.summary.D
import
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.summary.OverviewView;
import
org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
/**
* Right panel of the Resource view.
@@ -69,12 +64,12 @@ import
org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
* @author Greg Hinkle
* @author Ian Springer
*/
-public class ResourceDetailView extends LocatableVLayout implements BookmarkableView,
TwoLevelTabSelectedHandler {
- private int resourceId;
+public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceComposite,
ResourceTitleBar> {
+ private static final String BASE_VIEW_PATH = "Resource";
- private ResourceComposite resourceComposite;
+ private Integer resourceId;
- private TwoLevelTabSet topTabSet;
+ private ResourceComposite resourceComposite;
private TwoLevelTab summaryTab;
private TwoLevelTab monitoringTab;
@@ -109,33 +104,22 @@ public class ResourceDetailView extends LocatableVLayout implements
Bookmarkable
private SubTab contentSubscrip;
private SubTab contentHistory;
- private ResourceTitleBar titleBar;
-
- private String tabName;
- private String subTabName;
-
public ResourceDetailView(String locatorId) {
- super(locatorId);
-
- setWidth100();
- setHeight100();
-
- // The Tabs section
+ super(locatorId, BASE_VIEW_PATH);
+ }
- topTabSet = new TwoLevelTabSet(extendLocatorId("TabSet"));
- topTabSet.setTabBarPosition(Side.TOP);
- topTabSet.setWidth100();
- topTabSet.setHeight100();
- topTabSet.setEdgeMarginSize(0);
- topTabSet.setEdgeSize(0);
+ protected List<TwoLevelTab> createTabs() {
+ List<TwoLevelTab> tabs = new ArrayList<TwoLevelTab>();
- summaryTab = new TwoLevelTab(topTabSet.extendLocatorId("Summary"),
"Summary", "/images/icons/Service_up_16.png");
+ summaryTab = new TwoLevelTab(getTabSet().extendLocatorId("Summary"),
"Summary",
+ "/images/icons/Service_up_16.png");
summaryOverview = new SubTab(summaryTab.extendLocatorId("Overview"),
"Overview", null);
summaryDashboard = new SubTab(summaryTab.extendLocatorId("Dashboard"),
"Dashboard", null);
summaryTimeline = new SubTab(summaryTab.extendLocatorId("Timeline"),
"Timeline", null);
summaryTab.registerSubTabs(summaryOverview, summaryDashboard, summaryTimeline);
+ tabs.add(summaryTab);
- monitoringTab = new
TwoLevelTab(topTabSet.extendLocatorId("Monitoring"), "Monitoring",
+ monitoringTab = new
TwoLevelTab(getTabSet().extendLocatorId("Monitoring"), "Monitoring",
"/images/icons/Monitor_grey_16.png");
monitorGraphs = new SubTab(monitoringTab.extendLocatorId("Graphs"),
"Graphs", null);
monitorTables = new SubTab(monitoringTab.extendLocatorId("Tables"),
"Tables", null);
@@ -145,64 +129,64 @@ public class ResourceDetailView extends LocatableVLayout implements
Bookmarkable
monitorCallTime = new SubTab(monitoringTab.extendLocatorId("CallTime"),
"Call Time", null);
monitoringTab.registerSubTabs(monitorGraphs, monitorTables, monitorTraits,
monitorAvail, monitorSched,
monitorCallTime);
+ tabs.add(monitoringTab);
- inventoryTab = new TwoLevelTab(topTabSet.extendLocatorId("Inventory"),
"Inventory",
+ inventoryTab = new
TwoLevelTab(getTabSet().extendLocatorId("Inventory"), "Inventory",
"/images/icons/Inventory_grey_16.png");
inventoryChildren = new
SubTab(inventoryTab.extendLocatorId("Children"), "Children", null);
inventoryConn = new
SubTab(inventoryTab.extendLocatorId("ConnectionSettings"), "Connection
Settings", null);
inventoryTab.registerSubTabs(this.inventoryChildren, this.inventoryConn);
+ tabs.add(inventoryTab);
- operationsTab = new
TwoLevelTab(topTabSet.extendLocatorId("Operations"), "Operations",
+ operationsTab = new
TwoLevelTab(getTabSet().extendLocatorId("Operations"), "Operations",
"/images/icons/Operation_grey_16.png");
this.opHistory = new SubTab(operationsTab.extendLocatorId("History"),
"History", null);
this.opSched = new SubTab(operationsTab.extendLocatorId("Scheduled"),
"Scheduled", null);
operationsTab.registerSubTabs(this.opHistory, this.opSched);
+ tabs.add(operationsTab);
- alertsTab = new TwoLevelTab(topTabSet.extendLocatorId("Alerts"),
"Alerts", "/images/icons/Alert_grey_16.png");
+ alertsTab = new TwoLevelTab(getTabSet().extendLocatorId("Alerts"),
"Alerts", "/images/icons/Alert_grey_16.png");
this.alertHistory = new SubTab(alertsTab.extendLocatorId("History"),
"History", null);
this.alertDef = new SubTab(alertsTab.extendLocatorId("Definitions"),
"Definitions", null);
this.alertDelete = new SubTab(alertsTab.extendLocatorId("DELETEME"),
"DELETEME", null);
alertsTab.registerSubTabs(alertHistory, alertDef, alertDelete);
+ tabs.add(alertsTab);
- configurationTab = new
TwoLevelTab(topTabSet.extendLocatorId("Configuration"),
"Configuration",
+ configurationTab = new
TwoLevelTab(getTabSet().extendLocatorId("Configuration"),
"Configuration",
"/images/icons/Configure_grey_16.png");
this.configCurrent = new
SubTab(configurationTab.extendLocatorId("Current"), "Current", null);
this.configHistory = new
SubTab(configurationTab.extendLocatorId("History"), "History", null);
configurationTab.registerSubTabs(this.configCurrent, this.configHistory);
+ tabs.add(configurationTab);
- eventsTab = new TwoLevelTab(topTabSet.extendLocatorId("Events"),
"Events", "/images/icons/Events_grey_16.png");
+ eventsTab = new TwoLevelTab(getTabSet().extendLocatorId("Events"),
"Events", "/images/icons/Events_grey_16.png");
this.eventHistory = new SubTab(eventsTab.extendLocatorId("History"),
"History", null);
eventsTab.registerSubTabs(eventHistory);
+ tabs.add(eventsTab);
- contentTab = new TwoLevelTab(topTabSet.extendLocatorId("Content"),
"Content",
+ contentTab = new TwoLevelTab(getTabSet().extendLocatorId("Content"),
"Content",
"/images/icons/Content_grey_16.png");
this.contentDeployed = new
SubTab(contentTab.extendLocatorId("Deployed"), "Deployed", null);
this.contentNew = new SubTab(contentTab.extendLocatorId("New"),
"New", null);
this.contentSubscrip = new
SubTab(contentTab.extendLocatorId("Subscriptions"), "Subscriptions",
null);
this.contentHistory = new SubTab(contentTab.extendLocatorId("History"),
"History", null);
contentTab.registerSubTabs(contentDeployed, contentNew, contentSubscrip,
contentHistory);
+ tabs.add(contentTab);
- topTabSet.setTabs(summaryTab, monitoringTab, inventoryTab, operationsTab,
alertsTab, configurationTab,
- eventsTab, contentTab);
-
- topTabSet.addTwoLevelTabSelectedHandler(this);
-
- titleBar = new ResourceTitleBar(extendLocatorId("TitleBar"));
-
- addMember(titleBar);
- addMember(topTabSet);
-
- // CoreGUI.addBreadCrumb(getPlace());
+ return tabs;
}
- public void updateDetailViews(ResourceComposite resourceComposite) {
+ protected ResourceTitleBar createTitleBar() {
+ return new ResourceTitleBar(extendLocatorId("TitleBar"));
+ }
+ protected void updateTabContent(ResourceComposite resourceComposite) {
this.resourceComposite = resourceComposite;
final Resource resource = this.resourceComposite.getResource();
- this.titleBar.setResource(resource);
+ getTitleBar().setResource(resource);
- for (Tab top : this.topTabSet.getTabs()) {
+ for (Tab top : this.getTabSet().getTabs()) {
((TwoLevelTab) top).getLayout().destroyViews();
}
@@ -276,66 +260,17 @@ public class ResourceDetailView extends LocatableVLayout implements
Bookmarkable
ResourceType type = this.resourceComposite.getResource().getResourceType();
inventoryTab.setSubTabEnabled(inventoryChildren.getLocatorId(),
!type.getChildResourceTypes().isEmpty());
- this.topTabSet.setTabEnabled(this.operationsTab,
facets.contains(ResourceTypeFacet.OPERATION));
- this.topTabSet.setTabEnabled(this.configurationTab,
facets.contains(ResourceTypeFacet.CONFIGURATION) &&
permissions.isConfigureRead());
- this.topTabSet.setTabEnabled(this.eventsTab,
facets.contains(ResourceTypeFacet.EVENT));
- this.topTabSet.setTabEnabled(this.contentTab,
facets.contains(ResourceTypeFacet.CONTENT));
- }
-
- public void onTabSelected(TwoLevelTabSelectedEvent tabSelectedEvent) {
- //CoreGUI.printWidgetTree();
-
- if (this.resourceComposite == null) {
- // History.fireCurrentHistoryState();
- } else {
- // Switch tabs directly, rather than letting the history framework do it, to
avoid redrawing the outer views.
- // selectSubTabByTitle(tabSelectedEvent.getId(),
tabSelectedEvent.getSubTabId());
- String tabPath = "/" + tabSelectedEvent.getId() + "/" +
tabSelectedEvent.getSubTabId();
- String path = "Resource/" + resourceId + tabPath;
-
- // If the tab that was selected is not already the current history item, the
user clicked on the tab, rather
- // than going directly to the tab's URL. In this case, fire a history
event to go to the tab and make it the
- // current history item.
- if (!History.getToken().equals(path)) {
- System.out.println("Firing History event [" + path +
"]...");
- History.newItem(path, true);
- }
- }
+ getTabSet().setTabEnabled(this.operationsTab,
facets.contains(ResourceTypeFacet.OPERATION));
+ getTabSet().setTabEnabled(this.configurationTab,
facets.contains(ResourceTypeFacet.CONFIGURATION) &&
permissions.isConfigureRead());
+ getTabSet().setTabEnabled(this.eventsTab,
facets.contains(ResourceTypeFacet.EVENT));
+ getTabSet().setTabEnabled(this.contentTab,
facets.contains(ResourceTypeFacet.CONTENT));
}
- public void renderView(ViewPath viewPath) {
- // e.g. #Resource/10010/Summary/Overview
- // ^ current path
- int resourceId = Integer.parseInt(viewPath.getCurrent().getPath());
- viewPath.next();
-
- if (!viewPath.isEnd()) {
- // e.g. #Resource/10010/Summary/Overview
- // ^ current path
- this.tabName = viewPath.getCurrent().getPath();
- viewPath.next();
- if (!viewPath.isEnd()) {
- // e.g. #Resource/10010/Summary/Overview
- // ^ current path
- this.subTabName = viewPath.getCurrent().getPath();
- viewPath.next();
- } else {
- this.subTabName = null;
- }
- } else {
- this.tabName = null;
- }
-
- if (this.resourceId != resourceId) {
- // A different Resource or first load - go get data.
- loadSelectedResource(resourceId, viewPath);
- } else {
- // Same Resource - just switch tabs.
- selectTab(this.tabName, this.subTabName, viewPath);
- }
+ public Integer getSelectedItemId() {
+ return this.resourceId;
}
- public void loadSelectedResource(final int resourceId, final ViewPath viewPath) {
+ protected void loadSelectedItem(final int resourceId, final ViewPath viewPath) {
this.resourceId = resourceId;
ResourceCriteria criteria = new ResourceCriteria();
@@ -379,54 +314,12 @@ public class ResourceDetailView extends LocatableVLayout implements
Bookmarkable
public void onTypesLoaded(ResourceType type) {
resourceComposite.getResource().setResourceType(type);
ResourceDetailView.this.resourceComposite = resourceComposite;
- updateDetailViews(resourceComposite);
- selectTab(tabName, subTabName, viewPath);
+ updateTabContent(resourceComposite);
+ selectTab(getTabName(), getSubTabName(), viewPath);
}
});
}
- /**
- * Select the tab/subtab with the specified titles (e.g. "Monitoring",
"Graphs").
- *
- * @param tabTitle the title of the tab to select - if null, the default tab (the
leftmost non-disabled one) will be selected
- * @param subtabTitle the title of the subtab to select - if null, the default subtab
(the leftmost non-disabled one) will be selected
- * @param viewPath the view path, which may have additional view items to be
rendered
- */
- public void selectTab(String tabTitle, String subtabTitle, ViewPath viewPath) {
- try {
- TwoLevelTab tab = (tabTitle != null) ? this.topTabSet.getTabByTitle(tabTitle)
:
- this.topTabSet.getDefaultTab();
- if (tab == null || tab.getDisabled()) {
- CoreGUI.getErrorHandler().handleError("Invalid tab name: " +
tabTitle);
- // TODO: Should we fire a history event here to redirect to a valid
bookmark?
- tab = this.topTabSet.getDefaultTab();
- subtabTitle = null;
- }
- // Do *not* select the tab and trigger the tab selected event until the
subtab has been selected first.
-
- SubTab subtab = (subtabTitle != null) ? tab.getSubTabByTitle(subtabTitle) :
tab.getDefaultSubTab();
- if (subtab == null || tab.getLayout().isDisabled()) {
- CoreGUI.getErrorHandler().handleError("Invalid subtab name: " +
subtabTitle);
- // TODO: Should we fire a history event here to redirect to a valid
bookmark?
- subtab = tab.getLayout().getDefaultSubTab();
- }
- tab.getLayout().selectSubTab(subtab);
-
- // Now that the subtab has been selected, select the tab (this will cause a
tab selected event to fire).
- this.topTabSet.selectTab(tab);
-
- // Handle any remaining view items (e.g. id of a selected item in a subtab
that contains a Master-Details view).
- Canvas subView = subtab.getCanvas();
- if (subView instanceof BookmarkableView) {
- ((BookmarkableView) subView).renderView(viewPath);
- }
-
- this.topTabSet.markForRedraw();
- } catch (Exception e) {
- System.err.println("Failed to select tab " + tabTitle +
"/" + subtabTitle + ": " + e);
- }
- }
-
private static boolean hasTraits(ResourceComposite resourceComposite) {
ResourceType type = resourceComposite.getResource().getResourceType();
Set<MeasurementDefinition> metricDefs = type.getMetricDefinitions();