You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2016/01/25 16:07:54 UTC
[33/50] [abbrv] isis git commit: ISIS-993: in process of converting
TabbedPanel into own panel.
ISIS-993: in process of converting TabbedPanel into own panel.
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/fc5355f5
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/fc5355f5
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/fc5355f5
Branch: refs/heads/ISIS-993
Commit: fc5355f5dad5b81e67d0e3f1121b5e88ecf4e3fe
Parents: 691a0be
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Thu Jan 14 16:33:59 2016 +0000
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Mon Jan 25 15:06:07 2016 +0000
----------------------------------------------------------------------
.../entity/tabgrouplist/TabGroupListPanel.java | 96 ++++++++++++--------
1 file changed, 57 insertions(+), 39 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/fc5355f5/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/tabgrouplist/TabGroupListPanel.java
----------------------------------------------------------------------
diff --git a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/tabgrouplist/TabGroupListPanel.java b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/tabgrouplist/TabGroupListPanel.java
index 770877e..bb6d59b 100644
--- a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/tabgrouplist/TabGroupListPanel.java
+++ b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/tabgrouplist/TabGroupListPanel.java
@@ -95,52 +95,70 @@ public class TabGroupListPanel extends PanelAbstract<EntityModel> {
}
});
}
- final AjaxBootstrapTabbedPanel tabbedPanel = new AjaxBootstrapTabbedPanel(ID_TAB_GROUP, tabs) {
- @Override
- public TabbedPanel setSelectedTab(final int index) {
- saveSelectedTabInSession(tabGroup, index, entityModel);
- return super.setSelectedTab(index);
- }
- };
- setSelectedTabFromSessionIfAny(tabGroup, tabbedPanel, entityModel);
+ final AjaxBootstrapTabbedPanel tabbedPanel = new MyAjaxBootstrapTabbedPanel(tabs, tabGroup,
+ entityModel);
return tabbedPanel;
}
- private void setSelectedTabFromSessionIfAny(
- final TabGroup tabGroup, final AjaxBootstrapTabbedPanel ajaxBootstrapTabbedPanel,
- final EntityModel entityModel) {
- final String key = buildKey(tabGroup, entityModel);
- final String value = (String) getSession().getAttribute(key);
- if(value != null) {
- final int tabIndex = Integer.parseInt(value);
- final int numTabs = ajaxBootstrapTabbedPanel.getTabs().size();
- if(tabIndex < numTabs) {
- // to support dynamic reloading; the data in the session might not be compatible with current layout.
- ajaxBootstrapTabbedPanel.setSelectedTab(tabIndex);
- }
- }
- }
-
- private void saveSelectedTabInSession(
- final TabGroup tabGroup,
- final int tabIndex,
- final EntityModel entityModel) {
- final String key = buildKey(tabGroup, entityModel);
- getSession().setAttribute(key, "" + tabIndex);
- }
-
- private String buildKey(final TabGroup tabGroup, final EntityModel entityModel) {
- final ObjectAdapterMemento objectAdapterMemento = entityModel.getObjectAdapterMemento();
- final RootOid oid = (RootOid) objectAdapterMemento.getObjectAdapter(
- AdapterManager.ConcurrencyChecking.NO_CHECK).getOid();
- final String key =
- IsisContext.getOidMarshaller().marshalNoVersion(oid) + ":" + tabGroup.getPath() + "#selectedTab";
- return key;
- }
};
add(tabGroupsList);
}
+ private static class MyAjaxBootstrapTabbedPanel extends AjaxBootstrapTabbedPanel {
+ private final TabGroup tabGroup;
+ private final EntityModel entityModel;
+
+ public MyAjaxBootstrapTabbedPanel(
+ final List<ITab> tabs,
+ final TabGroup tabGroup,
+ final EntityModel entityModel) {
+ super(TabGroupListPanel.ID_TAB_GROUP, tabs);
+ this.tabGroup = tabGroup;
+ this.entityModel = entityModel;
+
+ setSelectedTabFromSessionIfAny(tabGroup, this, entityModel);
+ }
+
+ @Override
+ public TabbedPanel setSelectedTab(final int index) {
+ saveSelectedTabInSession(tabGroup, index, entityModel);
+ return super.setSelectedTab(index);
+ }
+
+ private void setSelectedTabFromSessionIfAny(
+ final TabGroup tabGroup,
+ final AjaxBootstrapTabbedPanel ajaxBootstrapTabbedPanel,
+ final EntityModel entityModel) {
+ final String key = buildKey(tabGroup, entityModel);
+ final String value = (String) getSession().getAttribute(key);
+ if(value != null) {
+ final int tabIndex = Integer.parseInt(value);
+ final int numTabs = ajaxBootstrapTabbedPanel.getTabs().size();
+ if(tabIndex < numTabs) {
+ // to support dynamic reloading; the data in the session might not be compatible with current layout.
+ ajaxBootstrapTabbedPanel.setSelectedTab(tabIndex);
+ }
+ }
+ }
+
+ private void saveSelectedTabInSession(
+ final TabGroup tabGroup,
+ final int tabIndex,
+ final EntityModel entityModel) {
+ final String key = buildKey(tabGroup, entityModel);
+ getSession().setAttribute(key, "" + tabIndex);
+ }
+
+ private String buildKey(final TabGroup tabGroup, final EntityModel entityModel) {
+ final ObjectAdapterMemento objectAdapterMemento = entityModel.getObjectAdapterMemento();
+ final RootOid oid = (RootOid) objectAdapterMemento.getObjectAdapter(
+ AdapterManager.ConcurrencyChecking.NO_CHECK).getOid();
+ final String key =
+ IsisContext.getOidMarshaller().marshalNoVersion(oid) + ":" + tabGroup.getPath() + "#selectedTab";
+ return key;
+ }
+
+ }
}