com.intellij.ide.projectView.ProjectView Java Examples
The following examples show how to use
com.intellij.ide.projectView.ProjectView.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CopyHandler.java From consulo with Apache License 2.0 | 6 votes |
public static void updateSelectionInActiveProjectView(PsiElement newElement, Project project, boolean selectInActivePanel) { String id = ToolWindowManager.getInstance(project).getActiveToolWindowId(); if (id != null) { ToolWindow window = ToolWindowManager.getInstance(project).getToolWindow(id); Content selectedContent = window.getContentManager().getSelectedContent(); if (selectedContent != null) { JComponent component = selectedContent.getComponent(); if (component instanceof TwoPaneIdeView) { ((TwoPaneIdeView) component).selectElement(newElement, selectInActivePanel); return; } } } if (ToolWindowId.PROJECT_VIEW.equals(id)) { ProjectView.getInstance(project).selectPsiElement(newElement, true); } else if (ToolWindowId.STRUCTURE_VIEW.equals(id)) { VirtualFile virtualFile = newElement.getContainingFile().getVirtualFile(); FileEditor editor = FileEditorManager.getInstance(newElement.getProject()).getSelectedEditor(virtualFile); StructureViewFactoryEx.getInstanceEx(project).getStructureViewWrapper().selectCurrentElement(editor, virtualFile, true); } }
Example #2
Source File: ProjectTargetManagerImpl.java From intellij with Apache License 2.0 | 6 votes |
@Override public void buildStarted( Project project, BlazeContext context, boolean fullProjectSync, int buildId, ImmutableList<TargetExpression> targets) { ProjectTargetManagerImpl manager = getImpl(project); manager.inProgressBuilds.put( buildId, new InProgressSync(fullProjectSync, TargetExpressionList.create(targets))); if (fullProjectSync) { manager.projectSyncStatus = SyncStatus.RESYNCING; } // refresh the sync status indicators ProjectView.getInstance(project).refresh(); }
Example #3
Source File: PantsSystemProjectResolver.java From intellij-pants-plugin with Apache License 2.0 | 6 votes |
public void asyncViewSwitch() { /** * Make sure the project view opened so the view switch will follow. */ final ToolWindow projectWindow = ToolWindowManager.getInstance(myProject).getToolWindow(ToolWindowId.PROJECT_VIEW); if (projectWindow == null) { return; } ApplicationManager.getApplication().invokeLater(() -> { // Show Project Pane, and switch to ProjectFilesViewPane right after. projectWindow.show(() -> { ProjectView.getInstance(myProject).changeView(ProjectFilesViewPane.ID); // Disable directory focus as it may cause too much stress when // there is heavy indexing load right after project import. // https://youtrack.jetbrains.com/issue/IDEA-204959 // queueFocusOnImportDirectory(); }); }); }
Example #4
Source File: PantsSystemProjectResolver.java From intellij-pants-plugin with Apache License 2.0 | 6 votes |
private void queueFocusOnImportDirectory() { directoryFocusHandle = PantsUtil.scheduledThreadPool.scheduleWithFixedDelay(() -> { if (ModuleManager.getInstance(myProject).getModules().length == 0 || !ProjectView.getInstance(myProject).getCurrentViewId().equals(ProjectFilesViewPane.ID)) { return; } ApplicationManager.getApplication().invokeLater(() -> { final VirtualFile pathImported = LocalFileSystem.getInstance().findFileByPath(myProjectPath); // Skip focusing if directory is not found. if (pathImported != null) { VirtualFile importDirectory = pathImported.isDirectory() ? pathImported : pathImported.getParent(); SelectInContext selectInContext = new FileSelectInContext(myProject, importDirectory); for (SelectInTarget selectInTarget : ProjectView.getInstance(myProject).getSelectInTargets()) { if (selectInTarget instanceof PantsProjectPaneSelectInTarget) { selectInTarget.selectIn(selectInContext, false); break; } } } final boolean mayInterruptIfRunning = true; directoryFocusHandle.cancel(mayInterruptIfRunning); }); }, 0, 1, TimeUnit.SECONDS); }
Example #5
Source File: ProjectViewManager.java From SVNToolBox with Apache License 2.0 | 6 votes |
public void refreshProjectView(final Project project) { if (SvnToolBoxProjectState.getInstance(project).showingAnyDecorations()) { if (myActive.get()) { ApplicationManager.getApplication().invokeLater(new Runnable() { @Override public void run() { if (myActive.get()) { final ProjectView projectView = ProjectView.getInstance(project); if (LOG.isDebugEnabled()) { LOG.debug("[" + PV_SEQ.get() + "] Refreshing Project View"); } projectView.refresh(); } } }); } } else { if (LOG.isDebugEnabled()) { LOG.debug("[" + PV_SEQ.get() + "] Project View refresh ignored - decorations disabled"); } } }
Example #6
Source File: FavoritesProjectViewPane.java From consulo with Apache License 2.0 | 6 votes |
@Override public void select(Object object, VirtualFile file, boolean requestFocus) { if (!(object instanceof PsiElement)) return; /*PsiElement element = (PsiElement)object; PsiFile psiFile = element.getContainingFile(); if (psiFile != null) { element = psiFile; } if (element instanceof PsiJavaFile) { final PsiClass[] classes = ((PsiJavaFile)element).getClasses(); if (classes.length > 0) { element = classes[0]; } } final PsiElement originalElement = element.getOriginalElement();*/ final VirtualFile virtualFile = PsiUtilBase.getVirtualFile((PsiElement)object); final String list = FavoritesViewSelectInTarget.findSuitableFavoritesList(virtualFile, myProject, getSubId()); if (list == null) return; if (!list.equals(getSubId())) { ProjectView.getInstance(myProject).changeView(ID, list); } myViewPanel.selectElement(object, virtualFile, requestFocus); }
Example #7
Source File: NewElementToolbarAction.java From consulo with Apache License 2.0 | 6 votes |
@Override public void actionPerformed(AnActionEvent e) { if (e.getData(LangDataKeys.IDE_VIEW) == null) { final Project project = e.getData(CommonDataKeys.PROJECT); final PsiFileSystemItem psiFile = e.getData(LangDataKeys.PSI_FILE).getParent(); ProjectView.getInstance(project).selectCB(psiFile, psiFile.getVirtualFile(), true).doWhenDone(new Runnable() { @Override public void run() { showPopup(DataManager.getInstance().getDataContext()); } }); } else { super.actionPerformed(e); } }
Example #8
Source File: NavBarPanel.java From consulo with Apache License 2.0 | 6 votes |
protected void doubleClick(final Object object) { if (object instanceof Navigatable) { Navigatable navigatable = (Navigatable)object; if (navigatable.canNavigate()) { navigatable.navigate(true); } } else if (object instanceof Module) { ProjectView projectView = ProjectView.getInstance(myProject); AbstractProjectViewPane projectViewPane = projectView.getProjectViewPaneById(projectView.getCurrentViewId()); if (projectViewPane != null) { projectViewPane.selectModule((Module)object, true); } } else if (object instanceof Project) { return; } hideHint(true); }
Example #9
Source File: AbstractProjectViewPane.java From consulo with Apache License 2.0 | 6 votes |
private void doSelectModuleOrGroup(@Nonnull Object toSelect, final boolean requestFocus) { ToolWindowManager windowManager = ToolWindowManager.getInstance(myProject); final Runnable runnable = () -> { if (requestFocus) { ProjectView projectView = ProjectView.getInstance(myProject); if (projectView != null) { projectView.changeView(getId(), getSubId()); } } BaseProjectTreeBuilder builder = (BaseProjectTreeBuilder)getTreeBuilder(); if (builder != null) { builder.selectInWidth(toSelect, requestFocus, node -> node instanceof AbstractModuleNode || node instanceof ModuleGroupNode || node instanceof AbstractProjectNode); } }; if (requestFocus) { windowManager.getToolWindow(ToolWindowId.PROJECT_VIEW).activate(runnable); } else { runnable.run(); } }
Example #10
Source File: ProjectViewSelectInGroupTarget.java From consulo with Apache License 2.0 | 6 votes |
@Override public void selectIn(final SelectInContext context, final boolean requestFocus) { ProjectView projectView = ProjectView.getInstance(context.getProject()); Collection<SelectInTarget> targets = projectView.getSelectInTargets(); Collection<SelectInTarget> targetsToCheck = new LinkedHashSet<>(); String currentId = projectView.getCurrentViewId(); for (SelectInTarget projectViewTarget : targets) { if (Comparing.equal(currentId, projectViewTarget.getMinorViewId())) { targetsToCheck.add(projectViewTarget); break; } } targetsToCheck.addAll(targets); for (SelectInTarget target : targetsToCheck) { if (context.selectIn(target, requestFocus)) break; } }
Example #11
Source File: EditScopesAction.java From consulo with Apache License 2.0 | 6 votes |
@Override public void update(AnActionEvent e) { super.update(e); e.getPresentation().setEnabled(false); final DataContext dataContext = e.getDataContext(); final Project project = dataContext.getData(CommonDataKeys.PROJECT); 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); } } } }
Example #12
Source File: ScopeTreeViewPanel.java From consulo with Apache License 2.0 | 6 votes |
@Override public void selectElement(final PsiElement element) { if (element != null) { final PackageSet packageSet = getCurrentScope().getValue(); final PsiFile psiFile = element.getContainingFile(); if (packageSet == null) return; final VirtualFile virtualFile = psiFile != null ? psiFile.getVirtualFile() : (element instanceof PsiDirectory ? ((PsiDirectory)element).getVirtualFile() : null); if (virtualFile != null) { final ProjectView projectView = ProjectView.getInstance(myProject); final NamedScopesHolder holder = NamedScopesHolder.getHolder(myProject, CURRENT_SCOPE_NAME, myDependencyValidationManager); if (packageSet instanceof PackageSetBase && !((PackageSetBase)packageSet).contains(virtualFile, holder) || psiFile != null && !packageSet.contains(psiFile, holder)) { projectView.changeView(ProjectViewPane.ID); } projectView.select(element, virtualFile, false); } Editor editor = EditorHelper.openInEditor(element); if (editor != null) { ToolWindowManager.getInstance(myProject).activateEditorComponent(); } } }
Example #13
Source File: ScopeTreeViewPanel.java From consulo with Apache License 2.0 | 6 votes |
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(); } }); }
Example #14
Source File: PackageViewPane.java From consulo with Apache License 2.0 | 6 votes |
@Override public boolean addSubtreeToUpdateByElement(Object element) { // should convert PsiDirectories into PackageElements if (element instanceof PsiDirectory) { PsiDirectory dir = (PsiDirectory)element; final PsiPackage aPackage = PsiPackageManager.getInstance(dir.getProject()).findAnyPackage(dir); if (ProjectView.getInstance(myProject).isShowModules(getId())) { Module[] modules = getModulesFor(dir); boolean rv = false; for (Module module : modules) { rv |= addPackageElementToUpdate(aPackage, module); } return rv; } else { return addPackageElementToUpdate(aPackage, null); } } return super.addSubtreeToUpdateByElement(element); }
Example #15
Source File: ScopeTreeViewPanel.java From consulo with Apache License 2.0 | 6 votes |
private void fireListeners(ChangeList list, @Nullable String oldName) { AbstractProjectViewPane pane = ProjectView.getInstance(myProject).getCurrentProjectViewPane(); if (pane == null || !ScopeViewPane.ID.equals(pane.getId())) { return; } final String subId = pane.getSubId(); if (!list.getName().equals(subId) && (oldName == null || !oldName.equals(subId))) { return; } ApplicationManager.getApplication().invokeLater(new Runnable() { @Override public void run() { myDependencyValidationManager.fireScopeListeners(); } }, myProject.getDisposed()); }
Example #16
Source File: PullCommand.java From ADB-Duang with MIT License | 6 votes |
private void selectInTargetFile(final VirtualFile targetFile) { UIUtil.invokeLaterIfNeeded(new Runnable() { public void run() { Project project = deviceResult.anActionEvent.getProject(); Editor editor = deviceResult.anActionEvent.getData(PlatformDataKeys.EDITOR); MySelectInContext selectInContext = new MySelectInContext(targetFile, editor, project); ProjectViewImpl projectView = (ProjectViewImpl) ProjectView.getInstance(project); AbstractProjectViewPane currentProjectViewPane = projectView.getCurrentProjectViewPane(); SelectInTarget target = currentProjectViewPane.createSelectInTarget(); if (target != null && target.canSelect(selectInContext)) { target.selectIn(selectInContext, false); } else { selectInContext = new MySelectInContext(targetFile.getParent(), editor, project); if (target != null && target.canSelect(selectInContext)) { target.selectIn(selectInContext, false); } } } }); }
Example #17
Source File: TestProjectViewPSIPane.java From consulo with Apache License 2.0 | 5 votes |
public void projectOpened() { final Runnable runnable = new DumbAwareRunnable() { @Override public void run() { final ProjectView projectView = ProjectView.getInstance(myProject); projectView.addProjectPane(TestProjectViewPSIPane.this); } }; StartupManager.getInstance(myProject).registerPostStartupActivity(runnable); }
Example #18
Source File: FavoritesProjectViewPane.java From consulo with Apache License 2.0 | 5 votes |
protected FavoritesProjectViewPane(final Project project, ProjectView projectView, FavoritesManager favoritesManager) { super(project); myProjectView = projectView; myFavoritesManager = favoritesManager; myFavoritesListener = new FavoritesListener() { @Override public void rootsChanged() { } @Override public void listAdded(String listName) { refreshMySubIdsAndSelect(listName); } @Override public void listRemoved(String listName) { String selectedSubId = getSubId(); refreshMySubIdsAndSelect(selectedSubId); } private void refreshMySubIdsAndSelect(String listName) { myFavoritesManager.removeFavoritesListener(myFavoritesListener); myProjectView.removeProjectPane(FavoritesProjectViewPane.this); myProjectView.addProjectPane(FavoritesProjectViewPane.this); myFavoritesManager.addFavoritesListener(myFavoritesListener); if (!myFavoritesManager.getAvailableFavoritesListNames().contains(listName)) { listName = null; } myProjectView.changeView(ID, listName); } }; myFavoritesManager.addFavoritesListener(myFavoritesListener); }
Example #19
Source File: MoveModulesToGroupAction.java From consulo with Apache License 2.0 | 5 votes |
public static void doMove(final Module[] modules, final ModuleGroup group, @Nullable final DataContext dataContext) { Project project = modules[0].getProject(); for (final Module module : modules) { ModifiableModuleModel model = dataContext != null ? dataContext.getData(LangDataKeys.MODIFIABLE_MODULE_MODEL) : null; if (model != null){ model.setModuleGroupPath(module, group == null ? null : group.getGroupPath()); } else { ModuleManagerImpl.getInstanceImpl(project).setModuleGroupPath(module, group == null ? null : group.getGroupPath()); } } AbstractProjectViewPane pane = ProjectView.getInstance(project).getCurrentProjectViewPane(); if (pane != null) { pane.updateFromRoot(true); } if (!ProjectSettingsService.getInstance(project).processModulesMoved(modules, group) && pane != null) { if (group != null) { pane.selectModuleGroup(group, true); } else { pane.selectModule(modules[0], true); } } }
Example #20
Source File: PackageViewPane.java From consulo with Apache License 2.0 | 5 votes |
@Override public void update(AnActionEvent e) { super.update(e); final Presentation presentation = e.getPresentation(); final ProjectViewImpl projectView = (ProjectViewImpl)ProjectView.getInstance(myProject); presentation.setVisible(projectView.getCurrentProjectViewPane() == PackageViewPane.this); }
Example #21
Source File: PsiDirectoryNode.java From consulo with Apache License 2.0 | 5 votes |
@Override public int getWeight() { final ProjectView projectView = ProjectView.getInstance(myProject); if (projectView instanceof ProjectViewImpl && !((ProjectViewImpl)projectView).isFoldersAlwaysOnTop()) { return 20; } return isFQNameShown() ? 70 : 0; }
Example #22
Source File: ShowModulesAction.java From consulo with Apache License 2.0 | 5 votes |
@Override public void update(AnActionEvent e) { super.update(e); final Presentation presentation = e.getPresentation(); final ProjectViewImpl projectView = (ProjectViewImpl)ProjectView.getInstance(myProject); presentation.setVisible(Comparing.strEqual(projectView.getCurrentViewId(), getId())); }
Example #23
Source File: ProjectViewSelectInGroupTarget.java From consulo with Apache License 2.0 | 5 votes |
@Override public boolean canSelect(SelectInContext context) { ProjectView projectView = ProjectView.getInstance(context.getProject()); Collection<SelectInTarget> targets = projectView.getSelectInTargets(); for (SelectInTarget projectViewTarget : targets) { if (projectViewTarget.canSelect(context)) return true; } return false; }
Example #24
Source File: ProjectTargetManagerImpl.java From intellij with Apache License 2.0 | 5 votes |
@Override public void afterSync( Project project, BlazeContext context, SyncMode syncMode, SyncResult syncResult, ImmutableSet<Integer> buildIds) { ProjectTargetManagerImpl manager = getImpl(project); buildIds.forEach(manager.inProgressBuilds::remove); manager.updateProjectSyncStatus(); if (!syncResult.successful()) { // project view won't otherwise update for failed/cancelled syncs ProjectView.getInstance(project).refresh(); } }
Example #25
Source File: ProjectViewSelectInTarget.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull public static ActionCallback select(@Nonnull Project project, final Object toSelect, @Nullable final String viewId, @Nullable final String subviewId, final VirtualFile virtualFile, final boolean requestFocus) { final ActionCallback result = new ActionCallback(); final ProjectView projectView = ProjectView.getInstance(project); if (ApplicationManager.getApplication().isUnitTestMode()) { AbstractProjectViewPane pane = projectView.getProjectViewPaneById(ProjectViewPane.ID); pane.select(toSelect, virtualFile, requestFocus); return result; } ToolWindowManager windowManager = ToolWindowManager.getInstance(project); final ToolWindow projectViewToolWindow = windowManager.getToolWindow(ToolWindowId.PROJECT_VIEW); final Runnable runnable = () -> { Runnable r = () -> projectView.selectCB(toSelect, virtualFile, requestFocus).notify(result); projectView.changeViewCB(ObjectUtils.chooseNotNull(viewId, ProjectViewPane.ID), subviewId).doWhenProcessed(r); }; if (requestFocus) { projectViewToolWindow.activate(runnable, true); } else { projectViewToolWindow.show(runnable); } return result; }
Example #26
Source File: ProjectViewSelectInTarget.java From consulo with Apache License 2.0 | 5 votes |
@Override @Nonnull public Collection<SelectInTarget> getSubTargets(@Nonnull SelectInContext context) { List<SelectInTarget> result = new ArrayList<>(); AbstractProjectViewPane pane = ProjectView.getInstance(myProject).getProjectViewPaneById(getMinorViewId()); int index = 0; for (String subId : pane.getSubIds()) { result.add(new ProjectSubViewSelectInTarget(this, subId, index++)); } return result; }
Example #27
Source File: EditScopesAction.java From consulo with Apache License 2.0 | 5 votes |
@Override public void actionPerformed(AnActionEvent e) { final DataContext dataContext = e.getDataContext(); final Project project = dataContext.getData(CommonDataKeys.PROJECT); LOG.assertTrue(project != null); final String scopeName = ProjectView.getInstance(project).getCurrentProjectViewPane().getSubId(); LOG.assertTrue(scopeName != null); final ScopeChooserConfigurable scopeChooserConfigurable = new ScopeChooserConfigurable(project); ShowSettingsUtil.getInstance().editConfigurable(project, scopeChooserConfigurable, new Runnable(){ @Override public void run() { scopeChooserConfigurable.selectNodeInTree(scopeName); } }); }
Example #28
Source File: ScopeViewPane.java From consulo with Apache License 2.0 | 5 votes |
@Inject public ScopeViewPane(final Project project, ProjectView projectView, DependencyValidationManager dependencyValidationManager, NamedScopeManager namedScopeManager) { super(project); myProjectView = projectView; myDependencyValidationManager = dependencyValidationManager; myNamedScopeManager = namedScopeManager; myScopeListener = new NamedScopesHolder.ScopeListener() { Alarm refreshProjectViewAlarm = new Alarm(); @Override public void scopesChanged() { // amortize batch scope changes refreshProjectViewAlarm.cancelAllRequests(); refreshProjectViewAlarm.addRequest(new Runnable() { @Override public void run() { if (myProject.isDisposed()) return; final String subId = getSubId(); final String id = myProjectView.getCurrentViewId(); myProjectView.removeProjectPane(ScopeViewPane.this); myProjectView.addProjectPane(ScopeViewPane.this); if (id != null) { if (Comparing.strEqual(id, getId())) { myProjectView.changeView(id, subId); } else { myProjectView.changeView(id); } } } }, 10); } }; myDependencyValidationManager.addScopeListener(myScopeListener, this); myNamedScopeManager.addScopeListener(myScopeListener, this); }
Example #29
Source File: IJUtils.java From intellij-extra-icons-plugin with MIT License | 5 votes |
/** * Refresh project view. */ public static void refresh(Project project) { if (project != null) { ProjectView view = ProjectView.getInstance(project); view.refresh(); view.getCurrentProjectViewPane().updateFromRoot(true); } }
Example #30
Source File: ProjectFilesViewPane.java From intellij-pants-plugin with Apache License 2.0 | 5 votes |
@Override public void update(@NotNull AnActionEvent e) { super.update(e); final Presentation presentation = e.getPresentation(); final ProjectView projectView = ProjectView.getInstance(myProject); presentation.setEnabledAndVisible(projectView.getCurrentProjectViewPane() == ProjectFilesViewPane.this); }