diff --git a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/app/TimeCalcKeyAdapter.java b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/app/TimeCalcKeyAdapter.java index 3bb4f42..eba9796 100644 --- a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/app/TimeCalcKeyAdapter.java +++ b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/app/TimeCalcKeyAdapter.java @@ -68,43 +68,43 @@ public class TimeCalcKeyAdapter extends KeyAdapter { boolean reset = altDown; switch (keyCode) { case KeyEvent.VK_Y: { - Utils.showNotification((increase ? "Increasing" : (decrease ? "Decreasing" : "Reseting")) + " year."); + //Utils.showNotification((increase ? "Increasing" : (decrease ? "Decreasing" : "Reseting")) + " year."); updateProperty(timeCalcConfiguration.testYearCustomProperty, increase, decrease, reset, Calendar.YEAR); break; } case KeyEvent.VK_O: { - Utils.showNotification((increase ? "Increasing" : (decrease ? "Decreasing" : "Reseting")) + " month."); + //Utils.showNotification((increase ? "Increasing" : (decrease ? "Decreasing" : "Reseting")) + " month."); updateProperty(timeCalcConfiguration.testMonthCustomProperty, increase, decrease, reset, Calendar.MONTH); break; } case KeyEvent.VK_D: { - Utils.showNotification((increase ? "Increasing" : (decrease ? "Decreasing" : "Reseting")) + " day."); + //Utils.showNotification((increase ? "Increasing" : (decrease ? "Decreasing" : "Reseting")) + " day."); updateProperty(timeCalcConfiguration.testDayCustomProperty, increase, decrease, reset, Calendar.DAY_OF_MONTH); break; } case KeyEvent.VK_H: { - Utils.showNotification((increase ? "Increasing" : (decrease ? "Decreasing" : "Reseting")) + " hour."); + //Utils.showNotification((increase ? "Increasing" : (decrease ? "Decreasing" : "Reseting")) + " hour."); updateProperty(timeCalcConfiguration.testHourCustomProperty, increase, decrease, reset, Calendar.HOUR_OF_DAY); break; } case KeyEvent.VK_M: { - Utils.showNotification((increase ? "Increasing" : (decrease ? "Decreasing" : "Reseting")) + " minute."); + //Utils.showNotification((increase ? "Increasing" : (decrease ? "Decreasing" : "Reseting")) + " minute."); updateProperty(timeCalcConfiguration.testMinuteCustomProperty, increase, decrease, reset, Calendar.MINUTE); break; } case KeyEvent.VK_S: { - Utils.showNotification((increase ? "Increasing" : (decrease ? "Decreasing" : "Reseting")) + " second."); + //Utils.showNotification((increase ? "Increasing" : (decrease ? "Decreasing" : "Reseting")) + " second."); updateProperty(timeCalcConfiguration.testSecondCustomProperty, increase, decrease, reset, Calendar.SECOND); break; } case KeyEvent.VK_I: { - Utils.showNotification((increase ? "Increasing" : (decrease ? "Decreasing" : "Reseting")) + " millisecond."); + //Utils.showNotification((increase ? "Increasing" : (decrease ? "Decreasing" : "Reseting")) + " millisecond."); updateProperty(timeCalcConfiguration.testMillisecondCustomProperty, increase, decrease, reset, Calendar.MILLISECOND); break; @@ -145,6 +145,10 @@ public class TimeCalcKeyAdapter extends KeyAdapter { if(Calendar.MONTH == timeUnit) { newValue ++; } + if(reset) { + newValue = Integer.MAX_VALUE; + } + integerProperty.setValue(newValue); int newYear = cal.get(Calendar.YEAR); int newMonth = cal.get(Calendar.MONTH) + 1; int newDay = cal.get(Calendar.DAY_OF_MONTH); @@ -160,26 +164,23 @@ public class TimeCalcKeyAdapter extends KeyAdapter { case Calendar.HOUR_OF_DAY:if(oldDay != newDay) { updateProperty(timeCalcConfiguration.testDayCustomProperty, increase, decrease, reset, Calendar.DAY_OF_MONTH);}break; case Calendar.MINUTE:if(oldHour != newHour) { updateProperty(timeCalcConfiguration.testHourCustomProperty, increase, decrease, reset, Calendar.HOUR_OF_DAY);}break; case Calendar.SECOND:if(oldMinute != newMinute) { updateProperty(timeCalcConfiguration.testMinuteCustomProperty, increase, decrease, reset, Calendar.MINUTE);}break; - case Calendar.MILLISECOND:if(oldSecond != newSecond) { updateProperty(timeCalcConfiguration.testSecondCustomProperty, increase, decrease, reset, Calendar.MILLISECOND);}break; + case Calendar.MILLISECOND:if(oldSecond != newSecond) { updateProperty(timeCalcConfiguration.testSecondCustomProperty, increase, decrease, reset, Calendar.SECOND);}break; default: throw new TimeCalcException("Unsupported time unit: " + timeUnit); } } if(decrease){ switch(timeUnit) { - case Calendar.YEAR: if(oldMonth != newMonth) { updateProperty(timeCalcConfiguration.testMonthCustomProperty, increase, decrease, reset, Calendar.MONTH);}break; - case Calendar.MONTH:if(oldDay != newDay) { updateProperty(timeCalcConfiguration.testDayCustomProperty, increase, decrease, reset, Calendar.DAY_OF_MONTH);}break; - case Calendar.DAY_OF_MONTH:if(oldHour != newHour) { updateProperty(timeCalcConfiguration.testHourCustomProperty, increase, decrease, reset, Calendar.HOUR_OF_DAY);}break; - case Calendar.HOUR_OF_DAY:if(oldMinute != newMinute) { updateProperty(timeCalcConfiguration.testMinuteCustomProperty, increase, decrease, reset, Calendar.MINUTE);}break; - case Calendar.MINUTE:if(oldSecond != newSecond) { updateProperty(timeCalcConfiguration.testSecondCustomProperty, increase, decrease, reset, Calendar.SECOND);}break; - case Calendar.SECOND:if(oldMillisecond != newMillisecond) { updateProperty(timeCalcConfiguration.testMillisecondCustomProperty, increase, decrease, reset, Calendar.MILLISECOND);}break; - case Calendar.MILLISECOND: break; + case Calendar.YEAR: break; + case Calendar.MONTH:if(oldYear != newYear) { updateProperty(timeCalcConfiguration.testYearCustomProperty, increase, decrease, reset, Calendar.YEAR);}break; + case Calendar.DAY_OF_MONTH:if(oldMonth != newMonth) { updateProperty(timeCalcConfiguration.testMinuteCustomProperty, increase, decrease, reset, Calendar.MONTH);}break; + case Calendar.HOUR_OF_DAY:if(oldDay != newDay) { updateProperty(timeCalcConfiguration.testSecondCustomProperty, increase, decrease, reset, Calendar.DAY_OF_MONTH);}break; + case Calendar.MINUTE:if(oldHour != newHour) { updateProperty(timeCalcConfiguration.testMillisecondCustomProperty, increase, decrease, reset, Calendar.HOUR_OF_DAY);}break; + case Calendar.SECOND:if(oldMinute != newMinute) { updateProperty(timeCalcConfiguration.testMillisecondCustomProperty, increase, decrease, reset, Calendar.MINUTE);}break; + case Calendar.MILLISECOND: if(oldSecond != newSecond) { updateProperty(timeCalcConfiguration.testMillisecondCustomProperty, increase, decrease, reset, Calendar.SECOND);}break; default: throw new TimeCalcException("Unsupported time unit: " + timeUnit); } } - if(reset) { - newValue = Integer.MAX_VALUE; - } - integerProperty.setValue(newValue); + } private void processKeyCode(int keyCode) { @@ -393,7 +394,6 @@ public class TimeCalcKeyAdapter extends KeyAdapter { break; } case KeyEvent.VK_D: { - System.out.println("D"); timeCalcConfiguration.testYearCustomProperty.setValue(Integer.MAX_VALUE); timeCalcConfiguration.testMonthCustomProperty.setValue(Integer.MAX_VALUE); timeCalcConfiguration.testDayCustomProperty.setValue(Integer.MAX_VALUE); diff --git a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/common/MainWindow.java b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/common/MainWindow.java index 83bcb38..50eb410 100644 --- a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/common/MainWindow.java +++ b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/common/MainWindow.java @@ -248,17 +248,6 @@ public class MainWindow extends TWindow { Calendar calNow = Calendar.getInstance(); calNow.setTime(new Date()); - Properties testProperties = new Properties(); - File testPropertiesFile = new File("test.txt"); - try { - if (testPropertiesFile.exists()) { - testProperties.load(new FileInputStream(testPropertiesFile)); - } - } catch (IOException ex) { - Logger.getLogger(MainWindow.class.getName()) - .log(Level.SEVERE, null, ex); - } - time.yearCustomProperty.bindTo(timeCalcConfiguration.testYearCustomProperty); time.monthCustomProperty.bindTo(timeCalcConfiguration.testMonthCustomProperty); time.dayCustomProperty.bindTo(timeCalcConfiguration.testDayCustomProperty); @@ -267,33 +256,15 @@ public class MainWindow extends TWindow { time.secondCustomProperty.bindTo(timeCalcConfiguration.testSecondCustomProperty); time.millisecondCustomProperty.bindTo(timeCalcConfiguration.testMillisecondCustomProperty); time.allowCustomValuesProperty.setValue(true); - bindToIfPropertyMissing(testProperties, "test.current.day", calNow, - Calendar.DAY_OF_MONTH, analogClock.dayProperty, - time.dayProperty); - bindToIfPropertyMissing(testProperties, "test.current.month", calNow, - Calendar.MONTH, analogClock.monthProperty, time.monthProperty); - bindToIfPropertyMissing(testProperties, "test.current.year", calNow, - Calendar.YEAR, analogClock.yearProperty, time.yearProperty); - bindToIfPropertyMissing(testProperties, "test.current.hour", calNow, - Calendar.HOUR, analogClock.hourProperty, time.hourProperty); - bindToIfPropertyMissing(testProperties, "test.current.minute", calNow, - Calendar.MINUTE, analogClock.minuteProperty, - time.minuteProperty); - bindToIfPropertyMissing(testProperties, "test.current.second", calNow, - Calendar.SECOND, analogClock.secondProperty, - time.secondProperty); - bindToIfPropertyMissing(testProperties, "test.current.millisecond", - calNow, Calendar.MILLISECOND, analogClock.millisecondProperty, - time.millisecondProperty); + analogClock.dayProperty.bindTo(time.dayProperty); + analogClock.monthProperty.bindTo(time.monthProperty); + analogClock.yearProperty.bindTo(time.yearProperty); + analogClock.hourProperty.bindTo(time.hourProperty); + analogClock.minuteProperty.bindTo(time.minuteProperty); + analogClock.secondProperty.bindTo( time.secondProperty); + analogClock.millisecondProperty.bindTo(time.millisecondProperty); - if (testProperties.containsKey("test.current.year") || testProperties - .containsKey("test.current.month") || testProperties - .containsKey("test.current.day")) { - analogClock.dayOfWeekProperty - .setValue(calNow.get(Calendar.DAY_OF_WEEK)); - } else { - analogClock.dayOfWeekProperty.bindTo(time.dayOfWeek); - } + analogClock.dayOfWeekProperty.bindTo(time.dayOfWeek); analogClock.millisecondEnabledProperty .bindTo(timeCalcConfiguration.clockHandsMillisecondVisibleProperty); @@ -664,20 +635,6 @@ public class MainWindow extends TWindow { } - private void bindToIfPropertyMissing(Properties properties, String key, - Calendar cal, int timeUnit, IntegerProperty firstProperty, - Property secondProperty) { - if (properties.containsKey(key)) { - cal.set(timeUnit, Integer.parseInt( - (String) properties.get(key)) + ( - timeUnit == Calendar.MONTH ? -1 : 0)); - firstProperty.setValue(Integer.valueOf( - (String) properties.get(key))); - } else { - firstProperty.bindTo(secondProperty); - } - } - public void openWorkDaysWindow() { workDaysButton.doClick(); } diff --git a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/utils/common/DateFormats.java b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/utils/common/DateFormats.java index 8245842..d4c4b55 100644 --- a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/utils/common/DateFormats.java +++ b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/utils/common/DateFormats.java @@ -17,7 +17,7 @@ public class DateFormats { = new SimpleDateFormat("EEEE : yyyy-MM-dd", Locale.ENGLISH); // public static DateFormat DATE_TIME_FORMATTER_TIME - = new SimpleDateFormat("HH:mm:ss", Locale.ENGLISH); + = new SimpleDateFormat("HH:mm:ss:SSS", Locale.ENGLISH); public static DateFormat DATE_TIME_FORMATTER_VERY_LONG = new SimpleDateFormat("yyyy:MM:dd:HH:mm:ss:EEEE", Locale.ENGLISH);