예제 #1
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();
      }
    }
  }
  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);
          }
        }
      }
    }
  }
  private void addMenuItems(JMenu f, String m[]) {

    Dimension d = Toolkit.getDefaultToolkit().getScreenSize();

    for (int i = 0; i < m.length; i++) {
      if (m[i].equals("--")) {
        f.addSeparator();
      } else if (m[i].equals("---")) {

        // (ulrivo): full size on screen with less than 640 width
        if (d.width >= 640) {
          f.addSeparator();
        } else {
          return;
        }
      } else {
        JMenuItem item = new JMenuItem(m[i].substring(1));
        char c = m[i].charAt(0);

        if (c != '-') {
          item.setMnemonic(c);
        }

        item.addActionListener(this);
        f.add(item);
      }
    }
  }
예제 #4
0
  @Override
  public JPopupMenu getComponentPopupMenu() {
    if (popupMenu == null) {
      popupMenu = new JPopupMenu(Messages.CHART_COLON);
      timeRangeMenu = new JMenu(Messages.PLOTTER_TIME_RANGE_MENU);
      timeRangeMenu.setMnemonic(Resources.getMnemonicInt(Messages.PLOTTER_TIME_RANGE_MENU));
      popupMenu.add(timeRangeMenu);
      menuRBs = new JRadioButtonMenuItem[rangeNames.length];
      ButtonGroup rbGroup = new ButtonGroup();
      for (int i = 0; i < rangeNames.length; i++) {
        menuRBs[i] = new JRadioButtonMenuItem(rangeNames[i]);
        rbGroup.add(menuRBs[i]);
        menuRBs[i].addActionListener(this);
        if (viewRange == rangeValues[i]) {
          menuRBs[i].setSelected(true);
        }
        timeRangeMenu.add(menuRBs[i]);
      }

      popupMenu.addSeparator();

      saveAsMI = new JMenuItem(Messages.PLOTTER_SAVE_AS_MENU_ITEM);
      saveAsMI.setMnemonic(Resources.getMnemonicInt(Messages.PLOTTER_SAVE_AS_MENU_ITEM));
      saveAsMI.addActionListener(this);
      popupMenu.add(saveAsMI);
    }
    return popupMenu;
  }
  private void addToRecent(String s) {

    for (int i = 0; i < iMaxRecent; i++) {
      if (s.equals(sRecent[i])) {
        return;
      }
    }

    if (sRecent[iRecent] != null) {
      mRecent.remove(iRecent);
    }

    sRecent[iRecent] = s;

    if (s.length() > 43) {
      s = s.substring(0, 40) + "...";
    }

    JMenuItem item = new JMenuItem(s);

    item.setActionCommand("#" + iRecent);
    item.addActionListener(this);
    mRecent.insert(item, iRecent);

    iRecent = (iRecent + 1) % iMaxRecent;
  }
예제 #6
0
  void windowMenu_menuSelected(MenuEvent e) {
    // <<TODO:MAINTAINABILITY>> This algorithm is not robust. It assumes
    // the Window
    // menu has exactly one "regular" menu item (newWindowMenuItem). [Jon
    // Aquino]
    if (windowMenu.getItemCount() > 0
        && windowMenu.getItem(0) != null
        && windowMenu
            .getItem(0)
            .getText()
            .equals(AbstractPlugIn.createName(CloneWindowPlugIn.class))) {
      JMenuItem newWindowMenuItem = windowMenu.getItem(0);
      windowMenu.removeAll();
      windowMenu.add(newWindowMenuItem);
      windowMenu.addSeparator();
    } else {
      // ezLink doesn't have a Clone Window menu [Jon Aquino]
      windowMenu.removeAll();
    }

    // final TaskComponent[] frames = (TaskComponent[]) desktopPane.getAllFrames();
    final JInternalFrame[] frames = desktopPane.getAllFrames();
    for (int i = 0; i < frames.length; i++) {
      JMenuItem menuItem = new JMenuItem();
      // Increase truncation threshold from 20 to 40, for eziLink [Jon
      // Aquino]
      menuItem.setText(GUIUtil.truncateString(frames[i].getTitle(), 40));
      associate(menuItem, frames[i]);
      windowMenu.add(menuItem);
    }
    if (windowMenu.getItemCount() == 0) {
      // For ezLink [Jon Aquino]
      windowMenu.add(new JMenuItem("(No Windows)"));
    }
  }
예제 #7
0
 public void actionPerformed(ActionEvent e) {
   if (e.getSource() instanceof JMenuItem) {
     JMenuItem item = (JMenuItem) e.getSource();
     String name = item.getText();
     profiles.delete(name);
   }
 }
예제 #8
0
 private void addMenuItem(
     JMenu menu,
     String label,
     int mnemonic,
     String accessibleDescription,
     String actionCallbackName)
     throws NoSuchMethodException {
   JMenuItem menuItem = new JMenuItem(label, mnemonic);
   menuItem
       .getAccessibleContext()
       .setAccessibleDescription((accessibleDescription != null) ? accessibleDescription : label);
   final Method callback =
       getClass().getMethod(actionCallbackName, new Class[] {ActionEvent.class});
   menuItem.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           try {
             callback.invoke(WordListScreen.this, new Object[] {e});
           } catch (InvocationTargetException ex) {
             handleException(ex.getTargetException());
           } catch (IllegalAccessException ex) {
             handleException(ex);
           }
         }
       });
   menu.add(menuItem);
 }
예제 #9
0
    public void actionPerformed(ActionEvent e) {
      JTextField tf = getTextField();
      final String text = tf.getText();
      final int caretIndex = tf.getCaretPosition();
      String pre = text.substring(0, caretIndex);
      java.util.List<TreeNode> nodes = null; // m_root.search(pre);
      // Collections.sort(nodes);
      if (nodes.isEmpty()) {
        return;
      }

      JPopupMenu jp = new JPopupMenu("options");

      JMenuItem lastItem = null;
      for (TreeNode node : nodes) {
        String nodeName = node.toString();
        String insertion = nodeName.substring(leaf(pre, ".").length());
        lastItem = createInsertAction(nodeName, caretIndex, insertion);
        jp.add(lastItem);
      }
      if (nodes.size() == 0) {
        return;
      }
      if (nodes.size() == 1) {
        lastItem.getAction().actionPerformed(null);
      } else {
        Point pos = tf.getCaret().getMagicCaretPosition();
        pos = pos != null ? pos : new Point(2, 2);
        jp.show(tf, pos.x, pos.y);
      }
    }
예제 #10
0
  /** When a new set of saved statements come in, refresh the menu of saved statements. */
  private void refreshSaveMenu() {
    ArrayList list;
    // first, delete what's already there
    for (; ; ) {
      Component comp = popup.getComponent(1);
      if (!(comp instanceof JMenuItem)) break;

      JMenuItem item = (JMenuItem) comp;
      if (item.getActionCommand().startsWith("save:")) popup.remove(1);
      else break;
    }
    StatementHistory history;
    history = sshare.statementHistory();
    // now insert the new list of saved statements
    list = history.getNamedStatementList();
    Color bgColor = Util.getBgColor();
    for (int i = 0; i < list.size(); i++) {
      ArrayList nameNlabel = (ArrayList) list.get(i);
      JMenuItem item = new JMenuItem("  " + (String) nameNlabel.get(1));
      item.setActionCommand("save:" + (String) nameNlabel.get(0));
      popup.add(item, 1);
      //	    item.setBackground(bgColor);
      item.addActionListener(popActionListener);
    }
  } // refreshSaveMenu()
예제 #11
0
 private JMenuItem getJMenuItem3() {
   if (jMenuItem3 == null) {
     jMenuItem3 = new JMenuItem();
     jMenuItem3.setText("Solution");
     jMenuItem3.setMnemonic(java.awt.event.KeyEvent.VK_S);
     jMenuItem3.setAccelerator(
         javax.swing.KeyStroke.getKeyStroke(
             java.awt.event.KeyEvent.VK_S, java.awt.Event.CTRL_MASK, false));
     jMenuItem3.addActionListener(
         new java.awt.event.ActionListener() {
           public void actionPerformed(java.awt.event.ActionEvent e) {
             solution = true;
             current = new ArrayList<String>(correct);
             shuffle();
             getStatusLabel().setText("Correct solution.");
             // Change the buttons colors to green
             Iterator itr = buttons.iterator();
             while (itr.hasNext()) {
               ((JButton) itr.next()).setBackground(java.awt.Color.green);
             }
           }
         });
   }
   return jMenuItem3;
 }
예제 #12
0
파일: JImage.java 프로젝트: RussTedrake/lcm
  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);
  }
예제 #13
0
  public void actionPerformed(ActionEvent event) {
    JMenuItem source = (JMenuItem) (event.getSource());

    for (GraphView v : gp.getGraphViewList()) {
      if (v.getMenuText().equals(source.getText())) {
        v.view();
        repaint();
        return;
      }
    }

    for (GraphDrawer d : gp.getGraphDrawerList()) {
      if (d.getMenuText().equals(source.getText())) {
        d.layout();
        repaint();
        return;
      }
    }

    for (GraphUtility u : gp.getGraphUtilityList()) {
      if (u.getMenuText().equals(source.getText())) {
        u.apply();
        repaint();
        return;
      }
    }

    for (GraphExperiment ge : gp.getGraphExperimentList()) {
      if (ge.getMenuText().equals(source.getText())) {
        ge.experiment();
        repaint();
        return;
      }
    }
  }
  private void helpButtonActionPerformed(java.awt.event.ActionEvent evt) {
    JPopupMenu jp = new JPopupMenu();

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

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

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

    mi.setLayout(new BorderLayout());
    mi.setPreferredSize(panel.getPreferredSize());
    mi.setFocusPainted(false);
    mi.add(panel, BorderLayout.CENTER);
    jp.setLayout(new BorderLayout());
    jp.add(mi, BorderLayout.CENTER);
    jp.show(helpButton, -60, -60);
  }
예제 #15
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);
   }
 }
예제 #16
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());
         }
       });
 }
예제 #17
0
  /** Create menus */
  private JMenuBar createMenus() {
    JMenuItem mi;
    // ***** create the menubar ****
    menuBar = new JMenuBar();

    // ***** create File menu
    fileMenu = (JMenu) menuBar.add(new JMenu("File"));
    fileMenu.setMnemonic('F');
    createMenuItem(fileMenu, "Print", 'P', "", new PrintAction(this));
    createMenuItem(fileMenu, "Close", 'C', "", new CloseAction(this));
    fileMenu.add(new JSeparator());
    createMenuItem(fileMenu, "Exit", 'E', "", new ExitAction());

    // ***** create laf switcher menu
    lafMenu = (JMenu) menuBar.add(new JMenu("Look & Feel"));
    lafMenu.setMnemonic('L');

    mi = createLafMenuItem(lafMenu, "Java Look & Feel", 'J', "", metal);
    mi.setSelected(true); // this is the default l&f
    metalMenuItem = mi;

    createLafMenuItem(lafMenu, "Macintosh Look & Feel", 'M', "", mac);

    createLafMenuItem(lafMenu, "Motif Look & Feel", 'F', "", motif);

    createLafMenuItem(lafMenu, "Windows Look & Feel", 'W', "", windows);

    // ***** create themes menu
    themesMenu = (JMenu) menuBar.add(new JMenu("Themes"));
    themesMenu.setMnemonic('T');

    mi = createThemesMenuItem(themesMenu, "Default", 'D', "", new DefaultMetalTheme());
    mi.setSelected(true); // This is the default theme

    createThemesMenuItem(themesMenu, "Aqua", 'A', "", new AquaTheme());

    createThemesMenuItem(themesMenu, "Charcoal", 'C', "", new CharcoalTheme());

    createThemesMenuItem(themesMenu, "High Contrast", 'H', "", new ContrastTheme());

    createThemesMenuItem(themesMenu, "Emerald", 'E', "", new EmeraldTheme());

    createThemesMenuItem(themesMenu, "Ruby", 'R', "", new RubyTheme());

    createThemesMenuItem(themesMenu, "Presentation", 'P', "", new DemoMetalTheme());

    createThemesMenuItem(themesMenu, "Sandstone", 'S', "", new KhakiMetalTheme());

    createThemesMenuItem(themesMenu, "Big High Contrast", 'I', "", new BigContrastMetalTheme());

    createThemesMenuItem(themesMenu, "Blue", 'B', "", new BlueTheme());

    createThemesMenuItem(themesMenu, "Cougaar", 'O', "", new CougaarTheme());

    createThemesMenuItem(
        themesMenu, "Cougaar Presentation", 'O', "", new CougaarPresentationTheme());

    return menuBar;
  }
  /** Display the forwards window history in a menu. */
  private void onShowForwardHistory() {

    UIScrollableMenu hist =
        new UIScrollableMenu(
            LanguageProperties.getString(
                LanguageProperties.TOOLBARS_BUNDLE, "UIToolBarMain.forwardHistory"),
            0); //$NON-NLS-1$

    Vector views = history.getForwardHistory();
    int currentIndex = history.getCurrentPosition();

    int count = views.size();
    if (count == 0) return;

    JMenuItem item = null;
    for (int i = 0; i < count; i++) {
      View view = (View) views.elementAt(i);
      item = new JMenuItem(view.getLabel());

      final View fview = view;
      final int fi = (currentIndex + 1) + i;
      item.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent event) {
              if (history.goToHistoryItem(fi)) oParent.addViewToDesktop(fview, fview.getLabel());
            }
          });

      hist.add(item);
    }

    JPopupMenu pop = hist.getPopupMenu();
    pop.pack();

    Point loc = pbShowForwardHistory.getLocation();
    Dimension size = pbShowForwardHistory.getSize();
    Dimension popsize = hist.getPreferredSize();
    Point finalP = SwingUtilities.convertPoint(tbrToolBar.getParent(), loc, oParent.getDesktop());

    int x = 0;
    int y = 0;
    if (oManager.getLeftToolBarController().containsBar(tbrToolBar)) {
      x = finalP.x + size.width;
      y = finalP.y;
    } else if (oManager.getRightToolBarController().containsBar(tbrToolBar)) {
      x = finalP.x - popsize.width;
      y = finalP.y;
    } else if (oManager.getTopToolBarController().containsBar(tbrToolBar)) {
      x = finalP.x;
      y = finalP.y + size.width;
    } else if (oManager.getBottomToolBarController().containsBar(tbrToolBar)) {
      x = finalP.x;
      y = finalP.y - popsize.height;
    }

    hist.setPopupMenuVisible(true);
    pop.show(oParent.getDesktop(), x, y);
  }
예제 #19
0
  protected void openPopupMenu(TrackClickEvent te, List<Component> extraItems) {
    MouseEvent e = te.getMouseEvent();

    Collection<Track> selectedTracks = getSelectedTracks();
    if (selectedTracks.size() == 0) {
      return;
    }

    IGVPopupMenu menu = null;

    // If a single track is selected, give it an opportunity to provide the popup menu
    if (selectedTracks.size() == 1) {
      Track track = selectedTracks.iterator().next();
      menu = track.getPopupMenu(te);
    }

    // If still no menu, create a generic one with common items
    if (menu == null) {
      String title = getPopupMenuTitle(e.getX(), e.getY());
      menu = TrackMenuUtils.getPopupMenu(selectedTracks, title, te);
    }

    // Add additional items, if any
    if (extraItems != null) {
      menu.addSeparator();
      for (Component item : extraItems) {
        menu.add(item);
      }
    }

    // Add saveImage
    menu.addSeparator();
    JMenuItem item = new JMenuItem("Save image...");
    item.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            saveImage();
          }
        });
    menu.add(item);

    if (menu != null) {
      menu.addPopupMenuListener(
          new PopupMenuListener() {
            public void popupMenuWillBecomeVisible(PopupMenuEvent popupMenuEvent) {}

            public void popupMenuWillBecomeInvisible(PopupMenuEvent popupMenuEvent) {
              clearTrackSelections();
            }

            public void popupMenuCanceled(PopupMenuEvent popupMenuEvent) {
              clearTrackSelections();
            }
          });
      menu.show(e.getComponent(), e.getX(), e.getY());
    }
  }
예제 #20
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);
      }
    }
예제 #21
0
 public void handleUI() {
   DarkMod darkMod = DarkMod.getInstance();
   DarkModUI ui = darkMod.getUI();
   JButton screenshotButton = ui.getScreenshotButton();
   screenshotButton.setEnabled(true);
   if (!darkMod.isPlayingOffline()) {
     JMenuItem newSessionIDItem = ui.getNewSessionIDItem();
     newSessionIDItem.setEnabled(true);
   }
 }
 @Override
 public void setProfiler(Profiler profiler) {
   if (profiler != null) {
     profilerWindow = new ProfilerWindow(profiler);
     profilerMenuItem.setEnabled(true);
   } else {
     profilerWindow = null;
     profilerMenuItem.setEnabled(false);
   }
 }
예제 #23
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()
예제 #24
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());
   }
 }
예제 #25
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()
예제 #26
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);
   }
 }
예제 #27
0
  private void showContextMenu(JList characterList, MouseEvent mouseEvent) {
    // TODO: handle right-click outside of selected range correctly (should treat as single
    // selection, but not deselect)
    boolean multipleSelected = herolabsCharacterList.getSelectedValues().length > 1;
    if (mouseEvent.isPopupTrigger() && mouseEvent.getClickCount() == 1) {
      if (!multipleSelected) {
        herolabsCharacterList.setSelectedIndex(
            herolabsCharacterList.locationToIndex(mouseEvent.getPoint()));
      }

      if (contextMenuEnabled) {
        JPopupMenu menu = new JPopupMenu();
        JMenuItem menuItem;

        menuItem = new JMenuItem("Configure character" + (multipleSelected ? "s" : "") + "...");
        menuItem.addActionListener(
            new ActionListener() {
              public void actionPerformed(ActionEvent actionEvent) {
                configureSelectedCharacters();
              }
            });
        menu.add(menuItem);

        menuItem = new JMenuItem("Configure using portfolio defaults");
        menuItem.addActionListener(
            new ActionListener() {
              public void actionPerformed(ActionEvent actionEvent) {
                resetToDefaultsForSelectedCharacters();
              }
            });
        menu.add(menuItem);

        menuItem = new JMenuItem("Export character" + (multipleSelected ? "s" : ""));
        menuItem.addActionListener(
            new ActionListener() {
              public void actionPerformed(ActionEvent actionEvent) {
                exportSelectedCharacters();
              }
            });
        menu.add(menuItem);

        menuItem = new JMenuItem("Clear configuration" + (multipleSelected ? "s" : ""));
        menuItem.addActionListener(
            new ActionListener() {
              public void actionPerformed(ActionEvent actionEvent) {
                clearConfigForSelectedCharacters();
              }
            });
        menu.add(menuItem);

        menu.show(characterList, mouseEvent.getX(), mouseEvent.getY());
      }
    }
  }
예제 #28
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);
   }
 }
  public void go() {
    frame = new JFrame("Quiz Card Player");
    JPanel mainPanel = new JPanel();
    Font bigFont = new Font("sanserif", Font.BOLD, 24);

    display = new JTextArea(10, 20);
    display.setFont(bigFont);
    display.setLineWrap(true);
    display.setEditable(false);

    JScrollPane qScroller = new JScrollPane(display);
    qScroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    qScroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);

    nextButton = new JButton("Show Questions");
    nextButton.addActionListener(new NextCardListener());

    mainPanel.add(qScroller);
    mainPanel.add(nextButton);

    JMenuBar menuBar = new JMenuBar();
    JMenu fileMenu = new JMenu("File");
    JMenuItem loadMenuItem = new JMenuItem("Load Card Set");
    loadMenuItem.addActionListener(new OpenMenuListener());
    fileMenu.add(loadMenuItem);
    menuBar.add(fileMenu);

    frame.setJMenuBar(menuBar);
    frame.getContentPane().add(BorderLayout.CENTER, mainPanel);
    frame.setSize(640, 500);
    frame.setVisible(true);
  }
예제 #30
-1
  public void go() {
    // build gui

    frame = new JFrame("Quiz Card Buider");
    JPanel mainPanel = new JPanel();
    Font bigFont = new Font("sanserif", Font.BOLD, 24);
    question = new JTextArea(6, 20);
    question.setLineWrap(true);
    question.setWrapStyleWord(true);
    question.setFont(bigFont);

    JScrollPane qScroller = new JScrollPane(question);
    qScroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    qScroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

    answer = new JTextArea(6, 20);
    answer.setLineWrap(true);
    answer.setWrapStyleWord(true);
    answer.setFont(bigFont);

    JScrollPane aScroller = new JScrollPane(question);
    aScroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    aScroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

    JButton nextButton = new JButton("Next Card");

    cardList = new ArrayList<QuizCard>();

    JLabel qLabel = new JLabel("Question");
    JLabel aLabel = new JLabel("Answer");

    mainPanel.add(qLabel);
    mainPanel.add(qScroller);
    mainPanel.add(aLabel);
    mainPanel.add(aScroller);
    mainPanel.add(nextButton);

    nextButton.addActionListener(new NextCardListener());

    JMenuBar menuBar = new JMenuBar();

    JMenu fileMenu = new JMenu("File");

    JMenuItem newMenuItem = new JMenuItem("New");
    JMenuItem saveMenuItem = new JMenuItem("Save");
    newMenuItem.addActionListener(new NewMenuListener());
    saveMenuItem.addActionListener(new SaveMenuListener());

    fileMenu.add(newMenuItem);
    fileMenu.add(saveMenuItem);
    menuBar.add(fileMenu);
    frame.setJMenuBar(menuBar);
    frame.getContentPane().add(BorderLayout.CENTER, mainPanel);
    frame.setSize(500, 600);
    frame.setVisible(true);
    // frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

  }