Added several improvements, changes and bug fixes

This commit is contained in:
Robert Vokac 2024-03-16 17:43:01 +00:00
parent 97aa529b62
commit 1af495ca5c
No known key found for this signature in database
GPG Key ID: 693D30BEE3329055
5 changed files with 35 additions and 5 deletions

View File

@ -96,7 +96,11 @@ public class ActivitiesWindow extends TWindow {
JTabbedPane sourceTabbedPane = (JTabbedPane) changeEvent.getSource();
int index = sourceTabbedPane.getSelectedIndex();
years.get(sourceTabbedPane.getTitleAt(index)).getMonthPanel("1").getDayPanel("1").load();
YearPanel yearPanel =
years.get(sourceTabbedPane.getTitleAt(index));
MonthPanel monthPanel = yearPanel.getMonthPanel("1");
monthPanel.load();
monthPanel.getDayPanel("1").load();
}
};
tp.addChangeListener(changeListener);

View File

@ -14,6 +14,9 @@ import javax.swing.JTextField;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.util.function.BiConsumer;
/**
@ -60,6 +63,12 @@ public class ActivityPanel extends JPanel implements Comparable<ActivityPanel> {
}
}
});
} else {
addMouseListener((MouseClickedListener) e -> {
Clipboard
clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(new StringSelection(getText()), null);
});
}
}

View File

@ -68,6 +68,7 @@ public class DayPanel extends JPanel {
//nothing to do
return;
}
System.out.println("Loaded: " + year + month + day);
if (this.loadButton.isVisible()) {
this.loadButton.setVisible(false);
this.loadButton = null;

View File

@ -21,9 +21,12 @@ public class MonthPanel extends JPanel {
private final Map<String, DayPanel> days;
private final TTabbedPane tp;
private final ActivityRepositoryApi activityRepository;
private final Calendar cal;
private boolean loaded = false;
public MonthPanel(String yearIn, String monthIn, ActivityRepositoryApi activityRepository) {
super();
this.activityRepository = activityRepository;
this.year = yearIn;
this.month = monthIn;
@ -49,17 +52,27 @@ public class MonthPanel extends JPanel {
};
tp.addChangeListener(changeListener);
Calendar cal = Calendar.getInstance();
this.cal = Calendar.getInstance();
cal.set(Calendar.YEAR, Integer.valueOf(year));
cal.set(Calendar.MONTH, Integer.valueOf(month) - 1);
cal.set(Calendar.DAY_OF_MONTH, 1);
}
public void load() {
if(loaded) {
//nothing to do
return;
}
System.out.println("Loaded: " + year + month);
int maxDay = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
for (int day = 1; day <= maxDay; day++) {
String dayS = String.valueOf(day);
DayPanel dayPanel = new DayPanel(year, month, dayS, activityRepository);
DayPanel dayPanel = new DayPanel(year, month, dayS,
activityRepository);
tp.add(dayS, dayPanel);
days.put(dayS, dayPanel);
}
loaded = true;
}
public void setSelectedDay(String day) {

View File

@ -38,7 +38,10 @@ public class YearPanel extends JPanel {
JTabbedPane sourceTabbedPane = (JTabbedPane) changeEvent.getSource();
int index = sourceTabbedPane.getSelectedIndex();
months.get(sourceTabbedPane.getTitleAt(index)).getDayPanel("1").load();
MonthPanel monthPanel =
months.get(sourceTabbedPane.getTitleAt(index));
monthPanel.load();
monthPanel.getDayPanel("1").load();
}
};
tp.addChangeListener(changeListener);