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:eu.ggnet.dwoss.stock.CommissioningManagerView.java

public void setModel(CommissioningManagerModel model) {
    this.model = model;
    updateStatus();//w  w w .  j  a v  a 2s  .c o m
    model.addPropertyChangeListener(new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            updateStatus();
            if (evt.getPropertyName().equals(CommissioningManagerModel.PROP_FULL)) {
                boolean temp = (Boolean) evt.getNewValue();
                done1Button.setEnabled(temp);
                done2Button.setEnabled(temp);
            }
            if (evt.getPropertyName().equals(CommissioningManagerModel.PROP_PARTICIPANT_ONE)) {
                done1Button.setText("Authentifiziere " + evt.getNewValue().toString());
            }
            if (evt.getPropertyName().equals(CommissioningManagerModel.PROP_PARTICIPANT_TWO)) {
                done2Button.setText("Authentifiziere " + evt.getNewValue().toString());
            }
            if (evt.getPropertyName().equals(CommissioningManagerModel.PROP_COMPLETEABLE)) {
                boolean temp = (Boolean) evt.getNewValue();
                confirmButton.setEnabled(temp);
            }
        }
    });
    unitsList.setModel(model.getUnitModel());
    transactionList.setModel(model.getTransactionModel());
}

From source file:fi.elfcloud.client.dialog.UploadDialog.java

@Override
public void propertyChange(PropertyChangeEvent evt) {
    int value;//from   w ww  .  j a  v  a2 s  . c o  m
    if ("totalNumBytesRead" == evt.getPropertyName()) { //$NON-NLS-1$
        task.progress += (Long) evt.getNewValue() - (Long) evt.getOldValue();
        value = (int) ((task.progress.doubleValue() / task.totalLength.doubleValue()) * 100);
        progressBar.setValue(value);
        setTitle(Messages.getString("UploadDialog.window_title_uploading_1") + task.filesSent //$NON-NLS-1$
                + Messages.getString("UploadDialog.window_title_uploading_2") + task.fileCount + " - " //$NON-NLS-1$//$NON-NLS-2$
                + Integer.toString(value) + "%"); //$NON-NLS-1$
    }
    if ("progress" == evt.getPropertyName()) { //$NON-NLS-1$
        int progress = (Integer) evt.getNewValue();
        progressBar.setValue(progress);
        setTitle(Messages.getString("UploadDialog.window_title_uploading_1") + task.filesSent //$NON-NLS-1$
                + Messages.getString("UploadDialog.window_title_uploading_2") + task.fileCount + " - " //$NON-NLS-1$//$NON-NLS-2$
                + Integer.toString(progress) + "%"); //$NON-NLS-1$
    }
}

From source file:uk.ac.gda.client.plotting.ScanDataPlotterComposite.java

private void setupDataSelection() {
    rootDataNode.getChildren().addListChangeListener(new IListChangeListener() {
        @Override//from w w  w.  j a v a  2  s.  c  o m
        public void handleListChange(ListChangeEvent event) {
            event.diff.accept(new ListDiffVisitor() {
                @Override
                public void handleRemove(int index, Object element) {
                    //
                }

                @Override
                public void handleAdd(int index, Object element) {
                    if (clearPlotOnStartOfScan) {
                        for (Object obj : dataTreeViewer.getCheckedElements()) {
                            dataTreeViewer.updateCheckSelection(obj, false);
                        }
                    }
                }
            });
        }
    });
    rootDataNode.addPropertyChangeListener(Node.DATA_ADDED_PROP_NAME, new PropertyChangeListener() {
        @Override
        public void propertyChange(final PropertyChangeEvent evt) {
            Node node = (Node) evt.getNewValue();
            dataTreeViewer.expandToLevel(node.getParent(), AbstractTreeViewer.ALL_LEVELS);
            if (node instanceof LineTraceProviderNode && dataTreeViewer.getChecked(node)) {
                addTrace((LineTraceProviderNode) node);
            }
        }
    });

    rootDataNode.addPropertyChangeListener(Node.SCAN_ADDED_PROP_NAME, new PropertyChangeListener() {
        @Override
        public void propertyChange(final PropertyChangeEvent evt) {
            Node node = (Node) evt.getNewValue();
            dataTreeViewer.setSelection(new StructuredSelection(node), true);
        }
    });

    rootDataNode.addPropertyChangeListener(Node.DATA_CHANGED_PROP_NAME, new PropertyChangeListener() {
        @Override
        public void propertyChange(final PropertyChangeEvent evt) {
            Node node = (Node) evt.getNewValue();
            if (node instanceof LineTraceProviderNode && dataTreeViewer.getChecked(node)) {
                updateTrace((LineTraceProviderNode) node);
            }
        }
    });
}

From source file:de.fhg.fokus.hss.model.Impu.java

/**
 * Method to change property/* ww  w.  j a v a  2 s . co  m*/
 * @param evt Property change event   
 */
public void propertyChange(PropertyChangeEvent evt) {
    super.propertyChange(evt);

    if (evt.getPropertyName().equals("userStatus") && (evt.getOldValue() != null)) {
        changeUserState = true;

        if ((evt.getNewValue().equals(USER_STATUS_NOT_REGISTERED)) && (evt.getOldValue() != null)) {
            deregistered = true;
        }
    } else if (evt.getPropertyName().equals("svp") && (evt.getOldValue() != null)) {
        this.changedSVP = true;
    } else if (evt.getPropertyName().equals("barringIndication") && (evt.getOldValue() != null)) {
        this.changedBarring = true;
    }
}

From source file:edu.ku.brc.specify.config.init.InstSetupPanel.java

/**
 * //from   w w w. j  a va2  s. co m
 */
protected void doCreate() {
    if (isOK == null || !isOK) {
        progressBar.setIndeterminate(true);
        progressBar.setVisible(true);

        setUIEnabled(false);

        label.setText(UIRegistry.getResourceString("CONN_DB"));

        testBtn.setVisible(false);

        SwingWorker<Object, Object> worker = new SwingWorker<Object, Object>() {
            @Override
            protected Object doInBackground() throws Exception {
                isOK = false;
                try {
                    getValues(properties);

                    firePropertyChange(propName, 0, 1);

                    conn = DBConnection.getInstance();

                    AppContextMgr.getInstance().setHasContext(true); // override

                    BuildSampleDatabase bsd = new BuildSampleDatabase();

                    bsd.setSession(HibernateUtil.getCurrentSession());

                    int treeDir = BuildSampleDatabase.getTreeDirForClass(properties, StorageTreeDef.class);

                    isOK = bsd.createEmptyInstitution(properties, false, false, true, treeDir);

                    AppContextMgr.getInstance().setClassObject(DataType.class, bsd.getDataType());

                    HibernateUtil.closeSession();

                    if (!isOK) {
                        errorKey = "BAD_INST";
                        return null;
                    }

                    String userName = properties.getProperty("usrUsername");
                    String password = properties.getProperty("usrPassword");
                    String dbName = properties.getProperty("dbName");

                    firePropertyChange(propName, 0, 2);

                    isOK = tryLogginIn(userName, password, dbName);
                    if (!isOK) {
                        errorKey = "BAD_LOGIN";
                        return null;
                    }

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

                    errorKey = "INST_UNRECOVERABLE";
                }

                return null;
            }

            /* (non-Javadoc)
             * @see javax.swing.SwingWorker#done()
             */
            @Override
            protected void done() {
                super.done();

                progressBar.setIndeterminate(false);
                progressBar.setVisible(false);

                setUIEnabled(true);

                updateBtnUI();

                label.setText(UIRegistry.getResourceString(
                        isOK ? "INST_CREATED" : (errorKey != null ? errorKey : "ERR_CRE_INST")));

                if (isOK) {
                    setUIEnabled(false);
                    prevBtn.setEnabled(false);
                }
            }
        };

        worker.addPropertyChangeListener(new PropertyChangeListener() {
            public void propertyChange(final PropertyChangeEvent evt) {
                if (propName.equals(evt.getPropertyName())) {
                    String key = null;
                    switch ((Integer) evt.getNewValue()) {
                    case 1:
                        key = "CREATING_INST";
                        break;
                    case 2:
                        key = "LOGIN_USER";
                        break;
                    default:
                        break;
                    }
                    if (key != null) {
                        InstSetupPanel.this.label.setText(UIRegistry.getResourceString(key));
                    }
                }
            }
        });
        worker.execute();
    }
}

From source file:com.emr.mappings.MappingsForm.java

/**
 * Creates new form MappingsForm//  w  w  w.  j  a va 2  s .  c  o m
 * SQliteDataLoadWorker is a SwingWorker that fetches the saved mappings from the sqlite database,
 * and populates this to the mappings table
 * 
 */
public MappingsForm() {
    //model=new DefaultTableModel(new Object[]{"Source Value","Map To"}, 25);

    final SQliteDataLoadWorker dl = new SQliteDataLoadWorker(tblMappings,
            "select sourceValue,dataMapping from mappings");
    dl.addPropertyChangeListener(new PropertyChangeListener() {

        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 {
                        model = dl.get();
                        tblMappings.setModel(model);
                    } 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;
            }
        }

    });
    dl.execute();
    initComponents();
    //todo: get already added mappings and use their count to initilize model
    this.setClosable(true);

    /*TextBoxTableCellEditor sourceValEditor=new TextBoxTableCellEditor(new JTextField());
    tblMappings.getColumnModel().getColumn(0).setCellEditor(sourceValEditor);
    TextBoxTableCellEditor mappingValEditor=new TextBoxTableCellEditor(new JTextField());
    tblMappings.getColumnModel().getColumn(1).setCellEditor(mappingValEditor);*/
}

From source file:org.fourthline.cling.model.gena.LocalGENASubscription.java

/**
 * Moderates {@link org.fourthline.cling.model.ServiceManager#EVENTED_STATE_VARIABLES} events and state variable
 * values, calls {@link #eventReceived()}.
 *//*ww w . j  ava2  s .co m*/
synchronized public void propertyChange(PropertyChangeEvent e) {
    if (!e.getPropertyName().equals(ServiceManager.EVENTED_STATE_VARIABLES))
        return;

    log.fine("Eventing triggered, getting state for subscription: " + getSubscriptionId());

    long currentTime = new Date().getTime();

    Collection<StateVariableValue> newValues = (Collection) e.getNewValue();
    Set<String> excludedVariables = moderateStateVariables(currentTime, newValues);

    // Map<String, StateVariableValue> oldValues = currentValues;
    currentValues.clear();
    for (StateVariableValue newValue : newValues) {
        String name = newValue.getStateVariable().getName();
        if (!excludedVariables.contains(name)) {
            log.fine("Adding state variable value to current values of event: " + newValue.getStateVariable()
                    + " = " + newValue);
            currentValues.put(newValue.getStateVariable().getName(), newValue);

            // Preserve "last sent" state for future moderation
            lastSentTimestamp.put(name, currentTime);
            if (newValue.getStateVariable().isModeratedNumericType()) {
                lastSentNumericValue.put(name, Long.valueOf(newValue.toString()));
            }
        }
    }

    if (currentValues.size() > 0) {
        log.fine("Propagating new state variable values to subscription: " + this);
        // TODO: I'm not happy with this design, this dispatches to a separate thread which _then_
        // is supposed to lock and read the values off this instance. That obviously doesn't work
        // so it's currently a hack in SendingEvent.java
        eventReceived();
    } else {
        log.fine("No state variable values for event (all moderated out?), not triggering event");
    }
}

From source file:org.kalypso.ui.wizard.shape.ImportShapeFileImportPage.java

private WorkspaceFileBinding createStyleFileControls(final Composite parent) {
    final Label styleLabel = new Label(parent, SWT.NONE);
    styleLabel.setText(Messages.getString("org.kalypso.ui.wizard.shape.ImportShapeFileImportPage.6")); //$NON-NLS-1$

    final IObservableValue modelFile = BeansObservables.observeValue(m_data.getStyleFile(),
            FileAndHistoryData.PROPERTY_PATH);
    final IObservableValue modelHistory = BeansObservables.observeValue(m_data.getStyleFile(),
            FileAndHistoryData.PROPERTY_HISTORY);

    final String dialogMessage = Messages.getString("org.kalypso.ui.wizard.shape.ImportShapeFileImportPage.14"); //$NON-NLS-1$
    final String[] extensions = new String[] { "sld" }; //$NON-NLS-1$

    final WorkspaceFileBinding fileBinding = new WorkspaceFileBinding(m_binding, modelFile, dialogMessage,
            extensions);// www.  j  av a  2s . c o m
    fileBinding.setInputContainer(m_project);

    final Control fileField = fileBinding.createFileFieldWithHistory(parent, modelHistory);
    fileField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));

    final Button searchButton = fileBinding.createFileSearchButton(parent);

    /* file is optional iff import type is 'existing' */
    fileBinding.setIsOptional(m_data.getStyleImportType() != StyleImport.selectExisting);

    // final DataBindingContext bindingContext = m_binding.getBindingContext();
    m_data.addPropertyChangeListener(ImportShapeFileData.PROPERTY_STYLE_IMPORT_TYPE,
            new PropertyChangeListener() {
                @Override
                public void propertyChange(final PropertyChangeEvent evt) {
                    final IObservableValue validationStatus = fileBinding.getFileBinding()
                            .getValidationStatus();

                    fileBinding.setIsOptional(evt.getNewValue() != StyleImport.selectExisting);

                    // If style file is currently bad, clear it now, else the error message remains
                    final IStatus value = (IStatus) validationStatus.getValue();
                    if (value != null && !value.isOK() && evt.getNewValue() != StyleImport.selectExisting)
                        modelFile.setValue(null);

                    // we need to force revalidation here, but how...?!
                    fileBinding.getFileBinding().validateTargetToModel();
                }
            });

    /* Enablement */
    final IObservableValue modelEnablement = BeansObservables.observeValue(m_data,
            ImportShapeFileData.PROPERTY_STYLE_CONTROLS_ENABLED);

    final IObservableValue targetLabelEnablement = SWTObservables.observeEnabled(styleLabel);
    m_binding.bindValue(targetLabelEnablement, modelEnablement);

    final IObservableValue targetFieldEnablement = SWTObservables.observeEnabled(fileField);
    m_binding.bindValue(targetFieldEnablement, modelEnablement);

    final IObservableValue targetButtonEnablement = SWTObservables.observeEnabled(searchButton);
    m_binding.bindValue(targetButtonEnablement, modelEnablement);

    return fileBinding;
}

From source file:edu.ku.brc.specify.plugins.LocalityGoogleEarthPlugin.java

@Override
public void propertyChange(PropertyChangeEvent evt) {
    if (evt.getPropertyName().equals("latlon")) {
        Object obj = evt.getNewValue();
        if (obj instanceof Pair<?, ?>) {
            latLon = latLonPlugin.getLatLon();
            isLatLonOK = latLon != null && latLon.first != null && latLon.second != null
                    && latLonPlugin.getState() == ErrorType.Valid;
            setEnabled(isLatLonOK);/*from  w  w  w  .j a  va 2 s. c o m*/
        }
    }
}

From source file:org.openmicroscopy.shoola.agents.metadata.editor.OriginalMetadataComponent.java

/**
 * Downloads the original file.//from   w  w w . j  a  v a 2s . co m
 * @see PropertyChangeListener#propertyChange(PropertyChangeEvent)
 */
public void propertyChange(PropertyChangeEvent evt) {
    String name = evt.getPropertyName();
    if (FileChooser.APPROVE_SELECTION_PROPERTY.equals(name)) {
        File[] files = (File[]) evt.getNewValue();
        File folder = files[0];
        if (folder == null)
            folder = UIUtilities.getDefaultFolder();
        UserNotifier un = MetadataViewerAgent.getRegistry().getUserNotifier();
        ImageData img = model.getImage();
        if (img == null)
            return;
        IconManager icons = IconManager.getInstance();
        DownloadActivityParam activity = new DownloadActivityParam(img.getId(),
                DownloadActivityParam.METADATA_FROM_IMAGE, folder, icons.getIcon(IconManager.DOWNLOAD_22));
        un.notifyActivity(model.getSecurityContext(), activity);
    }
}