List of usage examples for javax.swing JPopupMenu addSeparator
public void addSeparator()
From source file:org.tinymediamanager.ui.tvshows.TvShowPanel.java
/** * Builds the menu.//from w w w .j av a 2 s . c om */ private void buildMenu() { menu.setMnemonic(KeyEvent.VK_V); // menu items JMenuItem menuItem = menu.add(actionUpdateDatasources2); menuItem.setMnemonic(KeyEvent.VK_U); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_U, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK)); menu.addSeparator(); JMenu menuScrape = new JMenu(BUNDLE.getString("Button.scrape")); //$NON-NLS-1$ menuScrape.setMnemonic(KeyEvent.VK_S); menuItem = menuScrape.add(actionScrape2); menuItem.setMnemonic(KeyEvent.VK_S); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK)); menuItem = menuScrape.add(actionScrapeSelected); menuItem.setMnemonic(KeyEvent.VK_F); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_F, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK)); menuItem = menuScrape.add(actionScrapeNewItems); menuItem.setMnemonic(KeyEvent.VK_N); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK)); menu.add(menuScrape); JMenu menuEdit = new JMenu(BUNDLE.getString("Button.edit")); //$NON-NLS-1$ menuEdit.setMnemonic(KeyEvent.VK_E); menuItem = menuEdit.add(actionEdit2); menuItem.setMnemonic(KeyEvent.VK_E); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_E, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK)); menuItem = menuEdit.add(actionBatchEdit); menuItem.setMnemonic(KeyEvent.VK_B); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_B, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK)); menuItem = menuEdit.add(actionSetWatchedFlag); menuItem.setMnemonic(KeyEvent.VK_W); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_W, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK)); menuItem = menuEdit.add(actionChangeSeasonPoster2); menuItem.setMnemonic(KeyEvent.VK_S); menuEdit.add(actionChangeToDvdOrder); menuEdit.add(actionChangeToAiredOrder); menu.add(menuEdit); menu.add(actionRewriteTvShowNfo); menu.add(actionRewriteTvShowEpisodeNfo); menuItem = menu.add(actionRename); menuItem.setMnemonic(KeyEvent.VK_R); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_R, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK)); menuItem = menu.add(actionMediaInformation2); menuItem.setMnemonic(KeyEvent.VK_M); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_M, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK)); menuItem = menu.add(actionExport); menuItem.setMnemonic(KeyEvent.VK_X); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK)); menuItem = menu.add(actionClearImageCache); menuItem.setMnemonic(KeyEvent.VK_C); menu.addSeparator(); menuItem = menu.add(actionRemove2); menuItem.setAccelerator(KeyStroke.getKeyStroke((char) KeyEvent.VK_DELETE)); menuItem = menu.add(actionDelete2); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, ActionEvent.SHIFT_MASK)); menu.addSeparator(); menuItem = menu.add(actionSyncTrakt); menuItem.setMnemonic(KeyEvent.VK_T); menuItem = menu.add(actionSyncWatchedTrakt); menuItem.setMnemonic(KeyEvent.VK_W); menuItem = menu.add(actionSyncSelectedTrakt); // popup menu JPopupMenu popupMenu = new JPopupMenu(); popupMenu.add(actionScrape2); popupMenu.add(actionScrapeSelected); popupMenu.add(actionScrapeEpisodes); popupMenu.add(actionScrapeEpisodes2); popupMenu.add(actionScrapeNewItems); // popupMenu.add(actionScrapeMetadataSelected); popupMenu.addSeparator(); popupMenu.add(actionUpdateTvShow); popupMenu.addSeparator(); popupMenu.add(actionEdit2); popupMenu.add(actionChangeSeasonPoster2); popupMenu.add(actionBatchEdit); popupMenu.add(actionSetWatchedFlag); popupMenu.add(actionChangeToDvdOrder); popupMenu.add(actionChangeToAiredOrder); popupMenu.add(actionRewriteTvShowNfo); popupMenu.add(actionRewriteTvShowEpisodeNfo); // popupMenu.add(actionBatchEdit); popupMenu.add(actionRename); popupMenu.add(actionMediaInformation2); popupMenu.add(actionExport); popupMenu.add(actionClearImageCache); popupMenu.addSeparator(); popupMenu.add(actionDownloadSubtitles); popupMenu.add(actionSearchAndDownloadSubtitles); popupMenu.addSeparator(); popupMenu.add(actionSyncTrakt); popupMenu.add(actionSyncWatchedTrakt); popupMenu.add(actionSyncSelectedTrakt); popupMenu.addSeparator(); popupMenu.add(actionRemove2); popupMenu.add(actionDelete2); popupMenu.addSeparator(); popupMenu.add(new ExpandAllAction()); popupMenu.add(new CollapseAllAction()); if (Globals.isDebug()) { JMenu menuDebug = new JMenu("Debug"); //$NON-NLS-1$ menuDebug.add(debugDumpShow); popupMenu.addSeparator(); popupMenu.add(menuDebug); } MouseListener popupListener = new TreePopupListener(popupMenu, tree); tree.addMouseListener(popupListener); }
From source file:org.yccheok.jstock.gui.IndicatorPanel.java
private JPopupMenu getJListPopupMenu() { final JPopupMenu popup = new JPopupMenu(); javax.swing.JMenuItem menuItem = new JMenuItem(GUIBundle.getString("New..."), this.getImageIcon("/images/16x16/filenew.png")); menuItem.addActionListener(new ActionListener() { @Override/*from w w w .j av a2s . c o m*/ public void actionPerformed(ActionEvent evt) { New(); } }); popup.add(menuItem); menuItem = new JMenuItem(GUIBundle.getString("Save"), this.getImageIcon("/images/16x16/filesave.png")); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { Save(true); } }); popup.add(menuItem); popup.addSeparator(); menuItem = new JMenuItem(GUIBundle.getString("Install..."), this.getImageIcon("/images/16x16/download.png")); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { Install(); } }); popup.add(menuItem); if (isIndicatorDatabaseVisibleAndSelected() || isModuleDatabaseVisibleAndSelected()) { menuItem = new JMenuItem(GUIBundle.getString("Export..."), this.getImageIcon("/images/16x16/upload.png")); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { Export(); } }); popup.add(menuItem); popup.addSeparator(); menuItem = new JMenuItem(GUIBundle.getString("Rename..."), this.getImageIcon("/images/16x16/edit.png")); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { Rename(); } }); popup.add(menuItem); menuItem = new JMenuItem(GUIBundle.getString("Delete"), this.getImageIcon("/images/16x16/editdelete.png")); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { Delete(true); } }); popup.add(menuItem); } return popup; }
From source file:org.yccheok.jstock.gui.IndicatorScannerJPanel.java
private JPopupMenu getMyJTablePopupMenu() { JPopupMenu popup = new JPopupMenu(); final JStock m = JStock.instance(); javax.swing.JMenuItem menuItem = new JMenuItem(java.util.ResourceBundle .getBundle("org/yccheok/jstock/data/gui").getString("IndicatorScannerJPanel_History..."), this.getImageIcon("/images/16x16/strokedocker.png")); menuItem.addActionListener(new ActionListener() { @Override/*from w ww .java2 s .c o m*/ public void actionPerformed(ActionEvent evt) { int rows[] = jTable1.getSelectedRows(); final IndicatorTableModel tableModel = (IndicatorTableModel) jTable1.getModel(); for (int row : rows) { final int modelIndex = jTable1.convertRowIndexToModel(row); final Indicator indicator = tableModel.getIndicator(modelIndex); if (indicator != null) { m.displayHistoryChart(indicator.getStock()); } } } }); popup.add(menuItem); menuItem = new JMenuItem(java.util.ResourceBundle.getBundle("org/yccheok/jstock/data/gui") .getString("IndicatorScannerJPanel_News..."), this.getImageIcon("/images/16x16/news.png")); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { int rows[] = jTable1.getSelectedRows(); final IndicatorTableModel tableModel = (IndicatorTableModel) jTable1.getModel(); for (int row : rows) { final int modelIndex = jTable1.convertRowIndexToModel(row); final Indicator indicator = tableModel.getIndicator(modelIndex); if (indicator != null) { m.displayStockNews(indicator.getStock()); } } } }); popup.add(menuItem); popup.addSeparator(); menuItem = new JMenuItem(GUIBundle.getString("IndicatorScannerJPanel_AddToRealTimeInfo"), this.getImageIcon("/images/16x16/add.png")); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { int rows[] = jTable1.getSelectedRows(); final IndicatorTableModel tableModel = (IndicatorTableModel) jTable1.getModel(); for (int row : rows) { final int modelIndex = jTable1.convertRowIndexToModel(row); final Indicator indicator = tableModel.getIndicator(modelIndex); if (indicator != null) { m.addStockToTable(indicator.getStock()); } } } }); popup.add(menuItem); if (jTable1.getSelectedRowCount() == 1) { popup.addSeparator(); menuItem = new JMenuItem(GUIBundle.getString("IndicatorScannerJPanel_Buy..."), this.getImageIcon("/images/16x16/inbox.png")); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { final int row = jTable1.getSelectedRow(); final int modelIndex = jTable1.getRowSorter().convertRowIndexToModel(row); final IndicatorTableModel tableModel = (IndicatorTableModel) jTable1.getModel(); final Indicator indicator = tableModel.getIndicator(modelIndex); final Stock stock = indicator.getStock(); JStock.instance().getPortfolioManagementJPanel().showNewBuyTransactionJDialog(stock, stock.getLastPrice(), false); } }); popup.add(menuItem); } return popup; }
From source file:org.yccheok.jstock.gui.JStock.java
private JPopupMenu getMyJTablePopupMenu() { final JPopupMenu popup = new JPopupMenu(); final TableModel tableModel = jTable1.getModel(); javax.swing.JMenuItem menuItem = new JMenuItem( java.util.ResourceBundle.getBundle("org/yccheok/jstock/data/gui").getString("MainFrame_History..."), this.getImageIcon("/images/16x16/strokedocker.png")); menuItem.addActionListener(new ActionListener() { @Override// www.j a v a 2s . c o m public void actionPerformed(ActionEvent evt) { displayHistoryCharts(); } }); popup.add(menuItem); menuItem = new JMenuItem( java.util.ResourceBundle.getBundle("org/yccheok/jstock/data/gui").getString("MainFrame_News..."), this.getImageIcon("/images/16x16/news.png")); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { displayStocksNews(); } }); popup.add(menuItem); popup.addSeparator(); if (jTable1.getSelectedRowCount() == 1) { menuItem = new JMenuItem( java.util.ResourceBundle.getBundle("org/yccheok/jstock/data/gui").getString("MainFrame_Buy..."), this.getImageIcon("/images/16x16/inbox.png")); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { final int row = jTable1.getSelectedRow(); final int modelIndex = jTable1.getRowSorter().convertRowIndexToModel(row); final Stock stock = ((StockTableModel) tableModel).getStock(modelIndex); // We have a real nasty bug here. We retrieve stock information through stock code. // When we receive stock information, we update all its particular information, including stock // symbol. Here is the catch, the latest updated stock symbol (stock.getSymbol), may not be the // same as stock symbol found in stock database. If we pass the stock symbol which is not found // in stock database to portfolio, something can go wrong. This is because portfolio rely heavily // on symbol <-> code conversion. Hence, instead of using stock.getSymbol, we prefer to get the // symbol out from stock database. This marks the close of the following reported bugs : // // [2800598] buyportfolio.xml file not updated with code symbol // [2790218] User unable to add new buy transaction in Spain // // Say no to : portfolioManagementJPanel.showNewBuyTransactionJDialog(stock.symbol, stock.getLastPrice(), false); portfolioManagementJPanel.showNewBuyTransactionJDialog(stock, stock.getLastPrice(), false); } }); popup.add(menuItem); popup.addSeparator(); } menuItem = new JMenuItem( java.util.ResourceBundle.getBundle("org/yccheok/jstock/data/gui").getString("MainFrame_Delete"), this.getImageIcon("/images/16x16/editdelete.png")); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { JStock.this.deteleSelectedTableRow(); } }); popup.add(menuItem); return popup; }
From source file:org.yccheok.jstock.gui.MainFrame.java
private JPopupMenu getMyJTablePopupMenu() { final JPopupMenu popup = new JPopupMenu(); final TableModel tableModel = jTable1.getModel(); javax.swing.JMenuItem menuItem = new JMenuItem( java.util.ResourceBundle.getBundle("org/yccheok/jstock/data/gui").getString("MainFrame_History..."), this.getImageIcon("/images/16x16/strokedocker.png")); menuItem.addActionListener(new ActionListener() { @Override//from w ww . j a v a2 s . c o m public void actionPerformed(ActionEvent evt) { int rows[] = jTable1.getSelectedRows(); final StockTableModel tableModel = (StockTableModel) jTable1.getModel(); for (int row : rows) { final int modelIndex = jTable1.getRowSorter().convertRowIndexToModel(row); Stock stock = tableModel.getStock(modelIndex); displayHistoryChart(stock); } } }); popup.add(menuItem); popup.addSeparator(); if (jTable1.getSelectedRowCount() == 1) { menuItem = new JMenuItem( java.util.ResourceBundle.getBundle("org/yccheok/jstock/data/gui").getString("MainFrame_Buy..."), this.getImageIcon("/images/16x16/inbox.png")); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { final int row = jTable1.getSelectedRow(); final int modelIndex = jTable1.getRowSorter().convertRowIndexToModel(row); final Stock stock = ((StockTableModel) tableModel).getStock(modelIndex); // We have a real nasty bug here. We retrieve stock information through stock code. // When we receive stock information, we update all its particular information, including stock // symbol. Here is the catch, the latest updated stock symbol (stock.getSymbol), may not be the // same as stock symbol found in stock database. If we pass the stock symbol which is not found // in stock database to portfolio, something can go wrong. This is because portfolio rely heavily // on symbol <-> code conversion. Hence, instead of using stock.getSymbol, we prefer to get the // symbol out from stock database. This marks the close of the following reported bugs : // // [2800598] buyportfolio.xml file not updated with code symbol // [2790218] User unable to add new buy transaction in Spain // // Say no to : portfolioManagementJPanel.showNewBuyTransactionJDialog(stock.symbol, stock.getLastPrice(), false); portfolioManagementJPanel.showNewBuyTransactionJDialog(stock, stock.getLastPrice(), false); } }); popup.add(menuItem); popup.addSeparator(); } menuItem = new JMenuItem( java.util.ResourceBundle.getBundle("org/yccheok/jstock/data/gui").getString("MainFrame_Delete"), this.getImageIcon("/images/16x16/editdelete.png")); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { MainFrame.this.deteleSelectedTableRow(); } }); popup.add(menuItem); return popup; }
From source file:org.yccheok.jstock.gui.portfolio.DividendSummaryJDialog.java
private JPopupMenu getMyJTablePopupMenu() { final JPopupMenu popup = new JPopupMenu(); javax.swing.JMenuItem menuItem = new JMenuItem( java.util.ResourceBundle.getBundle("org/yccheok/jstock/data/gui").getString("DividendSummary_New"), new javax.swing.ImageIcon(getClass().getResource("/images/16x16/filenew.png"))); menuItem.addActionListener(new ActionListener() { @Override//from ww w .ja v a 2s.c o m public void actionPerformed(ActionEvent e) { addNewDividend(); } }); popup.add(menuItem); final Commentable commentable = getSelectedCommentable(); final String text = this.getSelectedSecondColumnString(); if (commentable != null && text != null) { popup.addSeparator(); menuItem = new JMenuItem( java.util.ResourceBundle.getBundle("org/yccheok/jstock/data/gui") .getString("DividendSummary_Note..."), new javax.swing.ImageIcon(getClass().getResource("/images/16x16/sticky.png"))); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { showCommentJDialog(commentable, MessageFormat .format(GUIBundle.getString("DividendSummaryJDialog_NoteFor_template"), text)); } }); popup.add(menuItem); } if (jTable1.getSelectedRowCount() >= 1) { popup.addSeparator(); menuItem = new JMenuItem( java.util.ResourceBundle.getBundle("org/yccheok/jstock/data/gui") .getString("DividendSummaryJDialog_Delete"), new javax.swing.ImageIcon(getClass().getResource("/images/16x16/editdelete.png"))); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { deleteSelectedDividend(); jLabel2.setText(getDividendSummaryText()); } }); popup.add(menuItem); } return popup; }
From source file:org.yccheok.jstock.gui.PortfolioManagementJPanel.java
private JPopupMenu getSellTreeTablePopupMenu() { final List<Transaction> transactions = getSelectedTransactions(this.sellTreeTable); JPopupMenu popup = new JPopupMenu(); JMenuItem menuItem = null;/*from ww w. j a va 2s . c o m*/ menuItem = new JMenuItem(GUIBundle.getString("PortfolioManagementJPanel_Cash..."), this.getImageIcon("/images/16x16/money.png")); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { showDepositSummaryJDialog(); } }); popup.add(menuItem); menuItem = new JMenuItem(GUIBundle.getString("PortfolioManagement_Dividend..."), this.getImageIcon("/images/16x16/money2.png")); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { showDividendSummaryJDialog(); } }); popup.add(menuItem); popup.addSeparator(); if (transactions.size() == 1) { menuItem = new JMenuItem(GUIBundle.getString("PortfolioManagement_Edit..."), this.getImageIcon("/images/16x16/edit.png")); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { PortfolioManagementJPanel.this.showEditTransactionJDialog(transactions.get(0)); } }); popup.add(menuItem); } final Commentable commentable = getSelectedCommentable(this.sellTreeTable); final String tmp = getSelectedFirstColumnString(this.sellTreeTable); if (commentable != null && tmp != null) { menuItem = new JMenuItem(GUIBundle.getString("PortfolioManagement_Note..."), this.getImageIcon("/images/16x16/sticky.png")); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { final String template = GUIBundle.getString("PortfolioManagementJPanel_NoteFor_template"); final String title = MessageFormat.format(template, tmp); PortfolioManagementJPanel.this.showCommentJDialog(commentable, title); } }); popup.add(menuItem); popup.addSeparator(); } else if (transactions.size() == 1) { popup.addSeparator(); } menuItem = new JMenuItem(GUIBundle.getString("PortfolioManagement_InvestmentChart..."), this.getImageIcon("/images/16x16/graph.png")); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { showChashFlowChartJDialog(); } }); popup.add(menuItem); menuItem = new JMenuItem(GUIBundle.getString("PortfolioManagementJPanel_DividendChart"), this.getImageIcon("/images/16x16/chart.png")); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { PortfolioManagementJPanel.this.showDividendSummaryBarChartJDialog(); } }); popup.add(menuItem); menuItem = new JMenuItem(GUIBundle.getString("PortfolioManagement_Summary..."), this.getImageIcon("/images/16x16/pie_chart.png")); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { PortfolioManagementJPanel.this.showSellPortfolioChartJDialog(); } }); popup.add(menuItem); if (isOnlyTreeTableRootBeingSelected(sellTreeTable) == false && (sellTreeTable.getSelectedRow() > 0)) { final JStock m = JStock.instance(); menuItem = new JMenuItem(GUIBundle.getString("PortfolioManagement_History..."), this.getImageIcon("/images/16x16/strokedocker.png")); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { List<Stock> stocks = getSelectedStocks(sellTreeTable); for (Stock stock : stocks) { m.displayHistoryChart(stock); } } }); popup.addSeparator(); popup.add(menuItem); menuItem = new JMenuItem(GUIBundle.getString("PortfolioManagement_News..."), this.getImageIcon("/images/16x16/news.png")); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { List<Stock> stocks = getSelectedStocks(sellTreeTable); for (Stock stock : stocks) { m.displayStockNews(stock); } } }); popup.add(menuItem); popup.addSeparator(); menuItem = new JMenuItem(GUIBundle.getString("PortfolioManagement_Delete"), this.getImageIcon("/images/16x16/editdelete.png")); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { PortfolioManagementJPanel.this.deteleSelectedTreeTableRow(); } }); popup.add(menuItem); } return popup; }
From source file:org.yccheok.jstock.gui.PortfolioManagementJPanel.java
private JPopupMenu getBuyTreeTablePopupMenu() { JPopupMenu popup = new JPopupMenu(); JMenuItem menuItem = new JMenuItem(GUIBundle.getString("PortfolioManagement_Buy..."), this.getImageIcon("/images/16x16/inbox.png")); menuItem.addActionListener(new ActionListener() { @Override/*from w w w . j av a 2 s . c o m*/ public void actionPerformed(ActionEvent evt) { List<Stock> stocks = getSelectedStocks(); if (stocks.size() == 1) { PortfolioManagementJPanel.this.showNewBuyTransactionJDialog(stocks.get(0), PortfolioManagementJPanel.this.getStockPrice(stocks.get(0).code), true); } else { PortfolioManagementJPanel.this.showNewBuyTransactionJDialog(org.yccheok.jstock.engine.Utils .getEmptyStock(Code.newInstance(""), Symbol.newInstance("")), 0.0, true); } } }); popup.add(menuItem); final List<Transaction> transactions = getSelectedTransactions(this.buyTreeTable); final List<Stock> stocks = this.getSelectedStocks(this.buyTreeTable); if (transactions.size() > 0 && stocks.size() == 1) { menuItem = new JMenuItem(GUIBundle.getString("PortfolioManagement_Sell..."), this.getImageIcon("/images/16x16/outbox.png")); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { PortfolioManagementJPanel.this.showNewSellTransactionJDialog(transactions); } }); popup.add(menuItem); } popup.addSeparator(); menuItem = new JMenuItem(GUIBundle.getString("PortfolioManagementJPanel_Cash..."), this.getImageIcon("/images/16x16/money.png")); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { showDepositSummaryJDialog(); } }); popup.add(menuItem); menuItem = new JMenuItem(GUIBundle.getString("PortfolioManagement_Dividend..."), this.getImageIcon("/images/16x16/money2.png")); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { showDividendSummaryJDialog(); } }); popup.add(menuItem); popup.addSeparator(); boolean needToAddSeperator = false; if (transactions.size() == 1) { menuItem = new JMenuItem(GUIBundle.getString("PortfolioManagement_Edit..."), this.getImageIcon("/images/16x16/edit.png")); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { PortfolioManagementJPanel.this.showEditTransactionJDialog(transactions.get(0)); } }); popup.add(menuItem); needToAddSeperator = true; } final Commentable commentable = getSelectedCommentable(this.buyTreeTable); final String tmp = getSelectedFirstColumnString(this.buyTreeTable); if (commentable != null && tmp != null) { menuItem = new JMenuItem(GUIBundle.getString("PortfolioManagement_Note..."), this.getImageIcon("/images/16x16/sticky.png")); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { final String template = GUIBundle.getString("PortfolioManagementJPanel_NoteFor_template"); final String title = MessageFormat.format(template, tmp); PortfolioManagementJPanel.this.showCommentJDialog(commentable, title); } }); popup.add(menuItem); needToAddSeperator = true; } // Split or merge only allowed, if there is one and only one stock // being selected. final List<Stock> selectedStocks = this.getSelectedStocks(); if (selectedStocks.size() == 1) { menuItem = new JMenuItem(GUIBundle.getString("PortfolioManagementJPanel_SplitOrMerge"), this.getImageIcon("/images/16x16/merge.png")); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { PortfolioManagementJPanel.this .showSplitOrMergeJDialog(StockInfo.newInstance(selectedStocks.get(0))); } }); popup.add(menuItem); needToAddSeperator = true; } if (needToAddSeperator) { popup.addSeparator(); } menuItem = new JMenuItem(GUIBundle.getString("PortfolioManagement_InvestmentChart..."), this.getImageIcon("/images/16x16/graph.png")); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { showChashFlowChartJDialog(); } }); popup.add(menuItem); menuItem = new JMenuItem(GUIBundle.getString("PortfolioManagementJPanel_DividendChart"), this.getImageIcon("/images/16x16/chart.png")); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { PortfolioManagementJPanel.this.showDividendSummaryBarChartJDialog(); } }); popup.add(menuItem); menuItem = new JMenuItem(GUIBundle.getString("PortfolioManagement_Summary..."), this.getImageIcon("/images/16x16/pie_chart.png")); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { PortfolioManagementJPanel.this.showBuyPortfolioChartJDialog(); } }); popup.add(menuItem); if (isOnlyTreeTableRootBeingSelected(buyTreeTable) == false && (buyTreeTable.getSelectedRow() > 0)) { final JStock m = JStock.instance(); menuItem = new JMenuItem(GUIBundle.getString("PortfolioManagement_History..."), this.getImageIcon("/images/16x16/strokedocker.png")); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { List<Stock> stocks = getSelectedStocks(buyTreeTable); for (Stock stock : stocks) { m.displayHistoryChart(stock); } } }); popup.addSeparator(); popup.add(menuItem); menuItem = new JMenuItem(GUIBundle.getString("PortfolioManagement_News..."), this.getImageIcon("/images/16x16/news.png")); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { List<Stock> stocks = getSelectedStocks(buyTreeTable); for (Stock stock : stocks) { m.displayStockNews(stock); } } }); popup.add(menuItem); popup.addSeparator(); menuItem = new JMenuItem(GUIBundle.getString("PortfolioManagement_Delete"), this.getImageIcon("/images/16x16/editdelete.png")); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { PortfolioManagementJPanel.this.deteleSelectedTreeTableRow(); } }); popup.add(menuItem); } return popup; }
From source file:org.yccheok.jstock.gui.StockDatabaseJDialog.java
private JPopupMenu getMyJTablePopupMenu(boolean newMenuItemOnly) { final JPopupMenu popup = new JPopupMenu(); javax.swing.JMenuItem menuItem = new JMenuItem("New", new javax.swing.ImageIcon(getClass().getResource("/images/16x16/filenew.png"))); menuItem.addActionListener(new ActionListener() { @Override//from ww w .j a v a 2 s . co m public void actionPerformed(ActionEvent e) { addNewStockInfo(); } }); popup.add(menuItem); if (newMenuItemOnly) { /* Single menu item only. */ return popup; } if (jTable2.getSelectedRowCount() >= 1) { popup.addSeparator(); menuItem = new JMenuItem("Delete", new javax.swing.ImageIcon(getClass().getResource("/images/16x16/editdelete.png"))); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { deleteSelectedUserDefinedDatabase(); } }); popup.add(menuItem); } return popup; }
From source file:processing.app.Editor.java
protected void configurePopupMenu(final SketchTextArea textarea) { JPopupMenu menu = textarea.getPopupMenu(); menu.addSeparator(); JMenuItem item = createToolMenuItem("cc.arduino.packages.formatter.AStyle"); item.setName("menuToolsAutoFormat"); menu.add(item);//from ww w . j av a2 s. c o m item = newJMenuItem(_("Comment/Uncomment"), '/'); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { handleCommentUncomment(); } }); menu.add(item); item = newJMenuItem(_("Increase Indent"), ']'); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { handleIndentOutdent(true); } }); menu.add(item); item = newJMenuItem(_("Decrease Indent"), '['); item.setName("menuDecreaseIndent"); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { handleIndentOutdent(false); } }); menu.add(item); item = new JMenuItem(_("Copy for Forum")); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { handleDiscourseCopy(); } }); menu.add(item); item = new JMenuItem(_("Copy as HTML")); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { handleHTMLCopy(); } }); menu.add(item); final JMenuItem referenceItem = new JMenuItem(_("Find in Reference")); referenceItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { handleFindReference(); } }); menu.add(referenceItem); final JMenuItem openURLItem = new JMenuItem(_("Open URL")); openURLItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Base.openURL(e.getActionCommand()); } }); menu.add(openURLItem); menu.addPopupMenuListener(new PopupMenuListener() { @Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { String referenceFile = base.getPdeKeywords().getReference(getCurrentKeyword()); referenceItem.setEnabled(referenceFile != null); int offset = textarea.getCaretPosition(); org.fife.ui.rsyntaxtextarea.Token token = RSyntaxUtilities.getTokenAtOffset(textarea, offset); if (token != null && token.isHyperlink()) { openURLItem.setEnabled(true); openURLItem.setActionCommand(token.getLexeme()); } else { openURLItem.setEnabled(false); } } @Override public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { } @Override public void popupMenuCanceled(PopupMenuEvent e) { } }); }