Example usage for java.beans PropertyChangeEvent getNewValue

List of usage examples for java.beans PropertyChangeEvent getNewValue

Introduction

In this page you can find the example usage for java.beans PropertyChangeEvent getNewValue.

Prototype

public Object getNewValue() 

Source Link

Document

Gets the new value for the property, expressed as an Object.

Usage

From source file:org.tinymediamanager.ui.MainWindow.java

private void checkForUpdate() {
    try {//from w w w  .j a  va 2  s .  co  m
        final UpdaterTask updateWorker = new UpdaterTask();

        updateWorker.addPropertyChangeListener(new PropertyChangeListener() {
            public void propertyChange(PropertyChangeEvent evt) {
                if ("state".equals(evt.getPropertyName()) && evt.getNewValue() == StateValue.DONE) {
                    try {
                        boolean update = updateWorker.get();
                        LOGGER.debug("update result was: " + update);
                        if (update) {

                            // we might need this somewhen...
                            if (updateWorker.isForcedUpdate()) {
                                LOGGER.info("Updating (forced)...");
                                closeTmmAndStart(Utils.getPBforTMMupdate());
                                return;
                            }

                            // show whatsnewdialog with the option to update
                            if (StringUtils.isNotBlank(updateWorker.getChangelog())) {
                                UpdateDialog dialog = new UpdateDialog(updateWorker.getChangelog());
                                dialog.setVisible(true);
                            } else {
                                // do the update without changelog popup

                                int answer = JOptionPane.showConfirmDialog(null,
                                        BUNDLE.getString("tmm.update.message"),
                                        BUNDLE.getString("tmm.update.title"), JOptionPane.YES_NO_OPTION);
                                if (answer == JOptionPane.OK_OPTION) {
                                    LOGGER.info("Updating...");

                                    // spawn getdown and exit TMM
                                    closeTmmAndStart(Utils.getPBforTMMupdate());
                                }
                            }
                        }
                    } catch (Exception e) {
                        LOGGER.error("Update task failed!" + e.getMessage());
                    }
                }
            }
        });

        // update task start a few secs after GUI...
        Timer timer = new Timer(5000, new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                updateWorker.execute();
            }
        });
        timer.setRepeats(false);
        timer.start();
    } catch (Exception e) {
        LOGGER.error("Update task failed!" + e.getMessage());
    }
}

From source file:org.talend.component.ui.wizard.ui.DynamicComposite.java

@Override
public void propertyChange(PropertyChangeEvent event) {
    String propertyName = event.getPropertyName();
    if (IElementParameterEventProperties.EVENT_PROPERTY_VALUE_CHANGED.equals(propertyName)) {
        reset(true);/*from  ww  w.  j  a v  a 2 s  . c  o  m*/
    } else if (IElementParameterEventProperties.EVENT_PROPERTY_NAME_CHANGED.equals(propertyName)) {
        String newPropertyName = String.valueOf(event.getNewValue());
        updateProperty(newPropertyName);
    } else if (IElementParameterEventProperties.EVENT_VALIDATE_RESULT_UPDATE.equals(propertyName)) {
        Object newValue = event.getNewValue();
        if (newValue instanceof ValidationResult) {
            updateValidationStatus((ValidationResult) newValue);
        }
    } else if (IElementParameterEventProperties.EVENT_SHOW_DIALOG.equals(propertyName)) {
        Object newValue = event.getNewValue();
        if (newValue instanceof Form) {
            new GenericDialog(getShell(), (Form) newValue).open();
        }
    } else if (IContextEventProperties.EVENT_PROPERTY_EXPORT_CONTEXT.equals(propertyName)) {
        resetComponentProperties();
    } else if (IContextEventProperties.EVENT_PROPERTY_REFRESH_UI.equals(propertyName)) {
        Object newValue = event.getNewValue();
        if (newValue instanceof ComponentProperties) {
            ComponentProperties newComponentProperties = (ComponentProperties) newValue;
            form.getComponentProperties().copyValuesFrom(newComponentProperties);
            reset(true);
        }
    }
}

From source file:oct.analysis.application.dat.OCTAnalysisManager.java

/**
 * This method will take care of interacting with the user in determining
 * where the fovea is within the OCT. It first lets the user inspect the
 * automatically identified locations where the fovea may be and then choose
 * the selection that is at the fovea. If none of the automated findings are
 * at the fovea the user has the option to manual specify it's location.
 * Finally, the chosen X coordinate (within the OCT) of the fovea is set in
 * the manager and can be obtained via the getFoveaCenterXPosition getter.
 *
 * @param fullAutoMode find the fovea automatically without user input when
 * true, otherwise find the fovea in semi-automatic mode involving user
 * interaction/*from w  w  w  .  j a  v  a  2  s .  co  m*/
 */
public void findCenterOfFovea(boolean fullAutoMode) throws InterruptedException, ExecutionException {
    //disable clicking other components while processing by enabling glass pane
    JFrame topFrame = (JFrame) SwingUtilities.getWindowAncestor(imgPanel);
    Component glassPane = topFrame.getGlassPane();
    glassPane.setVisible(true);

    //monitor progress of finding the fovea
    ProgressMonitor pm = new ProgressMonitor(imgPanel, "Analyzing OCT for fovea...", "", 0, 100);
    pm.setMillisToDecideToPopup(0);
    pm.setMillisToPopup(100);
    pm.setProgress(0);
    FoveaFindingTask fvtask = new FoveaFindingTask(!fullAutoMode, glassPane);
    fvtask.addPropertyChangeListener((PropertyChangeEvent evt) -> {
        if ("progress".equals(evt.getPropertyName())) {
            int progress1 = (Integer) evt.getNewValue();
            pm.setProgress(progress1);
        }
    });
    fvtask.execute();
}

From source file:edu.ku.brc.specify.tasks.StatsTrackerTask.java

@Override
protected PropertyChangeListener getPCLForWorker() {
    return new PropertyChangeListener() {
        public void propertyChange(final PropertyChangeEvent evt) {
            if ("progress".equals(evt.getPropertyName())) {
                if (progress != null)
                    progress.setValue((Integer) evt.getNewValue());
            }/*from w w  w.  j av  a  2s  . co m*/
        }
    };
}

From source file:org.talend.repository.generic.ui.DynamicComposite.java

@Override
public void propertyChange(PropertyChangeEvent event) {
    String propertyName = event.getPropertyName();
    if (IElementParameterEventProperties.EVENT_PROPERTY_VALUE_CHANGED.equals(propertyName)) {
        reset(true);/*w w w.j  av a 2 s .co m*/
    } else if (IElementParameterEventProperties.EVENT_PROPERTY_NAME_CHANGED.equals(propertyName)) {
        String newPropertyName = String.valueOf(event.getNewValue());
        updateProperty(newPropertyName);
    } else if (IElementParameterEventProperties.EVENT_VALIDATE_RESULT_UPDATE.equals(propertyName)) {
        Object newValue = event.getNewValue();
        if (newValue instanceof ValidationResult) {
            updateValidationStatus((ValidationResult) newValue);
        }
    } else if (IElementParameterEventProperties.EVENT_SHOW_DIALOG.equals(propertyName)) {
        Object newValue = event.getNewValue();
        if (newValue instanceof Form) {
            GenericDialog genericDialog = new GenericDialog(getShell(), (Form) newValue);
            genericDialog.setConnectionItem(connectionItem);
            genericDialog.open();
        }
    } else if (IContextEventProperties.EVENT_PROPERTY_EXPORT_CONTEXT.equals(propertyName)) {
        resetComponentProperties();
    } else if (IContextEventProperties.EVENT_PROPERTY_REFRESH_UI.equals(propertyName)) {
        Object newValue = event.getNewValue();
        if (newValue instanceof ComponentProperties) {
            ComponentProperties newComponentProperties = (ComponentProperties) newValue;
            form.getProperties().copyValuesFrom(newComponentProperties);
            reset(true);
        }
    }
}

From source file:org.polymap.core.data.ui.featureselection.FeatureSelectionView.java

public void createPartControl(@SuppressWarnings("hiding") Composite parent) {
    if (initLayer.get() != null) {
        init(initLayer.get());//from  w w  w.  ja v a  2s .  co  m
    } else {
        if (layer == null) {
            log.warn("No layer set. Closing view...");
            Label msg = new Label(parent, SWT.NONE);
            msg.setText("No layer.");
            close(null);
        } else {
            init(layer);
        }
    }

    this.parent = parent;
    this.parent.setLayout(new FormLayout());

    // check fs -> error message
    if (fs == null) {
        Label msg = new Label(parent, SWT.NONE);
        msg.setText("No feature pipeline for layer: " + (layer != null ? layer.getLabel() : "???"));
        return;
    }

    viewer = new FeatureTableViewer(parent, SWT.MULTI);
    viewer.getTable().setLayoutData(new SimpleFormData().fill().create());

    viewer.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent ev) {
            if (ev.getPropertyName().equals(FeatureTableViewer.PROP_CONTENT_SIZE)) {
                Integer count = (Integer) ev.getNewValue();
                setPartName(basePartName + " (" + count + ")");
            }
        }
    });
    viewer.addSelectionChangedListener(this);

    // double-click
    viewer.addDoubleClickListener(new IDoubleClickListener() {
        public void doubleClick(DoubleClickEvent ev) {
            log.info("doubleClick(): " + ev);
            //IAction openHandler = getViewSite().getActionBars().getGlobalActionHandler( "org.polymap.rhei.OpenFormAction" );
            if (openAction != null) {
                openAction.run(null);
            }
        }
    });

    // columns
    assert fs != null : "fs not set. Call init() first.";
    SimpleFeatureType schema = fs.getSchema();
    for (PropertyDescriptor prop : schema.getDescriptors()) {
        if (Geometry.class.isAssignableFrom(prop.getType().getBinding())) {
            // skip Geometry
        } else {
            viewer.addColumn(new DefaultFeatureTableColumn(prop));
        }
    }

    viewer.getTable().pack(true);

    getSite().setSelectionProvider(viewer);
    hookContextMenu();

    loadTable(filter);
}

From source file:org.openmicroscopy.shoola.agents.fsimporter.view.ImporterControl.java

/**
 * Handles a PropertyChangedEvent/*from  w  w  w .ja  v  a2 s  .co  m*/
 * @param evt The event
 */
private void handlePropertyChangedEvent(PropertyChangeEvent evt) {
    String name = evt.getPropertyName();
    if (ImportDialog.IMPORT_PROPERTY.equals(name)) {
        actionsMap.get(CANCEL_BUTTON).setEnabled(true);
        model.importData((ImportableObject) evt.getNewValue());
    } else if (ImportDialog.LOAD_TAGS_PROPERTY.equals(name)) {
        model.loadExistingTags();
    } else if (ImportDialog.CANCEL_SELECTION_PROPERTY.equals(name)) {
        model.close();
    } else if (ClosableTabbedPane.CLOSE_TAB_PROPERTY.equals(name)) {
        model.removeImportElement(evt.getNewValue());
    } else if (FileImportComponent.SUBMIT_ERROR_PROPERTY.equals(name)) {
        submitFiles((FileImportComponent) evt.getNewValue());
    } else if (ImportDialog.REFRESH_LOCATION_PROPERTY.equals(name)) {
        model.refreshContainers((ImportLocationDetails) evt.getNewValue());
    } else if (ImportDialog.CREATE_OBJECT_PROPERTY.equals(name)) {
        ObjectToCreate l = (ObjectToCreate) evt.getNewValue();
        model.createDataObject(l);
    } else if (StatusLabel.DEBUG_TEXT_PROPERTY.equals(name)) {
        view.appendDebugText((String) evt.getNewValue());
    } else if (MacOSMenuHandler.QUIT_APPLICATION_PROPERTY.equals(name)) {
        Action a = getAction(EXIT);
        ActionEvent event = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, "");
        a.actionPerformed(event);
    } else if (ImportDialog.PROPERTY_GROUP_CHANGED.equals(name)) {
        GroupData newGroup = (GroupData) evt.getNewValue();
        model.setUserGroup(newGroup);
    } else if (StatusLabel.FILE_IMPORT_STARTED_PROPERTY.equals(name)
            || FileImportComponent.CANCEL_IMPORT_PROPERTY.equals(name)) {
        checkDisableCancelAllButtons();
    } else if (StatusLabel.IMPORT_DONE_PROPERTY.equals(name)) {
        model.onImportComplete((FileImportComponent) evt.getNewValue());
    } else if (StatusLabel.UPLOAD_DONE_PROPERTY.equals(name)) {
        model.onUploadComplete((FileImportComponent) evt.getNewValue());
    }
}

From source file:edu.ku.brc.specify.tools.schemalocale.SchemaToolsDlg.java

/**
 * //from   w  ww .j  a  v  a 2  s  .  com
 */
@SuppressWarnings("unchecked")
protected void exportSchemaLocales() {
    FileDialog dlg = new FileDialog(((Frame) UIRegistry.getTopWindow()), getResourceString("Save"),
            FileDialog.SAVE);
    dlg.setVisible(true);

    String fileName = dlg.getFile();
    if (fileName != null) {
        final File outFile = new File(dlg.getDirectory() + File.separator + fileName);
        //final File    outFile = new File("xxx.xml");

        final SimpleGlassPane glassPane = new SimpleGlassPane(getResourceString("SL_EXPORT_SCHEMA"), 18);
        glassPane.setBarHeight(12);
        glassPane.setFillColor(new Color(0, 0, 0, 85));

        setGlassPane(glassPane);
        glassPane.setVisible(true);

        SwingWorker<Integer, Integer> backupWorker = new SwingWorker<Integer, Integer>() {
            @Override
            protected Integer doInBackground() throws Exception {

                DataProviderSessionIFace session = null;
                try {
                    session = DataProviderFactory.getInstance().createSession();

                    int dispId = AppContextMgr.getInstance().getClassObject(Discipline.class).getDisciplineId();
                    String sql = String.format(
                            "FROM SpLocaleContainer WHERE disciplineId = %d AND schemaType = %d", dispId,
                            schemaType);
                    List<SpLocaleContainer> spContainers = (List<SpLocaleContainer>) session.getDataList(sql);
                    try {
                        FileWriter fw = new FileWriter(outFile);

                        //fw.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<vector>\n");
                        fw.write("<vector>\n");

                        BeanWriter beanWriter = new BeanWriter(fw);
                        XMLIntrospector introspector = beanWriter.getXMLIntrospector();
                        introspector.getConfiguration().setWrapCollectionsInElement(true);
                        beanWriter.getBindingConfiguration().setMapIDs(false);
                        beanWriter.setWriteEmptyElements(false);

                        beanWriter.enablePrettyPrint();

                        double step = 100.0 / (double) spContainers.size();
                        double total = 0.0;
                        for (SpLocaleContainer container : spContainers) {
                            // force Load of lazy collections
                            container.getDescs().size();
                            container.getNames().size();

                            // Leaving this Code as an example of specifying the bewtixt file.
                            /*InputStream inputStream = Specify.class.getResourceAsStream("datamodel/SpLocaleContainer.betwixt");
                            //InputStream inputStream = Specify.class.getResourceAsStream("/edu/ku/brc/specify/tools/schemalocale/SpLocaleContainer.betwixt");
                            InputSource inputSrc    = new InputSource(inputStream); 
                            beanWriter.write(container, inputSrc);
                            inputStream.close(); */

                            beanWriter.write(container);

                            total += step;
                            firePropertyChange("progress", 0, (int) total);
                        }

                        fw.write("</vector>\n");
                        fw.close();

                    } catch (Exception ex) {
                        ex.printStackTrace();
                    }

                } catch (Exception e) {
                    edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
                    edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(SchemaLocalizerDlg.class, e);
                    e.printStackTrace();

                } finally {
                    if (session != null) {
                        session.close();
                    }
                }

                return null;
            }

            @Override
            protected void done() {
                super.done();

                glassPane.setVisible(false);
            }
        };

        backupWorker.addPropertyChangeListener(new PropertyChangeListener() {
            public void propertyChange(final PropertyChangeEvent evt) {
                if (evt.getPropertyName().equals("progress")) {
                    glassPane.setProgress((Integer) evt.getNewValue());
                }
            }
        });
        backupWorker.execute();
    }
}

From source file:de.rub.syssec.saaf.gui.editor.FileTree.java

@Override
public void propertyChange(PropertyChangeEvent arg0) {
    if ("currentFile".equals(arg0.getPropertyName())) {
        File f = (File) arg0.getNewValue();
        ApplicationInterface app = model.getCurrentApplication();
        String shortpath = f.getAbsolutePath().replace(app.getApplicationDirectory().getAbsolutePath(), "");

        // update the tree selection
        searchNode(shortpath, null);/*from  w w  w. java  2  s .  co  m*/
        //update the editor so we see what we are editing
        this.setTitle("Editor - " + shortpath);
    }
}

From source file:org.ut.biolab.medsavant.client.view.genetics.variantinfo.GeneManiaSubInspector.java

private void registerDownloadListener() {
    try {//from   w  ww. ja v  a2  s .  c  o m
        DownloadTask downloadTask = GenemaniaInfoRetriever.getGeneManiaDownloadTask();
        if (currentDownloadTask != downloadTask) {
            currentDownloadTask = downloadTask;

            final DownloadTask dt = downloadTask;
            dt.addPropertyChangeListener(new PropertyChangeListener() {
                @Override
                public void propertyChange(PropertyChangeEvent evt) {
                    if (evt.getPropertyName().equals("downloadState")) {
                        DownloadState ds = (DownloadState) evt.getNewValue();
                        if (ds == DownloadState.CANCELLED) {
                            panel.removeAll();
                            panel.add(downloadGeneManiaButton);
                            panel.revalidate();
                            panel.repaint();
                        } else if (ds == DownloadState.FINISHED) {
                            //this should always be true.
                            if (DirectorySettings.isGeneManiaInstalled()) {
                                try {
                                    dataPresent = true;
                                    genemania = new GenemaniaInfoRetriever();
                                    genemaniaSettings = new GeneManiaSettingsDialog(genemania);
                                    panel.removeAll();
                                    buildPanel();
                                    updateRelatedGenesPanel(genes);
                                } catch (IOException e) {
                                    DialogUtils.displayMessage("Error downloading GeneMANIA files");
                                    LOG.error("Error downloading GeneMANIA files " + e);
                                    dataPresent = false;
                                }
                            } else {
                                LOG.error("Error downloading GeneMANIA files.");
                            }
                        }
                    }
                }
            });
        }
    } catch (IOException e) {
    }
}