use of com.intellij.ide.projectView.impl.AbstractProjectViewPane in project android by JetBrains.
the class CreateTypedResourceFileAction method invokeDialog.
@NotNull
@Override
protected PsiElement[] invokeDialog(@NotNull Project project, @NotNull DataContext dataContext) {
final IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
if (view != null) {
// If you're in the Android View, we want to ask you not just the filename but also let you
// create other resource folder configurations
AbstractProjectViewPane pane = ProjectView.getInstance(project).getCurrentProjectViewPane();
if (pane instanceof AndroidProjectViewPane) {
return CreateResourceFileAction.getInstance().invokeDialog(project, dataContext);
}
final PsiDirectory directory = view.getOrChooseDirectory();
if (directory != null) {
InputValidator validator = createValidator(project, directory);
Messages.showInputDialog(project, AndroidBundle.message("new.file.dialog.text"), AndroidBundle.message("new.typed.resource.dialog.title", myResourcePresentableName), Messages.getQuestionIcon(), "", validator);
}
}
return PsiElement.EMPTY_ARRAY;
}
use of com.intellij.ide.projectView.impl.AbstractProjectViewPane in project android by JetBrains.
the class CreateMultiRootResourceFileAction method invokeDialog.
@NotNull
@Override
protected PsiElement[] invokeDialog(@NotNull Project project, @NotNull DataContext dataContext) {
final IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
if (view != null) {
// If you're in the Android View, we want to ask you not just the filename but also let you
// create other resource folder configurations
AbstractProjectViewPane pane = ProjectView.getInstance(project).getCurrentProjectViewPane();
if (pane instanceof AndroidProjectViewPane) {
return CreateResourceFileAction.getInstance().invokeDialog(project, dataContext);
}
final PsiDirectory directory = view.getOrChooseDirectory();
if (directory != null) {
InputValidator validator = createValidator(project, directory);
final AndroidFacet facet = AndroidFacet.getInstance(directory);
if (facet != null) {
final MyDialog dialog = new MyDialog(facet, validator);
dialog.show();
return PsiElement.EMPTY_ARRAY;
}
}
}
return PsiElement.EMPTY_ARRAY;
}
use of com.intellij.ide.projectView.impl.AbstractProjectViewPane in project android by JetBrains.
the class CreateResourceDialogUtils method findResourceDirectory.
@Nullable
public static PsiDirectory findResourceDirectory(@NotNull DataContext dataContext) {
// Look at the set of selected files and see if one *specific* resource directory is implied (selected, or a parent
// of all selected nodes); if so, use it; otherwise return null.
//
// In the Android Project View we don't want to do this, since there is only ever a single "res" node,
// even when you have other overlays.
// If you're in the Android View, we want to ask you not just the filename but also let you
// create other resource folder configurations
Project project = CommonDataKeys.PROJECT.getData(dataContext);
if (project != null) {
AbstractProjectViewPane pane = ProjectView.getInstance(project).getCurrentProjectViewPane();
if (pane instanceof AndroidProjectViewPane) {
return null;
}
}
VirtualFile file = CommonDataKeys.VIRTUAL_FILE.getData(dataContext);
if (file != null) {
// See if it's inside a res folder (or is equal to a resource folder)
Module module = LangDataKeys.MODULE.getData(dataContext);
if (module != null) {
LocalResourceManager manager = LocalResourceManager.getInstance(module);
if (manager != null) {
VirtualFile resFolder = getResFolderParent(manager, file);
if (resFolder != null) {
return AndroidPsiUtils.getPsiDirectorySafely(module.getProject(), resFolder);
}
}
}
}
return null;
}
use of com.intellij.ide.projectView.impl.AbstractProjectViewPane 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.impl.AbstractProjectViewPane in project android by JetBrains.
the class Projects method getModulesToBuildFromSelection.
/**
* Returns the modules to build based on the current selection in the 'Project' tool window. If the module that corresponds to the project
* is selected, all the modules in such projects are returned. If there is no selection, an empty array is returned.
*
* @param project the given project.
* @param dataContext knows the modules that are selected. If {@code null}, this method gets the {@code DataContext} from the 'Project'
* tool window directly.
* @return the modules to build based on the current selection in the 'Project' tool window.
*/
@NotNull
public static Module[] getModulesToBuildFromSelection(@NotNull Project project, @Nullable DataContext dataContext) {
if (dataContext == null) {
ProjectView projectView = ProjectView.getInstance(project);
AbstractProjectViewPane pane = projectView.getCurrentProjectViewPane();
if (pane != null) {
JComponent treeComponent = pane.getComponentToFocus();
dataContext = DataManager.getInstance().getDataContext(treeComponent);
} else {
return Module.EMPTY_ARRAY;
}
}
Module[] modules = MODULE_CONTEXT_ARRAY.getData(dataContext);
if (modules != null) {
if (modules.length == 1 && isProjectModule(modules[0])) {
return ModuleManager.getInstance(project).getModules();
}
return modules;
}
Module module = MODULE.getData(dataContext);
if (module != null) {
return isProjectModule(module) ? ModuleManager.getInstance(project).getModules() : new Module[] { module };
}
return Module.EMPTY_ARRAY;
}
Aggregations