Search in sources :

Example 96 with PropertyChangeListener

use of java.beans.PropertyChangeListener in project intellij-community by JetBrains.

the class TemplateState method initListeners.

private void initListeners() {
    if (isDisposed())
        return;
    myEditorDocumentListener = new DocumentAdapter() {

        @Override
        public void beforeDocumentChange(DocumentEvent e) {
            myDocumentChanged = true;
        }
    };
    myLookupListener = new LookupAdapter() {

        @Override
        public void itemSelected(LookupEvent event) {
            if (isCaretOutsideCurrentSegment(null)) {
                if (isCaretInsideNextVariable()) {
                    nextTab();
                } else {
                    gotoEnd(true);
                }
            }
        }
    };
    LookupManager.getInstance(myProject).addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if (LookupManager.PROP_ACTIVE_LOOKUP.equals(evt.getPropertyName())) {
                Lookup lookup = (Lookup) evt.getNewValue();
                if (lookup != null) {
                    lookup.addLookupListener(myLookupListener);
                }
            }
        }
    }, this);
    myCommandListener = new CommandAdapter() {

        boolean started = false;

        @Override
        public void commandStarted(CommandEvent event) {
            myDocumentChangesTerminateTemplate = isCaretOutsideCurrentSegment(event.getCommandName());
            started = true;
        }

        @Override
        public void beforeCommandFinished(CommandEvent event) {
            if (started && !isDisposed()) {
                Runnable runnable = () -> afterChangedUpdate();
                final LookupImpl lookup = myEditor != null ? (LookupImpl) LookupManager.getActiveLookup(myEditor) : null;
                if (lookup != null) {
                    lookup.performGuardedChange(runnable);
                } else {
                    runnable.run();
                }
            }
        }
    };
    myCaretListener = new CaretAdapter() {

        @Override
        public void caretAdded(CaretEvent e) {
            if (isMultiCaretMode()) {
                finishTemplateEditing();
            }
        }

        @Override
        public void caretRemoved(CaretEvent e) {
            if (isMultiCaretMode()) {
                finishTemplateEditing();
            }
        }
    };
    if (myEditor != null) {
        myEditor.getCaretModel().addCaretListener(myCaretListener);
    }
    myDocument.addDocumentListener(myEditorDocumentListener, this);
    CommandProcessor.getInstance().addCommandListener(myCommandListener, this);
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener) CommandAdapter(com.intellij.openapi.command.CommandAdapter) LookupImpl(com.intellij.codeInsight.lookup.impl.LookupImpl) CommandEvent(com.intellij.openapi.command.CommandEvent)

Example 97 with PropertyChangeListener

use of java.beans.PropertyChangeListener in project intellij-community by JetBrains.

the class PushLog method createStrategyPanel.

private JComponent createStrategyPanel() {
    final JPanel labelPanel = new JPanel(new BorderLayout());
    labelPanel.setBackground(myTree.getBackground());
    final LinkLabel<String> linkLabel = new LinkLabel<>("Edit all targets", null);
    linkLabel.setBorder(new EmptyBorder(2, 2, 2, 2));
    linkLabel.setListener(new LinkListener<String>() {

        @Override
        public void linkSelected(LinkLabel aSource, String aLinkData) {
            if (linkLabel.isEnabled()) {
                startSyncEditing();
            }
        }
    }, null);
    myTree.addPropertyChangeListener(PushLogTreeUtil.EDIT_MODE_PROP, new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            Boolean editMode = (Boolean) evt.getNewValue();
            linkLabel.setEnabled(!editMode);
            linkLabel.setPaintUnderline(!editMode);
            linkLabel.repaint();
        }
    });
    labelPanel.add(linkLabel, BorderLayout.EAST);
    return labelPanel;
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener) LinkLabel(com.intellij.ui.components.labels.LinkLabel) EmptyBorder(javax.swing.border.EmptyBorder)

Example 98 with PropertyChangeListener

use of java.beans.PropertyChangeListener in project intellij-community by JetBrains.

the class SpeedSearchSupply method installSupplyTo.

protected void installSupplyTo(final JComponent component) {
    component.putClientProperty(SPEED_SEARCH_COMPONENT_MARKER, this);
    addChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            component.repaint();
        }
    });
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener)

Example 99 with PropertyChangeListener

use of java.beans.PropertyChangeListener in project intellij-community by JetBrains.

the class NotificationsManagerImpl method createButtons.

@Nullable
private static JPanel createButtons(@NotNull Notification notification, @NotNull final JPanel content, @Nullable HyperlinkListener listener) {
    if (notification instanceof NotificationActionProvider) {
        JPanel buttons = new JPanel(new HorizontalLayout(5));
        buttons.setOpaque(false);
        content.add(BorderLayout.SOUTH, buttons);
        final Ref<JButton> defaultButton = new Ref<>();
        NotificationActionProvider provider = (NotificationActionProvider) notification;
        for (NotificationActionProvider.Action action : provider.getActions(listener)) {
            JButton button = new JButton(action) {

                @Override
                public void setUI(ButtonUI ui) {
                    boolean isDarcula = ui instanceof DarculaButtonUI && UIUtil.isUnderDarcula();
                    if (isDarcula) {
                        ui = new DarculaButtonUI() {

                            @Override
                            protected Color getButtonColor1() {
                                return new ColorUIResource(0x464b4c);
                            }

                            @Override
                            protected Color getButtonColor2() {
                                return new ColorUIResource(0x383c3d);
                            }
                        };
                    }
                    super.setUI(ui);
                    if (isDarcula) {
                        setBorder(new DarculaButtonPainter() {

                            @Override
                            protected Color getBorderColor() {
                                return new ColorUIResource(0x616263);
                            }
                        });
                    }
                }
            };
            button.setOpaque(false);
            if (action.isDefaultAction()) {
                defaultButton.setIfNull(button);
            }
            buttons.add(HorizontalLayout.RIGHT, button);
        }
        if (!defaultButton.isNull()) {
            UIUtil.addParentChangeListener(content, new PropertyChangeListener() {

                @Override
                public void propertyChange(PropertyChangeEvent event) {
                    if (event.getOldValue() == null && event.getNewValue() != null) {
                        UIUtil.removeParentChangeListener(content, this);
                        JRootPane rootPane = UIUtil.getRootPane(content);
                        if (rootPane != null) {
                            rootPane.setDefaultButton(defaultButton.get());
                        }
                    }
                }
            });
        }
        return buttons;
    }
    return null;
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener) DarculaButtonPainter(com.intellij.ide.ui.laf.darcula.ui.DarculaButtonPainter) ButtonUI(javax.swing.plaf.ButtonUI) DarculaButtonUI(com.intellij.ide.ui.laf.darcula.ui.DarculaButtonUI) ColorUIResource(javax.swing.plaf.ColorUIResource) HorizontalLayout(com.intellij.ui.components.panels.HorizontalLayout) Ref(com.intellij.openapi.util.Ref) DarculaButtonUI(com.intellij.ide.ui.laf.darcula.ui.DarculaButtonUI) Nullable(org.jetbrains.annotations.Nullable)

Example 100 with PropertyChangeListener

use of java.beans.PropertyChangeListener in project intellij-community by JetBrains.

the class ShortcutDialog method createNorthPanel.

@Nullable
@Override
protected JComponent createNorthPanel() {
    myAction.setIpad(JBUI.insets(10, 10, 5, 10));
    myShortcutPanel.addPropertyChangeListener("shortcut", new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent event) {
            setShortcut(toShortcut(event.getNewValue()));
        }
    });
    JBPanel result = new JBPanel(new BorderLayout()).withPreferredWidth(300).withMinimumWidth(200);
    result.add(BorderLayout.NORTH, myAction);
    result.add(BorderLayout.SOUTH, myShortcutPanel);
    return result;
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener) BorderLayout(java.awt.BorderLayout) JBPanel(com.intellij.ui.components.JBPanel) Nullable(org.jetbrains.annotations.Nullable)

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