[rhq] modules/enterprise
by Simeon Pinder
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java | 83 ++++------
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/OperationGWTService.java | 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java | 55 ++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java | 53 +++++-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/OperationGWTServiceImpl.java | 10 -
5 files changed, 141 insertions(+), 66 deletions(-)
New commits:
commit fc50175d9159e90c52b8839283d7baba4323336e
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Mon Sep 13 20:46:27 2010 -0400
enable server side operations portlet.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java
index ce381ce..54647a1 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java
@@ -64,14 +64,15 @@ public class OperationsPortlet extends LocatableVLayout implements CustomSetting
private static final String TITLE = KEY;
private static String recentOperations = "Recent Operations";
private static String scheduledOperations = "Scheduled Operations";
- private boolean operationsRangeLastEnabled = false;
- private boolean operationsRangeNextEnabled = false;
- private int operationsRangeScheduled = -1;
- private int operationsRangeCompleted = -1;
+ public static String RANGE_DISABLED_MESSAGE = "(Results currently disabled. Change settings to enable results.)";
+ //TODO: change this to use the Smart GWT default value.
+ public static String RANGE_DISABLED_MESSAGE_DEFAULT = "No items to show.";
//ListGrids for operations
private LocatableListGrid recentOperationsGrid = null;
private LocatableListGrid scheduledOperationsGrid = null;
private DashboardPortlet storedPortlet = null;
+ private RecentOperationsDataSource dataSourceCompleted;
+ private ScheduledOperationsDataSource dataSourceScheduled;
public static String unlimited = "unlimited";
public static String defaultValue = unlimited;
public static boolean defaultEnabled = true;
@@ -83,17 +84,18 @@ public class OperationsPortlet extends LocatableVLayout implements CustomSetting
public OperationsPortlet(String locatorId) {
super(locatorId);
+ this.dataSourceCompleted = new RecentOperationsDataSource(this);
+ this.dataSourceScheduled = new ScheduledOperationsDataSource(this);
}
@Override
protected void onInit() {
super.onInit();
-
//set title for larger container
setTitle(TITLE);
this.recentOperationsGrid = new LocatableListGrid(recentOperations);
- recentOperationsGrid.setDataSource(new RecentOperationsDataSource());
+ recentOperationsGrid.setDataSource(getDataSourceCompleted());
recentOperationsGrid.setAutoFetchData(true);
recentOperationsGrid.setTitle(recentOperations);
recentOperationsGrid.setWidth100();
@@ -111,7 +113,7 @@ public class OperationsPortlet extends LocatableVLayout implements CustomSetting
// Add the list table as the top half of the view.
this.scheduledOperationsGrid = new LocatableListGrid(scheduledOperations);
- scheduledOperationsGrid.setDataSource(new ScheduledOperationsDataSource());
+ scheduledOperationsGrid.setDataSource(getDataSourceScheduled());
scheduledOperationsGrid.setAutoFetchData(true);
scheduledOperationsGrid.setTitle(scheduledOperations);
scheduledOperationsGrid.setWidth100();
@@ -140,42 +142,44 @@ public class OperationsPortlet extends LocatableVLayout implements CustomSetting
//retrieve and translate to int
String retrieved = property.getStringValue();
if (retrieved.equals(unlimited)) {
- setOperationsRangeCompleted(-1);
+ getDataSourceCompleted().setOperationsRangeCompleted(-1);
} else {
- setOperationsRangeCompleted(Integer.parseInt(retrieved));
+ getDataSourceCompleted().setOperationsRangeCompleted(Integer.parseInt(retrieved));
}
} else {//create setting
storedPortlet.getConfiguration().put(new PropertySimple(OPERATIONS_RANGE_COMPLETED, defaultValue));
- setOperationsRangeCompleted(-1);
+ getDataSourceCompleted().setOperationsRangeCompleted(-1);
}
+
property = storedPortlet.getConfiguration().getSimple(OPERATIONS_RANGE_SCHEDULED);
if ((property != null) && (property.getStringValue() != null)) {
//retrieve and translate to int
String retrieved = property.getStringValue();
if (retrieved.equals(unlimited)) {
- setOperationsRangeScheduled(-1);
+ getDataSourceScheduled().setOperationsRangeScheduled(-1);
} else {
- setOperationsRangeScheduled(Integer.parseInt(retrieved));
+ getDataSourceScheduled().setOperationsRangeScheduled(Integer.parseInt(retrieved));
}
} else {//create setting
storedPortlet.getConfiguration().put(new PropertySimple(OPERATIONS_RANGE_SCHEDULED, defaultValue));
- setOperationsRangeScheduled(-1);
+ getDataSourceScheduled().setOperationsRangeScheduled(-1);
}
//Checkbox settings property
property = storedPortlet.getConfiguration().getSimple(OPERATIONS_RANGE_SCHEDULED_ENABLED);
if ((property != null) && (property.getBooleanValue() != null)) {
- setOperationsRangeScheduleEnabled(property.getBooleanValue().booleanValue());
+ getDataSourceScheduled().setOperationsRangeScheduleEnabled(property.getBooleanValue().booleanValue());
} else {//create setting
storedPortlet.getConfiguration()
.put(new PropertySimple(OPERATIONS_RANGE_SCHEDULED_ENABLED, defaultEnabled));
- setOperationsRangeScheduleEnabled(defaultEnabled);
+ getDataSourceScheduled().setOperationsRangeScheduleEnabled(defaultEnabled);
}
property = storedPortlet.getConfiguration().getSimple(OPERATIONS_RANGE_COMPLETED_ENABLED);
if ((property != null) && (property.getBooleanValue() != null)) {
- setOperationsRangeScheduleEnabled(property.getBooleanValue().booleanValue());
+ getDataSourceCompleted().setOperationsRangeCompleteEnabled(property.getBooleanValue().booleanValue());
} else {//create setting
storedPortlet.getConfiguration()
.put(new PropertySimple(OPERATIONS_RANGE_COMPLETED_ENABLED, defaultEnabled));
+ getDataSourceCompleted().setOperationsRangeCompleteEnabled(defaultEnabled);
}
}
@@ -359,38 +363,6 @@ public class OperationsPortlet extends LocatableVLayout implements CustomSetting
}
}
- public boolean isOperationsRangeCompletedEnabled() {
- return operationsRangeLastEnabled;
- }
-
- public void setOperationsRangeCompleteEnabled(boolean operationsRangeLastEnabled) {
- this.operationsRangeLastEnabled = operationsRangeLastEnabled;
- }
-
- public boolean isOperationsRangeScheduleEnabled() {
- return operationsRangeNextEnabled;
- }
-
- public void setOperationsRangeScheduleEnabled(boolean operationsRangeNextEnabled) {
- this.operationsRangeNextEnabled = operationsRangeNextEnabled;
- }
-
- public int getOperationsRangeScheduled() {
- return operationsRangeScheduled;
- }
-
- public void setOperationsRangeScheduled(int operationsRangeScheduled) {
- this.operationsRangeScheduled = operationsRangeScheduled;
- }
-
- public int getOperationsRangeCompleted() {
- return operationsRangeCompleted;
- }
-
- public void setOperationsRangeCompleted(int operationsRangeCompleted) {
- this.operationsRangeCompleted = operationsRangeCompleted;
- }
-
/** Custom refresh operation as we cannot directly extend Table because it only
* contains one ListGrid while the OperationsPortlet displays two tables.
*/
@@ -424,4 +396,19 @@ public class OperationsPortlet extends LocatableVLayout implements CustomSetting
return definition;
}
+ public RecentOperationsDataSource getDataSourceCompleted() {
+ return this.dataSourceCompleted;
+ }
+
+ public ScheduledOperationsDataSource getDataSourceScheduled() {
+ return this.dataSourceScheduled;
+ }
+
+ public LocatableListGrid getCompletedOperationsGrid() {
+ return this.recentOperationsGrid;
+ }
+
+ public LocatableListGrid getScheduledOperationsGrid() {
+ return this.scheduledOperationsGrid;
+ }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/OperationGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/OperationGWTService.java
index 72f2fb9..b74efea 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/OperationGWTService.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/OperationGWTService.java
@@ -24,7 +24,6 @@ import com.google.gwt.user.client.rpc.RemoteService;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.criteria.GroupOperationHistoryCriteria;
-import org.rhq.core.domain.criteria.ResourceCriteria;
import org.rhq.core.domain.criteria.ResourceOperationHistoryCriteria;
import org.rhq.core.domain.operation.GroupOperationHistory;
import org.rhq.core.domain.operation.ResourceOperationHistory;
@@ -44,10 +43,9 @@ public interface OperationGWTService extends RemoteService {
PageList<GroupOperationHistory> findGroupOperationHistoriesByCriteria(GroupOperationHistoryCriteria criteria);
- List<DisambiguationReport<ResourceOperationLastCompletedComposite>> findRecentCompletedOperations(
- ResourceCriteria criteria);
+ List<DisambiguationReport<ResourceOperationLastCompletedComposite>> findRecentCompletedOperations(int pageSize);
- List<DisambiguationReport<ResourceOperationScheduleComposite>> findScheduledOperations(ResourceCriteria criteria);
+ List<DisambiguationReport<ResourceOperationScheduleComposite>> findScheduledOperations(int pageSize);
void scheduleResourceOperation(int resourceId, String operationName, Configuration parameters,
ExecutionSchedule schedule, String description, int timeout) throws RuntimeException;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java
index e53708c..2c02f25 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java
@@ -31,11 +31,12 @@ import com.smartgwt.client.types.DSDataFormat;
import com.smartgwt.client.types.DSProtocol;
import com.smartgwt.client.widgets.grid.ListGridRecord;
-import org.rhq.core.domain.criteria.ResourceCriteria;
import org.rhq.core.domain.operation.OperationRequestStatus;
import org.rhq.core.domain.operation.composite.ResourceOperationLastCompletedComposite;
import org.rhq.core.domain.resource.composite.DisambiguationReport;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.operations.OperationsPortlet;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.resource.disambiguation.ReportDecorator;
import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
@@ -52,10 +53,18 @@ public class RecentOperationsDataSource extends
public static final String operation = "operation";
public static final String time = "time";
public static final String status = "status";
+ private Portlet portlet;
+
+ //config attributes
+ private boolean operationsRangeLastEnabled = false;
+ private int operationsRangeCompleted = -1;
+ private boolean dataRangeDisabled = true;
+ public static String RANGE_DISABLED_MESSAGE = "(Results currently disabled. Change settings to enable results.)";
/** Build list of fields for the datasource and then adds them to it.
*/
- public RecentOperationsDataSource() {
+ public RecentOperationsDataSource(Portlet portlet) {
+ this.portlet = portlet;
setClientOnly(false);
setDataProtocol(DSProtocol.CLIENTCUSTOM);
setDataFormat(DSDataFormat.CUSTOM);
@@ -100,9 +109,30 @@ public class RecentOperationsDataSource extends
* @param response outgoing response
*/
public void executeFetch(final DSRequest request, final DSResponse response) {
+ int pageSize = -1;
+ //retrieve current portlet display settings
+ if ((this.portlet != null) && (this.portlet instanceof OperationsPortlet)) {
+ OperationsPortlet operationsPortlet = (OperationsPortlet) this.portlet;
+ //populate criteria with portlet preferences defined.
+ if (operationsPortlet != null) {
+ if (isOperationsRangeCompletedEnabled()) {
+ pageSize = getOperationsRangeCompleted();
+ operationsPortlet.getCompletedOperationsGrid().setEmptyMessage(
+ OperationsPortlet.RANGE_DISABLED_MESSAGE_DEFAULT);
+ } else {//show the component, return no results and indicate that you've disabled this display
+ pageSize = 0;
+ operationsPortlet.getCompletedOperationsGrid().setEmptyMessage(
+ OperationsPortlet.RANGE_DISABLED_MESSAGE);
+ response.setData(null);
+ response.setTotalRows(0);
+ //pass off for processing
+ processResponse(request.getRequestId(), response);
+ return;
+ }
+ }
+ }
- ResourceCriteria c = new ResourceCriteria();
- GWTServiceLookup.getOperationService().findRecentCompletedOperations(c,
+ GWTServiceLookup.getOperationService().findRecentCompletedOperations(pageSize,
new AsyncCallback<List<DisambiguationReport<ResourceOperationLastCompletedComposite>>>() {
public void onFailure(Throwable throwable) {
@@ -204,4 +234,21 @@ public class RecentOperationsDataSource extends
return record;
}
+
+ public boolean isOperationsRangeCompletedEnabled() {
+ return operationsRangeLastEnabled;
+ }
+
+ public void setOperationsRangeCompleteEnabled(boolean operationsRangeLastEnabled) {
+ this.operationsRangeLastEnabled = operationsRangeLastEnabled;
+ }
+
+ public int getOperationsRangeCompleted() {
+ return operationsRangeCompleted;
+ }
+
+ public void setOperationsRangeCompleted(int operationsRangeCompleted) {
+ this.operationsRangeCompleted = operationsRangeCompleted;
+ }
+
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java
index 4f58644..ebb1185 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java
@@ -30,10 +30,11 @@ import com.smartgwt.client.types.DSDataFormat;
import com.smartgwt.client.types.DSProtocol;
import com.smartgwt.client.widgets.grid.ListGridRecord;
-import org.rhq.core.domain.criteria.ResourceCriteria;
import org.rhq.core.domain.operation.composite.ResourceOperationScheduleComposite;
import org.rhq.core.domain.resource.composite.DisambiguationReport;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.operations.OperationsPortlet;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.resource.disambiguation.ReportDecorator;
import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
@@ -49,10 +50,15 @@ public class ScheduledOperationsDataSource extends
public static final String location = "location";
public static final String operation = "operation";
public static final String time = "time";
+ //config settings
+ private boolean operationsRangeNextEnabled = false;
+ private int operationsRangeScheduled = -1;
+ private Portlet portlet;
/** Build list of fields for the datasource and then adds them to it.
*/
- public ScheduledOperationsDataSource() {
+ public ScheduledOperationsDataSource(Portlet portlet) {
+ this.portlet = portlet;
setClientOnly(false);
setDataProtocol(DSProtocol.CLIENTCUSTOM);
setDataFormat(DSDataFormat.CUSTOM);
@@ -96,8 +102,30 @@ public class ScheduledOperationsDataSource extends
*/
public void executeFetch(final DSRequest request, final DSResponse response) {
- ResourceCriteria c = new ResourceCriteria();
- GWTServiceLookup.getOperationService().findScheduledOperations(c,
+ int pageSize = -1;
+ //retrieve current portlet display settings
+ if ((this.portlet != null) && (this.portlet instanceof OperationsPortlet)) {
+ OperationsPortlet operationsPortlet = (OperationsPortlet) this.portlet;
+ //populate criteria with portlet preferences defined.
+ if (operationsPortlet != null) {
+ if (isOperationsRangeScheduleEnabled()) {
+ pageSize = getOperationsRangeScheduled();
+ operationsPortlet.getScheduledOperationsGrid().setEmptyMessage(
+ OperationsPortlet.RANGE_DISABLED_MESSAGE_DEFAULT);
+ } else {//show the component, return no results and indicate that you've disabled this display
+ pageSize = 0;
+ operationsPortlet.getScheduledOperationsGrid().setEmptyMessage(
+ OperationsPortlet.RANGE_DISABLED_MESSAGE);
+ response.setData(null);
+ response.setTotalRows(0);
+ //pass off for processing
+ processResponse(request.getRequestId(), response);
+ return;
+ }
+ }
+ }
+
+ GWTServiceLookup.getOperationService().findScheduledOperations(pageSize,
new AsyncCallback<List<DisambiguationReport<ResourceOperationScheduleComposite>>>() {
public void onFailure(Throwable throwable) {
@@ -172,4 +200,21 @@ public class ScheduledOperationsDataSource extends
return record;
}
+
+ public boolean isOperationsRangeScheduleEnabled() {
+ return operationsRangeNextEnabled;
+ }
+
+ public void setOperationsRangeScheduleEnabled(boolean operationsRangeNextEnabled) {
+ this.operationsRangeNextEnabled = operationsRangeNextEnabled;
+ }
+
+ public int getOperationsRangeScheduled() {
+ return operationsRangeScheduled;
+ }
+
+ public void setOperationsRangeScheduled(int operationsRangeScheduled) {
+ this.operationsRangeScheduled = operationsRangeScheduled;
+ }
+
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/OperationGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/OperationGWTServiceImpl.java
index e44c086..a7f72ed 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/OperationGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/OperationGWTServiceImpl.java
@@ -24,7 +24,6 @@ import org.quartz.CronTrigger;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.criteria.GroupOperationHistoryCriteria;
-import org.rhq.core.domain.criteria.ResourceCriteria;
import org.rhq.core.domain.criteria.ResourceOperationHistoryCriteria;
import org.rhq.core.domain.operation.GroupOperationHistory;
import org.rhq.core.domain.operation.ResourceOperationHistory;
@@ -88,9 +87,9 @@ public class OperationGWTServiceImpl extends AbstractGWTServiceImpl implements O
*
*/
public List<DisambiguationReport<ResourceOperationLastCompletedComposite>> findRecentCompletedOperations(
- ResourceCriteria criteria) {
+ int pageSize) {
- PageControl pageControl = new PageControl(0, -1);
+ PageControl pageControl = new PageControl(0, pageSize);
PageList<ResourceOperationLastCompletedComposite> lastCompletedResourceOps = operationManager
.findRecentlyCompletedResourceOperations(getSessionSubject(), null, pageControl);
@@ -105,10 +104,9 @@ public class OperationGWTServiceImpl extends AbstractGWTServiceImpl implements O
/** Find scheduled operations, disambiguate them and return that list.
*
*/
- public List<DisambiguationReport<ResourceOperationScheduleComposite>> findScheduledOperations(
- ResourceCriteria criteria) {
+ public List<DisambiguationReport<ResourceOperationScheduleComposite>> findScheduledOperations(int pageSize) {
- PageControl pageControl = new PageControl(0, -1);
+ PageControl pageControl = new PageControl(0, pageSize);
PageList<ResourceOperationScheduleComposite> scheduledResourceOps = operationManager
.findCurrentlyScheduledResourceOperations(getSessionSubject(), pageControl);
13 years, 8 months
[rhq] modules/enterprise
by mazz
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java | 6 ++-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java | 8 ++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java | 9 +++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java | 17 +++++-----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java | 8 ++++
5 files changed, 38 insertions(+), 10 deletions(-)
New commits:
commit b9b50704a663d86eb0f961aa45c09cc2cc40063a
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Sep 13 17:23:27 2010 -0400
abstract out the save method since different SLSBs need to be called depending on the type of alert def (resource, group, or template)
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java
index 657fd5c..ce834da 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java
@@ -119,14 +119,14 @@ public abstract class AbstractAlertDefinitionsView extends TableSection {
AlertDefinition alertDef = getAlertDefinitionDataSource().copyValues(record);
SingleAlertDefinitionView singleAlertDefinitionView = new SingleAlertDefinitionView(this
- .extendLocatorId(alertDef.getName()), getResourceType(), alertDef);
+ .extendLocatorId(alertDef.getName()), this, alertDef);
return singleAlertDefinitionView;
}
@Override
public SingleAlertDefinitionView getDetailsView(int id) {
final SingleAlertDefinitionView singleAlertDefinitionView = new SingleAlertDefinitionView(this
- .extendLocatorId("singleAlertDefinitionView"), getResourceType());
+ .extendLocatorId("singleAlertDefinitionView"), this);
if (id == 0) {
// create an empty one with all defaults
@@ -176,4 +176,6 @@ public abstract class AbstractAlertDefinitionsView extends TableSection {
protected abstract void enableButtonPressed(ListGridRecord[] selection);
protected abstract void disableButtonPressed(ListGridRecord[] selection);
+
+ protected abstract void commitAlertDefinition(AlertDefinition alertDefinition);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java
index ec67b08..0c7cdff 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java
@@ -27,6 +27,7 @@ import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.util.SC;
import com.smartgwt.client.widgets.grid.ListGridRecord;
+import org.rhq.core.domain.alert.AlertDefinition;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.resource.group.ResourceGroup;
@@ -106,4 +107,11 @@ public class GroupAlertDefinitionsView extends AbstractAlertDefinitionsView {
}
SC.say(str);
}
+
+ @Override
+ protected void commitAlertDefinition(AlertDefinition alertDefinition) {
+ // TODO call into server SLSB to store alert def
+ // GroupAlertDefinitionManagerLocal groupAlertDefinitionManager = LookupUtil.getGroupAlertDefinitionManager();
+ // groupAlertDefinitionManager.updateGroupAlertDefinitions(subject, alertDef, true);
+ }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java
index 83a8629..da46f44 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java
@@ -27,6 +27,7 @@ import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.util.SC;
import com.smartgwt.client.widgets.grid.ListGridRecord;
+import org.rhq.core.domain.alert.AlertDefinition;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceType;
@@ -101,4 +102,12 @@ public class ResourceAlertDefinitionsView extends AbstractAlertDefinitionsView {
}
SC.say(str);
}
+
+ @Override
+ protected void commitAlertDefinition(AlertDefinition alertDefinition) {
+ System.out.println("=======================================>" + alertDefinition);
+ // TODO call into server SLSB to store alert def
+ // AlertDefinitionManagerLocal alertDefinitionManager = LookupUtil.getAlertDefinitionManager();
+ // alertDefinitionManager.updateAlertDefinition(subject, alertDef.getId(), alertDef, true);
+ }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java
index 7cf6356..bc7a8b0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java
@@ -30,8 +30,6 @@ import com.smartgwt.client.widgets.layout.HLayout;
import com.smartgwt.client.widgets.tab.Tab;
import org.rhq.core.domain.alert.AlertDefinition;
-import org.rhq.core.domain.resource.ResourceType;
-import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableButton;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableTab;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableTabSet;
@@ -54,11 +52,12 @@ public class SingleAlertDefinitionView extends LocatableVLayout {
private Button saveButton;
private Button cancelButton;
- public SingleAlertDefinitionView(String locatorId, ResourceType resourceType) {
- this(locatorId, resourceType, null);
+ public SingleAlertDefinitionView(String locatorId, AbstractAlertDefinitionsView alertDefView) {
+ this(locatorId, alertDefView, null);
}
- public SingleAlertDefinitionView(String locatorId, ResourceType resourceType, AlertDefinition alertDefinition) {
+ public SingleAlertDefinitionView(String locatorId, final AbstractAlertDefinitionsView alertDefView,
+ AlertDefinition alertDefinition) {
super(locatorId);
this.alertDefinition = alertDefinition;
@@ -71,7 +70,8 @@ public class SingleAlertDefinitionView extends LocatableVLayout {
generalPropertiesTab.setPane(generalProperties);
Tab conditionsTab = new LocatableTab(tabSet.extendLocatorId("Conditions"), "Conditions");
- conditions = new ConditionsAlertDefinitionForm(this.getLocatorId(), resourceType, alertDefinition);
+ conditions = new ConditionsAlertDefinitionForm(this.getLocatorId(), alertDefView.getResourceType(),
+ alertDefinition);
conditionsTab.setPane(conditions);
Tab notificationsTab = new LocatableTab(tabSet.extendLocatorId("Notifications"), "Notifications");
@@ -117,8 +117,9 @@ public class SingleAlertDefinitionView extends LocatableVLayout {
setAlertDefinition(getAlertDefinition()); // loads data into static fields
makeViewOnly();
- // TODO getAlertDefinition() should now have the new user data - commit it to DB
- CoreGUI.refresh();
+ alertDefView.commitAlertDefinition(getAlertDefinition());
+
+ alertDefView.refresh();
}
});
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java
index d5a5e14..3ef3dfe 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java
@@ -27,6 +27,7 @@ import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.util.SC;
import com.smartgwt.client.widgets.grid.ListGridRecord;
+import org.rhq.core.domain.alert.AlertDefinition;
import org.rhq.core.domain.resource.ResourceType;
/**
@@ -105,4 +106,11 @@ public class TemplateAlertDefinitionsView extends AbstractAlertDefinitionsView {
}
SC.say(str);
}
+
+ @Override
+ protected void commitAlertDefinition(AlertDefinition alertDefinition) {
+ // TODO call into server SLSB to store alert def
+ // AlertTemplateManagerLocal alertTemplateManager = LookupUtil.getAlertTemplateManager();
+ // alertTemplateManager.updateAlertTemplate(subject, alertDef, true);
+ }
}
13 years, 8 months
[rhq] 2 commits - modules/core modules/enterprise
by mazz
modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertCondition.java | 49 ++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java | 8
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java | 224 +++++++---
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java | 2
4 files changed, 220 insertions(+), 63 deletions(-)
New commits:
commit f1599977fb315f35391f8b8c54babc40c5b062ea
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Sep 13 17:08:19 2010 -0400
builds the conditions object and sets the new condition in the alert def
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java
index 78261a3..7b85eae 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java
@@ -111,7 +111,13 @@ public class ConditionsEditor extends LocatableVLayout {
});
NewConditionEditor newConditionEditor = new NewConditionEditor(extendLocatorId("newConditionEditor"),
- conditions, ConditionsEditor.this.resourceType, winModal);
+ conditions, ConditionsEditor.this.resourceType, new Runnable() {
+ @Override
+ public void run() {
+ winModal.markForDestroy();
+ table.refresh();
+ }
+ });
winModal.addItem(newConditionEditor);
winModal.show();
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java
index 7922824..bd20b0a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java
@@ -24,13 +24,11 @@
package org.rhq.enterprise.gui.coregui.client.alert.definitions;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.Set;
import com.smartgwt.client.types.Alignment;
-import com.smartgwt.client.widgets.Window;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.FormItemIfFunction;
import com.smartgwt.client.widgets.form.fields.ButtonItem;
@@ -46,10 +44,12 @@ import org.rhq.core.domain.alert.AlertCondition;
import org.rhq.core.domain.alert.AlertConditionCategory;
import org.rhq.core.domain.event.EventSeverity;
import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.core.domain.measurement.DataType;
import org.rhq.core.domain.measurement.MeasurementDefinition;
import org.rhq.core.domain.operation.OperationDefinition;
import org.rhq.core.domain.operation.OperationRequestStatus;
import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
/**
@@ -57,42 +57,49 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
*/
public class NewConditionEditor extends LocatableDynamicForm {
+ private static final String AVAILABILITY_ITEMNAME = "availability";
+ private static final String THRESHOLD_METRIC_ITEMNAME = "thresholdMetric";
+ private static final String THRESHOLD_COMPARATOR_ITEMNAME = "thresholdComparator";
+ private static final String THRESHOLD_ABSVALUE_ITEMNAME = "metricAbsoluteValue";
+ private static final String BASELINE_METRIC_ITEMNAME = "baselineMetric";
+ private static final String BASELINE_COMPARATOR_ITEMNAME = "baselineComparator";
+ private static final String BASELINE_PERCENTAGE_ITEMNAME = "baselinePercentage";
+ private static final String BASELINE_SELECTION_ITEMNAME = "baselineSelection";
+ private static final String CHANGE_METRIC_ITEMNAME = "changeMetric";
+ private static final String TRAIT_METRIC_ITEMNAME = "trait";
+ private static final String OPERATION_NAME_ITEMNAME = "operation";
+ private static final String OPERATION_RESULTS_ITEMNAME = "operationResults";
+ private static final String EVENT_SEVERITY_ITEMNAME = "eventSeverity";
+ private static final String EVENT_REGEX_ITEMNAME = "eventRegex";
+
private SelectItem conditionTypeSelectItem;
private HashSet<AlertCondition> conditions; // the new condition we create goes into this set
- private Collection<String> metrics;
- private Collection<String> traits;
- private Collection<String> operations;
- private boolean supportsEvents;
- private Window parentWindow; // where this form is located; after form is OK'ed, this window will be destroyed
+ private boolean supportsMetrics = false;
+ private boolean supportsTraits = false;
+ private boolean supportsOperations = false;
+ private boolean supportsEvents = false;
+ private Runnable okFunction; // this is called after the OK button is pressed and a new condition is saved
+ private ResourceType resourceType;
- public NewConditionEditor(String locatorId, HashSet<AlertCondition> conditions, ResourceType rtype, Window parent) {
+ public NewConditionEditor(String locatorId, HashSet<AlertCondition> conditions, ResourceType rtype, Runnable okFunc) {
super(locatorId);
this.conditions = conditions;
- this.parentWindow = parent;
+ this.okFunction = okFunc;
+ this.resourceType = rtype;
this.supportsEvents = (rtype.getEventDefinitions() != null & rtype.getEventDefinitions().size() > 0);
Set<MeasurementDefinition> metricDefinitions = rtype.getMetricDefinitions();
- Set<OperationDefinition> operationDefinitions = rtype.getOperationDefinitions();
- if (metricDefinitions == null || metricDefinitions.size() == 0) {
- this.metrics = null;
- this.traits = null;
- } else {
+ if (metricDefinitions != null && metricDefinitions.size() > 0) {
for (MeasurementDefinition measurementDefinition : metricDefinitions) {
switch (measurementDefinition.getDataType()) {
case MEASUREMENT: {
- if (this.metrics == null) {
- this.metrics = new ArrayList<String>();
- }
- this.metrics.add(measurementDefinition.getDisplayName());
+ this.supportsMetrics = true;
break;
}
case TRAIT: {
- if (this.traits == null) {
- this.traits = new ArrayList<String>();
- }
- this.traits.add(measurementDefinition.getDisplayName());
+ this.supportsTraits = true;
break;
}
default: {
@@ -102,13 +109,9 @@ public class NewConditionEditor extends LocatableDynamicForm {
}
}
- if (operationDefinitions == null || operationDefinitions.size() == 0) {
- this.operations = null;
- } else {
- this.operations = new ArrayList<String>(operationDefinitions.size());
- for (OperationDefinition operationDefinition : operationDefinitions) {
- this.operations.add(operationDefinition.getDisplayName());
- }
+ Set<OperationDefinition> operationDefinitions = rtype.getOperationDefinitions();
+ if (operationDefinitions != null && operationDefinitions.size() > 0) {
+ this.supportsOperations = true;
}
}
@@ -121,15 +124,15 @@ public class NewConditionEditor extends LocatableDynamicForm {
conditionTypeSelectItem = new SelectItem("conditionType", "Condition Type");
LinkedHashMap<String, String> condTypes = new LinkedHashMap<String, String>(7);
condTypes.put(AlertConditionCategory.AVAILABILITY.name(), "Availability Change");
- if (metrics != null) {
+ if (supportsMetrics) {
condTypes.put(AlertConditionCategory.THRESHOLD.name(), "Measurement Absolute Value Threshold");
condTypes.put(AlertConditionCategory.BASELINE.name(), "Measurement Baseline Threshold");
condTypes.put(AlertConditionCategory.CHANGE.name(), "Measurement Value Change");
}
- if (traits != null) {
+ if (supportsTraits) {
condTypes.put(AlertConditionCategory.TRAIT.name(), "Trait Value Change");
}
- if (operations != null) {
+ if (supportsOperations) {
condTypes.put(AlertConditionCategory.CONTROL.name(), "Operation Execution");
}
if (supportsEvents) {
@@ -152,8 +155,8 @@ public class NewConditionEditor extends LocatableDynamicForm {
@Override
public void onClick(ClickEvent event) {
if (validate(false)) {
- // TODO
- NewConditionEditor.this.parentWindow.markForDestroy();
+ saveNewCondition();
+ okFunction.run();
}
}
});
@@ -162,15 +165,15 @@ public class NewConditionEditor extends LocatableDynamicForm {
formItems.add(conditionTypeSelectItem);
formItems.add(spacer);
formItems.addAll(buildAvailabilityChangeFormItems());
- if (metrics != null) {
+ if (supportsMetrics) {
formItems.addAll(buildMetricThresholdFormItems());
formItems.addAll(buildMetricBaselineFormItems());
formItems.addAll(buildMetricChangeFormItems());
}
- if (traits != null) {
+ if (supportsTraits) {
formItems.addAll(buildTraitChangeFormItems());
}
- if (operations != null) {
+ if (supportsOperations) {
formItems.addAll(buildOperationFormItems());
}
if (supportsEvents) {
@@ -181,6 +184,90 @@ public class NewConditionEditor extends LocatableDynamicForm {
setFields(formItems.toArray(new FormItem[formItems.size()]));
};
+ private void saveNewCondition() {
+ AlertConditionCategory category;
+ category = AlertConditionCategory.valueOf(conditionTypeSelectItem.getValue().toString());
+
+ AlertCondition newCondition = new AlertCondition();
+ newCondition.setCategory(category);
+
+ switch (category) {
+ case AVAILABILITY: {
+ newCondition.setName(null);
+ newCondition.setComparator(null);
+ newCondition.setThreshold(null);
+ newCondition.setOption(getValueAsString(AVAILABILITY_ITEMNAME));
+ newCondition.setMeasurementDefinition(null);
+ break;
+ }
+
+ case THRESHOLD: {
+ MeasurementDefinition measDef = getMeasurementDefinition(getValueAsString(THRESHOLD_METRIC_ITEMNAME));
+ newCondition.setName(measDef.getDisplayName()); // TODO should not use display name
+ newCondition.setThreshold(Double.valueOf(getValueAsString(THRESHOLD_ABSVALUE_ITEMNAME)));
+ newCondition.setComparator(getValueAsString(THRESHOLD_COMPARATOR_ITEMNAME));
+ newCondition.setOption(null);
+ newCondition.setMeasurementDefinition(measDef);
+ break;
+ }
+
+ case BASELINE: {
+ MeasurementDefinition measDef = getMeasurementDefinition(getValueAsString(BASELINE_METRIC_ITEMNAME));
+ newCondition.setName(measDef.getDisplayName()); // TODO should not use display name
+ newCondition.setThreshold(Double.valueOf(getValueAsString(BASELINE_PERCENTAGE_ITEMNAME)) / 100.0);
+ newCondition.setComparator(getValueAsString(BASELINE_COMPARATOR_ITEMNAME));
+ newCondition.setOption(null);
+ newCondition.setMeasurementDefinition(measDef);
+ break;
+ }
+
+ case CHANGE: {
+ MeasurementDefinition measDef = getMeasurementDefinition(getValueAsString(CHANGE_METRIC_ITEMNAME));
+ newCondition.setName(measDef.getDisplayName()); // TODO should not use display name
+ newCondition.setComparator(null);
+ newCondition.setThreshold(null);
+ newCondition.setOption(null);
+ newCondition.setMeasurementDefinition(measDef);
+ break;
+ }
+
+ case TRAIT: {
+ MeasurementDefinition measDef = getMeasurementDefinition(getValueAsString(TRAIT_METRIC_ITEMNAME));
+ newCondition.setName(measDef.getDisplayName()); // TODO should not use display name
+ newCondition.setComparator(null);
+ newCondition.setThreshold(null);
+ newCondition.setOption(null);
+ newCondition.setMeasurementDefinition(measDef);
+ break;
+ }
+
+ case CONTROL: {
+ newCondition.setName(getValueAsString(OPERATION_NAME_ITEMNAME));
+ newCondition.setComparator(null);
+ newCondition.setThreshold(null);
+ newCondition.setOption(getValueAsString(OPERATION_RESULTS_ITEMNAME));
+ newCondition.setMeasurementDefinition(null);
+ break;
+ }
+
+ case EVENT: {
+ newCondition.setName(getValueAsString(EVENT_SEVERITY_ITEMNAME));
+ newCondition.setComparator(null);
+ newCondition.setThreshold(null);
+ newCondition.setOption(getValueAsString(EVENT_REGEX_ITEMNAME));
+ newCondition.setMeasurementDefinition(null);
+ break;
+ }
+
+ default: {
+ CoreGUI.getErrorHandler().handleError("Invalid alert category selected: " + category); // should never happen
+ break;
+ }
+ }
+
+ this.conditions.add(newCondition);
+ }
+
private ArrayList<FormItem> buildMetricThresholdFormItems() {
ArrayList<FormItem> formItems = new ArrayList<FormItem>();
@@ -190,10 +277,9 @@ public class NewConditionEditor extends LocatableDynamicForm {
StaticTextItem helpItem = buildHelpTextItem("thresholdHelp", helpStr, ifFunc);
formItems.add(helpItem);
- formItems.add(buildMetricDropDownMenu("thresholdMetric", ifFunc));
- formItems.add(buildComparatorDropDownMenu("thresholdComparator", ifFunc));
-
- TextItem absoluteValue = new TextItem("metricAbsoluteValue", "Metric Value");
+ formItems.add(buildMetricDropDownMenu(THRESHOLD_METRIC_ITEMNAME, ifFunc));
+ formItems.add(buildComparatorDropDownMenu(THRESHOLD_COMPARATOR_ITEMNAME, ifFunc));
+ TextItem absoluteValue = new TextItem(THRESHOLD_ABSVALUE_ITEMNAME, "Metric Value");
absoluteValue.setWrapTitle(false);
absoluteValue.setRequired(true);
absoluteValue
@@ -214,10 +300,10 @@ public class NewConditionEditor extends LocatableDynamicForm {
StaticTextItem helpItem = buildHelpTextItem("baselineHelp", helpStr, ifFunc);
formItems.add(helpItem);
- formItems.add(buildMetricDropDownMenu("baselineMetric", ifFunc));
- formItems.add(buildComparatorDropDownMenu("baselineComparator", ifFunc));
+ formItems.add(buildMetricDropDownMenu(BASELINE_METRIC_ITEMNAME, ifFunc));
+ formItems.add(buildComparatorDropDownMenu(BASELINE_COMPARATOR_ITEMNAME, ifFunc));
- TextItem baselinePercentage = new TextItem("baselinePercentage", "Baseline Percentage");
+ TextItem baselinePercentage = new TextItem(BASELINE_PERCENTAGE_ITEMNAME, "Baseline Percentage");
baselinePercentage.setWrapTitle(false);
baselinePercentage.setRequired(true);
baselinePercentage
@@ -225,13 +311,13 @@ public class NewConditionEditor extends LocatableDynamicForm {
baselinePercentage.setShowIfCondition(ifFunc);
formItems.add(baselinePercentage);
- SelectItem baselineSelection = new SelectItem("baselineSelection", "Baseline");
+ SelectItem baselineSelection = new SelectItem(BASELINE_SELECTION_ITEMNAME, "Baseline");
LinkedHashMap<String, String> baselines = new LinkedHashMap<String, String>(3);
- baselines.put("min", "Minimum"); // title should have the current value of the min baseline
- baselines.put("avg", "Baseline"); // title should have the current value of the avg baseline
- baselines.put("max", "Maximum"); // title should have the current value of the max baseline
+ baselines.put("min", "Minimum"); // TODO can we have the current value of the min baseline
+ baselines.put("mean", "Average"); // TODO can we have the current value of the avg baseline
+ baselines.put("max", "Maximum"); // TODO can we have the current value of the max baseline
baselineSelection.setValueMap(baselines);
- baselineSelection.setDefaultValue("avg");
+ baselineSelection.setDefaultValue("mean");
baselineSelection.setWrapTitle(false);
baselineSelection.setWidth("*");
baselineSelection.setRedrawOnChange(true);
@@ -250,7 +336,7 @@ public class NewConditionEditor extends LocatableDynamicForm {
StaticTextItem helpItem = buildHelpTextItem("changeMetricHelp", helpStr, ifFunc);
formItems.add(helpItem);
- formItems.add(buildMetricDropDownMenu("changeMetric", ifFunc));
+ formItems.add(buildMetricDropDownMenu(CHANGE_METRIC_ITEMNAME, ifFunc));
return formItems;
}
@@ -265,11 +351,13 @@ public class NewConditionEditor extends LocatableDynamicForm {
formItems.add(helpItem);
LinkedHashMap<String, String> traitsMap = new LinkedHashMap<String, String>();
- for (String traitName : this.traits) {
- traitsMap.put(traitName, traitName);
+ for (MeasurementDefinition def : this.resourceType.getMetricDefinitions()) {
+ if (def.getDataType() == DataType.TRAIT) {
+ traitsMap.put(def.getName(), def.getDisplayName());
+ }
}
- SelectItem traitSelection = new SelectItem("trait", "Trait");
+ SelectItem traitSelection = new SelectItem(TRAIT_METRIC_ITEMNAME, "Trait");
traitSelection.setValueMap(traitsMap);
traitSelection.setDefaultValue(traitsMap.keySet().iterator().next()); // just use the first one
traitSelection.setWidth("*");
@@ -289,7 +377,7 @@ public class NewConditionEditor extends LocatableDynamicForm {
StaticTextItem helpItem = buildHelpTextItem("availabilityHelp", helpStr, ifFunc);
formItems.add(helpItem);
- SelectItem selection = new SelectItem("availability", "Availability");
+ SelectItem selection = new SelectItem(AVAILABILITY_ITEMNAME, "Availability");
LinkedHashMap<String, String> avails = new LinkedHashMap<String, String>(2);
avails.put(AvailabilityType.UP.name(), "Goes UP");
avails.put(AvailabilityType.DOWN.name(), "Goes DOWN");
@@ -311,11 +399,11 @@ public class NewConditionEditor extends LocatableDynamicForm {
formItems.add(helpItem);
LinkedHashMap<String, String> ops = new LinkedHashMap<String, String>();
- for (String opName : this.operations) {
- ops.put(opName, opName);
+ for (OperationDefinition opDef : this.resourceType.getOperationDefinitions()) {
+ ops.put(opDef.getName(), opDef.getDisplayName());
}
- SelectItem opSelection = new SelectItem("operation", "Operation");
+ SelectItem opSelection = new SelectItem(OPERATION_NAME_ITEMNAME, "Operation");
opSelection.setValueMap(ops);
opSelection.setDefaultValue(ops.keySet().iterator().next()); // just use the first one
opSelection.setWidth("*");
@@ -323,7 +411,7 @@ public class NewConditionEditor extends LocatableDynamicForm {
opSelection.setShowIfCondition(ifFunc);
formItems.add(opSelection);
- SelectItem opResultsSelection = new SelectItem("operationResults", "Operation Status");
+ SelectItem opResultsSelection = new SelectItem(OPERATION_RESULTS_ITEMNAME, "Operation Status");
LinkedHashMap<String, String> operationStatuses = new LinkedHashMap<String, String>(4);
operationStatuses.put(OperationRequestStatus.INPROGRESS.name(), OperationRequestStatus.INPROGRESS.name());
operationStatuses.put(OperationRequestStatus.SUCCESS.name(), OperationRequestStatus.SUCCESS.name());
@@ -347,7 +435,7 @@ public class NewConditionEditor extends LocatableDynamicForm {
StaticTextItem helpItem = buildHelpTextItem("eventHelp", helpStr, ifFunc);
formItems.add(helpItem);
- SelectItem eventSeveritySelection = new SelectItem("eventSeverity", "Event Severity");
+ SelectItem eventSeveritySelection = new SelectItem(EVENT_SEVERITY_ITEMNAME, "Event Severity");
LinkedHashMap<String, String> severities = new LinkedHashMap<String, String>(5);
severities.put(EventSeverity.DEBUG.name(), EventSeverity.DEBUG.name());
severities.put(EventSeverity.INFO.name(), EventSeverity.INFO.name());
@@ -360,7 +448,7 @@ public class NewConditionEditor extends LocatableDynamicForm {
eventSeveritySelection.setShowIfCondition(ifFunc);
formItems.add(eventSeveritySelection);
- TextItem eventRegex = new TextItem("eventRegex", "Regular Expression");
+ TextItem eventRegex = new TextItem(EVENT_REGEX_ITEMNAME, "Regular Expression");
eventRegex.setRequired(false);
eventRegex
.setTooltip("If specified, this is a regular expression that must match a collected event message in order to trigger the condition.");
@@ -374,8 +462,10 @@ public class NewConditionEditor extends LocatableDynamicForm {
private SelectItem buildMetricDropDownMenu(String itemName, FormItemIfFunction ifFunc) {
LinkedHashMap<String, String> metricsMap = new LinkedHashMap<String, String>();
- for (String metricName : this.metrics) {
- metricsMap.put(metricName, metricName);
+ for (MeasurementDefinition def : this.resourceType.getMetricDefinitions()) {
+ if (def.getDataType() == DataType.MEASUREMENT) {
+ metricsMap.put(def.getName(), def.getDisplayName());
+ }
}
SelectItem metricSelection = new SelectItem(itemName, "Metric");
@@ -413,6 +503,16 @@ public class NewConditionEditor extends LocatableDynamicForm {
return help;
}
+ private MeasurementDefinition getMeasurementDefinition(String metricName) {
+ for (MeasurementDefinition def : this.resourceType.getMetricDefinitions()) {
+ if (metricName.equals(def.getName())) {
+ return def;
+ }
+ }
+ CoreGUI.getErrorHandler().handleError("Should have found metric definition - something is wrong");
+ return null;
+ }
+
private class ShowIfCategoryFunction implements FormItemIfFunction {
private final AlertConditionCategory category;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java
index 8269a8d..7cf6356 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java
@@ -31,6 +31,7 @@ import com.smartgwt.client.widgets.tab.Tab;
import org.rhq.core.domain.alert.AlertDefinition;
import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableButton;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableTab;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableTabSet;
@@ -117,6 +118,7 @@ public class SingleAlertDefinitionView extends LocatableVLayout {
makeViewOnly();
// TODO getAlertDefinition() should now have the new user data - commit it to DB
+ CoreGUI.refresh();
}
});
commit d0a76a4f3628d280bd861237869933dc126e235b
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Sep 13 15:23:41 2010 -0400
add javadoc omments to AlertCondition so its clear what the different fields should be based on the different category semantics
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertCondition.java b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertCondition.java
index b54d58e..3218d9d 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertCondition.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertCondition.java
@@ -47,7 +47,9 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlTransient;
+import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.domain.measurement.MeasurementDefinition;
+import org.rhq.core.domain.operation.OperationRequestStatus;
/**
* An alert condition (e.g. ActiveThreads > 100) as configured in an alert definition.
@@ -366,6 +368,13 @@ public class AlertCondition implements Serializable {
this.category = category;
}
+ /**
+ * Identifies the measurement definition of the metric that is to be compared when determining
+ * if the condition is true. This is null if the condition category is not a metric-related one
+ * (metric related categories are THRESHOLD, TRAIT, BASELINE and CHANGE; others are not).
+ *
+ * @return measurement definition or null
+ */
public MeasurementDefinition getMeasurementDefinition() {
return this.measurementDefinition;
}
@@ -374,6 +383,19 @@ public class AlertCondition implements Serializable {
this.measurementDefinition = measurementDefinition;
}
+ /**
+ * The name of the condition whose semantics are different based on this condition's category:
+ *
+ * AVAILABILITY: n/a (null)
+ * THRESHOLD: the name of the metric (TODO: today its the display name, very bad for i18n purposes)
+ * BASELINE: the name of the metric (TODO: today its the display name, very bad for i18n purposes)
+ * CHANGE: the name of the metric (TODO: today its the display name, very bad for i18n purposes)
+ * TRAIT: the name of the trait (TODO: today its the display name, very bad for i18n purposes)
+ * CONTROL: the name of the operation (not its display name)
+ * EVENT: the level of event to compare with (DEBUG, INFO, WARN, ERROR, FATAL)
+ *
+ * @return additional information about the condition
+ */
public String getName() {
return this.name;
}
@@ -382,6 +404,14 @@ public class AlertCondition implements Serializable {
this.name = name;
}
+ /**
+ * One of these comparators: "<", ">" or "=".
+ * This will be null if the condition does not compare values. Only THRESHOLD
+ * and BASELINE condition categories use comparators; other types of conditions
+ * will return <code>null</code>.
+ *
+ * @return comparator string
+ */
public String getComparator() {
return this.comparator;
}
@@ -390,6 +420,13 @@ public class AlertCondition implements Serializable {
this.comparator = comparator;
}
+ /**
+ * Returns the threshold to compare a measurement value to see if the condition is true.
+ * This is only valid for conditions of category THRESHOLD and BASELINE. All other
+ * condition types will return <code>null</code>.
+ *
+ * @return threshold value or null
+ */
public Double getThreshold() {
return this.threshold;
}
@@ -398,6 +435,18 @@ public class AlertCondition implements Serializable {
this.threshold = threshold;
}
+ /**
+ * The option string is optional and its semantics differ based on the category of this condition:
+ * AVAILABILITY: the {@link AvailabilityType} to trigger off of (DOWN or UP)
+ * THRESHOLD: n/a
+ * BASELINE: one of "min", "max" or "mean" - indicates what the threshold is compared to (min/max/avg baseline value)
+ * CHANGE: n/a
+ * TRAIT: n/a
+ * CONTROL: the {@link OperationRequestStatus} name (SUCCESS, FAILURE, etc).
+ * EVENT: the regular expression of the message to match (which may be empty string if not specified)
+ *
+ * @return additional information about the condition
+ */
public String getOption() {
return this.option;
}
13 years, 8 months
[rhq] modules/enterprise
by mazz
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java | 7
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsAlertDefinitionForm.java | 11
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java | 14
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java | 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java | 147 +++++++---
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java | 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java | 10
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java | 5
8 files changed, 162 insertions(+), 44 deletions(-)
New commits:
commit 4752d410687ff02f7c04e3f62a552f3f7e55bb06
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Sep 13 14:17:48 2010 -0400
get new condition editor to show metrics, operations, etc
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java
index 23bc0cc..657fd5c 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java
@@ -29,6 +29,7 @@ import org.rhq.core.domain.alert.AlertDefinition;
import org.rhq.core.domain.alert.AlertPriority;
import org.rhq.core.domain.alert.BooleanExpression;
import org.rhq.core.domain.criteria.AlertDefinitionCriteria;
+import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.components.table.TableAction;
@@ -118,14 +119,14 @@ public abstract class AbstractAlertDefinitionsView extends TableSection {
AlertDefinition alertDef = getAlertDefinitionDataSource().copyValues(record);
SingleAlertDefinitionView singleAlertDefinitionView = new SingleAlertDefinitionView(this
- .extendLocatorId(alertDef.getName()), alertDef);
+ .extendLocatorId(alertDef.getName()), getResourceType(), alertDef);
return singleAlertDefinitionView;
}
@Override
public SingleAlertDefinitionView getDetailsView(int id) {
final SingleAlertDefinitionView singleAlertDefinitionView = new SingleAlertDefinitionView(this
- .extendLocatorId("Empty"));
+ .extendLocatorId("singleAlertDefinitionView"), getResourceType());
if (id == 0) {
// create an empty one with all defaults
@@ -160,6 +161,8 @@ public abstract class AbstractAlertDefinitionsView extends TableSection {
return singleAlertDefinitionView;
}
+ protected abstract ResourceType getResourceType();
+
protected abstract Criteria getCriteria();
protected abstract AbstractAlertDefinitionsDataSource getAlertDefinitionDataSource();
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsAlertDefinitionForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsAlertDefinitionForm.java
index e1cb68f..182173a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsAlertDefinitionForm.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsAlertDefinitionForm.java
@@ -32,6 +32,7 @@ import com.smartgwt.client.widgets.form.fields.StaticTextItem;
import org.rhq.core.domain.alert.AlertCondition;
import org.rhq.core.domain.alert.AlertDefinition;
import org.rhq.core.domain.alert.BooleanExpression;
+import org.rhq.core.domain.resource.ResourceType;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
@@ -40,6 +41,7 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
*/
public class ConditionsAlertDefinitionForm extends LocatableVLayout implements EditAlertDefinitionForm {
+ private final ResourceType resourceType;
private AlertDefinition alertDefinition;
private SelectItem conditionExpression;
@@ -49,12 +51,13 @@ public class ConditionsAlertDefinitionForm extends LocatableVLayout implements E
private boolean formBuilt = false;
- public ConditionsAlertDefinitionForm(String locatorId) {
- this(locatorId, null);
+ public ConditionsAlertDefinitionForm(String locatorId, ResourceType resourceType) {
+ this(locatorId, resourceType, null);
}
- public ConditionsAlertDefinitionForm(String locatorId, AlertDefinition alertDefinition) {
+ public ConditionsAlertDefinitionForm(String locatorId, ResourceType resourceType, AlertDefinition alertDefinition) {
super(locatorId);
+ this.resourceType = resourceType;
this.alertDefinition = alertDefinition;
}
@@ -146,7 +149,7 @@ public class ConditionsAlertDefinitionForm extends LocatableVLayout implements E
conditionExpressionForm.setFields(conditionExpression, conditionExpressionStatic);
- conditionsEditor = new ConditionsEditor(this.extendLocatorId("conditionsEditor"), null);
+ conditionsEditor = new ConditionsEditor(this.extendLocatorId("conditionsEditor"), resourceType, null);
setMembers(conditionExpressionForm, conditionsEditor);
formBuilt = true;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java
index 1742ec0..78261a3 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java
@@ -29,12 +29,14 @@ import java.util.Set;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
import com.smartgwt.client.data.fields.DataSourceTextField;
+import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.widgets.Window;
import com.smartgwt.client.widgets.events.CloseClickHandler;
import com.smartgwt.client.widgets.events.CloseClientEvent;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.alert.AlertCondition;
+import org.rhq.core.domain.resource.ResourceType;
import org.rhq.enterprise.gui.coregui.client.alert.AlertFormatUtility;
import org.rhq.enterprise.gui.coregui.client.components.table.Table;
import org.rhq.enterprise.gui.coregui.client.components.table.TableAction;
@@ -47,11 +49,13 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
*/
public class ConditionsEditor extends LocatableVLayout {
+ private ResourceType resourceType;
private HashSet<AlertCondition> conditions;
private Table table;
- public ConditionsEditor(String locatorId, HashSet<AlertCondition> conditions) {
+ public ConditionsEditor(String locatorId, ResourceType resourceType, HashSet<AlertCondition> conditions) {
super(locatorId);
+ this.resourceType = resourceType;
setConditions(conditions);
}
@@ -90,20 +94,24 @@ public class ConditionsEditor extends LocatableVLayout {
public void executeAction(ListGridRecord[] selection) {
final Window winModal = new Window();
winModal.setTitle("Add Condition");
+ winModal.setOverflow(Overflow.VISIBLE);
winModal.setShowMinimizeButton(false);
winModal.setIsModal(true);
winModal.setShowModalMask(true);
winModal.setAutoSize(true);
winModal.setAutoCenter(true);
+ //winModal.setShowResizer(true);
+ //winModal.setCanDragResize(true);
winModal.centerInPage();
winModal.addCloseClickHandler(new CloseClickHandler() {
@Override
public void onCloseClick(CloseClientEvent event) {
- winModal.destroy();
+ winModal.markForDestroy();
}
});
+
NewConditionEditor newConditionEditor = new NewConditionEditor(extendLocatorId("newConditionEditor"),
- conditions);
+ conditions, ConditionsEditor.this.resourceType, winModal);
winModal.addItem(newConditionEditor);
winModal.show();
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java
index c0b37ca..ec67b08 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java
@@ -27,6 +27,7 @@ import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.util.SC;
import com.smartgwt.client.widgets.grid.ListGridRecord;
+import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.resource.group.ResourceGroup;
/**
@@ -44,6 +45,11 @@ public class GroupAlertDefinitionsView extends AbstractAlertDefinitionsView {
}
@Override
+ protected ResourceType getResourceType() {
+ return group.getResourceType();
+ }
+
+ @Override
protected Criteria getCriteria() {
Criteria criteria = new Criteria();
criteria.addCriteria(CRITERIA_GROUP_ID, group.getId());
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java
index c6c59c1..7922824 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java
@@ -24,11 +24,13 @@
package org.rhq.enterprise.gui.coregui.client.alert.definitions;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedHashMap;
+import java.util.Set;
import com.smartgwt.client.types.Alignment;
-import com.smartgwt.client.util.SC;
+import com.smartgwt.client.widgets.Window;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.FormItemIfFunction;
import com.smartgwt.client.widgets.form.fields.ButtonItem;
@@ -44,7 +46,10 @@ import org.rhq.core.domain.alert.AlertCondition;
import org.rhq.core.domain.alert.AlertConditionCategory;
import org.rhq.core.domain.event.EventSeverity;
import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.core.domain.measurement.MeasurementDefinition;
+import org.rhq.core.domain.operation.OperationDefinition;
import org.rhq.core.domain.operation.OperationRequestStatus;
+import org.rhq.core.domain.resource.ResourceType;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
/**
@@ -52,12 +57,59 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
*/
public class NewConditionEditor extends LocatableDynamicForm {
- private HashSet<AlertCondition> conditions; // the new condition we create goes into this set
private SelectItem conditionTypeSelectItem;
+ private HashSet<AlertCondition> conditions; // the new condition we create goes into this set
+ private Collection<String> metrics;
+ private Collection<String> traits;
+ private Collection<String> operations;
+ private boolean supportsEvents;
+ private Window parentWindow; // where this form is located; after form is OK'ed, this window will be destroyed
+
+ public NewConditionEditor(String locatorId, HashSet<AlertCondition> conditions, ResourceType rtype, Window parent) {
- public NewConditionEditor(String locatorId, HashSet<AlertCondition> conditions) {
super(locatorId);
this.conditions = conditions;
+ this.parentWindow = parent;
+
+ this.supportsEvents = (rtype.getEventDefinitions() != null & rtype.getEventDefinitions().size() > 0);
+
+ Set<MeasurementDefinition> metricDefinitions = rtype.getMetricDefinitions();
+ Set<OperationDefinition> operationDefinitions = rtype.getOperationDefinitions();
+ if (metricDefinitions == null || metricDefinitions.size() == 0) {
+ this.metrics = null;
+ this.traits = null;
+ } else {
+ for (MeasurementDefinition measurementDefinition : metricDefinitions) {
+ switch (measurementDefinition.getDataType()) {
+ case MEASUREMENT: {
+ if (this.metrics == null) {
+ this.metrics = new ArrayList<String>();
+ }
+ this.metrics.add(measurementDefinition.getDisplayName());
+ break;
+ }
+ case TRAIT: {
+ if (this.traits == null) {
+ this.traits = new ArrayList<String>();
+ }
+ this.traits.add(measurementDefinition.getDisplayName());
+ break;
+ }
+ default: {
+ break;
+ }
+ }
+ }
+ }
+
+ if (operationDefinitions == null || operationDefinitions.size() == 0) {
+ this.operations = null;
+ } else {
+ this.operations = new ArrayList<String>(operationDefinitions.size());
+ for (OperationDefinition operationDefinition : operationDefinitions) {
+ this.operations.add(operationDefinition.getDisplayName());
+ }
+ }
}
@Override
@@ -68,15 +120,23 @@ public class NewConditionEditor extends LocatableDynamicForm {
conditionTypeSelectItem = new SelectItem("conditionType", "Condition Type");
LinkedHashMap<String, String> condTypes = new LinkedHashMap<String, String>(7);
- condTypes.put(AlertConditionCategory.THRESHOLD.name(), "Measurement Absolute Value Threshold");
- condTypes.put(AlertConditionCategory.BASELINE.name(), "Measurement Baseline Threshold");
- condTypes.put(AlertConditionCategory.CHANGE.name(), "Measurement Value Change");
- condTypes.put(AlertConditionCategory.TRAIT.name(), "Trait Value Change");
condTypes.put(AlertConditionCategory.AVAILABILITY.name(), "Availability Change");
- condTypes.put(AlertConditionCategory.CONTROL.name(), "Operation Execution");
- condTypes.put(AlertConditionCategory.EVENT.name(), "Event Detection");
+ if (metrics != null) {
+ condTypes.put(AlertConditionCategory.THRESHOLD.name(), "Measurement Absolute Value Threshold");
+ condTypes.put(AlertConditionCategory.BASELINE.name(), "Measurement Baseline Threshold");
+ condTypes.put(AlertConditionCategory.CHANGE.name(), "Measurement Value Change");
+ }
+ if (traits != null) {
+ condTypes.put(AlertConditionCategory.TRAIT.name(), "Trait Value Change");
+ }
+ if (operations != null) {
+ condTypes.put(AlertConditionCategory.CONTROL.name(), "Operation Execution");
+ }
+ if (supportsEvents) {
+ condTypes.put(AlertConditionCategory.EVENT.name(), "Event Detection");
+ }
conditionTypeSelectItem.setValueMap(condTypes);
- conditionTypeSelectItem.setDefaultValue(AlertConditionCategory.THRESHOLD.name());
+ conditionTypeSelectItem.setDefaultValue(AlertConditionCategory.AVAILABILITY.name());
conditionTypeSelectItem.setWrapTitle(false);
conditionTypeSelectItem.setRedrawOnChange(true);
conditionTypeSelectItem.setWidth("*");
@@ -91,21 +151,31 @@ public class NewConditionEditor extends LocatableDynamicForm {
ok.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
- // TODO
- SC.say("Not yet implemented");
+ if (validate(false)) {
+ // TODO
+ NewConditionEditor.this.parentWindow.markForDestroy();
+ }
}
});
ArrayList<FormItem> formItems = new ArrayList<FormItem>();
formItems.add(conditionTypeSelectItem);
formItems.add(spacer);
- formItems.addAll(buildMetricThresholdFormItems());
- formItems.addAll(buildMetricBaselineFormItems());
- formItems.addAll(buildMetricChangeFormItems());
- formItems.addAll(buildTraitChangeFormItems());
formItems.addAll(buildAvailabilityChangeFormItems());
- formItems.addAll(buildOperationFormItems());
- formItems.addAll(buildEventFormItems());
+ if (metrics != null) {
+ formItems.addAll(buildMetricThresholdFormItems());
+ formItems.addAll(buildMetricBaselineFormItems());
+ formItems.addAll(buildMetricChangeFormItems());
+ }
+ if (traits != null) {
+ formItems.addAll(buildTraitChangeFormItems());
+ }
+ if (operations != null) {
+ formItems.addAll(buildOperationFormItems());
+ }
+ if (supportsEvents) {
+ formItems.addAll(buildEventFormItems());
+ }
formItems.add(ok);
setFields(formItems.toArray(new FormItem[formItems.size()]));
@@ -126,6 +196,8 @@ public class NewConditionEditor extends LocatableDynamicForm {
TextItem absoluteValue = new TextItem("metricAbsoluteValue", "Metric Value");
absoluteValue.setWrapTitle(false);
absoluteValue.setRequired(true);
+ absoluteValue
+ .setTooltip("The threshold value of the metric that will trigger the condition when compared using the selected comparator.");
absoluteValue.setShowIfCondition(ifFunc);
formItems.add(absoluteValue);
@@ -148,6 +220,8 @@ public class NewConditionEditor extends LocatableDynamicForm {
TextItem baselinePercentage = new TextItem("baselinePercentage", "Baseline Percentage");
baselinePercentage.setWrapTitle(false);
baselinePercentage.setRequired(true);
+ baselinePercentage
+ .setTooltip("A collected metric value will trigger this condition when compared to this percentage of the selected baseline value using the selected comparator");
baselinePercentage.setShowIfCondition(ifFunc);
formItems.add(baselinePercentage);
@@ -158,8 +232,9 @@ public class NewConditionEditor extends LocatableDynamicForm {
baselines.put("max", "Maximum"); // title should have the current value of the max baseline
baselineSelection.setValueMap(baselines);
baselineSelection.setDefaultValue("avg");
- baselineSelection.setWidth("*");
baselineSelection.setWrapTitle(false);
+ baselineSelection.setWidth("*");
+ baselineSelection.setRedrawOnChange(true);
baselineSelection.setShowIfCondition(ifFunc);
formItems.add(baselineSelection);
@@ -189,14 +264,16 @@ public class NewConditionEditor extends LocatableDynamicForm {
StaticTextItem helpItem = buildHelpTextItem("traitHelp", helpStr, ifFunc);
formItems.add(helpItem);
- LinkedHashMap<String, String> traits = new LinkedHashMap<String, String>();
- // TODO
- traits.put("dummy trait", "Dummy Trait Name");
+ LinkedHashMap<String, String> traitsMap = new LinkedHashMap<String, String>();
+ for (String traitName : this.traits) {
+ traitsMap.put(traitName, traitName);
+ }
SelectItem traitSelection = new SelectItem("trait", "Trait");
- traitSelection.setValueMap(traits);
- traitSelection.setDefaultValue(traits.keySet().iterator().next()); // just use the first one
+ traitSelection.setValueMap(traitsMap);
+ traitSelection.setDefaultValue(traitsMap.keySet().iterator().next()); // just use the first one
traitSelection.setWidth("*");
+ traitSelection.setRedrawOnChange(true);
traitSelection.setShowIfCondition(ifFunc);
formItems.add(traitSelection);
@@ -234,12 +311,15 @@ public class NewConditionEditor extends LocatableDynamicForm {
formItems.add(helpItem);
LinkedHashMap<String, String> ops = new LinkedHashMap<String, String>();
- // TODO
- ops.put("dummy op", "Dummy Op Name");
+ for (String opName : this.operations) {
+ ops.put(opName, opName);
+ }
SelectItem opSelection = new SelectItem("operation", "Operation");
opSelection.setValueMap(ops);
opSelection.setDefaultValue(ops.keySet().iterator().next()); // just use the first one
+ opSelection.setWidth("*");
+ opSelection.setRedrawOnChange(true);
opSelection.setShowIfCondition(ifFunc);
formItems.add(opSelection);
@@ -251,7 +331,6 @@ public class NewConditionEditor extends LocatableDynamicForm {
operationStatuses.put(OperationRequestStatus.CANCELED.name(), OperationRequestStatus.CANCELED.name());
opResultsSelection.setValueMap(operationStatuses);
opResultsSelection.setDefaultValue(OperationRequestStatus.FAILURE.name());
- opResultsSelection.setWidth("*");
opResultsSelection.setWrapTitle(false);
opResultsSelection.setShowIfCondition(ifFunc);
formItems.add(opResultsSelection);
@@ -283,6 +362,8 @@ public class NewConditionEditor extends LocatableDynamicForm {
TextItem eventRegex = new TextItem("eventRegex", "Regular Expression");
eventRegex.setRequired(false);
+ eventRegex
+ .setTooltip("If specified, this is a regular expression that must match a collected event message in order to trigger the condition.");
eventRegex.setWrapTitle(false);
eventRegex.setShowIfCondition(ifFunc);
formItems.add(eventRegex);
@@ -292,13 +373,16 @@ public class NewConditionEditor extends LocatableDynamicForm {
private SelectItem buildMetricDropDownMenu(String itemName, FormItemIfFunction ifFunc) {
- LinkedHashMap<String, String> metrics = new LinkedHashMap<String, String>();
- metrics.put("dummy metric", "Dummy Metric Name");
+ LinkedHashMap<String, String> metricsMap = new LinkedHashMap<String, String>();
+ for (String metricName : this.metrics) {
+ metricsMap.put(metricName, metricName);
+ }
SelectItem metricSelection = new SelectItem(itemName, "Metric");
- metricSelection.setValueMap(metrics);
- metricSelection.setDefaultValue(metrics.keySet().iterator().next()); // just use the first one
+ metricSelection.setValueMap(metricsMap);
+ metricSelection.setDefaultValue(metricsMap.keySet().iterator().next()); // just use the first one
metricSelection.setWidth("*");
+ metricSelection.setRedrawOnChange(true);
metricSelection.setShowIfCondition(ifFunc);
return metricSelection;
}
@@ -313,6 +397,7 @@ public class NewConditionEditor extends LocatableDynamicForm {
SelectItem comparatorSelection = new SelectItem(itemName, "Comparator");
comparatorSelection.setValueMap(comparators);
comparatorSelection.setDefaultValue("<");
+ comparatorSelection.setTooltip("How a collected metric value should be compared to the given threshold value");
comparatorSelection.setShowIfCondition(ifFunc);
return comparatorSelection;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java
index 7cf7226..83a8629 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java
@@ -28,6 +28,7 @@ import com.smartgwt.client.util.SC;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.ResourceType;
/**
* @author John Mazzitelli
@@ -44,6 +45,11 @@ public class ResourceAlertDefinitionsView extends AbstractAlertDefinitionsView {
}
@Override
+ protected ResourceType getResourceType() {
+ return resource.getResourceType();
+ }
+
+ @Override
protected Criteria getCriteria() {
Criteria criteria = new Criteria();
criteria.addCriteria(CRITERIA_RESOURCE_ID, resource.getId());
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java
index d06e422..8269a8d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java
@@ -30,6 +30,7 @@ import com.smartgwt.client.widgets.layout.HLayout;
import com.smartgwt.client.widgets.tab.Tab;
import org.rhq.core.domain.alert.AlertDefinition;
+import org.rhq.core.domain.resource.ResourceType;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableButton;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableTab;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableTabSet;
@@ -41,6 +42,7 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
public class SingleAlertDefinitionView extends LocatableVLayout {
private AlertDefinition alertDefinition;
+
private GeneralPropertiesAlertDefinitionForm generalProperties;
private ConditionsAlertDefinitionForm conditions;
private NotificationsAlertDefinitionForm notifications;
@@ -51,11 +53,11 @@ public class SingleAlertDefinitionView extends LocatableVLayout {
private Button saveButton;
private Button cancelButton;
- public SingleAlertDefinitionView(String locatorId) {
- this(locatorId, null);
+ public SingleAlertDefinitionView(String locatorId, ResourceType resourceType) {
+ this(locatorId, resourceType, null);
}
- public SingleAlertDefinitionView(String locatorId, AlertDefinition alertDefinition) {
+ public SingleAlertDefinitionView(String locatorId, ResourceType resourceType, AlertDefinition alertDefinition) {
super(locatorId);
this.alertDefinition = alertDefinition;
@@ -68,7 +70,7 @@ public class SingleAlertDefinitionView extends LocatableVLayout {
generalPropertiesTab.setPane(generalProperties);
Tab conditionsTab = new LocatableTab(tabSet.extendLocatorId("Conditions"), "Conditions");
- conditions = new ConditionsAlertDefinitionForm(this.getLocatorId(), alertDefinition);
+ conditions = new ConditionsAlertDefinitionForm(this.getLocatorId(), resourceType, alertDefinition);
conditionsTab.setPane(conditions);
Tab notificationsTab = new LocatableTab(tabSet.extendLocatorId("Notifications"), "Notifications");
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java
index d2f44f6..d5a5e14 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java
@@ -44,6 +44,11 @@ public class TemplateAlertDefinitionsView extends AbstractAlertDefinitionsView {
}
@Override
+ protected ResourceType getResourceType() {
+ return resourceType;
+ }
+
+ @Override
protected Criteria getCriteria() {
Criteria criteria = new Criteria();
criteria.addCriteria(CRITERIA_RESOURCE_TYPE_ID, resourceType.getId());
13 years, 8 months
[rhq] modules/enterprise
by Simeon Pinder
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java | 20 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedResourceDS.java | 170 ++++++----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedView.java | 52 +--
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java | 10
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java | 35 +-
5 files changed, 170 insertions(+), 117 deletions(-)
New commits:
commit 8d1ef83e3075616b615c385f2174c7228ddde9d6
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Mon Sep 13 12:24:48 2010 -0400
moved Table attrs back to private, enabled RecentlyAdded server side
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
index 0d4e6d6..5196c71 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
@@ -77,12 +77,12 @@ public class Table extends LocatableHLayout {
private TableFilter filterForm;
private ListGrid listGrid;
private ToolStrip footer;
- protected Label tableInfo;
+ private Label tableInfo;
private List<String> headerIcons = new ArrayList<String>();
private boolean showHeader = true;
- protected boolean showFooter = true;
+ private boolean showFooter = true;
private boolean showFooterRefresh = true;
private String tableTitle;
@@ -249,7 +249,7 @@ public class Table extends LocatableHLayout {
// Now give subclasses a chance to configure the table
configureTable();
- tableInfo = new Label("Total: " + listGrid.getTotalRows());
+ setTableInfo(new Label("Total: " + listGrid.getTotalRows()));
// NOTE: It is essential that we wait to hide any excluded fields until after super.onDraw() is called, since
// super.onDraw() is what actually adds the fields to the ListGrid (based on what fields are defined in
@@ -260,7 +260,7 @@ public class Table extends LocatableHLayout {
}
}
- tableInfo.setWrap(false);
+ getTableInfo().setWrap(false);
if (showHeader) {
@@ -543,8 +543,8 @@ public class Table extends LocatableHLayout {
((TableWidget) extraWidget).refresh(this.listGrid);
}
}
- if (this.tableInfo != null) {
- this.tableInfo.setContents("Total: " + listGrid.getTotalRows() + " (" + count + " selected)");
+ if (getTableInfo() != null) {
+ getTableInfo().setContents("Total: " + listGrid.getTotalRows() + " (" + count + " selected)");
}
}
}
@@ -659,4 +659,12 @@ public class Table extends LocatableHLayout {
public void setShowFooterRefresh(boolean showFooterRefresh) {
this.showFooterRefresh = showFooterRefresh;
}
+
+ public Label getTableInfo() {
+ return tableInfo;
+ }
+
+ public void setTableInfo(Label tableInfo) {
+ this.tableInfo = tableInfo;
+ }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedResourceDS.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedResourceDS.java
index fb1db39..17b4074 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedResourceDS.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedResourceDS.java
@@ -23,6 +23,10 @@
package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.imported;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
import com.google.gwt.i18n.client.DateTimeFormat;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
@@ -32,28 +36,28 @@ import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.types.DSDataFormat;
import com.smartgwt.client.types.DSProtocol;
import com.smartgwt.client.widgets.tree.TreeNode;
-import org.rhq.core.domain.criteria.ResourceCriteria;
+
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.domain.resource.Resource;
-import org.rhq.core.domain.resource.ResourceCategory;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.resource.composite.RecentlyAddedResourceComposite;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
+import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility;
public class RecentlyAddedResourceDS extends DataSource {
+ private Portlet portlet;
+ private int maximumRecentlyAddedToDisplay;
+ private int maximumRecentlyAddedWithinHours;
+ private long oldestDate = -1;
-
- public RecentlyAddedResourceDS() {
+ public RecentlyAddedResourceDS(Portlet recentlyAddedPortlet) {
+ this.portlet = recentlyAddedPortlet;
setClientOnly(false);
setDataProtocol(DSProtocol.CLIENTCUSTOM);
setDataFormat(DSDataFormat.CUSTOM);
-
DataSourceTextField idField = new DataSourceTextField("id", "ID");
idField.setPrimaryKey(true);
@@ -75,11 +79,11 @@ public class RecentlyAddedResourceDS extends DataSource {
// Asume success
response.setStatus(0);
switch (request.getOperationType()) {
- case FETCH:
- executeFetch(request, response);
- break;
- default:
- break;
+ case FETCH:
+ executeFetch(request, response);
+ break;
+ default:
+ break;
}
return request.getData();
@@ -87,21 +91,43 @@ public class RecentlyAddedResourceDS extends DataSource {
public void executeFetch(final DSRequest request, final DSResponse response) {
- ResourceCriteria c = new ResourceCriteria();
+ long ctime = -1;
+ int maxItems = -1;
+ //retrieve current portlet display settings
+ if ((this.portlet != null) && (this.portlet instanceof RecentlyAddedView)) {
+ RecentlyAddedView recentAdditionsPortlet = (RecentlyAddedView) this.portlet;
+ if (recentAdditionsPortlet != null) {
+ if (getMaximumRecentlyAddedToDisplay() > 0) {
+ maxItems = getMaximumRecentlyAddedToDisplay();
+ }
- String p = request.getCriteria().getAttribute("parentId");
+ //define the time window
+ if (getMaximumRecentlyAddedWithinHours() > 0) {
+ ctime = System.currentTimeMillis()
+ - (getMaximumRecentlyAddedWithinHours() * MeasurementUtility.HOURS);
+ setOldestDate(ctime);
+ }
- if (p == null) {
- c.addFilterResourceCategory(ResourceCategory.PLATFORM);
- c.fetchChildResources(true);
- } else {
- c.addFilterParentResourceId(Integer.parseInt(p));
+ }
}
+ // TODO: spinder: revisit this later. ResourceCriteria mechanism does not work. Not sure if it's better?
+ // ResourceCriteria c = new ResourceCriteria();
+ //
+ // String p = request.getCriteria().getAttribute("parentId");
+ //
+ // if (p == null) {
+ // c.addFilterResourceCategory(ResourceCategory.PLATFORM);
+ // c.fetchChildResources(true);
+ // } else {
+ // c.addFilterParentResourceId(Integer.parseInt(p));
+ // }
+
// TODO GH: Enhance resourceCriteria query to support itime based filtering for
// "Recently imported" resources
- GWTServiceLookup.getResourceService().findRecentlyAddedResources(0, 100,
+ // GWTServiceLookup.getResourceService().findRecentlyAddedResources(0, 100,
+ GWTServiceLookup.getResourceService().findRecentlyAddedResources(ctime, maxItems,
new AsyncCallback<List<RecentlyAddedResourceComposite>>() {
public void onFailure(Throwable throwable) {
CoreGUI.getErrorHandler().handleError("Failed to load recently added resources", throwable);
@@ -120,38 +146,38 @@ public class RecentlyAddedResourceDS extends DataSource {
processResponse(request.getRequestId(), response);
}
});
-//
-// GWTServiceLookup.getResourceService().findResourcesByCriteria(c, new AsyncCallback<PageList<Resource>>() {
-// public void onFailure(Throwable caught) {
-// CoreGUI.getErrorHandler().handleError("Failed to load recently added resources data",caught);
-// response.setStatus(DSResponse.STATUS_FAILURE);
-// processResponse(request.getRequestId(), response);
-// }
-//
-// public void onSuccess(PageList<Resource> result) {
-// PageList<Resource> all = new PageList<Resource>();
-//
-// for (Resource root : result) {
-// all.add(root);
-// if (root.getChildResources() != null)
-// all.addAll(root.getChildResources());
-// }
-//
-//
-// response.setData(buildNodes(all));
-// response.setTotalRows(all.getTotalSize());
-// processResponse(request.getRequestId(), response);
-// }
-// });
+ //
+ // GWTServiceLookup.getResourceService().findResourcesByCriteria(c, new AsyncCallback<PageList<Resource>>() {
+ // public void onFailure(Throwable caught) {
+ // CoreGUI.getErrorHandler().handleError("Failed to load recently added resources data",caught);
+ // response.setStatus(DSResponse.STATUS_FAILURE);
+ // processResponse(request.getRequestId(), response);
+ // }
+ //
+ // public void onSuccess(PageList<Resource> result) {
+ // PageList<Resource> all = new PageList<Resource>();
+ //
+ // for (Resource root : result) {
+ // all.add(root);
+ // if (root.getChildResources() != null)
+ // all.addAll(root.getChildResources());
+ // }
+ //
+ //
+ // response.setData(buildNodes(all));
+ // response.setTotalRows(all.getTotalSize());
+ // processResponse(request.getRequestId(), response);
+ // }
+ // });
}
-// private TreeNode[] buildNodes(PageList<Resource> list) {
-// TreeNode[] treeNodes = new TreeNode[list.size()];
-// for (int i = 0; i < list.size(); ++i) {
-// treeNodes[i] = new ResourceTreeNode(list.get(i));
-// }
-// return treeNodes;
-// }
+ // private TreeNode[] buildNodes(PageList<Resource> list) {
+ // TreeNode[] treeNodes = new TreeNode[list.size()];
+ // for (int i = 0; i < list.size(); ++i) {
+ // treeNodes[i] = new ResourceTreeNode(list.get(i));
+ // }
+ // return treeNodes;
+ // }
private TreeNode[] buildNodes(List<RecentlyAddedResourceComposite> list) {
TreeNode[] treeNodes = new TreeNode[list.size()];
@@ -169,8 +195,7 @@ public class RecentlyAddedResourceDS extends DataSource {
Date dateAdded = new Date(recentlyAdded.getCtime());
String id = String.valueOf(recentlyAdded.getId());
- String parentId = recentlyAdded.getParentId() == 0 ? null
- : String.valueOf((recentlyAdded.getParentId()));
+ String parentId = recentlyAdded.getParentId() == 0 ? null : String.valueOf((recentlyAdded.getParentId()));
setID(id);
setParentID(parentId);
@@ -191,8 +216,8 @@ public class RecentlyAddedResourceDS extends DataSource {
this.resource = resource;
String id = String.valueOf(resource.getId());
- String parentId = resource.getParentResource() == null ? null
- : String.valueOf((resource.getParentResource().getId()));
+ String parentId = resource.getParentResource() == null ? null : String.valueOf((resource
+ .getParentResource().getId()));
setID(id);
setParentID(parentId);
@@ -201,10 +226,10 @@ public class RecentlyAddedResourceDS extends DataSource {
setAttribute("parentId", parentId);
setAttribute("name", resource.getName());
setAttribute("timestamp", "");//String.valueOf(resource.getItime())); // Seems to be null
- setAttribute("currentAvailability",
- resource.getCurrentAvailability().getAvailabilityType() == AvailabilityType.UP
- ? "/images/icons/availability_green_16.png"
- : "/images/icons/availability_red_16.png");
+ setAttribute(
+ "currentAvailability",
+ resource.getCurrentAvailability().getAvailabilityType() == AvailabilityType.UP ? "/images/icons/availability_green_16.png"
+ : "/images/icons/availability_red_16.png");
}
public Resource getResource() {
@@ -223,4 +248,29 @@ public class RecentlyAddedResourceDS extends DataSource {
return getAttribute("parentId");
}
}
+
+ public int getMaximumRecentlyAddedToDisplay() {
+ return maximumRecentlyAddedToDisplay;
+ }
+
+ public void setMaximumRecentlyAddedToDisplay(int maximumRecentlyAddedToDisplay) {
+ this.maximumRecentlyAddedToDisplay = maximumRecentlyAddedToDisplay;
+ }
+
+ public int getMaximumRecentlyAddedWithinHours() {
+ return maximumRecentlyAddedWithinHours;
+ }
+
+ public void setMaximumRecentlyAddedWithinHours(int maximumRecentlyAddedWithinHours) {
+ this.maximumRecentlyAddedWithinHours = maximumRecentlyAddedWithinHours;
+ }
+
+ public long getOldestDate() {
+ return oldestDate;
+ }
+
+ public void setOldestDate(long oldestDate) {
+ this.oldestDate = oldestDate;
+ }
+
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedView.java
index c856151..31bcf9d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedView.java
@@ -49,27 +49,25 @@ public class RecentlyAddedView extends LocatableVLayout implements CustomSetting
private boolean simple = true;
private DashboardPortlet storedPortlet;
+ private RecentlyAddedResourceDS dataSource;
+ private TreeGrid treeGrid = null;
public static final String unlimited = "unlimited";
public static final String defaultValue = unlimited;
private static final String RECENTLY_ADDED_SHOW_MAX = "recently-added-show-amount";
-
private static final String RECENTLY_ADDED_SHOW_HRS = "recently-added-time-range";
public RecentlyAddedView(String locatorId) {
super(locatorId);
+ //insert the datasource
+ this.dataSource = new RecentlyAddedResourceDS(this);
}
- private TreeGrid treeGrid = null;
-
- private int maximumRecentlyAddedToDisplay;
- private int maximumRecentlyAddedWithinHours;
-
@Override
protected void onInit() {
super.onInit();
treeGrid = new TreeGrid();
- treeGrid.setDataSource(new RecentlyAddedResourceDS());
+ treeGrid.setDataSource(getDataSource());
treeGrid.setAutoFetchData(true);
treeGrid.setTitle("Recently Added Resources");
treeGrid.setResizeFieldsInRealTime(true);
@@ -83,7 +81,7 @@ public class RecentlyAddedView extends LocatableVLayout implements CustomSetting
}
});
- ListGridField timestampField = new ListGridField("timestamp", "Date//Time");
+ ListGridField timestampField = new ListGridField("timestamp", "Date/Time");
treeGrid.setFields(resourceNameField, timestampField);
@@ -100,20 +98,24 @@ public class RecentlyAddedView extends LocatableVLayout implements CustomSetting
if (storedPortlet.getConfiguration().getSimple(RECENTLY_ADDED_SHOW_MAX) != null) {
//retrieve and translate to int
String retrieved = storedPortlet.getConfiguration().getSimple(RECENTLY_ADDED_SHOW_MAX).getStringValue();
- if (retrieved.equals(unlimited)) {
- maximumRecentlyAddedToDisplay = -1;
- } else {
- maximumRecentlyAddedToDisplay = Integer.parseInt(retrieved);
+ if (getDataSource() != null) {//check for initialization of datasource unavailability
+ if (retrieved.equals(unlimited)) {
+ getDataSource().setMaximumRecentlyAddedToDisplay(-1);
+ } else {
+ getDataSource().setMaximumRecentlyAddedToDisplay(Integer.parseInt(retrieved));
+ }
}
} else {//create setting
storedPortlet.getConfiguration().put(new PropertySimple(RECENTLY_ADDED_SHOW_MAX, defaultValue));
}
if (storedPortlet.getConfiguration().getSimple(RECENTLY_ADDED_SHOW_HRS) != null) {
String retrieved = storedPortlet.getConfiguration().getSimple(RECENTLY_ADDED_SHOW_HRS).getStringValue();
- if (retrieved.equals(unlimited)) {
- setMaximumRecentlyAddedWithinHours(-1);
- } else {
- setMaximumRecentlyAddedWithinHours(Integer.parseInt(retrieved));
+ if (getDataSource() != null) {//check for initialization of datasource unavailability
+ if (retrieved.equals(unlimited)) {
+ getDataSource().setMaximumRecentlyAddedWithinHours(-1);
+ } else {
+ getDataSource().setMaximumRecentlyAddedWithinHours(Integer.parseInt(retrieved));
+ }
}
} else {
storedPortlet.getConfiguration().put(new PropertySimple(RECENTLY_ADDED_SHOW_HRS, defaultValue));
@@ -130,7 +132,7 @@ public class RecentlyAddedView extends LocatableVLayout implements CustomSetting
//-------------combobox for number of recently added resources to display on the dashboard
final SelectItem maximumRecentlyAddedComboBox = new SelectItem(RECENTLY_ADDED_SHOW_MAX);
maximumRecentlyAddedComboBox.setTitle("Show");
- maximumRecentlyAddedComboBox.setHint("<nobr><b> recently approved resources on dashboard.</b></nobr>");
+ maximumRecentlyAddedComboBox.setHint("<nobr><b> recently approved platforms on dashboard.</b></nobr>");
//spinder 9/3/10: the following is required workaround to disable editability of combobox.
maximumRecentlyAddedComboBox.setType("selection");
//define acceptable values for display amount
@@ -216,19 +218,7 @@ public class RecentlyAddedView extends LocatableVLayout implements CustomSetting
this.treeGrid.markForRedraw();
}
- public int getMaximumRecentlyAddedToDisplay() {
- return maximumRecentlyAddedToDisplay;
- }
-
- public void setMaximumRecentlyAddedToDisplay(int maximumRecentlyAddedToDisplay) {
- this.maximumRecentlyAddedToDisplay = maximumRecentlyAddedToDisplay;
- }
-
- public int getMaximumRecentlyAddedWithinHours() {
- return maximumRecentlyAddedWithinHours;
- }
-
- public void setMaximumRecentlyAddedWithinHours(int maximumRecentlyAddedWithinHours) {
- this.maximumRecentlyAddedWithinHours = maximumRecentlyAddedWithinHours;
+ public RecentlyAddedResourceDS getDataSource() {
+ return dataSource;
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java
index 3faa954..2778c59 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java
@@ -62,6 +62,9 @@ public class ProblemResourcesPortlet extends Table implements CustomSettingsPort
public static final String KEY = "Has Alerts or Currently Unavailable";
private static final String TITLE = KEY;
private DashboardPortlet storedPortlet;
+ //reference to datasource
+ private ProblemResourcesDataSource dataSource;
+
//constants
public static final String unlimited = "unlimited";
public static final String defaultValue = unlimited;
@@ -97,9 +100,6 @@ public class ProblemResourcesPortlet extends Table implements CustomSettingsPort
}
}
- //reference to datasource
- private ProblemResourcesDataSource dataSource;
-
@Override
public ProblemResourcesDataSource getDataSource() {
return (ProblemResourcesDataSource) super.getDataSource();
@@ -251,7 +251,7 @@ public class ProblemResourcesPortlet extends Table implements CustomSettingsPort
}
protected void refreshTableInfo() {
- if (showFooter) {
+ if (isShowFooter()) {
long begin = 0;
List<Long> bounds = MeasurementUtility.calculateTimeFrame(getDataSource()
.getMaximumProblemResourcesWithinHours(), MeasurementUtility.UNIT_HOURS);
@@ -272,7 +272,7 @@ public class ProblemResourcesPortlet extends Table implements CustomSettingsPort
}
}
//remove selected count as portlet is view only. Selection not used.
- this.tableInfo.setContents("Total: " + getListGrid().getTotalRows());
+ getTableInfo().setContents("Total: " + getListGrid().getTotalRows());
}
}
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 64fd5f8..e228f15 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
@@ -213,7 +213,7 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
if (!authorizationManager.hasResourcePermission(user, Permission.MODIFY_RESOURCE, resource.getId())) {
throw new PermissionException("You do not have permission to modify Resource with id " + resource.getId()
- + ".");
+ + ".");
}
/*if (getResourceByParentAndKey(user, resource.getParentResource(), resource.getResourceKey()) != null)
@@ -246,8 +246,8 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
@SuppressWarnings("unchecked")
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public List<Integer> uninventoryResource(Subject user, int resourceId) {
-// Resource resource = resourceManager.getResourceTree(resourceId, true);
- Resource resource = entityManager.find(Resource.class,resourceId);
+ // Resource resource = resourceManager.getResourceTree(resourceId, true);
+ Resource resource = entityManager.find(Resource.class, resourceId);
if (resource == null) {
log.info("Delete resource not possible, as resource with id [" + resourceId + "] was not found");
return Collections.emptyList(); // Resource not found. TODO give a nice message to the user
@@ -313,10 +313,10 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
// QUERY_MARK_RESOURCES_FOR_ASYNC_DELETION is an expensive recursive query
// But luckily we have already (through such a recursive query above) determined the doomed resources
-// Query markDeletedQuery = entityManager.createNamedQuery(Resource.QUERY_MARK_RESOURCES_FOR_ASYNC_DELETION);
-// markDeletedQuery.setParameter("resourceId", resourceId);
-// markDeletedQuery.setParameter("status", InventoryStatus.UNINVENTORIED);
-// int resourcesDeleted = markDeletedQuery.executeUpdate();
+ // Query markDeletedQuery = entityManager.createNamedQuery(Resource.QUERY_MARK_RESOURCES_FOR_ASYNC_DELETION);
+ // markDeletedQuery.setParameter("resourceId", resourceId);
+ // markDeletedQuery.setParameter("status", InventoryStatus.UNINVENTORIED);
+ // int resourcesDeleted = markDeletedQuery.executeUpdate();
i = 0;
int resourcesDeleted = 0;
@@ -326,11 +326,11 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
j = toBeDeletedResourceIds.size();
List<Integer> idsToDelete = toBeDeletedResourceIds.subList(i, j);
-
- Query markDeletedQuery = entityManager.createNamedQuery(Resource.QUERY_MARK_RESOURCES_FOR_ASYNC_DELETION_QUICK);
+ Query markDeletedQuery = entityManager
+ .createNamedQuery(Resource.QUERY_MARK_RESOURCES_FOR_ASYNC_DELETION_QUICK);
markDeletedQuery.setParameter("resourceIds", idsToDelete);
markDeletedQuery.setParameter("status", InventoryStatus.UNINVENTORIED);
- resourcesDeleted+= markDeletedQuery.executeUpdate();
+ resourcesDeleted += markDeletedQuery.executeUpdate();
i = j;
}
@@ -1063,7 +1063,11 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
}
query.setParameter("oldestEpochTime", ctime);
- query.setMaxResults(maxItems); // this query is only used by the dashboard portlet, let's not blow it up
+ if ((maxItems > 100) || (maxItems < 0)) {//cap infininte(-1) and large requests to 100
+ query.setMaxResults(100); // this query is only used by the dashboard portlet, let's not blow it up
+ } else {
+ query.setMaxResults(maxItems);
+ }
return query.getResultList();
}
@@ -2093,14 +2097,14 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
Resource parent = resource.getParentResource();
ResourceComposite composite = new ResourceComposite(resource, parent, availType);
composite.setResourceFacets(typeManager.getResourceFacets(resource.getResourceType().getId()));
- Set<Permission> permissions = authorizationManager.getImplicitResourcePermissions(subject, resource.getId());
+ Set<Permission> permissions = authorizationManager
+ .getImplicitResourcePermissions(subject, resource.getId());
composite.setResourcePermission(new ResourcePermission(permissions));
// TODO: jmarques: Alter criteria projection to include permissions.
results.add(composite);
}
- return new PageList<ResourceComposite>(results, resources.getTotalSize(), resources
- .getPageControl());
+ return new PageList<ResourceComposite>(results, resources.getTotalSize(), resources.getPageControl());
}
@SuppressWarnings("unchecked")
@@ -2168,6 +2172,7 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
public <T> List<DisambiguationReport<T>> disambiguate(List<T> results, IntExtractor<? super T> extractor,
DisambiguationUpdateStrategy updateStrategy) {
- return Disambiguator.disambiguate(results, updateStrategy, extractor, entityManager, typeManager.getDuplicateTypeNames());
+ return Disambiguator.disambiguate(results, updateStrategy, extractor, entityManager, typeManager
+ .getDuplicateTypeNames());
}
}
13 years, 8 months
[rhq] 2 commits - modules/enterprise
by Simeon Pinder
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java | 31 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java | 22 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java | 131 +++++++---
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/AutodiscoveryQueueDataSource.java | 61 ++--
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java | 12
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java | 38 ++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/MeasurementUtility.java | 117 ++++++++
7 files changed, 334 insertions(+), 78 deletions(-)
New commits:
commit e3467c9c4e144cf4f1859fdce25711b6239c2783
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Mon Sep 13 09:00:28 2010 -0400
enable server side for autodiscovery and some cleanup.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java
index e66f091..8159d23 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java
@@ -35,6 +35,7 @@ import org.rhq.enterprise.gui.coregui.client.dashboard.CustomSettingsPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.discovery.AutodiscoveryQueueDataSource;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.discovery.ResourceAutodiscoveryView;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
@@ -54,6 +55,15 @@ public class AutodiscoveryPortlet extends ResourceAutodiscoveryView implements C
super(locatorId, true);
}
+ @Override
+ protected void onInit() {
+ super.onInit();
+ //initialize the datasource to include Portlet instance
+ if (getTreeGrid() != null) {
+ getTreeGrid().setDataSource(new AutodiscoveryQueueDataSource(this));
+ }
+ }
+
/** Implement configure action.
*/
@Override
@@ -63,9 +73,9 @@ public class AutodiscoveryPortlet extends ResourceAutodiscoveryView implements C
//retrieve and translate to int
String retrieved = storedPortlet.getConfiguration().getSimple(AUTODISCOVERY_PLATFORM_MAX).getStringValue();
if (retrieved.equals(unlimited)) {
- maximumPlatformsToDisplay = -1;
+ setMaximumPlatformsToDisplay(-1);
} else {
- maximumPlatformsToDisplay = Integer.parseInt(retrieved);
+ setMaximumPlatformsToDisplay(Integer.parseInt(retrieved));
}
} else {//create setting
storedPortlet.getConfiguration().put(new PropertySimple(AUTODISCOVERY_PLATFORM_MAX, defaultValue));
@@ -153,4 +163,12 @@ public class AutodiscoveryPortlet extends ResourceAutodiscoveryView implements C
return new AutodiscoveryPortlet(locatorId);
}
}
+
+ public int getMaximumPlatformsToDisplay() {
+ return maximumPlatformsToDisplay;
+ }
+
+ public void setMaximumPlatformsToDisplay(int maximumPlatformsToDisplay) {
+ this.maximumPlatformsToDisplay = maximumPlatformsToDisplay;
+ }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/AutodiscoveryQueueDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/AutodiscoveryQueueDataSource.java
index 01a5ad3..63ed782 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/AutodiscoveryQueueDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/AutodiscoveryQueueDataSource.java
@@ -20,7 +20,6 @@ package org.rhq.enterprise.gui.coregui.client.inventory.resource.discovery;
import java.util.ArrayList;
import java.util.Date;
-import java.util.EnumSet;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
@@ -40,6 +39,8 @@ import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageOrdering;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.queue.AutodiscoveryPortlet;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGWTServiceAsync;
@@ -48,15 +49,20 @@ import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGWTServiceAsync;
*/
public class AutodiscoveryQueueDataSource extends DataSource {
-
+ private Portlet portlet = null;
+ private int unlimited = -1;
private ResourceGWTServiceAsync resourceService = GWTServiceLookup.getResourceService();
+ public AutodiscoveryQueueDataSource(Portlet portlet) {
+ this();
+ this.portlet = portlet;
+ }
+
public AutodiscoveryQueueDataSource() {
setClientOnly(false);
setDataProtocol(DSProtocol.CLIENTCUSTOM);
setDataFormat(DSDataFormat.CUSTOM);
-
DataSourceTextField idField = new DataSourceTextField("id", "ID");
idField.setPrimaryKey(true);
@@ -75,7 +81,8 @@ public class AutodiscoveryQueueDataSource extends DataSource {
DataSourceTextField statusField = new DataSourceTextField("status", "Inventory Status");
- setFields(idField, parentIdField, resourceNameField, resourceKeyField, resourceTypeField, descriptionField, statusField, timestampField);
+ setFields(idField, parentIdField, resourceNameField, resourceKeyField, resourceTypeField, descriptionField,
+ statusField, timestampField);
}
protected Object transformRequest(DSRequest request) {
@@ -84,17 +91,16 @@ public class AutodiscoveryQueueDataSource extends DataSource {
// Asume success
response.setStatus(0);
switch (request.getOperationType()) {
- case FETCH:
- executeFetch(request, response);
- break;
- default:
- break;
+ case FETCH:
+ executeFetch(request, response);
+ break;
+ default:
+ break;
}
return request.getData();
}
-
protected void executeFetch(final DSRequest request, final DSResponse response) {
PageControl pc = getPageControl(request);
@@ -114,21 +120,18 @@ public class AutodiscoveryQueueDataSource extends DataSource {
statuses.add(InventoryStatus.NEW);
}
+ resourceService.getQueuedPlatformsAndServers(statuses, pc, new AsyncCallback<Map<Resource, List<Resource>>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to load inventory discovery queue", caught);
+ }
- resourceService.getQueuedPlatformsAndServers(statuses, pc,
- new AsyncCallback<Map<Resource, List<Resource>>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to load inventory discovery queue", caught);
- }
-
- public void onSuccess(Map<Resource, List<Resource>> result) {
- response.setData(buildNodes(result));
- processResponse(request.getRequestId(), response);
- }
- });
+ public void onSuccess(Map<Resource, List<Resource>> result) {
+ response.setData(buildNodes(result));
+ processResponse(request.getRequestId(), response);
+ }
+ });
}
-
private TreeNode[] buildNodes(Map<Resource, List<Resource>> result) {
ArrayList<ResourceTreeNode> nodes = new ArrayList<ResourceTreeNode>();
@@ -146,7 +149,6 @@ public class AutodiscoveryQueueDataSource extends DataSource {
return treeNodes;
}
-
/**
* Returns a prepopulated PageControl based on the provided DSRequest. This will set sort fields,
* pagination, but *not* filter fields.
@@ -157,10 +159,12 @@ public class AutodiscoveryQueueDataSource extends DataSource {
protected PageControl getPageControl(DSRequest request) {
// Initialize paging.
PageControl pageControl;
- if (request.getStartRow() == null || request.getEndRow() == null) {
- pageControl = new PageControl();
+ //retrieve portlet.configurationInformation
+ if ((this.portlet != null) || (this.portlet instanceof AutodiscoveryPortlet)) {//using default
+ AutodiscoveryPortlet settings = (AutodiscoveryPortlet) this.portlet;
+ pageControl = new PageControl(0, settings.getMaximumPlatformsToDisplay());
} else {
- pageControl = PageControl.getExplicitPageControl(request.getStartRow(), request.getEndRow() - request.getStartRow());
+ pageControl = new PageControl(0, unlimited);
}
// Initialize sorting.
@@ -177,7 +181,6 @@ public class AutodiscoveryQueueDataSource extends DataSource {
return pageControl;
}
-
public static class ResourceTreeNode extends TreeNode {
private Resource resource;
@@ -186,8 +189,8 @@ public class AutodiscoveryQueueDataSource extends DataSource {
this.resource = resource;
String id = String.valueOf(resource.getId());
- String parentId = resource.getParentResource() == null ? null
- : String.valueOf((resource.getParentResource().getId()));
+ String parentId = resource.getParentResource() == null ? null : String.valueOf((resource
+ .getParentResource().getId()));
setID(id);
setParentID(parentId);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java
index 2d81fe0..445d1cb 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java
@@ -22,6 +22,7 @@ import java.util.ArrayList;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.Criteria;
+import com.smartgwt.client.data.DataSource;
import com.smartgwt.client.types.SelectionAppearance;
import com.smartgwt.client.widgets.HTMLFlow;
import com.smartgwt.client.widgets.IButton;
@@ -57,6 +58,7 @@ public class ResourceAutodiscoveryView extends LocatableVLayout {
private boolean simple = false;
private TreeGrid treeGrid;
private ToolStrip footer;
+ private DataSource dataSource = null;
private ResourceGWTServiceAsync resourceService = GWTServiceLookup.getResourceService();
@@ -107,7 +109,7 @@ public class ResourceAutodiscoveryView extends LocatableVLayout {
treeGrid.setHeight100();
- treeGrid.setDataSource(new AutodiscoveryQueueDataSource());
+ treeGrid.setDataSource(dataSource = new AutodiscoveryQueueDataSource());
treeGrid.setAutoFetchData(true);
treeGrid.setResizeFieldsInRealTime(true);
@@ -230,4 +232,12 @@ public class ResourceAutodiscoveryView extends LocatableVLayout {
this.treeGrid.invalidateCache();
this.treeGrid.markForRedraw();
}
+
+ public DataSource getDataSource() {
+ return dataSource;
+ }
+
+ public TreeGrid getTreeGrid() {
+ return treeGrid;
+ }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/MeasurementUtility.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/MeasurementUtility.java
index bc72530..1dd89ce 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/MeasurementUtility.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/MeasurementUtility.java
@@ -1,5 +1,23 @@
package org.rhq.enterprise.gui.coregui.client.util;
+/*
+ * 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.
+ */
import java.util.ArrayList;
import java.util.List;
commit 3bd640d779cbd010aa70fa13a81a54598ed78ada
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Sun Sep 12 21:23:06 2010 -0400
add footer for portlet and port of measurement utility.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
index f30ab10..0d4e6d6 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
@@ -77,12 +77,13 @@ public class Table extends LocatableHLayout {
private TableFilter filterForm;
private ListGrid listGrid;
private ToolStrip footer;
- private Label tableInfo;
+ protected Label tableInfo;
private List<String> headerIcons = new ArrayList<String>();
private boolean showHeader = true;
- private boolean showFooter = true;
+ protected boolean showFooter = true;
+ private boolean showFooterRefresh = true;
private String tableTitle;
private Criteria criteria;
@@ -122,7 +123,7 @@ public class Table extends LocatableHLayout {
private List<TableActionInfo> tableActions = new ArrayList<TableActionInfo>();
private boolean tableActionDisableOverride = false;
- private List<Canvas> extraWidgets = new ArrayList<Canvas>();
+ protected List<Canvas> extraWidgets = new ArrayList<Canvas>();
public Table(String locatorId) {
this(locatorId, null, null, null, null, true);
@@ -314,13 +315,15 @@ public class Table extends LocatableHLayout {
footer.addMember(new LayoutSpacer());
- IButton refreshButton = new LocatableIButton(extendLocatorId("Refresh"), "Refresh");
- refreshButton.addClickHandler(new ClickHandler() {
- public void onClick(ClickEvent clickEvent) {
- listGrid.invalidateCache();
- }
- });
- footer.addMember(refreshButton);
+ if (isShowFooterRefresh()) {
+ IButton refreshButton = new LocatableIButton(extendLocatorId("Refresh"), "Refresh");
+ refreshButton.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent clickEvent) {
+ listGrid.invalidateCache();
+ }
+ });
+ footer.addMember(refreshButton);
+ }
footer.addMember(tableInfo);
@@ -648,4 +651,12 @@ public class Table extends LocatableHLayout {
this.actionButton = actionButton;
}
}
+
+ public boolean isShowFooterRefresh() {
+ return showFooterRefresh;
+ }
+
+ public void setShowFooterRefresh(boolean showFooterRefresh) {
+ this.showFooterRefresh = showFooterRefresh;
+ }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java
index 815afd7..3faa954 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java
@@ -19,9 +19,14 @@ package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.problems
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+//import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.List;
+
import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.HTMLFlow;
+import com.smartgwt.client.widgets.Label;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.events.SubmitValuesEvent;
import com.smartgwt.client.widgets.form.events.SubmitValuesHandler;
@@ -34,11 +39,14 @@ import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
import org.rhq.core.domain.configuration.definition.PropertySimpleType;
import org.rhq.core.domain.dashboard.DashboardPortlet;
import org.rhq.enterprise.gui.coregui.client.components.table.Table;
+import org.rhq.enterprise.gui.coregui.client.components.table.TableWidget;
import org.rhq.enterprise.gui.coregui.client.dashboard.CustomSettingsPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow;
import org.rhq.enterprise.gui.coregui.client.resource.ProblemResourcesDataSource;
+import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
/**
* A view that displays a paginated table of Resources with alerts,
@@ -48,13 +56,13 @@ import org.rhq.enterprise.gui.coregui.client.resource.ProblemResourcesDataSource
*/
public class ProblemResourcesPortlet extends Table implements CustomSettingsPortlet {
+ //keys for smart gwt elements. should be unique
public static final String PROBLEM_RESOURCE_SHOW_HRS = "max-problems-query-span";
public static final String PROBLEM_RESOURCE_SHOW_MAX = "max-problems-shown";
public static final String KEY = "Has Alerts or Currently Unavailable";
private static final String TITLE = KEY;
- private int maximumProblemResourcesToDisplay = -1;
- private int maximumProblemResourcesWithinHours = -1;
private DashboardPortlet storedPortlet;
+ //constants
public static final String unlimited = "unlimited";
public static final String defaultValue = unlimited;
@@ -62,10 +70,13 @@ public class ProblemResourcesPortlet extends Table implements CustomSettingsPort
super(locatorId, TITLE, true);
setShowHeader(false);
- setShowFooter(false);
+ setShowFooter(true);
+ //disable footer refresh
+ setShowFooterRefresh(false);
setOverflow(Overflow.HIDDEN);
+ //insert the datasource
this.dataSource = new ProblemResourcesDataSource(this);
setDataSource(this.dataSource);
@@ -82,16 +93,18 @@ public class ProblemResourcesPortlet extends Table implements CustomSettingsPort
listGrid.setCellHeight(50);
//wrap to display disambiguation
listGrid.setWrapCells(true);
- listGrid.getField(ProblemResourcesDataSource.resource).setWidth("40%");
- listGrid.getField(ProblemResourcesDataSource.location).setWidth("40%");
- listGrid.getField(ProblemResourcesDataSource.alerts).setWidth("10%");
- listGrid.getField(ProblemResourcesDataSource.available).setWidth("10%");
+ addExtraWidget(new TimeRange(this.getLocatorId(), this));
}
}
//reference to datasource
private ProblemResourcesDataSource dataSource;
+ @Override
+ public ProblemResourcesDataSource getDataSource() {
+ return (ProblemResourcesDataSource) super.getDataSource();
+ }
+
/** Implement configure action.
*
*/
@@ -99,27 +112,39 @@ public class ProblemResourcesPortlet extends Table implements CustomSettingsPort
public void configure(PortletWindow portletWindow, DashboardPortlet storedPortlet) {
this.storedPortlet = storedPortlet;
- if (storedPortlet.getConfiguration().getSimple(PROBLEM_RESOURCE_SHOW_MAX) != null) {
+ int configuredValue = -1;
+
+ //determine configuration value for ProblemResourceShowMax
+ configuredValue = populateConfigurationValue(storedPortlet, PROBLEM_RESOURCE_SHOW_MAX, defaultValue);
+ getDataSource().setMaximumProblemResourcesToDisplay(configuredValue);
+
+ //determine configuration value for ProblemResourceShowHrs
+ configuredValue = populateConfigurationValue(storedPortlet, PROBLEM_RESOURCE_SHOW_HRS, defaultValue);
+ getDataSource().setMaximumProblemResourcesWithinHours(configuredValue);
+ }
+
+ /**Determine which configuration value to use given the property passed in.
+ *
+ * @param storedPortlet DashboardPortlet instance
+ * @param propertyKey Widget key
+ * @param defaultKeyValue default value to be used if property not yet set.
+ * @return int value of configuration, Ex. 1,5,10,unlimited where unlimited==-1.
+ */
+ private int populateConfigurationValue(DashboardPortlet storedPortlet, String propertyKey, String defaultKeyValue) {
+ int configuredValue;
+ if ((storedPortlet != null) && (storedPortlet.getConfiguration().getSimple(propertyKey) != null)) {
//retrieve and translate to int
- String retrieved = storedPortlet.getConfiguration().getSimple(PROBLEM_RESOURCE_SHOW_MAX).getStringValue();
+ String retrieved = storedPortlet.getConfiguration().getSimple(propertyKey).getStringValue();
if (retrieved.equals(unlimited)) {
- maximumProblemResourcesToDisplay = -1;
+ configuredValue = -1;
} else {
- maximumProblemResourcesToDisplay = Integer.parseInt(retrieved);
+ configuredValue = Integer.parseInt(retrieved);
}
- } else {//create setting
- storedPortlet.getConfiguration().put(new PropertySimple(PROBLEM_RESOURCE_SHOW_MAX, defaultValue));
- }
- if (storedPortlet.getConfiguration().getSimple(PROBLEM_RESOURCE_SHOW_HRS) != null) {
- String retrieved = storedPortlet.getConfiguration().getSimple(PROBLEM_RESOURCE_SHOW_HRS).getStringValue();
- if (retrieved.equals(unlimited)) {
- setMaximumProblemResourcesWithinHours(-1);
- } else {
- setMaximumProblemResourcesWithinHours(Integer.parseInt(retrieved));
- }
- } else {
- storedPortlet.getConfiguration().put(new PropertySimple(PROBLEM_RESOURCE_SHOW_HRS, defaultValue));
+ } else {//create setting if not already there.
+ storedPortlet.getConfiguration().put(new PropertySimple(propertyKey, defaultKeyValue));
+ configuredValue = -1;
}
+ return configuredValue;
}
@Override
@@ -198,6 +223,7 @@ public class ProblemResourcesPortlet extends Table implements CustomSettingsPort
storedPortlet.getConfiguration().put(
new PropertySimple(PROBLEM_RESOURCE_SHOW_HRS, form.getValue(PROBLEM_RESOURCE_SHOW_HRS)));
}
+ refresh();
}
});
@@ -224,19 +250,62 @@ public class ProblemResourcesPortlet extends Table implements CustomSettingsPort
return definition;
}
- public int getMaximumProblemResourcesToDisplay() {
- return maximumProblemResourcesToDisplay;
+ protected void refreshTableInfo() {
+ if (showFooter) {
+ long begin = 0;
+ List<Long> bounds = MeasurementUtility.calculateTimeFrame(getDataSource()
+ .getMaximumProblemResourcesWithinHours(), MeasurementUtility.UNIT_HOURS);
+ begin = bounds.get(0);
+ long end = bounds.get(1);
+
+ //if range spans greater than year then change formatter.
+ if ((end - begin) > MeasurementUtility.ONE_YEAR) {
+ timeRange = new String[] { MeasurementUtility.getDateTimeYearFormatter().format(new Date(begin)),
+ MeasurementUtility.getDateTimeYearFormatter().format(new Date(end)) };
+ } else {
+ timeRange = new String[] { MeasurementUtility.getDateTimeFormatter().format(new Date(begin)),
+ MeasurementUtility.getDateTimeFormatter().format(new Date(end)) };
+ }
+ for (Canvas extraWidget : extraWidgets) {
+ if (extraWidget instanceof TableWidget) {
+ ((TableWidget) extraWidget).refresh(getListGrid());
+ }
+ }
+ //remove selected count as portlet is view only. Selection not used.
+ this.tableInfo.setContents("Total: " + getListGrid().getTotalRows());
+ }
+ }
+
+ private String[] timeRange = null;
+
+ public String[] getTimeRange() {
+ return timeRange;
}
- public void setMaximumProblemResourcesToDisplay(int maxPerRow) {
- this.maximumProblemResourcesToDisplay = maxPerRow;
+}
+
+/**Construct table widget Label to display timerange settings used with latest datasource query.
+ *
+ * @author spinder
+ */
+class TimeRange extends LocatableHLayout implements TableWidget {
+ private Label label = new Label();
+ private ProblemResourcesPortlet portlet = null;
+
+ public TimeRange(String locatorId, ProblemResourcesPortlet problemResourcesPortlet) {
+ super(locatorId);
+ this.portlet = problemResourcesPortlet;
}
- public void setMaximumProblemResourcesWithinHours(int maximumProblemResourcesWithinHours) {
- this.maximumProblemResourcesWithinHours = maximumProblemResourcesWithinHours;
+ @Override
+ public void refresh(ListGrid listGrid) {
+ this.label.setWidth(400);
+ this.label.setContents("From " + portlet.getTimeRange()[0] + " to " + portlet.getTimeRange()[1]);
}
- public int getMaximumProblemResourcesWithinHours() {
- return maximumProblemResourcesWithinHours;
+ @Override
+ protected void onDraw() {
+ super.onDraw();
+ addMember(this.label);
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java
index 7597d13..38c316b 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java
@@ -52,6 +52,10 @@ public class ProblemResourcesDataSource extends RPCDataSource<DisambiguationRepo
public static final String alerts = "alerts";
public static final String available = "available";
private Portlet portlet = null;
+ private long oldestDate = -1;
+ //configure elements
+ private int maximumProblemResourcesToDisplay = -1;
+ private int maximumProblemResourcesWithinHours = -1;
/** Build list of fields for the datasource and then adds them to it.
* @param problemResourcesPortlet
@@ -108,13 +112,13 @@ public class ProblemResourcesDataSource extends RPCDataSource<DisambiguationRepo
ProblemResourcesPortlet problemPortlet = (ProblemResourcesPortlet) this.portlet;
//populate criteria with portlet preferences defined.
if (problemPortlet != null) {
- if (problemPortlet.getMaximumProblemResourcesToDisplay() > 0) {
- maxItems = problemPortlet.getMaximumProblemResourcesToDisplay();
+ if (getMaximumProblemResourcesToDisplay() > 0) {
+ maxItems = getMaximumProblemResourcesToDisplay();
}
//define the time window
- if (problemPortlet.getMaximumProblemResourcesWithinHours() > 0) {
- ctime = System.currentTimeMillis()
- - (problemPortlet.getMaximumProblemResourcesWithinHours() * 60 * 60 * 1000);
+ if (getMaximumProblemResourcesWithinHours() > 0) {
+ ctime = System.currentTimeMillis() - (getMaximumProblemResourcesWithinHours() * 60 * 60 * 1000);
+ setOldestDate(ctime);
}
}
}
@@ -200,4 +204,28 @@ public class ProblemResourcesDataSource extends RPCDataSource<DisambiguationRepo
public DisambiguationReport<ProblemResourceComposite> copyValues(ListGridRecord from) {
throw new UnsupportedOperationException("ProblemResource data is read only");
}
+
+ public long getOldestDate() {
+ return oldestDate;
+ }
+
+ public void setOldestDate(long oldestDate) {
+ this.oldestDate = oldestDate;
+ }
+
+ public int getMaximumProblemResourcesToDisplay() {
+ return maximumProblemResourcesToDisplay;
+ }
+
+ public void setMaximumProblemResourcesToDisplay(int maxPerRow) {
+ this.maximumProblemResourcesToDisplay = maxPerRow;
+ }
+
+ public void setMaximumProblemResourcesWithinHours(int maximumProblemResourcesWithinHours) {
+ this.maximumProblemResourcesWithinHours = maximumProblemResourcesWithinHours;
+ }
+
+ public int getMaximumProblemResourcesWithinHours() {
+ return maximumProblemResourcesWithinHours;
+ }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/MeasurementUtility.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/MeasurementUtility.java
new file mode 100644
index 0000000..bc72530
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/MeasurementUtility.java
@@ -0,0 +1,99 @@
+package org.rhq.enterprise.gui.coregui.client.util;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.google.gwt.i18n.client.DateTimeFormat;
+
+public class MeasurementUtility {
+
+ private static DateTimeFormat formatter = DateTimeFormat.getFormat("MMM d, hh:mm a");
+ private static DateTimeFormat formatterYear = DateTimeFormat.getFormat("MMM d, yyyy hh:mm a");
+
+ //Time constants
+ public static final int UNIT_COLLECTION_POINTS = 1;
+ public static final int UNIT_MINUTES = 2;
+ public static final int UNIT_HOURS = 3;
+ public static final int UNIT_DAYS = 4;
+ public static final int UNIT_WEEKS = 5;
+ /*
+ * show units in terms of milliseconds
+ */
+ public static final long MINUTES = 60000;
+ public static final long HOURS = 3600000;
+ public static final long DAYS = 86400000;
+ public static final long WEEKS = 604800000;
+
+ /**
+ * five minutes in millisecond increments
+ */
+ public static final long FIVE_MINUTES = 300000;
+ public static final long ONE_YEAR = WEEKS * 52;
+
+ /**
+ * Method calculateTimeFrame
+ * <p/>
+ * Returns a two element<code>List</code> of <code>Long</code> objects representing the begin and end times (in
+ * milliseconds since the epoch) of the timeframe. Returns null instead if the time unit is indicated as
+ * <code>UNIT_COLLECTION_POINTS</code>. Ported to GWT from MeasurementUtils(i:server side dep
+ * ii:old DateFormat doesn't play well with GWT).
+ *
+ * @param lastN the number of time units in the time frame
+ * @param unit the unit of time (as defined by <code>UNIT_*</code> constants
+ * @return List
+ */
+ public static List<Long> calculateTimeFrame(int lastN, int unit) {
+ List<Long> l = new ArrayList<Long>(0);
+ if (unit == UNIT_COLLECTION_POINTS) {
+ return null;
+ }
+
+ long now = System.currentTimeMillis();
+
+ long retrospective = lastN;
+
+ switch (unit) {
+ case UNIT_WEEKS:
+ retrospective *= WEEKS;
+ break;
+ case UNIT_MINUTES:
+ retrospective *= MINUTES;
+ break;
+ case UNIT_HOURS:
+ retrospective *= HOURS;
+ break;
+ case UNIT_DAYS:
+ retrospective *= DAYS;
+ break;
+ default:
+ retrospective = -1;
+ break;
+ }
+
+ if (retrospective < 0) {//translate unlimited hrs to 0 time.
+ retrospective = now;
+ }
+
+ l.add(now - retrospective);
+ l.add(now);
+
+ return l;
+ }
+
+ /**Utility to return shared DateTimeFormat("MMM d, hh:mm a");
+ *
+ * @return DateTimeFormat
+ */
+ public static DateTimeFormat getDateTimeFormatter() {
+ return formatter;
+ }
+
+ /**Utility to return shared DateTimeFormat("MMM d, yyyy hh:mm a");
+ *
+ * @return DateTimeFormat
+ */
+ public static DateTimeFormat getDateTimeYearFormatter() {
+ return formatterYear;
+ }
+
+}
13 years, 8 months
[rhq] modules/enterprise
by ips
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ViewId.java | 7
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/AbstractTwoLevelTabSetView.java | 198 +++++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java | 199 ++--------
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java | 195 ++-------
4 files changed, 294 insertions(+), 305 deletions(-)
New commits:
commit 4b78144546207ab92eddf048699a3a46fbb1434b
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Sat Sep 11 16:29:57 2010 -0400
extract superclass for resource and group detail view classes
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ViewId.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ViewId.java
index 1302774..cba747e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ViewId.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ViewId.java
@@ -35,7 +35,7 @@ public class ViewId {
public ViewId(String path, Breadcrumb... breadcrumbs) {
this.path = path;
if ( breadcrumbs != null) {
- this.breadcrumbs = Arrays.asList(breadcrumbs);
+ this.breadcrumbs = Arrays.asList(breadcrumbs);
} else {
this.breadcrumbs = new ArrayList<Breadcrumb>();
}
@@ -57,6 +57,11 @@ public class ViewId {
}
@Override
+ public String toString() {
+ return this.path;
+ }
+
+ @Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/AbstractTwoLevelTabSetView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/AbstractTwoLevelTabSetView.java
new file mode 100644
index 0000000..bdd1981
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/AbstractTwoLevelTabSetView.java
@@ -0,0 +1,198 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.inventory.common.detail;
+
+import com.google.gwt.user.client.History;
+import com.smartgwt.client.types.Side;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.layout.Layout;
+import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.ViewPath;
+import org.rhq.enterprise.gui.coregui.client.components.tab.SubTab;
+import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTab;
+import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTabSelectedEvent;
+import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTabSelectedHandler;
+import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTabSet;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+
+import java.util.List;
+
+/**
+ * @author Greg Hinkle
+ * @author Ian Springer
+ */
+public abstract class AbstractTwoLevelTabSetView<T, U extends Layout> extends LocatableVLayout
+ implements BookmarkableView, TwoLevelTabSelectedHandler {
+ private String baseViewPath;
+ private TwoLevelTabSet tabSet;
+ private String tabName;
+ private String subTabName;
+ private U titleBar;
+
+ public AbstractTwoLevelTabSetView(String locatorId, String baseViewPath) {
+ super(locatorId);
+ this.baseViewPath = baseViewPath;
+
+ setWidth100();
+ setHeight100();
+
+ this.titleBar = createTitleBar();
+ addMember(this.titleBar);
+
+ this.tabSet = new TwoLevelTabSet(extendLocatorId("TabSet"));
+ this.tabSet.setTabBarPosition(Side.TOP);
+ this.tabSet.setWidth100();
+ this.tabSet.setHeight100();
+ this.tabSet.setEdgeMarginSize(0);
+ this.tabSet.setEdgeSize(0);
+
+ List<TwoLevelTab> tabsList = createTabs();
+ this.tabSet.setTabs(tabsList.toArray(new TwoLevelTab[tabsList.size()]));
+
+ this.tabSet.addTwoLevelTabSelectedHandler(this);
+
+ addMember(this.tabSet);
+ }
+
+ // ------------------ Abstract Methods --------------------
+ public abstract Integer getSelectedItemId();
+
+ protected abstract U createTitleBar();
+
+ protected abstract List<TwoLevelTab> createTabs();
+
+ protected abstract void loadSelectedItem(int itemId, ViewPath viewPath);
+
+ protected abstract void updateTabContent(T selectedItem);
+ // ---------------------------------------------------------
+
+ protected U getTitleBar() {
+ return this.titleBar;
+ }
+
+ public void onTabSelected(TwoLevelTabSelectedEvent tabSelectedEvent) {
+ //CoreGUI.printWidgetTree();
+
+ if (getSelectedItemId() == null) {
+ // History.fireCurrentHistoryState();
+ } else {
+ // Switch tabs directly, rather than letting the history framework do it, to avoid redrawing the outer views.
+ // selectSubTabByTitle(tabSelectedEvent.getId(), tabSelectedEvent.getSubTabId());
+ String tabPath = "/" + tabSelectedEvent.getId() + "/" + tabSelectedEvent.getSubTabId();
+ String path = this.baseViewPath + "/" + getSelectedItemId() + tabPath;
+
+ // If the tab that was selected is not already the current history item, the user clicked on the tab, rather
+ // than going directly to the tab's URL. In this case, fire a history event to go to the tab and make it the
+ // current history item.
+ if (!History.getToken().equals(path)) {
+ History.newItem(path, true);
+ }
+ }
+ }
+
+ public void renderView(ViewPath viewPath) {
+ // e.g. #Resource/10010/Summary/Overview
+ // ^ current path
+ int id = Integer.parseInt(viewPath.getCurrent().getPath());
+ viewPath.next();
+
+ if (!viewPath.isEnd()) {
+ // e.g. #Resource/10010/Summary/Overview
+ // ^ current path
+ this.tabName = viewPath.getCurrent().getPath();
+ viewPath.next();
+ if (!viewPath.isEnd()) {
+ // e.g. #Resource/10010/Summary/Overview
+ // ^ current path
+ this.subTabName = viewPath.getCurrent().getPath();
+ viewPath.next();
+ } else {
+ this.subTabName = null;
+ }
+ } else {
+ this.tabName = null;
+ }
+
+ if (getSelectedItemId() == null || getSelectedItemId() != id) {
+ // A different Resource or first load - go get data.
+ loadSelectedItem(id, viewPath);
+ } else {
+ // Same Resource - just switch tabs.
+ selectTab(this.tabName, this.subTabName, viewPath);
+ }
+ }
+
+ /**
+ * Select the tab/subtab with the specified titles (e.g. "Monitoring", "Graphs").
+ *
+ * @param tabTitle the title of the tab to select - if null, the default tab (the leftmost non-disabled one) will be selected
+ * @param subtabTitle the title of the subtab to select - if null, the default subtab (the leftmost non-disabled one) will be selected
+ * @param viewPath the view path, which may have additional view items to be rendered
+ */
+ public void selectTab(String tabTitle, String subtabTitle, ViewPath viewPath) {
+ try {
+ TwoLevelTab tab = (tabTitle != null) ? this.tabSet.getTabByTitle(tabTitle) :
+ this.tabSet.getDefaultTab();
+ if (tab == null || tab.getDisabled()) {
+ CoreGUI.getErrorHandler().handleError("Invalid tab name: " + tabTitle);
+ // TODO: Should we fire a history event here to redirect to a valid bookmark?
+ tab = this.tabSet.getDefaultTab();
+ if (tab == null) {
+ throw new IllegalStateException("No default tab is defined.");
+ }
+ subtabTitle = null;
+ }
+ // Do *not* select the tab and trigger the tab selected event until the subtab has been selected first.
+
+ SubTab subtab = (subtabTitle != null) ? tab.getSubTabByTitle(subtabTitle) : tab.getDefaultSubTab();
+ if (subtab == null || tab.getLayout().isDisabled()) {
+ CoreGUI.getErrorHandler().handleError("Invalid subtab name: " + subtabTitle);
+ // TODO: Should we fire a history event here to redirect to a valid bookmark?
+ subtab = tab.getLayout().getDefaultSubTab();
+ }
+ tab.getLayout().selectSubTab(subtab);
+
+ // Now that the subtab has been selected, select the tab (this will cause a tab selected event to fire).
+ this.tabSet.selectTab(tab);
+
+ // Handle any remaining view items (e.g. id of a selected item in a subtab that contains a Master-Details view).
+ Canvas subView = subtab.getCanvas();
+ if (subView instanceof BookmarkableView) {
+ ((BookmarkableView) subView).renderView(viewPath);
+ }
+
+ this.tabSet.markForRedraw();
+ } catch (Exception e) {
+ System.err.println("Failed to select tab " + tabTitle + "/" + subtabTitle + ": " + e);
+ }
+ }
+
+ public TwoLevelTabSet getTabSet() {
+ return tabSet;
+ }
+
+ public String getTabName() {
+ return tabName;
+ }
+
+ public String getSubTabName() {
+ return subTabName;
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
index 9d289ca..b51bc00 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
@@ -18,13 +18,12 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail;
+import java.util.ArrayList;
import java.util.EnumSet;
+import java.util.List;
import java.util.Set;
-import com.google.gwt.user.client.History;
import com.google.gwt.user.client.rpc.AsyncCallback;
-import com.smartgwt.client.types.Side;
-import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.tab.Tab;
import org.rhq.core.domain.authz.Permission;
@@ -38,23 +37,19 @@ import org.rhq.core.domain.resource.group.GroupCategory;
import org.rhq.core.domain.resource.group.ResourceGroup;
import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite;
import org.rhq.core.domain.util.PageList;
-import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.ViewPath;
import org.rhq.enterprise.gui.coregui.client.components.FullHTMLPane;
import org.rhq.enterprise.gui.coregui.client.components.tab.SubTab;
import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTab;
-import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTabSelectedEvent;
-import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTabSelectedHandler;
-import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTabSet;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.AbstractTwoLevelTabSetView;
import org.rhq.enterprise.gui.coregui.client.inventory.common.event.EventCompositeHistoryView;
import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.schedules.SchedulesView;
import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.traits.TraitsView;
import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.summary.OverviewView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceSearchView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
/**
* Right panel of the group view.
@@ -62,13 +57,14 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
* @author Greg Hinkle
* @author Ian Springer
*/
-public class ResourceGroupDetailView extends LocatableVLayout implements BookmarkableView, TwoLevelTabSelectedHandler {
- private static final String DEFAULT_TAB_NAME = "Inventory";
+public class ResourceGroupDetailView extends AbstractTwoLevelTabSetView<ResourceGroupComposite, ResourceGroupTitleBar> {
+ private static final String BASE_VIEW_PATH = "ResourceGroup";
- private int groupId;
+ private Integer groupId;
private ResourceGroupComposite groupComposite;
private ResourcePermission permissions;
+ // tabs
private TwoLevelTab summaryTab;
private TwoLevelTab monitoringTab;
private TwoLevelTab inventoryTab;
@@ -77,8 +73,7 @@ public class ResourceGroupDetailView extends LocatableVLayout implements Bookmar
private TwoLevelTab configurationTab;
private TwoLevelTab eventsTab;
- private TwoLevelTabSet topTabSet;
-
+ // subtabs
private SubTab summaryOverview;
private SubTab summaryTimeline;
private SubTab monitorGraphs;
@@ -96,32 +91,30 @@ public class ResourceGroupDetailView extends LocatableVLayout implements Bookmar
private SubTab configHistory;
private SubTab eventHistory;
- private ResourceGroupTitleBar titleBar;
-
- private String tabName;
- private String subTabName;
-
public ResourceGroupDetailView(String locatorId) {
- super(locatorId);
+ super(locatorId, BASE_VIEW_PATH);
+ }
- setWidth100();
- setHeight100();
+ @Override
+ public Integer getSelectedItemId() {
+ return this.groupId;
+ }
- // The Tabs section
+ @Override
+ protected ResourceGroupTitleBar createTitleBar() {
+ return new ResourceGroupTitleBar(getLocatorId());
+ }
- topTabSet = new TwoLevelTabSet(getLocatorId());
- topTabSet.setTabBarPosition(Side.TOP);
- topTabSet.setWidth100();
- topTabSet.setHeight100();
- topTabSet.setEdgeMarginSize(0);
- topTabSet.setEdgeSize(0);
+ protected List<TwoLevelTab> createTabs() {
+ List<TwoLevelTab> tabs = new ArrayList<TwoLevelTab>();
- summaryTab = new TwoLevelTab(topTabSet.extendLocatorId("Summary"), "Summary", "/images/icons/Service_up_16.png");
+ summaryTab = new TwoLevelTab(getTabSet().extendLocatorId("Summary"), "Summary", "/images/icons/Service_up_16.png");
summaryOverview = new SubTab(summaryTab.extendLocatorId("Overview"), "Overview", null);
summaryTimeline = new SubTab(summaryTab.extendLocatorId("Timeline"), "Timeline", null);
summaryTab.registerSubTabs(summaryOverview, summaryTimeline);
+ tabs.add(summaryTab);
- monitoringTab = new TwoLevelTab(topTabSet.extendLocatorId("Monitoring"), "Monitoring",
+ monitoringTab = new TwoLevelTab(getTabSet().extendLocatorId("Monitoring"), "Monitoring",
"/images/icons/Monitor_grey_16.png");
monitorGraphs = new SubTab(monitoringTab.extendLocatorId("Graphs"), "Graphs", null);
monitorTables = new SubTab(monitoringTab.extendLocatorId("Tables"), "Tables", null);
@@ -130,54 +123,49 @@ public class ResourceGroupDetailView extends LocatableVLayout implements Bookmar
monitorSched = new SubTab(monitoringTab.extendLocatorId("Schedules"), "Schedules", null);
monitorCallTime = new SubTab(monitoringTab.extendLocatorId("CallTime"), "Call Time", null);
monitoringTab.registerSubTabs(monitorGraphs, monitorTables, monitorTraits, monitorSched, monitorCallTime);
+ tabs.add(monitoringTab);
- inventoryTab = new TwoLevelTab(topTabSet.extendLocatorId("Inventory"), "Inventory",
+ inventoryTab = new TwoLevelTab(getTabSet().extendLocatorId("Inventory"), "Inventory",
"/images/icons/Inventory_grey_16.png");
inventoryMembers = new SubTab(inventoryTab.extendLocatorId("Members"), "Members", null);
inventoryConn = new SubTab(inventoryTab.extendLocatorId("ConnectionSettings"), "Connection Settings", null);
inventoryTab.registerSubTabs(this.inventoryMembers, this.inventoryConn);
+ tabs.add(inventoryTab);
- operationsTab = new TwoLevelTab(topTabSet.extendLocatorId("Operations"), "Operations",
+ operationsTab = new TwoLevelTab(getTabSet().extendLocatorId("Operations"), "Operations",
"/images/icons/Operation_grey_16.png");
this.opHistory = new SubTab(operationsTab.extendLocatorId("History"), "History", null);
this.opSched = new SubTab(operationsTab.extendLocatorId("Scheduled"), "Scheduled", null);
operationsTab.registerSubTabs(this.opHistory, this.opSched);
+ tabs.add(operationsTab);
- alertsTab = new TwoLevelTab(topTabSet.extendLocatorId("Alerts"), "Alerts", "/images/icons/Alert_grey_16.png");
+ alertsTab = new TwoLevelTab(getTabSet().extendLocatorId("Alerts"), "Alerts", "/images/icons/Alert_grey_16.png");
this.alertHistory = new SubTab(alertsTab.extendLocatorId("History"), "History", null);
this.alertDef = new SubTab(alertsTab.extendLocatorId("Definitions"), "Definitions", null);
alertsTab.registerSubTabs(alertHistory, alertDef);
+ tabs.add(alertsTab);
- configurationTab = new TwoLevelTab(topTabSet.extendLocatorId("Configuration"), "Configuration",
+ configurationTab = new TwoLevelTab(getTabSet().extendLocatorId("Configuration"), "Configuration",
"/images/icons/Configure_grey_16.png");
this.configCurrent = new SubTab(configurationTab.extendLocatorId("Current"), "Current", null);
this.configHistory = new SubTab(configurationTab.extendLocatorId("History"), "History", null);
configurationTab.registerSubTabs(this.configCurrent, this.configHistory);
+ tabs.add(configurationTab);
- eventsTab = new TwoLevelTab(topTabSet.extendLocatorId("Events"), "Events", "/images/icons/Events_grey_16.png");
+ eventsTab = new TwoLevelTab(getTabSet().extendLocatorId("Events"), "Events", "/images/icons/Events_grey_16.png");
this.eventHistory = new SubTab(eventsTab.extendLocatorId("History"), "History", null);
eventsTab.registerSubTabs(eventHistory);
+ tabs.add(eventsTab);
- topTabSet.setTabs(summaryTab, monitoringTab, inventoryTab, operationsTab, alertsTab, configurationTab,
- eventsTab);
-
- topTabSet.addTwoLevelTabSelectedHandler(this);
-
- titleBar = new ResourceGroupTitleBar(getLocatorId());
- addMember(titleBar);
-
- addMember(topTabSet);
-
- // CoreGUI.addBreadCrumb(getPlace());
+ return tabs;
}
- public void updateDetailViews(ResourceGroupComposite groupComposite) {
-
+ protected void updateTabContent(ResourceGroupComposite groupComposite) {
this.groupComposite = groupComposite;
- this.titleBar.setGroup(groupComposite.getResourceGroup());
+ getTitleBar().setGroup(groupComposite.getResourceGroup());
- for (Tab top : this.topTabSet.getTabs()) {
+ for (Tab top : this.getTabSet().getTabs()) {
((TwoLevelTab) top).getLayout().destroyViews();
}
@@ -218,7 +206,6 @@ public class ResourceGroupDetailView extends LocatableVLayout implements Bookmar
updateTabEnablement();
}
-
private void updateTabEnablement() {
GroupCategory groupCategory = groupComposite.getResourceGroup().getGroupCategory();
Set<ResourceTypeFacet> facets = groupComposite.getResourceFacets().getFacets();
@@ -235,74 +222,22 @@ public class ResourceGroupDetailView extends LocatableVLayout implements Bookmar
// Monitoring and Alerts tabs are always enabled for compatible groups and always disabled for mixed groups.
// TODO (ips): Break out mixed groups into a separate view.
- this.topTabSet.setTabEnabled(this.monitoringTab, groupCategory == GroupCategory.COMPATIBLE);
- this.topTabSet.setTabEnabled(this.alertsTab, groupCategory == GroupCategory.COMPATIBLE);
+ getTabSet().setTabEnabled(this.monitoringTab, groupCategory == GroupCategory.COMPATIBLE);
+ getTabSet().setTabEnabled(this.alertsTab, groupCategory == GroupCategory.COMPATIBLE);
// Operations tab is only enabled for compatible groups of a type that supports the Operations facet.
- this.topTabSet.setTabEnabled(this.operationsTab, facets.contains(ResourceTypeFacet.OPERATION));
+ getTabSet().setTabEnabled(this.operationsTab, facets.contains(ResourceTypeFacet.OPERATION));
// Configuration tab is only enabled for compatible groups of a type that supports the Configuration facet
// and when the current user has the CONFIGURE_READ permission.
- this.topTabSet.setTabEnabled(this.configurationTab, facets.contains(ResourceTypeFacet.CONFIGURATION)
+ getTabSet().setTabEnabled(this.configurationTab, facets.contains(ResourceTypeFacet.CONFIGURATION)
&& this.permissions.isConfigureRead());
// Events tab is only enabled for compatible groups of a type that supports the Events facet.
- this.topTabSet.setTabEnabled(this.eventsTab, facets.contains(ResourceTypeFacet.EVENT));
- }
-
- public void onTabSelected(TwoLevelTabSelectedEvent tabSelectedEvent) {
- //CoreGUI.printWidgetTree();
-
- if (this.groupComposite == null) {
- // History.fireCurrentHistoryState();
- } else {
- String tabPath = "/" + tabSelectedEvent.getId() + "/" + tabSelectedEvent.getSubTabId();
- String path = "ResourceGroup/" + this.groupComposite.getResourceGroup().getId() + tabPath;
-
- // If the tab that was selected is not already the current history item, the user clicked on the tab, rather
- // than going directly to the tab's URL. In this case, fire a history event to go to the tab and make it the
- // current history item.
- if (!History.getToken().equals(path)) {
- //System.out.println("Firing History event [" + path + "]...");
- History.newItem(path, true);
- }
- }
+ getTabSet().setTabEnabled(this.eventsTab, facets.contains(ResourceTypeFacet.EVENT));
}
- public void renderView(ViewPath viewPath) {
- // e.g. #ResourceGroup/10010/Summary/Overview
- // ^ current path
- int groupId = Integer.parseInt(viewPath.getCurrent().getPath());
- viewPath.next();
-
- if (!viewPath.isEnd()) {
- // e.g. #ResourceGroup/10010/Summary/Overview
- // ^ current path
- this.tabName = viewPath.getCurrent().getPath();
- viewPath.next();
- if (!viewPath.isEnd()) {
- // e.g. #ResourceGroup/10010/Summary/Overview
- // ^ current path
- this.subTabName = viewPath.getCurrent().getPath();
- viewPath.next();
- } else {
- this.subTabName = null;
- }
- } else {
- this.tabName = null;
- }
-
- if (this.groupId != groupId) {
- // A different group or first load - go get data.
- loadSelectedGroup(groupId, viewPath);
- } else {
- // Same group - just switch tabs.
- selectTab(this.tabName, this.subTabName, viewPath);
- }
-
- }
-
- public void loadSelectedGroup(final int groupId, final ViewPath viewPath) {
+ protected void loadSelectedItem(final int groupId, final ViewPath viewPath) {
this.groupId = groupId;
ResourceGroupCriteria criteria = new ResourceGroupCriteria();
@@ -348,8 +283,8 @@ public class ResourceGroupDetailView extends LocatableVLayout implements Bookmar
public void onSuccess(Set<Permission> result) {
ResourceGroupDetailView.this.permissions = new ResourcePermission(result);
- updateDetailViews(groupComposite);
- selectTab(tabName, subTabName, viewPath);
+ updateTabContent(groupComposite);
+ selectTab(getTabName(), getSubTabName(), viewPath);
}
});
}
@@ -357,48 +292,6 @@ public class ResourceGroupDetailView extends LocatableVLayout implements Bookmar
}
}
- /**
- * Select the tab/subtab with the specified titles (e.g. "Monitoring", "Graphs").
- *
- * @param tabTitle the title of the tab to select - if null, the default tab (the leftmost non-disabled one) will be selected
- * @param subtabTitle the title of the subtab to select - if null, the default subtab (the leftmost non-disabled one) will be selected
- * @param viewPath the view path, which may have additional view items to be rendered
- */
- public void selectTab(String tabTitle, String subtabTitle, ViewPath viewPath) {
- try {
- TwoLevelTab tab = (tabTitle != null) ? this.topTabSet.getTabByTitle(tabTitle) :
- this.topTabSet.getDefaultTab();
- if (tab == null || tab.getDisabled()) {
- CoreGUI.getErrorHandler().handleError("Invalid tab name: " + tabTitle);
- // TODO: Should we fire a history event here to redirect to a valid bookmark?
- tab = this.topTabSet.getDefaultTab();
- subtabTitle = null;
- }
- // Do *not* select the tab and trigger the tab selected event until the subtab has been selected first.
-
- SubTab subtab = (subtabTitle != null) ? tab.getSubTabByTitle(subtabTitle) : tab.getDefaultSubTab();
- if (subtab == null || tab.getLayout().isDisabled()) {
- CoreGUI.getErrorHandler().handleError("Invalid subtab name: " + subtabTitle);
- // TODO: Should we fire a history event here to redirect to a valid bookmark?
- subtab = tab.getLayout().getDefaultSubTab();
- }
- tab.getLayout().selectSubTab(subtab);
-
- // Now that the subtab has been selected, select the tab (this will cause a tab selected event to fire).
- this.topTabSet.selectTab(tab);
-
- // Handle any remaining view items (e.g. id of a selected item in a subtab that contains a Master-Details view).
- Canvas subView = subtab.getCanvas();
- if (subView instanceof BookmarkableView) {
- ((BookmarkableView) subView).renderView(viewPath);
- }
-
- this.topTabSet.markForRedraw();
- } catch (Exception e) {
- System.err.println("Failed to select tab " + tabTitle + "/" + subtabTitle + ": " + e);
- }
- }
-
private static boolean hasTraits(ResourceGroupComposite groupComposite) {
ResourceType type = groupComposite.getResourceGroup().getResourceType();
if (type != null) {
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 2451e4b..e4bb9fd 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
@@ -18,13 +18,12 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail;
+import java.util.ArrayList;
import java.util.EnumSet;
+import java.util.List;
import java.util.Set;
-import com.google.gwt.user.client.History;
import com.google.gwt.user.client.rpc.AsyncCallback;
-import com.smartgwt.client.types.Side;
-import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.tab.Tab;
import org.rhq.core.domain.criteria.ResourceCriteria;
@@ -36,17 +35,14 @@ import org.rhq.core.domain.resource.ResourceTypeFacet;
import org.rhq.core.domain.resource.composite.ResourceComposite;
import org.rhq.core.domain.resource.composite.ResourcePermission;
import org.rhq.core.domain.util.PageList;
-import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.ViewPath;
import org.rhq.enterprise.gui.coregui.client.alert.definitions.ResourceAlertDefinitionsView;
import org.rhq.enterprise.gui.coregui.client.components.FullHTMLPane;
import org.rhq.enterprise.gui.coregui.client.components.tab.SubTab;
import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTab;
-import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTabSelectedEvent;
-import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTabSelectedHandler;
-import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTabSet;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.AbstractTwoLevelTabSetView;
import org.rhq.enterprise.gui.coregui.client.inventory.common.event.EventCompositeHistoryView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.InventoryView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceSearchView;
@@ -61,7 +57,6 @@ import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.summary.D
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.summary.OverviewView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
/**
* Right panel of the Resource view.
@@ -69,12 +64,12 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
* @author Greg Hinkle
* @author Ian Springer
*/
-public class ResourceDetailView extends LocatableVLayout implements BookmarkableView, TwoLevelTabSelectedHandler {
- private int resourceId;
+public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceComposite, ResourceTitleBar> {
+ private static final String BASE_VIEW_PATH = "Resource";
- private ResourceComposite resourceComposite;
+ private Integer resourceId;
- private TwoLevelTabSet topTabSet;
+ private ResourceComposite resourceComposite;
private TwoLevelTab summaryTab;
private TwoLevelTab monitoringTab;
@@ -109,33 +104,22 @@ public class ResourceDetailView extends LocatableVLayout implements Bookmarkable
private SubTab contentSubscrip;
private SubTab contentHistory;
- private ResourceTitleBar titleBar;
-
- private String tabName;
- private String subTabName;
-
public ResourceDetailView(String locatorId) {
- super(locatorId);
-
- setWidth100();
- setHeight100();
-
- // The Tabs section
+ super(locatorId, BASE_VIEW_PATH);
+ }
- topTabSet = new TwoLevelTabSet(extendLocatorId("TabSet"));
- topTabSet.setTabBarPosition(Side.TOP);
- topTabSet.setWidth100();
- topTabSet.setHeight100();
- topTabSet.setEdgeMarginSize(0);
- topTabSet.setEdgeSize(0);
+ protected List<TwoLevelTab> createTabs() {
+ List<TwoLevelTab> tabs = new ArrayList<TwoLevelTab>();
- summaryTab = new TwoLevelTab(topTabSet.extendLocatorId("Summary"), "Summary", "/images/icons/Service_up_16.png");
+ summaryTab = new TwoLevelTab(getTabSet().extendLocatorId("Summary"), "Summary",
+ "/images/icons/Service_up_16.png");
summaryOverview = new SubTab(summaryTab.extendLocatorId("Overview"), "Overview", null);
summaryDashboard = new SubTab(summaryTab.extendLocatorId("Dashboard"), "Dashboard", null);
summaryTimeline = new SubTab(summaryTab.extendLocatorId("Timeline"), "Timeline", null);
summaryTab.registerSubTabs(summaryOverview, summaryDashboard, summaryTimeline);
+ tabs.add(summaryTab);
- monitoringTab = new TwoLevelTab(topTabSet.extendLocatorId("Monitoring"), "Monitoring",
+ monitoringTab = new TwoLevelTab(getTabSet().extendLocatorId("Monitoring"), "Monitoring",
"/images/icons/Monitor_grey_16.png");
monitorGraphs = new SubTab(monitoringTab.extendLocatorId("Graphs"), "Graphs", null);
monitorTables = new SubTab(monitoringTab.extendLocatorId("Tables"), "Tables", null);
@@ -145,64 +129,64 @@ public class ResourceDetailView extends LocatableVLayout implements Bookmarkable
monitorCallTime = new SubTab(monitoringTab.extendLocatorId("CallTime"), "Call Time", null);
monitoringTab.registerSubTabs(monitorGraphs, monitorTables, monitorTraits, monitorAvail, monitorSched,
monitorCallTime);
+ tabs.add(monitoringTab);
- inventoryTab = new TwoLevelTab(topTabSet.extendLocatorId("Inventory"), "Inventory",
+ inventoryTab = new TwoLevelTab(getTabSet().extendLocatorId("Inventory"), "Inventory",
"/images/icons/Inventory_grey_16.png");
inventoryChildren = new SubTab(inventoryTab.extendLocatorId("Children"), "Children", null);
inventoryConn = new SubTab(inventoryTab.extendLocatorId("ConnectionSettings"), "Connection Settings", null);
inventoryTab.registerSubTabs(this.inventoryChildren, this.inventoryConn);
+ tabs.add(inventoryTab);
- operationsTab = new TwoLevelTab(topTabSet.extendLocatorId("Operations"), "Operations",
+ operationsTab = new TwoLevelTab(getTabSet().extendLocatorId("Operations"), "Operations",
"/images/icons/Operation_grey_16.png");
this.opHistory = new SubTab(operationsTab.extendLocatorId("History"), "History", null);
this.opSched = new SubTab(operationsTab.extendLocatorId("Scheduled"), "Scheduled", null);
operationsTab.registerSubTabs(this.opHistory, this.opSched);
+ tabs.add(operationsTab);
- alertsTab = new TwoLevelTab(topTabSet.extendLocatorId("Alerts"), "Alerts", "/images/icons/Alert_grey_16.png");
+ alertsTab = new TwoLevelTab(getTabSet().extendLocatorId("Alerts"), "Alerts", "/images/icons/Alert_grey_16.png");
this.alertHistory = new SubTab(alertsTab.extendLocatorId("History"), "History", null);
this.alertDef = new SubTab(alertsTab.extendLocatorId("Definitions"), "Definitions", null);
this.alertDelete = new SubTab(alertsTab.extendLocatorId("DELETEME"), "DELETEME", null);
alertsTab.registerSubTabs(alertHistory, alertDef, alertDelete);
+ tabs.add(alertsTab);
- configurationTab = new TwoLevelTab(topTabSet.extendLocatorId("Configuration"), "Configuration",
+ configurationTab = new TwoLevelTab(getTabSet().extendLocatorId("Configuration"), "Configuration",
"/images/icons/Configure_grey_16.png");
this.configCurrent = new SubTab(configurationTab.extendLocatorId("Current"), "Current", null);
this.configHistory = new SubTab(configurationTab.extendLocatorId("History"), "History", null);
configurationTab.registerSubTabs(this.configCurrent, this.configHistory);
+ tabs.add(configurationTab);
- eventsTab = new TwoLevelTab(topTabSet.extendLocatorId("Events"), "Events", "/images/icons/Events_grey_16.png");
+ eventsTab = new TwoLevelTab(getTabSet().extendLocatorId("Events"), "Events", "/images/icons/Events_grey_16.png");
this.eventHistory = new SubTab(eventsTab.extendLocatorId("History"), "History", null);
eventsTab.registerSubTabs(eventHistory);
+ tabs.add(eventsTab);
- contentTab = new TwoLevelTab(topTabSet.extendLocatorId("Content"), "Content",
+ contentTab = new TwoLevelTab(getTabSet().extendLocatorId("Content"), "Content",
"/images/icons/Content_grey_16.png");
this.contentDeployed = new SubTab(contentTab.extendLocatorId("Deployed"), "Deployed", null);
this.contentNew = new SubTab(contentTab.extendLocatorId("New"), "New", null);
this.contentSubscrip = new SubTab(contentTab.extendLocatorId("Subscriptions"), "Subscriptions", null);
this.contentHistory = new SubTab(contentTab.extendLocatorId("History"), "History", null);
contentTab.registerSubTabs(contentDeployed, contentNew, contentSubscrip, contentHistory);
+ tabs.add(contentTab);
- topTabSet.setTabs(summaryTab, monitoringTab, inventoryTab, operationsTab, alertsTab, configurationTab,
- eventsTab, contentTab);
-
- topTabSet.addTwoLevelTabSelectedHandler(this);
-
- titleBar = new ResourceTitleBar(extendLocatorId("TitleBar"));
-
- addMember(titleBar);
- addMember(topTabSet);
-
- // CoreGUI.addBreadCrumb(getPlace());
+ return tabs;
}
- public void updateDetailViews(ResourceComposite resourceComposite) {
+ protected ResourceTitleBar createTitleBar() {
+ return new ResourceTitleBar(extendLocatorId("TitleBar"));
+ }
+ protected void updateTabContent(ResourceComposite resourceComposite) {
this.resourceComposite = resourceComposite;
final Resource resource = this.resourceComposite.getResource();
- this.titleBar.setResource(resource);
+ getTitleBar().setResource(resource);
- for (Tab top : this.topTabSet.getTabs()) {
+ for (Tab top : this.getTabSet().getTabs()) {
((TwoLevelTab) top).getLayout().destroyViews();
}
@@ -276,66 +260,17 @@ public class ResourceDetailView extends LocatableVLayout implements Bookmarkable
ResourceType type = this.resourceComposite.getResource().getResourceType();
inventoryTab.setSubTabEnabled(inventoryChildren.getLocatorId(), !type.getChildResourceTypes().isEmpty());
- this.topTabSet.setTabEnabled(this.operationsTab, facets.contains(ResourceTypeFacet.OPERATION));
- this.topTabSet.setTabEnabled(this.configurationTab, facets.contains(ResourceTypeFacet.CONFIGURATION) && permissions.isConfigureRead());
- this.topTabSet.setTabEnabled(this.eventsTab, facets.contains(ResourceTypeFacet.EVENT));
- this.topTabSet.setTabEnabled(this.contentTab, facets.contains(ResourceTypeFacet.CONTENT));
- }
-
- public void onTabSelected(TwoLevelTabSelectedEvent tabSelectedEvent) {
- //CoreGUI.printWidgetTree();
-
- if (this.resourceComposite == null) {
- // History.fireCurrentHistoryState();
- } else {
- // Switch tabs directly, rather than letting the history framework do it, to avoid redrawing the outer views.
- // selectSubTabByTitle(tabSelectedEvent.getId(), tabSelectedEvent.getSubTabId());
- String tabPath = "/" + tabSelectedEvent.getId() + "/" + tabSelectedEvent.getSubTabId();
- String path = "Resource/" + resourceId + tabPath;
-
- // If the tab that was selected is not already the current history item, the user clicked on the tab, rather
- // than going directly to the tab's URL. In this case, fire a history event to go to the tab and make it the
- // current history item.
- if (!History.getToken().equals(path)) {
- System.out.println("Firing History event [" + path + "]...");
- History.newItem(path, true);
- }
- }
+ getTabSet().setTabEnabled(this.operationsTab, facets.contains(ResourceTypeFacet.OPERATION));
+ getTabSet().setTabEnabled(this.configurationTab, facets.contains(ResourceTypeFacet.CONFIGURATION) && permissions.isConfigureRead());
+ getTabSet().setTabEnabled(this.eventsTab, facets.contains(ResourceTypeFacet.EVENT));
+ getTabSet().setTabEnabled(this.contentTab, facets.contains(ResourceTypeFacet.CONTENT));
}
- public void renderView(ViewPath viewPath) {
- // e.g. #Resource/10010/Summary/Overview
- // ^ current path
- int resourceId = Integer.parseInt(viewPath.getCurrent().getPath());
- viewPath.next();
-
- if (!viewPath.isEnd()) {
- // e.g. #Resource/10010/Summary/Overview
- // ^ current path
- this.tabName = viewPath.getCurrent().getPath();
- viewPath.next();
- if (!viewPath.isEnd()) {
- // e.g. #Resource/10010/Summary/Overview
- // ^ current path
- this.subTabName = viewPath.getCurrent().getPath();
- viewPath.next();
- } else {
- this.subTabName = null;
- }
- } else {
- this.tabName = null;
- }
-
- if (this.resourceId != resourceId) {
- // A different Resource or first load - go get data.
- loadSelectedResource(resourceId, viewPath);
- } else {
- // Same Resource - just switch tabs.
- selectTab(this.tabName, this.subTabName, viewPath);
- }
+ public Integer getSelectedItemId() {
+ return this.resourceId;
}
- public void loadSelectedResource(final int resourceId, final ViewPath viewPath) {
+ protected void loadSelectedItem(final int resourceId, final ViewPath viewPath) {
this.resourceId = resourceId;
ResourceCriteria criteria = new ResourceCriteria();
@@ -379,54 +314,12 @@ public class ResourceDetailView extends LocatableVLayout implements Bookmarkable
public void onTypesLoaded(ResourceType type) {
resourceComposite.getResource().setResourceType(type);
ResourceDetailView.this.resourceComposite = resourceComposite;
- updateDetailViews(resourceComposite);
- selectTab(tabName, subTabName, viewPath);
+ updateTabContent(resourceComposite);
+ selectTab(getTabName(), getSubTabName(), viewPath);
}
});
}
- /**
- * Select the tab/subtab with the specified titles (e.g. "Monitoring", "Graphs").
- *
- * @param tabTitle the title of the tab to select - if null, the default tab (the leftmost non-disabled one) will be selected
- * @param subtabTitle the title of the subtab to select - if null, the default subtab (the leftmost non-disabled one) will be selected
- * @param viewPath the view path, which may have additional view items to be rendered
- */
- public void selectTab(String tabTitle, String subtabTitle, ViewPath viewPath) {
- try {
- TwoLevelTab tab = (tabTitle != null) ? this.topTabSet.getTabByTitle(tabTitle) :
- this.topTabSet.getDefaultTab();
- if (tab == null || tab.getDisabled()) {
- CoreGUI.getErrorHandler().handleError("Invalid tab name: " + tabTitle);
- // TODO: Should we fire a history event here to redirect to a valid bookmark?
- tab = this.topTabSet.getDefaultTab();
- subtabTitle = null;
- }
- // Do *not* select the tab and trigger the tab selected event until the subtab has been selected first.
-
- SubTab subtab = (subtabTitle != null) ? tab.getSubTabByTitle(subtabTitle) : tab.getDefaultSubTab();
- if (subtab == null || tab.getLayout().isDisabled()) {
- CoreGUI.getErrorHandler().handleError("Invalid subtab name: " + subtabTitle);
- // TODO: Should we fire a history event here to redirect to a valid bookmark?
- subtab = tab.getLayout().getDefaultSubTab();
- }
- tab.getLayout().selectSubTab(subtab);
-
- // Now that the subtab has been selected, select the tab (this will cause a tab selected event to fire).
- this.topTabSet.selectTab(tab);
-
- // Handle any remaining view items (e.g. id of a selected item in a subtab that contains a Master-Details view).
- Canvas subView = subtab.getCanvas();
- if (subView instanceof BookmarkableView) {
- ((BookmarkableView) subView).renderView(viewPath);
- }
-
- this.topTabSet.markForRedraw();
- } catch (Exception e) {
- System.err.println("Failed to select tab " + tabTitle + "/" + subtabTitle + ": " + e);
- }
- }
-
private static boolean hasTraits(ResourceComposite resourceComposite) {
ResourceType type = resourceComposite.getResource().getResourceType();
Set<MeasurementDefinition> metricDefs = type.getMetricDefinitions();
13 years, 8 months
[rhq] modules/enterprise
by ips
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java | 29 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/DemoCanvas.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ViewId.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ViewPath.java | 9
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/AdministrationView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/SubTabLayout.java | 65 ++-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTab.java | 8
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTabSelectedEvent.java | 22 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTabSet.java | 25 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/footer/FavoritesButton.java | 3
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java | 166 +++++-----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTopView.java | 18 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsDataSource.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java | 117 +++----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTopView.java | 7
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java | 29 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/rpc/RPCManager.java | 27 -
19 files changed, 269 insertions(+), 270 deletions(-)
New commits:
commit f32625b5a47a803f36bc77351f8efa8344070381
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Sat Sep 11 01:25:22 2010 -0400
various fixes to tab/tree navigation/bookmarking; various refactoring of tab components; some refactoring of Resource and group detail views
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java
index 12c624c..77cc196 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
@@ -132,11 +132,9 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String> {
messages = GWT.create(Messages.class);
checkLoginStatus();
-
}
public static void checkLoginStatus() {
-
// String sessionIdString = com.google.gwt.user.client.Cookies.getCookie("RHQ_Sesssion");
// if (sessionIdString == null) {
@@ -255,9 +253,8 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String> {
}
public void onValueChange(ValueChangeEvent<String> stringValueChangeEvent) {
-
String event = URL.decodeComponent(stringValueChangeEvent.getValue());
- System.out.println("Handling history event: " + event);
+ //System.out.println("Handling history event: " + event);
currentPath = event;
currentViewPath = new ViewPath(event);
@@ -357,8 +354,24 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String> {
contentCanvas.markForRedraw();
}
- public static void goTo(String path) {
- History.newItem(path);
+ public static void goToView(String viewPath) {
+ String currentViewPath = History.getToken();
+ if (currentViewPath.equals(viewPath)) {
+ // We're already there - just refresh the view.
+ refresh();
+ } else {
+ if (viewPath.matches("(Resource|ResourceGroup)/[^/]*")) {
+ // e.g. "Resource/10001"
+ if (!currentViewPath.startsWith(viewPath)) {
+ // The Resource that was selected is not the same Resource that was previously selected -
+ // grab the end portion of the previous history URL and append it to the new history URL,
+ // so the same tab is selected for the new Resource.
+ String suffix = currentViewPath.replaceFirst("^[^/]*/[^/]*", "");
+ viewPath += suffix;
+ }
+ }
+ History.newItem(viewPath);
+ }
}
public static void refreshBreadCrumbTrail() {
@@ -386,6 +399,10 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String> {
});
}
+ public static void goToResourceOrGroupView(String newToken) {
+
+ }
+
private class RootCanvas extends VLayout implements BookmarkableView {
ViewId currentViewId;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/DemoCanvas.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/DemoCanvas.java
index aa9da49..935f351 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/DemoCanvas.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/DemoCanvas.java
@@ -78,7 +78,7 @@ public class DemoCanvas extends Canvas {
topTabSet.addTab(configTab);
topTabSet.addTab(treeTab);
//topTabSet.addTab(alertHistoryTab);
- //topTabSet.selectTab(alertHistoryTab);
+ //topTabSet.selectSubTabByTitle(alertHistoryTab);
final Menu configSelectMenu = new Menu();
configSelectMenu.addItem(new MenuItem("Agent"));
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ViewId.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ViewId.java
index 7d022ce..1302774 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ViewId.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ViewId.java
@@ -28,12 +28,10 @@ import java.util.List;
*/
public class ViewId {
-
private String path;
private List<Breadcrumb> breadcrumbs;
-
public ViewId(String path, Breadcrumb... breadcrumbs) {
this.path = path;
if ( breadcrumbs != null) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ViewPath.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ViewPath.java
index 445b0b7..d0e3c06 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ViewPath.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ViewPath.java
@@ -19,13 +19,14 @@
package org.rhq.enterprise.gui.coregui.client;
import java.util.ArrayList;
+import java.util.List;
/**
* @author Greg Hinkle
*/
public class ViewPath {
- private ArrayList<ViewId> viewPath = new ArrayList<ViewId>();
+ private List<ViewId> viewPath = new ArrayList<ViewId>();
private int index = 0;
@@ -35,12 +36,12 @@ public class ViewPath {
}
public ViewPath(String pathString) {
- for (String pe : pathString.split("/")) {
- viewPath.add(new ViewId(pe));
+ for (String pathElement : pathString.split("/")) {
+ viewPath.add(new ViewId(pathElement));
}
}
- public ArrayList<ViewId> getViewPath() {
+ public List<ViewId> getViewPath() {
return viewPath;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/AdministrationView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/AdministrationView.java
index 7c69fa5..df0f4b5 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/AdministrationView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/AdministrationView.java
@@ -91,7 +91,7 @@ public class AdministrationView extends LocatableHLayout implements Bookmarkable
grid.addSelectionChangedHandler(new SelectionChangedHandler() {
public void onSelectionChanged(SelectionEvent selectionEvent) {
if (selectionEvent.getState()) {
- CoreGUI.goTo("Administration/" + name + "/" + selectionEvent.getRecord().getAttribute("name"));
+ CoreGUI.goToView("Administration/" + name + "/" + selectionEvent.getRecord().getAttribute("name"));
}
}
});
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/SubTabLayout.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/SubTabLayout.java
index 1db0e78..741d931 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/SubTabLayout.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/SubTabLayout.java
@@ -48,7 +48,6 @@ public class SubTabLayout extends LocatableVLayout {
private SubTab currentlyDisplayed;
private String currentlySelected;
- private int currentIndex;
public SubTabLayout(String locatorId) {
super(locatorId);
@@ -99,12 +98,9 @@ public class SubTabLayout extends LocatableVLayout {
// button.setStyleName("SubTabButton");
// button.setStylePrimaryName("SubTabButton");
- final Integer index = i++;
-
button.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent clickEvent) {
currentlySelected = locatorId;
- currentIndex = index;
fireSubTabSelection();
draw();
}
@@ -116,14 +112,14 @@ public class SubTabLayout extends LocatableVLayout {
}
// Initial settings
- selectTabByLocatorId(currentlySelected);
+ selectSubTabByLocatorId(currentlySelected);
}
@Override
protected void onDraw() {
super.onDraw();
- selectTabByLocatorId(currentlySelected);
+ selectSubTabByLocatorId(currentlySelected);
}
public void enableSubTab(String locatorId) {
@@ -171,17 +167,25 @@ public class SubTabLayout extends LocatableVLayout {
subtabs.put(locatorId, subTab);
}
- public int getCurrentIndex() {
- return currentIndex;
+ public SubTab getDefaultSubTab() {
+ // the default subtab is the first one in the set that is not disabled
+ for (SubTab subtab : this.subtabs.values()) {
+ if (!this.disabledSubTabs.contains(subtab.getLocatorId())) {
+ return subtab;
+ }
+ }
+ return null;
}
- public SubTab getDefaultSubTab() {
- return subtabs.values().iterator().next();
+ public boolean selectSubTab(SubTab subtab) {
+ if (subtab == null) {
+ throw new IllegalArgumentException("subtab is null.");
+ }
+ return selectSubTabByLocatorId(subtab.getLocatorId());
}
- public boolean selectTabByLocatorId(String locatorId) {
+ public boolean selectSubTabByLocatorId(String locatorId) {
boolean foundTab = false;
- int i = 0;
for (String subtabLocatorId : this.subtabs.keySet()) {
if (subtabLocatorId.equals(locatorId)) {
if (this.disabledSubTabs.contains(subtabLocatorId)) {
@@ -190,12 +194,10 @@ public class SubTabLayout extends LocatableVLayout {
CoreGUI.getErrorHandler().handleError("Cannot select disabled subtab '" + subtab.getTitle() + "'.");
} else {
this.currentlySelected = subtabLocatorId;
- this.currentIndex = i;
foundTab = true;
}
break;
}
- i++;
}
if (foundTab) {
@@ -205,30 +207,31 @@ public class SubTabLayout extends LocatableVLayout {
return foundTab;
}
- public boolean selectTab(String title) {
- boolean foundTab = false;
- int i = 0;
+ public SubTab getSubTabByTitle(String title) {
for (String subtabLocatorId : this.subtabs.keySet()) {
SubTab subtab = this.subtabs.get(subtabLocatorId);
if (subtab.getTitle().equals(title)) {
- if (this.disabledSubTabs.contains(subtab.getLocatorId())) {
- // Nice try - user tried to select a disabled tab, probably by going directly to a bookmark URL.
- CoreGUI.getErrorHandler().handleError("Cannot select disabled subtab '" + title + "'.");
- } else {
- this.currentlySelected = subtab.getLocatorId();
- this.currentIndex = i;
- foundTab = true;
- }
- break;
+ return subtab;
}
- i++;
}
- if (foundTab) {
+ return null;
+ }
+
+ public boolean selectSubTabByTitle(String title) {
+ SubTab subtab = getSubTabByTitle(title);
+ if (subtab == null) {
+ return false;
+ } else {
+ if (this.disabledSubTabs.contains(subtab.getLocatorId())) {
+ // Nice try - user tried to select a disabled tab, probably by going directly to a bookmark URL.
+ CoreGUI.getErrorHandler().handleError("Cannot select disabled subtab '" + title + "'.");
+ return false;
+ }
+ this.currentlySelected = subtab.getLocatorId();
refresh();
+ return true;
}
-
- return foundTab;
}
public SubTab getCurrentSubTab() {
@@ -246,7 +249,7 @@ public class SubTabLayout extends LocatableVLayout {
public void fireSubTabSelection() {
TwoLevelTabSelectedEvent event = new TwoLevelTabSelectedEvent("?", getCurrentSubTab().getTitle(), -1,
- currentIndex, getCurrentCanvas());
+ getCurrentCanvas());
hm.fireEvent(event);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTab.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTab.java
index 845128f..6258e9e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTab.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTab.java
@@ -52,6 +52,14 @@ public class TwoLevelTab extends LocatableTab {
}
}
+ public SubTab getSubTabByTitle(String title) {
+ return this.layout.getSubTabByTitle(title);
+ }
+
+ public SubTab getDefaultSubTab() {
+ return this.layout.getDefaultSubTab();
+ }
+
public SubTabLayout getLayout() {
return layout;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTabSelectedEvent.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTabSelectedEvent.java
index 374c049..5f2b2ab 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTabSelectedEvent.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTabSelectedEvent.java
@@ -18,10 +18,8 @@
*/
package org.rhq.enterprise.gui.coregui.client.components.tab;
-import com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.GwtEvent;
import com.smartgwt.client.widgets.Canvas;
-import com.smartgwt.client.widgets.tab.Tab;
/**
* @author Greg Hinkle
@@ -30,19 +28,17 @@ public class TwoLevelTabSelectedEvent extends GwtEvent<TwoLevelTabSelectedHandle
public static final GwtEvent.Type<TwoLevelTabSelectedHandler> TYPE = new Type<TwoLevelTabSelectedHandler>();
- String id;
- String subTabId;
+ private String id;
+ private String subTabId;
- int tabNum;
- int subTabNum;
+ private int tabNum;
- Canvas subTabPane;
+ private Canvas subTabPane;
- public TwoLevelTabSelectedEvent(String id, String subTabId, int tabNum, int subTabNum, Canvas subTabPane) {
+ public TwoLevelTabSelectedEvent(String id, String subTabId, int tabNum, Canvas subTabPane) {
this.id = id;
this.subTabId = subTabId;
this.tabNum = tabNum;
- this.subTabNum = subTabNum;
this.subTabPane = subTabPane;
}
@@ -70,14 +66,6 @@ public class TwoLevelTabSelectedEvent extends GwtEvent<TwoLevelTabSelectedHandle
this.tabNum = tabNum;
}
- public int getSubTabNum() {
- return subTabNum;
- }
-
- public void setSubTabNum(int subTabNum) {
- this.subTabNum = subTabNum;
- }
-
public Canvas getSubTabPane() {
return subTabPane;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTabSet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTabSet.java
index a5c2611..d39efb7 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTabSet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTabSet.java
@@ -70,23 +70,30 @@ public class TwoLevelTabSet extends LocatableTabSet implements TabSelectedHandle
}
public void onTabSelected(TabSelectedEvent tabSelectedEvent) {
- System.out.println("TwoLevelTabSet.onTabSelected(): " + tabSelectedEvent.getTab().getTitle());
TwoLevelTab tab = (TwoLevelTab) getSelectedTab();
TwoLevelTabSelectedEvent event = new TwoLevelTabSelectedEvent(tab.getTitle(),
tab.getLayout().getCurrentSubTab().getTitle(), tabSelectedEvent.getTabNum(),
- tab.getLayout().getCurrentIndex(), tab.getLayout().getCurrentCanvas());
+ tab.getLayout().getCurrentCanvas());
m.fireEvent(event);
}
public void onTabSelected(TwoLevelTabSelectedEvent tabSelectedEvent) {
- System.out.println("TwoLevelTabSet.onTwoLevelTabSelected(): " + tabSelectedEvent.getId() + "/" +
- tabSelectedEvent.getSubTabId());
tabSelectedEvent.setTabNum(getSelectedTabNumber());
- Tab tab = getSelectedTab();
+ Tab tab = getSelectedTab();
tabSelectedEvent.setId(tab.getTitle());
m.fireEvent(tabSelectedEvent);
}
+ public TwoLevelTab getDefaultTab() {
+ TwoLevelTab[] tabs = getTabs();
+ for (TwoLevelTab tab : tabs) {
+ if (!tab.getDisabled()) {
+ return tab;
+ }
+ }
+ return null;
+ }
+
public TwoLevelTab getTabByTitle(String title) {
return (TwoLevelTab) super.getTabByTitle(title);
}
@@ -94,4 +101,12 @@ public class TwoLevelTabSet extends LocatableTabSet implements TabSelectedHandle
public TwoLevelTab getTabByLocatorId(String locatorId) {
return (TwoLevelTab) super.getTabByLocatorId(locatorId);
}
+
+ public void setTabEnabled(TwoLevelTab tab, boolean enabled) {
+ if (enabled) {
+ enableTab(tab);
+ } else {
+ disableTab(tab);
+ }
+ }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/footer/FavoritesButton.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/footer/FavoritesButton.java
index 0d04750..4f5374c 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/footer/FavoritesButton.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/footer/FavoritesButton.java
@@ -22,7 +22,6 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Set;
-import com.google.gwt.user.client.History;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.widgets.events.ClickEvent;
import com.smartgwt.client.widgets.events.ClickHandler;
@@ -70,7 +69,7 @@ public class FavoritesButton extends LocatableIMenuButton {
MenuItem item = new MenuItem(String.valueOf(resourceId));
item.addClickHandler(new com.smartgwt.client.widgets.menu.events.ClickHandler() {
public void onClick(MenuItemClickEvent event) {
- History.newItem("Resource/" + resourceId);
+ CoreGUI.goToView("Resource/" + resourceId);
}
});
items[i] = item;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
index 6bb216e..9d289ca 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
@@ -177,7 +177,7 @@ public class ResourceGroupDetailView extends LocatableVLayout implements Bookmar
this.titleBar.setGroup(groupComposite.getResourceGroup());
- for (Tab top : topTabSet.getTabs()) {
+ for (Tab top : this.topTabSet.getTabs()) {
((TwoLevelTab) top).getLayout().destroyViews();
}
@@ -185,7 +185,6 @@ public class ResourceGroupDetailView extends LocatableVLayout implements Bookmar
// summaryTab.updateSubTab("Overview", new DashboardView(resource));
// summaryTab.updateSubTab("Timeline", timelinePane);
this.summaryOverview.setCanvas(new OverviewView(this.groupComposite));
- summaryTab.updateSubTab(this.summaryOverview);
int groupId = this.groupComposite.getResourceGroup().getId();
@@ -194,126 +193,113 @@ public class ResourceGroupDetailView extends LocatableVLayout implements Bookmar
this.monitorTraits.setCanvas(new TraitsView(this.monitoringTab.extendLocatorId("TraitsView"), groupId));
this.monitorSched.setCanvas(new SchedulesView(this.monitoringTab.extendLocatorId("SchedulesView"), groupId));
this.monitorCallTime.setCanvas(new FullHTMLPane("/rhq/group/monitor/response-plain.xhtml?groupId=" + groupId));
- monitoringTab.updateSubTab(this.monitorGraphs);
- monitoringTab.updateSubTab(this.monitorTables);
- monitoringTab.updateSubTab(this.monitorSched);
- monitoringTab.updateSubTab(this.monitorCallTime);
this.inventoryMembers.setCanvas(ResourceSearchView.getMembersOf(groupId));
- inventoryTab.updateSubTab(this.inventoryMembers);
-
- // inventoryTab.updateSubTab("Connection Settings", new GroupPluginConfigurationEditView(this.group.getId(), this.group.getResourceType().getId(), ConfigurationEditor.ConfigType.plugin));
+ // TODO: Uncomment this once the group config component is done.
+ //this.inventoryConn.setCanvas(new GroupPluginConfigurationEditView(this.group.getId(), this.group.getResourceType().getId(), ConfigurationEditor.ConfigType.plugin));
this.opHistory.setCanvas(new FullHTMLPane("/rhq/group/operation/groupOperationHistory-plain.xhtml?groupId="
+ groupId));
this.opSched.setCanvas(new FullHTMLPane("/rhq/group/operation/groupOperationSchedules-plain.xhtml?groupId="
+ groupId));
- operationsTab.updateSubTab(this.opHistory);
- operationsTab.updateSubTab(this.opSched);
this.alertHistory.setCanvas(new FullHTMLPane("/rhq/group/alert/listGroupAlertHistory-plain.xhtml?groupId="
+ groupId));
this.alertDef.setCanvas(new FullHTMLPane("/rhq/group/alert/listGroupAlertDefinitions-plain.xhtml?groupId="
+ groupId));
- alertsTab.updateSubTab(this.alertHistory);
- alertsTab.updateSubTab(this.alertDef);
this.configCurrent.setCanvas(new FullHTMLPane("/rhq/group/configuration/viewCurrent-plain.xhtml?groupId="
+ groupId));
this.configHistory
.setCanvas(new FullHTMLPane("/rhq/group/configuration/history-plain.xhtml?groupId=" + groupId));
- configurationTab.updateSubTab(this.configCurrent);
- configurationTab.updateSubTab(this.configHistory);
this.eventHistory.setCanvas(EventCompositeHistoryView.get(groupComposite));
- eventsTab.updateSubTab(this.eventHistory);
updateTabEnablement();
}
private void updateTabEnablement() {
-
GroupCategory groupCategory = groupComposite.getResourceGroup().getGroupCategory();
Set<ResourceTypeFacet> facets = groupComposite.getResourceFacets().getFacets();
// Summary and Inventory tabs are always enabled.
- topTabSet.enableTab(summaryTab);
- topTabSet.enableTab(inventoryTab);
+
+ // Only enable "Call Time" and "Traits" subtabs for groups that implement them.
+ this.monitoringTab.setSubTabEnabled(this.monitorTraits.getLocatorId(), hasTraits(this.groupComposite));
+ this.monitoringTab.setSubTabEnabled(this.monitorCallTime.getLocatorId(), facets.contains(ResourceTypeFacet.CALL_TIME));
// Inventory>Connection Settings subtab is only enabled for compat groups that define conn props.
- inventoryTab.setSubTabEnabled(this.inventoryConn.getLocatorId(), groupCategory == GroupCategory.COMPATIBLE
+ this.inventoryTab.setSubTabEnabled(this.inventoryConn.getLocatorId(), groupCategory == GroupCategory.COMPATIBLE
&& facets.contains(ResourceTypeFacet.PLUGIN_CONFIGURATION));
// Monitoring and Alerts tabs are always enabled for compatible groups and always disabled for mixed groups.
- if (groupCategory == GroupCategory.COMPATIBLE) {
- topTabSet.enableTab(monitoringTab);
- topTabSet.enableTab(alertsTab);
- } else {
- topTabSet.disableTab(monitoringTab);
- topTabSet.disableTab(alertsTab);
- }
+ // TODO (ips): Break out mixed groups into a separate view.
+ this.topTabSet.setTabEnabled(this.monitoringTab, groupCategory == GroupCategory.COMPATIBLE);
+ this.topTabSet.setTabEnabled(this.alertsTab, groupCategory == GroupCategory.COMPATIBLE);
// Operations tab is only enabled for compatible groups of a type that supports the Operations facet.
- if (facets.contains(ResourceTypeFacet.OPERATION)) {
- topTabSet.enableTab(operationsTab);
- } else {
- topTabSet.disableTab(operationsTab);
- }
+ this.topTabSet.setTabEnabled(this.operationsTab, facets.contains(ResourceTypeFacet.OPERATION));
// Configuration tab is only enabled for compatible groups of a type that supports the Configuration facet
// and when the current user has the CONFIGURE_READ permission.
- if (facets.contains(ResourceTypeFacet.CONFIGURATION) && permissions.isConfigureRead()) {
- topTabSet.enableTab(configurationTab);
- } else {
- topTabSet.disableTab(configurationTab);
- }
+ this.topTabSet.setTabEnabled(this.configurationTab, facets.contains(ResourceTypeFacet.CONFIGURATION)
+ && this.permissions.isConfigureRead());
// Events tab is only enabled for compatible groups of a type that supports the Events facet.
- if (facets.contains(ResourceTypeFacet.EVENT)) {
- topTabSet.enableTab(eventsTab);
- } else {
- topTabSet.disableTab(eventsTab);
- }
-
- // only enable "Call Time" and "Traits" subtabs for groups that implement them.
- monitoringTab.setSubTabEnabled(monitorTraits.getLocatorId(), hasTraits(this.groupComposite));
- monitoringTab.setSubTabEnabled(monitorCallTime.getLocatorId(), facets.contains(ResourceTypeFacet.CALL_TIME));
+ this.topTabSet.setTabEnabled(this.eventsTab, facets.contains(ResourceTypeFacet.EVENT));
}
public void onTabSelected(TwoLevelTabSelectedEvent tabSelectedEvent) {
+ //CoreGUI.printWidgetTree();
+
if (this.groupComposite == null) {
-// History.fireCurrentHistoryState();
+ // History.fireCurrentHistoryState();
} else {
- // Switch tabs directly, rather than letting the history framework do it, to avoid redrawing the outer views.
-// selectTab(tabSelectedEvent.getId(), tabSelectedEvent.getSubTabId());
String tabPath = "/" + tabSelectedEvent.getId() + "/" + tabSelectedEvent.getSubTabId();
String path = "ResourceGroup/" + this.groupComposite.getResourceGroup().getId() + tabPath;
- // But still add an item to the history, specifying false to tell it not to fire an event.
- History.newItem(path, true);
+ // If the tab that was selected is not already the current history item, the user clicked on the tab, rather
+ // than going directly to the tab's URL. In this case, fire a history event to go to the tab and make it the
+ // current history item.
+ if (!History.getToken().equals(path)) {
+ //System.out.println("Firing History event [" + path + "]...");
+ History.newItem(path, true);
+ }
}
}
public void renderView(ViewPath viewPath) {
- // e.g. #ResourceGroup/10010/Inventory/Overview
+ // e.g. #ResourceGroup/10010/Summary/Overview
+ // ^ current path
int groupId = Integer.parseInt(viewPath.getCurrent().getPath());
-
- viewPath.next();
-
- tabName = (!viewPath.isEnd()) ? viewPath.getCurrent().getPath() : null; // e.g. "Inventory"
- subTabName = (viewPath.viewsLeft() >= 1) ? viewPath.getNext().getPath() : null; // e.g. "Overview"
-
- viewPath.next();
viewPath.next();
+ if (!viewPath.isEnd()) {
+ // e.g. #ResourceGroup/10010/Summary/Overview
+ // ^ current path
+ this.tabName = viewPath.getCurrent().getPath();
+ viewPath.next();
+ if (!viewPath.isEnd()) {
+ // e.g. #ResourceGroup/10010/Summary/Overview
+ // ^ current path
+ this.subTabName = viewPath.getCurrent().getPath();
+ viewPath.next();
+ } else {
+ this.subTabName = null;
+ }
+ } else {
+ this.tabName = null;
+ }
if (this.groupId != groupId) {
+ // A different group or first load - go get data.
loadSelectedGroup(groupId, viewPath);
} else {
- // Same group just switching tabs
- selectTab(tabName, subTabName, viewPath);
+ // Same group - just switch tabs.
+ selectTab(this.tabName, this.subTabName, viewPath);
}
+
}
public void loadSelectedGroup(final int groupId, final ViewPath viewPath) {
@@ -337,7 +323,6 @@ public class ResourceGroupDetailView extends LocatableVLayout implements Bookmar
});
}
-
private void loadResourceType(final ResourceGroupComposite groupComposite, final ViewPath viewPath) {
final ResourceGroup group = this.groupComposite.getResourceGroup();
@@ -372,33 +357,48 @@ public class ResourceGroupDetailView extends LocatableVLayout implements Bookmar
}
}
+ /**
+ * Select the tab/subtab with the specified titles (e.g. "Monitoring", "Graphs").
+ *
+ * @param tabTitle the title of the tab to select - if null, the default tab (the leftmost non-disabled one) will be selected
+ * @param subtabTitle the title of the subtab to select - if null, the default subtab (the leftmost non-disabled one) will be selected
+ * @param viewPath the view path, which may have additional view items to be rendered
+ */
+ public void selectTab(String tabTitle, String subtabTitle, ViewPath viewPath) {
+ try {
+ TwoLevelTab tab = (tabTitle != null) ? this.topTabSet.getTabByTitle(tabTitle) :
+ this.topTabSet.getDefaultTab();
+ if (tab == null || tab.getDisabled()) {
+ CoreGUI.getErrorHandler().handleError("Invalid tab name: " + tabTitle);
+ // TODO: Should we fire a history event here to redirect to a valid bookmark?
+ tab = this.topTabSet.getDefaultTab();
+ subtabTitle = null;
+ }
+ // Do *not* select the tab and trigger the tab selected event until the subtab has been selected first.
- public void selectTab(String tabName, String subtabName, ViewPath viewPath) {
- if (tabName == null) {
- tabName = DEFAULT_TAB_NAME;
- }
- TwoLevelTab tab = this.topTabSet.getTabByTitle(tabName);
- if (tab == null) {
- CoreGUI.getErrorHandler().handleError("Invalid tab name: " + tabName);
- // TODO: Should we fire a history event here to redirect to a valid bookmark?
- tab = this.topTabSet.getTabByTitle(DEFAULT_TAB_NAME);
- }
- this.topTabSet.selectTab(tab);
- if (subtabName != null) {
- if (!tab.getLayout().selectTab(subtabName)) {
- CoreGUI.getErrorHandler().handleError("Invalid subtab name: " + subtabName);
+ SubTab subtab = (subtabTitle != null) ? tab.getSubTabByTitle(subtabTitle) : tab.getDefaultSubTab();
+ if (subtab == null || tab.getLayout().isDisabled()) {
+ CoreGUI.getErrorHandler().handleError("Invalid subtab name: " + subtabTitle);
// TODO: Should we fire a history event here to redirect to a valid bookmark?
- return;
- } else {
- Canvas subView = tab.getLayout().getCurrentCanvas();
- if (subView instanceof BookmarkableView) {
- ((BookmarkableView) subView).renderView(viewPath);
- }
+ subtab = tab.getLayout().getDefaultSubTab();
}
+ tab.getLayout().selectSubTab(subtab);
+
+ // Now that the subtab has been selected, select the tab (this will cause a tab selected event to fire).
+ this.topTabSet.selectTab(tab);
+
+ // Handle any remaining view items (e.g. id of a selected item in a subtab that contains a Master-Details view).
+ Canvas subView = subtab.getCanvas();
+ if (subView instanceof BookmarkableView) {
+ ((BookmarkableView) subView).renderView(viewPath);
+ }
+
+ this.topTabSet.markForRedraw();
+ } catch (Exception e) {
+ System.err.println("Failed to select tab " + tabTitle + "/" + subtabTitle + ": " + e);
}
}
-
private static boolean hasTraits(ResourceGroupComposite groupComposite) {
ResourceType type = groupComposite.getResourceGroup().getResourceType();
if (type != null) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTopView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTopView.java
index 7fe5361..a205584 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTopView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTopView.java
@@ -25,10 +25,7 @@ package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail;
import com.smartgwt.client.widgets.Canvas;
import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
-import org.rhq.enterprise.gui.coregui.client.ViewId;
import org.rhq.enterprise.gui.coregui.client.ViewPath;
-import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
-import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGroupGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
/**
@@ -37,17 +34,14 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
public class ResourceGroupTopView extends LocatableHLayout implements BookmarkableView {
private Canvas contentCanvas;
-
-
private ResourceGroupTreeView treeView;
private ResourceGroupDetailView detailView;
- private ResourceGroupGWTServiceAsync groupService = GWTServiceLookup.getResourceGroupService();
-
public ResourceGroupTopView(String locatorId) {
super(locatorId);
}
+
@Override
protected void onInit() {
super.onInit();
@@ -68,7 +62,6 @@ public class ResourceGroupTopView extends LocatableHLayout implements Bookmarkab
setContent(detailView);
}
-
public void setContent(Canvas newContent) {
if (contentCanvas.getChildren().length > 0)
@@ -77,16 +70,9 @@ public class ResourceGroupTopView extends LocatableHLayout implements Bookmarkab
contentCanvas.markForRedraw();
}
- public void renderView(ViewPath viewPath) {
- if (viewPath.isEnd()) {
- // default detail view
- viewPath.getViewPath().add(new ViewId("Inventory"));
- viewPath.getViewPath().add(new ViewId("Overview"));
- }
-
+ public void renderView(ViewPath viewPath) {
this.treeView.renderView(viewPath);
-
this.detailView.renderView(viewPath);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsDataSource.java
index 28aee70..4be1f22 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsDataSource.java
@@ -49,8 +49,8 @@ public class TraitsDataSource extends AbstractMeasurementDataTraitDataSource {
groupIdField.setHidden(true);
fields.add(0, groupIdField);
- DataSourceTextField resourceNameField = new DataSourceTextField(MeasurementDataTraitCriteria.SORT_FIELD_RESOURCE_NAME,
- "Resource Name");
+ DataSourceTextField resourceNameField =
+ new DataSourceTextField(MeasurementDataTraitCriteria.SORT_FIELD_RESOURCE_NAME, "Member Resource");
fields.add(0, resourceNameField);
return fields;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java
index 731711e..c31881c 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java
@@ -111,7 +111,7 @@ public class InventoryView extends LocatableHLayout implements BookmarkableView
grid.addSelectionChangedHandler(new SelectionChangedHandler() {
public void onSelectionChanged(SelectionEvent selectionEvent) {
if (selectionEvent.getState()) {
- CoreGUI.goTo("Inventory/" + name + "/" + selectionEvent.getRecord().getAttribute("name"));
+ CoreGUI.goToView("Inventory/" + name + "/" + selectionEvent.getRecord().getAttribute("name"));
}
}
});
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 fc67739..2451e4b 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
@@ -264,7 +264,6 @@ public class ResourceDetailView extends LocatableVLayout implements Bookmarkable
}
private void updateTabEnablement() {
-
ResourcePermission permissions = this.resourceComposite.getResourcePermission();
Set<ResourceTypeFacet> facets = this.resourceComposite.getResourceFacets().getFacets();
@@ -277,29 +276,10 @@ public class ResourceDetailView extends LocatableVLayout implements Bookmarkable
ResourceType type = this.resourceComposite.getResource().getResourceType();
inventoryTab.setSubTabEnabled(inventoryChildren.getLocatorId(), !type.getChildResourceTypes().isEmpty());
- if (facets.contains(ResourceTypeFacet.OPERATION)) {
- topTabSet.enableTab(operationsTab);
- } else {
- topTabSet.disableTab(operationsTab);
- }
-
- if (facets.contains(ResourceTypeFacet.CONFIGURATION) && permissions.isConfigureRead()) {
- topTabSet.enableTab(configurationTab);
- } else {
- topTabSet.disableTab(configurationTab);
- }
-
- if (facets.contains(ResourceTypeFacet.EVENT)) {
- topTabSet.enableTab(eventsTab);
- } else {
- topTabSet.disableTab(eventsTab);
- }
-
- if (facets.contains(ResourceTypeFacet.CONTENT)) {
- topTabSet.enableTab(contentTab);
- } else {
- topTabSet.disableTab(contentTab);
- }
+ this.topTabSet.setTabEnabled(this.operationsTab, facets.contains(ResourceTypeFacet.OPERATION));
+ this.topTabSet.setTabEnabled(this.configurationTab, facets.contains(ResourceTypeFacet.CONFIGURATION) && permissions.isConfigureRead());
+ this.topTabSet.setTabEnabled(this.eventsTab, facets.contains(ResourceTypeFacet.EVENT));
+ this.topTabSet.setTabEnabled(this.contentTab, facets.contains(ResourceTypeFacet.CONTENT));
}
public void onTabSelected(TwoLevelTabSelectedEvent tabSelectedEvent) {
@@ -309,7 +289,7 @@ public class ResourceDetailView extends LocatableVLayout implements Bookmarkable
// History.fireCurrentHistoryState();
} else {
// Switch tabs directly, rather than letting the history framework do it, to avoid redrawing the outer views.
- // selectTab(tabSelectedEvent.getId(), tabSelectedEvent.getSubTabId());
+ // selectSubTabByTitle(tabSelectedEvent.getId(), tabSelectedEvent.getSubTabId());
String tabPath = "/" + tabSelectedEvent.getId() + "/" + tabSelectedEvent.getSubTabId();
String path = "Resource/" + resourceId + tabPath;
@@ -324,26 +304,35 @@ public class ResourceDetailView extends LocatableVLayout implements Bookmarkable
}
public void renderView(ViewPath viewPath) {
- // e.g. #Resource/10010/Inventory/Overview
- // ^ Current Path
+ // e.g. #Resource/10010/Summary/Overview
+ // ^ current path
int resourceId = Integer.parseInt(viewPath.getCurrent().getPath());
-
viewPath.next();
- tabName = (!viewPath.isEnd()) ? viewPath.getCurrent().getPath() : null; // e.g. "Inventory"
- subTabName = (viewPath.viewsLeft() >= 1) ? viewPath.getNext().getPath() : null; // e.g. "Overview"
-
- viewPath.next();
- viewPath.next();
+ if (!viewPath.isEnd()) {
+ // e.g. #Resource/10010/Summary/Overview
+ // ^ current path
+ this.tabName = viewPath.getCurrent().getPath();
+ viewPath.next();
+ if (!viewPath.isEnd()) {
+ // e.g. #Resource/10010/Summary/Overview
+ // ^ current path
+ this.subTabName = viewPath.getCurrent().getPath();
+ viewPath.next();
+ } else {
+ this.subTabName = null;
+ }
+ } else {
+ this.tabName = null;
+ }
if (this.resourceId != resourceId) {
- // A different resource or first load, go get data
+ // A different Resource or first load - go get data.
loadSelectedResource(resourceId, viewPath);
} else {
- // same resource just switch tabs
- selectTab(tabName, subTabName, viewPath);
+ // Same Resource - just switch tabs.
+ selectTab(this.tabName, this.subTabName, viewPath);
}
-
}
public void loadSelectedResource(final int resourceId, final ViewPath viewPath) {
@@ -360,7 +349,7 @@ public class ResourceDetailView extends LocatableVLayout implements Bookmarkable
new Message("Resource with id [" + resourceId + "] does not exist or is not accessible.",
Message.Severity.Warning));
- CoreGUI.goTo(InventoryView.VIEW_PATH);
+ CoreGUI.goToView(InventoryView.VIEW_PATH);
}
public void onSuccess(PageList<ResourceComposite> result) {
@@ -396,37 +385,45 @@ public class ResourceDetailView extends LocatableVLayout implements Bookmarkable
});
}
- public void selectTab(String tabName, String subtabName, ViewPath viewPath) {
+ /**
+ * Select the tab/subtab with the specified titles (e.g. "Monitoring", "Graphs").
+ *
+ * @param tabTitle the title of the tab to select - if null, the default tab (the leftmost non-disabled one) will be selected
+ * @param subtabTitle the title of the subtab to select - if null, the default subtab (the leftmost non-disabled one) will be selected
+ * @param viewPath the view path, which may have additional view items to be rendered
+ */
+ public void selectTab(String tabTitle, String subtabTitle, ViewPath viewPath) {
try {
- TwoLevelTab tab = this.topTabSet.getTabByTitle(tabName);
+ TwoLevelTab tab = (tabTitle != null) ? this.topTabSet.getTabByTitle(tabTitle) :
+ this.topTabSet.getDefaultTab();
if (tab == null || tab.getDisabled()) {
- CoreGUI.getErrorHandler().handleError("Invalid tab name: " + tabName);
+ CoreGUI.getErrorHandler().handleError("Invalid tab name: " + tabTitle);
// TODO: Should we fire a history event here to redirect to a valid bookmark?
- Tab defaultTab = this.topTabSet.getTab(0);
- tab = (TwoLevelTab) defaultTab;
+ tab = this.topTabSet.getDefaultTab();
+ subtabTitle = null;
}
- SubTab subTab = null;
- if (subtabName != null) {
- if (!tab.getLayout().selectTab(subtabName)) {
- CoreGUI.getErrorHandler().handleError("Invalid subtab name: " + subtabName);
- // TODO: Should we fire a history event here to redirect to a valid bookmark?
- SubTab defaultSubtab = tab.getLayout().getDefaultSubTab();
- tab.getLayout().selectTab(defaultSubtab.getTitle());
- }
- subTab = tab.getLayout().getCurrentSubTab();
+ // Do *not* select the tab and trigger the tab selected event until the subtab has been selected first.
+
+ SubTab subtab = (subtabTitle != null) ? tab.getSubTabByTitle(subtabTitle) : tab.getDefaultSubTab();
+ if (subtab == null || tab.getLayout().isDisabled()) {
+ CoreGUI.getErrorHandler().handleError("Invalid subtab name: " + subtabTitle);
+ // TODO: Should we fire a history event here to redirect to a valid bookmark?
+ subtab = tab.getLayout().getDefaultSubTab();
}
+ tab.getLayout().selectSubTab(subtab);
+
+ // Now that the subtab has been selected, select the tab (this will cause a tab selected event to fire).
this.topTabSet.selectTab(tab);
- if (subTab != null) {
- tab.updateSubTab(subTab);
- Canvas subView = subTab.getCanvas();
- if (subView instanceof BookmarkableView) {
- ((BookmarkableView) subView).renderView(viewPath);
- }
+
+ // Handle any remaining view items (e.g. id of a selected item in a subtab that contains a Master-Details view).
+ Canvas subView = subtab.getCanvas();
+ if (subView instanceof BookmarkableView) {
+ ((BookmarkableView) subView).renderView(viewPath);
}
- tab.getLayout().markForRedraw();
+
this.topTabSet.markForRedraw();
} catch (Exception e) {
- System.err.println("Failed to select tab " + tabName + "/" + subtabName + ": " + e);
+ System.err.println("Failed to select tab " + tabTitle + "/" + subtabTitle + ": " + e);
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTopView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTopView.java
index 83c5352..7fae500 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTopView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTopView.java
@@ -62,14 +62,7 @@ public class ResourceTopView extends LocatableHLayout implements BookmarkableVie
}
public void renderView(ViewPath viewPath) {
- if (viewPath.isEnd()) {
- // default detail view
- viewPath.getViewPath().add(new ViewId("Summary"));
- viewPath.getViewPath().add(new ViewId("Overview"));
- }
-
this.treeView.renderView(viewPath);
-
this.detailView.renderView(viewPath);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
index 8566975..57ba8f2 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
@@ -91,7 +91,7 @@ public class ResourceTreeView extends LocatableVLayout {
private ViewId currentViewId;
- private ArrayList<ResourceSelectListener> selectListeners = new ArrayList<ResourceSelectListener>();
+ private List<ResourceSelectListener> selectListeners = new ArrayList<ResourceSelectListener>();
private boolean initialSelect = false;
@@ -105,6 +105,7 @@ public class ResourceTreeView extends LocatableVLayout {
}
public void onInit() {
+ // TODO (ips): Are we intentionally avoiding calling super.onInit() here? If so, why?
}
private void buildTree() {
@@ -124,7 +125,6 @@ public class ResourceTreeView extends LocatableVLayout {
treeGrid.setLeaveScrollbarGap(false);
contextMenu = new Menu();
- MenuItem item = new MenuItem("Expand node");
treeGrid.addSelectionChangedHandler(new SelectionChangedHandler() {
public void onSelectionChanged(SelectionEvent selectionEvent) {
@@ -132,16 +132,11 @@ public class ResourceTreeView extends LocatableVLayout {
if (treeGrid.getSelectedRecord() instanceof ResourceTreeDatasource.ResourceTreeNode) {
ResourceTreeDatasource.ResourceTreeNode node = (ResourceTreeDatasource.ResourceTreeNode) treeGrid
.getSelectedRecord();
- System.out.println("Resource selected in tree: " + node.getResource());
-
- String newToken = "Resource/" + node.getResource().getId();
- String currentToken = History.getToken();
- if (!currentToken.startsWith(newToken)) {
-
- String ending = currentToken.replaceFirst("^[^\\/]*\\/[^\\/]*", "");
-
- History.newItem("Resource/" + node.getResource().getId() + ending);
-
+ //System.out.println("Resource selected in tree: " + node.getResource());
+ String viewPath = "Resource/" + node.getResource().getId();
+ String currentViewPath = History.getToken();
+ if (!currentViewPath.startsWith(viewPath)) {
+ CoreGUI.goToView(viewPath);
}
}
}
@@ -167,13 +162,13 @@ public class ResourceTreeView extends LocatableVLayout {
treeGrid.addDataArrivedHandler(new DataArrivedHandler() {
public void onDataArrived(DataArrivedEvent dataArrivedEvent) {
if (!initialSelect) {
-
updateBreadcrumb();
}
}
});
}
+
private void updateBreadcrumb() {
TreeNode selectedNode = treeGrid.getTree().findById(String.valueOf(selectedResourceId));
// System.out.println("Trying to preopen: " + selectedNode);
@@ -455,7 +450,7 @@ public class ResourceTreeView extends LocatableVLayout {
public void setSelectedResource(final int selectedResourceId) {
this.selectedResourceId = selectedResourceId;
- TreeNode node = null;
+ TreeNode node;
if (treeGrid != null && treeGrid.getTree() != null
&& (node = treeGrid.getTree().findById(String.valueOf(selectedResourceId))) != null) {
@@ -466,8 +461,10 @@ public class ResourceTreeView extends LocatableVLayout {
treeGrid.getTree().openFolders(parents);
treeGrid.getTree().openFolder(node);
- treeGrid.deselectAllRecords();
- treeGrid.selectRecord(node);
+ if (!treeGrid.getSelectedRecord().equals(node)) {
+ treeGrid.deselectAllRecords();
+ treeGrid.selectRecord(node);
+ }
updateBreadcrumb();
/*
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java
index 9d56dc2..c507395 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java
@@ -100,7 +100,7 @@ public class ReportTopView extends LocatableHLayout implements BookmarkableView
grid.addSelectionChangedHandler(new SelectionChangedHandler() {
public void onSelectionChanged(SelectionEvent selectionEvent) {
if (selectionEvent.getState()) {
- CoreGUI.goTo("Reports/" + name + "/" + selectionEvent.getRecord().getAttribute("name"));
+ CoreGUI.goToView("Reports/" + name + "/" + selectionEvent.getRecord().getAttribute("name"));
}
}
});
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/rpc/RPCManager.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/rpc/RPCManager.java
index 37f553d..10213f4 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/rpc/RPCManager.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/rpc/RPCManager.java
@@ -21,20 +21,22 @@ package org.rhq.enterprise.gui.coregui.client.util.rpc;
import com.smartgwt.client.widgets.Img;
import java.util.HashSet;
+import java.util.Set;
/**
* @author Greg Hinkle
*/
public class RPCManager {
+ private static final RPCManager INSTANCE = new RPCManager();
- int nextCallId = 0;
+ private int nextCallId = 0;
- HashSet<MonitoringRequestCallback> inProgress = new HashSet<MonitoringRequestCallback>();
+ private Set<MonitoringRequestCallback> inProgress = new HashSet<MonitoringRequestCallback>();
- Img activityIndicator;
+ private Img activityIndicator;
- public RPCManager() {
+ private RPCManager() {
activityIndicator = new Img("/coregui/images/ajax-loader.gif", 16, 16);
activityIndicator.setZIndex(10000);
activityIndicator.setLeft(10);
@@ -43,6 +45,10 @@ public class RPCManager {
activityIndicator.draw();
}
+ public static RPCManager getInstance() {
+ return INSTANCE;
+ }
+
public int register(MonitoringRequestCallback callback) {
inProgress.add(callback);
refresh();
@@ -50,13 +56,13 @@ public class RPCManager {
}
public void failCall(MonitoringRequestCallback callback) {
- System.out.println("RPC [" + callback.getName() + "] failed in [" + callback.age() + "]");
+ //System.err.println("RPC [" + callback.getName() + "] failed in [" + callback.age() + "] ms.");
inProgress.remove(callback);
refresh();
}
public void succeedCall(MonitoringRequestCallback callback) {
- System.out.println("RPC [" + callback.getName() + "] succeeded in [" + callback.age() + "]");
+ //System.out.println("RPC [" + callback.getName() + "] succeeded in [" + callback.age() + "] ms.");
inProgress.remove(callback);
refresh();
}
@@ -76,17 +82,8 @@ public class RPCManager {
}
activityIndicator.setTooltip(buf.toString());
-
} else {
activityIndicator.hide();
}
}
-
-
- public static RPCManager INSTANCE = new RPCManager();
-
- public static RPCManager getInstance() {
- return INSTANCE;
- }
-
}
13 years, 8 months
[rhq] modules/enterprise
by mazz
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java | 1
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GeneralPropertiesAlertDefinitionForm.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java | 263 +++++++++-
3 files changed, 263 insertions(+), 3 deletions(-)
New commits:
commit f121c0c17c6740c078e71a8d7da0ddda549c1392
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Sep 10 17:22:43 2010 -0400
continuing to build out the "new condition" dialog window for alert def/condition editor
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java
index e6ee5c0..23bc0cc 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java
@@ -137,6 +137,7 @@ public abstract class AbstractAlertDefinitionsView extends TableSection {
newAlertDef.setConditionExpression(BooleanExpression.ALL);
newAlertDef.setPriority(AlertPriority.MEDIUM);
newAlertDef.setWillRecover(false);
+ singleAlertDefinitionView.setAlertDefinition(newAlertDef);
singleAlertDefinitionView.makeEditable();
} else {
final AlertDefinitionCriteria criteria = new AlertDefinitionCriteria();
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GeneralPropertiesAlertDefinitionForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GeneralPropertiesAlertDefinitionForm.java
index d1f5de5..fe1e2e2 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GeneralPropertiesAlertDefinitionForm.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GeneralPropertiesAlertDefinitionForm.java
@@ -219,7 +219,7 @@ public class GeneralPropertiesAlertDefinitionForm extends LocatableDynamicForm i
priorities.put(AlertPriority.HIGH.name(), AlertPriority.HIGH.name());
priorities.put(AlertPriority.MEDIUM.name(), AlertPriority.MEDIUM.name());
priorities.put(AlertPriority.LOW.name(), AlertPriority.LOW.name());
- LinkedHashMap<String, String> priorityIcons = new LinkedHashMap<String, String>();
+ LinkedHashMap<String, String> priorityIcons = new LinkedHashMap<String, String>(3);
priorityIcons.put(AlertPriority.HIGH.name(), "/images/icons/Flag_red_16.png");
priorityIcons.put(AlertPriority.MEDIUM.name(), "/images/icons/Flag_yellow_16.png");
priorityIcons.put(AlertPriority.LOW.name(), "/images/icons/Flag_blue_16.png");
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java
index 9f39e6e..c6c59c1 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java
@@ -23,18 +23,28 @@
package org.rhq.enterprise.gui.coregui.client.alert.definitions;
+import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedHashMap;
import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.util.SC;
+import com.smartgwt.client.widgets.form.DynamicForm;
+import com.smartgwt.client.widgets.form.FormItemIfFunction;
import com.smartgwt.client.widgets.form.fields.ButtonItem;
+import com.smartgwt.client.widgets.form.fields.FormItem;
import com.smartgwt.client.widgets.form.fields.SelectItem;
+import com.smartgwt.client.widgets.form.fields.SpacerItem;
+import com.smartgwt.client.widgets.form.fields.StaticTextItem;
+import com.smartgwt.client.widgets.form.fields.TextItem;
import com.smartgwt.client.widgets.form.fields.events.ClickEvent;
import com.smartgwt.client.widgets.form.fields.events.ClickHandler;
import org.rhq.core.domain.alert.AlertCondition;
import org.rhq.core.domain.alert.AlertConditionCategory;
+import org.rhq.core.domain.event.EventSeverity;
+import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.core.domain.operation.OperationRequestStatus;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
/**
@@ -42,7 +52,7 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
*/
public class NewConditionEditor extends LocatableDynamicForm {
- private HashSet<AlertCondition> conditions;
+ private HashSet<AlertCondition> conditions; // the new condition we create goes into this set
private SelectItem conditionTypeSelectItem;
public NewConditionEditor(String locatorId, HashSet<AlertCondition> conditions) {
@@ -54,6 +64,8 @@ public class NewConditionEditor extends LocatableDynamicForm {
protected void onInit() {
super.onInit();
+ setMargin(20);
+
conditionTypeSelectItem = new SelectItem("conditionType", "Condition Type");
LinkedHashMap<String, String> condTypes = new LinkedHashMap<String, String>(7);
condTypes.put(AlertConditionCategory.THRESHOLD.name(), "Measurement Absolute Value Threshold");
@@ -66,6 +78,12 @@ public class NewConditionEditor extends LocatableDynamicForm {
conditionTypeSelectItem.setValueMap(condTypes);
conditionTypeSelectItem.setDefaultValue(AlertConditionCategory.THRESHOLD.name());
conditionTypeSelectItem.setWrapTitle(false);
+ conditionTypeSelectItem.setRedrawOnChange(true);
+ conditionTypeSelectItem.setWidth("*");
+
+ SpacerItem spacer = new SpacerItem();
+ spacer.setColSpan(2);
+ spacer.setHeight(5);
ButtonItem ok = new ButtonItem("buttonItem", "OK");
ok.setColSpan(2);
@@ -78,6 +96,247 @@ public class NewConditionEditor extends LocatableDynamicForm {
}
});
- setFields(conditionTypeSelectItem, ok);
+ ArrayList<FormItem> formItems = new ArrayList<FormItem>();
+ formItems.add(conditionTypeSelectItem);
+ formItems.add(spacer);
+ formItems.addAll(buildMetricThresholdFormItems());
+ formItems.addAll(buildMetricBaselineFormItems());
+ formItems.addAll(buildMetricChangeFormItems());
+ formItems.addAll(buildTraitChangeFormItems());
+ formItems.addAll(buildAvailabilityChangeFormItems());
+ formItems.addAll(buildOperationFormItems());
+ formItems.addAll(buildEventFormItems());
+ formItems.add(ok);
+
+ setFields(formItems.toArray(new FormItem[formItems.size()]));
};
+
+ private ArrayList<FormItem> buildMetricThresholdFormItems() {
+ ArrayList<FormItem> formItems = new ArrayList<FormItem>();
+
+ ShowIfCategoryFunction ifFunc = new ShowIfCategoryFunction(AlertConditionCategory.THRESHOLD);
+
+ String helpStr = "Specify the threshold value that, when violated, triggers the condition. The value you specify is an absolute value with an optional units specifier.";
+ StaticTextItem helpItem = buildHelpTextItem("thresholdHelp", helpStr, ifFunc);
+ formItems.add(helpItem);
+
+ formItems.add(buildMetricDropDownMenu("thresholdMetric", ifFunc));
+ formItems.add(buildComparatorDropDownMenu("thresholdComparator", ifFunc));
+
+ TextItem absoluteValue = new TextItem("metricAbsoluteValue", "Metric Value");
+ absoluteValue.setWrapTitle(false);
+ absoluteValue.setRequired(true);
+
+ absoluteValue.setShowIfCondition(ifFunc);
+ formItems.add(absoluteValue);
+
+ return formItems;
+ }
+
+ private ArrayList<FormItem> buildMetricBaselineFormItems() {
+ ArrayList<FormItem> formItems = new ArrayList<FormItem>();
+
+ ShowIfCategoryFunction ifFunc = new ShowIfCategoryFunction(AlertConditionCategory.BASELINE);
+
+ String helpStr = "Specify the baseline value that must be violated to trigger the condition. The value you specify is a percentage of the given baseline value.";
+ StaticTextItem helpItem = buildHelpTextItem("baselineHelp", helpStr, ifFunc);
+ formItems.add(helpItem);
+
+ formItems.add(buildMetricDropDownMenu("baselineMetric", ifFunc));
+ formItems.add(buildComparatorDropDownMenu("baselineComparator", ifFunc));
+
+ TextItem baselinePercentage = new TextItem("baselinePercentage", "Baseline Percentage");
+ baselinePercentage.setWrapTitle(false);
+ baselinePercentage.setRequired(true);
+ baselinePercentage.setShowIfCondition(ifFunc);
+ formItems.add(baselinePercentage);
+
+ SelectItem baselineSelection = new SelectItem("baselineSelection", "Baseline");
+ LinkedHashMap<String, String> baselines = new LinkedHashMap<String, String>(3);
+ baselines.put("min", "Minimum"); // title should have the current value of the min baseline
+ baselines.put("avg", "Baseline"); // title should have the current value of the avg baseline
+ baselines.put("max", "Maximum"); // title should have the current value of the max baseline
+ baselineSelection.setValueMap(baselines);
+ baselineSelection.setDefaultValue("avg");
+ baselineSelection.setWidth("*");
+ baselineSelection.setWrapTitle(false);
+ baselineSelection.setShowIfCondition(ifFunc);
+ formItems.add(baselineSelection);
+
+ return formItems;
+ }
+
+ private ArrayList<FormItem> buildMetricChangeFormItems() {
+ ArrayList<FormItem> formItems = new ArrayList<FormItem>();
+
+ ShowIfCategoryFunction ifFunc = new ShowIfCategoryFunction(AlertConditionCategory.CHANGE);
+
+ String helpStr = "Specify the metric whose value must change to trigger the condition.";
+ StaticTextItem helpItem = buildHelpTextItem("changeMetricHelp", helpStr, ifFunc);
+ formItems.add(helpItem);
+
+ formItems.add(buildMetricDropDownMenu("changeMetric", ifFunc));
+
+ return formItems;
+ }
+
+ private ArrayList<FormItem> buildTraitChangeFormItems() {
+ ArrayList<FormItem> formItems = new ArrayList<FormItem>();
+
+ ShowIfCategoryFunction ifFunc = new ShowIfCategoryFunction(AlertConditionCategory.TRAIT);
+
+ String helpStr = "Specify the trait whose value must change to trigger the condition.";
+ StaticTextItem helpItem = buildHelpTextItem("traitHelp", helpStr, ifFunc);
+ formItems.add(helpItem);
+
+ LinkedHashMap<String, String> traits = new LinkedHashMap<String, String>();
+ // TODO
+ traits.put("dummy trait", "Dummy Trait Name");
+
+ SelectItem traitSelection = new SelectItem("trait", "Trait");
+ traitSelection.setValueMap(traits);
+ traitSelection.setDefaultValue(traits.keySet().iterator().next()); // just use the first one
+ traitSelection.setWidth("*");
+ traitSelection.setShowIfCondition(ifFunc);
+ formItems.add(traitSelection);
+
+ return formItems;
+ }
+
+ private ArrayList<FormItem> buildAvailabilityChangeFormItems() {
+ ArrayList<FormItem> formItems = new ArrayList<FormItem>();
+
+ ShowIfCategoryFunction ifFunc = new ShowIfCategoryFunction(AlertConditionCategory.AVAILABILITY);
+
+ String helpStr = "Specify the availability state change that will trigger the condition.";
+ StaticTextItem helpItem = buildHelpTextItem("availabilityHelp", helpStr, ifFunc);
+ formItems.add(helpItem);
+
+ SelectItem selection = new SelectItem("availability", "Availability");
+ LinkedHashMap<String, String> avails = new LinkedHashMap<String, String>(2);
+ avails.put(AvailabilityType.UP.name(), "Goes UP");
+ avails.put(AvailabilityType.DOWN.name(), "Goes DOWN");
+ selection.setValueMap(avails);
+ selection.setDefaultValue(AvailabilityType.DOWN.name());
+ selection.setShowIfCondition(ifFunc);
+
+ formItems.add(selection);
+ return formItems;
+ }
+
+ private ArrayList<FormItem> buildOperationFormItems() {
+ ArrayList<FormItem> formItems = new ArrayList<FormItem>();
+
+ ShowIfCategoryFunction ifFunc = new ShowIfCategoryFunction(AlertConditionCategory.CONTROL);
+
+ String helpStr = "Specify the result that must occur when the selected operation is executed in order to trigger the condition.";
+ StaticTextItem helpItem = buildHelpTextItem("operationHelp", helpStr, ifFunc);
+ formItems.add(helpItem);
+
+ LinkedHashMap<String, String> ops = new LinkedHashMap<String, String>();
+ // TODO
+ ops.put("dummy op", "Dummy Op Name");
+
+ SelectItem opSelection = new SelectItem("operation", "Operation");
+ opSelection.setValueMap(ops);
+ opSelection.setDefaultValue(ops.keySet().iterator().next()); // just use the first one
+ opSelection.setShowIfCondition(ifFunc);
+ formItems.add(opSelection);
+
+ SelectItem opResultsSelection = new SelectItem("operationResults", "Operation Status");
+ LinkedHashMap<String, String> operationStatuses = new LinkedHashMap<String, String>(4);
+ operationStatuses.put(OperationRequestStatus.INPROGRESS.name(), OperationRequestStatus.INPROGRESS.name());
+ operationStatuses.put(OperationRequestStatus.SUCCESS.name(), OperationRequestStatus.SUCCESS.name());
+ operationStatuses.put(OperationRequestStatus.FAILURE.name(), OperationRequestStatus.FAILURE.name());
+ operationStatuses.put(OperationRequestStatus.CANCELED.name(), OperationRequestStatus.CANCELED.name());
+ opResultsSelection.setValueMap(operationStatuses);
+ opResultsSelection.setDefaultValue(OperationRequestStatus.FAILURE.name());
+ opResultsSelection.setWidth("*");
+ opResultsSelection.setWrapTitle(false);
+ opResultsSelection.setShowIfCondition(ifFunc);
+ formItems.add(opResultsSelection);
+
+ return formItems;
+ }
+
+ private ArrayList<FormItem> buildEventFormItems() {
+ ArrayList<FormItem> formItems = new ArrayList<FormItem>();
+
+ ShowIfCategoryFunction ifFunc = new ShowIfCategoryFunction(AlertConditionCategory.EVENT);
+
+ String helpStr = "Specify the event severity that an event message must be reported with in order to trigger this condition. If you specify an optional regular expression, the event message must also match that regular expression in order for the condition to trigger.";
+ StaticTextItem helpItem = buildHelpTextItem("eventHelp", helpStr, ifFunc);
+ formItems.add(helpItem);
+
+ SelectItem eventSeveritySelection = new SelectItem("eventSeverity", "Event Severity");
+ LinkedHashMap<String, String> severities = new LinkedHashMap<String, String>(5);
+ severities.put(EventSeverity.DEBUG.name(), EventSeverity.DEBUG.name());
+ severities.put(EventSeverity.INFO.name(), EventSeverity.INFO.name());
+ severities.put(EventSeverity.WARN.name(), EventSeverity.WARN.name());
+ severities.put(EventSeverity.ERROR.name(), EventSeverity.ERROR.name());
+ severities.put(EventSeverity.FATAL.name(), EventSeverity.FATAL.name());
+ eventSeveritySelection.setValueMap(severities);
+ eventSeveritySelection.setDefaultValue(EventSeverity.ERROR.name());
+ eventSeveritySelection.setWrapTitle(false);
+ eventSeveritySelection.setShowIfCondition(ifFunc);
+ formItems.add(eventSeveritySelection);
+
+ TextItem eventRegex = new TextItem("eventRegex", "Regular Expression");
+ eventRegex.setRequired(false);
+ eventRegex.setWrapTitle(false);
+ eventRegex.setShowIfCondition(ifFunc);
+ formItems.add(eventRegex);
+
+ return formItems;
+ }
+
+ private SelectItem buildMetricDropDownMenu(String itemName, FormItemIfFunction ifFunc) {
+
+ LinkedHashMap<String, String> metrics = new LinkedHashMap<String, String>();
+ metrics.put("dummy metric", "Dummy Metric Name");
+
+ SelectItem metricSelection = new SelectItem(itemName, "Metric");
+ metricSelection.setValueMap(metrics);
+ metricSelection.setDefaultValue(metrics.keySet().iterator().next()); // just use the first one
+ metricSelection.setWidth("*");
+ metricSelection.setShowIfCondition(ifFunc);
+ return metricSelection;
+ }
+
+ private SelectItem buildComparatorDropDownMenu(String itemName, FormItemIfFunction ifFunc) {
+
+ LinkedHashMap<String, String> comparators = new LinkedHashMap<String, String>();
+ comparators.put("<", "< (Less than)");
+ comparators.put("=", "= (Equal to)");
+ comparators.put(">", "> (Greater than)");
+
+ SelectItem comparatorSelection = new SelectItem(itemName, "Comparator");
+ comparatorSelection.setValueMap(comparators);
+ comparatorSelection.setDefaultValue("<");
+ comparatorSelection.setShowIfCondition(ifFunc);
+ return comparatorSelection;
+ }
+
+ private StaticTextItem buildHelpTextItem(String itemName, String helpText, FormItemIfFunction ifFunc) {
+ StaticTextItem help = new StaticTextItem(itemName);
+ help.setShowTitle(false);
+ help.setColSpan(2);
+ help.setRowSpan(2);
+ help.setWrap(true);
+ help.setValue(helpText);
+ help.setShowIfCondition(ifFunc);
+ return help;
+ }
+
+ private class ShowIfCategoryFunction implements FormItemIfFunction {
+ private final AlertConditionCategory category;
+
+ public ShowIfCategoryFunction(AlertConditionCategory category) {
+ this.category = category;
+ }
+
+ public boolean execute(FormItem item, Object value, DynamicForm form) {
+ return category.name().equals(form.getValue("conditionType").toString());
+ }
+ }
}
13 years, 8 months
[rhq] 2 commits - modules/enterprise
by Simeon Pinder
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java | 2 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedView.java | 4 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java | 2 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java | 6 ++--
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/resource/ProblemResourcesDataSource.java | 14 ++++-----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java | 15 +---------
7 files changed, 16 insertions(+), 29 deletions(-)
New commits:
commit ee8eb63dc16b3e4d9847c0d26705dee5008e2222
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Thu Sep 9 18:30:01 2010 -0400
organize config labels.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java
index ad0895b..e66f091 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java
@@ -88,7 +88,7 @@ public class AutodiscoveryPortlet extends ResourceAutodiscoveryView implements C
//horizontal display component
LocatableHLayout row = new LocatableHLayout("auto-discovery.configuration");
BlurbItem label = new BlurbItem("discovery-platform-count-label");
- label.setValue("Maximum Platforms to show");
+ label.setValue("Number of platforms to display");
//-------------combobox for number of platforms to display on the dashboard
final SelectItem maximumPlatformsComboBox = new SelectItem(AUTODISCOVERY_PLATFORM_MAX);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedView.java
index 655596b..c856151 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedView.java
@@ -129,7 +129,7 @@ public class RecentlyAddedView extends LocatableVLayout implements CustomSetting
//-------------combobox for number of recently added resources to display on the dashboard
final SelectItem maximumRecentlyAddedComboBox = new SelectItem(RECENTLY_ADDED_SHOW_MAX);
- maximumRecentlyAddedComboBox.setTitle("Show maximum of");
+ maximumRecentlyAddedComboBox.setTitle("Show");
maximumRecentlyAddedComboBox.setHint("<nobr><b> recently approved resources on dashboard.</b></nobr>");
//spinder 9/3/10: the following is required workaround to disable editability of combobox.
maximumRecentlyAddedComboBox.setType("selection");
@@ -154,7 +154,7 @@ public class RecentlyAddedView extends LocatableVLayout implements CustomSetting
//------------- Build second combobox for timeframe for problem resources search.
final SelectItem maximumTimeRecentlyAddedComboBox = new SelectItem(RECENTLY_ADDED_SHOW_HRS);
- maximumTimeRecentlyAddedComboBox.setTitle("For the last ");
+ maximumTimeRecentlyAddedComboBox.setTitle("Over ");
maximumTimeRecentlyAddedComboBox.setHint("<nobr><b> hours </b></nobr>");
//spinder 9/3/10: the following is required workaround to disable editability of combobox.
maximumTimeRecentlyAddedComboBox.setType("selection");
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java
index 88df56f..815afd7 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java
@@ -136,8 +136,8 @@ public class ProblemResourcesPortlet extends Table implements CustomSettingsPort
//-------------combobox for number of resource to display on the dashboard
final SelectItem maximumProblemResourcesComboBox = new SelectItem(PROBLEM_RESOURCE_SHOW_MAX);
- maximumProblemResourcesComboBox.setTitle("Show maximum of");
- maximumProblemResourcesComboBox.setHint("<nobr><b> problem resources for display on dashboard.</b></nobr>");
+ maximumProblemResourcesComboBox.setTitle("Display");
+ maximumProblemResourcesComboBox.setHint("<nobr><b> problem resources on dashboard.</b></nobr>");
//spinder 9/3/10: the following is required workaround to disable editability of combobox.
maximumProblemResourcesComboBox.setType("selection");
//define acceptable values for display amount
@@ -161,7 +161,7 @@ public class ProblemResourcesPortlet extends Table implements CustomSettingsPort
//------------- Build second combobox for timeframe for problem resources search.
final SelectItem maximumTimeProblemResourcesComboBox = new SelectItem(PROBLEM_RESOURCE_SHOW_HRS);
- maximumTimeProblemResourcesComboBox.setTitle("For the last ");
+ maximumTimeProblemResourcesComboBox.setTitle("Over ");
maximumTimeProblemResourcesComboBox.setHint("<nobr><b> hours </b></nobr>");
//spinder 9/3/10: the following is required workaround to disable editability of combobox.
maximumTimeProblemResourcesComboBox.setType("selection");
commit b07055b4f5bb90aa5d4d3c01541793fc5c23b3ef
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Thu Sep 9 18:16:01 2010 -0400
enable server side problem resource config.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java
index 81accf8..ce381ce 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java
@@ -74,7 +74,7 @@ public class OperationsPortlet extends LocatableVLayout implements CustomSetting
private DashboardPortlet storedPortlet = null;
public static String unlimited = "unlimited";
public static String defaultValue = unlimited;
- public static boolean defaultEnabled = false;
+ public static boolean defaultEnabled = true;
//default no-args constructor for serialization.
private OperationsPortlet() {
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 fefa85f..b282e41 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
@@ -50,7 +50,7 @@ public interface ResourceGWTService extends RemoteService {
List<RecentlyAddedResourceComposite> findRecentlyAddedResources(long ctime, int maxItems);
- List<DisambiguationReport<ProblemResourceComposite>> findProblemResources(ResourceCriteria criteria);
+ List<DisambiguationReport<ProblemResourceComposite>> findProblemResources(long ctime, int maxItems);
Resource getPlatformForResource(int resourceId);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java
index d0835b8..7597d13 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java
@@ -31,7 +31,6 @@ import com.smartgwt.client.types.DSDataFormat;
import com.smartgwt.client.types.DSProtocol;
import com.smartgwt.client.widgets.grid.ListGridRecord;
-import org.rhq.core.domain.criteria.ResourceCriteria;
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.domain.resource.composite.DisambiguationReport;
import org.rhq.core.domain.resource.composite.ProblemResourceComposite;
@@ -102,26 +101,25 @@ public class ProblemResourcesDataSource extends RPCDataSource<DisambiguationRepo
*/
public void executeFetch(final DSRequest request, final DSResponse response) {
- ResourceCriteria criteria = new ResourceCriteria();
+ long ctime = -1;
+ int maxItems = -1;
//retrieve current portlet display settings
if ((this.portlet != null) && (this.portlet instanceof ProblemResourcesPortlet)) {
ProblemResourcesPortlet problemPortlet = (ProblemResourcesPortlet) this.portlet;
//populate criteria with portlet preferences defined.
if (problemPortlet != null) {
if (problemPortlet.getMaximumProblemResourcesToDisplay() > 0) {
- criteria.setPaging(0, problemPortlet.getMaximumProblemResourcesToDisplay());
+ maxItems = problemPortlet.getMaximumProblemResourcesToDisplay();
}
//define the time window
if (problemPortlet.getMaximumProblemResourcesWithinHours() > 0) {
- criteria.addFilterStartItime(System.currentTimeMillis()
- - (problemPortlet.getMaximumProblemResourcesWithinHours() * 60 * 60 * 1000));
- criteria.addFilterEndItime(System.currentTimeMillis());
+ ctime = System.currentTimeMillis()
+ - (problemPortlet.getMaximumProblemResourcesWithinHours() * 60 * 60 * 1000);
}
}
- //problem resources within the time specified
}
- GWTServiceLookup.getResourceService().findProblemResources(criteria,
+ GWTServiceLookup.getResourceService().findProblemResources(ctime, maxItems,
new AsyncCallback<List<DisambiguationReport<ProblemResourceComposite>>>() {
public void onFailure(Throwable throwable) {
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 aca7778..6bb2d7d 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
@@ -146,16 +146,14 @@ public class ResourceGWTServiceImpl extends AbstractGWTServiceImpl implements Re
/** Locate ProblemResourcesComposites and generate the disambiguation reports for them.
* Criteria passed in not currently used.
*/
- public List<DisambiguationReport<ProblemResourceComposite>> findProblemResources(ResourceCriteria criteria) {
+ public List<DisambiguationReport<ProblemResourceComposite>> findProblemResources(long ctime, int maxItems) {
List<ProblemResourceComposite> located = new ArrayList<ProblemResourceComposite>();
MeasurementProblemManagerLocal problemManager = LookupUtil.getMeasurementProblemManager();
ResourceManagerLocal resourceManager = LookupUtil.getResourceManager();
//retrieve list of discovered problem resources. Grab all, live scrolling data
- //TODO: modify MeasurementProblemManagerLocal to accept ResourceCriteria
- // located = problemManager.findProblemResources(getSessionSubject(), 0, new PageControl(0, -1));
- located = problemManager.findProblemResources(getSessionSubject(), 0, new PageControl(0, -1));
+ located = problemManager.findProblemResources(getSessionSubject(), ctime, new PageControl(0, maxItems));
//translate the returned problem resources to disambiguated links
List<DisambiguationReport<ProblemResourceComposite>> translated = resourceManager.disambiguate(located,
@@ -197,15 +195,6 @@ public class ResourceGWTServiceImpl extends AbstractGWTServiceImpl implements Re
return platforms;
}
- // @Override
- // public List<ProblemResourceComposite> findProblemResources(long ctime, int maxItems) {
- // List<ProblemResourceComposite> problems =
- // resourceManager.findResourceCompositesByCriteria(getSessionSubject(), criteria)(
- // getSessionSubject(), ctime, maxItems);
- //
- // return problems;
- // }
-
public List<Integer> uninventoryResources(int[] resourceIds) {
return SerialUtility.prepare(resourceManager.uninventoryResources(getSessionSubject(), resourceIds),
"ResourceService.uninventoryResources");
13 years, 8 months