List of usage examples for java.awt.event ActionEvent getSource
public Object getSource()
From source file:com.alvermont.terraj.stargen.ui.StargenFrame.java
private void subclassComboActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_subclassComboActionPerformed {//GEN-HEADEREND:event_subclassComboActionPerformed JComboBox src = (JComboBox) evt.getSource(); this.parameters.setSpectralSubclass(Integer.parseInt((String) (src.getModel().getSelectedItem()))); }
From source file:modnlp.capte.AlignmentInterfaceWS.java
public void actionPerformed(ActionEvent e) { //Handle open button action. if (e.getSource() == openButton) { int returnVal = fc.showOpenDialog(AlignmentInterfaceWS.this); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); //This is where a real application would open the file. sourceFile = file.getAbsolutePath(); log.append("Source File: " + sourceFile + "." + newline); } else {//from w w w .jav a 2s .com log.append("Open command cancelled by user." + newline); } log.setCaretPosition(log.getDocument().getLength()); } //deleteSegment else if (e.getSource() == deleteSegment) { Object[] o; String ivalue; int[] selected = table.getSelectedRows(); ExampleTableModel em = (ExampleTableModel) table.getModel(); if (selected.length < 1) { System.out.println("Please select at least one row"); JOptionPane.showMessageDialog(edit, "Please select at least one row"); } else { System.out.println("Deleting rows..."); for (int i = selected.length - 1; i > -1; i--) { em.removeRow(selected[i]); //update numbers System.out.println("Removed row " + selected[i]); } } //Table should update itself automatically } else if (e.getSource() == moveUp) { int[] selected = table.getSelectedRows(); ExampleTableModel em = (ExampleTableModel) table.getModel(); if (selected.length > 1) { System.out.println("You can only move one segment at a time!"); JOptionPane.showMessageDialog(edit, "You can only move one segment at a time!"); } else if (selected[0] == 0) { System.out.println("Can't move up anymore!"); JOptionPane.showMessageDialog(edit, "Can't move up anymore!"); } else { System.out.println("Moving " + selected[0]); em.moveSegmentUp(selected[0]); //Table should repaint } } else if (e.getSource() == moveDown) { int[] selected = table.getSelectedRows(); ExampleTableModel em = (ExampleTableModel) table.getModel(); if (selected.length > 1) { System.out.println("You can only move one segment at a time!"); JOptionPane.showMessageDialog(edit, "You can only move one segment at a time!"); } else if (selected[0] == em.getRowCount() - 1) { System.out.println("Can't move down anymore!"); JOptionPane.showMessageDialog(edit, "Can't move down anymore"); } else { System.out.println("Moving " + selected[0]); em.moveSegmentDown(selected[0]); //Table should repaint } } else if (e.getSource() == mergeSource) { int[] selected = table.getSelectedRows(); ExampleTableModel em = (ExampleTableModel) table.getModel(); if (selected.length < 2 || selected.length > 2) { System.out.println("Please select two rows to merge "); JOptionPane.showMessageDialog(edit, "Please select two rows to merge"); } else if (selected[0] - selected[1] > 1 || selected[0] - selected[1] < -1) { System.out.println("Can only merge adjacent rows"); JOptionPane.showMessageDialog(edit, "Can only merge adjacent rows"); } else { System.out.println("Merging source in rows " + selected[0] + " " + selected[1]); em.mergeSource(selected[0], selected[1]); } } else if (e.getSource() == mergeTarget) { int[] selected = table.getSelectedRows(); ExampleTableModel em = (ExampleTableModel) table.getModel(); if (selected.length < 2 || selected.length > 2) { System.out.println("Please select two rows to merge "); JOptionPane.showMessageDialog(edit, "Please select two rows to merge"); } else if (selected[0] - selected[1] > 1 || selected[0] - selected[1] < -1) { System.out.println("Can only merge adjacent rows"); JOptionPane.showMessageDialog(edit, "Can only merge adjacent rows"); } else { System.out.println("Merging target in " + selected[0] + " " + selected[1]); em.mergeTarget(selected[0], selected[1]); } } else if (e.getSource() == newSegment) { int[] selected = table.getSelectedRows(); ExampleTableModel em = (ExampleTableModel) table.getModel(); if (selected.length < 1) { System.out.println("Please select a position to insert at:"); JOptionPane.showMessageDialog(edit, "Please select a position to insert at"); } else { System.out.println("Inserting new segment at " + (selected[0] + 1)); //insert empty string array Object[] sa = new Object[6]; sa[0] = ""; sa[1] = ""; sa[2] = "0.0"; sa[3] = new Boolean(false); sa[4] = "0"; sa[5] = em.getValueAt((selected[0]), 5) + "(+)"; em.insertRow(sa, (selected[0] + 1)); } } else if (e.getSource() == lockSelected) { int[] selected = table.getSelectedRows(); ExampleTableModel em = (ExampleTableModel) table.getModel(); if (selected.length < 1) { System.out.println("Please select some rows to lock:"); JOptionPane.showMessageDialog(edit, "Please select some rows to lock:"); } else { //lock selected rows for (int i = 0; i < selected.length; i++) { em.lockRow(selected[i]); System.out.println("Locking row " + selected[i]); } } } else if (e.getSource() == unlockSelected) { int[] selected = table.getSelectedRows(); ExampleTableModel em = (ExampleTableModel) table.getModel(); if (selected.length < 1) { System.out.println("Please select some rows to unlock:"); JOptionPane.showMessageDialog(edit, "Please select some rows to unlock:"); } else { //lock selected rows for (int i = 0; i < selected.length; i++) { em.unlockRow(selected[i]); System.out.println("Unlocking row " + selected[i]); } } } else if (e.getSource() == reAlign) { // if(true){ // JOptionPane.showMessageDialog(edit,"This feature is currently disabled"); // }else{ reNumber++; ExampleTableModel em = (ExampleTableModel) table.getModel(); // Get list of locked segments // Find lowest locked segment // Realign from lowest locked segment // Join the realigned bit back up with the locked bit // refresh the table int lowestlock = 0; Vector<Object[]> slice = new Vector<Object[]>(); Vector<Object[]> result = new Vector<Object[]>(); Vector<Object[]> locked = new Vector<Object[]>(); Boolean b = new Boolean(true); for (int i = 0; i < em.getRowCount(); i++) { b = (Boolean) em.getValueAt(i, 3); if (b.booleanValue() == true) { lowestlock = i; } } //get slice of table for realignment System.out.println("The lowest lock point is " + (lowestlock)); System.out.println("Realigning from row:" + (lowestlock + 1) + " to : " + em.getRowCount()); System.out.println("Total size of realign array =:" + (em.getRowCount() - (lowestlock))); //Get locked bits for (int h = 0; h < lowestlock + 1; h++) { locked.add(em.getRow(h)); } //Get bits to realign for (int j = lowestlock + 1; j < em.getRowCount(); j++) { slice.add(em.getRow(j)); } //flush em.flush(); for (int z = 0; z < locked.size(); z++) { em.insertRow(locked.get(z), z); } // System.out.println("Total size of array after bits removed = " + (em.getRowCount())); //get the directory where the source files came from File parent = new File(sourceFile).getParentFile(); String dir = parent.getAbsolutePath(); //create files File sf = null; File tf = null; try { sf = File.createTempFile("source", "tmp"); tf = File.createTempFile("target", "tmp"); } catch (IOException ef) { ef.printStackTrace(); } System.out.println("Writing temp file:" + sf.getName()); System.out.println("Writing temp file:" + tf.getName()); // File mf = new File("merged.tmp"); //get absolute paths String sourceF = sf.getAbsolutePath(); String targetF = tf.getAbsolutePath(); //String alignF = mf.getAbsolutePath(); //write out source and target to files //NEW write files to server and return string String alignment = ""; AlignerUtils.reWriteAlignment(targetF, sourceF, slice); try { alignment = AlignerUtils.MultiPartFileUpload(targetF, sourceF); } catch (IOException es) { es.printStackTrace(); } //convert the String to a Vector form result = AlignerUtils.StringToData(alignment, true, reNumber); // append the resultant file to the table //System.out.println("Total size of array before bits inserted = " + (em.getRowCount())); for (int y = 0, z = em.getRowCount(); y < result.size(); y++, z++) { em.insertRow(result.get(y), z); System.out.println("Inserting at position: " + z); System.out.println("Inserting from position: " + y); } // System.out.println("Total size of array after bits inserted = " + (em.getRowCount())); // } } else if (e.getSource() == saveButton) { int returnVal = fc.showSaveDialog(AlignmentInterfaceWS.this); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); //This is where a real application would save the file. targetFile = file.getAbsolutePath(); log.append("Target File " + targetFile + "." + newline); } else { log.append("Save command cancelled by user." + newline); } log.setCaretPosition(log.getDocument().getLength()); } else if (e.getSource() == export) { int returnVal = fc.showSaveDialog(AlignmentInterfaceWS.this); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); outputFile = file.getAbsolutePath(); //aserver.writeAlignment(targetFile,data); AlignerUtils.writeAlignment(outputFile, data); log.append(newline + "Saving " + outputFile + "." + newline); } else { log.append("Save command cancelled by user." + newline); } log.setCaretPosition(log.getDocument().getLength()); } else if (e.getSource() == alignButton) { if (sl.getText().length() >= 2 && tl.getText().length() >= 2) { log.append("Attempting to align texts"); sourcel = sl.getText(); targetl = tl.getText(); String aligned = ""; try { aligned = AlignerUtils.MultiPartFileUpload(sourceFile, targetFile); } catch (IOException ed) { ed.printStackTrace(); } //Convert string to alignment format data = AlignerUtils.StringToData(aligned, false, 0); int i = 0; // // AlreadyRun = true; if (i == 0) { //log.setCaretPosition(log.getDocument().getLength()); log.append("\nAutomatic alignment successful!"); log.append("\nOpening display window......"); //Set up the editor window JFrame edit = new JFrame("Alignment Editor"); cols = new Vector<String>(); cols.add("Source"); cols.add("Target"); cols.add("Score"); cols.add("Lock"); cols.add("Index"); cols.add("Orig"); System.out.println("Size of data array " + data.size()); System.out.println(data.get(0)[0]); ex = new ExampleTableModel(cols, data); //ex.addTableModelListener(this); table = new JTable(ex); table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); TableColumnModel cmodel = table.getColumnModel(); cmodel.getColumn(0).setCellRenderer(new TextAreaRenderer()); cmodel.getColumn(1).setCellRenderer(new TextAreaRenderer()); cmodel.getColumn(2).setCellRenderer(new TextAreaRenderer()); cmodel.getColumn(4).setCellRenderer(new TextAreaRenderer()); cmodel.getColumn(5).setCellRenderer(new TextAreaRenderer()); TextAreaEditor textEditor = new TextAreaEditor(); textEditor.addCellEditorListener(this); cmodel.getColumn(0).setCellEditor(textEditor); cmodel.getColumn(1).setCellEditor(textEditor); cmodel.getColumn(2).setCellEditor(textEditor); cmodel.getColumn(4).setCellEditor(textEditor); cmodel.getColumn(5).setCellEditor(textEditor); mergeTarget = new JButton("Merge target"); mergeSource = new JButton("Merge source"); export = new JButton("Export to File"); newSegment = new JButton("Create New Segment"); deleteSegment = new JButton("Delete Selected"); moveUp = new JButton("Move Segment Up"); moveDown = new JButton("Move Segment Down"); lockSelected = new JButton("Lock Selected"); unlockSelected = new JButton("Unlock Selected"); reAlign = new JButton("Realign"); reAlign.addActionListener(this); lockSelected.addActionListener(this); unlockSelected.addActionListener(this); mergeSource.addActionListener(this); mergeTarget.addActionListener(this); export.addActionListener(this); newSegment.addActionListener(this); deleteSegment.addActionListener(this); moveUp.addActionListener(this); moveDown.addActionListener(this); JPanel control = new JPanel(); JPanel manipulate = new JPanel(); control.add(moveUp); control.add(moveDown); control.add(mergeTarget); control.add(mergeSource); //control.add(export); control.add(newSegment); control.add(deleteSegment); manipulate.add(reAlign); manipulate.add(lockSelected); manipulate.add(unlockSelected); manipulate.add(export); edit.add(control, BorderLayout.PAGE_START); edit.add(manipulate, BorderLayout.PAGE_END); JScrollPane scr = new JScrollPane(table); // JTable rowTable = new FirstRowNumberTable(table); //scr.add(table); //scr.setRowHeaderView(rowTable); //scr.setCorner(JScrollPane.UPPER_LEFT_CORNER, rowTable.getTableHeader()); scr.repaint(); edit.add(scr, BorderLayout.CENTER); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); edit.setSize(screenSize.width - 4, screenSize.height - 50); int totwidth = screenSize.width - 50; table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); cmodel.getColumn(0).setPreferredWidth((totwidth / 36) * 15); cmodel.getColumn(1).setPreferredWidth((totwidth / 36) * 15); cmodel.getColumn(2).setPreferredWidth(totwidth / 36 * 2); cmodel.getColumn(3).setPreferredWidth(totwidth / 36 * 2); cmodel.getColumn(4).setPreferredWidth(totwidth / 36 * 2); cmodel.getColumn(4).setPreferredWidth(totwidth / 36 * 2); edit.validate(); // Make sure layout is ok //edit.setSize(1024,700); edit.setVisible(true); } else { //log.setCaretPosition(log.getDocument().getLength()); log.append("\nAutomatic alignment unsuccessful..check error logs"); } } else { log.append("Please enter valid two letter language codes"); } log.setCaretPosition(log.getDocument().getLength()); } }
From source file:com.google.code.facebook.graph.sna.applet.PluggableRendererDemo.java
public void actionPerformed(ActionEvent e) { AbstractButton source = (AbstractButton) e.getSource(); if (source == v_color) { seedDrawColor.setSeedColoring(source.isSelected()); seedFillColor.setSeedColoring(source.isSelected()); } else if (source == e_color) { ewcs.setWeighted(source.isSelected()); } else if (source == v_stroke) { vsh.setHighlight(source.isSelected()); } else if (source == v_labels) { if (source.isSelected()) vv.getRenderContext().setVertexLabelTransformer(vs); else/*from ww w .j a v a2s .c o m*/ vv.getRenderContext().setVertexLabelTransformer(vs_none); } else if (source == e_labels) { if (source.isSelected()) vv.getRenderContext().setEdgeLabelTransformer(es); else vv.getRenderContext().setEdgeLabelTransformer(es_none); } else if (source == e_uarrow_pred) { show_arrow.showUndirected(source.isSelected()); } else if (source == e_darrow_pred) { show_arrow.showDirected(source.isSelected()); } else if (source == e_arrow_centered) { if (source.isSelected()) { vv.getRenderer().getEdgeRenderer() .setEdgeArrowRenderingSupport(new CenterEdgeArrowRenderingSupport()); } else { vv.getRenderer().getEdgeRenderer() .setEdgeArrowRenderingSupport(new BasicEdgeArrowRenderingSupport()); } } else if (source == font) { vff.setBold(source.isSelected()); eff.setBold(source.isSelected()); } else if (source == v_shape) { vssa.useFunnyShapes(source.isSelected()); } else if (source == v_size) { vssa.setScaling(source.isSelected()); } else if (source == v_aspect) { vssa.setStretching(source.isSelected()); } else if (source == e_line) { if (source.isSelected()) { vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line<Integer, Number>()); } } else if (source == e_ortho) { if (source.isSelected()) vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Orthogonal<Integer, Number>()); } else if (source == e_wedge) { if (source.isSelected()) vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Wedge<Integer, Number>(10)); } // else if (source == e_bent) // { // if(source.isSelected()) // { // vv.getRenderContext().setEdgeShapeFunction(new EdgeShape.BentLine()); // } // } else if (source == e_quad) { if (source.isSelected()) { vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.QuadCurve<Integer, Number>()); } } else if (source == e_cubic) { if (source.isSelected()) { vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.CubicCurve<Integer, Number>()); } } else if (source == e_show_d) { show_edge.showDirected(source.isSelected()); } else if (source == e_show_u) { show_edge.showUndirected(source.isSelected()); } else if (source == v_small) { show_vertex.filterSmall(source.isSelected()); } else if (source == zoom_at_mouse) { gm.setZoomAtMouse(source.isSelected()); } else if (source == no_gradient) { if (source.isSelected()) { gradient_level = GRADIENT_NONE; } // } else if (source == gradient_absolute) { // if (source.isSelected()) { // gradient_level = GRADIENT_ABSOLUTE; // } } else if (source == gradient_relative) { if (source.isSelected()) { gradient_level = GRADIENT_RELATIVE; } } else if (source == fill_edges) { if (source.isSelected()) { vv.getRenderContext().setEdgeFillPaintTransformer(edgeFillPaint); } else { vv.getRenderContext().setEdgeFillPaintTransformer(new ConstantTransformer(null)); } // edgePaint.useFill(source.isSelected()); } vv.repaint(); }
From source file:edu.uci.ics.jung.samples.PluggableRendererDemo.java
@SuppressWarnings({ "rawtypes", "unchecked" }) public void actionPerformed(ActionEvent e) { AbstractButton source = (AbstractButton) e.getSource(); if (source == v_color) { seedDrawColor.setSeedColoring(source.isSelected()); seedFillColor.setSeedColoring(source.isSelected()); } else if (source == e_color) { ewcs.setWeighted(source.isSelected()); } else if (source == v_stroke) { vsh.setHighlight(source.isSelected()); } else if (source == v_labels) { if (source.isSelected()) vv.getRenderContext().setVertexLabelTransformer(vs); else/* www .j a va 2 s.c o m*/ vv.getRenderContext().setVertexLabelTransformer(vs_none); } else if (source == e_labels) { if (source.isSelected()) vv.getRenderContext().setEdgeLabelTransformer(es); else vv.getRenderContext().setEdgeLabelTransformer(es_none); } else if (source == e_uarrow_pred) { show_arrow.showUndirected(source.isSelected()); } else if (source == e_darrow_pred) { show_arrow.showDirected(source.isSelected()); } else if (source == e_arrow_centered) { if (source.isSelected()) { vv.getRenderer().getEdgeRenderer() .setEdgeArrowRenderingSupport(new CenterEdgeArrowRenderingSupport()); } else { vv.getRenderer().getEdgeRenderer() .setEdgeArrowRenderingSupport(new BasicEdgeArrowRenderingSupport()); } } else if (source == font) { vff.setBold(source.isSelected()); eff.setBold(source.isSelected()); } else if (source == v_shape) { vssa.useFunnyShapes(source.isSelected()); } else if (source == v_size) { vssa.setScaling(source.isSelected()); } else if (source == v_aspect) { vssa.setStretching(source.isSelected()); } else if (source == e_line) { if (source.isSelected()) { vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line<Integer, Number>()); } } else if (source == e_ortho) { if (source.isSelected()) vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Orthogonal<Integer, Number>()); } else if (source == e_wedge) { if (source.isSelected()) vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Wedge<Integer, Number>(10)); } // else if (source == e_bent) // { // if(source.isSelected()) // { // vv.getRenderContext().setEdgeShapeFunction(new EdgeShape.BentLine()); // } // } else if (source == e_quad) { if (source.isSelected()) { vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.QuadCurve<Integer, Number>()); } } else if (source == e_cubic) { if (source.isSelected()) { vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.CubicCurve<Integer, Number>()); } } else if (source == e_show_d) { show_edge.showDirected(source.isSelected()); } else if (source == e_show_u) { show_edge.showUndirected(source.isSelected()); } else if (source == v_small) { show_vertex.filterSmall(source.isSelected()); } else if (source == zoom_at_mouse) { gm.setZoomAtMouse(source.isSelected()); } else if (source == no_gradient) { if (source.isSelected()) { gradient_level = GRADIENT_NONE; } // } else if (source == gradient_absolute) { // if (source.isSelected()) { // gradient_level = GRADIENT_ABSOLUTE; // } } else if (source == gradient_relative) { if (source.isSelected()) { gradient_level = GRADIENT_RELATIVE; } } else if (source == fill_edges) { if (source.isSelected()) { vv.getRenderContext().setEdgeFillPaintTransformer(edgeFillPaint); } else { vv.getRenderContext().setEdgeFillPaintTransformer(new ConstantTransformer(null)); } // edgePaint.useFill(source.isSelected()); } vv.repaint(); }
From source file:edu.ucla.stat.SOCR.analyses.gui.Survival.java
public void actionPerformed(ActionEvent event) { //////System.out.println("Survival actionPerformed"); if (event.getSource() == addButton1) { //////System.out.println("Survival actionPerformed addButton1"); addButtonTime();//from w ww . j a v a 2 s. c o m } else if (event.getSource() == removeButton1) { //////System.out.println("Survival actionPerformed removeButton1"); removeButtonTime(); } else if (event.getSource() == addButton2) { //////System.out.println("Survival actionPerformed addButton2"); addButtonCensor(); } else if (event.getSource() == removeButton2) { //////System.out.println("Survival actionPerformed removeButton2"); removeButtonCensor(); } else if (event.getSource() == addButton3) { //////System.out.println("Survival actionPerformed addButton3"); addButtonGroupNames(); } else if (event.getSource() == removeButton3) { //////System.out.println("Survival actionPerformed removeButton3"); removeButtonGroupNames(); } }
From source file:dbseer.gui.panel.DBSeerMiddlewarePanel.java
@Override public void actionPerformed(ActionEvent actionEvent) { try {// w w w .j ava2 s .c o m if (actionEvent.getSource() == startMonitoringButton) { id = idField.getText(); password = String.valueOf(passwordField.getPassword()); ip = ipField.getText(); port = Integer.parseInt(portField.getText()); // liveDatasetPath = DBSeerGUI.userSettings.getDBSeerRootPath() + File.separator + // DBSeerConstants.LIVE_DATASET_PATH; String date = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); currentDatasetPath = DBSeerGUI.userSettings.getDBSeerRootPath() + File.separator + DBSeerConstants.ROOT_DATASET_PATH + File.separator + date; final File newDatasetDirectory = new File(currentDatasetPath); // create new dataset directory FileUtils.forceMkdir(newDatasetDirectory); if (newDatasetDirectory == null || !newDatasetDirectory.isDirectory()) { JOptionPane.showMessageDialog(DBSeerGUI.mainFrame, String.format("We could not create the dataset directory: %s", currentDatasetPath), "Message", JOptionPane.PLAIN_MESSAGE); return; } if (runner != null) { runner.stop(); } DBSeerGUI.liveMonitorPanel.reset(); DBSeerGUI.liveMonitorInfo.reset(); DBSeerGUI.middlewareStatus.setText("Middleware: Connecting..."); startMonitoringButton.setEnabled(false); stopMonitoringButton.setEnabled(false); connectSuccess = true; runner = new MiddlewareClientRunner(id, password, ip, port, currentDatasetPath, this); runner.run(); int sleepCount = 0; while (liveLogProcessor == null || !liveLogProcessor.isStarted()) { Thread.sleep(250); sleepCount += 250; if (!connectSuccess) { return; } if (sleepCount > 10000) { JOptionPane.showMessageDialog(DBSeerGUI.mainFrame, String.format("Failed to receive live logs."), "Message", JOptionPane.PLAIN_MESSAGE); runner.stop(); liveLogProcessor = null; return; } } DBSeerGUI.liveDatasets.clear(); String[] servers = liveLogProcessor.getServers(); for (String s : servers) { DBSeerDataSet newDataset = new DBSeerDataSet(); newDataset.setName(date + "_" + s); OpenDirectoryAction openDir = new OpenDirectoryAction(newDataset); openDir.openWithoutDialog(new File(newDatasetDirectory + File.separator + s)); DBSeerGUI.datasets.addElement(newDataset); newDataset.setCurrent(true); DBSeerGUI.liveDatasets.add(newDataset); } if (servers.length > 1) { DBSeerDataSet newDataset = new DBSeerDataSet(); newDataset.setName(date + "_all"); OpenDirectoryAction openDir = new OpenDirectoryAction(newDataset); openDir.openWithoutDialog(newDatasetDirectory); DBSeerGUI.datasets.addElement(newDataset); newDataset.setCurrent(true); DBSeerGUI.liveDatasets.add(newDataset); } // save last middleware connection DBSeerGUI.userSettings.setLastMiddlewareIP(ip); DBSeerGUI.userSettings.setLastMiddlewarePort(port); DBSeerGUI.userSettings.setLastMiddlewareID(id); XStreamHelper xmlHelper = new XStreamHelper(); xmlHelper.toXML(DBSeerGUI.userSettings, DBSeerGUI.settingsPath); } else if (actionEvent.getSource() == stopMonitoringButton) { int stopMonitoring = JOptionPane.showConfirmDialog(DBSeerGUI.mainFrame, "Do you really want to stop monitoring?", "Stop Monitoring", JOptionPane.YES_NO_OPTION); if (stopMonitoring == JOptionPane.YES_OPTION) { if (runner != null) { runner.stop(); } if (liveLogProcessor != null) { liveLogProcessor.stop(); } for (DBSeerDataSet dataset : DBSeerGUI.liveDatasets) { dataset.setCurrent(false); } boolean isRemoved = false; if (DBSeerGUI.dbscan == null || (DBSeerGUI.dbscan != null && !DBSeerGUI.dbscan.isInitialized())) { JOptionPane.showMessageDialog(DBSeerGUI.mainFrame, String.format( "Not enough transactions for clustering. You need at least %d transactions. Datasets are removed.", DBSeerGUI.settings.dbscanInitPts), "Message", JOptionPane.PLAIN_MESSAGE); for (DBSeerDataSet dataset : DBSeerGUI.liveDatasets) { DBSeerGUI.datasets.removeElement(dataset); } isRemoved = true; } if (!isRemoved) { if (liveLogProcessor != null && !liveLogProcessor.isTxWritingStarted()) { JOptionPane.showMessageDialog(DBSeerGUI.mainFrame, String.format( "Live monitoring has not written any transactions yet. Datasets are removed."), "Message", JOptionPane.PLAIN_MESSAGE); for (DBSeerDataSet dataset : DBSeerGUI.liveDatasets) { DBSeerGUI.datasets.removeElement(dataset); } } } DBSeerGUI.liveDatasets.clear(); if (liveLogProcessor != null) { liveLogProcessor = null; } DBSeerGUI.liveMonitorPanel.reset(); startMonitoringButton.setEnabled(true); stopMonitoringButton.setEnabled(false); DBSeerGUI.middlewareStatus.setText("Middleware: Not Connected"); } // if (DBSeerGUI.dbscan == null || // (DBSeerGUI.dbscan != null && !DBSeerGUI.dbscan.isInitialized())) // { // JOptionPane.showMessageDialog(DBSeerGUI.mainFrame, // String.format("Not enough transactions for clustering. You need at least %d transactions. Dataset is not saved.", DBSeerGUI.settings.dbscanInitPts), // "Message", JOptionPane.PLAIN_MESSAGE); // // DBSeerGUI.liveMonitorPanel.reset(); // DBSeerGUI.liveMonitorInfo.reset(); // // startMonitoringButton.setEnabled(true); // stopMonitoringButton.setEnabled(false); // DBSeerGUI.middlewareStatus.setText("Middleware: Not Connected"); // // return; // } // if (!liveLogProcessor.isTxWritingStarted()) // { // JOptionPane.showMessageDialog(DBSeerGUI.mainFrame, // String.format("Live monitoring has not written any transactions yet. Dataset is not saved."), // "Message", JOptionPane.PLAIN_MESSAGE); // // DBSeerGUI.liveMonitorPanel.reset(); // DBSeerGUI.liveMonitorInfo.reset(); // // startMonitoringButton.setEnabled(true); // stopMonitoringButton.setEnabled(false); // DBSeerGUI.middlewareStatus.setText("Middleware: Not Connected"); // // return; // } // // int saveResult = JOptionPane.showConfirmDialog(DBSeerGUI.mainFrame, "Do you want to save the monitored data?", // "Save monitored data as a dataset", JOptionPane.YES_NO_OPTION); // // if (saveResult == JOptionPane.YES_OPTION) // { // String date = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); // String newDatasetPath = DBSeerGUI.userSettings.getDBSeerRootPath() + File.separator + // DBSeerConstants.ROOT_DATASET_PATH + File.separator + date; // File liveDatasetDirectory = new File(liveDatasetPath); // final File newDatasetDirectory = new File(newDatasetPath); // // // create new dataset directory // FileUtils.forceMkdir(newDatasetDirectory); // // // copy dataset // FileUtils.copyDirectory(liveDatasetDirectory, newDatasetDirectory, false); // // // show message dialog. // JOptionPane.showMessageDialog(DBSeerGUI.mainFrame, // String.format("Dataset has been successfully saved under '%s'", newDatasetDirectory.getCanonicalPath()), // "Message", JOptionPane.PLAIN_MESSAGE); // // String[] servers = liveLogProcessor.getServers(); // for (String s : servers) // { // DBSeerDataSet newDataset = new DBSeerDataSet(); // newDataset.setName(date + "_" + s); // OpenDirectoryAction openDir = new OpenDirectoryAction(newDataset); // openDir.openWithoutDialog(new File(newDatasetDirectory + File.separator + s)); // DBSeerGUI.datasets.addElement(newDataset); // } // if (servers.length > 1) // { // DBSeerDataSet newDataset = new DBSeerDataSet(); // newDataset.setName(date + "_all"); // OpenDirectoryAction openDir = new OpenDirectoryAction(newDataset); // openDir.openWithoutDialog(newDatasetDirectory); // DBSeerGUI.datasets.addElement(newDataset); // } // SaveSettingsAction saveSettings = new SaveSettingsAction(); // saveSettings.actionPerformed(new ActionEvent(this, 0, "")); // } } else if (actionEvent.getSource() == applyRefreshRateButton) { int rate = Integer.parseInt(refreshRateField.getText()); DBSeerGUI.liveMonitorRefreshRate = rate; } } catch (Exception e) { DBSeerExceptionHandler.handleException(e); } // old implementation /* final MiddlewareSocket socket = DBSeerGUI.middlewareSocket; if (actionEvent.getSource() == logInOutButton) { if (!isLoggedIn) { String ip = ipField.getText(); int port = Integer.parseInt(portField.getText()); String id = idField.getText(); String password = String.valueOf(passwordField.getPassword()); try { if (!socket.connect(ip, port)) { return; } if (socket.login(id, password)) { if (socket.isMonitoring(true)) { DBSeerGUI.middlewareStatus.setText("Middleware Connected: " + socket.getIp() + ":" + socket.getPort() + " as " + socket.getId() + " (Monitoring)"); startMonitoringButton.setEnabled(false); stopMonitoringButton.setEnabled(true); } else { DBSeerGUI.middlewareStatus.setText("Middleware Connected: " + socket.getIp() + ":" + socket.getPort() + " as " + socket.getId()); startMonitoringButton.setEnabled(true); stopMonitoringButton.setEnabled(false); } // save last login credentials DBSeerGUI.userSettings.setLastMiddlewareIP(socket.getIp()); DBSeerGUI.userSettings.setLastMiddlewarePort(socket.getPort()); DBSeerGUI.userSettings.setLastMiddlewareID(socket.getId()); XStreamHelper xmlHelper = new XStreamHelper(); xmlHelper.toXML(DBSeerGUI.userSettings, DBSeerGUI.settingsPath); this.setLogin(); } else { JOptionPane.showMessageDialog(null, socket.getErrorMessage(), "Middleware Login Error", JOptionPane.ERROR_MESSAGE); } } catch (Exception e) { DBSeerExceptionHandler.handleException(e, "Middleware Login Error"); // JOptionPane.showMessageDialog(null, e.getMessage(), "Middleware Login Error", JOptionPane.ERROR_MESSAGE); } } else // log out { try { socket.disconnect(); startMonitoringButton.setEnabled(false); stopMonitoringButton.setEnabled(false); } catch (Exception e) { DBSeerExceptionHandler.handleException(e); } } } else if (actionEvent.getSource() == startMonitoringButton) { try { if (socket.startMonitoring()) { DBSeerGUI.middlewareStatus.setText("Middleware Connected: " + socket.getIp() + ":" + socket.getPort() + " as " + socket.getId() + " (Monitoring)"); startMonitoringButton.setEnabled(false); stopMonitoringButton.setEnabled(true); } else { JOptionPane.showMessageDialog(null, socket.getErrorMessage(), "Middleware Monitoring Error", JOptionPane.ERROR_MESSAGE); } } catch (IOException e) { JOptionPane.showMessageDialog(null, e.getMessage(), "Middleware Error", JOptionPane.ERROR_MESSAGE); } } else if (actionEvent.getSource() == stopMonitoringButton) { try { startMonitoringButton.setEnabled(true); stopMonitoringButton.setEnabled(false); if (!socket.isMonitoring(false)) { return; } final String datasetRootPath = DBSeerGUI.userSettings.getDBSeerRootPath() + File.separator + DBSeerConstants.ROOT_DATASET_PATH; final String liveDatasetPath = DBSeerGUI.userSettings.getDBSeerRootPath() + File.separator + DBSeerConstants.LIVE_DATASET_PATH; final File rawDatasetDir = new File(datasetRootPath); if (!rawDatasetDir.exists()) { rawDatasetDir.mkdirs(); } String datasetName = (String)JOptionPane.showInputDialog(this, "Enter the name of new dataset", "New Dataset", JOptionPane.PLAIN_MESSAGE, null, null, "NewDataset"); boolean getData = true; File newRawDatasetDir = null; if (datasetName == null) { getData = false; } else { // newRawDatasetDir = new File(DBSeerConstants.RAW_DATASET_PATH + File.separator + datasetName); newRawDatasetDir = new File(datasetRootPath + File.separator + datasetName); while (newRawDatasetDir.exists()) { datasetName = (String) JOptionPane.showInputDialog(this, datasetName + " already exists.\n" + "Enter the name of new dataset", "New Dataset", JOptionPane.PLAIN_MESSAGE, null, null, "NewDataset"); newRawDatasetDir = new File(datasetRootPath + File.separator + datasetName); } newRawDatasetDir.mkdirs(); } final boolean downloadData = getData; final File datasetDir = newRawDatasetDir; final String datasetNameFinal = datasetName; final JPanel middlewarePanel = this; final JButton logButton = logInOutButton; final JButton startButton = startMonitoringButton; SwingWorker<Void, Void> datasetWorker = new SwingWorker<Void, Void>() { @Override protected Void doInBackground() throws Exception { if (downloadData) { DBSeerGUI.status.setText("Stopping monitoring..."); middlewarePanel.setEnabled(false); logButton.setEnabled(false); startButton.setEnabled(false); } if (socket.stopMonitoring(downloadData)) { DBSeerGUI.middlewareStatus.setText("Middleware Connected: " + socket.getIp() + ":" + socket.getPort() + " as " + socket.getId()); DBSeerGUI.liveMonitorPanel.reset(); if (!downloadData) { return null; } // File logFile = socket.getLogFile(); // byte[] buf = new byte[8192]; // int length = 0; // // FileInputStream byteStream = new FileInputStream(logFile); // ZipInputStream zipInputStream = new ZipInputStream(byteStream); // ZipEntry entry = null; // // // unzip the monitor package. // while ((entry = zipInputStream.getNextEntry()) != null) // { // File entryFile = new File(liveDatasetPath + File.separator + entry.getName()); // new File(entryFile.getParent()).mkdirs(); // // FileOutputStream out = new FileOutputStream(liveDatasetPath + File.separator + entry.getName()); // // try // { // while ((length = zipInputStream.read(buf, 0, 8192)) >= 0) // { // out.write(buf, 0, length); // } // } // catch (EOFException e) // { // // do nothing // } // // //zipInputStream.closeEntry(); // out.flush(); // out.close(); // } // zipInputStream.close(); // move dataset from 'temp' to user-specified directory File liveDir = new File(DBSeerGUI.userSettings.getDBSeerRootPath() + File.separator + DBSeerConstants.LIVE_DATASET_PATH); File[] files = liveDir.listFiles(); for (File f : files) { FileUtils.moveFileToDirectory(f, datasetDir, false); } // We may not need to process the data after all? // int confirm = JOptionPane.showConfirmDialog(null, // "The monitoring data has been downloaded.\n" + // "Do you want to proceed and process the downloaded dataset?", // "Warning", // JOptionPane.YES_NO_OPTION); // // if (confirm == JOptionPane.YES_OPTION) // { // // process the dataset // DBSeerGUI.status.setText("Processing the dataset..."); // DataCenter dc = new DataCenter(DBSeerConstants.ROOT_DATASET_PATH, datasetNameFinal, true); // if (!dc.parseLogs()) // { // JOptionPane.showMessageDialog(null, "Failed to parse received monitoring logs", "Error", JOptionPane.ERROR_MESSAGE); // } // // if (!dc.processDataset()) // { // JOptionPane.showMessageDialog(null, "Failed to process received dataset", "Error", JOptionPane.ERROR_MESSAGE); // } // } } else { JOptionPane.showMessageDialog(null, socket.getErrorMessage(), "Middleware Monitoring Error", JOptionPane.ERROR_MESSAGE); } return null; } @Override protected void done() { DBSeerGUI.status.setText(""); middlewarePanel.setEnabled(true); logButton.setEnabled(true); startButton.setEnabled(true); } }; datasetWorker.execute(); } catch (Exception e) { JOptionPane.showMessageDialog(null, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); DBSeerGUI.status.setText(""); } } else if (actionEvent.getSource() == applyRefreshRateButton) { int rate = Integer.parseInt(refreshRateField.getText()); DBSeerGUI.liveMonitorRefreshRate = rate; } */ }
From source file:net.sourceforge.doddle_owl.ui.InputDocumentSelectionPanel.java
public void actionPerformed(ActionEvent e) { if (e.getSource() == termExtractionButton) { destroyProcesses(); // ?????? TermExtractionWorker worker = new TermExtractionWorker(4); DODDLE_OWL.STATUS_BAR.setSwingWorker(worker); worker.execute();/*from w w w . j av a2 s.c om*/ } else if (e.getSource() == docLangBox) { if (docList.getSelectedValues().length == 1) { String lang = (String) docLangBox.getSelectedItem(); Document doc = (Document) docList.getSelectedValue(); doc.setLang(lang); updateUI(); } } else if (e.getSource() == inputDocLangBox) { if (inputDocList.getSelectedValues().length == 1) { String lang = (String) inputDocLangBox.getSelectedItem(); Document doc = (Document) inputDocList.getSelectedValue(); doc.setLang(lang); updateUI(); } } else if (e.getSource() == setPunctuationButton) { PUNCTUATION_CHARS = punctuationField.getText(); ListModel inputDocModel = inputDocList.getModel(); for (int i = 0; i < inputDocModel.getSize(); i++) { Document doc = (Document) inputDocModel.getElementAt(i); doc.resetText(); } Document doc = (Document) inputDocList.getSelectedValue(); if (doc != null) { inputDocArea.setText(doc.getText()); inputDocArea.setCaretPosition(0); docLangBox.setSelectedItem(doc.getLang()); } updateUI(); } }
From source file:dk.dma.epd.common.prototype.gui.route.RoutePropertiesDialogCommon.java
/** * Handle action events//w ww .j ava2s .c o m * @param evt the action event */ @Override public void actionPerformed(ActionEvent evt) { // Check if we are in a quiescent state if (quiescent) { return; } if (evt.getSource() == btnZoomToRoute && chartPanel != null) { chartPanel.zoomToWaypoints(route.getWaypoints()); } else if (evt.getSource() == btnZoomToWp && chartPanel != null) { chartPanel.goToPosition(route.getWaypoints().get(selectedWp).getPos()); } else if (evt.getSource() == btnDelete) { onDelete(); routeUpdated(); } else if (evt.getSource() == btnActivate) { EPD.getInstance().getRouteManager().changeActiveWp(selectedWp); routeUpdated(); } else if (evt.getSource() == btnClose) { dispose(); } else if (evt.getSource() == cbVisible) { route.setVisible(cbVisible.isSelected()); EPD.getInstance().getRouteManager().notifyListeners(RoutesUpdateEvent.ROUTE_VISIBILITY_CHANGED); } else if (evt.getSource() == etaCalculationTime) { route.setEtaCalculationType((EtaCalculationType) etaCalculationTime.getSelectedItem()); adjustStartTime(); routeUpdated(); } else if (evt.getSource() == allSpeedsBtn) { double speed; try { speed = parseDouble(allSpeeds.getText()); allSpeeds.setText(Formatter.formatSpeed(speed)); } catch (FormatException e) { JOptionPane.showMessageDialog(this, "Error in speed", "Input error", JOptionPane.ERROR_MESSAGE); return; } for (int i = 0; i < route.getWaypoints().size(); i++) { RouteWaypoint wp = route.getWaypoints().get(i); if (wp.getOutLeg() != null && !locked[i]) { wp.getOutLeg().setSpeed(speed); } } adjustStartTime(); } EPD.getInstance().getRouteManager().notifyListeners(RoutesUpdateEvent.ROUTE_CHANGED); }
From source file:com.game.ui.views.ItemPanel.java
@Override public void actionPerformed(ActionEvent ae) { validationMess.setText(""); validationMess.setVisible(false);//from w ww . j ava 2 s . c o m if (ae.getActionCommand().equalsIgnoreCase("dropDown")) { JPanel panel = (JPanel) comboBox.getParent().getComponent(4); String name = comboBox.getSelectedItem().toString(); if (ringPanel) { getRingDetailForName(name, panel); } else if (armourPanel) { getArmourDetailForName(name, panel); } else if (potionPanel) { getPotionDetailForName(name, panel); } else if (treasurePanel) { getTreasureDetailForName(name, panel); } } else { JButton btn = (JButton) ae.getSource(); JPanel panel = (JPanel) btn.getParent(); String name = ((JTextField) panel.getComponent(2)).getText(); if (ringPanel) { persistRingData(name, panel); } else if (armourPanel) { persistArmourData(name, panel); } else if (potionPanel) { persistPotionData(name, panel); } else if (treasurePanel) { persistTreasure(name, panel); } } this.revalidate(); }
From source file:de.unikassel.jung.PluggableRendererDemo.java
@Override public void actionPerformed(final ActionEvent e) { AbstractButton source = (AbstractButton) e.getSource(); if (source == v_color) { seedDrawColor.setSeedColoring(source.isSelected()); seedFillColor.setSeedColoring(source.isSelected()); } else if (source == e_color) { ewcs.setWeighted(source.isSelected()); } else if (source == v_stroke) { vsh.setHighlight(source.isSelected()); } else if (source == v_labels) { if (source.isSelected()) { vv.getRenderContext().setVertexLabelTransformer(vs); } else {//from w w w.ja va2 s. c om vv.getRenderContext().setVertexLabelTransformer(vs_none); } } else if (source == e_labels) { if (source.isSelected()) { vv.getRenderContext().setEdgeLabelTransformer(es); } else { vv.getRenderContext().setEdgeLabelTransformer(es_none); } } else if (source == e_uarrow_pred) { show_arrow.showUndirected(source.isSelected()); } else if (source == e_darrow_pred) { show_arrow.showDirected(source.isSelected()); } else if (source == e_arrow_centered) { if (source.isSelected()) { vv.getRenderer().getEdgeRenderer() .setEdgeArrowRenderingSupport(new CenterEdgeArrowRenderingSupport()); } else { vv.getRenderer().getEdgeRenderer() .setEdgeArrowRenderingSupport(new BasicEdgeArrowRenderingSupport()); } } else if (source == font) { vff.setBold(source.isSelected()); eff.setBold(source.isSelected()); } else if (source == v_shape) { vssa.useFunnyShapes(source.isSelected()); } else if (source == v_size) { vssa.setScaling(source.isSelected()); } else if (source == v_aspect) { vssa.setStretching(source.isSelected()); } else if (source == e_line) { if (source.isSelected()) { vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line<Integer, Number>()); } } else if (source == e_ortho) { if (source.isSelected()) { vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Orthogonal<Integer, Number>()); } } else if (source == e_wedge) { if (source.isSelected()) { vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Wedge<Integer, Number>(10)); } } // else if (source == e_bent) // { // if(source.isSelected()) // { // vv.getRenderContext().setEdgeShapeFunction(new EdgeShape.BentLine()); // } // } else if (source == e_quad) { if (source.isSelected()) { vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.QuadCurve<Integer, Number>()); } } else if (source == e_cubic) { if (source.isSelected()) { vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.CubicCurve<Integer, Number>()); } } else if (source == e_show_d) { show_edge.showDirected(source.isSelected()); } else if (source == e_show_u) { show_edge.showUndirected(source.isSelected()); } else if (source == v_small) { show_vertex.filterSmall(source.isSelected()); } else if (source == zoom_at_mouse) { gm.setZoomAtMouse(source.isSelected()); } else if (source == no_gradient) { if (source.isSelected()) { gradient_level = GRADIENT_NONE; } // } else if (source == gradient_absolute) { // if (source.isSelected()) { // gradient_level = GRADIENT_ABSOLUTE; // } } else if (source == gradient_relative) { if (source.isSelected()) { gradient_level = GRADIENT_RELATIVE; } } else if (source == fill_edges) { if (source.isSelected()) { vv.getRenderContext().setEdgeFillPaintTransformer(edgeFillPaint); } else { vv.getRenderContext().setEdgeFillPaintTransformer(new ConstantTransformer(null)); } // edgePaint.useFill(source.isSelected()); } vv.repaint(); }