mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-29 18:52:13 +01:00
Ported UX of library manager to core manager
This commit is contained in:
parent
17d3729426
commit
b32dc93506
@ -0,0 +1,17 @@
|
||||
package cc.arduino.contributions.filters;
|
||||
|
||||
import cc.arduino.contributions.packages.DownloadableContribution;
|
||||
import com.google.common.base.Predicate;
|
||||
|
||||
public class InstalledPredicate implements Predicate<DownloadableContribution> {
|
||||
@Override
|
||||
public boolean apply(DownloadableContribution input) {
|
||||
return input.isInstalled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return obj instanceof DownloadableContribution;
|
||||
}
|
||||
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
package cc.arduino.contributions.libraries.filters;
|
||||
|
||||
import cc.arduino.contributions.libraries.ContributedLibrary;
|
||||
import com.google.common.base.Predicate;
|
||||
|
||||
public class InstalledPredicate implements Predicate<ContributedLibrary> {
|
||||
@Override
|
||||
public boolean apply(ContributedLibrary input) {
|
||||
return input.isInstalled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return obj instanceof InstalledPredicate;
|
||||
}
|
||||
|
||||
}
|
@ -31,7 +31,7 @@ package cc.arduino.contributions.libraries.ui;
|
||||
import cc.arduino.contributions.libraries.ContributedLibrary;
|
||||
import cc.arduino.contributions.libraries.ContributedLibraryComparator;
|
||||
import cc.arduino.contributions.libraries.filters.BuiltInPredicate;
|
||||
import cc.arduino.contributions.libraries.filters.InstalledPredicate;
|
||||
import cc.arduino.contributions.filters.InstalledPredicate;
|
||||
import cc.arduino.contributions.libraries.filters.OnlyUpstreamReleasePredicate;
|
||||
import cc.arduino.contributions.VersionComparator;
|
||||
import cc.arduino.contributions.ui.InstallerTableCell;
|
||||
@ -201,9 +201,7 @@ public class ContributedLibraryTableCell extends InstallerTableCell {
|
||||
|
||||
statusLabel = new JLabel(" ");
|
||||
inactiveButtonsPanel.add(statusLabel);
|
||||
|
||||
inactiveButtonsPanel.add(Box.createGlue());
|
||||
inactiveButtonsPanel.add(Box.createVerticalStrut(height));
|
||||
inactiveButtonsPanel.add(Box.createHorizontalStrut(15));
|
||||
|
||||
panel.add(inactiveButtonsPanel);
|
||||
}
|
||||
@ -211,11 +209,11 @@ public class ContributedLibraryTableCell extends InstallerTableCell {
|
||||
panel.add(Box.createVerticalStrut(15));
|
||||
}
|
||||
|
||||
protected void onRemove(ContributedLibrary selectedLib) {
|
||||
protected void onRemove(ContributedLibrary selected) {
|
||||
// Empty
|
||||
}
|
||||
|
||||
protected void onInstall(ContributedLibrary selectedLib, ContributedLibrary installedLib) {
|
||||
protected void onInstall(ContributedLibrary selected, ContributedLibrary installed) {
|
||||
// Empty
|
||||
}
|
||||
|
||||
@ -251,52 +249,52 @@ public class ContributedLibraryTableCell extends InstallerTableCell {
|
||||
editorValue = (LibrariesIndexTableModel.ContributedLibraryReleases) value;
|
||||
setEnabled(true);
|
||||
|
||||
final ContributedLibrary installedLibrary = editorValue.getInstalled();
|
||||
final ContributedLibrary installed = editorValue.getInstalled();
|
||||
|
||||
List<ContributedLibrary> libraries = new LinkedList<ContributedLibrary>(Collections2.filter(editorValue.releases, new OnlyUpstreamReleasePredicate()));
|
||||
List<ContributedLibrary> uninstalledLibraries = new LinkedList<ContributedLibrary>(Collections2.filter(libraries, Predicates.not(new InstalledPredicate())));
|
||||
List<ContributedLibrary> releases = new LinkedList<ContributedLibrary>(Collections2.filter(editorValue.releases, new OnlyUpstreamReleasePredicate()));
|
||||
List<ContributedLibrary> uninstalledReleases = new LinkedList<ContributedLibrary>(Collections2.filter(releases, Predicates.not(new InstalledPredicate())));
|
||||
|
||||
List<ContributedLibrary> installedBuiltIn = new LinkedList<ContributedLibrary>(Collections2.filter(libraries, Predicates.and(new InstalledPredicate(), new BuiltInPredicate())));
|
||||
List<ContributedLibrary> installedBuiltIn = new LinkedList<ContributedLibrary>(Collections2.filter(releases, Predicates.and(new InstalledPredicate(), new BuiltInPredicate())));
|
||||
|
||||
if (installedLibrary != null && !installedBuiltIn.contains(installedLibrary)) {
|
||||
uninstalledLibraries.addAll(installedBuiltIn);
|
||||
if (installed != null && !installedBuiltIn.contains(installed)) {
|
||||
uninstalledReleases.addAll(installedBuiltIn);
|
||||
}
|
||||
|
||||
Collections.sort(uninstalledLibraries, new ReverseComparator<ContributedLibrary>(new ContributedLibraryComparator()));
|
||||
Collections.sort(uninstalledReleases, new ReverseComparator<ContributedLibrary>(new ContributedLibraryComparator()));
|
||||
|
||||
downgradeChooser.removeAllItems();
|
||||
downgradeChooser.addItem(_("Select version"));
|
||||
|
||||
final List<ContributedLibrary> uninstalledPreviousLibraries = Lists.newLinkedList();
|
||||
final List<ContributedLibrary> uninstalledNewerLibraries = Lists.newLinkedList();
|
||||
final List<ContributedLibrary> uninstalledPreviousReleases = Lists.newLinkedList();
|
||||
final List<ContributedLibrary> uninstalledNewerReleases = Lists.newLinkedList();
|
||||
|
||||
Lists.newLinkedList(Lists.transform(uninstalledLibraries, new Function<ContributedLibrary, ContributedLibrary>() {
|
||||
Lists.newLinkedList(Lists.transform(uninstalledReleases, new Function<ContributedLibrary, ContributedLibrary>() {
|
||||
@Override
|
||||
public ContributedLibrary apply(ContributedLibrary input) {
|
||||
if (installedLibrary == null || VersionComparator.VERSION_COMPARATOR.greaterThan(installedLibrary.getVersion(), input.getVersion())) {
|
||||
uninstalledPreviousLibraries.add(input);
|
||||
if (installed == null || VersionComparator.VERSION_COMPARATOR.greaterThan(installed.getVersion(), input.getVersion())) {
|
||||
uninstalledPreviousReleases.add(input);
|
||||
} else {
|
||||
uninstalledNewerLibraries.add(input);
|
||||
uninstalledNewerReleases.add(input);
|
||||
}
|
||||
|
||||
return input;
|
||||
}
|
||||
}));
|
||||
for (ContributedLibrary release : uninstalledNewerLibraries) {
|
||||
for (ContributedLibrary release : uninstalledNewerReleases) {
|
||||
downgradeChooser.addItem(release);
|
||||
}
|
||||
for (ContributedLibrary release : uninstalledPreviousLibraries) {
|
||||
for (ContributedLibrary release : uninstalledPreviousReleases) {
|
||||
downgradeChooser.addItem(release);
|
||||
}
|
||||
|
||||
downgradeChooser.setVisible(installedLibrary != null && (!uninstalledPreviousLibraries.isEmpty() || uninstalledNewerLibraries.size() > 1));
|
||||
downgradeButton.setVisible(installedLibrary != null && (!uninstalledPreviousLibraries.isEmpty() || uninstalledNewerLibraries.size() > 1));
|
||||
downgradeChooser.setVisible(installed != null && (!uninstalledPreviousReleases.isEmpty() || uninstalledNewerReleases.size() > 1));
|
||||
downgradeButton.setVisible(installed != null && (!uninstalledPreviousReleases.isEmpty() || uninstalledNewerReleases.size() > 1));
|
||||
|
||||
versionToInstallChooser.removeAllItems();
|
||||
for (ContributedLibrary release : uninstalledLibraries) {
|
||||
for (ContributedLibrary release : uninstalledReleases) {
|
||||
versionToInstallChooser.addItem(release);
|
||||
}
|
||||
versionToInstallChooser.setVisible(installedLibrary == null && uninstalledLibraries.size() > 1);
|
||||
versionToInstallChooser.setVisible(installed == null && uninstalledReleases.size() > 1);
|
||||
|
||||
Component component = getUpdatedCellComponent(value, true, row, !installedBuiltIn.isEmpty());
|
||||
component.setBackground(new Color(218, 227, 227)); //#dae3e3
|
||||
@ -311,18 +309,18 @@ public class ContributedLibraryTableCell extends InstallerTableCell {
|
||||
return panel;
|
||||
}
|
||||
|
||||
ContributedLibrary selectedLib = releases.getSelected();
|
||||
ContributedLibrary installedLib = releases.getInstalled();
|
||||
ContributedLibrary selected = releases.getSelected();
|
||||
ContributedLibrary installed = releases.getInstalled();
|
||||
|
||||
boolean removable, installable, upgradable;
|
||||
if (installedLib == null) {
|
||||
if (installed == null) {
|
||||
installable = true;
|
||||
removable = false;
|
||||
upgradable = false;
|
||||
} else {
|
||||
installable = false;
|
||||
removable = !installedLib.isReadOnly() && !hasBuiltInRelease;
|
||||
upgradable = new ContributedLibraryComparator().compare(selectedLib, installedLib) > 0;
|
||||
removable = !installed.isReadOnly() && !hasBuiltInRelease;
|
||||
upgradable = new ContributedLibraryComparator().compare(selected, installed) > 0;
|
||||
}
|
||||
if (installable) {
|
||||
installButton.setText(_("Install"));
|
||||
@ -335,14 +333,14 @@ public class ContributedLibraryTableCell extends InstallerTableCell {
|
||||
removeButton.setVisible(removable);
|
||||
removeButtonPlaceholder.setVisible(!removable);
|
||||
|
||||
String name = selectedLib.getName();
|
||||
String author = selectedLib.getAuthor();
|
||||
String name = selected.getName();
|
||||
String author = selected.getAuthor();
|
||||
// String maintainer = selectedLib.getMaintainer();
|
||||
String website = selectedLib.getWebsite();
|
||||
String sentence = selectedLib.getSentence();
|
||||
String paragraph = selectedLib.getParagraph();
|
||||
String website = selected.getWebsite();
|
||||
String sentence = selected.getSentence();
|
||||
String paragraph = selected.getParagraph();
|
||||
// String availableVer = selectedLib.getVersion();
|
||||
String url = selectedLib.getUrl();
|
||||
String url = selected.getUrl();
|
||||
|
||||
String midcolor = isSelected ? "#000000" : "#888888";
|
||||
|
||||
@ -350,7 +348,7 @@ public class ContributedLibraryTableCell extends InstallerTableCell {
|
||||
|
||||
// Library name...
|
||||
desc += format("<b>{0}</b> ", name);
|
||||
if (installedLib != null && installedLib.isReadOnly()) {
|
||||
if (installed != null && installed.isReadOnly()) {
|
||||
desc += "Built-In ";
|
||||
}
|
||||
|
||||
@ -361,8 +359,8 @@ public class ContributedLibraryTableCell extends InstallerTableCell {
|
||||
}
|
||||
|
||||
// ...version.
|
||||
if (installedLib != null) {
|
||||
String installedVer = installedLib.getVersion();
|
||||
if (installed != null) {
|
||||
String installedVer = installed.getVersion();
|
||||
if (installedVer == null) {
|
||||
desc += " " + _("Version unknown");
|
||||
} else {
|
||||
@ -373,7 +371,7 @@ public class ContributedLibraryTableCell extends InstallerTableCell {
|
||||
}
|
||||
desc += "</font>";
|
||||
|
||||
if (installedLib != null) {
|
||||
if (installed != null) {
|
||||
desc += " <strong><font color=\"#00979D\">INSTALLED</font></strong>";
|
||||
}
|
||||
|
||||
@ -438,6 +436,10 @@ public class ContributedLibraryTableCell extends InstallerTableCell {
|
||||
removeButton.setEnabled(enabled);
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
statusLabel.setText(status);
|
||||
}
|
||||
|
||||
public void invalidate() {
|
||||
panel.invalidate();
|
||||
}
|
||||
|
@ -1,20 +0,0 @@
|
||||
package cc.arduino.contributions.libraries.ui;
|
||||
|
||||
import cc.arduino.contributions.libraries.ContributedLibrary;
|
||||
import cc.arduino.contributions.libraries.filters.InstalledPredicate;
|
||||
import cc.arduino.contributions.ui.DropdownItem;
|
||||
import com.google.common.base.Predicate;
|
||||
|
||||
import static processing.app.I18n._;
|
||||
|
||||
public class DropdownInstalledLibrariesItem implements DropdownItem<ContributedLibrary> {
|
||||
|
||||
public String toString() {
|
||||
return _("Installed");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Predicate<ContributedLibrary> getFilterPredicate() {
|
||||
return new InstalledPredicate();
|
||||
}
|
||||
}
|
@ -31,9 +31,7 @@ package cc.arduino.contributions.libraries.ui;
|
||||
import cc.arduino.contributions.libraries.ContributedLibrary;
|
||||
import cc.arduino.contributions.libraries.LibrariesIndexer;
|
||||
import cc.arduino.contributions.packages.ui.InstallerJDialogUncaughtExceptionHandler;
|
||||
import cc.arduino.contributions.ui.FilteredAbstractTableModel;
|
||||
import cc.arduino.contributions.ui.InstallerJDialog;
|
||||
import cc.arduino.contributions.ui.InstallerTableCell;
|
||||
import cc.arduino.contributions.ui.*;
|
||||
import cc.arduino.utils.Progress;
|
||||
|
||||
import javax.swing.*;
|
||||
@ -100,8 +98,8 @@ public class LibraryManagerUI extends InstallerJDialog {
|
||||
categoryChooser.addActionListener(categoryChooserActionListener);
|
||||
|
||||
// Load categories
|
||||
categoryChooser.addItem(new DropdownAllLibrariesItem());
|
||||
categoryChooser.addItem(new DropdownInstalledLibrariesItem());
|
||||
categoryChooser.addItem(new DropdownAllItem());
|
||||
categoryChooser.addItem(new DropdownInstalledContributionItem());
|
||||
categoryChooser.addItem(new DropdownBuiltInLibrariesItem());
|
||||
Collection<String> categories = indexer.getIndex().getCategories();
|
||||
for (String category : categories) {
|
||||
|
@ -28,12 +28,21 @@
|
||||
*/
|
||||
package cc.arduino.contributions.packages.ui;
|
||||
|
||||
import cc.arduino.contributions.VersionComparator;
|
||||
import cc.arduino.contributions.filters.InstalledPredicate;
|
||||
import cc.arduino.contributions.packages.ContributedBoard;
|
||||
import cc.arduino.contributions.packages.ContributedPlatform;
|
||||
import cc.arduino.contributions.packages.ContributedPlatformComparator;
|
||||
import cc.arduino.contributions.ui.InstallerTableCell;
|
||||
import cc.arduino.utils.ReverseComparator;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Predicates;
|
||||
import com.google.common.collect.Collections2;
|
||||
import com.google.common.collect.Lists;
|
||||
import processing.app.Base;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.Timer;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.event.HyperlinkEvent;
|
||||
import javax.swing.event.HyperlinkListener;
|
||||
@ -41,10 +50,12 @@ import javax.swing.text.Document;
|
||||
import javax.swing.text.html.HTMLDocument;
|
||||
import javax.swing.text.html.StyleSheet;
|
||||
import java.awt.*;
|
||||
import java.awt.List;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ItemEvent;
|
||||
import java.awt.event.ItemListener;
|
||||
import java.util.*;
|
||||
|
||||
import static processing.app.I18n._;
|
||||
import static processing.app.I18n.format;
|
||||
@ -54,14 +65,15 @@ public class ContributedPlatformTableCell extends InstallerTableCell {
|
||||
|
||||
private JPanel panel;
|
||||
private JTextPane description;
|
||||
|
||||
private JPanel buttonsPanel;
|
||||
private JButton installButton;
|
||||
private JComboBox downgradeChooser;
|
||||
private JButton downgradeButton;
|
||||
private JButton removeButton;
|
||||
private Component removeButtonPlaceholder;
|
||||
private Component installButtonPlaceholder;
|
||||
private JComboBox downgradeChooser;
|
||||
private JComboBox versionToInstallChooser;
|
||||
private JButton downgradeButton;
|
||||
private JPanel buttonsPanel;
|
||||
private Component removeButtonStrut;
|
||||
|
||||
private JPanel inactiveButtonsPanel;
|
||||
private JLabel statusLabel;
|
||||
|
||||
@ -93,28 +105,35 @@ public class ContributedPlatformTableCell extends InstallerTableCell {
|
||||
}
|
||||
});
|
||||
|
||||
installButton = new JButton(_("Install"));
|
||||
installButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
onInstall(editorValue.getSelected(), editorValue.getInstalled());
|
||||
}
|
||||
});
|
||||
{
|
||||
installButton = new JButton(_("Install"));
|
||||
installButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
onInstall(editorValue.getSelected(), editorValue.getInstalled());
|
||||
}
|
||||
});
|
||||
int width = installButton.getPreferredSize().width;
|
||||
installButtonPlaceholder = Box.createRigidArea(new Dimension(width, 1));
|
||||
}
|
||||
|
||||
removeButton = new JButton(_("Remove"));
|
||||
removeButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
onRemove(editorValue.getInstalled());
|
||||
}
|
||||
});
|
||||
{
|
||||
removeButton = new JButton(_("Remove"));
|
||||
removeButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
onRemove(editorValue.getInstalled());
|
||||
}
|
||||
});
|
||||
int width = removeButton.getPreferredSize().width;
|
||||
removeButtonPlaceholder = Box.createRigidArea(new Dimension(width, 1));
|
||||
}
|
||||
|
||||
downgradeButton = new JButton(_("Install"));
|
||||
downgradeButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
ContributedPlatform selected;
|
||||
selected = (ContributedPlatform) downgradeChooser.getSelectedItem();
|
||||
ContributedPlatform selected = (ContributedPlatform) downgradeChooser.getSelectedItem();
|
||||
onInstall(selected, editorValue.getInstalled());
|
||||
}
|
||||
});
|
||||
@ -131,6 +150,16 @@ public class ContributedPlatformTableCell extends InstallerTableCell {
|
||||
}
|
||||
});
|
||||
|
||||
versionToInstallChooser = new JComboBox();
|
||||
versionToInstallChooser.addItem("-");
|
||||
versionToInstallChooser.setMaximumSize(versionToInstallChooser.getPreferredSize());
|
||||
versionToInstallChooser.addItemListener(new ItemListener() {
|
||||
@Override
|
||||
public void itemStateChanged(ItemEvent e) {
|
||||
editorValue.select((ContributedPlatform) versionToInstallChooser.getSelectedItem());
|
||||
}
|
||||
});
|
||||
|
||||
panel = new JPanel();
|
||||
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
|
||||
|
||||
@ -141,12 +170,15 @@ public class ContributedPlatformTableCell extends InstallerTableCell {
|
||||
buttonsPanel.setLayout(new BoxLayout(buttonsPanel, BoxLayout.X_AXIS));
|
||||
buttonsPanel.setOpaque(false);
|
||||
|
||||
buttonsPanel.add(Box.createHorizontalStrut(20));
|
||||
buttonsPanel.add(Box.createHorizontalStrut(7));
|
||||
buttonsPanel.add(downgradeChooser);
|
||||
buttonsPanel.add(Box.createHorizontalStrut(5));
|
||||
buttonsPanel.add(downgradeButton);
|
||||
|
||||
buttonsPanel.add(Box.createHorizontalGlue());
|
||||
|
||||
buttonsPanel.add(versionToInstallChooser);
|
||||
buttonsPanel.add(Box.createHorizontalStrut(5));
|
||||
buttonsPanel.add(installButton);
|
||||
buttonsPanel.add(Box.createHorizontalStrut(5));
|
||||
buttonsPanel.add(removeButton);
|
||||
@ -173,7 +205,7 @@ public class ContributedPlatformTableCell extends InstallerTableCell {
|
||||
panel.add(inactiveButtonsPanel);
|
||||
}
|
||||
|
||||
panel.add(Box.createVerticalStrut(10));
|
||||
panel.add(Box.createVerticalStrut(15));
|
||||
}
|
||||
|
||||
protected void onRemove(ContributedPlatform contributedPlatform) {
|
||||
@ -190,13 +222,13 @@ public class ContributedPlatformTableCell extends InstallerTableCell {
|
||||
int column) {
|
||||
parentTable = table;
|
||||
setEnabled(false);
|
||||
|
||||
Component component = getUpdatedCellComponent(value, isSelected, row);
|
||||
Component component = getUpdatedCellComponent(value, isSelected, row, false);
|
||||
if (row % 2 == 0) {
|
||||
component.setBackground(new Color(236, 241, 241)); //#ecf1f1
|
||||
} else {
|
||||
component.setBackground(new Color(255, 255, 255));
|
||||
}
|
||||
|
||||
return component;
|
||||
}
|
||||
|
||||
@ -216,63 +248,105 @@ public class ContributedPlatformTableCell extends InstallerTableCell {
|
||||
editorValue = (ContributionIndexTableModel.ContributedPlatformReleases) value;
|
||||
setEnabled(true);
|
||||
|
||||
final ContributedPlatform installed = editorValue.getInstalled();
|
||||
|
||||
java.util.List<ContributedPlatform> releases = new LinkedList<ContributedPlatform>(editorValue.releases);
|
||||
java.util.List<ContributedPlatform> uninstalledReleases = new LinkedList<ContributedPlatform>(Collections2.filter(releases, Predicates.not(new InstalledPredicate())));
|
||||
|
||||
java.util.List<ContributedPlatform> installedBuiltIn = new LinkedList<ContributedPlatform>();
|
||||
|
||||
if (installed != null && !installedBuiltIn.contains(installed)) {
|
||||
uninstalledReleases.addAll(installedBuiltIn);
|
||||
}
|
||||
|
||||
Collections.sort(uninstalledReleases, new ReverseComparator<ContributedPlatform>(new ContributedPlatformComparator()));
|
||||
|
||||
downgradeChooser.removeAllItems();
|
||||
downgradeChooser.addItem(_("Select version"));
|
||||
boolean visible = false;
|
||||
for (ContributedPlatform release : editorValue.releases) {
|
||||
if (release.isInstalled())
|
||||
continue;
|
||||
downgradeChooser.addItem(release);
|
||||
visible = true;
|
||||
}
|
||||
downgradeChooser.setVisible(visible && editorValue.releases.size() > 1);
|
||||
downgradeButton.setVisible(visible && editorValue.releases.size() > 1);
|
||||
|
||||
Component component = getUpdatedCellComponent(value, true, row);
|
||||
final java.util.List<ContributedPlatform> uninstalledPreviousReleases = Lists.newLinkedList();
|
||||
final java.util.List<ContributedPlatform> uninstalledNewerReleases = Lists.newLinkedList();
|
||||
|
||||
Lists.newLinkedList(Lists.transform(uninstalledReleases, new Function<ContributedPlatform, ContributedPlatform>() {
|
||||
@Override
|
||||
public ContributedPlatform apply(ContributedPlatform input) {
|
||||
if (installed == null || VersionComparator.VERSION_COMPARATOR.greaterThan(installed.getVersion(), input.getVersion())) {
|
||||
uninstalledPreviousReleases.add(input);
|
||||
} else {
|
||||
uninstalledNewerReleases.add(input);
|
||||
}
|
||||
|
||||
return input;
|
||||
}
|
||||
}));
|
||||
for (ContributedPlatform release : uninstalledNewerReleases) {
|
||||
downgradeChooser.addItem(release);
|
||||
}
|
||||
for (ContributedPlatform release : uninstalledPreviousReleases) {
|
||||
downgradeChooser.addItem(release);
|
||||
}
|
||||
|
||||
downgradeChooser.setVisible(installed != null && (!uninstalledPreviousReleases.isEmpty() || uninstalledNewerReleases.size() > 1));
|
||||
downgradeButton.setVisible(installed != null && (!uninstalledPreviousReleases.isEmpty() || uninstalledNewerReleases.size() > 1));
|
||||
|
||||
versionToInstallChooser.removeAllItems();
|
||||
for (ContributedPlatform release : uninstalledReleases) {
|
||||
versionToInstallChooser.addItem(release);
|
||||
}
|
||||
versionToInstallChooser.setVisible(installed == null && uninstalledReleases.size() > 1);
|
||||
|
||||
Component component = getUpdatedCellComponent(value, true, row, !installedBuiltIn.isEmpty());
|
||||
component.setBackground(new Color(218, 227, 227)); //#dae3e3
|
||||
return component;
|
||||
}
|
||||
|
||||
private Component getUpdatedCellComponent(Object value, boolean isSelected,
|
||||
int row) {
|
||||
private Component getUpdatedCellComponent(Object value, boolean isSelected, int row, boolean hasBuiltInRelease) {
|
||||
ContributionIndexTableModel.ContributedPlatformReleases releases = (ContributionIndexTableModel.ContributedPlatformReleases) value;
|
||||
ContributedPlatform selectedPlatform = releases.getSelected();
|
||||
ContributedPlatform installedPlatform = releases.getInstalled();
|
||||
|
||||
//FIXME: happens on macosx, don't know why
|
||||
if (releases == null) {
|
||||
return panel;
|
||||
}
|
||||
|
||||
ContributedPlatform selected = releases.getSelected();
|
||||
ContributedPlatform installed = releases.getInstalled();
|
||||
|
||||
boolean removable, installable, upgradable;
|
||||
if (installedPlatform == null) {
|
||||
if (installed == null) {
|
||||
installable = true;
|
||||
removable = false;
|
||||
upgradable = false;
|
||||
} else {
|
||||
installable = false;
|
||||
removable = true;
|
||||
upgradable = (selectedPlatform != installedPlatform);
|
||||
//removable = !installed.isReadOnly() && !hasBuiltInRelease;
|
||||
removable = !hasBuiltInRelease;
|
||||
upgradable = new ContributedPlatformComparator().compare(selected, installed) > 0;
|
||||
}
|
||||
|
||||
if (installable)
|
||||
if (installable) {
|
||||
installButton.setText(_("Install"));
|
||||
if (upgradable)
|
||||
}
|
||||
if (upgradable) {
|
||||
installButton.setText(_("Update"));
|
||||
}
|
||||
installButton.setVisible(installable || upgradable);
|
||||
|
||||
installButtonPlaceholder.setVisible(!(installable || upgradable));
|
||||
removeButton.setVisible(removable);
|
||||
removeButtonStrut.setVisible(removable);
|
||||
removeButtonPlaceholder.setVisible(!removable);
|
||||
|
||||
String desc = "<html><body>";
|
||||
desc += "<b>" + selectedPlatform.getName() + "</b>";
|
||||
String author = selectedPlatform.getParentPackage().getMaintainer();
|
||||
String url = selectedPlatform.getParentPackage().getWebsiteURL();
|
||||
desc += "<b>" + selected.getName() + "</b>";
|
||||
String author = selected.getParentPackage().getMaintainer();
|
||||
String url = selected.getParentPackage().getWebsiteURL();
|
||||
if (author != null && !author.isEmpty()) {
|
||||
desc += " " + format("by <b>{0}</b>", author);
|
||||
}
|
||||
if (removable) {
|
||||
desc += " " + format(_("version <b>{0}</b>"), installedPlatform.getVersion()) + " <strong><font color=\"#00979D\">INSTALLED</font></strong>";
|
||||
desc += " " + format(_("version <b>{0}</b>"), installed.getVersion()) + " <strong><font color=\"#00979D\">INSTALLED</font></strong>";
|
||||
}
|
||||
desc += "<br />";
|
||||
|
||||
desc += _("Boards included in this package:") + "<br />";
|
||||
for (ContributedBoard board : selectedPlatform.getBoards())
|
||||
for (ContributedBoard board : selected.getBoards())
|
||||
desc += format("{0}, ", board.getName());
|
||||
desc = desc.substring(0, desc.lastIndexOf(',')) + ".<br />";
|
||||
|
||||
@ -282,8 +356,13 @@ public class ContributedPlatformTableCell extends InstallerTableCell {
|
||||
|
||||
desc += "</body></html>";
|
||||
description.setText(desc);
|
||||
//description.setBackground(Color.WHITE);
|
||||
description.setBackground(Color.WHITE);
|
||||
|
||||
// for modelToView to work, the text area has to be sized. It doesn't
|
||||
// matter if it's visible or not.
|
||||
|
||||
// See:
|
||||
// http://stackoverflow.com/questions/3081210/how-to-set-jtextarea-to-have-height-that-matches-the-size-of-a-text-it-contains
|
||||
int width = parentTable.getBounds().width;
|
||||
setJTextPaneDimensionToFitContainedText(description, width);
|
||||
|
||||
@ -311,12 +390,14 @@ public class ContributedPlatformTableCell extends InstallerTableCell {
|
||||
enable(false);
|
||||
if (enabled) {
|
||||
enabler.start();
|
||||
} else {
|
||||
enabler.stop();
|
||||
}
|
||||
buttonsPanel.setVisible(enabled);
|
||||
inactiveButtonsPanel.setVisible(!enabled);
|
||||
}
|
||||
|
||||
private void enable(boolean enabled) {
|
||||
public void enable(boolean enabled) {
|
||||
installButton.setEnabled(enabled);
|
||||
removeButton.setEnabled(enabled);
|
||||
}
|
||||
|
@ -1,20 +1,21 @@
|
||||
package cc.arduino.contributions.libraries.ui;
|
||||
package cc.arduino.contributions.ui;
|
||||
|
||||
import cc.arduino.contributions.libraries.ContributedLibrary;
|
||||
import cc.arduino.contributions.filters.NoopPredicate;
|
||||
import cc.arduino.contributions.packages.DownloadableContribution;
|
||||
import cc.arduino.contributions.ui.DropdownItem;
|
||||
import com.google.common.base.Predicate;
|
||||
|
||||
import static processing.app.I18n._;
|
||||
|
||||
public class DropdownAllLibrariesItem implements DropdownItem<ContributedLibrary> {
|
||||
public class DropdownAllItem implements DropdownItem<DownloadableContribution> {
|
||||
|
||||
public String toString() {
|
||||
return _("All");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Predicate<ContributedLibrary> getFilterPredicate() {
|
||||
return new NoopPredicate<ContributedLibrary>();
|
||||
public Predicate<DownloadableContribution> getFilterPredicate() {
|
||||
return new NoopPredicate<DownloadableContribution>();
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package cc.arduino.contributions.ui;
|
||||
|
||||
import cc.arduino.contributions.filters.InstalledPredicate;
|
||||
import cc.arduino.contributions.packages.DownloadableContribution;
|
||||
import cc.arduino.contributions.ui.DropdownItem;
|
||||
import com.google.common.base.Predicate;
|
||||
|
||||
import static processing.app.I18n._;
|
||||
|
||||
public class DropdownInstalledContributionItem implements DropdownItem<DownloadableContribution> {
|
||||
|
||||
public String toString() {
|
||||
return _("Installed");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Predicate<DownloadableContribution> getFilterPredicate() {
|
||||
return new InstalledPredicate();
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package cc.arduino.contributions.packages;
|
||||
|
||||
import cc.arduino.contributions.VersionComparator;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
public class ContributedPlatformComparator implements Comparator<ContributedPlatform> {
|
||||
|
||||
@Override
|
||||
public int compare(ContributedPlatform lib1, ContributedPlatform lib2) {
|
||||
return VersionComparator.VERSION_COMPARATOR.compare(lib1.getVersion(), lib2.getVersion());
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user