Example usage for javax.swing JDialog addPropertyChangeListener

List of usage examples for javax.swing JDialog addPropertyChangeListener

Introduction

In this page you can find the example usage for javax.swing JDialog addPropertyChangeListener.

Prototype

public void addPropertyChangeListener(PropertyChangeListener listener) 

Source Link

Document

Adds a PropertyChangeListener to the listener list.

Usage

From source file:org.geopublishing.atlasStyler.swing.PolygonSymbolEditGUI.java

/**
 * This method initializes jButton/*from www . java 2s  .  c  o m*/
 * 
 * @return javax.swing.JButton
 */
private JButton getJButtonFillGraphic() {
    if (jButtonFillGraphic == null) {
        jButtonFillGraphic = new JButton();

        boolean enabled = false;
        if (symbolizer.getFill() != null) {
            Graphic graphicFill = symbolizer.getFill().getGraphicFill();
            enabled = (graphicFill != null);
        }

        jButtonFillGraphic.setAction(new AbstractAction() {

            @Override
            public void actionPerformed(ActionEvent e) {

                if (symbolizer.getFill() == null) {
                    symbolizer.setFill(StylingUtil.STYLE_BUILDER.createFill((Color) null, (Color) null, 1.,
                            StylingUtil.STYLE_BUILDER.createGraphic()));
                }

                JDialog editFillGraphicJDialog = new GraphicEditGUIinDialog(asv,
                        SwingUtil.getParentWindow(PolygonSymbolEditGUI.this), symbolizer.getFill());

                editFillGraphicJDialog.addPropertyChangeListener(new PropertyChangeListener() {

                    @Override
                    public void propertyChange(PropertyChangeEvent evt) {
                        if (evt.getPropertyName().equals(AbstractStyleEditGUI.PROPERTY_UPDATED)) {

                            PolygonSymbolEditGUI.this.firePropertyChange(AbstractStyleEditGUI.PROPERTY_UPDATED,
                                    null, null);

                            // Update the Button Icon
                            jButtonFillGraphic.setIcon(new ImageIcon(ASUtil.getSymbolizerImage(symbolizer,
                                    FeatureUtil.createFeatureType(Polygon.class))));
                        }
                    }

                });

                SwingUtil.setRelativeFramePosition(editFillGraphicJDialog, PolygonSymbolEditGUI.this,
                        SwingUtil.BOUNDS_OUTER, SwingUtil.NORTHEAST);

                editFillGraphicJDialog.setVisible(true);
            }

        });

        // Initialize correctly
        jLabelFillGraphic.setEnabled(enabled);
        jButtonFillGraphic.setEnabled(enabled);
        if (enabled) {
            jButtonFillGraphic.setIcon(new ImageIcon(
                    ASUtil.getSymbolizerImage(symbolizer, FeatureUtil.createFeatureType(Polygon.class))));
        }

    }
    return jButtonFillGraphic;
}

From source file:org.openmicroscopy.shoola.agents.treeviewer.view.TreeViewerComponent.java

/**
 * Implemented as specified by the {@link TreeViewer} interface.
 * @see TreeViewer#createDataObject(DataObject, boolean)
 *///from  ww  w  .  j a v a 2  s.  c  om
public void createDataObject(DataObject object, boolean withParent) {
    switch (model.getState()) {
    case DISCARDED:
    case SAVE:
        throw new IllegalStateException("This method cannot be invoked in the DISCARDED " + "or SAVE state.");
    }
    if (object == null)
        return;
    JDialog d = null;
    if ((object instanceof ProjectData) || (object instanceof DatasetData) || (object instanceof ScreenData)
            || (object instanceof TagAnnotationData)) {
        d = new EditorDialog(view, object, withParent);
    } else if ((object instanceof GroupData) || (object instanceof ExperimenterData)) {
        Object uo = null;
        Set<DataObject> nodes = null;
        if (object instanceof ExperimenterData) {
            Browser browser = getSelectedBrowser();
            TreeImageDisplay node = null;
            if (browser != null)
                node = browser.getLastSelectedDisplay();
            if (node != null)
                uo = node.getUserObject();
            ContainerFinder finder = new ContainerFinder(GroupData.class);
            getSelectedBrowser().accept(finder, TreeImageDisplayVisitor.TREEIMAGE_SET_ONLY);
            nodes = finder.getContainers();
            if (nodes.size() == 0) {
                //Notify user
                UserNotifier un = TreeViewerAgent.getRegistry().getUserNotifier();
                un.notifyInfo("User Creation", "No group available. Please create a group first.");
                return;
            }
        }
        d = new AdminDialog(view, model.getAdminContext(), object.getClass(), uo, nodes);
    }

    if (d != null) {
        d.addPropertyChangeListener(controller);
        UIUtilities.centerAndShow(d);
    }
}