1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-22 07:43:56 +02:00

Put back the Arduino license check.

Change-Id: I2a59207f61dffe132d0bb3c6cd768030eb7ebc07
This commit is contained in:
Doug Schaefer 2016-07-14 21:18:20 -04:00 committed by Gerrit Code Review @ Eclipse.org
parent f8c6c39c40
commit a36ef4c088
3 changed files with 48 additions and 16 deletions

View file

@ -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;
}
}
}

View file

@ -263,6 +263,7 @@ public class LibrariesTabControl extends Composite {
SelectLibrariesDialog selectDialog = new SelectLibrariesDialog(getShell());
selectDialog.setLibraries(availableLibraries);
if (selectDialog.open() == Window.OK) {
if (ArduinoDownloadsManager.checkLicense(getShell())) {
Collection<ArduinoLibrary> selectedLibraries = selectDialog.getChecked();
container.run(true, true, monitor -> {
try {
@ -272,6 +273,7 @@ public class LibrariesTabControl extends Composite {
}
});
}
}
populateTable();
} catch (InterruptedException | InvocationTargetException e) {
Activator.log(e);

View file

@ -257,6 +257,7 @@ public class PlatformsTabControl extends Composite {
SelectPlatformsDialog selectDialog = new SelectPlatformsDialog(getShell());
selectDialog.setPlatforms(availablePlatforms);
if (selectDialog.open() == Window.OK) {
if (ArduinoDownloadsManager.checkLicense(getShell())) {
Collection<ArduinoPlatform> selectedPlatforms = selectDialog.getSelectedPlatforms();
container.run(true, true, monitor -> {
try {
@ -266,6 +267,7 @@ public class PlatformsTabControl extends Composite {
}
});
}
}
populateTable();
} catch (InterruptedException | InvocationTargetException e) {
Activator.log(e);