Search in sources :

Example 76 with JBLabel

use of com.intellij.ui.components.JBLabel in project intellij-community by JetBrains.

the class GroovyLanguageCodeStyleSettingsProvider method getIndentOptionsEditor.

@Override
public IndentOptionsEditor getIndentOptionsEditor() {
    return new SmartIndentOptionsEditor() {

        private JTextField myLabelIndent;

        private JLabel myLabelIndentLabel;

        private JComboBox myLabelIndentStyle;

        private JBLabel myStyleLabel;

        @Override
        protected void addComponents() {
            super.addComponents();
            myLabelIndent = new JTextField(4);
            add(myLabelIndentLabel = new JLabel(ApplicationBundle.message("editbox.indent.label.indent")), myLabelIndent);
            myStyleLabel = new JBLabel("Label indent style:");
            myLabelIndentStyle = new JComboBox(new Object[] { ABSOLUTE, RELATIVE, RELATIVE_REVERSED });
            add(myStyleLabel, myLabelIndentStyle);
        }

        @Override
        public boolean isModified(final CodeStyleSettings settings, final CommonCodeStyleSettings.IndentOptions options) {
            boolean isModified = super.isModified(settings, options);
            isModified |= isFieldModified(myLabelIndent, options.LABEL_INDENT_SIZE);
            isModified |= isLabelStyleModified(options.LABEL_INDENT_ABSOLUTE, settings.getCustomSettings(GroovyCodeStyleSettings.class).INDENT_LABEL_BLOCKS);
            return isModified;
        }

        private boolean isLabelStyleModified(boolean absolute, boolean relative) {
            if (absolute) {
                return !ABSOLUTE.equals(myLabelIndentStyle.getSelectedItem());
            } else if (relative) {
                return !RELATIVE.equals(myLabelIndentStyle.getSelectedItem());
            } else {
                return !RELATIVE_REVERSED.equals(myLabelIndentStyle.getSelectedItem());
            }
        }

        @Override
        public void apply(final CodeStyleSettings settings, final CommonCodeStyleSettings.IndentOptions options) {
            super.apply(settings, options);
            options.LABEL_INDENT_SIZE = getFieldValue(myLabelIndent, Integer.MIN_VALUE, options.LABEL_INDENT_SIZE);
            options.LABEL_INDENT_ABSOLUTE = ABSOLUTE.equals(myLabelIndentStyle.getSelectedItem());
            settings.getCustomSettings(GroovyCodeStyleSettings.class).INDENT_LABEL_BLOCKS = RELATIVE.equals(myLabelIndentStyle.getSelectedItem());
        }

        @Override
        public void reset(@NotNull final CodeStyleSettings settings, @NotNull final CommonCodeStyleSettings.IndentOptions options) {
            super.reset(settings, options);
            myLabelIndent.setText(Integer.toString(options.LABEL_INDENT_SIZE));
            if (options.LABEL_INDENT_ABSOLUTE) {
                myLabelIndentStyle.setSelectedItem(ABSOLUTE);
            } else if (settings.getCustomSettings(GroovyCodeStyleSettings.class).INDENT_LABEL_BLOCKS) {
                myLabelIndentStyle.setSelectedItem(RELATIVE);
            } else {
                myLabelIndentStyle.setSelectedItem(RELATIVE_REVERSED);
            }
        }

        @Override
        public void setEnabled(final boolean enabled) {
            super.setEnabled(enabled);
            myLabelIndent.setEnabled(enabled);
            myLabelIndentLabel.setEnabled(enabled);
            myStyleLabel.setEnabled(enabled);
            myLabelIndentStyle.setEnabled(enabled);
        }
    };
}
Also used : CommonCodeStyleSettings(com.intellij.psi.codeStyle.CommonCodeStyleSettings) CodeStyleSettings(com.intellij.psi.codeStyle.CodeStyleSettings) SmartIndentOptionsEditor(com.intellij.application.options.SmartIndentOptionsEditor) JBLabel(com.intellij.ui.components.JBLabel) NotNull(org.jetbrains.annotations.NotNull)

Example 77 with JBLabel

use of com.intellij.ui.components.JBLabel in project intellij-community by JetBrains.

the class GitUserNameNotDefinedDialog method createCenterPanel.

@Override
protected JComponent createCenterPanel() {
    JLabel icon = new JLabel(UIUtil.getWarningIcon(), SwingConstants.LEFT);
    JLabel description = new JLabel(getMessageText());
    myNameTextField = new JTextField(20);
    JBLabel nameLabel = new JBLabel("Name: ");
    nameLabel.setDisplayedMnemonic('n');
    nameLabel.setLabelFor(myNameTextField);
    myEmailTextField = new JTextField(20);
    JBLabel emailLabel = new JBLabel("E-mail: ");
    emailLabel.setDisplayedMnemonic('e');
    emailLabel.setLabelFor(myEmailTextField);
    if (myProposedValues != null) {
        myNameTextField.setText(myProposedValues.getFirst());
        myEmailTextField.setText(myProposedValues.getSecond());
    } else {
        myNameTextField.setText(SystemProperties.getUserName());
    }
    myGlobalCheckbox = new JBCheckBox("Set properties globally", mySettings.shouldSetUserNameGlobally());
    myGlobalCheckbox.setMnemonic('g');
    JPanel rootPanel = new JPanel(new GridBagLayout());
    GridBag g = new GridBag().setDefaultInsets(new Insets(0, 0, DEFAULT_VGAP, DEFAULT_HGAP)).setDefaultAnchor(GridBagConstraints.LINE_START).setDefaultFill(GridBagConstraints.HORIZONTAL);
    rootPanel.add(description, g.nextLine().next().coverLine(3).pady(DEFAULT_HGAP));
    rootPanel.add(icon, g.nextLine().next().coverColumn(3));
    rootPanel.add(nameLabel, g.next().fillCellNone().insets(new Insets(0, 6, DEFAULT_VGAP, DEFAULT_HGAP)));
    rootPanel.add(myNameTextField, g.next());
    rootPanel.add(emailLabel, g.nextLine().next().next().fillCellNone().insets(new Insets(0, 6, DEFAULT_VGAP, DEFAULT_HGAP)));
    rootPanel.add(myEmailTextField, g.next());
    rootPanel.add(myGlobalCheckbox, g.nextLine().next().next().coverLine(2));
    return rootPanel;
}
Also used : JBLabel(com.intellij.ui.components.JBLabel) GridBag(com.intellij.util.ui.GridBag) JBCheckBox(com.intellij.ui.components.JBCheckBox)

Example 78 with JBLabel

use of com.intellij.ui.components.JBLabel in project intellij-community by JetBrains.

the class GitDefineRemoteDialog method createCenterPanel.

@Nullable
@Override
protected JComponent createCenterPanel() {
    JPanel defineRemoteComponent = new JPanel(new GridBagLayout());
    GridBag gb = new GridBag().setDefaultAnchor(GridBagConstraints.LINE_START).setDefaultInsets(UIUtil.DEFAULT_VGAP, UIUtil.DEFAULT_HGAP, 0, 0);
    defineRemoteComponent.add(new JBLabel("Name:"), gb.nextLine().next().anchor(GridBagConstraints.EAST));
    defineRemoteComponent.add(myRemoteName, gb.next());
    defineRemoteComponent.add(new JBLabel("URL: "), gb.nextLine().next().anchor(GridBagConstraints.EAST).insets(0, UIUtil.DEFAULT_HGAP, UIUtil.DEFAULT_VGAP, 0));
    defineRemoteComponent.add(myRemoteUrl, gb.next());
    return defineRemoteComponent;
}
Also used : JBLabel(com.intellij.ui.components.JBLabel) GridBag(com.intellij.util.ui.GridBag) Nullable(org.jetbrains.annotations.Nullable)

Example 79 with JBLabel

use of com.intellij.ui.components.JBLabel in project intellij-community by JetBrains.

the class GitNewResetDialog method createCenterPanel.

@Nullable
@Override
protected JComponent createCenterPanel() {
    JPanel panel = new JPanel(new GridBagLayout());
    GridBag gb = new GridBag().setDefaultAnchor(GridBagConstraints.LINE_START).setDefaultInsets(0, UIUtil.DEFAULT_HGAP, UIUtil.LARGE_VGAP, 0);
    String description = prepareDescription(myProject, myCommits);
    panel.add(new JBLabel(XmlStringUtil.wrapInHtml(description)), gb.nextLine().next().coverLine());
    String explanation = "This will reset the current branch head to the selected commit, <br/>" + "and update the working tree and the index according to the selected mode:";
    panel.add(new JBLabel(XmlStringUtil.wrapInHtml(explanation), UIUtil.ComponentStyle.SMALL), gb.nextLine().next().coverLine());
    for (GitResetMode mode : GitResetMode.values()) {
        JBRadioButton button = new JBRadioButton(mode.getName());
        button.setMnemonic(mode.getName().charAt(0));
        myButtonGroup.add(button);
        panel.add(button, gb.nextLine().next());
        panel.add(new JBLabel(XmlStringUtil.wrapInHtml(mode.getDescription()), UIUtil.ComponentStyle.SMALL), gb.next());
    }
    myEnumModel = RadioButtonEnumModel.bindEnum(GitResetMode.class, myButtonGroup);
    myEnumModel.setSelected(myDefaultMode);
    return panel;
}
Also used : JBLabel(com.intellij.ui.components.JBLabel) JBRadioButton(com.intellij.ui.components.JBRadioButton) GridBag(com.intellij.util.ui.GridBag) Nullable(org.jetbrains.annotations.Nullable)

Example 80 with JBLabel

use of com.intellij.ui.components.JBLabel in project intellij-community by JetBrains.

the class GitRejectedPushUpdateDialog method createCenterPanel.

@Override
protected JComponent createCenterPanel() {
    JBLabel desc = new JBLabel(wrapInHtml(makeDescription()));
    JPanel options = new JPanel(new BorderLayout());
    if (!myRebaseOverMergeProblemDetected) {
        options.add(myAutoUpdateInFuture, BorderLayout.SOUTH);
    }
    if (!GitUtil.justOneGitRepository(myProject)) {
        options.add(myUpdateAllRoots);
    }
    final int GAP = 15;
    JPanel rootPanel = new JPanel(new BorderLayout(GAP, GAP));
    rootPanel.add(desc);
    rootPanel.add(options, BorderLayout.SOUTH);
    JLabel iconLabel = new JLabel(myRebaseOverMergeProblemDetected ? UIUtil.getWarningIcon() : UIUtil.getQuestionIcon());
    rootPanel.add(iconLabel, BorderLayout.WEST);
    return rootPanel;
}
Also used : JBLabel(com.intellij.ui.components.JBLabel)

Aggregations

JBLabel (com.intellij.ui.components.JBLabel)98 Nullable (org.jetbrains.annotations.Nullable)23 NotNull (org.jetbrains.annotations.NotNull)11 JBCheckBox (com.intellij.ui.components.JBCheckBox)10 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)9 VirtualFile (com.intellij.openapi.vfs.VirtualFile)8 ComboBox (com.intellij.openapi.ui.ComboBox)7 VerticalFlowLayout (com.intellij.openapi.ui.VerticalFlowLayout)7 GridBag (com.intellij.util.ui.GridBag)7 List (java.util.List)7 JBList (com.intellij.ui.components.JBList)6 JBTable (com.intellij.ui.table.JBTable)6 JBTextField (com.intellij.ui.components.JBTextField)5 DocumentEvent (javax.swing.event.DocumentEvent)5 DumbAwareAction (com.intellij.openapi.project.DumbAwareAction)4 Project (com.intellij.openapi.project.Project)4 TextFieldWithBrowseButton (com.intellij.openapi.ui.TextFieldWithBrowseButton)4 StringUtil (com.intellij.openapi.util.text.StringUtil)4 java.awt (java.awt)4 ArrayList (java.util.ArrayList)4