diff --git a/src/jdbernard/timestamper/TimeStamperApp.java b/src/jdbernard/timestamper/TimeStamperApp.java index 04f4f66..b74fbd9 100755 --- a/src/jdbernard/timestamper/TimeStamperApp.java +++ b/src/jdbernard/timestamper/TimeStamperApp.java @@ -4,6 +4,7 @@ package jdbernard.timestamper; +import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; @@ -51,19 +52,16 @@ implements Application.ExitListener { try { config = new Properties(); - FileInputStream cfgIn = new FileInputStream("timestamper.config"); + File cfgFile = new File("timestamper.config"); + if (!cfgFile.exists()) cfgFile.createNewFile(); + FileInputStream cfgIn = new FileInputStream(cfgFile); config.load(cfgIn); cfgIn.close(); } catch (IOException ioe) { log.warning("Could not load configuration options."); } - try { - activeTimeline = Timeline.readFromFile( - config.getProperty("lastUsedTimelineFilename")); - } catch (IOException ioe) { - log.warning("Could not load the last used timeline file."); - } + loadTimeline(config.getProperty("lastUsedTimelineFilename")); } /** diff --git a/src/jdbernard/timestamper/TimeStamperView.java b/src/jdbernard/timestamper/TimeStamperView.java index 1fd9796..30b8b57 100755 --- a/src/jdbernard/timestamper/TimeStamperView.java +++ b/src/jdbernard/timestamper/TimeStamperView.java @@ -73,10 +73,12 @@ public class TimeStamperView extends FrameView implements MouseMotionListener { Timeline t = ((TimeStamperApp) getApplication()).getActiveTimeline(); Timeline.TimelineMarker lastMarker = t.getLastMarker(new Date()); - mostRecentTask = lastMarker.getTimestamp(); - startTimeLabel.setText(Timeline.shortFormat.format(lastMarker.getTimestamp())); + if (lastMarker != null) { + mostRecentTask = lastMarker.getTimestamp(); + startTimeLabel.setText(Timeline.shortFormat.format(lastMarker.getTimestamp())); - taskTextField.setText(lastMarker.getMark()); + taskTextField.setText(lastMarker.getMark()); + } } /** This method is called from within the constructor to @@ -401,9 +403,11 @@ private void optionsButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIR Timeline t = ((TimeStamperApp) getApplication()).getActiveTimeline(); Timeline.TimelineMarker lastMarker = t.getLastMarker(new Date()); - mostRecentTask = lastMarker.getTimestamp(); - startTimeLabel.setText(Timeline.shortFormat.format(lastMarker.getTimestamp())); + if (lastMarker != null) { + mostRecentTask = lastMarker.getTimestamp(); + startTimeLabel.setText(Timeline.shortFormat.format(lastMarker.getTimestamp())); - taskTextField.setText(lastMarker.getMark()); + taskTextField.setText(lastMarker.getMark()); + } } } diff --git a/timestamper.config b/timestamper.config deleted file mode 100755 index e8de75c..0000000 --- a/timestamper.config +++ /dev/null @@ -1,4 +0,0 @@ -# -#Fri Aug 29 18:18:08 CDT 2008 -lastUsedTimelineFilename=default-timeline.txt -lastUsedTimelineFile=default-timeline.txt