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/08/18 20:26:03 UTC

svn commit: r805526 - in /incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra: TerraFileBrowserSheetSkin.java TerraFileBrowserSkin.java TerraTextInputSkin.java terra_file_browser_skin.wtkx

Author: gbrown
Date: Tue Aug 18 18:26:03 2009
New Revision: 805526

URL: http://svn.apache.org/viewvc?rev=805526&view=rev
Log:
Fix minor bug in TerraTextInputSkin; minor enhancements and additions to file browser/sheet.

Modified:
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraFileBrowserSheetSkin.java
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraFileBrowserSkin.java
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraTextInputSkin.java
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/terra_file_browser_skin.wtkx

Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraFileBrowserSheetSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraFileBrowserSheetSkin.java?rev=805526&r1=805525&r2=805526&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraFileBrowserSheetSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraFileBrowserSheetSkin.java Tue Aug 18 18:26:03 2009
@@ -45,6 +45,20 @@
  * Terra file browser sheet skin.
  */
 public class TerraFileBrowserSheetSkin extends TerraSheetSkin implements FileBrowserSheetListener {
+    private static class SaveToFileFilter implements Filter<File> {
+        public final Filter<File> sourceFilter;
+
+        public SaveToFileFilter(Filter<File> sourceFilter) {
+            this.sourceFilter = sourceFilter;
+        }
+
+        public boolean include(File file) {
+            return (!file.isDirectory()
+                || (sourceFilter != null
+                    && sourceFilter.include(file)));
+        }
+    };
+
     @WTKX private TablePane tablePane = null;
     @WTKX private TablePane.Row saveAsRow = null;
     @WTKX private TextInput saveAsTextInput = null;
@@ -264,8 +278,16 @@
         }
     }
 
-    public void disabledFileFilterChanged(FileBrowserSheet fileBrowserSheet, Filter<File> previousFileFilter) {
-        fileBrowser.setDisabledFileFilter(fileBrowserSheet.getDisabledFileFilter());
+    public void disabledFileFilterChanged(FileBrowserSheet fileBrowserSheet, Filter<File> previousDisabledFileFilter) {
+
+        Filter<File> disabledFileFilter = fileBrowserSheet.getDisabledFileFilter();
+
+        FileBrowserSheet.Mode mode = fileBrowserSheet.getMode();
+        if (mode == FileBrowserSheet.Mode.SAVE_TO) {
+            disabledFileFilter = new SaveToFileFilter(disabledFileFilter);
+        }
+
+        fileBrowser.setDisabledFileFilter(disabledFileFilter);
     }
 
     private void updateOKButtonState() {
@@ -288,7 +310,7 @@
             }
 
             case SAVE_TO: {
-                okButton.setEnabled(selectedDirectoryCount > 0);
+                okButton.setEnabled(selectedFiles.getLength() > 0);
                 break;
             }
         }

Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraFileBrowserSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraFileBrowserSkin.java?rev=805526&r1=805525&r2=805526&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraFileBrowserSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraFileBrowserSkin.java Tue Aug 18 18:26:03 2009
@@ -24,6 +24,7 @@
 import java.util.Date;
 
 import org.apache.pivot.collections.ArrayList;
+import org.apache.pivot.collections.List;
 import org.apache.pivot.collections.Sequence;
 import org.apache.pivot.io.Folder;
 import org.apache.pivot.serialization.SerializationException;
@@ -474,25 +475,39 @@
         fileTableView.requestFocus();
     }
 
+    @SuppressWarnings("unchecked")    
     public void selectedFileAdded(FileBrowser fileBrowser, File file) {
         if (!updatingSelection) {
-            // TODO
+            // TODO This won't work because the table contains absolute files, while the selection
+            // does not
+            List<File> fileTableData = (List<File>)fileTableView.getTableData();
+            int index = fileTableData.indexOf(file);
+            if (index != -1) {
+                fileTableView.addSelectedIndex(index);
+            }
         }
     }
 
+    @SuppressWarnings("unchecked")
     public void selectedFileRemoved(FileBrowser fileBrowser, File file) {
         if (!updatingSelection) {
-            // TODO
+            // TODO This won't work because the table contains absolute files, while the selection
+            // does not
+            List<File> fileTableData = (List<File>)fileTableView.getTableData();
+            int index = fileTableData.indexOf(file);
+            if (index != -1) {
+                fileTableView.removeSelectedIndex(index);
+            }
         }
     }
 
     public void selectedFilesChanged(FileBrowser fileBrowser, Sequence<File> previousSelectedFiles) {
         if (!updatingSelection) {
-            // TODO
+            // TODO Reset the selection
         }
     }
 
-    public void disabledFileFilterChanged(FileBrowser fileBrowser, Filter<File> previousFileFilter) {
+    public void disabledFileFilterChanged(FileBrowser fileBrowser, Filter<File> previousDisabledFileFilter) {
         fileTableView.setDisabledRowFilter(fileBrowser.getDisabledFileFilter());
     }
 

Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraTextInputSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraTextInputSkin.java?rev=805526&r1=805525&r2=805526&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraTextInputSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraTextInputSkin.java Tue Aug 18 18:26:03 2009
@@ -1245,7 +1245,7 @@
 
     // Text input events
     public void textNodeChanged(TextInput textInput, TextNode previousTextNode) {
-        updateSelection();
+        updateSelection(0);
     }
 
     public void textSizeChanged(TextInput textInput, int previousTextSize) {
@@ -1278,7 +1278,7 @@
 
     // Text input character events
     public void charactersInserted(TextInput textInput, int index, int count) {
-        updateSelection();
+        updateSelection(0);
     }
 
     public void charactersRemoved(TextInput textInput, int index, int count) {
@@ -1294,16 +1294,28 @@
             scrollLeft = Math.max(textWidth + (padding.left + padding.right + 2) - width, 0);
         }
 
-        updateSelection();
+        updateSelection(0);
     }
 
     // Text input selection events
     public void selectionChanged(TextInput textInput, int previousSelectionStart,
         int previousSelectionLength) {
-        updateSelection();
+        int selectionStart = textInput.getSelectionStart();
+        int selectionLength = textInput.getSelectionLength();
+
+        int bias;
+        if (selectionStart < previousSelectionStart) {
+            bias = -1;
+        } else if (selectionLength > previousSelectionLength) {
+            bias = 1;
+        } else {
+            bias = 0;
+        }
+
+        updateSelection(bias);
     }
 
-    private void updateSelection() {
+    private void updateSelection(int bias) {
         // Update the selection bounding box
         String text = getText();
 
@@ -1336,7 +1348,8 @@
                 Rectangle2D caretBounds = caretShapes[0].getBounds();
                 int caretLeft = (int)caretBounds.getX();
 
-                if (caretLeft - scrollLeft < 0) {
+                if (caretLeft - scrollLeft < 0
+                    && bias <= 0) {
                     // Ensure that the left edge of caret is visible
                     scrollLeft = caretLeft;
                 } else {
@@ -1352,7 +1365,8 @@
                 Rectangle2D logicalHighlightBounds = logicalHighlightShape.getBounds();
                 int logicalHighlightLeft = (int)logicalHighlightBounds.getX();
 
-                if (logicalHighlightLeft - scrollLeft < 0) {
+                if (logicalHighlightLeft - scrollLeft < 0
+                    && bias <= 0) {
                     // Ensure that the left edge of the highlight is visible
                     scrollLeft = logicalHighlightLeft;
                 } else {

Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/terra_file_browser_skin.wtkx
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/terra_file_browser_skin.wtkx?rev=805526&r1=805525&r2=805526&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/terra_file_browser_skin.wtkx (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/terra_file_browser_skin.wtkx Tue Aug 18 18:26:03 2009
@@ -52,7 +52,8 @@
                                     <content:ButtonData icon="@folder_up.png"/>
                                 </buttonData>
                             </PushButton>
-                            <PushButton wtkx:id="newFolderButton" styles="{toolbar:true}" tooltipText="%newFolder">
+                            <PushButton wtkx:id="newFolderButton" styles="{toolbar:true}" tooltipText="%newFolder"
+                                visible="false">
                                 <buttonData>
                                     <content:ButtonData icon="@folder_add.png"/>
                                 </buttonData>