ConfigWindow IV
This commit is contained in:
parent
1ed924fe08
commit
e1dfb42149
2
build.sh
2
build.sh
@ -56,6 +56,6 @@ echo ... 4. Moving new jar file to dist directory
|
||||
mv ./modules/time-calc-app/target/time-calc-app-$ORIG_VERSION-jar-with-all-dependencies.jar ./dist/time-calc-$VERSION.jar
|
||||
rm ./modules/time-calc-app/target/time-calc-app-$ORIG_VERSION.jar
|
||||
|
||||
cp ./dist/time-calc-$VERSION.jar C:/Users/Robert Vokac/Desktop/rv
|
||||
cp ./dist/time-calc-$VERSION.jar C:/Users/user/Desktop/rv
|
||||
|
||||
|
||||
|
@ -31,12 +31,15 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
|
||||
}
|
||||
|
||||
public void keyPressed(KeyEvent e) {
|
||||
System.out.println("Key was pressed: " + e);
|
||||
boolean onlyGreyOrNone =
|
||||
timeCalcConfiguration.visibilitySupportedColoredProperty
|
||||
.isEnabled();
|
||||
Visibility visibility = Visibility
|
||||
.valueOf(timeCalcApp.visibilityProperty.getValue());
|
||||
System.out.println("visibility=" + visibility);
|
||||
if (e.getKeyCode() == KeyEvent.VK_UP) {
|
||||
System.out.println("Key UP was pressed: " + e);
|
||||
timeCalcApp.visibilityProperty
|
||||
.setValue(onlyGreyOrNone ? Visibility.GRAY.name() :
|
||||
Visibility.STRONGLY_COLORED.name());
|
||||
@ -81,6 +84,7 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
|
||||
}
|
||||
}
|
||||
if (e.getKeyCode() == KeyEvent.VK_V) {
|
||||
System.out.println("Key V was pressed: " + e);
|
||||
if (visibility.isNone()) {
|
||||
timeCalcApp.visibilityProperty
|
||||
.setValue(onlyGreyOrNone ? Visibility.GRAY.name() :
|
||||
|
@ -2,7 +2,6 @@ package org.nanoboot.utils.timecalc.swing.common;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
import javax.swing.JComponent;
|
||||
import java.awt.Component;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
@ -34,4 +33,5 @@ public class ComponentRegistry<T extends Component> {
|
||||
c.setVisible(b);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,13 @@
|
||||
package org.nanoboot.utils.timecalc.swing.common;
|
||||
|
||||
/**
|
||||
* @author Robert Vokac
|
||||
* @since 16.02.2024
|
||||
*/
|
||||
public class HelpWindow extends TimeCalcWindow {
|
||||
|
||||
public HelpWindow() {
|
||||
setSize(800, 600);
|
||||
setTitle("Help");
|
||||
}
|
||||
}
|
@ -28,16 +28,19 @@ import org.nanoboot.utils.timecalc.utils.property.Property;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JFrame;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.io.File;
|
||||
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
|
||||
@ -47,6 +50,7 @@ public class MainWindow extends TimeCalcWindow{
|
||||
|
||||
public static final Color BACKGROUND_COLOR = new Color(238, 238, 238);
|
||||
public static final Color FOREGROUND_COLOR = new Color(210, 210, 210);
|
||||
private HelpWindow helpWindow = null;
|
||||
private WorkDaysWindow workDaysWindow = null;
|
||||
private ConfigWindow configWindow = null;
|
||||
private ActivitiesWindow activitiesWindow = null;
|
||||
@ -91,6 +95,7 @@ public class MainWindow extends TimeCalcWindow{
|
||||
TimeCalcButton restartButton = new TimeCalcButton("Restart");
|
||||
TimeCalcButton exitButton = new TimeCalcButton("Exit");
|
||||
TimeCalcButton focusButton = new TimeCalcButton("Focus");
|
||||
TimeCalcButton helpButton = new TimeCalcButton("Help");
|
||||
TimeCalcButton weatherButton = new TimeCalcButton("Weather");
|
||||
TimeCalcButton commandButton = new TimeCalcButton("Command");
|
||||
TimeCalcButton jokeButton = new TimeCalcButton("Joke");
|
||||
@ -98,7 +103,7 @@ public class MainWindow extends TimeCalcWindow{
|
||||
|
||||
//window.add(weatherButton);
|
||||
addAll(configButton, workDaysButton, activitiesButton, restartButton,
|
||||
exitButton, focusButton, commandButton, jokeButton);
|
||||
exitButton, focusButton, helpButton, commandButton, jokeButton);
|
||||
|
||||
if(timeCalcConfiguration.visibilitySupportedColoredProperty.isEnabled()) {
|
||||
timeCalcApp.visibilityProperty.setValue(Visibility.GRAY.name());
|
||||
@ -138,7 +143,9 @@ public class MainWindow extends TimeCalcWindow{
|
||||
exitButton.setBoundsFromLeft(restartButton);
|
||||
|
||||
//
|
||||
focusButton.setBoundsFromTop(exitButton);
|
||||
|
||||
helpButton.setBoundsFromTop(exitButton, 2);
|
||||
focusButton.setBoundsFromLeft(helpButton);
|
||||
commandButton.setBoundsFromLeft(focusButton);
|
||||
jokeButton.setBoundsFromLeft(commandButton);
|
||||
//
|
||||
@ -185,6 +192,13 @@ public class MainWindow extends TimeCalcWindow{
|
||||
}
|
||||
configWindow.setVisible(true);
|
||||
});
|
||||
|
||||
helpButton.addActionListener(e -> {
|
||||
if(helpWindow == null) {
|
||||
this.helpWindow = new HelpWindow();
|
||||
}
|
||||
helpWindow.setVisible(true);
|
||||
});
|
||||
Calendar calNow = Calendar.getInstance();
|
||||
calNow.setTime(new Date());
|
||||
|
||||
@ -274,25 +288,28 @@ public class MainWindow extends TimeCalcWindow{
|
||||
weekBattery.getY(), 140);
|
||||
add(monthBattery);
|
||||
|
||||
ComponentRegistry<JComponent> componentRegistry = new ComponentRegistry();
|
||||
componentRegistry.addAll(
|
||||
walkingHumanProgressAsciiArt,
|
||||
progressSquare,
|
||||
progressCircle,
|
||||
analogClock,
|
||||
dayBattery,
|
||||
weekBattery,
|
||||
monthBattery,
|
||||
hourBattery,
|
||||
configButton,
|
||||
workDaysButton,
|
||||
activitiesButton,
|
||||
restartButton,
|
||||
exitButton,
|
||||
focusButton,
|
||||
jokeButton,
|
||||
commandButton
|
||||
);
|
||||
ComponentRegistry<Component> componentRegistry = new ComponentRegistry();
|
||||
// componentRegistry.addAll(
|
||||
// walkingHumanProgressAsciiArt,
|
||||
// progressSquare,
|
||||
// progressCircle,
|
||||
// analogClock,
|
||||
// dayBattery,
|
||||
// weekBattery,
|
||||
// monthBattery,
|
||||
// hourBattery,
|
||||
// configButton,
|
||||
// workDaysButton,
|
||||
// activitiesButton,
|
||||
// restartButton,
|
||||
// exitButton,
|
||||
// helpButton,
|
||||
// focusButton,
|
||||
// jokeButton,
|
||||
// commandButton
|
||||
// );
|
||||
componentRegistry.addAll(this.getContentPane().getComponents());
|
||||
componentRegistry.getSet().stream().forEach(c-> System.out.println("Found component: " + c));
|
||||
ComponentRegistry<TimeCalcButton> buttonRegistry = new ComponentRegistry();
|
||||
componentRegistry.getSet().stream().filter(c-> c instanceof TimeCalcButton).forEach(c->
|
||||
buttonRegistry.add((TimeCalcButton)c));
|
||||
@ -318,6 +335,7 @@ public class MainWindow extends TimeCalcWindow{
|
||||
if(configWindow != null) {configWindow.setVisible(false);configWindow.dispose();}
|
||||
if(workDaysWindow != null) {workDaysWindow.setVisible(false);workDaysWindow.dispose();}
|
||||
if(activitiesWindow != null) {activitiesWindow.setVisible(false);activitiesWindow.dispose();}
|
||||
if(helpWindow != null) {helpWindow.setVisible(false);helpWindow.dispose();}
|
||||
|
||||
setVisible(false);
|
||||
dispose();
|
||||
@ -432,6 +450,7 @@ public class MainWindow extends TimeCalcWindow{
|
||||
if(configWindow != null) {configWindow.setVisible(false);configWindow.dispose();}
|
||||
if(workDaysWindow != null) {workDaysWindow.setVisible(false);workDaysWindow.dispose();}
|
||||
if(activitiesWindow != null) {activitiesWindow.setVisible(false);activitiesWindow.dispose();}
|
||||
if(helpWindow != null) {helpWindow.setVisible(false);helpWindow.dispose();}
|
||||
|
||||
setVisible(false);
|
||||
dispose();
|
||||
|
@ -56,10 +56,14 @@ public class TimeCalcButton extends JButton implements GetProperty {
|
||||
public void setBoundsFromLeft(JComponent jComponent) {
|
||||
setBounds(jComponent.getX() + jComponent.getWidth() + SwingUtils.MARGIN, jComponent.getY());
|
||||
}
|
||||
|
||||
public void setBoundsFromTop(JComponent jComponent) {
|
||||
setBoundsFromTop(jComponent, 1);
|
||||
}
|
||||
public void setBoundsFromTop(JComponent jComponent, int marginCount) {
|
||||
setBounds(SwingUtils.MARGIN, jComponent.getY()
|
||||
+ jComponent.getHeight()
|
||||
+ SwingUtils.MARGIN);
|
||||
+ marginCount * SwingUtils.MARGIN);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
x
Reference in New Issue
Block a user