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

@@ -251,7 +251,10 @@ public class Toolbar extends JPanel {
date = new DateChooser(); date = new DateChooser();
Dimension dim = new Dimension(400, 250); Dimension dim = new Dimension(400, 250);
date.setMaximumSize(dim); 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; return date;
} }
@@ -353,6 +356,19 @@ public class Toolbar extends JPanel {
return panel; 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(){ public Toolbar nextPage(){
var page = t("PAGE"); var page = t("PAGE");
var panel = additonalComponents.get(page); var panel = additonalComponents.get(page);
@@ -486,6 +502,7 @@ public class Toolbar extends JPanel {
*/ */
private void updateCat(String newCat) { private void updateCat(String newCat) {
LOG.debug("updateCat({})",newCat); LOG.debug("updateCat({})",newCat);
resetPage();
categoryListeners.forEach(l -> l.setCategory(newCat)); categoryListeners.forEach(l -> l.setCategory(newCat));
LOG.debug("Listeners notified."); LOG.debug("Listeners notified.");
if (!newCat.isEmpty()) { if (!newCat.isEmpty()) {
@@ -553,6 +570,7 @@ public class Toolbar extends JPanel {
*/ */
protected void updatePath(String newPath) { protected void updatePath(String newPath) {
LOG.debug("updatePath({})",newPath); LOG.debug("updatePath({})",newPath);
resetPage();
pathListeners.forEach(l -> l.setPath(newPath)); pathListeners.forEach(l -> l.setPath(newPath));
} }
} }