Search in sources :

Example 46 with ChangeListener

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

the class AppearanceConfigurable method createComponent.

@SuppressWarnings("unchecked")
@Override
public JComponent createComponent() {
    UISettings settings = UISettings.getInstance();
    initComponent();
    myComponent.myFontSizeCombo.setModel(new DefaultComboBoxModel(UIUtil.getStandardFontSizes()));
    myComponent.myPresentationModeFontSize.setModel(new DefaultComboBoxModel(UIUtil.getStandardFontSizes()));
    myComponent.myFontSizeCombo.setEditable(true);
    myComponent.myPresentationModeFontSize.setEditable(true);
    myComponent.myLafComboBox.setModel(new DefaultComboBoxModel(LafManager.getInstance().getInstalledLookAndFeels()));
    myComponent.myLafComboBox.setRenderer(new LafComboBoxRenderer());
    myComponent.myAntialiasingInIDE.setModel(new DefaultComboBoxModel(AntialiasingType.values()));
    myComponent.myAntialiasingInEditor.setModel(new DefaultComboBoxModel(AntialiasingType.values()));
    myComponent.myAntialiasingInIDE.setSelectedItem(settings.getIdeAAType());
    myComponent.myAntialiasingInEditor.setSelectedItem(settings.getEditorAAType());
    myComponent.myAntialiasingInIDE.setRenderer(new AAListCellRenderer(false));
    myComponent.myAntialiasingInEditor.setRenderer(new AAListCellRenderer(true));
    @SuppressWarnings("UseOfObsoleteCollectionType") Dictionary<Integer, JComponent> delayDictionary = new Hashtable<>();
    delayDictionary.put(new Integer(0), new JLabel("0"));
    delayDictionary.put(new Integer(1200), new JLabel("1200"));
    //delayDictionary.put(new Integer(2400), new JLabel("2400"));
    myComponent.myInitialTooltipDelaySlider.setLabelTable(delayDictionary);
    UIUtil.setSliderIsFilled(myComponent.myInitialTooltipDelaySlider, Boolean.TRUE);
    myComponent.myInitialTooltipDelaySlider.setMinimum(0);
    myComponent.myInitialTooltipDelaySlider.setMaximum(1200);
    myComponent.myInitialTooltipDelaySlider.setPaintLabels(true);
    myComponent.myInitialTooltipDelaySlider.setPaintTicks(true);
    myComponent.myInitialTooltipDelaySlider.setPaintTrack(true);
    myComponent.myInitialTooltipDelaySlider.setMajorTickSpacing(1200);
    myComponent.myInitialTooltipDelaySlider.setMinorTickSpacing(100);
    myComponent.myEnableAlphaModeCheckBox.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            boolean state = myComponent.myEnableAlphaModeCheckBox.isSelected();
            myComponent.myAlphaModeDelayTextField.setEnabled(state);
            myComponent.myAlphaModeRatioSlider.setEnabled(state);
        }
    });
    myComponent.myAlphaModeRatioSlider.setSize(100, 50);
    @SuppressWarnings({ "UseOfObsoleteCollectionType" }) Dictionary<Integer, JComponent> dictionary = new Hashtable<>();
    dictionary.put(new Integer(0), new JLabel("0%"));
    dictionary.put(new Integer(50), new JLabel("50%"));
    dictionary.put(new Integer(100), new JLabel("100%"));
    myComponent.myAlphaModeRatioSlider.setLabelTable(dictionary);
    UIUtil.setSliderIsFilled(myComponent.myAlphaModeRatioSlider, Boolean.TRUE);
    myComponent.myAlphaModeRatioSlider.setPaintLabels(true);
    myComponent.myAlphaModeRatioSlider.setPaintTicks(true);
    myComponent.myAlphaModeRatioSlider.setPaintTrack(true);
    myComponent.myAlphaModeRatioSlider.setMajorTickSpacing(50);
    myComponent.myAlphaModeRatioSlider.setMinorTickSpacing(10);
    myComponent.myAlphaModeRatioSlider.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            myComponent.myAlphaModeRatioSlider.setToolTipText(myComponent.myAlphaModeRatioSlider.getValue() + "%");
        }
    });
    myComponent.myTransparencyPanel.setVisible(WindowManagerEx.getInstanceEx().isAlphaModeSupported());
    return myComponent.myPanel;
}
Also used : Hashtable(java.util.Hashtable) ActionEvent(java.awt.event.ActionEvent) ActionListener(java.awt.event.ActionListener) ChangeEvent(javax.swing.event.ChangeEvent) ChangeListener(javax.swing.event.ChangeListener)

Example 47 with ChangeListener

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

the class UnnecessaryFinalOnLocalVariableOrParameterInspection method createOptionsPanel.

@Override
@Nullable
public JComponent createOptionsPanel() {
    final JPanel panel = new JPanel(new GridBagLayout());
    final JCheckBox abstractOnlyCheckBox = new JCheckBox(InspectionGadgetsBundle.message("unnecessary.final.on.parameter.only.interface.option"), onlyWarnOnAbstractMethods) {

        @Override
        public void setEnabled(boolean b) {
            // inspection settings (otherwise it is always enabled)
            if (b) {
                super.setEnabled(reportParameters);
            } else {
                super.setEnabled(false);
            }
        }
    };
    abstractOnlyCheckBox.setEnabled(true);
    abstractOnlyCheckBox.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            onlyWarnOnAbstractMethods = abstractOnlyCheckBox.isSelected();
        }
    });
    final JCheckBox reportLocalVariablesCheckBox = new JCheckBox(InspectionGadgetsBundle.message("unnecessary.final.report.local.variables.option"), reportLocalVariables);
    final JCheckBox reportParametersCheckBox = new JCheckBox(InspectionGadgetsBundle.message("unnecessary.final.report.parameters.option"), reportParameters);
    reportLocalVariablesCheckBox.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            reportLocalVariables = reportLocalVariablesCheckBox.isSelected();
            if (!reportLocalVariables) {
                reportParametersCheckBox.setSelected(true);
            }
        }
    });
    reportParametersCheckBox.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            reportParameters = reportParametersCheckBox.isSelected();
            if (!reportParameters) {
                reportLocalVariablesCheckBox.setSelected(true);
            }
            abstractOnlyCheckBox.setEnabled(reportParameters);
        }
    });
    final GridBagConstraints constraints = new GridBagConstraints();
    constraints.anchor = GridBagConstraints.NORTHWEST;
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.weightx = 1.0;
    panel.add(reportLocalVariablesCheckBox, constraints);
    constraints.gridy = 1;
    panel.add(reportParametersCheckBox, constraints);
    constraints.insets.left = 20;
    constraints.gridy = 2;
    constraints.weighty = 1.0;
    panel.add(abstractOnlyCheckBox, constraints);
    return panel;
}
Also used : ChangeEvent(javax.swing.event.ChangeEvent) ChangeListener(javax.swing.event.ChangeListener) Nullable(org.jetbrains.annotations.Nullable)

Example 48 with ChangeListener

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

the class IdeErrorsDialog method createCenterPanel.

@Override
protected JComponent createCenterPanel() {
    DefaultActionGroup goBack = new DefaultActionGroup();
    BackAction back = new BackAction();
    goBack.add(back);
    ActionToolbar backToolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, goBack, true);
    backToolbar.getComponent().setBorder(IdeBorderFactory.createEmptyBorder());
    backToolbar.setLayoutPolicy(ActionToolbar.NOWRAP_LAYOUT_POLICY);
    myBackButtonPanel.add(backToolbar.getComponent(), BorderLayout.CENTER);
    DefaultActionGroup goForward = new DefaultActionGroup();
    ForwardAction forward = new ForwardAction();
    goForward.add(forward);
    ActionToolbar forwardToolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, goForward, true);
    forwardToolbar.setLayoutPolicy(ActionToolbar.NOWRAP_LAYOUT_POLICY);
    forwardToolbar.getComponent().setBorder(IdeBorderFactory.createEmptyBorder());
    myNextButtonPanel.add(forwardToolbar.getComponent(), BorderLayout.CENTER);
    myTabs = new HeaderlessTabbedPane(getDisposable());
    final LabeledTextComponent.TextListener commentsListener = new LabeledTextComponent.TextListener() {

        @Override
        public void textChanged(String newText) {
            if (myMute) {
                return;
            }
            AbstractMessage message = getSelectedMessage();
            if (message != null) {
                message.setAdditionalInfo(newText);
            }
        }
    };
    if (!myInternalMode) {
        myDetailsTabForm = new DetailsTabForm(null, false);
        myCommentsTabForm = new CommentsTabForm();
        myCommentsTabForm.addCommentsListener(commentsListener);
        myTabs.addTab(DiagnosticBundle.message("error.comments.tab.title"), myCommentsTabForm.getContentPane());
        myDetailsTabForm.setCommentsAreaVisible(false);
    } else {
        final AnAction analyzePlatformAction = ActionManager.getInstance().getAction("AnalyzeStacktraceOnError");
        if (analyzePlatformAction != null) {
            myAnalyzeAction = new AnalyzeAction(analyzePlatformAction);
        }
        myDetailsTabForm = new DetailsTabForm(myAnalyzeAction, true);
        myDetailsTabForm.setCommentsAreaVisible(true);
        myDetailsTabForm.addCommentsListener(commentsListener);
    }
    myTabs.addTab(DiagnosticBundle.message("error.details.tab.title"), myDetailsTabForm.getContentPane());
    myAttachmentsTabForm = new AttachmentsTabForm();
    myAttachmentsTabForm.addInclusionListener(new ChangeListener() {

        @Override
        public void stateChanged(final ChangeEvent e) {
            updateAttachmentWarning(getSelectedMessage());
        }
    });
    int activeTabIndex = Integer.parseInt(PropertiesComponent.getInstance().getValue(ACTIVE_TAB_OPTION, "0"));
    if (activeTabIndex >= myTabs.getTabCount() || activeTabIndex < 0) {
        // may happen if myInternalMode changed since last open
        activeTabIndex = 0;
    }
    myTabs.setSelectedIndex(activeTabIndex);
    myTabs.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            final JComponent c = getPreferredFocusedComponent();
            if (c != null) {
                IdeFocusManager.findInstanceByComponent(myContentPane).requestFocus(c, true);
            }
        }
    });
    myTabsPanel.add(myTabs, BorderLayout.CENTER);
    myDisableLink.setHyperlinkText(UIUtil.removeMnemonic(DiagnosticBundle.message("error.list.disable.plugin")));
    myDisableLink.addHyperlinkListener(new HyperlinkListener() {

        @Override
        public void hyperlinkUpdate(HyperlinkEvent e) {
            if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                disablePlugin();
            }
        }
    });
    myCredentialsLabel.addHyperlinkListener(new HyperlinkListener() {

        @Override
        public void hyperlinkUpdate(HyperlinkEvent e) {
            if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                JetBrainsAccountDialogKt.showJetBrainsAccountDialog(getRootPane()).show();
                updateCredentialsPane(getSelectedMessage());
            }
        }
    });
    myAttachmentWarningLabel.setIcon(UIUtil.getBalloonWarningIcon());
    myAttachmentWarningLabel.addHyperlinkListener(new HyperlinkListener() {

        @Override
        public void hyperlinkUpdate(final HyperlinkEvent e) {
            if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                myTabs.setSelectedIndex(myTabs.indexOfComponent(myAttachmentsTabForm.getContentPane()));
                myAttachmentsTabForm.selectFirstIncludedAttachment();
            }
        }
    });
    myDetailsTabForm.addAssigneeListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (myMute)
                return;
            AbstractMessage message = getSelectedMessage();
            if (message != null) {
                message.setAssigneeId(myDetailsTabForm.getAssigneeId());
            }
        }
    });
    return myContentPane;
}
Also used : HyperlinkEvent(javax.swing.event.HyperlinkEvent) ActionEvent(java.awt.event.ActionEvent) HeaderlessTabbedPane(com.intellij.ui.HeaderlessTabbedPane) ChangeEvent(javax.swing.event.ChangeEvent) ActionListener(java.awt.event.ActionListener) HyperlinkListener(javax.swing.event.HyperlinkListener) ChangeListener(javax.swing.event.ChangeListener)

Example 49 with ChangeListener

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

the class AirPackageDialog method createUIComponents.

private void createUIComponents() {
    myTree = new FlexBCTree(myProject, bc -> {
        final BuildConfigurationNature nature = bc.getNature();
        return nature.isApp() && !nature.isWebPlatform();
    });
    myTree.addToggleCheckBoxListener(new ChangeListener() {

        public void stateChanged(final ChangeEvent e) {
            updateControlsEnabledState();
        }
    });
}
Also used : UIUtil(com.intellij.util.ui.UIUtil) ActionListener(java.awt.event.ActionListener) TargetPlatform(com.intellij.flex.model.bc.TargetPlatform) ArrayList(java.util.ArrayList) FlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration) DialogWrapper(com.intellij.openapi.ui.DialogWrapper) Project(com.intellij.openapi.project.Project) Messages(com.intellij.openapi.ui.Messages) ChangeListener(javax.swing.event.ChangeListener) Module(com.intellij.openapi.module.Module) ProjectStructureProblemType(com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureProblemType) ValidationInfo(com.intellij.openapi.ui.ValidationInfo) ChangeEvent(javax.swing.event.ChangeEvent) StringUtil(com.intellij.openapi.util.text.StringUtil) Collection(java.util.Collection) FlexBCTree(com.intellij.lang.javascript.flex.actions.FlexBCTree) FlexBundle(com.intellij.lang.javascript.flex.FlexBundle) ValidateFlashConfigurationsPrecompileTask(com.intellij.lang.javascript.flex.build.ValidateFlashConfigurationsPrecompileTask) ActionEvent(java.awt.event.ActionEvent) LocalFileSystem(com.intellij.openapi.vfs.LocalFileSystem) BuildConfigurationNature(com.intellij.flex.model.bc.BuildConfigurationNature) FlashProjectStructureProblem(com.intellij.lang.javascript.flex.build.FlashProjectStructureProblem) AirPackageProjectParameters(com.intellij.lang.javascript.flex.actions.airpackage.AirPackageProjectParameters) AirPackagingOptions(com.intellij.lang.javascript.flex.projectStructure.model.AirPackagingOptions) Pair(com.intellij.openapi.util.Pair) Ref(com.intellij.openapi.util.Ref) Consumer(com.intellij.util.Consumer) Condition(com.intellij.openapi.util.Condition) javax.swing(javax.swing) BuildConfigurationNature(com.intellij.flex.model.bc.BuildConfigurationNature) ChangeEvent(javax.swing.event.ChangeEvent) FlexBCTree(com.intellij.lang.javascript.flex.actions.FlexBCTree) ChangeListener(javax.swing.event.ChangeListener)

Example 50 with ChangeListener

use of javax.swing.event.ChangeListener in project ChatGameFontificator by GlitchCog.

the class MessageCensorPanel method build.

@Override
protected void build() {
    setBorder(new TitledBorder(ControlPanelBase.getBaseBorder(), "Message Censorship Configuration", TitledBorder.CENTER, TitledBorder.TOP));
    setLayout(new GridBagLayout());
    GridBagConstraints gbc = ControlPanelBase.getGbc();
    enableCensorshipBox = new JCheckBox("Enable message censoring");
    purgeOnTwitchBanBox = new JCheckBox("Purge messages on Twitch ban/timeout");
    censorAllUrlsBox = new JCheckBox("Censor all messages containing URLs");
    censorFirstPostUrlsBox = new JCheckBox("Censor messages containing URLs in a user's initial post");
    censorUnknownCharsBox = new JCheckBox("Censor messages containing a specified percentage of extended characters:");
    final String minLabel = "> 0";
    // @formatter:off
    unknownCharSlider = new LabeledSlider("", "%", ConfigCensor.MIN_UNKNOWN_CHAR_PCT, ConfigCensor.MAX_UNKNOWN_CHAR_PCT, Math.max(Math.max(Integer.toString(ConfigCensor.MIN_UNKNOWN_CHAR_PCT).length(), Integer.toString(ConfigCensor.MAX_UNKNOWN_CHAR_PCT).length()), minLabel.length())) {

        // @formatter:on
        private static final long serialVersionUID = 1L;

        @Override
        public String getValueString() {
            if (getValue() == slider.getMinimum()) {
                return minLabel;
            } else {
                return super.getValueString();
            }
        }
    };
    userWhitelist = new ListInput("User Whitelist", "Exempt from all censorship", this);
    userBlacklist = new ListInput("User Blacklist", "Every message censored", this);
    bannedWordList = new ListInput("Banned Words", "Containing censors message", this);
    ActionListener bl = new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            updateConfig();
            chat.repaint();
            chat.initMessageRollout();
        }
    };
    enableCensorshipBox.addActionListener(bl);
    purgeOnTwitchBanBox.addActionListener(bl);
    censorAllUrlsBox.addActionListener(bl);
    censorFirstPostUrlsBox.addActionListener(bl);
    censorUnknownCharsBox.addActionListener(bl);
    unknownCharSlider.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            config.setUnknownCharPercentage(unknownCharSlider.getValue());
        }
    });
    messageList = new MessageCheckList(chat, this);
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.weightx = 1.0;
    gbc.weighty = 0.0;
    gbc.gridwidth = 3;
    add(new JLabel("Censorship rules affect the visualization only; they don't influence the visibility of IRC posts."), gbc);
    gbc.gridy++;
    add(enableCensorshipBox, gbc);
    gbc.gridy++;
    add(purgeOnTwitchBanBox, gbc);
    gbc.gridy++;
    add(censorAllUrlsBox, gbc);
    gbc.gridy++;
    add(censorFirstPostUrlsBox, gbc);
    gbc.gridy++;
    JPanel unknownPanel = new JPanel(new GridBagLayout());
    GridBagConstraints uGbc = getGbc();
    uGbc.anchor = GridBagConstraints.WEST;
    uGbc.weightx = 1.0;
    uGbc.fill = GridBagConstraints.NONE;
    unknownPanel.add(censorUnknownCharsBox, uGbc);
    uGbc.gridy++;
    uGbc.anchor = GridBagConstraints.EAST;
    uGbc.weightx = 1.0;
    uGbc.weighty = 1.0;
    uGbc.fill = GridBagConstraints.BOTH;
    unknownPanel.add(unknownCharSlider, uGbc);
    add(unknownPanel, gbc);
    gbc.gridy++;
    gbc.weightx = 0.33;
    gbc.gridwidth = 1;
    add(userWhitelist, gbc);
    gbc.gridx++;
    add(userBlacklist, gbc);
    gbc.gridx++;
    add(bannedWordList, gbc);
    gbc.gridx++;
    gbc.gridy++;
    gbc.gridx = 0;
    gbc.gridwidth = 3;
    gbc.weightx = 1.0;
    gbc.weighty = 1.0;
    gbc.fill = GridBagConstraints.BOTH;
    add(messageList, gbc);
    gbc.gridy++;
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) GridBagLayout(java.awt.GridBagLayout) ActionEvent(java.awt.event.ActionEvent) JLabel(javax.swing.JLabel) TitledBorder(javax.swing.border.TitledBorder) ListInput(com.glitchcog.fontificator.gui.component.ListInput) JCheckBox(javax.swing.JCheckBox) LabeledSlider(com.glitchcog.fontificator.gui.component.LabeledSlider) ActionListener(java.awt.event.ActionListener) ChangeEvent(javax.swing.event.ChangeEvent) MessageCheckList(com.glitchcog.fontificator.gui.controls.messages.MessageCheckList) ChangeListener(javax.swing.event.ChangeListener)

Aggregations

ChangeListener (javax.swing.event.ChangeListener)218 ChangeEvent (javax.swing.event.ChangeEvent)205 JPanel (javax.swing.JPanel)54 ActionEvent (java.awt.event.ActionEvent)47 ActionListener (java.awt.event.ActionListener)46 JLabel (javax.swing.JLabel)34 Dimension (java.awt.Dimension)29 GridBagConstraints (java.awt.GridBagConstraints)27 GridBagLayout (java.awt.GridBagLayout)24 JCheckBox (javax.swing.JCheckBox)24 Insets (java.awt.Insets)21 JSlider (javax.swing.JSlider)20 PropertyChangeListener (java.beans.PropertyChangeListener)19 JButton (javax.swing.JButton)19 BorderLayout (java.awt.BorderLayout)17 PropertyChangeEvent (java.beans.PropertyChangeEvent)17 IOException (java.io.IOException)14 BoxLayout (javax.swing.BoxLayout)14 ButtonGroup (javax.swing.ButtonGroup)14 JSpinner (javax.swing.JSpinner)13