diff --git a/platform/external-system-impl/api-dump.txt b/platform/external-system-impl/api-dump.txt index e9200c8f9380..5fbfd3d2c6fc 100644 --- a/platform/external-system-impl/api-dump.txt +++ b/platform/external-system-impl/api-dump.txt @@ -1352,40 +1352,6 @@ c:com.intellij.openapi.externalSystem.view.ExternalProjectsViewAdapter - showInheritedTasks():Z - updateUpTo(com.intellij.openapi.externalSystem.view.ExternalSystemNode):V - useTasksNode():Z -f:com.intellij.openapi.externalSystem.view.ExternalProjectsViewImpl -- com.intellij.openapi.ui.SimpleToolWindowPanel -- com.intellij.openapi.Disposable -- com.intellij.openapi.externalSystem.view.ExternalProjectsView -- sf:LOG:com.intellij.openapi.diagnostic.Logger -- (com.intellij.openapi.project.Project,com.intellij.openapi.wm.ex.ToolWindowEx,com.intellij.openapi.externalSystem.model.ProjectSystemId):V -- addListener(com.intellij.openapi.externalSystem.view.ExternalProjectsView$Listener):V -- createNodes(com.intellij.openapi.externalSystem.view.ExternalProjectsView,com.intellij.openapi.externalSystem.view.ExternalSystemNode,com.intellij.openapi.externalSystem.model.DataNode):java.util.List -- dispose():V -- getDisplayName(com.intellij.openapi.externalSystem.model.DataNode):java.lang.String -- getErrorLevelRecursively(com.intellij.openapi.externalSystem.model.DataNode):com.intellij.openapi.externalSystem.view.ExternalProjectsStructure$ErrorLevel -- getGroupModules():Z -- getGroupTasks():Z -- getNotificationGroup():com.intellij.notification.NotificationGroup -- getProject():com.intellij.openapi.project.Project -- getShowIgnored():Z -- getState():com.intellij.openapi.externalSystem.view.ExternalProjectsViewState -- getStructure():com.intellij.openapi.externalSystem.view.ExternalProjectsStructure -- getSystemId():com.intellij.openapi.externalSystem.model.ProjectSystemId -- getTaskActivator():com.intellij.openapi.externalSystem.service.project.manage.ExternalSystemTaskActivator -- getUiAware():com.intellij.openapi.externalSystem.ExternalSystemUiAware -- handleDoubleClickOrEnter(com.intellij.openapi.externalSystem.view.ExternalSystemNode,java.lang.String,java.awt.event.InputEvent):V -- init():V -- s:isNoBackgroundMode():Z -- loadState(com.intellij.openapi.externalSystem.view.ExternalProjectsViewState):V -- scheduleStructureUpdate():V -- setGroupModules(Z):V -- setGroupTasks(Z):V -- setShowIgnored(Z):V -- setShowInheritedTasks(Z):V -- showInheritedTasks():Z -- uiDataSnapshot(com.intellij.openapi.actionSystem.DataSink):V -- updateUpTo(com.intellij.openapi.externalSystem.view.ExternalSystemNode):V -- useTasksNode():Z a:com.intellij.openapi.externalSystem.view.ExternalSystemNode - com.intellij.ui.treeStructure.SimpleNode - java.lang.Comparable diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ExternalProjectsState.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ExternalProjectsState.java index 374581f50814..9980da606ad8 100644 --- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ExternalProjectsState.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ExternalProjectsState.java @@ -13,7 +13,7 @@ import java.util.Map; * @author Vladislav.Soroka */ @ApiStatus.Internal -public class ExternalProjectsState { +public final class ExternalProjectsState { private final Map myExternalSystemsState = FactoryMap.create(key -> new State()); @Property(surroundWithTag = false) @@ -30,7 +30,7 @@ public class ExternalProjectsState { public boolean storeExternally = false; @Tag("state") - public static class State { + public static final class State { private ExternalProjectsViewState projectsViewState = new ExternalProjectsViewState(); private final Map myExternalSystemsTaskActivation = FactoryMap.createMap(key-> new TaskActivationState(), LinkedHashMap::new); diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/task/ui/AbstractExternalSystemToolWindowFactory.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/task/ui/AbstractExternalSystemToolWindowFactory.java index a877fab9f6f4..e377d70801a8 100644 --- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/task/ui/AbstractExternalSystemToolWindowFactory.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/task/ui/AbstractExternalSystemToolWindowFactory.java @@ -39,7 +39,7 @@ public abstract class AbstractExternalSystemToolWindowFactory implements ToolWin contentManager.addContent(new ContentImpl(createInitializingLabel(), "", false)); ExternalProjectsManager.getInstance(project).runWhenInitialized(() -> { - ExternalProjectsViewImpl projectView = new ExternalProjectsViewImpl(project, (ToolWindowEx)toolWindow, externalSystemId); + ExternalProjectsViewImpl projectView = new ExternalProjectsViewImpl(toolWindow.getDisposable(), project, (ToolWindowEx)toolWindow, externalSystemId); ExternalProjectsManagerImpl.getInstance(project).registerView(projectView); ContentImpl taskContent = new ContentImpl(projectView, "", true); contentManager.removeAllContents(true); diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/ui/SelectExternalSystemNodeDialog.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/ui/SelectExternalSystemNodeDialog.java index 357a81d92772..797e801ed386 100644 --- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/ui/SelectExternalSystemNodeDialog.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/ui/SelectExternalSystemNodeDialog.java @@ -37,7 +37,6 @@ import java.util.function.Predicate; */ @ApiStatus.Internal public class SelectExternalSystemNodeDialog extends DialogWrapper { - private final @NotNull SimpleTree myTree; private final @Nullable Predicate mySelector; protected @Nullable Boolean groupTasks; @@ -46,7 +45,7 @@ public class SelectExternalSystemNodeDialog extends DialogWrapper { public SelectExternalSystemNodeDialog(@NotNull ProjectSystemId systemId, @NotNull Project project, @NotNull @NlsContexts.DialogTitle String title, - Class nodeClass, + Class> nodeClass, @Nullable Predicate selector) { //noinspection unchecked this(systemId, project, title, new Class[]{nodeClass}, selector); @@ -55,7 +54,7 @@ public class SelectExternalSystemNodeDialog extends DialogWrapper { public SelectExternalSystemNodeDialog(@NotNull ProjectSystemId systemId, @NotNull Project project, @NotNull @NlsContexts.DialogTitle String title, - final Class[] nodeClasses, + final Class>[] nodeClasses, @Nullable Predicate selector) { super(project, false); mySelector = selector; @@ -68,14 +67,13 @@ public class SelectExternalSystemNodeDialog extends DialogWrapper { if (projectsView == null) { ToolWindow toolWindow = ExternalToolWindowManager.getToolWindow(project, systemId); if (toolWindow instanceof ToolWindowEx) { - projectsView = new ExternalProjectsViewImpl(project, (ToolWindowEx)toolWindow, systemId); - Disposer.register(getDisposable(), (ExternalProjectsViewImpl)projectsView); + projectsView = new ExternalProjectsViewImpl(getDisposable(), project, (ToolWindowEx)toolWindow, systemId); } } if(projectsView != null) { final ExternalProjectsStructure treeStructure = new ExternalProjectsStructure(project, myTree) { @Override - protected Class[] getVisibleNodesClasses() { + protected Class>[] getVisibleNodesClasses() { return nodeClasses; } @@ -141,7 +139,7 @@ public class SelectExternalSystemNodeDialog extends DialogWrapper { return myTree; } - protected void handleDoubleClickOrEnter(@NotNull ExternalSystemNode node, @Nullable String actionId, InputEvent inputEvent) { + protected void handleDoubleClickOrEnter(@NotNull ExternalSystemNode node, @Nullable String actionId, InputEvent inputEvent) { } protected SimpleNode getSelectedNode() { diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/ui/SelectExternalTaskDialog.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/ui/SelectExternalTaskDialog.java index c03ad08666ae..38a4410be99c 100644 --- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/ui/SelectExternalTaskDialog.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/ui/SelectExternalTaskDialog.java @@ -19,13 +19,9 @@ import org.jetbrains.annotations.Nullable; import java.awt.event.InputEvent; -/** - * @author Vladislav.Soroka - */ @ApiStatus.Internal -public class SelectExternalTaskDialog extends SelectExternalSystemNodeDialog { - - private static final Class[] NODE_CLASSES = ContainerUtil.ar( +public final class SelectExternalTaskDialog extends SelectExternalSystemNodeDialog { + private static final Class>[] NODE_CLASSES = ContainerUtil.ar( ProjectNode.class, ModuleNode.class, TaskNode.class diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/view/ExternalProjectsViewImpl.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/view/ExternalProjectsViewImpl.java index 9b0b9dbc8a9c..408bf995320f 100644 --- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/view/ExternalProjectsViewImpl.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/view/ExternalProjectsViewImpl.java @@ -59,15 +59,17 @@ import org.jetbrains.annotations.Nullable; import javax.swing.tree.TreeSelectionModel; import java.awt.*; import java.awt.event.InputEvent; -import java.util.List; import java.util.*; +import java.util.List; /** * @author Vladislav.Soroka */ -public final class ExternalProjectsViewImpl extends SimpleToolWindowPanel implements ExternalProjectsView, Disposable { +@ApiStatus.Internal +public final class ExternalProjectsViewImpl extends SimpleToolWindowPanel implements ExternalProjectsView { public static final Logger LOG = Logger.getInstance(ExternalProjectsViewImpl.class); + @NotNull private final Disposable parentDisposable; private final @NotNull Project myProject; private final @NotNull ExternalProjectsManagerImpl myProjectsManager; private final @NotNull ToolWindowEx myToolWindow; @@ -82,8 +84,14 @@ public final class ExternalProjectsViewImpl extends SimpleToolWindowPanel implem private ExternalProjectsViewState myState = new ExternalProjectsViewState(); - public ExternalProjectsViewImpl(@NotNull Project project, @NotNull ToolWindowEx toolWindow, @NotNull ProjectSystemId externalSystemId) { + public ExternalProjectsViewImpl(@NotNull Disposable parentDisposable, + @NotNull Project project, + @NotNull ToolWindowEx toolWindow, + @NotNull ProjectSystemId externalSystemId) { super(true, true); + + this.parentDisposable = parentDisposable; + myProject = project; myToolWindow = toolWindow; myExternalSystemId = externalSystemId; @@ -98,7 +106,15 @@ public final class ExternalProjectsViewImpl extends SimpleToolWindowPanel implem Condition contributorPredicate = c -> { return ProjectSystemId.IDE.equals(c.getSystemId()) || myExternalSystemId.equals(c.getSystemId()); }; - myViewContributors = new ArrayList<>(ContainerUtil.filter(ExternalSystemViewContributor.EP_NAME.getExtensions(), contributorPredicate)); + myViewContributors = new ArrayList<>(ContainerUtil.filter(ExternalSystemViewContributor.EP_NAME.getExtensionList(), contributorPredicate)); + + Disposer.register(parentDisposable, () -> { + this.listeners.clear(); + this.myViewContributors.clear(); + this.myStructure = null; + this.myTree = null; + }); + ExternalSystemViewContributor.EP_NAME.addExtensionPointListener(new ExtensionPointListener<>() { @Override public void extensionAdded(@NotNull ExternalSystemViewContributor extension, @NotNull PluginDescriptor pluginDescriptor) { @@ -113,7 +129,7 @@ public final class ExternalProjectsViewImpl extends SimpleToolWindowPanel implem myViewContributors.remove(extension); } } - }, this); + }, parentDisposable); setName(myExternalSystemId.getReadableName() + " tool window"); Touchbar.setActions(this, "ExternalSystem.RefreshAllProjects"); @@ -177,10 +193,9 @@ public final class ExternalProjectsViewImpl extends SimpleToolWindowPanel implem } public void init() { - Disposer.register(myProject, this); initTree(); - MessageBusConnection busConnection = myProject.getMessageBus().connect(this); + MessageBusConnection busConnection = myProject.getMessageBus().connect(parentDisposable); busConnection.subscribe(ToolWindowManagerListener.TOPIC, new ToolWindowManagerListener() { boolean wasVisible; @@ -204,9 +219,9 @@ public final class ExternalProjectsViewImpl extends SimpleToolWindowPanel implem } }); - getShortcutsManager().addListener(() -> scheduleTaskAndRunConfigUpdate(), this); + getShortcutsManager().addListener(() -> scheduleTaskAndRunConfigUpdate(), parentDisposable); - getTaskActivator().addListener(() -> scheduleTaskAndRunConfigUpdate(), this); + getTaskActivator().addListener(() -> scheduleTaskAndRunConfigUpdate(), parentDisposable); busConnection.subscribe(RunManagerListener.TOPIC, new RunManagerListener() { private void changed() { @@ -232,7 +247,7 @@ public final class ExternalProjectsViewImpl extends SimpleToolWindowPanel implem } }); - myToolWindow.setAdditionalGearActions(createAdditionalGearActionsGroup()); + myToolWindow.setAdditionalGearActions(createAdditionalGearActionsGroup(parentDisposable)); scheduleStructureUpdate(); } @@ -260,7 +275,7 @@ public final class ExternalProjectsViewImpl extends SimpleToolWindowPanel implem listeners.add(listener); } - private ActionGroup createAdditionalGearActionsGroup() { + private ActionGroup createAdditionalGearActionsGroup(@NotNull Disposable parentDisposable) { ActionManager actionManager = ActionManager.getInstance(); DefaultActionGroup group = new DefaultActionGroup(); String[] ids = new String[]{"ExternalSystem.GroupModules", "ExternalSystem.GroupTasks", "ExternalSystem.ShowInheritedTasks", "ExternalSystem.ShowIgnored"}; @@ -269,7 +284,7 @@ public final class ExternalProjectsViewImpl extends SimpleToolWindowPanel implem if (gearAction instanceof ExternalSystemViewGearAction) { ((ExternalSystemViewGearAction)gearAction).setView(this); group.add(gearAction); - Disposer.register(this, () -> ((ExternalSystemViewGearAction)gearAction).setView(null)); + Disposer.register(parentDisposable, () -> ((ExternalSystemViewGearAction)gearAction).setView(null)); } } return group; @@ -278,7 +293,7 @@ public final class ExternalProjectsViewImpl extends SimpleToolWindowPanel implem @ApiStatus.Internal public void initStructure() { myStructure = new ExternalProjectsStructure(myProject, myTree); - Disposer.register(this, myStructure); + Disposer.register(parentDisposable, myStructure); myStructure.init(this); } @@ -553,7 +568,7 @@ public final class ExternalProjectsViewImpl extends SimpleToolWindowPanel implem String projectPath = null; - for (ExternalSystemNode node : selectedNodes) { + for (ExternalSystemNode node : selectedNodes) { final Object data = node.getData(); if (data instanceof TaskData taskData) { if (projectPath == null) { @@ -576,12 +591,4 @@ public final class ExternalProjectsViewImpl extends SimpleToolWindowPanel implem return ExternalSystemTaskLocation.create(myProject, myExternalSystemId, projectPath, taskExecutionInfo); } - - @Override - public void dispose() { - this.listeners.clear(); - this.myViewContributors.clear(); - this.myStructure = null; - this.myTree = null; - } } \ No newline at end of file diff --git a/plugins/gradle/java/testSources/importing/GradleToolWindowTest.kt b/plugins/gradle/java/testSources/importing/GradleToolWindowTest.kt index d1bb5c85e5d7..618baf8a33e2 100644 --- a/plugins/gradle/java/testSources/importing/GradleToolWindowTest.kt +++ b/plugins/gradle/java/testSources/importing/GradleToolWindowTest.kt @@ -52,7 +52,7 @@ open class GradleToolWindowTest : GradleImportingTestCase() { super.setUp() isPreview = false toolWindow = ToolWindowHeadlessManagerImpl.MockToolWindow(myProject) - view = ExternalProjectsViewImpl(myProject, toolWindow!!, externalSystemId) + view = ExternalProjectsViewImpl(myProject, myProject, toolWindow!!, externalSystemId) runInEdtAndWait { ExternalProjectsManagerImpl.getInstance(myProject).registerView(view) view.initStructure()