Skip to content

Commit aaef922

Browse files
authored
Merge pull request #9164 from joew46167/buttonsInManagers
Add Buttons in Library and Boards managers
2 parents a740021 + 1b515b1 commit aaef922

File tree

3 files changed

+70
-4
lines changed

3 files changed

+70
-4
lines changed

Diff for: app/src/cc/arduino/contributions/libraries/ui/ContributedLibraryTableCellJPanel.java

+31-2
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,12 @@
2828
import cc.arduino.contributions.libraries.ContributedLibraryReleases;
2929
import cc.arduino.contributions.ui.InstallerTableCell;
3030
import processing.app.Base;
31+
import processing.app.PreferencesData;
3132
import processing.app.Theme;
3233

3334
public class ContributedLibraryTableCellJPanel extends JPanel {
3435

36+
final JButton moreInfoButton;
3537
final JButton installButton;
3638
final Component installButtonPlaceholder;
3739
final JComboBox downgradeChooser;
@@ -40,12 +42,15 @@ public class ContributedLibraryTableCellJPanel extends JPanel {
4042
final JPanel buttonsPanel;
4143
final JPanel inactiveButtonsPanel;
4244
final JLabel statusLabel;
45+
private final String moreInfoLbl = tr("More info");
4346

4447
public ContributedLibraryTableCellJPanel(JTable parentTable, Object value,
4548
boolean isSelected) {
4649
super();
4750
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
4851

52+
moreInfoButton = new JButton(moreInfoLbl);
53+
moreInfoButton.setVisible(false);
4954
installButton = new JButton(tr("Install"));
5055
int width = installButton.getPreferredSize().width;
5156
installButtonPlaceholder = Box.createRigidArea(new Dimension(width, 1));
@@ -79,6 +84,11 @@ public ContributedLibraryTableCellJPanel(JTable parentTable, Object value,
7984
buttonsPanel.setOpaque(false);
8085

8186
buttonsPanel.add(Box.createHorizontalStrut(7));
87+
if (PreferencesData.getBoolean("ide.accessible")) {
88+
buttonsPanel.add(moreInfoButton);
89+
buttonsPanel.add(Box.createHorizontalStrut(5));
90+
buttonsPanel.add(Box.createHorizontalStrut(15));
91+
}
8292
buttonsPanel.add(downgradeChooser);
8393
buttonsPanel.add(Box.createHorizontalStrut(5));
8494
buttonsPanel.add(downgradeButton);
@@ -141,7 +151,7 @@ public ContributedLibraryTableCellJPanel(JTable parentTable, Object value,
141151
String name = selected.getName();
142152
String author = selected.getAuthor();
143153
// String maintainer = selectedLib.getMaintainer();
144-
String website = selected.getWebsite();
154+
final String website = selected.getWebsite();
145155
String sentence = selected.getSentence();
146156
String paragraph = selected.getParagraph();
147157
// String availableVer = selectedLib.getVersion();
@@ -188,7 +198,7 @@ public ContributedLibraryTableCellJPanel(JTable parentTable, Object value,
188198
desc += "<br />";
189199
}
190200
if (author != null && !author.isEmpty()) {
191-
desc += format("<a href=\"{0}\">More info</a>", website);
201+
desc = setButtonOrLink(moreInfoButton, desc, moreInfoLbl, website);
192202
}
193203

194204
desc += "</body></html>";
@@ -215,6 +225,25 @@ public ContributedLibraryTableCellJPanel(JTable parentTable, Object value,
215225
}
216226
}
217227

228+
// same function as in ContributedPlatformTableCellJPanel - is there a utils file this can move to?
229+
private String setButtonOrLink(JButton button, String desc, String label, String url) {
230+
boolean accessibleIDE = PreferencesData.getBoolean("ide.accessible");
231+
String retString = desc;
232+
233+
if (accessibleIDE) {
234+
button.setVisible(true);
235+
button.addActionListener(e -> {
236+
Base.openURL(url);
237+
});
238+
}
239+
else {
240+
// if not accessible IDE, keep link the same EXCEPT that now the link text is translated!
241+
retString += format("<a href=\"{0}\">{1}</a><br/>", url, label);
242+
}
243+
244+
return retString;
245+
}
246+
218247
// TODO Make this a method of Theme
219248
private JTextPane makeNewDescription() {
220249
if (getComponentCount() > 0) {

Diff for: app/src/cc/arduino/contributions/packages/ui/ContributedPlatformTableCellJPanel.java

+38-2
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,14 @@
5757
import cc.arduino.contributions.packages.ContributedPlatform;
5858
import cc.arduino.contributions.ui.InstallerTableCell;
5959
import processing.app.Base;
60+
import processing.app.PreferencesData;
6061
import processing.app.Theme;
6162

6263
@SuppressWarnings("serial")
6364
public class ContributedPlatformTableCellJPanel extends JPanel {
6465

66+
final JButton moreInfoButton;
67+
final JButton onlineHelpButton;
6568
final JButton installButton;
6669
final JButton removeButton;
6770
final Component removeButtonPlaceholder;
@@ -72,13 +75,19 @@ public class ContributedPlatformTableCellJPanel extends JPanel {
7275
final JPanel buttonsPanel;
7376
final JPanel inactiveButtonsPanel;
7477
final JLabel statusLabel;
78+
private final String moreInfoLbl = tr("More Info");
79+
private final String onlineHelpLbl = tr("Online Help");
7580

7681
public ContributedPlatformTableCellJPanel() {
7782
super();
7883
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
7984

8085
{
8186
installButton = new JButton(tr("Install"));
87+
moreInfoButton = new JButton(moreInfoLbl);
88+
moreInfoButton.setVisible(false);
89+
onlineHelpButton = new JButton(onlineHelpLbl);
90+
onlineHelpButton.setVisible(false);
8291
int width = installButton.getPreferredSize().width;
8392
installButtonPlaceholder = Box.createRigidArea(new Dimension(width, 1));
8493
}
@@ -115,6 +124,13 @@ public ContributedPlatformTableCellJPanel() {
115124
buttonsPanel.setOpaque(false);
116125

117126
buttonsPanel.add(Box.createHorizontalStrut(7));
127+
if (PreferencesData.getBoolean("ide.accessible")) { // only add the buttons if needed
128+
buttonsPanel.add(onlineHelpButton);
129+
buttonsPanel.add(Box.createHorizontalStrut(5));
130+
buttonsPanel.add(moreInfoButton);
131+
buttonsPanel.add(Box.createHorizontalStrut(5));
132+
buttonsPanel.add(Box.createHorizontalStrut(15));
133+
}
118134
buttonsPanel.add(downgradeChooser);
119135
buttonsPanel.add(Box.createHorizontalStrut(5));
120136
buttonsPanel.add(downgradeButton);
@@ -149,6 +165,25 @@ public ContributedPlatformTableCellJPanel() {
149165
add(Box.createVerticalStrut(15));
150166
}
151167

168+
// same function as in ContributedLibraryTableCellJPanel - is there a utils file this can move to?
169+
private String setButtonOrLink(JButton button, String desc, String label, String url) {
170+
boolean accessibleIDE = PreferencesData.getBoolean("ide.accessible");
171+
String retString = desc;
172+
173+
if (accessibleIDE) {
174+
button.setVisible(true);
175+
button.addActionListener(e -> {
176+
Base.openURL(url);
177+
});
178+
}
179+
else {
180+
// if not accessible IDE, keep link the same EXCEPT that now the link text is translated!
181+
retString += " " + format("<a href=\"{0}\">{1}</a><br/>", url, label);
182+
}
183+
184+
return retString;
185+
}
186+
152187
void update(JTable parentTable, Object value, boolean isSelected,
153188
boolean hasBuiltInRelease) {
154189
ContributedPlatformReleases releases = (ContributedPlatformReleases) value;
@@ -216,16 +251,17 @@ void update(JTable parentTable, Object value, boolean isSelected,
216251
} else if (selected.getParentPackage().getHelp() != null) {
217252
help = selected.getParentPackage().getHelp();
218253
}
254+
219255
if (help != null) {
220256
String url = help.getOnline();
221257
if (url != null && !url.isEmpty()) {
222-
desc += " " + format("<a href=\"{0}\">Online help</a><br/>", url);
258+
desc = setButtonOrLink(onlineHelpButton, desc, onlineHelpLbl, url);
223259
}
224260
}
225261

226262
String url = selected.getParentPackage().getWebsiteURL();
227263
if (url != null && !url.isEmpty()) {
228-
desc += " " + format("<a href=\"{0}\">More info</a>", url);
264+
desc = setButtonOrLink(moreInfoButton, desc, moreInfoLbl, url);
229265
}
230266

231267
desc += "</body></html>";

Diff for: app/src/cc/arduino/contributions/ui/InstallerJDialog.java

+1
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ protected void onFilter(String[] _filters) {
133133
updateIndexFilter(filters, categoryFilter);
134134
}
135135
};
136+
filterField.getAccessibleContext().setAccessibleDescription(tr("Search Filter"));
136137

137138
// Add cut/copy/paste contextual menu to the search filter input field.
138139
JPopupMenu menu = new JPopupMenu();

0 commit comments

Comments
 (0)