protected void actionToggle() { if (started == null) { miToggle.setText("Stop"); started = new DateTime(); timer.start(); } else { miToggle.setText("Start"); DateTime end = new DateTime(); TimeSpan ts = new TimeSpan(started, end); times.add(ts); period = period.plus(ts.getPeriod()).normalizedStandard(); started = null; timer.stop(); updateTimes(); } }
protected void actionAdjustment() { String result = (String) JOptionPane.showInputDialog(this, "Enter an adjustment", "0 00:00:00.000"); if (result != null && !result.isEmpty()) { try { Period adjustment = format_short.parsePeriod(result); DateTime start = new DateTime(); DateTime end = start.plus(adjustment); TimeSpan ts = new TimeSpan(start, end); times.add(ts); period = period.plus(adjustment); updateTimes(); } catch (IllegalArgumentException ex) { JOptionPane.showMessageDialog(this, ex.toString(), "Error", JOptionPane.ERROR_MESSAGE); } } }
protected void updateTimes() { Period current = started == null ? new Period(0) : new Period(started, new DateTime()); total.setText(Timer.format_full.print(period.plus(current).normalizedStandard(period_type))); time.setText(Timer.format_short.print(current.normalizedStandard(period_type))); }