List of usage examples for javax.swing JPopupMenu JPopupMenu
public JPopupMenu()
JPopupMenu
without an "invoker". From source file:it.unibas.spicygui.vista.JLayeredPaneCorrespondences.java
private void creaPopUpMappingTaskTreeSourceDuplicate() { this.popUpMenuSourceDuplicate = new JPopupMenu(); MappingTask mappingTask = scenario.getMappingTask(); if (mappingTask != null) { this.popUpMenuSourceDuplicate .add(new ActionDuplicateSetNode(this, sourceSchemaTree, mappingTask.getSourceProxy())); this.popUpMenuSourceDuplicate .add(new ActionSelectionCondition(this, sourceSchemaTree, mappingTask.getSourceProxy())); }/*from w ww .ja va2 s .c o m*/ }
From source file:com.haulmont.cuba.desktop.gui.components.DesktopTree.java
protected JPopupMenu createPopupMenu() { JPopupMenu popup = new JPopupMenu(); JMenuItem menuItem;//from w w w . j ava 2 s .c o m for (final com.haulmont.cuba.gui.components.Action action : actionList) { if (StringUtils.isNotBlank(action.getCaption()) && action.isVisible()) { menuItem = new JMenuItem(action.getCaption()); if (action.getIcon() != null) { menuItem.setIcon(AppBeans.get(IconResolver.class).getIconResource(action.getIcon())); } if (action.getShortcutCombination() != null) { menuItem.setAccelerator( DesktopComponentsHelper.convertKeyCombination(action.getShortcutCombination())); } menuItem.setEnabled(action.isEnabled()); menuItem.addActionListener(e -> action.actionPerform(DesktopTree.this)); popup.add(menuItem); } } return popup; }
From source file:it.unibas.spicygui.vista.JLayeredPaneCorrespondences.java
private void creaPopUpMappingTaskTreeSourceDeleteDuplicate() { this.popUpMenuSourceDeleteDuplicate = new JPopupMenu(); MappingTask mappingTask = scenario.getMappingTask(); if (mappingTask != null) { this.popUpMenuSourceDeleteDuplicate.add( new ActionDeleteDuplicateSetCloneNode(this, sourceSchemaTree, mappingTask.getSourceProxy())); this.popUpMenuSourceDeleteDuplicate .add(new ActionSelectionCondition(this, sourceSchemaTree, mappingTask.getSourceProxy())); }/*ww w . j a v a 2 s. c o m*/ }
From source file:edu.ku.brc.specify.tasks.subpane.ESResultsTablePanel.java
/** * //from w w w. jav a 2s .c o m */ protected void addContextMenu() { MouseAdapter mouseAdapter = new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { super.mousePressed(e); if (e.isPopupTrigger()) { if (table.getSelectedColumnCount() > 0) { if (popupMenu != null && popupMenu.isVisible()) { popupMenu.setVisible(false); } if (popupMenu == null) { popupMenu = new JPopupMenu(); JMenuItem mi = popupMenu.add(new JMenuItem(UIRegistry.getResourceString("Remove"))); mi.addActionListener(createRemoveItemAL()); } Point p = table.getLocationOnScreen(); popupMenu.setLocation(p.x + e.getX() + 1, p.y + e.getY() + 1); popupMenu.setVisible(true); } } } }; table.addMouseListener(mouseAdapter); }
From source file:com.net2plan.gui.utils.viewEditTopolTables.specificTables.AdvancedJTable_demand.java
public void doPopup(final MouseEvent e, final int row, final Object itemId) { JPopupMenu popup = new JPopupMenu(); final ITableRowFilter rf = callback.getVisualizationState().getTableRowFilter(); final List<Demand> demandRowsInTheTable = getVisibleElementsInTable(); /* Add the popup menu option of the filters */ final List<Demand> selectedDemands = (List<Demand>) (List<?>) getSelectedElements().getFirst(); if (!selectedDemands.isEmpty()) { final JMenu submenuFilters = new JMenu("Filters"); final JMenuItem filterKeepElementsAffectedThisLayer = new JMenuItem( "This layer: Keep elements associated to this demand traffic"); final JMenuItem filterKeepElementsAffectedAllLayers = new JMenuItem( "All layers: Keep elements associated to this demand traffic"); submenuFilters.add(filterKeepElementsAffectedThisLayer); if (callback.getDesign().getNumberOfLayers() > 1) submenuFilters.add(filterKeepElementsAffectedAllLayers); filterKeepElementsAffectedThisLayer.addActionListener(new ActionListener() { @Override// ww w . j a va2 s.co m public void actionPerformed(ActionEvent e) { if (selectedDemands.size() > 1) throw new RuntimeException(); TBFToFromCarriedTraffic filter = new TBFToFromCarriedTraffic(selectedDemands.get(0), true); callback.getVisualizationState().updateTableRowFilter(filter); callback.updateVisualizationJustTables(); } }); filterKeepElementsAffectedAllLayers.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (selectedDemands.size() > 1) throw new RuntimeException(); TBFToFromCarriedTraffic filter = new TBFToFromCarriedTraffic(selectedDemands.get(0), false); callback.getVisualizationState().updateTableRowFilter(filter); callback.updateVisualizationJustTables(); } }); popup.add(submenuFilters); popup.addSeparator(); } if (callback.getVisualizationState().isNetPlanEditable()) { popup.add(getAddOption()); for (JComponent item : getExtraAddOptions()) popup.add(item); } if (!demandRowsInTheTable.isEmpty()) { if (callback.getVisualizationState().isNetPlanEditable()) { if (row != -1) { if (popup.getSubElements().length > 0) popup.addSeparator(); JMenuItem removeItem = new JMenuItem("Remove " + networkElementType); removeItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { NetPlan netPlan = callback.getDesign(); try { final Demand demand = netPlan.getDemandFromId((long) itemId); demand.remove(); callback.getVisualizationState().resetPickedState(); callback.updateVisualizationAfterChanges( Collections.singleton(NetworkElementType.DEMAND)); callback.getUndoRedoNavigationManager().addNetPlanChange(); } catch (Throwable ex) { ErrorHandling.addErrorOrException(ex, getClass()); ErrorHandling.showErrorDialog("Unable to remove " + networkElementType); } } }); popup.add(removeItem); addPopupMenuAttributeOptions(e, row, itemId, popup); } JMenuItem removeItems = new JMenuItem("Remove all " + networkElementType + "s in the table"); removeItems.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { NetPlan netPlan = callback.getDesign(); try { if (rf == null) netPlan.removeAllDemands(); else for (Demand d : demandRowsInTheTable) d.remove(); callback.getVisualizationState().resetPickedState(); callback.updateVisualizationAfterChanges( Collections.singleton(NetworkElementType.DEMAND)); callback.getUndoRedoNavigationManager().addNetPlanChange(); } catch (Throwable ex) { ex.printStackTrace(); ErrorHandling.showErrorDialog(ex.getMessage(), "Unable to remove all " + networkElementType + "s"); } } }); popup.add(removeItems); List<JComponent> extraOptions = getExtraOptions(row, itemId); if (!extraOptions.isEmpty()) { if (popup.getSubElements().length > 0) popup.addSeparator(); for (JComponent item : extraOptions) popup.add(item); } } List<JComponent> forcedOptions = getForcedOptions(); if (!forcedOptions.isEmpty()) { if (popup.getSubElements().length > 0) popup.addSeparator(); for (JComponent item : forcedOptions) popup.add(item); } } popup.show(e.getComponent(), e.getX(), e.getY()); }
From source file:base.BasePlayer.AddGenome.java
static void updateEnsemblList() { try {// ww w . j a v a 2 s .c o m menu = new JPopupMenu(); area = new JTextArea(); menuscroll = new JScrollPane(); area.setFont(Main.menuFont); menu.add(menuscroll); //menu.setPreferredSize(new Dimension(menu.getFontMetrics(Main.menuFont).stringWidth("0000000000000000000000000000000000000000000000000")+Main.defaultFontSize*10, (int)menu.getFontMetrics(Main.menuFont).getHeight()*4)); menu.setPreferredSize(new Dimension(300, 200)); //area.setMaximumSize(new Dimension(300, 600)); //area.setLineWrap(true); //area.setWrapStyleWord(true); //area.setPreferredSize(new Dimension(300,200)); area.revalidate(); menuscroll.getViewport().add(area); menu.pack(); menu.show(AddGenome.treescroll, 0, 0); /* area.addMouseListener(new MouseListener() { @Override public void mouseClicked(MouseEvent arg0) { // TODO Auto-generated method stub } @Override public void mouseEntered(MouseEvent arg0) { // TODO Auto-generated method stub } @Override public void mouseExited(MouseEvent arg0) { // TODO Auto-generated method stub } @Override public void mousePressed(MouseEvent arg0) { StringBuffer buf = new StringBuffer(""); for(int i= 0; i<(int)(Math.random()*100); i++) { buf.append("O"); } AddGenome.area.append(buf.toString() +"\n"); AddGenome.area.setCaretPosition(AddGenome.area.getText().length()); AddGenome.area.revalidate(); } @Override public void mouseReleased(MouseEvent arg0) { // TODO Auto-generated method stub } });*/ FTPClient f = new FTPClient(); news = new ArrayList<String[]>(); area.append("Connecting to Ensembl...\n"); //System.out.println("Connecting to Ensembl..."); f.connect("ftp.ensembl.org"); f.enterLocalPassiveMode(); f.login("anonymous", ""); //System.out.println("Connected."); area.append("Connected.\n"); FTPFile[] files = f.listFiles("pub"); String releasedir = ""; String releasenro; for (int i = 0; i < files.length; i++) { if (files[i].isDirectory() && files[i].getName().contains("release")) { releasedir = files[i].getName(); } } files = f.listFiles("pub/" + releasedir + "/fasta/"); releasenro = releasedir.substring(releasedir.indexOf("-") + 1); area.append("Searching for new genomes"); for (int i = 0; i < files.length; i++) { if (files[i].isDirectory()) { FTPFile[] fastafiles = f .listFiles("pub/" + releasedir + "/fasta/" + files[i].getName() + "/dna/"); String[] urls = new String[5]; for (int j = 0; j < fastafiles.length; j++) { if (fastafiles[j].getName().contains(".dna.toplevel.")) { urls[0] = "ftp://ftp.ensembl.org/pub/" + releasedir + "/fasta/" + files[i].getName() + "/dna/" + fastafiles[j].getName(); String filePath = "/pub/" + releasedir + "/fasta/" + files[i].getName() + "/dna/" + fastafiles[j].getName(); f.sendCommand("SIZE", filePath); String reply = f.getReplyString().split("\\s+")[1]; urls[1] = reply; break; } } if (urls[0] == null) { continue; } FTPFile[] annofiles = f.listFiles("pub/" + releasedir + "/gff3/" + files[i].getName()); for (int j = 0; j < annofiles.length; j++) { if (annofiles[j].getName().contains("." + releasenro + ".gff3.gz")) { urls[2] = "ftp://ftp.ensembl.org/pub/" + releasedir + "/gff3/" + files[i].getName() + "/" + annofiles[j].getName(); String filePath = "/pub/" + releasedir + "/gff3/" + files[i].getName() + "/" + annofiles[j].getName(); f.sendCommand("SIZE", filePath); String reply = f.getReplyString().split("\\s+")[1]; urls[3] = reply; break; } } if (urls[2] == null) { continue; } if (files[i].getName().contains("homo_sapiens")) { urls[4] = "http://hgdownload.cse.ucsc.edu/goldenPath/hg19/database/cytoBand.txt.gz"; } else if (files[i].getName().contains("mus_musculus")) { urls[4] = "http://hgdownload.cse.ucsc.edu/goldenPath/mm10/database/cytoBand.txt.gz"; } String name = urls[0].substring(urls[0].lastIndexOf("/") + 1, urls[0].indexOf(".dna.")); //System.out.print(urls[0]+"\t" +urls[1] +"\t" +urls[2] +"\t" +urls[3]); if (genomeHash.containsKey(name) || AddGenome.removables.contains(name)) { //System.out.println(name +" already in the list."); area.append("."); } else { area.append("\nNew genome " + name + " added.\n"); AddGenome.area.setCaretPosition(AddGenome.area.getText().length()); AddGenome.area.revalidate(); //System.out.println("New reference " +name +" found."); organisms.add(name); news.add(urls); if (urls[4] != null) { //System.out.println(urls[0] +" " + urls[2] +" " +urls[4]); URL[] newurls = { new URL(urls[0]), new URL(urls[2]), new URL(urls[4]) }; genomeHash.put(name, newurls); } else { URL[] newurls = { new URL(urls[0]), new URL(urls[2]) }; genomeHash.put(name, newurls); } Integer[] sizes = { Integer.parseInt(urls[1]), Integer.parseInt(urls[3]) }; sizeHash.put(name, sizes); } /*if(urls[4] != null) { System.out.print("\t" +urls[4]); } System.out.println(); */ } } checkGenomes(); if (news.size() > 0) { try { //File file = new File(); FileWriter fw = new FileWriter(Main.genomeDir.getCanonicalPath() + "/ensembl_fetched.txt"); BufferedWriter bw = new BufferedWriter(fw); for (int i = 0; i < news.size(); i++) { for (int j = 0; j < news.get(i).length; j++) { if (news.get(i)[j] == null) { break; } if (j > 0) { bw.write("\t"); } bw.write(news.get(i)[j]); } bw.write("\n"); } bw.close(); fw.close(); } catch (IOException e) { e.printStackTrace(); } } } catch (Exception e) { Main.showError(e.getMessage(), "Error"); e.printStackTrace(); } }
From source file:canreg.client.gui.analysis.FrequenciesByYearInternalFrame.java
/** * * @param offset/*w w w . j a va2s . c o m*/ * @param evt */ public void showPopUpMenu(int offset, java.awt.event.MouseEvent evt) { JTable target = (JTable) evt.getSource(); int rowNumber = target.rowAtPoint(new Point(evt.getX(), evt.getY())); rowNumber = target.convertRowIndexToModel(rowNumber); JPopupMenu jpm = new JPopupMenu(); jpm.add(java.util.ResourceBundle .getBundle("canreg/client/gui/analysis/resources/FrequenciesByYearInternalFrame") .getString("SHOW_IN_BROWSER")); TableModel tableModel = target.getModel(); // resultTable.get // jpm.add("Column " + rowNumber +" " + tableColumnModel.getColumn(tableColumnModel.getColumnIndexAtX(evt.getX())).getHeaderValue()); int year = Integer.parseInt((String) tableModel.getValueAt(rowNumber, 0)); String filterString = "INCID >= '" + year * 10000 + "' AND INCID <'" + (year + 1) * 10000 + "'"; for (DatabaseVariablesListElement dvle : chosenVariables) { int columnNumber = tableColumnModel .getColumnIndex(canreg.common.Tools.toUpperCaseStandardized(dvle.getDatabaseVariableName())); String value = tableModel.getValueAt(rowNumber, columnNumber).toString(); filterString += " AND " + canreg.common.Tools.toUpperCaseStandardized(dvle.getDatabaseVariableName()) + " = " + dvle.getSQLqueryFormat(value); } DatabaseFilter filter = new DatabaseFilter(); filter.setFilterString(filterString); Logger.getLogger(FrequenciesByYearInternalFrame.class.getName()).log(Level.INFO, "FilterString: {0}", filterString); try { tableDatadescriptionPopUp = canreg.client.CanRegClientApp.getApplication() .getDistributedTableDescription(filter, rangeFilterPanel.getSelectedTable()); Object[][] rows = canreg.client.CanRegClientApp.getApplication().retrieveRows( tableDatadescriptionPopUp.getResultSetID(), 0, MAX_ENTRIES_DISPLAYED_ON_RIGHT_CLICK); String[] variableNames = tableDatadescriptionPopUp.getColumnNames(); for (Object[] row : rows) { String line = ""; int i = 0; for (Object obj : row) { if (obj != null) { line += variableNames[i] + ": " + obj.toString() + ", "; } i++; } jpm.add(line); } } catch (SQLException ex) { Logger.getLogger(FrequenciesByYearInternalFrame.class.getName()).log(Level.SEVERE, null, ex); } catch (RemoteException ex) { Logger.getLogger(FrequenciesByYearInternalFrame.class.getName()).log(Level.SEVERE, null, ex); } catch (SecurityException ex) { Logger.getLogger(FrequenciesByYearInternalFrame.class.getName()).log(Level.SEVERE, null, ex); } catch (DistributedTableDescriptionException ex) { Logger.getLogger(FrequenciesByYearInternalFrame.class.getName()).log(Level.SEVERE, null, ex); } catch (UnknownTableException ex) { Logger.getLogger(FrequenciesByYearInternalFrame.class.getName()).log(Level.SEVERE, null, ex); } int cases = (Integer) tableModel.getValueAt(rowNumber, tableColumnModel.getColumnIndex("CASES")); if (MAX_ENTRIES_DISPLAYED_ON_RIGHT_CLICK < cases) { jpm.add("..."); } MenuItem menuItem = new MenuItem(); jpm.show(target, evt.getX(), evt.getY()); }
From source file:com.net2plan.gui.utils.viewEditTopolTables.specificTables.AdvancedJTable_node.java
@Override public void doPopup(final MouseEvent e, final int row, final Object itemId) { JPopupMenu popup = new JPopupMenu(); final ITableRowFilter rf = callback.getVisualizationState().getTableRowFilter(); final List<Node> rowsInTheTable = getVisibleElementsInTable(); /* Add the popup menu option of the filters */ final List<Node> selectedNodes = (List<Node>) (List<?>) getSelectedElements().getFirst(); if (!selectedNodes.isEmpty()) { final JMenu submenuFilters = new JMenu("Filters"); final JMenuItem filterKeepElementsAffectedThisLayer = new JMenuItem( "This layer: Keep elements associated to this node traffic"); final JMenuItem filterKeepElementsAffectedAllLayers = new JMenuItem( "All layers: Keep elements associated to this node traffic"); submenuFilters.add(filterKeepElementsAffectedThisLayer); if (callback.getDesign().getNumberOfLayers() > 1) submenuFilters.add(filterKeepElementsAffectedAllLayers); filterKeepElementsAffectedThisLayer.addActionListener(new ActionListener() { @Override//from w ww.j a va 2s . co m public void actionPerformed(ActionEvent e) { if (selectedNodes.size() > 1) throw new RuntimeException(); TBFToFromCarriedTraffic filter = new TBFToFromCarriedTraffic(selectedNodes.get(0), callback.getDesign().getNetworkLayerDefault(), true); callback.getVisualizationState().updateTableRowFilter(filter); callback.updateVisualizationJustTables(); } }); filterKeepElementsAffectedAllLayers.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (selectedNodes.size() > 1) throw new RuntimeException(); TBFToFromCarriedTraffic filter = new TBFToFromCarriedTraffic(selectedNodes.get(0), callback.getDesign().getNetworkLayerDefault(), false); callback.getVisualizationState().updateTableRowFilter(filter); callback.updateVisualizationJustTables(); } }); popup.add(submenuFilters); popup.addSeparator(); } if (callback.getVisualizationState().isNetPlanEditable()) { popup.add(getAddOption()); for (JComponent item : getExtraAddOptions()) popup.add(item); } if (!rowsInTheTable.isEmpty()) { if (callback.getVisualizationState().isNetPlanEditable()) { if (row != -1) { if (popup.getSubElements().length > 0) popup.addSeparator(); JMenuItem removeItem = new JMenuItem("Remove " + networkElementType); removeItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { callback.getDesign().getNodeFromId((long) itemId).remove(); callback.getVisualizationState() .recomputeCanvasTopologyBecauseOfLinkOrNodeAdditionsOrRemovals(); callback.updateVisualizationAfterChanges(Sets.newHashSet(NetworkElementType.NODE)); callback.getUndoRedoNavigationManager().addNetPlanChange(); } catch (Throwable ex) { ErrorHandling.addErrorOrException(ex, getClass()); ErrorHandling.showErrorDialog("Unable to remove " + networkElementType); } } }); popup.add(removeItem); addPopupMenuAttributeOptions(e, row, itemId, popup); } JMenuItem removeItems = new JMenuItem("Remove all " + networkElementType + "s in the table"); removeItems.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { NetPlan netPlan = callback.getDesign(); try { if (rf == null) netPlan.removeAllNodes(); else for (Node n : rowsInTheTable) n.remove(); callback.getVisualizationState() .recomputeCanvasTopologyBecauseOfLinkOrNodeAdditionsOrRemovals(); callback.updateVisualizationAfterChanges(Sets.newHashSet(NetworkElementType.NODE)); callback.getUndoRedoNavigationManager().addNetPlanChange(); } catch (Throwable ex) { ex.printStackTrace(); ErrorHandling.showErrorDialog(ex.getMessage(), "Unable to remove all " + networkElementType + "s"); } } }); popup.add(removeItems); List<JComponent> extraOptions = getExtraOptions(row, itemId); if (!extraOptions.isEmpty()) { if (popup.getSubElements().length > 0) popup.addSeparator(); for (JComponent item : extraOptions) popup.add(item); } } List<JComponent> forcedOptions = getForcedOptions(); if (!forcedOptions.isEmpty()) { if (popup.getSubElements().length > 0) popup.addSeparator(); for (JComponent item : forcedOptions) popup.add(item); } } popup.show(e.getComponent(), e.getX(), e.getY()); }
From source file:gdt.jgui.entity.JEntityDigestDisplay.java
private JPopupMenu getFacetComponentMenu() { JPopupMenu popup = new JPopupMenu(); JMenuItem openItem = new JMenuItem("Open"); popup.add(openItem);/*from w w w. j a v a 2s .com*/ openItem.setHorizontalTextPosition(JMenuItem.RIGHT); openItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { //System.out.println("JEmailFacetOpenItem:edit:digest locator="+digestLocator$); try { Properties locator = Locator.toProperties(selection$); String entihome$ = locator.getProperty(Entigrator.ENTIHOME); String entityKey$ = locator.getProperty(EntityHandler.ENTITY_KEY); JEntityFacetPanel efp = new JEntityFacetPanel(); String efpLocator$ = efp.getLocator(); efpLocator$ = Locator.append(efpLocator$, Entigrator.ENTIHOME, entihome$); efpLocator$ = Locator.append(efpLocator$, EntityHandler.ENTITY_KEY, entityKey$); //System.out.println("JEmailFacetOpenItem:edit:text editor="+teLocator$); JConsoleHandler.execute(console, efpLocator$); } catch (Exception ee) { Logger.getLogger(JEntityDigestDisplay.class.getName()).info(ee.toString()); } } }); return popup; }
From source file:com.diversityarrays.kdxplore.trials.TrialOverviewPanel.java
public TrialOverviewPanel(String title, OfflineData offdata, TrialExplorerManager manager, FileListTransferHandler flth, MessagePrinter mp, final Closure<List<Trial>> onTrialSelected) { super(new BorderLayout()); offlineData = offdata;/*from w w w .ja va2s.co m*/ KdxploreDatabase kdxdb = offlineData.getKdxploreDatabase(); if (kdxdb != null) { kdxdb.addEntityChangeListener(trialChangeListener); kdxdb.addEntityChangeListener(traitChangeListener); } this.messagePrinter = mp; TableTransferHandler tth = TableTransferHandler.initialiseForCopySelectAll(trialsTable, true); trialsTable.setTransferHandler(new ChainingTransferHandler(flth, tth)); trialsTable.setAutoCreateRowSorter(true); trialsTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { List<Trial> selectedTrials = getSelectedTrials(); if (selectedTrials.size() == 1) { trialTraitsTableModel.setSelectedTrial(selectedTrials.get(0)); } else { trialTraitsTableModel.setSelectedTrial(null); } onTrialSelected.execute(selectedTrials); } } }); trialsTable.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2 && SwingUtilities.isLeftMouseButton(e)) { fireEditCommand(e); } } }); GuiUtil.setVisibleRowCount(trialsTable, MAX_INITIAL_VISIBLE_TRIAL_ROWS); offlineData.addOfflineDataChangeListener(offlineDataChangeListener); trialTableModel.addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent e) { updateRefreshAction(); } }); trialTraitsTableModel.addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent e) { updateAddTraitAction(); updateRemoveTraitAction(); updateScoringOrderAction(); } }); trialTraitsTable.addMouseListener(new MouseAdapter() { List<Trait> selectedTraits; JPopupMenu popupMenu; Action showTraitsAction = new AbstractAction("Select in Trait Explorer") { @Override public void actionPerformed(ActionEvent e) { manager.showTraitsInTraitExplorer(selectedTraits); } }; @Override public void mouseClicked(MouseEvent e) { if (SwingUtilities.isLeftMouseButton(e) && 2 == e.getClickCount()) { // Start editing the Trait e.consume(); int vrow = trialTraitsTable.rowAtPoint(e.getPoint()); if (vrow >= 0) { int mrow = trialTraitsTable.convertRowIndexToModel(vrow); if (mrow >= 0) { Trait trait = trialTraitsTableModel.getTraitAt(mrow); if (trait != null) { traitExplorer.startEditing(trait); ; } } } } else if (SwingUtilities.isRightMouseButton(e) && 1 == e.getClickCount()) { // Select the traits in the traitExplorer e.consume(); List<Integer> modelRows = GuiUtil.getSelectedModelRows(trialTraitsTable); if (!modelRows.isEmpty()) { selectedTraits = modelRows.stream().map(trialTraitsTableModel::getTraitAt) .collect(Collectors.toList()); if (popupMenu == null) { popupMenu = new JPopupMenu(); popupMenu.add(showTraitsAction); } Point pt = e.getPoint(); popupMenu.show(trialTraitsTable, pt.x, pt.y); } } } }); trialTraitsTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { updateRemoveTraitAction(); } } }); updateAddTraitAction(); updateRemoveTraitAction(); updateScoringOrderAction(); updateRefreshAction(); KDClientUtils.initAction(ImageId.REFRESH_24, refreshTrialTraitsAction, "Refresh"); KDClientUtils.initAction(ImageId.MINUS_GOLD_24, removeTraitAction, "Remove selected Traits"); KDClientUtils.initAction(ImageId.PLUS_BLUE_24, addTraitAction, "Add Traits to Trial"); KDClientUtils.initAction(ImageId.TRAIT_ORDER_24, setScoringOrderAction, "Define Trait Scoring Order"); Box buttons = Box.createHorizontalBox(); buttons.add(new JButton(setScoringOrderAction)); buttons.add(Box.createHorizontalGlue()); buttons.add(new JButton(addTraitAction)); buttons.add(new JButton(removeTraitAction)); buttons.add(Box.createHorizontalStrut(10)); buttons.add(refreshTrialTraitsButton); JPanel traitsPanel = new JPanel(new BorderLayout()); traitsPanel.add(GuiUtil.createLabelSeparator("Uses Traits", buttons), BorderLayout.NORTH); traitsPanel.add(new PromptScrollPane(trialTraitsTable, "If the (single) selected Trial has Traits they will appear here"), BorderLayout.CENTER); JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, new JScrollPane(trialsTable), traitsPanel); splitPane.setResizeWeight(0.5); add(splitPane, BorderLayout.CENTER); }