コード例 #1
0
ファイル: Bootloader.java プロジェクト: ikbelkirasan/UECIDE
  public void populateMenu(JMenu menu, int flags) {
    if (flags == (Plugin.MENU_TOOLS | Plugin.MENU_MID)) {
      Sketch sketch = editor.getSketch();
      JMenuItem item = new JMenu("Program Bootloader");
      item.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              run();
            }
          });
      menu.add(item);

      PropertyFile props = sketch.mergeAllProperties();
      String blProgs = props.get("bootloader.upload");
      if (blProgs == null) {
        JMenuItem sub = new JMenuItem("No bootloader programmer defined!");
        item.add(sub);
        return;
      }
      String[] progs = blProgs.split("::");
      for (String prog : progs) {
        JMenuItem sub = new JMenuItem(sketch.parseString(props.get("upload." + prog + ".name")));
        sub.setActionCommand(prog);
        sub.addActionListener(
            new ActionListener() {
              public void actionPerformed(ActionEvent e) {
                doProgram(e.getActionCommand());
              }
            });
        item.add(sub);
      }
    }
  }
コード例 #2
0
ファイル: App.java プロジェクト: branscha/tmplt-swingbasic
  private static void constructMenu() {
    final JFrame lFrame = (JFrame) viewModel.get("window.frame");

    final JMenuBar lMenuBar = new JMenuBar();
    lFrame.setJMenuBar(lMenuBar);
    viewModel.put("menu", lMenuBar);

    final JMenu lFileMenu = new JMenu("File");
    lFileMenu.setMnemonic(KeyEvent.VK_F);
    viewModel.put("menu.file", lFileMenu);
    lMenuBar.add(lFileMenu);

    final JMenuItem lExitItem = new JMenuItem((Action) viewModel.get("action.exit"));
    viewModel.put("menu.file.exit", lExitItem);
    lFileMenu.add(lExitItem);

    final JMenuItem lHelpMenu = new JMenu("Help");
    lHelpMenu.setMnemonic(KeyEvent.VK_H);
    viewModel.put("menu.help", lHelpMenu);
    lMenuBar.add(lHelpMenu);

    final JMenuItem lHelpTopicsItem = new JMenuItem((Action) viewModel.get("action.help"));
    viewModel.put("menu.help.topics", lHelpTopicsItem);
    lHelpMenu.add(lHelpTopicsItem);

    final JMenuItem lAboutItem = new JMenuItem((Action) viewModel.get("action.about"));
    viewModel.put("menu.help.about", lAboutItem);
    lHelpMenu.add(lAboutItem);
  }
コード例 #3
0
  private void helpButtonActionPerformed(java.awt.event.ActionEvent evt) {
    JPopupMenu jp = new JPopupMenu();

    JMenuItem mi = new JMenuItem("Help"); // No i18n
    JPanel panel = new JPanel();

    String msgTxt =
        "<html>Drops redundant events/alerts. <br>The suppressed/dropped Events/alerts will not <br>be added to the database. <br>You can choose to suppress all events/alerts <br>or only those that occur after a <br>certain period of time. <br>Refer Admin Guide for details.</html>"; // No i18n

    /*JTextArea ep = new JTextArea();
    ep.setColumns(20);
    ep.setLineWrap(true);
    ep.setRows(10);
    ep.setBackground(new java.awt.Color(200, 200, 200));
    ep.setWrapStyleWord(true);*/
    JLabel ep = new JLabel();
    ep.setSize(300, 200);
    ep.setText(msgTxt);
    panel.add(ep);

    mi.setLayout(new BorderLayout());
    mi.setPreferredSize(panel.getPreferredSize());
    mi.setFocusPainted(false);
    mi.add(panel, BorderLayout.CENTER);
    jp.setLayout(new BorderLayout());
    jp.add(mi, BorderLayout.CENTER);
    jp.show(helpButton, -60, -60);
  }
コード例 #4
0
ファイル: Latihan94.java プロジェクト: UMBYFTI/Java-Praktikum
  void GUI() {
    setJMenuBar(mainmenu);
    mainmenu.add(menu_file);
    menu_file.add(submenu_open);
    submenu_open.add(content_data);
    menu_file.add(submenu_exit);
    mainmenu.add(menu_about);
    menu_about.add(submenu_about);

    setVisible(true);
  }
コード例 #5
0
    JMenuItem getItem() {
      JMenuItem i;

      if (null == cmd) {
        i = new JMenu(name);
        for (MenuElement e : submenu) {
          i.add(e.getItem());
        }
      } else {
        i = new JMenuItem(cmd.name());
        i.setActionCommand(cmd.name());
        i.addActionListener(menuListener);
      }

      return i;
    }
コード例 #6
0
ファイル: IGVMenuBar.java プロジェクト: kshakir/IGV
  /**
   * Generate the "tools" menu. This is imperative, it is written to field {@code toolsMenu}. Reason
   * being, when we add (TODO remove) a new tool, we need to refresh just this menu
   */
  void refreshToolsMenu() {
    List<JComponent> menuItems = new ArrayList<JComponent>(10);

    // batch script
    MenuAction menuAction = new RunScriptMenuAction("Run Batch Script...", KeyEvent.VK_X, igv);
    menuItems.add(MenuAndToolbarUtils.createMenuItem(menuAction));

    // igvtools
    // menuItems.add(new JSeparator());
    menuAction =
        new SortTracksMenuAction("Run igvtools...", KeyEvent.VK_T, igv) {
          @Override
          public void actionPerformed(ActionEvent e) {
            IgvToolsGui.launch(false, igv.getGenomeManager().getGenomeId());
          }
        };
    menuItems.add(MenuAndToolbarUtils.createMenuItem(menuAction));

    List<JComponent> otherToolMenus = igv.getOtherToolMenus();
    if (otherToolMenus.size() > 0) {
      for (JComponent entry : otherToolMenus) {
        menuItems.add(entry);
      }
    }
    // menuItems.add(new JSeparator());

    // -------------------------------------//
    // "Add tool" option, for loading cli_plugin from someplace else
    JMenuItem addTool = new JMenuItem("Add Tool...");
    addTool.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            File pluginFi = FileDialogUtils.chooseFile("Select cli_plugin .xml spec");
            if (pluginFi == null) return;

            try {
              PluginSpecReader.addCustomPlugin(pluginFi.getAbsolutePath());
              refreshToolsMenu();
            } catch (IOException e1) {
              MessageUtils.showErrorMessage("Error loading custom cli_plugin", e1);
            }
          }
        });
    // menuItems.add(addTool);
    // menuItems.add(new JSeparator());

    // -------------------------------------//

    for (final PluginSpecReader pluginSpecReader : PluginSpecReader.getPlugins()) {
      for (final PluginSpecReader.Tool tool : pluginSpecReader.getTools()) {
        final String toolName = tool.name;
        boolean toolVisible = tool.visible;
        JMenuItem toolMenu;

        if (toolVisible) {

          final String toolPath = pluginSpecReader.getToolPath(tool);
          final String tool_url = tool.toolUrl;
          boolean isValid = PluginSpecReader.isToolPathValid(toolPath);

          ActionListener invalidActionListener =
              new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                  String msg = String.format("%s executable not found at %s", toolName, toolPath);
                  if (tool_url != null) {
                    msg += "<br/>See " + tool_url + " to install";
                  }
                  MessageUtils.showMessage(msg);
                }
              };

          toolMenu = new JMenu(toolName);
          // Kind of overlaps with the side-pull menu, doesn't look great
          // toolMenu.setToolTipText(tool.getAttribute("description"));
          for (final PluginSpecReader.Command command : tool.commandList) {
            final String cmdName = command.name;
            JMenuItem cmdItem = new JMenuItem(cmdName);
            toolMenu.add(cmdItem);
            if (isValid || toolPath == null) {
              cmdItem.addActionListener(
                  new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                      RunPlugin runPlugin = null;
                      try {
                        runPlugin =
                            new RunPlugin(IGV.getMainFrame(), pluginSpecReader, tool, command);
                      } catch (IllegalStateException e1) {
                        MessageUtils.showErrorMessage(e1.getMessage(), e1);
                        return;
                      }
                      runPlugin.setVisible(true);
                    }
                  });
              cmdItem.setEnabled(true);
            } else {
              cmdItem.setEnabled(false);
            }
          }
          // Hack so we can have a tool which is just general command line stuff
          // Don't let the user change the path in that case
          if (tool.defaultPath != null) {
            JMenuItem setPathItem = new JMenuItem(String.format("Set path to %s...", toolName));
            setPathItem.addActionListener(
                new ActionListener() {
                  @Override
                  public void actionPerformed(ActionEvent e) {
                    (new SetPluginPathDialog(IGV.getMainFrame(), pluginSpecReader, tool))
                        .setVisible(true);
                    refreshToolsMenu();
                  }
                });
            toolMenu.add(setPathItem);
          }
          menuItems.add(toolMenu);
        }
      }
    }
    // -------------------------------------//

    // -----------SQL DB Tools--------------//
    boolean showDBEditor = Globals.isDevelopment();
    if (showDBEditor) {
      JMenu sqlDBProfileEditor = new JMenu("SQL DB Profile Editor");
      JMenuItem createNewProfile = new JMenuItem("Create New Profile");
      createNewProfile.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              File file =
                  FileDialogUtils.chooseFile(
                      "Save DB Profile", DirectoryManager.getUserDirectory(), FileDialogUtils.SAVE);
              if (file != null) {
                DBProfileEditor editor =
                    new DBProfileEditor(IGV.getMainFrame(), file.getAbsolutePath());
                editor.setVisible(true);
              }
            }
          });
      JMenuItem editExistingProfile = new JMenuItem("Edit Existing Profile");
      editExistingProfile.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              File file = FileDialogUtils.chooseFile("Select .dbxml database profile");
              if (file != null) {
                if (!file.exists()) {}

                DBProfileEditor editor =
                    new DBProfileEditor(IGV.getMainFrame(), file.getAbsolutePath());
                editor.setVisible(true);
              }
            }
          });
      sqlDBProfileEditor.add(createNewProfile);
      sqlDBProfileEditor.add(editExistingProfile);
      menuItems.add(sqlDBProfileEditor);
    }

    // -------------------------------------//

    // DataTrack Math------------------------//
    if (Globals.isDevelopment()) {
      JMenuItem combineDataItem = new JMenuItem("Combine Data Tracks");
      combineDataItem.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              CombinedDataSourceDialog dialog = new CombinedDataSourceDialog(IGV.getMainFrame());
              dialog.setVisible(true);
            }
          });
      menuItems.add(combineDataItem);
    }

    // -------------------------------------//

    MenuAction toolsMenuAction = new MenuAction("Tools", null);
    if (toolsMenu == null) {
      toolsMenu = MenuAndToolbarUtils.createMenu(menuItems, toolsMenuAction);
      toolsMenu.setName("Tools");
    } else {
      toolsMenu.removeAll();
      for (JComponent item : menuItems) {
        toolsMenu.add(item);
      }
    }
  }