mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
cleanup
GitOrigin-RevId: e7055959d7aadeeeb6c8617092fa19a21a7b3d9f
This commit is contained in:
committed by
intellij-monorepo-bot
parent
4775b3525a
commit
dc2ce633f7
@@ -1,15 +1,17 @@
|
||||
|
||||
// Copyright 2000-2019 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.favoritesTreeView;
|
||||
|
||||
import com.intellij.ide.projectView.ProjectView;
|
||||
import com.intellij.ide.projectView.impl.GroupByTypeComparator;
|
||||
import com.intellij.ide.util.treeView.NodeDescriptor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public class FavoritesComparator extends GroupByTypeComparator {
|
||||
public FavoritesComparator(ProjectView view, String id) {
|
||||
class FavoritesComparator extends GroupByTypeComparator {
|
||||
FavoritesComparator(@NotNull ProjectView view, String id) {
|
||||
super(view, id);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
// Copyright 2000-2019 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.favoritesTreeView;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -21,7 +7,8 @@ import org.jetbrains.annotations.NotNull;
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public interface FavoritesListener {
|
||||
void rootsChanged();
|
||||
default void rootsChanged() {
|
||||
}
|
||||
|
||||
void listAdded(@NotNull String listName);
|
||||
|
||||
|
||||
@@ -50,7 +50,10 @@ public final class FavoritesManager implements ProjectComponent, JDOMExternaliza
|
||||
|
||||
@NotNull
|
||||
private Map<String, FavoritesListProvider> getProviders() {
|
||||
if (myProviders != null) return myProviders;
|
||||
if (myProviders != null) {
|
||||
return myProviders;
|
||||
}
|
||||
|
||||
myProviders = new HashMap<>();
|
||||
if (!ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
final FavoritesListProvider[] providers = EP_NAME.getExtensions(myProject);
|
||||
|
||||
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
// Copyright 2000-2019 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.favoritesTreeView;
|
||||
|
||||
import com.intellij.icons.AllIcons;
|
||||
@@ -47,7 +33,7 @@ import java.util.List;
|
||||
/**
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public class FavoritesPanel {
|
||||
public final class FavoritesPanel {
|
||||
private final Project myProject;
|
||||
private final FavoritesTreeViewPanel myViewPanel;
|
||||
private final DnDAwareTree myTree;
|
||||
|
||||
-169
@@ -1,169 +0,0 @@
|
||||
// Copyright 2000-2019 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.favoritesTreeView;
|
||||
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.ide.SelectInTarget;
|
||||
import com.intellij.ide.projectView.ProjectView;
|
||||
import com.intellij.ide.projectView.impl.AbstractProjectViewPane;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.ActionCallback;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.util.PsiUtilBase;
|
||||
import com.intellij.util.ArrayUtilRt;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* @author cdr
|
||||
*/
|
||||
public class FavoritesProjectViewPane extends AbstractProjectViewPane {
|
||||
@NonNls public static final String ID = "Favorites";
|
||||
private FavoritesTreeViewPanel myViewPanel;
|
||||
private final FavoritesManager myFavoritesManager;
|
||||
private static final Logger LOG = Logger.getInstance(FavoritesProjectViewPane.class);
|
||||
|
||||
protected FavoritesProjectViewPane(@NotNull Project project, @NotNull FavoritesManager favoritesManager) {
|
||||
super(project);
|
||||
|
||||
myFavoritesManager = favoritesManager;
|
||||
FavoritesListener favoritesListener = new FavoritesListener() {
|
||||
private boolean enabled = true;
|
||||
|
||||
@Override
|
||||
public void rootsChanged() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void listAdded(@NotNull String listName) {
|
||||
refreshMySubIdsAndSelect(listName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void listRemoved(@NotNull String listName) {
|
||||
String selectedSubId = getSubId();
|
||||
refreshMySubIdsAndSelect(selectedSubId);
|
||||
}
|
||||
|
||||
private void refreshMySubIdsAndSelect(String listName) {
|
||||
if (!enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
enabled = false;
|
||||
ProjectView projectView = ProjectView.getInstance(myProject);
|
||||
projectView.removeProjectPane(FavoritesProjectViewPane.this);
|
||||
projectView.addProjectPane(FavoritesProjectViewPane.this);
|
||||
if (!myFavoritesManager.getAvailableFavoritesListNames().contains(listName)) {
|
||||
listName = null;
|
||||
}
|
||||
projectView.changeView(ID, listName);
|
||||
}
|
||||
finally {
|
||||
enabled = true;
|
||||
}
|
||||
}
|
||||
};
|
||||
myFavoritesManager.addFavoritesListener(favoritesListener, this);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return "Favorites";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Icon getIcon() {
|
||||
return AllIcons.Toolwindows.ToolWindowFavorites;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getId() {
|
||||
return ID;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JComponent createComponent() {
|
||||
//if (myViewPanel != null) return myViewPanel;
|
||||
|
||||
final String subId = getSubId();
|
||||
LOG.assertTrue(subId != null, getSubIds());
|
||||
myViewPanel = new FavoritesTreeViewPanel(myProject);
|
||||
myTree = myViewPanel.getTree();
|
||||
setTreeBuilder(myViewPanel.getBuilder());
|
||||
myTreeStructure = myViewPanel.getFavoritesTreeStructure();
|
||||
installComparator();
|
||||
enableDnD();
|
||||
return myViewPanel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
myViewPanel = null;
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String[] getSubIds() {
|
||||
return ArrayUtilRt.toStringArray(myFavoritesManager.getAvailableFavoritesListNames());
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getPresentableSubIdName(@NotNull final String subId) {
|
||||
return subId;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ActionCallback updateFromRoot(boolean restoreExpandedPaths) {
|
||||
return ((FavoritesViewTreeBuilder)getTreeBuilder()).updateFromRootCB();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void select(Object object, VirtualFile file, boolean requestFocus) {
|
||||
if (!(object instanceof PsiElement)) return;
|
||||
/*PsiElement element = (PsiElement)object;
|
||||
PsiFile psiFile = element.getContainingFile();
|
||||
if (psiFile != null) {
|
||||
element = psiFile;
|
||||
}
|
||||
|
||||
if (element instanceof PsiJavaFile) {
|
||||
final PsiClass[] classes = ((PsiJavaFile)element).getClasses();
|
||||
if (classes.length > 0) {
|
||||
element = classes[0];
|
||||
}
|
||||
}
|
||||
|
||||
final PsiElement originalElement = element.getOriginalElement();*/
|
||||
final VirtualFile virtualFile = PsiUtilBase.getVirtualFile((PsiElement)object);
|
||||
final String list = FavoritesViewSelectInTarget.findSuitableFavoritesList(virtualFile, myProject, getSubId());
|
||||
if (list == null) return;
|
||||
if (!list.equals(getSubId())) {
|
||||
ProjectView.getInstance(myProject).changeView(ID, list);
|
||||
}
|
||||
myViewPanel.selectElement(object, virtualFile, requestFocus);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWeight() {
|
||||
return 4;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public SelectInTarget createSelectInTarget() {
|
||||
return new FavoritesViewSelectInTarget(myProject);
|
||||
}
|
||||
}
|
||||
+5
-22
@@ -2,8 +2,6 @@
|
||||
|
||||
package com.intellij.ide.favoritesTreeView;
|
||||
|
||||
import com.intellij.ide.IdeBundle;
|
||||
import com.intellij.ide.projectView.PresentationData;
|
||||
import com.intellij.ide.projectView.SettingsProvider;
|
||||
import com.intellij.ide.projectView.TreeStructureProvider;
|
||||
import com.intellij.ide.projectView.ViewSettings;
|
||||
@@ -24,18 +22,18 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static com.intellij.ide.favoritesTreeView.FavoritesViewTreeBuilder.ID;
|
||||
|
||||
/**
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public class FavoritesTreeStructure extends ProjectTreeStructure {
|
||||
|
||||
public final class FavoritesTreeStructure extends ProjectTreeStructure {
|
||||
private static final Logger LOGGER = Logger.getInstance(FavoritesTreeStructure.class);
|
||||
private TreeStructureProvider myNonProjectProvider = null;
|
||||
private final TreeStructureProvider myNonProjectProvider;
|
||||
public FavoritesTreeStructure(@NotNull Project project) {
|
||||
super(project, FavoritesProjectViewPane.ID);
|
||||
super(project, ID);
|
||||
myNonProjectProvider = new MyProvider(project);
|
||||
}
|
||||
|
||||
@@ -105,21 +103,6 @@ public class FavoritesTreeStructure extends ProjectTreeStructure {
|
||||
return ArrayUtilRt.EMPTY_OBJECT_ARRAY;
|
||||
}
|
||||
|
||||
private AbstractTreeNode<String> getEmptyScreen() {
|
||||
return new AbstractTreeNode<String>(myProject, IdeBundle.message("favorites.empty.screen")) {
|
||||
@Override
|
||||
@NotNull
|
||||
public Collection<AbstractTreeNode> getChildren() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(@NotNull final PresentationData presentation) {
|
||||
presentation.setPresentableText(getValue());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getParentElement(@NotNull Object element) {
|
||||
AbstractTreeNode parent = null;
|
||||
|
||||
+31
-127
@@ -4,12 +4,10 @@ package com.intellij.ide.favoritesTreeView;
|
||||
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.ide.CopyPasteDelegator;
|
||||
import com.intellij.ide.ExporterToTextFile;
|
||||
import com.intellij.ide.IdeView;
|
||||
import com.intellij.ide.bookmarks.Bookmark;
|
||||
import com.intellij.ide.dnd.aware.DnDAwareTree;
|
||||
import com.intellij.ide.favoritesTreeView.actions.*;
|
||||
import com.intellij.ide.projectView.PresentationData;
|
||||
import com.intellij.ide.projectView.ProjectView;
|
||||
import com.intellij.ide.projectView.impl.ModuleGroup;
|
||||
import com.intellij.ide.projectView.impl.ProjectViewTree;
|
||||
@@ -57,8 +55,6 @@ import javax.swing.tree.DefaultMutableTreeNode;
|
||||
import javax.swing.tree.DefaultTreeModel;
|
||||
import javax.swing.tree.TreePath;
|
||||
import java.awt.*;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
@@ -66,29 +62,27 @@ import java.util.*;
|
||||
* @author anna
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public class FavoritesTreeViewPanel extends JPanel implements DataProvider, DockContainer {
|
||||
public final class FavoritesTreeViewPanel extends JPanel implements DataProvider, DockContainer {
|
||||
private final FavoritesTreeStructure myFavoritesTreeStructure;
|
||||
private FavoritesViewTreeBuilder myBuilder;
|
||||
private final CopyPasteDelegator myCopyPasteDelegator;
|
||||
private final MouseListener myTreePopupHandler;
|
||||
|
||||
public static final DataKey<FavoritesTreeNodeDescriptor[]> CONTEXT_FAVORITES_ROOTS_DATA_KEY = DataKey.create("FavoritesRoot");
|
||||
public static final DataKey<DnDAwareTree> FAVORITES_TREE_KEY = DataKey.create("Favorites.Tree");
|
||||
public static final DataKey<FavoritesViewTreeBuilder> FAVORITES_TREE_BUILDER_KEY = DataKey.create("Favorites.Tree.Builder");
|
||||
|
||||
public static final DataKey<String> FAVORITES_LIST_NAME_DATA_KEY = DataKey.create("FavoritesListName");
|
||||
protected Project myProject;
|
||||
protected DnDAwareTree myTree;
|
||||
private final Project myProject;
|
||||
final DnDAwareTree myTree;
|
||||
|
||||
private final AutoScrollToSourceHandler myAutoScrollToSourceHandler;
|
||||
|
||||
private final IdeView myIdeView = new MyIdeView();
|
||||
private final FavoritesManager myFavoritesManager;
|
||||
|
||||
public FavoritesTreeViewPanel(Project project) {
|
||||
public FavoritesTreeViewPanel(@NotNull Project project) {
|
||||
super(new BorderLayout());
|
||||
|
||||
myProject = project;
|
||||
myFavoritesManager = FavoritesManager.getInstance(myProject);
|
||||
|
||||
myFavoritesTreeStructure = new FavoritesTreeStructure(project);
|
||||
DefaultMutableTreeNode root = new DefaultMutableTreeNode();
|
||||
@@ -114,14 +108,14 @@ public class FavoritesTreeViewPanel extends JPanel implements DataProvider, Dock
|
||||
myTree.setLargeModel(true);
|
||||
new TreeSpeedSearch(myTree);
|
||||
ToolTipManager.sharedInstance().registerComponent(myTree);
|
||||
final FavoritesComparator favoritesComparator =
|
||||
new FavoritesComparator(ProjectView.getInstance(project), FavoritesProjectViewPane.ID);
|
||||
FavoritesComparator favoritesComparator = new FavoritesComparator(ProjectView.getInstance(project), FavoritesViewTreeBuilder.ID);
|
||||
FavoritesManager favoriteManager = FavoritesManager.getInstance(myProject);
|
||||
myBuilder.setNodeDescriptorComparator((o1, o2) -> {
|
||||
if (o1 instanceof FavoritesTreeNodeDescriptor && o2 instanceof FavoritesTreeNodeDescriptor) {
|
||||
final FavoritesListNode listNode1 = FavoritesTreeUtil.extractParentList((FavoritesTreeNodeDescriptor)o1);
|
||||
final FavoritesListNode listNode2 = FavoritesTreeUtil.extractParentList((FavoritesTreeNodeDescriptor)o2);
|
||||
if (listNode1.equals(listNode2)) {
|
||||
final Comparator<FavoritesTreeNodeDescriptor> comparator = myFavoritesManager.getCustomComparator(listNode1.getName());
|
||||
final Comparator<FavoritesTreeNodeDescriptor> comparator = favoriteManager.getCustomComparator(listNode1.getName());
|
||||
if (comparator != null) {
|
||||
return comparator.compare((FavoritesTreeNodeDescriptor)o1, (FavoritesTreeNodeDescriptor)o2);
|
||||
}
|
||||
@@ -149,7 +143,7 @@ public class FavoritesTreeViewPanel extends JPanel implements DataProvider, Dock
|
||||
if (userObject instanceof FavoritesTreeNodeDescriptor) {
|
||||
final FavoritesTreeNodeDescriptor favoritesTreeNodeDescriptor = (FavoritesTreeNodeDescriptor)userObject;
|
||||
AbstractTreeNode treeNode = favoritesTreeNodeDescriptor.getElement();
|
||||
FavoritesListProvider provider = FavoritesTreeUtil.getProvider(myFavoritesManager, favoritesTreeNodeDescriptor);
|
||||
FavoritesListProvider provider = FavoritesTreeUtil.getProvider(favoriteManager, favoritesTreeNodeDescriptor);
|
||||
if (provider != null) {
|
||||
Object o = myBuilder.getUi().getElementFor(value);
|
||||
if (o instanceof AbstractTreeNode) {
|
||||
@@ -173,8 +167,7 @@ public class FavoritesTreeViewPanel extends JPanel implements DataProvider, Dock
|
||||
}
|
||||
}
|
||||
});
|
||||
myTreePopupHandler =
|
||||
CustomizationUtil.installPopupHandler(myTree, IdeActions.GROUP_FAVORITES_VIEW_POPUP, ActionPlaces.FAVORITES_VIEW_POPUP);
|
||||
CustomizationUtil.installPopupHandler(myTree, IdeActions.GROUP_FAVORITES_VIEW_POPUP, ActionPlaces.FAVORITES_VIEW_POPUP);
|
||||
|
||||
EditSourceOnDoubleClickHandler.install(myTree);
|
||||
EditSourceOnEnterKeyHandler.install(myTree);
|
||||
@@ -212,16 +205,16 @@ public class FavoritesTreeViewPanel extends JPanel implements DataProvider, Dock
|
||||
myAutoScrollToSourceHandler = new AutoScrollToSourceHandler() {
|
||||
@Override
|
||||
protected boolean isAutoScrollMode() {
|
||||
return myFavoritesManager.getViewSettings().isAutoScrollToSource();
|
||||
return favoriteManager.getViewSettings().isAutoScrollToSource();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setAutoScrollMode(boolean state) {
|
||||
myFavoritesManager.getViewSettings().setAutoScrollToSource(state);
|
||||
favoriteManager.getViewSettings().setAutoScrollToSource(state);
|
||||
}
|
||||
};
|
||||
myAutoScrollToSourceHandler.install(myTree);
|
||||
myFavoritesManager.addFavoritesListener(new FavoritesListener() {
|
||||
favoriteManager.addFavoritesListener(new FavoritesListener() {
|
||||
@Override
|
||||
public void rootsChanged() {
|
||||
myBuilder.updateFromRoot();
|
||||
@@ -242,80 +235,6 @@ public class FavoritesTreeViewPanel extends JPanel implements DataProvider, Dock
|
||||
}, this);
|
||||
}
|
||||
|
||||
|
||||
private ExporterToTextFile createTextExporter() {
|
||||
return new ExporterToTextFile() {
|
||||
@NotNull
|
||||
@Override
|
||||
public String getReportText() {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
|
||||
final Object[] elements = myBuilder.getStructure().getChildElements(myBuilder.getRoot());
|
||||
|
||||
final TreeUtil.Traverse traverse = new TreeUtil.Traverse() {
|
||||
@Override
|
||||
public boolean accept(Object node) {
|
||||
if (node instanceof LoadingNode) return true;
|
||||
final AbstractTreeNode abstractTreeNode = (AbstractTreeNode)node;
|
||||
if (sb.length() > 0) {
|
||||
sb.append('\n');
|
||||
}
|
||||
int deepLevel = getDeepLevel((AbstractTreeNode)node);
|
||||
for (int i = 1; i < deepLevel; i++) {
|
||||
sb.append('\t');
|
||||
}
|
||||
abstractTreeNode.update();
|
||||
final PresentationData presentation = abstractTreeNode.getPresentation();
|
||||
sb.append(presentation.getPresentableText());
|
||||
String locationString = presentation.getLocationString();
|
||||
if (locationString == null) {
|
||||
locationString = FavoritesTreeNodeDescriptor.getLocation(abstractTreeNode, myProject);
|
||||
}
|
||||
if (locationString != null) {
|
||||
sb.append(" (").append(locationString).append(")");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public int getDeepLevel(AbstractTreeNode node) {
|
||||
int result = 0;
|
||||
while (node.getParent() != null) {
|
||||
result++;
|
||||
node = node.getParent();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
for (Object element : elements) {
|
||||
traverseDepth((AbstractTreeNode)element, traverse);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getDefaultFilePath() {
|
||||
return myProject.getBasePath() + File.separator + "Favorites.txt";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExport() {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private static boolean traverseDepth(final AbstractTreeNode node, final TreeUtil.Traverse traverse) {
|
||||
if (!traverse.accept(node)) return false;
|
||||
final Collection<? extends AbstractTreeNode> children = node.getChildren();
|
||||
for (AbstractTreeNode child : children) {
|
||||
child.setParent(node);
|
||||
if (!traverseDepth(child, traverse)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void selectElement(final Object selector, final VirtualFile file, final boolean requestFocus) {
|
||||
myBuilder.selectAsync(selector, file, requestFocus);
|
||||
}
|
||||
@@ -374,12 +293,12 @@ public class FavoritesTreeViewPanel extends JPanel implements DataProvider, Dock
|
||||
final FavoritesTreeNodeDescriptor[] selectedNodeDescriptors = FavoritesTreeUtil.getSelectedNodeDescriptors(myTree);
|
||||
return selectedNodeDescriptors.length == 1 ? selectedNodeDescriptors[0].getElement() : null;
|
||||
}
|
||||
FavoritesManager favoriteManager = FavoritesManager.getInstance(myProject);
|
||||
if (CommonDataKeys.NAVIGATABLE_ARRAY.is(dataId)) {
|
||||
List<String> listNames = getSelectedElements(String.class);
|
||||
final List<Navigatable> selectedElements = new SmartList<>();
|
||||
for (String listname : listNames) {
|
||||
selectedElements.addAll(
|
||||
ContainerUtil.map(myFavoritesManager.getVirtualFiles(listname, false), file -> new OpenFileDescriptor(myProject, file)));
|
||||
selectedElements.addAll(ContainerUtil.map(favoriteManager.getVirtualFiles(listname, false), file -> new OpenFileDescriptor(myProject, file)));
|
||||
}
|
||||
selectedElements.addAll(getSelectedElements(Navigatable.class));
|
||||
return selectedElements.isEmpty() ? null : selectedElements.toArray(new Navigatable[0]);
|
||||
@@ -449,7 +368,7 @@ public class FavoritesTreeViewPanel extends JPanel implements DataProvider, Dock
|
||||
List<FavoritesTreeNodeDescriptor> result = new ArrayList<>();
|
||||
FavoritesTreeNodeDescriptor[] selectedNodeDescriptors = FavoritesTreeUtil.getSelectedNodeDescriptors(myTree);
|
||||
for (FavoritesTreeNodeDescriptor selectedNodeDescriptor : selectedNodeDescriptors) {
|
||||
if (FavoritesTreeUtil.getProvider(myFavoritesManager, selectedNodeDescriptor) != null) {
|
||||
if (FavoritesTreeUtil.getProvider(favoriteManager, selectedNodeDescriptor) != null) {
|
||||
continue;
|
||||
}
|
||||
FavoritesTreeNodeDescriptor root = selectedNodeDescriptor.getFavoritesRoot();
|
||||
@@ -491,24 +410,9 @@ public class FavoritesTreeViewPanel extends JPanel implements DataProvider, Dock
|
||||
return null;
|
||||
}
|
||||
|
||||
private Set<FavoritesListNode> getSelectedListsNodes() {
|
||||
final Set<FavoritesListNode> result = new HashSet<>();
|
||||
final FavoritesTreeNodeDescriptor[] descriptors = FavoritesTreeUtil.getSelectedNodeDescriptors(myTree);
|
||||
for (FavoritesTreeNodeDescriptor descriptor : descriptors) {
|
||||
final FavoritesListNode listNode = FavoritesTreeUtil.extractParentList(descriptor);
|
||||
if (listNode != null) {
|
||||
result.add(listNode);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private <T> List<T> getSelectedElements(Class<T> klass) {
|
||||
final Object[] elements = getSelectedNodeElements();
|
||||
ArrayList<T> result = new ArrayList<>();
|
||||
if (elements == null) {
|
||||
return result;
|
||||
}
|
||||
for (Object element : elements) {
|
||||
if (element == null) continue;
|
||||
if (klass.isAssignableFrom(element.getClass())) {
|
||||
@@ -520,9 +424,6 @@ public class FavoritesTreeViewPanel extends JPanel implements DataProvider, Dock
|
||||
|
||||
private Module[] getSelectedModules() {
|
||||
final Object[] elements = getSelectedNodeElements();
|
||||
if (elements == null) {
|
||||
return null;
|
||||
}
|
||||
ArrayList<Module> result = new ArrayList<>();
|
||||
for (Object element : elements) {
|
||||
if (element instanceof Module) {
|
||||
@@ -536,9 +437,10 @@ public class FavoritesTreeViewPanel extends JPanel implements DataProvider, Dock
|
||||
return result.isEmpty() ? null : result.toArray(Module.EMPTY_ARRAY);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Object[] getSelectedNodeElements() {
|
||||
final FavoritesTreeNodeDescriptor[] selectedNodeDescriptors = FavoritesTreeUtil.getSelectedNodeDescriptors(myTree);
|
||||
ArrayList<Object> result = new ArrayList<>();
|
||||
FavoritesTreeNodeDescriptor[] selectedNodeDescriptors = FavoritesTreeUtil.getSelectedNodeDescriptors(myTree);
|
||||
List<Object> result = new ArrayList<>();
|
||||
for (FavoritesTreeNodeDescriptor selectedNodeDescriptor : selectedNodeDescriptors) {
|
||||
if (selectedNodeDescriptor != null) {
|
||||
Object value = selectedNodeDescriptor.getElement().getValue();
|
||||
@@ -553,7 +455,7 @@ public class FavoritesTreeViewPanel extends JPanel implements DataProvider, Dock
|
||||
|
||||
public void setupToolWindow(ToolWindowEx window) {
|
||||
final CollapseAllAction collapseAction = new CollapseAllAction(myTree);
|
||||
collapseAction.getTemplatePresentation().setIcon(AllIcons.General.CollapseAll);
|
||||
collapseAction.getTemplatePresentation().setIcon(AllIcons.Actions.Collapseall);
|
||||
window.setTitleActions(collapseAction);
|
||||
|
||||
final DefaultActionGroup group = new DefaultActionGroup();
|
||||
@@ -728,15 +630,17 @@ public class FavoritesTreeViewPanel extends JPanel implements DataProvider, Dock
|
||||
|
||||
@Override
|
||||
public void add(@NotNull DockableContent content, RelativePoint dropTarget) {
|
||||
if (content.getKey() instanceof VirtualFile) {
|
||||
VirtualFile vFile = (VirtualFile)content.getKey();
|
||||
PsiFileSystemItem psiFile = PsiUtilCore.findFileSystemItem(myProject, vFile);
|
||||
Point p = dropTarget.getScreenPoint();
|
||||
SwingUtilities.convertPointFromScreen(p, myTree);
|
||||
FavoritesListNode node = findFavoritesListNode(p);
|
||||
if (node != null && psiFile != null) {
|
||||
dropPsiElements(myFavoritesManager, node, new PsiElement[]{psiFile});
|
||||
}
|
||||
if (!(content.getKey() instanceof VirtualFile)) {
|
||||
return;
|
||||
}
|
||||
|
||||
VirtualFile vFile = (VirtualFile)content.getKey();
|
||||
PsiFileSystemItem psiFile = PsiUtilCore.findFileSystemItem(myProject, vFile);
|
||||
Point p = dropTarget.getScreenPoint();
|
||||
SwingUtilities.convertPointFromScreen(p, myTree);
|
||||
FavoritesListNode node = findFavoritesListNode(p);
|
||||
if (node != null && psiFile != null) {
|
||||
dropPsiElements(FavoritesManager.getInstance(myProject), node, new PsiElement[]{psiFile});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -23,8 +23,8 @@ import org.jetbrains.annotations.NotNull;
|
||||
* @author anna
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public class FavoritesViewSelectInTarget extends SelectInTargetPsiWrapper {
|
||||
public FavoritesViewSelectInTarget(final Project project) {
|
||||
final class FavoritesViewSelectInTarget extends SelectInTargetPsiWrapper {
|
||||
FavoritesViewSelectInTarget(final Project project) {
|
||||
super(project);
|
||||
|
||||
if (PlatformUtils.isPyCharmEducational()) {
|
||||
@@ -93,7 +93,7 @@ public class FavoritesViewSelectInTarget extends SelectInTargetPsiWrapper {
|
||||
|
||||
@Override
|
||||
public String getMinorViewId() {
|
||||
return FavoritesProjectViewPane.ID;
|
||||
return FavoritesViewTreeBuilder.ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+4
-3
@@ -1,4 +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-2019 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.favoritesTreeView;
|
||||
|
||||
import com.intellij.ProjectTopics;
|
||||
@@ -36,7 +36,8 @@ import javax.swing.tree.DefaultTreeModel;
|
||||
/**
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public class FavoritesViewTreeBuilder extends BaseProjectTreeBuilder {
|
||||
public final class FavoritesViewTreeBuilder extends BaseProjectTreeBuilder {
|
||||
public static final String ID = "Favorites";
|
||||
|
||||
public FavoritesViewTreeBuilder(@NotNull Project project,
|
||||
JTree tree,
|
||||
@@ -46,7 +47,7 @@ public class FavoritesViewTreeBuilder extends BaseProjectTreeBuilder {
|
||||
tree,
|
||||
treeModel,
|
||||
treeStructure,
|
||||
new FavoritesComparator(ProjectView.getInstance(project), FavoritesProjectViewPane.ID));
|
||||
new FavoritesComparator(ProjectView.getInstance(project), ID));
|
||||
final MessageBusConnection bus = myProject.getMessageBus().connect(this);
|
||||
ProjectViewPsiTreeChangeListener psiTreeChangeListener = new ProjectViewPsiTreeChangeListener(myProject) {
|
||||
@Override
|
||||
|
||||
@@ -924,7 +924,6 @@
|
||||
<applicationService serviceInterface="com.intellij.codeInsight.template.TemplateBuilderFactory"
|
||||
serviceImplementation="com.intellij.codeInsight.template.TemplateBuilderFactoryImpl"/>
|
||||
|
||||
<!--<projectViewPane implementation="com.intellij.ide.favoritesTreeView.FavoritesProjectViewPane"/>-->
|
||||
<projectViewPane implementation="com.intellij.ide.scopeView.ScopeViewPane"/>
|
||||
|
||||
<renameHandler implementation="com.intellij.refactoring.rename.PlainDirectoryRenameHandler"/>
|
||||
|
||||
Reference in New Issue
Block a user