mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
add icons
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 637 B |
Binary file not shown.
|
After Width: | Height: | Size: 734 B |
@@ -7,14 +7,22 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.InputValidator;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.openapi.wm.ToolWindowId;
|
||||
import com.intellij.openapi.wm.ToolWindowManager;
|
||||
import com.intellij.ui.LayeredIcon;
|
||||
|
||||
/**
|
||||
* User: anna
|
||||
* Date: Feb 24, 2005
|
||||
*/
|
||||
public class AddNewFavoritesListAction extends AnAction{
|
||||
public static LayeredIcon ourIcon = new LayeredIcon(2);
|
||||
static {
|
||||
ourIcon.setIcon(IconLoader.getIcon("/general/favorites.png"), 1);
|
||||
ourIcon.setIcon(IconLoader.getIcon("/general/add.png"), 0, 2, 2);
|
||||
}
|
||||
public AddNewFavoritesListAction() {
|
||||
super("Add New Favorites List", "Add New Favorites List", IconLoader.getIcon("/general/toolWindowMessages.png"));
|
||||
super("Add New Favorites List", "Add New Favorites List", ourIcon);
|
||||
}
|
||||
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
@@ -33,6 +41,12 @@ public class AddNewFavoritesListAction extends AnAction{
|
||||
return inputString != null && inputString.trim().length() > 0;
|
||||
}
|
||||
});
|
||||
FavoritesViewImpl.getInstance(project).addNewFavoritesList(s);
|
||||
final FavoritesViewImpl favoritesView = FavoritesViewImpl.getInstance(project);
|
||||
final FavoritesTreeViewPanel favoritesTreeViewPanel = favoritesView.addNewFavoritesList(s);
|
||||
final ToolWindowManager windowManager = ToolWindowManager.getInstance(project);
|
||||
windowManager.getToolWindow(ToolWindowId.FAVORITES_VIEW).activate(null);
|
||||
favoritesView.setSelectedContent(favoritesView.getContent(favoritesTreeViewPanel));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -7,8 +7,6 @@ import com.intellij.ide.projectView.impl.ModuleGroup;
|
||||
import com.intellij.ide.projectView.impl.PackageViewPane;
|
||||
import com.intellij.ide.projectView.impl.nodes.*;
|
||||
import com.intellij.ide.util.treeView.AbstractTreeNode;
|
||||
import com.intellij.j2ee.module.view.J2EEProjectViewPane;
|
||||
import com.intellij.j2ee.module.view.nodes.J2EENodeDescriptor;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.DataConstants;
|
||||
@@ -49,6 +47,10 @@ public class AddToFavoritesAction extends AnAction {
|
||||
final DataContext dataContext = e.getDataContext();
|
||||
Project project = (Project)dataContext.getData(DataConstants.PROJECT);
|
||||
final AbstractTreeNode[] nodes = createNodes(dataContext);
|
||||
addNodes(project, nodes);
|
||||
}
|
||||
|
||||
public void addNodes(final Project project, final AbstractTreeNode[] nodes) {
|
||||
final FavoritesViewImpl favoritesView = FavoritesViewImpl.getInstance(project);
|
||||
if (nodes != null) {
|
||||
final FavoritesTreeViewPanel favoritesTreeViewPanel = favoritesView.getFavoritesTreeViewPanel(myFavoritesList);
|
||||
@@ -81,10 +83,7 @@ public class AddToFavoritesAction extends AnAction {
|
||||
|
||||
final String currentViewId = ProjectView.getInstance(project).getCurrentViewId();
|
||||
AbstractProjectViewPane pane = ProjectView.getInstance(project).getProjectViewPaneById(currentViewId);
|
||||
if (currentViewId.equals(J2EEProjectViewPane.ID)){
|
||||
J2EENodeDescriptor j2eeNodeDescriptor = (J2EENodeDescriptor)pane.getSelectedDescriptor();
|
||||
}
|
||||
|
||||
|
||||
//on psi element
|
||||
PsiElement psiElement = (PsiElement)dataContext.getData(DataConstants.PSI_ELEMENT);
|
||||
if (psiElement != null){
|
||||
|
||||
@@ -11,7 +11,7 @@ import com.intellij.openapi.util.IconLoader;
|
||||
*/
|
||||
public class DeleteFromFavoritesAction extends AnAction {
|
||||
public DeleteFromFavoritesAction() {
|
||||
super("Remove From Favorites", "Remove Selected Favorite", IconLoader.getIcon("/actions/cancel.png"));
|
||||
super("Remove From Current Favorites", "Remove Selected Favorite", IconLoader.getIcon("/general/remove.png"));
|
||||
}
|
||||
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
@@ -32,24 +32,14 @@ public class DeleteFromFavoritesAction extends AnAction {
|
||||
final FavoritesTreeViewPanel favoritesTreeViewPanel = FavoritesViewImpl.getInstance(project).getFavoritesTreeViewPanel(favoritesViewPane);
|
||||
for (int i = 0; selectedNodeDescriptors != null && i < selectedNodeDescriptors.length; i++) {
|
||||
FavoritesTreeNodeDescriptor selectedNodeDescriptor = selectedNodeDescriptors[i];
|
||||
selectedNodeDescriptor = getFavoritesRoot(selectedNodeDescriptor, project, favoritesViewPane);
|
||||
selectedNodeDescriptor = FavoritesTreeNodeDescriptor.getFavoritesRoot(selectedNodeDescriptor, project, favoritesViewPane);
|
||||
if (selectedNodeDescriptor != null) {
|
||||
favoritesTreeViewPanel.removeFromFavorites((AbstractTreeNode)selectedNodeDescriptor.getElement());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private FavoritesTreeNodeDescriptor getFavoritesRoot(FavoritesTreeNodeDescriptor node, Project project, String favoritesViewPane) {
|
||||
final FavoritesTreeViewPanel favoritesTreeViewPanel = FavoritesViewImpl.getInstance(project).getFavoritesTreeViewPanel(favoritesViewPane);
|
||||
while (node.getParentDescriptor() != null && node.getParentDescriptor() instanceof FavoritesTreeNodeDescriptor) {
|
||||
FavoritesTreeNodeDescriptor favoritesDescriptor = (FavoritesTreeNodeDescriptor)node.getParentDescriptor();
|
||||
if (favoritesDescriptor.getElement() == favoritesTreeViewPanel.getFavoritesTreeStructure().getRootElement()) {
|
||||
return node;
|
||||
}
|
||||
node = favoritesDescriptor;
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
|
||||
public void update(AnActionEvent e) {
|
||||
final DataContext dataContext = e.getDataContext();
|
||||
|
||||
@@ -9,13 +9,13 @@ import com.intellij.ide.util.treeView.NodeDescriptor;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.impl.ModuleUtil;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Iconable;
|
||||
import com.intellij.openapi.vcs.FileStatusManager;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiDirectory;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.presentation.java.ClassPresentationUtil;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* User: anna
|
||||
* Date: Feb 15, 2005
|
||||
@@ -35,12 +35,27 @@ public class FavoritesTreeNodeDescriptor extends NodeDescriptor<AbstractTreeNode
|
||||
myElement.update();
|
||||
myName = myElement.getPresentation().getPresentableText();
|
||||
final Object value = myElement.getValue();
|
||||
if (value instanceof PsiElement && ((PsiElement)value).getContainingFile() != null){
|
||||
myColor = FileStatusManager.getInstance(myProject).getStatus(((PsiElement)value).getContainingFile().getVirtualFile()).getColor();
|
||||
if (value instanceof PsiElement){
|
||||
if (((PsiElement)value).getContainingFile() != null){
|
||||
myColor = FileStatusManager.getInstance(myProject).getStatus(((PsiElement)value).getContainingFile().getVirtualFile()).getColor();
|
||||
int flags = ((PsiElement)value).getContainingFile() instanceof PsiJavaFile ? Iconable.ICON_FLAG_VISIBILITY : 0;
|
||||
if (isMarkReadOnly()) {
|
||||
flags |= Iconable.ICON_FLAG_READ_STATUS;
|
||||
}
|
||||
Icon icon = ((PsiElement)value).getIcon(flags);
|
||||
myOpenIcon = icon;
|
||||
myClosedIcon = icon;
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected boolean isMarkReadOnly() {
|
||||
final Object parentValue = myElement.getParent() == null ? null : myElement.getParent().getValue();
|
||||
return parentValue instanceof PsiDirectory || parentValue instanceof PackageElement;
|
||||
}
|
||||
|
||||
public String getLocation(){
|
||||
final Object nodeElement = myElement.getValue();
|
||||
if (nodeElement instanceof PsiElement){
|
||||
@@ -89,4 +104,16 @@ public class FavoritesTreeNodeDescriptor extends NodeDescriptor<AbstractTreeNode
|
||||
public int hashCode() {
|
||||
return myElement.hashCode();
|
||||
}
|
||||
|
||||
public static FavoritesTreeNodeDescriptor getFavoritesRoot(FavoritesTreeNodeDescriptor node, Project project, String favoritesViewPane) {
|
||||
final FavoritesTreeViewPanel favoritesTreeViewPanel = FavoritesViewImpl.getInstance(project).getFavoritesTreeViewPanel(favoritesViewPane);
|
||||
while (node.getParentDescriptor() != null && node.getParentDescriptor() instanceof FavoritesTreeNodeDescriptor) {
|
||||
FavoritesTreeNodeDescriptor favoritesDescriptor = (FavoritesTreeNodeDescriptor)node.getParentDescriptor();
|
||||
if (favoritesDescriptor.getElement() == favoritesTreeViewPanel.getFavoritesTreeStructure().getRootElement()) {
|
||||
return node;
|
||||
}
|
||||
node = favoritesDescriptor;
|
||||
}
|
||||
return node;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ public class FavoritesViewImpl extends ContentManagerImpl implements ProjectComp
|
||||
public void run() {
|
||||
ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(myProject);
|
||||
ToolWindow toolWindow = toolWindowManager.registerToolWindow(ToolWindowId.FAVORITES_VIEW, getComponent(), ToolWindowAnchor.RIGHT);
|
||||
toolWindow.setIcon(IconLoader.getIcon("/general/toolWindowMessages.png"));
|
||||
toolWindow.setIcon(IconLoader.getIcon("/general/favorites.png"));
|
||||
new ContentManagerWatcher(toolWindow, FavoritesViewImpl.this);
|
||||
final ContentFactory contentFactory = PeerFactory.getInstance().getContentFactory();
|
||||
if (myName2FavoritesListSet.isEmpty()){
|
||||
@@ -112,7 +112,7 @@ public class FavoritesViewImpl extends ContentManagerImpl implements ProjectComp
|
||||
return keys.toArray(new String[keys.size()]);
|
||||
}
|
||||
|
||||
public void addNewFavoritesList(String name){
|
||||
public FavoritesTreeViewPanel addNewFavoritesList(String name){
|
||||
final ContentFactory contentFactory = PeerFactory.getInstance().getContentFactory();
|
||||
final FavoritesTreeViewPanel panel = new FavoritesTreeViewPanel(myProject, null, name);
|
||||
final Content favoritesContent = contentFactory.createContent(panel, name, false);
|
||||
@@ -121,6 +121,7 @@ public class FavoritesViewImpl extends ContentManagerImpl implements ProjectComp
|
||||
final AddToFavoritesAction addAction = new AddToFavoritesAction(name);
|
||||
myActions.put(name, addAction);
|
||||
((DefaultActionGroup)ActionManager.getInstance().getAction(IdeActions.ADD_TO_FAVORITES)).add(addAction);
|
||||
return panel;
|
||||
}
|
||||
|
||||
public void removeCurrentFavoritesList(){
|
||||
@@ -144,7 +145,7 @@ public class FavoritesViewImpl extends ContentManagerImpl implements ProjectComp
|
||||
}
|
||||
|
||||
public void projectClosed() {
|
||||
ToolWindowManager.getInstance(myProject).unregisterToolWindow(ToolWindowId.FAVORITES_VIEW);
|
||||
ToolWindowManager.getInstance(myProject).unregisterToolWindow(ToolWindowId.FAVORITES_VIEW);
|
||||
}
|
||||
|
||||
public String getComponentName() {
|
||||
|
||||
@@ -102,7 +102,7 @@ public class FavoritesViewSelectInTarget extends SelectInTargetPsiWrapper{
|
||||
}
|
||||
|
||||
protected boolean canWorkWithCustomObjects() {
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getToolWindowId() {
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
package com.intellij.ide.favoritesTreeView;
|
||||
|
||||
import com.intellij.ide.util.treeView.AbstractTreeNode;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.project.Project;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* User: anna
|
||||
* Date: Feb 24, 2005
|
||||
@@ -20,7 +23,12 @@ public class SendToFavoritesAction extends AnAction{
|
||||
final FavoritesViewImpl favoritesView = FavoritesViewImpl.getInstance(project);
|
||||
final FavoritesTreeViewPanel currentTreeViewPanel = favoritesView.getCurrentTreeViewPanel();
|
||||
final FavoritesTreeNodeDescriptor[] selectedNodeDescriptors = currentTreeViewPanel.getSelectedNodeDescriptors();
|
||||
favoritesView.getAddToFavoritesAction(myName).actionPerformed(e);
|
||||
ArrayList<AbstractTreeNode> nodesToAdd = new ArrayList<AbstractTreeNode>();
|
||||
for (int i = 0; i < selectedNodeDescriptors.length; i++) {
|
||||
final FavoritesTreeNodeDescriptor selectedNodeDescriptor = FavoritesTreeNodeDescriptor.getFavoritesRoot(selectedNodeDescriptors[i], project, currentTreeViewPanel.getName());
|
||||
nodesToAdd.add(selectedNodeDescriptor.getElement());
|
||||
}
|
||||
favoritesView.getAddToFavoritesAction(myName).addNodes(project, nodesToAdd.toArray(new AbstractTreeNode[nodesToAdd.size()]));
|
||||
((DeleteFromFavoritesAction)ActionManager.getInstance().getAction(IdeActions.REMOVE_FROM_FAVORITES)).removeNodes(selectedNodeDescriptors, project, currentTreeViewPanel.getName());
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ public class DependenciesAnalyzeManager implements ProjectComponent{
|
||||
myContentManager.getComponent(),
|
||||
ToolWindowAnchor.RIGHT);
|
||||
|
||||
toolWindow.setIcon(IconLoader.getIcon("/general/toolWindowInspection.png"));
|
||||
toolWindow.setIcon(IconLoader.getIcon("/general/toolWindowModuleDependencies.png"));
|
||||
new ContentManagerWatcher(toolWindow, myContentManager);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user