use of java.beans.PropertyChangeEvent 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) {
}
}
}
use of java.beans.PropertyChangeEvent in project jdk8u_jdk by JetBrains.
the class TestPropertyChangeSupport method test.
private static void test(int step, int listeners, int attempts) {
TestPropertyChangeSupport test = new TestPropertyChangeSupport();
PropertyChangeSupport pcs = new PropertyChangeSupport(test);
PropertyChangeEvent eventNull = new PropertyChangeEvent(test, null, null, null);
PropertyChangeEvent eventName = new PropertyChangeEvent(test, NAME, null, null);
long time1 = System.currentTimeMillis();
for (int i = 0; i < listeners; i++) {
pcs.addPropertyChangeListener(test);
pcs.addPropertyChangeListener(NAME, test);
}
long time2 = System.currentTimeMillis();
for (int i = 0; i < attempts; i++) {
pcs.firePropertyChange(eventNull);
pcs.firePropertyChange(eventName);
}
long time3 = System.currentTimeMillis();
// time of adding the listeners
time1 = time2 - time1;
// time of firing the events
time2 = time3 - time2;
System.out.println("Step: " + step + "; Listeners: " + listeners + "; Attempts: " + attempts + "; Time (ms): " + time1 + "/" + time2);
}
use of java.beans.PropertyChangeEvent in project jdk8u_jdk by JetBrains.
the class TestVetoableChangeSupport method test.
private static void test(int step, int listeners, int attempts) throws PropertyVetoException {
TestVetoableChangeSupport test = new TestVetoableChangeSupport();
VetoableChangeSupport vcs = new VetoableChangeSupport(test);
PropertyChangeEvent eventNull = new PropertyChangeEvent(test, null, null, null);
PropertyChangeEvent eventName = new PropertyChangeEvent(test, NAME, null, null);
long time1 = System.currentTimeMillis();
for (int i = 0; i < listeners; i++) {
vcs.addVetoableChangeListener(test);
vcs.addVetoableChangeListener(NAME, test);
}
long time2 = System.currentTimeMillis();
for (int i = 0; i < attempts; i++) {
vcs.fireVetoableChange(eventNull);
vcs.fireVetoableChange(eventName);
}
long time3 = System.currentTimeMillis();
// time of adding the listeners
time1 = time2 - time1;
// time of firing the events
time2 = time3 - time2;
System.out.println("Step: " + step + "; Listeners: " + listeners + "; Attempts: " + attempts + "; Time (ms): " + time1 + "/" + time2);
}
use of java.beans.PropertyChangeEvent in project azure-tools-for-java by Microsoft.
the class SparkSubmissionContentPanel method addSparkClustersLineItem.
private void addSparkClustersLineItem() {
JLabel sparkClusterLabel = new JLabel("Spark clusters(Linux only)");
sparkClusterLabel.setToolTipText("The HDInsight Spark cluster you want to submit your application to. Only Linux cluster is supported.");
GridBagConstraints c11 = new GridBagConstraints();
c11.gridx = 0;
c11.gridy = 0;
c11.insets = new Insets(margin, margin, 0, margin);
add(sparkClusterLabel, new GridBagConstraints(0, displayLayoutCurrentRow, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(margin, margin, 0, margin), 0, 0));
clustersListComboBox = new ComboboxWithBrowseButton();
clustersListComboBox.setButtonIcon(StreamUtil.getImageResourceFile(REFRESH_BUTTON_PATH));
clustersListComboBox.getButton().setToolTipText("Refresh");
clustersListComboBox.getButton().addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
Cursor cursor = getCursor();
setCursor(new Cursor(Cursor.WAIT_CURSOR));
List<IClusterDetail> clusterDetails = ClusterManagerEx.getInstance().getClusterDetails(submitModel.getProject());
setCursor(cursor);
submitModel.setClusterComboBoxModel(clusterDetails);
}
});
clustersListComboBox.getComboBox().setToolTipText("The HDInsight Spark cluster you want to submit your application to. Only Linux cluster is supported.");
clustersListComboBox.getComboBox().addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (evt.getPropertyName() == "model" && evt.getNewValue() instanceof DefaultComboBoxModel) {
int size = ((DefaultComboBoxModel) evt.getNewValue()).getSize();
setVisibleForFixedErrorMessageLabel(ErrorMessageLabelTag.ClusterName.ordinal(), size <= 0);
}
}
});
add(clustersListComboBox, new GridBagConstraints(1, displayLayoutCurrentRow, 0, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(margin, margin, 0, margin), 0, 0));
errorMessageLabels[ErrorMessageLabelTag.ClusterName.ordinal()] = new JLabel("Cluster Name Should not be null");
errorMessageLabels[ErrorMessageLabelTag.ClusterName.ordinal()].setForeground(DarkThemeManager.getInstance().getErrorMessageColor());
clustersListComboBox.getComboBox().addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
setVisibleForFixedErrorMessageLabel(0, clustersListComboBox.getComboBox().getItemCount() == 0);
}
});
add(errorMessageLabels[ErrorMessageLabelTag.ClusterName.ordinal()], new GridBagConstraints(1, ++displayLayoutCurrentRow, 0, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, margin, 0, 0), 0, 0));
}
use of java.beans.PropertyChangeEvent in project intellij-community by JetBrains.
the class LafManagerImpl method initComponent.
@Override
public void initComponent() {
if (myCurrentLaf != null) {
final UIManager.LookAndFeelInfo laf = findLaf(myCurrentLaf.getClassName());
if (laf != null) {
boolean needUninstall = UIUtil.isUnderDarcula();
// setup default LAF or one specified by readExternal.
setCurrentLookAndFeel(laf);
updateWizardLAF(needUninstall);
}
}
updateUI();
if (SystemInfo.isXWindow) {
PropertyChangeListener themeChangeListener = new PropertyChangeListener() {
@Override
public void propertyChange(final PropertyChangeEvent evt) {
//noinspection SSBasedInspection
SwingUtilities.invokeLater(() -> {
fixGtkPopupStyle();
patchGtkDefaults(UIManager.getLookAndFeelDefaults());
});
}
};
Toolkit.getDefaultToolkit().addPropertyChangeListener(GNOME_THEME_PROPERTY_NAME, themeChangeListener);
Disposer.register(this, new Disposable() {
@Override
public void dispose() {
Toolkit.getDefaultToolkit().removePropertyChangeListener(GNOME_THEME_PROPERTY_NAME, themeChangeListener);
}
});
}
}
Aggregations