[rhq] 2 commits - modules/enterprise
by Jay Shaughnessy
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java | 15 +++++++---
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/inventory/resource/detail/ResourceTreeView.java | 1
3 files changed, 14 insertions(+), 5 deletions(-)
New commits:
commit 614e969e489795a4408f23e474507f174c95fdf2
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Oct 1 18:00:25 2010 -0400
Reverting a change made in 6415ed10e3b0d967b712a7be0aa0a3fcf4ce95cb, it
breaks rendering of single-element paths (like "#Bundles or #Reports).
The BookmarkableView's renderView needs to be invoked.
I didn't see any ill effect of adding this back in, so I'm not sure of the
intent of the original change. May need more work.
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 e9b7788..cf9e470 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
@@ -304,12 +304,19 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String> {
}
if (this.currentCanvas instanceof BookmarkableView) {
- viewPath.next();
- if (!viewPath.isEnd()) {
- ((BookmarkableView) this.currentCanvas).renderView(viewPath);
- }
+ ((BookmarkableView) this.currentCanvas).renderView(viewPath.next());
}
+ // reverting this is as it breaks rendering of single-element paths (like "#Bundles or
+ // #Reports. the BookmarkableView's renderView needs to be invoked.
+ //
+ //if (this.currentCanvas instanceof BookmarkableView) {
+ // viewPath.next();
+ // if (!viewPath.isEnd()) {
+ // ((BookmarkableView) this.currentCanvas).renderView(viewPath);
+ // }
+ //}
+
refreshBreadCrumbTrail();
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleView.java
index fb382fa..4dc2182 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
@@ -45,6 +45,7 @@ import org.rhq.enterprise.gui.coregui.client.Breadcrumb;
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.bundle.BundleTopView;
import org.rhq.enterprise.gui.coregui.client.bundle.deploy.BundleDeployWizard;
import org.rhq.enterprise.gui.coregui.client.bundle.deployment.BundleDeploymentView;
import org.rhq.enterprise.gui.coregui.client.bundle.destination.BundleDestinationListView;
@@ -98,7 +99,7 @@ public class BundleView extends LocatableVLayout implements BookmarkableView {
this.bundle = bundle;
- addMember(new BackButton(extendLocatorId("BackButton"), "Back to All Bundles", "Bundles"));
+ addMember(new BackButton(extendLocatorId("BackButton"), "Back to All Bundles", BundleTopView.VIEW_ID));
headerLabel = new HeaderLabel("subsystems/bundle/Bundle_24.png", bundle.getName());
commit 53a86e032a7df9e9c35bb50c9bde6fca72c722aa
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Oct 1 09:57:45 2010 -0400
ResourceTree Authz work
- support for locked nodes
- support for autogroups for non-inventory managers. Now that AGs are
backed by compat groups it's necessary for non-inv-managers
to be able to create and access the private groups that they own. Private
groups (aka subject-owned groups) are new, they are basically groups
that are tagged with the creating subjectId. Those groups can be
created (via a new slsb call) and fetched (via a new ResourceGroupCriteria
filter) w/o inventory manager perms.
- note: i had to move rhq_subject to auth-schema from authz-schema and
slightly change the dbsetup order to make it ok for rhq_resource_group to
reference rhq_subject.
- schema spec bumped to 2.97
- added ResourceLineageComposite to combine Resource and locked/viewable
info.
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 c06c636..d6cfdba 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
@@ -628,6 +628,7 @@ public class ResourceTreeView extends LocatableVLayout {
}
if (!root.equals(ResourceTreeView.this.rootResource)) {
+
if (treeGrid != null) {
treeGrid.destroy();
}
13 years, 8 months
[rhq] modules/enterprise
by mazz
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractNotificationSenderForm.java | 34 ++++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewNotificationEditor.java | 30 ++++++-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SimpleNotificationSenderForm.java | 40 ++++++++--
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/AlertDefinitionGWTService.java | 3
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertDefinitionGWTServiceImpl.java | 12 +++
5 files changed, 108 insertions(+), 11 deletions(-)
New commits:
commit 4d9fbbc3af633a1e59f5148edcb6bab040d618c0
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Oct 1 18:59:21 2010 -0400
create the catch-all simple notif sender config editor
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractNotificationSenderForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractNotificationSenderForm.java
index 357943f..5b8b0b4 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractNotificationSenderForm.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractNotificationSenderForm.java
@@ -37,9 +37,41 @@ public abstract class AbstractNotificationSenderForm extends LocatableVLayout {
private Configuration configuration;
private Configuration extraConfiguration;
+ private final String sender;
- public AbstractNotificationSenderForm(String locatorId) {
+ public AbstractNotificationSenderForm(String locatorId, AlertNotification notif, String sender) {
super(locatorId);
+
+ this.sender = sender;
+
+ if (notif != null) {
+ // make our own deep copies of the configs so we can throw them away without
+ // affecting the actual notif in case the user clicks cancel
+ Configuration notifConfig = notif.getConfiguration();
+ Configuration notifExtraConfig = notif.getExtraConfiguration();
+
+ if (notifConfig != null) {
+ configuration = notifConfig.deepCopy(true);
+ } else {
+ configuration = new Configuration(); // must not be null
+ }
+ if (notifExtraConfig != null) {
+ extraConfiguration = notifExtraConfig.deepCopy(true);
+ } else {
+ extraConfiguration = null; // allowed to be null
+ }
+ } else {
+ configuration = new Configuration();
+ extraConfiguration = null;
+ }
+ }
+
+ /**
+ * The name of the alert sender that is to be configured.
+ * @return the sender name
+ */
+ public String getSender() {
+ return sender;
}
/**
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewNotificationEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewNotificationEditor.java
index 92d8f75..390357c 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewNotificationEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewNotificationEditor.java
@@ -197,11 +197,33 @@ public class NewNotificationEditor extends LocatableDynamicForm {
if (oldCanvas != null) {
oldCanvas.markForDestroy();
}
-
- // TODO: need to create different forms for different types of senders
- SimpleNotificationSenderForm newCanvas = new SimpleNotificationSenderForm(extendLocatorId(newAlertSender));
+ AbstractNotificationSenderForm newCanvas = createNotificationSenderForm(newAlertSender);
senderCanvasItem.setCanvas(newCanvas);
-
markForRedraw();
}
+
+ private AbstractNotificationSenderForm createNotificationSenderForm(String sender) {
+ String newLocatorId = extendLocatorId(sender);
+ AbstractNotificationSenderForm newCanvas;
+
+ // NOTE: today there is no way for an alert server plugin developer
+ // to be able to provide us with a custom UI component to render (like we used to be able
+ // to do when the ui was implemented in JSF and the server plugin can give us a JSF snippet).
+ // We have to hard code the names of the "special" plugins that require special UIs which
+ // are necessary to build the sender configuration for these special alert senders.
+ // For those that want to write their own custom alert plugins, you are restricted to
+ // using configuration definitions as the only way to configure the sender.
+ if ("System Users".equals(sender)) {
+ newCanvas = null; // TODO
+ } else if ("System Roles".equals(sender)) {
+ newCanvas = null; // TODO
+ } else if ("Resource Operations".equals(sender)) {
+ newCanvas = null; // TODO
+ } else {
+ // catch all - all other senders are assumed to just have simple configuration definition
+ // that can be used by our configuration editor UI component to ask for config values.
+ newCanvas = new SimpleNotificationSenderForm(newLocatorId, notificationToEdit, sender);
+ }
+ return newCanvas;
+ }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SimpleNotificationSenderForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SimpleNotificationSenderForm.java
index a70bd82..4a16380 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SimpleNotificationSenderForm.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SimpleNotificationSenderForm.java
@@ -23,8 +23,15 @@
package org.rhq.enterprise.gui.coregui.client.alert.definitions;
+import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.widgets.Label;
+import org.rhq.core.domain.alert.notification.AlertNotification;
+import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.components.configuration.ConfigurationEditor;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+
/**
* This notification form will be used for most alert senders since most alert senders
* only need to be given a simple set of configuration properties where the user
@@ -34,14 +41,35 @@ import com.smartgwt.client.widgets.Label;
*/
public class SimpleNotificationSenderForm extends AbstractNotificationSenderForm {
- public SimpleNotificationSenderForm(String locatorId) {
- super(locatorId);
+ public SimpleNotificationSenderForm(String locatorId, AlertNotification notif, String sender) {
+ super(locatorId, notif, sender);
}
@Override
- protected void onInit() {
- super.onInit();
- // TODO add config editor
- addMember(new Label("simple form : " + getLocatorId()));
+ protected void onDraw() {
+ super.onDraw();
+
+ GWTServiceLookup.getAlertDefinitionService().getConfigurationDefinitionForSender(getSender(),
+ new AsyncCallback<ConfigurationDefinition>() {
+ @Override
+ public void onSuccess(ConfigurationDefinition configDef) {
+ ConfigurationEditor configEditor = new ConfigurationEditor(extendLocatorId("configEditor"),
+ configDef, getConfiguration());
+ configEditor.setHeight(500);
+ configEditor.setWidth(500);
+ addMember(configEditor);
+ markForRedraw();
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ String errMsg = "Cannot get alert sender configuration definition";
+ CoreGUI.getErrorHandler().handleError(errMsg, caught);
+ Label label = new Label(errMsg);
+ label.setIcon("[SKIN]/Dialog/error.png");
+ addMember(label);
+ markForRedraw();
+ }
+ });
}
}
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 ee93aed..ceb427e 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
@@ -22,6 +22,7 @@ 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.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.criteria.AlertDefinitionCriteria;
import org.rhq.core.domain.util.PageList;
@@ -43,4 +44,6 @@ public interface AlertDefinitionGWTService extends RemoteService {
String[] getAlertNotificationConfigurationPreview(AlertNotification[] notifs) throws Exception;
String[] getAllAlertSenders() throws Exception;
+
+ ConfigurationDefinition getConfigurationDefinitionForSender(String sender) 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 b906473..ada48ab 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
@@ -22,6 +22,7 @@ import java.util.List;
import org.rhq.core.domain.alert.AlertDefinition;
import org.rhq.core.domain.alert.notification.AlertNotification;
+import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.criteria.AlertDefinitionCriteria;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.util.exception.ThrowableUtil;
@@ -122,4 +123,15 @@ public class AlertDefinitionGWTServiceImpl extends AbstractGWTServiceImpl implem
throw new RuntimeException(ThrowableUtil.getAllMessages(e));
}
}
+
+ @Override
+ public ConfigurationDefinition getConfigurationDefinitionForSender(String sender) throws Exception {
+ try {
+ ConfigurationDefinition results = alertNotifManager.getConfigurationDefinitionForSender(sender);
+ return SerialUtility.prepare(results, "getConfigurationDefinitionForSender");
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
+ }
+
}
\ No newline at end of file
13 years, 8 months
[rhq] 2 commits - modules/enterprise
by John Sanda
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBeanTest.java | 39 +++++++++-
modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/configuration/metadata/configuration_metadata_manager_bean_test_v1.xml | 8 ++
modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/configuration/metadata/configuration_metadata_manager_bean_test_v2.xml | 17 ++++
3 files changed, 63 insertions(+), 1 deletion(-)
New commits:
commit 54400ac63137b081d50b7bdac7419b44e9ab2dbc
Merge: 9cfec33... cd224c2...
Author: John Sanda <jsanda(a)redhat.com>
Date: Thu Sep 30 16:48:03 2010 -0400
Merge branch 'master' of ssh://git.fedorahosted.org/git/rhq/rhq
commit 9cfec33df4ca3f5975a2a6ba72c6b6a5ddc09cdd
Author: John Sanda <jsanda(a)redhat.com>
Date: Thu Sep 30 16:47:49 2010 -0400
Updating tests
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBeanTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBeanTest.java
index bc0d6c5..5e2913b 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBeanTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBeanTest.java
@@ -24,11 +24,13 @@
package org.rhq.enterprise.server.configuration.metadata;
import javax.persistence.EntityManager;
+import javax.transaction.SystemException;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.rhq.core.clientapi.descriptor.plugin.PluginDescriptor;
+import org.rhq.core.clientapi.descriptor.plugin.ServerDescriptor;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
import org.rhq.core.domain.configuration.definition.PropertyGroupDefinition;
@@ -91,6 +93,20 @@ public class ConfigurationMetadataManagerBeanTest extends AbstractEJB3Test {
"not change", expected, actual);
}
+ // This test fails with,
+ //
+ // PersistentObjectException: detached entity passed to persist
+ //
+ // I get the exception with both PropertyGroupDefinition and PropertyDefinitionSimple when I have tried various
+ // approaches to get past the exception.
+ @Test(enabled = false)
+ public void addNewGroup() {
+ initConfigDefs("servers[name='GroupTests']", "GroupTests");
+
+ assertNotNull("The new property should be added to the configuration definition",
+ findGroup("newGroup", originalConfigDef));
+ }
+
// void assertGroupDefinitionExists() {
// for (PropertyGroupDefinition groupDef : originalConfigurationDef.getGroupDefinitions()) {
// if (groupDef.getName().equals("groupToBeRemoved")) {
@@ -107,17 +123,24 @@ public class ConfigurationMetadataManagerBeanTest extends AbstractEJB3Test {
private void loadAndPersistConfigDefs(String path, String configName) {
originalConfigDef = loadPluginConfigDefFor(originalDescriptor, path, configName);
+ assertNotNull(originalConfigDef);
updatedConfigDef = loadPluginConfigDefFor(updatedDescriptor, path, configName);
+ assertNotNull(updatedConfigDef);
try {
getTransactionManager().begin();
EntityManager entityMgr = getEntityManager();
entityMgr.persist(originalConfigDef);
- entityMgr.persist(updatedConfigDef);
+ //entityMgr.persist(updatedConfigDef);
getTransactionManager().commit();
} catch (Exception e) {
+ try {
+ getTransactionManager().rollback();
+ } catch (SystemException e1) {
+ throw new RuntimeException(e1);
+ }
throw new RuntimeException(e);
}
}
@@ -131,6 +154,11 @@ public class ConfigurationMetadataManagerBeanTest extends AbstractEJB3Test {
getTransactionManager().commit();
} catch (Exception e) {
+ try {
+ getTransactionManager().rollback();
+ } catch (SystemException e1) {
+ throw new RuntimeException(e1);
+ }
throw new RuntimeException(e);
}
}
@@ -139,6 +167,15 @@ public class ConfigurationMetadataManagerBeanTest extends AbstractEJB3Test {
return "/" + getClass().getPackage().getName().replace('.', '/') + "/";
}
+ private PropertyGroupDefinition findGroup(String name, ConfigurationDefinition configDef) {
+ for (PropertyGroupDefinition groupDef : configDef.getGroupDefinitions()) {
+ if (groupDef.getName().equals(name)) {
+ return groupDef;
+ }
+ }
+ return null;
+ }
+
void assertPropertyDefinitionMatches(String msg, PropertyDefinitionSimple expected,
PropertyDefinitionSimple actual) {
AssertUtils.assertPropertiesMatch(msg, expected, actual, "id", "configurationDefinition");
diff --git a/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/configuration/metadata/configuration_metadata_manager_bean_test_v1.xml b/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/configuration/metadata/configuration_metadata_manager_bean_test_v1.xml
index 131cff7..dd8fcfa 100644
--- a/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/configuration/metadata/configuration_metadata_manager_bean_test_v1.xml
+++ b/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/configuration/metadata/configuration_metadata_manager_bean_test_v1.xml
@@ -18,4 +18,12 @@
description="This property exists only in version 1 of the plugin"/>
</plugin-configuration>
</server>
+
+ <server name="GroupTests">
+ <plugin-configuration>
+ <c:group name="existingGroup">
+ <c:simple-property name="existingGroupProperty"/>
+ </c:group>
+ </plugin-configuration>
+ </server>
</plugin>
diff --git a/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/configuration/metadata/configuration_metadata_manager_bean_test_v2.xml b/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/configuration/metadata/configuration_metadata_manager_bean_test_v2.xml
index 2c94f72..d090e76 100644
--- a/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/configuration/metadata/configuration_metadata_manager_bean_test_v2.xml
+++ b/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/configuration/metadata/configuration_metadata_manager_bean_test_v2.xml
@@ -25,4 +25,21 @@
summary="false"/>
</plugin-configuration>
</server>
+
+ <server name="GroupTests">
+ <plugin-configuration>
+ <c:group name="existingGroup">
+ <c:simple-property name="existingGroupProperty"/>
+ </c:group>
+
+ <c:group name="newGroup">
+ <c:simple-property name="newGroupProperty"
+ description="A new, grouped property"
+ activationPolicy="immediate"
+ default="new grouped property"
+ displayName="New Group Property"
+ readOnly="true"/>
+ </c:group>
+ </plugin-configuration>
+ </server>
</plugin>
13 years, 8 months
[rhq] 2 commits - modules/enterprise
by mazz
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractNotificationSenderForm.java | 70 ++++++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewNotificationEditor.java | 60 +++++---
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SimpleNotificationSenderForm.java | 47 ++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java | 19 ++
5 files changed, 178 insertions(+), 20 deletions(-)
New commits:
commit cd224c2d8b3c2a2ed53d5b66ec4bbdb66b404a41
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Oct 1 14:33:01 2010 -0400
start building framework for the different forms needed for the different senders
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractNotificationSenderForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractNotificationSenderForm.java
new file mode 100644
index 0000000..357943f
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractNotificationSenderForm.java
@@ -0,0 +1,70 @@
+/*
+ * 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.alert.definitions;
+
+import org.rhq.core.domain.alert.notification.AlertNotification;
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+
+/**
+ * Superclass to all alert senders' forms. Instances of this class
+ * are displayed when switching the drop-down option menu selecting
+ * a specific sender.
+ *
+ * @author John Mazzitelli
+ */
+public abstract class AbstractNotificationSenderForm extends LocatableVLayout {
+
+ private Configuration configuration;
+ private Configuration extraConfiguration;
+
+ public AbstractNotificationSenderForm(String locatorId) {
+ super(locatorId);
+ }
+
+ /**
+ * The {@link AlertNotification#getConfiguration()} for the new alert definition notification.
+ *
+ * @return the configuration
+ */
+ public Configuration getConfiguration() {
+ return configuration;
+ }
+
+ public void setConfiguration(Configuration configuration) {
+ this.configuration = configuration;
+ }
+
+ /**
+ * The {@link AlertNotification#getExtraConfiguration()} for the new alert definition notification.
+ *
+ * @return the extra configuration
+ */
+ public Configuration getExtraConfiguration() {
+ return extraConfiguration;
+ }
+
+ public void setExtraConfiguration(Configuration extraConfiguration) {
+ this.extraConfiguration = extraConfiguration;
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewNotificationEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewNotificationEditor.java
index 5da3c43..92d8f75 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewNotificationEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewNotificationEditor.java
@@ -28,12 +28,14 @@ import java.util.LinkedHashMap;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.types.Alignment;
-import com.smartgwt.client.widgets.form.DynamicForm;
-import com.smartgwt.client.widgets.form.FormItemIfFunction;
+import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.form.fields.ButtonItem;
+import com.smartgwt.client.widgets.form.fields.CanvasItem;
import com.smartgwt.client.widgets.form.fields.FormItem;
import com.smartgwt.client.widgets.form.fields.SelectItem;
import com.smartgwt.client.widgets.form.fields.SpacerItem;
+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.ClickEvent;
import com.smartgwt.client.widgets.form.fields.events.ClickHandler;
@@ -54,6 +56,7 @@ public class NewNotificationEditor extends LocatableDynamicForm {
private final Runnable closeFunction; // this is called after a button is pressed and the editor should close
private SelectItem notificationSenderSelectItem;
+ private CanvasItem senderCanvasItem;
public NewNotificationEditor(String locatorId, AlertDefinition alertDefinition,
ArrayList<AlertNotification> notifs, AlertNotification notifToEdit, Runnable closeFunc) {
@@ -71,17 +74,30 @@ public class NewNotificationEditor extends LocatableDynamicForm {
setMargin(20);
+ // this is the container that will house the sender-specific form components
+ senderCanvasItem = new CanvasItem();
+ senderCanvasItem.setShowTitle(false);
+ senderCanvasItem.setColSpan(2);
+
notificationSenderSelectItem = new SelectItem("notificationSender", "Notification Sender");
+ notificationSenderSelectItem.setDefaultToFirstOption(true);
+ notificationSenderSelectItem.setWrapTitle(false);
+ notificationSenderSelectItem.setRedrawOnChange(true);
+ notificationSenderSelectItem.setWidth("*");
if (notificationToEdit != null) {
// we were given a notification to edit, you can't change the sender type, its the only option
notificationSenderSelectItem.setDisabled(true);
+ String senderName = notificationToEdit.getSenderName();
LinkedHashMap<String, String> senders = new LinkedHashMap<String, String>(1);
- senders.put(notificationToEdit.getSenderName(), notificationToEdit.getSenderName());
+ senders.put(senderName, senderName);
notificationSenderSelectItem.setValueMap(senders);
+ switchToAlertSender(senderName);
+ senderCanvasItem.setVisible(true);
} else {
notificationSenderSelectItem.setValueMap("Loading...");
notificationSenderSelectItem.setDisabled(true);
+ senderCanvasItem.setVisible(false); // don't show it yet, until we determine what senders exist
// we are creating a new notification, need to provide all senders as options
GWTServiceLookup.getAlertDefinitionService().getAllAlertSenders(new AsyncCallback<String[]>() {
@Override
@@ -94,6 +110,8 @@ public class NewNotificationEditor extends LocatableDynamicForm {
notificationSenderSelectItem.setValueMap(senders);
notificationSenderSelectItem.setDisabled(false);
notificationSenderSelectItem.redraw();
+ switchToAlertSender(result[0]);
+ senderCanvasItem.show();
} else {
CoreGUI.getErrorHandler().handleError("No alert senders available");
}
@@ -106,10 +124,13 @@ public class NewNotificationEditor extends LocatableDynamicForm {
});
}
- notificationSenderSelectItem.setDefaultToFirstOption(true);
- notificationSenderSelectItem.setWrapTitle(false);
- notificationSenderSelectItem.setRedrawOnChange(true);
- notificationSenderSelectItem.setWidth("*");
+ notificationSenderSelectItem.addChangedHandler(new ChangedHandler() {
+ @Override
+ public void onChanged(ChangedEvent event) {
+ String newAlertSender = event.getValue().toString();
+ switchToAlertSender(newAlertSender);
+ }
+ });
SpacerItem spacer1 = new SpacerItem();
spacer1.setColSpan(2);
@@ -145,7 +166,7 @@ public class NewNotificationEditor extends LocatableDynamicForm {
ArrayList<FormItem> formItems = new ArrayList<FormItem>();
formItems.add(notificationSenderSelectItem);
formItems.add(spacer1);
- // TODO put config editor here
+ formItems.add(senderCanvasItem);
formItems.add(spacer2);
formItems.add(ok);
formItems.add(cancel);
@@ -166,20 +187,21 @@ public class NewNotificationEditor extends LocatableDynamicForm {
notif = notificationToEdit;
}
- // notif.setConfiguration(configuration);
- // notif.setExtraConfiguration(extraConfiguration);
+ AbstractNotificationSenderForm senderForm = (AbstractNotificationSenderForm) senderCanvasItem.getCanvas();
+ notif.setConfiguration(senderForm.getConfiguration());
+ notif.setExtraConfiguration(senderForm.getExtraConfiguration());
}
- private class ShowIfSenderFunction implements FormItemIfFunction {
- private final String senderName;
-
- public ShowIfSenderFunction(String senderName) {
- this.senderName = senderName;
+ private void switchToAlertSender(String newAlertSender) {
+ Canvas oldCanvas = senderCanvasItem.getCanvas();
+ if (oldCanvas != null) {
+ oldCanvas.markForDestroy();
}
- public boolean execute(FormItem item, Object value, DynamicForm form) {
- String selectedSenderString = form.getValue("notificationSender").toString();
- return senderName.equals(selectedSenderString);
- }
+ // TODO: need to create different forms for different types of senders
+ SimpleNotificationSenderForm newCanvas = new SimpleNotificationSenderForm(extendLocatorId(newAlertSender));
+ senderCanvasItem.setCanvas(newCanvas);
+
+ markForRedraw();
}
}
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 bc585ac..f707dc1 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
@@ -237,7 +237,7 @@ public class NotificationsAlertDefinitionForm extends LocatableVLayout implement
configField.setWidth("75%");
getListGrid().setFields(senderField, configField);
- getListGrid().addDoubleClickHandler(new DoubleClickHandler() {
+ setListGridDoubleClickHandler(new DoubleClickHandler() {
@Override
public void onDoubleClick(DoubleClickEvent event) {
ListGrid listGrid = (ListGrid) event.getSource();
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SimpleNotificationSenderForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SimpleNotificationSenderForm.java
new file mode 100644
index 0000000..a70bd82
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SimpleNotificationSenderForm.java
@@ -0,0 +1,47 @@
+/*
+ * 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.alert.definitions;
+
+import com.smartgwt.client.widgets.Label;
+
+/**
+ * This notification form will be used for most alert senders since most alert senders
+ * only need to be given a simple set of configuration properties where the user
+ * provides values via the normal configuration editor.
+ *
+ * @author John Mazzitelli
+ */
+public class SimpleNotificationSenderForm extends AbstractNotificationSenderForm {
+
+ public SimpleNotificationSenderForm(String locatorId) {
+ super(locatorId);
+ }
+
+ @Override
+ protected void onInit() {
+ super.onInit();
+ // TODO add config editor
+ addMember(new Label("simple form : " + getLocatorId()));
+ }
+}
commit 7101d3d1535d107523615a2a7f7d4d56ec1f537e
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Oct 1 14:32:00 2010 -0400
provide a way to add a double-click handler to the Table API
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 c933047..f5c9a40 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
@@ -35,6 +35,8 @@ import com.smartgwt.client.widgets.Img;
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.events.DoubleClickEvent;
+import com.smartgwt.client.widgets.events.DoubleClickHandler;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.fields.FormItem;
import com.smartgwt.client.widgets.form.fields.SelectItem;
@@ -122,6 +124,7 @@ public class Table extends LocatableHLayout {
;
+ private DoubleClickHandler doubleClickHandler;
private List<TableActionInfo> tableActions = new ArrayList<TableActionInfo>();
private boolean tableActionDisableOverride = false;
protected List<Canvas> extraWidgets = new ArrayList<Canvas>();
@@ -259,6 +262,15 @@ public class Table extends LocatableHLayout {
// Now give subclasses a chance to configure the table
configureTable();
+ listGrid.addDoubleClickHandler(new DoubleClickHandler() {
+ @Override
+ public void onDoubleClick(DoubleClickEvent event) {
+ if (doubleClickHandler != null && !getTableActionDisableOverride()) {
+ doubleClickHandler.onDoubleClick(event);
+ }
+ }
+ });
+
setTableInfo(new Label("Total: " + listGrid.getTotalRows()));
// NOTE: It is essential that we wait to hide any excluded fields until after super.onDraw() is called, since
@@ -480,6 +492,10 @@ public class Table extends LocatableHLayout {
tableActions.add(info);
}
+ public void setListGridDoubleClickHandler(DoubleClickHandler handler) {
+ doubleClickHandler = handler;
+ }
+
public void addExtraWidget(Canvas canvas) {
this.extraWidgets.add(canvas);
}
@@ -502,6 +518,9 @@ public class Table extends LocatableHLayout {
* buttons regardless of which rows are selected. This method let's
* you set this override-disable flag.
*
+ * Note: this also effects the double-click handler - if this disable override
+ * is on, the double-click handler is not called.
+ *
* @param disabled if true, all table action buttons will be disabled
* if false, table action buttons will be enabled based on their predefined
* selection enablement rule.
13 years, 8 months
[rhq] modules/enterprise
by ips
modules/enterprise/gui/coregui/pom.xml | 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/CoreGUI.gwt.xml | 44 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java | 8
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/DemoCanvas.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/SearchGUI.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/UserSessionManager.java | 33 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletDataSource.java | 2
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/components/FullHTMLPane.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java | 26
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ListGridConfigurationEditor.java | 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortalLayout.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementDataTraitDataSource.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementScheduleDataSource.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeView.java | 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/schedules/SchedulesDataSource.java | 24
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/NewResourceTreeDataSource.java | 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/NewResourceTreeView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java | 13
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java | 5
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/PluginConfigurationEditView.java | 3
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/create/OperationCreateWizard.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/type/ResourceTypeRepository.java | 8
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/DropDownMenuBarView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/SearchBarPane.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/search/SearchBar.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestConfigurationFactory.java | 293 ++++++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestConfigurationView.java | 129 ++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java | 10
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/TreeUtility.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/WidgetUtility.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageBar.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenterView.java | 22
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/rpc/MonitoringRequestCallback.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/rpc/RPCManager.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ConfigurationGWTServiceImpl.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ObjectFilter.java | 8
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceTypeGWTServiceImpl.java | 2
44 files changed, 597 insertions(+), 109 deletions(-)
New commits:
commit ef62478885fcdd851184b31e9d5a94ebad5f7d29
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Fri Oct 1 14:51:33 2010 -0400
integrate gwt-log and convert over all System.out.println's to logging; add test config view (#TestConfig) for testing config editor
diff --git a/modules/enterprise/gui/coregui/pom.xml b/modules/enterprise/gui/coregui/pom.xml
index c8dce21..21dd681 100644
--- a/modules/enterprise/gui/coregui/pom.xml
+++ b/modules/enterprise/gui/coregui/pom.xml
@@ -107,6 +107,12 @@
<version>1.0.0</version>
</dependency>
+ <dependency>
+ <groupId>com.google.code.gwt-log</groupId>
+ <artifactId>gwt-log</artifactId>
+ <version>3.0.3</version>
+ </dependency>
+
<!-- for file uploads -->
<dependency>
<groupId>commons-fileupload</groupId>
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/CoreGUI.gwt.xml b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/CoreGUI.gwt.xml
index 8db747c..ed2ce42 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/CoreGUI.gwt.xml
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/CoreGUI.gwt.xml
@@ -1,5 +1,5 @@
-<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 1.6//EN"
- "http://google-web-toolkit.googlecode.com/svn/releases/1.6/distro-source/c...">
+<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.0//EN"
+ "http://google-web-toolkit.googlecode.com/svn/releases/2.0/distro-source/c...">
<module>
@@ -11,20 +11,45 @@
<inherits name="com.smartgwt.tools.SmartGwtTools"/>
<inherits name='com.google.gwt.user.theme.standard.Standard'/>
-<!--
- <inherits name="com.smartclient.theme.graphite.Graphite"/>
--->
+ <!--
+ <inherits name="com.smartclient.theme.graphite.Graphite"/>
+ -->
<inherits name='ca.nanometrics.gflot.GFlot'/>
<!--
- <inherits name='com.google.gwt.widgetideas.WidgetIdeas'/>
+ <inherits name='com.google.gwt.widgetideas.WidgetIdeas'/>
-->
-<!-- <generate-with class="org.rhq.core.rebind.RecordBuilderGenerator">
+ <!-- ============================ gwt-log ============================= -->
+
+ <!-- For development, a default of 'DEBUG' is recommended. -->
+ <inherits name="com.allen_sauer.gwt.log.gwt-log-DEBUG" />
+
+ <!-- For production, most teams prefer to set the default log level to 'OFF'. -->
+ <!--<inherits name="com.allen_sauer.gwt.log.gwt-log-OFF" />-->
+
+ <!--
+ Enable experimental WindowLogger, which logs messages to a separate
+ popup window. There are currently a couple of restrictions:
+
+ 1. When Firefox is configured to open new Windows as new tabs,
+ WindowLogger does not work
+ 2. In hosted mode, the windows are not automatically closed,
+ although you can easily close them manually in the usual way
+ -->
+ <set-property name="log_WindowLogger" value="ENABLED" />
+
+ <!--
+ You probably will want to disable the default `DivLogger` as well:
+ -->
+ <set-property name="log_DivLogger" value="DISABLED" />
+
+ <!--
+ <generate-with class="org.rhq.core.rebind.RecordBuilderGenerator">
<when-type-assignable class="org.rhq.core.domain.util.Recordizable"/>
- </generate-with>-->
-
+ </generate-with>
+ -->
<replace-with class="org.rhq.enterprise.gui.coregui.client.components.upload.DynamicCallbackFormImpl">
<when-type-is class="org.rhq.enterprise.gui.coregui.client.components.upload.DynamicCallbackFormImpl"/>
@@ -47,6 +72,7 @@
<entry-point class='org.rhq.enterprise.gui.coregui.client.CoreGUI'/>
<entry-point class='org.rhq.enterprise.gui.coregui.client.SearchGUI'/>
+
<servlet path="/AlertGWTService" class="org.rhq.enterprise.gui.coregui.server.gwt.AlertGWTServiceImpl"/>
<servlet path="/AlertDefinitionGWTService" class="org.rhq.enterprise.gui.coregui.server.gwt.AlertDefinitionGWTServiceImpl"/>
<servlet path="/AuthorizationGWTService" class="org.rhq.enterprise.gui.coregui.server.gwt.AuthorizationGWTServiceImpl"/>
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 34cf23e..e9b7788 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
@@ -18,6 +18,7 @@
*/
package org.rhq.enterprise.gui.coregui.client;
+import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Element;
@@ -45,6 +46,7 @@ import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.ResourceT
import org.rhq.enterprise.gui.coregui.client.menu.MenuBarView;
import org.rhq.enterprise.gui.coregui.client.report.ReportTopView;
import org.rhq.enterprise.gui.coregui.client.report.tag.TaggedView;
+import org.rhq.enterprise.gui.coregui.client.test.TestConfigurationView;
import org.rhq.enterprise.gui.coregui.client.util.ErrorHandler;
import org.rhq.enterprise.gui.coregui.client.util.WidgetUtility;
import org.rhq.enterprise.gui.coregui.client.util.message.MessageBar;
@@ -84,7 +86,7 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String> {
public void onModuleLoad() {
String hostPageBaseURL = GWT.getHostPageBaseURL();
if (hostPageBaseURL.indexOf("/coregui/") == -1) {
- System.out.println("Suppressing load of CoreGUI module");
+ Log.info("Suppressing load of CoreGUI module");
return; // suppress loading this module if not using the new GWT app
}
@@ -165,7 +167,7 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String> {
public void onValueChange(ValueChangeEvent<String> stringValueChangeEvent) {
String event = URL.decodeComponent(stringValueChangeEvent.getValue());
- //System.out.println("Handling history event: " + event);
+ com.allen_sauer.gwt.log.client.Log.debug("Handling history event: " + event);
currentPath = event;
currentViewPath = new ViewPath(event);
@@ -208,6 +210,8 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String> {
canvas = new AlertsView("Alert");
} else if (breadcrumbName.equals(ReportTopView.VIEW_ID)) {
canvas = new ReportTopView("Report");
+ } else if (breadcrumbName.equals(TestConfigurationView.VIEW_ID)) {
+ canvas = new TestConfigurationView("TestConfig");
} else {
canvas = null;
}
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 bd0aabe..d252fb8 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
@@ -89,7 +89,7 @@ public class DemoCanvas extends Canvas {
configSelectMenu.addItemClickHandler(new ItemClickHandler() {
public void onItemClick(ItemClickEvent itemClickEvent) {
int x = configSelectMenu.getItemNum(itemClickEvent.getItem());
- System.out.println("Loading: " + x);
+ com.allen_sauer.gwt.log.client.Log.info("Loading: " + x);
topTabSet.removeTab(configTab);
switch (x) {
case 0:
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 24ef812..3d79afd 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
@@ -178,7 +178,7 @@ public class LoginView extends Canvas {
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");
+ com.allen_sauer.gwt.log.client.Log.info("Preloaded [" + types.size() + "] resource types");
}
});
}
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 2266993..55588e9 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
@@ -41,7 +41,7 @@ public class SearchGUI implements EntryPoint {
public void onModuleLoad() {
if (SearchBar.existsOnPage() == false) {
- System.out.println("Suppressing load of SearchGUI module");
+ com.allen_sauer.gwt.log.client.Log.info("Suppressing load of SearchGUI module");
return;
}
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 5219213..ecbd719 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,6 +22,7 @@
*/
package org.rhq.enterprise.gui.coregui.client;
+import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.http.client.Request;
import com.google.gwt.http.client.RequestBuilder;
import com.google.gwt.http.client.RequestCallback;
@@ -30,7 +31,6 @@ 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;
@@ -66,7 +66,7 @@ public class UserSessionManager {
private static Timer sessionTimer = new Timer() {
@Override
public void run() {
- System.out.println("Session Timer Expired");
+ Log.info("Session timer expired.");
new LoginView().showLoginDialog(); // log user out, show login dialog
}
};
@@ -88,7 +88,7 @@ public class UserSessionManager {
try {
b.setCallback(new RequestCallback() {
public void onResponseReceived(final Request request, final Response response) {
- System.out.println("response text = " + response.getText());
+ com.allen_sauer.gwt.log.client.Log.info("response text = " + response.getText());
String sessionIdString = response.getText();
if (sessionIdString != null && sessionIdString.length() > 0) {
@@ -96,20 +96,20 @@ public class UserSessionManager {
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);
+ com.allen_sauer.gwt.log.client.Log.info("sessionAccess-subjectId: " + subjectId);
+ com.allen_sauer.gwt.log.client.Log.info("sessionAccess-sessionId: " + sessionId);
+ com.allen_sauer.gwt.log.client.Log.info("sessionAccess-lastAccess: " + lastAccess);
String previousSessionId = getPreviousSessionId(); // may be null
- System.out.println("sessionAccess-previousSessionId: " + previousSessionId);
+ com.allen_sauer.gwt.log.client.Log.info("sessionAccess-previousSessionId: " + previousSessionId);
if (previousSessionId == null || previousSessionId.equals(sessionId) == false) {
// persist sessionId if different from previously saved sessionId
- System.out.println("sessionAccess-savingSessionId: " + sessionId);
+ com.allen_sauer.gwt.log.client.Log.info("sessionAccess-savingSessionId: " + sessionId);
saveSessionId(sessionId);
// new sessions get the full 29 minutes to expire
- System.out.println("sessionAccess-schedulingSessionTimeout: " + SESSION_TIMEOUT);
+ com.allen_sauer.gwt.log.client.Log.info("sessionAccess-schedulingSessionTimeout: " + SESSION_TIMEOUT);
sessionTimer.schedule(SESSION_TIMEOUT);
} else {
@@ -124,7 +124,7 @@ public class UserSessionManager {
expiryMillis = SESSION_TIMEOUT; // guarantees maximum is 29 minutes
}
- System.out.println("sessionAccess-reschedulingSessionTimeout: " + expiryMillis);
+ com.allen_sauer.gwt.log.client.Log.info("sessionAccess-reschedulingSessionTimeout: " + expiryMillis);
sessionTimer.schedule((int) expiryMillis);
}
@@ -143,13 +143,13 @@ public class UserSessionManager {
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");
+ com.allen_sauer.gwt.log.client.Log.info("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);
+ Log.debug("Found subject [" + subject + "].");
subject.setSessionId(Integer.valueOf(sessionId));
// reset the session subject to the latest, for wrapping in user preferences
@@ -187,7 +187,7 @@ public class UserSessionManager {
@Override
public void onFailure(Throwable caught) {
- SC.say("Unable to determine login status, check server status");
+ Log.error("Unable to determine login status - check Server status.");
}
});
}
@@ -213,7 +213,7 @@ public class UserSessionManager {
// now continue with the rest of the login logic
loggedIn = true;
- System.out.println("Refreshing Session Timer");
+ Log.info("Refreshing session timer...");
sessionTimer.schedule(millis);
}
@@ -223,7 +223,7 @@ public class UserSessionManager {
}
loggedIn = false;
- System.out.println("Destroying Session Timer");
+ Log.info("Destroying session timer...");
sessionTimer.cancel();
// log out the web session on the server-side in a delayed fashion,
@@ -250,7 +250,7 @@ public class UserSessionManager {
}
public static boolean isLoggedIn() {
- //System.out.println("isLoggedIn = " + loggedIn);
+ Log.trace("isLoggedIn = " + loggedIn);
return loggedIn;
}
@@ -272,5 +272,4 @@ public class UserSessionManager {
public static UserPreferences getUserPreferences() {
return userPreferences;
}
-
}
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 61b58b7..a950c34 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
@@ -153,7 +153,7 @@ 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");
+ com.allen_sauer.gwt.log.client.Log.info(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());
@@ -284,7 +284,7 @@ public class AlertDataSource extends RPCDataSource<Alert> {
CoreGUI.getMessageCenter().notify(
new Message("Acknowledged [" + alertIds.length + "] alerts", Message.Severity.Info));
- System.out.println("Acknowledged Alerts with id's: " + Arrays.toString(alertIds) + ".");
+ com.allen_sauer.gwt.log.client.Log.info("Acknowledged Alerts with id's: " + Arrays.toString(alertIds) + ".");
alertsView.refresh();
}
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 d21ab76..ad825a9 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
@@ -96,7 +96,7 @@ public class AlertPortletDataSource extends AlertDataSource {
public void onSuccess(PageList<Alert> result) {
long fetchTime = System.currentTimeMillis() - start;
- System.out.println(result.size() + " alerts fetched in: " + fetchTime + "ms");
+ com.allen_sauer.gwt.log.client.Log.info(result.size() + " alerts fetched in: " + fetchTime + "ms");
response.setData(buildRecords(result));
response.setTotalRows(result.size());
processResponse(request.getRequestId(), response);
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 7da68cd..fa823e3 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
@@ -106,7 +106,7 @@ public class BundleTopView extends LocatableHLayout implements BookmarkableView
if (viewPath.isEnd()) {
if (currentNextPath == null && bundlesListView != null) {
// refresh
- System.out.println("Refreshing BundleTopView");
+ com.allen_sauer.gwt.log.client.Log.info("Refreshing BundleTopView");
bundlesListView.refresh();
} else {
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 c90ca57..bc296cc 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
@@ -33,7 +33,7 @@ public class FullHTMLPane extends HTMLPane {
public FullHTMLPane(String url) {
this();
- //System.out.println("Creating IFrame pane with URL [" + url + "]...");
+ com.allen_sauer.gwt.log.client.Log.debug("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 eb1e2d2..343a709 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
@@ -241,7 +241,7 @@ public class ConfigurationEditor extends LocatableVLayout {
public void onSuccess(Configuration result) {
configuration = result;
- System.out.println("Config retreived in: " + (System.currentTimeMillis() - start));
+ com.allen_sauer.gwt.log.client.Log.info("Config retreived in: " + (System.currentTimeMillis() - start));
reload();
}
});
@@ -250,7 +250,7 @@ public class ConfigurationEditor extends LocatableVLayout {
EnumSet.of(ResourceTypeRepository.MetadataType.resourceConfigurationDefinition),
new ResourceTypeRepository.TypesLoadedCallback() {
public void onTypesLoaded(Map<Integer, ResourceType> types) {
- //System.out.println("ConfigDef retreived in: " + (System.currentTimeMillis() - start));
+ com.allen_sauer.gwt.log.client.Log.debug("ConfigDef retreived in: " + (System.currentTimeMillis() - start));
definition = types.get(resourceTypeId).getResourceConfigurationDefinition();
if (definition == null) {
loadingLabel.hide();
@@ -276,7 +276,7 @@ public class ConfigurationEditor extends LocatableVLayout {
EnumSet.of(ResourceTypeRepository.MetadataType.pluginConfigurationDefinition),
new ResourceTypeRepository.TypesLoadedCallback() {
public void onTypesLoaded(Map<Integer, ResourceType> types) {
- //System.out.println("ConfigDef retreived in: " + (System.currentTimeMillis() - start));
+ com.allen_sauer.gwt.log.client.Log.debug("ConfigDef retreived in: " + (System.currentTimeMillis() - start));
definition = types.get(resourceTypeId).getPluginConfigurationDefinition();
if (definition == null) {
showError("Connection settings are not supported by this Resource.");
@@ -302,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...");
+ com.allen_sauer.gwt.log.client.Log.info("Loading files view...");
Tab tab = new LocatableTab("Files", "Files");
tab.setPane(buildRawPane());
tabSet.addTab(tab);
@@ -310,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...");
+ com.allen_sauer.gwt.log.client.Log.info("Loading properties view...");
Tab tab = new LocatableTab("Properties", "Properties");
tab.setPane(buildStructuredPane());
tabSet.addTab(tab);
@@ -358,10 +358,10 @@ public class ConfigurationEditor extends LocatableVLayout {
fileTree.addSelectionChangedHandler(new SelectionChangedHandler() {
public void onSelectionChanged(SelectionEvent selectionEvent) {
String path = selectionEvent.getRecord().getAttribute("name");
- System.out.println("Getting Path: " + path);
+ com.allen_sauer.gwt.log.client.Log.info("Getting Path: " + path);
rawEditor.setValue(filesMap.get(path).getContents());
rawEditor.redraw();
- System.out.println("Data: " + filesMap.get(path).getContents());
+ com.allen_sauer.gwt.log.client.Log.info("Data: " + filesMap.get(path).getContents());
}
});
@@ -391,7 +391,7 @@ public class ConfigurationEditor extends LocatableVLayout {
}
for (PropertyGroupDefinition definition : definitions) {
- // System.out.println("building: " + definition.getDisplayName());
+ // com.allen_sauer.gwt.log.client.Log.info("building: " + definition.getDisplayName());
sectionStack.addSection(buildGroupSection(layout.extendLocatorId(definition.getName()), definition));
}
@@ -656,7 +656,7 @@ public class ConfigurationEditor extends LocatableVLayout {
editField.setCanHide(false);
editField.addRecordClickHandler(new RecordClickHandler() {
public void onRecordClick(RecordClickEvent recordClickEvent) {
- System.out.println("You want to edit: " + recordClickEvent.getRecord());
+ com.allen_sauer.gwt.log.client.Log.info("You want to edit: " + recordClickEvent.getRecord());
displayMapEditor(locatorId + "_MapEdit", summaryTable, recordClickEvent.getRecord(),
propertyDefinition, propertyList, (PropertyMap) recordClickEvent.getRecord().getAttributeAsObject(
"_RHQ_PROPERTY"));
@@ -678,7 +678,7 @@ public class ConfigurationEditor extends LocatableVLayout {
removeField.addRecordClickHandler(new RecordClickHandler() {
public void onRecordClick(final RecordClickEvent recordClickEvent) {
- System.out.println("You want to delete: " + recordClickEvent.getRecordNum());
+ com.allen_sauer.gwt.log.client.Log.info("You want to delete: " + recordClickEvent.getRecordNum());
SC.confirm("Are you sure you want to delete this row?", new BooleanCallback() {
public void execute(Boolean aBoolean) {
if (aBoolean) {
@@ -865,7 +865,7 @@ public class ConfigurationEditor extends LocatableVLayout {
Click handlers seem to be turned off for disabled fields... need an alternative
valueItem.addClickHandler(new com.smartgwt.client.widgets.form.fields.events.ClickHandler() {
public void onClick(ClickEvent clickEvent) {
- System.out.println("Click in value field");
+ com.allen_sauer.gwt.log.client.Log.info("Click in value field");
clickEvent.getItem().setDisabled(false);
unsetItem.setValue(false);
@@ -1000,10 +1000,10 @@ public class ConfigurationEditor extends LocatableVLayout {
list.add(finalMap);
ListGridRecord record = buildSummaryRecord(definitions, finalMap);
- System.out.println("here");
+ com.allen_sauer.gwt.log.client.Log.info("here");
try {
summaryTable.addData(record);
- System.out.println("there");
+ com.allen_sauer.gwt.log.client.Log.info("there");
} catch (Exception e) {
e.printStackTrace();
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ListGridConfigurationEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ListGridConfigurationEditor.java
index 9e0e480..7136199 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ListGridConfigurationEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ListGridConfigurationEditor.java
@@ -73,7 +73,7 @@ public class ListGridConfigurationEditor extends VLayout {
public void onSuccess(Configuration result) {
configuration = result;
- System.out.println("Got config");
+ com.allen_sauer.gwt.log.client.Log.info("Got config");
reload();
}
});
@@ -85,7 +85,7 @@ public class ListGridConfigurationEditor extends VLayout {
public void onSuccess(ConfigurationDefinition result) {
definition = result;
- System.out.println("Got def");
+ com.allen_sauer.gwt.log.client.Log.info("Got def");
reload();
}
@@ -108,7 +108,7 @@ public class ListGridConfigurationEditor extends VLayout {
sectionStack.setOverflow(Overflow.VISIBLE);
for (PropertyGroupDefinition definition : definitions) {
- System.out.println("building: " + definition.getDisplayName());
+ com.allen_sauer.gwt.log.client.Log.info("building: " + definition.getDisplayName());
sectionStack.addSection(buildGroupSection(definition));
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java
index f4b3cad..ca5a929 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java
@@ -198,7 +198,7 @@ public class DashboardView extends LocatableVLayout {
picker.addChangedHandler(new ChangedHandler() {
public void onChanged(ChangedEvent changedEvent) {
Object v = changedEvent.getValue();
- System.out.println("color chagned to " + v);
+ com.allen_sauer.gwt.log.client.Log.info("color chagned to " + v);
setBackgroundColor(String.valueOf(v));
storedDashboard.getConfiguration().put(new PropertySimple(Dashboard.CFG_BACKGROUND, String.valueOf(v)));
save();
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 7e0fb8e..422c244 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
@@ -314,7 +314,7 @@ public class DashboardsView extends LocatableVLayout implements BookmarkableView
}
}
} else {
- System.out.println("WARN: While rendering DashboardsView tabSet is null.");
+ com.allen_sauer.gwt.log.client.Log.info("WARN: While rendering DashboardsView tabSet is null.");
}
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortalLayout.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortalLayout.java
index 8a3d355..aad543c 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortalLayout.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortalLayout.java
@@ -81,7 +81,7 @@ public class PortalLayout extends LocatableHLayout {
colNum++;
}
save();
- System.out.println("Rearranged column indexes");
+ com.allen_sauer.gwt.log.client.Log.info("Rearranged column indexes");
}
});
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementDataTraitDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementDataTraitDataSource.java
index a21e4f5..b30714f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementDataTraitDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementDataTraitDataSource.java
@@ -96,7 +96,7 @@ public abstract class AbstractMeasurementDataTraitDataSource extends RPCDataSour
public void onSuccess(PageList<MeasurementDataTrait> result) {
long fetchDuration = System.currentTimeMillis() - startTime;
- System.out.println(result.size() + " traits fetched in: " + fetchDuration + "ms");
+ com.allen_sauer.gwt.log.client.Log.info(result.size() + " traits fetched in: " + fetchDuration + "ms");
response.setData(buildRecords(result));
// For paging to work, we have to specify size of full result set.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementScheduleDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementScheduleDataSource.java
index 08f3473..e1181ab 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementScheduleDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementScheduleDataSource.java
@@ -105,7 +105,7 @@ public abstract class AbstractMeasurementScheduleDataSource extends RPCDataSourc
public void onSuccess(PageList<MeasurementSchedule> result) {
long fetchDuration = System.currentTimeMillis() - startTime;
- System.out.println(result.size() + " measurement schedules fetched in: " + fetchDuration + "ms");
+ com.allen_sauer.gwt.log.client.Log.info(result.size() + " measurement schedules fetched in: " + fetchDuration + "ms");
response.setData(buildRecords(result));
// For paging to work, we have to specify size of full result set.
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 6c9127b..9e2442b 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
@@ -110,7 +110,7 @@ public class ResourceGroupTreeView extends LocatableVLayout implements Bookmarka
public void onSelectionChanged(SelectionEvent selectionEvent) {
if (selectionEvent.getState()) {
Record selectedNode = selectionEvent.getRecord();
- System.out.println("Node selected in tree: " + selectedNode);
+ com.allen_sauer.gwt.log.client.Log.info("Node selected in tree: " + selectedNode);
ResourceType type = (ResourceType) selectedNode.getAttributeAsObject("resourceType");
if (type != null) {
// It's a cluster group node, not a subcategory node or an autoTypeGroup node.
@@ -118,14 +118,14 @@ public class ResourceGroupTreeView extends LocatableVLayout implements Bookmarka
if (key == null) {
// The root group was selected.
String groupId = selectedNode.getAttribute("id");
- //System.out.println("Selecting group [" + groupId + "]...");
+ com.allen_sauer.gwt.log.client.Log.debug("Selecting group [" + groupId + "]...");
String viewPath = ResourceGroupTopView.VIEW_ID + "/" + groupId;
String currentViewPath = History.getToken();
if (!currentViewPath.startsWith(viewPath)) {
CoreGUI.goToView(viewPath);
}
} else {
- //System.out.println("Selecting cluster group [" + key + "]...");
+ com.allen_sauer.gwt.log.client.Log.debug("Selecting cluster group [" + key + "]...");
selectClusterGroup(key);
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/schedules/SchedulesDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/schedules/SchedulesDataSource.java
index ccf8ee3..7bf4903 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/schedules/SchedulesDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/schedules/SchedulesDataSource.java
@@ -65,19 +65,21 @@ public class SchedulesDataSource extends AbstractMeasurementScheduleDataSource {
@Override
protected void enableSchedules(AbstractMeasurementScheduleListView measurementScheduleListView,
- int[] measurementDefinitionIds, final List<String> measurementDefinitionDisplayNames) {
- this.measurementService.enableSchedulesForCompatibleGroup(this.resourceGroupId, measurementDefinitionIds,
+ final int[] measurementDefinitionIds, final List<String> measurementDefinitionDisplayNames) {
+ final String s = (measurementDefinitionIds.length > 1) ? "s" : "";
+ this.measurementService.enableSchedulesForCompatibleGroup(this.resourceGroupId, measurementDefinitionIds,
new AsyncCallback<Void>() {
@Override
public void onFailure(Throwable throwable) {
- CoreGUI.getErrorHandler().handleError("Failed to enable collection of metrics "
+ CoreGUI.getErrorHandler().handleError("Failed to enable collection of metric" + s + " "
+ measurementDefinitionDisplayNames + " for Resource group with id [" + resourceGroupId + "].",
throwable);
}
@Override
public void onSuccess(Void aVoid) {
- CoreGUI.getMessageCenter().notify(new Message("Enabled collection of metrics "
+ CoreGUI.getMessageCenter().notify(new Message("Enabled collection of selected metric" + s + ".",
+ "Enabled collection of metric" + s + " "
+ measurementDefinitionDisplayNames + " for Resource group with id [" + resourceGroupId +
"].", Message.Severity.Info));
@@ -87,18 +89,20 @@ public class SchedulesDataSource extends AbstractMeasurementScheduleDataSource {
@Override
protected void disableSchedules(AbstractMeasurementScheduleListView measurementScheduleListView, int[] measurementDefinitionIds, final List<String> measurementDefinitionDisplayNames) {
- this.measurementService.disableSchedulesForCompatibleGroup(this.resourceGroupId, measurementDefinitionIds,
+ final String s = (measurementDefinitionIds.length > 1) ? "s" : "";
+ this.measurementService.disableSchedulesForCompatibleGroup(this.resourceGroupId, measurementDefinitionIds,
new AsyncCallback<Void>() {
@Override
public void onFailure(Throwable throwable) {
- CoreGUI.getErrorHandler().handleError("Failed to disable collection of metrics "
+ CoreGUI.getErrorHandler().handleError("Failed to disable collection of metric" + s + " "
+ measurementDefinitionDisplayNames + " for Resource group with id [" + resourceGroupId + "].",
throwable);
}
@Override
public void onSuccess(Void aVoid) {
- CoreGUI.getMessageCenter().notify(new Message("Disabled collection of metrics "
+ CoreGUI.getMessageCenter().notify(new Message("Disabled collection of selected metric" + s + ".",
+ "Disabled collection of metric" + s + " "
+ measurementDefinitionDisplayNames + " for Resource group with id [" + resourceGroupId +
"].", Message.Severity.Info));
@@ -109,19 +113,21 @@ public class SchedulesDataSource extends AbstractMeasurementScheduleDataSource {
@Override
protected void updateSchedules(AbstractMeasurementScheduleListView measurementScheduleListView,
int[] measurementDefinitionIds, final List<String> measurementDefinitionDisplayNames, final long collectionInterval) {
+ final String s = (measurementDefinitionIds.length > 1) ? "s" : "";
this.measurementService.updateSchedulesForCompatibleGroup(this.resourceGroupId, measurementDefinitionIds, collectionInterval,
new AsyncCallback<Void>() {
@Override
public void onFailure(Throwable throwable) {
CoreGUI.getErrorHandler().handleError("Failed to set collection interval to " + (collectionInterval / 1000)
- + " seconds for metrics " + measurementDefinitionDisplayNames + " for Resource group with id ["
+ + " seconds for metric" + s + " " + measurementDefinitionDisplayNames + " for Resource group with id ["
+ resourceGroupId + "].",
throwable);
}
@Override
public void onSuccess(Void aVoid) {
- CoreGUI.getMessageCenter().notify(new Message("Collection interval for metrics "
+ CoreGUI.getMessageCenter().notify(new Message("Updated collection intervals of selected metric" + s + ".",
+ "Collection interval for metric" + s + " "
+ measurementDefinitionDisplayNames + " for Resource group with id [" + resourceGroupId +
"] set to " + (collectionInterval / 1000) + " seconds.", Message.Severity.Info));
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
index e1bed72..6382fcb 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
@@ -165,7 +165,7 @@ public class ResourceSearchView extends Table {
long start = System.currentTimeMillis();
getListGrid().fetchData(c);
- System.out.println("Loaded in: " + (System.currentTimeMillis() - start));
+ com.allen_sauer.gwt.log.client.Log.info("Loaded in: " + (System.currentTimeMillis() - start));
}
}
});*/
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/NewResourceTreeDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/NewResourceTreeDataSource.java
index bccf8c5..35eb2d6 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/NewResourceTreeDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/NewResourceTreeDataSource.java
@@ -133,12 +133,12 @@ public class NewResourceTreeDataSource extends DataSource {
ResourceCriteria criteria = new ResourceCriteria();
if (p == null) {
- System.out.println("DataSourceTree: Loading initial data");
+ com.allen_sauer.gwt.log.client.Log.info("DataSourceTree: Loading initial data");
criteria.addFilterId(rootId);
} else {
- System.out.println("DataSourceTree: Loading " + p);
+ com.allen_sauer.gwt.log.client.Log.info("DataSourceTree: Loading " + p);
criteria.addFilterParentResourceId(Integer.parseInt(p));
}
@@ -319,7 +319,7 @@ public class NewResourceTreeDataSource extends DataSource {
String parentId = resource.getParentResource() == null ? null
: (resource.getParentResource().getId() + "_" + resource.getResourceType().getName());
- // System.out.println(id + " / " + parentId);
+ // com.allen_sauer.gwt.log.client.Log.info(id + " / " + parentId);
setID(id);
setParentID(parentId);
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 bad1ada..da08c04 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
@@ -124,7 +124,7 @@ public class NewResourceTreeView extends LocatableVLayout {
if (treeGrid.getSelectedRecord() instanceof ResourceTreeDatasource.ResourceTreeNode) {
ResourceTreeDatasource.ResourceTreeNode node = (ResourceTreeDatasource.ResourceTreeNode) treeGrid
.getSelectedRecord();
- System.out.println("Resource selected in tree: " + node.getResource());
+ com.allen_sauer.gwt.log.client.Log.info("Resource selected in tree: " + node.getResource());
String newToken = "Resource/" + node.getResource().getId();
String currentToken = History.getToken();
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 1c73198..d577c4d 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
@@ -107,7 +107,6 @@ public class ResourceTreeDatasource extends DataSource {
case UPDATE:
//executeAdd(lstRec, false);
break;
-
default:
break;
}
@@ -119,12 +118,12 @@ public class ResourceTreeDatasource extends DataSource {
//final long start = System.currentTimeMillis();
String parentResourceId = request.getCriteria().getAttribute("parentId");
- // System.out.println("All attributes: " + Arrays.toString(request.getCriteria().getAttributes()));
+ // com.allen_sauer.gwt.log.client.Log.info("All attributes: " + Arrays.toString(request.getCriteria().getAttributes()));
ResourceCriteria criteria = new ResourceCriteria();
if (parentResourceId == null) {
- System.out.println("ResourceTreeDatasource: Loading initial data...");
+ com.allen_sauer.gwt.log.client.Log.info("ResourceTreeDatasource: Loading initial data...");
// criteria.addFilterId(rootId);
@@ -133,7 +132,7 @@ public class ResourceTreeDatasource extends DataSource {
return;
} else {
- System.out.println("ResourceTreeDatasource: Loading Resource [" + parentResourceId + "]...");
+ com.allen_sauer.gwt.log.client.Log.info("ResourceTreeDatasource: Loading Resource [" + parentResourceId + "]...");
criteria.addFilterParentResourceId(Integer.parseInt(parentResourceId));
}
@@ -205,14 +204,14 @@ public class ResourceTreeDatasource extends DataSource {
Resource parentResource = resource.getParentResource();
ResourceSubCategory subcategory = type.getSubCategory();
if (subcategory != null) {
- //System.out.println("Processing " + subcategory + "...");
+ com.allen_sauer.gwt.log.client.Log.debug("Processing " + subcategory + "...");
do {
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...");
+ com.allen_sauer.gwt.log.client.Log.debug("Adding " + subcategoryNode + " to tree...");
updatedNodes.add(subcategoryNode);
}
} while ((subcategory = subcategory.getParentSubCategory()) != null);
@@ -221,7 +220,7 @@ public class ResourceTreeDatasource extends DataSource {
if (!type.isSingleton()) {
AutoGroupTreeNode autogroupNode = new AutoGroupTreeNode(resource);
autogroupNodes.put(autogroupNodeId, autogroupNode);
- //System.out.println("Adding " + autogroupNode + " to tree...");
+ com.allen_sauer.gwt.log.client.Log.debug("Adding " + autogroupNode + " to tree...");
updatedNodes.add(autogroupNode);
}
}
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 4cea21b..c06c636 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
@@ -159,7 +159,7 @@ public class ResourceTreeView extends LocatableVLayout {
treeGrid.deselectAllRecords();
}
} else if (selectedRecord instanceof AutoGroupTreeNode) {
- System.out.println("AutoGroup Node selected in tree: " + selectedRecord);
+ com.allen_sauer.gwt.log.client.Log.info("AutoGroup Node selected in tree: " + selectedRecord);
AutoGroupTreeNode agNode = (AutoGroupTreeNode) selectedRecord;
selectedNodeId = agNode.getID();
@@ -173,7 +173,7 @@ public class ResourceTreeView extends LocatableVLayout {
}
});
} else {
- System.out.println("Unhandled Node selected in tree: " + selectedRecord);
+ com.allen_sauer.gwt.log.client.Log.info("Unhandled Node selected in tree: " + selectedRecord);
}
}
}
@@ -628,7 +628,6 @@ public class ResourceTreeView extends LocatableVLayout {
}
if (!root.equals(ResourceTreeView.this.rootResource)) {
-
if (treeGrid != null) {
treeGrid.destroy();
}
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 4556da0..116e1ad 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
@@ -118,8 +118,7 @@ public class PluginConfigurationEditView extends LocatableVLayout implements Pro
public void onSuccess(PluginConfigurationUpdate result) {
CoreGUI.getMessageCenter().notify(
new Message("Connection settings updated.",
- "Connection settings updated for Resource [" + resource.getName() + "].",
- Message.Severity.Info));
+ "Connection settings updated for Resource [" + resource.getName() + "]."));
reloadConfiguration();
}
});
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/create/OperationCreateWizard.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/create/OperationCreateWizard.java
index 5d0be9d..e76e2ca 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/create/OperationCreateWizard.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/create/OperationCreateWizard.java
@@ -113,7 +113,7 @@ public class OperationCreateWizard extends AbstractWizard {
}
private void execute() {
- System.out.println("TODO Executed operation!!");
+ com.allen_sauer.gwt.log.client.Log.info("TODO Executed operation!!");
OperationGWTServiceAsync operationService = GWTServiceLookup.getOperationService();
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 cfa51bf..1c01176 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
@@ -109,7 +109,7 @@ public class ResourceTypeRepository {
}
});
- // System.out.println("Loaded types from cache in " + (System.currentTimeMillis() - start));
+ // com.allen_sauer.gwt.log.client.Log.info("Loaded types from cache in " + (System.currentTimeMillis() - start));
}
public void loadResourceTypes(final PageList<ResourceGroup> groups, final ResourceTypeLoadedInGroupCallback callback) {
@@ -142,7 +142,7 @@ public class ResourceTypeRepository {
}
});
- // System.out.println("Loaded types from cache in " + (System.currentTimeMillis() - start));
+ // com.allen_sauer.gwt.log.client.Log.info("Loaded types from cache in " + (System.currentTimeMillis() - start));
}
public void getResourceTypes(Integer[] resourceTypeIds, final TypesLoadedCallback callback) {
@@ -234,7 +234,7 @@ public class ResourceTypeRepository {
criteria.setPageControl(PageControl.getUnlimitedInstance());
- System.out.println("Loading " + typesNeeded.size()
+ com.allen_sauer.gwt.log.client.Log.info("Loading " + typesNeeded.size()
+ ((metadataTypes != null) ? (" types: " + metadataTypes) : ""));
resourceTypeService.findResourceTypesByCriteria(criteria, new AsyncCallback<PageList<ResourceType>>() {
@@ -313,7 +313,7 @@ public class ResourceTypeRepository {
public void preloadAll() {
getResourceTypes((Integer[]) null, EnumSet.allOf(MetadataType.class), new TypesLoadedCallback() {
public void onTypesLoaded(Map<Integer, ResourceType> types) {
- System.out.println("Preloaded [" + types.size() + "] Resource types.");
+ com.allen_sauer.gwt.log.client.Log.info("Preloaded [" + types.size() + "] Resource types.");
}
});
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/DropDownMenuBarView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/DropDownMenuBarView.java
index da5b92e..f6e1730 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/DropDownMenuBarView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/DropDownMenuBarView.java
@@ -119,7 +119,7 @@ public class DropDownMenuBarView extends LocatableVLayout {
resourcesMenu.addItem(favoritesMenu);
menu.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent clickEvent) {
- System.out.println("over here");
+ com.allen_sauer.gwt.log.client.Log.info("over here");
favoritesMenu.refresh();
}
});
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 657c4d3..5e6d943 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
@@ -165,7 +165,7 @@ public class SearchBarPane extends LocatableHLayout {
comboBox.addChangedHandler(new ChangedHandler() {
public void onChanged(ChangedEvent changedEvent) {
- //System.out.println("ChangedEvent: " + changedEvent.getValue());
+ com.allen_sauer.gwt.log.client.Log.debug("ChangedEvent: " + changedEvent.getValue());
Object intermediate = changedEvent.getValue();
if (!(intermediate instanceof Integer)) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/search/SearchBar.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/search/SearchBar.java
index 47dcded..42c830b 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/search/SearchBar.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/search/SearchBar.java
@@ -140,7 +140,7 @@ public class SearchBar extends SimplePanel {
}
public SearchBar() {
- System.out.println("Loading SearchBar...");
+ com.allen_sauer.gwt.log.client.Log.info("Loading SearchBar...");
// in the future, will be instantiated directly from a higher-level widget
if (existsOnPage()) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestConfigurationFactory.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestConfigurationFactory.java
new file mode 100644
index 0000000..bfcb322
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestConfigurationFactory.java
@@ -0,0 +1,293 @@
+/*
+ * RHQ Management Platform
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.test;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PropertyList;
+import org.rhq.core.domain.configuration.PropertyMap;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
+import org.rhq.core.domain.configuration.definition.PropertyDefinition;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionEnumeration;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionList;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionMap;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
+import org.rhq.core.domain.configuration.definition.PropertyGroupDefinition;
+import org.rhq.core.domain.configuration.definition.PropertySimpleType;
+
+/**
+ * A utility class that provides methods for creating a test {@link ConfigurationDefinition} and a
+ * {@link Configuration} that conforms to that definition.
+ *
+ * @author Ian Springer
+ */
+public abstract class TestConfigurationFactory {
+ public static ConfigurationDefinition createConfigurationDefinition() {
+ ConfigurationDefinition configurationDefinition = new ConfigurationDefinition("TestConfig", "a test config");
+ Map<String, PropertyDefinition> propertyDefinitions = new HashMap<String, PropertyDefinition>();
+ configurationDefinition.setPropertyDefinitions(propertyDefinitions);
+
+ PropertyDefinitionSimple simplePropDef;
+
+ simplePropDef = createStringPropDef1();
+ propertyDefinitions.put(simplePropDef.getName(), simplePropDef);
+
+ simplePropDef = createStringPropDef2();
+ propertyDefinitions.put(simplePropDef.getName(), simplePropDef);
+
+ simplePropDef = new PropertyDefinitionSimple("LongString", "a Long String simple prop", false,
+ PropertySimpleType.LONG_STRING);
+ simplePropDef.setDisplayName(simplePropDef.getName());
+ propertyDefinitions.put(simplePropDef.getName(), simplePropDef);
+
+ simplePropDef = new PropertyDefinitionSimple("Password", "a Password simple prop", false,
+ PropertySimpleType.PASSWORD);
+ simplePropDef.setDisplayName(simplePropDef.getName());
+ propertyDefinitions.put(simplePropDef.getName(), simplePropDef);
+
+ simplePropDef = new PropertyDefinitionSimple("Boolean", "a required Boolean simple prop", true,
+ PropertySimpleType.BOOLEAN);
+ simplePropDef.setDisplayName(simplePropDef.getName());
+ propertyDefinitions.put(simplePropDef.getName(), simplePropDef);
+ simplePropDef.setRequired(true);
+
+ simplePropDef = createIntegerPropDef();
+ propertyDefinitions.put(simplePropDef.getName(), simplePropDef);
+
+ simplePropDef = new PropertyDefinitionSimple("Float", "a Float simple prop", false, PropertySimpleType.FLOAT);
+ simplePropDef.setDisplayName(simplePropDef.getName());
+ propertyDefinitions.put(simplePropDef.getName(), simplePropDef);
+
+ simplePropDef = new PropertyDefinitionSimple("StringEnum1",
+ "a String enum prop with <=5 items - should be rendered as radio buttons", false,
+ PropertySimpleType.STRING);
+ simplePropDef.setDisplayName(simplePropDef.getName());
+ ArrayList<PropertyDefinitionEnumeration> propDefEnums = new ArrayList<PropertyDefinitionEnumeration>();
+ propDefEnums.add(new PropertyDefinitionEnumeration("NY", "NY"));
+ propDefEnums.add(new PropertyDefinitionEnumeration("NJ", "NJ", true));
+ propDefEnums.add(new PropertyDefinitionEnumeration("PA", "PA"));
+ simplePropDef.setEnumeratedValues(propDefEnums, false);
+ propertyDefinitions.put(simplePropDef.getName(), simplePropDef);
+
+ simplePropDef = new PropertyDefinitionSimple("StringEnum2",
+ "a String enum prop with >5 items - should be rendered as a popup menu", false, PropertySimpleType.STRING);
+ simplePropDef.setDisplayName(simplePropDef.getName());
+ propDefEnums = new ArrayList<PropertyDefinitionEnumeration>();
+ propDefEnums.add(new PropertyDefinitionEnumeration("red", "red"));
+ propDefEnums.add(new PropertyDefinitionEnumeration("orange", "orange", true));
+ propDefEnums.add(new PropertyDefinitionEnumeration("yellow", "yellow"));
+ propDefEnums.add(new PropertyDefinitionEnumeration("green", "green"));
+ propDefEnums.add(new PropertyDefinitionEnumeration("blue", "blue"));
+ propDefEnums.add(new PropertyDefinitionEnumeration("purple", "purple"));
+ simplePropDef.setEnumeratedValues(propDefEnums, false);
+ propertyDefinitions.put(simplePropDef.getName(), simplePropDef);
+
+ PropertyDefinitionMap mapPropDef = new PropertyDefinitionMap("MapOfSimples", "a map of simples", false);
+ mapPropDef.put(createStringPropDef1());
+ mapPropDef.put(createStringPropDef2());
+ mapPropDef.put(createIntegerPropDef());
+ mapPropDef.setDisplayName(mapPropDef.getName());
+ propertyDefinitions.put(mapPropDef.getName(), mapPropDef);
+
+ PropertyDefinitionMap openMapPropDef = new PropertyDefinitionMap("OpenMapOfSimples", "an open map of simples",
+ false);
+ openMapPropDef.setDisplayName(openMapPropDef.getName());
+ propertyDefinitions.put(openMapPropDef.getName(), openMapPropDef);
+
+ PropertyDefinitionMap readOnlyOpenMapPropDef = new PropertyDefinitionMap("ReadOnlyOpenMapOfSimples",
+ "a read-only open map of simples", false);
+ readOnlyOpenMapPropDef.setDisplayName(readOnlyOpenMapPropDef.getName());
+ readOnlyOpenMapPropDef.setReadOnly(true);
+ propertyDefinitions.put(readOnlyOpenMapPropDef.getName(), readOnlyOpenMapPropDef);
+
+ PropertyDefinitionList listOfSimplesPropDef = new PropertyDefinitionList("ListOfStrings",
+ "another list of Strings", true, new PropertyDefinitionSimple("note", "a note", false,
+ PropertySimpleType.STRING));
+ listOfSimplesPropDef.setDisplayName(listOfSimplesPropDef.getName());
+ propertyDefinitions.put(listOfSimplesPropDef.getName(), listOfSimplesPropDef);
+
+ PropertyDefinitionMap mapInListPropDef =
+ new PropertyDefinitionMap("MapOfSimplesInList", "a map of simples in a list", false);
+ mapInListPropDef.put(createStringPropDef1());
+ mapInListPropDef.put(createStringPropDef2());
+ mapInListPropDef.put(createIntegerPropDef());
+ mapInListPropDef.setDisplayName(mapInListPropDef.getName());
+
+ PropertyDefinitionList listPropDef = new PropertyDefinitionList("ListOfMaps", "a list of maps", true,
+ mapInListPropDef);
+ listPropDef.setDisplayName(listPropDef.getName());
+ propertyDefinitions.put(listPropDef.getName(), listPropDef);
+
+ PropertyDefinitionMap mapInReadOnlyListPropDef =
+ new PropertyDefinitionMap("MapOfSimplesInReadOnlyList", "a map of simples in a list", false);
+ mapInReadOnlyListPropDef.put(createStringPropDef1());
+ mapInReadOnlyListPropDef.put(createStringPropDef2());
+ mapInReadOnlyListPropDef.put(createIntegerPropDef());
+ mapInReadOnlyListPropDef.setDisplayName(mapInReadOnlyListPropDef.getName());
+
+ PropertyDefinitionList readOnlyListPropDef = new PropertyDefinitionList("ReadOnlyListOfMaps",
+ "a read-only list of maps", true, mapInReadOnlyListPropDef);
+ readOnlyListPropDef.setDisplayName(readOnlyListPropDef.getName());
+ readOnlyListPropDef.setReadOnly(true);
+ propertyDefinitions.put(readOnlyListPropDef.getName(), readOnlyListPropDef);
+
+ PropertyGroupDefinition propertyGroupDefinition = new PropertyGroupDefinition("myGroup");
+ propertyGroupDefinition.setDisplayName(propertyGroupDefinition.getName());
+ propertyGroupDefinition.setDescription("this is an example group");
+
+ PropertyDefinitionSimple myString = new PropertyDefinitionSimple("myString1", "my little string", true,
+ PropertySimpleType.STRING);
+ myString.setDisplayName(myString.getName());
+ myString.setSummary(true);
+ propertyDefinitions.put(myString.getName(), myString);
+ myString.setPropertyGroupDefinition(propertyGroupDefinition);
+
+ PropertyDefinitionSimple myString2 = new PropertyDefinitionSimple("myString2", "my other little string", true,
+ PropertySimpleType.STRING);
+ myString2.setDisplayName(myString2.getName());
+ myString2.setSummary(true);
+ propertyDefinitions.put(myString2.getName(), myString2);
+ myString2.setPropertyGroupDefinition(propertyGroupDefinition);
+
+ PropertyGroupDefinition propertyGroupDefinition2 = new PropertyGroupDefinition("myGroup2");
+ propertyGroupDefinition2.setDisplayName(propertyGroupDefinition2.getName());
+ propertyGroupDefinition2.setDescription("this is another example group");
+
+ PropertyDefinitionSimple myString3 = new PropertyDefinitionSimple("myString3", "my third string", true,
+ PropertySimpleType.STRING);
+ myString3.setDisplayName((myString3.getName()));
+ myString3.setSummary(true);
+ propertyDefinitions.put(myString3.getName(), myString3);
+ myString3.setPropertyGroupDefinition(propertyGroupDefinition2);
+
+ PropertyDefinitionSimple enumExample = new PropertyDefinitionSimple("myEnum",
+ "a grouped enum prop with <=5 items", false, PropertySimpleType.STRING);
+ enumExample.setDisplayName(enumExample.getName());
+ ArrayList<PropertyDefinitionEnumeration> myEnums = new ArrayList<PropertyDefinitionEnumeration>();
+ myEnums.add(new PropertyDefinitionEnumeration("Burlington", "Burlington"));
+ myEnums.add(new PropertyDefinitionEnumeration("Camden", "Camden", true));
+ myEnums.add(new PropertyDefinitionEnumeration("Gloucester", "Gloucester"));
+ enumExample.setEnumeratedValues(myEnums, false);
+ propertyDefinitions.put(enumExample.getName(), enumExample);
+ enumExample.setPropertyGroupDefinition(propertyGroupDefinition2);
+
+ return configurationDefinition;
+ }
+
+ public static Configuration createConfiguration() {
+ Configuration configuration = new Configuration();
+ configuration.setNotes("a test config");
+ configuration.setVersion(1);
+
+ configuration.put(new PropertySimple("String1", "blah"));
+ configuration.put(new PropertySimple("String2",
+ "a really, really, really, really, really long value that won't fit in the text input box"));
+ configuration.put(new PropertySimple("LongString", "blah blah blah\nblah blah blah"));
+ configuration.put(new PropertySimple("Password", null));
+ configuration.put(new PropertySimple("Boolean", false));
+ configuration.put(new PropertySimple("Integer", 666));
+ configuration.put(new PropertySimple("Float", Math.PI));
+
+ configuration.put(new PropertySimple("StringEnum1", "PA"));
+ configuration.put(new PropertySimple("StringEnum2", "blue"));
+
+ PropertyMap propMap1 = new PropertyMap("MapOfSimples");
+ propMap1.put(new PropertySimple("String1", "One"));
+ propMap1.put(new PropertySimple("String2", "Two"));
+ propMap1.put(new PropertySimple("Integer", 11));
+ configuration.put(propMap1);
+
+ PropertyMap openPropMap1 = new PropertyMap("OpenMapOfSimples");
+ openPropMap1.put(new PropertySimple("PROCESSOR_ARCHITECTURE", "x86"));
+ openPropMap1.put(new PropertySimple("PROCESSOR_IDENTIFIER", "x86 Family 6 Model 15 Stepping 6, GenuineIntel"));
+ openPropMap1.put(new PropertySimple("PROCESSOR_LEVEL", "6"));
+ openPropMap1.put(new PropertySimple("PROCESSOR_REVISION", "0f06"));
+ configuration.put(openPropMap1);
+
+ PropertyMap openPropMap2 = new PropertyMap("ReadOnlyOpenMapOfSimples");
+ openPropMap2.put(new PropertySimple("ANT_HOME", "C:\\opt\\ant-1.6.5"));
+ openPropMap2.put(new PropertySimple("ANT_OPTS", "-Xms128M -Xmx256M"));
+ configuration.put(openPropMap2);
+
+ configuration.put(new PropertyList("ListOfStrings", new PropertySimple("note", "Do"), new PropertySimple(
+ "note", "Re"), new PropertySimple("note", "Mi"), new PropertySimple("note", "Fa"), new PropertySimple(
+ "note", "So"), new PropertySimple("note", "La"), new PropertySimple("note", "Ti")));
+
+ PropertyMap propMap2 = new PropertyMap("MapOfSimples");
+ propMap2.put(new PropertySimple("String1", "Uno"));
+ propMap2.put(new PropertySimple("String2", "Dos"));
+ propMap2.put(new PropertySimple("Integer", Integer.MIN_VALUE));
+ PropertyMap propMap3 = new PropertyMap("MapOfSimples");
+ propMap3.put(new PropertySimple("String1", "Un"));
+ propMap3.put(new PropertySimple("String2", "Deux"));
+ propMap3.put(new PropertySimple("Integer", Integer.MAX_VALUE));
+ configuration.put(new PropertyList("ListOfMaps", propMap2, propMap3));
+
+ PropertyMap propMap4 = new PropertyMap("MapOfSimples");
+ propMap4.put(new PropertySimple("String1", "A"));
+ propMap4.put(new PropertySimple("String2", "B"));
+ propMap4.put(new PropertySimple("Integer", 999));
+ PropertyMap propMap5 = new PropertyMap("MapOfSimples");
+ propMap5.put(new PropertySimple("String1", "a"));
+ propMap5.put(new PropertySimple("String2", "b"));
+ propMap5.put(new PropertySimple("Integer", 0));
+ configuration.put(new PropertyList("ReadOnlyListOfMaps", propMap4, propMap5));
+
+ configuration.put(new PropertySimple("myString1", "grouped String 1"));
+ configuration.put(new PropertySimple("myString2", "grouped String 2"));
+ configuration.put(new PropertySimple("myString3", "strings are cool"));
+ configuration.put(new PropertySimple("myEnum", "Burlington"));
+
+ return configuration;
+ }
+
+ private static PropertyDefinitionSimple createStringPropDef1() {
+ PropertyDefinitionSimple stringPropDef1;
+ stringPropDef1 = new PropertyDefinitionSimple("String1",
+ "an optional String simple prop", false, PropertySimpleType.STRING);
+ stringPropDef1.setDisplayName(stringPropDef1.getName());
+ return stringPropDef1;
+ }
+
+ private static PropertyDefinitionSimple createStringPropDef2() {
+ PropertyDefinitionSimple stringPropDef2;
+ stringPropDef2 = new PropertyDefinitionSimple("String2",
+ "a read-only String simple prop", false, PropertySimpleType.STRING);
+ stringPropDef2.setDisplayName(stringPropDef2.getName());
+ stringPropDef2.setReadOnly(true);
+ return stringPropDef2;
+ }
+
+ private static PropertyDefinitionSimple createIntegerPropDef() {
+ PropertyDefinitionSimple integerPropDef;
+ integerPropDef = new PropertyDefinitionSimple("Integer",
+ "a required summary Integer simple prop", true, PropertySimpleType.INTEGER);
+ integerPropDef.setDisplayName(integerPropDef.getName());
+ integerPropDef.setSummary(true);
+ return integerPropDef;
+ }
+
+ private TestConfigurationFactory() {
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestConfigurationView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestConfigurationView.java
new file mode 100644
index 0000000..0349718
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestConfigurationView.java
@@ -0,0 +1,129 @@
+/*
+ * RHQ Management Platform
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.test;
+
+import java.util.EnumSet;
+
+import com.smartgwt.client.types.Overflow;
+import com.smartgwt.client.widgets.events.ClickEvent;
+import com.smartgwt.client.widgets.events.ClickHandler;
+import com.smartgwt.client.widgets.layout.LayoutSpacer;
+import com.smartgwt.client.widgets.toolbar.ToolStrip;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.components.configuration.ConfigurationEditor;
+import org.rhq.enterprise.gui.coregui.client.components.configuration.PropertyValueChangeEvent;
+import org.rhq.enterprise.gui.coregui.client.components.configuration.PropertyValueChangeListener;
+import org.rhq.enterprise.gui.coregui.client.util.message.Message;
+import org.rhq.enterprise.gui.coregui.client.util.message.MessageCenter;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIButton;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+
+/**
+ * @author Ian Springer
+ */
+public class TestConfigurationView
+ extends LocatableVLayout implements PropertyValueChangeListener {
+ public static final String VIEW_ID = "TestConfig";
+
+ private ConfigurationEditor editor;
+ private LocatableIButton saveButton;
+ private ConfigurationDefinition configurationDefinition;
+ private Configuration configuration;
+
+ public TestConfigurationView(String locatorId) {
+ super(locatorId);
+ }
+
+ @Override
+ protected void onDraw() {
+ super.onDraw();
+ build();
+ }
+
+ public void build() {
+ setWidth100();
+ setHeight100();
+
+ ToolStrip toolStrip = new ToolStrip();
+ toolStrip.setWidth100();
+
+ toolStrip.addMember(new LayoutSpacer());
+
+ this.saveButton = new LocatableIButton(this.extendLocatorId("Save"), "Save");
+ this.saveButton.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent clickEvent) {
+ save();
+ }
+ });
+ this.saveButton.disable();
+ toolStrip.addMember(this.saveButton);
+
+ addMember(toolStrip);
+
+ this.configurationDefinition = TestConfigurationFactory.createConfigurationDefinition();
+ this.configuration = TestConfigurationFactory.createConfiguration();
+
+ reloadConfiguration();
+ }
+
+ private void reloadConfiguration() {
+ this.saveButton.disable();
+ if (editor != null) {
+ editor.destroy();
+ removeMember(editor);
+ }
+
+ editor = new ConfigurationEditor(extendLocatorId("Editor"), this.configurationDefinition, this.configuration);
+ editor.setOverflow(Overflow.AUTO);
+ editor.addValidationStateChangeListener(this);
+ addMember(editor);
+ }
+
+ private void save() {
+ CoreGUI.getMessageCenter().notify(
+ new Message("Configuration updated.", "Test configuration updated."));
+ }
+
+ @Override
+ public void propertyValueChanged(PropertyValueChangeEvent event) {
+ MessageCenter messageCenter = CoreGUI.getMessageCenter();
+ Message message;
+ if (event.isValidationStateChanged()) {
+ if (event.getInvalidPropertyNames().isEmpty()) {
+ this.saveButton.enable();
+ message = new Message("All properties now have valid values, so the configuration can now be saved.",
+ Message.Severity.Info, EnumSet.of(Message.Option.Transient));
+ }
+ else {
+ this.saveButton.disable();
+ message = new Message(
+ "One or more properties have invalid values. The values must be corrected before the configuration can be saved.",
+ Message.Severity.Error, EnumSet.of(Message.Option.Transient, Message.Option.Sticky));
+ }
+ messageCenter.notify(message);
+ }
+ else {
+ this.saveButton.enable();
+ }
+ }
+}
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 a717108..2640674 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
@@ -56,7 +56,7 @@ public abstract class RPCDataSource<T> extends DataSource {
public RPCDataSource(String name) {
if (name != null) {
- System.out.println("Trying to build DS: " + name);
+ com.allen_sauer.gwt.log.client.Log.info("Trying to build DS: " + name);
setID(name);
}
// TODO until http://code.google.com/p/smartgwt/issues/detail?id=490 is fixed always go to the server for data
@@ -245,7 +245,7 @@ public abstract class RPCDataSource<T> extends DataSource {
@SuppressWarnings("unchecked")
public static <S> S[] getArrayFilter(DSRequest request, String paramName, Class<S> type) {
- //System.out.println("Fetching array " + paramName + " (" + type + ")");
+ com.allen_sauer.gwt.log.client.Log.debug("Fetching array " + paramName + " (" + type + ")");
Criteria criteria = request.getCriteria();
Map<String, Object> criteriaMap = criteria.getValues();
@@ -272,14 +272,14 @@ public abstract class RPCDataSource<T> extends DataSource {
throw new IllegalArgumentException("No support for passing array filters of type " + type);
}
- //System.out.println("Result array = " + resultArray);
+ com.allen_sauer.gwt.log.client.Log.debug("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 + ")");
+ com.allen_sauer.gwt.log.client.Log.debug("Fetching " + paramName + " (" + type + ")");
Criteria criteria = request.getCriteria();
Map<String, Object> criteriaMap = criteria.getValues();
@@ -301,7 +301,7 @@ public abstract class RPCDataSource<T> extends DataSource {
}
}
- //System.out.println("Result = " + result);
+ com.allen_sauer.gwt.log.client.Log.debug("Result = " + result);
return result;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/TreeUtility.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/TreeUtility.java
index 360fd86..17049a8 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/TreeUtility.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/TreeUtility.java
@@ -38,7 +38,7 @@ public class TreeUtility {
for (int i = 0; i < level; i++) {
System.out.print(" ");
}
- System.out.println("* " + toString(node));
+ com.allen_sauer.gwt.log.client.Log.info("* " + toString(node));
TreeNode[] childNodes = tree.getChildren(node);
for (TreeNode childNode : childNodes) {
printTreeNode(tree, childNode);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/WidgetUtility.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/WidgetUtility.java
index 5790c70..5714634 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/WidgetUtility.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/WidgetUtility.java
@@ -165,7 +165,7 @@ public class WidgetUtility {
indent.append(" ");
}
- System.out.println(indent + simpleClassName + "[id=" + id + ", title=" + title + ", flags=[" + flags + "]]");
+ com.allen_sauer.gwt.log.client.Log.info(indent + simpleClassName + "[id=" + id + ", title=" + title + ", flags=[" + flags + "]]");
}
private static List<Widget> getChildren(Widget widget) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageBar.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageBar.java
index 8da5ef0..6b356ae 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageBar.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageBar.java
@@ -120,6 +120,10 @@ public class MessageBar extends LocatableHLayout implements MessageCenter.Messag
label.setWidth(400);
+ // TODO: Create some custom edge images in greed, yellow, red, etc. so we can add nice rounded corners to the
+ // label.
+ //label.setShowEdges(true);
+
String icon = (contents != null) ? SEVERITY_TO_ICON_MAP.get(message.getSeverity()) : null;
label.setIcon(icon);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenterView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenterView.java
index d51bc47..1a6968d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenterView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenterView.java
@@ -20,6 +20,7 @@ package org.rhq.enterprise.gui.coregui.client.util.message;
import java.util.List;
+import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.user.client.Timer;
import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.types.AnimationEffect;
@@ -158,6 +159,8 @@ public class MessageCenterView extends LocatableHLayout implements MessageCenter
public void onMessage(final Message message) {
if (!message.isTransient()) {
+ logMessage(message);
+
final Label label = new Label(message.conciseMessage);
label.setMargin(5);
label.setAutoFit(true);
@@ -193,6 +196,25 @@ public class MessageCenterView extends LocatableHLayout implements MessageCenter
}
}
+ private void logMessage(Message message) {
+ // TODO: Format the message better.
+ String logMessage = message.toString();
+ switch (message.getSeverity()) {
+ case Info:
+ Log.info(logMessage);
+ break;
+ case Warning:
+ Log.warn(logMessage);
+ break;
+ case Error:
+ Log.error(logMessage);
+ break;
+ case Fatal:
+ Log.fatal(logMessage);
+ break;
+ }
+ }
+
private String getSeverityIcon(Message.Severity severity) {
String iconSrc = null;
switch (severity) {
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 2064f63..8ae0364 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
@@ -55,7 +55,7 @@ public class MonitoringRequestCallback implements RequestCallback {
if (STATUS_CODE_OK == response.getStatusCode()) {
RPCManager.getInstance().succeedCall(this);
callback.onResponseReceived(request, response);
- //System.out.println("MonitoringRequestCallback: OK");
+ com.allen_sauer.gwt.log.client.Log.debug("MonitoringRequestCallback: OK");
} else {
RPCManager.getInstance().failCall(this);
callback.onResponseReceived(request, response);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/rpc/RPCManager.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/rpc/RPCManager.java
index 10213f4..3e2e007 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/rpc/RPCManager.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/rpc/RPCManager.java
@@ -62,7 +62,7 @@ public class RPCManager {
}
public void succeedCall(MonitoringRequestCallback callback) {
- //System.out.println("RPC [" + callback.getName() + "] succeeded in [" + callback.age() + "] ms.");
+ com.allen_sauer.gwt.log.client.Log.debug("RPC [" + callback.getName() + "] succeeded in [" + callback.age() + "] ms.");
inProgress.remove(callback);
refresh();
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ConfigurationGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ConfigurationGWTServiceImpl.java
index 63b71a0..08d8046 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ConfigurationGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ConfigurationGWTServiceImpl.java
@@ -102,7 +102,7 @@ public class ConfigurationGWTServiceImpl extends AbstractGWTServiceImpl implemen
}
public RawConfiguration dummy(RawConfiguration config) {
- System.out.println(config.getPath());
+ com.allen_sauer.gwt.log.client.Log.info(config.getPath());
return new RawConfiguration();
// Dummy method for gwt compiler
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ObjectFilter.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ObjectFilter.java
index 7c3acfb..e090640 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ObjectFilter.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ObjectFilter.java
@@ -25,6 +25,8 @@ import java.lang.reflect.Modifier;
import java.util.Collection;
import java.util.Set;
+import com.allen_sauer.gwt.log.client.Log;
+
import org.rhq.core.domain.resource.Resource;
/**
@@ -37,7 +39,7 @@ public class ObjectFilter {
for (Object object : collection) {
filterFields(object, goodFields);
}
- System.out.println("Object filtered from size [" + sizeOfBefore + "] to [" + sizeOf(collection) + "]");
+ com.allen_sauer.gwt.log.client.Log.info("Object filtered from size [" + sizeOfBefore + "] to [" + sizeOf(collection) + "]");
return collection;
}
@@ -51,11 +53,11 @@ public class ObjectFilter {
// Only clearing objects, no point in clearing primitives as it
// doesn't save any space on the stream
if (!f.getType().isPrimitive()) {
- // System.out.println("clearing " + f.getName());
+ Log.debug("Clearing " + f.getName() + "...");
f.setAccessible(true);
f.set(object, null);
} else {
- // System.out.println("Can't do " + f.getType());
+ Log.debug("Can't do " + f.getType());
}
}
}
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 14c6f8d..4e14b75 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
@@ -111,7 +111,7 @@ public class ResourceGWTServiceImpl extends AbstractGWTServiceImpl implements Re
@Override
public void init(ServletConfig config) throws ServletException {
super.init(config);
- System.out.println("Loading GWT RPC Services");
+ com.allen_sauer.gwt.log.client.Log.info("Loading GWT RPC Services");
}
public ResourceGWTServiceImpl() {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceTypeGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceTypeGWTServiceImpl.java
index c74aa3c..4d6706c 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceTypeGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceTypeGWTServiceImpl.java
@@ -26,7 +26,7 @@ public class ResourceTypeGWTServiceImpl extends AbstractGWTServiceImpl implement
}
public RawConfiguration dummy(RawConfiguration config) {
- System.out.println(config.getPath());
+ com.allen_sauer.gwt.log.client.Log.info(config.getPath());
return new RawConfiguration();
}
}
\ No newline at end of file
13 years, 8 months
[rhq] 2 commits - .classpath modules/enterprise
by Joseph Marques
.classpath | 1
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertGWTServiceImpl.java | 21 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AuthorizationGWTServiceImpl.java | 44 ++-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AvailabilityGWTServiceImpl.java | 15 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ClusterGWTServiceImpl.java | 22 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ConfigurationGWTServiceImpl.java | 105 ++++---
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ContentGWTServiceImpl.java | 12
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/DashboardGWTServiceImpl.java | 28 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/EventGWTServiceImpl.java | 54 +++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/MeasurementDataGWTServiceImpl.java | 132 ++++++---
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ObjectFilter.java | 13
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/OperationGWTServiceImpl.java | 65 ++--
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/RepoGWTServiceImpl.java | 11
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceBossGWTServiceImpl.java | 9
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java | 137 ++++++----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceTypeGWTServiceImpl.java | 17 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/RoleGWTServiceImpl.java | 47 ++-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/SearchGWTServiceImpl.java | 49 ++-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/SubjectGWTServiceImpl.java | 47 ++-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/SystemGWTServiceImpl.java | 10
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/TagGWTServiceImpl.java | 66 +++-
21 files changed, 632 insertions(+), 273 deletions(-)
New commits:
commit 198bfdca2ff0c5f150e2f98a20655a5bde66d247
Author: Joseph Marques <joseph(a)redhat.com>
Date: Fri Oct 1 13:48:22 2010 -0400
add jxpath to eclipse .classpath
diff --git a/.classpath b/.classpath
index c13d973..0a567d7 100644
--- a/.classpath
+++ b/.classpath
@@ -254,5 +254,6 @@
<classpathentry exported="true" kind="var" path="M2_REPO/com/smartgwt/smartgwt/2.2/smartgwt-2.2.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/ca/nanometrics/gflot/1.0.0/gflot-1.0.0.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/com/jcraft/jsch/0.1.29/jsch-0.1.29.jar"/>
+ <classpathentry exported="true" kind="var" path="M2_REPO/commons-jxpath/commons-jxpath/1.3/commons-jxpath-1.3.jar"/>
<classpathentry kind="output" path="eclipse-classes"/>
</classpath>
commit 374f578bc10335cd4cd93a8800b264ee5dcd5ee2
Author: Joseph Marques <joseph(a)redhat.com>
Date: Fri Oct 1 13:18:06 2010 -0400
fix all current gwt services to wrap exceptions that are gwt-serializable
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 a1f47c9..dc7497f 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
@@ -21,6 +21,7 @@ package org.rhq.enterprise.gui.coregui.server.gwt;
import org.rhq.core.domain.alert.Alert;
import org.rhq.core.domain.criteria.AlertCriteria;
import org.rhq.core.domain.util.PageList;
+import org.rhq.core.util.exception.ThrowableUtil;
import org.rhq.enterprise.gui.coregui.client.gwt.AlertGWTService;
import org.rhq.enterprise.gui.coregui.server.util.SerialUtility;
import org.rhq.enterprise.server.alert.AlertManagerLocal;
@@ -35,15 +36,27 @@ public class AlertGWTServiceImpl extends AbstractGWTServiceImpl implements Alert
private AlertManagerLocal alertManager = LookupUtil.getAlertManager();
public PageList<Alert> findAlertsByCriteria(AlertCriteria criteria) {
- return SerialUtility.prepare(this.alertManager.findAlertsByCriteria(getSessionSubject(), criteria),
- "AlertService.findAlertsByCriteria");
+ try {
+ return SerialUtility.prepare(this.alertManager.findAlertsByCriteria(getSessionSubject(), criteria),
+ "AlertService.findAlertsByCriteria");
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
public void deleteResourceAlerts(Integer[] alertIds) {
- this.alertManager.deleteResourceAlerts(getSessionSubject(), alertIds);
+ try {
+ this.alertManager.deleteResourceAlerts(getSessionSubject(), alertIds);
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
public void acknowledgeResourceAlerts(Integer[] alertIds) {
- this.alertManager.acknowledgeAlerts(getSessionSubject(), alertIds);
+ try {
+ this.alertManager.acknowledgeAlerts(getSessionSubject(), alertIds);
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AuthorizationGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AuthorizationGWTServiceImpl.java
index 7218061..4b8d73f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AuthorizationGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AuthorizationGWTServiceImpl.java
@@ -22,6 +22,7 @@ import java.util.HashSet;
import java.util.Set;
import org.rhq.core.domain.authz.Permission;
+import org.rhq.core.util.exception.ThrowableUtil;
import org.rhq.enterprise.gui.coregui.client.gwt.AuthorizationGWTService;
import org.rhq.enterprise.gui.coregui.server.util.SerialUtility;
import org.rhq.enterprise.server.authz.AuthorizationManagerLocal;
@@ -32,30 +33,53 @@ import org.rhq.enterprise.server.util.LookupUtil;
*/
public class AuthorizationGWTServiceImpl extends AbstractGWTServiceImpl implements AuthorizationGWTService {
+ private static final long serialVersionUID = 1L;
+
private AuthorizationManagerLocal authorizationManager = LookupUtil.getAuthorizationManager();
public Set<Permission> getExplicitResourcePermissions(int resourceId) {
- return SerialUtility.prepare(new HashSet<Permission>(authorizationManager.getExplicitResourcePermissions(
- getSessionSubject(), resourceId)), "AuthorizationManager.getExplicitResourcePermissions");
+ try {
+ return SerialUtility.prepare(new HashSet<Permission>(authorizationManager.getExplicitResourcePermissions(
+ getSessionSubject(), resourceId)), "AuthorizationManager.getExplicitResourcePermissions");
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
public Set<Permission> getImplicitResourcePermissions(int resourceId) {
- return SerialUtility.prepare(new HashSet<Permission>(authorizationManager.getImplicitResourcePermissions(
- getSessionSubject(), resourceId)), "AuthorizationManager.getImplicitResourcePermissions");
+ try {
+ return SerialUtility.prepare(new HashSet<Permission>(authorizationManager.getImplicitResourcePermissions(
+ getSessionSubject(), resourceId)), "AuthorizationManager.getImplicitResourcePermissions");
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
public Set<Permission> getExplicitGroupPermissions(int groupId) {
- return SerialUtility.prepare(new HashSet<Permission>(authorizationManager.getExplicitGroupPermissions(
- getSessionSubject(), groupId)), "AuthorizationManager.getExplicitGroupPermissions");
+ try {
+ return SerialUtility.prepare(new HashSet<Permission>(authorizationManager.getExplicitGroupPermissions(
+ getSessionSubject(), groupId)), "AuthorizationManager.getExplicitGroupPermissions");
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
public Set<Permission> getImplicitGroupPermissions(int groupId) {
- return SerialUtility.prepare(new HashSet<Permission>(authorizationManager.getImplicitGroupPermissions(
- getSessionSubject(), groupId)), "AuthorizationManager.getImplicitGroupPermissions");
+ try {
+ return SerialUtility.prepare(new HashSet<Permission>(authorizationManager.getImplicitGroupPermissions(
+ getSessionSubject(), groupId)), "AuthorizationManager.getImplicitGroupPermissions");
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
public Set<Permission> getExplicitGlobalPermissions() {
- return SerialUtility.prepare(new HashSet<Permission>(authorizationManager
- .getExplicitGlobalPermissions(getSessionSubject())), "AuthorizationManager.getExplicitGlobalPermissions");
+ try {
+ return SerialUtility.prepare(new HashSet<Permission>(authorizationManager
+ .getExplicitGlobalPermissions(getSessionSubject())),
+ "AuthorizationManager.getExplicitGlobalPermissions");
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AvailabilityGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AvailabilityGWTServiceImpl.java
index cbf72c7..4b636f0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AvailabilityGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AvailabilityGWTServiceImpl.java
@@ -18,10 +18,10 @@
*/
package org.rhq.enterprise.gui.coregui.server.gwt;
-import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.measurement.Availability;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
+import org.rhq.core.util.exception.ThrowableUtil;
import org.rhq.enterprise.gui.coregui.client.gwt.AvailabilityGWTService;
import org.rhq.enterprise.gui.coregui.server.util.SerialUtility;
import org.rhq.enterprise.server.measurement.AvailabilityManagerLocal;
@@ -32,15 +32,16 @@ import org.rhq.enterprise.server.util.LookupUtil;
*/
public class AvailabilityGWTServiceImpl extends AbstractGWTServiceImpl implements AvailabilityGWTService {
+ private static final long serialVersionUID = 1L;
private AvailabilityManagerLocal availabilityManager = LookupUtil.getAvailabilityManager();
public PageList<Availability> findAvailabilityForResource(int resourceId, PageControl pc) {
-
- return SerialUtility.prepare(
- availabilityManager.findAvailabilityForResource(getSessionSubject(), resourceId, pc),
- "AvailabilityService.findAvailabilityForResource"
- );
-
+ try {
+ return SerialUtility.prepare(availabilityManager.findAvailabilityForResource(getSessionSubject(),
+ resourceId, pc), "AvailabilityService.findAvailabilityForResource");
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ClusterGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ClusterGWTServiceImpl.java
index f3f8323..211735d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ClusterGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ClusterGWTServiceImpl.java
@@ -38,32 +38,28 @@ import org.rhq.enterprise.server.util.LookupUtil;
*/
public class ClusterGWTServiceImpl extends AbstractGWTServiceImpl implements ClusterGWTService {
+ private static final long serialVersionUID = 1L;
private ClusterManagerLocal clusterManager = LookupUtil.getClusterManager();
-
public ResourceGroup createAutoClusterBackingGroup(ClusterKey clusterKey, boolean addResources) {
- return SerialUtility.prepare(
- clusterManager.createAutoClusterBackingGroup(getSessionSubject(), clusterKey, addResources),
- "ClusterGWTServiceImpl.createAutoClusterBackingGroup");
+ return SerialUtility.prepare(clusterManager.createAutoClusterBackingGroup(getSessionSubject(), clusterKey,
+ addResources), "ClusterGWTServiceImpl.createAutoClusterBackingGroup");
}
public ResourceGroup getAutoClusterBackingGroup(ClusterKey clusterKey) {
- return SerialUtility.prepare(
- clusterManager.getAutoClusterBackingGroup(getSessionSubject(), clusterKey),
- "ClusterGWTServiceImpl.getAutoClusterBackingGroup");
+ return SerialUtility.prepare(clusterManager.getAutoClusterBackingGroup(getSessionSubject(), clusterKey),
+ "ClusterGWTServiceImpl.getAutoClusterBackingGroup");
}
public List<Resource> getAutoClusterResources(ClusterKey clusterKey) {
- return SerialUtility.prepare(
- clusterManager.getAutoClusterResources(getSessionSubject(), clusterKey),
- "ClusterGWTServiceImpl.getAutoClusterResources");
+ return SerialUtility.prepare(clusterManager.getAutoClusterResources(getSessionSubject(), clusterKey),
+ "ClusterGWTServiceImpl.getAutoClusterResources");
}
public ClusterFlyweight getClusterTree(int groupId) {
- return SerialUtility.prepare(
- clusterManager.getClusterTree(getSessionSubject(), groupId),
- "ClusterGWTServiceImpl.getClusterTree");
+ return SerialUtility.prepare(clusterManager.getClusterTree(getSessionSubject(), groupId),
+ "ClusterGWTServiceImpl.getClusterTree");
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ConfigurationGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ConfigurationGWTServiceImpl.java
index 487b167..63b71a0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ConfigurationGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ConfigurationGWTServiceImpl.java
@@ -1,6 +1,5 @@
package org.rhq.enterprise.gui.coregui.server.gwt;
-import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PluginConfigurationUpdate;
import org.rhq.core.domain.configuration.RawConfiguration;
@@ -9,79 +8,97 @@ import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.criteria.ResourceConfigurationUpdateCriteria;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
-import org.rhq.core.domain.util.PageOrdering;
+import org.rhq.core.util.exception.ThrowableUtil;
import org.rhq.enterprise.gui.coregui.client.gwt.ConfigurationGWTService;
import org.rhq.enterprise.gui.coregui.server.util.SerialUtility;
import org.rhq.enterprise.server.configuration.ConfigurationManagerLocal;
-import org.rhq.enterprise.server.configuration.ConfigurationUpdateStillInProgressException;
import org.rhq.enterprise.server.util.LookupUtil;
-import com.google.gwt.user.server.rpc.RemoteServiceServlet;
-
public class ConfigurationGWTServiceImpl extends AbstractGWTServiceImpl implements ConfigurationGWTService {
+ private static final long serialVersionUID = 1L;
private ConfigurationManagerLocal configurationManager = LookupUtil.getConfigurationManager();
public Configuration getPluginConfiguration(int resourceId) {
-
-
- Configuration configuration = configurationManager.getPluginConfiguration(getSessionSubject(), resourceId);
-
- return SerialUtility.prepare(configuration, "PluginConfiguration");
+ try {
+ Configuration configuration = configurationManager.getPluginConfiguration(getSessionSubject(), resourceId);
+ return SerialUtility.prepare(configuration, "PluginConfiguration");
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
public ConfigurationDefinition getPluginConfigurationDefinition(int resourceTypeId) {
-
- ConfigurationDefinition definition = configurationManager.getPluginConfigurationDefinitionForResourceType(getSessionSubject(), resourceTypeId);
- return SerialUtility.prepare(definition, "PluginDefinition");
+ try {
+ ConfigurationDefinition definition = configurationManager.getPluginConfigurationDefinitionForResourceType(
+ getSessionSubject(), resourceTypeId);
+ return SerialUtility.prepare(definition, "PluginDefinition");
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
-
public Configuration getResourceConfiguration(int resourceId) {
-
- Configuration configuration = configurationManager.getResourceConfiguration(getSessionSubject(), resourceId);
- return SerialUtility.prepare(configuration, "ResourceConfiguration");
+ try {
+ Configuration configuration = configurationManager
+ .getResourceConfiguration(getSessionSubject(), resourceId);
+ return SerialUtility.prepare(configuration, "ResourceConfiguration");
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
public ConfigurationDefinition getResourceConfigurationDefinition(int resourceTypeId) {
-
- ConfigurationDefinition definition = configurationManager.getResourceConfigurationDefinitionWithTemplatesForResourceType(getSessionSubject(), resourceTypeId);
- return SerialUtility.prepare(definition, "ResourceDefinition");
+ try {
+ ConfigurationDefinition definition = configurationManager
+ .getResourceConfigurationDefinitionWithTemplatesForResourceType(getSessionSubject(), resourceTypeId);
+ return SerialUtility.prepare(definition, "ResourceDefinition");
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
- public PageList<ResourceConfigurationUpdate> findResourceConfigurationUpdates(
- Integer resourceId, Long beginDate, Long endDate, boolean suppressOldest, PageControl pc) {
-
- PageList<ResourceConfigurationUpdate> result =
- configurationManager.findResourceConfigurationUpdates(
- getSessionSubject(), resourceId, beginDate, endDate, suppressOldest, pc);
-
- return SerialUtility.prepare(result, "ConfigurationService.findResourceConfigurationUpdates");
+ public PageList<ResourceConfigurationUpdate> findResourceConfigurationUpdates(Integer resourceId, Long beginDate,
+ Long endDate, boolean suppressOldest, PageControl pc) {
+ try {
+ PageList<ResourceConfigurationUpdate> result = configurationManager.findResourceConfigurationUpdates(
+ getSessionSubject(), resourceId, beginDate, endDate, suppressOldest, pc);
+ return SerialUtility.prepare(result, "ConfigurationService.findResourceConfigurationUpdates");
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
-
public ResourceConfigurationUpdate updateResourceConfiguration(int resourceId, Configuration configuration) {
- ResourceConfigurationUpdate update =
- configurationManager.updateResourceConfiguration(getSessionSubject(), resourceId, configuration);
-
- return SerialUtility.prepare(update, "ConfigurationService.updateResourceConfiguration");
+ try {
+ ResourceConfigurationUpdate update = configurationManager.updateResourceConfiguration(getSessionSubject(),
+ resourceId, configuration);
+ return SerialUtility.prepare(update, "ConfigurationService.updateResourceConfiguration");
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
public PluginConfigurationUpdate updatePluginConfiguration(int resourceId, Configuration configuration) {
- PluginConfigurationUpdate update =
- configurationManager.updatePluginConfiguration(getSessionSubject(), resourceId, configuration);
-
- return SerialUtility.prepare(update, "ConfigurationService.updatePluginConfiguration");
+ try {
+ PluginConfigurationUpdate update = configurationManager.updatePluginConfiguration(getSessionSubject(),
+ resourceId, configuration);
+ return SerialUtility.prepare(update, "ConfigurationService.updatePluginConfiguration");
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
- public PageList<ResourceConfigurationUpdate> findResourceConfigurationUpdatesByCriteria(ResourceConfigurationUpdateCriteria criteria) {
- PageList<ResourceConfigurationUpdate> updates =
- configurationManager.findResourceConfigurationUpdatesByCriteria(
- getSessionSubject(), criteria
- );
-
- return SerialUtility.prepare(updates, "ConfigurationService.findResourceConfigurationUpdatesByCriteria");
+ public PageList<ResourceConfigurationUpdate> findResourceConfigurationUpdatesByCriteria(
+ ResourceConfigurationUpdateCriteria criteria) {
+ try {
+ PageList<ResourceConfigurationUpdate> updates = configurationManager
+ .findResourceConfigurationUpdatesByCriteria(getSessionSubject(), criteria);
+ return SerialUtility.prepare(updates, "ConfigurationService.findResourceConfigurationUpdatesByCriteria");
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
public RawConfiguration dummy(RawConfiguration config) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ContentGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ContentGWTServiceImpl.java
index 91c45f8..2d112fb 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ContentGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ContentGWTServiceImpl.java
@@ -25,6 +25,7 @@ package org.rhq.enterprise.gui.coregui.server.gwt;
import org.rhq.core.domain.content.PackageVersion;
import org.rhq.core.domain.criteria.PackageVersionCriteria;
import org.rhq.core.domain.util.PageList;
+import org.rhq.core.util.exception.ThrowableUtil;
import org.rhq.enterprise.gui.coregui.client.gwt.ContentGWTService;
import org.rhq.enterprise.gui.coregui.server.util.SerialUtility;
import org.rhq.enterprise.server.content.ContentManagerLocal;
@@ -35,16 +36,17 @@ import org.rhq.enterprise.server.util.LookupUtil;
*/
public class ContentGWTServiceImpl extends AbstractGWTServiceImpl implements ContentGWTService {
+ private static final long serialVersionUID = 1L;
private ContentManagerLocal contentManager = LookupUtil.getContentManager();
-
-
public PageList<PackageVersion> findPackageVersionsByCriteria(PackageVersionCriteria criteria) {
- return SerialUtility.prepare(contentManager.findPackageVersionsByCriteria(getSessionSubject(), criteria),
+ try {
+ return SerialUtility.prepare(contentManager.findPackageVersionsByCriteria(getSessionSubject(), criteria),
"ContentService.findPackageVersionsByCriteria");
-
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
-
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/DashboardGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/DashboardGWTServiceImpl.java
index 1d28f7d..742c68e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/DashboardGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/DashboardGWTServiceImpl.java
@@ -25,6 +25,7 @@ package org.rhq.enterprise.gui.coregui.server.gwt;
import java.util.List;
import org.rhq.core.domain.dashboard.Dashboard;
+import org.rhq.core.util.exception.ThrowableUtil;
import org.rhq.enterprise.gui.coregui.client.gwt.DashboardGWTService;
import org.rhq.enterprise.gui.coregui.server.util.SerialUtility;
import org.rhq.enterprise.server.dashboard.DashboardManagerLocal;
@@ -35,25 +36,42 @@ import org.rhq.enterprise.server.util.LookupUtil;
*/
public class DashboardGWTServiceImpl extends AbstractGWTServiceImpl implements DashboardGWTService {
- private DashboardManagerLocal dashboardManager = LookupUtil.getDashboardManagerLocal();
+ private static final long serialVersionUID = 1L;
+ private DashboardManagerLocal dashboardManager = LookupUtil.getDashboardManagerLocal();
public List<Dashboard> findDashboardsForSubject() {
- return SerialUtility.prepare(dashboardManager.findDashboardsForSubject(getSessionSubject()),
+ try {
+ return SerialUtility.prepare(dashboardManager.findDashboardsForSubject(getSessionSubject()),
"DashboardManager.findDashboardsForSubject");
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
public List<Dashboard> findSharedDashboards() {
- return SerialUtility.prepare(dashboardManager.findSharedDashboards(getSessionSubject()),
+ try {
+ return SerialUtility.prepare(dashboardManager.findSharedDashboards(getSessionSubject()),
"DashboardManager.findSharedDashboards");
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
public Dashboard storeDashboard(Dashboard dashboard) {
- return SerialUtility.prepare(dashboardManager.storeDashboard(getSessionSubject(),dashboard),
+ try {
+ return SerialUtility.prepare(dashboardManager.storeDashboard(getSessionSubject(), dashboard),
"DashboardManager.storeDashboard");
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
public void removeDashboard(int dashboardId) {
- dashboardManager.removeDashboard(getSessionSubject(), dashboardId);
+ try {
+ dashboardManager.removeDashboard(getSessionSubject(), dashboardId);
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/EventGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/EventGWTServiceImpl.java
index 665f370..3dbae8e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/EventGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/EventGWTServiceImpl.java
@@ -30,6 +30,7 @@ import org.rhq.core.domain.event.Event;
import org.rhq.core.domain.event.EventSeverity;
import org.rhq.core.domain.event.composite.EventComposite;
import org.rhq.core.domain.util.PageList;
+import org.rhq.core.util.exception.ThrowableUtil;
import org.rhq.enterprise.gui.coregui.client.gwt.EventGWTService;
import org.rhq.enterprise.gui.coregui.server.util.SerialUtility;
import org.rhq.enterprise.server.event.EventManagerLocal;
@@ -46,37 +47,66 @@ public class EventGWTServiceImpl extends AbstractGWTServiceImpl implements Event
private EventManagerLocal eventManager = LookupUtil.getEventManager();
public EventSeverity[] getSeverityBuckets(int resourceId, long begin, long end, int numBuckets) {
- return SerialUtility.prepare(eventManager.getSeverityBuckets(getSessionSubject(), resourceId, begin, end,
- numBuckets), "EventService.getSeverityBuckets");
+ try {
+ return SerialUtility.prepare(eventManager.getSeverityBuckets(getSessionSubject(), resourceId, begin, end,
+ numBuckets), "EventService.getSeverityBuckets");
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
public EventSeverity[] getSeverityBucketsForAutoGroup(int parentResourceId, int resourceTypeId, long begin,
long end, int numBuckets) {
- return SerialUtility.prepare(eventManager.getSeverityBucketsForAutoGroup(getSessionSubject(), parentResourceId,
- resourceTypeId, begin, end, numBuckets), "EventService.getSeverityBucketsForAutoGroup");
+ try {
+ return SerialUtility.prepare(eventManager.getSeverityBucketsForAutoGroup(getSessionSubject(),
+ parentResourceId, resourceTypeId, begin, end, numBuckets),
+ "EventService.getSeverityBucketsForAutoGroup");
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
public EventSeverity[] getSeverityBucketsForCompGroup(int resourceGroupId, long begin, long end, int numBuckets) {
- return SerialUtility.prepare(eventManager.getSeverityBucketsForCompGroup(getSessionSubject(), resourceGroupId,
- begin, end, numBuckets), "EventService.getSeverityBucketsForCompGroup");
+ try {
+ return SerialUtility.prepare(eventManager.getSeverityBucketsForCompGroup(getSessionSubject(),
+ resourceGroupId, begin, end, numBuckets), "EventService.getSeverityBucketsForCompGroup");
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
public PageList<Event> findEventsByCriteria(EventCriteria criteria) {
- return SerialUtility.prepare(eventManager.findEventsByCriteria(getSessionSubject(), criteria),
- "EventService.findEventsByCriteria");
+ try {
+ return SerialUtility.prepare(eventManager.findEventsByCriteria(getSessionSubject(), criteria),
+ "EventService.findEventsByCriteria");
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
public PageList<EventComposite> findEventCompositesByCriteria(EventCriteria criteria) {
- return SerialUtility.prepare(eventManager.findEventCompositesByCriteria(getSessionSubject(), criteria),
- "EventService.findEventsByCriteria");
+ try {
+ return SerialUtility.prepare(eventManager.findEventCompositesByCriteria(getSessionSubject(), criteria),
+ "EventService.findEventsByCriteria");
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
public int deleteEventsForContext(EntityContext context, List<Integer> eventIds) {
- return eventManager.deleteEventsForContext(getSessionSubject(), context, eventIds);
+ try {
+ return eventManager.deleteEventsForContext(getSessionSubject(), context, eventIds);
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
public int purgeEventsForContext(EntityContext context) {
- return eventManager.purgeEventsForContext(getSessionSubject(), context);
+ try {
+ return eventManager.purgeEventsForContext(getSessionSubject(), context);
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/MeasurementDataGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/MeasurementDataGWTServiceImpl.java
index 78232b6..1cc9170 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/MeasurementDataGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/MeasurementDataGWTServiceImpl.java
@@ -34,6 +34,7 @@ import org.rhq.core.domain.measurement.composite.MeasurementDataNumericHighLowCo
import org.rhq.core.domain.measurement.composite.MeasurementOOBComposite;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
+import org.rhq.core.util.exception.ThrowableUtil;
import org.rhq.enterprise.gui.coregui.client.gwt.MeasurementDataGWTService;
import org.rhq.enterprise.gui.coregui.server.util.SerialUtility;
import org.rhq.enterprise.server.measurement.CallTimeDataManagerLocal;
@@ -58,89 +59,140 @@ public class MeasurementDataGWTServiceImpl extends AbstractGWTServiceImpl implem
private MeasurementDefinitionManagerLocal definitionManager = LookupUtil.getMeasurementDefinitionManager();
public List<MeasurementDataTrait> findCurrentTraitsForResource(int resourceId, DisplayType displayType) {
- return SerialUtility.prepare(dataManager.findCurrentTraitsForResource(getSessionSubject(), resourceId,
- displayType), "MeasurementDataService.findCurrentTraitsForResource");
+ try {
+ return SerialUtility.prepare(dataManager.findCurrentTraitsForResource(getSessionSubject(), resourceId,
+ displayType), "MeasurementDataService.findCurrentTraitsForResource");
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
public Set<MeasurementData> findLiveData(int resourceId, int[] definitionIds) {
- return SerialUtility.prepare(dataManager.findLiveData(getSessionSubject(), resourceId, definitionIds),
- "MeasurementDataService.findLiveData");
+ try {
+ return SerialUtility.prepare(dataManager.findLiveData(getSessionSubject(), resourceId, definitionIds),
+ "MeasurementDataService.findLiveData");
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
public List<List<MeasurementDataNumericHighLowComposite>> findDataForResource(int resourceId, int[] definitionIds,
long beginTime, long endTime, int numPoints) {
- return SerialUtility.prepare(dataManager.findDataForResource(getSessionSubject(), resourceId, definitionIds,
- beginTime, endTime, numPoints), "MeasurementDataService.findDataForResource");
+ try {
+ return SerialUtility.prepare(dataManager.findDataForResource(getSessionSubject(), resourceId,
+ definitionIds, beginTime, endTime, numPoints), "MeasurementDataService.findDataForResource");
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
public PageList<CallTimeDataComposite> findCallTimeDataForResource(int scheduleId, long start, long end,
PageControl pageControl) {
- return SerialUtility.prepare(callTimeDataManager.findCallTimeDataForResource(getSessionSubject(), scheduleId,
- start, end, pageControl), "MeasurementDataService.findCallTimeDataForResource");
+ try {
+ return SerialUtility.prepare(callTimeDataManager.findCallTimeDataForResource(getSessionSubject(),
+ scheduleId, start, end, pageControl), "MeasurementDataService.findCallTimeDataForResource");
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
public PageList<MeasurementDefinition> findMeasurementDefinitionsByCriteria(MeasurementDefinitionCriteria criteria) {
- return SerialUtility.prepare(definitionManager.findMeasurementDefinitionsByCriteria(getSessionSubject(),
- criteria), "MeasurementDataService.findMeasurementDefinintionsByCriteria");
+ try {
+ return SerialUtility.prepare(definitionManager.findMeasurementDefinitionsByCriteria(getSessionSubject(),
+ criteria), "MeasurementDataService.findMeasurementDefinintionsByCriteria");
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
public PageList<MeasurementSchedule> findMeasurementSchedulesByCriteria(MeasurementScheduleCriteria criteria) {
- return SerialUtility.prepare(scheduleManager.findSchedulesByCriteria(getSessionSubject(), criteria),
- "MeasurementDataService.findMeasurementSchedulesByCriteria");
+ try {
+ return SerialUtility.prepare(scheduleManager.findSchedulesByCriteria(getSessionSubject(), criteria),
+ "MeasurementDataService.findMeasurementSchedulesByCriteria");
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
-
- public PageList<MeasurementOOBComposite> getSchedulesWithOOBs(String metricNameFilter, String resourceNameFilter, String parentNameFilter, PageControl pc) {
- return SerialUtility.prepare(
- measurementOOBManager.getSchedulesWithOOBs(
- getSessionSubject(),
- metricNameFilter,
- resourceNameFilter,
- parentNameFilter,
- pc),
+ public PageList<MeasurementOOBComposite> getSchedulesWithOOBs(String metricNameFilter, String resourceNameFilter,
+ String parentNameFilter, PageControl pc) {
+ try {
+ return SerialUtility.prepare(measurementOOBManager.getSchedulesWithOOBs(getSessionSubject(),
+ metricNameFilter, resourceNameFilter, parentNameFilter, pc),
"MeasurementDataService.getSchedulesWithOOBs");
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
public PageList<MeasurementOOBComposite> getHighestNOOBsForResource(int resourceId, int n) {
- return SerialUtility.prepare(
- measurementOOBManager.getHighestNOOBsForResource(
- getSessionSubject(),
- resourceId,
- n),
- "MeasurementDataService.getHighestNOOBsForResource");
+ try {
+ return SerialUtility.prepare(measurementOOBManager.getHighestNOOBsForResource(getSessionSubject(),
+ resourceId, n), "MeasurementDataService.getHighestNOOBsForResource");
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
public void enableSchedulesForResource(int resourceId, int[] measurementDefinitionIds) {
- scheduleManager.enableSchedulesForResource(getSessionSubject(), resourceId, measurementDefinitionIds);
+ try {
+ scheduleManager.enableSchedulesForResource(getSessionSubject(), resourceId, measurementDefinitionIds);
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
public void disableSchedulesForResource(int resourceId, int[] measurementDefinitionIds) {
- scheduleManager.disableSchedulesForResource(getSessionSubject(), resourceId, measurementDefinitionIds);
+ try {
+ scheduleManager.disableSchedulesForResource(getSessionSubject(), resourceId, measurementDefinitionIds);
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
public void updateSchedulesForResource(int resourceId, int[] measurementDefinitionIds, long collectionInterval) {
- scheduleManager.updateSchedulesForResource(getSessionSubject(), resourceId, measurementDefinitionIds,
+ try {
+ scheduleManager.updateSchedulesForResource(getSessionSubject(), resourceId, measurementDefinitionIds,
collectionInterval);
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
public void enableSchedulesForCompatibleGroup(int resourceGroupId, int[] measurementDefinitionIds) {
- scheduleManager.enableSchedulesForCompatibleGroup(getSessionSubject(), resourceGroupId, measurementDefinitionIds);
+ try {
+ scheduleManager.enableSchedulesForCompatibleGroup(getSessionSubject(), resourceGroupId,
+ measurementDefinitionIds);
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
public void disableSchedulesForCompatibleGroup(int resourceGroupId, int[] measurementDefinitionIds) {
- scheduleManager.disableSchedulesForCompatibleGroup(getSessionSubject(), resourceGroupId, measurementDefinitionIds);
+ try {
+ scheduleManager.disableSchedulesForCompatibleGroup(getSessionSubject(), resourceGroupId,
+ measurementDefinitionIds);
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
public void updateSchedulesForCompatibleGroup(int resourceGroupId, int[] measurementDefinitionIds,
- long collectionInterval) {
- scheduleManager.updateSchedulesForCompatibleGroup(getSessionSubject(), resourceGroupId, measurementDefinitionIds,
- collectionInterval);
- }
+ long collectionInterval) {
+ try {
+ scheduleManager.updateSchedulesForCompatibleGroup(getSessionSubject(), resourceGroupId,
+ measurementDefinitionIds, collectionInterval);
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
+ }
public PageList<MeasurementDataTrait> findTraitsByCriteria(MeasurementDataTraitCriteria criteria) {
- return SerialUtility.prepare(dataManager.findTraitsByCriteria(getSessionSubject(), criteria),
- "MeasurementDataService.findTraitsByCriteria");
+ try {
+ return SerialUtility.prepare(dataManager.findTraitsByCriteria(getSessionSubject(), criteria),
+ "MeasurementDataService.findTraitsByCriteria");
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
}
-
-
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ObjectFilter.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ObjectFilter.java
index 62dc79b..7c3acfb 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ObjectFilter.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ObjectFilter.java
@@ -18,22 +18,20 @@
*/
package org.rhq.enterprise.gui.coregui.server.gwt;
-import org.rhq.core.domain.resource.Resource;
-
import java.io.ByteArrayOutputStream;
import java.io.ObjectOutputStream;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.Collection;
-import java.util.List;
import java.util.Set;
+import org.rhq.core.domain.resource.Resource;
+
/**
* @author Greg Hinkle
*/
public class ObjectFilter {
-
public static <T extends Collection<?>> T filterFieldsInCollection(T collection, Set<String> goodFields) {
long sizeOfBefore = sizeOf(collection);
for (Object object : collection) {
@@ -45,7 +43,6 @@ public class ObjectFilter {
}
public static <T> T filterFields(T object, Set<String> goodFields) {
-
try {
Field[] fields = Resource.class.getDeclaredFields();
for (Field f : fields) {
@@ -54,11 +51,11 @@ public class ObjectFilter {
// Only clearing objects, no point in clearing primitives as it
// doesn't save any space on the stream
if (!f.getType().isPrimitive()) {
-// System.out.println("clearing " + f.getName());
+ // System.out.println("clearing " + f.getName());
f.setAccessible(true);
f.set(object, null);
} else {
-// System.out.println("Can't do " + f.getType());
+ // System.out.println("Can't do " + f.getType());
}
}
}
@@ -67,11 +64,9 @@ public class ObjectFilter {
e.printStackTrace();
}
-
return object;
}
-
private static int sizeOf(Object object) {
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream(50000);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/OperationGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/OperationGWTServiceImpl.java
index a7f72ed..4519e00 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/OperationGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/OperationGWTServiceImpl.java
@@ -33,6 +33,7 @@ import org.rhq.core.domain.resource.composite.DisambiguationReport;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.util.IntExtractor;
+import org.rhq.core.util.exception.ThrowableUtil;
import org.rhq.enterprise.gui.coregui.client.gwt.OperationGWTService;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.create.ExecutionSchedule;
import org.rhq.enterprise.gui.coregui.server.util.SerialUtility;
@@ -52,29 +53,33 @@ public class OperationGWTServiceImpl extends AbstractGWTServiceImpl implements O
public PageList<ResourceOperationHistory> findResourceOperationHistoriesByCriteria(
ResourceOperationHistoryCriteria criteria) {
- return SerialUtility.prepare(operationManager.findResourceOperationHistoriesByCriteria(getSessionSubject(),
- criteria), "OperationService.findResourceOperationHistoriesByCriteria");
-
+ try {
+ return SerialUtility.prepare(operationManager.findResourceOperationHistoriesByCriteria(getSessionSubject(),
+ criteria), "OperationService.findResourceOperationHistoriesByCriteria");
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
public PageList<GroupOperationHistory> findGroupOperationHistoriesByCriteria(GroupOperationHistoryCriteria criteria) {
- return SerialUtility.prepare(operationManager.findGroupOperationHistoriesByCriteria(getSessionSubject(),
- criteria), "OperationService.findGroupOperationHistoriesByCriteria");
+ try {
+ return SerialUtility.prepare(operationManager.findGroupOperationHistoriesByCriteria(getSessionSubject(),
+ criteria), "OperationService.findGroupOperationHistoriesByCriteria");
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
public void scheduleResourceOperation(int resourceId, String operationName, Configuration parameters,
ExecutionSchedule schedule, String description, int timeout) throws RuntimeException {
- ResourceOperationSchedule opSchedule;
try {
-
+ ResourceOperationSchedule opSchedule;
if (schedule.getStart() == ExecutionSchedule.Start.Immediately) {
opSchedule = operationManager.scheduleResourceOperation(getSessionSubject(), resourceId, operationName,
0, 0, 0, 0, parameters, description);
} else {
-
CronTrigger ct = new CronTrigger("resource " + resourceId + "_" + operationName, "group", schedule
.getCronString());
-
opSchedule = operationManager.scheduleResourceOperation(getSessionSubject(), resourceId, operationName,
parameters, ct, description);
}
@@ -88,34 +93,40 @@ public class OperationGWTServiceImpl extends AbstractGWTServiceImpl implements O
*/
public List<DisambiguationReport<ResourceOperationLastCompletedComposite>> findRecentCompletedOperations(
int pageSize) {
+ try {
+ PageControl pageControl = new PageControl(0, pageSize);
+ PageList<ResourceOperationLastCompletedComposite> lastCompletedResourceOps = operationManager
+ .findRecentlyCompletedResourceOperations(getSessionSubject(), null, pageControl);
- PageControl pageControl = new PageControl(0, pageSize);
- PageList<ResourceOperationLastCompletedComposite> lastCompletedResourceOps = operationManager
- .findRecentlyCompletedResourceOperations(getSessionSubject(), null, pageControl);
-
- //translate the returned problem resources to disambiguated links
- List<DisambiguationReport<ResourceOperationLastCompletedComposite>> disambiguatedLastCompletedResourceOps = resourceManager
- .disambiguate(lastCompletedResourceOps, RESOURCE_OPERATION_RESOURCE_ID_EXTRACTOR,
- DefaultDisambiguationUpdateStrategies.getDefault());
+ //translate the returned problem resources to disambiguated links
+ List<DisambiguationReport<ResourceOperationLastCompletedComposite>> disambiguatedLastCompletedResourceOps = resourceManager
+ .disambiguate(lastCompletedResourceOps, RESOURCE_OPERATION_RESOURCE_ID_EXTRACTOR,
+ DefaultDisambiguationUpdateStrategies.getDefault());
- return disambiguatedLastCompletedResourceOps;
+ return disambiguatedLastCompletedResourceOps;
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
/** Find scheduled operations, disambiguate them and return that list.
*
*/
public List<DisambiguationReport<ResourceOperationScheduleComposite>> findScheduledOperations(int pageSize) {
+ try {
+ PageControl pageControl = new PageControl(0, pageSize);
+ PageList<ResourceOperationScheduleComposite> scheduledResourceOps = operationManager
+ .findCurrentlyScheduledResourceOperations(getSessionSubject(), pageControl);
- PageControl pageControl = new PageControl(0, pageSize);
- PageList<ResourceOperationScheduleComposite> scheduledResourceOps = operationManager
- .findCurrentlyScheduledResourceOperations(getSessionSubject(), pageControl);
-
- //translate the returned problem resources to disambiguated links
- List<DisambiguationReport<ResourceOperationScheduleComposite>> disambiguatedNextScheduledResourceOps = resourceManager
- .disambiguate(scheduledResourceOps, RESOURCE_OPERATION_SCHEDULE_RESOURCE_ID_EXTRACTOR,
- DefaultDisambiguationUpdateStrategies.getDefault());
+ //translate the returned problem resources to disambiguated links
+ List<DisambiguationReport<ResourceOperationScheduleComposite>> disambiguatedNextScheduledResourceOps = resourceManager
+ .disambiguate(scheduledResourceOps, RESOURCE_OPERATION_SCHEDULE_RESOURCE_ID_EXTRACTOR,
+ DefaultDisambiguationUpdateStrategies.getDefault());
- return disambiguatedNextScheduledResourceOps;
+ return disambiguatedNextScheduledResourceOps;
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
private static final IntExtractor<ResourceOperationLastCompletedComposite> RESOURCE_OPERATION_RESOURCE_ID_EXTRACTOR = new IntExtractor<ResourceOperationLastCompletedComposite>() {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/RepoGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/RepoGWTServiceImpl.java
index 45c2c5e..073a6f7 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/RepoGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/RepoGWTServiceImpl.java
@@ -25,6 +25,7 @@ package org.rhq.enterprise.gui.coregui.server.gwt;
import org.rhq.core.domain.content.Repo;
import org.rhq.core.domain.criteria.RepoCriteria;
import org.rhq.core.domain.util.PageList;
+import org.rhq.core.util.exception.ThrowableUtil;
import org.rhq.enterprise.gui.coregui.client.gwt.RepoGWTService;
import org.rhq.enterprise.gui.coregui.server.util.SerialUtility;
import org.rhq.enterprise.server.content.RepoManagerLocal;
@@ -35,13 +36,17 @@ import org.rhq.enterprise.server.util.LookupUtil;
*/
public class RepoGWTServiceImpl extends AbstractGWTServiceImpl implements RepoGWTService {
+ private static final long serialVersionUID = 1L;
+
private RepoManagerLocal repoManager = LookupUtil.getRepoManagerLocal();
public PageList<Repo> findReposByCriteria(RepoCriteria criteria) {
- return SerialUtility.prepare(
- repoManager.findReposByCriteria(getSessionSubject(), criteria),
+ try {
+ return SerialUtility.prepare(repoManager.findReposByCriteria(getSessionSubject(), criteria),
"ContentService.findReposByCriteria");
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
-
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceBossGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceBossGWTServiceImpl.java
index 5ac22b5..fb00c3a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceBossGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceBossGWTServiceImpl.java
@@ -25,6 +25,7 @@ package org.rhq.enterprise.gui.coregui.server.gwt;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.resource.InventorySummary;
+import org.rhq.core.util.exception.ThrowableUtil;
import org.rhq.enterprise.gui.coregui.client.gwt.ResourceBossGWTService;
import org.rhq.enterprise.server.resource.ResourceBossLocal;
import org.rhq.enterprise.server.util.LookupUtil;
@@ -34,6 +35,8 @@ import org.rhq.enterprise.server.util.LookupUtil;
*/
public class ResourceBossGWTServiceImpl extends AbstractGWTServiceImpl implements ResourceBossGWTService {
+ private static final long serialVersionUID = 1L;
+
private ResourceBossLocal resourceBoss = LookupUtil.getResourceBoss();
public InventorySummary getInventorySummaryForLoggedInUser() {
@@ -42,6 +45,10 @@ public class ResourceBossGWTServiceImpl extends AbstractGWTServiceImpl implement
}
public InventorySummary getInventorySummary(Subject user) {
- return resourceBoss.getInventorySummary(user);
+ try {
+ return resourceBoss.getInventorySummary(user);
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
}
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 2e2f6d6..14c6f8d 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
@@ -43,6 +43,7 @@ import org.rhq.core.domain.resource.composite.ResourceLineageComposite;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.util.IntExtractor;
+import org.rhq.core.util.exception.ThrowableUtil;
import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGWTService;
import org.rhq.enterprise.gui.coregui.server.util.SerialUtility;
import org.rhq.enterprise.server.discovery.DiscoveryBossLocal;
@@ -57,6 +58,8 @@ import org.rhq.enterprise.server.util.LookupUtil;
*/
public class ResourceGWTServiceImpl extends AbstractGWTServiceImpl implements ResourceGWTService {
+ private static final long serialVersionUID = 1L;
+
private ResourceManagerLocal resourceManager = LookupUtil.getResourceManager();
private ResourceFactoryManagerLocal resourceFactoryManager = LookupUtil.getResourceFactoryManager();
private DiscoveryBossLocal discoveryBoss = LookupUtil.getDiscoveryBoss();
@@ -122,8 +125,7 @@ public class ResourceGWTServiceImpl extends AbstractGWTServiceImpl implements Re
return SerialUtility.prepare(result, "ResourceService.findResourcesByCriteria");
} catch (Exception e) {
- e.printStackTrace();
- throw new RuntimeException(e);
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
}
}
@@ -139,8 +141,7 @@ public class ResourceGWTServiceImpl extends AbstractGWTServiceImpl implements Re
return SerialUtility.prepare(result, "ResourceService.findResourceCompositesByCriteria");
} catch (Exception e) {
- e.printStackTrace();
- throw new RuntimeException(e);
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
}
}
@@ -148,18 +149,21 @@ public class ResourceGWTServiceImpl extends AbstractGWTServiceImpl implements Re
* Criteria passed in not currently used.
*/
public List<DisambiguationReport<ProblemResourceComposite>> findProblemResources(long ctime, int maxItems) {
+ try {
+ List<ProblemResourceComposite> located = new ArrayList<ProblemResourceComposite>();
+ MeasurementProblemManagerLocal problemManager = LookupUtil.getMeasurementProblemManager();
+ ResourceManagerLocal resourceManager = LookupUtil.getResourceManager();
- List<ProblemResourceComposite> located = new ArrayList<ProblemResourceComposite>();
- MeasurementProblemManagerLocal problemManager = LookupUtil.getMeasurementProblemManager();
- ResourceManagerLocal resourceManager = LookupUtil.getResourceManager();
-
- //retrieve list of discovered problem resources. Grab all, live scrolling data
- located = problemManager.findProblemResources(getSessionSubject(), ctime, new PageControl(0, maxItems));
+ //retrieve list of discovered problem resources. Grab all, live scrolling data
+ located = problemManager.findProblemResources(getSessionSubject(), ctime, new PageControl(0, maxItems));
- //translate the returned problem resources to disambiguated links
- List<DisambiguationReport<ProblemResourceComposite>> translated = resourceManager.disambiguate(located,
- RESOURCE_ID_EXTRACTOR, DefaultDisambiguationUpdateStrategies.getDefault());
- return translated;
+ //translate the returned problem resources to disambiguated links
+ List<DisambiguationReport<ProblemResourceComposite>> translated = resourceManager.disambiguate(located,
+ RESOURCE_ID_EXTRACTOR, DefaultDisambiguationUpdateStrategies.getDefault());
+ return translated;
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
private static final IntExtractor<ProblemResourceComposite> RESOURCE_ID_EXTRACTOR = new IntExtractor<ProblemResourceComposite>() {
@@ -169,71 +173,112 @@ public class ResourceGWTServiceImpl extends AbstractGWTServiceImpl implements Re
};
public List<ResourceLineageComposite> getResourceLineageAndSiblings(int resourceId) {
- return SerialUtility.prepare(resourceManager.getResourceLineageAndSiblings(getSessionSubject(), resourceId),
- "ResourceService.getResourceLineageAndSiblings");
+ try {
+ return SerialUtility.prepare(
+ resourceManager.getResourceLineageAndSiblings(getSessionSubject(), resourceId),
+ "ResourceService.getResourceLineageAndSiblings");
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
public Resource getPlatformForResource(int resourceId) {
- return SerialUtility.prepare(resourceManager.getRootResourceForResource(resourceId),
- "ResourceService.getPlatformForResource");
+ try {
+ return SerialUtility.prepare(resourceManager.getRootResourceForResource(resourceId),
+ "ResourceService.getPlatformForResource");
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
public List<RecentlyAddedResourceComposite> findRecentlyAddedResources(long ctime, int maxItems) {
- List<RecentlyAddedResourceComposite> platforms = resourceManager.findRecentlyAddedPlatforms(
- getSessionSubject(), ctime, maxItems);
+ try {
+ List<RecentlyAddedResourceComposite> platforms = resourceManager.findRecentlyAddedPlatforms(
+ getSessionSubject(), ctime, maxItems);
- for (RecentlyAddedResourceComposite platform : platforms) {
- List<RecentlyAddedResourceComposite> servers = resourceManager.findRecentlyAddedServers(
- getSessionSubject(), ctime, platform.getId());
- platform.setChildren(servers);
- }
+ for (RecentlyAddedResourceComposite platform : platforms) {
+ List<RecentlyAddedResourceComposite> servers = resourceManager.findRecentlyAddedServers(
+ getSessionSubject(), ctime, platform.getId());
+ platform.setChildren(servers);
+ }
- return platforms;
+ return platforms;
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
public List<Integer> uninventoryResources(int[] resourceIds) {
- return SerialUtility.prepare(resourceManager.uninventoryResources(getSessionSubject(), resourceIds),
- "ResourceService.uninventoryResources");
+ try {
+ return SerialUtility.prepare(resourceManager.uninventoryResources(getSessionSubject(), resourceIds),
+ "ResourceService.uninventoryResources");
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
public void updateResource(Resource resource) {
- resourceManager.updateResource(getSessionSubject(), resource);
+ try {
+ resourceManager.updateResource(getSessionSubject(), resource);
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
public void createResource(int parentResourceId, int newResourceTypeId, String newResourceName,
Configuration newResourceConfiguration) {
+ try {
- ConfigurationDefinition pluginConfigDefinition = LookupUtil.getConfigurationManager()
- .getPluginConfigurationDefinitionForResourceType(getSessionSubject(), newResourceTypeId);
- Configuration pluginConfig = null;
- if (pluginConfigDefinition != null) {
- ConfigurationTemplate pluginConfigTemplate = pluginConfigDefinition.getDefaultTemplate();
- pluginConfig = (pluginConfigTemplate != null) ? pluginConfigTemplate.createConfiguration()
- : new Configuration();
+ ConfigurationDefinition pluginConfigDefinition = LookupUtil.getConfigurationManager()
+ .getPluginConfigurationDefinitionForResourceType(getSessionSubject(), newResourceTypeId);
+ Configuration pluginConfig = null;
+ if (pluginConfigDefinition != null) {
+ ConfigurationTemplate pluginConfigTemplate = pluginConfigDefinition.getDefaultTemplate();
+ pluginConfig = (pluginConfigTemplate != null) ? pluginConfigTemplate.createConfiguration()
+ : new Configuration();
- // TODO GH: Is this still necessary now that we don't blow up on non-normalized configs
- // ConfigurationUtility.normalizeConfiguration(pluginConfig, pluginConfigDefinition);
- }
+ // TODO GH: Is this still necessary now that we don't blow up on non-normalized configs
+ // ConfigurationUtility.normalizeConfiguration(pluginConfig, pluginConfigDefinition);
+ }
- resourceFactoryManager.createResource(getSessionSubject(), parentResourceId, newResourceTypeId,
- newResourceName, pluginConfig, newResourceConfiguration);
+ resourceFactoryManager.createResource(getSessionSubject(), parentResourceId, newResourceTypeId,
+ newResourceName, pluginConfig, newResourceConfiguration);
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
public Map<Resource, List<Resource>> getQueuedPlatformsAndServers(HashSet<InventoryStatus> statuses, PageControl pc) {
- return SerialUtility.prepare(discoveryBoss.getQueuedPlatformsAndServers(getSessionSubject(), EnumSet
- .copyOf(statuses), pc), "ResourceService.getQueuedPlatformsAndServers");
+ try {
+ return SerialUtility.prepare(discoveryBoss.getQueuedPlatformsAndServers(getSessionSubject(), EnumSet
+ .copyOf(statuses), pc), "ResourceService.getQueuedPlatformsAndServers");
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
public void importResources(Integer[] resourceIds) {
- discoveryBoss.importResources(getSessionSubject(), resourceIds);
+ try {
+ discoveryBoss.importResources(getSessionSubject(), resourceIds);
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
public void ignoreResources(Integer[] resourceIds) {
- discoveryBoss.ignoreResources(getSessionSubject(), resourceIds);
+ try {
+ discoveryBoss.ignoreResources(getSessionSubject(), resourceIds);
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
public void unignoreResources(Integer[] resourceIds) {
- discoveryBoss.unignoreResources(getSessionSubject(), resourceIds);
+ try {
+ discoveryBoss.unignoreResources(getSessionSubject(), resourceIds);
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceTypeGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceTypeGWTServiceImpl.java
index 6ff33b3..c74aa3c 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceTypeGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceTypeGWTServiceImpl.java
@@ -1,25 +1,28 @@
package org.rhq.enterprise.gui.coregui.server.gwt;
-import com.google.gwt.user.server.rpc.RemoteServiceServlet;
-
-import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.configuration.RawConfiguration;
import org.rhq.core.domain.criteria.ResourceTypeCriteria;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.util.PageList;
+import org.rhq.core.util.exception.ThrowableUtil;
import org.rhq.enterprise.gui.coregui.client.gwt.ResourceTypeGWTService;
import org.rhq.enterprise.gui.coregui.server.util.SerialUtility;
-import org.rhq.enterprise.server.auth.SubjectManagerLocal;
import org.rhq.enterprise.server.resource.ResourceTypeManagerLocal;
import org.rhq.enterprise.server.util.LookupUtil;
public class ResourceTypeGWTServiceImpl extends AbstractGWTServiceImpl implements ResourceTypeGWTService {
- public PageList<ResourceType> findResourceTypesByCriteria(ResourceTypeCriteria criteria) {
+ private static final long serialVersionUID = 1L;
- ResourceTypeManagerLocal typeManager = LookupUtil.getResourceTypeManager();
+ public PageList<ResourceType> findResourceTypesByCriteria(ResourceTypeCriteria criteria) {
+ try {
+ ResourceTypeManagerLocal typeManager = LookupUtil.getResourceTypeManager();
- return SerialUtility.prepare(typeManager.findResourceTypesByCriteria(getSessionSubject(), criteria), "ResourceTypes.findResourceTypesByCriteria");
+ return SerialUtility.prepare(typeManager.findResourceTypesByCriteria(getSessionSubject(), criteria),
+ "ResourceTypes.findResourceTypesByCriteria");
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
public RawConfiguration dummy(RawConfiguration config) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/RoleGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/RoleGWTServiceImpl.java
index 7b278e1..ed7e50d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/RoleGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/RoleGWTServiceImpl.java
@@ -21,6 +21,7 @@ package org.rhq.enterprise.gui.coregui.server.gwt;
import org.rhq.core.domain.authz.Role;
import org.rhq.core.domain.criteria.RoleCriteria;
import org.rhq.core.domain.util.PageList;
+import org.rhq.core.util.exception.ThrowableUtil;
import org.rhq.enterprise.gui.coregui.client.gwt.RoleGWTService;
import org.rhq.enterprise.gui.coregui.server.util.SerialUtility;
import org.rhq.enterprise.server.authz.RoleManagerLocal;
@@ -31,34 +32,64 @@ import org.rhq.enterprise.server.util.LookupUtil;
*/
public class RoleGWTServiceImpl extends AbstractGWTServiceImpl implements RoleGWTService {
+ private static final long serialVersionUID = 1L;
+
private RoleManagerLocal roleManager = LookupUtil.getRoleManager();
public PageList<Role> findRolesByCriteria(RoleCriteria criteria) {
- return SerialUtility.prepare(roleManager.findRolesByCriteria(getSessionSubject(), criteria),
- "RoleService.findRolesByCriteria");
+ try {
+ return SerialUtility.prepare(roleManager.findRolesByCriteria(getSessionSubject(), criteria),
+ "RoleService.findRolesByCriteria");
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
public Role createRole(Role role) {
- return SerialUtility.prepare(roleManager.createRole(getSessionSubject(), role), "RoleService.createRole");
+ try {
+ return SerialUtility.prepare(roleManager.createRole(getSessionSubject(), role), "RoleService.createRole");
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
public Role updateRole(Role role) {
- return SerialUtility.prepare(roleManager.updateRole(getSessionSubject(), role), "RoleService.updateRole");
+ try {
+ return SerialUtility.prepare(roleManager.updateRole(getSessionSubject(), role), "RoleService.updateRole");
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
public void removeRoles(Integer[] roleIds) {
- roleManager.deleteRoles(getSessionSubject(), roleIds);
+ try {
+ roleManager.deleteRoles(getSessionSubject(), roleIds);
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
public void setAssignedResourceGroups(int roleId, int[] resourceGroupIds) {
- roleManager.setAssignedResourceGroups(getSessionSubject(), roleId, resourceGroupIds);
+ try {
+ roleManager.setAssignedResourceGroups(getSessionSubject(), roleId, resourceGroupIds);
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
public void setAssignedSubjects(int roleId, int[] subjectIds) {
- roleManager.setAssignedSubjects(getSessionSubject(), roleId, subjectIds);
+ try {
+ roleManager.setAssignedSubjects(getSessionSubject(), roleId, subjectIds);
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
public void setAssignedRolesForSubject(int subjectId, int[] roleIds) {
- roleManager.setAssignedSubjectRoles(getSessionSubject(), subjectId, roleIds);
+ try {
+ roleManager.setAssignedSubjectRoles(getSessionSubject(), subjectId, roleIds);
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/SearchGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/SearchGWTServiceImpl.java
index cff798c..ae72b4c 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/SearchGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/SearchGWTServiceImpl.java
@@ -24,6 +24,7 @@ import org.rhq.core.domain.criteria.SavedSearchCriteria;
import org.rhq.core.domain.search.SavedSearch;
import org.rhq.core.domain.search.SearchSubsystem;
import org.rhq.core.domain.search.SearchSuggestion;
+import org.rhq.core.util.exception.ThrowableUtil;
import org.rhq.enterprise.gui.coregui.client.gwt.SearchGWTService;
import org.rhq.enterprise.gui.coregui.server.util.SerialUtility;
import org.rhq.enterprise.server.search.SavedSearchManagerLocal;
@@ -35,36 +36,62 @@ import org.rhq.enterprise.server.util.LookupUtil;
*/
public class SearchGWTServiceImpl extends AbstractGWTServiceImpl implements SearchGWTService {
+ private static final long serialVersionUID = 1L;
+
private SavedSearchManagerLocal savedSearchManager = LookupUtil.getSavedSearchManager();
public List<SearchSuggestion> getTabAwareSuggestions(SearchSubsystem searchSubsystem, String expression,
int caretPosition, String tab) {
- SearchAssistManager searchAssistManager = new SearchAssistManager(getSessionSubject(), searchSubsystem);
- List<SearchSuggestion> results = searchAssistManager.getTabAwareSuggestions(expression, caretPosition, tab);
- return results;
+ try {
+ SearchAssistManager searchAssistManager = new SearchAssistManager(getSessionSubject(), searchSubsystem);
+ List<SearchSuggestion> results = searchAssistManager.getTabAwareSuggestions(expression, caretPosition, tab);
+ return results;
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
public List<SearchSuggestion> getSuggestions(SearchSubsystem searchSubsystem, String expression, int caretPosition) {
- SearchAssistManager searchAssistManager = new SearchAssistManager(getSessionSubject(), searchSubsystem);
- List<SearchSuggestion> results = searchAssistManager.getSuggestions(expression, caretPosition);
- return results;
+ try {
+ SearchAssistManager searchAssistManager = new SearchAssistManager(getSessionSubject(), searchSubsystem);
+ List<SearchSuggestion> results = searchAssistManager.getSuggestions(expression, caretPosition);
+ return results;
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
public int createSavedSearch(SavedSearch savedSearch) {
- return savedSearchManager.createSavedSearch(getSessionSubject(), savedSearch);
+ try {
+ return savedSearchManager.createSavedSearch(getSessionSubject(), savedSearch);
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
public void updateSavedSearch(SavedSearch savedSearch) {
- savedSearchManager.updateSavedSearch(getSessionSubject(), savedSearch);
+ try {
+ savedSearchManager.updateSavedSearch(getSessionSubject(), savedSearch);
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
public void deleteSavedSearch(int savedSearchId) {
- savedSearchManager.deleteSavedSearch(getSessionSubject(), savedSearchId);
+ try {
+ savedSearchManager.deleteSavedSearch(getSessionSubject(), savedSearchId);
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
public List<SavedSearch> findSavedSearchesByCriteria(SavedSearchCriteria criteria) {
- return SerialUtility.prepare(savedSearchManager.findSavedSearchesByCriteria(getSessionSubject(), criteria),
- "SearchService.findRolesByCriteria");
+ try {
+ return SerialUtility.prepare(savedSearchManager.findSavedSearchesByCriteria(getSessionSubject(), criteria),
+ "SearchService.findRolesByCriteria");
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/SubjectGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/SubjectGWTServiceImpl.java
index 32e1d2c..6f86e45 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/SubjectGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/SubjectGWTServiceImpl.java
@@ -21,35 +21,53 @@ package org.rhq.enterprise.gui.coregui.server.gwt;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.criteria.SubjectCriteria;
import org.rhq.core.domain.util.PageList;
+import org.rhq.core.util.exception.ThrowableUtil;
import org.rhq.enterprise.gui.coregui.client.gwt.SubjectGWTService;
import org.rhq.enterprise.gui.coregui.server.util.SerialUtility;
import org.rhq.enterprise.server.auth.SubjectManagerLocal;
import org.rhq.enterprise.server.exception.LoginException;
import org.rhq.enterprise.server.util.LookupUtil;
-
/**
* @author Greg Hinkle
*/
public class SubjectGWTServiceImpl extends AbstractGWTServiceImpl implements SubjectGWTService {
+ private static final long serialVersionUID = 1L;
+
private SubjectManagerLocal subjectManager = LookupUtil.getSubjectManager();
public void changePassword(String username, String password) {
- subjectManager.changePassword(getSessionSubject(), username, password);
+ try {
+ subjectManager.changePassword(getSessionSubject(), username, password);
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
public void createPrincipal(String username, String password) {
- subjectManager.createPrincipal(getSessionSubject(), username, password);
+ try {
+ subjectManager.createPrincipal(getSessionSubject(), username, password);
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
public Subject createSubject(Subject subjectToCreate) {
- return SerialUtility.prepare(subjectManager.createSubject(getSessionSubject(), subjectToCreate),
+ try {
+ return SerialUtility.prepare(subjectManager.createSubject(getSessionSubject(), subjectToCreate),
"SubjectManager.createSubject");
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
public void deleteSubjects(int[] subjectIds) {
- subjectManager.deleteSubjects(getSessionSubject(),subjectIds);
+ try {
+ subjectManager.deleteSubjects(getSessionSubject(), subjectIds);
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
public Subject login(String username, String password) {
@@ -61,15 +79,28 @@ public class SubjectGWTServiceImpl extends AbstractGWTServiceImpl implements Sub
}
public void logout(Subject subject) {
- subjectManager.logout(subject.getSessionId());
+ try {
+ subjectManager.logout(subject.getSessionId());
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
public Subject updateSubject(Subject subjectToModify) {
- return SerialUtility.prepare(subjectManager.updateSubject(getSessionSubject(), subjectToModify),
+ try {
+ return SerialUtility.prepare(subjectManager.updateSubject(getSessionSubject(), subjectToModify),
"SubjectManager.updateSubject");
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
public PageList<Subject> findSubjectsByCriteria(SubjectCriteria criteria) {
- return SerialUtility.prepare(subjectManager.findSubjectsByCriteria(getSessionSubject(), criteria), "SubjectManager.findSubjectsByCriteria");
+ try {
+ return SerialUtility.prepare(subjectManager.findSubjectsByCriteria(getSessionSubject(), criteria),
+ "SubjectManager.findSubjectsByCriteria");
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/SystemGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/SystemGWTServiceImpl.java
index af12a6a..43431c7 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/SystemGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/SystemGWTServiceImpl.java
@@ -19,6 +19,7 @@
package org.rhq.enterprise.gui.coregui.server.gwt;
import org.rhq.core.domain.common.ProductInfo;
+import org.rhq.core.util.exception.ThrowableUtil;
import org.rhq.enterprise.gui.coregui.client.gwt.SystemGWTService;
import org.rhq.enterprise.server.system.SystemManagerLocal;
import org.rhq.enterprise.server.util.LookupUtil;
@@ -27,9 +28,16 @@ import org.rhq.enterprise.server.util.LookupUtil;
* @author Ian Springer
*/
public class SystemGWTServiceImpl extends AbstractGWTServiceImpl implements SystemGWTService {
+
+ private static final long serialVersionUID = 1L;
+
private SystemManagerLocal systemManager = LookupUtil.getSystemManager();
public ProductInfo getProductInfo() {
- return this.systemManager.getProductInfo(getSessionSubject());
+ try {
+ return this.systemManager.getProductInfo(getSessionSubject());
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/TagGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/TagGWTServiceImpl.java
index 20add85..7ab6941 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/TagGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/TagGWTServiceImpl.java
@@ -28,6 +28,7 @@ import org.rhq.core.domain.criteria.TagCriteria;
import org.rhq.core.domain.tagging.Tag;
import org.rhq.core.domain.tagging.compsite.TagReportComposite;
import org.rhq.core.domain.util.PageList;
+import org.rhq.core.util.exception.ThrowableUtil;
import org.rhq.enterprise.gui.coregui.client.gwt.TagGWTService;
import org.rhq.enterprise.gui.coregui.server.util.SerialUtility;
import org.rhq.enterprise.server.tagging.TagManagerLocal;
@@ -38,49 +39,90 @@ import org.rhq.enterprise.server.util.LookupUtil;
*/
public class TagGWTServiceImpl extends AbstractGWTServiceImpl implements TagGWTService {
+ private static final long serialVersionUID = 1L;
+
private TagManagerLocal tagManager = LookupUtil.getTagManager();
public PageList<Tag> findTagsByCriteria(TagCriteria tagCriteria) {
- return SerialUtility.prepare(tagManager.findTagsByCriteria(getSessionSubject(), tagCriteria),
+ try {
+ return SerialUtility.prepare(tagManager.findTagsByCriteria(getSessionSubject(), tagCriteria),
"TagService.findTagsByCriteria");
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
public Set<Tag> addTags(Set<Tag> tags) {
- return SerialUtility.prepare(
- tagManager.addTags(getSessionSubject(), tags),
- "TagService.addTags");
+ try {
+ return SerialUtility.prepare(tagManager.addTags(getSessionSubject(), tags), "TagService.addTags");
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
public void removeTags(Set<Tag> tags) {
- tagManager.removeTags(getSessionSubject(), tags);
+ try {
+ tagManager.removeTags(getSessionSubject(), tags);
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
public void updateResourceTags(int resourceId, Set<Tag> tags) {
- tagManager.updateResourceTags(getSessionSubject(), resourceId, tags);
+ try {
+ tagManager.updateResourceTags(getSessionSubject(), resourceId, tags);
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
public void updateResourceGroupTags(int resourceGroupId, Set<Tag> tags) {
- tagManager.updateResourceGroupTags(getSessionSubject(), resourceGroupId, tags);
+ try {
+ tagManager.updateResourceGroupTags(getSessionSubject(), resourceGroupId, tags);
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
public void updateBundleTags(int bundleId, Set<Tag> tags) {
- tagManager.updateBundleTags(getSessionSubject(), bundleId, tags);
+ try {
+ tagManager.updateBundleTags(getSessionSubject(), bundleId, tags);
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
public void updateBundleVersionTags(int bundleVersionId, Set<Tag> tags) {
- tagManager.updateBundleVersionTags(getSessionSubject(), bundleVersionId, tags);
+ try {
+ tagManager.updateBundleVersionTags(getSessionSubject(), bundleVersionId, tags);
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
public void updateBundleDeploymentTags(int bundleDeploymentId, Set<Tag> tags) {
- tagManager.updateBundleDeploymentTags(getSessionSubject(), bundleDeploymentId, tags);
+ try {
+ tagManager.updateBundleDeploymentTags(getSessionSubject(), bundleDeploymentId, tags);
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
public void updateBundleDestinationTags(int bundleDestinationId, Set<Tag> tags) {
- tagManager.updateBundleDestinationTags(getSessionSubject(), bundleDestinationId, tags);
+ try {
+ tagManager.updateBundleDestinationTags(getSessionSubject(), bundleDestinationId, tags);
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
public PageList<TagReportComposite> findTagReportCompositesByCriteria(TagCriteria tagCriteria) {
- return SerialUtility.prepare(tagManager.findTagReportCompositesByCriteria(getSessionSubject(), tagCriteria),
+ try {
+ return SerialUtility.prepare(
+ tagManager.findTagReportCompositesByCriteria(getSessionSubject(), tagCriteria),
"TagService.findTagReportCompositesByCriteria");
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
}
}
13 years, 8 months
[rhq] 2 commits - modules/core modules/enterprise
by Jay Shaughnessy
modules/core/dbutils/pom.xml | 2
modules/core/dbutils/src/main/scripts/dbsetup-build.xml | 2
modules/core/dbutils/src/main/scripts/dbsetup/auth-schema.xml | 19 +
modules/core/dbutils/src/main/scripts/dbsetup/authz-schema.xml | 19 -
modules/core/dbutils/src/main/scripts/dbsetup/inventory-schema.xml | 5
modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml | 16
modules/core/domain/src/main/java/org/rhq/core/domain/auth/Subject.java | 16
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceGroupCriteria.java | 23 +
modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceLineageComposite.java | 51 ++
modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/ResourceGroup.java | 26 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java | 11
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGWTService.java | 5
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGroupGWTService.java | 8
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/AbstractTwoLevelTabSetView.java | 5
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java | 12
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/CustomResourceTreeGrid.java | 17
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java | 44 --
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java | 171 +++++-----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java | 10
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java | 11
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SubjectManagerBean.java | 26 +
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/AuthorizationManagerBean.java | 36 +-
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java | 80 +++-
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerLocal.java | 9
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java | 77 +++-
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerLocal.java | 27 +
26 files changed, 526 insertions(+), 202 deletions(-)
New commits:
commit 4027a3a94c8399ce08485df9043a4386f668cf2b
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Oct 1 09:57:45 2010 -0400
ResourceTree Authz work
- support for locked nodes
- support for autogroups for non-inventory managers. Now that AGs are
backed by compat groups it's necessary for non-inv-managers
to be able to create and access the private groups that they own. Private
groups (aka subject-owned groups) are new, they are basically groups
that are tagged with the creating subjectId. Those groups can be
created (via a new slsb call) and fetched (via a new ResourceGroupCriteria
filter) w/o inventory manager perms.
- note: i had to move rhq_subject to auth-schema from authz-schema and
slightly change the dbsetup order to make it ok for rhq_resource_group to
reference rhq_subject.
- schema spec bumped to 2.97
- added ResourceLineageComposite to combine Resource and locked/viewable
info.
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index 02aa606..4035ed5 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.96</db.schema.version>
+ <db.schema.version>2.97</db.schema.version>
</properties>
<dependencies>
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup-build.xml b/modules/core/dbutils/src/main/scripts/dbsetup-build.xml
index f4993e5..b0ee520 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup-build.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup-build.xml
@@ -39,7 +39,7 @@ To run the default target, you must set one of the following properties to true:
<property name="dbsetup.scripts.dir" value="${basedir}/src/main/scripts/dbsetup" />
<property name="dbsetup.output.dir" value="${basedir}/target/dbsetup" /> <!-- away from classes so it doesn't go into the jar -->
<!-- define the setup creation processing order. note, removals are done in the reverse order -->
- <property name="dbsetup.subsystems" value="config,cluster,inventory,auth,authz,search,dashboard,operation,event,alert,sysconfig,scheduler,amps,measurement,content,resource-request,jms,obsolete"/>
+ <property name="dbsetup.subsystems" value="config,cluster,auth,inventory,authz,search,dashboard,operation,event,alert,sysconfig,scheduler,amps,measurement,content,resource-request,jms,obsolete"/>
<property name="dbsetup.combined.schema" value="${dbsetup.output.dir}/all-schema.xml" />
<property name="dbsetup.combined.data" value="${dbsetup.output.dir}/all-data.xml" />
<property name="dbsetup.tstamp.file" value="${dbsetup.output.dir}/dbsetup-combine.tstamp" />
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/auth-schema.xml b/modules/core/dbutils/src/main/scripts/dbsetup/auth-schema.xml
index d24b386..9b77256 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/auth-schema.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/auth-schema.xml
@@ -16,5 +16,24 @@
</index>
</table>
+
+ <table name="RHQ_SUBJECT">
+ <column name="ID" default="sequence-only" initial="10001"
+ primarykey="true" required="true" type="INTEGER"/>
+ <column name="NAME" required="true" size="100" type="VARCHAR2"/>
+ <column name="CONFIGURATION_ID" type="INTEGER" references="RHQ_CONFIG"/>
+ <column name="FIRST_NAME" required="false" size="100" type="VARCHAR2"/>
+ <column name="LAST_NAME" required="false" size="100" type="VARCHAR2"/>
+ <column name="EMAIL_ADDRESS" size="100" type="VARCHAR2"/>
+ <column name="SMS_ADDRESS" size="100" type="VARCHAR2"/>
+ <column name="PHONE_NUMBER" size="100" type="VARCHAR2"/>
+ <column name="DEPARTMENT" size="100" type="VARCHAR2"/>
+ <column name="FACTIVE" required="true" type="BOOLEAN" default="true"/>
+ <column name="FSYSTEM" required="true" type="BOOLEAN" default="false"/>
+
+ <index name="RHQ_SUBJECT_AUTH_KEY" unique="true">
+ <field ref="NAME"/>
+ </index>
+ </table>
</dbsetup>
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/authz-schema.xml b/modules/core/dbutils/src/main/scripts/dbsetup/authz-schema.xml
index 8d9f738..b1385e9 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/authz-schema.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/authz-schema.xml
@@ -50,25 +50,6 @@
</constraint>
</table>
- <table name="RHQ_SUBJECT">
- <column name="ID" default="sequence-only" initial="10001"
- primarykey="true" required="true" type="INTEGER"/>
- <column name="NAME" required="true" size="100" type="VARCHAR2"/>
- <column name="CONFIGURATION_ID" type="INTEGER" references="RHQ_CONFIG"/>
- <column name="FIRST_NAME" required="false" size="100" type="VARCHAR2"/>
- <column name="LAST_NAME" required="false" size="100" type="VARCHAR2"/>
- <column name="EMAIL_ADDRESS" size="100" type="VARCHAR2"/>
- <column name="SMS_ADDRESS" size="100" type="VARCHAR2"/>
- <column name="PHONE_NUMBER" size="100" type="VARCHAR2"/>
- <column name="DEPARTMENT" size="100" type="VARCHAR2"/>
- <column name="FACTIVE" required="true" type="BOOLEAN" default="true"/>
- <column name="FSYSTEM" required="true" type="BOOLEAN" default="false"/>
-
- <index name="RHQ_SUBJECT_AUTH_KEY" unique="true">
- <field ref="NAME"/>
- </index>
- </table>
-
<table name="RHQ_SUBJECT_ROLE_MAP">
<column name="SUBJECT_ID" required="true" type="INTEGER" references="RHQ_SUBJECT"/>
<column name="ROLE_ID" required="true" type="INTEGER" references="RHQ_ROLE"/>
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 6246880..5d89c2d 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,14 @@
<column name="CATEGORY" type="VARCHAR2" size="20" required="true"/>
+ <!-- This is only set if this is a subject-owned group (like an autogroup) -->
+ <column name="SUBJECT_ID" type="INTEGER" references="RHQ_SUBJECT"/>
+
<!-- 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"/>
<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 -->
+ <!-- This is 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"/>
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 f0940ab..b477b09 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -3226,9 +3226,21 @@
REFERENCES RHQ_RESOURCE (ID)
</statement>
</schema-directSQL>
-
</schemaSpec>
-
+
+ <schemaSpec version="2.97">
+ <!-- Support subject-owned groups (e.g. autogroups) -->
+ <schema-addColumn table="RHQ_RESOURCE_GROUP" column="SUBJECT_ID" columnType="INTEGER" />
+ <schema-directSQL>
+ <statement desc="Creating RHQ_RESOURCE_GROUP foreign key relation to RHQ_SUBJECT for owned groups">
+ ALTER TABLE RHQ_RESOURCE_GROUP
+ ADD CONSTRAINT RHQ_RG_SUBJECT_ID_FK
+ FOREIGN KEY (SUBJECT_ID)
+ REFERENCES RHQ_SUBJECT (ID)
+ </statement>
+ </schema-directSQL>
+ </schemaSpec>
+
</dbupgrade>
</target>
</project>
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/auth/Subject.java b/modules/core/domain/src/main/java/org/rhq/core/domain/auth/Subject.java
index 477a128..4a93c1f 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/auth/Subject.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/auth/Subject.java
@@ -24,11 +24,13 @@ package org.rhq.core.domain.auth;
import java.io.Serializable;
import java.util.HashSet;
+import java.util.List;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
+import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
@@ -37,6 +39,7 @@ import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
+import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.QueryHint;
import javax.persistence.SequenceGenerator;
@@ -47,6 +50,7 @@ import org.jetbrains.annotations.NotNull;
import org.rhq.core.domain.authz.Role;
import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.resource.group.ResourceGroup;
import org.rhq.core.domain.util.Recordizable;
/**
@@ -271,6 +275,10 @@ public class Subject implements Serializable, Recordizable {
@ManyToMany
private java.util.Set<Role> ldapRoles;
+ // When a subject is removed any owned groups should also be removed
+ @OneToMany(mappedBy = "subject", fetch = FetchType.LAZY)
+ private List<ResourceGroup> ownedGroups = null;
+
@Transient
private Integer sessionId = null;
@@ -448,6 +456,14 @@ public class Subject implements Serializable, Recordizable {
getLdapRoles().remove(role);
}
+ public List<ResourceGroup> getOwnedGroups() {
+ return ownedGroups;
+ }
+
+ public void setOwnedGroups(List<ResourceGroup> ownedGroups) {
+ this.ownedGroups = ownedGroups;
+ }
+
@Override
public String toString() {
return "org.rhq.core.domain.auth.Subject[id=" + id + ",name=" + name + "]";
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 2278c7f..835821a 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
@@ -46,6 +46,7 @@ public class ResourceGroupCriteria extends TaggedCriteria {
private Boolean filterRecursive;
private Integer filterResourceTypeId; // requires overrides
private String filterResourceTypeName; // requires overrides
+ private Integer filterSubjectId; // requires overrides
private Integer filterAutoGroupParentResourceId; // requires overrides
private String filterPluginName; // requires overrides
private GroupCategory filterGroupCategory;
@@ -56,6 +57,7 @@ public class ResourceGroupCriteria extends TaggedCriteria {
private Integer filterExplicitResourceTypeId; // requires overrides
private String filterExplicitResourceTypeName; // requires overrides
private Integer filterGroupDefinitionId; // requires overrides
+ private Boolean filterPrivate; /* if true, show only private groups for the calling user */
private Boolean filterVisible = true; /* only show visible groups by default */
private boolean fetchExplicitResources;
@@ -74,6 +76,7 @@ public class ResourceGroupCriteria extends TaggedCriteria {
filterOverrides.put("resourceTypeId", "resourceType.id = ?");
filterOverrides.put("resourceTypeName", "resourceType.name like ?");
filterOverrides.put("autoGroupParentResourceId", "autoGroupParentResource.id = ?");
+ filterOverrides.put("subjectId", "subject.id = ?");
filterOverrides.put("pluginName", "resourceType.plugin like ?");
filterOverrides.put("downMemberCount", "" //
+ "id IN ( SELECT implicitGroup.id " //
@@ -148,6 +151,14 @@ public class ResourceGroupCriteria extends TaggedCriteria {
this.filterResourceTypeName = filterResourceTypeName;
}
+ /**
+ * Requires MANAGE_INVENTORY. Use addFilterPrivate(true) to filter on the caller's private groups.
+ * @param filterSubjectId.
+ */
+ public void addFilterSubjectId(Integer filterSubjectId) {
+ this.filterSubjectId = filterSubjectId;
+ }
+
public void addFilterAutoGroupParentResourceId(Integer filterAutoGroupParentResourceId) {
this.filterAutoGroupParentResourceId = filterAutoGroupParentResourceId;
}
@@ -199,6 +210,14 @@ public class ResourceGroupCriteria extends TaggedCriteria {
this.filterGroupDefinitionId = filterGroupDefinitionId;
}
+ public void addFilterPrivate(Boolean filterPrivate) {
+ this.filterPrivate = filterPrivate;
+ }
+
+ public boolean isFilterPrivate() {
+ return (Boolean.TRUE.equals(this.filterPrivate));
+ }
+
public void addFilterVisible(Boolean filterVisible) {
this.filterVisible = filterVisible;
}
@@ -258,8 +277,8 @@ public class ResourceGroupCriteria extends TaggedCriteria {
@Override
public boolean isInventoryManagerRequired() {
- // presently only inventory managers can view/manage group definitions
- return this.filterGroupDefinitionId != null;
+ // presently only inventory managers can view/manage group definitions or see other user's private groups
+ return this.filterGroupDefinitionId != null || this.filterSubjectId != null;
}
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceLineageComposite.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceLineageComposite.java
new file mode 100644
index 0000000..713a558
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceLineageComposite.java
@@ -0,0 +1,51 @@
+/*
+ * 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.core.domain.resource.composite;
+
+import java.io.Serializable;
+
+import org.rhq.core.domain.resource.Resource;
+
+/**
+ * @author jay shaughnessy
+ */
+public class ResourceLineageComposite implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ private Resource resource;
+ private boolean isLocked;
+
+ // for gwt serialization
+ @SuppressWarnings("unused")
+ private ResourceLineageComposite() {
+ }
+
+ public ResourceLineageComposite(Resource resource, boolean isLocked) {
+ this.resource = resource;
+ this.isLocked = isLocked;
+ }
+
+ public Resource getResource() {
+ return resource;
+ }
+
+ public boolean isLocked() {
+ return isLocked;
+ }
+}
\ No newline at end of file
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 46d6bcb..5250c11 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
@@ -55,6 +55,7 @@ import javax.xml.bind.annotation.XmlAccessorType;
import org.jetbrains.annotations.NotNull;
import org.rhq.core.domain.alert.AlertDefinition;
+import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.authz.Role;
import org.rhq.core.domain.bundle.BundleDestination;
import org.rhq.core.domain.configuration.group.AbstractGroupConfigurationUpdate;
@@ -432,6 +433,12 @@ public class ResourceGroup extends Group {
@ManyToOne
private ResourceType resourceType; // if non-null, it implies a compatible group
+ // The group owner. Certain groups (like autogroups) are not associated with Roles. Instead, they
+ // are bound to specific owners. Subject-Owned groups defer to member-level authorization as needed.
+ @JoinColumn(name = "SUBJECT_ID", referencedColumnName = "ID", nullable = true)
+ @ManyToOne
+ private Subject subject = null;
+
@Column(name = "CLUSTER_KEY", nullable = true)
private String clusterKey;
@@ -612,6 +619,25 @@ public class ResourceGroup extends Group {
}
}
+ public Subject getSubject() {
+ return subject;
+ }
+
+ public void setSubject(Subject subject) {
+ if (this.id > 0 && null != this.subject) {
+ throw new IllegalStateException("The group owner can not be changed after the group is created.");
+ }
+
+ this.subject = subject;
+ }
+
+ /**
+ * @return true if this is a subject-owned group, private to the set subject
+ */
+ public boolean isPrivateGroup() {
+ return (null != this.subject);
+ }
+
public String getClusterKey() {
return clusterKey;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGWTService.java
index b282e41..7ad683a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGWTService.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGWTService.java
@@ -32,6 +32,7 @@ import org.rhq.core.domain.resource.composite.DisambiguationReport;
import org.rhq.core.domain.resource.composite.ProblemResourceComposite;
import org.rhq.core.domain.resource.composite.RecentlyAddedResourceComposite;
import org.rhq.core.domain.resource.composite.ResourceComposite;
+import org.rhq.core.domain.resource.composite.ResourceLineageComposite;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
@@ -44,9 +45,7 @@ public interface ResourceGWTService extends RemoteService {
PageList<ResourceComposite> findResourceCompositesByCriteria(ResourceCriteria criteria);
- List<Resource> getResourceLineage(int resourceId);
-
- List<Resource> getResourceLineageAndSiblings(int resourceId);
+ List<ResourceLineageComposite> getResourceLineageAndSiblings(int resourceId);
List<RecentlyAddedResourceComposite> findRecentlyAddedResources(long ctime, int maxItems);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGroupGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGroupGWTService.java
index d968e19..f48fd96 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGroupGWTService.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGroupGWTService.java
@@ -37,6 +37,14 @@ public interface ResourceGroupGWTService extends RemoteService {
GroupDefinition createGroupDefinition(GroupDefinition groupDefinition);
+ /**
+ * The owner will be set to the session subject.
+ * @param group
+ * @param resourceIds initial members
+ * @return
+ */
+ ResourceGroup createPrivateResourceGroup(ResourceGroup group, int[] resourceIds);
+
ResourceGroup createResourceGroup(ResourceGroup group, int[] resourceIds);
void deleteGroupDefinitions(int[] groupDefinitionIds);
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 50700f2..33b22e9 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
@@ -243,4 +243,9 @@ public abstract class AbstractTwoLevelTabSetView<T, U extends Layout> extends Lo
public String getSubTabName() {
return subTabName;
}
+
+ public String getBaseViewPath() {
+ return baseViewPath;
+ }
+
}
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 be66cb9..8d8db75 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
@@ -270,7 +270,12 @@ public class ResourceGroupDetailView extends AbstractTwoLevelTabSetView<Resource
ResourceGroupCriteria criteria = new ResourceGroupCriteria();
criteria.addFilterId(groupId);
- criteria.addFilterVisible(null);
+
+ // for autogroups we need to add more criteria
+ if (AUTO_GROUP_VIEW_PATH.equals(getBaseViewPath())) {
+ criteria.addFilterVisible(null);
+ criteria.addFilterPrivate(true);
+ }
GWTServiceLookup.getResourceGroupService().findResourceGroupCompositesByCriteria(criteria,
new AsyncCallback<PageList<ResourceGroupComposite>>() {
@@ -280,6 +285,11 @@ public class ResourceGroupDetailView extends AbstractTwoLevelTabSetView<Resource
}
public void onSuccess(PageList<ResourceGroupComposite> result) {
+ if (result.isEmpty()) {
+ CoreGUI.getErrorHandler().handleError(
+ "Failed to load group composite for group with id " + groupId);
+ }
+
groupComposite = result.get(0);
loadResourceType(groupComposite, viewPath, globalPermissions);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/CustomResourceTreeGrid.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/CustomResourceTreeGrid.java
index 71e6c61..f1dad07 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/CustomResourceTreeGrid.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/CustomResourceTreeGrid.java
@@ -23,6 +23,7 @@ import com.smartgwt.client.widgets.tree.TreeNode;
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.domain.resource.Resource;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.ResourceTreeDatasource.ResourceTreeNode;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableTreeGrid;
/**
@@ -40,15 +41,19 @@ public class CustomResourceTreeGrid extends LocatableTreeGrid {
if (record instanceof TreeNode) {
boolean open = getTree().isOpen((TreeNode) record);
- if (record instanceof ResourceTreeDatasource.ResourceTreeNode) {
- Resource resource = ((ResourceTreeDatasource.ResourceTreeNode) record).getResource();
+ if (record instanceof ResourceTreeNode) {
+ ResourceTreeNode node = (ResourceTreeNode) record;
- boolean up = resource.getCurrentAvailability().getAvailabilityType() == AvailabilityType.UP;
+ if (node.isLocked()) {
+ return "global/Locked_16.png";
- String category = resource.getResourceType().getCategory().getDisplayName();
-
- return "types/" + category + "_" + (up ? "up" : "down") + "_16.png";
+ } else {
+ Resource resource = ((ResourceTreeDatasource.ResourceTreeNode) record).getResource();
+ String category = resource.getResourceType().getCategory().getDisplayName();
+ boolean up = resource.getCurrentAvailability().getAvailabilityType() == AvailabilityType.UP;
+ return "types/" + category + "_" + (up ? "up" : "down") + "_16.png";
+ }
} else {
return "resources/folder_group_" + (open ? "opened" : "closed") + ".png";
}
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 e577491..1c73198 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
@@ -30,7 +30,6 @@ 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;
@@ -38,8 +37,6 @@ 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.measurement.ResourceAvailability;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceCategory;
import org.rhq.core.domain.resource.ResourceSubCategory;
@@ -61,15 +58,17 @@ import org.rhq.enterprise.gui.coregui.client.util.StringUtility;
*/
public class ResourceTreeDatasource extends DataSource {
private List<Resource> initialData;
+ private List<Resource> lockedData;
private ResourceGWTServiceAsync resourceService = GWTServiceLookup.getResourceService();
- public ResourceTreeDatasource(List<Resource> initialData) {
+ public ResourceTreeDatasource(List<Resource> initialData, List<Resource> lockedData) {
setClientOnly(false);
setDataProtocol(DSProtocol.CLIENTCUSTOM);
setDataFormat(DSDataFormat.CUSTOM);
this.initialData = initialData;
+ this.lockedData = (null != lockedData) ? lockedData : new ArrayList<Resource>();
DataSourceField idDataField = new DataSourceTextField("id", "ID");
idDataField.setPrimaryKey(true);
@@ -80,22 +79,12 @@ public class ResourceTreeDatasource extends DataSource {
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);
+ setFields(idDataField, nameDataField, descriptionDataField);
}
@Override
@@ -127,7 +116,7 @@ public class ResourceTreeDatasource extends DataSource {
}
public void executeFetch(final String requestId, final DSRequest request, final DSResponse response) {
- final long start = System.currentTimeMillis();
+ //final long start = System.currentTimeMillis();
String parentResourceId = request.getCriteria().getAttribute("parentId");
// System.out.println("All attributes: " + Arrays.toString(request.getCriteria().getAttributes()));
@@ -173,7 +162,7 @@ public class ResourceTreeDatasource extends DataSource {
ResourceTypeRepository.MetadataType.subCategory),
new ResourceTypeRepository.ResourceTypeLoadedCallback() {
public void onResourceTypeLoaded(List<Resource> result) {
- TreeNode[] treeNodes = buildNodes(result);
+ TreeNode[] treeNodes = buildNodes(result, lockedData);
response.setData(treeNodes);
processResponse(requestId, response);
response.setStatus(DSResponse.STATUS_SUCCESS);
@@ -187,11 +176,11 @@ public class ResourceTreeDatasource extends DataSource {
* @param resources
* @return
*/
- public static TreeNode[] buildNodes(List<Resource> resources) {
+ public static TreeNode[] buildNodes(List<Resource> resources, List<Resource> lockedData) {
ResourceTreeNode[] nodes = new ResourceTreeNode[resources.size()];
for (int i = 0; i < resources.size(); i++) {
Resource resource = resources.get(i);
- ResourceTreeNode node = new ResourceTreeNode(resource);
+ ResourceTreeNode node = new ResourceTreeNode(resource, lockedData.contains(resource));
nodes[i] = node;
}
@@ -352,9 +341,11 @@ public class ResourceTreeDatasource extends DataSource {
public static class ResourceTreeNode extends EnhancedTreeNode {
private Resource resource;
+ private boolean isLocked;
- private ResourceTreeNode(Resource resource) {
+ private ResourceTreeNode(Resource resource, boolean isLocked) {
this.resource = resource;
+ this.isLocked = isLocked;
String id = idOf(resource);
setID(id);
@@ -371,21 +362,12 @@ public class ResourceTreeDatasource extends DataSource {
setParentID(parentId);
setAttribute(Attributes.PARENT_ID, parentId);
- // System.out.println(id + " / " + parentId);
- // setAttribute("parentKey", resource.getParentResource() == null ? 0 : (resource.getParentResource().getId() + resource.getResourceType().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");
-
Set<ResourceType> childTypes = resource.getResourceType().getChildResourceTypes();
setIsFolder((childTypes != null && !childTypes.isEmpty()));
}
@@ -394,6 +376,10 @@ public class ResourceTreeDatasource extends DataSource {
return this.resource;
}
+ public boolean isLocked() {
+ return isLocked;
+ }
+
public static String idOf(Resource resource) {
return idOf(resource.getId());
}
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 0d16bea..4cea21b 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
@@ -63,6 +63,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.composite.ResourceLineageComposite;
import org.rhq.core.domain.resource.group.ResourceGroup;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.Breadcrumb;
@@ -142,14 +143,20 @@ public class ResourceTreeView extends LocatableVLayout {
if (!selectionEvent.isRightButtonDown() && selectionEvent.getState()) {
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);
+
+ if (!resourceNode.isLocked()) {
+ System.out.println("Resource Node selected in tree: " + selectedRecord);
+
+ selectedNodeId = resourceNode.getID();
+ String viewPath = "Resource/" + resourceNode.getResource().getId();
+ String currentViewPath = History.getToken();
+ if (!currentViewPath.startsWith(viewPath)) {
+ CoreGUI.goToView(viewPath);
+ }
+ } else {
+ // TODO: Can we select the previous node? Or do we need a "Locked" hover etc...
+ treeGrid.deselectAllRecords();
}
} else if (selectedRecord instanceof AutoGroupTreeNode) {
System.out.println("AutoGroup Node selected in tree: " + selectedRecord);
@@ -183,7 +190,9 @@ public class ResourceTreeView extends LocatableVLayout {
if (event.getNode() instanceof AutoGroupTreeNode) {
showContextMenu((AutoGroupTreeNode) event.getNode());
} else if (event.getNode() instanceof ResourceTreeNode) {
- showContextMenu((ResourceTreeNode) event.getNode());
+ if (!((ResourceTreeNode) event.getNode()).isLocked()) {
+ showContextMenu((ResourceTreeNode) event.getNode());
+ }
}
}
});
@@ -207,6 +216,7 @@ public class ResourceTreeView extends LocatableVLayout {
// get the backing group if it exists, otherwise create the group
ResourceGroupCriteria criteria = new ResourceGroupCriteria();
+ criteria.addFilterPrivate(true);
criteria.addFilterResourceTypeId(agNode.getResourceType().getId());
criteria.addFilterAutoGroupParentResourceId(agNode.getParentResource().getId());
criteria.addFilterVisible(false);
@@ -224,8 +234,7 @@ public class ResourceTreeView extends LocatableVLayout {
backingGroup.setAutoGroupParentResource(agNode.getParentResource());
backingGroup.setResourceType(agNode.getResourceType());
backingGroup.setVisible(false);
- backingGroup.setRecursive(false);
- resourceGroupService.createResourceGroup(backingGroup, childIds,
+ resourceGroupService.createPrivateResourceGroup(backingGroup, childIds,
new AsyncCallback<ResourceGroup>() {
public void onFailure(Throwable caught) {
CoreGUI.getErrorHandler().handleError("Failed to create resource autogroup", caught);
@@ -596,65 +605,79 @@ public class ResourceTreeView extends LocatableVLayout {
selectedNodeId = ResourceTreeNode.idOf(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);
+ // 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<ResourceLineageComposite>>() {
- if (!root.equals(ResourceTreeView.this.rootResource)) {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to lookup platform for tree", caught);
+ }
- if (treeGrid != null) {
- treeGrid.destroy();
- }
- buildTree();
+ public void onSuccess(List<ResourceLineageComposite> result) {
+ Resource root = result.get(0).getResource();
- setRootResource(root);
+ final List<Resource> lineage = new ArrayList<Resource>(result.size());
+ final List<Resource> lockedData = new ArrayList<Resource>();
- // seed datasource with initial resource list
- ResourceTreeDatasource dataSource = new ResourceTreeDatasource(result);
- treeGrid.setDataSource(dataSource);
+ for (ResourceLineageComposite r : result) {
+ lineage.add(r.getResource());
+ if (r.isLocked()) {
+ lockedData.add(r.getResource());
+ }
+ }
- addMember(treeGrid);
+ if (!root.equals(ResourceTreeView.this.rootResource)) {
- treeGrid.fetchData(treeGrid.getCriteria(), new DSCallback() {
- public void execute(DSResponse response, Object rawData, DSRequest request) {
- System.out.println("Done fetching data for tree.");
- updateSelection();
+ if (treeGrid != null) {
+ treeGrid.destroy();
}
- });
+ buildTree();
- updateSelection();
+ setRootResource(root);
- } 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));
- }
+ // seed datasource with initial resource list and which ancestor resources are locked
+ ResourceTreeDatasource dataSource = new ResourceTreeDatasource(lineage, lockedData);
+ treeGrid.setDataSource(dataSource);
+ addMember(treeGrid);
+
+ treeGrid.fetchData(treeGrid.getCriteria(), new DSCallback() {
+ public void execute(DSResponse response, Object rawData, DSRequest request) {
+ System.out.println("Done fetching data for tree.");
+ updateSelection();
}
});
+ updateSelection();
+
+ } else {
+ ResourceTypeRepository.Cache.getInstance().loadResourceTypes(
+ lineage,
+ 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(lineage, lockedData));
+
+ 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));
+ }
+
+ }
+ });
+
+ }
}
- }
- });
+ });
}
public void setSelectedAutoGroup(final Integer selectedAutoGroupId) {
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 66a25be..2e2f6d6 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
@@ -39,6 +39,7 @@ import org.rhq.core.domain.resource.composite.DisambiguationReport;
import org.rhq.core.domain.resource.composite.ProblemResourceComposite;
import org.rhq.core.domain.resource.composite.RecentlyAddedResourceComposite;
import org.rhq.core.domain.resource.composite.ResourceComposite;
+import org.rhq.core.domain.resource.composite.ResourceLineageComposite;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.util.IntExtractor;
@@ -167,13 +168,8 @@ public class ResourceGWTServiceImpl extends AbstractGWTServiceImpl implements Re
}
};
- public List<Resource> getResourceLineage(int resourceId) {
- return SerialUtility.prepare(resourceManager.getResourceLineage(resourceId),
- "ResourceService.getResourceLineage");
- }
-
- public List<Resource> getResourceLineageAndSiblings(int resourceId) {
- return SerialUtility.prepare(resourceManager.getResourceLineageAndSiblings(resourceId),
+ public List<ResourceLineageComposite> getResourceLineageAndSiblings(int resourceId) {
+ return SerialUtility.prepare(resourceManager.getResourceLineageAndSiblings(getSessionSubject(), resourceId),
"ResourceService.getResourceLineageAndSiblings");
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java
index 1ddecc3..2015091 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java
@@ -87,6 +87,17 @@ public class ResourceGroupGWTServiceImpl extends AbstractGWTServiceImpl implemen
}
}
+ public ResourceGroup createPrivateResourceGroup(ResourceGroup group, int[] resourceIds) {
+ try {
+ Subject user = getSessionSubject();
+ group = groupManager.createPrivateResourceGroup(user, group);
+ groupManager.setAssignedResources(user, group.getId(), resourceIds, true);
+ return SerialUtility.prepare(group, "ResourceGroupService.createResourceGroup");
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ }
+ }
+
public ResourceGroup createResourceGroup(ResourceGroup group, int[] resourceIds) {
try {
Subject user = getSessionSubject();
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SubjectManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SubjectManagerBean.java
index 4e1a53d..37ec2c9 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SubjectManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SubjectManagerBean.java
@@ -48,6 +48,7 @@ import org.rhq.core.domain.authz.Permission;
import org.rhq.core.domain.authz.Role;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.criteria.SubjectCriteria;
+import org.rhq.core.domain.resource.group.ResourceGroup;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.server.PersistenceUtility;
@@ -58,6 +59,7 @@ import org.rhq.enterprise.server.authz.PermissionException;
import org.rhq.enterprise.server.authz.RequiredPermission;
import org.rhq.enterprise.server.core.CustomJaasDeploymentServiceMBean;
import org.rhq.enterprise.server.exception.LoginException;
+import org.rhq.enterprise.server.resource.group.ResourceGroupManagerLocal;
import org.rhq.enterprise.server.system.SystemManagerLocal;
import org.rhq.enterprise.server.util.CriteriaQueryGenerator;
import org.rhq.enterprise.server.util.CriteriaQueryRunner;
@@ -69,7 +71,6 @@ import org.rhq.enterprise.server.util.CriteriaQueryRunner;
*/
@Stateless
public class SubjectManagerBean implements SubjectManagerLocal, SubjectManagerRemote {
- @SuppressWarnings("unused")
private final Log log = LogFactory.getLog(SubjectManagerBean.class);
@PersistenceContext(unitName = RHQConstants.PERSISTENCE_UNIT_NAME)
@@ -79,6 +80,10 @@ public class SubjectManagerBean implements SubjectManagerLocal, SubjectManagerRe
private AuthorizationManagerLocal authorizationManager;
@EJB
+ @IgnoreDependency
+ private ResourceGroupManagerLocal resourceGroupManager;
+
+ @EJB
private SystemManagerLocal systemManager;
@EJB
@@ -508,6 +513,25 @@ public class SubjectManagerBean implements SubjectManagerLocal, SubjectManagerRe
deletePrincipal(subject, doomedSubject);
}
+ // one more thing, delete any owned groups
+ List<ResourceGroup> ownedGroups = doomedSubject.getOwnedGroups();
+ if (!ownedGroups.isEmpty()) {
+ int size = ownedGroups.size();
+ int[] ownedGroupIds = new int[size];
+ for (int i = 0; (i < size); ++i) {
+ ownedGroupIds[i] = ownedGroups.get(i).getId();
+ }
+ try {
+ resourceGroupManager.deleteResourceGroups(subject, ownedGroupIds);
+ } catch (Throwable t) {
+ if (log.isDebugEnabled()) {
+ log.error("Error deleting owned group " + ownedGroupIds, t);
+ } else {
+ log.error("Error deleting owned group " + ownedGroupIds + ": " + t.getMessage());
+ }
+ }
+ }
+
deleteSubject(subject, doomedSubject);
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/AuthorizationManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/AuthorizationManagerBean.java
index d675177..1a14a56 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/AuthorizationManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/AuthorizationManagerBean.java
@@ -18,6 +18,7 @@
*/
package org.rhq.enterprise.server.authz;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.EnumSet;
import java.util.List;
@@ -32,6 +33,8 @@ import javax.persistence.Query;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.authz.Permission;
import org.rhq.core.domain.authz.Permission.Target;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.group.ResourceGroup;
import org.rhq.enterprise.server.RHQConstants;
/**
@@ -117,12 +120,33 @@ public class AuthorizationManagerBean implements AuthorizationManagerLocal {
return true;
}
- Query query = entityManager.createNamedQuery(Subject.QUERY_HAS_GROUP_PERMISSION);
- query.setParameter("subject", subject);
- query.setParameter("permission", permission);
- query.setParameter("groupId", groupId);
- long count = (Long) query.getSingleResult();
- return (count != 0);
+ ResourceGroup group = entityManager.find(ResourceGroup.class, groupId);
+ Subject owner = group.getSubject();
+
+ if (null == owner) {
+ // role-owned group
+ Query query = entityManager.createNamedQuery(Subject.QUERY_HAS_GROUP_PERMISSION);
+ query.setParameter("subject", subject);
+ query.setParameter("permission", permission);
+ query.setParameter("groupId", groupId);
+ long count = (Long) query.getSingleResult();
+ return (count != 0);
+
+ } else {
+ // don't let a user other than the owner do anything with this group
+ if (!subject.equals(owner)) {
+ return false;
+ }
+
+ // subject-owned group, requires perm check against each group member
+ Set<Resource> members = group.getExplicitResources();
+ List<Integer> memberIds = new ArrayList<Integer>(members.size());
+ for (Resource member : members) {
+ memberIds.add(member.getId());
+ }
+
+ return hasResourcePermission(owner, permission, memberIds);
+ }
}
public boolean hasResourcePermission(Subject subject, Permission permission, int resourceId) {
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 0528b06..bf213c0 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
@@ -94,6 +94,7 @@ import org.rhq.core.domain.resource.composite.ResourceComposite;
import org.rhq.core.domain.resource.composite.ResourceHealthComposite;
import org.rhq.core.domain.resource.composite.ResourceIdFlyWeight;
import org.rhq.core.domain.resource.composite.ResourceInstallCount;
+import org.rhq.core.domain.resource.composite.ResourceLineageComposite;
import org.rhq.core.domain.resource.composite.ResourcePermission;
import org.rhq.core.domain.resource.composite.ResourceWithAvailability;
import org.rhq.core.domain.resource.flyweight.FlyweightCache;
@@ -721,27 +722,68 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
return resourceLineage;
}
- public List<Resource> getResourceLineageAndSiblings(int resourceId) {
- List<Resource> resourceLineage = getResourceLineage(resourceId);
- List<Resource> result = new LinkedList<Resource>();
+ public List<ResourceLineageComposite> getResourceLineageAndSiblings(Subject subject, int resourceId) {
+ boolean isInventoryManager = authorizationManager.isInventoryManager(subject);
- Resource platform = resourceLineage.get(0);
- result.add(platform);
- for (Resource resource : resourceLineage) {
- if (resource.getParentResource() != null) {
- // This ensures Hibernate actually fetches the parent Resource.
- resource.getParentResource().getId();
- }
- Set<Resource> childResources = resource.getChildResources();
- result.addAll(childResources);
- for (Resource childResource : childResources) {
- // This ensures Hibernate actually fetches the parent Resource.
- childResource.getParentResource().getId();
- Set<Resource> grandchildResources = childResource.getChildResources();
- result.addAll(grandchildResources);
- for (Resource grandchildResource : grandchildResources) {
+ // get the raw resource lineage up to the platform. We'll check the auth below
+ List<Resource> rawResourceLineage = getResourceLineage(resourceId);
+ int depth = rawResourceLineage.size();
+ Resource parent = (depth > 1) ? rawResourceLineage.get(depth - 2) : null;
+
+ // record which of the raw ancestry is locked from view
+ List<ResourceLineageComposite> resourceLineage = new ArrayList<ResourceLineageComposite>(rawResourceLineage
+ .size());
+ for (Resource resource : rawResourceLineage) {
+ resourceLineage.add(new ResourceLineageComposite(resource, !authorizationManager.canViewResource(subject,
+ resource.getId())));
+ }
+
+ // fill out the tree, including only the direct ancestors and all viewable relations
+ List<ResourceLineageComposite> result = new LinkedList<ResourceLineageComposite>();
+
+ for (ResourceLineageComposite ancestor : resourceLineage) {
+ // always include a direct ancestor
+ result.add(ancestor);
+
+ // if the ancestor is not locked, include relevant children. Also, always show viewable
+ // siblings of the target resource.
+ if (!ancestor.isLocked() || ancestor.getResource() == parent) {
+
+ // get children
+ Set<Resource> children = ancestor.getResource().getChildResources();
+ // only add the viewable children
+ List<Resource> viewableChildren = new ArrayList<Resource>(children.size());
+ for (Resource child : children) {
+ boolean isCommitted = (child.getInventoryStatus() == InventoryStatus.COMMITTED);
+ boolean isViewable = (isInventoryManager || authorizationManager.canViewResource(subject, child
+ .getId()));
+ if (isCommitted && isViewable) {
+ // if not a direct ancestor add to the list (direct ancestors already added by default)
+ if (!rawResourceLineage.contains(child)) {
+ child.getParentResource().getId();
+ result.add(new ResourceLineageComposite(child, false));
+ }
+ viewableChildren.add(child);
+ }
+ }
+
+ // get grandchildren
+ for (Resource child : viewableChildren) {
// This ensures Hibernate actually fetches the parent Resource.
- grandchildResource.getParentResource().getId();
+ child.getParentResource().getId();
+ Set<Resource> grandChildren = child.getChildResources();
+ for (Resource grandChild : grandChildren) {
+ boolean isCommitted = (grandChild.getInventoryStatus() == InventoryStatus.COMMITTED);
+ boolean isViewable = (isInventoryManager || authorizationManager.canViewResource(subject,
+ grandChild.getId()));
+ if (isCommitted && isViewable) {
+ // if not a direct ancestor add to the list (direct ancestors already added by default)
+ if (!rawResourceLineage.contains(grandChild)) {
+ grandChild.getParentResource().getId();
+ result.add(new ResourceLineageComposite(grandChild, false));
+ }
+ }
+ }
}
}
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerLocal.java
index 78ece78..6f2ae41 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerLocal.java
@@ -43,6 +43,7 @@ import org.rhq.core.domain.resource.composite.ResourceComposite;
import org.rhq.core.domain.resource.composite.ResourceHealthComposite;
import org.rhq.core.domain.resource.composite.ResourceIdFlyWeight;
import org.rhq.core.domain.resource.composite.ResourceInstallCount;
+import org.rhq.core.domain.resource.composite.ResourceLineageComposite;
import org.rhq.core.domain.resource.composite.ResourceWithAvailability;
import org.rhq.core.domain.resource.flyweight.ResourceFlyweight;
import org.rhq.core.domain.resource.group.ResourceGroup;
@@ -156,11 +157,13 @@ public interface ResourceManagerLocal {
/**
* Returns the lineage of a resource plus all the siblings of the resources in the lineage. This is
- * useful for prepopulating all the resources visible in an expanded tree.
+ * useful for prepopulating all the resources visible in an expanded tree. Composites are returned
+ * that indicate whether the resource is viewable or should be locked in the tree.
+ *
* @param resourceId id of resource
- * @return resoure lineage and siblings
+ * @return resource lineage and siblings
*/
- List<Resource> getResourceLineageAndSiblings(int resourceId);
+ List<ResourceLineageComposite> getResourceLineageAndSiblings(Subject subject, int resourceId);
/**
* Looks up the root of a subtree in the inventory. This will generally find the platform on which
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java
index 0e7500f..f75d32d 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java
@@ -146,6 +146,15 @@ public class ResourceGroupManagerBean implements ResourceGroupManagerLocal, Reso
}
}
+ public ResourceGroup createPrivateResourceGroup(Subject subject, //
+ @XmlJavaTypeAdapter(ResourceGroupAdapter.class) ResourceGroup group) {
+
+ group.setSubject(subject);
+ group.setRecursive(false);
+
+ return resourceGroupManager.createResourceGroup(subjectManager.getOverlord(), group);
+ }
+
@RequiredPermission(Permission.MANAGE_INVENTORY)
public ResourceGroup createResourceGroup(Subject user, //
@XmlJavaTypeAdapter(ResourceGroupAdapter.class) ResourceGroup group) {
@@ -1017,8 +1026,9 @@ public class ResourceGroupManagerBean implements ResourceGroupManagerLocal, Reso
*/
public PageList<ResourceGroupComposite> findResourceGroupCompositesByCriteria(Subject subject,
ResourceGroupCriteria criteria) {
- CriteriaQueryGenerator generator = new CriteriaQueryGenerator(subject, criteria);
- ;
+
+ CriteriaQueryGenerator generator = getCriteriaQueryGenerator(subject, criteria);
+
String replacementSelectList = ""
+ " new org.rhq.core.domain.resource.group.composite.ResourceGroupComposite( "
+ " ( SELECT COUNT(avail) FROM resourcegroup.explicitResources res JOIN res.currentAvailability avail ) AS explicitCount,"
@@ -1028,17 +1038,6 @@ public class ResourceGroupManagerBean implements ResourceGroupManagerLocal, Reso
+ " resourcegroup ) ";
generator.alterProjection(replacementSelectList);
- if (criteria.isSecurityManagerRequired()
- && !authorizationManager.hasGlobalPermission(subject, Permission.MANAGE_SECURITY)) {
- throw new PermissionException("Subject [" + subject.getName()
- + "] requires SecurityManager permission for requested query criteria.");
- }
-
- if (authorizationManager.isInventoryManager(subject) == false) {
- generator.setAuthorizationResourceFragment(CriteriaQueryGenerator.AuthorizationTokenType.GROUP, null,
- subject.getId());
- }
-
CriteriaQueryRunner<ResourceGroupComposite> queryRunner = new CriteriaQueryRunner<ResourceGroupComposite>(
criteria, generator, entityManager);
PageList<ResourceGroupComposite> results = queryRunner.execute();
@@ -1299,18 +1298,35 @@ public class ResourceGroupManagerBean implements ResourceGroupManagerLocal, Reso
public void setAssignedResources(Subject subject, int groupId, int[] resourceIds, boolean setType)
throws ResourceGroupDeleteException {
+ ResourceGroup group = entityManager.find(ResourceGroup.class, groupId);
+ if (group.isPrivateGroup()) {
+ List<Integer> ids = new ArrayList<Integer>(resourceIds.length);
+ for (int id : resourceIds) {
+ ids.add(id);
+ }
+ if (!authorizationManager.canViewResources(subject, ids)) {
+ throw new PermissionException("Subject [" + subject.getName()
+ + "] does not have VIEW permission for all specified resources.");
+ }
+ } else {
+ if (!authorizationManager.isInventoryManager(subject)) {
+ throw new PermissionException("Subject [" + subject.getName()
+ + "] is not authorized for [ MANAGE_INVENTORY ]. Required for changing group membership ");
+ }
+ }
+
List<Integer> currentMembers = resourceManager.findExplicitResourceIdsByResourceGroup(groupId);
List<Integer> newMembers = ArrayUtils.wrapInList(resourceIds); // members needing addition
newMembers.removeAll(currentMembers);
if (newMembers.size() > 0) {
- addResourcesToGroup(subject, groupId, ArrayUtils.unwrapCollection(newMembers));
+ addResourcesToGroup(subjectManager.getOverlord(), groupId, ArrayUtils.unwrapCollection(newMembers));
}
List<Integer> extraMembers = new ArrayList<Integer>(currentMembers); // members needing removal
extraMembers.removeAll(ArrayUtils.wrapInList(resourceIds));
if (extraMembers.size() > 0) {
- removeResourcesFromGroup(subject, groupId, ArrayUtils.unwrapCollection(extraMembers));
+ removeResourcesFromGroup(subjectManager.getOverlord(), groupId, ArrayUtils.unwrapCollection(extraMembers));
}
// As a result of the membership change ensure that the group type is set correctly.
@@ -1461,28 +1477,45 @@ public class ResourceGroupManagerBean implements ResourceGroupManagerLocal, Reso
@SuppressWarnings("unchecked")
public PageList<ResourceGroup> findResourceGroupsByCriteria(Subject subject, ResourceGroupCriteria criteria) {
- CriteriaQueryGenerator generator = new CriteriaQueryGenerator(subject, criteria);
- ;
+ CriteriaQueryGenerator generator = getCriteriaQueryGenerator(subject, criteria);
+
+ CriteriaQueryRunner<ResourceGroup> queryRunner = new CriteriaQueryRunner(criteria, generator, entityManager);
+ PageList<ResourceGroup> result = queryRunner.execute();
+ return result;
+ }
+
+ private CriteriaQueryGenerator getCriteriaQueryGenerator(Subject subject, ResourceGroupCriteria criteria) {
if (criteria.isSecurityManagerRequired()
&& !authorizationManager.hasGlobalPermission(subject, Permission.MANAGE_SECURITY)) {
throw new PermissionException("Subject [" + subject.getName()
+ "] requires SecurityManager permission for requested query criteria.");
}
- if (criteria.isInventoryManagerRequired()
- && !authorizationManager.hasGlobalPermission(subject, Permission.MANAGE_INVENTORY)) {
+ boolean isInventoryManager = authorizationManager.isInventoryManager(subject);
+ boolean groupAuthzRequired = (!(criteria.isFilterPrivate() || isInventoryManager));
+
+ if (criteria.isInventoryManagerRequired() && !isInventoryManager) {
throw new PermissionException("Subject [" + subject.getName()
+ "] requires InventoryManager permission for requested query criteria.");
}
- if (authorizationManager.isInventoryManager(subject) == false) {
+ // if we're searching for private groups set the subject filter to the current user's subjectId
+ // setting it here prevents the caller from spoofing a different user. This is why the subject and
+ // private filters are different. The suject filter can specifiy any use and therefore requires
+ // inventory manager.
+ if (criteria.isFilterPrivate()) {
+ criteria.addFilterPrivate(null);
+ criteria.addFilterSubjectId(subject.getId());
+ }
+
+ CriteriaQueryGenerator generator = new CriteriaQueryGenerator(subject, criteria);
+ if (groupAuthzRequired) {
generator.setAuthorizationResourceFragment(CriteriaQueryGenerator.AuthorizationTokenType.GROUP, null,
subject.getId());
}
- CriteriaQueryRunner<ResourceGroup> queryRunner = new CriteriaQueryRunner(criteria, generator, entityManager);
- return queryRunner.execute();
+ return generator;
}
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerLocal.java
index de96dbf..a0481b1 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerLocal.java
@@ -42,6 +42,28 @@ import org.rhq.core.domain.util.PageList;
@Local
public interface ResourceGroupManagerLocal {
+ /**
+ * NOTE: This is only used to support AutoGroups currently but the idea may be expanded in the future.
+ *
+ * Creates a private, "user-owned" (aka "subject-owned") resource group. This group differs from a role-owned
+ * group in that it can not be assigned to a role, instead it is owned by the user that creates it. It comprises
+ * only a set of resources for which the user has, minimally, view permission. Since a user's view permissions
+ * can change, membership and authz checking must be performed as needed when taking any action on the group.
+ * <br/><br/>
+ * A user does not need MANAGE_INVENTORY to create a sub-group because it is private to his view.
+ * <br/><br/>
+ * This call does not populate the group with members, it only creates the group. The group is automatically set
+ * to be non-recursive.
+ * <br/><br/>
+ * All user-owned groups are deleted if the the user is deleted.
+ *
+ * @param user The user for which the group will be created.
+ * @param group The group characteristics. Any membership defined here is ignored. The recursivity setting is
+ * ignored.
+ * @return The new group.
+ */
+ ResourceGroup createPrivateResourceGroup(Subject user, ResourceGroup group);
+
ResourceGroup getResourceGroupById(Subject user, int id, GroupCategory category)
throws ResourceGroupNotFoundException;
@@ -108,7 +130,10 @@ public interface ResourceGroupManagerLocal {
/**
* This method ensures that the explicit group membership is set to the specified resources. Members
* will be added or removed as necessary. Make sure you pass the correct value for the <setType>
- * parameter.
+ * parameter.
+ * <br/><br/>
+ * For global groups requires MANAGE_INVENTORY. For private groups requires VIEW permission on all specified
+ * resources.
*
* @param subject
* @param groupId
commit dd657e98f4d906e6bb6b58b3948d1b7d7282b4ec
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Sep 28 12:35:44 2010 -0400
AutoGroup/ResourceTree work
- Fix up breadcrumbs for AutoGroup selections and also fix up some path
- issues that were happening when selecting AG resources.
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 bb39f2d..34cf23e 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
@@ -254,10 +254,13 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String> {
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 -
- // grab the end portion of the previous history URL and append it to the new history URL,
- // so the same tab is selected for the new Resource.
- String suffix = currentViewPath.replaceFirst("^[^/]*/[^/]*", "");
+ // The Node that was selected is not the same Node that was previously selected - it
+ // may not even be the same node type. For example, the user could have moved from a
+ // resource to an autogroup in the same tree. Try to keep the tab selection sticky as best as
+ // possible while moving from one view to another by grabbing the end portion of the previous
+ // history URL and append it to the new history URL. The suffix is assumed to follow the
+ // ID (numeric) portion of the currentViewPath.
+ String suffix = currentViewPath.replaceFirst("\\D*[^/]*", "");
viewPath += suffix;
}
}
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 6a7cba9..0d16bea 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
@@ -236,7 +236,6 @@ public class ResourceTreeView extends LocatableVLayout {
// get back to this node given the id of the backing group (from the viewpath)
autoGroupNodeMap.put(result.getId(), agNode);
callback.onSuccess(result);
- //renderAutoGroup(result);
}
});
} else {
@@ -302,6 +301,23 @@ public class ResourceTreeView extends LocatableVLayout {
}
}
+ private void adjustBreadcrumb(TreeNode node, ViewId viewId) {
+ if (node instanceof ResourceTreeNode) {
+ 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";
+
+ viewId.getBreadcrumbs().add(new Breadcrumb(node.getAttribute("id"), display, icon, true));
+
+ } else if (node instanceof AutoGroupTreeNode) {
+ String name = ((AutoGroupTreeNode) node).getBackingGroupName();
+ String display = node.getName() + " <span class=\"subtitle\">" + name + "</span>";
+ String icon = "types/" + ((AutoGroupTreeNode) node).getResourceType().getCategory() + "_up_16.png";
+
+ viewId.getBreadcrumbs().add(new Breadcrumb(node.getAttribute("id"), display, icon, true));
+ }
+ }
+
private void showContextMenu(AutoGroupTreeNode agNode) {
getAutoGroupBackingGroup(agNode, new AsyncCallback<ResourceGroup>() {
public void onFailure(Throwable caught) {
@@ -680,23 +696,6 @@ public class ResourceTreeView extends LocatableVLayout {
}
}
- private void adjustBreadcrumb(TreeNode node, ViewId viewId) {
- if (node instanceof ResourceTreeNode) {
-
- 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";
-
- viewId.getBreadcrumbs().add(new Breadcrumb(node.getAttribute("id"), display, icon, true));
-
- } else {
-
- // if (node.getName() != null) {
- // viewId.getBreadcrumbs().add(new Breadcrumb(node.getAttribute("id"), node.getName(), null, true));
- // }
- }
- }
-
/*private List<Resource> preload(final List<Resource> lineage) {
final ArrayList<Resource> list = new ArrayList<Resource>(lineage);
@@ -730,8 +729,9 @@ public class ResourceTreeView extends LocatableVLayout {
currentViewId = viewPath.getCurrent();
String currentViewIdPath = currentViewId.getPath();
if ("AutoGroup".equals(currentViewIdPath)) {
- ViewId nextViewId = viewPath.getNext();
- Integer autoGroupId = Integer.parseInt(nextViewId.getPath());
+ // Move the currentViewId to the ID portion to play better with other code
+ currentViewId = viewPath.getNext();
+ Integer autoGroupId = Integer.parseInt(currentViewId.getPath());
setSelectedAutoGroup(autoGroupId);
} else {
Integer resourceId = Integer.parseInt(currentViewId.getPath());
13 years, 8 months
[rhq] 2 commits - modules/core modules/enterprise
by John Sanda
modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyDefinitionSimple.java | 12 ---
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBeanTest.java | 34 +++++++---
modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/configuration/metadata/configuration_metadata_manager_bean_test_v1.xml | 10 ++
modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/configuration/metadata/configuration_metadata_manager_bean_test_v2.xml | 18 ++++-
4 files changed, 53 insertions(+), 21 deletions(-)
New commits:
commit 7f0ee950e729a69708326e6ad7b5c8df7ebd749f
Author: John Sanda <jsanda(a)redhat.com>
Date: Thu Sep 30 11:01:51 2010 -0400
Adding more tests
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBeanTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBeanTest.java
index 1658e18..bc0d6c5 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBeanTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBeanTest.java
@@ -24,8 +24,6 @@
package org.rhq.enterprise.server.configuration.metadata;
import javax.persistence.EntityManager;
-import javax.transaction.NotSupportedException;
-import javax.transaction.SystemException;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@@ -38,12 +36,11 @@ import org.rhq.enterprise.server.test.AbstractEJB3Test;
import org.rhq.enterprise.server.util.LookupUtil;
import org.rhq.test.AssertUtils;
-import static org.rhq.enterprise.server.configuration.metadata.PluginDescriptorUtil.*;
+import static org.rhq.enterprise.server.configuration.metadata.PluginDescriptorUtil.loadPluginConfigDefFor;
+import static org.rhq.enterprise.server.configuration.metadata.PluginDescriptorUtil.loadPluginDescriptor;
public class ConfigurationMetadataManagerBeanTest extends AbstractEJB3Test {
- EntityManager entityMgr;
-
PluginDescriptor originalDescriptor;
PluginDescriptor updatedDescriptor;
@@ -63,16 +60,37 @@ public class ConfigurationMetadataManagerBeanTest extends AbstractEJB3Test {
}
@Test
- public void newUngroupedPropertyDefsShouldBeAddedToConfigurationDef() throws Exception {
+ public void addNewUngroupedPropertyDef() {
initConfigDefs("servers[name='MyServer1']", "test");
- PropertyDefinitionSimple expected = updatedConfigDef.getPropertyDefinitionSimple("bar");
- PropertyDefinitionSimple actual = originalConfigDef.getPropertyDefinitionSimple("bar");
+ String propertyName = "newUngroupedProperty";
+ PropertyDefinitionSimple expected = updatedConfigDef.getPropertyDefinitionSimple(propertyName);
+ PropertyDefinitionSimple actual = originalConfigDef.getPropertyDefinitionSimple(propertyName);
assertPropertyDefinitionMatches("New ungrouped property defs should be added to the configuration definition",
expected, actual);
}
+ @Test
+ public void removePropertyDefThatIsNotInNewDescriptor() {
+ initConfigDefs("servers[name='MyServer1']", "test");
+
+ assertNull("The property exists in version 1 but not in version 2 of the plugin; therefore, it should be " +
+ "removed the configuration definition", originalConfigDef.get("v1OnlyProperty"));
+ }
+
+ @Test
+ public void doNotModifyExistingPropertyDefThatIsNotModifiedInUpgrade() {
+ initConfigDefs("servers[name='MyServer1']", "test");
+
+ String propertyName = "myExistingProperty";
+ PropertyDefinitionSimple expected = updatedConfigDef.getPropertyDefinitionSimple(propertyName);
+ PropertyDefinitionSimple actual = originalConfigDef.getPropertyDefinitionSimple(propertyName);
+
+ assertPropertyDefinitionMatches("Existing property that is not changed in new version of pluign should " +
+ "not change", expected, actual);
+ }
+
// void assertGroupDefinitionExists() {
// for (PropertyGroupDefinition groupDef : originalConfigurationDef.getGroupDefinitions()) {
// if (groupDef.getName().equals("groupToBeRemoved")) {
diff --git a/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/configuration/metadata/configuration_metadata_manager_bean_test_v1.xml b/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/configuration/metadata/configuration_metadata_manager_bean_test_v1.xml
index 0c7d362..131cff7 100644
--- a/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/configuration/metadata/configuration_metadata_manager_bean_test_v1.xml
+++ b/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/configuration/metadata/configuration_metadata_manager_bean_test_v1.xml
@@ -7,7 +7,15 @@
<server name="MyServer1">
<plugin-configuration>
- <c:simple-property name="myProperty1"/>
+ <c:simple-property name="myExistingProperty"
+ type="integer"
+ units="megabytes"
+ default="256"
+ required="true"
+ description="My Existing Property"/>
+
+ <c:simple-property name="v1OnlyProperty"
+ description="This property exists only in version 1 of the plugin"/>
</plugin-configuration>
</server>
</plugin>
diff --git a/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/configuration/metadata/configuration_metadata_manager_bean_test_v2.xml b/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/configuration/metadata/configuration_metadata_manager_bean_test_v2.xml
index 8997f8f..2c94f72 100644
--- a/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/configuration/metadata/configuration_metadata_manager_bean_test_v2.xml
+++ b/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/configuration/metadata/configuration_metadata_manager_bean_test_v2.xml
@@ -7,8 +7,22 @@
<server name="MyServer1">
<plugin-configuration>
- <c:simple-property name="myProperty1"/>
- <c:simple-property name="bar" description="bar property"/>
+ <c:simple-property name="myExistingProperty"
+ type="integer"
+ units="megabytes"
+ default="256"
+ required="true"
+ description="My Existing Property"/>
+
+ <c:simple-property name="newUngroupedProperty"
+ description="A new, ungrouped property"
+ activationPolicy="immediate"
+ default="new property"
+ required="true"
+ displayName="My New Ungrouped Property"
+ readOnly="true"
+ type="longString"
+ summary="false"/>
</plugin-configuration>
</server>
</plugin>
commit 423bfa5e3c976746bd61d917464eff8da2cbac46
Author: John Sanda <jsanda(a)redhat.com>
Date: Thu Sep 30 09:52:34 2010 -0400
Guarding against hibernate exception that can occur when using delete-orphan
While adding/updating tests I was running into,
HibernateException: A collection with cascade="all-delete-orphan" was no longer
referenced by the owning entity instance
The solution is to make sure that the managed collection references do
not change
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyDefinitionSimple.java b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyDefinitionSimple.java
index 101d894..782dc99 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyDefinitionSimple.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyDefinitionSimple.java
@@ -78,7 +78,7 @@ public class PropertyDefinitionSimple extends PropertyDefinition {
@Cascade( { org.hibernate.annotations.CascadeType.ALL, org.hibernate.annotations.CascadeType.DELETE_ORPHAN })
@IndexColumn(name = "order_index")
@OneToMany(mappedBy = "propertyDefinitionSimple", fetch = FetchType.EAGER)
- private List<PropertyDefinitionEnumeration> enumeratedValues;
+ private List<PropertyDefinitionEnumeration> enumeratedValues = new ArrayList<PropertyDefinitionEnumeration>();
/**
* This property's default value. This field should have a non-null value for properties whose
@@ -122,10 +122,6 @@ public class PropertyDefinitionSimple extends PropertyDefinition {
*/
@NotNull
public Set<Constraint> getConstraints() {
- if (this.constraints == null) {
- this.constraints = new LinkedHashSet<Constraint>();
- }
-
return this.constraints;
}
@@ -148,15 +144,11 @@ public class PropertyDefinitionSimple extends PropertyDefinition {
*/
@NotNull
public List<PropertyDefinitionEnumeration> getEnumeratedValues() {
- if (this.enumeratedValues == null) {
- this.enumeratedValues = new ArrayList<PropertyDefinitionEnumeration>();
- }
-
return this.enumeratedValues;
}
public void setEnumeratedValues(List<PropertyDefinitionEnumeration> enumeratedValues, boolean allowCustomEnumValue) {
- this.enumeratedValues = enumeratedValues;
+ addEnumeratedValues(enumeratedValues.toArray(new PropertyDefinitionEnumeration[enumeratedValues.size()]));
this.allowCustomEnumeratedValue = allowCustomEnumValue;
ensureOrdering();
}
13 years, 8 months
[rhq] 3 commits - modules/core modules/enterprise
by John Sanda
modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyDefinitionSimple.java | 3
modules/enterprise/server/jar/pom.xml | 7
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationDefinitionUpdateReport.java | 17 +
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBean.java | 8
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBean.java | 19 +
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBeanTest.java | 152 ++++------
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/metadata/PluginDescriptorUtil.java | 70 ++++
modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/configuration/metadata/configuration_metadata_manager_bean_test_v1.xml | 13
modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/configuration/metadata/configuration_metadata_manager_bean_test_v2.xml | 14
9 files changed, 213 insertions(+), 90 deletions(-)
New commits:
commit d6f69c80499f3e959825ab50b613ad45cd472404
Merge: b56a7c0... 3c5a00e...
Author: John Sanda <jsanda(a)redhat.com>
Date: Thu Sep 30 09:21:43 2010 -0400
Merge branch 'master' of ssh://git.fedorahosted.org/git/rhq/rhq
commit b56a7c0af0071ebee3b350ac1769a52e8a8b3a75
Author: John Sanda <jsanda(a)redhat.com>
Date: Thu Sep 30 09:17:01 2010 -0400
Getting infrastructure in place for testing plugin upgrade code
Trying to clean up and get tests in ConfigurationMetadataManagerBean in a
working, maintainable state.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyDefinitionSimple.java b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyDefinitionSimple.java
index a27b677..101d894 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyDefinitionSimple.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyDefinitionSimple.java
@@ -23,6 +23,7 @@
package org.rhq.core.domain.configuration.definition;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
@@ -69,7 +70,7 @@ public class PropertyDefinitionSimple extends PropertyDefinition {
@Cascade( { org.hibernate.annotations.CascadeType.ALL, org.hibernate.annotations.CascadeType.DELETE_ORPHAN })
@OneToMany(mappedBy = "propertyDefinitionSimple", cascade = { CascadeType.ALL }, fetch = FetchType.EAGER)
- private Set<Constraint> constraints;
+ private Set<Constraint> constraints = new HashSet<Constraint>();
/**
* The <options> within <property-options> for a <simple-property>
diff --git a/modules/enterprise/server/jar/pom.xml b/modules/enterprise/server/jar/pom.xml
index 4c4e9a5..b54dfd8 100644
--- a/modules/enterprise/server/jar/pom.xml
+++ b/modules/enterprise/server/jar/pom.xml
@@ -400,6 +400,13 @@
<version>1.8</version>
<scope>test</scope>
</dependency>
+
+ <dependency>
+ <groupId>commons-jxpath</groupId>
+ <artifactId>commons-jxpath</artifactId>
+ <version>1.3</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBeanTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBeanTest.java
index 87d254a..1658e18 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBeanTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBeanTest.java
@@ -23,113 +23,102 @@
package org.rhq.enterprise.server.configuration.metadata;
-import org.rhq.core.clientapi.agent.metadata.ConfigurationMetadataParser;
-import org.rhq.core.clientapi.descriptor.DescriptorPackages;
-import org.rhq.core.clientapi.descriptor.configuration.ConfigurationDescriptor;
+import javax.persistence.EntityManager;
+import javax.transaction.NotSupportedException;
+import javax.transaction.SystemException;
+
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
import org.rhq.core.clientapi.descriptor.plugin.PluginDescriptor;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
import org.rhq.core.domain.configuration.definition.PropertyGroupDefinition;
-import org.rhq.core.domain.resource.ResourceType;
-import org.rhq.enterprise.server.resource.metadata.test.UpdateSubsytemTestBase;
import org.rhq.enterprise.server.test.AbstractEJB3Test;
import org.rhq.enterprise.server.util.LookupUtil;
import org.rhq.test.AssertUtils;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-import javax.persistence.EntityManager;
-import javax.transaction.TransactionManager;
-import javax.xml.XMLConstants;
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.Unmarshaller;
-import javax.xml.bind.util.ValidationEventCollector;
-import javax.xml.validation.Schema;
-import javax.xml.validation.SchemaFactory;
-import java.io.FileNotFoundException;
-import java.net.URL;
+import static org.rhq.enterprise.server.configuration.metadata.PluginDescriptorUtil.*;
public class ConfigurationMetadataManagerBeanTest extends AbstractEJB3Test {
- ConfigurationMetadataManagerLocal configurationMetadataMgr;
-
EntityManager entityMgr;
- ConfigurationDefinition originalConfigurationDef;
+ PluginDescriptor originalDescriptor;
+
+ PluginDescriptor updatedDescriptor;
- ConfigurationDefinition newConfigurationDef;
+ ConfigurationDefinition originalConfigDef;
- @BeforeClass(enabled = false)
- public void setupClass() throws Exception {
+ ConfigurationDefinition updatedConfigDef;
+
+ @BeforeClass
+ public void setupClass() {
String pluginFileBaseName = "configuration_metadata_manager_bean_test";
String version1 = pluginFileBaseName + "_v1.xml";
String version2 = pluginFileBaseName + "_v2.xml";
- getTransactionManager().begin();
- entityMgr = getEntityManager();
+ originalDescriptor = loadPluginDescriptor(getPackagePath() + version1);
+ updatedDescriptor = loadPluginDescriptor(getPackagePath() + version2);
+ }
- configurationMetadataMgr = LookupUtil.getConfigurationMetadataManager();
+ @Test
+ public void newUngroupedPropertyDefsShouldBeAddedToConfigurationDef() throws Exception {
+ initConfigDefs("servers[name='MyServer1']", "test");
- originalConfigurationDef = createAndSaveConfigurationDef(version1);
- newConfigurationDef = loadPluginConfigurationFromFile(version2);
+ PropertyDefinitionSimple expected = updatedConfigDef.getPropertyDefinitionSimple("bar");
+ PropertyDefinitionSimple actual = originalConfigDef.getPropertyDefinitionSimple("bar");
- assertGroupDefinitionExists();
+ assertPropertyDefinitionMatches("New ungrouped property defs should be added to the configuration definition",
+ expected, actual);
+ }
- originalConfigurationDef = entityMgr.getReference(ConfigurationDefinition.class,
- originalConfigurationDef.getId());
+// void assertGroupDefinitionExists() {
+// for (PropertyGroupDefinition groupDef : originalConfigurationDef.getGroupDefinitions()) {
+// if (groupDef.getName().equals("groupToBeRemoved")) {
+// assertTrue(groupDef.getId() != 0);
+// assertNotNull(entityMgr.find(PropertyGroupDefinition.class, groupDef.getId()));
+// }
+// }
+// }
+
+ private void initConfigDefs(String path, String configName) {
+ loadAndPersistConfigDefs(path, configName);
+ updateConfigDef();
+ }
- configurationMetadataMgr.updateConfigurationDefinition(newConfigurationDef, originalConfigurationDef);
+ private void loadAndPersistConfigDefs(String path, String configName) {
+ originalConfigDef = loadPluginConfigDefFor(originalDescriptor, path, configName);
+ updatedConfigDef = loadPluginConfigDefFor(updatedDescriptor, path, configName);
- originalConfigurationDef = entityMgr.find(ConfigurationDefinition.class, originalConfigurationDef.getId());
+ try {
+ getTransactionManager().begin();
- assertNotNull(originalConfigurationDef);
- }
+ EntityManager entityMgr = getEntityManager();
+ entityMgr.persist(originalConfigDef);
+ entityMgr.persist(updatedConfigDef);
- void assertGroupDefinitionExists() {
- for (PropertyGroupDefinition groupDef : originalConfigurationDef.getGroupDefinitions()) {
- if (groupDef.getName().equals("groupToBeRemoved")) {
- assertTrue(groupDef.getId() != 0);
- assertNotNull(entityMgr.find(PropertyGroupDefinition.class, groupDef.getId()));
- }
+ getTransactionManager().commit();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
}
}
- @AfterClass(enabled = false)
- public void tearDownClass() throws Exception {
- getTransactionManager().rollback();
- }
-
- private ConfigurationDefinition createAndSaveConfigurationDef(String file) throws Exception {
- ConfigurationDefinition configurationDef = loadPluginConfigurationFromFile(file);
- entityMgr.persist(configurationDef);
- return configurationDef;
- }
+ private void updateConfigDef() {
+ try {
+ getTransactionManager().begin();
- private ConfigurationDefinition loadPluginConfigurationFromFile(String file) throws Exception {
- PluginDescriptor pluginDescriptor = loadPluginDescriptor(file);
- ConfigurationDescriptor configurationDescriptor = pluginDescriptor.getServers().get(0).getPluginConfiguration();
- return ConfigurationMetadataParser.parse("test", configurationDescriptor);
- }
+ ConfigurationMetadataManagerLocal configMetadataMgr = LookupUtil.getConfigurationMetadataManager();
+ configMetadataMgr.updateConfigurationDefinition(updatedConfigDef, originalConfigDef);
- private PluginDescriptor loadPluginDescriptor(String file) throws Exception {
- URL pluginDescriptorURL = getClass().getResource(file);
- if (pluginDescriptorURL == null) {
- throw new FileNotFoundException("File " + file + " not found");
+ getTransactionManager().commit();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
}
+ }
- JAXBContext jaxbContext = JAXBContext.newInstance(DescriptorPackages.PC_PLUGIN);
- URL pluginSchemaURL = this.getClass().getClassLoader().getResource("rhq-plugin.xsd");
- Schema pluginSchema = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI).newSchema(pluginSchemaURL);
-
- Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
- ValidationEventCollector vec = new ValidationEventCollector();
- unmarshaller.setEventHandler(vec);
- unmarshaller.setSchema(pluginSchema);
-
- return (PluginDescriptor) unmarshaller.unmarshal(pluginDescriptorURL.openStream());
+ private String getPackagePath() {
+ return "/" + getClass().getPackage().getName().replace('.', '/') + "/";
}
void assertPropertyDefinitionMatches(String msg, PropertyDefinitionSimple expected,
@@ -138,18 +127,9 @@ public class ConfigurationMetadataManagerBeanTest extends AbstractEJB3Test {
}
@Test(enabled = false)
- public void newUngroupedPropertyDefsShouldBeAddedToConfigurationDef() throws Exception {
- PropertyDefinitionSimple expected = newConfigurationDef.getPropertyDefinitionSimple("bar");
- PropertyDefinitionSimple actual = originalConfigurationDef.getPropertyDefinitionSimple("bar");
-
- assertPropertyDefinitionMatches("New ungrouped property defs shoould be added to the configuration definition",
- expected, actual);
- }
-
- @Test(enabled = false)
public void existingUngroupedPropertyDefShouldBeUpdated() throws Exception {
- PropertyDefinitionSimple expected = newConfigurationDef.getPropertyDefinitionSimple("foo");
- PropertyDefinitionSimple actual = originalConfigurationDef.getPropertyDefinitionSimple("foo");
+ PropertyDefinitionSimple expected = updatedConfigDef.getPropertyDefinitionSimple("foo");
+ PropertyDefinitionSimple actual = originalConfigDef.getPropertyDefinitionSimple("foo");
assertPropertyDefinitionMatches("Existing ungrouped property defs should be updated", expected, actual);
}
@@ -158,13 +138,13 @@ public class ConfigurationMetadataManagerBeanTest extends AbstractEJB3Test {
public void propertyDefNotInNewConfigurationDefShouldBeRemoved() throws Exception {
assertNull(
"A property def in the original configuration def that is removed in the new configuration def should be deleted",
- originalConfigurationDef.getPropertyDefinitionSimple("propertyToBeRemoved")
+ originalConfigDef.getPropertyDefinitionSimple("propertyToBeRemoved")
);
}
@Test(enabled = false)
public void propertyGroupDefNotInNewConfigurationDefShouldBeRemoved() throws Exception {
- for (PropertyGroupDefinition def : originalConfigurationDef.getGroupDefinitions()) {
+ for (PropertyGroupDefinition def : originalConfigDef.getGroupDefinitions()) {
if (def.getName().equals("groupToBeRemoved")) {
fail("Expected property group 'groupToBeRemoved' to be deleted since it is not in the new configuration def.");
}
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/metadata/PluginDescriptorUtil.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/metadata/PluginDescriptorUtil.java
new file mode 100644
index 0000000..8eb4632
--- /dev/null
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/metadata/PluginDescriptorUtil.java
@@ -0,0 +1,70 @@
+package org.rhq.enterprise.server.configuration.metadata;
+
+import java.io.FileNotFoundException;
+import java.net.URL;
+
+import javax.xml.XMLConstants;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.bind.util.ValidationEventCollector;
+import javax.xml.validation.Schema;
+import javax.xml.validation.SchemaFactory;
+
+import org.apache.commons.jxpath.JXPathContext;
+
+import org.rhq.core.clientapi.agent.metadata.ConfigurationMetadataParser;
+import org.rhq.core.clientapi.descriptor.DescriptorPackages;
+import org.rhq.core.clientapi.descriptor.plugin.PluginDescriptor;
+import org.rhq.core.clientapi.descriptor.plugin.ResourceDescriptor;
+import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
+
+public class PluginDescriptorUtil {
+
+ public static PluginDescriptor loadPluginDescriptor(String file) {
+ try {
+ URL pluginDescriptorURL = PluginDescriptorUtil.class.getResource(file);
+ if (pluginDescriptorURL == null) {
+ throw new FileNotFoundException("File " + file + " not found");
+ }
+
+ JAXBContext jaxbContext = JAXBContext.newInstance(DescriptorPackages.PC_PLUGIN);
+ URL pluginSchemaURL = PluginDescriptorUtil.class.getClassLoader().getResource("rhq-plugin.xsd");
+ Schema pluginSchema = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI).newSchema(
+ pluginSchemaURL);
+ Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
+ ValidationEventCollector vec = new ValidationEventCollector();
+ unmarshaller.setEventHandler(vec);
+ unmarshaller.setSchema(pluginSchema);
+
+ return (PluginDescriptor) unmarshaller.unmarshal(pluginDescriptorURL.openStream());
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public static Object find(PluginDescriptor descriptor, String path) {
+ JXPathContext context = JXPathContext.newContext(descriptor);
+ return context.getValue(path);
+ }
+
+ public static ConfigurationDefinition loadPluginConfigDefFor(PluginDescriptor descriptor, String path,
+ String configName) {
+ try {
+ ResourceDescriptor resourceDescriptor = (ResourceDescriptor) find(descriptor, path);
+ return ConfigurationMetadataParser.parse(configName, resourceDescriptor.getPluginConfiguration());
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public static ConfigurationDefinition loadResourceConfigDefFor(PluginDescriptor descriptor, String path,
+ String configName) {
+ try {
+ ResourceDescriptor resourceDescriptor = (ResourceDescriptor) find(descriptor, path);
+ return ConfigurationMetadataParser.parse(configName, resourceDescriptor.getResourceConfiguration());
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+}
diff --git a/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/configuration/metadata/configuration_metadata_manager_bean_test_v1.xml b/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/configuration/metadata/configuration_metadata_manager_bean_test_v1.xml
new file mode 100644
index 0000000..0c7d362
--- /dev/null
+++ b/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/configuration/metadata/configuration_metadata_manager_bean_test_v1.xml
@@ -0,0 +1,13 @@
+<plugin name="ConfigurationMetadataManagerBeanTest"
+ package="org.rhq.enterprise.server.confiuguration.metadata"
+ version="2.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="urn:xmlns:rhq-plugin"
+ xmlns:c="urn:xmlns:rhq-configuration">
+
+ <server name="MyServer1">
+ <plugin-configuration>
+ <c:simple-property name="myProperty1"/>
+ </plugin-configuration>
+ </server>
+</plugin>
diff --git a/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/configuration/metadata/configuration_metadata_manager_bean_test_v2.xml b/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/configuration/metadata/configuration_metadata_manager_bean_test_v2.xml
new file mode 100644
index 0000000..8997f8f
--- /dev/null
+++ b/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/configuration/metadata/configuration_metadata_manager_bean_test_v2.xml
@@ -0,0 +1,14 @@
+<plugin name="ConfigurationMetadataManagerBeanTest"
+ package="org.rhq.enterprise.server.confiuguration.metadata"
+ version="2.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="urn:xmlns:rhq-plugin"
+ xmlns:c="urn:xmlns:rhq-configuration">
+
+ <server name="MyServer1">
+ <plugin-configuration>
+ <c:simple-property name="myProperty1"/>
+ <c:simple-property name="bar" description="bar property"/>
+ </plugin-configuration>
+ </server>
+</plugin>
commit f0fffb5636ef2cdf89f6a1a1b1808e5d2fd98b6c
Author: John Sanda <jsanda(a)redhat.com>
Date: Tue Sep 28 17:15:48 2010 -0400
[BZ 619781] Handling more scenarios for settting connection properties to default values
Adding logic to handle three additional scenarios each of which involves
connection properties that are required and specify a default value:
1) A new property is added to a new group
2) An existing property not part of a group added to an existing group
3) A property previously in a group moved outside of a group
There were also some scenarios when properties were moved into or out of a group
and the group reference was not getting set or unset.
ConfigurationMetadataManagerBean has been modifed to update these references.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationDefinitionUpdateReport.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationDefinitionUpdateReport.java
index ad0c84b..ecad316 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationDefinitionUpdateReport.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationDefinitionUpdateReport.java
@@ -25,6 +25,7 @@ package org.rhq.enterprise.server.configuration.metadata;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.configuration.definition.PropertyDefinition;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
import java.util.HashSet;
import java.util.Set;
@@ -35,6 +36,8 @@ public class ConfigurationDefinitionUpdateReport {
private Set<PropertyDefinition> newPropertyDefs = new HashSet<PropertyDefinition>();
+ private Set<PropertyDefinition> updatedPropertyDefs = new HashSet<PropertyDefinition>();
+
public ConfigurationDefinitionUpdateReport(ConfigurationDefinition configurationDefinition) {
configurationDef = configurationDefinition;
}
@@ -44,11 +47,23 @@ public class ConfigurationDefinitionUpdateReport {
}
public void addNewPropertyDefinition(PropertyDefinition propertyDef) {
- newPropertyDefs.add(propertyDef);
+ if (propertyDef instanceof PropertyDefinitionSimple) {
+ newPropertyDefs.add(propertyDef);
+ }
}
public Set<PropertyDefinition> getNewPropertyDefinitions() {
return newPropertyDefs;
}
+ public void addUpdatedPropertyDefinition(PropertyDefinition propertyDef) {
+ if (propertyDef instanceof PropertyDefinitionSimple) {
+ updatedPropertyDefs.add(propertyDef);
+ }
+ }
+
+ public Set<PropertyDefinition> getUpdatedPropertyDefinitions() {
+ return updatedPropertyDefs;
+ }
+
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBean.java
index 8427c8b..04a3995 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBean.java
@@ -74,6 +74,7 @@ public class ConfigurationMetadataManagerBean implements ConfigurationMetadataMa
PropertyDefinition existingProp = existingDefinition.get(newProperty.getName());
if (existingProp != null) {
updatePropertyDefinition(existingProp, newProperty);
+ updateReport.addUpdatedPropertyDefinition(newProperty);
} else {
existingDefinition.put(newProperty);
updateReport.addNewPropertyDefinition(newProperty);
@@ -130,6 +131,7 @@ public class ConfigurationMetadataManagerBean implements ConfigurationMetadataMa
PropertyDefinition existingProperty = existingDefinition.getPropertyDefinitions().get(nDef.getName());
if (existingProperty != null) {
updatePropertyDefinition(existingProperty, nDef);
+ updateReport.addUpdatedPropertyDefinition(nDef);
} else {
existingDefinition.put(nDef);
updateReport.addNewPropertyDefinition(nDef);
@@ -157,6 +159,11 @@ public class ConfigurationMetadataManagerBean implements ConfigurationMetadataMa
entityManager.persist(def);
def.setPropertyGroupDefinition(group);
def.setConfigurationDefinition(existingDefinition);
+
+ if (!exPDefs.containsKey(def.getName())) {
+ updateReport.addNewPropertyDefinition(def);
+ }
+
exPDefs.put(def.getName(), def);
}
}
@@ -309,6 +316,7 @@ public class ConfigurationMetadataManagerBean implements ConfigurationMetadataMa
existingProperty.setRequired(newProperty.isRequired());
existingProperty.setReadOnly(newProperty.isReadOnly());
existingProperty.setSummary(newProperty.isSummary());
+ existingProperty.setPropertyGroupDefinition(newProperty.getPropertyGroupDefinition());
/*
* After the general things have been set, go through the subtypes of PropertyDefinition. If the new type is the
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBean.java
index a136561..ff81a6e 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBean.java
@@ -969,7 +969,8 @@ public class ResourceMetadataManagerBean implements ResourceMetadataManagerLocal
.updateConfigurationDefinition(resourceType.getPluginConfigurationDefinition(),
existingConfigurationDefinition);
- if (updateReport.getNewPropertyDefinitions().size() > 0) {
+ if (updateReport.getNewPropertyDefinitions().size() > 0 ||
+ updateReport.getUpdatedPropertyDefinitions().size() > 0) {
Subject overlord = subjectManager.getOverlord();
ResourceCriteria criteria = new ResourceCriteria();
criteria.addFilterResourceTypeId(existingType.getId());
@@ -991,6 +992,7 @@ public class ResourceMetadataManagerBean implements ResourceMetadataManagerLocal
private void updateResourcePluginConfiguration(Resource resource, ConfigurationDefinitionUpdateReport updateReport) {
Configuration pluginConfiguration = resource.getPluginConfiguration();
+ boolean modified = false;
int numberOfProperties = pluginConfiguration.getProperties().size();
ConfigurationTemplate template = updateReport.getConfigurationDefinition().getDefaultTemplate();
Configuration templateConfiguration = template.getConfiguration();
@@ -999,10 +1001,23 @@ public class ResourceMetadataManagerBean implements ResourceMetadataManagerLocal
if (propertyDef.isRequired()) {
Property templateProperty = templateConfiguration.get(propertyDef.getName());
pluginConfiguration.put(templateProperty.deepCopy(false));
+ modified = true;
}
}
- if (pluginConfiguration.getProperties().size() > numberOfProperties) {
+ for (PropertyDefinition propertyDef : updateReport.getUpdatedPropertyDefinitions()) {
+ if (propertyDef.isRequired()) {
+ String propertyValue = pluginConfiguration.getSimpleValue(propertyDef.getName(), null);
+ if (propertyValue == null) {
+ Property templateProperty = templateConfiguration.get(propertyDef.getName());
+ pluginConfiguration.put(templateProperty.deepCopy(false));
+ modified = true;
+ }
+ }
+ }
+
+// if (pluginConfiguration.getProperties().size() > numberOfProperties) {
+ if (modified) {
resource.setMtime(new Date().getTime());
}
}
13 years, 8 months
[rhq] Branch 'resource-upgrade' - 121 commits - modules/core modules/enterprise modules/helpers modules/jopr modules/plugins
by lkrejci
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/AlertCondition.java | 20
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 | 75 -
modules/core/domain/src/test/java/org/rhq/core/domain/util/StringUtilsTest.java | 47
modules/core/native-system/src/main/java/org/rhq/core/system/FileSystemInfo.java | 11
modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/ClassLoaderManager.java | 15
modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/PluginComponentFactory.java | 7
modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/PluginManager.java | 7
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java | 274 ----
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 | 122 +-
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/UserEditView.java | 2
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/AlertDataSource.java | 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertFormatUtility.java | 90 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletDataSource.java | 167 ++
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 | 8
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/GeneralPropertiesAlertDefinitionForm.java | 22
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsDataSource.java | 17
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java | 266 ++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewNotificationEditor.java | 185 +++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java | 221 +++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/RecoveryAlertDefinitionForm.java | 185 ++-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsDataSource.java | 9
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java | 20
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java | 3
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsDataSource.java | 17
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java | 2
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 | 150 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/PropertyValueChangeEvent.java | 59
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/PropertyValueChangeListener.java | 30
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/selector/AbstractSelector.java | 23
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/SubTab.java | 20
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/SubTabLayout.java | 259 ++--
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTab.java | 22
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/table/TableSection.java | 49
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/components/wizard/AbstractWizard.java | 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java | 5
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 | 596 +++++++++-
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 | 9
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/gwt/ResourceGroupGWTService.java | 7
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/RoleGWTService.java | 7
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/AbstractTwoLevelTabSetView.java | 74 +
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/ResourceGroupListView.java | 7
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupsDataSource.java | 29
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionDataSource.java | 25
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionListView.java | 93 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java | 188 +--
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 | 160 +-
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/groups/detail/inventory/ResourceGroupMembershipView.java | 16
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/ResourceGroupResourceSelector.java | 11
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupCreateWizard.java | 17
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupMembersStep.java | 2
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 | 89 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java | 1
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/NewResourceTreeView.java | 9
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java | 197 +--
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 | 274 ++--
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java | 424 ++++---
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 | 80 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/PluginConfigurationEditView.java | 81 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/ResourceResourceGroupSelector.java | 50
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/ResourceResourceGroupsView.java | 125 ++
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 | 76 -
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 | 163 +-
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/ErrorHandler.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java | 65 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/StringUtility.java | 45
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 | 78 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageBar.java | 128 ++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenter.java | 22
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenterView.java | 86 -
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 | 33
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 | 46
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/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java | 24
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/RoleGWTServiceImpl.java | 13
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 | 9
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 | 30
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/cluster/ClusterManagerBean.java | 4
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/resource/group/ResourceGroupManagerBean.java | 37
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerLocal.java | 18
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerBean.java | 14
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 | 2
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
187 files changed, 7815 insertions(+), 3166 deletions(-)
New commits:
commit e6dd8c2618a009053b06c3f63fff808fc5e64dbf
Merge: 14fd25e... 3c5a00e...
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Fri Oct 1 12:58:36 2010 +0200
Merge branch 'master' into resource-upgrade
commit 3c5a00e40f93589f3fd333502d3b0d4ffde0c743
Author: Joseph Marques <joseph(a)redhat.com>
Date: Thu Sep 30 22:19:06 2010 -0400
cosmetic - reformatting
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageBar.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageBar.java
index 242aa4b..8da5ef0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageBar.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageBar.java
@@ -82,6 +82,7 @@ public class MessageBar extends LocatableHLayout implements MessageCenter.Messag
clearMessage();
this.label = createLabel(message);
+
addMember(this.label);
markForRedraw();
commit 4288e5e7ec99e01767be54eb91a2698b2e515036
Author: Joseph Marques <joseph(a)redhat.com>
Date: Thu Sep 30 22:18:48 2010 -0400
tweak display of top/center message
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageBar.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageBar.java
index 02d3e33..242aa4b 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageBar.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageBar.java
@@ -40,8 +40,7 @@ public class MessageBar extends LocatableHLayout implements MessageCenter.Messag
private static final String LOCATOR_ID = "MessageBar";
private static final int AUTO_HIDE_DELAY_MILLIS = 30000; // 30 seconds
- private static final Map<Message.Severity, String> SEVERITY_TO_STYLE_NAME_MAP =
- new HashMap<Message.Severity, String>();
+ private static final Map<Message.Severity, String> SEVERITY_TO_STYLE_NAME_MAP = new HashMap<Message.Severity, String>();
static {
SEVERITY_TO_STYLE_NAME_MAP.put(Message.Severity.Info, "InfoBlock");
SEVERITY_TO_STYLE_NAME_MAP.put(Message.Severity.Warning, "WarnBlock");
@@ -49,8 +48,7 @@ public class MessageBar extends LocatableHLayout implements MessageCenter.Messag
SEVERITY_TO_STYLE_NAME_MAP.put(Message.Severity.Fatal, "FatalBlock");
}
- private static final Map<Message.Severity, String> SEVERITY_TO_ICON_MAP =
- new HashMap<Message.Severity, String>();
+ private static final Map<Message.Severity, String> SEVERITY_TO_ICON_MAP = new HashMap<Message.Severity, String>();
static {
SEVERITY_TO_ICON_MAP.put(Message.Severity.Info, "info/icn_info_blue.png");
SEVERITY_TO_ICON_MAP.put(Message.Severity.Warning, "info/icn_info_orange.png");
@@ -70,7 +68,6 @@ public class MessageBar extends LocatableHLayout implements MessageCenter.Messag
super.onDraw();
setWidth100();
- setAutoHeight();
setHeight(35);
setAlign(Alignment.CENTER);
@@ -112,17 +109,15 @@ public class MessageBar extends LocatableHLayout implements MessageCenter.Messag
private Label createLabel(Message message) {
Label label = new Label();
- String contents = (message.getConciseMessage() != null) ?
- message.getConciseMessage() : message.getDetailedMessage();
+ String contents = (message.getConciseMessage() != null) ? message.getConciseMessage() : message
+ .getDetailedMessage();
label.setContents(contents);
+ label.setAlign(Alignment.CENTER);
String styleName = (contents != null) ? SEVERITY_TO_STYLE_NAME_MAP.get(message.getSeverity()) : null;
label.setStyleName(styleName);
- label.setAutoHeight();
- label.setHeight(30);
- label.setAutoWidth();
- label.setWidth("75%");
+ label.setWidth(400);
String icon = (contents != null) ? SEVERITY_TO_ICON_MAP.get(message.getSeverity()) : null;
label.setIcon(icon);
commit be9e31c733dcb1e75299025ed32caa3af28584a1
Author: Joseph Marques <joseph(a)redhat.com>
Date: Thu Sep 30 19:14:57 2010 -0400
minor fixes to SearchBarPanel for maintainability
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 0d920ef..657c4d3 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
@@ -29,7 +29,6 @@ import com.smartgwt.client.widgets.form.fields.ComboBoxItem;
import com.smartgwt.client.widgets.form.fields.FormItem;
import com.smartgwt.client.widgets.form.fields.SelectItem;
import com.smartgwt.client.widgets.form.fields.SpacerItem;
-import com.smartgwt.client.widgets.form.fields.TextItem;
import com.smartgwt.client.widgets.form.fields.events.ChangedEvent;
import com.smartgwt.client.widgets.form.fields.events.ChangedHandler;
import com.smartgwt.client.widgets.grid.ListGridField;
@@ -44,6 +43,7 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
/**
* @author Greg Hinkle
+ * @author Joseph Marques
*/
public class SearchBarPane extends LocatableHLayout {
@@ -54,6 +54,31 @@ public class SearchBarPane extends LocatableHLayout {
setHeight(28);
}
+ public enum SearchType {
+ RESOURCE("Resources"), //
+ GROUP("Resource Groups");
+
+ private String displayName;
+
+ private SearchType(String displayName) {
+ this.displayName = displayName;
+ }
+
+ public String getDisplayName() {
+ return displayName;
+ }
+
+ public static String[] getValueMap() {
+ SearchType[] searchTypes = SearchType.values();
+ String[] results = new String[searchTypes.length];
+ int i = 0;
+ for (SearchType nextType : searchTypes) {
+ results[i++] = nextType.getDisplayName();
+ }
+ return results;
+ }
+ }
+
@Override
protected void onDraw() {
super.onDraw();
@@ -63,9 +88,10 @@ public class SearchBarPane extends LocatableHLayout {
form.setColWidths("120", "140", "400");
final SelectItem searchType = new SelectItem("searchType", "Search");
+ String[] valueMap = SearchType.getValueMap();
+ searchType.setValueMap(valueMap);
+ searchType.setValue(valueMap[0]);
searchType.setWidth(120);
- searchType.setValueMap("Resources", "Resource Groups"/*, "Bundles", "Packages", "Users", "Roles"*/);
- searchType.setValue("Resources");
searchType.addChangedHandler(new ChangedHandler() {
@Override
public void onChanged(ChangedEvent event) {
@@ -74,21 +100,7 @@ public class SearchBarPane extends LocatableHLayout {
});
ComboBoxItem resourceSearch = getResourceComboBox();
- resourceSearch.setShowIfCondition(new FormItemIfFunction() {
- public boolean execute(FormItem formItem, Object o, DynamicForm dynamicForm) {
- return form.getValueAsString("searchType").equals("Resources");
- }
- });
-
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);
ButtonItem search = new ButtonItem("Search", "Search");
search.setStartRow(false);
@@ -102,14 +114,7 @@ public class SearchBarPane extends LocatableHLayout {
}
private ComboBoxItem getResourceComboBox() {
-
- final ComboBoxItem comboBox = new ComboBoxItem("query", "Query");
- comboBox.setWidth(400);
- comboBox.setShowTitle(false);
- comboBox.setHint("resource search");
- comboBox.setShowHintInField(true);
-
- comboBox.setOptionDataSource(new ResourceDatasource());
+ final ComboBoxItem comboBox = getBaseComboBox(SearchType.RESOURCE);
ListGridField nameField = ResourceDataSourceField.NAME.getListGridField(250);
ListGridField descriptionField = ResourceDataSourceField.DESCRIPTION.getListGridField();
@@ -124,38 +129,13 @@ public class SearchBarPane extends LocatableHLayout {
comboBox.setValueField("id");
comboBox.setDisplayField(ResourceDataSourceField.NAME.propertyName());
- comboBox.setPickListWidth(800);
- comboBox.setTextMatchStyle(TextMatchStyle.SUBSTRING);
- comboBox.setCompleteOnTab(true);
-
- comboBox.addChangedHandler(new ChangedHandler() {
- public void onChanged(ChangedEvent changedEvent) {
- try {
- Integer resourceId = (Integer) changedEvent.getValue();
- comboBox.setValue("");
-
- String link = LinkManager.getResourceLink(resourceId);
- if (!link.contains("#")) {
- com.google.gwt.user.client.Window.Location.assign(link);
- } else {
- History.newItem(link.substring(1));
- }
- } catch (Exception e) {
- }
- }
- });
+ comboBox.setOptionDataSource(new ResourceDatasource());
return comboBox;
}
private ComboBoxItem getGroupComboBox() {
- final ComboBoxItem comboBox = new ComboBoxItem("query", "Query");
- comboBox.setWidth(400);
- comboBox.setShowTitle(false);
- comboBox.setHint("group search");
- comboBox.setShowHintInField(true);
-
- comboBox.setOptionDataSource(new ResourceGroupsDataSource());
+ final ComboBoxItem comboBox = getBaseComboBox(SearchType.GROUP);
ListGridField nameField = ResourceGroupDataSourceField.NAME.getListGridField(250);
ListGridField descriptionField = ResourceGroupDataSourceField.DESCRIPTION.getListGridField();
@@ -167,27 +147,57 @@ public class SearchBarPane extends LocatableHLayout {
comboBox.setValueField("id");
comboBox.setDisplayField(ResourceGroupDataSourceField.NAME.propertyName());
+ comboBox.setOptionDataSource(new ResourceGroupsDataSource());
+
+ return comboBox;
+ }
+
+ private ComboBoxItem getBaseComboBox(final SearchType searchType) {
+ final ComboBoxItem comboBox = new ComboBoxItem("query", "Query");
+ comboBox.setWidth(400);
+ comboBox.setShowTitle(false);
+ comboBox.setHint("search");
+ comboBox.setShowHintInField(true);
+
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) {
+ //System.out.println("ChangedEvent: " + changedEvent.getValue());
+
+ Object intermediate = changedEvent.getValue();
+ if (!(intermediate instanceof Integer)) {
+ return;
+ }
+
+ Integer id = (Integer) changedEvent.getValue();
+ comboBox.setValue("");
+
+ String link = null;
+ if (searchType == SearchType.RESOURCE) {
+ link = LinkManager.getResourceLink(id);
+ } else if (searchType == SearchType.GROUP) {
+ link = LinkManager.getResourceGroupLink(id);
+ } else {
+ throw new IllegalArgumentException("There is no global search type for " + searchType);
+ }
+
+ if (!link.contains("#")) {
+ com.google.gwt.user.client.Window.Location.assign(link);
+ } else {
+ History.newItem(link.substring(1));
}
}
});
+ comboBox.setShowIfCondition(new FormItemIfFunction() {
+ public boolean execute(FormItem formItem, Object o, DynamicForm dynamicForm) {
+ return dynamicForm.getValueAsString("searchType").equals(searchType.getDisplayName());
+ }
+ });
+
return comboBox;
}
commit acf0d09358c36e094bb041ebf5106a921009a51a
Author: Joseph Marques <joseph(a)redhat.com>
Date: Thu Sep 30 17:30:43 2010 -0400
prevent exceptions when using integer-based filters that might pass empty string instead of null
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 1184697..a717108 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
@@ -286,7 +286,7 @@ public abstract class RPCDataSource<T> extends DataSource {
S result = null;
Object value = criteriaMap.get(paramName);
- if (value == null) {
+ if (value == null || value.toString().equals("")) {
// nothing to do, result is already null
} else {
String strValue = value.toString();
commit 3f5cc3fd0018b723b4082e9f31b20d94bed328c8
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Thu Sep 30 21:55:29 2010 -0400
implement v2 of the new MessageCenter API; fix a few bugs in resource and plugin config relating to authz checking and to Save button
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java
index 5e66764..9aaa0e9 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java
@@ -39,7 +39,7 @@ import org.rhq.enterprise.gui.coregui.client.CoreGUI;
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.inventory.resource.type.ResourceTypeRepository.MetadataType;
-import org.rhq.enterprise.gui.coregui.client.util.message.TransientMessage;
+import org.rhq.enterprise.gui.coregui.client.util.message.Message;
import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity;
/**
@@ -129,13 +129,13 @@ public class ResourceAlertDefinitionsView extends AbstractAlertDefinitionsView {
@Override
public void onSuccess(Integer result) {
CoreGUI.getMessageCenter().notify(
- new TransientMessage("[" + result + "] alert definitions enabled", Severity.Info));
+ new Message("[" + result + "] alert definitions enabled.", Severity.Info));
ResourceAlertDefinitionsView.this.refresh();
}
@Override
public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleTransientError("Failed to enable alert definitions", caught);
+ CoreGUI.getErrorHandler().handleError("Failed to enable alert definitions", caught);
}
});
}
@@ -156,13 +156,13 @@ public class ResourceAlertDefinitionsView extends AbstractAlertDefinitionsView {
@Override
public void onSuccess(Integer result) {
CoreGUI.getMessageCenter().notify(
- new TransientMessage("[" + result + "] alert definitions disabled", Severity.Info));
+ new Message("[" + result + "] alert definitions disabled.", Severity.Info));
ResourceAlertDefinitionsView.this.refresh();
}
@Override
public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleTransientError("Failed to disable alert definitions", caught);
+ CoreGUI.getErrorHandler().handleError("Failed to disable alert definitions.", caught);
}
});
}
@@ -183,13 +183,13 @@ public class ResourceAlertDefinitionsView extends AbstractAlertDefinitionsView {
@Override
public void onSuccess(Integer result) {
CoreGUI.getMessageCenter().notify(
- new TransientMessage("[" + result + "] alert definitions deleted", Severity.Info));
+ new Message("[" + result + "] alert definitions deleted.", Severity.Info));
ResourceAlertDefinitionsView.this.refresh();
}
@Override
public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleTransientError("Failed to delete alert definitions", caught);
+ CoreGUI.getErrorHandler().handleError("Failed to delete alert definitions.", caught);
}
});
}
@@ -202,13 +202,13 @@ public class ResourceAlertDefinitionsView extends AbstractAlertDefinitionsView {
@Override
public void onSuccess(Integer result) {
CoreGUI.getMessageCenter().notify(
- new TransientMessage("Alert definition is created", Severity.Info));
+ new Message("Alert definition is created", Severity.Info));
alertDefinition.setId(result.intValue());
}
@Override
public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleTransientError("Failed to create alert definition", caught);
+ CoreGUI.getErrorHandler().handleError("Failed to create alert definition.", caught);
}
});
} else {
@@ -217,12 +217,12 @@ public class ResourceAlertDefinitionsView extends AbstractAlertDefinitionsView {
@Override
public void onSuccess(AlertDefinition result) {
CoreGUI.getMessageCenter().notify(
- new TransientMessage("Alert definition is updated", Severity.Info));
+ new Message("Alert definition is updated.", Severity.Info));
}
@Override
public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleTransientError("Failed to update alert definition", caught);
+ CoreGUI.getErrorHandler().handleError("Failed to update alert definition.", caught);
}
});
}
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 544ded9..eb1e2d2 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
@@ -159,8 +159,8 @@ public class ConfigurationEditor extends LocatableVLayout {
private boolean readOnly = false;
private Set<String> invalidPropertyNames = new HashSet<String>();
- private Set<ValidationStateChangeListener> validationStateChangeListeners =
- new HashSet<ValidationStateChangeListener>();
+ private Set<PropertyValueChangeListener> validationStateChangeListeners =
+ new HashSet<PropertyValueChangeListener>();
public static enum ConfigType {
plugin, resource
@@ -218,7 +218,7 @@ public class ConfigurationEditor extends LocatableVLayout {
return this.valuesManager.hasErrors();
}
- public void addValidationStateChangeListener(ValidationStateChangeListener validationStateChangeListener) {
+ public void addValidationStateChangeListener(PropertyValueChangeListener validationStateChangeListener) {
this.validationStateChangeListeners.add(validationStateChangeListener);
}
@@ -250,11 +250,11 @@ public class ConfigurationEditor extends LocatableVLayout {
EnumSet.of(ResourceTypeRepository.MetadataType.resourceConfigurationDefinition),
new ResourceTypeRepository.TypesLoadedCallback() {
public void onTypesLoaded(Map<Integer, ResourceType> types) {
- System.out.println("ConfigDef retreived in: " + (System.currentTimeMillis() - start));
+ //System.out.println("ConfigDef retreived in: " + (System.currentTimeMillis() - start));
definition = types.get(resourceTypeId).getResourceConfigurationDefinition();
if (definition == null) {
loadingLabel.hide();
- showError("No configuration supported for this resource");
+ showError("Configuration is not supported by this Resource.");
}
reload();
}
@@ -276,10 +276,10 @@ public class ConfigurationEditor extends LocatableVLayout {
EnumSet.of(ResourceTypeRepository.MetadataType.pluginConfigurationDefinition),
new ResourceTypeRepository.TypesLoadedCallback() {
public void onTypesLoaded(Map<Integer, ResourceType> types) {
- System.out.println("ConfigDef retreived in: " + (System.currentTimeMillis() - start));
+ //System.out.println("ConfigDef retreived in: " + (System.currentTimeMillis() - start));
definition = types.get(resourceTypeId).getPluginConfigurationDefinition();
if (definition == null) {
- showError("No configuration supported for this resource");
+ showError("Connection settings are not supported by this Resource.");
}
reload();
}
@@ -556,6 +556,10 @@ public class ConfigurationEditor extends LocatableVLayout {
}
}
+ public Set<String> getInvalidPropertyNames() {
+ return this.invalidPropertyNames;
+ }
+
private void buildMapsField(ArrayList<FormItem> fields, PropertyDefinitionMap propertyDefinitionMap,
PropertyMap propertyMap) {
// create the property grid
@@ -564,7 +568,7 @@ public class ConfigurationEditor extends LocatableVLayout {
propertyGrid.getValuesField().setName("Value");
// create the editors
- HashMap<String, FormItem> editorsMap = new HashMap<String, FormItem>();
+ Map<String, FormItem> editorsMap = new HashMap<String, FormItem>();
TextItem textEditor = new TextItem();
editorsMap.put("simpleText", textEditor);
@@ -768,8 +772,8 @@ public class ConfigurationEditor extends LocatableVLayout {
return record;
}
- private FormItem buildSimpleField(ArrayList<FormItem> fields, PropertyDefinitionSimple propertyDefinition,
- boolean oddRow, Property property) {
+ private FormItem buildSimpleField(ArrayList<FormItem> fields, final PropertyDefinitionSimple propertyDefinition,
+ boolean oddRow, final Property property) {
final PropertySimple propertySimple = (PropertySimple) property;
FormItem valueItem = null;
@@ -887,10 +891,11 @@ public class ConfigurationEditor extends LocatableVLayout {
ConfigurationEditor.this.invalidPropertyNames.add(propertySimple.getName());
}
boolean isValidNow = ConfigurationEditor.this.invalidPropertyNames.isEmpty();
- if (isValidNow != wasValidBefore) {
- for (ValidationStateChangeListener validationStateChangeListener : ConfigurationEditor.this.validationStateChangeListeners) {
- validationStateChangeListener.validationStateChanged(isValidNow);
- }
+ boolean validationStateChanged = (isValidNow != wasValidBefore);
+ for (PropertyValueChangeListener validationStateChangeListener : ConfigurationEditor.this.validationStateChangeListeners) {
+ PropertyValueChangeEvent event = new PropertyValueChangeEvent(property, propertyDefinition,
+ validationStateChanged, ConfigurationEditor.this.invalidPropertyNames);
+ validationStateChangeListener.propertyValueChanged(event);
}
}
});
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/PropertyValueChangeEvent.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/PropertyValueChangeEvent.java
new file mode 100644
index 0000000..2ba852d
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/PropertyValueChangeEvent.java
@@ -0,0 +1,59 @@
+/*
+ * 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;
+
+import java.util.Set;
+
+import org.rhq.core.domain.configuration.Property;
+import org.rhq.core.domain.configuration.definition.PropertyDefinition;
+
+/**
+ * @author Ian Springer
+ */
+public class PropertyValueChangeEvent {
+ private Property property;
+ private PropertyDefinition propertyDefinition;
+ private boolean validationStateChanged;
+ private Set<String> invalidPropertyNames;
+
+ public PropertyValueChangeEvent(Property property, PropertyDefinition propertyDefinition, boolean validationStatechanged,
+ Set<String> invalidPropertyNames) {
+ this.property = property;
+ this.propertyDefinition = propertyDefinition;
+ this.validationStateChanged = validationStatechanged;
+ this.invalidPropertyNames = invalidPropertyNames;
+ }
+
+ public Property getProperty() {
+ return property;
+ }
+
+ public PropertyDefinition getPropertyDefinition() {
+ return propertyDefinition;
+ }
+
+ public boolean isValidationStateChanged() {
+ return validationStateChanged;
+ }
+
+ public Set<String> getInvalidPropertyNames() {
+ return invalidPropertyNames;
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/PropertyValueChangeListener.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/PropertyValueChangeListener.java
new file mode 100644
index 0000000..0ed46f4
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/PropertyValueChangeListener.java
@@ -0,0 +1,30 @@
+/*
+ * 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;
+
+/**
+ * A listener that can register to be notified by a {@link ConfigurationEditor} when a configuration property's value
+ * changes.
+ *
+ * @author Ian Springer
+ */
+public interface PropertyValueChangeListener {
+ void propertyValueChanged(PropertyValueChangeEvent event);
+}
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
deleted file mode 100644
index 154c731..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ValidationStateChangeListener.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright 2010, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.coregui.client.components.configuration;
-
-/**
- * @author Ian Springer
- */
-public interface ValidationStateChangeListener {
- void validationStateChanged(boolean isValid);
-}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupCreateWizard.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupCreateWizard.java
index 1008b83..4e66027 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupCreateWizard.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupCreateWizard.java
@@ -37,7 +37,6 @@ import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGroupGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.inventory.groups.ResourceGroupListView;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
-import org.rhq.enterprise.gui.coregui.client.util.message.TransientMessage;
/**
* A wizard for creating a new Resource group.
@@ -92,13 +91,11 @@ public class GroupCreateWizard extends AbstractWizard {
public void onSuccess(ResourceGroup result) {
String groupUrl = LinkManager.getResourceGroupLink(result.getId());
- CoreGUI.getMessageCenter().notify(
- new TransientMessage("Resource group created. [<a href='" + groupUrl + "'>View Group</a>]",
- Message.Severity.Info));
- CoreGUI.getMessageCenter().notify(
- new Message("Created new " + result.getGroupCategory().name().toLowerCase() + " Resource group '"
- + result.getName() + "' with " + memberStep.getSelectedResourceIds().length + " members.",
- Message.Severity.Info));
+ String conciseMessage = "Resource group created. [<a href='" + groupUrl + "'>View Group</a>]";
+ String detailedMessage =
+ "Created new " + result.getGroupCategory().name().toLowerCase() + " Resource group '"
+ + result.getName() + "' with " + memberStep.getSelectedResourceIds().length + " members.";
+ CoreGUI.getMessageCenter().notify(new Message(conciseMessage, detailedMessage));
resourceGroupListView.refresh();
}
});
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 b002f0b..f5afb2c 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
@@ -18,6 +18,8 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.configuration;
+import java.util.EnumSet;
+
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.widgets.IButton;
@@ -33,19 +35,21 @@ import org.rhq.core.domain.resource.composite.ResourceComposite;
import org.rhq.core.domain.resource.composite.ResourcePermission;
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.components.configuration.PropertyValueChangeEvent;
+import org.rhq.enterprise.gui.coregui.client.components.configuration.PropertyValueChangeListener;
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.MessageCenter;
-import org.rhq.enterprise.gui.coregui.client.util.message.TransientMessage;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIButton;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
/**
+ * A view for editing a Resource's configuration.
+ *
* @author Greg Hinkle
* @author Ian Springer
*/
-public class ResourceConfigurationEditView extends LocatableVLayout implements ValidationStateChangeListener {
+public class ResourceConfigurationEditView extends LocatableVLayout implements PropertyValueChangeListener {
private Resource resource;
private ResourcePermission resourcePermission;
private ConfigurationEditor editor;
@@ -76,20 +80,30 @@ public class ResourceConfigurationEditView extends LocatableVLayout implements V
save();
}
});
- this.saveButton.disable();
toolStrip.addMember(saveButton);
+
+ addMember(toolStrip);
+ reloadConfiguration();
- editor = new ConfigurationEditor(this.getLocatorId(), resource.getId(), resource.getResourceType().getId());
+ if (!this.resourcePermission.isConfigureWrite()) {
+ Message message = new Message("You do not have permission to edit this Resource's configuration.",
+ Message.Severity.Info, EnumSet.of(Message.Option.Transient, Message.Option.Sticky));
+ CoreGUI.getMessageCenter().notify(message);
+ }
+ }
+
+ private void reloadConfiguration() {
+ this.saveButton.disable();
+ if (editor != null) {
+ editor.destroy();
+ removeMember(editor);
+ }
+ editor = new ConfigurationEditor(this.extendLocatorId("Editor"), resource.getId(),
+ resource.getResourceType().getId());
editor.setOverflow(Overflow.AUTO);
editor.addValidationStateChangeListener(this);
editor.setReadOnly(!this.resourcePermission.isConfigureWrite());
-
- addMember(toolStrip);
addMember(editor);
-
- Message message = new TransientMessage("You do not have permission to edit this Resource's configuration.",
- Message.Severity.Info, true);
- CoreGUI.getMessageCenter().notify(message);
}
private void save() {
@@ -103,24 +117,31 @@ public class ResourceConfigurationEditView extends LocatableVLayout implements V
public void onSuccess(ResourceConfigurationUpdate result) {
CoreGUI.getMessageCenter().notify(
- new Message("Configuration updated for Resource [" + resource.getName() + "].",
+ new Message("Configuration updated.",
+ "Configuration updated for Resource [" + resource.getName() + "].",
Message.Severity.Info));
-
+ reloadConfiguration();
}
});
}
@Override
- public void validationStateChanged(boolean isValid) {
+ public void propertyValueChanged(PropertyValueChangeEvent event) {
MessageCenter messageCenter = CoreGUI.getMessageCenter();
Message message;
- if (isValid) {
- this.saveButton.enable();
- message = new TransientMessage("All configuration properties now have valid values, so the configuration can now be saved.", Message.Severity.Info);
+ if (event.isValidationStateChanged()) {
+ if (event.getInvalidPropertyNames().isEmpty()) {
+ this.saveButton.enable();
+ message = new Message("All configuration properties now have valid values, so the configuration can now be saved.",
+ Message.Severity.Info, EnumSet.of(Message.Option.Transient));
+ } else {
+ this.saveButton.disable();
+ message = new Message("One or more configuration properties have invalid values. The values must be corrected before the configuration can be saved.",
+ Message.Severity.Error, EnumSet.of(Message.Option.Transient, Message.Option.Sticky));
+ }
+ messageCenter.notify(message);
} else {
- this.saveButton.disable();
- message = new TransientMessage("One or more configuration properties have invalid values. The values must be corrected before the configuration can be saved.", Message.Severity.Error, true);
+ this.saveButton.enable();
}
- messageCenter.notify(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 1483cfa..4556da0 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
@@ -18,6 +18,8 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.inventory;
+import java.util.EnumSet;
+
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.widgets.events.ClickEvent;
@@ -32,19 +34,21 @@ import org.rhq.core.domain.resource.composite.ResourceComposite;
import org.rhq.core.domain.resource.composite.ResourcePermission;
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.components.configuration.PropertyValueChangeEvent;
+import org.rhq.enterprise.gui.coregui.client.components.configuration.PropertyValueChangeListener;
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.MessageCenter;
-import org.rhq.enterprise.gui.coregui.client.util.message.TransientMessage;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIButton;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
/**
+ * A view for editing a Resource's plugin configuration (aka connection settings).
+ *
* @author Greg Hinkle
* @author Ian Springer
*/
-public class PluginConfigurationEditView extends LocatableVLayout implements ValidationStateChangeListener {
+public class PluginConfigurationEditView extends LocatableVLayout implements PropertyValueChangeListener {
private Resource resource;
private ResourcePermission resourcePermission;
private ConfigurationEditor editor;
@@ -76,20 +80,30 @@ public class PluginConfigurationEditView extends LocatableVLayout implements Val
}
});
this.saveButton.disable();
- toolStrip.addMember(saveButton);
+ toolStrip.addMember(this.saveButton);
+
+ addMember(toolStrip);
+ reloadConfiguration();
+
+ if (!this.resourcePermission.isInventory()) {
+ Message message = new Message("You do not have permission to edit this Resource's connection settings.",
+ Message.Severity.Info, EnumSet.of(Message.Option.Transient));
+ CoreGUI.getMessageCenter().notify(message);
+ }
+ }
- editor = new ConfigurationEditor(this.getLocatorId(), resource.getId(), resource.getResourceType().getId(),
- ConfigurationEditor.ConfigType.plugin);
+ private void reloadConfiguration() {
+ this.saveButton.disable();
+ if (editor != null) {
+ editor.destroy();
+ removeMember(editor);
+ }
+ editor = new ConfigurationEditor(extendLocatorId("Editor"), resource.getId(),
+ resource.getResourceType().getId(), ConfigurationEditor.ConfigType.plugin);
editor.setOverflow(Overflow.AUTO);
editor.addValidationStateChangeListener(this);
editor.setReadOnly(!this.resourcePermission.isInventory());
-
- addMember(toolStrip);
addMember(editor);
-
- Message message = new TransientMessage("You do not have permission to edit this Resource's connection properties.",
- Message.Severity.Info, true);
- CoreGUI.getMessageCenter().notify(message);
}
private void save() {
@@ -103,24 +117,31 @@ public class PluginConfigurationEditView extends LocatableVLayout implements Val
public void onSuccess(PluginConfigurationUpdate result) {
CoreGUI.getMessageCenter().notify(
- new Message("Connection settings updated for Resource [" + resource.getName() + "].",
+ new Message("Connection settings updated.",
+ "Connection settings updated for Resource [" + resource.getName() + "].",
Message.Severity.Info));
-
+ reloadConfiguration();
}
});
}
@Override
- public void validationStateChanged(boolean isValid) {
+ public void propertyValueChanged(PropertyValueChangeEvent event) {
MessageCenter messageCenter = CoreGUI.getMessageCenter();
Message message;
- if (isValid) {
- this.saveButton.enable();
- message = new TransientMessage("All connection properties now have valid values, so the configuration can now be saved.", Message.Severity.Info);
+ if (event.isValidationStateChanged()) {
+ if (event.getInvalidPropertyNames().isEmpty()) {
+ this.saveButton.enable();
+ message = new Message("All connection settings now have valid values, so the settings can now be saved.",
+ Message.Severity.Info, EnumSet.of(Message.Option.Transient));
+ } else {
+ this.saveButton.disable();
+ message = new Message("One or more connection settings have invalid values. The values must be corrected before the settings can be saved.",
+ Message.Severity.Error, EnumSet.of(Message.Option.Transient, Message.Option.Sticky));
+ }
+ messageCenter.notify(message);
} else {
- this.saveButton.disable();
- message = new TransientMessage("One or more connection properties have invalid values. The values must be corrected before the configuration can be saved.", Message.Severity.Error, true);
+ this.saveButton.enable();
}
- messageCenter.notify(message);
}
}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/ErrorHandler.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/ErrorHandler.java
index 6e5f80b..49bb67e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/ErrorHandler.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/ErrorHandler.java
@@ -20,31 +20,21 @@ package org.rhq.enterprise.gui.coregui.client.util;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
-import org.rhq.enterprise.gui.coregui.client.util.message.TransientMessage;
/**
* @author Greg Hinkle
*/
public class ErrorHandler {
-
public void handleError(String message) {
handleError(message, null);
}
public void handleError(String message, Throwable t) {
- Message errorMessage = new Message(message, (t == null) ? null : t.toString(), Message.Severity.Error);
- CoreGUI.getMessageCenter().notify(errorMessage);
-
- if (t != null) {
- t.printStackTrace();
- }
- }
-
- public void handleTransientError(String message, Throwable t) {
- Message errorMessage = new TransientMessage(message, (t == null) ? null : t.toString(), Message.Severity.Error);
+ Message errorMessage = new Message(message, (t == null) ? null : t.toString(), Message.Severity.Fatal);
CoreGUI.getMessageCenter().notify(errorMessage);
if (t != null) {
+ System.err.println(message);
t.printStackTrace();
}
}
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 97cc7ab..429ef36 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
@@ -19,36 +19,55 @@
package org.rhq.enterprise.gui.coregui.client.util.message;
import java.util.Date;
+import java.util.EnumSet;
/**
+ * A message to be displayed to the user in one or more places.
+ *
* @author Greg Hinkle
+ * @author Ian Springer
*/
@SuppressWarnings({"UnnecessarySemicolon"})
public class Message {
- protected String title;
- protected String detail;
+ protected String conciseMessage;
+ protected String detailedMessage;
protected Date fired = new Date();
protected Severity severity;
+ protected EnumSet<Option> options;
// TODO: Add Debug severity?
- public enum Severity { Info, Warning, Error };
+ public enum Severity { Info, Warning, Error, Fatal };
+ public enum Option { Transient, Sticky, BackgroundJobResult };
+
+ public Message(String conciseMessage, Severity severity) {
+ this(conciseMessage, null, severity);
+ }
+
+ public Message(String conciseMessage, String detailedMessage) {
+ this(conciseMessage, detailedMessage, null);
+ }
+
+ public Message(String conciseMessage, String detailedMessage, Severity severity) {
+ this(conciseMessage, detailedMessage, severity, null);
+ }
- public Message(String title, Severity severity) {
- this(title, null, severity);
+ public Message(String conciseMessage, Severity severity, EnumSet<Option> options) {
+ this(conciseMessage, null, severity, options);
}
- public Message(String title, String detail, Severity severity) {
- this.title = title;
- this.detail = detail;
+ public Message(String conciseMessage, String detailedMessage, Severity severity, EnumSet<Option> options) {
+ this.conciseMessage = conciseMessage;
+ this.detailedMessage = detailedMessage;
this.severity = (severity != null) ? severity : Severity.Info;
+ this.options = (options != null) ? options : EnumSet.noneOf(Option.class);
}
- public String getTitle() {
- return title;
+ public String getConciseMessage() {
+ return conciseMessage;
}
- public String getDetail() {
- return detail;
+ public String getDetailedMessage() {
+ return detailedMessage;
}
public Date getFired() {
@@ -59,13 +78,26 @@ public class Message {
return severity;
}
+ public boolean isTransient() {
+ return options.contains(Option.Transient);
+ }
+
+ public boolean isSticky() {
+ return options.contains(Option.Sticky);
+ }
+
+ public boolean isBackgroundJobResult() {
+ return options.contains(Option.BackgroundJobResult);
+ }
+
@Override
public String toString() {
return "Message{" +
- "title='" + title + '\'' +
- ", detail='" + detail + '\'' +
- ", fired=" + fired +
- ", severity=" + severity +
+ "conciseMessage='" + this.conciseMessage + '\'' +
+ ", detailedMessage='" + this.detailedMessage + '\'' +
+ ", fired=" + this.fired +
+ ", severity=" + this.severity +
+ ", options=" + this.options +
'}';
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageBar.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageBar.java
index b03499f..02d3e33 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageBar.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageBar.java
@@ -46,6 +46,7 @@ public class MessageBar extends LocatableHLayout implements MessageCenter.Messag
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");
+ SEVERITY_TO_STYLE_NAME_MAP.put(Message.Severity.Fatal, "FatalBlock");
}
private static final Map<Message.Severity, String> SEVERITY_TO_ICON_MAP =
@@ -70,7 +71,7 @@ public class MessageBar extends LocatableHLayout implements MessageCenter.Messag
setWidth100();
setAutoHeight();
- setHeight(40);
+ setHeight(35);
setAlign(Alignment.CENTER);
@@ -79,18 +80,16 @@ public class MessageBar extends LocatableHLayout implements MessageCenter.Messag
@Override
public void onMessage(Message message) {
- if (message instanceof TransientMessage) {
- TransientMessage transientMessage = (TransientMessage)message;
-
+ if (!message.isBackgroundJobResult()) {
// First clear any previous message.
clearMessage();
- this.label = createLabel(transientMessage);
- addMember(this.label);
+ this.label = createLabel(message);
+ addMember(this.label);
markForRedraw();
// Auto-clear the message after 30 seconds unless it's been designated as sticky.
- if (!transientMessage.isSticky()) {
+ if (!message.isSticky()) {
Timer hideTimer = new Timer() {
@Override
public void run() {
@@ -113,17 +112,15 @@ public class MessageBar extends LocatableHLayout implements MessageCenter.Messag
private Label createLabel(Message message) {
Label label = new Label();
- String contents = message.getTitle();
- if (message.getDetail() != null) {
- contents += ": " + message.getDetail();
- }
+ String contents = (message.getConciseMessage() != null) ?
+ message.getConciseMessage() : message.getDetailedMessage();
label.setContents(contents);
String styleName = (contents != null) ? SEVERITY_TO_STYLE_NAME_MAP.get(message.getSeverity()) : null;
label.setStyleName(styleName);
label.setAutoHeight();
- label.setHeight(35);
+ label.setHeight(30);
label.setAutoWidth();
label.setWidth("75%");
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenter.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenter.java
index a3c29dd..a9070b1 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenter.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenter.java
@@ -29,12 +29,14 @@ public class MessageCenter {
private LinkedList<Message> messages = new LinkedList<Message>();
private List<MessageListener> listeners = new ArrayList<MessageListener>();
- private static final int MAX_MESSAGES = 100;
+ private static final int MAX_MESSAGES = 50;
public void notify(Message message) {
- this.messages.add(message);
- if (messages.size() > MAX_MESSAGES) {
- messages.removeFirst();
+ if (!message.isTransient()) {
+ this.messages.add(message);
+ if (messages.size() > MAX_MESSAGES) {
+ messages.removeFirst();
+ }
}
for (MessageListener listener : listeners) {
listener.onMessage(message);
@@ -45,6 +47,11 @@ public class MessageCenter {
this.listeners.add(listener);
}
+ /**
+ * Returns a list of recently published non-transient messages.
+ *
+ * @return a list of recently published non-transient messages
+ */
public List<Message> getMessages() {
return messages;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenterView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenterView.java
index 5d81646..d51bc47 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenterView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenterView.java
@@ -86,7 +86,7 @@ public class MessageCenterView extends LocatableHLayout implements MessageCenter
MenuItem[] items = new MenuItem[messages.size()];
for (int i = 0, messagesSize = messages.size(); i < messagesSize; i++) {
final Message message = messages.get(i);
- MenuItem messageItem = new MenuItem(message.title, getSeverityIcon(message.severity));
+ MenuItem messageItem = new MenuItem(message.conciseMessage, getSeverityIcon(message.severity));
items[i] = messageItem;
@@ -116,7 +116,7 @@ public class MessageCenterView extends LocatableHLayout implements MessageCenter
form.setWrapItemTitles(false);
StaticTextItem title = new StaticTextItem("title", "Title");
- title.setValue(message.title);
+ title.setValue(message.conciseMessage);
StaticTextItem severity = new StaticTextItem("severity", "Severity");
FormItemIcon severityIcon = new FormItemIcon();
@@ -129,7 +129,7 @@ public class MessageCenterView extends LocatableHLayout implements MessageCenter
StaticTextItem detail = new StaticTextItem("detail", "Detail");
detail.setTitleOrientation(TitleOrientation.TOP);
- detail.setValue(message.detail);
+ detail.setValue(message.detailedMessage);
detail.setColSpan(2);
ButtonItem okButton = new ButtonItem("Ok", "Ok");
@@ -139,7 +139,7 @@ public class MessageCenterView extends LocatableHLayout implements MessageCenter
form.setItems(title, severity, date, detail, okButton);
final Window window = new LocatableWindow(this.extendLocatorId("Message"));
- window.setTitle(message.title);
+ window.setTitle(message.conciseMessage);
window.setWidth(600);
window.setHeight(400);
window.setIsModal(true);
@@ -157,8 +157,8 @@ public class MessageCenterView extends LocatableHLayout implements MessageCenter
}
public void onMessage(final Message message) {
- if (!(message instanceof TransientMessage)) {
- final Label label = new Label(message.title);
+ if (!message.isTransient()) {
+ final Label label = new Label(message.conciseMessage);
label.setMargin(5);
label.setAutoFit(true);
label.setHeight(25);
@@ -168,7 +168,7 @@ public class MessageCenterView extends LocatableHLayout implements MessageCenter
label.setIcon(iconSrc);
- label.setTooltip(message.detail);
+ label.setTooltip(message.detailedMessage);
label.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent clickEvent) {
@@ -196,13 +196,14 @@ public class MessageCenterView extends LocatableHLayout implements MessageCenter
private String getSeverityIcon(Message.Severity severity) {
String iconSrc = null;
switch (severity) {
- case Info:
+ case Info:
iconSrc = "info/icn_info_blue.png";
break;
- case Warning:
+ case Warning:
iconSrc = "info/icn_info_orange.png";
break;
- case Error:
+ case Error:
+ case Fatal:
iconSrc = "info/icn_info_red.png";
break;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/TransientMessage.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/TransientMessage.java
deleted file mode 100644
index 318c4a5..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/TransientMessage.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright 2010, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.coregui.client.util.message;
-
-/**
- * @author Ian Springer
- */
-public class TransientMessage extends Message {
- private boolean sticky;
-
- public TransientMessage(String title, Severity severity) {
- super(title, severity);
- }
-
- public TransientMessage(String title, String detail, Severity severity) {
- super(title, detail, severity);
- }
-
- public TransientMessage(String title, Severity severity, boolean sticky) {
- this(title, null, severity, sticky);
- }
-
- public TransientMessage(String title, String detail, Severity severity, boolean sticky) {
- super(title, detail, severity);
- this.sticky = sticky;
- }
-
- public boolean isSticky() {
- return this.sticky;
- }
-}
commit dd8fc9bcd360542eb8933be9c34995d06e638fcb
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Sep 30 17:28:16 2010 -0400
write transient messages when enabling/disabling/creating alert defs
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java
index cbf368d..5e66764 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java
@@ -39,7 +39,7 @@ import org.rhq.enterprise.gui.coregui.client.CoreGUI;
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.inventory.resource.type.ResourceTypeRepository.MetadataType;
-import org.rhq.enterprise.gui.coregui.client.util.message.Message;
+import org.rhq.enterprise.gui.coregui.client.util.message.TransientMessage;
import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity;
/**
@@ -129,13 +129,13 @@ public class ResourceAlertDefinitionsView extends AbstractAlertDefinitionsView {
@Override
public void onSuccess(Integer result) {
CoreGUI.getMessageCenter().notify(
- new Message("[" + result + "] alert definitions enabled", Severity.Info));
+ new TransientMessage("[" + result + "] alert definitions enabled", Severity.Info));
ResourceAlertDefinitionsView.this.refresh();
}
@Override
public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to enable alert definitions", caught);
+ CoreGUI.getErrorHandler().handleTransientError("Failed to enable alert definitions", caught);
}
});
}
@@ -156,13 +156,13 @@ public class ResourceAlertDefinitionsView extends AbstractAlertDefinitionsView {
@Override
public void onSuccess(Integer result) {
CoreGUI.getMessageCenter().notify(
- new Message("[" + result + "] alert definitions disabled", Severity.Info));
+ new TransientMessage("[" + result + "] alert definitions disabled", Severity.Info));
ResourceAlertDefinitionsView.this.refresh();
}
@Override
public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to disable alert definitions", caught);
+ CoreGUI.getErrorHandler().handleTransientError("Failed to disable alert definitions", caught);
}
});
}
@@ -183,13 +183,13 @@ public class ResourceAlertDefinitionsView extends AbstractAlertDefinitionsView {
@Override
public void onSuccess(Integer result) {
CoreGUI.getMessageCenter().notify(
- new Message("[" + result + "] alert definitions deleted", Severity.Info));
+ new TransientMessage("[" + result + "] alert definitions deleted", Severity.Info));
ResourceAlertDefinitionsView.this.refresh();
}
@Override
public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to delete alert definitions", caught);
+ CoreGUI.getErrorHandler().handleTransientError("Failed to delete alert definitions", caught);
}
});
}
@@ -201,13 +201,14 @@ public class ResourceAlertDefinitionsView extends AbstractAlertDefinitionsView {
Integer.valueOf(resource.getId()), new AsyncCallback<Integer>() {
@Override
public void onSuccess(Integer result) {
- CoreGUI.getMessageCenter().notify(new Message("Alert definition is created", Severity.Info));
+ CoreGUI.getMessageCenter().notify(
+ new TransientMessage("Alert definition is created", Severity.Info));
alertDefinition.setId(result.intValue());
}
@Override
public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to create alert definition", caught);
+ CoreGUI.getErrorHandler().handleTransientError("Failed to create alert definition", caught);
}
});
} else {
@@ -215,12 +216,13 @@ public class ResourceAlertDefinitionsView extends AbstractAlertDefinitionsView {
alertDefinition, true, new AsyncCallback<AlertDefinition>() {
@Override
public void onSuccess(AlertDefinition result) {
- CoreGUI.getMessageCenter().notify(new Message("Alert definition is updated", Severity.Info));
+ CoreGUI.getMessageCenter().notify(
+ new TransientMessage("Alert definition is updated", Severity.Info));
}
@Override
public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to update alert definition", caught);
+ CoreGUI.getErrorHandler().handleTransientError("Failed to update alert definition", caught);
}
});
}
commit b3cf656d35e05a0c0b1130f994747900596a8f0e
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Sep 30 17:27:56 2010 -0400
provide a convienence method to write out a transient error message
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/ErrorHandler.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/ErrorHandler.java
index d410c54..6e5f80b 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/ErrorHandler.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/ErrorHandler.java
@@ -20,6 +20,7 @@ package org.rhq.enterprise.gui.coregui.client.util;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
+import org.rhq.enterprise.gui.coregui.client.util.message.TransientMessage;
/**
* @author Greg Hinkle
@@ -38,4 +39,13 @@ public class ErrorHandler {
t.printStackTrace();
}
}
+
+ public void handleTransientError(String message, Throwable t) {
+ Message errorMessage = new TransientMessage(message, (t == null) ? null : t.toString(), Message.Severity.Error);
+ CoreGUI.getMessageCenter().notify(errorMessage);
+
+ if (t != null) {
+ t.printStackTrace();
+ }
+ }
}
commit efd0a83daf83a5e667dbf0f0352aa28f03b806ef
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Thu Sep 30 16:44:44 2010 -0400
add authz checks to resource and plugin config views - if the user doesn't have the needed perms, the config editor is put in read-only mode and a transient message is displayed to inform them why the config is not editable
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 b2c532d..05c37b6 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
@@ -238,7 +238,7 @@ public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceCompo
updateSubTab(this.inventoryTab, this.inventoryChildren, canvas, visible, true);
visible = facets.contains(ResourceTypeFacet.PLUGIN_CONFIGURATION);
canvas = (visible) ? new PluginConfigurationEditView(this.inventoryTab.extendLocatorId("PluginConfigView"),
- resource) : null;
+ resourceComposite) : null;
updateSubTab(this.inventoryTab, this.inventoryConn, canvas, visible, true);
updateSubTab(this.inventoryTab, this.inventoryGroups, ResourceGroupListView.getGroupsOf(this.inventoryTab
.extendLocatorId("GroupsView"), resource.getId()), true, true);
@@ -275,7 +275,7 @@ public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceCompo
if (updateTab(this.configurationTab, facets.contains(ResourceTypeFacet.CONFIGURATION), resourcePermissions
.isConfigureRead())) {
updateSubTab(this.configurationTab, this.configCurrent, new ResourceConfigurationEditView(this
- .extendLocatorId("ResourceConfigView"), resource), true, true);
+ .extendLocatorId("ResourceConfigView"), resourceComposite), true, true);
updateSubTab(this.configurationTab, this.configHistory, ConfigurationHistoryView.getHistoryOf(
resource.getId()), true, true);
}
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 9843339..b002f0b 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
@@ -29,6 +29,8 @@ import com.smartgwt.client.widgets.toolbar.ToolStrip;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.ResourceConfigurationUpdate;
import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.composite.ResourceComposite;
+import org.rhq.core.domain.resource.composite.ResourcePermission;
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;
@@ -45,13 +47,15 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
*/
public class ResourceConfigurationEditView extends LocatableVLayout implements ValidationStateChangeListener {
private Resource resource;
+ private ResourcePermission resourcePermission;
private ConfigurationEditor editor;
private IButton saveButton;
- public ResourceConfigurationEditView(String locatorId, Resource resource) {
+ public ResourceConfigurationEditView(String locatorId, ResourceComposite resourceComposite) {
super(locatorId);
- this.resource = resource;
+ this.resource = resourceComposite.getResource();
+ this.resourcePermission = resourceComposite.getResourcePermission();
}
@Override
@@ -78,9 +82,14 @@ public class ResourceConfigurationEditView extends LocatableVLayout implements V
editor = new ConfigurationEditor(this.getLocatorId(), resource.getId(), resource.getResourceType().getId());
editor.setOverflow(Overflow.AUTO);
editor.addValidationStateChangeListener(this);
+ editor.setReadOnly(!this.resourcePermission.isConfigureWrite());
addMember(toolStrip);
addMember(editor);
+
+ Message message = new TransientMessage("You do not have permission to edit this Resource's configuration.",
+ Message.Severity.Info, true);
+ CoreGUI.getMessageCenter().notify(message);
}
private void save() {
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 d179046..1483cfa 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
@@ -28,6 +28,8 @@ import com.smartgwt.client.widgets.toolbar.ToolStrip;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PluginConfigurationUpdate;
import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.composite.ResourceComposite;
+import org.rhq.core.domain.resource.composite.ResourcePermission;
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;
@@ -44,13 +46,15 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
*/
public class PluginConfigurationEditView extends LocatableVLayout implements ValidationStateChangeListener {
private Resource resource;
+ private ResourcePermission resourcePermission;
private ConfigurationEditor editor;
private LocatableIButton saveButton;
- public PluginConfigurationEditView(String locatorId, Resource resource) {
+ public PluginConfigurationEditView(String locatorId, ResourceComposite resourceComposite) {
super(locatorId);
- this.resource = resource;
+ this.resource = resourceComposite.getResource();
+ this.resourcePermission = resourceComposite.getResourcePermission();
}
@Override
@@ -60,7 +64,6 @@ public class PluginConfigurationEditView extends LocatableVLayout implements Val
}
public void build() {
-
ToolStrip toolStrip = new ToolStrip();
toolStrip.setWidth100();
@@ -79,9 +82,14 @@ public class PluginConfigurationEditView extends LocatableVLayout implements Val
ConfigurationEditor.ConfigType.plugin);
editor.setOverflow(Overflow.AUTO);
editor.addValidationStateChangeListener(this);
+ editor.setReadOnly(!this.resourcePermission.isInventory());
addMember(toolStrip);
addMember(editor);
+
+ Message message = new TransientMessage("You do not have permission to edit this Resource's connection properties.",
+ Message.Severity.Info, true);
+ CoreGUI.getMessageCenter().notify(message);
}
private void save() {
commit 29888fd3a7ed804c812b299f1509ae5980321b3a
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Sep 30 16:18:14 2010 -0400
populate the notif drop down with all sender names
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewNotificationEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewNotificationEditor.java
index 1711bd5..5da3c43 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewNotificationEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewNotificationEditor.java
@@ -26,6 +26,7 @@ package org.rhq.enterprise.gui.coregui.client.alert.definitions;
import java.util.ArrayList;
import java.util.LinkedHashMap;
+import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.FormItemIfFunction;
@@ -38,6 +39,8 @@ import com.smartgwt.client.widgets.form.fields.events.ClickHandler;
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.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
/**
@@ -70,18 +73,39 @@ public class NewNotificationEditor extends LocatableDynamicForm {
notificationSenderSelectItem = new SelectItem("notificationSender", "Notification Sender");
- LinkedHashMap<String, String> senders = new LinkedHashMap<String, String>();
if (notificationToEdit != null) {
// we were given a notification to edit, you can't change the sender type, its the only option
- senders.put(notificationToEdit.getSenderName(), notificationToEdit.getSenderName());
notificationSenderSelectItem.setDisabled(true);
+ LinkedHashMap<String, String> senders = new LinkedHashMap<String, String>(1);
+ senders.put(notificationToEdit.getSenderName(), notificationToEdit.getSenderName());
+ notificationSenderSelectItem.setValueMap(senders);
} else {
+ notificationSenderSelectItem.setValueMap("Loading...");
+ notificationSenderSelectItem.setDisabled(true);
// we are creating a new notification, need to provide all senders as options
- senders.put("System Users", "System Users");
- senders.put("dummySender", "Dummy Sender");
+ GWTServiceLookup.getAlertDefinitionService().getAllAlertSenders(new AsyncCallback<String[]>() {
+ @Override
+ public void onSuccess(String[] result) {
+ if (result != null && result.length > 0) {
+ LinkedHashMap<String, String> senders = new LinkedHashMap<String, String>(result.length);
+ for (String senderName : result) {
+ senders.put(senderName, senderName);
+ }
+ notificationSenderSelectItem.setValueMap(senders);
+ notificationSenderSelectItem.setDisabled(false);
+ notificationSenderSelectItem.redraw();
+ } else {
+ CoreGUI.getErrorHandler().handleError("No alert senders available");
+ }
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Cannot get alert senders", caught);
+ }
+ });
}
- notificationSenderSelectItem.setValueMap(senders);
notificationSenderSelectItem.setDefaultToFirstOption(true);
notificationSenderSelectItem.setWrapTitle(false);
notificationSenderSelectItem.setRedrawOnChange(true);
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 4819bac..ee93aed 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
@@ -41,4 +41,6 @@ public interface AlertDefinitionGWTService extends RemoteService {
int removeAlertDefinitions(Integer[] alertDefinitionIds) throws Exception;
String[] getAlertNotificationConfigurationPreview(AlertNotification[] notifs) throws Exception;
+
+ String[] getAllAlertSenders() 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 d1f492b..b906473 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
@@ -18,6 +18,8 @@
*/
package org.rhq.enterprise.gui.coregui.server.gwt;
+import java.util.List;
+
import org.rhq.core.domain.alert.AlertDefinition;
import org.rhq.core.domain.alert.notification.AlertNotification;
import org.rhq.core.domain.criteria.AlertDefinitionCriteria;
@@ -26,12 +28,14 @@ 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;
import org.rhq.enterprise.server.alert.AlertDefinitionManagerLocal;
+import org.rhq.enterprise.server.alert.AlertNotificationManagerLocal;
import org.rhq.enterprise.server.util.LookupUtil;
public class AlertDefinitionGWTServiceImpl extends AbstractGWTServiceImpl implements AlertDefinitionGWTService {
private static final long serialVersionUID = 1L;
private AlertDefinitionManagerLocal alertDefManager = LookupUtil.getAlertDefinitionManager();
+ private AlertNotificationManagerLocal alertNotifManager = LookupUtil.getAlertNotificationManager();
@Override
public PageList<AlertDefinition> findAlertDefinitionsByCriteria(AlertDefinitionCriteria criteria) {
@@ -106,4 +110,16 @@ public class AlertDefinitionGWTServiceImpl extends AbstractGWTServiceImpl implem
}
}
+ @Override
+ public String[] getAllAlertSenders() throws Exception {
+ try {
+ List<String> results = alertNotifManager.listAllAlertSenders();
+ if (results == null) {
+ return null;
+ }
+ return SerialUtility.prepare(results.toArray(new String[results.size()]), "getAllAlertSenders");
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
+ }
}
\ No newline at end of file
commit b973891c83704c9d19f3fdf9f7a1515d275771c7
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Thu Sep 30 15:48:59 2010 -0400
comment out some debug println's
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 3ad6835..e577491 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
@@ -216,14 +216,14 @@ public class ResourceTreeDatasource extends DataSource {
Resource parentResource = resource.getParentResource();
ResourceSubCategory subcategory = type.getSubCategory();
if (subcategory != null) {
- System.out.println("Processing " + subcategory + "...");
+ //System.out.println("Processing " + subcategory + "...");
do {
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...");
+ //System.out.println("Adding " + subcategoryNode + " to tree...");
updatedNodes.add(subcategoryNode);
}
} while ((subcategory = subcategory.getParentSubCategory()) != null);
@@ -232,7 +232,7 @@ public class ResourceTreeDatasource extends DataSource {
if (!type.isSingleton()) {
AutoGroupTreeNode autogroupNode = new AutoGroupTreeNode(resource);
autogroupNodes.put(autogroupNodeId, autogroupNode);
- System.out.println("Adding " + autogroupNode + " to tree...");
+ //System.out.println("Adding " + autogroupNode + " to tree...");
updatedNodes.add(autogroupNode);
}
}
@@ -330,10 +330,12 @@ public class ResourceTreeDatasource extends DataSource {
}
/**
- * Given a Resource, generate a unique ID for the AGNode.
+ * Given an autogroup's parent Resource and member ResourceType, generate a unique ID for an autogroup TreeNode.
*
- * @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;
+ * @param parentResource requires resourceType field be set. requires parentResource field be set (null for no parent)
+ * @param resourceType the member ResourceType
+ *
+ * @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;
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 f4137b2..1184697 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
@@ -245,7 +245,7 @@ public abstract class RPCDataSource<T> extends DataSource {
@SuppressWarnings("unchecked")
public static <S> S[] getArrayFilter(DSRequest request, String paramName, Class<S> type) {
- System.out.println("Fetching array " + paramName + " (" + type + ")");
+ //System.out.println("Fetching array " + paramName + " (" + type + ")");
Criteria criteria = request.getCriteria();
Map<String, Object> criteriaMap = criteria.getValues();
@@ -272,14 +272,14 @@ public abstract class RPCDataSource<T> extends DataSource {
throw new IllegalArgumentException("No support for passing array filters of type " + type);
}
- System.out.println("Result array = " + resultArray);
+ //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 + ")");
+ //System.out.println("Fetching " + paramName + " (" + type + ")");
Criteria criteria = request.getCriteria();
Map<String, Object> criteriaMap = criteria.getValues();
@@ -301,7 +301,7 @@ public abstract class RPCDataSource<T> extends DataSource {
}
}
- System.out.println("Result = " + result);
+ //System.out.println("Result = " + result);
return result;
}
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 434d06d..2064f63 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
@@ -31,7 +31,6 @@ import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
* @author Greg Hinkle
*/
public class MonitoringRequestCallback implements RequestCallback {
-
@SuppressWarnings("unused")
private int id;
private String name;
@@ -56,11 +55,11 @@ public class MonitoringRequestCallback implements RequestCallback {
if (STATUS_CODE_OK == response.getStatusCode()) {
RPCManager.getInstance().succeedCall(this);
callback.onResponseReceived(request, response);
- System.out.println("MonitoringRequestCallback: OK");
+ //System.out.println("MonitoringRequestCallback: OK");
} else {
RPCManager.getInstance().failCall(this);
callback.onResponseReceived(request, response);
- System.out.println("MonitoringRequestCallback: " + response.getStatusCode() + "/"
+ System.err.println("MonitoringRequestCallback: " + response.getStatusCode() + "/"
+ response.getStatusText());
// if we have a rich and coordinated client-side loggedIn state, do we need to check upon failure here?
@@ -72,7 +71,7 @@ public class MonitoringRequestCallback implements RequestCallback {
@Override
public void onFailure(Throwable caught) {
- SC.say("Unable to determine login status, check server status");
+ SC.say("Unable to determine login status - check Server status.");
}
});
}
commit 6415ed10e3b0d967b712a7be0aa0a3fcf4ce95cb
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Thu Sep 30 15:40:37 2010 -0400
fix bug in core-domain StringUtils.deCamelCase() and add unit test for that method; add support for transient messages to the message center - transient messages are displayed in the header and generally auto-clear after 30 seconds
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 938b07f..01a6ddb 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
@@ -33,8 +33,14 @@ import java.util.Set;
public class StringUtils {
private static final Set<String> LOWERCASE_WORDS = new HashSet<String>();
static {
+ // conjunctions
LOWERCASE_WORDS.add("And");
LOWERCASE_WORDS.add("Or");
+
+ // articles
+ LOWERCASE_WORDS.add("A");
+ LOWERCASE_WORDS.add("An");
+ LOWERCASE_WORDS.add("The");
}
/*
@@ -65,39 +71,47 @@ public class StringUtils {
+ target.substring(nextDash + 2);
}
- StringBuilder currentWord = new StringBuilder();
char currentChar;
- char previousChar = 0;
- for (int i = 0; i < target.length(); i++) {
+ // Always make the first char upper case.
+ char previousChar = Character.toUpperCase(target.charAt(0));
+ StringBuilder currentWord = new StringBuilder();
+ currentWord.append(previousChar);
+ for (int i = 1; i < target.length(); i++) {
currentChar = target.charAt(i);
// Make sure to insert spaces in the middle of acronyms or multi-digit numbers.
- if ((i != 0) &&
- ((Character.isDigit(currentChar) && !Character.isDigit(previousChar))
+ if ((previousChar == ' ' && currentChar != ' ')
+ || (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);
+ appendWord(result, currentWord.toString());
currentWord = new StringBuilder();
// Append a space before the next word.
result.append(' ');
}
- currentWord.append(currentChar);
+ if (currentChar != ' ') {
+ currentWord.append(currentChar);
+ }
previousChar = currentChar;
}
// Append the final word.
- appendWord(result, currentWord);
+ appendWord(result, currentWord.toString());
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);
+ private static void appendWord(StringBuilder result, String word) {
+ if (word.length() >= 1) {
+ if (LOWERCASE_WORDS.contains(word)) {
+ result.append(word.toLowerCase());
+ } else {
+ result.append(Character.toUpperCase(word.charAt(0)));
+ if (word.length() > 1) {
+ result.append(word.substring(1));
+ }
+ }
}
}
diff --git a/modules/core/domain/src/test/java/org/rhq/core/domain/util/StringUtilsTest.java b/modules/core/domain/src/test/java/org/rhq/core/domain/util/StringUtilsTest.java
new file mode 100644
index 0000000..fde0c6b
--- /dev/null
+++ b/modules/core/domain/src/test/java/org/rhq/core/domain/util/StringUtilsTest.java
@@ -0,0 +1,47 @@
+/*
+ * 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.core.domain.util;
+
+import static org.testng.Assert.*;
+
+import org.testng.annotations.Test;
+
+/**
+ * Tests for {@link StringUtils}.
+ *
+ * @author Ian Springer
+ */
+public class StringUtilsTest {
+ @Test
+ public void testDeCamelCase() {
+ testDeCamelCase("RedGreenBlue", "Red Green Blue");
+ testDeCamelCase("redGreenBlue", "Red Green Blue");
+ testDeCamelCase("Red Green Blue", "Red Green Blue");
+ testDeCamelCase("red green blue", "Red Green Blue");
+ testDeCamelCase("RHQServer", "RHQ Server");
+ testDeCamelCase("Blink182", "Blink 182");
+ testDeCamelCase("SimonAndGarfunkel", "Simon and Garfunkel");
+ }
+
+ private void testDeCamelCase(String input, String expectedResult) {
+ String result = StringUtils.deCamelCase(input);
+ assertEquals(result, expectedResult, "For input \"" + input + "\": ");
+ }
+}
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 e342b11..bb39f2d 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
@@ -47,6 +47,7 @@ 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.ErrorHandler;
import org.rhq.enterprise.gui.coregui.client.util.WidgetUtility;
+import org.rhq.enterprise.gui.coregui.client.util.message.MessageBar;
import org.rhq.enterprise.gui.coregui.client.util.message.MessageCenter;
import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
@@ -61,6 +62,8 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String> {
private static ErrorHandler errorHandler = new ErrorHandler();
+ private static MessageBar messageBar;
+
private static BreadcrumbTrailPane breadCrumbTrailPane;
private static MessageCenter messageCenter;
@@ -130,6 +133,8 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String> {
MenuBarView menuBarView = new MenuBarView("TopMenu");
menuBarView.setWidth("100%");
+ messageBar = new MessageBar();
+
breadCrumbTrailPane = new BreadcrumbTrailPane();
Canvas canvas = new Canvas(CONTENT_CANVAS_ID);
@@ -139,9 +144,11 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String> {
rootCanvas = new RootCanvas();
rootCanvas.setOverflow(Overflow.HIDDEN);
rootCanvas.addMember(menuBarView);
+
+ rootCanvas.addMember(messageBar);
rootCanvas.addMember(breadCrumbTrailPane);
rootCanvas.addMember(canvas);
- rootCanvas.addMember(new Footer("CoreFooter"));
+ rootCanvas.addMember(new Footer());
rootCanvas.draw();
History.addValueChangeHandler(this);
@@ -267,8 +274,8 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String> {
}
private class RootCanvas extends VLayout implements BookmarkableView {
- ViewId currentViewId;
- Canvas currentCanvas;
+ private ViewId currentViewId;
+ private Canvas currentCanvas;
private RootCanvas() {
setWidth100();
@@ -280,14 +287,20 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String> {
// default view
History.newItem(DEFAULT_VIEW_PATH);
} else {
- if (!viewPath.getCurrent().equals(currentViewId)) {
- currentViewId = viewPath.getCurrent();
+ messageBar.clearMessage();
- currentCanvas = createContent(viewPath.getCurrent().getPath());
- setContent(currentCanvas);
+ ViewId topLevelViewId = viewPath.getCurrent(); // e.g. Administration
+ if (!topLevelViewId.equals(this.currentViewId)) {
+ this.currentViewId = topLevelViewId;
+ this.currentCanvas = createContent(this.currentViewId.getPath());
+ setContent(this.currentCanvas);
}
- if (currentCanvas instanceof BookmarkableView) {
- ((BookmarkableView) currentCanvas).renderView(viewPath.next()); // e.g.
+
+ if (this.currentCanvas instanceof BookmarkableView) {
+ viewPath.next();
+ if (!viewPath.isEnd()) {
+ ((BookmarkableView) this.currentCanvas).renderView(viewPath);
+ }
}
refreshBreadCrumbTrail();
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/Footer.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/Footer.java
index 36514aa..d7121e3 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
@@ -40,9 +40,10 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableToolStrip;
* @author Joseph Marques
*/
public class Footer extends LocatableToolStrip {
+ private static final String LOCATOR_ID = "CoreFooter";
- public Footer(String locatorId) {
- super(locatorId);
+ public Footer() {
+ super(LOCATOR_ID);
setHeight(30);
setAlign(VerticalAlignment.CENTER);
// setPadding(5);
@@ -55,7 +56,7 @@ public class Footer extends LocatableToolStrip {
super.onDraw();
final UserSessionState userSessionState = new UserSessionState("UserSessionState");
- final MessageCenterView recentMessage = new MessageCenterView(extendLocatorId("MessageCenter"));
+ final MessageCenterView recentMessage = new MessageCenterView(extendLocatorId(MessageCenterView.LOCATOR_ID));
recentMessage.setWidth("*");
final FavoritesButton favoritesButton = new FavoritesButton(extendLocatorId("Favorites"));
final AlertsMessage alertsMessage = new AlertsMessage(extendLocatorId("Alerts"));
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 432cd2b..544ded9 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
@@ -65,6 +65,7 @@ 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.CustomValidator;
import com.smartgwt.client.widgets.form.validator.FloatRangeValidator;
import com.smartgwt.client.widgets.form.validator.IntegerRangeValidator;
import com.smartgwt.client.widgets.form.validator.RegExpValidator;
@@ -136,7 +137,6 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
* @author Ian Springer
*/
public class ConfigurationEditor extends LocatableVLayout {
-
private ConfigurationGWTServiceAsync configurationService = GWTServiceLookup.getConfigurationService();
private TabSet tabSet;
@@ -854,7 +854,7 @@ public class ConfigurationEditor extends LocatableVLayout {
valueItem.setRequired(propertyDefinition.isRequired());
- List<Validator> validators = buildValidators(propertyDefinition, valueItem);
+ List<Validator> validators = buildValidators(propertyDefinition, property);
valueItem.setValidators(validators.toArray(new Validator[validators.size()]));
/*
@@ -879,6 +879,7 @@ public class ConfigurationEditor extends LocatableVLayout {
finalValueItem.addChangedHandler(new ChangedHandler() {
public void onChanged(ChangedEvent changedEvent) {
boolean wasValidBefore = ConfigurationEditor.this.invalidPropertyNames.isEmpty();
+ propertySimple.setErrorMessage(null);
if (changedEvent.getItem().validate()) {
ConfigurationEditor.this.invalidPropertyNames.remove(propertySimple.getName());
propertySimple.setValue(changedEvent.getValue());
@@ -888,7 +889,7 @@ public class ConfigurationEditor extends LocatableVLayout {
boolean isValidNow = ConfigurationEditor.this.invalidPropertyNames.isEmpty();
if (isValidNow != wasValidBefore) {
for (ValidationStateChangeListener validationStateChangeListener : ConfigurationEditor.this.validationStateChangeListeners) {
- validationStateChangeListener.validateStateChanged(isValidNow);
+ validationStateChangeListener.validationStateChanged(isValidNow);
}
}
}
@@ -913,7 +914,7 @@ public class ConfigurationEditor extends LocatableVLayout {
return valueItem;
}
- private List<Validator> buildValidators(PropertyDefinitionSimple propertyDefinition, FormItem valueItem) {
+ private List<Validator> buildValidators(PropertyDefinitionSimple propertyDefinition, Property property) {
List<Validator> validators = new ArrayList<Validator>();
if (propertyDefinition.getConstraints() != null) {
Set<Constraint> constraints = propertyDefinition.getConstraints();
@@ -941,11 +942,16 @@ public class ConfigurationEditor extends LocatableVLayout {
validators.add(validator);
} else if (constraint instanceof RegexConstraint) {
RegExpValidator validator =
- new RegExpValidator("^" + ((RegexConstraint) constraint).getDetails() + "$");
+ new RegExpValidator("^" + constraint.getDetails() + "$");
validators.add(validator);
}
}
}
+ if (property.getErrorMessage() != null) {
+ this.invalidPropertyNames.add(property.getName());
+ PluginReportedErrorValidator validator = new PluginReportedErrorValidator(property);
+ validators.add(validator);
+ }
return validators;
}
@@ -1043,4 +1049,22 @@ public class ConfigurationEditor extends LocatableVLayout {
return new Integer(o1.getOrder()).compareTo(o2.getOrder());
}
}
+
+ private class PluginReportedErrorValidator extends CustomValidator {
+ private Property property;
+
+ public PluginReportedErrorValidator(Property property) {
+ this.property = property;
+ }
+
+ @Override
+ protected boolean condition(Object value) {
+ String errorMessage = this.property.getErrorMessage();
+ boolean valid = (errorMessage != null);
+ if (!valid) {
+ setErrorMessage(errorMessage);
+ }
+ return valid;
+ }
+ }
}
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
index d8f7a85..154c731 100644
--- 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
@@ -23,5 +23,5 @@ package org.rhq.enterprise.gui.coregui.client.components.configuration;
* @author Ian Springer
*/
public interface ValidationStateChangeListener {
- void validateStateChanged(boolean isValid);
+ void validationStateChanged(boolean isValid);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/wizard/AbstractWizard.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/wizard/AbstractWizard.java
index 9c8e513..57d29b5 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/wizard/AbstractWizard.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/wizard/AbstractWizard.java
@@ -18,15 +18,13 @@
*/
package org.rhq.enterprise.gui.coregui.client.components.wizard;
-import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import com.smartgwt.client.widgets.IButton;
public abstract class AbstractWizard implements Wizard {
-
- private ArrayList<WizardStep> steps;
+ private List<WizardStep> steps;
private WizardView view;
private String windowTitle = "";
private String title = "";
@@ -63,7 +61,7 @@ public abstract class AbstractWizard implements Wizard {
return steps;
}
- public void setSteps(ArrayList<WizardStep> steps) {
+ public void setSteps(List<WizardStep> steps) {
this.steps = steps;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupCreateWizard.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupCreateWizard.java
index fbbf71e..1008b83 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupCreateWizard.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupCreateWizard.java
@@ -30,18 +30,21 @@ import com.smartgwt.client.widgets.IButton;
import org.rhq.core.domain.resource.group.ResourceGroup;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.LinkManager;
import org.rhq.enterprise.gui.coregui.client.components.wizard.AbstractWizard;
import org.rhq.enterprise.gui.coregui.client.components.wizard.WizardStep;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGroupGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.inventory.groups.ResourceGroupListView;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
+import org.rhq.enterprise.gui.coregui.client.util.message.TransientMessage;
/**
+ * A wizard for creating a new Resource group.
+ *
* @author Greg Hinkle
*/
public class GroupCreateWizard extends AbstractWizard {
-
private ResourceGroupListView resourceGroupListView;
private GroupCreateStep createStep;
@@ -50,7 +53,7 @@ public class GroupCreateWizard extends AbstractWizard {
public GroupCreateWizard(ResourceGroupListView resourceGroupListView) {
this.resourceGroupListView = resourceGroupListView;
- ArrayList<WizardStep> steps = new ArrayList<WizardStep>();
+ List<WizardStep> steps = new ArrayList<WizardStep>();
steps.add(createStep = new GroupCreateStep());
steps.add(memberStep = new GroupMembersStep(this));
@@ -84,13 +87,18 @@ public class GroupCreateWizard extends AbstractWizard {
groupService.createResourceGroup(createStep.getGroup(), memberStep.getSelectedResourceIds(),
new AsyncCallback<ResourceGroup>() {
public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to create resource group", caught);
+ CoreGUI.getErrorHandler().handleError("Failed to create Resource group.", caught);
}
public void onSuccess(ResourceGroup result) {
+ String groupUrl = LinkManager.getResourceGroupLink(result.getId());
CoreGUI.getMessageCenter().notify(
- new Message("Saved new group " + result.getName(), Message.Severity.Info));
-
+ new TransientMessage("Resource group created. [<a href='" + groupUrl + "'>View Group</a>]",
+ Message.Severity.Info));
+ CoreGUI.getMessageCenter().notify(
+ new Message("Created new " + result.getGroupCategory().name().toLowerCase() + " Resource group '"
+ + result.getName() + "' with " + memberStep.getSelectedResourceIds().length + " members.",
+ Message.Severity.Info));
resourceGroupListView.refresh();
}
});
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 7964a74..9843339 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
@@ -34,18 +34,19 @@ import org.rhq.enterprise.gui.coregui.client.components.configuration.Configurat
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.message.MessageCenter;
+import org.rhq.enterprise.gui.coregui.client.util.message.TransientMessage;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIButton;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
/**
* @author Greg Hinkle
+ * @author Ian Springer
*/
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);
@@ -74,14 +75,11 @@ public class ResourceConfigurationEditView extends LocatableVLayout implements V
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);
}
@@ -91,12 +89,12 @@ public class ResourceConfigurationEditView extends LocatableVLayout implements V
GWTServiceLookup.getConfigurationService().updateResourceConfiguration(resource.getId(), updatedConfiguration,
new AsyncCallback<ResourceConfigurationUpdate>() {
public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to update configuration", caught);
+ CoreGUI.getErrorHandler().handleError("Failed to update configuration.", caught);
}
public void onSuccess(ResourceConfigurationUpdate result) {
CoreGUI.getMessageCenter().notify(
- new Message("Configuration updated for resource [" + resource.getName() + "]",
+ new Message("Configuration updated for Resource [" + resource.getName() + "].",
Message.Severity.Info));
}
@@ -104,14 +102,16 @@ public class ResourceConfigurationEditView extends LocatableVLayout implements V
}
@Override
- public void validateStateChanged(boolean isValid) {
+ public void validationStateChanged(boolean isValid) {
+ MessageCenter messageCenter = CoreGUI.getMessageCenter();
+ Message message;
if (isValid) {
this.saveButton.enable();
- this.messageBar.hide();
+ message = new TransientMessage("All configuration properties now have valid values, so the configuration can now be saved.", Message.Severity.Info);
} 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);
+ message = new TransientMessage("One or more configuration properties have invalid values. The values must be corrected before the configuration can be saved.", Message.Severity.Error, true);
}
+ messageCenter.notify(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 357255a..d179046 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
@@ -33,19 +33,19 @@ import org.rhq.enterprise.gui.coregui.client.components.configuration.Configurat
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.message.MessageCenter;
+import org.rhq.enterprise.gui.coregui.client.util.message.TransientMessage;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIButton;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
/**
* @author Greg Hinkle
+ * @author Ian Springer
*/
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);
@@ -75,15 +75,12 @@ public class PluginConfigurationEditView extends LocatableVLayout implements Val
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);
}
@@ -103,18 +100,19 @@ public class PluginConfigurationEditView extends LocatableVLayout implements Val
}
});
-
}
@Override
- public void validateStateChanged(boolean isValid) {
+ public void validationStateChanged(boolean isValid) {
+ MessageCenter messageCenter = CoreGUI.getMessageCenter();
+ Message message;
if (isValid) {
this.saveButton.enable();
- this.messageBar.hide();
+ message = new TransientMessage("All connection properties now have valid values, so the configuration can now be saved.", Message.Severity.Info);
} 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);
+ message = new TransientMessage("One or more connection properties have invalid values. The values must be corrected before the configuration can be saved.", Message.Severity.Error, true);
}
+ messageCenter.notify(message);
}
}
\ No newline at end of file
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 905b0c7..97cc7ab 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
@@ -23,8 +23,8 @@ import java.util.Date;
/**
* @author Greg Hinkle
*/
+@SuppressWarnings({"UnnecessarySemicolon"})
public class Message {
-
protected String title;
protected String detail;
protected Date fired = new Date();
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageBar.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageBar.java
index e025ab1..b03499f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageBar.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageBar.java
@@ -22,52 +22,114 @@ package org.rhq.enterprise.gui.coregui.client.util.message;
import java.util.HashMap;
import java.util.Map;
+import com.google.gwt.user.client.Timer;
+import com.smartgwt.client.types.Alignment;
+import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.widgets.Label;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
+
/**
* A bar for displaying a message at the top of a page - the equivalent of the JSF h:messages component.
+ * The message will be displayed for 30 seconds and then will be automatically cleared.
*
* @author Ian Springer
*/
-public class MessageBar extends Label {
- public static final Map<Message.Severity, String> SEVERITY_TO_STYLE_NAME_MAP = new HashMap();
+public class MessageBar extends LocatableHLayout implements MessageCenter.MessageListener {
+ private static final String LOCATOR_ID = "MessageBar";
+ private static final int AUTO_HIDE_DELAY_MILLIS = 30000; // 30 seconds
+
+ private static final Map<Message.Severity, String> SEVERITY_TO_STYLE_NAME_MAP =
+ new HashMap<Message.Severity, String>();
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");
}
+ private static final Map<Message.Severity, String> SEVERITY_TO_ICON_MAP =
+ new HashMap<Message.Severity, String>();
+ static {
+ SEVERITY_TO_ICON_MAP.put(Message.Severity.Info, "info/icn_info_blue.png");
+ SEVERITY_TO_ICON_MAP.put(Message.Severity.Warning, "info/icn_info_orange.png");
+ SEVERITY_TO_ICON_MAP.put(Message.Severity.Error, "info/icn_info_red.png");
+ }
+
+ private Label label;
+
+ public MessageBar() {
+ super(LOCATOR_ID);
+
+ setOverflow(Overflow.VISIBLE);
+ }
+
@Override
protected void onDraw() {
super.onDraw();
setWidth100();
setAutoHeight();
+ setHeight(40);
- hide();
+ setAlign(Alignment.CENTER);
+
+ CoreGUI.getMessageCenter().addMessageListener(this);
}
- public void setMessage(Message message) {
+ @Override
+ public void onMessage(Message message) {
+ if (message instanceof TransientMessage) {
+ TransientMessage transientMessage = (TransientMessage)message;
+
+ // First clear any previous message.
+ clearMessage();
+
+ this.label = createLabel(transientMessage);
+ addMember(this.label);
+ markForRedraw();
- String contents;
- if (message != null) {
- contents = message.getTitle();
- if (message.getDetail() != null) {
- contents += ": " + message.getDetail();
+ // Auto-clear the message after 30 seconds unless it's been designated as sticky.
+ if (!transientMessage.isSticky()) {
+ Timer hideTimer = new Timer() {
+ @Override
+ public void run() {
+ clearMessage();
+ }
+ };
+ hideTimer.schedule(AUTO_HIDE_DELAY_MILLIS);
}
- } else {
- contents = null;
}
- setContents(contents);
- if (contents != null) {
- String styleName = SEVERITY_TO_STYLE_NAME_MAP.get(message.getSeverity());
- setStyleName(styleName);
+ }
+
+ public void clearMessage() {
+ if (this.label != null) {
+ this.label.destroy();
+ removeMember(this.label);
+ markForRedraw();
}
- markForRedraw();
- if (contents != null) {
- show();
- } else {
- hide();
+ }
+
+ private Label createLabel(Message message) {
+ Label label = new Label();
+
+ String contents = message.getTitle();
+ if (message.getDetail() != null) {
+ contents += ": " + message.getDetail();
}
+ label.setContents(contents);
+
+ String styleName = (contents != null) ? SEVERITY_TO_STYLE_NAME_MAP.get(message.getSeverity()) : null;
+ label.setStyleName(styleName);
+
+ label.setAutoHeight();
+ label.setHeight(35);
+ label.setAutoWidth();
+ label.setWidth("75%");
+
+ String icon = (contents != null) ? SEVERITY_TO_ICON_MAP.get(message.getSeverity()) : null;
+ label.setIcon(icon);
+
+ return label;
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenter.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenter.java
index afce657..a3c29dd 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenter.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenter.java
@@ -20,15 +20,14 @@ package org.rhq.enterprise.gui.coregui.client.util.message;
import java.util.ArrayList;
import java.util.LinkedList;
+import java.util.List;
/**
* @author Greg Hinkle
*/
public class MessageCenter {
-
private LinkedList<Message> messages = new LinkedList<Message>();
-
- private ArrayList<MessageListener> listeners = new ArrayList<MessageListener>();
+ private List<MessageListener> listeners = new ArrayList<MessageListener>();
private static final int MAX_MESSAGES = 100;
@@ -46,7 +45,7 @@ public class MessageCenter {
this.listeners.add(listener);
}
- public LinkedList<Message> getMessages() {
+ public List<Message> getMessages() {
return messages;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenterView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenterView.java
index 7b6d850..5d81646 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenterView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenterView.java
@@ -18,7 +18,7 @@
*/
package org.rhq.enterprise.gui.coregui.client.util.message;
-import java.util.LinkedList;
+import java.util.List;
import com.google.gwt.user.client.Timer;
import com.smartgwt.client.types.Alignment;
@@ -53,6 +53,7 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableWindow;
* @author Greg Hinkle
*/
public class MessageCenterView extends LocatableHLayout implements MessageCenter.MessageListener {
+ public static final String LOCATOR_ID = "MessageCenter";
public MessageCenterView(String locatorId) {
super(locatorId, 5);
@@ -78,16 +79,16 @@ public class MessageCenterView extends LocatableHLayout implements MessageCenter
recentEventsButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent clickEvent) {
- LinkedList<Message> messages = CoreGUI.getMessageCenter().getMessages();
+ List<Message> messages = CoreGUI.getMessageCenter().getMessages();
if (messages.isEmpty()) {
- recentEventsMenu.setItems(new MenuItem("No recent messages"));
+ recentEventsMenu.setItems(new MenuItem("No recent messages."));
} else {
MenuItem[] items = new MenuItem[messages.size()];
- int i = 0;
- for (final Message message : messages) {
+ for (int i = 0, messagesSize = messages.size(); i < messagesSize; i++) {
+ final Message message = messages.get(i);
MenuItem messageItem = new MenuItem(message.title, getSeverityIcon(message.severity));
- items[i++] = messageItem;
+ items[i] = messageItem;
messageItem.addClickHandler(new com.smartgwt.client.widgets.menu.events.ClickHandler() {
public void onClick(MenuItemClickEvent event) {
@@ -156,38 +157,40 @@ public class MessageCenterView extends LocatableHLayout implements MessageCenter
}
public void onMessage(final Message message) {
- final Label label = new Label(message.title);
- label.setMargin(5);
- label.setAutoFit(true);
- label.setHeight(25);
- label.setWrap(false);
+ if (!(message instanceof TransientMessage)) {
+ final Label label = new Label(message.title);
+ label.setMargin(5);
+ label.setAutoFit(true);
+ label.setHeight(25);
+ label.setWrap(false);
- String iconSrc = getSeverityIcon(message.severity);
+ String iconSrc = getSeverityIcon(message.severity);
- label.setIcon(iconSrc);
+ label.setIcon(iconSrc);
- label.setTooltip(message.detail);
+ label.setTooltip(message.detail);
- label.addClickHandler(new ClickHandler() {
- public void onClick(ClickEvent clickEvent) {
- showDetails(message);
- }
- });
-
- addMember(label, 1);
- redraw();
-
- Timer hideTimer = new Timer() {
- @Override
- public void run() {
- label.animateHide(AnimationEffect.FADE, new AnimationCallback() {
- public void execute(boolean b) {
- label.destroy();
- }
- });
- }
- };
- hideTimer.schedule(10000);
+ label.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent clickEvent) {
+ showDetails(message);
+ }
+ });
+
+ addMember(label, 1);
+ redraw();
+
+ Timer hideTimer = new Timer() {
+ @Override
+ public void run() {
+ label.animateHide(AnimationEffect.FADE, new AnimationCallback() {
+ public void execute(boolean b) {
+ label.destroy();
+ }
+ });
+ }
+ };
+ hideTimer.schedule(10000);
+ }
}
private String getSeverityIcon(Message.Severity severity) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/TransientMessage.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/TransientMessage.java
new file mode 100644
index 0000000..318c4a5
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/TransientMessage.java
@@ -0,0 +1,48 @@
+/*
+ * 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;
+
+/**
+ * @author Ian Springer
+ */
+public class TransientMessage extends Message {
+ private boolean sticky;
+
+ public TransientMessage(String title, Severity severity) {
+ super(title, severity);
+ }
+
+ public TransientMessage(String title, String detail, Severity severity) {
+ super(title, detail, severity);
+ }
+
+ public TransientMessage(String title, Severity severity, boolean sticky) {
+ this(title, null, severity, sticky);
+ }
+
+ public TransientMessage(String title, String detail, Severity severity, boolean sticky) {
+ super(title, detail, severity);
+ this.sticky = sticky;
+ }
+
+ public boolean isSticky() {
+ return this.sticky;
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/CoreGUI.css b/modules/enterprise/gui/coregui/src/main/webapp/CoreGUI.css
index c5d324e..85d1b83 100644
--- a/modules/enterprise/gui/coregui/src/main/webapp/CoreGUI.css
+++ b/modules/enterprise/gui/coregui/src/main/webapp/CoreGUI.css
@@ -361,29 +361,29 @@ a:hover {
}
.InfoBlock,.ConfirmationBlock,.WarnBlock,.ErrorBlock,.FatalBlock {
- padding: 4px;
+ /*padding: 4px;*/
border-width: 1px;
- border-top-style: solid;
- font-size: 10px;
+ border-style: solid;
+ /*font-size: 10px;*/
color: #000000;
}
.InfoBlock,.ConfirmationBlock {
background-color: #BFF1B5; /* light green */
- border-top-color: #00AC3D; /* medium green */
+ border-color: #00AC3D; /* medium green */
}
.WarnBlock {
background-color: #FFFD99; /* light yellow */
- border-top-color: #FF9C15; /* medium orange */
+ border-color: #FF9C15; /* medium orange */
}
.ErrorBlock {
background-color: #FF9999; /* light red */
- border-top-color: #EE4444; /* medium red */
+ border-color: #EE4444; /* medium red */
}
.FatalBlock {
background-color: #FF6666; /* slightly darker light red */
- border-top-color: #EE1111; /* slightly darker medium red */
+ border-color: #EE1111; /* slightly darker medium red */
}
commit cf57ff1d2706723c74d1a66c914a69e4d68f0b91
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Sep 30 14:48:49 2010 -0400
introduce the start of the new notification editor.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewNotificationEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewNotificationEditor.java
new file mode 100644
index 0000000..1711bd5
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewNotificationEditor.java
@@ -0,0 +1,161 @@
+/*
+ * 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.alert.definitions;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+
+import com.smartgwt.client.types.Alignment;
+import com.smartgwt.client.widgets.form.DynamicForm;
+import com.smartgwt.client.widgets.form.FormItemIfFunction;
+import com.smartgwt.client.widgets.form.fields.ButtonItem;
+import com.smartgwt.client.widgets.form.fields.FormItem;
+import com.smartgwt.client.widgets.form.fields.SelectItem;
+import com.smartgwt.client.widgets.form.fields.SpacerItem;
+import com.smartgwt.client.widgets.form.fields.events.ClickEvent;
+import com.smartgwt.client.widgets.form.fields.events.ClickHandler;
+
+import org.rhq.core.domain.alert.AlertDefinition;
+import org.rhq.core.domain.alert.notification.AlertNotification;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
+
+/**
+ * @author John Mazzitelli
+ */
+public class NewNotificationEditor extends LocatableDynamicForm {
+
+ private final AlertDefinition alertDefinition; // the definition we are adding the notification to
+ private final ArrayList<AlertNotification> notifications; // if we are creating a new notification, it gets added to this list
+ private final AlertNotification notificationToEdit; // the notification that this editor is editing (may be null)
+ private final Runnable closeFunction; // this is called after a button is pressed and the editor should close
+
+ private SelectItem notificationSenderSelectItem;
+
+ public NewNotificationEditor(String locatorId, AlertDefinition alertDefinition,
+ ArrayList<AlertNotification> notifs, AlertNotification notifToEdit, Runnable closeFunc) {
+
+ super(locatorId);
+ this.alertDefinition = alertDefinition;
+ this.notifications = notifs;
+ this.notificationToEdit = notifToEdit;
+ this.closeFunction = closeFunc;
+ }
+
+ @Override
+ protected void onInit() {
+ super.onInit();
+
+ setMargin(20);
+
+ notificationSenderSelectItem = new SelectItem("notificationSender", "Notification Sender");
+
+ LinkedHashMap<String, String> senders = new LinkedHashMap<String, String>();
+ if (notificationToEdit != null) {
+ // we were given a notification to edit, you can't change the sender type, its the only option
+ senders.put(notificationToEdit.getSenderName(), notificationToEdit.getSenderName());
+ notificationSenderSelectItem.setDisabled(true);
+ } else {
+ // we are creating a new notification, need to provide all senders as options
+ senders.put("System Users", "System Users");
+ senders.put("dummySender", "Dummy Sender");
+ }
+
+ notificationSenderSelectItem.setValueMap(senders);
+ notificationSenderSelectItem.setDefaultToFirstOption(true);
+ notificationSenderSelectItem.setWrapTitle(false);
+ notificationSenderSelectItem.setRedrawOnChange(true);
+ notificationSenderSelectItem.setWidth("*");
+
+ SpacerItem spacer1 = new SpacerItem();
+ spacer1.setColSpan(2);
+ spacer1.setHeight(5);
+
+ SpacerItem spacer2 = new SpacerItem();
+ spacer2.setColSpan(2);
+ spacer2.setHeight(5);
+
+ ButtonItem ok = new ButtonItem("okButtonItem", "OK");
+ ok.setEndRow(false);
+ ok.setAlign(Alignment.RIGHT);
+ ok.addClickHandler(new ClickHandler() {
+ @Override
+ public void onClick(ClickEvent event) {
+ if (validate(false)) {
+ saveNewNotification();
+ closeFunction.run();
+ }
+ }
+ });
+
+ ButtonItem cancel = new ButtonItem("cancelButtonItem", "Cancel");
+ cancel.setStartRow(false);
+ cancel.setAlign(Alignment.LEFT);
+ cancel.addClickHandler(new ClickHandler() {
+ @Override
+ public void onClick(ClickEvent event) {
+ closeFunction.run();
+ }
+ });
+
+ ArrayList<FormItem> formItems = new ArrayList<FormItem>();
+ formItems.add(notificationSenderSelectItem);
+ formItems.add(spacer1);
+ // TODO put config editor here
+ formItems.add(spacer2);
+ formItems.add(ok);
+ formItems.add(cancel);
+
+ setFields(formItems.toArray(new FormItem[formItems.size()]));
+ };
+
+ private void saveNewNotification() {
+ AlertNotification notif;
+
+ if (notificationToEdit == null) {
+ // we are adding a new notification - we just add it to the end of the list
+ String selectedSender = notificationSenderSelectItem.getValue().toString();
+ notif = new AlertNotification(selectedSender);
+ notif.setAlertDefinition(alertDefinition);
+ notifications.add(notif);
+ } else {
+ notif = notificationToEdit;
+ }
+
+ // notif.setConfiguration(configuration);
+ // notif.setExtraConfiguration(extraConfiguration);
+ }
+
+ private class ShowIfSenderFunction implements FormItemIfFunction {
+ private final String senderName;
+
+ public ShowIfSenderFunction(String senderName) {
+ this.senderName = senderName;
+ }
+
+ public boolean execute(FormItem item, Object value, DynamicForm form) {
+ String selectedSenderString = form.getValue("notificationSender").toString();
+ return senderName.equals(selectedSenderString);
+ }
+ }
+}
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 b8e4644..bc585ac 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
@@ -123,6 +123,11 @@ public class NotificationsAlertDefinitionForm extends LocatableVLayout implement
@Override
public void saveAlertDefinition() {
+ if (notifications != null && notifications.size() > 0) {
+ for (AlertNotification notif : notifications) {
+ notif.setAlertDefinition(alertDefinition);
+ }
+ }
alertDefinition.setAlertNotifications(notifications);
// make our own new internal copy since we gave ours to the definition object
@@ -184,7 +189,6 @@ public class NotificationsAlertDefinitionForm extends LocatableVLayout implement
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;
}
@@ -290,15 +294,15 @@ public class NotificationsAlertDefinitionForm extends LocatableVLayout implement
}
});
- // NewNotificationEditor newEditor = new NewNotificationEditor(
- // extendLocatorId("newNotificationEditor"), notifications, new Runnable() {
- // @Override
- // public void run() {
- // winModal.markForDestroy();
- // table.refresh();
- // }
- // });
- /// winModal.addItem(newEditor);
+ NewNotificationEditor newEditor = new NewNotificationEditor(extendLocatorId("newNotificationEditor"),
+ alertDefinition, notifications, notifToEdit, new Runnable() {
+ @Override
+ public void run() {
+ winModal.markForDestroy();
+ table.refresh();
+ }
+ });
+ winModal.addItem(newEditor);
winModal.show();
}
}
commit 0b06e79336f625dcd36e15004d746ee2228e13aa
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Sep 30 14:48:26 2010 -0400
add cancel button
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java
index 3fcc64e..361ad78 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java
@@ -96,14 +96,15 @@ public class NewConditionEditor extends LocatableDynamicForm {
private boolean supportsOperations = false;
private boolean supportsEvents = false;
private boolean supportsResourceConfig = false;
- private Runnable okFunction; // this is called after the OK button is pressed and a new condition is saved
+ private Runnable closeFunction; // this is called after a button is pressed and the editor should close
private ResourceType resourceType;
- public NewConditionEditor(String locatorId, HashSet<AlertCondition> conditions, ResourceType rtype, Runnable okFunc) {
+ public NewConditionEditor(String locatorId, HashSet<AlertCondition> conditions, ResourceType rtype,
+ Runnable closeFunc) {
super(locatorId);
this.conditions = conditions;
- this.okFunction = okFunc;
+ this.closeFunction = closeFunc;
this.resourceType = rtype;
this.supportsEvents = (rtype.getEventDefinitions() != null && rtype.getEventDefinitions().size() > 0);
@@ -174,26 +175,40 @@ public class NewConditionEditor extends LocatableDynamicForm {
conditionTypeSelectItem.setRedrawOnChange(true);
conditionTypeSelectItem.setWidth("*");
- SpacerItem spacer = new SpacerItem();
- spacer.setColSpan(2);
- spacer.setHeight(5);
+ SpacerItem spacer1 = new SpacerItem();
+ spacer1.setColSpan(2);
+ spacer1.setHeight(5);
- ButtonItem ok = new ButtonItem("buttonItem", "OK");
- ok.setColSpan(2);
- ok.setAlign(Alignment.CENTER);
+ SpacerItem spacer2 = new SpacerItem();
+ spacer2.setColSpan(2);
+ spacer2.setHeight(5);
+
+ ButtonItem ok = new ButtonItem("okButtonItem", "OK");
+ ok.setEndRow(false);
+ ok.setAlign(Alignment.RIGHT);
ok.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
if (validate(false)) {
saveNewCondition();
- okFunction.run();
+ closeFunction.run();
}
}
});
+ ButtonItem cancel = new ButtonItem("cancelButtonItem", "Cancel");
+ cancel.setStartRow(false);
+ cancel.setAlign(Alignment.LEFT);
+ cancel.addClickHandler(new ClickHandler() {
+ @Override
+ public void onClick(ClickEvent event) {
+ closeFunction.run();
+ }
+ });
+
ArrayList<FormItem> formItems = new ArrayList<FormItem>();
formItems.add(conditionTypeSelectItem);
- formItems.add(spacer);
+ formItems.add(spacer1);
formItems.addAll(buildAvailabilityChangeFormItems());
if (supportsMetrics) {
formItems.addAll(buildMetricThresholdFormItems());
@@ -216,7 +231,9 @@ public class NewConditionEditor extends LocatableDynamicForm {
if (supportsResourceConfig) {
formItems.addAll(buildResourceConfigChangeFormItems());
}
+ formItems.add(spacer2);
formItems.add(ok);
+ formItems.add(cancel);
setFields(formItems.toArray(new FormItem[formItems.size()]));
};
commit 5135c435804aef06ae9f37b1cebe72f2d79f580e
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Sep 30 12:19:04 2010 -0400
get notification tab ready to support editing an existing notif as well as adding new ones. this adds double click handler
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 cffdd78..b8e4644 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
@@ -34,6 +34,9 @@ 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.events.DoubleClickEvent;
+import com.smartgwt.client.widgets.events.DoubleClickHandler;
+import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
@@ -42,7 +45,6 @@ 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;
@@ -140,57 +142,6 @@ public class NotificationsAlertDefinitionForm extends LocatableVLayout implement
if (!formBuilt) {
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);
@@ -268,6 +219,10 @@ public class NotificationsAlertDefinitionForm extends LocatableVLayout implement
private class NotificationTable extends Table {
public NotificationTable(String locatorId) {
super(locatorId);
+ setShowHeader(false);
+
+ final NotificationDataSource dataSource = new NotificationDataSource();
+ setDataSource(dataSource);
}
@Override
@@ -277,6 +232,74 @@ public class NotificationsAlertDefinitionForm extends LocatableVLayout implement
ListGridField configField = new ListGridField(FIELD_CONFIGURATION, "Configuration");
configField.setWidth("75%");
getListGrid().setFields(senderField, configField);
+
+ getListGrid().addDoubleClickHandler(new DoubleClickHandler() {
+ @Override
+ public void onDoubleClick(DoubleClickEvent event) {
+ ListGrid listGrid = (ListGrid) event.getSource();
+ ListGridRecord[] selectedRows = listGrid.getSelection();
+ if (selectedRows != null && selectedRows.length == 1) {
+ AlertNotification notif = ((NotificationDataSource) getDataSource())
+ .copyValues(selectedRows[0]);
+ popupNotificationEditor(notif);
+ }
+ }
+ });
+
+ addTableAction(this.extendLocatorId("add"), "Add", SelectionEnablement.ALWAYS, null, new TableAction() {
+ @Override
+ public void executeAction(ListGridRecord[] selection) {
+ popupNotificationEditor(null);
+ }
+ });
+
+ addTableAction(this.extendLocatorId("delete"), "Delete", SelectionEnablement.ANY, "Are you sure?",
+ new TableAction() {
+ @Override
+ public void executeAction(ListGridRecord[] selection) {
+ for (ListGridRecord record : selection) {
+ AlertNotification notif = ((NotificationDataSource) getDataSource()).copyValues(record);
+ notifications.remove(notif);
+ }
+ table.refresh();
+ }
+ });
+ }
+
+ private void popupNotificationEditor(AlertNotification notifToEdit) {
+ final Window winModal = new LocatableWindow(NotificationsAlertDefinitionForm.this
+ .extendLocatorId("notificationEditorWindow"));
+ if (notifToEdit == null) {
+ winModal.setTitle("Add Notification");
+ } else {
+ winModal.setTitle("Edit 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();
}
}
}
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 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 ff9f820ba31283c57228c6a3357bc31f3f69b6d2
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Sep 22 08:15:43 2010 -0400
add tooltip help
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 a929a84..0e9fe8c 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,6 +157,8 @@ public class RecoveryAlertDefinitionForm extends LocatableDynamicForm implements
disableWhenFiredSelection.setValueMap(yesNo);
disableWhenFiredSelection.setDefaultValue("no");
disableWhenFiredSelection.setWrapTitle(false);
+ 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.");
disableWhenFiredStatic = new StaticTextItem("disableWhenFiredStatic", "Disable When Fired");
disableWhenFiredStatic.setWrapTitle(false);
@@ -164,6 +166,8 @@ public class RecoveryAlertDefinitionForm extends LocatableDynamicForm implements
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.");
recoverAlertStatic = new StaticTextItem("recoveryAlertStatic", "Recover Alert");
recoverAlertStatic.setDefaultValue(getNoRecoveryMenuItemTitle());
commit c40e42e59d96772ea2b953a47754db8f865d0cb9
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Wed Sep 22 00:36:38 2010 -0400
fix bug in usage of resource tree node IDs
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 1b7e5b5..bc9c956 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
@@ -49,6 +49,7 @@ 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.gwt.ResourceGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
+import org.rhq.enterprise.gui.coregui.client.util.StringUtility;
/**
* This doesn't extend RPCDataSource because it is tree-oriented and behaves differently than normal list data sources
@@ -127,13 +128,13 @@ public class ResourceTreeDatasource extends DataSource {
public void executeFetch(final String requestId, final DSRequest request, final DSResponse response) {
final long start = System.currentTimeMillis();
- String p = request.getCriteria().getAttribute("parentId");
+ String parentResourceId = 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");
+ if (parentResourceId == null) {
+ System.out.println("ResourceTreeDatasource: Loading initial data...");
// criteria.addFilterId(rootId);
@@ -142,9 +143,9 @@ public class ResourceTreeDatasource extends DataSource {
return;
} else {
- System.out.println("DataSourceTree: Loading " + p);
+ System.out.println("ResourceTreeDatasource: Loading Resource [" + parentResourceId + "]...");
- criteria.addFilterParentResourceId(Integer.parseInt(p));
+ criteria.addFilterParentResourceId(Integer.parseInt(parentResourceId));
}
// The server is already eager fetch resource type
@@ -186,14 +187,14 @@ public class ResourceTreeDatasource extends DataSource {
* @return
*/
public static TreeNode[] buildNodes(List<Resource> resources) {
- ResourceTreeNode[] records = new ResourceTreeNode[resources.size()];
- for (int x = 0; x < resources.size(); x++) {
- Resource resource = resources.get(x);
- ResourceTreeNode record = new ResourceTreeNode(resource);
- records[x] = record;
+ ResourceTreeNode[] nodes = new ResourceTreeNode[resources.size()];
+ for (int i = 0; i < resources.size(); i++) {
+ Resource resource = resources.get(i);
+ ResourceTreeNode node = new ResourceTreeNode(resource);
+ nodes[i] = node;
}
- return introduceTypeAndCategoryNodes(records);
+ return introduceTypeAndCategoryNodes(nodes);
}
private static TreeNode[] introduceTypeAndCategoryNodes(ResourceTreeNode[] nodes) {
@@ -274,7 +275,7 @@ public class ResourceTreeDatasource extends DataSource {
// setAttribute("parentKey", parentId);
ResourceType type = resource.getResourceType();
- String name = pluralize(type.getName());
+ String name = StringUtility.pluralize(type.getName());
setName(name);
setAttribute("name", name);
}
@@ -335,7 +336,7 @@ public class ResourceTreeDatasource extends DataSource {
}
public Resource getResource() {
- return resource;
+ return this.resource;
}
public static String idOf(Resource resource) {
@@ -343,19 +344,7 @@ public class ResourceTreeDatasource extends DataSource {
}
public static String idOf(int resourceId) {
- return "resource" + resourceId;
+ return String.valueOf(resourceId);
}
}
-
- private static String pluralize(String singularNoun) {
- // TODO: Make this smarter.
- String pluralNoun;
- if (singularNoun.endsWith("y") && !singularNoun.endsWith("ay") && !singularNoun.endsWith("ey") &&
- !singularNoun.endsWith("oy")) {
- pluralNoun = singularNoun.substring(0, singularNoun.length() - 1) + "ies";
- } else {
- pluralNoun = singularNoun + "s";
- }
- return pluralNoun;
- }
}
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
new file mode 100644
index 0000000..00a2cf1
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/StringUtility.java
@@ -0,0 +1,41 @@
+/*
+ * 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;
+
+/**
+ * A collection of utility methods for working with Strings.
+ *
+ * @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")) {
+ pluralNoun = singularNoun.substring(0, singularNoun.length() - 1) + "ies";
+ } else {
+ pluralNoun = singularNoun + "s";
+ }
+ return pluralNoun;
+ }
+
+ private StringUtility() {
+ }
+}
commit 2791d339c9959921882881afe23764961e0d8135
Author: Joseph Marques <joseph(a)redhat.com>
Date: Wed Sep 22 00:33:39 2010 -0400
enforce consistency of GroupDefinitions by controlling the merge explicitly
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerBean.java
index 905688b..ca04351 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerBean.java
@@ -210,11 +210,15 @@ public class GroupDefinitionManagerBean implements GroupDefinitionManagerLocal {
}
}
- try {
- return entityManager.merge(groupDefinition);
- } catch (Exception e) {
- throw new GroupDefinitionUpdateException(e);
- }
+ // do not call entityManager.merge, it could overwrite managed fields
+ // merge fields explicitly to control precisely which fields get updated
+ attachedGroupDefinition.setName(groupDefinition.getName());
+ attachedGroupDefinition.setDescription(groupDefinition.getDescription());
+ attachedGroupDefinition.setRecursive(groupDefinition.isRecursive());
+ attachedGroupDefinition.setExpression(groupDefinition.getExpression());
+ attachedGroupDefinition.setRecalculationInterval(groupDefinition.getRecalculationInterval());
+
+ return attachedGroupDefinition;
}
// return boolean indicating whether the name of this group definition is changing
commit ba09ae501b545b2a6452290584e7d5a9ea81b6ff
Author: Joseph Marques <joseph(a)redhat.com>
Date: Tue Sep 21 23:31:14 2010 -0400
fix master/details impl to allow detailsView navigation from /0 to /<id>
basically, since the detailsView is already showing when navigating from
/0 to /<id>, the animationHide event was being suppressed, which meant that
the subsequent callback wasn't invoked. this left the original detailsView
canvas attached to the detailsHolder, instead of refreshing the holder with
the latest view returned from the renderView method.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java
index 0e3a899..c8ab12b 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java
@@ -187,7 +187,6 @@ public abstract class TableSection extends Table implements BookmarkableView {
@Override
public void renderView(ViewPath viewPath) {
-
basePath = viewPath.getPathToCurrent();
if (!viewPath.isEnd()) {
@@ -224,20 +223,42 @@ public abstract class TableSection extends Table implements BookmarkableView {
protected void switchToDetailsView() {
Canvas contents = getTableContents();
if (contents != null) {
- contents.animateHide(AnimationEffect.WIPE, new AnimationCallback() {
- @Override
- public void execute(boolean b) {
- detailsView.setWidth100();
- detailsView.setHeight100();
-
- detailsHolder.addMember(new BackButton(extendLocatorId("BackButton"), "Back to List", basePath));
- detailsHolder.addMember(detailsView);
- detailsHolder.animateShow(AnimationEffect.WIPE);
+ if (contents.isVisible()) {
+ contents.animateHide(AnimationEffect.WIPE, new AnimationCallback() {
+ @Override
+ public void execute(boolean b) {
+ buildDetailsView();
+ }
+ });
+ } else {
+ /*
+ * if the programmer chooses to go directly from the detailView in create-mode to the
+ * detailsView in edit-mode, the content canvas will already be hidden, which means the
+ * animateHide would be a no-op (the event won't fire). this causes the detailsHolder
+ * to keep a reference to the previous detailsView (the one in create-mode) instead of the
+ * newly returned reference from getDetailsView(int) that was called when the renderView
+ * methods were called hierarchically down to render the new detailsView in edit-mode.
+ * therefore, we need to explicitly destroy what's already there (presumably the detailsView
+ * in create-mode), and then rebuild it (presumably the detailsView in edit-mode).
+ */
+ for (Canvas child : detailsHolder.getMembers()) {
+ child.destroy();
}
- });
+
+ buildDetailsView();
+ }
}
}
+ private void buildDetailsView() {
+ detailsView.setWidth100();
+ detailsView.setHeight100();
+
+ detailsHolder.addMember(new BackButton(extendLocatorId("BackButton"), "Back to List", basePath));
+ detailsHolder.addMember(detailsView);
+ detailsHolder.animateShow(AnimationEffect.WIPE);
+ }
+
/**
* Switches to viewing the table, hiding the details canvas.
*/
commit 2b9ec8f1ab6be2fb2a9437b51f89eb19219c849e
Author: Joseph Marques <joseph(a)redhat.com>
Date: Tue Sep 21 23:27:03 2010 -0400
remove debugging statements
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 9b17abf..c8293c7 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
@@ -141,8 +141,7 @@ public class GroupDefinitionListView extends TableSection {
@Override
public Canvas getDetailsView(int id) {
final SingleGroupDefinitionView singleGroupDefinitionView = new SingleGroupDefinitionView(this
- .extendLocatorId("Empty"));
+ .extendLocatorId("Details"));
return singleGroupDefinitionView;
}
-
}
\ No newline at end of file
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 d6ac260..dde421c 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
@@ -31,6 +31,8 @@ import com.smartgwt.client.data.Record;
import com.smartgwt.client.types.DSOperationType;
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.form.fields.CheckboxItem;
import com.smartgwt.client.widgets.form.fields.SelectItem;
import com.smartgwt.client.widgets.form.fields.SpinnerItem;
@@ -65,7 +67,6 @@ public class SingleGroupDefinitionView extends LocatableVLayout implements Bookm
private int groupDefinitionId;
private GroupDefinition groupDefinition;
private String basePath;
-
private ViewId viewId;
// editable form
@@ -85,29 +86,18 @@ public class SingleGroupDefinitionView extends LocatableVLayout implements Bookm
private StaticTextItem expressionStatic;
private StaticTextItem recalculationIntervalStatic;
- private GroupDefinitionDataSource dataSource;
-
public SingleGroupDefinitionView(String locatorId) {
- this(locatorId, null);
- }
-
- public SingleGroupDefinitionView(String locatorId, GroupDefinition groupDefinition) {
super(locatorId);
- this.dataSource = GroupDefinitionDataSource.getInstance();
-
setPadding(10);
setOverflow(Overflow.VISIBLE);
setWidth(5);
buildForm();
-
- this.groupDefinition = groupDefinition;
}
public void setGroupDefinition(final GroupDefinition groupDefinition) {
this.groupDefinition = groupDefinition;
- System.out.println("setGroupDefinition(" + groupDefinition + ")");
// form setup
id.setValue(groupDefinition.getId());
@@ -131,50 +121,39 @@ public class SingleGroupDefinitionView extends LocatableVLayout implements Bookm
final LocatableDynamicForm form = new LocatableDynamicForm(extendLocatorId("GroupDefinitionForm"));
form.setFields(id, idStatic, name, nameStatic, description, descriptionStatic, expression, expressionStatic,
recursive, recursiveStatic, recalculationInterval, recalculationIntervalStatic);
- form.setDataSource(dataSource);
+ form.setDataSource(GroupDefinitionDataSource.getInstance());
form.setHiliteRequiredFields(true);
form.setRequiredTitleSuffix(" <span style=\"color: red;\">* </span>:");
- final DSOperationType operationType;
if (groupDefinition.getId() == 0) {
- System.out.println("setting form operation: ADD");
form.setSaveOperationType(DSOperationType.ADD);
- operationType = DSOperationType.ADD;
} else {
- System.out.println("setting form operation: UPDATE");
form.setSaveOperationType(DSOperationType.UPDATE);
- operationType = DSOperationType.UPDATE;
}
- System.out.println("form operation default is " + form.getSaveOperationType());
final DynaGroupChildrenView dynaGroupChildrenView = new DynaGroupChildrenView(extendLocatorId("DynaGroups"),
groupDefinitionId);
// button setup
IButton saveButton = new LocatableIButton(this.extendLocatorId("Save"), "Save");
- saveButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
- public void onClick(com.smartgwt.client.widgets.events.ClickEvent clickEvent) {
- System.out.println("cached operaton type is " + operationType);
- form.setSaveOperationType(operationType);
- System.out.println("form operation before validation is " + form.getSaveOperationType());
+ //saveButton.addClickHandler(new SaveOrUpdateClickHandler(form, operationType, dynaGroupChildrenView));
+ saveButton.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent clickEvent) {
if (form.validate()) {
- System.out.println("form operation after validation is " + form.getSaveOperationType());
form.saveData(new DSCallback() {
@Override
public void execute(DSResponse response, Object rawData, DSRequest request) {
- if (groupDefinition.getId() == 0) {
- System.out.println("just created new group def");
+ if (form.isNewRecord()) {
Record[] results = response.getData();
if (results.length != 1) {
CoreGUI.getErrorHandler().handleError(
"Error: " + results.length + " created instead of one");
} else {
Record newRecord = results[0];
- GroupDefinition newGroupDefinition = dataSource
+ GroupDefinition newGroupDefinition = GroupDefinitionDataSource.getInstance()
.copyValues((ListGridRecord) newRecord);
History.newItem(basePath + "/" + newGroupDefinition.getId());
}
} else {
- System.out.println("just edited existing group def");
dynaGroupChildrenView.refresh();
}
}
@@ -185,8 +164,8 @@ public class SingleGroupDefinitionView extends LocatableVLayout implements Bookm
IButton recalculateButton = new LocatableIButton(this.extendLocatorId("Recalculate"), "Save & Recalculate");
recalculateButton.setWidth(150);
- recalculateButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
- public void onClick(com.smartgwt.client.widgets.events.ClickEvent clickEvent) {
+ recalculateButton.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent clickEvent) {
if (form.validate()) {
form.saveData(new DSCallback() {
@Override
@@ -214,8 +193,8 @@ public class SingleGroupDefinitionView extends LocatableVLayout implements Bookm
});
IButton resetButton = new LocatableIButton(this.extendLocatorId("Reset"), "Reset");
- resetButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
- public void onClick(com.smartgwt.client.widgets.events.ClickEvent clickEvent) {
+ resetButton.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent clickEvent) {
form.reset();
}
});
@@ -239,6 +218,7 @@ public class SingleGroupDefinitionView extends LocatableVLayout implements Bookm
super(locatorId, "DynaGroup Children", new Criteria("groupDefinitionId", String.valueOf(groupDefinition
.getId())));
setDataSource(ResourceGroupsDataSource.getInstance());
+ setMinHeight(250);
}
}
@@ -285,7 +265,7 @@ public class SingleGroupDefinitionView extends LocatableVLayout implements Bookm
private void buildForm() {
id = new TextItem("id", "ID");
- //id.setVisible(false);
+ id.setVisible(false);
idStatic = new StaticTextItem("idStatic", "ID");
idStatic.setVisible(false);
commit be2e9d2f22804f857e660692c138337f14bfef66
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Tue Sep 21 20:40:44 2010 -0400
fix so subcategory nodes for subcategories that have parent subcategories and rendered as child nodes of the parent subcategory nodes
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 5edd16d..38dc487 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
@@ -166,8 +166,9 @@ public class NewResourceTreeView extends LocatableVLayout {
}
private void showContextMenu(final ResourceTreeDatasource.ResourceTreeNode node) {
+ ResourceType type = node.getResource().getResourceType();
ResourceTypeRepository.Cache.getInstance().getResourceTypes(
- node.getResourceType().getId(),
+ type.getId(),
EnumSet.of(ResourceTypeRepository.MetadataType.operations, ResourceTypeRepository.MetadataType.children,
ResourceTypeRepository.MetadataType.subCategory,
ResourceTypeRepository.MetadataType.pluginConfigurationDefinition,
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 2516ac5..1b7e5b5 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
@@ -188,8 +188,8 @@ public class ResourceTreeDatasource extends DataSource {
public static TreeNode[] buildNodes(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);
+ Resource resource = resources.get(x);
+ ResourceTreeNode record = new ResourceTreeNode(resource);
records[x] = record;
}
@@ -198,42 +198,33 @@ public class ResourceTreeDatasource extends DataSource {
private static TreeNode[] introduceTypeAndCategoryNodes(ResourceTreeNode[] nodes) {
List<TreeNode> updatedNodes = new ArrayList<TreeNode>();
- Map<Integer, CategoryTreeNode> categories = new HashMap<Integer, CategoryTreeNode>();
+ // 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>();
for (ResourceTreeNode node : nodes) {
updatedNodes.add(node);
- ResourceType type = node.getResourceType();
+ Resource resource = node.getResource();
+ ResourceType type = resource.getResourceType();
if (type.getCategory() != ResourceCategory.PLATFORM) {
if (!types.containsKey(type)) {
-
- String parentResourceId = String.valueOf(node.getResource().getParentResource().getId());
-
- CategoryTreeNode categoryNode = null;
- if (type.getSubCategory() != null) {
- ResourceSubCategory category = type.getSubCategory();
- if (category.getName() != null) {
- categoryNode = categories.get(category.getId());
+ Resource parentResource = resource.getParentResource();
+ ResourceSubCategory category = type.getSubCategory();
+ if (category != null) {
+ do {
+ String categoryNodeId = CategoryTreeNode.idOf(category, parentResource);
+ CategoryTreeNode categoryNode = categories.get(categoryNodeId);
if (categoryNode == null) {
- // TODO (ips): Handle connecting child subcat nodes to their parent subcats.
- /*ResourceSubCategory parentCategory = category.getParentSubCategory();
- while (parentCategory != null) {
- Resource parentType = parentCategory.findParentResourceType();
- if (parentCategory.findTaggedResourceTypes().isEmpty()) {
- CategoryTreeNode parentCategoryNode =
- new CategoryTreeNode(parentResourceId, parentCategory);
- }
- }*/
- categoryNode = new CategoryTreeNode(parentResourceId, category);
- categories.put(category.getId(), categoryNode);
+ categoryNode = new CategoryTreeNode(category, parentResource);
+ categories.put(categoryNode.getID(), categoryNode);
updatedNodes.add(categoryNode);
}
- }
+ } while ((category = category.getParentSubCategory()) != null);
}
- String parentId = (categoryNode != null) ? categoryNode.getID() : parentResourceId;
- TypeTreeNode typeNode = new TypeTreeNode(parentId, parentResourceId, type);
+ TypeTreeNode typeNode = new TypeTreeNode(resource);
updatedNodes.add(typeNode);
types.put(type, typeNode);
}
@@ -243,78 +234,65 @@ public class ResourceTreeDatasource extends DataSource {
return updatedNodes.toArray(new TreeNode[updatedNodes.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 EnhancedTreeNode {
- public CategoryTreeNode(String parentResourceId, ResourceSubCategory category) {
- String id = parentResourceId + "__" + fixId(category.getName());
+ public CategoryTreeNode(ResourceSubCategory category, Resource parentResource) {
+ String id = idOf(category, parentResource);
setID(id);
setAttribute("id", id);
- setParentID(parentResourceId);
- setAttribute("parentId", parentResourceId);
+ ResourceSubCategory parentCategory = category.getParentSubCategory();
+ String parentId = (parentCategory != null) ?
+ CategoryTreeNode.idOf(parentCategory, parentResource) :
+ ResourceTreeNode.idOf(parentResource);
+ setParentID(parentId);
+ setAttribute("parentId", 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);
}
+
+ public static String idOf(ResourceSubCategory category, Resource parentResource) {
+ return "subcat" + category.getId() + "_" + parentResource.getId();
+ }
}
+ /**
+ * The Resource type folder node for an autogroup.
+ */
public static class TypeTreeNode extends EnhancedTreeNode {
- private TypeTreeNode(String parentId, String parentResourceId, ResourceType type) {
- String id = parentResourceId + "_" + type.getId();
+ private TypeTreeNode(Resource resource) {
+ String id = idOf(resource);
setID(id);
setAttribute("id", id);
- if (parentId == null) {
- try {
- throw new IllegalStateException("**************** WARNING: parent ID is null for type " + type);
- } catch (IllegalStateException e) {
- e.printStackTrace();
- }
- }
+ String parentId = parentIdOf(resource);
setParentID(parentId);
setAttribute("parentId", parentId);
// setAttribute("parentKey", parentId);
+ ResourceType type = resource.getResourceType();
String name = pluralize(type.getName());
setName(name);
setAttribute("name", name);
}
- @Override
- public void setParentID(String parentID) {
- if (parentID == null) {
- try {
- throw new IllegalStateException("**************** WARNING: setting parent ID to null for type " + getName());
- } catch (IllegalStateException e) {
- e.printStackTrace();
- }
- }
- super.setParentID(parentID);
+ public static String idOf(Resource resource) {
+ Resource parentResource = resource.getParentResource();
+ return (parentResource != null) ? "type" + resource.getResourceType().getId() + "_"
+ + parentResource.getId() : null;
}
- @Override
- public void setAttribute(String property, String value) {
- if (property.equals("parentId") && value == null) {
- try {
- throw new IllegalStateException("**************** WARNING: setting parent ID to null for type " + getName());
- } catch (IllegalStateException e) {
- e.printStackTrace();
- }
- }
- super.setAttribute(property, value);
- }
+ public static String parentIdOf(Resource resource) {
+ ResourceType type = resource.getResourceType();
+ ResourceSubCategory parentCategory = type.getSubCategory();
+ String parentId = (parentCategory != null) ?
+ CategoryTreeNode.idOf(parentCategory, resource.getParentResource()) :
+ ResourceTreeNode.idOf(resource.getParentResource());
+ return parentId;
+ }
}
public static class ResourceTreeNode extends EnhancedTreeNode {
@@ -323,12 +301,20 @@ public class ResourceTreeDatasource extends DataSource {
private ResourceTreeNode(Resource resource) {
this.resource = resource;
- String id = String.valueOf(resource.getId());
+ String id = idOf(resource);
setID(id);
setAttribute("id", id);
- String parentId = (resource.getParentResource() != null) ?
- (resource.getParentResource().getId() + "_" + resource.getResourceType().getId()) : null;
+ Resource parentResource = resource.getParentResource();
+ String parentId;
+ if (parentResource != null) {
+ parentId = resource.getResourceType().isSingleton() ?
+ TypeTreeNode.parentIdOf(resource) :
+ TypeTreeNode.idOf(resource);
+ }
+ else {
+ parentId = null;
+ }
setParentID(parentId);
setAttribute("parentId", parentId);
@@ -352,13 +338,13 @@ public class ResourceTreeDatasource extends DataSource {
return resource;
}
- public ResourceType getResourceType() {
- return resource.getResourceType();
+ public static String idOf(Resource resource) {
+ return idOf(resource.getId());
}
- }
- private static String fixId(String id) {
- return id.replace(' ', '_');
+ public static String idOf(int resourceId) {
+ return "resource" + resourceId;
+ }
}
private static String pluralize(String singularNoun) {
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 02afc80..418a334 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
@@ -172,7 +172,7 @@ public class ResourceTreeView extends LocatableVLayout {
private void updateBreadcrumbs() {
- TreeNode selectedNode = treeGrid.getTree().findById(String.valueOf(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);
@@ -204,8 +204,9 @@ public class ResourceTreeView extends LocatableVLayout {
}
private void showContextMenu(final ResourceTreeDatasource.ResourceTreeNode node) {
+ ResourceType type = node.getResource().getResourceType();
ResourceTypeRepository.Cache.getInstance().getResourceTypes(
- node.getResourceType().getId(),
+ type.getId(),
EnumSet.of(ResourceTypeRepository.MetadataType.operations, ResourceTypeRepository.MetadataType.children,
ResourceTypeRepository.MetadataType.subCategory,
ResourceTypeRepository.MetadataType.pluginConfigurationDefinition,
@@ -433,7 +434,7 @@ 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(String.valueOf(resourceId));
+ .getTree().findById(ResourceTreeDatasource.ResourceTreeNode.idOf(resourceId));
if (treeNode != null) {
return treeNode.getResource();
}
@@ -449,8 +450,9 @@ public class ResourceTreeView extends LocatableVLayout {
this.selectedResourceId = selectedResourceId;
TreeNode node;
+ final String resourceNodeId = ResourceTreeDatasource.ResourceTreeNode.idOf(selectedResourceId);
if (treeGrid != null && treeGrid.getTree() != null
- && (node = treeGrid.getTree().findById(String.valueOf(selectedResourceId))) != null) {
+ && (node = treeGrid.getTree().findById(resourceNodeId)) != 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
@@ -459,7 +461,7 @@ public class ResourceTreeView extends LocatableVLayout {
treeGrid.getTree().openFolders(parents);
treeGrid.getTree().openFolder(node);
- if (!treeGrid.getSelectedRecord().equals(node)) {
+ if (!node.equals(treeGrid.getSelectedRecord())) {
treeGrid.deselectAllRecords();
treeGrid.selectRecord(node);
}
@@ -507,7 +509,8 @@ public class ResourceTreeView extends LocatableVLayout {
TreeUtility.printTree(treeGrid.getTree());
- TreeNode selectedNode = treeGrid.getTree().findById(String.valueOf(selectedResourceId));
+ TreeNode selectedNode =
+ treeGrid.getTree().findById(resourceNodeId);
// System.out.println("Trying to preopen: " + selectedNode);
if (selectedNode != null) {
// System.out.println("Preopen node!!!");
@@ -541,8 +544,7 @@ public class ResourceTreeView extends LocatableVLayout {
treeGrid.getTree().linkNodes(ResourceTreeDatasource.buildNodes(result));
- TreeNode selectedNode = treeGrid.getTree().findById(
- String.valueOf(selectedResourceId));
+ TreeNode selectedNode = treeGrid.getTree().findById(resourceNodeId);
if (selectedNode != null) {
treeGrid.deselectAllRecords();
treeGrid.selectRecord(selectedNode);
@@ -564,7 +566,7 @@ public class ResourceTreeView extends LocatableVLayout {
} else {
CoreGUI.getMessageCenter().notify(
- new Message("Failed to select resource [" + selectedResourceId
+ new Message("Failed to select Resource [" + selectedResourceId
+ "] in tree.", Message.Severity.Warning));
}
@@ -573,7 +575,7 @@ public class ResourceTreeView extends LocatableVLayout {
}
- TreeNode selectedNode = treeGrid.getTree().findById(String.valueOf(selectedResourceId));
+ TreeNode selectedNode = treeGrid.getTree().findById(resourceNodeId);
// System.out.println("Trying to preopen: " + selectedNode);
if (selectedNode != null) {
TreeNode[] parents = treeGrid.getTree().getParents(selectedNode);
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 ed4c35f7a4e2f68ebc52eac47912ef7c4f8ebca0
Author: Joseph Marques <joseph(a)redhat.com>
Date: Tue Sep 21 17:08:29 2010 -0400
add some debugging statements
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 01dceca..d6ac260 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
@@ -105,7 +105,7 @@ public class SingleGroupDefinitionView extends LocatableVLayout implements Bookm
this.groupDefinition = groupDefinition;
}
- public void setGroupDefinition(GroupDefinition groupDefinition) {
+ public void setGroupDefinition(final GroupDefinition groupDefinition) {
this.groupDefinition = groupDefinition;
System.out.println("setGroupDefinition(" + groupDefinition + ")");
@@ -134,6 +134,17 @@ public class SingleGroupDefinitionView extends LocatableVLayout implements Bookm
form.setDataSource(dataSource);
form.setHiliteRequiredFields(true);
form.setRequiredTitleSuffix(" <span style=\"color: red;\">* </span>:");
+ final DSOperationType operationType;
+ if (groupDefinition.getId() == 0) {
+ System.out.println("setting form operation: ADD");
+ form.setSaveOperationType(DSOperationType.ADD);
+ operationType = DSOperationType.ADD;
+ } else {
+ System.out.println("setting form operation: UPDATE");
+ form.setSaveOperationType(DSOperationType.UPDATE);
+ operationType = DSOperationType.UPDATE;
+ }
+ System.out.println("form operation default is " + form.getSaveOperationType());
final DynaGroupChildrenView dynaGroupChildrenView = new DynaGroupChildrenView(extendLocatorId("DynaGroups"),
groupDefinitionId);
@@ -142,19 +153,16 @@ public class SingleGroupDefinitionView extends LocatableVLayout implements Bookm
IButton saveButton = new LocatableIButton(this.extendLocatorId("Save"), "Save");
saveButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
public void onClick(com.smartgwt.client.widgets.events.ClickEvent clickEvent) {
+ System.out.println("cached operaton type is " + operationType);
+ form.setSaveOperationType(operationType);
+ System.out.println("form operation before validation is " + form.getSaveOperationType());
if (form.validate()) {
- if (groupDefinitionId == 0) {
- System.out.println("setting form operation: ADD");
- form.setSaveOperationType(DSOperationType.ADD);
- } else {
- System.out.println("setting form operation: UPDATE");
- form.setSaveOperationType(DSOperationType.UPDATE);
- }
- System.out.println("form operation type is " + form.getSaveOperationType());
+ System.out.println("form operation after validation is " + form.getSaveOperationType());
form.saveData(new DSCallback() {
@Override
public void execute(DSResponse response, Object rawData, DSRequest request) {
- if (SingleGroupDefinitionView.this.groupDefinitionId == 0) {
+ if (groupDefinition.getId() == 0) {
+ System.out.println("just created new group def");
Record[] results = response.getData();
if (results.length != 1) {
CoreGUI.getErrorHandler().handleError(
@@ -166,6 +174,7 @@ public class SingleGroupDefinitionView extends LocatableVLayout implements Bookm
History.newItem(basePath + "/" + newGroupDefinition.getId());
}
} else {
+ System.out.println("just edited existing group def");
dynaGroupChildrenView.refresh();
}
}
commit 944ccfa1d927d00b9ca253a3f47dbdf792684592
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Tue Sep 21 16:54:00 2010 -0400
finished the "recovery editor" portion of the alert definition editor. you can now set recovery alerts and disable-on-fire flag
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 8f8c5c3..bf38e6b 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
@@ -136,4 +136,10 @@ public abstract class AbstractAlertDefinitionsDataSource extends RPCDataSource<A
}
protected abstract AlertDefinitionCriteria getCriteria(DSRequest request);
+
+ /**
+ * Returns a criteria that will query for all alerts, but only for the ID and name fields.
+ * @return criteria for an inexpensive query to obtain all alert defs
+ */
+ protected abstract AlertDefinitionCriteria getSimpleCriteriaForAll();
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GeneralPropertiesAlertDefinitionForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GeneralPropertiesAlertDefinitionForm.java
index fe1e2e2..12e27d9 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GeneralPropertiesAlertDefinitionForm.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GeneralPropertiesAlertDefinitionForm.java
@@ -99,10 +99,10 @@ public class GeneralPropertiesAlertDefinitionForm extends LocatableDynamicForm i
prioritySelection.setValue(alertDef.getPriority().name());
priorityStatic.setValue(alertDef.getPriority().name());
- enabledSelection.setValue(alertDef.getEnabled() ? "Yes" : "No");
+ enabledSelection.setValue(alertDef.getEnabled() ? "yes" : "no");
enabledStatic.setValue(alertDef.getEnabled() ? "Yes" : "No");
- readOnlySelection.setValue(alertDef.isReadOnly() ? "Yes" : "No");
+ readOnlySelection.setValue(alertDef.isReadOnly() ? "yes" : "no");
readOnlyStatic.setValue(alertDef.isReadOnly() ? "Yes" : "No");
}
@@ -181,8 +181,8 @@ public class GeneralPropertiesAlertDefinitionForm extends LocatableDynamicForm i
String prioritySelected = prioritySelection.getValue().toString();
alertDefinition.setPriority(AlertPriority.valueOf(prioritySelected));
- alertDefinition.setEnabled("Yes".equals(enabledSelection.getValue()));
- alertDefinition.setReadOnly("Yes".equals(readOnlySelection.getValue()));
+ alertDefinition.setEnabled("yes".equals(enabledSelection.getValue()));
+ alertDefinition.setReadOnly("yes".equals(readOnlySelection.getValue()));
}
@Override
@@ -230,13 +230,19 @@ public class GeneralPropertiesAlertDefinitionForm extends LocatableDynamicForm i
priorityStatic.setValueIcons(priorityIcons);
enabledSelection = new RadioGroupItem("enabled", "Enabled");
- enabledSelection.setValueMap("Yes", "No");
- enabledSelection.setDefaultValue("Yes");
+ LinkedHashMap<String, String> enabledYesNo = new LinkedHashMap<String, String>(2);
+ enabledYesNo.put("yes", "Yes");
+ enabledYesNo.put("no", "No");
+ enabledSelection.setValueMap(enabledYesNo);
+ enabledSelection.setDefaultValue("yes");
enabledStatic = new StaticTextItem("enabledStatic", "Enabled");
readOnlySelection = new RadioGroupItem("readOnly", "Protected");
- readOnlySelection.setValueMap("Yes", "No");
- readOnlySelection.setDefaultValue("Yes");
+ LinkedHashMap<String, String> readOnlyYesNo = new LinkedHashMap<String, String>(2);
+ readOnlyYesNo.put("yes", "Yes");
+ readOnlyYesNo.put("no", "No");
+ readOnlySelection.setValueMap(readOnlyYesNo);
+ readOnlySelection.setDefaultValue("yes");
readOnlySelection
.setPrompt("If true, this definition is protected from being changed by the parent definition. In other words, the parent definition settings will not override this definition.");
readOnlyStatic = new StaticTextItem("readOnlyStatic", "Protected");
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsDataSource.java
index 90f9490..bb2cc71 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsDataSource.java
@@ -29,12 +29,21 @@ import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.data.DSRequest;
import org.rhq.core.domain.criteria.AlertDefinitionCriteria;
+import org.rhq.core.domain.resource.group.ResourceGroup;
+import org.rhq.core.domain.util.PageControl;
/**
* @author John Mazzitelli
*/
public class GroupAlertDefinitionsDataSource extends AbstractAlertDefinitionsDataSource {
+ private ResourceGroup resourceGroup;
+
+ public GroupAlertDefinitionsDataSource(ResourceGroup group) {
+ super();
+ this.resourceGroup = group;
+ }
+
@Override
protected AlertDefinitionCriteria getCriteria(DSRequest request) {
AlertDefinitionCriteria criteria = new AlertDefinitionCriteria();
@@ -54,4 +63,12 @@ public class GroupAlertDefinitionsDataSource extends AbstractAlertDefinitionsDat
criteria.setPageControl(getPageControl(request));
return criteria;
}
+
+ @Override
+ protected AlertDefinitionCriteria getSimpleCriteriaForAll() {
+ AlertDefinitionCriteria criteria = new AlertDefinitionCriteria();
+ criteria.addFilterResourceGroupIds(Integer.valueOf(this.resourceGroup.getId()));
+ criteria.setPageControl(PageControl.getUnlimitedInstance());
+ return criteria;
+ }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java
index 4775ee4..183faec 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java
@@ -82,7 +82,7 @@ public class GroupAlertDefinitionsView extends AbstractAlertDefinitionsView {
@Override
protected AbstractAlertDefinitionsDataSource getAlertDefinitionDataSource() {
- return new GroupAlertDefinitionsDataSource();
+ return new GroupAlertDefinitionsDataSource(group);
}
@Override
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 ab64324..a929a84 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
@@ -23,10 +23,21 @@
package org.rhq.enterprise.gui.coregui.client.alert.definitions;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.widgets.form.fields.RadioGroupItem;
import com.smartgwt.client.widgets.form.fields.SelectItem;
+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.AlertDefinition;
+import org.rhq.core.domain.criteria.AlertDefinitionCriteria;
+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.util.selenium.LocatableDynamicForm;
/**
@@ -35,18 +46,25 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
public class RecoveryAlertDefinitionForm extends LocatableDynamicForm implements EditAlertDefinitionForm {
private AlertDefinition alertDefinition;
+ private AbstractAlertDefinitionsDataSource alertDataSource;
+ private ArrayList<AlertDefinition> allAlertDefinitions;
private SelectItem recoverAlertSelection;
+ private StaticTextItem recoverAlertStatic;
+
private RadioGroupItem disableWhenFiredSelection;
+ private StaticTextItem disableWhenFiredStatic;
private boolean formBuilt = false;
- public RecoveryAlertDefinitionForm(String locatorId) {
- this(locatorId, null);
+ public RecoveryAlertDefinitionForm(String locatorId, AbstractAlertDefinitionsDataSource dataSource) {
+ this(locatorId, dataSource, null);
}
- public RecoveryAlertDefinitionForm(String locatorId, AlertDefinition alertDefinition) {
+ public RecoveryAlertDefinitionForm(String locatorId, AbstractAlertDefinitionsDataSource dataSource,
+ AlertDefinition alertDefinition) {
super(locatorId);
+ this.alertDataSource = dataSource;
this.alertDefinition = alertDefinition;
}
@@ -55,7 +73,6 @@ public class RecoveryAlertDefinitionForm extends LocatableDynamicForm implements
super.onInit();
if (!formBuilt) {
- buildForm();
setAlertDefinition(alertDefinition);
makeViewOnly();
}
@@ -75,7 +92,10 @@ public class RecoveryAlertDefinitionForm extends LocatableDynamicForm implements
if (alertDef == null) {
clearFormValues();
} else {
- disableWhenFiredSelection.setValue(alertDef.getWillRecover() ? "Yes" : "No");
+ refreshWidgets(allAlertDefinitions);
+
+ disableWhenFiredSelection.setValue(alertDef.getWillRecover() ? "yes" : "no");
+ disableWhenFiredStatic.setValue(alertDef.getWillRecover() ? "Yes" : "No");
}
markForRedraw();
@@ -83,21 +103,38 @@ public class RecoveryAlertDefinitionForm extends LocatableDynamicForm implements
@Override
public void makeEditable() {
- // TODO Auto-generated method stub
+ recoverAlertSelection.show();
+ disableWhenFiredSelection.show();
+
+ recoverAlertStatic.hide();
+ disableWhenFiredStatic.hide();
markForRedraw();
}
@Override
public void makeViewOnly() {
- // TODO Auto-generated method stub
+ recoverAlertSelection.hide();
+ disableWhenFiredSelection.hide();
+
+ recoverAlertStatic.show();
+ disableWhenFiredStatic.show();
markForRedraw();
}
@Override
public void saveAlertDefinition() {
- // TODO Auto-generated method stub
+ // this silliness is to workaround the validation that AlertDefinition setters try to do
+ alertDefinition.setRecoveryId(0);
+ alertDefinition.setWillRecover(false);
+
+ alertDefinition.setRecoveryId(Integer.valueOf(recoverAlertSelection.getValue().toString()));
+ if (alertDefinition.getRecoveryId() != 0) {
+ alertDefinition.setWillRecover(false);
+ } else {
+ alertDefinition.setWillRecover("yes".equals(disableWhenFiredSelection.getValue()));
+ }
}
@Override
@@ -105,23 +142,133 @@ public class RecoveryAlertDefinitionForm extends LocatableDynamicForm implements
recoverAlertSelection.clearValue();
disableWhenFiredSelection.clearValue();
+ recoverAlertStatic.clearValue();
+ disableWhenFiredStatic.clearValue();
+
markForRedraw();
}
private void buildForm() {
if (!formBuilt) {
+ disableWhenFiredSelection = new RadioGroupItem("disableWhenFired", "Disable When Fired");
+ LinkedHashMap<String, String> yesNo = new LinkedHashMap<String, String>(2);
+ yesNo.put("yes", "Yes");
+ yesNo.put("no", "No");
+ disableWhenFiredSelection.setValueMap(yesNo);
+ disableWhenFiredSelection.setDefaultValue("no");
+ disableWhenFiredSelection.setWrapTitle(false);
+ disableWhenFiredStatic = new StaticTextItem("disableWhenFiredStatic", "Disable When Fired");
+ disableWhenFiredStatic.setWrapTitle(false);
+
recoverAlertSelection = new SelectItem("recoveryAlert", "Recover Alert");
- recoverAlertSelection.setValueMap("Select...");
- recoverAlertSelection.setDefaultValue("Select...");
- // TODO: call into server and get the menu list of all alerts that we can recover
+ recoverAlertSelection.setDefaultValue("0");
+ recoverAlertSelection.setWrapTitle(false);
+ recoverAlertSelection.setRedrawOnChange(true);
- disableWhenFiredSelection = new RadioGroupItem("disableWhenFired", "Disable When Fired");
- disableWhenFiredSelection.setValueMap("Yes", "No");
- disableWhenFiredSelection.setDefaultValue("Yes");
+ recoverAlertStatic = new StaticTextItem("recoveryAlertStatic", "Recover Alert");
+ recoverAlertStatic.setDefaultValue(getNoRecoveryMenuItemTitle());
+ recoverAlertStatic.setWrapTitle(false);
+
+ // 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
+ // for non-recoverable alerts or for alerts that will themselves be recovered.
+ // therefore, force the disableWhenFired selection to go to no and do not allow it to be changed when appropriate
+ recoverAlertSelection.addChangedHandler(new ChangedHandler() {
+ @Override
+ public void onChanged(ChangedEvent event) {
+ String recoveryAlertDefId = event.getItem().getValue().toString();
+ refreshDisableWhenFiredSelection(recoveryAlertDefId);
+ }
+ });
+
+ refreshWidgets(null); // for it to at least show the initial "no-op" entry
+ loadAllAlertDefinitionsAndRefreshRecoverAlertSelection(); // this gets the real entries asynchronously
- setFields(recoverAlertSelection, disableWhenFiredSelection);
+ setFields(recoverAlertSelection, recoverAlertStatic, disableWhenFiredSelection, disableWhenFiredStatic);
formBuilt = true;
}
}
+
+ private AlertDefinition lookupAlertDefinition(Integer id) {
+ if (id != null && id.intValue() != 0) {
+ if (this.allAlertDefinitions != null) {
+ for (AlertDefinition def : this.allAlertDefinitions) {
+ if (def.getId() == id.intValue()) {
+ return def;
+ }
+ }
+ }
+ }
+
+ return null;
+ }
+
+ private void loadAllAlertDefinitionsAndRefreshRecoverAlertSelection() {
+ if (allAlertDefinitions == null) {
+ AlertDefinitionCriteria criteria = alertDataSource.getSimpleCriteriaForAll();
+ GWTServiceLookup.getAlertService().findAlertDefinitionsByCriteria(criteria,
+ new AsyncCallback<PageList<AlertDefinition>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Cannot build recovery menu", caught);
+ }
+
+ public void onSuccess(PageList<AlertDefinition> result) {
+ allAlertDefinitions = result;
+ refreshWidgets(allAlertDefinitions);
+ }
+ });
+ } else {
+ // we already got the values before, just refresh the menu (in case this.alertDef changed)
+ refreshWidgets(allAlertDefinitions);
+ }
+ }
+
+ private void refreshWidgets(ArrayList<AlertDefinition> allDefs) {
+ int allDefsSize = (allDefs != null) ? allDefs.size() : 0;
+ LinkedHashMap<String, String> alertMap = new LinkedHashMap<String, String>(allDefsSize + 1);
+ alertMap.put("0", getNoRecoveryMenuItemTitle());
+ if (allDefs != null) {
+ for (AlertDefinition def : allDefs) {
+ if (alertDefinition == null || alertDefinition.getId() != def.getId()) {
+ alertMap.put(String.valueOf(def.getId()), def.getName());
+ }
+ }
+ }
+ recoverAlertSelection.setValueMap(alertMap);
+
+ if (alertDefinition != null) {
+ AlertDefinition recoveryAlert = lookupAlertDefinition(alertDefinition.getRecoveryId());
+ if (recoveryAlert != null) {
+ String recoveryIdStr = String.valueOf(recoveryAlert.getId());
+ recoverAlertSelection.setValue(recoveryIdStr);
+ recoverAlertStatic.setValue(recoveryAlert.getName());
+ refreshDisableWhenFiredSelection(recoveryIdStr);
+ } else {
+ recoverAlertSelection.setValue("0");
+ recoverAlertStatic.setValue(getNoRecoveryMenuItemTitle());
+ refreshDisableWhenFiredSelection("0");
+ }
+ }
+
+ recoverAlertSelection.redraw();
+ }
+
+ private void refreshDisableWhenFiredSelection(String recoveryAlertDefId) {
+ if ("0".equals(recoveryAlertDefId)) {
+ disableWhenFiredSelection.setDisabled(false);
+ } else {
+ disableWhenFiredSelection.setValue("no");
+ disableWhenFiredSelection.setDisabled(true);
+ }
+ disableWhenFiredSelection.redraw();
+ }
+
+ private String getNoRecoveryMenuItemTitle() {
+ StringBuilder str = new StringBuilder();
+ str.append("-- ");
+ str.append("No Recovery");
+ str.append(" --");
+ return str.toString();
+ }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsDataSource.java
index dc04a1e..3bc7a3f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsDataSource.java
@@ -34,6 +34,7 @@ import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.alert.AlertDefinition;
import org.rhq.core.domain.criteria.AlertDefinitionCriteria;
import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.util.PageControl;
/**
* @author John Mazzitelli
@@ -115,4 +116,12 @@ public class ResourceAlertDefinitionsDataSource extends AbstractAlertDefinitions
criteria.setPageControl(getPageControl(request));
return criteria;
}
+
+ @Override
+ protected AlertDefinitionCriteria getSimpleCriteriaForAll() {
+ AlertDefinitionCriteria criteria = new AlertDefinitionCriteria();
+ criteria.addFilterResourceIds(Integer.valueOf(this.resource.getId()));
+ criteria.setPageControl(PageControl.getUnlimitedInstance());
+ return criteria;
+ }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java
index bc7a8b0..2e3caf0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java
@@ -79,7 +79,8 @@ public class SingleAlertDefinitionView extends LocatableVLayout {
notificationsTab.setPane(notifications);
Tab recoveryTab = new LocatableTab(tabSet.extendLocatorId("Recovery"), "Recovery");
- recovery = new RecoveryAlertDefinitionForm(this.getLocatorId(), alertDefinition);
+ recovery = new RecoveryAlertDefinitionForm(this.getLocatorId(), alertDefView.getAlertDefinitionDataSource(),
+ alertDefinition);
recoveryTab.setPane(recovery);
Tab dampeningTab = new LocatableTab(tabSet.extendLocatorId("Dampening"), "Dampening");
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsDataSource.java
index 9a96db8..15163f0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsDataSource.java
@@ -29,12 +29,21 @@ import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.data.DSRequest;
import org.rhq.core.domain.criteria.AlertDefinitionCriteria;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.domain.util.PageControl;
/**
* @author John Mazzitelli
*/
public class TemplateAlertDefinitionsDataSource extends AbstractAlertDefinitionsDataSource {
+ private ResourceType resourceType;
+
+ public TemplateAlertDefinitionsDataSource(ResourceType rt) {
+ super();
+ this.resourceType = rt;
+ }
+
@Override
protected AlertDefinitionCriteria getCriteria(DSRequest request) {
AlertDefinitionCriteria criteria = new AlertDefinitionCriteria();
@@ -54,4 +63,12 @@ public class TemplateAlertDefinitionsDataSource extends AbstractAlertDefinitions
criteria.setPageControl(getPageControl(request));
return criteria;
}
+
+ @Override
+ protected AlertDefinitionCriteria getSimpleCriteriaForAll() {
+ AlertDefinitionCriteria criteria = new AlertDefinitionCriteria();
+ criteria.addFilterAlertTemplateResourceTypeId(Integer.valueOf(this.resourceType.getId()));
+ criteria.setPageControl(PageControl.getUnlimitedInstance());
+ return criteria;
+ }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java
index 4366291..c26a8f9 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java
@@ -83,7 +83,7 @@ public class TemplateAlertDefinitionsView extends AbstractAlertDefinitionsView {
@Override
protected AbstractAlertDefinitionsDataSource getAlertDefinitionDataSource() {
- return new TemplateAlertDefinitionsDataSource();
+ return new TemplateAlertDefinitionsDataSource(resourceType);
}
@Override
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 a67696bb08a8ab5c338a6be99de8c7e01ddd2866
Author: Joseph Marques <joseph(a)redhat.com>
Date: Tue Sep 21 16:26:02 2010 -0400
go to edit mode after finished creating new group definition
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 49ea417..32692b1 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,6 +109,7 @@ 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);
@@ -136,6 +137,7 @@ 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();
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 f4ca2cf..01dceca 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
@@ -27,6 +27,7 @@ import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.data.DSCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.Record;
import com.smartgwt.client.types.DSOperationType;
import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.widgets.IButton;
@@ -36,6 +37,7 @@ 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;
import com.smartgwt.client.widgets.layout.HLayout;
import org.rhq.core.domain.authz.Permission;
@@ -62,6 +64,7 @@ public class SingleGroupDefinitionView extends LocatableVLayout implements Bookm
private int groupDefinitionId;
private GroupDefinition groupDefinition;
+ private String basePath;
private ViewId viewId;
@@ -104,6 +107,7 @@ public class SingleGroupDefinitionView extends LocatableVLayout implements Bookm
public void setGroupDefinition(GroupDefinition groupDefinition) {
this.groupDefinition = groupDefinition;
+ System.out.println("setGroupDefinition(" + groupDefinition + ")");
// form setup
id.setValue(groupDefinition.getId());
@@ -130,11 +134,6 @@ public class SingleGroupDefinitionView extends LocatableVLayout implements Bookm
form.setDataSource(dataSource);
form.setHiliteRequiredFields(true);
form.setRequiredTitleSuffix(" <span style=\"color: red;\">* </span>:");
- if (groupDefinition.getId() == 0) {
- form.setSaveOperationType(DSOperationType.ADD);
- } else {
- form.setSaveOperationType(DSOperationType.UPDATE);
- }
final DynaGroupChildrenView dynaGroupChildrenView = new DynaGroupChildrenView(extendLocatorId("DynaGroups"),
groupDefinitionId);
@@ -144,10 +143,31 @@ public class SingleGroupDefinitionView extends LocatableVLayout implements Bookm
saveButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
public void onClick(com.smartgwt.client.widgets.events.ClickEvent clickEvent) {
if (form.validate()) {
+ if (groupDefinitionId == 0) {
+ System.out.println("setting form operation: ADD");
+ form.setSaveOperationType(DSOperationType.ADD);
+ } else {
+ System.out.println("setting form operation: UPDATE");
+ form.setSaveOperationType(DSOperationType.UPDATE);
+ }
+ System.out.println("form operation type is " + form.getSaveOperationType());
form.saveData(new DSCallback() {
@Override
public void execute(DSResponse response, Object rawData, DSRequest request) {
- dynaGroupChildrenView.refresh();
+ if (SingleGroupDefinitionView.this.groupDefinitionId == 0) {
+ Record[] results = response.getData();
+ if (results.length != 1) {
+ CoreGUI.getErrorHandler().handleError(
+ "Error: " + results.length + " created instead of one");
+ } else {
+ Record newRecord = results[0];
+ GroupDefinition newGroupDefinition = dataSource
+ .copyValues((ListGridRecord) newRecord);
+ History.newItem(basePath + "/" + newGroupDefinition.getId());
+ }
+ } else {
+ dynaGroupChildrenView.refresh();
+ }
}
});
}
@@ -256,7 +276,7 @@ public class SingleGroupDefinitionView extends LocatableVLayout implements Bookm
private void buildForm() {
id = new TextItem("id", "ID");
- id.setVisible(false);
+ //id.setVisible(false);
idStatic = new StaticTextItem("idStatic", "ID");
idStatic.setVisible(false);
@@ -387,6 +407,7 @@ public class SingleGroupDefinitionView extends LocatableVLayout implements Bookm
public void renderView(ViewPath viewPath) {
groupDefinitionId = viewPath.getCurrentAsInt();
viewId = viewPath.getCurrent();
+ basePath = viewPath.getPathToCurrent();
GWTServiceLookup.getAuthorizationService().getExplicitGlobalPermissions(new AsyncCallback<Set<Permission>>() {
@Override
public void onFailure(Throwable caught) {
commit 44f77ff7a5df1f2054180290285831b44fa87292
Merge: c1f4166... c073bce...
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Tue Sep 21 15:26:36 2010 -0400
Merge branch 'master' of ssh://git.fedorahosted.org/git/rhq/rhq
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 c073bceb346b0ecc93e238cf58646624fefde13c
Merge: 4d44fd5... fe4cc40...
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Sep 21 14:26:49 2010 -0400
Merge branch 'master' into master-jay
Conflicts:
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGroupGWTService.java
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupsDataSource.java
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/ResourceGroupMembershipView.java
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/ResourceGroupResourceSelector.java
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceSelector.java
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/cluster/ClusterManagerBean.java
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerLocal.java
diff --cc modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/RecentAlertsPortlet.java
index 60a3783,f88f949..f318cf4
--- 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
@@@ -65,3 -563,95 +563,96 @@@ public class RecentAlertsPortlet extend
}
}
}
+
+ class CustomizedResourceSelector extends ResourceSelector {
- public CustomizedResourceSelector(String id) {
- super(id);
++ public CustomizedResourceSelector(String locatorId) {
++ super(locatorId);
++ }
++
++ public CustomizedResourceSelector(String locatorId, ResourceType rtFilter, boolean forceRtFilter) {
++ super(locatorId, rtFilter, forceRtFilter);
+ }
+
+ 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)) {
++ if (selector == null) {
+ // selector = new ResourceSelector(getName());
- selector = new CustomizedResourceSelector(getName());
++ selector = new CustomizedResourceSelector(getName(), ResourceType.ANY_PLATFORM_TYPE, true);
+ 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 --cc modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGroupGWTService.java
index 0951851,d475aa8..d968e19
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGroupGWTService.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGroupGWTService.java
@@@ -48,10 -49,10 +49,12 @@@ public interface ResourceGroupGWTServic
PageList<ResourceGroupComposite> findResourceGroupCompositesByCriteria(ResourceGroupCriteria criteria);
- void recalculateGroupDefinitions(int[] groupDefinitionIds);
+ void setAssignedResourceGroupsForResource(int resourceId, int[] resourceGroupIds, boolean setType);
+
+ void setAssignedResources(int groupId, int[] resourceIds, boolean setType);
- void setMembership(int groupId, int[] resourceIds, boolean setType);
++ void recalculateGroupDefinitions(int[] groupDefinitionIds);
+
void updateGroupDefinition(GroupDefinition groupDefinition);
void updateResourceGroup(ResourceGroup group);
diff --cc modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupsDataSource.java
index 20786a0,f0fe978..91bf412
--- 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
@@@ -115,11 -110,11 +110,16 @@@ public class ResourceGroupsDataSource e
"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")));
+ }
+
return criteria;
}
diff --cc modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
index 6603a00,f085e9b..05590ff
--- 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
@@@ -187,74 -192,68 +192,64 @@@ public class ResourceGroupDetailView ex
// FullHTMLPane timelinePane = new FullHTMLPane("/rhq/resource/summary/timeline-plain.xhtml?id=" + resource.getId());
// summaryTab.updateSubTab("Overview", new DashboardView(resource));
// summaryTab.updateSubTab("Timeline", timelinePane);
- this.summaryOverview.setCanvas(new OverviewView(this.summaryTab.extendLocatorId("Overview"),
- this.groupComposite));
-
- int groupId = this.groupComposite.getResourceGroup().getId();
-
- this.monitorGraphs.setCanvas(new FullHTMLPane("/rhq/group/monitor/graphs-plain.xhtml?groupId=" + groupId));
- this.monitorTables.setCanvas(new FullHTMLPane("/rhq/group/monitor/tables-plain.xhtml?groupId=" + groupId));
- this.monitorTraits.setCanvas(new TraitsView(this.monitoringTab.extendLocatorId("TraitsView"), groupId));
- this.monitorSched.setCanvas(new SchedulesView(this.monitoringTab.extendLocatorId("SchedulesView"), groupId));
- this.monitorCallTime.setCanvas(new FullHTMLPane("/rhq/group/monitor/response-plain.xhtml?groupId=" + groupId));
+ // Summary tab is always visible and enabled.
- updateSubTab(this.summaryTab, this.summaryOverview,
- new OverviewView(this.summaryTab.extendLocatorId("Overview"), 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);
++ updateSubTab(this.summaryTab, this.summaryOverview, new OverviewView(this.summaryTab
++ .extendLocatorId("Overview"), 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);
+ // TODO (ips): Add Availability subtab.
+ }
- this.inventoryMembers.setCanvas(ResourceSearchView.getMembersOf(this.inventoryTab
- .extendLocatorId("MembersView"), groupId));
+ // Inventory tab is always visible and enabled.
- updateSubTab(this.inventoryTab, this.inventoryMembers,
- ResourceSearchView.getMembersOf(this.inventoryMembers.extendLocatorId("View"), groupId), true, true);
++ updateSubTab(this.inventoryTab, this.inventoryMembers, ResourceSearchView.getMembersOf(this.inventoryTab
++ .extendLocatorId("MembersView"), groupId), true, true);
// TODO: Uncomment this once the group config component is done.
- //this.inventoryConn.setCanvas(new GroupPluginConfigurationEditView(this.group.getId(), this.group.getResourceType().getId(), ConfigurationEditor.ConfigType.plugin));
- this.inventoryMembership.setCanvas(new ResourceGroupMembershipView(this.inventoryTab
- .extendLocatorId("MembershipView"), groupId));
-
- this.opHistory.setCanvas(new FullHTMLPane("/rhq/group/operation/groupOperationHistory-plain.xhtml?groupId="
- + groupId));
- this.opSched.setCanvas(new FullHTMLPane("/rhq/group/operation/groupOperationSchedules-plain.xhtml?groupId="
- + groupId));
-
- this.alertHistory.setCanvas(new FullHTMLPane("/rhq/group/alert/listGroupAlertHistory-plain.xhtml?groupId="
- + groupId));
- this.alertDef.setCanvas(new FullHTMLPane("/rhq/group/alert/listGroupAlertDefinitions-plain.xhtml?groupId="
- + groupId));
-
- this.configCurrent.setCanvas(new FullHTMLPane("/rhq/group/configuration/viewCurrent-plain.xhtml?groupId="
- + groupId));
- this.configHistory
- .setCanvas(new FullHTMLPane("/rhq/group/configuration/history-plain.xhtml?groupId=" + groupId));
-
- this.eventHistory.setCanvas(EventCompositeHistoryView.get(groupComposite));
-
- updateTabEnablement();
- }
-
- private void updateTabEnablement() {
- GroupCategory groupCategory = groupComposite.getResourceGroup().getGroupCategory();
- Set<ResourceTypeFacet> facets = groupComposite.getResourceFacets().getFacets();
-
- // Summary and Inventory tabs are always enabled.
-
- // Only enable "Call Time" and "Traits" subtabs for groups that implement them.
- this.monitoringTab.setSubTabEnabled(this.monitorTraits.getLocatorId(), hasTraits(this.groupComposite));
- this.monitoringTab.setSubTabEnabled(this.monitorCallTime.getLocatorId(), facets
- .contains(ResourceTypeFacet.CALL_TIME));
-
- // Inventory>Connection Settings subtab is only enabled for compat groups that define conn props.
- this.inventoryTab.setSubTabEnabled(this.inventoryConn.getLocatorId(), groupCategory == GroupCategory.COMPATIBLE
- && facets.contains(ResourceTypeFacet.PLUGIN_CONFIGURATION));
-
- // Monitoring and Alerts tabs are always enabled for compatible groups and always disabled for mixed groups.
- // TODO (ips): Break out mixed groups into a separate view.
- getTabSet().setTabEnabled(this.monitoringTab, groupCategory == GroupCategory.COMPATIBLE);
- getTabSet().setTabEnabled(this.alertsTab, groupCategory == GroupCategory.COMPATIBLE);
+ //updateSubTab(this.inventoryTab, this.inventoryConn,
+ // new GroupPluginConfigurationEditView(this.group.getId(), this.group.getResourceType().getId(), ConfigurationEditor.ConfigType.plugin),
+ // facets.contains(ResourceTypeFacet.PLUGIN_CONFIGURATION), true);
- updateSubTab(this.inventoryTab, this.inventoryMembership,
- new ResourceGroupMembershipView(this.inventoryTab.extendLocatorId("MembershipView"), groupId), true, true);
-
- if (updateTab(this.operationsTab,
- groupCategory == GroupCategory.COMPATIBLE && facets.contains(ResourceTypeFacet.OPERATION), true)) {
- updateSubTab(this.operationsTab, this.opHistory,
- new FullHTMLPane("/rhq/group/operation/groupOperationHistory-plain.xhtml?groupId=" + groupId), true, true);
- updateSubTab(this.operationsTab, this.opSched,
- new FullHTMLPane("/rhq/group/operation/groupOperationSchedules-plain.xhtml?groupId=" + groupId), true, true);
++ updateSubTab(this.inventoryTab, this.inventoryMembership, new ResourceGroupMembershipView(this.inventoryTab
++ .extendLocatorId("MembershipView"), groupId), true, true);
++
++ if (updateTab(this.operationsTab, groupCategory == GroupCategory.COMPATIBLE
++ && facets.contains(ResourceTypeFacet.OPERATION), true)) {
++ updateSubTab(this.operationsTab, this.opHistory, new FullHTMLPane(
++ "/rhq/group/operation/groupOperationHistory-plain.xhtml?groupId=" + groupId), true, true);
++ updateSubTab(this.operationsTab, this.opSched, new FullHTMLPane(
++ "/rhq/group/operation/groupOperationSchedules-plain.xhtml?groupId=" + groupId), true, true);
+ }
- // Operations tab is only enabled for compatible groups of a type that supports the Operations facet.
- getTabSet().setTabEnabled(this.operationsTab, facets.contains(ResourceTypeFacet.OPERATION));
+ if (updateTab(this.operationsTab, groupCategory == GroupCategory.COMPATIBLE, true)) {
- updateSubTab(this.alertsTab, this.alertHistory,
- new FullHTMLPane("/rhq/group/alert/listGroupAlertHistory-plain.xhtml?groupId=" + groupId), true, true);
- updateSubTab(this.alertsTab, this.alertDef,
- new FullHTMLPane("/rhq/group/alert/listGroupAlertDefinitions-plain.xhtml?groupId=" + groupId), true, true);
++ updateSubTab(this.alertsTab, this.alertHistory, new FullHTMLPane(
++ "/rhq/group/alert/listGroupAlertHistory-plain.xhtml?groupId=" + groupId), true, true);
++ updateSubTab(this.alertsTab, this.alertDef, new FullHTMLPane(
++ "/rhq/group/alert/listGroupAlertDefinitions-plain.xhtml?groupId=" + groupId), true, true);
+ }
- // Configuration tab is only enabled for compatible groups of a type that supports the Configuration facet
- // and when the current user has the CONFIGURE_READ permission.
- getTabSet().setTabEnabled(this.configurationTab,
- facets.contains(ResourceTypeFacet.CONFIGURATION) && this.permissions.isConfigureRead());
- if (updateTab(this.configurationTab,
- groupCategory == GroupCategory.COMPATIBLE && facets.contains(ResourceTypeFacet.CONFIGURATION),
- 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("/rhq/group/configuration/history-plain.xhtml?groupId=" + groupId), true, true);
++ if (updateTab(this.configurationTab, groupCategory == GroupCategory.COMPATIBLE
++ && facets.contains(ResourceTypeFacet.CONFIGURATION), 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(
++ "/rhq/group/configuration/history-plain.xhtml?groupId=" + groupId), true, true);
+ }
- // Events tab is only enabled for compatible groups of a type that supports the Events facet.
- getTabSet().setTabEnabled(this.eventsTab, facets.contains(ResourceTypeFacet.EVENT));
- if (updateTab(this.eventsTab,
- groupCategory == GroupCategory.COMPATIBLE && facets.contains(ResourceTypeFacet.EVENT), true)) {
- updateSubTab(this.eventsTab, this.eventHistory,
- EventCompositeHistoryView.get(groupComposite), true, true);
++ if (updateTab(this.eventsTab, groupCategory == GroupCategory.COMPATIBLE
++ && facets.contains(ResourceTypeFacet.EVENT), true)) {
++ updateSubTab(this.eventsTab, this.eventHistory, EventCompositeHistoryView.get(groupComposite), true, true);
+ }
}
protected void loadSelectedItem(final int groupId, final ViewPath viewPath) {
diff --cc modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupMembersStep.java
index 2e3e9c7,2e3e9c7..d87e26b
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupMembersStep.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupMembersStep.java
@@@ -43,7 -43,7 +43,7 @@@ public class GroupMembersStep extends A
public Canvas getCanvas() {
if (selector == null) {
-- selector = new ResourceSelector(getName());
++ selector = new ResourceSelector("GroupMembers");
}
return selector;
}
diff --cc modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
index 8e73379,88dd2f9..8e4e16f
--- 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
@@@ -197,92 -189,92 +196,91 @@@ public class ResourceDetailView extend
((TwoLevelTab) top).getLayout().destroyViews();
}
- this.summaryOverview.setCanvas(new OverviewView(this.summaryTab.extendLocatorId("OverviewView"),
- this.resourceComposite));
- this.summaryDashboard.setCanvas(new DashboardView(this.resourceComposite));
- this.summaryTimeline.setCanvas(new FullHTMLPane("/rhq/resource/summary/timeline-plain.xhtml?id="
- + resource.getId()));
-
- this.monitorGraphs.setCanvas(new GraphListView(this.monitoringTab.extendLocatorId("GraphListView"), resource));
- this.monitorTables.setCanvas(new FullHTMLPane("/rhq/common/monitor/tables-plain.xhtml?id=" + resource.getId()));
- this.monitorTraits
- .setCanvas(new TraitsView(this.monitoringTab.extendLocatorId("TraitsView"), resource.getId()));
- this.monitorAvail.setCanvas(new FullHTMLPane("/rhq/resource/monitor/availabilityHistory-plain.xhtml?id="
- + resource.getId()));
- this.monitorSched
- .setCanvas(new SchedulesView(monitoringTab.extendLocatorId("SchedulesView"), resource.getId()));
- this.monitorCallTime.setCanvas(new FullHTMLPane("/rhq/resource/monitor/response-plain.xhtml?id="
- + resource.getId()));
-
- this.inventoryChildren.setCanvas(ResourceSearchView.getChildrenOf(this.inventoryTab
- .extendLocatorId("ChildrenView"), resource.getId()));
- this.inventoryConn.setCanvas(new PluginConfigurationEditView(this.inventoryTab
- .extendLocatorId("PluginConfigView"), resource));
- this.inventoryGroups.setCanvas(ResourceGroupListView.getGroupsOf(this.inventoryTab
- .extendLocatorId("GroupsView"), resource.getId()));
- this.inventoryGroupMembership.setCanvas(new ResourceResourceGroupsView(this.inventoryTab
- .extendLocatorId("GroupMembershipView"), resourceId));
-
- // comment out GWT-based operation history until...
- // 1) user can delete history if they possess the appropriate permissions
- // 2) user can see both operation arguments and results in the history details pop-up
- // 3) operation arguments/results become read-only configuration data in the history details pop-up
- // 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
- this.opHistory.setCanvas(OperationHistoryView.getResourceHistoryView(operationsTab.extendLocatorId("History"),
- resourceComposite));
- this.opSched.setCanvas(new FullHTMLPane("/rhq/resource/operation/resourceOperationSchedules-plain.xhtml?id="
- + resource.getId()));
+ ResourcePermission permissions = this.resourceComposite.getResourcePermission();
+ Set<ResourceTypeFacet> facets = this.resourceComposite.getResourceFacets().getFacets();
+
- updateSubTab(this.summaryTab, this.summaryOverview,
- new OverviewView(this.summaryOverview.getLocatorId(), this.resourceComposite), true, true);
- updateSubTab(this.summaryTab, this.summaryDashboard,
- new DashboardView(this.resourceComposite), true, true);
- updateSubTab(this.summaryTab, this.summaryTimeline,
- new FullHTMLPane("/rhq/resource/summary/timeline-plain.xhtml?id=" + resource.getId()), true, true);
++ updateSubTab(this.summaryTab, this.summaryOverview, new OverviewView(this.summaryTab
++ .extendLocatorId("OverviewView"), this.resourceComposite), true, true);
++ updateSubTab(this.summaryTab, this.summaryDashboard, new DashboardView(this.resourceComposite), true, true);
++ 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),
++ 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()),
++ 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);
- 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);
++ 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);
+
+ ResourceType type = this.resourceComposite.getResource().getResourceType();
- updateSubTab(this.inventoryTab, this.inventoryChildren,
- ResourceSearchView.getChildrenOf(this.extendLocatorId("Children"), resource.getId()),
- !type.getChildResourceTypes().isEmpty(), true);
- updateSubTab(this.inventoryTab, this.inventoryConn,
- new PluginConfigurationEditView(this.extendLocatorId("PluginConfig"), resource),
- facets.contains(ResourceTypeFacet.PLUGIN_CONFIGURATION), true);
++ 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);
++ updateSubTab(this.inventoryTab, this.inventoryGroups, ResourceGroupListView.getGroupsOf(this.inventoryTab
++ .extendLocatorId("GroupsView"), resource.getId()), true, true);
++ updateSubTab(this.inventoryTab, this.inventoryGroupMembership, new ResourceResourceGroupsView(this.inventoryTab
++ .extendLocatorId("GroupMembershipView"), resourceId), true, true);
+
+ if (updateTab(this.operationsTab, facets.contains(ResourceTypeFacet.OPERATION), true)) {
+ // comment out GWT-based operation history until...
+ // 1) user can delete history if they possess the appropriate permissions
+ // 2) user can see both operation arguments and results in the history details pop-up
+ // 3) operation arguments/results become read-only configuration data in the history details pop-up
+ // 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);
- updateSubTab(this.operationsTab, this.opSched,
- new FullHTMLPane("/rhq/resource/operation/resourceOperationSchedules-plain.xhtml?id=" + resource.getId()),
- true, true);
++ updateSubTab(this.operationsTab, this.opHistory, OperationHistoryView.getResourceHistoryView(operationsTab
++ .extendLocatorId("History"), this.resourceComposite), true, true);
++ updateSubTab(this.operationsTab, this.opSched, new FullHTMLPane(
++ "/rhq/resource/operation/resourceOperationSchedules-plain.xhtml?id=" + resource.getId()), true, true);
+ }
// comment out GWT-based alert definitions/history views until...
// 1) new workflow is implement for alert definition creation, with particular attention to interaction model for alert notifications
// 2) user can delete/ack/purgeAll alerts if they possess the appropriate permissions
// 3) user can enable/disable/delete alert definitions if they possess the appropriate permissions
// 4) user can search alert history by: date alert was fired, alert priority, or alert definition
- this.alertHistory.setCanvas(new FullHTMLPane("/rhq/resource/alert/listAlertHistory-plain.xhtml?id="
- + resource.getId()));
- this.alertDef.setCanvas(new ResourceAlertDefinitionsView(alertsTab.extendLocatorId("AlertDef"),
- resourceComposite));
- this.alertDelete.setCanvas(new FullHTMLPane("/rhq/resource/alert/listAlertDefinitions-plain.xhtml?id="
- + resource.getId()));
-
- this.configCurrent
- .setCanvas(new ResourceConfigurationEditView(this.extendLocatorId("ResourceConfig"), resource));
- this.configHistory.setCanvas(ConfigurationHistoryView.getHistoryOf(configurationTab.extendLocatorId("Hist"),
- resource.getId()));
-
- this.eventHistory.setCanvas(EventCompositeHistoryView.get(resourceComposite));
-
- this.contentDeployed
- .setCanvas(new FullHTMLPane("/rhq/resource/content/view-plain.xhtml?id=" + resource.getId()));
- this.contentNew.setCanvas(new FullHTMLPane("/rhq/resource/content/deploy-plain.xhtml?id=" + resource.getId()));
- this.contentSubscrip.setCanvas(new FullHTMLPane("/rhq/resource/content/subscription-plain.xhtml?id="
- + resource.getId()));
- this.contentHistory.setCanvas(new FullHTMLPane("/rhq/resource/content/history-plain.xhtml?id="
- + resource.getId()));
-
- updateTabEnablement();
- }
-
- private void updateTabEnablement() {
- ResourcePermission permissions = this.resourceComposite.getResourcePermission();
- Set<ResourceTypeFacet> facets = this.resourceComposite.getResourceFacets().getFacets();
-
- // Summary, Monitoring, Inventory, and Alerts tabs are always enabled.
-
- monitoringTab.setSubTabEnabled(monitorTraits.getLocatorId(), hasTraits(this.resourceComposite));
- monitoringTab.setSubTabEnabled(monitorCallTime.getLocatorId(), facets.contains(ResourceTypeFacet.CALL_TIME));
- 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);
- updateSubTab(this.alertsTab, this.alertDelete,
- new FullHTMLPane("/rhq/resource/alert/listAlertDefinitions-plain.xhtml?id=" + resource.getId()), true, true);
++ 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);
++ 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);
- updateSubTab(this.configurationTab, this.configHistory,
- ConfigurationHistoryView.getHistoryOf(configurationTab.extendLocatorId("Hist"), 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);
++ updateSubTab(this.configurationTab, this.configHistory, ConfigurationHistoryView.getHistoryOf(
++ configurationTab.extendLocatorId("Hist"), resource.getId()), true, true);
+ }
- inventoryTab.setSubTabEnabled(inventoryConn.getLocatorId(), facets
- .contains(ResourceTypeFacet.PLUGIN_CONFIGURATION));
- ResourceType type = this.resourceComposite.getResource().getResourceType();
- inventoryTab.setSubTabEnabled(inventoryChildren.getLocatorId(), !type.getChildResourceTypes().isEmpty());
+ if (updateTab(this.eventsTab, facets.contains(ResourceTypeFacet.EVENT), true)) {
- updateSubTab(this.eventsTab, this.eventHistory,
- EventCompositeHistoryView.get(resourceComposite), true, true);
++ updateSubTab(this.eventsTab, this.eventHistory, EventCompositeHistoryView.get(resourceComposite), true,
++ true);
+ }
- getTabSet().setTabEnabled(this.operationsTab, facets.contains(ResourceTypeFacet.OPERATION));
- getTabSet().setTabEnabled(this.configurationTab,
- facets.contains(ResourceTypeFacet.CONFIGURATION) && permissions.isConfigureRead());
- getTabSet().setTabEnabled(this.eventsTab, facets.contains(ResourceTypeFacet.EVENT));
- getTabSet().setTabEnabled(this.contentTab, facets.contains(ResourceTypeFacet.CONTENT));
+ if (updateTab(this.contentTab, facets.contains(ResourceTypeFacet.CONTENT), true)) {
- updateSubTab(this.contentTab, this.contentDeployed,
- new FullHTMLPane("/rhq/resource/content/view-plain.xhtml?id=" + resource.getId()), true, true);
- updateSubTab(this.contentTab, this.contentNew,
- new FullHTMLPane("/rhq/resource/content/deploy-plain.xhtml?id=" + resource.getId()), true, true);
- updateSubTab(this.contentTab, this.contentSubscrip,
- new FullHTMLPane("/rhq/resource/content/subscription-plain.xhtml?id=" + resource.getId()), true, true);
- updateSubTab(this.contentTab, this.contentHistory,
- new FullHTMLPane("/rhq/resource/content/history-plain.xhtml?id=" + resource.getId()), true, true);
++ updateSubTab(this.contentTab, this.contentDeployed, new FullHTMLPane(
++ "/rhq/resource/content/view-plain.xhtml?id=" + resource.getId()), true, true);
++ updateSubTab(this.contentTab, this.contentNew, new FullHTMLPane(
++ "/rhq/resource/content/deploy-plain.xhtml?id=" + resource.getId()), true, true);
++ updateSubTab(this.contentTab, this.contentSubscrip, new FullHTMLPane(
++ "/rhq/resource/content/subscription-plain.xhtml?id=" + resource.getId()), true, true);
++ updateSubTab(this.contentTab, this.contentHistory, new FullHTMLPane(
++ "/rhq/resource/content/history-plain.xhtml?id=" + resource.getId()), true, true);
+ }
}
public Integer getSelectedItemId() {
diff --cc modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/cluster/ClusterManagerBean.java
index b210e31,4aaf7ca..b81400d
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/cluster/ClusterManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/cluster/ClusterManagerBean.java
@@@ -138,8 -138,8 +138,8 @@@ public class ClusterManagerBean impleme
try {
// You are allowed to cause the creation of an auto cluster backing group as long as you can
// view the parent group. (That check was done above)
- resourceGroupManager.setAssignedResources(subjectManager.getOverlord(), autoClusterBackingGroup.getId(),
- resourceIds, false);
- resourceGroupManager.setMembership(subjectManager.getOverlord(), autoClusterBackingGroup.getId(),
- resourceIds, false);
++ resourceGroupManager.setAssignedResources(subjectManager.getOverlord(),
++ autoClusterBackingGroup.getId(), resourceIds, false);
} catch (Exception e) {
log.error("Could not add resources to group:" + e);
}
diff --cc modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java
index 3acae10,28ae218..0e7500f
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java
@@@ -1319,40 -1319,6 +1319,39 @@@ public class ResourceGroupManagerBean i
}
}
+ public void setAssignedResourceGroupsForResource(Subject subject, int resourceId, int[] resourceGroupIds,
+ boolean setType) throws ResourceGroupDeleteException {
+
+ Resource resource = entityManager.find(Resource.class, resourceId);
+ Set<ResourceGroup> currentGroups = resource.getExplicitGroups();
+ List<Integer> currentGroupIds = new ArrayList<Integer>(currentGroups.size());
+ for (ResourceGroup currentGroup : currentGroups) {
+ currentGroupIds.add(currentGroup.getId());
+ }
+
+ int[] resourceIdArr = new int[] { resourceId };
+
+ List<Integer> addedGroupIds = ArrayUtils.wrapInList(resourceGroupIds);
+ addedGroupIds.removeAll(currentGroupIds);
+ for (Integer addedGroupId : addedGroupIds) {
+ addResourcesToGroup(subject, addedGroupId, resourceIdArr);
+ // As a result of the membership change ensure that the group type is set correctly.
+ if (setType) {
+ setResourceType(addedGroupId);
+ }
+ }
+
+ List<Integer> removedGroupIds = new ArrayList<Integer>(currentGroupIds); // groups needing removal
+ removedGroupIds.removeAll(ArrayUtils.wrapInList(resourceGroupIds));
+ for (Integer removedGroupId : removedGroupIds) {
+ removeResourcesFromGroup(subject, removedGroupId, resourceIdArr);
+ // As a result of the membership change ensure that the group type is set correctly.
+ if (setType) {
+ setResourceType(removedGroupId);
+ }
+ }
-
+ }
+
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// Remote interface impl
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
commit c1f4166199695ed25b031074f10cb9a012bacd47
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Tue Sep 21 13:01:56 2010 -0400
don't pluralize subcat names since they're typically already pluralized as defined in the plugin descriptors
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 0862d3a..2516ac5 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
@@ -262,7 +262,8 @@ public class ResourceTreeDatasource extends DataSource {
setParentID(parentResourceId);
setAttribute("parentId", parentResourceId);
- String name = pluralize(category.getDisplayName());
+ // Note, subcategory names are typically already plural, so there's no need to pluralize them.
+ String name = category.getDisplayName();
setName(name);
setAttribute("name", name);
}
@@ -360,8 +361,15 @@ public class ResourceTreeDatasource extends DataSource {
return id.replace(' ', '_');
}
- private static String pluralize(String s) {
+ private static String pluralize(String singularNoun) {
// TODO: Make this smarter.
- return s + "s";
+ String pluralNoun;
+ if (singularNoun.endsWith("y") && !singularNoun.endsWith("ay") && !singularNoun.endsWith("ey") &&
+ !singularNoun.endsWith("oy")) {
+ pluralNoun = singularNoun.substring(0, singularNoun.length() - 1) + "ies";
+ } else {
+ pluralNoun = singularNoun + "s";
+ }
+ return pluralNoun;
}
}
commit 4d44fd501554dbb58b30b7f561f110953b525dba
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Sep 21 12:41:16 2010 -0400
Group CRUD
- initially restrict group membership to group type for compat groups
- renamed some new "setAssigned*" SLSB methods for understanding and
consistency. (may need to consider these for remote API later)
- added new resource inventory subtabs for group view/assignment
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UserEditView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UserEditView.java
index 9ea9467..6c86265 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UserEditView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UserEditView.java
@@ -160,7 +160,7 @@ public class UserEditView extends LocatableVLayout implements BookmarkableView {
roleIds[i++] = id;
}
- GWTServiceLookup.getRoleService().setAssignedSubjectRoles(subjectId, roleIds,
+ GWTServiceLookup.getRoleService().setAssignedRolesForSubject(subjectId, roleIds,
new AsyncCallback<Void>() {
public void onFailure(Throwable caught) {
CoreGUI.getErrorHandler().handleError("Failed to save user role assignments.", caught);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGroupGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGroupGWTService.java
index 333427f..0951851 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGroupGWTService.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGroupGWTService.java
@@ -48,7 +48,9 @@ public interface ResourceGroupGWTService extends RemoteService {
PageList<ResourceGroupComposite> findResourceGroupCompositesByCriteria(ResourceGroupCriteria criteria);
- void setMembership(int groupId, int[] resourceIds, boolean setType);
+ void setAssignedResourceGroupsForResource(int resourceId, int[] resourceGroupIds, boolean setType);
+
+ void setAssignedResources(int groupId, int[] resourceIds, boolean setType);
void updateGroupDefinition(GroupDefinition groupDefinition);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/RoleGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/RoleGWTService.java
index 932ceb8..41d7204 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/RoleGWTService.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/RoleGWTService.java
@@ -18,13 +18,12 @@
*/
package org.rhq.enterprise.gui.coregui.client.gwt;
-import org.rhq.core.domain.auth.Subject;
+import com.google.gwt.user.client.rpc.RemoteService;
+
import org.rhq.core.domain.authz.Role;
import org.rhq.core.domain.criteria.RoleCriteria;
import org.rhq.core.domain.util.PageList;
-import com.google.gwt.user.client.rpc.RemoteService;
-
/**
* @author Greg Hinkle
*/
@@ -42,5 +41,5 @@ public interface RoleGWTService extends RemoteService {
void setAssignedSubjects(int roleId, int[] subjectIds);
- void setAssignedSubjectRoles(int subjectId, int[] roleIds);
+ void setAssignedRolesForSubject(int subjectId, int[] roleIds);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupListView.java
index 38d409f..7053f7c 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupListView.java
@@ -123,4 +123,11 @@ public class ResourceGroupListView extends Table {
});
}
+ // -------- Static Utility loaders ------------
+
+ public static ResourceGroupListView getGroupsOf(String locatorId, int explicitResourceId) {
+ return new ResourceGroupListView(locatorId, new Criteria("explicitResourceId", String
+ .valueOf(explicitResourceId)), "Resource Groups");
+ }
+
}
\ No newline at end of file
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 00e9389..20786a0 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
@@ -115,6 +115,11 @@ public class ResourceGroupsDataSource extends RPCDataSource<ResourceGroup> {
"downMemberCount")));
}
+ if (request.getCriteria().getValues().get("explicitResourceId") != null) {
+ criteria.addFilterExplicitResourceIds(Integer.parseInt((String) request.getCriteria().getValues().get(
+ "explicitResourceId")));
+ }
+
return criteria;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/ResourceGroupMembershipView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/ResourceGroupMembershipView.java
index e08b57d..48d0859 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/ResourceGroupMembershipView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/ResourceGroupMembershipView.java
@@ -22,7 +22,6 @@ package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.inventory;
import java.util.HashSet;
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;
@@ -30,6 +29,7 @@ import com.smartgwt.client.widgets.layout.LayoutSpacer;
import com.smartgwt.client.widgets.toolbar.ToolStrip;
import org.rhq.core.domain.criteria.ResourceGroupCriteria;
+import org.rhq.core.domain.resource.group.GroupCategory;
import org.rhq.core.domain.resource.group.ResourceGroup;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
@@ -79,6 +79,7 @@ public class ResourceGroupMembershipView extends LocatableVLayout {
ResourceGroupCriteria c = new ResourceGroupCriteria();
c.addFilterId(this.resourceGroupId);
c.fetchExplicitResources(true);
+ c.fetchResourceType(true);
GWTServiceLookup.getResourceGroupService().findResourceGroupsByCriteria(c,
new AsyncCallback<PageList<ResourceGroup>>() {
public void onFailure(Throwable caught) {
@@ -86,11 +87,14 @@ public class ResourceGroupMembershipView extends LocatableVLayout {
}
public void onSuccess(PageList<ResourceGroup> result) {
- ResourceGroupMembershipView.this.resourceGroup = result.get(0);
+ ResourceGroup group = result.get(0);
+ ResourceGroupMembershipView.this.resourceGroup = group;
ResourceGroupMembershipView.this.selector = new ResourceGroupResourceSelector(
- ResourceGroupMembershipView.this.getLocatorId(), ResourceGroupMembershipView.this.resourceGroup
- .getExplicitResources());
- ResourceGroupMembershipView.this.selector.setOverflow(Overflow.AUTO);
+ ResourceGroupMembershipView.this.getLocatorId(),
+ group.getExplicitResources(),
+ (GroupCategory.COMPATIBLE == ResourceGroupMembershipView.this.resourceGroup.getGroupCategory()) ? group
+ .getResourceType()
+ : null, false);
addMember(ResourceGroupMembershipView.this.selector);
}
@@ -100,7 +104,7 @@ public class ResourceGroupMembershipView extends LocatableVLayout {
private void save() {
int[] resourceIds = getSelectedResourceIds();
- GWTServiceLookup.getResourceGroupService().setMembership(this.resourceGroup.getId(), resourceIds, true,
+ GWTServiceLookup.getResourceGroupService().setAssignedResources(this.resourceGroup.getId(), resourceIds, true,
new AsyncCallback<Void>() {
public void onFailure(Throwable caught) {
CoreGUI.getErrorHandler().handleError("Failed to update configuration", caught);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/ResourceGroupResourceSelector.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/ResourceGroupResourceSelector.java
index 6bc96fb..587a8ca 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/ResourceGroupResourceSelector.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/ResourceGroupResourceSelector.java
@@ -24,9 +24,11 @@ package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.inventory;
import java.util.Collection;
+import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.ResourceType;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDatasource;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.selection.ResourceSelector;
@@ -35,11 +37,16 @@ import org.rhq.enterprise.gui.coregui.client.inventory.resource.selection.Resour
*/
public class ResourceGroupResourceSelector extends ResourceSelector {
- public ResourceGroupResourceSelector(String locatorId, Collection<Resource> resources) {
- super(locatorId);
+ public ResourceGroupResourceSelector(String locatorId, Collection<Resource> resources,
+ ResourceType resourceTypeFilter, boolean forceResourceTypeFilter) {
+
+ super(locatorId, resourceTypeFilter, forceResourceTypeFilter);
+
if (null != resources) {
ListGridRecord[] data = (new ResourceDatasource()).buildRecords(resources);
setAssigned(data);
}
+
+ this.setOverflow(Overflow.AUTO);
}
}
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 e80be32..8e73379 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
@@ -44,11 +44,13 @@ import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTab;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.AbstractTwoLevelTabSetView;
import org.rhq.enterprise.gui.coregui.client.inventory.common.event.EventCompositeHistoryView;
+import org.rhq.enterprise.gui.coregui.client.inventory.groups.ResourceGroupListView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.InventoryView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceSearchView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.configuration.ConfigurationHistoryView;
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;
@@ -91,6 +93,8 @@ public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceCompo
private SubTab monitorCallTime;
private SubTab inventoryChildren;
private SubTab inventoryConn;
+ private SubTab inventoryGroups;
+ private SubTab inventoryGroupMembership;
private SubTab opHistory;
private SubTab opSched;
private SubTab alertHistory;
@@ -135,7 +139,10 @@ public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceCompo
"/images/icons/Inventory_grey_16.png");
inventoryChildren = new SubTab(inventoryTab.extendLocatorId("Children"), "Children", null);
inventoryConn = new SubTab(inventoryTab.extendLocatorId("ConnectionSettings"), "Connection Settings", null);
- inventoryTab.registerSubTabs(this.inventoryChildren, this.inventoryConn);
+ inventoryGroups = new SubTab(inventoryTab.extendLocatorId("Groups"), "Groups", null);
+ inventoryGroupMembership = new SubTab(inventoryTab.extendLocatorId("GroupMembership"), "Group Membership", null);
+ inventoryTab.registerSubTabs(this.inventoryChildren, this.inventoryConn, this.inventoryGroups,
+ this.inventoryGroupMembership);
tabs.add(inventoryTab);
operationsTab = new TwoLevelTab(getTabSet().extendLocatorId("Operations"), "Operations",
@@ -207,9 +214,14 @@ public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceCompo
this.monitorCallTime.setCanvas(new FullHTMLPane("/rhq/resource/monitor/response-plain.xhtml?id="
+ resource.getId()));
- this.inventoryChildren.setCanvas(ResourceSearchView.getChildrenOf(this.extendLocatorId("Children"), resource
- .getId()));
- this.inventoryConn.setCanvas(new PluginConfigurationEditView(this.extendLocatorId("PluginConfig"), resource));
+ this.inventoryChildren.setCanvas(ResourceSearchView.getChildrenOf(this.inventoryTab
+ .extendLocatorId("ChildrenView"), resource.getId()));
+ this.inventoryConn.setCanvas(new PluginConfigurationEditView(this.inventoryTab
+ .extendLocatorId("PluginConfigView"), resource));
+ this.inventoryGroups.setCanvas(ResourceGroupListView.getGroupsOf(this.inventoryTab
+ .extendLocatorId("GroupsView"), resource.getId()));
+ this.inventoryGroupMembership.setCanvas(new ResourceResourceGroupsView(this.inventoryTab
+ .extendLocatorId("GroupMembershipView"), resourceId));
// comment out GWT-based operation history until...
// 1) user can delete history if they possess the appropriate permissions
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/ResourceResourceGroupSelector.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/ResourceResourceGroupSelector.java
new file mode 100644
index 0000000..6a178ea
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/ResourceResourceGroupSelector.java
@@ -0,0 +1,50 @@
+/*
+ * 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.resource.detail.inventory;
+
+import java.util.Collection;
+
+import com.smartgwt.client.types.Overflow;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+
+import org.rhq.core.domain.resource.group.ResourceGroup;
+import org.rhq.enterprise.gui.coregui.client.inventory.groups.ResourceGroupsDataSource;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.selection.ResourceGroupSelector;
+
+/**
+ * @author Jay Shaughnessy
+ */
+public class ResourceResourceGroupSelector extends ResourceGroupSelector {
+
+ public ResourceResourceGroupSelector(String locatorId, Collection<ResourceGroup> resourceGroups) {
+
+ super(locatorId);
+
+ if (null != resourceGroups) {
+ ListGridRecord[] data = (new ResourceGroupsDataSource()).buildRecords(resourceGroups);
+ setAssigned(data);
+ }
+
+ this.setOverflow(Overflow.AUTO);
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/ResourceResourceGroupsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/ResourceResourceGroupsView.java
new file mode 100644
index 0000000..8669142
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/ResourceResourceGroupsView.java
@@ -0,0 +1,125 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.inventory;
+
+import java.util.HashSet;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+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;
+import com.smartgwt.client.widgets.toolbar.ToolStrip;
+
+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.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.util.message.Message;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIButton;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+
+/**
+ * @author Jay Shaughnessy
+ */
+public class ResourceResourceGroupsView extends LocatableVLayout {
+
+ private int resourceId;
+ private Resource resource;
+ private ResourceResourceGroupSelector selector;
+
+ public ResourceResourceGroupsView(String locatorId, int resourceId) {
+ super(locatorId);
+
+ this.resourceId = resourceId;
+ }
+
+ @Override
+ protected void onDraw() {
+ super.onDraw();
+
+ build();
+ }
+
+ 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() {
+ public void onClick(ClickEvent clickEvent) {
+ save();
+ }
+ });
+
+ toolStrip.addMember(saveButton);
+ this.addMember(toolStrip);
+
+ ResourceCriteria c = new ResourceCriteria();
+ c.addFilterId(this.resourceId);
+ c.fetchExplicitGroups(true);
+ GWTServiceLookup.getResourceService().findResourcesByCriteria(c, new AsyncCallback<PageList<Resource>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to fetch Resource's Groups", caught);
+ }
+
+ public void onSuccess(PageList<Resource> result) {
+ resource = result.get(0);
+ ResourceResourceGroupsView.this.selector = new ResourceResourceGroupSelector(
+ ResourceResourceGroupsView.this.getLocatorId(), resource.getExplicitGroups());
+
+ addMember(ResourceResourceGroupsView.this.selector);
+ }
+ });
+ }
+
+ private void save() {
+ int[] resourceGroupIds = getSelectedResourceGroupIds();
+
+ GWTServiceLookup.getResourceGroupService().setAssignedResourceGroupsForResource(this.resource.getId(),
+ resourceGroupIds, true, new AsyncCallback<Void>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to update configuration", caught);
+ }
+
+ public void onSuccess(Void result) {
+ CoreGUI.getMessageCenter().notify(
+ new Message("Group membership updated for ["
+ + ResourceResourceGroupsView.this.resource.getName() + "]", Message.Severity.Info));
+ CoreGUI.refresh();
+ }
+ });
+ }
+
+ private int[] getSelectedResourceGroupIds() {
+ int[] selection = new int[this.selector.getSelection().size()];
+ HashSet<Integer> selectedIds = this.selector.getSelection();
+ int i = 0;
+ for (Integer id : selectedIds) {
+ selection[i++] = id;
+ }
+
+ return selection;
+ }
+
+}
\ No newline at end of file
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 b1ad07f..0047b1f 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
@@ -47,28 +47,29 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
*/
public class ResourceSelector extends AbstractSelector<Resource> {
- private ResourceType requireType;
+ private ResourceType resourceTypeFilter;
+ private boolean forceResourceTypeFilter;
+ private IPickTreeItem typeSelectItem;
public ResourceSelector(String locatorId) {
- super(locatorId);
- }
-
- public ResourceType getRequireType() {
- return requireType;
+ this(locatorId, null, false);
}
- public void setRequireType(ResourceType requireType) {
- this.requireType = requireType;
- markForRedraw();
+ public ResourceSelector(String locatorId, ResourceType resourceTypeFilter, boolean forceResourceTypeFilter) {
+ super(locatorId);
+ this.resourceTypeFilter = resourceTypeFilter;
+ this.forceResourceTypeFilter = forceResourceTypeFilter;
}
protected DynamicForm getAvailableFilterForm() {
if (null == availableFilterForm) {
availableFilterForm = new LocatableDynamicForm("ResSelectAvailFilterForm");
availableFilterForm.setNumCols(6);
+ availableFilterForm.setWidth("75%");
final TextItem search = new TextItem("search", "Search");
+ final SelectItem categorySelect;
- IPickTreeItem typeSelectItem = new IPickTreeItem("type", "Type");
+ typeSelectItem = new IPickTreeItem("type", "Type");
typeSelectItem.setDataSource(new ResourceTypePluginTreeDataSource());
typeSelectItem.setValueField("id");
typeSelectItem.setCanSelectParentItems(true);
@@ -76,22 +77,15 @@ public class ResourceSelector extends AbstractSelector<Resource> {
typeSelectItem.setEmptyMenuMessage("Loading...");
typeSelectItem.setShowIcons(true);
- if (requireType != null) {
- // TODO: Currently ignore the typeSelectItem widget because we already know the type.
- // Alternatively, we could display it disabled but we'd want the type name to be displayed as the
- // value. To get this to display the type name I think we need to pre-fetch the type tree here. We could
- // potentially optimize typeSelectItem.setValue(requireType.getId()) to buildNodes a tree that includes only
- // this single type.
- //typeSelectItem.setValue(requireType.getId());
- //typeSelectItem.setDisabled(true);
- availableFilterForm.setItems(search);
- } else {
- SelectItem categorySelect = new SelectItem("category", "Category");
- categorySelect.setValueMap("Platform", "Server", "Service");
- categorySelect.setAllowEmptyValue(true);
-
- availableFilterForm.setItems(search, typeSelectItem, categorySelect);
+ if (this.forceResourceTypeFilter) {
+ typeSelectItem.setDisabled(true);
}
+
+ categorySelect = new SelectItem("category", "Category");
+ categorySelect.setValueMap("Platform", "Server", "Service");
+ categorySelect.setAllowEmptyValue(true);
+
+ availableFilterForm.setItems(search, categorySelect, typeSelectItem);
}
return availableFilterForm;
@@ -173,13 +167,15 @@ public class ResourceSelector extends AbstractSelector<Resource> {
@Override
protected ResourceCriteria getFetchCriteria(final DSRequest request) {
- ResourceCriteria result = super.getFetchCriteria(request);
-
- // additional filters
- if (null != requireType) {
- result.addFilterResourceTypeId(requireType.getId());
+ // if specified seed with an initial type filter
+ if (null != ResourceSelector.this.resourceTypeFilter) {
+ ResourceSelector.this.typeSelectItem.setValue(resourceTypeFilter.getId());
+ request.getCriteria().addCriteria(TYPE.propertyName(), String.valueOf(resourceTypeFilter.getId()));
+ ResourceSelector.this.resourceTypeFilter = null;
}
+ ResourceCriteria result = super.getFetchCriteria(request);
+
// additional return data
result.fetchResourceType(true);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java
index b9642d6..8655bd8 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java
@@ -71,9 +71,17 @@ public class ResourceGroupGWTServiceImpl extends AbstractGWTServiceImpl implemen
}
}
- public void setMembership(int groupId, int[] resourceIds, boolean setType) {
+ public void setAssignedResources(int groupId, int[] resourceIds, boolean setType) {
try {
- groupManager.setMembership(getSessionSubject(), groupId, resourceIds, setType);
+ groupManager.setAssignedResources(getSessionSubject(), groupId, resourceIds, setType);
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ }
+ }
+
+ public void setAssignedResourceGroupsForResource(int resourceId, int[] resourceGroupIds, boolean setType) {
+ try {
+ groupManager.setAssignedResources(getSessionSubject(), resourceId, resourceGroupIds, setType);
} catch (Throwable t) {
throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
@@ -83,7 +91,7 @@ public class ResourceGroupGWTServiceImpl extends AbstractGWTServiceImpl implemen
try {
Subject user = getSessionSubject();
group = groupManager.createResourceGroup(user, group);
- groupManager.setMembership(user, group.getId(), resourceIds, true);
+ groupManager.setAssignedResources(user, group.getId(), resourceIds, true);
return SerialUtility.prepare(group, "ResourceGroupService.createResourceGroup");
} catch (Throwable t) {
throw new RuntimeException(ThrowableUtil.getAllMessages(t));
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/RoleGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/RoleGWTServiceImpl.java
index 87d9132..7b278e1 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/RoleGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/RoleGWTServiceImpl.java
@@ -18,7 +18,6 @@
*/
package org.rhq.enterprise.gui.coregui.server.gwt;
-import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.authz.Role;
import org.rhq.core.domain.criteria.RoleCriteria;
import org.rhq.core.domain.util.PageList;
@@ -34,20 +33,17 @@ public class RoleGWTServiceImpl extends AbstractGWTServiceImpl implements RoleGW
private RoleManagerLocal roleManager = LookupUtil.getRoleManager();
-
public PageList<Role> findRolesByCriteria(RoleCriteria criteria) {
return SerialUtility.prepare(roleManager.findRolesByCriteria(getSessionSubject(), criteria),
- "RoleService.findRolesByCriteria");
+ "RoleService.findRolesByCriteria");
}
public Role createRole(Role role) {
- return SerialUtility.prepare(roleManager.createRole(getSessionSubject(), role),
- "RoleService.createRole");
+ return SerialUtility.prepare(roleManager.createRole(getSessionSubject(), role), "RoleService.createRole");
}
public Role updateRole(Role role) {
- return SerialUtility.prepare(roleManager.updateRole(getSessionSubject(), role),
- "RoleService.updateRole");
+ return SerialUtility.prepare(roleManager.updateRole(getSessionSubject(), role), "RoleService.updateRole");
}
public void removeRoles(Integer[] roleIds) {
@@ -62,8 +58,7 @@ public class RoleGWTServiceImpl extends AbstractGWTServiceImpl implements RoleGW
roleManager.setAssignedSubjects(getSessionSubject(), roleId, subjectIds);
}
-
- public void setAssignedSubjectRoles(int subjectId, int[] roleIds) {
+ public void setAssignedRolesForSubject(int subjectId, int[] roleIds) {
roleManager.setAssignedSubjectRoles(getSessionSubject(), subjectId, roleIds);
}
}
\ No newline at end of file
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 ce68440..c9b4420 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
@@ -721,7 +721,7 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
// This ensures Hibernate actually fetches the parent Resource.
grandchildResource.getParentResource().getId();
}
- }
+ }
}
return result;
@@ -2126,7 +2126,7 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
@SuppressWarnings("unchecked")
public PageList<Resource> findResourcesByCriteria(Subject subject, ResourceCriteria criteria) {
CriteriaQueryGenerator generator = new CriteriaQueryGenerator(subject, criteria);
- ;
+
if (authorizationManager.isInventoryManager(subject) == false) {
if (criteria.isInventoryManagerRequired()) {
throw new PermissionException("Subject [" + subject.getName()
@@ -2138,8 +2138,8 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
}
CriteriaQueryRunner<Resource> queryRunner = new CriteriaQueryRunner(criteria, generator, entityManager);
-
- return queryRunner.execute();
+ PageList<Resource> results = queryRunner.execute();
+ return results;
}
public Resource getPlaformOfResource(Subject subject, int resourceId) {
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/cluster/ClusterManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/cluster/ClusterManagerBean.java
index 4aaf7ca..b210e31 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/cluster/ClusterManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/cluster/ClusterManagerBean.java
@@ -138,7 +138,7 @@ public class ClusterManagerBean implements ClusterManagerLocal, ClusterManagerRe
try {
// You are allowed to cause the creation of an auto cluster backing group as long as you can
// view the parent group. (That check was done above)
- resourceGroupManager.setMembership(subjectManager.getOverlord(), autoClusterBackingGroup.getId(),
+ resourceGroupManager.setAssignedResources(subjectManager.getOverlord(), autoClusterBackingGroup.getId(),
resourceIds, false);
} catch (Exception e) {
log.error("Could not add resources to group:" + e);
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java
index 28ae218..3acae10 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java
@@ -1296,9 +1296,9 @@ public class ResourceGroupManagerBean implements ResourceGroupManagerLocal, Reso
return groupIds;
}
- public void setMembership(Subject subject, int groupId, int[] resourceIds, boolean setType)
+ public void setAssignedResources(Subject subject, int groupId, int[] resourceIds, boolean setType)
throws ResourceGroupDeleteException {
- //throws ResourceGroupUpdateException {
+
List<Integer> currentMembers = resourceManager.findExplicitResourceIdsByResourceGroup(groupId);
List<Integer> newMembers = ArrayUtils.wrapInList(resourceIds); // members needing addition
@@ -1319,6 +1319,40 @@ public class ResourceGroupManagerBean implements ResourceGroupManagerLocal, Reso
}
}
+ public void setAssignedResourceGroupsForResource(Subject subject, int resourceId, int[] resourceGroupIds,
+ boolean setType) throws ResourceGroupDeleteException {
+
+ Resource resource = entityManager.find(Resource.class, resourceId);
+ Set<ResourceGroup> currentGroups = resource.getExplicitGroups();
+ List<Integer> currentGroupIds = new ArrayList<Integer>(currentGroups.size());
+ for (ResourceGroup currentGroup : currentGroups) {
+ currentGroupIds.add(currentGroup.getId());
+ }
+
+ int[] resourceIdArr = new int[] { resourceId };
+
+ List<Integer> addedGroupIds = ArrayUtils.wrapInList(resourceGroupIds);
+ addedGroupIds.removeAll(currentGroupIds);
+ for (Integer addedGroupId : addedGroupIds) {
+ addResourcesToGroup(subject, addedGroupId, resourceIdArr);
+ // As a result of the membership change ensure that the group type is set correctly.
+ if (setType) {
+ setResourceType(addedGroupId);
+ }
+ }
+
+ List<Integer> removedGroupIds = new ArrayList<Integer>(currentGroupIds); // groups needing removal
+ removedGroupIds.removeAll(ArrayUtils.wrapInList(resourceGroupIds));
+ for (Integer removedGroupId : removedGroupIds) {
+ removeResourcesFromGroup(subject, removedGroupId, resourceIdArr);
+ // As a result of the membership change ensure that the group type is set correctly.
+ if (setType) {
+ setResourceType(removedGroupId);
+ }
+ }
+
+ }
+
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// Remote interface impl
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerLocal.java
index 45f7cc4..de96dbf 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerLocal.java
@@ -118,7 +118,23 @@ public interface ResourceGroupManagerLocal {
* @throws ResourceGroupUpdateException
* @throws ResourceGroupDeleteException
*/
- void setMembership(Subject subject, int groupId, int[] resourceIds, boolean setType)
+ void setAssignedResources(Subject subject, int groupId, int[] resourceIds, boolean setType)
+ throws ResourceGroupUpdateException, ResourceGroupDeleteException;
+
+ /**
+ * This method ensures that the resource will have exactly the specified set of explicit group
+ * membership. Make sure you pass the correct value for the <setType> parameter.
+ *
+ * @param subject
+ * @param resourceId
+ * @param resourceGroupIds
+ * @param setType Set to false if addition or removal of the specified resourceId will not alter the group
+ * type for the specified resource groups (compatible or mixed). Set true to have the group type
+ * (re)set automatically, based on the new group membership.
+ * @throws ResourceGroupUpdateException
+ * @throws ResourceGroupDeleteException
+ */
+ void setAssignedResourceGroupsForResource(Subject subject, int groupId, int[] resourceIds, boolean setType)
throws ResourceGroupUpdateException, ResourceGroupDeleteException;
void uninventoryMembers(Subject subject, int groupId);
commit fe4cc406e8b82ba6b8d78d9e0d22440ebbaa432b
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Tue Sep 21 11:15:06 2010 -0400
tabs/subtabs that are not applicable to a Resource or group's type are no longer shown; tabs/subtabs that are not available due to lack of authz permissions are grayed out / disabled
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 1739a35..1d6134b 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
@@ -21,12 +21,14 @@ 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;
+
/**
* Simple class to provide a SubTab a locatorId.
*
* @author Jay Shaughnessy
*/
-public class SubTab {
+public class SubTab implements Locatable {
private String locatorId;
private String title;
private Canvas canvas;
@@ -54,6 +56,11 @@ public class SubTab {
}
@Override
+ public String extendLocatorId(String extension) {
+ return this.locatorId + "_" + extension;
+ }
+
+ @Override
public String toString() {
return "SubTab[title=" + this.title + ", locatorId=" + this.locatorId + "]";
}
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 741d931..0005436 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
@@ -155,7 +155,9 @@ public class SubTabLayout extends LocatableVLayout {
}
public void unregisterAllSubTabs() {
+ destroyViews();
subtabs.clear();
+ markForRedraw();
}
public void registerSubTab(SubTab subTab) {
@@ -167,6 +169,21 @@ public class SubTabLayout extends LocatableVLayout {
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();
+ }
+ }
+ }
+
public SubTab getDefaultSubTab() {
// the default subtab is the first one in the set that is not disabled
for (SubTab subtab : this.subtabs.values()) {
@@ -218,6 +235,16 @@ public class SubTabLayout extends LocatableVLayout {
return null;
}
+ public SubTab getSubTabByLocatorId(String locatorId) {
+ for (String subtabLocatorId : this.subtabs.keySet()) {
+ if (subtabLocatorId.equals(locatorId)) {
+ return this.subtabs.get(subtabLocatorId);
+ }
+ }
+
+ return null;
+ }
+
public boolean selectSubTabByTitle(String title) {
SubTab subtab = getSubTabByTitle(title);
if (subtab == null) {
@@ -264,6 +291,7 @@ public class SubTabLayout extends LocatableVLayout {
for (SubTab subtab : subtabs.values()) {
if (subtab.getCanvas() != null) {
subtab.getCanvas().destroy();
+ subtab.setCanvas(null);
}
}
}
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 6258e9e..cbb6370 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
@@ -44,6 +44,10 @@ public class TwoLevelTab extends LocatableTab {
}
}
+ public void setVisible(SubTab subTab, boolean visible) {
+ layout.setVisible(subTab, visible);
+ }
+
public void setSubTabEnabled(String locatorId, boolean enabled) {
if (enabled) {
layout.enableSubTab(locatorId);
@@ -56,6 +60,10 @@ public class TwoLevelTab extends LocatableTab {
return this.layout.getSubTabByTitle(title);
}
+ public SubTab getSubTabByLocatorId(String locatorId) {
+ return this.layout.getSubTabByLocatorId(locatorId);
+ }
+
public SubTab getDefaultSubTab() {
return this.layout.getDefaultSubTab();
}
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 bdd1981..8f7452c 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
@@ -87,6 +87,33 @@ public abstract class AbstractTwoLevelTabSetView<T, U extends Layout> extends Lo
return this.titleBar;
}
+ protected boolean updateTab(TwoLevelTab tab, boolean visible, boolean enabled) {
+ TwoLevelTab attachedTab = getTabSet().getTabByLocatorId(tab.getLocatorId());
+ if (visible) {
+ if (attachedTab == null) {
+ getTabSet().addTab(tab);
+ attachedTab = getTabSet().getTabByLocatorId(tab.getLocatorId());
+ }
+ getTabSet().setTabEnabled(attachedTab, enabled);
+ } else {
+ if (attachedTab != null) {
+ getTabSet().removeTab(attachedTab);
+ }
+ }
+
+ return 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);
+ if (enabled) {
+ subTab.setCanvas(canvas);
+ }
+ }
+ }
+
public void onTabSelected(TwoLevelTabSelectedEvent tabSelectedEvent) {
//CoreGUI.printWidgetTree();
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 6603a00..f085e9b 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
@@ -56,6 +56,7 @@ import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTyp
* Be able to view members as a resource list, or edit members via selector.
*
* @author Jay Shaughnessy
+ * @author Ian Springer
*/
public class ResourceGroupDetailView extends AbstractTwoLevelTabSetView<ResourceGroupComposite, ResourceGroupTitleBar> {
private static final String BASE_VIEW_PATH = "ResourceGroup";
@@ -177,84 +178,82 @@ public class ResourceGroupDetailView extends AbstractTwoLevelTabSetView<Resource
protected void updateTabContent(ResourceGroupComposite groupComposite) {
this.groupComposite = groupComposite;
-
- getTitleBar().setGroup(groupComposite.getResourceGroup());
+ ResourceGroup group = groupComposite.getResourceGroup();
+ int groupId = group.getId();
+ getTitleBar().setGroup(group);
for (Tab top : this.getTabSet().getTabs()) {
((TwoLevelTab) top).getLayout().destroyViews();
}
+ GroupCategory groupCategory = groupComposite.getResourceGroup().getGroupCategory();
+ Set<ResourceTypeFacet> facets = groupComposite.getResourceFacets().getFacets();
+
// FullHTMLPane timelinePane = new FullHTMLPane("/rhq/resource/summary/timeline-plain.xhtml?id=" + resource.getId());
// summaryTab.updateSubTab("Overview", new DashboardView(resource));
// summaryTab.updateSubTab("Timeline", timelinePane);
- this.summaryOverview.setCanvas(new OverviewView(this.summaryTab.extendLocatorId("Overview"),
- this.groupComposite));
-
- int groupId = this.groupComposite.getResourceGroup().getId();
-
- this.monitorGraphs.setCanvas(new FullHTMLPane("/rhq/group/monitor/graphs-plain.xhtml?groupId=" + groupId));
- this.monitorTables.setCanvas(new FullHTMLPane("/rhq/group/monitor/tables-plain.xhtml?groupId=" + groupId));
- this.monitorTraits.setCanvas(new TraitsView(this.monitoringTab.extendLocatorId("TraitsView"), groupId));
- this.monitorSched.setCanvas(new SchedulesView(this.monitoringTab.extendLocatorId("SchedulesView"), groupId));
- this.monitorCallTime.setCanvas(new FullHTMLPane("/rhq/group/monitor/response-plain.xhtml?groupId=" + groupId));
+ // Summary tab is always visible and enabled.
+ updateSubTab(this.summaryTab, this.summaryOverview,
+ new OverviewView(this.summaryTab.extendLocatorId("Overview"), 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);
+ // TODO (ips): Add Availability subtab.
+ }
- this.inventoryMembers.setCanvas(ResourceSearchView.getMembersOf(this.inventoryTab
- .extendLocatorId("MembersView"), groupId));
+ // Inventory tab is always visible and enabled.
+ updateSubTab(this.inventoryTab, this.inventoryMembers,
+ ResourceSearchView.getMembersOf(this.inventoryMembers.extendLocatorId("View"), groupId), true, true);
// TODO: Uncomment this once the group config component is done.
- //this.inventoryConn.setCanvas(new GroupPluginConfigurationEditView(this.group.getId(), this.group.getResourceType().getId(), ConfigurationEditor.ConfigType.plugin));
- this.inventoryMembership.setCanvas(new ResourceGroupMembershipView(this.inventoryTab
- .extendLocatorId("MembershipView"), groupId));
-
- this.opHistory.setCanvas(new FullHTMLPane("/rhq/group/operation/groupOperationHistory-plain.xhtml?groupId="
- + groupId));
- this.opSched.setCanvas(new FullHTMLPane("/rhq/group/operation/groupOperationSchedules-plain.xhtml?groupId="
- + groupId));
-
- this.alertHistory.setCanvas(new FullHTMLPane("/rhq/group/alert/listGroupAlertHistory-plain.xhtml?groupId="
- + groupId));
- this.alertDef.setCanvas(new FullHTMLPane("/rhq/group/alert/listGroupAlertDefinitions-plain.xhtml?groupId="
- + groupId));
-
- this.configCurrent.setCanvas(new FullHTMLPane("/rhq/group/configuration/viewCurrent-plain.xhtml?groupId="
- + groupId));
- this.configHistory
- .setCanvas(new FullHTMLPane("/rhq/group/configuration/history-plain.xhtml?groupId=" + groupId));
-
- this.eventHistory.setCanvas(EventCompositeHistoryView.get(groupComposite));
-
- updateTabEnablement();
- }
-
- private void updateTabEnablement() {
- GroupCategory groupCategory = groupComposite.getResourceGroup().getGroupCategory();
- Set<ResourceTypeFacet> facets = groupComposite.getResourceFacets().getFacets();
-
- // Summary and Inventory tabs are always enabled.
-
- // Only enable "Call Time" and "Traits" subtabs for groups that implement them.
- this.monitoringTab.setSubTabEnabled(this.monitorTraits.getLocatorId(), hasTraits(this.groupComposite));
- this.monitoringTab.setSubTabEnabled(this.monitorCallTime.getLocatorId(), facets
- .contains(ResourceTypeFacet.CALL_TIME));
-
- // Inventory>Connection Settings subtab is only enabled for compat groups that define conn props.
- this.inventoryTab.setSubTabEnabled(this.inventoryConn.getLocatorId(), groupCategory == GroupCategory.COMPATIBLE
- && facets.contains(ResourceTypeFacet.PLUGIN_CONFIGURATION));
-
- // Monitoring and Alerts tabs are always enabled for compatible groups and always disabled for mixed groups.
- // TODO (ips): Break out mixed groups into a separate view.
- getTabSet().setTabEnabled(this.monitoringTab, groupCategory == GroupCategory.COMPATIBLE);
- getTabSet().setTabEnabled(this.alertsTab, groupCategory == GroupCategory.COMPATIBLE);
+ //updateSubTab(this.inventoryTab, this.inventoryConn,
+ // new GroupPluginConfigurationEditView(this.group.getId(), this.group.getResourceType().getId(), ConfigurationEditor.ConfigType.plugin),
+ // facets.contains(ResourceTypeFacet.PLUGIN_CONFIGURATION), true);
+ updateSubTab(this.inventoryTab, this.inventoryMembership,
+ new ResourceGroupMembershipView(this.inventoryTab.extendLocatorId("MembershipView"), groupId), true, true);
+
+ if (updateTab(this.operationsTab,
+ groupCategory == GroupCategory.COMPATIBLE && facets.contains(ResourceTypeFacet.OPERATION), true)) {
+ updateSubTab(this.operationsTab, this.opHistory,
+ new FullHTMLPane("/rhq/group/operation/groupOperationHistory-plain.xhtml?groupId=" + groupId), true, true);
+ updateSubTab(this.operationsTab, this.opSched,
+ new FullHTMLPane("/rhq/group/operation/groupOperationSchedules-plain.xhtml?groupId=" + groupId), true, true);
+ }
- // Operations tab is only enabled for compatible groups of a type that supports the Operations facet.
- getTabSet().setTabEnabled(this.operationsTab, facets.contains(ResourceTypeFacet.OPERATION));
+ if (updateTab(this.operationsTab, groupCategory == GroupCategory.COMPATIBLE, true)) {
+ updateSubTab(this.alertsTab, this.alertHistory,
+ new FullHTMLPane("/rhq/group/alert/listGroupAlertHistory-plain.xhtml?groupId=" + groupId), true, true);
+ updateSubTab(this.alertsTab, this.alertDef,
+ new FullHTMLPane("/rhq/group/alert/listGroupAlertDefinitions-plain.xhtml?groupId=" + groupId), true, true);
+ }
- // Configuration tab is only enabled for compatible groups of a type that supports the Configuration facet
- // and when the current user has the CONFIGURE_READ permission.
- getTabSet().setTabEnabled(this.configurationTab,
- facets.contains(ResourceTypeFacet.CONFIGURATION) && this.permissions.isConfigureRead());
+ if (updateTab(this.configurationTab,
+ groupCategory == GroupCategory.COMPATIBLE && facets.contains(ResourceTypeFacet.CONFIGURATION),
+ 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("/rhq/group/configuration/history-plain.xhtml?groupId=" + groupId), true, true);
+ }
- // Events tab is only enabled for compatible groups of a type that supports the Events facet.
- getTabSet().setTabEnabled(this.eventsTab, facets.contains(ResourceTypeFacet.EVENT));
+ if (updateTab(this.eventsTab,
+ groupCategory == GroupCategory.COMPATIBLE && facets.contains(ResourceTypeFacet.EVENT), true)) {
+ updateSubTab(this.eventsTab, this.eventHistory,
+ EventCompositeHistoryView.get(groupComposite), true, true);
+ }
}
protected void loadSelectedItem(final int groupId, final ViewPath viewPath) {
@@ -313,12 +312,12 @@ public class ResourceGroupDetailView extends AbstractTwoLevelTabSetView<Resource
}
}
- private static boolean hasTraits(ResourceGroupComposite groupComposite) {
+ private static boolean hasMetricsOfType(ResourceGroupComposite groupComposite, DataType dataType) {
ResourceType type = groupComposite.getResourceGroup().getResourceType();
if (type != null) {
Set<MeasurementDefinition> metricDefs = type.getMetricDefinitions();
for (MeasurementDefinition metricDef : metricDefs) {
- if (metricDef.getDataType() == DataType.TRAIT) {
+ if (dataType == null || metricDef.getDataType() == dataType) {
return true;
}
}
@@ -332,5 +331,4 @@ public class ResourceGroupDetailView extends AbstractTwoLevelTabSetView<Resource
currentSubTab = subtabTitle;
super.selectTab(tabTitle, subtabTitle, 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 e80be32..88dd2f9 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
@@ -182,95 +182,99 @@ public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceCompo
protected void updateTabContent(ResourceComposite resourceComposite) {
this.resourceComposite = resourceComposite;
-
- final Resource resource = this.resourceComposite.getResource();
+ Resource resource = this.resourceComposite.getResource();
getTitleBar().setResource(resource);
for (Tab top : this.getTabSet().getTabs()) {
((TwoLevelTab) top).getLayout().destroyViews();
}
- this.summaryOverview.setCanvas(new OverviewView(this.summaryTab.extendLocatorId("OverviewView"),
- this.resourceComposite));
- this.summaryDashboard.setCanvas(new DashboardView(this.resourceComposite));
- this.summaryTimeline.setCanvas(new FullHTMLPane("/rhq/resource/summary/timeline-plain.xhtml?id="
- + resource.getId()));
-
- this.monitorGraphs.setCanvas(new GraphListView(this.monitoringTab.extendLocatorId("GraphListView"), resource));
- this.monitorTables.setCanvas(new FullHTMLPane("/rhq/common/monitor/tables-plain.xhtml?id=" + resource.getId()));
- this.monitorTraits
- .setCanvas(new TraitsView(this.monitoringTab.extendLocatorId("TraitsView"), resource.getId()));
- this.monitorAvail.setCanvas(new FullHTMLPane("/rhq/resource/monitor/availabilityHistory-plain.xhtml?id="
- + resource.getId()));
- this.monitorSched
- .setCanvas(new SchedulesView(monitoringTab.extendLocatorId("SchedulesView"), resource.getId()));
- this.monitorCallTime.setCanvas(new FullHTMLPane("/rhq/resource/monitor/response-plain.xhtml?id="
- + resource.getId()));
-
- this.inventoryChildren.setCanvas(ResourceSearchView.getChildrenOf(this.extendLocatorId("Children"), resource
- .getId()));
- this.inventoryConn.setCanvas(new PluginConfigurationEditView(this.extendLocatorId("PluginConfig"), resource));
-
- // comment out GWT-based operation history until...
- // 1) user can delete history if they possess the appropriate permissions
- // 2) user can see both operation arguments and results in the history details pop-up
- // 3) operation arguments/results become read-only configuration data in the history details pop-up
- // 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
- this.opHistory.setCanvas(OperationHistoryView.getResourceHistoryView(operationsTab.extendLocatorId("History"),
- resourceComposite));
- this.opSched.setCanvas(new FullHTMLPane("/rhq/resource/operation/resourceOperationSchedules-plain.xhtml?id="
- + resource.getId()));
+ ResourcePermission permissions = this.resourceComposite.getResourcePermission();
+ Set<ResourceTypeFacet> facets = this.resourceComposite.getResourceFacets().getFacets();
+
+ updateSubTab(this.summaryTab, this.summaryOverview,
+ new OverviewView(this.summaryOverview.getLocatorId(), this.resourceComposite), true, true);
+ updateSubTab(this.summaryTab, this.summaryDashboard,
+ new DashboardView(this.resourceComposite), true, true);
+ 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);
+ 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);
+
+ ResourceType type = this.resourceComposite.getResource().getResourceType();
+ updateSubTab(this.inventoryTab, this.inventoryChildren,
+ ResourceSearchView.getChildrenOf(this.extendLocatorId("Children"), resource.getId()),
+ !type.getChildResourceTypes().isEmpty(), true);
+ updateSubTab(this.inventoryTab, this.inventoryConn,
+ new PluginConfigurationEditView(this.extendLocatorId("PluginConfig"), resource),
+ facets.contains(ResourceTypeFacet.PLUGIN_CONFIGURATION), true);
+
+ if (updateTab(this.operationsTab, facets.contains(ResourceTypeFacet.OPERATION), true)) {
+ // comment out GWT-based operation history until...
+ // 1) user can delete history if they possess the appropriate permissions
+ // 2) user can see both operation arguments and results in the history details pop-up
+ // 3) operation arguments/results become read-only configuration data in the history details pop-up
+ // 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);
+ updateSubTab(this.operationsTab, this.opSched,
+ new FullHTMLPane("/rhq/resource/operation/resourceOperationSchedules-plain.xhtml?id=" + resource.getId()),
+ true, true);
+ }
// comment out GWT-based alert definitions/history views until...
// 1) new workflow is implement for alert definition creation, with particular attention to interaction model for alert notifications
// 2) user can delete/ack/purgeAll alerts if they possess the appropriate permissions
// 3) user can enable/disable/delete alert definitions if they possess the appropriate permissions
// 4) user can search alert history by: date alert was fired, alert priority, or alert definition
- this.alertHistory.setCanvas(new FullHTMLPane("/rhq/resource/alert/listAlertHistory-plain.xhtml?id="
- + resource.getId()));
- this.alertDef.setCanvas(new ResourceAlertDefinitionsView(alertsTab.extendLocatorId("AlertDef"),
- resourceComposite));
- this.alertDelete.setCanvas(new FullHTMLPane("/rhq/resource/alert/listAlertDefinitions-plain.xhtml?id="
- + resource.getId()));
-
- this.configCurrent
- .setCanvas(new ResourceConfigurationEditView(this.extendLocatorId("ResourceConfig"), resource));
- this.configHistory.setCanvas(ConfigurationHistoryView.getHistoryOf(configurationTab.extendLocatorId("Hist"),
- resource.getId()));
-
- this.eventHistory.setCanvas(EventCompositeHistoryView.get(resourceComposite));
-
- this.contentDeployed
- .setCanvas(new FullHTMLPane("/rhq/resource/content/view-plain.xhtml?id=" + resource.getId()));
- this.contentNew.setCanvas(new FullHTMLPane("/rhq/resource/content/deploy-plain.xhtml?id=" + resource.getId()));
- this.contentSubscrip.setCanvas(new FullHTMLPane("/rhq/resource/content/subscription-plain.xhtml?id="
- + resource.getId()));
- this.contentHistory.setCanvas(new FullHTMLPane("/rhq/resource/content/history-plain.xhtml?id="
- + resource.getId()));
-
- updateTabEnablement();
- }
-
- private void updateTabEnablement() {
- ResourcePermission permissions = this.resourceComposite.getResourcePermission();
- Set<ResourceTypeFacet> facets = this.resourceComposite.getResourceFacets().getFacets();
-
- // Summary, Monitoring, Inventory, and Alerts tabs are always enabled.
-
- monitoringTab.setSubTabEnabled(monitorTraits.getLocatorId(), hasTraits(this.resourceComposite));
- monitoringTab.setSubTabEnabled(monitorCallTime.getLocatorId(), facets.contains(ResourceTypeFacet.CALL_TIME));
+ 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);
+ 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);
+ updateSubTab(this.configurationTab, this.configHistory,
+ ConfigurationHistoryView.getHistoryOf(configurationTab.extendLocatorId("Hist"), resource.getId()), true, true);
+ }
- inventoryTab.setSubTabEnabled(inventoryConn.getLocatorId(), facets
- .contains(ResourceTypeFacet.PLUGIN_CONFIGURATION));
- ResourceType type = this.resourceComposite.getResource().getResourceType();
- inventoryTab.setSubTabEnabled(inventoryChildren.getLocatorId(), !type.getChildResourceTypes().isEmpty());
+ if (updateTab(this.eventsTab, facets.contains(ResourceTypeFacet.EVENT), true)) {
+ updateSubTab(this.eventsTab, this.eventHistory,
+ EventCompositeHistoryView.get(resourceComposite), true, true);
+ }
- getTabSet().setTabEnabled(this.operationsTab, facets.contains(ResourceTypeFacet.OPERATION));
- getTabSet().setTabEnabled(this.configurationTab,
- facets.contains(ResourceTypeFacet.CONFIGURATION) && permissions.isConfigureRead());
- getTabSet().setTabEnabled(this.eventsTab, facets.contains(ResourceTypeFacet.EVENT));
- getTabSet().setTabEnabled(this.contentTab, facets.contains(ResourceTypeFacet.CONTENT));
+ if (updateTab(this.contentTab, facets.contains(ResourceTypeFacet.CONTENT), true)) {
+ updateSubTab(this.contentTab, this.contentDeployed,
+ new FullHTMLPane("/rhq/resource/content/view-plain.xhtml?id=" + resource.getId()), true, true);
+ updateSubTab(this.contentTab, this.contentNew,
+ new FullHTMLPane("/rhq/resource/content/deploy-plain.xhtml?id=" + resource.getId()), true, true);
+ updateSubTab(this.contentTab, this.contentSubscrip,
+ new FullHTMLPane("/rhq/resource/content/subscription-plain.xhtml?id=" + resource.getId()), true, true);
+ updateSubTab(this.contentTab, this.contentHistory,
+ new FullHTMLPane("/rhq/resource/content/history-plain.xhtml?id=" + resource.getId()), true, true);
+ }
}
public Integer getSelectedItemId() {
@@ -324,11 +328,11 @@ public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceCompo
});
}
- private static boolean hasTraits(ResourceComposite resourceComposite) {
+ private static boolean hasMetricsOfType(ResourceComposite resourceComposite, DataType dataType) {
ResourceType type = resourceComposite.getResource().getResourceType();
Set<MeasurementDefinition> metricDefs = type.getMetricDefinitions();
for (MeasurementDefinition metricDef : metricDefs) {
- if (metricDef.getDataType() == DataType.TRAIT) {
+ if (dataType == null || metricDef.getDataType() == dataType) {
return true;
}
}
commit 31a27cb1807ea2e0ae258d996ce968ec0f730135
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Tue Sep 21 11:10:38 2010 -0400
comment out some code that was causing the following unit test failure:
Tests run: 3, Failures: 1, Errors: 0, Skipped: 2, Time elapsed: 863.162 sec <<< FAILURE!
beforeClass(org.rhq.core.pc.inventory.ResourceContainerTest) Time elapsed: 0 sec <<< FAILURE!
java.lang.RuntimeException: Cannot initialize the plugin container
at org.rhq.core.pc.plugin.PluginManager.initialize(PluginManager.java:173)
at org.rhq.core.pc.PluginContainer.startContainerService(PluginContainer.java:391)
at org.rhq.core.pc.PluginContainer.initialize(PluginContainer.java:252)
at org.rhq.core.pc.inventory.ResourceContainerTest.beforeClass(ResourceContainerTest.java:48)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:607)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:417)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:154)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:88)
at org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:167)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:104)
at org.testng.TestRunner.runWorkers(TestRunner.java:759)
at org.testng.TestRunner.privateRun(TestRunner.java:592)
at org.testng.TestRunner.run(TestRunner.java:486)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:332)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:327)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:299)
at org.testng.SuiteRunner.run(SuiteRunner.java:204)
at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:877)
at org.testng.TestNG.runSuitesLocally(TestNG.java:842)
at org.testng.TestNG.run(TestNG.java:751)
at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:62)
at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.execute(TestNGDirectoryTestSuite.java:141)
at org.apache.maven.surefire.Surefire.run(Surefire.java:180)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:350)
at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1021)
Caused by: org.rhq.core.clientapi.agent.PluginContainerException: A valid plugin JAR URL must be supplied.
at org.rhq.core.clientapi.descriptor.AgentPluginDescriptorUtil.loadPluginDescriptorFromUrl(AgentPluginDescriptorUtil.java:296)
at org.rhq.core.pc.plugin.PluginDescriptorLoader.loadPluginDescriptor(PluginDescriptorLoader.java:67)
at org.rhq.core.pc.plugin.PluginManager.loadPlugin(PluginManager.java:316)
at org.rhq.core.pc.plugin.PluginManager.initialize(PluginManager.java:168)
... 32 more
Results :
Failed tests:
beforeClass(org.rhq.core.pc.inventory.ResourceContainerTest)
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/PluginManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/PluginManager.java
index 2c64ff1..d9976cb 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/PluginManager.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/PluginManager.java
@@ -163,9 +163,11 @@ public class PluginManager implements ContainerService {
}
} else {
+ // TODO (ips, 10/21/10): I don't think this block of code is needed any longer. I am commenting it for
+ // now, but it should eventually be deleted.
// Loading a null plugin loads the plugin using the current classloader (for unit test testing)
- log.info("Loading the null plugin which uses non-isolated classloader");
- loadPlugin(null, thisClassLoader);
+ //log.info("Loading the null plugin which uses non-isolated classloader");
+ //loadPlugin(null, thisClassLoader);
}
} catch (Exception e) {
shutdown(); // have to clean up the environments (e.g. unpacked jars) we might have already created
@@ -379,7 +381,6 @@ public class PluginManager implements ContainerService {
*
* @param pluginName the name of the plugin to obtain dependency URLs for
* @param pluginNamesUrls map of all known plugin names and their plugin jar URLs
- * @param graph the dependency graph
* @param allUrls where the results will be stored
*
* TODO: Use it or lose it - this used to be needed, keeping this around just in case it needs to be resurrected
commit f742f93aabcfe099c727c4eb6b3fbde55f8baf53
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Mon Sep 20 23:43:29 2010 -0400
pluralize autogroup and subcategory names in the Resource tree (https://bugzilla.redhat.com/show_bug.cgi?id=587631)
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 9d7f395..0862d3a 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
@@ -262,8 +262,9 @@ public class ResourceTreeDatasource extends DataSource {
setParentID(parentResourceId);
setAttribute("parentId", parentResourceId);
- setName(category.getDisplayName());
- setAttribute("name", category.getDisplayName());
+ String name = pluralize(category.getDisplayName());
+ setName(name);
+ setAttribute("name", name);
}
}
@@ -285,7 +286,7 @@ public class ResourceTreeDatasource extends DataSource {
// setAttribute("parentKey", parentId);
- String name = type.getName();
+ String name = pluralize(type.getName());
setName(name);
setAttribute("name", name);
}
@@ -358,4 +359,9 @@ public class ResourceTreeDatasource extends DataSource {
private static String fixId(String id) {
return id.replace(' ', '_');
}
+
+ private static String pluralize(String s) {
+ // TODO: Make this smarter.
+ return s + "s";
+ }
}
commit 981dad09ee03eb74c3752900a036f03c93aac522
Merge: c443dbc... 73c0d37...
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Tue Sep 21 16:29:50 2010 +0200
Merge branch 'master' of ssh://git.fedorahosted.org/git/rhq/rhq
commit c443dbcd87339ccbb859c7ee4fef8576929c82f0
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Tue Sep 21 15:41:27 2010 +0200
Disable here, as it is broken and development goes on in the perftest branch for now.
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 a289960..fdd5f6a 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
@@ -44,7 +44,7 @@ import org.testng.annotations.Test;
*
* @author Heiko W. Rupp
*/
-@Test(groups = "PERF")
+@Test(groups = "PERF", enabled = false)
public class AvailabilityInsertPurgeTest extends AbstractEJB3PerformanceTest {
private final Log log = LogFactory.getLog(AvailabilityInsertPurgeTest.class);
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 73c0d3779b57b45b62ae592a77024dd476b8c645
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 a1bc4dae4211c6eadd0335dd362a582bcaa03240
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 {
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 {
commit b38fbd992d4a236fdf71ea5001db32b3af889ee8
Merge: 2b0a1c3... a03a5f6...
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Tue Sep 21 14:31:49 2010 +0200
Merge branch 'master' of ssh://git.fedorahosted.org/git/rhq/rhq
commit 2b0a1c3b350e74bb07943063a2df6b73f3de783c
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Tue Sep 21 14:30:38 2010 +0200
Bump target version to follow the recent change to the upgrade script.
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index 1f4adef..11ba639 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.94</db.schema.version>
+ <db.schema.version>2.95</db.schema.version>
</properties>
<dependencies>
commit a03a5f6757ac252cfd91f5578129e46a5ed54866
Author: Joseph Marques <joseph(a)redhat.com>
Date: Tue Sep 21 01:37:40 2010 -0400
more dynagroup CRUD work:
* add list of dynagroup children to details view
* add ability to recalculate the current group def from details view
* fix column widths and cell formatting for list view
* add ability to recalculate selected group definitions from list view
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 00e8819..f0fe978 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
@@ -110,6 +110,11 @@ public class ResourceGroupsDataSource extends RPCDataSource<ResourceGroup> {
"downMemberCount")));
}
+ if (request.getCriteria().getValues().get("groupDefinitionId") != null) {
+ criteria.addFilterGroupDefinitionId(Integer.parseInt((String) request.getCriteria().getValues().get(
+ "groupDefinitionId")));
+ }
+
return criteria;
}
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 a95e0e6..49ea417 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
@@ -30,7 +30,6 @@ import com.smartgwt.client.data.Record;
import com.smartgwt.client.data.fields.DataSourceIntegerField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.rpc.RPCResponse;
-import com.smartgwt.client.types.FieldType;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.criteria.ResourceGroupDefinitionCriteria;
@@ -70,23 +69,21 @@ public class GroupDefinitionDataSource extends RPCDataSource<GroupDefinition> {
DataSourceTextField descriptionField = new DataSourceTextField("description", "Description");
- DataSourceTextField expressionField = new DataSourceTextField("expression", "Expression");
+ DataSourceTextField expressionField = new DataSourceTextField("expression", "Expression Set");
expressionField.setRequired(true);
- DataSourceTextField recursiveField = new DataSourceTextField("recursive", "Recursive");
- recursiveField.setType(FieldType.BOOLEAN);
-
- /*
- DataSourceTextField recalculationIntervalField = new DataSourceTextField("recalculationInterval",
+ DataSourceIntegerField lastCalculationTimeIntervalField = new DataSourceIntegerField("lastCalculationTime",
"Recalculation Interval");
- */
- DataSourceTextField nextCalculationTimeField = new DataSourceTextField("nextCalculationTime",
+ DataSourceIntegerField nextCalculationTimeField = new DataSourceIntegerField("nextCalculationTime",
"Next Calculation Time");
- setFields(idField, nameField, descriptionField, expressionField, recursiveField, /*recalculationIntervalField,*/
- nextCalculationTimeField);
-
+ addField(idField);
+ addField(nameField);
+ addField(descriptionField);
+ addField(expressionField);
+ addField(lastCalculationTimeIntervalField);
+ addField(nextCalculationTimeField);
}
@Override
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 d6d78e5..9b17abf 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
@@ -21,13 +21,14 @@ package org.rhq.enterprise.gui.coregui.client.inventory.groups.definitions;
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.ListGrid;
+import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
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.TableSection;
+import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGroupGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.util.TableUtility;
@@ -50,25 +51,71 @@ public class GroupDefinitionListView extends TableSection {
@Override
protected void configureTable() {
- super.configureTable();
- ListGrid grid = getListGrid();
+ ListGridField idField = new ListGridField("id", "ID", 50);
+ ListGridField nameField = new ListGridField("name", "Name", 150);
+ ListGridField descriptionField = new ListGridField("description", "Description");
+ ListGridField expressionField = new ListGridField("expression", "Expression Set", 250);
+ expressionField.setCellFormatter(new CellFormatter() {
+ public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
+ return value.toString().replaceAll("\\n", "<br/>");
+ }
+ });
+
+ ListGridField lastCalculationTimeField = new ListGridField("lastCalculationTime", "Last Calculation Time", 175);
+ //lastCalculationTimeField.setAlign(Alignment.CENTER);
+ lastCalculationTimeField.setCellFormatter(new TimestampCellFormatter() {
+ public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
+ if (value == null) {
+ return "Never";
+ }
+ return super.format(value, record, rowNum, colNum);
+ }
+ });
- grid.getField("nextCalculationTime").setCellFormatter(new CellFormatter() {
+ ListGridField nextCalculationTimeField = new ListGridField("nextCalculationTime", "Next Calculation Time", 175);
+ //nextCalculationTimeField.setAlign(Alignment.CENTER);
+ nextCalculationTimeField.setCellFormatter(new TimestampCellFormatter() {
public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
- if ("0".equals(value.toString())) {
+ if (value == null || "0".equals(value.toString())) {
return "N/A";
}
- return value.toString();
+ return super.format(value, record, rowNum, colNum);
}
});
+ getListGrid().setFields(idField, nameField, descriptionField, expressionField, lastCalculationTimeField,
+ nextCalculationTimeField);
+
addTableAction(extendLocatorId("New"), "New", Table.SelectionEnablement.ALWAYS, null, new TableAction() {
public void executeAction(ListGridRecord[] selection) {
newDetails();
}
});
+ addTableAction(extendLocatorId("Recalculate"), "Recalculate", Table.SelectionEnablement.ANY, null,
+ new TableAction() {
+ public void executeAction(ListGridRecord[] selection) {
+ final int[] groupDefinitionIds = TableUtility.getIds(selection);
+ ResourceGroupGWTServiceAsync resourceGroupManager = GWTServiceLookup.getResourceGroupService();
+
+ resourceGroupManager.recalculateGroupDefinitions(groupDefinitionIds, new AsyncCallback<Void>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to recalculate selected group definitions",
+ caught);
+ }
+
+ public void onSuccess(Void result) {
+ CoreGUI.getMessageCenter().notify(
+ new Message("Successfully recalculated " + groupDefinitionIds.length
+ + " group definitions", Severity.Info));
+
+ GroupDefinitionListView.this.refresh();
+ }
+ });
+ }
+ });
+
addTableAction(extendLocatorId("Delete"), "Delete", Table.SelectionEnablement.ANY, null, new TableAction() {
public void executeAction(ListGridRecord[] selection) {
final int[] groupDefinitionIds = TableUtility.getIds(selection);
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 1639a92..f4ca2cf 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
@@ -23,6 +23,7 @@ import java.util.Set;
import com.google.gwt.user.client.History;
import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.data.DSCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
@@ -45,7 +46,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.table.Table;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.inventory.groups.ResourceGroupsDataSource;
+import org.rhq.enterprise.gui.coregui.client.util.message.Message;
+import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIButton;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
@@ -131,16 +136,48 @@ public class SingleGroupDefinitionView extends LocatableVLayout implements Bookm
form.setSaveOperationType(DSOperationType.UPDATE);
}
+ final DynaGroupChildrenView dynaGroupChildrenView = new DynaGroupChildrenView(extendLocatorId("DynaGroups"),
+ groupDefinitionId);
+
// button setup
IButton saveButton = new LocatableIButton(this.extendLocatorId("Save"), "Save");
saveButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
public void onClick(com.smartgwt.client.widgets.events.ClickEvent clickEvent) {
if (form.validate()) {
- //createOrUpdate();
form.saveData(new DSCallback() {
@Override
public void execute(DSResponse response, Object rawData, DSRequest request) {
- History.back();
+ dynaGroupChildrenView.refresh();
+ }
+ });
+ }
+ }
+ });
+
+ IButton recalculateButton = new LocatableIButton(this.extendLocatorId("Recalculate"), "Save & Recalculate");
+ recalculateButton.setWidth(150);
+ recalculateButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
+ public void onClick(com.smartgwt.client.widgets.events.ClickEvent clickEvent) {
+ if (form.validate()) {
+ form.saveData(new DSCallback() {
+ @Override
+ public void execute(DSResponse response, Object rawData, DSRequest request) {
+ GWTServiceLookup.getResourceGroupService().recalculateGroupDefinitions(
+ new int[] { groupDefinitionId }, new AsyncCallback<Void>() {
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(
+ "Failed to recalculate this group definition", caught);
+ }
+
+ @Override
+ public void onSuccess(Void result) {
+ dynaGroupChildrenView.refresh();
+ CoreGUI.getMessageCenter().notify(
+ new Message("Successfully recalculated this group definition",
+ Severity.Info));
+ }
+ });
}
});
}
@@ -157,15 +194,25 @@ public class SingleGroupDefinitionView extends LocatableVLayout implements Bookm
HLayout buttonLayout = new HLayout(10); // margin between members
buttonLayout.setMargin(10); // margin around layout widget
buttonLayout.addMember(saveButton);
+ buttonLayout.addMember(recalculateButton);
buttonLayout.addMember(resetButton);
// canvas setup
addMember(form);
addMember(buttonLayout);
+ addMember(dynaGroupChildrenView);
markForRedraw();
}
+ class DynaGroupChildrenView extends Table {
+ public DynaGroupChildrenView(String locatorId, int groupDefinitionId) {
+ super(locatorId, "DynaGroup Children", new Criteria("groupDefinitionId", String.valueOf(groupDefinition
+ .getId())));
+ setDataSource(ResourceGroupsDataSource.getInstance());
+ }
+ }
+
public void switchToEditMode() {
name.show();
description.show();
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
index 71f1996..e1bed72 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
@@ -106,7 +106,6 @@ public class ResourceSearchView extends Table {
protected void configureTable() {
getListGrid().setSelectionType(SelectionStyle.SIMPLE);
- getListGrid().setResizeFieldsInRealTime(true);
ListGridField idField = new ListGridField("id", "Id", 55);
idField.setType(ListGridFieldType.INTEGER);
commit c97a7a3d47cadd9405d9becdfda5beb3da783e8a
Author: Joseph Marques <joseph(a)redhat.com>
Date: Tue Sep 21 01:29:37 2010 -0400
add recalculation method to the ResourceGroup GWT service
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGroupGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGroupGWTService.java
index 333427f..d475aa8 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGroupGWTService.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGroupGWTService.java
@@ -30,6 +30,7 @@ import org.rhq.core.domain.util.PageList;
/**
* @author Greg Hinkle
+ * @author Joseph Marques
*/
@RemoteServiceRelativePath("ResourceGroupGWTService")
public interface ResourceGroupGWTService extends RemoteService {
@@ -48,6 +49,8 @@ public interface ResourceGroupGWTService extends RemoteService {
PageList<ResourceGroupComposite> findResourceGroupCompositesByCriteria(ResourceGroupCriteria criteria);
+ void recalculateGroupDefinitions(int[] groupDefinitionIds);
+
void setMembership(int groupId, int[] resourceIds, boolean setType);
void updateGroupDefinition(GroupDefinition groupDefinition);
@@ -55,5 +58,4 @@ public interface ResourceGroupGWTService extends RemoteService {
void updateResourceGroup(ResourceGroup group);
void updateResourceGroup(ResourceGroup group, boolean updateMembership);
-
}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java
index b9642d6..07b9168 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java
@@ -132,6 +132,16 @@ public class ResourceGroupGWTServiceImpl extends AbstractGWTServiceImpl implemen
}
}
+ public void recalculateGroupDefinitions(int[] groupDefinitionIds) {
+ try {
+ for (int nextGroupDefinitionId : groupDefinitionIds) {
+ definitionManager.calculateGroupMembership(getSessionSubject(), nextGroupDefinitionId);
+ }
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ }
+ }
+
public void deleteGroupDefinitions(int[] groupDefinitionIds) {
try {
for (int nextGroupDefinitionId : groupDefinitionIds) {
commit a8203c775172bf83d9aa611433f7c051fa253f7d
Author: Joseph Marques <joseph(a)redhat.com>
Date: Mon Sep 20 22:14:15 2010 -0400
remove redundant data caching methods from ResourceGroupsDatasource
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 00e9389..00e8819 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
@@ -54,10 +54,7 @@ public class ResourceGroupsDataSource extends RPCDataSource<ResourceGroup> {
}
public ResourceGroupsDataSource() {
-
- // TODO until http://code.google.com/p/smartgwt/issues/detail?id=490 is fixed always go to the server for data
- this.setAutoCacheAllData(false);
- this.setCacheAllData(false);
+ super();
DataSourceField idDataField = new DataSourceIntegerField("id", "ID", 20);
idDataField.setPrimaryKey(true);
@@ -77,8 +74,6 @@ public class ResourceGroupsDataSource extends RPCDataSource<ResourceGroup> {
}
public void executeFetch(final DSRequest request, final DSResponse response) {
- final long start = System.currentTimeMillis();
-
ResourceGroupCriteria criteria = getFetchCriteria(request);
groupService.findResourceGroupsByCriteria(criteria, new AsyncCallback<PageList<ResourceGroup>>() {
commit a5b3075fb496babadb208e2be2b1d4c5f2e92a1e
Author: Joseph Marques <joseph(a)redhat.com>
Date: Mon Sep 20 22:05:17 2010 -0400
remove redundant data caching methods from ResourceDatasource
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 280cb89..8a55ed7 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
@@ -58,10 +58,6 @@ public class ResourceDatasource extends RPCDataSource<Resource> {
public ResourceDatasource() {
super();
- // TODO until http://code.google.com/p/smartgwt/issues/detail?id=490 is fixed always go to the server for data
- this.setAutoCacheAllData(false);
- this.setCacheAllData(false);
-
DataSourceField idDataField = new DataSourceIntegerField("id", "ID", 20);
idDataField.setPrimaryKey(true);
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 dd5e77b..5b3ecf7 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
@@ -58,6 +58,7 @@ public abstract class RPCDataSource<T> extends DataSource {
System.out.println("Trying to build DS: " + name);
setID(name);
}
+ // TODO until http://code.google.com/p/smartgwt/issues/detail?id=490 is fixed always go to the server for data
setClientOnly(false);
setAutoCacheAllData(false);
setCacheAllData(false);
commit f4d2f1663b3beffe728af06df3aa7a12737fc201
Author: Joseph Marques <joseph(a)redhat.com>
Date: Mon Sep 20 13:13:58 2010 -0400
remove unnecessary set for number of columns
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 7b5ea42..1639a92 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
@@ -122,7 +122,6 @@ public class SingleGroupDefinitionView extends LocatableVLayout implements Bookm
final LocatableDynamicForm form = new LocatableDynamicForm(extendLocatorId("GroupDefinitionForm"));
form.setFields(id, idStatic, name, nameStatic, description, descriptionStatic, expression, expressionStatic,
recursive, recursiveStatic, recalculationInterval, recalculationIntervalStatic);
- form.setNumCols(2);
form.setDataSource(dataSource);
form.setHiliteRequiredFields(true);
form.setRequiredTitleSuffix(" <span style=\"color: red;\">* </span>:");
commit 1140690afe36709b2c53722c9ad447fb7a0ec8c1
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Mon Sep 20 14:58:44 2010 -0400
only ask discovery components for additional classpath URLs (i.e. client jars) if per-resource classloaders are enabled in the plugin container config
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/ClassLoaderManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/ClassLoaderManager.java
index aec2353..ffaae5e 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/ClassLoaderManager.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/ClassLoaderManager.java
@@ -463,6 +463,21 @@ public class ClassLoaderManager {
return new HashMap<CanonicalResourceKey, ClassLoader>(this.resourceClassLoaders);
}
+ /**
+ * Returns <code>true</code> if this manager will create instances of classloaders for those
+ * individual Resources that require it, or <code>false</code> if this manager will never create
+ * individual classloaders for Resources (i.e. {@link #obtainResourceClassLoader(Resource, ResourceContainer, List)}
+ * will always just return plugin classloaders).
+ *
+ * @return <code>true</code> if this manager will create instances of classloaders for those
+ * individual Resources that require it, or <code>false</code> if this manager will never create
+ * individual classloaders for Resources (i.e. {@link #obtainResourceClassLoader(Resource, ResourceContainer, List)}
+ * will always just return plugin classloaders)
+ */
+ public boolean isCreateResourceClassLoaders() {
+ return this.createResourceClassLoaders;
+ }
+
private Set<ClassLoader> getUniquePluginClassLoaders() {
HashSet<ClassLoader> uniqueClassLoaders = new HashSet<ClassLoader>(this.pluginClassLoaders.values());
return uniqueClassLoaders;
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/PluginComponentFactory.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/PluginComponentFactory.java
index 4176353..ca8eef6 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/PluginComponentFactory.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/PluginComponentFactory.java
@@ -23,6 +23,7 @@
package org.rhq.core.pc.plugin;
import java.net.URL;
+import java.util.Collections;
import java.util.List;
import org.apache.commons.logging.Log;
@@ -174,14 +175,16 @@ public class PluginComponentFactory implements ContainerService {
+ parentResource);
}
} else if (resource.equals(inventoryMgr.getPlatform())) {
- // the given resource is our top platform resource, just use its plugin classloader
+ // the given resource is our top platform resource - just use its plugin classloader
return classLoaderMgr.obtainPluginClassLoader(resourceType.getPlugin());
} else {
throw new PluginContainerException("Missing parent resource for resource=" + resource);
}
// get the classloader the resource should use
- List<URL> additionalJars = askDiscoveryComponentForAdditionalClasspathUrls(resource, parentContainer);
+ List<URL> additionalJars = (classLoaderMgr.isCreateResourceClassLoaders()) ?
+ askDiscoveryComponentForAdditionalClasspathUrls(resource, parentContainer) :
+ Collections.<URL>emptyList();
ClassLoader cl = classLoaderMgr.obtainResourceClassLoader(resource, parentContainer, additionalJars);
return cl;
} catch (Throwable t) {
commit a63b4bcd0ea05090acac14797f9e06d31e00c6b7
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Sep 20 14:16:36 2010 -0400
use WIPE animation - seems to work faster than the FADE
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java
index a1303a1..0e3a899 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java
@@ -224,7 +224,7 @@ public abstract class TableSection extends Table implements BookmarkableView {
protected void switchToDetailsView() {
Canvas contents = getTableContents();
if (contents != null) {
- contents.animateHide(AnimationEffect.FADE, new AnimationCallback() {
+ contents.animateHide(AnimationEffect.WIPE, new AnimationCallback() {
@Override
public void execute(boolean b) {
detailsView.setWidth100();
@@ -232,7 +232,7 @@ public abstract class TableSection extends Table implements BookmarkableView {
detailsHolder.addMember(new BackButton(extendLocatorId("BackButton"), "Back to List", basePath));
detailsHolder.addMember(detailsView);
- detailsHolder.animateShow(AnimationEffect.FADE);
+ detailsHolder.animateShow(AnimationEffect.WIPE);
}
});
}
@@ -246,18 +246,18 @@ public abstract class TableSection extends Table implements BookmarkableView {
if (contents != null) {
if (detailsHolder != null && detailsHolder.isVisible()) {
- detailsHolder.animateHide(AnimationEffect.FADE, new AnimationCallback() {
+ detailsHolder.animateHide(AnimationEffect.WIPE, new AnimationCallback() {
@Override
public void execute(boolean b) {
for (Canvas child : detailsHolder.getMembers()) {
child.destroy();
}
- contents.animateShow(AnimationEffect.FADE);
+ contents.animateShow(AnimationEffect.WIPE);
}
});
} else {
- contents.animateShow(AnimationEffect.FADE);
+ contents.animateShow(AnimationEffect.WIPE);
}
}
}
commit 665349f2a221a7aed276f67197ca9289fba322b2
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Sep 20 13:05:03 2010 -0400
bz 535756 add the ability to create calltime conditions to an alert definition
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertFormatUtility.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertFormatUtility.java
index 098e92a..14cb2c2 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertFormatUtility.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertFormatUtility.java
@@ -54,17 +54,40 @@ public class AlertFormatUtility {
break;
}
case THRESHOLD: {
- str.append("Metric Value Exceeds Threshold");
- str.append(" [");
- str.append(condition.getName());
- str.append(" ");
- str.append(condition.getComparator());
- str.append(" ");
double value = condition.getThreshold();
MeasurementUnits units = condition.getMeasurementDefinition().getUnits();
String formatted = MeasurementConverterClient.format(value, units, true);
- str.append(formatted);
- str.append("]");
+
+ if (condition.getOption() == null) {
+ str.append("Metric Value Exceeds Threshold");
+ str.append(" [");
+ str.append(condition.getName());
+ str.append(" ");
+ str.append(condition.getComparator());
+ str.append(" ");
+ str.append(formatted);
+ str.append("]");
+ } else {
+ // this is a calltime threshold condition
+ // the name of the metric is only obtainable by querying for the name from the meas def ID
+ // but since most times (all the time?) there is only one calltime metric per resource,
+ // not showing the metric name probably isn't detrimental
+ str.append("Calltime Value Exceeds Threshold");
+ str.append(" [");
+ str.append(condition.getOption()); // MIN, MAX, AVG (never null)
+ str.append(" ");
+ str.append(condition.getComparator()); // <, >, =
+ str.append(" ");
+ str.append(condition.getThreshold());
+ str.append("]");
+ if (condition.getName() != null && condition.getName().length() > 0) {
+ str.append(" ");
+ str.append("with call destination matching");
+ str.append(" '");
+ str.append(condition.getName());
+ str.append("'");
+ }
+ }
break;
}
case BASELINE: {
@@ -86,10 +109,39 @@ public class AlertFormatUtility {
break;
}
case CHANGE: {
- str.append("Metric Value Change");
- str.append(" [");
- str.append(condition.getName());
- str.append("]");
+ if (condition.getOption() == null) {
+ str.append("Metric Value Change");
+ str.append(" [");
+ str.append(condition.getName());
+ str.append("]");
+ } else {
+ // this is a calltime change condition
+ // the name of the metric is only obtainable by querying for the name from the meas def ID
+ // but since most times (all the time?) there is only one calltime metric per resource,
+ // not showing the metric name probably isn't detrimental
+ str.append("Calltime Value Changes");
+ str.append(" [");
+ str.append(condition.getOption()); // MIN, MAX, AVG (never null)
+ str.append(" ");
+ str.append(getCalltimeChangeComparator(condition.getComparator())); // LO, HI, CH
+ str.append(" ");
+ str.append("by at least");
+ str.append(" ");
+
+ double value = condition.getThreshold();
+ MeasurementUnits units = MeasurementUnits.PERCENTAGE;
+ String formatted = MeasurementConverterClient.format(value, units, true);
+ str.append(formatted);
+
+ str.append("]");
+ if (condition.getName() != null && condition.getName().length() > 0) {
+ str.append(" ");
+ str.append("with call destination matching");
+ str.append(" '");
+ str.append(condition.getName());
+ str.append("'");
+ }
+ }
break;
}
case TRAIT: {
@@ -122,9 +174,9 @@ public class AlertFormatUtility {
if (condition.getOption() != null && condition.getOption().length() > 0) {
str.append(" ");
str.append("matching");
- str.append(" [");
+ str.append(" '");
str.append(condition.getOption());
- str.append("]");
+ str.append("'");
}
break;
}
@@ -136,6 +188,16 @@ public class AlertFormatUtility {
return str.toString();
}
+ private static String getCalltimeChangeComparator(String comparator) {
+ if ("HI".equals(comparator)) {
+ return "Grows";
+ } else if ("LO".equals(comparator)) {
+ return "Shrinks";
+ } else { // CH
+ return "Changes";
+ }
+ }
+
public static String getAlertRecoveryInfo(Alert alert) {
String recoveryInfo;
AlertDefinition recoveryAlertDefinition = alert.getRecoveryAlertDefinition();
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java
index 7e81a0e..3fcc64e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java
@@ -58,6 +58,11 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
*/
public class NewConditionEditor extends LocatableDynamicForm {
+ // these aren't "real" calltime condition categories (not real AlertConditionCategory enums)
+ // but we need these values for the drop down menu selections
+ private static final String ALERT_CONDITION_CATEGORY_CALLTIME_CHANGE = "calltime-change";
+ private static final String ALERT_CONDITION_CATEGORY_CALLTIME_THRESHOLD = "calltime-threshold";
+
private static final String AVAILABILITY_ITEMNAME = "availability";
private static final String THRESHOLD_METRIC_ITEMNAME = "thresholdMetric";
private static final String THRESHOLD_COMPARATOR_ITEMNAME = "thresholdComparator";
@@ -67,6 +72,16 @@ public class NewConditionEditor extends LocatableDynamicForm {
private static final String BASELINE_PERCENTAGE_ITEMNAME = "baselinePercentage";
private static final String BASELINE_SELECTION_ITEMNAME = "baselineSelection";
private static final String CHANGE_METRIC_ITEMNAME = "changeMetric";
+ private static final String CALLTIME_THRESHOLD_METRIC_ITEMNAME = "calltimeThresholdMetric";
+ private static final String CALLTIME_THRESHOLD_MINMAXAVG_ITEMNAME = "calltimeThresholdMinMaxAvgSelection";
+ private static final String CALLTIME_THRESHOLD_COMPARATOR_ITEMNAME = "calltimeThresholdComparator";
+ private static final String CALLTIME_THRESHOLD_ABSVALUE_ITEMNAME = "calltimeThresholdAbsoluteValue";
+ private static final String CALLTIME_THRESHOLD_REGEX_ITEMNAME = "calltimeThresholdRegex";
+ private static final String CALLTIME_CHANGE_METRIC_ITEMNAME = "calltimeChangeMetric";
+ private static final String CALLTIME_CHANGE_MINMAXAVG_ITEMNAME = "calltimeChangeMinMaxAvgSelection";
+ private static final String CALLTIME_CHANGE_COMPARATOR_ITEMNAME = "calltimeChangeComparator";
+ private static final String CALLTIME_CHANGE_PERCENTAGE_ITEMNAME = "calltimeChangePercentageValue";
+ private static final String CALLTIME_CHANGE_REGEX_ITEMNAME = "calltimeChangeRegex";
private static final String TRAIT_METRIC_ITEMNAME = "trait";
private static final String OPERATION_NAME_ITEMNAME = "operation";
private static final String OPERATION_RESULTS_ITEMNAME = "operationResults";
@@ -76,6 +91,7 @@ public class NewConditionEditor extends LocatableDynamicForm {
private SelectItem conditionTypeSelectItem;
private HashSet<AlertCondition> conditions; // the new condition we create goes into this set
private boolean supportsMetrics = false;
+ private boolean supportsCalltimeMetrics = false;
private boolean supportsTraits = false;
private boolean supportsOperations = false;
private boolean supportsEvents = false;
@@ -101,6 +117,10 @@ public class NewConditionEditor extends LocatableDynamicForm {
this.supportsMetrics = true;
break;
}
+ case CALLTIME: {
+ this.supportsCalltimeMetrics = true;
+ break;
+ }
case TRAIT: {
this.supportsTraits = true;
break;
@@ -132,6 +152,10 @@ public class NewConditionEditor extends LocatableDynamicForm {
condTypes.put(AlertConditionCategory.BASELINE.name(), "Measurement Baseline Threshold");
condTypes.put(AlertConditionCategory.CHANGE.name(), "Measurement Value Change");
}
+ if (supportsCalltimeMetrics) {
+ condTypes.put(ALERT_CONDITION_CATEGORY_CALLTIME_THRESHOLD, "Calltime Value Threshold");
+ condTypes.put(ALERT_CONDITION_CATEGORY_CALLTIME_CHANGE, "Calltime Value Change");
+ }
if (supportsTraits) {
condTypes.put(AlertConditionCategory.TRAIT.name(), "Trait Value Change");
}
@@ -176,6 +200,10 @@ public class NewConditionEditor extends LocatableDynamicForm {
formItems.addAll(buildMetricBaselineFormItems());
formItems.addAll(buildMetricChangeFormItems());
}
+ if (supportsCalltimeMetrics) {
+ formItems.addAll(buildCalltimeThresholdFormItems());
+ formItems.addAll(buildCalltimeChangeFormItems());
+ }
if (supportsTraits) {
formItems.addAll(buildTraitChangeFormItems());
}
@@ -194,8 +222,20 @@ public class NewConditionEditor extends LocatableDynamicForm {
};
private void saveNewCondition() {
- AlertConditionCategory category;
- category = AlertConditionCategory.valueOf(conditionTypeSelectItem.getValue().toString());
+ final boolean calltimeCategory;
+ final AlertConditionCategory category;
+
+ String selectedCategory = conditionTypeSelectItem.getValue().toString();
+ if (selectedCategory.equals(ALERT_CONDITION_CATEGORY_CALLTIME_THRESHOLD)) {
+ calltimeCategory = true;
+ category = AlertConditionCategory.THRESHOLD;
+ } else if (selectedCategory.equals(ALERT_CONDITION_CATEGORY_CALLTIME_CHANGE)) {
+ calltimeCategory = true;
+ category = AlertConditionCategory.CHANGE;
+ } else {
+ calltimeCategory = false;
+ category = AlertConditionCategory.valueOf(selectedCategory);
+ }
AlertCondition newCondition = new AlertCondition();
newCondition.setCategory(category);
@@ -211,12 +251,21 @@ public class NewConditionEditor extends LocatableDynamicForm {
}
case THRESHOLD: {
- MeasurementDefinition measDef = getMeasurementDefinition(getValueAsString(THRESHOLD_METRIC_ITEMNAME));
- newCondition.setName(measDef.getDisplayName()); // TODO should not use display name
- newCondition.setThreshold(Double.valueOf(getValueAsString(THRESHOLD_ABSVALUE_ITEMNAME)));
- newCondition.setComparator(getValueAsString(THRESHOLD_COMPARATOR_ITEMNAME));
- newCondition.setOption(null);
- newCondition.setMeasurementDefinition(measDef);
+ if (!calltimeCategory) {
+ MeasurementDefinition measDef = getMeasurementDefinition(getValueAsString(THRESHOLD_METRIC_ITEMNAME));
+ newCondition.setName(measDef.getDisplayName()); // TODO should not use display name
+ newCondition.setThreshold(Double.valueOf(getValueAsString(THRESHOLD_ABSVALUE_ITEMNAME)));
+ newCondition.setComparator(getValueAsString(THRESHOLD_COMPARATOR_ITEMNAME));
+ newCondition.setOption(null);
+ newCondition.setMeasurementDefinition(measDef);
+ } else {
+ MeasurementDefinition measDef = getMeasurementDefinition(getValueAsString(CALLTIME_THRESHOLD_METRIC_ITEMNAME));
+ newCondition.setName(getValueAsString(CALLTIME_THRESHOLD_REGEX_ITEMNAME));
+ newCondition.setThreshold(Double.valueOf(getValueAsString(CALLTIME_THRESHOLD_ABSVALUE_ITEMNAME)));
+ newCondition.setComparator(getValueAsString(CALLTIME_THRESHOLD_COMPARATOR_ITEMNAME));
+ newCondition.setOption(getValueAsString(CALLTIME_THRESHOLD_MINMAXAVG_ITEMNAME));
+ newCondition.setMeasurementDefinition(measDef);
+ }
break;
}
@@ -231,12 +280,22 @@ public class NewConditionEditor extends LocatableDynamicForm {
}
case CHANGE: {
- MeasurementDefinition measDef = getMeasurementDefinition(getValueAsString(CHANGE_METRIC_ITEMNAME));
- newCondition.setName(measDef.getDisplayName()); // TODO should not use display name
- newCondition.setComparator(null);
- newCondition.setThreshold(null);
- newCondition.setOption(null);
- newCondition.setMeasurementDefinition(measDef);
+ if (!calltimeCategory) {
+ MeasurementDefinition measDef = getMeasurementDefinition(getValueAsString(CHANGE_METRIC_ITEMNAME));
+ newCondition.setName(measDef.getDisplayName()); // TODO should not use display name
+ newCondition.setComparator(null);
+ newCondition.setThreshold(null);
+ newCondition.setOption(null);
+ newCondition.setMeasurementDefinition(measDef);
+ } else {
+ MeasurementDefinition measDef = getMeasurementDefinition(getValueAsString(CALLTIME_CHANGE_METRIC_ITEMNAME));
+ newCondition.setName(getValueAsString(CALLTIME_CHANGE_REGEX_ITEMNAME));
+ newCondition
+ .setThreshold(Double.valueOf(getValueAsString(CALLTIME_CHANGE_PERCENTAGE_ITEMNAME)) / 100.0);
+ newCondition.setComparator(getValueAsString(CALLTIME_CHANGE_COMPARATOR_ITEMNAME));
+ newCondition.setOption(getValueAsString(CALLTIME_CHANGE_MINMAXAVG_ITEMNAME));
+ newCondition.setMeasurementDefinition(measDef);
+ }
break;
}
@@ -360,6 +419,97 @@ public class NewConditionEditor extends LocatableDynamicForm {
return formItems;
}
+ private ArrayList<FormItem> buildCalltimeThresholdFormItems() {
+ ArrayList<FormItem> formItems = new ArrayList<FormItem>();
+
+ ShowIfCategoryFunction ifFunc = new ShowIfCategoryFunction(ALERT_CONDITION_CATEGORY_CALLTIME_THRESHOLD);
+
+ String helpStr = "Specify the calltime threshold value that, when violated, triggers the condition. The value you specify is an absolute value with an optional units specifier. You also must specify which calltime limit to compare the value with (minimum, maximum or average calltime value).";
+ StaticTextItem helpItem = buildHelpTextItem("calltimeThresholdHelp", helpStr, ifFunc);
+ formItems.add(helpItem);
+
+ formItems.add(buildCalltimeMetricDropDownMenu(CALLTIME_THRESHOLD_METRIC_ITEMNAME, ifFunc));
+
+ SelectItem minMaxAvgSelection = new SelectItem(CALLTIME_THRESHOLD_MINMAXAVG_ITEMNAME, "Calltime Limit");
+ LinkedHashMap<String, String> limits = new LinkedHashMap<String, String>(3);
+ limits.put("MIN", "Minimum");
+ limits.put("AVG", "Average");
+ limits.put("MAX", "Maximum");
+ minMaxAvgSelection.setTooltip("The calltime limit value that is to be compared with the given value");
+ minMaxAvgSelection.setValueMap(limits);
+ minMaxAvgSelection.setDefaultValue("AVG");
+ minMaxAvgSelection.setWrapTitle(false);
+ minMaxAvgSelection.setWidth("*");
+ minMaxAvgSelection.setRedrawOnChange(true);
+ minMaxAvgSelection.setShowIfCondition(ifFunc);
+ formItems.add(minMaxAvgSelection);
+
+ formItems.add(buildComparatorDropDownMenu(CALLTIME_THRESHOLD_COMPARATOR_ITEMNAME, ifFunc));
+ TextItem absoluteValue = new TextItem(CALLTIME_THRESHOLD_ABSVALUE_ITEMNAME, "Calltime Value");
+ absoluteValue.setWrapTitle(false);
+ absoluteValue.setRequired(true);
+ absoluteValue
+ .setTooltip("The threshold value of the metric that will trigger the condition when compared using the selected comparator.");
+ absoluteValue.setShowIfCondition(ifFunc);
+ formItems.add(absoluteValue);
+
+ TextItem regex = new TextItem(CALLTIME_THRESHOLD_REGEX_ITEMNAME, "Regular Expression");
+ regex.setRequired(false);
+ regex
+ .setTooltip("If specified, this is a regular expression that must match a call destination in order to trigger the condition.");
+ regex.setWrapTitle(false);
+ regex.setShowIfCondition(ifFunc);
+ formItems.add(regex);
+
+ return formItems;
+ }
+
+ private ArrayList<FormItem> buildCalltimeChangeFormItems() {
+ ArrayList<FormItem> formItems = new ArrayList<FormItem>();
+
+ ShowIfCategoryFunction ifFunc = new ShowIfCategoryFunction(ALERT_CONDITION_CATEGORY_CALLTIME_CHANGE);
+
+ String helpStr = "Specify the calltime value that, when changed at least a specified amount, triggers the condition. You must specify which calltime limit to check (minimum, maximum or average calltime value) and the percentage of change that must occur.";
+ StaticTextItem helpItem = buildHelpTextItem("calltimeChangeHelp", helpStr, ifFunc);
+ formItems.add(helpItem);
+
+ formItems.add(buildCalltimeMetricDropDownMenu(CALLTIME_CHANGE_METRIC_ITEMNAME, ifFunc));
+
+ SelectItem minMaxAvgSelection = new SelectItem(CALLTIME_CHANGE_MINMAXAVG_ITEMNAME, "Calltime Limit");
+ LinkedHashMap<String, String> limits = new LinkedHashMap<String, String>(3);
+ limits.put("MIN", "Minimum");
+ limits.put("AVG", "Average");
+ limits.put("MAX", "Maximum");
+ minMaxAvgSelection.setTooltip("The calltime limit value that is to be checked for change");
+ minMaxAvgSelection.setValueMap(limits);
+ minMaxAvgSelection.setDefaultValue("AVG");
+ minMaxAvgSelection.setWrapTitle(false);
+ minMaxAvgSelection.setWidth("*");
+ minMaxAvgSelection.setRedrawOnChange(true);
+ minMaxAvgSelection.setShowIfCondition(ifFunc);
+ formItems.add(minMaxAvgSelection);
+
+ formItems.add(buildCalltimeComparatorDropDownMenu(CALLTIME_CHANGE_COMPARATOR_ITEMNAME, ifFunc));
+
+ TextItem percentage = new TextItem(CALLTIME_CHANGE_PERCENTAGE_ITEMNAME, "Percentage Change");
+ percentage.setWrapTitle(false);
+ percentage.setRequired(true);
+ percentage
+ .setTooltip("A collected calltime value will trigger this condition when it differs by at least this percentage of the selected calltime limit value");
+ percentage.setShowIfCondition(ifFunc);
+ formItems.add(percentage);
+
+ TextItem regex = new TextItem(CALLTIME_CHANGE_REGEX_ITEMNAME, "Regular Expression");
+ regex.setRequired(false);
+ regex
+ .setTooltip("If specified, this is a regular expression that must match a call destination in order to trigger the condition.");
+ regex.setWrapTitle(false);
+ regex.setShowIfCondition(ifFunc);
+ formItems.add(regex);
+
+ return formItems;
+ }
+
private ArrayList<FormItem> buildTraitChangeFormItems() {
ArrayList<FormItem> formItems = new ArrayList<FormItem>();
@@ -510,9 +660,27 @@ public class NewConditionEditor extends LocatableDynamicForm {
return metricSelection;
}
+ private SelectItem buildCalltimeMetricDropDownMenu(String itemName, FormItemIfFunction ifFunc) {
+
+ LinkedHashMap<String, String> metricsMap = new LinkedHashMap<String, String>();
+ for (MeasurementDefinition def : this.resourceType.getMetricDefinitions()) {
+ if (def.getDataType() == DataType.CALLTIME) {
+ metricsMap.put(def.getName(), def.getDisplayName());
+ }
+ }
+
+ SelectItem metricSelection = new SelectItem(itemName, "Metric");
+ metricSelection.setValueMap(metricsMap);
+ metricSelection.setDefaultValue(metricsMap.keySet().iterator().next()); // just use the first one
+ metricSelection.setWidth("*");
+ metricSelection.setRedrawOnChange(true);
+ metricSelection.setShowIfCondition(ifFunc);
+ return metricSelection;
+ }
+
private SelectItem buildComparatorDropDownMenu(String itemName, FormItemIfFunction ifFunc) {
- LinkedHashMap<String, String> comparators = new LinkedHashMap<String, String>();
+ LinkedHashMap<String, String> comparators = new LinkedHashMap<String, String>(3);
comparators.put("<", "< (Less than)");
comparators.put("=", "= (Equal to)");
comparators.put(">", "> (Greater than)");
@@ -525,6 +693,21 @@ public class NewConditionEditor extends LocatableDynamicForm {
return comparatorSelection;
}
+ private SelectItem buildCalltimeComparatorDropDownMenu(String itemName, FormItemIfFunction ifFunc) {
+
+ LinkedHashMap<String, String> comparators = new LinkedHashMap<String, String>(3);
+ comparators.put("LO", "Shrinks");
+ comparators.put("CH", "Changes");
+ comparators.put("HI", "Grows");
+
+ SelectItem comparatorSelection = new SelectItem(itemName, "Comparator");
+ comparatorSelection.setValueMap(comparators);
+ comparatorSelection.setDefaultValue("CH");
+ comparatorSelection.setTooltip("How a collected calltime value should be compared to the given calltime limit");
+ comparatorSelection.setShowIfCondition(ifFunc);
+ return comparatorSelection;
+ }
+
private StaticTextItem buildHelpTextItem(String itemName, String helpText, FormItemIfFunction ifFunc) {
StaticTextItem help = new StaticTextItem(itemName);
help.setShowTitle(false);
@@ -548,13 +731,25 @@ public class NewConditionEditor extends LocatableDynamicForm {
private class ShowIfCategoryFunction implements FormItemIfFunction {
private final AlertConditionCategory category;
+ private final String calltimeCategory;
public ShowIfCategoryFunction(AlertConditionCategory category) {
this.category = category;
+ this.calltimeCategory = null;
+ }
+
+ public ShowIfCategoryFunction(String calltimeCategory) {
+ this.category = null;
+ this.calltimeCategory = calltimeCategory;
}
public boolean execute(FormItem item, Object value, DynamicForm form) {
- return category.name().equals(form.getValue("conditionType").toString());
+ String conditionTypeString = form.getValue("conditionType").toString();
+ if (category != null) {
+ return category.name().equals(conditionTypeString);
+ } else {
+ return calltimeCategory.equals(conditionTypeString);
+ }
}
}
}
commit d4a02cc3c2fb7e999fede59f3813357e6b0e79ec
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Sep 20 09:19:34 2010 -0400
add more javadocs to explain what the fields are for calltime alert conditions
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertCondition.java b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertCondition.java
index 3218d9d..640648b 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertCondition.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertCondition.java
@@ -390,6 +390,8 @@ public class AlertCondition implements Serializable {
* THRESHOLD: the name of the metric (TODO: today its the display name, very bad for i18n purposes)
* BASELINE: the name of the metric (TODO: today its the display name, very bad for i18n purposes)
* CHANGE: the name of the metric (TODO: today its the display name, very bad for i18n purposes)
+ * OR (for calltime alert conditions only) this will be the optional regular expression condition
+ * (which may be null)
* TRAIT: the name of the trait (TODO: today its the display name, very bad for i18n purposes)
* CONTROL: the name of the operation (not its display name)
* EVENT: the level of event to compare with (DEBUG, INFO, WARN, ERROR, FATAL)
@@ -405,11 +407,14 @@ public class AlertCondition implements Serializable {
}
/**
- * One of these comparators: "<", ">" or "=".
- * This will be null if the condition does not compare values. Only THRESHOLD
- * and BASELINE condition categories use comparators; other types of conditions
- * will return <code>null</code>.
+ * Will be one of these comparators: "<", ">" or "=" but only for THRESHOLD
+ * and BASELINE condition categories. For calltime alert conditions (i.e. category
+ * CHANGE for calltime metric definitions), comparator will be one of these
+ * comparators: "HI", "LO", "CH" (where "CH" means "change").
*
+ * Other types of conditions will return <code>null</code> (i.e. this will be
+ * null if the condition does not compare values).
+ *
* @return comparator string
*/
public String getComparator() {
@@ -422,7 +427,8 @@ public class AlertCondition implements Serializable {
/**
* Returns the threshold to compare a measurement value to see if the condition is true.
- * This is only valid for conditions of category THRESHOLD and BASELINE. All other
+ * This is only valid for conditions of category THRESHOLD, BASELINE and CHANGE (but
+ * only where CHANGE is for a calltime metric alert condition). All other
* condition types will return <code>null</code>.
*
* @return threshold value or null
@@ -438,9 +444,9 @@ public class AlertCondition implements Serializable {
/**
* The option string is optional and its semantics differ based on the category of this condition:
* AVAILABILITY: the {@link AvailabilityType} to trigger off of (DOWN or UP)
- * THRESHOLD: n/a
+ * THRESHOLD: for calltime metric conditions, one of "MIN, "MAX", "AVG" - all others are n/a
* BASELINE: one of "min", "max" or "mean" - indicates what the threshold is compared to (min/max/avg baseline value)
- * CHANGE: n/a
+ * CHANGE: for calltime metric conditions, one of "MIN, "MAX", "AVG" - all others are n/a
* TRAIT: n/a
* CONTROL: the {@link OperationRequestStatus} name (SUCCESS, FAILURE, etc).
* EVENT: the regular expression of the message to match (which may be empty string if not specified)
commit 3f9bf4117760546e9efd7284cee6ee61e0090405
Merge: e7d80ea... 19cc4a4...
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Sep 17 17:58:39 2010 -0400
Merge branch 'master' into master-jay
commit e7d80ea51297197d838d2810814e25eb73a47776
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Sep 17 17:44:30 2010 -0400
Work on Group CRUD
- Group category now determined on the fly, a la group def calculation,
by group membership. This means a manually group can change category
in its lifetime by editing the membership. That may be less important
than the fact that it simplifies initial creation and users really
only have to care about adding members.
- Added basic support for mixed-group tree/detail view. Just enough to
get us moving.
- Added Inventory->Membership subtab for changing group members.
- Changed ResourceManagerLocal.ensureMembershipMatches() to .setMembership()
The name is cleaner and in line with naming for a series of new
calls that simply syncs associated data to be the set passed in. Also,
optionally can reset the group's category based on the membership change.
- A couple of locatorId fixes in touched files
-
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGroupGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGroupGWTService.java
index c4a4bca..333427f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGroupGWTService.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGroupGWTService.java
@@ -34,23 +34,26 @@ import org.rhq.core.domain.util.PageList;
@RemoteServiceRelativePath("ResourceGroupGWTService")
public interface ResourceGroupGWTService extends RemoteService {
- PageList<ResourceGroup> findResourceGroupsByCriteria(ResourceGroupCriteria criteria);
+ GroupDefinition createGroupDefinition(GroupDefinition groupDefinition);
- PageList<ResourceGroupComposite> findResourceGroupCompositesByCriteria(ResourceGroupCriteria criteria);
+ ResourceGroup createResourceGroup(ResourceGroup group, int[] resourceIds);
- PageList<GroupDefinition> findGroupDefinitionsByCriteria(ResourceGroupDefinitionCriteria criteria);
+ void deleteGroupDefinitions(int[] groupDefinitionIds);
- void ensureMembershipMatches(int groupId, int[] resourceIds);
+ void deleteResourceGroups(int[] groupIds);
- ResourceGroup createResourceGroup(ResourceGroup group, int[] resourceIds);
+ PageList<GroupDefinition> findGroupDefinitionsByCriteria(ResourceGroupDefinitionCriteria criteria);
- void deleteResourceGroups(int[] groupIds);
+ PageList<ResourceGroup> findResourceGroupsByCriteria(ResourceGroupCriteria criteria);
- void updateResourceGroup(ResourceGroup group);
+ PageList<ResourceGroupComposite> findResourceGroupCompositesByCriteria(ResourceGroupCriteria criteria);
+
+ void setMembership(int groupId, int[] resourceIds, boolean setType);
void updateGroupDefinition(GroupDefinition groupDefinition);
- void deleteGroupDefinitions(int[] groupDefinitionIds);
+ void updateResourceGroup(ResourceGroup group);
- GroupDefinition createGroupDefinition(GroupDefinition groupDefinition);
-}
+ void updateResourceGroup(ResourceGroup group, boolean updateMembership);
+
+}
\ 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/ResourceGroupDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
index 128dff8..6603a00 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
@@ -45,6 +45,7 @@ import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTab;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.AbstractTwoLevelTabSetView;
import org.rhq.enterprise.gui.coregui.client.inventory.common.event.EventCompositeHistoryView;
+import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.inventory.ResourceGroupMembershipView;
import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.schedules.SchedulesView;
import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.traits.TraitsView;
import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.summary.OverviewView;
@@ -52,10 +53,9 @@ import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceSearchVi
import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
/**
- * Right panel of the group view.
+ * Be able to view members as a resource list, or edit members via selector.
*
- * @author Greg Hinkle
- * @author Ian Springer
+ * @author Jay Shaughnessy
*/
public class ResourceGroupDetailView extends AbstractTwoLevelTabSetView<ResourceGroupComposite, ResourceGroupTitleBar> {
private static final String BASE_VIEW_PATH = "ResourceGroup";
@@ -83,6 +83,7 @@ public class ResourceGroupDetailView extends AbstractTwoLevelTabSetView<Resource
private SubTab monitorCallTime;
private SubTab inventoryMembers;
private SubTab inventoryConn;
+ private SubTab inventoryMembership;
private SubTab opHistory;
private SubTab opSched;
private SubTab alertHistory;
@@ -91,12 +92,24 @@ public class ResourceGroupDetailView extends AbstractTwoLevelTabSetView<Resource
private SubTab configHistory;
private SubTab eventHistory;
+ private String currentTab;
+ private String currentSubTab;
+
public ResourceGroupDetailView(String locatorId) {
super(locatorId, BASE_VIEW_PATH);
}
@Override
public Integer getSelectedItemId() {
+ // if moving from membership subtab then re-load the detail view as the membership and
+ // group type may have changed.
+ if (this.inventoryTab.getTitle().equals(currentTab)
+ && this.inventoryMembership.getTitle().equals(currentSubTab)) {
+ this.currentTab = null;
+ this.currentSubTab = null;
+ this.groupId = null;
+ }
+
return this.groupId;
}
@@ -130,7 +143,8 @@ public class ResourceGroupDetailView extends AbstractTwoLevelTabSetView<Resource
"/images/icons/Inventory_grey_16.png");
inventoryMembers = new SubTab(inventoryTab.extendLocatorId("Members"), "Members", null);
inventoryConn = new SubTab(inventoryTab.extendLocatorId("ConnectionSettings"), "Connection Settings", null);
- inventoryTab.registerSubTabs(this.inventoryMembers, this.inventoryConn);
+ inventoryMembership = new SubTab(inventoryTab.extendLocatorId("Membership"), "Membership", null);
+ inventoryTab.registerSubTabs(this.inventoryMembers, this.inventoryConn, this.inventoryMembership);
tabs.add(inventoryTab);
operationsTab = new TwoLevelTab(getTabSet().extendLocatorId("Operations"), "Operations",
@@ -184,9 +198,12 @@ public class ResourceGroupDetailView extends AbstractTwoLevelTabSetView<Resource
this.monitorSched.setCanvas(new SchedulesView(this.monitoringTab.extendLocatorId("SchedulesView"), groupId));
this.monitorCallTime.setCanvas(new FullHTMLPane("/rhq/group/monitor/response-plain.xhtml?groupId=" + groupId));
- this.inventoryMembers.setCanvas(ResourceSearchView.getMembersOf(groupId));
+ this.inventoryMembers.setCanvas(ResourceSearchView.getMembersOf(this.inventoryTab
+ .extendLocatorId("MembersView"), groupId));
// TODO: Uncomment this once the group config component is done.
//this.inventoryConn.setCanvas(new GroupPluginConfigurationEditView(this.group.getId(), this.group.getResourceType().getId(), ConfigurationEditor.ConfigType.plugin));
+ this.inventoryMembership.setCanvas(new ResourceGroupMembershipView(this.inventoryTab
+ .extendLocatorId("MembershipView"), groupId));
this.opHistory.setCanvas(new FullHTMLPane("/rhq/group/operation/groupOperationHistory-plain.xhtml?groupId="
+ groupId));
@@ -290,6 +307,9 @@ public class ResourceGroupDetailView extends AbstractTwoLevelTabSetView<Resource
});
}
});
+ } else {
+ updateTabContent(groupComposite);
+ selectTab(getTabName(), getSubTabName(), viewPath);
}
}
@@ -305,4 +325,12 @@ public class ResourceGroupDetailView extends AbstractTwoLevelTabSetView<Resource
}
return false;
}
+
+ @Override
+ public void selectTab(String tabTitle, String subtabTitle, ViewPath viewPath) {
+ currentTab = tabTitle;
+ currentSubTab = subtabTitle;
+ super.selectTab(tabTitle, subtabTitle, 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 aa2ee61..ba57920 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
@@ -43,6 +43,7 @@ import com.smartgwt.client.widgets.tree.events.NodeContextClickHandler;
import org.rhq.core.domain.criteria.ResourceGroupCriteria;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.resource.group.ClusterKey;
+import org.rhq.core.domain.resource.group.GroupCategory;
import org.rhq.core.domain.resource.group.ResourceGroup;
import org.rhq.core.domain.resource.group.composite.ClusterFlyweight;
import org.rhq.core.domain.resource.group.composite.ClusterKeyFlyweight;
@@ -89,14 +90,11 @@ public class ResourceGroupTreeView extends VLayout implements BookmarkableView {
treeGrid.setSortField("name");
treeGrid.setShowHeader(false);
-
addMember(this.treeGrid);
-
contextMenu = new ResourceGroupTreeContextMenu();
treeGrid.setContextMenu(contextMenu);
-
treeGrid.addSelectionChangedHandler(new SelectionChangedHandler() {
@Override
public void onSelectionChanged(SelectionEvent selectionEvent) {
@@ -141,17 +139,29 @@ public class ResourceGroupTreeView extends VLayout implements BookmarkableView {
criteria.fetchResourceType(true);
GWTServiceLookup.getResourceGroupService().findResourceGroupsByCriteria(criteria,
- new AsyncCallback<PageList<ResourceGroup>>() {
- @Override
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to load group", caught);
- }
-
- @Override
- public void onSuccess(PageList<ResourceGroup> result) {
- ResourceGroup group = result.get(0);
- ResourceGroupTreeView.this.selectedGroup = group;
+ new AsyncCallback<PageList<ResourceGroup>>() {
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to load group", caught);
+ }
+ @Override
+ public void onSuccess(PageList<ResourceGroup> result) {
+ 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) {
ResourceGroupTreeView.this.rootResourceGroup = group;
// This is a straight up group
@@ -164,12 +174,12 @@ public class ResourceGroupTreeView extends VLayout implements BookmarkableView {
loadGroup(rootGroup.getId());
}
-
}
- });
- }
+ }
+ });
+ }
private void loadGroup(int groupId) {
@@ -193,19 +203,17 @@ public class ResourceGroupTreeView extends VLayout implements BookmarkableView {
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);
- }
+ GWTServiceLookup.getClusterService().getClusterTree(groupId, new AsyncCallback<ClusterFlyweight>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to load tree", caught);
+ }
- public void onSuccess(ClusterFlyweight result) {
- loadTreeTypes(result);
- }
- });
+ public void onSuccess(ClusterFlyweight result) {
+ loadTreeTypes(result);
+ }
+ });
}
}
@@ -215,60 +223,54 @@ public class ResourceGroupTreeView extends VLayout implements BookmarkableView {
typeIds.add(this.rootResourceGroup.getResourceType().getId());
getTreeTypes(root, typeIds);
- ResourceTypeRepository.Cache.getInstance().getResourceTypes(
- typeIds.toArray(new Integer[typeIds.size()]),
- new ResourceTypeRepository.TypesLoadedCallback() {
- @Override
- public void onTypesLoaded(HashMap<Integer, ResourceType> types) {
- ResourceGroupTreeView.this.typeMap = types;
- loadTree(root);
- }
+ ResourceTypeRepository.Cache.getInstance().getResourceTypes(typeIds.toArray(new Integer[typeIds.size()]),
+ new ResourceTypeRepository.TypesLoadedCallback() {
+ @Override
+ public void onTypesLoaded(HashMap<Integer, ResourceType> types) {
+ ResourceGroupTreeView.this.typeMap = types;
+ loadTree(root);
}
- );
+ });
}
-
private void selectClusterGroup(ClusterKey key) {
GWTServiceLookup.getClusterService().createAutoClusterBackingGroup(key, true,
- new AsyncCallback<ResourceGroup>() {
- @Override
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to create or update auto cluster group", caught);
- }
+ new AsyncCallback<ResourceGroup>() {
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to create or update auto cluster group", caught);
+ }
- @Override
- public void onSuccess(ResourceGroup result) {
- int groupId = result.getId();
- History.newItem("ResourceGroup/" + groupId);
- }
- });
+ @Override
+ public void onSuccess(ResourceGroup result) {
+ int groupId = result.getId();
+ History.newItem("ResourceGroup/" + groupId);
+ }
+ });
}
private void loadTree(ClusterFlyweight root) {
TreeNode fakeRoot = new TreeNode("fakeRootNode");
-
TreeNode rootNode = new TreeNode(rootResourceGroup.getName());
rootNode.setID(String.valueOf(root.getGroupId())); //getClusterKey().toString());
+
ResourceType rootResourceType = typeMap.get(rootResourceGroup.getResourceType().getId());
rootNode.setAttribute("resourceType", rootResourceType);
String icon = "types/" + rootResourceType.getCategory().getDisplayName() + "_up_16.png";
rootNode.setIcon(icon);
- fakeRoot.setChildren(new TreeNode[]{rootNode});
+ fakeRoot.setChildren(new TreeNode[] { rootNode });
ClusterKey rootKey = new ClusterKey(root.getGroupId());
loadTree(rootNode, root, rootKey);
-
-
Tree tree = new Tree();
tree.setRoot(fakeRoot);
-
treeGrid.setData(tree);
treeGrid.markForRedraw();
}
@@ -286,7 +288,8 @@ public class ResourceGroupTreeView extends VLayout implements BookmarkableView {
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());
ResourceType type = this.typeMap.get(keyFlyweight.getResourceTypeId());
@@ -294,7 +297,6 @@ public class ResourceGroupTreeView extends VLayout implements BookmarkableView {
node.setIcon(icon);
-
node.setID(key.getKey());
node.setAttribute("key", key);
node.setAttribute("resourceType", type);
@@ -317,7 +319,6 @@ public class ResourceGroupTreeView extends VLayout implements BookmarkableView {
setSelectedGroup(groupId);
}
-
private void getTreeTypes(ClusterFlyweight clusterFlyweight, Set<Integer> typeIds) {
if (clusterFlyweight.getClusterKey() != null) {
typeIds.add(clusterFlyweight.getClusterKey().getResourceTypeId());
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/ResourceGroupMembershipView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/ResourceGroupMembershipView.java
new file mode 100644
index 0000000..e08b57d
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/ResourceGroupMembershipView.java
@@ -0,0 +1,129 @@
+/*
+ * 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.inventory;
+
+import java.util.HashSet;
+
+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;
+import com.smartgwt.client.widgets.toolbar.ToolStrip;
+
+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.CoreGUI;
+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.selenium.LocatableIButton;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+
+/**
+ * @author Jay Shaughnessy
+ */
+public class ResourceGroupMembershipView extends LocatableVLayout {
+
+ private int resourceGroupId;
+ private ResourceGroup resourceGroup;
+ private ResourceGroupResourceSelector selector;
+
+ public ResourceGroupMembershipView(String locatorId, int resourceGroupId) {
+ super(locatorId);
+
+ this.resourceGroupId = resourceGroupId;
+ }
+
+ @Override
+ protected void onDraw() {
+ super.onDraw();
+
+ build();
+ }
+
+ 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() {
+ public void onClick(ClickEvent clickEvent) {
+ save();
+ }
+ });
+
+ toolStrip.addMember(saveButton);
+ this.addMember(toolStrip);
+
+ ResourceGroupCriteria c = new ResourceGroupCriteria();
+ c.addFilterId(this.resourceGroupId);
+ c.fetchExplicitResources(true);
+ GWTServiceLookup.getResourceGroupService().findResourceGroupsByCriteria(c,
+ new AsyncCallback<PageList<ResourceGroup>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to fetch Resource Group", caught);
+ }
+
+ public void onSuccess(PageList<ResourceGroup> result) {
+ ResourceGroupMembershipView.this.resourceGroup = result.get(0);
+ ResourceGroupMembershipView.this.selector = new ResourceGroupResourceSelector(
+ ResourceGroupMembershipView.this.getLocatorId(), ResourceGroupMembershipView.this.resourceGroup
+ .getExplicitResources());
+ ResourceGroupMembershipView.this.selector.setOverflow(Overflow.AUTO);
+
+ addMember(ResourceGroupMembershipView.this.selector);
+ }
+ });
+ }
+
+ private void save() {
+ int[] resourceIds = getSelectedResourceIds();
+
+ GWTServiceLookup.getResourceGroupService().setMembership(this.resourceGroup.getId(), resourceIds, true,
+ new AsyncCallback<Void>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to update configuration", caught);
+ }
+
+ public void onSuccess(Void result) {
+ CoreGUI.getMessageCenter().notify(
+ new Message("Group membership updated for ["
+ + ResourceGroupMembershipView.this.resourceGroup.getName() + "]", Message.Severity.Info));
+ CoreGUI.refresh();
+ }
+ });
+ }
+
+ private int[] getSelectedResourceIds() {
+ int[] selection = new int[this.selector.getSelection().size()];
+ HashSet<Integer> selectedIds = this.selector.getSelection();
+ int i = 0;
+ for (Integer id : selectedIds) {
+ selection[i++] = id;
+ }
+
+ return selection;
+ }
+
+}
\ 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/inventory/ResourceGroupResourceSelector.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/ResourceGroupResourceSelector.java
new file mode 100644
index 0000000..6bc96fb
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/ResourceGroupResourceSelector.java
@@ -0,0 +1,45 @@
+/*
+ * 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.inventory;
+
+import java.util.Collection;
+
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDatasource;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.selection.ResourceSelector;
+
+/**
+ * @author Jay Shaughnessy
+ */
+public class ResourceGroupResourceSelector extends ResourceSelector {
+
+ public ResourceGroupResourceSelector(String locatorId, Collection<Resource> resources) {
+ super(locatorId);
+ if (null != resources) {
+ ListGridRecord[] data = (new ResourceDatasource()).buildRecords(resources);
+ setAssigned(data);
+ }
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/OverviewView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/OverviewView.java
index 41aff20..2c3f364 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/OverviewView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/OverviewView.java
@@ -91,7 +91,7 @@ public class OverviewView extends LocatableVLayout {
return;
}
group.setName(newName);
- OverviewView.this.resourceGroupService.updateResourceGroup(group, new AsyncCallback<Void>() {
+ OverviewView.this.resourceGroupService.updateResourceGroup(group, false, new AsyncCallback<Void>() {
public void onFailure(Throwable caught) {
CoreGUI.getErrorHandler().handleError(
"Failed to change name of Resource group with id " + group.getId() + " from \""
@@ -141,7 +141,7 @@ public class OverviewView extends LocatableVLayout {
return;
}
group.setDescription(newDescription);
- OverviewView.this.resourceGroupService.updateResourceGroup(group, new AsyncCallback<Void>() {
+ OverviewView.this.resourceGroupService.updateResourceGroup(group, false, new AsyncCallback<Void>() {
public void onFailure(Throwable caught) {
CoreGUI.getErrorHandler().handleError(
"Failed to change description of Resource group with id " + group.getId() + " from \""
@@ -177,7 +177,7 @@ public class OverviewView extends LocatableVLayout {
return;
}
group.setLocation(newLocation);
- OverviewView.this.resourceGroupService.updateResourceGroup(group, new AsyncCallback<Void>() {
+ OverviewView.this.resourceGroupService.updateResourceGroup(group, false, new AsyncCallback<Void>() {
public void onFailure(Throwable caught) {
CoreGUI.getErrorHandler().handleError(
"Failed to change location of Resource group with id " + group.getId() + " from \""
@@ -224,7 +224,8 @@ public class OverviewView extends LocatableVLayout {
StaticTextItem groupDefinitionItem = new StaticTextItem("groupDefinition", "Group Definition");
GroupDefinition groupDefinition = group.getGroupDefinition();
String groupDefinitionUrl = LinkManager.getGroupDefinitionLink(groupDefinition.getId());
- groupDefinitionItem.setValue("<a href=\"" + groupDefinitionUrl + "\">" + groupDefinition.getName() + "</a>");
+ groupDefinitionItem
+ .setValue("<a href=\"" + groupDefinitionUrl + "\">" + groupDefinition.getName() + "</a>");
formItems.add(groupDefinitionItem);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupCreateStep.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupCreateStep.java
index f06f6ae..6b4664a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupCreateStep.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupCreateStep.java
@@ -22,22 +22,16 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.groups.wizard;
-import java.util.LinkedHashMap;
-
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.ValuesManager;
import com.smartgwt.client.widgets.form.fields.AutoFitTextAreaItem;
import com.smartgwt.client.widgets.form.fields.CheckboxItem;
-import com.smartgwt.client.widgets.form.fields.IPickTreeItem;
import com.smartgwt.client.widgets.form.fields.TextAreaItem;
import com.smartgwt.client.widgets.form.fields.TextItem;
-import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.resource.group.ResourceGroup;
-import org.rhq.enterprise.gui.coregui.client.components.form.RadioGroupWithComponentsItem;
import org.rhq.enterprise.gui.coregui.client.components.wizard.AbstractWizardStep;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypePluginTreeDataSource;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
/**
@@ -68,42 +62,14 @@ public class GroupCreateStep extends AbstractWizardStep {
CheckboxItem recursive = new CheckboxItem("recursive", "Recursive");
- LinkedHashMap<String, Canvas> options = new LinkedHashMap<String, Canvas>();
- options.put("Mixed", null);
-
- IPickTreeItem typeSelectItem = new IPickTreeItem("type", "Type");
- typeSelectItem.setDataSource(new ResourceTypePluginTreeDataSource());
- typeSelectItem.setValueField("id");
- typeSelectItem.setCanSelectParentItems(true);
- typeSelectItem.setLoadDataOnDemand(false);
- typeSelectItem.setEmptyMenuMessage("Loading...");
- typeSelectItem.setShowIcons(true);
-
- DynamicForm form2 = new LocatableDynamicForm("TypeTree");
- form2.setValuesManager(form.getValuesManager());
- form2.setFields(typeSelectItem);
- options.put("Compatible", form2);
-
- RadioGroupWithComponentsItem kind = new RadioGroupWithComponentsItem("groupType", "Group Type", options,
- form);
- kind.setValue("Mixed");
- form.setFields(name, description, location, recursive, kind);
-
+ form.setFields(name, description, location, recursive);
}
+
return form;
}
public boolean nextPage() {
- boolean valid = form.validate();
- if (valid) {
- RadioGroupWithComponentsItem kind = (RadioGroupWithComponentsItem) form.getField("groupType");
- if ("Compatible".equals(kind.getSelected())) {
- DynamicForm form2 = (DynamicForm) kind.getSelectedComponent();
- valid = (null != form2.getValue("type"));
- }
- }
-
- return valid;
+ return form.validate();
}
public String getName() {
@@ -116,16 +82,6 @@ public class GroupCreateStep extends AbstractWizardStep {
group.setLocation(form.getValueAsString("location"));
group.setRecursive(form.getValue("recursive") != null ? true : false);
- RadioGroupWithComponentsItem kind = (RadioGroupWithComponentsItem) form.getField("groupType");
- if ("Compatible".equals(kind.getSelected())) {
- DynamicForm form2 = (DynamicForm) kind.getSelectedComponent();
- if (null != form2.getValue("type")) {
- ResourceType rt = new ResourceType();
- rt.setId(Integer.parseInt(form2.getValueAsString("type")));
- group.setResourceType(rt);
- }
- }
-
return group;
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupCreateWizard.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupCreateWizard.java
index a55b334..fbbf71e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupCreateWizard.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupCreateWizard.java
@@ -28,7 +28,6 @@ import java.util.List;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.widgets.IButton;
-import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.resource.group.ResourceGroup;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.components.wizard.AbstractWizard;
@@ -67,23 +66,11 @@ public class GroupCreateWizard extends AbstractWizard {
}
public String getSubtitle() {
- return null; // TODO: Implement this method.
+ return null;
}
public List<IButton> getCustomButtons(int step) {
- return null; // TODO: Implement this method.
- }
-
- /**
- * @return only the rt id is set
- */
- public ResourceType getCompatibleGroupResourceType() {
- ResourceGroup rg = createStep.getGroup();
- ResourceType rt = null;
- if (null != rg) {
- rt = rg.getResourceType();
- }
- return rt;
+ return null;
}
public void cancel() {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupMembersStep.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupMembersStep.java
index 3a3048d..2e3e9c7 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupMembersStep.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupMembersStep.java
@@ -26,7 +26,6 @@ import java.util.HashSet;
import com.smartgwt.client.widgets.Canvas;
-import org.rhq.core.domain.resource.ResourceType;
import org.rhq.enterprise.gui.coregui.client.components.wizard.AbstractWizardStep;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.selection.ResourceSelector;
@@ -37,18 +36,14 @@ public class GroupMembersStep extends AbstractWizardStep {
private GroupCreateWizard wizard = null;
private ResourceSelector selector = null;
- private ResourceType requireType = null;
public GroupMembersStep(GroupCreateWizard wizard) {
this.wizard = wizard;
}
public Canvas getCanvas() {
- ResourceType rt = wizard.getCompatibleGroupResourceType();
- if ((selector == null) || (rt != requireType)) {
+ if (selector == null) {
selector = new ResourceSelector(getName());
- requireType = rt;
- selector.setRequireType(rt);
}
return selector;
}
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 faa406e..ed442b2 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
@@ -57,8 +57,8 @@ public class InventoryView extends LocatableHLayout implements BookmarkableView
private static final String SECTION_GROUPS = "Groups";
private static final String SECTION_RESOURCES = "Resources";
- private static final String SUBSECTION_RESOURCE_INVENTORY = "Resource Inventory";
- private static final String SUBSECTION_GROUP_INVENTORY = "Group Inventory";
+ 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";
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
index 9817819..71f1996 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
@@ -182,14 +182,13 @@ public class ResourceSearchView extends Table {
// -------- Static Utility loaders ------------
- public static ResourceSearchView getChildrenOf(int resourceId) {
- return new ResourceSearchView("ResourceSearchChildren", new Criteria("parentId", String.valueOf(resourceId)),
+ public static ResourceSearchView getChildrenOf(String locatorId, int resourceId) {
+ return new ResourceSearchView(locatorId, new Criteria("parentId", String.valueOf(resourceId)),
"Child Resources");
}
- public static ResourceSearchView getMembersOf(int groupId) {
- return new ResourceSearchView("ResourceSearchMemberOf", new Criteria("groupId", String.valueOf(groupId)),
- "Member Resources");
+ public static ResourceSearchView getMembersOf(String locatorId, int groupId) {
+ return new ResourceSearchView(locatorId, new Criteria("groupId", String.valueOf(groupId)), "Member 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 2edb50f..e80be32 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
@@ -207,7 +207,8 @@ public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceCompo
this.monitorCallTime.setCanvas(new FullHTMLPane("/rhq/resource/monitor/response-plain.xhtml?id="
+ resource.getId()));
- this.inventoryChildren.setCanvas(ResourceSearchView.getChildrenOf(resource.getId()));
+ this.inventoryChildren.setCanvas(ResourceSearchView.getChildrenOf(this.extendLocatorId("Children"), resource
+ .getId()));
this.inventoryConn.setCanvas(new PluginConfigurationEditView(this.extendLocatorId("PluginConfig"), resource));
// comment out GWT-based operation history until...
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 e9f773d..b1ad07f 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,8 +49,8 @@ public class ResourceSelector extends AbstractSelector<Resource> {
private ResourceType requireType;
- public ResourceSelector(String id) {
- super(id);
+ public ResourceSelector(String locatorId) {
+ super(locatorId);
}
public ResourceType getRequireType() {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java
index b2ec813..b9642d6 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java
@@ -18,6 +18,7 @@
*/
package org.rhq.enterprise.gui.coregui.server.gwt;
+import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.criteria.ResourceGroupCriteria;
import org.rhq.core.domain.criteria.ResourceGroupDefinitionCriteria;
import org.rhq.core.domain.resource.group.GroupDefinition;
@@ -36,34 +37,57 @@ import org.rhq.enterprise.server.util.LookupUtil;
*/
public class ResourceGroupGWTServiceImpl extends AbstractGWTServiceImpl implements ResourceGroupGWTService {
+ private static final long serialVersionUID = 1L;
+
private ResourceGroupManagerLocal groupManager = LookupUtil.getResourceGroupManager();
private GroupDefinitionManagerLocal definitionManager = LookupUtil.getGroupDefinitionManager();
public PageList<ResourceGroup> findResourceGroupsByCriteria(ResourceGroupCriteria criteria) {
- return SerialUtility.prepare(groupManager.findResourceGroupsByCriteria(getSessionSubject(), criteria),
- "ResourceGroupService.findResourceGroupsByCriteria");
+ try {
+ PageList<ResourceGroup> groups = groupManager.findResourceGroupsByCriteria(getSessionSubject(), criteria);
+ return SerialUtility.prepare(groups, "ResourceGroupService.findResourceGroupsByCriteria");
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ }
}
public PageList<ResourceGroupComposite> findResourceGroupCompositesByCriteria(ResourceGroupCriteria criteria) {
- return SerialUtility.prepare(groupManager.findResourceGroupCompositesByCriteria(getSessionSubject(), criteria),
- "ResourceGroupService.findResourceGroupCompositesByCriteria");
+ try {
+ PageList<ResourceGroupComposite> composites = groupManager.findResourceGroupCompositesByCriteria(
+ getSessionSubject(), criteria);
+ return SerialUtility.prepare(composites, "ResourceGroupService.findResourceGroupCompositesByCriteria");
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ }
}
public PageList<GroupDefinition> findGroupDefinitionsByCriteria(ResourceGroupDefinitionCriteria criteria) {
- return SerialUtility.prepare(definitionManager.findGroupDefinitionsByCriteria(getSessionSubject(), criteria),
- "ResourceGroupService.findGroupDefinitionsByCriteria");
+ try {
+ PageList<GroupDefinition> definitions = definitionManager.findGroupDefinitionsByCriteria(
+ getSessionSubject(), criteria);
+ return SerialUtility.prepare(definitions, "ResourceGroupService.findGroupDefinitionsByCriteria");
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ }
}
- public void ensureMembershipMatches(int groupId, int[] resourceIds) {
- groupManager.ensureMembershipMatches(getSessionSubject(), groupId, resourceIds);
+ public void setMembership(int groupId, int[] resourceIds, boolean setType) {
+ try {
+ groupManager.setMembership(getSessionSubject(), groupId, resourceIds, setType);
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ }
}
public ResourceGroup createResourceGroup(ResourceGroup group, int[] resourceIds) {
- group = groupManager.createResourceGroup(getSessionSubject(), group);
-
- ensureMembershipMatches(group.getId(), resourceIds);
-
- return SerialUtility.prepare(group, "ResourceGroupService.createResourceGroup");
+ try {
+ Subject user = getSessionSubject();
+ group = groupManager.createResourceGroup(user, group);
+ groupManager.setMembership(user, group.getId(), resourceIds, true);
+ return SerialUtility.prepare(group, "ResourceGroupService.createResourceGroup");
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ }
}
public void deleteResourceGroups(int[] groupIds) {
@@ -75,7 +99,19 @@ public class ResourceGroupGWTServiceImpl extends AbstractGWTServiceImpl implemen
}
public void updateResourceGroup(ResourceGroup group) {
- groupManager.updateResourceGroup(getSessionSubject(), group);
+ try {
+ groupManager.updateResourceGroup(getSessionSubject(), group);
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ }
+ }
+
+ public void updateResourceGroup(ResourceGroup group, boolean updateMembership) {
+ try {
+ groupManager.updateResourceGroup(getSessionSubject(), group, null, updateMembership);
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ }
}
public GroupDefinition createGroupDefinition(GroupDefinition groupDefinition) {
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/cluster/ClusterManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/cluster/ClusterManagerBean.java
index 10611fa..4aaf7ca 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/cluster/ClusterManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/cluster/ClusterManagerBean.java
@@ -48,7 +48,6 @@ import org.rhq.enterprise.server.authz.AuthorizationManagerLocal;
import org.rhq.enterprise.server.authz.PermissionException;
import org.rhq.enterprise.server.resource.group.ResourceGroupAlreadyExistsException;
import org.rhq.enterprise.server.resource.group.ResourceGroupManagerLocal;
-import org.rhq.enterprise.server.resource.group.ResourceGroupUpdateException;
/**
*
@@ -139,9 +138,9 @@ public class ClusterManagerBean implements ClusterManagerLocal, ClusterManagerRe
try {
// You are allowed to cause the creation of an auto cluster backing group as long as you can
// view the parent group. (That check was done above)
- resourceGroupManager.ensureMembershipMatches(subjectManager.getOverlord(), autoClusterBackingGroup
- .getId(), resourceIds);
- } catch (ResourceGroupUpdateException e) {
+ resourceGroupManager.setMembership(subjectManager.getOverlord(), autoClusterBackingGroup.getId(),
+ resourceIds, false);
+ } catch (Exception e) {
log.error("Could not add resources to group:" + e);
}
}
@@ -177,11 +176,10 @@ public class ClusterManagerBean implements ClusterManagerLocal, ClusterManagerRe
}
public ClusterFlyweight getClusterTree(Subject subject, int groupId) {
- Query query = entityManager.createQuery(
- "SELECT r.id, r.resourceType.id, r.parentResource.id, r.resourceKey, r.name, " +
- "(SELECT count(r2) FROM Resource r2 join r2.explicitGroups g2 WHERE g2.id = :groupId and r2.id = r.id) " +
- "FROM Resource r join r.implicitGroups g " +
- "WHERE g.id = :groupId");
+ Query query = entityManager
+ .createQuery("SELECT r.id, r.resourceType.id, r.parentResource.id, r.resourceKey, r.name, "
+ + "(SELECT count(r2) FROM Resource r2 join r2.explicitGroups g2 WHERE g2.id = :groupId and r2.id = r.id) "
+ + "FROM Resource r join r.implicitGroups g " + "WHERE g.id = :groupId");
query.setParameter("groupId", groupId);
List<Object[]> rs = query.getResultList();
@@ -203,7 +201,6 @@ public class ClusterManagerBean implements ClusterManagerLocal, ClusterManagerRe
}
}
-
ClusterFlyweight key = new ClusterFlyweight(groupId);
buildTree(groupId, key, explicitResources, dataMap);
@@ -211,7 +208,8 @@ public class ClusterManagerBean implements ClusterManagerLocal, ClusterManagerRe
return key;
}
- private void buildTree(int groupId, ClusterFlyweight parent, Set<Integer> parentIds, Map<Integer,List<Object[]>> data) {
+ private void buildTree(int groupId, ClusterFlyweight parent, Set<Integer> parentIds,
+ Map<Integer, List<Object[]>> data) {
for (Integer parentId : parentIds) {
@@ -219,32 +217,29 @@ public class ClusterManagerBean implements ClusterManagerLocal, ClusterManagerRe
Map<ClusterKeyFlyweight, Set<Integer>> members = new HashMap<ClusterKeyFlyweight, Set<Integer>>();
if (data.get(parentId) != null) {
- for (Object[] child : data.get(parentId)) {
- ClusterKeyFlyweight n = new ClusterKeyFlyweight((Integer)child[1], (String)child[3]);
+ for (Object[] child : data.get(parentId)) {
+ ClusterKeyFlyweight n = new ClusterKeyFlyweight((Integer) child[1], (String) child[3]);
ClusterFlyweight flyweight = children.get(n);
- Set<Integer> memberList = members.get(n);
- if (flyweight == null) {
- flyweight = new ClusterFlyweight(n);
- children.put(n, flyweight);
- memberList = new HashSet<Integer>();
- members.put(n, memberList);
+ Set<Integer> memberList = members.get(n);
+ if (flyweight == null) {
+ flyweight = new ClusterFlyweight(n);
+ children.put(n, flyweight);
+ memberList = new HashSet<Integer>();
+ members.put(n, memberList);
+ }
+ flyweight.addResource((String) child[4]);
+ memberList.add((Integer) child[0]);
}
- flyweight.addResource((String)child[4]);
- memberList.add((Integer) child[0]);
- }
}
parent.setChildren(new ArrayList<ClusterFlyweight>(children.values()));
-
for (ClusterFlyweight child : children.values()) {
buildTree(groupId, child, members.get(child.getClusterKey()), data);
}
}
}
-
-
private String getClusterKeyQuery(ClusterKey clusterKey) {
if (null == clusterKey)
return null;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java
index 04dd614..28ae218 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java
@@ -171,8 +171,19 @@ public class ResourceGroupManagerBean implements ResourceGroupManagerLocal, Reso
}
@RequiredPermission(Permission.MANAGE_INVENTORY)
- public ResourceGroup updateResourceGroup(Subject user, ResourceGroup group, RecursivityChangeType changeType)
+ public ResourceGroup updateResourceGroup(Subject subject, ResourceGroup group) throws ResourceGroupUpdateException {
+ return updateResourceGroup(subject, group, null, true);
+ }
+
+ @RequiredPermission(Permission.MANAGE_INVENTORY)
+ public ResourceGroup updateResourceGroup(Subject subject, ResourceGroup group, RecursivityChangeType changeType)
throws ResourceGroupUpdateException {
+ return updateResourceGroup(subject, group, null, true);
+ }
+
+ @RequiredPermission(Permission.MANAGE_INVENTORY)
+ public ResourceGroup updateResourceGroup(Subject user, ResourceGroup group, RecursivityChangeType changeType,
+ boolean updateMembership) throws ResourceGroupUpdateException {
int groupId = group.getId();
ResourceGroup attachedGroup = entityManager.find(ResourceGroup.class, groupId);
@@ -198,6 +209,11 @@ public class ResourceGroupManagerBean implements ResourceGroupManagerLocal, Reso
}
}
+ if (!updateMembership) {
+ group.setExplicitResources(attachedGroup.getExplicitResources());
+ group.setImplicitResources(attachedGroup.getImplicitResources());
+ }
+
group.setMtime(System.currentTimeMillis());
group.setModifiedBy(user.getName());
@@ -320,7 +336,9 @@ public class ResourceGroupManagerBean implements ResourceGroupManagerLocal, Reso
try {
operationManager.unscheduleGroupOperation(overlord, schedule.getJobId().toString(), group.getId());
} catch (UnscheduleException e) {
- log.warn("Failed to unschedule job [" + schedule + "] for a group being deleted [" + group + "]", e);
+ log
+ .warn("Failed to unschedule job [" + schedule + "] for a group being deleted [" + group + "]",
+ e);
}
}
} catch (Exception e) {
@@ -759,8 +777,8 @@ public class ResourceGroupManagerBean implements ResourceGroupManagerLocal, Reso
* to this method, we can just do simple RHQ_RESOURCE_GROUP_RES_IMP_MAP table insertions
*/
String insertImplicitQueryString = JDBCUtil.transformQueryForMultipleInParameters(
- ResourceGroup.QUERY_NATIVE_ADD_RESOURCES_TO_GROUP_IMPLICIT, "@@RESOURCE_IDS@@",
- resourceIdsToAdd.size());
+ ResourceGroup.QUERY_NATIVE_ADD_RESOURCES_TO_GROUP_IMPLICIT, "@@RESOURCE_IDS@@", resourceIdsToAdd
+ .size());
insertImplicitStatement = conn.prepareStatement(insertImplicitQueryString);
insertImplicitStatement.setInt(1, implicitRecursiveGroupId);
JDBCUtil.bindNTimes(insertImplicitStatement, ArrayUtils.unwrapCollection(resourceIdsToAdd), 2);
@@ -822,9 +840,9 @@ public class ResourceGroupManagerBean implements ResourceGroupManagerLocal, Reso
ResourceGroup group = getResourceGroupById(subject, groupId, category);
Set<Resource> res = group.getExplicitResources();
if (res != null && res.size() > 0) {
- List<Resource> resources = PersistenceUtility.getHibernateSession(entityManager)
- .createFilter(res, "where this.inventoryStatus = :inventoryStatus")
- .setParameter("inventoryStatus", InventoryStatus.COMMITTED).list();
+ List<Resource> resources = PersistenceUtility.getHibernateSession(entityManager).createFilter(res,
+ "where this.inventoryStatus = :inventoryStatus").setParameter("inventoryStatus",
+ InventoryStatus.COMMITTED).list();
return resources;
} else {
@@ -1278,7 +1296,8 @@ public class ResourceGroupManagerBean implements ResourceGroupManagerLocal, Reso
return groupIds;
}
- public void ensureMembershipMatches(Subject subject, int groupId, int[] resourceIds) {
+ public void setMembership(Subject subject, int groupId, int[] resourceIds, boolean setType)
+ throws ResourceGroupDeleteException {
//throws ResourceGroupUpdateException {
List<Integer> currentMembers = resourceManager.findExplicitResourceIdsByResourceGroup(groupId);
@@ -1293,6 +1312,11 @@ public class ResourceGroupManagerBean implements ResourceGroupManagerLocal, Reso
if (extraMembers.size() > 0) {
removeResourcesFromGroup(subject, groupId, ArrayUtils.unwrapCollection(extraMembers));
}
+
+ // As a result of the membership change ensure that the group type is set correctly.
+ if (setType) {
+ setResourceType(groupId);
+ }
}
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@@ -1402,11 +1426,6 @@ public class ResourceGroupManagerBean implements ResourceGroupManagerLocal, Reso
: RecursivityChangeType.RemovedRecursion);
}
- @RequiredPermission(Permission.MANAGE_INVENTORY)
- public ResourceGroup updateResourceGroup(Subject subject, ResourceGroup group) throws ResourceGroupUpdateException {
- return updateResourceGroup(subject, group, null);
- }
-
@SuppressWarnings("unchecked")
public PageList<ResourceGroup> findResourceGroupsByCriteria(Subject subject, ResourceGroupCriteria criteria) {
CriteriaQueryGenerator generator = new CriteriaQueryGenerator(subject, criteria);
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerLocal.java
index 2919879..45f7cc4 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerLocal.java
@@ -42,9 +42,6 @@ import org.rhq.core.domain.util.PageList;
@Local
public interface ResourceGroupManagerLocal {
- ResourceGroup updateResourceGroup(Subject user, ResourceGroup group, RecursivityChangeType changeType)
- throws ResourceGroupAlreadyExistsException, ResourceGroupUpdateException;
-
ResourceGroup getResourceGroupById(Subject user, int id, GroupCategory category)
throws ResourceGroupNotFoundException;
@@ -108,10 +105,30 @@ public interface ResourceGroupManagerLocal {
List<Integer> findDeletedResourceGroupIds(int[] groupIds);
- void ensureMembershipMatches(Subject subject, int groupId, int[] resourceIds) throws ResourceGroupUpdateException;
+ /**
+ * This method ensures that the explicit group membership is set to the specified resources. Members
+ * will be added or removed as necessary. Make sure you pass the correct value for the <setType>
+ * parameter.
+ *
+ * @param subject
+ * @param groupId
+ * @param resourceIds
+ * @param setType Set to false if the specified resourceIds will not alter the group type (compatible or
+ * mixed). Set true to have the group type (re)set automatically, based on the new group membership.
+ * @throws ResourceGroupUpdateException
+ * @throws ResourceGroupDeleteException
+ */
+ void setMembership(Subject subject, int groupId, int[] resourceIds, boolean setType)
+ throws ResourceGroupUpdateException, ResourceGroupDeleteException;
void uninventoryMembers(Subject subject, int groupId);
+ ResourceGroup updateResourceGroup(Subject user, ResourceGroup group, RecursivityChangeType changeType)
+ throws ResourceGroupAlreadyExistsException, ResourceGroupUpdateException;
+
+ ResourceGroup updateResourceGroup(Subject user, ResourceGroup group, RecursivityChangeType changeType,
+ boolean updateMembership) throws ResourceGroupAlreadyExistsException, ResourceGroupUpdateException;
+
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//
// The following are shared with the Remote Interface
@@ -141,5 +158,4 @@ public interface ResourceGroupManagerLocal {
ResourceGroup updateResourceGroup(Subject subject, ResourceGroup group);
PageList<ResourceGroup> findResourceGroupsByCriteria(Subject subject, ResourceGroupCriteria criteria);
-
}
\ No newline at end of file
13 years, 8 months