implemented resetting page counter when changing project

Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
2023-03-05 17:57:51 +01:00
parent 19dd5e183a
commit 7cdccd1c04
2 changed files with 21 additions and 3 deletions

View File

@@ -600,7 +600,7 @@ public class MainFrame extends JFrame {
*/
@SuppressWarnings("deprecation")
private void updatePath() {
LOG.debug("updatePath() [path = {}]",path);
LOG.debug("updatePath() [path = {}]",path);
int year = 1900+date.getYear();
int month = date.getMonth()+1;
int day = date.getDate();

View File

@@ -251,7 +251,10 @@ public class Toolbar extends JPanel {
date = new DateChooser();
Dimension dim = new Dimension(400, 250);
date.setMaximumSize(dim);
date.addActionListener(ev -> dateListeners.forEach(listener -> listener.setDate(date.getSelectedDate())));
date.addActionListener(ev -> {
resetPage();
dateListeners.forEach(listener -> listener.setDate(date.getSelectedDate()));
});
return date;
}
@@ -353,6 +356,19 @@ public class Toolbar extends JPanel {
return panel;
}
public Toolbar resetPage(){
var page = t("PAGE");
var panel = additonalComponents.get(page);
if (panel == null) return this;
for (var child : panel.getComponents()){
if (child instanceof SelectComboBox scb){
scb.setText("1");
fieldListeners.forEach(l -> l.setField(page,"1"));
}
}
return this;
}
public Toolbar nextPage(){
var page = t("PAGE");
var panel = additonalComponents.get(page);
@@ -486,6 +502,7 @@ public class Toolbar extends JPanel {
*/
private void updateCat(String newCat) {
LOG.debug("updateCat({})",newCat);
resetPage();
categoryListeners.forEach(l -> l.setCategory(newCat));
LOG.debug("Listeners notified.");
if (!newCat.isEmpty()) {
@@ -515,7 +532,7 @@ public class Toolbar extends JPanel {
LOG.debug("h: {}",h);
height.setText(h == null ? Constants.DEFAULT_HEIGHT : h+"");
updateDimensions();
} else LOG.debug("newCat is empty!");
} else LOG.debug("newCat is empty!");
}
@@ -553,6 +570,7 @@ public class Toolbar extends JPanel {
*/
protected void updatePath(String newPath) {
LOG.debug("updatePath({})",newPath);
resetPage();
pathListeners.forEach(l -> l.setPath(newPath));
}
}