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