1 /*******************************************************************************
2 * Copyright (c) 2009, 2018 IBM Corporation and others.
4 * This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License 2.0
6 * which accompanies this distribution, and is available at
7 * https://www.eclipse.org/legal/epl-2.0/
9 * SPDX-License-Identifier: EPL-2.0
12 * IBM Corporation - initial API and implementation
13 *******************************************************************************/
14 package org.eclipse.swt.accessibility;
18 import org.eclipse.swt.graphics.*;
21 * Instances of this class are sent as a result of accessibility clients
22 * sending AccessibleAttribute or AccessibleEditableText messages to an
25 * @see AccessibleAttributeListener
26 * @see AccessibleAttributeAdapter
27 * @see AccessibleEditableTextListener
28 * @see AccessibleEditableTextAdapter
32 public class AccessibleTextAttributeEvent extends EventObject {
35 * [in] the 0-based text offset for which to return attribute information
37 * @see AccessibleAttributeListener#getTextAttributes
42 * [in/out] the starting and ending offsets of the character range
44 * @see AccessibleAttributeListener#getTextAttributes
45 * @see AccessibleEditableTextListener#setTextAttributes
47 public int start, end;
50 * [in/out] the TextStyle of the character range
52 * @see AccessibleAttributeListener#getTextAttributes
53 * @see AccessibleEditableTextListener#setTextAttributes
55 public TextStyle textStyle;
58 * [in/out] an array of alternating key and value Strings
59 * that represent attributes that do not correspond to TextStyle fields
61 * @see AccessibleAttributeListener#getTextAttributes
62 * @see AccessibleEditableTextListener#setTextAttributes
64 public String [] attributes;
67 * [out] Set this field to {@link ACC#OK} if the operation
68 * was completed successfully, and null otherwise.
70 * @see AccessibleEditableTextListener#setTextAttributes
76 static final long serialVersionUID = 7131825608864332802L;
79 * Constructs a new instance of this class.
81 * @param source the object that fired the event
83 public AccessibleTextAttributeEvent(Object source) {
88 * Returns a string containing a concise, human-readable
89 * description of the receiver.
91 * @return a string representation of the event
94 public String toString () {
95 return "AccessibleAttributeEvent {" //$NON-NLS-1$
96 + " offset=" + offset //$NON-NLS-1$
97 + " start=" + start //$NON-NLS-1$
98 + " end=" + end //$NON-NLS-1$
99 + " textStyle=" + textStyle //$NON-NLS-1$
100 + " attributes=" + toAttributeString(attributes) //$NON-NLS-1$
101 + " result=" + result //$NON-NLS-1$
105 String toAttributeString(String [] attributes) {
106 if (attributes == null || attributes.length == 0) return "" + attributes; //$NON-NLS-1$
107 StringBuilder attributeString = new StringBuilder();
108 for (int i = 0; i < attributes.length; i++) {
109 attributeString.append(attributes[i]);
110 attributeString.append((i % 2 == 0) ? ":" : ";"); //$NON-NLS-1$ //$NON-NLS-2$
112 return attributeString.toString();