Added new improvements
This commit is contained in:
parent
01d56d794e
commit
acec2fd611
@ -1,8 +1,11 @@
|
||||
package org.nanoboot.utils.timecalc.app;
|
||||
|
||||
import org.nanoboot.utils.timecalc.utils.Constants;
|
||||
import org.nanoboot.utils.timecalc.utils.FileConstants;
|
||||
import org.nanoboot.utils.timecalc.utils.Utils;
|
||||
import org.nanoboot.utils.timecalc.entity.Visibility;
|
||||
import org.nanoboot.utils.timecalc.utils.common.Constants;
|
||||
import org.nanoboot.utils.timecalc.utils.common.FileConstants;
|
||||
import org.nanoboot.utils.timecalc.utils.property.ReadOnlyProperty;
|
||||
import org.nanoboot.utils.timecalc.utils.property.StringProperty;
|
||||
import org.nanoboot.utils.timecalc.utils.common.Utils;
|
||||
|
||||
import javax.swing.JOptionPane;
|
||||
import java.io.IOException;
|
||||
@ -14,6 +17,8 @@ import java.io.IOException;
|
||||
public class TimeCalcApp {
|
||||
|
||||
private long startNanoTime = 0l;
|
||||
private StringProperty visibilityReadWriteProperty = new StringProperty(Visibility.STRONGLY_COLORED.name());
|
||||
public ReadOnlyProperty<String> visibilityProperty = visibilityReadWriteProperty.asReadOnlyProperty();
|
||||
|
||||
public void start(String[] args) throws IOException {
|
||||
|
||||
@ -60,7 +65,7 @@ public class TimeCalcApp {
|
||||
Utils.writeTextToFile(FileConstants.OVERTIME_TXT, newOvertime);
|
||||
try {
|
||||
TimeCalcManager timeCalc =
|
||||
new TimeCalcManager(newStartTime, newOvertime);
|
||||
new TimeCalcManager(newStartTime, newOvertime, this);
|
||||
} catch (Exception e) {
|
||||
JOptionPane.showMessageDialog(null, "Error: " + e.getMessage(),
|
||||
e.getMessage(), JOptionPane.ERROR_MESSAGE);
|
||||
@ -77,10 +82,11 @@ public class TimeCalcApp {
|
||||
}
|
||||
public long getCountOfMillisecondsSinceAppStarted() {
|
||||
if(startNanoTime == 0l) {
|
||||
throw new TimeCalcException("App was not yet started.");
|
||||
throw new TimeCalcException("TimeCalcApp was not yet started.");
|
||||
}
|
||||
return System.nanoTime() - startNanoTime;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -15,11 +15,11 @@ import org.nanoboot.utils.timecalc.swing.progress.ProgressCircle;
|
||||
import org.nanoboot.utils.timecalc.swing.progress.ProgressSquare;
|
||||
import org.nanoboot.utils.timecalc.swing.progress.WalkingHumanProgressAsciiArt;
|
||||
import org.nanoboot.utils.timecalc.swing.progress.WeekBattery;
|
||||
import org.nanoboot.utils.timecalc.utils.Constants;
|
||||
import org.nanoboot.utils.timecalc.utils.DateFormats;
|
||||
import org.nanoboot.utils.timecalc.utils.Jokes;
|
||||
import org.nanoboot.utils.timecalc.utils.TimeHM;
|
||||
import org.nanoboot.utils.timecalc.utils.Utils;
|
||||
import org.nanoboot.utils.timecalc.utils.common.Constants;
|
||||
import org.nanoboot.utils.timecalc.utils.common.DateFormats;
|
||||
import org.nanoboot.utils.timecalc.utils.common.Jokes;
|
||||
import org.nanoboot.utils.timecalc.utils.common.TimeHM;
|
||||
import org.nanoboot.utils.timecalc.utils.common.Utils;
|
||||
|
||||
import javax.swing.JOptionPane;
|
||||
import java.awt.Color;
|
||||
@ -48,10 +48,12 @@ public class TimeCalcManager {
|
||||
private final TimeHM startTime;
|
||||
private final TimeHM overtime;
|
||||
private final TimeHM endTime;
|
||||
private final TimeCalcApp timeCalcApp;
|
||||
private boolean stopBeforeEnd = false;
|
||||
private boolean vtipyShown = false;
|
||||
|
||||
public TimeCalcManager(String startTimeIn, String overTimeIn) {
|
||||
public TimeCalcManager(String startTimeIn, String overTimeIn,
|
||||
TimeCalcApp timeCalcApp) {
|
||||
this.timeCalcApp = timeCalcApp;
|
||||
Utils.everythingHidden
|
||||
.setValue(TimeCalcConf.getInstance().isEverythingHidden());
|
||||
Utils.toastsAreEnabled
|
||||
@ -189,7 +191,7 @@ public class TimeCalcManager {
|
||||
break;
|
||||
case "uptime":
|
||||
JOptionPane.showMessageDialog(null,
|
||||
Utils.getCountOfMinutesSinceAppStarted()
|
||||
timeCalcApp.getCountOfMinutesSinceAppStarted()
|
||||
+ " minutes");
|
||||
break;
|
||||
case "toast":
|
||||
@ -407,10 +409,6 @@ public class TimeCalcManager {
|
||||
double totalSecondsRemainsDouble =
|
||||
((double) totalMillisecondsRemains) / 1000;
|
||||
|
||||
if (timeRemains.getHour() == 0 && timeRemains.getMinute() == 1 && !vtipyShown) {
|
||||
vtipyShown = true;
|
||||
Jokes.showRandom();
|
||||
}
|
||||
// if (timeRemains.getHour() == 0 && timeRemains.getMinute() <= 3) {
|
||||
// Utils.highlighted.set(true);
|
||||
// walkingHumanProgressAsciiArt.setForeground(Color.BLUE);
|
||||
|
@ -1,7 +1,6 @@
|
||||
package org.nanoboot.utils.timecalc.swing.common;
|
||||
|
||||
import org.nanoboot.utils.timecalc.swing.common.TimeCalcButton;
|
||||
import org.nanoboot.utils.timecalc.utils.Utils;
|
||||
import org.nanoboot.utils.timecalc.utils.common.Utils;
|
||||
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
|
@ -31,7 +31,7 @@ package org.nanoboot.utils.timecalc.swing.common;
|
||||
* }
|
||||
*/
|
||||
|
||||
import org.nanoboot.utils.timecalc.utils.Utils;
|
||||
import org.nanoboot.utils.timecalc.utils.common.Utils;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.Icon;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package org.nanoboot.utils.timecalc.swing.common;
|
||||
|
||||
import org.nanoboot.utils.timecalc.utils.Utils;
|
||||
import org.nanoboot.utils.timecalc.utils.common.Utils;
|
||||
|
||||
import javax.swing.JEditorPane;
|
||||
import javax.swing.JFrame;
|
||||
|
@ -1,12 +1,21 @@
|
||||
package org.nanoboot.utils.timecalc.swing.common;
|
||||
|
||||
import org.nanoboot.utils.timecalc.utils.Utils;
|
||||
import org.nanoboot.utils.timecalc.app.TimeCalcConf;
|
||||
import org.nanoboot.utils.timecalc.entity.Visibility;
|
||||
import org.nanoboot.utils.timecalc.utils.common.TimeHM;
|
||||
import org.nanoboot.utils.timecalc.utils.property.StringProperty;
|
||||
import org.nanoboot.utils.timecalc.utils.common.Utils;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.Timer;
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.RenderingHints;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
|
||||
/**
|
||||
* @author Robert
|
||||
@ -20,6 +29,8 @@ public class Widget extends JPanel {
|
||||
protected double donePercent = 0;
|
||||
protected boolean mouseOver = false;
|
||||
|
||||
public StringProperty visibilityProperty = new StringProperty(Visibility.STRONGLY_COLORED.name());
|
||||
|
||||
public Widget() {
|
||||
setBackground(BACKGROUND_COLOR);
|
||||
new Timer(getTimerDelay(), e -> repaint()).start();
|
||||
@ -68,4 +79,16 @@ public class Widget extends JPanel {
|
||||
public void setBounds(int x, int y, int side) {
|
||||
setBounds(x, y, side, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
Visibility visibility = Visibility.valueOf(visibilityProperty.getValue());
|
||||
this.setVisible(visibility != Visibility.NONE);
|
||||
paintWidget(g);
|
||||
|
||||
}
|
||||
|
||||
protected void paintWidget(Graphics g) {
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,11 @@
|
||||
package org.nanoboot.utils.timecalc.swing.progress;
|
||||
|
||||
import org.nanoboot.utils.timecalc.entity.Visibility;
|
||||
import org.nanoboot.utils.timecalc.swing.common.Widget;
|
||||
import org.nanoboot.utils.timecalc.app.TimeCalcConf;
|
||||
import org.nanoboot.utils.timecalc.utils.DateFormats;
|
||||
import org.nanoboot.utils.timecalc.utils.TimeHM;
|
||||
import org.nanoboot.utils.timecalc.utils.Utils;
|
||||
import org.nanoboot.utils.timecalc.utils.common.DateFormats;
|
||||
import org.nanoboot.utils.timecalc.utils.common.TimeHM;
|
||||
import org.nanoboot.utils.timecalc.utils.common.Utils;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import java.awt.BasicStroke;
|
||||
@ -75,8 +76,9 @@ public class AnalogClock extends Widget {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintComponent(Graphics g) {
|
||||
public void paintWidget(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
Visibility visibility = Visibility.valueOf(visibilityProperty.getValue());
|
||||
Graphics2D g2d = (Graphics2D) g;
|
||||
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
|
@ -3,9 +3,9 @@ package org.nanoboot.utils.timecalc.swing.progress;
|
||||
import lombok.Getter;
|
||||
import org.nanoboot.utils.timecalc.swing.common.Widget;
|
||||
import org.nanoboot.utils.timecalc.app.TimeCalcConf;
|
||||
import org.nanoboot.utils.timecalc.utils.BooleanProperty;
|
||||
import org.nanoboot.utils.timecalc.utils.NumberFormats;
|
||||
import org.nanoboot.utils.timecalc.utils.Utils;
|
||||
import org.nanoboot.utils.timecalc.utils.property.BooleanProperty;
|
||||
import org.nanoboot.utils.timecalc.utils.common.NumberFormats;
|
||||
import org.nanoboot.utils.timecalc.utils.common.Utils;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
@ -52,7 +52,7 @@ public class Battery extends Widget {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintComponent(Graphics g) {
|
||||
public void paintWidget(Graphics g) {
|
||||
if (totalHeight == 0) {
|
||||
this.totalHeight = (int) (this.getHeight() / 10d * 7d);
|
||||
this.totalWidth = this.getWidth();
|
||||
|
@ -1,6 +1,6 @@
|
||||
package org.nanoboot.utils.timecalc.swing.progress;
|
||||
|
||||
import org.nanoboot.utils.timecalc.utils.TimeHM;
|
||||
import org.nanoboot.utils.timecalc.utils.common.TimeHM;
|
||||
|
||||
/**
|
||||
* @author Robert
|
||||
|
@ -1,8 +1,8 @@
|
||||
package org.nanoboot.utils.timecalc.swing.progress;
|
||||
|
||||
import org.nanoboot.utils.timecalc.swing.common.Widget;
|
||||
import org.nanoboot.utils.timecalc.utils.NumberFormats;
|
||||
import org.nanoboot.utils.timecalc.utils.Utils;
|
||||
import org.nanoboot.utils.timecalc.utils.common.NumberFormats;
|
||||
import org.nanoboot.utils.timecalc.utils.common.Utils;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
@ -17,7 +17,7 @@ public class ProgressCircle extends Widget {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintComponent(Graphics g) {
|
||||
public void paintWidget(Graphics g) {
|
||||
if (side == 0) {
|
||||
this.side = Math.min(getWidth(), getHeight());
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
package org.nanoboot.utils.timecalc.swing.progress;
|
||||
|
||||
import org.nanoboot.utils.timecalc.swing.common.Widget;
|
||||
import org.nanoboot.utils.timecalc.utils.NumberFormats;
|
||||
import org.nanoboot.utils.timecalc.utils.Utils;
|
||||
import org.nanoboot.utils.timecalc.utils.common.NumberFormats;
|
||||
import org.nanoboot.utils.timecalc.utils.common.Utils;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
@ -19,7 +19,7 @@ public class ProgressSquare extends Widget {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintComponent(Graphics g) {
|
||||
public void paintWidget(Graphics g) {
|
||||
if (side == 0) {
|
||||
this.side = Math.min(getWidth(), getHeight());
|
||||
this.square = side * side;
|
||||
|
@ -1,10 +1,10 @@
|
||||
package org.nanoboot.utils.timecalc.swing.progress;
|
||||
|
||||
import org.nanoboot.utils.timecalc.swing.common.Toaster;
|
||||
import org.nanoboot.utils.timecalc.utils.Constants;
|
||||
import org.nanoboot.utils.timecalc.utils.NumberFormats;
|
||||
import org.nanoboot.utils.timecalc.utils.TimeHM;
|
||||
import org.nanoboot.utils.timecalc.utils.Utils;
|
||||
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 javax.imageio.ImageIO;
|
||||
import javax.swing.ImageIcon;
|
||||
|
@ -1,16 +0,0 @@
|
||||
package org.nanoboot.utils.timecalc.utils;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* @author Robert
|
||||
* @since 23.02.2024
|
||||
*/
|
||||
public class Property <T>{
|
||||
@Getter @Setter
|
||||
private T value;
|
||||
public Property(T valueIn) {
|
||||
this.value = valueIn;
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package org.nanoboot.utils.timecalc.utils.binding;
|
||||
|
||||
/**
|
||||
* @author Robert
|
||||
* @since 23.02.2024
|
||||
*/
|
||||
public class NumberBinding {
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
package org.nanoboot.utils.timecalc.utils;
|
||||
package org.nanoboot.utils.timecalc.utils.common;
|
||||
|
||||
/**
|
||||
* @author pc00289
|
||||
* @author Robert
|
||||
* @since 21.02.2024
|
||||
*/
|
||||
public class Constants {
|
@ -1,4 +1,4 @@
|
||||
package org.nanoboot.utils.timecalc.utils;
|
||||
package org.nanoboot.utils.timecalc.utils.common;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
@ -6,7 +6,7 @@ import java.time.format.DateTimeFormatter;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* @author pc00289
|
||||
* @author Robert
|
||||
* @since 21.02.2024
|
||||
*/
|
||||
public class DateFormats {
|
@ -1,9 +1,9 @@
|
||||
package org.nanoboot.utils.timecalc.utils;
|
||||
package org.nanoboot.utils.timecalc.utils.common;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* @author pc00289
|
||||
* @author Robert
|
||||
* @since 21.02.2024
|
||||
*/
|
||||
public class FileConstants {
|
@ -1,10 +1,10 @@
|
||||
package org.nanoboot.utils.timecalc.utils;
|
||||
package org.nanoboot.utils.timecalc.utils.common;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author pc00289
|
||||
* @author Robert
|
||||
* @since 16.02.2024
|
||||
*/
|
||||
public class HttpProxy {
|
@ -1,4 +1,4 @@
|
||||
package org.nanoboot.utils.timecalc.utils;
|
||||
package org.nanoboot.utils.timecalc.utils.common;
|
||||
|
||||
import org.nanoboot.utils.timecalc.swing.common.Toaster;
|
||||
import org.nanoboot.utils.timecalc.app.TimeCalcConf;
|
||||
@ -13,7 +13,7 @@ import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author pc00289
|
||||
* @author Robert
|
||||
* @since 09.02.2024
|
||||
*/
|
||||
public class Jokes {
|
@ -1,4 +1,4 @@
|
||||
package org.nanoboot.utils.timecalc.utils;
|
||||
package org.nanoboot.utils.timecalc.utils.common;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
@ -7,7 +7,7 @@ import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/**
|
||||
* @author pc00289
|
||||
* @author Robert
|
||||
* @since 15.02.2024
|
||||
*/
|
||||
public class JokesTxt {
|
@ -1,10 +1,10 @@
|
||||
package org.nanoboot.utils.timecalc.utils;
|
||||
package org.nanoboot.utils.timecalc.utils.common;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.NumberFormat;
|
||||
|
||||
/**
|
||||
* @author pc00289
|
||||
* @author Robert
|
||||
* @since 21.02.2024
|
||||
*/
|
||||
public class NumberFormats {
|
@ -1,10 +1,10 @@
|
||||
package org.nanoboot.utils.timecalc.utils;
|
||||
package org.nanoboot.utils.timecalc.utils.common;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* @author pc00289
|
||||
* @author Robert
|
||||
* @since 21.02.2024
|
||||
*/
|
||||
public class TimeHM {
|
@ -1,6 +1,7 @@
|
||||
package org.nanoboot.utils.timecalc.utils;
|
||||
package org.nanoboot.utils.timecalc.utils.common;
|
||||
|
||||
import org.nanoboot.utils.timecalc.app.Main;
|
||||
import org.nanoboot.utils.timecalc.utils.property.BooleanProperty;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.io.File;
|
||||
@ -14,7 +15,7 @@ import java.util.jar.Attributes;
|
||||
import java.util.jar.Manifest;
|
||||
|
||||
/**
|
||||
* @author pc00289
|
||||
* @author Robert
|
||||
* @since 15.02.2024
|
||||
*/
|
||||
public class Utils {
|
@ -1,4 +1,4 @@
|
||||
package org.nanoboot.utils.timecalc.utils;
|
||||
package org.nanoboot.utils.timecalc.utils.property;
|
||||
|
||||
/**
|
||||
* @author Robert
|
@ -0,0 +1,23 @@
|
||||
package org.nanoboot.utils.timecalc.utils.property;
|
||||
|
||||
/**
|
||||
* @author Robert
|
||||
* @since 16.02.2024
|
||||
*/
|
||||
public class BooleanReadOnlyProperty extends ReadOnlyProperty<Boolean> {
|
||||
|
||||
public BooleanReadOnlyProperty(Boolean valueIn) {
|
||||
super(valueIn);
|
||||
}
|
||||
public BooleanReadOnlyProperty(Property<Boolean> property) {
|
||||
super(property);
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return getValue();
|
||||
}
|
||||
public boolean isDisabled() {
|
||||
return !getValue();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
package org.nanoboot.utils.timecalc.utils.property;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.nanoboot.utils.timecalc.app.TimeCalcException;
|
||||
import org.nanoboot.utils.timecalc.utils.property.ReadOnlyProperty;
|
||||
import org.nanoboot.utils.timecalc.utils.property.WriteOnlyProperty;
|
||||
|
||||
/**
|
||||
* @author Robert
|
||||
* @since 23.02.2024
|
||||
*/
|
||||
public class Property <T>{
|
||||
private T value;
|
||||
private Property<T> boundToProperty = null;
|
||||
public Property(T valueIn) {
|
||||
this.value = valueIn;
|
||||
}
|
||||
public ReadOnlyProperty<T> asReadOnlyProperty() {
|
||||
return new ReadOnlyProperty<>(this);
|
||||
}
|
||||
public WriteOnlyProperty<T> asWriteOnlyProperty() {
|
||||
return new WriteOnlyProperty<>(this);
|
||||
}
|
||||
public boolean isBound() {
|
||||
return boundToProperty != null;
|
||||
}
|
||||
public void unBound() {
|
||||
if(!isBound()) {
|
||||
throw new TimeCalcException("No bound property");
|
||||
}
|
||||
this.value = boundToProperty.value;
|
||||
this.boundToProperty = null;
|
||||
}
|
||||
public void bindTo(Property<T> anotherProperty) {
|
||||
this.boundToProperty = anotherProperty;
|
||||
}
|
||||
public T getValue() {
|
||||
return isBound() ? this.boundToProperty.getValue() : value;
|
||||
}
|
||||
|
||||
public void setValue(T value) {
|
||||
if(isBound()) {
|
||||
throw new TimeCalcException("Cannot set value, because property is bound.");
|
||||
} else {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package org.nanoboot.utils.timecalc.utils.property;
|
||||
|
||||
import org.nanoboot.utils.timecalc.app.TimeCalcException;
|
||||
|
||||
/**
|
||||
* @author Robert
|
||||
* @since 23.02.2024
|
||||
*/
|
||||
public class PropertyWrapper <T> {
|
||||
private Property<T> innerProperty;
|
||||
|
||||
public final void unBound() {
|
||||
throw new TimeCalcException("This is a write only property. Unbounding is forbiden.");
|
||||
}
|
||||
public final void bindTo(Property<T> anotherProperty) {
|
||||
throw new TimeCalcException("This is a write only property. Bounding to another property is forbiden.");
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package org.nanoboot.utils.timecalc.utils.property;
|
||||
|
||||
import org.nanoboot.utils.timecalc.app.TimeCalcException;
|
||||
|
||||
/**
|
||||
* @author Robert
|
||||
* @since 23.02.2024
|
||||
*/
|
||||
public class ReadOnlyProperty<T> extends Property<T> {
|
||||
private Property<T> innerProperty;
|
||||
public ReadOnlyProperty(T valueIn) {
|
||||
super(valueIn);
|
||||
throw new TimeCalcException("This constructor is forbidden in class " + getClass().getName() + ".");
|
||||
}
|
||||
public ReadOnlyProperty(Property<T> property) {
|
||||
super(null);
|
||||
this.innerProperty = property;
|
||||
}
|
||||
public final void setValue(T valueIn) {
|
||||
throw new TimeCalcException("This is a read only property. New value cannot be set.");
|
||||
}
|
||||
|
||||
public final T getValue(T valueIn) {
|
||||
return innerProperty.getValue();
|
||||
}
|
||||
public final void unBound() {
|
||||
throw new TimeCalcException("This is a write only property. Unbounding is forbiden.");
|
||||
}
|
||||
public final void bindTo(Property<T> anotherProperty) {
|
||||
throw new TimeCalcException("This is a write only property. Bounding to another property is forbiden.");
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package org.nanoboot.utils.timecalc.utils.property;
|
||||
|
||||
/**
|
||||
* @author Robert
|
||||
* @since 16.02.2024
|
||||
*/
|
||||
public class StringProperty extends Property<String> {
|
||||
|
||||
public StringProperty(String valueIn) {
|
||||
super(valueIn);
|
||||
}
|
||||
|
||||
public StringProperty() {
|
||||
this("");
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package org.nanoboot.utils.timecalc.utils.property;
|
||||
|
||||
/**
|
||||
* @author Robert
|
||||
* @since 16.02.2024
|
||||
*/
|
||||
public class StringReadOnlyProperty extends ReadOnlyProperty<String> {
|
||||
|
||||
public StringReadOnlyProperty(String valueIn) {
|
||||
super(valueIn);
|
||||
}
|
||||
public StringReadOnlyProperty(Property<String> property) {
|
||||
super(property);
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package org.nanoboot.utils.timecalc.utils.property;
|
||||
|
||||
import org.nanoboot.utils.timecalc.app.TimeCalcException;
|
||||
|
||||
/**
|
||||
* @author Robert
|
||||
* @since 23.02.2024
|
||||
*/
|
||||
public class WriteOnlyProperty<T> extends Property<T> {
|
||||
private Property<T> innerProperty;
|
||||
public WriteOnlyProperty(T valueIn) {
|
||||
super(valueIn);
|
||||
throw new TimeCalcException("This constructor is forbidden in class " + getClass().getName() + ".");
|
||||
}
|
||||
public WriteOnlyProperty(Property<T> property) {
|
||||
super(null);
|
||||
this.innerProperty = property;
|
||||
}
|
||||
public final void setValue(T valueIn) {
|
||||
this.innerProperty.setValue(valueIn);
|
||||
}
|
||||
|
||||
public final T getValue(T valueIn) {
|
||||
throw new TimeCalcException("This is a write only property. Current value cannot be read.");
|
||||
}
|
||||
public final void unBound() {
|
||||
throw new TimeCalcException("This is a write only property. Unbounding is forbiden.");
|
||||
}
|
||||
public final void bindTo(Property<T> anotherProperty) {
|
||||
throw new TimeCalcException("This is a write only property. Bounding to another property is forbiden.");
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -2,4 +2,5 @@ clock.colorful=false
|
||||
clock.hands.long=true
|
||||
jokes.visible=true
|
||||
battery.waves.enabled=true
|
||||
everything-hidden=false
|
||||
everything-hidden=false
|
||||
default-visibility=STRONGLY_COLORED
|
Loading…
x
Reference in New Issue
Block a user