[Bojangles-cvs] cvs: bojangles / MainWindow.java
Status: Alpha
Brought to you by:
nehresma
|
From: nehresma <boj...@li...> - 2002-08-22 02:51:31
|
nehresma Wed Aug 21 19:51:30 2002 EDT
Modified files:
/bojangles MainWindow.java
Log:
check to make sure the preferences file exists before attempting to read
from it.
Index: bojangles/MainWindow.java
diff -u bojangles/MainWindow.java:1.14 bojangles/MainWindow.java:1.15
--- bojangles/MainWindow.java:1.14 Tue Aug 20 15:32:24 2002
+++ bojangles/MainWindow.java Wed Aug 21 19:51:30 2002
@@ -16,16 +16,6 @@
import org.dom4j.io.*;
-/*
- * MainWindow.java
- *
- * Created on June 24, 2002, 8:46 PM
- */
-
-/**
- *
- * @author Nathan Ehresman
- */
public class MainWindow extends javax.swing.JFrame implements ElementFocusListener, TableModelListener {
/**
* The correlation table linking JTreeNode, Widget, and XML path.
@@ -630,36 +620,36 @@
}
private void loadPrefrences() {
- try {
- File prefFile = new File("prefs.xml");
- if (null == prefFile) {
- System.out.println("No saved prefrences...");
- // Lets make a document anyway to write collected prefrences to...
- // Document prefDocument = new SAXDocument();
- prefDocument = DocumentHelper.createDocument();
- }
- else {
- System.out.println("Loading prefrences from prefs.xml");
- prefDocument = new SAXReader().read("prefs.xml");
- sdir = new File(prefDocument.selectSingleNode("/prefrences/prefSaveDir").getText());
- lastfile = prefDocument.selectSingleNode("/prefrences/lastFileSaved").getText();
- prefBrowser = prefDocument.selectSingleNode("/prefrences/browser").getText();
- prefHost = prefDocument.selectSingleNode("/prefrences/testHost").getText();
- prefPort = prefDocument.selectSingleNode("/prefrences/testPort").getText();
- prefPath = prefDocument.selectSingleNode("/prefrences/testPath").getText();
- System.out.println("URL: http://" + prefHost + ":" + prefPort + "/" + prefPath + "/" + lastfile);
- System.out.println("Load ok!");
- }
- }
- catch (Exception e) {
- e.printStackTrace();
+ try {
+ File prefFile = new File("prefs.xml");
+ if (null == prefFile)
+ return;
+ else if (!prefFile.exists()) {
+ System.out.println("No saved prefrences...");
+ // Lets make a document anyway to write collected prefrences to...
+ // Document prefDocument = new SAXDocument();
+ prefDocument = DocumentHelper.createDocument();
+ } else {
+ System.out.println("Loading prefrences from prefs.xml");
+ prefDocument = new SAXReader().read("prefs.xml");
+ sdir = new File(prefDocument.selectSingleNode("/prefrences/prefSaveDir").getText());
+ lastfile = prefDocument.selectSingleNode("/prefrences/lastFileSaved").getText();
+ prefBrowser = prefDocument.selectSingleNode("/prefrences/browser").getText();
+ prefHost = prefDocument.selectSingleNode("/prefrences/testHost").getText();
+ prefPort = prefDocument.selectSingleNode("/prefrences/testPort").getText();
+ prefPath = prefDocument.selectSingleNode("/prefrences/testPath").getText();
+ System.out.println("URL: http://" + prefHost + ":" + prefPort + "/" + prefPath + "/" + lastfile);
+ System.out.println("Load ok!");
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
}
}
private void appModified(boolean moded) {
- appModified = moded;
- if(moded) this.setTitle(curTitle + "*");
- else this.setTitle(curTitle);
+ appModified = moded;
+ if(moded) this.setTitle(curTitle + "*");
+ else this.setTitle(curTitle);
}
private void saveXML() {
|