mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-30 19:52:13 +01:00
Removing previously installed platform on upgrade
This commit is contained in:
parent
b1e0249a4f
commit
fe6718ce4f
@ -98,7 +98,7 @@ public class ContributedPlatformTableCell extends InstallerTableCell {
|
|||||||
installButton.addActionListener(new ActionListener() {
|
installButton.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
onInstall(editorValue.getSelected());
|
onInstall(editorValue.getSelected(), editorValue.getInstalled());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -129,7 +129,7 @@ public class ContributedPlatformTableCell extends InstallerTableCell {
|
|||||||
// Empty
|
// Empty
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void onInstall(ContributedPlatform contributedPlatform) {
|
protected void onInstall(ContributedPlatform contributedPlatform, ContributedPlatform installed) {
|
||||||
// Empty
|
// Empty
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,14 +28,17 @@
|
|||||||
*/
|
*/
|
||||||
package cc.arduino.packages.contributions.ui;
|
package cc.arduino.packages.contributions.ui;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import cc.arduino.packages.contributions.ContributedPackage;
|
import cc.arduino.packages.contributions.ContributedPackage;
|
||||||
import cc.arduino.packages.contributions.ContributedPlatform;
|
import cc.arduino.packages.contributions.ContributedPlatform;
|
||||||
import cc.arduino.packages.contributions.ContributionsIndex;
|
import cc.arduino.packages.contributions.ContributionsIndex;
|
||||||
import cc.arduino.ui.FilteredAbstractTableModel;
|
import cc.arduino.ui.FilteredAbstractTableModel;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static processing.app.I18n._;
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class ContributionIndexTableModel extends FilteredAbstractTableModel {
|
public class ContributionIndexTableModel extends FilteredAbstractTableModel {
|
||||||
|
|
||||||
@ -69,9 +72,21 @@ public class ContributionIndexTableModel extends FilteredAbstractTableModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ContributedPlatform getInstalled() {
|
public ContributedPlatform getInstalled() {
|
||||||
for (ContributedPlatform plat : releases)
|
List<ContributedPlatform> installedPlatforms = new LinkedList<ContributedPlatform>();
|
||||||
if (plat.isInstalled())
|
for (ContributedPlatform platform : releases) {
|
||||||
return plat;
|
if (platform.isInstalled()) {
|
||||||
|
installedPlatforms.add(platform);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (installedPlatforms.size() > 1) {
|
||||||
|
throw new IllegalStateException(_("More than one platform is currently installed! Only one can be installed at any given time"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!installedPlatforms.isEmpty()) {
|
||||||
|
return installedPlatforms.get(0);
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,9 +127,9 @@ public class ContributionIndexTableModel extends FilteredAbstractTableModel {
|
|||||||
|
|
||||||
private List<ContributedPlatformReleases> contributions = new ArrayList<ContributedPlatformReleases>();
|
private List<ContributedPlatformReleases> contributions = new ArrayList<ContributedPlatformReleases>();
|
||||||
|
|
||||||
private String[] columnNames = { "Description" };
|
private String[] columnNames = {"Description"};
|
||||||
|
|
||||||
private Class<?>[] columnTypes = { ContributedPlatform.class };
|
private Class<?>[] columnTypes = {ContributedPlatform.class};
|
||||||
|
|
||||||
private ContributionsIndex index;
|
private ContributionsIndex index;
|
||||||
|
|
||||||
@ -145,7 +160,7 @@ public class ContributionIndexTableModel extends FilteredAbstractTableModel {
|
|||||||
* @param string
|
* @param string
|
||||||
* @param set
|
* @param set
|
||||||
* @return <b>true<b> if all the strings in <b>set</b> are contained in
|
* @return <b>true<b> if all the strings in <b>set</b> are contained in
|
||||||
* <b>string</b>.
|
* <b>string</b>.
|
||||||
*/
|
*/
|
||||||
private boolean stringContainsAll(String string, String set[]) {
|
private boolean stringContainsAll(String string, String set[]) {
|
||||||
if (set == null)
|
if (set == null)
|
||||||
|
@ -63,8 +63,8 @@ public class ContributionManagerUI extends InstallerJDialog {
|
|||||||
protected InstallerTableCell createCellEditor() {
|
protected InstallerTableCell createCellEditor() {
|
||||||
return new ContributedPlatformTableCell() {
|
return new ContributedPlatformTableCell() {
|
||||||
@Override
|
@Override
|
||||||
protected void onInstall(ContributedPlatform selectedPlatform) {
|
protected void onInstall(ContributedPlatform selectedPlatform, ContributedPlatform installed) {
|
||||||
onInstallPressed(selectedPlatform);
|
onInstallPressed(selectedPlatform, installed);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -146,13 +146,16 @@ public class ContributionManagerUI extends InstallerJDialog {
|
|||||||
installerThread.start();
|
installerThread.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onInstallPressed(final ContributedPlatform platform) {
|
public void onInstallPressed(final ContributedPlatform platformToInstall, final ContributedPlatform platformToRemove) {
|
||||||
installerThread = new Thread(new Runnable() {
|
installerThread = new Thread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
setProgressVisible(true);
|
setProgressVisible(true);
|
||||||
installer.install(platform);
|
installer.install(platformToInstall);
|
||||||
|
if (platformToRemove != null) {
|
||||||
|
installer.remove(platformToRemove);
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// TODO Show ERROR
|
// TODO Show ERROR
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -1123,7 +1123,7 @@ public class Base {
|
|||||||
rebuildExamplesMenu(Editor.examplesMenu);
|
rebuildExamplesMenu(Editor.examplesMenu);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void openInstallBoardDialog() {
|
private void openInstallBoardDialog() throws Exception {
|
||||||
// Create dialog for contribution manager
|
// Create dialog for contribution manager
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
ContributionManagerUI managerUI = new ContributionManagerUI(activeEditor) {
|
ContributionManagerUI managerUI = new ContributionManagerUI(activeEditor) {
|
||||||
@ -1139,14 +1139,9 @@ public class Base {
|
|||||||
// Installer dialog is modal, waits here until closed
|
// Installer dialog is modal, waits here until closed
|
||||||
|
|
||||||
// Reload all boards (that may have been installed/updated/removed)
|
// Reload all boards (that may have been installed/updated/removed)
|
||||||
try {
|
BaseNoGui.initPackages();
|
||||||
BaseNoGui.initPackages();
|
rebuildBoardsMenu();
|
||||||
rebuildBoardsMenu();
|
onBoardOrPortChange();
|
||||||
onBoardOrPortChange();
|
|
||||||
} catch (Exception e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void rebuildBoardsMenu() throws Exception {
|
public void rebuildBoardsMenu() throws Exception {
|
||||||
@ -1158,7 +1153,12 @@ public class Base {
|
|||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
Action runInstaller = new AbstractAction("Install boards...") {
|
Action runInstaller = new AbstractAction("Install boards...") {
|
||||||
public void actionPerformed(ActionEvent actionevent) {
|
public void actionPerformed(ActionEvent actionevent) {
|
||||||
openInstallBoardDialog();
|
try {
|
||||||
|
openInstallBoardDialog();
|
||||||
|
} catch (Exception e) {
|
||||||
|
//TODO show error
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
boardMenu.add(new JMenuItem(runInstaller));
|
boardMenu.add(new JMenuItem(runInstaller));
|
||||||
|
@ -66,7 +66,6 @@ public class LibrariesIndexer {
|
|||||||
|
|
||||||
public void parseIndex() throws JsonParseException, IOException {
|
public void parseIndex() throws JsonParseException, IOException {
|
||||||
parseIndex(indexFile);
|
parseIndex(indexFile);
|
||||||
System.out.println(index);
|
|
||||||
|
|
||||||
index.fillCategories();
|
index.fillCategories();
|
||||||
// TODO: resolve libraries inner references
|
// TODO: resolve libraries inner references
|
||||||
|
@ -60,8 +60,9 @@ public class ContributionInstaller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void install(ContributedPlatform platform) throws Exception {
|
public void install(ContributedPlatform platform) throws Exception {
|
||||||
if (platform.isInstalled())
|
if (platform.isInstalled()) {
|
||||||
throw new Exception("Platform is already installed!");
|
throw new Exception("Platform is already installed!");
|
||||||
|
}
|
||||||
|
|
||||||
// Do not download already installed tools
|
// Do not download already installed tools
|
||||||
List<ContributedTool> tools = new LinkedList<ContributedTool>(platform.getResolvedTools());
|
List<ContributedTool> tools = new LinkedList<ContributedTool>(platform.getResolvedTools());
|
||||||
@ -111,13 +112,11 @@ public class ContributionInstaller {
|
|||||||
File toolsFolder = new File(packageFolder, "tools");
|
File toolsFolder = new File(packageFolder, "tools");
|
||||||
int i = 1;
|
int i = 1;
|
||||||
for (ContributedTool tool : platform.getResolvedTools()) {
|
for (ContributedTool tool : platform.getResolvedTools()) {
|
||||||
progress.setStatus(format(_("Installing tools ({0}/{1})..."), i,
|
progress.setStatus(format(_("Installing tools ({0}/{1})..."), i, tools.size()));
|
||||||
tools.size()));
|
|
||||||
onProgress(progress);
|
onProgress(progress);
|
||||||
i++;
|
i++;
|
||||||
DownloadableContribution toolContrib = tool.getDownloadableContribution();
|
DownloadableContribution toolContrib = tool.getDownloadableContribution();
|
||||||
File destFolder = new File(toolsFolder, tool.getName() + File.separator +
|
File destFolder = new File(toolsFolder, tool.getName() + File.separator + tool.getVersion());
|
||||||
tool.getVersion());
|
|
||||||
|
|
||||||
destFolder.mkdirs();
|
destFolder.mkdirs();
|
||||||
ArchiveExtractor.extract(toolContrib.getDownloadedFile(), destFolder, 1);
|
ArchiveExtractor.extract(toolContrib.getDownloadedFile(), destFolder, 1);
|
||||||
@ -129,8 +128,7 @@ public class ContributionInstaller {
|
|||||||
// Unpack platform on the correct location
|
// Unpack platform on the correct location
|
||||||
progress.setStatus(_("Installing boards..."));
|
progress.setStatus(_("Installing boards..."));
|
||||||
onProgress(progress);
|
onProgress(progress);
|
||||||
File platformFolder = new File(packageFolder, "hardware" + File.separator +
|
File platformFolder = new File(packageFolder, "hardware" + File.separator + platform.getArchitecture());
|
||||||
platform.getArchitecture());
|
|
||||||
File destFolder = new File(platformFolder, platform.getVersion());
|
File destFolder = new File(platformFolder, platform.getVersion());
|
||||||
destFolder.mkdirs();
|
destFolder.mkdirs();
|
||||||
ArchiveExtractor.extract(platform.getDownloadedFile(), destFolder, 1);
|
ArchiveExtractor.extract(platform.getDownloadedFile(), destFolder, 1);
|
||||||
|
@ -612,7 +612,6 @@ public class BaseNoGui {
|
|||||||
}
|
}
|
||||||
indexer.parseIndex();
|
indexer.parseIndex();
|
||||||
indexer.syncWithFilesystem();
|
indexer.syncWithFilesystem();
|
||||||
System.out.println(indexer);
|
|
||||||
|
|
||||||
packages = new HashMap<String, TargetPackage>();
|
packages = new HashMap<String, TargetPackage>();
|
||||||
loadHardware(getHardwareFolder());
|
loadHardware(getHardwareFolder());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user