Example #1
0
    public ManagerPopupMenu() {
      jPopupMenu = new JPopupMenu();
      Font font = new Font("Verdana", Font.PLAIN, 12);

      JMenuItem jFormProviderOrderItem = new JMenuItem("Отменить заказ");
      jFormProviderOrderItem.setFont(font);
      jFormProviderOrderItem.addActionListener(e -> ClientWindow.this.cancelClientOrder());
      jPopupMenu.add(jFormProviderOrderItem);
      jPopupMenu.addSeparator();
      JMenuItem jPay25OrderItem = new JMenuItem("Оплатить часть заказа");
      jPay25OrderItem.addActionListener(
          e ->
              ClientWindow.this.pay25Order(
                  ((DefaultMutableTreeNode) e.getSource()).getUserObject().toString()));
      jPay25OrderItem.setFont(font);
      jPopupMenu.add(jPay25OrderItem);
      jPopupMenu.addSeparator();
      JMenuItem jPayFullOrderItem = new JMenuItem("Оплатить весь заказ");
      jPayFullOrderItem.addActionListener(
          e ->
              ClientWindow.this.payFullOrder(
                  ((DefaultMutableTreeNode) e.getSource()).getUserObject().toString()));
      jPayFullOrderItem.setFont(font);
      jPopupMenu.add(jPayFullOrderItem);
    }
  public void createPopupMenu() {
    super.createPopupMenu();

    JPopupMenu popupMenu = getPopupMenu();
    if (popupMenu == null) {
      popupMenu = new JPopupMenu();
      setPopupMenu(popupMenu);
    } else {
      popupMenu.addSeparator();
    }

    propertiesItem = new JMenuItem("Properties ...");

    propertiesItem.addActionListener(this);
    propertiesItem.setMnemonic('s');
    popupMenu.add(propertiesItem);

    popupMenu.addSeparator();
    ButtonGroup group = new ButtonGroup();
    inItem = new JRadioButtonMenuItem("IN");
    group.add(inItem);
    inItem.addActionListener(this);
    popupMenu.add(inItem);
    outItem = new JRadioButtonMenuItem("OUT");
    group.add(outItem);
    outItem.addActionListener(this);
    popupMenu.add(outItem);
    inoutItem = new JRadioButtonMenuItem("INOUT");
    group.add(inoutItem);
    inoutItem.addActionListener(this);
    popupMenu.add(inoutItem);
  }
  private JPopupMenu fillMenu(boolean under) {
    final JPopupMenu result = new JBPopupMenu();

    if (under && myOptions.length > 0) {
      final JMenuItem mainAction = new JBMenuItem(getAction());
      configureItem(getMenuInfo(getAction()), mainAction);
      result.add(mainAction);
      result.addSeparator();
    }

    for (Action each : myOptions) {
      if (getAction() == each) continue;
      final OptionInfo info = getMenuInfo(each);
      final JMenuItem eachItem = new JBMenuItem(each);

      configureItem(info, eachItem);
      result.add(eachItem);
    }

    if (!under && myOptions.length > 0) {
      result.addSeparator();
      final JMenuItem mainAction = new JBMenuItem(getAction());
      configureItem(getMenuInfo(getAction()), mainAction);
      result.add(mainAction);
    }

    return result;
  }
  // inherit doc comment
  protected JPopupMenu createPopupMenu() {
    if (TABLE.getSelectionModel().isSelectionEmpty()) {
      return null;
    }

    JPopupMenu menu = new SkinPopupMenu();

    menu.add(new SkinMenuItem(LAUNCH_ACTION));
    if (getMediaType().equals(MediaType.getAudioMediaType())) {
      menu.add(new SkinMenuItem(LAUNCH_OS_ACTION));
    }
    if (hasExploreAction()) {
      menu.add(new SkinMenuItem(OPEN_IN_FOLDER_ACTION));
    }

    if (areAllSelectedFilesMP4s()) {
      menu.add(DEMUX_MP4_AUDIO_ACTION);
      DEMUX_MP4_AUDIO_ACTION.setEnabled(
          !((DemuxMP4AudioAction) DEMUX_MP4_AUDIO_ACTION).isDemuxing());
    }

    menu.add(new SkinMenuItem(CREATE_TORRENT_ACTION));

    if (areAllSelectedFilesPlayable()) {
      menu.add(createAddToPlaylistSubMenu());
    }

    menu.add(new SkinMenuItem(SEND_TO_FRIEND_ACTION));
    menu.add(new SkinMenuItem(SEND_TO_ITUNES_ACTION));

    menu.addSeparator();
    menu.add(new SkinMenuItem(DELETE_ACTION));
    menu.addSeparator();

    int[] rows = TABLE.getSelectedRows();
    boolean dirSelected = false;
    boolean fileSelected = false;

    for (int i = 0; i < rows.length; i++) {
      File f = DATA_MODEL.get(rows[i]).getFile();
      if (f.isDirectory()) {
        dirSelected = true;
        //				if (IncompleteFileManager.isTorrentFolder(f))
        //					torrentSelected = true;
      } else fileSelected = true;

      if (dirSelected && fileSelected) break;
    }

    DELETE_ACTION.setEnabled(true);
    LibraryFilesTableDataLine line = DATA_MODEL.get(rows[0]);
    menu.add(createSearchSubMenu(line));
    return menu;
  }
Example #5
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;
  }
  /** Adds the menu represented by the node */
  private void addVisualMenu(RADMenuItemComponent comp) {
    Object o = getBeanInstance();
    Object m = comp.getBeanInstance();
    Object dto = getDesignTimeMenus(getFormManager()).getDesignTime(o);
    Object dtm = getDesignTimeMenus(getFormManager()).getDesignTime(m);

    switch (getMenuItemType()) {
      case T_MENUBAR:
        ((MenuBar) o).add((Menu) m);
        ((JMenuBar) dto).add((JMenu) dtm);
        ((JMenuBar) dto).validate();
        break;
      case T_MENU:
        if (comp.getMenuItemType() == T_SEPARATOR) {
          ((Menu) o).addSeparator();
          ((JMenu) dto).addSeparator();
        } else {
          ((Menu) o).add((MenuItem) m);
          ((JMenu) dto).add((JMenuItem) dtm);
        }
        break;
      case T_POPUPMENU:
        if (comp.getMenuItemType() == T_SEPARATOR) {
          ((Menu) o).addSeparator();
          ((JMenu) dto).addSeparator();
        } else {
          ((Menu) o).add((MenuItem) m);
          ((JPopupMenu) dto).add((JMenuItem) dtm);
        }
        break;
      case T_JMENUBAR:
        ((JMenuBar) o).add((JMenu) m);
        ((JMenuBar) o).validate();
        break;
      case T_JMENU:
        if (comp.getMenuItemType() == T_JSEPARATOR) {
          ((JMenu) o).addSeparator();
        } else {
          ((JMenu) o).add((JMenuItem) m);
        }
        break;
      case T_JPOPUPMENU:
        if (comp.getMenuItemType() == T_JSEPARATOR) {
          ((JPopupMenu) o).addSeparator();
        } else {
          ((JPopupMenu) o).add((JMenuItem) m);
        }
        break;
    }
  }
  @Override
  public JPopupMenu initLogviewPopupMenu() {
    JPopupMenu menu = super.initLogviewPopupMenu();

    menu.addSeparator();
    addMenuItem(menu, FIND);
    addMenuItem(menu, FINDNEXT);
    addMenuItem(menu, FINDPREVIOUS);

    menu.addSeparator();
    addMenuItem(menu, VIEWHELP);
    addMenuItem(menu, VIEWSOURCE);

    menu.addSeparator();
    addMenuItem(menu, STOPEVAL);

    JMenu historymenu = (JMenu) menu.getClientProperty(HISTORYMENU);

    addMenuItem(historymenu, LOADHISTORY);
    addMenuItem(historymenu, SAVEHISTORY);

    return menu;
  }
  protected JPopupMenu buildSystemTrayJPopupMenu(Stage primaryStage)
      throws ClassNotFoundException, UnsupportedLookAndFeelException, InstantiationException,
          IllegalAccessException {
    final JPopupMenu menu = new JPopupMenu();
    final JMenuItem showMenuItem = new JMenuItem("Show");
    final JMenuItem exitMenuItem = new JMenuItem("Exit");

    menu.add(showMenuItem);
    menu.addSeparator();
    menu.add(exitMenuItem);
    showMenuItem.addActionListener(ae -> Platform.runLater(primaryStage::show));
    exitMenuItem.addActionListener(ae -> System.exit(0));

    return menu;
  }
Example #9
0
  /** Code completion. */
  private void complete() {
    if (selected()) return;

    // find first character
    final int caret = editor.pos(), startPos = editor.completionStart();
    final String prefix = string(substring(editor.text(), startPos, caret));
    if (prefix.isEmpty()) return;

    // find insertion candidates
    final TreeMap<String, String> tmp = new TreeMap<>();
    for (final Entry<String, String> entry : REPLACE.entrySet()) {
      final String key = entry.getKey();
      if (key.startsWith(prefix)) tmp.put(key, entry.getValue());
    }

    if (tmp.size() == 1) {
      // insert single candidate
      complete(tmp.values().iterator().next(), startPos);
    } else if (!tmp.isEmpty()) {
      // show popup menu
      final JPopupMenu pm = new JPopupMenu();
      final ActionListener al =
          new ActionListener() {
            @Override
            public void actionPerformed(final ActionEvent ae) {
              complete(ae.getActionCommand().replaceAll("^.*?\\] ", ""), startPos);
            }
          };

      for (final Entry<String, String> entry : tmp.entrySet()) {
        final JMenuItem mi = new JMenuItem("[" + entry.getKey() + "] " + entry.getValue());
        pm.add(mi);
        mi.addActionListener(al);
      }
      pm.addSeparator();
      final JMenuItem mi = new JMenuItem(Text.INPUT + Text.COLS + prefix);
      mi.setEnabled(false);
      pm.add(mi);

      final int[] cursor = rend.cursor();
      pm.show(this, cursor[0], cursor[1]);

      // highlight first entry
      final MenuElement[] me = {pm, (JMenuItem) pm.getComponent(0)};
      MenuSelectionManager.defaultManager().setSelectedPath(me);
    }
  }
Example #10
0
  public MainPanel() {
    super(new BorderLayout());
    pop.add(new NewTabAction("Add", null));
    pop.addSeparator();
    pop.add(new CloseAllAction("Close All", null));
    tabbedPane.setComponentPopupMenu(pop);
    tabbedPane.addTab("aaaaaa", new JScrollPane(new JTree()));
    tabbedPane.addTab("12345678901234567890", new JScrollPane(new JLabel("asdfasdfsadf")));
    tabbedPane.addTab("b", new JScrollPane(new JTree()));

    //         tab.setSelectedIndex(0);
    //         TabPanel titleTab = (TabPanel) tab.getTabComponentAt(0);
    //         titleTab.setButtonVisible(true);

    add(tabbedPane);
    setPreferredSize(new Dimension(320, 240));
  }
  void constructComponent() {
    setLayout(new BorderLayout());

    m_popupMenu = new JPopupMenu();
    mi_add = new JMenuItem("Add...");
    mi_add.addActionListener(this);
    m_popupMenu.add(mi_add);
    mi_edit = new JMenuItem("Edit...");
    mi_edit.addActionListener(this);
    m_popupMenu.add(mi_edit);
    mi_delete = new JMenuItem("Delete");
    mi_delete.addActionListener(this);
    m_popupMenu.addSeparator();
    m_popupMenu.add(mi_delete);

    m_tree = new OrganizationTree(m_conn, m_sessionid);
    m_tree.addMouseListener(new TreeMouseAdapter());

    add(new JScrollPane(m_tree), BorderLayout.CENTER);
  }
Example #12
0
  /** initializes the popup menus */
  private void initPopupMenus() {
    // header popup
    m_PopupHeader = new JPopupMenu();
    m_PopupHeader.addMouseListener(this);
    m_PopupHeader.add(menuItemMean);
    if (!isReadOnly()) {
      m_PopupHeader.addSeparator();
      m_PopupHeader.add(menuItemSetAllValues);
      m_PopupHeader.add(menuItemSetMissingValues);
      m_PopupHeader.add(menuItemReplaceValues);
      m_PopupHeader.addSeparator();
      m_PopupHeader.add(menuItemRenameAttribute);
      m_PopupHeader.add(menuItemAttributeAsClass);
      m_PopupHeader.add(menuItemDeleteAttribute);
      m_PopupHeader.add(menuItemDeleteAttributes);
      m_PopupHeader.add(menuItemSortInstances);
    }
    m_PopupHeader.addSeparator();
    m_PopupHeader.add(menuItemOptimalColWidth);
    m_PopupHeader.add(menuItemOptimalColWidths);

    // row popup
    m_PopupRows = new JPopupMenu();
    m_PopupRows.addMouseListener(this);
    if (!isReadOnly()) {
      m_PopupRows.add(menuItemUndo);
      m_PopupRows.addSeparator();
    }
    m_PopupRows.add(menuItemCopy);
    m_PopupRows.addSeparator();
    m_PopupRows.add(menuItemSearch);
    m_PopupRows.add(menuItemClearSearch);
    if (!isReadOnly()) {
      m_PopupRows.addSeparator();
      m_PopupRows.add(menuItemDeleteSelectedInstance);
      m_PopupRows.add(menuItemDeleteAllSelectedInstances);
    }
  }
  private void addAdhocPacketPanel() {
    // Create UI elements for sending ad-hoc messages.
    final JTextArea adhocMessages = new JTextArea();
    adhocMessages.setEditable(true);
    adhocMessages.setForeground(new Color(1, 94, 35));
    tabbedPane.add("Ad-hoc message", new JScrollPane(adhocMessages));
    tabbedPane.setToolTipTextAt(3, "Panel that allows you to send adhoc packets");

    // Add pop-up menu.
    JPopupMenu menu = new JPopupMenu();
    JMenuItem menuItem = new JMenuItem("Message");
    menuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            adhocMessages.setText(
                "<message to=\"\" id=\""
                    + StringUtils.randomString(5)
                    + "-X\"><body></body></message>");
          }
        });
    menu.add(menuItem);

    menuItem = new JMenuItem("IQ Get");
    menuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            adhocMessages.setText(
                "<iq type=\"get\" to=\"\" id=\""
                    + StringUtils.randomString(5)
                    + "-X\"><query xmlns=\"\"></query></iq>");
          }
        });
    menu.add(menuItem);

    menuItem = new JMenuItem("IQ Set");
    menuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            adhocMessages.setText(
                "<iq type=\"set\" to=\"\" id=\""
                    + StringUtils.randomString(5)
                    + "-X\"><query xmlns=\"\"></query></iq>");
          }
        });
    menu.add(menuItem);

    menuItem = new JMenuItem("Presence");
    menuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            adhocMessages.setText(
                "<presence to=\"\" id=\"" + StringUtils.randomString(5) + "-X\"/>");
          }
        });
    menu.add(menuItem);
    menu.addSeparator();

    menuItem = new JMenuItem("Send");
    menuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (!"".equals(adhocMessages.getText())) {
              AdHocPacket packetToSend = new AdHocPacket(adhocMessages.getText());
              connection.sendPacket(packetToSend);
            }
          }
        });
    menu.add(menuItem);

    menuItem = new JMenuItem("Clear");
    menuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            adhocMessages.setText(null);
          }
        });
    menu.add(menuItem);

    // Add listener to the text area so the popup menu can come up.
    adhocMessages.addMouseListener(new PopupListener(menu));
  }
Example #14
0
    /**
     * Popup the menu for the instances.
     *
     * @param component the component
     * @param x mouse X
     * @param y mouse Y
     * @param selected the selected instance, possibly null
     */
    private void popupInstanceMenu(Component component, int x, int y, final Instance selected) {
        JPopupMenu popup = new JPopupMenu();
        JMenuItem menuItem;

        if (selected != null) {
            menuItem = new JMenuItem(!selected.isLocal() ? _("instance.install") : _("instance.launch"));
            menuItem.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    launch();
                }
            });
            popup.add(menuItem);

            if (selected.isLocal()) {
                popup.addSeparator();

                menuItem = new JMenuItem(_("instance.openFolder"));
                menuItem.addActionListener(ActionListeners.browseDir(
                        LauncherFrame.this, selected.getContentDir(), true));
                popup.add(menuItem);

                menuItem = new JMenuItem(_("instance.openSaves"));
                menuItem.addActionListener(ActionListeners.browseDir(
                        LauncherFrame.this, new File(selected.getContentDir(), "saves"), true));
                popup.add(menuItem);

                menuItem = new JMenuItem(_("instance.openResourcePacks"));
                menuItem.addActionListener(ActionListeners.browseDir(
                        LauncherFrame.this, new File(selected.getContentDir(), "resourcepacks"), true));
                popup.add(menuItem);

                menuItem = new JMenuItem(_("instance.openScreenshots"));
                menuItem.addActionListener(ActionListeners.browseDir(
                        LauncherFrame.this, new File(selected.getContentDir(), "screenshots"), true));
                popup.add(menuItem);

                menuItem = new JMenuItem(_("instance.copyAsPath"));
                menuItem.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        File dir = selected.getContentDir();
                        dir.mkdirs();
                        SwingHelper.setClipboard(dir.getAbsolutePath());
                    }
                });
                popup.add(menuItem);

                popup.addSeparator();

                if (!selected.isUpdatePending()) {
                    menuItem = new JMenuItem(_("instance.forceUpdate"));
                    menuItem.addActionListener(new ActionListener() {
                        @Override
                        public void actionPerformed(ActionEvent e) {
                            selected.setUpdatePending(true);
                            launch();
                            instancesModel.update();
                        }
                    });
                    popup.add(menuItem);
                }

                menuItem = new JMenuItem(_("instance.hardForceUpdate"));
                menuItem.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        confirmHardUpdate(selected);
                    }
                });
                popup.add(menuItem);

                menuItem = new JMenuItem(_("instance.deleteFiles"));
                menuItem.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        confirmDelete(selected);
                    }
                });
                popup.add(menuItem);
            }

            popup.addSeparator();
        }

        menuItem = new JMenuItem(_("launcher.refreshList"));
        menuItem.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                loadInstances();
            }
        });
        popup.add(menuItem);

        popup.show(component, x, y);

    }
 private void jbInit() throws Exception {
   ////////////////////////////////////////////////////////
   // Init LAF
   ////////////////////////////////////////////////////////
   ButtonGroup grpLAF = new ButtonGroup();
   ActionListener lsnLAF =
       new ActionListener() {
         public void actionPerformed(ActionEvent evt) {
           int iIndex = mvtLAFItem.indexOf(evt.getSource());
           if (iIndex >= 0) changeLAF(iIndex);
         }
       };
   ////////////////////////////////////////////////////////
   UIManager.LookAndFeelInfo laf =
       new UIManager.LookAndFeelInfo(
           "Kunststoff", "com.incors.plaf.kunststoff.KunststoffLookAndFeel");
   marrLaf = UIManager.getInstalledLookAndFeels();
   int iIndex = 0;
   while (iIndex < marrLaf.length && !marrLaf[iIndex].getName().equals(laf.getName())) iIndex++;
   if (iIndex >= marrLaf.length) {
     UIManager.installLookAndFeel(laf);
     marrLaf = UIManager.getInstalledLookAndFeels();
   }
   for (iIndex = 0; iIndex < marrLaf.length; iIndex++) {
     JMenuItem mnu = new JRadioButtonMenuItem(marrLaf[iIndex].getName());
     mnu.addActionListener(lsnLAF);
     mvtLAFItem.addElement(mnu);
     mnuUI.add(mnu);
     grpLAF.add(mnu);
   }
   mnuUI.addSeparator();
   ////////////////////////////////////////////////////////
   // Init language
   ////////////////////////////////////////////////////////
   ButtonGroup grpLanguage = new ButtonGroup();
   ActionListener lsnLanguage =
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           int iIndex = mvtLanguageItem.indexOf(e.getSource());
           if (iIndex >= 0) changeDictionary((String) mvtLanguage.elementAt(iIndex));
         }
       };
   ////////////////////////////////////////////////////////
   String[] str = MonitorDictionary.getSupportedLanguage();
   for (iIndex = 0; iIndex < str.length; iIndex++) {
     JMenuItem mnu =
         new JRadioButtonMenuItem(MonitorDictionary.getDictionary(str[iIndex]).getLanguage());
     mnu.addActionListener(lsnLanguage);
     mvtLanguage.addElement(str[iIndex]);
     mvtLanguageItem.addElement(mnu);
     mnuUI.add(mnu);
     grpLanguage.add(mnu);
   }
   ////////////////////////////////////////////////////////
   // Add to main menu
   ////////////////////////////////////////////////////////
   mnuMain.removeAll();
   mnuMain.add(mnuSystem);
   mnuSystem.add(mnuSystem_Login);
   mnuSystem.add(mnuSystem_ChangePassword);
   mnuSystem.addSeparator();
   mnuSystem.add(mnuSystem_StopServer);
   mnuSystem.add(mnuSystem_EnableThreads);
   mnuMain.add(mnuUI);
   mnuMain.add(mnuHelp);
   mnuHelp.add(mnuHelp_About);
   ////////////////////////////////////////////////////////
   mnuMain.add(chkVietnamese);
   mnuMain.add(lblStatus);
   ////////////////////////////////////////////////////////
   pnlThread.setTabPlacement(JTabbedPane.LEFT);
   pnlThread.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
   ////////////////////////////////////////////////////////
   tblUser.addColumn("", 1, false);
   tblUser.addColumn("", 2, false, Global.FORMAT_DATE_TIME);
   tblUser.addColumn("", 3, false);
   ////////////////////////////////////////////////////////
   JPanel pnlMessage = new JPanel();
   pnlMessage.setLayout(new GridBagLayout());
   pnlMessage.add(
       new JScrollPane(txtBoard),
       new GridBagConstraints(
           0,
           0,
           2,
           1,
           1.0,
           1.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.BOTH,
           new Insets(2, 2, 2, 2),
           0,
           0));
   pnlMessage.add(
       txtMessage,
       new GridBagConstraints(
           0,
           1,
           1,
           1,
           1.0,
           0.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.BOTH,
           new Insets(2, 2, 2, 2),
           0,
           0));
   pnlMessage.add(
       btnSend,
       new GridBagConstraints(
           1,
           1,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.NONE,
           new Insets(2, 2, 2, 2),
           0,
           0));
   txtBoard.setEditable(false);
   txtBoard.setAutoscrolls(true);
   txtBoard.setContentType("text/html");
   clearAll(txtBoard);
   ////////////////////////////////////////////////////////
   JPanel pnlUserButton = new JPanel(new GridLayout(1, 2, 4, 4));
   pnlUserButton.add(btnKick);
   pnlUserButton.add(btnRefresh);
   ////////////////////////////////////////////////////////
   JPanel pnlManager = new JPanel(new GridBagLayout());
   pnlManager.add(
       new JScrollPane(tblUser),
       new GridBagConstraints(
           0,
           0,
           1,
           1,
           1.0,
           1.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.BOTH,
           new Insets(2, 2, 2, 2),
           0,
           0));
   pnlManager.add(
       pnlUserButton,
       new GridBagConstraints(
           0,
           1,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.NONE,
           new Insets(4, 2, 4, 2),
           0,
           0));
   ////////////////////////////////////////////////////////
   pnlUser.setDividerLocation(320);
   pnlUser.setLeftComponent(pnlManager);
   pnlUser.setRightComponent(pnlMessage);
   pnlUser.setOneTouchExpandable(true);
   ////////////////////////////////////////////////////////
   setOrientation(JSplitPane.VERTICAL_SPLIT);
   setOneTouchExpandable(true);
   pnlThread.setVisible(false);
   pnlUser.setVisible(false);
   setTopComponent(pnlThread);
   setBottomComponent(pnlUser);
   ////////////////////////////////////////////////////////
   pmn.add(mnuSelectAll);
   pmn.addSeparator();
   pmn.add(mnuClearSelected);
   pmn.add(mnuClearAll);
   ////////////////////////////////////////////////////////
   setBorder(BorderFactory.createEmptyBorder());
   pnlUser.setBorder(BorderFactory.createEmptyBorder());
   pnlManager.setBorder(
       BorderFactory.createBevelBorder(
           javax.swing.border.BevelBorder.RAISED,
           Color.white,
           UIManager.getColor("Panel.background"),
           UIManager.getColor("Panel.background"),
           UIManager.getColor("Panel.background")));
   pnlMessage.setBorder(
       BorderFactory.createBevelBorder(
           javax.swing.border.BevelBorder.RAISED,
           Color.white,
           UIManager.getColor("Panel.background"),
           UIManager.getColor("Panel.background"),
           UIManager.getColor("Panel.background")));
   ////////////////////////////////////////////////////////
   Skin.applySkin(mnuMain);
   Skin.applySkin(tblUser);
   Skin.applySkin(pmn);
   Skin.applySkin(this);
   ////////////////////////////////////////////////////////
   // Default setting
   ////////////////////////////////////////////////////////
   Hashtable prt = null;
   try {
     prt = Global.loadHashtable(Global.FILE_CONFIG);
   } catch (Exception e) {
     prt = new Hashtable();
   }
   changeLAF(Integer.parseInt(StringUtil.nvl(prt.get("LAF"), "0")));
   changeDictionary(StringUtil.nvl(prt.get("Language"), "VN"));
   Skin.LANGUAGE_CHANGE_LISTENER = this;
   MonitorProcessor.setRootObject(this);
   updateKeyboardUI();
   ////////////////////////////////////////////////////////
   // Event handler
   ////////////////////////////////////////////////////////
   tblUser.addMouseListener(
       new MouseAdapter() {
         public void mouseClicked(MouseEvent e) {
           if (e.getClickCount() > 1) btnKick.doClick();
         }
       });
   ////////////////////////////////////////////////////////
   btnRefresh.addActionListener(
       new java.awt.event.ActionListener() {
         public void actionPerformed(ActionEvent evt) {
           try {
             DDTP request = new DDTP();
             request.setRequestID(String.valueOf(System.currentTimeMillis()));
             DDTP response = channel.sendRequest("ThreadProcessor", "queryUserList", request);
             if (response != null) {
               tblUser.setData((Vector) response.getReturn());
               if (mstrChannel != null) removeUser(mstrChannel);
             }
           } catch (Exception e) {
             e.printStackTrace();
             MessageBox.showMessageDialog(pnlThread, e, Global.APP_NAME, MessageBox.ERROR_MESSAGE);
           }
         }
       });
   ////////////////////////////////////////////////////////
   btnKick.addActionListener(
       new java.awt.event.ActionListener() {
         public void actionPerformed(ActionEvent evt) {
           int iSelected = tblUser.getSelectedRow();
           if (iSelected < 0) return;
           int iResult =
               MessageBox.showConfirmDialog(
                   pnlThread,
                   mdic.getString("ConfirmKick"),
                   Global.APP_NAME,
                   MessageBox.YES_NO_OPTION);
           if (iResult == MessageBox.NO_OPTION) return;
           try {
             String strChannel = (String) tblUser.getRow(iSelected).elementAt(0);
             DDTP request = new DDTP();
             request.setRequestID(String.valueOf(System.currentTimeMillis()));
             request.setString("strChannel", strChannel);
             DDTP response = channel.sendRequest("ThreadProcessor", "kickUser", request);
           } catch (Exception e) {
             e.printStackTrace();
             MessageBox.showMessageDialog(pnlThread, e, Global.APP_NAME, MessageBox.ERROR_MESSAGE);
           }
         }
       });
   ////////////////////////////////////////////////////////
   txtMessage.addActionListener(
       new java.awt.event.ActionListener() {
         public void actionPerformed(ActionEvent evt) {
           btnSend.doClick();
         }
       });
   ////////////////////////////////////////////////////////
   btnSend.addActionListener(
       new java.awt.event.ActionListener() {
         public void actionPerformed(ActionEvent evt) {
           if (txtMessage.getText().length() == 0) return;
           try {
             DDTP request = new DDTP();
             request.setString("strMessage", txtMessage.getText());
             channel.sendRequest("ThreadProcessor", "sendMessage", request);
             txtMessage.setText("");
           } catch (Exception e) {
             e.printStackTrace();
             MessageBox.showMessageDialog(pnlThread, e, Global.APP_NAME, MessageBox.ERROR_MESSAGE);
           }
         }
       });
   ////////////////////////////////////////////////////////
   mnuClearAll.addActionListener(
       new java.awt.event.ActionListener() {
         public void actionPerformed(ActionEvent e) {
           clearAll(txtBoard);
         }
       });
   ////////////////////////////////////////////////////////
   mnuClearSelected.addActionListener(
       new java.awt.event.ActionListener() {
         public void actionPerformed(ActionEvent e) {
           txtBoard.setEditable(true);
           txtBoard.replaceSelection("");
           txtBoard.setEditable(false);
         }
       });
   ////////////////////////////////////////////////////////
   mnuSelectAll.addActionListener(
       new java.awt.event.ActionListener() {
         public void actionPerformed(ActionEvent e) {
           txtBoard.requestFocus();
           txtBoard.selectAll();
         }
       });
   ////////////////////////////////////////////////////////
   txtBoard.addMouseListener(
       new MouseAdapter() {
         public void mouseClicked(MouseEvent e) {
           if (e.getButton() == e.BUTTON3) pmn.show(txtBoard, e.getX(), e.getY());
         }
       });
   ////////////////////////////////////////////////////////
   mnuSystem_Login.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           login();
         }
       });
   ////////////////////////////////////////////////////////
   mnuSystem_ChangePassword.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           changePassword();
         }
       });
   ////////////////////////////////////////////////////////
   mnuSystem_StopServer.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           stopServer();
         }
       });
   ////////////////////////////////////////////////////////
   mnuSystem_EnableThreads.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           manageThreads();
         }
       });
   ////////////////////////////////////////////////////////
   mnuHelp_About.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           WindowManager.centeredWindow(new DialogAbout(PanelThreadManager.this));
         }
       });
   ////////////////////////////////////////////////////////
   chkVietnamese.addActionListener(
       new java.awt.event.ActionListener() {
         public void actionPerformed(ActionEvent e) {
           switchKeyboard();
         }
       });
 }
  /** Creates new form. */
  public PopupMenuTest() {
    initComponents();

    ActionListener a =
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            System.out.println(evt);
          }
        };

    JPopupMenu pm = new JPopupMenu();
    JMenu m;
    JMenuItem mi;
    JCheckBoxMenuItem cbmi;
    JRadioButtonMenuItem crmi;
    mi = new JMenuItem("Menu Item 1");
    mi.addActionListener(a);
    pm.add(mi);
    mi = new JMenuItem("Menu Item 2");
    mi.addActionListener(a);
    pm.add(mi);
    mi = new JMenuItem("Menu Item 3");
    mi.addActionListener(a);
    pm.add(mi);

    m = new JMenu("Menu 1");
    mi = new JMenuItem("Menu Item 1.1");
    mi.addActionListener(a);
    m.add(mi);
    mi = new JMenuItem("Menu Item 1.2");
    mi.addActionListener(a);
    m.add(mi);
    pm.add(m);

    pm.addSeparator();
    cbmi = new JCheckBoxMenuItem("Checkbox Menu Item");
    pm.add(cbmi);

    pm.addSeparator();
    ButtonGroup group = new ButtonGroup();
    crmi = new JRadioButtonMenuItem("Radio Menu Item 1");
    crmi.setSelected(true);
    group.add(crmi);
    pm.add(crmi);

    crmi = new JRadioButtonMenuItem("Radio Menu Item 2");
    group.add(crmi);
    pm.add(crmi);
    popupMenu = pm;

    /*
    //setComponentPopupMenu(pm);
    //jLabel1.setComponentPopupMenu(pm);
    JButton button = new JButton("Hi");
    // button.setComponentPopupMenu(pm);
    button.setInheritsPopupMenu(true);
    add(button, BorderLayout.SOUTH);
     */
    MouseAdapter popper1 =
        new MouseAdapter() {
          public void mousePressed(MouseEvent evt) {
            if (evt.isPopupTrigger()) {
              showPopupMenu(evt);
            }
          }

          public void mouseReleased(MouseEvent evt) {
            if (evt.isPopupTrigger()) {
              showPopupMenu(evt);
            }
          }

          protected void showPopupMenu(MouseEvent evt) {
            popupMenu.show((Component) evt.getSource(), evt.getX(), evt.getY());
          }
        };

    popupLabel1.addMouseListener(popper1);
    popupField.addMouseListener(popper1);

    MouseAdapter popper2 =
        new MouseAdapter() {
          public void mousePressed(MouseEvent evt) {
            if (evt.isPopupTrigger()) {
              showPopupMenu(evt);
            }
          }

          public void mouseReleased(MouseEvent evt) {
            if (evt.isPopupTrigger()) {
              showPopupMenu(evt);
            }
          }

          protected void showPopupMenu(MouseEvent evt) {
            Dimension ps = popupMenu.getPreferredSize();
            popupMenu.show(popupLabel2, evt.getX() - ps.width / 2, evt.getY() - ps.height / 2);
          }
        };

    popupLabel2.addMouseListener(popper2);
  }
Example #17
0
  public SearchManager2(JabRefFrame frame, SidePaneManager manager) {
    super(manager, GUIGlobals.getIconUrl("search"), Globals.lang("Search"));

    this.frame = frame;
    incSearcher = new IncrementalSearcher(Globals.prefs);

    // setBorder(BorderFactory.createMatteBorder(1,1,1,1,Color.magenta));

    searchReq =
        new JCheckBoxMenuItem(
            Globals.lang("Search required fields"),
            Globals.prefs.getBoolean(JabRefPreferences.SEARCH_REQ));
    searchOpt =
        new JCheckBoxMenuItem(
            Globals.lang("Search optional fields"),
            Globals.prefs.getBoolean(JabRefPreferences.SEARCH_OPT));
    searchGen =
        new JCheckBoxMenuItem(
            Globals.lang("Search general fields"),
            Globals.prefs.getBoolean(JabRefPreferences.SEARCH_GEN));
    searchAll =
        new JCheckBoxMenuItem(
            Globals.lang("Search all fields"),
            Globals.prefs.getBoolean(JabRefPreferences.SEARCH_ALL));
    regExpSearch =
        new JCheckBoxMenuItem(
            Globals.lang("Use regular expressions"),
            Globals.prefs.getBoolean(JabRefPreferences.REG_EXP_SEARCH));

    increment = new JRadioButton(Globals.lang("Incremental"), false);
    floatSearch = new JRadioButton(Globals.lang("Float"), true);
    hideSearch = new JRadioButton(Globals.lang("Filter"), true);
    showResultsInDialog = new JRadioButton(Globals.lang("Show results in dialog"), true);
    searchAllBases =
        new JRadioButton(
            Globals.lang("Global search"),
            Globals.prefs.getBoolean(JabRefPreferences.SEARCH_ALL_BASES));
    ButtonGroup types = new ButtonGroup();
    types.add(increment);
    types.add(floatSearch);
    types.add(hideSearch);
    types.add(showResultsInDialog);
    types.add(searchAllBases);

    select = new JCheckBoxMenuItem(Globals.lang("Select matches"), false);
    increment.setToolTipText(Globals.lang("Incremental search"));
    floatSearch.setToolTipText(Globals.lang("Gray out non-matching entries"));
    hideSearch.setToolTipText(Globals.lang("Hide non-matching entries"));
    showResultsInDialog.setToolTipText(Globals.lang("Show search results in a window"));

    // Add an item listener that makes sure we only listen for key events
    // when incremental search is turned on.
    increment.addItemListener(this);
    floatSearch.addItemListener(this);
    hideSearch.addItemListener(this);
    showResultsInDialog.addItemListener(this);
    // Add the global focus listener, so a menu item can see if this field was focused when
    // an action was called.
    searchField.addFocusListener(Globals.focusListener);

    if (searchAll.isSelected()) {
      searchReq.setEnabled(false);
      searchOpt.setEnabled(false);
      searchGen.setEnabled(false);
    }
    searchAll.addChangeListener(
        new ChangeListener() {

          @Override
          public void stateChanged(ChangeEvent event) {
            boolean state = !searchAll.isSelected();
            searchReq.setEnabled(state);
            searchOpt.setEnabled(state);
            searchGen.setEnabled(state);
          }
        });

    caseSensitive =
        new JCheckBoxMenuItem(
            Globals.lang("Case sensitive"),
            Globals.prefs.getBoolean(JabRefPreferences.CASE_SENSITIVE_SEARCH));

    highLightWords =
        new JCheckBoxMenuItem(
            Globals.lang("Highlight Words"),
            Globals.prefs.getBoolean(JabRefPreferences.HIGH_LIGHT_WORDS));

    searchAutoComplete =
        new JCheckBoxMenuItem(
            Globals.lang("Autocomplete names"),
            Globals.prefs.getBoolean(JabRefPreferences.SEARCH_AUTO_COMPLETE));
    settings.add(select);

    // 2005.03.29, trying to remove field category searches, to simplify
    // search usability.
    // settings.addSeparator();
    // settings.add(searchReq);
    // settings.add(searchOpt);
    // settings.add(searchGen);
    // settings.addSeparator();
    // settings.add(searchAll);
    // ---------------------------------------------------------------
    settings.addSeparator();
    settings.add(caseSensitive);
    settings.add(regExpSearch);
    settings.addSeparator();
    settings.add(highLightWords);
    settings.addSeparator();
    settings.add(searchAutoComplete);

    searchField.addActionListener(this);
    searchField.addCaretListener(this);
    search.addActionListener(this);
    searchField.addFocusListener(
        new FocusAdapter() {

          @Override
          public void focusGained(FocusEvent e) {
            if (increment.isSelected()) {
              searchField.setText("");
            }
          }

          @Override
          public void focusLost(FocusEvent e) {
            incSearch = false;
            incSearchPos = -1; // Reset incremental
            // search. This makes the
            // incremental search reset
            // once the user moves focus to
            // somewhere else.
            if (increment.isSelected()) {
              // searchField.setText("");
              // System.out.println("focuslistener");
            }
          }
        });
    escape.addActionListener(this);
    escape.setEnabled(false); // enabled after searching

    openset.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            if (settings.isVisible()) {
              // System.out.println("oee");
              // settings.setVisible(false);
            } else {
              JButton src = (JButton) e.getSource();
              settings.show(src, 0, openset.getHeight());
            }
          }
        });

    searchAutoComplete.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent actionEvent) {
            Globals.prefs.putBoolean(
                JabRefPreferences.SEARCH_AUTO_COMPLETE, searchAutoComplete.isSelected());
            if (SearchManager2.this.frame.basePanel() != null) {
              SearchManager2.this.frame.basePanel().updateSearchManager();
            }
          }
        });
    Insets margin = new Insets(0, 2, 0, 2);
    // search.setMargin(margin);
    escape.setMargin(margin);
    openset.setMargin(margin);
    JButton help = new JButton(GUIGlobals.getImage("help"));
    int butSize = help.getIcon().getIconHeight() + 5;
    Dimension butDim = new Dimension(butSize, butSize);
    help.setPreferredSize(butDim);
    help.setMinimumSize(butDim);
    help.setMargin(margin);
    help.addActionListener(new HelpAction(Globals.helpDiag, GUIGlobals.searchHelp, "Help"));

    // Select the last used mode of search:
    if (Globals.prefs.getBoolean(JabRefPreferences.INCREMENT_S)) {
      increment.setSelected(true);
    } else if (Globals.prefs.getBoolean(JabRefPreferences.FLOAT_SEARCH)) {
      floatSearch.setSelected(true);
    } else if (Globals.prefs.getBoolean(JabRefPreferences.SHOW_SEARCH_IN_DIALOG)) {
      showResultsInDialog.setSelected(true);
    } else if (Globals.prefs.getBoolean(JabRefPreferences.SEARCH_ALL_BASES)) {
      searchAllBases.setSelected(true);
    } else {
      hideSearch.setSelected(true);
    }

    JPanel main = new JPanel();
    GridBagLayout gbl = new GridBagLayout();
    main.setLayout(gbl);
    GridBagConstraints con = new GridBagConstraints();
    con.gridwidth = GridBagConstraints.REMAINDER;
    con.fill = GridBagConstraints.BOTH;
    con.weightx = 1;

    gbl.setConstraints(searchField, con);
    main.add(searchField);
    // con.gridwidth = 1;
    gbl.setConstraints(search, con);
    main.add(search);
    con.gridwidth = GridBagConstraints.REMAINDER;
    gbl.setConstraints(escape, con);
    main.add(escape);
    con.insets = new Insets(0, 2, 0, 0);
    gbl.setConstraints(increment, con);
    main.add(increment);
    gbl.setConstraints(floatSearch, con);
    main.add(floatSearch);
    gbl.setConstraints(hideSearch, con);
    main.add(hideSearch);
    gbl.setConstraints(showResultsInDialog, con);
    main.add(showResultsInDialog);
    gbl.setConstraints(searchAllBases, con);
    main.add(searchAllBases);
    con.insets = new Insets(0, 0, 0, 0);
    JPanel pan = new JPanel();
    GridBagLayout gb = new GridBagLayout();
    gbl.setConstraints(pan, con);
    pan.setLayout(gb);
    con.weightx = 1;
    con.gridwidth = 1;
    gb.setConstraints(openset, con);
    pan.add(openset);
    con.weightx = 0;
    gb.setConstraints(help, con);
    pan.add(help);
    main.add(pan);
    main.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));

    setContentContainer(main);

    searchField.getInputMap().put(Globals.prefs.getKey("Repeat incremental search"), "repeat");

    searchField
        .getActionMap()
        .put(
            "repeat",
            new AbstractAction() {

              @Override
              public void actionPerformed(ActionEvent e) {
                if (increment.isSelected()) {
                  repeatIncremental();
                }
              }
            });
    searchField.getInputMap().put(Globals.prefs.getKey("Clear search"), "escape");
    searchField
        .getActionMap()
        .put(
            "escape",
            new AbstractAction() {

              @Override
              public void actionPerformed(ActionEvent e) {
                hideAway();
                // SearchManager2.this.actionPerformed(new ActionEvent(escape, 0, ""));
              }
            });
    setSearchButtonSizes();
    updateSearchButtonText();
  }
  public AutoFocusator() {
    super(new BorderLayout());

    taskList = new TaskList();
    Task task0 = new Task("Use right click to change the states of the tasks.");
    taskList.add(task0);
    Task task1 = new Task("Just play araound with this small app.");
    taskList.add(task1);
    Task task2 = new Task("Check http://sourceforge.net/projects/autofocusator/");
    taskList.add(task2);

    // task1.setState(State.crossed);
    // task0.setState(State.dismissed);

    table = new JTable(taskList);
    table.setPreferredScrollableViewportSize(new Dimension(500, 700));
    table.setFillsViewportHeight(true);
    table.getColumnModel().getColumn(0).setPreferredWidth(300);
    table.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
    table.setRowSelectionAllowed(true);

    table.getColumnModel().getColumn(0).setCellRenderer(new TaskRenderer());
    // TableCellRenderer renderer = table.getColumnModel().getColumn(0).getCellRenderer();
    // double height = ((TaskRenderer)renderer).getRendererHeight();

    // @todo: The height should be set dependent on the content
    table.setRowHeight(28);

    table.getModel().addTableModelListener(this);

    toolBar = new JToolBar("Autofocusator - Toolbar");

    JButton buttonAddTask = new JButton("Add a Task", new ImageIcon(loadPics("res/list-add.png")));
    buttonAddTask.setActionCommand("addTask");
    buttonAddTask.addActionListener(this);
    toolBar.add(buttonAddTask);

    JButton buttonDeleteTask =
        new JButton("Delete a Task", new ImageIcon(loadPics("res/list-remove.png")));
    buttonDeleteTask.setActionCommand("deleteTask");
    buttonDeleteTask.addActionListener(this);
    toolBar.add(buttonDeleteTask);

    JButton buttonSave = new JButton("Save", new ImageIcon(loadPics("res/document-save-as.png")));
    buttonSave.setActionCommand("save");
    buttonSave.addActionListener(this);
    toolBar.add(buttonSave);

    JButton buttonOpen = new JButton("open", new ImageIcon(loadPics("res/document-open.png")));
    buttonOpen.setActionCommand("open");
    buttonOpen.addActionListener(this);
    toolBar.add(buttonOpen);

    add(toolBar, BorderLayout.NORTH);

    contextMenu = new JPopupMenu();
    JMenuItem contextMenuItem;
    contextMenuItem = new JMenuItem("delete Task");
    contextMenuItem.addActionListener(this);
    contextMenuItem.setActionCommand("deleteTask");
    contextMenu.add(contextMenuItem);

    contextMenuItem = new JMenuItem("add Task");
    contextMenuItem.addActionListener(this);
    contextMenuItem.setActionCommand("addTask");
    contextMenu.add(contextMenuItem);

    contextMenu.addSeparator();

    contextMenuItem = new JMenuItem("cross");
    contextMenuItem.addActionListener(this);
    contextMenuItem.setActionCommand("cross");
    contextMenu.add(contextMenuItem);

    contextMenuItem = new JMenuItem("dismiss");
    contextMenuItem.addActionListener(this);
    contextMenuItem.setActionCommand("dismiss");
    contextMenu.add(contextMenuItem);

    contextMenuItem = new JMenuItem("worked on");
    contextMenuItem.addActionListener(this);
    contextMenuItem.setActionCommand("workedOn");
    contextMenu.add(contextMenuItem);

    fileChooser = new JFileChooser();
    FileFilter filter = new FileNameExtensionFilter("XML File", "xml");
    fileChooser.addChoosableFileFilter(filter);

    table.addMouseListener(this);

    JScrollPane scrollPane = new JScrollPane(table);
    add(scrollPane, BorderLayout.CENTER);
  }