mirror of
https://github.com/robertvokac/time-calc.git
synced 2025-03-25 07:27:49 +01:00
Added new improvements
This commit is contained in:
parent
2f7f070c80
commit
b9f27fb1c4
@ -16,7 +16,7 @@ import java.io.IOException;
|
|||||||
public class TimeCalcApp {
|
public class TimeCalcApp {
|
||||||
|
|
||||||
public StringProperty visibilityProperty =
|
public StringProperty visibilityProperty =
|
||||||
new StringProperty("timeCalcApp.visibilityReadWriteProperty",
|
new StringProperty("timeCalcApp.visibilityProperty",
|
||||||
Visibility.WEAKLY_COLORED.name());
|
Visibility.WEAKLY_COLORED.name());
|
||||||
private long startNanoTime = 0l;
|
private long startNanoTime = 0l;
|
||||||
|
|
||||||
|
@ -56,7 +56,6 @@ public class TimeCalcManager {
|
|||||||
private final TimeHM startTime;
|
private final TimeHM startTime;
|
||||||
private final TimeHM overtime;
|
private final TimeHM overtime;
|
||||||
private final TimeHM endTime;
|
private final TimeHM endTime;
|
||||||
private final TimeCalcApp timeCalcApp;
|
|
||||||
private boolean stopBeforeEnd = false;
|
private boolean stopBeforeEnd = false;
|
||||||
private final Time time = new Time();
|
private final Time time = new Time();
|
||||||
private final TimeCalcConfiguration timeCalcConfiguration =
|
private final TimeCalcConfiguration timeCalcConfiguration =
|
||||||
@ -64,7 +63,6 @@ public class TimeCalcManager {
|
|||||||
|
|
||||||
public TimeCalcManager(String startTimeIn, String overTimeIn,
|
public TimeCalcManager(String startTimeIn, String overTimeIn,
|
||||||
TimeCalcApp timeCalcApp) {
|
TimeCalcApp timeCalcApp) {
|
||||||
this.timeCalcApp = timeCalcApp;
|
|
||||||
timeCalcConfiguration
|
timeCalcConfiguration
|
||||||
.setFromTimeCalcProperties(TimeCalcProperties.getInstance());
|
.setFromTimeCalcProperties(TimeCalcProperties.getInstance());
|
||||||
// Utils.everythingHidden
|
// Utils.everythingHidden
|
||||||
@ -101,6 +99,10 @@ public class TimeCalcManager {
|
|||||||
//window.add(weatherButton);
|
//window.add(weatherButton);
|
||||||
window.addAll(configButton, commandButton, jokeButton, restartButton,
|
window.addAll(configButton, commandButton, jokeButton, restartButton,
|
||||||
exitButton);
|
exitButton);
|
||||||
|
boolean onlyGreyOrNone = timeCalcConfiguration.visibilityOnlyGreyOrNoneEnabledProperty.isEnabled();
|
||||||
|
if(onlyGreyOrNone) {
|
||||||
|
timeCalcApp.visibilityProperty.setValue(Visibility.GRAY.name());
|
||||||
|
}
|
||||||
window.addKeyListener(new KeyAdapter() {
|
window.addKeyListener(new KeyAdapter() {
|
||||||
// Key Pressed method
|
// Key Pressed method
|
||||||
public void keyPressed(KeyEvent e) {
|
public void keyPressed(KeyEvent e) {
|
||||||
@ -108,7 +110,7 @@ public class TimeCalcManager {
|
|||||||
.valueOf(timeCalcApp.visibilityProperty.getValue());
|
.valueOf(timeCalcApp.visibilityProperty.getValue());
|
||||||
if (e.getKeyCode() == KeyEvent.VK_UP) {
|
if (e.getKeyCode() == KeyEvent.VK_UP) {
|
||||||
timeCalcApp.visibilityProperty
|
timeCalcApp.visibilityProperty
|
||||||
.setValue(Visibility.STRONGLY_COLORED.name());
|
.setValue(onlyGreyOrNone ? Visibility.GRAY.name() : Visibility.STRONGLY_COLORED.name());
|
||||||
}
|
}
|
||||||
if (e.getKeyCode() == KeyEvent.VK_DOWN) {
|
if (e.getKeyCode() == KeyEvent.VK_DOWN) {
|
||||||
timeCalcApp.visibilityProperty
|
timeCalcApp.visibilityProperty
|
||||||
@ -117,14 +119,14 @@ public class TimeCalcManager {
|
|||||||
if (e.getKeyCode() == KeyEvent.VK_H) {
|
if (e.getKeyCode() == KeyEvent.VK_H) {
|
||||||
if (visibility.isNone()) {
|
if (visibility.isNone()) {
|
||||||
timeCalcApp.visibilityProperty
|
timeCalcApp.visibilityProperty
|
||||||
.setValue(Visibility.STRONGLY_COLORED.name());
|
.setValue(onlyGreyOrNone ? Visibility.GRAY.name() : Visibility.STRONGLY_COLORED.name());
|
||||||
} else {
|
} else {
|
||||||
timeCalcApp.visibilityProperty
|
timeCalcApp.visibilityProperty
|
||||||
.setValue(Visibility.NONE.name());
|
.setValue(Visibility.NONE.name());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (e.getKeyCode() == KeyEvent.VK_G) {
|
if (e.getKeyCode() == KeyEvent.VK_G) {
|
||||||
if (visibility.isGray()) {
|
if (visibility.isGray() && !onlyGreyOrNone) {
|
||||||
timeCalcApp.visibilityProperty
|
timeCalcApp.visibilityProperty
|
||||||
.setValue(Visibility.WEAKLY_COLORED.name());
|
.setValue(Visibility.WEAKLY_COLORED.name());
|
||||||
} else {
|
} else {
|
||||||
@ -134,18 +136,25 @@ public class TimeCalcManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (e.getKeyCode() == KeyEvent.VK_C) {
|
if (e.getKeyCode() == KeyEvent.VK_C) {
|
||||||
if (visibility.isStronglyColored()) {
|
if(!onlyGreyOrNone) {
|
||||||
timeCalcApp.visibilityProperty
|
if (visibility.isStronglyColored()) {
|
||||||
.setValue(Visibility.WEAKLY_COLORED.name());
|
timeCalcApp.visibilityProperty
|
||||||
} else {
|
.setValue(Visibility.WEAKLY_COLORED.name());
|
||||||
timeCalcApp.visibilityProperty
|
} else {
|
||||||
.setValue(Visibility.STRONGLY_COLORED.name());
|
timeCalcApp.visibilityProperty
|
||||||
|
.setValue(
|
||||||
|
Visibility.STRONGLY_COLORED.name());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
timeCalcApp.visibilityProperty.setValue(Visibility.GRAY
|
||||||
|
.name());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (e.getKeyCode() == KeyEvent.VK_V) {
|
if (e.getKeyCode() == KeyEvent.VK_V) {
|
||||||
if (visibility.isNone()) {
|
if (visibility.isNone()) {
|
||||||
timeCalcApp.visibilityProperty
|
timeCalcApp.visibilityProperty
|
||||||
.setValue(Visibility.STRONGLY_COLORED.name());
|
.setValue(onlyGreyOrNone ? Visibility.GRAY.name() : Visibility.STRONGLY_COLORED.name());
|
||||||
} else {
|
} else {
|
||||||
timeCalcApp.visibilityProperty
|
timeCalcApp.visibilityProperty
|
||||||
.setValue(Visibility.NONE.name());
|
.setValue(Visibility.NONE.name());
|
||||||
@ -154,7 +163,7 @@ public class TimeCalcManager {
|
|||||||
if (e.getKeyCode() == KeyEvent.VK_SPACE) {
|
if (e.getKeyCode() == KeyEvent.VK_SPACE) {
|
||||||
if (visibility.isStronglyColored()) {
|
if (visibility.isStronglyColored()) {
|
||||||
timeCalcApp.visibilityProperty
|
timeCalcApp.visibilityProperty
|
||||||
.setValue(Visibility.WEAKLY_COLORED.name());
|
.setValue(onlyGreyOrNone ? Visibility.GRAY.name() : Visibility.WEAKLY_COLORED.name());
|
||||||
}
|
}
|
||||||
if (visibility.isWeaklyColored()) {
|
if (visibility.isWeaklyColored()) {
|
||||||
timeCalcApp.visibilityProperty
|
timeCalcApp.visibilityProperty
|
||||||
@ -166,7 +175,7 @@ public class TimeCalcManager {
|
|||||||
}
|
}
|
||||||
if (visibility.isNone()) {
|
if (visibility.isNone()) {
|
||||||
timeCalcApp.visibilityProperty
|
timeCalcApp.visibilityProperty
|
||||||
.setValue(Visibility.STRONGLY_COLORED.name());
|
.setValue(onlyGreyOrNone ? Visibility.GRAY.name() : Visibility.STRONGLY_COLORED.name());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (e.getKeyCode() == KeyEvent.VK_R) {
|
if (e.getKeyCode() == KeyEvent.VK_R) {
|
||||||
|
@ -20,6 +20,7 @@ public class Property<T> {
|
|||||||
new ArrayList<>();
|
new ArrayList<>();
|
||||||
private final List<ChangeListener<T>>
|
private final List<ChangeListener<T>>
|
||||||
changeListeners = new ArrayList<ChangeListener<T>>();
|
changeListeners = new ArrayList<ChangeListener<T>>();
|
||||||
|
private ChangeListener<T> boundChangeListener = null;
|
||||||
|
|
||||||
public Property(String name, T valueIn) {
|
public Property(String name, T valueIn) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
@ -43,17 +44,21 @@ public class Property<T> {
|
|||||||
throw new TimeCalcException("No bound property");
|
throw new TimeCalcException("No bound property");
|
||||||
}
|
}
|
||||||
this.value = boundToProperty.value;
|
this.value = boundToProperty.value;
|
||||||
|
this.boundToProperty.removeListener(this.boundChangeListener);
|
||||||
|
this.boundChangeListener = null;
|
||||||
this.boundToProperty = null;
|
this.boundToProperty = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void bindTo(Property<T> anotherProperty) {
|
public void bindTo(Property<T> anotherProperty) {
|
||||||
this.boundToProperty = anotherProperty;
|
this.boundToProperty = anotherProperty;
|
||||||
this.boundToProperty
|
this.boundChangeListener =
|
||||||
.addListener((Property<T> p, T oldValue, T newValue) -> {
|
(Property<T> p, T oldValue, T newValue) -> {
|
||||||
this.markInvalid();
|
this.markInvalid();
|
||||||
this.fireValueChangedEvent(oldValue);
|
this.fireValueChangedEvent(oldValue);
|
||||||
//System.out.println("bindTo markInvalid " + p.getName() + " " + p.getValue());
|
//System.out.println("bindTo markInvalid " + p.getName() + " " + p.getValue());
|
||||||
});
|
};
|
||||||
|
this.boundToProperty
|
||||||
|
.addListener(boundChangeListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
public T getValue() {
|
public T getValue() {
|
||||||
@ -101,4 +106,8 @@ public class Property<T> {
|
|||||||
this.changeListeners.add(listener);
|
this.changeListeners.add(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void removeListener(ChangeListener<T> listener) {
|
||||||
|
this.changeListeners.remove(listener);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ clock.hands.second.enabled=true
|
|||||||
clock.hands.millisecond.enabled=false
|
clock.hands.millisecond.enabled=false
|
||||||
battery.waves.enabled=true
|
battery.waves.enabled=true
|
||||||
default-visibility=STRONGLY_COLORED
|
default-visibility=STRONGLY_COLORED
|
||||||
visibility.only-grey-or-none.enabled=false
|
visibility.only-grey-or-none.enabled=true
|
||||||
jokes.enabled=true
|
jokes.enabled=true
|
||||||
commands.enabled=true
|
commands.enabled=true
|
||||||
toasts.enabled=true
|
toasts.enabled=true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user