From d81ff0808ff68336bf39974d1571b985941b3d9a Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Tue, 22 Sep 2015 18:56:13 -0400 Subject: [PATCH] deal with section heads and other quirky ugliness --- .../app/contrib/ContributionType.java | 27 +++++++-- app/src/processing/app/contrib/ListPanel.java | 1 + .../app/contrib/UpdateContributionTab.java | 6 +- .../app/contrib/UpdateListPanel.java | 59 +++++++++++-------- todo.txt | 16 +++-- 5 files changed, 70 insertions(+), 39 deletions(-) diff --git a/app/src/processing/app/contrib/ContributionType.java b/app/src/processing/app/contrib/ContributionType.java index 3f55e98dd..e58c0f737 100644 --- a/app/src/processing/app/contrib/ContributionType.java +++ b/app/src/processing/app/contrib/ContributionType.java @@ -33,17 +33,17 @@ import processing.app.Util; import processing.app.ui.Editor; public enum ContributionType { - LIBRARY, TOOL, MODE, EXAMPLES; + LIBRARY, MODE, TOOL, EXAMPLES; public String toString() { switch (this) { case LIBRARY: return "library"; - case TOOL: - return "tool"; case MODE: return "mode"; + case TOOL: + return "tool"; case EXAMPLES: return "examples"; } @@ -61,6 +61,21 @@ public enum ContributionType { } + public String getPluralTitle() { + switch (this) { + case LIBRARY: + return "Libraries"; + case MODE: + return "Modes"; + case TOOL: + return "Tools"; + case EXAMPLES: + return "Examples"; + } + return null; // should be unreachable + } + + // public String getFolderName() { // return toString(); // /* @@ -115,12 +130,12 @@ public enum ContributionType { if ("library".equalsIgnoreCase(s)) { return LIBRARY; } - if ("tool".equalsIgnoreCase(s)) { - return TOOL; - } if ("mode".equalsIgnoreCase(s)) { return MODE; } + if ("tool".equalsIgnoreCase(s)) { + return TOOL; + } if ("examples".equalsIgnoreCase(s)) { return EXAMPLES; } diff --git a/app/src/processing/app/contrib/ListPanel.java b/app/src/processing/app/contrib/ListPanel.java index 419c7f2a4..8aeeb0d59 100644 --- a/app/src/processing/app/contrib/ListPanel.java +++ b/app/src/processing/app/contrib/ListPanel.java @@ -108,6 +108,7 @@ implements Scrollable, ContributionListing.ChangeListener { model.setColumnIdentifiers(colName); scrollPane = new JScrollPane(table); scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); + scrollPane.setBorder(BorderFactory.createEmptyBorder()); table.setFillsViewportHeight(true); table.setDefaultRenderer(Contribution.class, new ContribStatusRenderer()); table.setFont(plainFont); diff --git a/app/src/processing/app/contrib/UpdateContributionTab.java b/app/src/processing/app/contrib/UpdateContributionTab.java index b8275c981..00fbddb05 100644 --- a/app/src/processing/app/contrib/UpdateContributionTab.java +++ b/app/src/processing/app/contrib/UpdateContributionTab.java @@ -25,6 +25,8 @@ public class UpdateContributionTab extends ContributionTab { } }; contributionListPanel = new UpdateListPanel(this, filter); +// contributionListPanel.setBorder(new EmptyBorder(8, 8, 8, 8)); + statusPanel = new UpdateStatusPanel(this, 650); contribListing = ContributionListing.getInstance(); contribListing.addListener(contributionListPanel); @@ -49,12 +51,12 @@ public class UpdateContributionTab extends ContributionTab { layout.setHorizontalGroup(layout .createParallelGroup(GroupLayout.Alignment.CENTER) .addComponent(loaderLabel) - .addComponent(contributionListPanel).addComponent(errorPanel) + .addComponent(contributionListPanel) + .addComponent(errorPanel) .addComponent(statusPanel)); layout.setVerticalGroup(layout .createSequentialGroup() - .addGap(2) .addGroup(layout.createParallelGroup(GroupLayout.Alignment.CENTER) .addComponent(loaderLabel) .addComponent(contributionListPanel)) diff --git a/app/src/processing/app/contrib/UpdateListPanel.java b/app/src/processing/app/contrib/UpdateListPanel.java index 87f16e6d7..b2dc7ec2c 100644 --- a/app/src/processing/app/contrib/UpdateListPanel.java +++ b/app/src/processing/app/contrib/UpdateListPanel.java @@ -4,14 +4,15 @@ import java.awt.Color; import java.awt.Component; import java.awt.EventQueue; import java.awt.Font; +import java.util.Arrays; import java.util.Comparator; +import java.util.HashSet; 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; @@ -25,9 +26,16 @@ import processing.app.ui.Toolkit; public class UpdateListPanel extends ListPanel { + static final String[] PLURAL_TYPES = { + ContributionType.LIBRARY.getPluralTitle(), + ContributionType.MODE.getPluralTitle(), + ContributionType.TOOL.getPluralTitle(), + ContributionType.EXAMPLES.getPluralTitle(), + }; + Set sectionNames = new HashSet(Arrays.asList(PLURAL_TYPES)); public UpdateListPanel(ContributionTab contributionTab, - Contribution.Filter filter) { + Contribution.Filter filter) { this.contributionTab = contributionTab; this.filter = filter; @@ -55,10 +63,14 @@ public class UpdateListPanel extends ListPanel { 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("Library") || title.equals("Tools") - || title.equals("Modes") || title.equals("Examples")) { - ((JComponent) c).setBorder(BorderFactory - .createMatteBorder(row == 0 ? 0 : 2, 0, 2, 0, Color.BLACK)); + if (title.equals("Libraries") || + title.equals("Modes") || + title.equals("Tools") || + title.equals("Examples")) { + c.setBackground(new Color(0xFFf0f0f0)); + //((JComponent) c).setBorder(BorderFactory.createMatteBorder(row == 0 ? 0 : 1, 0, 1, 0, Color.GRAY)); + } else { + c.setBackground(Color.WHITE); } return c; } @@ -67,17 +79,19 @@ public class UpdateListPanel extends ListPanel { public void changeSelection(int rowIndex, int columnIndex, boolean toggle, boolean extend) { String title = (String) getValueAt(rowIndex, 1); - if (title.equals("Library") || - title.equals("Tools") || - title.equals("Modes") || - title.equals("Examples")){ - return; + // Disallow selection on the fake rows + if (!title.equals("Libraries") && + !title.equals("Modes") && + !title.equals("Tools") && + !title.equals("Examples")) { + super.changeSelection(rowIndex, columnIndex, toggle, extend); } - super.changeSelection(rowIndex, columnIndex, toggle, extend); } }; scrollPane = new JScrollPane(table); + scrollPane.setBorder(BorderFactory.createEmptyBorder()); + table.setFillsViewportHeight(true); table.setSelectionBackground(new Color(0xe0fffd)); table.setSelectionForeground(table.getForeground()); @@ -147,28 +161,23 @@ public class UpdateListPanel extends ListPanel { @Override void updatePanelOrdering(Set contributionsSet) { -// JLabel label = contributionTab.contribDialog.numberLabel; -// if (getNoOfRows() == 0) { -// label.setVisible(false); -// } else { -// label.setVisible(true); -// label.setText(Integer.toString(panelByContribution.size())); -// } +// int updateCount = panelByContribution.size(); +// new Exception("update count is " + updateCount).printStackTrace(System.out); +// (UpdateContributionTab) contributionTab + model.getDataVector().removeAllElements(); model.fireTableDataChanged(); - ContributionType temp = null; + ContributionType currentType = null; // Avoid ugly synthesized bold Font boldFont = Toolkit.getSansFont(table.getFont().getSize(), Font.BOLD); String fontFace = ""; for (Contribution entry : contributionsSet) { - if (entry.getType() != temp) { - temp = entry.getType(); + if (entry.getType() != currentType) { + currentType = entry.getType(); model.addRow(new Object[] { - null, - "" + temp.getTitle() + "", - null, null, null + null, currentType.getTitle(), null, null, null }); } //TODO Make this into a function diff --git a/todo.txt b/todo.txt index 58be9c1fe..4c97c342a 100644 --- a/todo.txt +++ b/todo.txt @@ -80,6 +80,10 @@ X https://github.com/processing/processing/issues/3643 o Contributions Manager UI design X https://github.com/processing/processing/issues/3482 X closing in favor of separate issues +X updates tab has ugly horizontal line at top +X CM selected tabs are too tall +X https://github.com/processing/processing/issues/3598 +X why the aqua background when opening the window? watcher X prevent re-prompting users when they say "no" to "sketch modified" message @@ -131,10 +135,7 @@ _ mouse events (i.e. toggle breakpoint) seem to be firing twice beta 7 -X CM selected tabs are too tall -X https://github.com/processing/processing/issues/3598 -X why the aqua background when opening the window? -_ bring back the # of updates on each tab +_ bring back the # of updates on the update tab _ use this instead of the 'icon' stuff _ show number of updates available in the footer _ https://github.com/processing/processing/issues/3518 @@ -167,17 +168,20 @@ _ list with contrib types separated is really wonky _ do we keep the list? _ does it even work for different contrib types? + manager / 3.0 final -_ updates tab has ugly horizontal line at top _ status/name/author table header is alternating color _ area above scroll bar looks like more scroll bar +_ table header is the wrong font +_ updates panel has the gray across, but nothing above the scrollbar _ remove focus blue from the scrollable list _ scrolling "past" top/bottom causes the screen to jiggle (OS X and Trackpad) _ looks like ContributionListing.getScrollableUnitIncrement() returns early +_ get rid of gross italic subheads on the Updates page gui / post 3.0 -_ build custom scroll bar since the OS versions are so ugly? +_ build custom scroll bar since the OS versions are so ugly _ error/warning location is awkward when no scroll bar is in use _ when only one screen-full, show ticks at exact location _ simpler/less confusing to not show at all?