modules/core/dbutils/pom.xml
| 2
modules/core/dbutils/src/main/scripts/dbsetup/inventory-schema.xml
| 6
modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
| 14
modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotification.java
| 19
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceCriteria.java
| 8
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceGroupCriteria.java
| 18
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/TaggedCriteria.java
| 9
modules/core/domain/src/main/java/org/rhq/core/domain/resource/DeleteResourceHistory.java
| 6
modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java
| 13
modules/core/domain/src/main/java/org/rhq/core/domain/resource/ResourceType.java
| 8
modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/ResourceGroup.java
| 24
modules/core/domain/src/main/java/org/rhq/core/domain/util/CriteriaUtils.java
| 58 +
modules/core/domain/src/main/java/org/rhq/core/domain/util/StringUtils.java
| 63 -
modules/core/native-system/src/main/java/org/rhq/core/system/FileSystemInfo.java
| 11
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java
| 245 ----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/DemoCanvas.java
| 1
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/Footer.java
| 117 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java
| 107 --
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/SearchGUI.java
| 117 --
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/UserSessionManager.java
| 276 +++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/AdministrationView.java
| 149 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/agent/install/RemoteAgentInstallView.java
| 3
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesView.java
| 1
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersView.java
| 1
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertsView.java
| 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsDataSource.java
| 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java
| 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsAlertDefinitionForm.java
| 3
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/DampeningAlertDefinitionForm.java
| 503 +++++++++-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java
| 194 +++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/RecoveryAlertDefinitionForm.java
| 18
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/BundleTopView.java
| 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleView.java
| 3
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/AboutModalWindow.java
| 60 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/FullHTMLPane.java
| 3
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
| 107 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ValidationStateChangeListener.java
| 27
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/SubTab.java
| 13
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/SubTabLayout.java
| 273 ++---
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTab.java
| 16
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTabSet.java
| 14
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
| 14
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tree/EnhancedTreeNode.java
| 54 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/upload/BundleDistributionFileUploadForm.java
| 3
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/upload/BundleFileUploadForm.java
| 3
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/upload/TextFileRetrieverForm.java
| 3
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java
| 1
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java
| 16
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletWindow.java
| 15
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java
| 73 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/resource/FavoriteResourcesPortlet.java
| 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/platform/PlatformPortletView.java
| 1
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/RecentAlertsPortlet.java
| 77 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java
| 17
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java
| 7
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/summary/InventorySummaryView.java
| 22
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/footer/FavoritesButton.java
| 3
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/AlertDefinitionGWTService.java
| 7
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/AlertGWTService.java
| 10
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GWTServiceLookup.java
| 15
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/AbstractTwoLevelTabSetView.java
| 51 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDetailsView.java
| 29
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java
| 34
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupDataSourceField.java
| 71 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupsDataSource.java
| 32
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionDataSource.java
| 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionListView.java
| 33
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java
| 94 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/AutoGroupTopView.java
| 106 ++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupContextMenu.java
| 306 ++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
| 68 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTitleBar.java
| 7
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTopView.java
| 18
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeContextMenu.java
| 313 ------
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeDatasource.java
| 368 -------
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeView.java
| 242 +++-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java
| 195 ++-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDataSourceField.java
| 10
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java
| 82 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/NewResourceTreeView.java
| 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
| 83 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTitleBar.java
| 7
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTopView.java
| 28
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java
| 163 ++-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
| 422 +++++---
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryDataSource.java
| 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryView.java
| 33
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ResourceConfigurationEditView.java
| 34
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/PluginConfigurationEditView.java
| 34
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/OperationHistoryView.java
| 1
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/AutodiscoveryQueueDataSource.java
| 24
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java
| 20
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceSelector.java
| 20
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/type/ResourceTypeRepository.java
| 148 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/FavoritesMenu.java
| 43
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/MenuBarView.java
| 129 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/SearchBarPane.java
| 77 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java
| 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java
| 133 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/measurement/MeasurementOOBView.java
| 3
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/tag/TaggedView.java
| 9
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/search/favorites/SavedSearchManager.java
| 8
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/BrowserUtility.java
| 58 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java
| 64 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/StringUtility.java
| 10
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/WidgetsField.java
| 63 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/Message.java
| 30
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageBar.java
| 73 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/preferences/UserPreferences.java
| 29
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/rpc/MonitoringRequestCallback.java
| 32
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AbstractGWTServiceImpl.java
| 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertDefinitionGWTServiceImpl.java
| 30
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertGWTServiceImpl.java
| 14
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java
| 2
modules/enterprise/gui/coregui/src/main/webapp/CoreGUI.css
| 28
modules/enterprise/gui/coregui/src/main/webapp/CoreGUI.html
| 5
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/authentication/SessionAccessServlet.java
| 25
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/events/EventDetailsAction.java
| 58 -
modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/monitor/events/data-plain.xhtml
| 180 +++
modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/monitor/graphs-plain.xhtml
| 123 ++
modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/monitor/measurement/data-plain.xhtml
| 197 +++
modules/enterprise/gui/portal-war/src/main/webapp/rhq/group/monitor/graphs-plain.xhtml
| 2
modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/monitor/graphs-plain.xhtml
| 19
modules/enterprise/server/jar/pom.xml
| 37
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerBean.java
| 30
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerLocal.java
| 3
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerRemote.java
| 6
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/AuthSession.java
| 4
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SessionManager.java
| 8
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceFactoryManagerBean.java
| 21
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceFactoryManagerLocal.java
| 10
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceFactoryManagerRemote.java
| 8
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
| 22
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/Disambiguator.java
| 15
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/MutableDisambiguationReport.java
| 25
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/system/ServerVersion.java
| 6
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
| 26
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/performance/test/AvailabilityInsertPurgeTest.java
| 12
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3PerformanceTest.java
| 36
modules/helpers/perftest-support/pom.xml
| 215 ++--
modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/testng/DatabaseSetupInterceptor.java
| 27
modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/testng/DatabaseState.java
| 14
modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/testng/JdbcConnectionProviderMethod.java
| 39
modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/PluginGen.java
| 2
modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Props.java
| 47
modules/helpers/pluginGen/src/main/resources/descriptorMain.ftl
| 12
modules/jopr/etc/jbas5-jnp-client/client.sh
| 38
modules/jopr/etc/jbas5-jnp-client/src/main/java/test/RmiClient.java
| 7
modules/plugins/jmx/src/main/resources/META-INF/rhq-plugin.xml
| 28
modules/plugins/platform/src/main/resources/META-INF/rhq-plugin.xml
| 2
pom.xml
| 2
151 files changed, 5181 insertions(+), 2928 deletions(-)
New commits:
commit 067f7016646feab4a0a4cacd9f9779c80f6ed4ad
Merge: 63d8660... 941fa0b...
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Thu Sep 30 16:30:59 2010 +0200
Merge branch 'master' into perftest
commit 63d86607c4ccf1626d16d5e68360d8483b9ac1e0
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Thu Sep 30 16:26:38 2010 +0200
Add jexcel lib for potential reporting.
diff --git a/modules/enterprise/server/jar/pom.xml
b/modules/enterprise/server/jar/pom.xml
index 335b76c..0ea5e08 100644
--- a/modules/enterprise/server/jar/pom.xml
+++ b/modules/enterprise/server/jar/pom.xml
@@ -67,7 +67,7 @@
<groupId>ant</groupId>
<artifactId>ant</artifactId>
</exclusion>
- </exclusions>
+ </exclusions>
</dependency>
<dependency>
@@ -87,7 +87,7 @@
<dependency>
<groupId>org.antlr</groupId>
<artifactId>antlr</artifactId>
- <version>3.2</version>
+ <version>3.2</version>
</dependency>
<!-- Required by a couple APL and Lather classes - TODO: Remove this once APL
and Lather have been excised. -->
@@ -358,7 +358,7 @@
<version>2.7.7</version>
<scope>test</scope>
</dependency>
-
+
<dependency>
<groupId>hibernate-entitymanager</groupId>
<artifactId>hibernate-entitymanager</artifactId>
@@ -400,13 +400,21 @@
<version>1.8</version>
<scope>test</scope>
</dependency>
-
+
<dependency>
<groupId>org.rhq.helpers</groupId>
<artifactId>perftest-support</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
+
+ <dependency>
+ <groupId>net.sourceforge.jexcelapi</groupId>
+ <artifactId>jxl</artifactId>
+ <version>2.6.8</version>
+ <scope>test</scope>
+ </dependency>
+
</dependencies>
<build>
@@ -509,10 +517,10 @@ Build-OS-Version=${os.version}
<dfa>false</dfa>
<nfa>false</nfa>
<excludes>
-
+
</excludes>
<includes>
-
+
</includes>
<libDirectory>src/main/antlr3/imports</libDirectory>
<messageFormat>antlr</messageFormat>
@@ -632,7 +640,7 @@ Build-OS-Version=${os.version}
</dependency>
</dependencies>
</profile>
-
+
<profile>
<id>javadoc</id>
<activation>
@@ -663,7 +671,7 @@ Build-OS-Version=${os.version}
</classpath>
<fileset dir="${project.dir}"
defaultexcludes="yes">
<include name="**/*Remote.java" />
- <exclude name="**/*Test*.java" />
+ <exclude name="**/*Test*.java" />
</fileset>
<link href="../domain" />
<link href="../plugin-api" />
@@ -682,8 +690,8 @@ Build-OS-Version=${os.version}
</plugins>
</build>
- </profile>
+ </profile>
</profiles>
-
+
</project>
commit d2b6ab8550ffdf39842a30567b3b76d4e5284331
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Thu Sep 30 16:25:51 2010 +0200
Clean up, as we are using the Datsource from JNDI
diff --git
a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/testng/DatabaseSetupInterceptor.java
b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/testng/DatabaseSetupInterceptor.java
index 8ed863d..ce38a46 100644
---
a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/testng/DatabaseSetupInterceptor.java
+++
b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/testng/DatabaseSetupInterceptor.java
@@ -66,12 +66,9 @@ public class DatabaseSetupInterceptor implements IInvokedMethodListener
{
return;
}
-// Method connectionProviderMethod = getConnectionProviderMethod(method, state);
try {
InputStreamProvider streamProvider = getInputStreamProvider(state.url(),
state.storage(), method);
-// Object classInstance = method.getTestMethod().getInstances()[0];
-// Connection connection = (Connection)
connectionProviderMethod.invoke(classInstance, (Object[]) null);
IDatabaseConnection connection = new DatabaseDataSourceConnection(new
InitialContext(),
"java:/RHQDS");
@@ -124,28 +121,6 @@ public class DatabaseSetupInterceptor implements
IInvokedMethodListener {
return javaMethod.getAnnotation(DatabaseState.class);
}
- private static Method getConnectionProviderMethod(IInvokedMethod method,
DatabaseState state) {
- String methodName = state.connectionProviderMethod();
- Class<?> declaringClass =
method.getTestMethod().getMethod().getDeclaringClass();
- if (methodName == null || methodName.trim().isEmpty()) {
- JdbcConnectionProviderMethod methodAnnotation =
declaringClass.getAnnotation(JdbcConnectionProviderMethod.class);
- if (methodAnnotation == null) {
- throw new IllegalStateException(
- "Neither 'connectionProviderMethod' attribute of the
@DatabaseState annotation nor @ConnectionProviderMethod annotation could be found. Cannot
initialize the database state without being able to get a connection.");
- }
- methodName = methodAnnotation.value();
- }
- try {
- return declaringClass.getMethod(methodName, (Class<?>[])null);
- } catch (SecurityException e) {
- LOG.warn("Failed to find a method declared by the
@ConnectionProviderMethod annotation.", e);
- return null;
- } catch (NoSuchMethodException e) {
- LOG.warn("Failed to find a method declared by the
@ConnectionProviderMethod annotation.", e);
- return null;
- }
-
- }
private static InputStreamProvider getInputStreamProvider(final String url,
DatabaseStateStorage storage, final IInvokedMethod method)
throws FileNotFoundException {
@@ -162,5 +137,5 @@ public class DatabaseSetupInterceptor implements
IInvokedMethodListener {
default:
return null;
}
- }
+ }
}
diff --git
a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/testng/DatabaseState.java
b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/testng/DatabaseState.java
index 5ceba4f..b7e66fa 100644
---
a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/testng/DatabaseState.java
+++
b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/testng/DatabaseState.java
@@ -28,7 +28,7 @@ import org.rhq.helpers.perftest.support.FileFormat;
/**
* An annotation to associate a test method with a required state of the database.
- *
+ *
* @author Lukas Krejci
*/
@Retention(value = RetentionPolicy.RUNTIME)
@@ -47,21 +47,15 @@ public @interface DatabaseState {
* is imported to it and the database is then upgraded to the latest version.
*/
String dbVersion();
-
+
/**
* Where is the export file accessible from (defaults to {@link
DatabaseStateStorage#CLASSLOADER}).
*/
DatabaseStateStorage storage() default DatabaseStateStorage.CLASSLOADER;
-
+
/**
* The format of the export file (defaults to zipped xml).
*/
FileFormat format() default FileFormat.ZIPPED_XML;
-
- /**
- * The name of the method to provide a JDBC connection object.
- * If the method is not specified, the value of the {@link
JdbcConnectionProviderMethod} annotation
- * is used.
- */
- String connectionProviderMethod() default "";
+
}
diff --git
a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/testng/JdbcConnectionProviderMethod.java
b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/testng/JdbcConnectionProviderMethod.java
deleted file mode 100644
index 8f04045..0000000
---
a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/testng/JdbcConnectionProviderMethod.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2010 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-package org.rhq.helpers.perftest.support.testng;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-import java.sql.Connection;
-
-/**
- * Specifies the method on the annotated class that can provide JDBC connections to the
caller.
- * The method must accept no arguments and return a {@link Connection} instance.
- *
- * @author Lukas Krejci
- */
-(a)Retention(RetentionPolicy.RUNTIME)
-(a)Target(ElementType.TYPE)
-public @interface JdbcConnectionProviderMethod {
-
- String value();
-}
commit 851eccbe8e96ea5c107b586f6f7598cd61f7ded9
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Thu Sep 30 16:18:27 2010 +0200
Move reporting into the abstract superclass.
diff --git
a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/performance/test/AvailabilityInsertPurgeTest.java
b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/performance/test/AvailabilityInsertPurgeTest.java
index 8f8c6ff..f0d2a5d 100644
---
a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/performance/test/AvailabilityInsertPurgeTest.java
+++
b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/performance/test/AvailabilityInsertPurgeTest.java
@@ -86,7 +86,6 @@ public class AvailabilityInsertPurgeTest extends
AbstractEJB3PerformanceTest {
@DatabaseState(url =
"perftest/AvailabilityInsertPurgeTest-testOne-data.xml.zip",
dbVersion="2.94")
public void testAlternating() throws Exception {
- System.out.println("=== testAlternating ===");
EntityManager em = getEntityManager();
Query q = em.createQuery("SELECT r FROM Resource r");
List<Resource> resources = q.getResultList();
@@ -130,7 +129,6 @@ public class AvailabilityInsertPurgeTest extends
AbstractEJB3PerformanceTest {
}
- printTimings();
long timing1000 = getTiming(String.format(ROUND__FORMAT,1000));
long timing2000 = getTiming(String.format(ROUND__FORMAT,2000));
@@ -152,7 +150,7 @@ public class AvailabilityInsertPurgeTest extends
AbstractEJB3PerformanceTest {
assertLinear(purge1000,purge3000,3,"Purge3");
assertLinear(purge1000,purge5000,5,"Purge3");
- commitTimings(false);
+// commitTimings(false);
}
/**
@@ -163,7 +161,6 @@ public class AvailabilityInsertPurgeTest extends
AbstractEJB3PerformanceTest {
@DatabaseState(url =
"perftest/AvailabilityInsertPurgeTest-testOne-data.xml.zip",
dbVersion="2.94")
public void testRandom() throws Exception {
- System.out.println("=== testRandom ===");
EntityManager em = getEntityManager();
Query q = em.createQuery("SELECT r FROM Resource r");
List<Resource> resources = q.getResultList();
@@ -200,8 +197,6 @@ public class AvailabilityInsertPurgeTest extends
AbstractEJB3PerformanceTest {
}
- printTimings();
-
long timing1000 = getTiming(String.format(ROUND__FORMAT,1000));
long timing2000 = getTiming(String.format(ROUND__FORMAT,2000));
long timing3000 = getTiming(String.format(ROUND__FORMAT,3000));
@@ -224,7 +219,6 @@ public class AvailabilityInsertPurgeTest extends
AbstractEJB3PerformanceTest {
assertLinear(purge1000,purge3000,3,"Purge3");
assertLinear(purge1000,purge5000,5,"Purge3");
- commitTimings(false);
}
/**
@@ -235,7 +229,6 @@ public class AvailabilityInsertPurgeTest extends
AbstractEJB3PerformanceTest {
@DatabaseState(url =
"perftest/AvailabilityInsertPurgeTest-testOne-data.xml.zip",
dbVersion="2.94")
public void testAlwaysUp() throws Exception {
- System.out.println("=== testAlwaysUp ===");
EntityManager em = getEntityManager();
Query q = em.createQuery("SELECT r FROM Resource r");
List<Resource> resources = q.getResultList();
@@ -271,7 +264,6 @@ public class AvailabilityInsertPurgeTest extends
AbstractEJB3PerformanceTest {
}
- printTimings();
long timing1000 = getTiming(String.format(ROUND__FORMAT,1000));
long timing2000 = getTiming(String.format(ROUND__FORMAT,2000));
@@ -295,6 +287,6 @@ public class AvailabilityInsertPurgeTest extends
AbstractEJB3PerformanceTest {
assertLinear(purge1000,purge3000,3,"Purge3");
assertLinear(purge1000,purge5000,5,"Purge3");
- commitTimings(false);
}
+
}
diff --git
a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3PerformanceTest.java
b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3PerformanceTest.java
index 2ebb35e..057b6c7 100644
---
a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3PerformanceTest.java
+++
b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3PerformanceTest.java
@@ -20,7 +20,11 @@ package org.rhq.enterprise.server.test;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.testng.ITestResult;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import java.lang.reflect.Method;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
@@ -39,8 +43,8 @@ public class AbstractEJB3PerformanceTest extends AbstractEJB3Test {
private static final String DEFAULT = "-default-";
- private Map<String,Long> timings = new HashMap<String, Long>();
- private Map<String,Long> startTime = new HashMap<String, Long>();
+ private Map<String,Long> timings ;
+ private Map<String,Long> startTime ;
protected void startTiming(String name) {
@@ -88,29 +92,43 @@ public class AbstractEJB3PerformanceTest extends AbstractEJB3Test {
return getTiming(DEFAULT);
}
+ @AfterMethod
+ protected void reportTimings(ITestResult result, Method meth) {
+ printTimings(meth.getName());
+
- protected void commitTimings(boolean alsoPrint) {
- if (alsoPrint)
- printTimings();
timings.clear();
startTime.clear();
}
- protected void printTimings() {
+ @BeforeMethod
+ protected void setupTimings(Method meth) {
+ System.out.println(">>> " + meth.getName() + "
===");
+ timings = new HashMap<String, Long>();
+ startTime = new HashMap<String, Long>();
+
+ }
+
+
+
+ protected void printTimings(String testName) {
+ System.out.println("=== " + testName + " ===");
Set<Map.Entry<String,Long>> data = timings.entrySet();
SortedSet <Map.Entry<String,Long>> sorted = new
TreeSet<Map.Entry<String,Long>>(new
Comparator<Map.Entry<String,Long>>() {
-
+
public int compare(Map.Entry<String,Long> item1,
Map.Entry<String,Long> item2) {
return item1.getKey().compareTo(item2.getKey());
}
});
sorted.addAll(data);
+ long summaryTime = 0L;
for (Map.Entry<String,Long> item : sorted) {
log.info(":| " + item.getKey() + " => " +
item.getValue());
System.out.println(":| " + item.getKey() + " => " +
item.getValue());
-
+ summaryTime += item.getValue();
}
+ System.out.println("Total: " + summaryTime + " ms");
}
protected void assertTiming(String name, long maxDuration) {
@@ -137,6 +155,8 @@ public class AbstractEJB3PerformanceTest extends AbstractEJB3Test {
* @param text text to prepend to a line if check fails.
*/
protected void assertLinear(long ref,long value, double multiplier, String text ) {
+
+System.out.println(">>> assertLinear " + text + " " + ref +
", " + value + ", " + multiplier );
long low = (long) (ref * multiplier * 0.80);
long hi = (long) (ref * multiplier * 1.2);
commit b3bfab468e1a3e9ea05f08c2b2ac5a8a3c57d808
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Thu Sep 30 15:27:51 2010 +0200
Use postgres 9 driver
diff --git a/pom.xml b/pom.xml
index 3d5c1f0..2bac92f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -86,7 +86,7 @@
<jsf-impl.version>1.2_14</jsf-impl.version>
<ojdbc5.version>11.2.0.1.0</ojdbc5.version>
<ems.version>1.2.15.1</ems.version>
- <postgresql.version>8.4-701.jdbc3</postgresql.version>
+ <postgresql.version>9.0-801.jdbc4</postgresql.version>
<h2.version>1.2.139</h2.version>
<jtds.version>1.2.2</jtds.version>
<richfaces.version>3.3.3.Final</richfaces.version>
commit 941fa0bcc0d7c177f7c0c2094a63a22c87727453
Author: Joseph Marques <joseph(a)redhat.com>
Date: Thu Sep 30 01:53:39 2010 -0400
EventCompositeHistoryView: disable flexRowDisplay and fix column widths
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
index a0487db..c933047 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
@@ -90,6 +90,7 @@ public class Table extends LocatableHLayout {
private SortSpecifier[] sortSpecifiers;
private String[] excludedFieldNames;
private boolean autoFetchData;
+ private boolean flexRowDisplay = true;
private RPCDataSource dataSource;
@@ -165,6 +166,10 @@ public class Table extends LocatableHLayout {
this.autoFetchData = autoFetchData;
}
+ public void setFlexRowDisplay(boolean flexRowDisplay) {
+ this.flexRowDisplay = flexRowDisplay;
+ }
+
@Override
protected void onInit() {
super.onInit();
@@ -183,11 +188,14 @@ public class Table extends LocatableHLayout {
}
listGrid.setWidth100();
listGrid.setHeight100();
- listGrid.setAutoFitData(Autofit.HORIZONTAL);
listGrid.setAlternateRecordStyles(true);
listGrid.setResizeFieldsInRealTime(false);
- listGrid.setWrapCells(true);
- listGrid.setFixedRecordHeights(false);
+
+ if (flexRowDisplay) {
+ listGrid.setAutoFitData(Autofit.HORIZONTAL);
+ listGrid.setWrapCells(true);
+ listGrid.setFixedRecordHeights(false);
+ }
// By default, SmartGWT will disable any rows that have a record named
"enabled" with a value of false - setting
// these fields to a bogus field name will disable this behavior. Note, setting
them to null does *not* disable
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java
index 954bac7..28e91f6 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java
@@ -32,6 +32,7 @@ import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.form.fields.TextItem;
import com.smartgwt.client.widgets.grid.CellFormatter;
import com.smartgwt.client.widgets.grid.ListGrid;
+import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.common.EntityContext;
@@ -78,6 +79,13 @@ public class EventCompositeHistoryView extends TableSection {
}
@Override
+ protected void onInit() {
+ setFlexRowDisplay(false);
+
+ super.onInit();
+ }
+
+ @Override
protected void configureTableFilters() {
final TextItem sourceFilter = new TextItem("source", "Source
Filter");
final TextItem detailsFilter = new TextItem("details", "Details
Filter");
@@ -90,11 +98,31 @@ public class EventCompositeHistoryView extends TableSection {
protected void configureTable() {
ListGrid grid = getListGrid();
- grid.setWrapCells(true);
- grid.setFixedRecordHeights(true);
-
// getListGrid().getField("id").setWidth(60);
+ ListGridField timestampField = new ListGridField("timestamp",
"ID", 125);
+ ListGridField severityField = new ListGridField("severity",
"Severity", 75);
+ severityField.setCellFormatter(new CellFormatter() {
+ public String format(Object o, ListGridRecord listGridRecord, int i, int i1)
{
+ return Canvas.imgHTML("subsystems/event/" + o +
"_16.png", 16, 16) + o;
+ }
+ });
+ ListGridField detailsField = new ListGridField("details-highlight",
"Details");
+ ListGridField sourceField = new ListGridField("source", "Source
Location", 275);
+ sourceField.setCellFormatter(new CellFormatter() {
+ public String format(Object o, ListGridRecord listGridRecord, int i, int i1)
{
+ String sourceLocation = (String) o;
+ int length = sourceLocation.length();
+ if (length > 40) {
+ return "..." + sourceLocation.substring(length - 40); //
the last 40 chars
+ }
+ return sourceLocation;
+ }
+ });
+
+ grid.setFields(timestampField, severityField, detailsField, sourceField);
+
+ /*
grid.getField("timestamp").setWidth(125);
grid.getField("severity").setWidth(75);
@@ -115,6 +143,7 @@ public class EventCompositeHistoryView extends TableSection {
return sourceLocation;
}
});
+ */
setupTableInteractions();
}
commit 9a77ce49fda241fc70ce3730ac21500fca584bf6
Author: Joseph Marques <joseph(a)redhat.com>
Date: Thu Sep 30 01:45:09 2010 -0400
InventoryView: tidy up labels, add tree node icons, add table header icons
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java
index 335d23c..a1683dc 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java
@@ -70,7 +70,7 @@ public class InventoryView extends LocatableHLayout implements
BookmarkableView
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 =
"DynamicGroupDefinitions";
+ private static final String PAGE_GROUP_DEFINITIONS = "DynagroupManager";
private static final String PAGE_MIXED_GROUPS = "MixedGroups";
private static final String PAGE_PLATFORMS = "Platforms";
private static final String PAGE_PROBLEM_GROUPS = "ProblemGroups";
@@ -203,6 +203,7 @@ public class InventoryView extends LocatableHLayout implements
BookmarkableView
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);
TreeGrid treeGrid = new LocatableTreeGrid(GROUPS_SECTION_VIEW_ID);
@@ -272,7 +273,7 @@ public class InventoryView extends LocatableHLayout implements
BookmarkableView
//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"),
PAGE_PROBLEM_GROUPS);
+ new Criteria("availability", "down"),
PAGE_PROBLEM_GROUPS, "types/Cluster_down_16.png");
} else { // selected the Inventory node itself
content = new
ResourceGroupListView(extendLocatorId("AllGroups"), null, PAGE_GROUPS,
"types/Cluster_up_24.png",
"types/Group_up_24.png");
commit 114cb5096cc46be1c78eeda894f8567b6a616306
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Wed Sep 29 19:23:13 2010 -0400
fix various bugs in config component; add new MessageBar component for displaying
JSF-like messages
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/util/StringUtils.java
b/modules/core/domain/src/main/java/org/rhq/core/domain/util/StringUtils.java
index 336aff1..938b07f 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/util/StringUtils.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/util/StringUtils.java
@@ -27,6 +27,9 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
+/**
+ *
+ */
public class StringUtils {
private static final Set<String> LOWERCASE_WORDS = new
HashSet<String>();
static {
@@ -62,18 +65,17 @@ public class StringUtils {
+ target.substring(nextDash + 2);
}
- result.append(Character.toUpperCase(target.charAt(0)));
-
StringBuilder currentWord = new StringBuilder();
char currentChar;
- char previousChar = target.charAt(0);
- for (int i = 1; i < target.length(); i++) {
+ char previousChar = 0;
+ for (int i = 0; i < target.length(); i++) {
currentChar = target.charAt(i);
- // Obey multi-digit numbers and acronyms
- if ((Character.isDigit(currentChar) &&
!Character.isDigit(previousChar))
+ // Make sure to insert spaces in the middle of acronyms or multi-digit
numbers.
+ if ((i != 0) &&
+ ((Character.isDigit(currentChar) &&
!Character.isDigit(previousChar))
|| (Character.isUpperCase(currentChar) &&
(!Character.isUpperCase(previousChar)
- || ((i < (target.length() - 1)) &&
Character.isLowerCase(target.charAt(i + 1)))))) {
+ || ((i < (target.length() - 1)) &&
Character.isLowerCase(target.charAt(i + 1))))))) {
// We're at the start of a new word.
appendWord(result, currentWord);
currentWord = new StringBuilder();
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/FullHTMLPane.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/FullHTMLPane.java
index b82482c..c90ca57 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/FullHTMLPane.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/FullHTMLPane.java
@@ -25,7 +25,6 @@ import com.smartgwt.client.widgets.HTMLPane;
* @author Greg Hinkle
*/
public class FullHTMLPane extends HTMLPane {
-
public FullHTMLPane() {
setWidth100();
setHeight100();
@@ -34,8 +33,7 @@ public class FullHTMLPane extends HTMLPane {
public FullHTMLPane(String url) {
this();
- System.out.println("Creating IFrame pane with URL [" + url +
"]...");
+ //System.out.println("Creating IFrame pane with URL [" + url +
"]...");
setContentsURL(url);
}
-
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
index 1de6dd2..432cd2b 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
@@ -23,6 +23,7 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.EnumSet;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -64,8 +65,10 @@ import com.smartgwt.client.widgets.form.fields.events.ChangeEvent;
import com.smartgwt.client.widgets.form.fields.events.ChangeHandler;
import com.smartgwt.client.widgets.form.fields.events.ChangedEvent;
import com.smartgwt.client.widgets.form.fields.events.ChangedHandler;
+import com.smartgwt.client.widgets.form.validator.FloatRangeValidator;
import com.smartgwt.client.widgets.form.validator.IntegerRangeValidator;
import com.smartgwt.client.widgets.form.validator.RegExpValidator;
+import com.smartgwt.client.widgets.form.validator.Validator;
import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
@@ -107,6 +110,7 @@ import
org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
import org.rhq.core.domain.configuration.definition.PropertyGroupDefinition;
import org.rhq.core.domain.configuration.definition.PropertySimpleType;
import org.rhq.core.domain.configuration.definition.constraint.Constraint;
+import org.rhq.core.domain.configuration.definition.constraint.FloatRangeConstraint;
import org.rhq.core.domain.configuration.definition.constraint.IntegerRangeConstraint;
import org.rhq.core.domain.configuration.definition.constraint.RegexConstraint;
import org.rhq.core.domain.resource.ResourceType;
@@ -129,6 +133,7 @@ import
org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
/**
* @author Greg Hinkle
+ * @author Ian Springer
*/
public class ConfigurationEditor extends LocatableVLayout {
@@ -153,6 +158,9 @@ public class ConfigurationEditor extends LocatableVLayout {
private IButton saveButton;
private boolean readOnly = false;
+ private Set<String> invalidPropertyNames = new HashSet<String>();
+ private Set<ValidationStateChangeListener> validationStateChangeListeners =
+ new HashSet<ValidationStateChangeListener>();
public static enum ConfigType {
plugin, resource
@@ -206,6 +214,14 @@ public class ConfigurationEditor extends LocatableVLayout {
return this.valuesManager.validate();
}
+ public boolean isValid() {
+ return this.valuesManager.hasErrors();
+ }
+
+ public void addValidationStateChangeListener(ValidationStateChangeListener
validationStateChangeListener) {
+ this.validationStateChangeListeners.add(validationStateChangeListener);
+ }
+
@Override
protected void onDraw() {
super.onDraw();
@@ -286,7 +302,7 @@ public class ConfigurationEditor extends LocatableVLayout {
if (definition.getConfigurationFormat() == ConfigurationFormat.RAW
|| definition.getConfigurationFormat() ==
ConfigurationFormat.STRUCTURED_AND_RAW) {
- System.out.println("Loading files view");
+ System.out.println("Loading files view...");
Tab tab = new LocatableTab("Files", "Files");
tab.setPane(buildRawPane());
tabSet.addTab(tab);
@@ -294,7 +310,7 @@ public class ConfigurationEditor extends LocatableVLayout {
if (definition.getConfigurationFormat() == ConfigurationFormat.STRUCTURED
|| definition.getConfigurationFormat() ==
ConfigurationFormat.STRUCTURED_AND_RAW) {
- System.out.println("loading properties view");
+ System.out.println("Loading properties view...");
Tab tab = new LocatableTab("Properties", "Properties");
tab.setPane(buildStructuredPane());
tabSet.addTab(tab);
@@ -462,7 +478,7 @@ public class ConfigurationEditor extends LocatableVLayout {
return section;
}
- private DynamicForm buildPropertiesForm(String locatorId,
ArrayList<PropertyDefinition> definitions,
+ private DynamicForm buildPropertiesForm(String locatorId,
List<PropertyDefinition> definitions,
AbstractPropertyMap propertyMap) {
LocatableDynamicForm form = new LocatableDynamicForm(locatorId);
form.setValuesManager(valuesManager);
@@ -499,6 +515,7 @@ public class ConfigurationEditor extends LocatableVLayout {
}
form.setFields(fields.toArray(new FormItem[fields.size()]));
+
return form;
}
@@ -516,7 +533,7 @@ public class ConfigurationEditor extends LocatableVLayout {
fields.add(nameItem);
- FormItem valueItem = null;
+ FormItem valueItem;
if (propertyDefinition instanceof PropertyDefinitionSimple) {
valueItem = buildSimpleField(fields, (PropertyDefinitionSimple)
propertyDefinition, oddRow, property);
fields.add(valueItem);
@@ -714,7 +731,7 @@ public class ConfigurationEditor extends LocatableVLayout {
return rows;
}
- private ListGridRecord buildSummaryRecord(ArrayList<PropertyDefinition>
definitions, PropertyMap rowMap) {
+ private ListGridRecord buildSummaryRecord(List<PropertyDefinition> definitions,
PropertyMap rowMap) {
ListGridRecord record = new ListGridRecord();
for (PropertyDefinition subDef : definitions) {
PropertyDefinitionSimple subDefSimple = (PropertyDefinitionSimple) subDef;
@@ -778,7 +795,7 @@ public class ConfigurationEditor extends LocatableVLayout {
}
List<PropertyDefinitionEnumeration> enumeratedValues =
propertyDefinition.getEnumeratedValues();
- if (enumeratedValues != null && enumeratedValues.size() > 0) {
+ if (enumeratedValues != null && !enumeratedValues.isEmpty()) {
LinkedHashMap<String, String> valueOptions = new
LinkedHashMap<String, String>();
for (PropertyDefinitionEnumeration option :
propertyDefinition.getEnumeratedValues()) {
@@ -837,24 +854,8 @@ public class ConfigurationEditor extends LocatableVLayout {
valueItem.setRequired(propertyDefinition.isRequired());
- if (propertyDefinition.getConstraints() != null) {
- Set<Constraint> constraints = propertyDefinition.getConstraints();
- for (Constraint c : constraints) {
- if (c instanceof IntegerRangeConstraint) {
- IntegerRangeConstraint integerConstraint = ((IntegerRangeConstraint)
c);
- IntegerRangeValidator validator = new IntegerRangeValidator();
-
- if (integerConstraint.getMinimum() != null)
- validator.setMin(integerConstraint.getMinimum().intValue());
- if (integerConstraint.getMaximum() != null)
- validator.setMax(integerConstraint.getMaximum().intValue());
- valueItem.setValidators(validator);
- } else if (c instanceof RegexConstraint) {
-
- valueItem.setValidators(new RegExpValidator("^" +
((RegexConstraint) c).getDetails() + "$"));
- }
- }
- }
+ List<Validator> validators = buildValidators(propertyDefinition,
valueItem);
+ valueItem.setValidators(validators.toArray(new Validator[validators.size()]));
/*
Click handlers seem to be turned off for disabled fields... need an
alternative
@@ -877,7 +878,19 @@ public class ConfigurationEditor extends LocatableVLayout {
finalValueItem.addChangedHandler(new ChangedHandler() {
public void onChanged(ChangedEvent changedEvent) {
- propertySimple.setValue(changedEvent.getValue());
+ boolean wasValidBefore =
ConfigurationEditor.this.invalidPropertyNames.isEmpty();
+ if (changedEvent.getItem().validate()) {
+
ConfigurationEditor.this.invalidPropertyNames.remove(propertySimple.getName());
+ propertySimple.setValue(changedEvent.getValue());
+ } else {
+
ConfigurationEditor.this.invalidPropertyNames.add(propertySimple.getName());
+ }
+ boolean isValidNow =
ConfigurationEditor.this.invalidPropertyNames.isEmpty();
+ if (isValidNow != wasValidBefore) {
+ for (ValidationStateChangeListener validationStateChangeListener :
ConfigurationEditor.this.validationStateChangeListeners) {
+ validationStateChangeListener.validateStateChanged(isValidNow);
+ }
+ }
}
});
@@ -900,10 +913,46 @@ public class ConfigurationEditor extends LocatableVLayout {
return valueItem;
}
+ private List<Validator> buildValidators(PropertyDefinitionSimple
propertyDefinition, FormItem valueItem) {
+ List<Validator> validators = new ArrayList<Validator>();
+ if (propertyDefinition.getConstraints() != null) {
+ Set<Constraint> constraints = propertyDefinition.getConstraints();
+
+ for (Constraint constraint : constraints) {
+ if (constraint instanceof IntegerRangeConstraint) {
+ IntegerRangeConstraint integerConstraint = ((IntegerRangeConstraint)
constraint);
+ IntegerRangeValidator validator = new IntegerRangeValidator();
+ if (integerConstraint.getMinimum() != null) {
+ validator.setMin(integerConstraint.getMinimum().intValue());
+ }
+ if (integerConstraint.getMaximum() != null) {
+ validator.setMax(integerConstraint.getMaximum().intValue());
+ }
+ validators.add(validator);
+ } else if (constraint instanceof FloatRangeConstraint) {
+ FloatRangeConstraint floatConstraint = ((FloatRangeConstraint)
constraint);
+ FloatRangeValidator validator = new FloatRangeValidator();
+ if (floatConstraint.getMinimum() != null) {
+ validator.setMin(floatConstraint.getMinimum().floatValue());
+ }
+ if (floatConstraint.getMaximum() != null) {
+ validator.setMax(floatConstraint.getMaximum().floatValue());
+ }
+ validators.add(validator);
+ } else if (constraint instanceof RegexConstraint) {
+ RegExpValidator validator =
+ new RegExpValidator("^" + ((RegexConstraint)
constraint).getDetails() + "$");
+ validators.add(validator);
+ }
+ }
+ }
+ return validators;
+ }
+
private void displayMapEditor(String locatorId, final ListGrid summaryTable, final
Record existingRecord,
PropertyDefinitionMap definition, final PropertyList list, PropertyMap map) {
- final ArrayList<PropertyDefinition> definitions = new
ArrayList<PropertyDefinition>(definition
+ final List<PropertyDefinition> definitions = new
ArrayList<PropertyDefinition>(definition
.getPropertyDefinitions().values());
Collections.sort(definitions, new PropertyDefinitionComparator());
@@ -994,5 +1043,4 @@ public class ConfigurationEditor extends LocatableVLayout {
return new Integer(o1.getOrder()).compareTo(o2.getOrder());
}
}
-
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ValidationStateChangeListener.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ValidationStateChangeListener.java
new file mode 100644
index 0000000..d8f7a85
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ValidationStateChangeListener.java
@@ -0,0 +1,27 @@
+/*
+ * 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.components.configuration;
+
+/**
+ * @author Ian Springer
+ */
+public interface ValidationStateChangeListener {
+ void validateStateChanged(boolean isValid);
+}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tree/EnhancedTreeNode.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tree/EnhancedTreeNode.java
index bbbcc1b..41e70c6 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tree/EnhancedTreeNode.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tree/EnhancedTreeNode.java
@@ -36,7 +36,17 @@ public class EnhancedTreeNode extends TreeNode {
public EnhancedTreeNode(String name, TreeNode... children) {
super(name, children);
- setTitle(StringUtils.deCamelCase(name));
+ if (name != null) {
+ setTitle(StringUtils.deCamelCase(name));
+ }
+ }
+
+ @Override
+ public void setName(String name) {
+ super.setName(name);
+ if (name != null && getTitle() == null) {
+ setTitle(StringUtils.deCamelCase(name));
+ }
}
public String getID() {
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
index b2cadc1..b2c532d 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
@@ -277,7 +277,7 @@ public class ResourceDetailView extends
AbstractTwoLevelTabSetView<ResourceCompo
updateSubTab(this.configurationTab, this.configCurrent, new
ResourceConfigurationEditView(this
.extendLocatorId("ResourceConfigView"), resource), true,
true);
updateSubTab(this.configurationTab, this.configHistory,
ConfigurationHistoryView.getHistoryOf(
- configurationTab.extendLocatorId("HistoryView"),
resource.getId()), true, true);
+ resource.getId()), true, true);
}
if (updateTab(this.eventsTab, facets.contains(ResourceTypeFacet.EVENT), true)) {
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryDataSource.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryDataSource.java
index 32e676a..f8387c9 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryDataSource.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryDataSource.java
@@ -43,7 +43,6 @@ public class ConfigurationHistoryDataSource extends
RPCDataSource<ResourceConfig
private ConfigurationGWTServiceAsync configurationService =
GWTServiceLookup.getConfigurationService();
-
public ConfigurationHistoryDataSource() {
super();
@@ -76,8 +75,9 @@ public class ConfigurationHistoryDataSource extends
RPCDataSource<ResourceConfig
criteria.setPageControl(getPageControl(request));
- if (request.getCriteria().getValues().get("resourceId") != null) {
-
criteria.addFilterResourceIds((Integer)request.getCriteria().getValues().get("resourceId"));
+ Integer resourceId =
(Integer)request.getCriteria().getValues().get("resourceId");
+ if (resourceId != null) {
+ criteria.addFilterResourceIds(resourceId);
}
configurationService.findResourceConfigurationUpdatesByCriteria(criteria,
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryView.java
index 0e51bae..aa11b05 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryView.java
@@ -40,22 +40,36 @@ import
org.rhq.enterprise.gui.coregui.client.components.table.TableSection;
*/
public class ConfigurationHistoryView extends TableSection {
public static final String VIEW_ID = "RecentConfigurationChanges";
+ private static final String LOCATOR_ID = "ConfigurationHistory";
+ private static final String TITLE = "Configuration History";
private Integer resourceId;
- public ConfigurationHistoryView(String locatorId) {
- super("ConfigurationHistory", "Configuration History");
+ /**
+ * Use this constructor to view config histories for all viewable Resources.
+ */
+ public ConfigurationHistoryView() {
+ super(LOCATOR_ID, TITLE);
final ConfigurationHistoryDataSource datasource = new
ConfigurationHistoryDataSource();
setDataSource(datasource);
}
- public ConfigurationHistoryView(String locatorId, final int resourceId) {
- super("ConfigurationHistory", "Configuration History", new
Criteria("resourceId", String.valueOf(resourceId)));
+ /**
+ * Use this constructor to view the config history for the Resource with the
specified ID.
+ *
+ * @param resourceId a Resource ID
+ */
+ public ConfigurationHistoryView(int resourceId) {
+ super(LOCATOR_ID, TITLE, createCriteria(resourceId));
this.resourceId = resourceId;
-
- final ConfigurationHistoryDataSource datasource = new
ConfigurationHistoryDataSource();
+ ConfigurationHistoryDataSource datasource = new
ConfigurationHistoryDataSource();
setDataSource(datasource);
+ }
+ private static Criteria createCriteria(int resourceId) {
+ Criteria criteria = new Criteria();
+ criteria.addCriteria("resourceId", Integer.valueOf(resourceId));
+ return criteria;
}
@Override
@@ -143,11 +157,11 @@ public class ConfigurationHistoryView extends TableSection {
}
+
// -------- Static Utility loaders ------------
- public static ConfigurationHistoryView getHistoryOf(String locatorId, int resourceId)
{
-
- return new ConfigurationHistoryView(locatorId, resourceId);
+ public static ConfigurationHistoryView getHistoryOf(int resourceId) {
+ return new ConfigurationHistoryView(resourceId);
}
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ResourceConfigurationEditView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ResourceConfigurationEditView.java
index a0df3e9..7964a74 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ResourceConfigurationEditView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ResourceConfigurationEditView.java
@@ -31,18 +31,21 @@ import org.rhq.core.domain.configuration.ResourceConfigurationUpdate;
import org.rhq.core.domain.resource.Resource;
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.ValidationStateChangeListener;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
+import org.rhq.enterprise.gui.coregui.client.util.message.MessageBar;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIButton;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
/**
* @author Greg Hinkle
*/
-public class ResourceConfigurationEditView extends LocatableVLayout {
-
- Resource resource;
- ConfigurationEditor editor;
+public class ResourceConfigurationEditView extends LocatableVLayout implements
ValidationStateChangeListener {
+ private Resource resource;
+ private ConfigurationEditor editor;
+ private IButton saveButton;
+ private MessageBar messageBar;
public ResourceConfigurationEditView(String locatorId, Resource resource) {
super(locatorId);
@@ -57,26 +60,28 @@ public class ResourceConfigurationEditView extends LocatableVLayout {
}
public void build() {
-
ToolStrip toolStrip = new ToolStrip();
toolStrip.setWidth100();
toolStrip.addMember(new LayoutSpacer());
- IButton saveButton = new LocatableIButton(this.extendLocatorId("Save"),
"Save");
- saveButton.addClickHandler(new ClickHandler() {
+ this.saveButton = new LocatableIButton(this.extendLocatorId("Save"),
"Save");
+ this.saveButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent clickEvent) {
save();
}
});
- // saveButton.disable();
+ this.saveButton.disable();
toolStrip.addMember(saveButton);
+ this.messageBar = new MessageBar();
+
editor = new ConfigurationEditor(this.getLocatorId(), resource.getId(),
resource.getResourceType().getId());
editor.setOverflow(Overflow.AUTO);
+ editor.addValidationStateChangeListener(this);
addMember(toolStrip);
-
+ addMember(this.messageBar);
addMember(editor);
}
@@ -96,6 +101,17 @@ public class ResourceConfigurationEditView extends LocatableVLayout {
}
});
+ }
+ @Override
+ public void validateStateChanged(boolean isValid) {
+ if (isValid) {
+ this.saveButton.enable();
+ this.messageBar.hide();
+ } else {
+ this.saveButton.disable();
+ Message message = new Message("One or more properties have invalid
values. The values must be fixed before the configuration can be saved.",
Message.Severity.Error);
+ this.messageBar.setMessage(message);
+ }
}
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/PluginConfigurationEditView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/PluginConfigurationEditView.java
index c11cca2..357255a 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/PluginConfigurationEditView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/PluginConfigurationEditView.java
@@ -20,7 +20,6 @@ package
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.inventor
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.types.Overflow;
-import com.smartgwt.client.widgets.IButton;
import com.smartgwt.client.widgets.events.ClickEvent;
import com.smartgwt.client.widgets.events.ClickHandler;
import com.smartgwt.client.widgets.layout.LayoutSpacer;
@@ -31,18 +30,22 @@ import org.rhq.core.domain.configuration.PluginConfigurationUpdate;
import org.rhq.core.domain.resource.Resource;
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.ValidationStateChangeListener;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
+import org.rhq.enterprise.gui.coregui.client.util.message.MessageBar;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIButton;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
/**
* @author Greg Hinkle
*/
-public class PluginConfigurationEditView extends LocatableVLayout {
+public class PluginConfigurationEditView extends LocatableVLayout implements
ValidationStateChangeListener {
private Resource resource;
private ConfigurationEditor editor;
+ private LocatableIButton saveButton;
+ private MessageBar messageBar;
public PluginConfigurationEditView(String locatorId, Resource resource) {
super(locatorId);
@@ -63,21 +66,24 @@ public class PluginConfigurationEditView extends LocatableVLayout {
toolStrip.addMember(new LayoutSpacer());
- IButton saveButton = new LocatableIButton(this.extendLocatorId("Save"),
"Save");
- saveButton.addClickHandler(new ClickHandler() {
+ this.saveButton = new LocatableIButton(this.extendLocatorId("Save"),
"Save");
+ this.saveButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent clickEvent) {
save();
}
});
- // saveButton.disable();
+ this.saveButton.disable();
toolStrip.addMember(saveButton);
+ this.messageBar = new MessageBar();
+
editor = new ConfigurationEditor(this.getLocatorId(), resource.getId(),
resource.getResourceType().getId(),
ConfigurationEditor.ConfigType.plugin);
editor.setOverflow(Overflow.AUTO);
+ editor.addValidationStateChangeListener(this);
addMember(toolStrip);
-
+ addMember(this.messageBar);
addMember(editor);
}
@@ -87,16 +93,28 @@ public class PluginConfigurationEditView extends LocatableVLayout {
GWTServiceLookup.getConfigurationService().updatePluginConfiguration(resource.getId(),
updatedConfiguration,
new AsyncCallback<PluginConfigurationUpdate>() {
public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to update
configuration", caught);
+ CoreGUI.getErrorHandler().handleError("Failed to update
connection settings.", caught);
}
public void onSuccess(PluginConfigurationUpdate result) {
CoreGUI.getMessageCenter().notify(
- new Message("Connection settings updated for resource
[" + resource.getName() + "]",
+ new Message("Connection settings updated for Resource
[" + resource.getName() + "].",
Message.Severity.Info));
}
});
}
+
+ @Override
+ public void validateStateChanged(boolean isValid) {
+ if (isValid) {
+ this.saveButton.enable();
+ this.messageBar.hide();
+ } else {
+ this.saveButton.disable();
+ Message message = new Message("One or more properties have invalid
values. The values must be fixed before the configuration can be saved.",
Message.Severity.Error);
+ this.messageBar.setMessage(message);
+ }
+ }
}
\ No newline at end of file
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 7627527..48a4455 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
@@ -214,7 +214,7 @@ public class ReportTopView extends LocatableHLayout implements
BookmarkableView
} else if (MeasurementOOBView.VIEW_ID.equals(pageName)) {
content = new
MeasurementOOBView(this.extendLocatorId("SuspectMetrics"));
} else if (ConfigurationHistoryView.VIEW_ID.equals(pageName)) {
- content = new
ConfigurationHistoryView(this.extendLocatorId("RecentConfigChanges"));
+ content = new ConfigurationHistoryView();
} else if (OperationHistoryView.VIEW_ID.equals(pageName)) {
content = new
OperationHistoryView(this.extendLocatorId("RecentOps"));
} else if (AlertsView.VIEW_ID.equals(pageName)) {
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/Message.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/Message.java
index 7e2eef4..905b0c7 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/Message.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/Message.java
@@ -34,14 +34,38 @@ public class Message {
public enum Severity { Info, Warning, Error };
public Message(String title, Severity severity) {
- this.title = title;
- this.severity = severity;
+ this(title, null, severity);
}
public Message(String title, String detail, Severity severity) {
this.title = title;
this.detail = detail;
- this.severity = severity;
+ this.severity = (severity != null) ? severity : Severity.Info;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public String getDetail() {
+ return detail;
}
+ public Date getFired() {
+ return fired;
+ }
+
+ public Severity getSeverity() {
+ return severity;
+ }
+
+ @Override
+ public String toString() {
+ return "Message{" +
+ "title='" + title + '\'' +
+ ", detail='" + detail + '\'' +
+ ", fired=" + fired +
+ ", severity=" + severity +
+ '}';
+ }
}
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
new file mode 100644
index 0000000..e025ab1
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageBar.java
@@ -0,0 +1,73 @@
+/*
+ * 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.util.message;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import com.smartgwt.client.widgets.Label;
+
+/**
+ * A bar for displaying a message at the top of a page - the equivalent of the JSF
h:messages component.
+ *
+ * @author Ian Springer
+ */
+public class MessageBar extends Label {
+ public static final Map<Message.Severity, String> SEVERITY_TO_STYLE_NAME_MAP =
new HashMap();
+ static {
+ SEVERITY_TO_STYLE_NAME_MAP.put(Message.Severity.Info, "InfoBlock");
+ SEVERITY_TO_STYLE_NAME_MAP.put(Message.Severity.Warning, "WarnBlock");
+ SEVERITY_TO_STYLE_NAME_MAP.put(Message.Severity.Error, "ErrorBlock");
+ }
+
+ @Override
+ protected void onDraw() {
+ super.onDraw();
+
+ setWidth100();
+ setAutoHeight();
+
+ hide();
+ }
+
+ public void setMessage(Message message) {
+
+ String contents;
+ if (message != null) {
+ contents = message.getTitle();
+ if (message.getDetail() != null) {
+ contents += ": " + message.getDetail();
+ }
+ } else {
+ contents = null;
+ }
+ setContents(contents);
+ if (contents != null) {
+ String styleName = SEVERITY_TO_STYLE_NAME_MAP.get(message.getSeverity());
+ setStyleName(styleName);
+ }
+ markForRedraw();
+ if (contents != null) {
+ show();
+ } else {
+ hide();
+ }
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/CoreGUI.css
b/modules/enterprise/gui/coregui/src/main/webapp/CoreGUI.css
index 305fcf8..c5d324e 100644
--- a/modules/enterprise/gui/coregui/src/main/webapp/CoreGUI.css
+++ b/modules/enterprise/gui/coregui/src/main/webapp/CoreGUI.css
@@ -359,3 +359,31 @@ a:hover {
.editableText {
color: #070;
}
+
+.InfoBlock,.ConfirmationBlock,.WarnBlock,.ErrorBlock,.FatalBlock {
+ padding: 4px;
+ border-width: 1px;
+ border-top-style: solid;
+ font-size: 10px;
+ color: #000000;
+}
+
+.InfoBlock,.ConfirmationBlock {
+ background-color: #BFF1B5; /* light green */
+ border-top-color: #00AC3D; /* medium green */
+}
+
+.WarnBlock {
+ background-color: #FFFD99; /* light yellow */
+ border-top-color: #FF9C15; /* medium orange */
+}
+
+.ErrorBlock {
+ background-color: #FF9999; /* light red */
+ border-top-color: #EE4444; /* medium red */
+}
+
+.FatalBlock {
+ background-color: #FF6666; /* slightly darker light red */
+ border-top-color: #EE1111; /* slightly darker medium red */
+}
commit cd8d92506dd5f31e8a340948e9ad6af0e2af2e1c
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Sep 29 18:49:57 2010 -0400
add javadoc to explain what the extra properties are for (as well as what the normal
config is)
diff --git
a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotification.java
b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotification.java
index 27da614..d93c81b 100644
---
a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotification.java
+++
b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotification.java
@@ -164,6 +164,14 @@ public class AlertNotification implements Serializable {
this.senderName = senderName;
}
+ /**
+ * The configuration containing the properties that each individual alert sender
requires.
+ * The properties in this configuration should match the property definitions
defined
+ * in the alert server plugin descriptor.
+ *
+ * @return the configuration for the alert notification (properties included in this
+ * configuration will be specific to the sender type).
+ */
public Configuration getConfiguration() {
return configuration;
}
@@ -175,6 +183,17 @@ public class AlertNotification implements Serializable {
this.configuration = configuration;
}
+ /**
+ * These are extra configuration property values that a particular sender instance
might need.
+ * These are only used/needed for specific alert implementations. One example where
extra config is used
+ * is for the "resource operation" alert sender. If a particular
notification uses this "resource operation"
+ * sender (where {@link #getConfiguration()} will include things like the operation
name that is to be invoked),
+ * its possible that the selected operation to invoke requires parameters to be
passed to it. The user can
+ * enter this "extra" data and those extra properties (that is, the
configuration properties to be passed to the
+ * operation as parametesr) will be stored here.
+ *
+ * @return extra configuration properties or <code>null</code> if not
set
+ */
public Configuration getExtraConfiguration() {
return extraConfiguration;
}
commit b6bf65f099863bb16d5bc920be9ad29eb5b1d3ce
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Sep 29 17:30:21 2010 -0400
alert def / notification editor's list now shows the sender config preview in the
config column
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java
index 18931c0..cffdd78 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java
@@ -26,6 +26,7 @@ package org.rhq.enterprise.gui.coregui.client.alert.definitions;
import java.util.ArrayList;
import java.util.List;
+import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
import com.smartgwt.client.data.fields.DataSourceTextField;
@@ -38,9 +39,11 @@ import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.alert.AlertDefinition;
import org.rhq.core.domain.alert.notification.AlertNotification;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.components.table.Table;
import org.rhq.enterprise.gui.coregui.client.components.table.TableAction;
import org.rhq.enterprise.gui.coregui.client.components.table.Table.SelectionEnablement;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableWindow;
@@ -226,20 +229,39 @@ public class NotificationsAlertDefinitionForm extends
LocatableVLayout implement
@Override
public ListGridRecord copyValues(AlertNotification from) {
ListGridRecord record = new ListGridRecord();
- record.setAttribute(FIELD_SENDER, from.getSenderName());
- record.setAttribute(FIELD_CONFIGURATION,
from.getConfiguration().toString(false));
- // TODO configuration should be the string of
-
//getAlertManager().getAlertPluginManager().getAlertSenderForNotification(alertNotification).previewConfiguration()
- // TODO what's this extra configuration in the notification?
-
record.setAttribute(FIELD_OBJECT, from);
+ record.setAttribute(FIELD_SENDER, from.getSenderName());
+ // our executeFetch will fill in the real value for FIELD_CONFIGURATION
+ record.setAttribute(FIELD_CONFIGURATION, "(unknown)");
+ // TODO what's the extraConfiguration the notification?
return record;
}
@Override
- protected void executeFetch(DSRequest request, DSResponse response) {
- response.setData(buildRecords(notifications));
- processResponse(request.getRequestId(), response);
+ protected void executeFetch(final DSRequest request, final DSResponse response)
{
+ final ListGridRecord[] records = buildRecords(notifications); // partially
builds the records, but we need to do another remote call to get the config preview
+
+ AlertNotification[] notifs = notifications.toArray(new
AlertNotification[notifications.size()]);
+
GWTServiceLookup.getAlertDefinitionService().getAlertNotificationConfigurationPreview(notifs,
+ new AsyncCallback<String[]>() {
+ @Override
+ public void onSuccess(String[] result) {
+ int i = 0;
+ for (ListGridRecord record : records) {
+ record.setAttribute(FIELD_CONFIGURATION, result[i++]);
+ }
+ response.setData(records);
+ processResponse(request.getRequestId(), response);
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to get
notification configuration preview",
+ caught);
+ response.setData(records);
+ processResponse(request.getRequestId(), response);
+ }
+ });
}
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/AlertDefinitionGWTService.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/AlertDefinitionGWTService.java
index e0d4e94..4819bac 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/AlertDefinitionGWTService.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/AlertDefinitionGWTService.java
@@ -21,6 +21,7 @@ package org.rhq.enterprise.gui.coregui.client.gwt;
import com.google.gwt.user.client.rpc.RemoteService;
import org.rhq.core.domain.alert.AlertDefinition;
+import org.rhq.core.domain.alert.notification.AlertNotification;
import org.rhq.core.domain.criteria.AlertDefinitionCriteria;
import org.rhq.core.domain.util.PageList;
@@ -38,4 +39,6 @@ public interface AlertDefinitionGWTService extends RemoteService {
int disableAlertDefinitions(Integer[] alertDefinitionIds) throws Exception;
int removeAlertDefinitions(Integer[] alertDefinitionIds) throws Exception;
+
+ String[] getAlertNotificationConfigurationPreview(AlertNotification[] notifs) throws
Exception;
}
\ No newline at end of file
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertDefinitionGWTServiceImpl.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertDefinitionGWTServiceImpl.java
index 392e710..d1f492b 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertDefinitionGWTServiceImpl.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertDefinitionGWTServiceImpl.java
@@ -19,6 +19,7 @@
package org.rhq.enterprise.gui.coregui.server.gwt;
import org.rhq.core.domain.alert.AlertDefinition;
+import org.rhq.core.domain.alert.notification.AlertNotification;
import org.rhq.core.domain.criteria.AlertDefinitionCriteria;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.util.exception.ThrowableUtil;
@@ -32,6 +33,7 @@ public class AlertDefinitionGWTServiceImpl extends
AbstractGWTServiceImpl implem
private AlertDefinitionManagerLocal alertDefManager =
LookupUtil.getAlertDefinitionManager();
+ @Override
public PageList<AlertDefinition>
findAlertDefinitionsByCriteria(AlertDefinitionCriteria criteria) {
try {
PageList<AlertDefinition> results =
this.alertDefManager.findAlertDefinitionsByCriteria(
@@ -42,6 +44,7 @@ public class AlertDefinitionGWTServiceImpl extends
AbstractGWTServiceImpl implem
}
}
+ @Override
public int createAlertDefinition(AlertDefinition alertDefinition, Integer resourceId)
throws Exception {
try {
int results = alertDefManager.createAlertDefinition(getSessionSubject(),
alertDefinition, resourceId);
@@ -51,6 +54,7 @@ public class AlertDefinitionGWTServiceImpl extends
AbstractGWTServiceImpl implem
}
}
+ @Override
public AlertDefinition updateAlertDefinition(int alertDefinitionId, AlertDefinition
alertDefinition,
boolean updateInternals) throws Exception {
try {
@@ -62,6 +66,7 @@ public class AlertDefinitionGWTServiceImpl extends
AbstractGWTServiceImpl implem
}
}
+ @Override
public int enableAlertDefinitions(Integer[] alertDefinitionIds) throws Exception {
try {
int results = alertDefManager.enableAlertDefinitions(getSessionSubject(),
alertDefinitionIds);
@@ -71,6 +76,7 @@ public class AlertDefinitionGWTServiceImpl extends
AbstractGWTServiceImpl implem
}
}
+ @Override
public int disableAlertDefinitions(Integer[] alertDefinitionIds) throws Exception {
try {
int results = alertDefManager.disableAlertDefinitions(getSessionSubject(),
alertDefinitionIds);
@@ -80,6 +86,7 @@ public class AlertDefinitionGWTServiceImpl extends
AbstractGWTServiceImpl implem
}
}
+ @Override
public int removeAlertDefinitions(Integer[] alertDefinitionIds) throws Exception {
try {
int results = alertDefManager.removeAlertDefinitions(getSessionSubject(),
alertDefinitionIds);
@@ -88,4 +95,15 @@ public class AlertDefinitionGWTServiceImpl extends
AbstractGWTServiceImpl implem
throw new RuntimeException(ThrowableUtil.getAllMessages(e));
}
}
+
+ @Override
+ public String[] getAlertNotificationConfigurationPreview(AlertNotification[] notifs)
throws Exception {
+ try {
+ String[] results =
alertDefManager.getAlertNotificationConfigurationPreview(getSessionSubject(), notifs);
+ return SerialUtility.prepare(results,
"getAlertNotificationConfigurationPreview");
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
+ }
+
}
\ No newline at end of file
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerBean.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerBean.java
index 3c41812..a221d96 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerBean.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerBean.java
@@ -32,6 +32,8 @@ import javax.persistence.Query;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.jboss.annotation.IgnoreDependency;
+
import org.rhq.core.domain.alert.AlertCondition;
import org.rhq.core.domain.alert.AlertConditionCategory;
import org.rhq.core.domain.alert.AlertConditionLog;
@@ -55,6 +57,8 @@ import org.rhq.enterprise.server.alert.engine.AlertDefinitionEvent;
import org.rhq.enterprise.server.authz.AuthorizationManagerLocal;
import org.rhq.enterprise.server.authz.PermissionException;
import org.rhq.enterprise.server.cloud.StatusManagerLocal;
+import org.rhq.enterprise.server.plugin.pc.alert.AlertSender;
+import org.rhq.enterprise.server.plugin.pc.alert.AlertSenderPluginManager;
import org.rhq.enterprise.server.util.CriteriaQueryGenerator;
import org.rhq.enterprise.server.util.CriteriaQueryRunner;
@@ -74,6 +78,9 @@ public class AlertDefinitionManagerBean implements
AlertDefinitionManagerLocal,
private AuthorizationManagerLocal authorizationManager;
@EJB
private AlertDefinitionManagerLocal alertDefinitionManager;
+ @EJB
+ @IgnoreDependency
+ private AlertManagerLocal alertManager;
@EJB
private StatusManagerLocal agentStatusManager;
@@ -696,4 +703,27 @@ public class AlertDefinitionManagerBean implements
AlertDefinitionManagerLocal,
CriteriaQueryRunner<AlertDefinition> queryRunner = new
CriteriaQueryRunner(criteria, generator, entityManager);
return queryRunner.execute();
}
+
+ @Override
+ public String[] getAlertNotificationConfigurationPreview(Subject sessionSubject,
AlertNotification[] notifications) {
+ if (notifications == null || notifications.length == 0) {
+ return new String[0];
+ }
+
+ AlertSenderPluginManager alertPluginManager =
alertManager.getAlertPluginManager();
+
+ String[] previews = new String[notifications.length];
+ int i = 0;
+ for (AlertNotification notif : notifications) {
+ AlertSender<?> sender =
alertPluginManager.getAlertSenderForNotification(notif);
+ if (sender != null) {
+ previews[i++] = sender.previewConfiguration();
+ } else {
+ previews[i++] = "n/a (unknown sender)";
+ }
+ }
+
+ return previews;
+ }
+
}
\ No newline at end of file
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerLocal.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerLocal.java
index 6908301..cca307f 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerLocal.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerLocal.java
@@ -23,6 +23,7 @@ import java.util.List;
import javax.ejb.Local;
import org.rhq.core.domain.alert.AlertDefinition;
+import org.rhq.core.domain.alert.notification.AlertNotification;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.common.composite.IntegerOptionItem;
import org.rhq.core.domain.criteria.AlertDefinitionCriteria;
@@ -81,4 +82,6 @@ public interface AlertDefinitionManagerLocal {
int disableAlertDefinitions(Subject subject, Integer[] alertDefinitionIds);
int removeAlertDefinitions(Subject subject, Integer[] alertDefinitionIds);
+
+ String[] getAlertNotificationConfigurationPreview(Subject sessionSubject,
AlertNotification[] notifications);
}
\ No newline at end of file
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerRemote.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerRemote.java
index 3ed890b..3280d70 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerRemote.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerRemote.java
@@ -25,6 +25,7 @@ import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import org.rhq.core.domain.alert.AlertDefinition;
+import org.rhq.core.domain.alert.notification.AlertNotification;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.criteria.AlertDefinitionCriteria;
import org.rhq.core.domain.util.PageList;
@@ -59,4 +60,9 @@ public interface AlertDefinitionManagerRemote {
@WebParam(name = "subject") Subject subject, //
@WebParam(name = "alertDefinitionIds") Integer[] alertDefinitionIds);
+ @WebMethod
+ String[] getAlertNotificationConfigurationPreview(//
+ @WebParam(name = "subject") Subject subject, //
+ @WebParam(name = "notifications") AlertNotification[] notifications);
+
}
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
index 0062843..d5f3cce 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
@@ -30,7 +30,6 @@ import java.util.Map;
import java.util.Set;
import javax.ejb.Stateless;
-import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import javax.xml.bind.annotation.XmlSeeAlso;
@@ -38,6 +37,7 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import org.rhq.core.domain.alert.Alert;
import org.rhq.core.domain.alert.AlertDefinition;
+import org.rhq.core.domain.alert.notification.AlertNotification;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.authz.Role;
import org.rhq.core.domain.bundle.Bundle;
@@ -166,7 +166,7 @@ import org.rhq.enterprise.server.util.LookupUtil;
*/
@Stateless
@WebService(endpointInterface =
"org.rhq.enterprise.server.webservices.WebservicesRemote", targetNamespace =
ServerVersion.namespace)
-@XmlSeeAlso({ PropertyDefinition.class, PropertyDefinitionSimple.class,
PropertyDefinitionList.class,
+@XmlSeeAlso( { PropertyDefinition.class, PropertyDefinitionSimple.class,
PropertyDefinitionList.class,
PropertyDefinitionMap.class })
public class WebservicesManagerBean implements WebservicesRemote {
@@ -229,6 +229,10 @@ public class WebservicesManagerBean implements WebservicesRemote {
return alertDefinitionManager.removeAlertDefinitions(subject,
alertDefinitionIds);
}
+ public String[] getAlertNotificationConfigurationPreview(Subject subject,
AlertNotification[] alertNotifications) {
+ return alertDefinitionManager.getAlertNotificationConfigurationPreview(subject,
alertNotifications);
+ }
+
//ALERTDEFINITIONMANAGER: END ----------------------------------
//AVAILABILITYMANAGER: BEGIN ----------------------------------
@@ -784,14 +788,14 @@ public class WebservicesManagerBean implements WebservicesRemote {
//REPOMANAGER: END ----------------------------------
//RESOURCEFACTORYMANAGER: BEGIN ----------------------------------
- public CreateResourceHistory createResource(Subject subject, int parentResourceId,
int resourceTypeId, String resourceName,
- Configuration pluginConfiguration, Configuration resourceConfiguration) {
+ public CreateResourceHistory createResource(Subject subject, int parentResourceId,
int resourceTypeId,
+ String resourceName, Configuration pluginConfiguration, Configuration
resourceConfiguration) {
return resourceFactoryManager.createResource(subject, parentResourceId,
resourceTypeId, resourceName,
pluginConfiguration, resourceConfiguration);
}
- public CreateResourceHistory createPackageBackedResource(Subject subject, int
parentResourceId, int newResourceTypeId,
- String newResourceName,//
+ public CreateResourceHistory createPackageBackedResource(Subject subject, int
parentResourceId,
+ int newResourceTypeId, String newResourceName,//
@XmlJavaTypeAdapter(value = ConfigurationAdapter.class)//
Configuration pluginConfiguration, String packageName, String packageVersion,
Integer architectureId,//
@XmlJavaTypeAdapter(value = ConfigurationAdapter.class)//
commit 6ecb7125e01e08584558b6d5176f85ef0ecf7e54
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Sep 29 17:28:00 2010 -0400
fix NPE
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/util/StringUtils.java
b/modules/core/domain/src/main/java/org/rhq/core/domain/util/StringUtils.java
index 88c08ee..336aff1 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/util/StringUtils.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/util/StringUtils.java
@@ -38,6 +38,10 @@ public class StringUtils {
* Take something that is camel-cased, add spaces between the words, and capitalize
each word.
*/
public static String deCamelCase(String target) {
+ if (target == null) {
+ return null;
+ }
+
if (target.length() == 0) {
return "";
}
commit 60549e9fd46e494a1eacfc0276b480c5027b19cc
Author: Joseph Marques <joseph(a)redhat.com>
Date: Wed Sep 29 16:06:48 2010 -0400
update javadoc
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/UserSessionManager.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/UserSessionManager.java
index 6fc72d8..5219213 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/UserSessionManager.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/UserSessionManager.java
@@ -40,9 +40,9 @@ import org.rhq.enterprise.gui.coregui.client.util.BrowserUtility;
import org.rhq.enterprise.gui.coregui.client.util.preferences.UserPreferences;
/**
- * First time this class is loaded, local loggedIn bit will be false, which implies user
is not logged in.
+ * Upon application load, if already loggedIn on the server-side, local loggedIn bit will
be set to true.
*
- * If login successful, CoreGUI/SearchGUI will call setSessionSubject, which sets local
loggedIn bit to true.
+ * If login successful, the local loggedIn bit will be set to true.
* If user clicks logout explicitly, LoginView will be shown, which sets local loggedIn
bit to false.
* If count down timer expires, LoginView will be shown, which sets local loggedIn bit to
false.
*
commit 62f7518ae8dd868d4777400f37bc69b4368c4115
Author: Joseph Marques <joseph(a)redhat.com>
Date: Wed Sep 29 15:44:59 2010 -0400
fix remainder of session oddities:
* when applications loads, restore if user is logged in on the server-side
* properly handle client-side sessions during timeout as well as logout action
* fix the footer to refresh loggedIn and recent alerts label properly
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 a1d8475..e342b11 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
@@ -23,16 +23,10 @@ import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Element;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
-import com.google.gwt.http.client.Request;
-import com.google.gwt.http.client.RequestBuilder;
-import com.google.gwt.http.client.RequestCallback;
-import com.google.gwt.http.client.RequestException;
-import com.google.gwt.http.client.Response;
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.Window.Location;
-import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.core.KeyIdentifier;
import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.util.KeyCallback;
@@ -41,22 +35,16 @@ import com.smartgwt.client.util.SC;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.layout.VLayout;
-import org.rhq.core.domain.auth.Subject;
-import org.rhq.core.domain.common.ProductInfo;
-import org.rhq.core.domain.criteria.SubjectCriteria;
-import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.admin.AdministrationView;
import org.rhq.enterprise.gui.coregui.client.alert.AlertsView;
import org.rhq.enterprise.gui.coregui.client.bundle.BundleTopView;
import org.rhq.enterprise.gui.coregui.client.dashboard.DashboardsView;
-import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import
org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.ResourceGroupTopView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.InventoryView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.ResourceTopView;
import org.rhq.enterprise.gui.coregui.client.menu.MenuBarView;
import org.rhq.enterprise.gui.coregui.client.report.ReportTopView;
import org.rhq.enterprise.gui.coregui.client.report.tag.TaggedView;
-import org.rhq.enterprise.gui.coregui.client.util.BrowserUtility;
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.MessageCenter;
@@ -90,8 +78,6 @@ public class CoreGUI implements EntryPoint,
ValueChangeHandler<String> {
private static Messages messages;
- private static ProductInfo productInfo;
-
public void onModuleLoad() {
String hostPageBaseURL = GWT.getHostPageBaseURL();
if (hostPageBaseURL.indexOf("/coregui/") == -1) {
@@ -127,124 +113,47 @@ public class CoreGUI implements EntryPoint,
ValueChangeHandler<String> {
messages = GWT.create(Messages.class);
- checkLoginStatus();
+ UserSessionManager.login();
// removing loading image, which can be seen if LoginView doesn't completely
cover it
Element loadingPanel = DOM.getElementById("Loading-Panel");
loadingPanel.removeFromParent();
}
- public static void checkLoginStatus() {
- if (!UserSessionManager.isLoggedIn()) {
- new LoginView().showLoginDialog();
- return;
- }
-
- // String sessionIdString =
com.google.gwt.user.client.Cookies.getCookie("RHQ_Sesssion");
- // if (sessionIdString == null) {
-
- BrowserUtility.forceIe6Hacks();
-
- RequestBuilder b = new RequestBuilder(RequestBuilder.GET,
"/sessionAccess");
- try {
- b.setCallback(new RequestCallback() {
- public void onResponseReceived(final Request request, final Response
response) {
- String sessionIdString = response.getText();
- if (sessionIdString != null && sessionIdString.length() >
0) {
-
- int subjectId =
Integer.parseInt(sessionIdString.split(":")[0]);
- final int sessionId =
Integer.parseInt(sessionIdString.split(":")[1]);
-
- Subject subject = new Subject();
- subject.setId(subjectId);
- subject.setSessionId(sessionId);
-
-
GWTServiceLookup.registerSession(String.valueOf(subject.getSessionId()));
-
- // look up real user prefs
-
- SubjectCriteria criteria = new SubjectCriteria();
- criteria.fetchConfiguration(true);
- criteria.addFilterId(subjectId);
- //criteria.fetchRoles(true);
-
-
GWTServiceLookup.getSubjectService().findSubjectsByCriteria(criteria,
- new AsyncCallback<PageList<Subject>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to
load user's subject", caught);
- new LoginView().showLoginDialog();
- }
-
- public void onSuccess(PageList<Subject> result) {
- Subject subject = result.get(0);
- subject.setSessionId(sessionId);
-
- // TODO this breaks because of reattach rules,
bizarrely even in queries.
- // gonna switch out to non-subject include apis
- //
- // Create a minimized session object for validation
on requests
- // Subject s = new
Subject(subject.getName(),subject.getFactive(), subject.getFsystem());
- // s.setSessionId(subject.getSessionId());
- UserSessionManager.setSessionSubject(subject);
- loadProductInfo();
- }
- });
- } else {
- new LoginView().showLoginDialog();
- }
- }
-
- public void onError(Request request, Throwable exception) {
- SC.say("Unable to determine login status, check server
status");
- }
- });
- b.send();
- } catch (RequestException e) {
- SC.say("Unable to determine login status, check server status");
- e.printStackTrace();
- } finally {
- BrowserUtility.unforceIe6Hacks();
- }
+ public static CoreGUI get() {
+ return coreGUI;
}
- private void buildCoreUI() {
+ public void buildCoreUI() {
// If the core gui is already built (eg. from previous login, just refire event)
- if (this.rootCanvas == null) {
- this.rootCanvas = new RootCanvas();
- rootCanvas.setOverflow(Overflow.HIDDEN);
-
- // HTMLPane menuPane = new HTMLPane();
- // menuPane.setWidth100();
- // menuPane.setHeight(26);
- // menuPane.setContentsType(ContentsType.PAGE);
- // menuPane.setContentsURL("/rhq/common/menu/menu.xhtml");
- // menuPane.setZIndex(400000);
- // layout.addMember(menuPane);
-
+ if (rootCanvas == null) {
MenuBarView menuBarView = new MenuBarView("TopMenu");
menuBarView.setWidth("100%");
- // WidgetCanvas menuCanvas = new WidgetCanvas(menuBarView);
- // menuCanvas.setTop(0);
- // menuCanvas.setWidth100();
- // menuCanvas.draw();
- rootCanvas.addMember(menuBarView);
breadCrumbTrailPane = new BreadcrumbTrailPane();
- rootCanvas.addMember(breadCrumbTrailPane);
Canvas canvas = new Canvas(CONTENT_CANVAS_ID);
canvas.setWidth100();
canvas.setHeight100();
- rootCanvas.addMember(canvas);
+ rootCanvas = new RootCanvas();
+ rootCanvas.setOverflow(Overflow.HIDDEN);
+ rootCanvas.addMember(menuBarView);
+ rootCanvas.addMember(breadCrumbTrailPane);
+ rootCanvas.addMember(canvas);
rootCanvas.addMember(new Footer("CoreFooter"));
-
rootCanvas.draw();
History.addValueChangeHandler(this);
}
- History.fireCurrentHistoryState();
+ if (History.getToken().equals("") ||
History.getToken().equals("LogOut")) {
+ // go to default view if user doesn't specify a history token
+ History.newItem(getDefaultView());
+ } else {
+ // otherwise just fire an event for the bookmarked URL they are returning to
+ History.fireCurrentHistoryState();
+ }
}
public void onValueChange(ValueChangeEvent<String> stringValueChangeEvent) {
@@ -262,7 +171,6 @@ public class CoreGUI implements EntryPoint,
ValueChangeHandler<String> {
currentViewPath.setRefresh(true);
coreGUI.rootCanvas.renderView(currentViewPath);
-
}
public Canvas createContent(String breadcrumbName) {
@@ -283,8 +191,10 @@ public class CoreGUI implements EntryPoint,
ValueChangeHandler<String> {
} else if (breadcrumbName.equals(BundleTopView.VIEW_ID)) {
canvas = new BundleTopView("Bundle");
} else if (breadcrumbName.equals("LogOut")) {
- canvas = new LoginView();
- UserSessionManager.logout();
+ // TODO: don't make LogOut a history event, just perform the logout
action by responding to click event
+ LoginView logoutView = new LoginView();
+ canvas = logoutView;
+ logoutView.showLoginDialog();
} else if (breadcrumbName.equals(TaggedView.VIEW_ID)) {
canvas = new TaggedView("Tag");
} else if (breadcrumbName.equals("Subsystems")) {
@@ -356,34 +266,7 @@ public class CoreGUI implements EntryPoint,
ValueChangeHandler<String> {
return messages;
}
- public static ProductInfo getProductInfo() {
- return productInfo;
- }
-
- private static void loadProductInfo() {
- GWTServiceLookup.getSystemService().getProductInfo(new
AsyncCallback<ProductInfo>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to load product
information.", caught);
- }
-
- public void onSuccess(ProductInfo result) {
- productInfo = result;
- coreGUI.buildCoreUI();
-
- // After a user initiated logout start back at the default view
- if ("LogOut".equals(CoreGUI.currentPath)) {
- History.newItem(DEFAULT_VIEW_PATH);
- }
- }
- });
- }
-
- public static void goToResourceOrGroupView(String newToken) {
-
- }
-
private class RootCanvas extends VLayout implements BookmarkableView {
-
ViewId currentViewId;
Canvas currentCanvas;
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/Footer.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/Footer.java
index 00050ad..36514aa 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/Footer.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/Footer.java
@@ -22,7 +22,6 @@ import com.google.gwt.user.client.History;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.types.VerticalAlignment;
-import com.smartgwt.client.widgets.Label;
import com.smartgwt.client.widgets.events.ClickEvent;
import com.smartgwt.client.widgets.events.ClickHandler;
import com.smartgwt.client.widgets.toolbar.ToolStripSeparator;
@@ -38,11 +37,10 @@ import
org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableToolStrip;
/**
* @author Greg Hinkle
+ * @author Joseph Marques
*/
public class Footer extends LocatableToolStrip {
- MessageCenterView recentMessage;
-
public Footer(String locatorId) {
super(locatorId);
setHeight(30);
@@ -56,36 +54,35 @@ public class Footer extends LocatableToolStrip {
protected void onDraw() {
super.onDraw();
- Label loggedInAs = new Label("Logged in as " +
UserSessionManager.getSessionSubject().getName());
- loggedInAs.setWrap(false);
- loggedInAs.setMargin(5);
- loggedInAs.setValign(VerticalAlignment.CENTER);
-
- addMember(loggedInAs);
- addMember(new ToolStripSeparator());
-
- recentMessage = new
MessageCenterView(extendLocatorId("MessageCenter"));
+ final UserSessionState userSessionState = new
UserSessionState("UserSessionState");
+ final MessageCenterView recentMessage = new
MessageCenterView(extendLocatorId("MessageCenter"));
recentMessage.setWidth("*");
+ final FavoritesButton favoritesButton = new
FavoritesButton(extendLocatorId("Favorites"));
+ final AlertsMessage alertsMessage = new
AlertsMessage(extendLocatorId("Alerts"));
+ addMember(userSessionState);
+ addMember(new ToolStripSeparator());
addMember(recentMessage);
-
addMember(new ToolStripSeparator());
+ addMember(favoritesButton);
+ addMember(alertsMessage);
- addMember(new FavoritesButton(extendLocatorId("Favorites")));
-
- addMember(new AlertsMessage(extendLocatorId("Alerts")));
-
+ userSessionState.schedule(15000);
+ alertsMessage.schedule(60000);
}
- public static class AlertsMessage extends LocatableLabel {
- public AlertsMessage(String locatorId) {
+ public abstract static class RefreshableLabel extends LocatableLabel {
+ public RefreshableLabel(String locatorId) {
super(locatorId);
- setHeight(30);
- setPadding(5);
+ }
- setIcon("subsystems/alert/Alert_LOW_16.png");
- setIconSize(16);
- setWrap(false);
+ // scheduling refreshes is sub-optimal, really need to move to a message bus
architecture
+ public void schedule(int millis) {
+ new Timer() {
+ public void run() {
+ refresh();
+ }
+ }.scheduleRepeating(millis);
}
@Override
@@ -93,15 +90,50 @@ public class Footer extends LocatableToolStrip {
super.onInit();
refresh();
+ }
- Timer t = new Timer() {
- public void run() {
- refresh();
- }
- };
+ public void refresh() {
+ if (UserSessionManager.isLoggedIn()) {
+ refreshLoggedIn();
+ } else {
+ refreshLoggedOut();
+ }
+ }
- // refresh every minute
- t.scheduleRepeating(60000);
+ public abstract void refreshLoggedIn();
+
+ public void refreshLoggedOut() {
+ setContents("");
+ setIcon(null);
+ }
+ }
+
+ public static class UserSessionState extends RefreshableLabel {
+ public UserSessionState(String locatorId) {
+ super(locatorId);
+ setWrap(false);
+ setMargin(5);
+ setValign(VerticalAlignment.CENTER);
+ }
+
+ public void refreshLoggedIn() {
+ setContents("Logged in as " +
UserSessionManager.getSessionSubject().getName());
+ }
+
+ public void refreshLoggedOut() {
+ setContents("Logged out");
+ }
+ }
+
+ public static class AlertsMessage extends RefreshableLabel {
+ public AlertsMessage(String locatorId) {
+ super(locatorId);
+ setHeight(30);
+ setPadding(5);
+
+ setIcon("subsystems/alert/Alert_LOW_16.png");
+ setIconSize(16);
+ setWrap(false);
addClickHandler(new ClickHandler() {
public void onClick(ClickEvent clickEvent) {
@@ -110,11 +142,7 @@ public class Footer extends LocatableToolStrip {
});
}
- public void refresh() {
- if (!UserSessionManager.isLoggedIn()) {
- return;
- }
-
+ public void refreshLoggedIn() {
AlertCriteria alertCriteria = new AlertCriteria();
alertCriteria.setPaging(1, 1);
// last eight hours
@@ -127,22 +155,15 @@ public class Footer extends LocatableToolStrip {
}
public void onSuccess(PageList<Alert> result) {
- drawAlerts(result);
+ if (result.isEmpty()) {
+ setContents("no recent alerts");
+ setIcon("subsystems/alert/Alert_LOW_16.png");
+ } else {
+ setContents(result.getTotalSize() + " recent
alerts");
+ setIcon("subsystems/alert/Alert_HIGH_16.png");
+ }
}
});
-
- }
-
- public void drawAlerts(PageList<Alert> alerts) {
- if (alerts.isEmpty()) {
- setContents("no recent alerts");
- setIcon("subsystems/alert/Alert_LOW_16.png");
-
- } else {
-
- setContents(alerts.getTotalSize() + " recent alerts");
- setIcon("subsystems/alert/Alert_HIGH_16.png");
- }
}
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java
index f6758e9..24ef812 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java
@@ -22,6 +22,9 @@
*/
package org.rhq.enterprise.gui.coregui.client;
+import java.util.EnumSet;
+import java.util.Map;
+
import com.google.gwt.event.dom.client.KeyCodes;
import com.google.gwt.http.client.Request;
import com.google.gwt.http.client.RequestBuilder;
@@ -44,6 +47,8 @@ import com.smartgwt.client.widgets.form.fields.TextItem;
import com.smartgwt.client.widgets.form.fields.events.KeyPressEvent;
import com.smartgwt.client.widgets.form.fields.events.KeyPressHandler;
+import org.rhq.core.domain.resource.ResourceType;
+import
org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
import org.rhq.enterprise.gui.coregui.client.util.BrowserUtility;
/**
@@ -150,8 +155,7 @@ public class LoginView extends Canvas {
if (statusCode == 200) {
window.destroy();
loginShowing = false;
- UserSessionManager.refresh();
- CoreGUI.checkLoginStatus();
+ UserSessionManager.login();
} else {
handleError(statusCode);
}
@@ -167,33 +171,16 @@ public class LoginView extends Canvas {
} finally {
BrowserUtility.unforceIe6Hacks();
}
+ }
- /*
- SubjectGWTServiceAsync subjectService =
SubjectGWTServiceAsync.Util.getInstance();
-
- subjectService.login(user, password, new AsyncCallback<Subject>() {
- public void onFailure(Throwable caught) {
- System.out.println("Failed to login - cause: " + caught);
- Label loginFailed = new Label("Failed to login - cause: " +
caught);
- loginFailed.draw();
- }
-
- public void onSuccess(Subject result) {
- System.out.println("Logged in: " + result.getSessionId());
- CoreGUI.setSessionSubject(result);
-
- *//* We can cache all metadata right here
- ResourceTypeRepository.Cache.getInstance().getResourceTypes(
- (Integer[]) null,
EnumSet.allOf(ResourceTypeRepository.MetadataType.class), new
ResourceTypeRepository.TypesLoadedCallback() {
- public void onTypesLoaded(HashMap<Integer, ResourceType> types)
{
- System.out.println("Preloaded [" + types.size() +
"] resource types");
- buildCoreUI();
- }
- });
- *//*
- }
- }); */
-
+ @SuppressWarnings("unused")
+ private void preloadAllTypeMetadata() {
+ ResourceTypeRepository.Cache.getInstance().getResourceTypes((Integer[]) null,
+ EnumSet.allOf(ResourceTypeRepository.MetadataType.class), new
ResourceTypeRepository.TypesLoadedCallback() {
+ public void onTypesLoaded(Map<Integer, ResourceType> types) {
+ System.out.println("Preloaded [" + types.size() + "]
resource types");
+ }
+ });
}
private void handleError(int statusCode) {
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/SearchGUI.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/SearchGUI.java
index 6312e93..2266993 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/SearchGUI.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/SearchGUI.java
@@ -19,20 +19,10 @@
package org.rhq.enterprise.gui.coregui.client;
import com.google.gwt.core.client.EntryPoint;
-import com.google.gwt.http.client.Request;
-import com.google.gwt.http.client.RequestBuilder;
-import com.google.gwt.http.client.RequestCallback;
-import com.google.gwt.http.client.RequestException;
-import com.google.gwt.http.client.Response;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.util.SC;
-import org.rhq.core.domain.auth.Subject;
-import org.rhq.core.domain.criteria.SubjectCriteria;
-import org.rhq.core.domain.util.PageList;
-import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.search.SearchBar;
-import org.rhq.enterprise.gui.coregui.client.util.BrowserUtility;
/**
* @author Joseph Marques
@@ -55,100 +45,25 @@ public class SearchGUI implements EntryPoint {
return;
}
- checkLoginStatus();
+ UserSessionManager.checkLoginStatus(new AsyncCallback<Void>() {
+ @Override
+ public void onFailure(Throwable caught) {
+ SC.say("Unable to determine login status, check server
status");
+ }
+
+ @Override
+ public void onSuccess(Void result) {
+ singleton.buildSearchGUI();
+ }
+ });
}
public void buildSearchGUI() {
searchBar = new SearchBar();
}
- public static void checkLoginStatus() {
-
- BrowserUtility.forceIe6Hacks();
-
- RequestBuilder b = new RequestBuilder(RequestBuilder.GET,
"/sessionAccess");
- try {
- b.setCallback(new RequestCallback() {
- public void onResponseReceived(final Request request, final Response
response) {
- String sessionIdString = response.getText();
- if (sessionIdString != null && sessionIdString.length() >
0) {
-
- int subjectId =
Integer.parseInt(sessionIdString.split(":")[0]);
- final int sessionId =
Integer.parseInt(sessionIdString.split(":")[1]);
-
- Subject subject = new Subject();
- subject.setId(subjectId);
- subject.setSessionId(sessionId);
-
-
GWTServiceLookup.registerSession(String.valueOf(subject.getSessionId()));
-
- // look up real user prefs
-
- SubjectCriteria criteria = new SubjectCriteria();
- criteria.addFilterId(subjectId);
-
-
GWTServiceLookup.getSubjectService().findSubjectsByCriteria(criteria,
- new AsyncCallback<PageList<Subject>>() {
- public void onFailure(Throwable caught) {
- // can't use this until gwt frame is always
present, reserve for futureu
- //CoreGUI.getErrorHandler().handleError("Failed
to load user's subject", caught);
- //SC.say("Failed to load user's
subject.");
- //new LoginView().showLoginDialog();
-
- System.out.println("Failed to load user's
subject");
- }
-
- public void onSuccess(PageList<Subject> result) {
- Subject subject = result.get(0);
- subject.setSessionId(sessionId);
- UserSessionManager.setSessionSubject(subject);
- singleton.buildSearchGUI();
- }
- });
- } else {
- new LoginView().showLoginDialog();
- }
- }
-
- public void onError(Request request, Throwable exception) {
- SC.say("Unable to determine login status, check server
status");
- }
- });
- b.send();
- } catch (RequestException e) {
- SC.say("Unable to determine login status, check server status");
- e.printStackTrace();
- } finally {
- BrowserUtility.unforceIe6Hacks();
- }
-
- }
-
public SearchBar getSearchBar() {
return searchBar;
}
- /**
- * Detects IE6.
- * <p/>
- * This is a nasty hack; but it's extremely reliable when running with other
- * js libraries on the same page at the same time as gwt.
- */
- public static native boolean detectIe6() /*-{
- if (typeof $doc.body.style.maxHeight !=
"undefined")
- return(false);
- else
- return(true);
- }-*/;
-
- public static native void forceIe6Hacks() /*-{
- $wnd.XMLHttpRequestBackup =
$wnd.XMLHttpRequest;
- $wnd.XMLHttpRequest = null;
- }-*/;
-
- public static native void unforceIe6Hacks() /*-{
- $wnd.XMLHttpRequest =
$wnd.XMLHttpRequestBackup;
- $wnd.XMLHttpRequestBackup = null;
- }-*/;
-
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/UserSessionManager.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/UserSessionManager.java
index 0bc285d..6fc72d8 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/UserSessionManager.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/UserSessionManager.java
@@ -22,11 +22,21 @@
*/
package org.rhq.enterprise.gui.coregui.client;
+import com.google.gwt.http.client.Request;
+import com.google.gwt.http.client.RequestBuilder;
+import com.google.gwt.http.client.RequestCallback;
+import com.google.gwt.http.client.RequestException;
+import com.google.gwt.http.client.Response;
+import com.google.gwt.user.client.Cookies;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.util.SC;
import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.criteria.SubjectCriteria;
+import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.util.BrowserUtility;
import org.rhq.enterprise.gui.coregui.client.util.preferences.UserPreferences;
/**
@@ -46,15 +56,12 @@ import
org.rhq.enterprise.gui.coregui.client.util.preferences.UserPreferences;
public class UserSessionManager {
private static int SESSION_TIMEOUT = 29 * 60 * 1000; // 29 mins, just shorter than
the 30-min web session timeout
- private static int LOGOUT_DELAY = 30 * 1000; // 30 seconds
+ private static int LOGOUT_DELAY = 15 * 1000; // wait 15 seconds for in-flight
requests to complete before logout
+ public static final String SESSION_NAME = "RHQ_Sesssion";
private static Subject sessionSubject;
private static UserPreferences userPreferences;
- private UserSessionManager() {
- // static access only
- }
-
private static boolean loggedIn = false;
private static Timer sessionTimer = new Timer() {
@Override
@@ -70,7 +77,134 @@ public class UserSessionManager {
}
};
+ private UserSessionManager() {
+ // static access only
+ }
+
+ public static void checkLoginStatus(final AsyncCallback<Void> callback) {
+ BrowserUtility.forceIe6Hacks();
+
+ RequestBuilder b = new RequestBuilder(RequestBuilder.GET,
"/sessionAccess");
+ try {
+ b.setCallback(new RequestCallback() {
+ public void onResponseReceived(final Request request, final Response
response) {
+ System.out.println("response text = " +
response.getText());
+ String sessionIdString = response.getText();
+ if (sessionIdString != null && sessionIdString.length() >
0) {
+
+ String[] parts = sessionIdString.split(":");
+ final int subjectId = Integer.parseInt(parts[0]);
+ final String sessionId = parts[1]; // not null
+ final long lastAccess = Long.parseLong(parts[2]);
+ System.out.println("sessionAccess-subjectId: " +
subjectId);
+ System.out.println("sessionAccess-sessionId: " +
sessionId);
+ System.out.println("sessionAccess-lastAccess: " +
lastAccess);
+
+ String previousSessionId = getPreviousSessionId(); // may be null
+ System.out.println("sessionAccess-previousSessionId: "
+ previousSessionId);
+ if (previousSessionId == null ||
previousSessionId.equals(sessionId) == false) {
+
+ // persist sessionId if different from previously saved
sessionId
+ System.out.println("sessionAccess-savingSessionId:
" + sessionId);
+ saveSessionId(sessionId);
+
+ // new sessions get the full 29 minutes to expire
+
System.out.println("sessionAccess-schedulingSessionTimeout: " +
SESSION_TIMEOUT);
+ sessionTimer.schedule(SESSION_TIMEOUT);
+ } else {
+
+ // existing sessions should expire 29 minutes from the
previous access time
+ long expiryTime = lastAccess + SESSION_TIMEOUT;
+ long expiryMillis = expiryTime - System.currentTimeMillis();
+
+ // can not schedule a time with millis less than or equal to
0
+ if (expiryMillis < 1) {
+ expiryMillis = 1; // expire VERY quickly
+ } else if (expiryMillis > SESSION_TIMEOUT) {
+ expiryMillis = SESSION_TIMEOUT; // guarantees maximum is
29 minutes
+ }
+
+
System.out.println("sessionAccess-reschedulingSessionTimeout: " +
expiryMillis);
+ sessionTimer.schedule((int) expiryMillis);
+ }
+
+ // set the session subject, so the fetch to load the
configuration works
+ Subject subject = new Subject();
+ subject.setId(subjectId);
+ subject.setSessionId(Integer.valueOf(sessionId));
+ sessionSubject = subject;
+
+ SubjectCriteria criteria = new SubjectCriteria();
+ criteria.fetchConfiguration(true);
+ criteria.addFilterId(subjectId);
+
+
GWTServiceLookup.getSubjectService().findSubjectsByCriteria(criteria,
+ new AsyncCallback<PageList<Subject>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(
+ "UserSessionManager: Failed to load
user's subject", caught);
+ System.out.println("Failed to load user's
subject");
+ new LoginView().showLoginDialog();
+ }
+
+ public void onSuccess(PageList<Subject> result) {
+ System.out.println("Found subject");
+ Subject subject = result.get(0);
+ subject.setSessionId(Integer.valueOf(sessionId));
+
+ // reset the session subject to the latest, for
wrapping in user preferences
+ sessionSubject = subject;
+ userPreferences = new
UserPreferences(sessionSubject);
+ refresh();
+
+ callback.onSuccess((Void) null);
+ }
+ });
+ } else {
+ new LoginView().showLoginDialog();
+ }
+ }
+
+ public void onError(Request request, Throwable exception) {
+ callback.onFailure(exception);
+ }
+ });
+ b.send();
+ } catch (RequestException e) {
+ callback.onFailure(e);
+ } finally {
+ BrowserUtility.unforceIe6Hacks();
+ }
+ }
+
+ public static void login() {
+ checkLoginStatus(new AsyncCallback<Void>() {
+ @Override
+ public void onSuccess(Void result) {
+ // will build UI if necessary, then fires history event
+ CoreGUI.get().buildCoreUI();
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ SC.say("Unable to determine login status, check server
status");
+ }
+ });
+ }
+
+ private static void saveSessionId(String sessionId) {
+ Cookies.setCookie(SESSION_NAME, sessionId);
+ }
+
+ private static String getPreviousSessionId() {
+ return Cookies.getCookie(SESSION_NAME);
+ }
+
public static void refresh() {
+ refresh(SESSION_TIMEOUT);
+ }
+
+ private static void refresh(int millis) {
// if quickly logging back in, first cancel the logout timer so that we
// don't have race conditions to the server where the login request beats
// the logout request, which would appear to the user for the login to
@@ -80,7 +214,7 @@ public class UserSessionManager {
// now continue with the rest of the login logic
loggedIn = true;
System.out.println("Refreshing Session Timer");
- sessionTimer.schedule(SESSION_TIMEOUT);
+ sessionTimer.schedule(millis);
}
public static void logout() {
@@ -124,13 +258,19 @@ public class UserSessionManager {
return sessionSubject;
}
- public static void setSessionSubject(Subject subject) {
- sessionSubject = subject;
- userPreferences = new UserPreferences(sessionSubject);
- refresh();
+ public static String getSessionId() {
+ if (sessionSubject == null) {
+ return null;
+ }
+ Integer sessionId = sessionSubject.getSessionId();
+ if (sessionId == null) {
+ return null;
+ }
+ return sessionId.toString();
}
public static UserPreferences getUserPreferences() {
return userPreferences;
}
+
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/AboutModalWindow.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/AboutModalWindow.java
index 2611435..5dc5b91 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/AboutModalWindow.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/AboutModalWindow.java
@@ -18,6 +18,7 @@
*/
package org.rhq.enterprise.gui.coregui.client.components;
+import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.Version;
import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.types.VerticalAlignment;
@@ -29,21 +30,23 @@ import com.smartgwt.client.widgets.events.ClickEvent;
import com.smartgwt.client.widgets.events.ClickHandler;
import com.smartgwt.client.widgets.layout.HLayout;
import com.smartgwt.client.widgets.layout.VLayout;
+
import org.rhq.core.domain.common.ProductInfo;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.Messages;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
/**
* The "About RHQ" modal window.
*
* @author Ian Springer
+ * @author Joseph Marques
*/
public class AboutModalWindow extends Window {
private static final Messages MESSAGES = CoreGUI.getMessages();
- private static final ProductInfo PRODUCT_INFO = CoreGUI.getProductInfo();
+ private static ProductInfo PRODUCT_INFO;
public AboutModalWindow() {
- setTitle(MESSAGES.about_title(PRODUCT_INFO.getFullName()));
setWidth(300);
setHeight(300);
setOverflow(Overflow.VISIBLE);
@@ -59,29 +62,42 @@ public class AboutModalWindow extends Window {
@Override
protected void onInit() {
super.onInit();
-
+
+ if (PRODUCT_INFO == null) {
+ GWTServiceLookup.getSystemService().getProductInfo(new
AsyncCallback<ProductInfo>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to load product
information.", caught);
+ }
+
+ public void onSuccess(ProductInfo result) {
+ PRODUCT_INFO = result;
+ setTitle(MESSAGES.about_title(PRODUCT_INFO.getFullName()));
+
+ finishOnInit();
+ }
+ });
+ } else {
+ finishOnInit();
+ }
+ }
+
+ private void finishOnInit() {
VLayout contentPane = new VLayout();
contentPane.setPadding(15);
contentPane.setMembersMargin(25);
-
+
HTMLFlow htmlFlow = new HTMLFlow();
- String html =
- "<span class=\"DisplaySubhead\">\n" +
- " <a href=\"" + PRODUCT_INFO.getUrl() + "\"
title=\"" + PRODUCT_INFO.getFullName() + " "
- + MESSAGES.about_homepage() + "\"
target=\"_blank\">" + PRODUCT_INFO.getFullName() +
"</a>\n" +
- "</span><br/>\n" +
- "<span class=\"DisplayLabel\">" +
MESSAGES.about_version() + " " + PRODUCT_INFO.getVersion()
- + "</span><br/>\n" +
- "<span class=\"DisplayLabel\">" +
MESSAGES.about_buildNumber() + " " + PRODUCT_INFO.getBuildNumber()
- + "</span><p/>\n" +
- "<span class=\"DisplayLabel\">GWT version: " +
MESSAGES.gwt_version()
- + "</span><br/>\n" +
- "<span class=\"DisplayLabel\">SmartGWT version:
" + Version.getVersion()
- + "</span><br/>\n" +
- "<p><a
href=\"http://jboss.org/\"
title=\"JBoss " + MESSAGES.about_homepage() + "\">\n" +
- " <img height=\"55\" alt=\"" +
MESSAGES.about_jbossByRedHat() + "\"
src=\"/images/jboss_logo.png\">\n" +
- "</a></p>\n" +
- "<div style=\"top-margin: 10px\">" +
MESSAGES.about_allRightsReserved() + "</div>\n";
+ String html = "<span class=\"DisplaySubhead\">\n" +
" <a href=\"" + PRODUCT_INFO.getUrl() + "\"
title=\""
+ + PRODUCT_INFO.getFullName() + " " + MESSAGES.about_homepage() +
"\" target=\"_blank\">"
+ + PRODUCT_INFO.getFullName() + "</a>\n" +
"</span><br/>\n" + "<span
class=\"DisplayLabel\">"
+ + MESSAGES.about_version() + " " + PRODUCT_INFO.getVersion() +
"</span><br/>\n"
+ + "<span class=\"DisplayLabel\">" +
MESSAGES.about_buildNumber() + " " + PRODUCT_INFO.getBuildNumber()
+ + "</span><p/>\n" + "<span
class=\"DisplayLabel\">GWT version: " + MESSAGES.gwt_version()
+ + "</span><br/>\n" + "<span
class=\"DisplayLabel\">SmartGWT version: " + Version.getVersion()
+ + "</span><br/>\n" + "<p><a
href=\"http://jboss.org/\" title=\"JBoss " +
MESSAGES.about_homepage()
+ + "\">\n" + " <img height=\"55\"
alt=\"" + MESSAGES.about_jbossByRedHat()
+ + "\" src=\"/images/jboss_logo.png\">\n" +
"</a></p>\n" + "<div style=\"top-margin:
10px\">"
+ + MESSAGES.about_allRightsReserved() + "</div>\n";
htmlFlow.setContents(html);
contentPane.addMember(htmlFlow);
@@ -106,6 +122,6 @@ public class AboutModalWindow extends Window {
// NOTE: Since this is a subclass of Window, we MUST use addItem(), rather than
addMember() from the
// Layout class.
- addItem(contentPane);
+ addItem(contentPane);
}
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GWTServiceLookup.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GWTServiceLookup.java
index 373f87c..4a9c639 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GWTServiceLookup.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GWTServiceLookup.java
@@ -19,10 +19,10 @@
package org.rhq.enterprise.gui.coregui.client.gwt;
import com.google.gwt.http.client.RequestBuilder;
-import com.google.gwt.user.client.Cookies;
import com.google.gwt.user.client.rpc.RpcRequestBuilder;
import com.google.gwt.user.client.rpc.ServiceDefTarget;
+import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
import org.rhq.enterprise.gui.coregui.client.util.rpc.MonitoringRequestCallback;
/**
@@ -34,8 +34,6 @@ import
org.rhq.enterprise.gui.coregui.client.util.rpc.MonitoringRequestCallback;
*/
public class GWTServiceLookup {
- public static final String SESSION_NAME = "RHQ_Sesssion";
-
public static AlertDefinitionGWTServiceAsync getAlertDefinitionService() {
return secure(AlertDefinitionGWTServiceAsync.Util.getInstance());
}
@@ -128,6 +126,7 @@ public class GWTServiceLookup {
return secure(ClusterGWTServiceAsync.Util.getInstance());
}
+ @SuppressWarnings("unchecked")
private static <T> T secure(Object sdt) {
if (!(sdt instanceof ServiceDefTarget))
return null;
@@ -137,10 +136,6 @@ public class GWTServiceLookup {
return (T) sdt;
}
- public static void registerSession(String sessionId) {
- Cookies.setCookie(SESSION_NAME, sessionId);
- }
-
public static class SessionRpcRequestBuilder extends RpcRequestBuilder {
@Override
@@ -155,9 +150,9 @@ public class GWTServiceLookup {
// TODO Don't use the expensive determineName except in dev mode
rb.setCallback(new MonitoringRequestCallback(determineName(),
rb.getCallback()));
- String sid = Cookies.getCookie(SESSION_NAME);
- if (sid != null) {
- rb.setHeader(SESSION_NAME, sid);
+ String sessionId = UserSessionManager.getSessionId();
+ if (sessionId != null) {
+ rb.setHeader(UserSessionManager.SESSION_NAME, sessionId);
}
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/preferences/UserPreferences.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/preferences/UserPreferences.java
index 62c88dd..bfffc33 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/preferences/UserPreferences.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/preferences/UserPreferences.java
@@ -18,13 +18,6 @@
*/
package org.rhq.enterprise.gui.coregui.client.util.preferences;
-import com.google.gwt.user.client.rpc.AsyncCallback;
-import org.rhq.core.domain.auth.Subject;
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.PropertySimple;
-import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
-import org.rhq.enterprise.gui.coregui.client.gwt.SubjectGWTServiceAsync;
-
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -33,6 +26,14 @@ import java.util.List;
import java.util.Set;
import java.util.TreeSet;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.gwt.SubjectGWTServiceAsync;
+
/**
* @author Greg Hinkle
* @author Ian Springer
@@ -47,9 +48,8 @@ public class UserPreferences {
private ArrayList<UserPreferenceChangeListener> changeListeners = new
ArrayList<UserPreferenceChangeListener>();
-
public UserPreferences(Subject subject) {
- this.subject = subject;
+ this.subject = subject;
this.userConfiguration = subject.getUserConfiguration();
}
@@ -71,14 +71,11 @@ public class UserPreferences {
store(callback);
}
-
-
-
protected String getPreference(String name) {
return userConfiguration.getSimpleValue(name, null);
}
- protected void setPreference(String name, Collection value) {
+ protected void setPreference(String name, Collection<?> value) {
StringBuilder buffer = new StringBuilder();
boolean first = true;
for (Object item : value) {
@@ -108,24 +105,21 @@ public class UserPreferences {
}
}
-
public void store(AsyncCallback<Subject> callback) {
this.subjectService.updateSubject(this.subject, callback);
}
-
public Configuration getConfiguration() {
return userConfiguration;
}
-
public List<String> getPreferenceAsList(String key) {
String pref = null;
try {
pref = getPreference(key);
} catch (IllegalArgumentException e) {
-// log.debug("A user preference named '" + key + "'
does not exist.");
+ // log.debug("A user preference named '" + key +
"' does not exist.");
}
return (pref != null) ? Arrays.asList(pref.split(PREF_LIST_DELIM_REGEX)) : new
ArrayList<String>();
@@ -149,7 +143,6 @@ public class UserPreferences {
}
}
-
public void addChangeListener(UserPreferenceChangeListener listener) {
changeListeners.add(listener);
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/rpc/MonitoringRequestCallback.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/rpc/MonitoringRequestCallback.java
index 9b80112..434d06d 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/rpc/MonitoringRequestCallback.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/rpc/MonitoringRequestCallback.java
@@ -21,14 +21,18 @@ package org.rhq.enterprise.gui.coregui.client.util.rpc;
import com.google.gwt.http.client.Request;
import com.google.gwt.http.client.RequestCallback;
import com.google.gwt.http.client.Response;
+import com.google.gwt.user.client.History;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.util.SC;
-import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
/**
* @author Greg Hinkle
*/
public class MonitoringRequestCallback implements RequestCallback {
+ @SuppressWarnings("unused")
private int id;
private String name;
private long start = System.currentTimeMillis();
@@ -52,11 +56,25 @@ public class MonitoringRequestCallback implements RequestCallback {
if (STATUS_CODE_OK == response.getStatusCode()) {
RPCManager.getInstance().succeedCall(this);
callback.onResponseReceived(request, response);
+ System.out.println("MonitoringRequestCallback: OK");
} else {
RPCManager.getInstance().failCall(this);
callback.onResponseReceived(request, response);
+ System.out.println("MonitoringRequestCallback: " +
response.getStatusCode() + "/"
+ + response.getStatusText());
- CoreGUI.checkLoginStatus();
+ // if we have a rich and coordinated client-side loggedIn state, do we need
to check upon failure here?
+ UserSessionManager.checkLoginStatus(new AsyncCallback<Void>() {
+ @Override
+ public void onSuccess(Void result) {
+ History.fireCurrentHistoryState();
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ SC.say("Unable to determine login status, check server
status");
+ }
+ });
}
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AbstractGWTServiceImpl.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AbstractGWTServiceImpl.java
index 6aaafdd..ae1e85b 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AbstractGWTServiceImpl.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AbstractGWTServiceImpl.java
@@ -27,7 +27,7 @@ import javax.servlet.http.HttpServletResponse;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import org.rhq.core.domain.auth.Subject;
-import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
import org.rhq.enterprise.server.auth.SubjectManagerLocal;
import org.rhq.enterprise.server.util.HibernatePerformanceMonitor;
import org.rhq.enterprise.server.util.LookupUtil;
@@ -45,7 +45,7 @@ public abstract class AbstractGWTServiceImpl extends
RemoteServiceServlet {
@Override
protected void service(HttpServletRequest req, HttpServletResponse resp) throws
ServletException, IOException {
- String sid = req.getHeader(GWTServiceLookup.SESSION_NAME);
+ String sid = req.getHeader(UserSessionManager.SESSION_NAME);
Subject subject = null;
if (sid != null) {
SubjectManagerLocal subjectManager = LookupUtil.getSubjectManager();
diff --git
a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/authentication/SessionAccessServlet.java
b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/authentication/SessionAccessServlet.java
index 08911dd..6739824 100644
---
a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/authentication/SessionAccessServlet.java
+++
b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/authentication/SessionAccessServlet.java
@@ -24,12 +24,8 @@ package org.rhq.enterprise.gui.authentication;
import java.io.IOException;
-import javax.servlet.Servlet;
-import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -45,14 +41,15 @@ import org.rhq.enterprise.server.auth.SessionTimeoutException;
/**
* @author Greg Hinkle
+ * @author Joseph Marques
*/
public class SessionAccessServlet extends HttpServlet {
+ private static final long serialVersionUID = 1L;
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws
ServletException, IOException {
-
HttpServletResponse response = (HttpServletResponse) resp;
HttpServletRequest request = (HttpServletRequest) req;
@@ -67,32 +64,24 @@ public class SessionAccessServlet extends HttpServlet {
//if a session does not already exist this call will create one
HttpSession session = request.getSession();
- /* check if the user object is in the session.
- * if not then the user is not validated and should be forwarded to the login
page
+ /*
+ * check if the user object is in the session. if not, then the user is not
validated, the response output
+ * will not contain the
"<subjectId>:<sessionId>:<lastAccess>", which will forward the
user to the login page
*/
WebUser webUser = SessionUtils.getWebUser(session);
-
-
if (webUser != null && webUser.getSubject() != null) {
// the web user exists, so update our SessionManager's session
last-access-time
Subject subject = webUser.getSubject();
try {
-
SessionManager.getInstance().getSubject(subject.getSessionId());
-
+ long lastAccess =
SessionManager.getInstance().getlastAccess(subject.getSessionId());
ServletOutputStream out = response.getOutputStream();
-
- String output =
- String.valueOf(webUser.getSubject().getId()) + ":" +
- String.valueOf(webUser.getSessionId());
-
+ String output = subject.getId() + ":" + webUser.getSessionId()
+ ":" + lastAccess;
out.write(output.getBytes());
-
-
} catch (SessionNotFoundException snfe) {
session.removeAttribute(ParamConstants.USER_PARAM);
SessionUtils.setWebUser(session, null);
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/AuthSession.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/AuthSession.java
index 55ef32e..ea5d48d 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/AuthSession.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/AuthSession.java
@@ -80,4 +80,8 @@ class AuthSession {
protected boolean isExpired() {
return System.currentTimeMillis() > (_lastAccess + _timeout);
}
+
+ public long getLastAccess() {
+ return _lastAccess;
+ }
}
\ No newline at end of file
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SessionManager.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SessionManager.java
index dce87b3..58cbe8b 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SessionManager.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SessionManager.java
@@ -200,6 +200,14 @@ public class SessionManager {
return;
}
+ public long getlastAccess(int sessionId) {
+ AuthSession session = _cache.get(sessionId);
+ if (session == null) {
+ return -1;
+ }
+ return session.getLastAccess();
+ }
+
public Subject getOverlord() {
if (overlordSubject == null) {
overlordSubject =
LookupUtil.getSubjectManager().getSubjectById(OVERLORD_SUBJECT_ID);
commit d3c6b01e6faaacae78153acd40ba2eaae076cbad
Author: Joseph Marques <joseph(a)redhat.com>
Date: Mon Sep 27 14:08:22 2010 -0400
centralize and simplify browser quirk handling
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 1dd1250..a1d8475 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
@@ -56,6 +56,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.util.BrowserUtility;
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.MessageCenter;
@@ -142,9 +143,7 @@ public class CoreGUI implements EntryPoint,
ValueChangeHandler<String> {
// String sessionIdString =
com.google.gwt.user.client.Cookies.getCookie("RHQ_Sesssion");
// if (sessionIdString == null) {
- if (detectIe6()) {
- forceIe6Hacks();
- }
+ BrowserUtility.forceIe6Hacks();
RequestBuilder b = new RequestBuilder(RequestBuilder.GET,
"/sessionAccess");
try {
@@ -204,9 +203,7 @@ public class CoreGUI implements EntryPoint,
ValueChangeHandler<String> {
SC.say("Unable to determine login status, check server status");
e.printStackTrace();
} finally {
- if (detectIe6()) {
- unforceIe6Hacks();
- }
+ BrowserUtility.unforceIe6Hacks();
}
}
@@ -415,30 +412,4 @@ public class CoreGUI implements EntryPoint,
ValueChangeHandler<String> {
}
}
- /**
- * Detects IE6.
- * <p/>
- * This is a nasty hack; but it's extremely reliable when running with other
- * js libraries on the same page at the same time as gwt.
- */
- public static native boolean detectIe6()
- /*-{
- if (typeof $doc.body.style.maxHeight != "undefined")
- return(false);
- else
- return(true);
- }-*/;
-
- public static native void forceIe6Hacks()
- /*-{
- $wnd.XMLHttpRequestBackup = $wnd.XMLHttpRequest;
- $wnd.XMLHttpRequest = null;
- }-*/;
-
- public static native void unforceIe6Hacks()
- /*-{
- $wnd.XMLHttpRequest = $wnd.XMLHttpRequestBackup;
- $wnd.XMLHttpRequestBackup = null;
- }-*/;
-
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java
index 0f660c3..f6758e9 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java
@@ -44,6 +44,8 @@ import com.smartgwt.client.widgets.form.fields.TextItem;
import com.smartgwt.client.widgets.form.fields.events.KeyPressEvent;
import com.smartgwt.client.widgets.form.fields.events.KeyPressHandler;
+import org.rhq.enterprise.gui.coregui.client.util.BrowserUtility;
+
/**
* @author Greg Hinkle
* @author Joseph Marques
@@ -135,9 +137,7 @@ public class LoginView extends Canvas {
}
private void login(String user, String password) {
- if (CoreGUI.detectIe6()) {
- CoreGUI.forceIe6Hacks();
- }
+ BrowserUtility.forceIe6Hacks();
loginButton.setDisabled(true);
@@ -165,9 +165,7 @@ public class LoginView extends Canvas {
} catch (Exception e) {
handleError(0);
} finally {
- if (CoreGUI.detectIe6()) {
- CoreGUI.unforceIe6Hacks();
- }
+ BrowserUtility.unforceIe6Hacks();
}
/*
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/SearchGUI.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/SearchGUI.java
index 3ec02b3..6312e93 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/SearchGUI.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/SearchGUI.java
@@ -32,6 +32,7 @@ import org.rhq.core.domain.criteria.SubjectCriteria;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.search.SearchBar;
+import org.rhq.enterprise.gui.coregui.client.util.BrowserUtility;
/**
* @author Joseph Marques
@@ -63,9 +64,7 @@ public class SearchGUI implements EntryPoint {
public static void checkLoginStatus() {
- if (CoreGUI.detectIe6()) {
- CoreGUI.forceIe6Hacks();
- }
+ BrowserUtility.forceIe6Hacks();
RequestBuilder b = new RequestBuilder(RequestBuilder.GET,
"/sessionAccess");
try {
@@ -120,9 +119,7 @@ public class SearchGUI implements EntryPoint {
SC.say("Unable to determine login status, check server status");
e.printStackTrace();
} finally {
- if (CoreGUI.detectIe6()) {
- CoreGUI.unforceIe6Hacks();
- }
+ BrowserUtility.unforceIe6Hacks();
}
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/BrowserUtility.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/BrowserUtility.java
new file mode 100644
index 0000000..f9549fb
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/BrowserUtility.java
@@ -0,0 +1,58 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.util;
+
+/**
+ * Utility class for dealing with browser quirks.
+ *
+ * @author Joseph Marques
+ */
+public class BrowserUtility {
+ private BrowserUtility() {
+ // static access only
+ }
+
+ /*
+ * Adapted from
http://code.google.com/p/google-web-toolkit/issues/detail?id=3608
+ *
+ * Should
+ */
+ public static native void forceIe6Hacks()
+ /*-{
+ if (typeof $doc.body.style.maxHeight == "undefined") {
+ $wnd.XMLHttpRequestBackup = $wnd.XMLHttpRequest;
+ $wnd.XMLHttpRequest = null;
+ }
+ }-*/;
+
+ /*
+ * Adapted from
http://code.google.com/p/google-web-toolkit/issues/detail?id=3608
+ */
+ public static native void unforceIe6Hacks()
+ /*-{
+ if (typeof $doc.body.style.maxHeight == "undefined") {
+ $wnd.XMLHttpRequest = $wnd.XMLHttpRequestBackup;
+ $wnd.XMLHttpRequestBackup = null;
+ }
+ }-*/;
+}
commit 71cb2ad0a3edc89631e781869e528107e97a9230
Author: Joseph Marques <joseph(a)redhat.com>
Date: Sun Sep 26 11:44:23 2010 -0400
remove erroneous cast
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java
index b61458f..f4137b2 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java
@@ -251,7 +251,7 @@ public abstract class RPCDataSource<T> extends DataSource {
S[] resultArray = null;
- Object value = (String) criteriaMap.get(paramName);
+ Object value = criteriaMap.get(paramName);
if (value == null) {
// nothing to do, result is already null
} else if (type == Integer.class) {
commit 4cf00dc96f7cd2e784d9a5d7fc6779132f2ac0e1
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Sep 29 15:16:11 2010 -0400
get the notification editor to show a list of notifs. very preliminary right now.
can't edit - just read-only
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java
index db9aeaa..18931c0 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java
@@ -23,18 +23,43 @@
package org.rhq.enterprise.gui.coregui.client.alert.definitions;
+import java.util.ArrayList;
+import java.util.List;
+
+import com.smartgwt.client.data.DSRequest;
+import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.fields.DataSourceTextField;
+import com.smartgwt.client.types.Overflow;
+import com.smartgwt.client.widgets.Window;
+import com.smartgwt.client.widgets.events.CloseClickHandler;
+import com.smartgwt.client.widgets.events.CloseClientEvent;
+import com.smartgwt.client.widgets.grid.ListGridField;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+
import org.rhq.core.domain.alert.AlertDefinition;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
+import org.rhq.core.domain.alert.notification.AlertNotification;
+import org.rhq.enterprise.gui.coregui.client.components.table.Table;
+import org.rhq.enterprise.gui.coregui.client.components.table.TableAction;
+import org.rhq.enterprise.gui.coregui.client.components.table.Table.SelectionEnablement;
+import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableWindow;
/**
* @author John Mazzitelli
*/
-public class NotificationsAlertDefinitionForm extends LocatableDynamicForm implements
EditAlertDefinitionForm {
+public class NotificationsAlertDefinitionForm extends LocatableVLayout implements
EditAlertDefinitionForm {
+ private static final String FIELD_OBJECT = "obj";
+ private static final String FIELD_SENDER = "sender";
+ private static final String FIELD_CONFIGURATION = "configuration";
private AlertDefinition alertDefinition;
+ private ArrayList<AlertNotification> notifications;
private boolean formBuilt = false;
+ private Table table;
+
public NotificationsAlertDefinitionForm(String locatorId) {
this(locatorId, null);
}
@@ -42,6 +67,7 @@ public class NotificationsAlertDefinitionForm extends
LocatableDynamicForm imple
public NotificationsAlertDefinitionForm(String locatorId, AlertDefinition
alertDefinition) {
super(locatorId);
this.alertDefinition = alertDefinition;
+ extractShallowCopyOfNotifications(this.alertDefinition);
}
@Override
@@ -69,7 +95,10 @@ public class NotificationsAlertDefinitionForm extends
LocatableDynamicForm imple
if (alertDef == null) {
clearFormValues();
} else {
- // TODO set values of the components
+ extractShallowCopyOfNotifications(alertDefinition);
+ if (table != null) {
+ table.refresh();
+ }
}
markForRedraw();
@@ -77,36 +106,155 @@ public class NotificationsAlertDefinitionForm extends
LocatableDynamicForm imple
@Override
public void makeEditable() {
- // TODO Auto-generated method stub
-
+ table.setTableActionDisableOverride(false);
markForRedraw();
}
@Override
public void makeViewOnly() {
- // TODO Auto-generated method stub
-
+ table.setTableActionDisableOverride(true);
markForRedraw();
}
@Override
public void saveAlertDefinition() {
- // TODO Auto-generated method stub
+ alertDefinition.setAlertNotifications(notifications);
+
+ // make our own new internal copy since we gave ours to the definition object
+ extractShallowCopyOfNotifications(alertDefinition);
}
@Override
public void clearFormValues() {
- // TODO component.clearValue();
-
+ notifications.clear();
+ if (table != null) {
+ table.refresh();
+ }
markForRedraw();
}
private void buildForm() {
if (!formBuilt) {
- // TODO buildNodes components
- // TODO setFields(components);
+
+ table = new
NotificationTable(extendLocatorId("notificationsTable"));
+ table.setShowHeader(false);
+
+ final NotificationDataSource dataSource = new NotificationDataSource();
+ table.setDataSource(dataSource);
+
+ table.addTableAction(this.extendLocatorId("add"), "Add",
SelectionEnablement.ALWAYS, null,
+ new TableAction() {
+ @Override
+ public void executeAction(ListGridRecord[] selection) {
+ final Window winModal = new
LocatableWindow(NotificationsAlertDefinitionForm.this
+ .extendLocatorId("newNotificationEditorWindow"));
+ winModal.setTitle("Add Notification");
+ winModal.setOverflow(Overflow.VISIBLE);
+ winModal.setShowMinimizeButton(false);
+ winModal.setIsModal(true);
+ winModal.setShowModalMask(true);
+ winModal.setAutoSize(true);
+ winModal.setAutoCenter(true);
+ //winModal.setShowResizer(true);
+ //winModal.setCanDragResize(true);
+ winModal.centerInPage();
+ winModal.addCloseClickHandler(new CloseClickHandler() {
+ @Override
+ public void onCloseClick(CloseClientEvent event) {
+ winModal.markForDestroy();
+ }
+ });
+
+ // NewNotificationEditor newEditor = new NewNotificationEditor(
+ // extendLocatorId("newNotificationEditor"),
notifications, new Runnable() {
+ // @Override
+ // public void run() {
+ // winModal.markForDestroy();
+ // table.refresh();
+ // }
+ // });
+ /// winModal.addItem(newEditor);
+ winModal.show();
+ }
+ });
+ table.addTableAction(this.extendLocatorId("delete"),
"Delete", SelectionEnablement.ANY, "Are you sure?",
+ new TableAction() {
+ @Override
+ public void executeAction(ListGridRecord[] selection) {
+ for (ListGridRecord record : selection) {
+ AlertNotification notif = dataSource.copyValues(record);
+ notifications.remove(notif);
+ }
+ table.refresh();
+ }
+ });
+
+ addMember(table);
formBuilt = true;
}
}
+
+ private void extractShallowCopyOfNotifications(AlertDefinition alertDefinition) {
+ List<AlertNotification> notifs = null;
+ if (alertDefinition != null) {
+ notifs = alertDefinition.getAlertNotifications();
+ }
+
+ // make our own shallow copy of the collection
+ if (notifs != null) {
+ this.notifications = new ArrayList<AlertNotification>(notifs);
+ } else {
+ this.notifications = new ArrayList<AlertNotification>();
+ }
+ }
+
+ private class NotificationDataSource extends RPCDataSource<AlertNotification>
{
+ public NotificationDataSource() {
+ DataSourceTextField senderField = new DataSourceTextField(FIELD_SENDER,
"Sender");
+ addField(senderField);
+
+ DataSourceTextField configField = new
DataSourceTextField(FIELD_CONFIGURATION, "Configuration");
+ addField(configField);
+ }
+
+ @Override
+ public AlertNotification copyValues(ListGridRecord from) {
+ return (AlertNotification) from.getAttributeAsObject(FIELD_OBJECT);
+ }
+
+ @Override
+ public ListGridRecord copyValues(AlertNotification from) {
+ ListGridRecord record = new ListGridRecord();
+ record.setAttribute(FIELD_SENDER, from.getSenderName());
+ record.setAttribute(FIELD_CONFIGURATION,
from.getConfiguration().toString(false));
+ // TODO configuration should be the string of
+
//getAlertManager().getAlertPluginManager().getAlertSenderForNotification(alertNotification).previewConfiguration()
+ // TODO what's this extra configuration in the notification?
+
+ record.setAttribute(FIELD_OBJECT, from);
+ return record;
+ }
+
+ @Override
+ protected void executeFetch(DSRequest request, DSResponse response) {
+ response.setData(buildRecords(notifications));
+ processResponse(request.getRequestId(), response);
+ }
+ }
+
+ private class NotificationTable extends Table {
+ public NotificationTable(String locatorId) {
+ super(locatorId);
+ }
+
+ @Override
+ protected void configureTable() {
+ ListGridField senderField = new ListGridField(FIELD_SENDER,
"Sender");
+ senderField.setWidth("25%");
+ ListGridField configField = new ListGridField(FIELD_CONFIGURATION,
"Configuration");
+ configField.setWidth("75%");
+ getListGrid().setFields(senderField, configField);
+ }
+ }
}
commit f7be27b6647ae745914ffa08435058e4fef00dc7
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Wed Sep 29 12:56:25 2010 -0400
add support for generating the runs-inside element within a server or service element
diff --git
a/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/PluginGen.java
b/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/PluginGen.java
index 69587d0..be39d9d 100644
--- a/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/PluginGen.java
+++ b/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/PluginGen.java
@@ -308,7 +308,7 @@ public class PluginGen {
}
/**
- * Translate a packgage into a filesystem path
+ * Translate a package into a filesystem path
* @param pkg Package in standard notation like com.acme.plugins
* @param separator File separator
* @return a path suitable to pass to File
diff --git a/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Props.java
b/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Props.java
index a657f42..bc1fc64 100644
--- a/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Props.java
+++ b/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Props.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
+ * Copyright (C) 2005-2010 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -71,14 +71,14 @@ public class Props {
private boolean deleteChildren;
/** Use externals chars in the plugin jar ? */
private boolean usesExternalJarsInPlugin;
- /** Does it support manuall add of children ? */
+ /** Does it support manual add of children ? */
private boolean manualAddOfResourceType;
/** Does it use the PluginLifecycleListener api ? */
private boolean usePluginLifecycleListenerApi;
/** Depends on JMX plugin ? */
private boolean dependsOnJmxPlugin;
/** What version of RHQ should this plugin's pom use ? */
- private String rhqVersion = "1.4.0-SNAPSHOT";
+ private String rhqVersion = "3.0.0";
/** Embedded children */
private Set<Props> children = new HashSet<Props>();
@@ -91,6 +91,8 @@ public class Props {
private Set<OperationProps> operations = new
LinkedHashSet<OperationProps>();;
+ private Set<TypeKey> runsInsides = new LinkedHashSet<TypeKey>();;
+
private String pluginName;
private String pluginDescription;
@@ -326,7 +328,15 @@ public class Props {
this.pluginDescription = pluginDescription;
}
- public void populateMetrics(List<Class> classes) {
+ public Set<TypeKey> getRunsInsides() {
+ return runsInsides;
+ }
+
+ public void setRunsInsides(Set<TypeKey> runsInsides) {
+ this.runsInsides = runsInsides;
+ }
+
+ public void populateMetrics(List<Class> classes) {
for (Class<?> clazz : classes) {
Metric metricAnnot = clazz.getAnnotation(Metric.class);
if (metricAnnot != null) {
@@ -372,10 +382,37 @@ public class Props {
sb.append(", children=").append(children);
sb.append(", simpleProps=").append(simpleProps);
sb.append(", templates=").append(templates);
+ sb.append(", runsInsides=").append(runsInsides);
sb.append('}');
return sb.toString();
}
+ public static class TypeKey {
+ private String name;
+ private String pluginName;
+
+ public TypeKey(String name, String pluginName) {
+ this.name = name;
+ this.pluginName = pluginName;
+ }
+
+ public String getPluginName() {
+ return pluginName;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public String toString() {
+ return "TypeKey{" +
+ "name='" + name + '\'' +
+ ", pluginName='" + pluginName + '\'' +
+ '}';
+ }
+ }
+
public static class SimpleProperty {
private final String name;
private String description;
@@ -431,7 +468,6 @@ public class Props {
public void setDefaultValue(String defaultValue) {
this.defaultValue = defaultValue;
}
-
}
public static class Template {
@@ -519,7 +555,6 @@ public class Props {
public String getProperty() {
return property;
}
-
}
public static class OperationProps {
diff --git a/modules/helpers/pluginGen/src/main/resources/descriptorMain.ftl
b/modules/helpers/pluginGen/src/main/resources/descriptorMain.ftl
index 0343787..b650f7a 100644
--- a/modules/helpers/pluginGen/src/main/resources/descriptorMain.ftl
+++ b/modules/helpers/pluginGen/src/main/resources/descriptorMain.ftl
@@ -1,7 +1,7 @@
<#--
/*
* RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
+ * Copyright (C) 2005-2010 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -24,7 +24,7 @@
platform/server/service. It is called by descriptor.ftl
-->
-name="${props.name}" <#-- TODO separate out plugin name and service name
-->
+name="${props.name}"
discovery="${props.discoveryClass}"
class="${props.componentClass}"
<#if props.singleton>singleton="true"</#if>
@@ -32,6 +32,14 @@ name="${props.name}" <#-- TODO separate out plugin name
and service name -->
<#if props.createChildren &&
props.deleteChildren>createDeletePolicy="both"<#elseif
props.createChildren &&
!props.deleteChildren>createDeletePolicy="create-only"<#elseif
!props.createChildren &&
props.deleteChildren>createDeletePolicy="delete-only"<#else > <#--
Dont mention it, as 'neither' is default --></#if>
+ <#if props.runsInsides?has_content>
+ <runs-inside>
+ <#list props.runsInsides as typeKey>
+ <parent-resource-type name="${typeKey.name}"
plugin="${typeKey.pluginName}"/>
+ </#list>
+ </runs-inside>
+ </#if>
+
<#if props.simpleProps?has_content>
<plugin-configuration>
<#list props.simpleProps as simpleProps>
commit c99febcffec0ca846f5463f863434cb7e6d9cf86
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Tue Sep 28 18:00:02 2010 -0400
get rid of spaces in view IDs, and use camelCase instead; add more view ID constants;
misc minor refactoring
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/util/StringUtils.java
b/modules/core/domain/src/main/java/org/rhq/core/domain/util/StringUtils.java
index 676ae61..88c08ee 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/util/StringUtils.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/util/StringUtils.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
+ * Copyright (C) 2005-2010 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -23,11 +23,19 @@
package org.rhq.core.domain.util;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
public class StringUtils {
+ private static final Set<String> LOWERCASE_WORDS = new
HashSet<String>();
+ static {
+ LOWERCASE_WORDS.add("And");
+ LOWERCASE_WORDS.add("Or");
+ }
+
/*
- * Take somethin that is camel-cased, add spaces between the words, and capitalize
each word
+ * Take something that is camel-cased, add spaces between the words, and capitalize
each word.
*/
public static String deCamelCase(String target) {
if (target.length() == 0) {
@@ -44,7 +52,7 @@ public class StringUtils {
target = target.substring(0, target.length() - 1);
}
- int nextDash = 0;
+ int nextDash;
while ((nextDash = target.indexOf('-')) > 0) {
target = target.substring(0, nextDash) +
Character.toUpperCase(target.charAt(nextDash + 1))
+ target.substring(nextDash + 2);
@@ -52,26 +60,41 @@ public class StringUtils {
result.append(Character.toUpperCase(target.charAt(0)));
- char next;
- char last = target.charAt(0);
+ StringBuilder currentWord = new StringBuilder();
+ char currentChar;
+ char previousChar = target.charAt(0);
for (int i = 1; i < target.length(); i++) {
- next = target.charAt(i);
+ currentChar = target.charAt(i);
// Obey multi-digit numbers and acronyms
- if ((Character.isDigit(next) && !Character.isDigit(last))
- || (Character.isUpperCase(next) && (!Character.isUpperCase(last)
|| ((i < (target.length() - 1)) && Character
- .isLowerCase(target.charAt(i + 1)))))) {
- // at the start of another word, add a space
+ if ((Character.isDigit(currentChar) &&
!Character.isDigit(previousChar))
+ || (Character.isUpperCase(currentChar) &&
(!Character.isUpperCase(previousChar)
+ || ((i < (target.length() - 1)) &&
Character.isLowerCase(target.charAt(i + 1)))))) {
+ // We're at the start of a new word.
+ appendWord(result, currentWord);
+ currentWord = new StringBuilder();
+ // Append a space before the next word.
result.append(' ');
}
- result.append(next);
- last = next;
+ currentWord.append(currentChar);
+ previousChar = currentChar;
}
+ // Append the final word.
+ appendWord(result, currentWord);
return result.toString();
}
+ private static void appendWord(StringBuilder result, StringBuilder nextWord) {
+ String word = nextWord.toString();
+ if (LOWERCASE_WORDS.contains(word)) {
+ result.append(word.toLowerCase());
+ } else {
+ result.append(word);
+ }
+ }
+
public static List<String> getStringAsList(String input, String regexSplitter,
boolean ignoreEmptyTokens) {
List<String> results = new ArrayList<String>();
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 b0cd874..37770eb 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
@@ -21,6 +21,7 @@ package org.rhq.enterprise.gui.coregui.client.admin;
import java.util.LinkedHashMap;
import java.util.Map;
+import com.google.gwt.user.client.History;
import com.smartgwt.client.types.VisibilityMode;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.HTMLFlow;
@@ -40,6 +41,7 @@ import
org.rhq.enterprise.gui.coregui.client.admin.agent.install.RemoteAgentInst
import org.rhq.enterprise.gui.coregui.client.admin.roles.RolesView;
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;
@@ -59,6 +61,10 @@ public class AdministrationView extends LocatableHLayout implements
Bookmarkable
private Canvas currentContent;
private Map<String, TreeGrid> treeGrids = new LinkedHashMap<String,
TreeGrid>();
+ private static final String SECURITY_SECTION_VIEW_ID = "Security";
+ private static final String TOPOLOGY_SECTION_VIEW_ID = "Topology";
+ private static final String CONFIGURATION_SECTION_VIEW_ID =
"Configuration";
+
public AdministrationView(String locatorId) {
super(locatorId);
}
@@ -80,30 +86,37 @@ public class AdministrationView extends LocatableHLayout implements
Bookmarkable
sectionStack.setWidth(250);
sectionStack.setHeight100();
- treeGrids.put("Security", buildSecuritySection());
- treeGrids.put("Configuration", buildSystemConfigurationSection());
- treeGrids.put("Cluster", buildManagementClusterSection());
+ addSection(buildSecuritySection());
+ addSection(buildSystemConfigurationSection());
+ addSection(buildManagementClusterSection());
- for (final String name : treeGrids.keySet()) {
- TreeGrid grid = treeGrids.get(name);
+ addMember(sectionStack);
+ addMember(contentCanvas);
+ }
- grid.addSelectionChangedHandler(new SelectionChangedHandler() {
- public void onSelectionChanged(SelectionEvent selectionEvent) {
- if (selectionEvent.getState()) {
- CoreGUI.goToView("Administration/" + name +
"/" + selectionEvent.getRecord().getAttribute("name"));
+ 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 = AdministrationView.VIEW_ID + "/" +
sectionName + "/" + pageName;
+ String currentViewPath = History.getToken();
+ if (!currentViewPath.startsWith(viewPath)) {
+ CoreGUI.goToView(viewPath);
}
}
- });
-
- SectionStackSection section = new SectionStackSection(name);
- section.setExpanded(true);
- section.addItem(grid);
+ }
+ });
- sectionStack.addSection(section);
- }
+ SectionStackSection section = new SectionStackSection(sectionName);
+ section.setExpanded(true);
+ section.addItem(treeGrid);
- addMember(sectionStack);
- addMember(contentCanvas);
+ this.sectionStack.addSection(section);
}
private HTMLFlow defaultView() {
@@ -117,21 +130,23 @@ public class AdministrationView extends LocatableHLayout implements
Bookmarkable
private TreeGrid buildSecuritySection() {
- final TreeGrid securityTreeGrid = new LocatableTreeGrid("Security");
+ final TreeGrid securityTreeGrid = new
LocatableTreeGrid(SECURITY_SECTION_VIEW_ID);
securityTreeGrid.setLeaveScrollbarGap(false);
securityTreeGrid.setShowHeader(false);
Tree tree = new Tree();
- final TreeNode manageUsersNode = new TreeNode("Manage Users");
+ final TreeNode manageUsersNode = new EnhancedTreeNode(UsersView.VIEW_ID);
manageUsersNode.setIcon("global/User_16.png");
- final TreeNode manageRolesNode = new TreeNode("Manage Roles");
+ final TreeNode manageRolesNode = new EnhancedTreeNode(RolesView.VIEW_ID);
manageRolesNode.setIcon("global/Role_16.png");
- final TreeNode remoteAgentInstall = new TreeNode("Remote Agent
Install");
+ final TreeNode remoteAgentInstall = new
EnhancedTreeNode(RemoteAgentInstallView.VIEW_ID);
remoteAgentInstall.setIcon("global/Agent_16.png");
- tree.setRoot(new TreeNode("security", manageUsersNode, manageRolesNode,
remoteAgentInstall));
+ TreeNode rootNode = new EnhancedTreeNode(SECURITY_SECTION_VIEW_ID,
manageUsersNode, manageRolesNode,
+ remoteAgentInstall);
+ tree.setRoot(rootNode);
securityTreeGrid.setData(tree);
@@ -140,18 +155,19 @@ public class AdministrationView extends LocatableHLayout implements
Bookmarkable
private TreeGrid buildManagementClusterSection() {
- final TreeGrid mgmtClusterTreeGrid = new
LocatableTreeGrid("Topology");
+ final TreeGrid mgmtClusterTreeGrid = new
LocatableTreeGrid(TOPOLOGY_SECTION_VIEW_ID);
mgmtClusterTreeGrid.setLeaveScrollbarGap(false);
mgmtClusterTreeGrid.setShowHeader(false);
Tree tree = new Tree();
- final TreeNode manageServersNode = new TreeNode("Servers");
- final TreeNode manageAgentsNode = new TreeNode("Agents");
- final TreeNode manageAffinityGroupsNode = new TreeNode("Affinity
Groups");
- final TreeNode managePartitionEventsNode = new TreeNode("Partition
Events");
+ final TreeNode manageServersNode = new EnhancedTreeNode("Servers");
+ final TreeNode manageAgentsNode = new EnhancedTreeNode("Agents");
+ final TreeNode manageAffinityGroupsNode = new
EnhancedTreeNode("AffinityGroups");
+ final TreeNode managePartitionEventsNode = new
EnhancedTreeNode("PartitionEvents");
- tree.setRoot(new TreeNode("clustering", manageServersNode,
manageAgentsNode, manageAffinityGroupsNode,
- managePartitionEventsNode));
+ TreeNode rootNode = new EnhancedTreeNode(TOPOLOGY_SECTION_VIEW_ID,
manageServersNode, manageAgentsNode,
+ manageAffinityGroupsNode, managePartitionEventsNode);
+ tree.setRoot(rootNode);
mgmtClusterTreeGrid.setData(tree);
@@ -160,19 +176,20 @@ public class AdministrationView extends LocatableHLayout implements
Bookmarkable
private TreeGrid buildSystemConfigurationSection() {
- final TreeGrid systemConfigTreeGrid = new LocatableTreeGrid("Config");
+ final TreeGrid systemConfigTreeGrid = new
LocatableTreeGrid(CONFIGURATION_SECTION_VIEW_ID);
systemConfigTreeGrid.setLeaveScrollbarGap(false);
systemConfigTreeGrid.setShowHeader(false);
Tree tree = new Tree();
- final TreeNode manageSettings = new TreeNode("System Settings");
- final TreeNode manageTemplates = new TreeNode("Templates");
- final TreeNode manageDownloads = new TreeNode("Downloads");
- final TreeNode manageLicense = new TreeNode("License");
- final TreeNode managePlugins = new TreeNode("Plugins");
+ final TreeNode manageSettings = new
EnhancedTreeNode("SystemSettings");
+ final TreeNode manageTemplates = new EnhancedTreeNode("Templates");
+ final TreeNode manageDownloads = new EnhancedTreeNode("Downloads");
+ final TreeNode manageLicense = new EnhancedTreeNode("License");
+ final TreeNode managePlugins = new EnhancedTreeNode("Plugins");
- tree.setRoot(new TreeNode("System Configuration", manageSettings,
manageTemplates, manageDownloads,
- manageLicense, managePlugins));
+ TreeNode rootNode = new EnhancedTreeNode(CONFIGURATION_SECTION_VIEW_ID,
manageSettings, manageTemplates, manageDownloads,
+ manageLicense, managePlugins);
+ tree.setRoot(rootNode);
systemConfigTreeGrid.setData(tree);
@@ -180,11 +197,8 @@ public class AdministrationView extends LocatableHLayout implements
Bookmarkable
}
public void setContent(Canvas newContent) {
-
- if (contentCanvas.getChildren().length > 0) {
- for (Canvas child : contentCanvas.getChildren()) {
- child.destroy();
- }
+ for (Canvas child : contentCanvas.getChildren()) {
+ child.destroy();
}
contentCanvas.addChild(newContent);
@@ -193,58 +207,56 @@ public class AdministrationView extends LocatableHLayout implements
Bookmarkable
}
private void renderContentView(ViewPath viewPath) {
-
currentSectionViewId = viewPath.getCurrent();
currentPageViewId = viewPath.getNext();
- String section = currentSectionViewId.getPath();
- String page = currentPageViewId.getPath();
+ String sectionName = currentSectionViewId.getPath();
+ String pageName = currentPageViewId.getPath();
Canvas content = null;
- if ("Security".equals(section)) {
+ if (SECURITY_SECTION_VIEW_ID.equals(sectionName)) {
- if ("Manage Users".equals(page)) {
+ if (UsersView.VIEW_ID.equals(pageName)) {
content = new UsersView(this.extendLocatorId("Users"));
- } else if ("Manage Roles".equals(page)) {
+ } else if (RolesView.VIEW_ID.equals(pageName)) {
content = new RolesView(this.extendLocatorId("Roles"));
- } else if ("Remote Agent Install".equals(page)) {
+ } else if (RemoteAgentInstallView.VIEW_ID.equals(pageName)) {
content = new
RemoteAgentInstallView(this.extendLocatorId("RemoteAgentInstall"));
}
- } else if ("Configuration".equals(section)) {
+ } else if (CONFIGURATION_SECTION_VIEW_ID.equals(sectionName)) {
String url = null;
- if ("System Settings".equals(page)) {
+ if ("SystemSettings".equals(pageName)) {
url = "/admin/config/Config.do?mode=edit";
- } else if ("Templates".equals(page)) {
+ } else if ("Templates".equals(pageName)) {
url =
"/admin/config/EditDefaults.do?mode=monitor&viewMode=all";
- } else if ("Downloads".equals(page)) {
+ } else if ("Downloads".equals(pageName)) {
url = "/rhq/admin/downloads-body.xhtml";
- } else if ("License".equals(page)) {
+ } else if ("License".equals(pageName)) {
url = "/admin/license/LicenseAdmin.do?mode=view";
- } else if ("Plugins".equals(page)) {
+ } else if ("Plugins".equals(pageName)) {
url = "/rhq/admin/plugin/plugin-list-plain.xhtml";
}
url = addQueryStringParam(url, "nomenu=true");
content = new FullHTMLPane(url);
- } else if ("Cluster".equals(section)) {
+ } else if (TOPOLOGY_SECTION_VIEW_ID.equals(sectionName)) {
String url = null;
- if ("Servers".equals(page)) {
+ if ("Servers".equals(pageName)) {
url = "/rhq/ha/listServers-plain.xhtml";
- } else if ("Agents".equals(page)) {
+ } else if ("Agents".equals(pageName)) {
url = "/rhq/ha/listAgents-plain.xhtml";
- } else if ("Affinity Groups".equals(page)) {
+ } else if ("Affinity Groups".equals(pageName)) {
url = "/rhq/ha/listAffinityGroups-plain.xhtml";
- } else if ("Partition Events".equals(page)) {
+ } else if ("Partition Events".equals(pageName)) {
url = "/rhq/ha/listPartitionEvents-plain.xhtml";
}
content = new FullHTMLPane(url);
}
for (String name : treeGrids.keySet()) {
-
TreeGrid treeGrid = treeGrids.get(name);
- if (name.equals(section)) {
+ if (name.equals(sectionName)) {
// treeGrid.setSelectedPaths(page);
} else {
treeGrid.deselectAllRecords();
@@ -259,13 +271,10 @@ public class AdministrationView extends LocatableHLayout implements
Bookmarkable
((BookmarkableView) content).renderView(viewPath.next().next());
}
}
-
}
public void renderView(ViewPath viewPath) {
-
if (!viewPath.isCurrent(currentSectionViewId) ||
!viewPath.isNext(currentPageViewId)) {
-
if (viewPath.isEnd()) {
// Display default view
setContent(defaultView());
@@ -276,7 +285,6 @@ public class AdministrationView extends LocatableHLayout implements
Bookmarkable
if (this.currentContent instanceof BookmarkableView) {
((BookmarkableView)
this.currentContent).renderView(viewPath.next().next());
}
-
}
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/agent/install/RemoteAgentInstallView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/agent/install/RemoteAgentInstallView.java
index 78aba28..b808fc8 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/agent/install/RemoteAgentInstallView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/agent/install/RemoteAgentInstallView.java
@@ -58,7 +58,8 @@ import
org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
* @author Greg Hinkle
*/
public class RemoteAgentInstallView extends LocatableVLayout {
-
+ public static final String VIEW_ID = "RemoteAgentInstall";
+
private RemoteInstallGWTServiceAsync remoteInstallService =
GWTServiceLookup.getRemoteInstallService();
private DynamicForm connectionForm;
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesView.java
index a9ea8b3..9e38e63 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesView.java
@@ -30,6 +30,7 @@ import
org.rhq.enterprise.gui.coregui.client.components.table.TableSection;
* @author Greg Hinkle
*/
public class RolesView extends TableSection implements BookmarkableView {
+ public static final String VIEW_ID = "Roles";
public RolesView(String locatorId) {
super(locatorId, "Roles");
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersView.java
index e1de74d..51a0b8a 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersView.java
@@ -30,6 +30,7 @@ import
org.rhq.enterprise.gui.coregui.client.components.table.TableSection;
* @author Greg Hinkle
*/
public class UsersView extends TableSection {
+ public static final String VIEW_ID = "Users";
public UsersView(String locatorId) {
super(locatorId, "Users");
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertsView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertsView.java
index 1a5e44a..8d2a36c 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertsView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertsView.java
@@ -56,6 +56,8 @@ import
org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellForma
* @author Heiko W. Rupp
*/
public class AlertsView extends Table {
+ public static final String VIEW_ID = "RecentAlerts";
+
private static final String TITLE = "Alerts";
private static final SortSpecifier[] SORT_SPECIFIERS = new SortSpecifier[] {
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/FullHTMLPane.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/FullHTMLPane.java
index 50ed0ae..b82482c 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/FullHTMLPane.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/FullHTMLPane.java
@@ -34,6 +34,7 @@ public class FullHTMLPane extends HTMLPane {
public FullHTMLPane(String url) {
this();
+ System.out.println("Creating IFrame pane with URL [" + url +
"]...");
setContentsURL(url);
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tree/EnhancedTreeNode.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tree/EnhancedTreeNode.java
index 11a78dc..bbbcc1b 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tree/EnhancedTreeNode.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tree/EnhancedTreeNode.java
@@ -20,19 +20,23 @@ package org.rhq.enterprise.gui.coregui.client.components.tree;
import com.smartgwt.client.widgets.tree.TreeNode;
+import org.rhq.core.domain.util.StringUtils;
+
/**
* @author Ian Springer
*/
public class EnhancedTreeNode extends TreeNode {
public EnhancedTreeNode() {
+ this(null);
}
public EnhancedTreeNode(String name) {
- super(name);
+ this(name, new TreeNode[0]);
}
public EnhancedTreeNode(String name, TreeNode... children) {
super(name, children);
+ setTitle(StringUtils.deCamelCase(name));
}
public String getID() {
@@ -46,9 +50,16 @@ public class EnhancedTreeNode extends TreeNode {
@Override
public String toString() {
StringBuilder buffer = new StringBuilder();
- String className = this.getClass().getName();
- String simpleClassName = className.substring(className.lastIndexOf(".")
+ 1);
- String innerClassName =
simpleClassName.substring(simpleClassName.lastIndexOf("$") + 1);
+ String innerClassName;
+ try {
+ String className = this.getClass().getName();
+ String simpleClassName =
className.substring(className.lastIndexOf(".") + 1);
+ innerClassName =
simpleClassName.substring(simpleClassName.lastIndexOf("$") + 1);
+ }
+ catch (RuntimeException e) {
+ innerClassName = "EnhancedTreeNode";
+ }
+
buffer.append(innerClassName).append("[");
String id = getID();
buffer.append("id=").append(id);
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/platform/PlatformPortletView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/platform/PlatformPortletView.java
index a02cdd4..ea9cbc4 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/platform/PlatformPortletView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/platform/PlatformPortletView.java
@@ -58,6 +58,7 @@ import
org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableListGrid;
* @author Greg Hinkle
*/
public class PlatformPortletView extends LocatableListGrid implements Portlet {
+ public static final String VIEW_ID = "CpuAndMemoryUtilization";
private MeasurementDataGWTServiceAsync measurementService =
GWTServiceLookup.getMeasurementDataService();
private ResourceTypeGWTServiceAsync typeService =
GWTServiceLookup.getResourceTypeGWTService();
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 a4fac9f..f7c37ee 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
@@ -47,7 +47,7 @@ import
org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity;
public class GroupDefinitionListView extends TableSection {
public GroupDefinitionListView(String locatorId, String headerIcon) {
- super(locatorId, "Group Definitions");
+ super(locatorId, "Dynamic Group Definitions");
setHeaderIcon(headerIcon);
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java
index e102771..335d23c 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java
@@ -43,6 +43,7 @@ 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.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.inventory.groups.ResourceGroupListView;
import
org.rhq.enterprise.gui.coregui.client.inventory.groups.definitions.GroupDefinitionListView;
@@ -58,22 +59,22 @@ import
org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableTreeGrid;
public class InventoryView extends LocatableHLayout implements BookmarkableView {
public static final String VIEW_ID = "Inventory";
- private static final String SECTION_GROUPS = "Groups";
- private static final String SECTION_RESOURCES = "Resources";
+ private static final String GROUPS_SECTION_VIEW_ID = "Groups";
+ 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 = "Saved Searches";
-
- private static final String PAGE_ADQ = "Discovery Manager";
- private static final String PAGE_COMPATIBLE_GROUPS = "Compatible Groups";
- private static final String PAGE_DOWN = "Down Servers";
- private static final String PAGE_GROUPS = "All Groups";
- private static final String PAGE_GROUP_DEFINITIONS = "DynaGroup Manager";
- private static final String PAGE_MIXED_GROUPS = "Mixed 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 =
"DynamicGroupDefinitions";
+ private static final String PAGE_MIXED_GROUPS = "MixedGroups";
private static final String PAGE_PLATFORMS = "Platforms";
- private static final String PAGE_PROBLEM_GROUPS = "Problem Groups";
- private static final String PAGE_RESOURCES = "All Resources";
+ 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";
@@ -110,7 +111,7 @@ public class InventoryView extends LocatableHLayout implements
BookmarkableView
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",
+ CoreGUI.getErrorHandler().handleError("Could not determine
user's global permissions - assuming none.",
caught);
finishOnInit(EnumSet.noneOf(Permission.class));
}
@@ -123,104 +124,98 @@ public class InventoryView extends LocatableHLayout implements
BookmarkableView
}
private void finishOnInit(Set<Permission> globalPermissions) {
- buildResourcesSection(globalPermissions);
- buildGroupsSection(globalPermissions);
-
- for (final String sectionName : treeGrids.keySet()) {
- TreeGrid grid = treeGrids.get(sectionName);
-
- grid.addSelectionChangedHandler(new SelectionChangedHandler() {
- public void onSelectionChanged(SelectionEvent selectionEvent) {
- if (selectionEvent.getState()) {
- String pageName =
selectionEvent.getRecord().getAttribute("name");
- String viewPath = "Inventory/" + sectionName +
"/" + pageName;
- String currentViewPath = History.getToken();
- if (!currentViewPath.startsWith(viewPath)) {
- CoreGUI.goToView(viewPath);
- }
- }
- }
- });
-
- SectionStackSection section = new SectionStackSection(sectionName);
- section.setExpanded(true);
- section.addItem(grid);
-
- sectionStack.addSection(section);
- }
+ addSection(buildResourcesSection(globalPermissions));
+ addSection(buildGroupsSection(globalPermissions));
addMember(sectionStack);
addMember(contentCanvas);
}
- private SectionStackSection buildResourcesSection(Set<Permission>
globalPermissions) {
+ 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);
+ }
+ }
+ }
+ });
- final SectionStackSection section = new SectionStackSection(SECTION_RESOURCES);
+ SectionStackSection section = new SectionStackSection(sectionName);
section.setExpanded(true);
+ section.addItem(treeGrid);
+
+ this.sectionStack.addSection(section);
+ }
- final TreeNode discoveryQueue = new TreeNode(PAGE_ADQ);
+ 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 TreeNode(PAGE_PLATFORMS);
+ final TreeNode onlyPlatforms = new EnhancedTreeNode(PAGE_PLATFORMS);
onlyPlatforms.setIcon("types/Platform_up_16.png");
- final TreeNode onlyServers = new TreeNode(PAGE_SERVERS);
+ final TreeNode onlyServers = new EnhancedTreeNode(PAGE_SERVERS);
onlyServers.setIcon("types/Server_up_16.png");
- final TreeNode onlyServices = new TreeNode(PAGE_SERVICES);
+ final TreeNode onlyServices = new EnhancedTreeNode(PAGE_SERVICES);
onlyServices.setIcon("types/Service_up_16.png");
- final TreeNode inventory = new TreeNode(SUBSECTION_RESOURCE_INVENTORY,
onlyPlatforms, onlyServers, onlyServices);
+ final TreeNode inventory = new EnhancedTreeNode(SUBSECTION_RESOURCE_INVENTORY,
onlyPlatforms, onlyServers, onlyServices);
- final TreeNode downServers = new TreeNode(PAGE_DOWN);
+ final TreeNode downServers = new EnhancedTreeNode(PAGE_DOWN);
downServers.setIcon("types/Server_down_16.png");
- final TreeNode savedSearches = new TreeNode(SUBSECTION_SAVED_SEARCHES,
downServers);
+ final TreeNode savedSearches = new EnhancedTreeNode(SUBSECTION_SAVED_SEARCHES,
downServers);
- TreeGrid treeGrid = new LocatableTreeGrid(SECTION_RESOURCES);
+ TreeGrid treeGrid = new LocatableTreeGrid(RESOURCES_SECTION_VIEW_ID);
treeGrid.setShowHeader(false);
Tree tree = new Tree();
- tree.setRoot(new TreeNode(SECTION_RESOURCES, discoveryQueue, inventory,
savedSearches));
+ TreeNode rootNode = new TreeNode(RESOURCES_SECTION_VIEW_ID, discoveryQueue,
inventory, savedSearches);
+ tree.setRoot(rootNode);
treeGrid.setData(tree);
treeGrid.getTree().openAll();
- treeGrids.put(SECTION_RESOURCES, treeGrid);
-
- section.addItem(treeGrid);
+ treeGrids.put(RESOURCES_SECTION_VIEW_ID, treeGrid);
- return section;
+ return treeGrid;
}
- private SectionStackSection buildGroupsSection(Set<Permission>
globalPermissions) {
- final SectionStackSection section = new SectionStackSection(SECTION_GROUPS);
- section.setExpanded(true);
-
- final TreeNode groupGroupDefinitions = new TreeNode(PAGE_GROUP_DEFINITIONS);
+ 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 TreeNode(PAGE_COMPATIBLE_GROUPS);
+ final TreeNode onlyCompatible = new EnhancedTreeNode(PAGE_COMPATIBLE_GROUPS);
onlyCompatible.setIcon("types/Cluster_up_16.png");
- final TreeNode onlyMixed = new TreeNode(PAGE_MIXED_GROUPS);
+ final TreeNode onlyMixed = new EnhancedTreeNode(PAGE_MIXED_GROUPS);
onlyMixed.setIcon("types/Group_up_16.png");
- final TreeNode inventory = new TreeNode(SUBSECTION_GROUP_INVENTORY,
onlyCompatible, onlyMixed);
+ final TreeNode inventory = new EnhancedTreeNode(SUBSECTION_GROUP_INVENTORY,
onlyCompatible, onlyMixed);
- final TreeNode problemGroups = new TreeNode(PAGE_PROBLEM_GROUPS);
- final TreeNode savedSearches = new TreeNode(SUBSECTION_SAVED_SEARCHES,
problemGroups);
+ final TreeNode problemGroups = new EnhancedTreeNode(PAGE_PROBLEM_GROUPS);
+ final TreeNode savedSearches = new EnhancedTreeNode(SUBSECTION_SAVED_SEARCHES,
problemGroups);
- TreeGrid treeGrid = new LocatableTreeGrid(SECTION_GROUPS);
+ TreeGrid treeGrid = new LocatableTreeGrid(GROUPS_SECTION_VIEW_ID);
treeGrid.setShowHeader(false);
Tree tree = new Tree();
- tree.setRoot(new TreeNode(SECTION_GROUPS, groupGroupDefinitions, inventory,
savedSearches));
+ TreeNode rootNode = new EnhancedTreeNode(GROUPS_SECTION_VIEW_ID,
groupGroupDefinitions, inventory, savedSearches);
+ tree.setRoot(rootNode);
treeGrid.setData(tree);
treeGrid.getTree().openAll();
- treeGrids.put(SECTION_GROUPS, treeGrid);
- section.addItem(treeGrid);
+ treeGrids.put(GROUPS_SECTION_VIEW_ID, treeGrid);
- return section;
+ return treeGrid;
}
public void setContent(Canvas newContent) {
@@ -233,30 +228,29 @@ public class InventoryView extends LocatableHLayout implements
BookmarkableView
}
private void renderContentView(ViewPath viewPath) {
-
currentSectionViewId = viewPath.getCurrent();
currentPageViewId = viewPath.getNext();
- String section = currentSectionViewId.getPath();
- String page = currentPageViewId.getPath();
+ String sectionName = currentSectionViewId.getPath();
+ String pageName = currentPageViewId.getPath();
Canvas content = null;
- if (SECTION_RESOURCES.equals(section)) {
- if (PAGE_PLATFORMS.equals(page)) {
+ if (RESOURCES_SECTION_VIEW_ID.equals(sectionName)) {
+ if (PAGE_PLATFORMS.equals(pageName)) {
content = new ResourceSearchView(extendLocatorId("Platforms"),
new Criteria(
ResourceDataSourceField.CATEGORY.propertyName(),
ResourceCategory.PLATFORM.name()), PAGE_PLATFORMS,
"types/Platform_up_24.png");
- } else if (PAGE_SERVERS.equals(page)) {
+ } else if (PAGE_SERVERS.equals(pageName)) {
content = new ResourceSearchView(extendLocatorId("Servers"),
new Criteria(
ResourceDataSourceField.CATEGORY.propertyName(),
ResourceCategory.SERVER.name()), PAGE_SERVERS,
"types/Server_up_24.png");
- } else if (PAGE_SERVICES.equals(page)) {
+ } else if (PAGE_SERVICES.equals(pageName)) {
content = new ResourceSearchView(extendLocatorId("Services"),
new Criteria(
ResourceDataSourceField.CATEGORY.propertyName(),
ResourceCategory.SERVICE.name()), PAGE_SERVICES,
"types/Service_up_24.png");
- } else if (PAGE_ADQ.equals(page)) {
+ } else if (PAGE_ADQ.equals(pageName)) {
content = new
ResourceAutodiscoveryView(this.extendLocatorId("ADQ"));
- } else if (PAGE_DOWN.equals(page)) {
+ } else if (PAGE_DOWN.equals(pageName)) {
Criteria criteria = new
Criteria(ResourceDataSourceField.AVAILABILITY.propertyName(),
AvailabilityType.DOWN.name());
criteria.addCriteria(ResourceDataSourceField.CATEGORY.propertyName(),
ResourceCategory.SERVER.name());
@@ -265,17 +259,16 @@ public class InventoryView extends LocatableHLayout implements
BookmarkableView
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 (SECTION_GROUPS.equals(section)) {
- if (PAGE_COMPATIBLE_GROUPS.equals(page)) {
+ } else if (GROUPS_SECTION_VIEW_ID.equals(sectionName)) {
+ if (PAGE_COMPATIBLE_GROUPS.equals(pageName)) {
content = new
ResourceGroupListView(extendLocatorId("Compatible"), new
Criteria("category",
"compatible"), PAGE_COMPATIBLE_GROUPS,
"types/Cluster_up_24.png");
- } else if (PAGE_MIXED_GROUPS.equals(page)) {
+ } else if (PAGE_MIXED_GROUPS.equals(pageName)) {
content = new ResourceGroupListView(extendLocatorId("Mixed"),
new Criteria("category", "mixed"),
PAGE_MIXED_GROUPS, "types/Group_up_24.png");
- } else if (PAGE_GROUP_DEFINITIONS.equals(page)) {
+ } else if (PAGE_GROUP_DEFINITIONS.equals(pageName)) {
content = new
GroupDefinitionListView(extendLocatorId("Definitions"),
"types/GroupDefinition_16.png");
- } else if (PAGE_PROBLEM_GROUPS.equals(page)) {
+ } 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"),
@@ -287,11 +280,10 @@ public class InventoryView extends LocatableHLayout implements
BookmarkableView
}
for (String name : treeGrids.keySet()) {
-
TreeGrid treeGrid = treeGrids.get(name);
- if (name.equals(section)) {
+ if (name.equals(sectionName)) {
for (TreeNode node : treeGrid.getTree().getAllNodes()) {
- if (page.equals(node.getName())) {
+ if (pageName.equals(node.getName())) {
treeGrid.selectSingleRecord(node);
}
}
@@ -308,7 +300,6 @@ public class InventoryView extends LocatableHLayout implements
BookmarkableView
((BookmarkableView) content).renderView(viewPath.next().next());
}
}
-
}
public void renderView(ViewPath viewPath) {
@@ -328,5 +319,4 @@ public class InventoryView extends LocatableHLayout implements
BookmarkableView
}
}
}
-
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryView.java
index 3339179..0e51bae 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryView.java
@@ -39,6 +39,7 @@ import
org.rhq.enterprise.gui.coregui.client.components.table.TableSection;
* @author Greg Hinkle
*/
public class ConfigurationHistoryView extends TableSection {
+ public static final String VIEW_ID = "RecentConfigurationChanges";
private Integer resourceId;
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/OperationHistoryView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/OperationHistoryView.java
index 212a5ae..5e03c44 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/OperationHistoryView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/OperationHistoryView.java
@@ -46,6 +46,7 @@ import
org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableMenu;
* @author Greg Hinkle
*/
public class OperationHistoryView extends TableSection {
+ public static final String VIEW_ID = "RecentOperations";
private ResourceComposite composite;
private Resource resource;
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 233637e..7627527 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
@@ -20,12 +20,13 @@
* if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-
package org.rhq.enterprise.gui.coregui.client.report;
import java.util.LinkedHashMap;
+import java.util.Map;
import com.google.gwt.http.client.URL;
+import com.google.gwt.user.client.History;
import com.smartgwt.client.types.VisibilityMode;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.HTMLFlow;
@@ -43,6 +44,7 @@ import org.rhq.enterprise.gui.coregui.client.ViewId;
import org.rhq.enterprise.gui.coregui.client.ViewPath;
import org.rhq.enterprise.gui.coregui.client.alert.AlertsView;
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.dashboard.portlets.platform.PlatformPortletView;
import
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.configuration.ConfigurationHistoryView;
import
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.OperationHistoryView;
@@ -58,8 +60,8 @@ import
org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableTreeGrid;
public class ReportTopView extends LocatableHLayout implements BookmarkableView {
public static final String VIEW_ID = "Reports";
- private static final String SECTION_INVENTORY = "Inventory";
- private static final String SECTION_REPORTS = "Reports";
+ private static final String SUBSYSTEMS_SECTION_VIEW_ID = "Subsystems";
+ private static final String INVENTORY_SECTION_VIEW_ID = "Inventory";
private ViewId currentSectionViewId;
private ViewId currentPageViewId;
@@ -68,7 +70,7 @@ public class ReportTopView extends LocatableHLayout implements
BookmarkableView
private Canvas contentCanvas;
private Canvas currentContent;
- private LinkedHashMap<String, TreeGrid> treeGrids = new
LinkedHashMap<String, TreeGrid>();
+ private Map<String, TreeGrid> treeGrids = new LinkedHashMap<String,
TreeGrid>();
public ReportTopView(String locatorId) {
super(locatorId);
@@ -91,30 +93,36 @@ public class ReportTopView extends LocatableHLayout implements
BookmarkableView
sectionStack.setWidth(250);
sectionStack.setHeight100();
- treeGrids.put(SECTION_INVENTORY, buildInventorySection());
- treeGrids.put(SECTION_REPORTS, buildReportsSection());
+ addSection(buildSubsystemsSection());
+ addSection(buildInventorySection());
- for (final String name : treeGrids.keySet()) {
- TreeGrid grid = treeGrids.get(name);
+ addMember(sectionStack);
+ addMember(contentCanvas);
+ }
- grid.addSelectionChangedHandler(new SelectionChangedHandler() {
- public void onSelectionChanged(SelectionEvent selectionEvent) {
- if (selectionEvent.getState()) {
- CoreGUI.goToView("Reports/" + name + "/" +
selectionEvent.getRecord().getAttribute("name"));
+ 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 = ReportTopView.VIEW_ID + "/" + sectionName
+ "/" + pageName;
+ String currentViewPath = History.getToken();
+ if (!currentViewPath.startsWith(viewPath)) {
+ CoreGUI.goToView(viewPath);
}
}
- });
-
- SectionStackSection section = new SectionStackSection(name);
- section.setExpanded(true);
- section.addItem(grid);
-
- sectionStack.addSection(section);
- }
+ }
+ });
- addMember(sectionStack);
- addMember(contentCanvas);
+ SectionStackSection section = new SectionStackSection(sectionName);
+ section.setExpanded(true);
+ section.addItem(treeGrid);
+ this.sectionStack.addSection(section);
}
private HTMLFlow defaultView() {
@@ -124,33 +132,32 @@ public class ReportTopView extends LocatableHLayout implements
BookmarkableView
return flow;
}
- private TreeGrid buildInventorySection() {
-
- final TreeGrid inventoryTreeGrid = new LocatableTreeGrid(SECTION_INVENTORY);
+ private TreeGrid buildSubsystemsSection() {
+ final TreeGrid inventoryTreeGrid = new
LocatableTreeGrid(SUBSYSTEMS_SECTION_VIEW_ID);
inventoryTreeGrid.setLeaveScrollbarGap(false);
inventoryTreeGrid.setShowHeader(false);
Tree tree = new Tree();
- final TreeNode tagCloud = new TreeNode("Tag Cloud");
+ final TreeNode tagCloud = new EnhancedTreeNode(TaggedView.VIEW_ID);
tagCloud.setIcon("global/Cloud_16.png");
- final TreeNode suspectMetrics = new TreeNode("Suspect Metrics");
+ final TreeNode suspectMetrics = new
EnhancedTreeNode(MeasurementOOBView.VIEW_ID);
suspectMetrics.setIcon("subsystems/monitor/Monitor_failed_16.png");
- final TreeNode recentConfigurationChanges = new TreeNode("Recent
Configuration Changes");
+ final TreeNode recentConfigurationChanges = new
EnhancedTreeNode(ConfigurationHistoryView.VIEW_ID);
recentConfigurationChanges.setIcon("subsystems/configure/Configure_16.png");
- final TreeNode recentOperations = new TreeNode("Recent Operations");
+ final TreeNode recentOperations = new
EnhancedTreeNode(OperationHistoryView.VIEW_ID);
recentOperations.setIcon("subsystems/control/Operation_16.png");
- final TreeNode recentAlerts = new TreeNode("Recent Alerts");
+ final TreeNode recentAlerts = new EnhancedTreeNode(AlertsView.VIEW_ID);
recentAlerts.setIcon("subsystems/alert/Alert_LOW_16.png");
- final TreeNode alertDefinitions = new TreeNode("Alert Definitions");
+ final TreeNode alertDefinitions = new EnhancedTreeNode("Alert
Definitions");
alertDefinitions.setIcon("subsystems/alert/Alerts_16.png");
- TreeNode inventoryNode = new TreeNode(SECTION_INVENTORY, tagCloud,
suspectMetrics, recentConfigurationChanges,
- recentOperations, recentAlerts, alertDefinitions);
+ TreeNode inventoryNode = new EnhancedTreeNode(SUBSYSTEMS_SECTION_VIEW_ID,
tagCloud, suspectMetrics,
+ recentConfigurationChanges, recentOperations, recentAlerts,
alertDefinitions);
tree.setRoot(inventoryNode);
inventoryTreeGrid.setData(tree);
@@ -158,20 +165,20 @@ public class ReportTopView extends LocatableHLayout implements
BookmarkableView
return inventoryTreeGrid;
}
- private TreeGrid buildReportsSection() {
+ private TreeGrid buildInventorySection() {
- final TreeGrid reportsTreeGrid = new LocatableTreeGrid(SECTION_REPORTS);
+ final TreeGrid reportsTreeGrid = new
LocatableTreeGrid(INVENTORY_SECTION_VIEW_ID);
reportsTreeGrid.setLeaveScrollbarGap(false);
reportsTreeGrid.setShowHeader(false);
Tree tree = new Tree();
- final TreeNode inventorySummary = new TreeNode("Inventory Summary");
+ final TreeNode inventorySummary = new
EnhancedTreeNode("InventorySummary");
inventorySummary.setIcon("subsystems/inventory/Inventory_16.png");
- final TreeNode platforms = new TreeNode("CPU & Memory
Utilization");
+ final TreeNode platforms = new EnhancedTreeNode(PlatformPortletView.VIEW_ID);
platforms.setIcon("types/Platform_up_16.png");
- TreeNode reportsNode = new TreeNode(SECTION_REPORTS, inventorySummary,
platforms);
+ TreeNode reportsNode = new EnhancedTreeNode(INVENTORY_SECTION_VIEW_ID,
inventorySummary, platforms);
tree.setRoot(reportsNode);
reportsTreeGrid.setData(tree);
@@ -180,7 +187,6 @@ public class ReportTopView extends LocatableHLayout implements
BookmarkableView
}
public void setContent(Canvas newContent) {
-
if (contentCanvas.getChildren().length > 0) {
for (Canvas child : contentCanvas.getChildren()) {
child.destroy();
@@ -193,44 +199,41 @@ public class ReportTopView extends LocatableHLayout implements
BookmarkableView
}
private void renderContentView(ViewPath viewPath) {
-
currentSectionViewId = viewPath.getCurrent();
currentPageViewId = viewPath.getNext();
- String section = currentSectionViewId.getPath();
- String page = currentPageViewId.getPath();
+ String sectionName = currentSectionViewId.getPath();
+ String pageName = currentPageViewId.getPath();
- page = URL.decode(page);
+ pageName = URL.decode(pageName);
Canvas content = null;
- if (SECTION_INVENTORY.equals(section)) {
-
- if ("Tag Cloud".equals(page)) {
- content = new TaggedView(this.extendLocatorId("TagCloud"));
- } else if ("Suspect Metrics".equals(page)) {
+ if (SUBSYSTEMS_SECTION_VIEW_ID.equals(sectionName)) {
+ if (TaggedView.VIEW_ID.equals(pageName)) {
+ content = new TaggedView(this.extendLocatorId("Tag"));
+ } else if (MeasurementOOBView.VIEW_ID.equals(pageName)) {
content = new
MeasurementOOBView(this.extendLocatorId("SuspectMetrics"));
- } else if ("Recent Configuration Changes".equals(page)) {
+ } else if (ConfigurationHistoryView.VIEW_ID.equals(pageName)) {
content = new
ConfigurationHistoryView(this.extendLocatorId("RecentConfigChanges"));
- } else if ("Recent Operations".equals(page)) {
+ } else if (OperationHistoryView.VIEW_ID.equals(pageName)) {
content = new
OperationHistoryView(this.extendLocatorId("RecentOps"));
- } else if ("Recent Alerts".equals(page)) {
+ } else if (AlertsView.VIEW_ID.equals(pageName)) {
content = new
AlertsView(this.extendLocatorId("RecentAlerts"));
- } else if ("Alert Definitions".equals(page)) {
- //todo
+ } else if ("Alert Definitions".equals(pageName)) {
+ // TODO (mazz)
}
-
- } else if (SECTION_REPORTS.equals(section)) {
- if ("Inventory Summary".equals(page)) {
+ } else if (INVENTORY_SECTION_VIEW_ID.equals(sectionName)) {
+ if ("InventorySummary".equals(pageName)) {
content = new
FullHTMLPane("/rhq/admin/report/resourceInstallReport-body.xhtml");
- } else if ("CPU & Memory Utilization".equals(page)) {
+ } else if (PlatformPortletView.VIEW_ID.equals(pageName)) {
content = new
PlatformPortletView(this.extendLocatorId("Platforms"));
}
}
- for (String name : treeGrids.keySet()) {
+ for (String name : treeGrids.keySet()) {
TreeGrid treeGrid = treeGrids.get(name);
- if (name.equals(section)) {
- TreeNode node = treeGrid.getTree().find(page);
+ if (name.equals(sectionName)) {
+ TreeNode node = treeGrid.getTree().find(pageName);
if (node != null) {
treeGrid.selectSingleRecord(node);
}
@@ -249,22 +252,17 @@ public class ReportTopView extends LocatableHLayout implements
BookmarkableView
}
public void renderView(ViewPath viewPath) {
-
if (!viewPath.isCurrent(currentSectionViewId) ||
!viewPath.isNext(currentPageViewId)) {
-
if (viewPath.isEnd()) {
// Display default view
setContent(defaultView());
} else {
-
renderContentView(viewPath);
}
} else {
if (this.currentContent instanceof BookmarkableView) {
((BookmarkableView)
this.currentContent).renderView(viewPath.next().next());
}
-
}
-
}
}
\ No newline at end of file
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/measurement/MeasurementOOBView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/measurement/MeasurementOOBView.java
index 9d68c48..e778e50 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/measurement/MeasurementOOBView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/measurement/MeasurementOOBView.java
@@ -31,7 +31,8 @@ import org.rhq.enterprise.gui.coregui.client.components.table.Table;
* @author Greg Hinkle
*/
public class MeasurementOOBView extends Table {
-
+ public static final String VIEW_ID = "SuspectMetrics";
+
public MeasurementOOBView(String locatorId) {
super(locatorId, "Suspect Metrics");
commit 4a91718ee72e1a67eff794eb1a7e3c057c2d2716
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Tue Sep 28 14:45:46 2010 -0400
we now have a alert definition gwt service - and this is the more appropriate place
for the getAlertDefinitionsByCriteria API
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsDataSource.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsDataSource.java
index bf38e6b..7a53dbe 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsDataSource.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsDataSource.java
@@ -120,7 +120,7 @@ public abstract class AbstractAlertDefinitionsDataSource extends
RPCDataSource<A
@Override
protected void executeFetch(final DSRequest request, final DSResponse response) {
AlertDefinitionCriteria criteria = getCriteria(request);
- GWTServiceLookup.getAlertService().findAlertDefinitionsByCriteria(criteria,
+
GWTServiceLookup.getAlertDefinitionService().findAlertDefinitionsByCriteria(criteria,
new AsyncCallback<PageList<AlertDefinition>>() {
public void onFailure(Throwable caught) {
CoreGUI.getErrorHandler().handleError("Failed to load alert
definition data", caught);
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java
index 818aaca..89a6c8b 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java
@@ -148,7 +148,7 @@ public abstract class AbstractAlertDefinitionsView extends
TableSection {
final AlertDefinitionCriteria criteria = new AlertDefinitionCriteria();
criteria.addFilterId(id);
criteria.fetchGroupAlertDefinition(true);
- GWTServiceLookup.getAlertService().findAlertDefinitionsByCriteria(criteria,
+
GWTServiceLookup.getAlertDefinitionService().findAlertDefinitionsByCriteria(criteria,
new AsyncCallback<PageList<AlertDefinition>>() {
public void onFailure(Throwable caught) {
CoreGUI.getErrorHandler().handleError("Failed to load alert
definition data", caught);
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/RecoveryAlertDefinitionForm.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/RecoveryAlertDefinitionForm.java
index b539d0a..cf8af6a 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/RecoveryAlertDefinitionForm.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/RecoveryAlertDefinitionForm.java
@@ -214,7 +214,7 @@ public class RecoveryAlertDefinitionForm extends LocatableDynamicForm
implements
private void loadAllAlertDefinitionsAndRefreshRecoverAlertSelection() {
if (allAlertDefinitions == null) {
AlertDefinitionCriteria criteria =
alertDataSource.getSimpleCriteriaForAll();
- GWTServiceLookup.getAlertService().findAlertDefinitionsByCriteria(criteria,
+
GWTServiceLookup.getAlertDefinitionService().findAlertDefinitionsByCriteria(criteria,
new AsyncCallback<PageList<AlertDefinition>>() {
public void onFailure(Throwable caught) {
CoreGUI.getErrorHandler().handleError("Cannot build recovery
menu", caught);
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/AlertDefinitionGWTService.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/AlertDefinitionGWTService.java
index 14c123c..e0d4e94 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/AlertDefinitionGWTService.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/AlertDefinitionGWTService.java
@@ -21,9 +21,13 @@ package org.rhq.enterprise.gui.coregui.client.gwt;
import com.google.gwt.user.client.rpc.RemoteService;
import org.rhq.core.domain.alert.AlertDefinition;
+import org.rhq.core.domain.criteria.AlertDefinitionCriteria;
+import org.rhq.core.domain.util.PageList;
public interface AlertDefinitionGWTService extends RemoteService {
+ PageList<AlertDefinition>
findAlertDefinitionsByCriteria(AlertDefinitionCriteria criteria);
+
int createAlertDefinition(AlertDefinition alertDefinition, Integer resourceId) throws
Exception;
AlertDefinition updateAlertDefinition(int alertDefinitionId, AlertDefinition
alertDefinition,
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/AlertGWTService.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/AlertGWTService.java
index 38b19ee..aac13a3 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/AlertGWTService.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/AlertGWTService.java
@@ -19,12 +19,9 @@
package org.rhq.enterprise.gui.coregui.client.gwt;
import com.google.gwt.user.client.rpc.RemoteService;
+
import org.rhq.core.domain.alert.Alert;
-import org.rhq.core.domain.alert.AlertDefinition;
-import org.rhq.core.domain.authz.Role;
import org.rhq.core.domain.criteria.AlertCriteria;
-import org.rhq.core.domain.criteria.AlertDefinitionCriteria;
-import org.rhq.core.domain.criteria.RoleCriteria;
import org.rhq.core.domain.util.PageList;
/**
@@ -57,9 +54,4 @@ public interface AlertGWTService extends RemoteService {
* @param alertIds the ids of the Resource alerts to be acknowledged
*/
void acknowledgeResourceAlerts(Integer[] alertIds);
-
-
-
- PageList<AlertDefinition>
findAlertDefinitionsByCriteria(AlertDefinitionCriteria criteria);
-
}
\ No newline at end of file
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertDefinitionGWTServiceImpl.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertDefinitionGWTServiceImpl.java
index 606195b..392e710 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertDefinitionGWTServiceImpl.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertDefinitionGWTServiceImpl.java
@@ -19,6 +19,8 @@
package org.rhq.enterprise.gui.coregui.server.gwt;
import org.rhq.core.domain.alert.AlertDefinition;
+import org.rhq.core.domain.criteria.AlertDefinitionCriteria;
+import org.rhq.core.domain.util.PageList;
import org.rhq.core.util.exception.ThrowableUtil;
import org.rhq.enterprise.gui.coregui.client.gwt.AlertDefinitionGWTService;
import org.rhq.enterprise.gui.coregui.server.util.SerialUtility;
@@ -30,6 +32,16 @@ public class AlertDefinitionGWTServiceImpl extends
AbstractGWTServiceImpl implem
private AlertDefinitionManagerLocal alertDefManager =
LookupUtil.getAlertDefinitionManager();
+ public PageList<AlertDefinition>
findAlertDefinitionsByCriteria(AlertDefinitionCriteria criteria) {
+ try {
+ PageList<AlertDefinition> results =
this.alertDefManager.findAlertDefinitionsByCriteria(
+ getSessionSubject(), criteria);
+ return SerialUtility.prepare(results,
"findAlertDefinitionsByCriteria");
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
+ }
+
public int createAlertDefinition(AlertDefinition alertDefinition, Integer resourceId)
throws Exception {
try {
int results = alertDefManager.createAlertDefinition(getSessionSubject(),
alertDefinition, resourceId);
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertGWTServiceImpl.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertGWTServiceImpl.java
index bc0d32d..a1f47c9 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertGWTServiceImpl.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertGWTServiceImpl.java
@@ -19,13 +19,10 @@
package org.rhq.enterprise.gui.coregui.server.gwt;
import org.rhq.core.domain.alert.Alert;
-import org.rhq.core.domain.alert.AlertDefinition;
import org.rhq.core.domain.criteria.AlertCriteria;
-import org.rhq.core.domain.criteria.AlertDefinitionCriteria;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.gwt.AlertGWTService;
import org.rhq.enterprise.gui.coregui.server.util.SerialUtility;
-import org.rhq.enterprise.server.alert.AlertDefinitionManagerLocal;
import org.rhq.enterprise.server.alert.AlertManagerLocal;
import org.rhq.enterprise.server.util.LookupUtil;
@@ -33,12 +30,13 @@ import org.rhq.enterprise.server.util.LookupUtil;
* @author Ian Springer
*/
public class AlertGWTServiceImpl extends AbstractGWTServiceImpl implements
AlertGWTService {
+ private static final long serialVersionUID = 1L;
+
private AlertManagerLocal alertManager = LookupUtil.getAlertManager();
- private AlertDefinitionManagerLocal alertDefinitionManager =
LookupUtil.getAlertDefinitionManager();
public PageList<Alert> findAlertsByCriteria(AlertCriteria criteria) {
return
SerialUtility.prepare(this.alertManager.findAlertsByCriteria(getSessionSubject(),
criteria),
- "AlertService.findAlertsByCriteria");
+ "AlertService.findAlertsByCriteria");
}
public void deleteResourceAlerts(Integer[] alertIds) {
@@ -48,10 +46,4 @@ public class AlertGWTServiceImpl extends AbstractGWTServiceImpl
implements Alert
public void acknowledgeResourceAlerts(Integer[] alertIds) {
this.alertManager.acknowledgeAlerts(getSessionSubject(), alertIds);
}
-
-
- public PageList<AlertDefinition>
findAlertDefinitionsByCriteria(AlertDefinitionCriteria criteria) {
- return
SerialUtility.prepare(this.alertDefinitionManager.findAlertDefinitionsByCriteria(getSessionSubject(),
criteria),
- "AlertService.findAlertDefinitionsByCriteria");
- }
}
\ No newline at end of file
commit ca46ea1e4f7dd5f1153b1082ad0b349b612556e9
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Tue Sep 28 14:36:25 2010 -0400
start using VIEW_ID constants for view id names
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 b59edba..1dd1250 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
@@ -66,6 +66,7 @@ import
org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
* @author Ian Springer
*/
public class CoreGUI implements EntryPoint, ValueChangeHandler<String> {
+ private static final String DEFAULT_VIEW_PATH = DashboardsView.VIEW_ID;
public static final String CONTENT_CANVAS_ID = "BaseContent";
@@ -270,28 +271,28 @@ public class CoreGUI implements EntryPoint,
ValueChangeHandler<String> {
public Canvas createContent(String breadcrumbName) {
Canvas canvas;
- if (breadcrumbName.equals("Administration")) {
+ if (breadcrumbName.equals(AdministrationView.VIEW_ID)) {
canvas = new AdministrationView("Admin");
- } else if (breadcrumbName.equals("Demo")) {
+ } else if (breadcrumbName.equals(DemoCanvas.VIEW_ID)) {
canvas = new DemoCanvas();
- } else if (breadcrumbName.equals("Inventory")) {
+ } else if (breadcrumbName.equals(InventoryView.VIEW_ID)) {
canvas = new InventoryView("Inventory");
- } else if (breadcrumbName.equals("Resource")) {
+ } else if (breadcrumbName.equals(ResourceTopView.VIEW_ID)) {
canvas = new ResourceTopView("Resource");
- } else if (breadcrumbName.equals("ResourceGroup")) {
+ } else if (breadcrumbName.equals(ResourceGroupTopView.VIEW_ID)) {
canvas = new ResourceGroupTopView("Group");
- } else if (breadcrumbName.equals("Dashboard")) {
+ } else if (breadcrumbName.equals(DashboardsView.VIEW_ID)) {
canvas = new DashboardsView("Dashboard");
- } else if (breadcrumbName.equals("Bundles")) {
+ } else if (breadcrumbName.equals(BundleTopView.VIEW_ID)) {
canvas = new BundleTopView("Bundle");
} else if (breadcrumbName.equals("LogOut")) {
canvas = new LoginView();
UserSessionManager.logout();
- } else if (breadcrumbName.equals("Tag")) {
+ } else if (breadcrumbName.equals(TaggedView.VIEW_ID)) {
canvas = new TaggedView("Tag");
} else if (breadcrumbName.equals("Subsystems")) {
canvas = new AlertsView("Alert");
- } else if (breadcrumbName.equals("Reports")) {
+ } else if (breadcrumbName.equals(ReportTopView.VIEW_ID)) {
canvas = new ReportTopView("Report");
} else {
canvas = null;
@@ -315,7 +316,7 @@ public class CoreGUI implements EntryPoint,
ValueChangeHandler<String> {
private static String getDefaultView() {
// TODO: should this be Dashboard or a User Preference?
- return "";
+ return DEFAULT_VIEW_PATH;
}
public static void setContent(Canvas newContent) {
@@ -336,7 +337,7 @@ public class CoreGUI implements EntryPoint,
ValueChangeHandler<String> {
// We're already there - just refresh the view.
refresh();
} else {
- if (viewPath.matches("(Resource|ResourceGroup)/[^/]*")) {
+ if (viewPath.matches("(" + ResourceTopView.VIEW_ID + "|"
+ ResourceGroupTopView.VIEW_ID + ")/[^/]*")) {
// e.g. "Resource/10001"
if (!currentViewPath.startsWith(viewPath)) {
// The Resource that was selected is not the same Resource that was
previously selected -
@@ -374,7 +375,7 @@ public class CoreGUI implements EntryPoint,
ValueChangeHandler<String> {
// After a user initiated logout start back at the default view
if ("LogOut".equals(CoreGUI.currentPath)) {
- History.newItem(getDefaultView());
+ History.newItem(DEFAULT_VIEW_PATH);
}
}
});
@@ -397,7 +398,7 @@ public class CoreGUI implements EntryPoint,
ValueChangeHandler<String> {
public void renderView(ViewPath viewPath) {
if (viewPath.isEnd()) {
// default view
- History.newItem("Dashboard");
+ History.newItem(DEFAULT_VIEW_PATH);
} else {
if (!viewPath.getCurrent().equals(currentViewId)) {
currentViewId = viewPath.getCurrent();
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/DemoCanvas.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/DemoCanvas.java
index 935f351..bd0aabe 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/DemoCanvas.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/DemoCanvas.java
@@ -38,6 +38,7 @@ import org.rhq.enterprise.gui.coregui.client.report.tag.TagCloudView;
* @author Greg Hinkle
*/
public class DemoCanvas extends Canvas {
+ public static final String VIEW_ID = "Demo";
@Override
protected void onInit() {
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/UserSessionManager.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/UserSessionManager.java
index 9bede31..0bc285d 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/UserSessionManager.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/UserSessionManager.java
@@ -116,7 +116,7 @@ public class UserSessionManager {
}
public static boolean isLoggedIn() {
- System.out.println("isLoggedIn = " + loggedIn);
+ //System.out.println("isLoggedIn = " + loggedIn);
return loggedIn;
}
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 8715366..b0cd874 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
@@ -19,6 +19,7 @@
package org.rhq.enterprise.gui.coregui.client.admin;
import java.util.LinkedHashMap;
+import java.util.Map;
import com.smartgwt.client.types.VisibilityMode;
import com.smartgwt.client.widgets.Canvas;
@@ -47,8 +48,7 @@ import
org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableTreeGrid;
* @author Greg Hinkle
*/
public class AdministrationView extends LocatableHLayout implements BookmarkableView {
-
- public static final String VIEW_PATH = "Administration";
+ public static final String VIEW_ID = "Administration";
private ViewId currentSectionViewId;
private ViewId currentPageViewId;
@@ -57,7 +57,7 @@ public class AdministrationView extends LocatableHLayout implements
Bookmarkable
private Canvas contentCanvas;
private Canvas currentContent;
- private LinkedHashMap<String, TreeGrid> treeGrids = new
LinkedHashMap<String, TreeGrid>();
+ private Map<String, TreeGrid> treeGrids = new LinkedHashMap<String,
TreeGrid>();
public AdministrationView(String locatorId) {
super(locatorId);
@@ -104,7 +104,6 @@ public class AdministrationView extends LocatableHLayout implements
Bookmarkable
addMember(sectionStack);
addMember(contentCanvas);
-
}
private HTMLFlow defaultView() {
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/BundleTopView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/BundleTopView.java
index 20188dd..7da68cd 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/BundleTopView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/BundleTopView.java
@@ -39,6 +39,8 @@ import
org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableSectionStack
* @author Greg Hinkle
*/
public class BundleTopView extends LocatableHLayout implements BookmarkableView {
+ public static final String VIEW_ID = "Bundles";
+
private BundleTreeView bundleTreeView;
private VLayout contentCanvas;
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleView.java
index bc6076a..fb382fa 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleView.java
@@ -66,8 +66,7 @@ import
org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableTabSet;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
public class BundleView extends LocatableVLayout implements BookmarkableView {
-
- LocatableDynamicForm form;
+ private LocatableDynamicForm form;
private int bundleBeingViewed = 0;
private HeaderLabel headerLabel;
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java
index c3dea19..7e0fb8e 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java
@@ -66,6 +66,7 @@ import
org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
* @author Greg Hinkle
*/
public class DashboardsView extends LocatableVLayout implements BookmarkableView {
+ public static final String VIEW_ID = "Dashboard";
private TabSet tabSet;
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/summary/InventorySummaryView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/summary/InventorySummaryView.java
index 361a1f7..0336a29 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/summary/InventorySummaryView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/summary/InventorySummaryView.java
@@ -117,7 +117,7 @@ public class InventorySummaryView extends LocatableVLayout implements
Portlet {
item.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent clickEvent) {
// TODO Figure out to where the click events should be navigating
- History.newItem(InventoryView.VIEW_PATH);
+ History.newItem(InventoryView.VIEW_ID);
}
});
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
index e5bfc72..be66cb9 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
@@ -61,7 +61,6 @@ import
org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTyp
*/
public class ResourceGroupDetailView extends
AbstractTwoLevelTabSetView<ResourceGroupComposite, ResourceGroupTitleBar> {
public static final String AUTO_GROUP_VIEW_PATH = "Resource/AutoGroup";
- public static final String GROUP_VIEW_PATH = "ResourceGroup";
private Integer groupId;
private ResourceGroupComposite groupComposite;
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTopView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTopView.java
index 3e87e03..5c8670e 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTopView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTopView.java
@@ -32,6 +32,7 @@ import
org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
* @author Greg Hinkle
*/
public class ResourceGroupTopView extends LocatableHLayout implements BookmarkableView {
+ public static final String VIEW_ID = "ResourceGroup";
private Canvas contentCanvas;
private ResourceGroupTreeView treeView;
@@ -48,8 +49,8 @@ public class ResourceGroupTopView extends LocatableHLayout implements
Bookmarkab
setWidth100();
setHeight100();
- treeView = new ResourceGroupTreeView(getLocatorId());
- detailView = new ResourceGroupDetailView(extendLocatorId("Detail"),
ResourceGroupDetailView.GROUP_VIEW_PATH);
+ treeView = new ResourceGroupTreeView(extendLocatorId("Tree"));
+ detailView = new ResourceGroupDetailView(extendLocatorId("Detail"),
ResourceGroupTopView.VIEW_ID);
addMember(treeView);
contentCanvas = new Canvas();
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeView.java
index 01511fb..6c9127b 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeView.java
@@ -119,7 +119,7 @@ public class ResourceGroupTreeView extends LocatableVLayout implements
Bookmarka
// The root group was selected.
String groupId = selectedNode.getAttribute("id");
//System.out.println("Selecting group [" + groupId
+ "]...");
- String viewPath = "ResourceGroup/" + groupId;
+ String viewPath = ResourceGroupTopView.VIEW_ID +
"/" + groupId;
String currentViewPath = History.getToken();
if (!currentViewPath.startsWith(viewPath)) {
CoreGUI.goToView(viewPath);
@@ -250,7 +250,7 @@ public class ResourceGroupTreeView extends LocatableVLayout implements
Bookmarka
@Override
public void onSuccess(ResourceGroup result) {
int groupId = result.getId();
- History.newItem("ResourceGroup/" + groupId);
+ History.newItem(ResourceGroupTopView.VIEW_ID + "/" +
groupId);
}
});
}
@@ -274,7 +274,7 @@ public class ResourceGroupTreeView extends LocatableVLayout implements
Bookmarka
Tree tree = new Tree();
tree.setRoot(fakeRoot);
- TreeUtility.printTree(tree);
+ //TreeUtility.printTree(tree);
treeGrid.setData(tree);
treeGrid.markForRedraw();
@@ -316,7 +316,6 @@ public class ResourceGroupTreeView extends LocatableVLayout implements
Bookmarka
// Insert an autoTypeGroup node if the type is not a singleton.
if (!childType.isSingleton()) {
- // Otherwise insert an autoTypeGroup folder node to group all cluster
groups of this type.
TreeNode autoTypeGroupNode = createAutoTypeGroupNode(childType,
nodesByType);
nodesByType.clear();
nodesByType.add(autoTypeGroupNode);
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java
index f94170b..e102771 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java
@@ -56,8 +56,7 @@ import
org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableTreeGrid;
* @author Joseph Marques
*/
public class InventoryView extends LocatableHLayout implements BookmarkableView {
-
- public static final String VIEW_PATH = "Inventory";
+ public static final String VIEW_ID = "Inventory";
private static final String SECTION_GROUPS = "Groups";
private static final String SECTION_RESOURCES = "Resources";
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
index 030eb2b..b2cadc1 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
@@ -319,7 +319,7 @@ public class ResourceDetailView extends
AbstractTwoLevelTabSetView<ResourceCompo
new Message("Resource with id [" + resourceId + "]
does not exist or is not accessible.",
Message.Severity.Warning));
- CoreGUI.goToView(InventoryView.VIEW_PATH);
+ CoreGUI.goToView(InventoryView.VIEW_ID);
}
public void onSuccess(PageList<ResourceComposite> result) {
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTopView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTopView.java
index 01b72dd..836b35e 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTopView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTopView.java
@@ -29,6 +29,7 @@ import
org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
* @author Greg Hinkle
*/
public class ResourceTopView extends LocatableHLayout implements BookmarkableView {
+ public static final String VIEW_ID = "Resource";
private Canvas contentCanvas;
private ResourceTreeView treeView;
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 f5f7dce..233637e 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
@@ -56,8 +56,7 @@ import
org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableTreeGrid;
* @author Greg Hinkle
*/
public class ReportTopView extends LocatableHLayout implements BookmarkableView {
-
- public static final String VIEW_PATH = "Reports";
+ public static final String VIEW_ID = "Reports";
private static final String SECTION_INVENTORY = "Inventory";
private static final String SECTION_REPORTS = "Reports";
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/tag/TaggedView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/tag/TaggedView.java
index 66ff323..20ddd34 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/tag/TaggedView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/tag/TaggedView.java
@@ -42,6 +42,7 @@ import
org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
* @author Greg Hinkle
*/
public class TaggedView extends LocatableVLayout implements BookmarkableView {
+ public static final String VIEW_ID = "Tag";
private TagCloudView tagCloudView;
commit 64abb7e08a090c0c44bdc64b31bb56adfdeb2805
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Tue Sep 28 08:35:16 2010 -0400
BZ 616918 - default the "detailed discovery" boolean parameter to true
diff --git a/modules/plugins/platform/src/main/resources/META-INF/rhq-plugin.xml
b/modules/plugins/platform/src/main/resources/META-INF/rhq-plugin.xml
index 22f4cb1..5a4a8a7 100644
--- a/modules/plugins/platform/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/platform/src/main/resources/META-INF/rhq-plugin.xml
@@ -11,7 +11,7 @@
<!ENTITY platformOperations '
<operation name="discovery" displayName="Manual
Autodiscovery" description="Run an immediate discovery to search for
resources">
<parameters>
- <c:simple-property name="detailedDiscovery" description="If
true, search for detailed child resources in addition to parent servers."
type="boolean"/>
+ <c:simple-property name="detailedDiscovery" description="If
true, search for detailed child resources in addition to parent servers."
type="boolean" default="true" required="true"/>
</parameters>
<results>
<c:simple-property name="operationResult"
type="longString"/>
commit 3f9a45b1b1dbbcdfb07009c71c4dd2bc202eba45
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Tue Sep 28 09:57:30 2010 +0200
fix for the rare NPE in the disambiguation which could happen in the views that
contained multiple results for single resource (e.g. list of alert history across all
resources)
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/Disambiguator.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/Disambiguator.java
index 617d4fd..01d60fc 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/Disambiguator.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/Disambiguator.java
@@ -34,6 +34,8 @@ import javax.persistence.Query;
import org.rhq.core.domain.resource.composite.DisambiguationReport;
import org.rhq.core.util.IntExtractor;
+import
org.rhq.enterprise.server.resource.disambiguation.MutableDisambiguationReport.Resource;
+import
org.rhq.enterprise.server.resource.disambiguation.MutableDisambiguationReport.ResourceType;
/**
* This is basically a helper class that provides the disambiguation method.
@@ -197,8 +199,8 @@ public class Disambiguator {
//update all the reports that correspond to this resourceId
for (MutableDisambiguationReport<T> report :
reportsByResourceId.get(resourceId)) {
- report.resource = resource;
- report.parents = parents;
+ report.resource = resource.clone();
+ report.parents = deepCopy(parents);
partitionedReports.put(report);
}
@@ -290,4 +292,13 @@ public class Disambiguator {
}
}
}
+
+ private static List<Resource> deepCopy(List<Resource> original) {
+ ArrayList<Resource> copy = new ArrayList<Resource>();
+
+ for (Resource o : original) {
+ copy.add(o.clone());
+ }
+ return copy;
+ }
}
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/MutableDisambiguationReport.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/MutableDisambiguationReport.java
index 68995d9..3084285 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/MutableDisambiguationReport.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/MutableDisambiguationReport.java
@@ -38,7 +38,7 @@ import org.rhq.core.domain.resource.composite.DisambiguationReport;
* @author Lukas Krejci
*/
public class MutableDisambiguationReport<T> {
- public static class ResourceType {
+ public static class ResourceType implements Cloneable {
public int id;
public String name;
public String plugin;
@@ -51,9 +51,20 @@ public class MutableDisambiguationReport<T> {
public String toString() {
return "MutableResourceType[id=" + id + ", name='" +
name + "', plugin='" + plugin + "', singleton=" +
singleton + "]";
}
+
+ @Override
+ public ResourceType clone() {
+ ResourceType ret = new ResourceType();
+ ret.id = id;
+ ret.name = name;
+ ret.plugin = plugin;
+ ret.singleton = singleton;
+
+ return ret;
+ }
}
- public static class Resource {
+ public static class Resource implements Cloneable {
public int id;
public String name;
public MutableDisambiguationReport.ResourceType resourceType;
@@ -65,6 +76,16 @@ public class MutableDisambiguationReport<T> {
public String toString() {
return "MutableResource[id=" + id + ", name='" + name
+ ", resourceType=" + resourceType + "]";
}
+
+ @Override
+ public Resource clone() {
+ Resource ret = new Resource();
+ ret.id = id;
+ ret.name = name;
+ ret.resourceType = resourceType.clone();
+
+ return ret;
+ }
}
public T original;
commit 6c22cc997a52ed1bc1f27244cfb3b548b952770d
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Mon Sep 27 20:41:53 2010 -0400
add subcategory nodes to group tree
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tree/EnhancedTreeNode.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tree/EnhancedTreeNode.java
index 89583b4..11a78dc 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tree/EnhancedTreeNode.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tree/EnhancedTreeNode.java
@@ -24,6 +24,17 @@ import com.smartgwt.client.widgets.tree.TreeNode;
* @author Ian Springer
*/
public class EnhancedTreeNode extends TreeNode {
+ public EnhancedTreeNode() {
+ }
+
+ public EnhancedTreeNode(String name) {
+ super(name);
+ }
+
+ public EnhancedTreeNode(String name, TreeNode... children) {
+ super(name, children);
+ }
+
public String getID() {
return getAttribute(Attributes.ID);
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeView.java
index f54ffd2..01511fb 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeView.java
@@ -23,6 +23,7 @@
package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail;
import java.util.ArrayList;
+import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -42,6 +43,7 @@ import com.smartgwt.client.widgets.tree.events.NodeContextClickEvent;
import com.smartgwt.client.widgets.tree.events.NodeContextClickHandler;
import org.rhq.core.domain.criteria.ResourceGroupCriteria;
+import org.rhq.core.domain.resource.ResourceSubCategory;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.resource.group.ClusterKey;
import org.rhq.core.domain.resource.group.GroupCategory;
@@ -53,9 +55,11 @@ 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.gwt.GWTServiceLookup;
import
org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
import org.rhq.enterprise.gui.coregui.client.util.StringUtility;
+import org.rhq.enterprise.gui.coregui.client.util.TreeUtility;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
/**
@@ -107,19 +111,23 @@ public class ResourceGroupTreeView extends LocatableVLayout
implements Bookmarka
if (selectionEvent.getState()) {
Record selectedNode = selectionEvent.getRecord();
System.out.println("Node selected in tree: " +
selectedNode);
- ClusterKey key = (ClusterKey)
selectedNode.getAttributeAsObject("key");
- if (key == null) {
- // The root group was selected.
- String groupId = selectedNode.getAttribute("id");
- //System.out.println("Selecting group [" + groupId +
"]...");
- String viewPath = "ResourceGroup/" + groupId;
- String currentViewPath = History.getToken();
- if (!currentViewPath.startsWith(viewPath)) {
- CoreGUI.goToView(viewPath);
+ ResourceType type = (ResourceType)
selectedNode.getAttributeAsObject("resourceType");
+ if (type != null) {
+ // It's a cluster group node, not a subcategory node or an
autoTypeGroup node.
+ ClusterKey key = (ClusterKey)
selectedNode.getAttributeAsObject("key");
+ if (key == null) {
+ // The root group was selected.
+ String groupId = selectedNode.getAttribute("id");
+ //System.out.println("Selecting group [" + groupId
+ "]...");
+ String viewPath = "ResourceGroup/" + groupId;
+ String currentViewPath = History.getToken();
+ if (!currentViewPath.startsWith(viewPath)) {
+ CoreGUI.goToView(viewPath);
+ }
+ } else {
+ //System.out.println("Selecting cluster group [" +
key + "]...");
+ selectClusterGroup(key);
}
- } else {
- //System.out.println("Selecting cluster group [" + key
+ "]...");
- selectClusterGroup(key);
}
}
}
@@ -221,6 +229,7 @@ public class ResourceGroupTreeView extends LocatableVLayout implements
Bookmarka
getTreeTypes(root, typeIds);
ResourceTypeRepository.Cache.getInstance().getResourceTypes(typeIds.toArray(new
Integer[typeIds.size()]),
+ EnumSet.of(ResourceTypeRepository.MetadataType.subCategory),
new ResourceTypeRepository.TypesLoadedCallback() {
@Override
public void onTypesLoaded(Map<Integer, ResourceType> types) {
@@ -261,10 +270,11 @@ public class ResourceGroupTreeView extends LocatableVLayout
implements Bookmarka
ClusterKey rootKey = new ClusterKey(root.getGroupId());
loadTree(rootNode, root, rootKey);
-
+
Tree tree = new Tree();
tree.setRoot(fakeRoot);
+ TreeUtility.printTree(tree);
treeGrid.setData(tree);
treeGrid.markForRedraw();
@@ -288,11 +298,13 @@ public class ResourceGroupTreeView extends LocatableVLayout
implements Bookmarka
// Second pass - process each of the sets of like-typed children created in
the first pass.
List<TreeNode> childNodes = new ArrayList<TreeNode>();
- for (ResourceType type : childrenByType.keySet()) {
- List<ClusterFlyweight> children = childrenByType.get(type);
+ Map<String, TreeNode> subCategoryNodesByName = new HashMap<String,
TreeNode>();
+ Map<String, List<TreeNode>> subCategoryChildrenByName = new
HashMap<String, List<TreeNode>>();
+ for (ResourceType childType : childrenByType.keySet()) {
+ List<ClusterFlyweight> children = childrenByType.get(childType);
List<TreeNode> nodesByType = new ArrayList<TreeNode>();
for (ClusterFlyweight child : children) {
- TreeNode node = createClusterGroupNode(parentKey, type, child);
+ TreeNode node = createClusterGroupNode(parentKey, childType, child);
nodesByType.add(node);
if (!child.getChildren().isEmpty()) {
@@ -302,23 +314,66 @@ public class ResourceGroupTreeView extends LocatableVLayout
implements Bookmarka
}
}
- // TODO (ips): Insert subcategory nodes.
+ // Insert an autoTypeGroup node if the type is not a singleton.
+ if (!childType.isSingleton()) {
+ // Otherwise insert an autoTypeGroup folder node to group all cluster
groups of this type.
+ TreeNode autoTypeGroupNode = createAutoTypeGroupNode(childType,
nodesByType);
+ nodesByType.clear();
+ nodesByType.add(autoTypeGroupNode);
+ }
+
+ // Insert subcategory node(s) if the type has a subcategory.
+ ResourceSubCategory subcategory = childType.getSubCategory();
+ if (subcategory != null) {
+ TreeNode lastSubcategoryNode = null;
+
+ ResourceSubCategory currentSubCategory = subcategory;
+ boolean currentSubcategoryNodeCreated = false;
+ do {
+ TreeNode currentSubcategoryNode =
subCategoryNodesByName.get(currentSubCategory.getName());
+ if (currentSubcategoryNode == null) {
+ currentSubcategoryNode = new
EnhancedTreeNode(currentSubCategory.getName());
+ // Note, subcategory names are typically already plural, so
there's no need to pluralize them.
+
currentSubcategoryNode.setTitle(currentSubCategory.getDisplayName());
+ currentSubcategoryNode.setIsFolder(true);
+ subCategoryNodesByName.put(currentSubCategory.getName(),
currentSubcategoryNode);
+ subCategoryChildrenByName.put(currentSubCategory.getName(),
new ArrayList<TreeNode>());
+
+ if (currentSubCategory.getParentSubCategory() == null) {
+ // It's a root subcategory - add a node for it to the
tree.
+ childNodes.add(currentSubcategoryNode);
+ }
+
+ currentSubcategoryNodeCreated = true;
+ }
+
+ if (lastSubcategoryNode != null) {
+ List<TreeNode> currentSubcategoryChildren =
subCategoryChildrenByName.get(currentSubcategoryNode.getName());
+ currentSubcategoryChildren.add(lastSubcategoryNode);
+ }
+ lastSubcategoryNode = currentSubcategoryNode;
+ } while (currentSubcategoryNodeCreated &&
+ (currentSubCategory =
currentSubCategory.getParentSubCategory()) != null);
- if (type.isSingleton()) {
- // If it's a singleton type, just insert the cluster group node
as is.
+ List<TreeNode> subcategoryChildren =
subCategoryChildrenByName.get(subcategory.getName());
+ subcategoryChildren.addAll(nodesByType);
+ } else {
childNodes.addAll(nodesByType);
- } else {
- // Otherwise insert an autoTypeGroup folder node to group all cluster
groups of this type.
- TreeNode autoTypeGroupNode = createAutoTypeGroupNode(type,
nodesByType);
- childNodes.add(autoTypeGroupNode);
}
}
+
+ for (String subcategoryName : subCategoryNodesByName.keySet()) {
+ TreeNode subcategoryNode = subCategoryNodesByName.get(subcategoryName);
+ List<TreeNode> subcategoryChildren =
subCategoryChildrenByName.get(subcategoryName);
+ subcategoryNode.setChildren(subcategoryChildren.toArray(new
TreeNode[subcategoryChildren.size()]));
+ }
+
parentNode.setChildren(childNodes.toArray(new TreeNode[childNodes.size()]));
}
}
private TreeNode createClusterGroupNode(ClusterKey parentKey, ResourceType type,
ClusterFlyweight child) {
- TreeNode node = new TreeNode(child.getName());
+ TreeNode node = new EnhancedTreeNode(child.getName());
ClusterKeyFlyweight keyFlyweight = child.getClusterKey();
ClusterKey key = new ClusterKey(parentKey, keyFlyweight.getResourceTypeId(),
keyFlyweight.getResourceKey());
@@ -335,16 +390,18 @@ public class ResourceGroupTreeView extends LocatableVLayout
implements Bookmarka
private TreeNode createAutoTypeGroupNode(ResourceType type, List<TreeNode>
memberNodes) {
String name = StringUtility.pluralize(type.getName());
- TreeNode autoTypeGroupNode = new TreeNode(name);
+ TreeNode autoTypeGroupNode = new EnhancedTreeNode(name);
autoTypeGroupNode.setIsFolder(true);
autoTypeGroupNode.setChildren(memberNodes.toArray(new
TreeNode[memberNodes.size()]));
return autoTypeGroupNode;
}
public void renderView(ViewPath viewPath) {
- currentViewId = viewPath.getCurrent();
- int groupId = Integer.parseInt(currentViewId.getPath());
- setSelectedGroup(groupId);
+ this.currentViewId = viewPath.getCurrent();
+ if (this.currentViewId != null) {
+ int groupId = Integer.parseInt(this.currentViewId.getPath());
+ setSelectedGroup(groupId);
+ }
}
private void getTreeTypes(ClusterFlyweight clusterFlyweight, Set<Integer>
typeIds) {
commit d6b4553df4da88b0964eb89b0dc8b4af49ae7d8b
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Mon Sep 27 17:50:04 2010 -0400
If setting to platforms viewpath issue an event. Otherwise selecting
'Platforms' from the section stack does nothing as it is
"invisibly"
selected already. But, moreover, comment out the whole thing and
don't display any content for the Inventory section, until the user
chooses something from the left nav.
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java
index 01f23a2..f94170b 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java
@@ -315,8 +315,10 @@ public class InventoryView extends LocatableHLayout implements
BookmarkableView
public void renderView(ViewPath viewPath) {
if (!viewPath.isCurrent(currentSectionViewId) ||
!viewPath.isNext(currentPageViewId)) {
if (viewPath.isEnd()) {
- // i.e. "Inventory" - display default view
- History.newItem("Inventory/Resources/Platforms", false);
+ // 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);
commit 2deb29dd26fec00c9d28c6b6d75a823252f9c1c6
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Mon Sep 27 16:35:32 2010 -0400
Introduce AutoGroup Context Menu.
- Extracted ResourceGroupContextMenu out of ResourceGroupTreeContextMenu so
that both autogroup and clustergroup backing groups could utilize the
same ResourceGroup context menu code.
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupContextMenu.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupContextMenu.java
new file mode 100644
index 0000000..b31c33e
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupContextMenu.java
@@ -0,0 +1,306 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail;
+
+import java.util.EnumSet;
+import java.util.List;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.widgets.Window;
+import com.smartgwt.client.widgets.events.CloseClickHandler;
+import com.smartgwt.client.widgets.events.CloseClientEvent;
+import com.smartgwt.client.widgets.menu.Menu;
+import com.smartgwt.client.widgets.menu.MenuItem;
+import com.smartgwt.client.widgets.menu.MenuItemSeparator;
+import com.smartgwt.client.widgets.menu.events.ClickHandler;
+import com.smartgwt.client.widgets.menu.events.MenuItemClickEvent;
+
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.criteria.ResourceTypeCriteria;
+import org.rhq.core.domain.dashboard.Dashboard;
+import org.rhq.core.domain.dashboard.DashboardPortlet;
+import org.rhq.core.domain.measurement.MeasurementDefinition;
+import org.rhq.core.domain.operation.OperationDefinition;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.domain.resource.group.ResourceGroup;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.resource.graph.GraphPortlet;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.gwt.ResourceTypeGWTServiceAsync;
+import
org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
+import org.rhq.enterprise.gui.coregui.client.util.message.Message;
+
+/**
+ * @author Greg Hinkle
+ */
+public class ResourceGroupContextMenu extends Menu {
+
+ private ResourceType currentType;
+ //private ResourceGroup group;
+ private ResourceGroup currentGroup;
+
+ public void showContextMenu(ResourceGroup compatibleGroup) {
+ this.currentType = compatibleGroup.getResourceType();
+ this.currentGroup = compatibleGroup;
+
+ ResourceTypeRepository.Cache.getInstance().getResourceTypes(
+ currentType.getId(),
+ EnumSet.of(ResourceTypeRepository.MetadataType.operations,
ResourceTypeRepository.MetadataType.children,
+ ResourceTypeRepository.MetadataType.subCategory,
+ ResourceTypeRepository.MetadataType.pluginConfigurationDefinition,
+ ResourceTypeRepository.MetadataType.resourceConfigurationDefinition),
+ new ResourceTypeRepository.TypeLoadedCallback() {
+ public void onTypesLoaded(ResourceType type) {
+
+ currentType = type;
+
+ buildResourceGroupContextMenu(currentGroup, type);
+ showContextMenu();
+ }
+ });
+
+ }
+
+ private void buildResourceGroupContextMenu(final ResourceGroup group, final
ResourceType resourceType) {
+ setItems(new MenuItem(group.getName()));
+
+ addItem(new MenuItem("Type: " + resourceType.getName()));
+
+ MenuItem editPluginConfiguration = new MenuItem("Plugin
Configuration");
+ editPluginConfiguration.addClickHandler(new ClickHandler() {
+ public void onClick(MenuItemClickEvent event) {
+ int groupId = group.getId();
+ int resourceTypeId = resourceType.getId();
+
+ Window configEditor = new Window();
+ // configEditor.setTitle("Edit " +
group.getName() + " plugin configuration");
+ configEditor.setWidth(800);
+ configEditor.setHeight(800);
+ configEditor.setIsModal(true);
+ configEditor.setShowModalMask(true);
+ configEditor.setCanDragResize(true);
+ configEditor.centerInPage();
+ // TODO Group config editor
+ // configEditor.addItem(new
ConfigurationEditor(resourceId, resourceTypeId,
+ // ConfigurationEditor.ConfigType.plugin));
+ configEditor.show();
+
+ }
+ });
+
editPluginConfiguration.setEnabled(resourceType.getPluginConfigurationDefinition() !=
null);
+ addItem(editPluginConfiguration);
+
+ MenuItem editResourceConfiguration = new MenuItem("Resource
Configuration");
+ editResourceConfiguration.addClickHandler(new ClickHandler() {
+ public void onClick(MenuItemClickEvent event) {
+ int groupId = group.getId();
+ int resourceTypeId = resourceType.getId();
+
+ final Window configEditor = new Window();
+ configEditor.setTitle("Edit " + group.getName() + "
resource configuration");
+ configEditor.setWidth(800);
+ configEditor.setHeight(800);
+ configEditor.setIsModal(true);
+ configEditor.setShowModalMask(true);
+ configEditor.setCanDragResize(true);
+ configEditor.setShowResizer(true);
+ configEditor.centerInPage();
+ configEditor.addCloseClickHandler(new CloseClickHandler() {
+ public void onCloseClick(CloseClientEvent closeClientEvent) {
+ configEditor.destroy();
+ }
+ });
+ // TODO group config editor
+ // configEditor.addItem(new
ConfigurationEditor(resourceId, resourceTypeId,
+ // ConfigurationEditor.ConfigType.resource));
+ configEditor.show();
+
+ }
+ });
+
editResourceConfiguration.setEnabled(resourceType.getResourceConfigurationDefinition() !=
null);
+ addItem(editResourceConfiguration);
+
+ addItem(new MenuItemSeparator());
+
+ // Operations Menu
+ MenuItem operations = new MenuItem("Operations");
+ Menu opSubMenu = new Menu();
+ if (resourceType.getOperationDefinitions() != null) {
+ for (final OperationDefinition operationDefinition :
resourceType.getOperationDefinitions()) {
+ MenuItem operationItem = new
MenuItem(operationDefinition.getDisplayName());
+ operationItem.addClickHandler(new ClickHandler() {
+ public void onClick(MenuItemClickEvent event) {
+
+ // TODO Group version
+ // ResourceCriteria criteria = new
ResourceCriteria();
+ // criteria.addFilterId(selectedResourceId);
+ //
+ //
GWTServiceLookup.getResourceService().findResourcesByCriteria(criteria,
+ // new
AsyncCallback<PageList<Resource>>() {
+ // public void onFailure(Throwable
caught) {
+ // CoreGUI.getErrorHandler()
+ // .handleError("Failed
to get resource to run operation", caught);
+ // }
+ //
+ // public void
onSuccess(PageList<Resource> result) {
+ // new
OperationCreateWizard(result.get(0), operationDefinition).startOperationWizard();
+ // }
+ // });
+
+ }
+ });
+ opSubMenu.addItem(operationItem);
+ }
+ }
+ operations.setEnabled(resourceType.getOperationDefinitions() != null
+ && !resourceType.getOperationDefinitions().isEmpty());
+ operations.setSubmenu(opSubMenu);
+ addItem(operations);
+
+ addItem(buildMetricsMenu(resourceType));
+
+ /* TODO: We don't support group factory create
+ // Create Menu
+ MenuItem createChildMenu = new MenuItem("Create Child");
+ Menu createChildSubMenu = new Menu();
+ for (final ResourceType childType : resourceType.getChildResourceTypes()) {
+ if (childType.isCreatable()) {
+ MenuItem createItem = new MenuItem(childType.getName());
+ createChildSubMenu.addItem(createItem);
+ createItem.addClickHandler(new ClickHandler() {
+ public void onClick(MenuItemClickEvent event) {
+ ResourceFactoryCreateWizard.showCreateWizard(resource,
childType);
+ }
+ });
+
+ }
+ }
+ createChildMenu.setSubmenu(createChildSubMenu);
+ createChildMenu.setEnabled(createChildSubMenu.getItems().length > 0);
+ contextMenu.addItem(createChildMenu);*/
+
+ /*
+ // TODO We don't group manual import
+ // Manually Add Menu
+ MenuItem importChildMenu = new MenuItem("Import");
+ Menu importChildSubMenu = new Menu();
+ for (ResourceType childType : resourceType.getChildResourceTypes()) {
+ if (childType.isSupportsManualAdd()) {
+ importChildSubMenu.addItem(new MenuItem(childType.getName()));
+ }
+ }
+ if (resourceType.getCategory() == ResourceCategory.PLATFORM) {
+ loadManuallyAddServersToPlatforms(importChildSubMenu);
+ }
+ importChildMenu.setSubmenu(importChildSubMenu);
+ importChildMenu.setEnabled(importChildSubMenu.getItems().length > 0);
+ addItem(importChildMenu);
+ */
+ }
+
+ private void loadManuallyAddServersToPlatforms(final Menu manuallyAddMenu) {
+ ResourceTypeGWTServiceAsync rts = GWTServiceLookup.getResourceTypeGWTService();
+
+ ResourceTypeCriteria criteria = new ResourceTypeCriteria();
+ criteria.addFilterSupportsManualAdd(true);
+ criteria.fetchParentResourceTypes(true);
+ rts.findResourceTypesByCriteria(criteria, new
AsyncCallback<PageList<ResourceType>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to load platform
manual add children", caught);
+ }
+
+ public void onSuccess(PageList<ResourceType> result) {
+ for (ResourceType type : result) {
+ if (type.getParentResourceTypes() == null ||
type.getParentResourceTypes().isEmpty()) {
+ MenuItem item = new MenuItem(type.getName());
+ manuallyAddMenu.addItem(item);
+ }
+ }
+ }
+ });
+ }
+
+ private MenuItem buildMetricsMenu(final ResourceType type) {
+ MenuItem measurements = new MenuItem("Measurements");
+ final Menu measurementsSubMenu = new Menu();
+
+ GWTServiceLookup.getDashboardService().findDashboardsForSubject(new
AsyncCallback<List<Dashboard>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to load user
dashboards", caught);
+ }
+
+ public void onSuccess(List<Dashboard> result) {
+
+ if (type.getMetricDefinitions() != null) {
+ for (final MeasurementDefinition def : type.getMetricDefinitions())
{
+
+ MenuItem defItem = new MenuItem(def.getDisplayName());
+ measurementsSubMenu.addItem(defItem);
+ Menu defSubItem = new Menu();
+ defItem.setSubmenu(defSubItem);
+
+ for (final Dashboard d : result) {
+ MenuItem addToDBItem = new MenuItem("Add chart to
Dashboard: " + d.getName());
+ defSubItem.addItem(addToDBItem);
+
+ addToDBItem.addClickHandler(new ClickHandler() {
+ public void onClick(MenuItemClickEvent
menuItemClickEvent) {
+
+ DashboardPortlet p = new
DashboardPortlet(def.getDisplayName() + " Chart",
+ GraphPortlet.KEY, 250);
+ p.getConfiguration().put(
+ new
PropertySimple(GraphPortlet.CFG_RESOURCE_GROUP_ID, currentGroup.getId()));
+ p.getConfiguration().put(
+ new
PropertySimple(GraphPortlet.CFG_DEFINITION_ID, def.getId()));
+
+ d.addPortlet(p, 0, 0);
+
+
GWTServiceLookup.getDashboardService().storeDashboard(d,
+ new AsyncCallback<Dashboard>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(
+ "Failed to save dashboard to
server", caught);
+ }
+
+ public void onSuccess(Dashboard result) {
+ CoreGUI.getMessageCenter().notify(
+ new Message("Saved dashboard
" + result.getName() + " to server",
+ Message.Severity.Info));
+ }
+ });
+
+ }
+ });
+
+ }
+
+ }
+ }
+
+ }
+ });
+ measurements.setSubmenu(measurementsSubMenu);
+ return measurements;
+ }
+}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeContextMenu.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeContextMenu.java
index 8e1e178..16c6369 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeContextMenu.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeContextMenu.java
@@ -22,328 +22,53 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail;
-import java.util.EnumSet;
-import java.util.List;
-
import com.google.gwt.user.client.rpc.AsyncCallback;
-import com.smartgwt.client.widgets.Window;
-import com.smartgwt.client.widgets.events.CloseClickHandler;
-import com.smartgwt.client.widgets.events.CloseClientEvent;
-import com.smartgwt.client.widgets.menu.Menu;
-import com.smartgwt.client.widgets.menu.MenuItem;
-import com.smartgwt.client.widgets.menu.MenuItemSeparator;
-import com.smartgwt.client.widgets.menu.events.ClickHandler;
-import com.smartgwt.client.widgets.menu.events.MenuItemClickEvent;
import com.smartgwt.client.widgets.tree.TreeNode;
-import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.criteria.ResourceGroupCriteria;
-import org.rhq.core.domain.criteria.ResourceTypeCriteria;
-import org.rhq.core.domain.dashboard.Dashboard;
-import org.rhq.core.domain.dashboard.DashboardPortlet;
-import org.rhq.core.domain.measurement.MeasurementDefinition;
-import org.rhq.core.domain.operation.OperationDefinition;
-import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.resource.group.ClusterKey;
import org.rhq.core.domain.resource.group.ResourceGroup;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
-import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.resource.graph.GraphPortlet;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
-import org.rhq.enterprise.gui.coregui.client.gwt.ResourceTypeGWTServiceAsync;
-import
org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
-import org.rhq.enterprise.gui.coregui.client.util.message.Message;
/**
* @author Greg Hinkle
*/
-public class ResourceGroupTreeContextMenu extends Menu {
-
- private ResourceType currentType;
- private ResourceGroup group;
- private ResourceGroup currentGroup;
+public class ResourceGroupTreeContextMenu extends ResourceGroupContextMenu {
public void showContextMenu(TreeNode node) {
- currentType = (ResourceType)
node.getAttributeAsObject("resourceType");
-
-
final ClusterKey clusterKey = (ClusterKey)
node.getAttributeAsObject("key");
if (clusterKey != null) {
GWTServiceLookup.getClusterService().createAutoClusterBackingGroup(clusterKey, true,
- new AsyncCallback<ResourceGroup>() {
- @Override
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to create
or update auto-cluster group: " + clusterKey, caught);
- }
+ new AsyncCallback<ResourceGroup>() {
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(
+ "Failed to create or update auto-cluster group: " +
clusterKey, caught);
+ }
- @Override
- public void onSuccess(ResourceGroup result) {
- showContextMenu(result);
- }
- });
+ @Override
+ public void onSuccess(ResourceGroup result) {
+ showContextMenu(result);
+ }
+ });
} else {
ResourceGroupCriteria criteria = new ResourceGroupCriteria();
criteria.addFilterId(Integer.parseInt(node.getAttribute("id")));
GWTServiceLookup.getResourceGroupService().findResourceGroupsByCriteria(criteria,
- new AsyncCallback<PageList<ResourceGroup>>() {
- @Override
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to load
group for context menu", caught);
- }
-
- @Override
- public void onSuccess(PageList<ResourceGroup> result) {
- showContextMenu(result.get(0));
- }
- });
- }
-
-
- }
-
- private void showContextMenu(ResourceGroup group) {
- this.currentGroup = group;
-
- ResourceTypeRepository.Cache.getInstance().getResourceTypes(
- currentType.getId(),
- EnumSet.of(ResourceTypeRepository.MetadataType.operations,
- ResourceTypeRepository.MetadataType.children,
- ResourceTypeRepository.MetadataType.subCategory,
-
ResourceTypeRepository.MetadataType.pluginConfigurationDefinition,
-
ResourceTypeRepository.MetadataType.resourceConfigurationDefinition),
- new ResourceTypeRepository.TypeLoadedCallback() {
- public void onTypesLoaded(ResourceType type) {
-
- currentType = type;
-
-
- buildResourceGroupContextMenu(currentGroup, type);
- showContextMenu();
+ new AsyncCallback<PageList<ResourceGroup>>() {
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to load group
for context menu", caught);
}
- });
-
- }
-
-
- private void buildResourceGroupContextMenu(final ResourceGroup group, final
ResourceType resourceType) {
- setItems(new MenuItem(group.getName()));
-
- addItem(new MenuItem("Type: " + resourceType.getName()));
-
- MenuItem editPluginConfiguration = new MenuItem("Plugin
Configuration");
- editPluginConfiguration.addClickHandler(new ClickHandler() {
- public void onClick(MenuItemClickEvent event) {
- int groupId = group.getId();
- int resourceTypeId = resourceType.getId();
-
- Window configEditor = new Window();
-// configEditor.setTitle("Edit " + group.getName() + "
plugin configuration");
- configEditor.setWidth(800);
- configEditor.setHeight(800);
- configEditor.setIsModal(true);
- configEditor.setShowModalMask(true);
- configEditor.setCanDragResize(true);
- configEditor.centerInPage();
- // TODO Group config editor
-// configEditor.addItem(new ConfigurationEditor(resourceId,
resourceTypeId,
-// ConfigurationEditor.ConfigType.plugin));
- configEditor.show();
- }
- });
-
editPluginConfiguration.setEnabled(resourceType.getPluginConfigurationDefinition() !=
null);
- addItem(editPluginConfiguration);
-
- MenuItem editResourceConfiguration = new MenuItem("Resource
Configuration");
- editResourceConfiguration.addClickHandler(new ClickHandler() {
- public void onClick(MenuItemClickEvent event) {
- int groupId = group.getId();
- int resourceTypeId = resourceType.getId();
-
- final Window configEditor = new Window();
- configEditor.setTitle("Edit " + group.getName() + "
resource configuration");
- configEditor.setWidth(800);
- configEditor.setHeight(800);
- configEditor.setIsModal(true);
- configEditor.setShowModalMask(true);
- configEditor.setCanDragResize(true);
- configEditor.setShowResizer(true);
- configEditor.centerInPage();
- configEditor.addCloseClickHandler(new CloseClickHandler() {
- public void onCloseClick(CloseClientEvent closeClientEvent) {
- configEditor.destroy();
+ @Override
+ public void onSuccess(PageList<ResourceGroup> result) {
+ showContextMenu(result.get(0));
}
});
- // TODO group config editor
-// configEditor.addItem(new ConfigurationEditor(resourceId,
resourceTypeId,
-// ConfigurationEditor.ConfigType.resource));
- configEditor.show();
-
- }
- });
-
editResourceConfiguration.setEnabled(resourceType.getResourceConfigurationDefinition() !=
null);
- addItem(editResourceConfiguration);
-
- addItem(new MenuItemSeparator());
-
- // Operations Menu
- MenuItem operations = new MenuItem("Operations");
- Menu opSubMenu = new Menu();
- if (resourceType.getOperationDefinitions() != null) {
- for (final OperationDefinition operationDefinition :
resourceType.getOperationDefinitions()) {
- MenuItem operationItem = new
MenuItem(operationDefinition.getDisplayName());
- operationItem.addClickHandler(new ClickHandler() {
- public void onClick(MenuItemClickEvent event) {
-
- // TODO Group version
-// ResourceCriteria criteria = new ResourceCriteria();
-// criteria.addFilterId(selectedResourceId);
-//
-//
GWTServiceLookup.getResourceService().findResourcesByCriteria(criteria,
-// new AsyncCallback<PageList<Resource>>() {
-// public void onFailure(Throwable caught) {
-// CoreGUI.getErrorHandler()
-// .handleError("Failed to get resource to run
operation", caught);
-// }
-//
-// public void onSuccess(PageList<Resource> result) {
-// new OperationCreateWizard(result.get(0),
operationDefinition).startOperationWizard();
-// }
-// });
-
- }
- });
- opSubMenu.addItem(operationItem);
- }
- }
- operations.setEnabled(resourceType.getOperationDefinitions() != null &&
!resourceType.getOperationDefinitions().isEmpty());
- operations.setSubmenu(opSubMenu);
- addItem(operations);
-
- addItem(buildMetricsMenu(resourceType));
-
- /* TODO: We don't support group factory create
- // Create Menu
- MenuItem createChildMenu = new MenuItem("Create Child");
- Menu createChildSubMenu = new Menu();
- for (final ResourceType childType : resourceType.getChildResourceTypes()) {
- if (childType.isCreatable()) {
- MenuItem createItem = new MenuItem(childType.getName());
- createChildSubMenu.addItem(createItem);
- createItem.addClickHandler(new ClickHandler() {
- public void onClick(MenuItemClickEvent event) {
- ResourceFactoryCreateWizard.showCreateWizard(resource,
childType);
- }
- });
-
- }
- }
- createChildMenu.setSubmenu(createChildSubMenu);
- createChildMenu.setEnabled(createChildSubMenu.getItems().length > 0);
- contextMenu.addItem(createChildMenu);*/
-
- /*
- // TODO We don't group manual import
- // Manually Add Menu
- MenuItem importChildMenu = new MenuItem("Import");
- Menu importChildSubMenu = new Menu();
- for (ResourceType childType : resourceType.getChildResourceTypes()) {
- if (childType.isSupportsManualAdd()) {
- importChildSubMenu.addItem(new MenuItem(childType.getName()));
- }
- }
- if (resourceType.getCategory() == ResourceCategory.PLATFORM) {
- loadManuallyAddServersToPlatforms(importChildSubMenu);
}
- importChildMenu.setSubmenu(importChildSubMenu);
- importChildMenu.setEnabled(importChildSubMenu.getItems().length > 0);
- addItem(importChildMenu);
- */
- }
-
- private void loadManuallyAddServersToPlatforms(final Menu manuallyAddMenu) {
- ResourceTypeGWTServiceAsync rts = GWTServiceLookup.getResourceTypeGWTService();
-
- ResourceTypeCriteria criteria = new ResourceTypeCriteria();
- criteria.addFilterSupportsManualAdd(true);
- criteria.fetchParentResourceTypes(true);
- rts.findResourceTypesByCriteria(criteria, new
AsyncCallback<PageList<ResourceType>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to load platform
manual add children", caught);
- }
-
- public void onSuccess(PageList<ResourceType> result) {
- for (ResourceType type : result) {
- if (type.getParentResourceTypes() == null ||
type.getParentResourceTypes().isEmpty()) {
- MenuItem item = new MenuItem(type.getName());
- manuallyAddMenu.addItem(item);
- }
- }
- }
- });
- }
-
- private MenuItem buildMetricsMenu(final ResourceType type) {
- MenuItem measurements = new MenuItem("Measurements");
- final Menu measurementsSubMenu = new Menu();
-
- GWTServiceLookup.getDashboardService().findDashboardsForSubject(new
AsyncCallback<List<Dashboard>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to load user
dashboards", caught);
- }
-
- public void onSuccess(List<Dashboard> result) {
-
- if (type.getMetricDefinitions() != null) {
- for (final MeasurementDefinition def : type.getMetricDefinitions())
{
-
- MenuItem defItem = new MenuItem(def.getDisplayName());
- measurementsSubMenu.addItem(defItem);
- Menu defSubItem = new Menu();
- defItem.setSubmenu(defSubItem);
-
- for (final Dashboard d : result) {
- MenuItem addToDBItem = new MenuItem("Add chart to
Dashboard: " + d.getName());
- defSubItem.addItem(addToDBItem);
-
- addToDBItem.addClickHandler(new ClickHandler() {
- public void onClick(MenuItemClickEvent
menuItemClickEvent) {
-
- DashboardPortlet p = new
DashboardPortlet(def.getDisplayName() + " Chart",
- GraphPortlet.KEY, 250);
- p.getConfiguration().put(
- new
PropertySimple(GraphPortlet.CFG_RESOURCE_GROUP_ID, group.getId()));
- p.getConfiguration().put(
- new
PropertySimple(GraphPortlet.CFG_DEFINITION_ID, def.getId()));
-
- d.addPortlet(p, 0, 0);
-
-
GWTServiceLookup.getDashboardService().storeDashboard(d,
- new AsyncCallback<Dashboard>() {
- public void onFailure(Throwable caught)
{
-
CoreGUI.getErrorHandler().handleError("Failed to save dashboard to server",
- caught);
- }
-
- public void onSuccess(Dashboard result)
{
- CoreGUI.getMessageCenter().notify(
- new Message("Saved
dashboard " + result.getName() + " to server",
-
Message.Severity.Info));
- }
- });
-
- }
- });
-
- }
-
- }
- }
-
- }
- });
- measurements.setSubmenu(measurementsSubMenu);
- return measurements;
}
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
index 2c7a973..6a7cba9 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
@@ -75,6 +75,7 @@ import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGroupGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.gwt.ResourceTypeGWTServiceAsync;
+import
org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.ResourceGroupContextMenu;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceSelectListener;
import
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.ResourceTreeDatasource.AutoGroupTreeNode;
import
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.ResourceTreeDatasource.ResourceTreeNode;
@@ -91,12 +92,14 @@ public class ResourceTreeView extends LocatableVLayout {
private TreeGrid treeGrid;
private String selectedNodeId;
- private Menu contextMenu;
private Resource rootResource;
private ViewId currentViewId;
+ private Menu resourceContextMenu;
+ private ResourceGroupContextMenu autoGroupContextMenu;
+
private List<ResourceSelectListener> selectListeners = new
ArrayList<ResourceSelectListener>();
// Maps autogroup/type backing group ids to the corresponding autogroup/type nodes.
@@ -131,7 +134,8 @@ public class ResourceTreeView extends LocatableVLayout {
treeGrid.setLeaveScrollbarGap(false);
- contextMenu = new Menu();
+ resourceContextMenu = new Menu();
+ autoGroupContextMenu = new ResourceGroupContextMenu();
treeGrid.addSelectionChangedHandler(new SelectionChangedHandler() {
public void onSelectionChanged(SelectionEvent selectionEvent) {
@@ -152,7 +156,15 @@ public class ResourceTreeView extends LocatableVLayout {
AutoGroupTreeNode agNode = (AutoGroupTreeNode) selectedRecord;
selectedNodeId = agNode.getID();
- handleSelectedAutoGroupNode(agNode);
+ getAutoGroupBackingGroup(agNode, new
AsyncCallback<ResourceGroup>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to
select autogroup node", caught);
+ }
+
+ public void onSuccess(ResourceGroup result) {
+ renderAutoGroup(result);
+ }
+ });
} else {
System.out.println("Unhandled Node selected in tree: "
+ selectedRecord);
}
@@ -161,7 +173,7 @@ public class ResourceTreeView extends LocatableVLayout {
});
// This constructs the context menu for the resource at the time of the click.
- setContextMenu(contextMenu);
+ // setContextMenu(resourceContextMenu);
treeGrid.addNodeContextClickHandler(new NodeContextClickHandler() {
public void onNodeContextClick(final NodeContextClickEvent event) {
@@ -183,7 +195,7 @@ public class ResourceTreeView extends LocatableVLayout {
});
}
- private void handleSelectedAutoGroupNode(final AutoGroupTreeNode agNode) {
+ private void getAutoGroupBackingGroup(final AutoGroupTreeNode agNode, final
AsyncCallback<ResourceGroup> callback) {
final ResourceGroupGWTServiceAsync resourceGroupService =
GWTServiceLookup.getResourceGroupService();
// get the children tree nodes and build a child resourceId array
@@ -223,7 +235,8 @@ public class ResourceTreeView extends LocatableVLayout {
// store a map entry from backingGroupId to AGTreeNode so
we can easily
// get back to this node given the id of the backing
group (from the viewpath)
autoGroupNodeMap.put(result.getId(), agNode);
- renderAutoGroup(result);
+ callback.onSuccess(result);
+ //renderAutoGroup(result);
}
});
} else {
@@ -243,13 +256,12 @@ public class ResourceTreeView extends LocatableVLayout {
}
public void onSuccess(Void result) {
- renderAutoGroup(backingGroup);
+ callback.onSuccess(backingGroup);
}
});
}
}
});
-
}
private void renderAutoGroup(ResourceGroup backingGroup) {
@@ -290,9 +302,16 @@ public class ResourceTreeView extends LocatableVLayout {
}
}
- private void showContextMenu(AutoGroupTreeNode node) {
- contextMenu.setItems(new MenuItem(node.getName()));
- contextMenu.showContextMenu();
+ private void showContextMenu(AutoGroupTreeNode agNode) {
+ getAutoGroupBackingGroup(agNode, new AsyncCallback<ResourceGroup>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to select AutoGroup
node", caught);
+ }
+
+ public void onSuccess(ResourceGroup result) {
+ autoGroupContextMenu.showContextMenu(result);
+ }
+ });
}
private void showContextMenu(final ResourceTreeNode node) {
@@ -306,15 +325,15 @@ public class ResourceTreeView extends LocatableVLayout {
new ResourceTypeRepository.TypeLoadedCallback() {
public void onTypesLoaded(ResourceType type) {
buildResourceContextMenu(node.getResource(), type);
- contextMenu.showContextMenu();
+ resourceContextMenu.showContextMenu();
}
});
}
private void buildResourceContextMenu(final Resource resource, final ResourceType
resourceType) {
- contextMenu.setItems(new MenuItem(resource.getName()));
+ resourceContextMenu.setItems(new MenuItem(resource.getName()));
- contextMenu.addItem(new MenuItem("Type: " + resourceType.getName()));
+ resourceContextMenu.addItem(new MenuItem("Type: " +
resourceType.getName()));
MenuItem editPluginConfiguration = new MenuItem("Plugin
Configuration");
editPluginConfiguration.addClickHandler(new ClickHandler() {
@@ -337,7 +356,7 @@ public class ResourceTreeView extends LocatableVLayout {
}
});
editPluginConfiguration.setEnabled(resourceType.getPluginConfigurationDefinition() !=
null);
- contextMenu.addItem(editPluginConfiguration);
+ resourceContextMenu.addItem(editPluginConfiguration);
MenuItem editResourceConfiguration = new MenuItem("Resource
Configuration");
editResourceConfiguration.addClickHandler(new ClickHandler() {
@@ -366,9 +385,9 @@ public class ResourceTreeView extends LocatableVLayout {
}
});
editResourceConfiguration.setEnabled(resourceType.getResourceConfigurationDefinition() !=
null);
- contextMenu.addItem(editResourceConfiguration);
+ resourceContextMenu.addItem(editResourceConfiguration);
- contextMenu.addItem(new MenuItemSeparator());
+ resourceContextMenu.addItem(new MenuItemSeparator());
// Operations Menu
MenuItem operations = new MenuItem("Operations");
@@ -402,9 +421,9 @@ public class ResourceTreeView extends LocatableVLayout {
}
operations.setEnabled(!resourceType.getOperationDefinitions().isEmpty());
operations.setSubmenu(opSubMenu);
- contextMenu.addItem(operations);
+ resourceContextMenu.addItem(operations);
- contextMenu.addItem(buildMetricsMenu(resourceType));
+ resourceContextMenu.addItem(buildMetricsMenu(resourceType));
// Create Menu
MenuItem createChildMenu = new MenuItem("Create Child");
@@ -423,7 +442,7 @@ public class ResourceTreeView extends LocatableVLayout {
}
createChildMenu.setSubmenu(createChildSubMenu);
createChildMenu.setEnabled(createChildSubMenu.getItems().length > 0);
- contextMenu.addItem(createChildMenu);
+ resourceContextMenu.addItem(createChildMenu);
// Manually Add Menu
MenuItem importChildMenu = new MenuItem("Import");
@@ -439,7 +458,7 @@ public class ResourceTreeView extends LocatableVLayout {
}
importChildMenu.setSubmenu(importChildSubMenu);
importChildMenu.setEnabled(importChildSubMenu.getItems().length > 0);
- contextMenu.addItem(importChildMenu);
+ resourceContextMenu.addItem(importChildMenu);
}
private void loadManuallyAddServersToPlatforms(final Menu manuallyAddMenu) {
commit 445ac45da9ab6a12c4293fde1194c203d2bfd255
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon Sep 27 21:09:43 2010 +0200
Re-format.
diff --git a/modules/helpers/perftest-support/pom.xml
b/modules/helpers/perftest-support/pom.xml
index 5fa1598..b8b26af 100644
--- a/modules/helpers/perftest-support/pom.xml
+++ b/modules/helpers/perftest-support/pom.xml
@@ -1,110 +1,113 @@
-<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <artifactId>rhq-helpers</artifactId>
+<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>rhq-helpers</artifactId>
+ <groupId>org.rhq.helpers</groupId>
+ <version>4.0.0-SNAPSHOT</version>
+ </parent>
<groupId>org.rhq.helpers</groupId>
+ <artifactId>perftest-support</artifactId>
<version>4.0.0-SNAPSHOT</version>
- </parent>
- <groupId>org.rhq.helpers</groupId>
- <artifactId>perftest-support</artifactId>
- <version>4.0.0-SNAPSHOT</version>
- <name>Performance Testing Support</name>
- <description>To support performance testing, this is a basic tool to support
extracting and later reimporting of data from/to a database.</description>
- <dependencies>
- <dependency>
- <groupId>ant</groupId>
- <artifactId>ant</artifactId>
- <version>1.6.5</version>
- </dependency>
- <dependency>
- <groupId>ant</groupId>
- <artifactId>ant-launcher</artifactId>
- <version>1.6.5</version>
- <scope>runtime</scope>
- </dependency>
- <dependency>
- <groupId>org.dbunit</groupId>
- <artifactId>dbunit</artifactId>
- <version>2.4.8</version>
- <exclusions>
- <exclusion>
- <artifactId>junit</artifactId>
- <groupId>junit</groupId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>gnu-getopt</groupId>
- <artifactId>getopt</artifactId>
- </dependency>
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- <version>${commons-logging.version}</version>
- </dependency>
- <dependency>
- <groupId>org.testng</groupId>
- <artifactId>testng</artifactId>
- <version>${testng.version}</version>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-jcl</artifactId>
- <version>1.5.6</version>
- <scope>runtime</scope>
- </dependency>
- <dependency>
- <groupId>postgresql</groupId>
- <artifactId>postgresql</artifactId>
- <version>${postgresql.version}</version>
- <scope>runtime</scope>
- </dependency>
- <dependency>
- <groupId>org.rhq</groupId>
- <artifactId>rhq-core-domain</artifactId>
- <version>${project.version}</version>
- <scope>runtime</scope>
- </dependency>
- <dependency>
- <groupId>javax.persistence</groupId>
- <artifactId>persistence-api</artifactId>
- <version>1.0</version>
- </dependency>
- <dependency>
- <groupId>org.rhq</groupId>
- <artifactId>rhq-core-dbutils</artifactId>
- <version>${project.version}</version>
- <type>jar</type>
- <scope>compile</scope>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <configuration>
- <archive>
- <manifest>
- <mainClass>org.rhq.helpers.perftest.support.Main</mainClass>
- </manifest>
- </archive>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
- <executions>
- <execution>
- <id>copy-dependencies</id>
- <phase>package</phase>
- <goals>
- <goal>copy-dependencies</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
+ <name>Performance Testing Support</name>
+ <description>To support performance testing, this is a basic tool to support
extracting and later reimporting of
+ data from/to a database.
+ </description>
+ <dependencies>
+ <dependency>
+ <groupId>ant</groupId>
+ <artifactId>ant</artifactId>
+ <version>1.6.5</version>
+ </dependency>
+ <dependency>
+ <groupId>ant</groupId>
+ <artifactId>ant-launcher</artifactId>
+ <version>1.6.5</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.dbunit</groupId>
+ <artifactId>dbunit</artifactId>
+ <version>2.4.8</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>junit</artifactId>
+ <groupId>junit</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>gnu-getopt</groupId>
+ <artifactId>getopt</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>${commons-logging.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <version>${testng.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-jcl</artifactId>
+ <version>1.5.6</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>postgresql</groupId>
+ <artifactId>postgresql</artifactId>
+ <version>${postgresql.version}</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-core-domain</artifactId>
+ <version>${project.version}</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.persistence</groupId>
+ <artifactId>persistence-api</artifactId>
+ <version>1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-core-dbutils</artifactId>
+ <version>${project.version}</version>
+ <type>jar</type>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifest>
+
<mainClass>org.rhq.helpers.perftest.support.Main</mainClass>
+ </manifest>
+ </archive>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-dependencies</id>
+ <phase>package</phase>
+ <goals>
+ <goal>copy-dependencies</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
</project>
\ No newline at end of file
commit 4632def4a92d6edfaffe118e07abd5135eb84c70
Merge: 67570cc... ab9648b...
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Mon Sep 27 15:00:56 2010 -0400
Merge branch 'master' into master-jay
Conflicts:
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeView.java
diff --cc
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeView.java
index d701852,aa854f8..f54ffd2
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeView.java
@@@ -54,12 -56,13 +55,14 @@@ import org.rhq.enterprise.gui.coregui.c
import org.rhq.enterprise.gui.coregui.client.ViewPath;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import
org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
+ import org.rhq.enterprise.gui.coregui.client.util.StringUtility;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
/**
* @author Greg Hinkle
+ * @author Ian Springer
*/
-public class ResourceGroupTreeView extends VLayout implements BookmarkableView {
+public class ResourceGroupTreeView extends LocatableVLayout implements BookmarkableView
{
private TreeGrid treeGrid;
@@@ -73,8 -76,7 +76,9 @@@
private Map<Integer, ResourceType> typeMap;
private ResourceGroup selectedGroup;
- public ResourceGroupTreeView() {
+ public ResourceGroupTreeView(String locatorId) {
+ super(locatorId);
++
setWidth(250);
setHeight100();
}
@@@ -152,35 -154,33 +156,33 @@@
ResourceGroup group = result.get(0);
ResourceGroupTreeView.this.selectedGroup = group;
- if (GroupCategory.MIXED == group.getGroupCategory()) {
+ GroupCategory groupCategory = group.getGroupCategory();
+ switch (groupCategory) {
- case MIXED:
++ case MIXED:
+ ResourceGroupTreeView.this.rootResourceGroup = group;
+ ResourceGroupTreeView.this.rootGroupId =
rootResourceGroup.getId();
+ TreeNode fakeRoot = new TreeNode("fakeRootNode");
+ TreeNode rootNode = new TreeNode(rootResourceGroup.getName());
+ rootNode.setID(String.valueOf(rootResourceGroup.getId()));
//getClusterKey().toString());
+ fakeRoot.setChildren(new TreeNode[] { rootNode });
+ Tree tree = new Tree();
+ tree.setRoot(fakeRoot);
+ treeGrid.setData(tree);
+ treeGrid.markForRedraw();
- } else {
++ break;
++ case COMPATIBLE:
+ if (group.getClusterResourceGroup() == null) {
++ // This is a straight up compatible group.
ResourceGroupTreeView.this.rootResourceGroup = group;
- // This is a straight up group
- loadGroup(groupId);
- ResourceGroupTreeView.this.rootGroupId =
rootResourceGroup.getId();
- TreeNode fakeRoot = new TreeNode("fakeRootNode");
- TreeNode rootNode = new
TreeNode(rootResourceGroup.getName());
- rootNode.setID(String.valueOf(rootResourceGroup.getId()));
//getClusterKey().toString());
- fakeRoot.setChildren(new TreeNode[] { rootNode });
- Tree tree = new Tree();
- tree.setRoot(fakeRoot);
- treeGrid.setData(tree);
- treeGrid.markForRedraw();
- break;
- case COMPATIBLE:
- if (group.getClusterResourceGroup() == null) {
- // This is a straight up compatible group.
- ResourceGroupTreeView.this.rootResourceGroup = group;
- } else {
- // This is a cluster group beneath a real recursive
compatible group.
- ResourceGroupTreeView.this.rootResourceGroup =
group.getClusterResourceGroup();
- }
-
loadGroup(ResourceGroupTreeView.this.rootResourceGroup.getId());
- break;
+ } else {
- // Someone select a cluster group beneath a real recursive
compatible group
-
- ResourceGroup rootGroup = group.getClusterResourceGroup();
- ResourceGroupTreeView.this.rootResourceGroup = rootGroup;
-
- loadGroup(rootGroup.getId());
++ // This is a cluster group beneath a real recursive
compatible group.
++ ResourceGroupTreeView.this.rootResourceGroup =
group.getClusterResourceGroup();
+ }
++
loadGroup(ResourceGroupTreeView.this.rootResourceGroup.getId());
++ break;
}
-
}
});
-
}
private void loadGroup(int groupId) {
@@@ -277,44 -268,79 +270,77 @@@
treeGrid.markForRedraw();
}
- public void loadTree(TreeNode parent, ClusterFlyweight parentNode, ClusterKey
parentKey) {
- if (!parentNode.getChildren().isEmpty()) {
-
- // TODO Introduce type groups (Do we still like this model for recursive
compatibles?)
-
- ArrayList<TreeNode> childNodes = new ArrayList<TreeNode>();
-
- HashMap<Integer, TreeNode> typeNodes = new HashMap<Integer,
TreeNode>();
-
- for (ClusterFlyweight child : parentNode.getChildren()) {
- TreeNode node = new TreeNode(child.getName());
-
+ public void loadTree(TreeNode parentNode, ClusterFlyweight parentClusterGroup,
ClusterKey parentKey) {
+ if (!parentClusterGroup.getChildren().isEmpty()) {
+ // First pass - group the children by type.
+ Map<ResourceType, List<ClusterFlyweight>> childrenByType = new
HashMap<ResourceType, List<ClusterFlyweight>>();
+ for (ClusterFlyweight child : parentClusterGroup.getChildren()) {
ClusterKeyFlyweight keyFlyweight = child.getClusterKey();
- ClusterKey key = new ClusterKey(parentKey,
keyFlyweight.getResourceTypeId(), keyFlyweight
- .getResourceKey());
ResourceType type = this.typeMap.get(keyFlyweight.getResourceTypeId());
+ List<ClusterFlyweight> children = childrenByType.get(type);
+ if (children == null) {
+ children = new ArrayList<ClusterFlyweight>();
+ childrenByType.put(type, children);
+ }
+ children.add(child);
+ }
- String icon = "types/" + type.getCategory().getDisplayName() +
"_up_16.png";
-
- node.setIcon(icon);
+ // Second pass - process each of the sets of like-typed children created in
the first pass.
+ List<TreeNode> childNodes = new ArrayList<TreeNode>();
+ for (ResourceType type : childrenByType.keySet()) {
+ List<ClusterFlyweight> children = childrenByType.get(type);
+ List<TreeNode> nodesByType = new ArrayList<TreeNode>();
+ for (ClusterFlyweight child : children) {
+ TreeNode node = createClusterGroupNode(parentKey, type, child);
+ nodesByType.add(node);
+
+ if (!child.getChildren().isEmpty()) {
+ // Recurse.
- ClusterKey key =
(ClusterKey)node.getAttributeAsObject("key");
++ ClusterKey key = (ClusterKey)
node.getAttributeAsObject("key");
+ loadTree(node, child, key);
+ }
+ }
- node.setID(key.getKey());
- node.setAttribute("key", key);
- node.setAttribute("resourceType", type);
- childNodes.add(node);
+ // TODO (ips): Insert subcategory nodes.
- if (child.getChildren().isEmpty()) {
- node.setIsFolder(false);
+ if (type.isSingleton()) {
+ // If it's a singleton type, just insert the cluster group node
as is.
+ childNodes.addAll(nodesByType);
- }
- else {
+ } else {
- node.setIsFolder(true);
- loadTree(node, child, key);
+ // Otherwise insert an autoTypeGroup folder node to group all
cluster groups of this type.
+ TreeNode autoTypeGroupNode = createAutoTypeGroupNode(type,
nodesByType);
+ childNodes.add(autoTypeGroupNode);
}
}
- parent.setChildren(childNodes.toArray(new TreeNode[childNodes.size()]));
+ parentNode.setChildren(childNodes.toArray(new
TreeNode[childNodes.size()]));
}
}
+ private TreeNode createClusterGroupNode(ClusterKey parentKey, ResourceType type,
ClusterFlyweight child) {
+ TreeNode node = new TreeNode(child.getName());
+
+ ClusterKeyFlyweight keyFlyweight = child.getClusterKey();
- ClusterKey key = new ClusterKey(parentKey, keyFlyweight.getResourceTypeId(),
keyFlyweight
- .getResourceKey());
++ ClusterKey key = new ClusterKey(parentKey, keyFlyweight.getResourceTypeId(),
keyFlyweight.getResourceKey());
+ String id = key.getKey();
+ node.setID(id);
+ node.setAttribute("key", key);
+ node.setAttribute("resourceType", type);
+ node.setIsFolder(!child.getChildren().isEmpty());
+
+ String icon = "types/" + type.getCategory().getDisplayName() +
"_up_16.png";
+ node.setIcon(icon);
+ return node;
+ }
+
+ private TreeNode createAutoTypeGroupNode(ResourceType type, List<TreeNode>
memberNodes) {
+ String name = StringUtility.pluralize(type.getName());
+ TreeNode autoTypeGroupNode = new TreeNode(name);
+ autoTypeGroupNode.setIsFolder(true);
+ autoTypeGroupNode.setChildren(memberNodes.toArray(new
TreeNode[memberNodes.size()]));
+ return autoTypeGroupNode;
+ }
+
public void renderView(ViewPath viewPath) {
currentViewId = viewPath.getCurrent();
int groupId = Integer.parseInt(currentViewId.getPath());
commit 67570cc0877700278ddac9588700699dd9b99129
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Mon Sep 27 14:26:21 2010 -0400
Initial support for Group-Backed AutoGroups
- A lot of work to integrate autogroup nodes into the resource tree view
such that the group renders in the tabbed view while maintaining a
resource tree (not a group tree).
- Tried to pare down code in resourceTreeView to only what is necessary.
- Some more work pending: breadcrumb issues, context menu not yet there,
direct url (saved url) does not always expand tree.
- minor, prevent adding "s" to singulars ending in "s" in
pluralization code.
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 f5c14c5..00a27f0 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java
@@ -51,7 +51,6 @@ import org.rhq.enterprise.gui.coregui.client.alert.AlertsView;
import org.rhq.enterprise.gui.coregui.client.bundle.BundleTopView;
import org.rhq.enterprise.gui.coregui.client.dashboard.DashboardsView;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
-import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.AutoGroupTopView;
import
org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.ResourceGroupTopView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.InventoryView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.ResourceTopView;
@@ -292,8 +291,6 @@ public class CoreGUI implements EntryPoint,
ValueChangeHandler<String> {
canvas = new ResourceTopView("Resource");
} else if (breadcrumbName.equals("ResourceGroup")) {
canvas = new ResourceGroupTopView("Group");
- } else if (breadcrumbName.equals("AutoGroup")) {
- canvas = new AutoGroupTopView("AutoGroup");
} else if (breadcrumbName.equals("Dashboard")) {
canvas = new DashboardsView("Dashboard");
} else if (breadcrumbName.equals("Bundles")) {
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
index e00ecbe..e5bfc72 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
@@ -60,7 +60,7 @@ import
org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTyp
* @author Ian Springer
*/
public class ResourceGroupDetailView extends
AbstractTwoLevelTabSetView<ResourceGroupComposite, ResourceGroupTitleBar> {
- public static final String AUTO_GROUP_VIEW_PATH = "AutoGroup";
+ public static final String AUTO_GROUP_VIEW_PATH = "Resource/AutoGroup";
public static final String GROUP_VIEW_PATH = "ResourceGroup";
private Integer groupId;
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTopView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTopView.java
index ec96874..01b72dd 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTopView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTopView.java
@@ -22,6 +22,7 @@ import com.smartgwt.client.widgets.Canvas;
import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
import org.rhq.enterprise.gui.coregui.client.ViewPath;
+import
org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.ResourceGroupDetailView;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
/**
@@ -32,7 +33,7 @@ public class ResourceTopView extends LocatableHLayout implements
BookmarkableVie
private Canvas contentCanvas;
private ResourceTreeView treeView;
private ResourceDetailView detailView = new
ResourceDetailView(extendLocatorId("Detail"));
-
+ private ResourceGroupDetailView autoGroupDetailView;
public ResourceTopView(String locatorId) {
super(locatorId);
@@ -49,7 +50,6 @@ public class ResourceTopView extends LocatableHLayout implements
BookmarkableVie
setContent(detailView);
}
-
public void setContent(Canvas newContent) {
for (Canvas child : this.contentCanvas.getChildren()) {
child.destroy();
@@ -58,10 +58,27 @@ public class ResourceTopView extends LocatableHLayout implements
BookmarkableVie
this.contentCanvas.markForRedraw();
}
-
public void renderView(ViewPath viewPath) {
- this.treeView.renderView(viewPath);
- this.detailView.renderView(viewPath);
+ if ("AutoGroup".equals(viewPath.getCurrent().getPath())) {
+ if (null == autoGroupDetailView) {
+ this.autoGroupDetailView = new
ResourceGroupDetailView(this.extendLocatorId("AutoGroupDetail"),
+ ResourceGroupDetailView.AUTO_GROUP_VIEW_PATH);
+ this.setContent(this.autoGroupDetailView);
+ this.detailView = null;
+ }
+ this.treeView.renderView(viewPath);
+ this.autoGroupDetailView.renderView(viewPath.next());
+ } else {
+ // Resource
+ if (null == detailView) {
+ this.detailView = new
ResourceDetailView(extendLocatorId("Detail"));
+ this.setContent(this.detailView);
+ this.autoGroupDetailView = null;
+ }
+ this.treeView.renderView(viewPath);
+ this.detailView.renderView(viewPath);
+ }
+
}
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java
index 07995df..3ad6835 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java
@@ -287,13 +287,9 @@ public class ResourceTreeDatasource extends DataSource {
String id = idOf(resource);
setID(id);
- setAttribute(Attributes.ID, id);
String parentId = parentIdOf(resource);
setParentID(parentId);
- setAttribute(Attributes.PARENT_ID, parentId);
-
- // setAttribute("parentKey", parentId);
ResourceType type = resource.getResourceType();
String name = StringUtility.pluralize(type.getName());
@@ -326,12 +322,21 @@ public class ResourceTreeDatasource extends DataSource {
* Given a Resource, generate a unique ID for the AGNode.
*
* @param resource requires resourceType field be set. requires parentResource
field be set (null for no parent)
- * @return The name string or null if the R
+ * @return The name string or null if the parentResource is null.
*/
public static String idOf(Resource resource) {
Resource parentResource = resource.getParentResource();
- return (parentResource != null) ? "autogroup_" +
resource.getResourceType().getId() + "_"
- + parentResource.getId() : null;
+ return idOf(parentResource, resource.getResourceType());
+ }
+
+ /**
+ * Given a Resource, generate a unique ID for the AGNode.
+ *
+ * @param resource requires resourceType field be set. requires parentResource
field be set (null for no parent)
+ * @return The name string or null if the parentResource is null;
+ */
+ public static String idOf(Resource parentResource, ResourceType resourceType) {
+ return (parentResource != null) ? "autogroup_" +
resourceType.getId() + "_" + parentResource.getId() : null;
}
// parent node is either a subcategory node or a resouce node
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
index b20cfb3..2c7a973 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
@@ -24,7 +24,9 @@ package
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail;
import java.util.ArrayList;
import java.util.EnumSet;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import com.google.gwt.user.client.History;
import com.google.gwt.user.client.rpc.AsyncCallback;
@@ -74,10 +76,11 @@ import
org.rhq.enterprise.gui.coregui.client.gwt.ResourceGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGroupGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.gwt.ResourceTypeGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceSelectListener;
+import
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.ResourceTreeDatasource.AutoGroupTreeNode;
+import
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.ResourceTreeDatasource.ResourceTreeNode;
import
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.create.OperationCreateWizard;
import
org.rhq.enterprise.gui.coregui.client.inventory.resource.factory.ResourceFactoryCreateWizard;
import
org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
-import org.rhq.enterprise.gui.coregui.client.util.TreeUtility;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
@@ -86,18 +89,18 @@ import
org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
*/
public class ResourceTreeView extends LocatableVLayout {
- private int selectedResourceId;
-
- private Resource rootResource;
-
private TreeGrid treeGrid;
+ private String selectedNodeId;
private Menu contextMenu;
+ private Resource rootResource;
+
private ViewId currentViewId;
private List<ResourceSelectListener> selectListeners = new
ArrayList<ResourceSelectListener>();
- private boolean initialSelect = false;
+ // Maps autogroup/type backing group ids to the corresponding autogroup/type nodes.
+ Map<Integer, AutoGroupTreeNode> autoGroupNodeMap = new HashMap<Integer,
AutoGroupTreeNode>();
public ResourceTreeView(String locatorId) {
super(locatorId);
@@ -133,20 +136,25 @@ public class ResourceTreeView extends LocatableVLayout {
treeGrid.addSelectionChangedHandler(new SelectionChangedHandler() {
public void onSelectionChanged(SelectionEvent selectionEvent) {
if (!selectionEvent.isRightButtonDown() &&
selectionEvent.getState()) {
- ListGridRecord selectedNode = treeGrid.getSelectedRecord();
- if (selectedNode instanceof ResourceTreeDatasource.ResourceTreeNode)
{
- System.out.println("Resource Node selected in tree: " +
selectedNode);
- ResourceTreeDatasource.ResourceTreeNode resourceNode =
(ResourceTreeDatasource.ResourceTreeNode) selectedNode;
+ ListGridRecord selectedRecord = treeGrid.getSelectedRecord();
+ if (selectedRecord instanceof ResourceTreeNode) {
+ System.out.println("AutoGroup Node selected in tree: "
+ selectedRecord);
+
+ ResourceTreeNode resourceNode = (ResourceTreeNode)
selectedRecord;
+ selectedNodeId = resourceNode.getID();
String viewPath = "Resource/" +
resourceNode.getResource().getId();
String currentViewPath = History.getToken();
if (!currentViewPath.startsWith(viewPath)) {
CoreGUI.goToView(viewPath);
}
- } else if (selectedNode instanceof
ResourceTreeDatasource.AutoGroupTreeNode) {
- System.out.println("AutoGroup Node selected in tree: "
+ selectedNode);
-
handleSelectedAutoGroupNode((ResourceTreeDatasource.AutoGroupTreeNode) selectedNode);
+ } else if (selectedRecord instanceof AutoGroupTreeNode) {
+ System.out.println("AutoGroup Node selected in tree: "
+ selectedRecord);
+
+ AutoGroupTreeNode agNode = (AutoGroupTreeNode) selectedRecord;
+ selectedNodeId = agNode.getID();
+ handleSelectedAutoGroupNode(agNode);
} else {
- System.out.println("Unhandled Node selected in tree: "
+ selectedNode);
+ System.out.println("Unhandled Node selected in tree: "
+ selectedRecord);
}
}
}
@@ -160,31 +168,29 @@ public class ResourceTreeView extends LocatableVLayout {
event.getNode();
event.cancel();
- if (event.getNode() instanceof ResourceTreeDatasource.AutoGroupTreeNode)
{
- showContextMenu((ResourceTreeDatasource.AutoGroupTreeNode)
event.getNode());
- } else if (event.getNode() instanceof
ResourceTreeDatasource.ResourceTreeNode) {
- showContextMenu((ResourceTreeDatasource.ResourceTreeNode)
event.getNode());
+ if (event.getNode() instanceof AutoGroupTreeNode) {
+ showContextMenu((AutoGroupTreeNode) event.getNode());
+ } else if (event.getNode() instanceof ResourceTreeNode) {
+ showContextMenu((ResourceTreeNode) event.getNode());
}
}
});
treeGrid.addDataArrivedHandler(new DataArrivedHandler() {
public void onDataArrived(DataArrivedEvent dataArrivedEvent) {
- if (!initialSelect) {
- updateBreadcrumbs();
- }
+ updateSelection();
}
});
}
- private void handleSelectedAutoGroupNode(final
ResourceTreeDatasource.AutoGroupTreeNode agNode) {
+ private void handleSelectedAutoGroupNode(final AutoGroupTreeNode agNode) {
final ResourceGroupGWTServiceAsync resourceGroupService =
GWTServiceLookup.getResourceGroupService();
// get the children tree nodes and build a child resourceId array
TreeNode[] children = treeGrid.getTree().getChildren(agNode);
final int[] childIds = new int[children.length];
for (int i = 0, size = children.length; (i < size); ++i) {
- childIds[i] = ((ResourceTreeDatasource.ResourceTreeNode)
children[i]).getResource().getId();
+ childIds[i] = ((ResourceTreeNode) children[i]).getResource().getId();
}
// get the backing group if it exists, otherwise create the group
@@ -214,12 +220,21 @@ public class ResourceTreeView extends LocatableVLayout {
}
public void onSuccess(ResourceGroup result) {
+ // store a map entry from backingGroupId to AGTreeNode so
we can easily
+ // get back to this node given the id of the backing
group (from the viewpath)
+ autoGroupNodeMap.put(result.getId(), agNode);
renderAutoGroup(result);
}
});
} else {
- // backing group found, make sure the members are correct
+ // backing group found
final ResourceGroup backingGroup = result.get(0);
+
+ // store a map entry from backingGroupId to AGTreeNode so we can
easily
+ // get back to this node given the id of the backing group (from the
viewpath)
+ autoGroupNodeMap.put(backingGroup.getId(), agNode);
+
+ // make sure the members are correct before rendering
resourceGroupService.setAssignedResources(backingGroup.getId(),
childIds, false,
new AsyncCallback<Void>() {
public void onFailure(Throwable caught) {
@@ -238,24 +253,28 @@ public class ResourceTreeView extends LocatableVLayout {
}
private void renderAutoGroup(ResourceGroup backingGroup) {
- String viewPath = "AutoGroup/" + backingGroup.getId();
+ String viewPath = "Resource/AutoGroup/" + backingGroup.getId();
String currentViewPath = History.getToken();
if (!currentViewPath.startsWith(viewPath)) {
CoreGUI.goToView(viewPath);
}
}
- private void updateBreadcrumbs() {
- TreeNode selectedNode = treeGrid.getTree().findById(
- ResourceTreeDatasource.ResourceTreeNode.idOf(selectedResourceId));
- // System.out.println("Trying to preopen:
" + selectedNode);
- if (selectedNode != null) {
+ private void updateSelection() {
+
+ TreeNode selectedNode = null;
+ if (treeGrid != null && treeGrid.getTree() != null
+ && (selectedNode = treeGrid.getTree().findById(selectedNodeId)) !=
null) {
+
TreeNode[] parents = treeGrid.getTree().getParents(selectedNode);
treeGrid.getTree().openFolders(parents);
treeGrid.getTree().openFolder(selectedNode);
- treeGrid.selectRecord(selectedNode);
- initialSelect = true;
+ if (!selectedNode.equals(treeGrid.getSelectedRecord())) {
+ treeGrid.deselectAllRecords();
+ treeGrid.selectRecord(selectedNode);
+ }
+
treeGrid.markForRedraw();
// Update breadcrumbs
@@ -271,12 +290,12 @@ public class ResourceTreeView extends LocatableVLayout {
}
}
- private void showContextMenu(ResourceTreeDatasource.AutoGroupTreeNode node) {
+ private void showContextMenu(AutoGroupTreeNode node) {
contextMenu.setItems(new MenuItem(node.getName()));
contextMenu.showContextMenu();
}
- private void showContextMenu(final ResourceTreeDatasource.ResourceTreeNode node) {
+ private void showContextMenu(final ResourceTreeNode node) {
ResourceType type = node.getResource().getResourceType();
ResourceTypeRepository.Cache.getInstance().getResourceTypes(
type.getId(),
@@ -358,9 +377,11 @@ public class ResourceTreeView extends LocatableVLayout {
MenuItem operationItem = new MenuItem(operationDefinition.getDisplayName());
operationItem.addClickHandler(new ClickHandler() {
public void onClick(MenuItemClickEvent event) {
+ int resourceId = ((ResourceTreeNode)
treeGrid.getTree().findById(selectedNodeId)).getResource()
+ .getId();
ResourceCriteria criteria = new ResourceCriteria();
- criteria.addFilterId(selectedResourceId);
+ criteria.addFilterId(resourceId);
GWTServiceLookup.getResourceService().findResourcesByCriteria(criteria,
new AsyncCallback<PageList<Resource>>() {
@@ -467,11 +488,12 @@ public class ResourceTreeView extends LocatableVLayout {
addToDBItem.addClickHandler(new ClickHandler() {
public void onClick(MenuItemClickEvent menuItemClickEvent) {
+ int resourceId = ((ResourceTreeNode)
treeGrid.getTree().findById(selectedNodeId))
+ .getResource().getId();
DashboardPortlet p = new
DashboardPortlet(def.getDisplayName() + " Chart",
GraphPortlet.KEY, 250);
- p.getConfiguration().put(
- new PropertySimple(GraphPortlet.CFG_RESOURCE_ID,
selectedResourceId));
+ p.getConfiguration().put(new
PropertySimple(GraphPortlet.CFG_RESOURCE_ID, resourceId));
p.getConfiguration().put(
new PropertySimple(GraphPortlet.CFG_DEFINITION_ID,
def.getId()));
@@ -506,8 +528,8 @@ public class ResourceTreeView extends LocatableVLayout {
Resource getResource(int resourceId) {
if (this.treeGrid != null && this.treeGrid.getTree() != null) {
- ResourceTreeDatasource.ResourceTreeNode treeNode =
(ResourceTreeDatasource.ResourceTreeNode) this.treeGrid
-
.getTree().findById(ResourceTreeDatasource.ResourceTreeNode.idOf(resourceId));
+ ResourceTreeNode treeNode = (ResourceTreeNode)
this.treeGrid.getTree().findById(
+ ResourceTreeNode.idOf(resourceId));
if (treeNode != null) {
return treeNode.getResource();
}
@@ -520,150 +542,129 @@ public class ResourceTreeView extends LocatableVLayout {
}
public void setSelectedResource(final int selectedResourceId) {
- this.selectedResourceId = selectedResourceId;
- TreeNode node;
- final String resourceNodeId =
ResourceTreeDatasource.ResourceTreeNode.idOf(selectedResourceId);
- if (treeGrid != null && treeGrid.getTree() != null
- && (node = treeGrid.getTree().findById(resourceNodeId)) != null) {
+ selectedNodeId = ResourceTreeNode.idOf(selectedResourceId);
+ if (treeGrid != null && treeGrid.getTree() != null &&
(treeGrid.getTree().findById(selectedNodeId)) != null) {
// This is the case where the tree was previously loaded and we get fired to
look at a different
- // node in the same tree and just have to switch the selection
-
- TreeNode[] parents = treeGrid.getTree().getParents(node);
- treeGrid.getTree().openFolders(parents);
- treeGrid.getTree().openFolder(node);
-
- if (!node.equals(treeGrid.getSelectedRecord())) {
- treeGrid.deselectAllRecords();
- treeGrid.selectRecord(node);
- }
+ // node in the same tree and just have to switch the selection
+ updateSelection();
- TreeUtility.printTree(treeGrid.getTree());
-
- updateBreadcrumbs();
} else {
-
// This is for cases where we have to load the tree fresh including down to
the currently visible node
+ loadTree(selectedResourceId);
+ }
- final ResourceGWTServiceAsync resourceService =
GWTServiceLookup.getResourceService();
- // This is an expensive call, but loads all nodes that are visible in the
tree given a selected resource
- resourceService.getResourceLineageAndSiblings(selectedResourceId, new
AsyncCallback<List<Resource>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to lookup platform
for tree", caught);
- }
-
- public void onSuccess(List<Resource> result) {
- Resource root = result.get(0);
+ }
- if (!root.equals(ResourceTreeView.this.rootResource)) {
+ private void loadTree(final int selectedResourceId) {
+ selectedNodeId = ResourceTreeNode.idOf(selectedResourceId);
- if (treeGrid != null) {
- treeGrid.destroy();
- }
- buildTree();
+ final ResourceGWTServiceAsync resourceService =
GWTServiceLookup.getResourceService();
+ // This is an expensive call, but loads all nodes that are visible in the tree
given a selected resource
+ resourceService.getResourceLineageAndSiblings(selectedResourceId, new
AsyncCallback<List<Resource>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to lookup platform for
tree", caught);
+ }
- setRootResource(root);
+ public void onSuccess(List<Resource> result) {
+ Resource root = result.get(0);
- ResourceTreeDatasource dataSource = new
ResourceTreeDatasource(result);
- treeGrid.setDataSource(dataSource);
- // GH: couldn't get initial data to mix with the
datasource... so i put the initial data in
- // the first datasource request
- // treeGrid.setInitialData(selectedLineage);
+ if (!root.equals(ResourceTreeView.this.rootResource)) {
- addMember(treeGrid);
+ if (treeGrid != null) {
+ treeGrid.destroy();
+ }
+ buildTree();
- treeGrid.fetchData(treeGrid.getCriteria(), new DSCallback() {
- public void execute(DSResponse response, Object rawData,
DSRequest request) {
- System.out.println("Done fetching data for
tree.");
- updateBreadcrumbs();
- }
- });
+ setRootResource(root);
- TreeUtility.printTree(treeGrid.getTree());
+ // seed datasource with initial resource list
+ ResourceTreeDatasource dataSource = new
ResourceTreeDatasource(result);
+ treeGrid.setDataSource(dataSource);
- TreeNode selectedNode =
treeGrid.getTree().findById(resourceNodeId);
- // System.out.println("Trying to
preopen: " + selectedNode);
- if (selectedNode != null) {
- //
System.out.println("Preopen node!!!");
- TreeNode[] parents =
treeGrid.getTree().getParents(selectedNode);
- treeGrid.getTree().openFolders(parents);
- treeGrid.getTree().openFolder(selectedNode);
+ addMember(treeGrid);
- for (TreeNode p : parents) {
- System.out.println("open? " +
treeGrid.getTree().isOpen(p) + " node: " + p.getName());
- }
+ treeGrid.fetchData(treeGrid.getCriteria(), new DSCallback() {
+ public void execute(DSResponse response, Object rawData,
DSRequest request) {
+ System.out.println("Done fetching data for
tree.");
+ updateSelection();
+ }
+ });
- updateBreadcrumbs();
+ updateSelection();
- treeGrid.selectRecord(selectedNode);
- initialSelect = true;
- treeGrid.markForRedraw();
- }
+ } else {
+ ResourceTypeRepository.Cache.getInstance().loadResourceTypes(
+ result,
+ EnumSet.of(ResourceTypeRepository.MetadataType.operations,
+ ResourceTypeRepository.MetadataType.children,
+ ResourceTypeRepository.MetadataType.subCategory),
+ new ResourceTypeRepository.ResourceTypeLoadedCallback() {
+ public void onResourceTypeLoaded(List<Resource> result)
{
+
treeGrid.getTree().linkNodes(ResourceTreeDatasource.buildNodes(result));
+
+ TreeNode selectedNode =
treeGrid.getTree().findById(selectedNodeId);
+ if (selectedNode != null) {
+ updateSelection();
+
+ } else {
+ CoreGUI.getMessageCenter().notify(
+ new Message("Failed to select Resource
[" + selectedResourceId + "] in tree.",
+ Message.Severity.Warning));
+ }
- } else {
+ }
+ });
- initialSelect = false;
- ResourceTypeRepository.Cache.getInstance().loadResourceTypes(
- result,
- EnumSet.of(ResourceTypeRepository.MetadataType.operations,
- ResourceTypeRepository.MetadataType.children,
- ResourceTypeRepository.MetadataType.subCategory),
- new ResourceTypeRepository.ResourceTypeLoadedCallback() {
- public void onResourceTypeLoaded(List<Resource>
result) {
-
treeGrid.getTree().linkNodes(ResourceTreeDatasource.buildNodes(result));
-
- //TreeUtility.printTree(treeGrid.getTree());
-
- TreeNode selectedNode =
treeGrid.getTree().findById(resourceNodeId);
- if (selectedNode != null) {
- treeGrid.deselectAllRecords();
- treeGrid.selectRecord(selectedNode);
-
- TreeNode[] parents =
treeGrid.getTree().getParents(selectedNode);
- treeGrid.getTree().openFolders(parents);
- treeGrid.getTree().openFolder(selectedNode);
-
- /*
- todo deleteme
- // Update breadcrumbs
- viewId.getBreadcrumbs().clear();
- for (int i = parents.length - 1; i >= 0; i--)
{
- TreeNode n = parents[i];
- adjustBreadcrumb(n, viewId);
- }
- adjustBreadcrumb(selectedNode, viewId);
- CoreGUI.refreshBreadCrumbTrail();*/
+ }
+ }
+ });
+ }
- } else {
- CoreGUI.getMessageCenter().notify(
- new Message("Failed to select Resource
[" + selectedResourceId
- + "] in tree.",
Message.Severity.Warning));
- }
+ public void setSelectedAutoGroup(final Integer selectedAutoGroupId) {
- }
- });
+ AutoGroupTreeNode selectedNode = autoGroupNodeMap.get(selectedAutoGroupId);
+ if (treeGrid != null && treeGrid.getTree() != null &&
selectedNode != null) {
+ // This is the case where the tree was previously loaded and we get fired to
look at a different
+ // node in the same tree and just have to switch the selection
- }
+ this.selectedNodeId = selectedNode.getID();
+ updateSelection();
- TreeNode selectedNode = treeGrid.getTree().findById(resourceNodeId);
- // System.out.println("Trying
to preopen: " + selectedNode);
- if (selectedNode != null) {
- TreeNode[] parents =
treeGrid.getTree().getParents(selectedNode);
+ } else {
+ // This is for cases where we have to load the tree fresh including down to
the currently visible node
- // todo update viewPath's breadcrumbs
- }
+ final ResourceGroupGWTServiceAsync resourceGroupService =
GWTServiceLookup.getResourceGroupService();
+ ResourceGroupCriteria criteria = new ResourceGroupCriteria();
+ criteria.addFilterId(selectedAutoGroupId);
+ criteria.addFilterVisible(false);
+ criteria.fetchResourceType(true);
+ resourceGroupService.findResourceGroupsByCriteria(criteria, new
AsyncCallback<PageList<ResourceGroup>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to fetch autogroup
backing group", caught);
+ }
- // CoreGUI.addBreadCrumb(new Place(String.valueOf(result.getId()),
result.getName()));
+ public void onSuccess(PageList<ResourceGroup> result) {
+ ResourceGroup backingGroup = result.get(0);
+ // load the tree up to the autogroup's parent resource
+ loadTree(backingGroup.getAutoGroupParentResource().getId());
+
+ // get the node ID and use it to add a map entry, then call this
again to finish up...
+ selectedNodeId =
AutoGroupTreeNode.idOf(backingGroup.getAutoGroupParentResource(), backingGroup
+ .getResourceType());
+ AutoGroupTreeNode agNode = (AutoGroupTreeNode)
treeGrid.getTree().findById(selectedNodeId);
+ autoGroupNodeMap.put(backingGroup.getId(), agNode);
+ updateSelection();
}
});
}
}
private void adjustBreadcrumb(TreeNode node, ViewId viewId) {
- if (node instanceof ResourceTreeDatasource.ResourceTreeNode) {
+ if (node instanceof ResourceTreeNode) {
- Resource nr = ((ResourceTreeDatasource.ResourceTreeNode)
node).getResource();
+ Resource nr = ((ResourceTreeNode) node).getResource();
String display = node.getName() + " <span
class=\"subtitle\">" + nr.getResourceType().getName() +
"</span>";
String icon = "types/" +
nr.getResourceType().getCategory().getDisplayName() + "_up_16.png";
@@ -687,7 +688,7 @@ public class ResourceTreeView extends LocatableVLayout {
c.addFilterParentResourceId(lineage.get(0).getId());
resourceService.findResourcesByCriteria(CoreGUI.getSessionSubject(), c,
new AsyncCallback<PageList<Resource>>() {
public void onFailure(Throwable caught) {
- SC.say("SHit");
+ SC.say("NotGood");
}
public void onSuccess(PageList<Resource> result) {
@@ -708,7 +709,14 @@ public class ResourceTreeView extends LocatableVLayout {
public void renderView(ViewPath viewPath) {
currentViewId = viewPath.getCurrent();
- Integer resourceId = Integer.parseInt(currentViewId.getPath());
- setSelectedResource(resourceId);
+ String currentViewIdPath = currentViewId.getPath();
+ if ("AutoGroup".equals(currentViewIdPath)) {
+ ViewId nextViewId = viewPath.getNext();
+ Integer autoGroupId = Integer.parseInt(nextViewId.getPath());
+ setSelectedAutoGroup(autoGroupId);
+ } else {
+ Integer resourceId = Integer.parseInt(currentViewId.getPath());
+ setSelectedResource(resourceId);
+ }
}
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/StringUtility.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/StringUtility.java
index 00a2cf1..14ce7e6 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/StringUtility.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/StringUtility.java
@@ -21,17 +21,21 @@ package org.rhq.enterprise.gui.coregui.client.util;
/**
* A collection of utility methods for working with Strings.
+ *
+ * TODO: I18N. The logic here may need to be pluggable for different localizations.
*
* @author Ian Springer
*/
public class StringUtility {
public static String pluralize(String singularNoun) {
String pluralNoun;
- if (singularNoun.endsWith("y") &&
!singularNoun.endsWith("ay") && !singularNoun.endsWith("ey")
&&
- !singularNoun.endsWith("oy")) {
+ if (singularNoun.endsWith("y") &&
!singularNoun.endsWith("ay") && !singularNoun.endsWith("ey")
+ && !singularNoun.endsWith("oy")) {
pluralNoun = singularNoun.substring(0, singularNoun.length() - 1) +
"ies";
- } else {
+ } else if (!singularNoun.endsWith("s")) {
pluralNoun = singularNoun + "s";
+ } else {
+ pluralNoun = singularNoun;
}
return pluralNoun;
}
commit ab9648bda9d733820cfc8037cc011e957e10fcfb
Author: Joseph Marques <joseph(a)redhat.com>
Date: Sun Sep 26 00:13:14 2010 -0400
enhance login and user session management experience:
* create formal notion of client-side loggedIn state
* add logic for synchronization between client/server loggedIn state
* "loading..." image is now dismissed upon app load, not upon login action
* LoginView is recentered upon browser resizing
* "recent alerts" no longer causes GWT service exceptions in the logs
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 00a27f0..b59edba 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
@@ -20,6 +20,7 @@ package org.rhq.enterprise.gui.coregui.client;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
+import com.google.gwt.dom.client.Element;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.http.client.Request;
@@ -30,10 +31,8 @@ import com.google.gwt.http.client.Response;
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.google.gwt.user.client.rpc.AsyncCallback;
-import com.google.gwt.user.client.ui.RootPanel;
import com.smartgwt.client.core.KeyIdentifier;
import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.util.KeyCallback;
@@ -60,7 +59,6 @@ import org.rhq.enterprise.gui.coregui.client.report.tag.TaggedView;
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.MessageCenter;
-import org.rhq.enterprise.gui.coregui.client.util.preferences.UserPreferences;
import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
/**
@@ -71,18 +69,6 @@ public class CoreGUI implements EntryPoint,
ValueChangeHandler<String> {
public static final String CONTENT_CANVAS_ID = "BaseContent";
- private static Subject sessionSubject;
-
- private static Timer sessionTimer = new Timer() {
- @Override
- public void run() {
- System.out.println("Session Timer Expired");
- new LoginView(true).showLoginDialog(); // log user out, show login dialog
- }
- };
-
- private static UserPreferences userPreferences;
-
private static ErrorHandler errorHandler = new ErrorHandler();
private static BreadcrumbTrailPane breadCrumbTrailPane;
@@ -140,9 +126,18 @@ public class CoreGUI implements EntryPoint,
ValueChangeHandler<String> {
messages = GWT.create(Messages.class);
checkLoginStatus();
+
+ // removing loading image, which can be seen if LoginView doesn't completely
cover it
+ Element loadingPanel = DOM.getElementById("Loading-Panel");
+ loadingPanel.removeFromParent();
}
public static void checkLoginStatus() {
+ if (!UserSessionManager.isLoggedIn()) {
+ new LoginView().showLoginDialog();
+ return;
+ }
+
// String sessionIdString =
com.google.gwt.user.client.Cookies.getCookie("RHQ_Sesssion");
// if (sessionIdString == null) {
@@ -181,11 +176,17 @@ public class CoreGUI implements EntryPoint,
ValueChangeHandler<String> {
}
public void onSuccess(PageList<Subject> result) {
-
Subject subject = result.get(0);
subject.setSessionId(sessionId);
- setSessionSubject(subject);
- //System.out.println("Portal-War logged
in");
+
+ // TODO this breaks because of reattach rules,
bizarrely even in queries.
+ // gonna switch out to non-subject include apis
+ //
+ // Create a minimized session object for validation
on requests
+ // Subject s = new
Subject(subject.getName(),subject.getFactive(), subject.getFsystem());
+ // s.setSessionId(subject.getSessionId());
+ UserSessionManager.setSessionSubject(subject);
+ loadProductInfo();
}
});
} else {
@@ -208,16 +209,6 @@ public class CoreGUI implements EntryPoint,
ValueChangeHandler<String> {
}
}
- public static void refreshSessionTimer() {
- System.out.println("Refreshing Session Timer");
- sessionTimer.schedule(29 * 60 * 1000); // 29 minutes from now, timeout before the
http session timeout
- }
-
- public static void destroySessionTimer() {
- System.out.println("Destroying Session Timer");
- sessionTimer.cancel();
- }
-
private void buildCoreUI() {
// If the core gui is already built (eg. from previous login, just refire event)
if (this.rootCanvas == null) {
@@ -243,8 +234,6 @@ public class CoreGUI implements EntryPoint,
ValueChangeHandler<String> {
breadCrumbTrailPane = new BreadcrumbTrailPane();
rootCanvas.addMember(breadCrumbTrailPane);
- DOM.setInnerHTML(RootPanel.get("Loading-Panel").getElement(),
"");
-
Canvas canvas = new Canvas(CONTENT_CANVAS_ID);
canvas.setWidth100();
canvas.setHeight100();
@@ -296,7 +285,8 @@ public class CoreGUI implements EntryPoint,
ValueChangeHandler<String> {
} else if (breadcrumbName.equals("Bundles")) {
canvas = new BundleTopView("Bundle");
} else if (breadcrumbName.equals("LogOut")) {
- canvas = new LoginView(true);
+ canvas = new LoginView();
+ UserSessionManager.logout();
} else if (breadcrumbName.equals("Tag")) {
canvas = new TaggedView("Tag");
} else if (breadcrumbName.equals("Subsystems")) {
@@ -319,32 +309,10 @@ public class CoreGUI implements EntryPoint,
ValueChangeHandler<String> {
return errorHandler;
}
- public static Subject getSessionSubject() {
- return sessionSubject;
- }
-
- public static UserPreferences getUserPreferences() {
- return userPreferences;
- }
-
public static void printWidgetTree() {
WidgetUtility.printWidgetTree(coreGUI.rootCanvas);
}
- public static void setSessionSubject(Subject subject) {
- // TODO this breaks because of reattach rules, bizarrely even in queries. gonna
switch out to non-subject include apis
- // Create a minimized session object for validation on requests
- // Subject s = new Subject(subject.getName(),subject.getFactive(),
subject.getFsystem());
- // s.setSessionId(subject.getSessionId());
- CoreGUI.sessionSubject = subject;
- CoreGUI.userPreferences = new UserPreferences(subject);
- loadProductInfo();
- // After a user initiated logout start back at the default view
- if ("LogOut".equals(CoreGUI.currentPath)) {
- History.newItem(getDefaultView());
- }
- }
-
private static String getDefaultView() {
// TODO: should this be Dashboard or a User Preference?
return "";
@@ -403,6 +371,11 @@ public class CoreGUI implements EntryPoint,
ValueChangeHandler<String> {
public void onSuccess(ProductInfo result) {
productInfo = result;
coreGUI.buildCoreUI();
+
+ // After a user initiated logout start back at the default view
+ if ("LogOut".equals(CoreGUI.currentPath)) {
+ History.newItem(getDefaultView());
+ }
}
});
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/Footer.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/Footer.java
index 66b94dc..00050ad 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/Footer.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/Footer.java
@@ -56,7 +56,7 @@ public class Footer extends LocatableToolStrip {
protected void onDraw() {
super.onDraw();
- Label loggedInAs = new Label("Logged in as " +
CoreGUI.getSessionSubject().getName());
+ Label loggedInAs = new Label("Logged in as " +
UserSessionManager.getSessionSubject().getName());
loggedInAs.setWrap(false);
loggedInAs.setMargin(5);
loggedInAs.setValign(VerticalAlignment.CENTER);
@@ -111,6 +111,9 @@ public class Footer extends LocatableToolStrip {
}
public void refresh() {
+ if (!UserSessionManager.isLoggedIn()) {
+ return;
+ }
AlertCriteria alertCriteria = new AlertCriteria();
alertCriteria.setPaging(1, 1);
@@ -127,6 +130,7 @@ public class Footer extends LocatableToolStrip {
drawAlerts(result);
}
});
+
}
public void drawAlerts(PageList<Alert> alerts) {
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java
index a19fcec..0f660c3 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java
@@ -27,7 +27,6 @@ import com.google.gwt.http.client.Request;
import com.google.gwt.http.client.RequestBuilder;
import com.google.gwt.http.client.RequestCallback;
import com.google.gwt.http.client.Response;
-import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.types.FormErrorOrientation;
import com.smartgwt.client.widgets.Canvas;
@@ -45,10 +44,9 @@ import com.smartgwt.client.widgets.form.fields.TextItem;
import com.smartgwt.client.widgets.form.fields.events.KeyPressEvent;
import com.smartgwt.client.widgets.form.fields.events.KeyPressHandler;
-import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
-
/**
* @author Greg Hinkle
+ * @author Joseph Marques
*/
public class LoginView extends Canvas {
@@ -60,34 +58,12 @@ public class LoginView extends Canvas {
private SubmitItem loginButton;
public LoginView() {
- this(false);
- }
-
- public LoginView(boolean logout) {
- if (logout) {
- CoreGUI.destroySessionTimer();
- if (CoreGUI.getSessionSubject() != null) {
- GWTServiceLookup.getSubjectService().logout(CoreGUI.getSessionSubject(),
new AsyncCallback<Void>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to
logout", caught);
- CoreGUI.checkLoginStatus();
- }
-
- public void onSuccess(Void result) {
- CoreGUI.checkLoginStatus();
- }
- });
- }
- } else {
- CoreGUI.refreshSessionTimer();
- }
-
}
public void showLoginDialog() {
-
if (!loginShowing) {
loginShowing = true;
+ UserSessionManager.logout();
form = new DynamicForm();
form.setMargin(25);
@@ -143,8 +119,7 @@ public class LoginView extends Canvas {
window.setCanDragReposition(false);
window.setShowCloseButton(false);
window.setShowMinimizeButton(false);
-
- window.centerInPage();
+ window.setAutoCenter(true);
window.addItem(form);
window.show();
@@ -157,11 +132,9 @@ public class LoginView extends Canvas {
}
});
}
-
}
private void login(String user, String password) {
-
if (CoreGUI.detectIe6()) {
CoreGUI.forceIe6Hacks();
}
@@ -177,6 +150,7 @@ public class LoginView extends Canvas {
if (statusCode == 200) {
window.destroy();
loginShowing = false;
+ UserSessionManager.refresh();
CoreGUI.checkLoginStatus();
} else {
handleError(statusCode);
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/SearchGUI.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/SearchGUI.java
index f4c52d7..3ec02b3 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/SearchGUI.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/SearchGUI.java
@@ -39,7 +39,6 @@ import org.rhq.enterprise.gui.coregui.client.search.SearchBar;
public class SearchGUI implements EntryPoint {
public static SearchGUI singleton = new SearchGUI();
- private static Subject sessionSubject;
private SearchBar searchBar;
private SearchGUI() {
@@ -101,12 +100,10 @@ public class SearchGUI implements EntryPoint {
}
public void onSuccess(PageList<Subject> result) {
-
Subject subject = result.get(0);
subject.setSessionId(sessionId);
- SearchGUI.sessionSubject = subject;
+ UserSessionManager.setSessionSubject(subject);
singleton.buildSearchGUI();
-
}
});
} else {
@@ -130,10 +127,6 @@ public class SearchGUI implements EntryPoint {
}
- public static Subject getSessionSubject() {
- return sessionSubject;
- }
-
public SearchBar getSearchBar() {
return searchBar;
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/UserSessionManager.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/UserSessionManager.java
new file mode 100644
index 0000000..9bede31
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/UserSessionManager.java
@@ -0,0 +1,136 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client;
+
+import com.google.gwt.user.client.Timer;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.util.preferences.UserPreferences;
+
+/**
+ * First time this class is loaded, local loggedIn bit will be false, which implies user
is not logged in.
+ *
+ * If login successful, CoreGUI/SearchGUI will call setSessionSubject, which sets local
loggedIn bit to true.
+ * If user clicks logout explicitly, LoginView will be shown, which sets local loggedIn
bit to false.
+ * If count down timer expires, LoginView will be shown, which sets local loggedIn bit to
false.
+ *
+ * If error during GWT RPC Service, check local loggedIn status
+ * If loggedIn bit false, display LoginView
+ * Else check server-side logged in state
+ * If logged out on server-side, LoginView will be shown, which sets local loggedIn
bit to false.
+ *
+ * @author Joseph Marques
+ */
+public class UserSessionManager {
+
+ private static int SESSION_TIMEOUT = 29 * 60 * 1000; // 29 mins, just shorter than
the 30-min web session timeout
+ private static int LOGOUT_DELAY = 30 * 1000; // 30 seconds
+
+ private static Subject sessionSubject;
+ private static UserPreferences userPreferences;
+
+ private UserSessionManager() {
+ // static access only
+ }
+
+ private static boolean loggedIn = false;
+ private static Timer sessionTimer = new Timer() {
+ @Override
+ public void run() {
+ System.out.println("Session Timer Expired");
+ new LoginView().showLoginDialog(); // log user out, show login dialog
+ }
+ };
+ private static Timer logoutTimer = new Timer() {
+ @Override
+ public void run() {
+ logoutServerSide();
+ }
+ };
+
+ public static void refresh() {
+ // if quickly logging back in, first cancel the logout timer so that we
+ // don't have race conditions to the server where the login request beats
+ // the logout request, which would appear to the user for the login to
+ // have failed since it will boot them back to the login screen.
+ logoutTimer.cancel();
+
+ // now continue with the rest of the login logic
+ loggedIn = true;
+ System.out.println("Refreshing Session Timer");
+ sessionTimer.schedule(SESSION_TIMEOUT);
+ }
+
+ public static void logout() {
+ if (!loggedIn) {
+ return; // nothing to do, already called
+ }
+
+ loggedIn = false;
+ System.out.println("Destroying Session Timer");
+ sessionTimer.cancel();
+
+ // log out the web session on the server-side in a delayed fashion,
+ // allowing enough time to pass to let in-flight requests complete
+ logoutTimer.schedule(LOGOUT_DELAY);
+ }
+
+ private static void logoutServerSide() {
+ try {
+ if (getSessionSubject() != null) {
+
GWTServiceLookup.getSubjectService().logout(UserSessionManager.getSessionSubject(),
+ new AsyncCallback<Void>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to
logout", caught);
+ }
+
+ public void onSuccess(Void result) {
+ }
+ });
+ }
+ } catch (Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to logout", caught);
+ }
+ }
+
+ public static boolean isLoggedIn() {
+ System.out.println("isLoggedIn = " + loggedIn);
+ return loggedIn;
+ }
+
+ public static Subject getSessionSubject() {
+ return sessionSubject;
+ }
+
+ public static void setSessionSubject(Subject subject) {
+ sessionSubject = subject;
+ userPreferences = new UserPreferences(sessionSubject);
+ refresh();
+ }
+
+ public static UserPreferences getUserPreferences() {
+ return userPreferences;
+ }
+}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/upload/BundleDistributionFileUploadForm.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/upload/BundleDistributionFileUploadForm.java
index 65f2cc3..0d90b8a 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/upload/BundleDistributionFileUploadForm.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/upload/BundleDistributionFileUploadForm.java
@@ -31,6 +31,7 @@ import com.smartgwt.client.widgets.form.fields.events.ClickEvent;
import com.smartgwt.client.widgets.form.fields.events.ClickHandler;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity;
@@ -138,7 +139,7 @@ public class BundleDistributionFileUploadForm extends
DynamicCallbackForm {
super.onDraw();
HiddenItem sessionIdField = new HiddenItem("sessionid");
- sessionIdField.setValue(CoreGUI.getSessionSubject().getSessionId().intValue());
+
sessionIdField.setValue(UserSessionManager.getSessionSubject().getSessionId().intValue());
setNumCols(4);
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/upload/BundleFileUploadForm.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/upload/BundleFileUploadForm.java
index cded781..3647913 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/upload/BundleFileUploadForm.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/upload/BundleFileUploadForm.java
@@ -32,6 +32,7 @@ import com.smartgwt.client.widgets.form.fields.events.ClickHandler;
import org.rhq.core.domain.bundle.BundleVersion;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity;
@@ -154,7 +155,7 @@ public class BundleFileUploadForm extends DynamicCallbackForm {
super.onDraw();
HiddenItem sessionIdField = new HiddenItem("sessionid");
- sessionIdField.setValue(CoreGUI.getSessionSubject().getSessionId().intValue());
+
sessionIdField.setValue(UserSessionManager.getSessionSubject().getSessionId().intValue());
HiddenItem bundleVersionIdField = new HiddenItem("bundleVersionId");
bundleVersionIdField.setValue(this.bundleVersion.getId());
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/upload/TextFileRetrieverForm.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/upload/TextFileRetrieverForm.java
index be0f0a9..31a8a23 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/upload/TextFileRetrieverForm.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/upload/TextFileRetrieverForm.java
@@ -30,6 +30,7 @@ import com.smartgwt.client.widgets.form.fields.events.ClickEvent;
import com.smartgwt.client.widgets.form.fields.events.ClickHandler;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity;
@@ -56,7 +57,7 @@ public class TextFileRetrieverForm extends DynamicCallbackForm {
retrieveField.setValue(true);
HiddenItem sessionIdField = new HiddenItem("sessionid");
- sessionIdField.setValue(CoreGUI.getSessionSubject().getSessionId().intValue());
+
sessionIdField.setValue(UserSessionManager.getSessionSubject().getSessionId().intValue());
setNumCols(4);
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/resource/FavoriteResourcesPortlet.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/resource/FavoriteResourcesPortlet.java
index 72cf55e..13a35c0 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/resource/FavoriteResourcesPortlet.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/resource/FavoriteResourcesPortlet.java
@@ -33,7 +33,7 @@ import
com.smartgwt.client.widgets.grid.events.FieldStateChangedHandler;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.dashboard.DashboardPortlet;
-import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow;
@@ -63,7 +63,7 @@ public class FavoriteResourcesPortlet extends ResourceSearchView
implements Port
protected void configureTable() {
super.configureTable();
- Set<Integer> favoriteIds =
CoreGUI.getUserPreferences().getFavoriteResources();
+ Set<Integer> favoriteIds =
UserSessionManager.getUserPreferences().getFavoriteResources();
Integer[] favArray = favoriteIds.toArray(new Integer[favoriteIds.size()]);
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/footer/FavoritesButton.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/footer/FavoritesButton.java
index 4f5374c..5557d50 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/footer/FavoritesButton.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/footer/FavoritesButton.java
@@ -33,6 +33,7 @@ import org.rhq.core.domain.criteria.ResourceCriteria;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIMenuButton;
@@ -56,7 +57,7 @@ public class FavoritesButton extends LocatableIMenuButton {
// favorite Resources successfully.
clickEvent.cancel();
- Set<Integer> favorites =
CoreGUI.getUserPreferences().getFavoriteResources();
+ Set<Integer> favorites =
UserSessionManager.getUserPreferences().getFavoriteResources();
if (!favorites.isEmpty()) {
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTitleBar.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTitleBar.java
index 431f52d..e78e3b6 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTitleBar.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTitleBar.java
@@ -36,6 +36,7 @@ import org.rhq.core.domain.resource.group.ResourceGroup;
import org.rhq.core.domain.tagging.Tag;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
import org.rhq.enterprise.gui.coregui.client.components.tagging.TagEditorView;
import org.rhq.enterprise.gui.coregui.client.components.tagging.TagsChangedCallback;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
@@ -82,7 +83,7 @@ public class ResourceGroupTitleBar extends LocatableHLayout {
this.favoriteButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent clickEvent) {
Set<Integer> favorites = toggleFavoriteLocally();
- CoreGUI.getUserPreferences().setFavoriteResources(favorites, new
UpdateFavoritesCallback());
+ UserSessionManager.getUserPreferences().setFavoriteResources(favorites,
new UpdateFavoritesCallback());
}
});
@@ -143,7 +144,7 @@ public class ResourceGroupTitleBar extends LocatableHLayout {
this.title.setContents("<span class=\"SectionHeader\">"
+ group.getName()
+ "</span> <span
class=\"subtitle\">" + group.getGroupCategory().name() +
"</span>");
- Set<Integer> favorites =
CoreGUI.getUserPreferences().getFavoriteResourceGroups();
+ Set<Integer> favorites =
UserSessionManager.getUserPreferences().getFavoriteResourceGroups();
this.favorite = favorites.contains(group.getId());
updateFavoriteButton();
@@ -167,7 +168,7 @@ public class ResourceGroupTitleBar extends LocatableHLayout {
private Set<Integer> toggleFavoriteLocally() {
this.favorite = !this.favorite;
- Set<Integer> favorites =
CoreGUI.getUserPreferences().getFavoriteResourceGroups();
+ Set<Integer> favorites =
UserSessionManager.getUserPreferences().getFavoriteResourceGroups();
if (this.favorite) {
favorites.add(group.getId());
} else {
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTitleBar.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTitleBar.java
index dcbcda6..bc1e0b7 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTitleBar.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTitleBar.java
@@ -36,6 +36,7 @@ import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.tagging.Tag;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
import org.rhq.enterprise.gui.coregui.client.components.tagging.TagEditorView;
import org.rhq.enterprise.gui.coregui.client.components.tagging.TagsChangedCallback;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
@@ -82,7 +83,7 @@ public class ResourceTitleBar extends LocatableHLayout {
this.favoriteButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent clickEvent) {
Set<Integer> favorites = toggleFavoriteLocally();
- CoreGUI.getUserPreferences().setFavoriteResources(favorites, new
UpdateFavoritesCallback());
+ UserSessionManager.getUserPreferences().setFavoriteResources(favorites,
new UpdateFavoritesCallback());
}
});
@@ -142,7 +143,7 @@ public class ResourceTitleBar extends LocatableHLayout {
this.title.setContents("<span
class=\"SectionHeader\">" + resource.getName()
+ "</span> <span
class=\"subtitle\">" + resource.getResourceType().getName() +
"</span>");
- Set<Integer> favorites =
CoreGUI.getUserPreferences().getFavoriteResources();
+ Set<Integer> favorites =
UserSessionManager.getUserPreferences().getFavoriteResources();
this.favorite = favorites.contains(resource.getId());
updateFavoriteButton();
@@ -168,7 +169,7 @@ public class ResourceTitleBar extends LocatableHLayout {
private Set<Integer> toggleFavoriteLocally() {
this.favorite = !this.favorite;
- Set<Integer> favorites =
CoreGUI.getUserPreferences().getFavoriteResources();
+ Set<Integer> favorites =
UserSessionManager.getUserPreferences().getFavoriteResources();
int resourceId = this.resource.getId();
if (this.favorite) {
favorites.add(resourceId);
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/FavoritesMenu.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/FavoritesMenu.java
index a13e705..876f8d5 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/FavoritesMenu.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/FavoritesMenu.java
@@ -36,9 +36,9 @@ import org.rhq.core.domain.criteria.ResourceCriteria;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
-
/**
* @author Greg Hinkle
*/
@@ -56,7 +56,7 @@ public class FavoritesMenu extends MenuItem {
}
public void refresh() {
- Set<Integer> favorites =
CoreGUI.getUserPreferences().getFavoriteResources();
+ Set<Integer> favorites =
UserSessionManager.getUserPreferences().getFavoriteResources();
if (!favorites.isEmpty()) {
@@ -80,33 +80,30 @@ public class FavoritesMenu extends MenuItem {
ResourceCriteria criteria = new ResourceCriteria();
criteria.addFilterIds(resourceIds);
GWTServiceLookup.getResourceService().findResourcesByCriteria(criteria,
- new AsyncCallback<PageList<Resource>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to load
favorite Resources.", caught);
- }
+ new AsyncCallback<PageList<Resource>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to load
favorite Resources.", caught);
+ }
- public void onSuccess(PageList<Resource> resources) {
- for (Resource resource : resources) {
- MenuItem item = idToMenuItemMap.get(resource.getId());
- // TODO: Ideally, we should use
ResourceManagerLocal.disambiguate() here to obtain
- // disambiguated Resource names.
- item.setTitle(resource.getName());
+ public void onSuccess(PageList<Resource> resources) {
+ for (Resource resource : resources) {
+ MenuItem item = idToMenuItemMap.get(resource.getId());
+ // TODO: Ideally, we should use
ResourceManagerLocal.disambiguate() here to obtain
+ // disambiguated Resource names.
+ item.setTitle(resource.getName());
- String category =
resource.getResourceType().getCategory().getDisplayName();
+ String category =
resource.getResourceType().getCategory().getDisplayName();
- String avail = (resource.getCurrentAvailability() != null
&& resource.getCurrentAvailability().getAvailabilityType() != null)
- ?
(resource.getCurrentAvailability().getAvailabilityType().name().toLowerCase()) :
"down";
- item.setIcon("types/" + category +
"_" + avail + "_16.png");
- }
- submenu.setItems(items);
+ String avail = (resource.getCurrentAvailability() != null
&& resource
+ .getCurrentAvailability().getAvailabilityType() != null)
? (resource
+
.getCurrentAvailability().getAvailabilityType().name().toLowerCase()) : "down";
+ item.setIcon("types/" + category + "_" +
avail + "_16.png");
}
- });
+ submenu.setItems(items);
+ }
+ });
}
-
}
-
}
-
-
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/search/favorites/SavedSearchManager.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/search/favorites/SavedSearchManager.java
index 66260e8..ac069cb 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/search/favorites/SavedSearchManager.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/search/favorites/SavedSearchManager.java
@@ -29,7 +29,7 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.criteria.SavedSearchCriteria;
import org.rhq.core.domain.search.SavedSearch;
-import org.rhq.enterprise.gui.coregui.client.SearchGUI;
+import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.gwt.SearchGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.search.SearchBar;
@@ -74,8 +74,8 @@ public class SavedSearchManager {
public synchronized void updatePatternByName(final String name, final String pattern)
{
SavedSearch savedSearch = savedSearches.get(name);
if (savedSearch == null) { // created case
- final SavedSearch newSavedSearch = new
SavedSearch(searchBar.getSearchSubsystem(), name, pattern, SearchGUI
- .getSessionSubject());
+ final SavedSearch newSavedSearch = new
SavedSearch(searchBar.getSearchSubsystem(), name, pattern,
+ UserSessionManager.getSessionSubject());
searchService.createSavedSearch(newSavedSearch, new
AsyncCallback<Integer>() {
public void onFailure(Throwable caught) {
@@ -157,7 +157,7 @@ public class SavedSearchManager {
}
private synchronized void load() {
- Subject currentUser = SearchGUI.getSessionSubject();
+ Subject currentUser = UserSessionManager.getSessionSubject();
SavedSearchCriteria criteria = new SavedSearchCriteria();
criteria.addFilterSubjectId(currentUser.getId());
criteria.addFilterSearchSubsystem(searchBar.getSearchSubsystem());
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/rpc/MonitoringRequestCallback.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/rpc/MonitoringRequestCallback.java
index 4456c1c..9b80112 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/rpc/MonitoringRequestCallback.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/rpc/MonitoringRequestCallback.java
@@ -21,7 +21,6 @@ package org.rhq.enterprise.gui.coregui.client.util.rpc;
import com.google.gwt.http.client.Request;
import com.google.gwt.http.client.RequestCallback;
import com.google.gwt.http.client.Response;
-import com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
@@ -42,11 +41,6 @@ public class MonitoringRequestCallback implements RequestCallback {
this.name = name;
id = RPCManager.getInstance().register(this);
this.callback = callback;
- if (callback instanceof RequestCallbackAdapter) {
-// ((RequestCallbackAdapter)callback)
-
- }
-
}
public void onError(Request request, Throwable exception) {
@@ -56,7 +50,6 @@ public class MonitoringRequestCallback implements RequestCallback {
public void onResponseReceived(Request request, Response response) {
if (STATUS_CODE_OK == response.getStatusCode()) {
-
RPCManager.getInstance().succeedCall(this);
callback.onResponseReceived(request, response);
} else {
@@ -67,7 +60,6 @@ public class MonitoringRequestCallback implements RequestCallback {
}
}
-
public String getName() {
return name;
}
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/CoreGUI.html
b/modules/enterprise/gui/coregui/src/main/webapp/CoreGUI.html
index fb46e97..5dd3c64 100644
--- a/modules/enterprise/gui/coregui/src/main/webapp/CoreGUI.html
+++ b/modules/enterprise/gui/coregui/src/main/webapp/CoreGUI.html
@@ -23,10 +23,9 @@
<script type="text/javascript" language="javascript"
src="org.rhq.enterprise.gui.coregui.CoreGUI/org.rhq.enterprise.gui.coregui.CoreGUI.nocache.js"></script>
-<div id="Loading-Panel" style="width: 214px;height: 90px; margin-top:
300px; margin-left: auto;margin-right: auto;">
-
+<div id="Loading-Panel" style="width: 214px; height: 90px; margin-top:
300px; margin-left: auto; margin-right: auto;">
<div style="text-align: center; border: 3px solid lightgray;">
- <img src="images/rhq_logo_animated_100px.gif"
alt="loading" style="margin: 5px;">
+ <img src="images/rhq_logo_animated_100px.gif"
alt="Loading..." style="border: none;">
Loading...
</div>
</div>
commit 98807bb7626dd9f33fe5e60176f73e711808b973
Author: Joseph Marques <joseph(a)redhat.com>
Date: Fri Sep 24 16:31:54 2010 -0400
fix login screen - disable drag/resize/move/minimize/close, better alignment
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java
index 077b692..a19fcec 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java
@@ -39,6 +39,7 @@ import com.smartgwt.client.widgets.form.events.SubmitValuesHandler;
import com.smartgwt.client.widgets.form.fields.CanvasItem;
import com.smartgwt.client.widgets.form.fields.HeaderItem;
import com.smartgwt.client.widgets.form.fields.PasswordItem;
+import com.smartgwt.client.widgets.form.fields.RowSpacerItem;
import com.smartgwt.client.widgets.form.fields.SubmitItem;
import com.smartgwt.client.widgets.form.fields.TextItem;
import com.smartgwt.client.widgets.form.fields.events.KeyPressEvent;
@@ -89,7 +90,8 @@ public class LoginView extends Canvas {
loginShowing = true;
form = new DynamicForm();
- form.setMargin(10);
+ form.setMargin(25);
+ form.setAutoFocus(true);
form.setShowErrorText(true);
form.setErrorOrientation(FormErrorOrientation.BOTTOM);
@@ -98,11 +100,12 @@ public class LoginView extends Canvas {
logo.setShowTitle(false);
HeaderItem header = new HeaderItem();
- header.setValue("RHQ Login");
+ header.setValue("Please Login");
TextItem user = new TextItem("user", "User");
user.setRequired(true);
user.setAttribute("autoComplete", "native");
+
final PasswordItem password = new PasswordItem("password",
"Password");
password.setRequired(true);
password.setAttribute("autoComplete", "native");
@@ -126,21 +129,26 @@ public class LoginView extends Canvas {
}
});
- form.setFields(logo, header, user, password, loginButton);
+ form.setFields(logo, header, new RowSpacerItem(), user, password,
loginButton);
window = new Window();
- window.setTitle("RHQ Login");
window.setWidth(400);
- window.setHeight(250);
+ window.setHeight(275);
+ window.setTitle("Welcome");
+
+ // forced focused, static size, can't close / dismiss
window.setIsModal(true);
window.setShowModalMask(true);
- window.setCanDragResize(true);
+ window.setCanDragResize(false);
+ window.setCanDragReposition(false);
+ window.setShowCloseButton(false);
+ window.setShowMinimizeButton(false);
+
window.centerInPage();
+
window.addItem(form);
window.show();
- form.focusInItem(user);
-
form.addSubmitValuesHandler(new SubmitValuesHandler() {
public void onSubmitValues(SubmitValuesEvent submitValuesEvent) {
if (form.validate()) {
commit 2493b2c730de20bd805f460e81f7a4e2ebfd3a97
Author: Joseph Marques <joseph(a)redhat.com>
Date: Fri Sep 24 14:49:51 2010 -0400
fix error message during login
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java
index 6290eb7..077b692 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java
@@ -220,7 +220,7 @@ public class LoginView extends Canvas {
if (statusCode == 401) {
form.setFieldErrors("login", "The username or password
provided does not match our records", true);
} else {
- form.setFieldErrors("login", "The server could data source is
unavailable", true);
+ form.setFieldErrors("login", "The backend data source is
unavailable", true);
}
loginButton.setDisabled(false);
}
commit 2fd87a1f7b9ad8e113d2e4448cb14b84d76da58a
Author: Joseph Marques <joseph(a)redhat.com>
Date: Thu Sep 23 23:46:10 2010 -0400
do not wrap cells, the contents could be enormous
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java
index d185f40..954bac7 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java
@@ -90,6 +90,9 @@ public class EventCompositeHistoryView extends TableSection {
protected void configureTable() {
ListGrid grid = getListGrid();
+ grid.setWrapCells(true);
+ grid.setFixedRecordHeights(true);
+
// getListGrid().getField("id").setWidth(60);
grid.getField("timestamp").setWidth(125);
commit 35b45657af8e90730df664c8533c9384e4210002
Author: Joseph Marques <joseph(a)redhat.com>
Date: Thu Sep 23 23:36:19 2010 -0400
add headerIcon to discovery manager table view
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 445d1cb..e1ea25e 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
@@ -24,8 +24,10 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.data.DataSource;
import com.smartgwt.client.types.SelectionAppearance;
+import com.smartgwt.client.types.VerticalAlignment;
import com.smartgwt.client.widgets.HTMLFlow;
import com.smartgwt.client.widgets.IButton;
+import com.smartgwt.client.widgets.Img;
import com.smartgwt.client.widgets.events.ClickEvent;
import com.smartgwt.client.widgets.events.ClickHandler;
import com.smartgwt.client.widgets.form.DynamicForm;
@@ -36,6 +38,7 @@ import com.smartgwt.client.widgets.grid.ListGridRecord;
import com.smartgwt.client.widgets.grid.events.SelectionChangedHandler;
import com.smartgwt.client.widgets.grid.events.SelectionEvent;
import com.smartgwt.client.widgets.layout.HLayout;
+import com.smartgwt.client.widgets.layout.LayoutSpacer;
import com.smartgwt.client.widgets.toolbar.ToolStrip;
import com.smartgwt.client.widgets.tree.TreeGrid;
import com.smartgwt.client.widgets.tree.TreeGridField;
@@ -59,11 +62,13 @@ public class ResourceAutodiscoveryView extends LocatableVLayout {
private TreeGrid treeGrid;
private ToolStrip footer;
private DataSource dataSource = null;
+ private String headerIcon = "global/Recent_16.png";
private ResourceGWTServiceAsync resourceService =
GWTServiceLookup.getResourceService();
public ResourceAutodiscoveryView(String locatorId) {
super(locatorId);
+
setWidth100();
setHeight100();
}
@@ -78,8 +83,8 @@ public class ResourceAutodiscoveryView extends LocatableVLayout {
super.onInit();
if (!simple) {
-
- HLayout titleLayout = new HLayout(150);
+ Img img = new Img(headerIcon, 24, 24);
+ img.setPadding(4);
HTMLFlow title = new HTMLFlow();
title.setWidth100();
@@ -87,14 +92,12 @@ public class ResourceAutodiscoveryView extends LocatableVLayout {
title.setContents("Discovery Manager");
title.setPadding(4);
title.setStyleName("HeaderLabel");
- titleLayout.addMember(title);
DynamicForm form = new
LocatableDynamicForm(this.extendLocatorId("Status"));
final SelectItem statusSelectItem = new SelectItem("status",
"Status");
statusSelectItem.setValueMap("New", "Ignored", "New
and Ignored");
statusSelectItem.setValue("New");
form.setItems(statusSelectItem);
- titleLayout.addMember(form);
statusSelectItem.addChangedHandler(new ChangedHandler() {
public void onChanged(ChangedEvent changedEvent) {
@@ -102,6 +105,15 @@ public class ResourceAutodiscoveryView extends LocatableVLayout {
}
});
+ HLayout titleLayout = new HLayout();
+ titleLayout.setAutoHeight();
+ titleLayout.setAlign(VerticalAlignment.BOTTOM);
+
+ titleLayout.addMember(img);
+ titleLayout.addMember(title);
+ titleLayout.addMember(new LayoutSpacer());
+ titleLayout.addMember(form);
+
addMember(titleLayout);
}
commit 978e6463310bf0155ec4cd9d2ea6a4d23951b9c1
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Fri Sep 24 20:17:33 2010 -0400
conn props for various JVM services (Memory Pool, etc.) should be read-only
(
https://bugzilla.redhat.com/show_bug.cgi?id=601715)
diff --git a/modules/plugins/jmx/src/main/resources/META-INF/rhq-plugin.xml
b/modules/plugins/jmx/src/main/resources/META-INF/rhq-plugin.xml
index 2c7ca1d..dc5a4cf 100644
--- a/modules/plugins/jmx/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/jmx/src/main/resources/META-INF/rhq-plugin.xml
@@ -119,9 +119,9 @@
createDeletePolicy="neither" singleton="true">
<plugin-configuration>
- <c:simple-property name="objectName"
default="java.lang:type=OperatingSystem"/>
- <c:simple-property name="nameTemplate" default="Operating
system information"/>
- <c:simple-property name="descriptionTemplate"
default="Operating system information provided by the JVM."/>
+ <c:simple-property name="objectName" readOnly="true"
default="java.lang:type=OperatingSystem"/>
+ <c:simple-property name="nameTemplate" readOnly="true"
default="Operating system information"/>
+ <c:simple-property name="descriptionTemplate"
readOnly="true" default="Operating system information provided by the
JVM."/>
</plugin-configuration>
<metric displayName="Free Physical Memory"
@@ -160,7 +160,7 @@
<plugin-configuration>
<c:simple-property name="objectName" readOnly="true"
default="java.lang:type=Threading"/>
- <c:simple-property name="nameTemplate"
default="Threading"/>
+ <c:simple-property name="nameTemplate" readOnly="true"
default="Threading"/>
</plugin-configuration>
<operation displayName="Reset Peak Thread Metrics"
name="resetPeakThreadCount"
@@ -250,7 +250,7 @@
<plugin-configuration>
<c:simple-property name="objectName" readOnly="true"
default="java.lang:type=Memory"/>
- <c:simple-property name="nameTemplate" default="Memory
Subsystem"/>
+ <c:simple-property name="nameTemplate" readOnly="true"
default="Memory Subsystem"/>
</plugin-configuration>
<operation name="gc" displayName="Run Garbage Collection"
description="Runs the garbage collector."/>
@@ -312,9 +312,9 @@
<plugin-configuration>
<c:simple-property name="objectName"
readOnly="true" default="java.lang:type=MemoryPool,name=%name%"/>
- <c:simple-property name="nameTemplate"
default="{name}"/>
- <c:simple-property name="descriptionTemplate"
default="The {name} memory pool for this VM."/>
- <c:simple-property name="name" type="string"
description="The memory pool's name"/>
+ <c:simple-property name="nameTemplate"
readOnly="true" default="{name}"/>
+ <c:simple-property name="descriptionTemplate"
readOnly="true" default="The {name} memory pool for this VM."/>
+ <c:simple-property name="name" type="string"
readOnly="true" description="The memory pool's name"/>
</plugin-configuration>
<metric displayName="Used"
@@ -355,9 +355,9 @@
<plugin-configuration>
<c:simple-property name="objectName"
readOnly="true"
default="java.lang:type=GarbageCollector,name=%name%"/>
- <c:simple-property name="nameTemplate"
default="{name}"/>
- <c:simple-property name="descriptionTemplate"
default="The {name} Garbage Collector for this VM."/>
- <c:simple-property name="name" type="string"
description="The garbage collector's name"/>
+ <c:simple-property name="nameTemplate"
readOnly="true" default="{name}"/>
+ <c:simple-property name="descriptionTemplate"
readOnly="true" default="The {name} Garbage Collector for this
VM."/>
+ <c:simple-property name="name" type="string"
readOnly="true" description="The garbage collector's name"/>
</plugin-configuration>
<metric property="CollectionCount"
@@ -384,7 +384,7 @@
<plugin-configuration>
<c:simple-property name="objectName" readOnly="true"
default="java.lang:type=Compilation"/>
- <c:simple-property name="nameTemplate"
default="Compilation"/>
+ <c:simple-property name="nameTemplate" readOnly="true"
default="Compilation"/>
</plugin-configuration>
<metric property="TotalCompilationTime"
@@ -400,7 +400,7 @@
<plugin-configuration>
<c:simple-property name="objectName" readOnly="true"
default="java.lang:type=ClassLoading"/>
- <c:simple-property name="nameTemplate" default="Class
Loading"/>
+ <c:simple-property name="nameTemplate" readOnly="true"
default="Class Loading"/>
</plugin-configuration>
<metric displayName="Loaded Classes"
@@ -428,7 +428,7 @@
<plugin-configuration>
<c:simple-property name="objectName" readOnly="true"
default="java.util.logging:type=Logging"/>
- <c:simple-property name="nameTemplate"
default="Logging"/>
+ <c:simple-property name="nameTemplate" readOnly="true"
default="Logging"/>
<c:simple-property name="configManagementEnabled"
type="boolean" default="false" description="When false,
configuration reading for this resource will fail."/>
</plugin-configuration>
commit da4d8fd6d57b787c612e829486f0ed83a582680f
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Fri Sep 24 18:13:58 2010 -0400
cleanup/refactor group tree view code; add autotypegroup nodes to cluster group tree
(still need to add subcategory nodes); delete unused ResourceGroupTreeDatasource class;
add toString() impl to FileSystemInfo class
diff --git
a/modules/core/native-system/src/main/java/org/rhq/core/system/FileSystemInfo.java
b/modules/core/native-system/src/main/java/org/rhq/core/system/FileSystemInfo.java
index f6415ba..2bde8ee 100644
--- a/modules/core/native-system/src/main/java/org/rhq/core/system/FileSystemInfo.java
+++ b/modules/core/native-system/src/main/java/org/rhq/core/system/FileSystemInfo.java
@@ -35,7 +35,7 @@ import org.hyperic.sigar.SigarProxy;
* @author John Mazzitelli
*/
public class FileSystemInfo {
- private final Log log = LogFactory.getLog(FileSystemInfo.class);
+ private final Log log = LogFactory.getLog(this.getClass());
private final String mountPoint;
private FileSystem fs;
@@ -91,4 +91,13 @@ public class FileSystemInfo {
public FileSystemUsage getFileSystemUsage() {
return this.fsUsage;
}
+
+ @Override
+ public String toString() {
+ return this.getClass().getSimpleName() + "[" +
+ "mountPoint='" + mountPoint + '\'' +
+ ", fs=" + fs +
+ ", fsUsage=" + fsUsage +
+ ']';
+ }
}
\ No newline at end of file
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeDatasource.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeDatasource.java
deleted file mode 100644
index 76b7b76..0000000
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeDatasource.java
+++ /dev/null
@@ -1,368 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2010 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail;
-
-import java.util.ArrayList;
-import java.util.EnumSet;
-import java.util.HashMap;
-import java.util.List;
-
-import com.google.gwt.user.client.rpc.AsyncCallback;
-import com.smartgwt.client.data.DSRequest;
-import com.smartgwt.client.data.DSResponse;
-import com.smartgwt.client.data.DataSource;
-import com.smartgwt.client.data.DataSourceField;
-import com.smartgwt.client.data.fields.DataSourceImageField;
-import com.smartgwt.client.data.fields.DataSourceTextField;
-import com.smartgwt.client.rpc.RPCResponse;
-import com.smartgwt.client.types.DSDataFormat;
-import com.smartgwt.client.types.DSProtocol;
-import com.smartgwt.client.widgets.tree.TreeNode;
-
-import org.rhq.core.domain.criteria.ResourceCriteria;
-import org.rhq.core.domain.measurement.AvailabilityType;
-import org.rhq.core.domain.resource.Resource;
-import org.rhq.core.domain.resource.ResourceCategory;
-import org.rhq.core.domain.resource.ResourceSubCategory;
-import org.rhq.core.domain.resource.ResourceType;
-import org.rhq.core.domain.util.PageList;
-import org.rhq.enterprise.gui.coregui.client.CoreGUI;
-import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
-import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGWTServiceAsync;
-import
org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
-
-/**
- * This doesn't extend RPCDataSource because it is tree oriented and
- * behaves different from normal list data sources in some places.
- *
- * @author Greg Hinkle
- */
-public class ResourceGroupTreeDatasource extends DataSource {
-
- private boolean initialized = false;
- int rootId;
- List<Resource> initialData;
-
- private ResourceGWTServiceAsync resourceService =
GWTServiceLookup.getResourceService();
-
- public ResourceGroupTreeDatasource(List<Resource> initialData) {
- setClientOnly(false);
- setDataProtocol(DSProtocol.CLIENTCUSTOM);
- setDataFormat(DSDataFormat.CUSTOM);
-
- this.initialData = initialData;
-
- this.rootId = rootId;
-
- DataSourceField idDataField = new DataSourceTextField("id",
"ID");
- idDataField.setPrimaryKey(true);
-
- DataSourceTextField nameDataField = new DataSourceTextField("name",
"Name");
- nameDataField.setCanEdit(false);
-
- DataSourceTextField descriptionDataField = new
DataSourceTextField("description", "Description");
- descriptionDataField.setCanEdit(false);
-
- DataSourceImageField availabilityDataField = new
DataSourceImageField("currentAvailability", "Availability");
- descriptionDataField.setCanEdit(false);
-
- DataSourceTextField parentIdField = new DataSourceTextField("parentId",
"Parent ID");
- parentIdField.setForeignKey("id");
- // parentIdField.setRootValue(rootId);
-
- // DataSourceTextField parentKeyField = new
DataSourceTextField("parentKey", "Parent KEY");
- // parentKeyField.setForeignKey("id");
- // parentKeyField.setRootValue(rootId);
-
- // nameDataField.setType(FieldType.);
-
- setDropExtraFields(false);
-
- setFields(idDataField, nameDataField, descriptionDataField,
availabilityDataField);
- }
-
- @Override
- protected Object transformRequest(DSRequest request) {
- String requestId = request.getRequestId();
- DSResponse response = new DSResponse();
- response.setAttribute("clientContext",
request.getAttributeAsObject("clientContext"));
- // Asume success
- response.setStatus(0);
- switch (request.getOperationType()) {
- case ADD:
- //executeAdd(request, response);
- break;
- case FETCH:
- executeFetch(requestId, request, response);
- break;
- case REMOVE:
- //executeRemove(lstRec);
- break;
- case UPDATE:
- //executeAdd(lstRec, false);
- break;
-
- default:
- break;
- }
-
- return request.getData();
- }
-
-
- public void executeFetch(final String requestId, final DSRequest request, final
DSResponse response) {
- final long start = System.currentTimeMillis();
-
- String p = request.getCriteria().getAttribute("parentId");
- // System.out.println("All attributes: " +
Arrays.toString(request.getCriteria().getAttributes()));
-
- ResourceCriteria criteria = new ResourceCriteria();
-
- if (p == null) {
- System.out.println("DataSourceTree: Loading initial data");
-
- // criteria.addFilterId(rootId);
-
- processIncomingData(initialData, response, requestId);
- return;
-
- } else {
- System.out.println("DataSourceTree: Loading " + p);
-
- criteria.addFilterParentResourceId(Integer.parseInt(p));
- }
-
- // The server is already eager fetch resource type
- // * criteria.fetchResourceType(true);
-
- resourceService.findResourcesByCriteria(criteria, new
AsyncCallback<PageList<Resource>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to load resource data
for tree", caught);
- response.setStatus(RPCResponse.STATUS_FAILURE);
- processResponse(requestId, response);
- }
-
- public void onSuccess(PageList<Resource> result) {
- processIncomingData(result, response, requestId);
- }
- });
- }
-
- private void processIncomingData(List<Resource> result, final DSResponse
response, final String requestId) {
-
- ResourceTypeRepository.Cache.getInstance().loadResourceTypes(result,
- EnumSet.of(ResourceTypeRepository.MetadataType.operations,
ResourceTypeRepository.MetadataType.children,
ResourceTypeRepository.MetadataType.subCategory),
- new ResourceTypeRepository.ResourceTypeLoadedCallback() {
- public void onResourceTypeLoaded(List<Resource> result) {
- response.setData(build(result));
- processResponse(requestId, response);
-
- }
- });
- }
-
- /**
- * Construct a set of TreeNodes from a list of resources
- *
- * @param resources
- * @return
- */
- public static TreeNode[] build(List<Resource> resources) {
- ResourceTreeNode[] records = new ResourceTreeNode[resources.size()];
- for (int x = 0; x < resources.size(); x++) {
- Resource res = resources.get(x);
- ResourceTreeNode record = new ResourceTreeNode(res);
- records[x] = record;
- }
-
- return introduceTypeFolders(records);
- }
-
- private static TreeNode[] introduceTypeFolders(ResourceTreeNode[] nodes) {
- ArrayList<TreeNode> built = new ArrayList<TreeNode>();
- HashMap<ResourceSubCategory, CategoryTreeNode> categories = new
HashMap<ResourceSubCategory, CategoryTreeNode>();
- HashMap<ResourceType, TypeTreeNode> types = new HashMap<ResourceType,
TypeTreeNode>();
-
-
- for (ResourceTreeNode node : nodes) {
- built.add(node);
-
- if (!types.containsKey(node.getResourceType())
- && node.getResourceType().getCategory() !=
ResourceCategory.PLATFORM) {
-
- String parentResourceId =
String.valueOf(node.getResource().getParentResource().getId());
-
- CategoryTreeNode categoryNode = null;
-
- if (node.getResourceType().getSubCategory() != null) {
- ResourceSubCategory category =
node.getResourceType().getSubCategory();
- if (category.getName() != null) {
- categoryNode = categories.get(category);
-
- if (categoryNode == null) {
- categoryNode = new CategoryTreeNode(parentResourceId,
category);
-
- categories.put(category, categoryNode);
- built.add(categoryNode);
- }
- }
- }
-
- String parentId = null;
- if (categoryNode != null) {
- parentId = categoryNode.getAttribute("id");
- } else {
- parentId = parentResourceId;
- }
-
- TypeTreeNode typeNode = new TypeTreeNode(parentId, parentResourceId,
node.getResourceType().getName());
- built.add(typeNode);
- types.put(node.getResourceType(), typeNode);
- }
- }
-
- return built.toArray(new TreeNode[built.size()]);
-
- }
-
- private static boolean sameTypes(ResourceTreeNode[] nodes) {
- ResourceType first = nodes[0].getResourceType();
- for (ResourceTreeNode node : nodes) {
- if (!first.equals(node)) {
- return false;
- }
- }
- return true;
- }
-
- public static class CategoryTreeNode extends TreeNode {
- public CategoryTreeNode(String parentId, ResourceSubCategory category) {
- setID(parentId + "__" + category.getName());
- setParentID(parentId);
- setName(category.getDisplayName());
-
- setAttribute("id", parentId + "__" +
category.getName());
- setAttribute("parentId", parentId);
- setAttribute("name", category.getDisplayName());
- }
-
- @Override
- public String toString() {
- StringBuilder buffer = new StringBuilder();
- buffer.append("CategoryTreeNode[");
- String id = getAttribute("id");
- buffer.append("id=").append(id);
- String parentId = getAttribute("parentId");
- buffer.append(", parentId=").append(parentId);
- String name = getAttribute("name");
- buffer.append(", name=").append(name);
- buffer.append("]");
- return buffer.toString();
- }
- }
-
-
- public static class TypeTreeNode extends TreeNode {
- private TypeTreeNode(String parentId, String parentResourceId, String type) {
- setID(parentId + "_" + type);
- setParentID(parentId);
-
- setAttribute("id", parentResourceId + "_" + type);
- setAttribute("parentId", parentId);
- // setAttribute("parentKey", parentId);
- setAttribute("name", type);
- }
-
- @Override
- public String toString() {
- StringBuilder buffer = new StringBuilder();
- buffer.append("TypeTreeNode[");
- String id = getAttribute("id");
- buffer.append("id=").append(id);
- String parentId = getAttribute("parentId");
- buffer.append(", parentId=").append(parentId);
- String name = getAttribute("name");
- buffer.append(", name=").append(name);
- buffer.append("]");
- return buffer.toString();
- }
- }
-
- public static class ResourceTreeNode extends TreeNode {
- private Resource resource;
-
- private ResourceTreeNode(Resource resource) {
- this.resource = resource;
-
- String id = String.valueOf(resource.getId());
- String parentId = resource.getParentResource() == null ? null
- : (resource.getParentResource().getId() + "_" +
resource.getResourceType().getName());
-
- // System.out.println(id + " / " + parentId);
-
- setID(id);
- setParentID(parentId);
-
- setAttribute("id", id);
- setAttribute("parentId", parentId);
-
- // setAttribute("parentKey",
resource.getParentResource() == null ? 0 : (resource.getParentResource().getId() +
resource.getResourceType().getName()));
-
- setAttribute("name", resource.getName());
- setAttribute("description", resource.getDescription());
- setAttribute(
- "currentAvailability",
- resource.getCurrentAvailability().getAvailabilityType() ==
AvailabilityType.UP ? "/images/icons/availability_green_16.png"
- : "/images/icons/availability_red_16.png");
-
- setIsFolder((resource.getResourceType().getChildResourceTypes() != null
&& !resource.getResourceType()
- .getChildResourceTypes().isEmpty()));
- }
-
- public Resource getResource() {
- return resource;
- }
-
- public void setResource(Resource resource) {
- this.resource = resource;
- }
-
- public ResourceType getResourceType() {
- return resource.getResourceType();
- }
-
- public String getParentId() {
- return getAttribute("parentId");
- }
-
- @Override
- public String toString() {
- StringBuilder buffer = new StringBuilder();
- buffer.append("ResourceTreeNode[");
- String id = getAttribute("id");
- buffer.append("id=").append(id);
- String parentId = getAttribute("parentId");
- buffer.append(", parentId=").append(parentId);
- String name = getAttribute("name");
- buffer.append(", name=").append(name);
- buffer.append("]");
- return buffer.toString();
- }
- }
-}
\ No newline at end of file
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeView.java
index acaca4a..aa854f8 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeView.java
@@ -25,6 +25,7 @@ package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -55,9 +56,11 @@ import org.rhq.enterprise.gui.coregui.client.ViewId;
import org.rhq.enterprise.gui.coregui.client.ViewPath;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import
org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
+import org.rhq.enterprise.gui.coregui.client.util.StringUtility;
/**
* @author Greg Hinkle
+ * @author Ian Springer
*/
public class ResourceGroupTreeView extends VLayout implements BookmarkableView {
@@ -143,7 +146,7 @@ public class ResourceGroupTreeView extends VLayout implements
BookmarkableView {
new AsyncCallback<PageList<ResourceGroup>>() {
@Override
public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to load
group", caught);
+ CoreGUI.getErrorHandler().handleError("Failed to load group with
id [" + groupId + "].", caught);
}
@Override
@@ -151,64 +154,56 @@ public class ResourceGroupTreeView extends VLayout implements
BookmarkableView {
ResourceGroup group = result.get(0);
ResourceGroupTreeView.this.selectedGroup = group;
- if (GroupCategory.MIXED == group.getGroupCategory()) {
- ResourceGroupTreeView.this.rootResourceGroup = group;
- ResourceGroupTreeView.this.rootGroupId =
rootResourceGroup.getId();
- TreeNode fakeRoot = new TreeNode("fakeRootNode");
- TreeNode rootNode = new TreeNode(rootResourceGroup.getName());
- rootNode.setID(String.valueOf(rootResourceGroup.getId()));
//getClusterKey().toString());
- fakeRoot.setChildren(new TreeNode[] { rootNode });
- Tree tree = new Tree();
- tree.setRoot(fakeRoot);
- treeGrid.setData(tree);
- treeGrid.markForRedraw();
- } else {
- if (group.getClusterResourceGroup() == null) {
+ GroupCategory groupCategory = group.getGroupCategory();
+ switch (groupCategory) {
+ case MIXED:
ResourceGroupTreeView.this.rootResourceGroup = group;
- // This is a straight up group
- loadGroup(groupId);
- } else {
- // Someone select a cluster group beneath a real recursive
compatible group
-
- ResourceGroup rootGroup = group.getClusterResourceGroup();
- ResourceGroupTreeView.this.rootResourceGroup = rootGroup;
-
- loadGroup(rootGroup.getId());
- }
+ ResourceGroupTreeView.this.rootGroupId =
rootResourceGroup.getId();
+ TreeNode fakeRoot = new TreeNode("fakeRootNode");
+ TreeNode rootNode = new
TreeNode(rootResourceGroup.getName());
+ rootNode.setID(String.valueOf(rootResourceGroup.getId()));
//getClusterKey().toString());
+ fakeRoot.setChildren(new TreeNode[] { rootNode });
+ Tree tree = new Tree();
+ tree.setRoot(fakeRoot);
+ treeGrid.setData(tree);
+ treeGrid.markForRedraw();
+ break;
+ case COMPATIBLE:
+ if (group.getClusterResourceGroup() == null) {
+ // This is a straight up compatible group.
+ ResourceGroupTreeView.this.rootResourceGroup = group;
+ } else {
+ // This is a cluster group beneath a real recursive
compatible group.
+ ResourceGroupTreeView.this.rootResourceGroup =
group.getClusterResourceGroup();
+ }
+
loadGroup(ResourceGroupTreeView.this.rootResourceGroup.getId());
+ break;
}
-
}
});
-
}
private void loadGroup(int groupId) {
-
if (groupId == this.rootGroupId) {
// Still looking at the same compat-recursive tree
// TODO reselect tree to selected node
+ TreeNode selectedNode;
if (this.selectedGroup.getClusterKey() != null) {
- TreeNode selectedNode =
treeGrid.getTree().findById(this.selectedGroup.getClusterKey());
- TreeNode[] parents = treeGrid.getTree().getParents(selectedNode);
- treeGrid.getTree().openFolders(parents);
- treeGrid.getTree().openFolder(selectedNode);
-
- treeGrid.selectRecord(selectedNode);
+ selectedNode =
treeGrid.getTree().findById(this.selectedGroup.getClusterKey());
} else {
- TreeNode selectedNode =
treeGrid.getTree().findById(String.valueOf(this.selectedGroup.getId()));
- TreeNode[] parents = treeGrid.getTree().getParents(selectedNode);
- treeGrid.getTree().openFolders(parents);
- treeGrid.getTree().openFolder(selectedNode);
-
- treeGrid.selectRecord(selectedNode);
+ selectedNode =
treeGrid.getTree().findById(String.valueOf(this.selectedGroup.getId()));
}
+ TreeNode[] parents = treeGrid.getTree().getParents(selectedNode);
+ treeGrid.getTree().openFolders(parents);
+ treeGrid.getTree().openFolder(selectedNode);
+ treeGrid.selectRecord(selectedNode);
} else {
this.rootGroupId = groupId;
GWTServiceLookup.getClusterService().getClusterTree(groupId, new
AsyncCallback<ClusterFlyweight>() {
public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to load
tree", caught);
+ CoreGUI.getErrorHandler().handleError("Failed to load group
tree.", caught);
}
public void onSuccess(ClusterFlyweight result) {
@@ -216,11 +211,10 @@ public class ResourceGroupTreeView extends VLayout implements
BookmarkableView {
}
});
}
-
}
private void loadTreeTypes(final ClusterFlyweight root) {
- HashSet<Integer> typeIds = new HashSet<Integer>();
+ Set<Integer> typeIds = new HashSet<Integer>();
typeIds.add(this.rootResourceGroup.getResourceType().getId());
getTreeTypes(root, typeIds);
@@ -235,7 +229,6 @@ public class ResourceGroupTreeView extends VLayout implements
BookmarkableView {
}
private void selectClusterGroup(ClusterKey key) {
-
GWTServiceLookup.getClusterService().createAutoClusterBackingGroup(key, true,
new AsyncCallback<ResourceGroup>() {
@Override
@@ -249,7 +242,6 @@ public class ResourceGroupTreeView extends VLayout implements
BookmarkableView {
History.newItem("ResourceGroup/" + groupId);
}
});
-
}
private void loadTree(ClusterFlyweight root) {
@@ -276,44 +268,79 @@ public class ResourceGroupTreeView extends VLayout implements
BookmarkableView {
treeGrid.markForRedraw();
}
- public void loadTree(TreeNode parent, ClusterFlyweight parentNode, ClusterKey
parentKey) {
- if (!parentNode.getChildren().isEmpty()) {
-
- // TODO Introduce type groups (Do we still like this model for recursive
compatibles?)
-
- ArrayList<TreeNode> childNodes = new ArrayList<TreeNode>();
-
- HashMap<Integer, TreeNode> typeNodes = new HashMap<Integer,
TreeNode>();
-
- for (ClusterFlyweight child : parentNode.getChildren()) {
- TreeNode node = new TreeNode(child.getName());
-
+ public void loadTree(TreeNode parentNode, ClusterFlyweight parentClusterGroup,
ClusterKey parentKey) {
+ if (!parentClusterGroup.getChildren().isEmpty()) {
+ // First pass - group the children by type.
+ Map<ResourceType, List<ClusterFlyweight>> childrenByType = new
HashMap<ResourceType, List<ClusterFlyweight>>();
+ for (ClusterFlyweight child : parentClusterGroup.getChildren()) {
ClusterKeyFlyweight keyFlyweight = child.getClusterKey();
- ClusterKey key = new ClusterKey(parentKey,
keyFlyweight.getResourceTypeId(), keyFlyweight
- .getResourceKey());
ResourceType type = this.typeMap.get(keyFlyweight.getResourceTypeId());
+ List<ClusterFlyweight> children = childrenByType.get(type);
+ if (children == null) {
+ children = new ArrayList<ClusterFlyweight>();
+ childrenByType.put(type, children);
+ }
+ children.add(child);
+ }
- String icon = "types/" + type.getCategory().getDisplayName() +
"_up_16.png";
-
- node.setIcon(icon);
+ // Second pass - process each of the sets of like-typed children created in
the first pass.
+ List<TreeNode> childNodes = new ArrayList<TreeNode>();
+ for (ResourceType type : childrenByType.keySet()) {
+ List<ClusterFlyweight> children = childrenByType.get(type);
+ List<TreeNode> nodesByType = new ArrayList<TreeNode>();
+ for (ClusterFlyweight child : children) {
+ TreeNode node = createClusterGroupNode(parentKey, type, child);
+ nodesByType.add(node);
+
+ if (!child.getChildren().isEmpty()) {
+ // Recurse.
+ ClusterKey key =
(ClusterKey)node.getAttributeAsObject("key");
+ loadTree(node, child, key);
+ }
+ }
- node.setID(key.getKey());
- node.setAttribute("key", key);
- node.setAttribute("resourceType", type);
- childNodes.add(node);
+ // TODO (ips): Insert subcategory nodes.
- if (child.getChildren().isEmpty()) {
- node.setIsFolder(false);
- } else {
- node.setIsFolder(true);
- loadTree(node, child, key);
+ if (type.isSingleton()) {
+ // If it's a singleton type, just insert the cluster group node
as is.
+ childNodes.addAll(nodesByType);
+ }
+ else {
+ // Otherwise insert an autoTypeGroup folder node to group all cluster
groups of this type.
+ TreeNode autoTypeGroupNode = createAutoTypeGroupNode(type,
nodesByType);
+ childNodes.add(autoTypeGroupNode);
}
}
- parent.setChildren(childNodes.toArray(new TreeNode[childNodes.size()]));
+ parentNode.setChildren(childNodes.toArray(new TreeNode[childNodes.size()]));
}
}
+ private TreeNode createClusterGroupNode(ClusterKey parentKey, ResourceType type,
ClusterFlyweight child) {
+ TreeNode node = new TreeNode(child.getName());
+
+ ClusterKeyFlyweight keyFlyweight = child.getClusterKey();
+ ClusterKey key = new ClusterKey(parentKey, keyFlyweight.getResourceTypeId(),
keyFlyweight
+ .getResourceKey());
+ String id = key.getKey();
+ node.setID(id);
+ node.setAttribute("key", key);
+ node.setAttribute("resourceType", type);
+ node.setIsFolder(!child.getChildren().isEmpty());
+
+ String icon = "types/" + type.getCategory().getDisplayName() +
"_up_16.png";
+ node.setIcon(icon);
+ return node;
+ }
+
+ private TreeNode createAutoTypeGroupNode(ResourceType type, List<TreeNode>
memberNodes) {
+ String name = StringUtility.pluralize(type.getName());
+ TreeNode autoTypeGroupNode = new TreeNode(name);
+ autoTypeGroupNode.setIsFolder(true);
+ autoTypeGroupNode.setChildren(memberNodes.toArray(new
TreeNode[memberNodes.size()]));
+ return autoTypeGroupNode;
+ }
+
public void renderView(ViewPath viewPath) {
currentViewId = viewPath.getCurrent();
int groupId = Integer.parseInt(currentViewId.getPath());
commit 746f2b2b63bf1aef017a1bfba7410002dbb008c6
Merge: a0461ff... 34d531b...
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Sep 24 16:18:36 2010 -0400
Merge branch 'master' into master-jay
commit a0461ff51bd1cf36283b504083b9eece378254d8
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Sep 24 16:15:30 2010 -0400
Initial cut at adding autogroup support. autogroups will now have
backing groups.
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index 11ba639..02aa606 100644
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@ -22,7 +22,7 @@
<properties>
<scm.module.path>modules/core/dbutils/</scm.module.path>
- <db.schema.version>2.95</db.schema.version>
+ <db.schema.version>2.96</db.schema.version>
</properties>
<dependencies>
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/inventory-schema.xml
b/modules/core/dbutils/src/main/scripts/dbsetup/inventory-schema.xml
index bf83991..6246880 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/inventory-schema.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/inventory-schema.xml
@@ -168,11 +168,13 @@
<column name="CATEGORY" type="VARCHAR2"
size="20" required="true"/>
+ <!-- These two only set if this is a backing group for a resource
auto-cluster -->
<column name="CLUSTER_KEY" type="VARCHAR2"
size="4000" required="false"/>
-
- <!-- These two only set if this is a backing group for a resource cluster
-->
<column name="CLUSTER_RESOURCE_GROUP_ID" type="INTEGER"
references="RHQ_RESOURCE_GROUP"/>
+ <!-- This only set if this is a backing group for a resource auto-group
-->
+ <column name="AUTO_GROUP_PARENT_RESOURCE_ID"
type="INTEGER" references="RHQ_RESOURCE"/>
+
<column name="VISIBLE" type="BOOLEAN"/>
<index name="RHQ_RES_GROUP_NAME" unique="false">
diff --git a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
index ddb1974..f0940ab 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -3215,6 +3215,20 @@
<schema-alterColumn table="RHQ_RESOURCE"
column="VERSION" columnType="VARCHAR2" precision="100"
/>
</schemaSpec>
+ <schemaSpec version="2.96">
+ <!-- Support autogroup backing groups -->
+ <schema-addColumn table="RHQ_RESOURCE_GROUP"
column="AUTO_GROUP_PARENT_RESOURCE_ID" columnType="INTEGER" />
+ <schema-directSQL>
+ <statement desc="Creating RHQ_RESOURCE_GROUP foreign key
relation to RHQ_RESOURCE for autogroup backing groups">
+ ALTER TABLE RHQ_RESOURCE_GROUP
+ ADD CONSTRAINT RHQ_RG_AG_PARENT_ID_FK
+ FOREIGN KEY (AUTO_GROUP_PARENT_RESOURCE_ID)
+ REFERENCES RHQ_RESOURCE (ID)
+ </statement>
+ </schema-directSQL>
+
+ </schemaSpec>
+
</dbupgrade>
</target>
</project>
diff --git
a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceGroupCriteria.java
b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceGroupCriteria.java
index 6f5c259..2278c7f 100644
---
a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceGroupCriteria.java
+++
b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceGroupCriteria.java
@@ -42,13 +42,14 @@ public class ResourceGroupCriteria extends TaggedCriteria {
private static final long serialVersionUID = 1L;
private Integer filterId;
- private Integer filterDownMemberCount; // required overrides
private String filterName;
private Boolean filterRecursive;
private Integer filterResourceTypeId; // requires overrides
private String filterResourceTypeName; // requires overrides
+ private Integer filterAutoGroupParentResourceId; // requires overrides
private String filterPluginName; // requires overrides
private GroupCategory filterGroupCategory;
+ private Integer filterDownMemberCount; // required overrides
private List<Integer> filterExplicitResourceIds; // requires overrides
private List<Integer> filterImplicitResourceIds; // requires overrides
private ResourceCategory filterExplicitResourceCategory; // requires overrides
@@ -71,6 +72,9 @@ public class ResourceGroupCriteria extends TaggedCriteria {
public ResourceGroupCriteria() {
filterOverrides.put("resourceTypeId", "resourceType.id =
?");
+ filterOverrides.put("resourceTypeName", "resourceType.name like
?");
+ filterOverrides.put("autoGroupParentResourceId",
"autoGroupParentResource.id = ?");
+ filterOverrides.put("pluginName", "resourceType.plugin like
?");
filterOverrides.put("downMemberCount", "" //
+ "id IN ( SELECT implicitGroup.id " //
+ " FROM Resource res " //
@@ -78,8 +82,6 @@ public class ResourceGroupCriteria extends TaggedCriteria {
+ " WHERE res.currentAvailability.availabilityType = 0 "
//
+ " GROUP BY implicitGroup.id " //
+ " HAVING COUNT(res) >= ? )");
- filterOverrides.put("resourceTypeName", "resourceType.name like
?");
- filterOverrides.put("pluginName", "resourceType.plugin like
?");
filterOverrides.put("explicitResourceIds", "" //
+ "id IN ( SELECT explicitGroup.id " //
+ " FROM Resource res " //
@@ -146,6 +148,10 @@ public class ResourceGroupCriteria extends TaggedCriteria {
this.filterResourceTypeName = filterResourceTypeName;
}
+ public void addFilterAutoGroupParentResourceId(Integer
filterAutoGroupParentResourceId) {
+ this.filterAutoGroupParentResourceId = filterAutoGroupParentResourceId;
+ }
+
public void addFilterPluginName(String filterPluginName) {
this.filterPluginName = filterPluginName;
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java
b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java
index 9355e30..6726bbb 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java
@@ -1031,6 +1031,11 @@ public class Resource implements Comparable<Resource>,
Serializable {
@ManyToMany(mappedBy = "resources", fetch = FetchType.LAZY, cascade =
CascadeType.REMOVE)
private Set<Tag> tags;
+ // When a resource is removed any referring autgroup backing groups should also be
removed
+ // bulk delete
+ @OneToMany(mappedBy = "autoGroupParentResource", fetch = FetchType.LAZY)
+ private List<ResourceGroup> autoGroupBackingGroups = null;
+
public Resource() {
}
@@ -1629,6 +1634,14 @@ public class Resource implements Comparable<Resource>,
Serializable {
}
}
+ public List<ResourceGroup> getAutoGroupBackingGroups() {
+ return autoGroupBackingGroups;
+ }
+
+ public void setAutoGroupBackingGroups(List<ResourceGroup>
autoGroupBackingGroups) {
+ this.autoGroupBackingGroups = autoGroupBackingGroups;
+ }
+
public int compareTo(Resource that) {
return this.name.compareTo(that.getName());
}
diff --git
a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/ResourceGroup.java
b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/ResourceGroup.java
index d9ca343..46d6bcb 100644
---
a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/ResourceGroup.java
+++
b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/ResourceGroup.java
@@ -183,8 +183,7 @@ import org.rhq.core.domain.tagging.Tag;
+ " AND res.id NOT IN ( SELECT explicitRes.id " //
+ " FROM ResourceGroup rg " //
+ " JOIN rg.explicitResources explicitRes "
//
- + " WHERE rg.id = :groupId ) ")
-})
+ + " WHERE rg.id = :groupId ) ") })
@SequenceGenerator(name = "id", sequenceName =
"RHQ_RESOURCE_GROUP_ID_SEQ")
@Table(name = "RHQ_RESOURCE_GROUP")
@XmlAccessorType(XmlAccessType.FIELD)
@@ -441,13 +440,18 @@ public class ResourceGroup extends Group {
@ManyToOne
private ResourceGroup clusterResourceGroup = null;
- // When false hide this group from the UI. For example, for a Resource Cluster
backing group.
- private boolean visible = true;
-
- // When a compatible group is removed any referring backing groups should also be
removed
+ // When a compatible group is removed any referring autocluster backing groups should
also be removed
@OneToMany(mappedBy = "clusterResourceGroup")
private List<ResourceGroup> clusterBackingGroups = null;
+ // The parent resource for which this is an auto-group backing group
+ @JoinColumn(name = "AUTO_GROUP_PARENT_RESOURCE_ID", referencedColumnName =
"ID", nullable = true)
+ @ManyToOne
+ private Resource autoGroupParentResource = null;
+
+ // When false hide this group from the UI. For example, for an autocluster or
autogroup backing group.
+ private boolean visible = true;
+
// bulk delete @OneToMany(mappedBy = "resource", cascade = {
CascadeType.ALL })
@OneToMany(mappedBy = "resourceGroup", cascade = { CascadeType.MERGE,
CascadeType.PERSIST, CascadeType.REFRESH })
private Set<AlertDefinition> alertDefinitions = new
LinkedHashSet<AlertDefinition>();
@@ -624,6 +628,14 @@ public class ResourceGroup extends Group {
this.clusterResourceGroup = clusterResourceGroup;
}
+ public Resource getAutoGroupParentResource() {
+ return autoGroupParentResource;
+ }
+
+ public void setAutoGroupParentResource(Resource autoGroupParentResource) {
+ this.autoGroupParentResource = autoGroupParentResource;
+ }
+
public boolean isVisible() {
return visible;
}
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 00a27f0..f5c14c5 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java
@@ -51,6 +51,7 @@ import org.rhq.enterprise.gui.coregui.client.alert.AlertsView;
import org.rhq.enterprise.gui.coregui.client.bundle.BundleTopView;
import org.rhq.enterprise.gui.coregui.client.dashboard.DashboardsView;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.AutoGroupTopView;
import
org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.ResourceGroupTopView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.InventoryView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.ResourceTopView;
@@ -291,6 +292,8 @@ public class CoreGUI implements EntryPoint,
ValueChangeHandler<String> {
canvas = new ResourceTopView("Resource");
} else if (breadcrumbName.equals("ResourceGroup")) {
canvas = new ResourceGroupTopView("Group");
+ } else if (breadcrumbName.equals("AutoGroup")) {
+ canvas = new AutoGroupTopView("AutoGroup");
} else if (breadcrumbName.equals("Dashboard")) {
canvas = new DashboardsView("Dashboard");
} else if (breadcrumbName.equals("Bundles")) {
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/AutoGroupTopView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/AutoGroupTopView.java
new file mode 100644
index 0000000..384444f
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/AutoGroupTopView.java
@@ -0,0 +1,106 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.widgets.Canvas;
+
+import org.rhq.core.domain.criteria.ResourceGroupCriteria;
+import org.rhq.core.domain.resource.group.ResourceGroup;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.ViewPath;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.ResourceTreeView;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
+
+/**
+ * @author Greg Hinkle
+ */
+public class AutoGroupTopView extends LocatableHLayout implements BookmarkableView {
+
+ private Canvas contentCanvas;
+ private Integer parentResourceId;
+ private ResourceTreeView treeView;
+ private ResourceGroupDetailView detailView;
+
+ public AutoGroupTopView(String locatorId) {
+ super(locatorId);
+ }
+
+ @Override
+ protected void onInit() {
+ super.onInit();
+
+ setWidth100();
+ setHeight100();
+
+ treeView = new ResourceTreeView(getLocatorId());
+ detailView = new ResourceGroupDetailView(extendLocatorId("Detail"),
+ ResourceGroupDetailView.AUTO_GROUP_VIEW_PATH);
+ addMember(treeView);
+
+ contentCanvas = new Canvas();
+ addMember(contentCanvas);
+
+ setContent(detailView);
+ }
+
+ public void setContent(Canvas newContent) {
+ for (Canvas child : this.contentCanvas.getChildren()) {
+ child.destroy();
+ }
+ this.contentCanvas.addChild(newContent);
+ this.contentCanvas.markForRedraw();
+ }
+
+ public void renderView(final ViewPath viewPath) {
+ // we need the backing group parent resource id to render the LHS resource tree.
Once it's rendered leave
+ // it displayed but don't muck with it. A LHS user selection will drive a
view change.
+ if (null == this.parentResourceId) {
+ final int backingGroupId = Integer.valueOf(viewPath.getCurrent().getPath());
+ ResourceGroupCriteria criteria = new ResourceGroupCriteria();
+ criteria.addFilterId(backingGroupId);
+ criteria.addFilterVisible(false);
+
GWTServiceLookup.getResourceGroupService().findResourceGroupsByCriteria(criteria,
+ new AsyncCallback<PageList<ResourceGroup>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to fetch
autogroup backing group", caught);
+ }
+
+ public void onSuccess(PageList<ResourceGroup> result) {
+ if (result.isEmpty()) {
+ CoreGUI.getErrorHandler().handleError(
+ "Failed to find autogroup backing group: " +
backingGroupId);
+ } else {
+ String parentResourceId = String
+
.valueOf(result.get(0).getAutoGroupParentResource().getId());
+ treeView.renderView(new ViewPath(parentResourceId));
+ }
+ }
+ });
+ }
+ detailView.renderView(viewPath);
+ }
+}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
index f273c40..e00ecbe 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
@@ -60,7 +60,8 @@ import
org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTyp
* @author Ian Springer
*/
public class ResourceGroupDetailView extends
AbstractTwoLevelTabSetView<ResourceGroupComposite, ResourceGroupTitleBar> {
- private static final String BASE_VIEW_PATH = "ResourceGroup";
+ public static final String AUTO_GROUP_VIEW_PATH = "AutoGroup";
+ public static final String GROUP_VIEW_PATH = "ResourceGroup";
private Integer groupId;
private ResourceGroupComposite groupComposite;
@@ -97,8 +98,8 @@ public class ResourceGroupDetailView extends
AbstractTwoLevelTabSetView<Resource
private String currentTab;
private String currentSubTab;
- public ResourceGroupDetailView(String locatorId) {
- super(locatorId, BASE_VIEW_PATH);
+ public ResourceGroupDetailView(String locatorId, String baseViewPath) {
+ super(locatorId, baseViewPath);
this.hide();
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTopView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTopView.java
index ac0281c..3e87e03 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTopView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTopView.java
@@ -41,7 +41,6 @@ public class ResourceGroupTopView extends LocatableHLayout implements
Bookmarkab
super(locatorId);
}
-
@Override
protected void onInit() {
super.onInit();
@@ -49,20 +48,16 @@ public class ResourceGroupTopView extends LocatableHLayout implements
Bookmarkab
setWidth100();
setHeight100();
- treeView = new ResourceGroupTreeView();
+ treeView = new ResourceGroupTreeView(getLocatorId());
+ detailView = new ResourceGroupDetailView(extendLocatorId("Detail"),
ResourceGroupDetailView.GROUP_VIEW_PATH);
addMember(treeView);
contentCanvas = new Canvas();
addMember(contentCanvas);
- detailView = new ResourceGroupDetailView(extendLocatorId("Detail"));
-
- // treeView.addResourceSelectListener(detailView);
-
setContent(detailView);
}
-
public void setContent(Canvas newContent) {
for (Canvas child : this.contentCanvas.getChildren()) {
child.destroy();
@@ -71,10 +66,8 @@ public class ResourceGroupTopView extends LocatableHLayout implements
Bookmarkab
this.contentCanvas.markForRedraw();
}
-
- public void renderView(ViewPath viewPath) {
- this.treeView.renderView(viewPath);
- this.detailView.renderView(viewPath);
+ public void renderView(final ViewPath viewPath) {
+ treeView.renderView(viewPath);
+ detailView.renderView(viewPath);
}
-
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeView.java
index acaca4a..d701852 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeView.java
@@ -34,7 +34,6 @@ import com.smartgwt.client.data.Record;
import com.smartgwt.client.types.SelectionStyle;
import com.smartgwt.client.widgets.grid.events.SelectionChangedHandler;
import com.smartgwt.client.widgets.grid.events.SelectionEvent;
-import com.smartgwt.client.widgets.layout.VLayout;
import com.smartgwt.client.widgets.tree.Tree;
import com.smartgwt.client.widgets.tree.TreeGrid;
import com.smartgwt.client.widgets.tree.TreeNode;
@@ -55,11 +54,12 @@ import org.rhq.enterprise.gui.coregui.client.ViewId;
import org.rhq.enterprise.gui.coregui.client.ViewPath;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import
org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
/**
* @author Greg Hinkle
*/
-public class ResourceGroupTreeView extends VLayout implements BookmarkableView {
+public class ResourceGroupTreeView extends LocatableVLayout implements BookmarkableView
{
private TreeGrid treeGrid;
@@ -73,7 +73,8 @@ public class ResourceGroupTreeView extends VLayout implements
BookmarkableView {
private Map<Integer, ResourceType> typeMap;
private ResourceGroup selectedGroup;
- public ResourceGroupTreeView() {
+ public ResourceGroupTreeView(String locatorId) {
+ super(locatorId);
setWidth(250);
setHeight100();
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java
index ca3f8e6..07995df 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java
@@ -169,9 +169,7 @@ public class ResourceTreeDatasource extends DataSource {
ResourceTypeRepository.Cache.getInstance().loadResourceTypes(
result,
- EnumSet.of(
- ResourceTypeRepository.MetadataType.operations,
- ResourceTypeRepository.MetadataType.children,
+ EnumSet.of(ResourceTypeRepository.MetadataType.operations,
ResourceTypeRepository.MetadataType.children,
ResourceTypeRepository.MetadataType.subCategory),
new ResourceTypeRepository.ResourceTypeLoadedCallback() {
public void onResourceTypeLoaded(List<Resource> result) {
@@ -204,7 +202,7 @@ public class ResourceTreeDatasource extends DataSource {
List<TreeNode> updatedNodes = new ArrayList<TreeNode>();
// Maps category node IDs to the corresponding category nodes.
Map<String, SubCategoryTreeNode> subcategoryNodes = new HashMap<String,
SubCategoryTreeNode>();
- // Maps type node IDs to the corresponding type nodes.
+ // Maps autogroup/type node IDs to the corresponding autogroup/type nodes.
Map<String, AutoGroupTreeNode> autogroupNodes = new HashMap<String,
AutoGroupTreeNode>();
for (ResourceTreeNode resourceNode : resourceNodes) {
@@ -222,7 +220,8 @@ public class ResourceTreeDatasource extends DataSource {
do {
String subcategoryNodeId =
SubCategoryTreeNode.idOf(subcategory, parentResource);
if (!subcategoryNodes.containsKey(subcategoryNodeId)) {
- SubCategoryTreeNode subcategoryNode = new
SubCategoryTreeNode(subcategory, parentResource);
+ SubCategoryTreeNode subcategoryNode = new
SubCategoryTreeNode(subcategory,
+ parentResource);
subcategoryNodes.put(subcategoryNode.getID(),
subcategoryNode);
System.out.println("Adding " + subcategoryNode
+ " to tree...");
updatedNodes.add(subcategoryNode);
@@ -253,9 +252,8 @@ public class ResourceTreeDatasource extends DataSource {
setAttribute(Attributes.ID, id);
ResourceSubCategory parentCategory = category.getParentSubCategory();
- String parentId = (parentCategory != null) ?
- SubCategoryTreeNode.idOf(parentCategory, parentResource) :
- ResourceTreeNode.idOf(parentResource);
+ String parentId = (parentCategory != null) ?
SubCategoryTreeNode.idOf(parentCategory, parentResource)
+ : ResourceTreeNode.idOf(parentResource);
setParentID(parentId);
setAttribute(Attributes.PARENT_ID, parentId);
@@ -276,7 +274,17 @@ public class ResourceTreeDatasource extends DataSource {
* The folder node for a Resource autogroup.
*/
public static class AutoGroupTreeNode extends EnhancedTreeNode {
+
+ private Resource parentResource;
+ private ResourceType resourceType;
+
+ /**
+ * @param resource requires resourceType field be set. requires parentResource
field be set (null for no parent)
+ */
private AutoGroupTreeNode(Resource resource) {
+ this.parentResource = resource.getParentResource();
+ this.resourceType = resource.getResourceType();
+
String id = idOf(resource);
setID(id);
setAttribute(Attributes.ID, id);
@@ -295,20 +303,44 @@ public class ResourceTreeDatasource extends DataSource {
setAttribute(Attributes.DESCRIPTION, type.getDescription());
}
+ public Resource getParentResource() {
+ return parentResource;
+ }
+
+ public ResourceType getResourceType() {
+ return resourceType;
+ }
+
+ /**
+ * Generates a backing group name based on the resource type name and parent
resource name. It may not be unique
+ * so should not be used to query for the group (use rtId and parentResId). The
name may be displayed to the
+ * user.
+ *
+ * @return The name of the backing group.
+ */
+ public String getBackingGroupName() {
+ return this.getParentResource().getName() + " ( " +
this.getResourceType().getName() + " )";
+ }
+
+ /**
+ * Given a Resource, generate a unique ID for the AGNode.
+ *
+ * @param resource requires resourceType field be set. requires parentResource
field be set (null for no parent)
+ * @return The name string or null if the R
+ */
public static String idOf(Resource resource) {
Resource parentResource = resource.getParentResource();
- return (parentResource != null) ?
- "autogroup" + resource.getResourceType().getId() +
"_" + parentResource.getId() :
- null;
+ return (parentResource != null) ? "autogroup_" +
resource.getResourceType().getId() + "_"
+ + parentResource.getId() : null;
}
+ // parent node is either a subcategory node or a resouce node
public static String parentIdOf(Resource resource) {
ResourceType type = resource.getResourceType();
ResourceSubCategory parentCategory = type.getSubCategory();
- return (parentCategory != null) ?
- SubCategoryTreeNode.idOf(parentCategory, resource.getParentResource()) :
- ResourceTreeNode.idOf(resource.getParentResource());
- }
+ return (parentCategory != null) ? SubCategoryTreeNode.idOf(parentCategory,
resource.getParentResource())
+ : ResourceTreeNode.idOf(resource.getParentResource());
+ }
}
public static class ResourceTreeNode extends EnhancedTreeNode {
@@ -324,11 +356,9 @@ public class ResourceTreeDatasource extends DataSource {
Resource parentResource = resource.getParentResource();
String parentId;
if (parentResource != null) {
- parentId = resource.getResourceType().isSingleton() ?
- AutoGroupTreeNode.parentIdOf(resource) :
- AutoGroupTreeNode.idOf(resource);
- }
- else {
+ parentId = resource.getResourceType().isSingleton() ?
AutoGroupTreeNode.parentIdOf(resource)
+ : AutoGroupTreeNode.idOf(resource);
+ } else {
parentId = null;
}
setParentID(parentId);
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
index a03acaf..b20cfb3 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
@@ -52,6 +52,7 @@ import com.smartgwt.client.widgets.tree.events.NodeContextClickHandler;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.criteria.ResourceCriteria;
+import org.rhq.core.domain.criteria.ResourceGroupCriteria;
import org.rhq.core.domain.criteria.ResourceTypeCriteria;
import org.rhq.core.domain.dashboard.Dashboard;
import org.rhq.core.domain.dashboard.DashboardPortlet;
@@ -60,6 +61,7 @@ import org.rhq.core.domain.operation.OperationDefinition;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceCategory;
import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.domain.resource.group.ResourceGroup;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.Breadcrumb;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
@@ -69,6 +71,7 @@ import
org.rhq.enterprise.gui.coregui.client.components.configuration.Configurat
import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.resource.graph.GraphPortlet;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGWTServiceAsync;
+import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGroupGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.gwt.ResourceTypeGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceSelectListener;
import
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.create.OperationCreateWizard;
@@ -131,15 +134,19 @@ public class ResourceTreeView extends LocatableVLayout {
public void onSelectionChanged(SelectionEvent selectionEvent) {
if (!selectionEvent.isRightButtonDown() &&
selectionEvent.getState()) {
ListGridRecord selectedNode = treeGrid.getSelectedRecord();
- System.out.println("Node selected in tree: " +
selectedNode);
if (selectedNode instanceof ResourceTreeDatasource.ResourceTreeNode)
{
- ResourceTreeDatasource.ResourceTreeNode resourceNode =
- (ResourceTreeDatasource.ResourceTreeNode) selectedNode;
+ System.out.println("Resource Node selected in tree: " +
selectedNode);
+ ResourceTreeDatasource.ResourceTreeNode resourceNode =
(ResourceTreeDatasource.ResourceTreeNode) selectedNode;
String viewPath = "Resource/" +
resourceNode.getResource().getId();
String currentViewPath = History.getToken();
if (!currentViewPath.startsWith(viewPath)) {
CoreGUI.goToView(viewPath);
}
+ } else if (selectedNode instanceof
ResourceTreeDatasource.AutoGroupTreeNode) {
+ System.out.println("AutoGroup Node selected in tree: "
+ selectedNode);
+
handleSelectedAutoGroupNode((ResourceTreeDatasource.AutoGroupTreeNode) selectedNode);
+ } else {
+ System.out.println("Unhandled Node selected in tree: "
+ selectedNode);
}
}
}
@@ -170,9 +177,77 @@ public class ResourceTreeView extends LocatableVLayout {
});
}
+ private void handleSelectedAutoGroupNode(final
ResourceTreeDatasource.AutoGroupTreeNode agNode) {
+ final ResourceGroupGWTServiceAsync resourceGroupService =
GWTServiceLookup.getResourceGroupService();
+
+ // get the children tree nodes and build a child resourceId array
+ TreeNode[] children = treeGrid.getTree().getChildren(agNode);
+ final int[] childIds = new int[children.length];
+ for (int i = 0, size = children.length; (i < size); ++i) {
+ childIds[i] = ((ResourceTreeDatasource.ResourceTreeNode)
children[i]).getResource().getId();
+ }
+
+ // get the backing group if it exists, otherwise create the group
+ ResourceGroupCriteria criteria = new ResourceGroupCriteria();
+ criteria.addFilterResourceTypeId(agNode.getResourceType().getId());
+ criteria.addFilterAutoGroupParentResourceId(agNode.getParentResource().getId());
+ criteria.addFilterVisible(false);
+ resourceGroupService.findResourceGroupsByCriteria(criteria, new
AsyncCallback<PageList<ResourceGroup>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to fetch autogroup
backing group", caught);
+ }
+
+ public void onSuccess(PageList<ResourceGroup> result) {
+ if (result.isEmpty()) {
+ // Not found, create new backing group
+ // the backing group name is a display name using a unique
parentResource-resourceType combo
+ final String backingGroupName = agNode.getBackingGroupName();
+ ResourceGroup backingGroup = new ResourceGroup(backingGroupName);
+ backingGroup.setAutoGroupParentResource(agNode.getParentResource());
+ backingGroup.setResourceType(agNode.getResourceType());
+ backingGroup.setVisible(false);
+ backingGroup.setRecursive(false);
+ resourceGroupService.createResourceGroup(backingGroup, childIds,
+ new AsyncCallback<ResourceGroup>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to
create resource autogroup", caught);
+ }
+
+ public void onSuccess(ResourceGroup result) {
+ renderAutoGroup(result);
+ }
+ });
+ } else {
+ // backing group found, make sure the members are correct
+ final ResourceGroup backingGroup = result.get(0);
+ resourceGroupService.setAssignedResources(backingGroup.getId(),
childIds, false,
+ new AsyncCallback<Void>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(
+ "Failed to set assigned members for autogroup
backing group", caught);
+ }
+
+ public void onSuccess(Void result) {
+ renderAutoGroup(backingGroup);
+ }
+ });
+ }
+ }
+ });
+
+ }
+
+ private void renderAutoGroup(ResourceGroup backingGroup) {
+ String viewPath = "AutoGroup/" + backingGroup.getId();
+ String currentViewPath = History.getToken();
+ if (!currentViewPath.startsWith(viewPath)) {
+ CoreGUI.goToView(viewPath);
+ }
+ }
private void updateBreadcrumbs() {
- TreeNode selectedNode =
treeGrid.getTree().findById(ResourceTreeDatasource.ResourceTreeNode.idOf(selectedResourceId));
+ TreeNode selectedNode = treeGrid.getTree().findById(
+ ResourceTreeDatasource.ResourceTreeNode.idOf(selectedResourceId));
// System.out.println("Trying to preopen:
" + selectedNode);
if (selectedNode != null) {
TreeNode[] parents = treeGrid.getTree().getParents(selectedNode);
@@ -205,9 +280,7 @@ public class ResourceTreeView extends LocatableVLayout {
ResourceType type = node.getResource().getResourceType();
ResourceTypeRepository.Cache.getInstance().getResourceTypes(
type.getId(),
- EnumSet.of(
- ResourceTypeRepository.MetadataType.operations,
- ResourceTypeRepository.MetadataType.children,
+ EnumSet.of(ResourceTypeRepository.MetadataType.operations,
ResourceTypeRepository.MetadataType.children,
ResourceTypeRepository.MetadataType.subCategory,
ResourceTypeRepository.MetadataType.pluginConfigurationDefinition,
ResourceTypeRepository.MetadataType.resourceConfigurationDefinition),
@@ -509,8 +582,7 @@ public class ResourceTreeView extends LocatableVLayout {
TreeUtility.printTree(treeGrid.getTree());
- TreeNode selectedNode =
- treeGrid.getTree().findById(resourceNodeId);
+ TreeNode selectedNode =
treeGrid.getTree().findById(resourceNodeId);
// System.out.println("Trying to
preopen: " + selectedNode);
if (selectedNode != null) {
//
System.out.println("Preopen node!!!");
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
index c9b4420..0528b06 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
@@ -146,6 +146,8 @@ public class ResourceManagerBean implements ResourceManagerLocal,
ResourceManage
@EJB
private ResourceManagerLocal resourceManager; // ourself, for xactional semantic
consistency
@EJB
+ private ResourceGroupManagerLocal resourceGroupManager;
+ @EJB
private ResourceTypeManagerLocal typeManager;
@EJB
@IgnoreDependency
@@ -397,6 +399,26 @@ public class ResourceManagerBean implements ResourceManagerLocal,
ResourceManage
log.debug("Overlord is asynchronously deleting resource [" +
attachedResource + "]");
}
+ // one more thing, delete any autogroup backing groups
+ List<ResourceGroup> backingGroups =
attachedResource.getAutoGroupBackingGroups();
+ if (!backingGroups.isEmpty()) {
+ int size = backingGroups.size();
+ int[] backingGroupIds = new int[size];
+ for (int i = 0; (i < size); ++i) {
+ backingGroupIds[i] = backingGroups.get(i).getId();
+ }
+ try {
+ resourceGroupManager.deleteResourceGroups(user, backingGroupIds);
+ } catch (Throwable t) {
+ if (log.isDebugEnabled()) {
+ log.error("Bulk delete error for autogroup backing group
deletion for " + backingGroupIds, t);
+ } else {
+ log.error("Bulk delete error for autogroup backing group
deletion for " + backingGroupIds + ": "
+ + t.getMessage());
+ }
+ }
+ }
+
// now we can purge the resource, let cascading do the rest
entityManager.remove(attachedResource);
commit 34d531bf2b41cdb2b100903f984d0fa313984250
Merge: c8ecb19... 03c0fa9...
Author: John Sanda <jsanda(a)redhat.com>
Date: Thu Sep 23 13:00:22 2010 -0400
Merge branch 'master' of
ssh://git.fedorahosted.org/git/rhq/rhq
commit 03c0fa915be672fe82c8afd01c00e5ac1a5e6605
Author: Joseph Marques <joseph(a)redhat.com>
Date: Thu Sep 23 20:57:46 2010 -0400
convert EventCompositeDetailsView into a singleton, update callers appropriately
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDetailsView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDetailsView.java
index 343947b..3581a59 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDetailsView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDetailsView.java
@@ -45,31 +45,16 @@ import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
public class EventCompositeDetailsView extends VLayout implements BookmarkableView {
private int eventId;
- private EventComposite composite;
-
private ViewId viewId;
- public EventCompositeDetailsView(int eventId) {
- this.eventId = eventId;
- }
+ private static EventCompositeDetailsView INSTANCE = new EventCompositeDetailsView();
- public EventCompositeDetailsView(EventComposite composite) {
- this.composite = composite;
+ public static EventCompositeDetailsView getInstance() {
+ return INSTANCE;
}
- @Override
- protected void onDraw() {
- super.onDraw();
-
- for (Canvas child : getMembers()) {
- child.destroy();
- }
-
- if (this.composite != null) {
- show(composite);
- } else {
- show(eventId);
- }
+ private EventCompositeDetailsView() {
+ // access through the static singleton only
}
private void show(int eventId) {
@@ -96,12 +81,10 @@ public class EventCompositeDetailsView extends VLayout implements
BookmarkableVi
}
if (this.viewId != null) {
- viewId.getBreadcrumbs().get(0).setDisplayName("Event Details");
+ viewId.getBreadcrumbs().get(0).setDisplayName("Details");
CoreGUI.refreshBreadCrumbTrail();
}
- this.composite = composite;
-
DynamicForm form = new DynamicForm();
form.setWidth100();
form.setHeight100();
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java
index b9434f0..d185f40 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java
@@ -173,6 +173,6 @@ public class EventCompositeHistoryView extends TableSection {
@Override
public Canvas getDetailsView(int eventId) {
- return new EventCompositeDetailsView(eventId);
+ return EventCompositeDetailsView.getInstance();
}
}
commit e17220ef6827775b472f95e1d81417d12d61f5f9
Author: Joseph Marques <joseph(a)redhat.com>
Date: Thu Sep 23 20:57:41 2010 -0400
revert to old monitor>graphs page until new charting library chosen
* update embedded resource/group links
* disabled embedded links to full-screen graph
* update embedded links to event details
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
index 7236d4b..030eb2b 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
@@ -53,7 +53,6 @@ import
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.configura
import
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.configuration.ResourceConfigurationEditView;
import
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.inventory.PluginConfigurationEditView;
import
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.inventory.ResourceResourceGroupsView;
-import
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.GraphListView;
import
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.schedules.SchedulesView;
import
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.traits.TraitsView;
import
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.OperationHistoryView;
@@ -213,7 +212,8 @@ public class ResourceDetailView extends
AbstractTwoLevelTabSetView<ResourceCompo
"/rhq/resource/summary/timeline-plain.xhtml?id=" +
resource.getId()), true, true);
visible = hasMetricsOfType(this.resourceComposite, DataType.MEASUREMENT);
- canvas = (visible) ? new
GraphListView(this.monitoringTab.extendLocatorId("GraphListView"), resource) :
null;
+ //canvas = (visible) ? new
GraphListView(this.monitoringTab.extendLocatorId("GraphListView"), resource) :
null;
+ canvas = (visible) ? new
FullHTMLPane("/rhq/resource/monitor/graphs-plain.xhtml?id=" + resource.getId())
: null;
updateSubTab(this.monitoringTab, this.monitorGraphs, canvas, visible, true);
// visible = same test as above
canvas = (visible) ? new
FullHTMLPane("/rhq/common/monitor/tables-plain.xhtml?id=" + resource.getId()) :
null;
@@ -221,6 +221,7 @@ public class ResourceDetailView extends
AbstractTwoLevelTabSetView<ResourceCompo
visible = hasMetricsOfType(this.resourceComposite, DataType.TRAIT);
canvas = (visible) ? new
TraitsView(this.monitoringTab.extendLocatorId("TraitsView"), resource.getId()) :
null;
updateSubTab(this.monitoringTab, this.monitorTraits, canvas, visible, true);
+
updateSubTab(this.monitoringTab, this.monitorAvail, new FullHTMLPane(
"/rhq/resource/monitor/availabilityHistory-plain.xhtml?id=" +
resource.getId()), true, true);
updateSubTab(this.monitoringTab, this.monitorSched, new
SchedulesView(monitoringTab
diff --git
a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/events/EventDetailsAction.java
b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/events/EventDetailsAction.java
index 8403297..df45f52 100755
---
a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/events/EventDetailsAction.java
+++
b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/events/EventDetailsAction.java
@@ -86,6 +86,7 @@ public class EventDetailsAction extends BaseAction {
int groupId = WebUtility.getOptionalIntRequestParameter(request,
ParamConstants.GROUP_ID_PARAM, -1);
int parent = WebUtility.getOptionalIntRequestParameter(request,
"parent", -1);
int type = WebUtility.getOptionalIntRequestParameter(request,
"type", -1);
+ String mode = WebUtility.getOptionalRequestParameter(request,
"mode", "normal");
EventManagerLocal eventManager = LookupUtil.getEventManager();
@@ -124,7 +125,7 @@ public class EventDetailsAction extends BaseAction {
}
html.append(" ");
- createLinkForResource(resourceId, groupId, parent, type, html, event,
ridBadChars(event
+ createLinkForResource(mode, resourceId, groupId, parent, type, html,
event, ridBadChars(event
.getEventDetail()));
html.append("</li>");
}
@@ -133,7 +134,7 @@ public class EventDetailsAction extends BaseAction {
if (events.getTotalSize() > MAX_EVENTS_PER_DOT) {
EventComposite event = events.get(events.size() - 1); // take the
last one to initialize the list
html.append("<p/>");
- createLinkForResource(resourceId, groupId, parent, type, html, event,
res
+ createLinkForResource(mode, resourceId, groupId, parent, type, html,
event, res
.getMessage("resource.common.monitor.text.events.MoreEvents"));
html.append("<p/>");
}
@@ -149,30 +150,41 @@ public class EventDetailsAction extends BaseAction {
return mapping.findForward(RetCodeConstants.SUCCESS_URL);
}
- private void createLinkForResource(int resourceId, int groupId, int parent, int type,
StringBuffer html,
- EventComposite event, String text) {
+ private void createLinkForResource(String mode, int resourceId, int groupId, int
parent, int type,
+ StringBuffer html, EventComposite event, String text) {
- //html.append("<a
href=\"/resource/common/Events.do?mode=events&eventId=");
- html.append("<a
href=\"/rhq/resource/events/history.xhtml?eventId=");
- html.append(event.getEventId());
- if (resourceId > -1) {
- html.append("&id=").append(event.getResourceId());
- } else if (groupId > -1) {
- html.append("&groupId=").append(groupId);
+ log.info("mode = " + mode);
+ if (mode.equals("plain")) {
+ String context = (resourceId > -1) ? "Resource/" :
"ResourceGroup/";
+ int contextId = (resourceId > -1) ? resourceId : groupId;
+
+ html.append("<a target=\"_top\"
href=\"/coregui/CoreGUI.html#").append(context).append(contextId);
+
html.append("/Events/History/").append(event.getEventId()).append("\">");
+ html.append(text);
+ html.append("</a> ");
} else {
-
html.append("&parent=").append(parent).append("&type=").append(type);
- }
- html.append("\">");
- //html.append(event.getEventId());
- if (text.contains("\n")) {
- text = text.substring(0, text.indexOf("\n"));
- }
- if (text.length() > DETAIL_MAX_LEN) {
- text = text.substring(0, DETAIL_MAX_LEN - 1);
+ //html.append("<a
href=\"/resource/common/Events.do?mode=events&eventId=");
+ html.append("<a
href=\"/rhq/resource/events/history.xhtml?eventId=");
+ html.append(event.getEventId());
+ if (resourceId > -1) {
+ html.append("&id=").append(event.getResourceId());
+ } else if (groupId > -1) {
+ html.append("&groupId=").append(groupId);
+ } else {
+
html.append("&parent=").append(parent).append("&type=").append(type);
+ }
+ html.append("\">");
+ //html.append(event.getEventId());
+ if (text.contains("\n")) {
+ text = text.substring(0, text.indexOf("\n"));
+ }
+ if (text.length() > DETAIL_MAX_LEN) {
+ text = text.substring(0, DETAIL_MAX_LEN - 1);
+ }
+ html.append(text);
+ html.append("</a>");
+ html.append(" ");
}
- html.append(text);
- html.append("</a>");
- html.append(" ");
}
diff --git
a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/monitor/events/data-plain.xhtml
b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/monitor/events/data-plain.xhtml
new file mode 100644
index 0000000..068f97b
--- /dev/null
+++
b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/monitor/events/data-plain.xhtml
@@ -0,0 +1,180 @@
+<?xml version="1.0"?>
+
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:c="http://java.sun.com/jstl/core"
+
xmlns:rich="http://richfaces.ajax4jsf.org/rich"
+
xmlns:onc="http://jboss.org/on/component"
+
xmlns:onf="http://jboss.org/on/function">
+
+<ui:composition>
+
+<script type="text/javascript" src="/js/monitorGraphs.js" />
+<!-- need to include this function directly in the facelet so that parameter
resolution happens at render-time -->
+<script type="text/javascript">
+ function showEventsDetails(time, status) {
+ initEventDetails();
+ eventsTime = time;
+ var detail = $('eventsSummary');
+ detail.innerHTML = "";
+
+ if (status != null)
+ ajaxEngine.sendRequest( 'getEventDetails',
+ 'id=#{param.id}',
+ 'groupId=#{param.groupId}',
+ 'parent=#{param.parent}',
+ 'type=#{param.type}',
+ 'mode=plain',
+ 'begin=' + time,
+ 'status=' + status);
+ else
+ ajaxEngine.sendRequest( 'getEventDetails',
+ 'id=#{param.id}',
+ 'groupId=#{param.groupId}',
+ 'parent=#{param.parent}',
+ 'type=#{param.type}',
+ 'mode=plain',
+ 'begin=' + time);
+
+ showEventsCallback();
+ }
+</script>
+
+<div id="overlay" class="overlay"></div>
+
+<table cellpadding="0" cellspacing="0" border="0"
width="100%">
+
+ <c:if test="#{not empty EventsTimelineUIBean.data}">
+ <tr>
+ <td colspan="62" style="height: 2px;"></td>
+ </tr>
+
+ <tr style="height: 12px;">
+ <td></td>
+ <c:forEach var="timeTick" items="#{EventsTimelineUIBean.data}"
varStatus="status">
+ <c:set var="count" value="#{status.index}"/>
+ <c:set var="icon" value="/images/no_event.gif"/>
+ <c:if test="#{not empty timeTick.severity}">
+ <c:set var="sev"
value="#{timeTick.severity.ordinal}"/>
+ <c:choose>
+ <c:when test="#{sev == 0 }">
+ <c:set var="icon"
value="/images/event_debug.gif"/>
+ </c:when>
+ <c:when test="#{sev == 1 }">
+ <c:set var="icon"
value="/images/event_info.gif"/>
+ </c:when>
+ <c:when test="#{sev == 2 }">
+ <c:set var="icon"
value="/images/event_warn.gif"/>
+ </c:when>
+ <c:when test="#{sev == 3 }">
+ <c:set var="icon"
value="/images/event_error.gif"/>
+ </c:when>
+ <c:when test="#{sev == 4 }">
+ <c:set var="icon"
value="/images/event_fatal.gif"/>
+ </c:when>
+ <c:otherwise>
+ <c:set var="icon"
value="/images/no_event.gif"/>
+ </c:otherwise>
+ </c:choose>
+ </c:if>
+
+ <!-- put onmousedown in table data element not the div, which gives the user a
larger clickable area -->
+ <c:if test="#{empty timeTick.severity}">
+ <td style="background-image: url(#{icon});
background-repeat:no-repeat;" align="center" valign="middle">
+ </td>
+ </c:if>
+
+ <c:if test="#{not empty timeTick.severity}">
+ <ui:param name="formattedTimeTick"
value="#{onf:formatTimestamp(timeTick.time)}"/>
+ <td style="background-image: url(#{icon});
background-repeat:no-repeat;" align="center" valign="middle"
+
onmousedown="detailsShowing=true;overlay.moveOverlay(this);overlay.showTimePopup('#{count}','#{formattedTimeTick}');showEventsDetails(#{timeTick.time});">
+ </td>
+ </c:if>
+
+ </c:forEach>
+ <td style="margin: 0 0 0 5;">
+ <h:outputFormat
value="#{msg['resource.common.monitor.label.elc']}" />
+ </td>
+ </tr>
+
+ <tr>
+ <td colspan="62" valign="top">
+ <a name="eventDetail"></a>
+ <div id="eventDetailTable"
+ style="position: relative; height: 230px; display: none; ">
+ <div class="eventDetails">
+ <table cellspacing="0" width="100%">
+ <tr>
+ <td class="eventsTabOn" nowrap="nowrap">
+ <h:outputFormat
value="#{msg['resource.common.monitor.events.ListOfEvents']}" />
+ </td>
+ <td valign="top" style="text-align: right; border-bottom:
solid; border-width: 1px; border-color: #000000;">
+ <img src="/images/dash-icon_delete.gif"
+ onclick="detailsShowing=false;new
Effect.Fade($('eventDetailTable'), {afterFinish: function (obj) {
maxIndicatorDivHeight(); overlay.moveOverlay(this); }})"/>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="8">
+ <div id="eventsSummary" style="height:200px;
overflow:auto;"></div>
+ </td>
+ </tr>
+ </table>
+ </div>
+ </div>
+ </td>
+ </tr>
+
+ <tr>
+ <td colspan="62" style="height: 3px;"></td>
+ </tr>
+ </c:if>
+
+ <tr>
+ <td width="10">
+ <div id="timetop"></div>
+ <img src="/images/timeline_ll.gif" height="10"/>
+ </td>
+ <c:forEach var="timeTick" items="#{EventsTimelineUIBean.data}"
varStatus="status">
+ <c:set var="count" value="#{status.index}"/>
+ <ui:param name="formattedTimeTick"
value="#{onf:formatTimestamp(timeTick.time)}"/>
+ <td width="12">
+ <div id="timePopup_#{count}"
+
onmouseover="overlay.moveOverlay(this);overlay.showTimePopup('#{count}','#{formattedTimeTick}')"
>
+ <img src="/images/timeline_off.gif" height="10"
width="9"
+ onmouseover="imageSwap(this, imagePath + 'timeline',
'_on')"
+ onmouseout="imageSwap(this, imagePath + 'timeline',
'_off');"
+ onmousedown="imageSwap(this, imagePath + 'timeline',
'_down')" />
+ </div>
+ </td>
+ </c:forEach>
+ <td width="100%">
+ <img src="/images/timeline_lr.gif" height="10"/>
+ </td>
+ </tr>
+
+ <tr>
+ <td></td>
+ <td colspan="30" valign="top">
+ <h:outputText value="#{EventsTimelineUIBean.data[0].time}">
+ <f:converter converterId="UserDateTimeConverter" />
+ </h:outputText>
+ <div id="timePopup" class="timepopup"
onmousedown="overlay.hideTimePopup()"></div>
+ </td>
+ <td colspan="30" align="right" valign="top">
+ <h:outputText value="#{EventsTimelineUIBean.data[59].time}">
+ <f:converter converterId="UserDateTimeConverter" />
+ </h:outputText>
+ </td>
+ <td></td>
+ </tr>
+</table>
+
+</ui:composition>
+
+</html>
\ No newline at end of file
diff --git
a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/monitor/graphs-plain.xhtml
b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/monitor/graphs-plain.xhtml
new file mode 100644
index 0000000..acb697e
--- /dev/null
+++
b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/monitor/graphs-plain.xhtml
@@ -0,0 +1,123 @@
+<ui:composition
+
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:c="http://java.sun.com/jstl/core"
+
xmlns:onc="http://jboss.org/on/component"
+
xmlns:onf="http://jboss.org/on/function"
+
xmlns:s="http://jboss.com/products/seam/taglib"
+
xmlns:a4j="https://ajax4jsf.dev.java.net/ajax"
+
xmlns:rich="http://richfaces.ajax4jsf.org/rich">
+
+<table border="0" cellpadding="0" cellspacing="0"
width="100%">
+ <!-- chart actions -->
+ <tr class="BlockContent">
+ <td align="right">
+ <ui:include src="measurement/views.xhtml"/>
+ </td>
+ </tr>
+
+ <tr class="BlockContent">
+ <td>
+ <ui:include src="availability/data.xhtml"/>
+ </td>
+ </tr>
+
+ <tr class="BlockContent">
+ <td>
+ <div id="indicatorDiv" style="width: 750px; height: 400px;
border: 1; overflow-x: hidden; overflow-y: scroll;">
+ <ui:include src="measurement/data-plain.xhtml"/>
+ </div>
+ </td>
+ </tr>
+
+<tr class="BlockContent">
+ <td width="550px">
+ <div id="eventsDiv">
+ <ui:include src="events/data-plain.xhtml"/>
+ </div>
+ </td>
+</tr>
+
+<!-- spacer for date/time overlay, so it doesn't overlap metric display range
-->
+<tr class="BlockContent">
+ <td>
+ <br />
+ <br />
+ </td>
+</tr>
+
+<tr class="BlockContent">
+ <td>
+ <h:form id="MetricComponentForm">
+ <c:if test="#{IndicatorChartsUIBean.context.resourceId !=
-1}">
+ <input type="hidden" name="id"
value="#{IndicatorChartsUIBean.context.resourceId}" />
+ </c:if>
+ <c:if test="#{IndicatorChartsUIBean.context.groupId != -1}">
+ <input type="hidden" name="groupId"
value="#{IndicatorChartsUIBean.context.groupId}" />
+ </c:if>
+ <c:if test="#{IndicatorChartsUIBean.context.parentResourceId !=
-1}">
+ <input type="hidden" name="parent"
value="#{IndicatorChartsUIBean.context.parentResourceId}" />
+ </c:if>
+ <c:if test="#{IndicatorChartsUIBean.context.resourceTypeId !=
-1}">
+ <input type="hidden" name="type"
value="#{IndicatorChartsUIBean.context.resourceTypeId}" />
+ </c:if>
+ <table>
+ <tr>
+ <td><onc:metric optionList="m,h,d"
/></td>
+ <td>
+ <h:commandLink rendered="#{not
MetricComponentUtilityUIBean.readOnly}"
+
action="#{MetricComponentUtilityUIBean.update}" >
+ <img src="/images/dash-button_go-arrow.gif"
alt="Apply Metric Settings "/>
+ </h:commandLink>
+ <h:commandLink
rendered="#{MetricComponentUtilityUIBean.readOnly}"
+
action="#{MetricComponentUtilityUIBean.switchToSimpleMode}">
+ <h:outputText value="Switch to Simple Mode"
/>
+ </h:commandLink>
+ </td>
+ </tr>
+ </table>
+ </h:form>
+ </td>
+</tr>
+
+<!-- footerDiv used purely for calculating the height for the overlay -->
+<tr class="BlockContent">
+ <td>
+ <div id="footerDiv"></div>
+ </td>
+</tr>
+</table>
+
+<script type="text/javascript">
+ function maxIndicatorDivHeight() {
+ var indicatorDiv = getElementCrossBrowser("indicatorDiv");
+ var eventsDiv = getElementCrossBrowser("eventsDiv");
+ var footerDiv = getElementCrossBrowser("footerDiv");
+
+ //IE6 returns 0 for document.documentElement.clientHeight
+ var browserHeight = document.documentElement.clientHeight ||
document.body.clientHeight;
+ var indicatorTopPos = getElementTopPos(indicatorDiv);
+ var eventsTopPos = getElementTopPos(eventsDiv);
+ var footerTopPos = getElementTopPos(footerDiv) ;
+ var eventsDivHeight = footerTopPos - eventsTopPos;
+
+ var newIndicatorDivHeight = browserHeight - indicatorTopPos - eventsDivHeight -
2;
+
+ //accomodating for the IE measurement difficulties
+ if (Prototype.Browser.IE) {
+ newIndicatorDivHeight -= 4;
+ }
+
+ //if the inidicator div would be too small, let the whole content pane scroll
instead
+ if (newIndicatorDivHeight > 50) {
+ indicatorDiv.style.height = newIndicatorDivHeight + "px";
+ }
+ }
+
+ addWindowOnLoadEvent(maxIndicatorDivHeight);
+ addWindowOnResizeEvent(maxIndicatorDivHeight);
+</script>
+
+</ui:composition>
\ No newline at end of file
diff --git
a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/monitor/measurement/data-plain.xhtml
b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/monitor/measurement/data-plain.xhtml
new file mode 100644
index 0000000..d944499
--- /dev/null
+++
b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/monitor/measurement/data-plain.xhtml
@@ -0,0 +1,197 @@
+<?xml version="1.0"?>
+
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:c="http://java.sun.com/jstl/core"
+
xmlns:rich="http://richfaces.ajax4jsf.org/rich"
+
xmlns:a4j="https://ajax4jsf.dev.java.net/ajax"
+
xmlns:s="http://jboss.com/products/seam/taglib"
+
xmlns:onc="http://jboss.org/on/component"
+
xmlns:onf="http://jboss.org/on/function">
+
+<ui:composition>
+
+<!-- NOTE: rico.js is used for the AJAX stuff below (i.e. the ajaxEngine object).
-->
+<a4j:loadScript src="/js/rico.js"/>
+
+<script language="JavaScript">
+
+ var baseUrl = "/resource/common/monitor/visibility/IndicatorCharts.do";
+ baseUrl += '?';
+ baseUrl += "#{onf:contextFragmentURLForIndicatorsChart()}"
+ baseUrl += '&view=';
+ baseUrl += "#{IndicatorChartsUIBean.view}";
+
+ // Register the remove metric chart method
+ ajaxEngine.registerRequest( 'indicatorCharts', baseUrl );
+
+ function addMetric(token) {
+ ajaxEngine.sendRequest(
+ 'indicatorCharts',
+ 'metric=' + token,
+ 'action=addChart',
+ 'view=' + '#{IndicatorChartsUIBean.view}');
+ }
+
+ function removeMetric(token) {
+ ajaxEngine.sendRequest(
+ 'indicatorCharts',
+ 'metric=' + token,
+ 'action=remove',
+ 'view=' + '#{IndicatorChartsUIBean.view}');
+ new Effect.Fade(token);
+ }
+
+ function moveMetricUp(token) {
+ ajaxEngine.sendRequest(
+ 'indicatorCharts',
+ 'metric=' + token,
+ 'action=moveUp',
+ 'view=' + '#{IndicatorChartsUIBean.view}');
+ var root = $('root');
+ var elem = $(token);
+ moveElementUp(elem, root);
+ }
+
+ function moveMetricDown(token) {
+ ajaxEngine.sendRequest(
+ 'indicatorCharts',
+ 'metric=' + token,
+ 'action=moveDown',
+ 'view=' + '#{IndicatorChartsUIBean.view}');
+
+ var root = $('root');
+ var elem = $(token);
+ moveElementDown(elem, root);
+ }
+
+</script>
+
+<form id="metricViewsForm">
+
+<ul id="root" class="boxy">
+
+<ui:param name="tableBorder" value="0" /> <!-- used for
quick debugging -->
+<ui:param name="context" value="#{IndicatorChartsUIBean.context}"
/>
+<c:forEach var="metric" varStatus="status"
items="#{IndicatorChartsUIBean.data}">
+
+ <li id="#{metric.metricToken}">
+ <table width="100%" border="#{tableBorder}"
cellpadding="0" cellspacing="0">
+ <tr>
+ <td>
+ <rich:panel bodyClass="BlockContent" style="border: 0px;
margin: 0; padding: 0;">
+ <font class="BoldText">
+ <ui:remove>
+ <h:outputLink value="/resource/common/monitor/Visibility.do">
+ <f:param name="m"
value="#{metric.definitionId}"/>
+ <c:choose>
+ <c:when test="#{context.resourceTypeId > 0}">
+ <f:param name="mode"
value="chartSingleMetricMultiResource"/>
+ <f:param name="type"
value="#{context.resourceTypeId}"/>
+ <f:param name="parent"
value="#{context.parentResourceId}"/>
+ </c:when>
+ <c:when test="#{context.groupId > 0}">
+ <f:param name="mode"
value="chartSingleMetricMultiResource"/>
+ <f:param name="groupId"
value="#{context.groupId}"/>
+ </c:when>
+ <c:otherwise>
+ <f:param name="mode"
value="chartSingleMetricSingleResource"/>
+ <f:param name="id"
value="#{context.resourceId}"/>
+ </c:otherwise>
+ </c:choose>
+ <h:outputText value="#{metric.label} " />
+ </h:outputLink>
+ </ui:remove>
+ <h:outputText value="#{metric.label} " />
+
+ <c:choose>
+ <c:when test="#{context.groupId > 0}">
+ <h:outputLink target="_top"
value="/coregui/CoreGUI.html#ResourceGroup/#{metric.groupId}">
+ <h:outputFormat
value="#{msg['common.value.parenthesis']}">
+ <f:param value="#{metric.metricSource}" />
+ </h:outputFormat>
+ </h:outputLink>
+ </c:when>
+ <c:otherwise>
+ <h:outputLink target="_top"
value="/coregui/CoreGUI.html#Resource/#{metric.metricSourceId}">
+ <h:outputFormat
value="#{msg['common.value.parenthesis']}">
+ <f:param value="#{metric.metricSource}" />
+ </h:outputFormat>
+ </h:outputLink>
+ </c:otherwise>
+ </c:choose>
+ </font>
+ <rich:toolTip followMouse="true" showDelay="500">
+ <h:outputText value="#{metric.description}"
rendered="#{not empty metric.description}" />
+ <h:outputText value="No description of this metric
available" rendered="#{empty metric.description}" />
+ </rich:toolTip>
+ </rich:panel>
+ </td>
+
+ <td width="400">
+ <table cellpadding="0" cellspacing="0"
border="#{tableBorder}" width="100%">
+ <tr>
+ <td width="33%" nowrap="nowrap">
+ <h:outputFormat style="font-weight: bold;"
value="#{msg['resource.common.monitor.visibility.LowTH']}" />:
+ <h:outputText value="#{metric.minMetric.valueFmt}"/>
+ </td>
+ <td width="34%" nowrap="nowrap">
+ <h:outputFormat style="font-weight: bold;"
value="#{msg['resource.common.monitor.visibility.AvgTH']}" />:
+ <h:outputText value="#{metric.avgMetric.valueFmt}"/>
+ </td>
+ <td width="33%" nowrap="nowrap">
+ <h:outputFormat style="font-weight: bold;"
value="#{msg['resource.common.monitor.visibility.PeakTH']}" />:
+ <h:outputText value="#{metric.maxMetric.valueFmt}"/>
+ </td>
+ </tr>
+ </table>
+ </td>
+
+ <td width="1">
+ <table cellpadding="0" cellspacing="0"
border="#{tableBorder}" width="100%" style="margin-right:
2px;">
+ <tr>
+ <td width="33%">
+ <a
href="javascript:moveMetricUp('#{metric.metricToken}')">
+ <img src="/images/dash_icon_up.gif"
border="0"/>
+ </a>
+ </td>
+ <td width="33%">
+ <a
href="javascript:moveMetricDown('#{metric.metricToken}')">
+ <img src="/images/dash_icon_down.gif"
border="0"/>
+ </a>
+ </td>
+ <td width="34%">
+ <a
href="javascript:removeMetric('#{metric.metricToken}')">
+ <img src="/images/dash-icon_delete.gif"
border="0"/>
+ </a>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+
+ <tr>
+ <td colspan="3">
+ <h:graphicImage
value="/resource/HighLowChart?#{onf:getChartURLParams(metric)}"
+ width="647" height="100" />
+ </td>
+ </tr>
+ </table>
+
+ </li>
+
+</c:forEach>
+
+</ul>
+
+</form>
+
+</ui:composition>
+
+</html>
\ No newline at end of file
diff --git
a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/group/monitor/graphs-plain.xhtml
b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/group/monitor/graphs-plain.xhtml
index 14f6b68..c2c594f 100644
---
a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/group/monitor/graphs-plain.xhtml
+++
b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/group/monitor/graphs-plain.xhtml
@@ -12,7 +12,7 @@
<ui:define name="content">
- <ui:include src="/rhq/common/monitor/graphs.xhtml" />
+ <ui:include src="/rhq/common/monitor/graphs-plain.xhtml" />
</ui:define>
diff --git
a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/monitor/graphs-plain.xhtml
b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/monitor/graphs-plain.xhtml
new file mode 100644
index 0000000..9aabd00
--- /dev/null
+++
b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/monitor/graphs-plain.xhtml
@@ -0,0 +1,19 @@
+<ui:composition template="/rhq/resource/layout/main-plain.xhtml"
+
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:c="http://java.sun.com/jstl/core"
+
xmlns:onc="http://jboss.org/on/component"
+
xmlns:onf="http://jboss.org/on/function"
+
xmlns:s="http://jboss.com/products/seam/taglib"
+
xmlns:a4j="https://ajax4jsf.dev.java.net/ajax"
+
xmlns:rich="http://richfaces.ajax4jsf.org/rich">
+
+ <ui:define name="content">
+
+ <ui:include src="/rhq/common/monitor/graphs-plain.xhtml" />
+
+ </ui:define>
+
+</ui:composition>
\ No newline at end of file
commit 3cbc6823b6c9592c227b18018bfad6cd75caa927
Merge: e84012c... 6eea739...
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Thu Sep 23 19:23:02 2010 -0400
Merge branch 'master' of ssh://spinder@git.fedorahosted.org/git/rhq/rhq into
track-master
commit e84012cf010751c9eb71439d954f56170c060306
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Thu Sep 23 19:01:52 2010 -0400
various locatable selenium fixes, cleanup refactoring, refresh fix for
InventorySummary portlet.
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java
index 11ce54c..3a09d44 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java
@@ -75,13 +75,26 @@ public class PortletFactory {
// TODO: Note, we're using a sequence generated ID here as a locatorId. This
is not optimal for repeatable
// tests as a change in the number of default portlets, or a change in test order
could make a test
// non-repeatable. But, at the moment we lack the infrastructure to generate a
unique, predictable id.
- Portlet view = viewFactory.getInstance(storedPortlet.getPortletKey() +
"-"
+ Portlet view =
viewFactory.getInstance(replaceSpaces(storedPortlet.getPortletKey()) + "-"
+ Integer.toString(storedPortlet.getId()));
view.configure(portletWindow, storedPortlet);
return view;
}
+ /** Translated spaces to underscore. Spaces not allowed in locator ids.
+ *
+ * @param portletKey
+ * @return
+ */
+ private static String replaceSpaces(String portletKey) {
+ String translated = portletKey;
+ if (portletKey != null) {
+ translated = portletKey.replaceAll(" ", "_");
+ }
+ return translated;
+ }
+
@SuppressWarnings("unchecked")
public static List<String> getRegisteredPortlets() {
@@ -89,4 +102,5 @@ public class PortletFactory {
Collections.sort(portlets);
return portlets;
}
+
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java
index 8159d23..062b882 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java
@@ -18,6 +18,8 @@
*/
package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.queue;
+import static org.rhq.enterprise.gui.coregui.client.util.WidgetsField.UNLIMITED;
+
import com.smartgwt.client.types.VerticalAlignment;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.HTMLFlow;
@@ -37,6 +39,7 @@ import
org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow;
import
org.rhq.enterprise.gui.coregui.client.inventory.resource.discovery.AutodiscoveryQueueDataSource;
import
org.rhq.enterprise.gui.coregui.client.inventory.resource.discovery.ResourceAutodiscoveryView;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
/**
@@ -44,12 +47,14 @@ import
org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
*/
public class AutodiscoveryPortlet extends ResourceAutodiscoveryView implements
CustomSettingsPortlet {
+ //ui attributes/properties/indentifiers
public static final String KEY = "Discovery Queue";
private static final String AUTODISCOVERY_PLATFORM_MAX =
"auto-discovery-platform-max";
- private String unlimited = "unlimited";
+ private String unlimited = UNLIMITED.propertyName();
private String defaultValue = unlimited;
+ //portlet settings and datasource elements
private DashboardPortlet storedPortlet;
- private int maximumPlatformsToDisplay = -1;
+ private AutodiscoveryQueueDataSource dataSource;
public AutodiscoveryPortlet(String locatorId) {
super(locatorId, true);
@@ -59,26 +64,35 @@ public class AutodiscoveryPortlet extends ResourceAutodiscoveryView
implements C
protected void onInit() {
super.onInit();
//initialize the datasource to include Portlet instance
- if (getTreeGrid() != null) {
- getTreeGrid().setDataSource(new AutodiscoveryQueueDataSource(this));
+ this.dataSource = new AutodiscoveryQueueDataSource();
+ if ((getTreeGrid() != null) && (getDataSource() != null)) {
+ getTreeGrid().setDataSource(getDataSource());
}
}
- /** Implement configure action.
+ /** Implements configure action. Stores reference to the initiating
DashboardPortlet.
+ * Method loads i)initial portlet settings OR ii)retrieves previous settings and adds
to
+ * the datasource.
*/
@Override
public void configure(PortletWindow portletWindow, DashboardPortlet storedPortlet) {
this.storedPortlet = storedPortlet;
+ String retrieved = null;
+ //if settings already exist for this portlet
if (storedPortlet.getConfiguration().getSimple(AUTODISCOVERY_PLATFORM_MAX) !=
null) {
//retrieve and translate to int
- String retrieved =
storedPortlet.getConfiguration().getSimple(AUTODISCOVERY_PLATFORM_MAX).getStringValue();
+ retrieved =
storedPortlet.getConfiguration().getSimple(AUTODISCOVERY_PLATFORM_MAX).getStringValue();
+ } else {//create setting
+ storedPortlet.getConfiguration().put(new
PropertySimple(AUTODISCOVERY_PLATFORM_MAX, defaultValue));
+ retrieved = defaultValue;
+ }
+
+ if (getDataSource() != null) {
if (retrieved.equals(unlimited)) {
- setMaximumPlatformsToDisplay(-1);
+ getDataSource().setMaximumPlatformsToDisplay(-1);
} else {
- setMaximumPlatformsToDisplay(Integer.parseInt(retrieved));
+
getDataSource().setMaximumPlatformsToDisplay(Integer.parseInt(retrieved));
}
- } else {//create setting
- storedPortlet.getConfiguration().put(new
PropertySimple(AUTODISCOVERY_PLATFORM_MAX, defaultValue));
}
}
@@ -91,29 +105,28 @@ public class AutodiscoveryPortlet extends ResourceAutodiscoveryView
implements C
*
*/
public DynamicForm getCustomSettingsForm() {
-
- final DynamicForm form = new DynamicForm();
+ final LocatableDynamicForm form = new
LocatableDynamicForm(extendLocatorId("Settings"));
form.setLayoutAlign(VerticalAlignment.CENTER);
//horizontal display component
- LocatableHLayout row = new
LocatableHLayout("auto-discovery.configuration");
- BlurbItem label = new BlurbItem("discovery-platform-count-label");
+ LocatableHLayout row = new
LocatableHLayout(extendLocatorId("auto-discovery.configuration"));
+ BlurbItem label = new
BlurbItem(form.extendLocatorId("discovery-platform-count-label"));
label.setValue("Number of platforms to display");
+ label.setWrap(false);
//-------------combobox for number of platforms to display on the dashboard
- final SelectItem maximumPlatformsComboBox = new
SelectItem(AUTODISCOVERY_PLATFORM_MAX);
- maximumPlatformsComboBox.setTitle("");
+ final SelectItem maximumPlatformsComboBox = new
SelectItem(form.extendLocatorId(AUTODISCOVERY_PLATFORM_MAX), "");
//spinder 9/3/10: the following is required workaround to disable editability of
combobox.
maximumPlatformsComboBox.setType("selection");
//define acceptable values for display amount
- String[] acceptableDisplayValues = { "1", "2", "5",
"10", unlimited };
- maximumPlatformsComboBox.setValueMap(acceptableDisplayValues);
+ String[] displayValues = { "1", "2", "5",
"10", unlimited };
+ maximumPlatformsComboBox.setValueMap(displayValues);
//set width of dropdown display region
maximumPlatformsComboBox.setWidth(100);
maximumPlatformsComboBox.addChangeHandler(new ChangeHandler() {
public void onChange(ChangeEvent event) {
String selectedItem = "" + event.getValue();
- //stuff into the master form for retrieval
+ //store in master form for retrieval
form.setValue(AUTODISCOVERY_PLATFORM_MAX, selectedItem);
}
});
@@ -129,12 +142,11 @@ public class AutodiscoveryPortlet extends ResourceAutodiscoveryView
implements C
//default selected value to 'unlimited'(live lists) and check both
combobox settings here.
String selectedValue = defaultValue;
- if (storedPortlet != null) {
- //if property exists retrieve it
- if (storedPortlet.getConfiguration().getSimple(AUTODISCOVERY_PLATFORM_MAX) !=
null) {
- selectedValue =
storedPortlet.getConfiguration().getSimple(AUTODISCOVERY_PLATFORM_MAX).getStringValue();
- } else {//insert default value
- storedPortlet.getConfiguration().put(new
PropertySimple(AUTODISCOVERY_PLATFORM_MAX, defaultValue));
+ if (getDataSource() != null) {
+ if (getDataSource().getMaximumPlatformsToDisplay() == -1) {
+ selectedValue = unlimited;
+ } else {
+ selectedValue =
String.valueOf(getDataSource().getMaximumPlatformsToDisplay());
}
}
//prepopulate the combobox with the previously stored selection
@@ -144,9 +156,10 @@ public class AutodiscoveryPortlet extends ResourceAutodiscoveryView
implements C
//submit handler
form.addSubmitValuesHandler(new SubmitValuesHandler() {
- @Override
+ //specify submit action.
public void onSubmitValues(SubmitValuesEvent event) {
if (form.getValue(AUTODISCOVERY_PLATFORM_MAX) != null) {
+ //persist this value to configuration
storedPortlet.getConfiguration().put(
new PropertySimple(AUTODISCOVERY_PLATFORM_MAX,
form.getValue(AUTODISCOVERY_PLATFORM_MAX)));
}
@@ -164,11 +177,7 @@ public class AutodiscoveryPortlet extends ResourceAutodiscoveryView
implements C
}
}
- public int getMaximumPlatformsToDisplay() {
- return maximumPlatformsToDisplay;
- }
-
- public void setMaximumPlatformsToDisplay(int maximumPlatformsToDisplay) {
- this.maximumPlatformsToDisplay = maximumPlatformsToDisplay;
+ public AutodiscoveryQueueDataSource getDataSource() {
+ return dataSource;
}
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/RecentAlertsPortlet.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/RecentAlertsPortlet.java
index f318cf4..18d262c 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/RecentAlertsPortlet.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/RecentAlertsPortlet.java
@@ -36,7 +36,6 @@ import com.smartgwt.client.widgets.form.fields.events.ChangeHandler;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.events.DataArrivedEvent;
import com.smartgwt.client.widgets.grid.events.DataArrivedHandler;
-import com.smartgwt.client.widgets.layout.HLayout;
import com.smartgwt.client.widgets.layout.VLayout;
import org.rhq.core.domain.alert.AlertPriority;
@@ -50,9 +49,9 @@ import
org.rhq.enterprise.gui.coregui.client.dashboard.CustomSettingsPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow;
-import org.rhq.enterprise.gui.coregui.client.inventory.groups.wizard.GroupMembersStep;
import
org.rhq.enterprise.gui.coregui.client.inventory.resource.selection.ResourceSelector;
import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableLabel;
@@ -98,8 +97,9 @@ public class RecentAlertsPortlet extends AlertsView implements
CustomSettingsPor
private AlertResourceSelectorRegion resourceSelector;
private DashboardPortlet storedPortlet = null;
private AlertPortletDataSource dataSource;
+ //instance ui widgets
private Canvas containerCanvas;
- private HLayout resourceSelectionLabelRow;
+ private LocatableHLayout resourceSelectionLabelRow;
public RecentAlertsPortlet(String locatorId) {
this(locatorId, null, null);
@@ -264,7 +264,7 @@ public class RecentAlertsPortlet extends AlertsView implements
CustomSettingsPor
public DynamicForm getCustomSettingsForm() {
//root dynamic form instance
- final DynamicForm form = new DynamicForm();
+ final LocatableDynamicForm form = new
LocatableDynamicForm(extendLocatorId("custom-settings"));
form.setWidth(RecentAlertsPortlet.ALERT_RESOURCE_SELECTION_WIDTH + 40);//largest
widget display + 40 for buttons
form.setHeight(450);
form.setMargin(5);
@@ -276,7 +276,7 @@ public class RecentAlertsPortlet extends AlertsView implements
CustomSettingsPor
LocatableLabel alertRangeLabel = new
LocatableLabel("DynamicForm_Label_Alert_Range", "<b>Alert
Range</b>");
//horizontal layout
- LocatableHLayout row = new
LocatableHLayout("alert-range-settings-row-1");
+ LocatableHLayout row = new
LocatableHLayout(extendLocatorId("alert-range-settings-row-1"));
row.setMembersMargin(10);
//-------------combobox for number of completed scheduled ops to display on the
dashboard
@@ -352,9 +352,10 @@ public class RecentAlertsPortlet extends AlertsView implements
CustomSettingsPor
row.addMember(wrappedPriority);
//horizontal layout
- LocatableHLayout row2 = new
LocatableHLayout("alert-range-settings-row-2");
+ LocatableHLayout row2 = new
LocatableHLayout(extendLocatorId("alert-range-settings-row-2"));
- Label alertRangeSpanLabel = new Label("<b>within the
past<b>");
+ LocatableLabel alertRangeSpanLabel = new
LocatableLabel(extendLocatorId("range-span-label"),
+ "<b>within the past<b>");
//------------- Build second combobox for timeframe for problem resources
search.
final SelectItem alertRangeTimeComboBox = new
SelectItem(ALERT_RANGE_TIME_VALUE);
alertRangeTimeComboBox.setTitle("");
@@ -444,49 +445,53 @@ public class RecentAlertsPortlet extends AlertsView implements
CustomSettingsPor
row2.addMember(resourceSelectionWrapper);
//Row 3 of labels for the alert selected resources area
- resourceSelectionLabelRow = new HLayout();
+ resourceSelectionLabelRow = new
LocatableHLayout(extendLocatorId("resource-selection-label"));
resourceSelectionLabelRow.setHeight(30);
resourceSelectionLabelRow.setMembersMargin(5);
resourceSelectionLabelRow.setWidth(RecentAlertsPortlet.ALERT_RESOURCE_SELECTION_WIDTH);//ui
size + fixed button widths
- Label availableResourcesLabel = new Label("<b>" +
ALERT_LABEL_AVAILABLE_RESOURCES + "</b>");
+ LocatableLabel availableResourcesLabel = new
LocatableLabel(extendLocatorId("available-resources"), "<b>"
+ + ALERT_LABEL_AVAILABLE_RESOURCES + "</b>");
availableResourcesLabel.setHeight(20);
availableResourcesLabel.setWrap(false);
resourceSelectionLabelRow.addMember(availableResourcesLabel);
Label spacer = new Label("");
spacer.setWidth(400);
- Label selectedResourcesLabel = new Label("<b>" +
ALERT_LABEL_SELECTED_RESOURCES + "</b>");
+ LocatableLabel selectedResourcesLabel = new
LocatableLabel(extendLocatorId("selected-resources"), "<b>"
+ + ALERT_LABEL_SELECTED_RESOURCES + "</b>");
selectedResourcesLabel.setHeight(20);
selectedResourcesLabel.setWrap(false);
resourceSelectionLabelRow.addMember(spacer);
resourceSelectionLabelRow.addMember(selectedResourcesLabel);
- //##### if portlet config setting exist, then retrieve#############
+ //if portlet config setting exist, then retrieve
Integer[] alertFilterResourceIds = null;
alertFilterResourceIds = getDataSource().extractFilterResourceIds(storedPortlet,
alertFilterResourceIds);
if (alertFilterResourceIds != null) {
getDataSource().setAlertFilterResourceId(alertFilterResourceIds);
}
- HLayout row4 = new HLayout();
- row4.setID("row4");
- // resourceSelector = new MemberSelect();
+ LocatableHLayout resourceSelectionRegion = new
LocatableHLayout(extendLocatorId("selection-canvas"));
resourceSelector = new AlertResourceSelectorRegion(alertFilterResourceIds);
- row4.setWidth100();
+ resourceSelectionRegion.setWidth100();
+
+ //instantiate canvas area to display empty or rich resource selection based on
dropdown selection
containerCanvas = new Canvas();
- String retProp =
storedPortlet.getConfiguration().getSimple(ALERT_RANGE_RESOURCES_VALUE).getStringValue();
+ String previousAlertFilterChoice =
storedPortlet.getConfiguration().getSimple(ALERT_RANGE_RESOURCES_VALUE)
+ .getStringValue();
//reload the ResourceSelectionRegion if user has chosen to focus on specific
resources with alerts
- if (retProp.equals(RESOURCES_SELECTED)) {
+ if (previousAlertFilterChoice.equals(RESOURCES_SELECTED)) {
containerCanvas.addChild(resourceSelector.getCanvas());
- } else {
+ } else {// define empty canvas
containerCanvas.addChild(new Canvas());
//iterate over children of row3 and make invisible
for (Canvas c : resourceSelectionLabelRow.getMembers()) {
c.setVisible(false);
}
}
+
//add contain resource selection region.
- row4.addMember(containerCanvas);
+ resourceSelectionRegion.addMember(containerCanvas);
//finish construction of the layout
column.addMember(row);
@@ -497,7 +502,7 @@ public class RecentAlertsPortlet extends AlertsView implements
CustomSettingsPor
spacerWrapper.setItems(verticalSpace);
column.addMember(spacerWrapper);
column.addMember(resourceSelectionLabelRow);
- column.addMember(row4);
+ column.addMember(resourceSelectionRegion);
form.addChild(column);
//submit handler
@@ -525,7 +530,7 @@ public class RecentAlertsPortlet extends AlertsView implements
CustomSettingsPor
storedPortlet.getConfiguration().put(new
PropertyList(ALERT_RANGE_RESOURCE_IDS, list));
getDataSource().setAlertFilterResourceId(resourceSelector.getCurrentlyAssignedIds());
}
- refresh();//
+ refresh();//reload form with new data selections
markForRedraw();
}
});
@@ -564,25 +569,13 @@ public class RecentAlertsPortlet extends AlertsView implements
CustomSettingsPor
}
}
-class CustomizedResourceSelector extends ResourceSelector {
- public CustomizedResourceSelector(String locatorId) {
- super(locatorId);
- }
-
- public CustomizedResourceSelector(String locatorId, ResourceType rtFilter, boolean
forceRtFilter) {
- super(locatorId, rtFilter, forceRtFilter);
- }
+/** Bundles a ResourceSelector instance with labelling in Canvas for display.
+ * Also modifies the AssignedGrid to listen for AvailbleGrid completion and act
accordingly.
+ */
+class AlertResourceSelectorRegion {
- public void addAvailableGridSelectionsToAssignedGrid() {
- assignedGrid.transferSelectedData(availableGrid);
- select(assignedGrid.getSelection());
- updateButtons();
- }
-}
+ private ResourceSelector selector = null;
-class AlertResourceSelectorRegion extends GroupMembersStep {
- // private ResourceSelector selector = null;
- private CustomizedResourceSelector selector = null;
private Integer[] currentlyAssignedIds;
public Integer[] getCurrentlyAssignedIds() {
@@ -605,20 +598,20 @@ class AlertResourceSelectorRegion extends GroupMembersStep {
}
public AlertResourceSelectorRegion(Integer[] assigned) {
- super(null);
this.currentlyAssignedIds = assigned;
}
public Canvas getCanvas() {
if (selector == null) {
- // selector = new ResourceSelector(getName());
- selector = new CustomizedResourceSelector(getName(),
ResourceType.ANY_PLATFORM_TYPE, true);
+ selector = new ResourceSelector("Select Members",
ResourceType.ANY_PLATFORM_TYPE, true);
selector.setWidth100();
selector.setWidth(RecentAlertsPortlet.ALERT_RESOURCE_SELECTION_WIDTH);
//widget ui updates
selector.getAvailableGrid().setTitle("Available Resources");
selector.getAvailableGrid().setEmptyMessage("Loading data...");
selector.getAssignedGrid().setTitle("Selected Resources");
+ //disable display typeFilter.
+ selector.setDisplayResourceTypeFilter(false);
//populate fields for grid.
ListGridField nameField = new ListGridField("name",
"Name");
@@ -634,12 +627,14 @@ class AlertResourceSelectorRegion extends GroupMembersStep {
if ((getCurrentlyAssignedIds() != null) &&
(getCurrentlyAssignedIds().length > 0)) {
//retrieve the loaded data and add to the table itself
RecordList recordList =
selector.getAvailableGrid().getDataAsRecordList();
+ //for each of the resource ids loaded from settings, select that
row for transfer.
for (int ci : getCurrentlyAssignedIds()) {
int located = recordList.findIndex("id", ci);
if (located > -1) {
selector.getAvailableGrid().selectRecord(located);
}
}
+ //simulate 'add' button push.
selector.addAvailableGridSelectionsToAssignedGrid();
selector.getAssignedGrid().invalidateCache();
selector.getAssignedGrid().markForRedraw();
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java
index 54647a1..2484d63 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java
@@ -21,7 +21,6 @@ package
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.operatio
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.HTMLFlow;
-import com.smartgwt.client.widgets.Label;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.events.SubmitValuesEvent;
import com.smartgwt.client.widgets.form.events.SubmitValuesHandler;
@@ -43,7 +42,9 @@ import
org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow;
import org.rhq.enterprise.gui.coregui.client.operation.RecentOperationsDataSource;
import org.rhq.enterprise.gui.coregui.client.operation.ScheduledOperationsDataSource;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableLabel;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableListGrid;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
@@ -193,17 +194,17 @@ public class OperationsPortlet extends LocatableVLayout implements
CustomSetting
public DynamicForm getCustomSettingsForm() {
//root dynamic form instance
- final DynamicForm form = new DynamicForm();
+ final LocatableDynamicForm form = new
LocatableDynamicForm("custom-settings");
//vertical layout
VStack column = new VStack();
//label
- Label operationRange = new Label("Operation Range");
+ LocatableLabel operationRange = new
LocatableLabel(extendLocatorId("operation-range"), "Operation
Range");
column.addMember(operationRange);
//horizontal layout
- LocatableHLayout row = new
LocatableHLayout("enable.completed.operations");
+ LocatableHLayout row = new
LocatableHLayout(extendLocatorId("enable.completed.operations"));
//checkbox indicating whether to apply completed operations grouping settings
final CheckboxItem enableCompletedOperationsGrouping = new CheckboxItem();
@@ -266,7 +267,7 @@ public class OperationsPortlet extends LocatableVLayout implements
CustomSetting
row.addMember(item2);
//horizontal layout
- LocatableHLayout row2 = new
LocatableHLayout("enable.scheduled.operations");
+ LocatableHLayout sheduledOperationsLayout = new
LocatableHLayout(extendLocatorId("enable.scheduled.operations"));
final CheckboxItem enableScheduledOperationsGrouping = new CheckboxItem();
enableScheduledOperationsGrouping.setName(OPERATIONS_RANGE_SCHEDULED_ENABLED);
@@ -282,7 +283,7 @@ public class OperationsPortlet extends LocatableVLayout implements
CustomSetting
//wrap field item in dynamicform for addition
DynamicForm fieldWrapper = new DynamicForm();
fieldWrapper.setFields(enableScheduledOperationsGrouping);
- row2.addMember(fieldWrapper);
+ sheduledOperationsLayout.addMember(fieldWrapper);
//retrieve previous value otherwise initialize to true(live unlimited list)
retrieved =
storedPortlet.getConfiguration().getSimple(OPERATIONS_RANGE_SCHEDULED_ENABLED);
@@ -321,9 +322,9 @@ public class OperationsPortlet extends LocatableVLayout implements
CustomSetting
maximumScheduledOperationsComboBox.setDefaultValue(selectedValue);
DynamicForm fieldWrapper2 = new DynamicForm();
fieldWrapper2.setFields(maximumScheduledOperationsComboBox);
- row2.addMember(fieldWrapper2);
+ sheduledOperationsLayout.addMember(fieldWrapper2);
column.addMember(row);
- column.addMember(row2);
+ column.addMember(sheduledOperationsLayout);
form.addChild(column);
//submit handler
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java
index 2778c59..d233d5b 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java
@@ -26,7 +26,6 @@ import java.util.List;
import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.HTMLFlow;
-import com.smartgwt.client.widgets.Label;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.events.SubmitValuesEvent;
import com.smartgwt.client.widgets.form.events.SubmitValuesHandler;
@@ -46,7 +45,9 @@ import
org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow;
import org.rhq.enterprise.gui.coregui.client.resource.ProblemResourcesDataSource;
import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableLabel;
/**
* A view that displays a paginated table of Resources with alerts,
@@ -157,7 +158,7 @@ public class ProblemResourcesPortlet extends Table implements
CustomSettingsPort
*/
public DynamicForm getCustomSettingsForm() {
- final DynamicForm form = new DynamicForm();
+ final LocatableDynamicForm form = new
LocatableDynamicForm(extendLocatorId("custom-settings"));
//-------------combobox for number of resource to display on the dashboard
final SelectItem maximumProblemResourcesComboBox = new
SelectItem(PROBLEM_RESOURCE_SHOW_MAX);
@@ -289,7 +290,7 @@ public class ProblemResourcesPortlet extends Table implements
CustomSettingsPort
* @author spinder
*/
class TimeRange extends LocatableHLayout implements TableWidget {
- private Label label = new Label();
+ private LocatableLabel label = new
LocatableLabel(extendLocatorId("time-range-label"));
private ProblemResourcesPortlet portlet = null;
public TimeRange(String locatorId, ProblemResourcesPortlet problemResourcesPortlet)
{
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/summary/InventorySummaryView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/summary/InventorySummaryView.java
index 859a7d5..361a1f7 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/summary/InventorySummaryView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/summary/InventorySummaryView.java
@@ -45,25 +45,30 @@ import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.gwt.ResourceBossGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.InventoryView;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
public class InventorySummaryView extends LocatableVLayout implements Portlet {
private ResourceBossGWTServiceAsync resourceBossService =
GWTServiceLookup.getResourceBossService();
- private DynamicForm form;
+ private LocatableDynamicForm form;
public static final String KEY = "Summary Counts";
public InventorySummaryView(String locatorId) {
super(locatorId);
+ loadInventoryViewDiata();
+ }
+
+ private void loadInventoryViewDiata() {
resourceBossService.getInventorySummaryForLoggedInUser(new
AsyncCallback<InventorySummary>() {
public void onFailure(Throwable throwable) {
CoreGUI.getErrorHandler().handleError("Failed to retrieve inventory
summary", throwable);
}
public void onSuccess(InventorySummary summary) {
- form = new DynamicForm();
+ form = new LocatableDynamicForm("Portlet_Inventory_Summary");
List<FormItem> formItems = new ArrayList<FormItem>();
// HeaderItem headerItem = new
HeaderItem("header");
@@ -131,6 +136,17 @@ public class InventorySummaryView extends LocatableVLayout implements
Portlet {
return null; // TODO: Implement this method.
}
+ /** Custom refresh operation as we are not directly extending Table
+ */
+ @Override
+ public void redraw() {
+ super.redraw();
+ //destroy form
+ form.destroy();
+ //now reload the data
+ loadInventoryViewDiata();
+ }
+
public static final class Factory implements PortletViewFactory {
public static PortletViewFactory INSTANCE = new Factory();
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/AutodiscoveryQueueDataSource.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/AutodiscoveryQueueDataSource.java
index 63ed782..a881444 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/AutodiscoveryQueueDataSource.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/AutodiscoveryQueueDataSource.java
@@ -39,8 +39,6 @@ import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageOrdering;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
-import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
-import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.queue.AutodiscoveryPortlet;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGWTServiceAsync;
@@ -49,15 +47,10 @@ import
org.rhq.enterprise.gui.coregui.client.gwt.ResourceGWTServiceAsync;
*/
public class AutodiscoveryQueueDataSource extends DataSource {
- private Portlet portlet = null;
private int unlimited = -1;
+ private int maximumPlatformsToDisplay = -1;
private ResourceGWTServiceAsync resourceService =
GWTServiceLookup.getResourceService();
- public AutodiscoveryQueueDataSource(Portlet portlet) {
- this();
- this.portlet = portlet;
- }
-
public AutodiscoveryQueueDataSource() {
setClientOnly(false);
setDataProtocol(DSProtocol.CLIENTCUSTOM);
@@ -159,10 +152,8 @@ public class AutodiscoveryQueueDataSource extends DataSource {
protected PageControl getPageControl(DSRequest request) {
// Initialize paging.
PageControl pageControl;
- //retrieve portlet.configurationInformation
- if ((this.portlet != null) || (this.portlet instanceof AutodiscoveryPortlet))
{//using default
- AutodiscoveryPortlet settings = (AutodiscoveryPortlet) this.portlet;
- pageControl = new PageControl(0, settings.getMaximumPlatformsToDisplay());
+ if (getMaximumPlatformsToDisplay() > -1) {//using default
+ pageControl = new PageControl(0, getMaximumPlatformsToDisplay());
} else {
pageControl = new PageControl(0, unlimited);
}
@@ -221,4 +212,13 @@ public class AutodiscoveryQueueDataSource extends DataSource {
return getAttribute("parentId");
}
}
+
+ public int getMaximumPlatformsToDisplay() {
+ return maximumPlatformsToDisplay;
+ }
+
+ public void setMaximumPlatformsToDisplay(int maximumPlatformsToDisplay) {
+ this.maximumPlatformsToDisplay = maximumPlatformsToDisplay;
+ }
+
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceSelector.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceSelector.java
index 0047b1f..432ca27 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceSelector.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceSelector.java
@@ -49,6 +49,7 @@ public class ResourceSelector extends AbstractSelector<Resource>
{
private ResourceType resourceTypeFilter;
private boolean forceResourceTypeFilter;
+ private boolean displayResourceTypeFilter = true;
private IPickTreeItem typeSelectItem;
public ResourceSelector(String locatorId) {
@@ -80,6 +81,9 @@ public class ResourceSelector extends AbstractSelector<Resource>
{
if (this.forceResourceTypeFilter) {
typeSelectItem.setDisabled(true);
}
+ if (!isDisplayResourceTypeFilter()) {
+ typeSelectItem.setVisible(false);
+ }
categorySelect = new SelectItem("category", "Category");
categorySelect.setValueMap("Platform", "Server",
"Service");
@@ -126,6 +130,14 @@ public class ResourceSelector extends
AbstractSelector<Resource> {
return criteria;
}
+ /** transfers selected data to the assigned grid. This operation mimics button click
from ResourceSelection.
+ */
+ public void addAvailableGridSelectionsToAssignedGrid() {
+ assignedGrid.transferSelectedData(availableGrid);
+ select(assignedGrid.getSelection());
+ updateButtons();
+ }
+
// protected Criteria getLatestCriteria(DynamicForm availableFilterForm) {
// String search = (String) availableFilterForm.getValue("search");
// String type = availableFilterForm.getValueAsString("type");
@@ -183,4 +195,12 @@ public class ResourceSelector extends
AbstractSelector<Resource> {
}
}
+
+ public boolean isDisplayResourceTypeFilter() {
+ return displayResourceTypeFilter;
+ }
+
+ public void setDisplayResourceTypeFilter(boolean displayResourceTypeFilter) {
+ this.displayResourceTypeFilter = displayResourceTypeFilter;
+ }
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java
index 2c02f25..863afe2 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java
@@ -48,6 +48,7 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
*/
public class RecentOperationsDataSource extends
RPCDataSource<DisambiguationReport<ResourceOperationLastCompletedComposite>>
{
+ //ui keys
public static final String resource = "resource";
public static final String location = "location";
public static final String operation = "operation";
@@ -58,7 +59,6 @@ public class RecentOperationsDataSource extends
//config attributes
private boolean operationsRangeLastEnabled = false;
private int operationsRangeCompleted = -1;
- private boolean dataRangeDisabled = true;
public static String RANGE_DISABLED_MESSAGE = "(Results currently disabled.
Change settings to enable results.)";
/** Build list of fields for the datasource and then adds them to it.
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/WidgetsField.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/WidgetsField.java
new file mode 100644
index 0000000..ba8413a
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/WidgetsField.java
@@ -0,0 +1,63 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.rhq.enterprise.gui.coregui.client.util;
+
+public enum WidgetsField {
+
+ UNLIMITED("unlimited", "Unlimited");
+
+ // DESCRIPTION("description", "Description"),
+ //
+ // TYPE("resourceType.name", "Type"),
+ //
+ // PLUGIN("pluginName", "Plugin"),
+ //
+ // CATEGORY("resourceType.category", "Category"),
+ //
+ // AVAILABILITY("currentAvailability", "Availability");
+
+ /**
+ * Corresponds to a property name of Resource
+ */
+ private String propertyName;
+
+ /**
+ * The display name for the field or property
+ */
+ private String title;
+
+ private WidgetsField(String propertyName, String title) {
+ this.propertyName = propertyName;
+ this.title = title;
+ }
+
+ public String propertyName() {
+ return propertyName;
+ }
+
+ public String title() {
+ return title;
+ }
+
+}
commit 6eea739a198db967a5bb26567b0133b77b363466
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Sep 23 12:15:32 2010 -0400
finish the dampening editor
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/DampeningAlertDefinitionForm.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/DampeningAlertDefinitionForm.java
index 87eecea..1942004 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/DampeningAlertDefinitionForm.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/DampeningAlertDefinitionForm.java
@@ -30,6 +30,8 @@ import com.smartgwt.client.widgets.form.fields.SpinnerItem;
import com.smartgwt.client.widgets.form.fields.StaticTextItem;
import com.smartgwt.client.widgets.form.fields.events.ChangedEvent;
import com.smartgwt.client.widgets.form.fields.events.ChangedHandler;
+import com.smartgwt.client.widgets.form.fields.events.ItemHoverEvent;
+import com.smartgwt.client.widgets.form.fields.events.ItemHoverHandler;
import org.rhq.core.domain.alert.AlertDampening;
import org.rhq.core.domain.alert.AlertDefinition;
@@ -109,10 +111,12 @@ public class DampeningAlertDefinitionForm extends
LocatableDynamicForm implement
alertDefinition.setAlertDampening(alertDampening);
}
- dampeningRuleSelection.setValue(alertDampening.getCategory().name());
-
dampeningRuleStatic.setValue(getCategoryTitle(alertDampening.getCategory()));
+ Category category = alertDampening.getCategory();
+ dampeningRuleSelection.setValue(category.name());
+ dampeningRuleStatic.setValue(getCategoryTitle(category));
+ dampeningRuleStatic.setTooltip(getCategoryHelp(category.name()));
- switch (alertDampening.getCategory()) {
+ switch (category) {
case NONE: {
break;
}
@@ -141,8 +145,7 @@ public class DampeningAlertDefinitionForm extends LocatableDynamicForm
implement
break;
}
default: {
- throw new IllegalStateException("Invalid category - please report
this as a bug: "
- + alertDampening.getCategory()); // should never happen
+ throw new IllegalStateException("Invalid category - please report
this as a bug: " + category); // should never happen
}
}
}
@@ -380,8 +383,6 @@ public class DampeningAlertDefinitionForm extends LocatableDynamicForm
implement
private void buildForm() {
if (!formBuilt) {
- setNumCols(3);
-
dampeningRuleSelection = new SelectItem("dampeningRule",
"Dampening Rule");
LinkedHashMap<String, String> rules = new LinkedHashMap<String,
String>(4);
rules.put(AlertDampening.Category.NONE.name(),
getCategoryTitle(AlertDampening.Category.NONE));
@@ -395,79 +396,86 @@ public class DampeningAlertDefinitionForm extends
LocatableDynamicForm implement
dampeningRuleSelection.setDefaultValue(AlertDampening.Category.NONE.name());
dampeningRuleSelection.setWrapTitle(false);
dampeningRuleSelection.setRedrawOnChange(true);
- dampeningRuleSelection.setColSpan(2);
+ dampeningRuleSelection.setHoverWidth(300);
+ dampeningRuleSelection.addItemHoverHandler(new ItemHoverHandler() {
+ @Override
+ public void onItemHover(ItemHoverEvent event) {
+ String selection = dampeningRuleSelection.getValue().toString();
+ dampeningRuleSelection.setTooltip(getCategoryHelp(selection));
+ }
+ });
+
dampeningRuleStatic = new StaticTextItem("dampeningRuleStatic",
"Dampening Rule");
- dampeningRuleStatic.setColSpan(2);
dampeningRuleStatic.setWrapTitle(false);
+ dampeningRuleStatic.setHoverWidth(300);
// NONE
// nothing to do - the none category has no ui components to render
// CONSECUTIVE_COUNT
consecutiveOccurrencesSpinner = new
SpinnerItem("consecutiveOccurrencesSpinner", "Occurrences");
- consecutiveOccurrencesSpinner.setColSpan(2);
consecutiveOccurrencesSpinner.setWrapTitle(false);
consecutiveOccurrencesSpinner.setMin(1);
consecutiveOccurrencesSpinner.setMax(999999);
consecutiveOccurrencesSpinner.setStep(1);
consecutiveOccurrencesSpinner.setDefaultValue(1);
+ consecutiveOccurrencesSpinner.setHoverWidth(300);
consecutiveOccurrencesSpinner
.setTooltip("The number of times the condition set must be
consecutively true before the alert is triggered.");
consecutiveOccurrencesStatic = new
StaticTextItem("consecutiveOccurrencesStatic", "Occurrences");
- consecutiveOccurrencesStatic.setColSpan(2);
consecutiveOccurrencesStatic.setWrapTitle(false);
// PARTIAL_COUNT
partialOccurrencesSpinner = new
SpinnerItem("partialOccurrencesSpinner", "Occurrences");
- partialOccurrencesSpinner.setColSpan(2);
partialOccurrencesSpinner.setWrapTitle(false);
partialOccurrencesSpinner.setMin(1);
partialOccurrencesSpinner.setMax(999999);
partialOccurrencesSpinner.setStep(1);
partialOccurrencesSpinner.setDefaultValue(1);
+ partialOccurrencesSpinner.setHoverWidth(300);
partialOccurrencesSpinner
.setTooltip("The number of times the condition set must be true
during the last N evaluations before the alert is triggered.");
partialOccurrencesStatic = new
StaticTextItem("partialOccurrencesStatic", "Occurrences");
- partialOccurrencesStatic.setColSpan(2);
partialOccurrencesStatic.setWrapTitle(false);
partialEvaluationsSpinner = new
SpinnerItem("partialEvaluationsSpinner", "Evaluations");
- partialEvaluationsSpinner.setColSpan(2);
partialEvaluationsSpinner.setWrapTitle(false);
partialEvaluationsSpinner.setMin(1);
partialEvaluationsSpinner.setMax(999999);
partialEvaluationsSpinner.setStep(1);
partialEvaluationsSpinner.setDefaultValue(1);
+ partialEvaluationsSpinner.setHoverWidth(300);
+ partialEvaluationsSpinner
+ .setTooltip("The total number of times the condition set will be
tested to see if the given number of occurrences are true.");
partialEvaluationsStatic = new
StaticTextItem("partialEvaluationStatic", "Evaluations");
- partialEvaluationsStatic.setColSpan(2);
partialEvaluationsStatic.setWrapTitle(false);
// DURATION_COUNT
durationOccurrencesSpinner = new
SpinnerItem("durationOccurrencesSpinner", "Occurrences");
- durationOccurrencesSpinner.setColSpan(2);
durationOccurrencesSpinner.setWrapTitle(false);
durationOccurrencesSpinner.setMin(1);
durationOccurrencesSpinner.setMax(999999);
durationOccurrencesSpinner.setStep(1);
durationOccurrencesSpinner.setDefaultValue(1);
+ durationOccurrencesSpinner.setHoverWidth(300);
durationOccurrencesSpinner
.setTooltip("The number of times the condition set must be true
during the given time period before the alert is triggered.");
durationOccurrencesStatic = new
StaticTextItem("durationOccurrencesStatic", "Occurrences");
- durationOccurrencesStatic.setColSpan(2);
durationOccurrencesStatic.setWrapTitle(false);
durationTimePeriodSpinner = new
SpinnerItem("durationTimePeriodSpinner", "Time Period");
- durationTimePeriodSpinner.setEndRow(false);
durationTimePeriodSpinner.setWrapTitle(false);
durationTimePeriodSpinner.setMin(1);
durationTimePeriodSpinner.setMax(999999);
durationTimePeriodSpinner.setStep(1);
durationTimePeriodSpinner.setDefaultValue(1);
+ durationTimePeriodSpinner.setHoverWidth(300);
+ durationTimePeriodSpinner
+ .setTooltip("The time span in which the condition set will be tested
to see if the given number of occurrences are true.");
durationTimePeriodStatic = new
StaticTextItem("durationTimePeriodStatic", "Time Period");
- durationTimePeriodStatic.setEndRow(false);
durationTimePeriodStatic.setWrapTitle(false);
- durationTimeUnitsSelection = new SelectItem("durationTimeUnits");
+ durationTimeUnitsSelection = new SelectItem("durationTimeUnits",
"");
LinkedHashMap<String, String> units = new LinkedHashMap<String,
String>(4);
units.put(AlertDampening.TimeUnits.MINUTES.name(),
getTimeUnitsTitle(AlertDampening.TimeUnits.MINUTES));
units.put(AlertDampening.TimeUnits.HOURS.name(),
getTimeUnitsTitle(AlertDampening.TimeUnits.HOURS));
@@ -475,13 +483,7 @@ public class DampeningAlertDefinitionForm extends
LocatableDynamicForm implement
units.put(AlertDampening.TimeUnits.WEEKS.name(),
getTimeUnitsTitle(AlertDampening.TimeUnits.WEEKS));
durationTimeUnitsSelection.setValueMap(units);
durationTimeUnitsSelection.setDefaultValue(AlertDampening.TimeUnits.MINUTES.name());
- durationTimeUnitsSelection.setStartRow(false);
- durationTimeUnitsSelection.setEndRow(true);
- durationTimeUnitsSelection.setShowTitle(false);
- durationTimeUnitsStatic = new
StaticTextItem("durationTimeUnitsStatic");
- durationTimeUnitsStatic.setStartRow(false);
- durationTimeUnitsStatic.setEndRow(true);
- durationTimeUnitsStatic.setShowTitle(false);
+ durationTimeUnitsStatic = new
StaticTextItem("durationTimeUnitsStatic", "");
dampeningRuleSelection.addChangedHandler(new ChangedHandler() {
@Override
@@ -582,4 +584,18 @@ public class DampeningAlertDefinitionForm extends
LocatableDynamicForm implement
}
}
}
+
+ private String getCategoryHelp(String categorySelection) {
+ if (AlertDampening.Category.NONE.name().equals(categorySelection)) {
+ return "Dampening is disabled. Every time the condition set is true, an
alert will be triggered.";
+ } else if
(AlertDampening.Category.CONSECUTIVE_COUNT.name().equals(categorySelection)) {
+ return "An alert is triggered once every X occurrences the condition set
is true consecutively.";
+ } else if
(AlertDampening.Category.PARTIAL_COUNT.name().equals(categorySelection)) {
+ return "An alert is triggered once every X occurrences the condition set
is true during the last N evaluations of the condition set.";
+ } else if
(AlertDampening.Category.DURATION_COUNT.name().equals(categorySelection)) {
+ return "An alert is triggered once every X occurrences the condition set
is true within a given time period.";
+ }
+
+ return null; // should never happen
+ }
}
commit ef0e71c4bea6ebb2f9fb4b14eac1891007931b2e
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Sep 23 12:15:04 2010 -0400
widen the tooltip window
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/RecoveryAlertDefinitionForm.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/RecoveryAlertDefinitionForm.java
index 86d816b..b539d0a 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/RecoveryAlertDefinitionForm.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/RecoveryAlertDefinitionForm.java
@@ -158,6 +158,7 @@ public class RecoveryAlertDefinitionForm extends LocatableDynamicForm
implements
disableWhenFiredSelection.setDefaultValue("no");
disableWhenFiredSelection.setWrapTitle(false);
disableWhenFiredSelection.setWidth(300);
+ disableWhenFiredSelection.setHoverWidth(300);
disableWhenFiredSelection
.setTooltip("Indicates if this alert will be disabled after it
fires. Once disabled, the alert can be manually re-enabled or a recovery alert can be set
up to automatically re-enable it. If this alert is a recovery alert itself, this setting
cannot be turned on.");
disableWhenFiredStatic = new
StaticTextItem("disableWhenFiredStatic", "Disable When Fired");
@@ -166,6 +167,7 @@ public class RecoveryAlertDefinitionForm extends LocatableDynamicForm
implements
recoverAlertSelection = new SelectItem("recoveryAlert",
"Recover Alert");
recoverAlertSelection.setDefaultValue("0");
recoverAlertSelection.setWrapTitle(false);
+ recoverAlertSelection.setHoverWidth(300);
recoverAlertSelection
.setTooltip("The target alert that will be recovered (i.e.
re-enabled) after this alert triggers. Do not select an alert here if you are not defining
a recovery alert.");
commit 4092afb4e2b2c764b5ab0e8111b37110e9af73ea
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Sep 23 12:14:44 2010 -0400
add tooltip to explain ANY and ALL
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsAlertDefinitionForm.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsAlertDefinitionForm.java
index 571daed..6991b2c 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsAlertDefinitionForm.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsAlertDefinitionForm.java
@@ -143,6 +143,9 @@ public class ConditionsAlertDefinitionForm extends LocatableVLayout
implements E
conditionExpression.setValueMap(condExprs);
conditionExpression.setDefaultValue(BooleanExpression.ANY.name());
conditionExpression.setWrapTitle(false);
+ conditionExpression.setHoverWidth(300);
+ conditionExpression
+ .setTooltip("Determines if ANY or ALL of the conditions must
evaluate to true in order for the entire condition set to be considered true.");
conditionExpressionStatic = new
StaticTextItem("conditionExpressionStatic", "Fire alert when");
conditionExpressionStatic.setWrapTitle(false);
commit 34952d9da9c662bc241c90011e199e74c4a931cb
Merge: d905826... 9a36c9d...
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Thu Sep 23 10:58:11 2010 -0400
Merge branch 'master' into master-jay
commit d9058264c89ab9c489de7e698fd1af5de9245908
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Thu Sep 23 10:56:56 2010 -0400
Added MANAGE_INVENTORY check for group membership subtab enablement
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/AbstractTwoLevelTabSetView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/AbstractTwoLevelTabSetView.java
index c11659e..50700f2 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/AbstractTwoLevelTabSetView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/AbstractTwoLevelTabSetView.java
@@ -18,13 +18,17 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.common.detail;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
import com.google.gwt.user.client.History;
+import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.types.Side;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.layout.Layout;
+import org.rhq.core.domain.authz.Permission;
import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.ViewPath;
@@ -33,6 +37,7 @@ import
org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTab;
import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTabSelectedEvent;
import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTabSelectedHandler;
import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTabSet;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
/**
@@ -79,9 +84,9 @@ public abstract class AbstractTwoLevelTabSetView<T, U extends
Layout> extends Lo
protected abstract List<TwoLevelTab> createTabs();
- protected abstract void loadSelectedItem(int itemId, ViewPath viewPath);
+ protected abstract void loadSelectedItem(int itemId, ViewPath viewPath,
Set<Permission> globalPermissions);
- protected abstract void updateTabContent(T selectedItem);
+ protected abstract void updateTabContent(T selectedItem, Set<Permission>
globalPermissions);
// ---------------------------------------------------------
@@ -136,10 +141,10 @@ public abstract class AbstractTwoLevelTabSetView<T, U extends
Layout> extends Lo
}
}
- public void renderView(ViewPath viewPath) {
+ public void renderView(final ViewPath viewPath) {
// e.g. #Resource/10010/Summary/Overview
// ^ current path
- int id = Integer.parseInt(viewPath.getCurrent().getPath());
+ final int id = Integer.parseInt(viewPath.getCurrent().getPath());
viewPath.next();
if (!viewPath.isEnd()) {
@@ -160,8 +165,23 @@ public abstract class AbstractTwoLevelTabSetView<T, U extends
Layout> extends Lo
}
if (getSelectedItemId() == null || getSelectedItemId() != id) {
- // A different Resource or first load - go get data.
- loadSelectedItem(id, viewPath);
+ GWTServiceLookup.getAuthorizationService().getExplicitGlobalPermissions(
+ new AsyncCallback<Set<Permission>>() {
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(
+ "Could not determine global permissions for user,
defaulting to no global permissions.",
+ caught);
+ // A different Resource or first load - go get data.
+ loadSelectedItem(id, viewPath, new HashSet<Permission>());
+ }
+
+ @Override
+ public void onSuccess(Set<Permission> result) {
+ // A different Resource or first load - go get data.
+ loadSelectedItem(id, viewPath, result);
+ }
+ });
} else {
// Same Resource - just switch tabs.
selectTab(this.tabName, this.subTabName, viewPath);
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
index 17d901c..f273c40 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
@@ -178,7 +178,8 @@ public class ResourceGroupDetailView extends
AbstractTwoLevelTabSetView<Resource
return tabs;
}
- protected void updateTabContent(ResourceGroupComposite groupComposite) {
+ protected void updateTabContent(ResourceGroupComposite groupComposite,
Set<Permission> globalPermissions) {
+ boolean enabled;
boolean visible;
Canvas canvas;
@@ -227,9 +228,10 @@ public class ResourceGroupDetailView extends
AbstractTwoLevelTabSetView<Resource
//updateSubTab(this.inventoryTab, this.inventoryConn,
// new GroupPluginConfigurationEditView(this.group.getId(),
this.group.getResourceType().getId(), ConfigurationEditor.ConfigType.plugin),
// facets.contains(ResourceTypeFacet.PLUGIN_CONFIGURATION), true);
- // TODO: should require MANAGE_INVENTORY authz
- updateSubTab(this.inventoryTab, this.inventoryMembership, new
ResourceGroupMembershipView(this.inventoryTab
- .extendLocatorId("MembershipView"), groupId), true, true);
+ enabled = globalPermissions.contains(Permission.MANAGE_INVENTORY);
+ canvas = (enabled) ? new
ResourceGroupMembershipView(this.inventoryTab.extendLocatorId("MembershipView"),
+ groupId) : null;
+ updateSubTab(this.inventoryTab, this.inventoryMembership, canvas, true,
enabled);
if (updateTab(this.operationsTab, groupCategory == GroupCategory.COMPATIBLE
&& facets.contains(ResourceTypeFacet.OPERATION), true)) {
@@ -263,7 +265,7 @@ public class ResourceGroupDetailView extends
AbstractTwoLevelTabSetView<Resource
markForRedraw();
}
- protected void loadSelectedItem(final int groupId, final ViewPath viewPath) {
+ protected void loadSelectedItem(final int groupId, final ViewPath viewPath, final
Set<Permission> globalPermissions) {
this.groupId = groupId;
ResourceGroupCriteria criteria = new ResourceGroupCriteria();
@@ -279,12 +281,13 @@ public class ResourceGroupDetailView extends
AbstractTwoLevelTabSetView<Resource
public void onSuccess(PageList<ResourceGroupComposite> result) {
groupComposite = result.get(0);
- loadResourceType(groupComposite, viewPath);
+ loadResourceType(groupComposite, viewPath, globalPermissions);
}
});
}
- private void loadResourceType(final ResourceGroupComposite groupComposite, final
ViewPath viewPath) {
+ private void loadResourceType(final ResourceGroupComposite groupComposite, final
ViewPath viewPath,
+ final Set<Permission> globalPermissions) {
final ResourceGroup group = this.groupComposite.getResourceGroup();
if (group.getGroupCategory() == GroupCategory.COMPATIBLE) {
@@ -307,14 +310,14 @@ public class ResourceGroupDetailView extends
AbstractTwoLevelTabSetView<Resource
public void onSuccess(Set<Permission> result) {
ResourceGroupDetailView.this.permissions = new
ResourcePermission(result);
- updateTabContent(groupComposite);
+ updateTabContent(groupComposite, globalPermissions);
selectTab(getTabName(), getSubTabName(), viewPath);
}
});
}
});
} else {
- updateTabContent(groupComposite);
+ updateTabContent(groupComposite, globalPermissions);
selectTab(getTabName(), getSubTabName(), viewPath);
}
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
index ba88b87..7236d4b 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
@@ -27,6 +27,7 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.tab.Tab;
+import org.rhq.core.domain.authz.Permission;
import org.rhq.core.domain.criteria.ResourceCriteria;
import org.rhq.core.domain.measurement.DataType;
import org.rhq.core.domain.measurement.MeasurementDefinition;
@@ -189,7 +190,8 @@ public class ResourceDetailView extends
AbstractTwoLevelTabSetView<ResourceCompo
return new ResourceTitleBar(extendLocatorId("TitleBar"));
}
- protected void updateTabContent(ResourceComposite resourceComposite) {
+ protected void updateTabContent(ResourceComposite resourceComposite,
Set<Permission> globalPermissions) {
+ boolean enabled;
boolean visible;
Canvas canvas;
@@ -201,7 +203,7 @@ public class ResourceDetailView extends
AbstractTwoLevelTabSetView<ResourceCompo
((TwoLevelTab) top).getLayout().destroyViews();
}
- ResourcePermission permissions = this.resourceComposite.getResourcePermission();
+ ResourcePermission resourcePermissions =
this.resourceComposite.getResourcePermission();
Set<ResourceTypeFacet> facets =
this.resourceComposite.getResourceFacets().getFacets();
updateSubTab(this.summaryTab, this.summaryOverview, new
OverviewView(this.summaryTab
@@ -239,9 +241,10 @@ public class ResourceDetailView extends
AbstractTwoLevelTabSetView<ResourceCompo
updateSubTab(this.inventoryTab, this.inventoryConn, canvas, visible, true);
updateSubTab(this.inventoryTab, this.inventoryGroups,
ResourceGroupListView.getGroupsOf(this.inventoryTab
.extendLocatorId("GroupsView"), resource.getId()), true, true);
- // TODO: authz check for this subtab: MANAGE_INVENTORY
- updateSubTab(this.inventoryTab, this.inventoryGroupMembership, new
ResourceResourceGroupsView(this.inventoryTab
- .extendLocatorId("GroupMembershipView"), resourceId), true, true);
+ enabled = globalPermissions.contains(Permission.MANAGE_INVENTORY);
+ canvas = (enabled) ? new
ResourceResourceGroupsView(this.inventoryTab.extendLocatorId("GroupMembershipView"),
+ resourceId) : null;
+ updateSubTab(this.inventoryTab, this.inventoryGroupMembership, canvas, true,
enabled);
if (updateTab(this.operationsTab, facets.contains(ResourceTypeFacet.OPERATION),
true)) {
// comment out GWT-based operation history until...
@@ -268,7 +271,7 @@ public class ResourceDetailView extends
AbstractTwoLevelTabSetView<ResourceCompo
updateSubTab(this.alertsTab, this.alertDelete, new FullHTMLPane(
"/rhq/resource/alert/listAlertDefinitions-plain.xhtml?id=" +
resource.getId()), true, true);
- if (updateTab(this.configurationTab,
facets.contains(ResourceTypeFacet.CONFIGURATION), permissions
+ if (updateTab(this.configurationTab,
facets.contains(ResourceTypeFacet.CONFIGURATION), resourcePermissions
.isConfigureRead())) {
updateSubTab(this.configurationTab, this.configCurrent, new
ResourceConfigurationEditView(this
.extendLocatorId("ResourceConfigView"), resource), true,
true);
@@ -300,7 +303,8 @@ public class ResourceDetailView extends
AbstractTwoLevelTabSetView<ResourceCompo
return this.resourceId;
}
- protected void loadSelectedItem(final int resourceId, final ViewPath viewPath) {
+ protected void loadSelectedItem(final int resourceId, final ViewPath viewPath,
+ final Set<Permission> globalPermissions) {
this.resourceId = resourceId;
ResourceCriteria criteria = new ResourceCriteria();
@@ -323,13 +327,14 @@ public class ResourceDetailView extends
AbstractTwoLevelTabSetView<ResourceCompo
onFailure(new Exception("Resource with id [" +
resourceId + "] does not exist."));
} else {
final ResourceComposite resourceComposite = result.get(0);
- loadResourceType(resourceComposite, viewPath);
+ loadResourceType(resourceComposite, viewPath,
globalPermissions);
}
}
});
}
- private void loadResourceType(final ResourceComposite resourceComposite, final
ViewPath viewPath) {
+ private void loadResourceType(final ResourceComposite resourceComposite, final
ViewPath viewPath,
+ final Set<Permission> globalPermissions) {
final Resource resource = resourceComposite.getResource();
ResourceTypeRepository.Cache.getInstance().getResourceTypes(
resource.getResourceType().getId(),
@@ -341,7 +346,7 @@ public class ResourceDetailView extends
AbstractTwoLevelTabSetView<ResourceCompo
public void onTypesLoaded(ResourceType type) {
resourceComposite.getResource().setResourceType(type);
ResourceDetailView.this.resourceComposite = resourceComposite;
- updateTabContent(resourceComposite);
+ updateTabContent(resourceComposite, globalPermissions);
selectTab(getTabName(), getSubTabName(), viewPath);
}
});
commit 964d6819a63b7a44baacbc015d72e0fc9b4c588b
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Thu Sep 23 09:58:57 2010 -0400
Tab and SubTab work
- Rearranged things a bit to avoid ID conflicts/leaked widgets. Buttons
that were created but not visible (subtabs of detached tabs) were
not being destroyed in a timely manner. So, now create buttons only
when they are going to be visible. To help this I also encapsulated the
Button into the SubTab object itself.
- Added logic to not create views for subtabs that are not visible.
- Work to fix initial subtab selection.
- Work to avoid flash of buttons by hiding the detail view until after the
tabs have been updated the first time.
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/SubTab.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/SubTab.java
index 1d6134b..e149772 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/SubTab.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/SubTab.java
@@ -22,6 +22,7 @@ package org.rhq.enterprise.gui.coregui.client.components.tab;
import com.smartgwt.client.widgets.Canvas;
import org.rhq.enterprise.gui.coregui.client.util.selenium.Locatable;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableButton;
/**
* Simple class to provide a SubTab a locatorId.
@@ -32,11 +33,13 @@ public class SubTab implements Locatable {
private String locatorId;
private String title;
private Canvas canvas;
+ private LocatableButton button;
public SubTab(String locatorId, String title, Canvas canvas) {
this.locatorId = locatorId;
this.title = title;
this.canvas = canvas;
+ this.button = null;
}
public String getLocatorId() {
@@ -55,9 +58,17 @@ public class SubTab implements Locatable {
this.canvas = canvas;
}
+ public LocatableButton getButton() {
+ return button;
+ }
+
+ public void setButton(LocatableButton button) {
+ this.button = button;
+ }
+
@Override
public String extendLocatorId(String extension) {
- return this.locatorId + "_" + extension;
+ return this.locatorId + "_" + extension;
}
@Override
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/SubTabLayout.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/SubTabLayout.java
index 0005436..ff78476 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/SubTabLayout.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/SubTabLayout.java
@@ -18,7 +18,10 @@
*/
package org.rhq.enterprise.gui.coregui.client.components.tab;
-import java.util.*;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Set;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.event.shared.HandlerRegistration;
@@ -39,15 +42,14 @@ import
org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
*/
public class SubTabLayout extends LocatableVLayout {
- /** maps subtab locator IDs to SubTabs */
- private Map<String, SubTab> subtabs = new LinkedHashMap<String,
SubTab>();
- /** maps subtab locator IDs to subtab Buttons */
- private Map<String, Button> subTabButtons = new LinkedHashMap<String,
Button>();
- /** locator IDs of subtabs that are disabled */
+ /** maps subTab locator IDs to SubTabs */
+ private Map<String, SubTab> subTabs = new LinkedHashMap<String,
SubTab>();
+ /** locator IDs of subTabs that are disabled */
private Set<String> disabledSubTabs = new HashSet<String>();
private SubTab currentlyDisplayed;
private String currentlySelected;
+ private ToolStrip buttonBar;
public SubTabLayout(String locatorId) {
super(locatorId);
@@ -63,154 +65,149 @@ public class SubTabLayout extends LocatableVLayout {
setMargin(0);
setPadding(0);
- ToolStrip buttonBar = new ToolStrip();
+ buttonBar = new ToolStrip();
buttonBar.setBackgroundColor("grey");
buttonBar.setWidth100();
buttonBar.setBorder(null);
buttonBar.setMembersMargin(30);
addMember(buttonBar);
-
- int i = 0;
-
- for (final String locatorId : subtabs.keySet()) {
-
- SubTab subTab = subtabs.get(locatorId);
-
- if (currentlySelected == null) {
- currentlySelected = locatorId;
- }
-
- Button button = new LocatableButton(locatorId, subTab.getTitle());
- button.setShowRollOver(false);
- button.setActionType(SelectionType.RADIO);
- button.setRadioGroup("subtabs");
- button.setBorder(null);
- button.setAutoFit(true);
- if (disabledSubTabs.contains(locatorId)) {
- button.disable();
- } else {
- button.enable();
- }
-
- button.setBaseStyle("SubTabButton");
-
- // button.setStyleName("SubTabButton");
- // button.setStylePrimaryName("SubTabButton");
-
- button.addClickHandler(new ClickHandler() {
- public void onClick(ClickEvent clickEvent) {
- currentlySelected = locatorId;
- fireSubTabSelection();
- draw();
- }
- });
-
- subTabButtons.put(locatorId, button);
-
- buttonBar.addMember(button);
- }
-
- // Initial settings
- selectSubTabByLocatorId(currentlySelected);
}
@Override
protected void onDraw() {
super.onDraw();
- selectSubTabByLocatorId(currentlySelected);
+ if (null == currentlySelected) {
+ SubTab initial = getDefaultSubTab();
+ if (null != initial) {
+ currentlySelected = initial.getLocatorId();
+ }
+ }
+ if (null != currentlySelected) {
+ selectSubTabByLocatorId(currentlySelected);
+ }
}
- public void enableSubTab(String locatorId) {
- disabledSubTabs.remove(locatorId);
- if (subTabButtons.containsKey(locatorId)) {
- subTabButtons.get(locatorId).enable();
- markForRedraw();
+ /**
+ * Make subTab visible.
+ *
+ * @param subTab not null
+ */
+ public void showSubTab(SubTab subTab) {
+ LocatableButton button = subTab.getButton();
+ if (null == button) {
+ button = createSubTabButton(subTab);
+ buttonBar.addMember(button);
+ subTab.setButton(button);
}
+ button.show();
}
- public void disableSubTab(String locatorId) {
- disabledSubTabs.add(locatorId);
- if (subTabButtons.containsKey(locatorId)) {
- subTabButtons.get(locatorId).disable();
- markForRedraw();
+ /**
+ * Make subTab not visible.
+ *
+ * @param subTab not null
+ */
+ public void hideSubTab(SubTab subTab) {
+ Button button = subTab.getButton();
+ if (null != button) {
+ buttonBar.removeMember(button);
+ button.destroy();
+ subTab.setButton(null);
}
}
- public void updateSubTab(SubTab subTab) {
+ public boolean isSubTabVisible(SubTab subTab) {
+ return (null != subTab && null != subTab.getButton());
+ }
- // Destroy old views so they don't leak
- // TODO: You've already leaked because the subtab has already had its canvas
replaced.
-// Canvas oldCanvas = subTab.getCanvas();
-// if (oldCanvas != null) {
-// oldCanvas.destroy();
-// }
+ private LocatableButton createSubTabButton(final SubTab subTab) {
+ LocatableButton button = new LocatableButton(subTab.getLocatorId(),
subTab.getTitle());
+ button.setShowRollOver(false);
+ button.setActionType(SelectionType.RADIO);
+ button.setRadioGroup("subTabs");
+ button.setBorder(null);
+ button.setAutoFit(true);
- String locatorId = subTab.getLocatorId();
- this.subtabs.put(locatorId, subTab);
- if (locatorId.equals(this.currentlySelected)) {
- refresh();
+ button.setBaseStyle("SubTabButton");
+
+ // button.setStyleName("SubTabButton");
+ // button.setStylePrimaryName("SubTabButton");
+
+ button.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent clickEvent) {
+ SubTabLayout.this.currentlySelected = subTab.getLocatorId();
+ fireSubTabSelection();
+ draw();
+ }
+ });
+
+ return (button);
+ }
+
+ /**
+ * Ignored if not visible. Otherwise, enabled.
+ */
+ public void enableSubTab(SubTab subTab) {
+ if (isSubTabVisible(subTab)) {
+ disabledSubTabs.remove(subTab.getLocatorId());
+ subTab.getButton().enable();
+ subTab.getButton().show();
+ }
+ }
+
+ /**
+ * Ignored if not visible. Otherwise, disabled.
+ */
+ public void disableSubTab(SubTab subTab) {
+ if (isSubTabVisible(subTab)) {
+ disabledSubTabs.add(subTab.getLocatorId());
+ subTab.getButton().disable();
+ subTab.getButton().show();
}
}
- public void unregisterAllSubTabs() {
- destroyViews();
- subtabs.clear();
- markForRedraw();
+ /**
+ * @return true if not visible or disabled
+ */
+ public boolean isSubTabDisabled(SubTab subTab) {
+ return (!isSubTabVisible(subTab) || subTab.getButton().getDisabled());
}
public void registerSubTab(SubTab subTab) {
String locatorId = subTab.getLocatorId();
- if (currentlySelected == null) {
- currentlySelected = locatorId;
- }
- subtabs.put(locatorId, subTab);
- }
-
- public void setVisible(SubTab subTab, boolean visible) {
- Button button = this.subTabButtons.get(subTab.getLocatorId());
- if (visible) {
- if (!button.isVisible()) {
- button.show();
- markForRedraw();
- }
- } else {
- if (button.isVisible()) {
- button.hide();
- markForRedraw();
- }
- }
+ subTabs.put(locatorId, subTab);
}
public SubTab getDefaultSubTab() {
- // the default subtab is the first one in the set that is not disabled
- for (SubTab subtab : this.subtabs.values()) {
- if (!this.disabledSubTabs.contains(subtab.getLocatorId())) {
- return subtab;
+ // the default subTab is the first one in the set that is visible and not
disabled
+ for (SubTab subTab : this.subTabs.values()) {
+ if (!isSubTabDisabled(subTab)) {
+ return subTab;
}
}
return null;
}
- public boolean selectSubTab(SubTab subtab) {
- if (subtab == null) {
- throw new IllegalArgumentException("subtab is null.");
+ public boolean selectSubTab(SubTab subTab) {
+ if (subTab == null) {
+ throw new IllegalArgumentException("subTab is null.");
}
- return selectSubTabByLocatorId(subtab.getLocatorId());
+ return selectSubTabByLocatorId(subTab.getLocatorId());
}
public boolean selectSubTabByLocatorId(String locatorId) {
boolean foundTab = false;
- for (String subtabLocatorId : this.subtabs.keySet()) {
- if (subtabLocatorId.equals(locatorId)) {
- if (this.disabledSubTabs.contains(subtabLocatorId)) {
+ for (String subTabLocatorId : this.subTabs.keySet()) {
+ if (subTabLocatorId.equals(locatorId)) {
+ if (this.disabledSubTabs.contains(subTabLocatorId)) {
// Nice try - user tried to select a disabled tab, probably by going
directly to a bookmark URL.
- SubTab subtab = this.subtabs.get(subtabLocatorId);
- CoreGUI.getErrorHandler().handleError("Cannot select disabled
subtab '" + subtab.getTitle() + "'.");
+ SubTab subTab = this.subTabs.get(subTabLocatorId);
+ CoreGUI.getErrorHandler().handleError("Cannot select disabled
subTab '" + subTab.getTitle() + "'.");
} else {
- this.currentlySelected = subtabLocatorId;
+ this.currentlySelected = subTabLocatorId;
foundTab = true;
}
break;
@@ -225,10 +222,10 @@ public class SubTabLayout extends LocatableVLayout {
}
public SubTab getSubTabByTitle(String title) {
- for (String subtabLocatorId : this.subtabs.keySet()) {
- SubTab subtab = this.subtabs.get(subtabLocatorId);
- if (subtab.getTitle().equals(title)) {
- return subtab;
+ for (String subTabLocatorId : this.subTabs.keySet()) {
+ SubTab subTab = this.subTabs.get(subTabLocatorId);
+ if (subTab.getTitle().equals(title)) {
+ return subTab;
}
}
@@ -236,9 +233,9 @@ public class SubTabLayout extends LocatableVLayout {
}
public SubTab getSubTabByLocatorId(String locatorId) {
- for (String subtabLocatorId : this.subtabs.keySet()) {
- if (subtabLocatorId.equals(locatorId)) {
- return this.subtabs.get(subtabLocatorId);
+ for (String subTabLocatorId : this.subTabs.keySet()) {
+ if (subTabLocatorId.equals(locatorId)) {
+ return this.subTabs.get(subTabLocatorId);
}
}
@@ -246,23 +243,31 @@ public class SubTabLayout extends LocatableVLayout {
}
public boolean selectSubTabByTitle(String title) {
- SubTab subtab = getSubTabByTitle(title);
- if (subtab == null) {
+ SubTab subTab = getSubTabByTitle(title);
+ if (subTab == null) {
return false;
} else {
- if (this.disabledSubTabs.contains(subtab.getLocatorId())) {
+ if (this.disabledSubTabs.contains(subTab.getLocatorId())) {
// Nice try - user tried to select a disabled tab, probably by going
directly to a bookmark URL.
- CoreGUI.getErrorHandler().handleError("Cannot select disabled subtab
'" + title + "'.");
+ CoreGUI.getErrorHandler().handleError("Cannot select disabled subTab
'" + title + "'.");
return false;
}
- this.currentlySelected = subtab.getLocatorId();
+ this.currentlySelected = subTab.getLocatorId();
refresh();
return true;
}
}
public SubTab getCurrentSubTab() {
- return this.subtabs.get(this.currentlySelected);
+ if (null == currentlySelected) {
+ SubTab current = getDefaultSubTab();
+ if (null != current) {
+ currentlySelected = current.getLocatorId();
+ }
+ return current;
+ }
+
+ return this.subTabs.get(this.currentlySelected);
}
// ------- Event support -------
@@ -276,34 +281,34 @@ public class SubTabLayout extends LocatableVLayout {
public void fireSubTabSelection() {
TwoLevelTabSelectedEvent event = new TwoLevelTabSelectedEvent("?",
getCurrentSubTab().getTitle(), -1,
- getCurrentCanvas());
+ getCurrentCanvas());
hm.fireEvent(event);
}
public Canvas getCurrentCanvas() {
- return currentlyDisplayed != null ? currentlyDisplayed.getCanvas() :
subtabs.get(currentlySelected).getCanvas();
+ return currentlyDisplayed != null ? currentlyDisplayed.getCanvas() :
subTabs.get(currentlySelected).getCanvas();
}
/**
* Destroy all the currently held views so that they can be replaced with new
versions
*/
public void destroyViews() {
- for (SubTab subtab : subtabs.values()) {
- if (subtab.getCanvas() != null) {
- subtab.getCanvas().destroy();
- subtab.setCanvas(null);
+ for (SubTab subTab : subTabs.values()) {
+ if (subTab.getCanvas() != null) {
+ subTab.getCanvas().destroy();
+ subTab.setCanvas(null);
}
}
}
private void refresh() {
- if (isDrawn()) {
- Button button = this.subTabButtons.get(this.currentlySelected);
+ if (isDrawn() && null != this.currentlySelected) {
+ Button button = this.subTabs.get(this.currentlySelected).getButton();
button.select();
- SubTab currentSubtab = this.subtabs.get(this.currentlySelected);
+ SubTab currentSubTab = this.subTabs.get(this.currentlySelected);
- if (this.currentlyDisplayed != null &&
this.currentlyDisplayed.getCanvas() != currentSubtab.getCanvas()) {
+ if (this.currentlyDisplayed != null &&
this.currentlyDisplayed.getCanvas() != currentSubTab.getCanvas()) {
try {
this.currentlyDisplayed.getCanvas().hide();
} catch (Exception e) {
@@ -311,7 +316,7 @@ public class SubTabLayout extends LocatableVLayout {
}
}
- Canvas canvas = currentSubtab.getCanvas();
+ Canvas canvas = currentSubTab.getCanvas();
if (canvas != null) {
if (hasMember(canvas)) {
if (!canvas.isVisible()) {
@@ -324,7 +329,7 @@ public class SubTabLayout extends LocatableVLayout {
addMember(canvas);
}
markForRedraw();
- this.currentlyDisplayed = currentSubtab;
+ this.currentlyDisplayed = currentSubTab;
}
}
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTab.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTab.java
index cbb6370..4468d93 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTab.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTab.java
@@ -34,10 +34,6 @@ public class TwoLevelTab extends LocatableTab {
layout = new SubTabLayout(locatorId);
}
- public void updateSubTab(SubTab subTab) {
- layout.updateSubTab(subTab);
- }
-
public void registerSubTabs(SubTab... subTabs) {
for (SubTab subTab : subTabs) {
layout.registerSubTab(subTab);
@@ -45,14 +41,18 @@ public class TwoLevelTab extends LocatableTab {
}
public void setVisible(SubTab subTab, boolean visible) {
- layout.setVisible(subTab, visible);
+ if (visible) {
+ layout.showSubTab(subTab);
+ } else {
+ layout.hideSubTab(subTab);
+ }
}
- public void setSubTabEnabled(String locatorId, boolean enabled) {
+ public void setSubTabEnabled(SubTab subTab, boolean enabled) {
if (enabled) {
- layout.enableSubTab(locatorId);
+ layout.enableSubTab(subTab);
} else {
- layout.disableSubTab(locatorId);
+ layout.disableSubTab(subTab);
}
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTabSet.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTabSet.java
index d39efb7..d8e29b2 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTabSet.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTabSet.java
@@ -39,7 +39,7 @@ public class TwoLevelTabSet extends LocatableTabSet implements
TabSelectedHandle
public void setTabs(TwoLevelTab... tabs) {
super.setTabs(tabs);
- for (TwoLevelTab tab : tabs) {
+ for (TwoLevelTab tab : tabs) {
tab.getLayout().addTwoLevelTabSelectedHandler(this);
updateTab(tab, tab.getPane());
}
@@ -71,15 +71,17 @@ public class TwoLevelTabSet extends LocatableTabSet implements
TabSelectedHandle
public void onTabSelected(TabSelectedEvent tabSelectedEvent) {
TwoLevelTab tab = (TwoLevelTab) getSelectedTab();
- TwoLevelTabSelectedEvent event = new TwoLevelTabSelectedEvent(tab.getTitle(),
- tab.getLayout().getCurrentSubTab().getTitle(), tabSelectedEvent.getTabNum(),
- tab.getLayout().getCurrentCanvas());
- m.fireEvent(event);
+ SubTab currentSubTab = tab.getLayout().getCurrentSubTab();
+ if (null != currentSubTab) {
+ TwoLevelTabSelectedEvent event = new TwoLevelTabSelectedEvent(tab.getTitle(),
tab.getLayout()
+ .getCurrentSubTab().getTitle(), tabSelectedEvent.getTabNum(),
tab.getLayout().getCurrentCanvas());
+ m.fireEvent(event);
+ }
}
public void onTabSelected(TwoLevelTabSelectedEvent tabSelectedEvent) {
tabSelectedEvent.setTabNum(getSelectedTabNumber());
- Tab tab = getSelectedTab();
+ Tab tab = getSelectedTab();
tabSelectedEvent.setId(tab.getTitle());
m.fireEvent(tabSelectedEvent);
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/AbstractTwoLevelTabSetView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/AbstractTwoLevelTabSetView.java
index 8f7452c..c11659e 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/AbstractTwoLevelTabSetView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/AbstractTwoLevelTabSetView.java
@@ -18,10 +18,13 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.common.detail;
+import java.util.List;
+
import com.google.gwt.user.client.History;
import com.smartgwt.client.types.Side;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.layout.Layout;
+
import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.ViewPath;
@@ -32,14 +35,12 @@ import
org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTabSelectedH
import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTabSet;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
-import java.util.List;
-
/**
* @author Greg Hinkle
* @author Ian Springer
*/
-public abstract class AbstractTwoLevelTabSetView<T, U extends Layout> extends
LocatableVLayout
- implements BookmarkableView, TwoLevelTabSelectedHandler {
+public abstract class AbstractTwoLevelTabSetView<T, U extends Layout> extends
LocatableVLayout implements
+ BookmarkableView, TwoLevelTabSelectedHandler {
private String baseViewPath;
private TwoLevelTabSet tabSet;
private String tabName;
@@ -81,6 +82,7 @@ public abstract class AbstractTwoLevelTabSetView<T, U extends
Layout> extends Lo
protected abstract void loadSelectedItem(int itemId, ViewPath viewPath);
protected abstract void updateTabContent(T selectedItem);
+
// ---------------------------------------------------------
protected U getTitleBar() {
@@ -101,13 +103,13 @@ public abstract class AbstractTwoLevelTabSetView<T, U extends
Layout> extends Lo
}
}
- return enabled;
+ return (visible && enabled);
}
protected void updateSubTab(TwoLevelTab tab, SubTab subTab, Canvas canvas, boolean
visible, boolean enabled) {
tab.setVisible(subTab, visible);
if (visible) {
- tab.setSubTabEnabled(subTab.getLocatorId(), enabled);
+ tab.setSubTabEnabled(subTab, enabled);
if (enabled) {
subTab.setCanvas(canvas);
}
@@ -175,8 +177,7 @@ public abstract class AbstractTwoLevelTabSetView<T, U extends
Layout> extends Lo
*/
public void selectTab(String tabTitle, String subtabTitle, ViewPath viewPath) {
try {
- TwoLevelTab tab = (tabTitle != null) ? this.tabSet.getTabByTitle(tabTitle) :
- this.tabSet.getDefaultTab();
+ TwoLevelTab tab = (tabTitle != null) ? this.tabSet.getTabByTitle(tabTitle) :
this.tabSet.getDefaultTab();
if (tab == null || tab.getDisabled()) {
CoreGUI.getErrorHandler().handleError("Invalid tab name: " +
tabTitle);
// TODO: Should we fire a history event here to redirect to a valid
bookmark?
@@ -221,5 +222,5 @@ public abstract class AbstractTwoLevelTabSetView<T, U extends
Layout> extends Lo
public String getSubTabName() {
return subTabName;
- }
+ }
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
index 05590ff..17d901c 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
@@ -24,6 +24,7 @@ import java.util.List;
import java.util.Set;
import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.tab.Tab;
import org.rhq.core.domain.authz.Permission;
@@ -98,6 +99,7 @@ public class ResourceGroupDetailView extends
AbstractTwoLevelTabSetView<Resource
public ResourceGroupDetailView(String locatorId) {
super(locatorId, BASE_VIEW_PATH);
+ this.hide();
}
@Override
@@ -177,6 +179,9 @@ public class ResourceGroupDetailView extends
AbstractTwoLevelTabSetView<Resource
}
protected void updateTabContent(ResourceGroupComposite groupComposite) {
+ boolean visible;
+ Canvas canvas;
+
this.groupComposite = groupComposite;
ResourceGroup group = groupComposite.getResourceGroup();
int groupId = group.getId();
@@ -194,22 +199,24 @@ public class ResourceGroupDetailView extends
AbstractTwoLevelTabSetView<Resource
// summaryTab.updateSubTab("Timeline", timelinePane);
// Summary tab is always visible and enabled.
updateSubTab(this.summaryTab, this.summaryOverview, new
OverviewView(this.summaryTab
- .extendLocatorId("Overview"), this.groupComposite), true, true);
+ .extendLocatorId("OverviewView"), this.groupComposite), true,
true);
if (updateTab(this.monitoringTab, groupCategory == GroupCategory.COMPATIBLE,
true)) {
- updateSubTab(this.monitoringTab, this.monitorGraphs, new FullHTMLPane(
- "/rhq/group/monitor/graphs-plain.xhtml?groupId=" + groupId),
hasMetricsOfType(this.groupComposite,
- DataType.MEASUREMENT), true);
- updateSubTab(this.monitoringTab, this.monitorTables, new FullHTMLPane(
- "/rhq/group/monitor/tables-plain.xhtml?groupId=" + groupId),
hasMetricsOfType(this.groupComposite,
- DataType.MEASUREMENT), true);
- updateSubTab(this.monitoringTab, this.monitorTraits, new
TraitsView(this.monitoringTab
- .extendLocatorId("TraitsView"), groupId),
hasMetricsOfType(this.groupComposite, DataType.TRAIT), true);
- updateSubTab(this.monitoringTab, this.monitorSched, new
SchedulesView(this.monitoringTab
- .extendLocatorId("SchedulesView"), groupId),
hasMetricsOfType(this.groupComposite, null), true);
- updateSubTab(this.monitoringTab, this.monitorCallTime, new FullHTMLPane(
- "/rhq/group/monitor/response-plain.xhtml?groupId=" + groupId),
facets
- .contains(ResourceTypeFacet.CALL_TIME), true);
+ visible = hasMetricsOfType(this.groupComposite, DataType.MEASUREMENT);
+ canvas = (visible) ? new
FullHTMLPane("/rhq/group/monitor/graphs-plain.xhtml?groupId=" + groupId) :
null;
+ updateSubTab(this.monitoringTab, this.monitorGraphs, canvas, visible, true);
+ // visible = same test as above
+ canvas = (visible) ? new
FullHTMLPane("/rhq/group/monitor/tables-plain.xhtml?groupId=" + groupId) :
null;
+ updateSubTab(this.monitoringTab, this.monitorTables, canvas, visible, true);
+ visible = hasMetricsOfType(this.groupComposite, DataType.TRAIT);
+ canvas = (visible) ? new
TraitsView(this.monitoringTab.extendLocatorId("TraitsView"), groupId) : null;
+ updateSubTab(this.monitoringTab, this.monitorTraits, canvas, visible, true);
+ visible = hasMetricsOfType(this.groupComposite, null);
+ canvas = (visible) ? new
SchedulesView(this.monitoringTab.extendLocatorId("SchedulesView"), groupId) :
null;
+ updateSubTab(this.monitoringTab, this.monitorSched, canvas, visible, true);
+ visible = facets.contains(ResourceTypeFacet.CALL_TIME);
+ canvas = (visible) ? new
FullHTMLPane("/rhq/group/monitor/response-plain.xhtml?groupId=" + groupId) :
null;
+ updateSubTab(this.monitoringTab, this.monitorCallTime, canvas, visible,
true);
// TODO (ips): Add Availability subtab.
}
@@ -220,6 +227,7 @@ public class ResourceGroupDetailView extends
AbstractTwoLevelTabSetView<Resource
//updateSubTab(this.inventoryTab, this.inventoryConn,
// new GroupPluginConfigurationEditView(this.group.getId(),
this.group.getResourceType().getId(), ConfigurationEditor.ConfigType.plugin),
// facets.contains(ResourceTypeFacet.PLUGIN_CONFIGURATION), true);
+ // TODO: should require MANAGE_INVENTORY authz
updateSubTab(this.inventoryTab, this.inventoryMembership, new
ResourceGroupMembershipView(this.inventoryTab
.extendLocatorId("MembershipView"), groupId), true, true);
@@ -238,8 +246,8 @@ public class ResourceGroupDetailView extends
AbstractTwoLevelTabSetView<Resource
"/rhq/group/alert/listGroupAlertDefinitions-plain.xhtml?groupId=" + groupId),
true, true);
}
- if (updateTab(this.configurationTab, groupCategory == GroupCategory.COMPATIBLE
- && facets.contains(ResourceTypeFacet.CONFIGURATION),
this.permissions.isConfigureRead())) {
+ visible = groupCategory == GroupCategory.COMPATIBLE &&
facets.contains(ResourceTypeFacet.CONFIGURATION);
+ if (updateTab(this.configurationTab, visible, visible &&
this.permissions.isConfigureRead())) {
updateSubTab(this.configurationTab, this.configCurrent, new FullHTMLPane(
"/rhq/group/configuration/viewCurrent-plain.xhtml?groupId=" +
groupId), true, true);
updateSubTab(this.configurationTab, this.configHistory, new FullHTMLPane(
@@ -250,6 +258,9 @@ public class ResourceGroupDetailView extends
AbstractTwoLevelTabSetView<Resource
&& facets.contains(ResourceTypeFacet.EVENT), true)) {
updateSubTab(this.eventsTab, this.eventHistory,
EventCompositeHistoryView.get(groupComposite), true, true);
}
+
+ this.show();
+ markForRedraw();
}
protected void loadSelectedItem(final int groupId, final ViewPath viewPath) {
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
index 8e4e16f..ba88b87 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
@@ -24,6 +24,7 @@ import java.util.List;
import java.util.Set;
import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.tab.Tab;
import org.rhq.core.domain.criteria.ResourceCriteria;
@@ -110,6 +111,7 @@ public class ResourceDetailView extends
AbstractTwoLevelTabSetView<ResourceCompo
public ResourceDetailView(String locatorId) {
super(locatorId, BASE_VIEW_PATH);
+ this.hide();
}
protected List<TwoLevelTab> createTabs() {
@@ -188,6 +190,9 @@ public class ResourceDetailView extends
AbstractTwoLevelTabSetView<ResourceCompo
}
protected void updateTabContent(ResourceComposite resourceComposite) {
+ boolean visible;
+ Canvas canvas;
+
this.resourceComposite = resourceComposite;
Resource resource = this.resourceComposite.getResource();
getTitleBar().setResource(resource);
@@ -205,31 +210,36 @@ public class ResourceDetailView extends
AbstractTwoLevelTabSetView<ResourceCompo
updateSubTab(this.summaryTab, this.summaryTimeline, new FullHTMLPane(
"/rhq/resource/summary/timeline-plain.xhtml?id=" +
resource.getId()), true, true);
- updateSubTab(this.monitoringTab, this.monitorGraphs, new
GraphListView(this.monitoringTab
- .extendLocatorId("GraphListView"), resource),
- hasMetricsOfType(this.resourceComposite, DataType.MEASUREMENT), true);
- updateSubTab(this.monitoringTab, this.monitorTables, new FullHTMLPane(
- "/rhq/common/monitor/tables-plain.xhtml?id=" + resource.getId()),
hasMetricsOfType(this.resourceComposite,
- DataType.MEASUREMENT), true);
- updateSubTab(this.monitoringTab, this.monitorTraits, new
TraitsView(this.monitoringTab
- .extendLocatorId("TraitsView"), resource.getId()),
- hasMetricsOfType(this.resourceComposite, DataType.TRAIT), true);
+ visible = hasMetricsOfType(this.resourceComposite, DataType.MEASUREMENT);
+ canvas = (visible) ? new
GraphListView(this.monitoringTab.extendLocatorId("GraphListView"), resource) :
null;
+ updateSubTab(this.monitoringTab, this.monitorGraphs, canvas, visible, true);
+ // visible = same test as above
+ canvas = (visible) ? new
FullHTMLPane("/rhq/common/monitor/tables-plain.xhtml?id=" + resource.getId()) :
null;
+ updateSubTab(this.monitoringTab, this.monitorTables, canvas, visible, true);
+ visible = hasMetricsOfType(this.resourceComposite, DataType.TRAIT);
+ canvas = (visible) ? new
TraitsView(this.monitoringTab.extendLocatorId("TraitsView"), resource.getId()) :
null;
+ updateSubTab(this.monitoringTab, this.monitorTraits, canvas, visible, true);
updateSubTab(this.monitoringTab, this.monitorAvail, new FullHTMLPane(
"/rhq/resource/monitor/availabilityHistory-plain.xhtml?id=" +
resource.getId()), true, true);
updateSubTab(this.monitoringTab, this.monitorSched, new
SchedulesView(monitoringTab
.extendLocatorId("SchedulesView"), resource.getId()),
hasMetricsOfType(this.resourceComposite, null), true);
- updateSubTab(this.monitoringTab, this.monitorCallTime, new FullHTMLPane(
- "/rhq/resource/monitor/response-plain.xhtml?id=" +
resource.getId()), facets
- .contains(ResourceTypeFacet.CALL_TIME), true);
+ visible = facets.contains(ResourceTypeFacet.CALL_TIME);
+ canvas = (visible) ? new
FullHTMLPane("/rhq/resource/monitor/response-plain.xhtml?id=" +
resource.getId())
+ : null;
+ updateSubTab(this.monitoringTab, this.monitorCallTime, canvas, visible, true);
ResourceType type = this.resourceComposite.getResource().getResourceType();
- updateSubTab(this.inventoryTab, this.inventoryChildren,
ResourceSearchView.getChildrenOf(this.inventoryTab
- .extendLocatorId("ChildrenView"), resource.getId()),
!type.getChildResourceTypes().isEmpty(), true);
- updateSubTab(this.inventoryTab, this.inventoryConn, new
PluginConfigurationEditView(this.inventoryTab
- .extendLocatorId("PluginConfigView"), resource),
facets.contains(ResourceTypeFacet.PLUGIN_CONFIGURATION),
- true);
+ visible = !type.getChildResourceTypes().isEmpty();
+ canvas = (visible) ?
ResourceSearchView.getChildrenOf(this.inventoryTab.extendLocatorId("ChildrenView"),
+ resource.getId()) : null;
+ updateSubTab(this.inventoryTab, this.inventoryChildren, canvas, visible, true);
+ visible = facets.contains(ResourceTypeFacet.PLUGIN_CONFIGURATION);
+ canvas = (visible) ? new
PluginConfigurationEditView(this.inventoryTab.extendLocatorId("PluginConfigView"),
+ resource) : null;
+ updateSubTab(this.inventoryTab, this.inventoryConn, canvas, visible, true);
updateSubTab(this.inventoryTab, this.inventoryGroups,
ResourceGroupListView.getGroupsOf(this.inventoryTab
.extendLocatorId("GroupsView"), resource.getId()), true, true);
+ // TODO: authz check for this subtab: MANAGE_INVENTORY
updateSubTab(this.inventoryTab, this.inventoryGroupMembership, new
ResourceResourceGroupsView(this.inventoryTab
.extendLocatorId("GroupMembershipView"), resourceId), true, true);
@@ -241,7 +251,7 @@ public class ResourceDetailView extends
AbstractTwoLevelTabSetView<ResourceCompo
// 4) user can navigate to the group operation that spawned this resource
operation history, if appropriate
// note: enabled operation execution/schedules from left-nav, if it
doesn't already exist
updateSubTab(this.operationsTab, this.opHistory,
OperationHistoryView.getResourceHistoryView(operationsTab
- .extendLocatorId("History"), this.resourceComposite), true,
true);
+ .extendLocatorId("HistoryView"), this.resourceComposite), true,
true);
updateSubTab(this.operationsTab, this.opSched, new FullHTMLPane(
"/rhq/resource/operation/resourceOperationSchedules-plain.xhtml?id=" +
resource.getId()), true, true);
}
@@ -254,16 +264,16 @@ public class ResourceDetailView extends
AbstractTwoLevelTabSetView<ResourceCompo
updateSubTab(this.alertsTab, this.alertHistory, new FullHTMLPane(
"/rhq/resource/alert/listAlertHistory-plain.xhtml?id=" +
resource.getId()), true, true);
updateSubTab(this.alertsTab, this.alertDef, new
ResourceAlertDefinitionsView(alertsTab
- .extendLocatorId("AlertDef"), this.resourceComposite), true,
true);
+ .extendLocatorId("AlertDefView"), this.resourceComposite), true,
true);
updateSubTab(this.alertsTab, this.alertDelete, new FullHTMLPane(
"/rhq/resource/alert/listAlertDefinitions-plain.xhtml?id=" +
resource.getId()), true, true);
if (updateTab(this.configurationTab,
facets.contains(ResourceTypeFacet.CONFIGURATION), permissions
.isConfigureRead())) {
updateSubTab(this.configurationTab, this.configCurrent, new
ResourceConfigurationEditView(this
- .extendLocatorId("ResourceConfig"), resource), true, true);
+ .extendLocatorId("ResourceConfigView"), resource), true,
true);
updateSubTab(this.configurationTab, this.configHistory,
ConfigurationHistoryView.getHistoryOf(
- configurationTab.extendLocatorId("Hist"), resource.getId()),
true, true);
+ configurationTab.extendLocatorId("HistoryView"),
resource.getId()), true, true);
}
if (updateTab(this.eventsTab, facets.contains(ResourceTypeFacet.EVENT), true)) {
@@ -281,6 +291,9 @@ public class ResourceDetailView extends
AbstractTwoLevelTabSetView<ResourceCompo
updateSubTab(this.contentTab, this.contentHistory, new FullHTMLPane(
"/rhq/resource/content/history-plain.xhtml?id=" +
resource.getId()), true, true);
}
+
+ this.show();
+ markForRedraw();
}
public Integer getSelectedItemId() {
commit c8ecb19bf05ae6685178cd2c7f129e3cfd725472
Author: John Sanda <jsanda(a)redhat.com>
Date: Thu Sep 23 09:30:32 2010 -0400
Removing null placeholders
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceFactoryManagerBean.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceFactoryManagerBean.java
index 199fa13..4e5e8aa 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceFactoryManagerBean.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceFactoryManagerBean.java
@@ -459,7 +459,7 @@ public class ResourceFactoryManagerBean implements
ResourceFactoryManagerLocal,
ResourceFactoryAgentService resourceFactoryAgentService =
agentClient.getResourceFactoryAgentService();
resourceFactoryAgentService.createResource(request);
- return null;
+ return persistedHistory;
} catch (Exception e) {
log.error("Error while sending create resource request to agent
service", e);
@@ -548,7 +548,7 @@ public class ResourceFactoryManagerBean implements
ResourceFactoryManagerLocal,
ResourceFactoryAgentService resourceFactoryAgentService =
agentClient.getResourceFactoryAgentService();
resourceFactoryAgentService.createResource(request);
- return null;
+ return persistedHistory;
} catch (NoResultException nre) {
return null;
//eat the exception. Some of the queries return no results if no package yet
exists which is fine.
@@ -588,7 +588,7 @@ public class ResourceFactoryManagerBean implements
ResourceFactoryManagerLocal,
ResourceFactoryAgentService resourceFactoryAgentService =
agentClient.getResourceFactoryAgentService();
resourceFactoryAgentService.deleteResource(request);
- return null;
+ return persistedHistory;
} catch (Exception e) {
log.error("Error while sending delete resource request to agent
service", e);
commit 633eea8e64f70530bfb0c80d05d5c95afd179c6f
Author: John Sanda <jsanda(a)redhat.com>
Date: Thu Sep 23 09:23:22 2010 -0400
Making return type of create/delete resource operations non-void
This change is primarily for remote clients like the CLI. If a remote client
creates or deletes a resource, it has no way of knowing whether or not the
operation succeeds since the methods in ResourceFactoryManagerRemote have a
return type of void. Now they return CreateResourceHistory and
DeleteResourceHistory objects so that the progress of those operations can be
tracked.
diff --git
a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/DeleteResourceHistory.java
b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/DeleteResourceHistory.java
index b91622c..2812f3d 100644
---
a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/DeleteResourceHistory.java
+++
b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/DeleteResourceHistory.java
@@ -24,6 +24,7 @@ package org.rhq.core.domain.resource;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
+import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
@@ -59,7 +60,10 @@ import javax.persistence.Table;
@NamedQuery(name = DeleteResourceHistory.QUERY_DELETE_BY_RESOURCES, query =
"DELETE FROM DeleteResourceHistory drh WHERE drh.resource.id IN ( :resourceIds )
)") })
@SequenceGenerator(name = "SEQ", sequenceName =
"RHQ_DELETE_RES_HIST_ID_SEQ")
@Table(name = "RHQ_DELETE_RES_HIST")
-public class DeleteResourceHistory {
+public class DeleteResourceHistory implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
// Constants --------------------------------------------
public static final String QUERY_FIND_WITH_STATUS =
"DeleteResourceHistory.findWithStatus";
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceFactoryManagerBean.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceFactoryManagerBean.java
index 9a6b419..199fa13 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceFactoryManagerBean.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceFactoryManagerBean.java
@@ -431,7 +431,7 @@ public class ResourceFactoryManagerBean implements
ResourceFactoryManagerLocal,
//
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- public void createResource(Subject user, int parentResourceId, int resourceTypeId,
String resourceName,
+ public CreateResourceHistory createResource(Subject user, int parentResourceId, int
resourceTypeId, String resourceName,
Configuration pluginConfiguration, Configuration resourceConfiguration) {
log.debug("Received call to create configuration backed resource under
parent: " + parentResourceId
+ " of type: " + resourceTypeId);
@@ -458,6 +458,8 @@ public class ResourceFactoryManagerBean implements
ResourceFactoryManagerLocal,
AgentClient agentClient = agentManager.getAgentClient(agent);
ResourceFactoryAgentService resourceFactoryAgentService =
agentClient.getResourceFactoryAgentService();
resourceFactoryAgentService.createResource(request);
+
+ return null;
} catch (Exception e) {
log.error("Error while sending create resource request to agent
service", e);
@@ -471,25 +473,25 @@ public class ResourceFactoryManagerBean implements
ResourceFactoryManagerLocal,
}
}
- public void createPackageBackedResource(Subject subject, int parentResourceId, int
newResourceTypeId,
+ public CreateResourceHistory createPackageBackedResource(Subject subject, int
parentResourceId, int newResourceTypeId,
String newResourceName,//
@XmlJavaTypeAdapter(value = ConfigurationAdapter.class)//
Configuration pluginConfiguration, String packageName, String
packageVersionNumber, Integer architectureId,//
@XmlJavaTypeAdapter(value = ConfigurationAdapter.class)//
Configuration deploymentTimeConfiguration, byte[] packageBits) {
- createResource(subject, parentResourceId, newResourceTypeId, newResourceName,
pluginConfiguration, packageName,
+ return createResource(subject, parentResourceId, newResourceTypeId,
newResourceName, pluginConfiguration, packageName,
packageVersionNumber, architectureId, deploymentTimeConfiguration, new
ByteArrayInputStream(packageBits));
}
- public void createResource(Subject user, int parentResourceId, int newResourceTypeId,
String newResourceName,
+ public CreateResourceHistory createResource(Subject user, int parentResourceId, int
newResourceTypeId, String newResourceName,
Configuration pluginConfiguration, String packageName, String
packageVersionNumber, Integer architectureId,
Configuration deploymentTimeConfiguration, InputStream packageBitStream) {
- createResource(user, parentResourceId, newResourceTypeId, newResourceName,
pluginConfiguration, packageName,
+ return createResource(user, parentResourceId, newResourceTypeId, newResourceName,
pluginConfiguration, packageName,
packageVersionNumber, architectureId, deploymentTimeConfiguration,
packageBitStream, null);
}
- public void createResource(Subject user, int parentResourceId, int newResourceTypeId,
String newResourceName,
+ public CreateResourceHistory createResource(Subject user, int parentResourceId, int
newResourceTypeId, String newResourceName,
Configuration pluginConfiguration, String packageName, String
packageVersionNumber, Integer architectureId,
Configuration deploymentTimeConfiguration, InputStream packageBitStream,
Map<String, String> packageUploadDetails) {
@@ -545,7 +547,10 @@ public class ResourceFactoryManagerBean implements
ResourceFactoryManagerLocal,
AgentClient agentClient = agentManager.getAgentClient(agent);
ResourceFactoryAgentService resourceFactoryAgentService =
agentClient.getResourceFactoryAgentService();
resourceFactoryAgentService.createResource(request);
+
+ return null;
} catch (NoResultException nre) {
+ return null;
//eat the exception. Some of the queries return no results if no package yet
exists which is fine.
} catch (Exception e) {
log.error("Error while sending create resource request to agent
service", e);
@@ -560,7 +565,7 @@ public class ResourceFactoryManagerBean implements
ResourceFactoryManagerLocal,
}
}
- public void deleteResource(Subject subject, int resourceId) {
+ public DeleteResourceHistory deleteResource(Subject subject, int resourceId) {
log.debug("Received call to delete resource: " + resourceId);
Resource resource = entityManager.find(Resource.class, resourceId);
@@ -582,6 +587,8 @@ public class ResourceFactoryManagerBean implements
ResourceFactoryManagerLocal,
AgentClient agentClient = agentManager.getAgentClient(agent);
ResourceFactoryAgentService resourceFactoryAgentService =
agentClient.getResourceFactoryAgentService();
resourceFactoryAgentService.deleteResource(request);
+
+ return null;
} catch (Exception e) {
log.error("Error while sending delete resource request to agent
service", e);
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceFactoryManagerLocal.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceFactoryManagerLocal.java
index ea3784d..9796e0b 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceFactoryManagerLocal.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceFactoryManagerLocal.java
@@ -80,11 +80,11 @@ public interface ResourceFactoryManagerLocal {
* @param deploymentTimeConfiguration dictates how the package will be deployed
* @param packageBitStream content of the package to create
*/
- void createResource(Subject user, int parentResourceId, int newResourceTypeId, String
newResourceName,
+ CreateResourceHistory createResource(Subject user, int parentResourceId, int
newResourceTypeId, String newResourceName,
Configuration pluginConfiguration, String packageName, String packageVersion,
Integer architectureId,
Configuration deploymentTimeConfiguration, InputStream packageBitStream);
- void createResource(Subject user, int parentResourceId, int newResourceTypeId, String
newResourceName,
+ CreateResourceHistory createResource(Subject user, int parentResourceId, int
newResourceTypeId, String newResourceName,
Configuration pluginConfiguration, String packageName, String packageVersion,
Integer architectureId,
Configuration deploymentTimeConfiguration, InputStream packageBitStream,
Map<String, String> packageUploadDetails);
@@ -225,19 +225,19 @@ public interface ResourceFactoryManagerLocal {
/**
* @see {@link
ResourceFactoryManagerRemote.createResource(Subject,int,int,String,Configuration,Configuration)
*/
- void createResource(Subject subject, int parentResourceId, int resourceTypeId, String
resourceName,
+ CreateResourceHistory createResource(Subject subject, int parentResourceId, int
resourceTypeId, String resourceName,
Configuration pluginConfiguration, Configuration resourceConfiguration);
/**
* @see {@link
ResourceFactoryManagerRemote.createPackageBackedResource(Subject,int,int,String,Configuration,String,String,Integer,Configuration,byte[])
*/
- void createPackageBackedResource(Subject subject, int parentResourceId, int
newResourceTypeId,
+ CreateResourceHistory createPackageBackedResource(Subject subject, int
parentResourceId, int newResourceTypeId,
String newResourceName, Configuration pluginConfiguration, String packageName,
String packageVersion,
Integer architectureId, Configuration deploymentTimeConfiguration, byte[]
packageBits);
/**
* @see {@link ResourceFactoryManagerRemote.deleteResource(Subject,int)
*/
- void deleteResource(Subject subject, int resourceId);
+ DeleteResourceHistory deleteResource(Subject subject, int resourceId);
}
\ No newline at end of file
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceFactoryManagerRemote.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceFactoryManagerRemote.java
index 1c5633d..9d4f908 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceFactoryManagerRemote.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceFactoryManagerRemote.java
@@ -28,6 +28,8 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.resource.CreateDeletePolicy;
+import org.rhq.core.domain.resource.CreateResourceHistory;
+import org.rhq.core.domain.resource.DeleteResourceHistory;
import org.rhq.core.domain.resource.ResourceCreationDataType;
import org.rhq.enterprise.server.jaxb.adapter.ConfigurationAdapter;
import org.rhq.enterprise.server.system.ServerVersion;
@@ -57,7 +59,7 @@ public interface ResourceFactoryManagerRemote {
* @param resourceConfiguration resource configuration for the new resource
*/
@WebMethod
- void createResource( //
+ CreateResourceHistory createResource( //
@WebParam(name = "subject") Subject subject, //
@WebParam(name = "parentResourceId") int parentResourceId, //
@WebParam(name = "resourceTypeId") int resourceTypeId, //
@@ -87,7 +89,7 @@ public interface ResourceFactoryManagerRemote {
* @param packageBits content of the package to create
*/
@WebMethod
- void createPackageBackedResource(//
+ CreateResourceHistory createPackageBackedResource(//
@WebParam(name = "subject") Subject subject, //
@WebParam(name = "parentResourceId") int parentResourceId, //
@WebParam(name = "newResourceTypeId") int newResourceTypeId, //
@@ -112,7 +114,7 @@ public interface ResourceFactoryManagerRemote {
* @param resourceId resource being deleted
*/
@WebMethod
- void deleteResource( //
+ DeleteResourceHistory deleteResource( //
@WebParam(name = "subject") Subject subject, //
@WebParam(name = "resourceId") int resourceId);
}
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
index 96dcdd2..0062843 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
@@ -104,6 +104,8 @@ import
org.rhq.core.domain.measurement.composite.MeasurementDataNumericHighLowCo
import org.rhq.core.domain.operation.GroupOperationHistory;
import org.rhq.core.domain.operation.OperationDefinition;
import org.rhq.core.domain.operation.ResourceOperationHistory;
+import org.rhq.core.domain.resource.CreateResourceHistory;
+import org.rhq.core.domain.resource.DeleteResourceHistory;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceCategory;
import org.rhq.core.domain.resource.ResourceType;
@@ -782,25 +784,25 @@ public class WebservicesManagerBean implements WebservicesRemote {
//REPOMANAGER: END ----------------------------------
//RESOURCEFACTORYMANAGER: BEGIN ----------------------------------
- public void createResource(Subject subject, int parentResourceId, int resourceTypeId,
String resourceName,
+ public CreateResourceHistory createResource(Subject subject, int parentResourceId,
int resourceTypeId, String resourceName,
Configuration pluginConfiguration, Configuration resourceConfiguration) {
- resourceFactoryManager.createResource(subject, parentResourceId, resourceTypeId,
resourceName,
+ return resourceFactoryManager.createResource(subject, parentResourceId,
resourceTypeId, resourceName,
pluginConfiguration, resourceConfiguration);
}
- public void createPackageBackedResource(Subject subject, int parentResourceId, int
newResourceTypeId,
+ public CreateResourceHistory createPackageBackedResource(Subject subject, int
parentResourceId, int newResourceTypeId,
String newResourceName,//
@XmlJavaTypeAdapter(value = ConfigurationAdapter.class)//
Configuration pluginConfiguration, String packageName, String packageVersion,
Integer architectureId,//
@XmlJavaTypeAdapter(value = ConfigurationAdapter.class)//
Configuration deploymentTimeConfiguration, byte[] packageBits) {
- resourceFactoryManager.createPackageBackedResource(subject, parentResourceId,
newResourceTypeId,
+ return resourceFactoryManager.createPackageBackedResource(subject,
parentResourceId, newResourceTypeId,
newResourceName, pluginConfiguration, packageName, packageVersion,
architectureId,
deploymentTimeConfiguration, packageBits);
}
- public void deleteResource(Subject subject, int resourceId) {
- resourceFactoryManager.deleteResource(subject, resourceId);
+ public DeleteResourceHistory deleteResource(Subject subject, int resourceId) {
+ return resourceFactoryManager.deleteResource(subject, resourceId);
}
//RESOURCEFACTORYMANAGER: END ----------------------------------
commit 9a36c9d68e27aead173d141e7819b2a16d6c9236
Author: Joseph Marques <joseph(a)redhat.com>
Date: Thu Sep 23 07:49:43 2010 -0400
simplify the process of creating Criteria objects from a DSRequest
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupDataSourceField.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupDataSourceField.java
new file mode 100644
index 0000000..d7deadd
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupDataSourceField.java
@@ -0,0 +1,71 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.rhq.enterprise.gui.coregui.client.inventory.groups;
+
+import com.smartgwt.client.widgets.grid.ListGridField;
+
+public enum ResourceGroupDataSourceField {
+
+ NAME("name", "Name"),
+
+ DESCRIPTION("description", "Description"),
+
+ TYPE("typeName", "Type"),
+
+ PLUGIN("pluginName", "Plugin"),
+
+ CATEGORY("category", "Category");
+
+ /**
+ * Corresponds to a property name of Resource
+ */
+ private String propertyName;
+
+ /**
+ * The display name for the field or property
+ */
+ private String title;
+
+ private ResourceGroupDataSourceField(String propertyName, String title) {
+ this.propertyName = propertyName;
+ this.title = title;
+ }
+
+ public String propertyName() {
+ return propertyName;
+ }
+
+ public String title() {
+ return title;
+ }
+
+ public ListGridField getListGridField() {
+ return new ListGridField(propertyName, title);
+ }
+
+ public ListGridField getListGridField(int width) {
+ return new ListGridField(propertyName, title, width);
+ }
+
+}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupsDataSource.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupsDataSource.java
index 91bf412..2a02c99 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupsDataSource.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupsDataSource.java
@@ -18,6 +18,9 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.groups;
+import static
org.rhq.enterprise.gui.coregui.client.inventory.groups.ResourceGroupDataSourceField.CATEGORY;
+import static
org.rhq.enterprise.gui.coregui.client.inventory.groups.ResourceGroupDataSourceField.NAME;
+
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
@@ -93,32 +96,13 @@ public class ResourceGroupsDataSource extends
RPCDataSource<ResourceGroup> {
protected ResourceGroupCriteria getFetchCriteria(final DSRequest request) {
ResourceGroupCriteria criteria = new ResourceGroupCriteria();
-
criteria.setPageControl(getPageControl(request));
- if (request.getCriteria().getValues().get("name") != null) {
- criteria.addFilterName((String)
request.getCriteria().getValues().get("name"));
- }
-
- if (request.getCriteria().getValues().get("category") != null) {
- criteria.addFilterGroupCategory(GroupCategory.valueOf(((String)
request.getCriteria().getValues().get(
- "category")).toUpperCase()));
- }
-
- if (request.getCriteria().getValues().get("downMemberCount") != null)
{
- criteria.addFilterDownMemberCount(Integer.parseInt((String)
request.getCriteria().getValues().get(
- "downMemberCount")));
- }
-
- if (request.getCriteria().getValues().get("explicitResourceId") !=
null) {
- criteria.addFilterExplicitResourceIds(Integer.parseInt((String)
request.getCriteria().getValues().get(
- "explicitResourceId")));
- }
-
- if (request.getCriteria().getValues().get("groupDefinitionId") != null)
{
- criteria.addFilterGroupDefinitionId(Integer.parseInt((String)
request.getCriteria().getValues().get(
- "groupDefinitionId")));
- }
+ criteria.addFilterName(getFilter(request, NAME.propertyName(), String.class));
+ criteria.addFilterGroupCategory(getFilter(request, CATEGORY.propertyName(),
GroupCategory.class));
+ criteria.addFilterDownMemberCount(getFilter(request, "downMemberCount",
Integer.class));
+ criteria.addFilterExplicitResourceIds(getFilter(request,
"explicitResourceId", Integer.class));
+ criteria.addFilterGroupDefinitionId(getFilter(request,
"groupDefinitionId", Integer.class));
return criteria;
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDataSourceField.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDataSourceField.java
index 8b81f4c..59b55e9 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDataSourceField.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDataSourceField.java
@@ -23,6 +23,8 @@
package org.rhq.enterprise.gui.coregui.client.inventory.resource;
+import com.smartgwt.client.widgets.grid.ListGridField;
+
public enum ResourceDataSourceField {
NAME("name", "Name"),
@@ -60,4 +62,12 @@ public enum ResourceDataSourceField {
return title;
}
+ public ListGridField getListGridField() {
+ return new ListGridField(propertyName, title);
+ }
+
+ public ListGridField getListGridField(int width) {
+ return new ListGridField(propertyName, title, width);
+ }
+
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java
index 71e6eee..766df27 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java
@@ -25,8 +25,6 @@ import static
org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceD
import static
org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.PLUGIN;
import static
org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.TYPE;
-import java.util.Map;
-
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
@@ -41,7 +39,6 @@ import org.rhq.core.domain.criteria.ResourceCriteria;
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceCategory;
-import org.rhq.core.domain.tagging.Tag;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
@@ -101,75 +98,22 @@ public class ResourceDatasource extends RPCDataSource<Resource>
{
});
}
- @SuppressWarnings("unchecked")
protected ResourceCriteria getFetchCriteria(final DSRequest request) {
-
ResourceCriteria criteria = new ResourceCriteria();
criteria.setPageControl(getPageControl(request));
- // TODO: This call is broken in 2.2,
http://code.google.com/p/smartgwt/issues/detail?id=490
- // when using AdvancedCriteria
- Map<String, Object> criteriaMap = request.getCriteria().getValues();
-
- if (criteriaMap.get("parentId") != null) {
- criteria.addFilterParentResourceId(Integer.parseInt((String)
criteriaMap.get("parentId")));
- }
-
- if (criteriaMap.get("id") != null) {
-
criteria.addFilterId(Integer.parseInt(request.getCriteria().getAttribute("id")));
- }
-
- if (criteriaMap.get("resourceIds") != null) {
- int[] ids =
request.getCriteria().getAttributeAsIntArray("resourceIds");
- Integer[] oids = new Integer[ids.length];
- for (int i = 0; i < ids.length; i++) {
- oids[i] = ids[i++];
- }
- criteria.addFilterIds(oids);
- }
-
- // Fetch member Resources of the group with the specified id.
- if (criteriaMap.get("groupId") != null) {
- int groupId = Integer.parseInt((String)
criteriaMap.get("groupId"));
- criteria.addFilterImplicitGroupIds(groupId);
- }
-
- if (criteriaMap.get(NAME.propertyName()) != null) {
- criteria.addFilterName((String) criteriaMap.get(NAME.propertyName()));
- }
-
- if (criteriaMap.get(CATEGORY.propertyName()) != null) {
- criteria.addFilterResourceCategory(ResourceCategory.valueOf(((String)
criteriaMap.get(CATEGORY
- .propertyName())).toUpperCase()));
- }
-
- if (criteriaMap.get(AVAILABILITY.propertyName()) != null) {
- criteria.addFilterCurrentAvailability(AvailabilityType.valueOf(((String)
criteriaMap.get(AVAILABILITY
- .propertyName())).toUpperCase()));
- }
-
- if (criteriaMap.get(TYPE.propertyName()) != null) {
- criteria.addFilterResourceTypeId(Integer.parseInt(((String)
criteriaMap.get(TYPE.propertyName()))));
- }
-
- if (criteriaMap.get(PLUGIN.propertyName()) != null) {
- criteria.addFilterPluginName((String)
criteriaMap.get(PLUGIN.propertyName()));
- }
-
- if (criteriaMap.get("tag") != null) {
- criteria.addFilterTag((Tag) criteriaMap.get("tag"));
- }
-
- if (criteriaMap.get("tagNamespace") != null) {
- criteria.addFilterTagNamespace((String)
criteriaMap.get("tagNamespace"));
- }
-
- if (criteriaMap.get("tagSemantic") != null) {
- criteria.addFilterTagSemantic((String)
criteriaMap.get("tagSemantic"));
- }
-
- if (criteriaMap.get("tagName") != null) {
- criteria.addFilterTagName((String) criteriaMap.get("tagName"));
- }
+
+ criteria.addFilterId(getFilter(request, "id", Integer.class));
+ criteria.addFilterParentResourceId(getFilter(request, "parentId",
Integer.class));
+ criteria.addFilterCurrentAvailability(getFilter(request,
AVAILABILITY.propertyName(), AvailabilityType.class));
+ criteria.addFilterResourceCategory(getFilter(request, CATEGORY.propertyName(),
ResourceCategory.class));
+ criteria.addFilterIds(getArrayFilter(request, "resourceIds",
Integer.class));
+ criteria.addFilterImplicitGroupIds(getFilter(request, "groupId",
Integer.class));
+ criteria.addFilterName(getFilter(request, NAME.propertyName(), String.class));
+ criteria.addFilterResourceTypeId(getFilter(request, TYPE.propertyName(),
Integer.class));
+ criteria.addFilterPluginName(getFilter(request, PLUGIN.propertyName(),
String.class));
+ criteria.addFilterTagNamespace(getFilter(request, "tagNamespace",
String.class));
+ criteria.addFilterTagSemantic(getFilter(request, "tagSemantic",
String.class));
+ criteria.addFilterTagName(getFilter(request, "tagName",
String.class));
return criteria;
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java
index 5b3ecf7..b61458f 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java
@@ -24,6 +24,7 @@ import java.util.List;
import java.util.Map;
import com.google.gwt.core.client.JavaScriptObject;
+import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
import com.smartgwt.client.data.DataSource;
@@ -241,4 +242,67 @@ public abstract class RPCDataSource<T> extends DataSource {
JSOHelper.apply(data, newRecord.getJsObj());
return newRecord;
}
+
+ @SuppressWarnings("unchecked")
+ public static <S> S[] getArrayFilter(DSRequest request, String paramName,
Class<S> type) {
+ System.out.println("Fetching array " + paramName + " (" +
type + ")");
+ Criteria criteria = request.getCriteria();
+ Map<String, Object> criteriaMap = criteria.getValues();
+
+ S[] resultArray = null;
+
+ Object value = (String) criteriaMap.get(paramName);
+ if (value == null) {
+ // nothing to do, result is already null
+ } else if (type == Integer.class) {
+ int[] intermediates = criteria.getAttributeAsIntArray(paramName);
+ resultArray = (S[]) new Integer[intermediates.length];
+ int index = 0;
+ for (int next : intermediates) {
+ resultArray[index++] = (S) (Integer) next;
+ }
+ } else if (type == String.class) {
+ String[] intermediates = criteria.getAttributeAsStringArray(paramName);
+ resultArray = (S[]) new String[intermediates.length];
+ int index = 0;
+ for (String next : intermediates) {
+ resultArray[index++] = (S) next;
+ }
+ } else {
+ throw new IllegalArgumentException("No support for passing array filters
of type " + type);
+ }
+
+ System.out.println("Result array = " + resultArray);
+
+ return resultArray;
+ }
+
+ @SuppressWarnings("unchecked")
+ public static <S> S getFilter(DSRequest request, String paramName,
Class<S> type) {
+ System.out.println("Fetching " + paramName + " (" + type +
")");
+ Criteria criteria = request.getCriteria();
+ Map<String, Object> criteriaMap = criteria.getValues();
+
+ S result = null;
+
+ Object value = criteriaMap.get(paramName);
+ if (value == null) {
+ // nothing to do, result is already null
+ } else {
+ String strValue = value.toString();
+ if (type == String.class) {
+ result = (S) strValue;
+ } else if (type == Integer.class) {
+ result = (S) Integer.valueOf(strValue);
+ } else if (type.isEnum()) {
+ result = (S) Enum.valueOf((Class<? extends Enum>) type,
strValue.toUpperCase());
+ } else {
+ result = (S) value; // otherwise presume the object is already that type,
and just cast it
+ }
+ }
+
+ System.out.println("Result = " + result);
+
+ return result;
+ }
}
commit fb3843196fe9fa6c29b90f9cf8ba5e510e19fa97
Author: Joseph Marques <joseph(a)redhat.com>
Date: Thu Sep 23 07:48:54 2010 -0400
greater resiliance when passing null-"ish" values to addFilterXXX Criteria
methods
diff --git
a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceCriteria.java
b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceCriteria.java
index 1eae4a3..0fd3a0a 100644
---
a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceCriteria.java
+++
b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceCriteria.java
@@ -22,7 +22,6 @@
*/
package org.rhq.core.domain.criteria;
-import java.util.Arrays;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
@@ -33,6 +32,7 @@ import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.domain.resource.InventoryStatus;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceCategory;
+import org.rhq.core.domain.util.CriteriaUtils;
import org.rhq.core.domain.util.PageOrdering;
/**
@@ -213,15 +213,15 @@ public class ResourceCriteria extends TaggedCriteria {
}
public void addFilterIds(Integer... filterIds) {
- this.filterIds = Arrays.asList(filterIds);
+ this.filterIds = CriteriaUtils.getListIgnoringNulls(filterIds);
}
public void addFilterExplicitGroupIds(Integer... filterExplicitGroupIds) {
- this.filterExplicitGroupIds = Arrays.asList(filterExplicitGroupIds);
+ this.filterExplicitGroupIds =
CriteriaUtils.getListIgnoringNulls(filterExplicitGroupIds);
}
public void addFilterImplicitGroupIds(Integer... filterImplicitGroupIds) {
- this.filterImplicitGroupIds = Arrays.asList(filterImplicitGroupIds);
+ this.filterImplicitGroupIds =
CriteriaUtils.getListIgnoringNulls(filterImplicitGroupIds);
}
public void addFilterRootResourceId(Integer filterRootResourceId) {
diff --git
a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceGroupCriteria.java
b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceGroupCriteria.java
index 1a54f0f..6f5c259 100644
---
a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceGroupCriteria.java
+++
b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceGroupCriteria.java
@@ -22,7 +22,6 @@
*/
package org.rhq.core.domain.criteria;
-import java.util.Arrays;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
@@ -31,6 +30,7 @@ import javax.xml.bind.annotation.XmlAccessorType;
import org.rhq.core.domain.resource.ResourceCategory;
import org.rhq.core.domain.resource.group.GroupCategory;
import org.rhq.core.domain.resource.group.ResourceGroup;
+import org.rhq.core.domain.util.CriteriaUtils;
import org.rhq.core.domain.util.PageOrdering;
/**
@@ -155,11 +155,11 @@ public class ResourceGroupCriteria extends TaggedCriteria {
}
public void addFilterExplicitResourceIds(Integer... filterExplicitResourceIds) {
- this.filterExplicitResourceIds = Arrays.asList(filterExplicitResourceIds);
+ this.filterExplicitResourceIds =
CriteriaUtils.getListIgnoringNulls(filterExplicitResourceIds);
}
public void addFilterImplicitResourceIds(Integer... filterImplicitResourceIds) {
- this.filterImplicitResourceIds = Arrays.asList(filterImplicitResourceIds);
+ this.filterImplicitResourceIds =
CriteriaUtils.getListIgnoringNulls(filterImplicitResourceIds);
}
/** A somewhat special case filter that ensures that all explicit group members
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/util/CriteriaUtils.java
b/modules/core/domain/src/main/java/org/rhq/core/domain/util/CriteriaUtils.java
new file mode 100644
index 0000000..d6ca5e2
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/util/CriteriaUtils.java
@@ -0,0 +1,58 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.rhq.core.domain.util;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * A dumping ground for utility methods used by Criteria objects. We specifically
don't want to put these into the
+ * Criteria abstract class because they would become part of the auto-completion
candidate list in the interactive CLI.
+ * Putting them here (in core/domain versus, say, core/util) will provide the necessary
utility without requiring
+ * further module inheritance at the coregui layer.
+ *
+ * @author Joseph Marques
+ */
+public class CriteriaUtils {
+ /*
+ * remove nulls from the passed items, and return the resultant list. return null if
no non-null items exist.
+ * this is useful in criteria addFilterXXX methods which take varargs, where a single
null argument should be
+ * interpreted as a null collection (instead of one-item collection whose first value
is null).
+ */
+ public static <T> List<T> getListIgnoringNulls(T[] items) {
+ if (items == null) {
+ return null;
+ }
+
+ List<T> results = new ArrayList<T>();
+ for (T next : items) {
+ if (next != null) {
+ results.add(next);
+ }
+ }
+ if (results.size() == 0) {
+ return null;
+ }
+ return results;
+ }
+}
commit 260db28def8e9f080f3cf4bda8df8a75e3bd81be
Author: Joseph Marques <joseph(a)redhat.com>
Date: Thu Sep 23 07:45:41 2010 -0400
fix SearchBarPane so it searches for both resources and groups
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/SearchBarPane.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/SearchBarPane.java
index 81abe79..0d920ef 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/SearchBarPane.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/SearchBarPane.java
@@ -18,13 +18,6 @@
*/
package org.rhq.enterprise.gui.coregui.client.menu;
-import static
org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.AVAILABILITY;
-import static
org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.CATEGORY;
-import static
org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.DESCRIPTION;
-import static
org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.NAME;
-import static
org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.PLUGIN;
-import static
org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.TYPE;
-
import com.google.gwt.user.client.History;
import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.types.TextMatchStyle;
@@ -42,7 +35,9 @@ import com.smartgwt.client.widgets.form.fields.events.ChangedHandler;
import com.smartgwt.client.widgets.grid.ListGridField;
import org.rhq.enterprise.gui.coregui.client.LinkManager;
+import
org.rhq.enterprise.gui.coregui.client.inventory.groups.ResourceGroupDataSourceField;
import org.rhq.enterprise.gui.coregui.client.inventory.groups.ResourceGroupsDataSource;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDatasource;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
@@ -69,8 +64,14 @@ public class SearchBarPane extends LocatableHLayout {
final SelectItem searchType = new SelectItem("searchType",
"Search");
searchType.setWidth(120);
- searchType.setValueMap("Resources", "Resource Groups",
"Bundles", "Packages", "Users", "Roles");
+ searchType.setValueMap("Resources", "Resource Groups"/*,
"Bundles", "Packages", "Users", "Roles"*/);
searchType.setValue("Resources");
+ searchType.addChangedHandler(new ChangedHandler() {
+ @Override
+ public void onChanged(ChangedEvent event) {
+ markForRedraw();
+ }
+ });
ComboBoxItem resourceSearch = getResourceComboBox();
resourceSearch.setShowIfCondition(new FormItemIfFunction() {
@@ -79,6 +80,13 @@ public class SearchBarPane extends LocatableHLayout {
}
});
+ ComboBoxItem groupSearch = getGroupComboBox();
+ groupSearch.setShowIfCondition(new FormItemIfFunction() {
+ public boolean execute(FormItem formItem, Object o, DynamicForm dynamicForm)
{
+ return
form.getValueAsString("searchType").equals("Resource Groups");
+ }
+ });
+
TextItem query = new TextItem("query");
query.setShowTitle(false);
@@ -88,7 +96,7 @@ public class SearchBarPane extends LocatableHLayout {
search.setShowTitle(false);
search.setIcon(Window.getImgURL("[SKIN]/actions/view.png"));
- form.setItems(searchType, resourceSearch, search, new SpacerItem());
+ form.setItems(searchType, resourceSearch, groupSearch, search, new
SpacerItem());
addMember(form);
}
@@ -103,19 +111,19 @@ public class SearchBarPane extends LocatableHLayout {
comboBox.setOptionDataSource(new ResourceDatasource());
- ListGridField nameField = new ListGridField(NAME.propertyName(), NAME.title(),
250);
- ListGridField descriptionField = new ListGridField(DESCRIPTION.propertyName(),
DESCRIPTION.title());
- ListGridField typeNameField = new ListGridField(TYPE.propertyName(),
TYPE.title(), 130);
- ListGridField pluginNameField = new ListGridField(PLUGIN.propertyName(),
PLUGIN.title(), 100);
- ListGridField categoryField = new ListGridField(CATEGORY.propertyName(),
CATEGORY.title(), 60);
- ListGridField availabilityField = new ListGridField(AVAILABILITY.propertyName(),
AVAILABILITY.title(), 55);
+ ListGridField nameField = ResourceDataSourceField.NAME.getListGridField(250);
+ ListGridField descriptionField =
ResourceDataSourceField.DESCRIPTION.getListGridField();
+ ListGridField typeNameField =
ResourceDataSourceField.TYPE.getListGridField(130);
+ ListGridField pluginNameField =
ResourceDataSourceField.PLUGIN.getListGridField(100);
+ ListGridField categoryField =
ResourceDataSourceField.CATEGORY.getListGridField(60);
+ ListGridField availabilityField =
ResourceDataSourceField.AVAILABILITY.getListGridField(55);
availabilityField.setAlign(Alignment.CENTER);
comboBox.setPickListFields(nameField, descriptionField, typeNameField,
pluginNameField, categoryField,
availabilityField);
comboBox.setValueField("id");
- comboBox.setDisplayField("name");
+ comboBox.setDisplayField(ResourceDataSourceField.NAME.propertyName());
comboBox.setPickListWidth(800);
comboBox.setTextMatchStyle(TextMatchStyle.SUBSTRING);
comboBox.setCompleteOnTab(true);
@@ -141,19 +149,44 @@ public class SearchBarPane extends LocatableHLayout {
}
private ComboBoxItem getGroupComboBox() {
- ComboBoxItem comboBox = new ComboBoxItem("query", "Query");
+ final ComboBoxItem comboBox = new ComboBoxItem("query",
"Query");
comboBox.setWidth(400);
comboBox.setShowTitle(false);
+ comboBox.setHint("group search");
+ comboBox.setShowHintInField(true);
comboBox.setOptionDataSource(new ResourceGroupsDataSource());
- ListGridField nameField = new ListGridField("name");
- ListGridField descriptionField = new ListGridField("description");
- comboBox.setPickListFields(nameField, descriptionField);
+
+ ListGridField nameField =
ResourceGroupDataSourceField.NAME.getListGridField(250);
+ ListGridField descriptionField =
ResourceGroupDataSourceField.DESCRIPTION.getListGridField();
+ ListGridField typeNameField =
ResourceGroupDataSourceField.TYPE.getListGridField(130);
+ ListGridField pluginNameField =
ResourceGroupDataSourceField.PLUGIN.getListGridField(100);
+ ListGridField categoryField =
ResourceGroupDataSourceField.CATEGORY.getListGridField(105);
+
+ comboBox.setPickListFields(nameField, descriptionField, typeNameField,
pluginNameField, categoryField);
comboBox.setValueField("id");
- comboBox.setDisplayField("name");
- comboBox.setPickListWidth(600);
+ comboBox.setDisplayField(ResourceGroupDataSourceField.NAME.propertyName());
+ comboBox.setPickListWidth(800);
comboBox.setTextMatchStyle(TextMatchStyle.SUBSTRING);
+ comboBox.setCompleteOnTab(true);
+
+ comboBox.addChangedHandler(new ChangedHandler() {
+ public void onChanged(ChangedEvent changedEvent) {
+ try {
+ Integer groupId = (Integer) changedEvent.getValue();
+ comboBox.setValue("");
+
+ String link = LinkManager.getResourceGroupLink(groupId);
+ if (!link.contains("#")) {
+ com.google.gwt.user.client.Window.Location.assign(link);
+ } else {
+ History.newItem(link.substring(1));
+ }
+ } catch (Exception e) {
+ }
+ }
+ });
return comboBox;
}
commit a0e563db21d42cc467bd4e8102d1ae9dd2db450f
Author: Joseph Marques <joseph(a)redhat.com>
Date: Thu Sep 23 07:41:39 2010 -0400
make sure to create contentCanvas and sectionStack early
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java
index c6d5289..01f23a2 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java
@@ -95,6 +95,19 @@ public class InventoryView extends LocatableHLayout implements
BookmarkableView
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) {
@@ -111,19 +124,6 @@ public class InventoryView extends LocatableHLayout implements
BookmarkableView
}
private void finishOnInit(Set<Permission> globalPermissions) {
- 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();
-
buildResourcesSection(globalPermissions);
buildGroupsSection(globalPermissions);
commit 3321fe23ca85876b6fff148737f6a58112e2c6c1
Author: Joseph Marques <joseph(a)redhat.com>
Date: Thu Sep 23 06:51:22 2010 -0400
never change the internal state of a Criteria object, if the filter is NULL
diff --git
a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/TaggedCriteria.java
b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/TaggedCriteria.java
index 6ef2ce6..effbb4e 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/TaggedCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/TaggedCriteria.java
@@ -51,6 +51,9 @@ public abstract class TaggedCriteria extends Criteria {
}
public void addFilterTagNamespace(String filterTagNamespace) {
+ if (filterTagNamespace == null) {
+ return; // do nothing if the filter is empty
+ }
if (this.filterTag == null) {
this.filterTag = new Tag();
}
@@ -58,6 +61,9 @@ public abstract class TaggedCriteria extends Criteria {
}
public void addFilterTagSemantic(String filterTagSemantic) {
+ if (filterTagSemantic == null) {
+ return; // do nothing if the filter is empty
+ }
if (this.filterTag == null) {
this.filterTag = new Tag();
}
@@ -65,6 +71,9 @@ public abstract class TaggedCriteria extends Criteria {
}
public void addFilterTagName(String filterTagName) {
+ if (filterTagName == null) {
+ return; // do nothing if the filter is empty
+ }
if (this.filterTag == null) {
this.filterTag = new Tag();
}
commit 37633f6d8e7f5ceb222a415db1b9521258d46adf
Author: Joseph Marques <joseph(a)redhat.com>
Date: Thu Sep 23 06:45:10 2010 -0400
fix tagged view, so all tables that are tiled under it render correctly
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/tag/TaggedView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/tag/TaggedView.java
index 981852e..66ff323 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/tag/TaggedView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/tag/TaggedView.java
@@ -25,7 +25,6 @@ package org.rhq.enterprise.gui.coregui.client.report.tag;
import java.util.ArrayList;
import com.smartgwt.client.data.Criteria;
-import com.smartgwt.client.data.SortSpecifier;
import org.rhq.core.domain.tagging.Tag;
import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
@@ -91,10 +90,6 @@ public class TaggedView extends LocatableVLayout implements
BookmarkableView {
tileLayout.setTileWidth(getWidth() / 2 - 20);
addMember(tileLayout);
- ResourceSearchView resourceView = new ResourceSearchView(getLocatorId(),
criteria, "Tagged Resources",
- new SortSpecifier[] {}, new String[] { "pluginName",
"category", "currentAvailability" });
- tiles.add(resourceView);
-
BundlesListView bundlesView = new BundlesListView(getLocatorId(), criteria);
tiles.add(bundlesView);
@@ -108,6 +103,9 @@ public class TaggedView extends LocatableVLayout implements
BookmarkableView {
criteria);
tiles.add(bundleDestinationListView);
+ ResourceSearchView resourceView = new ResourceSearchView(getLocatorId(),
criteria, "Tagged Resources");
+ tiles.add(resourceView);
+
for (Table t : tiles) {
t.setShowFooter(false);
tileLayout.addTile(t);
commit 71a661acf8ce99a02f857bbd02a0c51bba5bebc3
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Wed Sep 22 18:29:17 2010 -0400
fix bug in restype cache that was preventing subcats from being fetched for restypes
that were loaded by a previous cache request; various minor refactoring of resource tree
code (better variable names, etc.)
diff --git
a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/ResourceType.java
b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/ResourceType.java
index 8218909..a94560d 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/ResourceType.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/ResourceType.java
@@ -739,6 +739,14 @@ public class ResourceType implements Serializable,
Comparable<ResourceType> {
this.subCategories.add(subCategory);
}
+ public Set<ProductVersion> getProductVersions() {
+ return productVersions;
+ }
+
+ public void setProductVersions(Set<ProductVersion> productVersions) {
+ this.productVersions = productVersions;
+ }
+
public int compareTo(ResourceType that) {
return this.name.compareTo(that.getName());
// TODO: Order by category too?
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
index a8472b8..1de6dd2 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
@@ -25,6 +25,7 @@ import java.util.EnumSet;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import com.google.gwt.user.client.rpc.AsyncCallback;
@@ -232,7 +233,7 @@ public class ConfigurationEditor extends LocatableVLayout {
ResourceTypeRepository.Cache.getInstance().getResourceTypes(new Integer[]
{ resourceTypeId },
EnumSet.of(ResourceTypeRepository.MetadataType.resourceConfigurationDefinition),
new ResourceTypeRepository.TypesLoadedCallback() {
- public void onTypesLoaded(HashMap<Integer, ResourceType>
types) {
+ public void onTypesLoaded(Map<Integer, ResourceType> types)
{
System.out.println("ConfigDef retreived in: " +
(System.currentTimeMillis() - start));
definition =
types.get(resourceTypeId).getResourceConfigurationDefinition();
if (definition == null) {
@@ -258,7 +259,7 @@ public class ConfigurationEditor extends LocatableVLayout {
ResourceTypeRepository.Cache.getInstance().getResourceTypes(new Integer[]
{ resourceTypeId },
EnumSet.of(ResourceTypeRepository.MetadataType.pluginConfigurationDefinition),
new ResourceTypeRepository.TypesLoadedCallback() {
- public void onTypesLoaded(HashMap<Integer, ResourceType>
types) {
+ public void onTypesLoaded(Map<Integer, ResourceType> types)
{
System.out.println("ConfigDef retreived in: " +
(System.currentTimeMillis() - start));
definition =
types.get(resourceTypeId).getPluginConfigurationDefinition();
if (definition == null) {
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tree/EnhancedTreeNode.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tree/EnhancedTreeNode.java
index 91303ee..89583b4 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tree/EnhancedTreeNode.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tree/EnhancedTreeNode.java
@@ -37,7 +37,8 @@ public class EnhancedTreeNode extends TreeNode {
StringBuilder buffer = new StringBuilder();
String className = this.getClass().getName();
String simpleClassName = className.substring(className.lastIndexOf(".")
+ 1);
- buffer.append(simpleClassName).append("[");
+ String innerClassName =
simpleClassName.substring(simpleClassName.lastIndexOf("$") + 1);
+ buffer.append(innerClassName).append("[");
String id = getID();
buffer.append("id=").append(id);
String parentId = getParentID();
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeView.java
index ba57920..acaca4a 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeView.java
@@ -25,6 +25,7 @@ package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.Map;
import java.util.Set;
import com.google.gwt.user.client.History;
@@ -69,7 +70,7 @@ public class ResourceGroupTreeView extends VLayout implements
BookmarkableView {
private ResourceGroupTreeContextMenu contextMenu;
private ResourceGroup rootResourceGroup;
- private HashMap<Integer, ResourceType> typeMap;
+ private Map<Integer, ResourceType> typeMap;
private ResourceGroup selectedGroup;
public ResourceGroupTreeView() {
@@ -226,7 +227,7 @@ public class ResourceGroupTreeView extends VLayout implements
BookmarkableView {
ResourceTypeRepository.Cache.getInstance().getResourceTypes(typeIds.toArray(new
Integer[typeIds.size()]),
new ResourceTypeRepository.TypesLoadedCallback() {
@Override
- public void onTypesLoaded(HashMap<Integer, ResourceType> types) {
+ public void onTypesLoaded(Map<Integer, ResourceType> types) {
ResourceGroupTreeView.this.typeMap = types;
loadTree(root);
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/NewResourceTreeView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/NewResourceTreeView.java
index 38dc487..bad1ada 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/NewResourceTreeView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/NewResourceTreeView.java
@@ -149,8 +149,8 @@ public class NewResourceTreeView extends LocatableVLayout {
event.getNode();
event.cancel();
- if (event.getNode() instanceof ResourceTreeDatasource.TypeTreeNode) {
- showContextMenu((ResourceTreeDatasource.TypeTreeNode)
event.getNode());
+ if (event.getNode() instanceof ResourceTreeDatasource.AutoGroupTreeNode)
{
+ showContextMenu((ResourceTreeDatasource.AutoGroupTreeNode)
event.getNode());
} else if (event.getNode() instanceof
ResourceTreeDatasource.ResourceTreeNode) {
showContextMenu((ResourceTreeDatasource.ResourceTreeNode)
event.getNode());
}
@@ -158,7 +158,7 @@ public class NewResourceTreeView extends LocatableVLayout {
});
}
- private void showContextMenu(ResourceTreeDatasource.TypeTreeNode node) {
+ private void showContextMenu(ResourceTreeDatasource.AutoGroupTreeNode node) {
contextMenu.setItems(new MenuItem(node.getName()));
contextMenu.showContextMenu();
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java
index 9b39e8a..ca3f8e6 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java
@@ -23,6 +23,7 @@ import java.util.EnumSet;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
@@ -168,7 +169,9 @@ public class ResourceTreeDatasource extends DataSource {
ResourceTypeRepository.Cache.getInstance().loadResourceTypes(
result,
- EnumSet.of(ResourceTypeRepository.MetadataType.operations,
ResourceTypeRepository.MetadataType.children,
+ EnumSet.of(
+ ResourceTypeRepository.MetadataType.operations,
+ ResourceTypeRepository.MetadataType.children,
ResourceTypeRepository.MetadataType.subCategory),
new ResourceTypeRepository.ResourceTypeLoadedCallback() {
public void onResourceTypeLoaded(List<Resource> result) {
@@ -197,39 +200,41 @@ public class ResourceTreeDatasource extends DataSource {
return introduceTypeAndCategoryNodes(nodes);
}
- private static TreeNode[] introduceTypeAndCategoryNodes(ResourceTreeNode[] nodes) {
+ private static TreeNode[] introduceTypeAndCategoryNodes(ResourceTreeNode[]
resourceNodes) {
List<TreeNode> updatedNodes = new ArrayList<TreeNode>();
// Maps category node IDs to the corresponding category nodes.
- Map<String, CategoryTreeNode> categories = new HashMap<String,
CategoryTreeNode>();
+ Map<String, SubCategoryTreeNode> subcategoryNodes = new HashMap<String,
SubCategoryTreeNode>();
// Maps type node IDs to the corresponding type nodes.
- Map<String, TypeTreeNode> types = new HashMap<String,
TypeTreeNode>();
+ Map<String, AutoGroupTreeNode> autogroupNodes = new HashMap<String,
AutoGroupTreeNode>();
- for (ResourceTreeNode node : nodes) {
- updatedNodes.add(node);
+ for (ResourceTreeNode resourceNode : resourceNodes) {
+ updatedNodes.add(resourceNode);
- Resource resource = node.getResource();
+ Resource resource = resourceNode.getResource();
ResourceType type = resource.getResourceType();
if (type.getCategory() != ResourceCategory.PLATFORM) {
- String typeNodeId = TypeTreeNode.idOf(resource);
- if (!types.containsKey(typeNodeId)) {
+ String autogroupNodeId = AutoGroupTreeNode.idOf(resource);
+ if (!autogroupNodes.containsKey(autogroupNodeId)) {
Resource parentResource = resource.getParentResource();
- ResourceSubCategory category = type.getSubCategory();
- if (category != null) {
+ ResourceSubCategory subcategory = type.getSubCategory();
+ if (subcategory != null) {
+ System.out.println("Processing " + subcategory +
"...");
do {
- String categoryNodeId = CategoryTreeNode.idOf(category,
parentResource);
- CategoryTreeNode categoryNode =
categories.get(categoryNodeId);
- if (categoryNode == null) {
- categoryNode = new CategoryTreeNode(category,
parentResource);
- categories.put(categoryNode.getID(), categoryNode);
- updatedNodes.add(categoryNode);
+ String subcategoryNodeId =
SubCategoryTreeNode.idOf(subcategory, parentResource);
+ if (!subcategoryNodes.containsKey(subcategoryNodeId)) {
+ SubCategoryTreeNode subcategoryNode = new
SubCategoryTreeNode(subcategory, parentResource);
+ subcategoryNodes.put(subcategoryNode.getID(),
subcategoryNode);
+ System.out.println("Adding " + subcategoryNode
+ " to tree...");
+ updatedNodes.add(subcategoryNode);
}
- } while ((category = category.getParentSubCategory()) != null);
+ } while ((subcategory = subcategory.getParentSubCategory()) !=
null);
}
if (!type.isSingleton()) {
- TypeTreeNode typeNode = new TypeTreeNode(resource);
- updatedNodes.add(typeNode);
- types.put(typeNodeId, typeNode);
+ AutoGroupTreeNode autogroupNode = new
AutoGroupTreeNode(resource);
+ autogroupNodes.put(autogroupNodeId, autogroupNode);
+ System.out.println("Adding " + autogroupNode + "
to tree...");
+ updatedNodes.add(autogroupNode);
}
}
}
@@ -238,15 +243,18 @@ public class ResourceTreeDatasource extends DataSource {
return updatedNodes.toArray(new TreeNode[updatedNodes.size()]);
}
- public static class CategoryTreeNode extends EnhancedTreeNode {
- public CategoryTreeNode(ResourceSubCategory category, Resource parentResource) {
+ /**
+ * The folder node for a Resource subcategory.
+ */
+ public static class SubCategoryTreeNode extends EnhancedTreeNode {
+ public SubCategoryTreeNode(ResourceSubCategory category, Resource parentResource)
{
String id = idOf(category, parentResource);
setID(id);
setAttribute(Attributes.ID, id);
ResourceSubCategory parentCategory = category.getParentSubCategory();
String parentId = (parentCategory != null) ?
- CategoryTreeNode.idOf(parentCategory, parentResource) :
+ SubCategoryTreeNode.idOf(parentCategory, parentResource) :
ResourceTreeNode.idOf(parentResource);
setParentID(parentId);
setAttribute(Attributes.PARENT_ID, parentId);
@@ -255,6 +263,8 @@ public class ResourceTreeDatasource extends DataSource {
String name = category.getDisplayName();
setName(name);
setAttribute(Attributes.NAME, name);
+
+ setAttribute(Attributes.DESCRIPTION, category.getDescription());
}
public static String idOf(ResourceSubCategory category, Resource parentResource)
{
@@ -263,10 +273,10 @@ public class ResourceTreeDatasource extends DataSource {
}
/**
- * The Resource type folder node for an autogroup.
+ * The folder node for a Resource autogroup.
*/
- public static class TypeTreeNode extends EnhancedTreeNode {
- private TypeTreeNode(Resource resource) {
+ public static class AutoGroupTreeNode extends EnhancedTreeNode {
+ private AutoGroupTreeNode(Resource resource) {
String id = idOf(resource);
setID(id);
setAttribute(Attributes.ID, id);
@@ -281,21 +291,23 @@ public class ResourceTreeDatasource extends DataSource {
String name = StringUtility.pluralize(type.getName());
setName(name);
setAttribute(Attributes.NAME, name);
+
+ setAttribute(Attributes.DESCRIPTION, type.getDescription());
}
public static String idOf(Resource resource) {
Resource parentResource = resource.getParentResource();
- return (parentResource != null) ? "type" +
resource.getResourceType().getId() + "_"
- + parentResource.getId() : null;
+ return (parentResource != null) ?
+ "autogroup" + resource.getResourceType().getId() +
"_" + parentResource.getId() :
+ null;
}
public static String parentIdOf(Resource resource) {
ResourceType type = resource.getResourceType();
ResourceSubCategory parentCategory = type.getSubCategory();
- String parentId = (parentCategory != null) ?
- CategoryTreeNode.idOf(parentCategory, resource.getParentResource()) :
+ return (parentCategory != null) ?
+ SubCategoryTreeNode.idOf(parentCategory, resource.getParentResource()) :
ResourceTreeNode.idOf(resource.getParentResource());
- return parentId;
}
}
@@ -313,8 +325,8 @@ public class ResourceTreeDatasource extends DataSource {
String parentId;
if (parentResource != null) {
parentId = resource.getResourceType().isSingleton() ?
- TypeTreeNode.parentIdOf(resource) :
- TypeTreeNode.idOf(resource);
+ AutoGroupTreeNode.parentIdOf(resource) :
+ AutoGroupTreeNode.idOf(resource);
}
else {
parentId = null;
@@ -325,17 +337,20 @@ public class ResourceTreeDatasource extends DataSource {
// System.out.println(id + " / " + parentId);
// setAttribute("parentKey",
resource.getParentResource() == null ? 0 : (resource.getParentResource().getId() +
resource.getResourceType().getName()));
- setName(resource.getName());
- setAttribute(Attributes.NAME, resource.getName());
+ String name = resource.getName();
+ setName(name);
+ setAttribute(Attributes.NAME, name);
+
setAttribute(Attributes.DESCRIPTION, resource.getDescription());
+
ResourceAvailability currentAvail = resource.getCurrentAvailability();
setAttribute(
"currentAvailability",
(null != currentAvail && currentAvail.getAvailabilityType() ==
AvailabilityType.UP) ? "/images/icons/availability_green_16.png"
: "/images/icons/availability_red_16.png");
- setIsFolder((resource.getResourceType().getChildResourceTypes() != null
&& !resource.getResourceType()
- .getChildResourceTypes().isEmpty()));
+ Set<ResourceType> childTypes =
resource.getResourceType().getChildResourceTypes();
+ setIsFolder((childTypes != null && !childTypes.isEmpty()));
}
public Resource getResource() {
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
index 418a334..a03acaf 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
@@ -153,8 +153,8 @@ public class ResourceTreeView extends LocatableVLayout {
event.getNode();
event.cancel();
- if (event.getNode() instanceof ResourceTreeDatasource.TypeTreeNode) {
- showContextMenu((ResourceTreeDatasource.TypeTreeNode)
event.getNode());
+ if (event.getNode() instanceof ResourceTreeDatasource.AutoGroupTreeNode)
{
+ showContextMenu((ResourceTreeDatasource.AutoGroupTreeNode)
event.getNode());
} else if (event.getNode() instanceof
ResourceTreeDatasource.ResourceTreeNode) {
showContextMenu((ResourceTreeDatasource.ResourceTreeNode)
event.getNode());
}
@@ -196,18 +196,18 @@ public class ResourceTreeView extends LocatableVLayout {
}
}
- private void showContextMenu(ResourceTreeDatasource.TypeTreeNode node) {
-
+ private void showContextMenu(ResourceTreeDatasource.AutoGroupTreeNode node) {
contextMenu.setItems(new MenuItem(node.getName()));
contextMenu.showContextMenu();
-
}
private void showContextMenu(final ResourceTreeDatasource.ResourceTreeNode node) {
ResourceType type = node.getResource().getResourceType();
ResourceTypeRepository.Cache.getInstance().getResourceTypes(
type.getId(),
- EnumSet.of(ResourceTypeRepository.MetadataType.operations,
ResourceTypeRepository.MetadataType.children,
+ EnumSet.of(
+ ResourceTypeRepository.MetadataType.operations,
+ ResourceTypeRepository.MetadataType.children,
ResourceTypeRepository.MetadataType.subCategory,
ResourceTypeRepository.MetadataType.pluginConfigurationDefinition,
ResourceTypeRepository.MetadataType.resourceConfigurationDefinition),
@@ -501,8 +501,8 @@ public class ResourceTreeView extends LocatableVLayout {
addMember(treeGrid);
treeGrid.fetchData(treeGrid.getCriteria(), new DSCallback() {
- public void execute(DSResponse dsResponse, Object o,
DSRequest dsRequest) {
- System.out.println("Here!!!!!");
+ public void execute(DSResponse response, Object rawData,
DSRequest request) {
+ System.out.println("Done fetching data for
tree.");
updateBreadcrumbs();
}
});
@@ -539,11 +539,10 @@ public class ResourceTreeView extends LocatableVLayout {
ResourceTypeRepository.MetadataType.subCategory),
new ResourceTypeRepository.ResourceTypeLoadedCallback() {
public void onResourceTypeLoaded(List<Resource>
result) {
-
- TreeUtility.printTree(treeGrid.getTree());
-
treeGrid.getTree().linkNodes(ResourceTreeDatasource.buildNodes(result));
+ //TreeUtility.printTree(treeGrid.getTree());
+
TreeNode selectedNode =
treeGrid.getTree().findById(resourceNodeId);
if (selectedNode != null) {
treeGrid.deselectAllRecords();
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/type/ResourceTypeRepository.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/type/ResourceTypeRepository.java
index d488d14..cfa51bf 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/type/ResourceTypeRepository.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/type/ResourceTypeRepository.java
@@ -40,6 +40,8 @@ import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.gwt.ResourceTypeGWTServiceAsync;
/**
+ * A cache for ResourceTypes and their various fields. Fields are only fetched as
needed.
+ *
* @author Greg Hinkle
*/
public class ResourceTypeRepository {
@@ -66,7 +68,7 @@ public class ResourceTypeRepository {
}
public static interface TypesLoadedCallback {
- void onTypesLoaded(HashMap<Integer, ResourceType> types);
+ void onTypesLoaded(Map<Integer, ResourceType> types);
}
public static interface ResourceTypeLoadedCallback {
@@ -97,7 +99,7 @@ public class ResourceTypeRepository {
types.add(res.getResourceType().getId());
}
getResourceTypes(types.toArray(new Integer[types.size()]), metadataTypes, new
TypesLoadedCallback() {
- public void onTypesLoaded(HashMap<Integer, ResourceType> types) {
+ public void onTypesLoaded(Map<Integer, ResourceType> types) {
for (Resource res : resources) {
res.setResourceType(types.get(res.getResourceType().getId()));
}
@@ -130,7 +132,7 @@ public class ResourceTypeRepository {
types.add(group.getResourceType().getId());
}
getResourceTypes(types.toArray(new Integer[types.size()]), metadataTypes, new
TypesLoadedCallback() {
- public void onTypesLoaded(HashMap<Integer, ResourceType> types) {
+ public void onTypesLoaded(Map<Integer, ResourceType> types) {
for (ResourceGroup group : groups) {
group.setResourceType(types.get(group.getResourceType().getId()));
}
@@ -150,7 +152,7 @@ public class ResourceTypeRepository {
public void getResourceTypes(final Integer resourceTypeId, final
EnumSet<MetadataType> metadataTypes,
final TypeLoadedCallback callback) {
getResourceTypes(new Integer[] { resourceTypeId }, metadataTypes, new
TypesLoadedCallback() {
- public void onTypesLoaded(HashMap<Integer, ResourceType> types) {
+ public void onTypesLoaded(Map<Integer, ResourceType> types) {
if (callback != null) {
callback.onTypesLoaded(types.get(resourceTypeId));
}
@@ -162,9 +164,9 @@ public class ResourceTypeRepository {
final TypesLoadedCallback callback) {
ResourceTypeCriteria criteria = new ResourceTypeCriteria();
- final HashMap<Integer, ResourceType> cachedTypes = new HashMap<Integer,
ResourceType>();
+ final Map<Integer, ResourceType> cachedTypes = new HashMap<Integer,
ResourceType>();
- ArrayList<Integer> typesNeeded = new ArrayList<Integer>();
+ List<Integer> typesNeeded = new ArrayList<Integer>();
if (resourceTypeIds == null) {
//preload all
} else {
@@ -191,39 +193,41 @@ public class ResourceTypeRepository {
if (metadataTypes != null) {
for (MetadataType metadataType : metadataTypes) {
switch (metadataType) {
- case children:
- criteria.fetchChildResourceTypes(true);
- break;
- case content:
- criteria.fetchPackageTypes(true);
- break;
- case measurements:
- criteria.fetchMetricDefinitions(true);
- break;
- case operations:
- criteria.fetchOperationDefinitions(true);
- break;
- case events:
- criteria.fetchEventDefinitions(true);
- break;
- case pluginConfigurationDefinition:
- criteria.fetchPluginConfigurationDefinition(true);
- break;
- case resourceConfigurationDefinition:
- criteria.fetchResourceConfigurationDefinition(true);
- break;
- case subCategory:
- criteria.fetchSubCategory(true);
- break;
- case parentTypes:
- criteria.fetchParentResourceTypes(true);
- break;
- case processScans:
- criteria.fetchProcessScans(true);
- break;
- case productVersions:
- criteria.fetchProductVersions(true);
- break;
+ case children:
+ criteria.fetchChildResourceTypes(true);
+ break;
+ case content:
+ criteria.fetchPackageTypes(true);
+ break;
+ case events:
+ criteria.fetchEventDefinitions(true);
+ break;
+ case measurements:
+ criteria.fetchMetricDefinitions(true);
+ break;
+ case operations:
+ criteria.fetchOperationDefinitions(true);
+ break;
+ case parentTypes:
+ criteria.fetchParentResourceTypes(true);
+ break;
+ case pluginConfigurationDefinition:
+ criteria.fetchPluginConfigurationDefinition(true);
+ break;
+ case processScans:
+ criteria.fetchProcessScans(true);
+ break;
+ case productVersions:
+ criteria.fetchProductVersions(true);
+ break;
+ case resourceConfigurationDefinition:
+ criteria.fetchResourceConfigurationDefinition(true);
+ break;
+ case subCategory:
+ criteria.fetchSubCategory(true);
+ break;
+ default:
+ System.err.println("ERROR: metadataType " +
metadataType.name() + " not incorporated into ResourceType criteria.");
}
}
}
@@ -231,7 +235,7 @@ public class ResourceTypeRepository {
criteria.setPageControl(PageControl.getUnlimitedInstance());
System.out.println("Loading " + typesNeeded.size()
- + ((metadataTypes != null) ? (" types: " +
metadataTypes.toString()) : ""));
+ + ((metadataTypes != null) ? (" types: " + metadataTypes) :
""));
resourceTypeService.findResourceTypesByCriteria(criteria, new
AsyncCallback<PageList<ResourceType>>() {
public void onFailure(Throwable caught) {
@@ -245,29 +249,43 @@ public class ResourceTypeRepository {
if (metadataTypes != null) {
for (MetadataType metadataType : metadataTypes) {
switch (metadataType) {
- case children:
-
cachedType.setChildResourceTypes(type.getChildResourceTypes());
- break;
- case operations:
-
cachedType.setOperationDefinitions(type.getOperationDefinitions());
- break;
- case measurements:
-
cachedType.setMetricDefinitions(type.getMetricDefinitions());
- break;
- case content:
- cachedType.setPackageTypes(type.getPackageTypes());
- break;
- case events:
- cachedType.setPackageTypes(type.getPackageTypes());
- break;
- case pluginConfigurationDefinition:
- cachedType
-
.setPluginConfigurationDefinition(type.getPluginConfigurationDefinition());
- break;
- case resourceConfigurationDefinition:
- cachedType.setResourceConfigurationDefinition(type
- .getResourceConfigurationDefinition());
- break;
+ case children:
+
cachedType.setChildResourceTypes(type.getChildResourceTypes());
+ break;
+ case content:
+
cachedType.setPackageTypes(type.getPackageTypes());
+ break;
+ case events:
+
cachedType.setPackageTypes(type.getPackageTypes());
+ break;
+ case measurements:
+
cachedType.setMetricDefinitions(type.getMetricDefinitions());
+ break;
+ case operations:
+
cachedType.setOperationDefinitions(type.getOperationDefinitions());
+ break;
+ case parentTypes:
+
cachedType.setParentResourceTypes(type.getParentResourceTypes());
+ break;
+ case pluginConfigurationDefinition:
+ cachedType
+
.setPluginConfigurationDefinition(type.getPluginConfigurationDefinition());
+ break;
+ case processScans:
+
cachedType.setProcessScans(type.getProcessScans());
+ break;
+ case productVersions:
+
cachedType.setProductVersions(type.getProductVersions());
+ break;
+ case resourceConfigurationDefinition:
+
cachedType.setResourceConfigurationDefinition(type
+ .getResourceConfigurationDefinition());
+ break;
+ case subCategory:
+
cachedType.setSubCategory(type.getSubCategory());
+ break;
+ default:
+ System.err.println("ERROR: metadataType
" + metadataType.name() + " not merged into cached ResourceType.");
}
}
}
@@ -294,8 +312,8 @@ public class ResourceTypeRepository {
public void preloadAll() {
getResourceTypes((Integer[]) null, EnumSet.allOf(MetadataType.class), new
TypesLoadedCallback() {
- public void onTypesLoaded(HashMap<Integer, ResourceType> types) {
- System.out.println("Preloaded [" + types.size() + "]
resource types");
+ public void onTypesLoaded(Map<Integer, ResourceType> types) {
+ System.out.println("Preloaded [" + types.size() + "]
Resource types.");
}
});
}
diff --git a/modules/jopr/etc/jbas5-jnp-client/client.sh
b/modules/jopr/etc/jbas5-jnp-client/client.sh
index 3dc0f94..240f137 100644
--- a/modules/jopr/etc/jbas5-jnp-client/client.sh
+++ b/modules/jopr/etc/jbas5-jnp-client/client.sh
@@ -9,7 +9,7 @@
MAIN_JAR_NAME=jbas5-jnp-client-1.0.jar
MAIN_CLASS=test.RmiClient
-JBOSS_HOME=/devel/jboss-5.1.0.CR1
+JBOSS_HOME=/home/ips/Applications/jboss-6.0.0-SNAPSHOT
JAVA_OPTS="-Xdebug
-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8788"
@@ -43,29 +43,29 @@ JAVA=$JAVA_HOME/bin/java
# only include jbossall-client.jar in classpath, if
# JBOSS_CLASSPATH was not yet set
#if not "%JBOSS_CLASSPATH%" == "" GOTO HAVE_JB_CP
-# set JBOSS_CLASSPATH=%JBOSS_HOME%/client/jbossall-client.jar
+JBOSS_CLASSPATH=$JBOSS_HOME/client/jbossall-client.jar
# For the call to new InitialContext() (using
org.jnp.interfaces.NamingContextFactory)...
-JBOSS_CLASSPATH=$JBOSS_CLASSPATH:$JBOSS_HOME/client/jnp-client.jar
-JBOSS_CLASSPATH=$JBOSS_CLASSPATH:$JBOSS_HOME/common/lib/jboss-security-aspects.jar
-JBOSS_CLASSPATH=$JBOSS_CLASSPATH:$JBOSS_HOME/client/jbosssx-client.jar
-JBOSS_CLASSPATH=$JBOSS_CLASSPATH:$JBOSS_HOME/client/jboss-aop-client.jar
-JBOSS_CLASSPATH=$JBOSS_CLASSPATH:$JBOSS_HOME/client/jboss-common-core.jar
+#JBOSS_CLASSPATH=$JBOSS_CLASSPATH:$JBOSS_HOME/client/jnp-client.jar
+#JBOSS_CLASSPATH=$JBOSS_CLASSPATH:$JBOSS_HOME/common/lib/jboss-security-aspects.jar
+#JBOSS_CLASSPATH=$JBOSS_CLASSPATH:$JBOSS_HOME/client/jbosssx-client.jar
+#JBOSS_CLASSPATH=$JBOSS_CLASSPATH:$JBOSS_HOME/client/jboss-aop-client.jar
+#JBOSS_CLASSPATH=$JBOSS_CLASSPATH:$JBOSS_HOME/client/jboss-common-core.jar
# For the call to InitialContext.lookup()...
-JBOSS_CLASSPATH=$JBOSS_CLASSPATH:$JBOSS_HOME/client/jboss-#oting.jar
-JBOSS_CLASSPATH=$JBOSS_CLASSPATH:$JBOSS_HOME/client/jboss-aspect-jdk50-client.jar
-JBOSS_CLASSPATH=$JBOSS_CLASSPATH:$JBOSS_HOME/client/trove.jar
-JBOSS_CLASSPATH=$JBOSS_CLASSPATH:$JBOSS_HOME/client/javassist.jar
-JBOSS_CLASSPATH=$JBOSS_CLASSPATH:$JBOSS_HOME/client/jboss-security-spi.jar
-JBOSS_CLASSPATH=$JBOSS_CLASSPATH:$JBOSS_HOME/client/jboss-javaee.jar
+#JBOSS_CLASSPATH=$JBOSS_CLASSPATH:$JBOSS_HOME/client/jboss-#oting.jar
+#JBOSS_CLASSPATH=$JBOSS_CLASSPATH:$JBOSS_HOME/client/jboss-aspect-jdk50-client.jar
+#JBOSS_CLASSPATH=$JBOSS_CLASSPATH:$JBOSS_HOME/client/trove.jar
+#JBOSS_CLASSPATH=$JBOSS_CLASSPATH:$JBOSS_HOME/client/javassist.jar
+#JBOSS_CLASSPATH=$JBOSS_CLASSPATH:$JBOSS_HOME/client/jboss-security-spi.jar
+#JBOSS_CLASSPATH=$JBOSS_CLASSPATH:$JBOSS_HOME/client/jboss-javaee.jar
# For remote invocations on the ProfileService proxy (e.g.
ProfileService.getViewManager())...
-JBOSS_CLASSPATH=$JBOSS_CLASSPATH:$JBOSS_HOME/client/concurrent.jar
-JBOSS_CLASSPATH=$JBOSS_CLASSPATH:$JBOSS_HOME/client/jboss-client.jar
-JBOSS_CLASSPATH=$JBOSS_CLASSPATH:$JBOSS_HOME/client/jboss-mdr.jar
-JBOSS_CLASSPATH=$JBOSS_CLASSPATH:$JBOSS_HOME/client/jboss-integration.jar
+#JBOSS_CLASSPATH=$JBOSS_CLASSPATH:$JBOSS_HOME/client/concurrent.jar
+#JBOSS_CLASSPATH=$JBOSS_CLASSPATH:$JBOSS_HOME/client/jboss-client.jar
+#JBOSS_CLASSPATH=$JBOSS_CLASSPATH:$JBOSS_HOME/client/jboss-mdr.jar
+#JBOSS_CLASSPATH=$JBOSS_CLASSPATH:$JBOSS_HOME/client/jboss-integration.jar
-JBOSS_CLASSPATH=$JBOSS_CLASSPATH:$JBOSS_HOME/lib/jboss-managed.jar
-JBOSS_CLASSPATH=$JBOSS_CLASSPATH:$JBOSS_HOME/lib/jboss-metatype.jar
+#JBOSS_CLASSPATH=$JBOSS_CLASSPATH:$JBOSS_HOME/lib/jboss-managed.jar
+#JBOSS_CLASSPATH=$JBOSS_CLASSPATH:$JBOSS_HOME/lib/jboss-metatype.jar
#:HAVE_JB_CP
diff --git a/modules/jopr/etc/jbas5-jnp-client/src/main/java/test/RmiClient.java
b/modules/jopr/etc/jbas5-jnp-client/src/main/java/test/RmiClient.java
index 6aa13c4..91b23ee 100644
--- a/modules/jopr/etc/jbas5-jnp-client/src/main/java/test/RmiClient.java
+++ b/modules/jopr/etc/jbas5-jnp-client/src/main/java/test/RmiClient.java
@@ -17,9 +17,11 @@ public class RmiClient
public static void main(String[] args)
throws Exception
- {
+ {
+ String jnpUrl = (args.length == 1) ? args[0] : "jnp://127.0.0.1:1099";
+
Properties env = new Properties();
- env.setProperty(Context.PROVIDER_URL, "jnp://127.0.0.1:1099");
+ env.setProperty(Context.PROVIDER_URL, jnpUrl);
env.setProperty(Context.INITIAL_CONTEXT_FACTORY, NAMING_CONTEXT_FACTORY);
env.setProperty("jnp.disableDiscovery", "true");
env.setProperty("jnp.timeout", "120");
@@ -40,3 +42,4 @@ public class RmiClient
deploymentManager.getProfiles();
}
}
+
commit 88e3f764331265d6557274f8b8443a7b75ea76de
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Sep 22 17:39:25 2010 -0400
initial try of the dampening editor. still some work to make it prettier, but its
functional. let's you view and edit/save dampening rules
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/DampeningAlertDefinitionForm.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/DampeningAlertDefinitionForm.java
index b332c3a..87eecea 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/DampeningAlertDefinitionForm.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/DampeningAlertDefinitionForm.java
@@ -23,7 +23,18 @@
package org.rhq.enterprise.gui.coregui.client.alert.definitions;
+import java.util.LinkedHashMap;
+
+import com.smartgwt.client.widgets.form.fields.SelectItem;
+import com.smartgwt.client.widgets.form.fields.SpinnerItem;
+import com.smartgwt.client.widgets.form.fields.StaticTextItem;
+import com.smartgwt.client.widgets.form.fields.events.ChangedEvent;
+import com.smartgwt.client.widgets.form.fields.events.ChangedHandler;
+
+import org.rhq.core.domain.alert.AlertDampening;
import org.rhq.core.domain.alert.AlertDefinition;
+import org.rhq.core.domain.alert.AlertDampening.Category;
+import org.rhq.core.domain.alert.AlertDampening.TimeUnits;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
/**
@@ -35,6 +46,27 @@ public class DampeningAlertDefinitionForm extends LocatableDynamicForm
implement
private boolean formBuilt = false;
+ private SelectItem dampeningRuleSelection;
+ private StaticTextItem dampeningRuleStatic;
+
+ private SpinnerItem consecutiveOccurrencesSpinner;
+ private StaticTextItem consecutiveOccurrencesStatic;
+
+ private SpinnerItem partialOccurrencesSpinner;
+ private StaticTextItem partialOccurrencesStatic;
+
+ private SpinnerItem partialEvaluationsSpinner;
+ private StaticTextItem partialEvaluationsStatic;
+
+ private SpinnerItem durationOccurrencesSpinner;
+ private StaticTextItem durationOccurrencesStatic;
+
+ private SpinnerItem durationTimePeriodSpinner;
+ private StaticTextItem durationTimePeriodStatic;
+
+ private SelectItem durationTimeUnitsSelection;
+ private StaticTextItem durationTimeUnitsStatic;
+
public DampeningAlertDefinitionForm(String locatorId) {
this(locatorId, null);
}
@@ -69,7 +101,50 @@ public class DampeningAlertDefinitionForm extends LocatableDynamicForm
implement
if (alertDef == null) {
clearFormValues();
} else {
- // TODO set values of the components
+ clearFormValues();
+
+ AlertDampening alertDampening = alertDef.getAlertDampening();
+ if (alertDampening == null) {
+ alertDampening = new AlertDampening(AlertDampening.Category.NONE);
+ alertDefinition.setAlertDampening(alertDampening);
+ }
+
+ dampeningRuleSelection.setValue(alertDampening.getCategory().name());
+
dampeningRuleStatic.setValue(getCategoryTitle(alertDampening.getCategory()));
+
+ switch (alertDampening.getCategory()) {
+ case NONE: {
+ break;
+ }
+ case CONSECUTIVE_COUNT: {
+ consecutiveOccurrencesSpinner.setValue(alertDampening.getValue());
+ consecutiveOccurrencesStatic.setValue(alertDampening.getValue());
+ break;
+ }
+ case PARTIAL_COUNT: {
+ partialOccurrencesSpinner.setValue(alertDampening.getValue());
+ partialOccurrencesStatic.setValue(alertDampening.getValue());
+
+ partialEvaluationsSpinner.setValue(alertDampening.getPeriod());
+ partialEvaluationsStatic.setValue(alertDampening.getPeriod());
+ break;
+ }
+ case DURATION_COUNT: {
+ durationOccurrencesSpinner.setValue(alertDampening.getValue());
+ durationOccurrencesStatic.setValue(alertDampening.getValue());
+
+ durationTimePeriodSpinner.setValue(alertDampening.getPeriod());
+ durationTimePeriodStatic.setValue(alertDampening.getPeriod());
+
+
durationTimeUnitsSelection.setValue(alertDampening.getPeriodUnits().name());
+
durationTimeUnitsStatic.setValue(getTimeUnitsTitle(alertDampening.getPeriodUnits()));
+ break;
+ }
+ default: {
+ throw new IllegalStateException("Invalid category - please report
this as a bug: "
+ + alertDampening.getCategory()); // should never happen
+ }
+ }
}
markForRedraw();
@@ -77,36 +152,434 @@ public class DampeningAlertDefinitionForm extends
LocatableDynamicForm implement
@Override
public void makeEditable() {
- // TODO Auto-generated method stub
+ dampeningRuleSelection.show();
+ dampeningRuleStatic.hide();
+
+ AlertDampening.Category cat =
AlertDampening.Category.valueOf(dampeningRuleSelection.getValue().toString());
+ switch (cat) {
+ case NONE: {
+ consecutiveOccurrencesSpinner.hide();
+ consecutiveOccurrencesStatic.hide();
+ partialOccurrencesSpinner.hide();
+ partialOccurrencesStatic.hide();
+ partialEvaluationsSpinner.hide();
+ partialEvaluationsStatic.hide();
+ durationOccurrencesSpinner.hide();
+ durationOccurrencesStatic.hide();
+ durationTimePeriodSpinner.hide();
+ durationTimePeriodStatic.hide();
+ durationTimeUnitsSelection.hide();
+ durationTimeUnitsStatic.hide();
+ break;
+ }
+ case CONSECUTIVE_COUNT: {
+ consecutiveOccurrencesSpinner.show();
+ consecutiveOccurrencesStatic.hide();
+
+ partialOccurrencesSpinner.hide();
+ partialOccurrencesStatic.hide();
+ partialEvaluationsSpinner.hide();
+ partialEvaluationsStatic.hide();
+ durationOccurrencesSpinner.hide();
+ durationOccurrencesStatic.hide();
+ durationTimePeriodSpinner.hide();
+ durationTimePeriodStatic.hide();
+ durationTimeUnitsSelection.hide();
+ durationTimeUnitsStatic.hide();
+
+ break;
+ }
+ case PARTIAL_COUNT: {
+ partialOccurrencesSpinner.show();
+ partialOccurrencesStatic.hide();
+
+ partialEvaluationsSpinner.show();
+ partialEvaluationsStatic.hide();
+
+ consecutiveOccurrencesSpinner.hide();
+ consecutiveOccurrencesStatic.hide();
+ durationOccurrencesSpinner.hide();
+ durationOccurrencesStatic.hide();
+ durationTimePeriodSpinner.hide();
+ durationTimePeriodStatic.hide();
+ durationTimeUnitsSelection.hide();
+ durationTimeUnitsStatic.hide();
+ break;
+ }
+ case DURATION_COUNT: {
+ durationOccurrencesSpinner.show();
+ durationOccurrencesStatic.hide();
+
+ durationTimePeriodSpinner.show();
+ durationTimePeriodStatic.hide();
+
+ durationTimeUnitsSelection.show();
+ durationTimeUnitsStatic.hide();
+
+ consecutiveOccurrencesSpinner.hide();
+ consecutiveOccurrencesStatic.hide();
+ partialOccurrencesSpinner.hide();
+ partialOccurrencesStatic.hide();
+ partialEvaluationsSpinner.hide();
+ partialEvaluationsStatic.hide();
+ break;
+ }
+ default: {
+ throw new IllegalStateException("Bad dampening category - please report
this bug: " + cat); // should never happen
+ }
+ }
markForRedraw();
}
@Override
public void makeViewOnly() {
- // TODO Auto-generated method stub
+ dampeningRuleSelection.hide();
+ dampeningRuleStatic.show();
+
+ AlertDampening.Category cat =
AlertDampening.Category.valueOf(dampeningRuleSelection.getValue().toString());
+ switch (cat) {
+ case NONE: {
+ consecutiveOccurrencesSpinner.hide();
+ consecutiveOccurrencesStatic.hide();
+ partialOccurrencesSpinner.hide();
+ partialOccurrencesStatic.hide();
+ partialEvaluationsSpinner.hide();
+ partialEvaluationsStatic.hide();
+ durationOccurrencesSpinner.hide();
+ durationOccurrencesStatic.hide();
+ durationTimePeriodSpinner.hide();
+ durationTimePeriodStatic.hide();
+ durationTimeUnitsSelection.hide();
+ durationTimeUnitsStatic.hide();
+ break;
+ }
+ case CONSECUTIVE_COUNT: {
+ consecutiveOccurrencesSpinner.hide();
+ consecutiveOccurrencesStatic.show();
+
+ partialOccurrencesSpinner.hide();
+ partialOccurrencesStatic.hide();
+ partialEvaluationsSpinner.hide();
+ partialEvaluationsStatic.hide();
+ durationOccurrencesSpinner.hide();
+ durationOccurrencesStatic.hide();
+ durationTimePeriodSpinner.hide();
+ durationTimePeriodStatic.hide();
+ durationTimeUnitsSelection.hide();
+ durationTimeUnitsStatic.hide();
+ break;
+ }
+ case PARTIAL_COUNT: {
+ partialOccurrencesSpinner.hide();
+ partialOccurrencesStatic.show();
+
+ partialEvaluationsSpinner.hide();
+ partialEvaluationsStatic.show();
+
+ consecutiveOccurrencesSpinner.hide();
+ consecutiveOccurrencesStatic.hide();
+ durationOccurrencesSpinner.hide();
+ durationOccurrencesStatic.hide();
+ durationTimePeriodSpinner.hide();
+ durationTimePeriodStatic.hide();
+ durationTimeUnitsSelection.hide();
+ durationTimeUnitsStatic.hide();
+ break;
+ }
+ case DURATION_COUNT: {
+ durationOccurrencesSpinner.hide();
+ durationOccurrencesStatic.show();
+
+ durationTimePeriodSpinner.hide();
+ durationTimePeriodStatic.show();
+
+ durationTimeUnitsSelection.hide();
+ durationTimeUnitsStatic.show();
+
+ consecutiveOccurrencesSpinner.hide();
+ consecutiveOccurrencesStatic.hide();
+ partialOccurrencesSpinner.hide();
+ partialOccurrencesStatic.hide();
+ partialEvaluationsSpinner.hide();
+ partialEvaluationsStatic.hide();
+ break;
+ }
+ default: {
+ throw new IllegalStateException("Bad dampening category - please report
this bug: " + cat); // should never happen
+ }
+ }
markForRedraw();
}
@Override
public void saveAlertDefinition() {
- // TODO Auto-generated method stub
+ AlertDampening.Category cat =
AlertDampening.Category.valueOf(dampeningRuleSelection.getValue().toString());
+ AlertDampening alertDampening = new AlertDampening(cat);
+ switch (cat) {
+ case NONE: {
+ // each time condition set is true
+ alertDampening.setValue(0);
+ alertDampening.setValueUnits(null);
+ alertDampening.setPeriod(0);
+ alertDampening.setPeriodUnits(null);
+ break;
+ }
+ case CONSECUTIVE_COUNT: {
+ // once every N times condition set is true consecutively
+
alertDampening.setValue(Integer.valueOf(consecutiveOccurrencesSpinner.getValue().toString()));
+ alertDampening.setValueUnits(null);
+ alertDampening.setPeriod(0);
+ alertDampening.setPeriodUnits(null);
+ break;
+ }
+ case PARTIAL_COUNT: {
+ // once every N times condition set is true during the last M evaluations
+
alertDampening.setValue(Integer.valueOf(partialOccurrencesSpinner.getValue().toString()));
+ alertDampening.setValueUnits(null);
+
alertDampening.setPeriod(Integer.valueOf(partialEvaluationsSpinner.getValue().toString()));
+ alertDampening.setPeriodUnits(null);
+ break;
+ }
+ case DURATION_COUNT: {
+ // once every N times condition set is true within a time period of M {mins,
hours, days, weeks}
+
alertDampening.setValue(Integer.valueOf(durationOccurrencesSpinner.getValue().toString()));
+ alertDampening.setValueUnits(null);
+
alertDampening.setPeriod(Integer.valueOf(durationTimePeriodSpinner.getValue().toString()));
+
alertDampening.setPeriodUnits(TimeUnits.valueOf(durationTimeUnitsSelection.getValue().toString()));
+ break;
+ }
+ default: {
+ throw new IllegalStateException("Bad dampening category - please report
this bug: " + cat); // should never happen
+ }
+ }
+ alertDefinition.setAlertDampening(alertDampening);
}
@Override
public void clearFormValues() {
- // TODO component.clearValue();
+ dampeningRuleSelection.clearValue();
+ consecutiveOccurrencesSpinner.clearValue();
+ partialOccurrencesSpinner.clearValue();
+ partialEvaluationsSpinner.clearValue();
+ durationOccurrencesSpinner.clearValue();
+ durationTimePeriodSpinner.clearValue();
+ durationTimeUnitsSelection.clearValue();
+
+ dampeningRuleStatic.clearValue();
+ consecutiveOccurrencesStatic.clearValue();
+ partialOccurrencesStatic.clearValue();
+ partialEvaluationsStatic.clearValue();
+ durationOccurrencesStatic.clearValue();
+ durationTimePeriodStatic.clearValue();
+ durationTimeUnitsStatic.clearValue();
markForRedraw();
}
private void buildForm() {
if (!formBuilt) {
- // TODO buildNodes components
- // TODO setFields(components);
+ setNumCols(3);
+
+ dampeningRuleSelection = new SelectItem("dampeningRule",
"Dampening Rule");
+ LinkedHashMap<String, String> rules = new LinkedHashMap<String,
String>(4);
+ rules.put(AlertDampening.Category.NONE.name(),
getCategoryTitle(AlertDampening.Category.NONE));
+ rules.put(AlertDampening.Category.CONSECUTIVE_COUNT.name(),
+ getCategoryTitle(AlertDampening.Category.CONSECUTIVE_COUNT));
+ rules.put(AlertDampening.Category.PARTIAL_COUNT.name(),
+ getCategoryTitle(AlertDampening.Category.PARTIAL_COUNT));
+ rules.put(AlertDampening.Category.DURATION_COUNT.name(),
+ getCategoryTitle(AlertDampening.Category.DURATION_COUNT));
+ dampeningRuleSelection.setValueMap(rules);
+ dampeningRuleSelection.setDefaultValue(AlertDampening.Category.NONE.name());
+ dampeningRuleSelection.setWrapTitle(false);
+ dampeningRuleSelection.setRedrawOnChange(true);
+ dampeningRuleSelection.setColSpan(2);
+ dampeningRuleStatic = new StaticTextItem("dampeningRuleStatic",
"Dampening Rule");
+ dampeningRuleStatic.setColSpan(2);
+ dampeningRuleStatic.setWrapTitle(false);
+
+ // NONE
+ // nothing to do - the none category has no ui components to render
+
+ // CONSECUTIVE_COUNT
+ consecutiveOccurrencesSpinner = new
SpinnerItem("consecutiveOccurrencesSpinner", "Occurrences");
+ consecutiveOccurrencesSpinner.setColSpan(2);
+ consecutiveOccurrencesSpinner.setWrapTitle(false);
+ consecutiveOccurrencesSpinner.setMin(1);
+ consecutiveOccurrencesSpinner.setMax(999999);
+ consecutiveOccurrencesSpinner.setStep(1);
+ consecutiveOccurrencesSpinner.setDefaultValue(1);
+ consecutiveOccurrencesSpinner
+ .setTooltip("The number of times the condition set must be
consecutively true before the alert is triggered.");
+ consecutiveOccurrencesStatic = new
StaticTextItem("consecutiveOccurrencesStatic", "Occurrences");
+ consecutiveOccurrencesStatic.setColSpan(2);
+ consecutiveOccurrencesStatic.setWrapTitle(false);
+
+ // PARTIAL_COUNT
+ partialOccurrencesSpinner = new
SpinnerItem("partialOccurrencesSpinner", "Occurrences");
+ partialOccurrencesSpinner.setColSpan(2);
+ partialOccurrencesSpinner.setWrapTitle(false);
+ partialOccurrencesSpinner.setMin(1);
+ partialOccurrencesSpinner.setMax(999999);
+ partialOccurrencesSpinner.setStep(1);
+ partialOccurrencesSpinner.setDefaultValue(1);
+ partialOccurrencesSpinner
+ .setTooltip("The number of times the condition set must be true
during the last N evaluations before the alert is triggered.");
+ partialOccurrencesStatic = new
StaticTextItem("partialOccurrencesStatic", "Occurrences");
+ partialOccurrencesStatic.setColSpan(2);
+ partialOccurrencesStatic.setWrapTitle(false);
+
+ partialEvaluationsSpinner = new
SpinnerItem("partialEvaluationsSpinner", "Evaluations");
+ partialEvaluationsSpinner.setColSpan(2);
+ partialEvaluationsSpinner.setWrapTitle(false);
+ partialEvaluationsSpinner.setMin(1);
+ partialEvaluationsSpinner.setMax(999999);
+ partialEvaluationsSpinner.setStep(1);
+ partialEvaluationsSpinner.setDefaultValue(1);
+ partialEvaluationsStatic = new
StaticTextItem("partialEvaluationStatic", "Evaluations");
+ partialEvaluationsStatic.setColSpan(2);
+ partialEvaluationsStatic.setWrapTitle(false);
+
+ // DURATION_COUNT
+ durationOccurrencesSpinner = new
SpinnerItem("durationOccurrencesSpinner", "Occurrences");
+ durationOccurrencesSpinner.setColSpan(2);
+ durationOccurrencesSpinner.setWrapTitle(false);
+ durationOccurrencesSpinner.setMin(1);
+ durationOccurrencesSpinner.setMax(999999);
+ durationOccurrencesSpinner.setStep(1);
+ durationOccurrencesSpinner.setDefaultValue(1);
+ durationOccurrencesSpinner
+ .setTooltip("The number of times the condition set must be true
during the given time period before the alert is triggered.");
+ durationOccurrencesStatic = new
StaticTextItem("durationOccurrencesStatic", "Occurrences");
+ durationOccurrencesStatic.setColSpan(2);
+ durationOccurrencesStatic.setWrapTitle(false);
+
+ durationTimePeriodSpinner = new
SpinnerItem("durationTimePeriodSpinner", "Time Period");
+ durationTimePeriodSpinner.setEndRow(false);
+ durationTimePeriodSpinner.setWrapTitle(false);
+ durationTimePeriodSpinner.setMin(1);
+ durationTimePeriodSpinner.setMax(999999);
+ durationTimePeriodSpinner.setStep(1);
+ durationTimePeriodSpinner.setDefaultValue(1);
+ durationTimePeriodStatic = new
StaticTextItem("durationTimePeriodStatic", "Time Period");
+ durationTimePeriodStatic.setEndRow(false);
+ durationTimePeriodStatic.setWrapTitle(false);
+
+ durationTimeUnitsSelection = new SelectItem("durationTimeUnits");
+ LinkedHashMap<String, String> units = new LinkedHashMap<String,
String>(4);
+ units.put(AlertDampening.TimeUnits.MINUTES.name(),
getTimeUnitsTitle(AlertDampening.TimeUnits.MINUTES));
+ units.put(AlertDampening.TimeUnits.HOURS.name(),
getTimeUnitsTitle(AlertDampening.TimeUnits.HOURS));
+ units.put(AlertDampening.TimeUnits.DAYS.name(),
getTimeUnitsTitle(AlertDampening.TimeUnits.DAYS));
+ units.put(AlertDampening.TimeUnits.WEEKS.name(),
getTimeUnitsTitle(AlertDampening.TimeUnits.WEEKS));
+ durationTimeUnitsSelection.setValueMap(units);
+
durationTimeUnitsSelection.setDefaultValue(AlertDampening.TimeUnits.MINUTES.name());
+ durationTimeUnitsSelection.setStartRow(false);
+ durationTimeUnitsSelection.setEndRow(true);
+ durationTimeUnitsSelection.setShowTitle(false);
+ durationTimeUnitsStatic = new
StaticTextItem("durationTimeUnitsStatic");
+ durationTimeUnitsStatic.setStartRow(false);
+ durationTimeUnitsStatic.setEndRow(true);
+ durationTimeUnitsStatic.setShowTitle(false);
+
+ dampeningRuleSelection.addChangedHandler(new ChangedHandler() {
+ @Override
+ public void onChanged(ChangedEvent event) {
+ Category cat =
AlertDampening.Category.valueOf(event.getValue().toString());
+ switch (cat) {
+ case NONE: {
+ consecutiveOccurrencesSpinner.hide();
+ partialOccurrencesSpinner.hide();
+ partialEvaluationsSpinner.hide();
+ durationOccurrencesSpinner.hide();
+ durationTimePeriodSpinner.hide();
+ durationTimeUnitsSelection.hide();
+ break;
+ }
+ case CONSECUTIVE_COUNT: {
+ consecutiveOccurrencesSpinner.show();
+ partialOccurrencesSpinner.hide();
+ partialEvaluationsSpinner.hide();
+ durationOccurrencesSpinner.hide();
+ durationTimePeriodSpinner.hide();
+ durationTimeUnitsSelection.hide();
+ break;
+ }
+ case PARTIAL_COUNT: {
+ consecutiveOccurrencesSpinner.hide();
+ partialOccurrencesSpinner.show();
+ partialEvaluationsSpinner.show();
+ durationOccurrencesSpinner.hide();
+ durationTimePeriodSpinner.hide();
+ durationTimeUnitsSelection.hide();
+ break;
+ }
+ case DURATION_COUNT: {
+ consecutiveOccurrencesSpinner.hide();
+ partialOccurrencesSpinner.hide();
+ partialEvaluationsSpinner.hide();
+ durationOccurrencesSpinner.show();
+ durationTimePeriodSpinner.show();
+ durationTimeUnitsSelection.show();
+ break;
+ }
+ default: {
+ throw new IllegalStateException("Invalid category - please
report this as a bug: " + cat); // should never happen
+ }
+ }
+ markForRedraw();
+ }
+ });
+
+ // put all the fields in the form now
+ setFields(dampeningRuleSelection, dampeningRuleStatic,
consecutiveOccurrencesSpinner,
+ consecutiveOccurrencesStatic, partialOccurrencesSpinner,
partialOccurrencesStatic,
+ partialEvaluationsSpinner, partialEvaluationsStatic,
durationOccurrencesSpinner,
+ durationOccurrencesStatic, durationTimePeriodSpinner,
durationTimePeriodStatic,
+ durationTimeUnitsSelection, durationTimeUnitsStatic);
formBuilt = true;
}
}
+
+ private String getCategoryTitle(AlertDampening.Category category) {
+ switch (category) {
+ case NONE: {
+ return "None";
+ }
+ case CONSECUTIVE_COUNT: {
+ return "Consecutive";
+ }
+ case PARTIAL_COUNT: {
+ return "Last N Evaluations";
+ }
+ case DURATION_COUNT: {
+ return "Time Period";
+ }
+ default: {
+ throw new IllegalStateException("Invalid category - please report this
as a bug: " + category); // should never happen
+ }
+ }
+ }
+
+ private String getTimeUnitsTitle(AlertDampening.TimeUnits units) {
+ switch (units) {
+ case MINUTES: {
+ return "minutes";
+ }
+ case HOURS: {
+ return "hours";
+ }
+ case DAYS: {
+ return "days";
+ }
+ case WEEKS: {
+ return "weeks";
+ }
+ default: {
+ throw new IllegalStateException("Invalid time units - please report this
as a bug: " + units); // should never happen
+ }
+ }
+ }
}
commit 6689f8e0e7057c2e183879a7a3bbbbb05f36d34b
Author: Joseph Marques <joseph(a)redhat.com>
Date: Wed Sep 22 14:35:10 2010 -0400
only read from viewPath if the user is allowed to access this view
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java
index bcdb9ca..ef55f63 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java
@@ -333,10 +333,7 @@ public class SingleGroupDefinitionView extends LocatableVLayout
implements Bookm
}
@Override
- public void renderView(ViewPath viewPath) {
- groupDefinitionId = viewPath.getCurrentAsInt();
- viewId = viewPath.getCurrent();
- basePath = viewPath.getPathToCurrent();
+ public void renderView(final ViewPath viewPath) {
GWTServiceLookup.getAuthorizationService().getExplicitGlobalPermissions(new
AsyncCallback<Set<Permission>>() {
@Override
public void onFailure(Throwable caught) {
@@ -355,6 +352,9 @@ public class SingleGroupDefinitionView extends LocatableVLayout
implements Bookm
if (result.contains(Permission.MANAGE_INVENTORY) == false) {
handleAuthorizationFailure();
} else {
+ groupDefinitionId = viewPath.getCurrentAsInt();
+ viewId = viewPath.getCurrent();
+ basePath = viewPath.getPathToCurrent();
lookupDetails(groupDefinitionId);
}
}
commit d93ec8d394b4e25a5f4ca3c0bc20f715976957d0
Merge: eda3ff1... e5215ae...
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Wed Sep 22 14:28:05 2010 -0400
Merge branch 'master' of
ssh://git.fedorahosted.org/git/rhq/rhq
commit e5215ae78bdb6ce50c560e5d957022489c161907
Author: Joseph Marques <joseph(a)redhat.com>
Date: Wed Sep 22 14:18:06 2010 -0400
authz: disable links in nav panel for InventoryView according to perms
* hide "Discovery Manager" behind MANAGE_INVENTORY
* hide "DynaGroup Manager" behind MANAGE_INVENTORY
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java
index ed442b2..c6d5289 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java
@@ -18,10 +18,13 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.resource;
+import java.util.EnumSet;
import java.util.LinkedHashMap;
import java.util.Map;
+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;
@@ -33,12 +36,14 @@ import com.smartgwt.client.widgets.tree.Tree;
import com.smartgwt.client.widgets.tree.TreeGrid;
import com.smartgwt.client.widgets.tree.TreeNode;
+import org.rhq.core.domain.authz.Permission;
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.domain.resource.ResourceCategory;
import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.ViewId;
import org.rhq.enterprise.gui.coregui.client.ViewPath;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.inventory.groups.ResourceGroupListView;
import
org.rhq.enterprise.gui.coregui.client.inventory.groups.definitions.GroupDefinitionListView;
import
org.rhq.enterprise.gui.coregui.client.inventory.resource.discovery.ResourceAutodiscoveryView;
@@ -90,6 +95,22 @@ public class InventoryView extends LocatableHLayout implements
BookmarkableView
protected void onInit() {
super.onInit();
+ 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));
+ }
+
+ @Override
+ public void onSuccess(Set<Permission> result) {
+ finishOnInit(result);
+ }
+ });
+ }
+
+ private void finishOnInit(Set<Permission> globalPermissions) {
setWidth100();
setHeight100();
@@ -103,8 +124,8 @@ public class InventoryView extends LocatableHLayout implements
BookmarkableView
sectionStack.setWidth(250);
sectionStack.setHeight100();
- buildResourcesSection();
- buildGroupsSection();
+ buildResourcesSection(globalPermissions);
+ buildGroupsSection(globalPermissions);
for (final String sectionName : treeGrids.keySet()) {
TreeGrid grid = treeGrids.get(sectionName);
@@ -133,12 +154,13 @@ public class InventoryView extends LocatableHLayout implements
BookmarkableView
addMember(contentCanvas);
}
- private SectionStackSection buildResourcesSection() {
+ private SectionStackSection buildResourcesSection(Set<Permission>
globalPermissions) {
final SectionStackSection section = new SectionStackSection(SECTION_RESOURCES);
section.setExpanded(true);
final TreeNode discoveryQueue = new TreeNode(PAGE_ADQ);
+
discoveryQueue.setEnabled(globalPermissions.contains(Permission.MANAGE_INVENTORY));
discoveryQueue.setIcon("global/Recent_16.png");
final TreeNode onlyPlatforms = new TreeNode(PAGE_PLATFORMS);
@@ -171,11 +193,12 @@ public class InventoryView extends LocatableHLayout implements
BookmarkableView
return section;
}
- private SectionStackSection buildGroupsSection() {
+ private SectionStackSection buildGroupsSection(Set<Permission>
globalPermissions) {
final SectionStackSection section = new SectionStackSection(SECTION_GROUPS);
section.setExpanded(true);
final TreeNode groupGroupDefinitions = new TreeNode(PAGE_GROUP_DEFINITIONS);
+
groupGroupDefinitions.setEnabled(globalPermissions.contains(Permission.MANAGE_INVENTORY));
groupGroupDefinitions.setIcon("types/GroupDefinition_16.png");
final TreeNode onlyCompatible = new TreeNode(PAGE_COMPATIBLE_GROUPS);
commit a97483270b9bb2be2ef07413d9a4bc81e1558a20
Author: Joseph Marques <joseph(a)redhat.com>
Date: Wed Sep 22 14:16:40 2010 -0400
authz: disallow users w/o MANAGE_INVENTORY from viewing list of group defs
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 c8293c7..a4fac9f 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
@@ -18,13 +18,18 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.groups.definitions;
+import java.util.Set;
+
+import com.google.gwt.user.client.History;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.grid.CellFormatter;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
+import org.rhq.core.domain.authz.Permission;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.ViewPath;
import org.rhq.enterprise.gui.coregui.client.components.table.Table;
import org.rhq.enterprise.gui.coregui.client.components.table.TableAction;
import org.rhq.enterprise.gui.coregui.client.components.table.TableSection;
@@ -144,4 +149,30 @@ public class GroupDefinitionListView extends TableSection {
.extendLocatorId("Details"));
return singleGroupDefinitionView;
}
+
+ @Override
+ public void renderView(final ViewPath viewPath) {
+ GWTServiceLookup.getAuthorizationService().getExplicitGlobalPermissions(new
AsyncCallback<Set<Permission>>() {
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(
+ "Could not determine whether user had MANAGE_INVENTORY
permission", caught);
+ handleAuthorizationFailure();
+ }
+
+ private void handleAuthorizationFailure() {
+ CoreGUI.getErrorHandler().handleError("You do not have permission to
view group definitions");
+ History.back();
+ }
+
+ @Override
+ public void onSuccess(Set<Permission> result) {
+ if (result.contains(Permission.MANAGE_INVENTORY) == false) {
+ handleAuthorizationFailure();
+ } else {
+ GroupDefinitionListView.super.renderView(viewPath);
+ }
+ }
+ });
+ }
}
\ No newline at end of file
commit b5a275a90b1249c52153d734c180d0174660255d
Author: Joseph Marques <joseph(a)redhat.com>
Date: Wed Sep 22 14:15:55 2010 -0400
authz: disallow users w/o MANAGE_INVENTORY from viewing group def details
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java
index dde421c..bcdb9ca 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java
@@ -36,7 +36,6 @@ import com.smartgwt.client.widgets.events.ClickHandler;
import com.smartgwt.client.widgets.form.fields.CheckboxItem;
import com.smartgwt.client.widgets.form.fields.SelectItem;
import com.smartgwt.client.widgets.form.fields.SpinnerItem;
-import com.smartgwt.client.widgets.form.fields.StaticTextItem;
import com.smartgwt.client.widgets.form.fields.TextAreaItem;
import com.smartgwt.client.widgets.form.fields.TextItem;
import com.smartgwt.client.widgets.grid.ListGridRecord;
@@ -78,14 +77,6 @@ public class SingleGroupDefinitionView extends LocatableVLayout
implements Bookm
private TextAreaItem expression;
private SpinnerItem recalculationInterval;
- // read-only form
- private StaticTextItem idStatic;
- private StaticTextItem nameStatic;
- private StaticTextItem descriptionStatic;
- private StaticTextItem recursiveStatic;
- private StaticTextItem expressionStatic;
- private StaticTextItem recalculationIntervalStatic;
-
public SingleGroupDefinitionView(String locatorId) {
super(locatorId);
@@ -101,26 +92,14 @@ public class SingleGroupDefinitionView extends LocatableVLayout
implements Bookm
// form setup
id.setValue(groupDefinition.getId());
- idStatic.setValue(groupDefinition.getId());
-
name.setValue(groupDefinition.getName());
- nameStatic.setValue(groupDefinition.getName());
-
recursive.setValue(groupDefinition.isRecursive());
- recursiveStatic.setValue(groupDefinition.isRecursive());
-
description.setValue(groupDefinition.getDescription());
- descriptionStatic.setValue(groupDefinition.getDescription());
-
recalculationInterval.setValue(groupDefinition.getRecalculationInterval());
-
recalculationIntervalStatic.setValue(groupDefinition.getRecalculationInterval());
-
expression.setValue(groupDefinition.getExpression());
- expressionStatic.setValue(groupDefinition.getExpression());
final LocatableDynamicForm form = new
LocatableDynamicForm(extendLocatorId("GroupDefinitionForm"));
- form.setFields(id, idStatic, name, nameStatic, description, descriptionStatic,
expression, expressionStatic,
- recursive, recursiveStatic, recalculationInterval,
recalculationIntervalStatic);
+ form.setFields(id, name, description, expression, recursive,
recalculationInterval);
form.setDataSource(GroupDefinitionDataSource.getInstance());
form.setHiliteRequiredFields(true);
form.setRequiredTitleSuffix(" <span style=\"color: red;\">*
</span>:");
@@ -229,71 +208,40 @@ public class SingleGroupDefinitionView extends LocatableVLayout
implements Bookm
expression.show();
recalculationInterval.show();
- nameStatic.hide();
- descriptionStatic.hide();
- recursiveStatic.hide();
- expressionStatic.hide();
- recalculationIntervalStatic.hide();
-
if (groupDefinitionId == 0) {
viewId.getBreadcrumbs().get(0).setDisplayName("New Group
Definition");
} else {
- viewId.getBreadcrumbs().get(0).setDisplayName("Editing '" +
nameStatic.getValue().toString() + "'");
+ viewId.getBreadcrumbs().get(0).setDisplayName("Editing '" +
name.getValue().toString() + "'");
}
CoreGUI.refreshBreadCrumbTrail();
markForRedraw();
}
- public void switchToViewMode() {
- name.hide();
- description.hide();
- recursive.hide();
- expression.hide();
- recalculationInterval.hide();
-
- nameStatic.show();
- descriptionStatic.show();
- recursiveStatic.show();
- expressionStatic.show();
- recalculationIntervalStatic.show();
-
- viewId.getBreadcrumbs().get(0).setDisplayName("Viewing '" +
nameStatic.getValue().toString() + "'");
-
- markForRedraw();
- }
-
private void buildForm() {
id = new TextItem("id", "ID");
id.setVisible(false);
- idStatic = new StaticTextItem("idStatic", "ID");
- idStatic.setVisible(false);
name = new TextItem("name", "Name");
name.setWidth(400);
name.setDefaultValue("");
- nameStatic = new StaticTextItem("nameStatic", "Name");
description = new TextAreaItem("description",
"Description");
description.setWidth(400);
description.setHeight(50);
description.setDefaultValue("");
- descriptionStatic = new StaticTextItem("descriptionStatic",
"Description");
recursive = new CheckboxItem("recursive", "Recursive");
- recursiveStatic = new StaticTextItem("recursiveStatic",
"Recursive");
expression = new TextAreaItem("expression", "Expression");
expression.setWidth(400);
expression.setHeight(150);
expression.setDefaultValue("");
- expressionStatic = new StaticTextItem("expressionStatic",
"Expression");
recalculationInterval = new SpinnerItem("recalculationInterval",
"Recalculation Interval");
recalculationInterval.setWrapTitle(false);
recalculationInterval.setMin(0);
recalculationInterval.setDefaultValue(0);
- recalculationIntervalStatic = new
StaticTextItem("recalculationIntervalStatic", "Recalculation
Interval");
templateSelector = new SelectItem();
templateSelector.setValueMap(getTemplates());
@@ -352,18 +300,14 @@ public class SingleGroupDefinitionView extends LocatableVLayout
implements Bookm
return results.toString();
}
- private void lookupDetails(final int groupDefinitionId, final boolean
hasEditPermission) {
+ private void lookupDetails(final int groupDefinitionId) {
ResourceGroupDefinitionCriteria criteria = new
ResourceGroupDefinitionCriteria();
criteria.addFilterId(groupDefinitionId);
if (groupDefinitionId == 0) {
GroupDefinition newGroupDefinition = new GroupDefinition();
setGroupDefinition(newGroupDefinition);
- if (hasEditPermission) {
- switchToEditMode();
- } else {
- switchToViewMode();
- }
+ switchToEditMode();
} else {
GWTServiceLookup.getResourceGroupService().findGroupDefinitionsByCriteria(criteria,
new AsyncCallback<PageList<GroupDefinition>>() {
@@ -381,11 +325,7 @@ public class SingleGroupDefinitionView extends LocatableVLayout
implements Bookm
} else {
GroupDefinition existingGroupDefinition = result.get(0);
setGroupDefinition(existingGroupDefinition);
- if (hasEditPermission) {
- switchToEditMode();
- } else {
- switchToViewMode();
- }
+ switchToEditMode();
}
}
});
@@ -401,14 +341,22 @@ public class SingleGroupDefinitionView extends LocatableVLayout
implements Bookm
@Override
public void onFailure(Throwable caught) {
CoreGUI.getErrorHandler().handleError(
- "Could not determine whether user had MANAGE_INVENTORY
permission, defaulting to view-only mode",
- caught);
- lookupDetails(groupDefinitionId, false);
+ "Could not determine whether user had MANAGE_INVENTORY
permission", caught);
+ handleAuthorizationFailure();
+ }
+
+ private void handleAuthorizationFailure() {
+ CoreGUI.getErrorHandler().handleError("You do not have permission to
view group definitions");
+ History.back();
}
@Override
public void onSuccess(Set<Permission> result) {
- lookupDetails(groupDefinitionId,
result.contains(Permission.MANAGE_INVENTORY));
+ if (result.contains(Permission.MANAGE_INVENTORY) == false) {
+ handleAuthorizationFailure();
+ } else {
+ lookupDetails(groupDefinitionId);
+ }
}
});
commit 9fa4e9c1a1444e4716cfd32a12499295ab2d5a35
Author: Joseph Marques <joseph(a)redhat.com>
Date: Wed Sep 22 13:10:12 2010 -0400
refactoring for maintainability; fix alignment of elements
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/MenuBarView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/MenuBarView.java
index 6878764..2aa22ce 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/MenuBarView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/MenuBarView.java
@@ -22,11 +22,13 @@ import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.user.client.History;
import com.google.gwt.user.client.ui.Hyperlink;
+import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.HTMLFlow;
import com.smartgwt.client.widgets.Img;
+import com.smartgwt.client.widgets.events.ClickEvent;
+import com.smartgwt.client.widgets.events.ClickHandler;
import com.smartgwt.client.widgets.layout.HLayout;
-import com.smartgwt.client.widgets.layout.LayoutSpacer;
import com.smartgwt.client.widgets.toolbar.ToolStrip;
import org.rhq.enterprise.gui.coregui.client.components.AboutModalWindow;
@@ -36,16 +38,13 @@ import
org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
/**
* @author Greg Hinkle
+ * @author Joseph Marques
*/
public class MenuBarView extends LocatableVLayout {
- private AboutModalWindow aboutModalWindow;
-
public static final String[] SECTIONS = { "Dashboard",
"Inventory", "Reports", "Bundles",
"Administration" };
- private String selected = "Dashboard";
-
- private HTMLFlow linksPane;
+ private String currentlySelectedSection = "Dashboard";
public MenuBarView(String locatorId) {
super(locatorId);
@@ -54,97 +53,62 @@ public class MenuBarView extends LocatableVLayout {
protected void onDraw() {
super.onDraw();
- History.addValueChangeHandler(new ValueChangeHandler<String>() {
- public void onValueChange(ValueChangeEvent<String>
stringValueChangeEvent) {
- String first =
stringValueChangeEvent.getValue().split("/")[0];
-
- if ("Resource".equals(first)) {
- first = "Inventory";
- }
-
- selected = first;
- linksPane.setContents(setupLinks());
- linksPane.markForRedraw();
- }
- });
-
ToolStrip topStrip = new ToolStrip();
topStrip.setHeight(34);
topStrip.setWidth100();
topStrip.setBackgroundImage("header/header_bg.png");
topStrip.setMembersMargin(20);
- this.aboutModalWindow = new AboutModalWindow();
+ topStrip.addMember(getLogoSection());
+ topStrip.addMember(getLinksSection());
+ topStrip.addMember(getActionsSection());
+
+ addMember(topStrip);
+ addMember(new SearchBarPane(this.extendLocatorId("Search")));
+
+ markForRedraw();
+ }
+
+ private Canvas getLogoSection() {
+ final AboutModalWindow aboutModalWindow = new AboutModalWindow();
Img logo = new Img("header/rhq_logo_28px.png", 80, 28);
- logo.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
- public void onClick(com.smartgwt.client.widgets.events.ClickEvent event) {
- MenuBarView.this.aboutModalWindow.show();
+ logo.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent event) {
+ aboutModalWindow.show();
}
});
- topStrip.addMember(logo);
+ return logo;
+ }
- linksPane = new HTMLFlow();
+ private Canvas getLinksSection() {
+ final HTMLFlow linksPane = new HTMLFlow();
linksPane.setContents(setupLinks());
- topStrip.addMember(linksPane);
-
- topStrip.addMember(new LayoutSpacer());
-
- //HLayout helpLayout = new HLayout();
- // Label loggedInAs = new Label("Logged in as " +
CoreGUI.getSessionSubject().getName());
- // loggedInAs.setWrap(false);
- // loggedInAs.setValign(VerticalAlignment.CENTER);
- // helpLayout.addMember(loggedInAs);
-
- topStrip.addMember(getHelpLinkSection());
- topStrip.addMember(SeleniumUtility.setHtmlId(new Hyperlink("Log Out",
"LogOut")));
- // helpLayout.setLayoutAlign(VerticalAlignment.CENTER);
- // topStrip.addMember(helpLayout);
-
- /* DynamicForm links = new DynamicForm();
- links.setNumCols(SECTIONS.length * 2);
- links.setHeight100();
-
- int i = 0;
- FormItem[] linkItems = new FormItem[SECTIONS.length];
- for (String section : SECTIONS) {
- LinkItem sectionLink = new LinkItem();
- sectionLink.setTitle(section);
- sectionLink.setValue("#" + section);
- sectionLink.setShowTitle(false);
-
- if (section.equals("Demo")) {
- sectionLink.setCellStyle("TopSectionLinkSelected");
- // sectionLink.("header/header_bg_selected.png");
- } else {
- sectionLink.setCellStyle("TopSectionLink");
- // widgetCanvas.setStyleName("TopSectionLink");
- }
- linkItems[i++] = sectionLink;
- }
- links.setItems(linkItems);
+ History.addValueChangeHandler(new ValueChangeHandler<String>() {
+ public void onValueChange(ValueChangeEvent<String>
stringValueChangeEvent) {
+ String first =
stringValueChangeEvent.getValue().split("/")[0];
- topStrip.addMember(links);
- */
- addMember(topStrip);
- addMember(new SearchBarPane(this.extendLocatorId("Search")));
+ if ("Resource".equals(first)) {
+ first = "Inventory";
+ }
- markForRedraw();
+ currentlySelectedSection = first;
+ linksPane.setContents(setupLinks());
+ linksPane.markForRedraw();
+ }
+ });
+ return linksPane;
}
private String setupLinks() {
StringBuilder headerString = new StringBuilder(
"<table style=\"height: 34px;\" cellpadding=\"0\"
cellspacing=\"0\"><tr>");
- boolean first = true;
+ headerString.append("<td style=\"width: 1px;\"><img
src=\"images/header/header_bg_line.png\"/></td>");
for (String section : SECTIONS) {
- if (first) {
- headerString.append("<td style=\"width:
1px;\"><img
src=\"images/header/header_bg_line.png\"/></td>");
- }
- first = false;
String styleClass = "TopSectionLink";
- if (section.equals(selected)) {
+ if (section.equals(currentlySelectedSection)) {
styleClass += "Selected";
}
@@ -162,13 +126,19 @@ public class MenuBarView extends LocatableVLayout {
return headerString.toString();
}
- private Canvas getHelpLinkSection() {
- HLayout helpLayout = new HLayout();
+ private Canvas getActionsSection() {
+ HLayout layout = new HLayout();
+ layout.setMargin(10);
+ layout.setAlign(Alignment.RIGHT);
+
LocatableImg helpImage = new LocatableImg("HelpImage",
"[SKIN]/actions/help.png", 16, 16);
Hyperlink helpLink = SeleniumUtility.setHtmlId(new Hyperlink("Help",
"Help"));
- helpLayout.addMember(helpImage);
- helpLayout.addMember(helpLink);
- return helpLayout;
- }
+ Hyperlink logoutLink = SeleniumUtility.setHtmlId(new Hyperlink("Log
Out", "LogOut"));
+ layout.addMember(helpImage);
+ layout.addMember(helpLink);
+ layout.addMember(logoutLink);
+
+ return layout;
+ }
}
commit bfbd77a21072e829969cdbf7a054997be06b74fe
Author: Joseph Marques <joseph(a)redhat.com>
Date: Wed Sep 22 11:29:28 2010 -0400
add icon next to help link in menu bar
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/MenuBarView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/MenuBarView.java
index cd1b7d9..6878764 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/MenuBarView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/MenuBarView.java
@@ -22,12 +22,15 @@ import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.user.client.History;
import com.google.gwt.user.client.ui.Hyperlink;
+import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.HTMLFlow;
import com.smartgwt.client.widgets.Img;
+import com.smartgwt.client.widgets.layout.HLayout;
import com.smartgwt.client.widgets.layout.LayoutSpacer;
import com.smartgwt.client.widgets.toolbar.ToolStrip;
import org.rhq.enterprise.gui.coregui.client.components.AboutModalWindow;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableImg;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
@@ -92,7 +95,8 @@ public class MenuBarView extends LocatableVLayout {
// loggedInAs.setWrap(false);
// loggedInAs.setValign(VerticalAlignment.CENTER);
// helpLayout.addMember(loggedInAs);
- topStrip.addMember(SeleniumUtility.setHtmlId(new Hyperlink("Help",
"Help")));
+
+ topStrip.addMember(getHelpLinkSection());
topStrip.addMember(SeleniumUtility.setHtmlId(new Hyperlink("Log Out",
"LogOut")));
// helpLayout.setLayoutAlign(VerticalAlignment.CENTER);
// topStrip.addMember(helpLayout);
@@ -158,4 +162,13 @@ public class MenuBarView extends LocatableVLayout {
return headerString.toString();
}
+ private Canvas getHelpLinkSection() {
+ HLayout helpLayout = new HLayout();
+ LocatableImg helpImage = new LocatableImg("HelpImage",
"[SKIN]/actions/help.png", 16, 16);
+ Hyperlink helpLink = SeleniumUtility.setHtmlId(new Hyperlink("Help",
"Help"));
+ helpLayout.addMember(helpImage);
+ helpLayout.addMember(helpLink);
+ return helpLayout;
+ }
+
}
commit 1bb5479e42ed753091337fdf2a81ffe089a1a937
Author: Joseph Marques <joseph(a)redhat.com>
Date: Wed Sep 22 10:56:27 2010 -0400
cosmetic, reformatting
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 403456c..00a27f0 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
@@ -447,21 +447,24 @@ public class CoreGUI implements EntryPoint,
ValueChangeHandler<String> {
* This is a nasty hack; but it's extremely reliable when running with other
* js libraries on the same page at the same time as gwt.
*/
- public static native boolean detectIe6() /*-{
- if (typeof $doc.body.style.maxHeight !=
"undefined")
- return(false);
- else
- return(true);
- }-*/;
-
- public static native void forceIe6Hacks() /*-{
- $wnd.XMLHttpRequestBackup =
$wnd.XMLHttpRequest;
- $wnd.XMLHttpRequest = null;
- }-*/;
-
- public static native void unforceIe6Hacks() /*-{
- $wnd.XMLHttpRequest =
$wnd.XMLHttpRequestBackup;
- $wnd.XMLHttpRequestBackup = null;
- }-*/;
+ public static native boolean detectIe6()
+ /*-{
+ if (typeof $doc.body.style.maxHeight != "undefined")
+ return(false);
+ else
+ return(true);
+ }-*/;
+
+ public static native void forceIe6Hacks()
+ /*-{
+ $wnd.XMLHttpRequestBackup = $wnd.XMLHttpRequest;
+ $wnd.XMLHttpRequest = null;
+ }-*/;
+
+ public static native void unforceIe6Hacks()
+ /*-{
+ $wnd.XMLHttpRequest = $wnd.XMLHttpRequestBackup;
+ $wnd.XMLHttpRequestBackup = null;
+ }-*/;
}
commit 6905ddc17545a6cb9e06230d476a81a2c379f8ca
Author: Joseph Marques <joseph(a)redhat.com>
Date: Wed Sep 22 00:35:24 2010 -0400
remove debugging statements from GroupDefinitionDataSource
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionDataSource.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionDataSource.java
index 32692b1..f4da478 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionDataSource.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionDataSource.java
@@ -109,7 +109,6 @@ public class GroupDefinitionDataSource extends
RPCDataSource<GroupDefinition> {
@Override
protected void executeAdd(final DSRequest request, final DSResponse response) {
- System.out.println("executeAdd");
JavaScriptObject data = request.getData();
final ListGridRecord record = new ListGridRecord(data);
final GroupDefinition newGroupDefinition = copyValues(record);
@@ -137,7 +136,6 @@ public class GroupDefinitionDataSource extends
RPCDataSource<GroupDefinition> {
@Override
protected void executeUpdate(final DSRequest request, final DSResponse response) {
- System.out.println("executeUpdate");
final ListGridRecord record = getEditedRecord(request);
final GroupDefinition updatedGroupDefinition = copyValues(record);
final String name = updatedGroupDefinition.getName();
@@ -161,10 +159,6 @@ public class GroupDefinitionDataSource extends
RPCDataSource<GroupDefinition> {
@Override
public GroupDefinition copyValues(ListGridRecord from) {
GroupDefinition groupDefinition = new GroupDefinition();
- String[] attributes = from.getAttributes();
- for (String nextAttribute : attributes) {
- System.out.println("ListGridRecord attribute: " + nextAttribute);
- }
groupDefinition.setId(from.getAttributeAsInt("id"));
groupDefinition.setName(from.getAttributeAsString("name"));
groupDefinition.setDescription(from.getAttributeAsString("description"));
commit eda3ff13594fff0133daf8a61bc7afa40f2aa2f4
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Wed Sep 22 14:10:08 2010 -0400
resource tree bug fixes: 1) do not add autogroup nodes for singleton resource types,
2) key the Map that stores created autogroup nodes off the node IDs rather than the
ResourceTypes
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tree/EnhancedTreeNode.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tree/EnhancedTreeNode.java
index c0752a1..91303ee 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tree/EnhancedTreeNode.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tree/EnhancedTreeNode.java
@@ -24,15 +24,12 @@ import com.smartgwt.client.widgets.tree.TreeNode;
* @author Ian Springer
*/
public class EnhancedTreeNode extends TreeNode {
- private static final String ID_FIELD = "id";
- private static final String PARENT_ID_FIELD = "parentId";
-
public String getID() {
- return getAttribute(ID_FIELD);
+ return getAttribute(Attributes.ID);
}
public String getParentID() {
- return getAttribute(PARENT_ID_FIELD);
+ return getAttribute(Attributes.PARENT_ID);
}
@Override
@@ -50,4 +47,14 @@ public class EnhancedTreeNode extends TreeNode {
buffer.append("]");
return buffer.toString();
}
+
+ public class Attributes {
+ public static final String ID = "id";
+ public static final String PARENT_ID = "parentId";
+ public static final String NAME = "name";
+ public static final String DESCRIPTION = "description";
+
+ private Attributes() {
+ }
+ }
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java
index bc9c956..9b39e8a 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java
@@ -201,8 +201,8 @@ public class ResourceTreeDatasource extends DataSource {
List<TreeNode> updatedNodes = new ArrayList<TreeNode>();
// Maps category node IDs to the corresponding category nodes.
Map<String, CategoryTreeNode> categories = new HashMap<String,
CategoryTreeNode>();
- // Maps Resource types to the corresponding type nodes.
- Map<ResourceType, TypeTreeNode> types = new HashMap<ResourceType,
TypeTreeNode>();
+ // Maps type node IDs to the corresponding type nodes.
+ Map<String, TypeTreeNode> types = new HashMap<String,
TypeTreeNode>();
for (ResourceTreeNode node : nodes) {
updatedNodes.add(node);
@@ -210,7 +210,8 @@ public class ResourceTreeDatasource extends DataSource {
Resource resource = node.getResource();
ResourceType type = resource.getResourceType();
if (type.getCategory() != ResourceCategory.PLATFORM) {
- if (!types.containsKey(type)) {
+ String typeNodeId = TypeTreeNode.idOf(resource);
+ if (!types.containsKey(typeNodeId)) {
Resource parentResource = resource.getParentResource();
ResourceSubCategory category = type.getSubCategory();
if (category != null) {
@@ -225,9 +226,11 @@ public class ResourceTreeDatasource extends DataSource {
} while ((category = category.getParentSubCategory()) != null);
}
- TypeTreeNode typeNode = new TypeTreeNode(resource);
- updatedNodes.add(typeNode);
- types.put(type, typeNode);
+ if (!type.isSingleton()) {
+ TypeTreeNode typeNode = new TypeTreeNode(resource);
+ updatedNodes.add(typeNode);
+ types.put(typeNodeId, typeNode);
+ }
}
}
}
@@ -239,19 +242,19 @@ public class ResourceTreeDatasource extends DataSource {
public CategoryTreeNode(ResourceSubCategory category, Resource parentResource) {
String id = idOf(category, parentResource);
setID(id);
- setAttribute("id", id);
+ setAttribute(Attributes.ID, id);
ResourceSubCategory parentCategory = category.getParentSubCategory();
String parentId = (parentCategory != null) ?
CategoryTreeNode.idOf(parentCategory, parentResource) :
ResourceTreeNode.idOf(parentResource);
setParentID(parentId);
- setAttribute("parentId", parentId);
+ setAttribute(Attributes.PARENT_ID, parentId);
// Note, subcategory names are typically already plural, so there's no
need to pluralize them.
String name = category.getDisplayName();
setName(name);
- setAttribute("name", name);
+ setAttribute(Attributes.NAME, name);
}
public static String idOf(ResourceSubCategory category, Resource parentResource)
{
@@ -266,18 +269,18 @@ public class ResourceTreeDatasource extends DataSource {
private TypeTreeNode(Resource resource) {
String id = idOf(resource);
setID(id);
- setAttribute("id", id);
+ setAttribute(Attributes.ID, id);
String parentId = parentIdOf(resource);
setParentID(parentId);
- setAttribute("parentId", parentId);
+ setAttribute(Attributes.PARENT_ID, parentId);
// setAttribute("parentKey", parentId);
ResourceType type = resource.getResourceType();
String name = StringUtility.pluralize(type.getName());
setName(name);
- setAttribute("name", name);
+ setAttribute(Attributes.NAME, name);
}
public static String idOf(Resource resource) {
@@ -304,7 +307,7 @@ public class ResourceTreeDatasource extends DataSource {
String id = idOf(resource);
setID(id);
- setAttribute("id", id);
+ setAttribute(Attributes.ID, id);
Resource parentResource = resource.getParentResource();
String parentId;
@@ -317,14 +320,14 @@ public class ResourceTreeDatasource extends DataSource {
parentId = null;
}
setParentID(parentId);
- setAttribute("parentId", parentId);
+ setAttribute(Attributes.PARENT_ID, parentId);
// System.out.println(id + " / " + parentId);
// setAttribute("parentKey",
resource.getParentResource() == null ? 0 : (resource.getParentResource().getId() +
resource.getResourceType().getName()));
setName(resource.getName());
- setAttribute("name", resource.getName());
- setAttribute("description", resource.getDescription());
+ setAttribute(Attributes.NAME, resource.getName());
+ setAttribute(Attributes.DESCRIPTION, resource.getDescription());
ResourceAvailability currentAvail = resource.getCurrentAvailability();
setAttribute(
"currentAvailability",
commit bd4c18a4954c6a8c5351d025dc97c97c8f025c64
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Sep 22 12:30:21 2010 -0400
trivial l&f changes
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/RecoveryAlertDefinitionForm.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/RecoveryAlertDefinitionForm.java
index e6b6cad..86d816b 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/RecoveryAlertDefinitionForm.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/RecoveryAlertDefinitionForm.java
@@ -157,21 +157,22 @@ public class RecoveryAlertDefinitionForm extends
LocatableDynamicForm implements
disableWhenFiredSelection.setValueMap(yesNo);
disableWhenFiredSelection.setDefaultValue("no");
disableWhenFiredSelection.setWrapTitle(false);
+ disableWhenFiredSelection.setWidth(300);
disableWhenFiredSelection
- .setTooltip("If this setting is turned on, then this alert will be
disabled after it fires. When this occurs, the only way for the alert to be able to fire
again is if a user manually re-enables the alert, or if a recovery alert triggers and
automatically re-enables this alert. If this alert is a recovery alert itself, it cannot
be disabled after it fires so it can always recover its target alert.");
+ .setTooltip("Indicates if this alert will be disabled after it
fires. Once disabled, the alert can be manually re-enabled or a recovery alert can be set
up to automatically re-enable it. If this alert is a recovery alert itself, this setting
cannot be turned on.");
disableWhenFiredStatic = new
StaticTextItem("disableWhenFiredStatic", "Disable When Fired");
disableWhenFiredStatic.setWrapTitle(false);
recoverAlertSelection = new SelectItem("recoveryAlert",
"Recover Alert");
recoverAlertSelection.setDefaultValue("0");
recoverAlertSelection.setWrapTitle(false);
- recoverAlertSelection.setRedrawOnChange(true);
recoverAlertSelection
- .setTooltip("If this alert is a recovery alert, this option lets you
select the target alert that will be re-enabled after this alert triggers. If this is not
a recovery alert, do not select an alert here.");
+ .setTooltip("The target alert that will be recovered (i.e.
re-enabled) after this alert triggers. Do not select an alert here if you are not defining
a recovery alert.");
recoverAlertStatic = new StaticTextItem("recoveryAlertStatic",
"Recover Alert");
recoverAlertStatic.setDefaultValue(getNoRecoveryMenuItemTitle());
recoverAlertStatic.setWrapTitle(false);
+ recoverAlertStatic.setWidth(300);
// if a recovery alert is set, then this alert definition must not disable
itself when fired
// because it will be needed to recover its recovery alert the next time it
fires. disabling is only
@@ -255,7 +256,7 @@ public class RecoveryAlertDefinitionForm extends LocatableDynamicForm
implements
}
}
- recoverAlertSelection.redraw();
+ markForRedraw();
}
private void refreshDisableWhenFiredSelection(String recoveryAlertDefId) {
@@ -265,7 +266,8 @@ public class RecoveryAlertDefinitionForm extends LocatableDynamicForm
implements
disableWhenFiredSelection.setValue("no");
disableWhenFiredSelection.setDisabled(true);
}
- disableWhenFiredSelection.redraw();
+
+ markForRedraw();
}
private String getNoRecoveryMenuItemTitle() {
commit ca19ca4e70a06d02fd701e2aa57a4c7090f4e2f8
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Wed Sep 22 12:24:02 2010 -0400
initial rss portet badge work.
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletWindow.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletWindow.java
index 457b75d..caffe54 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletWindow.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletWindow.java
@@ -27,6 +27,7 @@ import com.smartgwt.client.types.HeaderControls;
import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.HeaderControl;
+import com.smartgwt.client.widgets.HeaderControl.HeaderIcon;
import com.smartgwt.client.widgets.events.ClickEvent;
import com.smartgwt.client.widgets.events.ClickHandler;
import com.smartgwt.client.widgets.events.CloseClickHandler;
@@ -46,6 +47,7 @@ public class PortletWindow extends LocatableWindow {
private DashboardView dashboardView;
private DashboardPortlet dashboardPortlet;
+ private static String RSS = "Rss";
private Portlet view;
@@ -58,6 +60,8 @@ public class PortletWindow extends LocatableWindow {
private ClickHandler helpHandlerDelegate = NO_OP_HANDLER;
+ private ClickHandler rssHandlerDelegate = NO_OP_HANDLER;
+
private ClickHandler settingsHandler = new ClickHandler() {
public void onClick(ClickEvent clickEvent) {
settingsHandlerDelegate.onClick(clickEvent);
@@ -70,6 +74,12 @@ public class PortletWindow extends LocatableWindow {
}
};
+ private ClickHandler rssHandler = new ClickHandler() {
+ public void onClick(ClickEvent clickEvent) {
+ rssHandlerDelegate.onClick(clickEvent);
+ }
+ };
+
private ClickHandler refreshHandler = new ClickHandler() {
public void onClick(ClickEvent clickEvent) {
if (PortletWindow.this.view instanceof Table) {
@@ -91,6 +101,11 @@ public class PortletWindow extends LocatableWindow {
// setShowHeader(false);
// setShowEdges(false);
+ //configure HeaderControls with toolTips
+ LocatableHeaderControl RssHeader = new
LocatableHeaderControl(extendLocatorId(RSS), new HeaderIcon(
+ "[SKIN]/headerIcons/clipboard.png"), rssHandler);
+ RssHeader.setTooltip(RSS);
+
// customize the appearance and order of the controls in the window header
setHeaderControls(HeaderControls.MINIMIZE_BUTTON, HeaderControls.HEADER_LABEL,
new LocatableHeaderControl(
extendLocatorId("Refresh"), HeaderControl.REFRESH, refreshHandler),
new LocatableHeaderControl(
commit 9ad4b66bb53ddcab3c3b084ce02620e8eb99b027
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Sep 22 09:46:51 2010 -0400
trivial change to label when no recover alert set
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/RecoveryAlertDefinitionForm.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/RecoveryAlertDefinitionForm.java
index 0e9fe8c..e6b6cad 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/RecoveryAlertDefinitionForm.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/RecoveryAlertDefinitionForm.java
@@ -271,7 +271,7 @@ public class RecoveryAlertDefinitionForm extends LocatableDynamicForm
implements
private String getNoRecoveryMenuItemTitle() {
StringBuilder str = new StringBuilder();
str.append("-- ");
- str.append("No Recovery");
+ str.append("None");
str.append(" --");
return str.toString();
}
commit 43ce65db4af85551e98c636db80f113cb7be2d98
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Sep 21 18:30:53 2010 -0400
Allow Resource.explicitGroups to be passed from server to CoreGUI.
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java
index 25b19b0..66a25be 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java
@@ -86,7 +86,7 @@ public class ResourceGWTServiceImpl extends AbstractGWTServiceImpl
implements Re
// "resourceConfigurationUpdates \n" +
// "pluginConfigurationUpdates \n" +
// "implicitGroups \n" +
- // "explicitGroups \n" +
+ "explicitGroups",
// "contentServiceRequests \n" +
// "createChildResourceRequests \n" +
// "deleteResourceRequests \n" +
commit ef9231d7fcda51f9ca9e64bf91086e2237d63ccd
Merge: 2f19995... ed4c35f...
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Tue Sep 21 18:04:25 2010 -0400
Merge branch 'master' of ssh://spinder@git.fedorahosted.org/git/rhq/rhq into
track-master
commit 2f1999541edf590c3af79484071c28ef6dffeee6
Merge: 09d836b... a67696b...
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Tue Sep 21 16:37:00 2010 -0400
Merge branch 'master' of ssh://spinder@git.fedorahosted.org/git/rhq/rhq into
track-master
commit 09d836bba1d73eef4d48cc6dcf83931b042572fd
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Tue Sep 21 14:52:29 2010 -0400
commit to bind WS namespace to the build versioning.
diff --git a/modules/enterprise/server/jar/pom.xml
b/modules/enterprise/server/jar/pom.xml
index 04d3557..4c4e9a5 100644
--- a/modules/enterprise/server/jar/pom.xml
+++ b/modules/enterprise/server/jar/pom.xml
@@ -406,7 +406,16 @@
<build>
<finalName>${project.artifactId}</finalName>
+ <!-- point to new source code directory that has been filtered. -->
+ <sourceDirectory>target/filtered-sources/java</sourceDirectory>
+
<resources>
+ <!-- Redefine which directories to treat like resources(which are filtered).
-->
+ <resource>
+ <directory>src/main/java</directory>
+ <filtering>true</filtering>
+ <targetPath>../filtered-sources/java</targetPath>
+ </resource>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/system/ServerVersion.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/system/ServerVersion.java
index e8114aa..275a5c6 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/system/ServerVersion.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/system/ServerVersion.java
@@ -42,10 +42,8 @@ public class ServerVersion implements Serializable {
private String version;
private String build;
- //This value must be set by build system just before Build Time.
- public static final String namespace =
"http://www.rhq-project.org/2.4/2010/7/Webservices.xsd";
-
- // private final String namespace = "@ws-namespace@";
+ //This value must be set by build system just before Build/Compile Time.
+ public static final String namespace =
"http://www.rhq-project.org/${pom.version}/Webservices.xsd";
public ServerVersion(String version, String build) {
this.version = version;
commit 2fa80f50dfdbf1ba8820f1300066b669e2328eb1
Merge: 9075e22... c073bce...
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Tue Sep 21 14:36:28 2010 -0400
Merge branch 'master' of ssh://spinder@git.fedorahosted.org/git/rhq/rhq into
track-master
commit 9075e226eaac9f7476d7b51f8582749eea54d50d
Merge: aba004b... 73c0d37...
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Tue Sep 21 09:10:35 2010 -0400
Merge branch 'master' of ssh://spinder@git.fedorahosted.org/git/rhq/rhq into
track-master
commit aba004b202fd48d2d869908b96052cae9d9a5aca
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Tue Sep 21 08:40:46 2010 -0400
RecentAlerts config changes and some modifications to super classes for reuse.
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletDataSource.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletDataSource.java
index a639fca..d21ab76 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletDataSource.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletDataSource.java
@@ -7,10 +7,15 @@ import com.smartgwt.client.rpc.RPCResponse;
import org.rhq.core.domain.alert.Alert;
import org.rhq.core.domain.alert.AlertPriority;
+import org.rhq.core.domain.configuration.Property;
+import org.rhq.core.domain.configuration.PropertyList;
+import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.criteria.AlertCriteria;
+import org.rhq.core.domain.dashboard.DashboardPortlet;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.alerts.RecentAlertsPortlet;
public class AlertPortletDataSource extends AlertDataSource {
//configuration attributes
@@ -19,12 +24,50 @@ public class AlertPortletDataSource extends AlertDataSource {
private long alertTimeRange = -1;
private String alertResourcesToUse = "all";
private Integer[] alertFilterResourceIds = {};
+ private DashboardPortlet portlet = null;
+
+ public AlertPortletDataSource() {
+ super();
+ }
+
+ public AlertPortletDataSource(DashboardPortlet recentAlertsPortlet) {
+ super();
+ this.portlet = recentAlertsPortlet;
+ }
/** Override the executeFetch for AlertPortlet to allow specifying smaller than
total
* result displays.
*/
protected void executeFetch(final DSRequest request, final DSResponse response) {
final long start = System.currentTimeMillis();
+ //retrieve previous settings from portlet config
+ if ((portlet != null) && (this.portlet instanceof DashboardPortlet)) {
+ //must check for whether portlet config
+ PropertySimple property = portlet.getConfiguration().getSimple(
+ RecentAlertsPortlet.ALERT_RANGE_RESOURCES_VALUE);
+ if ((property != null) && (property.getStringValue() != null)) {
+ //retrieve and translate to int
+ String retrieved = property.getStringValue();
+ if
(retrieved.trim().equalsIgnoreCase(RecentAlertsPortlet.RESOURCES_SELECTED)) {
+ setAlertResourcesToUse(RecentAlertsPortlet.RESOURCES_SELECTED);
+ } else {
+ setAlertResourcesToUse(RecentAlertsPortlet.RESOURCES_ALL);
+ }
+ //if 'selected' then check for previously set resource ids to
filter on
+ if
(getAlertResourcesToUse().equals(RecentAlertsPortlet.RESOURCES_SELECTED)) {
+ Integer[] alertResourceFilterIds = null;
+ alertResourceFilterIds = extractFilterResourceIds(portlet,
alertResourceFilterIds);
+ if (alertFilterResourceIds != null) {
+ setAlertFilterResourceId(alertFilterResourceIds);
+ }
+ }
+ } else {//create setting
+ portlet.getConfiguration().put(
+ new PropertySimple(RecentAlertsPortlet.ALERT_RANGE_RESOURCES_VALUE,
+ RecentAlertsPortlet.defaultResourceValue));
+ setAlertResourcesToUse(RecentAlertsPortlet.RESOURCES_ALL);
+ }
+ }
AlertCriteria criteria = new AlertCriteria();
criteria.fetchAlertDefinition(true);
@@ -34,7 +77,8 @@ public class AlertPortletDataSource extends AlertDataSource {
PageControl pc = new PageControl(0, getAlertRangeCompleted());
criteria.setPageControl(pc);//display per page
criteria.addFilterStartTime(getAlertTimeRange());//alert age
- if (getAlertResourcesToUse().equalsIgnoreCase("selected")) {
+ if
((getAlertResourcesToUse().equalsIgnoreCase(RecentAlertsPortlet.RESOURCES_SELECTED))
+ && (getAlertFilterResourceIds().length > 0)) {
//add resource ids to filter on
criteria.addFilterResourceIds(getAlertFilterResourceIds());
}
@@ -99,4 +143,25 @@ public class AlertPortletDataSource extends AlertDataSource {
public void setAlertFilterResourceId(Integer[] alertFilterResourceId) {
this.alertFilterResourceIds = alertFilterResourceId;
}
+
+ public Integer[] extractFilterResourceIds(DashboardPortlet storedPortlet, Integer[]
filterResourceIds) {
+ PropertyList propertyList = storedPortlet.getConfiguration().getList(
+ RecentAlertsPortlet.ALERT_RANGE_RESOURCE_IDS);
+ if ((propertyList != null) && (propertyList.getList() != null) &&
(!propertyList.getList().isEmpty())
+ && (propertyList.getList().get(0) != null)) {
+ Property container = propertyList.getList().get(0);
+ if (container instanceof PropertyList) {
+ PropertyList anotherList = (PropertyList) container;
+ if (anotherList.getList() != null) {
+ filterResourceIds = new Integer[anotherList.getList().size()];
+ int index = 0;
+ for (Property p : anotherList.getList()) {
+ filterResourceIds[index++] = ((PropertySimple)
p).getIntegerValue();
+ }
+ }
+ }
+ }
+ return filterResourceIds;
+ }
+
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/selector/AbstractSelector.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/selector/AbstractSelector.java
index 1c8774f..e5a9d1f 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/selector/AbstractSelector.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/selector/AbstractSelector.java
@@ -182,6 +182,7 @@ public abstract class AbstractSelector<T> extends
LocatableVLayout {
updateButtons();
}
});
+
removeButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent clickEvent) {
deselect(assignedGrid.getSelection());
@@ -265,6 +266,16 @@ public abstract class AbstractSelector<T> extends
LocatableVLayout {
addMember(hlayout);
}
+ protected ClickHandler getAddButtonClickHandler() {
+ return new ClickHandler() {
+ public void onClick(ClickEvent clickEvent) {
+ assignedGrid.transferSelectedData(availableGrid);
+ select(assignedGrid.getSelection());
+ updateButtons();
+ }
+ };
+ }
+
@Override
protected void onDestroy() {
super.onDestroy();
@@ -310,4 +321,16 @@ public abstract class AbstractSelector<T> extends
LocatableVLayout {
}
availableGrid.markForRedraw();
}
+
+ public LocatableListGrid getAvailableGrid() {
+ return availableGrid;
+ }
+
+ public LocatableListGrid getAssignedGrid() {
+ return assignedGrid;
+ }
+
+ // public TransferImgButton getAddButton() {
+ // return addButton;
+ // }
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java
index 9e0ee74..c3dea19 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java
@@ -223,13 +223,13 @@ public class DashboardsView extends LocatableVLayout implements
BookmarkableView
DashboardPortlet discoveryQueue = new DashboardPortlet("Discovery
Queue", AutodiscoveryPortlet.KEY, 250);
dashboard.addPortlet(discoveryQueue, 1, 2);
- DashboardPortlet recentAlerts = new DashboardPortlet("Recent Alerts",
RecentAlertsPortlet.KEY, 250);
+ DashboardPortlet recentAlerts = new DashboardPortlet(RecentAlertsPortlet.KEY,
RecentAlertsPortlet.KEY, 250);
dashboard.addPortlet(recentAlerts, 1, 3);
DashboardPortlet recentlyAdded = new DashboardPortlet("Recently Added
Resources", RecentlyAddedView.KEY, 250);
dashboard.addPortlet(recentlyAdded, 1, 4);
- DashboardPortlet operations = new DashboardPortlet("Operations",
OperationsPortlet.KEY, 250);
+ DashboardPortlet operations = new DashboardPortlet("Operations",
OperationsPortlet.KEY, 500);
dashboard.addPortlet(operations, 1, 5);
DashboardPortlet problemResources = new DashboardPortlet("Has Alerts or
Currently Unavailable",
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/RecentAlertsPortlet.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/RecentAlertsPortlet.java
index c1a4ef9..f88f949 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/RecentAlertsPortlet.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/RecentAlertsPortlet.java
@@ -19,6 +19,9 @@
package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.alerts;
import com.smartgwt.client.data.Criteria;
+import com.smartgwt.client.data.Record;
+import com.smartgwt.client.data.RecordList;
+import com.smartgwt.client.types.ListGridFieldType;
import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.HTMLFlow;
@@ -27,24 +30,34 @@ import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.events.SubmitValuesEvent;
import com.smartgwt.client.widgets.form.events.SubmitValuesHandler;
import com.smartgwt.client.widgets.form.fields.SelectItem;
+import com.smartgwt.client.widgets.form.fields.SpacerItem;
import com.smartgwt.client.widgets.form.fields.events.ChangeEvent;
import com.smartgwt.client.widgets.form.fields.events.ChangeHandler;
+import com.smartgwt.client.widgets.grid.ListGridField;
+import com.smartgwt.client.widgets.grid.events.DataArrivedEvent;
+import com.smartgwt.client.widgets.grid.events.DataArrivedHandler;
+import com.smartgwt.client.widgets.layout.HLayout;
import com.smartgwt.client.widgets.layout.VLayout;
import org.rhq.core.domain.alert.AlertPriority;
+import org.rhq.core.domain.configuration.PropertyList;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.dashboard.DashboardPortlet;
+import org.rhq.core.domain.resource.ResourceType;
import org.rhq.enterprise.gui.coregui.client.alert.AlertPortletDataSource;
import org.rhq.enterprise.gui.coregui.client.alert.AlertsView;
import org.rhq.enterprise.gui.coregui.client.dashboard.CustomSettingsPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow;
+import org.rhq.enterprise.gui.coregui.client.inventory.groups.wizard.GroupMembersStep;
+import
org.rhq.enterprise.gui.coregui.client.inventory.resource.selection.ResourceSelector;
import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableLabel;
/**
+ * @author Simeon Pinder
* @author Greg Hinkle
*/
public class RecentAlertsPortlet extends AlertsView implements CustomSettingsPortlet {
@@ -52,10 +65,11 @@ public class RecentAlertsPortlet extends AlertsView implements
CustomSettingsPor
public static final String KEY = "Recent Alerts";
public static final String TITLE = KEY;
//widget keys also used in form population
- private static final String ALERT_RANGE_DISPLAY_AMOUNT_VALUE =
"alert-range-display-amount-value";
- private static final String ALERT_RANGE_PRIORITY_VALUE =
"alert-range-priority-value";
- private static final String ALERT_RANGE_TIME_VALUE =
"alert-range-time-value";
- private static final String ALERT_RANGE_RESOURCES_VALUE =
"alert-range-resource-value";
+ public static final String ALERT_RANGE_DISPLAY_AMOUNT_VALUE =
"alert-range-display-amount-value";
+ public static final String ALERT_RANGE_PRIORITY_VALUE =
"alert-range-priority-value";
+ public static final String ALERT_RANGE_TIME_VALUE =
"alert-range-time-value";
+ public static final String ALERT_RANGE_RESOURCES_VALUE =
"alert-range-resource-value";
+ public static final String ALERT_RANGE_RESOURCE_IDS =
"alert-range-resource-ids";
//configuration default information
private static final String defaultAlertCountValue = "5";
private static final String PRIORITY_ALL = "ALL";
@@ -70,16 +84,24 @@ public class RecentAlertsPortlet extends AlertsView implements
CustomSettingsPor
private static final String TIME_WEEK = "week";
private static final String TIME_MONTH = "month";
private static final String defaultTimeValue = TIME_DAY;
- private static final String RESOURCES_ALL = "all resources";
- private static final String RESOURCES_SELECTED = "selected resources";
- private static final String defaultResourceValue = RESOURCES_ALL;
+ public static final String RESOURCES_ALL = "all resources";
+ public static final String RESOURCES_SELECTED = "selected resources";
+ public static final String defaultResourceValue = RESOURCES_ALL;
private static final String unlimited = "unlimited";
- //configuration container element
+ //alert resource labels
+ public static final String ALERT_LABEL_SELECTED_RESOURCES = "Selected
Resources";
+ public static final String ALERT_LABEL_AVAILABLE_RESOURCES = "Available
Resources";
+ public static final String ALERT_LABEL_RESOURCE_INVENTORY = "Resource
Inventory";
+ public static final int ALERT_RESOURCE_SELECTION_WIDTH = 800;
+ public static final String ID = "id";
+ //shared private UI elements
+ private AlertResourceSelectorRegion resourceSelector;
private DashboardPortlet storedPortlet = null;
private AlertPortletDataSource dataSource;
+ private Canvas containerCanvas;
+ private HLayout resourceSelectionLabelRow;
public RecentAlertsPortlet(String locatorId) {
- // super(locatorId);
this(locatorId, null, null);
setShowHeader(false);
@@ -106,7 +128,6 @@ public class RecentAlertsPortlet extends AlertsView implements
CustomSettingsPor
//retrieve and translate to int
String retrieved = property.getStringValue();
int translatedAlertRangeSelection =
translatedAlertRangeSelection(retrieved);
- //
getDataSource().setAlertRangeCompleted(Integer.parseInt(retrieved));
getDataSource().setAlertRangeCompleted(translatedAlertRangeSelection);
} else {//create setting
storedPortlet.getConfiguration().put(
@@ -143,13 +164,35 @@ public class RecentAlertsPortlet extends AlertsView implements
CustomSettingsPor
//retrieve and translate to int
String retrieved = property.getStringValue();
if (retrieved.trim().equalsIgnoreCase(RESOURCES_SELECTED)) {
- getDataSource().setAlertResourcesToUse("selected");
+ getDataSource().setAlertResourcesToUse(RESOURCES_SELECTED);
} else {
- getDataSource().setAlertResourcesToUse("all");
+ getDataSource().setAlertResourcesToUse(RESOURCES_ALL);
}
} else {//create setting
storedPortlet.getConfiguration().put(new
PropertySimple(ALERT_RANGE_RESOURCES_VALUE, defaultResourceValue));
- getDataSource().setAlertResourcesToUse("all");
+ getDataSource().setAlertResourcesToUse(RESOURCES_ALL);
+ }
+
+ //resource ids to be conditionally included in the query
+ Integer[] filterResourceIds = null;
+ filterResourceIds = getDataSource().extractFilterResourceIds(storedPortlet,
filterResourceIds);
+ //no defaults
+
+ if (filterResourceIds != null) {
+ getDataSource().setAlertFilterResourceId(filterResourceIds);
+ }
+
+ //conditionally display the selected resources ui
+ if (containerCanvas != null) {
+ //empty out earlier canvas
+ for (Canvas c : containerCanvas.getChildren()) {
+ c.destroy();
+ }
+ if ((resourceSelector != null) &&
getDataSource().getAlertResourcesToUse().equals(RESOURCES_SELECTED)) {
+ containerCanvas.addChild(resourceSelector.getCanvas());
+ } else {
+ containerCanvas.addChild(new Canvas());
+ }
}
}
@@ -222,8 +265,11 @@ public class RecentAlertsPortlet extends AlertsView implements
CustomSettingsPor
//root dynamic form instance
final DynamicForm form = new DynamicForm();
- form.setWidth(200);
+ form.setWidth(RecentAlertsPortlet.ALERT_RESOURCE_SELECTION_WIDTH + 40);//largest
widget display + 40 for buttons
+ form.setHeight(450);
+ form.setMargin(5);
+ //vertical container
VLayout column = new VLayout();
//label
@@ -348,12 +394,29 @@ public class RecentAlertsPortlet extends AlertsView implements
CustomSettingsPor
alertResourcesComboBox.setType("selection");
String[] acceptableResourceDisplayValues = { RESOURCES_ALL, RESOURCES_SELECTED
};
alertResourcesComboBox.setValueMap(acceptableResourceDisplayValues);
- alertResourcesComboBox.setWidth(100);
+ alertResourcesComboBox.setWidth(150);
alertResourcesComboBox.addChangeHandler(new ChangeHandler() {
public void onChange(ChangeEvent event) {
String selectedItem = "" + event.getValue();
//stuff into the master form for retrieval
form.setValue(ALERT_RANGE_RESOURCES_VALUE, selectedItem);
+ //empty out earlier canvas
+ for (Canvas c : containerCanvas.getChildren()) {
+ c.destroy();
+ }
+ if (selectedItem.equals(RESOURCES_SELECTED)) {
+ containerCanvas.addChild(resourceSelector.getCanvas());
+ resourceSelectionLabelRow.setVisible(true);
+ for (Canvas c : resourceSelectionLabelRow.getMembers()) {
+ c.setVisible(true);
+ }
+ } else {
+ containerCanvas.addChild(new Canvas());
+ resourceSelectionLabelRow.setVisible(false);
+ for (Canvas c : resourceSelectionLabelRow.getMembers()) {
+ c.setVisible(false);
+ }
+ }
}
});
@@ -379,8 +442,62 @@ public class RecentAlertsPortlet extends AlertsView implements
CustomSettingsPor
row2.addMember(alertRangeSpanLabel);
row2.addMember(timeSelectionWrapper);
row2.addMember(resourceSelectionWrapper);
+
+ //Row 3 of labels for the alert selected resources area
+ resourceSelectionLabelRow = new HLayout();
+ resourceSelectionLabelRow.setHeight(30);
+ resourceSelectionLabelRow.setMembersMargin(5);
+
resourceSelectionLabelRow.setWidth(RecentAlertsPortlet.ALERT_RESOURCE_SELECTION_WIDTH);//ui
size + fixed button widths
+ Label availableResourcesLabel = new Label("<b>" +
ALERT_LABEL_AVAILABLE_RESOURCES + "</b>");
+ availableResourcesLabel.setHeight(20);
+ availableResourcesLabel.setWrap(false);
+ resourceSelectionLabelRow.addMember(availableResourcesLabel);
+ Label spacer = new Label("");
+ spacer.setWidth(400);
+ Label selectedResourcesLabel = new Label("<b>" +
ALERT_LABEL_SELECTED_RESOURCES + "</b>");
+ selectedResourcesLabel.setHeight(20);
+ selectedResourcesLabel.setWrap(false);
+ resourceSelectionLabelRow.addMember(spacer);
+ resourceSelectionLabelRow.addMember(selectedResourcesLabel);
+
+ //##### if portlet config setting exist, then retrieve#############
+ Integer[] alertFilterResourceIds = null;
+ alertFilterResourceIds = getDataSource().extractFilterResourceIds(storedPortlet,
alertFilterResourceIds);
+ if (alertFilterResourceIds != null) {
+ getDataSource().setAlertFilterResourceId(alertFilterResourceIds);
+ }
+
+ HLayout row4 = new HLayout();
+ row4.setID("row4");
+ // resourceSelector = new MemberSelect();
+ resourceSelector = new AlertResourceSelectorRegion(alertFilterResourceIds);
+ row4.setWidth100();
+ containerCanvas = new Canvas();
+ String retProp =
storedPortlet.getConfiguration().getSimple(ALERT_RANGE_RESOURCES_VALUE).getStringValue();
+
+ //reload the ResourceSelectionRegion if user has chosen to focus on specific
resources with alerts
+ if (retProp.equals(RESOURCES_SELECTED)) {
+ containerCanvas.addChild(resourceSelector.getCanvas());
+ } else {
+ containerCanvas.addChild(new Canvas());
+ //iterate over children of row3 and make invisible
+ for (Canvas c : resourceSelectionLabelRow.getMembers()) {
+ c.setVisible(false);
+ }
+ }
+ //add contain resource selection region.
+ row4.addMember(containerCanvas);
+
+ //finish construction of the layout
column.addMember(row);
column.addMember(row2);
+ SpacerItem verticalSpace = new SpacerItem();
+ verticalSpace.setHeight(20);
+ DynamicForm spacerWrapper = new DynamicForm();
+ spacerWrapper.setItems(verticalSpace);
+ column.addMember(spacerWrapper);
+ column.addMember(resourceSelectionLabelRow);
+ column.addMember(row4);
form.addChild(column);
//submit handler
@@ -390,12 +507,30 @@ public class RecentAlertsPortlet extends AlertsView implements
CustomSettingsPor
//no need to insert validation here as user not allowed to enter values
parseFormAndPopulateConfiguration(form, storedPortlet,
ALERT_RANGE_DISPLAY_AMOUNT_VALUE,
ALERT_RANGE_PRIORITY_VALUE, ALERT_RANGE_RESOURCES_VALUE,
ALERT_RANGE_TIME_VALUE);
+
+ //retrieve alert-resource-selection property
+ PropertySimple prop =
storedPortlet.getConfiguration().getSimple(ALERT_RANGE_RESOURCES_VALUE);
+
+ //check to see if "Selected Resources" or "All
Resources"
+ if (prop.getStringValue().equals(RESOURCES_SELECTED)) {
+ //retrieve currentlyAssignedIds
+ Integer[] valuesToPersist = resourceSelector.getListGridValues();
+ resourceSelector.setCurrentlyAssignedIds(valuesToPersist);
+
+ //build property list of ids to persist
+ PropertyList list = new PropertyList(ALERT_RANGE_RESOURCE_IDS);
+ for (int rid : resourceSelector.getCurrentlyAssignedIds()) {
+ list.add(new PropertySimple(ALERT_RANGE_RESOURCE_IDS, rid));
+ }
+ storedPortlet.getConfiguration().put(new
PropertyList(ALERT_RANGE_RESOURCE_IDS, list));
+
getDataSource().setAlertFilterResourceId(resourceSelector.getCurrentlyAssignedIds());
+ }
refresh();//
+ markForRedraw();
}
});
return form;
-
}
/**Iterates over DynamicForm instance to check for properties passed in and if they
have been set
@@ -428,3 +563,95 @@ public class RecentAlertsPortlet extends AlertsView implements
CustomSettingsPor
}
}
}
+
+class CustomizedResourceSelector extends ResourceSelector {
+ public CustomizedResourceSelector(String id) {
+ super(id);
+ }
+
+ public void addAvailableGridSelectionsToAssignedGrid() {
+ assignedGrid.transferSelectedData(availableGrid);
+ select(assignedGrid.getSelection());
+ updateButtons();
+ }
+}
+
+class AlertResourceSelectorRegion extends GroupMembersStep {
+ // private ResourceSelector selector = null;
+ private CustomizedResourceSelector selector = null;
+ private ResourceType requireType = null;
+ private Integer[] currentlyAssignedIds;
+
+ public Integer[] getCurrentlyAssignedIds() {
+ return currentlyAssignedIds;
+ }
+
+ public Integer[] getListGridValues() {
+ Integer[] listGridValues = new Integer[0];
+ if ((null != selector) && (null != selector.getAssignedGrid())) {
+ RecordList allRecords = selector.getAssignedGrid().getDataAsRecordList();
+ if (allRecords.getLength() > 0) {
+ listGridValues = new Integer[allRecords.getLength()];
+ for (int i = 0; i < allRecords.getLength(); i++) {
+ Record record = allRecords.get(i);
+ listGridValues[i] =
record.getAttributeAsInt(RecentAlertsPortlet.ID);
+ }
+ }
+ }
+ return listGridValues;
+ }
+
+ public AlertResourceSelectorRegion(Integer[] assigned) {
+ super(null);
+ this.currentlyAssignedIds = assigned;
+ }
+
+ public Canvas getCanvas() {
+ ResourceType rt = ResourceType.ANY_PLATFORM_TYPE;
+ if ((selector == null) || (rt != requireType)) {
+ // selector = new ResourceSelector(getName());
+ selector = new CustomizedResourceSelector(getName());
+ selector.setWidth100();
+ selector.setWidth(RecentAlertsPortlet.ALERT_RESOURCE_SELECTION_WIDTH);
+ selector.setRequireType(rt);
+ //widget ui updates
+ selector.getAvailableGrid().setTitle("Available Resources");
+ selector.getAvailableGrid().setEmptyMessage("Loading data...");
+ selector.getAssignedGrid().setTitle("Selected Resources");
+
+ //populate fields for grid.
+ ListGridField nameField = new ListGridField("name",
"Name");
+ ListGridField iconField = new ListGridField("icon",
"icon", 50);
+ iconField.setImageURLPrefix("types/");
+ iconField.setType(ListGridFieldType.ICON);
+ selector.getAssignedGrid().setFields(iconField, nameField);
+
+ //add listener to AvailableGrid, to act after successfully populated.
+ selector.getAvailableGrid().addDataArrivedHandler(new DataArrivedHandler() {
+ @Override
+ public void onDataArrived(DataArrivedEvent event) {
+ if ((getCurrentlyAssignedIds() != null) &&
(getCurrentlyAssignedIds().length > 0)) {
+ //retrieve the loaded data and add to the table itself
+ RecordList recordList =
selector.getAvailableGrid().getDataAsRecordList();
+ for (int ci : getCurrentlyAssignedIds()) {
+ int located = recordList.findIndex("id", ci);
+ if (located > -1) {
+ selector.getAvailableGrid().selectRecord(located);
+ }
+ }
+ selector.addAvailableGridSelectionsToAssignedGrid();
+ selector.getAssignedGrid().invalidateCache();
+ selector.getAssignedGrid().markForRedraw();
+ } else {//no selected resources found
+ selector.getAvailableGrid().setEmptyMessage("No items to
show");
+ }
+ }
+ });
+ }
+ return selector;
+ }
+
+ public void setCurrentlyAssignedIds(Integer[] currentlyAssignedIds) {
+ this.currentlyAssignedIds = currentlyAssignedIds;
+ }
+}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java
index 8a55ed7..71e6eee 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java
@@ -85,7 +85,6 @@ public class ResourceDatasource extends RPCDataSource<Resource> {
}
public void executeFetch(final DSRequest request, final DSResponse response) {
-
ResourceCriteria criteria = getFetchCriteria(request);
resourceService.findResourcesByCriteria(criteria, new
AsyncCallback<PageList<Resource>>() {
@@ -208,4 +207,8 @@ public class ResourceDatasource extends RPCDataSource<Resource>
{
return record;
}
+
+ public ResourceGWTServiceAsync getResourceService() {
+ return resourceService;
+ }
}
commit 4b53c0811d1e0d6d876806ac368a440ce50663c1
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Thu Sep 16 16:13:46 2010 -0400
enable recent alerts config(minus resource selection) and table footer
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java
index 33d32b3..61b58b7 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java
@@ -144,6 +144,7 @@ public class AlertDataSource extends RPCDataSource<Alert> {
AlertCriteria criteria = getCriteria(request);
this.alertService.findAlertsByCriteria(criteria, new
AsyncCallback<PageList<Alert>>() {
+
public void onFailure(Throwable caught) {
CoreGUI.getErrorHandler().handleError("Failed to fetch alerts
data", caught);
response.setStatus(RPCResponse.STATUS_FAILURE);
@@ -153,7 +154,6 @@ public class AlertDataSource extends RPCDataSource<Alert> {
public void onSuccess(PageList<Alert> result) {
long fetchTime = System.currentTimeMillis() - start;
System.out.println(result.size() + " alerts fetched in: " +
fetchTime + "ms");
-
response.setData(buildRecords(result));
// For paging to work, we have to specify size of full result set.
response.setTotalRows(result.getTotalSize());
@@ -296,4 +296,8 @@ public class AlertDataSource extends RPCDataSource<Alert> {
}
});
}
+
+ public AlertGWTServiceAsync getAlertService() {
+ return alertService;
+ }
}
\ No newline at end of file
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletDataSource.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletDataSource.java
new file mode 100644
index 0000000..a639fca
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletDataSource.java
@@ -0,0 +1,102 @@
+package org.rhq.enterprise.gui.coregui.client.alert;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.data.DSRequest;
+import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.rpc.RPCResponse;
+
+import org.rhq.core.domain.alert.Alert;
+import org.rhq.core.domain.alert.AlertPriority;
+import org.rhq.core.domain.criteria.AlertCriteria;
+import org.rhq.core.domain.util.PageControl;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+
+public class AlertPortletDataSource extends AlertDataSource {
+ //configuration attributes
+ private int alertRangeCompleted = -1;
+ private int alertPriorityIndex = -1;
+ private long alertTimeRange = -1;
+ private String alertResourcesToUse = "all";
+ private Integer[] alertFilterResourceIds = {};
+
+ /** Override the executeFetch for AlertPortlet to allow specifying smaller than
total
+ * result displays.
+ */
+ protected void executeFetch(final DSRequest request, final DSResponse response) {
+ final long start = System.currentTimeMillis();
+
+ AlertCriteria criteria = new AlertCriteria();
+ criteria.fetchAlertDefinition(true);
+ criteria.fetchRecoveryAlertDefinition(true);
+ // TODO: Uncomment the below once the bad performance of it has been fixed.
+ //criteria.fetchConditionLogs(true);
+ PageControl pc = new PageControl(0, getAlertRangeCompleted());
+ criteria.setPageControl(pc);//display per page
+ criteria.addFilterStartTime(getAlertTimeRange());//alert age
+ if (getAlertResourcesToUse().equalsIgnoreCase("selected")) {
+ //add resource ids to filter on
+ criteria.addFilterResourceIds(getAlertFilterResourceIds());
+ }
+ if (getAlertPriorityIndex() > 0) {//add priority selection
+
criteria.addFilterPriority(AlertPriority.getByLegacyIndex(getAlertPriorityIndex()));
+ }
+
+ getAlertService().findAlertsByCriteria(criteria, new
AsyncCallback<PageList<Alert>>() {
+
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to fetch alerts
data", caught);
+ response.setStatus(RPCResponse.STATUS_FAILURE);
+ processResponse(request.getRequestId(), response);
+ }
+
+ public void onSuccess(PageList<Alert> result) {
+ long fetchTime = System.currentTimeMillis() - start;
+ System.out.println(result.size() + " alerts fetched in: " +
fetchTime + "ms");
+ response.setData(buildRecords(result));
+ response.setTotalRows(result.size());
+ processResponse(request.getRequestId(), response);
+ }
+ });
+ }
+
+ public int getAlertRangeCompleted() {
+ return alertRangeCompleted;
+ }
+
+ public void setAlertRangeCompleted(int alertRangeCompleted) {
+ this.alertRangeCompleted = alertRangeCompleted;
+ }
+
+ public int getAlertPriorityIndex() {
+ return alertPriorityIndex;
+ }
+
+ public void setAlertPriorityIndex(int alertPriorityIndex) {
+ this.alertPriorityIndex = alertPriorityIndex;
+ }
+
+ public long getAlertTimeRange() {
+ return alertTimeRange;
+ }
+
+ public void setAlertTimeRange(long alertTimeRange) {
+ this.alertTimeRange = alertTimeRange;
+ }
+
+ public String getAlertResourcesToUse() {
+ return alertResourcesToUse;
+ }
+
+ public void setAlertResourcesToUse(String resourcesToUse) {
+ this.alertResourcesToUse = resourcesToUse;
+ }
+
+ public Integer[] getAlertFilterResourceIds() {
+ return alertFilterResourceIds;
+ }
+
+ public void setAlertFilterResourceId(Integer[] alertFilterResourceId) {
+ this.alertFilterResourceIds = alertFilterResourceId;
+ }
+}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/RecentAlertsPortlet.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/RecentAlertsPortlet.java
index 60a3783..c1a4ef9 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/RecentAlertsPortlet.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/RecentAlertsPortlet.java
@@ -18,35 +18,200 @@
*/
package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.alerts;
+import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.HTMLFlow;
+import com.smartgwt.client.widgets.Label;
import com.smartgwt.client.widgets.form.DynamicForm;
+import com.smartgwt.client.widgets.form.events.SubmitValuesEvent;
+import com.smartgwt.client.widgets.form.events.SubmitValuesHandler;
+import com.smartgwt.client.widgets.form.fields.SelectItem;
+import com.smartgwt.client.widgets.form.fields.events.ChangeEvent;
+import com.smartgwt.client.widgets.form.fields.events.ChangeHandler;
+import com.smartgwt.client.widgets.layout.VLayout;
+import org.rhq.core.domain.alert.AlertPriority;
+import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.dashboard.DashboardPortlet;
+import org.rhq.enterprise.gui.coregui.client.alert.AlertPortletDataSource;
import org.rhq.enterprise.gui.coregui.client.alert.AlertsView;
+import org.rhq.enterprise.gui.coregui.client.dashboard.CustomSettingsPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow;
+import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableLabel;
/**
* @author Greg Hinkle
*/
-public class RecentAlertsPortlet extends AlertsView implements Portlet {
+public class RecentAlertsPortlet extends AlertsView implements CustomSettingsPortlet {
public static final String KEY = "Recent Alerts";
+ public static final String TITLE = KEY;
+ //widget keys also used in form population
+ private static final String ALERT_RANGE_DISPLAY_AMOUNT_VALUE =
"alert-range-display-amount-value";
+ private static final String ALERT_RANGE_PRIORITY_VALUE =
"alert-range-priority-value";
+ private static final String ALERT_RANGE_TIME_VALUE =
"alert-range-time-value";
+ private static final String ALERT_RANGE_RESOURCES_VALUE =
"alert-range-resource-value";
+ //configuration default information
+ private static final String defaultAlertCountValue = "5";
+ private static final String PRIORITY_ALL = "ALL";
+ private static final String PRIORITY_HIGH = AlertPriority.HIGH.getDisplayName();
+ private static final String PRIORITY_MEDIUM = AlertPriority.MEDIUM.getDisplayName();
+ private static final String PRIORITY_LOW = AlertPriority.LOW.getDisplayName();
+ private static final String defaultPriorityValue = PRIORITY_ALL;
+ private static final String TIME_30_MINS = "30 minutes";
+ private static final String TIME_HOUR = "hour";
+ private static final String TIME_12_HRS = "12 hours";
+ private static final String TIME_DAY = "day";
+ private static final String TIME_WEEK = "week";
+ private static final String TIME_MONTH = "month";
+ private static final String defaultTimeValue = TIME_DAY;
+ private static final String RESOURCES_ALL = "all resources";
+ private static final String RESOURCES_SELECTED = "selected resources";
+ private static final String defaultResourceValue = RESOURCES_ALL;
+ private static final String unlimited = "unlimited";
+ //configuration container element
+ private DashboardPortlet storedPortlet = null;
+ private AlertPortletDataSource dataSource;
public RecentAlertsPortlet(String locatorId) {
- super(locatorId);
+ // super(locatorId);
+ this(locatorId, null, null);
setShowHeader(false);
- setShowFooter(false);
+ setShowFooter(true);
+ //disable footer refresh
+ setShowFooterRefresh(false);
setOverflow(Overflow.HIDDEN);
}
+ public RecentAlertsPortlet(String locatorId, Criteria criteria, String[]
excludedFieldNames) {
+ super(locatorId, criteria, excludedFieldNames);
+
+ //override the shared datasource
+ this.dataSource = new AlertPortletDataSource();
+ setDataSource(this.dataSource);
+ }
+
public void configure(PortletWindow portletWindow, DashboardPortlet storedPortlet) {
- // TODO: Implement this method.
+ this.storedPortlet = storedPortlet;
+ //Operation range property - retrieve existing value
+ PropertySimple property =
storedPortlet.getConfiguration().getSimple(ALERT_RANGE_DISPLAY_AMOUNT_VALUE);
+ if ((property != null) && (property.getStringValue() != null)) {
+ //retrieve and translate to int
+ String retrieved = property.getStringValue();
+ int translatedAlertRangeSelection =
translatedAlertRangeSelection(retrieved);
+ //
getDataSource().setAlertRangeCompleted(Integer.parseInt(retrieved));
+ getDataSource().setAlertRangeCompleted(translatedAlertRangeSelection);
+ } else {//create setting
+ storedPortlet.getConfiguration().put(
+ new PropertySimple(ALERT_RANGE_DISPLAY_AMOUNT_VALUE,
defaultAlertCountValue));
+
getDataSource().setAlertRangeCompleted(Integer.parseInt(defaultAlertCountValue));
+ }
+ //Operation priority property setting
+ property =
storedPortlet.getConfiguration().getSimple(ALERT_RANGE_PRIORITY_VALUE);
+ if ((property != null) && (property.getStringValue() != null)) {
+ //retrieve and translate to int
+ String retrieved = property.getStringValue();
+ int translatedPriorityIndex = translatedPriorityToValidIndex(retrieved);
+ getDataSource().setAlertPriorityIndex(translatedPriorityIndex);
+ } else {//create setting
+ storedPortlet.getConfiguration().put(new
PropertySimple(ALERT_RANGE_PRIORITY_VALUE, defaultPriorityValue));
+
getDataSource().setAlertPriorityIndex(translatedPriorityToValidIndex(PRIORITY_ALL));
+ }
+
+ //Range to time that alerts will be shown for
+ property = storedPortlet.getConfiguration().getSimple(ALERT_RANGE_TIME_VALUE);
+ if ((property != null) && (property.getStringValue() != null)) {
+ //retrieve and translate to int
+ String retrieved = property.getStringValue();
+ long translatedRange = translateTimeToValidRange(retrieved);
+ getDataSource().setAlertTimeRange(translatedRange);
+ } else {//create setting
+ storedPortlet.getConfiguration().put(new
PropertySimple(ALERT_RANGE_TIME_VALUE, defaultTimeValue));
+
getDataSource().setAlertTimeRange(translateTimeToValidRange(defaultTimeValue));
+ }
+
+ //Range of resources to be included in the query
+ property =
storedPortlet.getConfiguration().getSimple(ALERT_RANGE_RESOURCES_VALUE);
+ if ((property != null) && (property.getStringValue() != null)) {
+ //retrieve and translate to int
+ String retrieved = property.getStringValue();
+ if (retrieved.trim().equalsIgnoreCase(RESOURCES_SELECTED)) {
+ getDataSource().setAlertResourcesToUse("selected");
+ } else {
+ getDataSource().setAlertResourcesToUse("all");
+ }
+ } else {//create setting
+ storedPortlet.getConfiguration().put(new
PropertySimple(ALERT_RANGE_RESOURCES_VALUE, defaultResourceValue));
+ getDataSource().setAlertResourcesToUse("all");
+ }
+ }
+
+ private int translatedAlertRangeSelection(String retrieved) {
+ int translated = -1;
+ if ((retrieved != null) && (!retrieved.trim().isEmpty())) {
+ if (retrieved.equalsIgnoreCase(unlimited)) {
+ translated = -1;
+ } else {
+ translated = Integer.parseInt(retrieved);//default to all
+ }
+ } else {//default to defaultValue
+ if (defaultAlertCountValue.equalsIgnoreCase(unlimited)) {
+ translated = -1;
+ } else {
+ translated = Integer.parseInt(defaultAlertCountValue);
+ }
+ }
+ return translated;
+ }
+
+ private int translatedPriorityToValidIndex(String retrieved) {
+ int translatedPriority = 0;//default to all
+ if ((retrieved != null) && (!retrieved.trim().isEmpty())) {
+ if (retrieved.equalsIgnoreCase(PRIORITY_HIGH)) {
+ translatedPriority = 3;
+ } else if (retrieved.equalsIgnoreCase(PRIORITY_MEDIUM)) {
+ translatedPriority = 2;
+ } else if (retrieved.equalsIgnoreCase(PRIORITY_LOW)) {
+ translatedPriority = 1;
+ } else {
+ translatedPriority = 0;//default to all
+ }
+ }
+ return translatedPriority;
+ }
+
+ /**Translates the UI selection options into time values for alert query.
+ *
+ * @param retrieved
+ * @return long value mapping to string passed in.
+ */
+ private long translateTimeToValidRange(String retrieved) {
+ long translated = 0;//default to ALL
+ if ((retrieved != null) && (!retrieved.trim().isEmpty())) {
+ if (retrieved.equalsIgnoreCase(TIME_30_MINS)) {
+ translated = MeasurementUtility.MINUTES * 30;
+ } else if (retrieved.equalsIgnoreCase(TIME_HOUR)) {
+ translated = MeasurementUtility.HOURS;
+ } else if (retrieved.equalsIgnoreCase(TIME_12_HRS)) {
+ translated = MeasurementUtility.HOURS * 12;
+ } else if (retrieved.equalsIgnoreCase(TIME_DAY)) {
+ translated = MeasurementUtility.DAYS;
+ } else if (retrieved.equalsIgnoreCase(TIME_WEEK)) {
+ translated = MeasurementUtility.WEEKS;
+ } else if (retrieved.equalsIgnoreCase(TIME_MONTH)) {
+ translated = MeasurementUtility.DAYS * 28;//replicated from old struts
def.
+ } else {
+ translated = MeasurementUtility.DAYS;//default to day otherwise.
+ }
+ }
+ return translated;
}
public Canvas getHelpCanvas() {
@@ -54,7 +219,205 @@ public class RecentAlertsPortlet extends AlertsView implements
Portlet {
}
public DynamicForm getCustomSettingsForm() {
- return null; // TODO: Implement this method.
+
+ //root dynamic form instance
+ final DynamicForm form = new DynamicForm();
+ form.setWidth(200);
+
+ VLayout column = new VLayout();
+
+ //label
+ LocatableLabel alertRangeLabel = new
LocatableLabel("DynamicForm_Label_Alert_Range", "<b>Alert
Range</b>");
+
+ //horizontal layout
+ LocatableHLayout row = new
LocatableHLayout("alert-range-settings-row-1");
+ row.setMembersMargin(10);
+
+ //-------------combobox for number of completed scheduled ops to display on the
dashboard
+ final SelectItem alertRangeLastComboBox = new
SelectItem(ALERT_RANGE_DISPLAY_AMOUNT_VALUE);
+ alertRangeLastComboBox.setTitle("Last");
+ alertRangeLastComboBox.setType("selection");
+ //define acceptable values for display amount
+ String[] acceptableDisplayValues = { "5", "10",
"unlimited" };
+ alertRangeLastComboBox.setValueMap(acceptableDisplayValues);
+ //set width of dropdown display region
+ alertRangeLastComboBox.setWidth(100);
+ alertRangeLastComboBox.addChangeHandler(new ChangeHandler() {
+ public void onChange(ChangeEvent event) {
+ String selectedItem = "" + event.getValue();
+ //stuff into the master form for retrieval
+ form.setValue(ALERT_RANGE_DISPLAY_AMOUNT_VALUE, selectedItem);
+ }
+ });
+
+ //default selected value to 'unlimited'(live lists) and check both
combobox settings here.
+ String selectedValue = defaultAlertCountValue;
+ if (storedPortlet != null) {
+ //if property exists retrieve it
+ if
(storedPortlet.getConfiguration().getSimple(ALERT_RANGE_DISPLAY_AMOUNT_VALUE) != null) {
+ selectedValue =
storedPortlet.getConfiguration().getSimple(ALERT_RANGE_DISPLAY_AMOUNT_VALUE)
+ .getStringValue();
+ } else {//insert default value
+ storedPortlet.getConfiguration().put(
+ new PropertySimple(ALERT_RANGE_DISPLAY_AMOUNT_VALUE,
defaultAlertCountValue));
+ }
+ }
+ //prepopulate the combobox with the previously stored selection
+ alertRangeLastComboBox.setDefaultValue(selectedValue);
+
+ //-------------combobox for number of completed scheduled ops to display on the
dashboard
+ final SelectItem alertRangePriorityComboBox = new
SelectItem(ALERT_RANGE_PRIORITY_VALUE);
+ alertRangePriorityComboBox.setTitle("");
+ alertRangePriorityComboBox.setHint("<nobr> <b> priority
Alerts,</b></nobr>");
+ alertRangePriorityComboBox.setType("selection");
+ //define acceptable values for display amount
+ String[] acceptablePriorityDisplayValues = { PRIORITY_ALL, PRIORITY_HIGH,
PRIORITY_MEDIUM, PRIORITY_LOW };
+ alertRangePriorityComboBox.setValueMap(acceptablePriorityDisplayValues);
+ //set width of dropdown display region
+ alertRangePriorityComboBox.setWidth(100);
+ alertRangePriorityComboBox.addChangeHandler(new ChangeHandler() {
+ public void onChange(ChangeEvent event) {
+ String selectedItem = "" + event.getValue();
+ //stuff into the master form for retrieval
+ form.setValue(ALERT_RANGE_PRIORITY_VALUE, selectedItem);
+ }
+ });
+
+ //default selected value to 'unlimited'(live lists) and check both
combobox settings here.
+ selectedValue = defaultPriorityValue;
+ if (storedPortlet != null) {
+ //if property exists retrieve it
+ if (storedPortlet.getConfiguration().getSimple(ALERT_RANGE_PRIORITY_VALUE) !=
null) {
+ selectedValue =
storedPortlet.getConfiguration().getSimple(ALERT_RANGE_PRIORITY_VALUE).getStringValue();
+ } else {//insert default value
+ storedPortlet.getConfiguration().put(
+ new PropertySimple(ALERT_RANGE_PRIORITY_VALUE,
defaultPriorityValue));
+ }
+ }
+ //prepopulate the combobox with the previously stored selection
+ alertRangePriorityComboBox.setDefaultValue(selectedValue);
+ row.addMember(alertRangeLabel);
+ DynamicForm wrappedRange = new DynamicForm();
+ wrappedRange.setFields(alertRangeLastComboBox);
+ row.addMember(wrappedRange);
+
+ DynamicForm wrappedPriority = new DynamicForm();
+ wrappedPriority.setFields(alertRangePriorityComboBox);
+ row.addMember(wrappedPriority);
+
+ //horizontal layout
+ LocatableHLayout row2 = new
LocatableHLayout("alert-range-settings-row-2");
+
+ Label alertRangeSpanLabel = new Label("<b>within the
past<b>");
+ //------------- Build second combobox for timeframe for problem resources
search.
+ final SelectItem alertRangeTimeComboBox = new
SelectItem(ALERT_RANGE_TIME_VALUE);
+ alertRangeTimeComboBox.setTitle("");
+ alertRangeTimeComboBox.setHint("");
+ alertRangeTimeComboBox.setType("selection");
+ String[] acceptableTimeDisplayValues = { TIME_30_MINS, TIME_HOUR, TIME_12_HRS,
TIME_DAY, TIME_WEEK, TIME_MONTH };
+ alertRangeTimeComboBox.setValueMap(acceptableTimeDisplayValues);
+ alertRangeTimeComboBox.setWidth(100);
+ alertRangeTimeComboBox.addChangeHandler(new ChangeHandler() {
+ public void onChange(ChangeEvent event) {
+ String selectedItem = "" + event.getValue();
+ //stuff into the master form for retrieval
+ form.setValue(ALERT_RANGE_TIME_VALUE, selectedItem);
+ }
+ });
+
+ //set to default
+ selectedValue = defaultTimeValue;
+ if (storedPortlet != null) {
+ //if property exists retrieve it
+ if (storedPortlet.getConfiguration().getSimple(ALERT_RANGE_TIME_VALUE) !=
null) {
+ selectedValue =
storedPortlet.getConfiguration().getSimple(ALERT_RANGE_TIME_VALUE).getStringValue();
+ } else {//insert default value
+ storedPortlet.getConfiguration().put(new
PropertySimple(ALERT_RANGE_TIME_VALUE, defaultTimeValue));
+ }
+ }
+ //prepopulate the combobox with the previously stored selection
+ alertRangeTimeComboBox.setDefaultValue(selectedValue);
+ DynamicForm timeSelectionWrapper = new DynamicForm();
+ timeSelectionWrapper.setFields(alertRangeTimeComboBox);
+
+ // build resource selection drop down
+ //------------- Build second combobox for timeframe for problem resources
search.
+ final SelectItem alertResourcesComboBox = new
SelectItem(ALERT_RANGE_RESOURCES_VALUE);
+ alertResourcesComboBox.setTitle("for");
+ alertResourcesComboBox.setHint("");
+ alertResourcesComboBox.setType("selection");
+ String[] acceptableResourceDisplayValues = { RESOURCES_ALL, RESOURCES_SELECTED
};
+ alertResourcesComboBox.setValueMap(acceptableResourceDisplayValues);
+ alertResourcesComboBox.setWidth(100);
+ alertResourcesComboBox.addChangeHandler(new ChangeHandler() {
+ public void onChange(ChangeEvent event) {
+ String selectedItem = "" + event.getValue();
+ //stuff into the master form for retrieval
+ form.setValue(ALERT_RANGE_RESOURCES_VALUE, selectedItem);
+ }
+ });
+
+ //set to default
+ selectedValue = defaultResourceValue;
+ if (storedPortlet != null) {
+ //if property exists retrieve it
+ if (storedPortlet.getConfiguration().getSimple(ALERT_RANGE_RESOURCES_VALUE)
!= null) {
+ selectedValue =
storedPortlet.getConfiguration().getSimple(ALERT_RANGE_RESOURCES_VALUE)
+ .getStringValue();
+ } else {//insert default value
+ storedPortlet.getConfiguration().put(
+ new PropertySimple(ALERT_RANGE_RESOURCES_VALUE,
defaultResourceValue));
+ }
+ }
+ //prepopulate the combobox with the previously stored selection
+ alertResourcesComboBox.setDefaultValue(selectedValue);
+ DynamicForm resourceSelectionWrapper = new DynamicForm();
+ resourceSelectionWrapper.setFields(alertResourcesComboBox);
+
+ alertRangeSpanLabel.setWrap(false);
+ alertRangeSpanLabel.setWidth(150);
+ row2.addMember(alertRangeSpanLabel);
+ row2.addMember(timeSelectionWrapper);
+ row2.addMember(resourceSelectionWrapper);
+ column.addMember(row);
+ column.addMember(row2);
+ form.addChild(column);
+
+ //submit handler
+ form.addSubmitValuesHandler(new SubmitValuesHandler() {
+ @Override
+ public void onSubmitValues(SubmitValuesEvent event) {
+ //no need to insert validation here as user not allowed to enter values
+ parseFormAndPopulateConfiguration(form, storedPortlet,
ALERT_RANGE_DISPLAY_AMOUNT_VALUE,
+ ALERT_RANGE_PRIORITY_VALUE, ALERT_RANGE_RESOURCES_VALUE,
ALERT_RANGE_TIME_VALUE);
+ refresh();//
+ }
+ });
+
+ return form;
+
+ }
+
+ /**Iterates over DynamicForm instance to check for properties passed in and if they
have been set
+ * to put that property into the DashboardPortlet configuration.
+ *
+ * @param form Dynamic form storing user selections
+ * @param portlet Container for configuration changes
+ * @param properties Variable list of keys used to verify or populate properties.
+ */
+ private void parseFormAndPopulateConfiguration(final DynamicForm form,
DashboardPortlet portlet,
+ String... properties) {
+ if ((form != null) && (portlet != null)) {
+ for (String property : properties) {
+ if (form.getValue(property) != null) {//if new value supplied
+ storedPortlet.getConfiguration().put(new PropertySimple(property,
form.getValue(property)));
+ }
+ }
+ }
+ }
+
+ public AlertPortletDataSource getDataSource() {
+ return dataSource;
}
public static final class Factory implements PortletViewFactory {