mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
Sorting by author name
This commit is contained in:
@@ -136,8 +136,16 @@ public class ContributionListPanel extends JPanel implements Scrollable, Contrib
|
||||
TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(table.getModel());
|
||||
table.setRowSorter(sorter);
|
||||
sorter.setComparator(1, contribListing.getComparator());
|
||||
sorter.setComparator(2, new Comparator<Contribution>() {
|
||||
|
||||
@Override
|
||||
public int compare(Contribution o1, Contribution o2) {
|
||||
return getAuthorNameWithoutMarkup(o1.getAuthorList())
|
||||
.compareTo(getAuthorNameWithoutMarkup(o2.getAuthorList()));
|
||||
}
|
||||
});
|
||||
sorter.setSortable(0, false);
|
||||
sorter.setSortable(2, false);
|
||||
sorter.setSortable(2, true);
|
||||
table.getTableHeader().setDefaultRenderer(new MyColumnHeaderRenderer());
|
||||
|
||||
GroupLayout layout = new GroupLayout(this);
|
||||
@@ -314,24 +322,8 @@ public class ContributionListPanel extends JPanel implements Scrollable, Contrib
|
||||
label = new JLabel(
|
||||
contribution.isSpecial() ? Toolkit
|
||||
.getLibIcon("icons/pde-16.png") : null);
|
||||
StringBuilder name = new StringBuilder("");
|
||||
String authorList = contribution.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));
|
||||
}
|
||||
}
|
||||
}
|
||||
String name = getAuthorNameWithoutMarkup(authorList);
|
||||
label.setText(name.toString());
|
||||
label.setHorizontalAlignment(SwingConstants.LEFT);
|
||||
if(!contribution.isCompatible(Base.getRevision())){
|
||||
@@ -347,7 +339,6 @@ public class ContributionListPanel extends JPanel implements Scrollable, Contrib
|
||||
}
|
||||
return label;
|
||||
}
|
||||
|
||||
}
|
||||
private class MyTableModel extends DefaultTableModel{
|
||||
MyTableModel() {
|
||||
@@ -362,6 +353,27 @@ public class ContributionListPanel extends JPanel implements Scrollable, Contrib
|
||||
return Contribution.class;
|
||||
}
|
||||
}
|
||||
|
||||
String getAuthorNameWithoutMarkup(String authorList) {
|
||||
StringBuilder name = new StringBuilder("");
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
return name.toString();
|
||||
}
|
||||
|
||||
void updatePanelOrdering(Set<Contribution> contributionsSet) {
|
||||
/* int row = 0;
|
||||
|
||||
Reference in New Issue
Block a user