Merge pull request #3465 from Akarshit/gsoc-CMtable

Made update classes into one
This commit is contained in:
Ben Fry
2015-07-15 16:17:24 -04:00
6 changed files with 366 additions and 326 deletions
@@ -241,6 +241,10 @@ public class ContributionListPanel extends JPanel implements Scrollable, Contrib
class StatusRendere extends DefaultTableCellRenderer {
@Override
public void setVerticalAlignment(int alignment) {
super.setVerticalAlignment(SwingConstants.CENTER);
}
@Override
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected,
@@ -250,7 +254,7 @@ public class ContributionListPanel extends JPanel implements Scrollable, Contrib
JLabel label = new JLabel();
if (column == 0) {
Icon icon = null;
label.setBorder(BorderFactory.createEmptyBorder(0, 17, 0, 0));
label.setBorder(BorderFactory.createEmptyBorder(2, 17, 0, 0));
if (contribution.isInstalled()) {
icon = Toolkit.getLibIcon("manager/up-to-date.png");
if (contribListing.hasUpdates(contribution)) {
@@ -267,6 +271,7 @@ public class ContributionListPanel extends JPanel implements Scrollable, Contrib
label.setOpaque(true);
// return table.getDefaultRenderer(Icon.class).getTableCellRendererComponent(table, icon, isSelected, false, row, column);
} else if (column == 1) {
//TODO add ellipses, currently the height of JTextPane = height of font + 4
JTextPane name = new JTextPane();
name.setContentType("text/html");
name.setEditable(false);
@@ -275,23 +280,31 @@ public class ContributionListPanel extends JPanel implements Scrollable, Contrib
}
name.setText("<html><body><b>" + contribution.getName() + "</b> - "
+ contribution.getSentence() + "</body></html>");
int textHeight = table.getFontMetrics(table.getFont().deriveFont(Font.BOLD)).getHeight() + 4;
GroupLayout layout = new GroupLayout(label);
layout.setAutoCreateGaps(true);
layout.setHorizontalGroup(layout.createSequentialGroup()
.addComponent(name));
layout
.setVerticalGroup(layout.createParallelGroup().addComponent(name));
layout.setVerticalGroup(layout
.createSequentialGroup()
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED,
GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE)
.addComponent(name, 0,
textHeight,
textHeight)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED,
GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE));
if (table.isRowSelected(row)) {
name.setBackground(Color.BLUE);
name.setOpaque(true);
label.setBackground(Color.BLUE);
name.setOpaque(false);
}
label.setOpaque(true);
label.setLayout(layout);
} else {
JLabel icon = new JLabel(
label = new JLabel(
contribution.isSpecial() ? Toolkit
.getLibIcon("icons/pde-16.png") : null);
JTextPane author = new JTextPane();
StringBuilder name = new StringBuilder("");
String authorList = contribution.getAuthorList();
if (authorList != null) {
@@ -310,24 +323,14 @@ public class ContributionListPanel extends JPanel implements Scrollable, Contrib
}
}
}
author.setText(name.toString());
author.setEditable(false);
author.setOpaque(false);
label.setText(name.toString());
label.setHorizontalAlignment(SwingConstants.LEFT);
if(!contribution.isCompatible(Base.getRevision())){
author.setForeground(Color.LIGHT_GRAY);
label.setForeground(Color.LIGHT_GRAY);
}
if (table.isRowSelected(row)) {
label.setBackground(Color.BLUE);
}
GroupLayout layout = new GroupLayout(label);
// layout.setAutoCreateGaps(true);
layout.setHorizontalGroup(layout.createSequentialGroup()
.addContainerGap().addComponent(icon).addComponent(author));
layout.setVerticalGroup(layout
.createParallelGroup(GroupLayout.Alignment.CENTER)
.addComponent(author).addComponent(icon));
label.setLayout(layout);
label.setOpaque(true);
}
return label;
@@ -63,19 +63,18 @@ public class ContributionManagerDialog {
ContributionTab librariesContributionTab;
ContributionTab examplesContributionTab;
ContributionTab modesContributionTab;
ContributionTab updatesContributionTab;
UpdateContributionTab updatesContributionTab;
JLabel numberLabel;
ContributionListing contributionListing = ContributionListing.getInstance();
public ContributionManagerDialog() {
numberLabel = new JLabel();
numberLabel = new JLabel(Toolkit.getLibIcon("manager/notification.png"), SwingConstants.CENTER);
toolsContributionTab = new ContributionTab(ContributionType.TOOL, this);
librariesContributionTab = new ContributionTab(ContributionType.LIBRARY, this);
modesContributionTab = new ContributionTab(ContributionType.MODE, this);
examplesContributionTab = new ContributionTab(ContributionType.EXAMPLES, this);
updatesContributionTab = new ContributionTab(null, this);
updatesContributionTab = new UpdateContributionTab(null, this);
}
public boolean hasUpdates() {
@@ -147,10 +146,9 @@ public class ContributionManagerDialog {
JPanel updateTabPanel = new JPanel(true);
numberLabel.setOpaque(false);
numberLabel.setBorder(BorderFactory.createEmptyBorder(0, 6, 0, 0));
JLabel numberBackground = new JLabel(Toolkit.getLibIcon("manager/notification.png"));
JLabel updateTabLabel = new JLabel("Update");
numberLabel.setVerticalTextPosition(SwingConstants.CENTER);
numberLabel.setHorizontalTextPosition(SwingConstants.CENTER);
updateTabPanel.setOpaque(false);
updateTabPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory
.createMatteBorder(0, 2, 0, 0, Color.BLACK), BorderFactory
@@ -173,10 +171,10 @@ public class ContributionManagerDialog {
updateTabPanel.setLayout(tabLayout);
tabLayout.setHorizontalGroup(tabLayout
.createSequentialGroup()
.addGroup(tabLayout.createParallelGroup().addComponent(numberLabel)
.addComponent(numberBackground)).addComponent(updateTabLabel));
.addComponent(numberLabel)
.addComponent(updateTabLabel));
tabLayout.setVerticalGroup(tabLayout.createParallelGroup(GroupLayout.Alignment.CENTER)
.addComponent(numberBackground).addComponent(numberLabel)
.addComponent(numberLabel)
.addComponent(updateTabLabel));
tabbedPane.addChangeListener(new ChangeListener() {
@@ -68,39 +68,31 @@ public class ContributionTab {
public ContributionTab(ContributionType type,ContributionManagerDialog contributionManagerDialog) {
if (type == null) {
title = Language.text("contrib.manager_title.update");
filter = ContributionType.createUpdateFilter();
} else {
if (type == ContributionType.MODE) {
title = Language.text("contrib.manager_title.mode");
}
else if (type == ContributionType.TOOL) {
title = Language.text("contrib.manager_title.tool");
}
else if (type == ContributionType.LIBRARY) {
title = Language.text("contrib.manager_title.library");
}
else if (type == ContributionType.EXAMPLES) {
title = Language.text("contrib.manager_title.examples");
}
filter = type.createFilter();
if (type == ContributionType.MODE) {
title = Language.text("contrib.manager_title.mode");
} else if (type == ContributionType.TOOL) {
title = Language.text("contrib.manager_title.tool");
} else if (type == ContributionType.LIBRARY) {
title = Language.text("contrib.manager_title.library");
} else if (type == ContributionType.EXAMPLES) {
title = Language.text("contrib.manager_title.examples");
}
filter = type.createFilter();
this.contributionType = type;
this.contributionManagerDialog = contributionManagerDialog;
contribListing = ContributionListing.getInstance();
if (contributionType == null) {
contributionListPanel = new UpdateContribListingPanel(this, filter);
statusPanel = new UpdateStatusPanel(650, this);
} else {
statusPanel = new StatusPanel(650,this);
contributionListPanel = new ContributionListPanel(this, filter);
}
contribListing.addContributionListener(contributionListPanel);
}
public ContributionTab() {
// TODO Auto-generated constructor stub
}
public boolean hasUpdates() {
return contribListing.hasUpdates();
}
@@ -264,7 +256,7 @@ public class ContributionTab {
buildErrorPanel();
}
private void buildErrorPanel(){
void buildErrorPanel(){
errorPanel = new JPanel();
GroupLayout layout = new GroupLayout(errorPanel);
layout.setAutoCreateGaps(true);
@@ -1,222 +0,0 @@
package processing.app.contrib;
import java.awt.Color;
import java.awt.Component;
import java.util.Comparator;
import java.util.Set;
import java.util.TreeMap;
import javax.swing.BorderFactory;
import javax.swing.GroupLayout;
import javax.swing.Icon;
import javax.swing.JComponent;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.UIManager;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.JTableHeader;
import javax.swing.table.TableCellRenderer;
import processing.app.Base;
import processing.app.ui.Toolkit;
public class UpdateContribListingPanel extends ContributionListPanel {
public UpdateContribListingPanel(ContributionTab contributionTab,
ContributionFilter filter) {
super.contributionTab = contributionTab;
super.filter = filter;
setOpaque(true);
if (Base.isLinux()) {
// Because of a bug with GNOME, getColor returns the wrong value for
// List.background. We'll just assume its white. The number of people
// using Linux and an inverted color theme should be small enough.
setBackground(Color.white);
} else {
setBackground(UIManager.getColor("List.background"));
}
// statusPlaceholder = new JPanel();
// statusPlaceholder.setVisible(false);
// status = new StatusPanel(null);
String[] colName = { "", "Name", "Author", "Installed", "Update To" };
dtm = new MyTableModel();
dtm.setColumnIdentifiers(colName);
table = new JTable(dtm){
@Override
public Component prepareRenderer(
TableCellRenderer renderer, int row, int column) {
Component c = super.prepareRenderer(renderer, row, column);
String title = (String) getValueAt(row, 1);
if (title.equals("<html><i>Library</i></html>") || title.equals("Tools")
|| title.equals("Modes") || title.equals("Examples")) {
((JComponent) c).setBorder(BorderFactory
.createMatteBorder(row == 0 ? 0 : 2, 0, 2, 0, Color.BLACK));
}
return c;
}
@Override
public void changeSelection(int rowIndex, int columnIndex,
boolean toggle, boolean extend) {
String title = (String) getValueAt(rowIndex, 1);
if(title.equals("<html><i>Library</i></html>")){
return;
}
super.changeSelection(rowIndex, columnIndex, toggle, extend);
}
// @Override
// public boolean isRowSelected(int row) {
// if (row == 0) {
// return false;
// }
// return super.isRowSelected(row);
// }
};
JScrollPane scrollPane = new JScrollPane(table);
table.setFillsViewportHeight(true);
table.setRowHeight(30);
table.setRowMargin(6);
table.getColumnModel().setColumnMargin(-1);
table.getColumnModel().getColumn(0).setMaxWidth(60);
table.setShowGrid(false);
table.setCellSelectionEnabled(false);
table.setRowSelectionAllowed(true);
table.setAutoCreateColumnsFromModel(true);
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
table.getTableHeader().setDefaultRenderer(new MyColumnHeaderRenderer() {
@Override
public Component getTableCellRendererComponent(JTable table,
Object value,
boolean isSelected,
boolean hasFocus, int row,
int column) {
super.getTableCellRendererComponent(table, value, isSelected, hasFocus,
row, column);
JTableHeader tableHeader = table.getTableHeader();
if (tableHeader != null) {
setForeground(tableHeader.getForeground());
}
setIcon(getIcon(table, column));
setBackground(Color.WHITE);
setBorder(BorderFactory.createMatteBorder(2, 0, 2, 0, Color.BLACK));
return this;
}
});
GroupLayout layout = new GroupLayout(this);
layout.setHorizontalGroup(layout.createParallelGroup().addComponent(scrollPane));
layout.setVerticalGroup(layout.createSequentialGroup().addComponent(scrollPane));
this.setLayout(layout);
table.setVisible(true);
panelByContribution = new TreeMap<Contribution, ContributionPanel>(new Comparator<Contribution>() {
@Override
public int compare(Contribution o1, Contribution o2) {
int val1 = 0;
int val2 = 0;
switch(o1.getType()){
case LIBRARY: val1 = 1;
break;
case TOOL: val1 = 2;
break;
case MODE: val1 = 3;
break;
case EXAMPLES: val1 = 4;
break;
}
switch(o2.getType()){
case LIBRARY: val2 = 1;
break;
case TOOL: val2 = 2;
break;
case MODE: val2 = 3;
break;
case EXAMPLES: val2 = 4;
break;
}
if(val1 == val2){
return o1.getName().toLowerCase().compareTo(o2.getName().toLowerCase());
}
return val1 - val2;
}
});
}
//
// @Override
// public void contributionAdded(Contribution contribution) {
// if(filter.matches(contribution)){
// super.contributionAdded(contribution);
// }
// }
//
@Override
void updatePanelOrdering(Set<Contribution> contributionsSet) {
contributionTab.contributionManagerDialog.numberLabel.setText(Integer
.toString(panelByContribution.size()));
dtm.getDataVector().removeAllElements();
dtm.fireTableDataChanged();
ContributionType temp = null;
for (Contribution entry : contributionsSet) {
if(entry.getType() != temp){
temp = entry.getType();
dtm.addRow(new Object[] { null, "<html><i>" + temp.getTitle() + "</i></html>", null, null, null });
}
//TODO Make this into a function
StringBuilder name = new StringBuilder("");
String authorList = entry.getAuthorList();
if (authorList != null) {
for (int i = 0; i < authorList.length(); i++) {
if (authorList.charAt(i) == '[' || authorList.charAt(i) == ']') {
continue;
}
if (authorList.charAt(i) == '(') {
i++;
while (authorList.charAt(i) != ')') {
i++;
}
} else {
name.append(authorList.charAt(i));
}
}
}
Icon icon = null;
if (entry.isInstalled()) {
icon = Toolkit.getLibIcon("manager/up-to-date.png");
if (contribListing.hasUpdates(entry)) {
icon = Toolkit.getLibIcon("manager/update-available.png");
}
if (!entry.isCompatible(Base.getRevision())) {
icon = Toolkit.getLibIcon("manager/incompatible.png");
}
}
dtm
.addRow(new Object[] {
icon, "<html><b>" + entry.getName() + "</b></html>", name, entry.getPrettyVersion(),
contributionTab.contribListing.getLatestVersion(entry) });
}
}
private class MyTableModel extends DefaultTableModel{
MyTableModel() {
super(0,0);
}
@Override
public boolean isCellEditable(int row, int column) {
return false;
}
@Override
public Class<?> getColumnClass(int columnIndex) {
if(columnIndex == 0){
return Icon.class;
}
return super.getColumnClass(columnIndex);
}
}
}
@@ -0,0 +1,318 @@
package processing.app.contrib;
import java.awt.Color;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Comparator;
import java.util.Set;
import java.util.TreeMap;
import javax.swing.BorderFactory;
import javax.swing.GroupLayout;
import javax.swing.Icon;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.LayoutStyle;
import javax.swing.ListSelectionModel;
import javax.swing.SwingConstants;
import javax.swing.UIManager;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.JTableHeader;
import javax.swing.table.TableCellRenderer;
import processing.app.Base;
import processing.app.ui.Editor;
import processing.app.ui.Toolkit;
public class UpdateContributionTab extends ContributionTab {
public UpdateContributionTab(ContributionType type,ContributionManagerDialog contributionManagerDialog) {
super();
filter = ContributionType.createUpdateFilter();
contributionListPanel = new UpdateContribListingPanel(this, filter);
statusPanel = new UpdateStatusPanel(650, this);
this.contributionType = type;
this.contributionManagerDialog = contributionManagerDialog;
contribListing = ContributionListing.getInstance();
contribListing.addContributionListener(contributionListPanel);
}
@Override
public void setLayout(Editor editor, boolean activateErrorPanel,
boolean isLoading) {
if (panel == null) {
progressBar = new JProgressBar();
progressBar.setVisible(false);
buildErrorPanel();
panel = new JPanel(false);
loaderLabel = new JLabel(Toolkit.getLibIcon("icons/loader.gif"));
loaderLabel.setOpaque(false);
loaderLabel.setBackground(Color.WHITE);
}
GroupLayout layout = new GroupLayout(panel);
panel.setLayout(layout);
layout.setHorizontalGroup(layout
.createParallelGroup(GroupLayout.Alignment.CENTER)
.addComponent(loaderLabel)
.addComponent(contributionListPanel).addComponent(errorPanel)
.addComponent(statusPanel));
layout.setVerticalGroup(layout
.createSequentialGroup()
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.CENTER)
.addComponent(loaderLabel)
.addComponent(contributionListPanel))
.addComponent(errorPanel)
.addComponent(statusPanel, GroupLayout.PREFERRED_SIZE,
GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE));
layout.setHonorsVisibility(contributionListPanel, false);
panel.setBackground(Color.WHITE);
panel.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2));
}
public class UpdateContribListingPanel extends ContributionListPanel {
public UpdateContribListingPanel(ContributionTab contributionTab,
ContributionFilter filter) {
super.contributionTab = contributionTab;
super.filter = filter;
setOpaque(true);
if (Base.isLinux()) {
// Because of a bug with GNOME, getColor returns the wrong value for
// List.background. We'll just assume its white. The number of people
// using Linux and an inverted color theme should be small enough.
setBackground(Color.white);
} else {
setBackground(UIManager.getColor("List.background"));
}
// statusPlaceholder = new JPanel();
// statusPlaceholder.setVisible(false);
// status = new StatusPanel(null);
String[] colName = { "", "Name", "Author", "Installed", "Update To" };
dtm = new MyTableModel();
dtm.setColumnIdentifiers(colName);
table = new JTable(dtm){
@Override
public Component prepareRenderer(
TableCellRenderer renderer, int row, int column) {
Component c = super.prepareRenderer(renderer, row, column);
String title = (String) getValueAt(row, 1);
if (title.equals("<html><i>Library</i></html>") || title.equals("Tools")
|| title.equals("Modes") || title.equals("Examples")) {
((JComponent) c).setBorder(BorderFactory
.createMatteBorder(row == 0 ? 0 : 2, 0, 2, 0, Color.BLACK));
}
return c;
}
@Override
public void changeSelection(int rowIndex, int columnIndex,
boolean toggle, boolean extend) {
String title = (String) getValueAt(rowIndex, 1);
if(title.equals("<html><i>Library</i></html>")){
return;
}
super.changeSelection(rowIndex, columnIndex, toggle, extend);
}
// @Override
// public boolean isRowSelected(int row) {
// if (row == 0) {
// return false;
// }
// return super.isRowSelected(row);
// }
};
JScrollPane scrollPane = new JScrollPane(table);
table.setFillsViewportHeight(true);
table.setRowHeight(30);
table.setRowMargin(6);
table.getColumnModel().setColumnMargin(-1);
table.getColumnModel().getColumn(0).setMaxWidth(60);
table.setShowGrid(false);
table.setCellSelectionEnabled(false);
table.setRowSelectionAllowed(true);
table.setAutoCreateColumnsFromModel(true);
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
table.getTableHeader().setDefaultRenderer(new MyColumnHeaderRenderer() {
@Override
public Component getTableCellRendererComponent(JTable table,
Object value,
boolean isSelected,
boolean hasFocus, int row,
int column) {
super.getTableCellRendererComponent(table, value, isSelected, hasFocus,
row, column);
JTableHeader tableHeader = table.getTableHeader();
if (tableHeader != null) {
setForeground(tableHeader.getForeground());
}
setIcon(getIcon(table, column));
setBackground(Color.WHITE);
setBorder(BorderFactory.createMatteBorder(2, 0, 2, 0, Color.BLACK));
return this;
}
});
GroupLayout layout = new GroupLayout(this);
layout.setHorizontalGroup(layout.createParallelGroup().addComponent(scrollPane));
layout.setVerticalGroup(layout.createSequentialGroup().addComponent(scrollPane));
this.setLayout(layout);
table.setVisible(true);
panelByContribution = new TreeMap<Contribution, ContributionPanel>(new Comparator<Contribution>() {
@Override
public int compare(Contribution o1, Contribution o2) {
int val1 = 0;
int val2 = 0;
switch(o1.getType()){
case LIBRARY: val1 = 1;
break;
case TOOL: val1 = 2;
break;
case MODE: val1 = 3;
break;
case EXAMPLES: val1 = 4;
break;
}
switch(o2.getType()){
case LIBRARY: val2 = 1;
break;
case TOOL: val2 = 2;
break;
case MODE: val2 = 3;
break;
case EXAMPLES: val2 = 4;
break;
}
if(val1 == val2){
return o1.getName().toLowerCase().compareTo(o2.getName().toLowerCase());
}
return val1 - val2;
}
});
}
//
// @Override
// public void contributionAdded(Contribution contribution) {
// if(filter.matches(contribution)){
// super.contributionAdded(contribution);
// }
// }
//
@Override
void updatePanelOrdering(Set<Contribution> contributionsSet) {
contributionTab.contributionManagerDialog.numberLabel.setText(Integer
.toString(panelByContribution.size()));
dtm.getDataVector().removeAllElements();
dtm.fireTableDataChanged();
ContributionType temp = null;
for (Contribution entry : contributionsSet) {
if(entry.getType() != temp){
temp = entry.getType();
dtm.addRow(new Object[] { null, "<html><i>" + temp.getTitle() + "</i></html>", null, null, null });
}
//TODO Make this into a function
StringBuilder name = new StringBuilder("");
String authorList = entry.getAuthorList();
if (authorList != null) {
for (int i = 0; i < authorList.length(); i++) {
if (authorList.charAt(i) == '[' || authorList.charAt(i) == ']') {
continue;
}
if (authorList.charAt(i) == '(') {
i++;
while (authorList.charAt(i) != ')') {
i++;
}
} else {
name.append(authorList.charAt(i));
}
}
}
Icon icon = null;
if (entry.isInstalled()) {
icon = Toolkit.getLibIcon("icons/installedAndUptodate.png");
if (contribListing.hasUpdates(entry)) {
icon = Toolkit.getLibIcon("icons/installedNeedsUpdate.png");
}
if (!entry.isCompatible(Base.getRevision())) {
icon = Toolkit.getLibIcon("icons/installedIncompatible.png");
}
}
dtm
.addRow(new Object[] {
icon, "<html><b>" + entry.getName() + "</b></html>", name, entry.getPrettyVersion(),
contributionTab.contribListing.getLatestVersion(entry) });
}
}
private class MyTableModel extends DefaultTableModel{
MyTableModel() {
super(0,0);
}
@Override
public boolean isCellEditable(int row, int column) {
return false;
}
@Override
public Class<?> getColumnClass(int columnIndex) {
if(columnIndex == 0){
return Icon.class;
}
return super.getColumnClass(columnIndex);
}
}
}
public class UpdateStatusPanel extends StatusPanel {
public UpdateStatusPanel(int width, final ContributionTab contributionTab) {
super();
updateButton = new JButton("Update All");
updateButton.setContentAreaFilled(false);
updateButton.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.BLACK, 1),BorderFactory.createEmptyBorder(3, 0, 3, 0)));
updateButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
for(ContributionPanel contributionPanel : contributionTab.contributionListPanel.panelByContribution.values()){
contributionPanel.update();
}
}
});
this.setBackground(Color.WHITE);
this.setBorder(BorderFactory.createMatteBorder(2, 0, 0, 0, Color.BLACK));
layout = new GroupLayout(this);
this.setLayout(layout);
layout.setAutoCreateContainerGaps(true);
layout.setAutoCreateGaps(true);
layout.setHorizontalGroup(layout
.createSequentialGroup()
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED,
GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE)
.addComponent(updateButton, BUTTON_WIDTH, BUTTON_WIDTH, BUTTON_WIDTH));
layout.setVerticalGroup(layout.createParallelGroup()
.addComponent(updateButton));
updateButton.setVisible(true);
}
@Override
public void update(ContributionPanel panel) {
}
}
}
@@ -1,49 +0,0 @@
package processing.app.contrib;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BorderFactory;
import javax.swing.GroupLayout;
import javax.swing.JButton;
import javax.swing.LayoutStyle;
public class UpdateStatusPanel extends StatusPanel {
public UpdateStatusPanel(int width, final ContributionTab contributionTab) {
super();
updateButton = new JButton("Update All");
updateButton.setContentAreaFilled(false);
updateButton.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.BLACK, 1),BorderFactory.createEmptyBorder(3, 0, 3, 0)));
updateButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
for(ContributionPanel contributionPanel : contributionTab.contributionListPanel.panelByContribution.values()){
contributionPanel.update();
}
}
});
this.setBackground(Color.WHITE);
this.setBorder(BorderFactory.createMatteBorder(2, 0, 0, 0, Color.BLACK));
layout = new GroupLayout(this);
this.setLayout(layout);
layout.setAutoCreateContainerGaps(true);
layout.setAutoCreateGaps(true);
layout.setHorizontalGroup(layout
.createSequentialGroup()
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED,
GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE)
.addComponent(updateButton, BUTTON_WIDTH, BUTTON_WIDTH, BUTTON_WIDTH));
layout.setVerticalGroup(layout.createParallelGroup()
.addComponent(updateButton));
updateButton.setVisible(true);
}
@Override
public void update(ContributionPanel panel) {
}
}