Search in sources :

Example 21 with AccessibleEvent

use of org.eclipse.swt.accessibility.AccessibleEvent in project webtools.sourceediting by eclipse.

the class XMLSyntaxColoringPage method setAccessible.

/**
 * Specifically set the reporting name of a control for accessibility
 */
private void setAccessible(Control control, String name) {
    if (control == null)
        return;
    final String n = name;
    control.getAccessible().addAccessibleListener(new AccessibleAdapter() {

        public void getName(AccessibleEvent e) {
            if (e.childID == ACC.CHILDID_SELF)
                e.result = n;
        }
    });
}
Also used : AccessibleAdapter(org.eclipse.swt.accessibility.AccessibleAdapter) AccessibleEvent(org.eclipse.swt.accessibility.AccessibleEvent)

Example 22 with AccessibleEvent

use of org.eclipse.swt.accessibility.AccessibleEvent in project webtools.sourceediting by eclipse.

the class FlatCCombo method initAccessible.

void initAccessible() {
    AccessibleAdapter accessibleAdapter = new AccessibleAdapter() {

        public void getName(AccessibleEvent e) {
            String name = null;
            Label label = getAssociatedLabel();
            if (label != null) {
                name = stripMnemonic(label.getText());
            }
            e.result = name;
        }

        public void getKeyboardShortcut(AccessibleEvent e) {
            String shortcut = null;
            Label label = getAssociatedLabel();
            if (label != null) {
                String text = label.getText();
                if (text != null) {
                    char mnemonic = _findMnemonic(text);
                    if (mnemonic != '\0') {
                        // $NON-NLS-1$
                        shortcut = "Alt+" + mnemonic;
                    }
                }
            }
            e.result = shortcut;
        }

        public void getHelp(AccessibleEvent e) {
            e.result = getToolTipText();
        }
    };
    getAccessible().addAccessibleListener(accessibleAdapter);
    text.getAccessible().addAccessibleListener(accessibleAdapter);
    list.getAccessible().addAccessibleListener(accessibleAdapter);
    arrow.getAccessible().addAccessibleListener(new AccessibleAdapter() {

        public void getName(AccessibleEvent e) {
            // $NON-NLS-1$ //$NON-NLS-2$
            e.result = isDropped() ? SWT.getMessage("SWT_Close") : SWT.getMessage("SWT_Open");
        }

        public void getKeyboardShortcut(AccessibleEvent e) {
            // $NON-NLS-1$
            e.result = "Alt+Down Arrow";
        }

        public void getHelp(AccessibleEvent e) {
            e.result = getToolTipText();
        }
    });
    getAccessible().addAccessibleTextListener(new AccessibleTextAdapter() {

        public void getCaretOffset(AccessibleTextEvent e) {
            e.offset = text.getCaretPosition();
        }

        public void getSelectionRange(AccessibleTextEvent e) {
            Point sel = text.getSelection();
            e.offset = sel.x;
            e.length = sel.y - sel.x;
        }
    });
    getAccessible().addAccessibleControlListener(new AccessibleControlAdapter() {

        public void getChildAtPoint(AccessibleControlEvent e) {
            Point testPoint = toControl(e.x, e.y);
            if (getBounds().contains(testPoint)) {
                e.childID = ACC.CHILDID_SELF;
            }
        }

        public void getLocation(AccessibleControlEvent e) {
            Rectangle location = getBounds();
            Point pt = toDisplay(location.x, location.y);
            e.x = pt.x;
            e.y = pt.y;
            e.width = location.width;
            e.height = location.height;
        }

        public void getChildCount(AccessibleControlEvent e) {
            e.detail = 0;
        }

        public void getRole(AccessibleControlEvent e) {
            e.detail = ACC.ROLE_COMBOBOX;
        }

        public void getState(AccessibleControlEvent e) {
            e.detail = ACC.STATE_NORMAL;
        }

        public void getValue(AccessibleControlEvent e) {
            e.result = getText();
        }
    });
    text.getAccessible().addAccessibleControlListener(new AccessibleControlAdapter() {

        public void getRole(AccessibleControlEvent e) {
            e.detail = text.getEditable() ? ACC.ROLE_TEXT : ACC.ROLE_LABEL;
        }
    });
    arrow.getAccessible().addAccessibleControlListener(new AccessibleControlAdapter() {

        public void getDefaultAction(AccessibleControlEvent e) {
            // $NON-NLS-1$ //$NON-NLS-2$
            e.result = isDropped() ? SWT.getMessage("SWT_Close") : SWT.getMessage("SWT_Open");
        }
    });
}
Also used : AccessibleTextAdapter(org.eclipse.swt.accessibility.AccessibleTextAdapter) AccessibleControlEvent(org.eclipse.swt.accessibility.AccessibleControlEvent) AccessibleControlAdapter(org.eclipse.swt.accessibility.AccessibleControlAdapter) Label(org.eclipse.swt.widgets.Label) Rectangle(org.eclipse.swt.graphics.Rectangle) AccessibleAdapter(org.eclipse.swt.accessibility.AccessibleAdapter) AccessibleTextEvent(org.eclipse.swt.accessibility.AccessibleTextEvent) Point(org.eclipse.swt.graphics.Point) AccessibleEvent(org.eclipse.swt.accessibility.AccessibleEvent)

Example 23 with AccessibleEvent

use of org.eclipse.swt.accessibility.AccessibleEvent in project netxms by netxms.

the class ImageCombo method initAccessible.

void initAccessible() {
    AccessibleAdapter accessibleAdapter = new AccessibleAdapter() {

        public void getName(AccessibleEvent e) {
            String name = null;
            Label label = getAssociatedLabel();
            if (label != null) {
                name = stripMnemonic(label.getText());
            }
            e.result = name;
        }

        public void getKeyboardShortcut(AccessibleEvent e) {
            String shortcut = null;
            Label label = getAssociatedLabel();
            if (label != null) {
                String text = label.getText();
                if (text != null) {
                    char mnemonic = getMnemonic(text);
                    if (mnemonic != '\0') {
                        // $NON-NLS-1$
                        shortcut = "Alt+" + mnemonic;
                    }
                }
            }
            e.result = shortcut;
        }

        public void getHelp(AccessibleEvent e) {
            e.result = getToolTipText();
        }
    };
    getAccessible().addAccessibleListener(accessibleAdapter);
    this.comboComposite.getAccessible().addAccessibleListener(accessibleAdapter);
    this.table.getAccessible().addAccessibleListener(accessibleAdapter);
    this.arrow.getAccessible().addAccessibleListener(new AccessibleAdapter() {

        public void getName(AccessibleEvent e) {
            // $NON-NLS-1$ //$NON-NLS-2$
            e.result = isDropped() ? SWT.getMessage("SWT_Close") : SWT.getMessage("SWT_Open");
        }

        public void getKeyboardShortcut(AccessibleEvent e) {
            // $NON-NLS-1$
            e.result = "Alt+Down Arrow";
        }

        public void getHelp(AccessibleEvent e) {
            e.result = getToolTipText();
        }
    });
    getAccessible().addAccessibleTextListener(new AccessibleTextAdapter() {

        public void getCaretOffset(AccessibleTextEvent e) {
            e.offset = ImageCombo.this.text.getCaretPosition();
        }
    });
    getAccessible().addAccessibleControlListener(new AccessibleControlAdapter() {

        public void getChildAtPoint(AccessibleControlEvent e) {
            Point testPoint = toControl(e.x, e.y);
            if (getBounds().contains(testPoint)) {
                e.childID = ACC.CHILDID_SELF;
            }
        }

        public void getLocation(AccessibleControlEvent e) {
            Rectangle location = getBounds();
            Point pt = toDisplay(location.x, location.y);
            e.x = pt.x;
            e.y = pt.y;
            e.width = location.width;
            e.height = location.height;
        }

        public void getChildCount(AccessibleControlEvent e) {
            e.detail = 0;
        }

        public void getRole(AccessibleControlEvent e) {
            e.detail = ACC.ROLE_COMBOBOX;
        }

        public void getState(AccessibleControlEvent e) {
            e.detail = ACC.STATE_NORMAL;
        }

        public void getValue(AccessibleControlEvent e) {
            e.result = getText();
        }
    });
    this.text.getAccessible().addAccessibleControlListener(new AccessibleControlAdapter() {

        public void getRole(AccessibleControlEvent e) {
            e.detail = ACC.ROLE_LABEL;
        }
    });
    this.arrow.getAccessible().addAccessibleControlListener(new AccessibleControlAdapter() {

        public void getDefaultAction(AccessibleControlEvent e) {
            // $NON-NLS-1$ //$NON-NLS-2$
            e.result = isDropped() ? SWT.getMessage("SWT_Close") : SWT.getMessage("SWT_Open");
        }
    });
}
Also used : AccessibleTextAdapter(org.eclipse.swt.accessibility.AccessibleTextAdapter) AccessibleControlEvent(org.eclipse.swt.accessibility.AccessibleControlEvent) AccessibleControlAdapter(org.eclipse.swt.accessibility.AccessibleControlAdapter) Label(org.eclipse.swt.widgets.Label) Rectangle(org.eclipse.swt.graphics.Rectangle) AccessibleAdapter(org.eclipse.swt.accessibility.AccessibleAdapter) AccessibleTextEvent(org.eclipse.swt.accessibility.AccessibleTextEvent) Point(org.eclipse.swt.graphics.Point) AccessibleEvent(org.eclipse.swt.accessibility.AccessibleEvent)

Example 24 with AccessibleEvent

use of org.eclipse.swt.accessibility.AccessibleEvent in project tmdm-studio-se by Talend.

the class FilteredCheckboxTree method createFilterText.

/**
 * Creates the filter text and adds listeners. This method calls {@link #doCreateFilterText(Composite)} to create
 * the text control. Subclasses should override {@link #doCreateFilterText(Composite)} instead of overriding this
 * method.
 *
 * @param parent <code>Composite</code> of the filter text
 */
protected void createFilterText(Composite parent) {
    filterText = doCreateFilterText(parent);
    filterText.getAccessible().addAccessibleListener(new AccessibleAdapter() {

        /*
             * (non-Javadoc)
             *
             * @see
             * org.eclipse.swt.accessibility.AccessibleListener#getName(org.eclipse.swt.accessibility.AccessibleEvent)
             */
        @Override
        public void getName(AccessibleEvent e) {
            String filterTextString = filterText.getText();
            if (filterTextString.length() == 0) {
                e.result = initialText;
            } else {
                e.result = filterTextString;
            }
        }
    });
    filterText.addFocusListener(new FocusAdapter() {

        /*
             * (non-Javadoc)
             *
             * @see org.eclipse.swt.events.FocusListener#focusLost(org.eclipse.swt.events.FocusEvent)
             */
        @Override
        public void focusGained(FocusEvent e) {
            /*
                 * Running in an asyncExec because the selectAll() does not appear to work when using mouse to give
                 * focus to text.
                 */
            Display display = filterText.getDisplay();
            display.asyncExec(new Runnable() {

                public void run() {
                    if (!filterText.isDisposed()) {
                        if (getInitialText().equals(filterText.getText().trim())) {
                            filterText.selectAll();
                        }
                    }
                }
            });
        }
    });
    filterText.addKeyListener(new KeyAdapter() {

        /*
             * (non-Javadoc)
             *
             * @see org.eclipse.swt.events.KeyAdapter#keyReleased(org.eclipse.swt.events.KeyEvent)
             */
        @Override
        public void keyPressed(KeyEvent e) {
            // on a CR we want to transfer focus to the list
            boolean hasItems = getViewer().getTree().getItemCount() > 0;
            if (hasItems && e.keyCode == SWT.ARROW_DOWN) {
                treeViewer.getTree().setFocus();
            } else if (e.character == SWT.CR) {
                return;
            }
        }
    });
    // enter key set focus to tree
    filterText.addTraverseListener(new TraverseListener() {

        public void keyTraversed(TraverseEvent e) {
            if (e.detail == SWT.TRAVERSE_RETURN) {
                e.doit = false;
                if (getViewer().getTree().getItemCount() == 0) {
                    Display.getCurrent().beep();
                } else {
                    // if the initial filter text hasn't changed, do not try to match
                    boolean hasFocus = getViewer().getTree().setFocus();
                    boolean textChanged = !getInitialText().equals(filterText.getText().trim());
                    if (hasFocus && textChanged && filterText.getText().trim().length() > 0) {
                        TreeItem item = getFirstMatchingItem(getViewer().getTree().getItems());
                        if (item != null) {
                            getViewer().getTree().setSelection(new TreeItem[] { item });
                            ISelection sel = getViewer().getSelection();
                            getViewer().setSelection(sel, true);
                        }
                    }
                }
            }
        }
    });
    filterText.addModifyListener(new ModifyListener() {

        /*
             * (non-Javadoc)
             *
             * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
             */
        public void modifyText(ModifyEvent e) {
            textChanged();
        }
    });
    GridData gridData = new GridData(SWT.FILL, SWT.BEGINNING, true, false);
    // integrated button. We can take all of the space.
    if ((filterText.getStyle() & SWT.CANCEL) != 0) {
        gridData.horizontalSpan = 2;
    }
    filterText.setLayoutData(gridData);
}
Also used : FocusAdapter(org.eclipse.swt.events.FocusAdapter) TraverseEvent(org.eclipse.swt.events.TraverseEvent) ModifyListener(org.eclipse.swt.events.ModifyListener) TraverseListener(org.eclipse.swt.events.TraverseListener) TreeItem(org.eclipse.swt.widgets.TreeItem) KeyAdapter(org.eclipse.swt.events.KeyAdapter) AccessibleAdapter(org.eclipse.swt.accessibility.AccessibleAdapter) FocusEvent(org.eclipse.swt.events.FocusEvent) KeyEvent(org.eclipse.swt.events.KeyEvent) ModifyEvent(org.eclipse.swt.events.ModifyEvent) ISelection(org.eclipse.jface.viewers.ISelection) GridData(org.eclipse.swt.layout.GridData) AccessibleEvent(org.eclipse.swt.accessibility.AccessibleEvent) Display(org.eclipse.swt.widgets.Display)

Example 25 with AccessibleEvent

use of org.eclipse.swt.accessibility.AccessibleEvent in project translationstudio8 by heartsome.

the class Grid method initAccessible.

/**
     * Initialize accessibility.
     */
private void initAccessible() {
    final Accessible accessible = getAccessible();
    accessible.addAccessibleListener(new AccessibleAdapter() {

        public void getDescription(AccessibleEvent e) {
            int childID = e.childID;
            if (childID >= 0 && childID < items.size()) {
                String descrption = "";
                for (int i = 0; i < columns.size(); i++) {
                    if (i != 0) {
                        descrption += ((GridColumn) columns.get(i)).getText() + " : ";
                        descrption += ((GridItem) items.get(childID)).getText(i) + " ";
                    }
                }
                e.result = descrption;
            }
        }

        public void getName(AccessibleEvent e) {
            int childID = e.childID;
            if (childID >= 0 && childID < items.size()) {
                // Name of the items
                e.result = ((GridItem) items.get(childID)).getText();
            } else if (childID >= items.size() && childID < items.size() + columns.size()) {
                // Name of the column headers
                e.result = ((GridColumn) columns.get(childID - items.size())).getText();
            } else if (childID >= items.size() + columns.size() && childID < items.size() + columns.size() + columnGroups.length) {
                // Name of the column group headers
                e.result = ((GridColumnGroup) columnGroups[childID - items.size() - columns.size()]).getText();
            } else if (childID >= items.size() + columns.size() + columnGroups.length && childID < items.size() + columns.size() + columnGroups.length + columnGroups.length) {
                // Name of the toggle button for column group headers
                e.result = ACC_TOGGLE_BUTTON_NAME;
            }
        }
    });
    accessible.addAccessibleControlListener(new AccessibleControlAdapter() {

        public void getChildAtPoint(AccessibleControlEvent e) {
            Point location = toControl(e.x, e.y);
            e.childID = ACC.CHILDID_SELF;
            // Grid Items
            GridItem item = getItem(location);
            if (item != null) {
                for (int i = 0; i < getItems().length; i++) {
                    if (item.equals(getItem(i))) {
                        e.childID = i;
                        return;
                    }
                }
            } else {
                // Column Headers
                GridColumn column = overColumnHeader(location.x, location.y);
                if (column != null) {
                    for (int i = 0; i < getColumns().length; i++) {
                        if (column.equals(getColumn(i))) {
                            e.childID = getItems().length + i;
                            return;
                        }
                    }
                } else {
                    // Column Group headers
                    GridColumnGroup columnGroup = overColumnGroupHeader(location.x, location.y);
                    if (columnGroup != null) {
                        for (int i = 0; i < getColumnGroups().length; i++) {
                            if (columnGroup.equals(getColumnGroup(i))) {
                                Rectangle toggle = ((DefaultColumnGroupHeaderRenderer) columnGroup.getHeaderRenderer()).getToggleBounds();
                                if (toggle.contains(location.x, location.y)) {
                                    // Toggle button for column group
                                    // header
                                    e.childID = getItems().length + getColumns().length + getColumnGroups().length + i;
                                } else {
                                    // Column Group header
                                    e.childID = getItems().length + getColumns().length + i;
                                }
                                return;
                            }
                        }
                    }
                }
            }
        }

        public void getChildCount(AccessibleControlEvent e) {
            if (e.childID == ACC.CHILDID_SELF) {
                int length = items.size();
                if (isTree) {
                    // it is consider as children of Grid
                    for (int i = 0; i < items.size(); i++) {
                        if (((GridItem) items.get(i)).getParentItem() != null) {
                            length--;
                        }
                    }
                }
                e.detail = length;
            }
        }

        public void getChildren(AccessibleControlEvent e) {
            if (e.childID == ACC.CHILDID_SELF) {
                int length = items.size();
                if (isTree) {
                    for (int i = 0; i < items.size(); i++) {
                        if (((GridItem) items.get(i)).getParentItem() != null) {
                            length--;
                        }
                    }
                    Object[] children = new Object[length];
                    int j = 0;
                    for (int i = 0; i < items.size(); i++) {
                        if (((GridItem) items.get(i)).getParentItem() == null) {
                            children[j] = new Integer(i);
                            j++;
                        }
                    }
                    e.children = children;
                } else {
                    Object[] children = new Object[length];
                    for (int i = 0; i < items.size(); i++) {
                        children[i] = new Integer(i);
                    }
                    e.children = children;
                }
            }
        }

        public void getDefaultAction(AccessibleControlEvent e) {
            int childID = e.childID;
            if (childID >= 0 && childID < items.size()) {
                if (getItem(childID).hasChildren()) {
                    // Action of tree items
                    if (getItem(childID).isExpanded()) {
                        e.result = ACC_ITEM_ACTION_COLLAPSE;
                    } else {
                        e.result = ACC_ITEM_ACTION_EXPAND;
                    }
                } else {
                    // action of default items
                    e.result = ACC_ITEM_DEFAULT_ACTION;
                }
            } else if (childID >= items.size() && childID < items.size() + columns.size() + columnGroups.length) {
                // action of column and column group header
                e.result = ACC_COLUMN_DEFAULT_ACTION;
            } else if (childID >= items.size() + columns.size() + columnGroups.length && childID < items.size() + columns.size() + columnGroups.length + columnGroups.length) {
                // action of toggle button of column group header
                e.result = SWT.getMessage("SWT_Press");
            }
        }

        public void getLocation(AccessibleControlEvent e) {
            // location of parent
            Rectangle location = getBounds();
            location.x = 0;
            location.y = 0;
            int childID = e.childID;
            if (childID >= 0 && childID < items.size()) {
                // location of items
                GridItem item = getItem(childID);
                if (item != null) {
                    Point p = getOrigin((GridColumn) columns.get(0), item);
                    location.y = p.y;
                    location.height = item.getHeight();
                }
            } else if (childID >= items.size() && childID < items.size() + columns.size()) {
                // location of columns headers
                GridColumn column = getColumn(childID - items.size());
                if (column != null) {
                    location.x = getColumnHeaderXPosition(column);
                    if (column.getColumnGroup() == null) {
                        location.y = 0;
                    } else {
                        location.y = groupHeaderHeight;
                    }
                    location.height = headerHeight;
                    location.width = column.getWidth();
                }
            } else if (childID >= items.size() + columns.size() && childID < items.size() + columns.size() + columnGroups.length) {
                // location of column group header
                GridColumnGroup columnGroup = getColumnGroup(childID - items.size() - columns.size());
                if (columnGroup != null) {
                    location.y = 0;
                    location.height = groupHeaderHeight;
                    location.x = getColumnHeaderXPosition(columnGroup.getFirstVisibleColumn());
                    int width = 0;
                    for (int i = 0; i < columnGroup.getColumns().length; i++) {
                        if (columnGroup.getColumns()[i].isVisible()) {
                            width += columnGroup.getColumns()[i].getWidth();
                        }
                    }
                    location.width = width;
                }
            } else if (childID >= items.size() + columns.size() + columnGroups.length && childID < items.size() + columns.size() + columnGroups.length + columnGroups.length) {
                // location of toggle button of column group header
                GridColumnGroup columnGroup = getColumnGroup(childID - items.size() - columns.size() - columnGroups.length);
                location = ((DefaultColumnGroupHeaderRenderer) columnGroup.getHeaderRenderer()).getToggleBounds();
            }
            if (location != null) {
                Point pt = toDisplay(location.x, location.y);
                e.x = pt.x;
                e.y = pt.y;
                e.width = location.width;
                e.height = location.height;
            }
        }

        public void getRole(AccessibleControlEvent e) {
            int childID = e.childID;
            if (childID >= 0 && childID < items.size()) {
                // role of items
                if (isTree) {
                    e.detail = ACC.ROLE_TREEITEM;
                } else {
                    e.detail = ACC.ROLE_LISTITEM;
                }
            } else if (childID >= items.size() && childID < items.size() + columns.size() + columnGroups.length) {
                // role of columns headers and column group headers
                e.detail = ACC.ROLE_TABLECOLUMNHEADER;
            } else if (childID >= items.size() + columns.size() + columnGroups.length && childID < items.size() + columns.size() + columnGroups.length + columnGroups.length) {
                // role of toggle button of column group headers
                e.detail = ACC.ROLE_PUSHBUTTON;
            } else if (childID == ACC.CHILDID_SELF) {
                // role of parent
                if (isTree) {
                    e.detail = ACC.ROLE_TREE;
                } else {
                    e.detail = ACC.ROLE_TABLE;
                }
            }
        }

        public void getSelection(AccessibleControlEvent e) {
            e.childID = ACC.CHILDID_NONE;
            if (selectedItems.size() == 1) {
                // Single selection
                e.childID = indexOf(((GridItem) selectedItems.get(0)));
            } else if (selectedItems.size() > 1) {
                // multiple selection
                e.childID = ACC.CHILDID_MULTIPLE;
                int length = selectedItems.size();
                Object[] children = new Object[length];
                for (int i = 0; i < length; i++) {
                    GridItem item = (GridItem) selectedItems.get(i);
                    children[i] = new Integer(indexOf(item));
                }
                e.children = children;
            }
        }

        public void getState(AccessibleControlEvent e) {
            int childID = e.childID;
            if (childID >= 0 && childID < items.size()) {
                // state of items
                e.detail = ACC.STATE_SELECTABLE;
                if (getDisplay().getActiveShell() == getParent().getShell()) {
                    e.detail |= ACC.STATE_FOCUSABLE;
                }
                if (selectedItems.contains(getItem(childID))) {
                    e.detail |= ACC.STATE_SELECTED;
                    if (getDisplay().getActiveShell() == getParent().getShell()) {
                        e.detail |= ACC.STATE_FOCUSED;
                    }
                }
                if (getItem(childID).getChecked()) {
                    e.detail |= ACC.STATE_CHECKED;
                }
                // only for tree type items
                if (getItem(childID).hasChildren()) {
                    if (getItem(childID).isExpanded()) {
                        e.detail |= ACC.STATE_EXPANDED;
                    } else {
                        e.detail |= ACC.STATE_COLLAPSED;
                    }
                }
                if (!getItem(childID).isVisible()) {
                    e.detail |= ACC.STATE_INVISIBLE;
                }
            } else if (childID >= items.size() && childID < items.size() + columns.size() + columnGroups.length) {
                // state of column headers and column group headers
                e.detail = ACC.STATE_READONLY;
            } else if (childID >= items.size() + columns.size() + columnGroups.length && childID < items.size() + columns.size() + columnGroups.length + columnGroups.length) {
                // state of toggle button of column group headers
                if (getColumnGroup(childID - items.size() - columns.size() - columnGroups.length).getExpanded()) {
                    e.detail = ACC.STATE_EXPANDED;
                } else {
                    e.detail = ACC.STATE_COLLAPSED;
                }
            }
        }

        public void getValue(AccessibleControlEvent e) {
            int childID = e.childID;
            if (childID >= 0 && childID < items.size()) {
                // value for tree items
                if (isTree) {
                    e.result = "" + getItem(childID).getLevel();
                }
            }
        }
    });
    addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event event) {
            if (selectedItems.size() > 0) {
                accessible.setFocus(items.indexOf(selectedItems.get(selectedItems.size() - 1)));
            }
        }
    });
    addTreeListener(new TreeListener() {

        public void treeCollapsed(TreeEvent e) {
            if (getFocusItem() != null) {
                accessible.setFocus(items.indexOf(getFocusItem()));
            }
        }

        public void treeExpanded(TreeEvent e) {
            if (getFocusItem() != null) {
                accessible.setFocus(items.indexOf(getFocusItem()));
            }
        }
    });
}
Also used : TreeListener(org.eclipse.swt.events.TreeListener) MouseMoveListener(org.eclipse.swt.events.MouseMoveListener) TraverseListener(org.eclipse.swt.events.TraverseListener) MouseListener(org.eclipse.swt.events.MouseListener) MouseTrackListener(org.eclipse.swt.events.MouseTrackListener) SelectionListener(org.eclipse.swt.events.SelectionListener) PaintListener(org.eclipse.swt.events.PaintListener) FocusListener(org.eclipse.swt.events.FocusListener) TypedListener(org.eclipse.swt.widgets.TypedListener) Listener(org.eclipse.swt.widgets.Listener) DropTargetListener(org.eclipse.swt.dnd.DropTargetListener) TreeListener(org.eclipse.swt.events.TreeListener) AccessibleControlEvent(org.eclipse.swt.accessibility.AccessibleControlEvent) AccessibleControlAdapter(org.eclipse.swt.accessibility.AccessibleControlAdapter) Rectangle(org.eclipse.swt.graphics.Rectangle) AccessibleAdapter(org.eclipse.swt.accessibility.AccessibleAdapter) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point) TreeEvent(org.eclipse.swt.events.TreeEvent) FocusEvent(org.eclipse.swt.events.FocusEvent) DropTargetEvent(org.eclipse.swt.dnd.DropTargetEvent) PaintEvent(org.eclipse.swt.events.PaintEvent) TraverseEvent(org.eclipse.swt.events.TraverseEvent) MouseEvent(org.eclipse.swt.events.MouseEvent) AccessibleEvent(org.eclipse.swt.accessibility.AccessibleEvent) Event(org.eclipse.swt.widgets.Event) AccessibleControlEvent(org.eclipse.swt.accessibility.AccessibleControlEvent) TreeEvent(org.eclipse.swt.events.TreeEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) AccessibleEvent(org.eclipse.swt.accessibility.AccessibleEvent) Accessible(org.eclipse.swt.accessibility.Accessible)

Aggregations

AccessibleEvent (org.eclipse.swt.accessibility.AccessibleEvent)45 AccessibleAdapter (org.eclipse.swt.accessibility.AccessibleAdapter)42 Button (org.eclipse.swt.widgets.Button)17 Label (org.eclipse.swt.widgets.Label)17 Point (org.eclipse.swt.graphics.Point)16 AccessibleControlAdapter (org.eclipse.swt.accessibility.AccessibleControlAdapter)15 AccessibleControlEvent (org.eclipse.swt.accessibility.AccessibleControlEvent)15 SelectionEvent (org.eclipse.swt.events.SelectionEvent)15 Rectangle (org.eclipse.swt.graphics.Rectangle)15 Composite (org.eclipse.swt.widgets.Composite)15 GridData (org.eclipse.swt.layout.GridData)14 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)11 Accessible (org.eclipse.swt.accessibility.Accessible)8 KeyAdapter (org.eclipse.swt.events.KeyAdapter)8 KeyEvent (org.eclipse.swt.events.KeyEvent)8 GridLayout (org.eclipse.swt.layout.GridLayout)8 Link (org.eclipse.swt.widgets.Link)8 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)7 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)7 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)7