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);
}
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));
}
}
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());
}
}
}
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);
}
}
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;
}
Aggregations