You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by gb...@apache.org on 2009/11/03 19:11:52 UTC
svn commit: r832489 - in /incubator/pivot/trunk:
tools/src/org/apache/pivot/tools/wtk/ComponentInspectorSkin.java
wtk/src/org/apache/pivot/wtk/TextArea.java
Author: gbrown
Date: Tue Nov 3 18:11:52 2009
New Revision: 832489
URL: http://svn.apache.org/viewvc?rev=832489&view=rev
Log:
Paste clipboard contents into TextArea using PlainTextSerializer so line breaks are preserved.
Modified:
incubator/pivot/trunk/tools/src/org/apache/pivot/tools/wtk/ComponentInspectorSkin.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/TextArea.java
Modified: incubator/pivot/trunk/tools/src/org/apache/pivot/tools/wtk/ComponentInspectorSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/tools/src/org/apache/pivot/tools/wtk/ComponentInspectorSkin.java?rev=832489&r1=832488&r2=832489&view=diff
==============================================================================
--- incubator/pivot/trunk/tools/src/org/apache/pivot/tools/wtk/ComponentInspectorSkin.java (original)
+++ incubator/pivot/trunk/tools/src/org/apache/pivot/tools/wtk/ComponentInspectorSkin.java Tue Nov 3 18:11:52 2009
@@ -421,7 +421,6 @@
}
}
- @SuppressWarnings("unchecked")
private Component addEnumControl(final Dictionary<String, Object> dictionary,
final String key, Class<? extends Enum<?>> type, Form.Section section) {
Enum<?> value = (Enum<?>)dictionary.get(key);
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/TextArea.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/TextArea.java?rev=832489&r1=832488&r2=832489&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/TextArea.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/TextArea.java Tue Nov 3 18:11:52 2009
@@ -515,7 +515,8 @@
// No-op
}
- if (text != null) {
+ if (text != null
+ && text.length() > 0) {
// Remove any existing selection
if (selectionLength > 0) {
// TODO Make this part of the undoable action (for all such
@@ -524,7 +525,20 @@
}
// Insert the clipboard contents
- insertText(text);
+ Document document;
+ int n;
+ try {
+ PlainTextSerializer serializer = new PlainTextSerializer();
+ StringReader reader = new StringReader(text);
+ document = serializer.readObject(reader);
+ n = document.getCharacterCount();
+
+ this.document.insertRange(document, selectionStart);
+ } catch(IOException exception) {
+ throw new RuntimeException(exception);
+ }
+
+ setSelection(selectionStart + n, 0);
}
}
}