List of usage examples for java.beans PropertyChangeEvent getNewValue
public Object getNewValue()
From source file:com.marginallyclever.makelangelo.MainGUI.java
public boolean LoadImage(String filename) { // where to save temp output file? final String sourceFile = filename; final String destinationFile = GetTempDestinationFile(); LoadImageConverters();//w ww.j av a2s . c o m if (ChooseImageConversionOptions(false) == false) return false; final ProgressMonitor pm = new ProgressMonitor(null, translator.get("Converting"), "", 0, 100); pm.setProgress(0); pm.setMillisToPopup(0); final SwingWorker<Void, Void> s = new SwingWorker<Void, Void>() { @Override public Void doInBackground() { // read in image BufferedImage img; try { Log("<font color='green'>" + translator.get("Converting") + " " + destinationFile + "</font>\n"); // convert with style img = ImageIO.read(new File(sourceFile)); int style = GetDrawStyle(); Filter f = image_converters.get(style); TabToLog(); f.SetParent(this); f.SetProgressMonitor(pm); f.SetDestinationFile(destinationFile); f.Convert(img); TabToDraw(); previewPane.ZoomToFitPaper(); } catch (IOException e) { Log("<font color='red'>" + translator.get("Failed") + e.getLocalizedMessage() + "</font>\n"); recentFiles.remove(sourceFile); updateMenuBar(); } pm.setProgress(100); return null; } @Override public void done() { pm.close(); Log("<font color='green'>" + translator.get("Finished") + "</font>\n"); PlayConversionFinishedSound(); LoadGCode(destinationFile); } }; s.addPropertyChangeListener(new PropertyChangeListener() { // Invoked when task's progress property changes. public void propertyChange(PropertyChangeEvent evt) { if ("progress" == evt.getPropertyName()) { int progress = (Integer) evt.getNewValue(); pm.setProgress(progress); String message = String.format("%d%%.\n", progress); pm.setNote(message); if (s.isDone()) { Log("<font color='green'>" + translator.get("Finished") + "</font>\n"); } else if (s.isCancelled() || pm.isCanceled()) { if (pm.isCanceled()) { s.cancel(true); } Log("<font color='green'>" + translator.get("Cancelled") + "</font>\n"); } } } }); s.execute(); return true; }
From source file:com.eviware.soapui.impl.wsdl.WsdlProject.java
public void propertyChange(PropertyChangeEvent evt) { if ("projectPassword".equals(evt.getPropertyName())) { if (encrypted == 0 & (evt.getOldValue() == null || ((String) evt.getOldValue()).length() == 0)) { encrypted = 1;//from w w w. j av a2s .c o m } if (encrypted == 1 & (evt.getNewValue() == null || ((String) evt.getNewValue()).length() == 0)) { encrypted = 0; } if (SoapUI.getNavigator() != null) SoapUI.getNavigator().repaint(); } }
From source file:org.apache.log4j.chainsaw.LogUI.java
/** * Initialises the Help system and the WelcomePanel * *///from w w w . java 2s . c om private void setupHelpSystem() { welcomePanel = new WelcomePanel(); JToolBar tb = welcomePanel.getToolbar(); tb.add(new SmallButton(new AbstractAction("Tutorial", new ImageIcon(ChainsawIcons.HELP)) { public void actionPerformed(ActionEvent e) { setupTutorial(); } })); tb.addSeparator(); final Action exampleConfigAction = new AbstractAction("View example Receiver configuration") { public void actionPerformed(ActionEvent e) { HelpManager.getInstance().setHelpURL(ChainsawConstants.EXAMPLE_CONFIG_URL); } }; exampleConfigAction.putValue(Action.SHORT_DESCRIPTION, "Displays an example Log4j configuration file with several Receivers defined."); JButton exampleButton = new SmallButton(exampleConfigAction); tb.add(exampleButton); tb.add(Box.createHorizontalGlue()); /** * Setup a listener on the HelpURL property and automatically change the WelcomePages URL * to it. */ HelpManager.getInstance().addPropertyChangeListener("helpURL", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { URL newURL = (URL) evt.getNewValue(); if (newURL != null) { welcomePanel.setURL(newURL); ensureWelcomePanelVisible(); } } }); }
From source file:cs.cirg.cida.CIDAView.java
public CIDAView(SingleFrameApplication app) { super(app);//from w ww. j a v a 2s . c o m exceptionController = new ExceptionController(); experimentController = new ExperimentController(this, new ExperimentAnalysisModel(((CIDAApplication) app).getStartupDirectory())); tableConstructionController = new TableConstructionController(this, experimentController.getModel()); userSelectedRows = new ArrayList<Integer>(); userSelectedColumns = new ArrayList<Integer>(); initComponents(); // status bar initialization - message timeout, idle icon and busy animation, etc ResourceMap resourceMap = getResourceMap(); int messageTimeout = resourceMap.getInteger("StatusBar.messageTimeout"); messageTimer = new Timer(messageTimeout, new ActionListener() { public void actionPerformed(ActionEvent e) { statusMessageLabel.setText(""); } }); messageTimer.setRepeats(false); int busyAnimationRate = resourceMap.getInteger("StatusBar.busyAnimationRate"); for (int i = 0; i < busyIcons.length; i++) { busyIcons[i] = resourceMap.getIcon("StatusBar.busyIcons[" + i + "]"); } busyIconTimer = new Timer(busyAnimationRate, new ActionListener() { public void actionPerformed(ActionEvent e) { busyIconIndex = (busyIconIndex + 1) % busyIcons.length; statusAnimationLabel.setIcon(busyIcons[busyIconIndex]); } }); idleIcon = resourceMap.getIcon("StatusBar.idleIcon"); statusAnimationLabel.setIcon(idleIcon); progressBar.setVisible(false); // connecting action tasks to status bar via TaskMonitor TaskMonitor taskMonitor = new TaskMonitor(getApplication().getContext()); taskMonitor.addPropertyChangeListener(new java.beans.PropertyChangeListener() { public void propertyChange(java.beans.PropertyChangeEvent evt) { String propertyName = evt.getPropertyName(); if ("started".equals(propertyName)) { if (!busyIconTimer.isRunning()) { statusAnimationLabel.setIcon(busyIcons[0]); busyIconIndex = 0; busyIconTimer.start(); } progressBar.setVisible(true); progressBar.setIndeterminate(true); } else if ("done".equals(propertyName)) { busyIconTimer.stop(); statusAnimationLabel.setIcon(idleIcon); progressBar.setVisible(false); progressBar.setValue(0); } else if ("message".equals(propertyName)) { String text = (String) (evt.getNewValue()); statusMessageLabel.setText((text == null) ? "" : text); messageTimer.restart(); } else if ("progress".equals(propertyName)) { int value = (Integer) (evt.getNewValue()); progressBar.setVisible(true); progressBar.setIndeterminate(false); progressBar.setValue(value); } } }); }
From source file:org.apache.log4j.chainsaw.LogUI.java
private void setupReceiverPanel() { receiversPanel = new ReceiversPanel(); receiversPanel.addPropertyChangeListener("visible", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { getApplicationPreferenceModel().setReceivers(((Boolean) evt.getNewValue()).booleanValue()); }// w w w . jav a 2 s.c o m }); }
From source file:uk.ac.lkl.cram.ui.chart.LearningExperienceChartMaker.java
/** * Create a dataset from the module// w w w .j a va 2 s . c o m * @return a category dataset that is used to produce a stacked bar chart */ @Override protected CategoryDataset createDataSet() { //Create the dataset to hold the data final DefaultCategoryDataset categoryDataset = new DefaultCategoryDataset(); //Populate the dataset with the data populateDataset(categoryDataset, module); //Create a listener, which repopulates the dataset when anything changes final PropertyChangeListener learningExperienceListener = new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent pce) { //LOGGER.info("property change: " + pce); populateDataset(categoryDataset, module); } }; //Add the listener to each of the module's tlaLineItems, as well as to each //tlaLineItem's activity //This means that whenever a tlaLineItem changes, or its activity changes, the listener is triggered //Causing the dataset to be repopulated for (TLALineItem lineItem : module.getTLALineItems()) { //LOGGER.info("adding listeners to : " + lineItem.getName()); lineItem.getActivity().addPropertyChangeListener(TLActivity.PROP_LEARNING_EXPERIENCE, learningExperienceListener); lineItem.addPropertyChangeListener(learningExperienceListener); } //Add a listener to the module, listening for changes where a tlaLineItem is added or removed module.addPropertyChangeListener(Module.PROP_TLA_LINEITEM, new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent pce) { //A tlaLineItem has been added or removed if (pce instanceof IndexedPropertyChangeEvent) { //LOGGER.info("indexed change: " + pce); if (pce.getOldValue() != null) { //This has been removed TLALineItem lineItem = (TLALineItem) pce.getOldValue(); //So remove the listener from it and its activity //LOGGER.info("removing listeners from: " + lineItem.getName()); lineItem.getActivity().removePropertyChangeListener(TLActivity.PROP_LEARNING_EXPERIENCE, learningExperienceListener); lineItem.removePropertyChangeListener(learningExperienceListener); } if (pce.getNewValue() != null) { //This has been added TLALineItem lineItem = (TLALineItem) pce.getNewValue(); //So add a listener to it and its activity //LOGGER.info("adding listeners to: " + lineItem); lineItem.getActivity().addPropertyChangeListener(TLActivity.PROP_LEARNING_EXPERIENCE, learningExperienceListener); lineItem.addPropertyChangeListener(learningExperienceListener); } } //Assume the dataset is now out of date, so repopulate it populateDataset(categoryDataset, module); } }); return categoryDataset; }
From source file:org.openscience.jmol.app.Jmol.java
Jmol(Splash splash, JFrame frame, Jmol parent, int startupWidth, int startupHeight, String commandOptions, Point loc) {/*from ww w. j a va 2s . com*/ super(true); this.frame = frame; this.startupWidth = startupWidth; this.startupHeight = startupHeight; numWindows++; try { say("history file is " + historyFile.getFile().getAbsolutePath()); } catch (Exception e) { } frame.setTitle("Jmol"); frame.getContentPane().setBackground(Color.lightGray); frame.getContentPane().setLayout(new BorderLayout()); this.splash = splash; setBorder(BorderFactory.createEtchedBorder()); setLayout(new BorderLayout()); language = GT.getLanguage(); status = (StatusBar) createStatusBar(); say(GT._("Initializing 3D display...")); // display = new DisplayPanel(status, guimap, haveDisplay.booleanValue(), startupWidth, startupHeight); String adapter = System.getProperty("model"); if (adapter == null || adapter.length() == 0) adapter = "smarter"; if (adapter.equals("smarter")) { report("using Smarter Model Adapter"); modelAdapter = new SmarterJmolAdapter(); } else if (adapter.equals("cdk")) { report("the CDK Model Adapter is currently no longer supported. Check out http://bioclipse.net/. -- using Smarter"); // modelAdapter = new CdkJmolAdapter(null); modelAdapter = new SmarterJmolAdapter(); } else { report("unrecognized model adapter:" + adapter + " -- using Smarter"); modelAdapter = new SmarterJmolAdapter(); } appletContext = commandOptions; viewer = JmolViewer.allocateViewer(display, modelAdapter); viewer.setAppletContext("", null, null, commandOptions); if (display != null) display.setViewer(viewer); say(GT._("Initializing Preferences...")); preferencesDialog = new PreferencesDialog(frame, guimap, viewer); say(GT._("Initializing Recent Files...")); recentFiles = new RecentFilesDialog(frame); if (haveDisplay.booleanValue()) { say(GT._("Initializing Script Window...")); scriptWindow = new ScriptWindow(viewer, frame); } MyStatusListener myStatusListener; myStatusListener = new MyStatusListener(); viewer.setJmolStatusListener(myStatusListener); say(GT._("Initializing Measurements...")); measurementTable = new MeasurementTable(viewer, frame); // Setup Plugin system // say(GT._("Loading plugins...")); // pluginManager = new CDKPluginManager( // System.getProperty("user.home") + System.getProperty("file.separator") // + ".jmol", new JmolEditBus(viewer) // ); // pluginManager.loadPlugin("org.openscience.cdkplugin.dirbrowser.DirBrowserPlugin"); // pluginManager.loadPlugin("org.openscience.cdkplugin.dirbrowser.DadmlBrowserPlugin"); // pluginManager.loadPlugins( // System.getProperty("user.home") + System.getProperty("file.separator") // + ".jmol/plugins" // ); // feature to allow for globally installed plugins // if (System.getProperty("plugin.dir") != null) { // pluginManager.loadPlugins(System.getProperty("plugin.dir")); // } if (haveDisplay.booleanValue()) { // install the command table say(GT._("Building Command Hooks...")); commands = new Hashtable(); if (display != null) { Action[] actions = getActions(); for (int i = 0; i < actions.length; i++) { Action a = actions[i]; commands.put(a.getValue(Action.NAME), a); } } menuItems = new Hashtable(); say(GT._("Building Menubar...")); executeScriptAction = new ExecuteScriptAction(); menubar = createMenubar(); add("North", menubar); JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); panel.add("North", createToolbar()); JPanel ip = new JPanel(); ip.setLayout(new BorderLayout()); ip.add("Center", display); panel.add("Center", ip); add("Center", panel); add("South", status); say(GT._("Starting display...")); display.start(); //say(GT._("Setting up File Choosers...")); /* pcs.addPropertyChangeListener(chemFileProperty, exportAction); pcs.addPropertyChangeListener(chemFileProperty, povrayAction); pcs.addPropertyChangeListener(chemFileProperty, writeAction); pcs.addPropertyChangeListener(chemFileProperty, toWebAction); pcs.addPropertyChangeListener(chemFileProperty, printAction); pcs.addPropertyChangeListener(chemFileProperty, viewMeasurementTableAction); */ if (menuFile != null) { menuStructure = viewer.getFileAsString(menuFile); } jmolpopup = JmolPopup.newJmolPopup(viewer, true, menuStructure, true); } // prevent new Jmol from covering old Jmol if (loc != null) { frame.setLocation(loc); } else if (parent != null) { Point location = parent.frame.getLocationOnScreen(); int maxX = screenSize.width - 50; int maxY = screenSize.height - 50; location.x += 40; location.y += 40; if ((location.x > maxX) || (location.y > maxY)) { location.setLocation(0, 0); } frame.setLocation(location); } frame.getContentPane().add("Center", this); frame.addWindowListener(new Jmol.AppCloser()); frame.pack(); frame.setSize(startupWidth, startupHeight); ImageIcon jmolIcon = JmolResourceHandler.getIconX("icon"); Image iconImage = jmolIcon.getImage(); frame.setIconImage(iconImage); // Repositionning windows if (scriptWindow != null) historyFile.repositionWindow(SCRIPT_WINDOW_NAME, scriptWindow, 200, 100); say(GT._("Setting up Drag-and-Drop...")); FileDropper dropper = new FileDropper(); final JFrame f = frame; dropper.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { //System.out.println("Drop triggered..."); f.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); if (evt.getPropertyName().equals(FileDropper.FD_PROPERTY_FILENAME)) { final String filename = evt.getNewValue().toString(); viewer.openFile(filename); } else if (evt.getPropertyName().equals(FileDropper.FD_PROPERTY_INLINE)) { final String inline = evt.getNewValue().toString(); viewer.openStringInline(inline); } f.setCursor(Cursor.getDefaultCursor()); } }); this.setDropTarget(new DropTarget(this, dropper)); this.setEnabled(true); say(GT._("Launching main frame...")); }
From source file:org.apache.log4j.chainsaw.LogUI.java
/** * Initialises the menu's and toolbars, but does not actually create any of * the main panel components./*from ww w . j a va2s . c o m*/ * */ private void initGUI() { setupHelpSystem(); statusBar = new ChainsawStatusBar(this); setupReceiverPanel(); setToolBarAndMenus(new ChainsawToolBarAndMenus(this)); toolbar = getToolBarAndMenus().getToolbar(); setJMenuBar(getToolBarAndMenus().getMenubar()); setTabbedPane(new ChainsawTabbedPane()); getSettingsManager().addSettingsListener(getTabbedPane()); getSettingsManager().configure(getTabbedPane()); /** * This adds Drag & Drop capability to Chainsaw */ FileDnDTarget dnDTarget = new FileDnDTarget(tabbedPane); dnDTarget.addPropertyChangeListener("fileList", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { final List fileList = (List) evt.getNewValue(); Thread thread = new Thread(new Runnable() { public void run() { logger.debug("Loading files: " + fileList); for (Iterator iter = fileList.iterator(); iter.hasNext();) { File file = (File) iter.next(); final Decoder decoder = new XMLDecoder(); try { getStatusBar().setMessage("Loading " + file.getAbsolutePath() + "..."); FileLoadAction.importURL(handler, decoder, file.getName(), file.toURI().toURL()); } catch (Exception e) { String errorMsg = "Failed to import a file"; logger.error(errorMsg, e); getStatusBar().setMessage(errorMsg); } } } }); thread.setPriority(Thread.MIN_PRIORITY); thread.start(); } }); applicationPreferenceModelPanel = new ApplicationPreferenceModelPanel(applicationPreferenceModel); applicationPreferenceModelPanel.setOkCancelActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { preferencesFrame.setVisible(false); } }); KeyStroke escape = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false); Action closeAction = new AbstractAction() { public void actionPerformed(ActionEvent e) { preferencesFrame.setVisible(false); } }; preferencesFrame.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(escape, "ESCAPE"); preferencesFrame.getRootPane().getActionMap().put("ESCAPE", closeAction); OSXIntegration.init(this); }
From source file:org.apache.log4j.chainsaw.LogUI.java
private void initPrefModelListeners() { applicationPreferenceModel.addPropertyChangeListener("identifierExpression", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { handler.setIdentifierExpression(evt.getNewValue().toString()); }// w ww. ja va 2s . c o m }); handler.setIdentifierExpression(applicationPreferenceModel.getIdentifierExpression()); applicationPreferenceModel.addPropertyChangeListener("toolTipDisplayMillis", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { ToolTipManager.sharedInstance().setDismissDelay(((Integer) evt.getNewValue()).intValue()); } }); ToolTipManager.sharedInstance().setDismissDelay(applicationPreferenceModel.getToolTipDisplayMillis()); applicationPreferenceModel.addPropertyChangeListener("responsiveness", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { int value = ((Integer) evt.getNewValue()).intValue(); handler.setQueueInterval((value * 1000) - 750); } }); handler.setQueueInterval((applicationPreferenceModel.getResponsiveness() * 1000) - 750); applicationPreferenceModel.addPropertyChangeListener("tabPlacement", new PropertyChangeListener() { public void propertyChange(final PropertyChangeEvent evt) { SwingUtilities.invokeLater(new Runnable() { public void run() { int placement = ((Integer) evt.getNewValue()).intValue(); switch (placement) { case SwingConstants.TOP: case SwingConstants.BOTTOM: tabbedPane.setTabPlacement(placement); break; default: break; } } }); } }); applicationPreferenceModel.addPropertyChangeListener("statusBar", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { boolean value = ((Boolean) evt.getNewValue()).booleanValue(); setStatusBarVisible(value); } }); setStatusBarVisible(applicationPreferenceModel.isStatusBar()); applicationPreferenceModel.addPropertyChangeListener("receivers", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { boolean value = ((Boolean) evt.getNewValue()).booleanValue(); if (value) { showReceiverPanel(); } else { hideReceiverPanel(); } } }); // if (applicationPreferenceModel.isReceivers()) { // showReceiverPanel(); // } else { // hideReceiverPanel(); // } applicationPreferenceModel.addPropertyChangeListener("toolbar", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { boolean value = ((Boolean) evt.getNewValue()).booleanValue(); toolbar.setVisible(value); } }); toolbar.setVisible(applicationPreferenceModel.isToolbar()); }
From source file:org.isatools.isacreator.spreadsheet.Spreadsheet.java
/** * Create the FlatButton panel - a panel which contains graphical representations of the options available * to the user when interacting with the software. *//* ww w . j a va 2 s .co m*/ private void createButtonPanel() { spreadsheetFunctionPanel = new JPanel(); spreadsheetFunctionPanel.setLayout(new BoxLayout(spreadsheetFunctionPanel, BoxLayout.LINE_AXIS)); spreadsheetFunctionPanel.setBackground(UIHelper.BG_COLOR); addRow = new JLabel(addRowButton); addRow.setToolTipText("<html><b>add row</b>" + "<p>add a new row to the table</p></html>"); addRow.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent mouseEvent) { addRow.setIcon(addRowButton); showMultipleRowsGUI(); } public void mouseEntered(MouseEvent mouseEvent) { addRow.setIcon(addRowButtonOver); } public void mouseExited(MouseEvent mouseEvent) { addRow.setIcon(addRowButton); } }); deleteRow = new JLabel(deleteRowButton); deleteRow.setToolTipText("<html><b>remove row</b>" + "<p>remove selected row from table</p></html>"); deleteRow.setEnabled(false); deleteRow.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent mouseEvent) { deleteRow.setIcon(deleteRowButton); if (table.getSelectedRow() != -1) { if (!(table.getSelectedRowCount() > 1)) { spreadsheetFunctions.deleteRow(table.getSelectedRow()); } else { spreadsheetFunctions.deleteRow(table.getSelectedRows()); } } } public void mouseEntered(MouseEvent mouseEvent) { deleteRow.setIcon(deleteRowButtonOver); } public void mouseExited(MouseEvent mouseEvent) { deleteRow.setIcon(deleteRowButton); } }); deleteColumn = new JLabel(deleteColumnButton); deleteColumn .setToolTipText("<html><b>remove column</b>" + "<p>remove selected column from table</p></html>"); deleteColumn.setEnabled(false); deleteColumn.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent mouseEvent) { deleteColumn.setIcon(deleteColumnButton); if (!(table.getSelectedColumns().length > 1)) { spreadsheetFunctions.deleteColumn(table.getSelectedColumn()); } else { showColumnErrorMessage(); } } public void mouseEntered(MouseEvent mouseEvent) { deleteColumn.setIcon(deleteColumnButtonOver); } public void mouseExited(MouseEvent mouseEvent) { deleteColumn.setIcon(deleteColumnButton); } }); multipleSort = new JLabel(multipleSortButton); multipleSort.setToolTipText( "<html><b>multiple sort</b>" + "<p>perform a multiple sort on the table</p></html>"); multipleSort.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent mouseEvent) { multipleSort.setIcon(multipleSortButton); showMultipleColumnSortGUI(); } public void mouseEntered(MouseEvent mouseEvent) { multipleSort.setIcon(multipleSortButtonOver); } public void mouseExited(MouseEvent mouseEvent) { multipleSort.setIcon(multipleSortButton); } }); copyColDown = new JLabel(copyColDownButton); copyColDown.setToolTipText("<html><b>copy column downwards</b>" + "<p>duplicate selected column and copy it from the current</p>" + "<p>position down to the final row in the table</p></html>"); copyColDown.setEnabled(false); copyColDown.addMouseListener(new MouseAdapter() { public void mouseExited(MouseEvent mouseEvent) { copyColDown.setIcon(copyColDownButton); } public void mouseEntered(MouseEvent mouseEvent) { copyColDown.setIcon(copyColDownButtonOver); } public void mousePressed(MouseEvent mouseEvent) { copyColDown.setIcon(copyColDownButton); final int row = table.getSelectedRow(); final int col = table.getSelectedColumn(); if (row != -1 && col != -1) { JOptionPane copyColDownConfirmationPane = new JOptionPane( "<html><b>Confirm Copy of Column...</b><p>Are you sure you wish to copy " + "this column downwards?</p><p>This Action can not be undone!</p></html>", JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION); copyColDownConfirmationPane.setIcon(copyColumnDownWarningIcon); UIHelper.applyOptionPaneBackground(copyColDownConfirmationPane, UIHelper.BG_COLOR); copyColDownConfirmationPane.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { if (event.getPropertyName().equals(JOptionPane.VALUE_PROPERTY)) { int lastOptionAnswer = Integer.valueOf(event.getNewValue().toString()); parentFrame.hideSheet(); if (lastOptionAnswer == JOptionPane.YES_OPTION) { spreadsheetFunctions.copyColumnDownwards(row, col); } } } }); parentFrame.showJDialogAsSheet( copyColDownConfirmationPane.createDialog(Spreadsheet.this, "Copy Column?")); } } }); copyRowDown = new JLabel(copyRowDownButton); copyRowDown.setToolTipText( "<html><b>copy row downwards</b>" + "<p>duplicate selected row and copy it from the current</p>" + "<p>position down to the final row</p></html>"); copyRowDown.setEnabled(false); copyRowDown.addMouseListener(new MouseAdapter() { public void mouseExited(MouseEvent mouseEvent) { copyRowDown.setIcon(copyRowDownButton); } public void mouseEntered(MouseEvent mouseEvent) { copyRowDown.setIcon(copyRowDownButtonOver); } public void mousePressed(MouseEvent mouseEvent) { copyRowDown.setIcon(copyRowDownButton); final int row = table.getSelectedRow(); JOptionPane copyRowDownConfirmationPane = new JOptionPane( "<html><b>Confirm Copy of Row...</b><p>Are you sure you wish to copy " + "this row downwards?</p><p>This Action can not be undone!</p>", JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION); copyRowDownConfirmationPane.setIcon(copyRowDownWarningIcon); UIHelper.applyOptionPaneBackground(copyRowDownConfirmationPane, UIHelper.BG_COLOR); copyRowDownConfirmationPane.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { if (event.getPropertyName().equals(JOptionPane.VALUE_PROPERTY)) { int lastOptionAnswer = Integer.valueOf(event.getNewValue().toString()); parentFrame.hideSheet(); if (lastOptionAnswer == JOptionPane.YES_OPTION) { spreadsheetFunctions.copyRowDownwards(row); } } } }); parentFrame.showJDialogAsSheet( copyRowDownConfirmationPane.createDialog(Spreadsheet.this, "Copy Row Down?")); } }); addProtocol = new JLabel(addProtocolButton); addProtocol.setToolTipText( "<html><b>add a protocol column</b>" + "<p>Add a protocol column to the table</p></html>"); addProtocol.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent mouseEvent) { addProtocol.setIcon(addProtocolButtonOver); } public void mouseExited(MouseEvent mouseEvent) { addProtocol.setIcon(addProtocolButton); } public void mousePressed(MouseEvent mouseEvent) { addProtocol.setIcon(addProtocolButton); if (addProtocol.isEnabled()) { FieldObject fo = new FieldObject(table.getColumnCount(), "Protocol REF", "Protocol used for experiment", DataTypes.LIST, "", false, false, false); fo.setFieldList(studyDataEntryEnvironment.getProtocolNames()); spreadsheetFunctions.addFieldToReferenceObject(fo); spreadsheetFunctions.addColumnAfterPosition("Protocol REF", null, fo.isRequired(), -1); } } }); addFactor = new JLabel(addFactorButton); addFactor.setToolTipText( "<html><b>add a factor column</b>" + "<p>Add a factor column to the table</p></html>"); addFactor.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent mouseEvent) { addFactor.setIcon(addFactorButtonOver); } public void mouseExited(MouseEvent mouseEvent) { addFactor.setIcon(addFactorButton); } public void mousePressed(MouseEvent mouseEvent) { addFactor.setIcon(addFactorButton); if (addFactor.isEnabled()) { showAddColumnsGUI(AddColumnGUI.ADD_FACTOR_COLUMN); } } }); addCharacteristic = new JLabel(addCharacteristicButton); addCharacteristic.setToolTipText("<html><b>add a characteristic column</b>" + "<p>Add a characteristic column to the table</p></html>"); addCharacteristic.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent mouseEvent) { addCharacteristic.setIcon(addCharacteristicButtonOver); } public void mouseExited(MouseEvent mouseEvent) { addCharacteristic.setIcon(addCharacteristicButton); } public void mousePressed(MouseEvent mouseEvent) { addCharacteristic.setIcon(addCharacteristicButton); if (addCharacteristic.isEnabled()) { showAddColumnsGUI(AddColumnGUI.ADD_CHARACTERISTIC_COLUMN); } } }); addParameter = new JLabel(addParameterButton); addParameter.setToolTipText( "<html><b>add a parameter column</b>" + "<p>Add a parameter column to the table</p></html>"); addParameter.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent mouseEvent) { addParameter.setIcon(addParameterButtonOver); } public void mouseExited(MouseEvent mouseEvent) { addParameter.setIcon(addParameterButton); } public void mousePressed(MouseEvent mouseEvent) { addParameter.setIcon(addParameterButton); if (addParameter.isEnabled()) { showAddColumnsGUI(AddColumnGUI.ADD_PARAMETER_COLUMN); } } }); undo = new JLabel(undoButton); undo.setToolTipText("<html><b>undo previous action<b></html>"); undo.setEnabled(undoManager.canUndo()); undo.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent mouseEvent) { undo.setIcon(undoButton); undoManager.undo(); if (highlightActive) { setRowsToDefaultColor(); } table.addNotify(); } public void mouseEntered(MouseEvent mouseEvent) { undo.setIcon(undoButtonOver); } public void mouseExited(MouseEvent mouseEvent) { undo.setIcon(undoButton); } }); redo = new JLabel(redoButton); redo.setToolTipText("<html><b>redo action<b></html>"); redo.setEnabled(undoManager.canRedo()); redo.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent mouseEvent) { redo.setIcon(redoButton); undoManager.redo(); if (highlightActive) { setRowsToDefaultColor(); } table.addNotify(); } public void mouseEntered(MouseEvent mouseEvent) { redo.setIcon(redoButtonOver); } public void mouseExited(MouseEvent mouseEvent) { redo.setIcon(redoButton); } }); transpose = new JLabel(transposeIcon); transpose.setToolTipText("<html>View a transposed version of this spreadsheet</html>"); transpose.addMouseListener(new MouseAdapter() { public void mouseExited(MouseEvent mouseEvent) { transpose.setIcon(transposeIcon); } public void mouseEntered(MouseEvent mouseEvent) { transpose.setIcon(transposeIconOver); } public void mousePressed(MouseEvent mouseEvent) { showTransposeSpreadsheetGUI(); } }); addButtons(); if (studyDataEntryEnvironment != null) { JPanel labelContainer = new JPanel(new GridLayout(1, 1)); labelContainer.setBackground(UIHelper.BG_COLOR); JLabel lab = UIHelper.createLabel(spreadsheetTitle, UIHelper.VER_10_PLAIN, UIHelper.DARK_GREEN_COLOR, JLabel.RIGHT); lab.setBackground(UIHelper.BG_COLOR); lab.setVerticalAlignment(JLabel.CENTER); lab.setPreferredSize(new Dimension(200, 30)); labelContainer.add(lab); spreadsheetFunctionPanel.add(labelContainer); spreadsheetFunctionPanel.add(Box.createHorizontalStrut(10)); } add(spreadsheetFunctionPanel, BorderLayout.NORTH); }