change favorites actions

This commit is contained in:
Anna Kozlova
2005-03-03 13:52:29 +03:00
parent 91d70120df
commit 283ed5f20f
9 changed files with 35 additions and 21 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 937 B

+1 -1
View File
@@ -16,7 +16,7 @@
<action id="Vcs.ShowTabbedFileHistory" class="com.intellij.openapi.vcs.actions.TabbedShowHistoryAction" text="_Show History" description="Show history of file"/>
<action id="AddToFavoritesPopup" class="com.intellij.ide.favoritesTreeView.AddToFavoritesPopupAction" text="Add To Favorites" description="Add selected node to favorites"/>
<group id="AddToFavorites" popup="true" text="_Add To Favorites"/>
<group id="AddToFavorites" class = "com.intellij.ide.favoritesTreeView.AddToFavoritesActionGroup" popup="true" text="_Add To Favorites"/>
<action id="AddNewFavoritesList" class="com.intellij.ide.favoritesTreeView.AddNewFavoritesListAction" text="Add New Favorites List" description="Add New Favorites List"/>
<action id="RemoveFavoritesList" class="com.intellij.ide.favoritesTreeView.RemoveFavoritesListAction" text="Remove Favorites List" description="REmove Favorites List"/>
<group id="SendToFavoritesGroup" class="com.intellij.ide.favoritesTreeView.SendToFavoritesGroup" popup="true" text="_Send To Favorites"/>
@@ -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);
@@ -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());
}
}
@@ -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) {
@@ -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);
}
@@ -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);
@@ -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;
@@ -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");
}