use of org.eclipse.swt.accessibility.Accessible in project eclipse.platform.swt by eclipse.
the class CTableItem method addColumn.
/*
* Updates internal structures in the receiver and its child items to handle the creation of a new column.
*/
void addColumn(CTableColumn column) {
int index = column.getIndex();
int columnCount = parent.columns.length;
if (columnCount > 1) {
if (columnCount == 2) {
texts = new String[2];
} else {
String[] newTexts = new String[columnCount];
System.arraycopy(texts, 0, newTexts, 0, index);
System.arraycopy(texts, index, newTexts, index + 1, columnCount - index - 1);
texts = newTexts;
}
if (index == 0) {
texts[1] = super.getText();
// $NON-NLS-1$
super.setText("");
}
if (columnCount == 2) {
images = new Image[2];
} else {
Image[] newImages = new Image[columnCount];
System.arraycopy(images, 0, newImages, 0, index);
System.arraycopy(images, index, newImages, index + 1, columnCount - index - 1);
images = newImages;
}
if (index == 0) {
images[1] = super.getImage();
super.setImage(null);
}
int[] newTextWidths = new int[columnCount];
System.arraycopy(textWidths, 0, newTextWidths, 0, index);
System.arraycopy(textWidths, index, newTextWidths, index + 1, columnCount - index - 1);
textWidths = newTextWidths;
} else {
customWidth = -1;
/* columnCount == 1 */
}
/*
* The length of displayTexts always matches the parent's column count, unless this
* count is zero, in which case displayTexts is null.
*/
String[] newDisplayTexts = new String[columnCount];
if (columnCount > 1) {
System.arraycopy(displayTexts, 0, newDisplayTexts, 0, index);
System.arraycopy(displayTexts, index, newDisplayTexts, index + 1, columnCount - index - 1);
}
displayTexts = newDisplayTexts;
if (cellBackgrounds != null) {
Color[] newCellBackgrounds = new Color[columnCount];
System.arraycopy(cellBackgrounds, 0, newCellBackgrounds, 0, index);
System.arraycopy(cellBackgrounds, index, newCellBackgrounds, index + 1, columnCount - index - 1);
cellBackgrounds = newCellBackgrounds;
}
if (cellForegrounds != null) {
Color[] newCellForegrounds = new Color[columnCount];
System.arraycopy(cellForegrounds, 0, newCellForegrounds, 0, index);
System.arraycopy(cellForegrounds, index, newCellForegrounds, index + 1, columnCount - index - 1);
cellForegrounds = newCellForegrounds;
}
if (cellFonts != null) {
Font[] newCellFonts = new Font[columnCount];
System.arraycopy(cellFonts, 0, newCellFonts, 0, index);
System.arraycopy(cellFonts, index, newCellFonts, index + 1, columnCount - index - 1);
cellFonts = newCellFonts;
int[] newFontHeights = new int[columnCount];
System.arraycopy(fontHeights, 0, newFontHeights, 0, index);
System.arraycopy(fontHeights, index, newFontHeights, index + 1, columnCount - index - 1);
fontHeights = newFontHeights;
}
if (columnCount > accessibles.length) {
Accessible[] newAccessibles = new Accessible[columnCount];
System.arraycopy(accessibles, 0, newAccessibles, 0, index);
System.arraycopy(accessibles, index, newAccessibles, index + 1, columnCount - index - 1);
accessibles = newAccessibles;
}
if (index == 0 && columnCount > 1) {
/*
* The new second column may have more width available to it than it did when it was
* the first column if checkboxes are being shown, so recompute its displayText if needed.
*/
if ((parent.getStyle() & SWT.CHECK) != 0) {
GC gc = new GC(parent);
gc.setFont(getFont(1, false));
computeDisplayText(1, gc);
gc.dispose();
}
}
}
use of org.eclipse.swt.accessibility.Accessible in project eclipse.platform.swt by eclipse.
the class AccessibleValueExample method main.
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
shell.setText("Accessible Value Example");
final Canvas canvas = new Canvas(shell, SWT.DOUBLE_BUFFERED);
canvas.addPaintListener(e -> {
Rectangle rect = canvas.getClientArea();
String val = String.valueOf(value);
Point size = e.gc.stringExtent(val);
e.gc.setBackground(e.display.getSystemColor(SWT.COLOR_LIST_SELECTION));
e.gc.fillRectangle(0, 0, rect.width * value / (max - min), rect.height);
e.gc.drawString(val, rect.x + (rect.width - size.x) / 2, rect.y + (rect.height - size.y) / 2, true);
});
Accessible accessible = canvas.getAccessible();
accessible.addAccessibleListener(new AccessibleAdapter() {
@Override
public void getName(AccessibleEvent e) {
e.result = "The value of this canvas is " + value;
}
});
accessible.addAccessibleControlListener(new AccessibleControlAdapter() {
@Override
public void getRole(AccessibleControlEvent e) {
e.detail = ACC.ROLE_PROGRESSBAR;
}
});
accessible.addAccessibleValueListener(new AccessibleValueAdapter() {
@Override
public void setCurrentValue(AccessibleValueEvent e) {
value = e.value.intValue();
canvas.redraw();
}
@Override
public void getMinimumValue(AccessibleValueEvent e) {
e.value = Integer.valueOf(min);
}
@Override
public void getMaximumValue(AccessibleValueEvent e) {
e.value = Integer.valueOf(max);
}
@Override
public void getCurrentValue(AccessibleValueEvent e) {
e.value = Integer.valueOf(value);
}
});
shell.pack();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
use of org.eclipse.swt.accessibility.Accessible in project eclipse.platform.swt by eclipse.
the class CTable method initAccessibility.
void initAccessibility() {
// TODO: does this all work if CTable is virtual?
final Accessible accessibleTable = getAccessible();
accessibleTable.addAccessibleListener(new AccessibleAdapter() {
@Override
public void getName(AccessibleEvent e) {
/* CTables take their name from the preceding Label, if any. */
Control[] siblings = getParent().getChildren();
for (int i = 0; i < siblings.length; i++) {
if (i != 0 && siblings[i] == CTable.this) {
Control control = siblings[i - 1];
if (control instanceof Label) {
e.result = ((Label) control).getText();
}
}
}
}
@Override
public void getHelp(AccessibleEvent e) {
/* A CTable's toolTip text (if any) can be used as its help text. */
e.result = getToolTipText();
}
});
accessibleTable.addAccessibleControlListener(new AccessibleControlAdapter() {
/* Child IDs are assigned as follows:
* - column header ids (if any) are numbered from 0 to columnCount - 1
* - cell ids are numbered in row-major order (starting from columnCount if there are columns)
* Accessibles are returned in getChild.
*/
@Override
public void getChild(AccessibleControlEvent e) {
int childID = e.childID;
// childID == index
if (childID == ACC.CHILDID_CHILD_AT_INDEX)
childID = e.detail;
if (columns.length > 0 && 0 <= childID && childID < columns.length) {
// header cell
CTableColumn column = columns[childID];
e.accessible = column.getAccessible(accessibleTable);
} else {
// item cell
int columnCount = columns.length > 0 ? columns.length : 1;
if (columns.length > 0)
childID -= columnCount;
if (0 <= childID && childID < itemsCount * columnCount) {
int rowIndex = childID / columnCount;
int columnIndex = childID - rowIndex * columnCount;
e.accessible = items[rowIndex].getAccessible(accessibleTable, columnIndex);
}
}
}
@Override
public void getChildAtPoint(AccessibleControlEvent e) {
Point point = toControl(e.x, e.y);
if (columns.length > 0 && point.y < getHeaderHeight()) {
// header cell
int columnIndex = computeColumnIntersect(point.x, 0);
if (columnIndex != -1) {
CTableColumn column = columns[columnIndex];
e.accessible = column.getAccessible(accessibleTable);
}
} else {
// item cell
int columnIndex = columns.length > 0 ? computeColumnIntersect(point.x, 0) : 0;
if (columnIndex != -1) {
int rowIndex = (point.y - getHeaderHeight()) / itemHeight + topIndex;
if (0 <= rowIndex && rowIndex < itemsCount) {
if (items[rowIndex].getHitBounds().contains(point)) {
/* considers the x value */
e.accessible = items[rowIndex].getAccessible(accessibleTable, columnIndex);
}
}
}
}
}
@Override
public void getChildCount(AccessibleControlEvent e) {
e.detail = columns.length > 0 ? columns.length + itemsCount * columns.length : itemsCount;
}
@Override
public void getChildren(AccessibleControlEvent e) {
int childIdCount = columns.length > 0 ? columns.length + itemsCount * columns.length : itemsCount;
Object[] children = new Object[childIdCount];
for (int i = 0; i < childIdCount; i++) {
children[i] = Integer.valueOf(i);
}
e.children = children;
}
@Override
public void getFocus(AccessibleControlEvent e) {
e.childID = isFocusControl() ? ACC.CHILDID_SELF : ACC.CHILDID_NONE;
}
@Override
public void getLocation(AccessibleControlEvent e) {
Rectangle location = null;
Point pt = null;
int childID = e.childID;
if (childID == ACC.CHILDID_SELF) {
// table
location = getBounds();
pt = getParent().toDisplay(location.x, location.y);
} else if (columns.length > 0 && 0 <= childID && childID < columns.length) {
// header cell
CTableColumn column = columns[childID];
location = new Rectangle(column.getX(), 0, column.getWidth(), getHeaderHeight());
pt = toDisplay(location.x, location.y);
} else {
// item cell
int columnCount = columns.length > 0 ? columns.length : 1;
if (columns.length > 0)
childID -= columnCount;
if (0 <= childID && childID < itemsCount * columnCount) {
int rowIndex = childID / columnCount;
int columnIndex = childID - rowIndex * columnCount;
location = items[rowIndex].getBounds(columnIndex);
pt = toDisplay(location.x, location.y);
}
}
if (location != null && pt != null) {
e.x = pt.x;
e.y = pt.y;
e.width = location.width;
e.height = location.height;
}
}
@Override
public void getRole(AccessibleControlEvent e) {
e.detail = e.childID == ACC.CHILDID_SELF ? ACC.ROLE_TABLE : ACC.ROLE_TABLECELL;
}
@Override
public void getSelection(AccessibleControlEvent e) {
int columnCount = columns.length > 0 ? columns.length : 1;
int[] selectionIndices = getSelectionIndices();
Object[] selectedChildren = new Object[selectionIndices.length * columnCount];
for (int i = 0; i < selectionIndices.length; i++) {
int row = selectionIndices[i];
for (int col = 0; col < columnCount; col++) {
selectedChildren[i] = Integer.valueOf(row * columnCount + col);
}
}
e.children = selectedChildren;
}
@Override
public void getState(AccessibleControlEvent e) {
int state = ACC.STATE_NORMAL;
int childID = e.childID;
if (childID == ACC.CHILDID_SELF) {
// table
state |= ACC.STATE_FOCUSABLE;
if (isFocusControl()) {
state |= ACC.STATE_FOCUSED;
}
} else if (columns.length > 0 && 0 <= childID && childID < columns.length) {
// header cell
/* CTable does not support header cell focus or selection. */
state |= ACC.STATE_SIZEABLE;
} else {
// item cell
int columnCount = columns.length > 0 ? columns.length : 1;
if (columns.length > 0)
childID -= columnCount;
if (0 <= childID && childID < itemsCount * columnCount) {
/* CTable does not support cell selection (only row selection). */
int rowIndex = childID / columnCount;
state |= ACC.STATE_SELECTABLE;
if (isFocusControl()) {
state |= ACC.STATE_FOCUSABLE;
}
if (items[rowIndex].isSelected()) {
state |= ACC.STATE_SELECTED;
if (isFocusControl()) {
state |= ACC.STATE_FOCUSED;
}
}
}
}
e.detail = state;
}
});
accessibleTable.addAccessibleTableListener(new AccessibleTableAdapter() {
@Override
public void deselectColumn(AccessibleTableEvent e) {
/* CTable does not support column selection. */
}
@Override
public void deselectRow(AccessibleTableEvent e) {
deselect(e.row);
e.result = ACC.OK;
}
@Override
public void getCaption(AccessibleTableEvent e) {
// TODO: What is a caption? How does it differ from name? Should app supply?
e.result = "This is the Custom Table's Test Caption";
}
@Override
public void getCell(AccessibleTableEvent e) {
int index = e.row;
if (0 <= index && index < itemsCount) {
CTableItem row = items[index];
index = e.column;
if (columns.length == 0 || 0 <= index && index < columns.length) {
e.accessible = row.getAccessible(accessibleTable, index);
}
}
}
@Override
public void getColumnCount(AccessibleTableEvent e) {
int columnCount = columns.length > 0 ? columns.length : 1;
e.count = columnCount;
}
@Override
public void getColumnDescription(AccessibleTableEvent e) {
// TODO: What is a description? How does it differ from name? Should app supply?
e.result = "This is the Custom Table's Test Description for column " + e.column;
}
// public void getColumnHeader(AccessibleTableEvent e) {
// e.accessible = header.getAccessible();
// }
@Override
public void getColumnHeaderCells(AccessibleTableEvent e) {
if (columns.length == 0) {
/* The CTable is being used as a list, and there are no headers. */
e.accessibles = null;
} else {
Accessible[] accessibles = new Accessible[columns.length];
for (int i = 0; i < columns.length; i++) {
CTableColumn column = columns[i];
accessibles[i] = column.getAccessible(accessibleTable);
}
e.accessibles = accessibles;
}
}
@Override
public void getRowCount(AccessibleTableEvent e) {
e.count = itemsCount;
}
@Override
public void getRowDescription(AccessibleTableEvent e) {
// TODO: What is a description? How does it differ from name? Should app supply?
e.result = "This is the Custom Table's Test Description for row " + e.row;
}
@Override
public void getRowHeader(AccessibleTableEvent e) {
/* CTable does not support row headers. */
}
@Override
public void getSelectedCellCount(AccessibleTableEvent e) {
int columnCount = columns.length > 0 ? columns.length : 1;
e.count = selectedItems.length * columnCount;
}
@Override
public void getSelectedCells(AccessibleTableEvent e) {
int columnCount = columns.length > 0 ? columns.length : 1;
Accessible[] accessibles = new Accessible[selectedItems.length * columnCount];
for (int r = 0; r < selectedItems.length; r++) {
CTableItem row = selectedItems[r];
for (int c = 0; c < columnCount; c++) accessibles[r + c] = row.getAccessible(accessibleTable, c);
}
e.accessibles = accessibles;
}
@Override
public void getSelectedColumnCount(AccessibleTableEvent e) {
e.count = 0;
/* CTable does not support column selection. */
}
@Override
public void getSelectedColumns(AccessibleTableEvent e) {
/* CTable does not support column selection. */
}
@Override
public void getSelectedRowCount(AccessibleTableEvent e) {
e.count = selectedItems.length;
}
@Override
public void getSelectedRows(AccessibleTableEvent e) {
int[] selectedIndices = new int[selectedItems.length];
for (int i = 0; i < selectedItems.length; i++) {
selectedIndices[i] = selectedItems[i].index;
}
e.selected = selectedIndices;
}
@Override
public void getSummary(AccessibleTableEvent e) {
// TODO: What is a summary? How does it differ from name? Should app supply?
e.result = "This is the Custom Table's Summary";
}
@Override
public void isColumnSelected(AccessibleTableEvent e) {
e.isSelected = false;
/* CTable does not support column selection. */
}
@Override
public void isRowSelected(AccessibleTableEvent e) {
e.isSelected = isSelected(e.row);
}
@Override
public void selectColumn(AccessibleTableEvent e) {
/* CTable does not support column selection. */
}
@Override
public void selectRow(AccessibleTableEvent e) {
select(e.row);
e.result = ACC.OK;
}
@Override
public void setSelectedColumn(AccessibleTableEvent e) {
/* CTable does not support column selection. */
}
@Override
public void setSelectedRow(AccessibleTableEvent e) {
setSelection(e.row);
e.result = ACC.OK;
}
});
}
use of org.eclipse.swt.accessibility.Accessible in project eclipse.platform.swt by eclipse.
the class Test_org_eclipse_swt_widgets_Control method test_getAccessible.
@Test
public void test_getAccessible() {
Accessible accessible = control.getAccessible();
assertNotNull(":a:", accessible);
}
use of org.eclipse.swt.accessibility.Accessible in project tdq-studio-se by Talend.
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()));
}
}
});
}
Aggregations