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.polymap.core.mapeditor.tooling.select.LayerSelectableDecorator.java

public void propertyChange(PropertyChangeEvent ev) {
    if (ev.getSource() instanceof SelectionTool) {
        ILayer layer = (ILayer) ev.getNewValue();

        if (ev.getPropertyName().equals(SelectionTool.PROP_LAYER_ACTIVATED)) {
            selectableLayerIds.add(layer.id());
        } else if (ev.getPropertyName().equals(SelectionTool.PROP_LAYER_DEACTIVATED)) {
            selectableLayerIds.remove(layer.id());
        }/* ww  w.ja va2 s  .c o  m*/

        Runnable runnable = new Runnable() {
            public void run() {
                // prevent deadlock on close
                if (!PlatformUI.getWorkbench().isClosing()) {
                    fireLabelProviderChanged(new LabelProviderChangedEvent(LayerSelectableDecorator.this));
                }
            }
        };
        if (Display.getCurrent() != null) {
            runnable.run();
        } else {
            Polymap.getSessionDisplay().asyncExec(runnable);
        }
    }
}

From source file:picocash.models.table.AccountTableModel.java

@Override
public void propertyChange(PropertyChangeEvent evt) {
    int index = accounts.indexOf((Account) evt.getSource());
    fireTableRowsUpdated(index, index);// w w  w  . java2 s.  co  m
}

From source file:org.polymap.core.project.ui.layer.LayerVisibleStatusAction.java

public void init(IViewPart view) {
    ProjectRepository.instance().addEntityListener(this, new EventFilter<PropertyChangeEvent>() {
        public boolean apply(PropertyChangeEvent ev) {
            return ev.getPropertyName().equals(ILayer.PROP_VISIBLE) && ev.getSource() instanceof ILayer
                    && layers.contains(ev.getSource());
        }/*from  w  w  w .j  a v  a 2s.c  om*/
    });
}

From source file:org.jcurl.mr.gui.BroomPanel0.java

public void propertyChange(final PropertyChangeEvent arg0) {
    log.debug(arg0);/*from w  w  w. j ava  2 s.  co m*/
    if (model == arg0.getSource())
        if ("broomX".equals(arg0.getPropertyName())) {
            final Measure raw = (Measure) arg0.getNewValue();
            final Measure val;
            if (raw.unit == Unit.NONE)
                val = new Measure(raw.value, dim);
            else
                val = raw.to(dim);
            slider.setValue((int) (val.value * Granularity));
            text.setText(val.toString());
        }
}

From source file:org.polymap.core.project.ui.project.MapVisibleStatusAction.java

public void init(IViewPart view) {
    ProjectRepository.instance().addEntityListener(this, new EventFilter<PropertyChangeEvent>() {
        public boolean apply(PropertyChangeEvent ev) {
            return ev.getPropertyName().equals(IMap.PROP_VISIBLE) && ev.getSource() instanceof IMap
                    && selected.contains(ev.getSource());
        }//from  w w  w.  ja v  a  2  s.c  o  m
    });
}

From source file:de.unentscheidbar.validation.swing.trigger.DocumentChangeTrigger.java

@Override
public void propertyChange(PropertyChangeEvent evt) {

    if (evt.getSource() instanceof JComponent) {
        JComponent src = (JComponent) evt.getSource();
        forgetDocument((Document) evt.getOldValue(), src);
        observeDocument(src);//w  w  w. j a v a 2 s.  com
    } else {
        /* JComponent correctly reports itself as the event source, so this should never happen */
        throw new IllegalStateException("Received a PropertyChangeEvent with unexpected source type: "
                + ClassUtils.getSimpleName(evt.getSource(), "NULL"));
    }
}

From source file:de.tudarmstadt.ukp.clarin.webanno.webapp.standalone.StandaloneShutdownDialog.java

private void displayShutdownDialog() {
    String serverId = ServerDetector.getServerId();
    log.info("Running in: " + (serverId != null ? serverId : "unknown server"));
    log.info("Console: " + ((System.console() != null) ? "available" : "not available"));
    log.info("Headless: " + (GraphicsEnvironment.isHeadless() ? "yes" : "no"));

    // Show this only when run from the standalone JAR via a double-click
    if (System.console() == null && !GraphicsEnvironment.isHeadless() && ServerDetector.isWinstone()) {
        log.info("If you are running WebAnno in a server environment, please use '-Djava.awt.headless=true'");

        EventQueue.invokeLater(new Runnable() {
            @Override/*from  w  w  w .  j  a v  a  2 s .  c  o  m*/
            public void run() {
                final JOptionPane optionPane = new JOptionPane(new JLabel(
                        "<HTML>WebAnno is running now and can be accessed via <a href=\"http://localhost:8080\">http://localhost:8080</a>.<br>"
                                + "WebAnno works best with the browsers Google Chrome or Safari.<br>"
                                + "Use this dialog to shut WebAnno down.</HTML>"),
                        JOptionPane.INFORMATION_MESSAGE, JOptionPane.OK_OPTION, null,
                        new String[] { "Shutdown" });

                final JDialog dialog = new JDialog((JFrame) null, "WebAnno", true);
                dialog.setContentPane(optionPane);
                dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
                dialog.addWindowListener(new WindowAdapter() {
                    @Override
                    public void windowClosing(WindowEvent we) {
                        // Avoid closing window by other means than button
                    }
                });
                optionPane.addPropertyChangeListener(new PropertyChangeListener() {
                    @Override
                    public void propertyChange(PropertyChangeEvent aEvt) {
                        if (dialog.isVisible() && (aEvt.getSource() == optionPane)
                                && (aEvt.getPropertyName().equals(JOptionPane.VALUE_PROPERTY))) {
                            System.exit(0);
                        }
                    }
                });
                dialog.pack();
                dialog.setVisible(true);
            }
        });
    } else {
        log.info("Running in server environment or from command line: disabling interactive shutdown dialog.");
    }
}

From source file:gda.gui.text.parameter.EpicsPanelParameterListener.java

/**
 * @param e/*from   w  ww.  j  av  a2 s .  c om*/
 * @throws PropertyVetoException
 */
public void vetoableChangeinNewThread(PropertyChangeEvent e) throws PropertyVetoException {
    Object source = e.getSource();
    if (source == null)
        throw new IllegalArgumentException("ParametersPanelListener.propertyChange - source == null ");

    if (source instanceof ParametersPanelBuilder.ParameterChangeEventSource) {

        Object newObject = e.getNewValue();
        if ((newObject == null) || !(newObject instanceof Double)) {
            throw new IllegalArgumentException(
                    "ParametersPanelListener.propertyChange -  (newObject == null ) || !(newObject instanceof Limited) ");
        }

        if (epicsChannel != null) {
            try {
                Double newVal = (Double) newObject;

                if (converter != null)
                    newVal = converter.convertValue(newVal);

                if (lastSuccessfullySentValue == null || (lastSuccessfullySentValue.compareTo(newVal) != 0)) {
                    epicsChannel.setValue(newVal);
                    lastSuccessfullySentValue = newVal;
                }
            } catch (DeviceException expt) {
                logger.error(expt.getMessage());
                throw new PropertyVetoException(expt.getMessage(), e);
            }
        } else {
            throw new IllegalArgumentException("EpicsPanelParameterListener: epicsChannel == null");
        }
    }
}

From source file:FormatterFactoryDemo.java

/** Called when a field's "value" property changes. */
public void propertyChange(PropertyChangeEvent e) {
    Object source = e.getSource();
    if (source == amountField) {
        amount = ((Number) amountField.getValue()).doubleValue();
    } else if (source == rateField) {
        rate = ((Number) rateField.getValue()).doubleValue();
    } else if (source == numPeriodsField) {
        numPeriods = ((Number) numPeriodsField.getValue()).intValue();
    }/*from  w ww  .j ava  2s  .c o m*/

    double payment = computePayment(amount, rate, numPeriods);
    paymentField.setValue(new Double(payment));
}

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

public void propertyChange(PropertyChangeEvent ev) {
    boolean changed = false;

    // edit/*from w ww  .  j  av a  2s . c  o  m*/
    if (ev.getSource() instanceof EditTool) {
        ILayer layer = (ILayer) ev.getNewValue();

        if (ev.getPropertyName().equals(EditTool.PROP_LAYER_ACTIVATED)) {
            changed = editableLayerIds.add(layer.id());
        } else if (ev.getPropertyName().equals(EditTool.PROP_LAYER_DEACTIVATED)) {
            changed = editableLayerIds.remove(layer.id());
        }
    }
    // digitize
    else if (ev.getSource() instanceof DigitizeTool) {
        ILayer layer = (ILayer) ev.getNewValue();

        if (ev.getPropertyName().equals(EditTool.PROP_LAYER_ACTIVATED)) {
            changed = digitizableLayerIds.add(layer.id());
        } else if (ev.getPropertyName().equals(EditTool.PROP_LAYER_DEACTIVATED)) {
            changed = digitizableLayerIds.remove(layer.id());
        }
    }

    if (changed) {
        Runnable runnable = new Runnable() {
            public void run() {
                if (!PlatformUI.getWorkbench().isClosing()) {
                    fireLabelProviderChanged(new LabelProviderChangedEvent(LayerEditableDecorator.this));
                }
            }
        };
        if (Display.getCurrent() != null) {
            runnable.run();
        } else {
            Polymap.getSessionDisplay().asyncExec(runnable);
        }
    }
}