]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.eclipse.swt.win32.win32.x86_64/src/org/eclipse/swt/accessibility/AccessibleTextAttributeEvent.java
Merge branch 'bug-623' into release/1.43.0
[simantics/platform.git] / bundles / org.eclipse.swt.win32.win32.x86_64 / src / org / eclipse / swt / accessibility / AccessibleTextAttributeEvent.java
1 /*******************************************************************************
2  * Copyright (c) 2009, 2018 IBM Corporation and others.
3  *
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/
8  *
9  * SPDX-License-Identifier: EPL-2.0
10  *
11  * Contributors:
12  *     IBM Corporation - initial API and implementation
13  *******************************************************************************/
14 package org.eclipse.swt.accessibility;
15
16 import java.util.*;
17
18 import org.eclipse.swt.graphics.*;
19
20 /**
21  * Instances of this class are sent as a result of accessibility clients
22  * sending AccessibleAttribute or AccessibleEditableText messages to an
23  * accessible object.
24  *
25  * @see AccessibleAttributeListener
26  * @see AccessibleAttributeAdapter
27  * @see AccessibleEditableTextListener
28  * @see AccessibleEditableTextAdapter
29  *
30  * @since 3.6
31  */
32 public class AccessibleTextAttributeEvent extends EventObject {
33
34         /**
35          * [in] the 0-based text offset for which to return attribute information
36          *
37          * @see AccessibleAttributeListener#getTextAttributes
38          */
39         public int offset;
40
41         /**
42          * [in/out] the starting and ending offsets of the character range
43          *
44          * @see AccessibleAttributeListener#getTextAttributes
45          * @see AccessibleEditableTextListener#setTextAttributes
46          */
47         public int start, end;
48
49         /**
50          * [in/out] the TextStyle of the character range
51          *
52          * @see AccessibleAttributeListener#getTextAttributes
53          * @see AccessibleEditableTextListener#setTextAttributes
54          */
55         public TextStyle textStyle;
56
57         /**
58          * [in/out] an array of alternating key and value Strings
59          * that represent attributes that do not correspond to TextStyle fields
60          *
61          * @see AccessibleAttributeListener#getTextAttributes
62          * @see AccessibleEditableTextListener#setTextAttributes
63          */
64         public String [] attributes;
65
66         /**
67          * [out] Set this field to {@link ACC#OK} if the operation
68          * was completed successfully, and null otherwise.
69          *
70          * @see AccessibleEditableTextListener#setTextAttributes
71          *
72          * @since 3.7
73          */
74         public String result;
75
76         static final long serialVersionUID = 7131825608864332802L;
77
78 /**
79  * Constructs a new instance of this class.
80  *
81  * @param source the object that fired the event
82  */
83 public AccessibleTextAttributeEvent(Object source) {
84         super(source);
85 }
86
87 /**
88  * Returns a string containing a concise, human-readable
89  * description of the receiver.
90  *
91  * @return a string representation of the event
92  */
93 @Override
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$
102                 + "}";  //$NON-NLS-1$
103 }
104
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$
111         }
112         return attributeString.toString();
113 }
114 }