use of javax.accessibility.AccessibleContext in project android by JetBrains.
the class ActivityGalleryStep method createGallery.
private JComponent createGallery() {
myGallery = new ASGallery<>();
Dimension thumbnailSize = DEFAULT_GALLERY_THUMBNAIL_SIZE;
myGallery.setThumbnailSize(thumbnailSize);
myGallery.setMinimumSize(new Dimension(thumbnailSize.width * 2 + 1, thumbnailSize.height));
myGallery.setLabelProvider(new Function<Optional<TemplateEntry>, String>() {
@Override
public String apply(Optional<TemplateEntry> template) {
if (template.isPresent()) {
return template.get().getTitle();
} else {
return "Add No Activity";
}
}
});
myGallery.setDefaultAction(new AbstractAction() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
DynamicWizard wizard = getWizard();
assert wizard != null;
wizard.doNextAction();
}
});
myGallery.setImageProvider(new Function<Optional<TemplateEntry>, Image>() {
@Override
public Image apply(Optional<TemplateEntry> input) {
return input.isPresent() ? input.get().getImage() : null;
}
});
myGallery.addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
saveState(myGallery);
}
});
myGallery.setName("Templates Gallery");
AccessibleContext accessibleContext = myGallery.getAccessibleContext();
if (accessibleContext != null) {
accessibleContext.setAccessibleDescription(getStepTitle());
}
JPanel panel = new JPanel(new JBCardLayout());
panel.add("only card", new JBScrollPane(myGallery));
return panel;
}
use of javax.accessibility.AccessibleContext in project android by JetBrains.
the class ChooseModuleTypeStep method createGallery.
@NotNull
private JComponent createGallery() {
myFormFactorGallery = new ASGallery<ModuleGalleryEntry>(JBList.createDefaultListModel(), image -> 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 implementations 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 * 2.2) + heightInsets);
}
};
myFormFactorGallery.setBorder(BorderFactory.createLineBorder(JBColor.border()));
AccessibleContext accessibleContext = myFormFactorGallery.getAccessibleContext();
if (accessibleContext != null) {
accessibleContext.setAccessibleDescription(getTitle());
}
return new JBScrollPane(myFormFactorGallery);
}
use of javax.accessibility.AccessibleContext in project jdk8u_jdk by JetBrains.
the class CAccessible method getCAccessible.
public static CAccessible getCAccessible(final Accessible a) {
if (a == null)
return null;
AccessibleContext context = a.getAccessibleContext();
try {
final CAccessible cachedCAX = (CAccessible) nativeAXResourceField.get(context);
if (cachedCAX != null)
return cachedCAX;
final CAccessible newCAX = new CAccessible(a);
nativeAXResourceField.set(context, newCAX);
return newCAX;
} catch (final Exception e) {
e.printStackTrace();
return null;
}
}
use of javax.accessibility.AccessibleContext in project android by JetBrains.
the class ChooseModuleTypeStep method createGallery.
private JPanel createGallery() {
Dimension thumbnailSize = DEFAULT_GALLERY_THUMBNAIL_SIZE;
myFormFactorGallery = new ASGallery<ModuleTemplate>(JBList.createDefaultListModel(), new Function<ModuleTemplate, Image>() {
@Override
public Image apply(ModuleTemplate input) {
return IconUtil.toImage(input.getIcon());
}
}, new Function<ModuleTemplate, String>() {
@Override
public String apply(@Nullable ModuleTemplate input) {
return input == null ? "<none>" : input.getName();
}
}, thumbnailSize, new AbstractAction() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
DynamicWizard wizard = getWizard();
assert wizard != null;
getWizard().doNextAction();
}
}) {
@Override
public Dimension getPreferredScrollableViewportSize() {
Dimension preferred = getPreferredSize();
int heightInsets = getInsets().top + getInsets().bottom;
// Don't want to show an exact number of rows, since then it's not obvious there's another row available.
return new Dimension(preferred.width, (int) (computeCellSize().height * 2.2) + heightInsets);
}
};
myFormFactorGallery.setMinimumSize(new Dimension(thumbnailSize.width * 2 + 1, thumbnailSize.height));
myFormFactorGallery.setBorder(BorderFactory.createLineBorder(JBColor.border()));
AccessibleContext accessibleContext = myFormFactorGallery.getAccessibleContext();
if (accessibleContext != null) {
accessibleContext.setAccessibleDescription(getStepTitle());
}
JPanel panel = new JPanel(new JBCardLayout());
panel.add("only card", new JBScrollPane(myFormFactorGallery));
return panel;
}
use of javax.accessibility.AccessibleContext in project jdk8u_jdk by JetBrains.
the class CAccessible method addNotificationListeners.
public void addNotificationListeners(Component c) {
if (c instanceof Accessible) {
AccessibleContext ac = ((Accessible) c).getAccessibleContext();
ac.addPropertyChangeListener(new AXChangeNotifier());
}
if (c instanceof JProgressBar) {
JProgressBar pb = (JProgressBar) c;
pb.addChangeListener(new AXProgressChangeNotifier());
} else if (c instanceof JSlider) {
JSlider slider = (JSlider) c;
slider.addChangeListener(new AXProgressChangeNotifier());
}
}
Aggregations