From 9f68d4df74ab290bc288d7f219c5fd838d46e27c Mon Sep 17 00:00:00 2001 From: Federico Fissore Date: Mon, 9 Mar 2015 09:59:35 +0100 Subject: [PATCH] First round of UX feedback --- .../ui/ContributedLibraryTableCell.java | 58 +++++++++--------- .../ui/LibrariesIndexTableModel.java | 41 ++++++++----- .../contributions/ui/LibraryManagerUI.java | 3 +- .../ui/ContributedPlatformTableCell.java | 61 ++++++++++--------- app/src/cc/arduino/ui/DropdownALLItem.java | 15 +++++ app/src/cc/arduino/ui/DropdownItem.java | 6 ++ app/src/cc/arduino/ui/InstallerJDialog.java | 14 ++++- app/src/processing/app/Base.java | 17 +++--- 8 files changed, 128 insertions(+), 87 deletions(-) create mode 100644 app/src/cc/arduino/ui/DropdownALLItem.java create mode 100644 app/src/cc/arduino/ui/DropdownItem.java diff --git a/app/src/cc/arduino/libraries/contributions/ui/ContributedLibraryTableCell.java b/app/src/cc/arduino/libraries/contributions/ui/ContributedLibraryTableCell.java index 9e6fe1950..6681dc0f9 100644 --- a/app/src/cc/arduino/libraries/contributions/ui/ContributedLibraryTableCell.java +++ b/app/src/cc/arduino/libraries/contributions/ui/ContributedLibraryTableCell.java @@ -28,38 +28,26 @@ */ package cc.arduino.libraries.contributions.ui; -import static processing.app.I18n._; -import static processing.app.I18n.format; +import cc.arduino.libraries.contributions.ContributedLibrary; +import cc.arduino.libraries.contributions.ui.LibrariesIndexTableModel.ContributedLibraryReleases; +import cc.arduino.ui.InstallerTableCell; +import processing.app.Base; -import java.awt.Color; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; - -import javax.swing.Box; -import javax.swing.BoxLayout; -import javax.swing.JButton; -import javax.swing.JComboBox; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JTable; -import javax.swing.JTextPane; -import javax.swing.Timer; +import javax.swing.*; import javax.swing.border.EmptyBorder; import javax.swing.event.HyperlinkEvent; import javax.swing.event.HyperlinkListener; import javax.swing.text.Document; import javax.swing.text.html.HTMLDocument; import javax.swing.text.html.StyleSheet; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; -import processing.app.Base; -import cc.arduino.libraries.contributions.ContributedLibrary; -import cc.arduino.libraries.contributions.ui.LibrariesIndexTableModel.ContributedLibraryReleases; -import cc.arduino.ui.InstallerTableCell; +import static processing.app.I18n._; +import static processing.app.I18n.format; @SuppressWarnings("serial") public class ContributedLibraryTableCell extends InstallerTableCell { @@ -213,7 +201,14 @@ public class ContributedLibraryTableCell extends InstallerTableCell { int column) { parentTable = table; setEnabled(false); - return getUpdatedCellComponent(value, isSelected, row); + Component component = getUpdatedCellComponent(value, isSelected, row); + if (row % 2 == 0) { + component.setBackground(new Color(236, 241, 241)); //#ecf1f1 + } else { + component.setBackground(new Color(255, 255, 255)); + } + + return component; } private ContributedLibraryReleases editorValue; @@ -241,10 +236,12 @@ public class ContributedLibraryTableCell extends InstallerTableCell { downgradeChooser.addItem(release); visible = true; } - downgradeChooser.setVisible(visible); - downgradeButton.setVisible(visible); + downgradeChooser.setVisible(visible && editorValue.releases.size() > 1); + downgradeButton.setVisible(visible && editorValue.releases.size() > 1); - return getUpdatedCellComponent(value, true, row); + Component component = getUpdatedCellComponent(value, true, row); + component.setBackground(new Color(218, 227, 227)); //#dae3e3 + return component; } private Component getUpdatedCellComponent(Object value, boolean isSelected, int row) { @@ -293,7 +290,7 @@ public class ContributedLibraryTableCell extends InstallerTableCell { // ...author... desc += format("", midcolor); if (author != null && !author.isEmpty()) { - desc += format(" by {1}", website, author); + desc += format(" by {0}", author); } // ...version. @@ -315,6 +312,9 @@ public class ContributedLibraryTableCell extends InstallerTableCell { desc += format("{0}", paragraph); desc += "
"; } + if (author != null && !author.isEmpty()) { + desc += format("More info", website); + } desc += ""; description.setText(desc); diff --git a/app/src/cc/arduino/libraries/contributions/ui/LibrariesIndexTableModel.java b/app/src/cc/arduino/libraries/contributions/ui/LibrariesIndexTableModel.java index 7293ccdce..d78c2b13b 100644 --- a/app/src/cc/arduino/libraries/contributions/ui/LibrariesIndexTableModel.java +++ b/app/src/cc/arduino/libraries/contributions/ui/LibrariesIndexTableModel.java @@ -28,18 +28,18 @@ */ package cc.arduino.libraries.contributions.ui; -import static cc.arduino.packages.contributions.VersionComparator.VERSION_COMPARATOR; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - import cc.arduino.libraries.contributions.ContributedLibrary; import cc.arduino.libraries.contributions.LibrariesIndexer; import cc.arduino.packages.contributions.ContributedPackage; import cc.arduino.packages.contributions.ContributedPlatform; import cc.arduino.ui.FilteredAbstractTableModel; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import static cc.arduino.packages.contributions.VersionComparator.VERSION_COMPARATOR; + @SuppressWarnings("serial") public class LibrariesIndexTableModel extends FilteredAbstractTableModel { @@ -144,17 +144,25 @@ public class LibrariesIndexTableModel extends FilteredAbstractTableModel { * compare is case insensitive. * * @param string - * @param set + * @param filters * @return true if all the strings in set are contained in * string. */ - private boolean stringContainsAll(String string, String set[]) { - if (set == null) - return true; - for (String s : set) { - if (!string.toLowerCase().contains(s.toLowerCase())) - return false; + private boolean stringContainsAll(String string, String filters[]) { + if (string == null) { + return false; } + + if (filters == null) { + return true; + } + + for (String filter : filters) { + if (!string.toLowerCase().contains(filter.toLowerCase())) { + return false; + } + } + return true; } @@ -229,12 +237,13 @@ public class LibrariesIndexTableModel extends FilteredAbstractTableModel { private void applyFilterToLibrary(ContributedLibrary lib) { if (selectedCategory != null && !selectedCategory.isEmpty()) { - if (lib.getCategory() == null || - !lib.getCategory().equals(selectedCategory)) + if (lib.getCategory() == null || !lib.getCategory().equals(selectedCategory)) { return; + } } - if (!stringContainsAll(lib.getName(), selectedFilters)) + if (!stringContainsAll(lib.getName(), selectedFilters) && !stringContainsAll(lib.getParagraph(), selectedFilters) && !stringContainsAll(lib.getSentence(), selectedFilters)) { return; + } addContribution(lib); } diff --git a/app/src/cc/arduino/libraries/contributions/ui/LibraryManagerUI.java b/app/src/cc/arduino/libraries/contributions/ui/LibraryManagerUI.java index 8ee0ba3e9..712cf0eb9 100644 --- a/app/src/cc/arduino/libraries/contributions/ui/LibraryManagerUI.java +++ b/app/src/cc/arduino/libraries/contributions/ui/LibraryManagerUI.java @@ -31,6 +31,7 @@ package cc.arduino.libraries.contributions.ui; import cc.arduino.libraries.contributions.ContributedLibrary; import cc.arduino.libraries.contributions.LibrariesIndexer; import cc.arduino.packages.contributions.ui.InstallerJDialogUncaughtExceptionHandler; +import cc.arduino.ui.DropdownALLItem; import cc.arduino.ui.FilteredAbstractTableModel; import cc.arduino.ui.InstallerJDialog; import cc.arduino.ui.InstallerTableCell; @@ -94,7 +95,7 @@ public class LibraryManagerUI extends InstallerJDialog { // Load categories Collection categories = indexer.getIndex().getCategories(); - categoryChooser.addItem(""); + categoryChooser.addItem(new DropdownALLItem()); for (String s : categories) categoryChooser.addItem(s); diff --git a/app/src/cc/arduino/packages/contributions/ui/ContributedPlatformTableCell.java b/app/src/cc/arduino/packages/contributions/ui/ContributedPlatformTableCell.java index 69b216bbe..93789d1da 100644 --- a/app/src/cc/arduino/packages/contributions/ui/ContributedPlatformTableCell.java +++ b/app/src/cc/arduino/packages/contributions/ui/ContributedPlatformTableCell.java @@ -28,38 +28,27 @@ */ package cc.arduino.packages.contributions.ui; -import static processing.app.I18n._; -import static processing.app.I18n.format; +import cc.arduino.packages.contributions.ContributedBoard; +import cc.arduino.packages.contributions.ContributedPlatform; +import cc.arduino.packages.contributions.ui.ContributionIndexTableModel.ContributedPlatformReleases; +import cc.arduino.ui.InstallerTableCell; +import processing.app.Base; -import java.awt.Color; -import java.awt.Component; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; - -import javax.swing.Box; -import javax.swing.BoxLayout; -import javax.swing.JButton; -import javax.swing.JComboBox; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JTable; -import javax.swing.JTextPane; -import javax.swing.Timer; +import javax.swing.*; import javax.swing.border.EmptyBorder; import javax.swing.event.HyperlinkEvent; import javax.swing.event.HyperlinkListener; import javax.swing.text.Document; import javax.swing.text.html.HTMLDocument; import javax.swing.text.html.StyleSheet; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; -import processing.app.Base; -import cc.arduino.packages.contributions.ContributedBoard; -import cc.arduino.packages.contributions.ContributedPlatform; -import cc.arduino.packages.contributions.ui.ContributionIndexTableModel.ContributedPlatformReleases; -import cc.arduino.ui.InstallerTableCell; +import static processing.app.I18n._; +import static processing.app.I18n.format; @SuppressWarnings("serial") public class ContributedPlatformTableCell extends InstallerTableCell { @@ -205,8 +194,13 @@ public class ContributedPlatformTableCell extends InstallerTableCell { parentTable = table; setEnabled(false); - Component panel = getUpdatedCellComponent(value, isSelected, row); - return panel; + Component component = getUpdatedCellComponent(value, isSelected, row); + if (row % 2 == 0) { + component.setBackground(new Color(236, 241, 241)); //#ecf1f1 + } else { + component.setBackground(new Color(255, 255, 255)); + } + return component; } private ContributedPlatformReleases editorValue; @@ -234,10 +228,12 @@ public class ContributedPlatformTableCell extends InstallerTableCell { downgradeChooser.addItem(release); visible = true; } - downgradeChooser.setVisible(visible); - downgradeButton.setVisible(visible); + downgradeChooser.setVisible(visible && editorValue.releases.size() > 1); + downgradeButton.setVisible(visible && editorValue.releases.size() > 1); - return getUpdatedCellComponent(value, true, row); + Component component = getUpdatedCellComponent(value, true, row); + component.setBackground(new Color(218, 227, 227)); //#dae3e3 + return component; } private Component getUpdatedCellComponent(Object value, boolean isSelected, @@ -271,7 +267,7 @@ public class ContributedPlatformTableCell extends InstallerTableCell { String author = selectedPlatform.getParentPackage().getMaintainer(); String url = selectedPlatform.getParentPackage().getWebsiteURL(); if (author != null && !author.isEmpty()) { - desc += " " + format("by {1}", url, author); + desc += " " + format("by {0}", author); } if (removable) { desc += " " + format(_("version {0}"), installedPlatform.getVersion()); @@ -282,6 +278,11 @@ public class ContributedPlatformTableCell extends InstallerTableCell { for (ContributedBoard board : selectedPlatform.getBoards()) desc += format("{0}, ", board.getName()); desc = desc.substring(0, desc.lastIndexOf(',')) + ".
"; + + if (author != null && !author.isEmpty()) { + desc += " " + format("More info", url); + } + desc += ""; description.setText(desc); //description.setBackground(Color.WHITE); diff --git a/app/src/cc/arduino/ui/DropdownALLItem.java b/app/src/cc/arduino/ui/DropdownALLItem.java new file mode 100644 index 000000000..094fc55d5 --- /dev/null +++ b/app/src/cc/arduino/ui/DropdownALLItem.java @@ -0,0 +1,15 @@ +package cc.arduino.ui; + +import static processing.app.I18n._; + +public class DropdownALLItem implements DropdownItem { + + @Override + public String toString() { + return _("All"); + } + + public String getItemValue() { + return ""; + } +} diff --git a/app/src/cc/arduino/ui/DropdownItem.java b/app/src/cc/arduino/ui/DropdownItem.java new file mode 100644 index 000000000..aada7bb34 --- /dev/null +++ b/app/src/cc/arduino/ui/DropdownItem.java @@ -0,0 +1,6 @@ +package cc.arduino.ui; + +public interface DropdownItem { + + String getItemValue(); +} diff --git a/app/src/cc/arduino/ui/InstallerJDialog.java b/app/src/cc/arduino/ui/InstallerJDialog.java index f3ccd41b6..5e9432743 100644 --- a/app/src/cc/arduino/ui/InstallerJDialog.java +++ b/app/src/cc/arduino/ui/InstallerJDialog.java @@ -258,9 +258,19 @@ public abstract class InstallerJDialog extends JDialog { } protected ActionListener categoryChooserActionListener = new ActionListener() { + + public String getSelectedItem() { + Object obj = categoryChooser.getSelectedItem(); + if (obj instanceof String) { + return (String) obj; + } + DropdownItem item = (DropdownItem) obj; + return item.getItemValue(); + } + @Override - public void actionPerformed(ActionEvent arg0) { - String selected = (String) categoryChooser.getSelectedItem(); + public void actionPerformed(ActionEvent event) { + String selected = getSelectedItem(); if (category == null || !category.equals(selected)) { category = selected; cellEditor.stopCellEditing(); diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java index 6f6ab8834..20efc2963 100644 --- a/app/src/processing/app/Base.java +++ b/app/src/processing/app/Base.java @@ -1056,24 +1056,23 @@ public class Base { // Find the current target. Get the platform, and then select the // correct name and core path. String platformNameLabel; - PreferencesMap prefs = targetPlatform.getPreferences(); - if (prefs != null && prefs.get("name") != null) { - platformNameLabel = prefs.get("name"); - } else { - platformNameLabel = targetPlatform.getContainerPackage().getId() + "/" + targetPlatform.getId(); - platformNameLabel = I18n.format(_("{0} boards"), platformNameLabel); - } + platformNameLabel = targetPlatform.getContainerPackage().getId() + "/" + targetPlatform.getId(); + platformNameLabel = I18n.format(_("{0} libraries"), platformNameLabel); JMenuItem platformItem = new JMenuItem(_(platformNameLabel)); platformItem.setEnabled(false); importMenu.add(platformItem); if (ideLibs.size() > 0) { - importMenu.addSeparator(); addLibraries(importMenu, ideLibs); } if (userLibs.size() > 0) { - importMenu.addSeparator(); + if (ideLibs.size() > 0) { + importMenu.addSeparator(); + } + JMenuItem contributedLibraryItem = new JMenuItem(_("Contributed libraries")); + contributedLibraryItem.setEnabled(false); + importMenu.add(contributedLibraryItem); addLibraries(importMenu, userLibs); } } catch (IOException e) {