diff --git a/icons/src/general/addFavoritesList.png b/icons/src/general/addFavoritesList.png new file mode 100644 index 000000000000..d1f75830ec89 Binary files /dev/null and b/icons/src/general/addFavoritesList.png differ diff --git a/resources/src/idea/ActionManager.xml b/resources/src/idea/ActionManager.xml index 1d6a392d027d..0b8abae4ed83 100644 --- a/resources/src/idea/ActionManager.xml +++ b/resources/src/idea/ActionManager.xml @@ -16,7 +16,7 @@ - + diff --git a/source/com/intellij/ide/favoritesTreeView/AddNewFavoritesListAction.java b/source/com/intellij/ide/favoritesTreeView/AddNewFavoritesListAction.java index 7ebf0a566bae..e826cc3b50b7 100644 --- a/source/com/intellij/ide/favoritesTreeView/AddNewFavoritesListAction.java +++ b/source/com/intellij/ide/favoritesTreeView/AddNewFavoritesListAction.java @@ -6,24 +6,15 @@ import com.intellij.openapi.actionSystem.DataConstants; 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; +import com.intellij.util.ArrayUtil; /** * 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", ourIcon); - } public void actionPerformed(AnActionEvent e) { final Project project = (Project)e.getDataContext().getData(DataConstants.PROJECT); @@ -45,7 +36,8 @@ public class AddNewFavoritesListAction extends AnAction{ } public boolean canClose(String inputString) { - return inputString != null && inputString.trim().length() > 0; + final boolean alreadyContains = ArrayUtil.find(FavoritesViewImpl.getInstance(project).getAvailableFavoritesLists(), inputString.trim()) == -1; + return inputString != null && inputString.trim().length() > 0 && alreadyContains; } }); final FavoritesViewImpl favoritesView = FavoritesViewImpl.getInstance(project); diff --git a/source/com/intellij/ide/favoritesTreeView/AddToFavoritesActionGroup.java b/source/com/intellij/ide/favoritesTreeView/AddToFavoritesActionGroup.java new file mode 100644 index 000000000000..5c31c8e6154e --- /dev/null +++ b/source/com/intellij/ide/favoritesTreeView/AddToFavoritesActionGroup.java @@ -0,0 +1,27 @@ +package com.intellij.ide.favoritesTreeView; + +import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.actionSystem.DataConstants; +import com.intellij.openapi.actionSystem.DefaultActionGroup; +import com.intellij.openapi.project.Project; + +/** + * User: anna + * Date: Mar 3, 2005 + */ +public class AddToFavoritesActionGroup extends DefaultActionGroup{ + public void update(AnActionEvent e) { + removeAll(); + final Project project = (Project)e.getDataContext().getData(DataConstants.PROJECT); + if (project == null){ + return; + } + final String[] availableFavoritesLists = FavoritesViewImpl.getInstance(project).getAvailableFavoritesLists(); + for (int i = 0; i < availableFavoritesLists.length; i++) { + String favoritesList = availableFavoritesLists[i]; + add(new AddToFavoritesAction(favoritesList)); + } + addSeparator(); + add(new AddToNewFavoritesListAction()); + } +} diff --git a/source/com/intellij/ide/favoritesTreeView/AddToNewFavoritesListAction.java b/source/com/intellij/ide/favoritesTreeView/AddToNewFavoritesListAction.java index 86db046a0122..e993714cb31a 100644 --- a/source/com/intellij/ide/favoritesTreeView/AddToNewFavoritesListAction.java +++ b/source/com/intellij/ide/favoritesTreeView/AddToNewFavoritesListAction.java @@ -2,6 +2,7 @@ package com.intellij.ide.favoritesTreeView; import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.IconLoader; /** * User: anna @@ -9,7 +10,7 @@ import com.intellij.openapi.project.Project; */ class AddToNewFavoritesListAction extends AnAction { public AddToNewFavoritesListAction() { - super("Add to New Favorites List"); + super("Add To New Favorites List", "Add To New Favorites List", IconLoader.getIcon("/general/addFavoritesList.png")); } public void actionPerformed(AnActionEvent e) { diff --git a/source/com/intellij/ide/favoritesTreeView/FavoritesViewImpl.java b/source/com/intellij/ide/favoritesTreeView/FavoritesViewImpl.java index 50df756d9f2a..f42c499e8310 100644 --- a/source/com/intellij/ide/favoritesTreeView/FavoritesViewImpl.java +++ b/source/com/intellij/ide/favoritesTreeView/FavoritesViewImpl.java @@ -147,10 +147,6 @@ public class FavoritesViewImpl extends ContentManagerImpl implements ProjectComp return temp.isEmpty() ? null : temp.toArray(new String[temp.size()]); } - public String [] getAllAddActionNames(){ - return myActions.keySet().toArray(new String[myActions.keySet().size()]); - } - public AddToFavoritesAction getAddToFavoritesAction(String name){ return myActions.get(name); } diff --git a/source/com/intellij/ide/favoritesTreeView/FavoritesViewSelectInTarget.java b/source/com/intellij/ide/favoritesTreeView/FavoritesViewSelectInTarget.java index 16bda21f23c7..c7b9d185ec45 100644 --- a/source/com/intellij/ide/favoritesTreeView/FavoritesViewSelectInTarget.java +++ b/source/com/intellij/ide/favoritesTreeView/FavoritesViewSelectInTarget.java @@ -75,7 +75,7 @@ public class FavoritesViewSelectInTarget extends SelectInTargetPsiWrapper{ private FavoritesTreeViewPanel findSuitableFavoritesList(VirtualFile file){ final FavoritesViewImpl favoritesView = FavoritesViewImpl.getInstance(myProject); - final String[] allAddActionNames = favoritesView.getAllAddActionNames(); + final String[] allAddActionNames = favoritesView.getAvailableFavoritesLists(); for (int i = 0; i < allAddActionNames.length; i++) { String actionName = allAddActionNames[i]; final FavoritesTreeViewPanel favoritesTreeViewPanel = favoritesView.getFavoritesTreeViewPanel(actionName); diff --git a/source/com/intellij/ide/favoritesTreeView/FavoritesViewTreeBuilder.java b/source/com/intellij/ide/favoritesTreeView/FavoritesViewTreeBuilder.java index 21b39ad45308..b63b398abeee 100644 --- a/source/com/intellij/ide/favoritesTreeView/FavoritesViewTreeBuilder.java +++ b/source/com/intellij/ide/favoritesTreeView/FavoritesViewTreeBuilder.java @@ -29,13 +29,11 @@ import javax.swing.tree.DefaultTreeModel; public class FavoritesViewTreeBuilder extends BaseProjectTreeBuilder { private ProjectViewPsiTreeChangeListener myPsiTreeChangeListener; private ModuleRootListener myModuleRootListener; - private Project myProject; private FileStatusListener myFileStatusListener; private MyCopyPasteListener myCopyPasteListener; public FavoritesViewTreeBuilder(Project project, JTree tree, DefaultTreeModel treeModel, ProjectAbstractTreeStructureBase treeStructure) { super(project, tree, treeModel, treeStructure, IndexComparator.INSTANCE); - myProject = project; myPsiTreeChangeListener = new ProjectViewPsiTreeChangeListener() { protected DefaultMutableTreeNode getRootNode() { return myRootNode; diff --git a/source/com/intellij/ide/favoritesTreeView/SendToFavoritesGroup.java b/source/com/intellij/ide/favoritesTreeView/SendToFavoritesGroup.java index bcde7ecdd6aa..9d0cffb63d26 100644 --- a/source/com/intellij/ide/favoritesTreeView/SendToFavoritesGroup.java +++ b/source/com/intellij/ide/favoritesTreeView/SendToFavoritesGroup.java @@ -26,7 +26,7 @@ public class SendToFavoritesGroup extends DefaultActionGroup{ add(new SendToNewFavoritesListAction()); } - private class SendToNewFavoritesListAction extends AnAction { + private static class SendToNewFavoritesListAction extends AnAction { public SendToNewFavoritesListAction() { super("Send To New Favorites List"); }