Initial working version checkin.
committer: Jonathan Bernard <jdbernard@gmail.com>
This commit is contained in:
parent
373f813c7c
commit
cb419c658f
@ -1,6 +1,7 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
./clean_trailing_whitespace.sh build.xml
|
./clean_trailing_whitespace.sh build.xml
|
||||||
|
./clean_trailing_whitespace.sh timestamper.config
|
||||||
./clean_trailing_whitespace.sh src/jdbernard/timestamper/*.java
|
./clean_trailing_whitespace.sh src/jdbernard/timestamper/*.java
|
||||||
./clean_trailing_whitespace.sh src/jdbernard/timestamper/*.form
|
./clean_trailing_whitespace.sh src/jdbernard/timestamper/*.form
|
||||||
./clean_trailing_whitespace.sh src/jdbernard/timestamper/resources/*.properties
|
./clean_trailing_whitespace.sh src/jdbernard/timestamper/resources/*.properties
|
||||||
|
@ -4,20 +4,75 @@
|
|||||||
|
|
||||||
package jdbernard.timestamper;
|
package jdbernard.timestamper;
|
||||||
|
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.EventObject;
|
||||||
|
import java.util.Properties;
|
||||||
|
import java.util.logging.ConsoleHandler;
|
||||||
|
import java.util.logging.FileHandler;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
import org.jdesktop.application.Application;
|
import org.jdesktop.application.Application;
|
||||||
import org.jdesktop.application.SingleFrameApplication;
|
import org.jdesktop.application.SingleFrameApplication;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The main class of the application.
|
* The main class of the application.
|
||||||
*/
|
*/
|
||||||
public class TimeStamperApp extends SingleFrameApplication {
|
public class TimeStamperApp extends SingleFrameApplication
|
||||||
|
implements Application.ExitListener {
|
||||||
|
|
||||||
|
private Timeline activeTimeline;
|
||||||
|
private String currentTimelineFile;
|
||||||
|
private Logger log;
|
||||||
|
private Properties config;
|
||||||
|
|
||||||
|
public TimeStamperApp() {
|
||||||
|
super();
|
||||||
|
|
||||||
|
activeTimeline = new Timeline();
|
||||||
|
|
||||||
|
log = Logger.getLogger("jdbernard.timestamper");
|
||||||
|
log.setLevel(Level.CONFIG);
|
||||||
|
|
||||||
|
ConsoleHandler ch = new ConsoleHandler();
|
||||||
|
ch.setLevel(Level.INFO);
|
||||||
|
|
||||||
|
log.addHandler(ch);
|
||||||
|
|
||||||
|
try {
|
||||||
|
FileHandler fh = new FileHandler("TimeStamper.log", true);
|
||||||
|
fh.setLevel(Level.ALL);
|
||||||
|
} catch (IOException ioe) {
|
||||||
|
log.warning("Could not open log file for writing. Switching console"
|
||||||
|
+ " logging to verbose.");
|
||||||
|
ch.setLevel(Level.ALL);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
config = new Properties();
|
||||||
|
FileInputStream cfgIn = new FileInputStream("timestamper.config");
|
||||||
|
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.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* At startup create and show the main frame of the application.
|
* At startup create and show the main frame of the application.
|
||||||
*/
|
*/
|
||||||
@Override protected void startup() {
|
@Override protected void startup() {
|
||||||
show(new TimeStamperView(this));
|
show(new TimeStamperView(this));
|
||||||
getMainFrame().setSize(400, 75);
|
getMainFrame().setSize(300, 60);
|
||||||
|
getApplication().addExitListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -42,4 +97,58 @@ public class TimeStamperApp extends SingleFrameApplication {
|
|||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
launch(TimeStamperApp.class, args);
|
launch(TimeStamperApp.class, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void saveTimeline() {
|
||||||
|
saveTimelineToFile(currentTimelineFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void saveTimelineToFile(String filename) {
|
||||||
|
if (filename == null || filename.equals(""))
|
||||||
|
filename = "default-timeline.txt";
|
||||||
|
|
||||||
|
try {
|
||||||
|
Timeline.writeToFile(filename, activeTimeline);
|
||||||
|
currentTimelineFile = filename;
|
||||||
|
} catch (IOException ioe) {
|
||||||
|
log.warning("Could not save timeline file: "
|
||||||
|
+ ioe.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadTimeline(String filename) {
|
||||||
|
|
||||||
|
if (filename == null || filename.equals("")) {
|
||||||
|
activeTimeline = new Timeline();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
activeTimeline = Timeline.readFromFile(filename);
|
||||||
|
// TODO: re-init gui for new timeline
|
||||||
|
} catch (IOException ioe) {
|
||||||
|
log.warning("Could not load from the file: " +
|
||||||
|
ioe.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Timeline getActiveTimeline() {
|
||||||
|
return activeTimeline;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void willExit(EventObject e) {
|
||||||
|
saveTimeline();
|
||||||
|
|
||||||
|
config.setProperty("lastUsedTimelineFilename", currentTimelineFile);
|
||||||
|
try {
|
||||||
|
FileOutputStream out = new FileOutputStream("timestamper.config");
|
||||||
|
config.store(out, "");
|
||||||
|
out.close();
|
||||||
|
} catch (IOException ioe) {
|
||||||
|
log.warning("Could not save config file.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canExit(EventObject e) { return true; }
|
||||||
}
|
}
|
||||||
|
@ -11,19 +11,25 @@
|
|||||||
</Property>
|
</Property>
|
||||||
<Property name="name" type="java.lang.String" value="mainPanel" noResource="true"/>
|
<Property name="name" type="java.lang.String" value="mainPanel" noResource="true"/>
|
||||||
</Properties>
|
</Properties>
|
||||||
|
<Events>
|
||||||
|
<EventHandler event="mousePressed" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="mainPanelMousePressed"/>
|
||||||
|
</Events>
|
||||||
|
<AuxValues>
|
||||||
|
<AuxValue name="JavaCodeGenerator_ListenersCodePost" type="java.lang.String" value="mainPanel.addMouseMotionListener(this);"/>
|
||||||
|
</AuxValues>
|
||||||
|
|
||||||
<Layout>
|
<Layout>
|
||||||
<DimensionLayout dim="0">
|
<DimensionLayout dim="0">
|
||||||
<Group type="103" groupAlignment="0" attributes="0">
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
<Group type="102" attributes="0">
|
<Group type="102" attributes="0">
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
<EmptySpace min="-2" max="-2" attributes="0"/>
|
||||||
<Group type="103" groupAlignment="0" max="-2" attributes="0">
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
<Group type="102" alignment="0" attributes="1">
|
<Group type="102" alignment="1" attributes="0">
|
||||||
<Component id="totalTimeNow" min="-2" max="-2" attributes="0"/>
|
<Component id="totalTimeNow" min="-2" max="-2" attributes="0"/>
|
||||||
<EmptySpace max="32767" attributes="0"/>
|
<EmptySpace pref="12" max="32767" attributes="0"/>
|
||||||
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
|
<Component id="currentTimeLabel" min="-2" max="-2" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
<Component id="taskTextField" alignment="0" max="32767" attributes="1"/>
|
<Component id="taskTextField" alignment="0" pref="229" max="32767" attributes="1"/>
|
||||||
<Group type="102" alignment="0" attributes="0">
|
<Group type="102" alignment="0" attributes="0">
|
||||||
<Component id="currentTaskLabel" min="-2" max="-2" attributes="1"/>
|
<Component id="currentTaskLabel" min="-2" max="-2" attributes="1"/>
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
@ -32,7 +38,9 @@
|
|||||||
</Group>
|
</Group>
|
||||||
<Group type="103" groupAlignment="0" attributes="0">
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
<Group type="102" attributes="0">
|
<Group type="102" attributes="0">
|
||||||
<EmptySpace pref="104" max="32767" attributes="0"/>
|
<EmptySpace pref="109" max="32767" attributes="0"/>
|
||||||
|
<Component id="optionsButton" min="-2" max="-2" attributes="0"/>
|
||||||
|
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
|
||||||
<Component id="exitButton" min="-2" max="-2" attributes="0"/>
|
<Component id="exitButton" min="-2" max="-2" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
<Group type="102" alignment="0" attributes="0">
|
<Group type="102" alignment="0" attributes="0">
|
||||||
@ -46,23 +54,30 @@
|
|||||||
</DimensionLayout>
|
</DimensionLayout>
|
||||||
<DimensionLayout dim="1">
|
<DimensionLayout dim="1">
|
||||||
<Group type="103" groupAlignment="0" attributes="0">
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
<Group type="102" alignment="0" attributes="0">
|
<Group type="102" attributes="0">
|
||||||
<Group type="103" groupAlignment="3" attributes="0">
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
<Component id="currentTaskLabel" alignment="3" min="-2" max="-2" attributes="0"/>
|
<Component id="exitButton" alignment="0" min="-2" pref="16" max="-2" attributes="0"/>
|
||||||
<Component id="exitButton" alignment="3" min="-2" pref="16" max="-2" attributes="0"/>
|
<Component id="optionsButton" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||||
<Component id="startTimeLabel" alignment="3" min="-2" max="-2" attributes="0"/>
|
<Group type="102" alignment="0" attributes="0">
|
||||||
|
<Group type="103" groupAlignment="1" attributes="0">
|
||||||
|
<Component id="notesButton" alignment="1" min="-2" max="-2" attributes="0"/>
|
||||||
|
<Group type="102" alignment="1" attributes="0">
|
||||||
|
<Group type="103" groupAlignment="3" attributes="0">
|
||||||
|
<Component id="currentTaskLabel" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||||
|
<Component id="startTimeLabel" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
|
||||||
|
<Component id="taskTextField" min="-2" max="-2" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
</Group>
|
||||||
|
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
|
||||||
|
<Group type="103" groupAlignment="3" attributes="0">
|
||||||
|
<Component id="currentTimeLabel" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||||
|
<Component id="totalTimeNow" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
</Group>
|
||||||
</Group>
|
</Group>
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
<EmptySpace pref="24" max="32767" attributes="0"/>
|
||||||
<Group type="103" groupAlignment="3" attributes="0">
|
|
||||||
<Component id="taskTextField" alignment="3" min="-2" max="-2" attributes="0"/>
|
|
||||||
<Component id="notesButton" alignment="3" min="-2" max="-2" attributes="0"/>
|
|
||||||
</Group>
|
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
|
||||||
<Group type="103" groupAlignment="3" attributes="0">
|
|
||||||
<Component id="totalTimeNow" alignment="3" min="-2" max="-2" attributes="0"/>
|
|
||||||
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
|
|
||||||
</Group>
|
|
||||||
<EmptySpace pref="15" max="32767" attributes="0"/>
|
|
||||||
</Group>
|
</Group>
|
||||||
</Group>
|
</Group>
|
||||||
</DimensionLayout>
|
</DimensionLayout>
|
||||||
@ -102,6 +117,11 @@
|
|||||||
</Component>
|
</Component>
|
||||||
<Component class="javax.swing.JTextField" name="taskTextField">
|
<Component class="javax.swing.JTextField" name="taskTextField">
|
||||||
<Properties>
|
<Properties>
|
||||||
|
<Property name="font" type="java.awt.Font" noResource="true" editor="org.netbeans.modules.form.editors2.FontEditor">
|
||||||
|
<FontInfo relative="true">
|
||||||
|
<Font bold="true" component="taskTextField" property="font" relativeSize="true" size="0"/>
|
||||||
|
</FontInfo>
|
||||||
|
</Property>
|
||||||
<Property name="text" type="java.lang.String" resourceKey="taskTextField.text"/>
|
<Property name="text" type="java.lang.String" resourceKey="taskTextField.text"/>
|
||||||
<Property name="name" type="java.lang.String" value="taskTextField" noResource="true"/>
|
<Property name="name" type="java.lang.String" value="taskTextField" noResource="true"/>
|
||||||
</Properties>
|
</Properties>
|
||||||
@ -133,16 +153,16 @@
|
|||||||
<Property name="name" type="java.lang.String" value="totalTimeNow" noResource="true"/>
|
<Property name="name" type="java.lang.String" value="totalTimeNow" noResource="true"/>
|
||||||
</Properties>
|
</Properties>
|
||||||
</Component>
|
</Component>
|
||||||
<Component class="javax.swing.JLabel" name="jLabel1">
|
<Component class="javax.swing.JLabel" name="currentTimeLabel">
|
||||||
<Properties>
|
<Properties>
|
||||||
<Property name="font" type="java.awt.Font" noResource="true" editor="org.netbeans.modules.form.editors2.FontEditor">
|
<Property name="font" type="java.awt.Font" noResource="true" editor="org.netbeans.modules.form.editors2.FontEditor">
|
||||||
<FontInfo relative="true">
|
<FontInfo relative="true">
|
||||||
<Font bold="true" component="jLabel1" property="font" relativeSize="true" size="3"/>
|
<Font bold="true" component="currentTimeLabel" property="font" relativeSize="true" size="3"/>
|
||||||
</FontInfo>
|
</FontInfo>
|
||||||
</Property>
|
</Property>
|
||||||
<Property name="foreground" type="java.awt.Color" resourceKey="jLabel1.foreground"/>
|
<Property name="foreground" type="java.awt.Color" resourceKey="currentTimeLabel.foreground"/>
|
||||||
<Property name="text" type="java.lang.String" resourceKey="jLabel1.text"/>
|
<Property name="text" type="java.lang.String" resourceKey="currentTimeLabel.text"/>
|
||||||
<Property name="name" type="java.lang.String" value="jLabel1" noResource="true"/>
|
<Property name="name" type="java.lang.String" value="currentTimeLabel" noResource="true"/>
|
||||||
</Properties>
|
</Properties>
|
||||||
</Component>
|
</Component>
|
||||||
<Component class="javax.swing.JButton" name="notesButton">
|
<Component class="javax.swing.JButton" name="notesButton">
|
||||||
@ -157,6 +177,68 @@
|
|||||||
<Property name="name" type="java.lang.String" value="notesButton" noResource="true"/>
|
<Property name="name" type="java.lang.String" value="notesButton" noResource="true"/>
|
||||||
</Properties>
|
</Properties>
|
||||||
</Component>
|
</Component>
|
||||||
|
<Component class="javax.swing.JButton" name="optionsButton">
|
||||||
|
<Properties>
|
||||||
|
<Property name="icon" type="javax.swing.Icon" resourceKey="optionsButton.icon"/>
|
||||||
|
<Property name="contentAreaFilled" type="boolean" value="false"/>
|
||||||
|
<Property name="focusPainted" type="boolean" value="false"/>
|
||||||
|
<Property name="hideActionText" type="boolean" value="true"/>
|
||||||
|
<Property name="iconTextGap" type="int" value="0"/>
|
||||||
|
<Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor">
|
||||||
|
<Insets value="[0, 0, 0, 0]"/>
|
||||||
|
</Property>
|
||||||
|
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||||
|
<Dimension value="[16, 16]"/>
|
||||||
|
</Property>
|
||||||
|
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||||
|
<Dimension value="[16, 16]"/>
|
||||||
|
</Property>
|
||||||
|
<Property name="name" type="java.lang.String" value="optionsButton" noResource="true"/>
|
||||||
|
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||||
|
<Dimension value="[16, 16]"/>
|
||||||
|
</Property>
|
||||||
|
</Properties>
|
||||||
|
<Events>
|
||||||
|
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="optionsButtonMouseClicked"/>
|
||||||
|
<EventHandler event="mouseEntered" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="optionsButtonMouseEntered"/>
|
||||||
|
<EventHandler event="mouseExited" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="optionsButtonMouseExited"/>
|
||||||
|
</Events>
|
||||||
|
</Component>
|
||||||
|
</SubComponents>
|
||||||
|
</Container>
|
||||||
|
<Container class="javax.swing.JPopupMenu" name="optionsMenu">
|
||||||
|
<Properties>
|
||||||
|
<Property name="name" type="java.lang.String" value="optionsMenu" noResource="true"/>
|
||||||
|
</Properties>
|
||||||
|
|
||||||
|
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout">
|
||||||
|
<Property name="useNullLayout" type="boolean" value="true"/>
|
||||||
|
</Layout>
|
||||||
|
<SubComponents>
|
||||||
|
<MenuItem class="javax.swing.JMenuItem" name="saveTimelineMenuItem">
|
||||||
|
<Properties>
|
||||||
|
<Property name="action" type="javax.swing.Action" editor="org.netbeans.modules.swingapp.ActionEditor">
|
||||||
|
<action class="jdbernard.timestamper.TimeStamperView" id="saveTimeline" methodName="saveTimeline"/>
|
||||||
|
</Property>
|
||||||
|
<Property name="name" type="java.lang.String" value="saveTimelineMenuItem" noResource="true"/>
|
||||||
|
</Properties>
|
||||||
|
</MenuItem>
|
||||||
|
<MenuItem class="javax.swing.JMenuItem" name="saveTimelineAsMenuItem">
|
||||||
|
<Properties>
|
||||||
|
<Property name="action" type="javax.swing.Action" editor="org.netbeans.modules.swingapp.ActionEditor">
|
||||||
|
<action class="jdbernard.timestamper.TimeStamperView" id="saveTimelineAs" methodName="saveTimelineAs"/>
|
||||||
|
</Property>
|
||||||
|
<Property name="name" type="java.lang.String" value="saveTimelineAsMenuItem" noResource="true"/>
|
||||||
|
</Properties>
|
||||||
|
</MenuItem>
|
||||||
|
<MenuItem class="javax.swing.JMenuItem" name="loadTimelineMenuItem">
|
||||||
|
<Properties>
|
||||||
|
<Property name="action" type="javax.swing.Action" editor="org.netbeans.modules.swingapp.ActionEditor">
|
||||||
|
<action class="jdbernard.timestamper.TimeStamperView" id="loadTimeline" methodName="loadTimeline"/>
|
||||||
|
</Property>
|
||||||
|
<Property name="name" type="java.lang.String" value="loadTimelineMenuItem" noResource="true"/>
|
||||||
|
</Properties>
|
||||||
|
</MenuItem>
|
||||||
</SubComponents>
|
</SubComponents>
|
||||||
</Container>
|
</Container>
|
||||||
</NonVisualComponents>
|
</NonVisualComponents>
|
||||||
@ -174,6 +256,6 @@
|
|||||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||||
<AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,0,88,0,0,1,107"/>
|
<AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,0,84,0,0,1,-128"/>
|
||||||
</AuxValues>
|
</AuxValues>
|
||||||
</Form>
|
</Form>
|
||||||
|
@ -4,7 +4,20 @@
|
|||||||
|
|
||||||
package jdbernard.timestamper;
|
package jdbernard.timestamper;
|
||||||
|
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.Font;
|
||||||
|
import java.awt.Point;
|
||||||
|
import java.awt.Rectangle;
|
||||||
|
import java.awt.Toolkit;
|
||||||
|
import java.awt.event.KeyEvent;
|
||||||
|
import java.awt.event.MouseEvent;
|
||||||
|
import java.awt.event.MouseMotionListener;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.Timer;
|
||||||
|
import java.util.TimerTask;
|
||||||
|
import javax.swing.JFileChooser;
|
||||||
import org.jdesktop.application.Action;
|
import org.jdesktop.application.Action;
|
||||||
|
import org.jdesktop.application.Application;
|
||||||
import org.jdesktop.application.ResourceMap;
|
import org.jdesktop.application.ResourceMap;
|
||||||
import org.jdesktop.application.SingleFrameApplication;
|
import org.jdesktop.application.SingleFrameApplication;
|
||||||
import org.jdesktop.application.FrameView;
|
import org.jdesktop.application.FrameView;
|
||||||
@ -12,7 +25,7 @@ import org.jdesktop.application.FrameView;
|
|||||||
/**
|
/**
|
||||||
* The application's main frame.
|
* The application's main frame.
|
||||||
*/
|
*/
|
||||||
public class TimeStamperView extends FrameView {
|
public class TimeStamperView extends FrameView implements MouseMotionListener {
|
||||||
|
|
||||||
public TimeStamperView(SingleFrameApplication app) {
|
public TimeStamperView(SingleFrameApplication app) {
|
||||||
super(app);
|
super(app);
|
||||||
@ -23,6 +36,47 @@ public class TimeStamperView extends FrameView {
|
|||||||
|
|
||||||
getFrame().setUndecorated(true);
|
getFrame().setUndecorated(true);
|
||||||
|
|
||||||
|
fileChooser = new JFileChooser();
|
||||||
|
|
||||||
|
updateTimer = new Timer();
|
||||||
|
updateTimer.scheduleAtFixedRate(new TimerTask() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
Date currentTime = new Date();
|
||||||
|
currentTimeLabel.setText(Timeline.shortFormat.format(currentTime));
|
||||||
|
if (mostRecentTask != null) {
|
||||||
|
long seconds = currentTime.getTime() - mostRecentTask.getTime();
|
||||||
|
seconds /= 1000;
|
||||||
|
long minutes = seconds / 60;
|
||||||
|
seconds = seconds % 60;
|
||||||
|
long hours = minutes / 60;
|
||||||
|
minutes %= 60;
|
||||||
|
long days = hours / 24;
|
||||||
|
hours %= 24;
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
|
if (days > 0) sb.append(Long.toString(days) + "day ");
|
||||||
|
if (hours > 0) sb.append(Long.toString(hours) + "hr ");
|
||||||
|
if (minutes > 0) sb.append(Long.toString(minutes) + "min ");
|
||||||
|
sb.append(Long.toString(seconds) + "sec");
|
||||||
|
|
||||||
|
totalTimeNow.setText(sb.toString());
|
||||||
|
} else totalTimeNow.setText("");
|
||||||
|
}
|
||||||
|
}, 0, 1000);
|
||||||
|
|
||||||
|
thinTaskFont = taskTextField.getFont().deriveFont(Font.PLAIN);
|
||||||
|
boldTaskFont = thinTaskFont.deriveFont(Font.BOLD);
|
||||||
|
|
||||||
|
// refresh new timeline
|
||||||
|
Timeline t = ((TimeStamperApp) getApplication()).getActiveTimeline();
|
||||||
|
Timeline.TimelineMarker lastMarker = t.getLastMarker(new Date());
|
||||||
|
|
||||||
|
mostRecentTask = lastMarker.getTimestamp();
|
||||||
|
startTimeLabel.setText(Timeline.shortFormat.format(lastMarker.getTimestamp()));
|
||||||
|
|
||||||
|
taskTextField.setText(lastMarker.getMark());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method is called from within the constructor to
|
/** This method is called from within the constructor to
|
||||||
@ -40,11 +94,22 @@ public class TimeStamperView extends FrameView {
|
|||||||
taskTextField = new javax.swing.JTextField();
|
taskTextField = new javax.swing.JTextField();
|
||||||
startTimeLabel = new javax.swing.JLabel();
|
startTimeLabel = new javax.swing.JLabel();
|
||||||
totalTimeNow = new javax.swing.JLabel();
|
totalTimeNow = new javax.swing.JLabel();
|
||||||
jLabel1 = new javax.swing.JLabel();
|
currentTimeLabel = new javax.swing.JLabel();
|
||||||
notesButton = new javax.swing.JButton();
|
notesButton = new javax.swing.JButton();
|
||||||
|
optionsButton = new javax.swing.JButton();
|
||||||
|
optionsMenu = new javax.swing.JPopupMenu();
|
||||||
|
saveTimelineMenuItem = new javax.swing.JMenuItem();
|
||||||
|
saveTimelineAsMenuItem = new javax.swing.JMenuItem();
|
||||||
|
loadTimelineMenuItem = new javax.swing.JMenuItem();
|
||||||
|
|
||||||
mainPanel.setBorder(javax.swing.BorderFactory.createMatteBorder(2, 2, 2, 2, new java.awt.Color(0, 0, 0)));
|
mainPanel.setBorder(javax.swing.BorderFactory.createMatteBorder(2, 2, 2, 2, new java.awt.Color(0, 0, 0)));
|
||||||
mainPanel.setName("mainPanel"); // NOI18N
|
mainPanel.setName("mainPanel"); // NOI18N
|
||||||
|
mainPanel.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||||
|
public void mousePressed(java.awt.event.MouseEvent evt) {
|
||||||
|
mainPanelMousePressed(evt);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
mainPanel.addMouseMotionListener(this);
|
||||||
|
|
||||||
currentTaskLabel.setFont(currentTaskLabel.getFont().deriveFont(currentTaskLabel.getFont().getStyle() | java.awt.Font.BOLD, currentTaskLabel.getFont().getSize()+2));
|
currentTaskLabel.setFont(currentTaskLabel.getFont().deriveFont(currentTaskLabel.getFont().getStyle() | java.awt.Font.BOLD, currentTaskLabel.getFont().getSize()+2));
|
||||||
org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(jdbernard.timestamper.TimeStamperApp.class).getContext().getResourceMap(TimeStamperView.class);
|
org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(jdbernard.timestamper.TimeStamperApp.class).getContext().getResourceMap(TimeStamperView.class);
|
||||||
@ -68,6 +133,7 @@ public class TimeStamperView extends FrameView {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
taskTextField.setFont(taskTextField.getFont().deriveFont(taskTextField.getFont().getStyle() | java.awt.Font.BOLD));
|
||||||
taskTextField.setText(resourceMap.getString("taskTextField.text")); // NOI18N
|
taskTextField.setText(resourceMap.getString("taskTextField.text")); // NOI18N
|
||||||
taskTextField.setName("taskTextField"); // NOI18N
|
taskTextField.setName("taskTextField"); // NOI18N
|
||||||
taskTextField.addKeyListener(new java.awt.event.KeyAdapter() {
|
taskTextField.addKeyListener(new java.awt.event.KeyAdapter() {
|
||||||
@ -86,35 +152,59 @@ public class TimeStamperView extends FrameView {
|
|||||||
totalTimeNow.setText(resourceMap.getString("totalTimeNow.text")); // NOI18N
|
totalTimeNow.setText(resourceMap.getString("totalTimeNow.text")); // NOI18N
|
||||||
totalTimeNow.setName("totalTimeNow"); // NOI18N
|
totalTimeNow.setName("totalTimeNow"); // NOI18N
|
||||||
|
|
||||||
jLabel1.setFont(jLabel1.getFont().deriveFont(jLabel1.getFont().getStyle() | java.awt.Font.BOLD, jLabel1.getFont().getSize()+3));
|
currentTimeLabel.setFont(currentTimeLabel.getFont().deriveFont(currentTimeLabel.getFont().getStyle() | java.awt.Font.BOLD, currentTimeLabel.getFont().getSize()+3));
|
||||||
jLabel1.setForeground(resourceMap.getColor("jLabel1.foreground")); // NOI18N
|
currentTimeLabel.setForeground(resourceMap.getColor("currentTimeLabel.foreground")); // NOI18N
|
||||||
jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
|
currentTimeLabel.setText(resourceMap.getString("currentTimeLabel.text")); // NOI18N
|
||||||
jLabel1.setName("jLabel1"); // NOI18N
|
currentTimeLabel.setName("currentTimeLabel"); // NOI18N
|
||||||
|
|
||||||
notesButton.setAction(actionMap.get("editNotes")); // NOI18N
|
notesButton.setAction(actionMap.get("editNotes")); // NOI18N
|
||||||
notesButton.setHideActionText(true);
|
notesButton.setHideActionText(true);
|
||||||
notesButton.setMargin(new java.awt.Insets(0, 0, 0, 0));
|
notesButton.setMargin(new java.awt.Insets(0, 0, 0, 0));
|
||||||
notesButton.setName("notesButton"); // NOI18N
|
notesButton.setName("notesButton"); // NOI18N
|
||||||
|
|
||||||
|
optionsButton.setIcon(resourceMap.getIcon("optionsButton.icon")); // NOI18N
|
||||||
|
optionsButton.setContentAreaFilled(false);
|
||||||
|
optionsButton.setFocusPainted(false);
|
||||||
|
optionsButton.setHideActionText(true);
|
||||||
|
optionsButton.setIconTextGap(0);
|
||||||
|
optionsButton.setMargin(new java.awt.Insets(0, 0, 0, 0));
|
||||||
|
optionsButton.setMaximumSize(new java.awt.Dimension(16, 16));
|
||||||
|
optionsButton.setMinimumSize(new java.awt.Dimension(16, 16));
|
||||||
|
optionsButton.setName("optionsButton"); // NOI18N
|
||||||
|
optionsButton.setPreferredSize(new java.awt.Dimension(16, 16));
|
||||||
|
optionsButton.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||||
|
public void mouseClicked(java.awt.event.MouseEvent evt) {
|
||||||
|
optionsButtonMouseClicked(evt);
|
||||||
|
}
|
||||||
|
public void mouseEntered(java.awt.event.MouseEvent evt) {
|
||||||
|
optionsButtonMouseEntered(evt);
|
||||||
|
}
|
||||||
|
public void mouseExited(java.awt.event.MouseEvent evt) {
|
||||||
|
optionsButtonMouseExited(evt);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);
|
javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);
|
||||||
mainPanel.setLayout(mainPanelLayout);
|
mainPanel.setLayout(mainPanelLayout);
|
||||||
mainPanelLayout.setHorizontalGroup(
|
mainPanelLayout.setHorizontalGroup(
|
||||||
mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(mainPanelLayout.createSequentialGroup()
|
.addGroup(mainPanelLayout.createSequentialGroup()
|
||||||
.addContainerGap()
|
.addContainerGap()
|
||||||
.addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
.addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(mainPanelLayout.createSequentialGroup()
|
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, mainPanelLayout.createSequentialGroup()
|
||||||
.addComponent(totalTimeNow)
|
.addComponent(totalTimeNow)
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 12, Short.MAX_VALUE)
|
||||||
.addComponent(jLabel1))
|
.addComponent(currentTimeLabel))
|
||||||
.addComponent(taskTextField)
|
.addComponent(taskTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 229, Short.MAX_VALUE)
|
||||||
.addGroup(mainPanelLayout.createSequentialGroup()
|
.addGroup(mainPanelLayout.createSequentialGroup()
|
||||||
.addComponent(currentTaskLabel)
|
.addComponent(currentTaskLabel)
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addComponent(startTimeLabel)))
|
.addComponent(startTimeLabel)))
|
||||||
.addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
.addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(mainPanelLayout.createSequentialGroup()
|
.addGroup(mainPanelLayout.createSequentialGroup()
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 104, Short.MAX_VALUE)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 109, Short.MAX_VALUE)
|
||||||
|
.addComponent(optionsButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addGap(0, 0, 0)
|
||||||
.addComponent(exitButton))
|
.addComponent(exitButton))
|
||||||
.addGroup(mainPanelLayout.createSequentialGroup()
|
.addGroup(mainPanelLayout.createSequentialGroup()
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
@ -124,27 +214,53 @@ public class TimeStamperView extends FrameView {
|
|||||||
mainPanelLayout.setVerticalGroup(
|
mainPanelLayout.setVerticalGroup(
|
||||||
mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(mainPanelLayout.createSequentialGroup()
|
.addGroup(mainPanelLayout.createSequentialGroup()
|
||||||
.addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
.addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addComponent(currentTaskLabel)
|
|
||||||
.addComponent(exitButton, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE)
|
.addComponent(exitButton, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
.addComponent(startTimeLabel))
|
.addComponent(optionsButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
.addGroup(mainPanelLayout.createSequentialGroup()
|
||||||
.addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
.addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
|
||||||
.addComponent(taskTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
.addComponent(notesButton)
|
||||||
.addComponent(notesButton))
|
.addGroup(mainPanelLayout.createSequentialGroup()
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
.addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||||
.addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
.addComponent(currentTaskLabel)
|
||||||
.addComponent(totalTimeNow)
|
.addComponent(startTimeLabel))
|
||||||
.addComponent(jLabel1))
|
.addGap(0, 0, 0)
|
||||||
.addContainerGap(15, Short.MAX_VALUE))
|
.addComponent(taskTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
|
||||||
|
.addGap(0, 0, 0)
|
||||||
|
.addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||||
|
.addComponent(currentTimeLabel)
|
||||||
|
.addComponent(totalTimeNow))))
|
||||||
|
.addContainerGap(24, Short.MAX_VALUE))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
optionsMenu.setName("optionsMenu"); // NOI18N
|
||||||
|
|
||||||
|
saveTimelineMenuItem.setAction(actionMap.get("saveTimeline")); // NOI18N
|
||||||
|
saveTimelineMenuItem.setName("saveTimelineMenuItem"); // NOI18N
|
||||||
|
optionsMenu.add(saveTimelineMenuItem);
|
||||||
|
|
||||||
|
saveTimelineAsMenuItem.setAction(actionMap.get("saveTimelineAs")); // NOI18N
|
||||||
|
saveTimelineAsMenuItem.setName("saveTimelineAsMenuItem"); // NOI18N
|
||||||
|
optionsMenu.add(saveTimelineAsMenuItem);
|
||||||
|
|
||||||
|
loadTimelineMenuItem.setAction(actionMap.get("loadTimeline")); // NOI18N
|
||||||
|
loadTimelineMenuItem.setName("loadTimelineMenuItem"); // NOI18N
|
||||||
|
optionsMenu.add(loadTimelineMenuItem);
|
||||||
|
|
||||||
setComponent(mainPanel);
|
setComponent(mainPanel);
|
||||||
}// </editor-fold>//GEN-END:initComponents
|
}// </editor-fold>//GEN-END:initComponents
|
||||||
|
|
||||||
private void taskTextFieldKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_taskTextFieldKeyReleased
|
private void taskTextFieldKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_taskTextFieldKeyReleased
|
||||||
// Do stuff
|
if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
|
||||||
|
Timeline t = ((TimeStamperApp) getApplication()).getActiveTimeline();
|
||||||
|
Date d = new Date();
|
||||||
|
t.addMarker(d, taskTextField.getText(), "No comments.");
|
||||||
|
startTimeLabel.setText(Timeline.shortFormat.format(d));
|
||||||
|
taskTextField.setFont(boldTaskFont);
|
||||||
|
mostRecentTask = d;
|
||||||
|
} else {
|
||||||
|
taskTextField.setFont(thinTaskFont);
|
||||||
|
}
|
||||||
}//GEN-LAST:event_taskTextFieldKeyReleased
|
}//GEN-LAST:event_taskTextFieldKeyReleased
|
||||||
|
|
||||||
private void exitButtonMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_exitButtonMouseEntered
|
private void exitButtonMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_exitButtonMouseEntered
|
||||||
@ -155,20 +271,139 @@ private void exitButtonMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:e
|
|||||||
exitButton.setIcon(getResourceMap().getIcon("exitButton.icon"));
|
exitButton.setIcon(getResourceMap().getIcon("exitButton.icon"));
|
||||||
}//GEN-LAST:event_exitButtonMouseExited
|
}//GEN-LAST:event_exitButtonMouseExited
|
||||||
|
|
||||||
|
private void optionsButtonMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_optionsButtonMouseEntered
|
||||||
|
optionsButton.setIcon(getResourceMap().getIcon("optionsButton.hover.icon"));//GEN-LAST:event_optionsButtonMouseEntered
|
||||||
|
}
|
||||||
|
|
||||||
|
private void optionsButtonMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_optionsButtonMouseExited
|
||||||
|
optionsButton.setIcon(getResourceMap().getIcon("optionsButton.icon"));//GEN-LAST:event_optionsButtonMouseExited
|
||||||
|
}
|
||||||
|
|
||||||
|
private void mainPanelMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_mainPanelMousePressed
|
||||||
|
mousePressRelativeToFrame = evt.getPoint();
|
||||||
|
}//GEN-LAST:event_mainPanelMousePressed
|
||||||
|
|
||||||
|
private void optionsButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_optionsButtonMouseClicked
|
||||||
|
optionsMenu.show(evt.getComponent(), evt.getX(), evt.getY());
|
||||||
|
}//GEN-LAST:event_optionsButtonMouseClicked
|
||||||
|
|
||||||
@Action
|
@Action
|
||||||
public void editNotes() {
|
public void editNotes() {
|
||||||
|
// TODO:
|
||||||
}
|
}
|
||||||
|
|
||||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||||
private javax.swing.JLabel currentTaskLabel;
|
private javax.swing.JLabel currentTaskLabel;
|
||||||
|
private javax.swing.JLabel currentTimeLabel;
|
||||||
private javax.swing.JButton exitButton;
|
private javax.swing.JButton exitButton;
|
||||||
private javax.swing.JLabel jLabel1;
|
private javax.swing.JMenuItem loadTimelineMenuItem;
|
||||||
private javax.swing.JPanel mainPanel;
|
private javax.swing.JPanel mainPanel;
|
||||||
private javax.swing.JButton notesButton;
|
private javax.swing.JButton notesButton;
|
||||||
|
private javax.swing.JButton optionsButton;
|
||||||
|
private javax.swing.JPopupMenu optionsMenu;
|
||||||
|
private javax.swing.JMenuItem saveTimelineAsMenuItem;
|
||||||
|
private javax.swing.JMenuItem saveTimelineMenuItem;
|
||||||
private javax.swing.JLabel startTimeLabel;
|
private javax.swing.JLabel startTimeLabel;
|
||||||
private javax.swing.JTextField taskTextField;
|
private javax.swing.JTextField taskTextField;
|
||||||
private javax.swing.JLabel totalTimeNow;
|
private javax.swing.JLabel totalTimeNow;
|
||||||
// End of variables declaration//GEN-END:variables
|
// End of variables declaration//GEN-END:variables
|
||||||
|
|
||||||
|
private Point mousePressRelativeToFrame;
|
||||||
|
private JFileChooser fileChooser;
|
||||||
|
private Timer updateTimer;
|
||||||
|
private Font boldTaskFont;
|
||||||
|
private Font thinTaskFont;
|
||||||
|
private Date mostRecentTask;
|
||||||
|
|
||||||
|
public void mouseDragged(MouseEvent e) {
|
||||||
|
Point currentMousePoint = e.getLocationOnScreen();
|
||||||
|
|
||||||
|
// this is the point we will compute as the new upper left
|
||||||
|
// coordinate of the frame. It needs to be translated some to account
|
||||||
|
// for the fact that the user can press the mouse anywhere on the
|
||||||
|
// main panel.
|
||||||
|
Point finalPoint = (Point) currentMousePoint.clone();
|
||||||
|
// find out where the new point should be, ignoreing screen bounds
|
||||||
|
finalPoint.translate(-mousePressRelativeToFrame.x,
|
||||||
|
-mousePressRelativeToFrame.y);
|
||||||
|
|
||||||
|
// get the current frame bounds
|
||||||
|
Rectangle frameBounds = getFrame().getBounds();
|
||||||
|
|
||||||
|
// screen resolution
|
||||||
|
Dimension resolution = Toolkit.getDefaultToolkit().getScreenSize();
|
||||||
|
|
||||||
|
// check to see if the frame is near any of the screen boundaries
|
||||||
|
// if it is, 'snap' the final point to that boundary.
|
||||||
|
if (frameBounds.x < 20)
|
||||||
|
finalPoint.translate(-finalPoint.x, 0);
|
||||||
|
if (frameBounds.y < 20)
|
||||||
|
finalPoint.translate(0, -finalPoint.y);
|
||||||
|
if ((resolution.width - (frameBounds.x + frameBounds.width)) < 20)
|
||||||
|
finalPoint.translate(resolution.width -
|
||||||
|
(finalPoint.x + frameBounds.width), 0);
|
||||||
|
if ((resolution.height - (frameBounds.y + frameBounds.height)) < 20)
|
||||||
|
finalPoint.translate(0, resolution.height -
|
||||||
|
(finalPoint.y + frameBounds.height));
|
||||||
|
|
||||||
|
|
||||||
|
// this point represents a backwards version of the initial calculation
|
||||||
|
// to find the finalPoint. It says, based on the current final point,
|
||||||
|
// assume I moved the frame to that point. Where, relative to that point
|
||||||
|
// should the mouse be, based on how far it was relative to the point
|
||||||
|
// when the user pressed it.
|
||||||
|
Point whereMouseShouldBe = (Point) finalPoint.clone();
|
||||||
|
whereMouseShouldBe.translate(mousePressRelativeToFrame.x,
|
||||||
|
mousePressRelativeToFrame.y);
|
||||||
|
|
||||||
|
// if the actual mouse location is different from the expected location,
|
||||||
|
// then we know that the snapping behaviour has altered the frames new
|
||||||
|
// placement. If this alteration is too large (30 px apart in this case)
|
||||||
|
// then we know the user is trying to pull the frame out of its snapped
|
||||||
|
// position. In this case, we want to ignore the snap calculations and
|
||||||
|
// base the new frame location entirely on the current mouse location
|
||||||
|
if (whereMouseShouldBe.distance(currentMousePoint) > 30) {
|
||||||
|
finalPoint = (Point) currentMousePoint.clone();
|
||||||
|
finalPoint.translate(-mousePressRelativeToFrame.x,
|
||||||
|
-mousePressRelativeToFrame.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
// once we've figured out where to go, put us there :)
|
||||||
|
getFrame().setLocation(finalPoint);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void mouseMoved(MouseEvent e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Action
|
||||||
|
public void saveTimeline() {
|
||||||
|
((TimeStamperApp) getApplication()).saveTimeline();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Action
|
||||||
|
public void saveTimelineAs() {
|
||||||
|
if (fileChooser.showSaveDialog(getFrame())!=JFileChooser.APPROVE_OPTION)
|
||||||
|
return;
|
||||||
|
|
||||||
|
((TimeStamperApp) getApplication()).saveTimelineToFile(
|
||||||
|
fileChooser.getSelectedFile().getAbsolutePath());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Action
|
||||||
|
public void loadTimeline() {
|
||||||
|
if (fileChooser.showOpenDialog(getFrame())!=JFileChooser.APPROVE_OPTION)
|
||||||
|
return;
|
||||||
|
|
||||||
|
((TimeStamperApp) getApplication()).loadTimeline(
|
||||||
|
fileChooser.getSelectedFile().getAbsolutePath());
|
||||||
|
|
||||||
|
// refresh new timeline
|
||||||
|
Timeline t = ((TimeStamperApp) getApplication()).getActiveTimeline();
|
||||||
|
Timeline.TimelineMarker lastMarker = t.getLastMarker(new Date());
|
||||||
|
|
||||||
|
mostRecentTask = lastMarker.getTimestamp();
|
||||||
|
startTimeLabel.setText(Timeline.shortFormat.format(lastMarker.getTimestamp()));
|
||||||
|
|
||||||
|
taskTextField.setText(lastMarker.getMark());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -93,18 +93,29 @@ public class Timeline implements Iterable<Timeline.TimelineMarker> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getLastName(Date timestamp) {
|
public String getLastName(Date timestamp) {
|
||||||
//TODO:
|
TimelineMarker lastMarker = getLastMarker(timestamp);
|
||||||
return null;
|
return (lastMarker == null ?
|
||||||
|
"No previous marker." :
|
||||||
|
lastMarker.getMark());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLastNotes(Date timestamp) {
|
public String getLastNotes(Date timestamp) {
|
||||||
//TODO:
|
TimelineMarker lastMarker = getLastMarker(timestamp);
|
||||||
return null;
|
return (lastMarker == null ?
|
||||||
|
"No previous marker." :
|
||||||
|
lastMarker.getNotes());
|
||||||
}
|
}
|
||||||
|
|
||||||
public TimelineMarker getLastMarker(Date timestamp) {
|
public TimelineMarker getLastMarker(Date timestamp) {
|
||||||
//TODO:
|
TimelineMarker lastMarker = null;
|
||||||
return null;
|
for (TimelineMarker tm : timelineList) {
|
||||||
|
if (tm.getTimestamp().after(timestamp))
|
||||||
|
break;
|
||||||
|
lastMarker = tm;
|
||||||
|
}
|
||||||
|
|
||||||
|
return lastMarker;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeMarker(TimelineMarker marker) {
|
public void removeMarker(TimelineMarker marker) {
|
||||||
|
@ -4,6 +4,8 @@ exitButton.text=
|
|||||||
#NOI18N
|
#NOI18N
|
||||||
exitButton.icon=icons/16-em-cross.png
|
exitButton.icon=icons/16-em-cross.png
|
||||||
exitButton.hover.icon=icons/16-em-cross-hover.png
|
exitButton.hover.icon=icons/16-em-cross-hover.png
|
||||||
|
optionsButton.icon=icons/16-tool-a.png
|
||||||
|
optionsButton.hover.icon=icons/16-tool-a-hover.png
|
||||||
taskTextField.text=
|
taskTextField.text=
|
||||||
#NOI18N
|
#NOI18N
|
||||||
startTimeLabel.foreground=0, 102, 102
|
startTimeLabel.foreground=0, 102, 102
|
||||||
@ -11,11 +13,34 @@ startTimeLabel.text=12:00:00
|
|||||||
totalTimeNow.text=3day 2hr 50min 25sec
|
totalTimeNow.text=3day 2hr 50min 25sec
|
||||||
#NOI18N
|
#NOI18N
|
||||||
totalTimeNow.foreground=0, 153, 0
|
totalTimeNow.foreground=0, 153, 0
|
||||||
jLabel1.text=12:00:00
|
|
||||||
#NOI18N
|
|
||||||
jLabel1.foreground=204, 0, 0
|
|
||||||
notesButton.text=jButton1
|
notesButton.text=jButton1
|
||||||
editNotes.Action.smallIcon=/jdbernard/timestamper/resources/icons/16-em-pencil.png
|
editNotes.Action.smallIcon=/jdbernard/timestamper/resources/icons/16-em-pencil.png
|
||||||
editNotes.Action.icon=/jdbernard/timestamper/resources/icons/16-em-pencil.png
|
editNotes.Action.icon=/jdbernard/timestamper/resources/icons/16-em-pencil.png
|
||||||
editNotes.Action.shortDescription=Edit notes for this task
|
editNotes.Action.shortDescription=Edit notes for this task
|
||||||
editNotes.Action.text=Notes
|
editNotes.Action.text=Notes
|
||||||
|
jButton1.text=
|
||||||
|
showOptionsMenu.Action.text=Options menu
|
||||||
|
showOptionsMenu.Action.shortDescription=Show the application's options menu.
|
||||||
|
showOptionsMenu.Action.smallIcon=/jdbernard/timestamper/resources/icons/16-tool-a.png
|
||||||
|
showOptionsMenu.Action.icon=/jdbernard/timestamper/resources/icons/16-tool-a.png
|
||||||
|
saveTimelineMenuItem.text=Item
|
||||||
|
saveTimeline.Action.text=Save Timeline...
|
||||||
|
saveTimeline.Action.smallIcon=/jdbernard/timestamper/resources/icons/document-save-16x16.png
|
||||||
|
saveTimeline.Action.icon=/jdbernard/timestamper/resources/icons/document-save-16x16.png
|
||||||
|
saveTimeline.Action.shortDescription=Save all actions to a timeline file.
|
||||||
|
saveTimelineAs.Action.smallIcon=/jdbernard/timestamper/resources/icons/document-save-as-16x16.png
|
||||||
|
saveTimelineAs.Action.icon=/jdbernard/timestamper/resources/icons/document-save-as-16x16.png
|
||||||
|
saveTimelineAs.Action.shortDescription=Save actions to a new timeline file.
|
||||||
|
saveTimelineAs.Action.text=Save Timeline As...
|
||||||
|
loadTimelineMenuItem.text=Item
|
||||||
|
loadTimeline.Action.text=Load Timeline...
|
||||||
|
loadTimeline.Action.shortDescription=Load a set of actions from a timeline file
|
||||||
|
loadTimeline.Action.smallIcon=/jdbernard/timestamper/resources/icons/document-open-16x16.png
|
||||||
|
loadTimeline.Action.icon=/jdbernard/timestamper/resources/icons/document-open-16x16.png
|
||||||
|
currentTimeLabel.text=12:00:00
|
||||||
|
#NOI18N
|
||||||
|
currentTimeLabel.foreground=204, 0, 0
|
||||||
|
exit.Action.text=Exit
|
||||||
|
exit.Action.smallIcon=/jdbernard/timestamper/resources/icons/16-em-cross.png
|
||||||
|
exit.Action.shortDescription=Close the application.
|
||||||
|
exit.Action.icon=/jdbernard/timestamper/resources/icons/16-em-cross.png
|
||||||
|
BIN
src/jdbernard/timestamper/resources/icons/16-tool-a-hover.png
Executable file
BIN
src/jdbernard/timestamper/resources/icons/16-tool-a-hover.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 393 B |
BIN
src/jdbernard/timestamper/resources/icons/16-tool-a.png
Executable file
BIN
src/jdbernard/timestamper/resources/icons/16-tool-a.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 275 B |
BIN
src/jdbernard/timestamper/resources/icons/document-open-16x16.png
Executable file
BIN
src/jdbernard/timestamper/resources/icons/document-open-16x16.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 537 B |
BIN
src/jdbernard/timestamper/resources/icons/document-save-16x16.png
Executable file
BIN
src/jdbernard/timestamper/resources/icons/document-save-16x16.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 911 B |
BIN
src/jdbernard/timestamper/resources/icons/document-save-as-16x16.png
Executable file
BIN
src/jdbernard/timestamper/resources/icons/document-save-as-16x16.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 866 B |
4
timestamper.config
Executable file
4
timestamper.config
Executable file
@ -0,0 +1,4 @@
|
|||||||
|
#
|
||||||
|
#Fri Aug 29 18:18:08 CDT 2008
|
||||||
|
lastUsedTimelineFilename=default-timeline.txt
|
||||||
|
lastUsedTimelineFile=default-timeline.txt
|
Loading…
x
Reference in New Issue
Block a user