List of usage examples for java.awt.event ActionEvent getSource
public Object getSource()
From source file:erigo.filepump.FilePump.java
public void actionPerformed(ActionEvent eventI) { Object source = eventI.getSource(); if (source == null) { return;//from w ww.j a v a2s .co m } else if (eventI.getActionCommand().equals("Settings...")) { // Turn off pump if it is currently running resetGUI_EDT(); stopFilePumpWorkerThread(); // Let user edit settings pumpSettings.popupSettingsDialog(); if (pumpSettings.getBClickedOK()) { String errStr = pumpSettings.canPumpRun(); if (!errStr.isEmpty()) { JOptionPane.showMessageDialog(filePumpGuiFrame, errStr, "Settings error", JOptionPane.ERROR_MESSAGE); return; } // Update the main frame with the new settings updateMainFrame(); } } else if (eventI.getActionCommand().equals("Exit")) { exit(); } else if (source == endButton) { // Turn off pump if it is currently running resetGUI_EDT(); stopFilePumpWorkerThread(); // Create an "end.txt" file in the output directory // Make sure we can do this String errStr = pumpSettings.canPumpRun(); if (!errStr.isEmpty()) { JOptionPane.showMessageDialog(filePumpGuiFrame, new String("Settings error:\n" + errStr), "Settings error", JOptionPane.ERROR_MESSAGE); return; } filePumpWorker = new FilePumpWorker(this, pumpSettings, true); filePumpThread = new Thread(filePumpWorker); filePumpThread.start(); } else if (source == actionButton) { // Turn on or off streaming data if (actionButton.getText().equals("Start pump")) { // User wants to start outputting files; make sure we can do this String errStr = pumpSettings.canPumpRun(); if (!errStr.isEmpty()) { JOptionPane.showMessageDialog(filePumpGuiFrame, new String("Settings error:\n" + errStr), "Settings error", JOptionPane.ERROR_MESSAGE); return; } bPumpRunning = true; // Change label to "Stop pump" actionButton.setText("Stop pump"); actionButton.setBackground(Color.RED); // Start pump filePumpWorker = new FilePumpWorker(this, pumpSettings, false); filePumpThread = new Thread(filePumpWorker); filePumpThread.start(); } else { resetGUI_EDT(); stopFilePumpWorkerThread(); } } }
From source file:es.emergya.ui.gis.popups.GPSDialog.java
@Override public void actionPerformed(ActionEvent e) { if (e.getActionCommand().equals(i18n.getString("window.gps.button.actualizar"))) { last_bandejaSalida = send();/* ww w.jav a 2 s. c o m*/ log.info("bandeja de salida: " + last_bandejaSalida); if (last_bandejaSalida == null) { return; } final JButton request = ((JButton) e.getSource()); request.setEnabled(false); progressIcon.setIcon(iconEnviando); notification.setForeground(Color.WHITE); SolicitudGPSActionListener listener = new SolicitudGPSActionListener(last_bandejaSalida); Timer t = new Timer(1000, listener); listener.setTimer(t); t.start(); } if (e.getActionCommand().equals(i18n.getString("Buttons.cancel"))) { if (last_bandejaSalida != null) { MessageGenerator.remove(last_bandejaSalida.getId()); } last_bandejaSalida = null; dispose(); } }
From source file:DateChooserPanel.java
/** * Handles action-events from the date panel. * * @param e information about the event that occurred. *//*from w w w. j av a 2s . c o m*/ public void actionPerformed(final ActionEvent e) { if (e.getActionCommand().equals("monthSelectionChanged")) { final JComboBox c = (JComboBox) e.getSource(); // In most cases, changing the month will not change the selected // day. But if the selected day is 29, 30 or 31 and the newly // selected month doesn't have that many days, we revert to the // last day of the newly selected month... int dayOfMonth = this.chosenDate.get(Calendar.DAY_OF_MONTH); this.chosenDate.set(Calendar.DAY_OF_MONTH, 1); this.chosenDate.set(Calendar.MONTH, c.getSelectedIndex()); int maxDayOfMonth = this.chosenDate.getActualMaximum(Calendar.DAY_OF_MONTH); this.chosenDate.set(Calendar.DAY_OF_MONTH, Math.min(dayOfMonth, maxDayOfMonth)); refreshButtons(); } else if (e.getActionCommand().equals("yearSelectionChanged")) { if (!this.refreshing) { final JComboBox c = (JComboBox) e.getSource(); final Integer y = (Integer) c.getSelectedItem(); // in most cases, changing the year will not change the // selected day. But if the selected day is Feb 29, and the // newly selected year is not a leap year, we revert to // Feb 28... int dayOfMonth = this.chosenDate.get(Calendar.DAY_OF_MONTH); this.chosenDate.set(Calendar.DAY_OF_MONTH, 1); this.chosenDate.set(Calendar.YEAR, y.intValue()); int maxDayOfMonth = this.chosenDate.getActualMaximum(Calendar.DAY_OF_MONTH); this.chosenDate.set(Calendar.DAY_OF_MONTH, Math.min(dayOfMonth, maxDayOfMonth)); refreshYearSelector(); refreshButtons(); } } else if (e.getActionCommand().equals("todayButtonClicked")) { setDate(new Date()); } else if (e.getActionCommand().equals("dateButtonClicked")) { final JButton b = (JButton) e.getSource(); final int i = Integer.parseInt(b.getName()); final Calendar cal = getFirstVisibleDate(); cal.add(Calendar.DATE, i); setDate(cal.getTime()); } }
From source file:javaresturentdesktopclient.EmployeeDetailsPage.java
private void jComboBoxPositionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxPositionActionPerformed // TODO add your handling code here: int index;/*ww w .ja v a2s.c o m*/ index = ((JComboBox) evt.getSource()).getSelectedIndex(); item = positionId[index]; if (item == 1) { position = Constant.manager; } else if (item == 2) { position = Constant.waiter; } else if (item == 3) { position = Constant.chef; } else if (item == 4) { position = Constant.cashier; } else if (item == 5) { position = Constant.cleaner; } else { position = null; } ShowTable(position); }
From source file:com.mucommander.ui.viewer.image.ImageViewer.java
public void actionPerformed(ActionEvent e) { Object source = e.getSource(); if (source == zoomInItem && zoomInItem.isEnabled()) { zoomFactor *= 2;// w ww . jav a 2 s .c o m zoom(zoomFactor); updateFrame(); } else if (source == zoomOutItem && zoomOutItem.isEnabled()) { zoomFactor /= 2; zoom(zoomFactor); updateFrame(); } else if (source == nextImageItem && nextImageItem.isEnabled()) { gotoNextFile(); } else if (source == prevImageItem && prevImageItem.isEnabled()) { gotoPrevFile(); } else { super.actionPerformed(e); } }
From source file:br.ufrgs.enq.jcosmo.ui.COSMOSACDialog.java
public void actionPerformed(ActionEvent e) { COSMOSAC cosmosac = (COSMOSAC) modelBox.getSelectedItem(); if (modelBox == e.getSource()) { chargeHB.setText(Double.toString(cosmosac.getCHB())); ignoreSGButton.setSelected(cosmosac.isIgnoreSG()); sigmaHB.setText(Double.toString(cosmosac.getSigmaHB())); sigmaHB2.setText(Double.toString(cosmosac.getSigmaHB2())); sigmaHB3.setText(Double.toString(cosmosac.getSigmaHB3())); sigmaDisp.setText(Double.toString(cosmosac.getSigmaDisp())); chargeDisp.setText(Double.toString(cosmosac.getCDisp())); beta.setText(Double.toString(cosmosac.getBeta())); fpol.setText(Double.toString(cosmosac.getFpol())); anorm.setText(Double.toString(cosmosac.getAnorm())); } else if (ignoreSGButton == e.getSource()) { cosmosac.setIgnoreSG(ignoreSGButton.isSelected()); } else if (removeButton == e.getSource()) { //This method can be called only if //there's a valid selection //so go ahead and remove whatever's selected. int index = list.getSelectedIndex(); listModel.remove(index);/*from w w w. ja v a 2s . c om*/ int size = listModel.getSize(); if (size == 0) { //Nobody's left, disable firing. visibRemove(false); } else { //Select an index. if (index == listModel.getSize()) { //removed item in last position index--; } list.setSelectedIndex(index); list.ensureIndexIsVisible(index); } } else if (e.getActionCommand() == QUIT) { setVisible(false); db.fini(); System.exit(0); } if (e.getActionCommand() == ABOUT) { new AboutDialog(this); } }
From source file:dbseer.gui.panel.DBSeerLiveMonitorPanel.java
@Override public synchronized void actionPerformed(ActionEvent event) { for (int i = 0; i < transactionRenameButtons.size(); ++i) { if (event.getSource() == transactionRenameButtons.get(i)) { String newName = (String) JOptionPane.showInputDialog(this, "Enter the new name for this transaction type", "New Dataset", JOptionPane.PLAIN_MESSAGE, null, null, transactionNames.get(i)); if (newName == null || newName.trim().isEmpty()) { return; } else { newName = newName.trim(); transactionNames.set(i, newName); transactionLabels.get(i).setText(newName); DefaultTableModel model = (DefaultTableModel) monitorTable.getModel(); model.setValueAt(String.format("Current TPS of '%s' transactions", transactionNames.get(i)), 2 + (i * ROW_PER_TX_TYPE), 0); model.setValueAt(/*from ww w . j a v a 2 s .c o m*/ String.format("Current average latency of '%s' transactions", transactionNames.get(i)), 2 + (i * ROW_PER_TX_TYPE) + 1, 0); // TimeSeriesCollection collection = (TimeSeriesCollection) throughputChartPanel.getChart().getXYPlot().getDataset(); throughputCollection.getSeries(i).setKey(newName); latencyCollection.getSeries(i).setKey(newName); // if (DBSeerGUI.currentDataset != null) // { // DBSeerGUI.currentDataset.setTransactionTypeName(i, newName); // } for (DBSeerDataSet dataset : DBSeerGUI.liveDatasets) { dataset.setTransactionTypeName(i, newName); } return; } } } for (int i = 0; i < transactionViewSampleButtons.size(); ++i) { if (event.getSource() == transactionViewSampleButtons.get(i)) { final int type = i; SwingUtilities.invokeLater(new Runnable() { @Override public void run() { DBSeerShowTransactionExampleFrame sampleFrame = new DBSeerShowTransactionExampleFrame(type); sampleFrame.pack(); sampleFrame.setLocationRelativeTo(DBSeerGUI.mainFrame); sampleFrame.setVisible(true); } }); } } for (int i = 0; i < transactionEnableDisableButtons.size(); ++i) { if (event.getSource() == transactionEnableDisableButtons.get(i)) { final XYItemRenderer throughputRenderer = throughputChartPanel.getChart().getXYPlot().getRenderer(); final XYItemRenderer latencyRenderer = latencyChartPanel.getChart().getXYPlot().getRenderer(); final int type = i; final JButton button = transactionEnableDisableButtons.get(i); final DBSeerDataSet dataset = DBSeerGUI.liveDataset; SwingUtilities.invokeLater(new Runnable() { @Override public void run() { if (button.getText() == "Disable") { dataset.disableTransaction(type); throughputRenderer.setSeriesVisible(type, false); latencyRenderer.setSeriesVisible(type, false); button.setText("Enable"); } else if (button.getText() == "Enable") { dataset.enableTransaction(type); throughputRenderer.setSeriesVisible(type, true); latencyRenderer.setSeriesVisible(type, true); button.setText("Disable"); } } }); } } for (int i = 0; i < transactionDeleteButtons.size(); ++i) { if (event.getSource() == transactionDeleteButtons.get(i)) { synchronized (LiveMonitorInfo.LOCK) { try { DBSeerGUI.middlewareSocket.removeTransactionType(i); } catch (IOException e) { DBSeerExceptionHandler.handleException(e); } throughputCollection.removeSeries(i); latencyCollection.removeSeries(i); DefaultTableModel model = (DefaultTableModel) monitorTable.getModel(); int newTxSize = transactionNames.size() - 1; for (int j = 0; j < transactionNames.size(); ++j) { model.setValueAt(String.format("Current TPS of '%s' transactions", transactionNames.get(j)), 2 + (j * ROW_PER_TX_TYPE), 0); model.setValueAt(String.format("Current average latency of '%s' transactions", transactionNames.get(j)), 2 + (j * ROW_PER_TX_TYPE) + 1, 0); model.setValueAt("", 2 + (j * ROW_PER_TX_TYPE), 1); model.setValueAt("", 2 + (j * ROW_PER_TX_TYPE) + 1, 1); } model.setValueAt("", 2 + (newTxSize * ROW_PER_TX_TYPE), 0); model.setValueAt("", 2 + (newTxSize * ROW_PER_TX_TYPE), 1); model.setValueAt("", 2 + (newTxSize * ROW_PER_TX_TYPE) + 1, 0); model.setValueAt("", 2 + (newTxSize * ROW_PER_TX_TYPE) + 1, 1); final JPanel panel = transactionTypesPanel; final JLabel label = transactionLabels.remove(i); final JButton renameButton = transactionRenameButtons.remove(i); final JButton exampleButton = transactionViewSampleButtons.remove(i); final JButton deleteButton = transactionDeleteButtons.remove(i); transactionNames.remove(i); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { panel.remove(label); panel.remove(renameButton); panel.remove(exampleButton); panel.remove(deleteButton); panel.revalidate(); panel.repaint(); } }); } break; } } }
From source file:com.mirth.connect.client.ui.alert.AlertActionPane.java
private void makeActionTable() { actionTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); actionTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); actionTable.getColumnExt(PROTOCOL_COLUMN_NAME).setCellEditor(new MirthComboBoxTableCellEditor(actionTable, protocols.keySet().toArray(), 1, false, new ActionListener() { @Override//from w ww .jav a 2 s.c om public void actionPerformed(ActionEvent e) { JComboBox comboBox = (JComboBox) e.getSource(); if (comboBox.isPopupVisible()) { PlatformUI.MIRTH_FRAME.setSaveEnabled(true); } } })); actionTable.getColumnExt(PROTOCOL_COLUMN_NAME) .setCellRenderer(new MirthComboBoxTableCellRenderer(protocols.keySet().toArray())); actionTable.getColumnExt(RECIPIENT_COLUMN_INDEX).setCellRenderer(new RecipientCellRenderer()); actionTable.getColumnExt(RECIPIENT_COLUMN_NAME).setCellEditor(new RecipientCellEditor()); actionTable.setRowHeight(UIConstants.ROW_HEIGHT); actionTable.setSortable(false); actionTable.setOpaque(true); actionTable.setDragEnabled(false); actionTable.getTableHeader().setReorderingAllowed(false); actionTable.setShowGrid(true, true); actionTable.setAutoCreateColumnsFromModel(false); actionTable.getColumnExt(PROTOCOL_COLUMN_NAME).setMaxWidth(PROTOCOL_COLUMN_WIDTH); actionTable.getColumnExt(PROTOCOL_COLUMN_NAME).setMinWidth(PROTOCOL_COLUMN_WIDTH); actionTable.getColumnExt(PROTOCOL_COLUMN_NAME).setResizable(false); actionTable.getColumnExt(RECIPIENT_COLUMN_NAME).setMinWidth(UIConstants.MIN_WIDTH); actionTable.getColumnExt(RECIPIENT_COLUMN_NAME).setResizable(false); if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) { Highlighter highlighter = HighlighterFactory.createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR, UIConstants.BACKGROUND_COLOR); actionTable.setHighlighters(highlighter); } }
From source file:com.mirth.connect.client.ui.alert.AlertActionPane.java
private void updateActionTable(List<AlertAction> alertActions) { // Make sure there aren't any cell editors still active TableCellEditor cellEditor = actionTable.getCellEditor(); if (cellEditor != null) { cellEditor.stopCellEditing();//from w w w.j a v a 2s. c o m } for (Protocol protocol : protocols.values()) { if (protocol.hasOptions()) { MirthComboBoxTableCellEditor editor = new MirthComboBoxTableCellEditor(actionTable, protocol.getRecipientNames().toArray(), 1, true, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JComboBox comboBox = (JComboBox) e.getSource(); if (comboBox.isPopupVisible() && actionTable.getCellEditor() != null) { actionTable.getCellEditor().stopCellEditing(); } PlatformUI.MIRTH_FRAME.setSaveEnabled(true); } }); editor.setEditable(true); editor.getComboBox().setCanEnableSave(false); editor.getComboBox().setAutoResizeDropdown(true); MirthComboBoxTableCellRenderer renderer = new MirthComboBoxTableCellRenderer( protocol.getRecipientNames().toArray()); renderer.setEditable(true); // Update the recipient column renderer and editor with the current names ((RecipientCellRenderer) actionTable.getColumnExt(RECIPIENT_COLUMN_INDEX).getCellRenderer()) .setCellRenderer(protocol.getProtocolName(), renderer); ((RecipientCellEditor) actionTable.getColumnExt(RECIPIENT_COLUMN_NAME).getCellEditor()) .setCellEditor(protocol.getProtocolName(), editor); } } ActionTableModel model = (ActionTableModel) actionTable.getModel(); model.refreshData(alertActions); if (model.getRowCount() == 0) { actionTable.clearSelection(); removeActionButton.setEnabled(false); } else { actionTable.getSelectionModel().setSelectionInterval(0, 0); removeActionButton.setEnabled(true); } }
From source file:org.cytoscape.dyn.internal.graphMetrics.GraphMetricsPanel.java
@Override public void actionPerformed(ActionEvent e) { /*// w ww. j av a2s . c o m * if Plot Chart JButton is clicked, we check which attributes are * checked by the user and store their names in a String array and then * generate a chart of the checked attributes using a class * GenerateChart. */ checkedAttributes = new ArrayList<String>(); edgeCheckedAttributes = new ArrayList<String>(); if (e.getSource() == plotChartButton) { for (int i = 0; i < attributesTable.getRowCount(); i++) { if (attributesTable.getValueAt(i, 1).equals(new Boolean(true))) { checkedAttributes.add(attributesTable.getValueAt(i, 0).toString()); } } for (int i = 0; i < edgeAttributesTable.getRowCount(); i++) { if (edgeAttributesTable.getValueAt(i, 1).equals(new Boolean(true))) { edgeCheckedAttributes.add(edgeAttributesTable.getValueAt(i, 0).toString()); } } List<CyNode> selectedNodes = CyTableUtil.getNodesInState(dynamicNetwork.getNetwork(), "selected", true); List<CyEdge> selectedEdges = CyTableUtil.getEdgesInState(dynamicNetwork.getNetwork(), "selected", true); if (checkedAttributes.isEmpty() && edgeCheckedAttributes.isEmpty()) JOptionPane.showMessageDialog(null, "Please select a node/edge attribute from the table and then try to plot!"); else if (selectedNodes.isEmpty() && !checkedAttributes.isEmpty()) JOptionPane.showMessageDialog(null, "You checked a node attribute. Please select a node to get the plot!"); else if (selectedEdges.isEmpty() && !edgeCheckedAttributes.isEmpty()) JOptionPane.showMessageDialog(null, "You checked an edge attribute. Please select an edge to get the plot!"); else { GenerateChart<T> chartGenerator = new GenerateChart<T>(this.dynamicNetwork, checkedAttributes, edgeCheckedAttributes, selectedNodes, selectedEdges); JFreeChart timeSeries = chartGenerator.generateTimeSeries(); XYSeriesCollection dataset = chartGenerator.getDataset(); GraphMetricsResultsPanel<T, C> resultsPanel = new GraphMetricsResultsPanel<T, C>(timeSeries, cyactivator, dataset, dynamicNetwork); cyactivator.getCyServiceRegistrar().registerService(resultsPanel, CytoPanelComponent.class, new Properties()); cyactivator.getCySwingAppication().getCytoPanel(CytoPanelName.EAST).setState(CytoPanelState.DOCK); cyactivator.getCySwingAppication().getCytoPanel(CytoPanelName.EAST).setSelectedIndex(cyactivator .getCySwingAppication().getCytoPanel(CytoPanelName.EAST).indexOfComponent(resultsPanel)); } } if (e.getSource() == closeTab) { cyactivator.getCyServiceRegistrar().unregisterService( /*cyactivator.getCySwingAppication().getCytoPanel(CytoPanelName.EAST).getSelectedComponent()*/this, CytoPanelComponent.class); } }