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);
}
}
});
}
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));
}
});
}
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;
}
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;
}
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) {
}
}
}
Aggregations