mirror of
https://github.com/robertvokac/time-calc.git
synced 2025-03-25 07:27:49 +01:00
ConfigWindow III
This commit is contained in:
parent
c59a27d1a1
commit
1ed924fe08
@ -53,7 +53,7 @@ public class CommandActionListener
|
|||||||
Visibility.WEAKLY_COLORED.name());
|
Visibility.WEAKLY_COLORED.name());
|
||||||
break;
|
break;
|
||||||
case "waves":
|
case "waves":
|
||||||
timeCalcConfiguration.batteryWavesEnabledProperty
|
timeCalcConfiguration.batteryWavesVisibleProperty
|
||||||
.setValue(commandsAsArray[1].equals("1"));
|
.setValue(commandsAsArray[1].equals("1"));
|
||||||
break;
|
break;
|
||||||
case "uptime":
|
case "uptime":
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package org.nanoboot.utils.timecalc.app;
|
package org.nanoboot.utils.timecalc.app;
|
||||||
|
|
||||||
import org.nanoboot.utils.timecalc.entity.Visibility;
|
import org.nanoboot.utils.timecalc.entity.Visibility;
|
||||||
|
import org.nanoboot.utils.timecalc.swing.common.MainWindow;
|
||||||
import org.nanoboot.utils.timecalc.utils.common.Constants;
|
import org.nanoboot.utils.timecalc.utils.common.Constants;
|
||||||
import org.nanoboot.utils.timecalc.utils.common.FileConstants;
|
import org.nanoboot.utils.timecalc.utils.common.FileConstants;
|
||||||
import org.nanoboot.utils.timecalc.utils.common.Utils;
|
import org.nanoboot.utils.timecalc.utils.common.Utils;
|
||||||
@ -63,8 +64,8 @@ public class TimeCalcApp {
|
|||||||
Utils.writeTextToFile(FileConstants.STARTTIME_TXT, newStartTime);
|
Utils.writeTextToFile(FileConstants.STARTTIME_TXT, newStartTime);
|
||||||
Utils.writeTextToFile(FileConstants.OVERTIME_TXT, newOvertime);
|
Utils.writeTextToFile(FileConstants.OVERTIME_TXT, newOvertime);
|
||||||
try {
|
try {
|
||||||
TimeCalcManager timeCalc =
|
MainWindow timeCalc =
|
||||||
new TimeCalcManager(newStartTime, newOvertime, this);
|
new MainWindow(newStartTime, newOvertime, this);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
JOptionPane.showMessageDialog(null, "Error: " + e.getMessage(),
|
JOptionPane.showMessageDialog(null, "Error: " + e.getMessage(),
|
||||||
e.getMessage(), JOptionPane.ERROR_MESSAGE);
|
e.getMessage(), JOptionPane.ERROR_MESSAGE);
|
||||||
|
@ -1,64 +1,100 @@
|
|||||||
package org.nanoboot.utils.timecalc.app;
|
package org.nanoboot.utils.timecalc.app;
|
||||||
|
|
||||||
import org.nanoboot.utils.timecalc.entity.Visibility;
|
|
||||||
import org.nanoboot.utils.timecalc.utils.property.BooleanProperty;
|
import org.nanoboot.utils.timecalc.utils.property.BooleanProperty;
|
||||||
|
import org.nanoboot.utils.timecalc.utils.property.Property;
|
||||||
import org.nanoboot.utils.timecalc.utils.property.StringProperty;
|
import org.nanoboot.utils.timecalc.utils.property.StringProperty;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Robert Vokac
|
* @author Robert Vokac
|
||||||
* @since 20.02.2024
|
* @since 20.02.2024
|
||||||
*/
|
*/
|
||||||
public class TimeCalcConfiguration {
|
public class TimeCalcConfiguration {
|
||||||
public final BooleanProperty clockHandLongProperty =
|
public final StringProperty visibilityDefaultProperty = new StringProperty(TimeCalcProperty.VISIBILITY_DEFAULT
|
||||||
new BooleanProperty("clockHandLongProperty", true);
|
.getKey());
|
||||||
public final BooleanProperty clockHandMinuteEnabledProperty =
|
public final BooleanProperty visibilitySupportedColoredProperty =
|
||||||
new BooleanProperty("clockHandMinuteEnabledProperty", true);
|
new BooleanProperty(TimeCalcProperty.VISIBILITY_SUPPORTED_COLORED
|
||||||
public final BooleanProperty clockHandSecondEnabledProperty =
|
.getKey());
|
||||||
new BooleanProperty("clockHandSecondEnabledProperty", true);
|
//
|
||||||
public final BooleanProperty clockHandMillisecondEnabledProperty =
|
public final BooleanProperty clockHandsLongVisibleProperty =
|
||||||
new BooleanProperty("clockHandMillisecondEnabledProperty", false);
|
new BooleanProperty(TimeCalcProperty.CLOCK_HANDS_LONG_VISIBLE
|
||||||
public final BooleanProperty batteryWavesEnabledProperty =
|
.getKey());
|
||||||
new BooleanProperty("batteryWavesEnabledProperty", true);
|
public final BooleanProperty clockHandsMinuteVisibleProperty =
|
||||||
public final StringProperty
|
new BooleanProperty(TimeCalcProperty.CLOCK_HANDS_MINUTE_VISIBLE
|
||||||
visibilityCurrentProperty =
|
.getKey());
|
||||||
new StringProperty("defaultVisibilityProperty",
|
public final BooleanProperty clockHandsSecondVisibleProperty =
|
||||||
Visibility.STRONGLY_COLORED.name());
|
new BooleanProperty(TimeCalcProperty.CLOCK_HANDS_SECOND_VISIBLE
|
||||||
public final BooleanProperty visibilityOnlyGreyOrNoneEnabledProperty =
|
.getKey());
|
||||||
new BooleanProperty("visibilityOnlyGreyOrNoneEnabledProperty",
|
public final BooleanProperty clockHandsMillisecondVisibleProperty =
|
||||||
false);
|
new BooleanProperty(TimeCalcProperty.CLOCK_HANDS_MILLISECOND_VISIBLE
|
||||||
public final BooleanProperty jokesEnabledProperty =
|
.getKey());
|
||||||
new BooleanProperty("jokesEnabledProperty", true);
|
//
|
||||||
public final BooleanProperty commandsEnabledProperty =
|
public final BooleanProperty batteryWavesVisibleProperty =
|
||||||
new BooleanProperty("commandsEnabledProperty", true);
|
new BooleanProperty(TimeCalcProperty.BATTERY_WAVES_VISIBLE
|
||||||
public final BooleanProperty toastsEnabledProperty =
|
.getKey());
|
||||||
new BooleanProperty("toastsEnabledProperty", true);
|
|
||||||
|
public final BooleanProperty jokesVisibleProperty =
|
||||||
|
new BooleanProperty(TimeCalcProperty.JOKES_VISIBLE
|
||||||
|
.getKey());
|
||||||
|
public final BooleanProperty commandsVisibleProperty =
|
||||||
|
new BooleanProperty(TimeCalcProperty.COMMANDS_VISIBLE
|
||||||
|
.getKey());
|
||||||
|
public final BooleanProperty notificationsVisibleProperty =
|
||||||
|
new BooleanProperty(TimeCalcProperty.NOTIFICATIONS_VISIBLE
|
||||||
|
.getKey());
|
||||||
public final BooleanProperty smileysColoredProperty =
|
public final BooleanProperty smileysColoredProperty =
|
||||||
new BooleanProperty("smileysColoredProperty", true);
|
new BooleanProperty(TimeCalcProperty.SMILEYS_COLORED.getKey());
|
||||||
|
|
||||||
|
private final Map<TimeCalcProperty, Property> mapOfProperties = new HashMap<>();
|
||||||
|
private List<Property> allProperties = new ArrayList<>();
|
||||||
public TimeCalcConfiguration() {
|
public TimeCalcConfiguration() {
|
||||||
|
for(Property p:new Property[] {
|
||||||
|
visibilityDefaultProperty,
|
||||||
|
visibilitySupportedColoredProperty,
|
||||||
|
clockHandsLongVisibleProperty,
|
||||||
|
clockHandsSecondVisibleProperty,
|
||||||
|
clockHandsMillisecondVisibleProperty,
|
||||||
|
batteryWavesVisibleProperty,
|
||||||
|
jokesVisibleProperty,
|
||||||
|
commandsVisibleProperty,
|
||||||
|
notificationsVisibleProperty,
|
||||||
|
smileysColoredProperty,
|
||||||
|
}) {
|
||||||
|
allProperties.add(p);
|
||||||
|
}
|
||||||
|
allProperties.stream().forEach(p -> mapOfProperties.put(TimeCalcProperty.forKey(p.getName()), p));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Property getProperty(TimeCalcProperty timeCalcProperty) {
|
||||||
|
if(!mapOfProperties.containsKey(timeCalcProperty)) {
|
||||||
|
throw new TimeCalcException("There is no property for : " + timeCalcProperty);
|
||||||
|
}
|
||||||
|
return mapOfProperties.get(timeCalcProperty);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFromTimeCalcProperties(
|
public void setFromTimeCalcProperties(
|
||||||
TimeCalcProperties timeCalcProperties) {
|
TimeCalcProperties timeCalcProperties) {
|
||||||
clockHandLongProperty.setValue(timeCalcProperties.areClockHandsLong());
|
for(Property p:allProperties) {
|
||||||
clockHandMinuteEnabledProperty
|
if(p instanceof BooleanProperty) {
|
||||||
.setValue(timeCalcProperties.isMinuteEnabled());
|
((BooleanProperty)p).setValue(timeCalcProperties.getBooleanProperty(TimeCalcProperty.forKey(p.getName())));
|
||||||
clockHandSecondEnabledProperty
|
continue;
|
||||||
.setValue(timeCalcProperties.isSecondEnabled());
|
}
|
||||||
clockHandMillisecondEnabledProperty
|
|
||||||
.setValue(timeCalcProperties.isMillisecondEnabled());
|
if(p.getName().equals(TimeCalcProperty.VISIBILITY_DEFAULT.name())) {
|
||||||
batteryWavesEnabledProperty
|
visibilityDefaultProperty.setValue(timeCalcProperties.getStringProperty(TimeCalcProperty.VISIBILITY_DEFAULT));
|
||||||
.setValue(timeCalcProperties.areBatteryWavesEnabled());
|
continue;
|
||||||
visibilityCurrentProperty
|
}
|
||||||
.setValue(timeCalcProperties.getVisibilityCurrent().name());
|
if(p instanceof StringProperty) {
|
||||||
visibilityOnlyGreyOrNoneEnabledProperty.setValue(
|
((StringProperty)p).setValue(timeCalcProperties.getStringProperty(TimeCalcProperty.forKey(p.getName())));
|
||||||
timeCalcProperties.isVisibilityOnlyGreyOrNoneEnabled());
|
continue;
|
||||||
jokesEnabledProperty.setValue(timeCalcProperties.areJokesEnabled());
|
}
|
||||||
commandsEnabledProperty
|
throw new TimeCalcException("Unsupported Property class: " + p.getClass().getName());
|
||||||
.setValue(timeCalcProperties.areCommandsEnabled());
|
|
||||||
toastsEnabledProperty.setValue(timeCalcProperties.areToastsEnabled());
|
}
|
||||||
smileysColoredProperty.setValue(timeCalcProperties.areSmileysColored());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
|
|||||||
|
|
||||||
public void keyPressed(KeyEvent e) {
|
public void keyPressed(KeyEvent e) {
|
||||||
boolean onlyGreyOrNone =
|
boolean onlyGreyOrNone =
|
||||||
timeCalcConfiguration.visibilityOnlyGreyOrNoneEnabledProperty
|
timeCalcConfiguration.visibilitySupportedColoredProperty
|
||||||
.isEnabled();
|
.isEnabled();
|
||||||
Visibility visibility = Visibility
|
Visibility visibility = Visibility
|
||||||
.valueOf(timeCalcApp.visibilityProperty.getValue());
|
.valueOf(timeCalcApp.visibilityProperty.getValue());
|
||||||
|
@ -1,10 +1,14 @@
|
|||||||
package org.nanoboot.utils.timecalc.app;
|
package org.nanoboot.utils.timecalc.app;
|
||||||
|
|
||||||
import org.nanoboot.utils.timecalc.entity.Visibility;
|
import org.nanoboot.utils.timecalc.entity.Visibility;
|
||||||
|
import org.nanoboot.utils.timecalc.utils.common.Utils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -12,25 +16,10 @@ import java.util.Properties;
|
|||||||
* @since 20.02.2024
|
* @since 20.02.2024
|
||||||
*/
|
*/
|
||||||
public class TimeCalcProperties {
|
public class TimeCalcProperties {
|
||||||
private static final String CLOCK_HANDS_LONG = "clock.hands.long";
|
|
||||||
private static final String CLOCK_HANDS_MINUTE_ENABLED =
|
|
||||||
"clock.hands.minute.enabled";
|
|
||||||
private static final String CLOCK_HANDS_SECOND_ENABLED =
|
|
||||||
"clock.hands.second.enabled";
|
|
||||||
private static final String CLOCK_HANDS_MILLISECOND_ENABLED =
|
|
||||||
"clock.hands.millisecond.enabled";
|
|
||||||
private static final String BATTERY_WAVES_ENABLED = "battery.waves.enabled";
|
|
||||||
private static final String VISIBILITY_CURRENT = "visibility.current";
|
|
||||||
private static final String VISIBILITY_ONLY_GREY_OR_NONE_ENABLED =
|
|
||||||
"visibility.only-grey-or-none.enabled";
|
|
||||||
private static final String JOKES_ENABLED = "jokes.enabled";
|
|
||||||
private static final String COMMANDS_ENABLED = "commands-enabled";
|
|
||||||
private static final String TOASTS_ENABLED = "toasts.enabled";
|
|
||||||
private static final String SMILEYS_COLORED = "smileys.colored";
|
|
||||||
|
|
||||||
|
|
||||||
private static TimeCalcProperties INSTANCE;
|
private static TimeCalcProperties INSTANCE;
|
||||||
private final Properties properties = new Properties();
|
private final Properties properties = new Properties();
|
||||||
|
private final Map<String, String> defaultProperties = new HashMap<>();
|
||||||
|
|
||||||
private TimeCalcProperties() {
|
private TimeCalcProperties() {
|
||||||
if (!new File("timecalc.conf").exists()) {
|
if (!new File("timecalc.conf").exists()) {
|
||||||
@ -42,6 +31,22 @@ public class TimeCalcProperties {
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
System.err.println(e);
|
System.err.println(e);
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
|
String defaultConfiguration = Utils.readTextFromTextResourceInJar(
|
||||||
|
"timecalc-default.conf");
|
||||||
|
Arrays.stream(defaultConfiguration.split("\n"))
|
||||||
|
.filter(l -> !l.trim().isEmpty())
|
||||||
|
.filter(l -> !l.trim().startsWith("#"))
|
||||||
|
.filter(l -> l.contains("="))
|
||||||
|
.forEach(l -> {
|
||||||
|
String[] array = l.split("=");
|
||||||
|
defaultProperties.put(array[0], array[1]);
|
||||||
|
});
|
||||||
|
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
throw new TimeCalcException(e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,59 +57,59 @@ public class TimeCalcProperties {
|
|||||||
return INSTANCE;
|
return INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean areClockHandsLong() {
|
public boolean getBooleanProperty(TimeCalcProperty timeCalcProperty) {
|
||||||
return getBooleanProperty(CLOCK_HANDS_LONG, true);
|
return getBooleanProperty(timeCalcProperty, Boolean.valueOf(
|
||||||
|
getDefaultStringValue(timeCalcProperty)));
|
||||||
}
|
}
|
||||||
|
private String getDefaultStringValue(TimeCalcProperty timeCalcProperty) {
|
||||||
public boolean isMinuteEnabled() {
|
if(!defaultProperties.containsKey(timeCalcProperty.getKey())) {
|
||||||
return getBooleanProperty(CLOCK_HANDS_MINUTE_ENABLED, true);
|
throw new TimeCalcException("timecalc-default.conf is missing key: " + timeCalcProperty.getKey());
|
||||||
}
|
|
||||||
public boolean isSecondEnabled() {
|
|
||||||
return getBooleanProperty(CLOCK_HANDS_SECOND_ENABLED, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isMillisecondEnabled() {
|
|
||||||
return getBooleanProperty(CLOCK_HANDS_MILLISECOND_ENABLED, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean areJokesEnabled() {
|
|
||||||
return getBooleanProperty(COMMANDS_ENABLED, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean areBatteryWavesEnabled() {
|
|
||||||
return getBooleanProperty(BATTERY_WAVES_ENABLED, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean areToastsEnabled() {
|
|
||||||
return getBooleanProperty(TOASTS_ENABLED, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean areSmileysColored() {
|
|
||||||
return getBooleanProperty(SMILEYS_COLORED, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Visibility getVisibilityCurrent() {
|
|
||||||
if (!properties.containsKey(VISIBILITY_CURRENT)) {
|
|
||||||
return Visibility.STRONGLY_COLORED;
|
|
||||||
}
|
}
|
||||||
return Visibility.valueOf((String) properties.get(VISIBILITY_CURRENT));
|
return defaultProperties.get(timeCalcProperty.getKey());
|
||||||
}
|
}
|
||||||
|
private boolean getBooleanProperty(TimeCalcProperty timeCalcProperty,
|
||||||
public boolean isVisibilityOnlyGreyOrNoneEnabled() {
|
Boolean defaultValue) {
|
||||||
return getBooleanProperty(VISIBILITY_ONLY_GREY_OR_NONE_ENABLED, false);
|
String key = timeCalcProperty.getKey();
|
||||||
}
|
|
||||||
|
|
||||||
public Boolean areCommandsEnabled() {
|
|
||||||
return getBooleanProperty(COMMANDS_ENABLED, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean getBooleanProperty(String key, boolean defaultValue) {
|
|
||||||
if (!properties.containsKey(key)) {
|
if (!properties.containsKey(key)) {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
return properties.get(key).equals("true");
|
return properties.get(key).equals("true");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getStringProperty(TimeCalcProperty timeCalcProperty) {
|
||||||
|
return getStringProperty(timeCalcProperty, getDefaultStringValue(timeCalcProperty));
|
||||||
|
}
|
||||||
|
private String getStringProperty(TimeCalcProperty timeCalcProperty,
|
||||||
|
String defaultValue) {
|
||||||
|
String key = timeCalcProperty.getKey();
|
||||||
|
if (!properties.containsKey(key)) {
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
return (String) properties.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getVisibilityProperty(TimeCalcProperty timeCalcProperty) {
|
||||||
|
return getStringProperty(timeCalcProperty, Visibility.STRONGLY_COLORED.name());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setBooleanProperty(TimeCalcProperty timeCalcProperty,
|
||||||
|
Boolean value) {
|
||||||
|
String key = timeCalcProperty.getKey();
|
||||||
|
properties.replace(key, value.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setStringProperty(TimeCalcProperty timeCalcProperty,
|
||||||
|
String value) {
|
||||||
|
String key = timeCalcProperty.getKey();
|
||||||
|
properties.replace(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setVisibilityProperty(TimeCalcProperty timeCalcProperty,
|
||||||
|
Visibility value) {
|
||||||
|
String key = timeCalcProperty.getKey();
|
||||||
|
properties.replace(key, value.name());
|
||||||
|
}
|
||||||
|
|
||||||
public void load() {
|
public void load() {
|
||||||
//to be implemented
|
//to be implemented
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,61 @@
|
|||||||
|
package org.nanoboot.utils.timecalc.app;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import org.nanoboot.utils.timecalc.entity.Visibility;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Robert Vokac
|
||||||
|
* @since 20.02.2024
|
||||||
|
*/
|
||||||
|
public enum TimeCalcProperty {
|
||||||
|
VISIBILITY_DEFAULT("visibility.default", "Default Visibility"),
|
||||||
|
VISIBILITY_SUPPORTED_COLORED("visibility.supported.colored", "Visibility : Supported : Colored"),
|
||||||
|
//
|
||||||
|
CLOCK_HANDS_LONG_VISIBLE("clock.hands.long.visible", "Visibility : Clock : Hands are long"),
|
||||||
|
CLOCK_HANDS_MINUTE_VISIBLE("clock.hands.minute.visible", "Visibility : Clock : Minute hand"),
|
||||||
|
CLOCK_HANDS_SECOND_VISIBLE("clock.hands.second.visible", "Visibility : Clock : Second hand"),
|
||||||
|
CLOCK_HANDS_MILLISECOND_VISIBLE("clock.hands.millisecond.visible", "Visibility : Clock : Millisecond hand"),
|
||||||
|
//
|
||||||
|
BATTERY_WAVES_VISIBLE("battery.waves.visible", "Visibility : Battery : Waves"),
|
||||||
|
JOKES_VISIBLE("jokes.visible", "Visibility : Jokes"),
|
||||||
|
COMMANDS_VISIBLE("commands.visible", "Visibility : Commands"),
|
||||||
|
NOTIFICATIONS_VISIBLE("notifications.visible", "Visibility : Toasts"),
|
||||||
|
SMILEYS_COLORED("smileys.colored", "Visibility : Smileys");
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private final String key;
|
||||||
|
@Getter
|
||||||
|
private final String description;
|
||||||
|
@Getter
|
||||||
|
private final Class clazz;
|
||||||
|
|
||||||
|
public static TimeCalcProperty forKey(String key) {
|
||||||
|
Optional<TimeCalcProperty>
|
||||||
|
timeCalcPropertyOptional = Arrays.stream(values()).filter(t -> t.getKey().equals(key)).findFirst();
|
||||||
|
if(timeCalcPropertyOptional.isPresent()) {
|
||||||
|
return timeCalcPropertyOptional.get();
|
||||||
|
} else {
|
||||||
|
TimeCalcException e =
|
||||||
|
new TimeCalcException("There is no key: " + key);
|
||||||
|
e.printStackTrace();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TimeCalcProperty(String key, String description, Class clazz) {
|
||||||
|
this.key = key;
|
||||||
|
this.description = description;
|
||||||
|
this.clazz = clazz;
|
||||||
|
}
|
||||||
|
TimeCalcProperty(String key, String description) {
|
||||||
|
this(key, description, Boolean.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -12,6 +12,7 @@ import lombok.ToString;
|
|||||||
@Setter
|
@Setter
|
||||||
@ToString
|
@ToString
|
||||||
public class Activity {
|
public class Activity {
|
||||||
|
public static final String SUBJECT_FIELD_SEPARATOR = " : ";
|
||||||
private int year;
|
private int year;
|
||||||
private int month;
|
private int month;
|
||||||
private int day;
|
private int day;
|
||||||
@ -22,5 +23,11 @@ public class Activity {
|
|||||||
private int spentMinutes;
|
private int spentMinutes;
|
||||||
private boolean jira;
|
private boolean jira;
|
||||||
private boolean bugzilla;
|
private boolean bugzilla;
|
||||||
|
public String createSubject() {
|
||||||
|
return ticket + SUBJECT_FIELD_SEPARATOR + name;
|
||||||
|
}
|
||||||
|
public String createBugzillaComment() {
|
||||||
|
return ticket + SUBJECT_FIELD_SEPARATOR + year + "-" + month + "-" + day + SUBJECT_FIELD_SEPARATOR + ((spentHours + spentMinutes / 60d) + "h") + SUBJECT_FIELD_SEPARATOR + comment;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,17 @@
|
|||||||
|
package org.nanoboot.utils.timecalc.entity;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class ActivityForStats extends Activity {
|
||||||
|
|
||||||
|
private int todaySpentHours;
|
||||||
|
private int todaySpentMinutes;
|
||||||
|
private int todayRemainsHours;
|
||||||
|
private int todayRemainsMinutes;
|
||||||
|
|
||||||
|
public ActivityForStats() {
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
package org.nanoboot.utils.timecalc.entity;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Robert Vokac
|
||||||
|
* @since 23.02.2024
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@ToString
|
||||||
|
public class WorkDay {
|
||||||
|
|
||||||
|
private int year;
|
||||||
|
private int month;
|
||||||
|
private int day;
|
||||||
|
private int arrivalHour;
|
||||||
|
private int arrivalMinute;
|
||||||
|
private int overtimeHour;
|
||||||
|
private int overtimeMinute;
|
||||||
|
private String note;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
package org.nanoboot.utils.timecalc.entity;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class WorkDayForStats extends WorkDay {
|
||||||
|
|
||||||
|
private int departureHour;
|
||||||
|
private int departureMinute;
|
||||||
|
private int dayOfWeek;
|
||||||
|
private int remainingOvertimeHours;
|
||||||
|
private int remainingOvertimeMinutes;
|
||||||
|
private double arrivalTimeMovingAverage7Days;
|
||||||
|
private double arrivalTimeMovingAverage14Days;
|
||||||
|
private double arrivalTimeMovingAverage28Days;
|
||||||
|
private double arrivalTimeMovingAverage56Days;
|
||||||
|
public WorkDayForStats() {
|
||||||
|
}
|
||||||
|
}
|
@ -1,30 +0,0 @@
|
|||||||
package org.nanoboot.utils.timecalc.entity;
|
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
import lombok.ToString;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Robert Vokac
|
|
||||||
* @since 23.02.2024
|
|
||||||
*/
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
@ToString
|
|
||||||
public class WorkingDay {
|
|
||||||
private int year;
|
|
||||||
private int month;
|
|
||||||
private int day;
|
|
||||||
private int arrivalHour;
|
|
||||||
private int arrivalMinute;
|
|
||||||
private int departureHour;
|
|
||||||
private int departureMinute;
|
|
||||||
private String note;
|
|
||||||
private int overtimeHoursThisDay;
|
|
||||||
private int overtimeMinutesThisDay;
|
|
||||||
private int compensatoryTimeOffHoursThisDay;
|
|
||||||
private int compensatoryTimeOffMinutesThisDay;
|
|
||||||
private int overtimeHoursToBeCompensatedUntilThisDay;
|
|
||||||
private int overtimeMinutesToBeCompensatedUntilThisDay;
|
|
||||||
|
|
||||||
}
|
|
@ -0,0 +1,15 @@
|
|||||||
|
package org.nanoboot.utils.timecalc.swing.common;
|
||||||
|
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Robert Vokac
|
||||||
|
* @since 16.02.2024
|
||||||
|
*/
|
||||||
|
public class ActivitiesWindow extends TimeCalcWindow {
|
||||||
|
|
||||||
|
public ActivitiesWindow() {
|
||||||
|
setSize(800, 600);
|
||||||
|
setTitle("Activities");
|
||||||
|
}
|
||||||
|
}
|
@ -1,112 +1,125 @@
|
|||||||
package org.nanoboot.utils.timecalc.swing.common;
|
package org.nanoboot.utils.timecalc.swing.common;
|
||||||
|
|
||||||
import org.nanoboot.utils.timecalc.app.TimeCalcConfiguration;
|
import org.nanoboot.utils.timecalc.app.TimeCalcConfiguration;
|
||||||
|
import org.nanoboot.utils.timecalc.app.TimeCalcProperty;
|
||||||
import org.nanoboot.utils.timecalc.entity.Visibility;
|
import org.nanoboot.utils.timecalc.entity.Visibility;
|
||||||
|
import org.nanoboot.utils.timecalc.utils.property.BooleanProperty;
|
||||||
|
import org.nanoboot.utils.timecalc.utils.property.StringProperty;
|
||||||
|
|
||||||
import javax.swing.BoxLayout;
|
|
||||||
import javax.swing.JCheckBox;
|
import javax.swing.JCheckBox;
|
||||||
import javax.swing.JComboBox;
|
import javax.swing.JComboBox;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JComponent;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JPanel;
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.Component;
|
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Robert Vokac
|
* @author Robert Vokac
|
||||||
* @since 16.02.2024
|
* @since 16.02.2024
|
||||||
*/
|
*/
|
||||||
public class ConfigWindow extends JFrame {
|
public class ConfigWindow extends TimeCalcWindow {
|
||||||
public static final int WIDTH1 = 600;
|
public static final int WIDTH1 = 600;
|
||||||
public static final int HEIGHT1 = 30;
|
public static final int HEIGHT1 = 30;
|
||||||
|
public static final String CLIENT_PROPERTY_KEY = TimeCalcProperty.class.getName();
|
||||||
private final TimeCalcConfiguration timeCalcConfiguration;
|
private final TimeCalcConfiguration timeCalcConfiguration;
|
||||||
private int currentY = SwingUtils.MARGIN;;
|
private int currentY = SwingUtils.MARGIN;
|
||||||
private JCheckBox clockHandLongProperty = new JCheckBox("Visibility : Clock : Hands are long", true);
|
private List<JComponent> propertiesList = new ArrayList<>();
|
||||||
private JCheckBox clockHandMinuteEnabledProperty = new JCheckBox("Visibility : Clock : Minute hand", true);
|
private Map<TimeCalcProperty, JComponent> propertiesMap = new HashMap<>();
|
||||||
private JCheckBox clockHandSecondEnabledProperty = new JCheckBox("Visibility : Clock : Second hand", true);
|
public final JComboBox visibilityDefaultProperty = new JComboBox(Arrays.stream(Visibility.values()).map(v -> v.name()).collect(
|
||||||
private JCheckBox clockHandMillisecondEnabledProperty = new JCheckBox("Visibility : Clock : Millisecond hand", false);
|
|
||||||
private JCheckBox batteryWavesEnabledProperty = new JCheckBox("Visibility : Battery : Waves", true);
|
|
||||||
public final JComboBox visibilityCurrentProperty = new JComboBox(
|
|
||||||
Arrays.stream(Visibility.values()).map(v->v.name()).collect(
|
|
||||||
Collectors.toList()).toArray());
|
Collectors.toList()).toArray());
|
||||||
|
|
||||||
private JCheckBox visibilityOnlyGreyOrNoneEnabledProperty = new JCheckBox("Visibility : Only GREY or NONE",
|
private JCheckBox visibilitySupportedColoredProperty =
|
||||||
false);
|
new JCheckBox("visibility.supported.colored");
|
||||||
private JCheckBox jokesEnabledProperty = new JCheckBox("Visibility : Jokes", true);
|
private JCheckBox clockHandsLongVisibleProperty =
|
||||||
private JCheckBox commandsEnabledProperty = new JCheckBox("Visibility : Commands", true);
|
new JCheckBox("clock.hands.long.visible");
|
||||||
private JCheckBox toastsEnabledProperty = new JCheckBox("Visibility : Toasts", true);
|
private JCheckBox clockHandsMinuteVisibleProperty =
|
||||||
private JCheckBox smileysColoredProperty = new JCheckBox("Visibility : Smileys", true);
|
new JCheckBox("clock.hands.minute.visible");
|
||||||
|
private JCheckBox clockHandsSecondVisibleProperty =
|
||||||
|
new JCheckBox("clock.hands.second.visible");
|
||||||
|
private JCheckBox clockHandsMillisecondVisibleProperty =
|
||||||
|
new JCheckBox("clock.hands.millisecond.visible");
|
||||||
|
private JCheckBox batteryWavesVisibleProperty =
|
||||||
|
new JCheckBox("battery.waves.visible");
|
||||||
|
|
||||||
|
private JCheckBox jokesVisibleProperty =
|
||||||
|
new JCheckBox("jokes.visible");
|
||||||
|
private JCheckBox commandsVisibleProperty =
|
||||||
|
new JCheckBox("commands.visible");
|
||||||
|
private JCheckBox notificationsVisibleProperty =
|
||||||
|
new JCheckBox("notifications.visible");
|
||||||
|
private JCheckBox smileysColoredProperty =
|
||||||
|
new JCheckBox("smileys.colored");
|
||||||
|
|
||||||
public ConfigWindow(TimeCalcConfiguration timeCalcConfiguration) {
|
public ConfigWindow(TimeCalcConfiguration timeCalcConfiguration) {
|
||||||
this.timeCalcConfiguration = timeCalcConfiguration;
|
this.timeCalcConfiguration = timeCalcConfiguration;
|
||||||
setTitle("Configuration");
|
setTitle("Configuration");
|
||||||
this.setSize(800, WIDTH1);
|
this.setSize(800, WIDTH1);
|
||||||
|
|
||||||
setLayout(null);
|
setLayout(null);
|
||||||
|
|
||||||
add(clockHandLongProperty);
|
propertiesList.addAll(Arrays.asList(visibilityDefaultProperty,
|
||||||
clockHandLongProperty.setBounds(SwingUtils.MARGIN, currentY, WIDTH1,
|
visibilitySupportedColoredProperty,
|
||||||
|
clockHandsLongVisibleProperty,
|
||||||
|
clockHandsMinuteVisibleProperty,
|
||||||
|
clockHandsSecondVisibleProperty,
|
||||||
|
clockHandsMillisecondVisibleProperty,
|
||||||
|
batteryWavesVisibleProperty,
|
||||||
|
jokesVisibleProperty,
|
||||||
|
commandsVisibleProperty,
|
||||||
|
notificationsVisibleProperty,
|
||||||
|
smileysColoredProperty));
|
||||||
|
//
|
||||||
|
propertiesList.stream().forEach(p -> {
|
||||||
|
if(p == visibilityDefaultProperty) {
|
||||||
|
p.putClientProperty(CLIENT_PROPERTY_KEY, TimeCalcProperty.VISIBILITY_DEFAULT.getKey());
|
||||||
|
addToNextRow(new JLabel(TimeCalcProperty.VISIBILITY_DEFAULT.getDescription()));
|
||||||
|
}
|
||||||
|
if(p instanceof JComboBox) {
|
||||||
|
JComboBox jComboBox = ((JComboBox)p);
|
||||||
|
jComboBox.setMaximumSize(new Dimension(150, 25));
|
||||||
|
|
||||||
|
String timeCalcPropertyKey = (String) jComboBox.getClientProperty(
|
||||||
|
CLIENT_PROPERTY_KEY);
|
||||||
|
TimeCalcProperty timeCalcProperty =
|
||||||
|
TimeCalcProperty.forKey(timeCalcPropertyKey);
|
||||||
|
jComboBox.addActionListener(e -> {
|
||||||
|
((StringProperty) timeCalcConfiguration.getProperty(timeCalcProperty))
|
||||||
|
.setValue(
|
||||||
|
(String) jComboBox.getSelectedItem());
|
||||||
|
System.out.println("configWindow.visibilityCurrentProperty="
|
||||||
|
+ visibilityDefaultProperty.getSelectedItem());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if(p instanceof JCheckBox) {
|
||||||
|
JCheckBox checkBox = ((JCheckBox)p);
|
||||||
|
String timeCalcPropertyKey = checkBox.getText();
|
||||||
|
checkBox.putClientProperty(CLIENT_PROPERTY_KEY, timeCalcPropertyKey);
|
||||||
|
TimeCalcProperty timeCalcProperty =
|
||||||
|
TimeCalcProperty.forKey(timeCalcPropertyKey);
|
||||||
|
checkBox.setText(timeCalcProperty.getDescription());
|
||||||
|
checkBox.addActionListener(e -> {
|
||||||
|
((BooleanProperty)timeCalcConfiguration.getProperty(timeCalcProperty))
|
||||||
|
.setValue(checkBox.isSelected());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
propertiesMap.put(TimeCalcProperty.forKey(
|
||||||
|
(String) p.getClientProperty(CLIENT_PROPERTY_KEY)),p);
|
||||||
|
addToNextRow(p);
|
||||||
|
});
|
||||||
|
|
||||||
|
Arrays.stream(getComponents()).forEach(c->c.getClass().getName());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addToNextRow(JComponent jComponent) {
|
||||||
|
jComponent.setBounds(SwingUtils.MARGIN, currentY, WIDTH1,
|
||||||
HEIGHT1);
|
HEIGHT1);
|
||||||
nextRow();
|
nextRow();
|
||||||
|
|
||||||
add(clockHandMinuteEnabledProperty);
|
|
||||||
clockHandMinuteEnabledProperty.setBounds(SwingUtils.MARGIN, currentY,
|
|
||||||
WIDTH1, HEIGHT1);
|
|
||||||
nextRow();
|
|
||||||
|
|
||||||
add(clockHandSecondEnabledProperty);
|
|
||||||
clockHandSecondEnabledProperty.setBounds(SwingUtils.MARGIN, currentY,
|
|
||||||
WIDTH1, HEIGHT1);
|
|
||||||
nextRow();
|
|
||||||
|
|
||||||
add(clockHandMillisecondEnabledProperty);
|
|
||||||
clockHandMillisecondEnabledProperty.setBounds(SwingUtils.MARGIN, currentY,
|
|
||||||
WIDTH1, HEIGHT1);
|
|
||||||
nextRow();
|
|
||||||
|
|
||||||
add(batteryWavesEnabledProperty);
|
|
||||||
batteryWavesEnabledProperty.setBounds(SwingUtils.MARGIN, currentY,
|
|
||||||
WIDTH1, HEIGHT1);
|
|
||||||
nextRow();
|
|
||||||
JLabel visibilityCurrentLabel = new JLabel("Visibility : Current");
|
|
||||||
|
|
||||||
add(visibilityCurrentLabel);
|
|
||||||
visibilityCurrentLabel.setBounds(SwingUtils.MARGIN, currentY, WIDTH1,
|
|
||||||
HEIGHT1);
|
|
||||||
nextRow();
|
|
||||||
|
|
||||||
add(visibilityCurrentProperty);
|
|
||||||
visibilityCurrentProperty.setMaximumSize(new Dimension(150, 25));
|
|
||||||
visibilityCurrentProperty.setBounds(SwingUtils.MARGIN, currentY, WIDTH1,
|
|
||||||
HEIGHT1);
|
|
||||||
nextRow();
|
|
||||||
|
|
||||||
clockHandLongProperty.addActionListener(e -> {
|
|
||||||
timeCalcConfiguration.clockHandLongProperty.setValue(clockHandLongProperty.isSelected());
|
|
||||||
});
|
|
||||||
clockHandMinuteEnabledProperty.addActionListener(e -> {
|
|
||||||
timeCalcConfiguration.clockHandMinuteEnabledProperty.setValue(clockHandMinuteEnabledProperty.isSelected());
|
|
||||||
});
|
|
||||||
clockHandSecondEnabledProperty.addActionListener(e -> {
|
|
||||||
timeCalcConfiguration.clockHandSecondEnabledProperty.setValue(clockHandSecondEnabledProperty.isSelected());
|
|
||||||
});
|
|
||||||
clockHandMillisecondEnabledProperty.addActionListener(e -> {
|
|
||||||
timeCalcConfiguration.clockHandMillisecondEnabledProperty.setValue(clockHandMillisecondEnabledProperty.isSelected());
|
|
||||||
});
|
|
||||||
batteryWavesEnabledProperty.addActionListener(e -> {
|
|
||||||
timeCalcConfiguration.batteryWavesEnabledProperty.setValue(batteryWavesEnabledProperty.isSelected());
|
|
||||||
});
|
|
||||||
|
|
||||||
visibilityCurrentProperty.addActionListener(e -> {
|
|
||||||
timeCalcConfiguration.visibilityCurrentProperty.setValue(
|
|
||||||
(String) visibilityCurrentProperty.getSelectedItem());
|
|
||||||
System.out.println("configWindow.visibilityCurrentProperty=" + visibilityCurrentProperty.getSelectedItem());
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void nextRow() {
|
private void nextRow() {
|
||||||
|
@ -1,411 +1,451 @@
|
|||||||
package org.nanoboot.utils.timecalc.app;
|
package org.nanoboot.utils.timecalc.swing.common;
|
||||||
|
|
||||||
import org.nanoboot.utils.timecalc.entity.Visibility;
|
import org.nanoboot.utils.timecalc.app.CommandActionListener;
|
||||||
import org.nanoboot.utils.timecalc.swing.common.AboutButton;
|
import org.nanoboot.utils.timecalc.app.GetProperty;
|
||||||
import org.nanoboot.utils.timecalc.swing.common.ComponentRegistry;
|
import org.nanoboot.utils.timecalc.app.TimeCalcApp;
|
||||||
import org.nanoboot.utils.timecalc.swing.common.ConfigWindow;
|
import org.nanoboot.utils.timecalc.app.TimeCalcConfiguration;
|
||||||
import org.nanoboot.utils.timecalc.swing.common.SwingUtils;
|
import org.nanoboot.utils.timecalc.app.TimeCalcKeyAdapter;
|
||||||
import org.nanoboot.utils.timecalc.swing.common.TimeCalcButton;
|
import org.nanoboot.utils.timecalc.app.TimeCalcProperties;
|
||||||
import org.nanoboot.utils.timecalc.swing.common.TimeCalcWindow;
|
import org.nanoboot.utils.timecalc.app.TimeCalcProperty;
|
||||||
import org.nanoboot.utils.timecalc.swing.common.Toaster;
|
import org.nanoboot.utils.timecalc.entity.Visibility;
|
||||||
import org.nanoboot.utils.timecalc.swing.common.WeatherWindow;
|
import org.nanoboot.utils.timecalc.swing.progress.AnalogClock;
|
||||||
import org.nanoboot.utils.timecalc.swing.common.Widget;
|
import org.nanoboot.utils.timecalc.swing.progress.Battery;
|
||||||
import org.nanoboot.utils.timecalc.swing.progress.AnalogClock;
|
import org.nanoboot.utils.timecalc.swing.progress.DayBattery;
|
||||||
import org.nanoboot.utils.timecalc.swing.progress.Battery;
|
import org.nanoboot.utils.timecalc.swing.progress.HourBattery;
|
||||||
import org.nanoboot.utils.timecalc.swing.progress.DayBattery;
|
import org.nanoboot.utils.timecalc.swing.progress.MonthBattery;
|
||||||
import org.nanoboot.utils.timecalc.swing.progress.HourBattery;
|
import org.nanoboot.utils.timecalc.swing.progress.ProgressCircle;
|
||||||
import org.nanoboot.utils.timecalc.swing.progress.MonthBattery;
|
import org.nanoboot.utils.timecalc.swing.progress.ProgressSquare;
|
||||||
import org.nanoboot.utils.timecalc.swing.progress.ProgressCircle;
|
import org.nanoboot.utils.timecalc.swing.progress.Time;
|
||||||
import org.nanoboot.utils.timecalc.swing.progress.ProgressSquare;
|
import org.nanoboot.utils.timecalc.swing.progress.WalkingHumanProgressAsciiArt;
|
||||||
import org.nanoboot.utils.timecalc.swing.progress.Time;
|
import org.nanoboot.utils.timecalc.swing.progress.WeekBattery;
|
||||||
import org.nanoboot.utils.timecalc.swing.progress.WalkingHumanProgressAsciiArt;
|
import org.nanoboot.utils.timecalc.utils.common.Constants;
|
||||||
import org.nanoboot.utils.timecalc.swing.progress.WeekBattery;
|
import org.nanoboot.utils.timecalc.utils.common.Jokes;
|
||||||
import org.nanoboot.utils.timecalc.utils.common.Constants;
|
import org.nanoboot.utils.timecalc.utils.common.TimeHM;
|
||||||
import org.nanoboot.utils.timecalc.utils.common.Jokes;
|
import org.nanoboot.utils.timecalc.utils.common.Utils;
|
||||||
import org.nanoboot.utils.timecalc.utils.common.TimeHM;
|
import org.nanoboot.utils.timecalc.utils.property.IntegerProperty;
|
||||||
import org.nanoboot.utils.timecalc.utils.common.Utils;
|
import org.nanoboot.utils.timecalc.utils.property.Property;
|
||||||
import org.nanoboot.utils.timecalc.utils.property.IntegerProperty;
|
|
||||||
import org.nanoboot.utils.timecalc.utils.property.Property;
|
import javax.swing.JComponent;
|
||||||
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JComponent;
|
import java.awt.Color;
|
||||||
import java.awt.Color;
|
import java.io.File;
|
||||||
import java.io.File;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileInputStream;
|
import java.io.IOException;
|
||||||
import java.io.IOException;
|
import java.time.DayOfWeek;
|
||||||
import java.time.DayOfWeek;
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDate;
|
import java.util.Calendar;
|
||||||
import java.util.Calendar;
|
import java.util.Date;
|
||||||
import java.util.Date;
|
import java.util.Properties;
|
||||||
import java.util.Properties;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Logger;
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
/**
|
||||||
/**
|
* @author Robert Vokac
|
||||||
* @author Robert Vokac
|
* @since 08.02.2024
|
||||||
* @since 08.02.2024
|
*/
|
||||||
*/
|
public class MainWindow extends TimeCalcWindow{
|
||||||
public class TimeCalcManager {
|
|
||||||
public static final Color BACKGROUND_COLOR = new Color(238, 238, 238);
|
public static final Color BACKGROUND_COLOR = new Color(238, 238, 238);
|
||||||
public static final Color FOREGROUND_COLOR = new Color(210, 210, 210);
|
public static final Color FOREGROUND_COLOR = new Color(210, 210, 210);
|
||||||
private ConfigWindow configWindow = null;
|
private WorkDaysWindow workDaysWindow = null;
|
||||||
|
private ConfigWindow configWindow = null;
|
||||||
private boolean stopBeforeEnd = false;
|
private ActivitiesWindow activitiesWindow = null;
|
||||||
private final TimeCalcConfiguration timeCalcConfiguration =
|
|
||||||
new TimeCalcConfiguration();
|
private boolean stopBeforeEnd = false;
|
||||||
|
private final TimeCalcConfiguration timeCalcConfiguration =
|
||||||
public TimeCalcManager(String startTimeIn, String overTimeIn,
|
new TimeCalcConfiguration();
|
||||||
TimeCalcApp timeCalcApp) {
|
|
||||||
timeCalcConfiguration
|
public MainWindow(String startTimeIn, String overTimeIn,
|
||||||
.setFromTimeCalcProperties(TimeCalcProperties.getInstance());
|
TimeCalcApp timeCalcApp) {
|
||||||
|
setFocusable(true);
|
||||||
overTimeIn = (overTimeIn == null || overTimeIn.isEmpty()) ?
|
setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
|
||||||
Constants.DEFAULT_OVERTIME : overTimeIn;
|
addWindowListener(new java.awt.event.WindowAdapter() {
|
||||||
|
@Override
|
||||||
TimeHM startTime = new TimeHM(startTimeIn);
|
public void windowClosing(java.awt.event.WindowEvent e) {
|
||||||
TimeHM overtime = new TimeHM(overTimeIn);
|
System.exit(0);
|
||||||
|
}
|
||||||
TimeHM endTime = new TimeHM(
|
});
|
||||||
startTime.getHour() + Constants.WORKING_HOURS_LENGTH + overtime
|
timeCalcConfiguration
|
||||||
.getHour(),
|
.setFromTimeCalcProperties(TimeCalcProperties.getInstance());
|
||||||
startTime.getMinute() + Constants.WORKING_MINUTES_LENGTH
|
|
||||||
+ overtime.getMinute());
|
overTimeIn = (overTimeIn == null || overTimeIn.isEmpty()) ?
|
||||||
|
Constants.DEFAULT_OVERTIME : overTimeIn;
|
||||||
int totalMinutes = TimeHM.countDiffInMinutes(startTime, endTime);
|
|
||||||
int totalSeconds = totalMinutes * TimeHM.SECONDS_PER_MINUTE;
|
TimeHM startTime = new TimeHM(startTimeIn);
|
||||||
int totalMilliseconds = totalSeconds * TimeHM.MILLISECONDS_PER_SECOND;
|
TimeHM overtime = new TimeHM(overTimeIn);
|
||||||
|
|
||||||
TimeCalcWindow window = new TimeCalcWindow();
|
TimeHM endTime = new TimeHM(
|
||||||
|
startTime.getHour() + Constants.WORKING_HOURS_LENGTH + overtime
|
||||||
TimeCalcButton configButton = new TimeCalcButton("Config");
|
.getHour(),
|
||||||
TimeCalcButton commandButton = new TimeCalcButton("Command");
|
startTime.getMinute() + Constants.WORKING_MINUTES_LENGTH
|
||||||
TimeCalcButton weatherButton = new TimeCalcButton("Weather");
|
+ overtime.getMinute());
|
||||||
TimeCalcButton jokeButton = new TimeCalcButton("Joke");
|
|
||||||
TimeCalcButton restartButton = new TimeCalcButton("Restart");
|
int totalMinutes = TimeHM.countDiffInMinutes(startTime, endTime);
|
||||||
TimeCalcButton exitButton = new TimeCalcButton("Exit");
|
int totalSeconds = totalMinutes * TimeHM.SECONDS_PER_MINUTE;
|
||||||
AboutButton aboutButton = new AboutButton();
|
int totalMilliseconds = totalSeconds * TimeHM.MILLISECONDS_PER_SECOND;
|
||||||
|
|
||||||
//window.add(weatherButton);
|
TimeCalcButton configButton = new TimeCalcButton("Config");
|
||||||
window.addAll(configButton, commandButton, jokeButton, restartButton,
|
TimeCalcButton workDaysButton = new TimeCalcButton("Work Days");
|
||||||
exitButton);
|
TimeCalcButton activitiesButton = new TimeCalcButton("Activities"
|
||||||
|
+ "");
|
||||||
if(timeCalcConfiguration.visibilityOnlyGreyOrNoneEnabledProperty.isEnabled()) {
|
TimeCalcButton restartButton = new TimeCalcButton("Restart");
|
||||||
timeCalcApp.visibilityProperty.setValue(Visibility.GRAY.name());
|
TimeCalcButton exitButton = new TimeCalcButton("Exit");
|
||||||
}
|
TimeCalcButton focusButton = new TimeCalcButton("Focus");
|
||||||
timeCalcApp.visibilityProperty.bindTo(timeCalcConfiguration.visibilityCurrentProperty);
|
TimeCalcButton weatherButton = new TimeCalcButton("Weather");
|
||||||
TimeCalcKeyAdapter timeCalcKeyAdapter = new TimeCalcKeyAdapter(timeCalcConfiguration, timeCalcApp, commandButton, window);
|
TimeCalcButton commandButton = new TimeCalcButton("Command");
|
||||||
window.addKeyListener(timeCalcKeyAdapter);
|
TimeCalcButton jokeButton = new TimeCalcButton("Joke");
|
||||||
|
AboutButton aboutButton = new AboutButton();
|
||||||
AnalogClock analogClock = new AnalogClock(startTime, endTime);
|
|
||||||
analogClock.setBounds(SwingUtils.MARGIN, SwingUtils.MARGIN, 200);
|
//window.add(weatherButton);
|
||||||
window.add(analogClock);
|
addAll(configButton, workDaysButton, activitiesButton, restartButton,
|
||||||
|
exitButton, focusButton, commandButton, jokeButton);
|
||||||
ProgressSquare progressSquare = new ProgressSquare();
|
|
||||||
progressSquare
|
if(timeCalcConfiguration.visibilitySupportedColoredProperty.isEnabled()) {
|
||||||
.setBounds(analogClock.getX() + analogClock.getWidth() + SwingUtils.MARGIN, analogClock.getY(),
|
timeCalcApp.visibilityProperty.setValue(Visibility.GRAY.name());
|
||||||
200);
|
}
|
||||||
window.add(progressSquare);
|
timeCalcApp.visibilityProperty.bindTo(timeCalcConfiguration.visibilityDefaultProperty);
|
||||||
|
TimeCalcKeyAdapter timeCalcKeyAdapter = new TimeCalcKeyAdapter(timeCalcConfiguration, timeCalcApp, commandButton, this);
|
||||||
ProgressCircle progressCircle = new ProgressCircle();
|
addKeyListener(timeCalcKeyAdapter);
|
||||||
progressCircle
|
|
||||||
.setBounds(
|
AnalogClock analogClock = new AnalogClock(startTime, endTime);
|
||||||
progressSquare.getX() + progressSquare.getWidth() + SwingUtils.MARGIN, progressSquare.getY(), 80);
|
analogClock.setBounds(SwingUtils.MARGIN, SwingUtils.MARGIN, 200);
|
||||||
window.add(progressCircle);
|
add(analogClock);
|
||||||
|
|
||||||
WalkingHumanProgressAsciiArt walkingHumanProgressAsciiArt =
|
ProgressSquare progressSquare = new ProgressSquare();
|
||||||
new WalkingHumanProgressAsciiArt(analogClock.getX(), analogClock.getY() + analogClock.getHeight() + SwingUtils.MARGIN, 420, 180);
|
progressSquare
|
||||||
window.add(walkingHumanProgressAsciiArt);
|
.setBounds(analogClock.getX() + analogClock.getWidth() + SwingUtils.MARGIN, analogClock.getY(),
|
||||||
weatherButton
|
200);
|
||||||
.setBounds(SwingUtils.MARGIN, walkingHumanProgressAsciiArt.getY()
|
add(progressSquare);
|
||||||
+ walkingHumanProgressAsciiArt.getHeight()
|
|
||||||
+ SwingUtils.MARGIN);
|
ProgressCircle progressCircle = new ProgressCircle();
|
||||||
|
progressCircle
|
||||||
configButton.setBoundsFromTop(walkingHumanProgressAsciiArt);
|
.setBounds(
|
||||||
commandButton.setBoundsFromLeft(configButton);
|
progressSquare.getX() + progressSquare.getWidth() + SwingUtils.MARGIN, progressSquare.getY(), 80);
|
||||||
|
add(progressCircle);
|
||||||
jokeButton.setBoundsFromLeft(commandButton);
|
|
||||||
restartButton.setBoundsFromLeft(jokeButton);
|
WalkingHumanProgressAsciiArt walkingHumanProgressAsciiArt =
|
||||||
exitButton.setBoundsFromLeft(restartButton);
|
new WalkingHumanProgressAsciiArt(analogClock.getX(), analogClock.getY() + analogClock.getHeight() + SwingUtils.MARGIN, 420, 180);
|
||||||
aboutButton.setBounds(exitButton.getX(),
|
add(walkingHumanProgressAsciiArt);
|
||||||
exitButton.getY() + exitButton.getHeight() + SwingUtils.MARGIN);
|
weatherButton
|
||||||
|
.setBounds(SwingUtils.MARGIN, walkingHumanProgressAsciiArt.getY()
|
||||||
window.setLayout(null);
|
+ walkingHumanProgressAsciiArt.getHeight()
|
||||||
window.setVisible(true);
|
+ SwingUtils.MARGIN);
|
||||||
|
|
||||||
String windowTitle = "Time Calc " + Utils.getVersion();
|
configButton.setBoundsFromTop(walkingHumanProgressAsciiArt);
|
||||||
window.setTitle(windowTitle);
|
workDaysButton.setBoundsFromLeft(configButton);
|
||||||
|
activitiesButton.setBoundsFromLeft(workDaysButton);
|
||||||
weatherButton
|
restartButton.setBoundsFromLeft(activitiesButton);
|
||||||
.addActionListener(e -> new WeatherWindow().setVisible(true));
|
exitButton.setBoundsFromLeft(restartButton);
|
||||||
commandButton.addActionListener(new CommandActionListener(timeCalcApp, timeCalcConfiguration));
|
|
||||||
|
//
|
||||||
jokeButton.addActionListener(e -> {
|
focusButton.setBoundsFromTop(exitButton);
|
||||||
for (int i = 1; i <= 1; i++) {
|
commandButton.setBoundsFromLeft(focusButton);
|
||||||
Jokes.showRandom();
|
jokeButton.setBoundsFromLeft(commandButton);
|
||||||
}
|
//
|
||||||
});
|
aboutButton.setBounds(exitButton.getX(),
|
||||||
exitButton.addActionListener(e -> System.exit(0));
|
exitButton.getY() + exitButton.getHeight() + SwingUtils.MARGIN);
|
||||||
restartButton.addActionListener(e -> {
|
|
||||||
window.setVisible(false);
|
setLayout(null);
|
||||||
stopBeforeEnd = true;
|
setVisible(true);
|
||||||
});
|
|
||||||
|
String windowTitle = "Time Calc " + Utils.getVersion();
|
||||||
configButton.addActionListener(e -> {
|
setTitle(windowTitle);
|
||||||
if(configWindow == null) {
|
|
||||||
this.configWindow = new ConfigWindow(timeCalcConfiguration);
|
weatherButton
|
||||||
}
|
.addActionListener(e -> new WeatherWindow().setVisible(true));
|
||||||
configWindow.setVisible(true);
|
commandButton.addActionListener(new CommandActionListener(timeCalcApp, timeCalcConfiguration));
|
||||||
});
|
|
||||||
Calendar calNow = Calendar.getInstance();
|
jokeButton.addActionListener(e -> {
|
||||||
calNow.setTime(new Date());
|
for (int i = 1; i <= 1; i++) {
|
||||||
|
Jokes.showRandom();
|
||||||
Properties testProperties = new Properties();
|
}
|
||||||
File testPropertiesFile = new File("test.txt");
|
});
|
||||||
try {
|
exitButton.addActionListener(e -> System.exit(0));
|
||||||
if (testPropertiesFile.exists()) {
|
focusButton.addActionListener(e -> requestFocus(true));
|
||||||
testProperties.load(new FileInputStream(testPropertiesFile));
|
restartButton.addActionListener(e -> {
|
||||||
}
|
setVisible(false);
|
||||||
} catch (IOException ex) {
|
stopBeforeEnd = true;
|
||||||
Logger.getLogger(TimeCalcManager.class.getName())
|
});
|
||||||
.log(Level.SEVERE, null, ex);
|
workDaysButton.addActionListener(e -> {
|
||||||
}
|
if(workDaysWindow == null) {
|
||||||
|
this.workDaysWindow = new WorkDaysWindow();
|
||||||
Time time = new Time();
|
}
|
||||||
|
workDaysWindow.setVisible(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);
|
activitiesButton.addActionListener(e -> {
|
||||||
bindToIfPropertyMissing(testProperties, "test.current.year", calNow, Calendar.YEAR, analogClock.yearProperty, time.yearProperty);
|
if(activitiesWindow == null) {
|
||||||
bindToIfPropertyMissing(testProperties, "test.current.hour", calNow, Calendar.HOUR, analogClock.hourProperty, time.hourProperty);
|
this.activitiesWindow = new ActivitiesWindow();
|
||||||
bindToIfPropertyMissing(testProperties, "test.current.minute", calNow, Calendar.MINUTE, analogClock.minuteProperty, time.minuteProperty);
|
}
|
||||||
bindToIfPropertyMissing(testProperties, "test.current.second", calNow, Calendar.SECOND, analogClock.secondProperty, time.secondProperty);
|
activitiesWindow.setVisible(true);
|
||||||
bindToIfPropertyMissing(testProperties, "test.current.millisecond", calNow, Calendar.MILLISECOND, analogClock.millisecondProperty, time.millisecondProperty);
|
});
|
||||||
|
|
||||||
if (testProperties.containsKey("test.current.year") || testProperties
|
configButton.addActionListener(e -> {
|
||||||
.containsKey("test.current.month") || testProperties
|
if(configWindow == null) {
|
||||||
.containsKey("test.current.day")) {
|
this.configWindow = new ConfigWindow(timeCalcConfiguration);
|
||||||
analogClock.dayOfWeekProperty
|
}
|
||||||
.setValue(calNow.get(Calendar.DAY_OF_WEEK));
|
configWindow.setVisible(true);
|
||||||
} else {
|
});
|
||||||
analogClock.dayOfWeekProperty.bindTo(time.dayOfWeek);
|
Calendar calNow = Calendar.getInstance();
|
||||||
}
|
calNow.setTime(new Date());
|
||||||
|
|
||||||
analogClock.millisecondEnabledProperty
|
Properties testProperties = new Properties();
|
||||||
.bindTo(timeCalcConfiguration.clockHandMillisecondEnabledProperty);
|
File testPropertiesFile = new File("test.txt");
|
||||||
analogClock.secondEnabledProperty
|
try {
|
||||||
.bindTo(timeCalcConfiguration.clockHandSecondEnabledProperty);
|
if (testPropertiesFile.exists()) {
|
||||||
analogClock.minuteEnabledProperty
|
testProperties.load(new FileInputStream(testPropertiesFile));
|
||||||
.bindTo(timeCalcConfiguration.clockHandMinuteEnabledProperty);
|
}
|
||||||
analogClock.handsLongProperty
|
} catch (IOException ex) {
|
||||||
.bindTo(timeCalcConfiguration.clockHandLongProperty);
|
Logger.getLogger(MainWindow.class.getName())
|
||||||
|
.log(Level.SEVERE, null, ex);
|
||||||
Battery hourBattery = new HourBattery(progressCircle.getBounds().x,
|
}
|
||||||
progressCircle.getY() + SwingUtils.MARGIN + progressCircle.getHeight(),
|
|
||||||
140);
|
Time time = new Time();
|
||||||
window.add(hourBattery);
|
|
||||||
|
bindToIfPropertyMissing(testProperties, "test.current.day", calNow, Calendar.DAY_OF_MONTH, analogClock.dayProperty, time.dayProperty);
|
||||||
Battery dayBattery = new DayBattery(hourBattery.getBounds().x + hourBattery.getWidth() + SwingUtils.MARGIN,
|
bindToIfPropertyMissing(testProperties, "test.current.month", calNow, Calendar.MONTH, analogClock.monthProperty, time.monthProperty);
|
||||||
hourBattery.getY(),
|
bindToIfPropertyMissing(testProperties, "test.current.year", calNow, Calendar.YEAR, analogClock.yearProperty, time.yearProperty);
|
||||||
140);
|
bindToIfPropertyMissing(testProperties, "test.current.hour", calNow, Calendar.HOUR, analogClock.hourProperty, time.hourProperty);
|
||||||
window.add(dayBattery);
|
bindToIfPropertyMissing(testProperties, "test.current.minute", calNow, Calendar.MINUTE, analogClock.minuteProperty, time.minuteProperty);
|
||||||
|
bindToIfPropertyMissing(testProperties, "test.current.second", calNow, Calendar.SECOND, analogClock.secondProperty, time.secondProperty);
|
||||||
Battery weekBattery = new WeekBattery(
|
bindToIfPropertyMissing(testProperties, "test.current.millisecond", calNow, Calendar.MILLISECOND, analogClock.millisecondProperty, time.millisecondProperty);
|
||||||
hourBattery.getBounds().x,
|
|
||||||
dayBattery.getY() + dayBattery.getHeight() + SwingUtils.MARGIN, 140);
|
if (testProperties.containsKey("test.current.year") || testProperties
|
||||||
window.add(weekBattery);
|
.containsKey("test.current.month") || testProperties
|
||||||
|
.containsKey("test.current.day")) {
|
||||||
int currentDayOfMonth = analogClock.dayProperty.getValue();
|
analogClock.dayOfWeekProperty
|
||||||
|
.setValue(calNow.get(Calendar.DAY_OF_WEEK));
|
||||||
int workDaysDone = 0;
|
} else {
|
||||||
int workDaysTodo = 0;
|
analogClock.dayOfWeekProperty.bindTo(time.dayOfWeek);
|
||||||
int workDaysTotal;
|
}
|
||||||
for (int dayOfMonth = 1;
|
|
||||||
dayOfMonth <= calNow.getActualMaximum(Calendar.DAY_OF_MONTH);
|
analogClock.millisecondEnabledProperty
|
||||||
dayOfMonth++) {
|
.bindTo(timeCalcConfiguration.clockHandsMillisecondVisibleProperty);
|
||||||
DayOfWeek dayOfWeek = LocalDate.of(analogClock.yearProperty.getValue(),
|
analogClock.secondEnabledProperty
|
||||||
analogClock.monthProperty.getValue(), dayOfMonth).getDayOfWeek();
|
.bindTo(timeCalcConfiguration.clockHandsSecondVisibleProperty);
|
||||||
boolean weekend =
|
analogClock.minuteEnabledProperty
|
||||||
dayOfWeek.toString().equals("SATURDAY") || dayOfWeek
|
.bindTo(timeCalcConfiguration.clockHandsMinuteVisibleProperty);
|
||||||
.toString().equals("SUNDAY");
|
analogClock.handsLongProperty
|
||||||
if (dayOfMonth < currentDayOfMonth && !weekend) {
|
.bindTo(timeCalcConfiguration.clockHandsLongVisibleProperty);
|
||||||
++workDaysDone;
|
|
||||||
}
|
Battery hourBattery = new HourBattery(progressCircle.getBounds().x,
|
||||||
if (dayOfMonth > currentDayOfMonth && !weekend) {
|
progressCircle.getY() + SwingUtils.MARGIN + progressCircle.getHeight(),
|
||||||
++workDaysTodo;
|
140);
|
||||||
}
|
add(hourBattery);
|
||||||
}
|
|
||||||
String currentDayOfWeekAsString = LocalDate
|
Battery dayBattery = new DayBattery(hourBattery.getBounds().x + hourBattery.getWidth() + SwingUtils.MARGIN,
|
||||||
.of(calNow.get(Calendar.YEAR), calNow.get(Calendar.MONTH) + 1,
|
hourBattery.getY(),
|
||||||
currentDayOfMonth).getDayOfWeek().toString();
|
140);
|
||||||
boolean nowIsWeekend = currentDayOfWeekAsString.equals("SATURDAY")
|
add(dayBattery);
|
||||||
|| currentDayOfWeekAsString.equals("SUNDAY");
|
|
||||||
workDaysTotal = workDaysDone + (nowIsWeekend ? 0 : 1) + workDaysTodo;
|
Battery weekBattery = new WeekBattery(
|
||||||
|
hourBattery.getBounds().x,
|
||||||
Battery monthBattery = new MonthBattery(
|
dayBattery.getY() + dayBattery.getHeight() + SwingUtils.MARGIN, 140);
|
||||||
dayBattery.getBounds().x,
|
add(weekBattery);
|
||||||
weekBattery.getY(), 140);
|
|
||||||
window.add(monthBattery);
|
int currentDayOfMonth = analogClock.dayProperty.getValue();
|
||||||
|
|
||||||
ComponentRegistry<JComponent> componentRegistry = new ComponentRegistry();
|
int workDaysDone = 0;
|
||||||
componentRegistry.addAll(
|
int workDaysTodo = 0;
|
||||||
walkingHumanProgressAsciiArt,
|
int workDaysTotal;
|
||||||
progressSquare,
|
for (int dayOfMonth = 1;
|
||||||
progressCircle,
|
dayOfMonth <= calNow.getActualMaximum(Calendar.DAY_OF_MONTH);
|
||||||
analogClock,
|
dayOfMonth++) {
|
||||||
dayBattery,
|
DayOfWeek dayOfWeek = LocalDate.of(analogClock.yearProperty.getValue(),
|
||||||
weekBattery,
|
analogClock.monthProperty.getValue(), dayOfMonth).getDayOfWeek();
|
||||||
monthBattery,
|
boolean weekend =
|
||||||
hourBattery,
|
dayOfWeek.toString().equals("SATURDAY") || dayOfWeek
|
||||||
configButton,
|
.toString().equals("SUNDAY");
|
||||||
jokeButton,
|
if (dayOfMonth < currentDayOfMonth && !weekend) {
|
||||||
commandButton,
|
++workDaysDone;
|
||||||
restartButton,
|
}
|
||||||
exitButton
|
if (dayOfMonth > currentDayOfMonth && !weekend) {
|
||||||
);
|
++workDaysTodo;
|
||||||
ComponentRegistry<TimeCalcButton> buttonRegistry = new ComponentRegistry();
|
}
|
||||||
componentRegistry.getSet().stream().filter(c-> c instanceof TimeCalcButton).forEach(c->
|
}
|
||||||
buttonRegistry.add((TimeCalcButton)c));
|
String currentDayOfWeekAsString = LocalDate
|
||||||
componentRegistry.getSet().stream().filter(c ->
|
.of(calNow.get(Calendar.YEAR), calNow.get(Calendar.MONTH) + 1,
|
||||||
GetProperty.class.isAssignableFrom(c.getClass())).forEach(c->
|
currentDayOfMonth).getDayOfWeek().toString();
|
||||||
((GetProperty<String>)c).getProperty().bindTo(timeCalcApp.visibilityProperty));
|
boolean nowIsWeekend = currentDayOfWeekAsString.equals("SATURDAY")
|
||||||
|
|| currentDayOfWeekAsString.equals("SUNDAY");
|
||||||
componentRegistry.getSet().stream().filter(c-> c instanceof Battery).forEach(c ->
|
workDaysTotal = workDaysDone + (nowIsWeekend ? 0 : 1) + workDaysTodo;
|
||||||
((Battery)c).wavesProperty.bindTo(timeCalcConfiguration.batteryWavesEnabledProperty));
|
|
||||||
|
Battery monthBattery = new MonthBattery(
|
||||||
componentRegistry.getSet().stream().filter(c-> c instanceof Widget).forEach(c ->
|
dayBattery.getBounds().x,
|
||||||
((Widget)c).smileysColoredProperty.bindTo(timeCalcConfiguration.smileysColoredProperty));
|
weekBattery.getY(), 140);
|
||||||
window.setSize(dayBattery.getX() + dayBattery.getWidth() + 3 * SwingUtils.MARGIN,
|
add(monthBattery);
|
||||||
exitButton.getY() + 3 * exitButton.getHeight() + SwingUtils.MARGIN);
|
|
||||||
while (true) {
|
ComponentRegistry<JComponent> componentRegistry = new ComponentRegistry();
|
||||||
//System.out.println("timeCalcConfiguration.handsLongProperty=" + timeCalcConfiguration.clockHandLongProperty.isEnabled());
|
componentRegistry.addAll(
|
||||||
Visibility currentVisibility = Visibility
|
walkingHumanProgressAsciiArt,
|
||||||
.valueOf(timeCalcApp.visibilityProperty.getValue());
|
progressSquare,
|
||||||
if(timeCalcConfiguration.visibilityOnlyGreyOrNoneEnabledProperty.isEnabled() && currentVisibility.isColored() ){
|
progressCircle,
|
||||||
timeCalcApp.visibilityProperty.setValue(Visibility.GRAY.name());
|
analogClock,
|
||||||
}
|
dayBattery,
|
||||||
if (stopBeforeEnd) {
|
weekBattery,
|
||||||
if(configWindow != null) {configWindow.setVisible(false);configWindow.dispose();}
|
monthBattery,
|
||||||
window.setVisible(false);
|
hourBattery,
|
||||||
window.dispose();
|
configButton,
|
||||||
|
workDaysButton,
|
||||||
break;
|
activitiesButton,
|
||||||
}
|
restartButton,
|
||||||
|
exitButton,
|
||||||
componentRegistry.setVisible(currentVisibility.isNotNone());
|
focusButton,
|
||||||
|
jokeButton,
|
||||||
jokeButton.setVisible(
|
commandButton
|
||||||
TimeCalcProperties.getInstance().areJokesEnabled()
|
);
|
||||||
&& !currentVisibility.isNone());
|
ComponentRegistry<TimeCalcButton> buttonRegistry = new ComponentRegistry();
|
||||||
|
componentRegistry.getSet().stream().filter(c-> c instanceof TimeCalcButton).forEach(c->
|
||||||
window.setTitle(currentVisibility.isNone() ? "" : windowTitle);
|
buttonRegistry.add((TimeCalcButton)c));
|
||||||
|
componentRegistry.getSet().stream().filter(c ->
|
||||||
int hourNow = analogClock.hourProperty.getValue();
|
GetProperty.class.isAssignableFrom(c.getClass())).forEach(c->
|
||||||
int minuteNow = analogClock.minuteProperty.getValue();
|
((GetProperty<String>)c).getProperty().bindTo(timeCalcApp.visibilityProperty));
|
||||||
|
|
||||||
int secondNow = analogClock.secondProperty.getValue();
|
componentRegistry.getSet().stream().filter(c-> c instanceof Battery).forEach(c ->
|
||||||
int millisecondNow = analogClock.millisecondProperty.getValue();
|
((Battery)c).wavesProperty.bindTo(timeCalcConfiguration.batteryWavesVisibleProperty));
|
||||||
TimeHM timeRemains = new TimeHM(endTime.getHour() - hourNow,
|
|
||||||
endTime.getMinute() - minuteNow);
|
componentRegistry.getSet().stream().filter(c-> c instanceof Widget).forEach(c ->
|
||||||
|
((Widget)c).smileysColoredProperty.bindTo(timeCalcConfiguration.smileysColoredProperty));
|
||||||
int secondsRemains = 60 - secondNow;
|
setSize(dayBattery.getX() + dayBattery.getWidth() + 3 * SwingUtils.MARGIN,
|
||||||
int millisecondsRemains = 1000 - millisecondNow;
|
focusButton.getY() + focusButton.getHeight() + SwingUtils.MARGIN + focusButton.getHeight() + 2 * SwingUtils.MARGIN);
|
||||||
|
while (true) {
|
||||||
int hourDone = Constants.WORKING_HOURS_LENGTH + overtime.getHour()
|
//System.out.println("timeCalcConfiguration.handsLongProperty=" + timeCalcConfiguration.clockHandLongProperty.isEnabled());
|
||||||
- timeRemains.getHour();
|
Visibility currentVisibility = Visibility
|
||||||
int minutesDone =
|
.valueOf(timeCalcApp.visibilityProperty.getValue());
|
||||||
Constants.WORKING_MINUTES_LENGTH + overtime.getMinute()
|
if(timeCalcConfiguration.visibilitySupportedColoredProperty.isEnabled() && currentVisibility.isColored() ){
|
||||||
- timeRemains.getMinute();
|
timeCalcApp.visibilityProperty.setValue(Visibility.GRAY.name());
|
||||||
int secondsDone = secondNow;
|
}
|
||||||
int millisecondsDone = millisecondNow;
|
if (stopBeforeEnd) {
|
||||||
|
if(configWindow != null) {configWindow.setVisible(false);configWindow.dispose();}
|
||||||
int totalMinutesDone = hourDone * 60 + minutesDone;
|
if(workDaysWindow != null) {workDaysWindow.setVisible(false);workDaysWindow.dispose();}
|
||||||
int totalSecondsDone = totalMinutesDone * 60 + secondsDone;
|
if(activitiesWindow != null) {activitiesWindow.setVisible(false);activitiesWindow.dispose();}
|
||||||
int totalMillisecondsDone =
|
|
||||||
totalSecondsDone * 1000 + millisecondsDone;
|
setVisible(false);
|
||||||
|
dispose();
|
||||||
double done = ((double) totalMillisecondsDone)
|
|
||||||
/ ((double) totalMilliseconds);
|
break;
|
||||||
progressSquare.setDonePercent(done);
|
}
|
||||||
progressCircle.setDonePercent(done);
|
|
||||||
dayBattery.setDonePercent(done);
|
componentRegistry.setVisible(currentVisibility.isNotNone());
|
||||||
|
|
||||||
int weekDayWhenMondayIsOne = calNow.get(Calendar.DAY_OF_WEEK) - 1;
|
jokeButton.setVisible(
|
||||||
weekBattery.setDonePercent(
|
TimeCalcProperties.getInstance().getBooleanProperty(
|
||||||
WeekBattery.getWeekProgress(weekDayWhenMondayIsOne, done));
|
TimeCalcProperty.JOKES_VISIBLE)
|
||||||
weekBattery.setLabel(
|
&& !currentVisibility.isNone());
|
||||||
nowIsWeekend ? "5/5" : (weekDayWhenMondayIsOne + "/5"));
|
|
||||||
|
setTitle(currentVisibility.isNone() ? "" : windowTitle);
|
||||||
monthBattery.setDonePercent(MonthBattery
|
|
||||||
.getMonthProgress(weekDayWhenMondayIsOne, workDaysDone,
|
int hourNow = analogClock.hourProperty.getValue();
|
||||||
workDaysTotal, done));
|
int minuteNow = analogClock.minuteProperty.getValue();
|
||||||
monthBattery.setLabel(
|
|
||||||
(nowIsWeekend ? workDaysDone : workDaysDone + 1) + "/"
|
int secondNow = analogClock.secondProperty.getValue();
|
||||||
+ (workDaysTotal));
|
int millisecondNow = analogClock.millisecondProperty.getValue();
|
||||||
|
TimeHM timeRemains = new TimeHM(endTime.getHour() - hourNow,
|
||||||
hourBattery.setDonePercent(
|
endTime.getMinute() - minuteNow);
|
||||||
HourBattery.getHourProgress(timeRemains, secondsRemains,
|
|
||||||
millisecondsRemains));
|
int secondsRemains = 60 - secondNow;
|
||||||
if (!nowIsWeekend) {
|
int millisecondsRemains = 1000 - millisecondNow;
|
||||||
hourBattery.setLabel(
|
|
||||||
hourDone + "/" + (
|
int hourDone = Constants.WORKING_HOURS_LENGTH + overtime.getHour()
|
||||||
totalMinutes / 60));
|
- timeRemains.getHour();
|
||||||
}
|
int minutesDone =
|
||||||
|
Constants.WORKING_MINUTES_LENGTH + overtime.getMinute()
|
||||||
int totalSecondsRemains =
|
- timeRemains.getMinute();
|
||||||
(timeRemains.getHour() * 60 * 60
|
int secondsDone = secondNow;
|
||||||
+ timeRemains.getMinute() * 60
|
int millisecondsDone = millisecondNow;
|
||||||
+ secondsRemains);
|
|
||||||
int totalMillisecondsRemains =
|
int totalMinutesDone = hourDone * 60 + minutesDone;
|
||||||
totalSecondsRemains * 1000 + millisecondsRemains;
|
int totalSecondsDone = totalMinutesDone * 60 + secondsDone;
|
||||||
double totalSecondsRemainsDouble =
|
int totalMillisecondsDone =
|
||||||
((double) totalMillisecondsRemains) / 1000;
|
totalSecondsDone * 1000 + millisecondsDone;
|
||||||
|
|
||||||
if (timeRemains.getHour() <= 0 && timeRemains.getMinute() <= 0) {
|
double done = ((double) totalMillisecondsDone)
|
||||||
Toaster toasterManager = new Toaster();
|
/ ((double) totalMilliseconds);
|
||||||
toasterManager.setDisplayTime(30000);
|
progressSquare.setDonePercent(done);
|
||||||
toasterManager.showToaster(
|
progressCircle.setDonePercent(done);
|
||||||
"Congratulation :-) It is the time to go home.");
|
dayBattery.setDonePercent(done);
|
||||||
walkingHumanProgressAsciiArt
|
|
||||||
.printPercentToAscii(done, timeRemains.getHour(),
|
int weekDayWhenMondayIsOne = calNow.get(Calendar.DAY_OF_WEEK) - 1;
|
||||||
timeRemains.getMinute(), done,
|
weekBattery.setDonePercent(
|
||||||
totalSecondsRemainsDouble, endTime);
|
WeekBattery.getWeekProgress(weekDayWhenMondayIsOne, done));
|
||||||
try {
|
weekBattery.setLabel(
|
||||||
Thread.sleep(10000);
|
nowIsWeekend ? "5/5" : (weekDayWhenMondayIsOne + "/5"));
|
||||||
} catch (InterruptedException e) {
|
|
||||||
|
monthBattery.setDonePercent(MonthBattery
|
||||||
}
|
.getMonthProgress(weekDayWhenMondayIsOne, workDaysDone,
|
||||||
while (!stopBeforeEnd) {
|
workDaysTotal, done));
|
||||||
try {
|
monthBattery.setLabel(
|
||||||
Thread.sleep(1000);
|
(nowIsWeekend ? workDaysDone : workDaysDone + 1) + "/"
|
||||||
} catch (InterruptedException e) {
|
+ (workDaysTotal));
|
||||||
|
|
||||||
}
|
hourBattery.setDonePercent(
|
||||||
}
|
HourBattery.getHourProgress(timeRemains, secondsRemains,
|
||||||
} else {
|
millisecondsRemains));
|
||||||
walkingHumanProgressAsciiArt
|
if (!nowIsWeekend) {
|
||||||
.printPercentToAscii(done, timeRemains.getHour(),
|
hourBattery.setLabel(
|
||||||
timeRemains.getMinute(), done,
|
hourDone + "/" + (
|
||||||
totalSecondsRemainsDouble, endTime);
|
totalMinutes / 60));
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
int totalSecondsRemains =
|
||||||
Thread.sleep(100);
|
(timeRemains.getHour() * 60 * 60
|
||||||
} catch (InterruptedException e) {
|
+ timeRemains.getMinute() * 60
|
||||||
|
+ secondsRemains);
|
||||||
}
|
int totalMillisecondsRemains =
|
||||||
}
|
totalSecondsRemains * 1000 + millisecondsRemains;
|
||||||
if(configWindow != null) {configWindow.setVisible(false);configWindow.dispose();}
|
double totalSecondsRemainsDouble =
|
||||||
window.setVisible(false);
|
((double) totalMillisecondsRemains) / 1000;
|
||||||
window.dispose();
|
|
||||||
}
|
if (timeRemains.getHour() <= 0 && timeRemains.getMinute() <= 0) {
|
||||||
|
Toaster toasterManager = new Toaster();
|
||||||
private void bindToIfPropertyMissing(Properties properties, String key, Calendar cal, int timeUnit, IntegerProperty firstProperty, Property secondProperty) {
|
toasterManager.setDisplayTime(30000);
|
||||||
if (properties.containsKey(key)) {
|
toasterManager.showToaster(
|
||||||
cal.set(timeUnit, Integer.parseInt(
|
"Congratulation :-) It is the time to go home.");
|
||||||
(String) properties.get(key)) + (timeUnit == Calendar.MONTH ? -1 : 0));
|
walkingHumanProgressAsciiArt
|
||||||
firstProperty.setValue(Integer.valueOf(
|
.printPercentToAscii(done, timeRemains.getHour(),
|
||||||
(String) properties.get(key)));
|
timeRemains.getMinute(), done,
|
||||||
} else {
|
totalSecondsRemainsDouble, endTime);
|
||||||
firstProperty.bindTo(secondProperty);
|
try {
|
||||||
}
|
Thread.sleep(10000);
|
||||||
}
|
} catch (InterruptedException e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
while (!stopBeforeEnd) {
|
||||||
|
try {
|
||||||
|
Thread.sleep(1000);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
walkingHumanProgressAsciiArt
|
||||||
|
.printPercentToAscii(done, timeRemains.getHour(),
|
||||||
|
timeRemains.getMinute(), done,
|
||||||
|
totalSecondsRemainsDouble, endTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
Thread.sleep(100);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(configWindow != null) {configWindow.setVisible(false);configWindow.dispose();}
|
||||||
|
if(workDaysWindow != null) {workDaysWindow.setVisible(false);workDaysWindow.dispose();}
|
||||||
|
if(activitiesWindow != null) {activitiesWindow.setVisible(false);activitiesWindow.dispose();}
|
||||||
|
|
||||||
|
setVisible(false);
|
||||||
|
dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,7 +1,6 @@
|
|||||||
package org.nanoboot.utils.timecalc.swing.common;
|
package org.nanoboot.utils.timecalc.swing.common;
|
||||||
|
|
||||||
import org.nanoboot.utils.timecalc.app.GetProperty;
|
import org.nanoboot.utils.timecalc.app.GetProperty;
|
||||||
import org.nanoboot.utils.timecalc.app.TimeCalcManager;
|
|
||||||
import org.nanoboot.utils.timecalc.entity.Visibility;
|
import org.nanoboot.utils.timecalc.entity.Visibility;
|
||||||
import org.nanoboot.utils.timecalc.utils.property.Property;
|
import org.nanoboot.utils.timecalc.utils.property.Property;
|
||||||
import org.nanoboot.utils.timecalc.utils.property.StringProperty;
|
import org.nanoboot.utils.timecalc.utils.property.StringProperty;
|
||||||
@ -31,8 +30,8 @@ public class TimeCalcButton extends JButton implements GetProperty {
|
|||||||
Visibility.valueOf(visibilityProperty.getValue());
|
Visibility.valueOf(visibilityProperty.getValue());
|
||||||
setVisible(visibility.isNotNone());
|
setVisible(visibility.isNotNone());
|
||||||
if (!visibility.isStronglyColored() || visibility.isGray()) {
|
if (!visibility.isStronglyColored() || visibility.isGray()) {
|
||||||
setBackground(TimeCalcManager.BACKGROUND_COLOR);
|
setBackground(MainWindow.BACKGROUND_COLOR);
|
||||||
setForeground(TimeCalcManager.FOREGROUND_COLOR);
|
setForeground(MainWindow.FOREGROUND_COLOR);
|
||||||
} else {
|
} else {
|
||||||
setOriginalBackground();
|
setOriginalBackground();
|
||||||
setOriginalForeground();
|
setOriginalForeground();
|
||||||
|
@ -10,14 +10,7 @@ import java.awt.HeadlessException;
|
|||||||
*/
|
*/
|
||||||
public class TimeCalcWindow extends JFrame {
|
public class TimeCalcWindow extends JFrame {
|
||||||
public TimeCalcWindow() throws HeadlessException {
|
public TimeCalcWindow() throws HeadlessException {
|
||||||
setFocusable(true);
|
|
||||||
setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
|
|
||||||
addWindowListener(new java.awt.event.WindowAdapter() {
|
|
||||||
@Override
|
|
||||||
public void windowClosing(java.awt.event.WindowEvent e) {
|
|
||||||
System.exit(0);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Component[] addAll(Component... comp) {
|
public Component[] addAll(Component... comp) {
|
||||||
|
@ -0,0 +1,28 @@
|
|||||||
|
package org.nanoboot.utils.timecalc.swing.common;
|
||||||
|
|
||||||
|
import org.nanoboot.utils.timecalc.app.TimeCalcConfiguration;
|
||||||
|
import org.nanoboot.utils.timecalc.app.TimeCalcProperty;
|
||||||
|
import org.nanoboot.utils.timecalc.entity.Visibility;
|
||||||
|
|
||||||
|
import javax.swing.JCheckBox;
|
||||||
|
import javax.swing.JComboBox;
|
||||||
|
import javax.swing.JComponent;
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Robert Vokac
|
||||||
|
* @since 16.02.2024
|
||||||
|
*/
|
||||||
|
public class WorkDaysWindow extends TimeCalcWindow {
|
||||||
|
public WorkDaysWindow() {
|
||||||
|
setSize(800, 600);
|
||||||
|
setTitle("Work Days");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -2,15 +2,13 @@ package org.nanoboot.utils.timecalc.swing.progress;
|
|||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.nanoboot.utils.timecalc.app.TimeCalcProperties;
|
import org.nanoboot.utils.timecalc.app.TimeCalcProperties;
|
||||||
|
import org.nanoboot.utils.timecalc.app.TimeCalcProperty;
|
||||||
import org.nanoboot.utils.timecalc.entity.Visibility;
|
import org.nanoboot.utils.timecalc.entity.Visibility;
|
||||||
import org.nanoboot.utils.timecalc.swing.common.Widget;
|
import org.nanoboot.utils.timecalc.swing.common.Widget;
|
||||||
import org.nanoboot.utils.timecalc.utils.common.ProgressSmiley;
|
|
||||||
import org.nanoboot.utils.timecalc.utils.common.NumberFormats;
|
import org.nanoboot.utils.timecalc.utils.common.NumberFormats;
|
||||||
import org.nanoboot.utils.timecalc.utils.common.Utils;
|
import org.nanoboot.utils.timecalc.utils.common.Utils;
|
||||||
import org.nanoboot.utils.timecalc.utils.property.BooleanProperty;
|
import org.nanoboot.utils.timecalc.utils.property.BooleanProperty;
|
||||||
|
|
||||||
import javax.swing.ImageIcon;
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.Font;
|
import java.awt.Font;
|
||||||
@ -117,7 +115,7 @@ public class Battery extends Widget {
|
|||||||
int waterSurfaceHeight =
|
int waterSurfaceHeight =
|
||||||
(int) (4 * surfacePower);//2 + (int) (Math.random() * 3);
|
(int) (4 * surfacePower);//2 + (int) (Math.random() * 3);
|
||||||
if (waterSurfaceHeight <= 2 || !TimeCalcProperties.getInstance()
|
if (waterSurfaceHeight <= 2 || !TimeCalcProperties.getInstance()
|
||||||
.areBatteryWavesEnabled() || wavesProperty.isDisabled()) {
|
.getBooleanProperty(TimeCalcProperty.BATTERY_WAVES_VISIBLE) || wavesProperty.isDisabled()) {
|
||||||
waterSurfaceHeight = 0;
|
waterSurfaceHeight = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package org.nanoboot.utils.timecalc.swing.progress;
|
package org.nanoboot.utils.timecalc.swing.progress;
|
||||||
|
|
||||||
import org.nanoboot.utils.timecalc.app.GetProperty;
|
import org.nanoboot.utils.timecalc.app.GetProperty;
|
||||||
import org.nanoboot.utils.timecalc.app.TimeCalcManager;
|
import org.nanoboot.utils.timecalc.swing.common.MainWindow;
|
||||||
import org.nanoboot.utils.timecalc.entity.Visibility;
|
import org.nanoboot.utils.timecalc.entity.Visibility;
|
||||||
import org.nanoboot.utils.timecalc.swing.common.Toaster;
|
import org.nanoboot.utils.timecalc.swing.common.Toaster;
|
||||||
import org.nanoboot.utils.timecalc.utils.common.Constants;
|
import org.nanoboot.utils.timecalc.utils.common.Constants;
|
||||||
@ -41,7 +41,7 @@ public class WalkingHumanProgressAsciiArt extends JTextPane implements
|
|||||||
putClientProperty("mouseEntered", "false");
|
putClientProperty("mouseEntered", "false");
|
||||||
setFocusable(false);
|
setFocusable(false);
|
||||||
setForeground(Color.GRAY);
|
setForeground(Color.GRAY);
|
||||||
setBackground(TimeCalcManager.BACKGROUND_COLOR);
|
setBackground(MainWindow.BACKGROUND_COLOR);
|
||||||
addMouseListener(new MouseListener() {
|
addMouseListener(new MouseListener() {
|
||||||
@Override
|
@Override
|
||||||
public void mouseClicked(MouseEvent e) {
|
public void mouseClicked(MouseEvent e) {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package org.nanoboot.utils.timecalc.utils.common;
|
package org.nanoboot.utils.timecalc.utils.common;
|
||||||
|
|
||||||
import org.nanoboot.utils.timecalc.app.TimeCalcProperties;
|
import org.nanoboot.utils.timecalc.app.TimeCalcProperties;
|
||||||
|
import org.nanoboot.utils.timecalc.app.TimeCalcProperty;
|
||||||
import org.nanoboot.utils.timecalc.swing.common.Toaster;
|
import org.nanoboot.utils.timecalc.swing.common.Toaster;
|
||||||
|
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
@ -63,7 +64,8 @@ public class Jokes {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void showRandom() {
|
public static void showRandom() {
|
||||||
if (!TimeCalcProperties.getInstance().areJokesEnabled()) {
|
if (!TimeCalcProperties.getInstance().getBooleanProperty(
|
||||||
|
TimeCalcProperty.JOKES_VISIBLE)) {
|
||||||
//nothing to do
|
//nothing to do
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -6,9 +6,12 @@ import org.nanoboot.utils.timecalc.utils.property.BooleanProperty;
|
|||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Font;
|
import java.awt.Font;
|
||||||
import java.awt.FontFormatException;
|
import java.awt.FontFormatException;
|
||||||
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
@ -125,4 +128,18 @@ public class Utils {
|
|||||||
return base64Decoder
|
return base64Decoder
|
||||||
.decode(s.getBytes());
|
.decode(s.getBytes());
|
||||||
}
|
}
|
||||||
|
public static String readTextFromTextResourceInJar(String pathToFile) throws IOException {
|
||||||
|
InputStream inputStream = ClassLoader.getSystemClassLoader().
|
||||||
|
getSystemResourceAsStream(pathToFile);
|
||||||
|
InputStreamReader
|
||||||
|
streamReader = new InputStreamReader(inputStream,
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
BufferedReader in = new BufferedReader(streamReader);
|
||||||
|
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for (String line; (line = in.readLine()) != null; ) {
|
||||||
|
sb.append(line).append("\n");
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,8 +9,11 @@ public class StringProperty extends Property<String> {
|
|||||||
public StringProperty(String name, String valueIn) {
|
public StringProperty(String name, String valueIn) {
|
||||||
super(name, valueIn);
|
super(name, valueIn);
|
||||||
}
|
}
|
||||||
|
public StringProperty(String name) {
|
||||||
|
this(name, "");
|
||||||
|
}
|
||||||
|
|
||||||
public StringProperty() {
|
public StringProperty() {
|
||||||
this("", "");
|
this("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,31 @@
|
|||||||
|
visibility.default=STRONGLY_COLORED
|
||||||
|
visibility.supported.colored=true
|
||||||
|
#
|
||||||
|
clock.hands.long.visible=true
|
||||||
|
clock.hands.minute.visible=true
|
||||||
|
clock.hands.second.visible=true
|
||||||
|
clock.hands.millisecond.visible=false
|
||||||
|
#
|
||||||
|
battery.waves.visible=true
|
||||||
|
#
|
||||||
|
jokes.visible=true
|
||||||
|
commands.visible=true
|
||||||
|
notifications.visible=true
|
||||||
|
smileys.colored=false
|
||||||
|
|
||||||
|
#todo
|
||||||
|
visibility.smileys.enabled=true
|
||||||
|
visibility.battery.smileys.enabled=true
|
||||||
|
visibility.progress.square.smileys.enabled=true
|
||||||
|
visibility.progress.circle.smileys.enabled=true
|
||||||
|
visibility.battery.charging-unicode-character.enabled=true
|
||||||
|
battery.percent-precision.count-of-decimal-points=5
|
||||||
|
visibility.battery.label.finished-from-total.enabled=true
|
||||||
|
visibility.widgets.clock.enabled=true
|
||||||
|
visibility.widgets.progress-square.enabled=true
|
||||||
|
visibility.widgets.progress-circle.enabled=true
|
||||||
|
visibility.widgets.walking-human.enabled=true
|
||||||
|
visibility.widgets.battery.hour.enabled=true
|
||||||
|
visibility.widgets.battery.day.enabled=true
|
||||||
|
visibility.widgets.battery.week.enabled=true
|
||||||
|
visibility.widgets.battery.month.enabled=true
|
@ -1,13 +1,16 @@
|
|||||||
clock.hands.long=true
|
visibility.default=STRONGLY_COLORED
|
||||||
clock.hands.minute.enabled=true
|
visibility.supported.colored=false
|
||||||
clock.hands.second.enabled=true
|
#
|
||||||
clock.hands.millisecond.enabled=false
|
clock.hands.long.visible=true
|
||||||
battery.waves.enabled=true
|
clock.hands.minute.visible=true
|
||||||
visibility.current=STRONGLY_COLORED
|
clock.hands.second.visible=true
|
||||||
visibility.only-grey-or-none.enabled=false
|
clock.hands.millisecond.visible=false
|
||||||
jokes.enabled=true
|
#
|
||||||
commands.enabled=true
|
battery.waves.visible=true
|
||||||
toasts.enabled=true
|
#
|
||||||
|
jokes.visible=true
|
||||||
|
commands.visible=true
|
||||||
|
notifications.visible=true
|
||||||
smileys.colored=false
|
smileys.colored=false
|
||||||
|
|
||||||
#todo
|
#todo
|
||||||
|
Loading…
x
Reference in New Issue
Block a user