modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java | 100 ++ modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedView.java | 142 ++++ modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java | 335 +++++++++- modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java | 28 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java | 11 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableListGrid.java | 2 6 files changed, 576 insertions(+), 42 deletions(-)
New commits: commit 256cc0e5624dcb2c1c656057924590126e37e5ff Author: Simeon Pinder spinder@redhat.com Date: Wed Sep 8 17:27:50 2010 -0400
refresh/config for portlets i)auto discovery ii)recently added.
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 0356212..ad0895b 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java @@ -18,29 +18,58 @@ */ package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.queue;
+import com.smartgwt.client.types.VerticalAlignment; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.HTMLFlow; import com.smartgwt.client.widgets.form.DynamicForm; +import com.smartgwt.client.widgets.form.events.SubmitValuesEvent; +import com.smartgwt.client.widgets.form.events.SubmitValuesHandler; +import com.smartgwt.client.widgets.form.fields.BlurbItem; +import com.smartgwt.client.widgets.form.fields.SelectItem; +import com.smartgwt.client.widgets.form.fields.events.ChangeEvent; +import com.smartgwt.client.widgets.form.fields.events.ChangeHandler;
+import org.rhq.core.domain.configuration.PropertySimple; import org.rhq.core.domain.dashboard.DashboardPortlet; +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.ResourceAutodiscoveryView; +import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
/** * @author Greg Hinkle */ -public class AutodiscoveryPortlet extends ResourceAutodiscoveryView implements Portlet { +public class AutodiscoveryPortlet extends ResourceAutodiscoveryView implements CustomSettingsPortlet {
public static final String KEY = "Discovery Queue"; + private static final String AUTODISCOVERY_PLATFORM_MAX = "auto-discovery-platform-max"; + private String unlimited = "unlimited"; + private String defaultValue = unlimited; + private DashboardPortlet storedPortlet; + private int maximumPlatformsToDisplay = -1;
public AutodiscoveryPortlet(String locatorId) { super(locatorId, true); }
+ /** Implement configure action. + */ + @Override public void configure(PortletWindow portletWindow, DashboardPortlet storedPortlet) { - // TODO: Implement this method. + this.storedPortlet = storedPortlet; + if (storedPortlet.getConfiguration().getSimple(AUTODISCOVERY_PLATFORM_MAX) != null) { + //retrieve and translate to int + String retrieved = storedPortlet.getConfiguration().getSimple(AUTODISCOVERY_PLATFORM_MAX).getStringValue(); + if (retrieved.equals(unlimited)) { + maximumPlatformsToDisplay = -1; + } else { + maximumPlatformsToDisplay = Integer.parseInt(retrieved); + } + } else {//create setting + storedPortlet.getConfiguration().put(new PropertySimple(AUTODISCOVERY_PLATFORM_MAX, defaultValue)); + } }
public Canvas getHelpCanvas() { @@ -48,8 +77,73 @@ public class AutodiscoveryPortlet extends ResourceAutodiscoveryView implements P + "for monitoring and management or to ingnore them from further action."); }
+ /** Build custom for to dispaly the Portlet Configuration settings. + * + */ public DynamicForm getCustomSettingsForm() { - return null; // TODO: Implement this method. + + final DynamicForm form = new DynamicForm(); + form.setLayoutAlign(VerticalAlignment.CENTER); + + //horizontal display component + LocatableHLayout row = new LocatableHLayout("auto-discovery.configuration"); + BlurbItem label = new BlurbItem("discovery-platform-count-label"); + label.setValue("Maximum Platforms to show"); + + //-------------combobox for number of platforms to display on the dashboard + final SelectItem maximumPlatformsComboBox = new SelectItem(AUTODISCOVERY_PLATFORM_MAX); + maximumPlatformsComboBox.setTitle(""); + //spinder 9/3/10: the following is required workaround to disable editability of combobox. + maximumPlatformsComboBox.setType("selection"); + //define acceptable values for display amount + String[] acceptableDisplayValues = { "1", "2", "5", "10", unlimited }; + maximumPlatformsComboBox.setValueMap(acceptableDisplayValues); + //set width of dropdown display region + maximumPlatformsComboBox.setWidth(100); + maximumPlatformsComboBox.addChangeHandler(new ChangeHandler() { + public void onChange(ChangeEvent event) { + String selectedItem = "" + event.getValue(); + //stuff into the master form for retrieval + form.setValue(AUTODISCOVERY_PLATFORM_MAX, selectedItem); + } + }); + + //wrap field item in dynamicform for addition as a field item + DynamicForm item = new DynamicForm(); + item.setFields(label); + + row.addMember(item); + DynamicForm item2 = new DynamicForm(); + item2.setFields(maximumPlatformsComboBox); + row.addMember(item2); + + //default selected value to 'unlimited'(live lists) and check both combobox settings here. + String selectedValue = defaultValue; + if (storedPortlet != null) { + //if property exists retrieve it + if (storedPortlet.getConfiguration().getSimple(AUTODISCOVERY_PLATFORM_MAX) != null) { + selectedValue = storedPortlet.getConfiguration().getSimple(AUTODISCOVERY_PLATFORM_MAX).getStringValue(); + } else {//insert default value + storedPortlet.getConfiguration().put(new PropertySimple(AUTODISCOVERY_PLATFORM_MAX, defaultValue)); + } + } + //prepopulate the combobox with the previously stored selection + maximumPlatformsComboBox.setDefaultValue(selectedValue); + + form.addChild(row); + + //submit handler + form.addSubmitValuesHandler(new SubmitValuesHandler() { + @Override + public void onSubmitValues(SubmitValuesEvent event) { + if (form.getValue(AUTODISCOVERY_PLATFORM_MAX) != null) { + storedPortlet.getConfiguration().put( + new PropertySimple(AUTODISCOVERY_PLATFORM_MAX, form.getValue(AUTODISCOVERY_PLATFORM_MAX))); + } + } + }); + + return form; }
public static final class Factory implements PortletViewFactory { 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 3a551eb..655596b 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 @@ -26,32 +26,49 @@ package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.imported import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.HTMLFlow; import com.smartgwt.client.widgets.form.DynamicForm; +import com.smartgwt.client.widgets.form.events.SubmitValuesEvent; +import com.smartgwt.client.widgets.form.events.SubmitValuesHandler; +import com.smartgwt.client.widgets.form.fields.SelectItem; import com.smartgwt.client.widgets.grid.CellFormatter; import com.smartgwt.client.widgets.grid.ListGridField; import com.smartgwt.client.widgets.grid.ListGridRecord; import com.smartgwt.client.widgets.tree.TreeGrid;
+import org.rhq.core.domain.configuration.PropertySimple; import org.rhq.core.domain.dashboard.DashboardPortlet; import org.rhq.enterprise.gui.coregui.client.components.HeaderLabel; +import org.rhq.enterprise.gui.coregui.client.dashboard.CustomSettingsPortlet; import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet; import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory; import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
-public class RecentlyAddedView extends LocatableVLayout implements Portlet { +public class RecentlyAddedView extends LocatableVLayout implements CustomSettingsPortlet {
public static final String KEY = "Recently Added Portlet";
private boolean simple = true; + private DashboardPortlet storedPortlet; + 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); }
+ private TreeGrid treeGrid = null; + + private int maximumRecentlyAddedToDisplay; + private int maximumRecentlyAddedWithinHours; + @Override protected void onInit() { super.onInit(); - TreeGrid treeGrid = new TreeGrid(); + treeGrid = new TreeGrid(); treeGrid.setDataSource(new RecentlyAddedResourceDS()); treeGrid.setAutoFetchData(true); treeGrid.setTitle("Recently Added Resources"); @@ -79,7 +96,28 @@ public class RecentlyAddedView extends LocatableVLayout implements Portlet { }
public void configure(PortletWindow portletWindow, DashboardPortlet storedPortlet) { - + this.storedPortlet = storedPortlet; + 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); + } + } 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)); + } + } else { + storedPortlet.getConfiguration().put(new PropertySimple(RECENTLY_ADDED_SHOW_HRS, defaultValue)); + } }
public Canvas getHelpCanvas() { @@ -87,7 +125,76 @@ public class RecentlyAddedView extends LocatableVLayout implements Portlet { }
public DynamicForm getCustomSettingsForm() { - return null; + final DynamicForm form = new DynamicForm(); + + //-------------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.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"); + //define acceptable values for display amount + String[] acceptableDisplayValues = { "5", "10", "15", "20", "30", unlimited }; + maximumRecentlyAddedComboBox.setValueMap(acceptableDisplayValues); + //set width of dropdown display region + maximumRecentlyAddedComboBox.setWidth(100); + + //default selected value to 'unlimited'(live lists) and check both combobox settings here. + String selectedValue = defaultValue; + if (storedPortlet != null) { + //if property exists retrieve it + if (storedPortlet.getConfiguration().getSimple(RECENTLY_ADDED_SHOW_MAX) != null) { + selectedValue = storedPortlet.getConfiguration().getSimple(RECENTLY_ADDED_SHOW_MAX).getStringValue(); + } else {//insert default value + storedPortlet.getConfiguration().put(new PropertySimple(RECENTLY_ADDED_SHOW_MAX, defaultValue)); + } + } + //prepopulate the combobox with the previously stored selection + maximumRecentlyAddedComboBox.setDefaultValue(selectedValue); + + //------------- Build second combobox for timeframe for problem resources search. + final SelectItem maximumTimeRecentlyAddedComboBox = new SelectItem(RECENTLY_ADDED_SHOW_HRS); + maximumTimeRecentlyAddedComboBox.setTitle("For the last "); + maximumTimeRecentlyAddedComboBox.setHint("<nobr><b> hours </b></nobr>"); + //spinder 9/3/10: the following is required workaround to disable editability of combobox. + maximumTimeRecentlyAddedComboBox.setType("selection"); + //define acceptable values for display amount + String[] acceptableTimeValues = { "1", "4", "8", "24", "48", unlimited }; + maximumTimeRecentlyAddedComboBox.setValueMap(acceptableTimeValues); + maximumTimeRecentlyAddedComboBox.setWidth(100); + + //set to default + selectedValue = defaultValue; + if (storedPortlet != null) { + //if property exists retrieve it + if (storedPortlet.getConfiguration().getSimple(RECENTLY_ADDED_SHOW_HRS) != null) { + selectedValue = storedPortlet.getConfiguration().getSimple(RECENTLY_ADDED_SHOW_HRS).getStringValue(); + } else {//insert default value + storedPortlet.getConfiguration().put(new PropertySimple(RECENTLY_ADDED_SHOW_HRS, defaultValue)); + } + } + //prepopulate the combobox with the previously stored selection + maximumTimeRecentlyAddedComboBox.setDefaultValue(selectedValue); + + //insert fields + form.setFields(maximumRecentlyAddedComboBox, maximumTimeRecentlyAddedComboBox); + + //submit handler + form.addSubmitValuesHandler(new SubmitValuesHandler() { + @Override + public void onSubmitValues(SubmitValuesEvent event) { + if (form.getValue(RECENTLY_ADDED_SHOW_MAX) != null) { + storedPortlet.getConfiguration().put( + new PropertySimple(RECENTLY_ADDED_SHOW_MAX, form.getValue(RECENTLY_ADDED_SHOW_MAX))); + } + if (form.getValue(RECENTLY_ADDED_SHOW_HRS) != null) { + storedPortlet.getConfiguration().put( + new PropertySimple(RECENTLY_ADDED_SHOW_HRS, form.getValue(RECENTLY_ADDED_SHOW_HRS))); + } + } + }); + + return form; }
public static final class Factory implements PortletViewFactory { @@ -97,4 +204,31 @@ public class RecentlyAddedView extends LocatableVLayout implements Portlet { return new RecentlyAddedView(locatorId); } } + + /** Custom refresh operation as we cannot directly extend Table because it + * contains a TreeGrid which is not a Table. + */ + @Override + public void redraw() { + super.redraw(); + //now reload the table data + this.treeGrid.invalidateCache(); + 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; + } } 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 57472d3..88df56f 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 @@ -82,7 +82,6 @@ public class ProblemResourcesPortlet extends Table implements CustomSettingsPort listGrid.setCellHeight(50); //wrap to display disambiguation listGrid.setWrapCells(true); - // System.out.println("@@@@:"+listGrid.getField(ProblemResourcesDataSource.resource)+":W"+listGrid.getField(ProblemResourcesDataSource.resource).getWidth()); listGrid.getField(ProblemResourcesDataSource.resource).setWidth("40%"); listGrid.getField(ProblemResourcesDataSource.location).setWidth("40%"); listGrid.getField(ProblemResourcesDataSource.alerts).setWidth("10%"); 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 54d175f..2d81fe0 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 @@ -219,4 +219,15 @@ public class ResourceAutodiscoveryView extends LocatableVLayout { } return selected.toArray(new Integer[selected.size()]); } + + /** Custom refresh operation as we cannot directly extend Table because it + * contains a TreeGrid which is not a Table. + */ + @Override + public void redraw() { + super.redraw(); + //now reload the table data + this.treeGrid.invalidateCache(); + this.treeGrid.markForRedraw(); + } }
commit c6fa4276a970f11ad543bdd83d714c3c2cc8c5bb Author: Simeon Pinder spinder@redhat.com Date: Wed Sep 8 09:23:39 2010 -0400
i)OperationsPortlet config/refresh ii)editable combobox fix.
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 b7eeef9..81accf8 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java @@ -21,15 +21,29 @@ package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.operatio
import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.HTMLFlow; +import com.smartgwt.client.widgets.Label; import com.smartgwt.client.widgets.form.DynamicForm; +import com.smartgwt.client.widgets.form.events.SubmitValuesEvent; +import com.smartgwt.client.widgets.form.events.SubmitValuesHandler; +import com.smartgwt.client.widgets.form.fields.CheckboxItem; +import com.smartgwt.client.widgets.form.fields.SelectItem; +import com.smartgwt.client.widgets.form.fields.events.ChangeEvent; +import com.smartgwt.client.widgets.form.fields.events.ChangeHandler; import com.smartgwt.client.widgets.grid.HeaderSpan; +import com.smartgwt.client.widgets.layout.VStack;
+import org.rhq.core.domain.configuration.PropertySimple; +import org.rhq.core.domain.configuration.definition.ConfigurationDefinition; +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.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.operation.RecentOperationsDataSource; import org.rhq.enterprise.gui.coregui.client.operation.ScheduledOperationsDataSource; +import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableListGrid; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
@@ -38,12 +52,34 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout; * * @author Simeon Pinder */ -public class OperationsPortlet extends LocatableVLayout implements Portlet { +public class OperationsPortlet extends LocatableVLayout implements CustomSettingsPortlet {
+ //unique field/form identifiers + public static final String OPERATIONS_RANGE_COMPLETED_ENABLED = "operations-completed-enabled"; + public static final String OPERATIONS_RANGE_SCHEDULED_ENABLED = "operations-scheduled-enabled"; + public static final String OPERATIONS_RANGE_COMPLETED = "operations-range-completed"; + public static final String OPERATIONS_RANGE_SCHEDULED = "operations-range-scheduled"; + //portlet key public static final String KEY = "Operations"; 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; + //ListGrids for operations + private LocatableListGrid recentOperationsGrid = null; + private LocatableListGrid scheduledOperationsGrid = null; + private DashboardPortlet storedPortlet = null; + public static String unlimited = "unlimited"; + public static String defaultValue = unlimited; + public static boolean defaultEnabled = false; + + //default no-args constructor for serialization. + private OperationsPortlet() { + super("(unitialized)"); + }
public OperationsPortlet(String locatorId) { super(locatorId); @@ -56,13 +92,16 @@ public class OperationsPortlet extends LocatableVLayout implements Portlet { //set title for larger container setTitle(TITLE);
- // Add the list table as the top half of the view. - LocatableListGrid recentOperationsGrid = new LocatableListGrid(recentOperations); + this.recentOperationsGrid = new LocatableListGrid(recentOperations); recentOperationsGrid.setDataSource(new RecentOperationsDataSource()); recentOperationsGrid.setAutoFetchData(true); - String[] allRows = new String[] { RecentOperationsDataSource.location, RecentOperationsDataSource.operation, - RecentOperationsDataSource.resource, RecentOperationsDataSource.status, RecentOperationsDataSource.time }; - recentOperationsGrid.setHeaderSpans(new HeaderSpan(recentOperations, allRows)); + recentOperationsGrid.setTitle(recentOperations); + recentOperationsGrid.setWidth100(); + //defining header span + String[] completedRows = new String[] { RecentOperationsDataSource.location, + RecentOperationsDataSource.operation, RecentOperationsDataSource.resource, + RecentOperationsDataSource.status, RecentOperationsDataSource.time }; + recentOperationsGrid.setHeaderSpans(new HeaderSpan(recentOperations, completedRows)); recentOperationsGrid.setHeaderSpanHeight(new Integer(20)); recentOperationsGrid.setHeaderHeight(40); recentOperationsGrid.setResizeFieldsInRealTime(true); @@ -71,13 +110,15 @@ public class OperationsPortlet extends LocatableVLayout implements Portlet { addMember(recentOperationsGrid);
// Add the list table as the top half of the view. - LocatableListGrid scheduledOperationsGrid = new LocatableListGrid(scheduledOperations); + this.scheduledOperationsGrid = new LocatableListGrid(scheduledOperations); scheduledOperationsGrid.setDataSource(new ScheduledOperationsDataSource()); scheduledOperationsGrid.setAutoFetchData(true); - String[] allRows2 = new String[] { ScheduledOperationsDataSource.location, + scheduledOperationsGrid.setTitle(scheduledOperations); + scheduledOperationsGrid.setWidth100(); + String[] scheduledRows = new String[] { ScheduledOperationsDataSource.location, ScheduledOperationsDataSource.operation, ScheduledOperationsDataSource.resource, ScheduledOperationsDataSource.time }; - scheduledOperationsGrid.setHeaderSpans(new HeaderSpan(scheduledOperations, allRows2)); + scheduledOperationsGrid.setHeaderSpans(new HeaderSpan(scheduledOperations, scheduledRows)); scheduledOperationsGrid.setHeaderSpanHeight(new Integer(20)); scheduledOperationsGrid.setHeaderHeight(40);
@@ -92,8 +133,50 @@ public class OperationsPortlet extends LocatableVLayout implements Portlet {
@Override public void configure(PortletWindow portletWindow, DashboardPortlet storedPortlet) { - // TODO implement this. - + this.storedPortlet = storedPortlet; + //Operation range property - retrieve existing value + PropertySimple property = storedPortlet.getConfiguration().getSimple(OPERATIONS_RANGE_COMPLETED); + if ((property != null) && (property.getStringValue() != null)) { + //retrieve and translate to int + String retrieved = property.getStringValue(); + if (retrieved.equals(unlimited)) { + setOperationsRangeCompleted(-1); + } else { + setOperationsRangeCompleted(Integer.parseInt(retrieved)); + } + } else {//create setting + storedPortlet.getConfiguration().put(new PropertySimple(OPERATIONS_RANGE_COMPLETED, defaultValue)); + 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); + } else { + setOperationsRangeScheduled(Integer.parseInt(retrieved)); + } + } else {//create setting + storedPortlet.getConfiguration().put(new PropertySimple(OPERATIONS_RANGE_SCHEDULED, defaultValue)); + setOperationsRangeScheduled(-1); + } + //Checkbox settings property + property = storedPortlet.getConfiguration().getSimple(OPERATIONS_RANGE_SCHEDULED_ENABLED); + if ((property != null) && (property.getBooleanValue() != null)) { + setOperationsRangeScheduleEnabled(property.getBooleanValue().booleanValue()); + } else {//create setting + storedPortlet.getConfiguration() + .put(new PropertySimple(OPERATIONS_RANGE_SCHEDULED_ENABLED, defaultEnabled)); + setOperationsRangeScheduleEnabled(defaultEnabled); + } + property = storedPortlet.getConfiguration().getSimple(OPERATIONS_RANGE_COMPLETED_ENABLED); + if ((property != null) && (property.getBooleanValue() != null)) { + setOperationsRangeScheduleEnabled(property.getBooleanValue().booleanValue()); + } else {//create setting + storedPortlet.getConfiguration() + .put(new PropertySimple(OPERATIONS_RANGE_COMPLETED_ENABLED, defaultEnabled)); + } }
@Override @@ -101,8 +184,171 @@ public class OperationsPortlet extends LocatableVLayout implements Portlet { return new HTMLFlow("This portlet displays both operations that have occurred and are scheduled to occur."); }
+ /** Constructs the dynamic form instance using 1 column and multiple row layouts. + */ public DynamicForm getCustomSettingsForm() { - return null; + + //root dynamic form instance + final DynamicForm form = new DynamicForm(); + + //vertical layout + VStack column = new VStack(); + + //label + Label operationRange = new Label("Operation Range"); + column.addMember(operationRange); + + //horizontal layout + LocatableHLayout row = new LocatableHLayout("enable.completed.operations"); + + //checkbox indicating whether to apply completed operations grouping settings + final CheckboxItem enableCompletedOperationsGrouping = new CheckboxItem(); + enableCompletedOperationsGrouping.setName(OPERATIONS_RANGE_COMPLETED_ENABLED); + enableCompletedOperationsGrouping.setTitle(" show Last "); + //add change listener + enableCompletedOperationsGrouping.addChangeHandler(new ChangeHandler() { + public void onChange(ChangeEvent event) { + String selectedItem = "" + event.getValue(); + //stuff into the master form for retrieval + form.setValue(OPERATIONS_RANGE_COMPLETED_ENABLED, selectedItem); + } + }); + //retrieve previous value otherwise initialize to true(live unlimited list) + PropertySimple retrieved = storedPortlet.getConfiguration().getSimple(OPERATIONS_RANGE_COMPLETED_ENABLED); + if (retrieved != null) { + enableCompletedOperationsGrouping.setValue(retrieved.getBooleanValue()); + } else {//default + enableCompletedOperationsGrouping.setValue(true); + } + + //wrap field item in dynamicform for addition as a field item + DynamicForm item = new DynamicForm(); + item.setFields(enableCompletedOperationsGrouping); + row.addMember(item); + + //-------------combobox for number of completed scheduled ops to display on the dashboard + final SelectItem maximumCompletedOperationsComboBox = new SelectItem(OPERATIONS_RANGE_COMPLETED); + maximumCompletedOperationsComboBox.setTitle(""); + maximumCompletedOperationsComboBox.setHint("<nobr><b> completed operations.</b></nobr>"); + //spinder: required to disable editability + maximumCompletedOperationsComboBox.setType("selection"); + //define acceptable values for display amount + String[] acceptableDisplayValues = { "1", "5", "10", "15", unlimited }; + maximumCompletedOperationsComboBox.setValueMap(acceptableDisplayValues); + //set width of dropdown display region + maximumCompletedOperationsComboBox.setWidth(100); + maximumCompletedOperationsComboBox.addChangeHandler(new ChangeHandler() { + public void onChange(ChangeEvent event) { + String selectedItem = "" + event.getValue(); + //stuff into the master form for retrieval + form.setValue(OPERATIONS_RANGE_COMPLETED, selectedItem); + } + }); + + //default selected value to 'unlimited'(live lists) and check both combobox settings here. + String selectedValue = defaultValue; + if (storedPortlet != null) { + //if property exists retrieve it + if (storedPortlet.getConfiguration().getSimple(OPERATIONS_RANGE_COMPLETED) != null) { + selectedValue = storedPortlet.getConfiguration().getSimple(OPERATIONS_RANGE_COMPLETED).getStringValue(); + } else {//insert default value + storedPortlet.getConfiguration().put(new PropertySimple(OPERATIONS_RANGE_COMPLETED, defaultValue)); + } + } + //prepopulate the combobox with the previously stored selection + maximumCompletedOperationsComboBox.setDefaultValue(selectedValue); + DynamicForm item2 = new DynamicForm(); + item2.setFields(maximumCompletedOperationsComboBox); + row.addMember(item2); + + //horizontal layout + LocatableHLayout row2 = new LocatableHLayout("enable.scheduled.operations"); + + final CheckboxItem enableScheduledOperationsGrouping = new CheckboxItem(); + enableScheduledOperationsGrouping.setName(OPERATIONS_RANGE_SCHEDULED_ENABLED); + enableScheduledOperationsGrouping.setTitle(" show Next "); + enableScheduledOperationsGrouping.addChangeHandler(new ChangeHandler() { + public void onChange(ChangeEvent event) { + String selectedItem = "" + event.getValue(); + //stuff into the master form for retrieval + form.setValue(OPERATIONS_RANGE_SCHEDULED_ENABLED, selectedItem); + } + }); + + //wrap field item in dynamicform for addition + DynamicForm fieldWrapper = new DynamicForm(); + fieldWrapper.setFields(enableScheduledOperationsGrouping); + row2.addMember(fieldWrapper); + + //retrieve previous value otherwise initialize to true(live unlimited list) + retrieved = storedPortlet.getConfiguration().getSimple(OPERATIONS_RANGE_SCHEDULED_ENABLED); + if (retrieved != null) { + enableScheduledOperationsGrouping.setValue(retrieved.getBooleanValue()); + } else { + enableScheduledOperationsGrouping.setValue(true); + } + + //------------- Build second combobox for timeframe for problem resources search. + final SelectItem maximumScheduledOperationsComboBox = new SelectItem(OPERATIONS_RANGE_SCHEDULED); + maximumScheduledOperationsComboBox.setTitle(""); + maximumScheduledOperationsComboBox.setHint("<nobr><b> scheduled operations.</b></nobr>"); + maximumScheduledOperationsComboBox.setType("selection"); + maximumScheduledOperationsComboBox.setValueMap(acceptableDisplayValues); + maximumScheduledOperationsComboBox.setWidth(100); + maximumScheduledOperationsComboBox.addChangeHandler(new ChangeHandler() { + public void onChange(ChangeEvent event) { + String selectedItem = "" + event.getValue(); + //stuff into the master form for retrieval + form.setValue(OPERATIONS_RANGE_SCHEDULED, selectedItem); + } + }); + + //set to default + selectedValue = defaultValue; + if (storedPortlet != null) { + //if property exists retrieve it + if (storedPortlet.getConfiguration().getSimple(OPERATIONS_RANGE_SCHEDULED) != null) { + selectedValue = storedPortlet.getConfiguration().getSimple(OPERATIONS_RANGE_SCHEDULED).getStringValue(); + } else {//insert default value + storedPortlet.getConfiguration().put(new PropertySimple(OPERATIONS_RANGE_SCHEDULED, defaultValue)); + } + } + //prepopulate the combobox with the previously stored selection + maximumScheduledOperationsComboBox.setDefaultValue(selectedValue); + DynamicForm fieldWrapper2 = new DynamicForm(); + fieldWrapper2.setFields(maximumScheduledOperationsComboBox); + row2.addMember(fieldWrapper2); + column.addMember(row); + column.addMember(row2); + form.addChild(column); + + //submit handler + form.addSubmitValuesHandler(new SubmitValuesHandler() { + @Override + public void onSubmitValues(SubmitValuesEvent event) { + //no need to insert validation here as user not allowed to enter values + if (form.getValue(OPERATIONS_RANGE_SCHEDULED) != null) {//if new value supplied + storedPortlet.getConfiguration().put( + new PropertySimple(OPERATIONS_RANGE_SCHEDULED, form.getValue(OPERATIONS_RANGE_SCHEDULED))); + } + if (form.getValue(OPERATIONS_RANGE_COMPLETED) != null) {//if new value supplied + storedPortlet.getConfiguration().put( + new PropertySimple(OPERATIONS_RANGE_COMPLETED, form.getValue(OPERATIONS_RANGE_COMPLETED))); + } + if (form.getValue(OPERATIONS_RANGE_COMPLETED_ENABLED) != null) {//if new value supplied + storedPortlet.getConfiguration().put( + new PropertySimple(OPERATIONS_RANGE_COMPLETED_ENABLED, form + .getValue(OPERATIONS_RANGE_COMPLETED_ENABLED))); + } + if (form.getValue(OPERATIONS_RANGE_SCHEDULED_ENABLED) != null) {//if new value supplied + storedPortlet.getConfiguration().put( + new PropertySimple(OPERATIONS_RANGE_SCHEDULED_ENABLED, form + .getValue(OPERATIONS_RANGE_SCHEDULED_ENABLED))); + } + } + }); + + return form; }
public static final class Factory implements PortletViewFactory { @@ -113,4 +359,69 @@ public class OperationsPortlet extends LocatableVLayout implements Portlet { } }
+ 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. + */ + @Override + public void redraw() { + super.redraw(); + //now reload the table data + this.recentOperationsGrid.invalidateCache(); + this.recentOperationsGrid.markForRedraw(); + this.scheduledOperationsGrid.invalidateCache(); + this.scheduledOperationsGrid.markForRedraw(); + } + + public ConfigurationDefinition getConfigurationDefinition() { + ConfigurationDefinition definition = new ConfigurationDefinition("OperationsPortlet Configuration", + "The configuration settings for the Operations portlet."); + + definition.put(new PropertyDefinitionSimple(OPERATIONS_RANGE_COMPLETED, + "Maximum number of Completed operations to display.", true, PropertySimpleType.STRING)); + definition.put(new PropertyDefinitionSimple(OPERATIONS_RANGE_SCHEDULED, + "Maximum number of Scheduled operations to display.", true, PropertySimpleType.STRING)); + definition + .put(new PropertyDefinitionSimple(OPERATIONS_RANGE_COMPLETED_ENABLED, + "Whether to enable completed operations results grouping for dashboard.", true, + PropertySimpleType.BOOLEAN)); + definition + .put(new PropertyDefinitionSimple(OPERATIONS_RANGE_SCHEDULED_ENABLED, + "Whether to enable scheduled operations results grouping for dashboard.", true, + PropertySimpleType.BOOLEAN)); + + return definition; + } + } 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 f87d80d..57472d3 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,8 +19,6 @@ package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.problems * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-import java.util.ArrayList; - import com.smartgwt.client.types.Overflow; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.HTMLFlow; @@ -84,6 +82,7 @@ public class ProblemResourcesPortlet extends Table implements CustomSettingsPort listGrid.setCellHeight(50); //wrap to display disambiguation listGrid.setWrapCells(true); + // System.out.println("@@@@:"+listGrid.getField(ProblemResourcesDataSource.resource)+":W"+listGrid.getField(ProblemResourcesDataSource.resource).getWidth()); listGrid.getField(ProblemResourcesDataSource.resource).setWidth("40%"); listGrid.getField(ProblemResourcesDataSource.location).setWidth("40%"); listGrid.getField(ProblemResourcesDataSource.alerts).setWidth("10%"); @@ -137,20 +136,14 @@ public class ProblemResourcesPortlet extends Table implements CustomSettingsPort final DynamicForm form = new DynamicForm();
//-------------combobox for number of resource to display on the dashboard - // final ComboBoxItem maximumProblemResourcesComboBox = new ComboBoxItem(PROBLEM_RESOURCE_SHOW_MAX); - //TODO: spinder(9/1/10) field is still editable. This looks like a bug. 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.setType("comboBox"); + //spinder 9/3/10: the following is required workaround to disable editability of combobox. + maximumProblemResourcesComboBox.setType("selection"); //define acceptable values for display amount String[] acceptableDisplayValues = { "5", "10", "15", "20", "30", unlimited }; maximumProblemResourcesComboBox.setValueMap(acceptableDisplayValues); - //load the acceptable values for validity check later. - final ArrayList<String> acceptableProblemResourceDisplayValues = new ArrayList<String>(); - for (String value : acceptableDisplayValues) { - acceptableProblemResourceDisplayValues.add(value); - } //set width of dropdown display region maximumProblemResourcesComboBox.setWidth(100);
@@ -171,14 +164,10 @@ public class ProblemResourcesPortlet extends Table implements CustomSettingsPort final SelectItem maximumTimeProblemResourcesComboBox = new SelectItem(PROBLEM_RESOURCE_SHOW_HRS); maximumTimeProblemResourcesComboBox.setTitle("For the last "); maximumTimeProblemResourcesComboBox.setHint("<nobr><b> hours </b></nobr>"); - maximumTimeProblemResourcesComboBox.setType("comboBox"); + //spinder 9/3/10: the following is required workaround to disable editability of combobox. + maximumTimeProblemResourcesComboBox.setType("selection"); //define acceptable values for display amount String[] acceptableTimeValues = { "1", "4", "8", "24", "48", unlimited }; - //load the acceptable values for validity check later. - final ArrayList<String> acceptableTimeDisplayValues = new ArrayList<String>(); - for (String value : acceptableTimeValues) { - acceptableTimeDisplayValues.add(value); - } maximumTimeProblemResourcesComboBox.setValueMap(acceptableTimeValues); maximumTimeProblemResourcesComboBox.setWidth(100);
@@ -202,15 +191,11 @@ public class ProblemResourcesPortlet extends Table implements CustomSettingsPort form.addSubmitValuesHandler(new SubmitValuesHandler() { @Override public void onSubmitValues(SubmitValuesEvent event) { - String maxItems = (String) form.getValue(PROBLEM_RESOURCE_SHOW_MAX); - String timeFrame = (String) form.getValue(PROBLEM_RESOURCE_SHOW_HRS); - //TODO: spinder 9/1/10: use smartgwt validation here? - //shouldn't be necessary, but SelectItem remains editable for odd reason. - if (acceptableProblemResourceDisplayValues.contains(maxItems.trim())) { + if (form.getValue(PROBLEM_RESOURCE_SHOW_MAX) != null) { storedPortlet.getConfiguration().put( new PropertySimple(PROBLEM_RESOURCE_SHOW_MAX, form.getValue(PROBLEM_RESOURCE_SHOW_MAX))); } - if (acceptableTimeDisplayValues.contains(timeFrame.trim())) { + if (form.getValue(PROBLEM_RESOURCE_SHOW_HRS) != null) { storedPortlet.getConfiguration().put( new PropertySimple(PROBLEM_RESOURCE_SHOW_HRS, form.getValue(PROBLEM_RESOURCE_SHOW_HRS))); } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableListGrid.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableListGrid.java index 87ed4b7..28e6169 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableListGrid.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableListGrid.java @@ -13,7 +13,7 @@ public class LocatableListGrid extends ListGrid implements Locatable {
/** * <pre> - * ID Format: "simpleClassname_locatorId" + * ID Format: "scClassname-id" * </pre> * @param locatorId not null or empty. */