List of usage examples for javax.swing JPopupMenu add
public JMenuItem add(Action a)
Action
object. From source file:org.executequery.gui.ExportResultSetPanel.java
private void init() throws Exception { fileNameField = WidgetFactory.createTextField(); connectionsCombo = WidgetFactory.createComboBox(); String[] delims = { "|", ",", ";", "#" }; delimiterCombo = WidgetFactory.createComboBox(delims); delimiterCombo.setEditable(true);//from ww w . j a v a 2s .c o m combosGroup = new TableSelectionCombosGroup(connectionsCombo); includeColumNamesCheck = new JCheckBox("Include column names as first row"); sqlText = new SimpleSqlTextPanel(); // sqlText.getTextPane().setBackground(Color.WHITE); sqlText.setBorder(null); sqlText.setScrollPaneBorder(BorderFactory.createMatteBorder(1, 1, 0, 1, UIUtils.getDefaultBorderColour())); statusBar = new SqlTextPaneStatusBar(); JPanel sqlPanel = new JPanel(new BorderLayout()); sqlPanel.add(sqlText, BorderLayout.CENTER); sqlPanel.add(statusBar, BorderLayout.SOUTH); statusBar.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 1)); outputPanel = new LoggingOutputPanel(); FlatSplitPane splitPane = new FlatSplitPane(JSplitPane.VERTICAL_SPLIT, sqlPanel, outputPanel); splitPane.setResizeWeight(0.5); splitPane.setDividerLocation(0.8); splitPane.setDividerSize(5); JButton button = WidgetFactory.createInlineFieldButton("Browse"); button.setActionCommand("browse"); button.addActionListener(this); button.setMnemonic('r'); JPanel mainPanel = new JPanel(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridy = 0; gbc.gridx = 0; gbc.gridheight = 1; gbc.insets.top = 5; gbc.insets.bottom = 5; gbc.insets.right = 5; gbc.insets.left = 5; gbc.anchor = GridBagConstraints.NORTHWEST; mainPanel.add(new JLabel("Connection:"), gbc); gbc.gridx = 1; gbc.weightx = 1.0; gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.fill = GridBagConstraints.HORIZONTAL; mainPanel.add(connectionsCombo, gbc); gbc.insets.left = 5; gbc.gridy++; gbc.gridx = 0; gbc.weightx = 0; gbc.gridwidth = 1; gbc.insets.top = 0; mainPanel.add(new JLabel("Data Delimiter:"), gbc); gbc.gridx = 1; gbc.weightx = 1.0; gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.fill = GridBagConstraints.HORIZONTAL; mainPanel.add(delimiterCombo, gbc); gbc.gridy++; gbc.gridx = 0; gbc.weightx = 0; gbc.gridwidth = 1; gbc.insets.top = 2; mainPanel.add(new JLabel("Output File:"), gbc); gbc.gridx = 1; gbc.weightx = 1.0; gbc.fill = GridBagConstraints.HORIZONTAL; mainPanel.add(fileNameField, gbc); gbc.gridx = 2; gbc.weightx = 0; gbc.insets.left = 0; gbc.fill = GridBagConstraints.HORIZONTAL; mainPanel.add(button, gbc); gbc.gridy++; gbc.gridx = 0; gbc.weightx = 0; gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.insets.top = 2; gbc.insets.left = 5; mainPanel.add(includeColumNamesCheck, gbc); gbc.gridy++; gbc.insets.bottom = 10; mainPanel.add(new JLabel(instructionNote()), gbc); gbc.gridy++; gbc.gridx = 0; gbc.weighty = 1.0; gbc.weightx = 1.0; gbc.insets.top = 0; gbc.insets.left = 5; gbc.insets.bottom = 5; gbc.fill = GridBagConstraints.BOTH; mainPanel.add(splitPane, gbc); mainPanel.setBorder(BorderFactory.createEtchedBorder()); int minimumButtonWidth = 85; executeButton = new MinimumWidthActionButton(minimumButtonWidth, this, "Execute", "executeAndExport"); stopButton = new MinimumWidthActionButton(minimumButtonWidth, this, "Stop", "stop"); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 2, 5)); buttonPanel.add(executeButton); buttonPanel.add(stopButton); stopButton.setEnabled(false); add(mainPanel, BorderLayout.CENTER); add(buttonPanel, BorderLayout.SOUTH); setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); // register as a keyword and connection listener EventMediator.registerListener(this); JTextPane textPane = sqlText.getTextPane(); ActionMap actionMap = textPane.getActionMap(); String actionKey = "executeQueryAction"; actionMap.put(actionKey, executeQueryAction); InputMap inputMap = textPane.getInputMap(); inputMap.put(EXECUTE_KEYSTROKE, actionKey); JPopupMenu popupMenu = sqlText.getPopup(); popupMenu.addSeparator(); popupMenu.add(executeQueryAction); }
From source file:org.gofleet.module.routing.RoutingMap.java
@Override protected JPopupMenu getContextMenu() { JPopupMenu menu = new JPopupMenu(); menu.setBackground(Color.decode("#E8EDF6")); String mapMenuTituloPlanning = i18n.getString("map.menu.titulo.planning"); String mapMenuNewPlanning = i18n.getString("map.menu.new.planning"); // Ttulo/*w w w. j av a 2s .com*/ final JMenuItem titulo = new JMenuItem(mapMenuTituloPlanning); titulo.setFont(LogicConstants.deriveBoldFont(10.0f)); titulo.setBackground(Color.decode("#A4A4A4")); titulo.setFocusable(false); menu.add(titulo); // New Planning final JMenuItem to = new JMenuItem(mapMenuNewPlanning, KeyEvent.VK_F6); to.setIcon(LogicConstants.getIcon("menucontextual_icon_destinoruta")); to.addActionListener(this); menu.add(to); menu.addSeparator(); return menu; }
From source file:org.isatools.isacreator.filechooser.FileChooserUI.java
/** * Create the Navigation Tree panel/* www .j a va 2s .c om*/ * * @return @see JPanel containing the navigation tree to browse a file system. */ private JPanel createNavTree() { JPanel treeContainer = new JPanel(new BorderLayout()); treeContainer.setBackground(UIHelper.BG_COLOR); treeContainer .setBorder(new TitledBorder(UIHelper.GREEN_ROUNDED_BORDER, "", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, UIHelper.VER_12_BOLD, UIHelper.DARK_GREEN_COLOR)); JPanel navigationControls = new JPanel(); navigationControls.setLayout(new BoxLayout(navigationControls, BoxLayout.LINE_AXIS)); navigationControls.setOpaque(false); final JLabel navToParentDir = new JLabel(upIcon); navToParentDir.setOpaque(false); navToParentDir.addMouseListener(new CommonMouseAdapter() { public void mousePressed(MouseEvent event) { super.mousePressed(event); navToParentDir.setIcon(upIcon); try { updateTree(fileBrowser.getParentDirectory()); } catch (IOException e) { errorAction("problem occurred!"); } } public void mouseEntered(MouseEvent event) { super.mouseEntered(event); navToParentDir.setIcon(upIconOver); } public void mouseExited(MouseEvent event) { super.mouseExited(event); navToParentDir.setIcon(upIcon); } }); navigationControls.add(navToParentDir); navigationControls.add(Box.createHorizontalStrut(5)); final JLabel navToHomeDir = new JLabel(homeIcon); navToHomeDir.setOpaque(false); navToHomeDir.addMouseListener(new CommonMouseAdapter() { public void mousePressed(MouseEvent event) { super.mousePressed(event); navToHomeDir.setIcon(homeIcon); try { updateTree(fileBrowser.getHomeDirectory()); } catch (IOException e) { if (e instanceof ConnectionException) { status.setText("<html>status: not connected!</html>"); } FileBrowserTreeNode defaultFTPNode = new FileBrowserTreeNode("problem occurred!", false, FileBrowserTreeNode.DIRECTORY); updateTree(defaultFTPNode); } } public void mouseEntered(MouseEvent event) { super.mouseEntered(event); navToHomeDir.setIcon(homeIconOver); } public void mouseExited(MouseEvent event) { super.mouseExited(event); navToHomeDir.setIcon(homeIcon); } }); navigationControls.add(navToHomeDir); navigationControls.add(Box.createGlue()); treeContainer.add(navigationControls, BorderLayout.NORTH); try { treeModel = new DefaultTreeModel(fileBrowser.getHomeDirectory()); directoryTree = new JTree(treeModel); directoryTree.setFont(UIHelper.VER_11_PLAIN); directoryTree.setCellRenderer(new FileSystemTreeCellRenderer()); } catch (IOException e) { FileBrowserTreeNode defaultFTPNode = new FileBrowserTreeNode("problem occurred!", false, FileBrowserTreeNode.DIRECTORY); updateTree(defaultFTPNode); } directoryTree.addMouseListener(new CommonMouseAdapter() { public void mousePressed(MouseEvent event) { super.mousePressed(event); int selRow = directoryTree.getRowForLocation(event.getX(), event.getY()); TreePath selPath = directoryTree.getPathForLocation(event.getX(), event.getY()); if (selRow != -1) { final FileBrowserTreeNode node = (FileBrowserTreeNode) selPath.getLastPathComponent(); if (SwingUtilities.isLeftMouseButton(event)) { if (event.getClickCount() == 2) { if ((node.getType() == FileBrowserTreeNode.DIRECTORY) && (node.getLevel() != 0)) { String newPath; if (fileBrowser instanceof LocalBrowser) { newPath = ((File) fileBrowser.getDirFiles().get(node.toString())).getPath(); } else { newPath = node.toString(); } updateTree(fileBrowser.changeDirectory(newPath)); } // else, if a leaf node, then add file to to list if (node.isLeaf() && (node.getType() != FileBrowserTreeNode.DIRECTORY)) { String extension = node.toString().substring(node.toString().lastIndexOf(".") + 1) .trim().toUpperCase(); FileChooserFile toAdd = null; for (Object o : fileBrowser.getFileMap().get(extension)) { String fileName; String filePath; if (fileBrowser instanceof LocalBrowser) { File file = (File) o; fileName = file.getName(); filePath = file.getPath(); if (fileName.equals(node.toString())) { toAdd = new CustomFile(filePath); break; } } else { FTPFile ftpFile = (FTPFile) o; fileName = ftpFile.getName(); filePath = fileBrowser.getAbsoluteWorkingDirectory() + File.separator + ftpFile.getName(); if (fileName.equals(node.toString())) { toAdd = new CustomFTPFile(ftpFile, filePath); break; } } } if (toAdd != null && !checkIfInList(toAdd)) { selectedFiles.addFileItem(toAdd); } } } } else { if ((node.getType() == FileBrowserTreeNode.DIRECTORY) && (node.getLevel() != 0)) { // show popup to add the directory to the selected files JPopupMenu popup = new JPopupMenu(); JMenuItem addDirectory = new JMenuItem("add directory"); addDirectory.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { Object fileToAdd = fileBrowser.getDirFiles().get(node.toString()); FileChooserFile toAdd; if (fileToAdd instanceof File) { toAdd = new CustomFile(((File) fileToAdd).getPath()); } else { FTPFile ftpFile = (FTPFile) fileToAdd; String filePath = fileBrowser.getAbsoluteWorkingDirectory() + File.separator + ftpFile.getName(); toAdd = new CustomFTPFile(ftpFile, filePath); } if (!checkIfInList(toAdd)) { selectedFiles.addDirectoryItem(toAdd); } } }); popup.add(addDirectory); popup.show(directoryTree, event.getX(), event.getY()); } } } } }); BasicTreeUI ui = new BasicTreeUI() { public Icon getCollapsedIcon() { return null; } public Icon getExpandedIcon() { return null; } }; directoryTree.setUI(ui); directoryTree.setFont(UIHelper.VER_12_PLAIN); JScrollPane treeScroll = new JScrollPane(directoryTree, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); treeScroll.setPreferredSize(new Dimension(300, 200)); treeScroll.setBorder(new EmptyBorder(0, 0, 0, 0)); treeContainer.add(treeScroll, BorderLayout.CENTER); IAppWidgetFactory.makeIAppScrollPane(treeScroll); return treeContainer; }
From source file:org.javaswift.cloudie.CloudiePanel.java
private JPopupMenu createContainerPopupMenu() { JPopupMenu pop = new JPopupMenu("Container"); pop.add(new JMenuItem(containerRefreshAction)); pop.add(new JMenuItem(containerViewMetaData)); pop.addSeparator();//from w w w. j a v a 2s. c om pop.add(new JMenuItem(containerCreateAction)); pop.add(new JMenuItem(containerDeleteAction)); pop.addSeparator(); pop.add(new JMenuItem(containerEmptyAction)); pop.addSeparator(); pop.add(new JMenuItem(containerPurgeAction)); return pop; }
From source file:org.javaswift.cloudie.CloudiePanel.java
/** * @return/* w ww . ja v a 2 s .com*/ */ private JPopupMenu createStoredObjectPopupMenu() { JPopupMenu pop = new JPopupMenu("StoredObject"); pop.add(new JMenuItem(storedObjectPreviewAction)); pop.add(new JMenuItem(storedObjectOpenAction)); pop.add(new JMenuItem(storedObjectViewMetaData)); pop.addSeparator(); pop.add(new JMenuItem(storedObjectCreateAction)); pop.add(new JMenuItem(storedObjectDownloadAction)); pop.addSeparator(); pop.add(new JMenuItem(storedObjectDeleteAction)); return pop; }
From source file:org.languagetool.gui.ConfigurationDialog.java
@NotNull private MouseAdapter getMouseAdapter() { return new MouseAdapter() { private void handlePopupEvent(MouseEvent e) { JTree tree = (JTree) e.getSource(); TreePath path = tree.getPathForLocation(e.getX(), e.getY()); if (path == null) { return; }// w ww .ja va 2s . c om DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent(); TreePath[] paths = tree.getSelectionPaths(); boolean isSelected = false; if (paths != null) { for (TreePath selectionPath : paths) { if (selectionPath.equals(path)) { isSelected = true; } } } if (!isSelected) { tree.setSelectionPath(path); } if (node.isLeaf()) { JPopupMenu popup = new JPopupMenu(); JMenuItem aboutRuleMenuItem = new JMenuItem(messages.getString("guiAboutRuleMenu")); aboutRuleMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { RuleNode node = (RuleNode) tree.getSelectionPath().getLastPathComponent(); Rule rule = node.getRule(); Language lang = config.getLanguage(); if (lang == null) { lang = Languages.getLanguageForLocale(Locale.getDefault()); } Tools.showRuleInfoDialog(tree, messages.getString("guiAboutRuleTitle"), rule.getDescription(), rule, rule.getUrl(), messages, lang.getShortCodeWithCountryAndVariant()); } }); popup.add(aboutRuleMenuItem); popup.show(tree, e.getX(), e.getY()); } } @Override public void mousePressed(MouseEvent e) { if (e.isPopupTrigger()) { handlePopupEvent(e); } } @Override public void mouseReleased(MouseEvent e) { if (e.isPopupTrigger()) { handlePopupEvent(e); } } }; }
From source file:org.languagetool.gui.LanguageToolSupport.java
private void showPopup(MouseEvent event) { if (documentSpans.isEmpty() && languageTool.getDisabledRules().isEmpty()) { //No errors and no disabled Rules return;/* w w w .j a va2 s . c om*/ } int offset = this.textComponent.viewToModel(event.getPoint()); Span span = getSpan(offset); JPopupMenu popup = new JPopupMenu("Grammar Menu"); if (span != null) { JLabel msgItem = new JLabel("<html>" + span.msg.replace("<suggestion>", "<b>").replace("</suggestion>", "</b>") + "</html>"); msgItem.setToolTipText(span.desc.replace("<suggestion>", "").replace("</suggestion>", "")); msgItem.setBorder(new JMenuItem().getBorder()); popup.add(msgItem); popup.add(new JSeparator()); for (String r : span.replacement) { ReplaceMenuItem item = new ReplaceMenuItem(r, span); popup.add(item); item.addActionListener(actionListener); } popup.add(new JSeparator()); JMenuItem moreItem = new JMenuItem(messages.getString("guiMore")); moreItem.addActionListener(e -> showDialog(textComponent, span.msg, span.desc, span.rule, span.url)); popup.add(moreItem); JMenuItem ignoreItem = new JMenuItem(messages.getString("guiTurnOffRule")); ignoreItem.addActionListener(e -> disableRule(span.rule.getId())); popup.add(ignoreItem); popup.applyComponentOrientation(ComponentOrientation.getOrientation(Locale.getDefault())); } List<Rule> disabledRules = getDisabledRules(); if (!disabledRules.isEmpty()) { JMenu activateRuleMenu = new JMenu(messages.getString("guiActivateRule")); addDisabledRulesToMenu(disabledRules, activateRuleMenu); popup.add(activateRuleMenu); } if (span != null) { textComponent.setCaretPosition(span.start); textComponent.moveCaretPosition(span.end); } popup.addPopupMenuListener(new PopupMenuListener() { @Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { } @Override public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { } @Override public void popupMenuCanceled(PopupMenuEvent e) { if (span != null) { textComponent.setCaretPosition(span.start); } } }); popup.show(textComponent, event.getPoint().x, event.getPoint().y); }
From source file:org.ngrinder.recorder.ui.RecordingControlPanel.java
private JPopupMenu createFilterTablePopUp() { final JPopupMenu result = new JPopupMenu(); JMenuItem excludeSelectedHosts = new JMenuItem("Exclude selected hosts", KeyEvent.VK_U); result.add(excludeSelectedHosts); excludeSelectedHosts.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int[] selectedRows = createFilterTables.getSelectedRows(); ((FilterTableModel) createFilterTables.getModel()).setSelection(selectedRows, false); }/*from ww w . j a v a 2 s . com*/ }); JMenuItem includeSelectedHost = new JMenuItem("Include selected hosts", KeyEvent.VK_I); result.add(includeSelectedHost); includeSelectedHost.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int[] selectedRows = createFilterTables.getSelectedRows(); ((FilterTableModel) createFilterTables.getModel()).setSelection(selectedRows, true); } }); result.addSeparator(); JMenuItem deleteSelectedHost = new JMenuItem("Deleted selected hosts", KeyEvent.VK_D); result.add(deleteSelectedHost); deleteSelectedHost.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int[] selectedRows = createFilterTables.getSelectedRows(); ((FilterTableModel) createFilterTables.getModel()).removeRows(selectedRows); } }); return result; }
From source file:org.ngrinder.recorder.ui.RecordingControlPanel.java
/** * Create Filter Button Panel.//w ww .j a va2s . co m * * @return filter button panel */ protected JPanel createFilterButtonPanel() { JPanel panel = new JPanel(); panel.setLayout(new FlowLayout()); panel.add(createSimpleTextButton("Unselect All", new AbstractAction() { /** UUID */ private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { for (EndPoint each : connectionFilter.getConnectionEndPoints()) { connectionFilter.setFilter(each, true); } } })); DropDownButton resetDropDownButton = createSimpleDropDownButton("Reset", null); panel.add(resetDropDownButton); JPopupMenu menu = new JPopupMenu(); menu.add(createMenuItem("Clear all recording", new AbstractAction() { /** UUID */ private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { messageBus.getPublisher(Topics.RESET) .propertyChange(new PropertyChangeEvent(RecordingControlPanel.this, "RESET", null, null)); connectionFilter.makeZeroCount(); } })); menu.add(createMenuItem("Clear all filters", new AbstractAction() { /** UUID */ private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { connectionFilter.reset(); } })); menu.add(createMenuItem("Clear connection count", new AbstractAction() { /** UUID */ private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { connectionFilter.makeZeroCount(); } })); menu.add(createMenuItem("Reset browser cache", new AbstractAction() { /** UUID */ private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { BrowserServices browserServices = BrowserServices.getInstance(); for (BrowserType type : BrowserFactoryEx.getSupportedBrowser()) { clearCacheIfSupported(browserServices, type); } } private void clearCacheIfSupported(BrowserServices browserServices, BrowserType type) { if (type.isSupported()) { try { browserServices.getCacheStorage(type).clearCache(); } catch (Exception e) { NoOp.noOp(); } } } })); menu.add(createMenuItem("Reset cookies", new AbstractAction() { /** UUID */ private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { BrowserServices browserServices = BrowserServices.getInstance(); for (BrowserType type : BrowserFactoryEx.getSupportedBrowser()) { clearCookieIfSupported(browserServices, type); } } private void clearCookieIfSupported(BrowserServices browserServices, BrowserType type) { if (type.isSupported()) { try { HttpCookieStorage cookieStorage = browserServices.getCookieStorage(type); List<HttpCookie> cookies = cookieStorage.getCookies(); cookieStorage.deleteCookie(cookies); } catch (Exception e) { NoOp.noOp(); } } } })); resetDropDownButton.setMenu(menu); return panel; }
From source file:org.nuclos.client.customcomp.resplan.ResPlanPanel.java
private void initJResPlan() { resPlan = new JResPlanComponent<Collectable, Date, Collectable, Collectable>(resPlanModel, timeModel); resPlan.getTimelineHeader().setCategoryModel(timeGranularityModel.getSelectedItem()); resPlan.addMouseListener(new AbstractJPopupMenuListener() { @Override//from w w w .ja v a 2s . co m protected JPopupMenu getJPopupMenu(MouseEvent evt) { JPopupMenu popupMenu = new JPopupMenu(); Point pt = evt.getPoint(); Area<Collectable, Date> blankSelection = resPlan.getSelectedBlankArea(); if (blankSelection != null) { popupMenu.add(new AddAction(blankSelection.getResource(), blankSelection.getInterval())); } else { popupMenu.add(new AddAction(resPlan.getResourceAt(pt), resPlan.getTimeIntervalAt(pt))); } List<Collectable> selectedEntries = selectEntriesForEvent(pt); List<Collectable> selectedRelations = selectRelationsForEvent(pt); if (resPlan.isEditable() && (!selectedEntries.isEmpty() || !selectedRelations.isEmpty())) { JMenuItem menuItem = popupMenu.add(removeAction); boolean enabled = true; for (Collectable clct : selectedEntries) { if (!resPlanModel.isRemoveEntryAllowed(clct)) { enabled = false; break; } } for (Collectable clct : selectedRelations) { if (!resPlanModel.isRemoveRelationAllowed(clct)) { enabled = false; break; } } // Note: just change the state of the menu item (and leave the action as is) menuItem.setEnabled(enabled); } if (!selectedEntries.isEmpty() || !selectedRelations.isEmpty()) { popupMenu.add(detailsAction); } if (selectedEntries.size() == 1 && resPlanModel.getRelationEntity() != null && resPlanModel.isCreateRelationAllowed()) { popupMenu.addSeparator(); if (resPlan.getRelateBegin() != null) { Collectable to = selectedEntries.get(0); if (to != resPlan.getRelateBegin()) { popupMenu.add(relateFinishAction); } } popupMenu.add(relateBeginAction); } return popupMenu; } private List<Collectable> selectEntriesForEvent(Point pt) { List<Collectable> selection = resPlan.getSelectedEntries(); Collectable entryAt = resPlan.getEntryAt(pt); if (entryAt != null && (selection.isEmpty() || !selection.contains(entryAt))) { selection = Collections.singletonList(entryAt); resPlan.setSelectedEntries(selection); } return selection; } private List<Collectable> selectRelationsForEvent(Point pt) { List<Collectable> selection = resPlan.getSelectedRelations(); Collectable relAt = resPlan.getRelationAt(pt); if (relAt != null && (selection.isEmpty() || !selection.contains(relAt))) { selection = Collections.singletonList(relAt); resPlan.setSelectedRelations(selection); } return selection; } @Override public void mouseClicked(MouseEvent evt) { if (evt.getClickCount() == 2) { Collectable clct = resPlan.getEntryAt(evt.getPoint()); if (clct == null) { clct = resPlan.getRelationAt(evt.getPoint()); if (clct != null) { runDetailsCollectable(resPlanModel.getRelationEntity().getEntityName(), clct); } } else { runDetailsCollectable(resPlanModel.getEntryEntity().getEntityName(), clct); } evt.consume(); } } }); resPlan.getResourceHeader().addMouseListener(new AbstractJPopupMenuListener() { @Override public void mouseClicked(MouseEvent evt) { if (evt.getClickCount() == 2) { Collectable clct = resPlan.getResourceHeader().getValueAt(evt.getPoint()); runDetailsCollectable(resPlanModel.getResourceEntity().getEntityName(), clct); evt.consume(); } } @Override protected JPopupMenu getJPopupMenu(MouseEvent evt) { final Collectable clct = resPlan.getResourceHeader().getValueAt(evt.getPoint()); if (clct != null) { JPopupMenu popupMenu = new JPopupMenu(); popupMenu.add(new AbstractAction( SpringLocaleDelegate.getInstance().getText("nuclos.resplan.action.showDetails")) { @Override public void actionPerformed(ActionEvent e) { runDetailsCollectable(resPlanModel.getResourceEntity().getEntityName(), clct); } }); return popupMenu; } return null; } }); Date start = DateUtils.addDays(DateUtils.getPureDate(new Date()), -5); Date end = DateUtils.addDays(start, 30); resPlan.setTimeHorizon(new Interval<Date>(start, end)); }