Added notes dialog.
Refined snap behaviour to be more generic. Snap functionality broken out as a seperate method. NotesDialog uses snap method to snap to app frame and screen committer: Jonathan Bernard <jdbernard@gmail.com>
This commit is contained in:
parent
fb83bc9161
commit
83c8933a0a
96
src/jdbernard/timestamper/NotesDialog.form
Executable file
96
src/jdbernard/timestamper/NotesDialog.form
Executable file
@ -0,0 +1,96 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
|
||||||
|
<Form version="1.5" maxVersion="1.6" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
|
||||||
|
<Properties>
|
||||||
|
<Property name="defaultCloseOperation" type="int" value="2"/>
|
||||||
|
<Property name="name" type="java.lang.String" value="Form" noResource="true"/>
|
||||||
|
<Property name="undecorated" type="boolean" value="true"/>
|
||||||
|
</Properties>
|
||||||
|
<SyntheticProperties>
|
||||||
|
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||||
|
</SyntheticProperties>
|
||||||
|
<AuxValues>
|
||||||
|
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="2"/>
|
||||||
|
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="true"/>
|
||||||
|
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||||
|
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||||
|
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||||
|
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||||
|
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||||
|
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||||
|
</AuxValues>
|
||||||
|
|
||||||
|
<Layout>
|
||||||
|
<DimensionLayout dim="0">
|
||||||
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
|
<Component id="mainPanel" alignment="0" max="32767" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
</DimensionLayout>
|
||||||
|
<DimensionLayout dim="1">
|
||||||
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
|
<Component id="mainPanel" alignment="0" max="32767" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
</DimensionLayout>
|
||||||
|
</Layout>
|
||||||
|
<SubComponents>
|
||||||
|
<Container class="javax.swing.JPanel" name="mainPanel">
|
||||||
|
<Properties>
|
||||||
|
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
|
||||||
|
<Border info="org.netbeans.modules.form.compat2.border.MatteColorBorderInfo">
|
||||||
|
<MatteColorBorder bottom="2" left="2" right="2" top="2"/>
|
||||||
|
</Border>
|
||||||
|
</Property>
|
||||||
|
<Property name="toolTipText" type="java.lang.String" resourceKey="mainPanel.toolTipText"/>
|
||||||
|
<Property name="name" type="java.lang.String" value="mainPanel" noResource="true"/>
|
||||||
|
</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>
|
||||||
|
<DimensionLayout dim="0">
|
||||||
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
|
<Group type="102" alignment="0" attributes="0">
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
<Component id="notesScollPane" pref="258" max="32767" attributes="0"/>
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
</Group>
|
||||||
|
</DimensionLayout>
|
||||||
|
<DimensionLayout dim="1">
|
||||||
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
|
<Group type="102" alignment="1" attributes="0">
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
<Component id="notesScollPane" pref="174" max="32767" attributes="0"/>
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
</Group>
|
||||||
|
</DimensionLayout>
|
||||||
|
</Layout>
|
||||||
|
<SubComponents>
|
||||||
|
<Container class="javax.swing.JScrollPane" name="notesScollPane">
|
||||||
|
<Properties>
|
||||||
|
<Property name="name" type="java.lang.String" value="notesScollPane" noResource="true"/>
|
||||||
|
</Properties>
|
||||||
|
|
||||||
|
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
|
||||||
|
<SubComponents>
|
||||||
|
<Component class="javax.swing.JTextArea" name="notesTextArea">
|
||||||
|
<Properties>
|
||||||
|
<Property name="columns" type="int" value="20"/>
|
||||||
|
<Property name="rows" type="int" value="5"/>
|
||||||
|
<Property name="name" type="java.lang.String" value="notesTextArea" noResource="true"/>
|
||||||
|
</Properties>
|
||||||
|
<Events>
|
||||||
|
<EventHandler event="keyReleased" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="notesTextAreaKeyReleased"/>
|
||||||
|
</Events>
|
||||||
|
</Component>
|
||||||
|
</SubComponents>
|
||||||
|
</Container>
|
||||||
|
</SubComponents>
|
||||||
|
</Container>
|
||||||
|
</SubComponents>
|
||||||
|
</Form>
|
148
src/jdbernard/timestamper/NotesDialog.java
Executable file
148
src/jdbernard/timestamper/NotesDialog.java
Executable file
@ -0,0 +1,148 @@
|
|||||||
|
/*
|
||||||
|
* NotesDialog.java
|
||||||
|
*
|
||||||
|
* Created on September 3, 2008, 4:53 PM
|
||||||
|
*/
|
||||||
|
|
||||||
|
package jdbernard.timestamper;
|
||||||
|
|
||||||
|
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 javax.swing.JDialog;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author jbernard
|
||||||
|
*/
|
||||||
|
public class NotesDialog extends JDialog implements MouseMotionListener {
|
||||||
|
|
||||||
|
/** Creates new form NotesDialog */
|
||||||
|
public NotesDialog(TimeStamperView parent, boolean modal) {
|
||||||
|
super(parent.getFrame(), modal);
|
||||||
|
initComponents();
|
||||||
|
|
||||||
|
setSize(300, 200);
|
||||||
|
thinNotesFont = notesTextArea.getFont().deriveFont(Font.PLAIN);
|
||||||
|
boldNotesFont = notesTextArea.getFont().deriveFont(Font.BOLD);
|
||||||
|
|
||||||
|
this.parent = parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNotes(String notes) {
|
||||||
|
notesTextArea.setText(notes);
|
||||||
|
notesTextArea.setFont(boldNotesFont);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNotes() {
|
||||||
|
return notesTextArea.getText();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** This method is called from within the constructor to
|
||||||
|
* initialize the form.
|
||||||
|
* WARNING: Do NOT modify this code. The content of this method is
|
||||||
|
* always regenerated by the Form Editor.
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||||
|
private void initComponents() {
|
||||||
|
|
||||||
|
mainPanel = new javax.swing.JPanel();
|
||||||
|
notesScollPane = new javax.swing.JScrollPane();
|
||||||
|
notesTextArea = new javax.swing.JTextArea();
|
||||||
|
|
||||||
|
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
||||||
|
setName("Form"); // NOI18N
|
||||||
|
setUndecorated(true);
|
||||||
|
|
||||||
|
mainPanel.setBorder(javax.swing.BorderFactory.createMatteBorder(2, 2, 2, 2, new java.awt.Color(0, 0, 0)));
|
||||||
|
org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(jdbernard.timestamper.TimeStamperApp.class).getContext().getResourceMap(NotesDialog.class);
|
||||||
|
mainPanel.setToolTipText(resourceMap.getString("mainPanel.toolTipText")); // 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);
|
||||||
|
|
||||||
|
notesScollPane.setName("notesScollPane"); // NOI18N
|
||||||
|
|
||||||
|
notesTextArea.setColumns(20);
|
||||||
|
notesTextArea.setRows(5);
|
||||||
|
notesTextArea.setName("notesTextArea"); // NOI18N
|
||||||
|
notesTextArea.addKeyListener(new java.awt.event.KeyAdapter() {
|
||||||
|
public void keyReleased(java.awt.event.KeyEvent evt) {
|
||||||
|
notesTextAreaKeyReleased(evt);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
notesScollPane.setViewportView(notesTextArea);
|
||||||
|
|
||||||
|
javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);
|
||||||
|
mainPanel.setLayout(mainPanelLayout);
|
||||||
|
mainPanelLayout.setHorizontalGroup(
|
||||||
|
mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(mainPanelLayout.createSequentialGroup()
|
||||||
|
.addContainerGap()
|
||||||
|
.addComponent(notesScollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 258, Short.MAX_VALUE)
|
||||||
|
.addContainerGap())
|
||||||
|
);
|
||||||
|
mainPanelLayout.setVerticalGroup(
|
||||||
|
mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, mainPanelLayout.createSequentialGroup()
|
||||||
|
.addContainerGap()
|
||||||
|
.addComponent(notesScollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 174, Short.MAX_VALUE)
|
||||||
|
.addContainerGap())
|
||||||
|
);
|
||||||
|
|
||||||
|
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||||
|
getContentPane().setLayout(layout);
|
||||||
|
layout.setHorizontalGroup(
|
||||||
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
.addComponent(mainPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
|
);
|
||||||
|
layout.setVerticalGroup(
|
||||||
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
.addComponent(mainPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
|
);
|
||||||
|
|
||||||
|
pack();
|
||||||
|
}// </editor-fold>//GEN-END:initComponents
|
||||||
|
|
||||||
|
private void notesTextAreaKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_notesTextAreaKeyReleased
|
||||||
|
if ((evt.getKeyCode() == KeyEvent.VK_ENTER) && evt.isControlDown()) {
|
||||||
|
parent.setNotesForActiveTask(notesTextArea.getText());
|
||||||
|
notesTextArea.setFont(boldNotesFont);
|
||||||
|
} else if (evt.getKeyCode() != KeyEvent.VK_CONTROL)
|
||||||
|
notesTextArea.setFont(thinNotesFont);
|
||||||
|
}//GEN-LAST:event_notesTextAreaKeyReleased
|
||||||
|
|
||||||
|
private void mainPanelMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_mainPanelMousePressed
|
||||||
|
mousePressRelativeToWindow = evt.getPoint();
|
||||||
|
}//GEN-LAST:event_mainPanelMousePressed
|
||||||
|
|
||||||
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||||
|
private javax.swing.JPanel mainPanel;
|
||||||
|
private javax.swing.JScrollPane notesScollPane;
|
||||||
|
private javax.swing.JTextArea notesTextArea;
|
||||||
|
// End of variables declaration//GEN-END:variables
|
||||||
|
|
||||||
|
private TimeStamperView parent;
|
||||||
|
Font thinNotesFont;
|
||||||
|
Font boldNotesFont;
|
||||||
|
Point mousePressRelativeToWindow;
|
||||||
|
|
||||||
|
public void mouseDragged(MouseEvent e) {
|
||||||
|
setLocation(TimeStamperView.calculateWindowMovement(
|
||||||
|
e.getLocationOnScreen(), mousePressRelativeToWindow,
|
||||||
|
getBounds(), parent.getFrame().getBounds(),
|
||||||
|
new Rectangle(Toolkit.getDefaultToolkit().getScreenSize())));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void mouseMoved(MouseEvent e) {
|
||||||
|
}
|
||||||
|
}
|
@ -22,7 +22,7 @@
|
|||||||
<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 min="-2" max="-2" attributes="0"/>
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
<Group type="103" groupAlignment="0" attributes="0">
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
<Group type="102" alignment="1" attributes="0">
|
<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"/>
|
||||||
@ -37,7 +37,7 @@
|
|||||||
</Group>
|
</Group>
|
||||||
</Group>
|
</Group>
|
||||||
<Group type="103" groupAlignment="0" attributes="0">
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
<Group type="102" attributes="0">
|
<Group type="102" alignment="0" attributes="0">
|
||||||
<EmptySpace pref="109" max="32767" attributes="0"/>
|
<EmptySpace pref="109" max="32767" attributes="0"/>
|
||||||
<Component id="optionsButton" min="-2" max="-2" attributes="0"/>
|
<Component id="optionsButton" min="-2" max="-2" attributes="0"/>
|
||||||
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
|
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
|
||||||
@ -77,7 +77,7 @@
|
|||||||
</Group>
|
</Group>
|
||||||
</Group>
|
</Group>
|
||||||
</Group>
|
</Group>
|
||||||
<EmptySpace pref="24" max="32767" attributes="0"/>
|
<EmptySpace pref="31" max="32767" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
</Group>
|
</Group>
|
||||||
</DimensionLayout>
|
</DimensionLayout>
|
||||||
@ -165,18 +165,6 @@
|
|||||||
<Property name="name" type="java.lang.String" value="currentTimeLabel" noResource="true"/>
|
<Property name="name" type="java.lang.String" value="currentTimeLabel" noResource="true"/>
|
||||||
</Properties>
|
</Properties>
|
||||||
</Component>
|
</Component>
|
||||||
<Component class="javax.swing.JButton" name="notesButton">
|
|
||||||
<Properties>
|
|
||||||
<Property name="action" type="javax.swing.Action" editor="org.netbeans.modules.swingapp.ActionEditor">
|
|
||||||
<action class="jdbernard.timestamper.TimeStamperView" id="editNotes" methodName="editNotes"/>
|
|
||||||
</Property>
|
|
||||||
<Property name="hideActionText" type="boolean" value="true"/>
|
|
||||||
<Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor">
|
|
||||||
<Insets value="[0, 0, 0, 0]"/>
|
|
||||||
</Property>
|
|
||||||
<Property name="name" type="java.lang.String" value="notesButton" noResource="true"/>
|
|
||||||
</Properties>
|
|
||||||
</Component>
|
|
||||||
<Component class="javax.swing.JButton" name="optionsButton">
|
<Component class="javax.swing.JButton" name="optionsButton">
|
||||||
<Properties>
|
<Properties>
|
||||||
<Property name="icon" type="javax.swing.Icon" resourceKey="optionsButton.icon"/>
|
<Property name="icon" type="javax.swing.Icon" resourceKey="optionsButton.icon"/>
|
||||||
@ -204,6 +192,18 @@
|
|||||||
<EventHandler event="mouseExited" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="optionsButtonMouseExited"/>
|
<EventHandler event="mouseExited" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="optionsButtonMouseExited"/>
|
||||||
</Events>
|
</Events>
|
||||||
</Component>
|
</Component>
|
||||||
|
<Component class="javax.swing.JToggleButton" name="notesButton">
|
||||||
|
<Properties>
|
||||||
|
<Property name="action" type="javax.swing.Action" editor="org.netbeans.modules.swingapp.ActionEditor">
|
||||||
|
<action class="jdbernard.timestamper.TimeStamperView" id="editNotes" methodName="editNotes"/>
|
||||||
|
</Property>
|
||||||
|
<Property name="hideActionText" type="boolean" value="true"/>
|
||||||
|
<Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor">
|
||||||
|
<Insets value="[0, 0, 0, 0]"/>
|
||||||
|
</Property>
|
||||||
|
<Property name="name" type="java.lang.String" value="notesButton" noResource="true"/>
|
||||||
|
</Properties>
|
||||||
|
</Component>
|
||||||
</SubComponents>
|
</SubComponents>
|
||||||
</Container>
|
</Container>
|
||||||
<Container class="javax.swing.JPopupMenu" name="optionsMenu">
|
<Container class="javax.swing.JPopupMenu" name="optionsMenu">
|
||||||
@ -256,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,84,0,0,1,-128"/>
|
<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,91,0,0,1,-128"/>
|
||||||
</AuxValues>
|
</AuxValues>
|
||||||
</Form>
|
</Form>
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
package jdbernard.timestamper;
|
package jdbernard.timestamper;
|
||||||
|
|
||||||
import java.awt.Dimension;
|
|
||||||
import java.awt.Font;
|
import java.awt.Font;
|
||||||
import java.awt.Point;
|
import java.awt.Point;
|
||||||
import java.awt.Rectangle;
|
import java.awt.Rectangle;
|
||||||
@ -17,7 +16,6 @@ import java.util.Timer;
|
|||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
import javax.swing.JFileChooser;
|
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;
|
||||||
@ -37,6 +35,7 @@ public class TimeStamperView extends FrameView implements MouseMotionListener {
|
|||||||
getFrame().setUndecorated(true);
|
getFrame().setUndecorated(true);
|
||||||
|
|
||||||
fileChooser = new JFileChooser();
|
fileChooser = new JFileChooser();
|
||||||
|
notesDialog = new NotesDialog(this, false);
|
||||||
|
|
||||||
updateTimer = new Timer();
|
updateTimer = new Timer();
|
||||||
updateTimer.scheduleAtFixedRate(new TimerTask() {
|
updateTimer.scheduleAtFixedRate(new TimerTask() {
|
||||||
@ -78,6 +77,7 @@ public class TimeStamperView extends FrameView implements MouseMotionListener {
|
|||||||
startTimeLabel.setText(Timeline.shortFormat.format(lastMarker.getTimestamp()));
|
startTimeLabel.setText(Timeline.shortFormat.format(lastMarker.getTimestamp()));
|
||||||
|
|
||||||
taskTextField.setText(lastMarker.getMark());
|
taskTextField.setText(lastMarker.getMark());
|
||||||
|
notesDialog.setNotes(lastMarker.getNotes());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,8 +97,8 @@ public class TimeStamperView extends FrameView implements MouseMotionListener {
|
|||||||
startTimeLabel = new javax.swing.JLabel();
|
startTimeLabel = new javax.swing.JLabel();
|
||||||
totalTimeNow = new javax.swing.JLabel();
|
totalTimeNow = new javax.swing.JLabel();
|
||||||
currentTimeLabel = new javax.swing.JLabel();
|
currentTimeLabel = new javax.swing.JLabel();
|
||||||
notesButton = new javax.swing.JButton();
|
|
||||||
optionsButton = new javax.swing.JButton();
|
optionsButton = new javax.swing.JButton();
|
||||||
|
notesButton = new javax.swing.JToggleButton();
|
||||||
optionsMenu = new javax.swing.JPopupMenu();
|
optionsMenu = new javax.swing.JPopupMenu();
|
||||||
saveTimelineMenuItem = new javax.swing.JMenuItem();
|
saveTimelineMenuItem = new javax.swing.JMenuItem();
|
||||||
saveTimelineAsMenuItem = new javax.swing.JMenuItem();
|
saveTimelineAsMenuItem = new javax.swing.JMenuItem();
|
||||||
@ -159,11 +159,6 @@ public class TimeStamperView extends FrameView implements MouseMotionListener {
|
|||||||
currentTimeLabel.setText(resourceMap.getString("currentTimeLabel.text")); // NOI18N
|
currentTimeLabel.setText(resourceMap.getString("currentTimeLabel.text")); // NOI18N
|
||||||
currentTimeLabel.setName("currentTimeLabel"); // NOI18N
|
currentTimeLabel.setName("currentTimeLabel"); // NOI18N
|
||||||
|
|
||||||
notesButton.setAction(actionMap.get("editNotes")); // NOI18N
|
|
||||||
notesButton.setHideActionText(true);
|
|
||||||
notesButton.setMargin(new java.awt.Insets(0, 0, 0, 0));
|
|
||||||
notesButton.setName("notesButton"); // NOI18N
|
|
||||||
|
|
||||||
optionsButton.setIcon(resourceMap.getIcon("optionsButton.icon")); // NOI18N
|
optionsButton.setIcon(resourceMap.getIcon("optionsButton.icon")); // NOI18N
|
||||||
optionsButton.setContentAreaFilled(false);
|
optionsButton.setContentAreaFilled(false);
|
||||||
optionsButton.setFocusPainted(false);
|
optionsButton.setFocusPainted(false);
|
||||||
@ -186,6 +181,11 @@ public class TimeStamperView extends FrameView implements MouseMotionListener {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
notesButton.setAction(actionMap.get("editNotes")); // NOI18N
|
||||||
|
notesButton.setHideActionText(true);
|
||||||
|
notesButton.setMargin(new java.awt.Insets(0, 0, 0, 0));
|
||||||
|
notesButton.setName("notesButton"); // NOI18N
|
||||||
|
|
||||||
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(
|
||||||
@ -232,7 +232,7 @@ public class TimeStamperView extends FrameView implements MouseMotionListener {
|
|||||||
.addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
.addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||||
.addComponent(currentTimeLabel)
|
.addComponent(currentTimeLabel)
|
||||||
.addComponent(totalTimeNow))))
|
.addComponent(totalTimeNow))))
|
||||||
.addContainerGap(24, Short.MAX_VALUE))
|
.addContainerGap(31, Short.MAX_VALUE))
|
||||||
);
|
);
|
||||||
|
|
||||||
optionsMenu.setName("optionsMenu"); // NOI18N
|
optionsMenu.setName("optionsMenu"); // NOI18N
|
||||||
@ -291,7 +291,14 @@ private void optionsButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIR
|
|||||||
|
|
||||||
@Action
|
@Action
|
||||||
public void editNotes() {
|
public void editNotes() {
|
||||||
// TODO:
|
notesDialog.setVisible(notesButton.isSelected());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNotesForActiveTask(String notes) {
|
||||||
|
Timeline t = ((TimeStamperApp) getApplication()).getActiveTimeline();
|
||||||
|
Timeline.TimelineMarker tm = t.getLastMarker(new Date());
|
||||||
|
if (tm == null) return;
|
||||||
|
tm.setNotes(notes);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||||
@ -300,7 +307,7 @@ private void optionsButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIR
|
|||||||
private javax.swing.JButton exitButton;
|
private javax.swing.JButton exitButton;
|
||||||
private javax.swing.JMenuItem loadTimelineMenuItem;
|
private javax.swing.JMenuItem loadTimelineMenuItem;
|
||||||
private javax.swing.JPanel mainPanel;
|
private javax.swing.JPanel mainPanel;
|
||||||
private javax.swing.JButton notesButton;
|
private javax.swing.JToggleButton notesButton;
|
||||||
private javax.swing.JButton optionsButton;
|
private javax.swing.JButton optionsButton;
|
||||||
private javax.swing.JPopupMenu optionsMenu;
|
private javax.swing.JPopupMenu optionsMenu;
|
||||||
private javax.swing.JMenuItem saveTimelineAsMenuItem;
|
private javax.swing.JMenuItem saveTimelineAsMenuItem;
|
||||||
@ -316,47 +323,74 @@ private void optionsButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIR
|
|||||||
private Font boldTaskFont;
|
private Font boldTaskFont;
|
||||||
private Font thinTaskFont;
|
private Font thinTaskFont;
|
||||||
private Date mostRecentTask;
|
private Date mostRecentTask;
|
||||||
|
private NotesDialog notesDialog;
|
||||||
|
|
||||||
public void mouseDragged(MouseEvent e) {
|
public void mouseDragged(MouseEvent e) {
|
||||||
Point currentMousePoint = e.getLocationOnScreen();
|
getFrame().setLocation(calculateWindowMovement(e.getLocationOnScreen(),
|
||||||
|
mousePressRelativeToFrame, getFrame().getBounds(),
|
||||||
|
new Rectangle(Toolkit.getDefaultToolkit().getScreenSize())));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Point calculateWindowMovement(Point currentMousePoint,
|
||||||
|
Point mousePressRelativeToWindow, Rectangle windowBounds,
|
||||||
|
Rectangle... snapBoxes) {
|
||||||
|
|
||||||
// this is the point we will compute as the new upper left
|
// this is the point we will compute as the new upper left
|
||||||
// coordinate of the frame. It needs to be translated some to account
|
// 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
|
// for the fact that the user can press the mouse anywhere on the
|
||||||
// main panel.
|
// main panel.
|
||||||
Point finalPoint = (Point) currentMousePoint.clone();
|
Point currentWindowPoint = (Point) currentMousePoint.clone();
|
||||||
// find out where the new point should be, ignoreing screen bounds
|
// find out where the new point should be, ignoreing screen bounds
|
||||||
finalPoint.translate(-mousePressRelativeToFrame.x,
|
currentWindowPoint.translate(-mousePressRelativeToWindow.x,
|
||||||
-mousePressRelativeToFrame.y);
|
-mousePressRelativeToWindow.y);
|
||||||
|
|
||||||
// get the current frame bounds
|
Point finalWindowPoint = (Point) currentWindowPoint.clone();
|
||||||
Rectangle frameBounds = getFrame().getBounds();
|
|
||||||
|
|
||||||
// screen resolution
|
// snap tests. In the event of a conflict in snaps positions, the
|
||||||
Dimension resolution = Toolkit.getDefaultToolkit().getScreenSize();
|
// last snap wins
|
||||||
|
int wUp = windowBounds.y;
|
||||||
|
int wDown = windowBounds.y + windowBounds.height;
|
||||||
|
int wLeft = windowBounds.x;
|
||||||
|
int wRight = windowBounds.x + windowBounds.width;
|
||||||
|
|
||||||
// check to see if the frame is near any of the screen boundaries
|
// currentTaskLabel.setText("U:" + wUp + " D:" + wDown + " L:" + wLeft
|
||||||
|
// + " R:" + wRight);
|
||||||
|
|
||||||
|
for (Rectangle r : snapBoxes) {
|
||||||
|
int rUp = r.y;
|
||||||
|
int rDown = r.y + r.height;
|
||||||
|
int rLeft = r.x;
|
||||||
|
int rRight = r.x + r.width;
|
||||||
|
|
||||||
|
// check to see if the window is near any of the snap boundaries
|
||||||
// if it is, 'snap' the final point to that boundary.
|
// if it is, 'snap' the final point to that boundary.
|
||||||
if (frameBounds.x < 20)
|
if (Math.abs(rUp - wUp) < 20) // top of window to top of rect
|
||||||
finalPoint.translate(-finalPoint.x, 0);
|
finalWindowPoint.y = rUp;
|
||||||
if (frameBounds.y < 20)
|
else if (Math.abs(rUp - wDown) < 20) // bot of w to top of r
|
||||||
finalPoint.translate(0, -finalPoint.y);
|
finalWindowPoint.y = rUp - windowBounds.height;
|
||||||
if ((resolution.width - (frameBounds.x + frameBounds.width)) < 20)
|
else if (Math.abs(rDown - wUp) < 20) // top of w to bot of r
|
||||||
finalPoint.translate(resolution.width -
|
finalWindowPoint.y = rDown;
|
||||||
(finalPoint.x + frameBounds.width), 0);
|
else if (Math.abs(rDown - wDown) < 20) // bot of w to bot of r
|
||||||
if ((resolution.height - (frameBounds.y + frameBounds.height)) < 20)
|
finalWindowPoint.y = rDown - windowBounds.height;
|
||||||
finalPoint.translate(0, resolution.height -
|
|
||||||
(finalPoint.y + frameBounds.height));
|
|
||||||
|
|
||||||
|
if (Math.abs(rLeft - wLeft) < 20) // left of w to left of r
|
||||||
|
finalWindowPoint.x = rLeft;
|
||||||
|
else if (Math.abs(rLeft - wRight) < 20) // right of w to left of r
|
||||||
|
finalWindowPoint.x = rLeft - windowBounds.width;
|
||||||
|
else if (Math.abs(rRight - wLeft) < 20) // left of w to right of r
|
||||||
|
finalWindowPoint.x = rRight;
|
||||||
|
else if (Math.abs(rRight - wRight) < 20) // right of w to right of r
|
||||||
|
finalWindowPoint.x = rRight - windowBounds.width;
|
||||||
|
}
|
||||||
|
|
||||||
// this point represents a backwards version of the initial calculation
|
// this point represents a backwards version of the initial calculation
|
||||||
// to find the finalPoint. It says, based on the current final point,
|
// 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
|
// 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
|
// should the mouse be, based on how far it was relative to the point
|
||||||
// when the user pressed it.
|
// when the user pressed it.
|
||||||
Point whereMouseShouldBe = (Point) finalPoint.clone();
|
Point whereMouseShouldBe = (Point) finalWindowPoint.clone();
|
||||||
whereMouseShouldBe.translate(mousePressRelativeToFrame.x,
|
whereMouseShouldBe.translate(mousePressRelativeToWindow.x,
|
||||||
mousePressRelativeToFrame.y);
|
mousePressRelativeToWindow.y);
|
||||||
|
|
||||||
// if the actual mouse location is different from the expected location,
|
// if the actual mouse location is different from the expected location,
|
||||||
// then we know that the snapping behaviour has altered the frames new
|
// then we know that the snapping behaviour has altered the frames new
|
||||||
@ -365,13 +399,12 @@ private void optionsButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIR
|
|||||||
// position. In this case, we want to ignore the snap calculations and
|
// position. In this case, we want to ignore the snap calculations and
|
||||||
// base the new frame location entirely on the current mouse location
|
// base the new frame location entirely on the current mouse location
|
||||||
if (whereMouseShouldBe.distance(currentMousePoint) > 30) {
|
if (whereMouseShouldBe.distance(currentMousePoint) > 30) {
|
||||||
finalPoint = (Point) currentMousePoint.clone();
|
finalWindowPoint = (Point) currentMousePoint.clone();
|
||||||
finalPoint.translate(-mousePressRelativeToFrame.x,
|
finalWindowPoint.translate(-mousePressRelativeToWindow.x,
|
||||||
-mousePressRelativeToFrame.y);
|
-mousePressRelativeToWindow.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
// once we've figured out where to go, put us there :)
|
return finalWindowPoint;
|
||||||
getFrame().setLocation(finalPoint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void mouseMoved(MouseEvent e) {
|
public void mouseMoved(MouseEvent e) {
|
||||||
@ -408,6 +441,7 @@ private void optionsButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIR
|
|||||||
startTimeLabel.setText(Timeline.shortFormat.format(lastMarker.getTimestamp()));
|
startTimeLabel.setText(Timeline.shortFormat.format(lastMarker.getTimestamp()));
|
||||||
|
|
||||||
taskTextField.setText(lastMarker.getMark());
|
taskTextField.setText(lastMarker.getMark());
|
||||||
|
notesDialog.setNotes(lastMarker.getNotes());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
4
src/jdbernard/timestamper/resources/NotesDialog.properties
Executable file
4
src/jdbernard/timestamper/resources/NotesDialog.properties
Executable file
@ -0,0 +1,4 @@
|
|||||||
|
# To change this template, choose Tools | Templates
|
||||||
|
# and open the template in the editor.
|
||||||
|
|
||||||
|
mainPanel.toolTipText=Write notes for this event.
|
@ -44,3 +44,4 @@ exit.Action.text=Exit
|
|||||||
exit.Action.smallIcon=/jdbernard/timestamper/resources/icons/16-em-cross.png
|
exit.Action.smallIcon=/jdbernard/timestamper/resources/icons/16-em-cross.png
|
||||||
exit.Action.shortDescription=Close the application.
|
exit.Action.shortDescription=Close the application.
|
||||||
exit.Action.icon=/jdbernard/timestamper/resources/icons/16-em-cross.png
|
exit.Action.icon=/jdbernard/timestamper/resources/icons/16-em-cross.png
|
||||||
|
notesButton2.text=jToggleButton1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user