[Jreepad-CVS] jreepad/src/jreepad JreepadTreeModel.java, 1.3, 1.4 JreepadPrefs.java, 1.24, 1.25 Jre
Brought to you by:
danstowell
From: PeWu <pe...@us...> - 2007-03-23 09:37:41
|
Update of /cvsroot/jreepad/jreepad/src/jreepad In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv28832/src/jreepad Modified Files: JreepadTreeModel.java JreepadPrefs.java JreepadViewer.java Log Message: Moved the path to the currently open file (savedLocation) to JreepadTreeModel Index: JreepadPrefs.java =================================================================== RCS file: /cvsroot/jreepad/jreepad/src/jreepad/JreepadPrefs.java,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** JreepadPrefs.java 1 Mar 2007 12:10:59 -0000 1.24 --- JreepadPrefs.java 23 Mar 2007 09:37:36 -0000 1.25 *************** *** 41,45 **** { Preferences prefs; ! File openLocation, saveLocation, importLocation, exportLocation, backupLocation; boolean seenLicense; --- 41,45 ---- { Preferences prefs; ! File openLocation, importLocation, exportLocation, backupLocation; boolean seenLicense; *************** *** 77,81 **** Vector openRecentList; int openRecentListLength; ! File getMostRecentFile() // This is used, specifically, by the command-line "find" tool { if(openRecentList.size()==0) --- 77,81 ---- Vector openRecentList; int openRecentListLength; ! File getMostRecentFile() { if(openRecentList.size()==0) *************** *** 143,147 **** openLocation = new File(prefs.get("OPENLOCATION", System.getProperty("user.home"))); - saveLocation = new File(prefs.get("SAVELOCATION", System.getProperty("user.home"))); importLocation = new File(prefs.get("IMPORTLOCATION", System.getProperty("user.home"))); exportLocation = new File(prefs.get("EXPORTLOCATION", System.getProperty("user.home"))); --- 143,146 ---- *************** *** 253,257 **** { prefs.put("OPENLOCATION",""+openLocation); - prefs.put("SAVELOCATION", ""+saveLocation); prefs.put("IMPORTLOCATION", ""+importLocation); prefs.put("EXPORTLOCATION", ""+exportLocation); --- 252,255 ---- Index: JreepadViewer.java =================================================================== RCS file: /cvsroot/jreepad/jreepad/src/jreepad/JreepadViewer.java,v retrieving revision 1.55 retrieving revision 1.56 diff -C2 -d -r1.55 -r1.56 *** JreepadViewer.java 21 Mar 2007 10:40:35 -0000 1.55 --- JreepadViewer.java 23 Mar 2007 09:37:36 -0000 1.56 *************** *** 268,272 **** yield(); // ...then if the saveLocation != null, trigger saveAction() ! if(getPrefs().autoSave && getPrefs().saveLocation != null) new SaveAction().actionPerformed(null); else --- 268,272 ---- yield(); // ...then if the saveLocation != null, trigger saveAction() ! if(getPrefs().autoSave && document.getSaveLocation() != null) new SaveAction().actionPerformed(null); else *************** *** 294,299 **** if(fileNameToLoad != "") firstTimeFile = new File(fileNameToLoad); ! else if(getPrefs().loadLastFileOnOpen && getPrefs().saveLocation != null) ! firstTimeFile = getPrefs().saveLocation; if(firstTimeFile != null && firstTimeFile.isFile()) --- 294,299 ---- if(fileNameToLoad != "") firstTimeFile = new File(fileNameToLoad); ! else if(getPrefs().loadLastFileOnOpen && getPrefs().getMostRecentFile() != null) ! firstTimeFile = getPrefs().getMostRecentFile(); if(firstTimeFile != null && firstTimeFile.isFile()) *************** *** 301,319 **** try { ! getPrefs().openLocation = firstTimeFile; content.remove(theJreepad); ! InputStream in = new FileInputStream(getPrefs().openLocation); JreepadReader reader = new AutoDetectReader(getPrefs().getEncoding(), getPrefs().autoDetectHtmlArticles); document = new JreepadTreeModel(reader.read(in)); theJreepad = new JreepadView(document); ! getPrefs().saveLocation = getPrefs().exportLocation = getPrefs().importLocation = getPrefs().openLocation; content.add(theJreepad); searchDialog.setJreepad(theJreepad); ! getPrefs().saveLocation = getPrefs().openLocation; ! setTitleBasedOnFilename(getPrefs().openLocation.getName()); ! document.setContentSaved(true); } catch(IOException err) --- 301,318 ---- try { ! getPrefs().openLocation = firstTimeFile; // Remember the open directory content.remove(theJreepad); ! InputStream in = new FileInputStream(firstTimeFile); JreepadReader reader = new AutoDetectReader(getPrefs().getEncoding(), getPrefs().autoDetectHtmlArticles); document = new JreepadTreeModel(reader.read(in)); + document.setSaveLocation(firstTimeFile); theJreepad = new JreepadView(document); ! getPrefs().exportLocation = getPrefs().importLocation = firstTimeFile; content.add(theJreepad); searchDialog.setJreepad(theJreepad); ! setTitleBasedOnFilename(firstTimeFile.getName()); } catch(IOException err) *************** *** 328,333 **** } } - else - getPrefs().saveLocation = null; // Set close operation --- 327,330 ---- *************** *** 360,372 **** setVisible(true); ! // If loading the last-saved file, expand the nodes we last had open ! if(fileNameToLoad == "" ! && getPrefs().loadLastFileOnOpen ! && getPrefs().saveLocation != null ! && getPrefs().treePathCollection != null ! && getPrefs().treePathCollection.paths != null) ! { ! theJreepad.expandPaths(getPrefs().treePathCollection.paths); ! } theJreepad.returnFocusToTree(); } --- 357,364 ---- setVisible(true); ! // If loading the last-saved file, expand the nodes we last had open ! if(document.getSaveLocation() != null) ! theJreepad.expandPaths(getPrefs().treePathCollection.paths); ! theJreepad.returnFocusToTree(); } *************** *** 1281,1285 **** private boolean askAndSave(String prompt) { ! if (document == null || document.isContentSaved()) return true; int answer = JOptionPane.showConfirmDialog(this, prompt, --- 1273,1277 ---- private boolean askAndSave(String prompt) { ! if (document.isContentSaved()) return true; int answer = JOptionPane.showConfirmDialog(this, prompt, *************** *** 1305,1309 **** document = new JreepadTreeModel(); theJreepad = new JreepadView(document); - getPrefs().saveLocation = null; content.add(theJreepad); searchDialog.setJreepad(theJreepad); --- 1297,1300 ---- *************** *** 1336,1353 **** content.remove(theJreepad); ! InputStream in = new FileInputStream(getPrefs().openLocation); JreepadReader reader = new AutoDetectReader(getPrefs().getEncoding(), getPrefs().autoDetectHtmlArticles); document = new JreepadTreeModel(reader.read(in)); theJreepad = new JreepadView(document); - getPrefs().saveLocation = getPrefs().openLocation; content.add(theJreepad); searchDialog.setJreepad(theJreepad); ! addToOpenRecentMenu(getPrefs().openLocation); ! setTitleBasedOnFilename(getPrefs().openLocation.getName()); validate(); repaint(); - document.setContentSaved(true); //DEL theJreepad.clearUndoCache(); setCursor(Cursor.getDefaultCursor()); --- 1327,1343 ---- content.remove(theJreepad); ! InputStream in = new FileInputStream(f); JreepadReader reader = new AutoDetectReader(getPrefs().getEncoding(), getPrefs().autoDetectHtmlArticles); document = new JreepadTreeModel(reader.read(in)); + document.setSaveLocation(f); theJreepad = new JreepadView(document); content.add(theJreepad); searchDialog.setJreepad(theJreepad); ! addToOpenRecentMenu(f); ! setTitleBasedOnFilename(f.getName()); validate(); repaint(); //DEL theJreepad.clearUndoCache(); setCursor(Cursor.getDefaultCursor()); *************** *** 1395,1403 **** { int fileType = getPrefs().mainFileType; ! if(askForFilename || getPrefs().saveLocation==null || (getPrefs().saveLocation.isFile() && !getPrefs().saveLocation.canWrite())) { // Ask for filename JFileChooser fileChooser = new SaveFileChooser(); ! fileChooser.setCurrentDirectory(getPrefs().saveLocation); fileChooser.addChoosableFileFilter(JREEPAD_FILE_FILTER); fileChooser.addChoosableFileFilter(TREEPAD_FILE_FILTER); --- 1385,1394 ---- { int fileType = getPrefs().mainFileType; ! File saveLocation = document.getSaveLocation(); ! if(askForFilename || saveLocation==null || (saveLocation.isFile() && !saveLocation.canWrite())) { // Ask for filename JFileChooser fileChooser = new SaveFileChooser(); ! fileChooser.setCurrentDirectory(getPrefs().openLocation); fileChooser.addChoosableFileFilter(JREEPAD_FILE_FILTER); fileChooser.addChoosableFileFilter(TREEPAD_FILE_FILTER); *************** *** 1414,1418 **** return; // No file chosen } ! getPrefs().saveLocation = fileChooser.getSelectedFile(); if (fileChooser.getFileFilter() == JREEPAD_FILE_FILTER) fileType = JreepadPrefs.FILETYPE_XML; --- 1405,1409 ---- return; // No file chosen } ! saveLocation = fileChooser.getSelectedFile(); if (fileChooser.getFileFilter() == JREEPAD_FILE_FILTER) fileType = JreepadPrefs.FILETYPE_XML; *************** *** 1420,1423 **** --- 1411,1415 ---- fileType = JreepadPrefs.FILETYPE_HJT; } + getPrefs().openLocation = saveLocation; // Remember the file's directory // Save the file *************** *** 1432,1445 **** else writer = new TreepadWriter(getPrefs().getEncoding()); ! OutputStream fos = new FileOutputStream(getPrefs().saveLocation); writer.write(fos, document.getRootNode()); fos.close(); if(MAC_OS_X){ ! com.apple.eio.FileManager.setFileTypeAndCreator(getPrefs().saveLocation.toString(), appleAppCode, appleAppCode); } ! document.setContentSaved(true); updateWindowTitle(); savePreferencesFile(); setCursor(Cursor.getDefaultCursor()); --- 1424,1438 ---- else writer = new TreepadWriter(getPrefs().getEncoding()); ! OutputStream fos = new FileOutputStream(saveLocation); writer.write(fos, document.getRootNode()); fos.close(); if(MAC_OS_X){ ! com.apple.eio.FileManager.setFileTypeAndCreator(saveLocation.toString(), appleAppCode, appleAppCode); } ! document.setSaveLocation(saveLocation); updateWindowTitle(); + addToOpenRecentMenu(saveLocation); savePreferencesFile(); setCursor(Cursor.getDefaultCursor()); *************** *** 1502,1506 **** private void updateWindowTitle() { ! setTitle(windowTitle + ((document == null || document.isContentSaved())?"":"*") + (getPrefs().autoSave?" ["+lang.getString("AUTOSAVE_ACTIVE")+"]":"")); } --- 1495,1499 ---- private void updateWindowTitle() { ! setTitle(windowTitle + (document.isContentSaved()?"":"*") + (getPrefs().autoSave?" ["+lang.getString("AUTOSAVE_ACTIVE")+"]":"")); } Index: JreepadTreeModel.java =================================================================== RCS file: /cvsroot/jreepad/jreepad/src/jreepad/JreepadTreeModel.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** JreepadTreeModel.java 21 Mar 2007 09:40:52 -0000 1.3 --- JreepadTreeModel.java 23 Mar 2007 09:37:36 -0000 1.4 *************** *** 1,4 **** --- 1,6 ---- package jreepad; + import java.io.File; + import javax.swing.tree.DefaultTreeModel; import javax.swing.tree.TreePath; *************** *** 12,15 **** --- 14,22 ---- { /** + * The location, where the document was last saved. + */ + private File saveLocation = null; + + /** * True if the current document content has been saved. */ *************** *** 67,69 **** --- 74,87 ---- this.contentSaved = contentSaved; } + + public void setSaveLocation(File saveLocation) + { + this.saveLocation = saveLocation; + setContentSaved(true); + } + + public File getSaveLocation() + { + return saveLocation; + } } |