mirror of
https://github.com/arduino/Arduino.git
synced 2025-02-15 09:54:20 +01:00
Removed no more needed LibraryInstaller (it's now done via GRPC)
This commit is contained in:
parent
401fe65418
commit
bdd621786a
@ -49,8 +49,8 @@ import javax.swing.JOptionPane;
|
|||||||
import javax.swing.table.TableCellRenderer;
|
import javax.swing.table.TableCellRenderer;
|
||||||
|
|
||||||
import cc.arduino.contributions.libraries.ContributedLibraryRelease;
|
import cc.arduino.contributions.libraries.ContributedLibraryRelease;
|
||||||
|
import cc.arduino.cli.ArduinoCoreInstance;
|
||||||
import cc.arduino.contributions.libraries.ContributedLibrary;
|
import cc.arduino.contributions.libraries.ContributedLibrary;
|
||||||
import cc.arduino.contributions.libraries.LibraryInstaller;
|
|
||||||
import cc.arduino.contributions.libraries.LibraryTypeComparator;
|
import cc.arduino.contributions.libraries.LibraryTypeComparator;
|
||||||
import cc.arduino.contributions.libraries.ui.MultiLibraryInstallDialog.Result;
|
import cc.arduino.contributions.libraries.ui.MultiLibraryInstallDialog.Result;
|
||||||
import cc.arduino.contributions.ui.DropdownItem;
|
import cc.arduino.contributions.ui.DropdownItem;
|
||||||
@ -64,8 +64,8 @@ import processing.app.BaseNoGui;
|
|||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class LibraryManagerUI extends InstallerJDialog<ContributedLibrary> {
|
public class LibraryManagerUI extends InstallerJDialog<ContributedLibrary> {
|
||||||
|
|
||||||
|
private final ArduinoCoreInstance core;
|
||||||
private final JComboBox typeChooser;
|
private final JComboBox typeChooser;
|
||||||
private final LibraryInstaller installer;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected FilteredAbstractTableModel createContribModel() {
|
protected FilteredAbstractTableModel createContribModel() {
|
||||||
@ -100,9 +100,9 @@ public class LibraryManagerUI extends InstallerJDialog<ContributedLibrary> {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public LibraryManagerUI(Frame parent, LibraryInstaller installer) {
|
public LibraryManagerUI(Frame parent, ArduinoCoreInstance core) {
|
||||||
super(parent, tr("Library Manager"), Dialog.ModalityType.APPLICATION_MODAL, tr("Unable to reach Arduino.cc due to possible network issues."));
|
super(parent, tr("Library Manager"), Dialog.ModalityType.APPLICATION_MODAL, tr("Unable to reach Arduino.cc due to possible network issues."));
|
||||||
this.installer = installer;
|
this.core = core;
|
||||||
|
|
||||||
filtersContainer.add(new JLabel(tr("Topic")), 1);
|
filtersContainer.add(new JLabel(tr("Topic")), 1);
|
||||||
filtersContainer.remove(2);
|
filtersContainer.remove(2);
|
||||||
@ -218,7 +218,7 @@ public class LibraryManagerUI extends InstallerJDialog<ContributedLibrary> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onInstallPressed(final ContributedLibraryRelease lib) {
|
public void onInstallPressed(final ContributedLibraryRelease lib) {
|
||||||
List<ContributedLibraryRelease> deps = BaseNoGui.getArduinoCoreService().libraryResolveDependecies(lib);
|
List<ContributedLibraryRelease> deps = core.libraryResolveDependecies(lib);
|
||||||
boolean depsInstalled = deps.stream().allMatch(l -> l.getInstalledLibrary().isPresent() || l.getName().equals(lib.getName()));
|
boolean depsInstalled = deps.stream().allMatch(l -> l.getInstalledLibrary().isPresent() || l.getName().equals(lib.getName()));
|
||||||
Result installDeps;
|
Result installDeps;
|
||||||
if (!depsInstalled) {
|
if (!depsInstalled) {
|
||||||
@ -237,9 +237,11 @@ public class LibraryManagerUI extends InstallerJDialog<ContributedLibrary> {
|
|||||||
try {
|
try {
|
||||||
setProgressVisible(true, tr("Installing..."));
|
setProgressVisible(true, tr("Installing..."));
|
||||||
if (installDeps == Result.ALL) {
|
if (installDeps == Result.ALL) {
|
||||||
installer.install(deps, this::setProgress);
|
deps.forEach(dep -> {
|
||||||
|
core.libraryInstall(dep, this::setProgress);
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
installer.install(lib, this::setProgress);
|
core.libraryInstall(lib, this::setProgress);
|
||||||
}
|
}
|
||||||
onIndexesUpdated();
|
onIndexesUpdated();
|
||||||
if (contribTable.getCellEditor() != null) {
|
if (contribTable.getCellEditor() != null) {
|
||||||
@ -271,7 +273,7 @@ public class LibraryManagerUI extends InstallerJDialog<ContributedLibrary> {
|
|||||||
installerThread = new Thread(() -> {
|
installerThread = new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
setProgressVisible(true, tr("Removing..."));
|
setProgressVisible(true, tr("Removing..."));
|
||||||
installer.remove(lib, this::setProgress);
|
core.libraryRemove(lib, this::setProgress);
|
||||||
onIndexesUpdated();
|
onIndexesUpdated();
|
||||||
if (contribTable.getCellEditor() != null) {
|
if (contribTable.getCellEditor() != null) {
|
||||||
contribTable.getCellEditor().stopCellEditing();
|
contribTable.getCellEditor().stopCellEditing();
|
||||||
|
@ -30,7 +30,6 @@ import cc.arduino.contributions.*;
|
|||||||
import cc.arduino.contributions.libraries.ContributedLibrary;
|
import cc.arduino.contributions.libraries.ContributedLibrary;
|
||||||
import cc.arduino.contributions.libraries.ContributedLibraryRelease;
|
import cc.arduino.contributions.libraries.ContributedLibraryRelease;
|
||||||
import cc.arduino.contributions.libraries.LibrariesIndexer;
|
import cc.arduino.contributions.libraries.LibrariesIndexer;
|
||||||
import cc.arduino.contributions.libraries.LibraryInstaller;
|
|
||||||
import cc.arduino.contributions.libraries.LibraryOfSameTypeComparator;
|
import cc.arduino.contributions.libraries.LibraryOfSameTypeComparator;
|
||||||
import cc.arduino.contributions.libraries.ui.LibraryManagerUI;
|
import cc.arduino.contributions.libraries.ui.LibraryManagerUI;
|
||||||
import cc.arduino.contributions.packages.ContributedPlatform;
|
import cc.arduino.contributions.packages.ContributedPlatform;
|
||||||
@ -98,7 +97,6 @@ public class Base {
|
|||||||
|
|
||||||
public static Map<String, Object> FIND_DIALOG_STATE = new HashMap<>();
|
public static Map<String, Object> FIND_DIALOG_STATE = new HashMap<>();
|
||||||
private final ContributionInstaller contributionInstaller;
|
private final ContributionInstaller contributionInstaller;
|
||||||
private final LibraryInstaller libraryInstaller;
|
|
||||||
private ContributionsSelfCheck contributionsSelfCheck;
|
private ContributionsSelfCheck contributionsSelfCheck;
|
||||||
|
|
||||||
// set to true after the first time the menu is built.
|
// set to true after the first time the menu is built.
|
||||||
@ -302,7 +300,6 @@ public class Base {
|
|||||||
|
|
||||||
final GPGDetachedSignatureVerifier gpgDetachedSignatureVerifier = new GPGDetachedSignatureVerifier();
|
final GPGDetachedSignatureVerifier gpgDetachedSignatureVerifier = new GPGDetachedSignatureVerifier();
|
||||||
contributionInstaller = new ContributionInstaller(BaseNoGui.getPlatform(), gpgDetachedSignatureVerifier);
|
contributionInstaller = new ContributionInstaller(BaseNoGui.getPlatform(), gpgDetachedSignatureVerifier);
|
||||||
libraryInstaller = new LibraryInstaller(BaseNoGui.getPlatform());
|
|
||||||
|
|
||||||
parser.parseArgumentsPhase2();
|
parser.parseArgumentsPhase2();
|
||||||
|
|
||||||
@ -395,9 +392,9 @@ public class Base {
|
|||||||
System.out.println(tr(I18n
|
System.out.println(tr(I18n
|
||||||
.format("Library {0} is available as built-in in the IDE.\nRemoving the other version {1} installed in the sketchbook...",
|
.format("Library {0} is available as built-in in the IDE.\nRemoving the other version {1} installed in the sketchbook...",
|
||||||
libraryArg, mayInstalled.get().getParsedVersion())));
|
libraryArg, mayInstalled.get().getParsedVersion())));
|
||||||
libraryInstaller.remove(mayInstalled.get(), progressListener);
|
BaseNoGui.getArduinoCoreService().libraryRemove(mayInstalled.get(), progressListener);
|
||||||
} else {
|
} else {
|
||||||
libraryInstaller.install(selected, progressListener);
|
BaseNoGui.getArduinoCoreService().libraryInstall(selected, progressListener);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1374,7 +1371,7 @@ public class Base {
|
|||||||
contributionsSelfCheck.cancel();
|
contributionsSelfCheck.cancel();
|
||||||
}
|
}
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
LibraryManagerUI managerUI = new LibraryManagerUI(activeEditor, libraryInstaller) {
|
LibraryManagerUI managerUI = new LibraryManagerUI(activeEditor, BaseNoGui.getArduinoCoreService()) {
|
||||||
@Override
|
@Override
|
||||||
protected void onIndexesUpdated() throws Exception {
|
protected void onIndexesUpdated() throws Exception {
|
||||||
BaseNoGui.initPackages();
|
BaseNoGui.initPackages();
|
||||||
|
@ -46,13 +46,18 @@ import cc.arduino.cli.commands.Commands.UpdateLibrariesIndexReq;
|
|||||||
import cc.arduino.cli.commands.Commands.UpdateLibrariesIndexResp;
|
import cc.arduino.cli.commands.Commands.UpdateLibrariesIndexResp;
|
||||||
import cc.arduino.cli.commands.Common.DownloadProgress;
|
import cc.arduino.cli.commands.Common.DownloadProgress;
|
||||||
import cc.arduino.cli.commands.Common.Instance;
|
import cc.arduino.cli.commands.Common.Instance;
|
||||||
|
import cc.arduino.cli.commands.Common.TaskProgress;
|
||||||
import cc.arduino.cli.commands.Compile.CompileReq;
|
import cc.arduino.cli.commands.Compile.CompileReq;
|
||||||
import cc.arduino.cli.commands.Compile.CompileResp;
|
import cc.arduino.cli.commands.Compile.CompileResp;
|
||||||
import cc.arduino.cli.commands.Lib.InstalledLibrary;
|
import cc.arduino.cli.commands.Lib.InstalledLibrary;
|
||||||
|
import cc.arduino.cli.commands.Lib.LibraryInstallReq;
|
||||||
|
import cc.arduino.cli.commands.Lib.LibraryInstallResp;
|
||||||
import cc.arduino.cli.commands.Lib.LibraryListReq;
|
import cc.arduino.cli.commands.Lib.LibraryListReq;
|
||||||
import cc.arduino.cli.commands.Lib.LibraryListResp;
|
import cc.arduino.cli.commands.Lib.LibraryListResp;
|
||||||
import cc.arduino.cli.commands.Lib.LibrarySearchReq;
|
import cc.arduino.cli.commands.Lib.LibrarySearchReq;
|
||||||
import cc.arduino.cli.commands.Lib.LibrarySearchResp;
|
import cc.arduino.cli.commands.Lib.LibrarySearchResp;
|
||||||
|
import cc.arduino.cli.commands.Lib.LibraryUninstallReq;
|
||||||
|
import cc.arduino.cli.commands.Lib.LibraryUninstallResp;
|
||||||
import cc.arduino.cli.commands.Lib.SearchedLibrary;
|
import cc.arduino.cli.commands.Lib.SearchedLibrary;
|
||||||
import cc.arduino.contributions.ProgressListener;
|
import cc.arduino.contributions.ProgressListener;
|
||||||
import cc.arduino.contributions.libraries.ContributedLibraryRelease;
|
import cc.arduino.contributions.libraries.ContributedLibraryRelease;
|
||||||
@ -155,7 +160,8 @@ public class ArduinoCoreInstance {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<InstalledLibrary> libraryList(boolean listAll) throws StatusException {
|
public List<InstalledLibrary> libraryList(boolean listAll)
|
||||||
|
throws StatusException {
|
||||||
try {
|
try {
|
||||||
LibraryListResp resp = stub.libraryList(LibraryListReq.newBuilder() //
|
LibraryListResp resp = stub.libraryList(LibraryListReq.newBuilder() //
|
||||||
.setInstance(instance) //
|
.setInstance(instance) //
|
||||||
@ -171,4 +177,35 @@ public class ArduinoCoreInstance {
|
|||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void libraryInstall(ContributedLibraryRelease lib,
|
||||||
|
ProgressListener progressListener) {
|
||||||
|
Iterator<LibraryInstallResp> stream = stub
|
||||||
|
.libraryInstall(LibraryInstallReq.newBuilder() //
|
||||||
|
.setInstance(instance) //
|
||||||
|
.setName(lib.getName()) //
|
||||||
|
.setVersion(lib.getVersion()) //
|
||||||
|
.build());
|
||||||
|
ProgressWrapper p = new ProgressWrapper(progressListener);
|
||||||
|
while (stream.hasNext()) {
|
||||||
|
LibraryInstallResp resp = stream.next();
|
||||||
|
DownloadProgress progress = resp.getProgress();
|
||||||
|
p.update(progress);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void libraryRemove(ContributedLibraryRelease lib,
|
||||||
|
ProgressListener progressListener) {
|
||||||
|
Iterator<LibraryUninstallResp> stream = stub
|
||||||
|
.libraryUninstall(LibraryUninstallReq.newBuilder() //
|
||||||
|
.setInstance(instance) //
|
||||||
|
.setName(lib.getName()) //
|
||||||
|
.setVersion(lib.getVersion()) //
|
||||||
|
.build());
|
||||||
|
ProgressWrapper p = new ProgressWrapper(progressListener);
|
||||||
|
while (stream.hasNext()) {
|
||||||
|
LibraryUninstallResp resp = stream.next();
|
||||||
|
TaskProgress progress = resp.getTaskProgress();
|
||||||
|
p.update(progress);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,7 @@ import static processing.app.I18n.format;
|
|||||||
import static processing.app.I18n.tr;
|
import static processing.app.I18n.tr;
|
||||||
|
|
||||||
import cc.arduino.cli.commands.Common.DownloadProgress;
|
import cc.arduino.cli.commands.Common.DownloadProgress;
|
||||||
|
import cc.arduino.cli.commands.Common.TaskProgress;
|
||||||
import cc.arduino.contributions.ProgressListener;
|
import cc.arduino.contributions.ProgressListener;
|
||||||
import cc.arduino.utils.MultiStepProgress;
|
import cc.arduino.utils.MultiStepProgress;
|
||||||
import cc.arduino.utils.Progress;
|
import cc.arduino.utils.Progress;
|
||||||
@ -78,4 +79,17 @@ class ProgressWrapper {
|
|||||||
}
|
}
|
||||||
progressListener.onProgress(progress);
|
progressListener.onProgress(progress);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String taskName;
|
||||||
|
|
||||||
|
public void update(TaskProgress t) {
|
||||||
|
String name = t.getName();
|
||||||
|
if (!name.isEmpty()) {
|
||||||
|
taskName = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
progress.setProgress(t.getCompleted() ? 100 : 0);
|
||||||
|
progress.setStatus(taskName + " " + t.getMessage());
|
||||||
|
progressListener.onProgress(progress);
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,186 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.libraries;
|
|
||||||
|
|
||||||
import cc.arduino.Constants;
|
|
||||||
import cc.arduino.contributions.DownloadableContributionsDownloader;
|
|
||||||
import cc.arduino.contributions.GPGDetachedSignatureVerifier;
|
|
||||||
import cc.arduino.contributions.GZippedJsonDownloader;
|
|
||||||
import cc.arduino.contributions.ProgressListener;
|
|
||||||
import cc.arduino.utils.ArchiveExtractor;
|
|
||||||
import cc.arduino.utils.MultiStepProgress;
|
|
||||||
import cc.arduino.utils.network.FileDownloader;
|
|
||||||
import org.apache.commons.io.FilenameUtils;
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
import processing.app.BaseNoGui;
|
|
||||||
import processing.app.I18n;
|
|
||||||
import processing.app.Platform;
|
|
||||||
import processing.app.helpers.FileUtils;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.StandardCopyOption;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
import static processing.app.I18n.tr;
|
|
||||||
|
|
||||||
public class LibraryInstaller {
|
|
||||||
private static Logger log = LogManager.getLogger(LibraryInstaller.class);
|
|
||||||
|
|
||||||
private final Platform platform;
|
|
||||||
|
|
||||||
public LibraryInstaller(Platform platform) {
|
|
||||||
this.platform = platform;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void install(ContributedLibraryRelease lib, ProgressListener progressListener) throws Exception {
|
|
||||||
ArrayList<ContributedLibraryRelease> libs = new ArrayList<>();
|
|
||||||
libs.add(lib);
|
|
||||||
install(libs, progressListener);
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized void install(List<ContributedLibraryRelease> libs, ProgressListener progressListener) throws Exception {
|
|
||||||
/*
|
|
||||||
MultiStepProgress progress = new MultiStepProgress(3 * libs.size() + 1);
|
|
||||||
|
|
||||||
for (ContributedLibraryRelease lib : libs) {
|
|
||||||
// Do install library (3 steps)
|
|
||||||
performInstall(lib, progressListener, progress);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Rescan index (1 step)
|
|
||||||
rescanLibraryIndex(progress, progressListener);
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
private void performInstall(ContributedLibraryRelease lib, ProgressListener progressListener, MultiStepProgress progress) throws Exception {
|
|
||||||
/*
|
|
||||||
if (lib.isLibraryInstalled()) {
|
|
||||||
System.out.println(I18n.format(tr("Library is already installed: {0}:{1}"), lib.getName(), lib.getParsedVersion()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
File libsFolder = BaseNoGui.getSketchbookLibrariesFolder().folder;
|
|
||||||
File destFolder = new File(libsFolder, lib.getName().replaceAll(" ", "_"));
|
|
||||||
|
|
||||||
// Check if we are replacing an already installed lib
|
|
||||||
LibrariesIndex index = BaseNoGui.librariesIndexer.getIndex();
|
|
||||||
Optional<ContributedLibraryRelease> mayReplacedLib = lib.getLibrary()
|
|
||||||
.getInstalled();
|
|
||||||
if (mayReplacedLib.isPresent()) {
|
|
||||||
if (mayReplacedLib.get().getInstalledLibrary().get().getInstalledFolder()
|
|
||||||
.equals(destFolder) && destFolder.exists()) {
|
|
||||||
System.out
|
|
||||||
.println(I18n.format(tr("Library {0} is already installed in: {1}"),
|
|
||||||
lib.getName(), destFolder));
|
|
||||||
return;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// TODO: Check correctness
|
|
||||||
// Optional<ContributedLibraryRelease> mayReplacedLib =
|
|
||||||
// index.find(lib.getName());
|
|
||||||
// .filter(l ->
|
|
||||||
// l.getInstalledLibrary().get().getInstalledFolder().equals(destFolder)) //
|
|
||||||
// .findAny();
|
|
||||||
if (!replacedLib.isPresent() && destFolder.exists()) {
|
|
||||||
System.out
|
|
||||||
.println(I18n.format(tr("Library {0} is already installed in: {1}"),
|
|
||||||
lib.getName(), destFolder));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
DownloadableContributionsDownloader downloader = new DownloadableContributionsDownloader(BaseNoGui.librariesIndexer.getStagingFolder());
|
|
||||||
|
|
||||||
// Step 1: Download library
|
|
||||||
try {
|
|
||||||
downloader.download(lib, progress, I18n.format(tr("Downloading library: {0}"), lib.getName()), progressListener, false);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
// Download interrupted... just exit
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
progress.stepDone();
|
|
||||||
|
|
||||||
// TODO: Extract to temporary folders and move to the final destination only
|
|
||||||
// once everything is successfully unpacked. If the operation fails remove
|
|
||||||
// all the temporary folders and abort installation.
|
|
||||||
|
|
||||||
// Step 2: Unpack library on the correct location
|
|
||||||
progress.setStatus(I18n.format(tr("Installing library: {0}:{1}"), lib.getName(), lib.getParsedVersion()));
|
|
||||||
progressListener.onProgress(progress);
|
|
||||||
File tmpFolder = FileUtils.createTempFolder(libsFolder);
|
|
||||||
try {
|
|
||||||
new ArchiveExtractor(platform).extract(lib.getDownloadedFile(), tmpFolder, 1);
|
|
||||||
} catch (Exception e) {
|
|
||||||
if (tmpFolder.exists())
|
|
||||||
FileUtils.recursiveDelete(tmpFolder);
|
|
||||||
}
|
|
||||||
progress.stepDone();
|
|
||||||
|
|
||||||
// Step 3: Remove replaced library and move installed one to the correct location
|
|
||||||
// TODO: Fix progress bar...
|
|
||||||
if (replacedLib.isPresent()) {
|
|
||||||
remove(replacedLib.get(), progressListener);
|
|
||||||
}
|
|
||||||
tmpFolder.renameTo(destFolder);
|
|
||||||
progress.stepDone();
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized void remove(ContributedLibraryRelease lib, ProgressListener progressListener) throws IOException {
|
|
||||||
/*
|
|
||||||
if (lib.isIDEBuiltIn()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final MultiStepProgress progress = new MultiStepProgress(2);
|
|
||||||
|
|
||||||
// Step 1: Remove library
|
|
||||||
progress.setStatus(I18n.format(tr("Removing library: {0}:{1}"), lib.getName(), lib.getParsedVersion()));
|
|
||||||
progressListener.onProgress(progress);
|
|
||||||
FileUtils.recursiveDelete(lib.getInstalledLibrary().get().getInstalledFolder());
|
|
||||||
progress.stepDone();
|
|
||||||
|
|
||||||
// Step 2: Rescan index
|
|
||||||
rescanLibraryIndex(progress, progressListener);
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
private void rescanLibraryIndex(MultiStepProgress progress, ProgressListener progressListener) {
|
|
||||||
progress.setStatus(tr("Updating list of installed libraries"));
|
|
||||||
progressListener.onProgress(progress);
|
|
||||||
BaseNoGui.librariesIndexer.rescanLibraries();
|
|
||||||
progress.stepDone();
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user