changeset 73:9ff9b8f7284b

FileTreeViewer now work on windows without error dialog.
author Frank Benoit <benoit@tionex.de>
date Sun, 13 Apr 2008 20:55:55 +0200
parents fc7a8f537871
children 4742b5384719
files .hgignore jface/FileTreeViewer.d jface/Librarian.d
diffstat 3 files changed, 25 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/.hgignore	Sun Apr 13 17:19:38 2008 +0200
+++ b/.hgignore	Sun Apr 13 20:55:55 2008 +0200
@@ -5,6 +5,7 @@
 *.map
 *.exe
 *.bak
+*.rf
 
 syntax: regexp
 ^build.sh$
@@ -16,8 +17,8 @@
 ^dwtexamples/addressbook/AddressBook$
 ^dwtexamples/controlexample/ControlExample$
 ^dwtexamples/controlexample/CustomControlExample$
+^dwtexamples/texteditor/TextEditor$
 ^dwtsnippets/.*/Snippet[0-9]*$
-
 ^user/torhu_synctest$
 ^user/drawingboard/DrawingBoard$
 ^user/dragdrop/texttolabel$
--- a/jface/FileTreeViewer.d	Sun Apr 13 17:19:38 2008 +0200
+++ b/jface/FileTreeViewer.d	Sun Apr 13 20:55:55 2008 +0200
@@ -41,7 +41,7 @@
 
 import tango.util.collection.model.Seq;
 import tango.util.collection.ArraySeq;
-
+import tango.text.convert.Utf;
 
 void main(){
     auto hw = new FileTree;
@@ -129,6 +129,10 @@
         Object[] res;
 
         foreach( root; FileRoots.list()){
+            // ignore floppy drives, they bring up strange error messages
+            if( root == `A:\`|| root == `B:\` ){
+                continue;
+            }
             res ~= new FilePath( root );
         }
 
@@ -169,14 +173,20 @@
     }
 
     public override Image getImage(Object arg0){
-        return (cast(FilePath)arg0).isFolder() ? dir : file;
+        auto fp = cast(FilePath)arg0;
+        // is a root
+        if( fp.name.length is 0 ){
+            return dir;
+        }
+        return fp.isFolder() ? dir : file;
     }
 
     public override char[] getText(Object arg0){
-        auto text = (cast(FilePath)arg0).name();
+        auto fp = cast(FilePath)arg0;
+        auto text = fp.name();
         if( text.length is 0 ){
             // now take all info, it will be drive or the root folder
-            text = (cast(FilePath)arg0).toString();
+            text = fp.toString();
         }
         return preserveCase ? text : text.toUpperCase();
     }
--- a/jface/Librarian.d	Sun Apr 13 17:19:38 2008 +0200
+++ b/jface/Librarian.d	Sun Apr 13 20:55:55 2008 +0200
@@ -57,12 +57,6 @@
 
 version(JIVE) import jive.stacktrace;
 
-/++
-    Known Problem:
-        Blocks in Save Method
-        Not prepared for windows.
-++/
-
 /**
  * The application entry point
  *
@@ -361,8 +355,8 @@
         }
     }
     /**
-    * Creates a new file
-    */
+     * Creates a new file
+     */
     public void newFile() {
         if (checkOverwrite()) {
         library = new Library();
@@ -371,8 +365,8 @@
     }
 
     /**
-    * Saves the current file
-    */
+     * Saves the current file
+     */
     public void saveFile() {
         String fileName = library.getFileName();
         if (fileName is null) {
@@ -385,10 +379,10 @@
     }
 
     /**
-    * Saves the current file using the specified file name
-    *
-    * @param fileName the file name
-    */
+     * Saves the current file using the specified file name
+     *
+     * @param fileName the file name
+     */
     public void saveFileAs(String fileName) {
         // Disable the actions, so user can't change file while it's saving
         enableActions(false);
@@ -433,7 +427,7 @@
 
         // Repack the columns
         for (int i = 0, n = viewer.getTable().getColumnCount(); i < n; i++) {
-        viewer.getTable().getColumn(i).pack();
+            viewer.getTable().getColumn(i).pack();
         }
 
         getStatusLineManager().setMessage(