/** * Handle widget events. * * @param e action event */ public void actionPerformed(final ActionEvent e) { if (e.getSource() == tableClose) { propertySupport.firePropertyChange(ModuleFrame.WINDOW_CLOSE_PROPERTY, 0, 1); } else if (e.getSource() == applyExpressions) { applyExpressions(model); } else if (e.getSource() == applyFilter) { applyFilter(); } else if (e.getSource() == sortByMostActive) { setColumnSortStatus(EODQuoteModel.ACTIVITY_COLUMN, SORT_UP); resort(); validate(); repaint(); } // Find symbol else if (e.getSource() == findSymbol) findSymbol(); // Graph symbols, either by the popup menu or the main menu else if ((popupGraphSymbols != null && e.getSource() == popupGraphSymbols) || e.getSource() == graphSymbols) { int[] selectedRows = getSelectedRows(); List symbols = new ArrayList(); for (int i = 0; i < selectedRows.length; i++) { Symbol symbol = (Symbol) model.getValueAt(selectedRows[i], EODQuoteModel.SYMBOL_COLUMN); symbols.add(symbol); } // Graph the highlighted symbols CommandManager.getInstance().graphStockBySymbol(symbols); } // Table symbols, either by the popup menu or the main menu else if ((popupTableSymbols != null && e.getSource() == popupTableSymbols) || e.getSource() == tableSymbols) { int[] selectedRows = getSelectedRows(); List symbols = new ArrayList(); for (int i = 0; i < selectedRows.length; i++) { Symbol symbol = (Symbol) model.getValueAt(selectedRows[i], EODQuoteModel.SYMBOL_COLUMN); symbols.add(symbol); } // Table the highlighted symbols CommandManager.getInstance().tableStocks(symbols); } else if (e.getSource() == alertSymbols) { int[] selectedRows = getSelectedRows(); Symbol symbol = (Symbol) model.getValueAt(selectedRows[0], EODQuoteModel.SYMBOL_COLUMN); CommandManager.getInstance().newAlert(symbol); } else assert false; }
// If the user double clicks on a stock with the LMB, graph the stock. // If the user right clicks over the table, open up a popup menu. private void handleMouseClicked(MouseEvent event) { Point point = event.getPoint(); // Right click on the table - raise menu if (event.getButton() == MouseEvent.BUTTON3) { JPopupMenu menu = new JPopupMenu(); popupGraphSymbols = MenuHelper.addMenuItem(this, menu, Locale.getString("GRAPH")); popupGraphSymbols.setEnabled(getSelectedRowCount() > 0); popupTableSymbols = MenuHelper.addMenuItem(this, menu, Locale.getString("TABLE")); popupTableSymbols.setEnabled(getSelectedRowCount() > 0); menu.show(this, point.x, point.y); } // Left double click on the table - graph stock else if (event.getButton() == MouseEvent.BUTTON1 && event.getClickCount() == 2) { int[] selectedRows = getSelectedRows(); List symbols = new ArrayList(); for (int i = 0; i < selectedRows.length; i++) { Symbol symbol = (Symbol) model.getValueAt(selectedRows[i], EODQuoteModel.SYMBOL_COLUMN); symbols.add(symbol); } // Graph the highlighted symbols CommandManager.getInstance().graphStockBySymbol(symbols); } }