Example usage for java.beans PropertyChangeEvent getPropertyName

List of usage examples for java.beans PropertyChangeEvent getPropertyName

Introduction

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

Prototype

public String getPropertyName() 

Source Link

Document

Gets the programmatic name of the property that was changed.

Usage

From source file:org.polymap.rhei.batik.dashboard.Dashboard.java

@EventHandler
protected void onSitePropertyChange(PropertyChangeEvent ev) {
    if (!isDisposed()) {
        if (ev.getPropertyName().equals("title")) {
            log.warn("!!! Dashlet TITLE changed! !!!");
        }/*w  w  w  .ja  v a2  s.  com*/
    }
}

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());/* w  w w  . ja v a 2s.  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();
}

From source file:net.landora.video.manager.ManagerFrame.java

private void contentPanelPropertyChanged(ContentPanel panel, PropertyChangeEvent evt) {
    if (evt.getPropertyName().equals(ContentPanel.PROP_CURRENTCONTEXT)) {
        checkContext();/*from  w w  w .  j a  v  a 2s . com*/
    }
}

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   w w  w  .ja  va 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:org.eclipse.php.composer.api.entities.AbstractJsonObject.java

private void installListener(final String property, JsonEntity entity) {
    if (entity != null) {
        listeners.put(property, new PropertyChangeListener() {
            public void propertyChange(PropertyChangeEvent evt) {
                firePropertyChange(property + "." + evt.getPropertyName(), evt.getOldValue(), //$NON-NLS-1$
                        evt.getNewValue());
            }/*  ww  w .j a v a  2s  .co m*/
        });

        entity.addPropertyChangeListener(listeners.get(property));
    }
}

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 a  v a2  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.yccheok.jstock.gui.analysis.OperatorFigure.java

public void propertyChange(java.beans.PropertyChangeEvent propertyChangeEvent) {
    if (propertyChangeEvent.getPropertyName().equals("value")) {
        this.setValue("" + propertyChangeEvent.getNewValue());
    } else if (propertyChangeEvent.getPropertyName().equals("attribute")) {
        this.setAttribute("" + propertyChangeEvent.getNewValue());
    } else {/*w  ww . j a  v a  2s  . com*/
        log.error("Unknown property change : " + propertyChangeEvent.getPropertyName());
    }
}

From source file:org.jboss.tools.openshift.internal.ui.wizard.newapp.fromimage.ApplicationSourceFromImageModel.java

@SuppressWarnings("unchecked")
@Override//from  ww  w.jav a  2 s  .c o m
public void propertyChange(PropertyChangeEvent evt) {
    if (evt == null)
        return;
    super.propertyChange(evt);
    switch (evt.getPropertyName()) {
    case IResourceLabelsPageModel.PROPERTY_LABELS:
        setLabels((List<Label>) evt.getNewValue());
        break;
    case IApplicationSourceListPageModel.PROPERTY_SELECTED_APP_SOURCE:
        handleSelectedAppSource(evt);
        break;
    case IApplicationSourceListPageModel.PROPERTY_PROJECT:
        setProject((IProject) evt.getNewValue());
        break;
    case IApplicationSourceListPageModel.PROPERTY_ECLIPSE_PROJECT:
        handleEclipseProject(evt);
        break;
    }
}

From source file:org.photovault.swingui.framework.AbstractController.java

/**
 * Register an action that can be executed by this controller.
 *
 * @param source The source component, this method sets action command and registers the controller as listener.
 * @param actionCommand The action command, used as a key when registering and executing actions.
 * @param action An actual action implementation.
 *//*from  w  w w .java2 s  .c  o  m*/
public void registerAction(AbstractButton source, String actionCommand, DefaultAction action) {
    source.setActionCommand(actionCommand);
    source.addActionListener(this);
    this.actions.put(actionCommand, action);
    final String cmd = actionCommand;
    final AbstractController ctrl = this;
    // TODO: Is this really needed???
    action.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName().equals("enabled")) {
                fireEvent(new ActionStateChangeEvent(ctrl, cmd, (Boolean) evt.getNewValue()));
            }
        }

    });
}

From source file:ui.frame.UILogin.java

public UILogin() {
    super("Login");

    Label l = new Label();

    setLayout(new BorderLayout());
    this.setPreferredSize(new Dimension(400, 300));

    Panel p = new Panel();

    loginPanel = p.createPanel(Layouts.grid, 4, 2);
    loginPanel.setBorder(new EmptyBorder(25, 25, 0, 25));
    lblUser = l.createLabel("Username:");
    lblPassword = l.createLabel("Password:");
    lblURL = l.createLabel("Server URL");
    lblBucket = l.createLabel("Bucket");

    tfURL = new JTextField();
    tfURL.setText("kaiup.kaisquare.com");
    tfBucket = new JTextField();
    PromptSupport.setPrompt("BucketName", tfBucket);
    tfUser = new JTextField();
    PromptSupport.setPrompt("Username", tfUser);
    pfPassword = new JPasswordField();
    PromptSupport.setPrompt("Password", pfPassword);

    buttonPanel = p.createPanel(Layouts.flow);
    buttonPanel.setBorder(new EmptyBorder(0, 0, 25, 0));
    Button b = new Button();
    JButton btnLogin = b.createButton("Login");
    JButton btnExit = b.createButton("Exit");
    btnLogin.setPreferredSize(new Dimension(150, 50));
    btnExit.setPreferredSize(new Dimension(150, 50));
    Component[] arrayBtn = { btnExit, btnLogin };
    p.addComponentsToPanel(buttonPanel, arrayBtn);

    Component[] arrayComponents = { lblURL, tfURL, lblBucket, tfBucket, lblUser, tfUser, lblPassword,
            pfPassword };/*from   w  ww  .j av a  2 s .  co  m*/
    p.addComponentsToPanel(loginPanel, arrayComponents);
    add(loginPanel, BorderLayout.CENTER);
    add(buttonPanel, BorderLayout.SOUTH);
    pack();
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    setLocationRelativeTo(null);

    setVisible(true);
    btnLogin.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {

            SwingWorker<Void, Void> mySwingWorker = new SwingWorker<Void, Void>() {
                @Override
                protected Void doInBackground() throws Exception {
                    if (tfUser.getText().equals("") || String.valueOf(pfPassword.getPassword()).equals("")
                            || tfBucket.getText().equals("")) {
                        JOptionPane.showMessageDialog(Data.mainFrame, "Please fill up all the fields", "Error",
                                JOptionPane.ERROR_MESSAGE);
                    } else {
                        String username = tfUser.getText();
                        String password = String.valueOf(pfPassword.getPassword());
                        Data.URL = Data.protocol + tfURL.getText();
                        Data.targetURL = Data.protocol + tfURL.getText() + "/api/" + tfBucket.getText() + "/";

                        String response = api.loginBucket(Data.targetURL, username, password);

                        try {

                            if (DesktopAppMain.checkResult(response)) {
                                JSONObject responseJSON = new JSONObject(response);
                                Data.sessionKey = responseJSON.get("session-key").toString();
                                response = api.getUserFeatures(Data.targetURL, Data.sessionKey);
                                if (checkFeatures(response)) {
                                    Data.mainFrame = new KAIQRFrame();
                                    Data.mainFrame.uiInventorySelect = new UIInventorySelect();
                                    Data.mainFrame.addPanel(Data.mainFrame.uiInventorySelect, "inventory");
                                    Data.mainFrame.showPanel("inventory");
                                    Data.mainFrame.pack();
                                    setVisible(false);
                                    Data.mainFrame.setVisible(true);

                                } else {
                                    JOptionPane.showMessageDialog(Data.loginFrame,
                                            "User does not have necessary features", "Error",
                                            JOptionPane.ERROR_MESSAGE);
                                }
                            } else {
                                JOptionPane.showMessageDialog(Data.loginFrame, "Wrong username/password",
                                        "Error", JOptionPane.ERROR_MESSAGE);
                            }

                        } catch (JSONException e1) {
                            e1.printStackTrace();
                        }
                    }

                    return null;
                }
            };

            Window win = SwingUtilities.getWindowAncestor((AbstractButton) e.getSource());
            final JDialog dialog = new JDialog(win, "Login", 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("Logging in .........."), BorderLayout.PAGE_START);
            dialog.add(panel);
            dialog.pack();
            dialog.setBounds(50, 50, 300, 100);
            dialog.setLocationRelativeTo(Data.mainFrame);
            dialog.setVisible(true);
        }
    });

    btnExit.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            System.exit(0);
        }

    });

}