Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2015-03-26 11:07:05 +0000
committerEike Stepper2015-03-26 11:07:05 +0000
commit351c7a4c52828617565b8f6025e815515554aee0 (patch)
tree2ab46859efc203966bb08ef50e6d30b39cabe514
parent6482d54a15ac25512ae45ad896f547a2cbb09d8e (diff)
downloadorg.eclipse.oomph-351c7a4c52828617565b8f6025e815515554aee0.tar.gz
org.eclipse.oomph-351c7a4c52828617565b8f6025e815515554aee0.tar.xz
org.eclipse.oomph-351c7a4c52828617565b8f6025e815515554aee0.zip
[460825] Put the network settings button on the main page
https://bugs.eclipse.org/bugs/show_bug.cgi?id=460825
-rw-r--r--plugins/org.eclipse.oomph.setup.core/src/org/eclipse/oomph/setup/internal/core/util/CatalogManager.java11
-rw-r--r--plugins/org.eclipse.oomph.setup.core/src/org/eclipse/oomph/setup/internal/core/util/ECFURIHandlerImpl.java656
-rw-r--r--plugins/org.eclipse.oomph.setup.core/src/org/eclipse/oomph/setup/internal/core/util/SetupCoreUtil.java4
-rw-r--r--plugins/org.eclipse.oomph.setup.installer/src/org/eclipse/oomph/setup/internal/installer/SimpleProductPage.java108
-rw-r--r--plugins/org.eclipse.oomph.setup.ui/src/org/eclipse/oomph/setup/ui/wizards/ProductPage.java5
-rw-r--r--plugins/org.eclipse.oomph.setup.ui/src/org/eclipse/oomph/setup/ui/wizards/SetupWizard.java32
-rw-r--r--plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/IOUtil.java8
7 files changed, 470 insertions, 354 deletions
diff --git a/plugins/org.eclipse.oomph.setup.core/src/org/eclipse/oomph/setup/internal/core/util/CatalogManager.java b/plugins/org.eclipse.oomph.setup.core/src/org/eclipse/oomph/setup/internal/core/util/CatalogManager.java
index 8aa3a8485..032cdb20f 100644
--- a/plugins/org.eclipse.oomph.setup.core/src/org/eclipse/oomph/setup/internal/core/util/CatalogManager.java
+++ b/plugins/org.eclipse.oomph.setup.core/src/org/eclipse/oomph/setup/internal/core/util/CatalogManager.java
@@ -31,6 +31,7 @@ import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.ecore.util.InternalEList;
+import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -64,6 +65,11 @@ public class CatalogManager
public List<? extends Scope> getCatalogs(boolean product)
{
+ if (index == null)
+ {
+ return Collections.emptyList();
+ }
+
@SuppressWarnings("unchecked")
List<? extends Scope> result = (List<? extends Scope>)index.eGet(product ? SetupPackage.Literals.INDEX__PRODUCT_CATALOGS
: SetupPackage.Literals.INDEX__PROJECT_CATALOGS);
@@ -93,6 +99,11 @@ public class CatalogManager
public void indexLoaded(Index index)
{
+ if (index == null)
+ {
+ return;
+ }
+
this.index = index;
// Load the local selection into the same resource set as the index, but only if the local selection exists.
diff --git a/plugins/org.eclipse.oomph.setup.core/src/org/eclipse/oomph/setup/internal/core/util/ECFURIHandlerImpl.java b/plugins/org.eclipse.oomph.setup.core/src/org/eclipse/oomph/setup/internal/core/util/ECFURIHandlerImpl.java
index 7bd1a8dad..07387650e 100644
--- a/plugins/org.eclipse.oomph.setup.core/src/org/eclipse/oomph/setup/internal/core/util/ECFURIHandlerImpl.java
+++ b/plugins/org.eclipse.oomph.setup.core/src/org/eclipse/oomph/setup/internal/core/util/ECFURIHandlerImpl.java
@@ -51,6 +51,7 @@ import org.eclipse.equinox.security.storage.StorageException;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
+import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
@@ -72,309 +73,15 @@ public class ECFURIHandlerImpl extends URIHandlerImpl
{
public static final String OPTION_CACHE_HANDLING = "OPTION_CACHE_HANDLING";
- public enum CacheHandling
- {
- CACHE_ONLY, CACHE_WITHOUT_ETAG_CHECKING, CACHE_WITH_ETAG_CHECKING, CACHE_IGNORE
- }
-
public static final String OPTION_AUTHORIZATION_HANDLER = "OPTION_AUTHORIZATION_HANDLER";
public static final String OPTION_AUTHORIZATION = "OPTION_AUTHORIZATION";
- public interface AuthorizationHandler
- {
- public final class Authorization
- {
- public static final Authorization UNAUTHORIZED = new Authorization("", "");
-
- public static final Authorization UNAUTHORIZEABLE = new Authorization("", "");
-
- private final String user;
-
- private final String password;
-
- public Authorization(String user, String password)
- {
- this.user = user == null ? "" : user;
- this.password = obscure(password == null ? "" : password);
- }
-
- public String getUser()
- {
- return user;
- }
-
- public String getPassword()
- {
- return unobscure(password);
- }
-
- public String getAuthorization()
- {
- return "Basic " + obscure(user.length() == 0 ? getPassword() : user + ":" + getPassword());
- }
-
- public boolean isAuthorized()
- {
- return !"".equals(password);
- }
-
- public boolean isUnauthorizeable()
- {
- return this == UNAUTHORIZEABLE;
- }
-
- private String obscure(String string)
- {
- return XMLTypeFactory.eINSTANCE.convertBase64Binary(string.getBytes());
- }
-
- private String unobscure(String string)
- {
- return new String(XMLTypeFactory.eINSTANCE.createBase64Binary(string));
- }
-
- @Override
- public int hashCode()
- {
- final int prime = 31;
- int result = 1;
- result = prime * result + (user == null ? 0 : user.hashCode());
- result = prime * result + (password == null ? 0 : password.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (this == obj)
- {
- return true;
- }
-
- if (obj == null)
- {
- return false;
- }
-
- if (getClass() != obj.getClass())
- {
- return false;
- }
-
- if (this == UNAUTHORIZEABLE)
- {
- return obj == UNAUTHORIZEABLE;
- }
-
- Authorization other = (Authorization)obj;
- if (!user.equals(other.user))
- {
- return false;
- }
-
- if (!password.equals(other.password))
- {
- return false;
- }
-
- return true;
- }
-
- @Override
- public String toString()
- {
- return this == UNAUTHORIZEABLE ? "Authorization [unauthorizeable]" : "Authorization [user=" + user + ", password=" + password + "]";
- }
- }
-
- public Authorization authorize(URI uri);
-
- public Authorization reauthorize(URI uri, Authorization authorization);
- }
-
- public static class AuthorizationHandlerImpl implements AuthorizationHandler
- {
- private final Map<String, Authorization> authorizations = new HashMap<String, Authorization>();
-
- private final UIServices uiServices;
-
- private ISecurePreferences securePreferences;
-
- public AuthorizationHandlerImpl(UIServices uiServices, ISecurePreferences securePreferences)
- {
- this.uiServices = uiServices;
- this.securePreferences = securePreferences;
- }
-
- public synchronized void clearCache()
- {
- authorizations.clear();
- }
-
- public synchronized Authorization authorize(URI uri)
- {
- String host = getHost(uri);
- if (host != null)
- {
- Authorization cachedAuthorization = authorizations.get(host);
- if (cachedAuthorization == Authorization.UNAUTHORIZEABLE)
- {
- return cachedAuthorization;
- }
-
- if (securePreferences != null)
- {
- try
- {
- ISecurePreferences node = securePreferences.node(host);
- String user = node.get("user", "");
- String password = node.get("password", "");
-
- Authorization authorization = new Authorization(user, password);
- if (authorization.isAuthorized())
- {
- authorizations.put(host, authorization);
- return authorization;
- }
- }
- catch (StorageException ex)
- {
- SetupCorePlugin.INSTANCE.log(ex);
- }
- }
-
- if (cachedAuthorization != null)
- {
- return cachedAuthorization;
- }
- }
-
- return Authorization.UNAUTHORIZED;
- }
-
- public synchronized Authorization reauthorize(URI uri, Authorization authorization)
- {
- // Double check that another thread hasn't already prompted and updated the secure store or has not already permanently failed to authorize.
- Authorization currentAuthorization = authorize(uri);
- if (!currentAuthorization.equals(authorization) || currentAuthorization == Authorization.UNAUTHORIZEABLE)
- {
- return currentAuthorization;
- }
-
- if (uiServices != null)
- {
- String host = getHost(uri);
- if (host != null)
- {
- AuthenticationInfo authenticationInfo = uiServices.getUsernamePassword(uri.toString());
- String user = authenticationInfo.getUserName();
- String password = authenticationInfo.getPassword();
- Authorization reauthorization = new Authorization(user, password);
- if (reauthorization.isAuthorized())
- {
- if (authenticationInfo.saveResult() && securePreferences != null)
- {
- try
- {
- ISecurePreferences node = securePreferences.node(host);
- node.put("user", user, false);
- node.put("password", password, true);
- node.flush();
- }
- catch (IOException ex)
- {
- SetupCorePlugin.INSTANCE.log(ex);
- }
- catch (StorageException ex)
- {
- SetupCorePlugin.INSTANCE.log(ex);
- }
- }
-
- authorizations.put(host, reauthorization);
- return reauthorization;
- }
- else
- {
- authorizations.put(host, Authorization.UNAUTHORIZEABLE);
- return Authorization.UNAUTHORIZEABLE;
- }
- }
- }
-
- return currentAuthorization;
- }
- }
-
private static final URI CACHE_FOLDER = SetupContext.GLOBAL_STATE_LOCATION_URI.appendSegment("cache");
private static final Map<URI, String> EXPECTED_ETAGS = new HashMap<URI, String>();
- public static Set<? extends URI> clearExpectedETags()
- {
- Set<URI> result;
- synchronized (EXPECTED_ETAGS)
- {
- result = new HashSet<URI>(EXPECTED_ETAGS.keySet());
- EXPECTED_ETAGS.clear();
- }
-
- return result;
- }
-
- public static Job mirror(final Set<? extends URI> uris)
- {
- Job job = new Job("ETag Mirror")
- {
- @Override
- protected IStatus run(IProgressMonitor monitor)
- {
- new ETagMirror().begin(uris, monitor);
- return Status.OK_STATUS;
- }
- };
-
- job.schedule();
- return job;
- }
-
- private static String getExpectedETag(URI uri)
- {
- synchronized (EXPECTED_ETAGS)
- {
- return EXPECTED_ETAGS.get(uri);
- }
- }
-
- private static void setExpectedETag(URI uri, String eTag)
- {
- synchronized (EXPECTED_ETAGS)
- {
- EXPECTED_ETAGS.put(uri, eTag);
- }
- }
-
- private static CacheHandling getCacheHandling(Map<?, ?> options)
- {
- CacheHandling cacheHandling = (CacheHandling)options.get(OPTION_CACHE_HANDLING);
- if (cacheHandling == null)
- {
- cacheHandling = CacheHandling.CACHE_WITH_ETAG_CHECKING;
- }
-
- return cacheHandling;
- }
-
- private static AuthorizationHandler getAuthorizatonHandler(Map<?, ?> options)
- {
- return (AuthorizationHandler)options.get(OPTION_AUTHORIZATION_HANDLER);
- }
-
- private static Authorization getAuthorizaton(Map<?, ?> options)
- {
- return (Authorization)options.get(OPTION_AUTHORIZATION);
- }
+ private static final boolean TEST_IO_EXCEPTION = false;
@Override
public Map<String, ?> getAttributes(URI uri, Map<?, ?> options)
@@ -402,6 +109,18 @@ public class ECFURIHandlerImpl extends URIHandlerImpl
@Override
public InputStream createInputStream(URI uri, Map<?, ?> options) throws IOException
{
+ if (TEST_IO_EXCEPTION)
+ {
+ File folder = new File(CACHE_FOLDER.toFileString());
+ if (folder.isDirectory())
+ {
+ System.out.println("Deleting cache folder: " + folder);
+ IOUtil.deleteBestEffort(folder);
+ }
+
+ throw new IOException("Simulated network problem");
+ }
+
CacheHandling cacheHandling = getCacheHandling(options);
URIConverter uriConverter = getURIConverter(options);
URI cacheURI = getCacheFile(uri);
@@ -446,8 +165,7 @@ public class ECFURIHandlerImpl extends URIHandlerImpl
int triedReauthorization = 0;
for (int i = 0;; ++i)
{
- IRetrieveFileTransferContainerAdapter fileTransfer = (IRetrieveFileTransferContainerAdapter)container
- .getAdapter(IRetrieveFileTransferContainerAdapter.class);
+ IRetrieveFileTransferContainerAdapter fileTransfer = container.getAdapter(IRetrieveFileTransferContainerAdapter.class);
if (proxy != null)
{
@@ -585,6 +303,34 @@ public class ECFURIHandlerImpl extends URIHandlerImpl
}
}
+ public static Set<? extends URI> clearExpectedETags()
+ {
+ Set<URI> result;
+ synchronized (EXPECTED_ETAGS)
+ {
+ result = new HashSet<URI>(EXPECTED_ETAGS.keySet());
+ EXPECTED_ETAGS.clear();
+ }
+
+ return result;
+ }
+
+ public static Job mirror(final Set<? extends URI> uris)
+ {
+ Job job = new Job("ETag Mirror")
+ {
+ @Override
+ protected IStatus run(IProgressMonitor monitor)
+ {
+ new ETagMirror().begin(uris, monitor);
+ return Status.OK_STATUS;
+ }
+ };
+
+ job.schedule();
+ return job;
+ }
+
public static URI getCacheFile(URI uri)
{
return CACHE_FOLDER.appendSegment(IOUtil.encodeFileName(uri.toString()));
@@ -648,6 +394,301 @@ public class ECFURIHandlerImpl extends URIHandlerImpl
return null;
}
+ @SuppressWarnings({ "deprecation", "restriction" })
+ private static Date parseHTTPDate(String string)
+ {
+ try
+ {
+ return org.apache.http.impl.cookie.DateUtils.parseDate(string);
+ }
+ catch (Exception ex)
+ {
+ //$FALL-THROUGH$
+ }
+
+ return null;
+ }
+
+ private static String getExpectedETag(URI uri)
+ {
+ synchronized (EXPECTED_ETAGS)
+ {
+ return EXPECTED_ETAGS.get(uri);
+ }
+ }
+
+ private static void setExpectedETag(URI uri, String eTag)
+ {
+ synchronized (EXPECTED_ETAGS)
+ {
+ EXPECTED_ETAGS.put(uri, eTag);
+ }
+ }
+
+ private static CacheHandling getCacheHandling(Map<?, ?> options)
+ {
+ CacheHandling cacheHandling = (CacheHandling)options.get(OPTION_CACHE_HANDLING);
+ if (cacheHandling == null)
+ {
+ cacheHandling = CacheHandling.CACHE_WITH_ETAG_CHECKING;
+ }
+
+ return cacheHandling;
+ }
+
+ private static AuthorizationHandler getAuthorizatonHandler(Map<?, ?> options)
+ {
+ return (AuthorizationHandler)options.get(OPTION_AUTHORIZATION_HANDLER);
+ }
+
+ private static Authorization getAuthorizaton(Map<?, ?> options)
+ {
+ return (Authorization)options.get(OPTION_AUTHORIZATION);
+ }
+
+ /**
+ * @author Ed Merks
+ */
+ public enum CacheHandling
+ {
+ CACHE_ONLY, CACHE_WITHOUT_ETAG_CHECKING, CACHE_WITH_ETAG_CHECKING, CACHE_IGNORE
+ }
+
+ /**
+ * @author Ed Merks
+ */
+ public interface AuthorizationHandler
+ {
+ public Authorization authorize(URI uri);
+
+ public Authorization reauthorize(URI uri, Authorization authorization);
+
+ /**
+ * @author Ed Merks
+ */
+ public static final class Authorization
+ {
+ public static final Authorization UNAUTHORIZED = new Authorization("", "");
+
+ public static final Authorization UNAUTHORIZEABLE = new Authorization("", "");
+
+ private final String user;
+
+ private final String password;
+
+ public Authorization(String user, String password)
+ {
+ this.user = user == null ? "" : user;
+ this.password = obscure(password == null ? "" : password);
+ }
+
+ public String getUser()
+ {
+ return user;
+ }
+
+ public String getPassword()
+ {
+ return unobscure(password);
+ }
+
+ public String getAuthorization()
+ {
+ return "Basic " + obscure(user.length() == 0 ? getPassword() : user + ":" + getPassword());
+ }
+
+ public boolean isAuthorized()
+ {
+ return !"".equals(password);
+ }
+
+ public boolean isUnauthorizeable()
+ {
+ return this == UNAUTHORIZEABLE;
+ }
+
+ private String obscure(String string)
+ {
+ return XMLTypeFactory.eINSTANCE.convertBase64Binary(string.getBytes());
+ }
+
+ private String unobscure(String string)
+ {
+ return new String(XMLTypeFactory.eINSTANCE.createBase64Binary(string));
+ }
+
+ @Override
+ public int hashCode()
+ {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + (user == null ? 0 : user.hashCode());
+ result = prime * result + (password == null ? 0 : password.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
+ {
+ return true;
+ }
+
+ if (obj == null)
+ {
+ return false;
+ }
+
+ if (getClass() != obj.getClass())
+ {
+ return false;
+ }
+
+ if (this == UNAUTHORIZEABLE)
+ {
+ return obj == UNAUTHORIZEABLE;
+ }
+
+ Authorization other = (Authorization)obj;
+ if (!user.equals(other.user))
+ {
+ return false;
+ }
+
+ if (!password.equals(other.password))
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public String toString()
+ {
+ return this == UNAUTHORIZEABLE ? "Authorization [unauthorizeable]" : "Authorization [user=" + user + ", password=" + password + "]";
+ }
+ }
+ }
+
+ /**
+ * @author Ed Merks
+ */
+ public static class AuthorizationHandlerImpl implements AuthorizationHandler
+ {
+ private final Map<String, Authorization> authorizations = new HashMap<String, Authorization>();
+
+ private final UIServices uiServices;
+
+ private ISecurePreferences securePreferences;
+
+ public AuthorizationHandlerImpl(UIServices uiServices, ISecurePreferences securePreferences)
+ {
+ this.uiServices = uiServices;
+ this.securePreferences = securePreferences;
+ }
+
+ public synchronized void clearCache()
+ {
+ authorizations.clear();
+ }
+
+ public synchronized Authorization authorize(URI uri)
+ {
+ String host = getHost(uri);
+ if (host != null)
+ {
+ Authorization cachedAuthorization = authorizations.get(host);
+ if (cachedAuthorization == Authorization.UNAUTHORIZEABLE)
+ {
+ return cachedAuthorization;
+ }
+
+ if (securePreferences != null)
+ {
+ try
+ {
+ ISecurePreferences node = securePreferences.node(host);
+ String user = node.get("user", "");
+ String password = node.get("password", "");
+
+ Authorization authorization = new Authorization(user, password);
+ if (authorization.isAuthorized())
+ {
+ authorizations.put(host, authorization);
+ return authorization;
+ }
+ }
+ catch (StorageException ex)
+ {
+ SetupCorePlugin.INSTANCE.log(ex);
+ }
+ }
+
+ if (cachedAuthorization != null)
+ {
+ return cachedAuthorization;
+ }
+ }
+
+ return Authorization.UNAUTHORIZED;
+ }
+
+ public synchronized Authorization reauthorize(URI uri, Authorization authorization)
+ {
+ // Double check that another thread hasn't already prompted and updated the secure store or has not already permanently failed to authorize.
+ Authorization currentAuthorization = authorize(uri);
+ if (!currentAuthorization.equals(authorization) || currentAuthorization == Authorization.UNAUTHORIZEABLE)
+ {
+ return currentAuthorization;
+ }
+
+ if (uiServices != null)
+ {
+ String host = getHost(uri);
+ if (host != null)
+ {
+ AuthenticationInfo authenticationInfo = uiServices.getUsernamePassword(uri.toString());
+ String user = authenticationInfo.getUserName();
+ String password = authenticationInfo.getPassword();
+ Authorization reauthorization = new Authorization(user, password);
+ if (reauthorization.isAuthorized())
+ {
+ if (authenticationInfo.saveResult() && securePreferences != null)
+ {
+ try
+ {
+ ISecurePreferences node = securePreferences.node(host);
+ node.put("user", user, false);
+ node.put("password", password, true);
+ node.flush();
+ }
+ catch (IOException ex)
+ {
+ SetupCorePlugin.INSTANCE.log(ex);
+ }
+ catch (StorageException ex)
+ {
+ SetupCorePlugin.INSTANCE.log(ex);
+ }
+ }
+
+ authorizations.put(host, reauthorization);
+ return reauthorization;
+ }
+ else
+ {
+ authorizations.put(host, Authorization.UNAUTHORIZEABLE);
+ return Authorization.UNAUTHORIZEABLE;
+ }
+ }
+ }
+
+ return currentAuthorization;
+ }
+ }
+
/**
* @author Eike Stepper
*/
@@ -746,21 +787,9 @@ public class ECFURIHandlerImpl extends URIHandlerImpl
}
}
- @SuppressWarnings({ "deprecation", "restriction" })
- private static Date parseHTTPDate(String string)
- {
- try
- {
- return org.apache.http.impl.cookie.DateUtils.parseDate(string);
- }
- catch (Exception ex)
- {
- //$FALL-THROUGH$
- }
-
- return null;
- }
-
+ /**
+ * @author Ed Merks
+ */
private static class ETagMirror extends WorkerPool<ETagMirror, URI, ETagMirror.Worker>
{
private static final Map<Object, Object> OPTIONS;
@@ -797,6 +826,9 @@ public class ECFURIHandlerImpl extends URIHandlerImpl
perform(uris);
}
+ /**
+ * @author Ed Merks
+ */
private static class Worker extends WorkerPool.Worker<URI, ETagMirror>
{
protected Worker(String name, ETagMirror workPool, URI key, int id, boolean secondary)
diff --git a/plugins/org.eclipse.oomph.setup.core/src/org/eclipse/oomph/setup/internal/core/util/SetupCoreUtil.java b/plugins/org.eclipse.oomph.setup.core/src/org/eclipse/oomph/setup/internal/core/util/SetupCoreUtil.java
index f114afed8..3bd3b5fb2 100644
--- a/plugins/org.eclipse.oomph.setup.core/src/org/eclipse/oomph/setup/internal/core/util/SetupCoreUtil.java
+++ b/plugins/org.eclipse.oomph.setup.core/src/org/eclipse/oomph/setup/internal/core/util/SetupCoreUtil.java
@@ -97,13 +97,13 @@ public final class SetupCoreUtil
{
return "";
}
-
+
String label = scope.getLabel();
if (StringUtil.isEmpty(label))
{
label = StringUtil.safe(scope.getName());
}
-
+
return label;
}
diff --git a/plugins/org.eclipse.oomph.setup.installer/src/org/eclipse/oomph/setup/internal/installer/SimpleProductPage.java b/plugins/org.eclipse.oomph.setup.installer/src/org/eclipse/oomph/setup/internal/installer/SimpleProductPage.java
index ca9516ef3..54abbba2a 100644
--- a/plugins/org.eclipse.oomph.setup.installer/src/org/eclipse/oomph/setup/internal/installer/SimpleProductPage.java
+++ b/plugins/org.eclipse.oomph.setup.installer/src/org/eclipse/oomph/setup/internal/installer/SimpleProductPage.java
@@ -11,6 +11,7 @@
package org.eclipse.oomph.setup.internal.installer;
import org.eclipse.oomph.internal.ui.AccessUtil;
+import org.eclipse.oomph.setup.Index;
import org.eclipse.oomph.setup.Product;
import org.eclipse.oomph.setup.ProductCatalog;
import org.eclipse.oomph.setup.Scope;
@@ -32,6 +33,7 @@ import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.browser.LocationAdapter;
@@ -45,6 +47,7 @@ import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;
import java.lang.reflect.InvocationTargetException;
+import java.util.List;
/**
* @author Eike Stepper
@@ -63,6 +66,8 @@ public class SimpleProductPage extends SimpleInstallerPage implements FilterHand
private SearchField searchField;
+ private ToolBar buttonBar;
+
private ToolItem refreshButton;
private ToolItem catalogsButton;
@@ -102,13 +107,13 @@ public class SimpleProductPage extends SimpleInstallerPage implements FilterHand
searchField.setLayoutData(searchFieldData);
searchField.getFilterControl().setFont(font);
- ToolBar toolBar = new ToolBar(searchComposite, SWT.FLAT | SWT.RIGHT);
- toolBar.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
+ buttonBar = new ToolBar(searchComposite, SWT.FLAT | SWT.RIGHT);
+ buttonBar.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
CatalogManager catalogManager = installer.getCatalogManager();
catalogSelector = new CatalogSelector(catalogManager, true);
- refreshButton = new ToolItem(toolBar, SWT.NONE);
+ refreshButton = new ToolItem(buttonBar, SWT.NONE);
refreshButton.setToolTipText("Refresh");
refreshButton.setImage(SetupInstallerPlugin.INSTANCE.getSWTImage("simple/refresh.png"));
refreshButton.addSelectionListener(new SelectionAdapter()
@@ -121,20 +126,6 @@ public class SimpleProductPage extends SimpleInstallerPage implements FilterHand
});
AccessUtil.setKey(refreshButton, "refresh");
- catalogsButton = new ToolItem(toolBar, SWT.DROP_DOWN);
- catalogsButton.setToolTipText("Select Catalogs");
- catalogsButton.setImage(SetupInstallerPlugin.INSTANCE.getSWTImage("simple/folder.png"));
- catalogManager.getSelection().eAdapters().add(new AdapterImpl()
- {
- @Override
- public void notifyChanged(Notification msg)
- {
- handleFilter("");
- }
- });
- catalogSelector.configure(catalogsButton);
- AccessUtil.setKey(catalogsButton, "catalogs");
-
stackComposite = new StackComposite(this, SWT.NONE);
stackComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
@@ -277,6 +268,38 @@ public class SimpleProductPage extends SimpleInstallerPage implements FilterHand
browser.setText(browser.getText());
}
+ private void createCatalogsButton()
+ {
+ if (catalogsButton == null)
+ {
+ catalogsButton = new ToolItem(buttonBar, SWT.DROP_DOWN);
+ catalogsButton.setToolTipText("Select Catalogs");
+ catalogsButton.setImage(SetupInstallerPlugin.INSTANCE.getSWTImage("simple/folder.png"));
+
+ CatalogManager catalogManager = catalogSelector.getCatalogManager();
+ catalogManager.getSelection().eAdapters().add(new AdapterImpl()
+ {
+ @Override
+ public void notifyChanged(Notification msg)
+ {
+ handleFilter("");
+ }
+ });
+
+ catalogSelector.configure(catalogsButton);
+ AccessUtil.setKey(catalogsButton, "catalogs");
+ }
+ }
+
+ private void disposeCatalogsButton()
+ {
+ if (catalogsButton != null)
+ {
+ catalogsButton.dispose();
+ catalogsButton = null;
+ }
+ }
+
public static String getHtml(StringBuilder builder)
{
builder.append("</table></body></html>\n");
@@ -402,9 +425,14 @@ public class SimpleProductPage extends SimpleInstallerPage implements FilterHand
{
searchField.setEnabled(false);
refreshButton.setEnabled(false);
- catalogsButton.setEnabled(false);
- stackComposite.setTopControl(animator);
+ if (catalogsButton != null)
+ {
+ catalogsButton.setEnabled(false);
+ }
+
+ browser.setText("", true);
+ stackComposite.setTopControl(animator);
animator.start(1, animator.getImages().length - 1);
final IProgressMonitor monitor = new NullProgressMonitor();
@@ -435,11 +463,49 @@ public class SimpleProductPage extends SimpleInstallerPage implements FilterHand
{
public void run()
{
- searchField.setEnabled(true);
refreshButton.setEnabled(true);
- catalogsButton.setEnabled(true);
stackComposite.setTopControl(browser);
browser.setFocus();
+
+ CatalogManager catalogManager = catalogSelector.getCatalogManager();
+ Index index = catalogManager.getIndex();
+ if (index == null)
+ {
+ disposeCatalogsButton();
+ int answer = new MessageDialog(getShell(), "Network Problem", null,
+ "The catalog could not be loaded. Please ensure that you have network access and, if needed, have configured your network proxy.",
+ MessageDialog.ERROR, new String[] { "Retry", "Configure Network Proxy...", "Exit" }, 0).open();
+ switch (answer)
+ {
+ case 0:
+ installer.reloadIndex();
+ return;
+
+ case 1:
+ new ProxyPreferenceDialog(getShell()).open();
+ installer.reloadIndex();
+ return;
+
+ default:
+ dialog.exitSelected();
+ return;
+ }
+ }
+
+ searchField.setEnabled(true);
+
+ List<? extends Scope> productCatalogs = catalogManager.getCatalogs(true);
+ if (productCatalogs != null && productCatalogs.size() >= 3) // Self products + 2 more catalogs
+ {
+ createCatalogsButton();
+ catalogsButton.setEnabled(true);
+ }
+ else
+ {
+ disposeCatalogsButton();
+ }
+
+ buttonBar.getParent().layout();
}
});
diff --git a/plugins/org.eclipse.oomph.setup.ui/src/org/eclipse/oomph/setup/ui/wizards/ProductPage.java b/plugins/org.eclipse.oomph.setup.ui/src/org/eclipse/oomph/setup/ui/wizards/ProductPage.java
index 849daf1b0..f8b38fa59 100644
--- a/plugins/org.eclipse.oomph.setup.ui/src/org/eclipse/oomph/setup/ui/wizards/ProductPage.java
+++ b/plugins/org.eclipse.oomph.setup.ui/src/org/eclipse/oomph/setup/ui/wizards/ProductPage.java
@@ -621,6 +621,11 @@ public class ProductPage extends SetupWizardPage
versionLabel.setEnabled(productSelected);
versionComboViewer.getControl().setEnabled(productSelected);
+ bitness32Button.setEnabled(productSelected);
+ bitness64Button.setEnabled(productSelected);
+ javaLabel.setEnabled(productSelected);
+ javaViewer.getControl().setEnabled(productSelected);
+ javaButton.setEnabled(productSelected);
if (poolButton != null)
{
diff --git a/plugins/org.eclipse.oomph.setup.ui/src/org/eclipse/oomph/setup/ui/wizards/SetupWizard.java b/plugins/org.eclipse.oomph.setup.ui/src/org/eclipse/oomph/setup/ui/wizards/SetupWizard.java
index 803ad8d0a..4d647fe2e 100644
--- a/plugins/org.eclipse.oomph.setup.ui/src/org/eclipse/oomph/setup/ui/wizards/SetupWizard.java
+++ b/plugins/org.eclipse.oomph.setup.ui/src/org/eclipse/oomph/setup/ui/wizards/SetupWizard.java
@@ -562,29 +562,27 @@ public abstract class SetupWizard extends Wizard implements IPageChangedListener
{
Resource resource = resourceSet.getResource(SetupContext.INDEX_SETUP_URI, false);
final Index index = (Index)EcoreUtil.getObjectByType(resource.getContents(), SetupPackage.Literals.INDEX);
- if (index != null)
+
+ Display display = wizard.getShell().getDisplay();
+ display.asyncExec(new Runnable()
{
- Display display = wizard.getShell().getDisplay();
- display.asyncExec(new Runnable()
+ public void run()
{
- public void run()
- {
- indexLoaded(index);
+ indexLoaded(index);
- if (wizard.indexLoadedAction != null)
+ if (wizard.indexLoadedAction != null)
+ {
+ try
{
- try
- {
- wizard.indexLoadedAction.run();
- }
- catch (Exception ex)
- {
- SetupUIPlugin.INSTANCE.log(ex);
- }
+ wizard.indexLoadedAction.run();
+ }
+ catch (Exception ex)
+ {
+ SetupUIPlugin.INSTANCE.log(ex);
}
}
- });
- }
+ }
+ });
}
}
diff --git a/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/IOUtil.java b/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/IOUtil.java
index 0192a6635..6c4a91298 100644
--- a/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/IOUtil.java
+++ b/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/IOUtil.java
@@ -485,9 +485,13 @@ public final class IOUtil
{
if (file.isDirectory())
{
- for (File child : file.listFiles())
+ File[] children = file.listFiles();
+ if (children != null)
{
- deleted &= deleteBestEffort(child, deleteOnExit);
+ for (File child : children)
+ {
+ deleted &= deleteBestEffort(child, deleteOnExit);
+ }
}
}

Back to the top