diff --git a/migration/i1.0c-release/oracle/20130717091459_IDEMPIERE-984.sql b/migration/i1.0c-release/oracle/20130717091459_IDEMPIERE-984.sql index 1c2b601aeb..b0003e00ae 100644 --- a/migration/i1.0c-release/oracle/20130717091459_IDEMPIERE-984.sql +++ b/migration/i1.0c-release/oracle/20130717091459_IDEMPIERE-984.sql @@ -7,4 +7,6 @@ INSERT INTO AD_Message (MsgType,MsgText,MsgTip,AD_Message_ID,EntityType,AD_Messa -- IDEMPIERE-984 Change Role and Logout must check for unsaved records on open windows INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgText,MsgTip, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Message_Trl_UU ) SELECT l.AD_Language,t.AD_Message_ID, t.MsgText,t.MsgTip, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Message t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Message_ID=200207 AND NOT EXISTS (SELECT * FROM AD_Message_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Message_ID=t.AD_Message_ID) ; + SELECT register_migration_script('20130717091459_IDEMPIERE-984.sql') FROM dual +; diff --git a/migration/i1.0c-release/postgresql/20130717091459_IDEMPIERE-984.sql b/migration/i1.0c-release/postgresql/20130717091459_IDEMPIERE-984.sql index 7c56888df9..820178942d 100644 --- a/migration/i1.0c-release/postgresql/20130717091459_IDEMPIERE-984.sql +++ b/migration/i1.0c-release/postgresql/20130717091459_IDEMPIERE-984.sql @@ -9,3 +9,4 @@ INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgText,MsgTip, IsTransla ; SELECT register_migration_script('20130717091459_IDEMPIERE-984.sql') FROM dual +; diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/UserPanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/UserPanel.java index d910b0f261..ca2265442f 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/UserPanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/UserPanel.java @@ -17,7 +17,6 @@ package org.adempiere.webui.panel; - import java.util.Properties; import org.adempiere.util.Callback; @@ -66,7 +65,10 @@ public class UserPanel implements EventListener, Composer protected Component component; - public UserPanel() + private static final String ON_DEFER_CHANGE_ROLE = "onDeferChangeRole"; + private static final String ON_DEFER_LOGOUT = "onDeferLogout"; + + public UserPanel() { super(); this.ctx = Env.getCtx(); @@ -106,6 +108,9 @@ public class UserPanel implements EventListener, Composer SessionManager.getSessionApplication().getKeylistener().addEventListener(Events.ON_CTRL_KEY, this); component.addEventListener("onEmailSupport", this); + + component.addEventListener(ON_DEFER_LOGOUT, this); + component.addEventListener(ON_DEFER_CHANGE_ROLE, this); } private String getUserName() @@ -139,19 +144,13 @@ public class UserPanel implements EventListener, Composer return "*"; } } + public void onEvent(Event event) throws Exception { if (event == null) return; if (logout == event.getTarget()) { - component.addEventListener("onLogout", new EventListener() { - @Override - public void onEvent(Event event) throws Exception { - SessionManager.logoutSession(); - } - }); - if (SessionManager.getAppDesktop().isPendingWindow()) { FDialog.ask(0, component, "ProceedWithTask?", new Callback() { @@ -160,12 +159,12 @@ public class UserPanel implements EventListener, Composer { if (result) { - Events.echoEvent(new Event("onLogout", component)); + Events.echoEvent(ON_DEFER_LOGOUT, component, null); } } }); } else { - SessionManager.logoutSession(); + Events.echoEvent(ON_DEFER_LOGOUT, component, null); } } else if (lblUserNameValue == event.getTarget()) @@ -176,13 +175,6 @@ public class UserPanel implements EventListener, Composer } else if (changeRole == event.getTarget()) { - component.addEventListener("onChangeRole", new EventListener() { - @Override - public void onEvent(Event event) throws Exception { - MUser user = MUser.get(ctx); - SessionManager.changeRole(user); - } - }); if (SessionManager.getAppDesktop().isPendingWindow()) { FDialog.ask(0, component, "ProceedWithTask?", new Callback() { @@ -191,13 +183,12 @@ public class UserPanel implements EventListener, Composer { if (result) { - Events.echoEvent(new Event("onChangeRole", component)); + Events.echoEvent(ON_DEFER_CHANGE_ROLE, component, null); } } }); } else { - MUser user = MUser.get(ctx); - SessionManager.changeRole(user); + Events.echoEvent(ON_DEFER_CHANGE_ROLE, component, null); } } else if (preference == event.getTarget()) @@ -246,6 +237,16 @@ public class UserPanel implements EventListener, Composer } } } + else if (ON_DEFER_LOGOUT.equals(event.getName())) + { + SessionManager.logoutSession(); + } + else if (ON_DEFER_CHANGE_ROLE.equals(event.getName())) + { + MUser user = MUser.get(ctx); + SessionManager.changeRole(user); + } + } @Override