diff --git a/app/src/cc/arduino/contributions/libraries/ui/ContributedLibraryTableCellEditor.java b/app/src/cc/arduino/contributions/libraries/ui/ContributedLibraryTableCellEditor.java index c5c2e41751c..7c2ecff383f 100644 --- a/app/src/cc/arduino/contributions/libraries/ui/ContributedLibraryTableCellEditor.java +++ b/app/src/cc/arduino/contributions/libraries/ui/ContributedLibraryTableCellEditor.java @@ -125,6 +125,7 @@ public Component getTableCellEditorComponent(JTable table, Object value, editorCell.versionToInstallChooser .setVisible(!mayInstalled.isPresent() && notInstalled.size() > 1); + editorCell.setForeground(Color.BLACK); editorCell.setBackground(new Color(218, 227, 227)); // #dae3e3 return editorCell; } diff --git a/app/src/cc/arduino/contributions/libraries/ui/ContributedLibraryTableCellJPanel.java b/app/src/cc/arduino/contributions/libraries/ui/ContributedLibraryTableCellJPanel.java index 865de577630..46182bd0c5d 100644 --- a/app/src/cc/arduino/contributions/libraries/ui/ContributedLibraryTableCellJPanel.java +++ b/app/src/cc/arduino/contributions/libraries/ui/ContributedLibraryTableCellJPanel.java @@ -42,6 +42,7 @@ public class ContributedLibraryTableCellJPanel extends JPanel { final JPanel buttonsPanel; final JPanel inactiveButtonsPanel; final JLabel statusLabel; + final JTextPane description; private final String moreInfoLbl = tr("More info"); public ContributedLibraryTableCellJPanel(JTable parentTable, Object value, @@ -77,7 +78,8 @@ public ContributedLibraryTableCellJPanel(JTable parentTable, Object value, versionToInstallChooser .setMinimumSize(new Dimension((int)versionToInstallChooser.getPreferredSize().getWidth() + 50, (int)versionToInstallChooser.getPreferredSize().getHeight())); - makeNewDescription(); + description = makeNewDescription(); + add(description); buttonsPanel = new JPanel(); buttonsPanel.setLayout(new BoxLayout(buttonsPanel, BoxLayout.X_AXIS)); @@ -121,7 +123,6 @@ public ContributedLibraryTableCellJPanel(JTable parentTable, Object value, add(Box.createVerticalStrut(15)); ContributedLibraryReleases releases = (ContributedLibraryReleases) value; - JTextPane description = makeNewDescription(); // FIXME: happens on macosx, don't know why if (releases == null) @@ -205,7 +206,6 @@ public ContributedLibraryTableCellJPanel(JTable parentTable, Object value, description.setText(desc); // copy description to accessibility context for screen readers to use description.getAccessibleContext().setAccessibleDescription(desc); - 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. @@ -215,14 +215,6 @@ public ContributedLibraryTableCellJPanel(JTable parentTable, Object value, InstallerTableCell .setJTextPaneDimensionToFitContainedText(description, parentTable.getBounds().width); - - if (isSelected) { - setBackground(parentTable.getSelectionBackground()); - setForeground(parentTable.getSelectionForeground()); - } else { - setBackground(parentTable.getBackground()); - setForeground(parentTable.getForeground()); - } } // same function as in ContributedPlatformTableCellJPanel - is there a utils file this can move to? @@ -246,9 +238,6 @@ private String setButtonOrLink(JButton button, String desc, String label, String // TODO Make this a method of Theme private JTextPane makeNewDescription() { - if (getComponentCount() > 0) { - remove(0); - } JTextPane description = new JTextPane(); description.setInheritsPopupMenu(true); Insets margin = description.getMargin(); @@ -274,7 +263,6 @@ private JTextPane makeNewDescription() { } }); // description.addKeyListener(new DelegatingKeyListener(parentTable)); - add(description, 0); return description; } @@ -283,4 +271,11 @@ public void setButtonsVisible(boolean enabled) { buttonsPanel.setVisible(enabled); inactiveButtonsPanel.setVisible(!enabled); } + + public void setForeground(Color c) { + super.setForeground(c); + // The description is not opaque, so copy our foreground color to it. + if (description != null) + description.setForeground(c); + } } diff --git a/app/src/cc/arduino/contributions/libraries/ui/ContributedLibraryTableCellRenderer.java b/app/src/cc/arduino/contributions/libraries/ui/ContributedLibraryTableCellRenderer.java index bc4b3ffd940..d107f90208a 100644 --- a/app/src/cc/arduino/contributions/libraries/ui/ContributedLibraryTableCellRenderer.java +++ b/app/src/cc/arduino/contributions/libraries/ui/ContributedLibraryTableCellRenderer.java @@ -46,6 +46,7 @@ public Component getTableCellRendererComponent(JTable table, Object value, value, isSelected); cell.setButtonsVisible(false); + cell.setForeground(Color.BLACK); if (row % 2 == 0) { cell.setBackground(new Color(236, 241, 241)); // #ecf1f1 } else { diff --git a/app/src/cc/arduino/contributions/packages/ui/ContributedPlatformTableCellEditor.java b/app/src/cc/arduino/contributions/packages/ui/ContributedPlatformTableCellEditor.java index 26bcb1c9d3b..7fe221fa340 100644 --- a/app/src/cc/arduino/contributions/packages/ui/ContributedPlatformTableCellEditor.java +++ b/app/src/cc/arduino/contributions/packages/ui/ContributedPlatformTableCellEditor.java @@ -129,7 +129,8 @@ public Component getTableCellEditorComponent(JTable table, Object _value, cell.versionToInstallChooser .setVisible(installed == null && uninstalledReleases.size() > 1); - cell.update(table, _value, true, !installedBuiltIn.isEmpty()); + cell.update(table, _value, !installedBuiltIn.isEmpty()); + cell.setForeground(Color.BLACK); cell.setBackground(new Color(218, 227, 227)); // #dae3e3 return cell; } diff --git a/app/src/cc/arduino/contributions/packages/ui/ContributedPlatformTableCellJPanel.java b/app/src/cc/arduino/contributions/packages/ui/ContributedPlatformTableCellJPanel.java index d59538823f7..100c7b8b12b 100644 --- a/app/src/cc/arduino/contributions/packages/ui/ContributedPlatformTableCellJPanel.java +++ b/app/src/cc/arduino/contributions/packages/ui/ContributedPlatformTableCellJPanel.java @@ -75,6 +75,7 @@ public class ContributedPlatformTableCellJPanel extends JPanel { final JPanel buttonsPanel; final JPanel inactiveButtonsPanel; final JLabel statusLabel; + final JTextPane description; private final String moreInfoLbl = tr("More Info"); private final String onlineHelpLbl = tr("Online Help"); @@ -117,7 +118,8 @@ public ContributedPlatformTableCellJPanel() { versionToInstallChooser .setMaximumSize(versionToInstallChooser.getPreferredSize()); - makeNewDescription(); + description = makeNewDescription(); + add(description); buttonsPanel = new JPanel(); buttonsPanel.setLayout(new BoxLayout(buttonsPanel, BoxLayout.X_AXIS)); @@ -184,12 +186,9 @@ private String setButtonOrLink(JButton button, String desc, String label, String return retString; } - void update(JTable parentTable, Object value, boolean isSelected, - boolean hasBuiltInRelease) { + void update(JTable parentTable, Object value, boolean hasBuiltInRelease) { ContributedPlatformReleases releases = (ContributedPlatformReleases) value; - JTextPane description = makeNewDescription(); - // FIXME: happens on macosx, don't know why if (releases == null) { return; @@ -268,7 +267,6 @@ void update(JTable parentTable, Object value, boolean isSelected, description.setText(desc); // copy description to accessibility context for screen readers to use description.getAccessibleContext().setAccessibleDescription(desc); - 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. @@ -278,20 +276,9 @@ void update(JTable parentTable, Object value, boolean isSelected, int width = parentTable.getBounds().width; InstallerTableCell.setJTextPaneDimensionToFitContainedText(description, width); - - if (isSelected) { - setBackground(parentTable.getSelectionBackground()); - setForeground(parentTable.getSelectionForeground()); - } else { - setBackground(parentTable.getBackground()); - setForeground(parentTable.getForeground()); - } } private JTextPane makeNewDescription() { - if (getComponentCount() > 0) { - remove(0); - } JTextPane description = new JTextPane(); description.setInheritsPopupMenu(true); Insets margin = description.getMargin(); @@ -315,7 +302,6 @@ private JTextPane makeNewDescription() { Base.openURL(e.getDescription()); } }); - add(description, 0); return description; } @@ -326,4 +312,10 @@ public void setButtonsVisible(boolean enabled) { inactiveButtonsPanel.setVisible(!enabled); } + public void setForeground(Color c) { + super.setForeground(c); + // The description is not opaque, so copy our foreground color to it. + if (description != null) + description.setForeground(c); + } } diff --git a/app/src/cc/arduino/contributions/packages/ui/ContributedPlatformTableCellRenderer.java b/app/src/cc/arduino/contributions/packages/ui/ContributedPlatformTableCellRenderer.java index cc4b1d0c186..b6f6aae015c 100644 --- a/app/src/cc/arduino/contributions/packages/ui/ContributedPlatformTableCellRenderer.java +++ b/app/src/cc/arduino/contributions/packages/ui/ContributedPlatformTableCellRenderer.java @@ -44,8 +44,9 @@ public Component getTableCellRendererComponent(JTable table, Object value, int column) { ContributedPlatformTableCellJPanel cell = new ContributedPlatformTableCellJPanel(); cell.setButtonsVisible(false); - cell.update(table, value, isSelected, false); + cell.update(table, value, false); + cell.setForeground(Color.BLACK); if (row % 2 == 0) { cell.setBackground(new Color(236, 241, 241)); // #ecf1f1 } else { diff --git a/app/src/cc/arduino/contributions/ui/InstallerJDialog.java b/app/src/cc/arduino/contributions/ui/InstallerJDialog.java index dd2998bc441..2888cd68800 100644 --- a/app/src/cc/arduino/contributions/ui/InstallerJDialog.java +++ b/app/src/cc/arduino/contributions/ui/InstallerJDialog.java @@ -180,7 +180,6 @@ public void windowOpened(WindowEvent e) { contribTable.setDragEnabled(false); contribTable.setIntercellSpacing(new Dimension(0, 1)); contribTable.setShowVerticalLines(false); - contribTable.setSelectionBackground(Theme.getColor("status.notice.bgcolor")); contribTable.addKeyListener(new AbstractKeyListener() { @Override