mirror of
https://github.com/robertvokac/time-calc.git
synced 2025-03-25 07:27:49 +01:00
Added several improvements
This commit is contained in:
parent
efa6e1437e
commit
f9bad51649
@ -68,43 +68,43 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
|
|||||||
boolean reset = altDown;
|
boolean reset = altDown;
|
||||||
switch (keyCode) {
|
switch (keyCode) {
|
||||||
case KeyEvent.VK_Y: {
|
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,
|
updateProperty(timeCalcConfiguration.testYearCustomProperty, increase, decrease, reset,
|
||||||
Calendar.YEAR);
|
Calendar.YEAR);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case KeyEvent.VK_O: {
|
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,
|
updateProperty(timeCalcConfiguration.testMonthCustomProperty, increase, decrease, reset,
|
||||||
Calendar.MONTH);
|
Calendar.MONTH);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case KeyEvent.VK_D: {
|
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,
|
updateProperty(timeCalcConfiguration.testDayCustomProperty, increase, decrease, reset,
|
||||||
Calendar.DAY_OF_MONTH);
|
Calendar.DAY_OF_MONTH);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case KeyEvent.VK_H: {
|
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,
|
updateProperty(timeCalcConfiguration.testHourCustomProperty, increase, decrease, reset,
|
||||||
Calendar.HOUR_OF_DAY);
|
Calendar.HOUR_OF_DAY);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case KeyEvent.VK_M: {
|
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,
|
updateProperty(timeCalcConfiguration.testMinuteCustomProperty, increase, decrease, reset,
|
||||||
Calendar.MINUTE);
|
Calendar.MINUTE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case KeyEvent.VK_S: {
|
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,
|
updateProperty(timeCalcConfiguration.testSecondCustomProperty, increase, decrease, reset,
|
||||||
Calendar.SECOND);
|
Calendar.SECOND);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case KeyEvent.VK_I: {
|
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,
|
updateProperty(timeCalcConfiguration.testMillisecondCustomProperty, increase, decrease, reset,
|
||||||
Calendar.MILLISECOND);
|
Calendar.MILLISECOND);
|
||||||
break;
|
break;
|
||||||
@ -145,6 +145,10 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
|
|||||||
if(Calendar.MONTH == timeUnit) {
|
if(Calendar.MONTH == timeUnit) {
|
||||||
newValue ++;
|
newValue ++;
|
||||||
}
|
}
|
||||||
|
if(reset) {
|
||||||
|
newValue = Integer.MAX_VALUE;
|
||||||
|
}
|
||||||
|
integerProperty.setValue(newValue);
|
||||||
int newYear = cal.get(Calendar.YEAR);
|
int newYear = cal.get(Calendar.YEAR);
|
||||||
int newMonth = cal.get(Calendar.MONTH) + 1;
|
int newMonth = cal.get(Calendar.MONTH) + 1;
|
||||||
int newDay = cal.get(Calendar.DAY_OF_MONTH);
|
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.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.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.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);
|
default: throw new TimeCalcException("Unsupported time unit: " + timeUnit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(decrease){
|
if(decrease){
|
||||||
switch(timeUnit) {
|
switch(timeUnit) {
|
||||||
case Calendar.YEAR: if(oldMonth != newMonth) { updateProperty(timeCalcConfiguration.testMonthCustomProperty, increase, decrease, reset, Calendar.MONTH);}break;
|
case Calendar.YEAR: break;
|
||||||
case Calendar.MONTH:if(oldDay != newDay) { updateProperty(timeCalcConfiguration.testDayCustomProperty, increase, decrease, reset, Calendar.DAY_OF_MONTH);}break;
|
case Calendar.MONTH:if(oldYear != newYear) { updateProperty(timeCalcConfiguration.testYearCustomProperty, increase, decrease, reset, Calendar.YEAR);}break;
|
||||||
case Calendar.DAY_OF_MONTH:if(oldHour != newHour) { updateProperty(timeCalcConfiguration.testHourCustomProperty, increase, decrease, reset, Calendar.HOUR_OF_DAY);}break;
|
case Calendar.DAY_OF_MONTH:if(oldMonth != newMonth) { updateProperty(timeCalcConfiguration.testMinuteCustomProperty, increase, decrease, reset, Calendar.MONTH);}break;
|
||||||
case Calendar.HOUR_OF_DAY:if(oldMinute != newMinute) { updateProperty(timeCalcConfiguration.testMinuteCustomProperty, increase, decrease, reset, Calendar.MINUTE);}break;
|
case Calendar.HOUR_OF_DAY:if(oldDay != newDay) { updateProperty(timeCalcConfiguration.testSecondCustomProperty, increase, decrease, reset, Calendar.DAY_OF_MONTH);}break;
|
||||||
case Calendar.MINUTE:if(oldSecond != newSecond) { updateProperty(timeCalcConfiguration.testSecondCustomProperty, increase, decrease, reset, Calendar.SECOND);}break;
|
case Calendar.MINUTE:if(oldHour != newHour) { updateProperty(timeCalcConfiguration.testMillisecondCustomProperty, increase, decrease, reset, Calendar.HOUR_OF_DAY);}break;
|
||||||
case Calendar.SECOND:if(oldMillisecond != newMillisecond) { updateProperty(timeCalcConfiguration.testMillisecondCustomProperty, increase, decrease, reset, Calendar.MILLISECOND);}break;
|
case Calendar.SECOND:if(oldMinute != newMinute) { updateProperty(timeCalcConfiguration.testMillisecondCustomProperty, increase, decrease, reset, Calendar.MINUTE);}break;
|
||||||
case Calendar.MILLISECOND: break;
|
case Calendar.MILLISECOND: if(oldSecond != newSecond) { updateProperty(timeCalcConfiguration.testMillisecondCustomProperty, increase, decrease, reset, Calendar.SECOND);}break;
|
||||||
default: throw new TimeCalcException("Unsupported time unit: " + timeUnit);
|
default: throw new TimeCalcException("Unsupported time unit: " + timeUnit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(reset) {
|
|
||||||
newValue = Integer.MAX_VALUE;
|
|
||||||
}
|
|
||||||
integerProperty.setValue(newValue);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processKeyCode(int keyCode) {
|
private void processKeyCode(int keyCode) {
|
||||||
@ -393,7 +394,6 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case KeyEvent.VK_D: {
|
case KeyEvent.VK_D: {
|
||||||
System.out.println("D");
|
|
||||||
timeCalcConfiguration.testYearCustomProperty.setValue(Integer.MAX_VALUE);
|
timeCalcConfiguration.testYearCustomProperty.setValue(Integer.MAX_VALUE);
|
||||||
timeCalcConfiguration.testMonthCustomProperty.setValue(Integer.MAX_VALUE);
|
timeCalcConfiguration.testMonthCustomProperty.setValue(Integer.MAX_VALUE);
|
||||||
timeCalcConfiguration.testDayCustomProperty.setValue(Integer.MAX_VALUE);
|
timeCalcConfiguration.testDayCustomProperty.setValue(Integer.MAX_VALUE);
|
||||||
|
@ -248,17 +248,6 @@ public class MainWindow extends TWindow {
|
|||||||
Calendar calNow = Calendar.getInstance();
|
Calendar calNow = Calendar.getInstance();
|
||||||
calNow.setTime(new Date());
|
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.yearCustomProperty.bindTo(timeCalcConfiguration.testYearCustomProperty);
|
||||||
time.monthCustomProperty.bindTo(timeCalcConfiguration.testMonthCustomProperty);
|
time.monthCustomProperty.bindTo(timeCalcConfiguration.testMonthCustomProperty);
|
||||||
time.dayCustomProperty.bindTo(timeCalcConfiguration.testDayCustomProperty);
|
time.dayCustomProperty.bindTo(timeCalcConfiguration.testDayCustomProperty);
|
||||||
@ -267,33 +256,15 @@ public class MainWindow extends TWindow {
|
|||||||
time.secondCustomProperty.bindTo(timeCalcConfiguration.testSecondCustomProperty);
|
time.secondCustomProperty.bindTo(timeCalcConfiguration.testSecondCustomProperty);
|
||||||
time.millisecondCustomProperty.bindTo(timeCalcConfiguration.testMillisecondCustomProperty);
|
time.millisecondCustomProperty.bindTo(timeCalcConfiguration.testMillisecondCustomProperty);
|
||||||
time.allowCustomValuesProperty.setValue(true);
|
time.allowCustomValuesProperty.setValue(true);
|
||||||
bindToIfPropertyMissing(testProperties, "test.current.day", calNow,
|
analogClock.dayProperty.bindTo(time.dayProperty);
|
||||||
Calendar.DAY_OF_MONTH, analogClock.dayProperty,
|
analogClock.monthProperty.bindTo(time.monthProperty);
|
||||||
time.dayProperty);
|
analogClock.yearProperty.bindTo(time.yearProperty);
|
||||||
bindToIfPropertyMissing(testProperties, "test.current.month", calNow,
|
analogClock.hourProperty.bindTo(time.hourProperty);
|
||||||
Calendar.MONTH, analogClock.monthProperty, time.monthProperty);
|
analogClock.minuteProperty.bindTo(time.minuteProperty);
|
||||||
bindToIfPropertyMissing(testProperties, "test.current.year", calNow,
|
analogClock.secondProperty.bindTo( time.secondProperty);
|
||||||
Calendar.YEAR, analogClock.yearProperty, time.yearProperty);
|
analogClock.millisecondProperty.bindTo(time.millisecondProperty);
|
||||||
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);
|
|
||||||
|
|
||||||
if (testProperties.containsKey("test.current.year") || testProperties
|
analogClock.dayOfWeekProperty.bindTo(time.dayOfWeek);
|
||||||
.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.millisecondEnabledProperty
|
analogClock.millisecondEnabledProperty
|
||||||
.bindTo(timeCalcConfiguration.clockHandsMillisecondVisibleProperty);
|
.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() {
|
public void openWorkDaysWindow() {
|
||||||
workDaysButton.doClick();
|
workDaysButton.doClick();
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ public class DateFormats {
|
|||||||
= new SimpleDateFormat("EEEE : yyyy-MM-dd", Locale.ENGLISH);
|
= new SimpleDateFormat("EEEE : yyyy-MM-dd", Locale.ENGLISH);
|
||||||
//
|
//
|
||||||
public static DateFormat DATE_TIME_FORMATTER_TIME
|
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
|
public static DateFormat DATE_TIME_FORMATTER_VERY_LONG
|
||||||
= new SimpleDateFormat("yyyy:MM:dd:HH:mm:ss:EEEE", Locale.ENGLISH);
|
= new SimpleDateFormat("yyyy:MM:dd:HH:mm:ss:EEEE", Locale.ENGLISH);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user