use of com.intellij.ide.projectView.ProjectView in project intellij-plugins by StepicOrg.
the class NavigationUtils method collapseNonSelected.
private static void collapseNonSelected(@NotNull PsiFileSystemItem file) {
ProjectView projectView = ProjectView.getInstance(file.getProject());
if (projectView == null) {
return;
}
AbstractProjectViewPane projectViewPane = projectView.getCurrentProjectViewPane();
if (projectViewPane == null) {
return;
}
JTree tree = projectViewPane.getTree();
Set<TreePath> paths = new HashSet<>(TreeUtil.collectExpandedPaths(tree));
DefaultMutableTreeNode root = (DefaultMutableTreeNode) tree.getModel().getRoot();
DefaultMutableTreeNode selectionNode = findNodeWithObject(root, file);
if (selectionNode != null) {
List<TreePath> toCollapse = new ArrayList<>();
TreePath selectedPath = getPathFromRoot(selectionNode);
for (TreePath treePath : paths) {
if (treePath.isDescendant(selectedPath)) {
continue;
}
TreePath currPath = treePath;
TreePath parent = treePath.getParentPath();
while (parent != null) {
if (parent.isDescendant(selectedPath)) {
toCollapse.add(currPath);
break;
}
currPath = parent;
parent = parent.getParentPath();
}
}
for (TreePath path : toCollapse) {
tree.collapsePath(path);
tree.fireTreeCollapsed(path);
}
}
}
use of com.intellij.ide.projectView.ProjectView in project intellij-community by JetBrains.
the class ContentRootDataService method importData.
@Override
public void importData(@NotNull Collection<DataNode<ContentRootData>> toImport, @Nullable ProjectData projectData, @NotNull Project project, @NotNull IdeModifiableModelsProvider modelsProvider) {
if (toImport.isEmpty()) {
return;
}
boolean isNewlyImportedProject = project.getUserData(ExternalSystemDataKeys.NEWLY_IMPORTED_PROJECT) == Boolean.TRUE;
boolean forceDirectoriesCreation = false;
DataNode<ProjectData> projectDataNode = ExternalSystemApiUtil.findParent(toImport.iterator().next(), ProjectKeys.PROJECT);
if (projectDataNode != null) {
forceDirectoriesCreation = projectDataNode.getUserData(CREATE_EMPTY_DIRECTORIES) == Boolean.TRUE;
}
Set<Module> modulesToExpand = ContainerUtil.newTroveSet();
MultiMap<DataNode<ModuleData>, DataNode<ContentRootData>> byModule = ExternalSystemApiUtil.groupBy(toImport, ModuleData.class);
for (Map.Entry<DataNode<ModuleData>, Collection<DataNode<ContentRootData>>> entry : byModule.entrySet()) {
Module module = entry.getKey().getUserData(AbstractModuleDataService.MODULE_KEY);
module = module != null ? module : modelsProvider.findIdeModule(entry.getKey().getData());
if (module == null) {
LOG.warn(String.format("Can't import content roots. Reason: target module (%s) is not found at the ide. Content roots: %s", entry.getKey(), entry.getValue()));
continue;
}
importData(modelsProvider, entry.getValue(), module, forceDirectoriesCreation);
if (forceDirectoriesCreation || (isNewlyImportedProject && projectData != null && projectData.getLinkedExternalProjectPath().equals(ExternalSystemApiUtil.getExternalProjectPath(module)))) {
modulesToExpand.add(module);
}
}
if (!modulesToExpand.isEmpty()) {
for (Module module : modulesToExpand) {
String productionModuleName = modelsProvider.getProductionModuleName(module);
if (productionModuleName == null || !modulesToExpand.contains(modelsProvider.findIdeModule(productionModuleName))) {
VirtualFile[] roots = modelsProvider.getModifiableRootModel(module).getContentRoots();
if (roots.length > 0) {
VirtualFile virtualFile = roots[0];
ExternalSystemUtil.invokeLater(project, ModalityState.NON_MODAL, () -> {
final ProjectView projectView = ProjectView.getInstance(project);
projectView.changeViewCB(ProjectViewPane.ID, null).doWhenProcessed(() -> projectView.selectCB(null, virtualFile, false));
});
}
}
}
}
}
use of com.intellij.ide.projectView.ProjectView in project intellij-community by JetBrains.
the class ProjectViewSelectInGroupTarget method canSelect.
@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;
}
use of com.intellij.ide.projectView.ProjectView in project intellij-community by JetBrains.
the class ScopeTreeViewPanel method refreshScope.
public void refreshScope(@Nullable NamedScope scope) {
FileTreeModelBuilder.clearCaches(myProject);
if (scope == null) {
//was deleted
scope = CustomScopesProviderEx.getAllScope();
}
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, myProject, holder) : packageSet.contains(PackageSetBase.getPsiFile(file, myProject), holder));
}
}, settings);
myTree.setPaintBusy(true);
myBuilder.setTree(myTree);
myTree.getEmptyText().setText("Loading...");
myActionCallback = new ActionCallback();
myTree.putClientProperty(TreeState.CALLBACK, new WeakReference<>(myActionCallback));
myTree.setModel(myBuilder.build(myProject, true, () -> {
myTree.setPaintBusy(false);
myTree.getEmptyText().setText(UIBundle.message("message.nothingToShow"));
myActionCallback.setDone();
}));
((PackageDependenciesNode) myTree.getModel().getRoot()).sortChildren();
((DefaultTreeModel) myTree.getModel()).reload();
FileTreeModelBuilder.clearCaches(myProject);
}
use of com.intellij.ide.projectView.ProjectView in project intellij-community by JetBrains.
the class ChangeProjectViewAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
Project project = e.getProject();
if (project == null) {
return;
}
ProjectView projectView = ProjectView.getInstance(project);
projectView.changeView();
}
Aggregations