Search in sources :

Example 1 with NewAndroidComponentDialog

use of org.jetbrains.android.actions.NewAndroidComponentDialog in project android by JetBrains.

the class LegacyNewAndroidComponentAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    final DataContext dataContext = e.getDataContext();
    final IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
    if (view == null) {
        return;
    }
    final Module module = LangDataKeys.MODULE.getData(dataContext);
    if (module == null)
        return;
    final AndroidFacet facet = AndroidFacet.getInstance(module);
    assert facet != null;
    final PsiDirectory dir = view.getOrChooseDirectory();
    if (dir == null)
        return;
    NewAndroidComponentDialog dialog = new NewAndroidComponentDialog(module, dir);
    dialog.show();
    if (dialog.getExitCode() != DialogWrapper.OK_EXIT_CODE) {
        return;
    }
    final PsiElement[] createdElements = dialog.getCreatedElements();
    for (PsiElement createdElement : createdElements) {
        view.selectElement(createdElement);
    }
}
Also used : DataContext(com.intellij.openapi.actionSystem.DataContext) NewAndroidComponentDialog(org.jetbrains.android.actions.NewAndroidComponentDialog) PsiDirectory(com.intellij.psi.PsiDirectory) IdeView(com.intellij.ide.IdeView) Module(com.intellij.openapi.module.Module) AndroidFacet(org.jetbrains.android.facet.AndroidFacet) PsiElement(com.intellij.psi.PsiElement)

Aggregations

IdeView (com.intellij.ide.IdeView)1 DataContext (com.intellij.openapi.actionSystem.DataContext)1 Module (com.intellij.openapi.module.Module)1 PsiDirectory (com.intellij.psi.PsiDirectory)1 PsiElement (com.intellij.psi.PsiElement)1 NewAndroidComponentDialog (org.jetbrains.android.actions.NewAndroidComponentDialog)1 AndroidFacet (org.jetbrains.android.facet.AndroidFacet)1