Update of /cvsroot/jreepad/jreepad/src/jreepad
In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv27250/src/jreepad
Modified Files:
JreepadTreeModel.java JreepadViewer.java
Log Message:
Fixes to the file saving and loading code
Index: JreepadViewer.java
===================================================================
RCS file: /cvsroot/jreepad/jreepad/src/jreepad/JreepadViewer.java,v
retrieving revision 1.58
retrieving revision 1.59
diff -C2 -d -r1.58 -r1.59
*** JreepadViewer.java 26 Mar 2007 13:28:16 -0000 1.58
--- JreepadViewer.java 3 Apr 2007 12:41:30 -0000 1.59
***************
*** 1281,1286 ****
setCursor(Cursor.getDefaultCursor());
updateUndoRedoMenuState();
- validate();
- repaint();
} // End of: openAction()
--- 1281,1284 ----
***************
*** 1307,1310 ****
--- 1305,1310 ----
getPrefs().exportLocation = getPrefs().importLocation = file;
setTitleBasedOnFilename(file.getName());
+ validate();
+ repaint();
return true;
}
***************
*** 1343,1351 ****
{
int fileType = getPrefs().mainFileType;
File saveLocation = document.getSaveLocation();
if(askForFilename || saveLocation==null || (saveLocation.isFile() && !saveLocation.canWrite()))
{
// Ask for filename
! JFileChooser fileChooser = new SaveFileChooser(getPrefs().mainFileType);
fileChooser.setCurrentDirectory(getPrefs().openLocation);
--- 1343,1354 ----
{
int fileType = getPrefs().mainFileType;
+ if (document.getSaveLocation() != null)
+ fileType = document.getFileType();
+
File saveLocation = document.getSaveLocation();
if(askForFilename || saveLocation==null || (saveLocation.isFile() && !saveLocation.canWrite()))
{
// Ask for filename
! SaveFileChooser fileChooser = new SaveFileChooser(getPrefs().mainFileType);
fileChooser.setCurrentDirectory(getPrefs().openLocation);
***************
*** 1358,1365 ****
}
saveLocation = fileChooser.getSelectedFile();
! if (fileChooser.getFileFilter() == SaveFileChooser.JREEPAD_FILE_FILTER)
! fileType = JreepadPrefs.FILETYPE_XML;
! else if (fileChooser.getFileFilter() == SaveFileChooser.TREEPAD_FILE_FILTER)
! fileType = JreepadPrefs.FILETYPE_HJT;
}
getPrefs().openLocation = saveLocation; // Remember the file's directory
--- 1361,1365 ----
}
saveLocation = fileChooser.getSelectedFile();
! fileType = fileChooser.getFileType();
}
getPrefs().openLocation = saveLocation; // Remember the file's directory
***************
*** 1383,1386 ****
--- 1383,1387 ----
else
writer = new TreepadWriter(encoding);
+
OutputStream fos = new FileOutputStream(saveLocation);
writer.write(fos, document);
***************
*** 1391,1395 ****
--- 1392,1401 ----
appleAppCode, appleAppCode);
}
+
+ // When calling "Save As..." remember the _new_ file settings
document.setSaveLocation(saveLocation);
+ document.setFileType(fileType);
+ document.setEncoding(encoding);
+
updateWindowTitle();
addToOpenRecentMenu(saveLocation);
Index: JreepadTreeModel.java
===================================================================
RCS file: /cvsroot/jreepad/jreepad/src/jreepad/JreepadTreeModel.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** JreepadTreeModel.java 26 Mar 2007 11:49:24 -0000 1.5
--- JreepadTreeModel.java 3 Apr 2007 12:41:30 -0000 1.6
***************
*** 21,25 ****
* Format of the loaded file.
*/
! private int fileFormat = -1;
/**
--- 21,25 ----
* Format of the loaded file.
*/
! private int fileType = -1;
/**
***************
*** 91,97 ****
}
! public void setFileFormat(int fileFormat)
{
! this.fileFormat = fileFormat;
}
--- 91,97 ----
}
! public void setFileType(int fileType)
{
! this.fileType = fileType;
}
***************
*** 101,107 ****
}
! public int getFileFormat()
{
! return fileFormat;
}
--- 101,107 ----
}
! public int getFileType()
{
! return fileType;
}
|