mirror of
https://github.com/arduino/Arduino.git
synced 2024-12-01 12:24:14 +01:00
First round of UX feedback
This commit is contained in:
parent
d050c4ee4a
commit
9f68d4df74
@ -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("<font color=\"{0}\">", midcolor);
|
||||
if (author != null && !author.isEmpty()) {
|
||||
desc += format(" by <a href=\"{0}\">{1}</a>", website, author);
|
||||
desc += format(" by <b>{0}</b>", author);
|
||||
}
|
||||
|
||||
// ...version.
|
||||
@ -315,6 +312,9 @@ public class ContributedLibraryTableCell extends InstallerTableCell {
|
||||
desc += format("{0}", paragraph);
|
||||
desc += "<br />";
|
||||
}
|
||||
if (author != null && !author.isEmpty()) {
|
||||
desc += format("<a href=\"{0}\">More info</a>", website);
|
||||
}
|
||||
|
||||
desc += "</body></html>";
|
||||
description.setText(desc);
|
||||
|
@ -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 <b>true<b> if all the strings in <b>set</b> are contained in
|
||||
* <b>string</b>.
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -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<String> categories = indexer.getIndex().getCategories();
|
||||
categoryChooser.addItem("");
|
||||
categoryChooser.addItem(new DropdownALLItem());
|
||||
for (String s : categories)
|
||||
categoryChooser.addItem(s);
|
||||
|
||||
|
@ -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 <a href=\"{0}\">{1}</a>", url, author);
|
||||
desc += " " + format("by <b>{0}</b>", author);
|
||||
}
|
||||
if (removable) {
|
||||
desc += " " + format(_("version <b>{0}</b>"), 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(',')) + ".<br />";
|
||||
|
||||
if (author != null && !author.isEmpty()) {
|
||||
desc += " " + format("<a href=\"{0}\">More info</a>", url);
|
||||
}
|
||||
|
||||
desc += "</body></html>";
|
||||
description.setText(desc);
|
||||
//description.setBackground(Color.WHITE);
|
||||
|
15
app/src/cc/arduino/ui/DropdownALLItem.java
Normal file
15
app/src/cc/arduino/ui/DropdownALLItem.java
Normal file
@ -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 "";
|
||||
}
|
||||
}
|
6
app/src/cc/arduino/ui/DropdownItem.java
Normal file
6
app/src/cc/arduino/ui/DropdownItem.java
Normal file
@ -0,0 +1,6 @@
|
||||
package cc.arduino.ui;
|
||||
|
||||
public interface DropdownItem {
|
||||
|
||||
String getItemValue();
|
||||
}
|
@ -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();
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user