Search in sources :

Example 36 with EditorTextField

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

the class DarculaEditorTextFieldBorder method paintBorder.

@Override
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
    if (isComboBoxEditor(c)) /*|| isCellEditor(c)*/
    {
        g.setColor(c.getBackground());
        g.fillRect(x, y, width, height);
        return;
    }
    final EditorTextField textField = UIUtil.getParentOfType(EditorTextField.class, c);
    if (textField == null)
        return;
    final Rectangle r = new Rectangle(x + 1, y + 1, width - 2, height - 2);
    if (c.isOpaque()) {
        g.setColor(UIUtil.getPanelBackground());
        g.fillRect(x, y, width, height);
    }
    g.setColor(c.getBackground());
    g.fillRect(r.x, r.y, r.width, r.height);
    if (!textField.isEnabled()) {
        ((Graphics2D) g).setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.4f));
    }
    if (textField.isEnabled() && textField.isVisible() && textField.getFocusTarget().hasFocus()) {
        DarculaUIUtil.paintFocusRing(g, new Rectangle(r.x + 1, r.y + 1, r.width - 2, r.height - 2));
    } else {
        g.setColor(new JBColor(Gray._150, Gray._100));
        g.drawRect(r.x, r.y, r.width, r.height);
    }
}
Also used : EditorTextField(com.intellij.ui.EditorTextField) JBColor(com.intellij.ui.JBColor)

Example 37 with EditorTextField

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

the class GroovyMapParameterDialog method setUpNameComboBox.

private void setUpNameComboBox(String[] possibleNames) {
    final EditorComboBoxEditor comboEditor = new StringComboboxEditor(myProject, GroovyFileType.GROOVY_FILE_TYPE, myNameComboBox);
    myNameComboBox.setEditor(comboEditor);
    myNameComboBox.setRenderer(new EditorComboBoxRenderer(comboEditor));
    myNameComboBox.setEditable(true);
    myNameComboBox.setMaximumRowCount(8);
    myListenerList.add(DataChangedListener.class, new DataChangedListener());
    myNameComboBox.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            fireNameDataChanged();
        }
    });
    ((EditorTextField) myNameComboBox.getEditor().getEditorComponent()).addDocumentListener(new DocumentListener() {

        @Override
        public void beforeDocumentChange(DocumentEvent event) {
        }

        @Override
        public void documentChanged(DocumentEvent event) {
            fireNameDataChanged();
        }
    });
    contentPane.registerKeyboardAction(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> {
                IdeFocusManager.getGlobalInstance().requestFocus(myNameComboBox, true);
            });
        }
    }, KeyStroke.getKeyStroke(KeyEvent.VK_N, InputEvent.ALT_MASK), JComponent.WHEN_IN_FOCUSED_WINDOW);
    for (String possibleName : possibleNames) {
        myNameComboBox.addItem(possibleName);
    }
}
Also used : EditorComboBoxEditor(com.intellij.ui.EditorComboBoxEditor) DocumentListener(com.intellij.openapi.editor.event.DocumentListener) StringComboboxEditor(com.intellij.ui.StringComboboxEditor) DocumentEvent(com.intellij.openapi.editor.event.DocumentEvent) EditorTextField(com.intellij.ui.EditorTextField) EditorComboBoxRenderer(com.intellij.ui.EditorComboBoxRenderer)

Example 38 with EditorTextField

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

the class GradleRunTaskDialog method setUpDialog.

private void setUpDialog() {
    JComponent commandLineComponent;
    if (myHistory == null) {
        commandLineEditor = new EditorTextField("", myProject, PlainTextFileType.INSTANCE);
        commandLineComponent = commandLineEditor;
        commandLineLabel.setLabelFor(commandLineEditor);
    } else {
        commandLineComboBox = new ComboBox(ArrayUtilRt.toStringArray(myHistory));
        commandLineComponent = commandLineComboBox;
        commandLineLabel.setLabelFor(commandLineComboBox);
        commandLineComboBox.setLightWeightPopupEnabled(false);
        EditorComboBoxEditor editor = new StringComboboxEditor(myProject, PlainTextFileType.INSTANCE, commandLineComboBox);
        //noinspection GtkPreferredJComboBoxRenderer
        commandLineComboBox.setRenderer(new EditorComboBoxRenderer(editor));
        commandLineComboBox.setEditable(true);
        commandLineComboBox.setEditor(editor);
        commandLineComboBox.setFocusable(true);
        commandLineEditor = editor.getEditorComponent();
    }
    commandLinePanel.add(commandLineComponent);
    ExternalSystemManager<?, ?, ?, ?, ?> manager = ExternalSystemApiUtil.getManager(GradleConstants.SYSTEM_ID);
    FileChooserDescriptor projectPathChooserDescriptor = null;
    if (manager instanceof ExternalSystemUiAware) {
        projectPathChooserDescriptor = ((ExternalSystemUiAware) manager).getExternalProjectConfigDescriptor();
    }
    if (projectPathChooserDescriptor == null) {
        projectPathChooserDescriptor = FileChooserDescriptorFactory.createSingleLocalFileDescriptor();
    }
    String title = ExternalSystemBundle.message("settings.label.select.project", GradleConstants.SYSTEM_ID.getReadableName());
    myProjectPathField = new ExternalProjectPathField(myProject, GradleConstants.SYSTEM_ID, projectPathChooserDescriptor, title) {

        @Override
        public Dimension getPreferredSize() {
            return commandLinePanel == null ? super.getPreferredSize() : commandLinePanel.getPreferredSize();
        }
    };
    projectPathFieldPanel.add(myProjectPathField);
    new GradleArgumentsCompletionProvider(myProject, myProjectPathField).apply(commandLineEditor);
}
Also used : EditorComboBoxEditor(com.intellij.ui.EditorComboBoxEditor) GradleArgumentsCompletionProvider(org.jetbrains.plugins.gradle.service.execution.GradleArgumentsCompletionProvider) StringComboboxEditor(com.intellij.ui.StringComboboxEditor) ExternalProjectPathField(com.intellij.openapi.externalSystem.service.ui.ExternalProjectPathField) ComboBox(com.intellij.openapi.ui.ComboBox) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) ExternalSystemUiAware(com.intellij.openapi.externalSystem.ExternalSystemUiAware) EditorTextField(com.intellij.ui.EditorTextField) EditorComboBoxRenderer(com.intellij.ui.EditorComboBoxRenderer)

Example 39 with EditorTextField

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

the class EditVarConstraintsDialog method createScriptComponent.

private static EditorTextField createScriptComponent() {
    @NonNls final String fileName = "1.groovy";
    final FileType fileType = getFileType(fileName);
    final Document doc = createDocument(fileName, fileType, "");
    return new EditorTextField(doc, myProject, fileType);
}
Also used : NonNls(org.jetbrains.annotations.NonNls) FileType(com.intellij.openapi.fileTypes.FileType) EditorTextField(com.intellij.ui.EditorTextField) Document(com.intellij.openapi.editor.Document)

Example 40 with EditorTextField

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

the class MavenEditGoalDialog method setUpDialog.

private void setUpDialog() {
    JComponent goalComponent;
    if (myHistory == null) {
        goalsEditor = new EditorTextField("", myProject, PlainTextFileType.INSTANCE);
        goalComponent = goalsEditor;
        goalsLabel.setLabelFor(goalsEditor);
    } else {
        goalsComboBox = new ComboBox(ArrayUtilRt.toStringArray(myHistory));
        goalComponent = goalsComboBox;
        goalsLabel.setLabelFor(goalsComboBox);
        goalsComboBox.setLightWeightPopupEnabled(false);
        EditorComboBoxEditor editor = new StringComboboxEditor(myProject, PlainTextFileType.INSTANCE, goalsComboBox);
        goalsComboBox.setRenderer(new EditorComboBoxRenderer(editor));
        goalsComboBox.setEditable(true);
        goalsComboBox.setEditor(editor);
        goalsComboBox.setFocusable(true);
        goalsEditor = editor.getEditorComponent();
    }
    goalsPanel.add(goalComponent);
    new MavenArgumentsCompletionProvider(myProject).apply(goalsEditor);
    MavenProjectsManager projectsManager = MavenProjectsManager.getInstance(myProject);
    showProjectTreeButton.setIcon(AllIcons.Actions.Module);
    MavenSelectProjectPopup.attachToWorkingDirectoryField(projectsManager, workDirectoryField.getTextField(), showProjectTreeButton, goalsComboBox != null ? goalsComboBox : goalsEditor);
    workDirectoryField.addBrowseFolderListener(RunnerBundle.message("maven.select.maven.project.file"), "", myProject, new FileChooserDescriptor(false, true, false, false, false, false) {

        @Override
        public boolean isFileSelectable(VirtualFile file) {
            if (!super.isFileSelectable(file))
                return false;
            for (VirtualFile child : file.getChildren()) {
                if (MavenUtil.isPomFileName(child.getName()))
                    return true;
            }
            return false;
        }
    });
}
Also used : EditorComboBoxEditor(com.intellij.ui.EditorComboBoxEditor) VirtualFile(com.intellij.openapi.vfs.VirtualFile) StringComboboxEditor(com.intellij.ui.StringComboboxEditor) MavenProjectsManager(org.jetbrains.idea.maven.project.MavenProjectsManager) EditorTextField(com.intellij.ui.EditorTextField) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) EditorComboBoxRenderer(com.intellij.ui.EditorComboBoxRenderer)

Aggregations

EditorTextField (com.intellij.ui.EditorTextField)47 Document (com.intellij.openapi.editor.Document)11 NotNull (org.jetbrains.annotations.NotNull)11 DocumentEvent (com.intellij.openapi.editor.event.DocumentEvent)9 DocumentAdapter (com.intellij.openapi.editor.event.DocumentAdapter)7 EditorEx (com.intellij.openapi.editor.ex.EditorEx)5 EditorComboBoxEditor (com.intellij.ui.EditorComboBoxEditor)5 EditorComboBoxRenderer (com.intellij.ui.EditorComboBoxRenderer)5 StringComboboxEditor (com.intellij.ui.StringComboboxEditor)5 JBLabel (com.intellij.ui.components.JBLabel)4 Editor (com.intellij.openapi.editor.Editor)3 DocumentListener (com.intellij.openapi.editor.event.DocumentListener)3 ExternalSystemUiAware (com.intellij.openapi.externalSystem.ExternalSystemUiAware)3 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)3 Project (com.intellij.openapi.project.Project)3 ComboBox (com.intellij.openapi.ui.ComboBox)3 FixedSizeButton (com.intellij.openapi.ui.FixedSizeButton)3 CompletionResultSet (com.intellij.codeInsight.completion.CompletionResultSet)2 InlayParameterHintsProvider (com.intellij.codeInsight.hints.InlayParameterHintsProvider)2 Language (com.intellij.lang.Language)2