introduce ProjectViewImpl.getDefaultViewId for Android Studio

This commit is contained in:
Vladimir Krivosheev
2018-05-02 18:10:49 +02:00
parent 322dd24aed
commit 318ece93f4
2 changed files with 20 additions and 14 deletions
@@ -1,6 +1,4 @@
/*
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
*/
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.ide.impl;
import com.intellij.ide.CompositeSelectInTarget;
@@ -10,7 +8,7 @@ import com.intellij.ide.projectView.ProjectView;
import com.intellij.ide.projectView.SelectableTreeStructureProvider;
import com.intellij.ide.projectView.TreeStructureProvider;
import com.intellij.ide.projectView.impl.AbstractProjectViewPane;
import com.intellij.ide.projectView.impl.ProjectViewPane;
import com.intellij.ide.projectView.impl.ProjectViewImpl;
import com.intellij.ide.scratch.ScratchProjectViewPane;
import com.intellij.ide.scratch.ScratchUtil;
import com.intellij.openapi.application.ApplicationManager;
@@ -63,7 +61,7 @@ public abstract class ProjectViewSelectInTarget extends SelectInTargetPsiWrapper
if (projectView == null) return ActionCallback.REJECTED;
if (ApplicationManager.getApplication().isUnitTestMode()) {
AbstractProjectViewPane pane = projectView.getProjectViewPaneById(ObjectUtils.chooseNotNull(viewId, ProjectViewPane.ID));
AbstractProjectViewPane pane = projectView.getProjectViewPaneById(ObjectUtils.chooseNotNull(viewId, ProjectViewImpl.getDefaultViewId()));
pane.select(toSelect, virtualFile, requestFocus);
return ActionCallback.DONE;
}
@@ -79,7 +77,7 @@ public abstract class ProjectViewSelectInTarget extends SelectInTargetPsiWrapper
ActionCallback result = new ActionCallback();
final Runnable runnable = () -> {
Runnable r = () -> projectView.selectCB(toSelectSupplier.get(), virtualFile, requestFocus).notify(result);
projectView.changeViewCB(ObjectUtils.chooseNotNull(viewId, ProjectViewPane.ID), subviewId).doWhenProcessed(r);
projectView.changeViewCB(ObjectUtils.chooseNotNull(viewId, ProjectViewImpl.getDefaultViewId()), subviewId).doWhenProcessed(r);
};
if (requestFocus) {
@@ -73,10 +73,7 @@ import com.intellij.ui.content.ContentManagerAdapter;
import com.intellij.ui.content.ContentManagerEvent;
import com.intellij.ui.switcher.QuickActionProvider;
import com.intellij.ui.tree.TreeVisitor;
import com.intellij.util.ArrayUtil;
import com.intellij.util.IJSwingUtilities;
import com.intellij.util.PlatformIcons;
import com.intellij.util.SmartList;
import com.intellij.util.*;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.JBIterable;
import com.intellij.util.messages.MessageBusConnection;
@@ -155,7 +152,7 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
private static final DataKey<ProjectViewImpl> DATA_KEY = DataKey.create("com.intellij.ide.projectView.impl.ProjectViewImpl");
private DefaultActionGroup myActionGroup;
private String mySavedPaneId = ProjectViewPane.ID;
private String mySavedPaneId = getDefaultViewId();
private String mySavedPaneSubId;
@NonNls private static final String ELEMENT_NAVIGATOR = "navigator";
@NonNls private static final String ELEMENT_PANES = "panes";
@@ -699,7 +696,7 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
collapseAllAction.getTemplatePresentation().setIcon(AllIcons.General.CollapseAll);
collapseAllAction.getTemplatePresentation().setHoveredIcon(AllIcons.General.CollapseAllHover);
titleActions.add(collapseAllAction);
getProjectViewPaneById(myCurrentViewId == null ? ProjectViewPane.ID : myCurrentViewId).addToolbarActions(myActionGroup);
getProjectViewPaneById(myCurrentViewId == null ? getDefaultViewId() : myCurrentViewId).addToolbarActions(myActionGroup);
ToolWindowEx window = (ToolWindowEx)ToolWindowManager.getInstance(myProject).getToolWindow(ToolWindowId.PROJECT_VIEW);
if (window != null) {
@@ -1387,7 +1384,7 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
mySavedPaneId = navigatorElement.getAttributeValue(ATTRIBUTE_CURRENT_VIEW);
mySavedPaneSubId = navigatorElement.getAttributeValue(ATTRIBUTE_CURRENT_SUBVIEW);
if (mySavedPaneId == null) {
mySavedPaneId = ProjectViewPane.ID;
mySavedPaneId = getDefaultViewId();
mySavedPaneSubId = null;
}
@@ -1417,6 +1414,17 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
}
}
@NotNull
public static String getDefaultViewId() {
//noinspection SpellCheckingInspection
if (!"AndroidStudio".equals(PlatformUtils.getPlatformPrefix()) || Boolean.getBoolean("studio.projectview")) {
return ProjectViewPane.ID;
}
else {
return "AndroidView";
}
}
private void readPaneState(@NotNull Element panesElement) {
@SuppressWarnings({"unchecked"})
final List<Element> paneElements = panesElement.getChildren(ELEMENT_PANE);
@@ -1449,7 +1457,7 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
AbstractProjectViewPane currentPane = getCurrentProjectViewPane();
if (currentPane != null) {
String subId = currentPane.getSubId();
if (subId != null || !currentPane.getId().equals(ProjectViewPane.ID)) {
if (subId != null || !currentPane.getId().equals(getDefaultViewId())) {
navigatorElement.setAttribute(ATTRIBUTE_CURRENT_VIEW, currentPane.getId());
if (subId != null) {
navigatorElement.setAttribute(ATTRIBUTE_CURRENT_SUBVIEW, subId);