List of usage examples for java.awt.event ActionEvent getActionCommand
public String getActionCommand()
From source file:ffx.ui.ModelingPanel.java
/** * {@inheritDoc}//from w w w.ja va2 s .c o m */ @Override public void actionPerformed(ActionEvent evt) { synchronized (this) { String actionCommand = evt.getActionCommand(); // A change to the selected TINKER Command switch (actionCommand) { case "FFXCommand": JComboBox jcb = (JComboBox) toolBar.getComponentAtIndex(2); String com = jcb.getSelectedItem().toString(); if (!com.equals(activeCommand)) { activeCommand = com.toLowerCase(); loadCommand(); } break; case "LogSettings": // A change to the Log Settings. loadLogSettings(); statusLabel.setText(" " + createCommandInput()); break; case "Launch": // Launch the selected Force Field X command. runScript(); break; case "NUCLEIC": case "PROTEIN": // Editor functions for the Protein and Nucleic Acid Builders builderCommandEvent(evt); break; case "Conditional": // Some command options are conditional on other input. conditionalCommandEvent(evt); break; case "End": // End the currently executing command. setEnd(); break; case "Delete": // Delete log files. deleteLogs(); break; case "Description": // Allow command descriptions to be hidden. JCheckBoxMenuItem box = (JCheckBoxMenuItem) evt.getSource(); setDivider(box.isSelected()); break; default: logger.log(Level.WARNING, "ModelingPanel ActionCommand not recognized: {0}", evt); break; } } }
From source file:ffx.ui.ModelingPanel.java
private void builderCommandEvent(ActionEvent evt) { JButton button = (JButton) evt.getSource(); String arg = evt.getActionCommand(); int index = acidComboBox.getSelectedIndex(); String selected = (String) acidComboBox.getItemAt(index); if ("Remove".equals(button.getText())) { // Remove one entry if (acidComboBox.getItemCount() > 0) { acidComboBox.removeItemAt(index); index--;/* w w w .j a v a 2 s . co m*/ } } else if ("Edit".equals(button.getText())) { String entry = new String(acidTextField.getText()); // Allow editing - should add more input validation here if (!entry.equals("")) { String s[] = entry.trim().split(" +"); String newResidue = s[0].toUpperCase(); if ("NUCLEIC".equals(arg)) { // Residue.NA3Set.contains(newResidue); try { Residue.NA3.valueOf(newResidue); acidComboBox.removeItemAt(index); acidComboBox.insertItemAt("" + index + " " + entry, index); } catch (Exception e) { } } else { try { Residue.AA3.valueOf(newResidue); acidComboBox.removeItemAt(index); acidComboBox.insertItemAt("" + index + " " + entry, index); } catch (Exception e) { } } } } else if ("Reset".equals(button.getText())) { // Remove all entries acidComboBox.removeAllItems(); acidTextArea.setText(""); } else { // A base/residue button was selected String newResidue = button.getText(); if ("PROTEIN".equals(arg)) { String c = (String) conformationComboBox.getSelectedItem(); if (!c.toUpperCase().startsWith("DEFAULT")) { c = c.substring(c.indexOf("[") + 1, c.indexOf("]")); newResidue = newResidue + " " + c; } acidComboBox.insertItemAt("" + index + " " + newResidue, index + 1); index++; } else { if (!newResidue.equalsIgnoreCase("MOL")) { acidComboBox.insertItemAt("" + index + " " + newResidue, index + 1); index++; } else if (!selected.equalsIgnoreCase("MOL")) { acidComboBox.insertItemAt("" + index + " " + newResidue, index + 1); index++; } } } // Create the condensed sequence view. StringBuilder sequence = new StringBuilder(); for (int i = 0; i < acidComboBox.getItemCount(); i++) { String s[] = ((String) acidComboBox.getItemAt(i)).trim().toUpperCase().split(" +"); if (s.length > 1) { if (s[1].equalsIgnoreCase("MOL")) { sequence.append(s[1]).append("\n"); } else { sequence.append(s[1]).append(" "); } } } // Renumber the sequence. acidTextArea.setText(sequence.toString()); for (int i = 0; i < acidComboBox.getItemCount(); i++) { String s = (String) acidComboBox.getItemAt(i); s = s.substring(s.indexOf(" "), s.length()).trim(); acidComboBox.removeItemAt(i); acidComboBox.insertItemAt("" + (i + 1) + " " + s, i); } // Set the selected entry and fill in the edit textField. if (index < 0) { index = 0; } if (index > acidComboBox.getItemCount() - 1) { index = acidComboBox.getItemCount() - 1; } acidComboBox.setSelectedIndex(index); String s = (String) acidComboBox.getItemAt(index); if (s != null) { acidTextField.setText(s.substring(s.indexOf(" "), s.length()).trim()); } else { acidTextField.setText(""); } }
From source file:org.fhaes.jsea.JSEAFrame.java
@Override public void actionPerformed(ActionEvent event) { if (event.getActionCommand().equals("SegmentationMode")) { Boolean $success = this.validateDataFiles(); if ($success == null) { log.debug("Files not set yet"); return; } else if ($success == false) { log.debug("Invalid file ranges"); return; }/* w ww . ja v a2 s . c o m*/ if (segmentationPanel.chkSegmentation.isSelected() && chronologyYears.size() > 1) { segmentationPanel.table.setEarliestYear(Integer.parseInt(this.firstPossibleYear.toString())); segmentationPanel.table.setLatestYear(Integer.parseInt(this.lastPossibleYear.toString())); } else { // cannot perform segmentation if there are less than 2 years in the chronology segmentationPanel.chkSegmentation.setSelected(false); } } else if (event.getActionCommand().equals("AllYearsCheckbox")) { setYearRangeGUI(); } else if (event.getActionCommand().equals("TimeSeriesFileBrowse")) { String lastVisitedFolder = App.prefs.getPref(PrefKey.PREF_LAST_READ_TIME_SERIES_FOLDER, App.prefs.getPref(PrefKey.PREF_LAST_READ_FOLDER, null)); JFileChooser fc; if (lastVisitedFolder != null) { fc = new JFileChooser(lastVisitedFolder); } else { fc = new JFileChooser(); } fc.setMultiSelectionEnabled(false); fc.setDialogTitle("Open file"); fc.addChoosableFileFilter(new TXTFileFilter()); fc.setAcceptAllFileFilterUsed(false); fc.setFileFilter(new CSVFileFilter()); int returnVal = fc.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { txtTimeSeriesFile.setText(fc.getSelectedFile().getAbsolutePath()); txtwrapper.updatePref(); App.prefs.setPref(PrefKey.PREF_LAST_READ_TIME_SERIES_FOLDER, fc.getSelectedFile().getPath()); if (parseTimeSeriesFile()) { setYearRangeGUI(); } else { txtTimeSeriesFile.setText(""); } validateForm(); } } else if (event.getActionCommand().equals("EventListFileBrowse")) { String lastVisitedFolder = App.prefs.getPref(PrefKey.PREF_LAST_READ_EVENT_LIST_FOLDER, App.prefs.getPref(PrefKey.PREF_LAST_READ_FOLDER, null)); JFileChooser fc; if (lastVisitedFolder != null) { fc = new JFileChooser(lastVisitedFolder); } else { fc = new JFileChooser(); } fc.setMultiSelectionEnabled(false); fc.setDialogTitle("Open file"); int returnVal = fc.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { txtEventListFile.setText(fc.getSelectedFile().getAbsolutePath()); App.prefs.setPref(PrefKey.PREF_LAST_READ_EVENT_LIST_FOLDER, fc.getSelectedFile().getPath()); parseEventListFile(); validateForm(); } } }
From source file:edu.harvard.i2b2.query.ui.QueryConceptTreePanel.java
public void actionPerformed(ActionEvent e) { if (e.getActionCommand().equalsIgnoreCase("Constrain Item ...")) { //JOptionPane.showMessageDialog(this, "Constrain Item ..."); //DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getSelectionPath().getLastPathComponent(); //QueryConceptTreeNodeData ndata = (QueryConceptTreeNodeData) node.getUserObject(); //final QueryConstrainFrame cframe = new QueryConstrainFrame(ndata); //cframe.setTitle("Constrain Item: "+ndata.name()); java.awt.EventQueue.invokeLater(new Runnable() { public void run() { //cframe.setVisible(true); }/*from ww w .ja v a 2s.c om*/ }); } else if (e.getActionCommand().equalsIgnoreCase("Delete Item")) { //JOptionPane.showMessageDialog(this, "Delete Item"); DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getSelectionPath().getLastPathComponent(); treeModel.removeNodeFromParent(node); data().getItems().remove(node.getUserObject()); } else if (e.getActionCommand().equalsIgnoreCase("Set Value ...")) { final DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getSelectionPath() .getLastPathComponent(); final QueryConceptTreeNodeData ndata = (QueryConceptTreeNodeData) node.getUserObject(); final QueryConceptTreePanel parent = this; int index = data().getItems().indexOf(node.getUserObject()); currentData = data().getItems().get(index); java.awt.EventQueue.invokeLater(new Runnable() { public void run() { if (ndata.valuePropertyData().hasEnumValue()) { EnumValueConstrainFrame vDialog = new EnumValueConstrainFrame(parent); vDialog.setSize(410, 330); vDialog.setLocation(300, 300); vDialog.setTitle("Choose value of " + ndata.titleName()); vDialog.setVisible(true); } else { NumericValueConstrainFrame vDialog = new NumericValueConstrainFrame(parent); vDialog.setSize(410, 215); vDialog.setLocation(300, 300); vDialog.setTitle("Choose value of " + ndata.titleName()); vDialog.setVisible(true); } } }); } }
From source file:edu.ucla.stat.SOCR.applications.demo.BinomialTradingApplication.java
public void actionPerformed(ActionEvent evt) { /* Here we need the action listeners for all of the user-specified parameters in the COntrol-Panel * See init() method!!!//w w w . j a va 2 s . c o m * 1.a Floating-point Text-Field for So = Price of the stock at time zero, So>=0. * 1.b Floating-Point Text-Field for EP = Exercise price (it is exercised at the end if price of stock at the end > EP), EP>=0. * 1.c Integer Slider for t = Time until expiration in years, 0<=t<=365. * 1.d Floating-Point Text-Field for r = Interest rate per year (0.000<=r). * 1.e Floating Point Text-Field for sigma = Annual volatility (0.000<=sigma). * 1.f Integer Slider for n = Number of periods that we divide the time to expiration (0<=n<=1000). */ //System.out.println(evt.getActionCommand()); if (evt.getSource() instanceof JComboBox) { JComboBox JCB = (JComboBox) evt.getSource(); choice = (String) JCB.getSelectedItem(); choice = choice.toLowerCase(); chartPanel2.validate(); inputPanel.validate(); } else if (evt.getActionCommand().equals("S0")) { So = Double.parseDouble(inSo.getText()); } else if (evt.getActionCommand().equals("EP")) { EP = Double.parseDouble(inEP.getText()); } else if (evt.getActionCommand().equals("Sigma")) { sigma = Double.parseDouble(inSigma.getText()); } else if (evt.getActionCommand().equals("Rate")) { rate = Double.parseDouble(inR.getText()); } updateAllNodes(); }
From source file:edu.harvard.i2b2.query.ui.ConceptTreePanel.java
public void actionPerformed(ActionEvent e) { if (e.getActionCommand().equalsIgnoreCase("Constrain Item ...")) { // JOptionPane.showMessageDialog(this, "Constrain Item ..."); // DefaultMutableTreeNode node = (DefaultMutableTreeNode) // jTree1.getSelectionPath().getLastPathComponent(); // QueryConceptTreeNodeData ndata = (QueryConceptTreeNodeData) // node.getUserObject(); // final QueryConstrainFrame cframe = new // QueryConstrainFrame(ndata); // cframe.setTitle("Constrain Item: "+ndata.name()); java.awt.EventQueue.invokeLater(new Runnable() { public void run() { // cframe.setVisible(true); }//from w w w .j a v a 2 s . c o m }); } else if (e.getActionCommand().equalsIgnoreCase("Delete Item")) { // JOptionPane.showMessageDialog(this, "Delete Item"); DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getSelectionPath().getLastPathComponent(); treeModel.removeNodeFromParent(node); data().getItems().remove(node.getUserObject()); } else if (e.getActionCommand().equalsIgnoreCase("Set Value ...")) { final DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getSelectionPath() .getLastPathComponent(); final QueryConceptTreeNodeData ndata = (QueryConceptTreeNodeData) node.getUserObject(); final ConceptTreePanel parent = this; int index = data().getItems().indexOf(node.getUserObject()); currentData = data().getItems().get(index); java.awt.EventQueue.invokeLater(new Runnable() { public void run() { if (ndata.valuePropertyData().hasEnumValue()) { EnumValueConstrainFrame vDialog = new EnumValueConstrainFrame(parent); vDialog.setSize(410, 330); vDialog.setLocation(300, 300); vDialog.setTitle("Choose value of " + ndata.titleName()); vDialog.setVisible(true); } else { NumericValueConstrainFrame vDialog = new NumericValueConstrainFrame(parent); vDialog.setSize(410, 215); vDialog.setLocation(300, 300); vDialog.setTitle("Choose value of " + ndata.titleName()); vDialog.setVisible(true); } } }); } }
From source file:PickTest.java
public void actionPerformed(ActionEvent e) { String name = ((Component) e.getSource()).getName(); String value = e.getActionCommand(); //System.out.println("action: name = " + name + " value = " + value); if (name == pickModeString) { if (value == boundsString) { setPickMode(PickCanvas.BOUNDS); } else if (value == geometryString) { setPickMode(PickCanvas.GEOMETRY); } else if (value == geometryIntersectString) { setPickMode(PickCanvas.GEOMETRY_INTERSECT_INFO); } else {//from w w w . j a v a 2s.co m System.out.println("Unknown pick mode: " + value); } } else if (name == toleranceString) { if (value == tolerance0String) { setPickTolerance(0.0f); } else if (value == tolerance2String) { setPickTolerance(2.0f); } else if (value == tolerance4String) { setPickTolerance(4.0f); } else if (value == tolerance8String) { setPickTolerance(8.0f); } else { System.out.println("Unknown tolerance: " + value); } } else if (name == viewModeString) { if (value == perspectiveString) { setViewMode(View.PERSPECTIVE_PROJECTION); } else if (value == parallelString) { setViewMode(View.PARALLEL_PROJECTION); } } else { System.out.println("Unknown action name: " + name); } }
From source file:br.org.acessobrasil.ases.ferramentas_de_reparo.vista.script.PainelScript.java
public void actionPerformed(ActionEvent e) { String cmd = e.getActionCommand(); if (cmd == "SaveAs") { salvaAlteracoes.salvarComo();/*w ww.jav a 2 s . co m*/ // salvarComo(); } else if (cmd == "AbrirURL") { abreUrl(); } else if (cmd == "Sair") { salvaAlteracoes.sair(); } else if (cmd == "Salvar") { salvaAlteracoes.salvar(); } else if (cmd == "Abrir") { Abrir(); } else if (cmd == "AbrirURL") { abreUrl(); } else if (cmd.equals("SelecionarTudo")) { textAreaSourceCode.getTextPane().selectAll(); textAreaSourceCode.getTextPane().requestFocus(); } else if (cmd == "SaveAs") { salvaAlteracoes.salvarComo(); // salvarComo(); } else if (cmd == "Sair") { salvaAlteracoes.sair(); } else if (cmd == "Desfazer") { // boxCode.undo(); // boxCode.coloreSource(); // reavalia(boxCode.getText()); } else if (cmd == "AumentaFonte") { textAreaSourceCode.aumentaFontSize(); } else if (cmd == "Creditos") { new Creditos(); } else if (cmd == "DiminuiFonte") { textAreaSourceCode.diminuiFontSize(); } else if (cmd == "Contraste") { textAreaSourceCode.autoContraste(); int selectedStart = 0; int selectedEnd = 0; int corretordePosicoesdoLabel = 0; int corretordePosicoesdoControle = 0; ArrayList<Integer> ordenador = new ArrayList<Integer>(); ArrayList<String> conteudoParticRotuloOrdenado = new ArrayList<String>(); conteudoParticRotulo = null; conteudoParticRotulo = tArParticipRotulo.getTextoEPos(); String[] conteudo = new String[3]; String codHTML = textAreaSourceCode.getTextPane().getText().replace("\r", ""); // System.out.println(codHTML.substring((Integer) (getPosTagRepEnd() // + corretordePosicoesdoControle - 1), (getPosTagRepEnd() + // corretordePosicoesdoControle - 1) + 36)); while (codHTML.indexOf("SIL" + inicial) != -1) { inicial++; } ColorModel cm = tArParticipRotulo.getColorModel(); for (String conteudoPR : conteudoParticRotulo) { conteudo = conteudoPR.split("@"); ordenador.add(Integer.parseInt(conteudo[1])); } int[] ordem = new int[ordenador.size()]; for (int i = 0; i < ordem.length; i++) { ordem[i] = ordenador.get(i); } Arrays.sort(ordem); for (int i = 0; i < ordem.length; i++) { for (String conteudoPR : conteudoParticRotulo) { conteudo = conteudoPR.split("@"); if (Integer.parseInt(conteudo[1]) == ordem[i]) { conteudoParticRotuloOrdenado.add(conteudoPR); } } } for (String conteudoPR : conteudoParticRotuloOrdenado) { conteudo = conteudoPR.split("@"); // System.out.println("posico: " + // Integer.parseInt(conteudo[1])); } for (String conteudoPR : conteudoParticRotuloOrdenado) { conteudo = conteudoPR.split("@"); conteudo[0] = "<label for=\"SIL" + inicial + "\">" + conteudo[0] + "</label>"; selectedStart = Integer.parseInt(conteudo[1]) + corretordePosicoesdoLabel; selectedEnd = Integer.parseInt(conteudo[2]) + corretordePosicoesdoLabel; // corretordePosicoesdoLabel += ("<label for=\"SIL" + inicial + // "\"></label>").length(); if ((selectedStart < getPosTagRepInit() + corretordePosicoesdoLabel)) { corretordePosicoesdoControle = corretordePosicoesdoLabel; } /* * if((selectedStart>getPosTagRepInit()+corretordePosicoesdoLabel)){ * //arTextPainelCorrecao.select(selectedStart+("id=x").length(), * selectedEnd+("id=x").length()); * * }else{ } */ // scrollPaneCorrecaoLabel.getTextPane().select(selectedStart, // selectedEnd); // arTextPainelCorrecao.setTextoParaSelecionado(conteudo[0]); arTextPainelCorrecao.setASet(arTextPainelCorrecao.getSc().addAttributes(SimpleAttributeSet.EMPTY, SimpleAttributeSet.EMPTY)); textAreaSourceCode.getTextPane().select(selectedStart, selectedEnd); arTextPainelCorrecao.setColorForSelectedText(new Color(255, 204, 102), new Color(0, 0, 0)); textAreaSourceCode.getTextPane().setCharacterAttributes(arTextPainelCorrecao.getASet(), false); } // arTextPainelCorrecao.formataHTML(); // tArParticipRotulo.apagaTexto(); TabelaDescricao tcl = tableLinCod; int linha = (Integer) dtm.getValueAt(tcl.getSelectedRow(), 0); int coluna = (Integer) dtm.getValueAt(tcl.getSelectedRow(), 1); int endTag = 0; int posAtual = 0; int posFinal = 0; codHTML = textAreaSourceCode.getTextPane().getText().replace("\r", ""); int i; for (i = 0; i < (linha - 1); i++) { posAtual = codHTML.indexOf("\n", posAtual + 1); } i = 0; // gambiarra provisria posFinal = codHTML.indexOf((String) dtm.getValueAt(tcl.getSelectedRow(), 2), posAtual + coluna); while (codHTML.charAt(posFinal + i) != '>') { i++; } setPosTagRepInit(posFinal); setPosTagRepEnd(posFinal + i + 1); textAreaSourceCode.goToLine(linha); textAreaSourceCode.getTextPane().select(getPosTagRepInit(), getPosTagRepEnd()); arTextPainelCorrecao.setColorForSelectedText(Color.decode("0xEEEEEE"), new Color(255, 0, 0)); arTextPainelCorrecao.setUnderline(); // TODO Auto-generated method stub // tArParticipRotulo.apagaTexto(); } }
From source file:lejos.pc.charting.LogChartFrame.java
/** Attempt to start a connection using a thread so the GUI stays responsive. Manage connect button state * @param e// w ww . ja v a 2 s . c om */ private void jButtonConnect_actionPerformed(ActionEvent e) { final ActionEvent ee = e; Runnable doAction = new Runnable() { public void run() { if (jButtonConnect.getText().equals("Connect")) { if (!isNXTConnected) { jButtonConnect.setText("Connecting.."); jButtonConnect.setEnabled(false); LogChartFrame.this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); if (makeConnection()) { jButtonConnect.setText("Disconnect"); } else { jButtonConnect.setText("Connect"); } LogChartFrame.this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); jButtonConnect.setEnabled(true); } System.out.println(ee.getActionCommand().toString()); } else { closeCurrentConnection(); } } }; new Thread(doAction).start(); }
From source file:windows.sensorWindow.java
@Override public void actionPerformed(ActionEvent e) { for (int i = 0; i < connectionData.presentedBrickList.size(); i++) { Brick tmpBrick = connectionData.presentedBrickList.get(i); String command = e.getActionCommand().substring(0, e.getActionCommand().length() - 4); String indexStr = e.getActionCommand().substring(e.getActionCommand().length() - 4, e.getActionCommand().length() - 3); int index = Integer.valueOf(indexStr); // start template control if ((command.equals(buttonComAddBtn + tmpBrick.uid)) && (!tmpBrick.ctrlTmplruns[index])) { System.out.println("set new template start time"); long timeNow = System.currentTimeMillis(); tmplStartMs.put(tmpBrick.uid, timeNow); tmplLapCnt.put(tmpBrick.uid, 0); // start auto update plot // autoUpdatePlot(); startStopTmplCntrl(tmpBrick, index); }//w w w .j a va 2s. c o m // stop template control else if ((command.equals(buttonComAddBtn + tmpBrick.uid)) && (tmpBrick.ctrlTmplruns[index])) { startStopTmplCntrl(tmpBrick, index); } } }