Search in sources :

Example 1 with ModuleGalleryEntry

use of com.android.tools.idea.npw.module.ModuleGalleryEntry in project android by JetBrains.

the class AndroidNewModuleAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    Project project = e.getProject();
    if (project != null) {
        // TODO: before submitting this code, change this to only use the new wizard
        if (Boolean.getBoolean("use.npw.modelwizard") && (e.getModifiers() & InputEvent.SHIFT_MASK) == 0) {
            ArrayList<ModuleGalleryEntry> moduleDescriptions = new ArrayList<>();
            for (ModuleDescriptionProvider provider : ModuleDescriptionProvider.EP_NAME.getExtensions()) {
                moduleDescriptions.addAll(provider.getDescriptions());
            }
            ChooseModuleTypeStep chooseModuleTypeStep = new ChooseModuleTypeStep(new NewModuleModel(project), moduleDescriptions);
            ModelWizard wizard = new ModelWizard.Builder().addStep(chooseModuleTypeStep).build();
            new StudioWizardDialogBuilder(wizard, message("android.wizard.module.new.module.title")).build().show();
        } else {
            NewModuleWizardDynamic dialog = new NewModuleWizardDynamic(project, null);
            dialog.init();
            dialog.show();
        }
    }
}
Also used : Project(com.intellij.openapi.project.Project) ChooseModuleTypeStep(com.android.tools.idea.npw.module.ChooseModuleTypeStep) ModuleDescriptionProvider(com.android.tools.idea.npw.module.ModuleDescriptionProvider) NewModuleModel(com.android.tools.idea.npw.module.NewModuleModel) ModuleGalleryEntry(com.android.tools.idea.npw.module.ModuleGalleryEntry) StudioWizardDialogBuilder(com.android.tools.idea.ui.wizard.StudioWizardDialogBuilder) ArrayList(java.util.ArrayList) StudioWizardDialogBuilder(com.android.tools.idea.ui.wizard.StudioWizardDialogBuilder) ModelWizard(com.android.tools.idea.wizard.model.ModelWizard)

Example 2 with ModuleGalleryEntry

use of com.android.tools.idea.npw.module.ModuleGalleryEntry in project flutter-intellij by flutter.

the class ChoseProjectTypeStep method createDependentSteps.

@NotNull
@Override
public Collection<? extends ModelWizardStep> createDependentSteps() {
    List<ModelWizardStep> allSteps = Lists.newArrayList();
    myModuleDescriptionToStepMap = new HashMap<>();
    for (ModuleGalleryEntry moduleGalleryEntry : myModuleGalleryEntryList) {
        FlutterProjectStep step = ((FlutterGalleryEntry) moduleGalleryEntry).createFlutterStep(getModel());
        allSteps.add(step);
        myModuleDescriptionToStepMap.put(moduleGalleryEntry, step);
    }
    return allSteps;
}
Also used : ModuleGalleryEntry(com.android.tools.idea.npw.module.ModuleGalleryEntry) ModelWizardStep(com.android.tools.idea.wizard.model.ModelWizardStep) FlutterGalleryEntry(io.flutter.module.FlutterDescriptionProvider.FlutterGalleryEntry) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with ModuleGalleryEntry

use of com.android.tools.idea.npw.module.ModuleGalleryEntry in project flutter-intellij by flutter.

the class ChoseProjectTypeStep method createGallery.

@NotNull
private JComponent createGallery() {
    myProjectTypeGallery = new ASGallery<ModuleGalleryEntry>(JBList.createDefaultListModel(), image -> image == null ? null : image.getIcon() == null ? null : IconUtil.toImage(image.getIcon()), label -> label == null ? message("android.wizard.gallery.item.none") : label.getName(), DEFAULT_GALLERY_THUMBNAIL_SIZE, null) {

        @Override
        public Dimension getPreferredScrollableViewportSize() {
            // The default implementation assigns a height as tall as the screen.
            // When calling setVisibleRowCount(2), the underlying implementation is buggy, and  will have a gap on the right and when the user
            // resizes, it enters on an adjustment loop at some widths (can't decide to fit 3 or for elements, and loops between the two)
            Dimension cellSize = computeCellSize();
            int heightInsets = getInsets().top + getInsets().bottom;
            int widthInsets = getInsets().left + getInsets().right;
            // Don't want to show an exact number of rows, since then it's not obvious there's another row available.
            return new Dimension(cellSize.width * 5 + widthInsets, (int) (cellSize.height * 1.2) + heightInsets);
        }
    };
    myProjectTypeGallery.setBorder(BorderFactory.createLineBorder(JBColor.border()));
    AccessibleContext accessibleContext = myProjectTypeGallery.getAccessibleContext();
    if (accessibleContext != null) {
        accessibleContext.setAccessibleDescription(getTitle());
    }
    return new JBScrollPane(myProjectTypeGallery);
}
Also used : FormScalingUtil(com.android.tools.adtui.util.FormScalingUtil) HashMap(com.intellij.util.containers.HashMap) ModelWizard(com.android.tools.idea.wizard.model.ModelWizard) ArrayList(java.util.ArrayList) Lists(com.google.common.collect.Lists) Map(java.util.Map) DEFAULT_GALLERY_THUMBNAIL_SIZE(com.android.tools.idea.wizard.WizardConstants.DEFAULT_GALLERY_THUMBNAIL_SIZE) Logger(com.intellij.openapi.diagnostic.Logger) FlutterGalleryEntry(io.flutter.module.FlutterDescriptionProvider.FlutterGalleryEntry) JBList(com.intellij.ui.components.JBList) AndroidBundle.message(org.jetbrains.android.util.AndroidBundle.message) FlutterDescriptionProvider(io.flutter.module.FlutterDescriptionProvider) Collection(java.util.Collection) AccessibleContext(javax.accessibility.AccessibleContext) ModelWizardStep(com.android.tools.idea.wizard.model.ModelWizardStep) ActionEvent(java.awt.event.ActionEvent) JBScrollPane(com.intellij.ui.components.JBScrollPane) VerticalFlowLayout(com.intellij.openapi.ui.VerticalFlowLayout) java.awt(java.awt) ASGallery(com.android.tools.adtui.ASGallery) Nullable(org.jetbrains.annotations.Nullable) ModuleGalleryEntry(com.android.tools.idea.npw.module.ModuleGalleryEntry) List(java.util.List) NotNull(org.jetbrains.annotations.NotNull) JBColor(com.intellij.ui.JBColor) IconUtil(com.intellij.util.IconUtil) javax.swing(javax.swing) AccessibleContext(javax.accessibility.AccessibleContext) ModuleGalleryEntry(com.android.tools.idea.npw.module.ModuleGalleryEntry) JBScrollPane(com.intellij.ui.components.JBScrollPane) NotNull(org.jetbrains.annotations.NotNull)

Example 4 with ModuleGalleryEntry

use of com.android.tools.idea.npw.module.ModuleGalleryEntry in project flutter-intellij by flutter.

the class ChoseProjectTypeStep method onProceeding.

@Override
protected void onProceeding() {
    // This wizard includes a step for each module, but we only visit the selected one. First, we hide all steps (in case we visited a
    // different module before and hit back), and then we activate the step we care about.
    ModuleGalleryEntry selectedEntry = myProjectTypeGallery.getSelectedElement();
    myModuleDescriptionToStepMap.forEach((galleryEntry, step) -> step.setShouldShow(galleryEntry == selectedEntry));
}
Also used : ModuleGalleryEntry(com.android.tools.idea.npw.module.ModuleGalleryEntry)

Aggregations

ModuleGalleryEntry (com.android.tools.idea.npw.module.ModuleGalleryEntry)4 ModelWizard (com.android.tools.idea.wizard.model.ModelWizard)2 ModelWizardStep (com.android.tools.idea.wizard.model.ModelWizardStep)2 FlutterGalleryEntry (io.flutter.module.FlutterDescriptionProvider.FlutterGalleryEntry)2 ArrayList (java.util.ArrayList)2 NotNull (org.jetbrains.annotations.NotNull)2 ASGallery (com.android.tools.adtui.ASGallery)1 FormScalingUtil (com.android.tools.adtui.util.FormScalingUtil)1 ChooseModuleTypeStep (com.android.tools.idea.npw.module.ChooseModuleTypeStep)1 ModuleDescriptionProvider (com.android.tools.idea.npw.module.ModuleDescriptionProvider)1 NewModuleModel (com.android.tools.idea.npw.module.NewModuleModel)1 StudioWizardDialogBuilder (com.android.tools.idea.ui.wizard.StudioWizardDialogBuilder)1 DEFAULT_GALLERY_THUMBNAIL_SIZE (com.android.tools.idea.wizard.WizardConstants.DEFAULT_GALLERY_THUMBNAIL_SIZE)1 Lists (com.google.common.collect.Lists)1 Logger (com.intellij.openapi.diagnostic.Logger)1 Project (com.intellij.openapi.project.Project)1 VerticalFlowLayout (com.intellij.openapi.ui.VerticalFlowLayout)1 JBColor (com.intellij.ui.JBColor)1 JBList (com.intellij.ui.components.JBList)1 JBScrollPane (com.intellij.ui.components.JBScrollPane)1