summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rapicault2013-07-29 13:40:44 (EDT)
committerPascal Rapicault2013-08-27 20:31:18 (EDT)
commit3099bef679cf0c41fd6852fe58e013ea565475c9 (patch)
tree30b5649f10fee70a46430b28c6281fb55cc42e27
parentdd069d6df2f9085e7fb4197709510c0bbc6697f0 (diff)
downloadrt.equinox.p2-3099bef679cf0c41fd6852fe58e013ea565475c9.zip
rt.equinox.p2-3099bef679cf0c41fd6852fe58e013ea565475c9.tar.gz
rt.equinox.p2-3099bef679cf0c41fd6852fe58e013ea565475c9.tar.bz2
Bug - 402560,405041 Migration wizard Update to latest versions and shows only those to be migrated.
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.verifier/META-INF/MANIFEST.MF5
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.verifier/src/org/eclipse/equinox/internal/p2/tests/verifier/MigrationWizardTestHelper.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.verifier/src/org/eclipse/equinox/internal/p2/tests/verifier/VerifierApplication.java19
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/sharedinstall/NeedsMigration.java5
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/AbstractImportPage_c.java126
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/ImportFromInstallationPage_c.java437
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/MigrationPage.java (renamed from bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/AbstractPage_c.java)645
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/MigrationSupport.java19
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/MigrationWizard.java (renamed from bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/ImportFromInstallationWizard_c.java)41
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/ProvUIMessages.java24
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/messages.properties21
11 files changed, 482 insertions, 864 deletions
diff --git a/bundles/org.eclipse.equinox.p2.tests.verifier/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.tests.verifier/META-INF/MANIFEST.MF
index 5e61517..fdfd0d4 100644
--- a/bundles/org.eclipse.equinox.p2.tests.verifier/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.p2.tests.verifier/META-INF/MANIFEST.MF
@@ -8,7 +8,10 @@ Export-Package: org.eclipse.equinox.internal.p2.tests.verifier;x-internal:=true
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.equinox.p2.core,
org.eclipse.equinox.p2.ui.sdk.scheduler;bundle-version="1.2.0",
- org.eclipse.swt;bundle-version="3.102.0"
+ org.eclipse.swt;bundle-version="3.102.0",
+ org.eclipse.equinox.p2.metadata;bundle-version="2.2.0",
+ org.eclipse.equinox.p2.ui;bundle-version="2.3.0",
+ org.eclipse.equinox.p2.operations;bundle-version="2.3.0"
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Import-Package: org.eclipse.equinox.internal.p2.core.helpers,
org.eclipse.equinox.internal.p2.ui.sdk.scheduler.migration,
diff --git a/bundles/org.eclipse.equinox.p2.tests.verifier/src/org/eclipse/equinox/internal/p2/tests/verifier/MigrationWizardTestHelper.java b/bundles/org.eclipse.equinox.p2.tests.verifier/src/org/eclipse/equinox/internal/p2/tests/verifier/MigrationWizardTestHelper.java
index 49635a0..868e939 100644
--- a/bundles/org.eclipse.equinox.p2.tests.verifier/src/org/eclipse/equinox/internal/p2/tests/verifier/MigrationWizardTestHelper.java
+++ b/bundles/org.eclipse.equinox.p2.tests.verifier/src/org/eclipse/equinox/internal/p2/tests/verifier/MigrationWizardTestHelper.java
@@ -10,15 +10,17 @@
package org.eclipse.equinox.internal.p2.tests.verifier;
import java.net.URI;
+import java.util.Collection;
import org.eclipse.equinox.internal.p2.ui.sdk.scheduler.migration.MigrationSupport;
import org.eclipse.equinox.p2.engine.IProfile;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
public class MigrationWizardTestHelper extends MigrationSupport {
//Variable that keeps track if the wizard has been requested to open
public boolean wizardOpened = false;
@Override
- protected void openMigrationWizard(IProfile inputProfile, URI[] reposToMigrate) {
+ protected void openMigrationWizard(final IProfile inputProfile, final Collection<IInstallableUnit> unitsToMigrate, final URI[] reposToMigrate) {
wizardOpened = true;
}
diff --git a/bundles/org.eclipse.equinox.p2.tests.verifier/src/org/eclipse/equinox/internal/p2/tests/verifier/VerifierApplication.java b/bundles/org.eclipse.equinox.p2.tests.verifier/src/org/eclipse/equinox/internal/p2/tests/verifier/VerifierApplication.java
index da825d7..c831457 100644
--- a/bundles/org.eclipse.equinox.p2.tests.verifier/src/org/eclipse/equinox/internal/p2/tests/verifier/VerifierApplication.java
+++ b/bundles/org.eclipse.equinox.p2.tests.verifier/src/org/eclipse/equinox/internal/p2/tests/verifier/VerifierApplication.java
@@ -1,10 +1,10 @@
/*******************************************************************************
* Copyright (c) 2009, 2013 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
+ * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* Ericsson AB - Ongoing development
@@ -22,10 +22,11 @@ import org.eclipse.equinox.app.IApplication;
import org.eclipse.equinox.app.IApplicationContext;
import org.eclipse.equinox.internal.p2.core.helpers.LogHelper;
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
-import org.eclipse.equinox.internal.p2.ui.sdk.scheduler.migration.ImportFromInstallationWizard_c;
+import org.eclipse.equinox.internal.p2.ui.sdk.scheduler.migration.MigrationWizard;
import org.eclipse.equinox.p2.core.IProvisioningAgent;
import org.eclipse.equinox.p2.engine.IProfile;
import org.eclipse.equinox.p2.engine.IProfileRegistry;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.query.IQueryResult;
import org.eclipse.equinox.p2.query.QueryUtil;
import org.eclipse.osgi.framework.internal.core.Constants;
@@ -37,7 +38,7 @@ import org.osgi.service.packageadmin.PackageAdmin;
/**
* Application which verifies an install.
- *
+ *
* @since 1.0
*/
public class VerifierApplication implements IApplication {
@@ -108,7 +109,7 @@ public class VerifierApplication implements IApplication {
if (DEFAULT_PROPERTIES_FILE.exists())
properties = readProperties(DEFAULT_PROPERTIES_FILE);
} catch (IOException e) {
- // TODO
+ // TODO
e.printStackTrace();
}
}
@@ -182,7 +183,7 @@ public class VerifierApplication implements IApplication {
/*
* Check to ensure all of the bundles in the system are resolved.
- *
+ *
* Copied and modified from EclipseStarter#logUnresolvedBundles.
* This method prints out all the reasons while asking the resolver directly
* will only print out the first reason.
@@ -216,7 +217,7 @@ public class VerifierApplication implements IApplication {
constraints.add(leafConstraints[i]);
}
- // found some bundles with missing leaf constraints; log them first
+ // found some bundles with missing leaf constraints; log them first
if (missing.size() > 0) {
for (Iterator iter = missing.keySet().iterator(); iter.hasNext();) {
BundleDescription description = (BundleDescription) iter.next();
@@ -262,7 +263,7 @@ public class VerifierApplication implements IApplication {
}
/*
- * Return a boolean value indicating whether or not the given resolver error should be
+ * Return a boolean value indicating whether or not the given resolver error should be
* added to our results.
*/
private boolean shouldAdd(ResolverError error) {
@@ -342,7 +343,7 @@ public class VerifierApplication implements IApplication {
IProfileRegistry reg = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME);
IProfile profile = reg.getProfile(IProfileRegistry.SELF);
- ImportFromInstallationWizard_c wizardPage = new ImportFromInstallationWizard_c(profile, new URI[0], false);
+ MigrationWizard wizardPage = new MigrationWizard(profile, Collections.<IInstallableUnit> emptyList(), new URI[0], false);
int cancelAnswer = Integer.parseInt(properties.getProperty("checkMigration.cancelAnswer"));
wizardPage.rememberCancellationDecision(cancelAnswer);
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/sharedinstall/NeedsMigration.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/sharedinstall/NeedsMigration.java
index 9807978..bb46146 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/sharedinstall/NeedsMigration.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/sharedinstall/NeedsMigration.java
@@ -12,6 +12,7 @@ package org.eclipse.equinox.p2.tests.sharedinstall;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+import java.util.Collection;
import org.eclipse.equinox.internal.p2.ui.sdk.scheduler.migration.MigrationSupport;
import org.eclipse.equinox.p2.engine.IEngine;
import org.eclipse.equinox.p2.engine.IProfile;
@@ -50,7 +51,7 @@ public class NeedsMigration extends AbstractProvisioningTest {
engine = createEngine();
scheduler = new MigrationSupport();
createTestMetdataRepository(new IInstallableUnit[] {sdk1, sdk2, egit1, egit2, cdt1, eppPackage});
- needsMigrationMethod = scheduler.getClass().getDeclaredMethod("needsMigration", IProfile.class, IProfile.class);
+ needsMigrationMethod = scheduler.getClass().getDeclaredMethod("findUnitstoMigrate", IProfile.class, IProfile.class);
needsMigrationMethod.setAccessible(true);
}
@@ -179,7 +180,7 @@ public class NeedsMigration extends AbstractProvisioningTest {
private boolean needsMigration(IProfile previousUserProfile, IProfile currentBaseProfile) {
try {
- return (Boolean) needsMigrationMethod.invoke(scheduler, previousUserProfile, currentBaseProfile);
+ return !((Collection) needsMigrationMethod.invoke(scheduler, previousUserProfile, currentBaseProfile)).isEmpty();
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
} catch (IllegalArgumentException e) {
diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/AbstractImportPage_c.java b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/AbstractImportPage_c.java
deleted file mode 100644
index 5c9ff86..0000000
--- a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/AbstractImportPage_c.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 WindRiver Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * WindRiver Corporation - initial API and implementation
- * Ericsson AB (Pascal Rapicault) - Bug 395210
- * Ericsson AB (Hamdan Msheik) - Bug 398833
- *******************************************************************************/
-package org.eclipse.equinox.internal.p2.ui.sdk.scheduler.migration;
-
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.equinox.internal.p2.ui.ProvUI;
-import org.eclipse.equinox.internal.p2.ui.dialogs.ProvisioningOperationWizard;
-import org.eclipse.equinox.p2.engine.IProfile;
-import org.eclipse.equinox.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.p2.metadata.VersionRange;
-import org.eclipse.equinox.p2.query.IQueryResult;
-import org.eclipse.equinox.p2.query.QueryUtil;
-import org.eclipse.equinox.p2.ui.ProvisioningUI;
-import org.eclipse.jface.viewers.ICheckStateProvider;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.*;
-
-public abstract class AbstractImportPage_c extends AbstractPage_c {
-
- IProfile profile = null;
- private final ProvisioningOperationWizard wizard;
- private final ProvisioningUI ui;
-
- public AbstractImportPage_c(String pageName, ProvisioningUI ui, ProvisioningOperationWizard wizard) {
- super(pageName);
- this.wizard = wizard;
- this.ui = ui;
- profile = getSelfProfile();
- }
-
- protected ProvisioningOperationWizard getProvisioningWizard() {
- return wizard;
- }
-
- protected ProvisioningUI getProvisioningUI() {
- return ui;
- }
-
- @Override
- protected void createInstallationTable(Composite parent) {
- super.createInstallationTable(parent);
- viewer.getTree().addListener(SWT.Selection, new Listener() {
-
- public void handleEvent(Event event) {
- if (event.detail == SWT.CHECK) {
- if (hasInstalled(ProvUI.getAdapter(event.item.getData(), IInstallableUnit.class))) {
- viewer.getTree().setRedraw(false);
- ((TreeItem) event.item).setChecked(false);
- viewer.getTree().setRedraw(true);
- }
- }
- updatePageCompletion();
- }
- });
- }
-
- public boolean hasInstalled(IInstallableUnit iu) {
- IQueryResult<IInstallableUnit> results = profile.query(QueryUtil.createIUQuery(iu.getId(), new VersionRange(iu.getVersion(), true, null, false)), null);
- return !results.isEmpty();
- }
-
- public String getIUNameWithDetail(IInstallableUnit iu) {
- IQueryResult<IInstallableUnit> results = profile.query(QueryUtil.createIUQuery(iu.getId(), new VersionRange(iu.getVersion(), true, null, false)), null);
- String text = iu.getProperty(IProfile.PROP_NAME, null);
- text = (text != null) ? text : iu.getId();
- if (!results.isEmpty()) {
- boolean hasHigherVersion = false;
- boolean hasEqualVersion = false;
- for (IInstallableUnit installedIU : results.toSet()) {
- int compareValue = installedIU.getVersion().compareTo(iu.getVersion());
- if (compareValue > 0) {
- hasHigherVersion = true;
- break;
- } else if (compareValue == 0)
- hasEqualVersion = true;
- }
- if (hasHigherVersion)
- return NLS.bind(ProvUIMessages.AbstractImportPage_HigherVersionInstalled, text);
- else if (hasEqualVersion)
- return NLS.bind(ProvUIMessages.AbstractImportPage_SameVersionInstalled, text);
- }
- return text;
- }
-
- @Override
- protected ICheckStateProvider getViewerDefaultState() {
- return new ICheckStateProvider() {
-
- public boolean isGrayed(Object element) {
- return false;
- }
-
- public boolean isChecked(Object element) {
- if (profile != null) {
- IInstallableUnit iu = ProvUI.getAdapter(element, IInstallableUnit.class);
- IQueryResult<IInstallableUnit> collector = profile.query(QueryUtil.createIUQuery(iu.getId(), new VersionRange(iu.getVersion(), true, null, false)), new NullProgressMonitor());
- if (collector.isEmpty()) {
- return true;
- }
- }
- return false;
- }
- };
- }
-
- @Override
- protected void doFinish() throws Exception {
- // do nothing
- }
-
- @Override
- public boolean canFlipToNextPage() {
- return isPageComplete();
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/ImportFromInstallationPage_c.java b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/ImportFromInstallationPage_c.java
deleted file mode 100644
index b6dc568..0000000
--- a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/ImportFromInstallationPage_c.java
+++ /dev/null
@@ -1,437 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 WindRiver Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * WindRiver Corporation - initial API and implementation
- * Ericsson AB (Pascal Rapicault) - Bug 387115 - Allow to export everything
- * Ericsson AB (Hamdan Msheik) - Bug 398833
- *******************************************************************************/
-package org.eclipse.equinox.internal.p2.ui.sdk.scheduler.migration;
-
-import java.net.URI;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.equinox.internal.p2.ui.ProvUI;
-import org.eclipse.equinox.internal.p2.ui.dialogs.ISelectableIUsPage;
-import org.eclipse.equinox.internal.p2.ui.dialogs.ProvisioningOperationWizard;
-import org.eclipse.equinox.internal.p2.ui.model.ProfileElement;
-import org.eclipse.equinox.internal.p2.ui.viewers.IUDetailsLabelProvider;
-import org.eclipse.equinox.p2.core.IProvisioningAgent;
-import org.eclipse.equinox.p2.engine.IProfile;
-import org.eclipse.equinox.p2.engine.ProvisioningContext;
-import org.eclipse.equinox.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager;
-import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
-import org.eclipse.equinox.p2.ui.ProvisioningUI;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-
-public class ImportFromInstallationPage_c extends AbstractImportPage_c implements ISelectableIUsPage {
-
- protected IProvisioningAgent otherInstanceAgent = null;
- private IProfile toBeImportedProfile = null;
- // private File instancePath = null;
- private URI[] metaURIs = null;
- private URI[] artiURIs = null;
-
- // private IProvisioningAgentProvider agentProvider;
-
- public ImportFromInstallationPage_c(ProvisioningUI ui, ProvisioningOperationWizard wizard, boolean firstTime) {
- super("importfrominstancepage", ui, wizard); //$NON-NLS-1$
- setTitle(firstTime ? ProvUIMessages.ImportFromInstallationPage_DIALOG_TITLE_FIRSTRUN : ProvUIMessages.ImportFromInstallationPage_DIALOG_TITLE);
- setDescription(NLS.bind(ProvUIMessages.ImportFromInstallationPage_DIALOG_DESCRIPTION, Platform.getProduct().getName()));
- }
-
- public ImportFromInstallationPage_c(ProvisioningUI ui, ImportFromInstallationWizard_c wizard, IProfile toImportFrom, boolean firstTime) {
- super("importfrominstancepage", ui, wizard); //$NON-NLS-1$
- setTitle(firstTime ? ProvUIMessages.ImportFromInstallationPage_DIALOG_TITLE_FIRSTRUN : ProvUIMessages.ImportFromInstallationPage_DIALOG_TITLE);
- setDescription(NLS.bind(firstTime ? ProvUIMessages.ImportFromInstallationPage_DIALOG_DESCRIPTION_FIRSTRUN : ProvUIMessages.ImportFromInstallationPage_DIALOG_DESCRIPTION, Platform.getProduct().getName()));
- toBeImportedProfile = toImportFrom;
- }
-
- @Override
- protected void createContents(Composite composite) {
- createInstallationTable(composite);
- }
-
- // private void showProfile() {
- //
- // //TODO remove already installed installable units from the profile to be imported
- // IQueryResult<IInstallableUnit> result = profile.available(null, null);
- // Profile p1 = (Profile) profile;
- // while (iterator)
- // for (IInstallableUnit unit : result.iterator()) {
- //
- // }
- // final ProfileElement element = new ProfileElement(null, toBeImportedProfile.getProfileId()) {
- // @Override
- // public org.eclipse.equinox.p2.query.IQueryable<?> getQueryable() {
- // return toBeImportedProfile;
- // }
- // };
- // element.setQueryable(toBeImportedProfile);
- //
- // viewer.setInput(element);
- // updatePageCompletion();
- // }
-
- // @Override
- // protected String getDestinationLabel() {
- // return Messages.ImportFromInstallationPage_DESTINATION_LABEL;
- // }
-
- @Override
- protected String getDialogTitle() {
- return ProvUIMessages.ImportFromInstallationPage_DIALOG_TITLE;
- }
-
- @Override
- protected Object getInput() {
-
- Object input = null;
-
- if (toBeImportedProfile != null) {
- final ProfileElement element = new ProfileElement(null, toBeImportedProfile.getProfileId()) {
- @Override
- public org.eclipse.equinox.p2.query.IQueryable<?> getQueryable() {
- return toBeImportedProfile;
- }
- };
- element.setQueryable(toBeImportedProfile);
- input = element;
- } else {
- input = new IInstallableUnit[0];
- }
-
- return input;
- }
-
- @Override
- protected String getInvalidDestinationMessage() {
- return "";//ProvUIMessages.ImportFromInstallationPage_INVALID_DESTINATION; //$NON-NLS-1$
- }
-
- @Override
- protected String getNoOptionsMessage() {
- return ProvUIMessages.ImportFromInstallationPage_SELECT_COMPONENT;
- }
-
- // @Override
- // protected boolean validateDestinationGroup() {
- // return validateDestinationGroup(new NullProgressMonitor());
- // }
-
- // private IProvisioningAgentProvider getAgentProvider() {
- // if (agentProvider == null) {
- // ServiceTracker<IProvisioningAgentProvider, IProvisioningAgentProvider> tracker = new ServiceTracker<IProvisioningAgentProvider, IProvisioningAgentProvider>(Platform.getBundle(Constants.Bundle_ID).getBundleContext(), IProvisioningAgentProvider.class, null);
- // tracker.open();
- // agentProvider = tracker.getService();
- // tracker.close();
- // }
- // return agentProvider;
- // }
-
- // boolean validateDestinationGroup(IProgressMonitor monitor) {
- // SubMonitor progress = SubMonitor.convert(monitor, 100);
- //
- // boolean rt;
- // if (Display.findDisplay(Thread.currentThread()) == null) {
- // Callable<Boolean> getSuperValidateDest = new Callable<Boolean>() {
- // Boolean validated;
- //
- // public Boolean call() throws Exception {
- // Display.getDefault().syncExec(new Runnable() {
- // public void run() {
- // validated = ImportFromInstallationPage_c.super.validateDestinationGroup();
- // }
- // });
- // return validated;
- // }
- // };
- // ExecutorService executor = Executors.newSingleThreadScheduledExecutor();
- // Future<Boolean> getSuperDestTask = executor.submit(getSuperValidateDest);
- //
- // try {
- // rt = getSuperDestTask.get().booleanValue();
- // } catch (Exception e) {
- // return false;
- // } finally {
- // executor.shutdown();
- // }
- // } else
- // rt = super.validateDestinationGroup();
- //
- // if (rt) {
- // try {
- // String destination;
- // if (Display.findDisplay(Thread.currentThread()) == null) {
- // Callable<String> getDestinationValue = new Callable<String>() {
- // String des;
- //
- // public String call() throws Exception {
- // if (Display.findDisplay(Thread.currentThread()) == null) {
- // Display.getDefault().syncExec(new Runnable() {
- // public void run() {
- // des = getDestinationValue();
- // }
- // });
- // } else
- // des = getDestinationValue();
- // return des;
- // }
- // };
- // ExecutorService executor = Executors.newSingleThreadScheduledExecutor();
- // Future<String> getDestTask = executor.submit(getDestinationValue);
- // try {
- // destination = getDestTask.get();
- // } finally {
- // executor.shutdown();
- // }
- // } else
- // destination = getDestinationValue();
- //
- // String toBeImportedProfileId = null;
- // try {
- // File config = new File(destination, "configuration/config.ini"); //$NON-NLS-1$
- // URI configArea = config.getParentFile().toURI();
- // InputStream is = null;
- // // default area
- // File p2DataArea = new File(destination, "p2"); //$NON-NLS-1$
- // try {
- // Properties props = new Properties();
- // is = new FileInputStream(config);
- // props.load(is);
- // toBeImportedProfileId = props.getProperty("eclipse.p2.profile"); //$NON-NLS-1$
- // String url = props.getProperty("eclipse.p2.data.area"); //$NON-NLS-1$
- // if (url != null) {
- // final String CONFIG_DIR = "@config.dir/"; //$NON-NLS-1$
- // final String FILE_PROTOCOL = "file:"; //$NON-NLS-1$
- // if (url.startsWith(CONFIG_DIR))
- // url = FILE_PROTOCOL + url.substring(CONFIG_DIR.length());
- // p2DataArea = new File(URIUtil.makeAbsolute(URIUtil.fromString(new File(url.substring(FILE_PROTOCOL.length())).isAbsolute() ? url : url.substring(FILE_PROTOCOL.length())), configArea));
- // }
- // } catch (IOException ioe) {
- // //ignore
- // } finally {
- // try {
- // is.close();
- // } catch (IOException ioe) {
- // //ignore
- // }
- // is = null;
- // }
- // if (p2DataArea.exists()) {
- // boolean createAgent = true;
- // if (otherInstanceAgent != null) {
- // // don't create agent again if the selection is not changed
- // if (!p2DataArea.equals(instancePath)) {
- // otherInstanceAgent.stop();
- // otherInstanceAgent = null;
- // // update cached specified path by users
- // instancePath = p2DataArea;
- // cleanLocalRepository();
- // } else
- // createAgent = false;
- // }
- // if (createAgent)
- // otherInstanceAgent = getAgentProvider().createAgent(p2DataArea.toURI());
- // ArtifactRepositoryFactory factory = new ExtensionLocationArtifactRepositoryFactory();
- // factory.setAgent(agent);
- // IArtifactRepository artiRepo = factory.load(new File(destination).toURI(), 0, progress.newChild(50));
- // artiURIs = new URI[] {artiRepo.getLocation()};
- // MetadataRepositoryFactory metaFatory = new ExtensionLocationMetadataRepositoryFactory();
- // metaFatory.setAgent(agent);
- // IMetadataRepository metaRepo = metaFatory.load(new File(destination).toURI(), 0, progress.newChild(50));
- // metaURIs = new URI[] {metaRepo.getLocation()};
- //
- // } else
- // throw new FileNotFoundException();
- // } catch (ProvisionException e) {
- // if (otherInstanceAgent != null) {
- // toBeImportedProfile = null;
- // IMetadataRepositoryManager manager = (IMetadataRepositoryManager) agent.getService(IMetadataRepositoryManager.SERVICE_NAME);
- // IArtifactRepositoryManager artifactManager = (IArtifactRepositoryManager) agent.getService(IArtifactRepositoryManager.SERVICE_NAME);
- // IProfileRegistry registry = (IProfileRegistry) otherInstanceAgent.getService(IProfileRegistry.SERVICE_NAME);
- // if (toBeImportedProfileId != null)
- // toBeImportedProfile = registry.getProfile(toBeImportedProfileId);
- // if (toBeImportedProfile == null) {
- // IProfile[] existingProfiles = registry.getProfiles();
- // if (existingProfiles.length == 1) {
- // toBeImportedProfile = existingProfiles[0];
- // } else {
- // for (IProfile existingProfile : existingProfiles) {
- // if (toBeImportedProfile == null)
- // toBeImportedProfile = existingProfile;
- // else if ((toBeImportedProfile.getTimestamp() < existingProfile.getTimestamp())) // assuming last modified one is we are looking for
- // toBeImportedProfile = existingProfile;
- // }
- // }
- // }
- // IAgentLocation location = (IAgentLocation) otherInstanceAgent.getService(IAgentLocation.SERVICE_NAME);
- // URI engineDataArea = location.getDataArea("org.eclipse.equinox.p2.engine"); //$NON-NLS-1$
- // progress.setWorkRemaining(50);
- // IMetadataRepository metaRepo = manager.loadRepository(engineDataArea.resolve("profileRegistry/" + toBeImportedProfile.getProfileId() + ".profile"), progress.newChild(25)); //$NON-NLS-1$//$NON-NLS-2$
- // metaURIs = new URI[] {metaRepo.getLocation()};
- // IArtifactRepository artiRepo = artifactManager.loadRepository(new File(destination).toURI(), progress.newChild(25));
- // artiURIs = new URI[] {artiRepo.getLocation()};
- // } else
- // throw new Exception();
- // }
- // } catch (Exception e) {
- // Display.getDefault().asyncExec(new Runnable() {
- // public void run() {
- // setErrorMessage(getInvalidDestinationMessage());
- // }
- // });
- // rt = false;
- // if (otherInstanceAgent != null)
- // otherInstanceAgent.stop();
- // otherInstanceAgent = null;
- // toBeImportedProfile = null;
- // cleanLocalRepository();
- // } finally {
- // monitor.done();
- // }
- // }
- // return rt;
- // }
-
- // @Override
- // protected void giveFocusToDestination() {
- // destinationBrowseButton.setFocus();
- // }
-
- // @Override
- // protected void handleDestinationBrowseButtonPressed() {
- // DirectoryDialog dialog = new DirectoryDialog(getContainer().getShell());
- // dialog.setText(getDialogTitle());
- // dialog.setFilterPath(getDestinationValue());
- // final String selectedFileName = dialog.open();
- //
- // if (selectedFileName != null) {
- // setDestinationValue(selectedFileName);
- // handleDestinationChanged(selectedFileName);
- // }
- // }
-
- // @Override
- // protected void handleDestinationChanged(String newDestination) {
- // try {
- // getContainer().run(true, false, new IRunnableWithProgress() {
- //
- // public void run(IProgressMonitor monitor) {
- // Object input = null;
- // if (validateDestinationGroup(monitor)) {
- // final IProfile currentProfile = toBeImportedProfile;
- // final ProfileElement element = new ProfileElement(null, currentProfile.getProfileId()) {
- // @Override
- // public org.eclipse.equinox.p2.query.IQueryable<?> getQueryable() {
- // return currentProfile;
- // }
- // };
- // element.setQueryable(currentProfile);
- // input = element;
- //
- // }
- // final Object viewerInput = input;
- // Display.getDefault().asyncExec(new Runnable() {
- //
- // public void run() {
- // viewer.setInput(viewerInput);
- // updatePageCompletion();
- // }
- // });
- // }
- // });
- // } catch (InvocationTargetException e) {
- // setErrorMessage(e.getLocalizedMessage());
- // setPageComplete(false);
- // } catch (InterruptedException e) {
- // // won't happen
- // }
- // }
-
- // @Override
- // protected boolean validDestination() {
- // if (this.destinationNameField == null)
- // return true;
- // File file = new File(getDestinationValue());
- // return file.exists() && file.isDirectory();
- // }
-
- class ImportFromInstallationLabelProvider extends IUDetailsLabelProvider {
- @Override
- public String getColumnText(Object element, int columnIndex) {
- String text = super.getColumnText(element, columnIndex);
- // it's the order of label provider
- if (columnIndex == 0) {
- IInstallableUnit iu = ProvUI.getAdapter(element, IInstallableUnit.class);
- return getIUNameWithDetail(iu);
- }
- return text;
- }
-
- @Override
- public Color getForeground(Object element) {
- IInstallableUnit iu = ProvUI.getAdapter(element, IInstallableUnit.class);
- if (hasInstalled(iu))
- return Display.getDefault().getSystemColor(SWT.COLOR_GRAY);
- return super.getForeground(element);
- }
- }
-
- @Override
- protected ITableLabelProvider getLabelProvider() {
- return new ImportFromInstallationLabelProvider();
- }
-
- @Override
- public void dispose() {
- super.dispose();
- if (otherInstanceAgent != null) {
- otherInstanceAgent.stop();
- otherInstanceAgent = null;
- toBeImportedProfile = null;
- }
- cleanLocalRepository();
- }
-
- public void cleanLocalRepository() {
- if (metaURIs != null && metaURIs.length > 0) {
- IProvisioningAgent runningAgent = getProvisioningUI().getSession().getProvisioningAgent();
- IMetadataRepositoryManager manager = (IMetadataRepositoryManager) runningAgent.getService(IMetadataRepositoryManager.SERVICE_NAME);
- for (URI uri : metaURIs)
- manager.removeRepository(uri);
- IArtifactRepositoryManager artifactManager = (IArtifactRepositoryManager) runningAgent.getService(IArtifactRepositoryManager.SERVICE_NAME);
- for (URI uri : artiURIs)
- artifactManager.removeRepository(uri);
- }
- }
-
- public Object[] getCheckedIUElements() {
- return viewer.getCheckedElements();
- }
-
- public Object[] getSelectedIUElements() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public void setCheckedElements(Object[] elements) {
- new UnsupportedOperationException();
- }
-
- public ProvisioningContext getProvisioningContext() {
- ProvisioningContext context = new ProvisioningContext(getProvisioningUI().getSession().getProvisioningAgent());
- context.setArtifactRepositories(artiURIs);
- context.setMetadataRepositories(metaURIs);
- return context;
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/AbstractPage_c.java b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/MigrationPage.java
index 72a4350..9a135a4 100644
--- a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/AbstractPage_c.java
+++ b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/MigrationPage.java
@@ -9,41 +9,52 @@
* WindRiver Corporation - initial API and implementation
* IBM Corporation - Ongoing development
* Ericsson AB (Pascal Rapicault) - Bug 387115 - Allow to export everything
- * Ericsson AB (Hamdan Msheik) - Bug 398833
+ * Ericsson AB (Hamdan Msheik) - Bug 398833, 402560
*******************************************************************************/
package org.eclipse.equinox.internal.p2.ui.sdk.scheduler.migration;
+import java.lang.reflect.InvocationTargetException;
+import java.net.URI;
import java.util.*;
-import org.eclipse.core.runtime.Platform;
+import java.util.List;
+import org.eclipse.core.runtime.*;
import org.eclipse.core.runtime.jobs.IJobChangeEvent;
import org.eclipse.core.runtime.jobs.JobChangeAdapter;
+import org.eclipse.core.runtime.preferences.*;
+import org.eclipse.equinox.internal.p2.metadata.query.UpdateQuery;
import org.eclipse.equinox.internal.p2.ui.ProvUI;
import org.eclipse.equinox.internal.p2.ui.ProvUIActivator;
import org.eclipse.equinox.internal.p2.ui.dialogs.*;
-import org.eclipse.equinox.internal.p2.ui.model.InstalledIUElement;
+import org.eclipse.equinox.internal.p2.ui.model.*;
+import org.eclipse.equinox.internal.p2.ui.sdk.scheduler.AutomaticUpdatePlugin;
import org.eclipse.equinox.internal.p2.ui.viewers.*;
import org.eclipse.equinox.p2.core.IProvisioningAgent;
-import org.eclipse.equinox.p2.engine.IProfile;
-import org.eclipse.equinox.p2.engine.IProfileRegistry;
+import org.eclipse.equinox.p2.engine.*;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.metadata.VersionRange;
+import org.eclipse.equinox.p2.query.*;
+import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
+import org.eclipse.equinox.p2.ui.ProvisioningUI;
import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.*;
import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.*;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.graphics.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.ui.dialogs.FilteredTree;
import org.eclipse.ui.dialogs.PatternFilter;
import org.eclipse.ui.progress.DeferredTreeContentManager;
import org.eclipse.ui.progress.WorkbenchJob;
+import org.eclipse.ui.statushandlers.StatusManager;
import org.osgi.framework.BundleContext;
import org.osgi.util.tracker.ServiceTracker;
-public abstract class AbstractPage_c extends WizardPage implements Listener {
+public class MigrationPage extends WizardPage implements ISelectableIUsPage, Listener {
protected String currentMessage;
// protected Button destinationBrowseButton;
@@ -52,12 +63,21 @@ public abstract class AbstractPage_c extends WizardPage implements Listener {
protected boolean entryChanged = false;
protected static IProfileRegistry profileRegistry = null;
static IProvisioningAgent agent = null;
+ protected Button updateToLatest;
public static final String REMIND_ME_LATER = "remindMeToMigrateLater";
- // dialog store id constants
- // private static final String STORE_DESTINATION_NAMES_ID = "P2ImportExportPage.STORE_DESTINATION_NAMES_ID";//$NON-NLS-1$
- protected static final int COMBO_HISTORY_LENGTH = 5;
+ IProfile profile = null;
+
+ private ProvisioningOperationWizard wizard;
+ private ProvisioningUI ui;
+
+ protected IProvisioningAgent otherInstanceAgent = null;
+ private Collection<IInstallableUnit> unitsToMigrate;
+ private IProfile toImportFrom = null;
+ // private File instancePath = null;
+ private URI[] metaURIs = null;
+ private URI[] artiURIs = null;
/**
* {@link DelayedFilterCheckboxTree} has a timing bug to prevent restoring the check state,
@@ -210,12 +230,27 @@ public abstract class AbstractPage_c extends WizardPage implements Listener {
profileRegistry = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME);
}
- public AbstractPage_c(String pageName) {
+ public MigrationPage(String pageName) {
super(pageName);
}
- public AbstractPage_c(String pageName, String title, ImageDescriptor titleImage) {
- super(pageName, title, titleImage);
+ public MigrationPage(ProvisioningUI ui, ProvisioningOperationWizard wizard, IProfile toImportFrom, Collection<IInstallableUnit> unitsToMigrate, boolean firstTime) {
+ super("MigrationPageInstace"); //$NON-NLS-1$
+ this.wizard = wizard;
+ this.ui = ui;
+ profile = getSelfProfile();
+ this.toImportFrom = toImportFrom;
+ this.unitsToMigrate = unitsToMigrate;
+ setTitle(firstTime ? ProvUIMessages.MigrationPage_DIALOG_TITLE_FIRSTRUN : ProvUIMessages.MigrationPage_DIALOG_TITLE);
+ setDescription(NLS.bind(ProvUIMessages.MigrationPage_DIALOG_DESCRIPTION, Platform.getProduct().getName()));
+ }
+
+ public MigrationPage(ProvisioningUI ui, ProvisioningOperationWizard wizard, boolean firstTime) {
+ super("importfrominstancepage"); //$NON-NLS-1$
+ this.wizard = wizard;
+ this.ui = ui;
+ setTitle(firstTime ? ProvUIMessages.MigrationPage_DIALOG_TITLE_FIRSTRUN : ProvUIMessages.MigrationPage_DIALOG_TITLE);
+ setDescription(NLS.bind(ProvUIMessages.MigrationPage_DIALOG_DESCRIPTION, Platform.getProduct().getName()));
}
protected IProfile getSelfProfile() {
@@ -259,8 +294,6 @@ public abstract class AbstractPage_c extends WizardPage implements Listener {
viewer.refresh(false);
}
- protected abstract void createContents(Composite composite);
-
public void createControl(Composite parent) {
initializeDialogUnits(parent);
// initializeService();
@@ -284,86 +317,6 @@ public abstract class AbstractPage_c extends WizardPage implements Listener {
Dialog.applyDialogFont(composite);
}
- // protected void createDestinationGroup(Composite parent, boolean includeButton) {
- // Composite composite = new Composite(parent, SWT.BORDER);
- // GridLayout layout = new GridLayout();
- // layout.numColumns = 3;
- // composite.setLayout(layout);
- // composite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
- //
- // Label label = new Label(composite, SWT.NONE);
- // label.setText(getDestinationLabel());
- //
- // destinationNameField = new Combo(composite, SWT.SINGLE | SWT.BORDER);
- // restoreWidgetValues();
- // GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL);
- // destinationNameField.setLayoutData(data);
- // destinationNameField.addSelectionListener(new SelectionAdapter() {
- // public void widgetSelected(SelectionEvent e) {
- // handleDestinationChanged(getDestinationValue());
- // }
- // });
- // destinationNameField.addKeyListener(new KeyListener() {
- //
- // /*
- // * @see KeyListener.keyPressed
- // */
- // public void keyPressed(KeyEvent e) {
- // if (e.character == SWT.CR) {
- // entryChanged = false;
- // handleDestinationChanged(getDestinationValue());
- // }
- // }
- //
- // public void keyReleased(KeyEvent e) {
- // // do nothing
- // }
- // });
- // destinationNameField.addModifyListener(new ModifyListener() {
- // public void modifyText(ModifyEvent e) {
- // entryChanged = true;
- // }
- // });
- // destinationNameField.addFocusListener(new FocusListener() {
- // /*
- // * @see FocusListener.focusGained(FocusEvent)
- // */
- // public void focusGained(FocusEvent e) {
- // //Do nothing when getting focus
- // }
- //
- // /*
- // * @see FocusListener.focusLost(FocusEvent)
- // */
- // public void focusLost(FocusEvent e) {
- // //Clear the flag to prevent constant update
- // if (entryChanged) {
- // entryChanged = false;
- // handleDestinationChanged(getDestinationValue());
- // }
- //
- // }
- // });
- //
- // destinationBrowseButton = new Button(composite, SWT.PUSH);
- // destinationBrowseButton.setText(Messages.Page_BUTTON_BROWSER);
- // destinationBrowseButton.addListener(SWT.Selection, this);
- // destinationBrowseButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
- //
- // if (includeButton) {
- // includeAllButton = new Button(composite, SWT.CHECK);
- // includeAllButton.setText(Messages.ExportPage_EntriesNotInRepo);
- // includeAllButton.setSelection(allowExportWithoutRepositoryReference());
- // GridData dataIncludeButton = new GridData();
- // dataIncludeButton.horizontalSpan = 3;
- // includeAllButton.setLayoutData(dataIncludeButton);
- // }
- // }
- //
- // private boolean allowExportWithoutRepositoryReference() {
- // return Platform.getPreferencesService().getBoolean(Constants.Bundle_ID, Constants.PREF_IU_WITHOUT_REPO, false, new IScopeContext[] {DefaultScope.INSTANCE});
- // }
-
protected IUColumnConfig[] getColumnConfig() {
return new IUColumnConfig[] {new IUColumnConfig(org.eclipse.equinox.internal.p2.ui.ProvUIMessages.ProvUI_NameColumnTitle, IUColumnConfig.COLUMN_NAME, ILayoutConstants.DEFAULT_PRIMARY_COLUMN_WIDTH), new IUColumnConfig(org.eclipse.equinox.internal.p2.ui.ProvUIMessages.ProvUI_VersionColumnTitle, IUColumnConfig.COLUMN_VERSION, ILayoutConstants.DEFAULT_SMALL_COLUMN_WIDTH), new IUColumnConfig(org.eclipse.equinox.internal.p2.ui.ProvUIMessages.ProvUI_IdColumnTitle, IUColumnConfig.COLUMN_ID, ILayoutConstants.DEFAULT_COLUMN_WIDTH)};
}
@@ -476,6 +429,21 @@ public abstract class AbstractPage_c extends WizardPage implements Listener {
viewer.getControl().setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
viewer.getControl().setSize(300, 200);
viewer.setInput(getInput());
+
+ viewer.getTree().addListener(SWT.Selection, new Listener() {
+
+ public void handleEvent(Event event) {
+ if (event.detail == SWT.CHECK) {
+ if (hasInstalled(ProvUI.getAdapter(event.item.getData(), IInstallableUnit.class))) {
+ viewer.getTree().setRedraw(false);
+ ((TreeItem) event.item).setChecked(false);
+ viewer.getTree().setRedraw(true);
+ }
+ }
+ updatePageCompletion();
+ }
+ });
+
Composite buttons = new Composite(group, SWT.NONE);
buttons.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
buttons.setLayout(new RowLayout(SWT.HORIZONTAL));
@@ -509,6 +477,21 @@ public abstract class AbstractPage_c extends WizardPage implements Listener {
updatePageCompletion();
}
});
+
+ }
+
+ protected void createAdditionOptions(Composite parent) {
+
+ Composite composite = new Composite(parent, SWT.BORDER);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 1;
+ composite.setLayout(layout);
+ composite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
+
+ updateToLatest = new Button(composite, SWT.CHECK);
+ updateToLatest.setText(ProvUIMessages.MigrationPage_UPDATE_TO_LATEST);
+ updateToLatest.setSelection(loadCustomizedSetting());
+
}
protected PatternFilter getPatternFilter() {
@@ -516,13 +499,29 @@ public abstract class AbstractPage_c extends WizardPage implements Listener {
}
protected ICheckStateProvider getViewerDefaultState() {
- return null;
- }
+ return new ICheckStateProvider() {
- protected ITableLabelProvider getLabelProvider() {
- return new IUDetailsLabelProvider(null, getColumnConfig(), null);
+ public boolean isGrayed(Object element) {
+ return false;
+ }
+
+ public boolean isChecked(Object element) {
+ if (profile != null) {
+ IInstallableUnit iu = ProvUI.getAdapter(element, IInstallableUnit.class);
+ IQueryResult<IInstallableUnit> collector = profile.query(QueryUtil.createIUQuery(iu.getId(), new VersionRange(iu.getVersion(), true, null, false)), new NullProgressMonitor());
+ if (collector.isEmpty()) {
+ return true;
+ }
+ }
+ return false;
+ }
+ };
}
+ // protected ITableLabelProvider getLabelProvider() {
+ // return new IUDetailsLabelProvider(null, getColumnConfig(), null);
+ // }
+
protected ITreeContentProvider getContentProvider() {
ProvElementContentProvider provider = new ProvElementContentProvider() {
@Override
@@ -558,63 +557,10 @@ public abstract class AbstractPage_c extends WizardPage implements Listener {
return complete;
}
- protected abstract void doFinish() throws Exception;
-
protected int getBrowseDialogStyle() {
return SWT.OPEN;
}
- // /**
- // * returns the destination label
- // * @return non null string
- // */
- // protected abstract String getDestinationLabel();
-
- // /**
- // * Answer the contents of self's destination specification widget
- // *
- // * @return java.lang.String
- // */
- // protected String getDestinationValue() {
- // return destinationNameField.getText().trim();
- // }
-
- /**
- * return the title of dialog
- * @return non null string
- */
- protected abstract String getDialogTitle();
-
- protected abstract Object getInput();
-
- protected abstract String getInvalidDestinationMessage();
-
- protected String getNoOptionsMessage() {
- return ProvUIMessages.PAGE_NOINSTALLTION_ERROR;
- }
-
- // protected abstract void giveFocusToDestination();
-
- // /**
- // * Open an appropriate destination browser so that the user can specify a
- // * source to import from
- // */
- // protected void handleDestinationBrowseButtonPressed() {
- // FileDialog dialog = new FileDialog(getContainer().getShell(), getBrowseDialogStyle() | SWT.SHEET);
- // dialog.setText(getDialogTitle());
- // dialog.setFilterPath(getDestinationValue());
- // dialog.setFilterExtensions(new String[] {Messages.EXTENSION_p2F, Messages.EXTENSION_ALL});
- // dialog.setFilterNames(new String[] {Messages.EXTENSION_p2F_NAME, Messages.EXTENSION_ALL_NAME});
- // String selectedFileName = dialog.open();
- //
- // if (selectedFileName != null) {
- // if (!selectedFileName.endsWith(Messages.EXTENSION_p2F.substring(1)))
- // selectedFileName += Messages.EXTENSION_p2F.substring(1);
- // setDestinationValue(selectedFileName);
- // handleDestinationChanged(selectedFileName);
- // }
- // }
-
//TODO remove the implementation of Listener
public void handleEvent(Event event) {
// Widget source = event.widget;
@@ -625,21 +571,6 @@ public abstract class AbstractPage_c extends WizardPage implements Listener {
// updatePageCompletion();
}
- // protected void handleDestinationChanged(String newDestination) {
- // // do nothing
- // }
-
- // protected void initializeService() {
- // ServiceTracker<P2ImportExport, P2ImportExport> tracker = new ServiceTracker<P2ImportExport, P2ImportExport>(Platform.getBundle(Constants.Bundle_ID).getBundleContext(), P2ImportExport.class.getName(), null);
- // tracker.open();
- // importexportService = tracker.getService();
- // tracker.close();
- // }
-
- // protected void setDestinationValue(String selectedFileName) {
- // destinationNameField.setText(selectedFileName);
- // }
-
/**
* Determine if the page is complete and update the page appropriately.
*/
@@ -653,20 +584,6 @@ public abstract class AbstractPage_c extends WizardPage implements Listener {
}
}
- // /**
- // * Validate the destination group.
- // * @return <code>true</code> if the group is valid. If
- // * not set the error message and return <code>false</code>.
- // */
- // protected boolean validateDestinationGroup() {
- // if (!validDestination()) {
- // currentMessage = getInvalidDestinationMessage();
- // return false;
- // }
- //
- // return true;
- // }
-
protected boolean validateOptionsGroup() {
if (viewer == null || viewer.getCheckedElements().length > 0)
return true;
@@ -675,74 +592,304 @@ public abstract class AbstractPage_c extends WizardPage implements Listener {
return false;
}
- // protected boolean validDestination() {
- // if (this.destinationNameField == null)
- // return true;
- // File file = new File(getDestinationValue());
- // return !(file.getPath().length() <= 0 || file.isDirectory());
- // }
+ protected ProvisioningOperationWizard getProvisioningWizard() {
+ return wizard;
+ }
- // protected void saveWidgetValues() {
- // IDialogSettings settings = getDialogSettings();
- // if (settings != null) {
- // String[] directoryNames = settings.getArray(STORE_DESTINATION_NAMES_ID);
- // if (directoryNames == null) {
- // directoryNames = new String[0];
- // }
- //
- // directoryNames = addToHistory(directoryNames, getDestinationValue());
- // settings.put(STORE_DESTINATION_NAMES_ID, directoryNames);
- // }
- // }
+ protected ProvisioningUI getProvisioningUI() {
+ return ui;
+ }
- // protected String[] addToHistory(String[] history, String newEntry) {
- // List<String> l = new ArrayList<String>(Arrays.asList(history));
- // addToHistory(l, newEntry);
- // String[] r = new String[l.size()];
- // l.toArray(r);
- // return r;
- // }
- //
- // protected void addToHistory(List<String> history, String newEntry) {
- // history.remove(newEntry);
- // history.add(0, newEntry);
- //
- // // since only one new item was added, we can be over the limit
- // // by at most one item
- // if (history.size() > COMBO_HISTORY_LENGTH) {
- // history.remove(COMBO_HISTORY_LENGTH);
- // }
- // }
+ public boolean hasInstalled(IInstallableUnit iu) {
+ IQueryResult<IInstallableUnit> results = profile.query(QueryUtil.createIUQuery(iu.getId(), new VersionRange(iu.getVersion(), true, null, false)), null);
+ return !results.isEmpty();
+ }
- // /**
- // * Hook method for restoring widget values to the values that they held last
- // * time this wizard was used to completion.
- // */
- // protected void restoreWidgetValues() {
- //
- // IDialogSettings settings = getDialogSettings();
- //
- // if (settings != null) {
- // String[] directoryNames = settings.getArray(STORE_DESTINATION_NAMES_ID);
- // if (directoryNames != null) {
- // // destination
- // setDestinationValue(directoryNames[0]);
- // for (int i = 0; i < directoryNames.length; i++) {
- // addDestinationItem(directoryNames[i]);
- // }
- //
- // setDestinationValue(""); //$NON-NLS-1$
- // }
- // }
- // }
+ public String getIUNameWithDetail(IInstallableUnit iu) {
+ IQueryResult<IInstallableUnit> results = profile.query(QueryUtil.createIUQuery(iu.getId(), new VersionRange(iu.getVersion(), true, null, false)), null);
+ String text = iu.getProperty(IProfile.PROP_NAME, null);
+ text = (text != null) ? text : iu.getId();
+ if (!results.isEmpty()) {
+ boolean hasHigherVersion = false;
+ boolean hasEqualVersion = false;
+ for (IInstallableUnit installedIU : results.toSet()) {
+ int compareValue = installedIU.getVersion().compareTo(iu.getVersion());
+ if (compareValue > 0) {
+ hasHigherVersion = true;
+ break;
+ } else if (compareValue == 0)
+ hasEqualVersion = true;
+ }
+ if (hasHigherVersion)
+ return NLS.bind(ProvUIMessages.AbstractImportPage_HigherVersionInstalled, text);
+ else if (hasEqualVersion)
+ return NLS.bind(ProvUIMessages.AbstractImportPage_SameVersionInstalled, text);
+ }
+ return text;
+ }
- // /**
- // * Add the passed value to self's destination widget's history
- // *
- // * @param value
- // * java.lang.String
- // */
- // protected void addDestinationItem(String value) {
- // destinationNameField.add(value);
- // }
+ protected void doFinish() throws Exception {
+ // do nothing
+ }
+
+ @Override
+ public boolean canFlipToNextPage() {
+ return isPageComplete();
+ }
+
+ protected void createContents(Composite composite) {
+ createInstallationTable(composite);
+ createAdditionOptions(composite);
+ }
+
+ protected String getDialogTitle() {
+ return ProvUIMessages.MigrationPage_DIALOG_TITLE;
+ }
+
+ protected Object getInput() {
+
+ IUElementListRoot root = new IUElementListRoot();
+ List<AvailableIUElement> elements = new ArrayList<AvailableIUElement>(unitsToMigrate.size());
+ for (IInstallableUnit unit : unitsToMigrate) {
+ elements.add(new AvailableIUElement(root, unit, toImportFrom.getProfileId(), false));
+ }
+ root.setChildren(elements.toArray());
+ return root;
+ }
+
+ protected String getInvalidDestinationMessage() {
+ return "";//ProvUIMessages.ImportFromInstallationPage_INVALID_DESTINATION; //$NON-NLS-1$
+ }
+
+ protected String getNoOptionsMessage() {
+ return ProvUIMessages.MigrationPage_SELECT_COMPONENT;
+ }
+
+ class ImportFromInstallationLabelProvider extends IUDetailsLabelProvider {
+ @Override
+ public String getColumnText(Object element, int columnIndex) {
+ String text = super.getColumnText(element, columnIndex);
+ // it's the order of label provider
+ if (columnIndex == 0) {
+ IInstallableUnit iu = ProvUI.getAdapter(element, IInstallableUnit.class);
+ return getIUNameWithDetail(iu);
+ }
+ return text;
+ }
+
+ @Override
+ public Color getForeground(Object element) {
+ IInstallableUnit iu = ProvUI.getAdapter(element, IInstallableUnit.class);
+ if (hasInstalled(iu))
+ return Display.getDefault().getSystemColor(SWT.COLOR_GRAY);
+ return super.getForeground(element);
+ }
+ }
+
+ protected ITableLabelProvider getLabelProvider() {
+ return new ImportFromInstallationLabelProvider();
+ }
+
+ @Override
+ public void dispose() {
+ super.dispose();
+ if (otherInstanceAgent != null) {
+ otherInstanceAgent.stop();
+ otherInstanceAgent = null;
+ toImportFrom = null;
+ }
+ cleanLocalRepository();
+ }
+
+ public void cleanLocalRepository() {
+ if (metaURIs != null && metaURIs.length > 0) {
+ IProvisioningAgent runningAgent = getProvisioningUI().getSession().getProvisioningAgent();
+ IMetadataRepositoryManager manager = (IMetadataRepositoryManager) runningAgent.getService(IMetadataRepositoryManager.SERVICE_NAME);
+ for (URI uri : metaURIs)
+ manager.removeRepository(uri);
+ IArtifactRepositoryManager artifactManager = (IArtifactRepositoryManager) runningAgent.getService(IArtifactRepositoryManager.SERVICE_NAME);
+ for (URI uri : artiURIs)
+ artifactManager.removeRepository(uri);
+ }
+ }
+
+ // Both checkedElements and checkedElementsUpdates and the logic inside the getCheckedIUElements method
+ // are used to prevent unnecessary call to getUpdates method due to computational cost.
+ private Set checkedElements;
+ private Set checkedElementsUpdates;
+ private boolean getUpdatesCanceled;
+
+ public Object[] getCheckedIUElements() {
+
+ if (isUpdateToLatest()) {
+
+ Object[] latestUpdates = getLatestVersionOfCheckedElements();
+
+ // If the getUpdades operation is cancelled, then set checkedElements and checkedElementsUpdates to null to force the lookup for updates again. Thereafter throw OperationCanceledException.
+ if (getUpdatesCanceled) {
+
+ this.checkedElements = null;
+ this.checkedElementsUpdates = null;
+ throw new OperationCanceledException();
+ }
+ return latestUpdates;
+ }
+ return viewer.getCheckedElements();
+ }
+
+ private Object[] getLatestVersionOfCheckedElements() {
+
+ Object[] checkedArray = viewer.getCheckedElements();
+ if (this.checkedElements == null) {
+ // initialize checkedElements and checkedElementsUpdates for the first time
+ this.checkedElements = new HashSet(Arrays.asList(checkedArray));
+ this.checkedElementsUpdates = new HashSet(Arrays.asList(getUpdates(checkedArray)));
+
+ } else {
+ Set checkedElementsNow = new HashSet(Arrays.asList(checkedArray));
+ if (checkedElementsNow.size() != this.checkedElements.size() || (!checkedElementsNow.containsAll(checkedElements))) {
+ // only if the set of checkedElements has changed get the update for them
+ this.checkedElements = checkedElementsNow; //
+ this.checkedElementsUpdates = new HashSet(Arrays.asList(getUpdates(checkedArray)));
+ }
+ }
+
+ return this.checkedElementsUpdates.toArray();
+ }
+
+ public Object[] getSelectedIUElements() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void setCheckedElements(Object[] elements) {
+ new UnsupportedOperationException();
+ }
+
+ // Look for update of the current selected installation units and replace the old ons with the updated version
+ private Object[] getUpdates(final Object[] checkedElements) {
+
+ final Collection<IInstallableUnit> toInstall = new ArrayList<IInstallableUnit>();
+
+ try {
+ getContainer().run(false, true, new IRunnableWithProgress() {
+
+ public void run(IProgressMonitor monitor) {
+ SubMonitor sub = SubMonitor.convert(monitor, checkedElements.length);
+ ProvisioningContext context = new ProvisioningContext(getProvisioningUI().getSession().getProvisioningAgent());
+
+ for (Object iu : checkedElements) {
+
+ if (sub.isCanceled()) {
+ MigrationPage.this.getUpdatesCanceled = true;
+ toInstall.clear();
+ sub.done();
+ return;
+ }
+
+ if (iu instanceof AvailableIUElement) {
+ IInstallableUnit unit = ((AvailableIUElement) iu).getIU();
+ IuUpdateAndPatches updateAndPatches = filterToInstall(unit, updatesFor(unit, context, sub.newChild(1)));
+ if (updateAndPatches.update != null) {
+ toInstall.add(updateAndPatches.update);
+ } else {
+ toInstall.add(updateAndPatches.iu); // because it is not yet installed
+ toInstall.addAll(updateAndPatches.patches);
+ }
+
+ }
+
+ sub.worked(1);
+ }
+ }
+
+ });
+ } catch (InterruptedException e) {
+ // Nothing to report if thread was interrupted
+ } catch (InvocationTargetException e) {
+ ProvUI.handleException(e.getCause(), null, StatusManager.SHOW | StatusManager.LOG);
+ }
+
+ return toInstall.toArray();
+
+ }
+
+ public boolean isUpdateToLatest() {
+ return updateToLatest.getSelection();
+ }
+
+ public ProvisioningContext getProvisioningContext() {
+ ProvisioningContext context = new ProvisioningContext(getProvisioningUI().getSession().getProvisioningAgent());
+ context.setArtifactRepositories(artiURIs);
+ context.setMetadataRepositories(metaURIs);
+ return context;
+ }
+
+ private static boolean hasHigherFidelity(IInstallableUnit iu, IInstallableUnit currentIU) {
+ if (Boolean.valueOf(currentIU.getProperty(IInstallableUnit.PROP_PARTIAL_IU)).booleanValue() && !Boolean.valueOf(iu.getProperty(IInstallableUnit.PROP_PARTIAL_IU)).booleanValue())
+ return true;
+ return false;
+ }
+
+ public Collection<IInstallableUnit> updatesFor(IInstallableUnit toUpdate, ProvisioningContext context, IProgressMonitor monitor) {
+ // IPlanner planner = (IPlanner) getProvisioningUI().getSession().getProvisioningAgent().getService(IPlanner.SERVICE_NAME);
+ // return planner.updatesFor(toUpdate, context, monitor).toSet();
+
+ Map<String, IInstallableUnit> resultsMap = new HashMap<String, IInstallableUnit>();
+
+ SubMonitor sub = SubMonitor.convert(monitor, 1000);
+ IQueryable<IInstallableUnit> queryable = context.getMetadata(sub.newChild(500));
+ IQueryResult<IInstallableUnit> matches = queryable.query(new UpdateQuery(toUpdate), sub.newChild(500));
+ for (Iterator<IInstallableUnit> it = matches.iterator(); it.hasNext();) {
+ IInstallableUnit iu = it.next();
+ String key = iu.getId() + "_" + iu.getVersion().toString(); //$NON-NLS-1$
+ IInstallableUnit currentIU = resultsMap.get(key);
+ if (currentIU == null || hasHigherFidelity(iu, currentIU))
+ resultsMap.put(key, iu);
+ }
+ sub.done();
+ return resultsMap.values();
+ }
+
+ class IuUpdateAndPatches {
+ public IInstallableUnit iu;
+ public IInstallableUnit update;
+ public Collection<IInstallableUnit> patches;
+
+ IuUpdateAndPatches(IInstallableUnit iu) {
+ this.iu = iu;
+ this.patches = new ArrayList<IInstallableUnit>();
+ }
+
+ }
+
+ /**
+ *
+ * @param iu original unit.
+ * @param updates list of updates: patches or true updates.
+ * @return a structure holding the original unit, its most recent update and any available patches.
+ */
+ private IuUpdateAndPatches filterToInstall(IInstallableUnit iu, Collection<IInstallableUnit> updates) {
+
+ IuUpdateAndPatches updateAndPatches = new IuUpdateAndPatches(iu);
+
+ for (IInstallableUnit update : updates) {
+
+ if (QueryUtil.isPatch(update)) {
+ updateAndPatches.patches.add(update);
+ } else {
+ if (updateAndPatches.update == null || updateAndPatches.update.getVersion().compareTo(update.getVersion()) < 0) {
+ updateAndPatches.update = update;
+ }
+ }
+ }
+
+ return updateAndPatches;
+ }
+
+ public static boolean loadCustomizedSetting() {
+ IScopeContext[] contexts = new IScopeContext[] {InstanceScope.INSTANCE, DefaultScope.INSTANCE, BundleDefaultsScope.INSTANCE, ConfigurationScope.INSTANCE};
+ boolean updateToLatest = Platform.getPreferencesService().getBoolean(AutomaticUpdatePlugin.PLUGIN_ID, "updateToLatest", false, contexts);
+ return updateToLatest;
+ }
} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/MigrationSupport.java b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/MigrationSupport.java
index fb49d72..8189050 100644
--- a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/MigrationSupport.java
+++ b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/MigrationSupport.java
@@ -3,9 +3,11 @@
* program and the accompanying materials are made available under the terms of
* the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
+ *
+ * Contributors:
* Ericsson AB - initial API and implementation
+ * Ericsson AB (Pascal Rapicault)
+ * Ericsson AB (Hamdan Msheik)
******************************************************************************/
package org.eclipse.equinox.internal.p2.ui.sdk.scheduler.migration;
@@ -72,8 +74,9 @@ public class MigrationSupport {
if (previousProfile == null)
return false;
- if (needsMigration(previousProfile, currentProfile)) {
- openMigrationWizard(previousProfile, reposToMigrate);
+ Collection<IInstallableUnit> unitsToMigrate = findUnitstoMigrate(previousProfile, currentProfile);
+ if (!unitsToMigrate.isEmpty()) {
+ openMigrationWizard(previousProfile, unitsToMigrate, reposToMigrate);
} else {
//There is nothing to migrate, so we mark the migration complete
rememberMigrationCompleted();
@@ -144,7 +147,7 @@ public class MigrationSupport {
* @param currentProfile is the current profile used by eclipse.
* @return true if set difference between previousProfile units and currentProfile units not empty, otherwise false
*/
- protected boolean needsMigration(IProfile previousProfile, IProfile currentProfile) {
+ protected Collection<IInstallableUnit> findUnitstoMigrate(IProfile previousProfile, IProfile currentProfile) {
//First, try the case of inclusion
Set<IInstallableUnit> previousProfileUnits = getUserRoots(previousProfile);
Set<IInstallableUnit> currentProfileUnits = currentProfile.available(new UserVisibleRootQuery(), null).toSet();
@@ -164,7 +167,7 @@ public class MigrationSupport {
previousProfileIterator.remove();
}
- return !previousProfileUnits.isEmpty();
+ return previousProfileUnits;
}
private Set<IInstallableUnit> getUserRoots(IProfile previousProfile) {
@@ -175,11 +178,11 @@ public class MigrationSupport {
return userRoots;
}
- protected void openMigrationWizard(final IProfile inputProfile, final URI[] reposToMigrate) {
+ protected void openMigrationWizard(final IProfile inputProfile, final Collection<IInstallableUnit> unitsToMigrate, final URI[] reposToMigrate) {
Display d = Display.getDefault();
d.asyncExec(new Runnable() {
public void run() {
- WizardDialog migrateWizard = new WizardDialog(getWorkbenchWindowShell(), new ImportFromInstallationWizard_c(inputProfile, reposToMigrate, reposToMigrate != null));
+ WizardDialog migrateWizard = new WizardDialog(getWorkbenchWindowShell(), new MigrationWizard(inputProfile, unitsToMigrate, reposToMigrate, reposToMigrate != null));
migrateWizard.create();
migrateWizard.open();
}
diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/ImportFromInstallationWizard_c.java b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/MigrationWizard.java
index 8db2a27..5d6af1c 100644
--- a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/ImportFromInstallationWizard_c.java
+++ b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/MigrationWizard.java
@@ -8,11 +8,14 @@
* Contributors:
* WindRiver Corporation - initial API and implementation
* Ericsson AB - Ongoing development
+ * Ericsson AB (Pascal Rapicault)
+ * Ericsson AB (Hamdan Msheik)
*******************************************************************************/
package org.eclipse.equinox.internal.p2.ui.sdk.scheduler.migration;
import java.net.URI;
import java.util.*;
+import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Platform;
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
import org.eclipse.equinox.internal.p2.ui.ProvUIActivator;
@@ -33,28 +36,32 @@ import org.eclipse.equinox.p2.ui.ProvisioningUI;
import org.eclipse.jface.dialogs.*;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.ui.IImportWizard;
import org.eclipse.ui.IWorkbench;
-public class ImportFromInstallationWizard_c extends InstallWizard implements IImportWizard {
+public class MigrationWizard extends InstallWizard implements IImportWizard {
+
private IProfile toImportFrom;
+ Collection<IInstallableUnit> unitsToMigrate;
private URI[] reposToMigrate;
private List<URI> addedRepos = new ArrayList<URI>();
private boolean firstTime = false;
- public ImportFromInstallationWizard_c() {
+ public MigrationWizard() {
this(ProvisioningUI.getDefaultUI(), null, null, null);
}
- public ImportFromInstallationWizard_c(IProfile toImportFrom, URI[] reposToMigrate, boolean firstTime) {
+ public MigrationWizard(IProfile toImportFrom, Collection<IInstallableUnit> unitsToMigrate, URI[] reposToMigrate, boolean firstTime) {
this(ProvisioningUI.getDefaultUI(), null, null, null);
this.toImportFrom = toImportFrom;
+ this.unitsToMigrate = unitsToMigrate;
this.reposToMigrate = reposToMigrate;
this.firstTime = firstTime;
addRepos();
}
- public ImportFromInstallationWizard_c(ProvisioningUI ui, InstallOperation operation, Collection<IInstallableUnit> initialSelections, LoadMetadataRepositoryJob preloadJob) {
+ public MigrationWizard(ProvisioningUI ui, InstallOperation operation, Collection<IInstallableUnit> initialSelections, LoadMetadataRepositoryJob preloadJob) {
super(ui, operation, initialSelections, preloadJob);
IDialogSettings workbenchSettings = ProvUIActivator.getDefault().getDialogSettings();
String sectionName = "MigrationWizard"; //$NON-NLS-1$
@@ -66,21 +73,21 @@ public class ImportFromInstallationWizard_c extends InstallWizard implements IIm
}
public void init(IWorkbench workbench, IStructuredSelection selection) {
- setWindowTitle(firstTime ? ProvUIMessages.ImportWizard_WINDOWTITLE_FIRSTRUN : ProvUIMessages.ImportWizard_WINDOWTITLE);
+ setWindowTitle(firstTime ? ProvUIMessages.MigrationWizard_WINDOWTITLE_FIRSTRUN : ProvUIMessages.MigrationWizard_WINDOWTITLE);
setDefaultPageImageDescriptor(ImageDescriptor.createFromURL(Platform.getBundle(ProvUIActivator.PLUGIN_ID).getEntry("icons/install_wiz.gif"))); //$NON-NLS-1$
setNeedsProgressMonitor(true);
}
@Override
protected ISelectableIUsPage createMainPage(IUElementListRoot input, Object[] selections) {
- if (toImportFrom != null)
- return new ImportFromInstallationPage_c(ui, this, toImportFrom, firstTime);
- return new ImportFromInstallationPage_c(ui, this, firstTime);
+ if (unitsToMigrate != null)
+ return new MigrationPage(ui, this, toImportFrom, unitsToMigrate, firstTime);
+ return new MigrationPage(ui, this, firstTime);
}
@Override
protected ProvisioningContext getProvisioningContext() {
- return ((ImportFromInstallationPage_c) mainPage).getProvisioningContext();
+ return ((MigrationPage) mainPage).getProvisioningContext();
}
@Override
@@ -144,8 +151,8 @@ public class ImportFromInstallationWizard_c extends InstallWizard implements IIm
}
public boolean performCancel() {
- String[] buttons = new String[] {IDialogConstants.YES_LABEL, ProvUIMessages.ImportFromInstallationPag_LATER_BUTTON, IDialogConstants.NO_LABEL};
- MessageDialog dialog = new MessageDialog(getShell(), ProvUIMessages.ImportFromInstallationPage_CONFIRMATION_TITLE, null, ProvUIMessages.ImportFromInstallationPage_CONFIRMATION_DIALOG, MessageDialog.QUESTION, buttons, 2);
+ String[] buttons = new String[] {IDialogConstants.YES_LABEL, ProvUIMessages.MigrationPage_LATER_BUTTON, IDialogConstants.NO_LABEL};
+ MessageDialog dialog = new MessageDialog(getShell(), ProvUIMessages.MigrationPage_CONFIRMATION_TITLE, null, ProvUIMessages.MigrationPage_CONFIRMATION_DIALOG, MessageDialog.QUESTION, buttons, 2);
return rememberCancellationDecision(dialog.open());
}
@@ -172,4 +179,16 @@ public class ImportFromInstallationWizard_c extends InstallWizard implements IIm
return result;
}
+ public IWizardPage getNextPage(IWizardPage page) {
+ IWizardPage toReturn = page;
+
+ try {
+ toReturn = super.getNextPage(page);
+ } catch (OperationCanceledException oce) {
+ // swallow and stay on the same page
+ }
+
+ return toReturn;
+ }
+
}
diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/ProvUIMessages.java b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/ProvUIMessages.java
index 5feb422..ce5f0b5 100644
--- a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/ProvUIMessages.java
+++ b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/ProvUIMessages.java
@@ -7,6 +7,8 @@
*
* Contributors:
* Ericsson AB - initial API and implementation
+ * Ericsson AB (Pascal Rapicault)
+ * Ericsson AB (Hamdan Msheik)
*******************************************************************************/
package org.eclipse.equinox.internal.p2.ui.sdk.scheduler.migration;
@@ -27,14 +29,16 @@ public class ProvUIMessages extends NLS {
public static String AbstractPage_ButtonSelectAll;
public static String AbstractPage_ButtonDeselectAll;
public static String PAGE_NOINSTALLTION_ERROR;
- public static String ImportFromInstallationPage_SELECT_COMPONENT;
- public static String ImportFromInstallationPage_DIALOG_TITLE;
- public static String ImportFromInstallationPage_DIALOG_TITLE_FIRSTRUN;
- public static String ImportFromInstallationPage_DIALOG_DESCRIPTION;
- public static String ImportFromInstallationPage_DIALOG_DESCRIPTION_FIRSTRUN;
- public static String ImportWizard_WINDOWTITLE;
- public static String ImportWizard_WINDOWTITLE_FIRSTRUN;
- public static String ImportFromInstallationPage_CONFIRMATION_TITLE;
- public static String ImportFromInstallationPage_CONFIRMATION_DIALOG;
- public static String ImportFromInstallationPag_LATER_BUTTON;
+ public static String MigrationWizard_WINDOWTITLE;
+ public static String MigrationWizard_WINDOWTITLE_FIRSTRUN;
+ public static String MigrationPage_SELECT_COMPONENT;
+ public static String MigrationPage_DIALOG_TITLE;
+ public static String MigrationPage_DIALOG_TITLE_FIRSTRUN;
+ public static String MigrationPage_DIALOG_DESCRIPTION;
+ public static String MigrationPage_DIALOG_DESCRIPTION_FIRSTRUN;
+ public static String MigrationPage_CONFIRMATION_TITLE;
+ public static String MigrationPage_CONFIRMATION_DIALOG;
+ public static String MigrationPage_LATER_BUTTON;
+ public static String MigrationPage_UPDATE_TO_LATEST;
+
}
diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/messages.properties b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/messages.properties
index 8bb0ab7..0063c3b 100644
--- a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/messages.properties
+++ b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/messages.properties
@@ -6,13 +6,14 @@ Column_Version=Version
AbstractPage_ButtonSelectAll=&Select All
AbstractPage_ButtonDeselectAll=&Deselect All
PAGE_NOINSTALLTION_ERROR=Select at least one available element to be installed.
-ImportFromInstallationPage_SELECT_COMPONENT=Select at least one available element to be installed.
-ImportWizard_WINDOWTITLE=Migrate
-ImportWizard_WINDOWTITLE_FIRSTRUN=Import
-ImportFromInstallationPage_DIALOG_TITLE=Migration wizard
-ImportFromInstallationPage_DIALOG_TITLE_FIRSTRUN=Import wizard
-ImportFromInstallationPage_DIALOG_DESCRIPTION=Because {0} has been updated, the plug-ins you had installed are now disabled.\nThis wizard will help you install those again.
-ImportFromInstallationPage_DIALOG_DESCRIPTION_FIRSTRUN=It is the first time you are running {0} from this location.\nThis wizard will help you install plug-ins you may have previously installed.
-ImportFromInstallationPage_CONFIRMATION_TITLE=Migration cancellation
-ImportFromInstallationPage_CONFIRMATION_DIALOG=Cancelling this operation will stop the re-installation of your plug-ins. Are you sure you want to cancel?
-ImportFromInstallationPag_LATER_BUTTON=Yes, remind me later \ No newline at end of file
+MigrationWizard_WINDOWTITLE=Migrate
+MigrationWizard_WINDOWTITLE_FIRSTRUN=Import
+MigrationPage_DIALOG_TITLE=Migration wizard
+MigrationPage_DIALOG_TITLE_FIRSTRUN=Import wizard
+MigrationPage_DIALOG_DESCRIPTION=Because {0} has been updated, the plug-ins you had installed are now disabled.\nThis wizard will help you install those again.
+MigrationPage_DIALOG_DESCRIPTION_FIRSTRUN=It is the first time you are running {0} from this location.\nThis wizard will help you install plug-ins you may have previously installed.
+MigrationPage_CONFIRMATION_TITLE=Migration cancellation
+MigrationPage_CONFIRMATION_DIALOG=Canceling this operation will stop the re-installation of your plug-ins. Are you sure you want to cancel?
+MigrationPage_LATER_BUTTON=Yes, remind me later
+MigrationPage_UPDATE_TO_LATEST=Update to latest
+MigrationPage_SELECT_COMPONENT==Select at least one available element to be installed.