Search in sources :

Example 1 with ExternalSystemUiAware

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

the class AbstractExternalSystemTaskConfigurationType method generateName.

@NotNull
public static String generateName(@NotNull Project project, @NotNull ProjectSystemId externalSystemId, @Nullable String externalProjectPath, @NotNull List<String> taskNames, @Nullable String executionName) {
    String rootProjectPath = null;
    if (externalProjectPath != null) {
        final ExternalProjectInfo projectInfo = ExternalSystemUtil.getExternalProjectInfo(project, externalSystemId, externalProjectPath);
        if (projectInfo != null) {
            rootProjectPath = projectInfo.getExternalProjectPath();
        }
    }
    StringBuilder buffer = new StringBuilder();
    final String projectName;
    if (rootProjectPath == null) {
        projectName = null;
    } else {
        final ExternalSystemUiAware uiAware = ExternalSystemUiUtil.getUiAware(externalSystemId);
        projectName = uiAware.getProjectRepresentationName(project, externalProjectPath, rootProjectPath);
    }
    if (!StringUtil.isEmptyOrSpaces(projectName)) {
        buffer.append(projectName);
        buffer.append(' ');
    } else {
        buffer.append(externalProjectPath);
        buffer.append(' ');
    }
    buffer.append('[');
    if (!StringUtil.isEmpty(executionName)) {
        buffer.append(executionName);
    } else if (!taskNames.isEmpty()) {
        for (String taskName : taskNames) {
            buffer.append(taskName).append(' ');
        }
        buffer.setLength(buffer.length() - 1);
    }
    buffer.append(']');
    return buffer.toString();
}
Also used : ExternalProjectInfo(com.intellij.openapi.externalSystem.model.ExternalProjectInfo) ExternalSystemUiAware(com.intellij.openapi.externalSystem.ExternalSystemUiAware) DefaultExternalSystemUiAware(com.intellij.openapi.externalSystem.service.ui.DefaultExternalSystemUiAware) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with ExternalSystemUiAware

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

the class ExternalSystemTaskSettingsControl method fillUi.

@Override
public void fillUi(@NotNull final PaintAwarePanel canvas, int indentLevel) {
    myProjectPathLabel = new JBLabel(ExternalSystemBundle.message("run.configuration.settings.label.project", myExternalSystemId.getReadableName()));
    ExternalSystemManager<?, ?, ?, ?, ?> manager = ExternalSystemApiUtil.getManager(myExternalSystemId);
    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", myExternalSystemId.getReadableName());
    myProjectPathField = new ExternalProjectPathField(myProject, myExternalSystemId, projectPathChooserDescriptor, title) {

        @Override
        public Dimension getPreferredSize() {
            return myVmOptionsEditor == null ? super.getPreferredSize() : myVmOptionsEditor.getTextField().getPreferredSize();
        }
    };
    canvas.add(myProjectPathLabel, ExternalSystemUiUtil.getLabelConstraints(0));
    canvas.add(myProjectPathField, ExternalSystemUiUtil.getFillLineConstraints(0));
    myTasksLabel = new JBLabel(ExternalSystemBundle.message("run.configuration.settings.label.tasks"));
    myTasksTextField = new EditorTextField("", myProject, PlainTextFileType.INSTANCE);
    canvas.add(myTasksLabel, ExternalSystemUiUtil.getLabelConstraints(0));
    GridBag c = ExternalSystemUiUtil.getFillLineConstraints(0);
    c.insets.right = myProjectPathField.getButton().getPreferredSize().width + 8;
    canvas.add(myTasksTextField, c);
    new TaskCompletionProvider(myProject, myExternalSystemId, myProjectPathField).apply(myTasksTextField);
    myVmOptionsLabel = new JBLabel(ExternalSystemBundle.message("run.configuration.settings.label.vmoptions"));
    myVmOptionsEditor = new RawCommandLineEditor();
    myVmOptionsEditor.setDialogCaption(ExternalSystemBundle.message("run.configuration.settings.label.vmoptions"));
    canvas.add(myVmOptionsLabel, ExternalSystemUiUtil.getLabelConstraints(0));
    canvas.add(myVmOptionsEditor, ExternalSystemUiUtil.getFillLineConstraints(0));
    myArgumentsLabel = new JBLabel(ExternalSystemBundle.message("run.configuration.settings.label.arguments"));
    myArgumentsEditor = new RawCommandLineEditor();
    myArgumentsEditor.setDialogCaption(ExternalSystemBundle.message("run.configuration.settings.label.arguments"));
    canvas.add(myArgumentsLabel, ExternalSystemUiUtil.getLabelConstraints(0));
    canvas.add(myArgumentsEditor, ExternalSystemUiUtil.getFillLineConstraints(0));
}
Also used : ExternalProjectPathField(com.intellij.openapi.externalSystem.service.ui.ExternalProjectPathField) JBLabel(com.intellij.ui.components.JBLabel) EditorTextField(com.intellij.ui.EditorTextField) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) RawCommandLineEditor(com.intellij.ui.RawCommandLineEditor) GridBag(com.intellij.util.ui.GridBag) ExternalSystemUiAware(com.intellij.openapi.externalSystem.ExternalSystemUiAware)

Example 3 with ExternalSystemUiAware

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

the class ExternalProjectPathField method collapseIfPossible.

private static void collapseIfPossible(@NotNull final Editor editor, @NotNull ProjectSystemId externalSystemId, @NotNull Project project) {
    ExternalSystemManager<?, ?, ?, ?, ?> manager = ExternalSystemApiUtil.getManager(externalSystemId);
    assert manager != null;
    final AbstractExternalSystemLocalSettings settings = manager.getLocalSettingsProvider().fun(project);
    final ExternalSystemUiAware uiAware = ExternalSystemUiUtil.getUiAware(externalSystemId);
    String rawText = editor.getDocument().getText();
    for (Map.Entry<ExternalProjectPojo, Collection<ExternalProjectPojo>> entry : settings.getAvailableProjects().entrySet()) {
        if (entry.getKey().getPath().equals(rawText)) {
            collapse(editor, uiAware.getProjectRepresentationName(project, entry.getKey().getPath(), null));
            return;
        }
        for (ExternalProjectPojo pojo : entry.getValue()) {
            if (pojo.getPath().equals(rawText)) {
                collapse(editor, uiAware.getProjectRepresentationName(project, pojo.getPath(), entry.getKey().getPath()));
                return;
            }
        }
    }
}
Also used : AbstractExternalSystemLocalSettings(com.intellij.openapi.externalSystem.settings.AbstractExternalSystemLocalSettings) Collection(java.util.Collection) Map(java.util.Map) ExternalProjectPojo(com.intellij.openapi.externalSystem.model.project.ExternalProjectPojo) ExternalSystemUiAware(com.intellij.openapi.externalSystem.ExternalSystemUiAware)

Example 4 with ExternalSystemUiAware

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

the class OpenExternalConfigAction method isEnabled.

@Override
protected boolean isEnabled(AnActionEvent e) {
    if (!super.isEnabled(e))
        return false;
    final ExternalEntityData externalData = getExternalData(e, ExternalEntityData.class);
    if (!(externalData instanceof ExternalConfigPathAware))
        return false;
    VirtualFile config = getExternalConfig((ExternalConfigPathAware) externalData, externalData.getOwner());
    if (config == null)
        return false;
    ProjectSystemId externalSystemId = getSystemId(e);
    e.getPresentation().setText(ExternalSystemBundle.message("action.open.config.text", externalSystemId.getReadableName()));
    e.getPresentation().setDescription(ExternalSystemBundle.message("action.open.config.description", externalSystemId.getReadableName()));
    final ExternalSystemUiAware uiAware = getExternalSystemUiAware(e);
    if (uiAware != null) {
        e.getPresentation().setIcon(uiAware.getProjectIcon());
    }
    return true;
}
Also used : ExternalConfigPathAware(com.intellij.openapi.externalSystem.model.project.ExternalConfigPathAware) VirtualFile(com.intellij.openapi.vfs.VirtualFile) ExternalEntityData(com.intellij.openapi.externalSystem.model.project.ExternalEntityData) ProjectSystemId(com.intellij.openapi.externalSystem.model.ProjectSystemId) ExternalSystemUiAware(com.intellij.openapi.externalSystem.ExternalSystemUiAware)

Example 5 with ExternalSystemUiAware

use of com.intellij.openapi.externalSystem.ExternalSystemUiAware 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)

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