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/10/27 19:15:46 UTC
svn commit: r830279 - in /incubator/pivot/trunk:
core/src/org/apache/pivot/serialization/
core/test/org/apache/pivot/serialization/test/
demos/src/org/apache/pivot/demos/explorer/
web/src/org/apache/pivot/web/server/ wtk/src/org/apache/pivot/wtk/ wtk/s...
Author: gbrown
Date: Tue Oct 27 18:15:45 2009
New Revision: 830279
URL: http://svn.apache.org/viewvc?rev=830279&view=rev
Log:
Properly resolve some earlier issues that were hidden by @SuppressWarnings; continue to improve selection support in TextArea.
Modified:
incubator/pivot/trunk/core/src/org/apache/pivot/serialization/CSVSerializer.java
incubator/pivot/trunk/core/src/org/apache/pivot/serialization/JSONSerializer.java
incubator/pivot/trunk/core/test/org/apache/pivot/serialization/test/CSVSerializerTest.java
incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/ComponentExplorer.java
incubator/pivot/trunk/web/src/org/apache/pivot/web/server/QueryServlet.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/TextArea.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextAreaSkin.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/WindowSkin.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraCalendarSkin.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/text/PlainTextSerializer.java
Modified: incubator/pivot/trunk/core/src/org/apache/pivot/serialization/CSVSerializer.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/core/src/org/apache/pivot/serialization/CSVSerializer.java?rev=830279&r1=830278&r2=830279&view=diff
==============================================================================
--- incubator/pivot/trunk/core/src/org/apache/pivot/serialization/CSVSerializer.java (original)
+++ incubator/pivot/trunk/core/src/org/apache/pivot/serialization/CSVSerializer.java Tue Oct 27 18:15:45 2009
@@ -310,7 +310,7 @@
return new StreamIterator(reader);
}
- @SuppressWarnings({"unchecked"})
+ @SuppressWarnings("unchecked")
private Object readItem(Reader reader)
throws IOException, SerializationException {
Object item = null;
@@ -442,9 +442,8 @@
* @param writer
* The writer to which data will be written.
*/
- @SuppressWarnings({"unchecked", "unused"})
- public void writeObject(List<?> items, Writer writer)
- throws IOException, SerializationException {
+ @SuppressWarnings("unchecked")
+ public void writeObject(List<?> items, Writer writer) throws IOException {
if (items == null) {
throw new IllegalArgumentException("items is null.");
}
Modified: incubator/pivot/trunk/core/src/org/apache/pivot/serialization/JSONSerializer.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/core/src/org/apache/pivot/serialization/JSONSerializer.java?rev=830279&r1=830278&r2=830279&view=diff
==============================================================================
--- incubator/pivot/trunk/core/src/org/apache/pivot/serialization/JSONSerializer.java (original)
+++ incubator/pivot/trunk/core/src/org/apache/pivot/serialization/JSONSerializer.java Tue Oct 27 18:15:45 2009
@@ -313,9 +313,7 @@
return stringBuilder.toString();
}
- @SuppressWarnings("unused")
- private Number readNumber(Reader reader)
- throws IOException, SerializationException {
+ private Number readNumber(Reader reader) throws IOException {
Number number = null;
StringBuilder stringBuilder = new StringBuilder();
Modified: incubator/pivot/trunk/core/test/org/apache/pivot/serialization/test/CSVSerializerTest.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/core/test/org/apache/pivot/serialization/test/CSVSerializerTest.java?rev=830279&r1=830278&r2=830279&view=diff
==============================================================================
--- incubator/pivot/trunk/core/test/org/apache/pivot/serialization/test/CSVSerializerTest.java (original)
+++ incubator/pivot/trunk/core/test/org/apache/pivot/serialization/test/CSVSerializerTest.java Tue Oct 27 18:15:45 2009
@@ -142,7 +142,7 @@
@Test
@SuppressWarnings("unchecked")
- public void testBasicWriteObject() throws IOException, SerializationException {
+ public void testBasicWriteObject() throws IOException {
List<Object> items = new ArrayList<Object>();
items.add(new HashMap<String, Object>(
new Dictionary.Pair<String, Object>("A", "a1"),
@@ -169,7 +169,7 @@
@Test
@SuppressWarnings("unchecked")
- public void testQuotedCommaWriteObject() throws IOException, SerializationException {
+ public void testQuotedCommaWriteObject() throws IOException {
List<Object> items = new ArrayList<Object>();
items.add(new HashMap<String, Object>(
new Dictionary.Pair<String, Object>("A", "a"),
@@ -191,7 +191,7 @@
@Test
@SuppressWarnings("unchecked")
- public void testQuotedQuoteWriteObject() throws IOException, SerializationException {
+ public void testQuotedQuoteWriteObject() throws IOException {
List<Object> items = new ArrayList<Object>();
items.add(new HashMap<String, Object>(
new Dictionary.Pair<String, Object>("A", "a"),
@@ -213,7 +213,7 @@
@Test
@SuppressWarnings("unchecked")
- public void testQuotedNewlineWriteObject() throws IOException, SerializationException {
+ public void testQuotedNewlineWriteObject() throws IOException {
List<Object> items = new ArrayList<Object>();
items.add(new HashMap<String, Object>(
new Dictionary.Pair<String, Object>("A", "a"),
@@ -233,9 +233,8 @@
assertEquals("a,\"\nb\n\",c\r\n", writer.toString());
}
- @SuppressWarnings("unused")
@Test
- public void testStreamReader() throws IOException, SerializationException {
+ public void testStreamReader() {
// TODO
}
}
Modified: incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/ComponentExplorer.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/ComponentExplorer.java?rev=830279&r1=830278&r2=830279&view=diff
==============================================================================
--- incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/ComponentExplorer.java (original)
+++ incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/ComponentExplorer.java Tue Oct 27 18:15:45 2009
@@ -45,7 +45,6 @@
private EventLogger eventLogger = null;
@Override
- @SuppressWarnings({"unchecked"})
public void startup(Display display, Map<String, String> properties)
throws Exception {
WTKXSerializer wtkxSerializer = new WTKXSerializer();
Modified: incubator/pivot/trunk/web/src/org/apache/pivot/web/server/QueryServlet.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/web/src/org/apache/pivot/web/server/QueryServlet.java?rev=830279&r1=830278&r2=830279&view=diff
==============================================================================
--- incubator/pivot/trunk/web/src/org/apache/pivot/web/server/QueryServlet.java (original)
+++ incubator/pivot/trunk/web/src/org/apache/pivot/web/server/QueryServlet.java Tue Oct 27 18:15:45 2009
@@ -386,10 +386,12 @@
* This method is guaranteed to be called after the arguments and request
* properties have been made available.
*
+ * @throws ServletException
+ * If a servlet exception is thrown.
+ *
* @throws LoginException
- * Thrown if the request is not authorized
+ * If the request is not authorized.
*/
- @SuppressWarnings("unused")
protected void authorize() throws ServletException, LoginException {
// No-op
}
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=830279&r1=830278&r2=830279&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 Oct 27 18:15:45 2009
@@ -265,8 +265,6 @@
PlainTextSerializer serializer = new PlainTextSerializer();
StringReader reader = new StringReader(text);
document = serializer.readObject(reader);
- } catch(SerializationException exception) {
- throw new RuntimeException(exception);
} catch(IOException exception) {
throw new RuntimeException(exception);
}
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextAreaSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextAreaSkin.java?rev=830279&r1=830278&r2=830279&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextAreaSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextAreaSkin.java Tue Oct 27 18:15:45 2009
@@ -719,7 +719,8 @@
terminatorY = height - terminatorHeight;
}
- terminatorBounds = new Bounds(x, terminatorY, 0, terminatorHeight);
+ terminatorBounds = new Bounds(x, terminatorY,
+ PARAGRAPH_TERMINATOR_WIDTH, terminatorHeight);
// Ensure that the paragraph is visible even when empty
height = Math.max(height, terminatorBounds.height);
@@ -852,17 +853,19 @@
public int getRowIndex(int offset) {
int rowIndex = -1;
- for (int i = 0, n = rows.getLength(); i < n; i++) {
- Row row = rows.get(i);
- NodeView firstNodeView = row.nodeViews.get(0);
- NodeView lastNodeView = row.nodeViews.get(row.nodeViews.getLength() - 1);
+ if (offset == getCharacterCount() - 1) {
+ rowIndex = (rows.getLength() == 0) ? 0 : rows.getLength() - 1;
+ } else {
+ for (int i = 0, n = rows.getLength(); i < n; i++) {
+ Row row = rows.get(i);
+ NodeView firstNodeView = row.nodeViews.get(0);
+ NodeView lastNodeView = row.nodeViews.get(row.nodeViews.getLength() - 1);
- if (offset == getCharacterCount() - 1) {
- rowIndex = n - 1;
- } else if (offset >= firstNodeView.getOffset()
- && offset < lastNodeView.getOffset() + lastNodeView.getCharacterCount()) {
- rowIndex = i;
- break;
+ if (offset >= firstNodeView.getOffset()
+ && offset < lastNodeView.getOffset() + lastNodeView.getCharacterCount()) {
+ rowIndex = i;
+ break;
+ }
}
}
@@ -871,7 +874,7 @@
@Override
public int getRowCount() {
- return rows.getLength();
+ return Math.max(rows.getLength(), 1);
}
@Override
@@ -1298,6 +1301,7 @@
private DocumentView documentView = null;
private int caretX = 0;
+ private int anchor = -1;
private Rectangle caret = new Rectangle();
private Area selection = null;
@@ -1319,7 +1323,7 @@
private Insets margin = new Insets(4);
- public static final int PARAGRAPH_TERMINATOR_WIDTH = 2;
+ private static final int PARAGRAPH_TERMINATOR_WIDTH = 4;
private static final FontRenderContext FONT_RENDER_CONTEXT = new FontRenderContext(null, true, true);
private static final int SCROLL_RATE = 50;
@@ -1724,12 +1728,10 @@
if (offset != -1) {
// Select the range
- int selectionStart = textArea.getSelectionStart();
-
- if (offset > selectionStart) {
- textArea.setSelection(selectionStart, offset - selectionStart);
+ if (offset > anchor) {
+ textArea.setSelection(anchor, offset - anchor);
} else {
- textArea.setSelection(offset, selectionStart - offset);
+ textArea.setSelection(offset, anchor - offset);
}
}
} else {
@@ -1762,21 +1764,21 @@
TextArea textArea = (TextArea)component;
if (button == Mouse.Button.LEFT) {
- int offset = getInsertionPoint(x, y);
+ anchor = getInsertionPoint(x, y);
- if (offset != -1) {
+ if (anchor != -1) {
if (Keyboard.isPressed(Keyboard.Modifier.SHIFT)) {
// Select the range
int selectionStart = textArea.getSelectionStart();
- if (offset > selectionStart) {
- textArea.setSelection(selectionStart, offset - selectionStart);
+ if (anchor > selectionStart) {
+ textArea.setSelection(selectionStart, anchor - selectionStart);
} else {
- textArea.setSelection(offset, selectionStart - offset);
+ textArea.setSelection(anchor, selectionStart - anchor);
}
} else {
// Move the caret to the insertion point
- textArea.setSelection(offset, 0);
+ textArea.setSelection(anchor, 0);
consumed = true;
}
}
@@ -1806,6 +1808,8 @@
Mouse.release();
}
+ anchor = -1;
+
return consumed;
}
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/WindowSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/WindowSkin.java?rev=830279&r1=830278&r2=830279&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/WindowSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/WindowSkin.java Tue Oct 27 18:15:45 2009
@@ -42,15 +42,10 @@
* ensures that focus does not traverse out of the window.
*/
public static class WindowFocusTraversalPolicy implements FocusTraversalPolicy {
- @SuppressWarnings("null")
@Override
public Component getNextComponent(Container container, Component component, Direction direction) {
assert (container instanceof Window) : "container is not a Window";
- if (container == null) {
- throw new IllegalArgumentException("container is null.");
- }
-
if (direction == null) {
throw new IllegalArgumentException("direction is null.");
}
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraCalendarSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraCalendarSkin.java?rev=830279&r1=830278&r2=830279&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraCalendarSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraCalendarSkin.java Tue Oct 27 18:15:45 2009
@@ -58,7 +58,6 @@
/**
* Terra calendar skin.
*/
-@SuppressWarnings("unused")
public class TerraCalendarSkin extends CalendarSkin
implements CalendarListener, CalendarSelectionListener {
public class DateButton extends Button {
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/text/PlainTextSerializer.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/text/PlainTextSerializer.java?rev=830279&r1=830278&r2=830279&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/text/PlainTextSerializer.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/text/PlainTextSerializer.java Tue Oct 27 18:15:45 2009
@@ -66,9 +66,7 @@
return document;
}
- @SuppressWarnings("unused")
- public Document readObject(Reader reader)
- throws IOException, SerializationException {
+ public Document readObject(Reader reader) throws IOException {
Document document = new Document();
BufferedReader bufferedReader = new BufferedReader(reader, BUFFER_SIZE);