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:mulavito.gui.components.LayerDataPanel.java

public LayerDataPanel(FloatingTabbedPane owner) {
    super("Layer Data", owner);

    textArea = new JTextArea(defaultText);
    textArea.setEditable(false);//  w w w .  j a v  a2s  .co  m
    textArea.setCaretPosition(0); // Scroll up the text area.
    JScrollPane textPane = new JScrollPane(textArea);

    add(textPane, BorderLayout.CENTER);

    // updates the data
    mouseListener = new MouseAdapter() {
        @SuppressWarnings("unchecked")
        @Override
        public void mouseEntered(MouseEvent e) {
            if (e.getSource() instanceof LayerViewer<?, ?>) {
                LayerViewer<V, E> vv = (LayerViewer<V, E>) e.getSource();
                showData(vv.getLayer());
            }
        }

        @Override
        public void mouseExited(MouseEvent e) {
            showData(null);
        }
    };

    // adds/removes focus listeners on layers
    graphPanelListener = new PropertyChangeListener() {
        @SuppressWarnings("unchecked")
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName().equals("Viewers")) {
                if (evt.getOldValue() instanceof LayerViewer<?, ?> && evt.getNewValue() == null) {
                    // GraphPanel#removeLayer
                    ((LayerViewer<?, ?>) evt.getOldValue()).removeMouseListener(mouseListener);
                } else if (evt.getOldValue() instanceof List<?>) {
                    System.out.println("Replace");
                    for (LayerViewer<?, ?> vv : ((List<LayerViewer<?, ?>>) evt.getOldValue()))
                        vv.removeMouseListener(mouseListener);
                }

                if (evt.getNewValue() instanceof LayerViewer<?, ?> && evt.getOldValue() == null) {
                    // GraphPanel#addLayer
                    ((LayerViewer<?, ?>) evt.getNewValue()).addMouseListener(mouseListener);
                } else if (evt.getNewValue() instanceof List<?>) {
                    // New Layer List on start up
                    for (LayerViewer<?, ?> vv : ((List<LayerViewer<?, ?>>) evt.getNewValue()))
                        vv.addMouseListener(mouseListener);
                }

                showData(current);
            }
        }
    };
}

From source file:org.jcurl.core.api.PropertyChangeSupport.java

public void firePropertyChange(final PropertyChangeEvent event) {
    // log.debug(event);
    validateNamedProperty(event.getPropertyName());
    {//from   ww  w.  jav a 2  s  . c o  m
        final Object a = event.getOldValue();
        final Object b = event.getNewValue();
        if (a != null && a.equals(b) || a == null && b == null)
            return;
    }
    // validated that an event must be thrown; now throw it.
    synchronized (listenerMap) {
        // First gets the list of listeners and stores them in strong
        // references by copying them into a new set.
        final Set<PropertyChangeListener> targets = new HashSet<PropertyChangeListener>(
                listenerMap.get(ALL_PROPERTIES));
        targets.addAll(listenerMap.get(event.getPropertyName()));
        for (final PropertyChangeListener element : targets)
            element.propertyChange(event);
    }
}

From source file:org.netflux.core.task.AbstractTask.java

/**
 * Creates a new task with the given name, and initializes its input and output ports using the given names.
 * /*from   w  w w  .  ja v a  2  s.c om*/
 * @param name the name of the task to be created.
 * @param inputPortNames the name of the input ports this task will use to read records.
 * @param outputPortNames the name of the output ports this task will use to write records.
 */
protected AbstractTask(String name, Set<String> inputPortNames, Set<String> outputPortNames) {
    this.name = name;
    Iterator<String> inputPortNamesIterator = inputPortNames.iterator();
    while (inputPortNamesIterator.hasNext()) {
        String inputPortName = inputPortNamesIterator.next();
        InputPort currentInputPort = new SimpleInputPort(this.name + ":" + inputPortName);
        this.inputPorts.put(inputPortName, currentInputPort);
        currentInputPort.addPropertyChangeListener("metadata", new PropertyChangeListener() {
            public void propertyChange(PropertyChangeEvent event) {
                AbstractTask.this.updateMetadata((InputPort) event.getSource(),
                        (RecordMetadata) event.getNewValue());
            }
        });
    }

    Iterator<String> outputPortNamesIterator = outputPortNames.iterator();
    while (outputPortNamesIterator.hasNext()) {
        String outputPortName = outputPortNamesIterator.next();
        this.outputPorts.put(outputPortName, new SimpleOutputPort(this.name + ":" + outputPortName));
    }
}

From source file:org.ut.biolab.medsavant.client.util.VisibleMedSavantWorker.java

@Override
public final void propertyChange(PropertyChangeEvent evt) {
    if (!progressBar.isIndeterminate() && "progress" == evt.getPropertyName()) {
        int progress = (Integer) evt.getNewValue();
        progressBar.setValue(progress);// w ww.j a  v  a 2  s.c  o m
    }
}

From source file:org.eclipse.wb.internal.swing.customize.CustomizerAction.java

private void performCustomize0() throws Exception {
    Customizer customizer = m_customizerClass.newInstance();
    // prepare properties information
    final JavaInfoState javaInfoState = JavaInfoState.getState(m_javaInfo);
    boolean explicit = isExplicitPropertyChange(m_javaInfo);
    PropertyChangeListener propertyChangeListener = null;
    if (explicit) {
        propertyChangeListener = new PropertyChangeListener() {
            public void propertyChange(PropertyChangeEvent event) {
                javaInfoState.changedProperties.add(event.getPropertyName());
                javaInfoState.changedPropertyValues.put(event.getPropertyName(), event.getNewValue());
            }/*www .j  a  va  2 s. c om*/
        };
        customizer.addPropertyChangeListener(propertyChangeListener);
    }
    //
    try {
        // open customizer dialog
        customizer.setObject(javaInfoState.object);
        AwtComponentDialog dialog = new AwtComponentDialog(DesignerPlugin.getDefault(), (Component) customizer,
                ModelMessages.CustomizerAction_dialogTitle, MessageFormat
                        .format(ModelMessages.CustomizerAction_dialogMessage, m_customizerClass.getName()));
        int dialogResult = dialog.open();
        // handle update properties
        if (dialogResult == Window.OK) {
            RunnableEx runnable = null;
            if (explicit) {
                // update changed properties
                runnable = new RunnableEx() {
                    public void run() throws Exception {
                        int size = javaInfoState.properties.size();
                        for (int i = 0; i < size; i++) {
                            Property property = javaInfoState.properties.get(i);
                            if (javaInfoState.changedProperties.contains(property.getTitle())) {
                                Object newValue = javaInfoState.changedPropertyValues.get(property.getTitle());
                                Object oldValue = javaInfoState.oldValues.get(i);
                                if (!ObjectUtils.equals(newValue, oldValue)) {
                                    property.setValue(newValue);
                                }
                            }
                        }
                    }
                };
            } else {
                // update all properties
                runnable = new RunnableEx() {
                    public void run() throws Exception {
                        int size = javaInfoState.properties.size();
                        for (int i = 0; i < size; i++) {
                            Object newValue = javaInfoState.getters.get(i).invoke(javaInfoState.object);
                            Object oldValue = javaInfoState.oldValues.get(i);
                            if (!ObjectUtils.equals(newValue, oldValue)) {
                                javaInfoState.properties.get(i).setValue(newValue);
                            }
                        }
                    }
                };
            }
            // run update
            ExecutionUtils.run(m_javaInfo, runnable);
        }
        // rollback property changes
        if (dialogResult == Window.CANCEL) {
            ExecutionUtils.run(m_javaInfo, new RunnableEx() {
                public void run() throws Exception {
                    int size = javaInfoState.properties.size();
                    for (int i = 0; i < size; i++) {
                        Object newValue = javaInfoState.getters.get(i).invoke(javaInfoState.object);
                        Object oldValue = javaInfoState.oldValues.get(i);
                        if (!ObjectUtils.equals(newValue, oldValue)) {
                            javaInfoState.setters.get(i).invoke(javaInfoState.object, oldValue);
                        }
                    }
                }
            });
        }
    } finally {
        if (propertyChangeListener != null) {
            customizer.removePropertyChangeListener(propertyChangeListener);
        }
    }
}

From source file:com.eviware.soapui.impl.wsdl.panels.teststeps.GroovyScriptStepDesktopPanel.java

public void propertyChange(PropertyChangeEvent evt) {
    if (evt.getPropertyName().equals("script") && !updating) {
        updating = true;//from w  ww  . j  a  v  a2  s .  c  om
        editor.getEditArea().setText((String) evt.getNewValue());
        updating = false;
    }

    super.propertyChange(evt);
}

From source file:org.pentaho.reporting.libraries.designtime.swing.date.DateCellEditor.java

private void init() {
    if (dateChooserPanel == null) {
        dateChooserPanel = new DateChooserPanel(Calendar.getInstance(), true);
        dateChooserPanel.addPropertyChangeListener(DateChooserPanel.PROPERTY_DATE,
                new InternalDateUpdateHandler());

        dateField.addPropertyChangeListener("value", new PropertyChangeListener() {
            public void propertyChange(final PropertyChangeEvent evt) {
                Date newValue = (Date) evt.getNewValue();
                newValue = newValue == null ? null : DateConverter.convertToDateType(newValue, dateType);
                dateChooserPanel.setDate(newValue, false);
                dateChooserPanel.setDateSelected(true);
            }/*from  w ww  .  j  a  v a  2  s  . co m*/
        });
        dateField.addFocusListener(new FocusAdapter() {
            public void focusGained(final FocusEvent e) {
                dateChooserPanel.setDateSelected(false);
            }
        });
        if (dateField.getFormatterFactory() == null) {
            setDateFormat(createDateFormat(DEFAULT_FORMAT, Locale.getDefault(), TimeZone.getDefault()));
        }
    }
}

From source file:org.rifidi.designer.entities.databinding.ObservableTreeContentProvider.java

@Override
public void propertyChange(PropertyChangeEvent evt) {
    if (evt.getOldValue() != null) {
        viewer.remove(evt.getSource(), new Object[] { evt.getOldValue() });
    }/*from w w  w .  j  ava  2  s .  com*/
    viewer.add(evt.getSource(), evt.getNewValue());
    viewer.refresh(evt.getSource());
}

From source file:de.tntinteractive.portalsammler.gui.MainDialog.java

private void poll(final Gui gui) {

    this.pollButton.setEnabled(false);

    final Settings settings = this.getStore().getSettings().deepClone();
    final ProgressMonitor progress = new ProgressMonitor(this, "Sammle Daten aus den Quell-Portalen...", "...",
            0, settings.getSize());/*  www. j a  v a 2  s  .  c  o  m*/
    progress.setMillisToDecideToPopup(0);
    progress.setMillisToPopup(0);
    progress.setProgress(0);

    final SwingWorker<String, String> task = new SwingWorker<String, String>() {

        @Override
        protected String doInBackground() throws Exception {
            final StringBuilder summary = new StringBuilder();
            int cnt = 0;
            for (final String id : settings.getAllSettingIds()) {
                if (this.isCancelled()) {
                    break;
                }
                cnt++;
                this.publish(cnt + ": " + id);
                final Pair<Integer, Integer> counts = MainDialog.this.pollSingleSource(settings, id);
                summary.append(id).append(": ");
                if (counts != null) {
                    summary.append(counts.getLeft()).append(" neu, ").append(counts.getRight())
                            .append(" schon bekannt\n");
                } else {
                    summary.append("Fehler!\n");
                }
                this.setProgress(cnt);
            }
            MainDialog.this.getStore().writeMetadata();
            return summary.toString();
        }

        @Override
        protected void process(final List<String> ids) {
            progress.setNote(ids.get(ids.size() - 1));
        }

        @Override
        public void done() {
            MainDialog.this.pollButton.setEnabled(true);
            MainDialog.this.table.refreshContents();
            try {
                final String summary = this.get();
                JOptionPane.showMessageDialog(MainDialog.this, summary, "Abruf-Zusammenfassung",
                        JOptionPane.INFORMATION_MESSAGE);
            } catch (final Exception e) {
                gui.showError(e);
            }
        }

    };

    task.addPropertyChangeListener(new PropertyChangeListener() {
        @Override
        public void propertyChange(final PropertyChangeEvent evt) {
            if ("progress".equals(evt.getPropertyName())) {
                progress.setProgress((Integer) evt.getNewValue());
            }
            if (progress.isCanceled()) {
                task.cancel(true);
            }
        }
    });

    task.execute();
}