Alexander Wels has uploaded a new change for review. Change subject: webadmin: Store subtab in browser ......................................................................
webadmin: Store subtab in browser - This patch adds the ability to store the subtab height in the browser local storage. Change-Id: I2a7cb529914703e71da9ac323ee15bdb68b1449a Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1140249 Signed-off-by: Alexander Wels <aw...@redhat.com> --- M frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/MainContentView.java 1 file changed, 36 insertions(+), 9 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/78/35178/1 diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/MainContentView.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/MainContentView.java index 0b4f8cf..7d66823 100644 --- a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/MainContentView.java +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/MainContentView.java @@ -1,23 +1,38 @@ package org.ovirt.engine.ui.webadmin.section.main.view; +import org.ovirt.engine.ui.common.system.ClientStorage; import org.ovirt.engine.ui.common.view.AbstractView; import org.ovirt.engine.ui.webadmin.section.main.presenter.MainContentPresenter; import com.google.gwt.user.client.ui.IsWidget; import com.google.gwt.user.client.ui.SimplePanel; import com.google.gwt.user.client.ui.SplitLayoutPanel; +import com.google.inject.Inject; public class MainContentView extends AbstractView implements MainContentPresenter.ViewDef { - private static final int subTabPanelMaxHeight = 300; + private static final int SPLITTER_THICKNESS = 4; + private static final String SUB_TAB_HEIGHT_KEY = "subtabHeight"; //$NON-NLS-1$ - private final SplitLayoutPanel splitPanel = new SplitLayoutPanel(4); + private final SplitLayoutPanel splitPanel; private final SimplePanel mainTabPanelContainer = new SimplePanel(); private final SimplePanel subTabPanelContainer = new SimplePanel(); - + private final ClientStorage clientStorage; private boolean subTabPanelVisible; - public MainContentView() { + @Inject + public MainContentView(final ClientStorage clientStorage) { + splitPanel = new SplitLayoutPanel(SPLITTER_THICKNESS) { + @Override + public void onResize() { + super.onResize(); + if (subTabPanelVisible) { + clientStorage.setLocalItem(SUB_TAB_HEIGHT_KEY, + String.valueOf(subTabPanelContainer.getOffsetHeight())); + } + } + }; + this.clientStorage = clientStorage; initWidget(splitPanel); initSplitPanel(); } @@ -44,11 +59,7 @@ splitPanel.clear(); if (subTabPanelVisible) { - int subTabHeight = splitPanel.getOffsetHeight() / 2; - if (subTabHeight > subTabPanelMaxHeight) { - subTabHeight = subTabPanelMaxHeight; - } - splitPanel.addSouth(subTabPanelContainer, subTabHeight); + splitPanel.addSouth(subTabPanelContainer, getSubTabHeight()); splitPanel.add(mainTabPanelContainer); } else { splitPanel.add(mainTabPanelContainer); @@ -58,4 +69,20 @@ } } + private int getSubTabHeight() { + int subTabHeight = splitPanel.getOffsetHeight() / 2; + String storedHeight = clientStorage.getLocalItem(SUB_TAB_HEIGHT_KEY); + if (storedHeight != null) { + try { + subTabHeight = Integer.parseInt(storedHeight); + } catch (NumberFormatException nfe) { + //Default to max height if stored value is invalid. + subTabHeight = subTabPanelMaxHeight; + } + } else if (subTabHeight > subTabPanelMaxHeight) { + subTabHeight = subTabPanelMaxHeight; + } + return subTabHeight; + } + } -- To view, visit http://gerrit.ovirt.org/35178 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I2a7cb529914703e71da9ac323ee15bdb68b1449a Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Alexander Wels <aw...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches