use of java.beans.PropertyChangeListener in project intellij-community by JetBrains.
the class MacIntelliJComboBoxUI method createPopup.
@Override
protected ComboPopup createPopup() {
return new BasicComboPopup(myComboBox) {
@Override
protected void configurePopup() {
super.configurePopup();
setBorderPainted(false);
setBorder(JBUI.Borders.empty());
setBackground(Gray.xFF);
}
@Override
protected void configureList() {
super.configureList();
wrapRenderer();
}
@Override
protected PropertyChangeListener createPropertyChangeListener() {
final PropertyChangeListener listener = super.createPropertyChangeListener();
return new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
listener.propertyChange(evt);
if ("renderer".equals(evt.getPropertyName())) {
wrapRenderer();
}
}
};
}
class ComboBoxRendererWrapper implements ListCellRenderer {
private final ListCellRenderer myRenderer;
public ComboBoxRendererWrapper(@NotNull ListCellRenderer renderer) {
myRenderer = renderer;
}
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
Component c = myRenderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
BorderLayoutPanel panel = JBUI.Panels.simplePanel(c).withBorder(JBUI.Borders.empty(0, 8));
panel.setBackground(c.getBackground());
return panel;
}
}
private void wrapRenderer() {
ListCellRenderer renderer = list.getCellRenderer();
if (!(renderer instanceof ComboBoxRendererWrapper) && renderer != null) {
list.setCellRenderer(new ComboBoxRendererWrapper(renderer));
}
}
};
}
use of java.beans.PropertyChangeListener in project wildfly by wildfly.
the class Host method start.
@Override
public void start(StartContext context) throws StartException {
ControlledProcessStateService controlledProcessStateService = controlledProcessStateServiceInjectedValue.getValue();
//may be null for tests
if (controlledProcessStateService != null && controlledProcessStateService.getCurrentState() == ControlledProcessState.State.STARTING) {
gateHandlerWrapper = new GateHandlerWrapper();
controlledProcessStateService.addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
controlledProcessStateService.removePropertyChangeListener(this);
if (gateHandlerWrapper != null) {
gateHandlerWrapper.open();
gateHandlerWrapper = null;
}
rootHandler = null;
}
});
}
server.getValue().registerHost(this);
UndertowLogger.ROOT_LOGGER.hostStarting(name);
}
use of java.beans.PropertyChangeListener in project wildfly by wildfly.
the class EJBRemoteConnectorService method start.
@Override
public void start(StartContext context) throws StartException {
final AssociationService associationService = associationServiceInjectedValue.getValue();
final Endpoint endpoint = endpointValue.getValue();
Executor executor = executorService.getOptionalValue();
if (executor != null) {
associationService.setExecutor(executor);
}
RemoteEJBService remoteEJBService = RemoteEJBService.create(associationService.getAssociation(), remotingTransactionServiceInjectedValue.getValue());
final ControlledProcessStateService processStateService = controlledProcessStateServiceInjectedValue.getValue();
if (processStateService.getCurrentState() == ControlledProcessState.State.STARTING) {
final PropertyChangeListener listener = new PropertyChangeListener() {
public void propertyChange(final PropertyChangeEvent evt) {
if (evt.getPropertyName().equals("currentState") && evt.getOldValue() == ControlledProcessState.State.STARTING) {
remoteEJBService.serverUp();
// can't use a lambda because of this line...
processStateService.removePropertyChangeListener(this);
}
}
};
processStateService.addPropertyChangeListener(listener);
// this is actually racy, so we have to double-check the state afterwards just to be sure it didn't transition before we got here.
if (processStateService.getCurrentState() != ControlledProcessState.State.STARTING) {
// this method is idempotent so it's OK if the listener got fired
remoteEJBService.serverUp();
// this one too
processStateService.removePropertyChangeListener(listener);
}
} else {
remoteEJBService.serverUp();
}
// Register an EJB channel open listener
OpenListener channelOpenListener = remoteEJBService.getOpenListener();
try {
registration = endpoint.registerService(EJB_CHANNEL_NAME, channelOpenListener, this.channelCreationOptions);
} catch (ServiceRegistrationException e) {
throw new StartException(e);
}
}
use of java.beans.PropertyChangeListener in project intellij-community by JetBrains.
the class RelativeFontTest method checkInstallUninstall.
private static void checkInstallUninstall(int expected, JLabel label) {
int actual = 0;
for (PropertyChangeListener listener : label.getPropertyChangeListeners("font")) {
if (listener instanceof RelativeFont) {
actual++;
}
}
assertEquals(expected, actual);
}
use of java.beans.PropertyChangeListener in project intellij-community by JetBrains.
the class MacIntelliJComboBoxUI method installUI.
@Override
public void installUI(final JComponent c) {
super.installUI(c);
myEditorBorderChangeListener = new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
Object value = evt.getNewValue();
if (value == ourDefaultEditorBorder)
return;
ComboBoxEditor editor = ((JComboBox) c).getEditor();
if (editor != null) {
Component component = editor.getEditorComponent();
if (component instanceof JComponent) {
((JComponent) component).setBorder(ourDefaultEditorBorder);
}
}
}
};
myEditorChangeListener = new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
Object value = evt.getNewValue();
Object oldEditor = evt.getOldValue();
if (oldEditor instanceof ComboBoxEditor) {
Component component = ((ComboBoxEditor) oldEditor).getEditorComponent();
if (component instanceof JComponent) {
component.removePropertyChangeListener("border", myEditorBorderChangeListener);
}
}
if (value instanceof ComboBoxEditor) {
Component component = ((ComboBoxEditor) value).getEditorComponent();
if (component instanceof JComponent) {
JComponent comboBoxEditor = (JComponent) component;
comboBoxEditor.setBorder(ourDefaultEditorBorder);
comboBoxEditor.addPropertyChangeListener("border", myEditorBorderChangeListener);
}
}
}
};
c.addPropertyChangeListener("editor", myEditorChangeListener);
}
Aggregations