mirror of
https://github.com/robertvokac/time-calc.git
synced 2025-03-25 07:27:49 +01:00
ConfigWindow VIII
This commit is contained in:
parent
c56e3be383
commit
6e92cf26fd
2
.gitignore
vendored
2
.gitignore
vendored
@ -13,6 +13,6 @@ proxy.txt
|
|||||||
out.txt
|
out.txt
|
||||||
pocasi.txt
|
pocasi.txt
|
||||||
test.txt
|
test.txt
|
||||||
timecalc.conf
|
timecalc.template.conf
|
||||||
focus.txt
|
focus.txt
|
||||||
dist/*
|
dist/*
|
||||||
|
@ -8,6 +8,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Robert Vokac
|
* @author Robert Vokac
|
||||||
@ -51,6 +52,8 @@ public class TimeCalcConfiguration {
|
|||||||
|
|
||||||
private final Map<TimeCalcProperty, Property> mapOfProperties = new HashMap<>();
|
private final Map<TimeCalcProperty, Property> mapOfProperties = new HashMap<>();
|
||||||
private List<Property> allProperties = new ArrayList<>();
|
private List<Property> allProperties = new ArrayList<>();
|
||||||
|
private TimeCalcProperties timeCalcProperties;
|
||||||
|
|
||||||
public TimeCalcConfiguration() {
|
public TimeCalcConfiguration() {
|
||||||
for(Property p:new Property[] {
|
for(Property p:new Property[] {
|
||||||
visibilityDefaultProperty,
|
visibilityDefaultProperty,
|
||||||
@ -77,8 +80,18 @@ public class TimeCalcConfiguration {
|
|||||||
return mapOfProperties.get(timeCalcProperty);
|
return mapOfProperties.get(timeCalcProperty);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFromTimeCalcProperties(
|
public void saveToTimeCalcProperties() {
|
||||||
|
if(timeCalcProperties == null) {
|
||||||
|
throw new TimeCalcException("Cannot save properties, because timeCalcProperties is null.");
|
||||||
|
}
|
||||||
|
Properties properties = new Properties();
|
||||||
|
this.allProperties.stream().forEach(p -> properties.put(p.getName(), p.getValue()));
|
||||||
|
this.timeCalcProperties.save(properties);
|
||||||
|
|
||||||
|
}
|
||||||
|
public void loadFromTimeCalcProperties(
|
||||||
TimeCalcProperties timeCalcProperties) {
|
TimeCalcProperties timeCalcProperties) {
|
||||||
|
this.timeCalcProperties = timeCalcProperties;
|
||||||
for(Property p:allProperties) {
|
for(Property p:allProperties) {
|
||||||
if(p instanceof BooleanProperty) {
|
if(p instanceof BooleanProperty) {
|
||||||
((BooleanProperty)p).setValue(timeCalcProperties.getBooleanProperty(TimeCalcProperty.forKey(p.getName())));
|
((BooleanProperty)p).setValue(timeCalcProperties.getBooleanProperty(TimeCalcProperty.forKey(p.getName())));
|
||||||
|
@ -5,6 +5,7 @@ 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.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -17,12 +18,13 @@ import java.util.Properties;
|
|||||||
*/
|
*/
|
||||||
public class TimeCalcProperties {
|
public class TimeCalcProperties {
|
||||||
|
|
||||||
|
public static final File FILE = new File("timecalc.conf");
|
||||||
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 final Map<String, String> defaultProperties = new HashMap<>();
|
||||||
|
|
||||||
private TimeCalcProperties() {
|
private TimeCalcProperties() {
|
||||||
if (!new File("timecalc.conf").exists()) {
|
if (!FILE.exists()) {
|
||||||
//nothing to do;
|
//nothing to do;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -110,11 +112,14 @@ public class TimeCalcProperties {
|
|||||||
properties.replace(key, value.name());
|
properties.replace(key, value.name());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void load() {
|
public void save(Properties properties) {
|
||||||
//to be implemented
|
properties.entrySet().stream().forEach(e-> this.properties.replace(e.getKey(), e.getValue().toString()));
|
||||||
}
|
try {
|
||||||
|
this.properties.store(new FileOutputStream(FILE), null);
|
||||||
public void save() {
|
System.out.println("Saving to " + FILE + " was successful");
|
||||||
//to be implemented
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
System.out.println("Saving to " + FILE + " failed: " + e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -121,48 +121,49 @@ public class ConfigWindow extends TimeCalcWindow {
|
|||||||
|
|
||||||
Arrays.stream(getComponents()).forEach(c->c.getClass().getName());
|
Arrays.stream(getComponents()).forEach(c->c.getClass().getName());
|
||||||
ConfigWindow configWindow = this;
|
ConfigWindow configWindow = this;
|
||||||
class ConfigThread implements Runnable {
|
// class ConfigThread implements Runnable {
|
||||||
public final AtomicBoolean stopped = new AtomicBoolean();
|
// public final AtomicBoolean stopped = new AtomicBoolean();
|
||||||
|
//
|
||||||
public void run() {
|
// public void run() {
|
||||||
while (true) {
|
// while (true) {
|
||||||
if (stopped.get()) {
|
// if (stopped.get()) {
|
||||||
break;
|
// System.out.println("stopping thread");
|
||||||
}
|
// break;
|
||||||
if (!configWindow.visibilitySupportedColoredProperty
|
// }
|
||||||
.isSelected()
|
// if (!configWindow.visibilitySupportedColoredProperty
|
||||||
&& configWindow.visibilityDefaultProperty.isEnabled()) {
|
// .isSelected()
|
||||||
configWindow.visibilityDefaultProperty.disable();
|
// && configWindow.visibilityDefaultProperty.isEnabled()) {
|
||||||
}
|
// configWindow.visibilityDefaultProperty.disable();
|
||||||
if (configWindow.visibilitySupportedColoredProperty
|
// }
|
||||||
.isSelected()
|
// if (configWindow.visibilitySupportedColoredProperty
|
||||||
&& !configWindow.visibilityDefaultProperty
|
// .isSelected()
|
||||||
.isEnabled()) {
|
// && !configWindow.visibilityDefaultProperty
|
||||||
configWindow.visibilityDefaultProperty.enable();
|
// .isEnabled()) {
|
||||||
}
|
// configWindow.visibilityDefaultProperty.enable();
|
||||||
}
|
// }
|
||||||
try {
|
// }
|
||||||
Thread.sleep(100);
|
// try {
|
||||||
} catch (InterruptedException e) {
|
// Thread.sleep(100);
|
||||||
e.printStackTrace();
|
// } catch (InterruptedException e) {
|
||||||
System.out.println(e);
|
// e.printStackTrace();
|
||||||
}
|
// System.out.println(e);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
ConfigThread configThread = new ConfigThread();
|
// }
|
||||||
Thread thread = new Thread(configThread);
|
// ConfigThread configThread = new ConfigThread();
|
||||||
|
// Thread thread = new Thread(configThread);
|
||||||
thread.start();
|
//
|
||||||
|
// thread.start();
|
||||||
addWindowListener(new WindowAdapter() {
|
addWindowListener(new WindowAdapter() {
|
||||||
//for closing
|
|
||||||
@Override
|
@Override
|
||||||
public void windowClosing(WindowEvent e) {
|
public void windowClosing(WindowEvent e) {
|
||||||
|
//configThread.stopped.set(true);
|
||||||
}
|
}
|
||||||
//for closed
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void windowClosed(WindowEvent e) {
|
public void windowClosed(WindowEvent e) {
|
||||||
configThread.stopped.set(true);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -63,11 +63,12 @@ public class MainWindow extends TimeCalcWindow{
|
|||||||
addWindowListener(new java.awt.event.WindowAdapter() {
|
addWindowListener(new java.awt.event.WindowAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void windowClosing(java.awt.event.WindowEvent e) {
|
public void windowClosing(java.awt.event.WindowEvent e) {
|
||||||
|
timeCalcConfiguration.saveToTimeCalcProperties();
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
timeCalcConfiguration
|
timeCalcConfiguration
|
||||||
.setFromTimeCalcProperties(TimeCalcProperties.getInstance());
|
.loadFromTimeCalcProperties(TimeCalcProperties.getInstance());
|
||||||
|
|
||||||
overTimeIn = (overTimeIn == null || overTimeIn.isEmpty()) ?
|
overTimeIn = (overTimeIn == null || overTimeIn.isEmpty()) ?
|
||||||
Constants.DEFAULT_OVERTIME : overTimeIn;
|
Constants.DEFAULT_OVERTIME : overTimeIn;
|
||||||
@ -319,6 +320,7 @@ public class MainWindow extends TimeCalcWindow{
|
|||||||
if(activitiesWindow != null) {activitiesWindow.setVisible(false);activitiesWindow.dispose();}
|
if(activitiesWindow != null) {activitiesWindow.setVisible(false);activitiesWindow.dispose();}
|
||||||
if(helpWindow != null) {helpWindow.setVisible(false);helpWindow.dispose();}
|
if(helpWindow != null) {helpWindow.setVisible(false);helpWindow.dispose();}
|
||||||
|
|
||||||
|
timeCalcConfiguration.saveToTimeCalcProperties();
|
||||||
setVisible(false);
|
setVisible(false);
|
||||||
dispose();
|
dispose();
|
||||||
|
|
||||||
@ -434,6 +436,7 @@ public class MainWindow extends TimeCalcWindow{
|
|||||||
if(activitiesWindow != null) {activitiesWindow.setVisible(false);activitiesWindow.dispose();}
|
if(activitiesWindow != null) {activitiesWindow.setVisible(false);activitiesWindow.dispose();}
|
||||||
if(helpWindow != null) {helpWindow.setVisible(false);helpWindow.dispose();}
|
if(helpWindow != null) {helpWindow.setVisible(false);helpWindow.dispose();}
|
||||||
|
|
||||||
|
timeCalcConfiguration.saveToTimeCalcProperties();
|
||||||
setVisible(false);
|
setVisible(false);
|
||||||
dispose();
|
dispose();
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,8 @@ public class Battery extends Widget {
|
|||||||
private final String name;
|
private final String name;
|
||||||
private final double[] randomDoubles =
|
private final double[] randomDoubles =
|
||||||
new double[] {1d, 1d, 1d, 1d, 1d, 1d, 1};
|
new double[] {1d, 1d, 1d, 1d, 1d, 1d, 1};
|
||||||
public BooleanProperty wavesProperty = new BooleanProperty("waves", true);
|
public BooleanProperty wavesProperty = new BooleanProperty(TimeCalcProperty.BATTERY_WAVES_VISIBLE
|
||||||
|
.getKey(), true);
|
||||||
private final BooleanProperty blinking = new BooleanProperty("blinking");
|
private final BooleanProperty blinking = new BooleanProperty("blinking");
|
||||||
private long tmpNanoTime = 0l;
|
private long tmpNanoTime = 0l;
|
||||||
private int totalHeight = 0;
|
private int totalHeight = 0;
|
||||||
|
@ -1,34 +1,29 @@
|
|||||||
visibility.default=STRONGLY_COLORED
|
#Wed Feb 28 12:20:58 CET 2024
|
||||||
visibility.supported.colored=false
|
battery.charging-unicode-character.visible=true
|
||||||
#
|
battery.week.visible=true
|
||||||
clock.hands.long.visible=true
|
smileys.colored=false
|
||||||
clock.hands.minute.visible=true
|
circle.smileys.visible=true
|
||||||
clock.hands.second.visible=true
|
notifications.visible=true
|
||||||
clock.hands.millisecond.visible=false
|
clock.hands.second.visible=true
|
||||||
#
|
battery.hour.visible=true
|
||||||
battery.waves.visible=true
|
widgets.clock.visible=true
|
||||||
#
|
battery.visible=true
|
||||||
jokes.visible=true
|
clock.hands.millisecond.visible=false
|
||||||
commands.visible=true
|
commands.visible=true
|
||||||
notifications.visible=true
|
battery.percent-precision.count-of-decimal-points=5
|
||||||
smileys.colored=false
|
visibility.supported.colored=false
|
||||||
|
jokes.visible=true
|
||||||
#todo
|
visibility.default=GRAY
|
||||||
logs.detailed=false
|
square.smileys.visible=true
|
||||||
smileys.visible=true
|
battery.month.visible=true
|
||||||
battery.smileys.visible=true
|
battery.waves.visible=true
|
||||||
square.smileys.visible=true
|
battery.day.visible=true
|
||||||
circle.smileys.visible=true
|
battery.smileys.visible=true
|
||||||
battery.charging-unicode-character.visible=true
|
clock.hands.minute.visible=true
|
||||||
battery.percent-precision.count-of-decimal-points=5
|
circle.visible=true
|
||||||
battery.label.finished-from-total.visible=true
|
logs.detailed=false
|
||||||
widgets.clock.visible=true
|
clock.hands.long.visible=true
|
||||||
square.visible=true
|
square.visible=true
|
||||||
circle.visible=true
|
walking-human.visible=true
|
||||||
walking-human.visible=true
|
battery.label.finished-from-total.visible=true
|
||||||
battery.visible=true
|
smileys.visible=true
|
||||||
battery.hour.visible=true
|
|
||||||
battery.day.visible=true
|
|
||||||
battery.week.visible=true
|
|
||||||
battery.month.visible=true
|
|
||||||
|
|
||||||
|
34
timecalc.template.conf
Normal file
34
timecalc.template.conf
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
visibility.default=STRONGLY_COLORED
|
||||||
|
visibility.supported.colored=false
|
||||||
|
#
|
||||||
|
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
|
||||||
|
logs.detailed=false
|
||||||
|
smileys.visible=true
|
||||||
|
battery.smileys.visible=true
|
||||||
|
square.smileys.visible=true
|
||||||
|
circle.smileys.visible=true
|
||||||
|
battery.charging-unicode-character.visible=true
|
||||||
|
battery.percent-precision.count-of-decimal-points=5
|
||||||
|
battery.label.finished-from-total.visible=true
|
||||||
|
widgets.clock.visible=true
|
||||||
|
square.visible=true
|
||||||
|
circle.visible=true
|
||||||
|
walking-human.visible=true
|
||||||
|
battery.visible=true
|
||||||
|
battery.hour.visible=true
|
||||||
|
battery.day.visible=true
|
||||||
|
battery.week.visible=true
|
||||||
|
battery.month.visible=true
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user