Ejemplo n.º 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);
  }
Ejemplo n.º 2
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()
Ejemplo n.º 3
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()
Ejemplo n.º 4
0
  protected final JPopupMenu constructTablePopup() {
    JPopupMenu pop = new JPopupMenu();

    addMenu(pop, "Do Search", "Execute");
    addMenu(pop, "Load Searches");
    addMenu(pop, "Edit Search");
    pop.add(new JPopupMenu.Separator());
    addMenu(pop, "Enable");
    addMenu(pop, "Disable");
    pop.add(new JPopupMenu.Separator());
    addMenu(pop, "Delete");

    return pop;
  }
  public static void main(String[] args) {
    final JPopupMenu menu = new JPopupMenu();
    menu.setLayout(new GridLayout(0, 3, 5, 5));

    final MenuedButton button = new MenuedButton("Icons", menu);

    for (int i = 0; i < 9; i++) {
      // replace "print.gif" with your own image
      final JLabel label = new JLabel("" + i); // new ImageIcon("resources/images/print.gif") );
      label.addMouseListener(
          new MouseAdapter() {
            public void mouseClicked(MouseEvent e) {
              button.getMainButton().setIcon(label.getIcon());
              menu.setVisible(false);
            }
          });
      menu.add(label);
    }

    JFrame frame = new JFrame("Button Test");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().add(new JLabel("Click Arrow Button To Show Popup"), BorderLayout.NORTH);
    frame.getContentPane().add(button, BorderLayout.CENTER);
    frame.pack();
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
  }
Ejemplo n.º 6
0
  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;
  }
Ejemplo n.º 7
0
 /** sets this user to be an admin */
 public void setAdmin() {
   admin = true;
   popup.add("kick user").addActionListener(myAction);
   if (chanAdmin) {
     butCreate.setEnabled(true);
   }
 }
Ejemplo n.º 8
0
    /**
     * Make the edit menu
     *
     * @param popup The popup
     * @param row The row
     */
    void makeEditableMenu(JPopupMenu popup, final int row) {

      JMenuItem mi;
      popup.add(GuiUtils.makeMenuItem("Add New Field", this, "addNewRow"));
      ParamInfo paramInfo = getInfo(row);
      if (paramInfo == null) {
        return;
      }

      popup.add(GuiUtils.makeMenuItem("Edit Settings", this, "editRow", paramInfo));

      mi = new JMenuItem("Delete Settings For Parameter");
      mi.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
              removeRow(row);
            }
          });
      popup.add(mi);
    }
  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);
  }
Ejemplo n.º 10
0
    public void mabeShowPopup(MouseEvent e) {

      if (e.isPopupTrigger()) {

        final JPopupMenu contextMenu = new JPopupMenu();

        int row = view.getTable().rowAtPoint(e.getPoint());
        ListTableModel<PatientModel> tModel = getTableModel();
        PatientModel obj = tModel.getObject(row);
        int selected = view.getTable().getSelectedRow();

        if (row == selected && obj != null) {
          contextMenu.add(
              new JMenuItem(new ReflectAction("カルテを開く", PatientSearchImpl.this, "openKarte")));
          contextMenu.addSeparator();
          // s.oh^ 2014/08/19 ID権限
          // contextMenu.add(new JMenuItem(copyAction));
          // contextMenu.add(new JMenuItem(new ReflectAction("受付登録", PatientSearchImpl.this,
          // "addAsPvt")));
          // contextMenu.addSeparator();
          if (!Project.isOtherCare()) {
            contextMenu.add(new JMenuItem(copyAction));
            contextMenu.add(
                new JMenuItem(new ReflectAction("受付登録", PatientSearchImpl.this, "addAsPvt")));
            contextMenu.addSeparator();
          }
          // s.oh$
        }

        JCheckBoxMenuItem item = new JCheckBoxMenuItem("年齢表示");
        contextMenu.add(item);
        item.setSelected(ageDisplay);
        item.addActionListener(
            (ActionListener)
                EventHandler.create(
                    ActionListener.class, PatientSearchImpl.this, "switchAgeDisplay"));

        contextMenu.show(e.getComponent(), e.getX(), e.getY());
      }
    }
Ejemplo n.º 11
0
 /**
  * Make the popup menu
  *
  * @param popup The popup menu
  * @param row The row the user clicked on
  */
 void makePopupMenu(JPopupMenu popup, final int row) {
   ParamInfo info = getInfo(row);
   if (isEditable) {
     makeEditableMenu(popup, row);
   } else {
     JMenuItem mi = new JMenuItem("Copy Row to Users Defaults");
     mi.addActionListener(
         new ActionListener() {
           public void actionPerformed(ActionEvent ae) {
             try {
               copyToUsers(getInfo(row));
             } catch (Exception exc) {
               LogUtil.printException(log_, "Copying row: " + row + " to users table.", exc);
             }
           }
         });
     popup.add(mi);
   }
   if (info != null) {
     popup.add(
         GuiUtils.makeMenuItem(
             "Export to Plugin", getIdv().getPluginManager(), "addObject", info));
   }
 }
Ejemplo n.º 12
0
  public Annotation(URL url) throws IOException {
    super(url);

    setEditable(false);
    addHyperlinkListener(this);

    // popup
    addMouseListener(new PopupListener());
    popup = new JPopupMenu();
    JMenuItem backMenu = new JMenuItem("Back");
    popup.add(backMenu);
    backMenu.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            goBack();
          }
        });
    back.add(url);
  }
Ejemplo n.º 13
0
  private void createPopupMenu() {
    JMenuItem menuItem;

    // Create the popup menu.
    popupMenu = new JPopupMenu();
    menuItem = new JMenuItem("Update");
    menuItem.addMouseListener(
        new MouseAdapter() {
          public void mouseReleased(MouseEvent e) {
            ListSelectionModel rowSM = getSelectionModel();
            if (!rowSM.isSelectionEmpty()) {
              // Find out which indexes are selected.
              for (Node node : getSelectedNodes()) {
                System.out.println(
                    "NodeStatusPanel - scheduling Status Update for nodeID= " + node.getNodeID());
                AckRequest ackRequest =
                    new AckRequest(spauldingApp, node, DriverMsgs.REQUESTMSG_TYPE_STATUS);
                spauldingApp.scheduleRequest(ackRequest);
              }
            }
          }
        });
    popupMenu.add(menuItem);

    // add separator
    popupMenu.addSeparator(); // JPopupMenu.Separator);

    menuItem = new JMenuItem("Start sampling");
    menuItem.addMouseListener(
        new MouseAdapter() {
          public void mouseReleased(MouseEvent e) {
            ListSelectionModel rowSM = getSelectionModel();
            if (!rowSM.isSelectionEmpty()) {
              // Find out which indexes are selected.
              for (Node node : getSelectedNodes()) {
                System.out.println(
                    "NodeStatusPanel - scheduling Start Sampling for nodeID= " + node.getNodeID());
                AckRequest ackRequest =
                    new AckRequest(spauldingApp, node, DriverMsgs.REQUESTMSG_TYPE_STARTSAMPLING);
                spauldingApp.scheduleRequest(ackRequest);
              }
            }
          }
        });
    popupMenu.add(menuItem);

    menuItem = new JMenuItem("Stop sampling");
    menuItem.addMouseListener(
        new MouseAdapter() {
          public void mouseReleased(MouseEvent e) {
            ListSelectionModel rowSM = getSelectionModel();
            if (!rowSM.isSelectionEmpty()) {
              // Find out which indexes are selected.
              for (Node node : getSelectedNodes()) {
                System.out.println(
                    "NodeStatusPanel - scheduling Stop Sampling for nodeID= " + node.getNodeID());
                AckRequest ackRequest =
                    new AckRequest(spauldingApp, node, DriverMsgs.REQUESTMSG_TYPE_STOPSAMPLING);
                spauldingApp.scheduleRequest(ackRequest);
              }
            }
          }
        });
    popupMenu.add(menuItem);

    // add separator
    popupMenu.addSeparator();

    menuItem = new JMenuItem("Download");
    menuItem.addMouseListener(
        new MouseAdapter() {
          public void mouseReleased(MouseEvent e) {
            ListSelectionModel rowSM = getSelectionModel();
            if (!rowSM.isSelectionEmpty()) {
              String str = JOptionPane.showInputDialog("Number of blocks to download", "3");
              int nbrBlockToDownload = 3;
              if (str == null)
                System.err.println(
                    "Invalid number of blocks, using default of "
                        + nbrBlockToDownload
                        + " blocks.");
              try {
                nbrBlockToDownload = Integer.parseInt(str);
              } catch (Exception exp) {
                System.err.println(
                    "Invalid number of blocks, using default of "
                        + nbrBlockToDownload
                        + " blocks.");
              }

              // Find out which indexes are selected.
              for (Node node : getSelectedNodes()) {

                System.out.println(
                    "NodeStatusPanel - scheduling Download Blocks for nodeID= " + node.getNodeID());
                FetchLogger fetchLogger =
                    new FetchLogger(spauldingApp, node, FetchLogger.MANUAL_FETCH, new Date(), null);
                long startBlockID = node.getHeadBlockID() - nbrBlockToDownload;
                FetchRequest fetchRequest =
                    new FetchRequest(
                        spauldingApp, node, startBlockID, nbrBlockToDownload, fetchLogger);
                spauldingApp.scheduleRequest(fetchRequest);
              }
            }
          }
        });
    popupMenu.add(menuItem);

    // add separator
    popupMenu.addSeparator();

    menuItem = new JMenuItem("Reset DataStore");
    menuItem.addMouseListener(
        new MouseAdapter() {
          public void mouseReleased(MouseEvent e) {
            ListSelectionModel rowSM = getSelectionModel();
            if (!rowSM.isSelectionEmpty()) {
              Object[] options = {"Yes", "No"};
              int n =
                  JOptionPane.showOptionDialog(
                      null,
                      "Are you sure you want to RESET the DataStore?  Note, This is irreversible!",
                      "Confirm RESET",
                      JOptionPane.YES_NO_OPTION,
                      JOptionPane.QUESTION_MESSAGE,
                      null,
                      options,
                      options[1]);
              if (n == JOptionPane.YES_OPTION) {
                // Find out which indexes are selected.
                for (Node node : getSelectedNodes()) {
                  System.out.println(
                      "NodeStatusPanel - scheduling Reset DataStore for nodeID= "
                          + node.getNodeID());
                  AckRequest ackRequest =
                      new AckRequest(spauldingApp, node, DriverMsgs.REQUESTMSG_TYPE_RESETDATASTORE);
                  spauldingApp.scheduleRequest(ackRequest);
                }
              }
            }
          }
        });
    popupMenu.add(menuItem);

    // add separator
    popupMenu.addSeparator(); // JPopupMenu.Separator);
  }
Ejemplo n.º 14
0
 private void addMenu(JPopupMenu p, String name) {
   p.add(makeMenuItem(name)).addActionListener(this);
 }
Ejemplo n.º 15
0
  /**
   * Helper method that initializes the items for the context menu. This menu will include cut,
   * copy, paste, undo/redo, and find/replace functionality.
   */
  private void initContextMenu() {

    contextPopup = new JPopupMenu();
    // Edit menu stuff
    contextPopup.add(GUIPrism.getClipboardPlugin().getUndoAction());
    contextPopup.add(GUIPrism.getClipboardPlugin().getRedoAction());
    contextPopup.add(new JSeparator());
    contextPopup.add(GUIPrism.getClipboardPlugin().getCutAction());
    contextPopup.add(GUIPrism.getClipboardPlugin().getCopyAction());
    contextPopup.add(GUIPrism.getClipboardPlugin().getPasteAction());
    contextPopup.add(GUIPrism.getClipboardPlugin().getDeleteAction());
    contextPopup.add(new JSeparator());
    contextPopup.add(GUIPrism.getClipboardPlugin().getSelectAllAction());
    contextPopup.add(new JSeparator());
    // Model menu stuff
    contextPopup.add(((GUIMultiModel) handler.getGUIPlugin()).getParseModel());
    contextPopup.add(((GUIMultiModel) handler.getGUIPlugin()).getBuildModel());
    contextPopup.add(new JSeparator());
    contextPopup.add(((GUIMultiModel) handler.getGUIPlugin()).getExportMenu());
    contextPopup.add(((GUIMultiModel) handler.getGUIPlugin()).getViewMenu());
    contextPopup.add(((GUIMultiModel) handler.getGUIPlugin()).getComputeMenu());
    // contextPopup.add(actionJumpToError);
    // contextPopup.add(actionSearch);

    if (editor.getContentType().equals("text/prism")) {

      JMenu insertMenu = new JMenu("Insert elements");
      JMenu insertModelTypeMenu = new JMenu("Model type");
      insertMenu.add(insertModelTypeMenu);
      JMenu insertModule = new JMenu("Module");
      insertMenu.add(insertModule);
      JMenu insertVariable = new JMenu("Variable");
      insertMenu.add(insertVariable);

      insertModelTypeMenu.add(insertDTMC);
      insertModelTypeMenu.add(insertCTMC);
      insertModelTypeMenu.add(insertMDP);
      // contextPopup.add(new JSeparator());
      // contextPopup.add(insertMenu);
    }
  }
Ejemplo n.º 16
0
  /** Initializes the graphical components */
  public void init() {
    username = getParameter("username");
    if (username == null) {
      username =
          JOptionPane.showInputDialog(
              this, "Please enter a username", "Login", JOptionPane.QUESTION_MESSAGE);
    }
    try {
      PORT = Integer.valueOf(getParameter("port")).intValue();
    } catch (NumberFormatException e) {
      PORT = 42412;
    }

    URL url = getDocumentBase();
    site = url.getHost();
    locationURL = "http://" + site + ":" + url.getPort() + "/" + url.getPath();

    setSize(615, 362);
    c = getContentPane();

    c.setBackground(new Color(224, 224, 224));

    if (site == null || locationURL == null) {
      c.add(new JLabel("ERROR: did not recieve needed data from page"));
    }

    myAction = new MyAction();
    myKeyListener = new MyKeyListener();
    myMouseListener = new MyMouseListener();
    myHyperlinkListener = new MyHyperlinkListener();

    c.setLayout(null);

    cboChannels = new JComboBox();
    cboChannels.setBounds(5, 5, 150, 24);

    butChannel = new JButton("Join");
    butChannel.setToolTipText("Join channel");
    butChannel.addActionListener(myAction);
    butChannel.setBounds(160, 5, 60, 24);

    butCreate = new JButton("Create");
    butCreate.setToolTipText("Create new channel");
    butCreate.addActionListener(myAction);
    butCreate.setBounds(230, 5, 100, 24);
    butCreate.setEnabled(false);

    butInvite = new JButton("Invite");
    butInvite.setToolTipText("Invite Friend");
    butInvite.addActionListener(myAction);
    butInvite.setBounds(340, 5, 80, 24);

    mainChat = new ChatPane(this);
    textScroller =
        new JScrollPane(
            mainChat,
            JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    textScroller.setBounds(5, 34, 500, 270);

    userList = new JList();
    userList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    userList.setCellRenderer(new MyCellRenderer());
    userList.setBackground(new Color(249, 249, 250));
    JScrollPane userScroller = new JScrollPane(userList);
    userScroller.setBounds(510, 34, 100, 297);

    messageText = new JTextField();
    messageText.setBounds(5, 309, 500, 22);
    messageText.setColumns(10);
    messageText.setBackground(new Color(249, 249, 250));

    JMenuItem item;
    popup = new JPopupMenu("test");
    popup.add("whisper").addActionListener(myAction);
    popup.add("private message").addActionListener(myAction);
    popup.add("ignore").addActionListener(myAction);
    popup.add("clear ignore list").addActionListener(myAction);

    conNo = new ImageIcon(getURL("images/connect_no.gif"));
    conYes = new ImageIcon(getURL("images/connect_established.gif"));
    secNo = new ImageIcon(getURL("images/decrypted.gif"));
    secYes = new ImageIcon(getURL("images/encrypted.gif"));

    conIcon = new JLabel(conNo);
    conIcon.setBorder(new EtchedBorder());
    secIcon = new JLabel(secNo);
    secIcon.setBorder(new EtchedBorder());

    conIcon.setBounds(563, 334, 22, 22);
    secIcon.setBounds(588, 334, 22, 22);

    bottomText =
        new JLabel(
            "<html><body><font color=#445577><b>"
                + "LlamaChat "
                + VERSION
                + "</b></font> &nbsp;&copy; "
                + "<a href=\""
                + linkURL
                + "\">Joseph Monti</a> 2002-2003"
                + "</body></html>");
    bottomText.setBounds(5, 336, 500, 20);

    c.add(cboChannels);
    c.add(butChannel);
    c.add(butCreate);
    c.add(butInvite);
    c.add(textScroller);
    c.add(userScroller);
    c.add(messageText);
    c.add(conIcon);
    c.add(secIcon);
    c.add(bottomText);

    userList.addMouseListener(myMouseListener);
    messageText.addKeyListener(myKeyListener);
    bottomText.addMouseListener(myMouseListener);

    users = new ArrayList();
    ignores = new ArrayList(5);
    afks = new ArrayList(5);
    admins = new ArrayList(5);
    history = new CommandHistory(10);
    admin = false;
    channels = new Hashtable();
    privates = new PrivateMsg(this);
    showUserStatus = false;

    myColors[0] = new Color(200, 0, 0);
    myColors[1] = new Color(0, 150, 0);
    myColors[2] = new Color(0, 0, 200);

    rect = new Rectangle(0, 0, 1, 1);

    String opening =
        "<font color=#333333>"
            + "==================================<br>"
            + "Welcome to LlamaChat "
            + VERSION
            + "<br>"
            + "If you need assistance, type \\help<br>"
            + "Enjoy your stay!<br>"
            + "Maestria Aplicada en Redes<br>"
            + "==================================<br></font>";
    HTMLDocument doc = (HTMLDocument) mainChat.getDocument();
    HTMLEditorKit kit = (HTMLEditorKit) mainChat.getEditorKit();
    try {
      kit.insertHTML(doc, doc.getLength(), opening, 0, 0, HTML.Tag.FONT);
    } catch (Throwable t) {
      t.printStackTrace(System.out);
    }

    // validate the name
    if (!username.matches("[\\w_-]+?")) {
      error(
          "username contains invalid characters, changing to "
              + "'invalid' for now. "
              + "Type \\rename to chose a new name");
      username = "******";
    }
    if (username.length() > 10) {
      username = username.substring(0, 10);
      error("username too long, changed to " + username);
    }

    connect();
  }