modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java | 135 ++++++++-- modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java | 3 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletWindow.java | 88 +++++- 3 files changed, 189 insertions(+), 37 deletions(-)
New commits: commit f758dd314f3701432e824cc7509fdba21f76d703 Author: Jay Shaughnessy jshaughn@redhat.com Date: Wed May 30 14:18:57 2012 -0400
[Bug 826673 - RFE: Add ability to maximize a dashboard portlet] - add this ability - also, fix a bug in portlet removal where the portlet window was not being fully removed from the current dashboard.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java index 43a8bc0..ac85aad 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java @@ -18,6 +18,13 @@ */ package org.rhq.enterprise.gui.coregui.client.dashboard;
+import java.util.EnumSet; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.Set; + import com.google.gwt.user.client.rpc.AsyncCallback; import com.smartgwt.client.types.Overflow; import com.smartgwt.client.widgets.AnimationCallback; @@ -25,7 +32,11 @@ import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.form.DynamicForm; import com.smartgwt.client.widgets.form.events.ColorSelectedEvent; import com.smartgwt.client.widgets.form.events.ColorSelectedHandler; -import com.smartgwt.client.widgets.form.fields.*; +import com.smartgwt.client.widgets.form.fields.ButtonItem; +import com.smartgwt.client.widgets.form.fields.CanvasItem; +import com.smartgwt.client.widgets.form.fields.FormItem; +import com.smartgwt.client.widgets.form.fields.StaticTextItem; +import com.smartgwt.client.widgets.form.fields.TextItem; import com.smartgwt.client.widgets.form.fields.events.BlurEvent; import com.smartgwt.client.widgets.form.fields.events.BlurHandler; import com.smartgwt.client.widgets.layout.LayoutSpacer; @@ -36,6 +47,7 @@ import com.smartgwt.client.widgets.menu.events.ClickHandler; import com.smartgwt.client.widgets.menu.events.ItemClickEvent; import com.smartgwt.client.widgets.menu.events.ItemClickHandler; import com.smartgwt.client.widgets.menu.events.MenuItemClickEvent; + import org.rhq.core.domain.auth.Subject; import org.rhq.core.domain.authz.Permission; import org.rhq.core.domain.common.EntityContext; @@ -50,13 +62,25 @@ import org.rhq.enterprise.gui.coregui.client.CoreGUI; import org.rhq.enterprise.gui.coregui.client.ImageManager; import org.rhq.enterprise.gui.coregui.client.UserSessionManager; import org.rhq.enterprise.gui.coregui.client.components.form.ColorButtonItem; -import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.*; -import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.resource.*; +import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupBundleDeploymentsPortlet; +import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupConfigurationUpdatesPortlet; +import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupMetricsPortlet; +import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupOobsPortlet; +import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupOperationsPortlet; +import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupPkgHistoryPortlet; +import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.resource.ResourceBundleDeploymentsPortlet; +import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.resource.ResourceConfigurationUpdatesPortlet; +import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.resource.ResourceEventsPortlet; +import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.resource.ResourceMetricsPortlet; +import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.resource.ResourceOperationsPortlet; +import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.resource.ResourcePkgHistoryPortlet; import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; import org.rhq.enterprise.gui.coregui.client.util.message.Message; -import org.rhq.enterprise.gui.coregui.client.util.selenium.*; - -import java.util.*; +import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm; +import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIMenuButton; +import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableMenu; +import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout; +import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
/** * @author Jay Shaughnessy @@ -68,13 +92,14 @@ public class DashboardView extends LocatableVLayout { private DashboardContainer dashboardContainer; private Dashboard storedDashboard;
- boolean editMode = false; + private boolean editMode = false;
PortalLayout portalLayout; LocatableDynamicForm editForm; IMenuButton addPortlet;
HashSet<PortletWindow> portletWindows = new HashSet<PortletWindow>(); + private static String STOP = MSG.view_dashboards_portlets_refresh_none(); private static String REFRESH1 = MSG.view_dashboards_portlets_refresh_one_min(); private static String REFRESH5 = MSG.view_dashboards_portlets_refresh_multiple_min(String.valueOf(5)); @@ -97,6 +122,8 @@ public class DashboardView extends LocatableVLayout { // the view is set to a Tab's pane. private boolean isInitialized = false;
+ private PortletWindow maximizedPortlet = null; + /** * Convenience constructor for subsystem context. * @@ -593,20 +620,21 @@ public class DashboardView extends LocatableVLayout { outline.draw(); outline.bringToFront();
- outline.animateRect(newPortletWindow.getPageLeft(), newPortletWindow.getPageTop(), newPortletWindow - .getVisibleWidth(), newPortletWindow.getViewportHeight(), new AnimationCallback() { - public void execute(boolean earlyFinish) { - // callback at end of animation - destroy placeholder and outline; show the new portlet - placeHolder.destroy(); - outline.destroy(); - newPortletWindow.show(); - } - }, 750); + outline.animateRect(newPortletWindow.getPageLeft(), newPortletWindow.getPageTop(), + newPortletWindow.getVisibleWidth(), newPortletWindow.getViewportHeight(), new AnimationCallback() { + public void execute(boolean earlyFinish) { + // callback at end of animation - destroy placeholder and outline; show the new portlet + placeHolder.destroy(); + outline.destroy(); + newPortletWindow.show(); + } + }, 750); save(); }
- public void removePortlet(DashboardPortlet portlet) { - storedDashboard.removePortlet(portlet); + public void removePortlet(PortletWindow portletWindow) { + storedDashboard.removePortlet(portletWindow.getStoredPortlet()); + this.portletWindows.remove(portletWindow);
// portlet remove means the portlet locations may have changed. The selenium testing locators include // positioning info. So, in this case we have to take the hit and completely refresh the dash. @@ -752,8 +780,8 @@ public class DashboardView extends LocatableVLayout { boolean unpersistedDash = (storedPortlet.getDashboard().getId() == 0 || updatedPortlet.getDashboard().getId() == 0); boolean dashMatchId = (!unpersistedDash && (storedPortlet.getDashboard().getId() == updatedPortlet .getDashboard().getId())); - boolean dashMatchName = (unpersistedDash && storedPortlet.getDashboard().getName().equals( - updatedPortlet.getDashboard().getName())); + boolean dashMatchName = (unpersistedDash && storedPortlet.getDashboard().getName() + .equals(updatedPortlet.getDashboard().getName())); if (!(dashMatchId || dashMatchName)) { return false; } @@ -792,6 +820,12 @@ public class DashboardView extends LocatableVLayout {
public void setEditMode(boolean editMode) { this.editMode = editMode; + + // don't allow resizing in min/max in edit mode + for (PortletWindow portletWindow : portletWindows) { + portletWindow.hideSizingHeaderControls(editMode); + } + if (editMode) { this.editForm.show(); // @@ -872,4 +906,65 @@ public class DashboardView extends LocatableVLayout { return resourceComposite; }
+ public boolean isMaximized() { + return (maximizedPortlet != null); + } + + public PortletWindow getMaximizePortlet() { + return maximizedPortlet; + } + + public void maximizePortlet(PortletWindow portletWindow) { + if (isMaximized()) { + return; + } + + maximizedPortlet = portletWindow; + + int numColumns = storedDashboard.getColumns(); + for (int i = 0; i < numColumns; ++i) { + PortalColumn col = portalLayout.getPortalColumn(i); + Canvas portlet = col.getMember(portletWindow.getID()); + if (null == portlet) { + col.hide(); + } else { + for (Canvas member : col.getMembers()) { + if (!member.equals(portlet)) { + member.hide(); + } else { + ((PortletWindow) member).hideSizingHeaderControls(true); + member.setHeight100(); + } + } + } + } + + portalLayout.markForRedraw(); + } + + public void restorePortlet() { + if (!isMaximized()) { + return; + } + + int numColumns = storedDashboard.getColumns(); + for (int i = 0; i < numColumns; ++i) { + PortalColumn col = portalLayout.getPortalColumn(i); + if (!col.isVisible()) { + col.show(); + } else { + for (Canvas member : col.getMembers()) { + if (!member.isVisible()) { + member.show(); + } else { + ((PortletWindow) member).hideSizingHeaderControls(false); + member.setHeight(maximizedPortlet.getStoredPortlet().getHeight()); + } + } + } + } + + maximizedPortlet = null; + portalLayout.markForRedraw(); + } } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java index 5cbc4c7..52e3a8f 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java @@ -188,6 +188,9 @@ public class DashboardsView extends LocatableVLayout implements DashboardContain public void onClick(ClickEvent clickEvent) { editMode = !editMode; editButton.setTitle(editMode ? MSG.common_title_view_mode() : MSG.common_title_edit_mode()); + if (selectedDashboardView.isMaximized()) { + selectedDashboardView.restorePortlet(); + } selectedDashboardView.setEditMode(editMode); } }); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletWindow.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletWindow.java index ff6f522..bb8d568 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletWindow.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletWindow.java @@ -22,13 +22,28 @@ */ package org.rhq.enterprise.gui.coregui.client.dashboard;
+import java.util.ArrayList; +import java.util.Set; + import com.smartgwt.client.types.DragAppearance; import com.smartgwt.client.types.HeaderControls; import com.smartgwt.client.types.Overflow; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.HeaderControl; import com.smartgwt.client.widgets.HeaderControl.HeaderIcon; -import com.smartgwt.client.widgets.events.*; +import com.smartgwt.client.widgets.events.ClickEvent; +import com.smartgwt.client.widgets.events.ClickHandler; +import com.smartgwt.client.widgets.events.CloseClickEvent; +import com.smartgwt.client.widgets.events.CloseClickHandler; +import com.smartgwt.client.widgets.events.DragResizeStopEvent; +import com.smartgwt.client.widgets.events.DragResizeStopHandler; +import com.smartgwt.client.widgets.events.MinimizeClickEvent; +import com.smartgwt.client.widgets.events.MinimizeClickHandler; +import com.smartgwt.client.widgets.events.MouseOverEvent; +import com.smartgwt.client.widgets.events.MouseOverHandler; +import com.smartgwt.client.widgets.events.RestoreClickEvent; +import com.smartgwt.client.widgets.events.RestoreClickHandler; + import org.rhq.core.domain.authz.Permission; import org.rhq.core.domain.common.EntityContext; import org.rhq.core.domain.dashboard.DashboardPortlet; @@ -37,8 +52,6 @@ import org.rhq.enterprise.gui.coregui.client.components.table.Table; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHeaderControl; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableWindow;
-import java.util.Set; - /** * @author Greg Hinkle * @author Jay Shaughnessy @@ -104,6 +117,12 @@ public class PortletWindow extends LocatableWindow { } };
+ private HeaderControl maximizeHeaderControl = new HeaderControl(HeaderControl.MAXIMIZE, new ClickHandler() { + public void onClick(ClickEvent event) { + PortletWindow.this.dashboardView.maximizePortlet(PortletWindow.this); + } + }); + public PortletWindow(String locatorId, DashboardView dashboardView, DashboardPortlet dashboardPortlet, EntityContext context) { super(locatorId); @@ -139,18 +158,7 @@ public class PortletWindow extends LocatableWindow { }
// customize the appearance and order of the controls in the window header - if (headerIcon != null) { - setHeaderControls(HeaderControls.MINIMIZE_BUTTON, headerIcon, HeaderControls.HEADER_LABEL, - new LocatableHeaderControl(extendLocatorId("Refresh"), HeaderControl.REFRESH, refreshHandler), - new LocatableHeaderControl(extendLocatorId("Settings"), HeaderControl.SETTINGS, settingsHandler), - new LocatableHeaderControl(extendLocatorId("Help"), HeaderControl.HELP, helpHandler), - HeaderControls.CLOSE_BUTTON); - } else { - setHeaderControls(HeaderControls.MINIMIZE_BUTTON, HeaderControls.HEADER_LABEL, new LocatableHeaderControl( - extendLocatorId("Refresh"), HeaderControl.REFRESH, refreshHandler), new LocatableHeaderControl( - extendLocatorId("Settings"), HeaderControl.SETTINGS, settingsHandler), new LocatableHeaderControl( - extendLocatorId("Help"), HeaderControl.HELP, helpHandler), HeaderControls.CLOSE_BUTTON); - } + initHeaderControls();
// enable predefined component animation setAnimateMinimize(true); @@ -189,8 +197,12 @@ public class PortletWindow extends LocatableWindow {
addCloseClickHandler(new CloseClickHandler() { public void onCloseClick(CloseClickEvent closeClientEvent) { - PortletWindow.this.dashboardView.removePortlet(PortletWindow.this.storedPortlet); - destroy(); + if (PortletWindow.this.dashboardView.isMaximized()) { + PortletWindow.this.dashboardView.restorePortlet(); + } else { + PortletWindow.this.dashboardView.removePortlet(PortletWindow.this); + destroy(); + } } });
@@ -198,6 +210,48 @@ public class PortletWindow extends LocatableWindow { setHelpClickHandler(helpHandler); }
+ private void initHeaderControls() { + + ArrayList<Object> headerControls = new ArrayList<Object>(); + + headerControls.add(HeaderControls.MINIMIZE_BUTTON); + addMinimizeClickHandler(new MinimizeClickHandler() { + public void onMinimizeClick(MinimizeClickEvent event) { + maximizeHeaderControl.hide(); + } + }); + addRestoreClickHandler(new RestoreClickHandler() { + public void onRestoreClick(RestoreClickEvent event) { + maximizeHeaderControl.show(); + } + }); + + headerControls.add(maximizeHeaderControl); + + if (headerIcon != null) { + headerControls.add(headerIcon); + } + headerControls.add(HeaderControls.HEADER_LABEL); + headerControls.add(new HeaderControl(HeaderControl.REFRESH, refreshHandler)); + headerControls.add(new HeaderControl(HeaderControl.SETTINGS, settingsHandler)); + headerControls.add(new HeaderControl(HeaderControl.HELP, helpHandler)); + headerControls.add(HeaderControls.CLOSE_BUTTON); + + setHeaderControls(headerControls.toArray(new Object[headerControls.size()])); + } + + void hideSizingHeaderControls(boolean hideControls) { + + if (hideControls) { + setShowMinimizeButton(false); + maximizeHeaderControl.hide(); + + } else { + setShowMinimizeButton(true); + maximizeHeaderControl.show(); + } + } + @Override protected void onInit() { super.onInit();
rhq-commits@lists.fedorahosted.org