|
Packit |
ffe0d2 |
/*
|
|
Packit |
ffe0d2 |
* Java ATK Wrapper for GNOME
|
|
Packit |
ffe0d2 |
* Copyright (C) 2009 Sun Microsystems Inc.
|
|
Packit |
ffe0d2 |
*
|
|
Packit |
ffe0d2 |
* This library is free software; you can redistribute it and/or
|
|
Packit |
ffe0d2 |
* modify it under the terms of the GNU Lesser General Public
|
|
Packit |
ffe0d2 |
* License as published by the Free Software Foundation; either
|
|
Packit |
ffe0d2 |
* version 2.1 of the License, or (at your option) any later version.
|
|
Packit |
ffe0d2 |
*
|
|
Packit |
ffe0d2 |
* This library is distributed in the hope that it will be useful,
|
|
Packit |
ffe0d2 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
ffe0d2 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
ffe0d2 |
* Lesser General Public License for more details.
|
|
Packit |
ffe0d2 |
*
|
|
Packit |
ffe0d2 |
* You should have received a copy of the GNU Lesser General Public
|
|
Packit |
ffe0d2 |
* License along with this library; if not, write to the Free Software
|
|
Packit |
ffe0d2 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
Packit |
ffe0d2 |
*/
|
|
Packit |
ffe0d2 |
|
|
Packit |
ffe0d2 |
package org.GNOME.Accessibility;
|
|
Packit |
ffe0d2 |
|
|
Packit |
ffe0d2 |
import javax.accessibility.*;
|
|
Packit |
ffe0d2 |
import java.awt.Toolkit;
|
|
Packit |
ffe0d2 |
import java.awt.datatransfer.StringSelection;
|
|
Packit |
ffe0d2 |
import javax.swing.text.*;
|
|
Packit |
ffe0d2 |
|
|
Packit |
ffe0d2 |
public class AtkEditableText extends AtkText {
|
|
Packit |
ffe0d2 |
|
|
Packit |
ffe0d2 |
AccessibleEditableText acc_edt_text;
|
|
Packit |
ffe0d2 |
|
|
Packit |
ffe0d2 |
public AtkEditableText (AccessibleContext ac) {
|
|
Packit |
ffe0d2 |
super(ac);
|
|
Packit |
ffe0d2 |
acc_edt_text = ac.getAccessibleEditableText();
|
|
Packit |
ffe0d2 |
}
|
|
Packit |
ffe0d2 |
|
|
Packit |
ffe0d2 |
public void set_text_contents (String s) {
|
|
Packit |
ffe0d2 |
acc_edt_text.setTextContents(s);
|
|
Packit |
ffe0d2 |
}
|
|
Packit |
ffe0d2 |
|
|
Packit |
ffe0d2 |
public void insert_text (String s, int position) {
|
|
Packit |
ffe0d2 |
if (position < 0) {
|
|
Packit |
ffe0d2 |
position = 0;
|
|
Packit |
ffe0d2 |
}
|
|
Packit |
ffe0d2 |
|
|
Packit |
ffe0d2 |
acc_edt_text.insertTextAtIndex(position, s);
|
|
Packit |
ffe0d2 |
}
|
|
Packit |
ffe0d2 |
|
|
Packit |
ffe0d2 |
public void copy_text (int start, int end) {
|
|
Packit |
ffe0d2 |
int n = acc_edt_text.getCharCount();
|
|
Packit |
ffe0d2 |
|
|
Packit |
ffe0d2 |
if (start < 0) {
|
|
Packit |
ffe0d2 |
start = 0;
|
|
Packit |
ffe0d2 |
}
|
|
Packit |
ffe0d2 |
|
|
Packit |
ffe0d2 |
if (end > n || end == -1) {
|
|
Packit |
ffe0d2 |
end = n;
|
|
Packit |
ffe0d2 |
} else if (end < -1) {
|
|
Packit |
ffe0d2 |
end = 0;
|
|
Packit |
ffe0d2 |
}
|
|
Packit |
ffe0d2 |
|
|
Packit |
ffe0d2 |
String s = acc_edt_text.getTextRange(start, end);
|
|
Packit |
ffe0d2 |
if (s != null) {
|
|
Packit |
ffe0d2 |
StringSelection stringSel = new StringSelection(s);
|
|
Packit |
ffe0d2 |
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(stringSel,
|
|
Packit |
ffe0d2 |
stringSel
|
|
Packit |
ffe0d2 |
);
|
|
Packit |
ffe0d2 |
}
|
|
Packit |
ffe0d2 |
}
|
|
Packit |
ffe0d2 |
|
|
Packit |
ffe0d2 |
public void cut_text (int start, int end) {
|
|
Packit |
ffe0d2 |
acc_edt_text.cut(start, end);
|
|
Packit |
ffe0d2 |
}
|
|
Packit |
ffe0d2 |
|
|
Packit |
ffe0d2 |
public void delete_text (int start, int end) {
|
|
Packit |
ffe0d2 |
acc_edt_text.delete(start, end);
|
|
Packit |
ffe0d2 |
}
|
|
Packit |
ffe0d2 |
|
|
Packit |
ffe0d2 |
public void paste_text (int position) {
|
|
Packit |
ffe0d2 |
acc_edt_text.paste(position);
|
|
Packit |
ffe0d2 |
}
|
|
Packit |
ffe0d2 |
}
|
|
Packit |
ffe0d2 |
|