modules/core/client-api/src/main/java/org/rhq/core/clientapi/descriptor/PluginTransformer.java | 27 modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceCriteria.java | 7 modules/core/domain/src/main/java/org/rhq/core/domain/resource/ResourceAncestryFormat.java | 47 modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java | 36 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/Footer.java | 56 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java | 10 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java | 29 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletConfigurationDataSource.java | 60 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletDataSource.java | 15 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java | 3 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java | 140 - modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/GroupConfigurationEditor.java | 19 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/lookup/ResourceLookupComboBoxItem.java | 8 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTabSet.java | 27 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java | 35 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tagging/TagEditorView.java | 255 +- modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/wizard/WizardView.java | 1 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/AutoRefreshPortlet.java | 6 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/AutoRefreshPortletUtil.java | 72 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java | 15 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java | 34 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet.java | 42 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet3.java | 38 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupBundleDeploymentsPortlet.java | 35 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupEventsPortlet.java | 43 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupMetricsPortlet.java | 46 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOobsPortlet.java | 37 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOperationsPortlet.java | 41 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupPkgHistoryPortlet.java | 36 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java | 33 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/resource/FavoriteResourcesPortlet.java | 33 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/RecentAlertsPortlet.java | 34 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedResourcesPortlet.java | 33 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java | 59 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java | 46 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceAlertsPortlet.java | 37 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceMetricsPortlet.java | 4 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceOperationsPortlet.java | 4 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/summary/InventorySummaryPortlet.java | 32 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/footer/FavoritesButton.java | 15 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGWTService.java | 2 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/AbstractTwoLevelTabSetView.java | 69 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/AbstractOperationHistoryListView.java | 17 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDatasource.java | 17 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/CustomResourceGroupTreeGrid.java | 23 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupContextMenu.java | 4 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeContextMenu.java | 7 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeView.java | 182 + modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/configuration/HistoryGroupResourceConfigurationMembers.java | 15 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/HistoryGroupPluginConfigurationMembers.java | 15 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsDetailView.java | 14 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsView.java | 15 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupMemberResourceOperationHistoryListView.java | 14 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/AncestryUtil.java | 84 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceCompositeDataSource.java | 2 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceCompositeSearchView.java | 8 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java | 25 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java | 3 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTitleBar.java | 22 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java | 42 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/AbstractConfigurationHistoryDataSource.java | 14 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsDataSource.java | 33 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsView.java | 187 + modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/AlertDefinitionReportView.java | 14 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestConfigurationFactory.java | 2 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/GwtRelativeDurationConverter.java | 8 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageBar.java | 66 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenterView.java | 55 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/filter/CacheControlFilter.java | 76 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ObjectFilter.java | 3 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java | 10 modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties | 20 modules/enterprise/gui/coregui/src/main/webapp/WEB-INF/web.xml | 9 modules/enterprise/server/ear/src/main/resources/alert-email-template.txt | 47 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertManagerBean.java | 43 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/jaxb/WebServiceMapAdapter.java | 51 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java | 145 + modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerLocal.java | 4 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerRemote.java | 22 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java | 23 modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/HttpdAddressUtility.java | 3 modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerOperationsDelegate.java | 1056 ++++------ modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerPluginConfigurationProperties.java | 4 modules/plugins/jboss-as-5/src/main/resources/META-INF/rhq-plugin.xml | 12 modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseDiscovery.java | 146 - modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java | 157 + modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml | 28 modules/plugins/rhq-agent/src/main/resources/META-INF/rhq-plugin.xml | 2 88 files changed, 2448 insertions(+), 1922 deletions(-)
New commits: commit bb592ab259599fcb931b681ec083cce7ed492b9f Merge: 80b2237 7a161e2 Author: Heiko W. Rupp hwr@redhat.com Date: Tue Mar 29 17:30:04 2011 +0200
Merge branch 'master' into as7plugin
commit 80b2237cc9bb9fb01cd04c30dd3e13ee8f1e9244 Author: Heiko W. Rupp hwr@redhat.com Date: Tue Mar 29 13:36:38 2011 +0200
Rename class to better reflect its purpose.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseDiscovery.java deleted file mode 100644 index 7c55233..0000000 --- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseDiscovery.java +++ /dev/null @@ -1,157 +0,0 @@ -package org.rhq.modules.plugins.jbossas7; - -import java.io.File; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.mc4j.ems.connection.support.metadata.LocalVMTypeDescriptor; - -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.pluginapi.event.log.LogFileEventResourceComponentHelper; -import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails; -import org.rhq.core.pluginapi.inventory.ProcessScanResult; -import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent; -import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext; -import org.rhq.plugins.jmx.JMXDiscoveryComponent; - - -/** - * Discovery class - */ -public class BaseDiscovery implements ResourceDiscoveryComponent - -{ - - static final String DJBOSS_SERVER_BASE_DIR = "-Djboss.server.base.dir="; - static final String DORG_JBOSS_BOOT_LOG_FILE = "-Dorg.jboss.boot.log.file="; - private final Log log = LogFactory.getLog(this.getClass()); - - /** - * Run the auto-discovery - */ - public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext discoveryContext) throws Exception { - Set<DiscoveredResourceDetails> discoveredResources = new HashSet<DiscoveredResourceDetails>(); - - - List<ProcessScanResult> scans = discoveryContext.getAutoDiscoveredProcesses(); - - for (ProcessScanResult psr : scans) { - - Configuration config = discoveryContext.getDefaultPluginConfiguration(); - // IF SE, then look at domain/configuration/host.xml <management interface="default" port="9990 - // for management port - String[] commandLine = psr.getProcessInfo().getCommandLine(); - String serverNameFull; - String serverName; - String psName = psr.getProcessScan().getName(); - if (psName.equals("ProcessManager")) { - serverNameFull = "ProcessManager"; - serverName = "ProcessManager"; - } else if (psName.equals("ASManager")) { - serverName = "ASManager"; - serverNameFull = "ASManager"; - } else if (psName.equals("HostController")) { - serverName = "HostController"; - serverNameFull = "HostController"; - } else { - serverNameFull = getBaseDirFromCommandLine(commandLine); - if (serverNameFull==null || serverNameFull.isEmpty()) { - // Try to obtain the server name - // -Dorg.jboss.boot.log.file=domain/servers/server-one/log/boot.log - // This is a hack until I know a better way to do so. - String tmp = getLogFileFromCommandLine(commandLine); - int i = tmp.indexOf("servers/"); - tmp = tmp.substring( i + 8); - tmp = tmp.substring(0,tmp.indexOf("/")); - serverNameFull = tmp; - } - serverName = serverNameFull.substring(serverNameFull.lastIndexOf("/")+1); - if (serverName.isEmpty()) - serverName = serverNameFull; - - } - String logFile = getLogFileFromCommandLine(commandLine); - initLogEventSourcesConfigProp(logFile,config); - String javaClazz = psr.getProcessInfo().getName(); - - - /* - * We'll connect to the discovered VM on the local host, so set the jmx connection - * properties accordingly. This may only work on JDK6+, but then JDK5 is deprecated - * anyway. - */ -// config.put(new PropertySimple(JMXDiscoveryComponent.COMMAND_LINE_CONFIG_PROPERTY, -// javaClazz)); - config.put(new PropertySimple(JMXDiscoveryComponent.CONNECTION_TYPE, - LocalVMTypeDescriptor.class.getName())); - - // TODO vmid will change when the detected server is bounced - how do we follow this? - config.put(new PropertySimple(JMXDiscoveryComponent.VMID_CONFIG_PROPERTY,psr.getProcessInfo().getPid())); - - - DiscoveredResourceDetails detail = new DiscoveredResourceDetails( - discoveryContext.getResourceType(), // ResourceType - serverNameFull, // key TODO distinguish per domain? - serverName, // Name - null, // TODO real version ? - "TODO", // Description - config, - psr.getProcessInfo() - ); - - - // Add to return values - discoveredResources.add(detail); - log.info("Discovered new ... " + discoveryContext.getResourceType() + ", " + serverNameFull); - } - - return discoveredResources; - - } - - String getBaseDirFromCommandLine(String[] commandLine) { - for (String line: commandLine) { - if (line.startsWith(DJBOSS_SERVER_BASE_DIR)) - return line.substring(DJBOSS_SERVER_BASE_DIR.length()); - } - return ""; - } - -//-Dorg.jboss.boot.log.file=/devel/jbas7/jboss-as/build/target/jboss-7.0.0.Alpha2/domain/log/server-manager/boot.log -//-Dlogging.configuration=file:/devel/jbas7/jboss-as/build/target/jboss-7.0.0.Alpha2/domain/configuration/logging.properties - - String getLogFileFromCommandLine(String[] commandLine) { - - for (String line: commandLine) { - if (line.startsWith(DORG_JBOSS_BOOT_LOG_FILE)) - return line.substring(DORG_JBOSS_BOOT_LOG_FILE.length()); - } - return ""; - } - - private void initLogEventSourcesConfigProp(String fileName, Configuration pluginConfiguration) { - - PropertyList logEventSources = pluginConfiguration - .getList(LogFileEventResourceComponentHelper.LOG_EVENT_SOURCES_CONFIG_PROP); - - if (logEventSources==null) - return; - - File serverLogFile = new File(fileName); - - if (serverLogFile.exists() && !serverLogFile.isDirectory()) { - PropertyMap serverLogEventSource = new PropertyMap("logEventSource"); - serverLogEventSource.put(new PropertySimple( - LogFileEventResourceComponentHelper.LogEventSourcePropertyNames.LOG_FILE_PATH, serverLogFile)); - serverLogEventSource.put(new PropertySimple( - LogFileEventResourceComponentHelper.LogEventSourcePropertyNames.ENABLED, Boolean.FALSE)); - logEventSources.add(serverLogEventSource); - } - } - -} diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java new file mode 100644 index 0000000..c38e297 --- /dev/null +++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java @@ -0,0 +1,157 @@ +package org.rhq.modules.plugins.jbossas7; + +import java.io.File; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.mc4j.ems.connection.support.metadata.LocalVMTypeDescriptor; + +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.pluginapi.event.log.LogFileEventResourceComponentHelper; +import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails; +import org.rhq.core.pluginapi.inventory.ProcessScanResult; +import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent; +import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext; +import org.rhq.plugins.jmx.JMXDiscoveryComponent; + + +/** + * Discovery class + */ +public class BaseProcessDiscovery implements ResourceDiscoveryComponent + +{ + + static final String DJBOSS_SERVER_BASE_DIR = "-Djboss.server.base.dir="; + static final String DORG_JBOSS_BOOT_LOG_FILE = "-Dorg.jboss.boot.log.file="; + private final Log log = LogFactory.getLog(this.getClass()); + + /** + * Run the auto-discovery + */ + public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext discoveryContext) throws Exception { + Set<DiscoveredResourceDetails> discoveredResources = new HashSet<DiscoveredResourceDetails>(); + + + List<ProcessScanResult> scans = discoveryContext.getAutoDiscoveredProcesses(); + + for (ProcessScanResult psr : scans) { + + Configuration config = discoveryContext.getDefaultPluginConfiguration(); + // IF SE, then look at domain/configuration/host.xml <management interface="default" port="9990 + // for management port + String[] commandLine = psr.getProcessInfo().getCommandLine(); + String serverNameFull; + String serverName; + String psName = psr.getProcessScan().getName(); + if (psName.equals("ProcessManager")) { + serverNameFull = "ProcessManager"; + serverName = "ProcessManager"; + } else if (psName.equals("ASManager")) { + serverName = "ASManager"; + serverNameFull = "ASManager"; + } else if (psName.equals("HostController")) { + serverName = "HostController"; + serverNameFull = "HostController"; + } else { + serverNameFull = getBaseDirFromCommandLine(commandLine); + if (serverNameFull==null || serverNameFull.isEmpty()) { + // Try to obtain the server name + // -Dorg.jboss.boot.log.file=domain/servers/server-one/log/boot.log + // This is a hack until I know a better way to do so. + String tmp = getLogFileFromCommandLine(commandLine); + int i = tmp.indexOf("servers/"); + tmp = tmp.substring( i + 8); + tmp = tmp.substring(0,tmp.indexOf("/")); + serverNameFull = tmp; + } + serverName = serverNameFull.substring(serverNameFull.lastIndexOf("/")+1); + if (serverName.isEmpty()) + serverName = serverNameFull; + + } + String logFile = getLogFileFromCommandLine(commandLine); + initLogEventSourcesConfigProp(logFile,config); + String javaClazz = psr.getProcessInfo().getName(); + + + /* + * We'll connect to the discovered VM on the local host, so set the jmx connection + * properties accordingly. This may only work on JDK6+, but then JDK5 is deprecated + * anyway. + */ +// config.put(new PropertySimple(JMXDiscoveryComponent.COMMAND_LINE_CONFIG_PROPERTY, +// javaClazz)); + config.put(new PropertySimple(JMXDiscoveryComponent.CONNECTION_TYPE, + LocalVMTypeDescriptor.class.getName())); + + // TODO vmid will change when the detected server is bounced - how do we follow this? + config.put(new PropertySimple(JMXDiscoveryComponent.VMID_CONFIG_PROPERTY,psr.getProcessInfo().getPid())); + + + DiscoveredResourceDetails detail = new DiscoveredResourceDetails( + discoveryContext.getResourceType(), // ResourceType + serverNameFull, // key TODO distinguish per domain? + serverName, // Name + null, // TODO real version ? + "TODO", // Description + config, + psr.getProcessInfo() + ); + + + // Add to return values + discoveredResources.add(detail); + log.info("Discovered new ... " + discoveryContext.getResourceType() + ", " + serverNameFull); + } + + return discoveredResources; + + } + + String getBaseDirFromCommandLine(String[] commandLine) { + for (String line: commandLine) { + if (line.startsWith(DJBOSS_SERVER_BASE_DIR)) + return line.substring(DJBOSS_SERVER_BASE_DIR.length()); + } + return ""; + } + +//-Dorg.jboss.boot.log.file=/devel/jbas7/jboss-as/build/target/jboss-7.0.0.Alpha2/domain/log/server-manager/boot.log +//-Dlogging.configuration=file:/devel/jbas7/jboss-as/build/target/jboss-7.0.0.Alpha2/domain/configuration/logging.properties + + String getLogFileFromCommandLine(String[] commandLine) { + + for (String line: commandLine) { + if (line.startsWith(DORG_JBOSS_BOOT_LOG_FILE)) + return line.substring(DORG_JBOSS_BOOT_LOG_FILE.length()); + } + return ""; + } + + private void initLogEventSourcesConfigProp(String fileName, Configuration pluginConfiguration) { + + PropertyList logEventSources = pluginConfiguration + .getList(LogFileEventResourceComponentHelper.LOG_EVENT_SOURCES_CONFIG_PROP); + + if (logEventSources==null) + return; + + File serverLogFile = new File(fileName); + + if (serverLogFile.exists() && !serverLogFile.isDirectory()) { + PropertyMap serverLogEventSource = new PropertyMap("logEventSource"); + serverLogEventSource.put(new PropertySimple( + LogFileEventResourceComponentHelper.LogEventSourcePropertyNames.LOG_FILE_PATH, serverLogFile)); + serverLogEventSource.put(new PropertySimple( + LogFileEventResourceComponentHelper.LogEventSourcePropertyNames.ENABLED, Boolean.FALSE)); + logEventSources.add(serverLogEventSource); + } + } + +} diff --git a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml index 2825e10..ee6b21f 100644 --- a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml +++ b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml @@ -59,7 +59,7 @@ -->
<server name="ProcessController" - discovery="BaseDiscovery" + discovery="BaseProcessDiscovery" class="BaseComponent" description="Reaper process for other AS7 servicees" > @@ -80,6 +80,28 @@
</server> + <server name="HostController" + discovery="BaseProcessDiscovery" + class="BaseComponent" + description="Domain controller delegate for this host" + > + + <plugin-configuration> + <c:simple-property name="hostname" default="localhost" required="true"/> + <c:simple-property name="port" default="9990" type="integer" required="true"/> + + &logSources; + </plugin-configuration> + + <process-scan name="ProcessManager" query="process|basename|match=^java.*,arg|org.jboss.as.host-controller|match=.*"/> + + + <operation name="dummyOperation"> + <!-- TODO supply parameters and return values --> + </operation> + + + </server>
<server name="Domain" discovery="DomainDiscovery" @@ -129,7 +151,7 @@ </server>
<server name="JBossAS7-Standalone" - discovery="BaseDiscovery" + discovery="BaseProcessDiscovery" class="BaseComponent" >
@@ -165,7 +187,7 @@ </server>
<server name="JBossAS-Managed" - discovery="BaseDiscovery" + discovery="BaseProcessDiscovery" class="BaseComponent" > <plugin-configuration>
commit 800fe24b2eff29a7922a9b9a4ab1a309d352a077 Author: Heiko W. Rupp hwr@redhat.com Date: Tue Mar 29 13:24:29 2011 +0200
Better discover managed AS servers - get their name from the log file for now.
TODO: should we better query the DC, as this also knows the AS that are not auto-started.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseDiscovery.java index 96737dd..7c55233 100644 --- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseDiscovery.java +++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseDiscovery.java @@ -55,10 +55,21 @@ public class BaseDiscovery implements ResourceDiscoveryComponent } else if (psName.equals("ASManager")) { serverName = "ASManager"; serverNameFull = "ASManager"; + } else if (psName.equals("HostController")) { + serverName = "HostController"; + serverNameFull = "HostController"; } else { serverNameFull = getBaseDirFromCommandLine(commandLine); - if (serverNameFull==null || serverNameFull.isEmpty()) - serverNameFull="JBossAS7"; + if (serverNameFull==null || serverNameFull.isEmpty()) { + // Try to obtain the server name + // -Dorg.jboss.boot.log.file=domain/servers/server-one/log/boot.log + // This is a hack until I know a better way to do so. + String tmp = getLogFileFromCommandLine(commandLine); + int i = tmp.indexOf("servers/"); + tmp = tmp.substring( i + 8); + tmp = tmp.substring(0,tmp.indexOf("/")); + serverNameFull = tmp; + } serverName = serverNameFull.substring(serverNameFull.lastIndexOf("/")+1); if (serverName.isEmpty()) serverName = serverNameFull;
commit 7a161e217c55ec77420303be7a4db2c84ec359d7 Author: John Mazzitelli mazz@redhat.com Date: Mon Mar 28 18:21:42 2011 -0400
add a refresh button on the right so a user can call CoreGUI.refresh(). this should help refresh left-hand trees when they go out of sync with changes to the inventory
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 62c3509..5a9d3fc 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 @@ -87,11 +87,35 @@ public class Footer extends LocatableHLayout {
addMember(getMessageCenterButton());
+ addMember(getRefreshButton()); + addMember(createHSpacer(0));
alertsMessage.schedule(60000); }
+ private LocatableVLayout getRefreshButton() { + LocatableVLayout layout = new LocatableVLayout(extendLocatorId("refreshLayout")); + layout.setHeight100(); + layout.setAlign(Alignment.CENTER); + layout.setAutoWidth(); + + LocatableIButton button = new LocatableIButton(extendLocatorId("refreshButton"), ""); + button.setAlign(Alignment.CENTER); + button.setAutoFit(true); + button.setIcon("[SKIN]/actions/refresh.png"); + button.setPrompt(CoreGUI.getMessages().common_button_refresh()); + button.addClickHandler(new ClickHandler() { + @Override + public void onClick(ClickEvent event) { + CoreGUI.refresh(); + } + }); + + layout.addMember(button); + return layout; + } + private LocatableVLayout getMessageCenterButton() { LocatableVLayout layout = new LocatableVLayout(extendLocatorId("layout")); layout.setMembersMargin(5);
commit 1d30fe194971feb08733847e7b2425a925b749cc Author: John Mazzitelli mazz@redhat.com Date: Mon Mar 28 18:13:19 2011 -0400
- shrink the global alerts indicator to just be the icon - the alert flag hover text tells you the count and reminds the user they can click the icon to get the recent alerts report - when there are no recent alerts, the flag is grey - the alert flag is moved to the right where the rest of the components are - the message bar now has 100% width allowing for the message to stretch if the browser is maximized
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 2f31bb8..62c3509 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 @@ -28,6 +28,7 @@ import com.smartgwt.client.widgets.layout.HLayout; import com.smartgwt.client.widgets.layout.VLayout;
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.criteria.Criteria.Restriction; import org.rhq.core.domain.util.PageList; @@ -73,10 +74,10 @@ public class Footer extends LocatableHLayout { // leave space for the RPC Activity Spinner addMember(createHSpacer(16));
- addMember(alertsMessage); - addMember(messageBar);
+ addMember(alertsMessage); + VLayout favoritesLayout = new VLayout(); favoritesLayout.setHeight100(); favoritesLayout.setAutoWidth(); @@ -153,12 +154,12 @@ public class Footer extends LocatableHLayout { public AlertsMessage(String locatorId) { super(locatorId); setHeight100(); + setWidth(25); setPadding(5); - - setIcon("subsystems/alert/Alert_LOW_16.png"); + setHoverWidth(200); setIconSize(16); setWrap(false); - + changeIcon(0); addClickHandler(new ClickHandler() { public void onClick(ClickEvent clickEvent) { History.newItem(ReportTopView.VIEW_ID.getName() + "/" + ReportTopView.SECTION_SUBSYSTEMS_VIEW_ID @@ -167,6 +168,19 @@ public class Footer extends LocatableHLayout { }); }
+ private void changeIcon(int alertCount) { + if (alertCount == 0) { + setPrompt(MSG.view_core_noRecentAlerts()); + setContents(imgHTML("subsystems/alert/Alerts_16.png", 16, 16)); + } else { + setPrompt(MSG.view_core_recentAlerts(String.valueOf(alertCount))); + String link = '#' + ReportTopView.VIEW_ID.getName() + "/" + ReportTopView.SECTION_SUBSYSTEMS_VIEW_ID + + "/" + AlertHistoryView.SUBSYSTEM_VIEW_ID; + setContents("<a href="" + link + "">" + imgHTML(ImageManager.getAlertIcon(AlertPriority.HIGH)) + + "</a>"); + } + } + public void refreshLoggedIn() { AlertCriteria alertCriteria = new AlertCriteria(); alertCriteria.addFilterStartTime(System.currentTimeMillis() - (1000L * 60 * 60 * 8)); // last 8 hrs @@ -179,13 +193,7 @@ public class Footer extends LocatableHLayout { }
public void onSuccess(PageList<Alert> result) { - if (result.getTotalSize() == 0) { - setContents(MSG.view_core_recentAlerts("0")); - setIcon("subsystems/alert/Alert_LOW_16.png"); - } else { - setContents(MSG.view_core_recentAlerts(String.valueOf(result.getTotalSize()))); - setIcon("subsystems/alert/Alert_HIGH_16.png"); - } + changeIcon(result.getTotalSize()); } }); } 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 f000569..1b27eee 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 @@ -62,7 +62,7 @@ public class MessageBar extends LocatableHLayout implements MessageCenter.Messag
label = new LocatableLabel(extendLocatorId("Label")); label.setAlign(Alignment.CENTER); - label.setWidth("600px"); + label.setWidth100(); label.setHeight("30px"); label.setCanSelectText(true); addMember(label); diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties index 35ff92d..695bd9d 100644 --- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties +++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties @@ -2057,7 +2057,8 @@ view_aboutBox_version = Version: view_core_error_1 = New Alerts lookup failed #view_core_loggedInAs = Logged in as {0} view_core_loggedOut = Logged out -view_core_recentAlerts = [{0}] recent alerts +view_core_recentAlerts = There are [{0}] recent alerts - click the icon to go to the recent alerts report +view_core_noRecentAlerts = There are no recent alerts to report view_core_uncaught = Globally uncaught exception
# Login
commit 48930bae6ee5f95142f76aafd9da7f684f8c9a43 Merge: c45a4ed 769949f Author: Filip Drabek fdrabek@dhcp-lab-136.englab.brq.redhat.com Date: Mon Mar 28 23:29:48 2011 +0200
Merge branch 'master' of ssh://git.fedorahosted.org/git/rhq/rhq
commit c45a4ed71306601af814364822149e20277bb4e7 Author: Filip Drabek fdrabek@dhcp-lab-136.englab.brq.redhat.com Date: Mon Mar 28 23:28:26 2011 +0200
JAXB adapter for Map<Integer,String>
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/jaxb/WebServiceMapAdapter.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/jaxb/WebServiceMapAdapter.java new file mode 100644 index 0000000..004576e --- /dev/null +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/jaxb/WebServiceMapAdapter.java @@ -0,0 +1,51 @@ +package org.rhq.enterprise.server.jaxb; + +import java.util.HashMap; +import java.util.Map; + +import javax.jws.WebResult; +import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.adapters.XmlAdapter; + +import org.rhq.enterprise.server.system.ServerVersion; + +/** See the javadoc for the XmlAdapter itself for a more complete explanation, but simply + * put the adapter maps types that JAXB has difficulty serializing(Ex. Map<Integer,String>) + * to java types that JAXB can actually serialize. From a JAXB perspective think of the + * problematic types as opaque to JAXB and the map to type in a marshal as the serializable + * type. + * + * @author Simeon Pinder + * @author Filip Drabek + * + */ +@XmlType(namespace = ServerVersion.namespace) +public class WebServiceMapAdapter extends XmlAdapter<Object[], Map<Integer, String>> { + + @WebResult(targetNamespace = ServerVersion.namespace) + public Object[] marshal(Map<Integer, String> opaque) throws Exception { + Object[] bag = null; + if (opaque != null) { + int i = 0; + bag = new Object[2 * opaque.size()]; + for (Map.Entry<Integer, String> mapEntry : opaque.entrySet()) { + bag[i++] = mapEntry.getKey(); + bag[i++] = mapEntry.getValue(); + } + } else { + bag = new Object[0]; + } + return bag; + } + + @WebResult(targetNamespace = ServerVersion.namespace) + public Map<Integer, String> unmarshal(Object[] marshallable) throws Exception { + Map<Integer, String> map = new HashMap<Integer, String>(); + if (marshallable != null) { + for (int i = 0; i < marshallable.length; i += 2) { + map.put((Integer) marshallable[i], (String) marshallable[i + 1]); + } + } + return map; + } +} diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerRemote.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerRemote.java index 9d1c269..0fcc193 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerRemote.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerRemote.java @@ -35,6 +35,7 @@ import org.rhq.core.domain.resource.Resource; import org.rhq.core.domain.resource.ResourceAncestryFormat; import org.rhq.core.domain.util.PageControl; import org.rhq.core.domain.util.PageList; +import org.rhq.enterprise.server.jaxb.WebServiceMapAdapter; import org.rhq.enterprise.server.jaxb.adapter.ResourceListAdapter; import org.rhq.enterprise.server.system.ServerVersion;
@@ -153,6 +154,7 @@ public interface ResourceManagerRemote { * @return A Map of ResourceIds to FormattedAncestryStrings, one entry for each unique, valid, resourceId passed in. */ @WebMethod + @XmlJavaTypeAdapter(value = WebServiceMapAdapter.class) Map<Integer, String> getResourcesAncestry( // @WebParam(name = "subject") Subject subject, // @WebParam(name = "resourceIds") Integer[] resourceIds, //
commit 769949fb28b0beeeba6c076130708c8a534cce88 Author: John Mazzitelli mazz@redhat.com Date: Mon Mar 28 15:00:25 2011 -0400
in our GWT UI, the alert and event severity filters are represented with a drop down selection menu containing one checkbox for each severity enum (alert: hi, med, lo; event: debug, info, warn, et...). If you don't select any severity (i.e. all the checkboxes are unchecked), we used to assume this means there is no filtering to be performed and the query returns everything.
However, because the UI renders these in individual checkboxes, that behavior doesn't really make sense and will confuse the user. Because, if the user doesn't select any severities, it seems as though the user is asking it to show nothing - since no event or alert will match the selected severities (and there are NO selected severities). So to make the query results/UI more sensical, if the user de-selects all severity check boxes, the table will show 0 rows.
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 f776d56..3e51b24 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 @@ -204,6 +204,13 @@ public class AlertDataSource extends RPCDataSource<Alert, AlertCriteria> {
@Override protected void executeFetch(final DSRequest request, final DSResponse response, final AlertCriteria criteria) { + if (criteria == null) { + // the user selected no severities in the filter - it makes sense from the UI perspective to show 0 rows + response.setTotalRows(0); + processResponse(request.getRequestId(), response); + return; + } + final long start = System.currentTimeMillis();
this.alertService.findAlertsByCriteria(criteria, new AsyncCallback<PageList<Alert>>() { @@ -272,10 +279,16 @@ public class AlertDataSource extends RPCDataSource<Alert, AlertCriteria> {
@Override protected AlertCriteria getFetchCriteria(DSRequest request) { + AlertPriority[] severitiesFilter = getArrayFilter(request, "severities", AlertPriority.class); + + if (severitiesFilter == null || severitiesFilter.length == 0) { + return null; // user didn't select any severities - return null to indicate no data should be displayed + } + AlertCriteria criteria = new AlertCriteria(); criteria.setPageControl(getPageControl(request));
- criteria.addFilterPriorities(getArrayFilter(request, "severities", AlertPriority.class)); + criteria.addFilterPriorities(severitiesFilter); criteria.addFilterEntityContext(entityContext); criteria.fetchConditionLogs(true);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDatasource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDatasource.java index e7f93e4..490ee4f 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDatasource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDatasource.java @@ -109,6 +109,13 @@ public class EventCompositeDatasource extends RPCDataSource<EventComposite, Even
@Override protected void executeFetch(final DSRequest request, final DSResponse response, final EventCriteria criteria) { + if (criteria == null) { + // the user selected no severities in the filter - it makes sense from the UI perspective to show 0 rows + response.setTotalRows(0); + processResponse(request.getRequestId(), response); + return; + } + GWTServiceLookup.getEventService().findEventCompositesByCriteria(criteria, new AsyncCallback<PageList<EventComposite>>() { public void onFailure(Throwable caught) { @@ -128,6 +135,11 @@ public class EventCompositeDatasource extends RPCDataSource<EventComposite, Even
@Override protected EventCriteria getFetchCriteria(final DSRequest request) { + EventSeverity[] severities = getArrayFilter(request, "severities", EventSeverity.class); + if (severities == null || severities.length == 0) { + return null; // user didn't select any severities - return null to indicate no data should be displayed + } + EventCriteria criteria = new EventCriteria();
PageControl pageControl = getPageControl(request); @@ -144,10 +156,7 @@ public class EventCompositeDatasource extends RPCDataSource<EventComposite, Even criteria.addFilterSourceName((String) criteriaMap.get("source")); criteria.addFilterDetail((String) criteriaMap.get("details"));
- if (criteriaMap.get("severities") != null) { - EventSeverity[] severities = getArrayFilter(request, "severities", EventSeverity.class); - criteria.addFilterSeverities(severities); - } + criteria.addFilterSeverities(severities);
criteria.addFilterEntityContext(entityContext);
commit cd758dcbc78fea04ebda2d3563a3b283b630b88e Author: Ian Springer ian.springer@redhat.com Date: Mon Mar 28 14:27:18 2011 -0400
fix editing of group config props via modal member value editor (https://bugzilla.redhat.com/show_bug.cgi?id=690483)
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 449e9c3..d991515 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 @@ -1316,17 +1316,20 @@ public class ConfigurationEditor extends LocatableVLayout { List<Validator> validators = buildValidators(propertyDefinitionSimple, propertySimple); valueItem.setValidators(validators.toArray(new Validator[validators.size()]));
- valueItem.addChangedHandler(new ChangedHandler() { - public void onChanged(ChangedEvent changedEvent) { - updatePropertySimpleValue(changedEvent.getValue(), propertySimple, propertyDefinitionSimple); - // Only fire a prop value change event if the prop's a top-level simple or a simple within a - // top-level map. - if (fireEventOnPropertyValueChange(propertyDefinitionSimple, propertySimple)) { - boolean isValid = changedEvent.getItem().validate(); - firePropertyChangedEvent(propertySimple, propertyDefinitionSimple, isValid); + if ((propertySimple.getConfiguration() != null) || (propertySimple.getParentMap() != null) || + (propertySimple.getParentList() != null)) { + valueItem.addChangedHandler(new ChangedHandler() { + public void onChanged(ChangedEvent changedEvent) { + updatePropertySimpleValue(changedEvent.getValue(), propertySimple, propertyDefinitionSimple); + // Only fire a prop value change event if the prop's a top-level simple or a simple within a + // top-level map. + if (fireEventOnPropertyValueChange(propertyDefinitionSimple, propertySimple)) { + boolean isValid = changedEvent.getItem().validate(); + firePropertyChangedEvent(propertySimple, propertyDefinitionSimple, isValid); + } } - } - }); + }); + } }
// for more robust and repeatable item locators (not positional) assign a name and title @@ -1356,9 +1359,9 @@ public class ConfigurationEditor extends LocatableVLayout {
protected boolean fireEventOnPropertyValueChange(PropertyDefinitionSimple propertyDefinitionSimple, PropertySimple propertySimple) { - PropertyDefinitionMap parentPropertyMapDefinition = propertyDefinitionSimple.getParentPropertyMapDefinition(); - return propertyDefinitionSimple.getConfigurationDefinition() != null - || (parentPropertyMapDefinition != null && parentPropertyMapDefinition.getConfigurationDefinition() != null); + PropertyMap parentMap = propertySimple.getParentMap(); + return propertySimple.getConfiguration() != null + || (parentMap != null && parentMap.getConfiguration() != null); }
protected void updatePropertySimpleValue(Object value, PropertySimple propertySimple, diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/GroupConfigurationEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/GroupConfigurationEditor.java index 4c4a29f..eafbd15 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/GroupConfigurationEditor.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/GroupConfigurationEditor.java @@ -250,7 +250,7 @@ public class GroupConfigurationEditor extends ConfigurationEditor { setAllValuesToItem.setAlign(Alignment.RIGHT); setAllItems.add(setAllValuesToItem);
- PropertySimple masterPropertySimple = new PropertySimple(aggregatePropertySimple.getName(), null); + PropertySimple masterPropertySimple = new PropertySimple(propertyDefinitionSimple.getName(), null); final FormItem masterValueItem = super.buildSimpleField(propertyDefinitionSimple, masterPropertySimple); masterValueItem.setDisabled(false);
@@ -286,7 +286,7 @@ public class GroupConfigurationEditor extends ConfigurationEditor { masterValueItem.addChangedHandler(new ChangedHandler() { public void onChanged(ChangedEvent changedEvent) { applyButton.enable(); - applyButton.focus(); + //applyButton.focus(); } });
@@ -332,7 +332,9 @@ public class GroupConfigurationEditor extends ConfigurationEditor { // Add data rows. final List<FormItem> valueItems = new ArrayList<FormItem>(this.memberConfigurations.size()); final Map<String, PropertySimple> valueItemNameToPropertySimpleMap = new HashMap<String, PropertySimple>(); - for (GroupMemberConfiguration memberConfiguration : this.memberConfigurations) { + List<GroupMemberConfiguration> memberConfigurations1 = this.memberConfigurations; + for (int i = 0, memberConfigurations1Size = memberConfigurations1.size(); i < memberConfigurations1Size; i++) { + GroupMemberConfiguration memberConfiguration = memberConfigurations1.get(i); String memberName = memberConfiguration.getLabel(); StaticTextItem memberItem = new StaticTextItem(); memberItem.setShowTitle(false); @@ -340,8 +342,11 @@ public class GroupConfigurationEditor extends ConfigurationEditor { items.add(memberItem); Configuration configuration = memberConfiguration.getConfiguration(); PropertySimple memberPropertySimple = (PropertySimple) getProperty(configuration, aggregatePropertySimple, - index); + index); FormItem valueItem = buildSimpleField(propertyDefinitionSimple, memberPropertySimple); + // All of the member props have the same name, so add an index to the item name to ensure it's unique + // to the form. + valueItem.setName(propertyDefinitionSimple.getName() + "-" + i); valueItems.add(valueItem); valueItemNameToPropertySimpleMap.put(valueItem.getName(), memberPropertySimple); FormItem unsetItem = buildUnsetItem(propertyDefinitionSimple, memberPropertySimple, valueItem); @@ -420,6 +425,10 @@ public class GroupConfigurationEditor extends ConfigurationEditor { @Override public void onClick(ClickEvent clickEvent) { Object value = masterValueItem.getValue(); + // Update the aggregate property. + aggregatePropertySimple.setValue(value); + + // Update the member properties. for (FormItem valueItem : valueItems) { setValue(valueItem, value);
commit e1b12455724418abfbb47f004d907faf2f052eeb Author: John Mazzitelli mazz@redhat.com Date: Mon Mar 28 12:43:00 2011 -0400
BZ 535384 - criteria needed to add search expression from the filter field in order for the search bar to work for any view using this ResourceComposite data source I also added the ability to set version criteria, to match that of the Resouce datasource.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceCompositeDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceCompositeDataSource.java index 24eb534..0567d7c 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceCompositeDataSource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceCompositeDataSource.java @@ -173,6 +173,8 @@ public class ResourceCompositeDataSource extends RPCDataSource<ResourceComposite criteria.addFilterTagNamespace(getFilter(request, "tagNamespace", String.class)); criteria.addFilterTagSemantic(getFilter(request, "tagSemantic", String.class)); criteria.addFilterTagName(getFilter(request, "tagName", String.class)); + criteria.addFilterVersion(getFilter(request, "version", String.class)); + criteria.setSearchExpression(getFilter(request, "search", String.class));
return criteria; }
commit c510a0e9ae1c21c63d66d6420b01fbeb65b50e22 Author: John Mazzitelli mazz@redhat.com Date: Mon Mar 28 11:16:17 2011 -0400
remove unused static API. we have a different way of getting group member views
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceCompositeSearchView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceCompositeSearchView.java index 7e9883e..617ca08 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceCompositeSearchView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceCompositeSearchView.java @@ -175,10 +175,4 @@ public class ResourceCompositeSearchView extends ResourceSearchView { return new ResourceCompositeSearchView(locatorId, parentResourceComposite, new Criteria("parentId", String .valueOf(parentResourceComposite.getResource().getId())), MSG.view_inventory_resources_title_children()); } - - public static ResourceCompositeSearchView getMembersOf(String locatorId, int groupId) { - return new ResourceCompositeSearchView(locatorId, (ResourceComposite) null, new Criteria("groupId", String - .valueOf(groupId)), MSG.view_inventory_resources_title_members()); - } - }
commit d525381080087b8ca9d439e2d7d9ff16d8e14117 Author: John Mazzitelli mazz@redhat.com Date: Mon Mar 28 10:59:09 2011 -0400
suppress warnings due to the fact that subclass has different datasource types than the superclass
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceCompositeSearchView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceCompositeSearchView.java index 097383e..7e9883e 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceCompositeSearchView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceCompositeSearchView.java @@ -67,6 +67,8 @@ public class ResourceCompositeSearchView extends ResourceSearchView { this(locatorId, null, criteria, title, headerIcons); }
+ // surpress unchecked warnings because the superclass has different generic types for the datasource + @SuppressWarnings("unchecked") @Override protected RPCDataSource getDataSourceInstance() { return ResourceCompositeDataSource.getInstance(); 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 beb5579..27e67d7 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 @@ -62,7 +62,7 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility; /** * @author Greg Hinkle */ -public class ResourceSearchView extends Table<RPCDataSource<Resource, ResourceCriteria>> { +public class ResourceSearchView extends Table {
private static final String DEFAULT_TITLE = MSG.view_inventory_resources_title();
@@ -112,7 +112,9 @@ public class ResourceSearchView extends Table<RPCDataSource<Resource, ResourceCr setDataSource(datasource); }
- protected RPCDataSource<Resource, ResourceCriteria> getDataSourceInstance() { + // surpress unchecked warnings because the subclasses may have different generic types for the datasource + @SuppressWarnings("unchecked") + protected RPCDataSource getDataSourceInstance() { return ResourceDatasource.getInstance(); }
commit 9b58b90dbeaad340e36ee4d9036e353a648dde72 Author: John Mazzitelli mazz@redhat.com Date: Mon Mar 28 10:41:09 2011 -0400
add generic type 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 6559a31..beb5579 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 @@ -41,6 +41,8 @@ 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.criteria.ResourceCriteria; +import org.rhq.core.domain.resource.Resource; import org.rhq.core.domain.resource.ResourceCategory; import org.rhq.core.domain.search.SearchSubsystem; import org.rhq.enterprise.gui.coregui.client.CoreGUI; @@ -60,7 +62,7 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility; /** * @author Greg Hinkle */ -public class ResourceSearchView extends Table { +public class ResourceSearchView extends Table<RPCDataSource<Resource, ResourceCriteria>> {
private static final String DEFAULT_TITLE = MSG.view_inventory_resources_title();
@@ -106,17 +108,11 @@ public class ResourceSearchView extends Table { addHeaderIcon(headerIcon); }
- // DynamicForm searchPanel = new DynamicForm(); - // final TextItem searchBox = new TextItem("query", "Search Resources"); - // searchBox.setValue(""); - // searchPanel.setWrapItemTitles(false); - // searchPanel.setFields(searchBox); - - final RPCDataSource datasource = getDataSourceInstance(); + final RPCDataSource<Resource, ResourceCriteria> datasource = getDataSourceInstance(); setDataSource(datasource); }
- protected RPCDataSource getDataSourceInstance() { + protected RPCDataSource<Resource, ResourceCriteria> getDataSourceInstance() { return ResourceDatasource.getInstance(); }
commit 9dff0af39f538f28833c51ff2ef206328b3bdc8d Author: Jay Shaughnessy jshaughn@redhat.com Date: Fri Mar 25 23:09:21 2011 -0400
remove link to unavailable package in jdoc
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/ResourceAncestryFormat.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/ResourceAncestryFormat.java index 5d87a7f..503f729 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/ResourceAncestryFormat.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/ResourceAncestryFormat.java @@ -26,11 +26,8 @@ import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlEnum;
-import org.rhq.enterprise.server.resource.ResourceManagerRemote; - /** * Used to request the desired diplay format for resource ancestry. - * @see {@link ResourceManagerRemote#getResourcesAncestry(org.rhq.core.domain.auth.Subject, Integer[], ResourceAncestryFormat)} * * @author Jay Shaughnessy */
commit 23820b201c04edcec4812d31ad4687abc30bf0ec Author: Jay Shaughnessy jshaughn@redhat.com Date: Fri Mar 25 21:48:10 2011 -0400
Resource Ancestry (Disambiguation) Work - Bug 602178 - Resource hierarchy in alert emails not disambiguated - Add SLSB support for getting formatted resource ancestry and use this for disambiguated resource info for alert email text. This also provides missing support for CLI users that may need formatted ancestry strings. - Tweaked the alert-email-template.txt to be slightly better formatted (is this ok to do? Is this file being parsed by users?)
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/ResourceAncestryFormat.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/ResourceAncestryFormat.java new file mode 100644 index 0000000..5d87a7f --- /dev/null +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/ResourceAncestryFormat.java @@ -0,0 +1,50 @@ +/* + * 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.resource; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlEnum; + +import org.rhq.enterprise.server.resource.ResourceManagerRemote; + +/** + * Used to request the desired diplay format for resource ancestry. + * @see {@link ResourceManagerRemote#getResourcesAncestry(org.rhq.core.domain.auth.Subject, Integer[], ResourceAncestryFormat)} + * + * @author Jay Shaughnessy + */ +@XmlEnum +@XmlAccessorType(XmlAccessType.FIELD) +public enum ResourceAncestryFormat { + /** + * <ul> + * <li>RAW: The raw, encoded value. This is already provided by the Resource.ancestry field. + * + * <li>SIMPLE: Short, name only format: (eg. parentName < grandParentName < etc...) + * + * <li>VERBOSE: Verbose, MultiLine format incorporating name, type and indentation. + * </ul> + */ + RAW, SIMPLE, VERBOSE +} \ No newline at end of file diff --git a/modules/enterprise/server/ear/src/main/resources/alert-email-template.txt b/modules/enterprise/server/ear/src/main/resources/alert-email-template.txt index 40fb2cf..a791933 100644 --- a/modules/enterprise/server/ear/src/main/resources/alert-email-template.txt +++ b/modules/enterprise/server/ear/src/main/resources/alert-email-template.txt @@ -1,24 +1,23 @@ -Subject: [ALERT] priority of [@@@PRIORITY@@@] for alert [@@@ALERT_NAME@@@] on resource [@@@RESOURCE_NAME@@@] - -The resource @@@RESOURCE_NAME@@@ has generated the following alert: - ------------------------------------------- - -- Resource Name: @@@RESOURCE_NAME@@@ -- Alert Name: @@@ALERT_NAME@@@ -- Alert Severity: @@@PRIORITY@@@ -- Alert Date/Time: @@@TIMESTAMP@@@ -- Conditions: @@@CONDITIONS@@@ - ------------------------------------------- - -Resource Hierarchy was: - -@@@FULL_RESOURCE_HIERARCHY@@@ - - ------------------------------------------- - -For additional details about this alert, go to @@@ALERT_URL@@@ - -This message was delivered to you by RHQ. +Subject: [ALERT] priority of [@@@PRIORITY@@@] for alert [@@@ALERT_NAME@@@] on resource [@@@RESOURCE_NAME@@@] + +The resource @@@RESOURCE_NAME@@@ has generated the following alert: + +------------------------------------------ + +Resource Name : @@@RESOURCE_NAME@@@ +Alert Name : @@@ALERT_NAME@@@ +Alert Severity : @@@PRIORITY@@@ +Alert Date/Time : @@@TIMESTAMP@@@ +Conditions: @@@CONDITIONS@@@ + +------------------------------------------ + +Resource Ancestry: + +@@@FULL_RESOURCE_HIERARCHY@@@ + +------------------------------------------ + +For additional details about this alert, go to @@@ALERT_URL@@@ + +This message was delivered to you by RHQ. diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertManagerBean.java index d25d1c4..02ae7b1 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertManagerBean.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertManagerBean.java @@ -64,6 +64,7 @@ import org.rhq.core.domain.measurement.MeasurementSchedule; import org.rhq.core.domain.measurement.MeasurementUnits; import org.rhq.core.domain.operation.OperationDefinition; import org.rhq.core.domain.resource.Resource; +import org.rhq.core.domain.resource.ResourceAncestryFormat; import org.rhq.core.domain.util.PageList; import org.rhq.core.server.MeasurementConverter; import org.rhq.core.server.PersistenceUtility; @@ -727,9 +728,11 @@ public class AlertManagerBean implements AlertManagerLocal, AlertManagerRemote { }
AlertDefinition alertDefinition = alert.getAlertDefinition(); - Map<String, String> alertMessage = emailManager.getAlertEmailMessage( - prettyPrintResourceHierarchy(alertDefinition.getResource()), // - alertDefinition.getResource().getName(), // + Resource resource = alertDefinition.getResource(); + Map<Integer, String> ancestry = resourceManager.getResourcesAncestry(subjectManager.getOverlord(), + new Integer[] { resource.getId() }, ResourceAncestryFormat.VERBOSE); + Map<String, String> alertMessage = emailManager.getAlertEmailMessage(ancestry.get(resource.getId()), // + resource.getName(), // alertDefinition.getName(), // alertDefinition.getPriority().toString(), // new Date(alert.getCtime()).toString(), // @@ -755,40 +758,6 @@ public class AlertManagerBean implements AlertManagerLocal, AlertManagerRemote {
private static String NEW_LINE = System.getProperty("line.separator");
- private String prettyPrintResourceHierarchy(Resource resource) { - StringBuilder builder = new StringBuilder(); - - List<Resource> lineage = resourceManager.getResourceLineage(resource.getId()); - - int depth = 0; - for (Resource res : lineage) { - if (depth == 0) { - builder.append(" - "); - } else { - builder.append(NEW_LINE); - - for (int i = 0; i < depth; i++) { - builder.append(" "); - } - - builder.append("|"); - builder.append(NEW_LINE); - - for (int i = 0; i < depth; i++) { - builder.append(" "); - } - - builder.append("+- "); - } - - builder.append(res.getName()); - - depth++; - } - - return builder.toString(); - } - /** * Create a human readable description of the conditions that led to this alert. * @param alert Alert to create human readable condition description 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 384104a..30c2334 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 @@ -20,7 +20,9 @@ package org.rhq.enterprise.server.resource;
import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; import java.util.Collections; +import java.util.HashMap; import java.util.HashSet; import java.util.LinkedHashMap; import java.util.LinkedList; @@ -66,6 +68,7 @@ import org.rhq.core.domain.content.InstalledPackageHistory; import org.rhq.core.domain.content.PackageInstallationStep; import org.rhq.core.domain.content.ResourceRepo; import org.rhq.core.domain.criteria.ResourceCriteria; +import org.rhq.core.domain.criteria.ResourceTypeCriteria; import org.rhq.core.domain.event.Event; import org.rhq.core.domain.event.EventSource; import org.rhq.core.domain.measurement.Availability; @@ -84,6 +87,7 @@ import org.rhq.core.domain.resource.CreateResourceHistory; import org.rhq.core.domain.resource.DeleteResourceHistory; import org.rhq.core.domain.resource.InventoryStatus; import org.rhq.core.domain.resource.Resource; +import org.rhq.core.domain.resource.ResourceAncestryFormat; import org.rhq.core.domain.resource.ResourceCategory; import org.rhq.core.domain.resource.ResourceError; import org.rhq.core.domain.resource.ResourceErrorType; @@ -827,6 +831,147 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage return resourceLineage; }
+ public Map<Integer, String> getResourcesAncestry(Subject subject, Integer[] resourceIds, + ResourceAncestryFormat format) { + Map<Integer, String> result = new HashMap<Integer, String>(resourceIds.length); + + if (resourceIds.length == 0) { + return result; + } + + ResourceCriteria resourceCriteria = new ResourceCriteria(); + resourceCriteria.addFilterIds(resourceIds); + resourceCriteria.fetchResourceType(true); + List<Resource> resources = findResourcesByCriteria(subject, resourceCriteria); + + if (ResourceAncestryFormat.RAW == format) { + for (Resource resource : resources) { + result.put(resource.getId(), resource.getAncestry()); + } + return result; + } + + HashSet<Integer> typesSet = new HashSet<Integer>(); + HashSet<String> ancestries = new HashSet<String>(); + for (Resource resource : resources) { + ResourceType type = resource.getResourceType(); + if (type != null) { + typesSet.add(type.getId()); + } + ancestries.add(resource.getAncestry()); + } + + // In addition to the types of the result resources, get the types of their ancestry + typesSet.addAll(getAncestryTypeIds(ancestries)); + + ResourceTypeCriteria resourceTypeCriteria = new ResourceTypeCriteria(); + resourceTypeCriteria.addFilterIds(typesSet.toArray(new Integer[typesSet.size()])); + List<ResourceType> types = typeManager.findResourceTypesByCriteria(subject, resourceTypeCriteria); + + for (Resource resource : resources) { + String decodedAncestry = getDecodedAncestry(resource, types, format); + result.put(resource.getId(), decodedAncestry); + } + return result; + } + + /** + * Get the complete set of resource type Ids in the ancestries provided. This is useful for + * being able to load all the types in advance of generating decoded values. + * + * @return + */ + private HashSet<Integer> getAncestryTypeIds(Collection<String> ancestries) { + HashSet<Integer> result = new HashSet<Integer>(); + + for (String ancestry : ancestries) { + if (null == ancestry) { + continue; + } + String[] ancestryEntries = ancestry.split(Resource.ANCESTRY_DELIM); + for (int i = 0; i < ancestryEntries.length; ++i) { + String[] entryTokens = ancestryEntries[i].split(Resource.ANCESTRY_ENTRY_DELIM); + int rtId = Integer.valueOf(entryTokens[0]); + result.add(rtId); + } + } + + return result; + } + + private String getDecodedAncestry(Resource resource, List<ResourceType> typeList, ResourceAncestryFormat format) { + String ancestry = resource.getAncestry(); + StringBuilder sb = new StringBuilder(); + + if (ResourceAncestryFormat.VERBOSE != format) { + if (null == ancestry) { + sb.append(""); + } + + String[] ancestryEntries = ancestry.split(Resource.ANCESTRY_DELIM); + for (int i = 0; i < ancestryEntries.length; ++i) { + String[] entryTokens = ancestryEntries[i].split(Resource.ANCESTRY_ENTRY_DELIM); + String ancestorName = entryTokens[2]; + + sb.append((i > 0) ? " < " : ""); + sb.append(ancestorName); + } + } else { + Map<Integer, ResourceType> types = new HashMap<Integer, ResourceType>(typeList.size()); + for (ResourceType type : typeList) { + types.put(type.getId(), type); + } + + ResourceType type = types.get(resource.getResourceType().getId()); + String resourceLongName = getResourceLongName(resource.getName(), type); + + // decode ancestry + if (null != ancestry) { + String[] ancestryEntries = ancestry.split(Resource.ANCESTRY_DELIM); + for (int i = ancestryEntries.length - 1, j = 0; i >= 0; --i, ++j) { + String[] entryTokens = ancestryEntries[i].split(Resource.ANCESTRY_ENTRY_DELIM); + int ancestorTypeId = Integer.valueOf(entryTokens[0]); + String ancestorName = entryTokens[2]; + + // indent with spaces + if (j > 0) { + sb.append("\n"); + for (int k = 0; k < j; ++k) { + sb.append(" "); + } + } + type = types.get(ancestorTypeId); + sb.append(getResourceLongName(ancestorName, type)); + } + + // add target resource, indent with spaces + sb.append("\n"); + for (int k = 0; k <= ancestryEntries.length; ++k) { + sb.append(" "); + } + sb.append(resourceLongName); + + } else { + // just show the resource name/type info + sb.append(resourceLongName); + } + } + + return sb.toString(); + } + + private String getResourceLongName(String resourceName, ResourceType type) { + StringBuilder sb = new StringBuilder(); + sb.append(resourceName); + sb.append(" ["); + sb.append(type.getPlugin()); + sb.append(", "); + sb.append(type.getName()); + sb.append("]"); + + return sb.toString(); + } + @NotNull public Resource getRootResourceForResource(int resourceId) { Query q = entityManager.createNamedQuery(Resource.QUERY_FIND_ROOT_PLATFORM_OF_RESOURCE); 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 02b0266..841428b 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 @@ -32,6 +32,7 @@ import org.rhq.core.domain.measurement.ResourceAvailability; import org.rhq.core.domain.resource.Agent; import org.rhq.core.domain.resource.InventoryStatus; import org.rhq.core.domain.resource.Resource; +import org.rhq.core.domain.resource.ResourceAncestryFormat; import org.rhq.core.domain.resource.ResourceCategory; import org.rhq.core.domain.resource.ResourceError; import org.rhq.core.domain.resource.ResourceErrorType; @@ -506,4 +507,7 @@ public interface ResourceManagerLocal { List<Integer> findIdsByTypeIds(List<Integer> resourceTypeIds);
Integer getResourceCount(List<Integer> resourceTypeIds); + + Map<Integer, String> getResourcesAncestry(Subject subject, Integer[] resourceIds, ResourceAncestryFormat format); + } \ No newline at end of file diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerRemote.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerRemote.java index 46b8e08..9d1c269 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerRemote.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerRemote.java @@ -19,6 +19,7 @@ package org.rhq.enterprise.server.resource;
import java.util.List; +import java.util.Map;
import javax.ejb.Remote; import javax.jws.WebMethod; @@ -31,6 +32,7 @@ import org.rhq.core.domain.auth.Subject; import org.rhq.core.domain.criteria.ResourceCriteria; import org.rhq.core.domain.measurement.ResourceAvailability; import org.rhq.core.domain.resource.Resource; +import org.rhq.core.domain.resource.ResourceAncestryFormat; import org.rhq.core.domain.util.PageControl; import org.rhq.core.domain.util.PageList; import org.rhq.enterprise.server.jaxb.adapter.ResourceListAdapter; @@ -138,4 +140,22 @@ public interface ResourceManagerRemote { Resource getParentResource( // @WebParam(name = "subject") Subject subject, // @WebParam(name = "resourceId") int resourceId); + + /** + * Resource.ancestry is an encoded value that holds the resource's parental ancestry. It is not suitable for display. + * This method can be used to get decoded and formatted ancestry values for a set of resources. A typical usage + * would a criteria resource fetch, and then a subsequent call to this method for ancestry display, potentially + * for resource disambiguation purposes. + * + * @param subject + * @param resourceIds + * @param format + * @return A Map of ResourceIds to FormattedAncestryStrings, one entry for each unique, valid, resourceId passed in. + */ + @WebMethod + Map<Integer, String> getResourcesAncestry( // + @WebParam(name = "subject") Subject subject, // + @WebParam(name = "resourceIds") Integer[] resourceIds, // + @WebParam(name = "format") ResourceAncestryFormat format); + } \ No newline at end of file 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 3a4910b..e06d5ae 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 @@ -25,7 +25,6 @@ package org.rhq.enterprise.server.webservices; import java.io.File; import java.io.InputStream; import java.net.URL; -import java.util.Comparator; import java.util.List; import java.util.Map; import java.util.Properties; @@ -115,6 +114,7 @@ import org.rhq.core.domain.operation.bean.ResourceOperationSchedule; 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.ResourceAncestryFormat; import org.rhq.core.domain.resource.ResourceType; import org.rhq.core.domain.resource.composite.ProblemResourceComposite; import org.rhq.core.domain.resource.group.ResourceGroup; @@ -517,12 +517,12 @@ public class WebservicesManagerBean implements WebservicesRemote { public PackageType findPackageType(Subject subject, Integer resourceTypeId, String packageTypeName) { return contentManager.findPackageType(subject, resourceTypeId, packageTypeName); } - + public PackageTypeAndVersionFormatComposite findPackageTypeWithVersionFormat(Subject subject, Integer resourceTypeId, String packageTypeName) { return contentManager.findPackageTypeWithVersionFormat(subject, resourceTypeId, packageTypeName); } - + public InstalledPackage getBackingPackageForResource(Subject subject, int resourceId) { return contentManager.getBackingPackageForResource(subject, resourceId); } @@ -533,15 +533,15 @@ public class WebservicesManagerBean implements WebservicesRemote {
public PageList<Package> findPackagesByCriteria(Subject subject, PackageCriteria criteria) { checkParametersPassedIn(subject, criteria); - return contentManager.findPackagesByCriteria(subject, criteria); + return contentManager.findPackagesByCriteria(subject, criteria); } - + public PageList<PackageAndLatestVersionComposite> findPackagesWithLatestVersion(Subject subject, PackageCriteria criteria) { checkParametersPassedIn(subject, criteria); - return contentManager.findPackagesWithLatestVersion(subject, criteria); + return contentManager.findPackagesWithLatestVersion(subject, criteria); } - + //CONTENTMANAGER: END ----------------------------------
// //DATAACCESSMANAGER: BEGIN ---------------------------------- @@ -807,11 +807,11 @@ public class WebservicesManagerBean implements WebservicesRemote { public PackageVersion getLatestPackageVersion(Subject subject, int packageId, int repoId) { return repoManager.getLatestPackageVersion(subject, packageId, repoId); } - + public boolean deletePackageVersionsFromRepo(Subject subject, int repoId, int[] packageVersionIds) { return repoManager.deletePackageVersionsFromRepo(subject, repoId, packageVersionIds); } - + public PageList<Resource> findSubscribedResources(Subject subject, int repoId, PageControl pc) { return repoManager.findSubscribedResources(subject, repoId, pc); } @@ -911,6 +911,11 @@ public class WebservicesManagerBean implements WebservicesRemote { return resourceManager.getResource(subject, resourceId); }
+ public Map<Integer, String> getResourcesAncestry(Subject subject, Integer[] resourceIds, + ResourceAncestryFormat format) { + return resourceManager.getResourcesAncestry(subject, resourceIds, format); + } + public List<Integer> uninventoryResources(Subject subject, int[] resourceIds) { return resourceManager.uninventoryResources(subject, resourceIds); }
commit 3e764d153948be8b0d7b9d25e58947caa14295ca Author: John Mazzitelli mazz@redhat.com Date: Fri Mar 25 18:23:16 2011 -0400
be able to clear out ResourcErrors for a particular resource. This is needed because I'm seeing instances where I get ResourcErrors in the database that never go away, even after the plugin can later successfully connect and monitor the resource.
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 72be13d..921b82d 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 @@ -59,6 +59,8 @@ public interface ResourceGWTService extends RemoteService {
List<ResourceError> findResourceErrors(int resourceId) throws RuntimeException;
+ void deleteResourceErrors(int[] resourceErrorIds) throws RuntimeException; + PageList<ProblemResourceComposite> findProblemResources(long ctime, int maxItems) throws RuntimeException;
Resource getPlatformForResource(int resourceId) throws RuntimeException; 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 1046f31..7bc1cdd 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 @@ -204,25 +204,25 @@ public class ResourceTitleBar extends LocatableVLayout { winModal.setWidth("70%"); winModal.setHeight("70%"); winModal.setIsModal(true); + winModal.setShowResizer(true); + winModal.setCanDragResize(true); winModal.centerInPage(); - winModal.setTitle(MSG.common_title_component_errors() + ":"); + winModal.setTitle(MSG.common_title_component_errors());
LocatableVLayout form = new LocatableVLayout(extendLocatorId("_Modal_Form")); form.setAlign(VerticalAlignment.CENTER); - form.setLayoutMargin(20); + form.setLayoutMargin(10); form.setWidth100(); - form.setHeight("40%"); - ResourceErrorsView errorsGrid = new ResourceErrorsView(extendLocatorId("errors"), MSG - .view_summaryOverview_header_detectedErrors(), null, null, - new String[] { ResourceErrorsDataSource.Field.DETAIL }); - errorsGrid.setWidth100(); - errorsGrid.setHeight("400"); + form.setHeight100();
Resource resource = resourceComposite.getResource(); ResourceErrorsDataSource errors = new ResourceErrorsDataSource(resource.getId());
- errorsGrid.setShowFooter(false); + ResourceErrorsView errorsGrid = new ResourceErrorsView(extendLocatorId("errors"), MSG + .view_summaryOverview_header_detectedErrors(), null, null, + new String[] { ResourceErrorsDataSource.Field.DETAIL }); errorsGrid.setDataSource(errors); + form.addMember(errorsGrid); winModal.addItem(form);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsDataSource.java index 5999e14..be76956 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsDataSource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsDataSource.java @@ -27,10 +27,6 @@ import com.smartgwt.client.data.DSRequest; import com.smartgwt.client.data.DSResponse; import com.smartgwt.client.data.DataSourceField; import com.smartgwt.client.data.Record; -import com.smartgwt.client.data.fields.DataSourceDateTimeField; -import com.smartgwt.client.data.fields.DataSourceEnumField; -import com.smartgwt.client.data.fields.DataSourceImageField; -import com.smartgwt.client.data.fields.DataSourceTextField; import com.smartgwt.client.rpc.RPCResponse; import com.smartgwt.client.widgets.grid.ListGridRecord;
@@ -42,22 +38,20 @@ import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGWTServiceAsync; import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
/** - * * @author Lukas Krejci * @author Simeon Pinder + * @author John Mazzitelli */ public class ResourceErrorsDataSource extends RPCDataSource<ResourceError, Criteria> {
public static abstract class Field { + public static final String ID = "id"; public static final String SUMMARY = "summary"; public static final String DETAIL = "detail"; public static final String ERROR_TYPE = "errorType"; public static final String TIME_OCCURED = "timeOccured"; - public static final String ICON = "icon"; }
- private static final String ERROR_ICON = "[SKIN]/Dialog/warn.png"; - ResourceGWTServiceAsync resourceService; int resourceId;
@@ -69,25 +63,6 @@ public class ResourceErrorsDataSource extends RPCDataSource<ResourceError, Crite }
@Override - protected List<DataSourceField> addDataSourceFields() { - List<DataSourceField> fields = super.addDataSourceFields(); - - fields.add(new DataSourceEnumField(Field.ERROR_TYPE, MSG.dataSource_resourceErrors_field_errorType())); - fields.add(new DataSourceDateTimeField(Field.TIME_OCCURED, MSG.dataSource_resourceErrors_field_timeOccured())); - fields.add(new DataSourceTextField(Field.SUMMARY, MSG.dataSource_resourceErrors_field_summary())); - DataSourceTextField details = new DataSourceTextField(Field.DETAIL, MSG - .dataSource_resourceErrors_field_detail()); - details.setHidden(true);//won't be displaying this value directly in the listgrid - fields.add(details); - fields.add(new DataSourceImageField(Field.ICON, MSG.dataSource_resourceErrors_field_detail())); - - return fields; - } - - /* (non-Javadoc) - * @see org.rhq.enterprise.gui.coregui.client.util.RPCDataSource#executeFetch(com.smartgwt.client.data.DSRequest, com.smartgwt.client.data.DSResponse) - */ - @Override protected void executeFetch(final DSRequest request, final DSResponse response, final Criteria unused) { resourceService.findResourceErrors(resourceId, new AsyncCallback<List<ResourceError>>() { public void onFailure(Throwable caught) { @@ -110,16 +85,18 @@ public class ResourceErrorsDataSource extends RPCDataSource<ResourceError, Crite return null; }
+ @Override public ResourceError copyValues(Record from) { //This is read-only datasource, so no need to implement this. return null; }
+ @Override public ListGridRecord copyValues(ResourceError from) { ListGridRecord record = new ListGridRecord();
+ record.setAttribute(Field.ID, from.getId()); record.setAttribute(Field.DETAIL, from.getDetail()); - record.setAttribute(Field.ICON, ERROR_ICON); record.setAttribute(Field.ERROR_TYPE, from.getErrorType().name()); record.setAttribute(Field.SUMMARY, from.getSummary()); record.setAttribute(Field.TIME_OCCURED, new Date(from.getTimeOccurred())); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsView.java index 0309602..1c75bcc 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsView.java @@ -1,80 +1,189 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2011 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.summary;
+import com.google.gwt.user.client.rpc.AsyncCallback; import com.smartgwt.client.data.Criteria; +import com.smartgwt.client.types.Alignment; +import com.smartgwt.client.types.AutoFitWidthApproach; +import com.smartgwt.client.types.DateDisplayFormat; +import com.smartgwt.client.types.ListGridFieldType; import com.smartgwt.client.types.Overflow; +import com.smartgwt.client.types.SelectionStyle; 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.HoverCustomizer; +import com.smartgwt.client.widgets.grid.ListGrid; import com.smartgwt.client.widgets.grid.ListGridField; import com.smartgwt.client.widgets.grid.ListGridRecord; import com.smartgwt.client.widgets.grid.events.RecordClickEvent; import com.smartgwt.client.widgets.grid.events.RecordClickHandler;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI; +import org.rhq.enterprise.gui.coregui.client.components.table.AbstractTableAction; import org.rhq.enterprise.gui.coregui.client.components.table.Table; +import org.rhq.enterprise.gui.coregui.client.components.table.TableActionEnablement; +import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; +import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.summary.ResourceErrorsDataSource.Field; +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.LocatableHTMLPane; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableWindow;
-public class ResourceErrorsView extends Table { +public class ResourceErrorsView extends Table<ResourceErrorsDataSource> { + private static final String ERROR_ICON = "[SKIN]/Dialog/warn.png"; + public ResourceErrorsView(String locatorId, String string, Criteria criteria, Object object, String[] strings) { super(locatorId, MSG.common_title_component_errors(), criteria); + setWidth100(); + setHeight100(); + setShowHeader(false); + } + + @Override + protected SelectionStyle getDefaultSelectionStyle() { + return SelectionStyle.MULTIPLE; }
- /** Set order and width of table display - */ @Override protected void configureTable() { - getListGrid().getField(ResourceErrorsDataSource.Field.ERROR_TYPE).setWidth("20%"); - getListGrid().getField(ResourceErrorsDataSource.Field.TIME_OCCURED).setWidth("15%"); - getListGrid().getField(ResourceErrorsDataSource.Field.SUMMARY).setWidth("30%"); - //modify icon display listgrid element - ListGridField iconField = getListGrid().getField(ResourceErrorsDataSource.Field.ICON); - iconField.setWidth("35%"); - //add action on click of cell + ListGridField errorTypeField = new ListGridField(Field.ERROR_TYPE, MSG + .dataSource_resourceErrors_field_errorType()); + errorTypeField.setAlign(Alignment.CENTER); + errorTypeField.setAutoFitWidth(true); + errorTypeField.setAutoFitWidthApproach(AutoFitWidthApproach.BOTH); + + ListGridField timeField = new ListGridField(Field.TIME_OCCURED, MSG + .dataSource_resourceErrors_field_timeOccured()); + timeField.setType(ListGridFieldType.DATE); + timeField.setDateFormatter(DateDisplayFormat.TOLOCALESTRING); + timeField.setAlign(Alignment.CENTER); + timeField.setWidth("20%"); + + ListGridField summaryField = new ListGridField(Field.SUMMARY, MSG.dataSource_resourceErrors_field_summary()); + summaryField.setAlign(Alignment.CENTER); + summaryField.setCellAlign(Alignment.LEFT); + summaryField.setWidth("*"); + + ListGridField iconField = new ListGridField("icon"); + iconField.setType(ListGridFieldType.ICON); + iconField.setAlign(Alignment.CENTER); + iconField.setIcon(ERROR_ICON); + iconField.setCellIcon(ERROR_ICON); + iconField.setWidth("50"); + iconField.setCanSort(false); iconField.addRecordClickHandler(new RecordClickHandler() { @Override public void onRecordClick(RecordClickEvent event) { - final Window winModal = new LocatableWindow(extendLocatorId("errorDetailsWin")); - winModal.setTitle(MSG.common_title_component_errors()); - winModal.setOverflow(Overflow.VISIBLE); - winModal.setShowMinimizeButton(false); - winModal.setShowMaximizeButton(true); - 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(); - } - }); - - LocatableHTMLPane htmlPane = new LocatableHTMLPane(extendLocatorId("errorDetailsPane")); - htmlPane.setMargin(10); - htmlPane.setDefaultWidth(550); - htmlPane.setDefaultHeight(550); - htmlPane.setContents((event.getRecord().getAttribute(ResourceErrorsDataSource.Field.DETAIL))); - winModal.addItem(htmlPane); - winModal.show(); + String details = event.getRecord().getAttribute(Field.DETAIL); + popupDetails(details); } }); iconField.setShowHover(true); - //show some details in mouseOver iconField.setHoverCustomizer(new HoverCustomizer() { @Override public String hoverHTML(Object value, ListGridRecord record, int rowNum, int colNum) { - String html = record.getAttribute(ResourceErrorsDataSource.Field.DETAIL); + String html = record.getAttribute(Field.DETAIL); if (html.length() > 80) { // this was probably an error stack trace, snip it so the tooltip isn't too big html = "<pre>" + html.substring(0, 80) + "...</pre><p>" - + MSG.view_group_pluginConfig_table_clickStatusIcon() + "</p>"; + + MSG.dataSource_resourceErrors_clickStatusIcon() + "</p>"; } return html; } }); + + setListGridDoubleClickHandler(new DoubleClickHandler() { + @Override + public void onDoubleClick(DoubleClickEvent event) { + ListGrid listGrid = (ListGrid) event.getSource(); + ListGridRecord[] selectedRows = listGrid.getSelection(); + if (selectedRows != null && selectedRows.length > 0) { + String details = selectedRows[0].getAttribute(Field.DETAIL); + popupDetails(details); + } + } + }); + + setListGridFields(errorTypeField, timeField, summaryField, iconField); + + addTableAction(extendLocatorId("delete"), MSG.common_button_delete(), MSG.common_msg_areYouSure(), + new AbstractTableAction(TableActionEnablement.ANY) { + @Override + public void executeAction(final ListGridRecord[] selection, Object actionValue) { + if (selection == null || selection.length == 0) { + return; + } + int[] resourceErrorIds = new int[selection.length]; + int i = 0; + for (ListGridRecord record : selection) { + resourceErrorIds[i++] = record.getAttributeAsInt(Field.ID); + } + GWTServiceLookup.getResourceService().deleteResourceErrors(resourceErrorIds, + new AsyncCallback<Void>() { + @Override + public void onSuccess(Void result) { + Message msg = new Message(MSG.dataSource_resourceErrors_deleteSuccess(String + .valueOf(selection.length)), Severity.Info); + CoreGUI.getMessageCenter().notify(msg); + refresh(); + } + + @Override + public void onFailure(Throwable caught) { + CoreGUI.getErrorHandler().handleError(MSG.dataSource_resourceErrors_deleteFailure(), + caught); + } + }); + } + }); + } + + private void popupDetails(String details) { + final Window winModal = new LocatableWindow(extendLocatorId("errorDetailsWin")); + winModal.setTitle(MSG.common_title_component_errors()); + winModal.setOverflow(Overflow.VISIBLE); + winModal.setShowMinimizeButton(false); + winModal.setShowMaximizeButton(true); + 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(); + } + }); + + LocatableHTMLPane htmlPane = new LocatableHTMLPane(extendLocatorId("errorDetailsPane")); + htmlPane.setMargin(10); + htmlPane.setDefaultWidth(700); + htmlPane.setDefaultHeight(500); + htmlPane.setContents("<pre>" + details + "</pre>"); + winModal.addItem(htmlPane); + winModal.show(); } } 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 7b32034..13fc75a 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 @@ -314,6 +314,16 @@ public class ResourceGWTServiceImpl extends AbstractGWTServiceImpl implements Re } }
+ public void deleteResourceErrors(int[] resourceErrorIds) throws RuntimeException { + try { + for (int doomedId : resourceErrorIds) { + resourceManager.deleteResourceError(getSessionSubject(), doomedId); + } + } catch (Throwable t) { + throw getExceptionToThrowToClient(t); + } + } + public Resource manuallyAddResource(int resourceTypeId, int parentResourceId, Configuration pluginConfiguration) throws RuntimeException { try { diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties index 8317263..35ff92d 100644 --- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties +++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties @@ -108,7 +108,7 @@ common_title_columns = Columns common_title_configuration = Configuration common_title_compatibleGroups = Compatible Groups common_title_compatibleGroups_total = Compatible Group Total -common_title_component_errors = Component errors +common_title_component_errors = Component Errors common_title_count = Count common_title_custom = Custom common_title_dashboard_name = Dashboard Name @@ -563,10 +563,12 @@ dataSource_configurationHistory_error_fetchFailure = Unable to load configuratio # Resource Errors #------------------------- dataSource_resourceErrors_field_summary = Summary -dataSource_resourceErrors_field_detail = Detailed Message dataSource_resourceErrors_field_errorType = Error Type dataSource_resourceErrors_field_timeOccured = Time dataSource_resourceErrors_error_fetchFailure = Failed to find Resource errors for Resource with id [{0}]. +dataSource_resourceErrors_clickStatusIcon = Click the icon for more details +dataSource_resourceErrors_deleteSuccess = You have successfully deleted [{0}] resource error messages. +dataSource_resourceErrors_deleteFailure = Failed to delete resource errors
# Template Schedules #-------------------------
commit 5e00d3c76b16f5e2f1e8c26467c3c1599add8e1c Author: Ian Springer ian.springer@redhat.com Date: Fri Mar 25 17:16:06 2011 -0400
make sure config editor renders everything appropriately when in read-only mode (https://bugzilla.redhat.com/show_bug.cgi?id=680233)
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 9765188..449e9c3 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 @@ -344,10 +344,6 @@ public class ConfigurationEditor extends LocatableVLayout { }
public void reload() { - /*if (this.loaded && !this.reloadable) { - return; - }*/ - if (this.configurationDefinition == null || this.configuration == null) { // Wait for both to load. return; @@ -364,13 +360,7 @@ public class ConfigurationEditor extends LocatableVLayout { if (configurationDefinition.getConfigurationFormat() == ConfigurationFormat.STRUCTURED || configurationDefinition.getConfigurationFormat() == ConfigurationFormat.STRUCTURED_AND_RAW) { Log.info("Building structured configuration editor..."); - LocatableVLayout structuredConfigLayout = null; - try { - structuredConfigLayout = buildStructuredPane(); - } catch (RuntimeException e) { - e.printStackTrace(); - throw e; - } + LocatableVLayout structuredConfigLayout = buildStructuredPane(); addMember(structuredConfigLayout); } else { Label label = new Label("Structured configuration is not supported."); @@ -1267,7 +1257,9 @@ public class ConfigurationEditor extends LocatableVLayout { FormItem valueItem = null;
boolean propertyIsReadOnly = isReadOnly(propertyDefinitionSimple, propertySimple); - if (propertyIsReadOnly) { + // TODO (ips, 03/25/11): We eventually want to use StaticTextItems for read-only PASSWORD props too, but we have + // to wait until we implement masking/unmasking of PASSWORD props at the SLSB layer first. + if (propertyIsReadOnly && propertyDefinitionSimple.getType() != PropertySimpleType.PASSWORD) { valueItem = new StaticTextItem(); } else { List<PropertyDefinitionEnumeration> enumeratedValues = propertyDefinitionSimple.getEnumeratedValues(); @@ -1319,7 +1311,7 @@ public class ConfigurationEditor extends LocatableVLayout { } }
- valueItem.setDisabled(isUnset(propertyDefinitionSimple, propertySimple)); + valueItem.setDisabled(propertyIsReadOnly || isUnset(propertyDefinitionSimple, propertySimple));
List<Validator> validators = buildValidators(propertyDefinitionSimple, propertySimple); valueItem.setValidators(validators.toArray(new Validator[validators.size()])); @@ -1348,7 +1340,7 @@ public class ConfigurationEditor extends LocatableVLayout { valueItem.setWidth(220);
/* - Click handlers seem to be turned off for disabled fields... need an alternative + TODO: Click handlers seem to be turned off for disabled fields... need to find an alternative. valueItem.addClickHandler(new com.smartgwt.client.widgets.form.fields.events.ClickHandler() { public void onClick(ClickEvent clickEvent) { com.allen_sauer.gwt.log.client.Log.info("Click in value field"); @@ -1532,7 +1524,7 @@ public class ConfigurationEditor extends LocatableVLayout {
private void displayMapEditor(final ListGrid summaryTable, final PropertyMapListGridRecord existingRecord, PropertyDefinitionMap definition, final PropertyList list, final PropertyMap map, - boolean mapReadOnly) { + final boolean mapReadOnly) {
final List<PropertyDefinition> memberDefinitions = new ArrayList<PropertyDefinition>(definition .getPropertyDefinitions().values()); @@ -1542,7 +1534,8 @@ public class ConfigurationEditor extends LocatableVLayout { final PropertyMap workingMap = (newRow) ? new PropertyMap(definition.getName()) : map.deepCopy(true);
final LocatableWindow popup = new LocatableWindow(extendLocatorId("MapEditor")); - popup.setTitle(MSG.view_configEdit_editRow()); + String title = (mapReadOnly) ? MSG.view_configEdit_viewRow() : MSG.view_configEdit_editRow(); + popup.setTitle(title); popup.setWidth(800); popup.setHeight(600); popup.setIsModal(true); @@ -1568,31 +1561,33 @@ public class ConfigurationEditor extends LocatableVLayout { } okButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() { public void onClick(ClickEvent clickEvent) { - if (!childForm.validate()) { - okButton.disable(); - return; - } - if (newRow) { - try { - list.add(workingMap); - int index = list.getList().size() - 1; - PropertyMapListGridRecord record = new PropertyMapListGridRecord(workingMap, index, - memberDefinitions); - summaryTable.addData(record); - } catch (Exception e) { - e.printStackTrace(); + if (!mapReadOnly) { + if (!childForm.validate()) { + okButton.disable(); + return; } - } else { - try { - mergePropertyMap(workingMap, map, memberDefinitions); - existingRecord.refresh(); - summaryTable.updateData(existingRecord); - } catch (Exception e) { - e.printStackTrace(); + if (newRow) { + try { + list.add(workingMap); + int index = list.getList().size() - 1; + PropertyMapListGridRecord record = new PropertyMapListGridRecord(workingMap, index, + memberDefinitions); + summaryTable.addData(record); + } catch (Exception e) { + e.printStackTrace(); + } + } else { + try { + mergePropertyMap(workingMap, map, memberDefinitions); + existingRecord.refresh(); + summaryTable.updateData(existingRecord); + } catch (Exception e) { + e.printStackTrace(); + } } + firePropertyChangedEvent(list, null, true); + summaryTable.redraw(); } - firePropertyChangedEvent(list, null, true); - summaryTable.redraw();
layout.destroy(); popup.destroy(); @@ -1608,20 +1603,21 @@ public class ConfigurationEditor extends LocatableVLayout { okButton.setDisabled(false); } }); + buttonBar.addMember(okButton);
- final IButton cancelButton = new LocatableIButton(buttonBar.extendLocatorId("Cancel"), MSG.common_button_cancel()); - cancelButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() { - public void onClick(ClickEvent clickEvent) { - layout.destroy(); - popup.destroy(); - } - }); + if (!mapReadOnly) { + final IButton cancelButton = new LocatableIButton(buttonBar.extendLocatorId("Cancel"), MSG.common_button_cancel()); + cancelButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() { + public void onClick(ClickEvent clickEvent) { + layout.destroy(); + popup.destroy(); + } + }); + buttonBar.addMember(cancelButton); + }
- buttonBar.setMembers(okButton, cancelButton); layout.addMember(buttonBar); - popup.addItem(layout); - popup.show(); }
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestConfigurationFactory.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestConfigurationFactory.java index 08c94d7..a080f13 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestConfigurationFactory.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestConfigurationFactory.java @@ -226,7 +226,7 @@ public abstract class TestConfigurationFactory { string2Prop.setErrorMessage("illegal value!"); configuration.put(string2Prop); configuration.put(new PropertySimple("LongString", "blah blah blah\nblah blah blah")); - configuration.put(new PropertySimple("Password", null)); + configuration.put(new PropertySimple("Password", "ou812")); configuration.put(new PropertySimple("Boolean", false)); configuration.put(new PropertySimple("Integer", 666)); configuration.put(new PropertySimple("Float", Math.PI)); diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties index df17ca8..8317263 100644 --- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties +++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties @@ -1332,7 +1332,8 @@ view_configEdit_addItem = Add Item to List view_configEdit_confirm_1 = Are you sure you want to delete the selected properties from the set? view_configEdit_confirm_2 = Are you sure you want to delete this row? view_configEdit_confirm_3 = Are you sure you want to delete the [{0}] selected [{1}]? -view_configEdit_editRow = Edit Configuration Row +view_configEdit_viewRow = View Row +view_configEdit_editRow = Edit Row view_configEdit_enterPropName = Enter the name of the property to be added. view_configEdit_error_1 = Configuration is not supported by this Resource. view_configEdit_error_2 = Connection settings are not supported by this Resource.
commit c6af7b79622870ece640027f06c0f1a40ee30f8e Author: John Mazzitelli mazz@redhat.com Date: Fri Mar 25 16:03:02 2011 -0400
BZ 675153 - fix confirm message
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java index 9958d0c..c113008 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java @@ -144,7 +144,8 @@ public class ConditionsEditor extends LocatableVLayout { });
table.addTableAction(this.extendLocatorId("delete"), MSG.common_button_delete(), MSG - .view_alert_definitions_delete_confirm(), new AbstractTableAction(TableActionEnablement.ANY) { + .view_alert_definition_condition_editor_delete_confirm(), new AbstractTableAction( + TableActionEnablement.ANY) { public void executeAction(ListGridRecord[] selection, Object actionValue) { for (ListGridRecord record : selection) { AlertCondition cond = getDataSource().copyValues(record); diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties index b8ce183..df17ca8 100644 --- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties +++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties @@ -991,6 +991,7 @@ view_alert_definition_condition_editor_event_regex_tooltip = If specified, this view_alert_definition_condition_editor_common_min = Minimum view_alert_definition_condition_editor_common_avg = Average view_alert_definition_condition_editor_common_max = Maximum +view_alert_definition_condition_editor_delete_confirm = Delete the selected alert condition(s)? view_alert_definition_notification_editor_title_add = Add Notification view_alert_definition_notification_editor_title_edit = Edit Notification view_alert_definition_notification_editor_sender = Notification Sender
commit d0bfc008ba20e4128377901b743d5680ff7f1bf3 Author: Ian Springer ian.springer@redhat.com Date: Fri Mar 25 14:58:58 2011 -0400
misc minor
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 c68da84..9765188 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 @@ -1267,12 +1267,9 @@ public class ConfigurationEditor extends LocatableVLayout { FormItem valueItem = null;
boolean propertyIsReadOnly = isReadOnly(propertyDefinitionSimple, propertySimple); - if (propertyIsReadOnly) { valueItem = new StaticTextItem(); } else { - - List<PropertyDefinitionEnumeration> enumeratedValues = propertyDefinitionSimple.getEnumeratedValues(); if (enumeratedValues != null && !enumeratedValues.isEmpty()) { LinkedHashMap<String, String> valueOptions = new LinkedHashMap<String, String>(); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/GroupConfigurationEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/GroupConfigurationEditor.java index 80d6269..4c4a29f 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/GroupConfigurationEditor.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/GroupConfigurationEditor.java @@ -284,7 +284,6 @@ public class GroupConfigurationEditor extends ConfigurationEditor { setAllItems.add(canvasItem);
masterValueItem.addChangedHandler(new ChangedHandler() { - @Override public void onChanged(ChangedEvent changedEvent) { applyButton.enable(); applyButton.focus(); @@ -292,7 +291,6 @@ public class GroupConfigurationEditor extends ConfigurationEditor { });
masterUnsetItem.addChangedHandler(new ChangedHandler() { - @Override public void onChanged(ChangedEvent changedEvent) { applyButton.enable(); applyButton.focus(); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/wizard/WizardView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/wizard/WizardView.java index 2ce842f..8713ecc 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/wizard/WizardView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/wizard/WizardView.java @@ -217,6 +217,7 @@ public class WizardView extends LocatableVLayout { // a valid step, continue currentStep = stepIndex;
+ // TODO: i18n stepLabel.setContents("Step " + (stepIndex + 1) + " of " + wizardSteps.size()); stepLabel.setWrap(false);
commit 5e63bfc1dd1b13a34196b011f1820b0d93b1d99d Author: Ian Springer ian.springer@redhat.com Date: Fri Mar 25 14:58:36 2011 -0400
support plugin JARs whose MANIFEST.MF is not the 2nd entry of the JAR (fix for https://bugzilla.redhat.com/show_bug.cgi?id=682116)
diff --git a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/descriptor/PluginTransformer.java b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/descriptor/PluginTransformer.java index ecaa80b..fbefc1d 100644 --- a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/descriptor/PluginTransformer.java +++ b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/descriptor/PluginTransformer.java @@ -1,6 +1,6 @@ /* * RHQ Management Platform - * Copyright (C) 2005-2010 Red Hat, Inc. + * Copyright (C) 2005-2011 Red Hat, Inc. * All rights reserved. * * This program is free software; you can redistribute it and/or modify @@ -22,6 +22,8 @@ */ package org.rhq.core.clientapi.descriptor;
+import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.rhq.core.domain.plugin.Plugin; import org.rhq.core.clientapi.descriptor.plugin.PluginDescriptor; import org.rhq.core.clientapi.descriptor.plugin.Help; @@ -29,6 +31,8 @@ import org.rhq.core.util.MessageDigestGenerator;
import java.net.URL; import java.io.IOException; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; import java.util.jar.JarInputStream; import java.util.jar.Manifest; import java.util.jar.Attributes; @@ -38,6 +42,8 @@ import java.util.jar.Attributes; */ public class PluginTransformer {
+ private static final Log LOG = LogFactory.getLog(PluginTransformer.class); + /** * Takes the given plugin descriptor and plugin JAR file URL and converts them into a * {@link org.rhq.core.domain.plugin.Plugin} object. This method does not set the <code>content</code> property @@ -112,8 +118,24 @@ public class PluginTransformer {
private String getVersionFromPluginJarManifest(URL pluginJarUrl) throws IOException { JarInputStream jarInputStream = new JarInputStream(pluginJarUrl.openStream()); - jarInputStream.close(); Manifest manifest = jarInputStream.getManifest(); + if (manifest == null) { + // BZ 682116 (ips, 03/25/11): The manifest file is not in the standard place as the 2nd entry of the JAR, + // but we want to be flexible and support JARs that have a manifest file somewhere else, so scan the entire + // JAR for one. + JarEntry jarEntry; + while((jarEntry = jarInputStream.getNextJarEntry()) != null) { + if (JarFile.MANIFEST_NAME.equalsIgnoreCase(jarEntry.getName())) { + manifest = new Manifest(jarInputStream); + break; + } + } + } + try { + jarInputStream.close(); + } catch (IOException e) { + LOG.error("Failed to close plugin jar input stream for plugin jar [" + pluginJarUrl + "].", e); + } if (manifest != null) { Attributes attributes = manifest.getMainAttributes(); return attributes.getValue(Attributes.Name.IMPLEMENTATION_VERSION); @@ -121,4 +143,5 @@ public class PluginTransformer { return null; } } + }
commit cc672ab2ab3839dde8ce9672b8703cb54ea0ed1e Author: Jay Shaughnessy jshaughn@redhat.com Date: Fri Mar 25 11:24:07 2011 -0400
ResourceGroupTree navigation work - fix various issues with tree select and context menu nav - some refactoring for clarity
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/CustomResourceGroupTreeGrid.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/CustomResourceGroupTreeGrid.java index 5e4ff6f..349c5e7 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/CustomResourceGroupTreeGrid.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/CustomResourceGroupTreeGrid.java @@ -22,7 +22,6 @@ import com.smartgwt.client.data.Record; import com.smartgwt.client.widgets.tree.TreeNode;
import org.rhq.core.domain.resource.ResourceType; -import org.rhq.core.domain.resource.group.ClusterKey; import org.rhq.enterprise.gui.coregui.client.ImageManager; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableTreeGrid;
@@ -48,19 +47,15 @@ public class CustomResourceGroupTreeGrid extends LocatableTreeGrid { return node.getIcon(); }
- // if this node is associated with a resource type AND a cluster key, it is a cluster node - // if this node is associated only with a resource type, it is a auto type group node. - // if this node is not associated with either a resource type or cluster key, it is a subcategory node (which uses the default icon) - ResourceType resourceType = node.getResourceType(); - if (resourceType != null) { - ClusterKey clusterKey = node.getClusterKey(); - if (clusterKey != null) { - String icon = ImageManager.getClusteredResourceIcon(resourceType.getCategory()); - return icon; - } else { - boolean open = getTree().isOpen((TreeNode) record); - return "resources/folder_group_" + (open ? "opened" : "closed") + ".png"; - } + if (node.isAutoClusterNode()) { + ResourceType resourceType = node.getResourceType(); + String icon = ImageManager.getClusteredResourceIcon(resourceType.getCategory()); + return icon; + + } else if (node.isCompatibleGroupTopNode() || node.isAutoGroupNode()) { + boolean open = getTree().isOpen((TreeNode) record); + return "resources/folder_group_" + (open ? "opened" : "closed") + ".png"; + }
// use the default image - which is typically for subcategory nodes 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 27cf7d6..7ad3a74 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 @@ -43,8 +43,8 @@ public class ResourceGroupTreeContextMenu extends ResourceGroupContextMenu {
public void showContextMenu(ResourceGroupEnhancedTreeNode node) {
- final ClusterKey clusterKey = (ClusterKey) node.getAttributeAsObject("key"); - if (clusterKey != null) { + if (node.isAutoClusterNode()) { + final ClusterKey clusterKey = (ClusterKey) node.getAttributeAsObject("key"); GWTServiceLookup.getClusterService().createAutoClusterBackingGroup(clusterKey, true, new AsyncCallback<ResourceGroup>() { @Override @@ -58,7 +58,8 @@ public class ResourceGroupTreeContextMenu extends ResourceGroupContextMenu { showContextMenu(result); } }); - } else { + + } else if (node.isCompatibleGroupTopNode()) { ResourceGroupCriteria criteria = new ResourceGroupCriteria(); criteria.addFilterId(Integer.parseInt(node.getAttribute("id"))); GWTServiceLookup.getResourceGroupService().findResourceGroupsByCriteria(criteria, 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 d3f4fbd..04fbfbd 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 @@ -93,17 +93,21 @@ public class ResourceGroupTreeView extends LocatableVLayout implements Bookmarka private static final String FAKE_ROOT_ID = "__fakeRoot__"; // id of the parent node of our real root node
private TreeGrid treeGrid; - private ViewId currentViewId; - private int rootGroupId; - private int selectedGroupId; - private String selectedNodeId; - + private Map<Integer, ResourceType> typeMap; private ResourceGroupTreeContextMenu contextMenu;
+ // the root (top of tree) compat or mixed group private ResourceGroup rootResourceGroup; - private Map<Integer, ResourceType> typeMap; - private ResourceGroup selectedGroup; + + // the root (top of tree) compat or mixed group id (may bet set prior to rootResourceGroup fetch) + private int rootGroupId; + + // the currently selected tree node + private String currentNodeId; + + // the currently selected group backing the tree node + private ResourceGroup currentGroup;
private Comparator<ResourceGroupEnhancedTreeNode> treeNodeComparator = new Comparator<ResourceGroupEnhancedTreeNode>() { @Override @@ -164,76 +168,93 @@ public class ResourceGroupTreeView extends LocatableVLayout implements Bookmarka } });
- addMember(this.treeGrid); - contextMenu = new ResourceGroupTreeContextMenu(extendLocatorId("contextMenu")); treeGrid.setContextMenu(contextMenu);
+ treeGrid.addNodeContextClickHandler(new NodeContextClickHandler() { + public void onNodeContextClick(final NodeContextClickEvent event) { + // stop the browser right-click menu + event.cancel(); + + // don't select the node on a right click, since we're not navigating to it, and + // re-select the current node if necessary + ResourceGroupEnhancedTreeNode contextNode = (ResourceGroupEnhancedTreeNode) event.getNode(); + + if (null != currentNodeId) { + TreeNode currentNode = treeGrid.getTree().findById(currentNodeId); + if (!contextNode.equals(currentNode)) { + treeGrid.deselectRecord(contextNode); + treeGrid.selectRecord(currentNode); + } + } + + // only show the context menu for cluster nodes and our top root node + if (contextNode.isCompatibleGroupTopNode() || contextNode.isAutoClusterNode()) { + contextMenu.showContextMenu(contextNode); + } + } + }); + treeGrid.addSelectionChangedHandler(new SelectionChangedHandler() { - @Override + public void onSelectionChanged(SelectionEvent selectionEvent) { if (!selectionEvent.isRightButtonDown() && selectionEvent.getState()) { - selectedNodeId = null; // if user selected a valid node, we'll set this later - ResourceGroupEnhancedTreeNode selectedNode = (ResourceGroupEnhancedTreeNode) selectionEvent - .getRecord(); - com.allen_sauer.gwt.log.client.Log.info("Node selected in tree: " + selectedNode); - - ResourceType type = selectedNode.getResourceType(); - ClusterKey key = selectedNode.getClusterKey(); - if (type != null) { - if (key != null) { - // the user selected a cluster node - let's switch to that cluster group view - com.allen_sauer.gwt.log.client.Log.debug("Selecting cluster group [" + key + "]..."); - selectedNodeId = selectedNode.getID(); - selectClusterGroup(key); + + ResourceGroupEnhancedTreeNode newNode = (ResourceGroupEnhancedTreeNode) selectionEvent.getRecord(); + TreeNode currentNode = (null != currentNodeId) ? treeGrid.getTree().findById(currentNodeId) : null; + + // if re-selecting the current node just return, otherwise deselect the currently selected node + if (null != currentNode) { + if (newNode.equals(currentNode)) { + return; } else { - if (selectedNode.getParentID().equals(FAKE_ROOT_ID)) { - // the user selected the top group node - selectedNodeId = selectedNode.getID(); - String groupId = selectedNodeId; - com.allen_sauer.gwt.log.client.Log.debug("Selecting group [" + groupId + "]..."); - String viewPath = LinkManager.getResourceGroupLink(Integer.parseInt(groupId)); - CoreGUI.goToView(viewPath, true); - } else { - // the user selected a auto type group node; we have got nothing to show, so cancel the selection of this node - treeGrid.deselectRecord(selectedNode); - } + treeGrid.deselectRecord(currentNode); } - } else { - // the user selected a subcategory; we have got nothing to show, so cancel the selection of this node - treeGrid.deselectRecord(selectedNode); } - } - return; - } - });
- treeGrid.addNodeContextClickHandler(new NodeContextClickHandler() { - public void onNodeContextClick(final NodeContextClickEvent event) { - // stop the browser right-click menu - event.cancel(); + com.allen_sauer.gwt.log.client.Log.debug("Node selected in tree: " + newNode);
- // don't select the node on a right click, since we're not navigating to it - ResourceGroupEnhancedTreeNode node = (ResourceGroupEnhancedTreeNode) event.getNode(); - treeGrid.deselectRecord(node); - if (null != selectedNodeId) { - treeGrid.selectRecord(treeGrid.getTree().findById(selectedNodeId)); - } + if (newNode.isCompatibleGroupTopNode()) { + currentNodeId = newNode.getID(); + com.allen_sauer.gwt.log.client.Log.debug("Selecting compatible group [" + currentNodeId + + "]..."); + String viewPath = LinkManager.getResourceGroupLink(Integer.parseInt(currentNodeId)); + String currentViewPath = History.getToken(); + if (!currentViewPath.startsWith(viewPath.substring(1))) { + CoreGUI.goToView(viewPath, true); + } else { + // this should not be necessary but for otherwise the top node does not always show selected + treeGrid.markForRedraw(); + }
- // only show the context menu for cluster nodes and our top root node - ResourceType type = node.getResourceType(); - ClusterKey key = node.getClusterKey(); - if (type != null && (key != null || node.getParentID().equals(FAKE_ROOT_ID))) { - contextMenu.showContextMenu(node); + } else if (newNode.isAutoClusterNode()) { + ClusterKey key = newNode.getClusterKey(); + com.allen_sauer.gwt.log.client.Log.debug("Selecting autocluster group [" + key + "]..."); + currentNodeId = newNode.getID(); + // the user selected a cluster node - let's switch to that cluster group view + selectClusterGroup(key); + + } else if (newNode.isMixedGroupTopNode()) { + currentNodeId = newNode.getID(); + com.allen_sauer.gwt.log.client.Log.debug("Selecting mixed group [" + currentNodeId + "]..."); + + } else { + // a subcategory node, deselect and reselect the current node + treeGrid.deselectRecord(newNode); + if (null != currentNode) { + treeGrid.selectRecord(currentNode); + } + } } + + return; } });
+ addMember(this.treeGrid); }
public void setSelectedGroup(final int groupId, boolean isAutoCluster) { - this.selectedGroupId = groupId; - ResourceGroupCriteria criteria = new ResourceGroupCriteria(); criteria.addFilterId(groupId); criteria.addFilterVisible(Boolean.valueOf(!isAutoCluster)); @@ -241,16 +262,15 @@ public class ResourceGroupTreeView extends LocatableVLayout implements Bookmarka
GWTServiceLookup.getResourceGroupService().findResourceGroupsByCriteria(criteria, new AsyncCallback<PageList<ResourceGroup>>() { - @Override + public void onFailure(Throwable caught) { CoreGUI.getErrorHandler().handleError( MSG.view_tree_common_loadFailed_group(String.valueOf(groupId)), caught); }
- @Override public void onSuccess(PageList<ResourceGroup> result) { ResourceGroup group = result.get(0); - ResourceGroupTreeView.this.selectedGroup = group; + ResourceGroupTreeView.this.currentGroup = group;
GroupCategory groupCategory = group.getGroupCategory(); switch (groupCategory) { @@ -271,8 +291,9 @@ public class ResourceGroupTreeView extends LocatableVLayout implements Bookmarka Tree tree = new Tree(); tree.setRoot(fakeRoot); treeGrid.setData(tree); - treeGrid.markForRedraw(); + treeGrid.selectRecord(rootNode); break; + case COMPATIBLE: if (group.getClusterResourceGroup() == null) { // This is a straight up compatible group. @@ -293,14 +314,14 @@ public class ResourceGroupTreeView extends LocatableVLayout implements Bookmarka // Still looking at the same compat-recursive tree
ResourceGroupEnhancedTreeNode selectedNode; - if (this.selectedGroup.getClusterKey() != null) { + if (this.currentGroup.getClusterKey() != null) { // a child cluster node leaf was selected selectedNode = (ResourceGroupEnhancedTreeNode) treeGrid.getTree().find( - ResourceGroupEnhancedTreeNode.CLUSTER_KEY, this.selectedGroup.getClusterKey()); + ResourceGroupEnhancedTreeNode.CLUSTER_KEY, this.currentGroup.getClusterKey()); } else { // the top root node, representing the group itself, was selected selectedNode = (ResourceGroupEnhancedTreeNode) treeGrid.getTree().findById( - String.valueOf(this.selectedGroup.getId())); + String.valueOf(this.currentGroup.getId())); }
if (selectedNode != null) { @@ -331,7 +352,7 @@ public class ResourceGroupTreeView extends LocatableVLayout implements Bookmarka 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) { ResourceGroupTreeView.this.typeMap = types; loadTree(root); @@ -342,12 +363,11 @@ public class ResourceGroupTreeView extends LocatableVLayout implements Bookmarka private void selectClusterGroup(ClusterKey key) { GWTServiceLookup.getClusterService().createAutoClusterBackingGroup(key, true, new AsyncCallback<ResourceGroup>() { - @Override + public void onFailure(Throwable caught) { CoreGUI.getErrorHandler().handleError(MSG.view_tree_common_createFailed_autoCluster(), caught); }
- @Override public void onSuccess(ResourceGroup result) { renderAutoCluster(result); } @@ -387,7 +407,7 @@ public class ResourceGroupTreeView extends LocatableVLayout implements Bookmarka
treeGrid.setData(tree); treeGrid.getTree().openFolder(rootNode); - treeGrid.markForRedraw(); + treeGrid.selectRecord(rootNode); }
public void loadTree(ResourceGroupEnhancedTreeNode parentNode, ClusterFlyweight parentClusterGroup, @@ -636,5 +656,29 @@ public class ResourceGroupTreeView extends LocatableVLayout implements Bookmarka setAttribute(RESOURCE_TYPE, rt); }
+ public boolean isTopNode() { + return getParentID().equals(FAKE_ROOT_ID); + } + + public boolean isMixedGroupTopNode() { + return isTopNode() && (null == getResourceType()); + } + + public boolean isCompatibleGroupTopNode() { + return isTopNode() && (null != getResourceType()) && (null == getClusterKey()); + } + + public boolean isAutoGroupNode() { + return !isTopNode() && (null != getResourceType()) && (null == getClusterKey()); + } + + public boolean isAutoClusterNode() { + return (null != getResourceType()) && (null != getClusterKey()) && !isTopNode(); + } + + public boolean isSubCategoryNode() { + return (null == getResourceType()) && !isMixedGroupTopNode(); + } + } } 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 9870a42..455f414 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 @@ -115,6 +115,7 @@ public class ResourceTreeView extends LocatableVLayout { setShowResizeBar(true); }
+ @Override public void onInit() { // TODO (ips): Are we intentionally avoiding calling super.onInit() here? If so, why? } @@ -141,6 +142,7 @@ public class ResourceTreeView extends LocatableVLayout { autoGroupContextMenu = new ResourceGroupContextMenu(extendLocatorId("autoGroupContextMenu"));
treeGrid.addSelectionChangedHandler(new SelectionChangedHandler() { + public void onSelectionChanged(SelectionEvent selectionEvent) { if (!selectionEvent.isRightButtonDown() && selectionEvent.getState()) { ListGridRecord selectedRecord = treeGrid.getSelectedRecord(); @@ -168,6 +170,7 @@ public class ResourceTreeView extends LocatableVLayout { AutoGroupTreeNode agNode = (AutoGroupTreeNode) selectedRecord; selectedNodeId = agNode.getID(); getAutoGroupBackingGroup(agNode, new AsyncCallback<ResourceGroup>() { + public void onFailure(Throwable caught) { CoreGUI.getErrorHandler().handleError(MSG.view_tree_common_loadFailed_selection(), caught); @@ -192,27 +195,35 @@ public class ResourceTreeView extends LocatableVLayout { // setContextMenu(resourceContextMenu);
treeGrid.addNodeContextClickHandler(new NodeContextClickHandler() { + public void onNodeContextClick(final NodeContextClickEvent event) { // stop the browser right-click menu event.cancel();
// don't select the node on a right click, since we're not navigating to it treeGrid.deselectRecord(event.getNode()); + TreeNode eventNode = event.getNode(); + + // re-select the current node if necessary if (null != selectedNodeId) { - treeGrid.selectRecord(treeGrid.getTree().findById(selectedNodeId)); + TreeNode selectedNode = treeGrid.getTree().findById(selectedNodeId); + if (!eventNode.equals(selectedNode)) { + treeGrid.selectRecord(selectedNode); + } }
- if (event.getNode() instanceof AutoGroupTreeNode) { - showContextMenu((AutoGroupTreeNode) event.getNode()); - } else if (event.getNode() instanceof ResourceTreeNode) { - if (!((ResourceTreeNode) event.getNode()).isLocked()) { - showContextMenu((ResourceTreeNode) event.getNode()); + if (eventNode instanceof AutoGroupTreeNode) { + showContextMenu((AutoGroupTreeNode) eventNode); + } else if (eventNode instanceof ResourceTreeNode) { + if (!((ResourceTreeNode) eventNode).isLocked()) { + showContextMenu((ResourceTreeNode) eventNode); } } } });
treeGrid.addDataArrivedHandler(new DataArrivedHandler() { + public void onDataArrived(DataArrivedEvent dataArrivedEvent) { updateSelection(); } @@ -236,6 +247,7 @@ public class ResourceTreeView extends LocatableVLayout { criteria.addFilterAutoGroupParentResourceId(agNode.getParentResource().getId()); criteria.addFilterVisible(false); resourceGroupService.findResourceGroupsByCriteria(criteria, new AsyncCallback<PageList<ResourceGroup>>() { + public void onFailure(Throwable caught) { CoreGUI.getErrorHandler().handleError(MSG.view_tree_common_loadFailed_node(), caught); } @@ -315,6 +327,7 @@ public class ResourceTreeView extends LocatableVLayout {
private void showContextMenu(AutoGroupTreeNode agNode) { getAutoGroupBackingGroup(agNode, new AsyncCallback<ResourceGroup>() { + public void onFailure(Throwable caught) { CoreGUI.getErrorHandler().handleError(MSG.view_tree_common_loadFailed_selection(), caught); } @@ -334,6 +347,7 @@ public class ResourceTreeView extends LocatableVLayout { criteria.addFilterId(resourceId); GWTServiceLookup.getResourceService().findResourceCompositesByCriteria(criteria, new AsyncCallback<PageList<ResourceComposite>>() { + public void onFailure(Throwable caught) { CoreGUI.getMessageCenter().notify( new Message(MSG.view_inventory_resource_loadFailed(String.valueOf(resourceId)), @@ -359,6 +373,7 @@ public class ResourceTreeView extends LocatableVLayout { ResourceTypeRepository.MetadataType.resourceConfigurationDefinition, ResourceTypeRepository.MetadataType.measurements), new ResourceTypeRepository.TypeLoadedCallback() { + public void onTypesLoaded(ResourceType type) { buildResourceContextMenu(resourceComposite, type); resourceContextMenu.showContextMenu(); @@ -386,6 +401,7 @@ public class ResourceTreeView extends LocatableVLayout { // plugin config MenuItem pluginConfiguration = new MenuItem(MSG.view_tabs_common_connectionSettings()); pluginConfiguration.addClickHandler(new ClickHandler() { + public void onClick(MenuItemClickEvent event) { CoreGUI.goToView(LinkManager.getResourceTabLink(resource.getId(), "Inventory", "ConnectionSettings")); } @@ -400,6 +416,7 @@ public class ResourceTreeView extends LocatableVLayout { resourceConfiguration.setEnabled(enabled); if (enabled) { resourceConfiguration.addClickHandler(new ClickHandler() { + public void onClick(MenuItemClickEvent event) { CoreGUI.goToView(LinkManager.getResourceTabLink(resource.getId(), "Configuration", "Current")); } @@ -420,6 +437,7 @@ public class ResourceTreeView extends LocatableVLayout { for (final OperationDefinition operationDefinition : resourceType.getOperationDefinitions()) { MenuItem operationItem = new MenuItem(operationDefinition.getDisplayName()); operationItem.addClickHandler(new ClickHandler() { + public void onClick(MenuItemClickEvent event) { CoreGUI.goToView(LinkManager.getResourceTabLink(resource.getId(), ResourceDetailView.Tab.OPERATIONS, ResourceDetailView.OperationsSubTab.SCHEDULES) @@ -445,6 +463,7 @@ public class ResourceTreeView extends LocatableVLayout { MenuItem createItem = new MenuItem(childType.getName());
createItem.addClickHandler(new ClickHandler() { + public void onClick(MenuItemClickEvent event) { ResourceFactoryCreateWizard.showCreateWizard(resource, childType); } @@ -470,6 +489,7 @@ public class ResourceTreeView extends LocatableVLayout { MenuItem importItem = new MenuItem(childType.getName());
importItem.addClickHandler(new ClickHandler() { + public void onClick(MenuItemClickEvent event) { ResourceFactoryImportWizard.showImportWizard(resource, childType); } @@ -497,6 +517,7 @@ public class ResourceTreeView extends LocatableVLayout { criteria.addFilterSupportsManualAdd(true); criteria.fetchParentResourceTypes(true); rts.findResourceTypesByCriteria(criteria, new AsyncCallback<PageList<ResourceType>>() { + public void onFailure(Throwable caught) { CoreGUI.getErrorHandler().handleError(MSG.view_tree_common_contextMenu_loadFailed_manualAddChildren(), caught); @@ -508,6 +529,7 @@ public class ResourceTreeView extends LocatableVLayout { MenuItem item = new MenuItem(type.getName());
item.addClickHandler(new ClickHandler() { + public void onClick(MenuItemClickEvent event) { ResourceFactoryImportWizard.showImportWizard(resource, type); } @@ -527,6 +549,7 @@ public class ResourceTreeView extends LocatableVLayout { DashboardCriteria criteria = new DashboardCriteria(); GWTServiceLookup.getDashboardService().findDashboardsByCriteria(criteria, new AsyncCallback<PageList<Dashboard>>() { + public void onFailure(Throwable caught) { CoreGUI.getErrorHandler().handleError(MSG.view_tree_common_contextMenu_loadFailed_dashboard(), caught); @@ -547,6 +570,7 @@ public class ResourceTreeView extends LocatableVLayout { defSubItem.addItem(addToDBItem);
addToDBItem.addClickHandler(new ClickHandler() { + public void onClick(MenuItemClickEvent menuItemClickEvent) { DashboardPortlet p = new DashboardPortlet(MSG .view_tree_common_contextMenu_resourceGraph(), ResourceGraphPortlet.KEY, 250); @@ -559,6 +583,7 @@ public class ResourceTreeView extends LocatableVLayout {
GWTServiceLookup.getDashboardService().storeDashboard(d, new AsyncCallback<Dashboard>() { + public void onFailure(Throwable caught) { CoreGUI.getErrorHandler().handleError( MSG.view_tree_common_contextMenu_saveChartToDashboardFailure(), @@ -651,6 +676,7 @@ public class ResourceTreeView extends LocatableVLayout { addMember(treeGrid);
treeGrid.fetchData(treeGrid.getCriteria(), new DSCallback() { + public void execute(DSResponse response, Object rawData, DSRequest request) { Log.info("Done fetching data for tree."); updateSelection(); @@ -670,6 +696,7 @@ public class ResourceTreeView extends LocatableVLayout { ResourceTypeRepository.MetadataType.children, ResourceTypeRepository.MetadataType.subCategory), new ResourceTypeRepository.ResourceTypeLoadedCallback() { + public void onResourceTypeLoaded(List<Resource> result) { treeGrid.getTree() .linkNodes(ResourceTreeDatasource.buildNodes(lineage, lockedData)); @@ -710,6 +737,7 @@ public class ResourceTreeView extends LocatableVLayout { criteria.addFilterVisible(false); criteria.fetchResourceType(true); resourceGroupService.findResourceGroupsByCriteria(criteria, new AsyncCallback<PageList<ResourceGroup>>() { + public void onFailure(Throwable caught) { CoreGUI.getErrorHandler().handleError(MSG.view_tree_common_loadFailed_node(), caught); } @@ -719,12 +747,10 @@ public class ResourceTreeView extends LocatableVLayout { // load the tree up to the autogroup's parent resource loadTree(backingGroup.getAutoGroupParentResource().getId(), new AsyncCallback<Void>() {
- @Override public void onFailure(Throwable caught) { CoreGUI.getErrorHandler().handleError(MSG.view_tree_common_loadFailed_children(), caught); }
- @Override public void onSuccess(Void arg) { // get the node ID and use it to add a map entry, then call this again to finish up... selectedNodeId = AutoGroupTreeNode.idOf(backingGroup.getAutoGroupParentResource(),
commit 22f96df0829e252b3c3de748bbddc7a5d7710704 Author: Jay Shaughnessy jshaughn@redhat.com Date: Fri Mar 25 11:13:55 2011 -0400
Selenium - Make the Login and Registration dialogs locatable.
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 3a5fa85..865793a 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,7 +39,6 @@ import com.smartgwt.client.widgets.HTMLFlow; import com.smartgwt.client.widgets.IButton; import com.smartgwt.client.widgets.Img; import com.smartgwt.client.widgets.Label; -import com.smartgwt.client.widgets.Window; import com.smartgwt.client.widgets.events.ClickEvent; import com.smartgwt.client.widgets.events.ClickHandler; import com.smartgwt.client.widgets.form.DynamicForm; @@ -69,6 +68,7 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableCanvas; 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; +import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableWindow;
/** * @author Greg Hinkle @@ -78,8 +78,8 @@ public class LoginView extends LocatableCanvas {
private static boolean loginShowing = false;
- private Window window; - private DynamicForm form; + private LocatableWindow window; + private LocatableDynamicForm form; private LocatableDynamicForm inputForm;
private SubmitItem loginButton; @@ -157,7 +157,7 @@ public class LoginView extends LocatableCanvas {
form.setFields(logo, header, new RowSpacerItem(), user, password, loginButton);
- window = new Window(); + window = new LocatableWindow(extendLocatorId("LoginWindow")); window.setWidth(400); window.setHeight(275); window.setTitle(MSG.common_title_welcome()); @@ -367,7 +367,7 @@ public class LoginView extends LocatableCanvas { row.addMember(logoutLabel); column.addMember(row);
- window = new Window(); + window = new LocatableWindow(extendLocatorId("RegistrationWindow")); window.setWidth(670); window.setHeight(330); window.setTitle(MSG.view_login_registerUser());
commit 12051d6e7026198b07aa7f9e8176488ebfd27986 Author: Simeon Pinder spinder@redhat.com Date: Fri Mar 25 01:14:11 2011 -0400
i)number Resource/Group*Portlet refresh/redraw fixes ii)general cleanup of some porlet classes.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletConfigurationDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletConfigurationDataSource.java index ae9069b..2cb7f74 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletConfigurationDataSource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletConfigurationDataSource.java @@ -134,16 +134,15 @@ public class AlertPortletConfigurationDataSource extends AlertDataSource { criteria.addFilterPriorities(filterPriorities); } } + PageControl pc = new PageControl(); //result sort order property = portletConfig.getSimple(Constant.RESULT_SORT_ORDER); if (property != null) { String currentSetting = property.getStringValue(); if (currentSetting.trim().isEmpty() || currentSetting.equalsIgnoreCase(PageOrdering.DESC.name())) { - criteria.addSortCtime(PageOrdering.DESC); pc.setPrimarySortOrder(PageOrdering.DESC); } else { - criteria.addSortCtime(PageOrdering.ASC); pc.setPrimarySortOrder(PageOrdering.ASC); } } @@ -186,8 +185,8 @@ public class AlertPortletConfigurationDataSource extends AlertDataSource { property = portletConfig.getSimple(Constant.RESULT_COUNT); if (property != null) { String currentSetting = property.getStringValue(); - if (currentSetting.trim().isEmpty() || currentSetting.equalsIgnoreCase("5")) { - pc.setPageSize(5); + if (currentSetting.trim().isEmpty() || currentSetting.equalsIgnoreCase(Constant.RESULT_COUNT_DEFAULT)) { + pc.setPageSize(Integer.valueOf(Constant.RESULT_COUNT_DEFAULT)); } else { pc.setPageSize(Integer.valueOf(currentSetting)); } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet.java index 740d549..6ac9afe 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet.java @@ -75,6 +75,7 @@ public class GroupAlertsPortlet extends AlertHistoryView implements CustomSettin public static final String RESOURCES_SELECTED = MSG.common_label_selected_resources(); public static final String defaultResourceValue = RESOURCES_ALL; public static final String ID = "id"; + private boolean currentlyRefreshing = false;
// set on initial configuration, the window for this portlet view. protected PortletWindow portletWindow; @@ -269,7 +270,7 @@ public class GroupAlertsPortlet extends AlertHistoryView implements CustomSettin }
public boolean isRefreshing() { - return false; + return this.currentlyRefreshing; }
@Override @@ -320,7 +321,6 @@ public class GroupAlertsPortlet extends AlertHistoryView implements CustomSettin protected void onInit() { super.onInit(); initializeUi(); - // getListGrid().setEmptyMessage(MSG.view_portlet_results_empty()); }
@Override @@ -332,6 +332,12 @@ public class GroupAlertsPortlet extends AlertHistoryView implements CustomSettin MSG.view_table_matchingRows(String.valueOf(getListGrid().getTotalRows()), String.valueOf(count))); } } + + @Override + public void redraw() { + super.redraw(); + refresh();//is table so need to call this to reload + } }
/** Bundles a ResourceSelector instance with labeling in Canvas for display. diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupBundleDeploymentsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupBundleDeploymentsPortlet.java index 4d163ab..6ef8a59 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupBundleDeploymentsPortlet.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupBundleDeploymentsPortlet.java @@ -215,6 +215,7 @@ public class GroupBundleDeploymentsPortlet extends LocatableVLayout implements C public void onFailure(Throwable caught) { Log.debug("Error retrieving installed bundle deployments for group [" + groupId + "]:" + caught.getMessage()); + currentlyLoading = false; }
@Override @@ -258,6 +259,7 @@ public class GroupBundleDeploymentsPortlet extends LocatableVLayout implements C recentBundleDeployContent.addChild(column); recentBundleDeployContent.markForRedraw(); markForRedraw(); + currentlyLoading = false; } }); } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupEventsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupEventsPortlet.java index 3b069c5..b4761e9 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupEventsPortlet.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupEventsPortlet.java @@ -103,6 +103,8 @@ public class GroupEventsPortlet extends LocatableVLayout implements CustomSettin @Override protected void onInit() { super.onInit(); + //disable the refresh timer for this run + currentlyLoading = true; initializeUi(); redraw(); } @@ -151,7 +153,6 @@ public class GroupEventsPortlet extends LocatableVLayout implements CustomSettin }
protected void loadData() { - currentlyLoading = true; getRecentEventUpdates(); }
@@ -235,6 +236,7 @@ public class GroupEventsPortlet extends LocatableVLayout implements CustomSettin Log .debug("Error retrieving recent event counts for group [" + groupId + "]:" + caught.getMessage()); + setCurrentlyRefreshing(false); }
@Override @@ -288,12 +290,14 @@ public class GroupEventsPortlet extends LocatableVLayout implements CustomSettin recentEventsContent.addChild(column); recentEventsContent.markForRedraw(); markForRedraw(); + setCurrentlyRefreshing(false); } }); }
public void startRefreshCycle() { refreshTimer = AutoRefreshPortletUtil.startRefreshCycle(this, this, refreshTimer); + markForRedraw(); }
@Override @@ -303,6 +307,7 @@ public class GroupEventsPortlet extends LocatableVLayout implements CustomSettin super.onDestroy(); }
+ @Override public boolean isRefreshing() { return this.currentlyLoading; } @@ -312,4 +317,8 @@ public class GroupEventsPortlet extends LocatableVLayout implements CustomSettin super.redraw(); loadData(); } + + protected void setCurrentlyRefreshing(boolean currentlyRefreshing) { + this.currentlyLoading = currentlyRefreshing; + } } \ No newline at end of file diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupMetricsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupMetricsPortlet.java index 898c04b..d6dbf19 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupMetricsPortlet.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupMetricsPortlet.java @@ -121,6 +121,7 @@ public class GroupMetricsPortlet extends LocatableVLayout implements CustomSetti @Override protected void onInit() { super.onInit(); + setRefreshing(true); initializeUi(); loadData(); } @@ -274,6 +275,7 @@ public class GroupMetricsPortlet extends LocatableVLayout implements CustomSetti public void onFailure(Throwable caught) { Log.debug("Error retrieving resource group composite for group [" + groupId + "]:" + caught.getMessage()); + setRefreshing(false); }
@Override @@ -325,6 +327,7 @@ public class GroupMetricsPortlet extends LocatableVLayout implements CustomSetti Log .debug("Error retrieving recent metrics charting data for group [" + groupId + "]:" + caught.getMessage()); + setRefreshing(false); }
@Override @@ -433,6 +436,7 @@ public class GroupMetricsPortlet extends LocatableVLayout implements CustomSetti AbstractActivityView.RECENT_MEASUREMENTS_NONE); column.addMember(row); } + setRefreshing(false); } }); } @@ -442,6 +446,7 @@ public class GroupMetricsPortlet extends LocatableVLayout implements CustomSetti LocatableDynamicForm row = AbstractActivityView.createEmptyDisplayRow(recentMeasurementsContent .extendLocatorId("None"), AbstractActivityView.RECENT_MEASUREMENTS_NONE); column.addMember(row); + setRefreshing(false); } } }); @@ -454,8 +459,12 @@ public class GroupMetricsPortlet extends LocatableVLayout implements CustomSetti recentMeasurementsContent.markForRedraw(); }
+ @Override public void startRefreshCycle() { refreshTimer = AutoRefreshPortletUtil.startRefreshCycle(this, this, refreshTimer); + //call out to 3rd party javascript lib + BrowserUtility.graphSparkLines(); + recentMeasurementsContent.markForRedraw(); }
@Override @@ -465,6 +474,7 @@ public class GroupMetricsPortlet extends LocatableVLayout implements CustomSetti super.onDestroy(); }
+ @Override public boolean isRefreshing() { return this.currentlyLoading; } @@ -486,4 +496,8 @@ public class GroupMetricsPortlet extends LocatableVLayout implements CustomSetti public String getBaseViewPath() { return baseViewPath; } + + protected void setRefreshing(boolean currentlyRefreshing) { + this.currentlyLoading = currentlyRefreshing; + } } \ No newline at end of file diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOobsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOobsPortlet.java index 265e200..008c34b 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOobsPortlet.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOobsPortlet.java @@ -204,6 +204,7 @@ public class GroupOobsPortlet extends LocatableVLayout implements CustomSettings public void onFailure(Throwable caught) { Log.debug("Error retrieving recent out of bound metrics for group [" + groupId + "]:" + caught.getMessage()); + currentlyLoading = false; }
@Override @@ -238,12 +239,14 @@ public class GroupOobsPortlet extends LocatableVLayout implements CustomSettings } recentOobContent.addChild(column); recentOobContent.markForRedraw(); + currentlyLoading = false; } }); }
public void startRefreshCycle() { refreshTimer = AutoRefreshPortletUtil.startRefreshCycle(this, this, refreshTimer); + recentOobContent.markForRedraw(); }
@Override diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOperationsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOperationsPortlet.java index 10031d1..9a9a124 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOperationsPortlet.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOperationsPortlet.java @@ -78,6 +78,7 @@ public class GroupOperationsPortlet extends LocatableVLayout implements CustomSe public static final String NAME = MSG.view_portlet_defaultName_group_operations();
protected static final String ID = "id"; + protected boolean currentlyRefreshing = false;
// set on initial configuration, the window for this portlet view. protected PortletWindow portletWindow; @@ -126,6 +127,8 @@ public class GroupOperationsPortlet extends LocatableVLayout implements CustomSe @Override protected void onInit() { super.onInit(); + //disable the refresh timer for this run + currentlyRefreshing = true; initializeUi(); loadData(); } @@ -157,6 +160,7 @@ public class GroupOperationsPortlet extends LocatableVLayout implements CustomSe public void onFailure(Throwable caught) { Log.debug("Error retrieving resource group composite for group [" + groupId + "]:" + caught.getMessage()); + currentlyRefreshing = false; }
@Override @@ -186,6 +190,7 @@ public class GroupOperationsPortlet extends LocatableVLayout implements CustomSe } recentOperationsContent.addChild(groupOperations); recentOperationsContent.markForRedraw(); + currentlyRefreshing = false; } }); } @@ -308,7 +313,7 @@ public class GroupOperationsPortlet extends LocatableVLayout implements CustomSe }
public boolean isRefreshing() { - return false; + return currentlyRefreshing; }
private boolean isAutoGroup() { @@ -328,6 +333,10 @@ public class GroupOperationsPortlet extends LocatableVLayout implements CustomSe super.redraw(); loadData(); } + + protected void setCurrentlyRefreshing(boolean currentlyRefreshing) { + this.currentlyRefreshing = currentlyRefreshing; + } }
/** Provide implementation of GroupOperationsHistoryListView using datasource diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupPkgHistoryPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupPkgHistoryPortlet.java index e58b1da..da5a0ee 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupPkgHistoryPortlet.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupPkgHistoryPortlet.java @@ -213,6 +213,7 @@ public class GroupPkgHistoryPortlet extends LocatableVLayout implements CustomSe public void onFailure(Throwable caught) { Log.debug("Error retrieving installed package history for group [" + groupId + "]:" + caught.getMessage()); + currentlyLoading = false; }
@Override @@ -255,6 +256,7 @@ public class GroupPkgHistoryPortlet extends LocatableVLayout implements CustomSe recentPkgHistoryContent.addChild(column); recentPkgHistoryContent.markForRedraw(); markForRedraw(); + currentlyLoading = false; } }); } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceAlertsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceAlertsPortlet.java index c79b9f9..ff3a9939 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceAlertsPortlet.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceAlertsPortlet.java @@ -20,16 +20,11 @@ package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.resource;
import com.google.gwt.user.client.History; import com.smartgwt.client.widgets.Canvas; -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.ListGridRecord;
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.CoreGUI; -import org.rhq.enterprise.gui.coregui.client.LinkManager; import org.rhq.enterprise.gui.coregui.client.Messages; import org.rhq.enterprise.gui.coregui.client.alert.AlertPortletConfigurationDataSource; import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet; @@ -139,10 +134,6 @@ public class ResourceAlertsPortlet extends GroupAlertsPortlet {
}
- public AlertPortletConfigurationDataSource getDataSource() { - return dataSource; - } - public static final class Factory implements PortletViewFactory { public static PortletViewFactory INSTANCE = new Factory();
@@ -151,34 +142,6 @@ public class ResourceAlertsPortlet extends GroupAlertsPortlet { return new ResourceAlertsPortlet(locatorId); } } - - @Override - protected void configureTable() { - super.configureTable(); - - setListGridDoubleClickHandler(new DoubleClickHandler() { - @Override - public void onDoubleClick(DoubleClickEvent event) { - ListGrid listGrid = (ListGrid) event.getSource(); - ListGridRecord[] selectedRows = listGrid.getSelection(); - if (selectedRows != null && selectedRows.length == 1) { - Integer recordId = getId(selectedRows[0]); - Integer resourceId = selectedRows[0].getAttributeAsInt("resourceId"); - CoreGUI.goToView(LinkManager.getSubsystemAlertHistoryLink(resourceId, recordId)); - } - } - }); - } - - @Override - protected void refreshTableInfo() { - super.refreshTableInfo(); - if (getTableInfo() != null) { - int count = getListGrid().getSelection().length; - getTableInfo().setContents( - MSG.view_table_matchingRows(String.valueOf(getListGrid().getTotalRows()), String.valueOf(count))); - } - } }
/** Bundles a ResourceSelector instance with labeling in Canvas for display. diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceMetricsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceMetricsPortlet.java index e907ce6..a77796f 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceMetricsPortlet.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceMetricsPortlet.java @@ -164,6 +164,7 @@ public class ResourceMetricsPortlet extends GroupMetricsPortlet { public void onFailure(Throwable caught) { Log.debug("Error retrieving resource resource composite for resource [" + resourceId + "]:" + caught.getMessage()); + setRefreshing(false); }
@Override @@ -214,6 +215,7 @@ public class ResourceMetricsPortlet extends GroupMetricsPortlet { Log .debug("Error retrieving recent metrics charting data for resource [" + resourceId + "]:" + caught.getMessage()); + setRefreshing(false); }
@Override @@ -322,11 +324,11 @@ public class ResourceMetricsPortlet extends GroupMetricsPortlet { AbstractActivityView.RECENT_MEASUREMENTS_NONE); column.addMember(row); } + setRefreshing(false); } }); } }); - // } } } }); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceOperationsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceOperationsPortlet.java index c584aaa..a0ef80ffba 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceOperationsPortlet.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceOperationsPortlet.java @@ -84,7 +84,7 @@ public class ResourceOperationsPortlet extends GroupOperationsPortlet {
@Override protected void onInit() { - // super.onInit(); + setCurrentlyRefreshing(true); initializeUi(); loadData(); } @@ -165,6 +165,7 @@ public class ResourceOperationsPortlet extends GroupOperationsPortlet { public void onFailure(Throwable caught) { Log.debug("Error retrieving resource composite for resource [" + resourceId + "]:" + caught.getMessage()); + setCurrentlyRefreshing(false); }
@Override @@ -186,6 +187,7 @@ public class ResourceOperationsPortlet extends GroupOperationsPortlet { recentOperationsContent.addChild(resourceOperations); recentOperationsContent.markForRedraw(); } + setCurrentlyRefreshing(false); } }); }
commit e5b698ed50fdd6638999cb6e1ebcb2d63e1a6194 Author: John Mazzitelli mazz@redhat.com Date: Thu Mar 24 15:54:48 2011 -0400
be more fault tolerant of invalid portlets that might be in the DB. this happens during development as portlets are changed and removed. could also happen when upgrading to a new version of RHQ that removed a 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 fa76473..520a948 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 @@ -24,7 +24,11 @@ import java.util.HashMap; import java.util.List; import java.util.Map;
+import com.smartgwt.client.widgets.Canvas; +import com.smartgwt.client.widgets.Label; + import org.rhq.core.domain.dashboard.DashboardPortlet; +import org.rhq.enterprise.gui.coregui.client.CoreGUI; import org.rhq.enterprise.gui.coregui.client.ImageManager; import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupAlertsPortlet; import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupBundleDeploymentsPortlet; @@ -53,6 +57,8 @@ import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.summary.Inventor import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.summary.TagCloudPortlet; import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.util.MashupPortlet; import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.util.MessagePortlet; +import org.rhq.enterprise.gui.coregui.client.util.message.Message; +import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity;
/** * @author Simeon Pinder @@ -177,9 +183,31 @@ public class PortletFactory { PortletViewFactory viewFactory = registeredPortletFactoryMap.get(storedPortlet.getPortletKey()); if (viewFactory == null) {//check group view factory viewFactory = registeredGroupPortletFactoryMap.get(storedPortlet.getPortletKey()); - } - if (viewFactory == null) {//check resource view factory - viewFactory = registeredResourcePortletFactoryMap.get(storedPortlet.getPortletKey()); + + if (viewFactory == null) {//check resource view factory + viewFactory = registeredResourcePortletFactoryMap.get(storedPortlet.getPortletKey()); + + if (viewFactory == null) { + Message msg = new Message("Bad portlet: " + storedPortlet, Severity.Warning); + CoreGUI.getMessageCenter().notify(msg); + class InvalidPortlet extends Label implements Portlet { + InvalidPortlet() { + super(CoreGUI.getMessages().view_portlet_factory_invalidPortlet()); + } + + @Override + public Canvas getHelpCanvas() { + return new Label(getContents()); + } + + @Override + public void configure(PortletWindow portletWindow, DashboardPortlet storedPortlet) { + } + } + ; + return new InvalidPortlet(); + } + } }
Portlet view = viewFactory.getInstance(locatorId); diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties index a149de8..b8ce183 100644 --- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties +++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties @@ -1442,6 +1442,8 @@ view_dashboards_portlets_refresh_success2=Stopping reload for portlets that auto view_dashboardsManager_error1 = Failed to add new dashboard view_dashboardsManager_message_title_details = <h1>Welcome to RHQ</h1>\n<p>The RHQ project is an abstraction and plug-in based systems management suite that provides extensible and integrated systems management for multiple products and platforms across a set of core features. The project is designed with layered modules that provide a flexible architecture for deployment. It delivers a core user interface that delivers audited and historical management across an entire enterprise. A Server/Agent architecture provides remote management and plugins implement all specific support for managed products.</p>\n <p>This default dashboard can be edited by clicking the (edit mode) button above.</p>
+view_portlet_factory_invalidPortlet = This is an obsolete portlet that is no longer valid. Please delete it. + view_portlet_defaultName_autodiscovery = Discovery Queue view_portlet_defaultName_favoriteResources = Favorite Resources view_portlet_defaultName_resourceMetric = Resource Metric Graph
commit c599feb1ee9146f09f14db319efd07a4b7c6acd7 Author: John Mazzitelli mazz@redhat.com Date: Thu Mar 24 15:49:55 2011 -0400
remove the ~, which was our old marker we used to use
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties index 56b7270..a149de8 100644 --- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties +++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties @@ -1418,7 +1418,7 @@ view_type_typeTreeLoadFailure = Failed to load resource type tree data
# Tabs view_tabs_invalidSubTab = Invalid subtab: {0} -view_tabs_invalidTab = Invalid tab: {0}~ +view_tabs_invalidTab = Invalid tab: {0}
# Group Tree group_tree_partialClusterTooltip = {0} out of {1} group members have a ''{2}'' resource @@ -1513,7 +1513,7 @@ view_portlet_operations_config_scheduled_enable = Whether to enable scheduled op view_portlet_operations_config_scheduled_maximum = Maximum number of Scheduled operations to display. view_portlet_operations_config_completed = completed operations view_portlet_operations_config_show_last = show Last -view_portlet_operations_config_show_next = show Next~ +view_portlet_operations_config_show_next = show Next view_portlet_operations_disabled = (Results currently disabled. Change settings to enable results.
view_portlet_platform_platform_error_1 = Failed to load platform metrics
commit 5ef481fe24f2a468ade1ca50eccce7f1a606916e Author: John Mazzitelli mazz@redhat.com Date: Thu Mar 24 12:00:41 2011 -0400
be able to not specify a width. this isn't used today, but can be in the future - just pass in a negative width
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/AncestryUtil.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/AncestryUtil.java index e28dab2..2393132 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/AncestryUtil.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/AncestryUtil.java @@ -341,11 +341,20 @@ public abstract class AncestryUtil { Map<Integer, ResourceType> types = ((MapWrapper) record.getAttributeAsObject(RESOURCE_ANCESTRY_TYPES)).getMap(); Integer resourceTypeId = record.getAttributeAsInt(RESOURCE_TYPE_ID); ResourceType type = types.get(resourceTypeId); - width = (width <= 0) ? 500 : width;
- StringBuilder sb = new StringBuilder("<p style='width:"); - sb.append(width); - sb.append("px'>"); + // note: if width is negative, we do not explicitly define a width in the HTML, thus enabling auto-resizing. + Integer widthObj = null; + if (width >= 0) { + widthObj = (width == 0) ? Integer.valueOf(500) : Integer.valueOf(width); + } + + StringBuilder sb = new StringBuilder("<p"); + if (widthObj != null) { + sb.append(" style='width:"); + sb.append(widthObj.toString()); + sb.append("px'"); + } + sb.append(">");
sb.append(getResourceLongName(resourceName, type));
commit 9b0627038c5f77cf610d74acd993b6953e12a68a Author: John Mazzitelli mazz@redhat.com Date: Thu Mar 24 11:54:47 2011 -0400
BZ 609135 - fix the favorites button so its context menu is popped up at the bottom of the button, like a typical context menu.
also get the ancestry items to be auto-sized
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 ba5e649..fd45110 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 @@ -70,8 +70,11 @@ public class FavoritesButton extends LocatableIMenuButton { final Menu favoriteGroupsMenu = new Menu(); final Menu recentlyViewedMenu = new Menu(); favoriteResourcesMenu.setSubmenuDirection("left"); + favoriteResourcesMenu.setAutoWidth(); favoriteGroupsMenu.setSubmenuDirection("left"); + favoriteGroupsMenu.setAutoWidth(); recentlyViewedMenu.setSubmenuDirection("left"); + recentlyViewedMenu.setAutoWidth(); MenuItem favoriteResourcesMenuItem = new MenuItem(MSG.favorites_resources(), "Favorite_Resource_16.png"); favoriteResourcesMenuItem.setSubmenu(favoriteResourcesMenu); favoriteResourcesMenu.setEmptyMessage(MSG.common_val_none()); @@ -102,7 +105,7 @@ public class FavoritesButton extends LocatableIMenuButton { // if we have no menu items at all, then show the empty menu now if (favoriteGroupIds.isEmpty() && favoriteResourceIds.isEmpty() && recentResourceIds.isEmpty() && recentGroupIds.isEmpty()) { - favoritesMenu.showContextMenu(); + favoritesMenu.showNextTo(FavoritesButton.this, "bottom"); return; }
@@ -149,7 +152,7 @@ public class FavoritesButton extends LocatableIMenuButton { buildRecentlyViewedMenu(favorites, recentlyViewedMenu, recentResourceIds, recentGroupIds, typesWrapper);
- favoritesMenu.showContextMenu(); + favoritesMenu.showNextTo(FavoritesButton.this, "bottom"); } }); } @@ -185,9 +188,11 @@ public class FavoritesButton extends LocatableIMenuButton { item.setAttribute(AncestryUtil.RESOURCE_TYPE_ID, resource.getResourceType().getId()); item.setAttribute(AncestryUtil.RESOURCE_ANCESTRY_TYPES, typesWrapper); Menu ancestryMenu = new Menu(); - MenuItem ancestryItem = new MenuItem(AncestryUtil.getAncestryHoverHTML(item, 0)); + MenuItem ancestryItem = new MenuItem(AncestryUtil.getAncestryHoverHTML(item, -1)); ancestryItem.setEnabled(false); ancestryMenu.setItems(ancestryItem); + ancestryMenu.setSubmenuDirection("left"); + ancestryMenu.setAutoWidth(); item.setSubmenu(ancestryMenu);
item.addClickHandler(new com.smartgwt.client.widgets.menu.events.ClickHandler() { @@ -260,9 +265,11 @@ public class FavoritesButton extends LocatableIMenuButton { item.setAttribute(AncestryUtil.RESOURCE_ANCESTRY_TYPES, typesWrapper);
Menu ancestryMenu = new Menu(); - MenuItem ancestryItem = new MenuItem(AncestryUtil.getAncestryHoverHTML(item, 0)); + MenuItem ancestryItem = new MenuItem(AncestryUtil.getAncestryHoverHTML(item, -1)); ancestryItem.setEnabled(false); ancestryMenu.setItems(ancestryItem); + ancestryMenu.setSubmenuDirection("left"); + ancestryMenu.setAutoWidth(); item.setSubmenu(ancestryMenu);
item.addClickHandler(new com.smartgwt.client.widgets.menu.events.ClickHandler() { diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/AncestryUtil.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/AncestryUtil.java index 20d9937..e28dab2 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/AncestryUtil.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/AncestryUtil.java @@ -259,12 +259,20 @@ public abstract class AncestryUtil { ResourceType type = types.get(resourceTypeId); String resourceLongName = getResourceLongName(resourceName, type);
- width = (width <= 0) ? 500 : width; + // note: if width is negative, we do not explicitly define a width in the HTML, thus enabling auto-resizing. + Integer widthObj = null; + if (width >= 0) { + widthObj = (width == 0) ? Integer.valueOf(500) : Integer.valueOf(width); + }
// decode ancestry - StringBuilder sb = new StringBuilder("<p style='width:"); - sb.append(width); - sb.append("px'>"); + StringBuilder sb = new StringBuilder("<p"); + if (widthObj != null) { + sb.append(" style='width:"); + sb.append(widthObj.toString()); + sb.append("px'"); + } + sb.append(">"); String title = (null != ancestry) ? TITLE_ANCESTRY : TITLE_PLATFORM; sb.append(title); sb.append(resourceLongName);
commit 0fb1eb897c78c2fb00941619699a837351399f35 Author: John Mazzitelli mazz@redhat.com Date: Thu Mar 24 10:53:21 2011 -0400
forgot these two classes as part of the datasource refactoring to have separate getFetchCriteria method
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletConfigurationDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletConfigurationDataSource.java index efb48d4..ae9069b 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletConfigurationDataSource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletConfigurationDataSource.java @@ -81,8 +81,34 @@ public class AlertPortletConfigurationDataSource extends AlertDataSource { /** Override the executeFetch for AlertPortlet to allow specifying smaller than total * result displays. */ - protected void executeFetch(final DSRequest request, final DSResponse response) { + @Override + protected void executeFetch(final DSRequest request, final DSResponse response, final AlertCriteria criteria) { final long start = System.currentTimeMillis(); + + getAlertService().findAlertsByCriteria(criteria, new AsyncCallback<PageList<Alert>>() { + + public void onFailure(Throwable caught) { + CoreGUI.getErrorHandler().handleError(MSG.view_alerts_loadFailed(), caught); + response.setStatus(RPCResponse.STATUS_FAILURE); + processResponse(request.getRequestId(), response); + } + + public void onSuccess(PageList<Alert> result) { + long fetchTime = System.currentTimeMillis() - start; + Log.info(result.size() + " alerts fetched in: " + fetchTime + "ms"); + if (entityContext.type != EntityContext.Type.Resource) { + dataRetrieved(result, response, request); + } else { + response.setData(buildRecords(result)); + response.setTotalRows(result.size()); + processResponse(request.getRequestId(), response); + } + } + }); + } + + @Override + protected AlertCriteria getFetchCriteria(DSRequest request) { AlertCriteria criteria = new AlertCriteria(); //initialize to only five for quick queries. criteria.setPageControl(new PageControl(0, Integer @@ -176,27 +202,7 @@ public class AlertPortletConfigurationDataSource extends AlertDataSource { } criteria.fetchAlertDefinition(true); criteria.fetchRecoveryAlertDefinition(true); - - getAlertService().findAlertsByCriteria(criteria, new AsyncCallback<PageList<Alert>>() { - - public void onFailure(Throwable caught) { - CoreGUI.getErrorHandler().handleError(MSG.view_alerts_loadFailed(), caught); - response.setStatus(RPCResponse.STATUS_FAILURE); - processResponse(request.getRequestId(), response); - } - - public void onSuccess(PageList<Alert> result) { - long fetchTime = System.currentTimeMillis() - start; - Log.info(result.size() + " alerts fetched in: " + fetchTime + "ms"); - if (entityContext.type != EntityContext.Type.Resource) { - dataRetrieved(result, response, request); - } else { - response.setData(buildRecords(result)); - response.setTotalRows(result.size()); - processResponse(request.getRequestId(), response); - } - } - }); + return criteria; }
public String getAlertResourcesToUse() { 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 f80a435..a2d0aba 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 @@ -35,11 +35,8 @@ public class AlertPortletDataSource extends AlertDataSource { 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(); + @Override + protected AlertCriteria getFetchCriteria(DSRequest request) { //retrieve previous settings from portlet config if ((portlet != null) && (this.portlet instanceof DashboardPortlet)) { //must check for whether portlet config @@ -86,6 +83,14 @@ public class AlertPortletDataSource extends AlertDataSource { criteria.addFilterPriorities(AlertPriority.getByLegacyIndex(getAlertPriorityIndex())); }
+ return criteria; + } + + /** Override the executeFetch for AlertPortlet to allow specifying smaller than total + * result displays. + */ + @Override + protected void executeFetch(final DSRequest request, final DSResponse response, final AlertCriteria criteria) { getAlertService().findAlertsByCriteria(criteria, new AsyncCallback<PageList<Alert>>() {
public void onFailure(Throwable caught) {
commit 771b04e9238e84bb9f269a552b1af837ee33ad85 Author: Lukas Krejci lkrejci@redhat.com Date: Thu Mar 24 15:13:50 2011 +0100
BZ 689833 - fixing the discovery regression. The original fix for this bug caused the discovery to be unable to determine the name to use for the localhost entry.
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/HttpdAddressUtility.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/HttpdAddressUtility.java index 6b9e686..873d5b8 100644 --- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/HttpdAddressUtility.java +++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/HttpdAddressUtility.java @@ -369,7 +369,8 @@ public enum HttpdAddressUtility { }
if (address.host == null || address.isHostDefault() || address.isHostWildcard()) { - address = getLocalhost(address.port); + Address localhost = getLocalhost(address.port); + address.host = localhost.host; }
updateWithServerName(address, ag);
commit f1560f9c48866f34949566ce368e0288d3d72757 Author: Simeon Pinder spinder@redhat.com Date: Thu Mar 24 00:31:35 2011 -0400
i)fix for default portlet list for mixed groups ii)fix for relativeDuration display
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletConfigurationDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletConfigurationDataSource.java index 5396bc0..efb48d4 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletConfigurationDataSource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletConfigurationDataSource.java @@ -87,6 +87,7 @@ public class AlertPortletConfigurationDataSource extends AlertDataSource { //initialize to only five for quick queries. criteria.setPageControl(new PageControl(0, Integer .valueOf(PortletConfigurationEditorComponent.Constant.RESULT_COUNT_DEFAULT))); + //retrieve previous settings from portlet config if ((portlet != null) && (this.portlet instanceof DashboardPortlet)) { Configuration portletConfig = configuration; @@ -160,10 +161,8 @@ public class AlertPortletConfigurationDataSource extends AlertDataSource { if (property != null) { String currentSetting = property.getStringValue(); if (currentSetting.trim().isEmpty() || currentSetting.equalsIgnoreCase("5")) { - PageControl pageControl = new PageControl(0, 5); pc.setPageSize(5); } else { - PageControl pageControl = new PageControl(0, Integer.valueOf(currentSetting)); pc.setPageSize(Integer.valueOf(currentSetting)); } } 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 e8ee80c..4c19ac1 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 @@ -515,9 +515,14 @@ public class DashboardView extends LocatableVLayout { //filter out portlets not relevent for facets Set<ResourceTypeFacet> facets = composite.getResourceFacets().getFacets(); GroupCategory groupCategory = composite.getResourceGroup().getGroupCategory(); - // ResourceGroup group = composite.getResourceGroup(); - //compatible if not a compatible group may need to do some pruning. + //if not a compatible group may need to do some pruning. if (groupCategory != GroupCategory.COMPATIBLE) { + groupKeyNameMap.remove(GroupOperationsPortlet.KEY); + groupKeyNameMap.remove(GroupMetricsPortlet.KEY); + groupKeyNameMap.remove(GroupOobsPortlet.KEY); + groupKeyNameMap.remove(GroupPkgHistoryPortlet.KEY); + } else { + //for compatible may still need to do some pruning. if (!facets.isEmpty()) { //Operations related portlets(Config,PkgHistory) if (!facets.contains(ResourceTypeFacet.OPERATION)) { @@ -533,12 +538,8 @@ public class DashboardView extends LocatableVLayout { groupKeyNameMap.remove(GroupPkgHistoryPortlet.KEY); } } - // //EVENT related portlets - // if (!facets.contains(ResourceTypeFacet.EVENT)) { - // groupKeyNameMap.remove(GroupEventsPortlet.KEY); - // } - } + } return groupKeyNameMap; } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/GwtRelativeDurationConverter.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/GwtRelativeDurationConverter.java index 1679e3f..803df4c 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/GwtRelativeDurationConverter.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/GwtRelativeDurationConverter.java @@ -32,13 +32,15 @@ public class GwtRelativeDurationConverter { public static TimeZone tz = null;
public static String format(long eventMillis) { - int dayOfYearToday = Integer.parseInt(dayFormatter.format(new Date(System.currentTimeMillis()))); + long now = System.currentTimeMillis(); + int dayOfYearToday = Integer.parseInt(dayFormatter.format(new Date(now))); int dayOfYearEvent = Integer.parseInt(dayFormatter.format(new Date(eventMillis))); String result = null; - if (dayOfYearEvent == dayOfYearToday) { + //add additional check to fix when dayOfYear and dayOfYearToday is same but month apart. + if ((dayOfYearEvent == dayOfYearToday) & ((now - eventMillis) < MILLIS_IN_DAY)) { // <time> result = formatter.format(new Date(eventMillis)); - } else if (dayOfYearEvent == dayOfYearToday - 1) { + } else if ((dayOfYearEvent == dayOfYearToday - 1) & ((now - eventMillis) < MILLIS_IN_DAY * 28)) { // "yesterday" <time> result = MSG.common_label_yesterday() + ", " + formatter.format(new Date(eventMillis)); } else {
commit 7a2b59a994595f2d2aa7a340b4c2ce4a99651539 Author: Simeon Pinder spinder@redhat.com Date: Wed Mar 23 20:56:25 2011 -0400
BZ 689992: adding ability to update start/stop max times for jbossAs5 plugin.
diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerOperationsDelegate.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerOperationsDelegate.java index 5f7ae4f..f58051e 100644 --- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerOperationsDelegate.java +++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerOperationsDelegate.java @@ -34,7 +34,9 @@ import org.mc4j.ems.connection.EmsConnection; import org.mc4j.ems.connection.bean.EmsBean; import org.mc4j.ems.connection.bean.operation.EmsOperation; import org.mc4j.ems.connection.bean.parameter.EmsParameter; + import org.rhq.core.domain.configuration.Configuration; +import org.rhq.core.domain.configuration.PropertySimple; import org.rhq.core.domain.measurement.AvailabilityType; import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException; import org.rhq.core.pluginapi.operation.OperationResult; @@ -51,108 +53,105 @@ import org.rhq.core.system.SystemInfo; * @author Jay Shaughnessy */ public class ApplicationServerOperationsDelegate { - /** - * max amount of time to wait for server to show as unavailable after - * executing stop - in milliseconds - */ - private static final long STOP_WAIT_MAX = 1000L * 150; // 2.5 minutes - - /** - * amount of time to wait between availability checks when performing a stop - * - in milliseconds - */ - private static final long STOP_WAIT_INTERVAL = 1000L * 5; // 5 seconds - - /** - * amount of time to wait for stop to complete after the loop that checks - * for DOWN availability terminates - in milliseconds - */ - private static final long STOP_WAIT_FINAL = 1000L * 30; // 30 seconds - - /** max amount of time to wait for start to complete - in milliseconds */ - private static final long START_WAIT_MAX = 1000L * 300; // 5 minutes - - /** - * amount of time to wait between availability checks when performing a - * start - in milliseconds - */ - private static final long START_WAIT_INTERVAL = 1000L * 5; // 5 seconds - - private final Log log = LogFactory - .getLog(ApplicationServerOperationsDelegate.class); - - private static final String SEPARATOR = "\n-----------------------\n"; - - static final String DEFAULT_START_SCRIPT = "bin" + File.separator + "run." - + ((File.separatorChar == '/') ? "sh" : "bat"); - static final String DEFAULT_SHUTDOWN_SCRIPT = "bin" + File.separator - + "shutdown." + ((File.separatorChar == '/') ? "sh" : "bat"); - - /** - * Server component against which the operations are being performed. - */ - private ApplicationServerComponent serverComponent; - - private File configPath; - - // Constructors -------------------------------------------- - - public ApplicationServerOperationsDelegate( - ApplicationServerComponent serverComponent) { - this.serverComponent = serverComponent; - } - - // Public -------------------------------------------- - - /** - * Performs the specified operation. The result of the operation will be - * indicated in the return. If there is an error, an - * <code>RuntimeException</code> will be thrown. - * - * @param operation - * the operation to perform - * @param parameters - * parameters to the operation call - * - * @return if successful, the result object will contain a success message - * - * @throws RuntimeException - * if any errors occur while trying to perform the operation - */ - public OperationResult invoke( - ApplicationServerSupportedOperations operation, - Configuration parameters) throws InterruptedException { - OperationResult result = null; - - switch (operation) { - case START: { - result = start(); - break; - } - case SHUTDOWN: { - result = shutDown(); - break; - } - case RESTART: { - result = restart(); - break; - } - } - - return result; - } - - // Private -------------------------------------------- - - /** - * Starts the underlying AS server. - * - * @return success message if no errors are encountered - * @throws InterruptedException - * if the plugin container stops this operation while its - * executing - */ - private OperationResult start() throws InterruptedException { + /** + * max amount of time to wait for server to show as unavailable after + * executing stop - in milliseconds + */ + private static long STOP_WAIT_MAX = 1000L * 150; // 2.5 minutes + + /** + * amount of time to wait between availability checks when performing a stop + * - in milliseconds + */ + private static final long STOP_WAIT_INTERVAL = 1000L * 5; // 5 seconds + + /** + * amount of time to wait for stop to complete after the loop that checks + * for DOWN availability terminates - in milliseconds + */ + private static final long STOP_WAIT_FINAL = 1000L * 30; // 30 seconds + + /** max amount of time to wait for start to complete - in milliseconds */ + private static long START_WAIT_MAX = 1000L * 300; // 5 minutes + + /** + * amount of time to wait between availability checks when performing a + * start - in milliseconds + */ + private static final long START_WAIT_INTERVAL = 1000L * 5; // 5 seconds + + private final Log log = LogFactory.getLog(ApplicationServerOperationsDelegate.class); + + private static final String SEPARATOR = "\n-----------------------\n"; + + static final String DEFAULT_START_SCRIPT = "bin" + File.separator + "run." + + ((File.separatorChar == '/') ? "sh" : "bat"); + static final String DEFAULT_SHUTDOWN_SCRIPT = "bin" + File.separator + "shutdown." + + ((File.separatorChar == '/') ? "sh" : "bat"); + + /** + * Server component against which the operations are being performed. + */ + private ApplicationServerComponent serverComponent; + + private File configPath; + + // Constructors -------------------------------------------- + + public ApplicationServerOperationsDelegate(ApplicationServerComponent serverComponent) { + this.serverComponent = serverComponent; + } + + // Public -------------------------------------------- + + /** + * Performs the specified operation. The result of the operation will be + * indicated in the return. If there is an error, an + * <code>RuntimeException</code> will be thrown. + * + * @param operation + * the operation to perform + * @param parameters + * parameters to the operation call + * + * @return if successful, the result object will contain a success message + * + * @throws RuntimeException + * if any errors occur while trying to perform the operation + */ + public OperationResult invoke(ApplicationServerSupportedOperations operation, Configuration parameters) + throws InterruptedException { + OperationResult result = null; + + switch (operation) { + case START: { + result = start(); + break; + } + case SHUTDOWN: { + result = shutDown(); + break; + } + case RESTART: { + result = restart(); + break; + } + } + + return result; + } + + // Private -------------------------------------------- + + /** + * Starts the underlying AS server. + * + * @return success message if no errors are encountered + * @throws InterruptedException + * if the plugin container stops this operation while its + * executing + */ + private OperationResult start() throws InterruptedException { AvailabilityType avail = this.serverComponent.getAvailability(); if (avail == AvailabilityType.UP) { OperationResult result = new OperationResult(); @@ -161,25 +160,20 @@ public class ApplicationServerOperationsDelegate { } Configuration pluginConfig = serverComponent.getResourceContext().getPluginConfiguration(); File startScriptFile = getStartScriptPath(); - validateScriptFile( - startScriptFile, - ApplicationServerPluginConfigurationProperties.START_SCRIPT_CONFIG_PROP); + validateScriptFile(startScriptFile, ApplicationServerPluginConfigurationProperties.START_SCRIPT_CONFIG_PROP);
// The optional command prefix (e.g. sudo or nohup). - String prefix = pluginConfig - .getSimple( - ApplicationServerPluginConfigurationProperties.SCRIPT_PREFIX_CONFIG_PROP) - .getStringValue(); - String configName = getConfigurationSet(); - String bindAddress = pluginConfig.getSimpleValue( - ApplicationServerPluginConfigurationProperties.BIND_ADDRESS, null); + String prefix = pluginConfig + .getSimple(ApplicationServerPluginConfigurationProperties.SCRIPT_PREFIX_CONFIG_PROP).getStringValue(); + String configName = getConfigurationSet(); + String bindAddress = pluginConfig.getSimpleValue(ApplicationServerPluginConfigurationProperties.BIND_ADDRESS, + null);
- ProcessExecution processExecution; - if (prefix == null || prefix.replaceAll("\s", "").equals("")) { - // Prefix is either null or contains ONLY whitespace characters. + ProcessExecution processExecution; + if (prefix == null || prefix.replaceAll("\s", "").equals("")) { + // Prefix is either null or contains ONLY whitespace characters.
- processExecution = ProcessExecutionUtility - .createProcessExecution(startScriptFile); + processExecution = ProcessExecutionUtility.createProcessExecution(startScriptFile);
processExecution.getArguments().add("-c"); processExecution.getArguments().add(configName); @@ -188,111 +182,103 @@ public class ApplicationServerOperationsDelegate { processExecution.getArguments().add("-b"); processExecution.getArguments().add(bindAddress); } - } else { - // The process execution should be tied to the process represented - // as the prefix. If there are any other - // tokens in the prefix, consider them arguments to the prefix - // process. - StringTokenizer prefixTokenizer = new StringTokenizer(prefix); - String processName = prefixTokenizer.nextToken(); - File prefixProcess = new File(processName); - - processExecution = ProcessExecutionUtility - .createProcessExecution(prefixProcess); - - while (prefixTokenizer.hasMoreTokens()) { - String prefixArgument = prefixTokenizer.nextToken(); - processExecution.getArguments().add(prefixArgument); - } - - // Add the AS start script and its options as a single argument to the prefix command. - String startScriptArgument = startScriptFile.getAbsolutePath(); - startScriptArgument += " -c " + configName; - if (bindAddress != null) { - startScriptArgument += " -b " + bindAddress; - } - processExecution.getArguments().add(startScriptArgument); - } - - initProcessExecution(processExecution, startScriptFile); - - long start = System.currentTimeMillis(); - if (log.isDebugEnabled()) { - log.debug("About to execute the following process: [" + processExecution + "]"); - } - SystemInfo systemInfo = serverComponent.getResourceContext().getSystemInformation(); - ProcessExecutionResults results = systemInfo - .executeProcess(processExecution); - logExecutionResults(results); - - if (results.getError() == null) { - avail = waitForServerToStart(start); - } else { - log.error( - "Error from process execution while starting the AS instance. Exit code [" - + results.getExitCode() + "]", results.getError()); - avail = this.serverComponent.getAvailability(); - } - - // If, after the loop, the Server is still down, consider the start to be a failure. - OperationResult result; + } else { + // The process execution should be tied to the process represented + // as the prefix. If there are any other + // tokens in the prefix, consider them arguments to the prefix + // process. + StringTokenizer prefixTokenizer = new StringTokenizer(prefix); + String processName = prefixTokenizer.nextToken(); + File prefixProcess = new File(processName); + + processExecution = ProcessExecutionUtility.createProcessExecution(prefixProcess); + + while (prefixTokenizer.hasMoreTokens()) { + String prefixArgument = prefixTokenizer.nextToken(); + processExecution.getArguments().add(prefixArgument); + } + + // Add the AS start script and its options as a single argument to the prefix command. + String startScriptArgument = startScriptFile.getAbsolutePath(); + startScriptArgument += " -c " + configName; + if (bindAddress != null) { + startScriptArgument += " -b " + bindAddress; + } + processExecution.getArguments().add(startScriptArgument); + } + + initProcessExecution(processExecution, startScriptFile); + + long start = System.currentTimeMillis(); + if (log.isDebugEnabled()) { + log.debug("About to execute the following process: [" + processExecution + "]"); + } + SystemInfo systemInfo = serverComponent.getResourceContext().getSystemInformation(); + ProcessExecutionResults results = systemInfo.executeProcess(processExecution); + logExecutionResults(results); + + if (results.getError() == null) { + avail = waitForServerToStart(start); + } else { + log.error("Error from process execution while starting the AS instance. Exit code [" + + results.getExitCode() + "]", results.getError()); + avail = this.serverComponent.getAvailability(); + } + + // If, after the loop, the Server is still down, consider the start to be a failure. + OperationResult result; if (avail == AvailabilityType.DOWN) { - result = new OperationResult(); + result = new OperationResult(); result.setErrorMessage("The server failed to start: " + results.getCapturedOutput()); - } else { - result = new OperationResult("The server has been started."); - } + } else { + result = new OperationResult("The server has been started."); + } return result; - } - - private String getConfigurationSet() { - Configuration pluginConfig = serverComponent.getResourceContext().getPluginConfiguration(); - configPath = resolvePathRelativeToHomeDir(getRequiredPropertyValue( - pluginConfig, - ApplicationServerPluginConfigurationProperties.SERVER_HOME_DIR)); - - if (!configPath.exists()) { - throw new InvalidPluginConfigurationException( - "Configuration path '" + configPath + "' does not exist."); - } - return pluginConfig.getSimpleValue( - ApplicationServerPluginConfigurationProperties.SERVER_NAME, - configPath.getName()); - } - - private void initProcessExecution(ProcessExecution processExecution, - File scriptFile) { - // NOTE: For both run.bat and shutdown.bat, the current working dir must - // be set to the script's parent dir - // (e.g. ${JBOSS_HOME}/bin) for the script to work. - processExecution.setWorkingDirectory(scriptFile.getParent()); - - // Both scripts require the JAVA_HOME env var to be set. - File javaHomeDir = getJavaHomePath(); - if (javaHomeDir == null) { - throw new IllegalStateException( - "The '" - + ApplicationServerPluginConfigurationProperties.JAVA_HOME - + "' connection property must be set in order to start the application server or to stop it via script."); - } - - validateJavaHomePathProperty(); - processExecution.getEnvironmentVariables().put("JAVA_HOME", - javaHomeDir.getPath()); - - processExecution.setCaptureOutput(true); - processExecution.setWaitForCompletion(1000L); // 1 second // TODO: - // Should we wait longer than one second? - processExecution.setKillOnTimeout(false); - } - - /** - * Shuts down the server by dispatching to shutdown via script or JMX. Waits - * until the server is down. - * - * @return The result of the shutdown operation - is successful - */ - private OperationResult shutDown() { + } + + private String getConfigurationSet() { + Configuration pluginConfig = serverComponent.getResourceContext().getPluginConfiguration(); + configPath = resolvePathRelativeToHomeDir(getRequiredPropertyValue(pluginConfig, + ApplicationServerPluginConfigurationProperties.SERVER_HOME_DIR)); + + if (!configPath.exists()) { + throw new InvalidPluginConfigurationException("Configuration path '" + configPath + "' does not exist."); + } + return pluginConfig.getSimpleValue(ApplicationServerPluginConfigurationProperties.SERVER_NAME, configPath + .getName()); + } + + private void initProcessExecution(ProcessExecution processExecution, File scriptFile) { + // NOTE: For both run.bat and shutdown.bat, the current working dir must + // be set to the script's parent dir + // (e.g. ${JBOSS_HOME}/bin) for the script to work. + processExecution.setWorkingDirectory(scriptFile.getParent()); + + // Both scripts require the JAVA_HOME env var to be set. + File javaHomeDir = getJavaHomePath(); + if (javaHomeDir == null) { + throw new IllegalStateException( + "The '" + + ApplicationServerPluginConfigurationProperties.JAVA_HOME + + "' connection property must be set in order to start the application server or to stop it via script."); + } + + validateJavaHomePathProperty(); + processExecution.getEnvironmentVariables().put("JAVA_HOME", javaHomeDir.getPath()); + + processExecution.setCaptureOutput(true); + processExecution.setWaitForCompletion(1000L); // 1 second // TODO: + // Should we wait longer than one second? + processExecution.setKillOnTimeout(false); + } + + /** + * Shuts down the server by dispatching to shutdown via script or JMX. Waits + * until the server is down. + * + * @return The result of the shutdown operation - is successful + */ + private OperationResult shutDown() { AvailabilityType avail = this.serverComponent.getAvailability(); if (avail == AvailabilityType.DOWN) { OperationResult result = new OperationResult(); @@ -301,339 +287,319 @@ public class ApplicationServerOperationsDelegate { }
Configuration pluginConfig = serverComponent.getResourceContext().getPluginConfiguration(); - ApplicationServerShutdownMethod shutdownMethod = Enum - .valueOf( - ApplicationServerShutdownMethod.class, - pluginConfig - .getSimple( - ApplicationServerPluginConfigurationProperties.SHUTDOWN_METHOD_CONFIG_PROP) - .getStringValue()); - String resultMessage = ApplicationServerShutdownMethod.JMX - .equals(shutdownMethod) ? shutdownViaJmx() - : shutdownViaScript(); + ApplicationServerShutdownMethod shutdownMethod = Enum.valueOf(ApplicationServerShutdownMethod.class, + pluginConfig.getSimple(ApplicationServerPluginConfigurationProperties.SHUTDOWN_METHOD_CONFIG_PROP) + .getStringValue()); + String resultMessage = ApplicationServerShutdownMethod.JMX.equals(shutdownMethod) ? shutdownViaJmx() + : shutdownViaScript();
avail = waitForServerToShutdown(); - OperationResult result; + OperationResult result; if (avail == AvailabilityType.UP) { - result = new OperationResult(); + result = new OperationResult(); result.setErrorMessage("The server failed to shut down."); - } else { - return new OperationResult(resultMessage); - } + } else { + return new OperationResult(resultMessage); + } return result; - } - - /** - * Shuts down the AS server using a shutdown script. - * - * @return success message if no errors are encountered - */ - private String shutdownViaScript() { - File shutdownScriptFile = getShutdownScriptPath(); - validateScriptFile( - shutdownScriptFile, - ApplicationServerPluginConfigurationProperties.SHUTDOWN_SCRIPT_CONFIG_PROP); - Configuration pluginConfig = serverComponent.getResourceContext().getPluginConfiguration(); - String prefix = pluginConfig - .getSimple( - ApplicationServerPluginConfigurationProperties.SCRIPT_PREFIX_CONFIG_PROP) - .getStringValue(); - ProcessExecution processExecution = ProcessExecutionUtility - .createProcessExecution(prefix, shutdownScriptFile); - - initProcessExecution(processExecution, shutdownScriptFile); - - String server = pluginConfig.getSimple( - ApplicationServerPluginConfigurationProperties.NAMING_URL) - .getStringValue(); - if (server != null) { - processExecution.getArguments().add("--server=" + server); - } - - String user = pluginConfig.getSimple( - ApplicationServerComponent.PRINCIPAL_CONFIG_PROP) - .getStringValue(); - if (user != null) { - processExecution.getArguments().add("--user=" + user); - } - - String password = pluginConfig.getSimple( - ApplicationServerComponent.CREDENTIALS_CONFIG_PROP) - .getStringValue(); - if (password != null) { - processExecution.getArguments().add("--password=" + password); - } - - processExecution.getArguments().add("--shutdown"); - - /* - * This tells shutdown.bat not to call the Windows PAUSE command, which - * would cause the script to hang indefinitely waiting for input. - * noinspection ConstantConditions - */ - processExecution.getEnvironmentVariables().put("NOPAUSE", "1"); - - if (log.isDebugEnabled()) { - log.debug("About to execute the following process: [" - + processExecution + "]"); - } - SystemInfo systemInfo = serverComponent.getResourceContext().getSystemInformation(); - ProcessExecutionResults results = systemInfo - .executeProcess(processExecution); - logExecutionResults(results); - - if (results.getError() != null) { - throw new RuntimeException( - "Error executing shutdown script while stopping AS instance. Exit code [" - + results.getExitCode() + "]", results.getError()); - } - - return "The server has been shut down."; - } - - private void logExecutionResults(ProcessExecutionResults results) { - // Always log the output at info level. On Unix we could switch - // depending on a exitCode being !=0, but ... - log.info("Exit code from process execution: " + results.getExitCode()); - log.info("Output from process execution: " + SEPARATOR - + results.getCapturedOutput() + SEPARATOR); - } - - /** - * Shuts down the AS server via a JMX call. - * - * @return success message if no errors are encountered - */ - private String shutdownViaJmx() { - Configuration pluginConfig = serverComponent.getResourceContext().getPluginConfiguration(); - String mbeanName = pluginConfig - .getSimple( - ApplicationServerPluginConfigurationProperties.SHUTDOWN_MBEAN_CONFIG_PROP) - .getStringValue(); - String operationName = pluginConfig - .getSimple( - ApplicationServerPluginConfigurationProperties.SHUTDOWN_MBEAN_OPERATION_CONFIG_PROP) - .getStringValue(); - - EmsConnection connection = this.serverComponent.getEmsConnection(); - if (connection == null) { - throw new RuntimeException("Can not connect to the server"); - } - EmsBean bean = connection.getBean(mbeanName); - EmsOperation operation = bean.getOperation(operationName); - /* - * Now see if we got the 'real' method (the one with no param) or the - * overloaded one. This is a workaround for a bug in EMS that prevents - * finding operations with same name and different signature. - * http://sourceforge - * .net/tracker/index.php?func=detail&aid=2007692&group_id - * =60228&atid=493495 - * - * In addition, as we offer the user to specify any MBean and any - * method, we'd need a clever way for the user to specify parameters - * anyway. - */ - List<EmsParameter> params = operation.getParameters(); - int count = params.size(); - if (count == 0) - operation.invoke(new Object[0]); - else { // overloaded operation - operation.invoke(new Object[] { 0 }); // return code of 0 - } - - return "The server has been shut down."; - } - - private void validateScriptFile(File scriptFile, String scriptPropertyName) { - if (!scriptFile.exists()) { - throw new RuntimeException("Script (" + scriptFile - + ") specified via '" + scriptPropertyName - + "' connection property does not exist."); - } - - if (scriptFile.isDirectory()) { - throw new RuntimeException("Script (" + scriptFile - + ") specified via '" + scriptPropertyName - + "' connection property is a directory, not a file."); - } - } - - /** - * Restart the server by first trying a shutdown and then a start. This is - * fail fast. - * - * @return A success message on success - */ - private OperationResult restart() { - try { - shutDown(); - } catch (Exception e) { - throw new RuntimeException("Shutdown may have failed: " + e); - } - - try { - start(); - } catch (Exception e) { - throw new RuntimeException("Start following shutdown may have failed: " + e); - } - - return new OperationResult("Server has been restarted."); - - } - - private AvailabilityType waitForServerToStart(long start) - throws InterruptedException { - AvailabilityType avail; - while (((avail = this.serverComponent.getAvailability()) == AvailabilityType.DOWN) - && (System.currentTimeMillis() < (start + START_WAIT_MAX))) { - try { - Thread.sleep(START_WAIT_INTERVAL); - } catch (InterruptedException e) { - // ignore - } - } - return avail; - } - - private AvailabilityType waitForServerToShutdown() { - long start = System.currentTimeMillis(); + } + + /** + * Shuts down the AS server using a shutdown script. + * + * @return success message if no errors are encountered + */ + private String shutdownViaScript() { + File shutdownScriptFile = getShutdownScriptPath(); + validateScriptFile(shutdownScriptFile, + ApplicationServerPluginConfigurationProperties.SHUTDOWN_SCRIPT_CONFIG_PROP); + Configuration pluginConfig = serverComponent.getResourceContext().getPluginConfiguration(); + String prefix = pluginConfig + .getSimple(ApplicationServerPluginConfigurationProperties.SCRIPT_PREFIX_CONFIG_PROP).getStringValue(); + ProcessExecution processExecution = ProcessExecutionUtility.createProcessExecution(prefix, shutdownScriptFile); + + initProcessExecution(processExecution, shutdownScriptFile); + + String server = pluginConfig.getSimple(ApplicationServerPluginConfigurationProperties.NAMING_URL) + .getStringValue(); + if (server != null) { + processExecution.getArguments().add("--server=" + server); + } + + String user = pluginConfig.getSimple(ApplicationServerComponent.PRINCIPAL_CONFIG_PROP).getStringValue(); + if (user != null) { + processExecution.getArguments().add("--user=" + user); + } + + String password = pluginConfig.getSimple(ApplicationServerComponent.CREDENTIALS_CONFIG_PROP).getStringValue(); + if (password != null) { + processExecution.getArguments().add("--password=" + password); + } + + processExecution.getArguments().add("--shutdown"); + + /* + * This tells shutdown.bat not to call the Windows PAUSE command, which + * would cause the script to hang indefinitely waiting for input. + * noinspection ConstantConditions + */ + processExecution.getEnvironmentVariables().put("NOPAUSE", "1"); + + if (log.isDebugEnabled()) { + log.debug("About to execute the following process: [" + processExecution + "]"); + } + SystemInfo systemInfo = serverComponent.getResourceContext().getSystemInformation(); + ProcessExecutionResults results = systemInfo.executeProcess(processExecution); + logExecutionResults(results); + + if (results.getError() != null) { + throw new RuntimeException("Error executing shutdown script while stopping AS instance. Exit code [" + + results.getExitCode() + "]", results.getError()); + } + + return "The server has been shut down."; + } + + private void logExecutionResults(ProcessExecutionResults results) { + // Always log the output at info level. On Unix we could switch + // depending on a exitCode being !=0, but ... + log.info("Exit code from process execution: " + results.getExitCode()); + log.info("Output from process execution: " + SEPARATOR + results.getCapturedOutput() + SEPARATOR); + } + + /** + * Shuts down the AS server via a JMX call. + * + * @return success message if no errors are encountered + */ + private String shutdownViaJmx() { + Configuration pluginConfig = serverComponent.getResourceContext().getPluginConfiguration(); + String mbeanName = pluginConfig.getSimple( + ApplicationServerPluginConfigurationProperties.SHUTDOWN_MBEAN_CONFIG_PROP).getStringValue(); + String operationName = pluginConfig.getSimple( + ApplicationServerPluginConfigurationProperties.SHUTDOWN_MBEAN_OPERATION_CONFIG_PROP).getStringValue(); + + EmsConnection connection = this.serverComponent.getEmsConnection(); + if (connection == null) { + throw new RuntimeException("Can not connect to the server"); + } + EmsBean bean = connection.getBean(mbeanName); + EmsOperation operation = bean.getOperation(operationName); + /* + * Now see if we got the 'real' method (the one with no param) or the + * overloaded one. This is a workaround for a bug in EMS that prevents + * finding operations with same name and different signature. + * http://sourceforge + * .net/tracker/index.php?func=detail&aid=2007692&group_id + * =60228&atid=493495 + * + * In addition, as we offer the user to specify any MBean and any + * method, we'd need a clever way for the user to specify parameters + * anyway. + */ + List<EmsParameter> params = operation.getParameters(); + int count = params.size(); + if (count == 0) + operation.invoke(new Object[0]); + else { // overloaded operation + operation.invoke(new Object[] { 0 }); // return code of 0 + } + + return "The server has been shut down."; + } + + private void validateScriptFile(File scriptFile, String scriptPropertyName) { + if (!scriptFile.exists()) { + throw new RuntimeException("Script (" + scriptFile + ") specified via '" + scriptPropertyName + + "' connection property does not exist."); + } + + if (scriptFile.isDirectory()) { + throw new RuntimeException("Script (" + scriptFile + ") specified via '" + scriptPropertyName + + "' connection property is a directory, not a file."); + } + } + + /** + * Restart the server by first trying a shutdown and then a start. This is + * fail fast. + * + * @return A success message on success + */ + private OperationResult restart() { + try { + shutDown(); + } catch (Exception e) { + throw new RuntimeException("Shutdown may have failed: " + e); + } + + try { + start(); + } catch (Exception e) { + throw new RuntimeException("Start following shutdown may have failed: " + e); + } + + return new OperationResult("Server has been restarted."); + + } + + private AvailabilityType waitForServerToStart(long start) throws InterruptedException { AvailabilityType avail; + //detect whether startWaitMax property has been set. + Configuration pluginConfig = serverComponent.getResourceContext().getPluginConfiguration(); + PropertySimple property = pluginConfig + .getSimple(ApplicationServerPluginConfigurationProperties.START_WAIT_MAX_PROP); + //if set and valid, update startWaitMax value + if ((property != null) && (property.getIntegerValue() != null)) { + int newValue = property.getIntegerValue(); + if (newValue >= 1) { + START_WAIT_MAX = 1000L * 60 * newValue; + } + } + while (((avail = this.serverComponent.getAvailability()) == AvailabilityType.DOWN) + && (System.currentTimeMillis() < (start + START_WAIT_MAX))) { + try { + Thread.sleep(START_WAIT_INTERVAL); + } catch (InterruptedException e) { + // ignore + } + } + return avail; + } + + private AvailabilityType waitForServerToShutdown() { + long start = System.currentTimeMillis(); + AvailabilityType avail; + //detect whether stopWaitMax property has been set. + Configuration pluginConfig = serverComponent.getResourceContext().getPluginConfiguration(); + PropertySimple property = pluginConfig + .getSimple(ApplicationServerPluginConfigurationProperties.STOP_WAIT_MAX_PROP); + //if set and valid update stopWaitMax value + if ((property != null) && (property.getIntegerValue() != null)) { + int newValue = property.getIntegerValue(); + if (newValue >= 1) { + STOP_WAIT_MAX = 1000L * 60 * newValue; + } + } while (((avail = this.serverComponent.getAvailability()) == AvailabilityType.UP) - && (System.currentTimeMillis() < (start + STOP_WAIT_MAX))) { - try { - Thread.sleep(STOP_WAIT_INTERVAL); - } catch (InterruptedException e) { - // ignore - } - } - - // After the server becomes unavailable, wait a little longer to hopefully - // ensure shutdown is complete. - try { - Thread.sleep(STOP_WAIT_FINAL); - } catch (InterruptedException e) { - // ignore - } - return avail; - } - - /** - * Return the absolute path of this JBoss server's start script (e.g. - * "C:\opt\jboss-5.1.0.GA\bin\run.sh"). - * - * @return the absolute path of this JBoss server's start script (e.g. - * "C:\opt\jboss-5.1.0.GA\bin\run.sh") - */ - @NotNull - public File getStartScriptPath() { - Configuration pluginConfig = serverComponent.getResourceContext() - .getPluginConfiguration(); - String startScript = pluginConfig - .getSimpleValue( - ApplicationServerPluginConfigurationProperties.START_SCRIPT_CONFIG_PROP, - DEFAULT_START_SCRIPT); - File startScriptFile = resolvePathRelativeToHomeDir(startScript); - return startScriptFile; - } - - @NotNull - private File resolvePathRelativeToHomeDir(@NotNull String path) { - return resolvePathRelativeToHomeDir(serverComponent - .getResourceContext().getPluginConfiguration(), path); - } - - @NotNull - private File resolvePathRelativeToHomeDir(Configuration pluginConfig, - @NotNull String path) { - File configDir = new File(path); - if (!configDir.isAbsolute()) { - String jbossHomeDir = getRequiredPropertyValue(pluginConfig, - ApplicationServerPluginConfigurationProperties.HOME_DIR); - configDir = new File(jbossHomeDir, path); - } - - return configDir; - } - - @NotNull - private String getRequiredPropertyValue(@NotNull Configuration config, - @NotNull String propName) { - String propValue = config.getSimpleValue(propName, null); - if (propValue == null) { - // Something's not right - neither autodiscovery, nor the config - // edit GUI, should ever allow this. - throw new IllegalStateException("Required property '" + propName - + "' is not set."); - } - - return propValue; - } - - /** - * Return the absolute path of this JBoss server's shutdown script (e.g. - * "C:\opt\jboss-5.1.0.GA\bin\shutdown.sh"). - * - * @return the absolute path of this JBoss server's shutdown script (e.g. - * "C:\opt\jboss-5.1.0.GA\bin\shutdown.sh") - */ - @NotNull - public File getShutdownScriptPath() { - Configuration pluginConfig = serverComponent.getResourceContext() - .getPluginConfiguration(); - String shutdownScript = pluginConfig - .getSimpleValue( - ApplicationServerPluginConfigurationProperties.SHUTDOWN_SCRIPT_CONFIG_PROP, - DEFAULT_SHUTDOWN_SCRIPT); - File shutdownScriptFile = resolvePathRelativeToHomeDir(shutdownScript); - return shutdownScriptFile; - } - - /** - * Return the absolute path of this JBoss server's JAVA_HOME directory (e.g. "C:\opt\jdk1.5.0_14"), as defined by + && (System.currentTimeMillis() < (start + STOP_WAIT_MAX))) { + try { + Thread.sleep(STOP_WAIT_INTERVAL); + } catch (InterruptedException e) { + // ignore + } + } + + // After the server becomes unavailable, wait a little longer to hopefully + // ensure shutdown is complete. + try { + Thread.sleep(STOP_WAIT_FINAL); + } catch (InterruptedException e) { + // ignore + } + return avail; + } + + /** + * Return the absolute path of this JBoss server's start script (e.g. + * "C:\opt\jboss-5.1.0.GA\bin\run.sh"). + * + * @return the absolute path of this JBoss server's start script (e.g. + * "C:\opt\jboss-5.1.0.GA\bin\run.sh") + */ + @NotNull + public File getStartScriptPath() { + Configuration pluginConfig = serverComponent.getResourceContext().getPluginConfiguration(); + String startScript = pluginConfig.getSimpleValue( + ApplicationServerPluginConfigurationProperties.START_SCRIPT_CONFIG_PROP, DEFAULT_START_SCRIPT); + File startScriptFile = resolvePathRelativeToHomeDir(startScript); + return startScriptFile; + } + + @NotNull + private File resolvePathRelativeToHomeDir(@NotNull String path) { + return resolvePathRelativeToHomeDir(serverComponent.getResourceContext().getPluginConfiguration(), path); + } + + @NotNull + private File resolvePathRelativeToHomeDir(Configuration pluginConfig, @NotNull String path) { + File configDir = new File(path); + if (!configDir.isAbsolute()) { + String jbossHomeDir = getRequiredPropertyValue(pluginConfig, + ApplicationServerPluginConfigurationProperties.HOME_DIR); + configDir = new File(jbossHomeDir, path); + } + + return configDir; + } + + @NotNull + private String getRequiredPropertyValue(@NotNull Configuration config, @NotNull String propName) { + String propValue = config.getSimpleValue(propName, null); + if (propValue == null) { + // Something's not right - neither autodiscovery, nor the config + // edit GUI, should ever allow this. + throw new IllegalStateException("Required property '" + propName + "' is not set."); + } + + return propValue; + } + + /** + * Return the absolute path of this JBoss server's shutdown script (e.g. + * "C:\opt\jboss-5.1.0.GA\bin\shutdown.sh"). + * + * @return the absolute path of this JBoss server's shutdown script (e.g. + * "C:\opt\jboss-5.1.0.GA\bin\shutdown.sh") + */ + @NotNull + public File getShutdownScriptPath() { + Configuration pluginConfig = serverComponent.getResourceContext().getPluginConfiguration(); + String shutdownScript = pluginConfig.getSimpleValue( + ApplicationServerPluginConfigurationProperties.SHUTDOWN_SCRIPT_CONFIG_PROP, DEFAULT_SHUTDOWN_SCRIPT); + File shutdownScriptFile = resolvePathRelativeToHomeDir(shutdownScript); + return shutdownScriptFile; + } + + /** + * Return the absolute path of this JBoss server's JAVA_HOME directory (e.g. "C:\opt\jdk1.5.0_14"), as defined by * the 'javaHome' plugin config prop, or null if that prop is not set. - * - * @return the absolute path of this JBoss server's JAVA_HOME directory, as defined by + * + * @return the absolute path of this JBoss server's JAVA_HOME directory, as defined by * the 'javaHome' plugin config prop, or null if that prop is not set - */ - @Nullable - public File getJavaHomePath() { - Configuration pluginConfig = serverComponent.getResourceContext().getPluginConfiguration(); - String javaHomePath = pluginConfig.getSimpleValue(ApplicationServerPluginConfigurationProperties.JAVA_HOME, - null); - File javaHome = (javaHomePath != null) ? new File(javaHomePath) : null; - return javaHome; - } - - void validateJavaHomePathProperty() { - Configuration pluginConfig = serverComponent.getResourceContext().getPluginConfiguration(); - String javaHome = pluginConfig.getSimple( - ApplicationServerPluginConfigurationProperties.JAVA_HOME) - .getStringValue(); - if (javaHome != null) { - File javaHomeDir = new File(javaHome); - if (!javaHomeDir.isAbsolute()) { - throw new InvalidPluginConfigurationException( - ApplicationServerPluginConfigurationProperties.JAVA_HOME - + " connection property ('" - + javaHomeDir - + "') is not an absolute path. Note, on Windows, absolute paths must start with the drive letter (e.g. C:)."); - } - - if (!javaHomeDir.exists()) { - throw new InvalidPluginConfigurationException( - ApplicationServerPluginConfigurationProperties.JAVA_HOME - + " connection property ('" - + javaHomeDir - + "') does not exist."); - } - - if (!javaHomeDir.isDirectory()) { - throw new InvalidPluginConfigurationException( - ApplicationServerPluginConfigurationProperties.JAVA_HOME - + " connection property ('" - + javaHomeDir - + "') is not a directory."); - } - } - } + */ + @Nullable + public File getJavaHomePath() { + Configuration pluginConfig = serverComponent.getResourceContext().getPluginConfiguration(); + String javaHomePath = pluginConfig.getSimpleValue(ApplicationServerPluginConfigurationProperties.JAVA_HOME, + null); + File javaHome = (javaHomePath != null) ? new File(javaHomePath) : null; + return javaHome; + } + + void validateJavaHomePathProperty() { + Configuration pluginConfig = serverComponent.getResourceContext().getPluginConfiguration(); + String javaHome = pluginConfig.getSimple(ApplicationServerPluginConfigurationProperties.JAVA_HOME) + .getStringValue(); + if (javaHome != null) { + File javaHomeDir = new File(javaHome); + if (!javaHomeDir.isAbsolute()) { + throw new InvalidPluginConfigurationException( + ApplicationServerPluginConfigurationProperties.JAVA_HOME + + " connection property ('" + + javaHomeDir + + "') is not an absolute path. Note, on Windows, absolute paths must start with the drive letter (e.g. C:)."); + } + + if (!javaHomeDir.exists()) { + throw new InvalidPluginConfigurationException(ApplicationServerPluginConfigurationProperties.JAVA_HOME + + " connection property ('" + javaHomeDir + "') does not exist."); + } + + if (!javaHomeDir.isDirectory()) { + throw new InvalidPluginConfigurationException(ApplicationServerPluginConfigurationProperties.JAVA_HOME + + " connection property ('" + javaHomeDir + "') is not a directory."); + } + } + } } diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerPluginConfigurationProperties.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerPluginConfigurationProperties.java index 3489fd4..c770844 100644 --- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerPluginConfigurationProperties.java +++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerPluginConfigurationProperties.java @@ -33,11 +33,13 @@ public class ApplicationServerPluginConfigurationProperties { public static final String HOME_DIR = "homeDir"; public static final String CLIENT_URL = "clientUrl"; public static final String LIB_URL = "libUrl"; - public static final String COMMON_LIB_URL = "commonLibUrl"; + public static final String COMMON_LIB_URL = "commonLibUrl"; public static final String SERVER_HOME_DIR = "serverHomeDir"; public static final String JAVA_HOME = "javaHome"; public static final String BIND_ADDRESS = "bindAddress"; public static final String START_SCRIPT_CONFIG_PROP = "startScript"; + public static final String START_WAIT_MAX_PROP = "startWaitMax"; + public static final String STOP_WAIT_MAX_PROP = "stopWaitMax"; public static final String SHUTDOWN_SCRIPT_CONFIG_PROP = "shutdownScript"; public static final String SHUTDOWN_MBEAN_CONFIG_PROP = "shutdownMBeanName"; public static final String SHUTDOWN_MBEAN_OPERATION_CONFIG_PROP = "shutdownMBeanOperation"; diff --git a/modules/plugins/jboss-as-5/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/jboss-as-5/src/main/resources/META-INF/rhq-plugin.xml index 421ac28..b88813c 100644 --- a/modules/plugins/jboss-as-5/src/main/resources/META-INF/rhq-plugin.xml +++ b/modules/plugins/jboss-as-5/src/main/resources/META-INF/rhq-plugin.xml @@ -1018,6 +1018,18 @@ this property must be set in order for the Start operation to work, or for the Shutdown operation to work when the shutdown method is set to 'shutdown script'."/> + <c:simple-property name="startWaitMax" required="false" + description="The time, in minutes,(e.g. 1 or 8) that must elapse before the server is considered to have failed to start up. The default is 5 minutes."> + <c:constraint> + <c:integer-constraint minimum="1"/> + </c:constraint> + </c:simple-property> + <c:simple-property name="stopWaitMax" required="false" + description="The time, in minutes,(e.g. 1 or 8) that must elapse before the server is considered to have failed to stop. The default is 2.5 minutes."> + <c:constraint> + <c:integer-constraint minimum="1"/> + </c:constraint> + </c:simple-property> </c:group>
<c:group name="advanced" displayName="Advanced" hiddenByDefault="true">
commit af9ff8bfcf561ca49eb6af2385ae7cb717a96199 Author: John Mazzitelli mazz@redhat.com Date: Thu Mar 24 09:04:55 2011 -0400
BZ 535572 - we don't want to support the agent talking to the server over the http or https transport protocol, so remove them from the options.
diff --git a/modules/plugins/rhq-agent/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/rhq-agent/src/main/resources/META-INF/rhq-plugin.xml index 438cbd5..bf48dcd 100644 --- a/modules/plugins/rhq-agent/src/main/resources/META-INF/rhq-plugin.xml +++ b/modules/plugins/rhq-agent/src/main/resources/META-INF/rhq-plugin.xml @@ -379,8 +379,6 @@ <c:option name="sslservlet" value="sslservlet" /> <c:option name="socket" value="socket" /> <c:option name="sslsocket" value="sslsocket" /> - <c:option name="http" value="http" /> - <c:option name="https" value="https" /> </c:property-options> </c:simple-property> <c:simple-property name="rhq.agent.server.bind-address" type="string" activationPolicy="restart" required="true" default="127.0.0.1" displayName="RHQ Server IP Address" description="The RHQ Server address that it is bound to" />
commit 7f51c8b8b62835bb0c7eaa68726de75bbbff9866 Author: John Mazzitelli mazz@redhat.com Date: Wed Mar 23 21:36:09 2011 -0400
BZ 689951 - message center window's list grid needed to be refreshed in order to have its rows be selectable
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 f861a37..b5907fd 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 @@ -90,31 +90,28 @@ public class MessageCenterView extends Table implements MessageCenter.MessageLis */ public void showMessageCenterWindow() { try { - createWindow().show(); + if (window == null) { + window = new MessageCenterWindow("MessageCenterViewWindow"); + window.addItem(this); + window.addCloseClickHandler(new CloseClickHandler() { + @Override + public void onCloseClick(CloseClientEvent event) { + try { + window.hide(); + } catch (Throwable e) { + Log.warn("Cannot destroy message center", e); + } + } + }); + } + + window.show(); + markForRedraw(); // need this to ensure the list grid rows are selectable } catch (Throwable e) { Log.error("Cannot show message center window", e); } }
- private Window createWindow() { - if (window == null) { - window = new MessageCenterWindow("MessageCenterViewWindow"); - window.addItem(this); - window.addCloseClickHandler(new CloseClickHandler() { - @Override - public void onCloseClick(CloseClientEvent event) { - try { - window.hide(); - } catch (Throwable e) { - Log.warn("Cannot destroy message center", e); - } - } - }); - } - - return window; - } - @Override public void onMessage(final Message message) { try {
commit 2f94b6e8de74e304c3044c404d3ce90b17332ada Author: John Mazzitelli mazz@redhat.com Date: Wed Mar 23 19:25:44 2011 -0400
don't allow tags to be added/removed if you don't have permission
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 a0e3949..1046f31 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 @@ -128,8 +128,8 @@ public class ResourceTitleBar extends LocatableVLayout {
badge = new Img(ImageManager.getResourceLargeIcon(ResourceCategory.SERVICE), 24, 24);
- TagEditorView tagEditorView = new TagEditorView(extendLocatorId("TagEdit"), resource.getTags(), false, - new TagsChangedCallback() { + TagEditorView tagEditorView = new TagEditorView(extendLocatorId("TagEdit"), resource.getTags(), + !resourceComposite.getResourcePermission().isInventory(), new TagsChangedCallback() { public void tagsChanged(final HashSet<Tag> tags) { GWTServiceLookup.getTagService().updateResourceTags(resource.getId(), tags, new AsyncCallback<Void>() {
commit cd4b00e6a257ac66ba60b128679168bcee1cecde Author: John Mazzitelli mazz@redhat.com Date: Wed Mar 23 19:24:54 2011 -0400
BZ 688915 refactor the tag editor so it doesn't disappear after adding a third tag. make components reuseable, don't throw away and recreate components
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tagging/TagEditorView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tagging/TagEditorView.java index 14f9a39..ac289a2 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tagging/TagEditorView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tagging/TagEditorView.java @@ -22,6 +22,7 @@ */ package org.rhq.enterprise.gui.coregui.client.components.tagging;
+import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedHashSet; import java.util.Map; @@ -30,6 +31,7 @@ import java.util.Set; import com.google.gwt.event.dom.client.KeyCodes; import com.google.gwt.user.client.rpc.AsyncCallback; import com.smartgwt.client.types.TextMatchStyle; +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; @@ -41,7 +43,6 @@ import com.smartgwt.client.widgets.events.MouseOverHandler; import com.smartgwt.client.widgets.form.fields.ComboBoxItem; import com.smartgwt.client.widgets.form.fields.events.KeyPressEvent; import com.smartgwt.client.widgets.form.fields.events.KeyPressHandler; -import com.smartgwt.client.widgets.layout.Layout; import com.smartgwt.client.widgets.layout.LayoutSpacer;
import org.rhq.core.domain.criteria.TagCriteria; @@ -51,34 +52,64 @@ import org.rhq.core.domain.util.PageOrdering; import org.rhq.enterprise.gui.coregui.client.CoreGUI; import org.rhq.enterprise.gui.coregui.client.LinkManager; import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; -import org.rhq.enterprise.gui.coregui.client.util.selenium.Locatable; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDialog; 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.LocatableImg; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableLayout; -import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
/** + * A reusable component that shows a set of tags and, if not read only, allows the user + * to delete existing tags or add new tags. + * * @author Greg Hinkle + * @author John Mazzitelli */ public class TagEditorView extends LocatableLayout {
private LinkedHashSet<Tag> tags = new LinkedHashSet<Tag>(); - private boolean readOnly; private TagsChangedCallback callback; - - private boolean vertical = false; + private HTMLFlow tagTitleLabel; + private ArrayList<LocatableHLayout> tagLayouts; + private Img addImg; + private TagInputDialog tagInputDialog;
public TagEditorView(String locatorId, Set<Tag> tags, boolean readOnly, TagsChangedCallback callback) { + this(locatorId, tags, readOnly, callback, false); + } + + public TagEditorView(String locatorId, Set<Tag> tags, boolean readOnly, TagsChangedCallback callback, + boolean vertical) { + super(locatorId);
+ setVertical(vertical); + setAutoWidth(); + if (!vertical) { + setMembersMargin(8); + } + if (tags != null) { this.tags.addAll(tags); } this.readOnly = readOnly; this.callback = callback; + + tagTitleLabel = new HTMLFlow("<b>" + MSG.view_tags_tags() + ":</b>"); + tagTitleLabel.setAutoWidth(); + + if (!this.readOnly) { + tagInputDialog = new TagInputDialog(extendLocatorId("tagInputDialog")); + + addImg = new LocatableImg(extendLocatorId("addImg"), "[skin]/images/actions/add.png", 16, 16); + addImg.setTooltip(MSG.view_tags_tooltip_2()); + addImg.addClickHandler(new ClickHandler() { + public void onClick(ClickEvent clickEvent) { + showTagInput(); + } + }); + } }
public LinkedHashSet<Tag> getTags() { @@ -86,40 +117,57 @@ public class TagEditorView extends LocatableLayout { }
public void setTags(LinkedHashSet<Tag> tags) { - this.tags = tags; + this.tags.clear(); + if (tags != null) { + this.tags.addAll(tags); + } setup(); }
- public void setVertical(boolean vertical) { - this.vertical = vertical; - } - @Override protected void onDraw() { super.onDraw(); - setup(); }
private void setup() { - destroyMembers(); + // remove old members + removeMember(tagTitleLabel); + if (tagLayouts != null) { + for (LocatableHLayout tagLayout : tagLayouts) { + removeMember(tagLayout); + tagLayout.destroy(); + } + } + if (addImg != null) { + removeMember(addImg); + } + + // add new members + addMember(tagTitleLabel); + tagLayouts = createTagLayouts(); + for (LocatableHLayout tagLayout : tagLayouts) { + addMember(tagLayout); + } + if (!readOnly) { + addMember(addImg); + tagInputDialog.place(addImg); + }
- Layout layout = vertical ? new LocatableVLayout(getLocatorId()) : new LocatableHLayout(getLocatorId()); - if (!vertical) - layout.setMembersMargin(8); + markForRedraw(); + }
- HTMLFlow title = new HTMLFlow("<b>" + MSG.view_tags_tags() + ":</b>"); - title.setAutoWidth(); - layout.addMember(title); + private ArrayList<LocatableHLayout> createTagLayouts() { + ArrayList<LocatableHLayout> tagLayouts = new ArrayList<LocatableHLayout>(tags.size());
for (final Tag tag : tags) { - LocatableHLayout tagLayout = new LocatableHLayout(((Locatable) layout).extendLocatorId(tag.getName())); + LocatableHLayout tagLayout = new LocatableHLayout(extendLocatorId(tag.getName())); tagLayout.setHeight(18); + tagLayout.setHeight(16);
HTMLFlow tagString = new HTMLFlow("<a href="" + LinkManager.getTagLink(tag.toString()) + "">" + tag.toString() + "</a>"); tagString.setAutoWidth(); - tagLayout.addMember(tagString);
if (!readOnly) { @@ -136,6 +184,7 @@ public class TagEditorView extends LocatableLayout { save(); } }); + tagLayout.addMember(remove); tagLayout.addMember(spacer); remove.hide(); @@ -154,38 +203,13 @@ public class TagEditorView extends LocatableLayout { }); }
- tagLayout.setHeight(16); - layout.addMember(tagLayout); - } - - if (!readOnly) { - final Img modeImg = new LocatableImg(((Locatable) layout).getLocatorId(), "[skin]/images/actions/add.png", - 16, 16); - - modeImg.setTooltip(MSG.view_tags_tooltip_2()); - modeImg.addClickHandler(new ClickHandler() { - public void onClick(ClickEvent clickEvent) { - - showTagInput(modeImg.getAbsoluteLeft(), modeImg.getAbsoluteTop()); - } - }); - layout.addMember(modeImg); + tagLayouts.add(tagLayout); }
- layout.setAutoWidth(); - addMember(layout); - - markForRedraw(); + return tagLayouts; }
- private void showTagInput(int left, int top) { - final LocatableDialog dialog = new LocatableDialog(getLocatorId()); - final LocatableDynamicForm form = new LocatableDynamicForm(dialog.getLocatorId()); - final ComboBoxItem tagInput = new ComboBoxItem("tag"); - - tagInput.setShowTitle(false); - tagInput.setHideEmptyPickList(true); - // tagInput.setOptionDataSource(new TaggingDataSource()); + private void showTagInput() { TagCriteria criteria = new TagCriteria(); criteria.addSortNamespace(PageOrdering.ASC); criteria.addSortSemantic(PageOrdering.ASC); @@ -201,69 +225,82 @@ public class TagEditorView extends LocatableLayout { for (Tag tag : result) { values[i++] = tag.toString(); } - tagInput.setValueMap(values); + tagInputDialog.setTagSuggestions(values); } });
- tagInput.setValueField("tag"); - tagInput.setDisplayField("tag"); - tagInput.setType("comboBox"); - tagInput.setTextMatchStyle(TextMatchStyle.SUBSTRING); - tagInput.setTooltip(MSG.view_tags_tooltip_3()); - /*tagInput.addBlurHandler(new BlurHandler() { - public void onBlur(BlurEvent blurEvent) { - String tag = form.getValueAsString("tag"); - if (tag != null) { - Tag newTag = new Tag(tag); - tags.add(newTag); - save(); - // TagEditorView.this.setup(); - } - } - });*/ - tagInput.addKeyPressHandler(new KeyPressHandler() { - public void onKeyPress(KeyPressEvent event) { - if ((event.getCharacterValue() != null) && (event.getCharacterValue() == KeyCodes.KEY_ENTER)) { - String tag = form.getValueAsString("tag"); - if (tag != null) { - Tag newTag = new Tag(tag); - tags.add(newTag); - save(); - dialog.destroy(); - // TagEditorView.this.setup(); - } - } - } - }); - - form.setFields(tagInput); - - dialog.setIsModal(true); - dialog.setShowHeader(false); - dialog.setShowEdges(false); - dialog.setEdgeSize(10); - dialog.setWidth(200); - dialog.setHeight(30); - - dialog.setShowToolbar(false); - - Map bodyDefaults = new HashMap(); - bodyDefaults.put("layoutLeftMargin", 5); - bodyDefaults.put("membersMargin", 10); - dialog.setBodyDefaults(bodyDefaults); - - dialog.addItem(form); - - dialog.setDismissOnEscape(true); - dialog.setDismissOnOutsideClick(true); - - dialog.show(); - dialog.moveTo(left - 8, top - 4); - tagInput.focusInItem(); + tagInputDialog.show(); + tagInputDialog.place(addImg); + markForRedraw(); }
private void save() { this.callback.tagsChanged(tags); TagEditorView.this.setup(); } + + private class TagInputDialog extends LocatableDialog { + private ComboBoxItem tagInputItem; + + public TagInputDialog(String locatorId) { + super(locatorId); + + setIsModal(true); + setShowHeader(false); + setShowEdges(false); + setEdgeSize(10); + setWidth(200); + setHeight(30); + setShowToolbar(false); + setDismissOnEscape(true); + setDismissOnOutsideClick(true); + Map<String, Integer> bodyDefaults = new HashMap<String, Integer>(2); + bodyDefaults.put("layoutLeftMargin", 5); + bodyDefaults.put("membersMargin", 10); + setBodyDefaults(bodyDefaults); + + final LocatableDynamicForm form = new LocatableDynamicForm(extendLocatorId("tagInputForm")); + addItem(form); + + tagInputItem = new ComboBoxItem("tag"); + tagInputItem.setShowTitle(false); + tagInputItem.setHideEmptyPickList(true); + tagInputItem.setValueField("tag"); + tagInputItem.setDisplayField("tag"); + tagInputItem.setType("comboBox"); + tagInputItem.setTextMatchStyle(TextMatchStyle.SUBSTRING); + tagInputItem.setTooltip(MSG.view_tags_tooltip_3()); + tagInputItem.addKeyPressHandler(new KeyPressHandler() { + public void onKeyPress(KeyPressEvent event) { + if ((event.getCharacterValue() != null) && (event.getCharacterValue() == KeyCodes.KEY_ENTER)) { + //String tag = form.getValueAsString("tag"); + String tag = tagInputItem.getEnteredValue(); + if (tag != null) { + Tag newTag = new Tag(tag); + tags.add(newTag); + TagEditorView.this.save(); + TagInputDialog.this.hide(); + } + } + } + }); + form.setFields(tagInputItem); + } + + @Override + public void show() { + super.show(); + tagInputItem.clearValue(); + tagInputItem.focusInItem(); + } + + public void setTagSuggestions(String[] suggestions) { + tagInputItem.setValueMap(suggestions); + } + + public void place(Canvas canvas) { + // move this object over top the given canvas + moveTo(canvas.getAbsoluteLeft() - 8, canvas.getAbsoluteTop() - 4); + } + } }
commit c9efcac6010e5a0a6f64472d1465d8e3cd991545 Author: Ian Springer ian.springer@redhat.com Date: Wed Mar 23 16:58:19 2011 -0400
implement "perfect caching" for GWT-compiled URLs (https://bugzilla.redhat.com/show_bug.cgi?id=617729)
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/filter/CacheControlFilter.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/filter/CacheControlFilter.java new file mode 100644 index 0000000..3f49857 --- /dev/null +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/filter/CacheControlFilter.java @@ -0,0 +1,76 @@ +/* + * RHQ Management Platform + * Copyright (C) 2011 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.server.filter; + +import javax.servlet.Filter; +import javax.servlet.FilterChain; +import javax.servlet.FilterConfig; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.Date; + +/** + * Specify the cache policy browsers should use for GWT-compiled files. See + * http://code.google.com/webtoolkit/doc/latest/DevGuideCompilingAndDebugging.h... for more info. + * + * @author Ian Springer + */ +public class CacheControlFilter implements Filter { + + private static final long SECONDS_IN_ONE_YEAR = 365 * 24 * 60 * 60L; + private static final long MILLISECONDS_IN_ONE_YEAR = SECONDS_IN_ONE_YEAR * 1000; + + public void init(FilterConfig config) throws ServletException { + return; + } + + public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, + ServletException { + HttpServletRequest httpServletRequest = (HttpServletRequest) request; + String requestURI = httpServletRequest.getRequestURI(); + + if (requestURI.contains(".nocache.")) { + // Tell browser to disable caching of the content. + Date now = new Date(); + HttpServletResponse httpResponse = (HttpServletResponse) response; + httpResponse.setDateHeader("Date", now.getTime()); + httpResponse.setDateHeader("Expires", now.getTime() - 1); + httpResponse.setHeader("Pragma", "no-cache"); + httpResponse.setHeader("Cache-Control", "public, max-age=0, must-revalidate"); + } else if (requestURI.contains(".cache.")) { + // Tell browser to cache the content for one year. + Date now = new Date(); + HttpServletResponse httpResponse = (HttpServletResponse) response; + httpResponse.setDateHeader("Date", now.getTime()); + httpResponse.setDateHeader("Expires", now.getTime() + MILLISECONDS_IN_ONE_YEAR); + httpResponse.setHeader("Cache-Control", "max-age=" + SECONDS_IN_ONE_YEAR); + } + + filterChain.doFilter(request, response); + } + + public void destroy() { + return; + } + +} diff --git a/modules/enterprise/gui/coregui/src/main/webapp/WEB-INF/web.xml b/modules/enterprise/gui/coregui/src/main/webapp/WEB-INF/web.xml index ac247b1..d06fa58 100644 --- a/modules/enterprise/gui/coregui/src/main/webapp/WEB-INF/web.xml +++ b/modules/enterprise/gui/coregui/src/main/webapp/WEB-INF/web.xml @@ -7,6 +7,15 @@
<display-name>RHQ GUI</display-name>
+ <filter> + <filter-name>CacheControlFilter</filter-name> + <filter-class>org.rhq.enterprise.gui.coregui.server.filter.CacheControlFilter</filter-class> + </filter> + + <filter-mapping> + <filter-name>CacheControlFilter</filter-name> + <url-pattern>/*</url-pattern> + </filter-mapping>
<servlet> <servlet-name>org.rhq.enterprise.gui.coregui.CoreGUI RoleGWTService</servlet-name>
commit 2dfc4a34aa925d2683bb6dff736e5154fbe6c443 Author: Ian Springer ian.springer@redhat.com Date: Wed Mar 23 13:21:21 2011 -0400
some changes to locators in Table sub-widgets to make sure locators are hierarchal
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 9d1c1ba..c68da84 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 @@ -458,11 +458,12 @@ public class ConfigurationEditor extends LocatableVLayout { Menu menu = new LocatableMenu(toolStrip.extendLocatorId("JumpMenu")); for (SectionStackSection section : sectionStack.getSections()) { MenuItem item = new MenuItem(section.getTitle()); + item.setAttribute("name", section.getName()); item.addClickHandler(new ClickHandler() { public void onClick(MenuItemClickEvent event) { - int x = event.getMenu().getItemNum(event.getItem()); - sectionStack.expandSection(x); - sectionStack.showSection(x); + int index = event.getMenu().getItemNum(event.getItem()); + sectionStack.expandSection(index); + sectionStack.showSection(index); } }); menu.addItem(item); @@ -491,13 +492,14 @@ public class ConfigurationEditor extends LocatableVLayout { section = new SectionStackSection(MSG.common_title_generalProp()); section.setExpanded(true); } else { - section = new SectionStackSection( - "<div style="float:left; font-weight: bold;">" + String title = "<div style="float:left; font-weight: bold;">" + group.getDisplayName() + "</div>" + (group.getDescription() != null ? ("<div style='padding-left: 10px; font-weight: normal; font-size: smaller; float: left;'>" - + " - " + group.getDescription() + "</div>") - : "")); + + " - " + group.getDescription() + "</div>") + : ""); + section = new SectionStackSection(title); + section.setName(group.getName()); section.setExpanded(!group.isDefaultHidden()); }
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 4864145..b22a79a 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 @@ -52,7 +52,6 @@ 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.HiddenItem; import com.smartgwt.client.widgets.form.fields.SelectItem; @@ -72,7 +71,6 @@ import com.smartgwt.client.widgets.layout.LayoutSpacer; import com.smartgwt.client.widgets.menu.IMenuButton; import com.smartgwt.client.widgets.menu.MenuItem; import com.smartgwt.client.widgets.menu.events.MenuItemClickEvent; -import com.smartgwt.client.widgets.toolbar.ToolStrip;
import org.rhq.core.domain.search.SearchSubsystem; import org.rhq.enterprise.gui.coregui.client.CoreGUI; @@ -80,11 +78,13 @@ import org.rhq.enterprise.gui.coregui.client.RefreshableView; import org.rhq.enterprise.gui.coregui.client.components.form.SearchBarItem; import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource; import org.rhq.enterprise.gui.coregui.client.util.message.Message; +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.LocatableIButton; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIMenuButton; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableListGrid; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableMenu; +import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableToolStrip; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout; import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
@@ -133,8 +133,8 @@ public class Table<DS extends RPCDataSource> extends LocatableHLayout implements private boolean tableActionDisableOverride = false; protected List<Canvas> extraWidgetsAboveFooter = new ArrayList<Canvas>(); protected List<Canvas> extraWidgetsInMainFooter = new ArrayList<Canvas>(); - private ToolStrip footer; - private ToolStrip footerExtraWidgets; + private LocatableToolStrip footer; + private LocatableToolStrip footerExtraWidgets;
public Table(String locatorId) { this(locatorId, null, null, null, null, true); @@ -210,7 +210,7 @@ public class Table<DS extends RPCDataSource> extends LocatableHLayout implements protected void onInit() { super.onInit();
- contents = new LocatableVLayout(extendLocatorId("tableContents")); + contents = new LocatableVLayout(extendLocatorId("Contents")); contents.setWidth100(); contents.setHeight100(); //contents.setOverflow(Overflow.AUTO); @@ -287,7 +287,7 @@ public class Table<DS extends RPCDataSource> extends LocatableHLayout implements setTableTitle(this.tableTitle);
if (showHeader) { - titleLayout = new HLayout(); + titleLayout = new LocatableHLayout(contents.extendLocatorId("Title")); titleLayout.setAutoHeight(); titleLayout.setAlign(VerticalAlignment.BOTTOM); contents.addMember(titleLayout, 0); @@ -301,16 +301,16 @@ public class Table<DS extends RPCDataSource> extends LocatableHLayout implements
// Footer
- // A second toolstrip that optionaly appears before the main footer - it will contain extra widgets. + // A second toolstrip that optionally appears before the main footer - it will contain extra widgets. // This is hidden from view unless extra widgets are actually added to the table above the main footer. - this.footerExtraWidgets = new ToolStrip(); + this.footerExtraWidgets = new LocatableToolStrip(contents.extendLocatorId("FooterExtraWidgets")); footerExtraWidgets.setPadding(5); footerExtraWidgets.setWidth100(); footerExtraWidgets.setMembersMargin(15); footerExtraWidgets.hide(); contents.addMember(footerExtraWidgets);
- this.footer = new ToolStrip(); + this.footer = new LocatableToolStrip(contents.extendLocatorId("Footer")); footer.setPadding(5); footer.setWidth100(); footer.setMembersMargin(15); @@ -747,7 +747,17 @@ public class Table<DS extends RPCDataSource> extends LocatableHLayout implements
public void addTableAction(String locatorId, String title, String confirmation, LinkedHashMap<String, ? extends Object> valueMap, TableAction tableAction) { - TableActionInfo info = new TableActionInfo(locatorId, title, confirmation, valueMap, tableAction); + // If the specified locator ID is qualified, strip off the ancestry prefix, so we can make sure its locator ID + // extends the footer's locator ID as it should. + int underscoreIndex = locatorId.lastIndexOf('_'); + String unqualifiedLocatorId; + if (underscoreIndex >= 0 && underscoreIndex != (locatorId.length() - 1)) { + unqualifiedLocatorId = locatorId.substring(underscoreIndex + 1); + } else { + unqualifiedLocatorId = locatorId; + } + TableActionInfo info = new TableActionInfo(this.footer.extendLocatorId(unqualifiedLocatorId), title, + confirmation, valueMap, tableAction); tableActions.add(info); }
@@ -894,7 +904,7 @@ public class Table<DS extends RPCDataSource> extends LocatableHLayout implements * * @author Joseph Marques */ - private static class TableFilter extends DynamicForm implements KeyPressHandler, ChangedHandler, + private static class TableFilter extends LocatableDynamicForm implements KeyPressHandler, ChangedHandler, com.google.gwt.event.dom.client.KeyPressHandler {
private Table<?> table; @@ -902,7 +912,7 @@ public class Table<DS extends RPCDataSource> extends LocatableHLayout implements private HiddenItem hiddenItem;
public TableFilter(Table<?> table) { - super(); + super(table.extendLocatorId("TableFilter")); setWidth100(); setPadding(5); this.table = table; @@ -1050,4 +1060,5 @@ public class Table<DS extends RPCDataSource> extends LocatableHLayout implements protected SearchSubsystem getSearchSubsystem() { return null; } + } 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 e090640..01921e6 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 @@ -39,7 +39,7 @@ public class ObjectFilter { for (Object object : collection) { filterFields(object, goodFields); } - com.allen_sauer.gwt.log.client.Log.info("Object filtered from size [" + sizeOfBefore + "] to [" + sizeOf(collection) + "]"); + Log.debug("Object filtered from size [" + sizeOfBefore + "] to [" + sizeOf(collection) + "]");
return collection; } @@ -80,4 +80,5 @@ public class ObjectFilter { } return -1; } + }
commit 42eaa4d6e29b325f94539bcb87d6f2155706df18 Author: John Mazzitelli mazz@redhat.com Date: Wed Mar 23 13:04:27 2011 -0400
remove unused, obsolete code
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tagging/TagEditorView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tagging/TagEditorView.java index 522c9cd..14f9a39 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tagging/TagEditorView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tagging/TagEditorView.java @@ -66,12 +66,10 @@ public class TagEditorView extends LocatableLayout {
private LinkedHashSet<Tag> tags = new LinkedHashSet<Tag>();
- private boolean editing = false; private boolean readOnly; private TagsChangedCallback callback;
private boolean vertical = false; - private boolean alwaysEdit = false;
public TagEditorView(String locatorId, Set<Tag> tags, boolean readOnly, TagsChangedCallback callback) { super(locatorId); @@ -96,11 +94,6 @@ public class TagEditorView extends LocatableLayout { this.vertical = vertical; }
- public void setAlwaysEdit(boolean alwaysEdit) { - this.alwaysEdit = alwaysEdit; - this.editing = true; - } - @Override protected void onDraw() { super.onDraw(); @@ -122,7 +115,6 @@ public class TagEditorView extends LocatableLayout { for (final Tag tag : tags) { LocatableHLayout tagLayout = new LocatableHLayout(((Locatable) layout).extendLocatorId(tag.getName())); tagLayout.setHeight(18); - //tagLayout.set
HTMLFlow tagString = new HTMLFlow("<a href="" + LinkManager.getTagLink(tag.toString()) + "">" + tag.toString() + "</a>");
commit 15099180a4a54d3d973ab8fe16116787e929c33b Author: John Mazzitelli mazz@redhat.com Date: Wed Mar 23 12:36:09 2011 -0400
be able to view details of the current message in the message bar via right-mouse context menu
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 39648a2..f000569 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 @@ -24,14 +24,22 @@ import com.smartgwt.client.types.Alignment; import com.smartgwt.client.types.Overflow; import com.smartgwt.client.widgets.events.DoubleClickEvent; import com.smartgwt.client.widgets.events.DoubleClickHandler; +import com.smartgwt.client.widgets.events.RightMouseDownEvent; +import com.smartgwt.client.widgets.events.RightMouseDownHandler; +import com.smartgwt.client.widgets.menu.Menu; +import com.smartgwt.client.widgets.menu.MenuItem; +import com.smartgwt.client.widgets.menu.events.ClickHandler; +import com.smartgwt.client.widgets.menu.events.MenuItemClickEvent;
import org.rhq.enterprise.gui.coregui.client.CoreGUI; 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.LocatableMenu;
/** * 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. + * The message will be displayed for 30 seconds and then will be automatically cleared unless + * it is a sticky message. * * @author Ian Springer * @author Jay Shaughnessy @@ -39,32 +47,42 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableLabel; public class MessageBar extends LocatableHLayout implements MessageCenter.MessageListener { private static final String LOCATOR_ID = "MessageBar"; private static final int AUTO_HIDE_DELAY_MILLIS = 30000; - - private LocatableLabel label = new LocatableLabel(extendLocatorId("Label")); - private Message stickyMessage; - private static final String NON_BREAKING_SPACE = " ";
+ private LocatableLabel label; + private Message currentMessage; + private Message stickyMessage; // this message will always be shown until dismissed by user. + private Menu showDetailsMenu; + public MessageBar() { super(LOCATOR_ID); - setOverflow(Overflow.VISIBLE); - } - - @Override - protected void onDraw() { - super.onDraw(); - setWidth100(); setAlign(Alignment.CENTER);
+ label = new LocatableLabel(extendLocatorId("Label")); label.setAlign(Alignment.CENTER); label.setWidth("600px"); label.setHeight("30px"); label.setCanSelectText(true); + addMember(label); + + showDetailsMenu = new LocatableMenu(extendLocatorId("showDetailsMenu")); + MenuItem showDetailsMenuItem = new MenuItem(MSG.view_messageCenter_messageBarShowDetails()); + showDetailsMenuItem.addClickHandler(new ClickHandler() { + @Override + public void onClick(MenuItemClickEvent event) { + MessageCenterView.showDetails(MessageBar.this.currentMessage); + } + }); + showDetailsMenu.setItems(showDetailsMenuItem); + } + + @Override + protected void onDraw() { + super.onDraw();
setLabelEmpty(); - addMember(label);
// sometimes it's annoying to have the error message hang around for too long; // let the user click the message so it goes away on demand @@ -75,12 +93,22 @@ public class MessageBar extends LocatableHLayout implements MessageCenter.Messag } });
+ addRightMouseDownHandler(new RightMouseDownHandler() { + @Override + public void onRightMouseDown(RightMouseDownEvent event) { + if (MessageBar.this.currentMessage != null) { + showDetailsMenu.showContextMenu(); + } + } + }); + CoreGUI.getMessageCenter().addMessageListener(this); }
@Override public void onMessage(Message message) { if (!message.isBackgroundJobResult()) { + this.currentMessage = message; updateLabel(message);
// Auto-clear the message after some time unless it's been designated as sticky. @@ -91,6 +119,7 @@ public class MessageBar extends LocatableHLayout implements MessageCenter.Messag @Override public void run() { clearMessage(false); + // if we had a sticky message before, show it again, now that our more recent message has gone away if (stickyMessage != null) { updateLabel(stickyMessage); } @@ -101,9 +130,9 @@ public class MessageBar extends LocatableHLayout implements MessageCenter.Messag }
public void clearMessage(boolean clearSticky) { + this.currentMessage = null; setLabelEmpty(); markForRedraw(); - if (clearSticky) { this.stickyMessage = null; } @@ -123,13 +152,6 @@ public class MessageBar extends LocatableHLayout implements MessageCenter.Messag String styleName = (contents != null) ? message.getSeverity().getStyle() : null; label.setStyleName(styleName);
- // TODO: perhaps just set the text to green/orange/red along with the proper icon and not have the defined - // color block... - - // TODO: Create some custom edge images in green, yellow, red, etc. so we can add nice rounded corners to the - // label. - //label.setShowEdges(true); - String icon = (contents != null) ? message.getSeverity().getIcon() : 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 f9ac79c..f861a37 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 @@ -317,8 +317,18 @@ public class MessageCenterView extends Table implements MessageCenter.MessageLis return record; }
- private void showDetails(Message message) { - DynamicForm form = new LocatableDynamicForm(extendLocatorId("Details")); + /** + * This is a static utility method that is package protected so the message center view + * and the message bar can pop up a dialog showing a message's details. + * + * @param message the message whose details are to be shown + */ + static void showDetails(Message message) { + if (message == null) { + return; + } + + DynamicForm form = new LocatableDynamicForm("MessageCenterDetailsForm"); form.setWrapItemTitles(false); form.setAlign(Alignment.LEFT);
@@ -340,7 +350,7 @@ public class MessageCenterView extends Table implements MessageCenter.MessageLis
form.setItems(title, severity, date, detail);
- final Window dialogWin = new LocatableWindow(this.extendLocatorId("MessageWindow")); + final Window dialogWin = new LocatableWindow("MessageCenterDetailsWindow"); dialogWin.setTitle(MSG.common_title_message()); dialogWin.setWidth(600); dialogWin.setHeight(400); @@ -360,7 +370,7 @@ public class MessageCenterView extends Table implements MessageCenter.MessageLis }); }
- private String getSeverityIcon(Message.Severity severity) { + private static String getSeverityIcon(Message.Severity severity) { if (severity == null) { severity = Severity.Blank; } diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties index 678ba25..56b7270 100644 --- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties +++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties @@ -2096,3 +2096,4 @@ view_messageCenter_messageTime = Time view_messageCenter_messageSeverity = Severity view_messageCenter_messageDetail = Detail view_messageCenter_stackTraceFollows = --- STACK TRACE FOLLOWS --- +view_messageCenter_messageBarShowDetails = Show Details
commit e11fec9247d8995bb668d040b119f0a657dc983a Merge: 58043cd 308f9f8 Author: Heiko W. Rupp hwr@redhat.com Date: Wed Mar 23 16:47:59 2011 +0100
Merge branch 'master' of ssh://git.fedorahosted.org/git/rhq/rhq
commit 308f9f8d0ea4e019c3439d79e259a20f8ee39162 Author: Jay Shaughnessy jshaughn@redhat.com Date: Wed Mar 23 10:09:24 2011 -0400
trivial: add import lost in merge
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupMetricsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupMetricsPortlet.java index 7c748fa..898c04b 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupMetricsPortlet.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupMetricsPortlet.java @@ -66,6 +66,7 @@ import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.ResourceGro import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository; import org.rhq.enterprise.gui.coregui.client.resource.disambiguation.ReportDecorator; import org.rhq.enterprise.gui.coregui.client.util.BrowserUtility; +import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableCanvas; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
commit b649b2f2f9853879ec2494df9510b04cbaac0dd7 Author: Jay Shaughnessy jshaughn@redhat.com Date: Wed Mar 23 10:09:06 2011 -0400
More Tabbing Fun There are multiple ways that during one rendering of tabs we can get a request for another. We need to shut down user and smartgwt initiated tab selection events until we're ready (until we've finished the previous rendering). Hopefully this finally gets it right. I added some more comments in this for the next unlucky soul (well, probably me...). I think I also may have gotten rid of some unwanted, duplicate rendering.
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 7413dae..6329f67 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 @@ -38,6 +38,8 @@ public class TwoLevelTabSet extends NamedTabSet implements TabSelectedHandler, T /** maps Tab locator IDs to Tabs. */ private Map<String, TwoLevelTab> hiddenTabs = new LinkedHashMap<String, TwoLevelTab>();
+ private boolean ignoreSelectEvents = false; + public TwoLevelTabSet(String locatorId) { super(locatorId); } @@ -109,7 +111,15 @@ public class TwoLevelTabSet extends NamedTabSet implements TabSelectedHandler, T return m.addHandler(TwoLevelTabSelectedEvent.TYPE, handler); }
+ // This is invoked by smartgwt when the user clicks on a Tab in the TabSet, or TabSet.selectTab() is called. It + // sets the current SubTab and fires an event to notify AbstractTwoLevelTabSet that a tab/subtab has been selected. public void onTabSelected(TabSelectedEvent tabSelectedEvent) { + // if requested, ignore select tab notifications. smartgwt can generate unwanted notifications + // while we manipulate the tabset (e.g. when hiding the current tab). We want to manage this at a higher level + if (isIgnoreSelectEvents()) { + return; + } + TwoLevelTab tab = (TwoLevelTab) getSelectedTab(); SubTab currentSubTab = tab.getLayout().getCurrentSubTab(); if (null != currentSubTab) { @@ -119,7 +129,15 @@ public class TwoLevelTabSet extends NamedTabSet implements TabSelectedHandler, T } }
+ // This is invoked by an event fired in SubTabLayout when the user clicks a SubTab button. It sets the Tab + // and fires an event to notify AbstractTwoLevelTabSet that a tab/subtab has been selected. public void onTabSelected(TwoLevelTabSelectedEvent tabSelectedEvent) { + // if requested, ignore select tab notifications. smartgwt can generate unwanted notifications + // while we manipulate the tabset (e.g. when hiding the current tab). We want to manage this at a higher level + if (isIgnoreSelectEvents()) { + return; + } + tabSelectedEvent.setTabNum(getSelectedTabNumber()); Tab tab = getSelectedTab(); tabSelectedEvent.setId(this.getTabByTitle(tab.getTitle()).getName()); @@ -156,6 +174,14 @@ public class TwoLevelTabSet extends NamedTabSet implements TabSelectedHandler, T } }
+ public boolean isIgnoreSelectEvents() { + return ignoreSelectEvents; + } + + public void setIgnoreSelectEvents(boolean ignoreSelectEvents) { + this.ignoreSelectEvents = ignoreSelectEvents; + } + @Override public void destroy() { // add the hidden tabs back under the TabSet. This will get them destroyed by smartgwt when the tabset @@ -168,4 +194,5 @@ public class TwoLevelTabSet extends NamedTabSet implements TabSelectedHandler, T } super.destroy(); } + } 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 e303c50..04d6410 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 @@ -133,18 +133,21 @@ public abstract class AbstractTwoLevelTabSetView<T, U extends Layout> extends Lo } }
+ // This is invoked by events fired in TwoLevelTabSet whenever a tab/subtab combo has been selected. public void onTabSelected(TwoLevelTabSelectedEvent tabSelectedEvent) {
- // We want to finish the tab selection process, which may involve async loading of content, - // before allowing more tab selection. This avoids potential tab "looping" that happens when a new - // tab is selected before the previous one could finish loading. So, disable the tab set here, and - // re-enable it later when the tab content is actuall rendered (see selectTab). + // Establishing the proper tabbed view may involve tab add/remove and async loading of content. While doing this + // we want to prevent user initiation of another tab change. To block users from clicking tabs we + // disable the tab set. We re-enable the tabset when safe. (see this method and also selectTab()).
if (getSelectedItemId() == null) { this.tabSet.disable(); CoreGUI.goToView(History.getToken()); + } else { - String tabPath = "/" + tabSelectedEvent.getId() + "/" + tabSelectedEvent.getSubTabId(); + String tabId = tabSelectedEvent.getId(); + String subTabId = tabSelectedEvent.getSubTabId(); + String tabPath = "/" + tabId + "/" + subTabId; String path = this.baseViewPath + "/" + getSelectedItemId() + tabPath;
// If the selected tab or subtab is not already the current history item, the user clicked on the tab, rather @@ -153,11 +156,16 @@ public abstract class AbstractTwoLevelTabSetView<T, U extends Layout> extends Lo if (!(History.getToken().equals(path) || History.getToken().startsWith(path + "/"))) { this.tabSet.disable(); CoreGUI.goToView(path); + + } else { + // ensure the tabset is enabled if we're not going to be doing any further tab selection + this.tabSet.enable(); } } }
public void renderView(final ViewPath viewPath) { + new PermissionsLoader().loadExplicitGlobalPermissions(new PermissionsLoadedListener() { @Override public void onPermissionsLoaded(Set<Permission> permissions) { @@ -168,6 +176,7 @@ public abstract class AbstractTwoLevelTabSetView<T, U extends Layout> extends Lo }
private void renderTabs(final ViewPath viewPath) { + // e.g. #Resource/10010/Summary/Overview // ^ current path final int id = Integer.parseInt(viewPath.getCurrent().getPath()); @@ -191,10 +200,19 @@ public abstract class AbstractTwoLevelTabSetView<T, U extends Layout> extends Lo }
if (getSelectedItemId() == null || getSelectedItemId() != id) { - loadSelectedItem(id, viewPath); + // A different entity (resource or group), load it and try to navigate to the same tabs if possible. + // Changing entities may change the available tabs as the same tab set may not be supported by the + // new entity's type. To maintain a valid tab selection for the TabSet, smartgwt will generate an + // events if the current tab is removed (which can happen say, when navigating from a resource of type A + // to a resource of type B). We need to ignore tab selection events generated by smartgwt because we + // handle this at a higher level. To do this we explicitly set events to be be ignored. We re-enable + // the event handling when safe. (see selectTab()). + this.tabSet.setIgnoreSelectEvents(true); + this.loadSelectedItem(id, viewPath); + } else { // Same Resource - just switch tabs. - selectTab(this.tabName, this.subTabName, viewPath); + this.selectTab(this.tabName, this.subTabName, viewPath); } }
@@ -210,23 +228,36 @@ public abstract class AbstractTwoLevelTabSetView<T, U extends Layout> extends Lo TwoLevelTab tab = (tabName != null) ? this.tabSet.getTabByName(tabName) : null; SubTab subtab = null;
+ // if the requested tab is not available for the tabset then select the defaults (firing a new event) if (tab == null || tab.getDisabled()) { + this.tabSet.setIgnoreSelectEvents(false); subtab = selectDefaultTabAndSubTab(); - } else { - // Do *not* select the tab and trigger the tab selected event until the subtab has been selected first. - subtab = (subtabName != null) ? tab.getSubTabByName(subtabName) : tab.getDefaultSubTab(); - if (subtab == null || tab.getLayout().isSubTabDisabled(subtab)) { - // due to our attempt to perform sticky tabbing we may request an invalid subtab when - // switching resources. Just silently go to the default tab/subtab. - subtab = tab.getLayout().getDefaultSubTab(); - } - tab.getLayout().selectSubTab(subtab); - - // Now that the subtab has been selected, select the tab (this will cause a tab selected event to fire). + return; + } + + // the tab is available, now get the subtab + subtab = (subtabName != null) ? tab.getSubTabByName(subtabName) : tab.getDefaultSubTab(); + + // due to our attempt to perform sticky tabbing we may request an invalid subtab when + // switching resources. If the requested subtab is not available the select the default subtab for the tab + if (subtab == null || tab.getLayout().isSubTabDisabled(subtab)) { + subtab = tab.getLayout().getDefaultSubTab(); + } + + // select the subTab (this does not fire an event, just sets the subtab) + tab.getLayout().selectSubTab(subtab); + + // now that the tab/subtab is determined, if currently selected tab is not the desired tab, then + // select it now (firing a new event). + if (!tab.equals(this.tabSet.getSelectedTab())) { + this.tabSet.setIgnoreSelectEvents(false); this.tabSet.selectTab(tab); + return; }
+ // if the desired tab/subtab are already selected, now we can render the subtab canvas Canvas subView = subtab.getCanvas(); + if (subView instanceof BookmarkableView) { // Handle any remaining view items (e.g. id of a selected item in a subtab that contains a Master-Details view). ((BookmarkableView) subView).renderView(viewPath); @@ -237,8 +268,10 @@ public abstract class AbstractTwoLevelTabSetView<T, U extends Layout> extends Lo }
// ensure the tabset is enabled (disabled in onTabSelected), and redraw + this.tabSet.setIgnoreSelectEvents(false); this.tabSet.enable(); this.tabSet.markForRedraw(); + } catch (Exception e) { this.tabSet.enable(); Log.info("Failed to select tab " + tabName + "/" + subtabName + ": " + e); 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 38e09eb..91f617d 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 @@ -85,7 +85,6 @@ public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceCompo public static class Tab { public static final String OPERATIONS = "Operations"; public static final String CONFIGURATION = "Configuration"; - // TODO: other tabs }
public static class OperationsSubTab { @@ -142,6 +141,8 @@ public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceCompo
public ResourceDetailView(String locatorId) { super(locatorId, BASE_VIEW_PATH); + + // hide until we have our tabs in place this.hide(); }
commit 48ec8e2feb895608ba589bfd36406f939a5f5e47 Author: Jay Shaughnessy jshaughn@redhat.com Date: Tue Mar 22 17:33:26 2011 -0400
Resource/Group dash AutoRefreshPortlets were continuing to refresh even when the Summary/Activity subtab was not being viewed. This generates a lot of background work and db round trips. The reason is that we don't destroy a subtab's canvas if the user stays within the same entity detail view (on the assumption that the user may well revisit the same subtab). Now, skip the refresh request if the subtab canvas is not visible. - consolidate some autoresreshportlet logic into a util class - add isRefreshing() to interface, and also skip the refresh request if the portlet is still refreshing from a previous request (not every ARP currently has this implemented) - get rid of some warnings/unused code
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/AutoRefreshPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/AutoRefreshPortlet.java index 9b23871..897c1b4 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/AutoRefreshPortlet.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/AutoRefreshPortlet.java @@ -32,4 +32,10 @@ public interface AutoRefreshPortlet extends Portlet { * should be canceled when the portlet goes out of scope (typically in an onDestroy() override). */ void startRefreshCycle(); + + /** + * @return true if the portlet is currently responding to a refresh (i.e. reloading data). This can be used + * to ignore refresh requests until a prior request is completed. + */ + boolean isRefreshing(); } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/AutoRefreshPortletUtil.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/AutoRefreshPortletUtil.java new file mode 100644 index 0000000..4977de6 --- /dev/null +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/AutoRefreshPortletUtil.java @@ -0,0 +1,72 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2009 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.dashboard; + +import com.google.gwt.user.client.Timer; +import com.smartgwt.client.widgets.Canvas; + +import org.rhq.enterprise.gui.coregui.client.UserSessionManager; +import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility; + +/** + * @author Jay Shaughnessy + */ +public class AutoRefreshPortletUtil { + + public static Timer startRefreshCycle(final AutoRefreshPortlet portlet, final Canvas autoRefreshPortletCanvas, + Timer refreshTimer) { + + final int refreshInterval = UserSessionManager.getUserPreferences().getPageRefreshInterval(); + + //cancel any existing timer + if (null != refreshTimer) { + refreshTimer.cancel(); + } + + if (refreshInterval >= MeasurementUtility.MINUTES) { + + refreshTimer = new Timer() { + public void run() { + + // if the portlet is already refreshing or if the portlet is not currently on screen then + // don't bother doing the work. this protects against unnecessary or unwanted db queries + // being performed in the background. + if (!portlet.isRefreshing() && autoRefreshPortletCanvas.isVisible()) { + autoRefreshPortletCanvas.redraw(); + } + } + }; + + refreshTimer.scheduleRepeating(refreshInterval); + } + + return refreshTimer; + } + + public static void onDestroy(final Canvas portlet, Timer refreshTimer) { + + if (refreshTimer != null) { + + refreshTimer.cancel(); + } + + } + +} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet.java index cc14736..740d549 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet.java @@ -43,12 +43,11 @@ import org.rhq.core.domain.dashboard.DashboardPortlet; import org.rhq.core.domain.resource.ResourceType; import org.rhq.enterprise.gui.coregui.client.CoreGUI; import org.rhq.enterprise.gui.coregui.client.LinkManager; -import org.rhq.enterprise.gui.coregui.client.Messages; -import org.rhq.enterprise.gui.coregui.client.UserSessionManager; import org.rhq.enterprise.gui.coregui.client.alert.AlertHistoryView; import org.rhq.enterprise.gui.coregui.client.alert.AlertPortletConfigurationDataSource; import org.rhq.enterprise.gui.coregui.client.components.measurement.CustomConfigMeasurementRangeEditor; import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortlet; +import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortletUtil; 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; @@ -56,7 +55,6 @@ import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow; import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.PortletConfigurationEditorComponent; import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.alerts.PortletAlertSelector; import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.summary.AbstractActivityView; -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.LocatableVLayout; import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility; @@ -216,7 +214,6 @@ public class GroupAlertsPortlet extends AlertHistoryView implements CustomSettin
@Override public void onSubmitValues(SubmitValuesEvent event) { - String selectedValue; //alert severity portletConfig = AbstractActivityView.saveAlertPrioritySettings(alertPrioritySelector, portletConfig);
@@ -260,37 +257,21 @@ public class GroupAlertsPortlet extends AlertHistoryView implements CustomSettin } }
- @Override public void startRefreshCycle() { - //current setting - final int refreshInterval = UserSessionManager.getUserPreferences().getPageRefreshInterval(); - - //cancel any existing timer - if (refreshTimer != null) { - refreshTimer.cancel(); - } - - if (refreshInterval >= MeasurementUtility.MINUTES) { - - refreshTimer = new Timer() { - public void run() { - redraw(); - } - }; - - refreshTimer.scheduleRepeating(refreshInterval); - } + refreshTimer = AutoRefreshPortletUtil.startRefreshCycle(this, this, refreshTimer); }
@Override protected void onDestroy() { - if (refreshTimer != null) { - refreshTimer.cancel(); - } + AutoRefreshPortletUtil.onDestroy(this, refreshTimer);
super.onDestroy(); }
+ public boolean isRefreshing() { + return false; + } + @Override protected void setupTableInteractions(boolean hasWriteAccess) { // The portlet is a "subsystem" view. Meaning the alerts displayed can be from any accessible group for @@ -363,7 +344,6 @@ final class AlertResourceSelectorRegion extends LocatableVLayout { this.currentlyAssignedIds = assigned; }
- private static final Messages MSG = CoreGUI.getMessages(); private PortletAlertSelector selector = null;
private Integer[] currentlyAssignedIds; diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet3.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet3.java index 7c166ad..2a2b3ac 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet3.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet3.java @@ -46,9 +46,9 @@ import org.rhq.core.domain.util.PageControl; import org.rhq.core.domain.util.PageList; import org.rhq.core.domain.util.PageOrdering; import org.rhq.enterprise.gui.coregui.client.ImageManager; -import org.rhq.enterprise.gui.coregui.client.UserSessionManager; import org.rhq.enterprise.gui.coregui.client.components.measurement.CustomConfigMeasurementRangeEditor; import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortlet; +import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortletUtil; 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; @@ -60,7 +60,6 @@ import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.summary.AbstractActivityView; import org.rhq.enterprise.gui.coregui.client.resource.disambiguation.ReportDecorator; import org.rhq.enterprise.gui.coregui.client.util.GwtRelativeDurationConverter; -import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableCanvas; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout; @@ -207,10 +206,10 @@ public class GroupAlertsPortlet3 extends LocatableVLayout implements CustomSetti if (property != null) { String currentSetting = property.getStringValue(); if (currentSetting.trim().isEmpty() || currentSetting.equalsIgnoreCase("5")) { - PageControl pageControl = new PageControl(0, 5); + //PageControl pageControl = new PageControl(0, 5); pc.setPageSize(5); } else { - PageControl pageControl = new PageControl(0, Integer.valueOf(currentSetting)); + //PageControl pageControl = new PageControl(0, Integer.valueOf(currentSetting)); pc.setPageSize(Integer.valueOf(currentSetting)); } } @@ -356,40 +355,21 @@ public class GroupAlertsPortlet3 extends LocatableVLayout implements CustomSetti return customSettings; }
- @Override public void startRefreshCycle() { - //current setting - final int refreshInterval = UserSessionManager.getUserPreferences().getPageRefreshInterval(); - - //cancel any existing timer - if (refreshTimer != null) { - refreshTimer.cancel(); - } - - if (refreshInterval >= MeasurementUtility.MINUTES) { - - refreshTimer = new Timer() { - public void run() { - if (!currentlyLoading) { - loadData(); - redraw(); - } - } - }; - - refreshTimer.scheduleRepeating(refreshInterval); - } + refreshTimer = AutoRefreshPortletUtil.startRefreshCycle(this, this, refreshTimer); }
@Override protected void onDestroy() { - if (refreshTimer != null) { + AutoRefreshPortletUtil.onDestroy(this, refreshTimer);
- refreshTimer.cancel(); - } super.onDestroy(); }
+ public boolean isRefreshing() { + return this.currentlyLoading; + } + @Override public void redraw() { super.redraw(); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupBundleDeploymentsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupBundleDeploymentsPortlet.java index 2c4fdc1..4d163ab 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupBundleDeploymentsPortlet.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupBundleDeploymentsPortlet.java @@ -43,8 +43,8 @@ import org.rhq.core.domain.dashboard.DashboardPortlet; import org.rhq.core.domain.util.PageControl; import org.rhq.core.domain.util.PageList; import org.rhq.core.domain.util.PageOrdering; -import org.rhq.enterprise.gui.coregui.client.UserSessionManager; import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortlet; +import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortletUtil; 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; @@ -55,7 +55,6 @@ import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.summary.AbstractActivityView; import org.rhq.enterprise.gui.coregui.client.resource.disambiguation.ReportDecorator; import org.rhq.enterprise.gui.coregui.client.util.GwtRelativeDurationConverter; -import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableCanvas; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout; @@ -263,37 +262,21 @@ public class GroupBundleDeploymentsPortlet extends LocatableVLayout implements C }); }
- @Override public void startRefreshCycle() { - //current setting - final int refreshInterval = UserSessionManager.getUserPreferences().getPageRefreshInterval(); - - //cancel any existing timer - if (refreshTimer != null) { - refreshTimer.cancel(); - } - - if (refreshInterval >= MeasurementUtility.MINUTES) { - refreshTimer = new Timer() { - public void run() { - if (!currentlyLoading) { - loadData(); - redraw(); - } - } - }; - refreshTimer.scheduleRepeating(refreshInterval); - } + refreshTimer = AutoRefreshPortletUtil.startRefreshCycle(this, this, refreshTimer); }
@Override protected void onDestroy() { - if (refreshTimer != null) { - refreshTimer.cancel(); - } + AutoRefreshPortletUtil.onDestroy(this, refreshTimer); + super.onDestroy(); }
+ public boolean isRefreshing() { + return this.currentlyLoading; + } + @Override public void redraw() { super.redraw(); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupEventsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupEventsPortlet.java index ec4dae7..3b069c5 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupEventsPortlet.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupEventsPortlet.java @@ -39,9 +39,9 @@ import org.rhq.core.domain.configuration.PropertySimple; import org.rhq.core.domain.dashboard.DashboardPortlet; import org.rhq.core.domain.event.EventSeverity; import org.rhq.enterprise.gui.coregui.client.ImageManager; -import org.rhq.enterprise.gui.coregui.client.UserSessionManager; import org.rhq.enterprise.gui.coregui.client.components.measurement.CustomConfigMeasurementRangeEditor; import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortlet; +import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortletUtil; 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; @@ -292,39 +292,21 @@ public class GroupEventsPortlet extends LocatableVLayout implements CustomSettin }); }
- @Override public void startRefreshCycle() { - //current setting - final int refreshInterval = UserSessionManager.getUserPreferences().getPageRefreshInterval(); - - //cancel any existing timer - if (refreshTimer != null) { - refreshTimer.cancel(); - } - - if (refreshInterval >= MeasurementUtility.MINUTES) { - - refreshTimer = new Timer() { - public void run() { - if (!currentlyLoading) { - redraw(); - } - } - }; - - refreshTimer.scheduleRepeating(refreshInterval); - } + refreshTimer = AutoRefreshPortletUtil.startRefreshCycle(this, this, refreshTimer); }
@Override protected void onDestroy() { - if (refreshTimer != null) { + AutoRefreshPortletUtil.onDestroy(this, refreshTimer);
- refreshTimer.cancel(); - } super.onDestroy(); }
+ public boolean isRefreshing() { + return this.currentlyLoading; + } + @Override public void redraw() { super.redraw(); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupMetricsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupMetricsPortlet.java index 5cf7b36..7c748fa 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupMetricsPortlet.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupMetricsPortlet.java @@ -51,9 +51,9 @@ import org.rhq.core.domain.resource.group.GroupCategory; import org.rhq.core.domain.resource.group.ResourceGroup; import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite; import org.rhq.core.domain.util.PageList; -import org.rhq.enterprise.gui.coregui.client.UserSessionManager; import org.rhq.enterprise.gui.coregui.client.components.measurement.CustomConfigMeasurementRangeEditor; import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortlet; +import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortletUtil; 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; @@ -66,7 +66,6 @@ import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.ResourceGro import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository; import org.rhq.enterprise.gui.coregui.client.resource.disambiguation.ReportDecorator; import org.rhq.enterprise.gui.coregui.client.util.BrowserUtility; -import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableCanvas; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout; @@ -454,39 +453,21 @@ public class GroupMetricsPortlet extends LocatableVLayout implements CustomSetti recentMeasurementsContent.markForRedraw(); }
- @Override public void startRefreshCycle() { - //current setting - final int refreshInterval = UserSessionManager.getUserPreferences().getPageRefreshInterval(); - - //cancel any existing timer - if (refreshTimer != null) { - refreshTimer.cancel(); - } - - if (refreshInterval >= MeasurementUtility.MINUTES) { - - refreshTimer = new Timer() { - public void run() { - if (!currentlyLoading) { - loadData(); - redraw(); - } - } - }; - - refreshTimer.scheduleRepeating(refreshInterval); - } + refreshTimer = AutoRefreshPortletUtil.startRefreshCycle(this, this, refreshTimer); }
@Override protected void onDestroy() { - if (refreshTimer != null) { - refreshTimer.cancel(); - } + AutoRefreshPortletUtil.onDestroy(this, refreshTimer); + super.onDestroy(); }
+ public boolean isRefreshing() { + return this.currentlyLoading; + } + @Override public void redraw() { super.redraw(); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOobsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOobsPortlet.java index ed3fb42..265e200 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOobsPortlet.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOobsPortlet.java @@ -40,8 +40,8 @@ import org.rhq.core.domain.configuration.PropertySimple; import org.rhq.core.domain.dashboard.DashboardPortlet; import org.rhq.core.domain.measurement.composite.MeasurementOOBComposite; import org.rhq.core.domain.util.PageList; -import org.rhq.enterprise.gui.coregui.client.UserSessionManager; import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortlet; +import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortletUtil; 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; @@ -51,7 +51,6 @@ import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.PortletConfigura import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.summary.AbstractActivityView; import org.rhq.enterprise.gui.coregui.client.util.GwtRelativeDurationConverter; -import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableCanvas; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout; @@ -243,40 +242,21 @@ public class GroupOobsPortlet extends LocatableVLayout implements CustomSettings }); }
- @Override public void startRefreshCycle() { - //current setting - final int refreshInterval = UserSessionManager.getUserPreferences().getPageRefreshInterval(); - - //cancel any existing timer - if (refreshTimer != null) { - refreshTimer.cancel(); - } - - if (refreshInterval >= MeasurementUtility.MINUTES) { - - refreshTimer = new Timer() { - public void run() { - if (!currentlyLoading) { - loadData(); - redraw(); - } - } - }; - - refreshTimer.scheduleRepeating(refreshInterval); - } + refreshTimer = AutoRefreshPortletUtil.startRefreshCycle(this, this, refreshTimer); }
@Override protected void onDestroy() { - if (refreshTimer != null) { + AutoRefreshPortletUtil.onDestroy(this, refreshTimer);
- refreshTimer.cancel(); - } super.onDestroy(); }
+ public boolean isRefreshing() { + return this.currentlyLoading; + } + @Override public void redraw() { super.redraw(); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOperationsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOperationsPortlet.java index 37813ac..10031d1 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOperationsPortlet.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOperationsPortlet.java @@ -48,9 +48,9 @@ import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite; 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.UserSessionManager; import org.rhq.enterprise.gui.coregui.client.components.measurement.CustomConfigMeasurementRangeEditor; import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortlet; +import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortletUtil; 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; @@ -296,37 +296,21 @@ public class GroupOperationsPortlet extends LocatableVLayout implements CustomSe } }
- @Override public void startRefreshCycle() { - //current setting - final int refreshInterval = UserSessionManager.getUserPreferences().getPageRefreshInterval(); - - //cancel any existing timer - if (refreshTimer != null) { - refreshTimer.cancel(); - } - - if (refreshInterval >= MeasurementUtility.MINUTES) { - - refreshTimer = new Timer() { - public void run() { - redraw(); - } - }; - - refreshTimer.scheduleRepeating(refreshInterval); - } + refreshTimer = AutoRefreshPortletUtil.startRefreshCycle(this, this, refreshTimer); }
@Override protected void onDestroy() { - if (refreshTimer != null) { - refreshTimer.cancel(); - } + AutoRefreshPortletUtil.onDestroy(this, refreshTimer);
super.onDestroy(); }
+ public boolean isRefreshing() { + return false; + } + private boolean isAutoGroup() { return ResourceGroupDetailView.AUTO_GROUP_VIEW_PATH.equals(getBaseViewPath()); } @@ -355,6 +339,7 @@ class GroupOperationsCriteriaHistoryListView extends GroupOperationHistoryListVi
private ResourceGroupComposite composite;
+ @SuppressWarnings("unchecked") public GroupOperationsCriteriaHistoryListView(String locatorId, GroupOperationsCriteriaDataSource dataSource, String title, Criteria criteria, ResourceGroupComposite composite) { super(locatorId, composite); @@ -363,6 +348,7 @@ class GroupOperationsCriteriaHistoryListView extends GroupOperationHistoryListVi setShowFooterRefresh(false); //disable footer refresh }
+ @SuppressWarnings("unchecked") public void setDatasource(GroupOperationsCriteriaDataSource datasource) { super.setDataSource(datasource); } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupPkgHistoryPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupPkgHistoryPortlet.java index 30c21a7..e58b1da 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupPkgHistoryPortlet.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupPkgHistoryPortlet.java @@ -43,8 +43,8 @@ import org.rhq.core.domain.dashboard.DashboardPortlet; import org.rhq.core.domain.util.PageControl; import org.rhq.core.domain.util.PageList; import org.rhq.core.domain.util.PageOrdering; -import org.rhq.enterprise.gui.coregui.client.UserSessionManager; import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortlet; +import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortletUtil; 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; @@ -54,7 +54,6 @@ import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.PortletConfigura import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.summary.AbstractActivityView; import org.rhq.enterprise.gui.coregui.client.util.GwtRelativeDurationConverter; -import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableCanvas; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout; @@ -260,40 +259,21 @@ public class GroupPkgHistoryPortlet extends LocatableVLayout implements CustomSe }); }
- @Override public void startRefreshCycle() { - //current setting - final int refreshInterval = UserSessionManager.getUserPreferences().getPageRefreshInterval(); - - //cancel any existing timer - if (refreshTimer != null) { - refreshTimer.cancel(); - } - - if (refreshInterval >= MeasurementUtility.MINUTES) { - - refreshTimer = new Timer() { - public void run() { - if (!currentlyLoading) { - loadData(); - redraw(); - } - } - }; - - refreshTimer.scheduleRepeating(refreshInterval); - } + refreshTimer = AutoRefreshPortletUtil.startRefreshCycle(this, this, refreshTimer); }
@Override protected void onDestroy() { - if (refreshTimer != null) { + AutoRefreshPortletUtil.onDestroy(this, refreshTimer);
- refreshTimer.cancel(); - } super.onDestroy(); }
+ public boolean isRefreshing() { + return this.currentlyLoading; + } + @Override public void redraw() { super.redraw(); 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 efa62f7..37d57df 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 @@ -31,15 +31,14 @@ import com.smartgwt.client.widgets.form.fields.events.ChangeHandler;
import org.rhq.core.domain.configuration.PropertySimple; import org.rhq.core.domain.dashboard.DashboardPortlet; -import org.rhq.enterprise.gui.coregui.client.UserSessionManager; import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortlet; +import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortletUtil; 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.resource.discovery.AutodiscoveryQueueDataSource; import org.rhq.enterprise.gui.coregui.client.inventory.resource.discovery.ResourceAutodiscoveryView; -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;
@@ -197,37 +196,19 @@ public class AutodiscoveryPortlet extends ResourceAutodiscoveryView implements C return dataSource; }
- @Override public void startRefreshCycle() { - //current setting - final int refreshInterval = UserSessionManager.getUserPreferences().getPageRefreshInterval(); - - //cancel any existing timer - if (refreshTimer != null) { - refreshTimer.cancel(); - } - - if (refreshInterval >= MeasurementUtility.MINUTES) { - - refreshTimer = new Timer() { - public void run() { - - redraw(); - } - }; - - refreshTimer.scheduleRepeating(refreshInterval); - } + refreshTimer = AutoRefreshPortletUtil.startRefreshCycle(this, this, refreshTimer); }
@Override protected void onDestroy() { - if (refreshTimer != null) { - - refreshTimer.cancel(); - } + AutoRefreshPortletUtil.onDestroy(this, refreshTimer);
super.onDestroy(); }
+ public boolean isRefreshing() { + return false; + } + } 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 f14d791..556ee6f 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 @@ -37,11 +37,11 @@ import org.rhq.core.domain.configuration.PropertySimple; import org.rhq.core.domain.dashboard.DashboardPortlet; import org.rhq.enterprise.gui.coregui.client.UserSessionManager; import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortlet; +import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortletUtil; 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.resource.ResourceSearchView; -import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility;
/** * @author Greg Hinkle @@ -127,36 +127,19 @@ public class FavoriteResourcesPortlet extends ResourceSearchView implements Auto } }
- @Override public void startRefreshCycle() { - //current setting - final int refreshInterval = UserSessionManager.getUserPreferences().getPageRefreshInterval(); - - //cancel any existing timer - if (refreshTimer != null) { - refreshTimer.cancel(); - } - - if (refreshInterval >= MeasurementUtility.MINUTES) { - - refreshTimer = new Timer() { - public void run() { - - redraw(); - } - }; - - refreshTimer.scheduleRepeating(refreshInterval); - } + refreshTimer = AutoRefreshPortletUtil.startRefreshCycle(this, this, refreshTimer); }
@Override protected void onDestroy() { - if (refreshTimer != null) { - - refreshTimer.cancel(); - } + AutoRefreshPortletUtil.onDestroy(this, refreshTimer);
super.onDestroy(); } + + public boolean isRefreshing() { + return false; + } + } 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 665898e..fed9070 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 @@ -46,11 +46,10 @@ import org.rhq.core.domain.dashboard.DashboardPortlet; import org.rhq.core.domain.resource.ResourceType; import org.rhq.enterprise.gui.coregui.client.CoreGUI; import org.rhq.enterprise.gui.coregui.client.LinkManager; -import org.rhq.enterprise.gui.coregui.client.Messages; -import org.rhq.enterprise.gui.coregui.client.UserSessionManager; import org.rhq.enterprise.gui.coregui.client.alert.AlertHistoryView; import org.rhq.enterprise.gui.coregui.client.alert.AlertPortletDataSource; import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortlet; +import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortletUtil; 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; @@ -566,39 +565,21 @@ public class RecentAlertsPortlet extends AlertHistoryView implements CustomSetti } }
- @Override public void startRefreshCycle() { - //current setting - final int refreshInterval = UserSessionManager.getUserPreferences().getPageRefreshInterval(); - - //cancel any existing timer - if (refreshTimer != null) { - refreshTimer.cancel(); - } - - if (refreshInterval >= MeasurementUtility.MINUTES) { - - refreshTimer = new Timer() { - public void run() { - - redraw(); - } - }; - - refreshTimer.scheduleRepeating(refreshInterval); - } + refreshTimer = AutoRefreshPortletUtil.startRefreshCycle(this, this, refreshTimer); }
@Override protected void onDestroy() { - if (refreshTimer != null) { - - refreshTimer.cancel(); - } + AutoRefreshPortletUtil.onDestroy(this, refreshTimer);
super.onDestroy(); }
+ public boolean isRefreshing() { + return false; + } + @Override protected void setupTableInteractions(boolean hasWriteAccess) { // The portlet is a "subsystem" view. Meaning the alerts displayed can be from any accessible group for @@ -655,7 +636,6 @@ class AlertResourceSelectorRegion extends LocatableVLayout { this.currentlyAssignedIds = assigned; }
- private static final Messages MSG = CoreGUI.getMessages(); private PortletAlertSelector selector = null;
private Integer[] currentlyAssignedIds; diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedResourcesPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedResourcesPortlet.java index e63c0c7..e570a04 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedResourcesPortlet.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedResourcesPortlet.java @@ -37,14 +37,13 @@ import com.smartgwt.client.widgets.tree.TreeGrid;
import org.rhq.core.domain.configuration.PropertySimple; import org.rhq.core.domain.dashboard.DashboardPortlet; -import org.rhq.enterprise.gui.coregui.client.UserSessionManager; import org.rhq.enterprise.gui.coregui.client.components.HeaderLabel; import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortlet; +import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortletUtil; 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.LocatableVLayout;
public class RecentlyAddedResourcesPortlet extends LocatableVLayout implements CustomSettingsPortlet, @@ -252,36 +251,18 @@ public class RecentlyAddedResourcesPortlet extends LocatableVLayout implements C return dataSource; }
- @Override public void startRefreshCycle() { - //current setting - final int refreshInterval = UserSessionManager.getUserPreferences().getPageRefreshInterval(); - - //cancel any existing timer - if (refreshTimer != null) { - refreshTimer.cancel(); - } - - if (refreshInterval >= MeasurementUtility.MINUTES) { - - refreshTimer = new Timer() { - public void run() { - - redraw(); - } - }; - - refreshTimer.scheduleRepeating(refreshInterval); - } + refreshTimer = AutoRefreshPortletUtil.startRefreshCycle(this, this, refreshTimer); }
@Override protected void onDestroy() { - if (refreshTimer != null) { - - refreshTimer.cancel(); - } + AutoRefreshPortletUtil.onDestroy(this, refreshTimer);
super.onDestroy(); } + + public boolean isRefreshing() { + return false; + } } 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 69a36a0..c839109 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 @@ -43,8 +43,8 @@ import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple; import org.rhq.core.domain.configuration.definition.PropertySimpleType; import org.rhq.core.domain.dashboard.DashboardPortlet; import org.rhq.enterprise.gui.coregui.client.LinkManager; -import org.rhq.enterprise.gui.coregui.client.UserSessionManager; import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortlet; +import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortletUtil; 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; @@ -52,7 +52,6 @@ import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow; import org.rhq.enterprise.gui.coregui.client.inventory.resource.AncestryUtil; 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.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; @@ -513,36 +512,18 @@ public class OperationsPortlet extends LocatableVLayout implements CustomSetting return this.scheduledOperationsGrid; }
- @Override public void startRefreshCycle() { - //current setting - final int refreshInterval = UserSessionManager.getUserPreferences().getPageRefreshInterval(); - - //cancel any existing timer - if (refreshTimer != null) { - refreshTimer.cancel(); - } - - if (refreshInterval >= MeasurementUtility.MINUTES) { - - refreshTimer = new Timer() { - public void run() { - - redraw(); - } - }; - - refreshTimer.scheduleRepeating(refreshInterval); - } + refreshTimer = AutoRefreshPortletUtil.startRefreshCycle(this, this, refreshTimer); }
@Override protected void onDestroy() { - if (refreshTimer != null) { - - refreshTimer.cancel(); - } + AutoRefreshPortletUtil.onDestroy(this, refreshTimer);
super.onDestroy(); } + + public boolean isRefreshing() { + return false; + } } 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 bd28719..8fcaba0 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 @@ -49,10 +49,10 @@ import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple; import org.rhq.core.domain.configuration.definition.PropertySimpleType; import org.rhq.core.domain.dashboard.DashboardPortlet; import org.rhq.enterprise.gui.coregui.client.LinkManager; -import org.rhq.enterprise.gui.coregui.client.UserSessionManager; import org.rhq.enterprise.gui.coregui.client.components.table.Table; import org.rhq.enterprise.gui.coregui.client.components.table.TableWidget; import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortlet; +import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortletUtil; 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; @@ -340,39 +340,21 @@ public class ProblemResourcesPortlet extends Table<ProblemResourcesDataSource> i return timeRange; }
- @Override public void startRefreshCycle() { - //current setting - final int refreshInterval = UserSessionManager.getUserPreferences().getPageRefreshInterval(); - - //cancel any existing timer - if (refreshTimer != null) { - refreshTimer.cancel(); - } - - if (refreshInterval >= MeasurementUtility.MINUTES) { - - refreshTimer = new Timer() { - public void run() { - - redraw(); - } - }; - - refreshTimer.scheduleRepeating(refreshInterval); - } + refreshTimer = AutoRefreshPortletUtil.startRefreshCycle(this, this, refreshTimer); }
@Override protected void onDestroy() { - if (refreshTimer != null) { - - refreshTimer.cancel(); - } + AutoRefreshPortletUtil.onDestroy(this, refreshTimer);
super.onDestroy(); }
+ public boolean isRefreshing() { + return false; + } + }
/**Construct table widget Label to display timerange settings used with latest datasource query. diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/summary/InventorySummaryPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/summary/InventorySummaryPortlet.java index 70fbc3e..3466bb6 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/summary/InventorySummaryPortlet.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/summary/InventorySummaryPortlet.java @@ -38,14 +38,13 @@ import com.smartgwt.client.widgets.form.fields.events.ClickHandler; import org.rhq.core.domain.dashboard.DashboardPortlet; import org.rhq.core.domain.resource.InventorySummary; import org.rhq.enterprise.gui.coregui.client.CoreGUI; -import org.rhq.enterprise.gui.coregui.client.UserSessionManager; import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortlet; +import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortletUtil; 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.gwt.GWTServiceLookup; import org.rhq.enterprise.gui.coregui.client.gwt.ResourceBossGWTServiceAsync; -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.LocatableVLayout;
@@ -172,37 +171,18 @@ public class InventorySummaryPortlet extends LocatableVLayout implements AutoRef } }
- @Override public void startRefreshCycle() { - //current setting - final int refreshInterval = UserSessionManager.getUserPreferences().getPageRefreshInterval(); - - //cancel any existing timer - if (refreshTimer != null) { - refreshTimer.cancel(); - } - - if (refreshInterval >= MeasurementUtility.MINUTES) { - - refreshTimer = new Timer() { - public void run() { - - redraw(); - } - }; - - refreshTimer.scheduleRepeating(refreshInterval); - } + refreshTimer = AutoRefreshPortletUtil.startRefreshCycle(this, this, refreshTimer); }
@Override protected void onDestroy() { - if (refreshTimer != null) { - - refreshTimer.cancel(); - } + AutoRefreshPortletUtil.onDestroy(this, refreshTimer);
super.onDestroy(); }
+ public boolean isRefreshing() { + return false; + } }
commit 3cd15d95af19b8d07e537898f0fe6acb80478ae9 Author: John Mazzitelli mazz@redhat.com Date: Wed Mar 23 10:06:21 2011 -0400
BZ 690110 - group tree context menu resource config link is fixed
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 index 43b3700..38edb6e 100644 --- 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 @@ -164,8 +164,8 @@ public class ResourceGroupContextMenu extends LocatableMenu { } else if (isAutoCluster) { CoreGUI.goToView(LinkManager.getAutoClusterTabLink(group.getId(), "Configuration", "Current")); } else { - CoreGUI.goToView(LinkManager.getResourceGroupTabLink(group.getId(), "Inventory", - "ConnectionSettings")); + CoreGUI + .goToView(LinkManager.getResourceGroupTabLink(group.getId(), "Configuration", "Current")); } } });
commit 58043cdc58274c84f0b515e568afd5a2ff0550b2 Author: Heiko W. Rupp hwr@redhat.com Date: Wed Mar 23 11:18:48 2011 +0100
Allow setting a resource-config
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java index b6a1d30..4e4e103 100644 --- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java +++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java @@ -36,6 +36,7 @@ import java.util.Set; import java.util.Stack;
import org.rhq.core.clientapi.agent.PluginContainerException; +import org.rhq.core.clientapi.agent.configuration.ConfigurationUpdateRequest; import org.rhq.core.domain.configuration.Configuration; import org.rhq.core.domain.configuration.PropertySimple; import org.rhq.core.domain.configuration.definition.ConfigurationDefinition; @@ -50,6 +51,7 @@ import org.rhq.core.domain.measurement.MeasurementDefinition; import org.rhq.core.domain.operation.OperationDefinition; import org.rhq.core.domain.resource.Resource; import org.rhq.core.domain.resource.ResourceType; +import org.rhq.core.pc.configuration.ConfigurationManager; import org.rhq.core.pc.inventory.InventoryManager; import org.rhq.core.pc.inventory.ResourceContainer; import org.rhq.core.pc.measurement.MeasurementManager; @@ -366,6 +368,9 @@ public class StandaloneContainer { case R_CONFIG: showResourceConfig(); break; + case SR_CONFIG: + setResourceConfig(tokens); + break; }
return false; @@ -426,6 +431,33 @@ public class StandaloneContainer {
}
+ private void setResourceConfig(String[] tokens) { + if (resourceId == 0) { + System.err.println("No resource set"); + return; + } + + + Configuration config = null; + if (tokens.length > 1) + config = createConfigurationFromString(tokens[1]); + else { + System.err.println("Need at least 1 token"); + return; + } + + ConfigurationUpdateRequest request = new ConfigurationUpdateRequest(1,config,resourceId); + + ConfigurationManager cm = pc.getConfigurationManager(); + + cm.updateResourceConfiguration(request); + + + + } + + + private ResourceType getTypeForResourceId() { ResourceContainer rc = inventoryManager.getResourceContainer(resourceId); Resource res = rc.getResource(); @@ -789,7 +821,9 @@ public class StandaloneContainer { STDIN("stdin","",0, "Stop reading the batch file and wait for commands on stdin"), // WAIT("w", "milliseconds", 1, "Waits the given amount of time"), P_CONFIG("pc", "", 0, "Shows the plugin configuration of the current resource."), - R_CONFIG("rc", "", 0, "Shows the resource configuration of the current resource."); + R_CONFIG("rc", "", 0, "Shows the resource configuration of the current resource."), + SR_CONFIG("src", "", 0, "[parameters] set resource config ") + ;
private String abbrev; private String args;
commit 8fe2c0741089d3fa2e67b4a0cf2b85d6dd8edf7d Author: John Mazzitelli mazz@redhat.com Date: Tue Mar 22 17:07:29 2011 -0400
BZ 689922 add a sort override since our ancestry fields are named "resourceAncestry" but the true field is "ancestry".
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 5ecec8c..70bb96c 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 @@ -100,6 +100,7 @@ public class ResourceCriteria extends TaggedCriteria { private PageOrdering sortParentResourceName; // needs overrides private PageOrdering sortAgentName; // needs overrides private PageOrdering sortCurrentAvailability; // needs overrides + private PageOrdering sortResourceAncestry; // needs overrides
public ResourceCriteria() { filterOverrides.put("resourceTypeId", "resourceType.id = ?"); @@ -133,6 +134,7 @@ public class ResourceCriteria extends TaggedCriteria { sortOverrides.put("parentResourceName", "parentResource.name"); sortOverrides.put("agentName", "agent.name"); sortOverrides.put("currentAvailability", "currentAvailability.availabilityType"); + sortOverrides.put("resourceAncestry", "ancestry"); }
@Override @@ -373,6 +375,11 @@ public class ResourceCriteria extends TaggedCriteria { this.sortCurrentAvailability = sortCurrentAvailability; }
+ public void addSortResourceAncestry(PageOrdering sortAncestry) { + addSortField("resourceAncestry"); + this.sortResourceAncestry = sortAncestry; + } + /** subclasses should override as necessary */ public boolean isInventoryManagerRequired() { return (this.fetchChildResources || this.fetchParentResource);
commit 6d3b3cc1d6b25ca7ba94a7689279fb31c3b6cee0 Author: John Mazzitelli mazz@redhat.com Date: Tue Mar 22 16:47:44 2011 -0400
create utility methods that create ancestry listgridfields in a single place AncestryUtil
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 5ca88d6..f776d56 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 @@ -181,19 +181,7 @@ public class AlertDataSource extends RPCDataSource<Alert, AlertCriteria> { }); fields.add(resourceNameField);
- ListGridField ancestryField = new ListGridField(AncestryUtil.RESOURCE_ANCESTRY, MSG.common_title_ancestry()); - ancestryField.setCellFormatter(new CellFormatter() { - public String format(Object o, ListGridRecord listGridRecord, int rowNum, int colNum) { - return listGridRecord.getAttributeAsString(AncestryUtil.RESOURCE_ANCESTRY_VALUE); - } - }); - ancestryField.setShowHover(true); - ancestryField.setHoverCustomizer(new HoverCustomizer() { - - public String hoverHTML(Object value, ListGridRecord listGridRecord, int rowNum, int colNum) { - return AncestryUtil.getAncestryHoverHTML(listGridRecord, 0); - } - }); + ListGridField ancestryField = AncestryUtil.setupAncestryListGridField(); fields.add(ancestryField);
ctimeField.setWidth(125); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/lookup/ResourceLookupComboBoxItem.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/lookup/ResourceLookupComboBoxItem.java index 2d3692c..a96f42a 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/lookup/ResourceLookupComboBoxItem.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/lookup/ResourceLookupComboBoxItem.java @@ -59,17 +59,13 @@ public class ResourceLookupComboBoxItem extends ComboBoxItem {
ListGridField ancestryField = new ListGridField(AncestryUtil.RESOURCE_ANCESTRY, MSG.common_title_ancestry(), 300); + // needs to use a different cell formatter than what AncestryUtil.setupAncestryListGridField creates ancestryField.setCellFormatter(new CellFormatter() { public String format(Object o, ListGridRecord listGridRecord, int rowNum, int colNum) { return AncestryUtil.getAncestryValue(listGridRecord, false); } }); - ancestryField.setShowHover(true); - ancestryField.setHoverCustomizer(new HoverCustomizer() { - public String hoverHTML(Object value, ListGridRecord listGridRecord, int rowNum, int colNum) { - return AncestryUtil.getAncestryHoverHTML(listGridRecord, 0); - } - }); + AncestryUtil.setupAncestryListGridFieldHover(ancestryField);
ListGridField descriptionField = new ListGridField("description", MSG.common_title_description()); ListGridField categoryField = new ListGridField("category", MSG.common_title_category(), 60); 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 f7e3ee4..69a36a0 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 @@ -180,18 +180,7 @@ public class OperationsPortlet extends LocatableVLayout implements CustomSetting } });
- ListGridField ancestryRecent = new ListGridField(AncestryUtil.RESOURCE_ANCESTRY, MSG.common_title_ancestry()); - ancestryRecent.setCellFormatter(new CellFormatter() { - public String format(Object o, ListGridRecord listGridRecord, int rowNum, int colNum) { - return listGridRecord.getAttributeAsString(AncestryUtil.RESOURCE_ANCESTRY_VALUE); - } - }); - ancestryRecent.setShowHover(true); - ancestryRecent.setHoverCustomizer(new HoverCustomizer() { - public String hoverHTML(Object value, ListGridRecord listGridRecord, int rowNum, int colNum) { - return AncestryUtil.getAncestryHoverHTML(listGridRecord, 0); - } - }); + ListGridField ancestryRecent = AncestryUtil.setupAncestryListGridField();
ListGridField operationRecent = new ListGridField(RecentOperationsDataSource.Field.OPERATION.propertyName(), RecentOperationsDataSource.Field.OPERATION.title()); @@ -220,18 +209,7 @@ public class OperationsPortlet extends LocatableVLayout implements CustomSetting } });
- ListGridField ancestryNext = new ListGridField(AncestryUtil.RESOURCE_ANCESTRY, MSG.common_title_ancestry()); - ancestryNext.setCellFormatter(new CellFormatter() { - public String format(Object o, ListGridRecord listGridRecord, int rowNum, int colNum) { - return listGridRecord.getAttributeAsString(AncestryUtil.RESOURCE_ANCESTRY_VALUE); - } - }); - ancestryNext.setShowHover(true); - ancestryNext.setHoverCustomizer(new HoverCustomizer() { - public String hoverHTML(Object value, ListGridRecord listGridRecord, int rowNum, int colNum) { - return AncestryUtil.getAncestryHoverHTML(listGridRecord, 0); - } - }); + ListGridField ancestryNext = AncestryUtil.setupAncestryListGridField();
ListGridField operationNext = new ListGridField(ScheduledOperationsDataSource.Field.OPERATION.propertyName(), ScheduledOperationsDataSource.Field.OPERATION.title()); 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 24820ec..bd28719 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 @@ -135,19 +135,7 @@ public class ProblemResourcesPortlet extends Table<ProblemResourcesDataSource> i } });
- ListGridField ancestryField = new ListGridField(AncestryUtil.RESOURCE_ANCESTRY, MSG.common_title_ancestry()); - ancestryField.setCellFormatter(new CellFormatter() { - public String format(Object o, ListGridRecord listGridRecord, int rowNum, int colNum) { - return listGridRecord.getAttributeAsString(AncestryUtil.RESOURCE_ANCESTRY_VALUE); - } - }); - ancestryField.setShowHover(true); - ancestryField.setHoverCustomizer(new HoverCustomizer() { - - public String hoverHTML(Object value, ListGridRecord listGridRecord, int rowNum, int colNum) { - return AncestryUtil.getAncestryHoverHTML(listGridRecord, 0); - } - }); + ListGridField ancestryField = AncestryUtil.setupAncestryListGridField();
ListGridField alertsField = new ListGridField(ALERTS.propertyName(), ALERTS.title(), 70);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/AbstractOperationHistoryListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/AbstractOperationHistoryListView.java index 6553b56..e058004 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/AbstractOperationHistoryListView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/AbstractOperationHistoryListView.java @@ -260,22 +260,7 @@ public abstract class AbstractOperationHistoryListView<T extends AbstractOperati }
protected ListGridField createAncestryField() { - ListGridField ancestryField = new ListGridField(AncestryUtil.RESOURCE_ANCESTRY, MSG.common_title_ancestry()); - ancestryField.setAlign(Alignment.LEFT); - ancestryField.setCellAlign(Alignment.LEFT); - ancestryField.setCellFormatter(new CellFormatter() { - public String format(Object o, ListGridRecord listGridRecord, int rowNum, int colNum) { - return listGridRecord.getAttributeAsString(AncestryUtil.RESOURCE_ANCESTRY_VALUE); - } - }); - ancestryField.setShowHover(true); - ancestryField.setHoverCustomizer(new HoverCustomizer() { - - public String hoverHTML(Object value, ListGridRecord listGridRecord, int rowNum, int colNum) { - return AncestryUtil.getAncestryHoverHTML(listGridRecord, 0); - } - }); - + ListGridField ancestryField = AncestryUtil.setupAncestryListGridField(); return ancestryField; }
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/configuration/HistoryGroupResourceConfigurationMembers.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/configuration/HistoryGroupResourceConfigurationMembers.java index 9071b94..ae28218 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/configuration/HistoryGroupResourceConfigurationMembers.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/configuration/HistoryGroupResourceConfigurationMembers.java @@ -118,20 +118,7 @@ public class HistoryGroupResourceConfigurationMembers extends LocatableVLayout { } });
- ListGridField fieldAncestry = new ListGridField(AncestryUtil.RESOURCE_ANCESTRY, MSG.common_title_ancestry()); - fieldAncestry.setCellFormatter(new CellFormatter() { - public String format(Object o, ListGridRecord listGridRecord, int rowNum, int colNum) { - return listGridRecord.getAttributeAsString(AncestryUtil.RESOURCE_ANCESTRY_VALUE); - } - }); - fieldAncestry.setShowHover(true); - fieldAncestry.setHoverCustomizer(new HoverCustomizer() { - - public String hoverHTML(Object value, ListGridRecord listGridRecord, int rowNum, int colNum) { - return AncestryUtil.getAncestryHoverHTML(listGridRecord, 0); - } - }); - + ListGridField fieldAncestry = AncestryUtil.setupAncestryListGridField(); ListGridField fieldDateCreated = new ListGridField(DataSource.Field.DATECREATED, MSG .common_title_dateCreated()); ListGridField fieldLastUpdated = new ListGridField(DataSource.Field.LASTUPDATED, MSG diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/HistoryGroupPluginConfigurationMembers.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/HistoryGroupPluginConfigurationMembers.java index ec590c0..b2f923c 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/HistoryGroupPluginConfigurationMembers.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/HistoryGroupPluginConfigurationMembers.java @@ -117,20 +117,7 @@ public class HistoryGroupPluginConfigurationMembers extends LocatableVLayout { } });
- ListGridField fieldAncestry = new ListGridField(AncestryUtil.RESOURCE_ANCESTRY, MSG.common_title_ancestry()); - fieldAncestry.setCellFormatter(new CellFormatter() { - public String format(Object o, ListGridRecord listGridRecord, int rowNum, int colNum) { - return listGridRecord.getAttributeAsString(AncestryUtil.RESOURCE_ANCESTRY_VALUE); - } - }); - fieldAncestry.setShowHover(true); - fieldAncestry.setHoverCustomizer(new HoverCustomizer() { - - public String hoverHTML(Object value, ListGridRecord listGridRecord, int rowNum, int colNum) { - return AncestryUtil.getAncestryHoverHTML(listGridRecord, 0); - } - }); - + ListGridField fieldAncestry = AncestryUtil.setupAncestryListGridField(); ListGridField fieldDateCreated = new ListGridField(DataSource.Field.DATECREATED, MSG .common_title_dateCreated()); ListGridField fieldLastUpdated = new ListGridField(DataSource.Field.LASTUPDATED, MSG diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsDetailView.java index b374561..e93a1cb 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsDetailView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsDetailView.java @@ -62,19 +62,7 @@ public class TraitsDetailView extends AbstractMeasurementDataTraitListDetailView }); resourceNameField.setCanGroupBy(true);
- ListGridField ancestryField = listGrid.getField(AncestryUtil.RESOURCE_ANCESTRY); - ancestryField.setCellFormatter(new CellFormatter() { - public String format(Object o, ListGridRecord listGridRecord, int rowNum, int colNum) { - return listGridRecord.getAttributeAsString(AncestryUtil.RESOURCE_ANCESTRY_VALUE); - } - }); - ancestryField.setShowHover(true); - ancestryField.setHoverCustomizer(new HoverCustomizer() { - - public String hoverHTML(Object value, ListGridRecord listGridRecord, int rowNum, int colNum) { - return AncestryUtil.getAncestryHoverHTML(listGridRecord, 0); - } - }); + AncestryUtil.setupAncestryListGridField(listGrid); }
private static Criteria createCriteria(int groupId, int definitionId) { diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsView.java index dfd3b38..f1c7cfa 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsView.java @@ -69,20 +69,7 @@ public class TraitsView extends AbstractMeasurementDataTraitListView { }); resourceNameField.setCanGroupBy(true);
- ListGridField ancestryField = listGrid.getField(AncestryUtil.RESOURCE_ANCESTRY); - ancestryField.setCellFormatter(new CellFormatter() { - public String format(Object o, ListGridRecord listGridRecord, int rowNum, int colNum) { - return listGridRecord.getAttributeAsString(AncestryUtil.RESOURCE_ANCESTRY_VALUE); - } - }); - ancestryField.setShowHover(true); - ancestryField.setHoverCustomizer(new HoverCustomizer() { - - public String hoverHTML(Object value, ListGridRecord listGridRecord, int rowNum, int colNum) { - return AncestryUtil.getAncestryHoverHTML(listGridRecord, 0); - } - }); - + AncestryUtil.setupAncestryListGridField(listGrid); super.configureTable(); }
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupMemberResourceOperationHistoryListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupMemberResourceOperationHistoryListView.java index da178c4..b4e1257 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupMemberResourceOperationHistoryListView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupMemberResourceOperationHistoryListView.java @@ -59,20 +59,8 @@ public class GroupMemberResourceOperationHistoryListView extends }); fields.add(resourceField);
- ListGridField ancestryField = new ListGridField(AncestryUtil.RESOURCE_ANCESTRY, MSG.common_title_ancestry()); + ListGridField ancestryField = AncestryUtil.setupAncestryListGridField(); ancestryField.setWidth("35%"); - ancestryField.setCellFormatter(new CellFormatter() { - public String format(Object o, ListGridRecord listGridRecord, int rowNum, int colNum) { - return listGridRecord.getAttributeAsString(AncestryUtil.RESOURCE_ANCESTRY_VALUE); - } - }); - ancestryField.setShowHover(true); - ancestryField.setHoverCustomizer(new HoverCustomizer() { - - public String hoverHTML(Object value, ListGridRecord listGridRecord, int rowNum, int colNum) { - return AncestryUtil.getAncestryHoverHTML(listGridRecord, 0); - } - }); fields.add(ancestryField);
ListGridField statusField = createStatusField(); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/AncestryUtil.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/AncestryUtil.java index 8a2cbe2..20d9937 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/AncestryUtil.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/AncestryUtil.java @@ -23,6 +23,11 @@ import java.util.HashSet; import java.util.Map;
import com.smartgwt.client.data.Record; +import com.smartgwt.client.types.Alignment; +import com.smartgwt.client.widgets.grid.CellFormatter; +import com.smartgwt.client.widgets.grid.HoverCustomizer; +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.resource.Resource; @@ -51,6 +56,52 @@ public abstract class AncestryUtil { private static final String TITLE_PLATFORM = CoreGUI.getMessages().common_title_platform() + ": ";
/** + * Convienence method that creates a standard ancestry ListGridField. + * @return ancestry field + */ + public static ListGridField setupAncestryListGridField() { + ListGridField ancestryField; + ancestryField = new ListGridField(AncestryUtil.RESOURCE_ANCESTRY, CoreGUI.getMessages().common_title_ancestry()); + ancestryField.setAlign(Alignment.LEFT); + ancestryField.setCellAlign(Alignment.LEFT); + setupAncestryListGridFieldCellFormatter(ancestryField); + setupAncestryListGridFieldHover(ancestryField); + return ancestryField; + } + + /** + * Convienence method that creates a standard ancestry ListGridField where the field already exists + * in the given list grid. + * + * @return ancestry field + */ + public static ListGridField setupAncestryListGridField(ListGrid listGrid) { + ListGridField ancestryField = listGrid.getField(AncestryUtil.RESOURCE_ANCESTRY); + ancestryField.setAlign(Alignment.LEFT); + ancestryField.setCellAlign(Alignment.LEFT); + setupAncestryListGridFieldCellFormatter(ancestryField); + setupAncestryListGridFieldHover(ancestryField); + return ancestryField; + } + + public static void setupAncestryListGridFieldHover(ListGridField ancestryField) { + ancestryField.setShowHover(true); + ancestryField.setHoverCustomizer(new HoverCustomizer() { + public String hoverHTML(Object value, ListGridRecord listGridRecord, int rowNum, int colNum) { + return AncestryUtil.getAncestryHoverHTML(listGridRecord, 0); + } + }); + } + + public static void setupAncestryListGridFieldCellFormatter(ListGridField ancestryField) { + ancestryField.setCellFormatter(new CellFormatter() { + public String format(Object o, ListGridRecord listGridRecord, int rowNum, int colNum) { + return listGridRecord.getAttributeAsString(AncestryUtil.RESOURCE_ANCESTRY_VALUE); + } + }); + } + + /** * Get the complete set of resource types in the ancestries provided. This is useful for * being able to load all the types in advance of generating decoded values. * 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 7d46996..6559a31 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 @@ -159,18 +159,7 @@ public class ResourceSearchView extends Table { } });
- ListGridField ancestryField = new ListGridField(AncestryUtil.RESOURCE_ANCESTRY, MSG.common_title_ancestry()); - ancestryField.setCellFormatter(new CellFormatter() { - public String format(Object o, ListGridRecord listGridRecord, int rowNum, int colNum) { - return listGridRecord.getAttributeAsString(AncestryUtil.RESOURCE_ANCESTRY_VALUE); - } - }); - ancestryField.setShowHover(true); - ancestryField.setHoverCustomizer(new HoverCustomizer() { - public String hoverHTML(Object value, ListGridRecord listGridRecord, int rowNum, int colNum) { - return AncestryUtil.getAncestryHoverHTML(listGridRecord, 0); - } - }); + ListGridField ancestryField = AncestryUtil.setupAncestryListGridField();
ListGridField descriptionField = new ListGridField(DESCRIPTION.propertyName(), DESCRIPTION.title());
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/AbstractConfigurationHistoryDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/AbstractConfigurationHistoryDataSource.java index bd8c430..3d41d42 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/AbstractConfigurationHistoryDataSource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/AbstractConfigurationHistoryDataSource.java @@ -229,19 +229,7 @@ public abstract class AbstractConfigurationHistoryDataSource<T extends AbstractR }); fields.add(resourceNameField);
- ListGridField ancestryField = new ListGridField(AncestryUtil.RESOURCE_ANCESTRY, MSG.common_title_ancestry()); - ancestryField.setCellFormatter(new CellFormatter() { - public String format(Object o, ListGridRecord listGridRecord, int rowNum, int colNum) { - return listGridRecord.getAttributeAsString(AncestryUtil.RESOURCE_ANCESTRY_VALUE); - } - }); - ancestryField.setShowHover(true); - ancestryField.setHoverCustomizer(new HoverCustomizer() { - - public String hoverHTML(Object value, ListGridRecord listGridRecord, int rowNum, int colNum) { - return AncestryUtil.getAncestryHoverHTML(listGridRecord, 0); - } - }); + ListGridField ancestryField = AncestryUtil.setupAncestryListGridField(); fields.add(ancestryField);
idField.setWidth("10%"); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/AlertDefinitionReportView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/AlertDefinitionReportView.java index 18f59cf..d481d86 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/AlertDefinitionReportView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/AlertDefinitionReportView.java @@ -196,19 +196,7 @@ public class AlertDefinitionReportView extends Table<AlertDefinitionReportView.D }); fields.add(resourceField);
- ListGridField ancestryField = new ListGridField(AncestryUtil.RESOURCE_ANCESTRY, MSG.common_title_ancestry()); - ancestryField.setCellFormatter(new CellFormatter() { - public String format(Object o, ListGridRecord listGridRecord, int rowNum, int colNum) { - return listGridRecord.getAttributeAsString(AncestryUtil.RESOURCE_ANCESTRY_VALUE); - } - }); - ancestryField.setShowHover(true); - ancestryField.setHoverCustomizer(new HoverCustomizer() { - - public String hoverHTML(Object value, ListGridRecord listGridRecord, int rowNum, int colNum) { - return AncestryUtil.getAncestryHoverHTML(listGridRecord, 0); - } - }); + ListGridField ancestryField = AncestryUtil.setupAncestryListGridField(); fields.add(ancestryField);
return fields;
rhq-commits@lists.fedorahosted.org