mirror of
https://github.com/robertvokac/time-calc.git
synced 2025-03-25 07:27:49 +01:00
patch27
This commit is contained in:
parent
55afc71d42
commit
5f33e62c76
@ -114,8 +114,6 @@ public enum TimeCalcProperty {
|
|||||||
@Getter
|
@Getter
|
||||||
private final Class clazz;
|
private final Class clazz;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
Set<String> uniqueKeys = new HashSet<>();
|
Set<String> uniqueKeys = new HashSet<>();
|
||||||
for(TimeCalcProperty tcp:TimeCalcProperty.values()) {
|
for(TimeCalcProperty tcp:TimeCalcProperty.values()) {
|
||||||
|
@ -28,7 +28,9 @@ import javax.swing.event.DocumentEvent;
|
|||||||
import javax.swing.event.DocumentListener;
|
import javax.swing.event.DocumentListener;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
|
import java.awt.FlowLayout;
|
||||||
import java.awt.Font;
|
import java.awt.Font;
|
||||||
|
import java.awt.LayoutManager;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.awt.event.MouseListener;
|
import java.awt.event.MouseListener;
|
||||||
import java.awt.event.WindowAdapter;
|
import java.awt.event.WindowAdapter;
|
||||||
@ -62,10 +64,13 @@ public class ConfigWindow extends TWindow {
|
|||||||
private final TimeCalcConfiguration timeCalcConfiguration;
|
private final TimeCalcConfiguration timeCalcConfiguration;
|
||||||
private final JPanel panelInsideScrollPaneClock;
|
private final JPanel panelInsideScrollPaneClock;
|
||||||
private final JPanel panelInsideScrollPaneBattery;
|
private final JPanel panelInsideScrollPaneBattery;
|
||||||
|
private final JPanel panelInsideScrollPaneLife;
|
||||||
|
private final JPanel panelInsideScrollPaneMoney;
|
||||||
private final JPanel panelInsideScrollPaneSmileys;
|
private final JPanel panelInsideScrollPaneSmileys;
|
||||||
private final JPanel panelInsideScrollPaneTest;
|
private final JPanel panelInsideScrollPaneTest;
|
||||||
private final JPanel panelInsideScrollPaneMisc;
|
private final JPanel panelInsideScrollPaneOther;
|
||||||
private final int[] currentY = new int[]{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<JComponent> propertiesList = new ArrayList<>();
|
private final List<JComponent> propertiesList = new ArrayList<>();
|
||||||
private final Map<TimeCalcProperty, JComponent> propertiesMap = new HashMap<>();
|
private final Map<TimeCalcProperty, JComponent> propertiesMap = new HashMap<>();
|
||||||
private final TButton enableAsMuchAsPossible
|
private final TButton enableAsMuchAsPossible
|
||||||
@ -241,16 +246,20 @@ public class ConfigWindow extends TWindow {
|
|||||||
//tp.setBackground(Color.red);
|
//tp.setBackground(Color.red);
|
||||||
this.panelInsideScrollPaneClock = new JPanel();
|
this.panelInsideScrollPaneClock = new JPanel();
|
||||||
this.panelInsideScrollPaneBattery = new JPanel();
|
this.panelInsideScrollPaneBattery = new JPanel();
|
||||||
|
this.panelInsideScrollPaneLife = new JPanel();
|
||||||
|
this.panelInsideScrollPaneMoney = new JPanel();
|
||||||
this.panelInsideScrollPaneSmileys = new JPanel();
|
this.panelInsideScrollPaneSmileys = new JPanel();
|
||||||
this.panelInsideScrollPaneTest = new JPanel();
|
this.panelInsideScrollPaneTest = new JPanel();
|
||||||
this.panelInsideScrollPaneMisc = new JPanel();
|
this.panelInsideScrollPaneOther = new JPanel();
|
||||||
|
|
||||||
List<JPanel> panelsInsideScrollPane = Stream.of(
|
List<JPanel> panelsInsideScrollPane = Stream.of(
|
||||||
panelInsideScrollPaneClock,
|
panelInsideScrollPaneClock,
|
||||||
panelInsideScrollPaneBattery,
|
panelInsideScrollPaneBattery,
|
||||||
|
panelInsideScrollPaneLife,
|
||||||
|
panelInsideScrollPaneMoney,
|
||||||
panelInsideScrollPaneSmileys,
|
panelInsideScrollPaneSmileys,
|
||||||
panelInsideScrollPaneTest,
|
panelInsideScrollPaneTest,
|
||||||
panelInsideScrollPaneMisc).collect(Collectors.toList());
|
panelInsideScrollPaneOther).collect(Collectors.toList());
|
||||||
panelsInsideScrollPane.forEach(p-> {
|
panelsInsideScrollPane.forEach(p-> {
|
||||||
final BoxLayout boxLayout = new BoxLayout(p, BoxLayout.Y_AXIS);
|
final BoxLayout boxLayout = new BoxLayout(p, BoxLayout.Y_AXIS);
|
||||||
p.setLayout(boxLayout);
|
p.setLayout(boxLayout);
|
||||||
@ -266,23 +275,29 @@ public class ConfigWindow extends TWindow {
|
|||||||
|
|
||||||
JScrollPane scrollPaneClock = new JScrollPane(panelInsideScrollPaneClock);
|
JScrollPane scrollPaneClock = new JScrollPane(panelInsideScrollPaneClock);
|
||||||
JScrollPane scrollPaneBattery = new JScrollPane(panelInsideScrollPaneBattery);
|
JScrollPane scrollPaneBattery = new JScrollPane(panelInsideScrollPaneBattery);
|
||||||
|
JScrollPane scrollPaneLife = new JScrollPane(panelInsideScrollPaneLife);
|
||||||
|
JScrollPane scrollPaneMoney = new JScrollPane(panelInsideScrollPaneMoney);
|
||||||
JScrollPane scrollPaneSmileys = new JScrollPane(panelInsideScrollPaneSmileys);
|
JScrollPane scrollPaneSmileys = new JScrollPane(panelInsideScrollPaneSmileys);
|
||||||
JScrollPane scrollPaneTest = new JScrollPane(panelInsideScrollPaneTest);
|
JScrollPane scrollPaneTest = new JScrollPane(panelInsideScrollPaneTest);
|
||||||
JScrollPane scrollPaneMisc = new JScrollPane(panelInsideScrollPaneMisc);
|
JScrollPane scrollPaneOther = new JScrollPane(panelInsideScrollPaneOther);
|
||||||
|
|
||||||
List<JScrollPane> scrollPanes = Stream.of(
|
List<JScrollPane> scrollPanes = Stream.of(
|
||||||
scrollPaneClock,
|
scrollPaneClock,
|
||||||
scrollPaneBattery,
|
scrollPaneBattery,
|
||||||
|
scrollPaneLife,
|
||||||
|
scrollPaneMoney,
|
||||||
scrollPaneSmileys,
|
scrollPaneSmileys,
|
||||||
scrollPaneTest,
|
scrollPaneTest,
|
||||||
scrollPaneMisc
|
scrollPaneOther
|
||||||
).collect(Collectors.toList());
|
).collect(Collectors.toList());
|
||||||
|
|
||||||
tp.add("Clock", scrollPaneClock);
|
tp.add("Clock", scrollPaneClock);
|
||||||
tp.add("Battery", scrollPaneBattery);
|
tp.add("Battery", scrollPaneBattery);
|
||||||
|
tp.add("Life", scrollPaneLife);
|
||||||
|
tp.add("Money", scrollPaneMoney);
|
||||||
tp.add("Smileys", scrollPaneSmileys);
|
tp.add("Smileys", scrollPaneSmileys);
|
||||||
tp.add("Test", scrollPaneTest);
|
tp.add("Test", scrollPaneTest);
|
||||||
tp.add("Misc", scrollPaneMisc);
|
tp.add("Other", scrollPaneOther);
|
||||||
scrollPanes.forEach(s->
|
scrollPanes.forEach(s->
|
||||||
{
|
{
|
||||||
s.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
|
s.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
|
||||||
@ -474,21 +489,21 @@ public class ConfigWindow extends TWindow {
|
|||||||
addToNextRow(label);
|
addToNextRow(label);
|
||||||
}
|
}
|
||||||
if (p == mainWindowCustomTitleProperty) {
|
if (p == mainWindowCustomTitleProperty) {
|
||||||
final JLabel jLabel = new JLabel(
|
// final JLabel jLabel = new JLabel(
|
||||||
TimeCalcProperty.MAIN_WINDOW_CUSTOM_TITLE
|
// TimeCalcProperty.MAIN_WINDOW_CUSTOM_TITLE
|
||||||
.getDescription());
|
// .getDescription());
|
||||||
jLabel.putClientProperty(CLIENT_PROPERTY_KEY,
|
// jLabel.putClientProperty(CLIENT_PROPERTY_KEY,
|
||||||
TimeCalcProperty.MAIN_WINDOW_CUSTOM_TITLE.getKey());
|
// TimeCalcProperty.MAIN_WINDOW_CUSTOM_TITLE.getKey());
|
||||||
addToNextRow(jLabel);
|
// addToNextRow(jLabel);
|
||||||
p.putClientProperty(CLIENT_PROPERTY_KEY,
|
p.putClientProperty(CLIENT_PROPERTY_KEY,
|
||||||
TimeCalcProperty.MAIN_WINDOW_CUSTOM_TITLE.getKey());
|
TimeCalcProperty.MAIN_WINDOW_CUSTOM_TITLE.getKey());
|
||||||
}
|
}
|
||||||
if (p == profileNameProperty) {
|
if (p == profileNameProperty) {
|
||||||
final JLabel jLabel = new JLabel(
|
// final JLabel jLabel = new JLabel(
|
||||||
TimeCalcProperty.PROFILE_NAME.getDescription());
|
// TimeCalcProperty.PROFILE_NAME.getDescription());
|
||||||
jLabel.putClientProperty(CLIENT_PROPERTY_KEY,
|
// jLabel.putClientProperty(CLIENT_PROPERTY_KEY,
|
||||||
TimeCalcProperty.PROFILE_NAME.getKey());
|
// TimeCalcProperty.PROFILE_NAME.getKey());
|
||||||
addToNextRow(jLabel);
|
// addToNextRow(jLabel);
|
||||||
p.putClientProperty(CLIENT_PROPERTY_KEY,
|
p.putClientProperty(CLIENT_PROPERTY_KEY,
|
||||||
TimeCalcProperty.PROFILE_NAME.getKey());
|
TimeCalcProperty.PROFILE_NAME.getKey());
|
||||||
}
|
}
|
||||||
@ -559,8 +574,8 @@ public class ConfigWindow extends TWindow {
|
|||||||
|
|
||||||
checkBox.setText(timeCalcProperty.getDescription());
|
checkBox.setText(timeCalcProperty.getDescription());
|
||||||
|
|
||||||
System.out.println(((JCheckBox) p).getText());
|
//System.out.println(((JCheckBox) p).getText());
|
||||||
System.out.println(timeCalcProperty);
|
//System.out.println(timeCalcProperty);
|
||||||
BooleanProperty property
|
BooleanProperty property
|
||||||
= (BooleanProperty) timeCalcConfiguration
|
= (BooleanProperty) timeCalcConfiguration
|
||||||
.getProperty(timeCalcProperty);
|
.getProperty(timeCalcProperty);
|
||||||
@ -659,11 +674,12 @@ public class ConfigWindow extends TWindow {
|
|||||||
String key = textField.getText();
|
String key = textField.getText();
|
||||||
textField.setText("");
|
textField.setText("");
|
||||||
textField.putClientProperty(CLIENT_PROPERTY_KEY, key);
|
textField.putClientProperty(CLIENT_PROPERTY_KEY, key);
|
||||||
JComponent label = new JLabel(TimeCalcProperty.forKey(key).getDescription());
|
// JComponent label = new JLabel(TimeCalcProperty.forKey(key).getDescription());
|
||||||
label.putClientProperty(CLIENT_PROPERTY_KEY, key);
|
// label.putClientProperty(CLIENT_PROPERTY_KEY, key);
|
||||||
addToNextRow(label);
|
// addToNextRow(label);
|
||||||
}
|
}
|
||||||
textField.setMaximumSize(new Dimension(150, 25));
|
textField.setMaximumSize(new Dimension(400, 25));
|
||||||
|
textField.setMinimumSize(new Dimension(100, 25));
|
||||||
|
|
||||||
String timeCalcPropertyKey
|
String timeCalcPropertyKey
|
||||||
= (String) textField.getClientProperty(
|
= (String) textField.getClientProperty(
|
||||||
@ -812,14 +828,18 @@ public class ConfigWindow extends TWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void addLabelToNextRow(TimeCalcProperty timeCalcProperty) {
|
private void addLabelToNextRow(TimeCalcProperty timeCalcProperty) {
|
||||||
final JLabel jLabel = new JLabel(
|
// final JLabel jLabel = new JLabel(
|
||||||
timeCalcProperty.getDescription());
|
// timeCalcProperty.getDescription());
|
||||||
jLabel.putClientProperty(CLIENT_PROPERTY_KEY,timeCalcProperty.getKey());
|
// jLabel.putClientProperty(CLIENT_PROPERTY_KEY,timeCalcProperty.getKey());
|
||||||
addToNextRow(jLabel);
|
// addToNextRow(jLabel, false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addToNextRow(JComponent jComponent) {
|
private void addToNextRow(JComponent jComponent) {
|
||||||
int index = 4;
|
addToNextRow(jComponent, true);
|
||||||
|
}
|
||||||
|
private void addToNextRow(JComponent jComponent, boolean nextRow) {
|
||||||
|
int index = 6;
|
||||||
String key = (String) jComponent.getClientProperty(CLIENT_PROPERTY_KEY);
|
String key = (String) jComponent.getClientProperty(CLIENT_PROPERTY_KEY);
|
||||||
if(key == null) {
|
if(key == null) {
|
||||||
//nothing to do
|
//nothing to do
|
||||||
@ -827,26 +847,61 @@ public class ConfigWindow extends TWindow {
|
|||||||
}
|
}
|
||||||
if(key.startsWith("clock")) index = 0;
|
if(key.startsWith("clock")) index = 0;
|
||||||
if(key.startsWith("battery")) index = 1;
|
if(key.startsWith("battery")) index = 1;
|
||||||
if(key.startsWith("smileys")) index = 2;
|
if(key.startsWith("life")) index = 2;
|
||||||
if(key.startsWith("test")) index = 3;
|
if(key.startsWith("money")) index = 3;
|
||||||
|
if(key.startsWith("smileys")) index = 4;
|
||||||
|
if(key.startsWith("test")) index = 5;
|
||||||
|
|
||||||
JPanel panel = null;
|
JPanel panel = null;
|
||||||
switch(index) {
|
switch(index) {
|
||||||
case 0: panel=panelInsideScrollPaneClock;break;
|
case 0: panel=panelInsideScrollPaneClock;break;
|
||||||
case 1: panel=panelInsideScrollPaneBattery;break;
|
case 1: panel=panelInsideScrollPaneBattery;break;
|
||||||
case 2: panel=panelInsideScrollPaneSmileys;break;
|
case 2: panel=panelInsideScrollPaneLife;break;
|
||||||
case 3: panel=panelInsideScrollPaneTest;break;
|
case 3: panel=panelInsideScrollPaneMoney;break;
|
||||||
default:panel=panelInsideScrollPaneMisc;
|
case 4: panel=panelInsideScrollPaneSmileys;break;
|
||||||
|
case 5: panel=panelInsideScrollPaneTest;break;
|
||||||
|
default:panel= panelInsideScrollPaneOther;
|
||||||
}
|
}
|
||||||
panel.add(jComponent);
|
if(jComponent instanceof JTextField) {
|
||||||
jComponent.setBounds(SwingUtils.MARGIN, currentY[index], 200,
|
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);
|
||||||
|
|
||||||
|
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));
|
||||||
|
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 {
|
||||||
|
panel.add(jComponent);
|
||||||
|
}
|
||||||
|
|
||||||
|
jComponent.setBounds(currentX[index], currentY[index], 200,
|
||||||
HEIGHT1);
|
HEIGHT1);
|
||||||
panel.add(Box.createRigidArea(new Dimension(5, 10)));
|
panel.add(Box.createRigidArea(new Dimension(5, 5)));
|
||||||
nextRow(index);
|
if(nextRow) {
|
||||||
|
nextRow(index);
|
||||||
|
} else {
|
||||||
|
currentX[index] = currentX[index] + SwingUtils.MARGIN + jComponent.getWidth();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void nextRow(int index) {
|
private void nextRow(int index) {
|
||||||
currentY[index] = (int) (currentY[index] + 3.0d * SwingUtils.MARGIN);
|
currentY[index] = (int) (currentY[index] + 3.0d * SwingUtils.MARGIN);
|
||||||
|
currentX[index] = SwingUtils.MARGIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void doEnableEverything() {
|
public void doEnableEverything() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user