mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-22 15:53:58 +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;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -263,6 +263,7 @@ 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) {
|
||||||
|
if (ArduinoDownloadsManager.checkLicense(getShell())) {
|
||||||
Collection<ArduinoLibrary> selectedLibraries = selectDialog.getChecked();
|
Collection<ArduinoLibrary> selectedLibraries = selectDialog.getChecked();
|
||||||
container.run(true, true, monitor -> {
|
container.run(true, true, monitor -> {
|
||||||
try {
|
try {
|
||||||
|
@ -272,6 +273,7 @@ public class LibrariesTabControl extends Composite {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
populateTable();
|
populateTable();
|
||||||
} catch (InterruptedException | InvocationTargetException e) {
|
} catch (InterruptedException | InvocationTargetException e) {
|
||||||
Activator.log(e);
|
Activator.log(e);
|
||||||
|
|
|
@ -257,6 +257,7 @@ 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) {
|
||||||
|
if (ArduinoDownloadsManager.checkLicense(getShell())) {
|
||||||
Collection<ArduinoPlatform> selectedPlatforms = selectDialog.getSelectedPlatforms();
|
Collection<ArduinoPlatform> selectedPlatforms = selectDialog.getSelectedPlatforms();
|
||||||
container.run(true, true, monitor -> {
|
container.run(true, true, monitor -> {
|
||||||
try {
|
try {
|
||||||
|
@ -266,6 +267,7 @@ public class PlatformsTabControl extends Composite {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
populateTable();
|
populateTable();
|
||||||
} catch (InterruptedException | InvocationTargetException e) {
|
} catch (InterruptedException | InvocationTargetException e) {
|
||||||
Activator.log(e);
|
Activator.log(e);
|
||||||
|
|
Loading…
Add table
Reference in a new issue