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