Search in sources :

Example 16 with ProjectSystemId

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

the class OpenTasksActivationManagerAction method isEnabled.

@Override
protected boolean isEnabled(AnActionEvent e) {
    if (!super.isEnabled(e))
        return false;
    final List<ExternalSystemNode> selectedNodes = ExternalSystemDataKeys.SELECTED_NODES.getData(e.getDataContext());
    if (selectedNodes == null || selectedNodes.size() != 1)
        return false;
    final Object externalData = selectedNodes.get(0).getData();
    ProjectSystemId projectSystemId = getSystemId(e);
    e.getPresentation().setText(ExternalSystemBundle.message("external.system.task.activation.title"));
    e.getPresentation().setDescription(ExternalSystemBundle.message("external.system.task.activation.description", projectSystemId.getReadableName()));
    final boolean isProjectNode = externalData instanceof ProjectData || externalData instanceof ModuleData;
    return isProjectNode && StringUtil.isNotEmpty(((ExternalConfigPathAware) externalData).getLinkedExternalProjectPath());
}
Also used : ExternalConfigPathAware(com.intellij.openapi.externalSystem.model.project.ExternalConfigPathAware) ProjectSystemId(com.intellij.openapi.externalSystem.model.ProjectSystemId) ModuleData(com.intellij.openapi.externalSystem.model.project.ModuleData) ExternalSystemNode(com.intellij.openapi.externalSystem.view.ExternalSystemNode) ProjectData(com.intellij.openapi.externalSystem.model.project.ProjectData)

Example 17 with ProjectSystemId

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

the class RefreshAllExternalProjectsAction method update.

@Override
public void update(AnActionEvent e) {
    final Project project = e.getProject();
    if (project == null) {
        e.getPresentation().setEnabled(false);
        return;
    }
    final List<ProjectSystemId> systemIds = getSystemIds(e);
    if (systemIds.isEmpty()) {
        e.getPresentation().setEnabled(false);
        return;
    }
    final String name = StringUtil.join(systemIds, projectSystemId -> projectSystemId.getReadableName(), ",");
    e.getPresentation().setText(ExternalSystemBundle.message("action.refresh.all.projects.text", name));
    e.getPresentation().setDescription(ExternalSystemBundle.message("action.refresh.all.projects.description", name));
    ExternalSystemProcessingManager processingManager = ServiceManager.getService(ExternalSystemProcessingManager.class);
    e.getPresentation().setEnabled(!processingManager.hasTaskOfTypeInProgress(ExternalSystemTaskType.RESOLVE_PROJECT, project));
}
Also used : Project(com.intellij.openapi.project.Project) ExternalSystemProcessingManager(com.intellij.openapi.externalSystem.service.internal.ExternalSystemProcessingManager) ProjectSystemId(com.intellij.openapi.externalSystem.model.ProjectSystemId)

Example 18 with ProjectSystemId

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

the class ToolWindowTaskService method processData.

@Override
protected void processData(@NotNull Collection<DataNode<TaskData>> nodes, @NotNull Project project) {
    if (nodes.isEmpty()) {
        return;
    }
    ProjectSystemId externalSystemId = nodes.iterator().next().getData().getOwner();
    ExternalSystemManager<?, ?, ?, ?, ?> manager = ExternalSystemApiUtil.getManager(externalSystemId);
    assert manager != null;
    ExternalSystemKeymapExtension.updateActions(project, nodes);
    MultiMap<ExternalConfigPathAware, DataNode<TaskData>> grouped = ContainerUtil.groupBy(nodes, TASK_HOLDER_RETRIEVAL_STRATEGY);
    Map<String, Collection<ExternalTaskPojo>> data = ContainerUtilRt.newHashMap();
    for (Map.Entry<ExternalConfigPathAware, Collection<DataNode<TaskData>>> entry : grouped.entrySet()) {
        data.put(entry.getKey().getLinkedExternalProjectPath(), ContainerUtilRt.map2List(entry.getValue(), MAPPER));
    }
    AbstractExternalSystemLocalSettings settings = manager.getLocalSettingsProvider().fun(project);
    Map<String, Collection<ExternalTaskPojo>> availableTasks = ContainerUtilRt.newHashMap(settings.getAvailableTasks());
    availableTasks.putAll(data);
    settings.setAvailableTasks(availableTasks);
}
Also used : ExternalConfigPathAware(com.intellij.openapi.externalSystem.model.project.ExternalConfigPathAware) AbstractExternalSystemLocalSettings(com.intellij.openapi.externalSystem.settings.AbstractExternalSystemLocalSettings) DataNode(com.intellij.openapi.externalSystem.model.DataNode) Collection(java.util.Collection) ProjectSystemId(com.intellij.openapi.externalSystem.model.ProjectSystemId) Map(java.util.Map) MultiMap(com.intellij.util.containers.MultiMap) TaskData(com.intellij.openapi.externalSystem.model.task.TaskData)

Example 19 with ProjectSystemId

use of com.intellij.openapi.externalSystem.model.ProjectSystemId in project android by JetBrains.

the class AndroidGradleProjectResolver method doCreateModule.

@NotNull
private DataNode<ModuleData> doCreateModule(@NotNull IdeaModule gradleModule, @NotNull DataNode<ProjectData> projectDataNode) {
    String moduleName = gradleModule.getName();
    if (moduleName == null) {
        throw new IllegalStateException("Module with undefined name detected: " + gradleModule);
    }
    String projectPath = projectDataNode.getData().getLinkedExternalProjectPath();
    String moduleConfigPath = getModuleConfigPath(resolverCtx, gradleModule, projectPath);
    String gradlePath = gradleModule.getGradleProject().getPath();
    String moduleId = isEmpty(gradlePath) || ":".equals(gradlePath) ? moduleName : gradlePath;
    ProjectSystemId owner = GradleConstants.SYSTEM_ID;
    String typeId = StdModuleTypes.JAVA.getId();
    ModuleData moduleData = new ModuleData(moduleId, owner, typeId, moduleName, moduleConfigPath, moduleConfigPath);
    ExternalProject externalProject = resolverCtx.getExtraProject(gradleModule, ExternalProject.class);
    if (externalProject != null) {
        moduleData.setDescription(externalProject.getDescription());
    }
    return projectDataNode.createChild(ProjectKeys.MODULE, moduleData);
}
Also used : ExternalProject(org.jetbrains.plugins.gradle.model.ExternalProject) ProjectSystemId(com.intellij.openapi.externalSystem.model.ProjectSystemId) ModuleData(com.intellij.openapi.externalSystem.model.project.ModuleData) NotNull(org.jetbrains.annotations.NotNull)

Example 20 with ProjectSystemId

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

the class ExternalSystemNotificationManager method clearNotifications.

public void clearNotifications(@Nullable final String groupName, @NotNull final NotificationSource notificationSource, @NotNull final ProjectSystemId externalSystemId) {
    myMessageCounter.remove(groupName, notificationSource, externalSystemId);
    myUpdater.submit(() -> {
        if (myProject.isDisposed())
            return;
        for (Iterator<Notification> iterator = myNotifications.iterator(); iterator.hasNext(); ) {
            Notification notification = iterator.next();
            if (groupName == null || groupName.equals(notification.getGroupId())) {
                notification.expire();
                iterator.remove();
            }
        }
        final ToolWindow toolWindow = ToolWindowManager.getInstance(myProject).getToolWindow(ToolWindowId.MESSAGES_WINDOW);
        if (toolWindow == null)
            return;
        final Pair<NotificationSource, ProjectSystemId> contentIdPair = Pair.create(notificationSource, externalSystemId);
        final MessageView messageView = ServiceManager.getService(myProject, MessageView.class);
        UIUtil.invokeLaterIfNeeded(() -> {
            if (myProject.isDisposed())
                return;
            for (Content content : messageView.getContentManager().getContents()) {
                if (!content.isPinned() && contentIdPair.equals(content.getUserData(CONTENT_ID_KEY))) {
                    if (groupName == null) {
                        messageView.getContentManager().removeContent(content, true);
                    } else {
                        assert content.getComponent() instanceof NewEditableErrorTreeViewPanel;
                        NewEditableErrorTreeViewPanel errorTreeView = (NewEditableErrorTreeViewPanel) content.getComponent();
                        ErrorViewStructure errorViewStructure = errorTreeView.getErrorViewStructure();
                        errorViewStructure.removeGroup(groupName);
                    }
                }
            }
        });
    });
}
Also used : ToolWindow(com.intellij.openapi.wm.ToolWindow) MessageView(com.intellij.ui.content.MessageView) Content(com.intellij.ui.content.Content) ProjectSystemId(com.intellij.openapi.externalSystem.model.ProjectSystemId) Notification(com.intellij.notification.Notification)

Aggregations

ProjectSystemId (com.intellij.openapi.externalSystem.model.ProjectSystemId)36 Project (com.intellij.openapi.project.Project)10 Map (java.util.Map)5 ExternalConfigPathAware (com.intellij.openapi.externalSystem.model.project.ExternalConfigPathAware)4 ProjectData (com.intellij.openapi.externalSystem.model.project.ProjectData)4 File (java.io.File)4 NotNull (org.jetbrains.annotations.NotNull)4 ExternalSystemManager (com.intellij.openapi.externalSystem.ExternalSystemManager)3 DataNode (com.intellij.openapi.externalSystem.model.DataNode)3 ExternalProjectInfo (com.intellij.openapi.externalSystem.model.ExternalProjectInfo)3 ModuleData (com.intellij.openapi.externalSystem.model.project.ModuleData)3 TaskData (com.intellij.openapi.externalSystem.model.task.TaskData)3 ExternalProjectSettings (com.intellij.openapi.externalSystem.settings.ExternalProjectSettings)3 Collection (java.util.Collection)3 RunnerAndConfigurationSettings (com.intellij.execution.RunnerAndConfigurationSettings)2 Presentation (com.intellij.openapi.actionSystem.Presentation)2 Logger (com.intellij.openapi.diagnostic.Logger)2 ExternalSystemTaskExecutionSettings (com.intellij.openapi.externalSystem.model.execution.ExternalSystemTaskExecutionSettings)2 ExternalSystemProcessingManager (com.intellij.openapi.externalSystem.service.internal.ExternalSystemProcessingManager)2 AbstractExternalSystemSettings (com.intellij.openapi.externalSystem.settings.AbstractExternalSystemSettings)2