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
|
||||
* @since 26.02.2024
|
||||
*/
|
||||
public interface GetProperty<T> {
|
||||
Property<T> getProperty();
|
||||
public interface GetProperty {
|
||||
Property getVisibilityProperty();
|
||||
Property getVisibilitySupportedColoredProperty();
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
|
||||
public void keyPressed(KeyEvent e) {
|
||||
boolean onlyGreyOrNone =
|
||||
timeCalcConfiguration.visibilitySupportedColoredProperty
|
||||
.isEnabled();
|
||||
.isDisabled();
|
||||
Visibility visibility = Visibility
|
||||
.valueOf(timeCalcApp.visibilityProperty.getValue());
|
||||
if (e.getKeyCode() == KeyEvent.VK_UP) {
|
||||
|
@ -74,6 +74,7 @@ public class ConfigWindow extends TimeCalcWindow {
|
||||
smileysColoredProperty));
|
||||
//
|
||||
propertiesList.stream().forEach(p -> {
|
||||
System.out.println("Found form item: " + p.getClass());
|
||||
if(p == visibilityDefaultProperty) {
|
||||
p.putClientProperty(CLIENT_PROPERTY_KEY, TimeCalcProperty.VISIBILITY_DEFAULT.getKey());
|
||||
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.Property;
|
||||
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JFrame;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
@ -34,13 +33,11 @@ import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.time.DayOfWeek;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author Robert Vokac
|
||||
@ -105,10 +102,11 @@ public class MainWindow extends TimeCalcWindow{
|
||||
addAll(configButton, workDaysButton, activitiesButton, restartButton,
|
||||
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.bindTo(timeCalcConfiguration.visibilityDefaultProperty);
|
||||
TimeCalcKeyAdapter timeCalcKeyAdapter = new TimeCalcKeyAdapter(timeCalcConfiguration, timeCalcApp, commandButton, this);
|
||||
addKeyListener(timeCalcKeyAdapter);
|
||||
|
||||
@ -296,7 +294,10 @@ public class MainWindow extends TimeCalcWindow{
|
||||
buttonRegistry.add((TimeCalcButton)c));
|
||||
componentRegistry.getSet().stream().filter(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 ->
|
||||
((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.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.StringProperty;
|
||||
|
||||
@ -20,6 +21,9 @@ public class TimeCalcButton extends JButton implements GetProperty {
|
||||
public StringProperty visibilityProperty =
|
||||
new StringProperty("visibilityProperty",
|
||||
Visibility.STRONGLY_COLORED.name());
|
||||
|
||||
public final BooleanProperty visibilitySupportedColoredProperty =
|
||||
new BooleanProperty("visibilitySupportedColoredProperty", true);
|
||||
private Color originalBackground;
|
||||
private Color originalForeground;
|
||||
|
||||
@ -67,7 +71,12 @@ public class TimeCalcButton extends JButton implements GetProperty {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Property getProperty() {
|
||||
public Property getVisibilityProperty() {
|
||||
return visibilityProperty;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Property getVisibilitySupportedColoredProperty() {
|
||||
return visibilitySupportedColoredProperty;
|
||||
}
|
||||
}
|
||||
|
@ -35,6 +35,9 @@ public class Widget extends JPanel implements
|
||||
Visibility.STRONGLY_COLORED.name());
|
||||
public final BooleanProperty smileysColoredProperty =
|
||||
new BooleanProperty("smileysColoredProperty", true);
|
||||
public final BooleanProperty visibilitySupportedColoredProperty =
|
||||
new BooleanProperty("visibilitySupportedColoredProperty", true);
|
||||
|
||||
protected int side = 0;
|
||||
protected double donePercent = 0;
|
||||
protected boolean mouseOver = false;
|
||||
@ -46,6 +49,10 @@ public class Widget extends JPanel implements
|
||||
addMouseListener(new MouseListener() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
if(visibilitySupportedColoredProperty.isDisabled()) {
|
||||
//nothing to do
|
||||
return;
|
||||
}
|
||||
Visibility visibility =
|
||||
Visibility.valueOf(visibilityProperty.getValue());
|
||||
if (visibility.isStronglyColored()) {
|
||||
@ -112,10 +119,15 @@ public class Widget extends JPanel implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public Property getProperty() {
|
||||
public Property getVisibilityProperty() {
|
||||
return visibilityProperty;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Property getVisibilitySupportedColoredProperty() {
|
||||
return visibilitySupportedColoredProperty;
|
||||
}
|
||||
|
||||
protected void paintSmiley(Visibility visibility, Graphics2D brush, int x, int y) {
|
||||
if(!mouseOver) {
|
||||
if(this.smileyIcon != null) {
|
||||
@ -164,4 +176,5 @@ public class Widget extends JPanel implements
|
||||
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.TimeHM;
|
||||
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.StringProperty;
|
||||
|
||||
@ -35,6 +36,8 @@ public class WalkingHumanProgressAsciiArt extends JTextPane implements
|
||||
public StringProperty visibilityProperty =
|
||||
new StringProperty("visibilityProperty",
|
||||
Visibility.STRONGLY_COLORED.name());
|
||||
public final BooleanProperty visibilitySupportedColoredProperty =
|
||||
new BooleanProperty("visibilitySupportedColoredProperty", true);
|
||||
|
||||
public WalkingHumanProgressAsciiArt(int x, int y, int width, int height) {
|
||||
setFont(new Font(Font.MONOSPACED, Font.PLAIN, 11));
|
||||
@ -45,6 +48,10 @@ public class WalkingHumanProgressAsciiArt extends JTextPane implements
|
||||
addMouseListener(new MouseListener() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
if(visibilitySupportedColoredProperty.isDisabled()) {
|
||||
//nothing to do
|
||||
return;
|
||||
}
|
||||
Visibility visibility =
|
||||
Visibility.valueOf(visibilityProperty.getValue());
|
||||
if (visibility.isStronglyColored()) {
|
||||
@ -198,7 +205,12 @@ public class WalkingHumanProgressAsciiArt extends JTextPane implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public Property getProperty() {
|
||||
public Property getVisibilityProperty() {
|
||||
return visibilityProperty;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Property getVisibilitySupportedColoredProperty() {
|
||||
return visibilitySupportedColoredProperty;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user