Search in sources :

Example 6 with ExternalSystemUiAware

use of com.intellij.openapi.externalSystem.ExternalSystemUiAware in project intellij-community by JetBrains.

the class ExternalProjectPathField method createTextField.

@NotNull
private static EditorTextField createTextField(@NotNull final Project project, @NotNull final ProjectSystemId externalSystemId) {
    ExternalSystemManager<?, ?, ?, ?, ?> manager = ExternalSystemApiUtil.getManager(externalSystemId);
    assert manager != null;
    final AbstractExternalSystemLocalSettings settings = manager.getLocalSettingsProvider().fun(project);
    final ExternalSystemUiAware uiAware = ExternalSystemUiUtil.getUiAware(externalSystemId);
    TextFieldCompletionProvider provider = new TextFieldCompletionProviderDumbAware() {

        @Override
        protected void addCompletionVariants(@NotNull String text, int offset, @NotNull String prefix, @NotNull CompletionResultSet result) {
            for (Map.Entry<ExternalProjectPojo, Collection<ExternalProjectPojo>> entry : settings.getAvailableProjects().entrySet()) {
                String rootProjectPath = entry.getKey().getPath();
                String rootProjectName = uiAware.getProjectRepresentationName(rootProjectPath, null);
                ExternalProjectPathLookupElement rootProjectElement = new ExternalProjectPathLookupElement(rootProjectName, rootProjectPath);
                result.addElement(rootProjectElement);
                for (ExternalProjectPojo subProject : entry.getValue()) {
                    String p = subProject.getPath();
                    if (rootProjectPath.equals(p)) {
                        continue;
                    }
                    String subProjectName = uiAware.getProjectRepresentationName(p, rootProjectPath);
                    ExternalProjectPathLookupElement subProjectElement = new ExternalProjectPathLookupElement(subProjectName, p);
                    result.addElement(subProjectElement);
                }
            }
            result.stopHere();
        }
    };
    EditorTextField result = provider.createEditor(project, false, editor -> {
        collapseIfPossible(editor, externalSystemId, project);
        editor.getSettings().setShowIntentionBulb(false);
    });
    result.setBorder(UIUtil.getTextFieldBorder());
    result.setOneLineMode(true);
    result.setOpaque(true);
    result.setBackground(UIUtil.getTextFieldBackground());
    return result;
}
Also used : AbstractExternalSystemLocalSettings(com.intellij.openapi.externalSystem.settings.AbstractExternalSystemLocalSettings) CompletionResultSet(com.intellij.codeInsight.completion.CompletionResultSet) NotNull(org.jetbrains.annotations.NotNull) ExternalSystemUiAware(com.intellij.openapi.externalSystem.ExternalSystemUiAware) TextFieldCompletionProviderDumbAware(com.intellij.util.TextFieldCompletionProviderDumbAware) EditorTextField(com.intellij.ui.EditorTextField) TextFieldCompletionProvider(com.intellij.util.TextFieldCompletionProvider) Collection(java.util.Collection) Map(java.util.Map) ExternalProjectPojo(com.intellij.openapi.externalSystem.model.project.ExternalProjectPojo) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

ExternalSystemUiAware (com.intellij.openapi.externalSystem.ExternalSystemUiAware)6 EditorTextField (com.intellij.ui.EditorTextField)3 ExternalProjectPojo (com.intellij.openapi.externalSystem.model.project.ExternalProjectPojo)2 ExternalProjectPathField (com.intellij.openapi.externalSystem.service.ui.ExternalProjectPathField)2 AbstractExternalSystemLocalSettings (com.intellij.openapi.externalSystem.settings.AbstractExternalSystemLocalSettings)2 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)2 Collection (java.util.Collection)2 Map (java.util.Map)2 NotNull (org.jetbrains.annotations.NotNull)2 CompletionResultSet (com.intellij.codeInsight.completion.CompletionResultSet)1 ExternalProjectInfo (com.intellij.openapi.externalSystem.model.ExternalProjectInfo)1 ProjectSystemId (com.intellij.openapi.externalSystem.model.ProjectSystemId)1 ExternalConfigPathAware (com.intellij.openapi.externalSystem.model.project.ExternalConfigPathAware)1 ExternalEntityData (com.intellij.openapi.externalSystem.model.project.ExternalEntityData)1 DefaultExternalSystemUiAware (com.intellij.openapi.externalSystem.service.ui.DefaultExternalSystemUiAware)1 ComboBox (com.intellij.openapi.ui.ComboBox)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 EditorComboBoxEditor (com.intellij.ui.EditorComboBoxEditor)1 EditorComboBoxRenderer (com.intellij.ui.EditorComboBoxRenderer)1 RawCommandLineEditor (com.intellij.ui.RawCommandLineEditor)1