Search in sources :

Example 31 with PropertyChangeListener

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));
            }
        }
    };
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener) BorderLayoutPanel(com.intellij.util.ui.components.BorderLayoutPanel)

Example 32 with PropertyChangeListener

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);
}
Also used : ControlledProcessStateService(org.jboss.as.controller.ControlledProcessStateService) PropertyChangeEvent(java.beans.PropertyChangeEvent) GateHandlerWrapper(org.wildfly.extension.undertow.deployment.GateHandlerWrapper) PropertyChangeListener(java.beans.PropertyChangeListener)

Example 33 with PropertyChangeListener

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);
    }
}
Also used : RemoteEJBService(org.jboss.ejb.protocol.remote.RemoteEJBService) ControlledProcessStateService(org.jboss.as.controller.ControlledProcessStateService) PropertyChangeEvent(java.beans.PropertyChangeEvent) Executor(java.util.concurrent.Executor) Endpoint(org.jboss.remoting3.Endpoint) PropertyChangeListener(java.beans.PropertyChangeListener) OpenListener(org.jboss.remoting3.OpenListener) ServiceRegistrationException(org.jboss.remoting3.ServiceRegistrationException) StartException(org.jboss.msc.service.StartException)

Example 34 with PropertyChangeListener

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);
}
Also used : PropertyChangeListener(java.beans.PropertyChangeListener)

Example 35 with PropertyChangeListener

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);
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener)

Aggregations

PropertyChangeListener (java.beans.PropertyChangeListener)228 PropertyChangeEvent (java.beans.PropertyChangeEvent)197 ActionEvent (java.awt.event.ActionEvent)27 IWidgetPropertyChangeHandler (org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler)27 ActionListener (java.awt.event.ActionListener)26 IFigure (org.eclipse.draw2d.IFigure)25 JPanel (javax.swing.JPanel)21 ArrayList (java.util.ArrayList)16 JLabel (javax.swing.JLabel)13 BorderLayout (java.awt.BorderLayout)12 Dimension (java.awt.Dimension)12 JButton (javax.swing.JButton)12 BoxLayout (javax.swing.BoxLayout)10 GridData (org.eclipse.swt.layout.GridData)10 GridLayout (org.eclipse.swt.layout.GridLayout)10 File (java.io.File)9 Composite (org.eclipse.swt.widgets.Composite)9 Test (org.junit.Test)9 IOException (java.io.IOException)8 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)8