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:edu.ku.brc.specify.tasks.WebSearchTask.java

/**
 * @param fileName/*from   w  w w . ja v a 2 s .  c  om*/
 */
private void startCompression(final String fileName) {
    if (StringUtils.isNotEmpty(fileName)) {
        try {
            final File file = File.createTempFile("Bkup", ".gz");
            final HttpLargeFileTransfer httpFileTransfer = new HttpLargeFileTransfer();

            httpFileTransfer.compressFile(fileName, file.getAbsolutePath(), new PropertyChangeListener() {
                @Override
                public void propertyChange(PropertyChangeEvent evt) {
                    if (evt.getPropertyName().equals("Done")) {
                        startUpload(httpFileTransfer, false, file);
                    }
                }
            });
        } catch (IOException e) {
            // TODO Auto-generated catch block
        }
    }
}

From source file:org.polymap.core.mapeditor.tooling.edit.SnapTool.java

/**
 * Called when selected layer of parent tool has changed.
 *///from ww  w. jav  a2s.  co  m
@Override
public void propertyChange(PropertyChangeEvent ev) {
    if (ev.getPropertyName().equals(BaseLayerEditorTool.PROP_LAYER_ACTIVATED)) {
        onDeactivate();
        onActivate();
    }
}

From source file:blue.mixer.EffectsChain.java

public void propertyChange(PropertyChangeEvent evt) {
    if (evt.getPropertyName().equals("sendChannel")) {
        Object obj = evt.getSource();

        int index = ListUtil.indexOfByRef(effects, obj);

        if (index >= 0) {
            ListDataEvent lde = new ListDataEvent(this, ListDataEvent.CONTENTS_CHANGED, index, index);

            fireContentsChangedEvent(lde);
        }//from  w w  w .java  2s  .c om
    }
}

From source file:org.openmicroscopy.shoola.agents.treeviewer.actions.DownloadAction.java

/**
 * Downloads the selected files.//from  ww w  .  ja  v  a 2  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:ui.panel.UIBucketSelect.java

public void runBucketSelect() {
    Panel p = new Panel();
    Button b = new Button();
    Label l = new Label();

    setLayout(new BorderLayout());

    JPanel pnlInstruction = p.createPanel(Layouts.flow);
    JLabel lblInstruction = l.createLabel("Bucket List");
    pnlInstruction.setBackground(CustomColor.LightBlue.returnColor());
    lblInstruction.setForeground(Color.white);
    lblInstruction.setFont(new Font("San Serif", Font.PLAIN, 18));
    pnlInstruction.add(lblInstruction);/*from w ww .ja va2s  .  c o  m*/

    JPanel pnlBucketList = p.createPanel(Layouts.border);

    listBucket.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    JScrollPane scrollBucket = new JScrollPane(listBucket);
    scrollBucket.setPreferredSize(new Dimension(300, 150));
    pnlBucketList.add(scrollBucket, BorderLayout.CENTER);

    JPanel pnlButtons = p.createPanel(Layouts.flow);
    JButton btnBack = b.createButton("Back");
    JButton btnSelectElements = b.createButton("Next");
    JButton btnRefresh = b.createButton("Refresh Bucket List");

    pnlButtons.add(btnBack);
    pnlButtons.add(btnRefresh);
    pnlButtons.add(btnSelectElements);

    add(pnlInstruction, BorderLayout.NORTH);
    add(pnlBucketList, BorderLayout.CENTER);
    add(pnlButtons, BorderLayout.SOUTH);
    setVisible(true);

    btnRefresh.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            getBucketData();
        }
    });
    btnSelectElements.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            SwingWorker<Void, Void> mySwingWorker = new SwingWorker<Void, Void>() {
                @Override
                protected Void doInBackground() throws Exception {

                    int selected = listBucket.getSelectedRow();
                    if (selected == -1) {
                        JOptionPane.showMessageDialog(Data.mainFrame, "Please Select a Bucket", "Error",
                                JOptionPane.ERROR_MESSAGE);
                    } else {
                        Data.bucketID = (int) listBucket.getModel().getValueAt(selected, 0);
                        Data.mainFrame.addPanel(Data.mainFrame.uiLicenseDetail = new UILicenseDetail(),
                                "license");
                        Data.mainFrame.pack();
                        Data.mainFrame.showPanel("license");
                    }
                    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 Licenses......."), BorderLayout.PAGE_START);
            dialog.add(panel);
            dialog.pack();
            dialog.setBounds(50, 50, 300, 100);
            dialog.setLocationRelativeTo(Data.mainFrame);
            dialog.setVisible(true);
        }
    });
    btnBack.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            setVisible(false);
            Data.mainFrame.showPanel("inventory");
        }
    });
}

From source file:mulavito.gui.components.LayerDataPanel.java

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

    textArea = new JTextArea(defaultText);
    textArea.setEditable(false);//ww w. ja v  a 2s .c om
    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.fourthline.cling.model.gena.LocalGENASubscription.java

/**
 * Moderates {@link org.fourthline.cling.model.ServiceManager#EVENTED_STATE_VARIABLES} events and state variable
 * values, calls {@link #eventReceived()}.
 *///from  ww w .j  a v  a  2 s .c o 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.jcurl.core.api.PropertyChangeSupport.java

public void firePropertyChange(final PropertyChangeEvent event) {
    // log.debug(event);
    validateNamedProperty(event.getPropertyName());
    {/*  w w  w.  ja v  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.talend.repository.generic.ui.GenericConnWizardPage.java

@Override
public void propertyChange(PropertyChangeEvent event) {
    String propertyName = event.getPropertyName();
    if (IElementParameterEventProperties.EVENT_PROPERTY_NAME_CHANGED.equals(propertyName)) {
        String newPropertyName = String.valueOf(event.getNewValue());
        updateProperty(newPropertyName);
    }/*from  w w w .  ja v a  2s .  c om*/
}

From source file:joachimeichborn.geotag.model.Geocoding.java

@Override
public void propertyChange(final PropertyChangeEvent aEvent) {
    propertyChangeSupport.firePropertyChange(aEvent.getPropertyName(), aEvent.getOldValue(),
            aEvent.getNewValue());//from   ww  w.  j a  va 2s  .com
}