List of usage examples for java.beans PropertyChangeEvent getNewValue
public Object getNewValue()
From source file:org.openmicroscopy.shoola.agents.treeviewer.actions.DownloadAction.java
/** * Downloads the selected files.// w w w .j a va2 s . c o m * @see java.awt.event.ActionListener#actionPerformed(ActionEvent) */ public void actionPerformed(ActionEvent e) { Browser browser = model.getSelectedBrowser(); if (browser == null) return; TreeImageDisplay node = browser.getLastSelectedDisplay(); if (node == null) return; JFrame f = TreeViewerAgent.getRegistry().getTaskBar().getFrame(); List<DataObject> list = browser.getSelectedDataObjects(); int type = FileChooser.SAVE; List<String> paths = new ArrayList<String>(); if (list != null && list.size() > 1) { type = FileChooser.FOLDER_CHOOSER; Iterator<DataObject> i = list.iterator(); DataObject data; while (i.hasNext()) { data = i.next(); if (data instanceof ImageData) { paths.add(FilenameUtils.getName(((ImageData) data).getName())); } } } FileChooser chooser = new FileChooser(f, type, FileChooser.DOWNLOAD_TEXT, FileChooser.DOWNLOAD_DESCRIPTION, null, true); try { File file = UIUtilities.getDefaultFolder(); if (file != null) chooser.setCurrentDirectory(file); } catch (Exception ex) { } String text = ""; Object ho = node.getUserObject(); if (ho instanceof ImageData) text = ((ImageData) ho).getName(); else if (ho instanceof FileAnnotationData) text = ((FileAnnotationData) ho).getFileName(); chooser.setSelectedFileFull(text); chooser.setCheckOverride(true); chooser.setSelectedFiles(paths); IconManager icons = IconManager.getInstance(); chooser.setTitleIcon(icons.getIcon(IconManager.DOWNLOAD_48)); chooser.setApproveButtonText(FileChooser.DOWNLOAD_TEXT); chooser.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { String name = evt.getPropertyName(); FileChooser src = (FileChooser) evt.getSource(); File path = null; if (FileChooser.APPROVE_SELECTION_PROPERTY.equals(name)) { if (src.getChooserType() == FileChooser.FOLDER_CHOOSER) { path = new File((String) evt.getNewValue()); } else { File[] files = (File[]) evt.getNewValue(); if (files == null || files.length == 0) return; path = files[0]; } if (path == null) { path = UIUtilities.getDefaultFolder(); } model.download(path, src.isOverride()); } } }); chooser.centerDialog(); }
From source file:EnrollFingerprint.Enroll.java
/** * Creates new form Enroll// w ww . j a v a2s.com */ public Enroll() { initComponents(); updateStatus(); // Event listener actived when fingerprint template is ready this.addPropertyChangeListener(TEMPLATE_PROPERTY, new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { btnSave.setEnabled(template != null); if (evt.getNewValue() == evt.getOldValue()) { return; } if (template != null) { JOptionPane.showMessageDialog(Enroll.this, "La huella capturada esta lista para ser guardada.", "Captura y Registro de huellas", JOptionPane.INFORMATION_MESSAGE); } } }); }
From source file:ec.ui.view.RevisionSaSeriesView.java
/** * Constructs a new view// w ww . j a v a 2s . c o m */ public RevisionSaSeriesView() { setLayout(new BorderLayout()); sRenderer = new XYLineAndShapeRenderer(); sRenderer.setBaseShapesVisible(false); //sRenderer.setSeriesStroke(1, new BasicStroke(0.75f, 1, 1, 1.0f, new float[]{2f, 3f}, 0.0f)); sRenderer.setBasePaint(themeSupport.getLineColor(ColorScheme.KnownColor.RED)); revRenderer = new XYLineAndShapeRenderer(false, true); mainChart = createMainChart(); chartpanel_ = new JChartPanel(ChartFactory.createLineChart(null, null, null, null, PlotOrientation.VERTICAL, false, false, false)); documentpanel_ = ComponentFactory.getDefault().newHtmlView(); JSplitPane splitpane = NbComponents.newJSplitPane(JSplitPane.VERTICAL_SPLIT, chartpanel_, NbComponents.newJScrollPane(documentpanel_)); splitpane.setDividerLocation(0.5); splitpane.setResizeWeight(.5); popup = new ChartPopup(null, false); chartpanel_.addChartMouseListener(new ChartMouseListener() { @Override public void chartMouseClicked(ChartMouseEvent e) { if (lastIndexSelected != -1) { revRenderer.setSeriesShapesFilled(lastIndexSelected, false); } if (e.getEntity() != null) { if (e.getEntity() instanceof XYItemEntity) { XYItemEntity item = (XYItemEntity) e.getEntity(); if (item.getDataset().equals(mainChart.getXYPlot().getDataset(REV_INDEX))) { int i = item.getSeriesIndex(); revRenderer.setSeriesShape(i, new Ellipse2D.Double(-3, -3, 6, 6)); revRenderer.setSeriesShapesFilled(i, true); revRenderer.setSeriesPaint(i, themeSupport.getLineColor(ColorScheme.KnownColor.BLUE)); lastIndexSelected = i; showRevisionPopup(e); } } } } @Override public void chartMouseMoved(ChartMouseEvent cme) { } }); chartpanel_.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals(JChartPanel.ZOOM_SELECTION_CHANGED)) { showSelectionPopup((Rectangle2D) evt.getNewValue()); } } }); this.add(splitpane, BorderLayout.CENTER); splitpane.setResizeWeight(0.5); onColorSchemeChange(); }
From source file:org.drugis.addis.gui.builder.NetworkMetaAnalysisView.java
private JComponent buildInconsistencyTab() { final FormLayout layout = new FormLayout("pref, 3dlu, pref, 3dlu, fill:0:grow", "p, 3dlu, p, 3dlu, p, 5dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p"); final PanelBuilder builder = new PanelBuilder(layout, new ScrollableJPanel()); builder.setDefaultDialogBorder();/* w ww . j a va 2 s . co m*/ final CellConstraints cc = new CellConstraints(); int row = 1; final int colSpan = 5; builder.addSeparator("Results - network inconsistency model", cc.xyw(1, row, colSpan)); row += 2; final InconsistencyWrapper<TreatmentDefinition> inconsistencyModel = d_pm.getInconsistencyModel(); final JPanel simulationControls = SimulationComponentFactory.createSimulationControls( d_pm.getWrappedModel(inconsistencyModel), d_mainWindow, false, AuxComponentFactory.COLOR_NOTE, d_mainWindow.getReloadRightPanelAction(INCONSISTENCY_TAB_TITLE)); builder.add(simulationControls, cc.xyw(3, row, 3)); row += 2; final JComponent inconsistencyNote = AuxComponentFactory.createTextPane(Help.getHelpText("inconsistency")); builder.add(inconsistencyNote, cc.xyw(1, row, colSpan)); row += 2; final TablePanel relativeEffectsTablePanel = createNetworkTablePanel(inconsistencyModel); builder.addSeparator("Network Meta-Analysis (Inconsistency Model)", cc.xyw(1, row, colSpan)); row += 2; builder.add(relativeEffectsTablePanel, cc.xyw(1, row, colSpan)); row += 2; final NetworkInconsistencyFactorsTableModel inconsistencyFactorsTableModel = new NetworkInconsistencyFactorsTableModel( d_pm.getInconsistencyModel(), d_pm.getWrappedModel(d_pm.getInconsistencyModel()).isModelConstructed(), true); final EnhancedTable table = new EnhancedTable(inconsistencyFactorsTableModel, 300); table.setDefaultRenderer(Summary.class, new SummaryCellRenderer(false)); final TablePanel inconsistencyFactorsTablePanel = new TablePanel(table); d_pm.getWrappedModel(inconsistencyModel).isModelConstructed() .addValueChangeListener(new PropertyChangeListener() { public void propertyChange(final PropertyChangeEvent event) { if (event.getNewValue().equals(true)) { final Runnable r = new Runnable() { public void run() { inconsistencyFactorsTablePanel.doLayout(); } }; SwingUtilities.invokeLater(r); } } }); builder.addSeparator("Inconsistency Factors", cc.xyw(1, row, colSpan)); row += 2; builder.add(inconsistencyFactorsTablePanel, cc.xyw(1, row, colSpan)); row += 2; final NetworkVarianceTableModel varianceTableModel = new NetworkVarianceTableModel(inconsistencyModel); final EnhancedTable varianceTable = new EnhancedTable(varianceTableModel, 300); varianceTable.setDefaultRenderer(QuantileSummary.class, new SummaryCellRenderer()); final TablePanel varianceTablePanel = new TablePanel(varianceTable); builder.addSeparator("Variance Calculation", cc.xyw(1, row, colSpan)); row += 2; builder.add(varianceTablePanel, cc.xyw(1, row, colSpan)); row += 2; return builder.getPanel(); }
From source file:ds.monte.carlo.Application.java
@Override public void propertyChange(PropertyChangeEvent evt) { if ("progress".equals(evt.getPropertyName())) { int progress = (Integer) evt.getNewValue(); jProgressBar1.setValue(progress); if (progress == 100) { createFrequencyGraph(monteCarlo.getDictionary()); createGrowthGraph(monteCarlo.getGrowthMap()); createLengthGraph(monteCarlo.findProbability()); ImageIcon img = new ImageIcon("img.png"); this.setIconImage(img.getImage()); jLabel13.setText(((double) monteCarlo.getSuccessful() / numberOfReplications) * 100 + "%"); jLabel16.setText(monteCarlo.getAvg() + ""); jLabel18.setText(monteCarlo.getP80() + ""); }//from w w w. java 2 s . c o m } }
From source file:org.jbb.lib.properties.UpdateFilePropertyChangeListener.java
@Override public void propertyChange(PropertyChangeEvent evt) { for (String propertyFile : propFiles) { try {// w w w . j a v a 2 s. co m FileBasedConfigurationBuilder<PropertiesConfiguration> builder = new FileBasedConfigurationBuilder<>( PropertiesConfiguration.class).configure( new Parameters().properties().setFileName(propertyFile).setIncludesAllowed(false)); builder.setAutoSave(true); PropertiesConfiguration conf = builder.getConfiguration(); evt.setPropagationId(propertyFile); conf.setProperty(evt.getPropertyName(), evt.getNewValue()); } catch (ConfigurationException e) { throw new IllegalArgumentException(e); } } }
From source file:com.emr.schemas.SchemerMapper.java
/** * Constructor//from w w w . jav a 2 s . c o m * @param emrConn {@link Connection} Connection to the EMR database * @param emrDbName {@link String} Database name */ public SchemerMapper(Connection emrConn, String emrDbName) { this.emrConn = emrConn; this.emrDbName = emrDbName; listModel = new DefaultListModel<String>(); initComponents(); this.setClosable(true); SourceTablesListener listSelectionListener = new SourceTablesListener(txtSelectedTables, listOfTables); sourceTablesList.setCellRenderer(new CheckboxListCellRenderer()); sourceTablesList.addListSelectionListener(listSelectionListener); sourceTablesList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); sourceTablesList.setSelectionModel(new DefaultListSelectionModel() { @Override public void setSelectionInterval(int index0, int index1) { if (isSelectedIndex(index0)) super.removeSelectionInterval(index0, index1); else super.addSelectionInterval(index0, index1); } }); //getDatabaseMetaData(); final ListUpdater lu = new ListUpdater(); lu.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent event) { switch (event.getPropertyName()) { case "progress": System.out.println("Fetching data from db"); break; case "state": switch ((SwingWorker.StateValue) event.getNewValue()) { case DONE: try { listModel = lu.get(); sourceTablesList.setModel(listModel); } catch (final CancellationException ex) { Logger.getLogger(SourceDataPreview.class.getName()).log(Level.SEVERE, null, ex); } catch (InterruptedException ex) { Logger.getLogger(SourceDataPreview.class.getName()).log(Level.SEVERE, null, ex); } catch (ExecutionException ex) { Logger.getLogger(SourceDataPreview.class.getName()).log(Level.SEVERE, null, ex); } break; } break; } } }); lu.execute(); }
From source file:org.ngrinder.recorder.ui.RecordingControlPanel.java
/** * Initialize event handler./*from ww w . j ava 2s . c o m*/ */ protected void initEventHandler() { // Global Event messageBus = MessageBus.getInstance(); messageBus.connect().subscribe(Topics.PREPARE_TO_CLOSE, new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { File home = (File) evt.getNewValue(); typeFilterPersistentHandler.save(home); generationOptionsPersistentHandler.save(home); } }); messageBus.connect().subscribe(Topics.PREPARE_TO_VIEW, new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { File home = (File) evt.getNewValue(); typeFilterPersistentHandler.load(home); generationOptionsPersistentHandler.load(home); } }); // Attach event. createFilterTablePopUp = createFilterTablePopUp(); attachPopupMenu(createFilterTables, createFilterTablePopUp); }
From source file:edu.ku.brc.specify.tools.schemalocale.SchemaToolsDlg.java
/** * /* www. j a va 2 s. c om*/ */ private void importSchema(final boolean doLocalization) { FileDialog fileDlg = new FileDialog((Dialog) null); fileDlg.setTitle(getResourceString(doLocalization ? SL_CHS_LOC : SL_CHS_IMP)); UIHelper.centerAndShow(fileDlg); String fileName = fileDlg.getFile(); if (StringUtils.isNotEmpty(fileName)) { String title = getResourceString(doLocalization ? "SL_L10N_SCHEMA" : "SL_IMPORT_SCHEMA"); final File file = new File(fileDlg.getDirectory() + File.separator + fileName); final SimpleGlassPane glassPane = new SimpleGlassPane(title, 18); glassPane.setBarHeight(12); glassPane.setFillColor(new Color(0, 0, 0, 85)); setGlassPane(glassPane); glassPane.setVisible(true); SwingWorker<Integer, Integer> importWorker = new SwingWorker<Integer, Integer>() { private boolean isOK = false; @Override protected Integer doInBackground() throws Exception { DataProviderSessionIFace localSession = null; try { localSession = DataProviderFactory.getInstance().createSession(); localSession.beginTransaction(); BuildSampleDatabase bsd = new BuildSampleDatabase(); Discipline discipline = localSession.get(Discipline.class, AppContextMgr.getInstance().getClassObject(Discipline.class).getId()); isOK = bsd.loadSchemaLocalization(discipline, schemaType, DBTableIdMgr.getInstance(), null, //catFmtName, null, //accFmtName, doLocalization ? UpdateType.eLocalize : UpdateType.eImport, // isDoingUpdate file, // external file glassPane, localSession); if (isOK) { localSession.commit(); } else { localSession.rollback(); } } catch (Exception ex) { ex.printStackTrace(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(BuildSampleDatabase.class, ex); } finally { if (localSession != null) { localSession.close(); } } return null; } @Override protected void done() { super.done(); glassPane.setVisible(false); if (isOK) { UIRegistry.showLocalizedMsg("Specify.ABT_EXIT"); CommandDispatcher.dispatch(new CommandAction("App", "AppReqExit")); } } }; importWorker.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(final PropertyChangeEvent evt) { if (evt.getPropertyName().equals("progress")) { glassPane.setProgress((Integer) evt.getNewValue()); } } }); importWorker.execute(); } }
From source file:ui.panel.UILicenseAdd.java
public JPanel createButtonPanel() { JPanel panel = p.createPanel(Layouts.flow); panel.setLayout(new FlowLayout(FlowLayout.CENTER)); btnSubmit = b.createButton("Submit"); btnCancel = b.createButton("Cancel"); btnSubmit.addActionListener(new ActionListener() { @Override//from ww w . j a va2s .c o m public void actionPerformed(ActionEvent e) { SwingWorker<Void, Void> mySwingWorker = new SwingWorker<Void, Void>() { @Override protected Void doInBackground() throws Exception { TreePath[] path = checkTreeManager.getSelectionModel().getSelectionPaths(); ArrayList<String> featureL = new ArrayList<String>(); String[] features = new String[] {}; for (TreePath tp : path) { if (tp.getLastPathComponent().toString().equals("Features")) { Object rootNode = tree.getModel().getRoot(); int parentCount = tree.getModel().getChildCount(rootNode); for (int i = 0; i < parentCount; i++) { Object parentNode = tree.getModel().getChild(rootNode, i); int childrenCount = tree.getModel().getChildCount(parentNode); for (int x = 0; x < childrenCount; x++) { MyDataNode node = (MyDataNode) tree.getModel().getChild(parentNode, x); featureL.add(node.getValue()); } } } else if (tp.getPathCount() == 2) { Object rootNode = tree.getModel().getRoot(); int parentCount = tree.getModel().getChildCount(rootNode); for (int i = 0; i < parentCount; i++) { Object parentNode = tree.getModel().getChild(rootNode, i); if (parentNode.toString().equals(tp.getLastPathComponent().toString())) { int childrenCount = tree.getModel().getChildCount(parentNode); for (int x = 0; x < childrenCount; x++) { MyDataNode node = (MyDataNode) tree.getModel().getChild(parentNode, x); featureL.add(node.getValue()); } } } } else if (tp.getPathCount() == 3) { MyDataNode node = (MyDataNode) tp.getLastPathComponent(); featureL.add(node.getValue()); } } features = featureL.toArray(features); String duration = spnValidity.getValue().toString(); if (cbPerpetual.isSelected()) { duration = "-1"; } String storage = spnCloud.getValue().toString(); String maxVCA = spnConcurrentVCA.getValue().toString(); String response = apiCall.addNodeLicense(Data.targetURL, Data.sessionKey, Data.bucketID, features, duration, storage, maxVCA); try { JSONObject responseObject = new JSONObject(response); if (responseObject.get("result").equals("ok")) { Data.mainFrame.uiLicenseDetail.getLicenseData(); Data.mainFrame.showPanel("license"); } } catch (JSONException e1) { e1.printStackTrace(); } return null; } }; Window win = SwingUtilities.getWindowAncestor((AbstractButton) e.getSource()); final JDialog dialog = new JDialog(win, "Loading", ModalityType.APPLICATION_MODAL); mySwingWorker.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("state")) { if (evt.getNewValue() == SwingWorker.StateValue.DONE) { dialog.dispose(); } } } }); mySwingWorker.execute(); JProgressBar progressBar = new JProgressBar(); progressBar.setIndeterminate(true); JPanel panel = new JPanel(new BorderLayout()); panel.add(progressBar, BorderLayout.CENTER); panel.add(new JLabel("Retrieving License..."), BorderLayout.PAGE_START); dialog.add(panel); dialog.pack(); dialog.setBounds(50, 50, 300, 100); dialog.setLocationRelativeTo(Data.mainFrame); dialog.setVisible(true); } }); btnCancel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setVisible(false); Data.mainFrame.showPanel("license"); } }); panel.add(btnSubmit); panel.add(btnCancel); return panel; }