use of com.android.tools.idea.navigator.AndroidProjectViewPane 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.android.tools.idea.navigator.AndroidProjectViewPane 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.android.tools.idea.navigator.AndroidProjectViewPane 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;
}
Aggregations