Search in sources :

Example 11 with ChangeListener

use of javax.swing.event.ChangeListener in project intellij-community by JetBrains.

the class GroovyExtractMethodDialog method setUpDialog.

private void setUpDialog() {
    myCbSpecifyType.setMnemonic(KeyEvent.VK_T);
    myCbSpecifyType.setFocusable(false);
    myCbSpecifyType.setSelected(true);
    if (GroovyApplicationSettings.getInstance().EXTRACT_METHOD_SPECIFY_TYPE != null) {
        myCbSpecifyType.setSelected(GroovyApplicationSettings.getInstance().EXTRACT_METHOD_SPECIFY_TYPE);
    }
    myCbSpecifyType.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            myHelper.setSpecifyType(myCbSpecifyType.isSelected());
            updateSignature();
        }
    });
    myHelper.setSpecifyType(myCbSpecifyType.isSelected());
    myHelper.setVisibility(myVisibilityPanel.getVisibility());
    myNameLabel.setLabelFor(myNameField);
    final PsiType type = myHelper.getOutputType();
    if (!PsiType.VOID.equals(type)) {
        myForceReturnCheckBox.setSelected(GroovyApplicationSettings.getInstance().FORCE_RETURN);
    } else {
        myForceReturnCheckBox.setEnabled(false);
        myForceReturnCheckBox.setSelected(false);
    }
}
Also used : ChangeEvent(javax.swing.event.ChangeEvent) ChangeListener(javax.swing.event.ChangeListener)

Example 12 with ChangeListener

use of javax.swing.event.ChangeListener in project intellij-community by JetBrains.

the class GroovyExtractMethodDialog method createUIComponents.

private void createUIComponents() {
    mySignature = new GrMethodSignatureComponent("", myProject);
    mySignature.setPreferredSize(JBUI.size(500, 100));
    mySignature.setMinimumSize(JBUI.size(500, 100));
    mySignature.setBorder(IdeBorderFactory.createTitledBorder(GroovyRefactoringBundle.message("signature.preview.border.title"), false));
    mySignature.setFocusable(false);
    myNameField = new EditorTextField("", myProject, GroovyFileType.GROOVY_FILE_TYPE);
    myVisibilityPanel = new GroovyComboboxVisibilityPanel();
    String visibility = GroovyApplicationSettings.getInstance().EXTRACT_METHOD_VISIBILITY;
    if (visibility == null) {
        visibility = PsiModifier.PRIVATE;
    }
    myVisibilityPanel.setVisibility(visibility);
    myVisibilityPanel.addListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            myHelper.setVisibility(myVisibilityPanel.getVisibility());
            updateSignature();
        }
    });
    myParameterTablePanel = new GrParameterTablePanel() {

        @Override
        protected void updateSignature() {
            GroovyExtractMethodDialog.this.updateSignature();
        }

        @Override
        protected void doEnterAction() {
            GroovyExtractMethodDialog.this.clickDefaultButton();
        }

        @Override
        protected void doCancelAction() {
            GroovyExtractMethodDialog.this.doCancelAction();
        }
    };
}
Also used : GrMethodSignatureComponent(org.jetbrains.plugins.groovy.refactoring.ui.GrMethodSignatureComponent) ChangeEvent(javax.swing.event.ChangeEvent) GrParameterTablePanel(org.jetbrains.plugins.groovy.refactoring.extract.GrParameterTablePanel) EditorTextField(com.intellij.ui.EditorTextField) ChangeListener(javax.swing.event.ChangeListener) GroovyComboboxVisibilityPanel(org.jetbrains.plugins.groovy.refactoring.ui.GroovyComboboxVisibilityPanel)

Example 13 with ChangeListener

use of javax.swing.event.ChangeListener in project intellij-community by JetBrains.

the class FormLayoutColumnProperties method updateSpec.

private void updateSpec() {
    if (myLayout == null || myShowing)
        return;
    mySaving = true;
    try {
        Size size = getSelectedSize();
        final SpinnerNumberModel model = (SpinnerNumberModel) myGrowSpinner.getModel();
        double resizeWeight = myGrowCheckBox.isSelected() ? model.getNumber().doubleValue() : 0.0;
        FormSpec.DefaultAlignment alignment = getSelectedAlignment();
        if (myIsRow) {
            myLayout.setRowSpec(myIndex, new RowSpec(alignment, size, resizeWeight));
        } else {
            myLayout.setColumnSpec(myIndex, new ColumnSpec(alignment, size, resizeWeight));
        }
        for (ChangeListener listener : myListeners) {
            listener.stateChanged(new ChangeEvent(this));
        }
    } finally {
        mySaving = false;
    }
}
Also used : ChangeEvent(javax.swing.event.ChangeEvent) ChangeListener(javax.swing.event.ChangeListener)

Example 14 with ChangeListener

use of javax.swing.event.ChangeListener in project intellij-community by JetBrains.

the class DebuggerDataViewsConfigurable method createComponent.

@Override
public JComponent createComponent() {
    if (myProject == null) {
        myProject = JavaDebuggerSupport.getContextProjectForEditorFieldsInDebuggerConfigurables();
    }
    final JPanel panel = new JPanel(new GridBagLayout());
    myCbAutoscroll = new JCheckBox(DebuggerBundle.message("label.base.renderer.configurable.autoscroll"));
    myCbShowSyntheticFields = new JCheckBox(DebuggerBundle.message("label.base.renderer.configurable.show.synthetic.fields"));
    myCbShowValFieldsAsLocalVariables = new StateRestoringCheckBox(DebuggerBundle.message("label.base.renderer.configurable.show.val.fields.as.locals"));
    myCbHideNullArrayElements = new JCheckBox(DebuggerBundle.message("label.base.renderer.configurable.hide.null.array.elements"));
    myCbShowStatic = new JCheckBox(DebuggerBundle.message("label.base.renderer.configurable.show.static.fields"));
    myCbShowStaticFinalFields = new StateRestoringCheckBox(DebuggerBundle.message("label.base.renderer.configurable.show.static.final.fields"));
    myCbEnableAlternateViews = new JCheckBox(DebuggerBundle.message("label.base.renderer.configurable.alternate.view"));
    myCbShowStatic.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            if (myCbShowStatic.isSelected()) {
                myCbShowStaticFinalFields.makeSelectable();
            } else {
                myCbShowStaticFinalFields.makeUnselectable(false);
            }
        }
    });
    myCbShowSyntheticFields.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            if (myCbShowSyntheticFields.isSelected()) {
                myCbShowValFieldsAsLocalVariables.makeSelectable();
            } else {
                myCbShowValFieldsAsLocalVariables.makeUnselectable(false);
            }
        }
    });
    myCbShowDeclaredType = new JCheckBox(DebuggerBundle.message("label.base.renderer.configurable.show.declared.type"));
    myCbShowFQNames = new JCheckBox(DebuggerBundle.message("label.base.renderer.configurable.show.fq.names"));
    myCbShowObjectId = new JCheckBox(DebuggerBundle.message("label.base.renderer.configurable.show.object.id"));
    myCbHexValue = new JCheckBox(DebuggerBundle.message("label.base.renderer.configurable.show.hex.value"));
    myCbShowStringsType = new JCheckBox(DebuggerBundle.message("label.base.renderer.configurable.show.strings.type"));
    myCbEnableToString = new JCheckBox(DebuggerBundle.message("label.base.renderer.configurable.enable.toString"));
    myRbAllThatOverride = new JRadioButton(DebuggerBundle.message("label.base.renderer.configurable.all.overriding"));
    myRbFromList = new JRadioButton(DebuggerBundle.message("label.base.renderer.configurable.classes.from.list"));
    ButtonGroup group = new ButtonGroup();
    group.add(myRbAllThatOverride);
    group.add(myRbFromList);
    myToStringFilterEditor = new ClassFilterEditor(myProject, null, "reference.viewBreakpoints.classFilters.newPattern");
    myCbEnableToString.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            final boolean enabled = myCbEnableToString.isSelected();
            myRbAllThatOverride.setEnabled(enabled);
            myRbFromList.setEnabled(enabled);
            myToStringFilterEditor.setEnabled(enabled && myRbFromList.isSelected());
        }
    });
    myRbFromList.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            myToStringFilterEditor.setEnabled(myCbEnableToString.isSelected() && myRbFromList.isSelected());
        }
    });
    panel.add(myCbAutoscroll, new GridBagConstraints(0, RELATIVE, 1, 1, 0.0, 0.0, WEST, NONE, JBUI.insetsTop(4), 0, 0));
    final JPanel showPanel = new JPanel(new GridBagLayout());
    showPanel.setBorder(IdeBorderFactory.createTitledBorder("Show", true));
    showPanel.add(myCbShowDeclaredType, new GridBagConstraints(0, RELATIVE, 1, 1, 0.0, 0.0, WEST, NONE, JBUI.emptyInsets(), 0, 0));
    showPanel.add(myCbShowObjectId, new GridBagConstraints(0, RELATIVE, 1, 1, 0.0, 0.0, WEST, NONE, JBUI.insetsTop(4), 0, 0));
    showPanel.add(myCbShowSyntheticFields, new GridBagConstraints(1, RELATIVE, 1, 1, 0.0, 0.0, WEST, NONE, JBUI.insetsLeft(10), 0, 0));
    showPanel.add(myCbShowStatic, new GridBagConstraints(1, RELATIVE, 1, 1, 0.0, 0.0, WEST, NONE, JBUI.insets(4, 10, 0, 0), 0, 0));
    showPanel.add(myCbShowValFieldsAsLocalVariables, new GridBagConstraints(2, RELATIVE, 1, 1, 0.0, 0.0, WEST, NONE, JBUI.insets(4, 10, 0, 0), 0, 0));
    showPanel.add(myCbShowStaticFinalFields, new GridBagConstraints(2, RELATIVE, 1, 1, 0.0, 0.0, WEST, NONE, JBUI.insets(4, 10, 0, 0), 0, 0));
    showPanel.add(myCbShowFQNames, new GridBagConstraints(3, RELATIVE, 1, 1, 1.0, 0.0, WEST, NONE, JBUI.insetsLeft(10), 0, 0));
    panel.add(showPanel, new GridBagConstraints(0, RELATIVE, 3, 1, 1.0, 0.0, WEST, HORIZONTAL, JBUI.insetsTop(4), 0, 0));
    //final JPanel arraysPanel = new JPanel(new BorderLayout(0, UIUtil.DEFAULT_VGAP));
    //final JComponent arraysComponent = myArrayRendererConfigurable.createComponent();
    //assert arraysComponent != null;
    //arraysPanel.add(arraysComponent, BorderLayout.CENTER);
    //arraysPanel.add(myCbHideNullArrayElements, BorderLayout.SOUTH);
    //arraysPanel.setBorder(IdeBorderFactory.createTitledBorder("Arrays", true));
    //panel.add(arraysPanel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 3, 1, 1.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
    panel.add(myCbShowStringsType, new GridBagConstraints(0, RELATIVE, 3, 1, 1.0, 0.0, NORTH, HORIZONTAL, JBUI.emptyInsets(), 0, 0));
    panel.add(myCbHexValue, new GridBagConstraints(0, RELATIVE, 3, 1, 1.0, 0.0, NORTH, HORIZONTAL, JBUI.insetsTop(4), 0, 0));
    panel.add(myCbHideNullArrayElements, new GridBagConstraints(0, RELATIVE, 3, 1, 1.0, 0.0, NORTH, HORIZONTAL, JBUI.insetsTop(4), 0, 0));
    panel.add(myCbEnableAlternateViews, new GridBagConstraints(0, RELATIVE, 1, 1, 0.0, 0.0, WEST, NONE, JBUI.insets(4, 0, 0, 10), 0, 0));
    // starting 4-th row
    panel.add(myCbEnableToString, new GridBagConstraints(0, RELATIVE, 3, 1, 1.0, 0.0, WEST, NONE, JBUI.insetsTop(4), 0, 0));
    panel.add(myRbAllThatOverride, new GridBagConstraints(0, RELATIVE, 3, 1, 1.0, 0.0, WEST, NONE, JBUI.insetsLeft(12), 0, 0));
    panel.add(myRbFromList, new GridBagConstraints(0, RELATIVE, 3, 1, 1.0, 0.0, WEST, NONE, JBUI.insetsLeft(12), 0, 0));
    myToStringFilterEditor.setMinimumSize(JBUI.size(50, 100));
    panel.add(myToStringFilterEditor, new GridBagConstraints(0, RELATIVE, 3, 1, 1.0, 1.0, CENTER, BOTH, JBUI.insetsLeft(12), 0, 0));
    return panel;
}
Also used : ItemEvent(java.awt.event.ItemEvent) GridBagConstraints(java.awt.GridBagConstraints) ClassFilterEditor(com.intellij.ui.classFilter.ClassFilterEditor) ChangeEvent(javax.swing.event.ChangeEvent) StateRestoringCheckBox(com.intellij.ui.StateRestoringCheckBox) ChangeListener(javax.swing.event.ChangeListener) ItemListener(java.awt.event.ItemListener)

Example 15 with ChangeListener

use of javax.swing.event.ChangeListener in project intellij-community by JetBrains.

the class SetBackgroundImageDialog method setupComponents.

private void setupComponents() {
    myAdjusting = true;
    myPreviewPanel.setLayout(new CardLayout());
    myPreviewPanel.add(myEditorPreview.getPanel(), "editor");
    myPreviewPanel.add(myIdePreview, "ide");
    ((CardLayout) myPreviewPanel.getLayout()).show(myPreviewPanel, "editor");
    myPathField.getComboBox().setEditable(true);
    FileChooserDescriptor descriptor = new FileChooserDescriptor(true, false, false, false, true, false).withFileFilter(file -> ImageFileTypeManager.getInstance().isImage(file));
    myPathField.addBrowseFolderListener(null, null, null, descriptor, TextComponentAccessor.STRING_COMBOBOX_WHOLE_TEXT);
    JTextComponent textComponent = getComboEditor();
    textComponent.getDocument().addDocumentListener(new DocumentAdapter() {

        @Override
        protected void textChanged(DocumentEvent e) {
            if (myAdjusting)
                return;
            imagePathChanged();
        }
    });
    for (Enumeration<AbstractButton> e = getTargetRbGroup().getElements(); e.hasMoreElements(); ) {
        AbstractButton button = e.nextElement();
        button.setActionCommand(button.getText());
        button.addItemListener(this::targetChanged);
    }
    for (Enumeration<AbstractButton> e = getFillRbGroup().getElements(); e.hasMoreElements(); ) {
        AbstractButton button = e.nextElement();
        button.setActionCommand(button.getText());
        button.addItemListener(this::fillOrPlaceChanged);
    }
    for (Enumeration<AbstractButton> e = getPlaceRbGroup().getElements(); e.hasMoreElements(); ) {
        AbstractButton button = e.nextElement();
        button.setActionCommand(button.getText());
        button.addItemListener(this::fillOrPlaceChanged);
    }
    ChangeListener opacitySync = new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            if (myAdjusting)
                return;
            myAdjusting = true;
            boolean b = e.getSource() == myOpacitySpinner;
            if (b) {
                int value = (Integer) myOpacitySpinner.getValue();
                myOpacitySpinner.setValue(Math.min(Math.max(0, value), 100));
                myOpacitySlider.setValue(value);
            } else {
                myOpacitySpinner.setValue(myOpacitySlider.getValue());
            }
            myAdjusting = false;
            opacityChanged();
        }
    };
    myOpacitySpinner.addChangeListener(opacitySync);
    myOpacitySlider.addChangeListener(opacitySync);
    myOpacitySlider.setValue(15);
    myOpacitySpinner.setValue(15);
    myScaleRb.setSelected(true);
    myCenterRb.setSelected(true);
    myEditorRb.setSelected(true);
    boolean perProject = !Comparing.equal(getBackgroundSpec(myProject, getSystemProp(true)), getBackgroundSpec(null, getSystemProp(true)));
    myThisProjectOnlyCb.setSelected(perProject);
    myAdjusting = false;
}
Also used : FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) DocumentAdapter(com.intellij.ui.DocumentAdapter) JTextComponent(javax.swing.text.JTextComponent) DocumentEvent(javax.swing.event.DocumentEvent) ChangeEvent(javax.swing.event.ChangeEvent) ChangeListener(javax.swing.event.ChangeListener)

Aggregations

ChangeListener (javax.swing.event.ChangeListener)472 ChangeEvent (javax.swing.event.ChangeEvent)449 ActionEvent (java.awt.event.ActionEvent)170 ActionListener (java.awt.event.ActionListener)164 Dimension (java.awt.Dimension)160 JPanel (javax.swing.JPanel)136 Point (java.awt.Point)108 JLabel (javax.swing.JLabel)98 JSlider (javax.swing.JSlider)69 JButton (javax.swing.JButton)66 JCheckBox (javax.swing.JCheckBox)55 MouseEvent (java.awt.event.MouseEvent)47 BorderLayout (java.awt.BorderLayout)46 GridBagConstraints (java.awt.GridBagConstraints)42 GridBagLayout (java.awt.GridBagLayout)39 MouseAdapter (java.awt.event.MouseAdapter)39 Insets (java.awt.Insets)37 PropertyChangeListener (java.beans.PropertyChangeListener)35 PropertyChangeEvent (java.beans.PropertyChangeEvent)34 ItemEvent (java.awt.event.ItemEvent)33