Search in sources :

Example 21 with PropertyChangeEvent

use of java.beans.PropertyChangeEvent 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 22 with PropertyChangeEvent

use of java.beans.PropertyChangeEvent 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)

Example 23 with PropertyChangeEvent

use of java.beans.PropertyChangeEvent in project adempiere by adempiere.

the class Graph method loadData.

private void loadData() {
    list = builder.loadData();
    JFreeChart chart = builder.createChart(builder.getMGoal().getChartType());
    if (chartPanel != null)
        remove(chartPanel);
    chartPanel = new ChartPanel(chart);
    chartPanel.setSize(getSize());
    chartPanel.addChartMouseListener(this);
    add(chartPanel, BorderLayout.CENTER);
    if (m_userSelection) {
        int AD_Reference_Value_ID = DB.getSQLValue(null, "SELECT AD_Reference_ID FROM AD_Reference WHERE Name = ?", "PA_Goal ChartType");
        MLookupInfo info = MLookupFactory.getLookup_List(Env.getLanguage(Env.getCtx()), AD_Reference_Value_ID);
        MLookup mLookup = new MLookup(info, 0);
        VLookup lookup = new VLookup("ChartType", false, false, true, mLookup);
        lookup.addVetoableChangeListener(new VetoableChangeListener() {

            public void vetoableChange(PropertyChangeEvent evt) throws PropertyVetoException {
                Object value = evt.getNewValue();
                if (value == null)
                    return;
                JFreeChart chart = null;
                chart = builder.createChart(value.toString());
                if (chart != null) {
                    if (chartPanel != null)
                        remove(chartPanel);
                    chartPanel = new ChartPanel(chart);
                    chartPanel.setSize(getSize());
                    chartPanel.addChartMouseListener(Graph.this);
                    add(chartPanel, BorderLayout.CENTER);
                    getParent().validate();
                }
            }
        });
        add(lookup, BorderLayout.NORTH);
    }
    this.setMinimumSize(paneldimension);
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) MLookupInfo(org.compiere.model.MLookupInfo) PropertyChangeEvent(java.beans.PropertyChangeEvent) ChartPanel(org.jfree.chart.ChartPanel) MLookup(org.compiere.model.MLookup) VLookup(org.compiere.grid.ed.VLookup) VetoableChangeListener(java.beans.VetoableChangeListener) JFreeChart(org.jfree.chart.JFreeChart) Point(java.awt.Point)

Example 24 with PropertyChangeEvent

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

the class TodoConfiguration method doSetTodoPatterns.

private void doSetTodoPatterns(@NotNull TodoPattern[] todoPatterns, final boolean shouldNotifyIndices) {
    TodoPattern[] oldTodoPatterns = myTodoPatterns;
    IndexPattern[] oldIndexPatterns = myIndexPatterns;
    myTodoPatterns = todoPatterns;
    buildIndexPatterns();
    // only trigger index refresh actual index patterns have changed
    if (shouldNotifyIndices && !Arrays.deepEquals(myIndexPatterns, oldIndexPatterns)) {
        PropertyChangeEvent event = new PropertyChangeEvent(this, IndexPatternProvider.PROP_INDEX_PATTERNS, oldTodoPatterns, todoPatterns);
        myMessageBus.syncPublisher(IndexPatternProvider.INDEX_PATTERNS_CHANGED).propertyChange(event);
    }
    // only trigger gui and code daemon refresh when either the index patterns or presentation attributes have changed
    if (!Arrays.deepEquals(myTodoPatterns, oldTodoPatterns)) {
        PropertyChangeListener multicaster = myPropertyChangeMulticaster.getMulticaster();
        multicaster.propertyChange(new PropertyChangeEvent(this, PROP_TODO_PATTERNS, oldTodoPatterns, todoPatterns));
    }
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener)

Example 25 with PropertyChangeEvent

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

the class TodoConfiguration method setTodoFilters.

public void setTodoFilters(@NotNull TodoFilter[] filters) {
    TodoFilter[] oldFilters = myTodoFilters;
    myTodoFilters = filters;
    myPropertyChangeMulticaster.getMulticaster().propertyChange(new PropertyChangeEvent(this, PROP_TODO_FILTERS, oldFilters, filters));
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent)

Aggregations

PropertyChangeEvent (java.beans.PropertyChangeEvent)574 PropertyChangeListener (java.beans.PropertyChangeListener)349 ActionEvent (java.awt.event.ActionEvent)42 JPanel (javax.swing.JPanel)36 ActionListener (java.awt.event.ActionListener)35 Test (org.junit.Test)33 ArrayList (java.util.ArrayList)31 PropertyVetoException (java.beans.PropertyVetoException)24 JLabel (javax.swing.JLabel)24 File (java.io.File)23 BorderLayout (java.awt.BorderLayout)22 List (java.util.List)21 IOException (java.io.IOException)19 Dimension (java.awt.Dimension)16 ChangeEvent (javax.swing.event.ChangeEvent)15 PropertyChangeSupport (java.beans.PropertyChangeSupport)13 ChangeListener (javax.swing.event.ChangeListener)13 UnprocessedChangeEvents (org.jvnet.hk2.config.UnprocessedChangeEvents)13 JScrollPane (javax.swing.JScrollPane)12 UnprocessedChangeEvent (org.jvnet.hk2.config.UnprocessedChangeEvent)12