mirror of
https://github.com/robertvokac/time-calc.git
synced 2025-03-25 07:27:49 +01:00
patch10
This commit is contained in:
parent
86245d0b46
commit
462e4c9c6e
@ -165,6 +165,8 @@ public class TimeCalcConfiguration {
|
|||||||
= new BooleanProperty("testModeProperty", false);
|
= new BooleanProperty("testModeProperty", false);
|
||||||
public final StringProperty profileNameProperty
|
public final StringProperty profileNameProperty
|
||||||
= new StringProperty(TimeCalcProperty.PROFILE_NAME.getKey());
|
= new StringProperty(TimeCalcProperty.PROFILE_NAME.getKey());
|
||||||
|
public final StringProperty activityNeededFlagsProperty
|
||||||
|
= new StringProperty(TimeCalcProperty.ACTIVITY_NEEDED_FLAGS.getKey());
|
||||||
public final BooleanProperty testEnabledProperty = new BooleanProperty(TimeCalcProperty.TEST_ENABLED.getKey(), false);
|
public final BooleanProperty testEnabledProperty = new BooleanProperty(TimeCalcProperty.TEST_ENABLED.getKey(), false);
|
||||||
public final IntegerProperty testYearCustomProperty = new IntegerProperty(TimeCalcProperty.TEST_CLOCK_CUSTOM_YEAR
|
public final IntegerProperty testYearCustomProperty = new IntegerProperty(TimeCalcProperty.TEST_CLOCK_CUSTOM_YEAR
|
||||||
.getKey(), Integer.MAX_VALUE);
|
.getKey(), Integer.MAX_VALUE);
|
||||||
@ -236,6 +238,7 @@ public class TimeCalcConfiguration {
|
|||||||
walkingHumanVisibleProperty,
|
walkingHumanVisibleProperty,
|
||||||
mainWindowCustomTitleProperty,
|
mainWindowCustomTitleProperty,
|
||||||
profileNameProperty,
|
profileNameProperty,
|
||||||
|
activityNeededFlagsProperty,
|
||||||
testEnabledProperty,
|
testEnabledProperty,
|
||||||
testYearCustomProperty,
|
testYearCustomProperty,
|
||||||
testMonthCustomProperty,
|
testMonthCustomProperty,
|
||||||
|
@ -87,7 +87,8 @@ public enum TimeCalcProperty {
|
|||||||
TEST_CLOCK_CUSTOM_HOUR("test.clock.custom.hour", "Test : Clock : Custom : Hour", Integer.class),
|
TEST_CLOCK_CUSTOM_HOUR("test.clock.custom.hour", "Test : Clock : Custom : Hour", Integer.class),
|
||||||
TEST_CLOCK_CUSTOM_MINUTE("test.clock.custom.minute", "Test : Clock : Custom : Minute", Integer.class),
|
TEST_CLOCK_CUSTOM_MINUTE("test.clock.custom.minute", "Test : Clock : Custom : Minute", Integer.class),
|
||||||
TEST_CLOCK_CUSTOM_SECOND("test.clock.custom.second", "Test : Clock : Custom : Second", Integer.class),
|
TEST_CLOCK_CUSTOM_SECOND("test.clock.custom.second", "Test : Clock : Custom : Second", Integer.class),
|
||||||
TEST_CLOCK_CUSTOM_MILLISECOND("test.clock.custom.millisecond", "Test : Clock : Custom : Millisecond", Integer.class);
|
TEST_CLOCK_CUSTOM_MILLISECOND("test.clock.custom.millisecond", "Test : Clock : Custom : Millisecond", Integer.class),
|
||||||
|
ACTIVITY_NEEDED_FLAGS("activity.needed-flags", "Activity : Needed flags", String.class);
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private final String key;
|
private final String key;
|
||||||
|
@ -1,8 +1,12 @@
|
|||||||
package org.nanoboot.utils.timecalc.persistence.api;
|
package org.nanoboot.utils.timecalc.persistence.api;
|
||||||
|
|
||||||
|
import org.nanoboot.utils.timecalc.app.TimeCalcConfiguration;
|
||||||
import org.nanoboot.utils.timecalc.entity.Activity;
|
import org.nanoboot.utils.timecalc.entity.Activity;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Robert Vokac
|
* @author Robert Vokac
|
||||||
@ -10,6 +14,34 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public interface ActivityRepositoryApi {
|
public interface ActivityRepositoryApi {
|
||||||
|
|
||||||
|
default double getProgressForDay(int year, int month, int day, TimeCalcConfiguration timeCalcConfiguration) {
|
||||||
|
List<Activity> list = list(year, month, day);
|
||||||
|
double done = 0d;
|
||||||
|
double todo = 8d;
|
||||||
|
|
||||||
|
loopName:
|
||||||
|
for(Activity a:list) {
|
||||||
|
Set<String> flags = a.flagsAsSet();
|
||||||
|
String neededFlags = timeCalcConfiguration.activityNeededFlagsProperty.getValue();
|
||||||
|
System.out.println("neededFlags=" + neededFlags);
|
||||||
|
neededFlags.replace(",", ":");
|
||||||
|
String[] neededFlagsArray = neededFlags.split(":");
|
||||||
|
Set<String> neededFlagsSet = Arrays.stream(neededFlagsArray).filter(f -> !f.isEmpty()).collect(
|
||||||
|
Collectors.toSet());
|
||||||
|
if(!neededFlagsSet.isEmpty()) {
|
||||||
|
for(String f:neededFlagsSet) {
|
||||||
|
if(!flags.contains(f)) {
|
||||||
|
continue loopName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
double now = a.getSpentHours() + a.getSpentMinutes() / 60d;
|
||||||
|
done = done + now;
|
||||||
|
todo = todo - now;
|
||||||
|
}
|
||||||
|
double progress = done / 8d;
|
||||||
|
return progress;
|
||||||
|
}
|
||||||
void create(Activity activity);
|
void create(Activity activity);
|
||||||
|
|
||||||
List<Activity> list(int year, int month, int day);
|
List<Activity> list(int year, int month, int day);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package org.nanoboot.utils.timecalc.swing.common;
|
package org.nanoboot.utils.timecalc.swing.common;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import org.nanoboot.utils.timecalc.app.TimeCalcConfiguration;
|
||||||
import org.nanoboot.utils.timecalc.entity.Activity;
|
import org.nanoboot.utils.timecalc.entity.Activity;
|
||||||
import org.nanoboot.utils.timecalc.persistence.api.ActivityRepositoryApi;
|
import org.nanoboot.utils.timecalc.persistence.api.ActivityRepositoryApi;
|
||||||
import org.nanoboot.utils.timecalc.utils.common.NumberFormats;
|
import org.nanoboot.utils.timecalc.utils.common.NumberFormats;
|
||||||
@ -40,6 +41,7 @@ public class DayPanel extends JPanel {
|
|||||||
|
|
||||||
private final Map<String, DayPanel> map = new HashMap<>();
|
private final Map<String, DayPanel> map = new HashMap<>();
|
||||||
private final ActivityRepositoryApi activityRepository;
|
private final ActivityRepositoryApi activityRepository;
|
||||||
|
private final TimeCalcConfiguration timeCalcConfiguration;
|
||||||
private JButton loadButton;
|
private JButton loadButton;
|
||||||
private JScrollPane scrollPane;
|
private JScrollPane scrollPane;
|
||||||
private JPanel panelInsideScrollPane;
|
private JPanel panelInsideScrollPane;
|
||||||
@ -47,13 +49,14 @@ public class DayPanel extends JPanel {
|
|||||||
private ActivityPanel markActivityPanelToBeMoved = null;
|
private ActivityPanel markActivityPanelToBeMoved = null;
|
||||||
|
|
||||||
public DayPanel(String yearIn, String monthIn, String dayIn,
|
public DayPanel(String yearIn, String monthIn, String dayIn,
|
||||||
ActivityRepositoryApi activityRepository) {
|
ActivityRepositoryApi activityRepository, TimeCalcConfiguration timeCalcConfiguration) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
this.year = yearIn;
|
this.year = yearIn;
|
||||||
this.month = monthIn;
|
this.month = monthIn;
|
||||||
this.day = dayIn;
|
this.day = dayIn;
|
||||||
this.activityRepository = activityRepository;
|
this.activityRepository = activityRepository;
|
||||||
|
this.timeCalcConfiguration = timeCalcConfiguration;
|
||||||
setSize(1450, 600);
|
setSize(1450, 600);
|
||||||
|
|
||||||
this.setLayout(null);
|
this.setLayout(null);
|
||||||
@ -168,22 +171,41 @@ public class DayPanel extends JPanel {
|
|||||||
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
|
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
|
||||||
clipboard.setContents(new StringSelection(comments), null);
|
clipboard.setContents(new StringSelection(comments), null);
|
||||||
});
|
});
|
||||||
|
|
||||||
statusButton.addActionListener(e-> {
|
statusButton.addActionListener(e-> {
|
||||||
|
// String neededFlags = timeCalcConfiguration.activityNeededFlagsProperty.getValue();
|
||||||
|
// System.out.println("neededFlags=" + neededFlags);
|
||||||
|
// neededFlags.replace(",", ":");
|
||||||
|
// String[] neededFlagsArray = neededFlags.split(":");
|
||||||
|
// Set<String> neededFlagsSet = Arrays.stream(neededFlagsArray).filter(f -> !f.isEmpty()).collect(Collectors.toSet());
|
||||||
List<ActivityPanel> activityPanels = new ArrayList<>();
|
List<ActivityPanel> activityPanels = new ArrayList<>();
|
||||||
Arrays
|
Arrays
|
||||||
.stream(panelInsideScrollPane.getComponents())
|
.stream(panelInsideScrollPane.getComponents())
|
||||||
.filter(c-> c instanceof ActivityPanel).forEach(f-> activityPanels.add((ActivityPanel) f));
|
.filter(c-> c instanceof ActivityPanel).forEach(f-> activityPanels.add((ActivityPanel) f));
|
||||||
Collections.sort(activityPanels);
|
Collections.sort(activityPanels);
|
||||||
|
|
||||||
double done = 0d;
|
// double done = 0d;
|
||||||
double todo = 8d;
|
// double todo = 8d;
|
||||||
for(ActivityPanel ap:activityPanels) {
|
// loopName:
|
||||||
|
// for(ActivityPanel ap:activityPanels) {
|
||||||
|
// Set<String> flags = ap.getActivity().flagsAsSet();
|
||||||
|
// if(!neededFlagsSet.isEmpty()) {
|
||||||
|
// for(String f:neededFlagsSet) {
|
||||||
|
// if(!flags.contains(f)) {
|
||||||
|
// continue loopName;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// double now = ap.getActivity().getSpentHours() + ap.getActivity().getSpentMinutes() / 60d;
|
||||||
|
// done = done + now;
|
||||||
|
// todo = todo - now;
|
||||||
|
// }
|
||||||
|
// double progress = done / 8d;
|
||||||
|
double progress = activityRepository.getProgressForDay(Integer.valueOf(year), Integer.valueOf(month), Integer.valueOf(day), timeCalcConfiguration);
|
||||||
|
|
||||||
double now = ap.getActivity().getSpentHours() + ap.getActivity().getSpentMinutes() / 60d;
|
double doneHours = progress * 8d;
|
||||||
done = done + now;
|
double todoHours = (8d - doneHours);
|
||||||
todo = todo - now;
|
Utils.showNotification("Current status: done=" + NumberFormats.FORMATTER_TWO_DECIMAL_PLACES.format(doneHours) + "h, todo="+ NumberFormats.FORMATTER_TWO_DECIMAL_PLACES.format(todoHours));
|
||||||
}
|
|
||||||
Utils.showNotification("Current status: done=" + NumberFormats.FORMATTER_TWO_DECIMAL_PLACES.format(done) + "h, todo="+ NumberFormats.FORMATTER_TWO_DECIMAL_PLACES.format(todo));
|
|
||||||
|
|
||||||
});
|
});
|
||||||
sortActivityPanels();
|
sortActivityPanels();
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package org.nanoboot.utils.timecalc.swing.common;
|
package org.nanoboot.utils.timecalc.swing.common;
|
||||||
|
|
||||||
|
import org.nanoboot.utils.timecalc.app.TimeCalcConfiguration;
|
||||||
import org.nanoboot.utils.timecalc.swing.controls.TTabbedPane;
|
import org.nanoboot.utils.timecalc.swing.controls.TTabbedPane;
|
||||||
import org.nanoboot.utils.timecalc.persistence.api.ActivityRepositoryApi;
|
import org.nanoboot.utils.timecalc.persistence.api.ActivityRepositoryApi;
|
||||||
|
|
||||||
@ -24,10 +25,13 @@ public class MonthPanel extends JPanel {
|
|||||||
private final TTabbedPane tp;
|
private final TTabbedPane tp;
|
||||||
private final ActivityRepositoryApi activityRepository;
|
private final ActivityRepositoryApi activityRepository;
|
||||||
private final Calendar cal;
|
private final Calendar cal;
|
||||||
|
private final TimeCalcConfiguration timeCalcConfiguration;
|
||||||
|
|
||||||
private boolean loaded = false;
|
private boolean loaded = false;
|
||||||
public MonthPanel(String yearIn, String monthIn, ActivityRepositoryApi activityRepository) {
|
public MonthPanel(String yearIn, String monthIn, ActivityRepositoryApi activityRepository, TimeCalcConfiguration timeCalcConfiguration) {
|
||||||
super();
|
super();
|
||||||
this.activityRepository = activityRepository;
|
this.activityRepository = activityRepository;
|
||||||
|
this.timeCalcConfiguration = timeCalcConfiguration;
|
||||||
|
|
||||||
this.year = yearIn;
|
this.year = yearIn;
|
||||||
this.month = monthIn;
|
this.month = monthIn;
|
||||||
@ -69,7 +73,7 @@ public class MonthPanel extends JPanel {
|
|||||||
for (int day = 1; day <= maxDay; day++) {
|
for (int day = 1; day <= maxDay; day++) {
|
||||||
String dayS = String.valueOf(day);
|
String dayS = String.valueOf(day);
|
||||||
DayPanel dayPanel = new DayPanel(year, month, dayS,
|
DayPanel dayPanel = new DayPanel(year, month, dayS,
|
||||||
activityRepository);
|
activityRepository, timeCalcConfiguration);
|
||||||
tp.add(dayS, dayPanel);
|
tp.add(dayS, dayPanel);
|
||||||
days.put(dayS, dayPanel);
|
days.put(dayS, dayPanel);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package org.nanoboot.utils.timecalc.swing.common;
|
package org.nanoboot.utils.timecalc.swing.common;
|
||||||
|
|
||||||
|
import org.nanoboot.utils.timecalc.app.TimeCalcConfiguration;
|
||||||
import org.nanoboot.utils.timecalc.swing.controls.TTabbedPane;
|
import org.nanoboot.utils.timecalc.swing.controls.TTabbedPane;
|
||||||
import org.nanoboot.utils.timecalc.persistence.api.ActivityRepositoryApi;
|
import org.nanoboot.utils.timecalc.persistence.api.ActivityRepositoryApi;
|
||||||
|
|
||||||
@ -20,12 +21,15 @@ public class YearPanel extends JPanel {
|
|||||||
private final Map<String, MonthPanel> months;
|
private final Map<String, MonthPanel> months;
|
||||||
private final TTabbedPane tp;
|
private final TTabbedPane tp;
|
||||||
private final ActivityRepositoryApi activityRepository;
|
private final ActivityRepositoryApi activityRepository;
|
||||||
|
private final TimeCalcConfiguration timeCalcConfiguration;
|
||||||
private boolean loaded = false;
|
private boolean loaded = false;
|
||||||
|
|
||||||
public YearPanel(String yearIn, ActivityRepositoryApi activityRepository) {
|
public YearPanel(String yearIn, ActivityRepositoryApi activityRepository, TimeCalcConfiguration timeCalcConfiguration) {
|
||||||
super();
|
super();
|
||||||
this.year = yearIn;
|
this.year = yearIn;
|
||||||
this.months = new HashMap<>();
|
this.months = new HashMap<>();
|
||||||
|
this.timeCalcConfiguration = timeCalcConfiguration;
|
||||||
|
|
||||||
setLayout(null);
|
setLayout(null);
|
||||||
this.tp = new TTabbedPane();
|
this.tp = new TTabbedPane();
|
||||||
add(tp);
|
add(tp);
|
||||||
@ -60,7 +64,7 @@ public class YearPanel extends JPanel {
|
|||||||
System.out.println("Loaded: " + year);
|
System.out.println("Loaded: " + year);
|
||||||
for (int month = 1; month <= 12; month++) {
|
for (int month = 1; month <= 12; month++) {
|
||||||
final String monthS = String.valueOf(month);
|
final String monthS = String.valueOf(month);
|
||||||
MonthPanel monthPanel = new MonthPanel(year, String.valueOf(month), activityRepository);
|
MonthPanel monthPanel = new MonthPanel(year, String.valueOf(month), activityRepository, timeCalcConfiguration);
|
||||||
tp.add(String.valueOf(month), monthPanel);
|
tp.add(String.valueOf(month), monthPanel);
|
||||||
months.put(monthS, monthPanel);
|
months.put(monthS, monthPanel);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package org.nanoboot.utils.timecalc.swing.windows;
|
package org.nanoboot.utils.timecalc.swing.windows;
|
||||||
|
|
||||||
|
import org.nanoboot.utils.timecalc.app.TimeCalcConfiguration;
|
||||||
import org.nanoboot.utils.timecalc.swing.controls.TWindow;
|
import org.nanoboot.utils.timecalc.swing.controls.TWindow;
|
||||||
import org.nanoboot.utils.timecalc.swing.controls.TTabbedPane;
|
import org.nanoboot.utils.timecalc.swing.controls.TTabbedPane;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -27,7 +28,7 @@ public class ActivitiesWindow extends TWindow {
|
|||||||
private final ActivityRepositoryApi activityRepository;
|
private final ActivityRepositoryApi activityRepository;
|
||||||
private final Map<String, YearPanel> years;
|
private final Map<String, YearPanel> years;
|
||||||
|
|
||||||
public ActivitiesWindow(ActivityRepositoryApi activityRepositoryApiIn, Time time) {
|
public ActivitiesWindow(ActivityRepositoryApi activityRepositoryApiIn, Time time, TimeCalcConfiguration timeCalcConfiguration) {
|
||||||
setSize(1600, 800);
|
setSize(1600, 800);
|
||||||
setTitle("Activities");
|
setTitle("Activities");
|
||||||
this.activityRepository = activityRepositoryApiIn;
|
this.activityRepository = activityRepositoryApiIn;
|
||||||
@ -57,13 +58,13 @@ public class ActivitiesWindow extends TWindow {
|
|||||||
|
|
||||||
tp.setBounds(addYearButton.getX(), addYearButton.getY() + addYearButton.getHeight() + SwingUtils.MARGIN, 1500, 750);
|
tp.setBounds(addYearButton.getX(), addYearButton.getY() + addYearButton.getHeight() + SwingUtils.MARGIN, 1500, 750);
|
||||||
yearsList.forEach(y -> {
|
yearsList.forEach(y -> {
|
||||||
final YearPanel yearPanel = new YearPanel(y, activityRepository);
|
final YearPanel yearPanel = new YearPanel(y, activityRepository, timeCalcConfiguration);
|
||||||
tp.add(y, yearPanel);
|
tp.add(y, yearPanel);
|
||||||
years.put(y, yearPanel);
|
years.put(y, yearPanel);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
if (!yearsList.contains(currentYearS)) {
|
if (!yearsList.contains(currentYearS)) {
|
||||||
YearPanel yearPanel = new YearPanel(currentYearS, activityRepository);
|
YearPanel yearPanel = new YearPanel(currentYearS, activityRepository, timeCalcConfiguration);
|
||||||
tp.add(currentYearS, yearPanel);
|
tp.add(currentYearS, yearPanel);
|
||||||
years.put(currentYearS, yearPanel);
|
years.put(currentYearS, yearPanel);
|
||||||
}
|
}
|
||||||
@ -84,7 +85,7 @@ public class ActivitiesWindow extends TWindow {
|
|||||||
throw new TimeCalcException(msg);
|
throw new TimeCalcException(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
YearPanel yearPanel = new YearPanel(year_, activityRepository);
|
YearPanel yearPanel = new YearPanel(year_, activityRepository, timeCalcConfiguration);
|
||||||
tp.add(year_, yearPanel);
|
tp.add(year_, yearPanel);
|
||||||
years.put(currentYearS, yearPanel);
|
years.put(currentYearS, yearPanel);
|
||||||
|
|
||||||
|
@ -1,10 +1,14 @@
|
|||||||
package org.nanoboot.utils.timecalc.swing.windows;
|
package org.nanoboot.utils.timecalc.swing.windows;
|
||||||
|
|
||||||
import org.nanoboot.utils.timecalc.swing.controls.TButton;
|
|
||||||
import org.nanoboot.utils.timecalc.swing.controls.TWindow;
|
|
||||||
import org.nanoboot.utils.timecalc.app.TimeCalcConfiguration;
|
import org.nanoboot.utils.timecalc.app.TimeCalcConfiguration;
|
||||||
import org.nanoboot.utils.timecalc.app.TimeCalcProperty;
|
import org.nanoboot.utils.timecalc.app.TimeCalcProperty;
|
||||||
import org.nanoboot.utils.timecalc.entity.Visibility;
|
import org.nanoboot.utils.timecalc.entity.Visibility;
|
||||||
|
import org.nanoboot.utils.timecalc.swing.common.SwingUtils;
|
||||||
|
import org.nanoboot.utils.timecalc.swing.controls.MouseClickedListener;
|
||||||
|
import org.nanoboot.utils.timecalc.swing.controls.TButton;
|
||||||
|
import org.nanoboot.utils.timecalc.swing.controls.TTabbedPane;
|
||||||
|
import org.nanoboot.utils.timecalc.swing.controls.TWindow;
|
||||||
|
import org.nanoboot.utils.timecalc.utils.common.TTime;
|
||||||
import org.nanoboot.utils.timecalc.utils.property.BooleanProperty;
|
import org.nanoboot.utils.timecalc.utils.property.BooleanProperty;
|
||||||
import org.nanoboot.utils.timecalc.utils.property.StringProperty;
|
import org.nanoboot.utils.timecalc.utils.property.StringProperty;
|
||||||
|
|
||||||
@ -15,6 +19,7 @@ import javax.swing.JColorChooser;
|
|||||||
import javax.swing.JComboBox;
|
import javax.swing.JComboBox;
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JScrollPane;
|
import javax.swing.JScrollPane;
|
||||||
import javax.swing.JTextField;
|
import javax.swing.JTextField;
|
||||||
@ -34,8 +39,6 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
import org.nanoboot.utils.timecalc.swing.common.SwingUtils;
|
|
||||||
import org.nanoboot.utils.timecalc.swing.controls.TTabbedPane;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Robert Vokac
|
* @author Robert Vokac
|
||||||
@ -50,6 +53,7 @@ public class ConfigWindow extends TWindow {
|
|||||||
public static final String THREE_DASHES = "---";
|
public static final String THREE_DASHES = "---";
|
||||||
private static final Font BIG_FONT = new Font("sans", Font.BOLD, 24);
|
private static final Font BIG_FONT = new Font("sans", Font.BOLD, 24);
|
||||||
private static final String FIVE_SPACES = " ";
|
private static final String FIVE_SPACES = " ";
|
||||||
|
private static final String EDITABLE_ONLY_IN_DIALOG = "editableOnlyInDialog";
|
||||||
public final JComboBox visibilityDefaultProperty = new JComboBox(
|
public final JComboBox visibilityDefaultProperty = new JComboBox(
|
||||||
Arrays.stream(Visibility.values()).map(v -> v.name()).collect(
|
Arrays.stream(Visibility.values()).map(v -> v.name()).collect(
|
||||||
Collectors.toList()).toArray());
|
Collectors.toList()).toArray());
|
||||||
@ -174,6 +178,8 @@ public class ConfigWindow extends TWindow {
|
|||||||
= new JTextField();
|
= new JTextField();
|
||||||
private final JTextField profileNameProperty
|
private final JTextField profileNameProperty
|
||||||
= new JTextField();
|
= new JTextField();
|
||||||
|
public final JTextField activityNeededFlagsProperty
|
||||||
|
= new JTextField(TimeCalcProperty.ACTIVITY_NEEDED_FLAGS.getKey());
|
||||||
private final JCheckBox testEnabledProperty
|
private final JCheckBox testEnabledProperty
|
||||||
= new JCheckBox(TimeCalcProperty.TEST_ENABLED.getKey());
|
= new JCheckBox(TimeCalcProperty.TEST_ENABLED.getKey());
|
||||||
private final JTextField testClockCustomYearProperty
|
private final JTextField testClockCustomYearProperty
|
||||||
@ -391,6 +397,7 @@ public class ConfigWindow extends TWindow {
|
|||||||
walkingHumanVisibleProperty,
|
walkingHumanVisibleProperty,
|
||||||
mainWindowCustomTitleProperty,
|
mainWindowCustomTitleProperty,
|
||||||
profileNameProperty,
|
profileNameProperty,
|
||||||
|
activityNeededFlagsProperty,
|
||||||
visibilityDefaultProperty,
|
visibilityDefaultProperty,
|
||||||
visibilitySupportedColoredProperty));
|
visibilitySupportedColoredProperty));
|
||||||
//
|
//
|
||||||
@ -435,6 +442,40 @@ public class ConfigWindow extends TWindow {
|
|||||||
p.putClientProperty(CLIENT_PROPERTY_KEY,
|
p.putClientProperty(CLIENT_PROPERTY_KEY,
|
||||||
TimeCalcProperty.PROFILE_NAME.getKey());
|
TimeCalcProperty.PROFILE_NAME.getKey());
|
||||||
}
|
}
|
||||||
|
if (p == activityNeededFlagsProperty) {
|
||||||
|
final JLabel jLabel = new JLabel(
|
||||||
|
TimeCalcProperty.ACTIVITY_NEEDED_FLAGS.getDescription());
|
||||||
|
jLabel.putClientProperty(CLIENT_PROPERTY_KEY,
|
||||||
|
TimeCalcProperty.ACTIVITY_NEEDED_FLAGS.getKey());
|
||||||
|
addToNextRow(jLabel);
|
||||||
|
p.putClientProperty(CLIENT_PROPERTY_KEY,
|
||||||
|
TimeCalcProperty.ACTIVITY_NEEDED_FLAGS.getKey());
|
||||||
|
activityNeededFlagsProperty.setEditable(false);
|
||||||
|
activityNeededFlagsProperty.setBackground(Color.WHITE);
|
||||||
|
activityNeededFlagsProperty.putClientProperty(
|
||||||
|
EDITABLE_ONLY_IN_DIALOG, "");
|
||||||
|
activityNeededFlagsProperty
|
||||||
|
.addMouseListener((MouseClickedListener) f -> {
|
||||||
|
|
||||||
|
String result =
|
||||||
|
(String) JOptionPane.showInputDialog(
|
||||||
|
null,
|
||||||
|
"Select new value",
|
||||||
|
"New value",
|
||||||
|
JOptionPane.PLAIN_MESSAGE,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
activityNeededFlagsProperty
|
||||||
|
.getText()
|
||||||
|
);
|
||||||
|
if (result != null) {
|
||||||
|
activityNeededFlagsProperty.setText(result);
|
||||||
|
timeCalcConfiguration.activityNeededFlagsProperty.setValue(result);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if (p == testClockCustomYearProperty) {
|
if (p == testClockCustomYearProperty) {
|
||||||
JLabel label = new JLabel("Test");
|
JLabel label = new JLabel("Test");
|
||||||
label.setFont(BIG_FONT);
|
label.setFont(BIG_FONT);
|
||||||
@ -584,7 +625,7 @@ public class ConfigWindow extends TWindow {
|
|||||||
timeCalcConfiguration
|
timeCalcConfiguration
|
||||||
.getProperty(timeCalcProperty).addListener(e -> {
|
.getProperty(timeCalcProperty).addListener(e -> {
|
||||||
|
|
||||||
textField.setText(isInteger
|
textField.setText(isInteger
|
||||||
? String.valueOf(timeCalcConfiguration
|
? String.valueOf(timeCalcConfiguration
|
||||||
.getProperty(timeCalcProperty).getValue())
|
.getProperty(timeCalcProperty).getValue())
|
||||||
: (String) timeCalcConfiguration
|
: (String) timeCalcConfiguration
|
||||||
@ -609,6 +650,9 @@ public class ConfigWindow extends TWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void update(DocumentEvent e) {
|
private void update(DocumentEvent e) {
|
||||||
|
if(textField.getClientProperty(EDITABLE_ONLY_IN_DIALOG) != null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
String text = textField.getText();
|
String text = textField.getText();
|
||||||
boolean isInteger = Integer.class == timeCalcProperty.getClazz();
|
boolean isInteger = Integer.class == timeCalcProperty.getClazz();
|
||||||
timeCalcConfiguration
|
timeCalcConfiguration
|
||||||
|
@ -30,7 +30,6 @@ import org.nanoboot.utils.timecalc.swing.progress.DayBattery;
|
|||||||
import org.nanoboot.utils.timecalc.swing.progress.HourBattery;
|
import org.nanoboot.utils.timecalc.swing.progress.HourBattery;
|
||||||
import org.nanoboot.utils.timecalc.swing.progress.MinuteBattery;
|
import org.nanoboot.utils.timecalc.swing.progress.MinuteBattery;
|
||||||
import org.nanoboot.utils.timecalc.swing.progress.MonthBattery;
|
import org.nanoboot.utils.timecalc.swing.progress.MonthBattery;
|
||||||
import org.nanoboot.utils.timecalc.swing.progress.PlaceHolderWidget;
|
|
||||||
import org.nanoboot.utils.timecalc.swing.progress.ProgressCircle;
|
import org.nanoboot.utils.timecalc.swing.progress.ProgressCircle;
|
||||||
import org.nanoboot.utils.timecalc.swing.progress.ProgressSquare;
|
import org.nanoboot.utils.timecalc.swing.progress.ProgressSquare;
|
||||||
import org.nanoboot.utils.timecalc.swing.progress.Time;
|
import org.nanoboot.utils.timecalc.swing.progress.Time;
|
||||||
@ -45,7 +44,6 @@ import org.nanoboot.utils.timecalc.utils.common.TTime;
|
|||||||
import org.nanoboot.utils.timecalc.utils.common.Utils;
|
import org.nanoboot.utils.timecalc.utils.common.Utils;
|
||||||
import org.nanoboot.utils.timecalc.utils.property.ChangeListener;
|
import org.nanoboot.utils.timecalc.utils.property.ChangeListener;
|
||||||
import org.nanoboot.utils.timecalc.utils.property.IntegerProperty;
|
import org.nanoboot.utils.timecalc.utils.property.IntegerProperty;
|
||||||
import org.nanoboot.utils.timecalc.utils.property.Property;
|
|
||||||
|
|
||||||
import javax.swing.JCheckBox;
|
import javax.swing.JCheckBox;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
@ -475,7 +473,7 @@ public class MainWindow extends TWindow {
|
|||||||
});
|
});
|
||||||
activitiesButton.addActionListener(e -> {
|
activitiesButton.addActionListener(e -> {
|
||||||
if (activitiesWindow == null) {
|
if (activitiesWindow == null) {
|
||||||
this.activitiesWindow = new ActivitiesWindow(this.activityRepository, time);
|
this.activitiesWindow = new ActivitiesWindow(this.activityRepository, time, timeCalcConfiguration);
|
||||||
}
|
}
|
||||||
activitiesWindow.setVisible(true);
|
activitiesWindow.setVisible(true);
|
||||||
});
|
});
|
||||||
|
@ -61,3 +61,4 @@ test.clock.custom.millisecond=2147483647
|
|||||||
logs.detailed=false
|
logs.detailed=false
|
||||||
battery.percent-precision.count-of-decimal-points=5
|
battery.percent-precision.count-of-decimal-points=5
|
||||||
main-window.custom-title=---
|
main-window.custom-title=---
|
||||||
|
activity.needed-flags=
|
||||||
|
Loading…
x
Reference in New Issue
Block a user