Example usage for java.beans PropertyChangeEvent getSource

List of usage examples for java.beans PropertyChangeEvent getSource

Introduction

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

Prototype

public Object getSource() 

Source Link

Document

The object on which the Event initially occurred.

Usage

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

/**
 * Downloads the selected files./*from   www.  j  ava 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: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   ww  w.  j av  a2 s.c om
    }
}

From source file:org.polymap.p4.fs.WorkbenchState.java

protected void handleEvent(PropertyChangeEvent ev) {
    log.debug("Event: " + ev);
    log.debug("my session: " + SessionContext.current());
    log.debug("publish session: " + EventManager.publishSession());

    map = new WeakReference(ev.getSource());
    mapModified = new Date();

    //getSite().invalidateFolder( getSite().getFolder( new Path( "/Workbench" ) ) );
}

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

public void propertyChange(PropertyChangeEvent arg0) {
    if (arg0.getSource() == wsdlOperation) {
        if (arg0.getPropertyName().equals(Operation.NAME_PROPERTY)) {
            requestStepConfig.setOperation((String) arg0.getNewValue());
        }/*www  .jav a 2s. com*/
    } else if (arg0.getSource() == wsdlOperation.getInterface()) {
        if (arg0.getPropertyName().equals(Interface.NAME_PROPERTY)) {
            requestStepConfig.setInterface((String) arg0.getNewValue());
        }
    } else {
        notifyPropertyChanged(arg0.getPropertyName(), arg0.getOldValue(), arg0.getNewValue());
    }
}

From source file:net.chaosserver.timelord.swingui.TaskDayPanel.java

/**
 * Listens from property changes on the TaskName or TaskDay and triggers
 * updates to the UI./*  w ww.  j av a  2s. com*/
 *
 * @param evt the property event
 */
public void propertyChange(PropertyChangeEvent evt) {
    if (evt.getSource().equals(getTodayTaskDay())) {
        if ("note".equals(evt.getPropertyName())) {
            updateTaskNameLabel();
        } else if ("hours".equals(evt.getPropertyName())) {
            enabledButtons();
        }
    } else if (evt.getSource().equals(getTimelordTask())) {
        if ("taskName".equals(evt.getPropertyName())) {
            updateTaskNameLabel();
        }
    }
}

From source file:org.polymap.core.mapeditor.NavigationHistory.java

public NavigationHistory(MapEditor mapEditor) {
    this.mapEditor = mapEditor;
    this.context = new ObjectUndoContext(this, "Navigation Context");
    this.history = new DefaultOperationHistory();
    //        approver = new AdvancedValidationUserApprover( context );
    //        history.addOperationApprover( approver );
    this.history.setLimit(context, 10);

    mapEditor.getMap().addPropertyChangeListener(this, new EventFilter<PropertyChangeEvent>() {
        public boolean apply(PropertyChangeEvent ev) {
            String name = ev.getPropertyName();
            return !ignoreEvents && NavigationHistory.this.mapEditor != null
                    && NavigationHistory.this.mapEditor.getMap().equals(ev.getSource())

            // XXX the extent events are often followed by an update
            // event with different extent (diskrete scales); processing just
            // the update event solves this but we are potentially loosing
            // map extent chnages
                    && (IMap.PROP_EXTENT.equals(name) || IMap.PROP_EXTENT_UPDATE.equals(name));
        }/*from w  w  w.j av  a2s .c o m*/
    });
}

From source file:org.jcurl.demo.tactics.sg.BroomPromptScenario.java

public void propertyChange(final PropertyChangeEvent evt) {
    if (evt.getSource() == model) {
        if ("idx16".equals(evt.getPropertyName()))
            syncIndexM2V((Integer) evt.getNewValue(), pie);
        else if ("outTurn".equals(evt.getPropertyName()))
            syncHandleM2V((Boolean) evt.getNewValue(), handle);
        else if ("broom".equals(evt.getPropertyName()))
            syncBroomM2V((Point2D) evt.getNewValue(), scene);
        else if ("splitTimeMillis".equals(evt.getPropertyName())) {
            final BoundedRangeModel os = (BoundedRangeModel) evt.getOldValue();
            if (os != null)
                os.removeChangeListener(this);
            final BoundedRangeModel ns = (BoundedRangeModel) evt.getNewValue();
            if (ns != null)
                ns.addChangeListener(this);
            syncSpeedM2V(ns);// ww  w .  j  av  a2 s.  c  o m
        } else
            log.info(evt.getPropertyName() + " " + evt.getSource());
    } else
        log.warn("Unconsumed event from " + evt.getSource());
}

From source file:org.mwc.cmap.LiveDataMonitor.views.LiveDataMonitor.java

/**
 * The constructor./*from   w  w  w .  j a v  a2s  .  c  o m*/
 */
public LiveDataMonitor() {
    _attListener = new PropertyChangeListener() {
        public void propertyChange(final PropertyChangeEvent evt) {
            // aah, is this for the scenario we're watching
            if (_myIndexedAttr != null)
                if (evt.getSource() == _myIndexedAttr.index) {

                    final DataDoublet newD = (DataDoublet) evt.getNewValue();
                    final long time = newD.getTime();
                    final Object newValue = newD.getValue();
                    if (newValue instanceof Number) {
                        final Number value = (Number) newValue;

                        // and store it
                        final TimeSeriesCollection coll = (TimeSeriesCollection) _chart.getXYPlot()
                                .getDataset();

                        TimeSeries tmpSeries;

                        if (coll == null) {
                            final TimeSeriesCollection dataset = new TimeSeriesCollection();
                            tmpSeries = new TimeSeries(_watchedAttr.getName());
                            dataset.addSeries(tmpSeries);
                            // add to series in different thread...
                            Display.getDefault().asyncExec(new Runnable() {
                                public void run() {
                                    _chart.getXYPlot().setDataset(dataset);
                                }
                            });
                        } else {
                            tmpSeries = coll.getSeries(0);
                        }

                        final TimeSeries series = tmpSeries;

                        // add to series in current thread, accepting it will slow down
                        // the
                        // UI
                        Display.getDefault().syncExec(new Runnable() {
                            public void run() {
                                // are we still open?i
                                if (!_chartFrame.isDisposed()) {
                                    // sure, go for it,
                                    series.addOrUpdate(new Millisecond(new Date(time)), value);
                                }
                            }
                        });
                    }
                }
        }
    };
}

From source file:de.tbuchloh.kiskis.gui.treeview.TreeView.java

@Override
public void propertyChange(final PropertyChangeEvent evt) {
    final Object src = evt.getSource();
    LOG.debug("TreeView - property changed object=" + src);
    if (src instanceof MyTreeNode) {
        // We have to force repaint with selecting another node and
        // reselecting the current one

        final MyTreeNode n = (MyTreeNode) src;
        display(getRoot());//from   w w w . j a v  a2  s  .com
        display(n);
        invalidate();
        repaint();
    }
}

From source file:org.eclipsetrader.kdb.internal.core.connector.SnapshotConnector.java

@Override
public void propertyChange(PropertyChangeEvent evt) {
    if (evt.getSource() instanceof IFeedIdentifier) {
        IFeedIdentifier identifier = (IFeedIdentifier) evt.getSource();
        synchronized (symbolSubscriptions) {
            for (FeedSubscription subscription : symbolSubscriptions.values()) {
                if (subscription.getIdentifier() == identifier) {
                    symbolSubscriptions.remove(subscription.getIdentifierType().getSymbol());
                    IdentifierType identifierType = IdentifiersList.getInstance().getIdentifierFor(identifier);
                    subscription.setIdentifierType(identifierType);
                    symbolSubscriptions.put(identifierType.getSymbol(), subscription);
                    setSubscriptionsChanged(true);
                    break;
                }// w  ww .  jav  a 2s .  co m
            }
        }
    }
}