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.yccheok.jstock.gui.analysis.ObjectInspectorJPanel.java

/** Creates a new instance of ObjectInspectorJPanel */
public ObjectInspectorJPanel(Object bean) {
    this.bean = bean;

    BeanInfo beanInfo = null;//from w ww  .  j  a  v a 2  s.c  o  m

    try {
        beanInfo = Introspector.getBeanInfo(bean.getClass());
    } catch (IntrospectionException exp) {
        log.error(null, exp);
    }

    this.getTable().setEditorFactory(new PropertyEditorRegistryEx());
    PropertyEditorRegistry editor = (PropertyEditorRegistry) this.getTable().getEditorFactory();
    PropertyRendererRegistry renderer = (PropertyRendererRegistry) this.getTable().getRendererFactory();

    editor.registerEditor(Enum.class, new EnumComboBoxPropertyEditor());

    DefaultCellRenderer r = new DefaultCellRenderer();
    r.setShowOddAndEvenRows(false);
    renderer.registerRenderer(Enum.class, r);

    this.setMode(PropertySheet.VIEW_AS_FLAT_LIST);
    this.setToolBarVisible(false);
    this.setDescriptionVisible(false);
    this.setToolBarVisible(true);
    this.setBeanInfo(beanInfo);

    Property[] properties = this.getProperties();
    for (int i = 0, c = properties.length; i < c; i++) {
        properties[i].readFromObject(bean);
    }

    PropertyChangeListener listener = new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            Property prop = (Property) evt.getSource();
            prop.writeToObject(ObjectInspectorJPanel.this.bean);
        }
    };

    this.addPropertySheetChangeListener(listener);
}

From source file:com.anrisoftware.prefdialog.miscswing.actions.Actions.java

Actions() {
    this.actions = new HashMap<String, List<ActionEntry>>();
    this.awtActions = new HashMap<String, List<Runnable>>();
    this.actionListener = new PropertyChangeListener() {

        @Override//from   w w  w .j  av a2  s.com
        public void propertyChange(PropertyChangeEvent evt) {
            Future<?> future = (Future<?>) evt.getSource();
            try {
                future.get();
            } catch (InterruptedException e) {
                log.taskInterrupted(future, e);
            } catch (ExecutionException e) {
                log.taskError(future, e.getCause());
            }
        }
    };
}

From source file:org.kalypso.model.wspm.ui.profil.wizard.classification.landuse.model.ALSSelectedShapeFileChangedListener.java

@Override
public void propertyChange(final PropertyChangeEvent evt) {
    final ApplyLanduseShapeModel model = (ApplyLanduseShapeModel) evt.getSource();
    final IFile file = (IFile) evt.getNewValue();
    if (Objects.equal(m_file, file) && Objects.equal(model.getType(), m_type))
        return;/*ww w.  ja  va2s  . c  o  m*/

    try {
        final String base = FilenameUtils.removeExtension(model.getLanduseShape().getLocation().toOSString());

        /* Properties are displayed in landuse mapping table. don't assign a new property member - merge! */
        final LanduseProperties shapeFileProperties = getProperties(model, base);
        final LanduseProperties modelProperties = model.getMapping();
        modelProperties.clear();

        PropertiesUtilities.merge(modelProperties, shapeFileProperties);

        final IDBFField column = model.getShapeColumn();
        if (Objects.isNull(column))
            updateColumn(model, shapeFileProperties);

        model.firePropertyChange(ILanduseModel.PROPERTY_MAPPING, null, modelProperties);
        m_type = model.getType();
        m_file = file;
    } catch (final Exception ex) {
        ex.printStackTrace();
    }
}

From source file:org.jcurl.demo.tactics.CurlerSwingBean.java

public void propertyChange(final PropertyChangeEvent evt) {
    log.warn("Unconsumed event '" + evt.getPropertyName() + "' from " + evt.getSource().getClass().getName()
            + ": " + evt.getOldValue() + " -> " + evt.getNewValue());
}

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

public void modelChanged(ModelChangeEvent ev) {
    for (PropertyChangeEvent pev : ev.events()) {
        Entity entity = (Entity) pev.getSource();
        try {/*w  w w  .j a va2s .c om*/
            if (entity instanceof IAdaptable) {
                ((IAdaptable) entity).getAdapter(String.class);
                if (decorated.containsKey(entity.id())) {
                    if (!PlatformUI.getWorkbench().isClosing()) {
                        fireLabelProviderChanged(
                                new LabelProviderChangedEvent(EntityModificationDecorator.this));
                    }
                    break;
                }
            }
        } catch (NoSuchEntityException e) {
        }
    }
}

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

/**
 * Downloads the selected files./*from w  w w . j  a  v a  2s  .c o  m*/
 * @see java.awt.event.ActionListener#actionPerformed(ActionEvent)
 */
public void actionPerformed(ActionEvent e) {
    ImageDisplay node = model.getBrowser().getLastSelectedDisplay();
    if (node == null)
        return;

    JFrame f = DataBrowserAgent.getRegistry().getTaskBar().getFrame();

    int type = FileChooser.FOLDER_CHOOSER;

    FileChooser chooser = new FileChooser(f, type, FileChooser.DOWNLOAD_TEXT, FileChooser.DOWNLOAD_DESCRIPTION);

    IconManager icons = IconManager.getInstance();
    chooser.setTitleIcon(icons.getIcon(IconManager.DOWNLOAD_48));
    chooser.setApproveButtonText(FileChooser.DOWNLOAD_TEXT);
    chooser.setCheckOverride(true);
    chooser.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            String name = evt.getPropertyName();
            FileChooser src = (FileChooser) evt.getSource();
            if (FileChooser.APPROVE_SELECTION_PROPERTY.equals(name)) {
                String path = (String) evt.getNewValue();
                EventBus bus = DataBrowserAgent.getRegistry().getEventBus();
                bus.post(new DownloadEvent(new File(path), src.isOverride()));
            }
        }
    });
    chooser.centerDialog();
}

From source file:org.jcurl.model.ComputedPathsTest.java

public void testNoneMoving() throws FunctionEvaluationException, InterruptedException {
    final ComputedPaths cp = new ComputedPaths();
    assertEquals(0, ec);//ww  w.  ja  v  a 2s .  co m
    cp.getCurrentPos().addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent e) {
            assertEquals("rock", e.getPropertyName());
            assertTrue(e.getSource() instanceof PositionSet);
            ec += pos;
        }
    });
    cp.getCurrentSpeed().addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent e) {
            assertEquals("rock", e.getPropertyName());
            assertTrue(e.getSource() instanceof SpeedSet);
            ec += vel;
        }
    });
    assertEquals(0, ec);
    assertEquals("", 0.0, cp.getCurrentT(), 1e-9);
    cp.setCurrentT(1);
    // Strange! Eclipse fails here, but maven does it right!
    assertEquals((vel + pos), ec);
    assertEquals("", 1.0, cp.getCurrentT(), 1e-9);
    cp.setCurrentT(Double.MAX_VALUE);
    assertEquals((vel + pos) * 2, ec);
    assertEquals("", Double.MAX_VALUE, cp.getCurrentT(), 1e-9);
    cp.setCurrentT(Double.POSITIVE_INFINITY);
    assertEquals((vel + pos) * 3, ec);
    assertEquals("", Double.POSITIVE_INFINITY, cp.getCurrentT(), 1e-9);
}

From source file:org.jcurl.model.ComputedPathsTest.java

public void testOneMovingEvents() throws FunctionEvaluationException {
    final ComputedPaths cp = new ComputedPaths();
    assertEquals(0, ec);/*from www.  java  2  s. c om*/
    cp.getCurrentPos().addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent e) {
            assertEquals("rock", e.getPropertyName());
            assertTrue(e.getSource() instanceof PositionSet);
            ec += pos;
        }
    });
    cp.getCurrentSpeed().addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent e) {
            assertEquals("rock", e.getPropertyName());
            assertTrue(e.getSource() instanceof SpeedSet);
            ec += vel;
        }
    });
    assertEquals(0, ec);
    cp.getInitialSpeed().getLight(0).setY(-1);
    cp.getInitialSpeed().notifyChange();
    assertEquals((vel + pos) * 1, ec);
    cp.setCurrentT(1);
    assertEquals((vel + pos) * 2, ec);
    assertEquals("", 1.0, cp.getCurrentT(), 1e-9);
    cp.setCurrentT(Double.MAX_VALUE);
    assertEquals((vel + pos) * 3, ec);
    assertEquals("", Double.MAX_VALUE, cp.getCurrentT(), 1e-9);
    cp.setCurrentT(Double.POSITIVE_INFINITY);
    assertEquals((vel + pos) * 4, ec);
    assertEquals("", Double.POSITIVE_INFINITY, cp.getCurrentT(), 1e-9);
}

From source file:org.polymap.core.geohub.LayerFeatureSelectionManager.java

public boolean addSelectionChangeListener(final PropertyChangeListener l) {
    EventManager.instance().subscribe(l, new EventFilter<PropertyChangeEvent>() {
        public boolean apply(PropertyChangeEvent ev) {
            return ev instanceof FeatureSelectionEvent && ev.getSource() == LayerFeatureSelectionManager.this;
        }/* ww w . j  a  v  a 2 s .c  o m*/
    });
    return true;
}

From source file:components.CustomDialog.java

/** This method reacts to state changes in the option pane. */
public void propertyChange(PropertyChangeEvent e) {
    String prop = e.getPropertyName();

    if (isVisible() && (e.getSource() == optionPane)
            && (JOptionPane.VALUE_PROPERTY.equals(prop) || JOptionPane.INPUT_VALUE_PROPERTY.equals(prop))) {
        Object value = optionPane.getValue();

        if (value == JOptionPane.UNINITIALIZED_VALUE) {
            //ignore reset
            return;
        }/*from   w  w w. jav  a  2  s.  c  o m*/

        //Reset the JOptionPane's value.
        //If you don't do this, then if the user
        //presses the same button next time, no
        //property change event will be fired.
        optionPane.setValue(JOptionPane.UNINITIALIZED_VALUE);

        if (btnString1.equals(value)) {
            typedText = textField.getText();
            String ucText = typedText.toUpperCase();
            if (magicWord.equals(ucText)) {
                //we're done; clear and dismiss the dialog
                clearAndHide();
            } else {
                //text was invalid
                textField.selectAll();
                JOptionPane
                        .showMessageDialog(
                                CustomDialog.this, "Sorry, \"" + typedText + "\" " + "isn't a valid response.\n"
                                        + "Please enter " + magicWord + ".",
                                "Try again", JOptionPane.ERROR_MESSAGE);
                typedText = null;
                textField.requestFocusInWindow();
            }
        } else { //user closed dialog or clicked cancel
            dd.setLabel("It's OK.  " + "We won't force you to type " + magicWord + ".");
            typedText = null;
            clearAndHide();
        }
    }
}