From 520f9d7dc78343289bf02813fe73d625c4b515e2 Mon Sep 17 00:00:00 2001 From: servertude Date: Sat, 8 Mar 2008 11:07:10 +0000 Subject: [PATCH] file missed in rev 1247 - implement window menu --- extra/jheidi/addToWindowMenu.ajl | 66 ++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 extra/jheidi/addToWindowMenu.ajl diff --git a/extra/jheidi/addToWindowMenu.ajl b/extra/jheidi/addToWindowMenu.ajl new file mode 100644 index 00000000..0aad95df --- /dev/null +++ b/extra/jheidi/addToWindowMenu.ajl @@ -0,0 +1,66 @@ +import java.util.*; + +WindowContext context = argObj("windowContext"); +HashObject profile = context.get("profile"); +String profileName = profile.get("name"); +Frame thisFrame = context.get("/"); + +// dont confuse Context (global context) with the variable context (the window context) +HashObject windowList = Context.get("windowList"); +HashObject windowCounts = Context.get("windowCounts"); +if ( windowList == null ) +{ + windowList = new HashObject(); + windowCounts = new HashObject(); + Context.putEnv("windowList", windowList); + Context.putEnv("windowCounts", windowCounts); +} + +List windowMenus = new ArrayList(); +String windowCount = windowCounts.get(profileName); +int count = windowCount == null ? 0 : Integer.valueOf(windowCount); + +String windowId = profileName + " (" + Integer.toString(++count) + ")"; +thisFrame.setProperty("windowId", windowId); +windowList.put(windowId, thisFrame); +windowCounts.put(profileName, Integer.toString(count)); + +Collections.sort(windowList, new Comparator() { + public int compare(Object o1, Object o2) { + return ((String)((Frame)o1).getProperty("windowId")) + .compareToIgnoreCase(((String)((Frame)o2).getProperty("windowId"))); + }}); + +//now rebuild all the window menus on all open frames +for (Object o : windowList) +{ + Frame f = (Frame)o; + Menu windowMenu = f.get("Window"); + windowMenu.removeAll(); + + for (Object o2 : windowList) + { + windowMenu.item(((String)((Frame)o2).getProperty("windowId"))); + } +} + + + + + + + + + + + + + + + + + + + + +