better location for update accessors and controllers

This commit is contained in:
Ben Fry
2015-09-22 19:15:39 -04:00
parent 5f401d4fa1
commit 2c02fc6661
2 changed files with 19 additions and 9 deletions

View File

@@ -433,4 +433,18 @@ public class ContributionTab extends JPanel {
public void updateStatusPanel(DetailPanel contributionPanel) {
statusPanel.update(contributionPanel);
}
protected void updateAll() {
Collection<DetailPanel> collection =
contributionListPanel.panelByContribution.values();
for (DetailPanel detailPanel : collection) {
detailPanel.update();
}
}
protected boolean hasUpdates() {
return contributionListPanel.getRowCount() > 0;
}
}

View File

@@ -4,7 +4,6 @@ import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Collection;
import javax.swing.GroupLayout;
import javax.swing.JButton;
@@ -22,14 +21,13 @@ public class UpdateStatusPanel extends StatusPanel {
updateButton = new JButton("Update All", Toolkit.getLibIconX("manager/update"));
updateButton.setFont(Toolkit.getSansFont(14, Font.PLAIN));
updateButton.setHorizontalAlignment(SwingConstants.LEFT);
updateButton.setVisible(true);
updateButton.setEnabled(false);
updateButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
Collection<DetailPanel> c =
contributionTab.contributionListPanel.panelByContribution.values();
for (DetailPanel contributionPanel : c) {
contributionPanel.update();
}
contributionTab.updateAll();
}
});
setBackground(new Color(0xebebeb));
@@ -48,11 +46,9 @@ public class UpdateStatusPanel extends StatusPanel {
layout.setVerticalGroup(layout.createParallelGroup()
.addComponent(updateButton));
updateButton.setVisible(true);
updateButton.setEnabled(false);
}
public void update() {
updateButton.setEnabled(contributionTab.contributionListPanel.getRowCount() > 0);
updateButton.setEnabled(contributionTab.hasUpdates());
}
}