modules/core/domain/pom.xml | 1 modules/core/domain/src/main/java/org/rhq/core/server/MeasurementConverter.java | 359 ++++++++++ modules/enterprise/gui/coregui/pom.xml | 12 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/CoreGUI.gwt.xml | 3 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/BreadCrumb.java | 3 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java | 36 - modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersDataSource.java | 10 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/SubTabLayout.java | 3 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java | 10 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/gwt/GWTServiceLookup.java | 4 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/MeasurementDataGWTService.java | 48 + 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/gwt/SubjectGWTService.java | 24 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java | 2 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java | 97 ++ modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceSummaryView.java | 155 ++++ modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java | 3 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java | 220 +++--- modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/GraphListView.java | 130 +++ modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/SmallGraphView.java | 230 ++++++ modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/type/ResourceTypeRepository.java | 71 + modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/MeasurementDataGWTServiceImpl.java | 61 + modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java | 6 modules/enterprise/gui/coregui/src/main/webapp/CoreGUI.css | 66 + modules/enterprise/gui/coregui/src/main/webapp/CoreGUI.html | 6 modules/enterprise/gui/coregui/src/main/webapp/WEB-INF/web.xml | 14 modules/enterprise/gui/coregui/src/main/webapp/images/rhq_logo_animated_100px.gif |binary modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/util/MonitorUtils.java | 2 modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/monitor/availabilityHistory.xhtml | 14 modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/monitor/schedules.xhtml | 14 modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/monitor/traits.xhtml | 14 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java | 19 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerLocal.java | 10 34 files changed, 1400 insertions(+), 264 deletions(-)
New commits: commit a704842eedf0470e07ece509a8c87373147ff646 Author: Greg Hinkle ghinkle@redhat.com Date: Wed Feb 24 10:18:22 2010 -0500
More measurementConverter refactory for portal-war additional features
diff --git a/modules/core/domain/pom.xml b/modules/core/domain/pom.xml index ef75cd2..0564164 100644 --- a/modules/core/domain/pom.xml +++ b/modules/core/domain/pom.xml @@ -206,7 +206,6 @@ <groupId>com.google.gwt</groupId> <artifactId>gwt-user</artifactId> <version>2.0.0</version> - <scope>provided</scope> </dependency>
<dependency> diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/server/MeasurementConverter.java b/modules/core/domain/src/main/java/org/rhq/core/domain/server/MeasurementConverter.java deleted file mode 100644 index 0471823..0000000 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/server/MeasurementConverter.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2010 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package org.rhq.core.domain.server; - -/** - * @author Greg Hinkle - */ -public class MeasurementConverter { - -} diff --git a/modules/enterprise/gui/coregui/pom.xml b/modules/enterprise/gui/coregui/pom.xml index 0574f6e..0e72200 100644 --- a/modules/enterprise/gui/coregui/pom.xml +++ b/modules/enterprise/gui/coregui/pom.xml @@ -70,6 +70,14 @@ </dependency>
+ <!-- The graphing library --> + <dependency> + <groupId>ca.nanometrics</groupId> + <artifactId>gflot</artifactId> + <version>1.0.0</version> + </dependency> + + <!-- Internal Deps -->
<dependency> @@ -374,6 +382,10 @@ </snapshots> </repository>
+ <repository> + <id>gflot-repository</id> + <url>http://codemonkey.dumontierlab.com/maven/repo/</url> + </repository> </repositories>
</project> diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/CoreGUI.gwt.xml b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/CoreGUI.gwt.xml index bf5e646..0dcfef8 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/CoreGUI.gwt.xml +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/CoreGUI.gwt.xml @@ -8,6 +8,8 @@
<inherits name='com.smartgwt.SmartGwt' /> <inherits name="com.smartgwt.tools.SmartGwtTools"/> + + <inherits name='ca.nanometrics.gflot.GFlot'/> <!-- <inherits name='com.google.gwt.widgetideas.WidgetIdeas'/> --> @@ -27,5 +29,6 @@ <servlet path="/ResourceGWTService" class="org.rhq.enterprise.gui.coregui.server.gwt.ResourceGWTServiceImpl"/> <servlet path="/ConfigurationGwtService" class="org.rhq.enterprise.gui.coregui.server.gwt.ConfigurationGWTServiceImpl"/> <servlet path="/ResourceTypeGWTService" class="org.rhq.enterprise.gui.coregui.server.gwt.ResourceTypeGWTServiceImpl"/> + <servlet path="/MeasurementDataGWTService" class="org.rhq.enterprise.gui.coregui.server.gwt.MeasurementDataGWTServiceImpl"/>
</module> \ No newline at end of file diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/BreadCrumb.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/BreadCrumb.java index 65a5285..2f5a744 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/BreadCrumb.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/BreadCrumb.java @@ -21,6 +21,7 @@ package org.rhq.enterprise.gui.coregui.client; import org.rhq.enterprise.gui.coregui.client.places.Place;
import com.google.gwt.user.client.History; +import com.google.gwt.user.client.Window; import com.google.gwt.user.client.ui.Hyperlink; import com.smartgwt.client.types.Overflow; import com.smartgwt.client.widgets.HTMLPane; @@ -107,6 +108,8 @@ public class BreadCrumb extends HTMLPane { setContents(content);
History.newItem(path); + if (!trail.isEmpty()) + Window.setTitle("RHQ: " + trail.get(trail.size()-1));
redraw(); } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java index bb2a598..fad909c 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java @@ -91,7 +91,18 @@ public class CoreGUI implements EntryPoint { public void onSuccess(Subject result) { System.out.println("Logged in: " + result.getSessionId()); setSessionSubject(result); + buildCoreUI(); + + /* We can cache all metadata right here + ResourceTypeRepository.Cache.getInstance().getResourceTypes( + (Integer[]) null, EnumSet.allOf(ResourceTypeRepository.MetadataType.class), new ResourceTypeRepository.TypesLoadedCallback() { + public void onTypesLoaded(HashMap<Integer, ResourceType> types) { + System.out.println("Preloaded [" + types.size() + "] resource types"); + buildCoreUI(); + } + }); + */ } }); } @@ -151,7 +162,6 @@ public class CoreGUI implements EntryPoint { public void onValueChange(ValueChangeEvent<String> historyChangeEvent) { System.out.println("History request: " + historyChangeEvent.getValue());
-
breadCrumb.verify(historyChangeEvent.getValue());
@@ -192,7 +202,7 @@ public class CoreGUI implements EntryPoint { } else if (key.equals("Resources")) { c = new ResourcesView(); } else if (key.equals("Resource")) { - c = new ResourceView(); + c = new ResourceView(); } else if (key.equals("Dashboard")) { c = new DashboardView(); } @@ -200,28 +210,6 @@ public class CoreGUI implements EntryPoint { }
- private void buildCaches() { - - -/* final long start = System.currentTimeMillis(); - ResourceTypeCriteria criteria = new ResourceTypeCriteria(); - criteria.fetchOperationDefinitions(true); - criteria.setPageControl(PageControl.getUnlimitedInstance()); -// criteria.fetchMetricDefinitions(true); - - ResourceTypeGWTService.App.getInstance().findResourceTypesByCriteria(criteria, new AsyncCallback<PageList<ResourceType>>() { - public void onFailure(Throwable caught) { - System.out.println("bad" + caught); - } - - public void onSuccess(PageList<ResourceType> result) { - System.out.println("Resource Types loaded in: " + (System.currentTimeMillis() - start)); - SC.say("Loaded " + result.size() + " resource types in " + (System.currentTimeMillis() - start)); - } - });*/ - } - - // -------------------- Static application utilities ----------------------
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersDataSource.java index 13eae48..e61f103 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersDataSource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersDataSource.java @@ -58,8 +58,6 @@ public class UsersDataSource extends RPCDataSource { protected UsersDataSource() { super("Users");
- - DataSourceField idDataField = new DataSourceIntegerField("id", "ID"); idDataField.setPrimaryKey(true);
@@ -93,11 +91,9 @@ public class UsersDataSource extends RPCDataSource {
public void executeFetch(final String requestId, final DSRequest request, final DSResponse response) { final long start = System.currentTimeMillis(); -
- SubjectCriteria criteria = new SubjectCriteria(); -// criteria.addFilterName(query); + // criteria.addFilterName(query);
if (request.getStartRow() != null && request.getEndRow() != null) { criteria.setPageControl(PageControl.getExplicitPageControl(request.getStartRow(), request.getEndRow() - request.getStartRow())); @@ -105,7 +101,7 @@ public class UsersDataSource extends RPCDataSource { criteria.setPageControl(PageControl.getSingleRowInstance()); }
-// criteria.addSortAgentName(PageOrdering.ASC); + // criteria.addSortAgentName(PageOrdering.ASC);
subjectService.findSubjectsByCriteria(criteria, new AsyncCallback<PageList<Subject>>() { @@ -117,7 +113,6 @@ public class UsersDataSource extends RPCDataSource { }
public void onSuccess(PageList<Subject> result) { - System.out.println("Data retrieved in: " + (System.currentTimeMillis() - start));
ListGridRecord[] records = new ListGridRecord[result.size()]; @@ -139,7 +134,6 @@ public class UsersDataSource extends RPCDataSource { response.setData(records); response.setTotalRows(result.getTotalSize()); // for paging to work we have to specify size of full result set processResponse(requestId, response); - } }); } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/SubTabLayout.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/SubTabLayout.java index 6b3a09a..ea27d0c 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/SubTabLayout.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/SubTabLayout.java @@ -47,10 +47,12 @@ public class SubTabLayout extends VLayout { setHeight100(); setMargin(0); setPadding(0); +
buttonBar = new ToolStrip(); buttonBar.setBackgroundColor("grey"); buttonBar.setWidth100(); + buttonBar.setBorder(null);
for (final String title : subtabs.keySet()) { @@ -66,6 +68,7 @@ public class SubTabLayout extends VLayout { button.setBorder(null);
button.setBaseStyle("SubTabButton"); + // button.setStyleName("SubTabButton"); // button.setStylePrimaryName("SubTabButton");
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 4b87244..ab6862c 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 @@ -37,7 +37,6 @@ import org.rhq.core.domain.configuration.definition.constraint.Constraint; import org.rhq.core.domain.configuration.definition.constraint.IntegerRangeConstraint; import org.rhq.core.domain.configuration.definition.constraint.RegexConstraint; import org.rhq.core.domain.resource.ResourceType; -import org.rhq.enterprise.gui.coregui.client.CoreGUI; import org.rhq.enterprise.gui.coregui.client.gwt.ConfigurationGWTServiceAsync; import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository; @@ -189,7 +188,9 @@ public class ConfigurationEditor extends VLayout { } });
- ResourceTypeRepository.Cache.getInstance().getResourceTypes(new Integer[]{resourceTypeId}, EnumSet.of(ResourceTypeRepository.MetadataType.resourceConfigurationDefinition), new ResourceTypeRepository.TypeLoadedCallback() { + ResourceTypeRepository.Cache.getInstance().getResourceTypes(new Integer[]{resourceTypeId}, + EnumSet.of(ResourceTypeRepository.MetadataType.resourceConfigurationDefinition), + new ResourceTypeRepository.TypesLoadedCallback() { public void onTypesLoaded(HashMap<Integer, ResourceType> types) { System.out.println("ConfigDef retreived in: " + (System.currentTimeMillis() - start)); definition = types.get(resourceTypeId).getResourceConfigurationDefinition(); @@ -212,10 +213,13 @@ public class ConfigurationEditor extends VLayout { } });
- ResourceTypeRepository.Cache.getInstance().getResourceTypes(new Integer[]{resourceTypeId}, EnumSet.of(ResourceTypeRepository.MetadataType.pluginConfigurationDefinition), new ResourceTypeRepository.TypeLoadedCallback() { + ResourceTypeRepository.Cache.getInstance().getResourceTypes(new Integer[]{resourceTypeId}, EnumSet.of(ResourceTypeRepository.MetadataType.pluginConfigurationDefinition), new ResourceTypeRepository.TypesLoadedCallback() { public void onTypesLoaded(HashMap<Integer, ResourceType> types) { System.out.println("ConfigDef retreived in: " + (System.currentTimeMillis() - start)); definition = types.get(resourceTypeId).getPluginConfigurationDefinition(); + if (definition == null) { + showError("No configuration supported for this resource"); + } reload(); } }); 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 ba77e31..4f78085 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 @@ -21,6 +21,7 @@ package org.rhq.enterprise.gui.coregui.client.dashboard; import org.rhq.enterprise.gui.coregui.client.Presenter; import org.rhq.enterprise.gui.coregui.client.admin.roles.RolesView; import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceSearchView; +import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.SmallGraphView; import org.rhq.enterprise.gui.coregui.client.places.Place;
import com.google.gwt.user.client.Random; @@ -67,12 +68,14 @@ public class DashboardView extends VLayout implements Presenter { Portlet portlet = new Portlet(); portlet.setTitle("Portlet");
- Label label = new Label(); - label.setAlign(Alignment.CENTER); - label.setLayoutAlign(VerticalAlignment.CENTER); - label.setContents("Portlet contents"); - label.setBackgroundColor(colors[Random.nextInt(colors.length - 1)]); - portlet.addItem(label); + // Label label = new Label(); + // label.setAlign(Alignment.CENTER); + // label.setLayoutAlign(VerticalAlignment.CENTER); + // label.setContents("Portlet contents"); + // label.setBackgroundColor(colors[Random.nextInt(colors.length - 1)]); + + portlet.addItem(new SmallGraphView()); + portlet.setHeight(400); portalLayout.addPortlet(portlet); }
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GWTServiceLookup.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GWTServiceLookup.java index 0253897..03ad07b 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GWTServiceLookup.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GWTServiceLookup.java @@ -60,7 +60,9 @@ public class GWTServiceLookup { return secure(SubjectGWTServiceAsync.Util.getInstance()); }
- + public static MeasurementDataGWTServiceAsync getMeasurementDataService() { + return secure(MeasurementDataGWTServiceAsync.Util.getInstance()); + }
private static <T> T secure(Object sdt) { diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/MeasurementDataGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/MeasurementDataGWTService.java index 74efb76..04df2bb 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/MeasurementDataGWTService.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/MeasurementDataGWTService.java @@ -18,9 +18,31 @@ */ package org.rhq.enterprise.gui.coregui.client.gwt;
+import org.rhq.core.domain.auth.Subject; +import org.rhq.core.domain.measurement.DisplayType; +import org.rhq.core.domain.measurement.MeasurementData; +import org.rhq.core.domain.measurement.MeasurementDataTrait; +import org.rhq.core.domain.measurement.composite.MeasurementDataNumericHighLowComposite; + +import com.google.gwt.user.client.rpc.RemoteService; +import com.google.gwt.user.client.rpc.RemoteServiceRelativePath; + +import java.util.List; +import java.util.Set; + /** * @author Greg Hinkle */ -public interface MeasurementDataGWTService { +@RemoteServiceRelativePath("MeasurementDataGWTService") +public interface MeasurementDataGWTService extends RemoteService { + + + List<MeasurementDataTrait> findCurrentTraitsForResource(int resourceId, DisplayType displayType); + + Set<MeasurementData> findLiveData(int resourceId, int[] definitionIds); + + List<List<MeasurementDataNumericHighLowComposite>> findDataForResource(int resourceId, + int[] definitionIds, long beginTime, long endTime, int numPoints); +
} 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 bc1e3a6..8246581 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 @@ -36,6 +36,8 @@ public interface ResourceGWTService extends RemoteService {
List<Resource> getResourceLineage(int resourceId);
+ List<Resource> getResourceLineageAndSiblings(int resourceId); + Resource getPlatformForResource(int resourceId);
} \ No newline at end of file diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/SubjectGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/SubjectGWTService.java index 486b390..eb74cd4 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/SubjectGWTService.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/SubjectGWTService.java @@ -39,9 +39,7 @@ public interface SubjectGWTService extends RemoteService { * @param username The user whose password will be changed * @param password The new password for the user */ - void changePassword( - String username, - String password); + void changePassword(String username, String password);
/** * Creates a new principal (username and password) in the internal database. The password will be encoded before @@ -51,9 +49,7 @@ public interface SubjectGWTService extends RemoteService { * @param password The password part ofthe principal * @throws Exception if the principal could not be added */ - void createPrincipal( - String username, - String password); + void createPrincipal(String username, String password);
/** * Create a a new subject. This <b>ignores</b> the roles in <code>subject</code>. The created subject will not be @@ -62,8 +58,7 @@ public interface SubjectGWTService extends RemoteService { * @param subjectToCreate The subject to be created. * @return the newly persisted {@link Subject} */ - Subject createSubject( - Subject subjectToCreate); + Subject createSubject(Subject subjectToCreate);
/** * Deletes the given set of users, including both the {@link Subject} and {@link org.rhq.core.domain.auth.Principal} objects associated with @@ -72,8 +67,7 @@ public interface SubjectGWTService extends RemoteService { * @param subjectIds identifies the subject IDs for all the users that are to be deleted * @throws Exception if failed to delete one or more users */ - void deleteSubjects( - int[] subjectIds); + void deleteSubjects(int[] subjectIds);
/** @@ -86,17 +80,14 @@ public interface SubjectGWTService extends RemoteService { * @throws org.rhq.enterprise.server.exception.LoginException * if the login failed for some reason */ - Subject login( - String username, - String password); + Subject login(String username, String password);
/** * Logs out a user. * * @param subject The username for the current user */ - void logout( - Subject subject); + void logout(Subject subject);
/** * Updates an existing subject with new data. This does <b>not</b> cascade any changes to the roles but it will save @@ -105,8 +96,7 @@ public interface SubjectGWTService extends RemoteService { * @param subjectToModify the subject whose data is to be updated (which may or may not be the same as <code>user</code>) * @return the merged subject, which may or may not be the same instance of <code>subjectToModify</code> */ - Subject updateSubject( - Subject subjectToModify); + Subject updateSubject(Subject subjectToModify);
PageList<Subject> findSubjectsByCriteria( SubjectCriteria criteria); 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 131e958..333a877 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 @@ -96,7 +96,7 @@ public class ResourceSearchView extends VLayout { listGrid.setCriteria(new Criteria("name", searchPanel.getValueAsString("query"))); listGrid.setSelectionType(SelectionStyle.SIMPLE); listGrid.setSelectionAppearance(SelectionAppearance.CHECKBOX); - + listGrid.setResizeFieldsInRealTime(true);
ListGridField idField = new ListGridField("id", "Id", 55); 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 9afc8a1..dede07c 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 @@ -19,12 +19,14 @@ package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail;
import org.rhq.core.domain.resource.Resource; -import org.rhq.enterprise.gui.coregui.client.CoreGUI; +import org.rhq.core.domain.resource.ResourceType; import org.rhq.enterprise.gui.coregui.client.Presenter; import org.rhq.enterprise.gui.coregui.client.components.FullHTMLPane; import org.rhq.enterprise.gui.coregui.client.components.SubTabLayout; import org.rhq.enterprise.gui.coregui.client.components.configuration.ConfigurationEditor; import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceSelectListener; +import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.GraphListView; +import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository; import org.rhq.enterprise.gui.coregui.client.places.Place;
import com.smartgwt.client.types.ContentsType; @@ -35,6 +37,8 @@ import com.smartgwt.client.widgets.layout.VLayout; import com.smartgwt.client.widgets.tab.Tab; import com.smartgwt.client.widgets.tab.TabSet;
+import java.util.EnumSet; +import java.util.HashMap; import java.util.List;
/** @@ -45,6 +49,9 @@ import java.util.List; public class ResourceDetailView extends VLayout implements Presenter, ResourceSelectListener {
private Resource resource; + + private ResourceSummaryView summaryView; + private Tab summaryTab; private Tab monitoringTab; private Tab inventoryTab; @@ -70,21 +77,24 @@ public class ResourceDetailView extends VLayout implements Presenter, ResourceSe setHeight100();
// addMember(new ResourceSummaryView()); + summaryView = new ResourceSummaryView();
topTabSet = new TabSet(); topTabSet.setTabBarPosition(Side.TOP); topTabSet.setWidth100(); topTabSet.setHeight100(); + topTabSet.setEdgeMarginSize(0); + topTabSet.setEdgeSize(0);
summaryTab = new Tab("Summary", "/images/icons/Service_up_16.png"); - monitoringTab = new Tab("Monitoring","/images/icons/Monitor_grey_16.png"); - inventoryTab = new Tab("Inventory","/images/icons/Inventory_grey_16.png"); - operationsTab = new Tab("Operations","/images/icons/Operation_grey_16.png"); - alertsTab = new Tab("Alerts","/images/icons/Alert_grey_16.png"); - configurationTab = new Tab("Configuration","/images/icons/Configure_grey_16.png"); - eventsTab = new Tab("Events","/images/icons/Events_grey_16.png"); - contentTab = new Tab("Content","/images/icons/Content_grey_16.png"); + monitoringTab = new Tab("Monitoring", "/images/icons/Monitor_grey_16.png"); + inventoryTab = new Tab("Inventory", "/images/icons/Inventory_grey_16.png"); + operationsTab = new Tab("Operations", "/images/icons/Operation_grey_16.png"); + alertsTab = new Tab("Alerts", "/images/icons/Alert_grey_16.png"); + configurationTab = new Tab("Configuration", "/images/icons/Configure_grey_16.png"); + eventsTab = new Tab("Events", "/images/icons/Events_grey_16.png"); + contentTab = new Tab("Content", "/images/icons/Content_grey_16.png");
topTabSet.setTabs(summaryTab, monitoringTab, inventoryTab, operationsTab, alertsTab, configurationTab, eventsTab, contentTab); @@ -92,6 +102,8 @@ public class ResourceDetailView extends VLayout implements Presenter, ResourceSe title.setContents("Loading..."); addMember(title);
+ addMember(summaryView); + addMember(topTabSet);
// CoreGUI.addBreadCrumb(getPlace()); @@ -108,11 +120,14 @@ public class ResourceDetailView extends VLayout implements Presenter, ResourceSe }
public Place getPlace() { - return new Place(String.valueOf(resource.getId()),resource.getName()); + return new Place(String.valueOf(resource.getId()), resource.getName()); }
public void onResourceSelected(Resource resource) { - // TODO: Implement this method. + + this.resource = resource; + + this.summaryView.onResourceSelected(resource);
title.setContents("<h2>" + resource.getName() + "</h2>"); title.markForRedraw(); @@ -120,8 +135,6 @@ public class ResourceDetailView extends VLayout implements Presenter, ResourceSe int selectedTab = topTabSet.getSelectedTabNumber();
- - FullHTMLPane summaryPane = new FullHTMLPane("/rhq/resource/summary/overview-plain.xhtml?id=" + resource.getId()); FullHTMLPane timelinePane = new FullHTMLPane("/rhq/resource/summary/timeline-plain.xhtml?id=" + resource.getId()); SubTabLayout summarySet = new SubTabLayout(); @@ -132,18 +145,66 @@ public class ResourceDetailView extends VLayout implements Presenter, ResourceSe
- HTMLPane monitorPane = new HTMLPane(); - monitorPane.setContentsURL("/rhq/common/monitor/graphs.xhtml?id=" + resource.getId()); - monitorPane.setWidth100(); - monitorPane.setHeight100(); - monitorPane.setContentsType(ContentsType.PAGE);
- topTabSet.updateTab(monitoringTab, monitorPane); + + SubTabLayout monitoringSet = new SubTabLayout(); + monitoringSet.registerSubTab("Graphs", new GraphListView(resource)); // new FullHTMLPane("/rhq/common/monitor/graphs.xhtml?id=" + resource.getId())); + monitoringSet.registerSubTab("Tables", new FullHTMLPane("/rhq/common/monitor/tables.xhtml?id=" + resource.getId())); + monitoringSet.registerSubTab("Traits", new FullHTMLPane("/rhq/resource/monitor/traits.xhtml?id=" + resource.getId())); + monitoringSet.registerSubTab("Availability", new FullHTMLPane("/rhq/resource/monitor/availabilityHistory.xhtml?id=" + resource.getId())); + monitoringSet.registerSubTab("Schedules", new FullHTMLPane("/rhq/resource/monitor/schedules.xhtml?id=" + resource.getId())); + topTabSet.updateTab(monitoringTab, monitoringSet);
topTabSet.updateTab(configurationTab, new ConfigurationEditor(resource.getId(), resource.getResourceType().getId()));
topTabSet.setSelectedTab(selectedTab); + + updateTabStatus(); + topTabSet.markForRedraw(); } + + + private void updateTabStatus() { + ResourceTypeRepository.Cache.getInstance().getResourceTypes(resource.getResourceType().getId(), + EnumSet.of(ResourceTypeRepository.MetadataType.content, ResourceTypeRepository.MetadataType.operations, ResourceTypeRepository.MetadataType.events, ResourceTypeRepository.MetadataType.resourceConfigurationDefinition), + new ResourceTypeRepository.TypeLoadedCallback() { + public void onTypesLoaded(ResourceType type) { + + + if (type.getOperationDefinitions() == null || type.getOperationDefinitions().isEmpty()) { + topTabSet.disableTab(operationsTab); + } else { + topTabSet.enableTab(operationsTab); + } + + if (type.getEventDefinitions() == null || type.getEventDefinitions().isEmpty()) { + topTabSet.disableTab(eventsTab); + } else { + topTabSet.enableTab(eventsTab); + } + + if (type.getPackageTypes() == null || type.getPackageTypes().isEmpty()) { + topTabSet.disableTab(contentTab); + } else { + topTabSet.enableTab(contentTab); + } + + if (type.getResourceConfigurationDefinition() == null) { + topTabSet.disableTab(configurationTab); + } else { + topTabSet.enableTab(configurationTab); + } + + if (topTabSet.getSelectedTab().getDisabled()) { + topTabSet.setSelectedTab(0); + } + + } + }); + + + } + } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceSummaryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceSummaryView.java index cda4983..f16b04e 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceSummaryView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceSummaryView.java @@ -18,20 +18,167 @@ */ package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail;
+import org.rhq.core.domain.measurement.DataType; +import org.rhq.core.domain.measurement.DisplayType; +import org.rhq.core.domain.measurement.MeasurementDataTrait; +import org.rhq.core.domain.measurement.MeasurementDefinition; +import org.rhq.core.domain.resource.Resource; +import org.rhq.core.domain.resource.ResourceType; +import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; +import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceSelectListener; +import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository; + +import com.google.gwt.user.client.rpc.AsyncCallback; +import com.smartgwt.client.util.SC; import com.smartgwt.client.widgets.form.DynamicForm; +import com.smartgwt.client.widgets.form.fields.FormItem; +import com.smartgwt.client.widgets.form.fields.SectionItem; +import com.smartgwt.client.widgets.form.fields.SpacerItem; import com.smartgwt.client.widgets.form.fields.StaticTextItem; +import com.smartgwt.client.widgets.form.fields.TextItem; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.EnumSet; +import java.util.List;
/** * @author Greg Hinkle */ -public class ResourceSummaryView extends DynamicForm { +public class ResourceSummaryView extends DynamicForm implements ResourceSelectListener { + + private Resource resource;
@Override - protected void onInit() { - super.onInit(); + protected void onDraw() { + super.onDraw(); + + setNumCols(4); + setWrapItemTitles(false); + setLeft("10%"); + setWidth("80%"); + } + + + public void onResourceSelected(Resource resource) { + + this.resource = resource; + + ResourceTypeRepository.Cache.getInstance().getResourceTypes(resource.getResourceType().getId(), + EnumSet.of(ResourceTypeRepository.MetadataType.measurements), + new ResourceTypeRepository.TypeLoadedCallback() { + public void onTypesLoaded(ResourceType type) { + try { + buildForm(type); + loadValues(); + } catch (Exception e) { + SC.say("Form load failure"); + e.printStackTrace(); + } + } + }); + + + markForRedraw(); + } + + private void loadValues() { + GWTServiceLookup.getMeasurementDataService().findCurrentTraitsForResource( + resource.getId(), + DisplayType.SUMMARY, + new AsyncCallback<List<MeasurementDataTrait>>() { + public void onFailure(Throwable caught) { + SC.say("Failed to load traits"); + } + + public void onSuccess(List<MeasurementDataTrait> result) { + // TODO: Implement this method. + for (MeasurementDataTrait trait : result) { + String formId = trait.getName().replaceAll("\.", "_").replaceAll(" ","__"); + FormItem item = getItem(formId); + + if (item != null) { + setValue(formId,trait.getValue()); + } + } + markForRedraw(); + } + } + ); + } + + private void buildForm(ResourceType type) { + ArrayList<MeasurementDefinition> traits = new ArrayList<MeasurementDefinition>(); + + for (MeasurementDefinition measurement : type.getMetricDefinitions()) { + if (measurement.getDataType() == DataType.TRAIT && measurement.getDisplayType() == DisplayType.SUMMARY) { + traits.add(measurement); + } + }
- setItems(new StaticTextItem("Summary goes here...")); + Collections.sort(traits, new Comparator<MeasurementDefinition>() { + public int compare(MeasurementDefinition o1, MeasurementDefinition o2) { + return new Integer(o1.getDisplayOrder()).compareTo(o2.getDisplayOrder()); + } + });
+ + ArrayList<FormItem> formItems = new ArrayList<FormItem>(); + ArrayList<String> itemIds = new ArrayList<String>(); + + + StaticTextItem typeItem = new StaticTextItem("typeItem","Type"); + typeItem.setTooltip("Plugin: " + type.getPlugin() + "\n<br>" + "Type: " + type.getName()); + typeItem.setValue(type.getName() + " (" + type.getPlugin() + ")"); + formItems.add(typeItem); + itemIds.add(typeItem.getName()); + + StaticTextItem descriptionItem = new StaticTextItem("descriptionItem","Description"); + descriptionItem.setValue(resource.getDescription()); + formItems.add(descriptionItem); + itemIds.add(descriptionItem.getName()); + + + StaticTextItem versionItem = new StaticTextItem("versionItem","Version"); + formItems.add(versionItem); + itemIds.add(versionItem.getName());
+ + StaticTextItem parentItem = new StaticTextItem("parentItem","Parent"); + formItems.add(parentItem); + itemIds.add(parentItem.getName()); + + + for (MeasurementDefinition trait : traits) { + + String id = trait.getDisplayName().replaceAll("\.", "_").replaceAll(" ","__"); + itemIds.add(id); + + StaticTextItem item = new StaticTextItem(id, trait.getDisplayName()); + item.setTooltip(trait.getDescription()); + formItems.add(item); +// item.setValue("?"); + } + + SectionItem section = new SectionItem("Summary", "Summary"); + section.setTitle("Summary"); + section.setDefaultValue("Summary"); + section.setCanCollapse(true); + section.setCellStyle("HidablePlainSectionHeader"); + section.setItemIds(itemIds.toArray(new String[itemIds.size()])); + + formItems.add(0, section); + formItems.add(new SpacerItem()); + setItems(formItems.toArray(new FormItem[formItems.size()])); + + + setValue("typeItem", type.getName() + " (" + type.getPlugin() + ")"); + setValue("descriptionItem", resource.getDescription()); + setValue("versionItem", resource.getVersion()); + setValue("parentItem", resource.getParentResource() == null ? null : (resource.getParentResource().getName() + + "'<a href="#Resource/" + resource.getParentResource().getId()) + "">" + resource.getParentResource().getName() + "</a>'"); + + } } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java index ea54a2a..f1e4592 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java @@ -171,7 +171,8 @@ public class ResourceTreeDatasource extends DataSource {
private void processIncomingData(List<Resource> result, final DSResponse response, final String requestId) {
- ResourceTypeRepository.Cache.getInstance().loadResourceTypes(result, EnumSet.of(ResourceTypeRepository.MetadataType.operations), + ResourceTypeRepository.Cache.getInstance().loadResourceTypes(result, + EnumSet.of(ResourceTypeRepository.MetadataType.operations, ResourceTypeRepository.MetadataType.children), new ResourceTypeRepository.ResourceTypeLoadedCallback() { public void onResourceTypeLoaded(List<Resource> result) { response.setData(build(result)); 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 93a4431..37ad015 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 @@ -20,6 +20,7 @@ package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail;
import org.rhq.core.domain.operation.OperationDefinition; import org.rhq.core.domain.resource.Resource; +import org.rhq.core.domain.resource.ResourceType; import org.rhq.enterprise.gui.coregui.client.components.configuration.ConfigurationEditor; import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGWTServiceAsync; @@ -58,6 +59,7 @@ public class ResourceTreeView extends VLayout { private Resource rootResource;
private TreeGrid treeGrid; + Menu contextMenu;
private ArrayList<ResourceSelectListener> selectListeners = new ArrayList<ResourceSelectListener>();
@@ -75,12 +77,6 @@ public class ResourceTreeView extends VLayout { if (selectedResource != null) { setSelectedResource(selectedResource); } -// ResourceTreeDatasource ds = new ResourceTreeDatasource(); -// -// setDataSource(new ResourceTreeDatasource()); -// setCriteria(new Criteria("selectedResourceId",String.valueOf(selectedResource.getId()))); - -// setCriteria(new Criteria("",)); }
public void onInit() { @@ -97,8 +93,12 @@ public class ResourceTreeView extends VLayout { treeGrid.setAutoFetchData(true); treeGrid.setAnimateFolders(false); treeGrid.setSelectionType(SelectionStyle.SINGLE); + treeGrid.setShowRollOver(false); + treeGrid.setSortField("name"); + treeGrid.setShowHeader(false); +
- final Menu contextMenu = new Menu(); + contextMenu = new Menu(); MenuItem item = new MenuItem("Expand node"); item.addClickHandler(new com.smartgwt.client.widgets.menu.events.ClickHandler() { public void onClick(MenuItemClickEvent event) { @@ -149,89 +149,139 @@ public class ResourceTreeView extends VLayout { // This constructs the context menu for the resource at the time of the click. setContextMenu(contextMenu); treeGrid.addNodeContextClickHandler(new NodeContextClickHandler() { - public void onNodeContextClick(final NodeContextClickEvent nodeContextClickEvent) { - nodeContextClickEvent.getNode(); - contextMenu.setItems(new MenuItem(nodeContextClickEvent.getNode().getName())); + public void onNodeContextClick(final NodeContextClickEvent event) { + event.getNode();
- contextMenu.addItem(new MenuItem("Id: " + nodeContextClickEvent.getNode().getAttribute("id"))); - contextMenu.addItem(new MenuItem("Parent: " + nodeContextClickEvent.getNode().getAttribute("parentId"))); + buildContextMenu(event.getNode());
+ contextMenu.showContextMenu(); + } + }); + }
- if (nodeContextClickEvent.getNode() instanceof ResourceTreeDatasource.ResourceTreeNode) {
- ResourceTreeDatasource.ResourceTreeNode node = (ResourceTreeDatasource.ResourceTreeNode) nodeContextClickEvent.getNode(); - contextMenu.addItem(new MenuItem("Type: " + ((ResourceTreeDatasource.ResourceTreeNode) nodeContextClickEvent.getNode()).getResourceType().getName())); + private void buildContextMenu(TreeNode node) { + if (node instanceof ResourceTreeDatasource.TypeTreeNode) { + buildContextMenu((ResourceTreeDatasource.TypeTreeNode) node); + } else if (node instanceof ResourceTreeDatasource.ResourceTreeNode) { + buildContextMenu((ResourceTreeDatasource.ResourceTreeNode) node); + } + }
- MenuItem editPluginConfiguration = new MenuItem("Plugin Configuration"); - editPluginConfiguration.addClickHandler(new ClickHandler() { - public void onClick(MenuItemClickEvent event) { - Resource resource = ((ResourceTreeDatasource.ResourceTreeNode) nodeContextClickEvent.getNode()).getResource(); - int resourceId = ((ResourceTreeDatasource.ResourceTreeNode) nodeContextClickEvent.getNode()).getResource().getId(); - int resourceTypeId = ((ResourceTreeDatasource.ResourceTreeNode) nodeContextClickEvent.getNode()).getResourceType().getId(); + private void buildContextMenu(ResourceTreeDatasource.TypeTreeNode node) {
- Window configEditor = new Window(); - configEditor.setTitle("Edit " + resource.getName() + " plugin configuration"); - configEditor.setWidth(800); - configEditor.setHeight(800); - configEditor.setIsModal(true); - configEditor.setShowModalMask(true); - configEditor.centerInPage(); -// configEditor.setShowResizeBar = - configEditor.addItem(new ConfigurationEditor(resourceId, resourceTypeId, ConfigurationEditor.ConfigType.plugin)); - configEditor.show(); + contextMenu.setItems(new MenuItem(node.getName()));
- } - }); - editPluginConfiguration.setEnabled(node.getResource().getResourceType().getPluginConfigurationDefinition() != null); - contextMenu.addItem(editPluginConfiguration); - - - MenuItem editResourceConfiguration = new MenuItem("Resource Configuration"); - editResourceConfiguration.addClickHandler(new ClickHandler() { - public void onClick(MenuItemClickEvent event) { - Resource resource = ((ResourceTreeDatasource.ResourceTreeNode) nodeContextClickEvent.getNode()).getResource(); - int resourceId = ((ResourceTreeDatasource.ResourceTreeNode) nodeContextClickEvent.getNode()).getResource().getId(); - int resourceTypeId = ((ResourceTreeDatasource.ResourceTreeNode) nodeContextClickEvent.getNode()).getResourceType().getId(); - - final Window configEditor = new Window(); - configEditor.setTitle("Edit " + resource.getName() + " resource configuration"); - configEditor.setWidth(800); - configEditor.setHeight(800); - configEditor.setIsModal(true); - configEditor.setShowModalMask(true); - configEditor.centerInPage(); - configEditor.addCloseClickHandler(new CloseClickHandler() { - public void onCloseClick(CloseClientEvent closeClientEvent) { - configEditor.destroy(); - } - }); - configEditor.addItem(new ConfigurationEditor(resourceId, resourceTypeId, ConfigurationEditor.ConfigType.resource)); - configEditor.show();
- } - }); - editResourceConfiguration.setEnabled(node.getResource().getResourceType().getResourceConfigurationDefinition() != null); - contextMenu.addItem(editResourceConfiguration); + }
- contextMenu.addItem(new MenuItemSeparator()); + private void buildContextMenu(final ResourceTreeDatasource.ResourceTreeNode node) {
- MenuItem operations = new MenuItem("Operations"); - Menu opSubMenu = new Menu(); - for (OperationDefinition operationDefinition : node.getResourceType().getOperationDefinitions()) { - opSubMenu.addItem(new MenuItem(operationDefinition.getDisplayName())); + contextMenu.setItems(new MenuItem(node.getName()));
- } - operations.setEnabled(!node.getResourceType().getOperationDefinitions().isEmpty()); - operations.setSubmenu(opSubMenu); - contextMenu.addItem(operations); + contextMenu.addItem(new MenuItem("Type: " + node.getResourceType().getName()));
- }
+ MenuItem editPluginConfiguration = new MenuItem("Plugin Configuration"); + editPluginConfiguration.addClickHandler(new ClickHandler() { + public void onClick(MenuItemClickEvent event) { + Resource resource = node.getResource(); + int resourceId = node.getResource().getId(); + int resourceTypeId = node.getResourceType().getId(); + + Window configEditor = new Window(); + configEditor.setTitle("Edit " + resource.getName() + " plugin configuration"); + configEditor.setWidth(800); + configEditor.setHeight(800); + configEditor.setIsModal(true); + configEditor.setShowModalMask(true); + configEditor.setCanDragResize(true); + configEditor.centerInPage(); + configEditor.addItem(new ConfigurationEditor(resourceId, resourceTypeId, ConfigurationEditor.ConfigType.plugin)); + configEditor.show();
- contextMenu.showContextMenu(); } }); + editPluginConfiguration.setEnabled(node.getResource().getResourceType().getPluginConfigurationDefinition() != null); + contextMenu.addItem(editPluginConfiguration); + + + MenuItem editResourceConfiguration = new MenuItem("Resource Configuration"); + editResourceConfiguration.addClickHandler(new ClickHandler() { + public void onClick(MenuItemClickEvent event) { + Resource resource = node.getResource(); + int resourceId = node.getResource().getId(); + int resourceTypeId = node.getResourceType().getId(); + + final Window configEditor = new Window(); + configEditor.setTitle("Edit " + resource.getName() + " resource configuration"); + configEditor.setWidth(800); + configEditor.setHeight(800); + configEditor.setIsModal(true); + configEditor.setShowModalMask(true); + configEditor.setCanDragResize(true); + configEditor.setShowResizer(true); + configEditor.centerInPage(); + configEditor.addCloseClickHandler(new CloseClickHandler() { + public void onCloseClick(CloseClientEvent closeClientEvent) { + configEditor.destroy(); + } + }); + configEditor.addItem(new ConfigurationEditor(resourceId, resourceTypeId, ConfigurationEditor.ConfigType.resource)); + configEditor.show(); + + } + }); + editResourceConfiguration.setEnabled(node.getResource().getResourceType().getResourceConfigurationDefinition() != null); + contextMenu.addItem(editResourceConfiguration); + + contextMenu.addItem(new MenuItemSeparator()); + + + // Operations Menu + MenuItem operations = new MenuItem("Operations"); + Menu opSubMenu = new Menu(); + for (OperationDefinition operationDefinition : node.getResourceType().getOperationDefinitions()) { + opSubMenu.addItem(new MenuItem(operationDefinition.getDisplayName())); + // todo action + } + operations.setEnabled(!node.getResourceType().getOperationDefinitions().isEmpty()); + operations.setSubmenu(opSubMenu); + contextMenu.addItem(operations); + + + + // Create Menu + MenuItem createChildMenu = new MenuItem("Create Child"); + Menu createChildSubMenu = new Menu(); + for (ResourceType childType : node.getResourceType().getChildResourceTypes()) { + if (childType.isCreatable()) { + createChildSubMenu.addItem(new MenuItem(childType.getName())); + //todo action + } + } + createChildMenu.setSubmenu(createChildSubMenu); + createChildMenu.setEnabled(createChildSubMenu.getItems().length > 0); + contextMenu.addItem(createChildMenu); + + + // Manually Menu + MenuItem importChildMenu = new MenuItem("Import"); + Menu importChildSubMenu = new Menu(); + for (ResourceType childType : node.getResourceType().getChildResourceTypes()) { + if (childType.isSupportsManualAdd()) { + importChildSubMenu.addItem(new MenuItem(childType.getName())); + //todo action + } + } + importChildMenu.setSubmenu(importChildSubMenu); + importChildMenu.setEnabled(importChildSubMenu.getItems().length > 0); + contextMenu.addItem(importChildMenu); + + + + }
@@ -244,7 +294,7 @@ public class ResourceTreeView extends VLayout { treeGrid.getTree().openFolder(node); } else { final ResourceGWTServiceAsync resourceService = GWTServiceLookup.getResourceService(); - resourceService.getResourceLineage(selectedResource.getId(), new AsyncCallback<List<Resource>>() { + resourceService.getResourceLineageAndSiblings(selectedResource.getId(), new AsyncCallback<List<Resource>>() { public void onFailure(Throwable caught) { SC.say("Failed to lookup platform"); System.out.println("Failed to lookup parent"); @@ -260,23 +310,16 @@ public class ResourceTreeView extends VLayout { } buildTree();
-// TreeNode[] selectedLineage = ResourceTreeDatasource.build(result); -// TreeNode[] preloadData = ResourceTreeDatasource.build(preload(result)); -// -// TreeNode[] rootData = ResourceTreeDatasource.build(result.subList(0,0)); - - ResourceTreeView.this.rootResource = root;
-// treeGrid.setLoadDataOnDemand(true); ResourceTreeDatasource dataSource = new ResourceTreeDatasource(result); treeGrid.setDataSource(dataSource); + // GH: couldn't get initial data to mix with the datasource... so i put the inital data in + // the first datasource request // treeGrid.setInitialData(selectedLineage);
- addMember(treeGrid); -// treeGrid.fetchData();
treeGrid.addDataArrivedHandler(new DataArrivedHandler() { @@ -303,19 +346,8 @@ public class ResourceTreeView extends VLayout { for (TreeNode n : ResourceTreeDatasource.build(result)) { treeGrid.getDataSource().addData(n); } -// -// TreeNode selectedNode = treeGrid.getTree().findById(String.valueOf(selectedResource.getId())); -// if (selectedNode != null) { -// treeGrid.getTree().openFolders(treeGrid.getTree().getParents(selectedNode)); -// treeGrid.selectRecord(selectedNode); -// } else { -// System.out.println("Couldn't select " + selectedResource.getId()); -// } }
-// TreeNode[] selectedLineage = ResourceTreeDatasource.build(result); -// getTree().linkNodes(selectedLineage); -
// CoreGUI.addBreadCrumb(new Place(String.valueOf(result.getId()), result.getName())); } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/GraphListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/GraphListView.java index c08ddfc..1ff9332 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/GraphListView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/GraphListView.java @@ -18,9 +18,113 @@ */ package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring;
+import org.rhq.core.domain.measurement.DataType; +import org.rhq.core.domain.measurement.DisplayType; +import org.rhq.core.domain.measurement.MeasurementDefinition; +import org.rhq.core.domain.measurement.composite.MeasurementDataNumericHighLowComposite; +import org.rhq.core.domain.resource.Resource; +import org.rhq.core.domain.resource.ResourceType; +import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; +import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceSelectListener; +import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository; + +import com.google.gwt.user.client.rpc.AsyncCallback; +import com.google.gwt.user.client.rpc.core.java.util.Arrays; +import com.smartgwt.client.util.SC; +import com.smartgwt.client.widgets.Canvas; +import com.smartgwt.client.widgets.layout.VLayout; + +import java.util.ArrayList; +import java.util.EnumSet; +import java.util.List; + /** * @author Greg Hinkle */ -public class GraphListView { +public class GraphListView extends VLayout implements ResourceSelectListener { + + + private Resource resource; + + + public GraphListView() { + } + + public GraphListView(Resource resource) { + this.resource = resource; + } + + + @Override + protected void onDraw() { + super.onDraw(); + + for (Canvas c : getMembers()) { + c.destroy(); + } + buildGraphs(); + } + + + private void buildGraphs() { + + + ResourceTypeRepository.Cache.getInstance().getResourceTypes( + resource.getResourceType().getId(), EnumSet.of(ResourceTypeRepository.MetadataType.measurements), + new ResourceTypeRepository.TypeLoadedCallback() { + public void onTypesLoaded(final ResourceType type) { + + final ArrayList<MeasurementDefinition> measurementDefinitions = new ArrayList<MeasurementDefinition>(); + + for (MeasurementDefinition def : type.getMetricDefinitions()) { + if (def.getDataType() == DataType.MEASUREMENT && def.getDisplayType() == DisplayType.SUMMARY) { + measurementDefinitions.add(def); + } + } + + int[] measDefIdArray = new int[measurementDefinitions.size()]; + for (int i = 0; i < measDefIdArray.length; i++) { + measDefIdArray[i] = measurementDefinitions.get(i).getId(); + } + + GWTServiceLookup.getMeasurementDataService().findDataForResource( + resource.getId(), + measDefIdArray, + System.currentTimeMillis() - (1000L*60*60*8), + System.currentTimeMillis(), + 60, + new AsyncCallback<List<List<MeasurementDataNumericHighLowComposite>>>() { + public void onFailure(Throwable caught) { + SC.say("Failed data load"); + } + + public void onSuccess(List<List<MeasurementDataNumericHighLowComposite>> result) { + int i = 0; + for (List<MeasurementDataNumericHighLowComposite> data : result) { + buildGraph(measurementDefinitions.get(i++), data); + } + } + } + ); + + } + } + ); + } + + private void buildGraph(MeasurementDefinition def, List<MeasurementDataNumericHighLowComposite> data) { + + addMember(new SmallGraphView(def, data)); + + } + + public void onResourceSelected(Resource resource) { + this.resource = resource; + + +
+ buildGraphs(); + markForRedraw(); + } } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/SmallGraphView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/SmallGraphView.java index 32fe407..4c23252 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/SmallGraphView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/SmallGraphView.java @@ -18,9 +18,213 @@ */ package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring;
+import ca.nanometrics.gflot.client.Axis; +import ca.nanometrics.gflot.client.DataPoint; +import ca.nanometrics.gflot.client.PlotItem; +import ca.nanometrics.gflot.client.PlotModel; +import ca.nanometrics.gflot.client.PlotPosition; +import ca.nanometrics.gflot.client.SeriesHandler; +import ca.nanometrics.gflot.client.SimplePlot; +import ca.nanometrics.gflot.client.event.PlotHoverListener; +import ca.nanometrics.gflot.client.jsni.Plot; +import ca.nanometrics.gflot.client.options.AxisOptions; +import ca.nanometrics.gflot.client.options.GridOptions; +import ca.nanometrics.gflot.client.options.LineSeriesOptions; +import ca.nanometrics.gflot.client.options.PlotOptions; +import ca.nanometrics.gflot.client.options.PointsSeriesOptions; +import ca.nanometrics.gflot.client.options.TickFormatter; + +import org.rhq.core.domain.measurement.MeasurementConverter; +import org.rhq.core.domain.measurement.MeasurementDefinition; +import org.rhq.core.domain.measurement.composite.MeasurementDataNumericHighLowComposite; + +import com.google.gwt.i18n.client.DateTimeFormat; +import com.smartgwt.client.types.AnimationEffect; +import com.smartgwt.client.widgets.Canvas; +import com.smartgwt.client.widgets.HTMLFlow; +import com.smartgwt.client.widgets.Label; +import com.smartgwt.client.widgets.layout.VLayout; + +import java.util.Date; +import java.util.List; + /** * @author Greg Hinkle */ -public class SmallGraphView { +public class SmallGraphView extends VLayout { + + + private static final String INSTRUCTIONS = "Point your mouse to a data point on the chart"; + + private static final String[] MONTH_NAMES = {"jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"}; + + private final Label selectedPointLabel = new Label(INSTRUCTIONS); + private final Label positionLabel = new Label(); + + private final Label hoverLabel = new Label(); + + private MeasurementDefinition definition; + private List<MeasurementDataNumericHighLowComposite> data; + + + public SmallGraphView() { + super(); + } + + public SmallGraphView(MeasurementDefinition def, List<MeasurementDataNumericHighLowComposite> data) { + super(); + this.definition = def; + this.data = data; + setHeight(250); + setWidth100(); + setPadding(10); + } + + public String getName() { + return "PlotHoverListener"; + } + + @Override + protected void onDraw() { + super.onDraw(); + + for (Canvas c : getChildren()) { + c.destroy(); + } + + drawGraph(); + } + + private void drawGraph() { + + PlotModel model = new PlotModel(); + PlotOptions plotOptions = new PlotOptions(); + plotOptions.setDefaultLineSeriesOptions(new LineSeriesOptions().setLineWidth(1).setShow(true)); + plotOptions.setDefaultPointsOptions(new PointsSeriesOptions().setRadius(2).setShow(true)); + plotOptions.setDefaultShadowSize(0); + + + + // You need make the grid hoverable <<<<<<<<< + plotOptions.setGridOptions(new GridOptions().setHoverable(true).setMouseActiveRadius(10).setAutoHighlight(true)); + + + // create a series + if (definition != null && data != null) { + loadData(model, plotOptions); + } else { + loadFakeData(model, plotOptions); + } + + // create the plot + SimplePlot plot = new SimplePlot(model, plotOptions); + plot.setSize("100%","70%"); + + + // add hover listener + plot.addHoverListener(new PlotHoverListener() { + public void onPlotHover(Plot plot, PlotPosition position, PlotItem item) { + if (position != null) { + positionLabel.setContents("position: (" + position.getX() + "," + position.getY() + ")"); + } + if (item != null) { + hoverLabel.setContents(getHover(item)); + + hoverLabel.animateShow(AnimationEffect.FADE); + if (hoverLabel.getLeft() > 0 || hoverLabel.getTop() > 0) { + hoverLabel.animateMove(item.getPageX() + 5, item.getPageY() + 5); + } else { + hoverLabel.moveTo(item.getPageX() + 5, item.getPageY() + 5); + } + hoverLabel.redraw(); + + selectedPointLabel.setContents("x: " + item.getDataPoint().getX() + ", y: " + item.getDataPoint().getY()); + } else { + hoverLabel.animateHide(AnimationEffect.FADE); + selectedPointLabel.setContents(INSTRUCTIONS); + } + } + }, false); + + hoverLabel.setOpacity(80); + hoverLabel.setWrap(false); + hoverLabel.setHeight(25); + hoverLabel.setBackgroundColor("yellow"); + hoverLabel.setBorder("1px solid orange"); + hoverLabel.hide(); + + hoverLabel.draw(); + + // put it on a panel + + if (definition != null) { + addMember(new HTMLFlow("<b>" + definition.getDisplayName() + "</b> " + definition.getDescription())); + } + addMember(plot); + } + + private String getHover(PlotItem item) { + if (definition != null) { + com.google.gwt.i18n.client.DateTimeFormat df = DateTimeFormat.getMediumDateTimeFormat(); + return definition.getDisplayName() + ": " + MeasurementConverter.format(item.getDataPoint().getY(),definition.getUnits(), true) + + "<br/>" + df.format(new Date((long) item.getDataPoint().getX())); + } else { + return "x: " + item.getDataPoint().getX() + ", y: " + item.getDataPoint().getY(); + } + } + + private void loadData(PlotModel model, PlotOptions plotOptions) { + SeriesHandler handler = model.addSeries(definition.getDisplayName(), "#007f00"); + + for (MeasurementDataNumericHighLowComposite d : data) { + handler.add(new DataPoint(d.getTimestamp(), d.getValue())); + } + + plotOptions.setYAxisOptions(new AxisOptions().setTicks(5).setTickFormatter(new TickFormatter() { + public String formatTickValue(double v, Axis axis) { + return MeasurementConverter.format(v, definition.getUnits(), true); + } + })); + + long max = System.currentTimeMillis(); + long min = max - (1000L * 60 * 60 *8); + + plotOptions.setXAxisOptions(new AxisOptions().setTicks(8). setMinimum(min).setMaximum(max).setTickFormatter(new TickFormatter() { + public String formatTickValue(double tickValue, Axis axis) { + return String.valueOf(new Date((long) tickValue)); +// return MONTH_NAMES[(int) (tickValue - 1)]; + } + })); + + } + + private void loadFakeData(PlotModel model, PlotOptions plotOptions) { + SeriesHandler handler = model.addSeries("Ottawa's Month Temperatures", "#007f00"); + + // add data + handler.add(new DataPoint(1, -10.5)); + handler.add(new DataPoint(2, -8.6)); + handler.add(new DataPoint(3, -2.4)); + handler.add(new DataPoint(4, 6)); + handler.add(new DataPoint(5, 13.6)); + handler.add(new DataPoint(6, 18.4)); + handler.add(new DataPoint(7, 21)); + handler.add(new DataPoint(8, 19.7)); + handler.add(new DataPoint(9, 14.7)); + handler.add(new DataPoint(10, 8.2)); + handler.add(new DataPoint(11, 1.5)); + handler.add(new DataPoint(12, -6.6)); + + plotOptions.setXAxisOptions(new AxisOptions().setTicks(12).setTickFormatter(new TickFormatter() { + public String formatTickValue(double tickValue, Axis axis) { + return MONTH_NAMES[(int) (tickValue - 1)]; + } + })); + }
+ @Override + protected void onDestroy() { + super.onDestroy(); + hoverLabel.destroy(); + } } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/type/ResourceTypeRepository.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/type/ResourceTypeRepository.java index 55a082b..a62ca57 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/type/ResourceTypeRepository.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/type/ResourceTypeRepository.java @@ -24,7 +24,6 @@ import org.rhq.core.domain.resource.Resource; import org.rhq.core.domain.resource.ResourceType; 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.gwt.GWTServiceLookup; import org.rhq.enterprise.gui.coregui.client.gwt.ResourceTypeGWTServiceAsync;
@@ -62,6 +61,11 @@ public class ResourceTypeRepository {
public static interface TypeLoadedCallback { + void onTypesLoaded( ResourceType type); + } + + + public static interface TypesLoadedCallback { void onTypesLoaded(HashMap<Integer, ResourceType> types); }
@@ -74,18 +78,6 @@ public class ResourceTypeRepository { }
public void loadResourceTypes(final List<Resource> resources, final EnumSet<MetadataType> metadataTypes, final ResourceTypeLoadedCallback callback) { - - - resourceTypeService.dummy(new RawConfiguration(), new AsyncCallback<RawConfiguration>() { - public void onFailure(Throwable caught) { - System.out.println("dummy failed"); - } - - public void onSuccess(RawConfiguration result) { - System.out.println("dummy worked"); - } - }); - if (resources.size() == 0) { callback.onResourceTypeLoaded(resources); return; @@ -98,7 +90,7 @@ public class ResourceTypeRepository { for (Resource res : resources) { types.add(res.getResourceType().getId()); } - getResourceTypes(types.toArray(new Integer[types.size()]), metadataTypes, new TypeLoadedCallback() { + getResourceTypes(types.toArray(new Integer[types.size()]), metadataTypes, new TypesLoadedCallback() { public void onTypesLoaded(HashMap<Integer, ResourceType> types) { for (Resource res : resources) { res.setResourceType(types.get(res.getResourceType().getId())); @@ -112,34 +104,44 @@ public class ResourceTypeRepository { }
- public void getResourceTypes(Integer[] resourceTypeIds, final TypeLoadedCallback callback) { + public void getResourceTypes(Integer[] resourceTypeIds, final TypesLoadedCallback callback) { getResourceTypes(resourceTypeIds, null, callback); }
- public void getResourceTypes(Integer[] resourceTypeIds, final EnumSet<MetadataType> metadataTypes, final TypeLoadedCallback callback) { - ResourceTypeCriteria criteria = new ResourceTypeCriteria(); + public void getResourceTypes(final Integer resourceTypeId, final EnumSet<MetadataType> metadataTypes, final TypeLoadedCallback callback) { + getResourceTypes(new Integer[]{resourceTypeId}, metadataTypes, new TypesLoadedCallback() { + public void onTypesLoaded(HashMap<Integer, ResourceType> types) { + callback.onTypesLoaded(types.get(resourceTypeId)); + } + }); + }
- ArrayList<Integer> typesNeeded = new ArrayList<Integer>(); + public void getResourceTypes(Integer[] resourceTypeIds, final EnumSet<MetadataType> metadataTypes, final TypesLoadedCallback callback) { + ResourceTypeCriteria criteria = new ResourceTypeCriteria();
final HashMap<Integer, ResourceType> cachedTypes = new HashMap<Integer, ResourceType>();
- for (Integer typeId : resourceTypeIds) { - if (!typeCache.containsKey(typeId) || (metadataTypes != null && !typeCacheLevel.get(typeId).containsAll(metadataTypes))) { - typesNeeded.add(typeId); - } else { - cachedTypes.put(typeId, typeCache.get(typeId)); - } - } - + if (resourceTypeIds == null) { + //preload all + } else { + ArrayList<Integer> typesNeeded = new ArrayList<Integer>();
+ for (Integer typeId : resourceTypeIds) { + if (!typeCache.containsKey(typeId) || (metadataTypes != null && !typeCacheLevel.get(typeId).containsAll(metadataTypes))) { + typesNeeded.add(typeId); + } else { + cachedTypes.put(typeId, typeCache.get(typeId)); + } + }
- if (typesNeeded.isEmpty()) { - callback.onTypesLoaded(cachedTypes); - return; + if (typesNeeded.isEmpty()) { + callback.onTypesLoaded(cachedTypes); + return; + } + criteria.addFilterIds(typesNeeded.toArray(new Integer[typesNeeded.size()])); }
- if (metadataTypes != null) { for (MetadataType metadataType : metadataTypes) { switch (metadataType) { @@ -168,8 +170,6 @@ public class ResourceTypeRepository { } }
- criteria.addFilterIds(typesNeeded.toArray(new Integer[typesNeeded.size()])); - criteria.setPageControl(PageControl.getUnlimitedInstance());
resourceTypeService.findResourceTypesByCriteria(criteria, new AsyncCallback<PageList<ResourceType>>() { @@ -229,4 +229,11 @@ public class ResourceTypeRepository { }
+ public void preloadAll() { + getResourceTypes((Integer[]) null, EnumSet.allOf(MetadataType.class), new TypesLoadedCallback() { + public void onTypesLoaded(HashMap<Integer, ResourceType> types) { + System.out.println("Preloaded ["+ types.size() + "] resource types"); + } + }); + } } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/MeasurementDataGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/MeasurementDataGWTServiceImpl.java index 7b0a971..8ef7f0a 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/MeasurementDataGWTServiceImpl.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/MeasurementDataGWTServiceImpl.java @@ -18,9 +18,44 @@ */ package org.rhq.enterprise.gui.coregui.server.gwt;
+import org.rhq.core.domain.auth.Subject; +import org.rhq.core.domain.measurement.DisplayType; +import org.rhq.core.domain.measurement.MeasurementData; +import org.rhq.core.domain.measurement.MeasurementDataTrait; +import org.rhq.core.domain.measurement.composite.MeasurementDataNumericHighLowComposite; +import org.rhq.enterprise.gui.coregui.client.gwt.MeasurementDataGWTService; +import org.rhq.enterprise.gui.coregui.server.util.SerialUtility; +import org.rhq.enterprise.server.measurement.MeasurementDataManagerLocal; +import org.rhq.enterprise.server.util.LookupUtil; + +import java.util.List; +import java.util.Set; + /** * @author Greg Hinkle */ -public class MeasurementDataGWTServiceImpl { +public class MeasurementDataGWTServiceImpl extends AbstractGWTServiceImpl implements MeasurementDataGWTService { + + private MeasurementDataManagerLocal dataManager = LookupUtil.getMeasurementDataManager(); + + public List<MeasurementDataTrait> findCurrentTraitsForResource(int resourceId, DisplayType displayType) { + return SerialUtility.prepare( + dataManager.findCurrentTraitsForResource(getSessionSubject(), resourceId, displayType), + "MeasurementDataService.findCurrentTraitsForResource"); + } + + + public Set<MeasurementData> findLiveData(int resourceId, int[] definitionIds) { + return SerialUtility.prepare( + dataManager.findLiveData(getSessionSubject(), resourceId, definitionIds), + "MeasurementDataService.findLiveData"); + } +
+ public List<List<MeasurementDataNumericHighLowComposite>> findDataForResource(int resourceId, int[] definitionIds, long beginTime, long endTime, int numPoints) { + return SerialUtility.prepare( + dataManager.findDataForResource( + getSessionSubject(), resourceId, definitionIds, beginTime, endTime, numPoints), + "MeasurementDataService.findDataForResource"); + } } 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 5e4164a..4198923 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 @@ -137,12 +137,16 @@ public class ResourceGWTServiceImpl extends AbstractGWTServiceImpl implements Re } }
- public List<Resource> getResourceLineage(int resourceId) { return SerialUtility.prepare(resourceManager.getResourceLineage(resourceId), "ResourceService.getResourceLineage"); }
+ public List<Resource> getResourceLineageAndSiblings(int resourceId) { + return SerialUtility.prepare(resourceManager.getResourceLineageAndSiblings(resourceId), "ResourceService.getResourceLineage"); + } + + public Resource getPlatformForResource(int resourceId) { return SerialUtility.prepare(resourceManager.getRootResourceForResource(resourceId), "ResourceService.getPlatformForResource"); } diff --git a/modules/enterprise/gui/coregui/src/main/webapp/CoreGUI.css b/modules/enterprise/gui/coregui/src/main/webapp/CoreGUI.css index 9d5deaa..3674615 100644 --- a/modules/enterprise/gui/coregui/src/main/webapp/CoreGUI.css +++ b/modules/enterprise/gui/coregui/src/main/webapp/CoreGUI.css @@ -6,8 +6,6 @@ body { margin: 8px; }
- - .OddRow { background-color: white; border-bottom-color: rgb(230, 234, 239); @@ -18,6 +16,7 @@ body { border-right-width: 1px;
} + .OddRowDisabled { background-color: white; border-bottom-color: rgb(230, 234, 239); @@ -39,6 +38,7 @@ body { border-right-width: 1px;
} + .EvenRowDisabled { background-color: rgb(246, 246, 246); border-bottom-color: rgb(230, 234, 239); @@ -50,7 +50,6 @@ body {
}
- .TopSectionLink { font-size: 16pt; font-weight: bold; @@ -72,22 +71,71 @@ z font-weight: bold; }
- .textItemDisabled { background: rgb(214, 213, 217); }
.formTitle, .formTitleFocused { - font-weight:bold; + font-weight: bold; }
-.SubTabButton,.SubTabButtonSelected { - font-family: Arial,Verdana,Bitstream Vera Sans,sans-serif; +.SubTabButton, +.SubTabButtonOver, +.SubTabButtonFocused, +.SubTabButtonFocusedOver, +.SubTabButtonDown, +.SubTabButtonFocusedDown, +.SubTabButtonSelected, +.SubTabButtonSelectedFocused, +.SubTabButtonSelectedDown, +.SubTabButtonSelectedFocusedDown, +.SubTabButtonSelectedOver, +.SubTabButtonSelectedFocusedOver, +.SubTabButtonDisabled, +.SubTabButtonSelectedDisabled { + font-family: Arial, Verdana, Bitstream Vera Sans, sans-serif; font-size: 11px; padding: 2px; + } + +.SubTabButtonDisabled { + +} + +.SubTabButtonDisabled, +.SubTabButtonSelectedDisabled { + font-weight: normal; + color: #AAAAAA; }
-.SubTabButtonSelected { - font-weight: bold; +.SubTabButtonFocused, +.SubTabButtonFocusedOver, +.SubTabButtonSelectedFocused, +.SubTabButtonSelectedFocusedOver, +.SubTabButtonSelectedFocusedDown { + +} + +.SubTabButtonOver, +.SubTabButtonFocusedOver, +.SubTabButtonSelectedFocused, +.SubTabButtonSelectedFocusedOver { + font-weight: bold; +} + +.SubTabButtonDown, +.SubTabButtonFocusedDown, +.SubTabButtonSelectedDown, +.SubTabButtonSelectedFocusedDown { + font-weight: bold; + font-size: 12px; +} + +.SubTabButtonSelected, +.SubTabButtonSelectedFocused, +.SubTabButtonSelectedOver, +.SubTabButtonSelectedFocusedOver, +.SubTabButtonSelectedDisabled { + font-weight: bold; } \ No newline at end of file diff --git a/modules/enterprise/gui/coregui/src/main/webapp/CoreGUI.html b/modules/enterprise/gui/coregui/src/main/webapp/CoreGUI.html index 4f28aac..722fdc0 100644 --- a/modules/enterprise/gui/coregui/src/main/webapp/CoreGUI.html +++ b/modules/enterprise/gui/coregui/src/main/webapp/CoreGUI.html @@ -10,9 +10,9 @@ <script type="text/javascript" language="javascript" src="org.rhq.enterprise.gui.coregui.CoreGUI/org.rhq.enterprise.gui.coregui.CoreGUI.nocache.js"></script>
-<div id="Loading-Panel"> - <img src="/images/ajax-loader.gif" alt="loading"> Loading RHQ, please wait... -</div> +<div id="Loading-Panel" style="width: 210px;height: 80px; top: 300px; margin-left: auto;margin-right: auto;"> + <img src="images/rhq_logo_animated_100px.gif" alt="loading" style="border: 1px solid gray; margin: 5px;"> + <div>
<iframe src="javascript:''" id="__gwt_historyFrame" style="width:0;height:0;border:0"></iframe>
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 6b4eacc..c35f36b 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 @@ -24,13 +24,15 @@ </servlet> <servlet> <servlet-name>org.rhq.enterprise.gui.coregui.CoreGUI ConfigurationGWTService</servlet-name> - <servlet-class>org.rhq.enterprise.gui.coregui.server.gwt.ConfigurationGWTServiceImpl - </servlet-class> + <servlet-class>org.rhq.enterprise.gui.coregui.server.gwt.ConfigurationGWTServiceImpl</servlet-class> </servlet> <servlet> <servlet-name>org.rhq.enterprise.gui.coregui.CoreGUI ResourceTypeGWTService</servlet-name> - <servlet-class>org.rhq.enterprise.gui.coregui.server.gwt.ResourceTypeGWTServiceImpl - </servlet-class> + <servlet-class>org.rhq.enterprise.gui.coregui.server.gwt.ResourceTypeGWTServiceImpl</servlet-class> + </servlet> + <servlet> + <servlet-name>org.rhq.enterprise.gui.coregui.CoreGUI MeasurementDataGWTService</servlet-name> + <servlet-class>org.rhq.enterprise.gui.coregui.server.gwt.MeasurementDataGWTServiceImpl</servlet-class> </servlet>
@@ -62,4 +64,8 @@ <servlet-name>org.rhq.enterprise.gui.coregui.CoreGUI ResourceTypeGWTService</servlet-name> <url-pattern>/org.rhq.enterprise.gui.coregui.CoreGUI/ResourceTypeGWTService</url-pattern> </servlet-mapping> + <servlet-mapping> + <servlet-name>org.rhq.enterprise.gui.coregui.CoreGUI MeasurementDataGWTService</servlet-name> + <url-pattern>/org.rhq.enterprise.gui.coregui.CoreGUI/MeasurementDataGWTService</url-pattern> + </servlet-mapping> </web-app> diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/util/MonitorUtils.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/util/MonitorUtils.java index 7afccb0..38e45bd 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/util/MonitorUtils.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/util/MonitorUtils.java @@ -32,7 +32,7 @@ import org.rhq.core.clientapi.util.units.DateFormatter.DateSpecifics; import org.rhq.core.domain.measurement.MeasurementUnits; import org.rhq.core.domain.measurement.composite.MeasurementNumericValueAndUnits; import org.rhq.core.domain.measurement.composite.MeasurementValueAndUnits; -import org.rhq.core.domain.measurement.MeasurementConverter; +import org.rhq.core.server.MeasurementConverter; import org.rhq.enterprise.gui.legacy.Constants; import org.rhq.enterprise.server.measurement.uibean.MetricDisplaySummary;
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/monitor/availabilityHistory.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/monitor/availabilityHistory.xhtml index 932adc1..61c7798 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/monitor/availabilityHistory.xhtml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/monitor/availabilityHistory.xhtml @@ -14,14 +14,7 @@ xmlns:a4j="https://ajax4jsf.dev.java.net/ajax" xmlns:rich="http://richfaces.ajax4jsf.org/rich%22%3E
-<ui:composition template="/rhq/resource/layout/main.xhtml"> - - <ui:param name="pageTitle" value="#{ResourceUIBean.resourceType.name} '#{ResourceUIBean.name}' - Metric Tables"/> - <ui:param name="selectedTabName" value="Monitor.Availability"/> - - <ui:define name="content"> - - +<body> <f:facet name="header" styleClass="BlockTitle"> <a name="AvailabilityHistory"/> Availability History @@ -198,9 +191,6 @@
</h:form> </rich:panel> - - </ui:define> - -</ui:composition> +</body>
</html> diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/monitor/schedules.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/monitor/schedules.xhtml index c568507..ac82b66 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/monitor/schedules.xhtml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/monitor/schedules.xhtml @@ -15,13 +15,7 @@ xmlns:a4j="https://ajax4jsf.dev.java.net/ajax" xmlns:rich="http://richfaces.ajax4jsf.org/rich">
-<ui:composition template="/rhq/resource/layout/main.xhtml"> - -<ui:param name="pageTitle" value="#{ResourceUIBean.resourceType.name} '#{ResourceUIBean.name}' - Metric Schedules"/> -<ui:param name="selectedTabName" value="Monitor.Schedules"/> - -<ui:define name="content"> - +<body> <h:outputText rendered="#{not ResourceUIBean.permissions.measure}" value="You don't have the measure permission for this resource and therefore can not change metric schedules"/>
@@ -171,9 +165,5 @@
</rich:panel> </h:form> - -</ui:define> - -</ui:composition> - +</body> </html> diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/monitor/traits.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/monitor/traits.xhtml index 1509fc2..8d0a42a 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/monitor/traits.xhtml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/monitor/traits.xhtml @@ -14,13 +14,7 @@ xmlns:a4j="https://ajax4jsf.dev.java.net/ajax" xmlns:rich="http://richfaces.ajax4jsf.org/rich">
-<ui:composition template="/rhq/resource/layout/main.xhtml"> - -<ui:param name="pageTitle" value="#{ResourceUIBean.resourceType.name} '#{ResourceUIBean.name}' - Metric Traits"/> -<ui:param name="selectedTabName" value="Monitor.Traits"/> - -<ui:define name="content"> - +<body> <rich:panel styleClass="BlockContent">
<f:facet name="header" styleClass="BlockTitle"> @@ -104,9 +98,5 @@ </rich:dataTable>
</rich:panel> - -</ui:define> - -</ui:composition> - +</body> </html> 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 7c463cc..6cb15a4 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 @@ -632,6 +632,24 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage int childResourceId = resourceId; Resource parent; while ((parent = getParentResource(childResourceId)) != null) { + resourceLineage.addFirst(parent); + childResourceId = parent.getId(); // This also ensures Hibernate actually populates parent's fields. + } + + return resourceLineage; + } + + public List<Resource> getResourceLineageAndSiblings(int resourceId) { + LinkedList<Resource> resourceLineage = new LinkedList<Resource>(); + Resource resource = entityManager.find(Resource.class, resourceId); + if (resource == null) { + throw new ResourceNotFoundException(resourceId); + } + + resourceLineage.add(resource); + int childResourceId = resourceId; + Resource parent; + while ((parent = getParentResource(childResourceId)) != null) { resourceLineage.addAll(parent.getChildResources()); resourceLineage.addFirst(parent); childResourceId = parent.getId(); // This also ensures Hibernate actually populates parent's fields. @@ -640,6 +658,7 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage return resourceLineage; }
+ @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 95445de..abd0622 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 @@ -162,6 +162,16 @@ public interface ResourceManagerLocal { @NotNull List<Resource> getResourceLineage(int resourceId);
+ + /** + * Returns the lineage of a resource plus all the siblings of the resources in the lineage. This is + * useful for prepopulating all the resources visible in an expanded tree. + * @param resourceId id of resource + * @return resoure lineage and siblings + */ + List<Resource> getResourceLineageAndSiblings(int resourceId); + + /** * Looks up the root of a subtree in the inventory. This will generally find the platform on which * a resource is running.
commit 36c0482d5156d6a1c7f897af8acc1bbbe78ce75c Author: Greg Hinkle <ghinkle@redhat.com> Date: Wed Feb 24 10:00:22 2010 -0500
Fixing more of the portal-war dependencies on MeasurementConverter More features in gwt
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/server/MeasurementConverter.java b/modules/core/domain/src/main/java/org/rhq/core/domain/server/MeasurementConverter.java new file mode 100644 index 0000000..0471823 --- /dev/null +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/server/MeasurementConverter.java @@ -0,0 +1,26 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2010 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +package org.rhq.core.domain.server; + +/** + * @author Greg Hinkle + */ +public class MeasurementConverter { + +} diff --git a/modules/core/domain/src/main/java/org/rhq/core/server/MeasurementConverter.java b/modules/core/domain/src/main/java/org/rhq/core/server/MeasurementConverter.java new file mode 100644 index 0000000..1826a63 --- /dev/null +++ b/modules/core/domain/src/main/java/org/rhq/core/server/MeasurementConverter.java @@ -0,0 +1,359 @@ +/* + * 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.server; + + import java.text.DecimalFormat; + import java.text.NumberFormat; + import java.text.ParseException; + import java.util.HashSet; + import java.util.Set; + import java.util.regex.Matcher; + import java.util.regex.Pattern; + + import org.rhq.core.domain.measurement.MeasurementSchedule; + import org.rhq.core.domain.measurement.MeasurementUnits; + import org.rhq.core.domain.measurement.composite.MeasurementNumericValueAndUnits; + import org.rhq.core.domain.measurement.util.MeasurementConversionException; + +public class MeasurementConverter { + private static final int MAX_PRECISION_DIGITS = 4; + private static final String NULL_OR_NAN_FORMATTED_VALUE = "--no data available--"; + + + private static NumberFormat getDefaultNumberFormat() { + NumberFormat nf = NumberFormat.getNumberInstance(); + + nf.setMinimumFractionDigits(1); + nf.setMaximumFractionDigits(1); + + return nf; + } + + public static Double scale(MeasurementNumericValueAndUnits origin, MeasurementUnits targetUnits) + throws MeasurementConversionException { + MeasurementUnits originUnits = origin.getUnits(); + Double originValue = origin.getValue(); + + return originValue * MeasurementUnits.calculateOffset(originUnits, targetUnits); + } + + public static Double scale(Double origin, MeasurementUnits targetUnits) throws MeasurementConversionException { + boolean wasNegative = false; + if (origin < 0) { + wasNegative = true; + origin = -origin; + } + + MeasurementUnits baseUnit = targetUnits.getBaseUnits(); + MeasurementNumericValueAndUnits valueAndUnits = new MeasurementNumericValueAndUnits(origin, baseUnit); + + Double results = scale(valueAndUnits, targetUnits); + if (wasNegative) { + results = -results; + } + + return results; + } + + public static String format(String value, MeasurementUnits targetUnits) { + if (targetUnits == null) { + return value; + } else { + return value + targetUnits; + } + } + + /** + * Formats the given array of double values: determines the necessary precision such that when formatted, they are + * distinct and reasonable to look at. For example, for values { 1.45 1.46 1.47 1.48 1.49 } the desired precision is + * 2 - less precision loses significant digits, and more precision provides no added benefit. Max precision is + * bounded for presentation considerations. + * + * @param values the values to be formatted + * @param targetUnits the target units for the values + * @param bestFit whether or not to use a normalized scale for the family of units + * + * @return the formatted values + */ + public static String[] formatToSignificantPrecision(double[] values, MeasurementUnits targetUnits, boolean bestFit) { + if ((null == values) || (values.length == 0)) { + return null; + } + + MeasurementUnits originalUnits = targetUnits; + + /* + * in the overwhelming majority of cases, you're going to want to apply a bestFit + * to the passed data, but it's not required; it's perfectly possible to allow a + * list of doubles to be formatted without being fit, in which case the targetUnits + * will be part of the formatted display for each result element + */ + if (bestFit) { + // find bestFit units by taking the average + Double average = 0.0; + + for (int i = 0, sz = values.length; i < sz; i++) { + /* + * adding fractional amount iterative leads to greater + * error, but prevents overflow on large data sets + */ + average += (values[i] / sz); + } + + MeasurementNumericValueAndUnits fittedAverage = fit(average, targetUnits); + //noinspection UnnecessaryLocalVariable + MeasurementUnits fittedUnits = fittedAverage.getUnits(); + + /* + * and change the local reference to targetUnits, so that the same logic + * can be used both for the bestFit and non-bestFit computations + */ + targetUnits = fittedUnits; + } + + @SuppressWarnings("unused") + Set<String> existingStrings; // technically this *is* unused because + int precisionDigits = 0; + boolean scaleWithMorePrecision = true; + String[] results = new String[values.length]; + NumberFormat nf = getDefaultNumberFormat(); + + /* + * we scale at most to MAX_PRECISION_DIGITS to allow for presentation limits + * + * increase the maxPrecisionDigits in the while condition + * itself to ensure it gets done for every loop + */ + while (scaleWithMorePrecision && (++precisionDigits <= MAX_PRECISION_DIGITS)) { + /* + * make the assumption that we no longer need to scale beyond this iteration + */ + scaleWithMorePrecision = false; + + /* + * we need to record the uniquely formatted values so we can determine + */ + existingStrings = new HashSet<String>(); + nf.setMinimumFractionDigits(0); + nf.setMaximumFractionDigits(precisionDigits); + + Double[] scaledValues = new Double[values.length]; + + for (int i = 0; i < scaledValues.length; i++) { + /* + * For relative units apply the scale now, prior to the nf.format(), since we are not using format( Double...). + * Otherwise, apply standard multi-unit scaling. + */ + if (MeasurementUnits.Family.RELATIVE == originalUnits.getFamily()) { + scaledValues[i] = MeasurementUnits.scaleUp(values[i], originalUnits); + } else { + scaledValues[i] = scale(new MeasurementNumericValueAndUnits(values[i], originalUnits), targetUnits); + } + } + + for (int i = 0; i < results.length; i++) { + /* + * JUST get the formatted value, specifically DON'T tack on the formatted units yet; + * we do this to see how many units we'll have to scale to afterwards (outside this + * while loop) to make the array of values passed to us unique + */ + String formatted = nf.format(scaledValues[i]); + + /* + * check whether formatted value was in the set or not; if it was, we have to + * loop, but only if we're not not already at our maximum precision + */ + boolean wasNewElement = existingStrings.add(formatted); + + if ((!wasNewElement) && (precisionDigits < MAX_PRECISION_DIGITS)) { + scaleWithMorePrecision = true; + break; + } + + results[i] = formatted; + } + } + + /* + * we did the best we could in terms of trying to find a precision that adds the most + * uniqueness to the given set of values, NOW tack on the formatted value for the units + */ + for (int i = 0; i < results.length; i++) { + results[i] = format(results[i], targetUnits); + } + + return results; + } + + public static String format(Double value, MeasurementUnits targetUnits, boolean bestFit) { + return format(value, targetUnits, bestFit, null, null); + } + + public static String format(Double value, MeasurementUnits targetUnits, boolean bestFit, + Integer minimumFractionDigits, Integer maximumFractionDigits) { + if (value == null || Double.isNaN(value)) { + return NULL_OR_NAN_FORMATTED_VALUE; + } + if (bestFit) { + MeasurementNumericValueAndUnits valueAndUnits = fit(value, targetUnits); + + value = valueAndUnits.getValue(); + targetUnits = valueAndUnits.getUnits(); + } + + // apply relative scale at presentation time + if (MeasurementUnits.Family.RELATIVE == targetUnits.getFamily()) { + value = MeasurementUnits.scaleUp(value, targetUnits); + } + + NumberFormat numberFormat = getDefaultNumberFormat(); + if (null != minimumFractionDigits) { + numberFormat.setMinimumFractionDigits(minimumFractionDigits); + } + if (null != maximumFractionDigits) { + numberFormat.setMaximumFractionDigits(maximumFractionDigits); + } + String formatted = numberFormat.format(value); + + return format(formatted, targetUnits); + } + + public static String scaleAndFormat(Double origin, MeasurementSchedule targetSchedule, boolean bestFit) + throws MeasurementConversionException { + MeasurementUnits targetUnits = targetSchedule.getDefinition().getUnits(); + + return scaleAndFormat(origin, targetUnits, bestFit, null, null); + } + + public static String scaleAndFormat(Double origin, MeasurementUnits targetUnits, boolean bestFit) + throws MeasurementConversionException { + + return scaleAndFormat(origin, targetUnits, bestFit, null, null); + } + + public static String scaleAndFormat(Double origin, MeasurementUnits targetUnits, boolean bestFit, + Integer minimumFractionDigits, Integer maximumFractionDigits) throws MeasurementConversionException { + + MeasurementUnits baseUnits = targetUnits.getBaseUnits(); + MeasurementNumericValueAndUnits valueAndUnits = new MeasurementNumericValueAndUnits(origin, baseUnits); + Double scaledMagnitude = scale(valueAndUnits, targetUnits); + + return format(scaledMagnitude, targetUnits, bestFit); + } + + public static MeasurementNumericValueAndUnits fit(Double origin, MeasurementUnits units) { + return fit(origin, units, null, null); + } + + public static MeasurementNumericValueAndUnits fit(Double origin, MeasurementUnits units, MeasurementUnits lowUnits, + MeasurementUnits highUnits) { + + // work-around for the various Chart descendants not properly setting their units field; + if (null == units) { + return new MeasurementNumericValueAndUnits(origin, units); + } + + // by definition, absolutely specified units don't scale to anything + if ((MeasurementUnits.Family.ABSOLUTE == units.getFamily()) + || (MeasurementUnits.Family.DURATION == units.getFamily())) { + return new MeasurementNumericValueAndUnits(origin, units); + } + + // by definition relative-valued units are self-scaled (converted at formatting) + if (MeasurementUnits.Family.RELATIVE == units.getFamily()) { + return new MeasurementNumericValueAndUnits(origin, units); + } + + if (MeasurementUnits.Family.TEMPERATURE == units.getFamily()) { + return new MeasurementNumericValueAndUnits(origin, units); + } + + // if the magnitude is zero, the best-fit also will spin around forever since it won't change + if (Math.abs(origin) < 1e-9) { + return new MeasurementNumericValueAndUnits(origin, units); + } + + boolean wasNegative = false; + + if (origin < 0) { + wasNegative = true; + origin = -origin; + } + + MeasurementNumericValueAndUnits currentValueAndUnits; + MeasurementNumericValueAndUnits nextValueAndUnits = new MeasurementNumericValueAndUnits(origin, units); + + // first, make the value smaller if it's too big + int maxOrdinal = (highUnits != null) ? (highUnits.ordinal() + 1) : MeasurementUnits.values().length; + + do { + currentValueAndUnits = nextValueAndUnits; + + int nextOrdinal = currentValueAndUnits.getUnits().ordinal() + 1; + if (nextOrdinal == maxOrdinal) { + // we could theoretically get bigger, but we don't have any units to represent that + break; + } + + MeasurementUnits biggerUnits = MeasurementUnits.values()[nextOrdinal]; + if (biggerUnits.getFamily() != currentValueAndUnits.getUnits().getFamily()) { + // we're as big as we can get, break out of the loop so we can return + break; + } + + Double smallerValue = scale(currentValueAndUnits, biggerUnits); + + nextValueAndUnits = new MeasurementNumericValueAndUnits(smallerValue, biggerUnits); + } while (nextValueAndUnits.getValue() > 1.0); + + // next, make the value bigger if it's too small + int minOrdinal = (lowUnits != null) ? (lowUnits.ordinal() - 1) : -1; + + while (currentValueAndUnits.getValue() < 1.0) { + int nextOrdinal = currentValueAndUnits.getUnits().ordinal() - 1; + if (nextOrdinal == minOrdinal) { + // we could theoretically get smaller, but we don't have any units to represent that + break; + } + + MeasurementUnits smallerUnits = MeasurementUnits.values()[nextOrdinal]; + if (smallerUnits.getFamily() != currentValueAndUnits.getUnits().getFamily()) { + // we're as small as we can get, break out of the loop so we can return + break; + } + + Double biggerValue = scale(currentValueAndUnits, smallerUnits); + + nextValueAndUnits = new MeasurementNumericValueAndUnits(biggerValue, smallerUnits); + + currentValueAndUnits = nextValueAndUnits; + } + + if (wasNegative) { + return new MeasurementNumericValueAndUnits(-currentValueAndUnits.getValue(), currentValueAndUnits + .getUnits()); + } + + return currentValueAndUnits; + } +} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/MeasurementDataGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/MeasurementDataGWTService.java new file mode 100644 index 0000000..74efb76 --- /dev/null +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/MeasurementDataGWTService.java @@ -0,0 +1,26 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2010 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +package org.rhq.enterprise.gui.coregui.client.gwt; + +/** + * @author Greg Hinkle + */ +public interface MeasurementDataGWTService { + +} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/GraphListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/GraphListView.java new file mode 100644 index 0000000..c08ddfc --- /dev/null +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/GraphListView.java @@ -0,0 +1,26 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2010 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring; + +/** + * @author Greg Hinkle + */ +public class GraphListView { + +} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/SmallGraphView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/SmallGraphView.java new file mode 100644 index 0000000..32fe407 --- /dev/null +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/SmallGraphView.java @@ -0,0 +1,26 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2010 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring; + +/** + * @author Greg Hinkle + */ +public class SmallGraphView { + +} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/MeasurementDataGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/MeasurementDataGWTServiceImpl.java new file mode 100644 index 0000000..7b0a971 --- /dev/null +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/MeasurementDataGWTServiceImpl.java @@ -0,0 +1,26 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2010 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +package org.rhq.enterprise.gui.coregui.server.gwt; + +/** + * @author Greg Hinkle + */ +public class MeasurementDataGWTServiceImpl { + +} diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/rhq_logo_animated_100px.gif b/modules/enterprise/gui/coregui/src/main/webapp/images/rhq_logo_animated_100px.gif new file mode 100644 index 0000000..d477931 Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/rhq_logo_animated_100px.gif differ
rhq-commits@lists.fedorahosted.org