mirror of
https://github.com/robertvokac/time-calc.git
synced 2025-03-25 07:27:49 +01:00
ConfigWindow VI
This commit is contained in:
parent
f1dadc033f
commit
03ae7071b9
@ -6,6 +6,7 @@ import org.nanoboot.utils.timecalc.utils.property.Property;
|
|||||||
* @author Robert
|
* @author Robert
|
||||||
* @since 26.02.2024
|
* @since 26.02.2024
|
||||||
*/
|
*/
|
||||||
public interface GetProperty<T> {
|
public interface GetProperty {
|
||||||
Property<T> getProperty();
|
Property getVisibilityProperty();
|
||||||
|
Property getVisibilitySupportedColoredProperty();
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
|
|||||||
public void keyPressed(KeyEvent e) {
|
public void keyPressed(KeyEvent e) {
|
||||||
boolean onlyGreyOrNone =
|
boolean onlyGreyOrNone =
|
||||||
timeCalcConfiguration.visibilitySupportedColoredProperty
|
timeCalcConfiguration.visibilitySupportedColoredProperty
|
||||||
.isEnabled();
|
.isDisabled();
|
||||||
Visibility visibility = Visibility
|
Visibility visibility = Visibility
|
||||||
.valueOf(timeCalcApp.visibilityProperty.getValue());
|
.valueOf(timeCalcApp.visibilityProperty.getValue());
|
||||||
if (e.getKeyCode() == KeyEvent.VK_UP) {
|
if (e.getKeyCode() == KeyEvent.VK_UP) {
|
||||||
|
@ -74,6 +74,7 @@ public class ConfigWindow extends TimeCalcWindow {
|
|||||||
smileysColoredProperty));
|
smileysColoredProperty));
|
||||||
//
|
//
|
||||||
propertiesList.stream().forEach(p -> {
|
propertiesList.stream().forEach(p -> {
|
||||||
|
System.out.println("Found form item: " + p.getClass());
|
||||||
if(p == visibilityDefaultProperty) {
|
if(p == visibilityDefaultProperty) {
|
||||||
p.putClientProperty(CLIENT_PROPERTY_KEY, TimeCalcProperty.VISIBILITY_DEFAULT.getKey());
|
p.putClientProperty(CLIENT_PROPERTY_KEY, TimeCalcProperty.VISIBILITY_DEFAULT.getKey());
|
||||||
addToNextRow(new JLabel(TimeCalcProperty.VISIBILITY_DEFAULT.getDescription()));
|
addToNextRow(new JLabel(TimeCalcProperty.VISIBILITY_DEFAULT.getDescription()));
|
||||||
|
@ -25,7 +25,6 @@ import org.nanoboot.utils.timecalc.utils.common.Utils;
|
|||||||
import org.nanoboot.utils.timecalc.utils.property.IntegerProperty;
|
import org.nanoboot.utils.timecalc.utils.property.IntegerProperty;
|
||||||
import org.nanoboot.utils.timecalc.utils.property.Property;
|
import org.nanoboot.utils.timecalc.utils.property.Property;
|
||||||
|
|
||||||
import javax.swing.JComponent;
|
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
@ -34,13 +33,11 @@ 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.Arrays;
|
|
||||||
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;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Robert Vokac
|
* @author Robert Vokac
|
||||||
@ -105,10 +102,11 @@ public class MainWindow extends TimeCalcWindow{
|
|||||||
addAll(configButton, workDaysButton, activitiesButton, restartButton,
|
addAll(configButton, workDaysButton, activitiesButton, restartButton,
|
||||||
exitButton, focusButton, helpButton, commandButton, jokeButton);
|
exitButton, focusButton, helpButton, commandButton, jokeButton);
|
||||||
|
|
||||||
if(timeCalcConfiguration.visibilitySupportedColoredProperty.isEnabled()) {
|
|
||||||
|
timeCalcApp.visibilityProperty.bindTo(timeCalcConfiguration.visibilityDefaultProperty);
|
||||||
|
if(!timeCalcConfiguration.visibilitySupportedColoredProperty.isEnabled()) {
|
||||||
timeCalcApp.visibilityProperty.setValue(Visibility.GRAY.name());
|
timeCalcApp.visibilityProperty.setValue(Visibility.GRAY.name());
|
||||||
}
|
}
|
||||||
timeCalcApp.visibilityProperty.bindTo(timeCalcConfiguration.visibilityDefaultProperty);
|
|
||||||
TimeCalcKeyAdapter timeCalcKeyAdapter = new TimeCalcKeyAdapter(timeCalcConfiguration, timeCalcApp, commandButton, this);
|
TimeCalcKeyAdapter timeCalcKeyAdapter = new TimeCalcKeyAdapter(timeCalcConfiguration, timeCalcApp, commandButton, this);
|
||||||
addKeyListener(timeCalcKeyAdapter);
|
addKeyListener(timeCalcKeyAdapter);
|
||||||
|
|
||||||
@ -296,7 +294,10 @@ public class MainWindow extends TimeCalcWindow{
|
|||||||
buttonRegistry.add((TimeCalcButton)c));
|
buttonRegistry.add((TimeCalcButton)c));
|
||||||
componentRegistry.getSet().stream().filter(c ->
|
componentRegistry.getSet().stream().filter(c ->
|
||||||
GetProperty.class.isAssignableFrom(c.getClass())).forEach(c->
|
GetProperty.class.isAssignableFrom(c.getClass())).forEach(c->
|
||||||
((GetProperty<String>)c).getProperty().bindTo(timeCalcApp.visibilityProperty));
|
{
|
||||||
|
((GetProperty) c).getVisibilityProperty().bindTo(timeCalcApp.visibilityProperty);
|
||||||
|
((GetProperty) c).getVisibilitySupportedColoredProperty().bindTo(timeCalcConfiguration.visibilitySupportedColoredProperty);
|
||||||
|
});
|
||||||
|
|
||||||
componentRegistry.getSet().stream().filter(c-> c instanceof Battery).forEach(c ->
|
componentRegistry.getSet().stream().filter(c-> c instanceof Battery).forEach(c ->
|
||||||
((Battery)c).wavesProperty.bindTo(timeCalcConfiguration.batteryWavesVisibleProperty));
|
((Battery)c).wavesProperty.bindTo(timeCalcConfiguration.batteryWavesVisibleProperty));
|
||||||
|
@ -2,6 +2,7 @@ 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.entity.Visibility;
|
import org.nanoboot.utils.timecalc.entity.Visibility;
|
||||||
|
import org.nanoboot.utils.timecalc.utils.property.BooleanProperty;
|
||||||
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;
|
||||||
|
|
||||||
@ -20,6 +21,9 @@ public class TimeCalcButton extends JButton implements GetProperty {
|
|||||||
public StringProperty visibilityProperty =
|
public StringProperty visibilityProperty =
|
||||||
new StringProperty("visibilityProperty",
|
new StringProperty("visibilityProperty",
|
||||||
Visibility.STRONGLY_COLORED.name());
|
Visibility.STRONGLY_COLORED.name());
|
||||||
|
|
||||||
|
public final BooleanProperty visibilitySupportedColoredProperty =
|
||||||
|
new BooleanProperty("visibilitySupportedColoredProperty", true);
|
||||||
private Color originalBackground;
|
private Color originalBackground;
|
||||||
private Color originalForeground;
|
private Color originalForeground;
|
||||||
|
|
||||||
@ -67,7 +71,12 @@ public class TimeCalcButton extends JButton implements GetProperty {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Property getProperty() {
|
public Property getVisibilityProperty() {
|
||||||
return visibilityProperty;
|
return visibilityProperty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Property getVisibilitySupportedColoredProperty() {
|
||||||
|
return visibilitySupportedColoredProperty;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,9 @@ public class Widget extends JPanel implements
|
|||||||
Visibility.STRONGLY_COLORED.name());
|
Visibility.STRONGLY_COLORED.name());
|
||||||
public final BooleanProperty smileysColoredProperty =
|
public final BooleanProperty smileysColoredProperty =
|
||||||
new BooleanProperty("smileysColoredProperty", true);
|
new BooleanProperty("smileysColoredProperty", true);
|
||||||
|
public final BooleanProperty visibilitySupportedColoredProperty =
|
||||||
|
new BooleanProperty("visibilitySupportedColoredProperty", true);
|
||||||
|
|
||||||
protected int side = 0;
|
protected int side = 0;
|
||||||
protected double donePercent = 0;
|
protected double donePercent = 0;
|
||||||
protected boolean mouseOver = false;
|
protected boolean mouseOver = false;
|
||||||
@ -46,6 +49,10 @@ public class Widget extends JPanel implements
|
|||||||
addMouseListener(new MouseListener() {
|
addMouseListener(new MouseListener() {
|
||||||
@Override
|
@Override
|
||||||
public void mouseClicked(MouseEvent e) {
|
public void mouseClicked(MouseEvent e) {
|
||||||
|
if(visibilitySupportedColoredProperty.isDisabled()) {
|
||||||
|
//nothing to do
|
||||||
|
return;
|
||||||
|
}
|
||||||
Visibility visibility =
|
Visibility visibility =
|
||||||
Visibility.valueOf(visibilityProperty.getValue());
|
Visibility.valueOf(visibilityProperty.getValue());
|
||||||
if (visibility.isStronglyColored()) {
|
if (visibility.isStronglyColored()) {
|
||||||
@ -112,10 +119,15 @@ public class Widget extends JPanel implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Property getProperty() {
|
public Property getVisibilityProperty() {
|
||||||
return visibilityProperty;
|
return visibilityProperty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Property getVisibilitySupportedColoredProperty() {
|
||||||
|
return visibilitySupportedColoredProperty;
|
||||||
|
}
|
||||||
|
|
||||||
protected void paintSmiley(Visibility visibility, Graphics2D brush, int x, int y) {
|
protected void paintSmiley(Visibility visibility, Graphics2D brush, int x, int y) {
|
||||||
if(!mouseOver) {
|
if(!mouseOver) {
|
||||||
if(this.smileyIcon != null) {
|
if(this.smileyIcon != null) {
|
||||||
@ -164,4 +176,5 @@ public class Widget extends JPanel implements
|
|||||||
this.add(smileyIcon);
|
this.add(smileyIcon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import org.nanoboot.utils.timecalc.utils.common.Constants;
|
|||||||
import org.nanoboot.utils.timecalc.utils.common.NumberFormats;
|
import org.nanoboot.utils.timecalc.utils.common.NumberFormats;
|
||||||
import org.nanoboot.utils.timecalc.utils.common.TimeHM;
|
import org.nanoboot.utils.timecalc.utils.common.TimeHM;
|
||||||
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.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;
|
||||||
|
|
||||||
@ -35,6 +36,8 @@ public class WalkingHumanProgressAsciiArt extends JTextPane implements
|
|||||||
public StringProperty visibilityProperty =
|
public StringProperty visibilityProperty =
|
||||||
new StringProperty("visibilityProperty",
|
new StringProperty("visibilityProperty",
|
||||||
Visibility.STRONGLY_COLORED.name());
|
Visibility.STRONGLY_COLORED.name());
|
||||||
|
public final BooleanProperty visibilitySupportedColoredProperty =
|
||||||
|
new BooleanProperty("visibilitySupportedColoredProperty", true);
|
||||||
|
|
||||||
public WalkingHumanProgressAsciiArt(int x, int y, int width, int height) {
|
public WalkingHumanProgressAsciiArt(int x, int y, int width, int height) {
|
||||||
setFont(new Font(Font.MONOSPACED, Font.PLAIN, 11));
|
setFont(new Font(Font.MONOSPACED, Font.PLAIN, 11));
|
||||||
@ -45,6 +48,10 @@ public class WalkingHumanProgressAsciiArt extends JTextPane implements
|
|||||||
addMouseListener(new MouseListener() {
|
addMouseListener(new MouseListener() {
|
||||||
@Override
|
@Override
|
||||||
public void mouseClicked(MouseEvent e) {
|
public void mouseClicked(MouseEvent e) {
|
||||||
|
if(visibilitySupportedColoredProperty.isDisabled()) {
|
||||||
|
//nothing to do
|
||||||
|
return;
|
||||||
|
}
|
||||||
Visibility visibility =
|
Visibility visibility =
|
||||||
Visibility.valueOf(visibilityProperty.getValue());
|
Visibility.valueOf(visibilityProperty.getValue());
|
||||||
if (visibility.isStronglyColored()) {
|
if (visibility.isStronglyColored()) {
|
||||||
@ -198,7 +205,12 @@ public class WalkingHumanProgressAsciiArt extends JTextPane implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Property getProperty() {
|
public Property getVisibilityProperty() {
|
||||||
return visibilityProperty;
|
return visibilityProperty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Property getVisibilitySupportedColoredProperty() {
|
||||||
|
return visibilitySupportedColoredProperty;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user