Search in sources :

Example 1 with AbstractProjectViewPane

use of com.intellij.ide.projectView.impl.AbstractProjectViewPane in project intellij-community by JetBrains.

the class DissociateResourceBundleAction method dissociate.

public static void dissociate(final Collection<ResourceBundle> resourceBundles, final Project project) {
    final Set<PsiFileSystemItem> toUpdateInProjectView = new HashSet<>();
    for (ResourceBundle resourceBundle : resourceBundles) {
        for (final PropertiesFile propertiesFile : resourceBundle.getPropertiesFiles()) {
            PsiDirectory containingDirectory = propertiesFile.getContainingFile().getContainingDirectory();
            if (containingDirectory != null) {
                toUpdateInProjectView.add(containingDirectory);
            }
        }
        ResourceBundleManager.getInstance(project).dissociateResourceBundle(resourceBundle);
    }
    AbstractProjectViewPane currentProjectViewPane = ProjectView.getInstance(project).getCurrentProjectViewPane();
    if (currentProjectViewPane == null) {
        return;
    }
    AbstractTreeBuilder treeBuilder = currentProjectViewPane.getTreeBuilder();
    if (treeBuilder != null) {
        for (PsiFileSystemItem item : toUpdateInProjectView) {
            treeBuilder.queueUpdateFrom(item, false);
        }
    }
}
Also used : PsiDirectory(com.intellij.psi.PsiDirectory) AbstractTreeBuilder(com.intellij.ide.util.treeView.AbstractTreeBuilder) ResourceBundle(com.intellij.lang.properties.ResourceBundle) PropertiesFile(com.intellij.lang.properties.psi.PropertiesFile) PsiFileSystemItem(com.intellij.psi.PsiFileSystemItem) AbstractProjectViewPane(com.intellij.ide.projectView.impl.AbstractProjectViewPane) HashSet(com.intellij.util.containers.HashSet)

Example 2 with AbstractProjectViewPane

use of com.intellij.ide.projectView.impl.AbstractProjectViewPane in project intellij-community by JetBrains.

the class ProjectViewContextProvider method saveContext.

public void saveContext(Element toElement) throws WriteExternalException {
    for (AbstractProjectViewPane pane : myPanes) {
        Element paneElement = new Element(pane.getId());
        pane.writeExternal(paneElement);
        toElement.addContent(paneElement);
    }
}
Also used : Element(org.jdom.Element) AbstractProjectViewPane(com.intellij.ide.projectView.impl.AbstractProjectViewPane)

Example 3 with AbstractProjectViewPane

use of com.intellij.ide.projectView.impl.AbstractProjectViewPane in project intellij-community by JetBrains.

the class AddToFavoritesAction method createNodes.

@NotNull
public static Collection<AbstractTreeNode> createNodes(Project project, Module moduleContext, Object object, boolean inProjectView, ViewSettings favoritesConfig) {
    if (project == null)
        return Collections.emptyList();
    ArrayList<AbstractTreeNode> result = new ArrayList<>();
    for (FavoriteNodeProvider provider : Extensions.getExtensions(FavoriteNodeProvider.EP_NAME, project)) {
        final AbstractTreeNode treeNode = provider.createNode(project, object, favoritesConfig);
        if (treeNode != null) {
            result.add(treeNode);
            return result;
        }
    }
    final PsiManager psiManager = PsiManager.getInstance(project);
    final String currentViewId = ProjectView.getInstance(project).getCurrentViewId();
    AbstractProjectViewPane pane = ProjectView.getInstance(project).getProjectViewPaneById(currentViewId);
    //on psi elements
    if (object instanceof PsiElement[]) {
        for (PsiElement psiElement : (PsiElement[]) object) {
            addPsiElementNode(psiElement, project, result, favoritesConfig);
        }
        return result;
    }
    //on psi element
    if (object instanceof PsiElement) {
        Module containingModule = null;
        if (inProjectView && ProjectView.getInstance(project).isShowModules(currentViewId)) {
            if (pane != null && pane.getSelectedDescriptor() != null && pane.getSelectedDescriptor().getElement() instanceof AbstractTreeNode) {
                AbstractTreeNode abstractTreeNode = ((AbstractTreeNode) pane.getSelectedDescriptor().getElement());
                while (abstractTreeNode != null && !(abstractTreeNode.getParent() instanceof AbstractModuleNode)) {
                    abstractTreeNode = abstractTreeNode.getParent();
                }
                if (abstractTreeNode != null) {
                    containingModule = ((AbstractModuleNode) abstractTreeNode.getParent()).getValue();
                }
            }
        }
        addPsiElementNode((PsiElement) object, project, result, favoritesConfig);
        return result;
    }
    if (object instanceof VirtualFile[]) {
        for (VirtualFile vFile : (VirtualFile[]) object) {
            PsiElement element = psiManager.findFile(vFile);
            if (element == null)
                element = psiManager.findDirectory(vFile);
            addPsiElementNode(element, project, result, favoritesConfig);
        }
        return result;
    }
    //on form in editor
    if (object instanceof VirtualFile) {
        final VirtualFile vFile = (VirtualFile) object;
        final PsiFile psiFile = psiManager.findFile(vFile);
        addPsiElementNode(psiFile, project, result, favoritesConfig);
        return result;
    }
    //on module groups
    if (object instanceof ModuleGroup[]) {
        for (ModuleGroup moduleGroup : (ModuleGroup[]) object) {
            result.add(new ProjectViewModuleGroupNode(project, moduleGroup, favoritesConfig));
        }
        return result;
    }
    //on module nodes
    if (object instanceof Module)
        object = new Module[] { (Module) object };
    if (object instanceof Module[]) {
        for (Module module1 : (Module[]) object) {
            result.add(new ProjectViewModuleNode(project, module1, favoritesConfig));
        }
        return result;
    }
    //on library group node
    if (object instanceof LibraryGroupElement[]) {
        for (LibraryGroupElement libraryGroup : (LibraryGroupElement[]) object) {
            result.add(new LibraryGroupNode(project, libraryGroup, favoritesConfig));
        }
        return result;
    }
    //on named library node
    if (object instanceof NamedLibraryElement[]) {
        for (NamedLibraryElement namedLibrary : (NamedLibraryElement[]) object) {
            result.add(new NamedLibraryElementNode(project, namedLibrary, favoritesConfig));
        }
        return result;
    }
    return result;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ArrayList(java.util.ArrayList) AbstractTreeNode(com.intellij.ide.util.treeView.AbstractTreeNode) PsiManager(com.intellij.psi.PsiManager) ModuleGroup(com.intellij.ide.projectView.impl.ModuleGroup) PsiFile(com.intellij.psi.PsiFile) Module(com.intellij.openapi.module.Module) FavoriteNodeProvider(com.intellij.ide.favoritesTreeView.FavoriteNodeProvider) AbstractProjectViewPane(com.intellij.ide.projectView.impl.AbstractProjectViewPane) PsiElement(com.intellij.psi.PsiElement) NotNull(org.jetbrains.annotations.NotNull)

Example 4 with AbstractProjectViewPane

use of com.intellij.ide.projectView.impl.AbstractProjectViewPane in project intellij-community by JetBrains.

the class EditScopesAction method update.

@Override
public void update(AnActionEvent e) {
    super.update(e);
    e.getPresentation().setEnabled(false);
    final DataContext dataContext = e.getDataContext();
    final Project project = CommonDataKeys.PROJECT.getData(dataContext);
    if (project != null) {
        final AbstractProjectViewPane projectViewPane = ProjectView.getInstance(project).getCurrentProjectViewPane();
        if (projectViewPane != null) {
            final String scopeName = projectViewPane.getSubId();
            if (scopeName != null) {
                e.getPresentation().setEnabled(true);
            }
        }
    }
}
Also used : Project(com.intellij.openapi.project.Project) AbstractProjectViewPane(com.intellij.ide.projectView.impl.AbstractProjectViewPane)

Example 5 with AbstractProjectViewPane

use of com.intellij.ide.projectView.impl.AbstractProjectViewPane in project intellij-community by JetBrains.

the class ScopeTreeViewPanel method queueUpdate.

private void queueUpdate(final VirtualFile fileToRefresh, final Function<PsiFile, DefaultMutableTreeNode> rootToReloadGetter, final String scopeName) {
    if (myProject.isDisposed())
        return;
    AbstractProjectViewPane pane = ProjectView.getInstance(myProject).getCurrentProjectViewPane();
    if (pane == null || !ScopeViewPane.ID.equals(pane.getId()) || !scopeName.equals(pane.getSubId())) {
        return;
    }
    myUpdateQueue.queue(new Update(fileToRefresh) {

        @Override
        public void run() {
            if (myProject.isDisposed() || !fileToRefresh.isValid())
                return;
            final PsiFile psiFile = PsiManager.getInstance(myProject).findFile(fileToRefresh);
            if (psiFile != null) {
                reload(rootToReloadGetter.fun(psiFile));
            }
        }

        @Override
        public boolean isExpired() {
            return !isTreeShowing();
        }
    });
}
Also used : Update(com.intellij.util.ui.update.Update) AbstractProjectViewPane(com.intellij.ide.projectView.impl.AbstractProjectViewPane)

Aggregations

AbstractProjectViewPane (com.intellij.ide.projectView.impl.AbstractProjectViewPane)14 NotNull (org.jetbrains.annotations.NotNull)6 Module (com.intellij.openapi.module.Module)4 AndroidProjectViewPane (com.android.tools.idea.navigator.AndroidProjectViewPane)3 ProjectView (com.intellij.ide.projectView.ProjectView)3 Project (com.intellij.openapi.project.Project)3 PsiDirectory (com.intellij.psi.PsiDirectory)3 ArrayList (java.util.ArrayList)3 IdeView (com.intellij.ide.IdeView)2 SelectInTarget (com.intellij.ide.SelectInTarget)2 InputValidator (com.intellij.openapi.ui.InputValidator)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 Executor (com.intellij.execution.Executor)1 DefaultDebugExecutor (com.intellij.execution.executors.DefaultDebugExecutor)1 CompositeSelectInTarget (com.intellij.ide.CompositeSelectInTarget)1 FavoriteNodeProvider (com.intellij.ide.favoritesTreeView.FavoriteNodeProvider)1 ModuleGroup (com.intellij.ide.projectView.impl.ModuleGroup)1 AbstractTreeBuilder (com.intellij.ide.util.treeView.AbstractTreeBuilder)1 AbstractTreeNode (com.intellij.ide.util.treeView.AbstractTreeNode)1 ResourceBundle (com.intellij.lang.properties.ResourceBundle)1