예제 #1
0
  /** Intialize me */
  private void init() {
    myTables = new ArrayList();
    tableTabbedPane = new JTabbedPane();
    tableTabbedPane.setPreferredSize(new Dimension(450, 200));
    JMenuBar menuBar = new JMenuBar();
    JMenu fileMenu = new JMenu("File");
    menuBar.add(fileMenu);
    fileMenu.add(GuiUtils.makeMenuItem("New Row", this, "addNewRow"));
    fileMenu.addSeparator();
    fileMenu.add(GuiUtils.makeMenuItem("Open", this, "doOpen"));
    fileMenu.add(GuiUtils.makeMenuItem("Import", this, "doImport"));
    fileMenu.addSeparator();
    fileMenu.add(GuiUtils.makeMenuItem("Export to File", this, "doSaveAs"));
    fileMenu.add(GuiUtils.makeMenuItem("Export to Plugin", this, "exportToPlugin"));
    fileMenu.add(
        GuiUtils.makeMenuItem("Export Selected to Plugin", this, "exportSelectedToPlugin"));
    fileMenu.addSeparator();
    fileMenu.add(GuiUtils.makeMenuItem("Close", this, "doClose"));

    JMenu helpMenu = new JMenu("Help");
    menuBar.add(helpMenu);
    helpMenu.add(GuiUtils.makeMenuItem("Parameter Defaults Help", this, "showHelp"));
    JComponent bottom = GuiUtils.wrap(GuiUtils.makeButton("Close", this, "doClose"));
    contents = GuiUtils.topCenterBottom(menuBar, GuiUtils.inset(tableTabbedPane, 2), bottom);
    setMenuBar(menuBar);
    loadResources(resources);
  }
예제 #2
0
 /**
  * Make the edit menu
  *
  * @param editMenu edit menu
  * @return edit menu
  */
 public JMenu makeEditMenu(JMenu editMenu) {
   editMenu.add(GuiUtils.makeDynamicMenu("Symbols", this, "initSymbolsMenu"));
   editMenu.add(
       GuiUtils.makeMenuItem("Set properties on selected", this, "setPropertiesOnSelected"));
   editMenu.addSeparator();
   return super.makeEditMenu(editMenu);
 }
예제 #3
0
  /**
   * Make the view menu
   *
   * @param viewMenu view menu
   * @return The view menu
   */
  public JMenu makeViewMenu(JMenu viewMenu) {
    showAlignmentPointsMI = new JCheckBoxMenuItem("Show Alignment Points", true);
    viewMenu.add(showAlignmentPointsMI);
    showAlignmentPointsMI.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            repaint();
          }
        });

    viewMenu.addSeparator();
    super.makeViewMenu(viewMenu);
    viewMenu.addSeparator();
    viewMenu.add(makeMenuItem("Black background", CMD_BLACKBG));
    viewMenu.add(makeMenuItem("White background", CMD_WHITEBG));
    return viewMenu;
  }
예제 #4
0
 /** Make the file menu */
 private void makeFileMenu() {
   fileMenu.removeAll();
   fileMenu.add(makeMenuItem("New", 'n', GuiUtils.CMD_NEW));
   fileMenu.addSeparator();
   fileMenu.add(makeMenuItem("Save", 's', GuiUtils.CMD_SAVE));
   fileMenu.add(makeMenuItem("Save As...", GuiUtils.CMD_SAVEAS));
   fileMenu.add(makeMenuItem("Rename...", GuiUtils.CMD_RENAME));
   fileMenu.addSeparator();
   JMenuItem removeMenuItem = makeMenuItem("Remove", GuiUtils.CMD_REMOVE);
   removeMenuItem.setEnabled(smm.isUsers(stationModel));
   fileMenu.add(removeMenuItem);
   fileMenu.addSeparator();
   fileMenu.add(makeMenuItem("Import...", GuiUtils.CMD_IMPORT));
   fileMenu.add(makeMenuItem("Export...", GuiUtils.CMD_EXPORT));
   fileMenu.addSeparator();
   fileMenu.add(makeMenuItem("Close", GuiUtils.CMD_CLOSE));
 }
예제 #5
0
 private JMenuBar buildMenuBar() {
   // This function builds the menu bar
   JMenuBar menuBar = new JMenuBar();
   JMenu fileMenu = new JMenu("File");
   fileMenu.add(makeMenuItem("New"));
   fileMenu.add(makeMenuItem("Open"));
   fileMenu.addSeparator();
   fileMenu.add(makeMenuItem("Save"));
   fileMenu.add(makeMenuItem("Save As"));
   fileMenu.addSeparator();
   fileMenu.add(makeMenuItem("Exit"));
   menuBar.add(fileMenu);
   // edit menu
   JMenu editMenu = new JMenu("Edit");
   editMenu.add(makeMenuItem(cutAction));
   editMenu.add(makeMenuItem(copyAction));
   editMenu.add(makeMenuItem(pasteAction));
   menuBar.add(editMenu);
   return menuBar;
 }
예제 #6
0
 /**
  * Create a menu for the app. By default this pulls the definition of the menu from the associated
  * resource file.
  */
 protected JMenu createMenu(String key) {
   JMenu menu = new JMenu(getResourceString(key + labelSuffix));
   for (String itemKey : getItemKeys(key)) {
     if (itemKey.equals("-")) {
       menu.addSeparator();
     } else {
       JMenuItem mi = createMenuItem(itemKey);
       menu.add(mi);
     }
   }
   return menu;
 }
예제 #7
0
  /*
   * Implements PopupMenuListener#popupMenuWillBecomeVisible(PopupMenuEvent).
   */
  public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
    createOtrContactMenus(currentContact);

    JMenu menu = getMenu();

    menu.addSeparator();

    whatsThis = new JMenuItem();
    whatsThis.setIcon(OtrActivator.resourceService.getImage("plugin.otr.HELP_ICON_15x15"));
    whatsThis.setText(OtrActivator.resourceService.getI18NString("plugin.otr.menu.WHATS_THIS"));
    whatsThis.addActionListener(this);
    menu.add(whatsThis);
  }
예제 #8
0
 /**
  * Create a menu for the app. By default this pulls the definition of the menu from the associated
  * resource file.
  */
 protected JMenu createMenu(String key) {
   String[] itemKeys = SCSUtility.tokenize(getResourceString(key));
   JMenu menu = new JMenu(getResourceString(key + "Label"));
   for (int i = 0; i < itemKeys.length; i++) {
     if (itemKeys[i].equals("-")) {
       menu.addSeparator();
     } else {
       // System.out.println("Debug:TextViewer:itemkey: "+itemKeys[i]);
       JMenuItem mi = createMenuItem(itemKeys[i]);
       menu.add(mi);
     }
   }
   return menu;
 }
예제 #9
0
 private void createDebugMenu() {
   debugMenu = new JMenu("Debug");
   menuBar.add(debugMenu);
   debugMenu.add(stepAction);
   debugMenu.add(nextAction);
   debugMenu.add(contAction);
   debugMenu.add(stopAction);
   traceAllItem = new JCheckBoxMenuItem("Trace All");
   debugMenu.add(traceAllItem);
   debugMenu.addSeparator();
   breakpointsItem = new JMenuItem("Breakpoints...");
   debugMenu.add(breakpointsItem);
   breakpointsItem.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent event) {
           Breakpoints.edit();
         }
       });
   Breakpoints.setParent(this);
 }
예제 #10
0
    public Popup() {
      super();
      String[] profileNames = profiles.getNames();
      JMenuItem item;

      // Make the load menu
      JMenu loadMenu = new JMenu("Load profile");
      loadMenu.setEnabled(profiles.size() > 0);
      addProfiles(loadMenu, profileNames, profileLoader);
      this.add(loadMenu);
      this.addSeparator();

      // put in a dummy item
      item = new JMenuItem();
      item.setEnabled(false);
      this.add(item);
      this.addSeparator();

      // Make the save menu
      JMenu saveMenu = new JMenu("Save profile");
      item = new JMenuItem("New...");
      item.addActionListener(profileSaver);
      saveMenu.add(item);
      saveMenu.addSeparator();
      addProfiles(saveMenu, profileNames, profileSaver);
      this.add(saveMenu);
      this.addSeparator();

      // put in a dummy item
      item = new JMenuItem();
      item.setEnabled(false);
      this.add(item);
      this.addSeparator();

      // Make the delete menu
      JMenu deleteMenu = new JMenu("Delete profile");
      deleteMenu.setEnabled(profiles.size() > 0);
      addProfiles(deleteMenu, profileNames, profileDeleter);
      this.add(deleteMenu);
    }
  /** Adds the menu items to the menuber. */
  protected void arrangeMenu() {

    // Build the first menu.
    fileMenu = new JMenu("File");
    fileMenu.setMnemonic(KeyEvent.VK_F);
    menuBar.add(fileMenu);

    viewMenu = new JMenu("View");
    viewMenu.setMnemonic(KeyEvent.VK_V);
    menuBar.add(viewMenu);

    runMenu = new JMenu("Run");
    runMenu.setMnemonic(KeyEvent.VK_R);
    menuBar.add(runMenu);

    // Build the second menu.
    helpMenu = new JMenu("Help");
    helpMenu.setMnemonic(KeyEvent.VK_H);
    menuBar.add(helpMenu);

    programMenuItem = new JMenuItem("Load Program", KeyEvent.VK_O);
    programMenuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            programMenuItem_actionPerformed();
          }
        });
    fileMenu.add(programMenuItem);

    scriptMenuItem = new JMenuItem("Load Script", KeyEvent.VK_P);
    scriptMenuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            scriptMenuItem_actionPerformed();
          }
        });
    fileMenu.add(scriptMenuItem);
    fileMenu.addSeparator();

    exitMenuItem = new JMenuItem("Exit", KeyEvent.VK_X);
    exitMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, InputEvent.ALT_MASK));
    exitMenuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            exitMenuItem_actionPerformed();
          }
        });
    fileMenu.add(exitMenuItem);

    viewMenu.addSeparator();

    ButtonGroup animationRadioButtons = new ButtonGroup();

    animationSubMenu = new JMenu("Animate");
    animationSubMenu.setMnemonic(KeyEvent.VK_A);
    viewMenu.add(animationSubMenu);

    partAnimMenuItem = new JRadioButtonMenuItem("Program flow");
    partAnimMenuItem.setMnemonic(KeyEvent.VK_P);
    partAnimMenuItem.setSelected(true);
    partAnimMenuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            partAnimMenuItem_actionPerformed();
          }
        });
    animationRadioButtons.add(partAnimMenuItem);
    animationSubMenu.add(partAnimMenuItem);

    fullAnimMenuItem = new JRadioButtonMenuItem("Program & data flow");
    fullAnimMenuItem.setMnemonic(KeyEvent.VK_D);
    fullAnimMenuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            fullAnimMenuItem_actionPerformed();
          }
        });
    animationRadioButtons.add(fullAnimMenuItem);
    animationSubMenu.add(fullAnimMenuItem);

    noAnimMenuItem = new JRadioButtonMenuItem("No Animation");
    noAnimMenuItem.setMnemonic(KeyEvent.VK_N);
    noAnimMenuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            noAnimMenuItem_actionPerformed();
          }
        });
    animationRadioButtons.add(noAnimMenuItem);
    animationSubMenu.add(noAnimMenuItem);

    ButtonGroup additionalDisplayRadioButtons = new ButtonGroup();

    additionalDisplaySubMenu = new JMenu("View");
    additionalDisplaySubMenu.setMnemonic(KeyEvent.VK_V);
    viewMenu.add(additionalDisplaySubMenu);

    scriptDisplayMenuItem = new JRadioButtonMenuItem("Script");
    scriptDisplayMenuItem.setMnemonic(KeyEvent.VK_S);
    scriptDisplayMenuItem.setSelected(true);
    scriptDisplayMenuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            scriptDisplayMenuItem_actionPerformed();
          }
        });
    additionalDisplayRadioButtons.add(scriptDisplayMenuItem);
    additionalDisplaySubMenu.add(scriptDisplayMenuItem);

    outputMenuItem = new JRadioButtonMenuItem("Output");
    outputMenuItem.setMnemonic(KeyEvent.VK_O);
    outputMenuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            outputMenuItem_actionPerformed();
          }
        });
    additionalDisplayRadioButtons.add(outputMenuItem);
    additionalDisplaySubMenu.add(outputMenuItem);

    compareMenuItem = new JRadioButtonMenuItem("Compare");
    compareMenuItem.setMnemonic(KeyEvent.VK_C);
    compareMenuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            compareMenuItem_actionPerformed();
          }
        });
    additionalDisplayRadioButtons.add(compareMenuItem);
    additionalDisplaySubMenu.add(compareMenuItem);

    noAdditionalDisplayMenuItem = new JRadioButtonMenuItem("Screen");
    noAdditionalDisplayMenuItem.setMnemonic(KeyEvent.VK_N);
    noAdditionalDisplayMenuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            noAdditionalDisplayMenuItem_actionPerformed();
          }
        });
    additionalDisplayRadioButtons.add(noAdditionalDisplayMenuItem);
    additionalDisplaySubMenu.add(noAdditionalDisplayMenuItem);

    ButtonGroup formatRadioButtons = new ButtonGroup();

    numericFormatSubMenu = new JMenu("Format");
    numericFormatSubMenu.setMnemonic(KeyEvent.VK_F);
    viewMenu.add(numericFormatSubMenu);

    decMenuItem = new JRadioButtonMenuItem("Decimal");
    decMenuItem.setMnemonic(KeyEvent.VK_D);
    decMenuItem.setSelected(true);
    decMenuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            decMenuItem_actionPerformed();
          }
        });
    formatRadioButtons.add(decMenuItem);
    numericFormatSubMenu.add(decMenuItem);

    hexaMenuItem = new JRadioButtonMenuItem("Hexadecimal");
    hexaMenuItem.setMnemonic(KeyEvent.VK_H);
    hexaMenuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            hexaMenuItem_actionPerformed();
          }
        });
    formatRadioButtons.add(hexaMenuItem);
    numericFormatSubMenu.add(hexaMenuItem);

    binMenuItem = new JRadioButtonMenuItem("Binary");
    binMenuItem.setMnemonic(KeyEvent.VK_B);
    binMenuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            binMenuItem_actionPerformed();
          }
        });
    formatRadioButtons.add(binMenuItem);
    numericFormatSubMenu.add(binMenuItem);

    viewMenu.addSeparator();

    singleStepMenuItem = new JMenuItem("Single Step", KeyEvent.VK_S);
    singleStepMenuItem.setAccelerator(KeyStroke.getKeyStroke("F11"));
    singleStepMenuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            singleStepMenuItem_actionPerformed();
          }
        });
    runMenu.add(singleStepMenuItem);

    ffwdMenuItem = new JMenuItem("Run", KeyEvent.VK_F);
    ffwdMenuItem.setAccelerator(KeyStroke.getKeyStroke("F5"));
    ffwdMenuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            ffwdMenuItem_actionPerformed();
          }
        });
    runMenu.add(ffwdMenuItem);

    stopMenuItem = new JMenuItem("Stop", KeyEvent.VK_T);
    stopMenuItem.setAccelerator(KeyStroke.getKeyStroke("shift F5"));
    stopMenuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            stopMenuItem_actionPerformed();
          }
        });
    runMenu.add(stopMenuItem);

    rewindMenuItem = new JMenuItem("Reset", KeyEvent.VK_R);
    rewindMenuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            rewindMenuItem_actionPerformed();
          }
        });
    runMenu.add(rewindMenuItem);

    runMenu.addSeparator();

    breakpointsMenuItem = new JMenuItem("Breakpoints", KeyEvent.VK_B);
    breakpointsMenuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            breakpointsMenuItem_actionPerformed();
          }
        });
    runMenu.add(breakpointsMenuItem);

    profilerMenuItem = new JMenuItem("Profiler", KeyEvent.VK_I);
    profilerMenuItem.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            showProfiler();
          }
        });
    profilerMenuItem.setEnabled(false);
    runMenu.add(profilerMenuItem);

    usageMenuItem = new JMenuItem("Usage", KeyEvent.VK_U);
    usageMenuItem.setAccelerator(KeyStroke.getKeyStroke("F1"));
    usageMenuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            usageMenuItem_actionPerformed();
          }
        });
    helpMenu.add(usageMenuItem);

    aboutMenuItem = new JMenuItem("About ...", KeyEvent.VK_A);
    aboutMenuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            aboutMenuItem_actionPerformed();
          }
        });
    helpMenu.add(aboutMenuItem);
  }
예제 #12
0
  /**
   * Show the saved results on the server.
   *
   * @param mysettings jemboss settings
   * @param frameName title name for frame
   */
  public ShowSavedResults(final JembossParams mysettings, final JFrame f) {

    this("Saved results list" + (Jemboss.withSoap ? " on server" : ""));

    try {
      final ResultList reslist = new ResultList(mysettings);
      JMenu resFileMenu = new JMenu("File");
      resMenu.add(resFileMenu);

      final JCheckBoxMenuItem listByProgram = new JCheckBoxMenuItem("List by program");
      listByProgram.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              listByProgramName();
            }
          });
      resFileMenu.add(listByProgram);

      JCheckBoxMenuItem listByDate = new JCheckBoxMenuItem("List by date", true);
      listByDate.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              listByDateRun(reslist, false);
            }
          });
      resFileMenu.add(listByDate);

      ButtonGroup group = new ButtonGroup();
      group.add(listByProgram);
      group.add(listByDate);

      JButton refresh = new JButton(rfii);
      refresh.setMargin(new Insets(0, 1, 0, 1));
      refresh.setToolTipText("Refresh");
      resMenu.add(refresh);

      refresh.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              try {
                setCursor(cbusy);
                ResultList newlist = new ResultList(mysettings);
                setCursor(cdone);
                if (newlist.getStatus().equals("0")) {
                  reslist.updateRes(newlist.hash());
                  datasets.removeAllElements();

                  StringTokenizer tok = new StringTokenizer((String) reslist.get("list"), "\n");
                  while (tok.hasMoreTokens()) datasets.addElement(convertToPretty(tok.nextToken()));

                  if (listByProgram.isSelected()) listByProgramName();
                  else listByDateRun(reslist, false);
                } else {
                  JOptionPane.showMessageDialog(
                      null, newlist.getStatusMsg(), "Soap Error", JOptionPane.ERROR_MESSAGE);
                }
              } catch (JembossSoapException eae) {
                AuthPopup ap = new AuthPopup(mysettings, f);
                ap.setBottomPanel();
                ap.setSize(380, 170);
                ap.pack();
                ap.setVisible(true);
              }
            }
          });

      resFileMenu.addSeparator();
      JMenuItem resFileMenuExit = new JMenuItem("Close");
      resFileMenuExit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E, ActionEvent.CTRL_MASK));

      resFileMenuExit.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              dispose();
            }
          });
      resFileMenu.add(resFileMenuExit);
      setJMenuBar(resMenu);

      // this is the list of saved results
      listByDateRun(reslist, true);

      final JList st = new JList(datasets);
      st.setCellRenderer(new TabListCellRenderer());

      st.addListSelectionListener(
          new ListSelectionListener() {
            public void valueChanged(ListSelectionEvent e) {
              if (e.getValueIsAdjusting()) return;

              JList theList = (JList) e.getSource();
              if (theList.isSelectionEmpty()) {
                System.out.println("Empty selection");
              } else {
                int index = theList.getSelectedIndex();
                String thisdata = convertToOriginal(datasets.elementAt(index));
                aboutRes.setText((String) reslist.get(thisdata));
                aboutRes.setCaretPosition(0);
              }
            }
          });

      st.addMouseListener(
          new MouseAdapter() {
            public void mouseClicked(MouseEvent e) {
              if (e.getClickCount() == 2) {
                try {
                  setCursor(cbusy);
                  String project = convertToOriginal(st.getSelectedValue());
                  ResultList thisres = new ResultList(mysettings, project, "show_saved_results");
                  new ShowResultSet(thisres.hash(), project, mysettings);
                  setCursor(cdone);
                } catch (JembossSoapException eae) {
                  AuthPopup ap = new AuthPopup(mysettings, f);
                  ap.setBottomPanel();
                  ap.setSize(380, 170);
                  ap.pack();
                  ap.setVisible(true);
                }
              }
            }
          });
      sp.add(st);

      // display retrieves all files and shows them in a window
      JPanel resButtonPanel = new JPanel();
      JButton showResButton = new JButton("Display");
      showResButton.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              String sel = convertToOriginal(st.getSelectedValue());
              if (sel != null) {
                try {
                  setCursor(cbusy);
                  ResultList thisres = new ResultList(mysettings, sel, "show_saved_results");
                  if (thisres.hash().size() == 0)
                    JOptionPane.showMessageDialog(
                        sp,
                        "This application launch '" + sel + "' didn't produce any result files.");
                  else new ShowResultSet(thisres.hash(), sel, mysettings);
                  setCursor(cdone);
                } catch (JembossSoapException eae) {
                  AuthPopup ap = new AuthPopup(mysettings, f);
                  ap.setBottomPanel();
                  ap.setSize(380, 170);
                  ap.pack();
                  ap.setVisible(true);
                }
              } else {
                statusField.setText("Nothing selected to be displayed.");
              }
            }
          });

      // add a users note for that project
      JButton addNoteButton = new JButton("Edit Notes");
      addNoteButton.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              String sel = convertToOriginal(st.getSelectedValue());
              if (sel != null) {
                try {
                  setCursor(cbusy);
                  ResultList thisres =
                      new ResultList(mysettings, sel, "Notes", "show_saved_results");
                  new ShowResultSet(thisres.hash(), sel, mysettings);
                  setCursor(cdone);
                } catch (JembossSoapException eae) {
                  AuthPopup ap = new AuthPopup(mysettings, f);
                  ap.setBottomPanel();
                  ap.setSize(380, 170);
                  ap.pack();
                  ap.setVisible(true);
                }
              } else {
                statusField.setText("Selected a project!");
              }
            }
          });

      // delete removes the file on the server & edits the list
      JButton delResButton = new JButton("Delete");
      delResButton.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              Object sel[] = st.getSelectedValues();
              if (sel != null) {
                String selList = new String("");
                JTextPane delList = new JTextPane();
                FontMetrics fm = delList.getFontMetrics(delList.getFont());
                int maxWidth = 0;
                for (int i = 0; i < sel.length; i++) {
                  if (i == sel.length - 1) selList = selList.concat((String) sel[i]);
                  else selList = selList.concat(sel[i] + "\n");

                  int width = fm.stringWidth((String) sel[i]);
                  if (width > maxWidth) maxWidth = width;
                }
                int ok = JOptionPane.OK_OPTION;
                if (sel.length > 1) {
                  JScrollPane scrollDel = new JScrollPane(delList);
                  delList.setText(selList);
                  delList.setEditable(false);
                  delList.setCaretPosition(0);

                  Dimension d1 = delList.getPreferredSize();
                  int maxHeight = (int) d1.getHeight() + 5;
                  if (maxHeight > 350) maxHeight = 350;
                  else if (maxHeight < 50) maxHeight = 50;

                  scrollDel.setPreferredSize(new Dimension(maxWidth + 30, maxHeight));

                  ok =
                      JOptionPane.showConfirmDialog(
                          null, scrollDel, "Confirm Deletion", JOptionPane.YES_NO_OPTION);
                }
                if (ok == JOptionPane.OK_OPTION) {
                  try // ask the server to delete these results
                  {
                    setCursor(cbusy);
                    selList = convertToOriginal(selList);
                    new ResultList(mysettings, selList, "delete_saved_results");
                    setCursor(cdone);

                    // amend the list
                    for (int i = 0; i < sel.length; i++) datasets.removeElement(sel[i]);

                    statusField.setText("Deleted " + sel.length + "  result(s)");

                    aboutRes.setText("");
                    st.setSelectedIndex(-1);
                  } catch (JembossSoapException eae) {
                    AuthPopup ap = new AuthPopup(mysettings, f);
                    ap.setBottomPanel();
                    ap.setSize(380, 170);
                    ap.pack();
                    ap.setVisible(true);
                  }
                }
              } else {
                statusField.setText("Nothing selected for deletion.");
              }
            }
          });
      resButtonPanel.add(delResButton);
      resButtonPanel.add(addNoteButton);
      resButtonPanel.add(showResButton);
      resButtonStatus.add(resButtonPanel, BorderLayout.CENTER);
      resButtonStatus.add(statusField, BorderLayout.SOUTH);

      Container c = getContentPane();
      c.add(ss, BorderLayout.WEST);
      c.add(aboutScroll, BorderLayout.CENTER);
      c.add(resButtonStatus, BorderLayout.SOUTH);
      pack();

      setVisible(true);
    } catch (JembossSoapException eae) {
      AuthPopup ap = new AuthPopup(mysettings, f);
      ap.setBottomPanel();
      ap.setSize(380, 170);
      ap.pack();
      ap.setVisible(true);
    }
  }
예제 #13
0
  public ImageLabFrame() {

    // Set up menus
    JMenuBar menuBar = new JMenuBar();

    JMenu imageLabMenu = new JMenu("imageLab");
    menuBar.add(imageLabMenu);

    aboutItem = new JMenuItem("About imageLab");
    imageLabMenu.add(aboutItem);
    quitItem = new JMenuItem("Quit");
    imageLabMenu.add(quitItem);

    JMenu fileMenu = new JMenu("File");
    menuBar.add(fileMenu);
    openItem = new JMenuItem("Open File...");
    fileMenu.add(openItem);
    saveItem = new JMenuItem("Save As...");
    fileMenu.add(saveItem);

    JMenu imageMenu = new JMenu("Images");
    menuBar.add(imageMenu);
    addPictureGenerator(imageMenu, new Stripe());

    JMenu filterMenu = new JMenu("Filters");
    menuBar.add(filterMenu);
    addFilter(filterMenu, new BWFilter());
    filterMenu.addSeparator();
    addScalableFilter(filterMenu, new SwirlFilter());

    // Listeners for filters are added in addScalableFilter
    aboutItem.addActionListener(this);
    quitItem.addActionListener(this);
    openItem.addActionListener(this);
    saveItem.addActionListener(this);

    // Set up rest of GUI

    lab = initialImage().getJLabel();

    slider = new JSlider(0, 100);
    sliderPanel = new JPanel();
    sliderPanel.add(slider);
    sliderPanel.setVisible(false);
    Border b1 = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
    border = BorderFactory.createTitledBorder(b1, "");
    sliderPanel.setBorder(border);
    slider.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            double scale = (slider.getValue() - 50) / 50.0;
            currentFilter.apply(pic1, pic2, scale);
            lab.setIcon(pic2.getJLabel().getIcon());
            repaint();
          }
        });

    JPanel panel = new JPanel(new BorderLayout());
    getContentPane().add(panel);
    panel.add(lab, BorderLayout.NORTH);
    panel.add(sliderPanel, BorderLayout.SOUTH);
    setJMenuBar(menuBar);
    pack();
    setTitle("imageLab");
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // Prepare file chooser
    chooser = new JFileChooser(new File("."));
    FileNameExtensionFilter filter = new FileNameExtensionFilter("JPG Images", "jpg");
    chooser.setFileFilter(filter);
  }
예제 #14
0
  /**
   * Create the main File menu.
   *
   * @param al the action listener to associate to the menu.
   * @return the menu.
   */
  public JMenu defineFileMenu(ActionListener al) {
    JMenu fileMenu = new JMenu(Globals.messages.getString("File"));
    JMenuItem fileNew = new JMenuItem(Globals.messages.getString("New"));
    fileNew.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, Globals.shortcutKey));
    JMenuItem fileOpen = new JMenuItem(Globals.messages.getString("Open"));
    fileOpen.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, Globals.shortcutKey));
    JMenuItem fileSave = new JMenuItem(Globals.messages.getString("Save"));
    fileSave.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, Globals.shortcutKey));
    JMenuItem fileSaveName = new JMenuItem(Globals.messages.getString("SaveName"));
    fileSaveName.setAccelerator(
        KeyStroke.getKeyStroke(KeyEvent.VK_S, Globals.shortcutKey | InputEvent.SHIFT_MASK));

    JMenuItem fileSaveNameSplit = new JMenuItem(Globals.messages.getString("Save_split"));

    JMenuItem fileExport = new JMenuItem(Globals.messages.getString("Export"));

    fileExport.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E, Globals.shortcutKey));

    JMenuItem filePrint = new JMenuItem(Globals.messages.getString("Print"));

    filePrint.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, Globals.shortcutKey));

    JMenuItem fileClose = new JMenuItem(Globals.messages.getString("Close"));

    fileClose.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_W, Globals.shortcutKey));

    JMenuItem options = new JMenuItem(Globals.messages.getString("Circ_opt"));

    // Add the items in the file menu.

    fileMenu.add(fileNew);
    fileMenu.add(fileOpen);
    fileMenu.add(fileSave);
    fileMenu.add(fileSaveName);
    fileMenu.addSeparator();
    fileMenu.add(fileSaveNameSplit);
    fileMenu.addSeparator();

    fileMenu.add(fileExport);
    fileMenu.add(filePrint);
    fileMenu.addSeparator();

    // On a MacOSX system, options is associated to preferences menu
    // in the application menu. We do not need to show it in File.
    // This needs the AppleSpecific extensions to be active.

    if (!Globals.weAreOnAMac) {
      fileMenu.add(options);
      fileMenu.addSeparator();
    }
    fileMenu.add(fileClose);

    // Define all the action listeners

    fileNew.addActionListener(al);
    fileOpen.addActionListener(al);
    fileExport.addActionListener(al);
    filePrint.addActionListener(al);
    fileClose.addActionListener(al);

    fileSave.addActionListener(al);
    fileSaveName.addActionListener(al);
    fileSaveNameSplit.addActionListener(al);

    options.addActionListener(al);

    return fileMenu;
  }
예제 #15
0
  private void createAnalysisMenu() {
    analysisMenu = new JMenu("Analysis");
    menuBar.add(analysisMenu);

    // analysis-related variables
    analysisInfo = new AnalysisInfo();
    wkldStatsDlg = new WkldStatsDlg(this);
    splitStatsDlg = new SplitStatsDlg(this);
    penaltyStatsDlg = new PenaltyStatsDlg(this);

    newAnalysisItem = new JMenuItem("Create Analysis ...");
    analysisMenu.add(newAnalysisItem);
    newAnalysisItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            JOptionPane.showMessageDialog(
                MainWindow.this,
                "Not implemented yet.\nUse command createanl in gistcmdline instead.");
          }
        });

    openAnalysisItem = new JMenuItem("Open Analysis ...");
    final JFileChooser openAnalysisChooser = new JFileChooser(".");
    openAnalysisChooser.setDialogTitle("Open Analysis");
    openAnalysisChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    analysisMenu.add(openAnalysisItem);
    openAnalysisItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            int retval = openAnalysisChooser.showOpenDialog(MainWindow.this);
            if (retval != 0) {
              return;
            }
            File f = openAnalysisChooser.getSelectedFile();

            cmd.reset();
            cmd.cmdType = LibgistCommand.OPENANL;
            cmd.analysisFile = f;
            opThread.dispatchCmd(cmd);
          }
        });

    completeAnalysisItem = new JMenuItem("Complete Analysis ...");
    analysisMenu.add(completeAnalysisItem);
    completeAnalysisItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            JOptionPane.showMessageDialog(
                MainWindow.this,
                "Not implemented yet.\nUse commands wkldstats, splitstats and penaltystats\nin gistcmdline instead.");
          }
        });

    analysisMenu.addSeparator();

    wkldStatsItem = new JMenuItem("Workload Stats ...");
    analysisMenu.add(wkldStatsItem);
    wkldStatsItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            wkldStatsDlg.setVisible(true);
          }
        });

    splitStatsItem = new JMenuItem("Split Stats ...");
    analysisMenu.add(splitStatsItem);
    wkldStatsItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            splitStatsDlg.setVisible(true);
          }
        });

    penaltyStatsItem = new JMenuItem("Penalty Stats ...");
    analysisMenu.add(penaltyStatsItem);
    penaltyStatsItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            penaltyStatsDlg.setVisible(true);
          }
        });
  }
예제 #16
0
    public static void makeMenuBar(JFrame frame, final AirspaceBuilderController controller) {
      JMenuBar menuBar = new JMenuBar();
      final JCheckBoxMenuItem resizeNewShapesItem;
      final JCheckBoxMenuItem enableEditItem;

      JMenu menu = new JMenu("File");
      {
        JMenuItem item = new JMenuItem("Open...");
        item.setAccelerator(
            KeyStroke.getKeyStroke(
                KeyEvent.VK_O, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
        item.setActionCommand(OPEN);
        item.addActionListener(controller);
        menu.add(item);

        item = new JMenuItem("Open URL...");
        item.setActionCommand(OPEN_URL);
        item.addActionListener(controller);
        menu.add(item);

        item = new JMenuItem("Save...");
        item.setAccelerator(
            KeyStroke.getKeyStroke(
                KeyEvent.VK_S, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
        item.setActionCommand(SAVE);
        item.addActionListener(controller);
        menu.add(item);

        menu.addSeparator();

        item = new JMenuItem("Load Demo Shapes");
        item.setActionCommand(OPEN_DEMO_AIRSPACES);
        item.addActionListener(controller);
        menu.add(item);
      }
      menuBar.add(menu);

      menu = new JMenu("Shape");
      {
        JMenu subMenu = new JMenu("New");
        for (final AirspaceFactory factory : defaultAirspaceFactories) {
          JMenuItem item = new JMenuItem(factory.toString());
          item.addActionListener(
              new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                  controller.createNewEntry(factory);
                }
              });
          subMenu.add(item);
        }
        menu.add(subMenu);

        resizeNewShapesItem = new JCheckBoxMenuItem("Fit new shapes to viewport");
        resizeNewShapesItem.setActionCommand(SIZE_NEW_SHAPES_TO_VIEWPORT);
        resizeNewShapesItem.addActionListener(controller);
        resizeNewShapesItem.setState(controller.isResizeNewShapesToViewport());
        menu.add(resizeNewShapesItem);

        enableEditItem = new JCheckBoxMenuItem("Enable shape editing");
        enableEditItem.setActionCommand(ENABLE_EDIT);
        enableEditItem.addActionListener(controller);
        enableEditItem.setState(controller.isEnableEdit());
        menu.add(enableEditItem);
      }
      menuBar.add(menu);

      menu = new JMenu("Selection");
      {
        JMenuItem item = new JMenuItem("Deselect");
        item.setAccelerator(
            KeyStroke.getKeyStroke(
                KeyEvent.VK_D, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
        item.setActionCommand(CLEAR_SELECTION);
        item.addActionListener(controller);
        menu.add(item);

        item = new JMenuItem("Delete");
        item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0));
        item.setActionCommand(REMOVE_SELECTED);
        item.addActionListener(controller);
        menu.add(item);
      }
      menuBar.add(menu);

      frame.setJMenuBar(menuBar);

      controller.addPropertyChangeListener(
          new PropertyChangeListener() {
            public void propertyChange(PropertyChangeEvent e) {
              if (SIZE_NEW_SHAPES_TO_VIEWPORT.equals((e.getPropertyName()))) {
                resizeNewShapesItem.setSelected(controller.isResizeNewShapesToViewport());
              } else if (ENABLE_EDIT.equals(e.getPropertyName())) {
                enableEditItem.setSelected(controller.isEnableEdit());
              }
            }
          });
    }
예제 #17
0
  private void createFileMenu() {
    fileMenu = new JMenu("File");
    menuBar.add(fileMenu);

    newItem = new JMenuItem("New...");
    fileMenu.add(newItem);
    // construct components of option pane to input name and type of new AM
    final Object[] newMsg = new Object[3];
    newMsg[0] = "Name for new AM:";
    final JTextField newName = new JTextField("new-am");
    newMsg[1] = newName;
    final JComboBox cb = new JComboBox();
    for (int i = 0; i < Libgist.extInfo.length; i++) {
      cb.addItem(Libgist.extInfo[i].name);
    }
    newMsg[2] = cb;
    newItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // first close the currently opened index
            int response =
                JOptionPane.showOptionDialog(
                    MainWindow.this,
                    newMsg,
                    "New",
                    JOptionPane.OK_CANCEL_OPTION,
                    JOptionPane.PLAIN_MESSAGE,
                    null,
                    null,
                    null);
            if (response != JOptionPane.OK_OPTION) {
              return;
            }

            // create new AM
            cmd.reset();
            cmd.cmdType = LibgistCommand.CREATE;
            cmd.indexName.append(newName.getText());
            cmd.extension.append(Libgist.extInfo[cb.getSelectedIndex()]);
            opThread.dispatchCmd(cmd);
          }
        });

    openItem = new JMenuItem("Open...");
    final JFileChooser openChooser = new JFileChooser(".");
    openChooser.setDialogTitle("Open Index");
    openChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    fileMenu.add(openItem);
    openItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            // first close currently opened index
            // let user choose index file
            int retval = openChooser.showOpenDialog(MainWindow.this);
            if (retval != 0) {
              return;
            }
            String fileName = openChooser.getSelectedFile().getPath();

            // open AM
            cmd.reset();
            cmd.cmdType = LibgistCommand.OPEN;
            cmd.indexName.append(fileName);
            opThread.dispatchCmd(cmd);

            enableIndexOpened();
          }
        });

    closeItem = new JMenuItem("Close");
    fileMenu.add(closeItem);
    closeItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            // close AM
            cmd.reset();
            cmd.cmdType = LibgistCommand.CLOSE;
            opThread.dispatchCmd(cmd);
            // MainWindow.this.setTitle("amdb");
          }
        });

    flushItem = new JMenuItem("Flush");
    fileMenu.add(flushItem);
    flushItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            // open AM
            cmd.reset();
            cmd.cmdType = LibgistCommand.FLUSH;
            opThread.dispatchCmd(cmd);
          }
        });

    fileMenu.addSeparator();

    optionsItem = new JMenuItem("Properties...");
    fileMenu.add(optionsItem);
    optionsItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            Properties.edit();
          }
        });

    settingsItem = new JMenuItem("Save Settings");
    fileMenu.add(settingsItem);
    settingsItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            saveConfig();
          }
        });
    fileMenu.addSeparator();
    exitItem = new JMenuItem("Exit");
    fileMenu.add(exitItem);
    exitItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // close AM
            opThread.stopNow();
            Libgist.cleanup();
            System.exit(0);
          }
        });
  }
예제 #18
0
  /**
   * Define the Edit main menu.
   *
   * @param al the action listener to associate to the menu.
   * @return the menu.
   */
  public JMenu defineEditMenu(ActionListener al) {
    JMenu editMenu = new JMenu(Globals.messages.getString("Edit_menu"));

    JMenuItem editUndo = new JMenuItem(Globals.messages.getString("Undo"));
    editUndo.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Z, Globals.shortcutKey));
    // editUndo.setEnabled(false);
    JMenuItem editRedo = new JMenuItem(Globals.messages.getString("Redo"));
    editRedo.setAccelerator(
        KeyStroke.getKeyStroke(KeyEvent.VK_Z, Globals.shortcutKey | InputEvent.SHIFT_MASK));
    // editRedo.setEnabled(false);
    JMenuItem editCut = new JMenuItem(Globals.messages.getString("Cut"));
    editCut.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, Globals.shortcutKey));

    JMenuItem editCopy = new JMenuItem(Globals.messages.getString("Copy"));
    editCopy.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, Globals.shortcutKey));

    JMenuItem editCopySplit = new JMenuItem(Globals.messages.getString("Copy_split"));
    editCopySplit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_M, Globals.shortcutKey));

    JMenuItem editPaste = new JMenuItem(Globals.messages.getString("Paste"));
    editPaste.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, Globals.shortcutKey));
    JMenuItem clipboardCircuit = new JMenuItem(Globals.messages.getString("DefineClipboard"));

    JMenuItem editSelectAll = new JMenuItem(Globals.messages.getString("SelectAll"));
    editSelectAll.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, Globals.shortcutKey));

    JMenuItem editDuplicate = new JMenuItem(Globals.messages.getString("Duplicate"));
    editDuplicate.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_D, Globals.shortcutKey));

    JMenuItem editRotate = new JMenuItem(Globals.messages.getString("Rotate"));
    editRotate.setAccelerator(KeyStroke.getKeyStroke("R"));

    JMenuItem editMirror = new JMenuItem(Globals.messages.getString("Mirror_E"));
    editMirror.setAccelerator(KeyStroke.getKeyStroke("S"));

    editUndo.addActionListener(al);
    editRedo.addActionListener(al);
    editCut.addActionListener(al);
    editCopy.addActionListener(al);
    editCopySplit.addActionListener(al);
    editPaste.addActionListener(al);
    editSelectAll.addActionListener(al);
    editDuplicate.addActionListener(al);
    editMirror.addActionListener(al);
    editRotate.addActionListener(al);
    clipboardCircuit.addActionListener(al);

    editMenu.add(editUndo);
    editMenu.add(editRedo);
    editMenu.addSeparator();

    editMenu.add(editCut);
    editMenu.add(editCopy);
    editMenu.add(editCopySplit);
    editMenu.add(editPaste);
    editMenu.add(clipboardCircuit);
    editMenu.add(editDuplicate);

    editMenu.addSeparator();

    editMenu.add(editSelectAll);
    editMenu.addSeparator();
    editMenu.add(editRotate);
    editMenu.add(editMirror);

    return editMenu;
  }