modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java | 55 - modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/InitializableView.java | 29 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/AdministrationView.java | 341 ++------- modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/view/AbstractSectionedLeftNavigationView.java | 47 - modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/view/NavigationItem.java | 10 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/InventoryView.java | 370 +++------- modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionListView.java | 3 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java | 11 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java | 8 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestConfigurationFactory.java | 311 -------- modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestConfigurationView.java | 133 --- modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestGroupConfigurationView.java | 142 --- modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestTopView.java | 90 ++ modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestConfigurationFactory.java | 311 ++++++++ modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestConfigurationView.java | 133 +++ modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestGroupConfigurationView.java | 142 +++ modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageBar.java | 1 17 files changed, 1027 insertions(+), 1110 deletions(-)
New commits: commit a943bf97ac60d3e8158b549d0e7abe19373e6e6f Author: Ian Springer ian.springer@redhat.com Date: Thu Oct 28 13:51:16 2010 -0400
refactor AdministrationView and InventoryView to extend the new AbstractSectionedLeftNavigationView base class; add a new Test top view for lumping together various test views
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 dccab2c..a8bdeba 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 @@ -27,6 +27,7 @@ import com.google.gwt.event.logical.shared.ValueChangeHandler; import com.google.gwt.http.client.URL; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.History; +import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.Window.Location; import com.smartgwt.client.core.KeyIdentifier; import com.smartgwt.client.types.Overflow; @@ -47,8 +48,7 @@ import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.ResourceT 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; -import org.rhq.enterprise.gui.coregui.client.test.TestConfigurationView; -import org.rhq.enterprise.gui.coregui.client.test.TestGroupConfigurationView; +import org.rhq.enterprise.gui.coregui.client.test.TestTopView; import org.rhq.enterprise.gui.coregui.client.util.ErrorHandler; import org.rhq.enterprise.gui.coregui.client.util.WidgetUtility; import org.rhq.enterprise.gui.coregui.client.util.message.MessageBar; @@ -56,6 +56,8 @@ import org.rhq.enterprise.gui.coregui.client.util.message.MessageCenter; import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
/** + * The GWT {@link EntryPoint entry point} to the RHQ GUI. + * * @author Greg Hinkle * @author Ian Springer */ @@ -192,11 +194,11 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String> { Canvas canvas;
if (breadcrumbName.equals(AdministrationView.VIEW_ID)) { - canvas = new AdministrationView("Admin"); + canvas = new AdministrationView(); } else if (breadcrumbName.equals(DemoCanvas.VIEW_ID)) { canvas = new DemoCanvas(); } else if (breadcrumbName.equals(InventoryView.VIEW_ID)) { - canvas = new InventoryView("Inventory"); + canvas = new InventoryView(); } else if (breadcrumbName.equals(ResourceTopView.VIEW_ID)) { canvas = new ResourceTopView("Resource"); } else if (breadcrumbName.equals(ResourceGroupTopView.VIEW_ID)) { @@ -215,11 +217,9 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String> { } else if (breadcrumbName.equals("Subsystems")) { canvas = new AlertHistoryView("Alert"); } else if (breadcrumbName.equals(ReportTopView.VIEW_ID)) { - canvas = new ReportTopView("Report"); - } else if (breadcrumbName.equals(TestConfigurationView.VIEW_ID)) { - canvas = new TestConfigurationView("TestConfig"); - } else if (breadcrumbName.equals(TestGroupConfigurationView.VIEW_ID)) { - canvas = new TestGroupConfigurationView("TestGroupConfig"); + canvas = new ReportTopView(); + } else if (breadcrumbName.equals(TestTopView.VIEW_ID)) { + canvas = new TestTopView(); } else { canvas = null; } @@ -306,7 +306,7 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String> { setHeight100(); }
- public void renderView(ViewPath viewPath) { + public void renderView(final ViewPath viewPath) { if (viewPath.isEnd()) { // default view History.newItem(DEFAULT_VIEW_PATH); @@ -321,19 +321,32 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String> { }
if (this.currentCanvas instanceof BookmarkableView) { - ((BookmarkableView) this.currentCanvas).renderView(viewPath.next()); + if (this.currentCanvas instanceof InitializableView) { + final InitializableView initializableView = (InitializableView)this.currentCanvas; + final long startTime = System.currentTimeMillis(); + final Timer timer = new Timer() { + public void run() { + if (initializableView.isInitialized()) { + ((BookmarkableView)currentCanvas).renderView(viewPath.next()); + } else { + long elapsedMillis = System.currentTimeMillis() - startTime; + if (elapsedMillis < 5000) { + // Reschedule the timer. + schedule(100); + } + } + } + }; + if (initializableView.isInitialized()) { + ((BookmarkableView)currentCanvas).renderView(viewPath.next()); + } else { + timer.schedule(100); + } + } else { + ((BookmarkableView)currentCanvas).renderView(viewPath.next()); + } }
- // reverting this is as it breaks rendering of single-element paths (like "#Bundles or - // #Reports. the BookmarkableView's renderView needs to be invoked. - // - //if (this.currentCanvas instanceof BookmarkableView) { - // viewPath.next(); - // if (!viewPath.isEnd()) { - // ((BookmarkableView) this.currentCanvas).renderView(viewPath); - // } - //} - refreshBreadCrumbTrail(); } } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/InitializableView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/InitializableView.java new file mode 100644 index 0000000..2420649 --- /dev/null +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/InitializableView.java @@ -0,0 +1,29 @@ +/* + * 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; + +/** + * The SmartGWT BaseWidget class provides no way to check if the widget has completed its init()/onInit(), so + * components that wish to provide that information can implement this interface. + * + * @author Ian Springer + */ +public interface InitializableView { + boolean isInitialized(); +} \ No newline at end of file diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/AdministrationView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/AdministrationView.java index f622596..dcd6aea 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/AdministrationView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/AdministrationView.java @@ -18,39 +18,29 @@ */ package org.rhq.enterprise.gui.coregui.client.admin;
-import java.util.LinkedHashMap; -import java.util.Map; +import java.util.ArrayList; +import java.util.List;
-import com.smartgwt.client.types.VisibilityMode; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.HTMLFlow; -import com.smartgwt.client.widgets.grid.events.CellClickEvent; -import com.smartgwt.client.widgets.grid.events.CellClickHandler; -import com.smartgwt.client.widgets.layout.SectionStack; -import com.smartgwt.client.widgets.layout.SectionStackSection; -import com.smartgwt.client.widgets.tree.Tree; -import com.smartgwt.client.widgets.tree.TreeGrid; -import com.smartgwt.client.widgets.tree.TreeNode;
-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.admin.agent.install.RemoteAgentInstallView; import org.rhq.enterprise.gui.coregui.client.admin.roles.RolesView; import org.rhq.enterprise.gui.coregui.client.admin.templates.ResourceTypeTreeView; import org.rhq.enterprise.gui.coregui.client.admin.users.UsersView; import org.rhq.enterprise.gui.coregui.client.components.FullHTMLPane; -import org.rhq.enterprise.gui.coregui.client.components.tree.EnhancedTreeNode; -import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout; -import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableSectionStack; -import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableTreeGrid; +import org.rhq.enterprise.gui.coregui.client.components.view.AbstractSectionedLeftNavigationView; +import org.rhq.enterprise.gui.coregui.client.components.view.NavigationItem; +import org.rhq.enterprise.gui.coregui.client.components.view.NavigationSection; +import org.rhq.enterprise.gui.coregui.client.components.view.ViewFactory;
/** + * The Administration top-level view. + * * @author Greg Hinkle + * @author Ian Springer */ -// TODO (ips, 10/28/10): Refactor this class to extend AbstractSectionedLeftNavigationView. -public class AdministrationView extends LocatableHLayout implements BookmarkableView { +public class AdministrationView extends AbstractSectionedLeftNavigationView { public static final String VIEW_ID = "Administration";
private static final String SECTION_SECURITY_VIEW_ID = "Security"; @@ -69,258 +59,137 @@ public class AdministrationView extends LocatableHLayout implements Bookmarkable private static final String PAGE_LICENSE_VIEW_ID = "License"; private static final String PAGE_PLUGINS_VIEW_ID = "Plugins";
- private ViewId currentSectionViewId; - private ViewId currentPageViewId; - - private SectionStack sectionStack; - - private Canvas contentCanvas; - private Canvas currentContent; - private Map<String, TreeGrid> treeGrids = new LinkedHashMap<String, TreeGrid>(); - - public AdministrationView(String locatorId) { - super(locatorId); + public AdministrationView() { + // This is a top level view, so our locator id can simply be our view id. + super(VIEW_ID); }
@Override - protected void onInit() { - super.onInit(); + protected List<NavigationSection> getNavigationSections() { + List<NavigationSection> sections = new ArrayList<NavigationSection>();
- setWidth100(); - setHeight100(); + NavigationSection securitySection = buildSecuritySection(); + sections.add(securitySection);
- contentCanvas = new Canvas(); - contentCanvas.setWidth("*"); - contentCanvas.setHeight100(); + NavigationSection topologySection = buildTopologySection(); + sections.add(topologySection);
- sectionStack = new LocatableSectionStack(this.getLocatorId()); - sectionStack.setShowResizeBar(true); - sectionStack.setVisibilityMode(VisibilityMode.MULTIPLE); - sectionStack.setWidth(250); - sectionStack.setHeight100(); + NavigationSection configurationSection = buildConfigurationSection(); + sections.add(configurationSection);
- addSection(buildSecuritySection()); - addSection(buildSystemConfigurationSection()); - addSection(buildTopologySection()); - - addMember(sectionStack); - addMember(contentCanvas); + return sections; }
- private void addSection(final TreeGrid treeGrid) { - final String sectionName = treeGrid.getTree().getRoot().getName(); - this.treeGrids.put(sectionName, treeGrid); - - treeGrid.addCellClickHandler(new CellClickHandler() { - @Override - public void onCellClick(CellClickEvent event) { - // we use cell click as opposed to selected changed handler - // because we want to be able to refresh even if clicking - // on an already selected node - TreeNode selectedRecord = (TreeNode) treeGrid.getSelectedRecord(); - if (selectedRecord != null) { - String pageName = selectedRecord.getName(); - String viewPath = AdministrationView.VIEW_ID + "/" + sectionName + "/" + pageName; - CoreGUI.goToView(viewPath); - } - } - }); - - SectionStackSection section = new SectionStackSection(sectionName); - section.setExpanded(true); - section.addItem(treeGrid); - - this.sectionStack.addSection(section); - } - - private HTMLFlow defaultView() { + protected HTMLFlow defaultView() { String contents = "<h1>Administration</h1>\n" + "From this section, the RHQ global settings can be administered. This includes configuring \n" - + "<a href="">Security</a>, setting up <a href="">Plugins</a> and other stuff."; + + "<a href="">Security</a>, setting up <a href="">Plugins</a> and various other stuff."; HTMLFlow flow = new HTMLFlow(contents); flow.setPadding(20); return flow; }
- private TreeGrid buildSecuritySection() { - - final TreeGrid securityTreeGrid = new LocatableTreeGrid(SECTION_SECURITY_VIEW_ID); - securityTreeGrid.setLeaveScrollbarGap(false); - securityTreeGrid.setShowHeader(false); - - Tree tree = new Tree(); - final TreeNode manageUsersNode = new EnhancedTreeNode(UsersView.VIEW_ID); - manageUsersNode.setIcon("global/User_16.png"); - - final TreeNode manageRolesNode = new EnhancedTreeNode(RolesView.VIEW_ID); - manageRolesNode.setIcon("global/Role_16.png"); - - final TreeNode remoteAgentInstall = new EnhancedTreeNode(RemoteAgentInstallView.VIEW_ID); - remoteAgentInstall.setIcon("global/Agent_16.png"); - - TreeNode rootNode = new EnhancedTreeNode(SECTION_SECURITY_VIEW_ID, manageUsersNode, manageRolesNode, - remoteAgentInstall); - tree.setRoot(rootNode); - - securityTreeGrid.setData(tree); - - return securityTreeGrid; - } - - private TreeGrid buildTopologySection() { - - final TreeGrid mgmtClusterTreeGrid = new LocatableTreeGrid(SECTION_TOPOLOGY_VIEW_ID); - mgmtClusterTreeGrid.setLeaveScrollbarGap(false); - mgmtClusterTreeGrid.setShowHeader(false); - - Tree tree = new Tree(); - final TreeNode manageServersNode = new EnhancedTreeNode(PAGE_SERVERS_VIEW_ID); - final TreeNode manageAgentsNode = new EnhancedTreeNode(PAGE_AGENTS_VIEW_ID); - final TreeNode manageAffinityGroupsNode = new EnhancedTreeNode(PAGE_AFFINITY_GROUPS_VIEW_ID); - final TreeNode managePartitionEventsNode = new EnhancedTreeNode(PAGE_PARTITION_EVENTS_VIEW_ID); - - TreeNode rootNode = new EnhancedTreeNode(SECTION_TOPOLOGY_VIEW_ID, manageServersNode, manageAgentsNode, - manageAffinityGroupsNode, managePartitionEventsNode); - tree.setRoot(rootNode); + private NavigationSection buildSecuritySection() { + NavigationItem usersItem = new NavigationItem(UsersView.VIEW_ID, "global/User_16.png", + new ViewFactory() { + public Canvas createView() { + return new UsersView(extendLocatorId("Users")); + } + });
- mgmtClusterTreeGrid.setData(tree); + NavigationItem rolesItem = new NavigationItem(RolesView.VIEW_ID, "global/Role_16.png", + new ViewFactory() { + public Canvas createView() { + return new RolesView(extendLocatorId("Roles")); + } + });
- return mgmtClusterTreeGrid; + return new NavigationSection(SECTION_SECURITY_VIEW_ID, usersItem, rolesItem); }
- private TreeGrid buildSystemConfigurationSection() { - - final TreeGrid systemConfigTreeGrid = new LocatableTreeGrid(SECTION_CONFIGURATION_VIEW_ID); - systemConfigTreeGrid.setLeaveScrollbarGap(false); - systemConfigTreeGrid.setShowHeader(false); - - Tree tree = new Tree(); - final TreeNode manageSettings = new EnhancedTreeNode(PAGE_SYSTEM_SETTINGS_VIEW_ID); - final TreeNode manageTemplates = new EnhancedTreeNode(PAGE_TEMPLATES_VIEW_ID); - final TreeNode manageDownloads = new EnhancedTreeNode(PAGE_DOWNLOADS_VIEW_ID); - final TreeNode manageLicense = new EnhancedTreeNode(PAGE_LICENSE_VIEW_ID); - final TreeNode managePlugins = new EnhancedTreeNode(PAGE_PLUGINS_VIEW_ID); - - TreeNode rootNode = new EnhancedTreeNode(SECTION_CONFIGURATION_VIEW_ID, manageSettings, manageTemplates, - manageDownloads, manageLicense, managePlugins); - tree.setRoot(rootNode); + private NavigationSection buildTopologySection() { + NavigationItem serversItem = new NavigationItem(PAGE_SERVERS_VIEW_ID, null, + new ViewFactory() { + public Canvas createView() { + return new FullHTMLPane(extendLocatorId(PAGE_SERVERS_VIEW_ID), "/rhq/ha/listServers-plain.xhtml?nomenu=true"); + } + });
- systemConfigTreeGrid.setData(tree); + NavigationItem agentsItem = new NavigationItem(PAGE_AGENTS_VIEW_ID, null, + new ViewFactory() { + public Canvas createView() { + return new FullHTMLPane(extendLocatorId(PAGE_AGENTS_VIEW_ID), "/rhq/ha/listAgents-plain.xhtml?nomenu=true"); + } + });
- return systemConfigTreeGrid; - } + NavigationItem affinityGroupsItem = new NavigationItem(PAGE_AFFINITY_GROUPS_VIEW_ID, null, + new ViewFactory() { + public Canvas createView() { + return new FullHTMLPane(extendLocatorId(PAGE_AFFINITY_GROUPS_VIEW_ID), + "/rhq/ha/listAffinityGroups-plain.xhtml?nomenu=true"); + } + });
- public void setContent(Canvas newContent) { + NavigationItem partitionEventsItem = new NavigationItem(PAGE_PARTITION_EVENTS_VIEW_ID, null, + new ViewFactory() { + public Canvas createView() { + return new FullHTMLPane(extendLocatorId(PAGE_PARTITION_EVENTS_VIEW_ID), + "/rhq/ha/listPartitionEvents-plain.xhtml?nomenu=true"); + } + });
- // A call to destroy (e.g. certain IFrames/FullHTMLPane) can actually remove multiple children of the - // contentCanvas. As such, we need to query for the children after each destroy to ensure only valid children - // are in the array. - Canvas[] children; - while ((children = contentCanvas.getChildren()).length > 0) { - children[0].destroy(); - } + NavigationItem remoteAgentInstallItem = new NavigationItem(RemoteAgentInstallView.VIEW_ID, "global/Agent_16.png", + new ViewFactory() { + public Canvas createView() { + return new RemoteAgentInstallView(extendLocatorId("RemoteAgentInstall")); + } + });
- contentCanvas.addChild(newContent); - contentCanvas.markForRedraw(); - currentContent = newContent; + return new NavigationSection(SECTION_TOPOLOGY_VIEW_ID, serversItem, agentsItem, affinityGroupsItem, + partitionEventsItem, remoteAgentInstallItem); }
- private void renderContentView(ViewPath viewPath) { - currentSectionViewId = viewPath.getCurrent(); - currentPageViewId = viewPath.getNext(); - - String sectionName = currentSectionViewId.getPath(); - String pageName = currentPageViewId.getPath(); - - Canvas content = null; - if (SECTION_SECURITY_VIEW_ID.equals(sectionName)) { - - if (UsersView.VIEW_ID.equals(pageName)) { - content = new UsersView(this.extendLocatorId("Users")); - } else if (RolesView.VIEW_ID.equals(pageName)) { - content = new RolesView(this.extendLocatorId("Roles")); - } else if (RemoteAgentInstallView.VIEW_ID.equals(pageName)) { - content = new RemoteAgentInstallView(this.extendLocatorId("RemoteAgentInstall")); - } - } else if (SECTION_CONFIGURATION_VIEW_ID.equals(sectionName)) { - String url = null; - if (PAGE_SYSTEM_SETTINGS_VIEW_ID.equals(pageName)) { - url = "/admin/config/Config.do?mode=edit"; - } else if (PAGE_TEMPLATES_VIEW_ID.equals(pageName)) { - content = new ResourceTypeTreeView(this.extendLocatorId("Templates")); - currentPageViewId = null; // we always want to refresh, even if we renavigate back - } else if (PAGE_DOWNLOADS_VIEW_ID.equals(pageName)) { - url = "/rhq/admin/downloads-body.xhtml"; - } else if (PAGE_LICENSE_VIEW_ID.equals(pageName)) { - url = "/admin/license/LicenseAdmin.do?mode=view"; - } else if (PAGE_PLUGINS_VIEW_ID.equals(pageName)) { - url = "/rhq/admin/plugin/plugin-list-plain.xhtml"; - } - if (url != null) { - url = addQueryStringParam(url, "nomenu=true"); - content = new FullHTMLPane(this.extendLocatorId(pageName), url); + private NavigationSection buildConfigurationSection() { + NavigationItem systemSettingsItem = new NavigationItem(PAGE_SYSTEM_SETTINGS_VIEW_ID, null, + new ViewFactory() { + public Canvas createView() { + return new FullHTMLPane(extendLocatorId(PAGE_SYSTEM_SETTINGS_VIEW_ID), + "/admin/config/Config.do?mode=edit&nomenu=true"); } + });
- } else if (SECTION_TOPOLOGY_VIEW_ID.equals(sectionName)) { - String url = null; - if (PAGE_SERVERS_VIEW_ID.equals(pageName)) { - url = "/rhq/ha/listServers-plain.xhtml"; - } else if (PAGE_AGENTS_VIEW_ID.equals(pageName)) { - url = "/rhq/ha/listAgents-plain.xhtml"; - } else if (PAGE_AFFINITY_GROUPS_VIEW_ID.equals(pageName)) { - url = "/rhq/ha/listAffinityGroups-plain.xhtml"; - } else if (PAGE_PARTITION_EVENTS_VIEW_ID.equals(pageName)) { - url = "/rhq/ha/listPartitionEvents-plain.xhtml"; + NavigationItem templatesItem = new NavigationItem(PAGE_TEMPLATES_VIEW_ID, null, + new ViewFactory() { + public Canvas createView() { + return new ResourceTypeTreeView(extendLocatorId(PAGE_TEMPLATES_VIEW_ID)); } - content = new FullHTMLPane(this.extendLocatorId(pageName), url); - } - - // when changing sections make sure the previous section's selection is deselected - selectSectionPageTreeGridNode(sectionName, pageName); - - // ignore clicks on subsection folder nodes - if (null != content) { - setContent(content); + });
- if (content instanceof BookmarkableView) { - ((BookmarkableView) content).renderView(viewPath.next().next()); + NavigationItem downloadsItem = new NavigationItem(PAGE_DOWNLOADS_VIEW_ID, null, + new ViewFactory() { + public Canvas createView() { + return new FullHTMLPane(extendLocatorId(PAGE_DOWNLOADS_VIEW_ID), + "/rhq/admin/downloads-body.xhtml?nomenu=true"); } - } - } + });
- public void renderView(ViewPath viewPath) { - if (!viewPath.isCurrent(currentSectionViewId) || !viewPath.isNext(currentPageViewId)) { - if (viewPath.isEnd()) { - // Display default view - setContent(defaultView()); - } else { - renderContentView(viewPath); + NavigationItem licenseItem = new NavigationItem(PAGE_LICENSE_VIEW_ID, null, + new ViewFactory() { + public Canvas createView() { + return new FullHTMLPane(extendLocatorId(PAGE_LICENSE_VIEW_ID), + "/admin/license/LicenseAdmin.do?mode=view&nomenu=true"); } - } else { - if (this.currentContent instanceof BookmarkableView) { - ((BookmarkableView) this.currentContent).renderView(viewPath.next().next()); - } - } - } + });
- private void selectSectionPageTreeGridNode(String sectionName, String pageName) { - for (String name : treeGrids.keySet()) { - TreeGrid treeGrid = treeGrids.get(name); - if (!name.equals(sectionName)) { - treeGrid.deselectAllRecords(); - } else { - TreeNode node = treeGrid.getTree().find(pageName); - if (node != null) { - treeGrid.selectSingleRecord(node); - } else { - CoreGUI.getErrorHandler().handleError("Unknown page name - URL is incorrect"); - } + NavigationItem pluginsItem = new NavigationItem(PAGE_PLUGINS_VIEW_ID, null, + new ViewFactory() { + public Canvas createView() { + return new FullHTMLPane(extendLocatorId(PAGE_PLUGINS_VIEW_ID), + "/rhq/admin/plugin/plugin-list-plain.xhtml?nomenu=true"); } - } - } + });
- private static String addQueryStringParam(String url, String param) { - char separatorChar = (url.indexOf('?') == -1) ? '?' : '&'; - return url + separatorChar + param; + return new NavigationSection(SECTION_CONFIGURATION_VIEW_ID, systemSettingsItem, templatesItem, downloadsItem, + licenseItem, pluginsItem); } } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/view/AbstractSectionedLeftNavigationView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/view/AbstractSectionedLeftNavigationView.java index 94b957f..74861c2 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/view/AbstractSectionedLeftNavigationView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/view/AbstractSectionedLeftNavigationView.java @@ -35,6 +35,7 @@ import com.smartgwt.client.widgets.tree.TreeNode;
import org.rhq.enterprise.gui.coregui.client.BookmarkableView; import org.rhq.enterprise.gui.coregui.client.CoreGUI; +import org.rhq.enterprise.gui.coregui.client.InitializableView; import org.rhq.enterprise.gui.coregui.client.ViewId; import org.rhq.enterprise.gui.coregui.client.ViewPath; import org.rhq.enterprise.gui.coregui.client.components.tree.EnhancedTreeNode; @@ -50,8 +51,10 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableTreeGrid; * @author Ian Springer * @author Jay Shaughnessy */ -public abstract class AbstractSectionedLeftNavigationView extends LocatableHLayout implements BookmarkableView { +public abstract class AbstractSectionedLeftNavigationView extends LocatableHLayout implements BookmarkableView, + InitializableView { private String viewId; + private boolean initialized; private ViewId currentSectionViewId; private ViewId currentPageViewId;
@@ -62,12 +65,8 @@ public abstract class AbstractSectionedLeftNavigationView extends LocatableHLayo private Map<String, TreeGrid> treeGrids = new LinkedHashMap<String, TreeGrid>(); private Map<String, NavigationSection> sectionsByName;
- public AbstractSectionedLeftNavigationView(String locatorId) { - this(locatorId, locatorId); - } - - public AbstractSectionedLeftNavigationView(String locatorId, String viewId) { - super(locatorId); + public AbstractSectionedLeftNavigationView(String viewId) { + super(viewId); this.viewId = viewId; }
@@ -93,11 +92,19 @@ public abstract class AbstractSectionedLeftNavigationView extends LocatableHLayo for (NavigationSection section : sections) { TreeGrid treeGrid = buildTreeGridForSection(section); addSection(treeGrid); + treeGrid.getTree().openAll(); this.sectionsByName.put(section.getName(), section); }
addMember(sectionStack); addMember(contentCanvas); + + this.initialized = true; + } + + @Override + public boolean isInitialized() { + return this.initialized; }
protected abstract Canvas defaultView(); @@ -115,6 +122,7 @@ public abstract class AbstractSectionedLeftNavigationView extends LocatableHLayo NavigationItem item = navigationItems.get(i); final TreeNode treeNode = new EnhancedTreeNode(item.getName()); treeNode.setIcon(item.getIcon()); + treeNode.setEnabled(item.isEnabled()); treeNodes[i] = treeNode; }
@@ -167,23 +175,28 @@ public abstract class AbstractSectionedLeftNavigationView extends LocatableHLayo }
private void renderContentView(ViewPath viewPath) { - currentSectionViewId = viewPath.getCurrent(); - currentPageViewId = viewPath.getNext(); + this.currentSectionViewId = viewPath.getCurrent(); + this.currentPageViewId = viewPath.getNext();
- String sectionName = currentSectionViewId.getPath(); - String pageName = currentPageViewId.getPath(); + String sectionName = this.currentSectionViewId.getPath(); + String pageName = this.currentPageViewId.getPath();
NavigationSection section = this.sectionsByName.get(sectionName); + if (section == null) { + throw new IllegalStateException("Invalid section: " + sectionName); + } NavigationItem item = section.getNavigationItem(pageName); - // TODO: null checks for section and item. - ViewFactory viewFactory = item.getViewFactory(); - Canvas content = viewFactory.createView(); + if (item == null) { + throw new IllegalStateException("Invalid page: " + pageName); + }
- // When changing sections make sure the previous section's selection is deselected. + // When changing sections, make sure the previous section's selection is deselected. selectSectionPageTreeGridNode(sectionName, pageName);
- // Ignore clicks on subsection folder nodes. - if (null != content) { + // Only update the content pane if the item has an associated view factory. + ViewFactory viewFactory = item.getViewFactory(); + Canvas content = (viewFactory != null) ? viewFactory.createView() : null; + if (content != null) { setContent(content);
if (content instanceof BookmarkableView) { diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/view/NavigationItem.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/view/NavigationItem.java index ee64e84..24e04ff 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/view/NavigationItem.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/view/NavigationItem.java @@ -26,11 +26,17 @@ public class NavigationItem { private String name; private String icon; private ViewFactory viewFactory; + private boolean enabled;
public NavigationItem(String name, String icon, ViewFactory viewFactory) { + this(name, icon, viewFactory, true); + } + + public NavigationItem(String name, String icon, ViewFactory viewFactory, boolean enabled) { this.icon = icon; this.name = name; this.viewFactory = viewFactory; + this.enabled = enabled; }
public String getName() { @@ -44,4 +50,8 @@ public class NavigationItem { public ViewFactory getViewFactory() { return viewFactory; } + + public boolean isEnabled() { + return enabled; + } } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/InventoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/InventoryView.java index ca23a16..ac2890d 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/InventoryView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/InventoryView.java @@ -18,33 +18,25 @@ */ package org.rhq.enterprise.gui.coregui.client.inventory;
+import java.util.ArrayList; import java.util.EnumSet; -import java.util.LinkedHashMap; -import java.util.Map; +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.data.Criteria; -import com.smartgwt.client.types.VisibilityMode; import com.smartgwt.client.widgets.Canvas; -import com.smartgwt.client.widgets.grid.events.SelectionChangedHandler; -import com.smartgwt.client.widgets.grid.events.SelectionEvent; -import com.smartgwt.client.widgets.layout.SectionStack; -import com.smartgwt.client.widgets.layout.SectionStackSection; -import com.smartgwt.client.widgets.tree.Tree; -import com.smartgwt.client.widgets.tree.TreeGrid; -import com.smartgwt.client.widgets.tree.TreeNode; +import com.smartgwt.client.widgets.HTMLFlow;
import org.rhq.core.domain.authz.Permission; import org.rhq.core.domain.measurement.AvailabilityType; import org.rhq.core.domain.resource.ResourceCategory; import org.rhq.core.domain.resource.group.GroupCategory; -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.components.tree.EnhancedTreeNode; +import org.rhq.enterprise.gui.coregui.client.components.view.AbstractSectionedLeftNavigationView; +import org.rhq.enterprise.gui.coregui.client.components.view.NavigationItem; +import org.rhq.enterprise.gui.coregui.client.components.view.NavigationSection; +import org.rhq.enterprise.gui.coregui.client.components.view.ViewFactory; import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; import org.rhq.enterprise.gui.coregui.client.inventory.groups.ResourceGroupDataSourceField; import org.rhq.enterprise.gui.coregui.client.inventory.groups.ResourceGroupListView; @@ -52,293 +44,189 @@ import org.rhq.enterprise.gui.coregui.client.inventory.groups.definitions.GroupD import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField; import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceSearchView; import org.rhq.enterprise.gui.coregui.client.inventory.resource.discovery.ResourceAutodiscoveryView; -import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout; -import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableSectionStack; -import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableTreeGrid;
/** + * The Inventory top-level view. + * * @author Greg Hinkle * @author Joseph Marques + * @author Ian Springer */ -// TODO (ips, 10/28/10): Refactor this class to extend AbstractSectionedLeftNavigationView. -public class InventoryView extends LocatableHLayout implements BookmarkableView { +public class InventoryView extends AbstractSectionedLeftNavigationView { public static final String VIEW_ID = "Inventory";
- private static final String GROUPS_SECTION_VIEW_ID = "Groups"; + // view IDs for Resources section private static final String RESOURCES_SECTION_VIEW_ID = "Resources";
- private static final String SUBSECTION_RESOURCE_INVENTORY = "Resources"; - private static final String SUBSECTION_GROUP_INVENTORY = "Groups"; - private static final String SUBSECTION_SAVED_SEARCHES = "SavedSearches"; - - private static final String PAGE_ADQ = "DiscoveryManager"; - private static final String PAGE_COMPATIBLE_GROUPS = "CompatibleGroups"; - private static final String PAGE_DOWN = "DownServers"; - private static final String PAGE_GROUPS = "AllGroups"; - private static final String PAGE_GROUP_DEFINITIONS = "DynagroupManager"; - private static final String PAGE_MIXED_GROUPS = "MixedGroups"; + private static final String PAGE_AUTODISCOVERY_QUEUE = "AutodiscoveryQueue"; + private static final String PAGE_ALL_RESOURCES = "AllResources"; private static final String PAGE_PLATFORMS = "Platforms"; - private static final String PAGE_PROBLEM_GROUPS = "ProblemGroups"; - private static final String PAGE_RESOURCES = "AllResources"; private static final String PAGE_SERVERS = "Servers"; private static final String PAGE_SERVICES = "Services"; + private static final String PAGE_DOWN_SERVERS = "DownServers";
- private ViewId currentSectionViewId; - private ViewId currentPageViewId; + // view IDs for Groups section + private static final String GROUPS_SECTION_VIEW_ID = "Groups";
- private Canvas contentCanvas; - private Canvas currentContent; - private Map<String, TreeGrid> treeGrids = new LinkedHashMap<String, TreeGrid>(); + private static final String PAGE_DYNAGROUP_DEFINITIONS = "DynagroupDefinitions"; + private static final String PAGE_ALL_GROUPS = "AllGroups"; + private static final String PAGE_COMPATIBLE_GROUPS = "CompatibleGroups"; + private static final String PAGE_MIXED_GROUPS = "MixedGroups"; + private static final String PAGE_PROBLEM_GROUPS = "ProblemGroups";
- private SectionStack sectionStack; + private Set<Permission> globalPermissions;
- public InventoryView(String locatorId) { - super(locatorId); + public InventoryView() { + // This is a top level view, so our locator id can simply be our view id. + super(VIEW_ID); }
@Override protected void onInit() { - super.onInit(); - - setWidth100(); - setHeight100(); - - contentCanvas = new Canvas(); - contentCanvas.setWidth("*"); - contentCanvas.setHeight100(); - - sectionStack = new LocatableSectionStack(getLocatorId()); - sectionStack.setShowResizeBar(true); - sectionStack.setVisibilityMode(VisibilityMode.MULTIPLE); - sectionStack.setWidth(250); - sectionStack.setHeight100(); - GWTServiceLookup.getAuthorizationService().getExplicitGlobalPermissions(new AsyncCallback<Set<Permission>>() { @Override public void onFailure(Throwable caught) { CoreGUI.getErrorHandler().handleError("Could not determine user's global permissions - assuming none.", caught); - finishOnInit(EnumSet.noneOf(Permission.class)); + globalPermissions = EnumSet.noneOf(Permission.class); + InventoryView.super.onInit(); }
@Override public void onSuccess(Set<Permission> result) { - finishOnInit(result); - } - }); - } - - private void finishOnInit(Set<Permission> globalPermissions) { - addSection(buildResourcesSection(globalPermissions)); - addSection(buildGroupsSection(globalPermissions)); - - addMember(sectionStack); - addMember(contentCanvas); - } - - private void addSection(TreeGrid treeGrid) { - final String sectionName = treeGrid.getTree().getRoot().getName(); - this.treeGrids.put(sectionName, treeGrid); - - treeGrid.addSelectionChangedHandler(new SelectionChangedHandler() { - public void onSelectionChanged(SelectionEvent selectionEvent) { - if (selectionEvent.getState()) { - TreeNode node = (TreeNode) selectionEvent.getRecord(); - String pageName = node.getName(); - String viewPath = InventoryView.VIEW_ID + "/" + sectionName + "/" + pageName; - String currentViewPath = History.getToken(); - if (!currentViewPath.startsWith(viewPath)) { - CoreGUI.goToView(viewPath); - } - } + globalPermissions = result; + InventoryView.super.onInit(); } }); - - SectionStackSection section = new SectionStackSection(sectionName); - section.setExpanded(true); - section.addItem(treeGrid); - - this.sectionStack.addSection(section); }
- private TreeGrid buildResourcesSection(Set<Permission> globalPermissions) { - final TreeNode discoveryQueue = new EnhancedTreeNode(PAGE_ADQ); - discoveryQueue.setEnabled(globalPermissions.contains(Permission.MANAGE_INVENTORY)); - discoveryQueue.setIcon("global/Recent_16.png"); - - final TreeNode onlyPlatforms = new EnhancedTreeNode(PAGE_PLATFORMS); - onlyPlatforms.setIcon("types/Platform_up_16.png"); - - final TreeNode onlyServers = new EnhancedTreeNode(PAGE_SERVERS); - onlyServers.setIcon("types/Server_up_16.png"); - - final TreeNode onlyServices = new EnhancedTreeNode(PAGE_SERVICES); - onlyServices.setIcon("types/Service_up_16.png"); - - final TreeNode inventory = new EnhancedTreeNode(SUBSECTION_RESOURCE_INVENTORY, onlyPlatforms, onlyServers, - onlyServices); - - final TreeNode downServers = new EnhancedTreeNode(PAGE_DOWN); - downServers.setIcon("types/Server_down_16.png"); - - final TreeNode savedSearches = new EnhancedTreeNode(SUBSECTION_SAVED_SEARCHES, downServers); - - TreeGrid treeGrid = new LocatableTreeGrid(RESOURCES_SECTION_VIEW_ID); - treeGrid.setShowHeader(false); - Tree tree = new Tree(); - TreeNode rootNode = new TreeNode(RESOURCES_SECTION_VIEW_ID, discoveryQueue, inventory, savedSearches); - tree.setRoot(rootNode); - treeGrid.setData(tree); - - treeGrid.getTree().openAll(); - treeGrids.put(RESOURCES_SECTION_VIEW_ID, treeGrid); - - return treeGrid; + protected Canvas defaultView() { + String contents = "<h1>Inventory</h1>\n" + + "From this section, newly discovered Resources, inventoried Resources, and Groups can be viewed and managed."; + HTMLFlow flow = new HTMLFlow(contents); + flow.setPadding(20); + return flow; }
- private TreeGrid buildGroupsSection(Set<Permission> globalPermissions) { - final TreeNode groupGroupDefinitions = new EnhancedTreeNode(PAGE_GROUP_DEFINITIONS); - groupGroupDefinitions.setEnabled(globalPermissions.contains(Permission.MANAGE_INVENTORY)); - groupGroupDefinitions.setIcon("types/GroupDefinition_16.png"); - - final TreeNode onlyCompatible = new EnhancedTreeNode(PAGE_COMPATIBLE_GROUPS); - onlyCompatible.setIcon("types/Cluster_up_16.png"); - final TreeNode onlyMixed = new EnhancedTreeNode(PAGE_MIXED_GROUPS); - onlyMixed.setIcon("types/Group_up_16.png"); - - final TreeNode inventory = new EnhancedTreeNode(SUBSECTION_GROUP_INVENTORY, onlyCompatible, onlyMixed); - - final TreeNode problemGroups = new EnhancedTreeNode(PAGE_PROBLEM_GROUPS); - problemGroups.setIcon("types/Cluster_down_16.png"); - final TreeNode savedSearches = new EnhancedTreeNode(SUBSECTION_SAVED_SEARCHES, problemGroups); + @Override + protected List<NavigationSection> getNavigationSections() { + List<NavigationSection> sections = new ArrayList<NavigationSection>();
- TreeGrid treeGrid = new LocatableTreeGrid(GROUPS_SECTION_VIEW_ID); - treeGrid.setShowHeader(false); - Tree tree = new Tree(); - TreeNode rootNode = new EnhancedTreeNode(GROUPS_SECTION_VIEW_ID, groupGroupDefinitions, inventory, - savedSearches); - tree.setRoot(rootNode); - treeGrid.setData(tree); + NavigationSection resourcesSection = buildResourcesSection(); + sections.add(resourcesSection);
- treeGrid.getTree().openAll(); - treeGrids.put(GROUPS_SECTION_VIEW_ID, treeGrid); + NavigationSection groupsSection = buildGroupsSection(); + sections.add(groupsSection);
- return treeGrid; + return sections; }
- public void setContent(Canvas newContent) { - for (Canvas child : this.contentCanvas.getChildren()) { - child.destroy(); - } - this.contentCanvas.addChild(newContent); - this.contentCanvas.markForRedraw(); - this.currentContent = newContent; - }
- private void renderContentView(ViewPath viewPath) { - currentSectionViewId = viewPath.getCurrent(); - currentPageViewId = viewPath.getNext(); + private NavigationSection buildResourcesSection() { + NavigationItem autodiscoveryQueueItem = new NavigationItem(PAGE_AUTODISCOVERY_QUEUE, "global/Recent_16.png", + new ViewFactory() { + public Canvas createView() { + return new ResourceAutodiscoveryView(extendLocatorId(PAGE_AUTODISCOVERY_QUEUE)); + } + }, this.globalPermissions.contains(Permission.MANAGE_INVENTORY));
- String sectionName = currentSectionViewId.getPath(); - String pageName = currentPageViewId.getPath(); + // TODO: Specify an icon for this item. + NavigationItem allResourcesItem = new NavigationItem(PAGE_ALL_RESOURCES, null, + new ViewFactory() { + public Canvas createView() { + return new ResourceSearchView(extendLocatorId(PAGE_ALL_RESOURCES), null, PAGE_ALL_RESOURCES, + "types/Platform_up_24.png", "types/Server_up_24.png", "types/Service_up_24.png"); + } + });
- Canvas content = null; - if (RESOURCES_SECTION_VIEW_ID.equals(sectionName)) { - if (PAGE_PLATFORMS.equals(pageName)) { - content = new ResourceSearchView(extendLocatorId("Platforms"), new Criteria( + NavigationItem platformsItem = new NavigationItem(PAGE_PLATFORMS, "types/Platform_up_16.png", + new ViewFactory() { + public Canvas createView() { + return new ResourceSearchView(extendLocatorId(PAGE_PLATFORMS), new Criteria( ResourceDataSourceField.CATEGORY.propertyName(), ResourceCategory.PLATFORM.name()), PAGE_PLATFORMS, "types/Platform_up_24.png"); - } else if (PAGE_SERVERS.equals(pageName)) { - content = new ResourceSearchView(extendLocatorId("Servers"), new Criteria( + } + }); + + NavigationItem serversItem = new NavigationItem(PAGE_SERVERS, "types/Server_up_16.png", + new ViewFactory() { + public Canvas createView() { + return new ResourceSearchView(extendLocatorId(PAGE_SERVERS), new Criteria( ResourceDataSourceField.CATEGORY.propertyName(), ResourceCategory.SERVER.name()), PAGE_SERVERS, "types/Server_up_24.png"); - } else if (PAGE_SERVICES.equals(pageName)) { - content = new ResourceSearchView(extendLocatorId("Services"), new Criteria( + } + }); + + NavigationItem servicesItem = new NavigationItem(PAGE_SERVICES, "types/Service_up_16.png", + new ViewFactory() { + public Canvas createView() { + return new ResourceSearchView(extendLocatorId(PAGE_SERVICES), new Criteria( ResourceDataSourceField.CATEGORY.propertyName(), ResourceCategory.SERVICE.name()), PAGE_SERVICES, "types/Service_up_24.png"); - } else if (PAGE_ADQ.equals(pageName)) { - content = new ResourceAutodiscoveryView(this.extendLocatorId("ADQ")); - } else if (PAGE_DOWN.equals(pageName)) { + } + }); + + NavigationItem downServersItem = new NavigationItem(PAGE_DOWN_SERVERS, "types/Server_down_16.png", + new ViewFactory() { + public Canvas createView() { Criteria criteria = new Criteria(ResourceDataSourceField.AVAILABILITY.propertyName(), AvailabilityType.DOWN.name()); criteria.addCriteria(ResourceDataSourceField.CATEGORY.propertyName(), ResourceCategory.SERVER.name()); - content = new ResourceSearchView(extendLocatorId("DownResources"), criteria, PAGE_DOWN); - } else { // selected the Inventory node itself - content = new ResourceSearchView(extendLocatorId("AllResources"), null, PAGE_RESOURCES, - "types/Platform_up_24.png", "types/Server_up_24.png", "types/Service_up_24.png"); - } - } else if (GROUPS_SECTION_VIEW_ID.equals(sectionName)) { - if (PAGE_COMPATIBLE_GROUPS.equals(pageName)) { - content = new ResourceGroupListView(extendLocatorId("Compatible"), new Criteria( - ResourceGroupDataSourceField.CATEGORY.propertyName(), GroupCategory.COMPATIBLE.name()), - "Compatible Groups", "types/Cluster_up_24.png"); - } else if (PAGE_MIXED_GROUPS.equals(pageName)) { - content = new ResourceGroupListView(extendLocatorId("Mixed"), new Criteria( - ResourceGroupDataSourceField.CATEGORY.propertyName(), GroupCategory.MIXED.name()), "Mixed Groups", - "types/Group_up_24.png"); - } else if (PAGE_GROUP_DEFINITIONS.equals(pageName)) { - content = new GroupDefinitionListView(extendLocatorId("Definitions"), "types/GroupDefinition_16.png"); - } else if (PAGE_PROBLEM_GROUPS.equals(pageName)) { - //TODO - there is no underlying support for this criteria. Also, there should not be an active - // new button on this page. - content = new ResourceGroupListView(extendLocatorId("DownGroups"), - new Criteria("availability", "down"), "Problem Groups", "types/Cluster_down_16.png"); - } else { // selected the Inventory node itself - content = new ResourceGroupListView(extendLocatorId("AllGroups"), null, "All Groups", - "types/Cluster_up_24.png", "types/Group_up_24.png"); + // TODO (ips, 10/28/10): Should we include down platforms too? + return new ResourceSearchView(extendLocatorId(PAGE_DOWN_SERVERS), criteria, "Down Servers"); } - } + });
- // when changing sections make sure the previous section's selection is deselected - selectSectionPageTreeGridNode(sectionName, pageName); + return new NavigationSection(RESOURCES_SECTION_VIEW_ID, autodiscoveryQueueItem, allResourcesItem, platformsItem, + serversItem, servicesItem, downServersItem); + }
- // ignore clicks on subsection folder nodes - if (null != content) { - setContent(content); + private NavigationSection buildGroupsSection() { + NavigationItem dynagroupDefinitionsItem = new NavigationItem(PAGE_DYNAGROUP_DEFINITIONS, "types/GroupDefinition_16.png", + new ViewFactory() { + public Canvas createView() { + // TODO: Do we have a 24x24 groupdef icon? + return new GroupDefinitionListView(extendLocatorId(PAGE_DYNAGROUP_DEFINITIONS), "types/GroupDefinition_16.png"); + } + }, this.globalPermissions.contains(Permission.MANAGE_INVENTORY));
- if (content instanceof BookmarkableView) { - ((BookmarkableView) content).renderView(viewPath.next().next()); + NavigationItem allGroupsItem = new NavigationItem(PAGE_ALL_GROUPS, "types/Group_up_16.png", + new ViewFactory() { + public Canvas createView() { + return new ResourceGroupListView(extendLocatorId(PAGE_ALL_GROUPS), null, "All Groups", + "types/Cluster_up_24.png", "types/Group_up_24.png"); } - } - } + });
- private void selectSectionPageTreeGridNode(String sectionName, String pageName) { - // TODO this method works, however, its getting invoked prior to treeGrids getting populated due to async authz check. need to fix that - for (String name : treeGrids.keySet()) { - TreeGrid treeGrid = treeGrids.get(name); - if (!name.equals(sectionName)) { - treeGrid.deselectAllRecords(); - } else { - boolean gotIt = false; - for (TreeNode node : treeGrid.getTree().getAllNodes()) { - if (node.getName().equals(pageName)) { - treeGrid.selectSingleRecord(node); - gotIt = true; - break; - } - } - if (!gotIt) { - CoreGUI.getErrorHandler().handleError("Unknown page name - URL is incorrect"); - } + NavigationItem compatibleGroupsItem = new NavigationItem(PAGE_COMPATIBLE_GROUPS, "types/Cluster_up_16.png", + new ViewFactory() { + public Canvas createView() { + return new ResourceGroupListView(extendLocatorId(PAGE_COMPATIBLE_GROUPS), new Criteria( + ResourceGroupDataSourceField.CATEGORY.propertyName(), GroupCategory.COMPATIBLE.name()), + "Compatible Groups", "types/Cluster_up_24.png"); } - } - } + });
- public void renderView(ViewPath viewPath) { - if (!viewPath.isCurrent(currentSectionViewId) || !viewPath.isNext(currentPageViewId)) { - if (viewPath.isEnd()) { - // i.e. "Inventory" - // Currently, leave content empty until the user selects something from section stack. To default - // to platform list uncomment following line. - // History.newItem("Inventory/Resources/Platforms", true); - } else { - // e.g. Inventory/Administration" - renderContentView(viewPath); + NavigationItem mixedGroupsItem = new NavigationItem(PAGE_MIXED_GROUPS, "types/Group_up_16.png", + new ViewFactory() { + public Canvas createView() { + return new ResourceGroupListView(extendLocatorId(PAGE_MIXED_GROUPS), new Criteria( + ResourceGroupDataSourceField.CATEGORY.propertyName(), GroupCategory.MIXED.name()), "Mixed Groups", + "types/Group_up_24.png"); } - } else { - if (this.currentContent instanceof BookmarkableView) { - ((BookmarkableView) this.currentContent).renderView(viewPath.next().next()); + }); + + NavigationItem problemGroupsItem = new NavigationItem(PAGE_PROBLEM_GROUPS, "types/Cluster_down_16.png", + new ViewFactory() { + public Canvas createView() { + // TODO: There is no underlying support for this criteria. Also, there should not be an active New + // button on this page. + return new ResourceGroupListView(extendLocatorId(PAGE_PROBLEM_GROUPS), + new Criteria("availability", "down"), "Problem Groups", "types/Cluster_down_16.png"); } - } + }); + + return new NavigationSection(GROUPS_SECTION_VIEW_ID, dynagroupDefinitionsItem, allGroupsItem, + compatibleGroupsItem, mixedGroupsItem, problemGroupsItem); } } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionListView.java index f7c37ee..ea2eb8c 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionListView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionListView.java @@ -45,9 +45,10 @@ import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity; * @author Joseph Marques */ public class GroupDefinitionListView extends TableSection { + private static final String TITLE = "Dynagroup Definitions";
public GroupDefinitionListView(String locatorId, String headerIcon) { - super(locatorId, "Dynamic Group Definitions"); + super(locatorId, TITLE);
setHeaderIcon(headerIcon);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java index 70126e3..0b954fc 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java @@ -59,12 +59,13 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout; * @author Greg Hinkle */ public class ResourceAutodiscoveryView extends LocatableVLayout { + private static final String TITLE = "Autodiscovery Queue"; + private static final String HEADER_ICON = "global/Recent_16.png";
- private boolean simple = false; + private boolean simple; private TreeGrid treeGrid; private ToolStrip footer; - private DataSource dataSource = null; - private String headerIcon = "global/Recent_16.png"; + private DataSource dataSource;
private ResourceGWTServiceAsync resourceService = GWTServiceLookup.getResourceService();
@@ -85,13 +86,13 @@ public class ResourceAutodiscoveryView extends LocatableVLayout { super.onInit();
if (!simple) { - Img img = new Img(headerIcon, 24, 24); + Img img = new Img(HEADER_ICON, 24, 24); img.setPadding(4);
HTMLFlow title = new HTMLFlow(); title.setWidth100(); title.setHeight(35); - title.setContents("Discovery Manager"); + title.setContents(TITLE); title.setPadding(4); title.setStyleName("HeaderLabel");
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java index d5cd465..6828ef8 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java @@ -41,7 +41,10 @@ import org.rhq.enterprise.gui.coregui.client.report.measurement.MeasurementOOBVi import org.rhq.enterprise.gui.coregui.client.report.tag.TaggedView;
/** + * The Reports top-level view. + * * @author Greg Hinkle + * @author Ian Springer */ public class ReportTopView extends AbstractSectionedLeftNavigationView { public static final String VIEW_ID = "Reports"; @@ -49,8 +52,9 @@ public class ReportTopView extends AbstractSectionedLeftNavigationView { private static final String SUBSYSTEMS_SECTION_VIEW_ID = "Subsystems"; private static final String INVENTORY_SECTION_VIEW_ID = "Inventory";
- public ReportTopView(String locatorId) { - super(locatorId, VIEW_ID); + public ReportTopView() { + // This is a top level view, so our locator id can simply be our view id. + super(VIEW_ID); }
@Override diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestConfigurationFactory.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestConfigurationFactory.java deleted file mode 100644 index 89d7d53..0000000 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestConfigurationFactory.java +++ /dev/null @@ -1,311 +0,0 @@ -/* - * RHQ Management Platform - * Copyright 2010, Red Hat Middleware LLC, and individual contributors - * as indicated by the @author tags. See the copyright.txt file in the - * distribution for a full listing of individual contributors. - * - * 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.test; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; - -import org.rhq.core.domain.configuration.Configuration; -import org.rhq.core.domain.configuration.PropertyList; -import org.rhq.core.domain.configuration.PropertyMap; -import org.rhq.core.domain.configuration.PropertySimple; -import org.rhq.core.domain.configuration.definition.ConfigurationDefinition; -import org.rhq.core.domain.configuration.definition.ConfigurationTemplate; -import org.rhq.core.domain.configuration.definition.PropertyDefinition; -import org.rhq.core.domain.configuration.definition.PropertyDefinitionEnumeration; -import org.rhq.core.domain.configuration.definition.PropertyDefinitionList; -import org.rhq.core.domain.configuration.definition.PropertyDefinitionMap; -import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple; -import org.rhq.core.domain.configuration.definition.PropertyGroupDefinition; -import org.rhq.core.domain.configuration.definition.PropertySimpleType; - -/** - * A utility class that provides methods for creating a test {@link ConfigurationDefinition} and a - * {@link Configuration} that conforms to that definition. - * - * @author Ian Springer - */ -public abstract class TestConfigurationFactory { - public static ConfigurationDefinition createConfigurationDefinition() { - ConfigurationDefinition configDef = new ConfigurationDefinition("TestConfig", "a test config"); - - ConfigurationTemplate defaultTemplate = new ConfigurationTemplate(ConfigurationTemplate.DEFAULT_TEMPLATE_NAME, "default template"); - configDef.putTemplate(defaultTemplate); - Configuration defaultConfiguration = new Configuration(); - defaultTemplate.setConfiguration(defaultConfiguration); - - Map<String, PropertyDefinition> propertyDefinitions = new HashMap<String, PropertyDefinition>(); - configDef.setPropertyDefinitions(propertyDefinitions); - - int orderIndex = 0; - - PropertyDefinitionSimple simplePropDef; - - simplePropDef = createStringPropDef1(); - addPropertyDefinition(configDef, simplePropDef, orderIndex++); - - simplePropDef = createStringPropDef2(); - addPropertyDefinition(configDef, simplePropDef, orderIndex++); - - simplePropDef = new PropertyDefinitionSimple("LongString", "a Long String simple prop", false, - PropertySimpleType.LONG_STRING); - simplePropDef.setDisplayName(simplePropDef.getName()); - addPropertyDefinition(configDef, simplePropDef, orderIndex++); - - simplePropDef = new PropertyDefinitionSimple("Password", "a Password simple prop", false, - PropertySimpleType.PASSWORD); - simplePropDef.setDisplayName(simplePropDef.getName()); - addPropertyDefinition(configDef, simplePropDef, orderIndex++); - - simplePropDef = new PropertyDefinitionSimple("Boolean", "a required Boolean simple prop", true, - PropertySimpleType.BOOLEAN); - simplePropDef.setDisplayName(simplePropDef.getName()); - addPropertyDefinition(configDef, simplePropDef, orderIndex++); - simplePropDef.setRequired(true); - - simplePropDef = createIntegerPropDef(); - addPropertyDefinition(configDef, simplePropDef, orderIndex++); - - simplePropDef = new PropertyDefinitionSimple("Float", "a Float simple prop", false, PropertySimpleType.FLOAT); - simplePropDef.setDisplayName(simplePropDef.getName()); - addPropertyDefinition(configDef, simplePropDef, orderIndex++); - - simplePropDef = new PropertyDefinitionSimple("StringEnum1", - "a String enum prop with <=5 items - should be rendered as radio buttons", false, - PropertySimpleType.STRING); - simplePropDef.setDisplayName(simplePropDef.getName()); - defaultConfiguration.put(new PropertySimple("StringEnum1", "NJ")); - ArrayList<PropertyDefinitionEnumeration> propDefEnums = new ArrayList<PropertyDefinitionEnumeration>(); - propDefEnums.add(new PropertyDefinitionEnumeration("NY", "NY")); - propDefEnums.add(new PropertyDefinitionEnumeration("NJ", "NJ")); - propDefEnums.add(new PropertyDefinitionEnumeration("PA", "PA")); - simplePropDef.setEnumeratedValues(propDefEnums, false); - addPropertyDefinition(configDef, simplePropDef, orderIndex++); - - simplePropDef = new PropertyDefinitionSimple("StringEnum2", - "a String enum prop with >5 items - should be rendered as a popup menu", false, PropertySimpleType.STRING); - simplePropDef.setDisplayName(simplePropDef.getName()); - defaultConfiguration.put(new PropertySimple("StringEnum2", "blue")); - propDefEnums = new ArrayList<PropertyDefinitionEnumeration>(); - propDefEnums.add(new PropertyDefinitionEnumeration("red", "red")); - propDefEnums.add(new PropertyDefinitionEnumeration("orange", "orange")); - propDefEnums.add(new PropertyDefinitionEnumeration("yellow", "yellow")); - propDefEnums.add(new PropertyDefinitionEnumeration("green", "green")); - propDefEnums.add(new PropertyDefinitionEnumeration("blue", "blue")); - propDefEnums.add(new PropertyDefinitionEnumeration("purple", "purple")); - simplePropDef.setEnumeratedValues(propDefEnums, false); - addPropertyDefinition(configDef, simplePropDef, orderIndex++); - - PropertyDefinitionMap mapPropDef = new PropertyDefinitionMap("MapOfSimples", "a map of simples", false); - mapPropDef.put(createStringPropDef1()); - mapPropDef.put(createStringPropDef2()); - mapPropDef.put(createIntegerPropDef()); - mapPropDef.setDisplayName(mapPropDef.getName()); - addPropertyDefinition(configDef, mapPropDef, orderIndex++); - - PropertyDefinitionMap openMapPropDef = new PropertyDefinitionMap("OpenMapOfSimples", "an open map of simples", - false); - openMapPropDef.setDisplayName(openMapPropDef.getName()); - addPropertyDefinition(configDef, openMapPropDef, orderIndex++); - - PropertyDefinitionMap readOnlyOpenMapPropDef = new PropertyDefinitionMap("ReadOnlyOpenMapOfSimples", - "a read-only open map of simples", false); - readOnlyOpenMapPropDef.setDisplayName(readOnlyOpenMapPropDef.getName()); - readOnlyOpenMapPropDef.setReadOnly(true); - addPropertyDefinition(configDef, readOnlyOpenMapPropDef, orderIndex++); - - PropertyDefinitionList listOfSimplesPropDef = new PropertyDefinitionList("ListOfSimples", - "a list of Integer simples", true, new PropertyDefinitionSimple("integer", "an integer", false, - PropertySimpleType.INTEGER)); - listOfSimplesPropDef.setDisplayName(listOfSimplesPropDef.getName()); - addPropertyDefinition(configDef, listOfSimplesPropDef, orderIndex++); - - PropertyDefinitionMap mapInListPropDef = - new PropertyDefinitionMap("MapOfSimplesInList", "a map of simples in a list", false); - mapInListPropDef.put(createStringPropDef1()); - mapInListPropDef.put(createStringPropDef2()); - mapInListPropDef.put(createIntegerPropDef()); - mapInListPropDef.setDisplayName(mapInListPropDef.getName()); - - PropertyDefinitionList listPropDef = new PropertyDefinitionList("ListOfMaps", "a list of maps", true, - mapInListPropDef); - listPropDef.setDisplayName(listPropDef.getName()); - addPropertyDefinition(configDef, listPropDef, orderIndex++); - - PropertyDefinitionMap mapInReadOnlyListPropDef = - new PropertyDefinitionMap("MapOfSimplesInReadOnlyList", "a map of simples in a list", false); - mapInReadOnlyListPropDef.put(createStringPropDef1()); - mapInReadOnlyListPropDef.put(createStringPropDef2()); - mapInReadOnlyListPropDef.put(createIntegerPropDef()); - mapInReadOnlyListPropDef.setDisplayName(mapInReadOnlyListPropDef.getName()); - - PropertyDefinitionList readOnlyListPropDef = new PropertyDefinitionList("ReadOnlyListOfMaps", - "a read-only list of maps", true, mapInReadOnlyListPropDef); - readOnlyListPropDef.setDisplayName(readOnlyListPropDef.getName()); - readOnlyListPropDef.setReadOnly(true); - addPropertyDefinition(configDef, readOnlyListPropDef, orderIndex++); - - PropertyGroupDefinition propertyGroupDefinition = new PropertyGroupDefinition("myGroup"); - propertyGroupDefinition.setDisplayName(propertyGroupDefinition.getName()); - propertyGroupDefinition.setDescription("this is an example group"); - - PropertyDefinitionSimple myString = new PropertyDefinitionSimple("myString1", "my little string", true, - PropertySimpleType.STRING); - myString.setDisplayName(myString.getName()); - myString.setSummary(true); - addPropertyDefinition(configDef, myString, orderIndex++); - myString.setPropertyGroupDefinition(propertyGroupDefinition); - - PropertyDefinitionSimple myString2 = new PropertyDefinitionSimple("myString2", "my other little string", true, - PropertySimpleType.STRING); - myString2.setDisplayName(myString2.getName()); - myString2.setSummary(true); - addPropertyDefinition(configDef, myString2, orderIndex++); - myString2.setPropertyGroupDefinition(propertyGroupDefinition); - - PropertyGroupDefinition propertyGroupDefinition2 = new PropertyGroupDefinition("myGroup2"); - propertyGroupDefinition2.setDisplayName(propertyGroupDefinition2.getName()); - propertyGroupDefinition2.setDescription("this is another example group"); - - PropertyDefinitionSimple myString3 = new PropertyDefinitionSimple("myString3", "my third string", true, - PropertySimpleType.STRING); - myString3.setDisplayName((myString3.getName())); - myString3.setSummary(true); - addPropertyDefinition(configDef, myString3, orderIndex++); - myString3.setPropertyGroupDefinition(propertyGroupDefinition2); - - PropertyDefinitionSimple enumExample = new PropertyDefinitionSimple("myEnum", - "a grouped enum prop with <=5 items", false, PropertySimpleType.STRING); - enumExample.setDisplayName(enumExample.getName()); - defaultConfiguration.put(new PropertySimple("myEnum", "Burlington")); - ArrayList<PropertyDefinitionEnumeration> myEnums = new ArrayList<PropertyDefinitionEnumeration>(); - myEnums.add(new PropertyDefinitionEnumeration("Burlington", "Burlington")); - myEnums.add(new PropertyDefinitionEnumeration("Camden", "Camden")); - myEnums.add(new PropertyDefinitionEnumeration("Gloucester", "Gloucester")); - enumExample.setEnumeratedValues(myEnums, false); - addPropertyDefinition(configDef, enumExample, orderIndex++); - enumExample.setPropertyGroupDefinition(propertyGroupDefinition2); - - return configDef; - } - - private static void addPropertyDefinition(ConfigurationDefinition configDef, - PropertyDefinition propDef, int orderIndex) { - propDef.setOrder(orderIndex); - configDef.put(propDef); - } - - public static Configuration createConfiguration() { - Configuration configuration = new Configuration(); - configuration.setNotes("a test config"); - configuration.setVersion(1); - - configuration.put(new PropertySimple("String1", "blah")); - configuration.put(new PropertySimple("String2", - "a really, really, really, really, really long value that won't fit in the text input box")); - configuration.put(new PropertySimple("LongString", "blah blah blah\nblah blah blah")); - configuration.put(new PropertySimple("Password", null)); - configuration.put(new PropertySimple("Boolean", false)); - configuration.put(new PropertySimple("Integer", 666)); - configuration.put(new PropertySimple("Float", Math.PI)); - - configuration.put(new PropertySimple("StringEnum1", "PA")); - configuration.put(new PropertySimple("StringEnum2", "blue")); - - PropertyMap propMap1 = new PropertyMap("MapOfSimples"); - propMap1.put(new PropertySimple("String1", "One")); - propMap1.put(new PropertySimple("String2", "Two")); - propMap1.put(new PropertySimple("Integer", 11)); - configuration.put(propMap1); - - PropertyMap openPropMap1 = new PropertyMap("OpenMapOfSimples"); - openPropMap1.put(new PropertySimple("PROCESSOR_ARCHITECTURE", "x86")); - openPropMap1.put(new PropertySimple("PROCESSOR_IDENTIFIER", "x86 Family 6 Model 15 Stepping 6, GenuineIntel")); - openPropMap1.put(new PropertySimple("PROCESSOR_LEVEL", "6")); - openPropMap1.put(new PropertySimple("PROCESSOR_REVISION", "0f06")); - configuration.put(openPropMap1); - - PropertyMap openPropMap2 = new PropertyMap("ReadOnlyOpenMapOfSimples"); - openPropMap2.put(new PropertySimple("ANT_HOME", "C:\opt\ant-1.6.5")); - openPropMap2.put(new PropertySimple("ANT_OPTS", "-Xms128M -Xmx256M")); - configuration.put(openPropMap2); - - configuration.put(new PropertyList("ListOfSimples", new PropertySimple("integer", "18"), new PropertySimple( - "integer", "127"), new PropertySimple("integer", "311"), new PropertySimple("integer", "2"), new PropertySimple( - "integer", "301"), new PropertySimple("integer", "79"), new PropertySimple("integer", "62"))); - - PropertyMap propMap2 = new PropertyMap("MapOfSimplesInList"); - propMap2.put(new PropertySimple("String1", "Uno")); - propMap2.put(new PropertySimple("String2", "Dos")); - propMap2.put(new PropertySimple("Integer", Integer.MIN_VALUE)); - PropertyMap propMap3 = new PropertyMap("MapOfSimplesInList"); - propMap3.put(new PropertySimple("String1", "Un")); - propMap3.put(new PropertySimple("String2", "Deux")); - propMap3.put(new PropertySimple("Integer", Integer.MAX_VALUE)); - configuration.put(new PropertyList("ListOfMaps", propMap2, propMap3)); - - PropertyMap propMap4 = new PropertyMap("MapOfSimplesInReadOnlyList"); - propMap4.put(new PropertySimple("String1", "A")); - propMap4.put(new PropertySimple("String2", "B")); - propMap4.put(new PropertySimple("Integer", 999)); - PropertyMap propMap5 = new PropertyMap("MapOfSimplesInReadOnlyList"); - propMap5.put(new PropertySimple("String1", "a")); - propMap5.put(new PropertySimple("String2", "b")); - propMap5.put(new PropertySimple("Integer", 0)); - configuration.put(new PropertyList("ReadOnlyListOfMaps", propMap4, propMap5)); - - configuration.put(new PropertySimple("myString1", "grouped String 1")); - configuration.put(new PropertySimple("myString2", "grouped String 2")); - configuration.put(new PropertySimple("myString3", "strings are cool")); - configuration.put(new PropertySimple("myEnum", "Burlington")); - - return configuration; - } - - private static PropertyDefinitionSimple createStringPropDef1() { - PropertyDefinitionSimple stringPropDef1; - stringPropDef1 = new PropertyDefinitionSimple("String1", - "an optional String simple prop", false, PropertySimpleType.STRING); - stringPropDef1.setDisplayName(stringPropDef1.getName()); - return stringPropDef1; - } - - private static PropertyDefinitionSimple createStringPropDef2() { - PropertyDefinitionSimple stringPropDef2; - stringPropDef2 = new PropertyDefinitionSimple("String2", - "a read-only String simple prop", false, PropertySimpleType.STRING); - stringPropDef2.setDisplayName(stringPropDef2.getName()); - stringPropDef2.setReadOnly(true); - return stringPropDef2; - } - - private static PropertyDefinitionSimple createIntegerPropDef() { - PropertyDefinitionSimple integerPropDef; - integerPropDef = new PropertyDefinitionSimple("Integer", - "a required summary Integer simple prop", true, PropertySimpleType.INTEGER); - integerPropDef.setDisplayName(integerPropDef.getName()); - integerPropDef.setSummary(true); - return integerPropDef; - } - - private TestConfigurationFactory() { - } -} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestConfigurationView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestConfigurationView.java deleted file mode 100644 index 9d94650..0000000 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestConfigurationView.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * RHQ Management Platform - * Copyright 2010, Red Hat Middleware LLC, and individual contributors - * as indicated by the @author tags. See the copyright.txt file in the - * distribution for a full listing of individual contributors. - * - * 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.test; - -import java.util.EnumSet; -import java.util.Set; - -import com.smartgwt.client.types.Overflow; -import com.smartgwt.client.widgets.events.ClickEvent; -import com.smartgwt.client.widgets.events.ClickHandler; -import com.smartgwt.client.widgets.layout.LayoutSpacer; -import com.smartgwt.client.widgets.toolbar.ToolStrip; - -import org.rhq.core.domain.configuration.Configuration; -import org.rhq.core.domain.configuration.definition.ConfigurationDefinition; -import org.rhq.enterprise.gui.coregui.client.CoreGUI; -import org.rhq.enterprise.gui.coregui.client.components.configuration.ConfigurationEditor; -import org.rhq.enterprise.gui.coregui.client.components.configuration.PropertyValueChangeEvent; -import org.rhq.enterprise.gui.coregui.client.components.configuration.PropertyValueChangeListener; -import org.rhq.enterprise.gui.coregui.client.util.message.Message; -import org.rhq.enterprise.gui.coregui.client.util.message.MessageCenter; -import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIButton; -import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout; - -/** - * @author Ian Springer - */ -public class TestConfigurationView - extends LocatableVLayout implements PropertyValueChangeListener { - public static final String VIEW_ID = "TestConfig"; - - private ConfigurationEditor editor; - private LocatableIButton saveButton; - private ConfigurationDefinition configurationDefinition; - private Configuration configuration; - - public TestConfigurationView(String locatorId) { - super(locatorId); - } - - @Override - protected void onDraw() { - super.onDraw(); - build(); - } - - public void build() { - setWidth100(); - setHeight100(); - - ToolStrip toolStrip = new ToolStrip(); - toolStrip.setWidth100(); - - toolStrip.addMember(new LayoutSpacer()); - - this.saveButton = new LocatableIButton(this.extendLocatorId("Save"), "Save"); - this.saveButton.addClickHandler(new ClickHandler() { - public void onClick(ClickEvent clickEvent) { - save(); - } - }); - this.saveButton.disable(); - toolStrip.addMember(this.saveButton); - - addMember(toolStrip); - - this.configurationDefinition = TestConfigurationFactory.createConfigurationDefinition(); - this.configuration = TestConfigurationFactory.createConfiguration(); - - reloadConfiguration(); - } - - @Override - public void propertyValueChanged(PropertyValueChangeEvent event) { - MessageCenter messageCenter = CoreGUI.getMessageCenter(); - Message message; - if (event.isValidationStateChanged()) { - Set<String> invalidPropertyNames = event.getInvalidPropertyNames(); - if (invalidPropertyNames.isEmpty()) { - this.saveButton.enable(); - message = new Message("All properties now have valid values, so the configuration can now be saved.", - Message.Severity.Info, EnumSet.of(Message.Option.Transient, Message.Option.Sticky)); - } - else { - this.saveButton.disable(); - message = new Message( - "The following properties have invalid values: " + invalidPropertyNames - + " - the values must be corrected before the configuration can be saved.", - Message.Severity.Error, EnumSet.of(Message.Option.Transient, Message.Option.Sticky)); - } - messageCenter.notify(message); - } - else { - this.saveButton.enable(); - } - } - - private void reloadConfiguration() { - this.saveButton.disable(); - if (editor != null) { - editor.destroy(); - removeMember(editor); - } - - editor = new ConfigurationEditor(extendLocatorId("Editor"), this.configurationDefinition, this.configuration); - editor.setOverflow(Overflow.AUTO); - editor.addPropertyValueChangeListener(this); - addMember(editor); - } - - private void save() { - CoreGUI.getMessageCenter().notify( - new Message("Configuration updated.", "Test configuration updated.")); - reloadConfiguration(); - } -} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestGroupConfigurationView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestGroupConfigurationView.java deleted file mode 100644 index f54bb01..0000000 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestGroupConfigurationView.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * RHQ Management Platform - * Copyright 2010, Red Hat Middleware LLC, and individual contributors - * as indicated by the @author tags. See the copyright.txt file in the - * distribution for a full listing of individual contributors. - * - * 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.test; - -import java.util.ArrayList; -import java.util.EnumSet; -import java.util.List; -import java.util.Set; - -import com.smartgwt.client.types.Overflow; -import com.smartgwt.client.widgets.events.ClickEvent; -import com.smartgwt.client.widgets.events.ClickHandler; -import com.smartgwt.client.widgets.layout.LayoutSpacer; -import com.smartgwt.client.widgets.toolbar.ToolStrip; - -import org.rhq.core.domain.configuration.Configuration; -import org.rhq.core.domain.configuration.definition.ConfigurationDefinition; -import org.rhq.enterprise.gui.coregui.client.CoreGUI; -import org.rhq.enterprise.gui.coregui.client.components.configuration.ConfigurationEditor; -import org.rhq.enterprise.gui.coregui.client.components.configuration.GroupConfigurationEditor; -import org.rhq.enterprise.gui.coregui.client.components.configuration.GroupMemberConfiguration; -import org.rhq.enterprise.gui.coregui.client.components.configuration.PropertyValueChangeEvent; -import org.rhq.enterprise.gui.coregui.client.components.configuration.PropertyValueChangeListener; -import org.rhq.enterprise.gui.coregui.client.util.message.Message; -import org.rhq.enterprise.gui.coregui.client.util.message.MessageCenter; -import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIButton; -import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout; - -/** - * @author Ian Springer - */ -public class TestGroupConfigurationView - extends LocatableVLayout implements PropertyValueChangeListener { - public static final String VIEW_ID = "TestGroupConfig"; - - private static final int GROUP_SIZE = 2; - - private ConfigurationEditor editor; - private LocatableIButton saveButton; - private ConfigurationDefinition configurationDefinition; - private List<GroupMemberConfiguration> memberConfigurations; - - public TestGroupConfigurationView(String locatorId) { - super(locatorId); - } - - @Override - protected void onDraw() { - super.onDraw(); - - setWidth100(); - setHeight100(); - - ToolStrip toolStrip = new ToolStrip(); - toolStrip.setWidth100(); - - toolStrip.addMember(new LayoutSpacer()); - - this.saveButton = new LocatableIButton(this.extendLocatorId("Save"), "Save"); - this.saveButton.addClickHandler(new ClickHandler() { - public void onClick(ClickEvent clickEvent) { - save(); - } - }); - this.saveButton.disable(); - toolStrip.addMember(this.saveButton); - - addMember(toolStrip); - - this.configurationDefinition = TestConfigurationFactory.createConfigurationDefinition(); - this.memberConfigurations = new ArrayList<GroupMemberConfiguration>(GROUP_SIZE); - for (int i = 0; i < GROUP_SIZE; i++) { - Configuration configuration = TestConfigurationFactory.createConfiguration(); - GroupMemberConfiguration memberConfiguration = new GroupMemberConfiguration(i, "Member #" + i, - configuration); - this.memberConfigurations.add(memberConfiguration); - } - - reloadConfiguration(); - } - - @Override - public void propertyValueChanged(PropertyValueChangeEvent event) { - MessageCenter messageCenter = CoreGUI.getMessageCenter(); - Message message; - if (event.isValidationStateChanged()) { - Set<String> invalidPropertyNames = event.getInvalidPropertyNames(); - if (invalidPropertyNames.isEmpty()) { - this.saveButton.enable(); - message = new Message("All properties now have valid values, so the configuration can now be saved.", - Message.Severity.Info, EnumSet.of(Message.Option.Transient, Message.Option.Sticky)); - } - else { - this.saveButton.disable(); - message = new Message( - "The following properties have invalid values: " + invalidPropertyNames - + " - the values must be corrected before the configuration can be saved.", - Message.Severity.Error, EnumSet.of(Message.Option.Transient, Message.Option.Sticky)); - } - messageCenter.notify(message); - } else { - this.saveButton.enable(); - } - } - - private void reloadConfiguration() { - this.saveButton.disable(); - if (editor != null) { - editor.destroy(); - removeMember(editor); - } - - editor = new GroupConfigurationEditor(extendLocatorId("Editor"), this.configurationDefinition, - this.memberConfigurations); - editor.setOverflow(Overflow.AUTO); - editor.addPropertyValueChangeListener(this); - addMember(editor); - } - - private void save() { - CoreGUI.getMessageCenter().notify( - new Message("Member configurations updated.", "Member configurations updated.")); - reloadConfiguration(); - } -} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestTopView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestTopView.java new file mode 100644 index 0000000..fa345bf --- /dev/null +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestTopView.java @@ -0,0 +1,90 @@ +/* + * 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.test; + +import java.util.ArrayList; +import java.util.List; + +import com.smartgwt.client.widgets.Canvas; +import com.smartgwt.client.widgets.HTMLFlow; + +import org.rhq.enterprise.gui.coregui.client.components.view.AbstractSectionedLeftNavigationView; +import org.rhq.enterprise.gui.coregui.client.components.view.NavigationItem; +import org.rhq.enterprise.gui.coregui.client.components.view.NavigationSection; +import org.rhq.enterprise.gui.coregui.client.components.view.ViewFactory; +import org.rhq.enterprise.gui.coregui.client.test.configuration.TestConfigurationView; +import org.rhq.enterprise.gui.coregui.client.test.configuration.TestGroupConfigurationView; + +/** + * The Test top-level view. This view is "hidden", i.e. there are no links to it, so the user must go to the URL + * directly using their browser. + * + * @author Ian Springer + */ +public class TestTopView extends AbstractSectionedLeftNavigationView { + public static final String VIEW_ID = "Test"; + + // view IDs for Configuration section + private static final String CONFIGURATION_SECTION_VIEW_ID = "Configuration"; + + private static final String PAGE_CONFIG_EDITOR = "ConfigEditor"; + private static final String PAGE_GROUP_CONFIG_EDITOR = "GroupConfigEditor"; + + public TestTopView() { + // This is a top level view, so our locator id can simply be our view id. + super(VIEW_ID); + } + + protected Canvas defaultView() { + String contents = "<h1>Test</h1>\n" + + "This section contains pages for testing various GUI components."; + HTMLFlow flow = new HTMLFlow(contents); + flow.setPadding(20); + return flow; + } + + @Override + protected List<NavigationSection> getNavigationSections() { + List<NavigationSection> sections = new ArrayList<NavigationSection>(); + + NavigationSection configurationSection = buildConfigurationSection(); + sections.add(configurationSection); + + return sections; + } + + + private NavigationSection buildConfigurationSection() { + NavigationItem configEditorItem = new NavigationItem(PAGE_CONFIG_EDITOR, null, + new ViewFactory() { + public Canvas createView() { + return new TestConfigurationView(extendLocatorId(PAGE_CONFIG_EDITOR)); + } + }); + + NavigationItem groupConfigEditorItem = new NavigationItem(PAGE_GROUP_CONFIG_EDITOR, null, + new ViewFactory() { + public Canvas createView() { + return new TestGroupConfigurationView(extendLocatorId(PAGE_GROUP_CONFIG_EDITOR)); + } + }); + + return new NavigationSection(CONFIGURATION_SECTION_VIEW_ID, configEditorItem, groupConfigEditorItem); + } +} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestConfigurationFactory.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestConfigurationFactory.java new file mode 100644 index 0000000..e786a36 --- /dev/null +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestConfigurationFactory.java @@ -0,0 +1,311 @@ +/* + * RHQ Management Platform + * Copyright 2010, Red Hat Middleware LLC, and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * 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.test.configuration; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; + +import org.rhq.core.domain.configuration.Configuration; +import org.rhq.core.domain.configuration.PropertyList; +import org.rhq.core.domain.configuration.PropertyMap; +import org.rhq.core.domain.configuration.PropertySimple; +import org.rhq.core.domain.configuration.definition.ConfigurationDefinition; +import org.rhq.core.domain.configuration.definition.ConfigurationTemplate; +import org.rhq.core.domain.configuration.definition.PropertyDefinition; +import org.rhq.core.domain.configuration.definition.PropertyDefinitionEnumeration; +import org.rhq.core.domain.configuration.definition.PropertyDefinitionList; +import org.rhq.core.domain.configuration.definition.PropertyDefinitionMap; +import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple; +import org.rhq.core.domain.configuration.definition.PropertyGroupDefinition; +import org.rhq.core.domain.configuration.definition.PropertySimpleType; + +/** + * A utility class that provides methods for creating a test {@link ConfigurationDefinition} and a + * {@link Configuration} that conforms to that definition. + * + * @author Ian Springer + */ +public abstract class TestConfigurationFactory { + public static ConfigurationDefinition createConfigurationDefinition() { + ConfigurationDefinition configDef = new ConfigurationDefinition("TestConfig", "a test config"); + + ConfigurationTemplate defaultTemplate = new ConfigurationTemplate(ConfigurationTemplate.DEFAULT_TEMPLATE_NAME, "default template"); + configDef.putTemplate(defaultTemplate); + Configuration defaultConfiguration = new Configuration(); + defaultTemplate.setConfiguration(defaultConfiguration); + + Map<String, PropertyDefinition> propertyDefinitions = new HashMap<String, PropertyDefinition>(); + configDef.setPropertyDefinitions(propertyDefinitions); + + int orderIndex = 0; + + PropertyDefinitionSimple simplePropDef; + + simplePropDef = createStringPropDef1(); + addPropertyDefinition(configDef, simplePropDef, orderIndex++); + + simplePropDef = createStringPropDef2(); + addPropertyDefinition(configDef, simplePropDef, orderIndex++); + + simplePropDef = new PropertyDefinitionSimple("LongString", "a Long String simple prop", false, + PropertySimpleType.LONG_STRING); + simplePropDef.setDisplayName(simplePropDef.getName()); + addPropertyDefinition(configDef, simplePropDef, orderIndex++); + + simplePropDef = new PropertyDefinitionSimple("Password", "a Password simple prop", false, + PropertySimpleType.PASSWORD); + simplePropDef.setDisplayName(simplePropDef.getName()); + addPropertyDefinition(configDef, simplePropDef, orderIndex++); + + simplePropDef = new PropertyDefinitionSimple("Boolean", "a required Boolean simple prop", true, + PropertySimpleType.BOOLEAN); + simplePropDef.setDisplayName(simplePropDef.getName()); + addPropertyDefinition(configDef, simplePropDef, orderIndex++); + simplePropDef.setRequired(true); + + simplePropDef = createIntegerPropDef(); + addPropertyDefinition(configDef, simplePropDef, orderIndex++); + + simplePropDef = new PropertyDefinitionSimple("Float", "a Float simple prop", false, PropertySimpleType.FLOAT); + simplePropDef.setDisplayName(simplePropDef.getName()); + addPropertyDefinition(configDef, simplePropDef, orderIndex++); + + simplePropDef = new PropertyDefinitionSimple("StringEnum1", + "a String enum prop with <=5 items - should be rendered as radio buttons", false, + PropertySimpleType.STRING); + simplePropDef.setDisplayName(simplePropDef.getName()); + defaultConfiguration.put(new PropertySimple("StringEnum1", "NJ")); + ArrayList<PropertyDefinitionEnumeration> propDefEnums = new ArrayList<PropertyDefinitionEnumeration>(); + propDefEnums.add(new PropertyDefinitionEnumeration("NY", "NY")); + propDefEnums.add(new PropertyDefinitionEnumeration("NJ", "NJ")); + propDefEnums.add(new PropertyDefinitionEnumeration("PA", "PA")); + simplePropDef.setEnumeratedValues(propDefEnums, false); + addPropertyDefinition(configDef, simplePropDef, orderIndex++); + + simplePropDef = new PropertyDefinitionSimple("StringEnum2", + "a String enum prop with >5 items - should be rendered as a popup menu", false, PropertySimpleType.STRING); + simplePropDef.setDisplayName(simplePropDef.getName()); + defaultConfiguration.put(new PropertySimple("StringEnum2", "blue")); + propDefEnums = new ArrayList<PropertyDefinitionEnumeration>(); + propDefEnums.add(new PropertyDefinitionEnumeration("red", "red")); + propDefEnums.add(new PropertyDefinitionEnumeration("orange", "orange")); + propDefEnums.add(new PropertyDefinitionEnumeration("yellow", "yellow")); + propDefEnums.add(new PropertyDefinitionEnumeration("green", "green")); + propDefEnums.add(new PropertyDefinitionEnumeration("blue", "blue")); + propDefEnums.add(new PropertyDefinitionEnumeration("purple", "purple")); + simplePropDef.setEnumeratedValues(propDefEnums, false); + addPropertyDefinition(configDef, simplePropDef, orderIndex++); + + PropertyDefinitionMap mapPropDef = new PropertyDefinitionMap("MapOfSimples", "a map of simples", false); + mapPropDef.put(createStringPropDef1()); + mapPropDef.put(createStringPropDef2()); + mapPropDef.put(createIntegerPropDef()); + mapPropDef.setDisplayName(mapPropDef.getName()); + addPropertyDefinition(configDef, mapPropDef, orderIndex++); + + PropertyDefinitionMap openMapPropDef = new PropertyDefinitionMap("OpenMapOfSimples", "an open map of simples", + false); + openMapPropDef.setDisplayName(openMapPropDef.getName()); + addPropertyDefinition(configDef, openMapPropDef, orderIndex++); + + PropertyDefinitionMap readOnlyOpenMapPropDef = new PropertyDefinitionMap("ReadOnlyOpenMapOfSimples", + "a read-only open map of simples", false); + readOnlyOpenMapPropDef.setDisplayName(readOnlyOpenMapPropDef.getName()); + readOnlyOpenMapPropDef.setReadOnly(true); + addPropertyDefinition(configDef, readOnlyOpenMapPropDef, orderIndex++); + + PropertyDefinitionList listOfSimplesPropDef = new PropertyDefinitionList("ListOfSimples", + "a list of Integer simples", true, new PropertyDefinitionSimple("integer", "an integer", false, + PropertySimpleType.INTEGER)); + listOfSimplesPropDef.setDisplayName(listOfSimplesPropDef.getName()); + addPropertyDefinition(configDef, listOfSimplesPropDef, orderIndex++); + + PropertyDefinitionMap mapInListPropDef = + new PropertyDefinitionMap("MapOfSimplesInList", "a map of simples in a list", false); + mapInListPropDef.put(createStringPropDef1()); + mapInListPropDef.put(createStringPropDef2()); + mapInListPropDef.put(createIntegerPropDef()); + mapInListPropDef.setDisplayName(mapInListPropDef.getName()); + + PropertyDefinitionList listPropDef = new PropertyDefinitionList("ListOfMaps", "a list of maps", true, + mapInListPropDef); + listPropDef.setDisplayName(listPropDef.getName()); + addPropertyDefinition(configDef, listPropDef, orderIndex++); + + PropertyDefinitionMap mapInReadOnlyListPropDef = + new PropertyDefinitionMap("MapOfSimplesInReadOnlyList", "a map of simples in a list", false); + mapInReadOnlyListPropDef.put(createStringPropDef1()); + mapInReadOnlyListPropDef.put(createStringPropDef2()); + mapInReadOnlyListPropDef.put(createIntegerPropDef()); + mapInReadOnlyListPropDef.setDisplayName(mapInReadOnlyListPropDef.getName()); + + PropertyDefinitionList readOnlyListPropDef = new PropertyDefinitionList("ReadOnlyListOfMaps", + "a read-only list of maps", true, mapInReadOnlyListPropDef); + readOnlyListPropDef.setDisplayName(readOnlyListPropDef.getName()); + readOnlyListPropDef.setReadOnly(true); + addPropertyDefinition(configDef, readOnlyListPropDef, orderIndex++); + + PropertyGroupDefinition propertyGroupDefinition = new PropertyGroupDefinition("myGroup"); + propertyGroupDefinition.setDisplayName(propertyGroupDefinition.getName()); + propertyGroupDefinition.setDescription("this is an example group"); + + PropertyDefinitionSimple myString = new PropertyDefinitionSimple("myString1", "my little string", true, + PropertySimpleType.STRING); + myString.setDisplayName(myString.getName()); + myString.setSummary(true); + addPropertyDefinition(configDef, myString, orderIndex++); + myString.setPropertyGroupDefinition(propertyGroupDefinition); + + PropertyDefinitionSimple myString2 = new PropertyDefinitionSimple("myString2", "my other little string", true, + PropertySimpleType.STRING); + myString2.setDisplayName(myString2.getName()); + myString2.setSummary(true); + addPropertyDefinition(configDef, myString2, orderIndex++); + myString2.setPropertyGroupDefinition(propertyGroupDefinition); + + PropertyGroupDefinition propertyGroupDefinition2 = new PropertyGroupDefinition("myGroup2"); + propertyGroupDefinition2.setDisplayName(propertyGroupDefinition2.getName()); + propertyGroupDefinition2.setDescription("this is another example group"); + + PropertyDefinitionSimple myString3 = new PropertyDefinitionSimple("myString3", "my third string", true, + PropertySimpleType.STRING); + myString3.setDisplayName((myString3.getName())); + myString3.setSummary(true); + addPropertyDefinition(configDef, myString3, orderIndex++); + myString3.setPropertyGroupDefinition(propertyGroupDefinition2); + + PropertyDefinitionSimple enumExample = new PropertyDefinitionSimple("myEnum", + "a grouped enum prop with <=5 items", false, PropertySimpleType.STRING); + enumExample.setDisplayName(enumExample.getName()); + defaultConfiguration.put(new PropertySimple("myEnum", "Burlington")); + ArrayList<PropertyDefinitionEnumeration> myEnums = new ArrayList<PropertyDefinitionEnumeration>(); + myEnums.add(new PropertyDefinitionEnumeration("Burlington", "Burlington")); + myEnums.add(new PropertyDefinitionEnumeration("Camden", "Camden")); + myEnums.add(new PropertyDefinitionEnumeration("Gloucester", "Gloucester")); + enumExample.setEnumeratedValues(myEnums, false); + addPropertyDefinition(configDef, enumExample, orderIndex++); + enumExample.setPropertyGroupDefinition(propertyGroupDefinition2); + + return configDef; + } + + private static void addPropertyDefinition(ConfigurationDefinition configDef, + PropertyDefinition propDef, int orderIndex) { + propDef.setOrder(orderIndex); + configDef.put(propDef); + } + + public static Configuration createConfiguration() { + Configuration configuration = new Configuration(); + configuration.setNotes("a test config"); + configuration.setVersion(1); + + configuration.put(new PropertySimple("String1", "blah")); + configuration.put(new PropertySimple("String2", + "a really, really, really, really, really long value that won't fit in the text input box")); + configuration.put(new PropertySimple("LongString", "blah blah blah\nblah blah blah")); + configuration.put(new PropertySimple("Password", null)); + configuration.put(new PropertySimple("Boolean", false)); + configuration.put(new PropertySimple("Integer", 666)); + configuration.put(new PropertySimple("Float", Math.PI)); + + configuration.put(new PropertySimple("StringEnum1", "PA")); + configuration.put(new PropertySimple("StringEnum2", "blue")); + + PropertyMap propMap1 = new PropertyMap("MapOfSimples"); + propMap1.put(new PropertySimple("String1", "One")); + propMap1.put(new PropertySimple("String2", "Two")); + propMap1.put(new PropertySimple("Integer", 11)); + configuration.put(propMap1); + + PropertyMap openPropMap1 = new PropertyMap("OpenMapOfSimples"); + openPropMap1.put(new PropertySimple("PROCESSOR_ARCHITECTURE", "x86")); + openPropMap1.put(new PropertySimple("PROCESSOR_IDENTIFIER", "x86 Family 6 Model 15 Stepping 6, GenuineIntel")); + openPropMap1.put(new PropertySimple("PROCESSOR_LEVEL", "6")); + openPropMap1.put(new PropertySimple("PROCESSOR_REVISION", "0f06")); + configuration.put(openPropMap1); + + PropertyMap openPropMap2 = new PropertyMap("ReadOnlyOpenMapOfSimples"); + openPropMap2.put(new PropertySimple("ANT_HOME", "C:\opt\ant-1.6.5")); + openPropMap2.put(new PropertySimple("ANT_OPTS", "-Xms128M -Xmx256M")); + configuration.put(openPropMap2); + + configuration.put(new PropertyList("ListOfSimples", new PropertySimple("integer", "18"), new PropertySimple( + "integer", "127"), new PropertySimple("integer", "311"), new PropertySimple("integer", "2"), new PropertySimple( + "integer", "301"), new PropertySimple("integer", "79"), new PropertySimple("integer", "62"))); + + PropertyMap propMap2 = new PropertyMap("MapOfSimplesInList"); + propMap2.put(new PropertySimple("String1", "Uno")); + propMap2.put(new PropertySimple("String2", "Dos")); + propMap2.put(new PropertySimple("Integer", Integer.MIN_VALUE)); + PropertyMap propMap3 = new PropertyMap("MapOfSimplesInList"); + propMap3.put(new PropertySimple("String1", "Un")); + propMap3.put(new PropertySimple("String2", "Deux")); + propMap3.put(new PropertySimple("Integer", Integer.MAX_VALUE)); + configuration.put(new PropertyList("ListOfMaps", propMap2, propMap3)); + + PropertyMap propMap4 = new PropertyMap("MapOfSimplesInReadOnlyList"); + propMap4.put(new PropertySimple("String1", "A")); + propMap4.put(new PropertySimple("String2", "B")); + propMap4.put(new PropertySimple("Integer", 999)); + PropertyMap propMap5 = new PropertyMap("MapOfSimplesInReadOnlyList"); + propMap5.put(new PropertySimple("String1", "a")); + propMap5.put(new PropertySimple("String2", "b")); + propMap5.put(new PropertySimple("Integer", 0)); + configuration.put(new PropertyList("ReadOnlyListOfMaps", propMap4, propMap5)); + + configuration.put(new PropertySimple("myString1", "grouped String 1")); + configuration.put(new PropertySimple("myString2", "grouped String 2")); + configuration.put(new PropertySimple("myString3", "strings are cool")); + configuration.put(new PropertySimple("myEnum", "Burlington")); + + return configuration; + } + + private static PropertyDefinitionSimple createStringPropDef1() { + PropertyDefinitionSimple stringPropDef1; + stringPropDef1 = new PropertyDefinitionSimple("String1", + "an optional String simple prop", false, PropertySimpleType.STRING); + stringPropDef1.setDisplayName(stringPropDef1.getName()); + return stringPropDef1; + } + + private static PropertyDefinitionSimple createStringPropDef2() { + PropertyDefinitionSimple stringPropDef2; + stringPropDef2 = new PropertyDefinitionSimple("String2", + "a read-only String simple prop", false, PropertySimpleType.STRING); + stringPropDef2.setDisplayName(stringPropDef2.getName()); + stringPropDef2.setReadOnly(true); + return stringPropDef2; + } + + private static PropertyDefinitionSimple createIntegerPropDef() { + PropertyDefinitionSimple integerPropDef; + integerPropDef = new PropertyDefinitionSimple("Integer", + "a required summary Integer simple prop", true, PropertySimpleType.INTEGER); + integerPropDef.setDisplayName(integerPropDef.getName()); + integerPropDef.setSummary(true); + return integerPropDef; + } + + private TestConfigurationFactory() { + } +} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestConfigurationView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestConfigurationView.java new file mode 100644 index 0000000..1f7ccaf --- /dev/null +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestConfigurationView.java @@ -0,0 +1,133 @@ +/* + * RHQ Management Platform + * Copyright 2010, Red Hat Middleware LLC, and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * 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.test.configuration; + +import java.util.EnumSet; +import java.util.Set; + +import com.smartgwt.client.types.Overflow; +import com.smartgwt.client.widgets.events.ClickEvent; +import com.smartgwt.client.widgets.events.ClickHandler; +import com.smartgwt.client.widgets.layout.LayoutSpacer; +import com.smartgwt.client.widgets.toolbar.ToolStrip; + +import org.rhq.core.domain.configuration.Configuration; +import org.rhq.core.domain.configuration.definition.ConfigurationDefinition; +import org.rhq.enterprise.gui.coregui.client.CoreGUI; +import org.rhq.enterprise.gui.coregui.client.components.configuration.ConfigurationEditor; +import org.rhq.enterprise.gui.coregui.client.components.configuration.PropertyValueChangeEvent; +import org.rhq.enterprise.gui.coregui.client.components.configuration.PropertyValueChangeListener; +import org.rhq.enterprise.gui.coregui.client.util.message.Message; +import org.rhq.enterprise.gui.coregui.client.util.message.MessageCenter; +import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIButton; +import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout; + +/** + * @author Ian Springer + */ +public class TestConfigurationView + extends LocatableVLayout implements PropertyValueChangeListener { + public static final String VIEW_ID = "TestConfig"; + + private ConfigurationEditor editor; + private LocatableIButton saveButton; + private ConfigurationDefinition configurationDefinition; + private Configuration configuration; + + public TestConfigurationView(String locatorId) { + super(locatorId); + } + + @Override + protected void onDraw() { + super.onDraw(); + build(); + } + + public void build() { + setWidth100(); + setHeight100(); + + ToolStrip toolStrip = new ToolStrip(); + toolStrip.setWidth100(); + + toolStrip.addMember(new LayoutSpacer()); + + this.saveButton = new LocatableIButton(this.extendLocatorId("Save"), "Save"); + this.saveButton.addClickHandler(new ClickHandler() { + public void onClick(ClickEvent clickEvent) { + save(); + } + }); + this.saveButton.disable(); + toolStrip.addMember(this.saveButton); + + addMember(toolStrip); + + this.configurationDefinition = TestConfigurationFactory.createConfigurationDefinition(); + this.configuration = TestConfigurationFactory.createConfiguration(); + + reloadConfiguration(); + } + + @Override + public void propertyValueChanged(PropertyValueChangeEvent event) { + MessageCenter messageCenter = CoreGUI.getMessageCenter(); + Message message; + if (event.isValidationStateChanged()) { + Set<String> invalidPropertyNames = event.getInvalidPropertyNames(); + if (invalidPropertyNames.isEmpty()) { + this.saveButton.enable(); + message = new Message("All properties now have valid values, so the configuration can now be saved.", + Message.Severity.Info, EnumSet.of(Message.Option.Transient, Message.Option.Sticky)); + } + else { + this.saveButton.disable(); + message = new Message( + "The following properties have invalid values: " + invalidPropertyNames + + " - the values must be corrected before the configuration can be saved.", + Message.Severity.Error, EnumSet.of(Message.Option.Transient, Message.Option.Sticky)); + } + messageCenter.notify(message); + } + else { + this.saveButton.enable(); + } + } + + private void reloadConfiguration() { + this.saveButton.disable(); + if (editor != null) { + editor.destroy(); + removeMember(editor); + } + + editor = new ConfigurationEditor(extendLocatorId("Editor"), this.configurationDefinition, this.configuration); + editor.setOverflow(Overflow.AUTO); + editor.addPropertyValueChangeListener(this); + addMember(editor); + } + + private void save() { + CoreGUI.getMessageCenter().notify( + new Message("Configuration updated.", "Test configuration updated.")); + reloadConfiguration(); + } +} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestGroupConfigurationView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestGroupConfigurationView.java new file mode 100644 index 0000000..1a8b304 --- /dev/null +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestGroupConfigurationView.java @@ -0,0 +1,142 @@ +/* + * RHQ Management Platform + * Copyright 2010, Red Hat Middleware LLC, and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * 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.test.configuration; + +import java.util.ArrayList; +import java.util.EnumSet; +import java.util.List; +import java.util.Set; + +import com.smartgwt.client.types.Overflow; +import com.smartgwt.client.widgets.events.ClickEvent; +import com.smartgwt.client.widgets.events.ClickHandler; +import com.smartgwt.client.widgets.layout.LayoutSpacer; +import com.smartgwt.client.widgets.toolbar.ToolStrip; + +import org.rhq.core.domain.configuration.Configuration; +import org.rhq.core.domain.configuration.definition.ConfigurationDefinition; +import org.rhq.enterprise.gui.coregui.client.CoreGUI; +import org.rhq.enterprise.gui.coregui.client.components.configuration.ConfigurationEditor; +import org.rhq.enterprise.gui.coregui.client.components.configuration.GroupConfigurationEditor; +import org.rhq.enterprise.gui.coregui.client.components.configuration.GroupMemberConfiguration; +import org.rhq.enterprise.gui.coregui.client.components.configuration.PropertyValueChangeEvent; +import org.rhq.enterprise.gui.coregui.client.components.configuration.PropertyValueChangeListener; +import org.rhq.enterprise.gui.coregui.client.util.message.Message; +import org.rhq.enterprise.gui.coregui.client.util.message.MessageCenter; +import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIButton; +import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout; + +/** + * @author Ian Springer + */ +public class TestGroupConfigurationView + extends LocatableVLayout implements PropertyValueChangeListener { + public static final String VIEW_ID = "TestGroupConfig"; + + private static final int GROUP_SIZE = 2; + + private ConfigurationEditor editor; + private LocatableIButton saveButton; + private ConfigurationDefinition configurationDefinition; + private List<GroupMemberConfiguration> memberConfigurations; + + public TestGroupConfigurationView(String locatorId) { + super(locatorId); + } + + @Override + protected void onDraw() { + super.onDraw(); + + setWidth100(); + setHeight100(); + + ToolStrip toolStrip = new ToolStrip(); + toolStrip.setWidth100(); + + toolStrip.addMember(new LayoutSpacer()); + + this.saveButton = new LocatableIButton(this.extendLocatorId("Save"), "Save"); + this.saveButton.addClickHandler(new ClickHandler() { + public void onClick(ClickEvent clickEvent) { + save(); + } + }); + this.saveButton.disable(); + toolStrip.addMember(this.saveButton); + + addMember(toolStrip); + + this.configurationDefinition = TestConfigurationFactory.createConfigurationDefinition(); + this.memberConfigurations = new ArrayList<GroupMemberConfiguration>(GROUP_SIZE); + for (int i = 0; i < GROUP_SIZE; i++) { + Configuration configuration = TestConfigurationFactory.createConfiguration(); + GroupMemberConfiguration memberConfiguration = new GroupMemberConfiguration(i, "Member #" + i, + configuration); + this.memberConfigurations.add(memberConfiguration); + } + + reloadConfiguration(); + } + + @Override + public void propertyValueChanged(PropertyValueChangeEvent event) { + MessageCenter messageCenter = CoreGUI.getMessageCenter(); + Message message; + if (event.isValidationStateChanged()) { + Set<String> invalidPropertyNames = event.getInvalidPropertyNames(); + if (invalidPropertyNames.isEmpty()) { + this.saveButton.enable(); + message = new Message("All properties now have valid values, so the configuration can now be saved.", + Message.Severity.Info, EnumSet.of(Message.Option.Transient, Message.Option.Sticky)); + } + else { + this.saveButton.disable(); + message = new Message( + "The following properties have invalid values: " + invalidPropertyNames + + " - the values must be corrected before the configuration can be saved.", + Message.Severity.Error, EnumSet.of(Message.Option.Transient, Message.Option.Sticky)); + } + messageCenter.notify(message); + } else { + this.saveButton.enable(); + } + } + + private void reloadConfiguration() { + this.saveButton.disable(); + if (editor != null) { + editor.destroy(); + removeMember(editor); + } + + editor = new GroupConfigurationEditor(extendLocatorId("Editor"), this.configurationDefinition, + this.memberConfigurations); + editor.setOverflow(Overflow.AUTO); + editor.addPropertyValueChangeListener(this); + addMember(editor); + } + + private void save() { + CoreGUI.getMessageCenter().notify( + new Message("Member configurations updated.", "Member configurations updated.")); + reloadConfiguration(); + } +} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageBar.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageBar.java index 1f95a24..f0c901d 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageBar.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageBar.java @@ -96,7 +96,6 @@ public class MessageBar extends LocatableHLayout implements MessageCenter.Messag private void clearMessage(boolean clearSticky) { if (this.label != null) { this.label.destroy(); - removeMember(this.label); markForRedraw(); } if (clearSticky) {
rhq-commits@lists.fedorahosted.org