Search in sources :

Example 6 with EditorComboBoxRenderer

use of com.intellij.ui.EditorComboBoxRenderer 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 7 with EditorComboBoxRenderer

use of com.intellij.ui.EditorComboBoxRenderer 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 8 with EditorComboBoxRenderer

use of com.intellij.ui.EditorComboBoxRenderer in project intellij-plugins by JetBrains.

the class DartIntroduceDialog method setUpNameComboBox.

private void setUpNameComboBox(Collection<String> possibleNames) {
    final EditorComboBoxEditor comboEditor = new StringComboboxEditor(myProject, DartFileType.INSTANCE, myNameComboBox);
    myNameComboBox.setEditor(comboEditor);
    myNameComboBox.setRenderer(new EditorComboBoxRenderer(comboEditor));
    myNameComboBox.setEditable(true);
    myNameComboBox.setMaximumRowCount(8);
    myContentPane.registerKeyboardAction(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) StringComboboxEditor(com.intellij.ui.StringComboboxEditor) EditorComboBoxRenderer(com.intellij.ui.EditorComboBoxRenderer)

Aggregations

EditorComboBoxRenderer (com.intellij.ui.EditorComboBoxRenderer)8 EditorComboBoxEditor (com.intellij.ui.EditorComboBoxEditor)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