57
57
import cc .arduino .contributions .packages .ContributedPlatform ;
58
58
import cc .arduino .contributions .ui .InstallerTableCell ;
59
59
import processing .app .Base ;
60
+ import processing .app .PreferencesData ;
60
61
import processing .app .Theme ;
61
62
62
63
@ SuppressWarnings ("serial" )
63
64
public class ContributedPlatformTableCellJPanel extends JPanel {
64
65
66
+ final JButton moreInfoButton ;
67
+ final JButton onlineHelpButton ;
65
68
final JButton installButton ;
66
69
final JButton removeButton ;
67
70
final Component removeButtonPlaceholder ;
@@ -72,13 +75,19 @@ public class ContributedPlatformTableCellJPanel extends JPanel {
72
75
final JPanel buttonsPanel ;
73
76
final JPanel inactiveButtonsPanel ;
74
77
final JLabel statusLabel ;
78
+ private final String moreInfoLbl = tr ("More Info" );
79
+ private final String onlineHelpLbl = tr ("Online Help" );
75
80
76
81
public ContributedPlatformTableCellJPanel () {
77
82
super ();
78
83
setLayout (new BoxLayout (this , BoxLayout .Y_AXIS ));
79
84
80
85
{
81
86
installButton = new JButton (tr ("Install" ));
87
+ moreInfoButton = new JButton (moreInfoLbl );
88
+ moreInfoButton .setVisible (false );
89
+ onlineHelpButton = new JButton (onlineHelpLbl );
90
+ onlineHelpButton .setVisible (false );
82
91
int width = installButton .getPreferredSize ().width ;
83
92
installButtonPlaceholder = Box .createRigidArea (new Dimension (width , 1 ));
84
93
}
@@ -115,6 +124,13 @@ public ContributedPlatformTableCellJPanel() {
115
124
buttonsPanel .setOpaque (false );
116
125
117
126
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
+ }
118
134
buttonsPanel .add (downgradeChooser );
119
135
buttonsPanel .add (Box .createHorizontalStrut (5 ));
120
136
buttonsPanel .add (downgradeButton );
@@ -149,6 +165,25 @@ public ContributedPlatformTableCellJPanel() {
149
165
add (Box .createVerticalStrut (15 ));
150
166
}
151
167
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
+
152
187
void update (JTable parentTable , Object value , boolean isSelected ,
153
188
boolean hasBuiltInRelease ) {
154
189
ContributedPlatformReleases releases = (ContributedPlatformReleases ) value ;
@@ -216,16 +251,17 @@ void update(JTable parentTable, Object value, boolean isSelected,
216
251
} else if (selected .getParentPackage ().getHelp () != null ) {
217
252
help = selected .getParentPackage ().getHelp ();
218
253
}
254
+
219
255
if (help != null ) {
220
256
String url = help .getOnline ();
221
257
if (url != null && !url .isEmpty ()) {
222
- desc += " " + format ( "<a href= \" {0} \" >Online help</a><br/>" , url );
258
+ desc = setButtonOrLink ( onlineHelpButton , desc , onlineHelpLbl , url );
223
259
}
224
260
}
225
261
226
262
String url = selected .getParentPackage ().getWebsiteURL ();
227
263
if (url != null && !url .isEmpty ()) {
228
- desc += " " + format ( "<a href= \" {0} \" >More info</a>" , url );
264
+ desc = setButtonOrLink ( moreInfoButton , desc , moreInfoLbl , url );
229
265
}
230
266
231
267
desc += "</body></html>" ;
0 commit comments