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);
}
Aggregations