Search in sources :

Example 1 with StringComboboxEditor

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

the class MvcRunTargetDialog method createUIComponents.

private void createUIComponents() {
    myTargetField = new ComboBox(MvcRunTargetHistoryService.getInstance().getHistory());
    myTargetField.setLightWeightPopupEnabled(false);
    EditorComboBoxEditor editor = new StringComboboxEditor(myModule.getProject(), PlainTextFileType.INSTANCE, myTargetField);
    myTargetField.setRenderer(new EditorComboBoxRenderer(editor));
    myTargetField.setEditable(true);
    myTargetField.setEditor(editor);
    EditorTextField editorTextField = editor.getEditorComponent();
    myFakePanel = new JPanel(new BorderLayout());
    myFakePanel.add(myTargetField, BorderLayout.CENTER);
    TextFieldCompletionProvider vmOptionCompletionProvider = new TextFieldCompletionProviderDumbAware() {

        @NotNull
        @Override
        protected String getPrefix(@NotNull String currentTextPrefix) {
            return MvcRunTargetDialog.getPrefix(currentTextPrefix);
        }

        @Override
        protected void addCompletionVariants(@NotNull String text, int offset, @NotNull String prefix, @NotNull CompletionResultSet result) {
            if (prefix.endsWith("-D")) {
                result.addAllElements(MvcTargetDialogCompletionUtils.getSystemPropertiesVariants());
            }
        }
    };
    myVmOptionsField = vmOptionCompletionProvider.createEditor(myModule.getProject());
    new TextFieldCompletionProviderDumbAware() {

        @NotNull
        @Override
        protected String getPrefix(@NotNull String currentTextPrefix) {
            return MvcRunTargetDialog.getPrefix(currentTextPrefix);
        }

        @Override
        protected void addCompletionVariants(@NotNull String text, int offset, @NotNull String prefix, @NotNull CompletionResultSet result) {
            for (LookupElement variant : MvcTargetDialogCompletionUtils.collectVariants(myModule, text, offset, prefix)) {
                result.addElement(variant);
            }
        }
    }.apply(editorTextField);
    editorTextField.getDocument().addDocumentListener(new DocumentAdapter() {

        @Override
        public void documentChanged(DocumentEvent e) {
            setOKActionEnabled(!StringUtil.isEmptyOrSpaces(e.getDocument().getText()));
        }
    });
    setOKActionEnabled(false);
}
Also used : EditorComboBoxEditor(com.intellij.ui.EditorComboBoxEditor) StringComboboxEditor(com.intellij.ui.StringComboboxEditor) ComboBox(com.intellij.openapi.ui.ComboBox) ModulesComboBox(com.intellij.application.options.ModulesComboBox) CompletionResultSet(com.intellij.codeInsight.completion.CompletionResultSet) DocumentAdapter(com.intellij.openapi.editor.event.DocumentAdapter) LookupElement(com.intellij.codeInsight.lookup.LookupElement) DocumentEvent(com.intellij.openapi.editor.event.DocumentEvent) NotNull(org.jetbrains.annotations.NotNull) TextFieldCompletionProviderDumbAware(com.intellij.util.TextFieldCompletionProviderDumbAware) EditorTextField(com.intellij.ui.EditorTextField) TextFieldCompletionProvider(com.intellij.util.TextFieldCompletionProvider) EditorComboBoxRenderer(com.intellij.ui.EditorComboBoxRenderer)

Example 2 with StringComboboxEditor

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

the class PyIntroduceDialog method setUpNameComboBox.

private void setUpNameComboBox(Collection<String> possibleNames) {
    final EditorComboBoxEditor comboEditor = new StringComboboxEditor(myProject, PythonFileType.INSTANCE, myNameComboBox);
    myNameComboBox.setEditor(comboEditor);
    myNameComboBox.setRenderer(new EditorComboBoxRenderer(comboEditor));
    myNameComboBox.setEditable(true);
    myNameComboBox.setMaximumRowCount(8);
    myNameComboBox.addItemListener(new ItemListener() {

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

        public void beforeDocumentChange(DocumentEvent event) {
        }

        public void documentChanged(DocumentEvent event) {
            updateControls();
        }
    });
    myContentPane.registerKeyboardAction(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> {
                IdeFocusManager.getGlobalInstance().requestFocus(myNameComboBox, true);
            });
        }
    }, KeyStroke.getKeyStroke(KeyEvent.VK_N, KeyEvent.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) EditorTextField(com.intellij.ui.EditorTextField) DocumentEvent(com.intellij.openapi.editor.event.DocumentEvent) EditorComboBoxRenderer(com.intellij.ui.EditorComboBoxRenderer)

Example 3 with StringComboboxEditor

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

the class NameSuggestionsField method setupComboBox.

private void setupComboBox(final ComboBox combobox, FileType fileType) {
    final EditorComboBoxEditor comboEditor = new StringComboboxEditor(myProject, fileType, combobox) {

        @Override
        public void setItem(Object anObject) {
            myNonHumanChange = true;
            super.setItem(anObject);
        }
    };
    combobox.setEditor(comboEditor);
    combobox.setRenderer(new EditorComboBoxRenderer(comboEditor));
    combobox.setEditable(true);
    combobox.setMaximumRowCount(8);
    comboEditor.selectAll();
}
Also used : EditorComboBoxEditor(com.intellij.ui.EditorComboBoxEditor) StringComboboxEditor(com.intellij.ui.StringComboboxEditor) EditorComboBoxRenderer(com.intellij.ui.EditorComboBoxRenderer)

Example 4 with StringComboboxEditor

use of com.intellij.ui.StringComboboxEditor 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)

Example 5 with StringComboboxEditor

use of com.intellij.ui.StringComboboxEditor 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)

Aggregations

EditorComboBoxEditor (com.intellij.ui.EditorComboBoxEditor)7 EditorComboBoxRenderer (com.intellij.ui.EditorComboBoxRenderer)7 StringComboboxEditor (com.intellij.ui.StringComboboxEditor)7 EditorTextField (com.intellij.ui.EditorTextField)5 DocumentEvent (com.intellij.openapi.editor.event.DocumentEvent)3 DocumentListener (com.intellij.openapi.editor.event.DocumentListener)2 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)2 ComboBox (com.intellij.openapi.ui.ComboBox)2 ModulesComboBox (com.intellij.application.options.ModulesComboBox)1 CompletionResultSet (com.intellij.codeInsight.completion.CompletionResultSet)1 LookupElement (com.intellij.codeInsight.lookup.LookupElement)1 DocumentAdapter (com.intellij.openapi.editor.event.DocumentAdapter)1 ExternalSystemUiAware (com.intellij.openapi.externalSystem.ExternalSystemUiAware)1 ExternalProjectPathField (com.intellij.openapi.externalSystem.service.ui.ExternalProjectPathField)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 TextFieldCompletionProvider (com.intellij.util.TextFieldCompletionProvider)1 TextFieldCompletionProviderDumbAware (com.intellij.util.TextFieldCompletionProviderDumbAware)1 NotNull (org.jetbrains.annotations.NotNull)1 MavenProjectsManager (org.jetbrains.idea.maven.project.MavenProjectsManager)1 GradleArgumentsCompletionProvider (org.jetbrains.plugins.gradle.service.execution.GradleArgumentsCompletionProvider)1