Added new feature - possibility to allow only the basic II

This commit is contained in:
Robert Vokac 2024-03-27 17:39:10 +01:00
parent 46cb809502
commit b391b2caf8
No known key found for this signature in database
GPG Key ID: 693D30BEE3329055
9 changed files with 194 additions and 291 deletions

View File

@ -6,6 +6,7 @@ import org.nanoboot.utils.timecalc.swing.windows.MainWindow;
import org.nanoboot.utils.timecalc.utils.common.DateFormats; import org.nanoboot.utils.timecalc.utils.common.DateFormats;
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;
import org.nanoboot.utils.timecalc.utils.property.Property;
import org.nanoboot.utils.timecalc.utils.property.ReadOnlyProperty; import org.nanoboot.utils.timecalc.utils.property.ReadOnlyProperty;
import org.nanoboot.utils.timecalc.utils.property.StringProperty; import org.nanoboot.utils.timecalc.utils.property.StringProperty;
@ -34,7 +35,8 @@ public class TimeCalcApp {
= new StringProperty("timeCalcApp.visibilityProperty", = new StringProperty("timeCalcApp.visibilityProperty",
Visibility.WEAKLY_COLORED.name()); Visibility.WEAKLY_COLORED.name());
private long startNanoTime = 0l; private long startNanoTime = 0l;
public ReadOnlyProperty<Boolean> allowOnlyBasicFeaturesProperty = new ReadOnlyProperty<>("allowOnlyBasicFeatures", false); private Property<Boolean> allowOnlyBasicFeaturesReadWriteProperty = new Property<>("allowOnlyBasicFeaturesReadWriteProperty", false);
public ReadOnlyProperty<Boolean> allowOnlyBasicFeaturesProperty = new ReadOnlyProperty<>(allowOnlyBasicFeaturesReadWriteProperty);
@Getter @Getter
private SqliteConnectionFactory sqliteConnectionFactory; private SqliteConnectionFactory sqliteConnectionFactory;
@ -58,14 +60,19 @@ public class TimeCalcApp {
e.printStackTrace(); e.printStackTrace();
} }
if(FileConstants.BASIC_TXT.exists()) { if(FileConstants.BASIC_TXT.exists()) {
allowOnlyBasicFeaturesProperty.setValue(true); allowOnlyBasicFeaturesReadWriteProperty.setValue(true);
} }
while (true) { while (true) {
if(!allowOnlyBasicFeaturesProperty.getValue() && FileConstants.BASIC_TXT.exists()) {
allowOnlyBasicFeaturesReadWriteProperty.setValue(true);
}
MainWindow timeCalcMainWindow = null; MainWindow timeCalcMainWindow = null;
try { try {
timeCalcMainWindow = new MainWindow(this); timeCalcMainWindow = new MainWindow(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);
e.printStackTrace(); e.printStackTrace();

View File

@ -18,6 +18,7 @@ import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.util.Arrays;
import java.util.Calendar; import java.util.Calendar;
import java.util.Properties; import java.util.Properties;
import lombok.Setter; import lombok.Setter;
@ -29,6 +30,10 @@ import org.nanoboot.utils.timecalc.utils.common.NumberFormats;
*/ */
public class TimeCalcKeyAdapter extends KeyAdapter { public class TimeCalcKeyAdapter extends KeyAdapter {
private static final int[] ALLOWED_KEY_CODES =
{KeyEvent.VK_R, KeyEvent.VK_X, KeyEvent.VK_W, KeyEvent.VK_A, KeyEvent.VK_Z,KeyEvent.VK_O};
private static final String EXTENDED_FEATURES_ARE_DISABLED =
"Extended features are disabled";
private final TimeCalcConfiguration timeCalcConfiguration; private final TimeCalcConfiguration timeCalcConfiguration;
private final TimeCalcApp timeCalcApp; private final TimeCalcApp timeCalcApp;
private final MainWindow mainWindow; private final MainWindow mainWindow;
@ -174,6 +179,10 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
break; break;
} }
case KeyEvent.VK_Q: { case KeyEvent.VK_Q: {
if(mainWindow.allowOnlyBasicFeaturesProperty.getValue()) {
showWarningExtendedFeaturesAreDisabled();
return;
}
double oldSpeed = this.mainWindow.getSpeed(); double oldSpeed = this.mainWindow.getSpeed();
if (oldSpeed < 0) { if (oldSpeed < 0) {
oldSpeed = 1.0d; oldSpeed = 1.0d;
@ -242,6 +251,10 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
break; break;
} }
case KeyEvent.VK_P: { case KeyEvent.VK_P: {
if(mainWindow.allowOnlyBasicFeaturesProperty.getValue()) {
showWarningExtendedFeaturesAreDisabled();
break;
}
if (increase) { if (increase) {
mainWindow.increasePause(changeTTime); mainWindow.increasePause(changeTTime);
} }
@ -268,7 +281,12 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
} }
} }
// private void processMetaKeyCodes(int keyCode) { private void showWarningExtendedFeaturesAreDisabled() {
Utils.showNotification(EXTENDED_FEATURES_ARE_DISABLED);
}
// private void processMetaKeyCodes(int keyCode) {
// //
// switch (keyCode) { // switch (keyCode) {
// case KeyEvent.VK_S: { // case KeyEvent.VK_S: {
@ -285,6 +303,10 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
private void updateProperty(IntegerProperty integerProperty, private void updateProperty(IntegerProperty integerProperty,
boolean increase, boolean decrease, boolean reset, int timeUnit, int value) { boolean increase, boolean decrease, boolean reset, int timeUnit, int value) {
if(mainWindow.allowOnlyBasicFeaturesProperty.getValue()) {
showWarningExtendedFeaturesAreDisabled();
return;
}
if (value == 0) { if (value == 0) {
//nothing to do //nothing to do
return; return;
@ -444,6 +466,12 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
"Warning: There is no profile assigned to Key with number, you pressed."); "Warning: There is no profile assigned to Key with number, you pressed.");
} }
if(mainWindow.allowOnlyBasicFeaturesProperty.getValue()) {
if(!Arrays.stream(ALLOWED_KEY_CODES).filter(k->k== keyCode).findFirst().isPresent()){
showWarningExtendedFeaturesAreDisabled();
return;
}
}
switch (keyCode) { switch (keyCode) {
case KeyEvent.VK_UP: { case KeyEvent.VK_UP: {
@ -709,13 +737,28 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
break; break;
} }
case KeyEvent.VK_O: { case KeyEvent.VK_O: {
if (timeCalcConfiguration.testEnabledProperty.isDisabled()) { if (mainWindow.allowOnlyBasicFeaturesProperty.getValue()) {
if (!Utils.askYesNo(null, "Do you really want to enable \"Test mode\"? If yes, then you will be allowed to set custom time.", "Enabling \"Test mode\"")) { Utils.showNotification("Extended features are already disabled.");
} else {
String question =
"Do you really want to disable the extended features of this application? Only the basic features will be enabled.";
if (!Utils.askYesNo(null, question, "Disabling \"Extended features\" of this app")) {
break; break;
} }
try {
FileConstants.BASIC_TXT.createNewFile();
String msg = "Warning: " + "You disabled the extended features of this application. Only the basic features are enabled. To enable the extended features, please: 1. stop this application 2. delete manually this file: " + FileConstants.BASIC_TXT.getAbsolutePath() + " 3. start this application again.";
Utils.showNotification(msg, 30000, 400);
this.mainWindow.doRestart();
} catch (IOException e) {
e.printStackTrace();
break;
}
break;
} }
timeCalcConfiguration.testEnabledProperty.flip();
Utils.showNotification((timeCalcConfiguration.testEnabledProperty.isEnabled() ? "Enabled" : "Disabled") + " \"Test mode\".");
break; break;
} }
case KeyEvent.VK_COMMA: { case KeyEvent.VK_COMMA: {
@ -735,8 +778,14 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
} }
} }
if (numberKeyWasPressed && FileConstants.TIME_CALC_PROFILES_TXT_FILE boolean profileSwitch =
.exists()) { numberKeyWasPressed && FileConstants.TIME_CALC_PROFILES_TXT_FILE
.exists();
if(profileSwitch && mainWindow.allowOnlyBasicFeaturesProperty.getValue()) {
showWarningExtendedFeaturesAreDisabled();
}
if (profileSwitch && !mainWindow.allowOnlyBasicFeaturesProperty.getValue()) {
Properties properties = new Properties(); Properties properties = new Properties();
try { try {

View File

@ -115,10 +115,10 @@ public class Toaster {
* Show a toaster with the specified message and the associated icon. * Show a toaster with the specified message and the associated icon.
*/ */
public void showToaster(Icon icon, String msg) { public void showToaster(Icon icon, String msg) {
if (notificationsVisibleProperty.isDisabled()) { // if (notificationsVisibleProperty.isDisabled()) {
//nothing to do // //nothing to do
return; // return;
} // }
SingleToaster singleToaster = new SingleToaster(); SingleToaster singleToaster = new SingleToaster();
if (icon != null) { if (icon != null) {
singleToaster.iconLabel.setIcon(icon); singleToaster.iconLabel.setIcon(icon);

View File

@ -1,239 +0,0 @@
package org.nanoboot.utils.timecalc.swing.progress.weather;
import java.util.Arrays;
/**
* @author pc00289
* @since 25.03.2024
*/
public class A {
public static void main(String[] args) {
String a = "\n"
+ " case KeyEvent.VK_UP: {\n"
+ " timeCalcApp.visibilityProperty\n"
+ " .setValue(onlyGreyOrNone ? Visibility.GRAY.name()\n"
+ " : Visibility.STRONGLY_COLORED.name());\n"
+ " break;\n"
+ " }\n"
+ "\n"
+ " case KeyEvent.VK_DOWN:\n"
+ " case KeyEvent.VK_PERIOD: {\n"
+ " timeCalcApp.visibilityProperty\n"
+ " .setValue(Visibility.NONE.name());\n"
+ " break;\n"
+ " }\n"
+ "\n"
+ " case KeyEvent.VK_G: {\n"
+ " if (visibility.isGray() && !onlyGreyOrNone) {\n"
+ " timeCalcApp.visibilityProperty\n"
+ " .setValue(Visibility.WEAKLY_COLORED.name());\n"
+ " } else {\n"
+ " timeCalcApp.visibilityProperty\n"
+ " .setValue(Visibility.GRAY.name());\n"
+ " }\n"
+ " break;\n"
+ " }\n"
+ " case KeyEvent.VK_C: {\n"
+ " if (!onlyGreyOrNone) {\n"
+ " if (visibility.isStronglyColored()) {\n"
+ " timeCalcApp.visibilityProperty\n"
+ " .setValue(Visibility.WEAKLY_COLORED.name());\n"
+ " } else {\n"
+ " timeCalcApp.visibilityProperty\n"
+ " .setValue(\n"
+ " Visibility.STRONGLY_COLORED.name());\n"
+ " }\n"
+ " } else {\n"
+ " timeCalcApp.visibilityProperty.setValue(Visibility.GRAY\n"
+ " .name());\n"
+ " }\n"
+ " break;\n"
+ " }\n"
+ " case KeyEvent.VK_V:\n"
+ "\n"
+ " case KeyEvent.VK_H: {\n"
+ " if (visibility.isNone()) {\n"
+ " timeCalcApp.visibilityProperty\n"
+ " .setValue(onlyGreyOrNone ? Visibility.GRAY.name()\n"
+ " : Visibility.STRONGLY_COLORED.name());\n"
+ " } else {\n"
+ " timeCalcApp.visibilityProperty\n"
+ " .setValue(Visibility.NONE.name());\n"
+ " }\n"
+ " break;\n"
+ " }\n"
+ " case KeyEvent.VK_SPACE: {\n"
+ " if (visibility.isStronglyColored()) {\n"
+ " timeCalcApp.visibilityProperty\n"
+ " .setValue(onlyGreyOrNone ? Visibility.GRAY.name()\n"
+ " : Visibility.WEAKLY_COLORED.name());\n"
+ " }\n"
+ " if (visibility.isWeaklyColored()) {\n"
+ " timeCalcApp.visibilityProperty\n"
+ " .setValue(Visibility.GRAY.name());\n"
+ " }\n"
+ " if (visibility.isGray()) {\n"
+ " timeCalcApp.visibilityProperty\n"
+ " .setValue(Visibility.NONE.name());\n"
+ " }\n"
+ " if (visibility.isNone()) {\n"
+ " timeCalcApp.visibilityProperty\n"
+ " .setValue(onlyGreyOrNone ? Visibility.GRAY.name()\n"
+ " : Visibility.STRONGLY_COLORED.name());\n"
+ " }\n"
+ " break;\n"
+ " }\n"
+ " case KeyEvent.VK_F2: {\n"
+ " mainWindow.doCommand();\n"
+ " break;\n"
+ " }\n"
+ " case KeyEvent.VK_R: {\n"
+ " mainWindow.doRestart();\n"
+ " break;\n"
+ " }\n"
+ " case KeyEvent.VK_N: {\n"
+ " timeCalcConfiguration.notificationsVisibleProperty.flip();\n"
+ " break;\n"
+ " }\n"
+ " case KeyEvent.VK_W: {\n"
+ " mainWindow.openWorkDaysWindow();\n"
+ " break;\n"
+ " }\n"
+ " case KeyEvent.VK_A: {\n"
+ " mainWindow.openActivitiesWindow();\n"
+ " break;\n"
+ " }\n"
+ " case KeyEvent.VK_X: {\n"
+ " mainWindow.doExit();\n"
+ " break;\n"
+ " }\n"
+ "\n"
+ " case KeyEvent.VK_S: {\n"
+ " mainWindow.openConfigWindow();\n"
+ " break;\n"
+ " }\n"
+ "\n"
+ " case KeyEvent.VK_J: {\n"
+ " if (timeCalcConfiguration.jokesVisibleProperty.isEnabled()) {\n"
+ " Jokes.showRandom();\n"
+ " break;\n"
+ " }\n"
+ "\n"
+ " }\n"
+ "\n"
+ " case KeyEvent.VK_P:\n"
+ " case KeyEvent.VK_F1: {\n"
+ " mainWindow.openHelpWindow();\n"
+ " break;\n"
+ " }\n"
+ " case KeyEvent.VK_U: {\n"
+ " mainWindow.doEnableEverything();\n"
+ " break;\n"
+ "\n"
+ " }\n"
+ " case KeyEvent.VK_I: {\n"
+ " mainWindow.doDisableAlmostEverything();\n"
+ " break;\n"
+ " }\n"
+ " case KeyEvent.VK_E: {\n"
+ " timeCalcConfiguration.batteryWavesVisibleProperty.flip();\n"
+ " break;\n"
+ " }\n"
+ "\n"
+ " case KeyEvent.VK_B: {\n"
+ " MainWindow.hideShowFormsCheckBox\n"
+ " .setSelected(!MainWindow.hideShowFormsCheckBox.isSelected());\n"
+ " break;\n"
+ " }\n"
+ " case KeyEvent.VK_F: {\n"
+ "\n"
+ " if (FileConstants.TIME_CALC_PROFILES_TXT_FILE.exists()) {\n"
+ " try {\n"
+ " Utils.showNotification(Utils.readTextFromFile(\n"
+ " FileConstants.TIME_CALC_PROFILES_TXT_FILE),\n"
+ " 15000, 200);\n"
+ " } catch (IOException ioException) {\n"
+ " ioException.printStackTrace();\n"
+ " Utils.showNotification(\n"
+ " \"Error: \" + ioException.getMessage());\n"
+ " }\n"
+ " } else {\n"
+ " Utils.showNotification(\n"
+ " \"Warning: There are no numbers assigned to profiles. Update file: \"\n"
+ " + FileConstants.TIME_CALC_PROFILES_TXT_FILE\n"
+ " .getAbsolutePath() + \".\");\n"
+ " }\n"
+ " break;\n"
+ " }\n"
+ " case KeyEvent.VK_Q: {\n"
+ " timeCalcConfiguration.squareVisibleProperty.flip();\n"
+ " break;\n"
+ " }\n"
+ " case KeyEvent.VK_L: {\n"
+ " timeCalcConfiguration.circleVisibleProperty.flip();\n"
+ " break;\n"
+ " }\n"
+ " case KeyEvent.VK_Y: {\n"
+ " timeCalcConfiguration.smileysVisibleOnlyIfMouseMovingOverProperty\n"
+ " .flip();\n"
+ " if (timeCalcConfiguration.smileysVisibleOnlyIfMouseMovingOverProperty.isDisabled() && timeCalcConfiguration.smileysVisibleProperty.isDisabled()) {\n"
+ " timeCalcConfiguration.smileysVisibleProperty.enable();\n"
+ " }\n"
+ " break;\n"
+ " }\n"
+ " case KeyEvent.VK_M: {\n"
+ " timeCalcConfiguration.walkingHumanVisibleProperty.flip();\n"
+ " break;\n"
+ " }\n"
+ " case KeyEvent.VK_LEFT: {\n"
+ " switchProfile(true, false);\n"
+ " break;\n"
+ " }\n"
+ " case KeyEvent.VK_RIGHT: {\n"
+ " switchProfile(false, true);\n"
+ " break;\n"
+ " }\n"
+ " case KeyEvent.VK_D: {\n"
+ " timeCalcConfiguration.testYearCustomProperty.setValue(Integer.MAX_VALUE);\n"
+ " timeCalcConfiguration.testMonthCustomProperty.setValue(Integer.MAX_VALUE);\n"
+ " timeCalcConfiguration.testDayCustomProperty.setValue(Integer.MAX_VALUE);\n"
+ " timeCalcConfiguration.testHourCustomProperty.setValue(Integer.MAX_VALUE);\n"
+ " timeCalcConfiguration.testMinuteCustomProperty.setValue(Integer.MAX_VALUE);\n"
+ " timeCalcConfiguration.testSecondCustomProperty.setValue(Integer.MAX_VALUE);\n"
+ " timeCalcConfiguration.testMillisecondCustomProperty.setValue(Integer.MAX_VALUE);\n"
+ " Utils.showNotification(timeCalcConfiguration.print(), 15000, 400);\n"
+ " this.mainWindow.resetSpeed();\n"
+ " break;\n"
+ " }\n"
+ "\n"
+ " case KeyEvent.VK_K: {\n"
+ " if (timeCalcConfiguration.clockVisibleProperty.isEnabled()) {\n"
+ " timeCalcConfiguration.clockVisibleProperty.disable();\n"
+ " } else {\n"
+ " timeCalcConfiguration.clockVisibleProperty.enable();\n"
+ " timeCalcConfiguration.clockHandsLongVisibleProperty.enable();\n"
+ " timeCalcConfiguration.clockHandsColoredProperty.enable();\n"
+ " timeCalcConfiguration.clockHandsHourVisibleProperty.enable();\n"
+ " timeCalcConfiguration.clockHandsMinuteVisibleProperty.enable();\n"
+ " timeCalcConfiguration.clockHandsSecondVisibleProperty.enable();\n"
+ " timeCalcConfiguration.clockHandsMillisecondVisibleProperty.enable();\n"
+ " timeCalcConfiguration.clockBorderVisibleProperty.enable();\n"
+ " timeCalcConfiguration.clockBorderOnlyHoursProperty.disable();\n"
+ " timeCalcConfiguration.clockNumbersVisibleProperty.enable();\n"
+ " timeCalcConfiguration.clockCircleVisibleProperty.enable();\n"
+ " timeCalcConfiguration.clockCircleStrongBorderProperty.disable();\n"
+ " timeCalcConfiguration.clockCircleBorderColorProperty.setValue(\"0,0,255\");\n"
+ " timeCalcConfiguration.clockCentreCircleVisibleProperty.enable();\n"
+ " timeCalcConfiguration.clockCentreCircleBlackProperty.disable();\n"
+ " timeCalcConfiguration.clockProgressVisibleOnlyIfMouseMovingOverProperty.disable();\n"
+ " timeCalcConfiguration.clockDateVisibleOnlyIfMouseMovingOverProperty.disable();\n"
+ " }\n"
+ " break;\n"
+ " }\n"
+ " case KeyEvent.VK_Z: {";
Arrays.stream(a.split("\n")).filter(l->l.contains("VK_"))
.map(l->l.replace("case KeyEvent.VK_",""))
.map(l->l.replace(": {","")).sorted()
.forEach(System.out::println);
}
}

View File

@ -0,0 +1,17 @@
package org.nanoboot.utils.timecalc.swing.progress.weather;
import java.util.Arrays;
/**
* @author pc00289
* @since 25.03.2024
*/
public class UtilityWhichKeysAreUsed {
public static void main(String[] args) {
String javaCode = "";
Arrays.stream(javaCode.split("\n")).filter(l->l.contains("VK_"))
.map(l->l.replace("case KeyEvent.VK_",""))
.map(l->l.replace(": {","")).sorted()
.forEach(System.out::println);
}
}

View File

@ -382,7 +382,7 @@ public class ConfigWindow extends TWindow {
button.addActionListener(e -> { button.addActionListener(e -> {
visibilityDefaultProperty visibilityDefaultProperty
.setSelectedItem(Visibility.STRONGLY_COLORED.name()); .setSelectedItem(Visibility.GRAY.name());
clockVisibleProperty.setSelected(true); clockVisibleProperty.setSelected(true);
clockHandsHourVisibleProperty.setSelected(enable); clockHandsHourVisibleProperty.setSelected(enable);
clockHandsMinuteVisibleProperty.setSelected(enable); clockHandsMinuteVisibleProperty.setSelected(enable);

View File

@ -70,6 +70,7 @@ import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import javax.swing.Timer; import javax.swing.Timer;
import org.nanoboot.utils.timecalc.swing.progress.ProgressDot; import org.nanoboot.utils.timecalc.swing.progress.ProgressDot;
import org.nanoboot.utils.timecalc.utils.property.ReadOnlyProperty;
/** /**
* @author Robert Vokac * @author Robert Vokac
@ -81,6 +82,8 @@ public class MainWindow extends TWindow {
public static final Color FOREGROUND_COLOR = new Color(210, 210, 210); public static final Color FOREGROUND_COLOR = new Color(210, 210, 210);
public static final JCheckBox hideShowFormsCheckBox = new JCheckBox(); public static final JCheckBox hideShowFormsCheckBox = new JCheckBox();
private static final int BATTERY_WIDTH = 140; private static final int BATTERY_WIDTH = 140;
private static final String BACKUP = "_backup";
private static final String BASIC_FEATURE__ = "__only_basic_features__";
private final TButton workDaysButton; private final TButton workDaysButton;
private final TButton activitiesButton; private final TButton activitiesButton;
private final TButton exitButton; private final TButton exitButton;
@ -123,6 +126,8 @@ public class MainWindow extends TWindow {
private double msRemaining = 0d; private double msRemaining = 0d;
private final Time timeAlwaysReal; private final Time timeAlwaysReal;
public final ReadOnlyProperty<Boolean> allowOnlyBasicFeaturesProperty;
{ {
ChangeListener valueMustBeTime ChangeListener valueMustBeTime
= (property, oldValue, newValue) -> new TTime((String) newValue); = (property, oldValue, newValue) -> new TTime((String) newValue);
@ -141,6 +146,7 @@ public class MainWindow extends TWindow {
// ToolTipManager ttm = ToolTipManager.sharedInstance(); // ToolTipManager ttm = ToolTipManager.sharedInstance();
// ttm.setInitialDelay(0); // ttm.setInitialDelay(0);
// ttm.setDismissDelay(10000); // ttm.setDismissDelay(10000);
allowOnlyBasicFeaturesProperty = timeCalcApp.allowOnlyBasicFeaturesProperty;
setFocusable(true); setFocusable(true);
setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
addWindowListener(new java.awt.event.WindowAdapter() { addWindowListener(new java.awt.event.WindowAdapter() {
@ -152,6 +158,7 @@ public class MainWindow extends TWindow {
}); });
timeCalcConfiguration timeCalcConfiguration
.loadFromTimeCalcProperties(TimeCalcProperties.getInstance()); .loadFromTimeCalcProperties(TimeCalcProperties.getInstance());
timeCalcConfiguration.mainWindowCustomTitleProperty.addListener(e -> { timeCalcConfiguration.mainWindowCustomTitleProperty.addListener(e -> {
setTitle(getWindowTitle()); setTitle(getWindowTitle());
}); });
@ -187,12 +194,45 @@ public class MainWindow extends TWindow {
} }
}); });
this.configButton = new TButton("Config"); this.configButton = new TButton("Config");
this.workDaysButton = new TButton("Work Days"); configButton.addActionListener(e -> {
this.activitiesButton = new TButton("Activities" if (configWindow == null) {
+ ""); this.configWindow = new ConfigWindow(timeCalcConfiguration);
this.restartButton = new TButton("Restart"); }
configWindow.setVisible(true);
configWindow.setLocationRelativeTo(this);
configWindow.setLocation(100, 100);
});
if(allowOnlyBasicFeaturesProperty.getValue()) {
if(!timeCalcConfiguration.profileNameProperty.getValue().equals(BASIC_FEATURE__)) {
timeCalcConfiguration.profileNameProperty.setValue(
timeCalcConfiguration.profileNameProperty.getValue()
+ BACKUP);
timeCalcConfiguration.saveToTimeCalcProperties();
timeCalcConfiguration.profileNameProperty.setValue(BASIC_FEATURE__);
timeCalcConfiguration.saveToTimeCalcProperties();
}
timeCalcConfiguration.profileNameProperty.setValue(BASIC_FEATURE__);
timeCalcConfiguration.mainWindowCustomTitleProperty.setValue("Report");
this.doDisableAlmostEverything();
//
//timeCalcConfiguration.batteryNameVisibleProperty.enable();
timeCalcConfiguration.batteryPercentProgressProperty.enable();
//timeCalcConfiguration.batteryCircleProgressProperty.enable();
//
// timeCalcConfiguration.clockHandsHourVisibleProperty.setValue(true);
// timeCalcConfiguration.clockHandsMinuteVisibleProperty.setValue(true);
timeCalcConfiguration.clockVisibleProperty.setValue(true);
// timeCalcConfiguration.clockHandsLongVisibleProperty.setValue(true);
timeCalcConfiguration.notificationsVisibleProperty.setValue(true);
//
timeCalcConfiguration.saveToTimeCalcProperties();
}
this.workDaysButton = new TButton(allowOnlyBasicFeaturesProperty.getValue() ? " " : "Work Days");
this.activitiesButton = new TButton(allowOnlyBasicFeaturesProperty.getValue() ? " " : "Activities");
this.restartButton = new TButton(allowOnlyBasicFeaturesProperty.getValue() ? " " : "Restart");
this.exitButton = new TButton("Exit"); this.exitButton = new TButton("Exit");
this.focusButton = new TButton("Focus"); this.focusButton = new TButton(allowOnlyBasicFeaturesProperty.getValue() ? " " : "Focus");
this.helpButton = new TButton("Help"); this.helpButton = new TButton("Help");
this.weatherButton = new TButton("Weather"); this.weatherButton = new TButton("Weather");
this.commandButton = new TButton("Command"); this.commandButton = new TButton("Command");
@ -200,11 +240,17 @@ public class MainWindow extends TWindow {
this.aboutButton = new AboutButton(); this.aboutButton = new AboutButton();
//window.add(weatherButton); //window.add(weatherButton);
addAll(configButton, workDaysButton, activitiesButton, restartButton, addAll(workDaysButton, activitiesButton, restartButton,focusButton);
exitButton, focusButton, helpButton, commandButton, jokeButton, if(!allowOnlyBasicFeaturesProperty.getValue()) {
hideShowFormsCheckBox); addAll(configButton, commandButton,jokeButton,helpButton,
exitButton,
hideShowFormsCheckBox);
}
if(allowOnlyBasicFeaturesProperty.getValue()) {
timeOffCheckBox.setText("");
}
timeCalcApp.visibilityProperty timeCalcApp.visibilityProperty
.bindTo(timeCalcConfiguration.visibilityDefaultProperty); .bindTo(timeCalcConfiguration.visibilityDefaultProperty);
if (!timeCalcConfiguration.visibilitySupportedColoredProperty if (!timeCalcConfiguration.visibilitySupportedColoredProperty
.isEnabled()) { .isEnabled()) {
@ -458,25 +504,27 @@ public class MainWindow extends TWindow {
timeOffCheckBox.setBoundsFromLeft(noteTextField); timeOffCheckBox.setBoundsFromLeft(noteTextField);
// //
add(arrivalTextFieldLabel); if(!allowOnlyBasicFeaturesProperty.getValue()) add(arrivalTextFieldLabel);
add(arrivalTextField); add(arrivalTextField);
add(arrivalIncreaseButton); add(arrivalIncreaseButton);
add(arrivalDecreaseButton); add(arrivalDecreaseButton);
add(overtimeTextFieldLabel); if(!allowOnlyBasicFeaturesProperty.getValue()) add(overtimeTextFieldLabel);
add(overtimeTextField); add(overtimeTextField);
add(overtimeIncreaseButton); add(overtimeIncreaseButton);
add(overtimeDecreaseButton); add(overtimeDecreaseButton);
add(workingTimeInMinutesTextFieldLabel); if(!allowOnlyBasicFeaturesProperty.getValue()) add(workingTimeInMinutesTextFieldLabel);
add(workingTimeTextField); add(workingTimeTextField);
add(workingIncreaseButton); add(workingIncreaseButton);
add(workingDecreaseButton); add(workingDecreaseButton);
add(pauseTimeInMinutesFieldLabel); if(!allowOnlyBasicFeaturesProperty.getValue()) {
add(pauseTimeTextField); add(pauseTimeInMinutesFieldLabel);
add(pauseIncreaseButton); add(pauseTimeTextField);
add(pauseDecreaseButton); add(pauseIncreaseButton);
add(pauseDecreaseButton);
}
arrivalIncreaseButton.addActionListener(e -> increaseArrival(TTime.T_TIME_ONE_MINUTE)); arrivalIncreaseButton.addActionListener(e -> increaseArrival(TTime.T_TIME_ONE_MINUTE));
arrivalDecreaseButton.addActionListener(e -> decreaseArrival(TTime.T_TIME_ONE_MINUTE)); arrivalDecreaseButton.addActionListener(e -> decreaseArrival(TTime.T_TIME_ONE_MINUTE));
@ -487,7 +535,7 @@ public class MainWindow extends TWindow {
pauseIncreaseButton.addActionListener(e -> increasePause(TTime.T_TIME_ONE_MINUTE)); pauseIncreaseButton.addActionListener(e -> increasePause(TTime.T_TIME_ONE_MINUTE));
pauseDecreaseButton.addActionListener(e -> decreasePause(TTime.T_TIME_ONE_MINUTE)); pauseDecreaseButton.addActionListener(e -> decreasePause(TTime.T_TIME_ONE_MINUTE));
add(noteTextFieldLabel); if(!allowOnlyBasicFeaturesProperty.getValue()) add(noteTextFieldLabel);
add(noteTextField); add(noteTextField);
add(timeOffCheckBox); add(timeOffCheckBox);
// //
@ -513,13 +561,17 @@ public class MainWindow extends TWindow {
saveButton.setBoundsFromLeft(remainingTextField); saveButton.setBoundsFromLeft(remainingTextField);
// //
add(departureTextFieldLabel); if(!allowOnlyBasicFeaturesProperty.getValue()) add(departureTextFieldLabel);
add(departureTextField); add(departureTextField);
add(elapsedTextFieldLabel); if(!allowOnlyBasicFeaturesProperty.getValue()) {
add(elapsedTextField); add(elapsedTextFieldLabel);
add(remainingTextFieldLabel); add(elapsedTextField);
add(remainingTextField); add(remainingTextFieldLabel);
add(saveButton); add(remainingTextField);
}
if(!allowOnlyBasicFeaturesProperty.getValue()) {
add(saveButton);
}
this.workingDayRepository = new WorkingDayRepositorySQLiteImpl(timeCalcApp.getSqliteConnectionFactory()); this.workingDayRepository = new WorkingDayRepositorySQLiteImpl(timeCalcApp.getSqliteConnectionFactory());
this.activityRepository = new ActivityRepositorySQLiteImpl(timeCalcApp.getSqliteConnectionFactory()); this.activityRepository = new ActivityRepositorySQLiteImpl(timeCalcApp.getSqliteConnectionFactory());
@ -575,26 +627,18 @@ public class MainWindow extends TWindow {
}); });
workDaysButton.addActionListener(e -> { workDaysButton.addActionListener(e -> {
if (workingDaysWindow == null) { if (workingDaysWindow == null) {
this.workingDaysWindow = new WorkingDaysWindow(workingDayRepository, time, 7d); this.workingDaysWindow = new WorkingDaysWindow(workingDayRepository, time, 7d, allowOnlyBasicFeaturesProperty.getValue());
} }
workingDaysWindow.setVisible(true); workingDaysWindow.setVisible(true);
}); });
activitiesButton.addActionListener(e -> { activitiesButton.addActionListener(e -> {
if (activitiesWindow == null) { if (activitiesWindow == null) {
this.activitiesWindow = new ActivitiesWindow(this.activityRepository, time, timeCalcConfiguration); this.activitiesWindow = new ActivitiesWindow(this.activityRepository, time,
timeCalcConfiguration);
} }
activitiesWindow.setVisible(true); activitiesWindow.setVisible(true);
}); });
configButton.addActionListener(e -> {
if (configWindow == null) {
this.configWindow = new ConfigWindow(timeCalcConfiguration);
}
configWindow.setVisible(true);
configWindow.setLocationRelativeTo(this);
configWindow.setLocation(100, 100);
});
helpButton.addActionListener(e -> { helpButton.addActionListener(e -> {
if (helpWindow == null) { if (helpWindow == null) {
this.helpWindow = new HelpWindow(); this.helpWindow = new HelpWindow();
@ -690,7 +734,8 @@ public class MainWindow extends TWindow {
.bindTo(timeCalcConfiguration.batteryLabelVisibleProperty); .bindTo(timeCalcConfiguration.batteryLabelVisibleProperty);
battery.blinkingIfCriticalLowVisibleProperty battery.blinkingIfCriticalLowVisibleProperty
.bindTo(timeCalcConfiguration.batteryQuarterIconVisibleProperty); .bindTo(timeCalcConfiguration.batteryQuarterIconVisibleProperty);
battery.quarterIconVisibleProperty.bindTo(timeCalcConfiguration.batteryQuarterIconVisibleProperty); battery.quarterIconVisibleProperty.bindTo(
timeCalcConfiguration.batteryQuarterIconVisibleProperty);
switch (battery.getName()) { switch (battery.getName()) {
case MinuteBattery.MINUTE: case MinuteBattery.MINUTE:
battery.visibleProperty battery.visibleProperty
@ -952,8 +997,28 @@ public class MainWindow extends TWindow {
}).start(); }).start();
if(allowOnlyBasicFeaturesProperty.getValue() && !FileConstants.BASIC_TXT.exists()) {
String msg =
"You deleted the file " + FileConstants.BASIC_TXT
+ ", extended features are disabled until the next stop and start of this application. Please, stop and start this application to enable extended features.";
Utils.showNotification(msg, 30000);
}
if(allowOnlyBasicFeaturesProperty.getValue()) {
String msg = "Warning: " + "You disabled the extended features of this application. Only the basic features are enabled. To enable the extended features, please: 1. stop this application 2. delete manually this file: " + FileConstants.BASIC_TXT.getAbsolutePath() + " 3. start this application again.";
Utils.showNotification(msg, 30000, 200);
}
while (true) { while (true) {
if(allowOnlyBasicFeaturesProperty.getValue()) {
if(timeCalcConfiguration.batteryDayVisibleProperty.isDisabled()) {
timeCalcConfiguration.batteryDayVisibleProperty.enable();
}
if(timeCalcConfiguration.batteryWeekVisibleProperty.isDisabled()) {
timeCalcConfiguration.batteryDayVisibleProperty.enable();
}
}
if (Math.random() > 0.99) { if (Math.random() > 0.99) {
File dbFileBackup = new File( File dbFileBackup = new File(
FileConstants.DB_FILE.getAbsolutePath() + ".backup." FileConstants.DB_FILE.getAbsolutePath() + ".backup."

View File

@ -61,6 +61,7 @@ public class WorkingDaysWindow extends TWindow {
private final TCheckBox enableMa14; private final TCheckBox enableMa14;
private final TCheckBox enableMa28; private final TCheckBox enableMa28;
private final TCheckBox enableMa56; private final TCheckBox enableMa56;
private final boolean extendedFeaturesAreDisabled;
private ArrivalChart arrivalChart; private ArrivalChart arrivalChart;
private JTable table = null; private JTable table = null;
@ -70,12 +71,12 @@ public class WorkingDaysWindow extends TWindow {
private InvalidationListener invalidationHeightListener; private InvalidationListener invalidationHeightListener;
public WorkingDaysWindow(WorkingDayRepositoryApi workingDayRepository, public WorkingDaysWindow(WorkingDayRepositoryApi workingDayRepository,
Time time, double target) { Time time, double target, boolean extendedFeaturesAreDisabled) {
setTitle("Work Days"); setTitle("Work Days");
this.workingDayRepository = workingDayRepository; this.workingDayRepository = workingDayRepository;
this.time = time; this.time = time;
this.target = target; this.target = target;
this.extendedFeaturesAreDisabled = extendedFeaturesAreDisabled;
int year = time.yearProperty.getValue(); int year = time.yearProperty.getValue();
this.setLayout(null); this.setLayout(null);
@ -530,7 +531,9 @@ public class WorkingDaysWindow extends TWindow {
this.widthProperty.addListener(invalidationWidthListener); this.widthProperty.addListener(invalidationWidthListener);
this.heightProperty.addListener(invalidationHeightListener); this.heightProperty.addListener(invalidationHeightListener);
arrivalChart.setBounds(bounds); arrivalChart.setBounds(bounds);
tp.add(arrivalChart, "Chart"); if(!extendedFeaturesAreDisabled) {
tp.add(arrivalChart, "Chart");
}
tp.switchTo(currentTitle); tp.switchTo(currentTitle);
arrivalChart.widthProperty.setValue(tp.getWidth() - 30); arrivalChart.widthProperty.setValue(tp.getWidth() - 30);
arrivalChart.heightProperty.setValue(tp.getHeight() - 10); arrivalChart.heightProperty.setValue(tp.getHeight() - 10);

View File

@ -186,6 +186,7 @@ Smileys can be colored or white-black (can be set in configuration)
* COMMA - Switch between foreward and backward speed * COMMA - Switch between foreward and backward speed
* T - Enable or disable floating speed * T - Enable or disable floating speed
* D - Reset custom time values to the real time * D - Reset custom time values to the real time
* O - Disable many features, let enable only the basic features of "Time Calc" application.
* SHIFT + A - Increase arrival time * SHIFT + A - Increase arrival time
* CTRL + A - Decrease arrival time * CTRL + A - Decrease arrival time
* SHIFT + O - Increase overtime * SHIFT + O - Increase overtime