Search in sources :

Example 6 with StudioWizardDialogBuilder

use of com.android.tools.idea.ui.wizard.StudioWizardDialogBuilder in project android by JetBrains.

the class AndroidAssetStudioAction method actionPerformed.

@Override
public final 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;
    }
    AndroidFacet facet = AndroidFacet.getInstance(module);
    if (facet == null) {
        return;
    }
    ModelWizard wizard = createWizard(facet);
    if (wizard != null) {
        StudioWizardDialogBuilder dialogBuilder = new StudioWizardDialogBuilder(wizard, "Asset Studio");
        dialogBuilder.setProject(facet.getModule().getProject()).setMinimumSize(getWizardSize()).setHelpUrl(getHelpUrl());
        dialogBuilder.build().show();
    }
}
Also used : DataContext(com.intellij.openapi.actionSystem.DataContext) StudioWizardDialogBuilder(com.android.tools.idea.ui.wizard.StudioWizardDialogBuilder) IdeView(com.intellij.ide.IdeView) Module(com.intellij.openapi.module.Module) AndroidFacet(org.jetbrains.android.facet.AndroidFacet) ModelWizard(com.android.tools.idea.wizard.model.ModelWizard)

Example 7 with StudioWizardDialogBuilder

use of com.android.tools.idea.ui.wizard.StudioWizardDialogBuilder in project android by JetBrains.

the class AndroidNewProjectAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    // TODO: Temporary! This will be the main code path after we completely convert over NewProjectWizardDynamic
    if (Boolean.getBoolean("use.npw.modelwizard") && (e.getModifiers() & InputEvent.SHIFT_MASK) == 0) {
        NewProjectModel model = new NewProjectModel();
        ModelWizard wizard = new ModelWizard.Builder().addStep(new ConfigureAndroidProjectStep(model)).build();
        new StudioWizardDialogBuilder(wizard, "Create New Project").build().show();
    } else {
        try {
            NewProjectWizardDynamic dialog = new NewProjectWizardDynamic(null, null);
            dialog.init();
            dialog.show();
        } catch (IllegalStateException error) {
            Logger.getInstance(AndroidNewProjectAction.class).warn("Unable to launch New Project Wizard", error);
        }
    }
}
Also used : NewProjectWizardDynamic(com.android.tools.idea.npw.NewProjectWizardDynamic) StudioWizardDialogBuilder(com.android.tools.idea.ui.wizard.StudioWizardDialogBuilder) StudioWizardDialogBuilder(com.android.tools.idea.ui.wizard.StudioWizardDialogBuilder) NewProjectModel(com.android.tools.idea.npw.project.NewProjectModel) ModelWizard(com.android.tools.idea.wizard.model.ModelWizard) ConfigureAndroidProjectStep(com.android.tools.idea.npw.project.ConfigureAndroidProjectStep)

Example 8 with StudioWizardDialogBuilder

use of com.android.tools.idea.ui.wizard.StudioWizardDialogBuilder in project android by JetBrains.

the class NewAndroidComponentAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    DataContext dataContext = e.getDataContext();
    IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
    if (view == null) {
        return;
    }
    Module module = LangDataKeys.MODULE.getData(dataContext);
    if (module == null) {
        return;
    }
    AndroidFacet facet = AndroidFacet.getInstance(module);
    if (facet == null || facet.getAndroidModel() == null) {
        return;
    }
    VirtualFile targetFile = CommonDataKeys.VIRTUAL_FILE.getData(dataContext);
    File file = TemplateManager.getInstance().getTemplateFile(myTemplateCategory, myTemplateName);
    assert targetFile != null;
    VirtualFile targetDirectory = targetFile;
    if (!targetDirectory.isDirectory()) {
        targetDirectory = targetFile.getParent();
        assert targetDirectory != null;
    }
    assert file != null;
    // e.g. "Empty Activity", "Tabbed Activity"
    String activityDescription = e.getPresentation().getText();
    List<AndroidSourceSet> sourceSets = AndroidSourceSet.getSourceSets(facet, targetDirectory);
    assert sourceSets.size() > 0;
    String initialPackageSuggestion = AndroidPackageUtils.getPackageForPath(facet, sourceSets, targetDirectory);
    Project project = module.getProject();
    RenderTemplateModel templateModel = new RenderTemplateModel(project, new TemplateHandle(file), initialPackageSuggestion, sourceSets.get(0), "New " + activityDescription);
    boolean isActivity = isActivityTemplate();
    String dialogTitle = AndroidBundle.message(isActivity ? "android.wizard.new.activity.title" : "android.wizard.new.component.title");
    String stepTitle = AndroidBundle.message(isActivity ? "android.wizard.config.activity.title" : "android.wizard.config.component.title");
    ModelWizard.Builder wizardBuilder = new ModelWizard.Builder();
    wizardBuilder.addStep(new ConfigureTemplateParametersStep(templateModel, stepTitle, sourceSets, facet));
    ModelWizardDialog dialog = new StudioWizardDialogBuilder(wizardBuilder.build(), dialogTitle).setProject(project).build();
    dialog.show();
/*
    // TODO: Implement the getCreatedElements call for the wizard
    final PsiElement[] createdElements = dialog.getCreatedElements();

    for (PsiElement createdElement : createdElements) {
      view.selectElement(createdElement);
    }
    */
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) StudioWizardDialogBuilder(com.android.tools.idea.ui.wizard.StudioWizardDialogBuilder) RenderTemplateModel(com.android.tools.idea.npw.template.RenderTemplateModel) IdeView(com.intellij.ide.IdeView) AndroidFacet(org.jetbrains.android.facet.AndroidFacet) Project(com.intellij.openapi.project.Project) StudioWizardDialogBuilder(com.android.tools.idea.ui.wizard.StudioWizardDialogBuilder) TemplateHandle(com.android.tools.idea.npw.template.TemplateHandle) ConfigureTemplateParametersStep(com.android.tools.idea.npw.template.ConfigureTemplateParametersStep) Module(com.intellij.openapi.module.Module) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) ModelWizardDialog(com.android.tools.idea.wizard.model.ModelWizardDialog) AndroidSourceSet(com.android.tools.idea.npw.project.AndroidSourceSet) ModelWizard(com.android.tools.idea.wizard.model.ModelWizard)

Aggregations

StudioWizardDialogBuilder (com.android.tools.idea.ui.wizard.StudioWizardDialogBuilder)8 ModelWizard (com.android.tools.idea.wizard.model.ModelWizard)8 Module (com.intellij.openapi.module.Module)3 Project (com.intellij.openapi.project.Project)3 AndroidFacet (org.jetbrains.android.facet.AndroidFacet)3 NewModuleModel (com.android.tools.idea.npw.module.NewModuleModel)2 AndroidSourceSet (com.android.tools.idea.npw.project.AndroidSourceSet)2 RenderTemplateModel (com.android.tools.idea.npw.template.RenderTemplateModel)2 TemplateHandle (com.android.tools.idea.npw.template.TemplateHandle)2 IdeView (com.intellij.ide.IdeView)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 File (java.io.File)2 VisibleForTesting (com.android.annotations.VisibleForTesting)1 RepositoryPackages (com.android.repository.impl.meta.RepositoryPackages)1 NewAndroidComponentAction (com.android.tools.idea.actions.NewAndroidComponentAction)1 NewAndroidActivityWizard (com.android.tools.idea.npw.NewAndroidActivityWizard)1 NewProjectWizardDynamic (com.android.tools.idea.npw.NewProjectWizardDynamic)1 ChooseModuleTypeStep (com.android.tools.idea.npw.module.ChooseModuleTypeStep)1 ModuleDescriptionProvider (com.android.tools.idea.npw.module.ModuleDescriptionProvider)1 ModuleGalleryEntry (com.android.tools.idea.npw.module.ModuleGalleryEntry)1