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; 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.cdt.arduino.ui.internal.Activator;
import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.wizard.Wizard; import org.eclipse.jface.wizard.Wizard;
import org.eclipse.jface.wizard.WizardDialog; import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.jface.wizard.WizardPage; 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.events.SelectionEvent;
import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Shell;
public class ArduinoDownloadsManager extends WizardDialog { public class ArduinoDownloadsManager extends WizardDialog {
@ -91,4 +97,26 @@ public class ArduinoDownloadsManager extends WizardDialog {
finishButton.moveBelow(null); 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,14 +263,16 @@ public class LibrariesTabControl extends Composite {
SelectLibrariesDialog selectDialog = new SelectLibrariesDialog(getShell()); SelectLibrariesDialog selectDialog = new SelectLibrariesDialog(getShell());
selectDialog.setLibraries(availableLibraries); selectDialog.setLibraries(availableLibraries);
if (selectDialog.open() == Window.OK) { if (selectDialog.open() == Window.OK) {
Collection<ArduinoLibrary> selectedLibraries = selectDialog.getChecked(); if (ArduinoDownloadsManager.checkLicense(getShell())) {
container.run(true, true, monitor -> { Collection<ArduinoLibrary> selectedLibraries = selectDialog.getChecked();
try { container.run(true, true, monitor -> {
manager.installLibraries(selectedLibraries, monitor); try {
} catch (CoreException e) { manager.installLibraries(selectedLibraries, monitor);
Activator.log(e); } catch (CoreException e) {
} Activator.log(e);
}); }
});
}
} }
populateTable(); populateTable();
} catch (InterruptedException | InvocationTargetException e) { } catch (InterruptedException | InvocationTargetException e) {

View file

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