Search in sources :

Example 1 with AccessibleContext

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;
}
Also used : Optional(java.util.Optional) AccessibleContext(javax.accessibility.AccessibleContext) ActionEvent(java.awt.event.ActionEvent) ListSelectionEvent(javax.swing.event.ListSelectionEvent) ListSelectionListener(javax.swing.event.ListSelectionListener) DynamicWizard(com.android.tools.idea.wizard.dynamic.DynamicWizard) JBCardLayout(com.intellij.ui.JBCardLayout) JBScrollPane(com.intellij.ui.components.JBScrollPane)

Example 2 with AccessibleContext

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);
}
Also used : JBList(com.intellij.ui.components.JBList) AndroidBundle.message(org.jetbrains.android.util.AndroidBundle.message) FormScalingUtil(com.android.tools.swing.util.FormScalingUtil) java.util(java.util) ATTR_INCLUDE_FORM_FACTOR(com.android.tools.idea.templates.TemplateMetadata.ATTR_INCLUDE_FORM_FACTOR) FormFactor(com.android.tools.idea.npw.FormFactor) StringUtil(com.intellij.openapi.util.text.StringUtil) HashMap(com.intellij.util.containers.HashMap) ModelWizard(com.android.tools.idea.wizard.model.ModelWizard) AccessibleContext(javax.accessibility.AccessibleContext) ModelWizardStep(com.android.tools.idea.wizard.model.ModelWizardStep) ActionEvent(java.awt.event.ActionEvent) ASGallery(com.android.tools.idea.ui.ASGallery) JBScrollPane(com.intellij.ui.components.JBScrollPane) SkippableWizardStep(com.android.tools.idea.wizard.model.SkippableWizardStep) java.awt(java.awt) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) Lists(com.google.common.collect.Lists) DEFAULT_GALLERY_THUMBNAIL_SIZE(com.android.tools.idea.wizard.WizardConstants.DEFAULT_GALLERY_THUMBNAIL_SIZE) NotNull(org.jetbrains.annotations.NotNull) JBColor(com.intellij.ui.JBColor) IconUtil(com.intellij.util.IconUtil) javax.swing(javax.swing) AccessibleContext(javax.accessibility.AccessibleContext) JBScrollPane(com.intellij.ui.components.JBScrollPane) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with AccessibleContext

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;
    }
}
Also used : AccessibleContext(javax.accessibility.AccessibleContext)

Example 4 with AccessibleContext

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;
}
Also used : AccessibleContext(javax.accessibility.AccessibleContext) ModuleTemplate(com.android.tools.idea.npw.ModuleTemplate) ActionEvent(java.awt.event.ActionEvent) Function(com.google.common.base.Function) DynamicWizard(com.android.tools.idea.wizard.dynamic.DynamicWizard) JBCardLayout(com.intellij.ui.JBCardLayout) Nullable(org.jetbrains.annotations.Nullable) JBScrollPane(com.intellij.ui.components.JBScrollPane)

Example 5 with AccessibleContext

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());
    }
}
Also used : AccessibleContext(javax.accessibility.AccessibleContext) JProgressBar(javax.swing.JProgressBar) JSlider(javax.swing.JSlider) Accessible(javax.accessibility.Accessible)

Aggregations

AccessibleContext (javax.accessibility.AccessibleContext)8 JBScrollPane (com.intellij.ui.components.JBScrollPane)3 ActionEvent (java.awt.event.ActionEvent)3 DynamicWizard (com.android.tools.idea.wizard.dynamic.DynamicWizard)2 JBCardLayout (com.intellij.ui.JBCardLayout)2 Accessible (javax.accessibility.Accessible)2 Nullable (org.jetbrains.annotations.Nullable)2 FormFactor (com.android.tools.idea.npw.FormFactor)1 ModuleTemplate (com.android.tools.idea.npw.ModuleTemplate)1 ATTR_INCLUDE_FORM_FACTOR (com.android.tools.idea.templates.TemplateMetadata.ATTR_INCLUDE_FORM_FACTOR)1 ASGallery (com.android.tools.idea.ui.ASGallery)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 SkippableWizardStep (com.android.tools.idea.wizard.model.SkippableWizardStep)1 FormScalingUtil (com.android.tools.swing.util.FormScalingUtil)1 Function (com.google.common.base.Function)1 Lists (com.google.common.collect.Lists)1 StringUtil (com.intellij.openapi.util.text.StringUtil)1 JBColor (com.intellij.ui.JBColor)1