Search in sources :

Example 1 with FavoritesViewTreeBuilder

use of com.intellij.ide.favoritesTreeView.FavoritesViewTreeBuilder 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 FavoritesViewTreeBuilder

use of com.intellij.ide.favoritesTreeView.FavoritesViewTreeBuilder 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)

Aggregations

FavoritesListProvider (com.intellij.ide.favoritesTreeView.FavoritesListProvider)2 FavoritesManager (com.intellij.ide.favoritesTreeView.FavoritesManager)2 FavoritesViewTreeBuilder (com.intellij.ide.favoritesTreeView.FavoritesViewTreeBuilder)2 Project (com.intellij.openapi.project.Project)2