Search in sources :

Example 6 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 7 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)

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