5757import cc .arduino .contributions .packages .ContributedPlatform ;
5858import cc .arduino .contributions .ui .InstallerTableCell ;
5959import processing .app .Base ;
60+ import processing .app .PreferencesData ;
6061import processing .app .Theme ;
6162
6263@ SuppressWarnings ("serial" )
6364public 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>" ;
0 commit comments