[111116] Fixed license registry dialog to not show if no internet connection available.
diff --git a/plugins/org.eclipse.wst.internet.cache/src/org/eclipse/wst/internet/cache/internal/LicenseAcceptanceDialog.java b/plugins/org.eclipse.wst.internet.cache/src/org/eclipse/wst/internet/cache/internal/LicenseAcceptanceDialog.java
index 276525f..a26a254 100644
--- a/plugins/org.eclipse.wst.internet.cache/src/org/eclipse/wst/internet/cache/internal/LicenseAcceptanceDialog.java
+++ b/plugins/org.eclipse.wst.internet.cache/src/org/eclipse/wst/internet/cache/internal/LicenseAcceptanceDialog.java
@@ -10,6 +10,8 @@
*******************************************************************************/
package org.eclipse.wst.internet.cache.internal;
+import java.io.IOException;
+import java.io.InputStream;
import java.net.URL;
import java.util.Hashtable;
@@ -174,11 +176,11 @@
* @param licenseURL The license URL.
* @return True if the license is accepted, false otherwise.
*/
- public static boolean promptForLicense(Shell parent, String url, String licenseURL)
+ public static boolean promptForLicense(Shell parent, String url, String licenseURL) throws IOException
{
boolean agreedToLicense = false;
boolean newDialog = true;
- LicenseAcceptanceDialog dialog;
+ LicenseAcceptanceDialog dialog = null;
// If the dialog is already displayed for this license use it instead of
// displaying another dialog.
if(dialogsInUse.containsKey(licenseURL))
@@ -188,22 +190,68 @@
}
else
{
- dialog = new LicenseAcceptanceDialog(parent, url, licenseURL);
- dialogsInUse.put(licenseURL, dialog);
- dialog.setBlockOnOpen(true);
+ //BufferedReader bufreader = null;
+ InputStream is = null;
+// StringBuffer source = new StringBuffer();
+ try
+ {
+ URL urlObj = new URL(licenseURL);
+ is = urlObj.openStream();
+// if (urlObj != null)
+// {
+// bufreader = new BufferedReader(new InputStreamReader(urlObj.openStream()));
+//
+// if (bufreader != null)
+// {
+// while (bufreader.ready())
+// {
+// source.append(bufreader.readLine());
+// }
+// }
+// }
+ dialog = new LicenseAcceptanceDialog(parent, url, licenseURL);
+ dialogsInUse.put(licenseURL, dialog);
+ dialog.setBlockOnOpen(true);
+ }
+ catch(Exception e)
+ {
+ throw new IOException("The license cannot be opened.");
+ }
+ finally
+ {
+// if(bufreader != null)
+// {
+// bufreader.close();
+// }
+ if(is != null)
+ {
+ try
+ {
+ is.close();
+ }
+ catch(IOException e)
+ {
+ // Do nothing.
+ }
+ }
+ }
+ }
+ if(dialog != null)
+ {
+ dialog.open();
- }
- dialog.open();
-
- if (dialog.getReturnCode() == LicenseAcceptanceDialog.OK)
- {
- agreedToLicense = true;
+ if (dialog.getReturnCode() == LicenseAcceptanceDialog.OK)
+ {
+ agreedToLicense = true;
+ }
+
+ if(newDialog)
+ {
+ dialogsInUse.remove(licenseURL);
+ }
}
- if(newDialog)
- {
- dialogsInUse.remove(licenseURL);
- }
+
return agreedToLicense;
}
diff --git a/plugins/org.eclipse.wst.internet.cache/src/org/eclipse/wst/internet/cache/internal/LicenseRegistry.java b/plugins/org.eclipse.wst.internet.cache/src/org/eclipse/wst/internet/cache/internal/LicenseRegistry.java
index f7bcf6c..6a66bc5 100644
--- a/plugins/org.eclipse.wst.internet.cache/src/org/eclipse/wst/internet/cache/internal/LicenseRegistry.java
+++ b/plugins/org.eclipse.wst.internet.cache/src/org/eclipse/wst/internet/cache/internal/LicenseRegistry.java
@@ -166,12 +166,17 @@
// Prompt the user to accept the license.
- if(promptToAcceptLicense(url, licenseURL))
+ int licenseAcceptance = promptToAcceptLicense(url, licenseURL);
+ if(licenseAcceptance == Accepted.ACCEPTED)
{
agreeLicense(licenseURL);
return true;
}
- disagreeLicenseThisSession(licenseURL);
+ else if(licenseAcceptance == Accepted.NOT_ACCEPTED)
+ {
+ disagreeLicenseThisSession(licenseURL);
+ return false;
+ }
return false;
}
@@ -184,14 +189,28 @@
*
* @param url The URL of the resource for which the license needs to be accepted.
* @param licenseURL The URL of the license to be accepted.
- * @return True if the license is accepted, false otherwise.
+ * @return 0 if accepted, 1 if not accepted, 2 if not able to accept.
*/
- protected boolean promptToAcceptLicense(final String url, final String licenseURL)
+ protected int promptToAcceptLicense(final String url, final String licenseURL)
{
final Accepted accepted = new Accepted();
Display.getDefault().syncExec(new Runnable() {
public void run() {
- accepted.accepted = LicenseAcceptanceDialog.promptForLicense(null, url, licenseURL);
+ try
+ {
+ if(LicenseAcceptanceDialog.promptForLicense(null, url, licenseURL))
+ {
+ accepted.accepted = Accepted.ACCEPTED;
+ }
+ else
+ {
+ accepted.accepted = Accepted.NOT_ACCEPTED;
+ }
+ }
+ catch(Exception e)
+ {
+ accepted.accepted = Accepted.NOT_DETERMINED;
+ }
}
});
return accepted.accepted;
@@ -224,7 +243,10 @@
*/
private class Accepted
{
- public boolean accepted = false;
+ public static final int ACCEPTED = 0;
+ public static final int NOT_ACCEPTED = 1;
+ public static final int NOT_DETERMINED = 2;
+ public int accepted = NOT_ACCEPTED;
}
}
diff --git a/plugins/org.eclipse.wst.internet.cache/src/org/eclipse/wst/internet/cache/internal/preferences/CachePreferencePage.java b/plugins/org.eclipse.wst.internet.cache/src/org/eclipse/wst/internet/cache/internal/preferences/CachePreferencePage.java
index f228efd..5b8bd6c 100644
--- a/plugins/org.eclipse.wst.internet.cache/src/org/eclipse/wst/internet/cache/internal/preferences/CachePreferencePage.java
+++ b/plugins/org.eclipse.wst.internet.cache/src/org/eclipse/wst/internet/cache/internal/preferences/CachePreferencePage.java
@@ -53,8 +53,6 @@
private static final String _UI_PREF_CACHE_ENTRIES_TITLE = "_UI_PREF_CACHE_ENTRIES_TITLE";
- private static final String _UI_PREF_CACHE_OPTIONS_TITLE = "_UI_PREF_CACHE_OPTIONS_TITLE";
-
private static final String _UI_PREF_CACHE_CACHE_OPTION = "_UI_PREF_CACHE_CACHE_OPTION";
private static final String _UI_CONFIRM_DELETE_CACHE_ENTRY_DIALOG_TITLE = "_UI_CONFIRM_DELETE_CACHE_ENTRY_DIALOG_TITLE";
@@ -127,7 +125,7 @@
GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
gridData.horizontalSpan = 2;
aboutLabel.setLayoutData(gridData);
- Label blankLabel = new Label(composite, SWT.None);
+ new Label(composite, SWT.None);
try
{
// Created the disable cache option.