comparison jface/FileTreeViewer.d @ 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 e7e5002eabcf
children 5fe95b1ccf68
comparison
equal deleted inserted replaced
72:fc7a8f537871 73:9ff9b8f7284b
39 import tango.io.FilePath; 39 import tango.io.FilePath;
40 import tango.util.log.Trace; 40 import tango.util.log.Trace;
41 41
42 import tango.util.collection.model.Seq; 42 import tango.util.collection.model.Seq;
43 import tango.util.collection.ArraySeq; 43 import tango.util.collection.ArraySeq;
44 44 import tango.text.convert.Utf;
45 45
46 void main(){ 46 void main(){
47 auto hw = new FileTree; 47 auto hw = new FileTree;
48 hw.run(); 48 hw.run();
49 } 49 }
127 127
128 public override Object[] getElements( Object arg0 ){ 128 public override Object[] getElements( Object arg0 ){
129 Object[] res; 129 Object[] res;
130 130
131 foreach( root; FileRoots.list()){ 131 foreach( root; FileRoots.list()){
132 // ignore floppy drives, they bring up strange error messages
133 if( root == `A:\`|| root == `B:\` ){
134 continue;
135 }
132 res ~= new FilePath( root ); 136 res ~= new FilePath( root );
133 } 137 }
134 138
135 return res; 139 return res;
136 } 140 }
167 ilpl.labelProviderChanged(event); 171 ilpl.labelProviderChanged(event);
168 } 172 }
169 } 173 }
170 174
171 public override Image getImage(Object arg0){ 175 public override Image getImage(Object arg0){
172 return (cast(FilePath)arg0).isFolder() ? dir : file; 176 auto fp = cast(FilePath)arg0;
177 // is a root
178 if( fp.name.length is 0 ){
179 return dir;
180 }
181 return fp.isFolder() ? dir : file;
173 } 182 }
174 183
175 public override char[] getText(Object arg0){ 184 public override char[] getText(Object arg0){
176 auto text = (cast(FilePath)arg0).name(); 185 auto fp = cast(FilePath)arg0;
186 auto text = fp.name();
177 if( text.length is 0 ){ 187 if( text.length is 0 ){
178 // now take all info, it will be drive or the root folder 188 // now take all info, it will be drive or the root folder
179 text = (cast(FilePath)arg0).toString(); 189 text = fp.toString();
180 } 190 }
181 return preserveCase ? text : text.toUpperCase(); 191 return preserveCase ? text : text.toUpperCase();
182 } 192 }
183 193
184 public void addListener( ILabelProviderListener arg0 ){ 194 public void addListener( ILabelProviderListener arg0 ){