IDEMPIERE-3008 Store divider of tree panel location for window per user

This commit is contained in:
Nicolas Micoud 2016-01-20 16:18:05 +01:00
parent 6217046c4d
commit 36e41f171b
1 changed files with 48 additions and 23 deletions

View File

@ -203,6 +203,8 @@ DataStatusListener, IADTabpanel, IdSpace, IFieldEditorContainer
public static final String ON_TOGGLE_EVENT = "onToggle";
private static final String DEFAULT_PANEL_WIDTH = "300px";
private static enum SouthEvent {
SLIDE(),
OPEN(),
@ -360,7 +362,7 @@ DataStatusListener, IADTabpanel, IdSpace, IFieldEditorContainer
treePanel = new ADTreePanel(windowNo, gridTab.getTabNo());
West west = new West();
west.appendChild(treePanel);
west.setWidth("300px");
west.setWidth(widthTreePanel());
west.setCollapsible(true);
west.setSplittable(true);
west.setAutoscroll(true);
@ -1171,6 +1173,17 @@ DataStatusListener, IADTabpanel, IdSpace, IFieldEditorContainer
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);
}
else
width = DEFAULT_PANEL_WIDTH;
return width;
}
private void navigateTo(DefaultTreeNode<MTreeNode> value) {
MTreeNode treeNode = value.getData();
// We Have a TreeNode
@ -1740,7 +1753,24 @@ DataStatusListener, IADTabpanel, IdSpace, IFieldEditorContainer
if (formContainer.getSouth() != null) {
if (formContainer.getSouth().isVisible() && formContainer.getSouth().isOpen()) {
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 adTabId = getGridTab().getAD_Tab_ID();
if (windowId > 0 && adTabId > 0) {
@ -1748,23 +1778,18 @@ DataStatusListener, IADTabpanel, IdSpace, IFieldEditorContainer
int userId = Env.getAD_User_ID(Env.getCtx());
MPreference preference = query.setOnlyActiveRecords(true)
.setApplyAccessFilter(true)
.setParameters(windowId, adTabId+"|DetailPane.Height", userId)
.setParameters(windowId, adTabId+"|"+attribute, userId)
.first();
if (preference == null || preference.getAD_Preference_ID() <= 0) {
preference = new MPreference(Env.getCtx(), 0, null);
preference.setAD_Window_ID(windowId);
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();
//update current context
Env.getCtx().setProperty("P"+windowId+"|"+adTabId+"|DetailPane.Height", height);
Env.getCtx().setProperty("P"+windowId+"|"+adTabId+"|"+attribute, value);
}
}
}
}
super.onPageDetached(page);
}
}