Search in sources :

Example 1 with ASGallery

use of com.android.tools.adtui.ASGallery 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)

Aggregations

ASGallery (com.android.tools.adtui.ASGallery)1 FormScalingUtil (com.android.tools.adtui.util.FormScalingUtil)1 ModuleGalleryEntry (com.android.tools.idea.npw.module.ModuleGalleryEntry)1 DEFAULT_GALLERY_THUMBNAIL_SIZE (com.android.tools.idea.wizard.WizardConstants.DEFAULT_GALLERY_THUMBNAIL_SIZE)1 ModelWizard (com.android.tools.idea.wizard.model.ModelWizard)1 ModelWizardStep (com.android.tools.idea.wizard.model.ModelWizardStep)1 Lists (com.google.common.collect.Lists)1 Logger (com.intellij.openapi.diagnostic.Logger)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 IconUtil (com.intellij.util.IconUtil)1 HashMap (com.intellij.util.containers.HashMap)1 FlutterDescriptionProvider (io.flutter.module.FlutterDescriptionProvider)1 FlutterGalleryEntry (io.flutter.module.FlutterDescriptionProvider.FlutterGalleryEntry)1 java.awt (java.awt)1 ActionEvent (java.awt.event.ActionEvent)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1