Search in sources :

Example 1 with FavoritesManager

use of com.intellij.ide.favoritesTreeView.FavoritesManager in project intellij-community by JetBrains.

the class EditFavoritesAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    Project project = e.getProject();
    FavoritesViewTreeBuilder treeBuilder = FavoritesTreeViewPanel.FAVORITES_TREE_BUILDER_KEY.getData(e.getDataContext());
    String listName = FavoritesTreeViewPanel.FAVORITES_LIST_NAME_DATA_KEY.getData(e.getDataContext());
    if (project == null || treeBuilder == null || listName == null) {
        return;
    }
    FavoritesManager favoritesManager = FavoritesManager.getInstance(project);
    FavoritesListProvider provider = favoritesManager.getListProvider(listName);
    Set<Object> selection = treeBuilder.getSelectedElements();
    if (provider != null && provider.willHandle(CommonActionsPanel.Buttons.EDIT, project, selection)) {
        provider.handle(CommonActionsPanel.Buttons.EDIT, project, selection, treeBuilder.getTree());
        return;
    }
    favoritesManager.renameList(project, listName);
}
Also used : Project(com.intellij.openapi.project.Project) FavoritesViewTreeBuilder(com.intellij.ide.favoritesTreeView.FavoritesViewTreeBuilder) FavoritesManager(com.intellij.ide.favoritesTreeView.FavoritesManager) FavoritesListProvider(com.intellij.ide.favoritesTreeView.FavoritesListProvider)

Example 2 with FavoritesManager

use of com.intellij.ide.favoritesTreeView.FavoritesManager in project intellij-community by JetBrains.

the class EditFavoritesAction method update.

@Override
public void update(AnActionEvent e) {
    e.getPresentation().setText(getTemplatePresentation().getText());
    e.getPresentation().setIcon(CommonActionsPanel.Buttons.EDIT.getIcon());
    e.getPresentation().setEnabled(true);
    Project project = e.getProject();
    FavoritesViewTreeBuilder treeBuilder = FavoritesTreeViewPanel.FAVORITES_TREE_BUILDER_KEY.getData(e.getDataContext());
    String listName = FavoritesTreeViewPanel.FAVORITES_LIST_NAME_DATA_KEY.getData(e.getDataContext());
    if (project == null || treeBuilder == null || listName == null) {
        e.getPresentation().setEnabled(false);
        return;
    }
    FavoritesManager favoritesManager = FavoritesManager.getInstance(project);
    FavoritesListProvider provider = favoritesManager.getListProvider(listName);
    Set<Object> selection = treeBuilder.getSelectedElements();
    if (provider != null) {
        e.getPresentation().setEnabled(provider.willHandle(CommonActionsPanel.Buttons.EDIT, project, selection));
        e.getPresentation().setText(provider.getCustomName(CommonActionsPanel.Buttons.EDIT));
    }
}
Also used : Project(com.intellij.openapi.project.Project) FavoritesViewTreeBuilder(com.intellij.ide.favoritesTreeView.FavoritesViewTreeBuilder) FavoritesManager(com.intellij.ide.favoritesTreeView.FavoritesManager) FavoritesListProvider(com.intellij.ide.favoritesTreeView.FavoritesListProvider)

Example 3 with FavoritesManager

use of com.intellij.ide.favoritesTreeView.FavoritesManager in project intellij-community by JetBrains.

the class SendToFavoritesAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    final DataContext dataContext = e.getDataContext();
    Project project = e.getProject();
    final FavoritesManager favoritesManager = FavoritesManager.getInstance(project);
    FavoritesTreeNodeDescriptor[] roots = FavoritesTreeViewPanel.CONTEXT_FAVORITES_ROOTS_DATA_KEY.getData(dataContext);
    if (roots == null)
        return;
    for (FavoritesTreeNodeDescriptor root : roots) {
        FavoritesTreeNodeDescriptor listNode = root.getFavoritesRoot();
        if (listNode != null && listNode != root && listNode.getElement() instanceof FavoritesListNode) {
            doSend(favoritesManager, new FavoritesTreeNodeDescriptor[] { root }, listNode.getElement().getName());
        }
    }
}
Also used : Project(com.intellij.openapi.project.Project) DataContext(com.intellij.openapi.actionSystem.DataContext) FavoritesListNode(com.intellij.ide.favoritesTreeView.FavoritesListNode) FavoritesTreeNodeDescriptor(com.intellij.ide.favoritesTreeView.FavoritesTreeNodeDescriptor) FavoritesManager(com.intellij.ide.favoritesTreeView.FavoritesManager)

Example 4 with FavoritesManager

use of com.intellij.ide.favoritesTreeView.FavoritesManager in project intellij-community by JetBrains.

the class AddAllOpenFilesToFavorites method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    final Project project = e.getProject();
    if (project == null) {
        return;
    }
    final FavoritesManager favoritesManager = FavoritesManager.getInstance(project);
    final ArrayList<PsiFile> filesToAdd = getFilesToAdd(project);
    for (PsiFile file : filesToAdd) {
        favoritesManager.addRoots(myFavoritesName, null, file);
    }
}
Also used : Project(com.intellij.openapi.project.Project) PsiFile(com.intellij.psi.PsiFile) FavoritesManager(com.intellij.ide.favoritesTreeView.FavoritesManager)

Example 5 with FavoritesManager

use of com.intellij.ide.favoritesTreeView.FavoritesManager in project intellij-community by JetBrains.

the class AddNewFavoritesListAction method doAddNewFavoritesList.

public static String doAddNewFavoritesList(final Project project) {
    final FavoritesManager favoritesManager = FavoritesManager.getInstance(project);
    final String name = Messages.showInputDialog(project, IdeBundle.message("prompt.input.new.favorites.list.name"), IdeBundle.message("title.add.new.favorites.list"), Messages.getInformationIcon(), getUniqueName(project), new InputValidator() {

        @Override
        public boolean checkInput(String inputString) {
            return inputString != null && inputString.trim().length() > 0;
        }

        @Override
        public boolean canClose(String inputString) {
            inputString = inputString.trim();
            if (favoritesManager.getAvailableFavoritesListNames().contains(inputString)) {
                Messages.showErrorDialog(project, IdeBundle.message("error.favorites.list.already.exists", inputString.trim()), IdeBundle.message("title.unable.to.add.favorites.list"));
                return false;
            }
            return inputString.length() > 0;
        }
    });
    if (name == null || name.length() == 0)
        return null;
    favoritesManager.createNewList(name);
    return name;
}
Also used : InputValidator(com.intellij.openapi.ui.InputValidator) FavoritesManager(com.intellij.ide.favoritesTreeView.FavoritesManager)

Aggregations

FavoritesManager (com.intellij.ide.favoritesTreeView.FavoritesManager)6 Project (com.intellij.openapi.project.Project)4 FavoritesListProvider (com.intellij.ide.favoritesTreeView.FavoritesListProvider)2 FavoritesViewTreeBuilder (com.intellij.ide.favoritesTreeView.FavoritesViewTreeBuilder)2 PsiFile (com.intellij.psi.PsiFile)2 FavoritesListNode (com.intellij.ide.favoritesTreeView.FavoritesListNode)1 FavoritesTreeNodeDescriptor (com.intellij.ide.favoritesTreeView.FavoritesTreeNodeDescriptor)1 AbstractUrl (com.intellij.ide.projectView.impl.AbstractUrl)1 DataContext (com.intellij.openapi.actionSystem.DataContext)1 Editor (com.intellij.openapi.editor.Editor)1 SelectionModel (com.intellij.openapi.editor.SelectionModel)1 InputValidator (com.intellij.openapi.ui.InputValidator)1 TextRange (com.intellij.openapi.util.TextRange)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 PsiElement (com.intellij.psi.PsiElement)1 PsiWhiteSpace (com.intellij.psi.PsiWhiteSpace)1 Usage (com.intellij.usages.Usage)1 UsageView (com.intellij.usages.UsageView)1 PsiElementUsage (com.intellij.usages.rules.PsiElementUsage)1 TreeItem (com.intellij.util.TreeItem)1