mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-20 09:52:13 +01:00
[Board/Lib manager] When the ide.accessible setting is enabled use buttons instead of links
This commit is contained in:
parent
199a943177
commit
1b515b1767
@ -28,10 +28,12 @@ import cc.arduino.contributions.libraries.ContributedLibrary;
|
|||||||
import cc.arduino.contributions.libraries.ContributedLibraryReleases;
|
import cc.arduino.contributions.libraries.ContributedLibraryReleases;
|
||||||
import cc.arduino.contributions.ui.InstallerTableCell;
|
import cc.arduino.contributions.ui.InstallerTableCell;
|
||||||
import processing.app.Base;
|
import processing.app.Base;
|
||||||
|
import processing.app.PreferencesData;
|
||||||
import processing.app.Theme;
|
import processing.app.Theme;
|
||||||
|
|
||||||
public class ContributedLibraryTableCellJPanel extends JPanel {
|
public class ContributedLibraryTableCellJPanel extends JPanel {
|
||||||
|
|
||||||
|
final JButton moreInfoButton;
|
||||||
final JButton installButton;
|
final JButton installButton;
|
||||||
final Component installButtonPlaceholder;
|
final Component installButtonPlaceholder;
|
||||||
final JComboBox downgradeChooser;
|
final JComboBox downgradeChooser;
|
||||||
@ -40,12 +42,15 @@ public class ContributedLibraryTableCellJPanel extends JPanel {
|
|||||||
final JPanel buttonsPanel;
|
final JPanel buttonsPanel;
|
||||||
final JPanel inactiveButtonsPanel;
|
final JPanel inactiveButtonsPanel;
|
||||||
final JLabel statusLabel;
|
final JLabel statusLabel;
|
||||||
|
private final String moreInfoLbl = tr("More info");
|
||||||
|
|
||||||
public ContributedLibraryTableCellJPanel(JTable parentTable, Object value,
|
public ContributedLibraryTableCellJPanel(JTable parentTable, Object value,
|
||||||
boolean isSelected) {
|
boolean isSelected) {
|
||||||
super();
|
super();
|
||||||
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
|
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
|
||||||
|
|
||||||
|
moreInfoButton = new JButton(moreInfoLbl);
|
||||||
|
moreInfoButton.setVisible(false);
|
||||||
installButton = new JButton(tr("Install"));
|
installButton = new JButton(tr("Install"));
|
||||||
int width = installButton.getPreferredSize().width;
|
int width = installButton.getPreferredSize().width;
|
||||||
installButtonPlaceholder = Box.createRigidArea(new Dimension(width, 1));
|
installButtonPlaceholder = Box.createRigidArea(new Dimension(width, 1));
|
||||||
@ -79,6 +84,11 @@ public class ContributedLibraryTableCellJPanel extends JPanel {
|
|||||||
buttonsPanel.setOpaque(false);
|
buttonsPanel.setOpaque(false);
|
||||||
|
|
||||||
buttonsPanel.add(Box.createHorizontalStrut(7));
|
buttonsPanel.add(Box.createHorizontalStrut(7));
|
||||||
|
if (PreferencesData.getBoolean("ide.accessible")) {
|
||||||
|
buttonsPanel.add(moreInfoButton);
|
||||||
|
buttonsPanel.add(Box.createHorizontalStrut(5));
|
||||||
|
buttonsPanel.add(Box.createHorizontalStrut(15));
|
||||||
|
}
|
||||||
buttonsPanel.add(downgradeChooser);
|
buttonsPanel.add(downgradeChooser);
|
||||||
buttonsPanel.add(Box.createHorizontalStrut(5));
|
buttonsPanel.add(Box.createHorizontalStrut(5));
|
||||||
buttonsPanel.add(downgradeButton);
|
buttonsPanel.add(downgradeButton);
|
||||||
@ -141,7 +151,7 @@ public class ContributedLibraryTableCellJPanel extends JPanel {
|
|||||||
String name = selected.getName();
|
String name = selected.getName();
|
||||||
String author = selected.getAuthor();
|
String author = selected.getAuthor();
|
||||||
// String maintainer = selectedLib.getMaintainer();
|
// String maintainer = selectedLib.getMaintainer();
|
||||||
String website = selected.getWebsite();
|
final String website = selected.getWebsite();
|
||||||
String sentence = selected.getSentence();
|
String sentence = selected.getSentence();
|
||||||
String paragraph = selected.getParagraph();
|
String paragraph = selected.getParagraph();
|
||||||
// String availableVer = selectedLib.getVersion();
|
// String availableVer = selectedLib.getVersion();
|
||||||
@ -188,7 +198,7 @@ public class ContributedLibraryTableCellJPanel extends JPanel {
|
|||||||
desc += "<br />";
|
desc += "<br />";
|
||||||
}
|
}
|
||||||
if (author != null && !author.isEmpty()) {
|
if (author != null && !author.isEmpty()) {
|
||||||
desc += format("<a href=\"{0}\">More info</a>", website);
|
desc = setButtonOrLink(moreInfoButton, desc, moreInfoLbl, website);
|
||||||
}
|
}
|
||||||
|
|
||||||
desc += "</body></html>";
|
desc += "</body></html>";
|
||||||
@ -215,6 +225,25 @@ public class ContributedLibraryTableCellJPanel extends JPanel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// same function as in ContributedPlatformTableCellJPanel - is there a utils file this can move to?
|
||||||
|
private String setButtonOrLink(JButton button, String desc, String label, String url) {
|
||||||
|
boolean accessibleIDE = PreferencesData.getBoolean("ide.accessible");
|
||||||
|
String retString = desc;
|
||||||
|
|
||||||
|
if (accessibleIDE) {
|
||||||
|
button.setVisible(true);
|
||||||
|
button.addActionListener(e -> {
|
||||||
|
Base.openURL(url);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// if not accessible IDE, keep link the same EXCEPT that now the link text is translated!
|
||||||
|
retString += format("<a href=\"{0}\">{1}</a><br/>", url, label);
|
||||||
|
}
|
||||||
|
|
||||||
|
return retString;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO Make this a method of Theme
|
// TODO Make this a method of Theme
|
||||||
private JTextPane makeNewDescription() {
|
private JTextPane makeNewDescription() {
|
||||||
if (getComponentCount() > 0) {
|
if (getComponentCount() > 0) {
|
||||||
|
@ -57,11 +57,14 @@ import cc.arduino.contributions.packages.ContributedHelp;
|
|||||||
import cc.arduino.contributions.packages.ContributedPlatform;
|
import cc.arduino.contributions.packages.ContributedPlatform;
|
||||||
import cc.arduino.contributions.ui.InstallerTableCell;
|
import cc.arduino.contributions.ui.InstallerTableCell;
|
||||||
import processing.app.Base;
|
import processing.app.Base;
|
||||||
|
import processing.app.PreferencesData;
|
||||||
import processing.app.Theme;
|
import processing.app.Theme;
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class ContributedPlatformTableCellJPanel extends JPanel {
|
public class ContributedPlatformTableCellJPanel extends JPanel {
|
||||||
|
|
||||||
|
final JButton moreInfoButton;
|
||||||
|
final JButton onlineHelpButton;
|
||||||
final JButton installButton;
|
final JButton installButton;
|
||||||
final JButton removeButton;
|
final JButton removeButton;
|
||||||
final Component removeButtonPlaceholder;
|
final Component removeButtonPlaceholder;
|
||||||
@ -72,6 +75,8 @@ public class ContributedPlatformTableCellJPanel extends JPanel {
|
|||||||
final JPanel buttonsPanel;
|
final JPanel buttonsPanel;
|
||||||
final JPanel inactiveButtonsPanel;
|
final JPanel inactiveButtonsPanel;
|
||||||
final JLabel statusLabel;
|
final JLabel statusLabel;
|
||||||
|
private final String moreInfoLbl = tr("More Info");
|
||||||
|
private final String onlineHelpLbl = tr("Online Help");
|
||||||
|
|
||||||
public ContributedPlatformTableCellJPanel() {
|
public ContributedPlatformTableCellJPanel() {
|
||||||
super();
|
super();
|
||||||
@ -79,6 +84,10 @@ public class ContributedPlatformTableCellJPanel extends JPanel {
|
|||||||
|
|
||||||
{
|
{
|
||||||
installButton = new JButton(tr("Install"));
|
installButton = new JButton(tr("Install"));
|
||||||
|
moreInfoButton = new JButton(moreInfoLbl);
|
||||||
|
moreInfoButton.setVisible(false);
|
||||||
|
onlineHelpButton = new JButton(onlineHelpLbl);
|
||||||
|
onlineHelpButton.setVisible(false);
|
||||||
int width = installButton.getPreferredSize().width;
|
int width = installButton.getPreferredSize().width;
|
||||||
installButtonPlaceholder = Box.createRigidArea(new Dimension(width, 1));
|
installButtonPlaceholder = Box.createRigidArea(new Dimension(width, 1));
|
||||||
}
|
}
|
||||||
@ -115,6 +124,13 @@ public class ContributedPlatformTableCellJPanel extends JPanel {
|
|||||||
buttonsPanel.setOpaque(false);
|
buttonsPanel.setOpaque(false);
|
||||||
|
|
||||||
buttonsPanel.add(Box.createHorizontalStrut(7));
|
buttonsPanel.add(Box.createHorizontalStrut(7));
|
||||||
|
if (PreferencesData.getBoolean("ide.accessible")) { // only add the buttons if needed
|
||||||
|
buttonsPanel.add(onlineHelpButton);
|
||||||
|
buttonsPanel.add(Box.createHorizontalStrut(5));
|
||||||
|
buttonsPanel.add(moreInfoButton);
|
||||||
|
buttonsPanel.add(Box.createHorizontalStrut(5));
|
||||||
|
buttonsPanel.add(Box.createHorizontalStrut(15));
|
||||||
|
}
|
||||||
buttonsPanel.add(downgradeChooser);
|
buttonsPanel.add(downgradeChooser);
|
||||||
buttonsPanel.add(Box.createHorizontalStrut(5));
|
buttonsPanel.add(Box.createHorizontalStrut(5));
|
||||||
buttonsPanel.add(downgradeButton);
|
buttonsPanel.add(downgradeButton);
|
||||||
@ -149,6 +165,25 @@ public class ContributedPlatformTableCellJPanel extends JPanel {
|
|||||||
add(Box.createVerticalStrut(15));
|
add(Box.createVerticalStrut(15));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// same function as in ContributedLibraryTableCellJPanel - is there a utils file this can move to?
|
||||||
|
private String setButtonOrLink(JButton button, String desc, String label, String url) {
|
||||||
|
boolean accessibleIDE = PreferencesData.getBoolean("ide.accessible");
|
||||||
|
String retString = desc;
|
||||||
|
|
||||||
|
if (accessibleIDE) {
|
||||||
|
button.setVisible(true);
|
||||||
|
button.addActionListener(e -> {
|
||||||
|
Base.openURL(url);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// if not accessible IDE, keep link the same EXCEPT that now the link text is translated!
|
||||||
|
retString += " " + format("<a href=\"{0}\">{1}</a><br/>", url, label);
|
||||||
|
}
|
||||||
|
|
||||||
|
return retString;
|
||||||
|
}
|
||||||
|
|
||||||
void update(JTable parentTable, Object value, boolean isSelected,
|
void update(JTable parentTable, Object value, boolean isSelected,
|
||||||
boolean hasBuiltInRelease) {
|
boolean hasBuiltInRelease) {
|
||||||
ContributedPlatformReleases releases = (ContributedPlatformReleases) value;
|
ContributedPlatformReleases releases = (ContributedPlatformReleases) value;
|
||||||
@ -216,16 +251,17 @@ public class ContributedPlatformTableCellJPanel extends JPanel {
|
|||||||
} else if (selected.getParentPackage().getHelp() != null) {
|
} else if (selected.getParentPackage().getHelp() != null) {
|
||||||
help = selected.getParentPackage().getHelp();
|
help = selected.getParentPackage().getHelp();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (help != null) {
|
if (help != null) {
|
||||||
String url = help.getOnline();
|
String url = help.getOnline();
|
||||||
if (url != null && !url.isEmpty()) {
|
if (url != null && !url.isEmpty()) {
|
||||||
desc += " " + format("<a href=\"{0}\">Online help</a><br/>", url);
|
desc = setButtonOrLink(onlineHelpButton, desc, onlineHelpLbl, url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String url = selected.getParentPackage().getWebsiteURL();
|
String url = selected.getParentPackage().getWebsiteURL();
|
||||||
if (url != null && !url.isEmpty()) {
|
if (url != null && !url.isEmpty()) {
|
||||||
desc += " " + format("<a href=\"{0}\">More info</a>", url);
|
desc = setButtonOrLink(moreInfoButton, desc, moreInfoLbl, url);
|
||||||
}
|
}
|
||||||
|
|
||||||
desc += "</body></html>";
|
desc += "</body></html>";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user