diff --git a/modules/time-calc-app/nbactions.xml b/modules/time-calc-app/nbactions.xml index 7f4a765..a7cc77e 100644 --- a/modules/time-calc-app/nbactions.xml +++ b/modules/time-calc-app/nbactions.xml @@ -17,4 +17,22 @@ java + + debug + + jar + + + process-classes + org.codehaus.mojo:exec-maven-plugin:3.1.0:exec + + + -agentlib:jdwp=transport=dt_socket,server=n,address=${jpda.address} + ${exec.vmArgs} -classpath %classpath ${exec.mainClass} ${exec.appArgs} + + org.nanoboot.utils.timecalc.app.Main + java + true + + diff --git a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/app/TimeCalcConfiguration.java b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/app/TimeCalcConfiguration.java index cd02d93..d908023 100644 --- a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/app/TimeCalcConfiguration.java +++ b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/app/TimeCalcConfiguration.java @@ -27,6 +27,9 @@ public class TimeCalcConfiguration { public final BooleanProperty clockVisibleProperty = new BooleanProperty(TimeCalcProperty.CLOCK_VISIBLE .getKey()); + public final BooleanProperty clockHiddenProperty + = new BooleanProperty(TimeCalcProperty.CLOCK_HIDDEN + .getKey()); public final BooleanProperty clockHandsLongVisibleProperty = new BooleanProperty(TimeCalcProperty.CLOCK_HANDS_LONG_VISIBLE .getKey()); @@ -132,6 +135,24 @@ public class TimeCalcConfiguration { public final BooleanProperty batteryYearVisibleProperty = new BooleanProperty(TimeCalcProperty.BATTERY_YEAR_VISIBLE .getKey()); + public final BooleanProperty batteryMinuteHiddenProperty + = new BooleanProperty(TimeCalcProperty.BATTERY_MINUTE_HIDDEN + .getKey()); + public final BooleanProperty batteryHourHiddenProperty + = new BooleanProperty(TimeCalcProperty.BATTERY_HOUR_HIDDEN + .getKey()); + public final BooleanProperty batteryDayHiddenProperty + = new BooleanProperty(TimeCalcProperty.BATTERY_DAY_HIDDEN + .getKey()); + public final BooleanProperty batteryWeekHiddenProperty + = new BooleanProperty(TimeCalcProperty.BATTERY_WEEK_HIDDEN + .getKey()); + public final BooleanProperty batteryMonthHiddenProperty + = new BooleanProperty(TimeCalcProperty.BATTERY_MONTH_HIDDEN + .getKey()); + public final BooleanProperty batteryYearHiddenProperty + = new BooleanProperty(TimeCalcProperty.BATTERY_YEAR_HIDDEN + .getKey()); public final BooleanProperty batteryBlinkingIfCriticalLowVisibleProperty = new BooleanProperty( TimeCalcProperty.BATTERY_BLINKING_IF_CRITICAL_LOW @@ -160,23 +181,34 @@ public class TimeCalcConfiguration { public final BooleanProperty squareVisibleProperty = new BooleanProperty(TimeCalcProperty.SQUARE_VISIBLE.getKey()); + public final BooleanProperty squareHiddenProperty + = new BooleanProperty(TimeCalcProperty.SQUARE_HIDDEN.getKey()); public final StringProperty squareTypeProperty = new StringProperty(TimeCalcProperty.SQUARE_TYPE.getKey()); public final BooleanProperty dotVisibleProperty = new BooleanProperty(TimeCalcProperty.DOT_VISIBLE.getKey()); + public final BooleanProperty dotHiddenProperty + = new BooleanProperty(TimeCalcProperty.DOT_HIDDEN.getKey()); public final StringProperty dotTypeProperty = new StringProperty(TimeCalcProperty.DOT_TYPE.getKey()); public final BooleanProperty circleVisibleProperty = new BooleanProperty(TimeCalcProperty.CIRCLE_VISIBLE.getKey()); + public final BooleanProperty circleHiddenProperty + = new BooleanProperty(TimeCalcProperty.CIRCLE_HIDDEN.getKey()); public final StringProperty circleTypeProperty = new StringProperty(TimeCalcProperty.CIRCLE_TYPE.getKey()); public final BooleanProperty walkingHumanVisibleProperty = new BooleanProperty( TimeCalcProperty.WALKING_HUMAN_VISIBLE.getKey()); + public final BooleanProperty walkingHumanHiddenProperty + = new BooleanProperty( + TimeCalcProperty.WALKING_HUMAN_HIDDEN.getKey()); public final StringProperty walkingHumanTypeProperty = new StringProperty(TimeCalcProperty.WALKING_HUMAN_TYPE.getKey()); public final BooleanProperty swingVisibleProperty = new BooleanProperty(TimeCalcProperty.SWING_VISIBLE.getKey()); + public final BooleanProperty swingHiddenProperty + = new BooleanProperty(TimeCalcProperty.SWING_HIDDEN.getKey()); public final StringProperty swingTypeProperty = new StringProperty(TimeCalcProperty.SWING_TYPE.getKey()); public final BooleanProperty swingQuarterIconVisibleProperty @@ -184,12 +216,16 @@ public class TimeCalcConfiguration { public final BooleanProperty lifeVisibleProperty = new BooleanProperty(TimeCalcProperty.LIFE_VISIBLE.getKey()); + public final BooleanProperty lifeHiddenProperty + = new BooleanProperty(TimeCalcProperty.LIFE_HIDDEN.getKey()); public final StringProperty lifeTypeProperty = new StringProperty(TimeCalcProperty.LIFE_TYPE.getKey()); public final StringProperty lifeBirthDateProperty = new StringProperty(TimeCalcProperty.LIFE_BIRTH_DATE.getKey()); public final BooleanProperty moneyVisibleProperty = new BooleanProperty(TimeCalcProperty.MONEY_VISIBLE.getKey()); + public final BooleanProperty moneyHiddenProperty + = new BooleanProperty(TimeCalcProperty.MONEY_HIDDEN.getKey()); public final StringProperty moneyTypeProperty = new StringProperty(TimeCalcProperty.MONEY_TYPE.getKey()); public final IntegerProperty moneyPerMonthProperty @@ -198,6 +234,8 @@ public class TimeCalcConfiguration { = new StringProperty(TimeCalcProperty.MONEY_CURRENCY.getKey()); public final BooleanProperty weatherVisibleProperty = new BooleanProperty(TimeCalcProperty.WEATHER_VISIBLE.getKey()); + public final BooleanProperty weatherHiddenProperty + = new BooleanProperty(TimeCalcProperty.WEATHER_HIDDEN.getKey()); public final StringProperty mainWindowCustomTitleProperty = new StringProperty( TimeCalcProperty.MAIN_WINDOW_CUSTOM_TITLE.getKey()); @@ -299,6 +337,21 @@ public class TimeCalcConfiguration { profileNameProperty, activityNeededFlagsProperty, speedProperty, + clockHiddenProperty, + batteryMinuteHiddenProperty, + batteryHourHiddenProperty, + batteryDayHiddenProperty, + batteryWeekHiddenProperty, + batteryMonthHiddenProperty, + batteryYearHiddenProperty, + squareHiddenProperty, + circleHiddenProperty, + walkingHumanHiddenProperty, + swingHiddenProperty, + lifeHiddenProperty, + moneyHiddenProperty, + weatherHiddenProperty, + dotHiddenProperty, testEnabledProperty, testYearCustomProperty, testMonthCustomProperty, diff --git a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/app/TimeCalcProperty.java b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/app/TimeCalcProperty.java index 0fb7c09..d6a9f66 100644 --- a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/app/TimeCalcProperty.java +++ b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/app/TimeCalcProperty.java @@ -51,6 +51,7 @@ public enum TimeCalcProperty { CLOCK_SMILEY_VISIBLE("clock.smiley.visible","Clock : Smiley : Visible"), CLOCK_PERCENT_PROGRESS_VISIBLE("clock.percent-progress.visible","Clock : Percent progress : Visible"), CLOCK_CIRCLE_PROGRESS_VISIBLE("clock.circle-progress.visible", "Clock : Circle Progress"), + CLOCK_HIDDEN("clock.hidden", "Clock : Hidden"), // BATTERY_WAVES_VISIBLE("battery.waves.visible", "Battery : Waves"), BATTERY_CIRCLE_PROGRESS_VISIBLE("battery.circle-progress.visible", @@ -68,6 +69,12 @@ public enum TimeCalcProperty { BATTERY_WEEK_VISIBLE("battery.week.visible", "Battery : Week"), BATTERY_MONTH_VISIBLE("battery.month.visible", "Battery : Month"), BATTERY_YEAR_VISIBLE("battery.year.visible", "Battery : Year"), + BATTERY_MINUTE_HIDDEN("battery.minute.hidden", "Battery : Minute : Hidden"), + BATTERY_HOUR_HIDDEN("battery.hour.hidden", "Battery : Hour : Hidden"), + BATTERY_DAY_HIDDEN("battery.day.hidden", "Battery : Day : Hidden"), + BATTERY_WEEK_HIDDEN("battery.week.hidden", "Battery : Week : Hidden"), + BATTERY_MONTH_HIDDEN("battery.month.hidden", "Battery : Month : Hidden"), + BATTERY_YEAR_HIDDEN("battery.year.hidden", "Battery : Year : Hidden"), BATTERY_BLINKING_IF_CRITICAL_LOW("battery.blinking-if-critical-low", "Battery : Blinking, if critical low"), BATTERY_QUARTER_ICON_VISIBLE("battery.quarter-icon.visible", "Battery : Quarter icon"), @@ -81,23 +88,31 @@ public enum TimeCalcProperty { SMILEYS_COLORED("smileys.colored", "Smileys : Colored"), SQUARE_VISIBLE("square.visible", "Square"), SQUARE_TYPE("square.type", "Square : Type"), + SQUARE_HIDDEN("square.hidden", "Square : Hidden"), DOT_VISIBLE("dot.visible", "Dot"), DOT_TYPE("dot.type", "Dot : Type"), + DOT_HIDDEN("dot.hidden", "Dot : Hidden"), CIRCLE_VISIBLE("circle.visible", "Circle"), CIRCLE_TYPE("circle.type", "Circle : Type"), + CIRCLE_HIDDEN("circle.hidden", "Circle : Hidden"), WALKING_HUMAN_VISIBLE("walking-human.visible", "Walking Human"), WALKING_HUMAN_TYPE("walking-human.type", "Walking Human : Type"), + WALKING_HUMAN_HIDDEN("walking-human.hidden", "Walking Human : Hidden"), SWING_VISIBLE("swing.visible", "Swing"), SWING_TYPE("swing.type", "Swing : Type"), + SWING_HIDDEN("swing.hidden", "Swing : Hidden"), SWING_QUARTER_ICON_VISIBLE("swing.quarter-icon.visible", "Swing: Quarter icon"), LIFE_VISIBLE("life.visible", "Life"), LIFE_TYPE("life.type", "Life : Type"), + LIFE_HIDDEN("life.hidden", "Life : Hidden"), LIFE_BIRTH_DATE("life.birth-date", "Life : Birth date"), MONEY_VISIBLE("money.visible", "Money"), MONEY_TYPE("money.type", "Money : Type"), + MONEY_HIDDEN("money.hidden", "Money : Hidden"), MONEY_PER_MONTH("money.per-month", "Money : Per month", Integer.class), MONEY_CURRENCY("money.currency", "Money : Currency", String.class), WEATHER_VISIBLE("weather.visible", "Weather"), + WEATHER_HIDDEN("weather.hidden", "Weather : Hidden"), MAIN_WINDOW_CUSTOM_TITLE("main-window.custom-title","Main Window : Custom Title"), PROFILE_NAME("profile.name", "Profile : Name"), TEST_ENABLED("test.enabled", "Test : Enabled", Boolean.class), diff --git a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/common/Widget.java b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/common/Widget.java index 9d83cb8..511eb12 100644 --- a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/common/Widget.java +++ b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/common/Widget.java @@ -16,7 +16,6 @@ import org.nanoboot.utils.timecalc.utils.property.StringProperty; import javax.swing.ImageIcon; import javax.swing.JLabel; -import javax.swing.JMenu; import javax.swing.JPanel; import javax.swing.Timer; import java.awt.BasicStroke; @@ -88,8 +87,8 @@ public class Widget extends JPanel implements private static final Color PURPLE_STRONGLY_COLORED = new Color(153,51,255); private static final Color PURPLE_WEAKLY_COLORED = new Color(204,153,255); - @Getter - private boolean hidden; + public final BooleanProperty hiddenProperty + = new BooleanProperty("hiddenProperty", false); private WidgetMenu widgetMenu = null; public Widget() { @@ -117,8 +116,8 @@ public class Widget extends JPanel implements addMouseListener(new MouseListener() { @Override public void mouseClicked(MouseEvent e) { - if(hidden) { - hidden = false; + if(hiddenProperty.isEnabled()) { + hiddenProperty.disable(); } if (mouseOverCloseButton) { @@ -127,7 +126,7 @@ public class Widget extends JPanel implements } if(mouseOverMinimizeButton) { - hidden = true; + hiddenProperty.enable(); return; } @@ -245,8 +244,8 @@ public class Widget extends JPanel implements Visibility visibility = Visibility.valueOf(visibilityProperty.getValue()); - if (visibleProperty.isDisabled() || hidden) { - if(hidden) { + if (visibleProperty.isDisabled() || hiddenProperty.isEnabled()) { + if(hiddenProperty.isEnabled()) { if(this.smileyIcon != null) { this.remove(this.smileyIcon); this.smileyIcon = null; @@ -261,7 +260,22 @@ public class Widget extends JPanel implements brush.fillRect(1, 1, getWidth() - 2, getHeight() - 2); brush.setColor(currentColor); } - brush.drawString("Show", (int) (getWidth() * 0.5 - 10), (int) (getHeight() * 0.5 - 10)); + if(!visibility.isStronglyColored()) { + brush.setColor(Color.LIGHT_GRAY); + } + int row = 10; + int x = (int)(getWidth() > 100 ? (int) (getWidth() * 0.4) : (int) (getWidth() * 0.1)); + brush.drawString("Show", x, row); + row = row + 20; + String[] nameArray = getHumanName().split(" "); + for(int i = 0; i< nameArray.length; i++) { + brush.drawString( + nameArray[i], + x + , row); + row = row + 12; + } + } //nothing to do return; @@ -563,6 +577,21 @@ public class Widget extends JPanel implements } public void hideWidget() { - this.hidden = true; + this.hiddenProperty.enable(); + } + + private String getHumanName() { + String name = getClass().getSimpleName(); + StringBuilder sb = new StringBuilder(); + for (char ch : name.toCharArray()) { + if (Character.isUpperCase(ch)) { + sb.append(' ').append(Character.toLowerCase(ch)); + } else { + sb.append(ch); + } + + } + String result = sb.toString().trim(); + return result.substring(0, 1).toUpperCase() + result.substring(1, result.length()); } } diff --git a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/windows/ConfigWindow.java b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/windows/ConfigWindow.java index afc4eec..c9549ae 100644 --- a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/windows/ConfigWindow.java +++ b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/windows/ConfigWindow.java @@ -69,8 +69,8 @@ public class ConfigWindow extends TWindow { private final JPanel panelInsideScrollPaneSmileys; private final JPanel panelInsideScrollPaneTest; private final JPanel panelInsideScrollPaneOther; - private final int[] currentY = new int[]{SwingUtils.MARGIN,SwingUtils.MARGIN,SwingUtils.MARGIN,SwingUtils.MARGIN,SwingUtils.MARGIN,SwingUtils.MARGIN,SwingUtils.MARGIN}; - private final int[] currentX = new int[]{SwingUtils.MARGIN,SwingUtils.MARGIN,SwingUtils.MARGIN,SwingUtils.MARGIN,SwingUtils.MARGIN,SwingUtils.MARGIN,SwingUtils.MARGIN}; + private final int[] currentY = new int[]{SwingUtils.MARGIN, SwingUtils.MARGIN, SwingUtils.MARGIN, SwingUtils.MARGIN, SwingUtils.MARGIN, SwingUtils.MARGIN, SwingUtils.MARGIN}; + private final int[] currentX = new int[]{SwingUtils.MARGIN, SwingUtils.MARGIN, SwingUtils.MARGIN, SwingUtils.MARGIN, SwingUtils.MARGIN, SwingUtils.MARGIN, SwingUtils.MARGIN}; private final List propertiesList = new ArrayList<>(); private final Map propertiesMap = new HashMap<>(); private final TButton enableAsMuchAsPossible @@ -122,16 +122,16 @@ public class ConfigWindow extends TWindow { .getKey()); private final JCheckBox clockSmileyVisibleProperty = new JCheckBox( - TimeCalcProperty.CLOCK_SMILEY_VISIBLE - .getKey()); + TimeCalcProperty.CLOCK_SMILEY_VISIBLE + .getKey()); private final JCheckBox clockPercentProgressVisibleProperty = new JCheckBox( - TimeCalcProperty.CLOCK_PERCENT_PROGRESS_VISIBLE - .getKey()); + TimeCalcProperty.CLOCK_PERCENT_PROGRESS_VISIBLE + .getKey()); private final JCheckBox clockCircleProgressVisibleProperty = new JCheckBox( - TimeCalcProperty.CLOCK_CIRCLE_PROGRESS_VISIBLE - .getKey()); + TimeCalcProperty.CLOCK_CIRCLE_PROGRESS_VISIBLE + .getKey()); // private final JCheckBox batteryWavesVisibleProperty = new JCheckBox(TimeCalcProperty.BATTERY_WAVES_VISIBLE.getKey()); @@ -167,7 +167,7 @@ public class ConfigWindow extends TWindow { TimeCalcProperty.BATTERY_BLINKING_IF_CRITICAL_LOW.getKey()); private final JCheckBox batteryQuarterIconVisibleProperty = new JCheckBox( - TimeCalcProperty.BATTERY_QUARTER_ICON_VISIBLE.getKey()); + TimeCalcProperty.BATTERY_QUARTER_ICON_VISIBLE.getKey()); private final JCheckBox jokesVisibleProperty = new JCheckBox(TimeCalcProperty.JOKES_VISIBLE.getKey()); private final JCheckBox commandsVisibleProperty @@ -228,6 +228,40 @@ public class ConfigWindow extends TWindow { = new JTextField(TimeCalcProperty.ACTIVITY_NEEDED_FLAGS.getKey()); public final JTextField speedProperty = new JTextField(TimeCalcProperty.SPEED.getKey()); + + // + public final JCheckBox clockHiddenProperty + = new JCheckBox(TimeCalcProperty.CLOCK_HIDDEN.getKey()); + public final JCheckBox batteryMinuteHiddenProperty + = new JCheckBox(TimeCalcProperty.BATTERY_MINUTE_HIDDEN.getKey()); + public final JCheckBox batteryHourHiddenProperty + = new JCheckBox(TimeCalcProperty.BATTERY_HOUR_HIDDEN.getKey()); + public final JCheckBox batteryDayHiddenProperty + = new JCheckBox(TimeCalcProperty.BATTERY_DAY_HIDDEN.getKey()); + public final JCheckBox batteryWeekHiddenProperty + = new JCheckBox(TimeCalcProperty.BATTERY_WEEK_HIDDEN.getKey()); + public final JCheckBox batteryMonthHiddenProperty + = new JCheckBox(TimeCalcProperty.BATTERY_MONTH_HIDDEN.getKey()); + public final JCheckBox batteryYearHiddenProperty + = new JCheckBox(TimeCalcProperty.BATTERY_YEAR_HIDDEN.getKey()); + public final JCheckBox squareHiddenProperty + = new JCheckBox(TimeCalcProperty.SQUARE_HIDDEN.getKey()); + public final JCheckBox circleHiddenProperty + = new JCheckBox(TimeCalcProperty.CIRCLE_HIDDEN.getKey()); + public final JCheckBox walkingHumanHiddenProperty + = new JCheckBox(TimeCalcProperty.WALKING_HUMAN_HIDDEN.getKey()); + public final JCheckBox swingHiddenProperty + = new JCheckBox(TimeCalcProperty.SWING_HIDDEN.getKey()); + public final JCheckBox lifeHiddenProperty + = new JCheckBox(TimeCalcProperty.LIFE_HIDDEN.getKey()); + public final JCheckBox moneyHiddenProperty + = new JCheckBox(TimeCalcProperty.MONEY_HIDDEN.getKey()); + public final JCheckBox weatherHiddenProperty + = new JCheckBox(TimeCalcProperty.WEATHER_HIDDEN.getKey()); + public final JCheckBox dotHiddenProperty + = new JCheckBox(TimeCalcProperty.DOT_HIDDEN.getKey()); + + // private final JCheckBox testEnabledProperty = new JCheckBox(TimeCalcProperty.TEST_ENABLED.getKey()); private final JTextField testClockCustomYearProperty @@ -245,7 +279,7 @@ public class ConfigWindow extends TWindow { private final JTextField testClockCustomMillisecondProperty = new JTextField(TimeCalcProperty.TEST_CLOCK_CUSTOM_MILLISECOND.getKey()); private final TTabbedPane tp; - + public ConfigWindow(TimeCalcConfiguration timeCalcConfiguration) { this.timeCalcConfiguration = timeCalcConfiguration; setTitle("Configuration"); @@ -263,7 +297,7 @@ public class ConfigWindow extends TWindow { this.panelInsideScrollPaneSmileys = new JPanel(); this.panelInsideScrollPaneTest = new JPanel(); this.panelInsideScrollPaneOther = new JPanel(); - + List panelsInsideScrollPane = Stream.of( panelInsideScrollPaneClock, panelInsideScrollPaneBattery, @@ -272,7 +306,7 @@ public class ConfigWindow extends TWindow { panelInsideScrollPaneSmileys, panelInsideScrollPaneTest, panelInsideScrollPaneOther).collect(Collectors.toList()); - panelsInsideScrollPane.forEach(p-> { + panelsInsideScrollPane.forEach(p -> { final BoxLayout boxLayout = new BoxLayout(p, BoxLayout.Y_AXIS); p.setLayout(boxLayout); p.setAlignmentX(LEFT_ALIGNMENT); @@ -284,7 +318,6 @@ public class ConfigWindow extends TWindow { //mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS)); mainPanel.setAlignmentX(LEFT_ALIGNMENT); - JScrollPane scrollPaneClock = new JScrollPane(panelInsideScrollPaneClock); JScrollPane scrollPaneBattery = new JScrollPane(panelInsideScrollPaneBattery); JScrollPane scrollPaneLife = new JScrollPane(panelInsideScrollPaneLife); @@ -292,8 +325,8 @@ public class ConfigWindow extends TWindow { JScrollPane scrollPaneSmileys = new JScrollPane(panelInsideScrollPaneSmileys); JScrollPane scrollPaneTest = new JScrollPane(panelInsideScrollPaneTest); JScrollPane scrollPaneOther = new JScrollPane(panelInsideScrollPaneOther); - - List scrollPanes = Stream.of( + + List scrollPanes = Stream.of( scrollPaneClock, scrollPaneBattery, scrollPaneLife, @@ -301,8 +334,8 @@ public class ConfigWindow extends TWindow { scrollPaneSmileys, scrollPaneTest, scrollPaneOther - ).collect(Collectors.toList()); - + ).collect(Collectors.toList()); + tp.add("Clock", scrollPaneClock); tp.add("Battery", scrollPaneBattery); tp.add("Life", scrollPaneLife); @@ -310,8 +343,8 @@ public class ConfigWindow extends TWindow { tp.add("Smileys", scrollPaneSmileys); tp.add("Test", scrollPaneTest); tp.add("Other", scrollPaneOther); - scrollPanes.forEach(s-> - { + scrollPanes.forEach(s + -> { s.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); s.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); s.setPreferredSize( @@ -335,7 +368,7 @@ public class ConfigWindow extends TWindow { .getWidth() + SwingUtils.MARGIN, SwingUtils.MARGIN, 250, HEIGHT1); - scrollPanes.stream().forEach(s->s.setBounds(10, 10, Integer.MAX_VALUE,Integer.MAX_VALUE)); + scrollPanes.stream().forEach(s -> s.setBounds(10, 10, Integer.MAX_VALUE, Integer.MAX_VALUE)); mainPanel.add(tp); @@ -405,12 +438,28 @@ public class ConfigWindow extends TWindow { swingVisibleProperty.setSelected(enable); swingQuarterIconVisibleProperty.setSelected(enable); walkingHumanVisibleProperty.setSelected(enable); + clockHiddenProperty.setSelected(!enable); + batteryMinuteHiddenProperty.setSelected(!enable); + batteryHourHiddenProperty.setSelected(!enable); + batteryDayHiddenProperty.setSelected(!enable); + batteryWeekHiddenProperty.setSelected(!enable); + batteryMonthHiddenProperty.setSelected(!enable); + batteryYearHiddenProperty.setSelected(!enable); + squareHiddenProperty.setSelected(!enable); + circleHiddenProperty.setSelected(!enable); + walkingHumanHiddenProperty.setSelected(!enable); + swingHiddenProperty.setSelected(!enable); + lifeHiddenProperty.setSelected(!enable); + moneyHiddenProperty.setSelected(!enable); + weatherHiddenProperty.setSelected(!enable); + dotHiddenProperty.setSelected(!enable); MainWindow.hideShowFormsCheckBox.setSelected(enable); }); } propertiesList.addAll(Arrays.asList( clockVisibleProperty, + clockHiddenProperty, clockHandsHourVisibleProperty, clockHandsMinuteVisibleProperty, clockHandsSecondVisibleProperty, @@ -443,6 +492,12 @@ public class ConfigWindow extends TWindow { batteryWeekVisibleProperty, batteryMonthVisibleProperty, batteryYearVisibleProperty, + batteryMinuteHiddenProperty, + batteryHourHiddenProperty, + batteryDayHiddenProperty, + batteryWeekHiddenProperty, + batteryMonthHiddenProperty, + batteryYearHiddenProperty, batteryBlinkingIfCriticalLowVisibleProperty, batteryQuarterIconVisibleProperty, // @@ -461,24 +516,32 @@ public class ConfigWindow extends TWindow { commandsVisibleProperty, notificationsVisibleProperty, squareVisibleProperty, + squareHiddenProperty, squareTypeProperty, dotVisibleProperty, + dotHiddenProperty, dotTypeProperty, circleVisibleProperty, + circleHiddenProperty, circleTypeProperty, swingVisibleProperty, + swingHiddenProperty, swingTypeProperty, swingQuarterIconVisibleProperty, walkingHumanVisibleProperty, + walkingHumanHiddenProperty, walkingHumanTypeProperty, lifeVisibleProperty, + lifeHiddenProperty, lifeTypeProperty, lifeBirthDateProperty, moneyVisibleProperty, + moneyHiddenProperty, moneyTypeProperty, moneyPerMonthProperty, moneyCurrencyProperty, weatherVisibleProperty, + weatherHiddenProperty, mainWindowCustomTitleProperty, profileNameProperty, activityNeededFlagsProperty, @@ -704,7 +767,7 @@ public class ConfigWindow extends TWindow { String timeCalcPropertyKey = (String) textField.getClientProperty( CLIENT_PROPERTY_KEY); - if(timeCalcPropertyKey == null) { + if (timeCalcPropertyKey == null) { timeCalcPropertyKey = textField.getText(); textField.putClientProperty(CLIENT_PROPERTY_KEY, timeCalcPropertyKey); } @@ -712,9 +775,6 @@ public class ConfigWindow extends TWindow { = TimeCalcProperty.forKey(timeCalcPropertyKey); boolean isInteger = Integer.class == timeCalcProperty.getClazz(); - - - { textField.setEditable(false); textField.setBackground(Color.WHITE); @@ -723,8 +783,8 @@ public class ConfigWindow extends TWindow { textField .addMouseListener((MouseClickedListener) f -> { - String result = - (String) JOptionPane.showInputDialog( + String result + = (String) JOptionPane.showInputDialog( null, "Select new value", "New value", @@ -735,15 +795,15 @@ public class ConfigWindow extends TWindow { .getText() ); if (result != null) { - if(timeCalcProperty.name().contains("TYPE")) { + if (timeCalcProperty.name().contains("TYPE")) { try { - WidgetType widgetType = - WidgetType.valueOf(result.toUpperCase( + WidgetType widgetType + = WidgetType.valueOf(result.toUpperCase( Locale.ROOT)); } catch (Exception e) { throw new TimeCalcException("Invalid format. Only these values are allowed: " + Arrays .stream(WidgetType.values()).map(WidgetType::name).map(String::toLowerCase).collect( - Collectors.joining(", "))); + Collectors.joining(", "))); } } textField.setText(result); @@ -755,7 +815,7 @@ public class ConfigWindow extends TWindow { timeCalcConfiguration .getProperty(timeCalcProperty).addListener(e -> { - textField.setText(isInteger + textField.setText(isInteger ? String.valueOf(timeCalcConfiguration .getProperty(timeCalcProperty).getValue()) : (String) timeCalcConfiguration @@ -780,7 +840,7 @@ public class ConfigWindow extends TWindow { } private void update(DocumentEvent e) { - if(textField.getClientProperty(EDITABLE_ONLY_IN_DIALOG) != null) { + if (textField.getClientProperty(EDITABLE_ONLY_IN_DIALOG) != null) { return; } String text = textField.getText(); @@ -858,51 +918,76 @@ public class ConfigWindow extends TWindow { private void addToNextRow(JComponent jComponent) { addToNextRow(jComponent, true); } + private void addToNextRow(JComponent jComponent, boolean nextRow) { int index = 6; String key = (String) jComponent.getClientProperty(CLIENT_PROPERTY_KEY); - if(key == null) { + if (key == null) { //nothing to do return; } - if(key.startsWith("clock")) index = 0; - if(key.startsWith("battery")) index = 1; - if(key.startsWith("life")) index = 2; - if(key.startsWith("money")) index = 3; - if(key.startsWith("smileys")) index = 4; - if(key.startsWith("test")) index = 5; - - JPanel panel = null; - switch(index) { - case 0: panel=panelInsideScrollPaneClock;break; - case 1: panel=panelInsideScrollPaneBattery;break; - case 2: panel=panelInsideScrollPaneLife;break; - case 3: panel=panelInsideScrollPaneMoney;break; - case 4: panel=panelInsideScrollPaneSmileys;break; - case 5: panel=panelInsideScrollPaneTest;break; - default:panel= panelInsideScrollPaneOther; + if (key.startsWith("clock")) { + index = 0; } - if(jComponent instanceof JTextField) { + if (key.startsWith("battery")) { + index = 1; + } + if (key.startsWith("life")) { + index = 2; + } + if (key.startsWith("money")) { + index = 3; + } + if (key.startsWith("smileys")) { + index = 4; + } + if (key.startsWith("test")) { + index = 5; + } + + JPanel panel = null; + switch (index) { + case 0: + panel = panelInsideScrollPaneClock; + break; + case 1: + panel = panelInsideScrollPaneBattery; + break; + case 2: + panel = panelInsideScrollPaneLife; + break; + case 3: + panel = panelInsideScrollPaneMoney; + break; + case 4: + panel = panelInsideScrollPaneSmileys; + break; + case 5: + panel = panelInsideScrollPaneTest; + break; + default: + panel = panelInsideScrollPaneOther; + } + if (jComponent instanceof JTextField) { JPanel p = new JPanel(); //p.setLayout(null); JLabel label = new JLabel(TimeCalcProperty.forKey(key).getDescription() + ": "); p.add(label); p.add(jComponent); - label.setBounds(10,0, 200, 25); + label.setBounds(10, 0, 200, 25); jComponent.setBounds(220, 0, 200, 25); LayoutManager flowLayout = new FlowLayout(FlowLayout.LEFT); p.setLayout(flowLayout); p.setAlignmentX(LEFT_ALIGNMENT); - label.setPreferredSize(new Dimension(key.startsWith("test.") ? 240: 200, 25)); + label.setPreferredSize(new Dimension(key.startsWith("test.") ? 240 : 200, 25)); jComponent.setPreferredSize(new Dimension(200, 25)); p.setMaximumSize(new Dimension(600, 30)); panel.add(p); - //jComponent.setMinimumSize(new Dimension(60, 30)); //label.setBounds(0,0,100, 30); } else { @@ -912,7 +997,7 @@ public class ConfigWindow extends TWindow { jComponent.setBounds(currentX[index], currentY[index], 200, HEIGHT1); panel.add(Box.createRigidArea(new Dimension(5, 5))); - if(nextRow) { + if (nextRow) { nextRow(index); } else { currentX[index] = currentX[index] + SwingUtils.MARGIN + jComponent.getWidth(); diff --git a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/windows/MainWindow.java b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/windows/MainWindow.java index 66c98dd..3e77db8 100644 --- a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/windows/MainWindow.java +++ b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/windows/MainWindow.java @@ -70,7 +70,6 @@ import java.util.List; import java.util.stream.Collectors; import javax.swing.Timer; import org.nanoboot.utils.timecalc.swing.progress.ProgressDot; -import org.nanoboot.utils.timecalc.utils.common.NumberFormats; /** * @author Robert Vokac @@ -386,6 +385,29 @@ public class MainWindow extends TWindow { .bindTo(timeCalcConfiguration.lifeVisibleProperty); } + { + clock.hiddenProperty.bindTo(timeCalcConfiguration.clockHiddenProperty); + minuteBattery.hiddenProperty.bindTo(timeCalcConfiguration.batteryMinuteHiddenProperty); + hourBattery.hiddenProperty.bindTo(timeCalcConfiguration.batteryHourHiddenProperty); + dayBattery.hiddenProperty.bindTo(timeCalcConfiguration.batteryDayHiddenProperty); + weekBattery.hiddenProperty.bindTo(timeCalcConfiguration.batteryWeekHiddenProperty); + monthBattery.hiddenProperty.bindTo(timeCalcConfiguration.batteryMonthHiddenProperty); + yearBattery.hiddenProperty.bindTo(timeCalcConfiguration.batteryYearHiddenProperty); + progressSquare.hiddenProperty + .bindTo(timeCalcConfiguration.squareHiddenProperty); + progressDot.hiddenProperty + .bindTo(timeCalcConfiguration.dotHiddenProperty); + progressCircle.hiddenProperty + .bindTo(timeCalcConfiguration.circleHiddenProperty); + walkingHumanProgress.hiddenProperty + .bindTo(timeCalcConfiguration.walkingHumanHiddenProperty); + progressSwing.hiddenProperty + .bindTo(timeCalcConfiguration.swingHiddenProperty); + progressLife.hiddenProperty + .bindTo(timeCalcConfiguration.lifeHiddenProperty); + progressMoney.hiddenProperty.bindTo(timeCalcConfiguration.moneyHiddenProperty); + progressWeather.hiddenProperty.bindTo(timeCalcConfiguration.weatherHiddenProperty); + } TLabel arrivalTextFieldLabel = new TLabel("Arrival:", 70); arrivalTextFieldLabel.setBoundsFromTop(progressSwing, 3); diff --git a/modules/time-calc-app/src/main/resources/timecalc-default.conf b/modules/time-calc-app/src/main/resources/timecalc-default.conf index f0ff270..e43842d 100644 --- a/modules/time-calc-app/src/main/resources/timecalc-default.conf +++ b/modules/time-calc-app/src/main/resources/timecalc-default.conf @@ -21,6 +21,7 @@ clock.date.visible-only-if-mouse-moving-over=true clock.smiley.visible=false clock.percent-progress.visible=false clock.circle-progress.visible=true +clock.hidden=false # battery.waves.visible=true battery.circle-progress.visible=true @@ -36,6 +37,12 @@ battery.day.visible=true battery.week.visible=true battery.month.visible=true battery.year.visible=true +battery.minute.hidden=false +battery.hour.hidden=false +battery.day.hidden=false +battery.week.hidden=false +battery.month.hidden=false +battery.year.hidden=false battery.blinking-if-critical-low=true battery.quarter-icon.visible=true # @@ -47,23 +54,31 @@ smileys.visible-only-if-mouse-moving-over=true smileys.colored=true square.visible=true square.type=day +square.hidden=false dot.visible=true dot.type=day +dot.hidden=false circle.visible=true circle.type=day +circle.hidden=false swing.visible=true swing.type=day +swing.hidden=false swing.quarter-icon.visible=true life.visible=false life.type=day +life.hidden=false life.birth-date= money.visible=false money.type=day +money.hidden=false money.per-month=0 money.currency= weather.visible=true +weather.hidden=false walking-human.visible=true walking-human.type=day +walking-human.hidden=false main-window.custom-title=--- profile.name= test.enabled=false