Java Code Examples for com.intellij.ide.projectView.ProjectView#getInstance()

The following examples show how to use com.intellij.ide.projectView.ProjectView#getInstance() . 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: ScopeTreeViewPanel.java    From consulo with Apache License 2.0 6 votes vote down vote up
@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 2
Source File: NavBarPanel.java    From consulo with Apache License 2.0 6 votes vote down vote up
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 3
Source File: AbstractProjectViewPane.java    From consulo with Apache License 2.0 6 votes vote down vote up
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 4
Source File: ProjectViewSelectInGroupTarget.java    From consulo with Apache License 2.0 6 votes vote down vote up
@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 5
Source File: IJUtils.java    From intellij-extra-icons-plugin with MIT License 5 votes vote down vote up
/**
 * Refresh project view.
 */
public static void refresh(Project project) {
    if (project != null) {
        ProjectView view = ProjectView.getInstance(project);
        view.refresh();
        view.getCurrentProjectViewPane().updateFromRoot(true);
    }
}
 
Example 6
Source File: ProjectFilesViewPane.java    From intellij-pants-plugin with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 7
Source File: ProjectFilesViewPane.java    From intellij-pants-plugin with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 8
Source File: Unity3dShowMetaFileProjectViewPaneOptionProvider.java    From consulo-unity3d with Apache License 2.0 5 votes vote down vote up
@Override
@RequiredUIAccess
public void update(AnActionEvent e)
{
	super.update(e);
	final Presentation presentation = e.getPresentation();
	final ProjectView projectView = ProjectView.getInstance(e.getProject());
	presentation.setVisible(projectView.getCurrentProjectViewPane() == myPane && Unity3dModuleExtensionUtil.getRootModuleExtension(myPane.getProject()) != null);
}
 
Example 9
Source File: TestProjectViewPSIPane.java    From consulo with Apache License 2.0 5 votes vote down vote up
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 10
Source File: ChangeProjectViewAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void actionPerformed(AnActionEvent e) {
  Project project = e.getDataContext().getData(CommonDataKeys.PROJECT);
  if (project == null) {
    return;
  }
  ProjectView projectView = ProjectView.getInstance(project);
  projectView.changeView();
}
 
Example 11
Source File: ProjectViewSelectInTarget.java    From consulo with Apache License 2.0 5 votes vote down vote up
@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 12
Source File: PackageViewPane.java    From consulo with Apache License 2.0 5 votes vote down vote up
@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 13
Source File: PsiDirectoryNode.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public int getWeight() {
  final ProjectView projectView = ProjectView.getInstance(myProject);
  if (projectView instanceof ProjectViewImpl && !((ProjectViewImpl)projectView).isFoldersAlwaysOnTop()) {
    return 20;
  }
  return isFQNameShown() ? 70 : 0;
}
 
Example 14
Source File: ProjectViewSelectInGroupTarget.java    From consulo with Apache License 2.0 5 votes vote down vote up
@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 15
Source File: ShowModulesAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@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 16
Source File: ScopeTreeViewPanel.java    From consulo with Apache License 2.0 4 votes vote down vote up
public void refreshScope(@Nullable NamedScope scope) {
  FileTreeModelBuilder.clearCaches(myProject);
  if (scope == null) { //was deleted
    scope = DefaultScopesProvider.getAllScope();
  }
  LOG.assertTrue(scope != null);
  final NamedScopesHolder holder = NamedScopesHolder.getHolder(myProject, scope.getName(), myDependencyValidationManager);
  final PackageSet packageSet = scope.getValue() != null ? scope.getValue() : new InvalidPackageSet("");
  final DependenciesPanel.DependencyPanelSettings settings = new DependenciesPanel.DependencyPanelSettings();
  settings.UI_FILTER_LEGALS = true;
  settings.UI_GROUP_BY_SCOPE_TYPE = false;
  settings.UI_SHOW_FILES = true;
  final ProjectView projectView = ProjectView.getInstance(myProject);
  settings.UI_FLATTEN_PACKAGES = projectView.isFlattenPackages(ScopeViewPane.ID);
  settings.UI_COMPACT_EMPTY_MIDDLE_PACKAGES = projectView.isHideEmptyMiddlePackages(ScopeViewPane.ID);
  settings.UI_SHOW_MODULES = projectView.isShowModules(ScopeViewPane.ID);
  settings.UI_SHOW_MODULE_GROUPS = projectView.isShowModules(ScopeViewPane.ID);
  myBuilder = new FileTreeModelBuilder(myProject, new Marker() {
    @Override
    public boolean isMarked(VirtualFile file) {
      return packageSet != null &&
             (packageSet instanceof PackageSetBase ? ((PackageSetBase)packageSet).contains(file, holder) : packageSet.contains(PackageSetBase.getPsiFile(file, holder), holder));
    }
  }, settings);
  myTree.setPaintBusy(true);
  myBuilder.setTree(myTree);
  myTree.getEmptyText().setText("Loading...");
  myActionCallback = new AsyncResult<>();
  myTree.putClientProperty(TreeState.CALLBACK, new WeakReference<ActionCallback>(myActionCallback));
  myTree.setModel(myBuilder.build(myProject, true, new Runnable() {
    @Override
    public void run() {
      myTree.setPaintBusy(false);
      myTree.getEmptyText().setText(UIBundle.message("message.nothingToShow"));
      myActionCallback.setDone();
    }
  }));
  ((PackageDependenciesNode)myTree.getModel().getRoot()).sortChildren();
  ((DefaultTreeModel)myTree.getModel()).reload();
  FileTreeModelBuilder.clearCaches(myProject);
}
 
Example 17
Source File: ShowModulesAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void setSelected(AnActionEvent event, boolean flag) {
  final ProjectViewImpl projectView = (ProjectViewImpl)ProjectView.getInstance(myProject);
  projectView.setShowModules(flag, getId());
}
 
Example 18
Source File: AbstractProjectViewPane.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
protected Comparator<NodeDescriptor> createComparator() {
  return new GroupByTypeComparator(ProjectView.getInstance(myProject), getId());
}
 
Example 19
Source File: PackageViewPane.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void setSelected(AnActionEvent event, boolean flag) {
  final ProjectViewImpl projectView = (ProjectViewImpl)ProjectView.getInstance(myProject);
  projectView.setShowLibraryContents(flag, getId());
}
 
Example 20
Source File: VirtualFileTreeNode.java    From intellij-pants-plugin with Apache License 2.0 4 votes vote down vote up
@Override
public int getWeight() {
  final ProjectView projectView = ProjectView.getInstance(myProject);
  final boolean foldersOnTop = projectView instanceof ProjectViewImpl && !((ProjectViewImpl)projectView).isFoldersAlwaysOnTop();
  return foldersOnTop && getValue().isDirectory() ? 20 : 0; // see PsiDirectoryNode.getWeight()
}