IDEMPIERE-623 Idempiere's UI stop working when any window is refreshed.

This commit is contained in:
Heng Sin Low 2013-02-14 11:56:01 +08:00
parent 5c1765a76f
commit 5dc758ae47
1 changed files with 17 additions and 12 deletions

View File

@ -233,6 +233,11 @@ public class AdempiereWebUI extends Window implements EventListener<Event>, IWeb
String autoNew = userPreference.getProperty(UserPreference.P_AUTO_NEW); String autoNew = userPreference.getProperty(UserPreference.P_AUTO_NEW);
Env.setAutoNew(ctx, "true".equalsIgnoreCase(autoNew) || "y".equalsIgnoreCase(autoNew)); Env.setAutoNew(ctx, "true".equalsIgnoreCase(autoNew) || "y".equalsIgnoreCase(autoNew));
keyListener = new Keylistener();
keyListener.setPage(this.getPage());
keyListener.setCtrlKeys("@a@c@d@e@f@h@n@o@p@r@s@t@z@x@#left@#right@#up@#down@#home@#end#enter");
keyListener.setAutoBlur(false);
IDesktop d = (IDesktop) currSess.getAttribute(APPLICATION_DESKTOP_KEY); IDesktop d = (IDesktop) currSess.getAttribute(APPLICATION_DESKTOP_KEY);
if (d != null && d instanceof IDesktop) if (d != null && d instanceof IDesktop)
{ {
@ -254,14 +259,12 @@ public class AdempiereWebUI extends Window implements EventListener<Event>, IWeb
//detach root component from old page //detach root component from old page
Page page = appDesktop.getComponent().getPage(); Page page = appDesktop.getComponent().getPage();
if (page.getDesktop() != null) { if (page.getDesktop() != null) {
Collection<?> collection = page.getRoots(); Collection<Component> collection = page.getRoots();
Object[] objects = new Object[0]; for(Component comp : collection) {
objects = collection.toArray(objects);
for(Object obj : objects) {
try { try {
if (obj instanceof Component) { comp.detach();
((Component)obj).detach(); if (!(comp instanceof Keylistener) && !(comp instanceof AdempiereWebUI)) {
rootComponents.add((Component) obj); rootComponents.add(comp);
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
@ -306,7 +309,14 @@ public class AdempiereWebUI extends Window implements EventListener<Event>, IWeb
} }
} catch (Throwable t) { } catch (Throwable t) {
//restore fail //restore fail
t.printStackTrace();
appDesktop = null; appDesktop = null;
Collection<Component> roots = this.getPage().getRoots();
for(Component comp : roots) {
if (!(comp instanceof Keylistener) && !(comp instanceof AdempiereWebUI)) {
comp.detach();
}
}
} }
} }
@ -342,11 +352,6 @@ public class AdempiereWebUI extends Window implements EventListener<Event>, IWeb
BrowserToken.remove(); BrowserToken.remove();
} }
keyListener = new Keylistener();
keyListener.setPage(this.getPage());
keyListener.setCtrlKeys("@a@c@d@e@f@h@n@o@p@r@s@t@z@x@#left@#right@#up@#down@#home@#end#enter");
keyListener.setAutoBlur(false);
Clients.response(new AuScript("zAu.cmd0.clearBusy()")); Clients.response(new AuScript("zAu.cmd0.clearBusy()"));
} }