示例#1
0
文件: Apps.java 项目: dpharris/JMRI
  /**
   * Create default File menu
   *
   * @param menuBar Menu bar to be populated
   * @param wi WindowInterface where this menu will appear as part of the menu bar
   */
  protected void fileMenu(JMenuBar menuBar, WindowInterface wi) {
    JMenu fileMenu = new JMenu(Bundle.getMessage("MenuFile"));
    menuBar.add(fileMenu);

    fileMenu.add(
        new PrintDecoderListAction(
            Bundle.getMessage("MenuPrintDecoderDefinitions"), wi.getFrame(), false));
    fileMenu.add(
        new PrintDecoderListAction(
            Bundle.getMessage("MenuPrintPreviewDecoderDefinitions"), wi.getFrame(), true));

    // Use Mac OS X native Quit if using Aqua look and feel
    if (!(SystemType.isMacOSX() && UIManager.getLookAndFeel().isNativeLookAndFeel())) {
      fileMenu.add(new JSeparator());
      fileMenu.add(
          new AbstractAction(Bundle.getMessage("MenuItemQuit")) {
            /** */
            private static final long serialVersionUID = -3051429826192051394L;

            @Override
            public void actionPerformed(ActionEvent e) {
              handleQuit();
            }
          });
    }
  }
示例#2
0
文件: Apps.java 项目: dpharris/JMRI
  /**
   * Create default menubar.
   *
   * <p>This does not include the development menu.
   *
   * @param menuBar Menu bar to be populated
   * @param wi WindowInterface where this menu bar will appear
   */
  protected void createMenus(JMenuBar menuBar, WindowInterface wi) {
    // the debugging statements in the following are
    // for testing startup time
    log.debug("start building menus");

    if (SystemType.isMacOSX()) {
      Application.getApplication()
          .setQuitHandler(
              new QuitHandler() {
                @Override
                public boolean handleQuitRequest(EventObject eo) {
                  return handleQuit();
                }
              });
    }

    fileMenu(menuBar, wi);
    editMenu(menuBar, wi);
    toolsMenu(menuBar, wi);
    rosterMenu(menuBar, wi);
    panelMenu(menuBar, wi);
    // check to see if operations in main menu
    if (jmri.jmrit.operations.setup.Setup.isMainMenuEnabled()) {
      operationsMenu(menuBar, wi);
    }
    systemsMenu(menuBar, wi);
    scriptMenu(menuBar, wi);
    debugMenu(menuBar, wi);
    menuBar.add(new WindowMenu(wi)); // * GT 28-AUG-2008 Added window menu
    helpMenu(menuBar, wi);
    log.debug("end building menus");
  }
示例#3
0
 @Override
 protected String[] getPortFriendlyNames() {
   if (SystemType.isWindows()) {
     return new String[] {"Silicon Labs CP210x USB to UART Bridge", "Silicon Labs CP210x"};
   }
   return new String[] {};
 }
示例#4
0
文件: Apps.java 项目: dpharris/JMRI
  protected void editMenu(JMenuBar menuBar, WindowInterface wi) {

    JMenu editMenu = new JMenu(Bundle.getMessage("MenuEdit"));
    menuBar.add(editMenu);

    // cut, copy, paste
    AbstractAction a;
    a = new DefaultEditorKit.CutAction();
    a.putValue(Action.NAME, Bundle.getMessage("MenuItemCut"));
    editMenu.add(a);
    a = new DefaultEditorKit.CopyAction();
    a.putValue(Action.NAME, Bundle.getMessage("MenuItemCopy"));
    editMenu.add(a);
    a = new DefaultEditorKit.PasteAction();
    a.putValue(Action.NAME, Bundle.getMessage("MenuItemPaste"));
    editMenu.add(a);

    // prefs
    prefsAction = new apps.gui3.TabbedPreferencesAction(Bundle.getMessage("MenuItemPreferences"));
    // Put prefs in Apple's prefered area on Mac OS X
    if (SystemType.isMacOSX()) {
      Application.getApplication()
          .setPreferencesHandler(
              new PreferencesHandler() {
                @Override
                public void handlePreferences(EventObject eo) {
                  doPreferences();
                }
              });
    }
    // Include prefs in Edit menu if not on Mac OS X or not using Aqua Look and Feel
    if (!SystemType.isMacOSX() || !UIManager.getLookAndFeel().isNativeLookAndFeel()) {
      editMenu.addSeparator();
      editMenu.add(prefsAction);
    }
  }
示例#5
0
  /**
   * Create and initialize the application object.
   *
   * <p>Expects initialization from preInit() to already be done.
   */
  public Apps3(String applicationName, String configFileDef, String[] args) {
    // pre-GUI work
    super(applicationName, configFileDef, args);

    // Prepare font lists
    prepareFontLists();

    addToActionModel();
    // create GUI
    initializeHelpSystem();
    if (SystemType.isMacOSX()) {
      initMacOSXMenus();
    }
    if (((!configOK) || (!configDeferredLoadOK)) && (!preferenceFileExists)) {
      FirstTimeStartUpWizardAction prefsAction =
          new FirstTimeStartUpWizardAction("Start Up Wizard");
      prefsAction.setApp(this);
      prefsAction.actionPerformed(null);
      return;
    }
    createAndDisplayFrame();
  }
示例#6
0
 static @Nonnull JMenu jMenuFromElement(
     @CheckForNull Element main, WindowInterface wi, Object context) {
   boolean addSep = false;
   String name = "<none>";
   if (main == null) {
     log.warn("Menu from element called without an element");
     return new JMenu(name);
   }
   name = LocaleSelector.getAttribute(main, "name");
   // Next statement left in if the xml file hasn't been converted
   if ((name == null) || (name.equals(""))) {
     if (main.getChild("name") != null) {
       name = main.getChild("name").getText();
     }
   }
   JMenu menu = new JMenu(name);
   ArrayList<Integer> mnemonicList = new ArrayList<Integer>();
   for (Object item : main.getChildren("node")) {
     JMenuItem menuItem = null;
     Element child = (Element) item;
     if (child.getChildren("node").size() == 0) { // leaf
       if ((child.getText().trim()).equals("separator")) {
         addSep = true;
       } else {
         if (!(SystemType.isMacOSX()
             && UIManager.getLookAndFeel().isNativeLookAndFeel()
             && ((child.getChild("adapter") != null
                     && child
                         .getChild("adapter")
                         .getText()
                         .equals("apps.gui3.TabbedPreferencesAction"))
                 || (child.getChild("current") != null
                     && child.getChild("current").getText().equals("quit"))))) {
           if (addSep) {
             menu.addSeparator();
             addSep = false;
           }
           Action act = actionFromNode(child, wi, context);
           menu.add(menuItem = new JMenuItem(act));
         }
       }
     } else {
       if (addSep) {
         menu.addSeparator();
         addSep = false;
       }
       if (child.getChild("group") != null && child.getChild("group").getText().equals("yes")) {
         // A seperate method is required for creating radio button groups
         menu.add(createMenuGroupFromElement(child, wi, context));
       } else {
         menu.add(menuItem = jMenuFromElement(child, wi, context)); // not leaf
       }
     }
     if (menuItem != null && child.getChild("current") != null) {
       setMenuItemInterAction(context, child.getChild("current").getText(), menuItem);
     }
     if (menuItem != null && child.getChild("mnemonic") != null) {
       int mnemonic = convertStringToKeyEvent(child.getChild("mnemonic").getText());
       if (mnemonicList.contains(mnemonic)) {
         log.error(
             "Menu Item '"
                 + menuItem.getText()
                 + "' Mnemonic '"
                 + child.getChild("mnemonic").getText()
                 + "' has already been assigned");
       } else {
         menuItem.setMnemonic(mnemonic);
         mnemonicList.add(mnemonic);
       }
     }
   }
   return menu;
 }