use of org.eclipse.swt.accessibility.AccessibleEvent in project translationstudio8 by heartsome.
the class TableCombo method initAccessible.
/**
* Add Accessbile listeners to label and table.
*/
void initAccessible() {
AccessibleAdapter accessibleAdapter = new AccessibleAdapter() {
public void getName(AccessibleEvent e) {
String name = null;
Label label = getAssociatedLabel();
if (label != null) {
name = stripMnemonic(text.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);
table.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 = getParent().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 = text.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");
}
});
}
use of org.eclipse.swt.accessibility.AccessibleEvent in project tdi-studio-se by Talend.
the class BasicNotePropertyComposite method createFontsGroup.
/**
* Create font tool bar group
*
* @param parent - parent composite
* @return - font tool bar
*/
protected Composite createFontsGroup(Composite parent) {
Composite familySize = getWidgetFactory().createComposite(parent);
GridLayout layout = new GridLayout(2, false);
layout.horizontalSpacing = 0;
layout.verticalSpacing = 0;
layout.marginHeight = 0;
layout.marginWidth = 0;
familySize.setLayout(layout);
fontFamilyCombo = getWidgetFactory().createCCombo(familySize, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER);
fontFamilyCombo.setItems(FontHelper.getFontNames());
fontFamilyCombo.setText((String) note.getPropertyValue(EParameterName.NOTE_FONT.getName()));
fontFamilyCombo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
updateFontFamily();
}
});
fontSizeCombo = getWidgetFactory().createCCombo(familySize, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER);
fontSizeCombo.setItems(FontHelper.getFontSizes());
fontSizeCombo.setText((String) note.getPropertyValue(EParameterName.FONT_SIZE.getName()));
fontSizeCombo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
updateFontSize();
}
});
Composite toolBar = new Composite(parent, SWT.SHADOW_NONE);
toolBar.setLayout(new GridLayout(7, false));
toolBar.setBackground(parent.getBackground());
fontBoldButton = new Button(toolBar, SWT.TOGGLE);
fontBoldButton.setImage(ImageProvider.getImage(EImage.BOLD_ICON));
fontBoldButton.getAccessible().addAccessibleListener(new AccessibleAdapter() {
@Override
public void getName(AccessibleEvent e) {
e.result = "Bold";
}
});
fontItalicButton = new Button(toolBar, SWT.TOGGLE);
fontItalicButton.setImage(ImageProvider.getImage(EImage.ITALIC_ICON));
fontItalicButton.getAccessible().addAccessibleListener(new AccessibleAdapter() {
@Override
public void getName(AccessibleEvent e) {
e.result = "Italic";
}
});
fontBoldButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
updateFontBold();
}
});
fontItalicButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
updateFontItalic();
}
});
new Label(toolBar, SWT.LEFT);
fontColorButton = new Button(toolBar, SWT.PUSH);
Image overlyedImage = new ColorOverlayImageDescriptor(ImageProvider.getImageDesc(EImage.FONT_COLOR_ICON).getImageData(), ColorUtils.stringToRGB((String) note.getPropertyValue(EParameterName.NOTETXT_COLOR.getName()))).createImage();
fontColorButton.setImage(overlyedImage);
fontColorButton.getAccessible().addAccessibleListener(new AccessibleAdapter() {
@Override
public void getName(AccessibleEvent e) {
e.result = "Font Color";
}
});
fontColorButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
ColorPalettePopup popup = new ColorPalettePopup(fontColorButton.getParent().getShell(), IDialogConstants.BUTTON_BAR_HEIGHT);
Rectangle r = fontColorButton.getBounds();
Point location = fontColorButton.getParent().toDisplay(r.x, r.y);
popup.open(new Point(location.x, location.y + r.height));
if (popup.getSelectedColor() == null && !popup.useDefaultColor()) {
return;
}
// selectedColor should be null if we are to use the default color
RGB selectedColor = popup.getSelectedColor();
if (popup.useDefaultColor()) {
selectedColor = new RGB(0, 0, 0);
}
if (selectedColor != null) {
//$NON-NLS-1$ //$NON-NLS-2$
String value = selectedColor.red + ";" + selectedColor.green + ";" + selectedColor.blue;
Command cmd = new PropertyChangeCommand(note, EParameterName.NOTETXT_COLOR.getName(), value);
getCommandStack().execute(cmd);
note.refresh();
Image overlyedImage = new ColorOverlayImageDescriptor(ImageProvider.getImageDesc(EImage.FONT_COLOR_ICON).getImageData(), selectedColor).createImage();
fontColorButton.setImage(overlyedImage);
text.setForeground(new Color(null, ColorUtils.stringToRGB((String) note.getPropertyValue(EParameterName.NOTETXT_COLOR.getName()))));
}
}
});
new Label(toolBar, SWT.LEFT);
lineColorButton = new Button(toolBar, SWT.PUSH);
overlyedImage = new ColorOverlayImageDescriptor(ImageProvider.getImageDesc(EImage.LINE_COLOR_ICON).getImageData(), ColorUtils.stringToRGB((String) note.getPropertyValue(EParameterName.NOTE_LINECOLOR.getName()))).createImage();
lineColorButton.setImage(overlyedImage);
lineColorButton.getAccessible().addAccessibleListener(new AccessibleAdapter() {
@Override
public void getName(AccessibleEvent e) {
e.result = "Line Color";
}
});
lineColorButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
ColorPalettePopup popup = new ColorPalettePopup(lineColorButton.getParent().getShell(), IDialogConstants.BUTTON_BAR_HEIGHT);
Rectangle r = lineColorButton.getBounds();
Point location = lineColorButton.getParent().toDisplay(r.x, r.y);
popup.open(new Point(location.x, location.y + r.height));
if (popup.getSelectedColor() == null && !popup.useDefaultColor()) {
return;
}
// selectedColor should be null if we are to use the default color
RGB selectedColor = popup.getSelectedColor();
if (popup.useDefaultColor()) {
selectedColor = new RGB(237, 201, 122);
}
if (selectedColor != null) {
//$NON-NLS-1$ //$NON-NLS-2$
String value = selectedColor.red + ";" + selectedColor.green + ";" + selectedColor.blue;
Command cmd = new PropertyChangeCommand(note, EParameterName.NOTE_LINECOLOR.getName(), value);
getCommandStack().execute(cmd);
note.refresh();
Image overlyedImage = new ColorOverlayImageDescriptor(ImageProvider.getImageDesc(EImage.LINE_COLOR_ICON).getImageData(), selectedColor).createImage();
lineColorButton.setImage(overlyedImage);
}
}
});
fillColorButton = new Button(toolBar, SWT.PUSH);
overlyedImage = new ColorOverlayImageDescriptor(ImageProvider.getImageDesc(EImage.FILL_COLOR_ICON).getImageData(), ColorUtils.stringToRGB((String) note.getPropertyValue(EParameterName.NOTE_COLOR.getName()))).createImage();
fillColorButton.setImage(overlyedImage);
fillColorButton.getAccessible().addAccessibleListener(new AccessibleAdapter() {
@Override
public void getName(AccessibleEvent e) {
e.result = "Fill Color";
}
});
fillColorButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
ColorPalettePopup popup = new ColorPalettePopup(fillColorButton.getParent().getShell(), IDialogConstants.BUTTON_BAR_HEIGHT);
Rectangle r = fillColorButton.getBounds();
Point location = fillColorButton.getParent().toDisplay(r.x, r.y);
popup.open(new Point(location.x, location.y + r.height));
if (popup.getSelectedColor() == null && !popup.useDefaultColor()) {
return;
}
// selectedColor should be null if we are to use the default color
RGB selectedColor = popup.getSelectedColor();
if (popup.useDefaultColor()) {
selectedColor = new RGB(255, 255, 203);
}
if (selectedColor != null) {
//$NON-NLS-1$ //$NON-NLS-2$
String value = selectedColor.red + ";" + selectedColor.green + ";" + selectedColor.blue;
Command cmd = new PropertyChangeCommand(note, EParameterName.NOTE_COLOR.getName(), value);
getCommandStack().execute(cmd);
note.refresh();
Image overlyedImage = new ColorOverlayImageDescriptor(ImageProvider.getImageDesc(EImage.FILL_COLOR_ICON).getImageData(), selectedColor).createImage();
fillColorButton.setImage(overlyedImage);
}
}
});
return toolBar;
}
use of org.eclipse.swt.accessibility.AccessibleEvent in project tdi-studio-se by Talend.
the class BusinessRulersAndGridComposite method createLineColorControl.
private void createLineColorControl(Composite composite) {
widgetFactory.createLabel(composite, LINE_COLOR_LABEL);
lineColorButton = new Button(composite, SWT.PUSH);
lineColorButton.setImage(DiagramUIPropertiesImages.get(DiagramUIPropertiesImages.IMG_LINE_COLOR));
lineColorButton.getAccessible().addAccessibleListener(new AccessibleAdapter() {
public void getName(AccessibleEvent e) {
e.result = DiagramUIMessages.PropertyDescriptorFactory_LineColor;
}
});
lineColorButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
changeLineColor(event);
}
/**
* Change line color property value
*/
private void changeLineColor(SelectionEvent event) {
lineColor = changeColor(event, lineColorButton, DiagramUIPropertiesImages.DESC_LINE_COLOR, getWorkspacePropertyInt(WorkspaceViewerProperties.GRIDLINECOLOR));
if (lineColor != null)
setWorkspaceProperty(WorkspaceViewerProperties.GRIDLINECOLOR, FigureUtilities.RGBToInteger(lineColor).intValue());
}
});
lineColorButton.setEnabled(true);
}
use of org.eclipse.swt.accessibility.AccessibleEvent in project eclipse.platform.swt by eclipse.
the class CTableColumn method getAccessible.
/* Returns the accessible for the column header. */
Accessible getAccessible(final Accessible accessibleTable) {
if (accessible == null) {
accessible = new Accessible(accessibleTable);
accessible.addAccessibleListener(new AccessibleAdapter() {
@Override
public void getName(AccessibleEvent e) {
e.result = getText();
System.out.println("tableColumn getName = " + e.result);
}
});
accessible.addAccessibleControlListener(new AccessibleControlAdapter() {
@Override
public void getChildAtPoint(AccessibleControlEvent e) {
Point point = parent.toControl(e.x, e.y);
int x = getX();
if (x <= point.x && point.x <= x + getWidth()) {
e.childID = ACC.CHILDID_SELF;
} else {
e.childID = ACC.CHILDID_NONE;
}
}
@Override
public void getChildCount(AccessibleControlEvent e) {
e.detail = 0;
}
@Override
public void getLocation(AccessibleControlEvent e) {
Rectangle rect = parent.header.getBounds();
rect.x = getX();
Point pt = parent.toDisplay(rect.x, rect.y);
e.x = pt.x;
e.y = pt.y;
e.width = width;
e.height = rect.height;
}
@Override
public void getRole(AccessibleControlEvent e) {
e.detail = ACC.ROLE_TABLECELL;
}
});
accessible.addAccessibleTableCellListener(new AccessibleTableCellListener() {
@Override
public void getColumnHeaders(AccessibleTableCellEvent e) {
/* Column header does not have a header. */
}
@Override
public void getColumnIndex(AccessibleTableCellEvent e) {
e.index = getIndex();
}
@Override
public void getColumnSpan(AccessibleTableCellEvent e) {
e.count = 1;
/* CTable cells only occupy one column. */
}
@Override
public void getRowHeaders(AccessibleTableCellEvent e) {
/* CTable does not support row headers. */
}
@Override
public void getRowIndex(AccessibleTableCellEvent e) {
e.index = 0;
}
@Override
public void getRowSpan(AccessibleTableCellEvent e) {
e.count = 1;
/* CTable cells only occupy one row. */
}
@Override
public void getTable(AccessibleTableCellEvent e) {
e.accessible = accessibleTable;
}
@Override
public void isSelected(AccessibleTableCellEvent e) {
e.isSelected = false;
/* CTable columns cannot be selected (only rows can be selected). */
}
});
}
return accessible;
}
use of org.eclipse.swt.accessibility.AccessibleEvent in project eclipse.platform.swt by eclipse.
the class CTableItem method getAccessible.
/* Returns the cell accessible for the specified column index in the receiver. */
Accessible getAccessible(final Accessible accessibleTable, final int columnIndex) {
if (accessibles[columnIndex] == null) {
Accessible accessible = new Accessible(accessibleTable);
accessible.addAccessibleListener(new AccessibleAdapter() {
@Override
public void getName(AccessibleEvent e) {
e.result = getText(columnIndex);
System.out.println("tableItem getName = " + e.result);
}
});
accessible.addAccessibleControlListener(new AccessibleControlAdapter() {
@Override
public void getChild(AccessibleControlEvent e) {
/* CTable cells do not have children, so just return the index in parent. */
switch(e.childID) {
case ACC.CHILDID_CHILD_INDEX:
e.detail = index * Math.max(1, parent.getColumnCount()) + columnIndex + parent.getColumnCount();
break;
}
}
@Override
public void getChildAtPoint(AccessibleControlEvent e) {
Point point = parent.toControl(e.x, e.y);
if (getBounds(columnIndex).contains(point)) {
e.childID = ACC.CHILDID_SELF;
} else {
e.childID = ACC.CHILDID_NONE;
}
}
@Override
public void getFocus(AccessibleControlEvent e) {
e.childID = (parent.focusItem == CTableItem.this && parent.isFocusControl()) ? ACC.CHILDID_SELF : ACC.CHILDID_NONE;
}
@Override
public void getLocation(AccessibleControlEvent e) {
Rectangle location = getBounds(columnIndex);
Point pt = parent.toDisplay(location.x, location.y);
e.x = pt.x;
e.y = pt.y;
e.width = location.width;
e.height = location.height;
}
@Override
public void getRole(AccessibleControlEvent e) {
e.detail = ACC.ROLE_TABLECELL;
}
@Override
public void getValue(AccessibleControlEvent e) {
e.result = getText(columnIndex);
}
});
accessible.addAccessibleTableCellListener(new AccessibleTableCellListener() {
@Override
public void getColumnHeaders(AccessibleTableCellEvent e) {
if (parent.columns.length == 0) {
/* The CTable is being used as a list, and there are no headers. */
e.accessibles = null;
} else {
/* CTable cells only occupy one column. */
CTableColumn column = parent.columns[columnIndex];
e.accessibles = new Accessible[] { column.getAccessible(accessibleTable) };
}
}
@Override
public void getColumnIndex(AccessibleTableCellEvent e) {
e.index = columnIndex;
}
@Override
public void getColumnSpan(AccessibleTableCellEvent e) {
/* CTable cells only occupy one column. */
e.count = 1;
}
@Override
public void getRowHeaders(AccessibleTableCellEvent e) {
/* CTable does not support row headers. */
}
@Override
public void getRowIndex(AccessibleTableCellEvent e) {
e.index = index;
}
@Override
public void getRowSpan(AccessibleTableCellEvent e) {
/* CTable cells only occupy one row. */
e.count = 1;
}
@Override
public void getTable(AccessibleTableCellEvent e) {
e.accessible = accessibleTable;
}
@Override
public void isSelected(AccessibleTableCellEvent e) {
e.isSelected = CTableItem.this.isSelected();
}
});
accessibles[columnIndex] = accessible;
}
return accessibles[columnIndex];
}
Aggregations