ContributedPlatformCell* now follows swing cell model abstraction

This commit completes the refactoring
This commit is contained in:
Cristian Maglie 2015-12-24 20:08:08 +01:00
parent 6370a74632
commit 4725584a49
4 changed files with 384 additions and 239 deletions

View File

@ -29,69 +29,64 @@
package cc.arduino.contributions.packages.ui;
import cc.arduino.contributions.DownloadableContributionVersionComparator;
import cc.arduino.contributions.VersionComparator;
import cc.arduino.contributions.filters.BuiltInPredicate;
import cc.arduino.contributions.filters.InstalledPredicate;
import cc.arduino.contributions.packages.ContributedBoard;
import cc.arduino.contributions.packages.ContributedHelp;
import cc.arduino.contributions.packages.ContributedPlatform;
import cc.arduino.contributions.ui.InstallerTableCell;
import cc.arduino.contributions.ui.listeners.DelegatingKeyListener;
import cc.arduino.utils.ReverseComparator;
import processing.app.Base;
import static processing.app.I18n.format;
import static processing.app.I18n.tr;
import javax.swing.*;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Insets;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
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.text.Document;
import javax.swing.text.html.HTMLDocument;
import javax.swing.text.html.StyleSheet;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Collections;
import java.util.LinkedList;
import java.util.stream.Collectors;
import static processing.app.I18n.format;
import static processing.app.I18n.tr;
import cc.arduino.contributions.DownloadableContributionVersionComparator;
import cc.arduino.contributions.packages.ContributedBoard;
import cc.arduino.contributions.packages.ContributedHelp;
import cc.arduino.contributions.packages.ContributedPlatform;
import cc.arduino.contributions.ui.InstallerTableCell;
import processing.app.Base;
@SuppressWarnings("serial")
public class ContributedPlatformTableCell extends InstallerTableCell {
public class ContributedPlatformTableCell {
private final JPanel panel;
private final JButton installButton;
private final JButton removeButton;
private final Component removeButtonPlaceholder;
private final Component installButtonPlaceholder;
private JComboBox downgradeChooser;
private final JComboBox versionToInstallChooser;
private final JButton downgradeButton;
private final JPanel buttonsPanel;
private final JPanel inactiveButtonsPanel;
private final JLabel statusLabel;
final JPanel panel;
final JButton installButton;
final JButton removeButton;
final Component removeButtonPlaceholder;
final Component installButtonPlaceholder;
JComboBox downgradeChooser;
final JComboBox versionToInstallChooser;
final JButton downgradeButton;
final JPanel buttonsPanel;
final JPanel inactiveButtonsPanel;
final JLabel statusLabel;
public ContributedPlatformTableCell() {
{
installButton = new JButton(tr("Install"));
installButton.addActionListener(e -> onInstall(editorValue.getSelected(), editorValue.getInstalled()));
int width = installButton.getPreferredSize().width;
installButtonPlaceholder = Box.createRigidArea(new Dimension(width, 1));
}
{
removeButton = new JButton(tr("Remove"));
removeButton.addActionListener(e -> onRemove(editorValue.getInstalled()));
int width = removeButton.getPreferredSize().width;
removeButtonPlaceholder = Box.createRigidArea(new Dimension(width, 1));
}
downgradeButton = new JButton(tr("Install"));
downgradeButton.addActionListener(e -> {
ContributedPlatform selected = (ContributedPlatform) downgradeChooser.getSelectedItem();
onInstall(selected, editorValue.getInstalled());
});
downgradeChooser = new JComboBox();
downgradeChooser.addItem("-");
@ -104,15 +99,14 @@ public class ContributedPlatformTableCell extends InstallerTableCell {
versionToInstallChooser = new JComboBox();
versionToInstallChooser.addItem("-");
versionToInstallChooser.setMaximumSize(versionToInstallChooser.getPreferredSize());
versionToInstallChooser.addItemListener(e -> editorValue.select((ContributedPlatform) versionToInstallChooser.getSelectedItem()));
versionToInstallChooser
.setMaximumSize(versionToInstallChooser.getPreferredSize());
panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
makeNewDescription(panel);
{
buttonsPanel = new JPanel();
buttonsPanel.setLayout(new BoxLayout(buttonsPanel, BoxLayout.X_AXIS));
buttonsPanel.setOpaque(false);
@ -133,11 +127,10 @@ public class ContributedPlatformTableCell extends InstallerTableCell {
buttonsPanel.add(Box.createHorizontalStrut(15));
panel.add(buttonsPanel);
}
{
inactiveButtonsPanel = new JPanel();
inactiveButtonsPanel.setLayout(new BoxLayout(inactiveButtonsPanel, BoxLayout.X_AXIS));
inactiveButtonsPanel
.setLayout(new BoxLayout(inactiveButtonsPanel, BoxLayout.X_AXIS));
inactiveButtonsPanel.setOpaque(false);
int height = installButton.getMinimumSize().height;
@ -149,138 +142,19 @@ public class ContributedPlatformTableCell extends InstallerTableCell {
inactiveButtonsPanel.add(Box.createHorizontalStrut(15));
panel.add(inactiveButtonsPanel);
}
panel.add(Box.createVerticalStrut(15));
}
private JTextPane makeNewDescription(JPanel panel) {
if (panel.getComponentCount() > 0) {
panel.remove(0);
}
JTextPane 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(e -> {
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
Base.openURL(e.getDescription());
}
});
description.addKeyListener(new DelegatingKeyListener(parentTable));
panel.add(description, 0);
return description;
}
protected void onRemove(ContributedPlatform contributedPlatform) {
// Empty
}
protected void onInstall(ContributedPlatform contributedPlatform, ContributedPlatform installed) {
// Empty
}
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected,
boolean hasFocus, int row,
int column) {
parentTable = table;
setEnabled(false);
Component component = getUpdatedCellComponent(value, isSelected, row, false);
if (row % 2 == 0) {
component.setBackground(new Color(236, 241, 241)); //#ecf1f1
} else {
component.setBackground(new Color(255, 255, 255));
}
int height = new Double(component.getPreferredSize().getHeight()).intValue();
if (table.getRowHeight(row) < height) {
table.setRowHeight(row, height);
}
return component;
}
private ContributionIndexTableModel.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 = (ContributionIndexTableModel.ContributedPlatformReleases) value;
setEnabled(true);
final ContributedPlatform installed = editorValue.getInstalled();
java.util.List<ContributedPlatform> releases = new LinkedList<>(editorValue.releases);
java.util.List<ContributedPlatform> uninstalledReleases = releases.stream().filter(new InstalledPredicate().negate()).collect(Collectors.toList());
java.util.List<ContributedPlatform> installedBuiltIn = releases.stream().filter(new InstalledPredicate()).filter(new BuiltInPredicate()).collect(Collectors.toList());
if (installed != null && !installedBuiltIn.contains(installed)) {
uninstalledReleases.addAll(installedBuiltIn);
}
Collections.sort(uninstalledReleases, new ReverseComparator<>(new DownloadableContributionVersionComparator()));
downgradeChooser.removeAllItems();
downgradeChooser.addItem(tr("Select version"));
final java.util.List<ContributedPlatform> uninstalledPreviousReleases = new LinkedList<>();
final java.util.List<ContributedPlatform> uninstalledNewerReleases = new LinkedList<>();
final VersionComparator versionComparator = new VersionComparator();
uninstalledReleases.stream().forEach(input -> {
if (installed == null || versionComparator.greaterThan(installed.getParsedVersion(), input.getParsedVersion())) {
uninstalledPreviousReleases.add(input);
} else {
uninstalledNewerReleases.add(input);
}
});
uninstalledNewerReleases.forEach(downgradeChooser::addItem);
uninstalledPreviousReleases.forEach(downgradeChooser::addItem);
downgradeChooser.setVisible(installed != null && (!uninstalledPreviousReleases.isEmpty() || uninstalledNewerReleases.size() > 1));
downgradeButton.setVisible(installed != null && (!uninstalledPreviousReleases.isEmpty() || uninstalledNewerReleases.size() > 1));
versionToInstallChooser.removeAllItems();
uninstalledReleases.forEach(versionToInstallChooser::addItem);
versionToInstallChooser.setVisible(installed == null && uninstalledReleases.size() > 1);
Component component = getUpdatedCellComponent(value, true, row, !installedBuiltIn.isEmpty());
component.setBackground(new Color(218, 227, 227)); //#dae3e3
return component;
}
private Component getUpdatedCellComponent(Object value, boolean isSelected, int row, boolean hasBuiltInRelease) {
void update(JTable parentTable, Object value, boolean isSelected, int row,
boolean hasBuiltInRelease) {
ContributionIndexTableModel.ContributedPlatformReleases releases = (ContributionIndexTableModel.ContributedPlatformReleases) value;
JTextPane description = makeNewDescription(panel);
// FIXME: happens on macosx, don't know why
if (releases == null) {
return panel;
return;
}
ContributedPlatform selected = releases.getSelected();
@ -294,7 +168,8 @@ public class ContributedPlatformTableCell extends InstallerTableCell {
} else {
installable = false;
removable = !installed.isReadOnly() && !hasBuiltInRelease;
upgradable = new DownloadableContributionVersionComparator().compare(selected, installed) > 0;
upgradable = new DownloadableContributionVersionComparator()
.compare(selected, installed) > 0;
}
if (installable) {
installButton.setText(tr("Install"));
@ -318,7 +193,9 @@ public class ContributedPlatformTableCell extends InstallerTableCell {
desc += " " + format("by <b>{0}</b>", author);
}
if (installed != null) {
desc += " " + format(tr("version <b>{0}</b>"), installed.getParsedVersion()) + " <strong><font color=\"#00979D\">INSTALLED</font></strong>";
desc += " "
+ format(tr("version <b>{0}</b>"), installed.getParsedVersion())
+ " <strong><font color=\"#00979D\">INSTALLED</font></strong>";
}
desc += "<br />";
@ -358,7 +235,8 @@ public class ContributedPlatformTableCell extends InstallerTableCell {
// See:
// http://stackoverflow.com/questions/3081210/how-to-set-jtextarea-to-have-height-that-matches-the-size-of-a-text-it-contains
int width = parentTable.getBounds().width;
setJTextPaneDimensionToFitContainedText(description, width);
InstallerTableCell.setJTextPaneDimensionToFitContainedText(description,
width);
if (isSelected) {
panel.setBackground(parentTable.getSelectionBackground());
@ -367,41 +245,37 @@ public class ContributedPlatformTableCell extends InstallerTableCell {
panel.setBackground(parentTable.getBackground());
panel.setForeground(parentTable.getForeground());
}
return panel;
}
private final Timer enabler = new Timer(100, new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
enable(true);
enabler.stop();
private static JTextPane makeNewDescription(JPanel panel) {
if (panel.getComponentCount() > 0) {
panel.remove(0);
}
JTextPane 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(e -> {
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
Base.openURL(e.getDescription());
}
});
@Override
public void setEnabled(boolean enabled) {
enable(false);
if (enabled) {
enabler.start();
} else {
enabler.stop();
}
buttonsPanel.setVisible(enabled);
inactiveButtonsPanel.setVisible(!enabled);
}
public void enable(boolean enabled) {
installButton.setEnabled(enabled);
removeButton.setEnabled(enabled);
}
public void setStatus(String status) {
statusLabel.setText(status);
}
public void invalidate() {
panel.invalidate();
panel.add(description, 0);
return description;
}
}

View File

@ -0,0 +1,184 @@
/*
* This file is part of Arduino.
*
* Copyright 2015 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.contributions.packages.ui;
import static processing.app.I18n.tr;
import java.awt.Color;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Collections;
import java.util.LinkedList;
import java.util.stream.Collectors;
import javax.swing.JTable;
import javax.swing.Timer;
import cc.arduino.contributions.DownloadableContributionVersionComparator;
import cc.arduino.contributions.VersionComparator;
import cc.arduino.contributions.filters.BuiltInPredicate;
import cc.arduino.contributions.filters.InstalledPredicate;
import cc.arduino.contributions.packages.ContributedPlatform;
import cc.arduino.contributions.ui.InstallerTableCell;
import cc.arduino.utils.ReverseComparator;
@SuppressWarnings("serial")
public class ContributedPlatformTableCellEditor extends InstallerTableCell {
private ContributedPlatformTableCell editorCell;
private ContributionIndexTableModel.ContributedPlatformReleases editorValue;
@Override
public Object getCellEditorValue() {
return editorValue;
}
@Override
public Component getTableCellEditorComponent(JTable table, Object value,
boolean isSelected, int row,
int column) {
editorCell = new ContributedPlatformTableCell();
editorCell.installButton
.addActionListener(e -> onInstall(editorValue.getSelected(),
editorValue.getInstalled()));
editorCell.removeButton
.addActionListener(e -> onRemove(editorValue.getInstalled()));
editorCell.downgradeButton.addActionListener(e -> {
ContributedPlatform selected = (ContributedPlatform) editorCell.downgradeChooser
.getSelectedItem();
onInstall(selected, editorValue.getInstalled());
});
editorCell.versionToInstallChooser.addItemListener(e -> editorValue
.select((ContributedPlatform) editorCell.versionToInstallChooser
.getSelectedItem()));
editorValue = (ContributionIndexTableModel.ContributedPlatformReleases) value;
setEnabled(true);
final ContributedPlatform installed = editorValue.getInstalled();
java.util.List<ContributedPlatform> releases = new LinkedList<>(
editorValue.releases);
java.util.List<ContributedPlatform> uninstalledReleases = releases.stream()
.filter(new InstalledPredicate().negate()).collect(Collectors.toList());
java.util.List<ContributedPlatform> installedBuiltIn = releases.stream()
.filter(new InstalledPredicate()).filter(new BuiltInPredicate())
.collect(Collectors.toList());
if (installed != null && !installedBuiltIn.contains(installed)) {
uninstalledReleases.addAll(installedBuiltIn);
}
Collections.sort(uninstalledReleases, new ReverseComparator<>(
new DownloadableContributionVersionComparator()));
editorCell.downgradeChooser.removeAllItems();
editorCell.downgradeChooser.addItem(tr("Select version"));
final java.util.List<ContributedPlatform> uninstalledPreviousReleases = new LinkedList<>();
final java.util.List<ContributedPlatform> uninstalledNewerReleases = new LinkedList<>();
final VersionComparator versionComparator = new VersionComparator();
uninstalledReleases.stream().forEach(input -> {
if (installed == null
|| versionComparator.greaterThan(installed.getParsedVersion(),
input.getParsedVersion())) {
uninstalledPreviousReleases.add(input);
} else {
uninstalledNewerReleases.add(input);
}
});
uninstalledNewerReleases.forEach(editorCell.downgradeChooser::addItem);
uninstalledPreviousReleases.forEach(editorCell.downgradeChooser::addItem);
editorCell.downgradeChooser
.setVisible(installed != null
&& (!uninstalledPreviousReleases.isEmpty()
|| uninstalledNewerReleases.size() > 1));
editorCell.downgradeButton
.setVisible(installed != null
&& (!uninstalledPreviousReleases.isEmpty()
|| uninstalledNewerReleases.size() > 1));
editorCell.versionToInstallChooser.removeAllItems();
uninstalledReleases.forEach(editorCell.versionToInstallChooser::addItem);
editorCell.versionToInstallChooser
.setVisible(installed == null && uninstalledReleases.size() > 1);
editorCell.update(table, value, true, row, !installedBuiltIn.isEmpty());
editorCell.panel.setBackground(new Color(218, 227, 227)); // #dae3e3
return editorCell.panel;
}
private final Timer enabler = new Timer(100, new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
enable(true);
enabler.stop();
}
});
@Override
public void setEnabled(boolean enabled) {
enable(false);
if (enabled) {
enabler.start();
} else {
enabler.stop();
}
editorCell.buttonsPanel.setVisible(enabled);
editorCell.inactiveButtonsPanel.setVisible(!enabled);
}
public void enable(boolean enabled) {
editorCell.installButton.setEnabled(enabled);
editorCell.removeButton.setEnabled(enabled);
}
public void setStatus(String status) {
editorCell.statusLabel.setText(status);
}
public void invalidate() {
editorCell.panel.invalidate();
}
protected void onRemove(ContributedPlatform contributedPlatform) {
// Empty
}
protected void onInstall(ContributedPlatform contributedPlatform,
ContributedPlatform installed) {
// Empty
}
}

View File

@ -0,0 +1,67 @@
/*
* This file is part of Arduino.
*
* Copyright 2015 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.contributions.packages.ui;
import java.awt.Color;
import java.awt.Component;
import javax.swing.JTable;
import javax.swing.table.TableCellRenderer;
@SuppressWarnings("serial")
public class ContributedPlatformTableCellRenderer implements TableCellRenderer {
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected,
boolean hasFocus, int row,
int column) {
ContributedPlatformTableCell cell = new ContributedPlatformTableCell();
cell.installButton.setEnabled(false);
cell.removeButton.setEnabled(false);
cell.buttonsPanel.setVisible(false);
cell.inactiveButtonsPanel.setVisible(true);
cell.update(table, value, isSelected, row, false);
if (row % 2 == 0) {
cell.panel.setBackground(new Color(236, 241, 241)); // #ecf1f1
} else {
cell.panel.setBackground(new Color(255, 255, 255));
}
int height = new Double(cell.panel.getPreferredSize().getHeight())
.intValue();
if (table.getRowHeight(row) < height) {
table.setRowHeight(row, height);
}
return cell.panel;
}
}

View File

@ -38,6 +38,8 @@ import processing.app.BaseNoGui;
import processing.app.I18n;
import javax.swing.*;
import javax.swing.table.TableCellRenderer;
import java.awt.*;
import java.util.Collection;
import java.util.LinkedList;
@ -60,15 +62,16 @@ public class ContributionManagerUI extends InstallerJDialog {
}
@Override
protected InstallerTableCell createCellRenderer() {
return new ContributedPlatformTableCell();
protected TableCellRenderer createCellRenderer() {
return new ContributedPlatformTableCellRenderer();
}
@Override
protected InstallerTableCell createCellEditor() {
return new ContributedPlatformTableCell() {
return new ContributedPlatformTableCellEditor() {
@Override
protected void onInstall(ContributedPlatform selected, ContributedPlatform installed) {
protected void onInstall(ContributedPlatform selected,
ContributedPlatform installed) {
if (selected.isReadOnly()) {
onRemovePressed(installed, false);
} else {
@ -84,12 +87,14 @@ public class ContributionManagerUI extends InstallerJDialog {
}
public ContributionManagerUI(Frame parent, ContributionInstaller installer) {
super(parent, tr("Boards Manager"), Dialog.ModalityType.APPLICATION_MODAL, tr("Unable to reach Arduino.cc due to possible network issues."));
super(parent, tr("Boards Manager"), Dialog.ModalityType.APPLICATION_MODAL,
tr("Unable to reach Arduino.cc due to possible network issues."));
this.installer = installer;
}
public void updateUI() {
DropdownItem<DownloadableContribution> previouslySelectedCategory = (DropdownItem<DownloadableContribution>) categoryChooser.getSelectedItem();
DropdownItem<DownloadableContribution> previouslySelectedCategory = (DropdownItem<DownloadableContribution>) categoryChooser
.getSelectedItem();
categoryChooser.removeActionListener(categoryChooserActionListener);
@ -138,7 +143,8 @@ public class ContributionManagerUI extends InstallerJDialog {
installerThread = new Thread(() -> {
try {
setProgressVisible(true, "");
List<String> downloadedPackageIndexFiles = installer.updateIndex(this::setProgress);
List<String> downloadedPackageIndexFiles = installer
.updateIndex(this::setProgress);
installer.deleteUnknownFiles(downloadedPackageIndexFiles);
onIndexesUpdated();
} catch (Exception e) {
@ -148,11 +154,14 @@ public class ContributionManagerUI extends InstallerJDialog {
}
});
installerThread.setName("ContributionManager Update Thread");
installerThread.setUncaughtExceptionHandler(new InstallerJDialogUncaughtExceptionHandler(this, noConnectionErrorMessage));
installerThread
.setUncaughtExceptionHandler(new InstallerJDialogUncaughtExceptionHandler(
this, noConnectionErrorMessage));
installerThread.start();
}
public void onInstallPressed(final ContributedPlatform platformToInstall, final ContributedPlatform platformToRemove) {
public void onInstallPressed(final ContributedPlatform platformToInstall,
final ContributedPlatform platformToRemove) {
clearErrorMessage();
installerThread = new Thread(() -> {
List<String> errors = new LinkedList<>();
@ -173,15 +182,24 @@ public class ContributionManagerUI extends InstallerJDialog {
}
});
installerThread.setName("ContributionManager Install Thread");
installerThread.setUncaughtExceptionHandler(new InstallerJDialogUncaughtExceptionHandler(this, noConnectionErrorMessage));
installerThread
.setUncaughtExceptionHandler(new InstallerJDialogUncaughtExceptionHandler(
this, noConnectionErrorMessage));
installerThread.start();
}
public void onRemovePressed(final ContributedPlatform platform, boolean showWarning) {
public void onRemovePressed(final ContributedPlatform platform,
boolean showWarning) {
clearErrorMessage();
if (showWarning) {
int chosenOption = JOptionPane.showConfirmDialog(this, I18n.format(tr("Do you want to remove {0}?\nIf you do so you won't be able to use {0} any more."), platform.getName()), tr("Please confirm boards deletion"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
int chosenOption = JOptionPane
.showConfirmDialog(this,
I18n.format(tr("Do you want to remove {0}?\nIf you do so you won't be able to use {0} any more."),
platform.getName()),
tr("Please confirm boards deletion"),
JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE);
if (chosenOption != JOptionPane.YES_OPTION) {
return;
}
@ -199,7 +217,9 @@ public class ContributionManagerUI extends InstallerJDialog {
}
});
installerThread.setName("ContributionManager Remove Thread");
installerThread.setUncaughtExceptionHandler(new InstallerJDialogUncaughtExceptionHandler(this, noConnectionErrorMessage));
installerThread
.setUncaughtExceptionHandler(new InstallerJDialogUncaughtExceptionHandler(
this, noConnectionErrorMessage));
installerThread.start();
}