mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-21 23:33:57 +02:00
Put back the Arduino license check.
Change-Id: I2a59207f61dffe132d0bb3c6cd768030eb7ebc07
This commit is contained in:
parent
f8c6c39c40
commit
a36ef4c088
3 changed files with 48 additions and 16 deletions
|
@ -7,8 +7,13 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.arduino.ui.internal.downloads;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.eclipse.cdt.arduino.core.internal.ArduinoPreferences;
|
||||
import org.eclipse.cdt.arduino.ui.internal.Activator;
|
||||
import org.eclipse.jface.dialogs.IDialogConstants;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.jface.wizard.Wizard;
|
||||
import org.eclipse.jface.wizard.WizardDialog;
|
||||
import org.eclipse.jface.wizard.WizardPage;
|
||||
|
@ -21,6 +26,7 @@ import org.eclipse.swt.events.SelectionAdapter;
|
|||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
public class ArduinoDownloadsManager extends WizardDialog {
|
||||
|
||||
|
@ -91,4 +97,26 @@ public class ArduinoDownloadsManager extends WizardDialog {
|
|||
finishButton.moveBelow(null);
|
||||
}
|
||||
|
||||
static boolean checkLicense(Shell shell) {
|
||||
File acceptedFile = ArduinoPreferences.getArduinoHome().resolve(".accepted").toFile(); //$NON-NLS-1$
|
||||
if (!acceptedFile.exists()) {
|
||||
String message = "Do you accept the licenses for the platforms and libraries you are downloading?";
|
||||
MessageDialog dialog = new MessageDialog(shell, "Arduino Licensing", null, message,
|
||||
MessageDialog.QUESTION, new String[] { "Yes", "No" }, 0);
|
||||
int rc = dialog.open();
|
||||
if (rc == 0) {
|
||||
try {
|
||||
acceptedFile.createNewFile();
|
||||
} catch (IOException e) {
|
||||
Activator.log(e);
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -263,14 +263,16 @@ public class LibrariesTabControl extends Composite {
|
|||
SelectLibrariesDialog selectDialog = new SelectLibrariesDialog(getShell());
|
||||
selectDialog.setLibraries(availableLibraries);
|
||||
if (selectDialog.open() == Window.OK) {
|
||||
Collection<ArduinoLibrary> selectedLibraries = selectDialog.getChecked();
|
||||
container.run(true, true, monitor -> {
|
||||
try {
|
||||
manager.installLibraries(selectedLibraries, monitor);
|
||||
} catch (CoreException e) {
|
||||
Activator.log(e);
|
||||
}
|
||||
});
|
||||
if (ArduinoDownloadsManager.checkLicense(getShell())) {
|
||||
Collection<ArduinoLibrary> selectedLibraries = selectDialog.getChecked();
|
||||
container.run(true, true, monitor -> {
|
||||
try {
|
||||
manager.installLibraries(selectedLibraries, monitor);
|
||||
} catch (CoreException e) {
|
||||
Activator.log(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
populateTable();
|
||||
} catch (InterruptedException | InvocationTargetException e) {
|
||||
|
|
|
@ -257,14 +257,16 @@ public class PlatformsTabControl extends Composite {
|
|||
SelectPlatformsDialog selectDialog = new SelectPlatformsDialog(getShell());
|
||||
selectDialog.setPlatforms(availablePlatforms);
|
||||
if (selectDialog.open() == Window.OK) {
|
||||
Collection<ArduinoPlatform> selectedPlatforms = selectDialog.getSelectedPlatforms();
|
||||
container.run(true, true, monitor -> {
|
||||
try {
|
||||
manager.installPlatforms(selectedPlatforms, monitor);
|
||||
} catch (CoreException e) {
|
||||
Activator.log(e);
|
||||
}
|
||||
});
|
||||
if (ArduinoDownloadsManager.checkLicense(getShell())) {
|
||||
Collection<ArduinoPlatform> selectedPlatforms = selectDialog.getSelectedPlatforms();
|
||||
container.run(true, true, monitor -> {
|
||||
try {
|
||||
manager.installPlatforms(selectedPlatforms, monitor);
|
||||
} catch (CoreException e) {
|
||||
Activator.log(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
populateTable();
|
||||
} catch (InterruptedException | InvocationTargetException e) {
|
||||
|
|
Loading…
Add table
Reference in a new issue