示例#1
0
  void initControls() {
    JMenuItem jmi;

    jmi = new JMenuItem("JImage Menu");
    jmi.setEnabled(false);
    popupMenu.add(jmi);

    jmi = new JMenuItem("Fit");
    jmi.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            fit = true;
            repaint();
          }
        });
    popupMenu.add(jmi);

    JMenu scaleMenu = new JMenu("Set Scale");
    popupMenu.add(scaleMenu);
    int scales[] = new int[] {25, 50, 100, 200, 400, 800};

    for (int i = 0; i < scales.length; i++) {
      jmi = new JMenuItem(scales[i] + " %");
      jmi.addActionListener(new ScaleAction(scales[i]));
      scaleMenu.add(jmi);
    }

    MyListener l = new MyListener();
    addMouseMotionListener(l);
    addMouseListener(l);
    addMouseWheelListener(l);
    addKeyListener(l);
  }
  public void adjustListMenuBar() {
    JMenuItem menuItem;
    Action act;
    String itemLabel;
    boolean enableState;
    boolean inEditState;
    boolean allowAdds;
    ICFInternetTopProjectObj selectedObj = getSwingFocusAsTopProject();
    CFJPanel.PanelMode mode = getPanelMode();
    if (mode == CFJPanel.PanelMode.Edit) {
      inEditState = true;
      if (getSwingContainer() != null) {
        allowAdds = true;
      } else {
        allowAdds = false;
      }
    } else {
      inEditState = false;
      allowAdds = false;
    }
    if (selectedObj == null) {
      enableState = false;
    } else {
      enableState = true;
    }

    if (actionViewSelected != null) {
      actionViewSelected.setEnabled(enableState);
    }
    if (actionEditSelected != null) {
      actionEditSelected.setEnabled(inEditState && enableState);
    }
    if (actionDeleteSelected != null) {
      actionDeleteSelected.setEnabled(inEditState && enableState);
    }
    if (actionAddTopProject != null) {
      actionAddTopProject.setEnabled(allowAdds);
    }

    if (menuAdd != null) {
      menuAdd.setEnabled(allowAdds);
    }
    if (menuSelected != null) {
      menuSelected.setEnabled(enableState);
      int itemCount = menuSelected.getItemCount();
      for (int itemIdx = 0; itemIdx < itemCount; itemIdx++) {
        menuItem = menuSelected.getItem(itemIdx);
        act = menuItem.getAction();
        if (act != null) {
          if (act == actionViewSelected) {
            menuItem.setEnabled(enableState);
          } else if (act == actionEditSelected) {
            menuItem.setEnabled(inEditState && enableState);
          } else if (act == actionDeleteSelected) {
            menuItem.setEnabled(inEditState && enableState);
          }
        }
      }
    }
  }
示例#3
0
  /**
   * initialize the symbols menu
   *
   * @param m menu
   */
  public void initSymbolsMenu(JMenu m) {
    m.removeAll();
    for (int i = 0; i < glyphs.size(); i++) {
      final MetSymbol metSymbol = (MetSymbol) glyphs.get(i);
      JMenuItem mi = GuiUtils.makeMenuItem(metSymbol.getLabel(), this, "showProperties", metSymbol);
      mi.addMouseListener(
          new MouseAdapter() {
            public void mousePressed(MouseEvent e) {
              highlightedMetSymbol = null;
              StationModelCanvas.this.repaint();
            }

            public void mouseReleased(MouseEvent e) {
              highlightedMetSymbol = null;
              StationModelCanvas.this.repaint();
            }

            public void mouseEntered(MouseEvent e) {
              highlightedMetSymbol = metSymbol;
              StationModelCanvas.this.repaint();
            }

            public void mouseExited(MouseEvent e) {
              highlightedMetSymbol = null;
              StationModelCanvas.this.repaint();
            }
          });
      m.add(mi);
    }
  }
示例#4
0
  public void updateConnectionStatus(boolean connected) {
    if (connected == true) {
      headerPanel.setLogoutText();
      loginMenuItem.setText("Logout");
    } else {
      headerPanel.setLoginText();
      loginMenuItem.setText("Login...");
    }
    mainCommandPanel.updateConnectionStatus(connected);
    propertiePanel.updateConnectionStatus(connected);
    cmdConsole.updateConnectionStatus(connected);
    Iterator iterator = plugins.iterator();
    PluginPanel updatePluginPanel = null;
    while (iterator.hasNext()) {
      updatePluginPanel = (PluginPanel) iterator.next();
      updatePluginPanel.updateConnectionStatus(connected);
    }

    if (connected == true) {
      int selected = tabbedPane.getSelectedIndex();
      if (selected >= 2) {
        ((PluginPanel) pluginPanelMap.get("" + selected)).activated();
      }
    }
  }
  /*
   * The following method creates the font menu item to choose a font
   *     style.
   * postcondition: returns the JMenuItem for the font menu item for
   *     the font style.
   */
  public JMenuItem createFontStyleItem(String style) {
    JMenuItem item = new JMenuItem(style);

    // This class is used to create a special ActionListener for this menu item
    class MenuItemListener implements ActionListener {
      private String style;

      public MenuItemListener(String s) {
        style = s;
      }

      public void actionPerformed(ActionEvent event) {
        // Set the size of the font
        if (style.equals("Plain")) fontStyle = Font.PLAIN;
        else if (style.equals("Italic")) fontStyle = Font.ITALIC;
        else if (style.equals("Bold")) fontStyle = Font.BOLD;
        else if (style.equals("Bold Italic")) fontStyle = Font.ITALIC | Font.BOLD;

        sampleField.setFont(new Font(fontName, fontStyle, fontSize));
        sampleField.repaint();

        pack();
      }
    }
    ActionListener listener = new MenuItemListener(style);
    item.addActionListener(listener);
    return item;
  } // end createFontStyleItem method
示例#6
0
 public void actionPerformed(ActionEvent e) {
   if (e.getSource() instanceof JMenuItem) {
     JMenuItem item = (JMenuItem) e.getSource();
     String name = item.getText();
     profiles.delete(name);
   }
 }
  /*
   * The following method creates the font menu item to choose a font
   *     size.
   * postcondition: returns the JMenuItem for the font menu item for
   *     the font size.
   */
  public JMenuItem createFontSizeItem(String size) {
    JMenuItem item = new JMenuItem(size);

    // This class is used to create a special ActionListener for this menu item
    class MenuItemListener implements ActionListener {
      private String size;

      public MenuItemListener(String s) {
        size = s;
      }

      public void actionPerformed(ActionEvent event) {
        // Set the size of the font
        //                        if(size.equals("Small"))
        //                              fontSize = SMALL;
        //                        else if(size.equals("Medium"))
        //                              fontSize = MEDIUM;
        //                        else if(size.equals("Large"))
        //                              fontSize = LARGE;

        fontSize = Integer.parseInt(size);

        sampleField.setFont(new Font(fontName, fontStyle, fontSize));
        sampleField.repaint();

        pack();
      }
    }
    ActionListener listener = new MenuItemListener(size);
    item.addActionListener(listener);
    return item;
  } // end createFontSizeItem method
示例#8
0
 private void addProfiles(JMenu menu, String[] profileNames, ActionListener listener) {
   for (int i = 0; i < profileNames.length; i++) {
     JMenuItem item = new JMenuItem(profileNames[i]);
     item.addActionListener(listener);
     menu.add(item);
   }
 }
  private JPanel createContentPane() {
    JPanel panel = new JPanel();

    combo1 = new JComboBox<>(numData);
    panel.add(combo1);
    combo2 = new JComboBox<>(dayData);
    combo2.setEditable(true);
    panel.add(combo2);
    panel.setSize(300, 200);

    popupMenu = new JPopupMenu();
    JMenuItem item;
    for (int i = 0; i < dayData.length; i++) {
      item = popupMenu.add(new JMenuItem(dayData[i], mnDayData[i]));
      item.addActionListener(this);
    }
    panel.addMouseListener(new PopupListener(popupMenu));

    JTextField field = new JTextField("CTRL+down for Popup");
    // CTRL-down will show the popup.
    field
        .getInputMap()
        .put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, InputEvent.CTRL_MASK), "OPEN_POPUP");
    field.getActionMap().put("OPEN_POPUP", new PopupHandler());

    panel.add(field);

    return panel;
  }
示例#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
  /**
   * _more_
   *
   * @param symbols _more_
   * @param listener _more_
   * @param smm _more_
   * @return _more_
   */
  public static List makeStationModelMenuItems(
      List symbols, final ObjectListener listener, StationModelManager smm) {
    List items = new ArrayList();
    List subMenus = new ArrayList();
    Hashtable categories = new Hashtable();
    for (int i = 0; i < symbols.size(); i++) {
      StationModel sm = (StationModel) symbols.get(i);
      boolean isUsers = smm.isUsers(sm);
      String name = sm.getName();
      if (name.equals("")) continue;
      List toks = StringUtil.split(name, ">", true, true);
      if (toks.size() > 0) {
        name = (String) toks.get(toks.size() - 1);
      }
      JMenuItem item = new JMenuItem(GuiUtils.getLocalName(name, isUsers));
      item.addActionListener(
          new ObjectListener(sm) {
            public void actionPerformed(ActionEvent ae) {
              listener.setObject(this.theObject);
              listener.actionPerformed(ae);
            }
          });

      toks.remove(toks.size() - 1);
      if (toks.size() == 0) {
        items.add(item);
        continue;
      }
      JMenu categoryMenu = null;
      String catSoFar = "";
      String menuCategory = "";
      for (int catIdx = 0; catIdx < toks.size(); catIdx++) {
        String subCat = (String) toks.get(catIdx);
        catSoFar = catSoFar + "/" + subCat;
        JMenu m = (JMenu) categories.get(catSoFar);
        if (m == null) {
          m = new JMenu(subCat);
          menuCategory = catSoFar;
          categories.put(catSoFar, m);
          if (categoryMenu != null) {
            categoryMenu.add(m, 0);
          } else {
            subMenus.add(m);
          }
        }
        categoryMenu = m;
      }
      if (categoryMenu == null) {
        categoryMenu = new JMenu("");
        categories.put(toks.toString(), categoryMenu);
        subMenus.add(categoryMenu);
        menuCategory = toks.toString();
      }
      categoryMenu.add(item);
    }
    items.addAll(subMenus);
    return items;
  }
示例#12
0
  /**
   * Define the main About menu.
   *
   * @param al the action listener to associate to the menu.
   * @return the menu.
   */
  public JMenu defineAboutMenu(ActionListener al) {
    JMenu about = new JMenu(Globals.messages.getString("About"));
    JMenuItem aboutMenu = new JMenuItem(Globals.messages.getString("About_menu"));
    about.add(aboutMenu);

    aboutMenu.addActionListener(al);

    return about;
  }
示例#13
0
    public void actionPerformed(ActionEvent event) {

      JMenuItem mi;
      String label = "";

      if (warningPopup == null) {
        warningPopup = new WarningDialog(textViewerFrame);
      }
      if ((editor1 == null) || (editor1.getDocument() == null)) {
        String errstr = "TextViewer:editor1 or document is null";
        warningPopup.display(errstr);
        return;
      }
      String actionStr = event.getActionCommand(); // is not makeing anysense
      // when keystrokes typed
      if ((event.getSource() instanceof JMenuItem)) {
        mi = (JMenuItem) event.getSource();
        label = mi.getText();
      } else if ((event.getSource() instanceof JTextArea)) { // keystroke
        label = "FindAgain"; // just set it to findagain
      } else {
        System.err.println("Debug:TextViewer:" + actionStr);
        System.err.println("Debug:TextViewer:" + event.getSource().toString());
        String errstr =
            "TextViewer:FindAction: "
                + event.getSource().toString()
                + " not an instance of JMenuItem or JTextArea";
        warningPopup.display(errstr);
        return;
      }

      if (label.equals("FindAgain")) {
        isFindAgain = true;
        lastFindStr = lastFindStr;
      } else {
        isFindAgain = false;
        lastFindStr = "";
      }
      StringBoolean content = new StringBoolean(lastFindStr, forwardFindDirection);

      boolean okPressed = mySearchDialog.display(content);
      if (!okPressed) {
        return;
      }
      lastFindStr = content.mystring;
      forwardFindDirection = content.myboolean;

      if (forwardFindDirection) {
        lastFindIndex = searchForward(lastFindStr);
        //		System.out.println("Debug:TextViewer: lastFindIndex:"+lastFindIndex);

      } else {
        lastFindIndex = searchBackward(lastFindStr);
        //		System.out.println("Debug:TextViewer: lastFindIndex:"+lastFindIndex);
      }
    }
示例#14
0
 public void actionPerformed(ActionEvent e) {
   JMenuItem jmi = (JMenuItem) e.getSource();
   Iterator marks = mediator.getMarkerModel().getMarkersWithLabel(jmi.getText());
   if (marks.hasNext()) {
     ChronicleMarker marker = (ChronicleMarker) marks.next();
     Instant to = marker.getWhen();
     Instant from = mediator.getMajorMoment();
     viper.api.impl.Util.shiftDescriptors(new Descriptor[] {desc}, from, to);
   }
 }
示例#15
0
 public void propertyChange(PropertyChangeEvent e) {
   String propertyName = e.getPropertyName();
   if (e.getPropertyName().equals(Action.NAME)) {
     String text = (String) e.getNewValue();
     menuItem.setText(text);
   } else if (propertyName.equals("enabled")) {
     Boolean enabledState = (Boolean) e.getNewValue();
     menuItem.setEnabled(enabledState.booleanValue());
   }
 }
示例#16
0
 /**
  * constructor
  *
  * @param values list of values, ArrayList
  */
 public MPopButton(ArrayList values) {
   this();
   for (int i = 0; i < values.size(); i++) {
     JMenuItem item = popup.add((String) values.get(i));
     item.addActionListener(popActionListener);
     popup.add(item);
   }
   m_aListValues = values;
   setDefaultText();
 } // MPopButton()
 @Override
 public void setProfiler(Profiler profiler) {
   if (profiler != null) {
     profilerWindow = new ProfilerWindow(profiler);
     profilerMenuItem.setEnabled(true);
   } else {
     profilerWindow = null;
     profilerMenuItem.setEnabled(false);
   }
 }
示例#18
0
 /**
  * constructor
  *
  * @param values list of values, String[]
  */
 public MPopButton(String[] values) {
   this();
   for (int i = 0; i < values.length; i++) {
     JMenuItem item = popup.add(values[i]);
     item.addActionListener(popActionListener);
     popup.add(item);
     m_aListValues.add(values[i]);
   }
   setDefaultText();
 } // MPopButton()
示例#19
0
 public void actionPerformed(ActionEvent e) {
   Iterator toInterp = Collections.singleton(desc).iterator();
   JMenuItem jmi = (JMenuItem) e.getSource();
   Iterator marks = mediator.getMarkerModel().getMarkersWithLabel(jmi.getText());
   if (marks.hasNext()) {
     ChronicleMarker marker = (ChronicleMarker) marks.next();
     Instant to = marker.getWhen();
     Instant from = mediator.getMajorMoment();
     mediator.getPropagator().interpolateDescriptors(toInterp, from, to);
   }
 }
示例#20
0
 public void propertyChange(PropertyChangeEvent e) {
   String propertyName = e.getPropertyName();
   if (e.getPropertyName().equals(Action.NAME)) {
     String text = (String) e.getNewValue();
     menuItem.setText(text);
   } else if (propertyName.equals("enabled")) {
     // System.out.println("Debug:TextViewer: ActionChangedListener enabled");
     Boolean enabledState = (Boolean) e.getNewValue();
     menuItem.setEnabled(enabledState.booleanValue());
   }
 }
示例#21
0
  /**
   * Define the main View menu.
   *
   * @param al the action listener to associate to the menu.
   * @return the menu.
   */
  public JMenu defineViewMenu(ActionListener al) {
    JMenu viewMenu = new JMenu(Globals.messages.getString("View"));
    JMenuItem layerOptions = new JMenuItem(Globals.messages.getString("Layer_opt"));

    layerOptions.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_L, Globals.shortcutKey));

    viewMenu.add(layerOptions);

    layerOptions.addActionListener(al);
    return viewMenu;
  }
 /*
  * The following method creates the file menu item to quit the program
  * postcondition: returns the JMenuItem for the file menu item "Exit".
  */
 public JMenuItem createFileExitItem() {
   JMenuItem item = new JMenuItem(new String("Exit"));
   class MenuItemListener implements ActionListener {
     public void actionPerformed(ActionEvent event) {
       System.exit(0);
     }
   }
   ActionListener listener = new MenuItemListener();
   item.addActionListener(listener);
   return item;
 } // end createFileExitItem method
  public void createPopupMenu() {
    menu = new JPopupMenu();
    for (int i = filenames.size() - 2, j = 0; i >= 0; i--, j++) {
      menu.add((String) filenames.elementAt(i));
      JMenuItem mi = (JMenuItem) menu.getComponent(j);
      mi.setFont(new Font("Arial", Font.PLAIN, 11));
      mi.addActionListener(this);
    }

    menu.pack();
    // setPopupLocation(200, 200);
  }
示例#24
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);
  }
示例#25
0
 // set all menu items related to debugging enabled, all else disabled;
 // for insert, remove and fetch: continue, step
 // additionally for scripts: next and sometimes cancel
 private void enableDebug(boolean isScript, boolean enableCancel) {
   setAllEnabled(false);
   debugMenu.setEnabled(true);
   stepAction.setEnabled(true);
   cancelAction.setEnabled(enableCancel);
   nextAction.setEnabled(isScript);
   contAction.setEnabled(true);
   breakpointsItem.setEnabled(true);
   treeStatsMenu.setEnabled(true);
   utilItem.setEnabled(true);
   predSzItem.setEnabled(true);
   slotCntItem.setEnabled(true);
 }
示例#26
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;
  }
示例#27
0
 /**
  * Factory method which creates the <code>JMenuItem</code> for <code>Actions</code> added to the
  * <code>JPopupMenu</code>.
  *
  * @param a the <code>Action</code> for the menu item to be added
  * @return the new menu item
  * @see Action
  * @since 1.3
  */
 protected JMenuItem createActionComponent(Action a) {
   JMenuItem mi =
       new JMenuItem() {
         protected PropertyChangeListener createActionPropertyChangeListener(Action a) {
           PropertyChangeListener pcl = createActionChangeListener(this);
           if (pcl == null) {
             pcl = super.createActionPropertyChangeListener(a);
           }
           return pcl;
         }
       };
   mi.setHorizontalTextPosition(JButton.TRAILING);
   mi.setVerticalTextPosition(JButton.CENTER);
   return mi;
 }
示例#28
0
 public void addPictureGenerator(JMenu menu, final PictureGenerator gen) {
   JMenuItem item = new JMenuItem(gen.getMenuName());
   menu.add(item);
   item.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           pic2 = gen.picture();
           pic1 = new Picture(pic2.width(), pic2.height());
           lab.setIcon(pic2.getJLabel().getIcon());
           sliderPanel.setVisible(false);
           pack();
           repaint();
         }
       });
 }
示例#29
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();
          }
        });
  }
示例#30
0
 public void addFilter(JMenu menu, final ImageFilter f) {
   JMenuItem item = new JMenuItem(f.getMenuName());
   menu.add(item);
   item.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           swapImages();
           f.apply(pic1, pic2);
           lab.setIcon(pic2.getJLabel().getIcon());
           sliderPanel.setVisible(false);
           pack();
           repaint();
         }
       });
 }