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/18 19:54:44 UTC

svn commit: r881873 - in /incubator/pivot/trunk: demos/src/org/apache/pivot/demos/explorer/ tutorials/src/org/apache/pivot/tutorials/ tutorials/src/org/apache/pivot/tutorials/text/ tutorials/www/platform_overview/ wtk/src/org/apache/pivot/wtk/ wtk/src/...

Author: gbrown
Date: Wed Nov 18 18:54:43 2009
New Revision: 881873

URL: http://svn.apache.org/viewvc?rev=881873&view=rev
Log:
Fix some issues in TextArea and associated tutorials.

Modified:
    incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/ComponentExplorer.java
    incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/KitchenSink.java
    incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/text.wtkx
    incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/text/text_areas.wtkx
    incubator/pivot/trunk/tutorials/www/platform_overview/wtk_classes-large.png
    incubator/pivot/trunk/tutorials/www/platform_overview/wtk_classes-small.png
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/TextArea.java
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/GridPaneSkin.java
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraTableViewSkin.java
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtkx/WTKXSerializer.java
    incubator/pivot/trunk/wtk/test/org/apache/pivot/wtk/test/TableViewTest2.java
    incubator/pivot/trunk/wtk/test/org/apache/pivot/wtk/test/table_view_test2.wtkx

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=881873&r1=881872&r2=881873&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 Wed Nov 18 18:54:43 2009
@@ -180,7 +180,7 @@
                         break;
                     }
                 } else {
-                    sourceTextArea.setText(null);
+                    sourceTextArea.setText((String)null);
                 }
 
                 contentPane.setContent(component);

Modified: incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/KitchenSink.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/KitchenSink.java?rev=881873&r1=881872&r2=881873&view=diff
==============================================================================
--- incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/KitchenSink.java (original)
+++ incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/KitchenSink.java Wed Nov 18 18:54:43 2009
@@ -18,7 +18,6 @@
 
 import java.awt.Color;
 import java.io.IOException;
-import java.io.InputStream;
 import java.net.URL;
 import java.util.Comparator;
 
@@ -68,7 +67,6 @@
 import org.apache.pivot.wtk.Spinner;
 import org.apache.pivot.wtk.TableView;
 import org.apache.pivot.wtk.TableViewSortListener;
-import org.apache.pivot.wtk.TextArea;
 import org.apache.pivot.wtk.TreeView;
 import org.apache.pivot.wtk.Visual;
 import org.apache.pivot.wtk.Window;
@@ -81,8 +79,6 @@
 import org.apache.pivot.wtk.content.TreeNode;
 import org.apache.pivot.wtk.effects.ReflectionDecorator;
 import org.apache.pivot.wtk.media.Image;
-import org.apache.pivot.wtk.text.Document;
-import org.apache.pivot.wtk.text.PlainTextSerializer;
 import org.apache.pivot.wtkx.WTKXSerializer;
 
 public class KitchenSink implements Application, Application.AboutHandler {
@@ -180,7 +176,6 @@
 
     private class TextRollupStateHandler extends RollupStateHandler {
         private Component component = null;
-        private TextArea textArea = null;
 
         @Override
         public Vote previewExpandedChange(Rollup rollup) {
@@ -194,20 +189,7 @@
                     throw new RuntimeException(exception);
                 }
 
-                textArea = (TextArea)wtkxSerializer.get("textArea");
                 rollup.setContent(component);
-
-                PlainTextSerializer plainTextSerializer = new PlainTextSerializer("UTF-8");
-                InputStream inputStream = getClass().getResourceAsStream("text_area.txt");
-
-                Document document = null;
-                try {
-                    document = plainTextSerializer.readObject(inputStream);
-                } catch(Exception exception) {
-                    System.err.println(exception);
-                }
-
-                textArea.setDocument(document);
             }
 
             return Vote.APPROVE;

Modified: incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/text.wtkx
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/text.wtkx?rev=881873&r1=881872&r2=881873&view=diff
==============================================================================
--- incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/text.wtkx (original)
+++ incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/text.wtkx Wed Nov 18 18:54:43 2009
@@ -64,7 +64,7 @@
                                     <content>
                                         <ScrollPane horizontalScrollBarPolicy="fill" verticalScrollBarPolicy="fill_to_capacity">
                                             <view>
-                                                <TextArea wtkx:id="textArea"/>
+                                                <TextArea text="@text_area.txt"/>
                                             </view>
                                         </ScrollPane>
                                     </content>

Modified: incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/text/text_areas.wtkx
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/text/text_areas.wtkx?rev=881873&r1=881872&r2=881873&view=diff
==============================================================================
--- incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/text/text_areas.wtkx (original)
+++ incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/text/text_areas.wtkx Wed Nov 18 18:54:43 2009
@@ -36,47 +36,7 @@
                                                 verticalScrollBarPolicy="fill_to_capacity"
                                                 preferredHeight="240">
                                                 <view>
-                                                    <TextArea wtkx:id="textArea">
-                                                        <text>
-                                                        Lorem ipsum dolor sit amet, consetetur
-                                                        sadipscing elitr, sed diam nonumy eirmod
-                                                        tempor invidunt ut labore et dolore magna
-                                                        aliquyam erat, sed diam voluptua. At vero
-                                                        eos et accusam et justo duo dolores et ea
-                                                        rebum. Stet clita kasd gubergren, no sea
-                                                        takimata sanctus est Lorem ipsum dolor sit
-                                                        amet.
-
-                                                        Stet clita kasd gubergren, no sea takimata
-                                                        sanctus est Lorem ipsum dolor sit amet.
-
-                                                        Lorem ipsum dolor sit amet, consetetur
-                                                        sadipscing elitr, sed diam nonumy eirmod
-                                                        tempor invidunt ut labore et dolore magna
-                                                        aliquyam erat, sed diam voluptua. At vero
-                                                        eos et accusam et justo duo dolores et ea
-                                                        rebum.
-
-                                                        Stet clita kasd gubergren, no sea takimata
-                                                        sanctus est Lorem ipsum dolor sit amet.
-
-                                                        Lorem ipsum dolor sit amet, consetetur
-                                                        sadipscing elitr, sed diam nonumy eirmod
-                                                        tempor invidunt ut labore et dolore magna
-                                                        aliquyam erat, sed diam voluptua. At vero
-                                                        eos et accusam et justo duo dolores et ea
-                                                        rebum. Stet clita kasd gubergren, no sea
-                                                        takimata sanctus est Lorem ipsum dolor sit
-                                                        amet.
-
-                                                        Lorem ipsum dolor sit amet, consetetur
-                                                        sadipscing elitr, sed diam nonumy eirmod
-                                                        tempor invidunt ut labore et dolore magna
-                                                        aliquyam erat, sed diam voluptua. At vero
-                                                        eos et accusam et justo duo dolores et ea
-                                                        rebum.
-                                                        </text>
-                                                    </TextArea>
+                                                    <TextArea text="@sample1.txt"/>
                                                 </view>
                                             </ScrollPane>
                                         </content>
@@ -85,16 +45,7 @@
                                 <TablePane.Row height="-1">
                                     <Border styles="{color:10}">
                                         <content>
-                                            <TextArea minimumPreferredHeight="80">
-                                                <text>
-                                                Lorem ipsum dolor sit amet, consetetur
-                                                sadipscing elitr, sed diam nonumy eirmod
-                                                tempor invidunt ut labore et dolore magna
-                                                aliquyam erat, sed diam voluptua. At vero
-                                                eos et accusam et justo duo dolores et ea
-                                                rebum.
-                                                </text>
-                                            </TextArea>
+                                            <TextArea minimumPreferredHeight="80" text="@sample2.txt"/>
                                         </content>
                                     </Border>
                                 </TablePane.Row>

Modified: incubator/pivot/trunk/tutorials/www/platform_overview/wtk_classes-large.png
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/tutorials/www/platform_overview/wtk_classes-large.png?rev=881873&r1=881872&r2=881873&view=diff
==============================================================================
Binary files - no diff available.

Modified: incubator/pivot/trunk/tutorials/www/platform_overview/wtk_classes-small.png
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/tutorials/www/platform_overview/wtk_classes-small.png?rev=881873&r1=881872&r2=881873&view=diff
==============================================================================
Binary files - no diff available.

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=881873&r1=881872&r2=881873&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 Wed Nov 18 18:54:43 2009
@@ -17,8 +17,10 @@
 package org.apache.pivot.wtk;
 
 import java.io.IOException;
+import java.io.InputStream;
 import java.io.StringReader;
 import java.io.StringWriter;
+import java.net.URL;
 
 import org.apache.pivot.collections.Dictionary;
 import org.apache.pivot.collections.Sequence;
@@ -277,6 +279,30 @@
         setDocument(document);
     }
 
+    public void setText(URL text) {
+        PlainTextSerializer plainTextSerializer = new PlainTextSerializer("UTF-8");
+
+        Document document = null;
+        InputStream inputStream = null;
+
+        try {
+            try {
+                inputStream = text.openStream();
+                document = plainTextSerializer.readObject(inputStream);
+            } finally {
+                if (inputStream != null) {
+                    inputStream.close();
+                }
+            }
+        } catch (IOException exception) {
+            throw new IllegalArgumentException(exception);
+        } catch (SerializationException exception) {
+            throw new IllegalArgumentException(exception);
+        }
+
+        setDocument(document);
+    }
+
     public void insertText(char character) {
         // TODO Don't make every character undoable; break at word boundaries?
 
@@ -755,7 +781,7 @@
     @Override
     public void clear() {
         if (textKey != null) {
-            setText(null);
+            setText((String)null);
         }
     }
 

Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/GridPaneSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/GridPaneSkin.java?rev=881873&r1=881872&r2=881873&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/GridPaneSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/GridPaneSkin.java Wed Nov 18 18:54:43 2009
@@ -96,7 +96,7 @@
             clientHeight -= (visibleRowCount - 1) * verticalSpacing;
         }
         clientHeight = Math.max(0, clientHeight);
-        
+
         int cellHeight = 0;
         if (visibleRowCount > 0) {
             cellHeight = clientHeight / visibleRowCount;
@@ -178,7 +178,7 @@
             clientWidth -= (visibleColumnCount - 1) * horizontalSpacing;
         }
         clientWidth = Math.max(0, clientWidth);
-        
+
         int cellWidth = 0;
         if (visibleColumnCount > 0) {
             cellWidth = clientWidth / visibleColumnCount;
@@ -199,7 +199,7 @@
                 }
             }
         }
-        
+
         // The preferred height of the grid pane is the sum of the row
         // heights, plus padding and spacing
 
@@ -290,7 +290,7 @@
     @Override
     public int getBaseline(int width, int height) {
         int baseline = -1;
-        
+
         GridPane gridPane = (GridPane)getComponent();
         GridPane.RowSequence rows = gridPane.getRows();
         GridPane.ColumnSequence columns = gridPane.getColumns();
@@ -331,7 +331,7 @@
             clientWidth -= (visibleColumnCount - 1) * horizontalSpacing;
         }
         clientWidth = Math.max(0, clientWidth);
-        
+
         int cellWidth = 0;
         if (visibleColumnCount > 0) {
             cellWidth = clientWidth / visibleColumnCount;
@@ -352,14 +352,14 @@
             clientHeight -= (visibleRowCount - 1) * verticalSpacing;
         }
         clientHeight = Math.max(0, clientHeight);
-        
+
         int cellHeight = 0;
         if (visibleRowCount > 0) {
             cellHeight = clientHeight / visibleRowCount;
         }
 
         // Return the first available baseline by traversing cells top left to bottom right
-        
+
         for (int i = 0; i < rowCount; i++) {
             GridPane.Row row = rows.get(i);
 
@@ -376,7 +376,7 @@
                 break;
             }
         }
-        
+
         // Include top padding value
         if (baseline != -1) {
             baseline += padding.top;
@@ -432,7 +432,7 @@
             clientWidth -= (visibleColumnCount - 1) * horizontalSpacing;
         }
         clientWidth = Math.max(0, clientWidth);
-        
+
         cellWidth = 0;
         if (visibleColumnCount > 0) {
             cellWidth = clientWidth / visibleColumnCount;
@@ -453,7 +453,7 @@
             clientHeight -= (visibleRowCount - 1) * verticalSpacing;
         }
         clientHeight = Math.max(0, clientHeight);
-        
+
         cellHeight = 0;
         if (visibleRowCount > 0) {
             cellHeight = clientHeight / visibleRowCount;

Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraTableViewSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraTableViewSkin.java?rev=881873&r1=881872&r2=881873&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraTableViewSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraTableViewSkin.java Wed Nov 18 18:54:43 2009
@@ -214,7 +214,7 @@
 
         TableView.ColumnSequence columns = tableView.getColumns();
         ArrayList<Integer> columnWidths = getColumnWidths(tableView, width);
-        
+
         if (variableRowHeight) {
             int rowHeight = getVariableRowHeight(0);
             Object rowData = tableData.get(0);
@@ -225,7 +225,7 @@
                 cellRenderer.render(rowData, 0, i, tableView, column.getName(), false, false, false);
                 baseline = Math.max(baseline, cellRenderer.getBaseline(columnWidths.get(i), rowHeight));
             }
-            
+
         } else {
             int rowHeight = calculateFixedRowHeight(tableView, columns);
 
@@ -244,15 +244,15 @@
     @SuppressWarnings("unchecked")
     public void layout() {
         columnWidths = getColumnWidths((TableView)getComponent(), getWidth());
-        
+
         TableView tableView = (TableView)getComponent();
         TableView.ColumnSequence columns = tableView.getColumns();
-        
+
         if (variableRowHeight) {
             List<Object> tableData = (List<Object>)tableView.getTableData();
 
             variableRowHeightYCache = new int[tableData.getLength() + 1];
-            
+
             int rowEnd = tableData.getLength() - 1;
             int rowY = 0;
 
@@ -301,10 +301,10 @@
 
             fixedRowHeight = Math.max(fixedRowHeight, cellRenderer.getPreferredHeight(-1));
         }
-        
+
         return fixedRowHeight;
     }
-    
+
     @Override
     @SuppressWarnings("unchecked")
     public void paint(Graphics2D graphics) {
@@ -386,7 +386,7 @@
             boolean rowDisabled = tableView.isRowDisabled(rowIndex);
             int rowY = getRowY(rowIndex);
             int rowHeight = getRowHeight(rowIndex);
-            
+
             // Paint selection state
             Color rowBackgroundColor = null;
             if (rowSelected) {
@@ -491,7 +491,7 @@
             }
         }
     }
-    
+
     private int getRowY(int rowIndex) {
         int rowY;
         if (variableRowHeight) {
@@ -511,7 +511,7 @@
         }
         return rowHeight;
     }
-    
+
     /**
      * Returns the table row height, which is determined as the maximum
      * preferred height of all cell renderers.
@@ -526,7 +526,7 @@
 
         TableView.ColumnSequence columns = tableView.getColumns();
         Object rowData = tableData.get(0);
-        
+
         int rowHeight = 0;
         for (int i = 0, n = columns.getLength(); i < n; i++) {
             TableView.Column column = columns.get(i);
@@ -1107,7 +1107,7 @@
         this.fixedRowHeight = -1;
         invalidateComponent();
     }
-    
+
     @Override
     public boolean mouseMove(Component component, int x, int y) {
         boolean consumed = super.mouseMove(component, x, y);
@@ -1461,10 +1461,10 @@
     @Override
     public void selectedRangesChanged(TableView tableView, Sequence<Span> previousSelectedRanges) {
         List<?> tableData = tableView.getTableData();
-        
+
         // Repaint only the area that changed (intersection of previous
         // and new selection)
-        
+
         int rangeStart = 0;
         int rangeEnd = tableData.getLength() - 1;
         for (int i = 0; i < previousSelectedRanges.getLength(); i++) {
@@ -1479,7 +1479,7 @@
             rangeStart = Math.min(rangeStart, span.start);
             rangeEnd = Math.max(rangeEnd, span.end);
         }
-        
+
         repaintComponent(0, getRowY(rangeStart),
             getWidth(), getRowY(rangeEnd) + getRowY(rangeEnd));
     }

Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtkx/WTKXSerializer.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtkx/WTKXSerializer.java?rev=881873&r1=881872&r2=881873&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtkx/WTKXSerializer.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtkx/WTKXSerializer.java Wed Nov 18 18:54:43 2009
@@ -322,6 +322,7 @@
         this.namedSerializers = namedSerializers;
 
         xmlInputFactory = XMLInputFactory.newInstance();
+        xmlInputFactory.setProperty("javax.xml.stream.isCoalescing", true);
 
         scriptEngineManager = new javax.script.ScriptEngineManager();
         scriptEngineManager.setBindings(new NamedObjectBindings());

Modified: incubator/pivot/trunk/wtk/test/org/apache/pivot/wtk/test/TableViewTest2.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/test/org/apache/pivot/wtk/test/TableViewTest2.java?rev=881873&r1=881872&r2=881873&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/test/org/apache/pivot/wtk/test/TableViewTest2.java (original)
+++ incubator/pivot/trunk/wtk/test/org/apache/pivot/wtk/test/TableViewTest2.java Wed Nov 18 18:54:43 2009
@@ -37,15 +37,15 @@
         WTKXSerializer wtkxSerializer = new WTKXSerializer();
         window = (Window)wtkxSerializer.readObject(this, "table_view_test2.wtkx");
         tableView = (TableView)wtkxSerializer.get("tableView");
-        
+
         TableViewRowEditor tableViewRowEditor = new TableViewRowEditor();
         tableViewRowEditor.setEditEffect(CardPaneSkin.SelectionChangeEffect.HORIZONTAL_SLIDE);
         tableView.setRowEditor(tableViewRowEditor);
-        
+
         TextArea textArea = new TextArea();
         textArea.setTextKey("value");
         tableViewRowEditor.getCellEditors().put("value", textArea);
-        
+
         window.open(display);
     }
 

Modified: incubator/pivot/trunk/wtk/test/org/apache/pivot/wtk/test/table_view_test2.wtkx
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/test/org/apache/pivot/wtk/test/table_view_test2.wtkx?rev=881873&r1=881872&r2=881873&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/test/org/apache/pivot/wtk/test/table_view_test2.wtkx (original)
+++ incubator/pivot/trunk/wtk/test/org/apache/pivot/wtk/test/table_view_test2.wtkx Wed Nov 18 18:54:43 2009
@@ -29,7 +29,7 @@
                         <content:TableViewTextAreaCellRenderer />
                     </cellRenderer>
                 </TableView.Column>
-                
+
                 <TableView.Column width="1*"/>
             </columns>
             <tableData>