[kaffe] CVS kaffe (riccardo): solved NPE on up in /, made left pane display only topmost directory in path

Kaffe CVS cvs-commits at kaffe.org
Fri May 5 16:58:29 PDT 2006


PatchSet 7284 
Date: 2006/05/05 23:35:03
Author: riccardo
Branch: HEAD
Tag: (none) 
Log:
solved NPE on up in /, made left pane display only topmost directory in path

Members: 
	ChangeLog:1.4788->1.4789 
	libraries/javalib/awt-implementations/kaffe/java/awt/FileDialog.java:1.2->1.3 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.4788 kaffe/ChangeLog:1.4789
--- kaffe/ChangeLog:1.4788	Fri May  5 23:26:11 2006
+++ kaffe/ChangeLog	Fri May  5 23:35:03 2006
@@ -1,5 +1,10 @@
 2006-05-06  Riccardo Mottola <riccardo at kaffe.org>
 
+	* libraries/javalib/awt-implementations/kaffe/java/awt/FileDialog.java:
+	solved NPE, made left pane display only topmost directory in path
+	
+2006-05-06  Riccardo Mottola <riccardo at kaffe.org>
+
 	* libraries/javalib/awt-implementations/kaffe/java/awt/ScrollPaneAdjustable.java:
 	removed, so to use classath
 
Index: kaffe/libraries/javalib/awt-implementations/kaffe/java/awt/FileDialog.java
diff -u kaffe/libraries/javalib/awt-implementations/kaffe/java/awt/FileDialog.java:1.2 kaffe/libraries/javalib/awt-implementations/kaffe/java/awt/FileDialog.java:1.3
--- kaffe/libraries/javalib/awt-implementations/kaffe/java/awt/FileDialog.java:1.2	Fri Feb 17 00:28:57 2006
+++ kaffe/libraries/javalib/awt-implementations/kaffe/java/awt/FileDialog.java	Fri May  5 23:35:11 2006
@@ -45,6 +45,7 @@
 	File tmpFile;
 	List lDirs = new List();
 	List lFiles = new List();
+	Vector vDirs = new Vector();
 
 public FileDialog( Frame parent) {
 	this( parent, null, LOAD);
@@ -94,10 +95,11 @@
 		dispose();
 	}
 	else if ( s == lDirs ) {
-		String d = lDirs.getSelectedItem();
-		if ( d == upDir )
-			loadSubs( new File( dir.getParent()) );
-		else
+		String d = (String)vDirs.elementAt(lDirs.getSelectedIndex());
+		if ( d == upDir ) {
+			if ( ! dir.getPath().equals( File.separator) )
+				loadSubs( new File( dir.getParent()) );
+		} else
 			loadSubs( new File( d) );
 	}
 	else if ( s == lFiles ) {
@@ -260,7 +262,7 @@
 	String is;
 
 	if ( s == lDirs ) {
-		is = lDirs.getSelectedItem();
+		is = (String)vDirs.elementAt(lDirs.getSelectedIndex());
 		if ( is != upDir ) {
 			dir = new File( is );
 			tFile.setText( dir.getPath() );
@@ -297,7 +299,7 @@
 	String dn = dir.getPath();
 	boolean up = (dn.length() == 0);
 	String[] all;
-	
+
 	if ( up )
 		dir = new File( File.separator);
 
@@ -305,6 +307,7 @@
 		
 	lFiles.removeAll();
 	lDirs.removeAll();
+	vDirs.removeAllElements();
 	
 	// fake visibility to disable redraw while filling in new contents
 	lFiles.flags &= ~IS_VISIBLE;
@@ -313,14 +316,19 @@
 	this.dir = dir;
 	tFile.setText( dir.getPath() );
 
-	if ( ! up)	
+	if (!up) {
 		lDirs.add( upDir);
+		vDirs.add( upDir);
+	}
 		
 	for ( int i=0; i<all.length; i++) {
 		File f = up ? new File( dir + all[i]) : new File( dir + File.separator + all[i]);
 		if ( f.isDirectory() ) {
 			String pn = f.getPath();
-			lDirs.addItem( pn, sortIdx( lDirs.ip.rows, pn) );
+			int idx = sortIdx( lDirs.ip.rows, pn);
+
+			lDirs.addItem( pn.substring(pn.lastIndexOf('/') + 1), idx);
+			vDirs.insertElementAt( pn, idx );
 		}
 		else if ( ! isFiltered( dir, all[i] ) )
 			lFiles.addItem( all[i], sortIdx( lFiles.ip.rows, all[i]) );




More information about the kaffe mailing list