windowMenuFrames = new WeakHashMap<JMenuItem, Frame>();
// Create a menu item for each of the MainFrame instances, that displays the MainFrame's path
// and a keyboard accelerator to recall the frame (for the first 10 frames only).
java.util.List<MainFrame> mainFrames = WindowManager.getMainFrames();
MainFrame mainFrame;
JCheckBoxMenuItem checkBoxMenuItem;
int nbFrames = mainFrames.size();
for(int i=0; i<nbFrames; i++) {
mainFrame = mainFrames.get(i);
checkBoxMenuItem = new JCheckBoxMenuItem();
// If frame number is less than 10, use the corresponding action class (accelerator will be displayed in the menu item)
MuAction recallWindowAction;
if(i<10) {
recallWindowAction = ActionManager.getActionInstance(RECALL_WINDOW_ACTION_IDS[i], this.mainFrame);
}
// Else use the generic RecallWindowAction
else {
Hashtable<String, Object> actionProps = new Hashtable<String, Object>();
// Specify the window number using the dedicated property
actionProps.put(RecallWindowAction.WINDOW_NUMBER_PROPERTY_KEY, ""+(i+1));
recallWindowAction = ActionManager.getActionInstance(new ActionParameters(RecallWindowAction.Descriptor.ACTION_ID, actionProps), this.mainFrame);
}
checkBoxMenuItem.setAction(recallWindowAction);
// Replace the action's label and use the MainFrame's current folder path instead
checkBoxMenuItem.setText((i+1)+" "+mainFrame.getActiveTable().getFolderPanel().getCurrentFolder().getAbsolutePath());
// Use the action's label as a tooltip
checkBoxMenuItem.setToolTipText(recallWindowAction.getLabel());
// Check current MainFrame (the one this menu bar belongs to)