Search in sources :

Example 1 with FieldPanel

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

the class RequiredAttributesInspection method createOptionsPanel.

@Override
@Nullable
public JComponent createOptionsPanel() {
    JPanel panel = new JPanel(new BorderLayout());
    FieldPanel additionalAttributesPanel = new FieldPanel(InspectionsBundle.message("inspection.javadoc.html.not.required.label.text"), InspectionsBundle.message("inspection.javadoc.html.not.required.dialog.title"), null, null);
    panel.add(additionalAttributesPanel, BorderLayout.NORTH);
    additionalAttributesPanel.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {

        @Override
        protected void textChanged(DocumentEvent e) {
            final Document document = e.getDocument();
            try {
                final String text = document.getText(0, document.getLength());
                if (text != null) {
                    myAdditionalRequiredHtmlAttributes = text.trim();
                }
            } catch (BadLocationException e1) {
                LOG.error(e1);
            }
        }
    });
    additionalAttributesPanel.setText(myAdditionalRequiredHtmlAttributes);
    return panel;
}
Also used : DocumentAdapter(com.intellij.ui.DocumentAdapter) DocumentEvent(javax.swing.event.DocumentEvent) Document(javax.swing.text.Document) FieldPanel(com.intellij.ui.FieldPanel) BadLocationException(javax.swing.text.BadLocationException) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with FieldPanel

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

the class ModuleWizardStep method createFieldPanel.

public static FieldPanel createFieldPanel(final JTextField field, final String labelText, final BrowseFilesListener browseButtonActionListener) {
    final FieldPanel fieldPanel = new FieldPanel(field, labelText, null, browseButtonActionListener, null);
    fieldPanel.getFieldLabel().setFont(UIUtil.getLabelFont().deriveFont(Font.BOLD));
    return fieldPanel;
}
Also used : FieldPanel(com.intellij.ui.FieldPanel)

Example 3 with FieldPanel

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

the class SourcePathsStep method createComponentForEmptyRootCase.

private JComponent createComponentForEmptyRootCase() {
    final JPanel panel = new JPanel(new GridBagLayout());
    final String text = IdeBundle.message("prompt.please.specify.java.sources.directory");
    final JLabel label = new JLabel(text);
    label.setUI(new MultiLineLabelUI());
    panel.add(label, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, JBUI.insets(8, 10, 0, 10), 0, 0));
    myRbCreateSource = new JRadioButton(IdeBundle.message("radio.create.source.directory"), true);
    panel.add(myRbCreateSource, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, JBUI.insets(8, 10, 0, 10), 0, 0));
    myTfSourceDirectoryName = new JTextField(suggestSourceDirectoryName());
    final JLabel srcPathLabel = new JLabel(IdeBundle.message("prompt.enter.relative.path.to.module.content.root", File.separator));
    panel.add(srcPathLabel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, JBUI.insets(8, 30, 0, 0), 0, 0));
    final FileChooserDescriptor chooserDescriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
    chooserDescriptor.withTreeRootVisible(true);
    final FieldPanel fieldPanel = createFieldPanel(myTfSourceDirectoryName, null, new BrowsePathListener(myTfSourceDirectoryName, chooserDescriptor));
    panel.add(fieldPanel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, JBUI.insets(8, 30, 0, 10), 0, 0));
    myRbNoSource = new JRadioButton(IdeBundle.message("radio.do.not.create.source.directory"), true);
    panel.add(myRbNoSource, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, JBUI.insets(8, 10, 0, 10), 0, 0));
    final JLabel fullPathLabel = new JLabel(IdeBundle.message("label.source.directory"));
    panel.add(fullPathLabel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.SOUTHWEST, GridBagConstraints.NONE, JBUI.insets(8, 10, 0, 10), 0, 0));
    myTfFullPath = new JTextField();
    myTfFullPath.setEditable(false);
    myTfFullPath.setOpaque(false);
    final Insets borderInsets = myTfFullPath.getBorder().getBorderInsets(myTfFullPath);
    myTfFullPath.setBorder(BorderFactory.createEmptyBorder(borderInsets.top, borderInsets.left, borderInsets.bottom, borderInsets.right));
    panel.add(myTfFullPath, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.SOUTHWEST, GridBagConstraints.HORIZONTAL, JBUI.insets(8, 10), 0, 0));
    ButtonGroup group = new ButtonGroup();
    group.add(myRbCreateSource);
    group.add(myRbNoSource);
    myTfSourceDirectoryName.getDocument().addDocumentListener(new DocumentAdapter() {

        public void textChanged(DocumentEvent event) {
            updateFullPathField();
        }
    });
    myRbCreateSource.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            final boolean enabled = e.getStateChange() == ItemEvent.SELECTED;
            srcPathLabel.setEnabled(enabled);
            fieldPanel.setEnabled(enabled);
            fullPathLabel.setVisible(enabled);
            myTfFullPath.setVisible(enabled);
            if (enabled) {
                IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> {
                    IdeFocusManager.getGlobalInstance().requestFocus(myTfSourceDirectoryName, true);
                });
            }
        }
    });
    return panel;
}
Also used : ItemEvent(java.awt.event.ItemEvent) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) DocumentAdapter(com.intellij.ui.DocumentAdapter) DocumentEvent(javax.swing.event.DocumentEvent) MultiLineLabelUI(com.intellij.openapi.ui.MultiLineLabelUI) ItemListener(java.awt.event.ItemListener) FieldPanel(com.intellij.ui.FieldPanel)

Example 4 with FieldPanel

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

the class ProjectConfigurable method createUIComponents.

private void createUIComponents() {
    myLanguageLevelCombo = new LanguageLevelCombo(JavaCoreBundle.message("default.language.level.description")) {

        @Override
        protected LanguageLevel getDefaultLevel() {
            Sdk sdk = myProjectJdkConfigurable.getSelectedProjectJdk();
            if (sdk == null)
                return null;
            JavaSdkVersion version = JavaSdk.getInstance().getVersion(sdk);
            return version == null ? null : version.getMaxLanguageLevel();
        }
    };
    final JTextField textField = new JTextField();
    final FileChooserDescriptor outputPathsChooserDescriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
    InsertPathAction.addTo(textField, outputPathsChooserDescriptor);
    outputPathsChooserDescriptor.setHideIgnored(false);
    BrowseFilesListener listener = new BrowseFilesListener(textField, "", ProjectBundle.message("project.compiler.output"), outputPathsChooserDescriptor);
    myProjectCompilerOutput = new FieldPanel(textField, null, null, listener, EmptyRunnable.getInstance());
    FileChooserFactory.getInstance().installFileCompletion(myProjectCompilerOutput.getTextField(), outputPathsChooserDescriptor, true, null);
}
Also used : JavaSdkVersion(com.intellij.openapi.projectRoots.JavaSdkVersion) BrowseFilesListener(com.intellij.ide.util.BrowseFilesListener) LanguageLevel(com.intellij.pom.java.LanguageLevel) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) JavaSdk(com.intellij.openapi.projectRoots.JavaSdk) Sdk(com.intellij.openapi.projectRoots.Sdk) FieldPanel(com.intellij.ui.FieldPanel)

Example 5 with FieldPanel

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

the class I18nInspection method createOptionsPanel.

@Override
public JComponent createOptionsPanel() {
    final GridBagLayout layout = new GridBagLayout();
    final JPanel panel = new JPanel(layout);
    final JCheckBox assertStatementsCheckbox = new JCheckBox(CodeInsightBundle.message("inspection.i18n.option.ignore.assert"), ignoreForAssertStatements);
    assertStatementsCheckbox.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(@NotNull ChangeEvent e) {
            ignoreForAssertStatements = assertStatementsCheckbox.isSelected();
        }
    });
    final JCheckBox exceptionConstructorCheck = new JCheckBox(CodeInsightBundle.message("inspection.i18n.option.ignore.for.exception.constructor.arguments"), ignoreForExceptionConstructors);
    exceptionConstructorCheck.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(@NotNull ChangeEvent e) {
            ignoreForExceptionConstructors = exceptionConstructorCheck.isSelected();
        }
    });
    final JTextField specifiedExceptions = new JTextField(ignoreForSpecifiedExceptionConstructors);
    specifiedExceptions.getDocument().addDocumentListener(new DocumentAdapter() {

        @Override
        protected void textChanged(DocumentEvent e) {
            ignoreForSpecifiedExceptionConstructors = specifiedExceptions.getText();
        }
    });
    final JCheckBox junitAssertCheckbox = new JCheckBox(CodeInsightBundle.message("inspection.i18n.option.ignore.for.junit.assert.arguments"), ignoreForJUnitAsserts);
    junitAssertCheckbox.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(@NotNull ChangeEvent e) {
            ignoreForJUnitAsserts = junitAssertCheckbox.isSelected();
        }
    });
    final JCheckBox classRef = new JCheckBox(CodeInsightBundle.message("inspection.i18n.option.ignore.qualified.class.names"), ignoreForClassReferences);
    classRef.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(@NotNull ChangeEvent e) {
            ignoreForClassReferences = classRef.isSelected();
        }
    });
    final JCheckBox propertyRef = new JCheckBox(CodeInsightBundle.message("inspection.i18n.option.ignore.property.keys"), ignoreForPropertyKeyReferences);
    propertyRef.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(@NotNull ChangeEvent e) {
            ignoreForPropertyKeyReferences = propertyRef.isSelected();
        }
    });
    final JCheckBox nonAlpha = new JCheckBox(CodeInsightBundle.message("inspection.i18n.option.ignore.nonalphanumerics"), ignoreForNonAlpha);
    nonAlpha.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(@NotNull ChangeEvent e) {
            ignoreForNonAlpha = nonAlpha.isSelected();
        }
    });
    final JCheckBox assignedToConstants = new JCheckBox(CodeInsightBundle.message("inspection.i18n.option.ignore.assigned.to.constants"), ignoreAssignedToConstants);
    assignedToConstants.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(@NotNull ChangeEvent e) {
            ignoreAssignedToConstants = assignedToConstants.isSelected();
        }
    });
    final JCheckBox chkToString = new JCheckBox(CodeInsightBundle.message("inspection.i18n.option.ignore.tostring"), ignoreToString);
    chkToString.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(@NotNull ChangeEvent e) {
            ignoreToString = chkToString.isSelected();
        }
    });
    final JCheckBox ignoreEnumConstants = new JCheckBox("Ignore enum constants", ignoreForEnumConstants);
    ignoreEnumConstants.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(@NotNull ChangeEvent e) {
            ignoreForEnumConstants = ignoreEnumConstants.isSelected();
        }
    });
    final GridBagConstraints gc = new GridBagConstraints();
    gc.fill = GridBagConstraints.HORIZONTAL;
    gc.insets.bottom = 2;
    gc.gridx = GridBagConstraints.REMAINDER;
    gc.gridy = 0;
    gc.weightx = 1;
    gc.weighty = 0;
    panel.add(assertStatementsCheckbox, gc);
    gc.gridy++;
    panel.add(junitAssertCheckbox, gc);
    gc.gridy++;
    panel.add(exceptionConstructorCheck, gc);
    gc.gridy++;
    final Project[] openProjects = ProjectManager.getInstance().getOpenProjects();
    panel.add(new FieldPanel(specifiedExceptions, null, CodeInsightBundle.message("inspection.i18n.option.ignore.for.specified.exception.constructor.arguments"), openProjects.length == 0 ? null : new ActionListener() {

        @Override
        public void actionPerformed(@NotNull ActionEvent e) {
            createIgnoreExceptionsConfigurationDialog(openProjects[0], specifiedExceptions).show();
        }
    }, null), gc);
    gc.gridy++;
    panel.add(classRef, gc);
    gc.gridy++;
    panel.add(propertyRef, gc);
    gc.gridy++;
    panel.add(assignedToConstants, gc);
    gc.gridy++;
    panel.add(chkToString, gc);
    gc.gridy++;
    panel.add(nonAlpha, gc);
    gc.gridy++;
    panel.add(ignoreEnumConstants, gc);
    gc.gridy++;
    gc.anchor = GridBagConstraints.NORTHWEST;
    gc.weighty = 1;
    final JTextField text = new JTextField(nonNlsCommentPattern);
    final FieldPanel nonNlsCommentPatternComponent = new FieldPanel(text, CodeInsightBundle.message("inspection.i18n.option.ignore.comment.pattern"), CodeInsightBundle.message("inspection.i18n.option.ignore.comment.title"), null, () -> {
        nonNlsCommentPattern = text.getText();
        cacheNonNlsCommentPattern();
    });
    panel.add(nonNlsCommentPatternComponent, gc);
    final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(panel);
    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
    scrollPane.setBorder(null);
    scrollPane.setPreferredSize(new Dimension(panel.getPreferredSize().width + scrollPane.getVerticalScrollBar().getPreferredSize().width, panel.getPreferredSize().height + scrollPane.getHorizontalScrollBar().getPreferredSize().height));
    return scrollPane;
}
Also used : ActionEvent(java.awt.event.ActionEvent) DocumentAdapter(com.intellij.ui.DocumentAdapter) DocumentEvent(javax.swing.event.DocumentEvent) Project(com.intellij.openapi.project.Project) ChangeEvent(javax.swing.event.ChangeEvent) ActionListener(java.awt.event.ActionListener) ChangeListener(javax.swing.event.ChangeListener) FieldPanel(com.intellij.ui.FieldPanel)

Aggregations

FieldPanel (com.intellij.ui.FieldPanel)6 DocumentAdapter (com.intellij.ui.DocumentAdapter)4 DocumentEvent (javax.swing.event.DocumentEvent)4 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)2 Project (com.intellij.openapi.project.Project)2 ActionEvent (java.awt.event.ActionEvent)2 ActionListener (java.awt.event.ActionListener)2 BadLocationException (javax.swing.text.BadLocationException)2 Document (javax.swing.text.Document)2 Nullable (org.jetbrains.annotations.Nullable)2 LocalQuickFix (com.intellij.codeInspection.LocalQuickFix)1 LocalQuickFixOnPsiElement (com.intellij.codeInspection.LocalQuickFixOnPsiElement)1 BrowseFilesListener (com.intellij.ide.util.BrowseFilesListener)1 LangBundle (com.intellij.lang.LangBundle)1 JavaSdk (com.intellij.openapi.projectRoots.JavaSdk)1 JavaSdkVersion (com.intellij.openapi.projectRoots.JavaSdkVersion)1 Sdk (com.intellij.openapi.projectRoots.Sdk)1 Messages (com.intellij.openapi.ui.Messages)1 MultiLineLabelUI (com.intellij.openapi.ui.MultiLineLabelUI)1 Ref (com.intellij.openapi.util.Ref)1