From 283ed5f20f39eae90f6f68c46d4ce61e32c96126 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Thu, 3 Mar 2005 13:52:29 +0300 Subject: [PATCH] change favorites actions --- icons/src/general/addFavoritesList.png | Bin 0 -> 937 bytes resources/src/idea/ActionManager.xml | 2 +- .../AddNewFavoritesListAction.java | 14 ++------- .../AddToFavoritesActionGroup.java | 27 ++++++++++++++++++ .../AddToNewFavoritesListAction.java | 3 +- .../favoritesTreeView/FavoritesViewImpl.java | 4 --- .../FavoritesViewSelectInTarget.java | 2 +- .../FavoritesViewTreeBuilder.java | 2 -- .../SendToFavoritesGroup.java | 2 +- 9 files changed, 35 insertions(+), 21 deletions(-) create mode 100644 icons/src/general/addFavoritesList.png create mode 100644 source/com/intellij/ide/favoritesTreeView/AddToFavoritesActionGroup.java diff --git a/icons/src/general/addFavoritesList.png b/icons/src/general/addFavoritesList.png new file mode 100644 index 0000000000000000000000000000000000000000..d1f75830ec892d6315c291480e5f9f234ddae0d5 GIT binary patch literal 937 zcmV;a16KTrP)Fu5KFNXj=n4P=07(G0 z{{(boRzo5n9kK%u902|M`2YX>_5fl)69xbN_yYm}`v3s|{QwaI>jCQP>i`xO>Hq)< z4**Lo@nZe`{ZIe?{s7$S2mtH#1hE2$MMXw*Q$}Va7lW_~1H%uX!XM8W7{0$`VEFq1 zh`%y0{QJuA{mo^Dt?Sn?gd_pgu>E6buKcOb@b5EF-4_OiXHOY|`)nBi0*Hy3SB!x{ z*ocAQ8_41a$D4f_2X>`jLMj6jz%GgMDgd9?kmi0eQ0zmGtH4G=&q|9%4v`tgz>HfJGF z(NCx$zZhadqkv}p0UGw3Vab}641c#~0=)v1W99{7HimM~qjK9Pd&vUL02>4lKrD

}WAqop!nv%E;zM7{G4RMR@QDjC z2($l)ea*lMPUQdr#00bwtQm&?0>cF45>V9s{_&OJ7Z8KO=g0TI|7IVTOs}3Oe2d}U zX$FSR?-^A2KdQpg5kLU3FfsmNWcdFLY{-9LnEd_u6Bw4i8UFtV8T1VpMnD&{axgId z{q^$;Gvki!cf|efPiCK{Dezw9(+`#}FoOUBh~?*}=fIdh&%h}l3$*zUP~&fgndRCH z9}ZOlgH00bBSX$*MQaskG@00000 LNkvXXu0mjf`GcxG literal 0 HcmV?d00001 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"); }