public JMenuBar getPanelMenuBar() {
   if (panelMenuBar == null) {
     JMenuItem menuItem;
     ICFLibAnyObj container = getSwingContainer();
     panelMenuBar = new JMenuBar();
     menuAdd = new JMenu("Add");
     actionAddSecGroupMember = new ActionAddSecGroupMember();
     if (container instanceof ICFSecuritySecGroupObj) {
       menuItem = new JMenuItem(actionAddSecGroupMember);
       menuAdd.add(menuItem);
     }
     if (getSwingContainer() != null) {
       panelMenuBar.add(menuAdd);
     }
     menuSelected = new JMenu("Selected");
     menuSelected.setEnabled(false);
     actionViewSelected = new ViewSelectedActionSecGroupMember();
     menuItem = new JMenuItem(actionViewSelected);
     menuSelected.add(menuItem);
     actionEditSelected = new EditSelectedActionSecGroupMember();
     menuItem = new JMenuItem(actionEditSelected);
     menuSelected.add(menuItem);
     actionDeleteSelected = new DeleteSelectedActionSecGroupMember();
     menuItem = new JMenuItem(actionDeleteSelected);
     menuSelected.add(menuItem);
     panelMenuBar.add(menuSelected);
   }
   return (panelMenuBar);
 }
  /*
   * This is the constructor for our ChoiceFrame
   */
  public ChoiceFrameExtras(String name) {
    // The keyword super simply sends name to the constructor of
    //  JFrame.
    super(name);

    // Construct the text
    sampleField = new JLabel(new String("Big Java"));

    // Add the text to the main panel
    getContentPane().add(sampleField, BorderLayout.CENTER);

    // Call the method below to add all the components and menu
    //  to the frame
    createControlPane();

    // Create and set the menu bar
    JMenuBar menuBar = new JMenuBar();
    setJMenuBar(menuBar);

    // Call the methods to add two menus (file and font) to the menu bar
    menuBar.add(createFileMenu());
    menuBar.add(createFontMenu());

    createColorDialog();

    // Call the method to re-draw the label
    setSampleFont();
  }
示例#3
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);
  }
 public JMenuBar getPanelMenuBar() {
   if (panelMenuBar == null) {
     JMenuItem menuItem;
     ICFLibAnyObj container = getSwingContainer();
     panelMenuBar = new JMenuBar();
     menuAdd = new JMenu("Add");
     actionAddMajorVersion = new ActionAddMajorVersion();
     if (container instanceof ICFInternetRealProjectObj) {
       menuItem = new JMenuItem(actionAddMajorVersion);
       menuAdd.add(menuItem);
     }
     actionAddMinorVersion = new ActionAddMinorVersion();
     if (container instanceof ICFInternetMajorVersionObj) {
       menuItem = new JMenuItem(actionAddMinorVersion);
       menuAdd.add(menuItem);
     }
     if (getSwingContainer() != null) {
       panelMenuBar.add(menuAdd);
     }
     menuSelected = new JMenu("Selected");
     menuSelected.setEnabled(false);
     actionViewSelected = new ViewSelectedActionVersion();
     menuItem = new JMenuItem(actionViewSelected);
     menuSelected.add(menuItem);
     actionEditSelected = new EditSelectedActionVersion();
     menuItem = new JMenuItem(actionEditSelected);
     menuSelected.add(menuItem);
     actionDeleteSelected = new DeleteSelectedActionVersion();
     menuItem = new JMenuItem(actionDeleteSelected);
     menuSelected.add(menuItem);
     panelMenuBar.add(menuSelected);
   }
   return (panelMenuBar);
 }
 public JMenuBar getPanelMenuBar() {
   if (panelMenuBar == null) {
     JMenuItem menuItem;
     ICFLibAnyObj container = getSwingContainer();
     panelMenuBar = new JMenuBar();
     menuAdd = new JMenu("Add");
     actionAddTextCol = new ActionAddTextCol();
     if (container instanceof ICFDbTestTableObj) {
       menuItem = new JMenuItem(actionAddTextCol);
       menuAdd.add(menuItem);
     }
     actionAddTextType = new ActionAddTextType();
     if (container instanceof ICFDbTestSchemaDefObj) {
       menuItem = new JMenuItem(actionAddTextType);
       menuAdd.add(menuItem);
     }
     if (getSwingContainer() != null) {
       panelMenuBar.add(menuAdd);
     }
     menuSelected = new JMenu("Selected");
     menuSelected.setEnabled(false);
     actionViewSelected = new ViewSelectedActionTextDef();
     menuItem = new JMenuItem(actionViewSelected);
     menuSelected.add(menuItem);
     actionEditSelected = new EditSelectedActionTextDef();
     menuItem = new JMenuItem(actionEditSelected);
     menuSelected.add(menuItem);
     actionDeleteSelected = new DeleteSelectedActionTextDef();
     menuItem = new JMenuItem(actionDeleteSelected);
     menuSelected.add(menuItem);
     panelMenuBar.add(menuSelected);
   }
   return (panelMenuBar);
 }
示例#6
0
 /**
  * Create the menubar for the app. By default this pulls the definition of the menu from the
  * associated resource file.
  */
 protected JMenuBar createMenubar() {
   JMenuBar mb = new JMenuBar();
   for (String menuKey : getMenuBarKeys()) {
     JMenu m = createMenu(menuKey);
     if (m != null) {
       mb.add(m);
     }
   }
   return mb;
 }
 public CFInternetSwingVersionListJPanel(
     ICFInternetSwingSchema argSchema,
     ICFLibAnyObj argContainer,
     ICFInternetVersionObj argFocus,
     Collection<ICFInternetVersionObj> argDataCollection,
     ICFJRefreshCallback refreshCallback,
     boolean sortByChain) {
   super();
   final String S_ProcName = "construct-schema-focus";
   if (argSchema == null) {
     throw CFLib.getDefaultExceptionFactory()
         .newNullArgumentException(getClass(), S_ProcName, 1, "argSchema");
   }
   // argFocus is optional; focus may be set later during execution as
   // conditions of the runtime change.
   swingSchema = argSchema;
   swingFocus = argFocus;
   swingContainer = argContainer;
   swingRefreshCallback = refreshCallback;
   swingSortByChain = sortByChain;
   setSwingDataCollection(argDataCollection);
   dataTable = new JTable(getDataModel(), getDataColumnModel(), getDataListSelectionModel());
   dataTable.addMouseListener(getDataListMouseAdapter());
   dataTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
   dataTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
   dataTable.setUpdateSelectionOnSort(true);
   dataTable.setRowHeight(25);
   getDataListSelectionModel().addListSelectionListener(getDataListSelectionListener());
   dataScrollPane =
       new JScrollPane(
           dataTable,
           ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
           ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
   dataScrollPane.setColumnHeader(
       new JViewport() {
         @Override
         public Dimension getPreferredSize() {
           Dimension sz = super.getPreferredSize();
           sz.height = 25;
           return (sz);
         }
       });
   dataTable.setFillsViewportHeight(true);
   // Do initial layout
   setSize(1024, 480);
   JMenuBar menuBar = getPanelMenuBar();
   add(menuBar);
   menuBar.setBounds(0, 0, 1024, 25);
   add(dataScrollPane);
   dataScrollPane.setBounds(0, 25, 1024, 455);
   adjustListMenuBar();
   doLayout();
   swingIsInitializing = false;
 }
示例#8
0
  /**
   * Create the menubar for the app. By default this pulls the definition of the menu from the
   * associated resource file.
   */
  protected JMenuBar createMenubar() {
    JMenuItem mi;
    JMenuBar mb = new JMenuBar();

    String[] menuKeys = SCSUtility.tokenize(getResourceString("menubar"));
    // System.out.println("TextViewer:menuKeys.length "+menuKeys.length);
    for (int i = 0; i < menuKeys.length; i++) {
      JMenu m = createMenu(menuKeys[i]);
      if (m != null) {
        mb.add(m);
      }
    }
    return mb;
  }
  /**
   * @param str name of Menu
   * @param bFlag set mnemonics on menu items
   */
  private JMenuBar createMenuBar(String str, boolean bFlag) {
    menubar = new JMenuBar();

    menu1 = new JMenu(str);
    menu1.setMnemonic(str.charAt(0));
    menu1.addActionListener(this);

    menubar.add(menu1);
    for (int i = 0; i < 8; i++) {
      JMenuItem menuitem = new JMenuItem("1 JMenuItem" + i);
      menuitem.addActionListener(this);
      if (bFlag) {
        menuitem.setMnemonic('0' + i);
      }
      menu1.add(menuitem);
    }

    // second menu
    menu2 = new JMenu("2 - Second Menu");
    menu2.addActionListener(this);
    menu2.setMnemonic('2');

    menubar.add(menu2);
    for (int i = 0; i < 5; i++) {
      JMenuItem menuitem = new JMenuItem("2 JMenuItem" + i);
      menuitem.addActionListener(this);

      if (bFlag) {
        menuitem.setMnemonic('0' + i);
      }
      menu2.add(menuitem);
    }
    JMenu submenu = new JMenu("Sub Menu");
    submenu.setMnemonic('S');
    submenu.addActionListener(this);
    for (int i = 0; i < 5; i++) {
      JMenuItem menuitem = new JMenuItem("S JMenuItem" + i);
      menuitem.addActionListener(this);
      if (bFlag) {
        menuitem.setMnemonic('0' + i);
      }
      submenu.add(menuitem);
    }
    menu2.add(new JSeparator());
    menu2.add(submenu);

    return menubar;
  }
示例#10
0
 private void createTreeStatsMenu() {
   treeStatsMenu = new JMenu("Tree Stats");
   menuBar.add(treeStatsMenu);
   utilItem = new JMenuItem("Utilization");
   treeStatsMenu.add(utilItem);
   utilItem.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           Libgist.getWkldNodeStats(Libgist.NODEUTIL, 0, false);
           treeView.showStats(Libgist.nodeCnt, Libgist.displayStats, utilItem.getText());
         }
       });
   slotCntItem = new JMenuItem("Slot Count");
   treeStatsMenu.add(slotCntItem);
   slotCntItem.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           Libgist.getWkldNodeStats(Libgist.SLOTCNT, 0, false);
           treeView.showStats(Libgist.nodeCnt, Libgist.displayStats, slotCntItem.getText());
         }
       });
   predSzItem = new JMenuItem("Predicate Size");
   treeStatsMenu.add(predSzItem);
   predSzItem.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           Libgist.getWkldNodeStats(Libgist.PREDSIZE, 0, false);
           treeView.showStats(Libgist.nodeCnt, Libgist.displayStats, predSzItem.getText());
         }
       });
 }
示例#11
0
  /**
   * Create all the menus and associate to them all the needed listeners.
   *
   * @param al the action listener to associate to the menu elements.
   * @return the menu bar.
   */
  public JMenuBar defineMenuBar(ActionListener al) {
    // Menu creation
    JMenuBar menuBar = new JMenuBar();

    menuBar.add(defineFileMenu(al));
    menuBar.add(defineEditMenu(al));
    menuBar.add(defineViewMenu(al));
    menuBar.add(defineCircuitMenu(al));

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

    JMenu about = defineAboutMenu(al);
    if (!Globals.weAreOnAMac) menuBar.add(about);

    return menuBar;
  }
示例#12
0
  /**
   * Add the menus into the menu bar
   *
   * @param menuBar The menu bar
   */
  public void initMenuBar(JMenuBar menuBar) {
    stationModelMenu = new JMenu("Layout Models");
    stationModelMenu.addMenuListener(
        new MenuListener() {
          public void menuCanceled(MenuEvent e) {}

          public void menuDeselected(MenuEvent e) {}

          public void menuSelected(MenuEvent e) {
            makeStationModelMenu();
          }
        });

    fileMenu = new JMenu("File");
    fileMenu.addMenuListener(
        new MenuListener() {
          public void menuCanceled(MenuEvent e) {}

          public void menuDeselected(MenuEvent e) {}

          public void menuSelected(MenuEvent e) {
            makeFileMenu();
          }
        });

    menuBar.add(fileMenu);
    super.initMenuBar(menuBar);

    menuBar.add(stationModelMenu);

    JMenu helpMenu = new JMenu("Help");
    JMenuItem helpMenuItem = new JMenuItem("Layout Models");
    helpMenu.add(helpMenuItem);
    helpMenuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            showHelp();
          }
        });

    menuBar.add(helpMenu);
  }
示例#13
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;
 }
示例#14
0
  /*
   * Creates the JMenuBar for the GUI.
   */
  private JMenuBar menuBar() {
    menuBar = new JMenuBar();
    menu = new JMenu("Menu");
    load = new JMenuItem("Load...");
    saveAs = new JMenuItem("Save As...");
    load.addActionListener(new ActionListenerLoad());
    saveAs.addActionListener(new ActionListenerSave());

    // responseArea.addActionListener(new ActionListenerArea());
    menu.add(load);
    menu.add(saveAs);
    menuBar.add(menu);
    return menuBar;
  }
示例#15
0
  private void createJMenuBar() {
    menubar = new JMenuBar();
    JMenu menu = null;
    JMenuItem item = null;

    menubar.add(menu = new JMenu("Edit"));
    menu.add(item = new JMenuItem("Edit Object..."));

    item.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            browser.editSelected();
          }
        });
  }
示例#16
0
  private void buildMenu() {
    jMenuBar = new javax.swing.JMenuBar();
    mainMenu = new javax.swing.JMenu();
    mainMenu.setText("Main");

    loginMenuItem = new JMenuItem("Login...");
    loginMenuItem.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            headerPanel.handleLoginLogout();
          }
        });

    mainMenu.add(loginMenuItem);

    exitMenuItem = new JMenuItem("Exit");
    exitMenuItem.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            if (qsadminMain.isConnected() == true) {
              headerPanel.handleLoginLogout();
            }
            System.exit(0);
          }
        });
    mainMenu.add(exitMenuItem);

    helpMenu = new javax.swing.JMenu();
    helpMenu.setText("Help");

    aboutMenuItem = new JMenuItem("About...");
    aboutMenuItem.setEnabled(true);
    aboutMenuItem.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            about();
          }
        });
    helpMenu.add(aboutMenuItem);

    jMenuBar.add(mainMenu);
    jMenuBar.add(helpMenu);

    parentFrame.setJMenuBar(jMenuBar);
  }
示例#17
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);
 }
示例#18
0
 private void createWindowsMenu() {
   windowsMenu = new JMenu("Windows");
   menuBar.add(windowsMenu);
   showCmdsItem = new JCheckBoxMenuItem("Show Commands");
   showCmdsItem.setState(true);
   windowsMenu.add(showCmdsItem);
   showResultsItem = new JCheckBoxMenuItem("Show Results");
   showResultsItem.setState(true);
   windowsMenu.add(showResultsItem);
   showTraceItem = new JCheckBoxMenuItem("Show Trace Output");
   showTraceItem.setState(true);
   windowsMenu.add(showTraceItem);
   tileItem = new JMenuItem("Tile");
   tileItem.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent event) {
           MainWindow.this.tile();
         }
       });
   windowsMenu.add(tileItem);
 }
  // Private helper methods
  private void createMenuBar() {
    menuBar = new JMenuBar();
    fileMenu = new JMenu("File");

    miOpen = new JMenuItem("Open...");
    miOpen.setAccelerator(
        KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.Event.META_MASK));
    fileMenu.add(miOpen).setEnabled(false);
    miOpen.addActionListener(new MenuActionListener());

    miSave = new JMenuItem("Save Selected...");
    miSave.setAccelerator(
        KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.Event.META_MASK));
    fileMenu.add(miSave).setEnabled(false);
    miSave.addActionListener(new MenuActionListener());

    miSaveAll = new JMenuItem("Save All...");
    fileMenu.add(miSaveAll).setEnabled(false);
    miSaveAll.addActionListener(new MenuActionListener());

    menuBar.add(fileMenu);
  }
 public JMenuBar getFinderMenuBar() {
   if (finderMenuBar == null) {
     JMenuItem menuItem;
     finderMenuBar = new JMenuBar();
     menuFile = new JMenu("File");
     actionAddServiceType = new ActionAddServiceType();
     menuItem = new JMenuItem(actionAddServiceType);
     menuFile.add(menuItem);
     actionViewSelected = new ActionViewSelectedServiceType();
     menuItem = new JMenuItem(actionViewSelected);
     menuFile.add(menuItem);
     actionEditSelected = new ActionEditSelectedServiceType();
     menuItem = new JMenuItem(actionEditSelected);
     menuFile.add(menuItem);
     actionDeleteSelected = new ActionDeleteSelectedServiceType();
     menuItem = new JMenuItem(actionDeleteSelected);
     menuFile.add(menuItem);
     actionClose = new ActionClose();
     menuItem = new JMenuItem(actionClose);
     menuFile.add(menuItem);
     finderMenuBar.add(menuFile);
   }
   return (finderMenuBar);
 }
示例#21
0
 public void run() {
   WindowBlocker blocker = new WindowBlocker(NearInfinity.getInstance());
   blocker.setBlocked(true);
   List<ResourceEntry> files = new ArrayList<ResourceEntry>();
   for (final String fileType : FILETYPES)
     files.addAll(ResourceFactory.getInstance().getResources(fileType));
   ProgressMonitor progress =
       new ProgressMonitor(NearInfinity.getInstance(), "Searching...", null, 0, files.size());
   table =
       new SortableTable(
           new String[] {"String", "StrRef"},
           new Class[] {Object.class, Integer.class},
           new int[] {450, 20});
   StringResource.getStringRef(0);
   strUsed = new boolean[StringResource.getMaxIndex() + 1];
   for (int i = 0; i < files.size(); i++) {
     ResourceEntry entry = files.get(i);
     Resource resource = ResourceFactory.getResource(entry);
     if (resource instanceof DlgResource) checkDialog((DlgResource) resource);
     else if (resource instanceof BcsResource) checkScript((BcsResource) resource);
     else if (resource instanceof PlainTextResource) checkTextfile((PlainTextResource) resource);
     else if (resource != null) checkStruct((AbstractStruct) resource);
     progress.setProgress(i + 1);
     if (progress.isCanceled()) {
       JOptionPane.showMessageDialog(
           NearInfinity.getInstance(),
           "Operation canceled",
           "Info",
           JOptionPane.INFORMATION_MESSAGE);
       blocker.setBlocked(false);
       return;
     }
   }
   for (int i = 0; i < strUsed.length; i++)
     if (!strUsed[i]) table.addTableItem(new UnusedStringTableItem(new Integer(i)));
   if (table.getRowCount() == 0)
     JOptionPane.showMessageDialog(
         NearInfinity.getInstance(),
         "No unused strings found",
         "Info",
         JOptionPane.INFORMATION_MESSAGE);
   else {
     table.tableComplete(1);
     textArea = new JTextArea(10, 40);
     textArea.setEditable(false);
     textArea.setWrapStyleWord(true);
     textArea.setLineWrap(true);
     JScrollPane scrollText = new JScrollPane(textArea);
     resultFrame = new ChildFrame("Result", true);
     save = new JMenuItem("Save");
     save.addActionListener(this);
     JMenu fileMenu = new JMenu("File");
     fileMenu.add(save);
     JMenuBar menuBar = new JMenuBar();
     menuBar.add(fileMenu);
     resultFrame.setJMenuBar(menuBar);
     resultFrame.setIconImage(Icons.getIcon("Find16.gif").getImage());
     JLabel count = new JLabel(table.getRowCount() + " unused string(s) found", JLabel.CENTER);
     count.setFont(count.getFont().deriveFont((float) count.getFont().getSize() + 2.0f));
     JScrollPane scrollTable = new JScrollPane(table);
     scrollTable.getViewport().setBackground(table.getBackground());
     JPanel pane = (JPanel) resultFrame.getContentPane();
     pane.setLayout(new BorderLayout(0, 3));
     pane.add(count, BorderLayout.NORTH);
     pane.add(scrollTable, BorderLayout.CENTER);
     JPanel bottomPanel = new JPanel(new BorderLayout());
     JPanel searchPanel = SearchMaster.createAsPanel(this, resultFrame);
     bottomPanel.add(scrollText, BorderLayout.CENTER);
     bottomPanel.add(searchPanel, BorderLayout.EAST);
     pane.add(bottomPanel, BorderLayout.SOUTH);
     table.setFont(BrowserMenuBar.getInstance().getScriptFont());
     pane.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
     table.getSelectionModel().addListSelectionListener(this);
     resultFrame.pack();
     Center.center(resultFrame, NearInfinity.getInstance().getBounds());
     resultFrame.setVisible(true);
   }
   blocker.setBlocked(false);
 }
示例#22
0
  /**
   * This method is called when the focused component (and none of its ancestors) want the key
   * event. This will look up the keystroke to see if any chidren (or subchildren) of the specified
   * container want a crack at the event. If one of them wants it, then it will "DO-THE-RIGHT-THING"
   */
  public boolean fireKeyboardAction(KeyEvent e, boolean pressed, Container topAncestor) {

    if (e.isConsumed()) {
      System.out.println("Acquired pre-used event!");
      Thread.dumpStack();
    }

    // There may be two keystrokes associated with a low-level key event;
    // in this case a keystroke made of an extended key code has a priority.
    KeyStroke ks;
    KeyStroke ksE = null;

    if (e.getID() == KeyEvent.KEY_TYPED) {
      ks = KeyStroke.getKeyStroke(e.getKeyChar());
    } else {
      if (e.getKeyCode() != e.getExtendedKeyCode()) {
        ksE = KeyStroke.getKeyStroke(e.getExtendedKeyCode(), e.getModifiers(), !pressed);
      }
      ks = KeyStroke.getKeyStroke(e.getKeyCode(), e.getModifiers(), !pressed);
    }

    Hashtable keyMap = containerMap.get(topAncestor);
    if (keyMap != null) { // this container isn't registered, so bail

      Object tmp = null;
      // extended code has priority
      if (ksE != null) {
        tmp = keyMap.get(ksE);
        if (tmp != null) {
          ks = ksE;
        }
      }
      if (tmp == null) {
        tmp = keyMap.get(ks);
      }

      if (tmp == null) {
        // don't do anything
      } else if (tmp instanceof JComponent) {
        JComponent c = (JComponent) tmp;
        if (c.isShowing() && c.isEnabled()) { // only give it out if enabled and visible
          fireBinding(c, ks, e, pressed);
        }
      } else if (tmp instanceof Vector) { // more than one comp registered for this
        Vector v = (Vector) tmp;
        // There is no well defined order for WHEN_IN_FOCUSED_WINDOW
        // bindings, but we give precedence to those bindings just
        // added. This is done so that JMenus WHEN_IN_FOCUSED_WINDOW
        // bindings are accessed before those of the JRootPane (they
        // both have a WHEN_IN_FOCUSED_WINDOW binding for enter).
        for (int counter = v.size() - 1; counter >= 0; counter--) {
          JComponent c = (JComponent) v.elementAt(counter);
          // System.out.println("Trying collision: " + c + " vector = "+ v.size());
          if (c.isShowing() && c.isEnabled()) { // don't want to give these out
            fireBinding(c, ks, e, pressed);
            if (e.isConsumed()) return true;
          }
        }
      } else {
        System.out.println("Unexpected condition in fireKeyboardAction " + tmp);
        // This means that tmp wasn't null, a JComponent, or a Vector.  What is it?
        Thread.dumpStack();
      }
    }

    if (e.isConsumed()) {
      return true;
    }
    // if no one else handled it, then give the menus a crack
    // The're handled differently.  The key is to let any JMenuBars
    // process the event
    if (keyMap != null) {
      Vector v = (Vector) keyMap.get(JMenuBar.class);
      if (v != null) {
        Enumeration iter = v.elements();
        while (iter.hasMoreElements()) {
          JMenuBar mb = (JMenuBar) iter.nextElement();
          if (mb.isShowing() && mb.isEnabled()) { // don't want to give these out
            boolean extended = (ksE != null) && !ksE.equals(ks);
            if (extended) {
              fireBinding(mb, ksE, e, pressed);
            }
            if (!extended || !e.isConsumed()) {
              fireBinding(mb, ks, e, pressed);
            }
            if (e.isConsumed()) {
              return true;
            }
          }
        }
      }
    }

    return e.isConsumed();
  }
示例#23
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());
              }
            }
          });
    }
示例#24
0
    /** Create the UI for this editor */
    void makeUI() {

      JPanel mainPanel = new JPanel(new BorderLayout());
      mainPanel.setBorder(new LineBorder(Color.blue));
      getContentPane().add(mainPanel, BorderLayout.CENTER);

      // the map and associated toolbar
      npEditControl = new NPController();
      mapEditPanel = npEditControl.getNavigatedPanel(); // here's where the map will be drawn
      mapEditPanel.setPreferredSize(new Dimension(250, 250));
      mapEditPanel.setSelectRegionMode(true);
      JToolBar navToolbar = mapEditPanel.getNavToolBar();
      navToolbar.setFloatable(false);
      JToolBar moveToolbar = mapEditPanel.getMoveToolBar();
      moveToolbar.setFloatable(false);
      // toolbar.remove("setReference");

      JPanel toolbar = new JPanel();
      List localMaps = maps;
      if (localMaps == null) {
        localMaps = getDefaultMaps();
      }
      JMenu mapMenu = new JMenu("Maps");
      JMenuBar menuHolder = new JMenuBar();
      menuHolder.setBorder(null);
      menuHolder.add(mapMenu);
      toolbar.add(menuHolder);
      for (int mapIdx = 0; mapIdx < localMaps.size(); mapIdx++) {
        final MapData mapData = (MapData) localMaps.get(mapIdx);
        final JCheckBoxMenuItem cbx =
            new JCheckBoxMenuItem(mapData.getDescription(), mapData.getVisible());
        if (mapData.getVisible()) {
          toggleMap(mapData, true);
        }
        mapMenu.add(cbx);
        cbx.addItemListener(
            new ItemListener() {
              public void itemStateChanged(ItemEvent event) {
                toggleMap(mapData, cbx.isSelected());
              }
            });
      }
      GuiUtils.limitMenuSize(mapMenu, "Maps ", 20);

      toolbar.add(navToolbar);
      toolbar.add(moveToolbar);

      JPanel mapSide = new JPanel();
      mapSide.setLayout(new BorderLayout());
      TitledBorder mapBorder =
          new TitledBorder(
              standardBorder, "Edit Projection", TitledBorder.ABOVE_TOP, TitledBorder.CENTER);
      mapSide.setBorder(mapBorder);
      mapSide.add(toolbar, BorderLayout.NORTH);
      mapSide.add(mapEditPanel, BorderLayout.CENTER);
      mainPanel.add(mapSide, BorderLayout.WEST);

      // the projection parameters

      // the Projection name
      JLabel nameLabel = GuiUtils.rLabel("Name: ");
      nameTF = new JTextField(20);

      // the list of Projection classes is kept in a comboBox
      typeLabel = GuiUtils.rLabel("Type: ");
      projClassCB = new JComboBox();
      // standard list of projection classes
      List classNames = getDefaultProjections();
      for (int i = 0; i < classNames.size(); i++) {
        String className = (String) classNames.get(i);
        try {
          projClassCB.addItem(new ProjectionClass(className));
        } catch (ClassNotFoundException ee) {
          System.err.println("ProjectionManager failed on " + className + " " + ee);
        } catch (IntrospectionException ee) {
          System.err.println("ProjectionManager failed on " + className + " " + ee);
        }
      }
      GuiUtils.tmpInsets = new Insets(4, 4, 4, 4);
      JPanel topPanel =
          GuiUtils.doLayout(
              new Component[] {nameLabel, nameTF, typeLabel, projClassCB},
              2,
              GuiUtils.WT_N,
              GuiUtils.WT_N);

      // the Projection parameter area
      paramPanel = new JPanel();
      paramPanel.setLayout(new BorderLayout());
      paramPanel.setBorder(
          new TitledBorder(
              standardBorder,
              "Projection Parameters",
              TitledBorder.ABOVE_TOP,
              TitledBorder.CENTER));

      // the bottom button panel
      JPanel buttPanel = new JPanel();
      JButton acceptButton = new JButton("Save");
      JButton previewButton = new JButton("Preview");
      JButton cancelButton = new JButton("Cancel");
      buttPanel.add(acceptButton, null);
      buttPanel.add(previewButton, null);
      buttPanel.add(cancelButton, null);

      JPanel mainBox = GuiUtils.topCenterBottom(topPanel, paramPanel, buttPanel);
      mainPanel.add(mainBox, BorderLayout.CENTER);
      pack();

      // enable event listeners when we're done constructing the UI
      projClassCB.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              ProjectionClass selectClass = (ProjectionClass) projClassCB.getSelectedItem();
              setProjection(selectClass.makeDefaultProjection());
            }
          });

      acceptButton.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
              accept();
            }
          });
      previewButton.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
              ProjectionClass projClass = findProjectionClass(editProjection);
              if (null != projClass) {
                setProjFromDialog(projClass, editProjection);
                setProjection(editProjection);
              }
            }
          });
      cancelButton.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
              NewProjectionDialog.this.setVisible(false);
            }
          });
    }
示例#25
0
  public DialogStammdaten(JFrame fenster, String[][] datensatz1, String s, Methoden datenbank1) {
    super(fenster, true);
    datenbank = datenbank1;
    datensatz = datensatz1;
    p = new JPanel();
    platzhalter = new JLabel();
    text1 = new JLabel("Name");
    text2 = new JLabel("Personalnummer");
    text3 = new JLabel("Titel");
    text4 = new JLabel("Institut");
    feld = new JComboBox();
    textName = new JTextField();
    textPersonalnr = new JTextField();
    textInstitut = new JTextField();
    textTitel = new JTextField();
    menue = new JMenuBar();
    datei = new JMenu("Datei");
    aendern = new JMenuItem("Aendern");
    hinzufuegen = new JMenuItem("Hinzufuegen");
    loeschen = new JMenuItem("Loeschen");
    beenden = new JMenuItem("Beenden");
    final JDialog dialog = this;
    this.setTitle(s);
    feld = new JComboBox(ersteElemente(datensatz));
    textName.setText(datensatz[0][0]);
    textPersonalnr.setText(datensatz[0][1]);
    setzen(datensatz, feld.getSelectedIndex());

    feld.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            if (e.getID() == ItemEvent.ITEM_STATE_CHANGED
                && e.getStateChange() == ItemEvent.SELECTED) {
              textName.setText((String) e.getItem());
              textPersonalnr.setText(datensatz[feld.getSelectedIndex()][1]);
              setzen(datensatz, feld.getSelectedIndex());
            }
          }
        });

    datei.addMenuListener(
        new MenuListener() {
          public void menuSelected(MenuEvent e) {
            hinzufuegen.setEnabled(false);
            aendern.setEnabled(false);
            loeschen.setEnabled(false);

            if (!geaendert(datensatz, feld.getSelectedIndex())) {
              loeschen.setEnabled(true);
            } else if (!(textName.getText().equals("") || textPersonalnr.getText().equals(""))) {
              hinzufuegen.setEnabled(true);
              aendern.setEnabled(true);
            }
          }

          public void menuDeselected(MenuEvent e) {}

          public void menuCanceled(MenuEvent e) {}
        });

    hinzufuegen.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            String[] daten = erstellen();
            if (hinzufuegen(daten)) {
              dispose();
            } else {
              JOptionPane.showMessageDialog(
                  dialog, "Hinzufuegen geht nicht.", "Fehler", JOptionPane.ERROR_MESSAGE);
            }
          }
        });
    aendern.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            String[] daten = erstellen();
            if (aendern(datensatz[feld.getSelectedIndex()][1], daten)) {
              dispose();
            } else {
              JOptionPane.showMessageDialog(
                  dialog, "Aendern geht nicht.", "Fehler", JOptionPane.ERROR_MESSAGE);
            }
          }
        });
    loeschen.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            String[] daten = erstellen();
            if (loeschen(datensatz[feld.getSelectedIndex()][1])) {
              dispose();
            } else {
              JOptionPane.showMessageDialog(
                  dialog, "Loeschen geht nicht.", "Fehler", JOptionPane.ERROR_MESSAGE);
            }
          }
        });
    beenden.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            dispose();
          }
        });

    datei.add(hinzufuegen);
    datei.add(aendern);
    datei.add(loeschen);
    datei.add(beenden);
    menue.add(datei);
    this.setJMenuBar(menue);

    p.setLayout(new GridLayout(2, 5));
    p.add(platzhalter);
    p.add(text1);
    p.add(text2);
    p.add(text3);
    p.add(text4);
    p.add(feld);
    p.add(textName);
    p.add(textPersonalnr);
    p.add(textTitel);
    p.add(textInstitut);
    this.setContentPane(p);

    this.pack();
    this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
  }
  /** 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);
  }
示例#27
0
  /**
   * Show the results sent to a batch queue.
   *
   * @param mysettings jemboss settings
   * @param epr pending results
   * @throws JembossSoapException when server connection fails
   */
  public ShowSavedResults(final JembossParams mysettings, final PendingResults epr)
      throws JembossSoapException {
    this("Current Sessions Results");

    Dimension d = new Dimension(270, 100);
    ss.setPreferredSize(d);
    //  ss.setMaximumSize(d);

    JMenu resFileMenu = new JMenu("File");
    resMenu.add(resFileMenu);

    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) {
            setCursor(cbusy);
            epr.updateStatus();
            setCursor(cdone);
            datasets.removeAllElements();
            Enumeration enumer = epr.descriptionHash().keys();
            while (enumer.hasMoreElements()) {
              String image = convertToPretty((String) enumer.nextElement());
              datasets.addElement(image);
            }
          }
        });

    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);

    // set up the results list in the gui
    Enumeration enumer = epr.descriptionHash().keys();
    while (enumer.hasMoreElements())
      datasets.addElement(convertToPretty((String) enumer.nextElement()));

    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()) {
              int index = theList.getSelectedIndex();
              String thisdata = convertToOriginal(datasets.elementAt(index));
              aboutRes.setText((String) epr.descriptionHash().get(thisdata));
              aboutRes.setCaretPosition(0);
              aboutRes.setEditable(false);
            }
          }
        });

    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");
                setCursor(cdone);
                if (thisres.getStatus().equals("0"))
                  new ShowResultSet(thisres.hash(), project, mysettings);
                else
                  JOptionPane.showMessageDialog(
                      null, thisres.getStatusMsg(), "Soap Error", JOptionPane.ERROR_MESSAGE);

              } catch (JembossSoapException eae) {
                AuthPopup ap = new AuthPopup(mysettings, null);
                ap.setBottomPanel();
                ap.setSize(380, 170);
                ap.pack();
                ap.setVisible(true);
              }
            }
          }
        });
    sp.add(st);

    // display retrieves all the 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) {
            if (st.getSelectedValue() != null) {
              try {
                setCursor(cbusy);
                String project = convertToOriginal(st.getSelectedValue());
                ResultList thisres = new ResultList(mysettings, project, "show_saved_results");
                setCursor(cdone);
                if (thisres.getStatus().equals("0"))
                  new ShowResultSet(thisres.hash(), project, mysettings);
                else
                  JOptionPane.showMessageDialog(
                      null, thisres.getStatusMsg(), "Soap Error", JOptionPane.ERROR_MESSAGE);
              } catch (JembossSoapException eae) {
                setCursor(cdone);
                AuthPopup ap = new AuthPopup(mysettings, null);
                ap.setBottomPanel();
                ap.setSize(380, 170);
                ap.pack();
                ap.setVisible(true);
              }
            }
          }
        });

    // delete removes the file on the server and 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("");
              for (int i = 0; i < sel.length; i++) selList = selList.concat(sel[i] + "\n");

              int ok = JOptionPane.OK_OPTION;
              if (sel.length > 1)
                ok =
                    JOptionPane.showConfirmDialog(
                        null,
                        "Delete the following results:\n" + selList,
                        "Confirm Deletion",
                        JOptionPane.YES_NO_OPTION);

              if (ok == JOptionPane.OK_OPTION) {

                try {
                  setCursor(cbusy);
                  selList = convertToOriginal(selList);
                  new ResultList(mysettings, selList, "delete_saved_results");
                  setCursor(cdone);

                  for (int i = 0; i < sel.length; i++) {
                    JembossProcess jp = epr.getResult(convertToOriginal(sel[i]));
                    epr.removeResult(jp);
                    datasets.removeElement(sel[i]); // amend the list
                  }
                  statusField.setText("Deleted " + sel.length + "  result(s)");
                  aboutRes.setText("");
                  st.setSelectedIndex(-1);
                } catch (JembossSoapException eae) {
                  // shouldn't happen
                  AuthPopup ap = new AuthPopup(mysettings, null);
                  ap.setBottomPanel();
                  ap.setSize(380, 170);
                  ap.pack();
                  ap.setVisible(true);
                }
              }
            }
          }
        });
    resButtonPanel.add(delResButton);
    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);
    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

    pack();
    setVisible(true);

    // add in automatic updates
    String freq = (String) AdvancedOptions.jobMgr.getSelectedItem();
    int ind = freq.indexOf(" ");
    new ResultsUpdateTimer(Integer.parseInt(freq.substring(0, ind)), datasets, this);
    statusField.setText("Window refresh rate " + freq);
  }
示例#28
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);
    }
  }
  // The init method
  public void init() {

    // Set the look and feel
    try {
      UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
      return;
    }

    // Create the menuListener
    MenuListener menuListener = new MenuListener();

    // Create the menu bar
    JMenuBar menuBar = new JMenuBar();
    setJMenuBar(menuBar);

    // Create the file menu
    JMenu fileMenu = new JMenu("File");
    menuBar.add(fileMenu);

    // Create the menuitems
    JMenuItem menuItem;
    menuItem = new JMenuItem("Read Particle Location Data");
    fileMenu.add(menuItem);
    menuItem.addActionListener(menuListener);

    menuItem = new JMenuItem("Save Uintah Input File");
    fileMenu.add(menuItem);
    menuItem.addActionListener(menuListener);

    menuItem = new JMenuItem("Exit");
    fileMenu.add(menuItem);
    menuItem.addActionListener(menuListener);

    // Create the main tabbed pane
    mainTabbedPane = new JTabbedPane();

    // Create the panels to be added to the tabbed pane
    uintahInputPanel = new UintahInputPanel(d_partList, this);
    particleGenPanel = new ParticleGeneratePanel(d_partList, this);

    // Add the tabs
    mainTabbedPane.addTab("Uintah Inputs", null, uintahInputPanel, null);
    mainTabbedPane.addTab("Generate Particle Locations", null, particleGenPanel, null);
    mainTabbedPane.setSelectedIndex(0);
    getContentPane().add(mainTabbedPane);

    // Create the help menu
    JMenu helpMenu = new JMenu("Help");
    menuBar.add(helpMenu);

    // Create the menuitems
    menuItem = new JMenuItem("About");
    helpMenu.add(menuItem);
    menuItem.addActionListener(menuListener);

    // Create the invisible help frames
    helpAboutFrame = new HelpAboutFrame();
    helpAboutFrame.pack();

    // Create the Tab Listener
    TabListener tabListener = new TabListener();
    mainTabbedPane.addChangeListener(tabListener);
  }
示例#30
0
  /**
   * Adds the menus to the main frame Includes adding ActionListeners to respond to menu commands
   */
  private void addMenus() {
    JMenuBar menuBar = new JMenuBar();
    JMenu gameMenu = new JMenu("Game");
    gameMenu.setMnemonic('G');

    JMenuItem newMenu = new JMenuItem("New Game");
    newMenu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, InputEvent.CTRL_MASK));

    newMenu.addActionListener(
        new ActionListener() {
          /**
           * Responds to the New menu option
           *
           * @param event The event that selected this menu option
           */
          public void actionPerformed(ActionEvent e) {
            newGame();
            time = 0;
          }
        });

    JMenuItem exitMenu = new JMenuItem("Exit");
    exitMenu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, InputEvent.CTRL_MASK));

    exitMenu.addActionListener(
        new ActionListener() {
          /**
           * Responds to the exit game option being selected
           *
           * @param event The event that selected this menu option
           */
          public void actionPerformed(ActionEvent event) {
            System.exit(0);
          }
        });
    gameMenu.add(newMenu);
    gameMenu.add(exitMenu);
    menuBar.add(gameMenu);

    JMenu helpMenu = new JMenu("Help");
    helpMenu.setMnemonic('H');
    JMenuItem instructionsMenuItem = new JMenuItem("Instructions", 'I');
    instructionsMenuItem.addActionListener(
        new ActionListener() {
          /**
           * Responds to the help option being selected
           *
           * @param event The event that selected this menu option
           */
          public void actionPerformed(ActionEvent event) {
            JOptionPane.showMessageDialog(
                BearSweeper.this,
                "The objective of the game is to flag Fabear's hiding spots so people know where to avoid.\n"
                    + "If you click on an area that Fabear does not reside, a digit is revealed.\n"
                    + "This digit indicates the number of adjacent squares in which Fabear resides.\n"
                    + "Mark Fabear's hiding spots by right clicking."
                    + "If you click on a spot where Fabear resides, you will wake up and unleash his wrath.\n"
                    + "Note: You only have enough flags for exactly the number of hiding spots!",
                "Help",
                JOptionPane.INFORMATION_MESSAGE);
          }
        });
    instructionsMenuItem.setAccelerator(
        KeyStroke.getKeyStroke(KeyEvent.VK_I, InputEvent.CTRL_MASK));
    JMenuItem aboutMenuItem = new JMenuItem("About...", 'A');
    aboutMenuItem.addActionListener(
        new ActionListener() {
          /**
           * Responds to the about option being selected
           *
           * @param event The event that selected this menu option
           */
          public void actionPerformed(ActionEvent event) {
            JOptionPane.showMessageDialog(
                BearSweeper.this,
                "Fabear is now a well-known hero on Earth.\n"
                    + "He has saved Earth in the Tera sagas, but not without sacrifice.\n"
                    + "Although the Earth is now clean from the dangerous substances left behind by the aliens, Fabear has changed...\n"
                    + "He had come in contact with the substance and is now under the control of the aliens.\n"
                    + "It is your turn to save Fabear, from himself..."
                    + "He is currently sleeping.\n"
                    + "Find Fabear's hiding spots without waking him from his sleep."
                    + "When all of his possible hiding spots are marked with flags,\n"
                    + "special task forces will take over to secure Fabear and take him to a lab "
                    + "where scientists will do everything they can to\n"
                    + "return Fabear to his original self.\n"
                    + "\nBy: Christopher Li and Aaron Lee - 2009-2010",
                "The Adventures of Fabear",
                JOptionPane.INFORMATION_MESSAGE);
          }
        });
    aboutMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, InputEvent.CTRL_MASK));

    helpMenu.add(instructionsMenuItem);
    helpMenu.add(aboutMenuItem);
    menuBar.add(helpMenu);
    setJMenuBar(menuBar);
  }