IDEMPIERE-3641 IDEMPIERE-3008 : Store divider of tree panel location for window per user is broken in 5.1

This commit is contained in:
Nicolas Micoud 2018-02-26 12:18:35 +01:00
parent a75dd18925
commit cfb0c7c6e7
1 changed files with 47 additions and 25 deletions

View File

@ -209,6 +209,8 @@ DataStatusListener, IADTabpanel, IdSpace, IFieldEditorContainer
public static final String ON_TOGGLE_EVENT = "onToggle"; public static final String ON_TOGGLE_EVENT = "onToggle";
private static final String DEFAULT_PANEL_WIDTH = "300px";
private static enum SouthEvent { private static enum SouthEvent {
SLIDE(), SLIDE(),
OPEN(), OPEN(),
@ -370,7 +372,7 @@ DataStatusListener, IADTabpanel, IdSpace, IFieldEditorContainer
treePanel = new ADTreePanel(windowNo, gridTab.getTabNo()); treePanel = new ADTreePanel(windowNo, gridTab.getTabNo());
West west = new West(); West west = new West();
west.appendChild(treePanel); west.appendChild(treePanel);
ZKUpdateUtil.setWidth(west, "300px"); ZKUpdateUtil.setWidth(west, widthTreePanel());
west.setCollapsible(true); west.setCollapsible(true);
west.setSplittable(true); west.setSplittable(true);
west.setAutoscroll(true); west.setAutoscroll(true);
@ -1302,6 +1304,15 @@ DataStatusListener, IADTabpanel, IdSpace, IFieldEditorContainer
return height; return height;
} }
private String widthTreePanel() {
String width = null;
int windowId = getGridTab().getAD_Window_ID();
int adTabId = getGridTab().getAD_Tab_ID();
if (windowId > 0 && adTabId > 0)
width = Env.getPreference(Env.getCtx(), windowId, adTabId+"|TreePanel.Width", false);
return Util.isEmpty(width) ? DEFAULT_PANEL_WIDTH : width;
}
private void navigateTo(DefaultTreeNode<MTreeNode> value) { private void navigateTo(DefaultTreeNode<MTreeNode> value) {
MTreeNode treeNode = value.getData(); MTreeNode treeNode = value.getData();
// We Have a TreeNode // We Have a TreeNode
@ -1877,7 +1888,22 @@ DataStatusListener, IADTabpanel, IdSpace, IFieldEditorContainer
if (formContainer.getSouth() != null) { if (formContainer.getSouth() != null) {
if (formContainer.getSouth().isVisible() && formContainer.getSouth().isOpen()) { if (formContainer.getSouth().isVisible() && formContainer.getSouth().isOpen()) {
String height = formContainer.getSouth().getHeight(); String height = formContainer.getSouth().getHeight();
if (! Util.isEmpty(height)) { if (! Util.isEmpty(height))
savePreference("DetailPane.Height", height);
}
}
if (treePanel != null && formContainer.getWest() != null) {
if (formContainer.getWest().isVisible() && formContainer.getWest().isOpen()) {
String width = formContainer.getWest().getWidth();
if (! Util.isEmpty(width))
savePreference("TreePanel.Width", width);
}
}
super.onPageDetached(page);
}
void savePreference(String attribute, String value)
{
int windowId = getGridTab().getAD_Window_ID(); int windowId = getGridTab().getAD_Window_ID();
int adTabId = getGridTab().getAD_Tab_ID(); int adTabId = getGridTab().getAD_Tab_ID();
if (windowId > 0 && adTabId > 0) { if (windowId > 0 && adTabId > 0) {
@ -1885,24 +1911,20 @@ DataStatusListener, IADTabpanel, IdSpace, IFieldEditorContainer
int userId = Env.getAD_User_ID(Env.getCtx()); int userId = Env.getAD_User_ID(Env.getCtx());
MPreference preference = query.setOnlyActiveRecords(true) MPreference preference = query.setOnlyActiveRecords(true)
.setApplyAccessFilter(true) .setApplyAccessFilter(true)
.setParameters(windowId, adTabId+"|DetailPane.Height", userId) .setParameters(windowId, adTabId+"|"+attribute, userId)
.first(); .first();
if (preference == null || preference.getAD_Preference_ID() <= 0) { if (preference == null || preference.getAD_Preference_ID() <= 0) {
preference = new MPreference(Env.getCtx(), 0, null); preference = new MPreference(Env.getCtx(), 0, null);
preference.setAD_Window_ID(windowId); preference.setAD_Window_ID(windowId);
preference.set_ValueOfColumn("AD_User_ID", userId); // required set_Value for System=0 user preference.set_ValueOfColumn("AD_User_ID", userId); // required set_Value for System=0 user
preference.setAttribute(adTabId+"|DetailPane.Height"); preference.setAttribute(adTabId+"|"+attribute);
} }
preference.setValue(height); preference.setValue(value);
preference.saveEx(); preference.saveEx();
//update current context //update current context
Env.getCtx().setProperty("P"+windowId+"|"+adTabId+"|DetailPane.Height", height); Env.getCtx().setProperty("P"+windowId+"|"+adTabId+"|"+attribute, value);
} }
} }
}
}
super.onPageDetached(page);
}
protected void onClientInfo() { protected void onClientInfo() {
if (!uiCreated || gridTab == null) return; if (!uiCreated || gridTab == null) return;