Search in sources :

Example 1 with ProjectNode

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

the class GradleOpenProjectCompositeConfigurationAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    final Project project = getProject(e);
    if (project == null)
        return;
    final ProjectNode projectNode = ExternalSystemDataKeys.SELECTED_PROJECT_NODE.getData(e.getDataContext());
    if (projectNode == null || projectNode.getData() == null)
        return;
    new GradleProjectCompositeSelectorDialog(project, projectNode.getData().getLinkedExternalProjectPath()).showAndGet();
}
Also used : Project(com.intellij.openapi.project.Project) ProjectNode(com.intellij.openapi.externalSystem.view.ProjectNode) GradleProjectCompositeSelectorDialog(org.jetbrains.plugins.gradle.ui.GradleProjectCompositeSelectorDialog)

Example 2 with ProjectNode

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

the class SelectExternalProjectDialog method doOKAction.

@Override
protected void doOKAction() {
    SimpleNode node = getSelectedNode();
    if (node instanceof NullNode)
        node = null;
    myResult = node instanceof ProjectNode ? ((ProjectNode) node).getData() : null;
    super.doOKAction();
}
Also used : ProjectNode(com.intellij.openapi.externalSystem.view.ProjectNode) NullNode(com.intellij.ui.treeStructure.NullNode) SimpleNode(com.intellij.ui.treeStructure.SimpleNode)

Example 3 with ProjectNode

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

the class DetachExternalProjectAction method perform.

@Override
public void perform(@NotNull final Project project, @NotNull ProjectSystemId projectSystemId, @NotNull ProjectData projectData, @NotNull AnActionEvent e) {
    e.getPresentation().setText(ExternalSystemBundle.message("action.detach.external.project.text", projectSystemId.getReadableName()));
    final ProjectNode projectNode = ExternalSystemDataKeys.SELECTED_PROJECT_NODE.getData(e.getDataContext());
    assert projectNode != null;
    ExternalSystemApiUtil.getLocalSettings(project, projectSystemId).forgetExternalProjects(Collections.singleton(projectData.getLinkedExternalProjectPath()));
    ExternalSystemApiUtil.getSettings(project, projectSystemId).unlinkExternalProject(projectData.getLinkedExternalProjectPath());
    ExternalProjectsManager.getInstance(project).forgetExternalProjectData(projectSystemId, projectData.getLinkedExternalProjectPath());
    // Process orphan modules.
    List<Module> orphanModules = ContainerUtilRt.newArrayList();
    for (Module module : ModuleManager.getInstance(project).getModules()) {
        if (!ExternalSystemApiUtil.isExternalSystemAwareModule(projectSystemId, module))
            continue;
        String path = ExternalSystemApiUtil.getExternalRootProjectPath(module);
        if (projectData.getLinkedExternalProjectPath().equals(path)) {
            orphanModules.add(module);
        }
    }
    if (!orphanModules.isEmpty()) {
        projectNode.getGroup().remove(projectNode);
        ProjectDataManager.getInstance().removeData(ProjectKeys.MODULE, orphanModules, Collections.<DataNode<ModuleData>>emptyList(), projectData, project, false);
    }
}
Also used : ProjectNode(com.intellij.openapi.externalSystem.view.ProjectNode) ModuleData(com.intellij.openapi.externalSystem.model.project.ModuleData) Module(com.intellij.openapi.module.Module)

Example 4 with ProjectNode

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

the class ExternalSystemSelectProjectDataToImportAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    final Project project = getProject(e);
    final ProjectSystemId projectSystemId = getSystemId(e);
    final List<ExternalSystemNode> selectedNodes = ExternalSystemDataKeys.SELECTED_NODES.getData(e.getDataContext());
    final ExternalProjectInfo projectInfo;
    final ExternalSystemNode<?> externalSystemNode = ContainerUtil.getFirstItem(selectedNodes);
    if (externalSystemNode == null) {
        projectInfo = ContainerUtil.getFirstItem(ProjectDataManager.getInstance().getExternalProjectsData(project, projectSystemId));
    } else {
        final ProjectNode projectNode = externalSystemNode instanceof ProjectNode ? (ProjectNode) externalSystemNode : externalSystemNode.findParent(ProjectNode.class);
        assert projectNode != null;
        final ProjectData projectData = projectNode.getData();
        assert projectData != null;
        projectInfo = ProjectDataManager.getInstance().getExternalProjectData(project, projectSystemId, projectData.getLinkedExternalProjectPath());
    }
    final ExternalProjectDataSelectorDialog dialog;
    if (projectInfo != null) {
        dialog = new ExternalProjectDataSelectorDialog(project, projectInfo, externalSystemNode != null ? externalSystemNode.getData() : null);
        dialog.showAndGet();
    }
}
Also used : ExternalProjectInfo(com.intellij.openapi.externalSystem.model.ExternalProjectInfo) Project(com.intellij.openapi.project.Project) ExternalProjectDataSelectorDialog(com.intellij.openapi.externalSystem.service.ui.ExternalProjectDataSelectorDialog) ProjectSystemId(com.intellij.openapi.externalSystem.model.ProjectSystemId) ProjectNode(com.intellij.openapi.externalSystem.view.ProjectNode) ExternalSystemNode(com.intellij.openapi.externalSystem.view.ExternalSystemNode) ProjectData(com.intellij.openapi.externalSystem.model.project.ProjectData)

Example 5 with ProjectNode

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

the class ToggleAutoImportAction method getProjectSettings.

@Nullable
private ExternalProjectSettings getProjectSettings(AnActionEvent e) {
    final ProjectNode projectNode = ExternalSystemDataKeys.SELECTED_PROJECT_NODE.getData(e.getDataContext());
    if (projectNode == null || projectNode.getData() == null)
        return null;
    final AbstractExternalSystemSettings externalSystemSettings = ExternalSystemApiUtil.getSettings(getProject(e), getSystemId(e));
    return externalSystemSettings.getLinkedProjectSettings(projectNode.getData().getLinkedExternalProjectPath());
}
Also used : AbstractExternalSystemSettings(com.intellij.openapi.externalSystem.settings.AbstractExternalSystemSettings) ProjectNode(com.intellij.openapi.externalSystem.view.ProjectNode) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

ProjectNode (com.intellij.openapi.externalSystem.view.ProjectNode)7 Project (com.intellij.openapi.project.Project)3 ProjectSystemId (com.intellij.openapi.externalSystem.model.ProjectSystemId)2 ModuleData (com.intellij.openapi.externalSystem.model.project.ModuleData)2 ProjectData (com.intellij.openapi.externalSystem.model.project.ProjectData)2 AnAction (com.intellij.openapi.actionSystem.AnAction)1 ExternalProjectInfo (com.intellij.openapi.externalSystem.model.ExternalProjectInfo)1 ExternalSystemShortcutsManager (com.intellij.openapi.externalSystem.service.project.manage.ExternalSystemShortcutsManager)1 ExternalProjectDataSelectorDialog (com.intellij.openapi.externalSystem.service.ui.ExternalProjectDataSelectorDialog)1 AbstractExternalSystemSettings (com.intellij.openapi.externalSystem.settings.AbstractExternalSystemSettings)1 ExternalSystemNode (com.intellij.openapi.externalSystem.view.ExternalSystemNode)1 ModuleNode (com.intellij.openapi.externalSystem.view.ModuleNode)1 EditKeymapsDialog (com.intellij.openapi.keymap.impl.ui.EditKeymapsDialog)1 Module (com.intellij.openapi.module.Module)1 NullNode (com.intellij.ui.treeStructure.NullNode)1 SimpleNode (com.intellij.ui.treeStructure.SimpleNode)1 Nullable (org.jetbrains.annotations.Nullable)1 GradleProjectSettings (org.jetbrains.plugins.gradle.settings.GradleProjectSettings)1 GradleProjectCompositeSelectorDialog (org.jetbrains.plugins.gradle.ui.GradleProjectCompositeSelectorDialog)1