Subversion Repositories public

Compare Revisions

Ignore whitespace Rev 93 → Rev 92

/lwtt/trunk/cz/aiken/util/lwtt/TaskPropetiesDialog.form
File deleted
/lwtt/trunk/cz/aiken/util/lwtt/TaskPropetiesDialog.java
File deleted
/lwtt/trunk/cz/aiken/util/lwtt/TaskTableModel.java
41,7 → 41,6
private javax.swing.Timer timer = new javax.swing.Timer(300000, this);
private MessageFormat timeFormat = new MessageFormat("{0,number}:{1,number,00}");
private MessageFormat priceFormat = new MessageFormat("{0,number}.{1,number,00}");
private TaskFrame taskFrame = null;
70,10 → 69,6
long mins = tasks.get(rowIndex).getConsumption() / 60000;
BigDecimal hm[] = new BigDecimal((int) mins).divideAndRemainder(new BigDecimal(60));
return timeFormat.format(hm);
case 2:
double tp = tasks.get(rowIndex).getTotalPrice();
BigDecimal pr[] = new BigDecimal(tp * 100).divideAndRemainder(new BigDecimal(100));
return priceFormat.format(pr);
default: return null;
}
}
91,7 → 86,7
* @return column count
*/
public int getColumnCount() {
return 3;
return 2;
}
 
/**
120,7 → 115,6
switch (column) {
case 0: return "Task name";
case 1: return "Time consumption [h:min]";
case 2: return "Total price";
default: return "";
}
}
136,7 → 130,6
switch (columnIndex) {
case 0: return String.class;
case 1: return StringBuffer.class;
case 2: return StringBuffer.class;
default: return Void.class;
}
}
153,10 → 146,6
return columnIndex == 0;
}
public Task getTask(int index) {
return tasks.get(index);
}
/**
* Creates a new task.
*/
194,7 → 183,6
Task t = tasks.get(i);
t.start();
fireTableCellUpdated(i, 1);
fireTableCellUpdated(i, 2);
}
}
208,7 → 196,6
Task t = tasks.get(i);
t.stop();
fireTableCellUpdated(i, 1);
fireTableCellUpdated(i, 2);
}
}
234,7 → 221,6
Task t = tasks.get(i);
t.setConsumption(0);
fireTableCellUpdated(i, 1);
fireTableCellUpdated(i, 2);
}
}
302,12 → 288,10
String ids = key.substring(0, key.length() - 5);
String name = props.getProperty(ids + ".name");
String cons = props.getProperty(ids + ".consumption");
String price = props.getProperty(ids + ".price", "1");
try {
int id = Integer.parseInt(ids);
long cn = Long.parseLong(cons);
double pr = Double.parseDouble(price);
Task t = new Task(id, name, cn, pr);
Task t = new Task(id, name, cn);
t.setActionListener(this);
tasks.add(t);
} catch (NumberFormatException e) {
347,7 → 331,6
String id = Integer.toString(t.getId());
props.setProperty(id + ".name", t.getName());
props.setProperty(id + ".consumption", Long.toString(t.getConsumption()));
props.setProperty(id + ".price", Double.toString(t.getPrice()));
}
try {
375,7 → 358,6
else {
int row = tasks.indexOf(src);
fireTableCellUpdated(row, 1);
fireTableCellUpdated(row, 2);
}
}
/lwtt/trunk/cz/aiken/util/lwtt/TaskFrame.form
13,7 → 13,6
</Events>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<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="2"/>
67,9 → 66,7
<Component id="removeButton" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="resetButton" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="propsButton" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="152" max="32767" attributes="0"/>
<EmptySpace pref="251" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
80,7 → 77,6
<Component id="addButton" alignment="3" pref="25" max="32767" attributes="0"/>
<Component id="removeButton" alignment="3" pref="25" max="32767" attributes="0"/>
<Component id="resetButton" alignment="3" pref="25" max="32767" attributes="0"/>
<Component id="propsButton" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
</DimensionLayout>
</Layout>
125,15 → 121,6
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="resetPressed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="propsButton">
<Properties>
<Property name="text" type="java.lang.String" value="Properties..."/>
<Property name="actionCommand" type="java.lang.String" value="Properties"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="propsPressed"/>
</Events>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
/lwtt/trunk/cz/aiken/util/lwtt/Task.java
25,7 → 25,6
 
import javax.swing.Timer;
import java.awt.event.*;
import java.math.*;
 
/**
* This class represents a tracked task.
36,7 → 35,6
private String name = "Unnamed task";
private long consumption = 0L;
private double price = 1;
private Timer timer = null;
/**
44,11 → 42,6
*/
public static final int PERIOD = 10000;
/**
* time units per hour
*/
public static final double UNITS_PER_HOUR = 3600000;
private ActionListener listener = null;
private static int nextId = 0;
75,13 → 68,11
* @param id task identifier
* @param name task name
* @param consumption up to now time consumption
* @param price price per hour
*/
public Task(int id, String name, long consumption, double price) {
public Task(int id, String name, long consumption) {
this.id = id;
this.name = name;
this.consumption = consumption;
this.price = price;
if (id >= nextId)
nextId = id + 1;
136,31 → 127,6
}
/**
* Sets the price per hour [currency unit].
* Changing this parameter affects the current total price of the task.
* @param price new price value
*/
public void setPrice(double price) {
this.price = price;
}
/**
* Returns the current price per hour [currency unit].
* @return current price value
*/
public double getPrice() {
return price;
}
/**
* Returns the total price of this task [currency unit].
* @return total price of this task
*/
public double getTotalPrice() {
return ((double) consumption) / UNITS_PER_HOUR * price;
}
/**
* Converts the instance to the string representation. It contains
* the task name and consumption.
* @return string representation
/lwtt/trunk/cz/aiken/util/lwtt/TaskFrame.java
111,8 → 111,6
startButton.setEnabled(rcnt < cnt);
stopButton.setEnabled(rcnt > 0);
}
propsButton.setEnabled(cnt == 1);
}
/**
138,7 → 136,6
addButton = new javax.swing.JButton();
removeButton = new javax.swing.JButton();
resetButton = new javax.swing.JButton();
propsButton = new javax.swing.JButton();
jScrollPane1 = new javax.swing.JScrollPane();
jTable1 = new javax.swing.JTable();
 
189,14 → 186,6
}
});
 
propsButton.setText("Properties...");
propsButton.setActionCommand("Properties");
propsButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
propsPressed(evt);
}
});
 
org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
211,9 → 200,7
.add(removeButton)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(resetButton)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(propsButton)
.addContainerGap(152, Short.MAX_VALUE))
.addContainerGap(251, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
222,7 → 209,6
.add(addButton, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 25, Short.MAX_VALUE)
.add(removeButton, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 25, Short.MAX_VALUE)
.add(resetButton, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 25, Short.MAX_VALUE)
.add(propsButton)
);
 
jSplitPane1.setTopComponent(jPanel1);
316,21 → 302,6
updateButtons();
}
}//GEN-LAST:event_startPressed
 
private void propsPressed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_propsPressed
TaskPropetiesDialog d = new TaskPropetiesDialog(this, true);
int start = jTable1.getSelectedRow();
int cnt = jTable1.getSelectedRowCount();
if (cnt == 1) {
Task t = model.getTask(start);
d.setPrice(t.getPrice());
d.setVisible(true);
if (d.getReturnStatus() == TaskPropetiesDialog.RET_OK) {
t.setPrice(d.getPrice());
model.fireTableCellUpdated(start, 2);
}
}
}//GEN-LAST:event_propsPressed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton addButton;
338,7 → 309,6
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JSplitPane jSplitPane1;
private javax.swing.JTable jTable1;
private javax.swing.JButton propsButton;
private javax.swing.JButton removeButton;
private javax.swing.JButton resetButton;
private javax.swing.JButton startButton;