diff --git a/app/src/cc/arduino/packages/contributions/ui/ContributedPlatformTableCell.java b/app/src/cc/arduino/packages/contributions/ui/ContributedPlatformTableCell.java
new file mode 100644
index 000000000..795615f7b
--- /dev/null
+++ b/app/src/cc/arduino/packages/contributions/ui/ContributedPlatformTableCell.java
@@ -0,0 +1,237 @@
+/*
+ * This file is part of Arduino.
+ *
+ * Copyright 2014 Arduino LLC (http://www.arduino.cc/)
+ *
+ * Arduino is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * As a special exception, you may use this file as part of a free software
+ * library without restriction. Specifically, if other files instantiate
+ * templates or use macros or inline functions from this file, or you compile
+ * this file and link it with other files to produce an executable, this
+ * file does not by itself cause the resulting executable to be covered by
+ * the GNU General Public License. This exception does not however
+ * invalidate any other reasons why the executable file might be covered by
+ * the GNU General Public License.
+ */
+package cc.arduino.packages.contributions.ui;
+
+import static processing.app.I18n._;
+import static processing.app.I18n.format;
+
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.Insets;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.AbstractCellEditor;
+import javax.swing.Box;
+import javax.swing.BoxLayout;
+import javax.swing.JButton;
+import javax.swing.JPanel;
+import javax.swing.JTable;
+import javax.swing.JTextPane;
+import javax.swing.border.EmptyBorder;
+import javax.swing.event.HyperlinkEvent;
+import javax.swing.event.HyperlinkListener;
+import javax.swing.table.TableCellEditor;
+import javax.swing.table.TableCellRenderer;
+import javax.swing.text.Document;
+import javax.swing.text.html.HTMLDocument;
+import javax.swing.text.html.StyleSheet;
+
+import processing.app.Base;
+import cc.arduino.packages.contributions.ContributedBoard;
+import cc.arduino.packages.contributions.ContributedPlatform;
+import cc.arduino.packages.contributions.ui.ContributionIndexTableModel.ContributedPlatformReleases;
+
+@SuppressWarnings("serial")
+public class ContributedPlatformTableCell extends AbstractCellEditor implements
+ TableCellEditor, TableCellRenderer {
+
+ private JPanel panel;
+ private JTextPane description;
+ private JButton installButton;
+ private JButton removeButton;
+ private Component removeButtonPlaceholder;
+
+ public ContributedPlatformTableCell() {
+ description = new JTextPane();
+ description.setInheritsPopupMenu(true);
+ Insets margin = description.getMargin();
+ margin.bottom = 0;
+ description.setMargin(margin);
+ description.setContentType("text/html");
+ Document doc = description.getDocument();
+ if (doc instanceof HTMLDocument) {
+ HTMLDocument html = (HTMLDocument) doc;
+ StyleSheet stylesheet = html.getStyleSheet();
+ stylesheet.addRule("body { margin: 0; padding: 0;"
+ + "font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;"
+ + "font-size: 100%;" + "font-size: 0.95em; }");
+ }
+ description.setOpaque(false);
+ description.setBorder(new EmptyBorder(4, 7, 7, 7));
+ description.setHighlighter(null);
+ description.setEditable(false);
+ description.addHyperlinkListener(new HyperlinkListener() {
+ @Override
+ public void hyperlinkUpdate(HyperlinkEvent e) {
+ if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
+ Base.openURL(e.getDescription());
+ }
+ }
+ });
+
+ installButton = new JButton(_("Install"));
+ installButton.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ onInstall(editorValue.getSelected());
+ }
+ });
+
+ removeButton = new JButton(_("Remove"));
+ removeButton.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ onRemove(editorValue.getInstalled());
+ }
+ });
+
+ int width = removeButton.getPreferredSize().width;
+ removeButtonPlaceholder = Box.createRigidArea(new Dimension(width, 1));
+
+ panel = new JPanel();
+ panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
+
+ panel.add(description);
+ panel.add(Box.createHorizontalStrut(5));
+ panel.add(installButton);
+ panel.add(Box.createHorizontalStrut(5));
+ panel.add(removeButton);
+ panel.add(removeButtonPlaceholder);
+ panel.add(Box.createHorizontalStrut(5));
+ }
+
+ protected void onRemove(ContributedPlatform contributedPlatform) {
+ // Empty
+ }
+
+ protected void onInstall(ContributedPlatform contributedPlatform) {
+ // Empty
+ }
+
+ public Component getTableCellRendererComponent(JTable table, Object value,
+ boolean isSelected,
+ boolean hasFocus, int row,
+ int column) {
+ parentTable = table;
+ Component panel = getUpdatedCellComponent(value, isSelected, row);
+ return panel;
+ }
+
+ private ContributedPlatformReleases editorValue;
+ private JTable parentTable;
+
+ @Override
+ public Object getCellEditorValue() {
+ return editorValue;
+ }
+
+ @Override
+ public Component getTableCellEditorComponent(JTable table, Object value,
+ boolean isSelected, int row,
+ int column) {
+ parentTable = table;
+ editorValue = (ContributedPlatformReleases) value;
+ return getUpdatedCellComponent(value, true, row);
+ }
+
+ private Component getUpdatedCellComponent(Object value, boolean isSelected,
+ int row) {
+ ContributedPlatformReleases releases = (ContributedPlatformReleases) value;
+ ContributedPlatform selectedPlatform = releases.getSelected();
+ ContributedPlatform installedPlatform = releases.getInstalled();
+
+ boolean removable, installable, upgradable;
+ if (installedPlatform == null) {
+ installable = true;
+ removable = false;
+ upgradable = false;
+ } else {
+ installable = false;
+ removable = true;
+ upgradable = (selectedPlatform != installedPlatform);
+ }
+
+ if (installable)
+ installButton.setText(_("Install"));
+ if (upgradable)
+ installButton.setText(_("Upgrade"));
+ installButton.setVisible(installable || upgradable);
+
+ removeButton.setVisible(removable);
+ removeButtonPlaceholder.setVisible(!removable);
+
+ String desc = "
";
+ desc += "" + selectedPlatform.getName() + "";
+ String author = selectedPlatform.getParentPackage().getMaintainer();
+ String url = selectedPlatform.getParentPackage().getWebsiteURL();
+ if (author != null && !author.isEmpty()) {
+ desc += format(" by {1}", url, author);
+ }
+ desc += "
";
+ desc += "
";
+
+ desc += _("Boards contributed in this package:") + "
";
+ for (ContributedBoard board : selectedPlatform.getBoards())
+ desc += format("- {0}
", board.getName());
+ desc += "
";
+ desc += format(_("Available version: {0}"),
+ selectedPlatform.getVersion());
+ desc += "
";
+ if (removable) {
+ desc += format(_("Installed version: {0}"),
+ installedPlatform.getVersion());
+ }
+ desc += "
";
+ desc += "";
+ description.setText(desc);
+ description.setBackground(Color.WHITE);
+
+ if (isSelected) {
+ panel.setBackground(parentTable.getSelectionBackground());
+ panel.setForeground(parentTable.getSelectionForeground());
+ } else {
+ panel.setBackground(parentTable.getBackground());
+ panel.setForeground(parentTable.getForeground());
+ }
+
+ return panel;
+ }
+
+ void setEnabled(boolean enabled) {
+ installButton.setEnabled(enabled);
+ removeButton.setEnabled(enabled);
+ }
+
+ public void invalidate() {
+ panel.invalidate();
+ }
+
+}
diff --git a/app/src/cc/arduino/packages/contributions/ui/ContributedPlatformTableCellRenderer.java b/app/src/cc/arduino/packages/contributions/ui/ContributedPlatformTableCellRenderer.java
deleted file mode 100644
index 25b566826..000000000
--- a/app/src/cc/arduino/packages/contributions/ui/ContributedPlatformTableCellRenderer.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * This file is part of Arduino.
- *
- * Copyright 2014 Arduino LLC (http://www.arduino.cc/)
- *
- * Arduino is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * As a special exception, you may use this file as part of a free software
- * library without restriction. Specifically, if other files instantiate
- * templates or use macros or inline functions from this file, or you compile
- * this file and link it with other files to produce an executable, this
- * file does not by itself cause the resulting executable to be covered by
- * the GNU General Public License. This exception does not however
- * invalidate any other reasons why the executable file might be covered by
- * the GNU General Public License.
- */
-package cc.arduino.packages.contributions.ui;
-
-import java.awt.Color;
-import java.awt.Component;
-import java.awt.Insets;
-
-import javax.swing.BoxLayout;
-import javax.swing.JPanel;
-import javax.swing.JTable;
-import javax.swing.JTextPane;
-import javax.swing.border.EmptyBorder;
-import javax.swing.table.TableCellRenderer;
-import javax.swing.text.Document;
-import javax.swing.text.html.HTMLDocument;
-import javax.swing.text.html.StyleSheet;
-
-import cc.arduino.packages.contributions.ContributedBoard;
-import cc.arduino.packages.contributions.ContributedPlatform;
-
-@SuppressWarnings("serial")
-public class ContributedPlatformTableCellRenderer extends JPanel implements
- TableCellRenderer {
-
- private JTextPane description;
-
- public ContributedPlatformTableCellRenderer() {
- super();
-
- // Align contents to the left
- setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
- setAlignmentX(Component.LEFT_ALIGNMENT);
-
- description = new JTextPane();
- description.setInheritsPopupMenu(true);
- Insets margin = description.getMargin();
- margin.bottom = 0;
- description.setMargin(margin);
- description.setContentType("text/html");
- setTextStyle(description);
- description.setOpaque(false);
- description.setBorder(new EmptyBorder(4, 7, 7, 7));
- description.setHighlighter(null);
- add(description);
- }
-
- static void setTextStyle(JTextPane textPane) {
- Document doc = textPane.getDocument();
- if (doc instanceof HTMLDocument) {
- HTMLDocument html = (HTMLDocument) doc;
- StyleSheet stylesheet = html.getStyleSheet();
- stylesheet.addRule("body { margin: 0; padding: 0;"
- + "font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;"
- + "font-size: 100%;" + "font-size: 0.95em; }");
- }
- }
-
- public Component getTableCellRendererComponent(JTable table, Object value,
- boolean isSelected,
- boolean hasFocus, int row,
- int column) {
- ContributedPlatform contrib = (ContributedPlatform) value;
-
- String descriptionText = "" + contrib.getName() + "";
- String authorList = "arduino"; // contrib.getAuthorList();
- if (authorList != null && !authorList.isEmpty()) {
- descriptionText += " by Arduino";
- }
- descriptionText += "
";
-
- descriptionText += "Boards contributed in this package:
";
- for (ContributedBoard board : contrib.getBoards())
- descriptionText += "- " + board.getName() + "
";
- // descriptionText += "
Available version: 1.5.5
";
- // descriptionText += "Installed version: 1.5.4
";
- descriptionText += "";
- description.setText(descriptionText);
- description.setBackground(Color.WHITE);
- description.setVisible(true);
-
- int h = getPreferredSize().height;
- if (table.getRowHeight(row) != h)
- table.setRowHeight(row, h);
-
- if (isSelected) {
- setBackground(table.getSelectionBackground());
- setForeground(table.getSelectionForeground());
- } else {
- setBackground(table.getBackground());
- setForeground(table.getForeground());
- }
- return this;
- }
-}
diff --git a/app/src/cc/arduino/packages/contributions/ui/ContributionIndexTableModel.java b/app/src/cc/arduino/packages/contributions/ui/ContributionIndexTableModel.java
index 0999480a5..8ca55606a 100644
--- a/app/src/cc/arduino/packages/contributions/ui/ContributionIndexTableModel.java
+++ b/app/src/cc/arduino/packages/contributions/ui/ContributionIndexTableModel.java
@@ -41,8 +41,6 @@ import cc.arduino.packages.contributions.ContributionsIndex;
public class ContributionIndexTableModel extends AbstractTableModel {
public final static int DESCRIPTION_COL = 0;
- public final static int VERSION_COL = 1;
- public final static int INSTALLED_COL = 2;
public static class ContributedPlatformReleases {
public ContributedPackage packager;
@@ -83,6 +81,7 @@ public class ContributionIndexTableModel extends AbstractTableModel {
for (ContributedPlatform plat : releases) {
if (latest == null)
latest = plat;
+ // TODO a better version compare
if (plat.getVersion().compareTo(latest.getVersion()) > 0)
latest = plat;
}
@@ -101,14 +100,22 @@ public class ContributionIndexTableModel extends AbstractTableModel {
}
}
}
+
+ public void select(ContributedPlatform value) {
+ for (ContributedPlatform plat : releases) {
+ if (plat == value) {
+ selected = plat;
+ return;
+ }
+ }
+ }
}
private List contributions = new ArrayList();
- private String[] m_colNames = { "Description", "Available", "Installed" };
+ private String[] columnNames = { "Description" };
- private Class>[] m_colTypes = { ContributedPlatform.class, Object[].class,
- String.class };
+ private Class>[] columnTypes = { ContributedPlatform.class };
public void updateIndex(ContributionsIndex index) {
contributions.clear();
@@ -117,6 +124,7 @@ public class ContributionIndexTableModel extends AbstractTableModel {
addContribution(platform);
}
}
+ fireTableDataChanged();
}
private void addContribution(ContributedPlatform platform) {
@@ -132,7 +140,7 @@ public class ContributionIndexTableModel extends AbstractTableModel {
@Override
public int getColumnCount() {
- return m_colNames.length;
+ return columnNames.length;
}
@Override
@@ -142,18 +150,17 @@ public class ContributionIndexTableModel extends AbstractTableModel {
@Override
public String getColumnName(int column) {
- return m_colNames[column];
+ return columnNames[column];
}
@Override
- public Class> getColumnClass(int col) {
- return m_colTypes[col];
+ public Class> getColumnClass(int colum) {
+ return columnTypes[colum];
}
@Override
public void setValueAt(Object value, int row, int col) {
- if (col == VERSION_COL) {
- contributions.get(row).selectVersion((String) value);
+ if (col == DESCRIPTION_COL) {
fireTableCellUpdated(row, col);
}
}
@@ -161,22 +168,15 @@ public class ContributionIndexTableModel extends AbstractTableModel {
@Override
public Object getValueAt(int row, int col) {
ContributedPlatformReleases contribution = contributions.get(row);
- ContributedPlatform installed = contribution.getInstalled();
if (col == DESCRIPTION_COL) {
- return contribution.getSelected();
- }
- if (col == VERSION_COL) {
- return contribution.getSelected().getVersion();
- }
- if (col == INSTALLED_COL) {
- return installed == null ? "-" : installed.getVersion();
+ return contribution;// .getSelected();
}
return null;
}
@Override
public boolean isCellEditable(int row, int col) {
- return col == VERSION_COL || col == INSTALLED_COL;
+ return col == DESCRIPTION_COL;
}
public List getReleasesVersions(int row) {
@@ -191,4 +191,7 @@ public class ContributionIndexTableModel extends AbstractTableModel {
return contributions.get(row).getSelected();
}
+ public void update() {
+ fireTableDataChanged();
+ }
}
diff --git a/app/src/cc/arduino/packages/contributions/ui/ContributionInstallerUI.java b/app/src/cc/arduino/packages/contributions/ui/ContributionInstallerUI.java
deleted file mode 100644
index d8e1ac7f7..000000000
--- a/app/src/cc/arduino/packages/contributions/ui/ContributionInstallerUI.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * This file is part of Arduino.
- *
- * Copyright 2014 Arduino LLC (http://www.arduino.cc/)
- *
- * Arduino is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * As a special exception, you may use this file as part of a free software
- * library without restriction. Specifically, if other files instantiate
- * templates or use macros or inline functions from this file, or you compile
- * this file and link it with other files to produce an executable, this
- * file does not by itself cause the resulting executable to be covered by
- * the GNU General Public License. This exception does not however
- * invalidate any other reasons why the executable file might be covered by
- * the GNU General Public License.
- */
-package cc.arduino.packages.contributions.ui;
-
-import java.awt.BorderLayout;
-import java.awt.Component;
-import java.awt.Dialog;
-import java.awt.Dimension;
-import java.awt.FlowLayout;
-import java.awt.Window;
-import java.awt.event.ActionListener;
-
-import javax.swing.Box;
-import javax.swing.BoxLayout;
-import javax.swing.JButton;
-import javax.swing.JDialog;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JProgressBar;
-import javax.swing.border.EmptyBorder;
-
-import cc.arduino.packages.contributions.ContributionInstaller;
-import cc.arduino.packages.contributions.ContributionInstaller.Listener;
-
-@SuppressWarnings("serial")
-public class ContributionInstallerUI extends JDialog {
-
- private final JPanel contentPanel = new JPanel();
- private JButton cancelButton;
- private JProgressBar progressBar;
- private JLabel operationLabel;
-
- public ContributionInstallerUI(Window parent) {
- super(parent, "Installer progress", Dialog.ModalityType.APPLICATION_MODAL);
-
- setBounds(100, 100, 450, 300);
- getContentPane().setLayout(new BorderLayout());
- contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
- getContentPane().add(contentPanel, BorderLayout.CENTER);
- contentPanel.setLayout(new BoxLayout(contentPanel, BoxLayout.Y_AXIS));
- {
- Box verticalBox = Box.createVerticalBox();
- contentPanel.add(verticalBox);
- {
- Component verticalGlue = Box.createVerticalGlue();
- verticalBox.add(verticalGlue);
- }
- {
- Box horizontalBox = Box.createHorizontalBox();
- verticalBox.add(horizontalBox);
- {
- Component horizontalGlue = Box.createHorizontalGlue();
- horizontalBox.add(horizontalGlue);
- }
- {
- JLabel lblNewLabel = new JLabel("Description");
- horizontalBox.add(lblNewLabel);
- }
- {
- Component horizontalGlue = Box.createHorizontalGlue();
- horizontalBox.add(horizontalGlue);
- }
- }
- {
- Component verticalGlue = Box.createVerticalGlue();
- verticalBox.add(verticalGlue);
- }
- {
- Box horizontalBox = Box.createHorizontalBox();
- verticalBox.add(horizontalBox);
- {
- operationLabel = new JLabel("Current running operation");
- horizontalBox.add(operationLabel);
- }
- {
- Component horizontalGlue = Box.createHorizontalGlue();
- horizontalBox.add(horizontalGlue);
- }
- }
- {
- Component verticalStrut = Box.createVerticalStrut(20);
- verticalStrut.setPreferredSize(new Dimension(0, 5));
- verticalStrut.setMinimumSize(new Dimension(0, 5));
- verticalBox.add(verticalStrut);
- }
- {
- progressBar = new JProgressBar();
- progressBar.setStringPainted(true);
- progressBar.setValue(10);
- progressBar.setSize(new Dimension(0, 30));
- progressBar.setMinimumSize(new Dimension(10, 30));
- progressBar.setMaximumSize(new Dimension(32767, 30));
- verticalBox.add(progressBar);
- }
- }
- {
- JPanel buttonPane = new JPanel();
- buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
- getContentPane().add(buttonPane, BorderLayout.SOUTH);
- {
- cancelButton = new JButton("Cancel");
- cancelButton.setActionCommand("Cancel");
- buttonPane.add(cancelButton);
- }
- }
- }
-
- public void onCancel(ActionListener listener) {
- cancelButton.addActionListener(listener);
- }
-
- public void setOperationText(String message) {
- operationLabel.setText(message);
- }
-
- public void setProgress(int progress) {
- progressBar.setValue(progress);
- }
-
- public void attach(ContributionInstaller installer) {
- installer.setListener(new Listener() {
- @Override
- public void onProgress(double progress, String message) {
- setOperationText(message);
- setProgress((int) progress);
- }
- });
- }
-}
diff --git a/app/src/cc/arduino/packages/contributions/ui/ContributionManagerUI.java b/app/src/cc/arduino/packages/contributions/ui/ContributionManagerUI.java
index 9d0029643..bdbbfb839 100644
--- a/app/src/cc/arduino/packages/contributions/ui/ContributionManagerUI.java
+++ b/app/src/cc/arduino/packages/contributions/ui/ContributionManagerUI.java
@@ -29,26 +29,18 @@
package cc.arduino.packages.contributions.ui;
import static cc.arduino.packages.contributions.ui.ContributionIndexTableModel.DESCRIPTION_COL;
-import static cc.arduino.packages.contributions.ui.ContributionIndexTableModel.INSTALLED_COL;
-import static cc.arduino.packages.contributions.ui.ContributionIndexTableModel.VERSION_COL;
import static processing.app.I18n._;
import java.awt.BorderLayout;
-import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dialog;
import java.awt.Dimension;
-import java.awt.Font;
import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
-import java.awt.event.FocusEvent;
-import java.awt.event.FocusListener;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collection;
-import java.util.List;
import javax.swing.Box;
import javax.swing.BoxLayout;
@@ -60,13 +52,14 @@ import javax.swing.JPanel;
import javax.swing.JProgressBar;
import javax.swing.JScrollPane;
import javax.swing.JTable;
-import javax.swing.JTextField;
import javax.swing.ListSelectionModel;
import javax.swing.ScrollPaneConstants;
-import javax.swing.UIManager;
+import javax.swing.SwingUtilities;
import javax.swing.border.EmptyBorder;
-import javax.swing.event.DocumentEvent;
-import javax.swing.event.DocumentListener;
+import javax.swing.event.TableModelEvent;
+import javax.swing.event.TableModelListener;
+import javax.swing.table.TableCellEditor;
+import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn;
import javax.swing.table.TableColumnModel;
@@ -76,7 +69,7 @@ import cc.arduino.packages.contributions.ContributionsIndex;
@SuppressWarnings("serial")
public class ContributionManagerUI extends JDialog {
- private FilterField filterField;
+ private FilterJTextField filterField;
private ContributionManagerUIListener listener = null;
@@ -94,6 +87,8 @@ public class ContributionManagerUI extends JDialog {
private Box progressBox;
private Box updateBox;
+ private ContributedPlatformTableCell cellEditor;
+
public ContributionManagerUI(Frame parent) {
super(parent, "Boards Manager", Dialog.ModalityType.APPLICATION_MODAL);
setResizable(true);
@@ -119,7 +114,7 @@ public class ContributionManagerUI extends JDialog {
setCategories(new ArrayList());
- filterField = new FilterField();
+ filterField = new FilterJTextField(_("Filter your search..."));
JPanel panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
@@ -152,54 +147,31 @@ public class ContributionManagerUI extends JDialog {
// int col = contribTable.columnAtPoint(point);
// }
// });
- TableColumnModel tcm = contribTable.getColumnModel();
{
- TableColumn descriptionCol = tcm.getColumn(DESCRIPTION_COL);
- descriptionCol
- .setCellRenderer(new ContributedPlatformTableCellRenderer());
- descriptionCol.setResizable(true);
- }
-
- {
- TableColumn versionCol = tcm.getColumn(VERSION_COL);
- versionCol.setCellRenderer(new VersionSelectorTableCellRenderer());
- VersionSelectorTableCellEditor editor = new VersionSelectorTableCellEditor();
- editor.setListener(new VersionSelectorTableCellEditor.Listener() {
+ TableColumnModel tcm = contribTable.getColumnModel();
+ TableColumn col = tcm.getColumn(DESCRIPTION_COL);
+ col.setCellRenderer(new ContributedPlatformTableCell());
+ cellEditor = new ContributedPlatformTableCell() {
@Override
- public void onInstallEvent(int row) {
+ protected void onInstall(ContributedPlatform selectedPlatform) {
if (listener == null)
return;
- ContributedPlatform selected = contribModel.getSelectedRelease(row);
- listener.onInstall(selected);
+ listener.onInstall(selectedPlatform);
}
- });
- versionCol.setCellEditor(editor);
- versionCol.setResizable(false);
- versionCol.setWidth(140);
- }
- {
- TableColumn installedCol = tcm.getColumn(INSTALLED_COL);
- installedCol.setCellRenderer(new VersionInstalledTableCellRenderer());
- VersionInstalledTableCellEditor editor = new VersionInstalledTableCellEditor();
- editor.setListener(new VersionInstalledTableCellEditor.Listener() {
@Override
- public void onRemoveEvent(int row) {
+ protected void onRemove(ContributedPlatform installedPlatform) {
if (listener == null)
return;
- ContributedPlatform installed = contribModel.getReleases(row)
- .getInstalled();
- listener.onRemove(installed);
+ listener.onRemove(installedPlatform);
}
- });
- installedCol.setCellEditor(editor);
- installedCol.setResizable(false);
- installedCol.setMaxWidth(70);
+ };
+ col.setCellEditor(cellEditor);
+ col.setResizable(true);
}
{
JScrollPane s = new JScrollPane();
- s.setPreferredSize(new Dimension(300, 300));
s.setViewportView(contribTable);
s.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
s.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
@@ -255,6 +227,20 @@ public class ContributionManagerUI extends JDialog {
}
setMinimumSize(new Dimension(500, 400));
+
+ doLayout();
+
+ contribModel.addTableModelListener(new TableModelListener() {
+ @Override
+ public void tableChanged(final TableModelEvent arg0) {
+ SwingUtilities.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ updateCellsHeight(arg0);
+ }
+ });
+ }
+ });
}
public void setListener(ContributionManagerUIListener listener) {
@@ -290,76 +276,6 @@ public class ContributionManagerUI extends JDialog {
}
}
- class FilterField extends JTextField {
- final static String filterHint = "Filter your search...";
- boolean showingHint;
- List filters;
-
- public FilterField() {
- super(filterHint);
-
- showingHint = true;
- filters = new ArrayList();
- updateStyle();
-
- addFocusListener(new FocusListener() {
- public void focusLost(FocusEvent focusEvent) {
- if (filterField.getText().isEmpty()) {
- showingHint = true;
- }
- updateStyle();
- }
-
- public void focusGained(FocusEvent focusEvent) {
- if (showingHint) {
- showingHint = false;
- filterField.setText("");
- }
- updateStyle();
- }
- });
-
- getDocument().addDocumentListener(new DocumentListener() {
- public void removeUpdate(DocumentEvent e) {
- applyFilter();
- }
-
- public void insertUpdate(DocumentEvent e) {
- applyFilter();
- }
-
- public void changedUpdate(DocumentEvent e) {
- applyFilter();
- }
- });
- }
-
- public void applyFilter() {
- String filter = filterField.getFilterText();
- filter = filter.toLowerCase();
-
- // Replace anything but 0-9, a-z, or : with a space
- filter = filter.replaceAll("[^\\x30-\\x39^\\x61-\\x7a^\\x3a]", " ");
- filters = Arrays.asList(filter.split(" "));
- // filterLibraries(category, filters);
- }
-
- public String getFilterText() {
- return showingHint ? "" : getText();
- }
-
- public void updateStyle() {
- if (showingHint) {
- setText(filterHint);
- setForeground(Color.gray);
- setFont(getFont().deriveFont(Font.ITALIC));
- } else {
- setForeground(UIManager.getColor("TextField.foreground"));
- setFont(getFont().deriveFont(Font.PLAIN));
- }
- }
- }
-
public void addContributions(ContributionsIndex index) {
contribModel.updateIndex(index);
}
@@ -372,6 +288,24 @@ public class ContributionManagerUI extends JDialog {
contribTable.setEnabled(!visible);
updateBox.setVisible(!visible);
updateBox.setEnabled(!visible);
+ cellEditor.setEnabled(!visible);
+
+ if (visible && contribTable.isEditing()) {
+ TableCellEditor editor = contribTable.getCellEditor();
+ if (editor != null)
+ editor.stopCellEditing();
+ }
+ }
+
+ private void updateCellsHeight(TableModelEvent e) {
+ int first = e.getFirstRow();
+ int last = Math.min(e.getLastRow(), contribTable.getRowCount() - 1);
+ for (int row = first; row <= last; row++) {
+ TableCellRenderer editor = new ContributedPlatformTableCell();
+ Component comp = contribTable.prepareRenderer(editor, row, 0);
+ int height = comp.getPreferredSize().height;
+ contribTable.setRowHeight(row, height);
+ }
}
public void setProgress(int progress, String text) {
diff --git a/app/src/cc/arduino/packages/contributions/ui/FilterJTextField.java b/app/src/cc/arduino/packages/contributions/ui/FilterJTextField.java
new file mode 100644
index 000000000..0d6f3c11d
--- /dev/null
+++ b/app/src/cc/arduino/packages/contributions/ui/FilterJTextField.java
@@ -0,0 +1,86 @@
+package cc.arduino.packages.contributions.ui;
+
+import java.awt.Color;
+import java.awt.Font;
+import java.awt.event.FocusEvent;
+import java.awt.event.FocusListener;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import javax.swing.JTextField;
+import javax.swing.UIManager;
+import javax.swing.event.DocumentEvent;
+import javax.swing.event.DocumentListener;
+
+@SuppressWarnings("serial")
+public class FilterJTextField extends JTextField {
+ private String filterHint;
+ boolean showingHint;
+ List filters;
+
+ public FilterJTextField(String hint) {
+ super(hint);
+ filterHint = hint;
+
+ showingHint = true;
+ filters = new ArrayList();
+ updateStyle();
+
+ addFocusListener(new FocusListener() {
+ public void focusLost(FocusEvent focusEvent) {
+ if (getText().isEmpty()) {
+ showingHint = true;
+ }
+ updateStyle();
+ }
+
+ public void focusGained(FocusEvent focusEvent) {
+ if (showingHint) {
+ showingHint = false;
+ setText("");
+ }
+ updateStyle();
+ }
+ });
+
+ getDocument().addDocumentListener(new DocumentListener() {
+ public void removeUpdate(DocumentEvent e) {
+ applyFilter();
+ }
+
+ public void insertUpdate(DocumentEvent e) {
+ applyFilter();
+ }
+
+ public void changedUpdate(DocumentEvent e) {
+ applyFilter();
+ }
+ });
+ }
+
+ public void applyFilter() {
+ String filter = getFilterText();
+ filter = filter.toLowerCase();
+
+ // Replace anything but 0-9, a-z, or : with a space
+ filter = filter.replaceAll("[^\\x30-\\x39^\\x61-\\x7a^\\x3a]", " ");
+ filters = Arrays.asList(filter.split(" "));
+ // filterLibraries(category, filters);
+ }
+
+ public String getFilterText() {
+ return showingHint ? "" : getText();
+ }
+
+ public void updateStyle() {
+ if (showingHint) {
+ setText(filterHint);
+ setForeground(Color.gray);
+ setFont(getFont().deriveFont(Font.ITALIC));
+ } else {
+ setForeground(UIManager.getColor("TextField.foreground"));
+ setFont(getFont().deriveFont(Font.PLAIN));
+ }
+ }
+}
diff --git a/app/src/cc/arduino/packages/contributions/ui/VersionInstalledTableCellEditor.java b/app/src/cc/arduino/packages/contributions/ui/VersionInstalledTableCellEditor.java
deleted file mode 100644
index 6ac6f9cbd..000000000
--- a/app/src/cc/arduino/packages/contributions/ui/VersionInstalledTableCellEditor.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * This file is part of Arduino.
- *
- * Copyright 2014 Arduino LLC (http://www.arduino.cc/)
- *
- * Arduino is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * As a special exception, you may use this file as part of a free software
- * library without restriction. Specifically, if other files instantiate
- * templates or use macros or inline functions from this file, or you compile
- * this file and link it with other files to produce an executable, this
- * file does not by itself cause the resulting executable to be covered by
- * the GNU General Public License. This exception does not however
- * invalidate any other reasons why the executable file might be covered by
- * the GNU General Public License.
- */
-package cc.arduino.packages.contributions.ui;
-
-import java.awt.Component;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-
-import javax.swing.AbstractCellEditor;
-import javax.swing.JButton;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JTable;
-import javax.swing.table.TableCellEditor;
-
-@SuppressWarnings("serial")
-public class VersionInstalledTableCellEditor extends AbstractCellEditor
- implements TableCellEditor {
-
- private JPanel panel;
- private JLabel versionLabel;
- private JButton button;
-
- private int currRow;
- private Object currValue;
- private Listener listener = null;
-
- public VersionInstalledTableCellEditor() {
- versionLabel = new JLabel("-");
- versionLabel.setOpaque(false);
-
- button = new JButton("Remove");
- button.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- if (listener == null)
- return;
- listener.onRemoveEvent(currRow);
- }
- });
-
- panel = new JPanel();
- panel.add(versionLabel);
- panel.add(button);
- }
-
- @Override
- public Component getTableCellEditorComponent(JTable table, Object value,
- boolean isSelected, int row,
- int col) {
- currRow = row;
- currValue = value;
-
- versionLabel.setText((String) value);
-
- if (value.equals("-")) {
- button.setVisible(false);
- } else {
- button.setVisible(true);
- }
-
- if (table.getRowSelectionAllowed()) {
- panel.setBackground(table.getSelectionBackground());
- panel.setForeground(table.getSelectionForeground());
- } else {
- panel.setBackground(table.getBackground());
- panel.setForeground(table.getForeground());
- }
-
- return panel;
- }
-
- @Override
- public Object getCellEditorValue() {
- return currValue;
- }
-
- public static interface Listener {
- public void onRemoveEvent(int row);
- }
-
- public void setListener(Listener newListener) {
- listener = newListener;
- }
-
-}
diff --git a/app/src/cc/arduino/packages/contributions/ui/VersionInstalledTableCellRenderer.java b/app/src/cc/arduino/packages/contributions/ui/VersionInstalledTableCellRenderer.java
deleted file mode 100644
index 5a7ba2ef0..000000000
--- a/app/src/cc/arduino/packages/contributions/ui/VersionInstalledTableCellRenderer.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * This file is part of Arduino.
- *
- * Copyright 2014 Arduino LLC (http://www.arduino.cc/)
- *
- * Arduino is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * As a special exception, you may use this file as part of a free software
- * library without restriction. Specifically, if other files instantiate
- * templates or use macros or inline functions from this file, or you compile
- * this file and link it with other files to produce an executable, this
- * file does not by itself cause the resulting executable to be covered by
- * the GNU General Public License. This exception does not however
- * invalidate any other reasons why the executable file might be covered by
- * the GNU General Public License.
- */
-package cc.arduino.packages.contributions.ui;
-
-import java.awt.Component;
-import java.awt.Dimension;
-
-import javax.swing.JButton;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JTable;
-import javax.swing.table.TableCellRenderer;
-import javax.swing.table.TableColumn;
-
-public class VersionInstalledTableCellRenderer implements TableCellRenderer {
-
- private JPanel panel;
- private JLabel versionLabel;
- private JButton button;
- private int minCellWidth;
-
- public VersionInstalledTableCellRenderer() {
- versionLabel = new JLabel("-");
- versionLabel.setOpaque(false);
-
- button = new JButton("Remove");
- minCellWidth = button.getPreferredSize().width;
-
- panel = new JPanel();
- panel.add(versionLabel);
- panel.add(button);
- }
-
- public Component getTableCellRendererComponent(JTable table, Object value,
- boolean isSelected,
- boolean hasFocus, int row,
- int col) {
- versionLabel.setText((String) value);
-
- Dimension labelSize = versionLabel.getPreferredSize();
- if (minCellWidth < labelSize.width)
- minCellWidth = labelSize.width;
- TableColumn column = table.getColumnModel().getColumn(col);
- if (column.getMinWidth() < minCellWidth + 20) {
- column.setMinWidth(minCellWidth + 20);
- column.setMaxWidth(minCellWidth + 20);
- }
-
- if (value.equals("-")) {
- button.setVisible(false);
- } else {
- button.setVisible(true);
- }
-
- if (isSelected) {
- panel.setBackground(table.getSelectionBackground());
- panel.setForeground(table.getSelectionForeground());
- } else {
- panel.setBackground(table.getBackground());
- panel.setForeground(table.getForeground());
- }
-
- return panel;
- }
-
-}
diff --git a/app/src/cc/arduino/packages/contributions/ui/VersionSelectorTableCellEditor.java b/app/src/cc/arduino/packages/contributions/ui/VersionSelectorTableCellEditor.java
deleted file mode 100644
index f4820c667..000000000
--- a/app/src/cc/arduino/packages/contributions/ui/VersionSelectorTableCellEditor.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * This file is part of Arduino.
- *
- * Copyright 2014 Arduino LLC (http://www.arduino.cc/)
- *
- * Arduino is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * As a special exception, you may use this file as part of a free software
- * library without restriction. Specifically, if other files instantiate
- * templates or use macros or inline functions from this file, or you compile
- * this file and link it with other files to produce an executable, this
- * file does not by itself cause the resulting executable to be covered by
- * the GNU General Public License. This exception does not however
- * invalidate any other reasons why the executable file might be covered by
- * the GNU General Public License.
- */
-package cc.arduino.packages.contributions.ui;
-
-import java.awt.Component;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.ItemEvent;
-import java.awt.event.ItemListener;
-import java.util.List;
-
-import javax.swing.AbstractCellEditor;
-import javax.swing.ComboBoxModel;
-import javax.swing.DefaultComboBoxModel;
-import javax.swing.JButton;
-import javax.swing.JComboBox;
-import javax.swing.JPanel;
-import javax.swing.JTable;
-import javax.swing.table.TableCellEditor;
-
-import cc.arduino.packages.contributions.ui.ContributionIndexTableModel.ContributedPlatformReleases;
-
-@SuppressWarnings("serial")
-public class VersionSelectorTableCellEditor extends AbstractCellEditor
- implements TableCellEditor {
-
- private JPanel panel;
- private JComboBox combo;
- private JButton button;
-
- private int currRow, currCol;
- private ContributionIndexTableModel currModel = null;
-
- private ItemListener itemListener = new ItemListener() {
- @Override
- public void itemStateChanged(ItemEvent e) {
- if (currModel != null) {
- currModel.setValueAt(getCellEditorValue(), currRow, currCol);
- updateButtons();
- }
- }
- };
-
- private Listener listener = null;
-
- public VersionSelectorTableCellEditor() {
- panel = new JPanel();
-
- combo = new JComboBox();
- combo.setOpaque(false);
- combo.addItemListener(itemListener);
- panel.add(combo);
-
- button = new JButton("Install");
- button.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- if (listener == null)
- return;
- listener.onInstallEvent(currRow);
- }
- });
- panel.add(button);
- }
-
- @Override
- public Component getTableCellEditorComponent(JTable table, Object value,
- boolean isSelected, int row,
- int col) {
- currCol = col;
- currRow = row;
- currModel = (ContributionIndexTableModel) table.getModel();
- List values = currModel.getReleasesVersions(row);
-
- ComboBoxModel model = new DefaultComboBoxModel(values.toArray());
- model.setSelectedItem(currModel.getSelectedRelease(row).getVersion());
- combo.setModel(model);
-
- updateButtons();
- if (table.getRowSelectionAllowed()) {
- panel.setBackground(table.getSelectionBackground());
- panel.setForeground(table.getSelectionForeground());
- } else {
- panel.setBackground(table.getBackground());
- panel.setForeground(table.getForeground());
- }
- return panel;
- }
-
- private void updateButtons() {
- ContributedPlatformReleases releases = currModel.getReleases(currRow);
- boolean installed = releases.getInstalled() != null;
- if (installed) {
- if (releases.getInstalled() != releases.getSelected()) {
- button.setText("Upgrade");
- button.setVisible(true);
- } else {
- button.setVisible(false);
- }
- } else {
- button.setText("Install");
- button.setVisible(true);
- }
- }
-
- @Override
- public Object getCellEditorValue() {
- return combo.getSelectedItem();
- }
-
- public static interface Listener {
- public void onInstallEvent(int row);
- }
-
- public void setListener(Listener newListener) {
- listener = newListener;
- }
-
-}
diff --git a/app/src/cc/arduino/packages/contributions/ui/VersionSelectorTableCellRenderer.java b/app/src/cc/arduino/packages/contributions/ui/VersionSelectorTableCellRenderer.java
deleted file mode 100644
index 088cb96cb..000000000
--- a/app/src/cc/arduino/packages/contributions/ui/VersionSelectorTableCellRenderer.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * This file is part of Arduino.
- *
- * Copyright 2014 Arduino LLC (http://www.arduino.cc/)
- *
- * Arduino is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * As a special exception, you may use this file as part of a free software
- * library without restriction. Specifically, if other files instantiate
- * templates or use macros or inline functions from this file, or you compile
- * this file and link it with other files to produce an executable, this
- * file does not by itself cause the resulting executable to be covered by
- * the GNU General Public License. This exception does not however
- * invalidate any other reasons why the executable file might be covered by
- * the GNU General Public License.
- */
-package cc.arduino.packages.contributions.ui;
-
-import java.awt.Component;
-
-import javax.swing.ComboBoxModel;
-import javax.swing.DefaultComboBoxModel;
-import javax.swing.JButton;
-import javax.swing.JComboBox;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JTable;
-import javax.swing.table.TableCellRenderer;
-import javax.swing.table.TableColumn;
-
-import cc.arduino.packages.contributions.ui.ContributionIndexTableModel.ContributedPlatformReleases;
-
-public class VersionSelectorTableCellRenderer implements TableCellRenderer {
-
- private JPanel panel;
- private JComboBox versionComboBox;
- private JLabel versionLabel;
- private JButton button;
- private int minCellWidth;
-
- public VersionSelectorTableCellRenderer() {
- panel = new JPanel();
-
- versionComboBox = new JComboBox();
- versionComboBox.setOpaque(false);
- panel.add(versionComboBox);
- versionComboBox.setVisible(false);
-
- versionLabel = new JLabel();
- versionLabel.setOpaque(false);
- panel.add(versionLabel);
-
- button = new JButton("Install");
- minCellWidth = button.getPreferredSize().width;
- button.setText("Upgrade");
- int buttonWidth = button.getPreferredSize().width;
- if (minCellWidth < buttonWidth)
- minCellWidth = buttonWidth;
-
- panel.add(button);
- }
-
- public Component getTableCellRendererComponent(JTable table, Object value,
- boolean isSelected,
- boolean hasFocus, int row,
- int col) {
- ComboBoxModel comboModel = new DefaultComboBoxModel(
- new String[] { (String) value });
- versionComboBox.setModel(comboModel);
-
- versionLabel.setText((String) value);
-
- ContributionIndexTableModel model = (ContributionIndexTableModel) table
- .getModel();
- ContributedPlatformReleases releases = model.getReleases(row);
-
- boolean installed = releases.getInstalled() != null;
- if (installed) {
- if (releases.getInstalled() != releases.getSelected()) {
- button.setText("Upgrade");
- button.setVisible(true);
- } else {
- button.setVisible(false);
- }
- } else {
- button.setText("Install");
- button.setVisible(true);
- }
-
- int labelWidth = versionComboBox.getPreferredSize().width;
- if (minCellWidth < labelWidth)
- minCellWidth = labelWidth;
- TableColumn column = table.getColumnModel().getColumn(col);
- if (column.getMinWidth() < minCellWidth + 20) {
- column.setMinWidth(minCellWidth + 20);
- column.setMaxWidth(minCellWidth + 20);
- }
-
- if (isSelected) {
- panel.setBackground(table.getSelectionBackground());
- panel.setForeground(table.getSelectionForeground());
- } else {
- panel.setBackground(table.getBackground());
- panel.setForeground(table.getForeground());
- }
- return panel;
- }
-}