IDEMPIERE-4915 Improvements to Preference Popup (#835)

* IDEMPIERE-4915 Improvements to Preference Popup

* IDEMPIERE-4915 Improvements to Preference Popup

- Move MY_PROFILE_MENU_ID to SystemIDs
This commit is contained in:
hengsin 2021-08-18 13:15:07 +08:00 committed by GitHub
parent c20e76bc13
commit 8cc3a2a33f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 73 additions and 18 deletions

View File

@ -68,6 +68,8 @@ public class SystemIDs
public final static int MESSAGE_WORKFLOWRESULT = 753; public final static int MESSAGE_WORKFLOWRESULT = 753;
public final static int MESSAGE_NOTES = 52244; public final static int MESSAGE_NOTES = 52244;
public static final int MY_PROFILE_MENU_ID = 53246;
public final static int PRINTFORMAT_STATEMENTOFACCOUNT = 134; public final static int PRINTFORMAT_STATEMENTOFACCOUNT = 134;
public final static int PRINTFORMAT_ORDER_HEADER_TEMPLATE = 100; public final static int PRINTFORMAT_ORDER_HEADER_TEMPLATE = 100;
public final static int PRINTFORMAT_ORDER_LINETAX_TEMPLATE = 101; public final static int PRINTFORMAT_ORDER_LINETAX_TEMPLATE = 101;

View File

@ -18,17 +18,22 @@ import java.util.logging.Level;
import org.adempiere.webui.ClientInfo; import org.adempiere.webui.ClientInfo;
import org.adempiere.webui.LayoutUtils; import org.adempiere.webui.LayoutUtils;
import org.adempiere.webui.apps.AEnv; import org.adempiere.webui.apps.AEnv;
import org.adempiere.webui.component.Label;
import org.adempiere.webui.component.ToolBar; import org.adempiere.webui.component.ToolBar;
import org.adempiere.webui.component.ToolBarButton; import org.adempiere.webui.component.ToolBarButton;
import org.adempiere.webui.component.Window; import org.adempiere.webui.component.Window;
import org.adempiere.webui.editor.WEditor;
import org.adempiere.webui.editor.WYesNoEditor; import org.adempiere.webui.editor.WYesNoEditor;
import org.adempiere.webui.event.ValueChangeEvent; import org.adempiere.webui.event.ValueChangeEvent;
import org.adempiere.webui.event.ValueChangeListener; import org.adempiere.webui.event.ValueChangeListener;
import org.adempiere.webui.grid.WQuickEntry; import org.adempiere.webui.grid.WQuickEntry;
import org.adempiere.webui.theme.ThemeManager; import org.adempiere.webui.theme.ThemeManager;
import org.adempiere.webui.util.ZKUpdateUtil; import org.adempiere.webui.util.ZKUpdateUtil;
import org.compiere.model.I_AD_UserPreference;
import org.compiere.model.MMenu;
import org.compiere.model.MRole; import org.compiere.model.MRole;
import org.compiere.model.MUserPreference; import org.compiere.model.MUserPreference;
import org.compiere.model.SystemIDs;
import org.compiere.util.CLogger; import org.compiere.util.CLogger;
import org.compiere.util.Env; import org.compiere.util.Env;
import org.compiere.util.Msg; import org.compiere.util.Msg;
@ -38,6 +43,7 @@ import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events; import org.zkoss.zk.ui.event.Events;
import org.zkoss.zul.A; import org.zkoss.zul.A;
import org.zkoss.zul.Div; import org.zkoss.zul.Div;
import org.zkoss.zul.Space;
/** /**
* *
* @author hengsin * @author hengsin
@ -47,14 +53,17 @@ public class WPreference extends WQuickEntry implements EventListener<Event>, Va
/** /**
* *
*/ */
private static final long serialVersionUID = -8223456746437563389L; private static final long serialVersionUID = 3259434079666571595L;
private static final CLogger log = CLogger.getCLogger(WPreference.class); private static final CLogger log = CLogger.getCLogger(WPreference.class);
private static final String LINE_DIV_STYLE = "background-color: transparent !important; border: none; margin: 5px;";
private WYesNoEditor adempiereSys; private WYesNoEditor adempiereSys;
private WYesNoEditor logMigrationScript; private WYesNoEditor logMigrationScript;
private WGadgets gadgets; private WGadgets gadgets;
private A addgadgets; private A addgadgets;
private A morePreferences; private A morePreferences;
private A myProfile;
private MUserPreference preferences = null; private MUserPreference preferences = null;
private int recordId = 0; private int recordId = 0;
@ -75,6 +84,7 @@ public class WPreference extends WQuickEntry implements EventListener<Event>, Va
if (canAccessPreference != null && canAccessPreference) { if (canAccessPreference != null && canAccessPreference) {
initPOs(); initPOs();
loadPreferences(); loadPreferences();
moveMigrationScriptComment();
} }
this.setTitle(""); this.setTitle("");
@ -100,19 +110,37 @@ public class WPreference extends WQuickEntry implements EventListener<Event>, Va
private void init() { private void init() {
Div div = new Div(); Div div = new Div();
div.setStyle("background-color: transparent !important; border: none; margin: 5px;"); div.setStyle(LINE_DIV_STYLE);
morePreferences= new A(); morePreferences= new A();
morePreferences.setLabel(Msg.translate(Env.getCtx(), "MorePreferences")); morePreferences.setLabel(Msg.translate(Env.getCtx(), "MorePreferences"));
morePreferences.addEventListener(Events.ON_CLICK, this); morePreferences.addEventListener(Events.ON_CLICK, this);
div.appendChild(morePreferences); div.appendChild(morePreferences);
this.appendChild(div); this.appendChild(div);
MMenu myProfileMenu = MMenu.get(SystemIDs.MY_PROFILE_MENU_ID);
div = new Div();
div.setStyle(LINE_DIV_STYLE);
myProfile= new A();
myProfile.setLabel(myProfileMenu.get_Translation("Name"));
myProfile.addEventListener(Events.ON_CLICK, this);
div.appendChild(myProfile);
this.appendChild(div);
div = new Div();
div.setStyle(LINE_DIV_STYLE);
addgadgets= new A();
addgadgets.setLabel( Msg.translate(Env.getCtx(), "ManageGadgets"));
addgadgets.addEventListener(Events.ON_CLICK, this);
div.appendChild(addgadgets);
this.appendChild(div);
if (Env.getAD_Client_ID(Env.getCtx()) <= 20 && Env.getAD_User_ID(Env.getCtx()) <= 102) { if (Env.getAD_Client_ID(Env.getCtx()) <= 20 && Env.getAD_User_ID(Env.getCtx()) <= 102) {
this.appendChild(new Space());
adempiereSys = new WYesNoEditor("AdempiereSys", Msg.getMsg(Env.getCtx(), "AdempiereSys", true), adempiereSys = new WYesNoEditor("AdempiereSys", Msg.getMsg(Env.getCtx(), "AdempiereSys", true),
null, false, false, true); null, false, false, true);
adempiereSys.getComponent().setTooltiptext(Msg.getMsg(Env.getCtx(), "AdempiereSys", false)); adempiereSys.getComponent().setTooltiptext(Msg.getMsg(Env.getCtx(), "AdempiereSys", false));
div = new Div(); div = new Div();
div.setStyle("background-color: transparent !important; border: none; margin: 5px;"); div.setStyle(LINE_DIV_STYLE);
div.appendChild(adempiereSys.getComponent()); div.appendChild(adempiereSys.getComponent());
this.appendChild(div); this.appendChild(div);
adempiereSys.setValue(Env.getCtx().getProperty("AdempiereSys")); adempiereSys.setValue(Env.getCtx().getProperty("AdempiereSys"));
@ -122,7 +150,7 @@ public class WPreference extends WQuickEntry implements EventListener<Event>, Va
null, false, false, true); null, false, false, true);
logMigrationScript.getComponent().setTooltiptext(Msg.getMsg(Env.getCtx(), "LogMigrationScript", false)); logMigrationScript.getComponent().setTooltiptext(Msg.getMsg(Env.getCtx(), "LogMigrationScript", false));
div = new Div(); div = new Div();
div.setStyle("background-color: transparent !important; border: none; margin: 5px;"); div.setStyle(LINE_DIV_STYLE);
div.appendChild(logMigrationScript.getComponent()); div.appendChild(logMigrationScript.getComponent());
this.appendChild(div); this.appendChild(div);
logMigrationScript.setValue(Env.getCtx().getProperty("LogMigrationScript")); logMigrationScript.setValue(Env.getCtx().getProperty("LogMigrationScript"));
@ -145,16 +173,38 @@ public class WPreference extends WQuickEntry implements EventListener<Event>, Va
if (ThemeManager.isUseFontIconForImage()) if (ThemeManager.isUseFontIconForImage())
LayoutUtils.addSclass("large-toolbarbutton", btn); LayoutUtils.addSclass("large-toolbarbutton", btn);
div = new Div();
div.setStyle("background-color: transparent !important; border: none; margin: 5px;");
addgadgets= new A();
addgadgets.setLabel( Msg.translate(Env.getCtx(), "ManageGadgets"));
addgadgets.addEventListener(Events.ON_CLICK, this);
div.appendChild(addgadgets);
this.appendChild(div);
} //init } //init
private void moveMigrationScriptComment() {
WEditor commentEditor = null;
for (WEditor editor : quickEditors) {
if (I_AD_UserPreference.COLUMNNAME_MigrationScriptComment.equals(editor.getColumnName())) {
commentEditor = editor;
break;
}
}
if (commentEditor != null) {
Component field = commentEditor.getComponent();
Component parent = field.getParent();
if (parent != null) {
parent.detach();
Div div = new Div();
div.setStyle(LINE_DIV_STYLE);
Label label = commentEditor.getLabel();
LayoutUtils.removeSclass("field-label", label);
if (!label.getValue().endsWith(":"))
label.setValue(label.getValue()+":");
div.appendChild(label);
this.insertBefore(div, logMigrationScript.getComponent().getParent().getNextSibling());
Component ref = div.getNextSibling();
div = new Div();
div.setStyle(LINE_DIV_STYLE);
div.appendChild(field);
this.insertBefore(div, ref);
}
}
}
public void onEvent(Event event) throws Exception { public void onEvent(Event event) throws Exception {
String nameEvent=event.getName(); String nameEvent=event.getName();
Component com =event.getTarget(); Component com =event.getTarget();
@ -182,10 +232,13 @@ public class WPreference extends WQuickEntry implements EventListener<Event>, Va
gadgets.setAttribute(Window.MODE_KEY, Mode.HIGHLIGHTED); gadgets.setAttribute(Window.MODE_KEY, Mode.HIGHLIGHTED);
AEnv.showWindow(gadgets); AEnv.showWindow(gadgets);
gadgets.focus(); gadgets.focus();
} } else if (com == morePreferences) {
if (com == morePreferences) {
AEnv.zoom(MUserPreference.Table_ID, recordId); AEnv.zoom(MUserPreference.Table_ID, recordId);
this.detach();
} else if (com == myProfile) {
MMenu myProfileMenu = MMenu.get(SystemIDs.MY_PROFILE_MENU_ID);
AEnv.zoom(myProfileMenu.getAD_Window_ID(), null);
this.detach();
} }
} }
} //onEvent } //onEvent