Search in sources :

Example 1 with FavoritesListNode

use of com.intellij.ide.favoritesTreeView.FavoritesListNode 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 2 with FavoritesListNode

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

the class SendToFavoritesAction method isEnabled.

static boolean isEnabled(AnActionEvent e) {
    Project project = e.getProject();
    if (project == null) {
        return false;
    }
    FavoritesTreeNodeDescriptor[] roots = FavoritesTreeViewPanel.CONTEXT_FAVORITES_ROOTS_DATA_KEY.getData(e.getDataContext());
    if (roots == null || roots.length == 0) {
        return false;
    }
    for (FavoritesTreeNodeDescriptor root : roots) {
        FavoritesTreeNodeDescriptor listNode = root.getFavoritesRoot();
        if (listNode == null || listNode == root || !(listNode.getElement() instanceof FavoritesListNode))
            return false;
    }
    return true;
}
Also used : Project(com.intellij.openapi.project.Project) FavoritesListNode(com.intellij.ide.favoritesTreeView.FavoritesListNode) FavoritesTreeNodeDescriptor(com.intellij.ide.favoritesTreeView.FavoritesTreeNodeDescriptor)

Aggregations

FavoritesListNode (com.intellij.ide.favoritesTreeView.FavoritesListNode)2 FavoritesTreeNodeDescriptor (com.intellij.ide.favoritesTreeView.FavoritesTreeNodeDescriptor)2 Project (com.intellij.openapi.project.Project)2 FavoritesManager (com.intellij.ide.favoritesTreeView.FavoritesManager)1 DataContext (com.intellij.openapi.actionSystem.DataContext)1