Search in sources :

Example 11 with PropertyChangeListener

use of java.beans.PropertyChangeListener in project gephi by gephi.

the class Module method install.

public static void install() {
    // don't install directory chooser if standard chooser is desired
    if (isStandardChooserForced()) {
        return;
    }
    final UIDefaults uid = UIManager.getDefaults();
    originalImpl = (Class<? extends FileChooserUI>) uid.getUIClass(KEY);
    Class impl = DelegatingChooserUI.class;
    final String val = impl.getName();
    // don't install dirchooser if quickfilechooser is present
    if (!isQuickFileChooser(uid.get(KEY))) {
        uid.put(KEY, val);
        // To make it work in NetBeans too:
        uid.put(val, impl);
    }
    // #61147: prevent NB from switching to a different UI later (under GTK):
    uid.addPropertyChangeListener(pcl = new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            String name = evt.getPropertyName();
            Object className = uid.get(KEY);
            if ((name.equals(KEY) || name.equals("UIDefaults")) && !val.equals(className) && !isQuickFileChooser(className)) {
                uid.put(KEY, val);
            }
        }
    });
}
Also used : UIDefaults(javax.swing.UIDefaults) PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener)

Example 12 with PropertyChangeListener

use of java.beans.PropertyChangeListener in project binnavi by google.

the class CGraphPanelSettingsSynchronizer method initializeSynchronizer.

/**
   * Sets up the listeners that keep the window layout settings updated.
   *
   * @param graphTaggingSplitter
   * @param graphSplitter
   */
public static void initializeSynchronizer(final JideSplitPane graphSplitter, final JideSplitPane graphTaggingSplitter) {
    final GeneralSettingsConfigItem.GraphWindowConfigItem settings = ConfigManager.instance().getGeneralSettings().getGraphWindow();
    graphSplitter.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, new PropertyChangeListener() {

        @Override
        public void propertyChange(final PropertyChangeEvent evt) {
            settings.setSizeBottomPanel(graphSplitter.getDividerLocation(0));
        }
    });
    graphTaggingSplitter.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, new PropertyChangeListener() {

        @Override
        public void propertyChange(final PropertyChangeEvent evt) {
            settings.setSizeLeftPanel(graphTaggingSplitter.getDividerLocation(0));
        }
    });
    graphTaggingSplitter.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, new PropertyChangeListener() {

        @Override
        public void propertyChange(final PropertyChangeEvent evt) {
            settings.setSizeRightPanel(graphTaggingSplitter.getDividerLocation(1));
        }
    });
}
Also used : GeneralSettingsConfigItem(com.google.security.zynamics.binnavi.config.GeneralSettingsConfigItem) PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener)

Example 13 with PropertyChangeListener

use of java.beans.PropertyChangeListener in project gradle by gradle.

the class DefaultAntBuilder method getReferences.

public Map<String, Object> getReferences() {
    ObservableMap map = new ObservableMap(getProject().getReferences());
    map.addPropertyChangeListener(new PropertyChangeListener() {

        public void propertyChange(PropertyChangeEvent event) {
            getProject().addReference(event.getPropertyName(), event.getNewValue());
        }
    });
    @SuppressWarnings("unchecked") Map<String, Object> castMap = (Map<String, Object>) map;
    return castMap;
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener) GroovyObject(groovy.lang.GroovyObject) ObservableMap(groovy.util.ObservableMap) ObservableMap(groovy.util.ObservableMap)

Example 14 with PropertyChangeListener

use of java.beans.PropertyChangeListener in project gradle by gradle.

the class SinglePaneUIInstance method createCenterPanel.

private Component createCenterPanel() {
    splitter = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    splitter.setTopComponent(createMainGradlePanel());
    splitter.setBottomComponent(outputPanelLord.getMainPanel());
    splitter.setContinuousLayout(true);
    //This little bit of tedium is so we can set our size based on window's size. This listens
    //for when the window is actually shown. It then adds a listen to store the location.
    splitter.addHierarchyListener(new HierarchyListener() {

        public void hierarchyChanged(HierarchyEvent e) {
            if (HierarchyEvent.SHOWING_CHANGED == (e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED)) {
                //we only want the first one of these, so remove ourselves as a listener.
                splitter.removeHierarchyListener(this);
                Window window = SwingUtilities.getWindowAncestor(splitter);
                if (window != null) {
                    Dimension dimension = window.getSize();
                    //we'll just make ourselves half the height of the window
                    int halfHeight = dimension.height / 2;
                    splitter.setDividerLocation(halfHeight);
                }
                PreferencesAssistant.restoreSettings(settings, splitter, SPLITTER_PREFERENCES_ID, SinglePaneUIInstance.class);
                //Now that we're visible, this is so we save the location when the splitter is moved.
                splitter.addPropertyChangeListener(new PropertyChangeListener() {

                    public void propertyChange(PropertyChangeEvent evt) {
                        if (JSplitPane.DIVIDER_LOCATION_PROPERTY.equals(evt.getPropertyName())) {
                            PreferencesAssistant.saveSettings(settings, splitter, SPLITTER_PREFERENCES_ID, SinglePaneUIInstance.class);
                        }
                    }
                });
            }
        }
    });
    //this keeps the bottom the same size when resizing the window. Extra space is added/removed from the top.
    splitter.setResizeWeight(1);
    return splitter;
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener) HierarchyEvent(java.awt.event.HierarchyEvent) HierarchyListener(java.awt.event.HierarchyListener)

Example 15 with PropertyChangeListener

use of java.beans.PropertyChangeListener in project jdk8u_jdk by JetBrains.

the class ListenersWithSM method main.

@SuppressWarnings("deprecation")
public static void main(String[] args) throws Exception {
    boolean granted = args[0].equals("grant");
    // need to get reference to LogManager before setting SecurityManager
    LogManager logman = LogManager.getLogManager();
    // set policy and enable security manager
    if (granted) {
        String testSrc = System.getProperty("test.src");
        if (testSrc == null)
            testSrc = ".";
        System.setProperty("java.security.policy", Paths.get(testSrc).resolve("java.policy").toString());
    }
    System.setSecurityManager(new SecurityManager());
    PropertyChangeListener listener = new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
        }
    };
    if (granted) {
        // permission granted, no security exception expected
        logman.addPropertyChangeListener(listener);
        logman.removePropertyChangeListener(listener);
    } else {
        // denied
        try {
            logman.addPropertyChangeListener(listener);
            throw new RuntimeException("SecurityException expected");
        } catch (SecurityException expected) {
        }
        try {
            logman.removePropertyChangeListener(listener);
            throw new RuntimeException("SecurityException expected");
        } catch (SecurityException expected) {
        }
    }
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener) LogManager(java.util.logging.LogManager)

Aggregations

PropertyChangeListener (java.beans.PropertyChangeListener)152 PropertyChangeEvent (java.beans.PropertyChangeEvent)124 ActionEvent (java.awt.event.ActionEvent)16 ActionListener (java.awt.event.ActionListener)15 JPanel (javax.swing.JPanel)15 ArrayList (java.util.ArrayList)11 BorderLayout (java.awt.BorderLayout)10 JButton (javax.swing.JButton)9 GridData (org.eclipse.swt.layout.GridData)9 GridLayout (org.eclipse.swt.layout.GridLayout)9 Composite (org.eclipse.swt.widgets.Composite)9 IOException (java.io.IOException)8 JLabel (javax.swing.JLabel)8 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)7 SelectionEvent (org.eclipse.swt.events.SelectionEvent)7 Dimension (java.awt.Dimension)6 FlowLayout (java.awt.FlowLayout)6 PropertyChangeSupport (java.beans.PropertyChangeSupport)6 File (java.io.File)6 BoxLayout (javax.swing.BoxLayout)6