Minor bug fix. Now allows a config file to be created if it does not exist.

committer: Jonathan Bernard <jdbernard@gmail.com>
This commit is contained in:
Jonathan Bernard 2008-08-29 18:27:48 -05:00
parent cb419c658f
commit ed5bdce87c
3 changed files with 15 additions and 17 deletions

View File

@ -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"));
}
/**

View File

@ -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());
}
}
}

View File

@ -1,4 +0,0 @@
#
#Fri Aug 29 18:18:08 CDT 2008
lastUsedTimelineFilename=default-timeline.txt
lastUsedTimelineFile=default-timeline.txt