import org.eclipse.core.runtime.jobs.IJobChangeEvent;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.core.runtime.jobs.JobChangeAdapter;
+import org.eclipse.equinox.internal.p2.ui.model.ElementUtils;
+import org.eclipse.equinox.internal.p2.ui.model.MetadataRepositoryElement;
import org.eclipse.equinox.p2.core.IProvisioningAgent;
import org.eclipse.equinox.p2.operations.ProvisioningJob;
import org.eclipse.equinox.p2.operations.ProvisioningSession;
import org.eclipse.equinox.p2.operations.Update;
import org.eclipse.equinox.p2.operations.UpdateOperation;
+import org.eclipse.equinox.p2.ui.ProvisioningUI;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PlatformUI;
import org.osgi.framework.BundleContext;
//private static String LOCAL_UPDATE_SITE = "file:///path/.../to/Development/EDIT/taxeditor/eu.etaxonomy.taxeditor/target/repository/";
private static String EDIT_NIGHTLY_UPDATE_SITE = "http://cybertaxonomy.eu/download/taxeditor/update/nightly/";
+ private static String EDIT_NIGHTLY_UPDATE_SITE_NAME = "Taxonomic Editor Nightly";
+
private static String EDIT_SNAPSHOT_UPDATE_SITE = "http://cybertaxonomy.eu/download/taxeditor/update/snapshot/";
+ private static String EDIT_SNAPSHOT_UPDATE_SITE_NAME = "Taxonomic Editor Snapshot";
+
private static String EDIT_STABLE_UPDATE_SITE = "http://cybertaxonomy.eu/download/taxeditor/update/stable/";
+ private static String EDIT_STABLE_UPDATE_SITE_NAME = "Taxonomic Editor Stable";
- public static void setUpdateRepositories(UpdateOperation operation) throws URISyntaxException {
+ @SuppressWarnings("restriction")
+ public static void setDefaultUpdateRepositories() {
String updateSite = EDIT_NIGHTLY_UPDATE_SITE;
+ String updateSiteName = EDIT_NIGHTLY_UPDATE_SITE_NAME;
+
if(ApplicationUtil.isStable()) {
updateSite = EDIT_STABLE_UPDATE_SITE;
+ updateSiteName = EDIT_STABLE_UPDATE_SITE_NAME;
}
- operation.getProvisioningContext().setMetadataRepositories(new URI[]{new URI(updateSite)});
- operation.getProvisioningContext().setArtifactRepositories(new URI[]{new URI(updateSite)});
- }
+ try {
+ final MetadataRepositoryElement element = new MetadataRepositoryElement(null, new URI(updateSite), true);
+ element.setNickname(updateSiteName);
+ ElementUtils.updateRepositoryUsingElements(ProvisioningUI.getDefaultUI(),new MetadataRepositoryElement[] {element}, null);
+ } catch (URISyntaxException e) {
+ MessagingUtils.errorDialog("Invalid update site URI",
+ P2Util.class,
+ "The update site URI has an invalid syntax",
+ TaxonomicEditorPlugin.PLUGIN_ID,
+ e,
+ false);
+ }
+ }
+
/**
*
*
// which installable units are being updated, use the more detailed
// constructors.
final UpdateOperation operation = new UpdateOperation(session);
- try {
- setUpdateRepositories(operation);
- } catch (URISyntaxException e) {
- MessagingUtils.errorDialog("Invalid update site URI",
- operation,
- "The update site URI has an invalid syntax",
- TaxonomicEditorPlugin.PLUGIN_ID,
- e,
- false);
- return null;
- }
+// try {
+// setUpdateRepositories(operation);
+// } catch (URISyntaxException e) {
+// MessagingUtils.errorDialog("Invalid update site URI",
+// operation,
+// "The update site URI has an invalid syntax",
+// TaxonomicEditorPlugin.PLUGIN_ID,
+// e,
+// false);
+// return null;
+// }
final IStatus status = operation.resolveModal(monitor);