Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rapicault (Ericsson)2013-02-14 12:39:14 -0500
committerPascal Rapicault2013-02-14 12:39:14 -0500
commitf7559f7f4976c6af53be9b54a36cbad40719e702 (patch)
tree53166b73da02e28ab7e586e9dd1247a73d2b5926 /bundles/org.eclipse.equinox.p2.ui.sdk.scheduler
parent03fbd7c20261d6859d6eddd663de97b37742c83f (diff)
downloadrt.equinox.p2-f7559f7f4976c6af53be9b54a36cbad40719e702.tar.gz
rt.equinox.p2-f7559f7f4976c6af53be9b54a36cbad40719e702.tar.xz
rt.equinox.p2-f7559f7f4976c6af53be9b54a36cbad40719e702.zip
Move the wizard classes to the scheduler bundle until we do figure out v20130214-173914
the possible merge with the import/export codebase.
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.ui.sdk.scheduler')
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/META-INF/MANIFEST.MF4
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/AutomaticUpdateScheduler.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/AbstractPage_c.java783
-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/ImportFromInstallationWizard_c.java72
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/ProvUIMessages.java36
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/messages.properties14
8 files changed, 1474 insertions, 3 deletions
diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/META-INF/MANIFEST.MF
index ded416037..e4498d102 100644
--- a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/META-INF/MANIFEST.MF
@@ -10,7 +10,8 @@ Export-Package: org.eclipse.equinox.internal.p2.ui.sdk.scheduler;x-internal:=tru
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.equinox.p2.updatechecker,
- org.eclipse.equinox.p2.ui
+ org.eclipse.equinox.p2.ui,
+ org.eclipse.equinox.p2.repository;bundle-version="2.3.0"
Bundle-RequiredExecutionEnvironment: J2SE-1.5,
J2SE-1.4,
CDC-1.1/Foundation-1.1
@@ -21,6 +22,7 @@ Import-Package: com.ibm.icu.util;version="4.0.1",
org.eclipse.equinox.internal.p2.engine.phases,
org.eclipse.equinox.internal.p2.garbagecollector,
org.eclipse.equinox.internal.p2.metadata.query,
+ org.eclipse.equinox.internal.p2.ui,
org.eclipse.equinox.internal.p2.ui.actions,
org.eclipse.equinox.internal.p2.ui.query,
org.eclipse.equinox.internal.provisional.p2.core.eventbus,
diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/AutomaticUpdateScheduler.java b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/AutomaticUpdateScheduler.java
index 73284da7f..2183d5b06 100644
--- a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/AutomaticUpdateScheduler.java
+++ b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/AutomaticUpdateScheduler.java
@@ -12,6 +12,9 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.ui.sdk.scheduler;
+import org.eclipse.equinox.internal.p2.ui.sdk.scheduler.migration.AbstractPage_c;
+import org.eclipse.equinox.internal.p2.ui.sdk.scheduler.migration.ImportFromInstallationWizard_c;
+
import com.ibm.icu.util.Calendar;
import com.ibm.icu.util.ULocale;
import java.util.Set;
@@ -20,8 +23,6 @@ import org.eclipse.core.runtime.preferences.ConfigurationScope;
import org.eclipse.core.runtime.preferences.IScopeContext;
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
import org.eclipse.equinox.internal.p2.garbagecollector.GarbageCollector;
-import org.eclipse.equinox.internal.p2.ui.dialogs.AbstractPage_c;
-import org.eclipse.equinox.internal.p2.ui.dialogs.ImportFromInstallationWizard_c;
import org.eclipse.equinox.internal.provisional.p2.updatechecker.*;
import org.eclipse.equinox.p2.core.IProvisioningAgent;
import org.eclipse.equinox.p2.engine.IProfile;
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
new file mode 100644
index 000000000..5c9ff866f
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/AbstractImportPage_c.java
@@ -0,0 +1,126 @@
+/*******************************************************************************
+ * 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/AbstractPage_c.java b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/AbstractPage_c.java
new file mode 100644
index 000000000..b78dbf5c8
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/AbstractPage_c.java
@@ -0,0 +1,783 @@
+/*******************************************************************************
+ * 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
+ * IBM Corporation - Ongoing development
+ * 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.util.*;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.jobs.IJobChangeEvent;
+import org.eclipse.core.runtime.jobs.JobChangeAdapter;
+import org.eclipse.core.runtime.preferences.ConfigurationScope;
+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.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.metadata.IInstallableUnit;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.*;
+import org.eclipse.jface.wizard.WizardPage;
+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.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.osgi.framework.BundleContext;
+import org.osgi.service.prefs.BackingStoreException;
+import org.osgi.service.prefs.Preferences;
+import org.osgi.util.tracker.ServiceTracker;
+
+public abstract class AbstractPage_c extends WizardPage implements Listener {
+
+ protected String currentMessage;
+ // protected Button destinationBrowseButton;
+ protected Button remindMeButton;
+ protected CheckboxTreeViewer viewer = null;
+ protected Exception finishException;
+ protected boolean entryChanged = false;
+ protected static IProfileRegistry profileRegistry = null;
+ static IProvisioningAgent agent = null;
+
+ 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;
+
+ /**
+ * {@link DelayedFilterCheckboxTree} has a timing bug to prevent restoring the check state,
+ * the methods {@link DeferredTreeContentManager}'s runClearPlaceholderJob and
+ * DelayedFilterCheckboxTree.doCreateRefreshJob().new JobChangeAdapter() {...}.done(IJobChangeEvent) has timing issue,
+ * I can't find a way to guarantee the first job is executed firstly
+ *
+ */
+ final class ImportExportFilteredTree extends FilteredTree {
+ ArrayList<Object> checkState = new ArrayList<Object>();
+
+ ImportExportFilteredTree(Composite parent, int treeStyle, PatternFilter filter, boolean useNewLook) {
+ super(parent, treeStyle, filter, useNewLook);
+ }
+
+ @Override
+ protected TreeViewer doCreateTreeViewer(Composite composite, int style) {
+ return new CheckboxTreeViewer(composite, style);
+ }
+
+ @Override
+ protected WorkbenchJob doCreateRefreshJob() {
+ WorkbenchJob job = super.doCreateRefreshJob();
+ job.addJobChangeListener(new JobChangeAdapter() {
+ @Override
+ public void aboutToRun(IJobChangeEvent event) {
+ Display.getDefault().syncExec(new Runnable() {
+
+ public void run() {
+ Object[] checked = viewer.getCheckedElements();
+ if (checkState == null)
+ checkState = new ArrayList<Object>(checked.length);
+ for (int i = 0; i < checked.length; i++)
+ if (!viewer.getGrayed(checked[i]))
+ if (!checkState.contains(checked[i]))
+ checkState.add(checked[i]);
+ }
+ });
+ }
+
+ @Override
+ public void done(IJobChangeEvent event) {
+ if (event.getResult().isOK()) {
+ Display.getDefault().asyncExec(new Runnable() {
+
+ public void run() {
+ if (viewer == null || viewer.getTree().isDisposed())
+ return;
+ if (checkState == null)
+ return;
+
+ viewer.setCheckedElements(new Object[0]);
+ viewer.setGrayedElements(new Object[0]);
+ // Now we are only going to set the check state of the leaf nodes
+ // and rely on our container checked code to update the parents properly.
+ Iterator<Object> iter = checkState.iterator();
+ while (iter.hasNext()) {
+ viewer.setChecked(iter.next(), true);
+ }
+
+ updatePageCompletion();
+ }
+ });
+ }
+ }
+ });
+ return job;
+ }
+ }
+
+ class TreeViewerComparator extends ViewerComparator {
+ private int sortColumn = 0;
+ private int lastSortColumn = 0;
+ private boolean ascending = false;
+ private boolean lastAscending = false;
+
+ @Override
+ public int compare(Viewer viewer1, Object e1, Object e2) {
+ IInstallableUnit iu1 = ProvUI.getAdapter(e1, IInstallableUnit.class);
+ IInstallableUnit iu2 = ProvUI.getAdapter(e2, IInstallableUnit.class);
+ if (iu1 != null && iu2 != null) {
+ if (viewer1 instanceof TreeViewer) {
+ TreeViewer treeViewer = (TreeViewer) viewer1;
+ IBaseLabelProvider baseLabel = treeViewer.getLabelProvider();
+ if (baseLabel instanceof ITableLabelProvider) {
+ ITableLabelProvider tableProvider = (ITableLabelProvider) baseLabel;
+ String e1p = tableProvider.getColumnText(e1, getSortColumn());
+ String e2p = tableProvider.getColumnText(e2, getSortColumn());
+ @SuppressWarnings("unchecked")
+ int result = getComparator().compare(e1p, e2p);
+ // Secondary column sort
+ if (result == 0) {
+ e1p = tableProvider.getColumnText(e1, lastSortColumn);
+ e2p = tableProvider.getColumnText(e2, lastSortColumn);
+ @SuppressWarnings("unchecked")
+ int result2 = getComparator().compare(e1p, e2p);
+ return lastAscending ? result2 : (-1) * result2;
+ }
+ return isAscending() ? result : (-1) * result;
+ }
+ }
+ // we couldn't determine a secondary sort, call it equal
+ return 0;
+ }
+ return super.compare(viewer1, e1, e2);
+ }
+
+ /**
+ * @return Returns the sortColumn.
+ */
+ public int getSortColumn() {
+ return sortColumn;
+ }
+
+ /**
+ * @param sortColumn
+ * The sortColumn to set.
+ */
+ public void setSortColumn(int sortColumn) {
+ if (this.sortColumn != sortColumn) {
+ lastSortColumn = this.sortColumn;
+ lastAscending = this.ascending;
+ this.sortColumn = sortColumn;
+ }
+ }
+
+ /**
+ * @return Returns the ascending.
+ */
+ public boolean isAscending() {
+ return ascending;
+ }
+
+ /**
+ * @param ascending
+ * The ascending to set.
+ */
+ public void setAscending(boolean ascending) {
+ this.ascending = ascending;
+ }
+ }
+
+ static {
+ BundleContext context = Platform.getBundle(ProvUIActivator.PLUGIN_ID).getBundleContext();
+ ServiceTracker<IProvisioningAgent, IProvisioningAgent> tracker = new ServiceTracker<IProvisioningAgent, IProvisioningAgent>(context, IProvisioningAgent.class, null);
+ tracker.open();
+ agent = tracker.getService();
+ tracker.close();
+ if (agent != null)
+ profileRegistry = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME);
+ }
+
+ public AbstractPage_c(String pageName) {
+ super(pageName);
+ }
+
+ public AbstractPage_c(String pageName, String title, ImageDescriptor titleImage) {
+ super(pageName, title, titleImage);
+ }
+
+ protected IProfile getSelfProfile() {
+ if (profileRegistry != null) {
+ String selfID = System.getProperty("eclipse.p2.profile"); //$NON-NLS-1$
+ if (selfID == null)
+ selfID = IProfileRegistry.SELF;
+ return profileRegistry.getProfile(selfID);
+ }
+ return null;
+ }
+
+ private void createColumns(TreeViewer treeViewer) {
+ String[] titles = {ProvUIMessages.Column_Name, ProvUIMessages.Column_Version, ProvUIMessages.Column_Id};
+ for (int i = 0; i < titles.length; i++) {
+ TreeViewerColumn column = new TreeViewerColumn(treeViewer, SWT.NONE);
+ column.getColumn().setText(titles[i]);
+ column.getColumn().setResizable(true);
+ column.getColumn().setMoveable(true);
+ if (ProvUIMessages.Column_Name.equals(titles[i]))
+ updateTableSorting(i);
+ final int columnIndex = i;
+ column.getColumn().addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ updateTableSorting(columnIndex);
+ }
+ });
+ }
+ }
+
+ protected void updateTableSorting(int columnIndex) {
+ TreeViewerComparator comparator = (TreeViewerComparator) viewer.getComparator();
+ // toggle direction if it's the same column
+ if (columnIndex == comparator.getSortColumn()) {
+ comparator.setAscending(!comparator.isAscending());
+ }
+ comparator.setSortColumn(columnIndex);
+ viewer.getTree().setSortColumn(viewer.getTree().getColumn(columnIndex));
+ viewer.getTree().setSortDirection(comparator.isAscending() ? SWT.UP : SWT.DOWN);
+ viewer.refresh(false);
+ }
+
+ protected abstract void createContents(Composite composite);
+
+ public void createControl(Composite parent) {
+ initializeDialogUnits(parent);
+ // initializeService();
+ Composite composite = new Composite(parent, SWT.NULL);
+ GridLayout layout = new GridLayout(1, true);
+ layout.horizontalSpacing = 0;
+ layout.verticalSpacing = 5;
+ composite.setLayout(layout);
+ composite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL));
+
+ createContents(composite);
+
+ // can not finish initially, but don't want to start with an error
+ // message either
+ if (!(validateOptionsGroup())) {
+ setPageComplete(false);
+ }
+
+ setControl(composite);
+ // giveFocusToDestination();
+ Dialog.applyDialogFont(composite);
+ }
+
+ protected void createRemindMeGroup(Composite parent) {
+
+ remindMeButton = new Button(parent, SWT.CHECK);
+ remindMeButton.setText(ProvUIMessages.REMIND_ME_TO_MIGRATE_LATER);
+ remindMeButton.setSelection(true);
+ GridData dataRemindMeButton = new GridData();
+ dataRemindMeButton.horizontalSpan = 3;
+ remindMeButton.setLayoutData(dataRemindMeButton);
+
+ remindMeButton.addSelectionListener(new SelectionListener() {
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+
+ Preferences prefs = ConfigurationScope.INSTANCE.getNode("org.eclipse.equinox.p2.ui"); //$NON-NLS-1$
+ prefs.putBoolean(REMIND_ME_LATER, ((Button) (e.widget)).getSelection());
+
+ try {
+ prefs.flush();
+ } catch (BackingStoreException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+
+ }
+ });
+
+ }
+
+ // 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)};
+ }
+
+ protected void createInstallationTable(final Composite parent) {
+ Group group = new Group(parent, SWT.NONE);
+ GridData griddata = new GridData(GridData.FILL, GridData.FILL, true, true);
+ griddata.verticalSpan = griddata.horizontalSpan = 0;
+ group.setLayoutData(griddata);
+ group.setLayout(new GridLayout(1, false));
+ PatternFilter filter = getPatternFilter();
+ filter.setIncludeLeadingWildcard(true);
+ final ImportExportFilteredTree filteredTree = new ImportExportFilteredTree(group, SWT.MULTI | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER, filter, true);
+ viewer = (CheckboxTreeViewer) filteredTree.getViewer();
+ final Tree tree = viewer.getTree();
+ tree.setHeaderVisible(true);
+ tree.setLinesVisible(false);
+ viewer.setComparator(new TreeViewerComparator());
+ viewer.setComparer(new ProvElementComparer());
+ createColumns(viewer);
+ final ITreeContentProvider contentProvider = getContentProvider();
+ viewer.setContentProvider(contentProvider);
+ viewer.setLabelProvider(getLabelProvider());
+ viewer.addCheckStateListener(new ICheckStateListener() {
+
+ public void checkStateChanged(CheckStateChangedEvent event) {
+ if (!event.getChecked() && filteredTree.checkState != null) {
+ ArrayList<Object> toRemove = new ArrayList<Object>(1);
+ // See bug 258117. Ideally we would get check state changes
+ // for children when the parent state changed, but we aren't, so
+ // we need to remove all children from the additive check state
+ // cache.
+ if (contentProvider.hasChildren(event.getElement())) {
+ Set<Object> unchecked = new HashSet<Object>();
+ Object[] children = contentProvider.getChildren(event.getElement());
+ for (int i = 0; i < children.length; i++) {
+ unchecked.add(children[i]);
+ }
+ Iterator<Object> iter = filteredTree.checkState.iterator();
+ while (iter.hasNext()) {
+ Object current = iter.next();
+ if (current != null && unchecked.contains(current)) {
+ toRemove.add(current);
+ }
+ }
+ } else {
+ for (Object element : filteredTree.checkState) {
+ if (viewer.getComparer().equals(element, event.getElement())) {
+ toRemove.add(element);
+ // Do not break out of the loop. We may have duplicate equal
+ // elements in the cache. Since the cache is additive, we want
+ // to be sure we've gotten everything.
+ }
+ }
+ }
+ filteredTree.checkState.removeAll(toRemove);
+ }
+ }
+ });
+ parent.addControlListener(new ControlAdapter() {
+ private final int[] columnRate = new int[] {6, 2, 2};
+
+ @Override
+ public void controlResized(ControlEvent e) {
+ Rectangle area = parent.getClientArea();
+ Point size = tree.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ ScrollBar vBar = tree.getVerticalBar();
+ int width = area.width - tree.computeTrim(0, 0, 0, 0).width - vBar.getSize().x;
+ if (size.y > area.height + tree.getHeaderHeight()) {
+ // Subtract the scrollbar width from the total column width
+ // if a vertical scrollbar will be required
+ Point vBarSize = vBar.getSize();
+ width -= vBarSize.x;
+ }
+ Point oldSize = tree.getSize();
+ TreeColumn[] columns = tree.getColumns();
+ int hasUsed = 0, i = 0;
+ if (oldSize.x > area.width) {
+ // table is getting smaller so make the columns
+ // smaller first and then resize the table to
+ // match the client area width
+ for (; i < columns.length - 1; i++) {
+ columns[i].setWidth(width * columnRate[i] / 10);
+ hasUsed += columns[i].getWidth();
+ }
+ columns[columns.length - 1].setWidth(width - hasUsed);
+ tree.setSize(area.width, area.height);
+ } else {
+ // table is getting bigger so make the table
+ // bigger first and then make the columns wider
+ // to match the client area width
+ tree.setSize(area.width, area.height);
+ for (; i < columns.length - 1; i++) {
+ columns[i].setWidth(width * columnRate[i] / 10);
+ hasUsed += columns[i].getWidth();
+ }
+ columns[columns.length - 1].setWidth(width - hasUsed);
+ }
+ }
+ });
+ ICheckStateProvider provider = getViewerDefaultState();
+ if (provider != null)
+ viewer.setCheckStateProvider(provider);
+ else
+ viewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ updatePageCompletion();
+ }
+ });
+ viewer.getControl().setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
+ viewer.getControl().setSize(300, 200);
+ viewer.setInput(getInput());
+ Composite buttons = new Composite(group, SWT.NONE);
+ buttons.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
+ buttons.setLayout(new RowLayout(SWT.HORIZONTAL));
+ Button selectAll = new Button(buttons, SWT.PUSH);
+ selectAll.setText(ProvUIMessages.AbstractPage_ButtonSelectAll);
+ selectAll.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ for (TreeItem item : viewer.getTree().getItems()) {
+ if (!item.getChecked()) {
+ item.setChecked(true);
+ Event event = new Event();
+ event.widget = item.getParent();
+ event.detail = SWT.CHECK;
+ event.item = item;
+ event.type = SWT.Selection;
+ viewer.getTree().notifyListeners(SWT.Selection, event);
+ }
+ }
+ updatePageCompletion();
+ }
+ });
+ Button deselectAll = new Button(buttons, SWT.PUSH);
+ deselectAll.setText(ProvUIMessages.AbstractPage_ButtonDeselectAll);
+ deselectAll.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ for (TreeItem item : viewer.getTree().getItems()) {
+ viewer.setSubtreeChecked(item.getData(), false);
+ }
+ updatePageCompletion();
+ }
+ });
+ }
+
+ protected PatternFilter getPatternFilter() {
+ return new AvailableIUPatternFilter(getColumnConfig());
+ }
+
+ protected ICheckStateProvider getViewerDefaultState() {
+ return null;
+ }
+
+ protected ITableLabelProvider getLabelProvider() {
+ return new IUDetailsLabelProvider(null, getColumnConfig(), null);
+ }
+
+ protected ITreeContentProvider getContentProvider() {
+ ProvElementContentProvider provider = new ProvElementContentProvider() {
+ @Override
+ public boolean hasChildren(Object element) {
+ if (element instanceof InstalledIUElement)
+ return false;
+ return super.hasChildren(element);
+ }
+
+ @Override
+ public Object[] getChildren(Object parent) {
+ if (parent instanceof InstalledIUElement)
+ return new Object[0];
+ return super.getChildren(parent);
+ }
+ };
+ return provider;
+ }
+
+ protected boolean determinePageCompletion() {
+ currentMessage = null;
+ // validate groups in order of priority so error message is the most important one
+ boolean complete = validateOptionsGroup();
+
+ // Avoid draw flicker by not clearing the error
+ // message unless all is valid.
+ if (complete) {
+ setErrorMessage(null);
+ } else {
+ setErrorMessage(currentMessage);
+ }
+
+ 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;
+ //
+ // if (source == destinationBrowseButton) {
+ // handleDestinationBrowseButtonPressed();
+ // }
+ // 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.
+ */
+ protected void updatePageCompletion() {
+ boolean pageComplete = determinePageCompletion();
+ setPageComplete(pageComplete);
+ if (pageComplete) {
+ // if (this instanceof AbstractImportPage_c)
+ // saveWidgetValues();
+ setMessage(null);
+ }
+ }
+
+ // /**
+ // * 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;
+
+ currentMessage = getNoOptionsMessage();
+ return false;
+ }
+
+ // protected boolean validDestination() {
+ // if (this.destinationNameField == null)
+ // return true;
+ // File file = new File(getDestinationValue());
+ // return !(file.getPath().length() <= 0 || file.isDirectory());
+ // }
+
+ // 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 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);
+ // }
+ // }
+
+ // /**
+ // * 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$
+ // }
+ // }
+ // }
+
+ // /**
+ // * Add the passed value to self's destination widget's history
+ // *
+ // * @param value
+ // * java.lang.String
+ // */
+ // protected void addDestinationItem(String value) {
+ // destinationNameField.add(value);
+ // }
+} \ 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
new file mode 100644
index 000000000..53bef0a51
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/ImportFromInstallationPage_c.java
@@ -0,0 +1,437 @@
+/*******************************************************************************
+ * 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.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.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) {
+ super("importfrominstancepage", ui, wizard); //$NON-NLS-1$
+ setTitle(org.eclipse.equinox.internal.p2.ui.sdk.scheduler.migration.ProvUIMessages.ImportFromInstallationPage_DIALOG_TITLE);
+ // setDescription(ProvUIMessages.ImportFromInstallationPage_DIALOG_DESCRIPTION);
+ }
+
+ public ImportFromInstallationPage_c(ProvisioningUI ui, ImportFromInstallationWizard_c wizard, IProfile toImportFrom) {
+ super("importfrominstancepage", ui, wizard); //$NON-NLS-1$
+ setTitle(ProvUIMessages.ImportFromInstallationPage_DIALOG_TITLE);
+ // setDescription(ProvUIMessages.ImportFromInstallationPage_DIALOG_DESCRIPTION);
+ toBeImportedProfile = toImportFrom;
+ }
+
+ @Override
+ protected void createContents(Composite composite) {
+ createRemindMeGroup(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;
+ }
+
+ @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;
+ }
+ if (getWizard().performCancel())
+ 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/ImportFromInstallationWizard_c.java b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/ImportFromInstallationWizard_c.java
new file mode 100644
index 000000000..d9080332d
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/ImportFromInstallationWizard_c.java
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * 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 (Hamdan Msheik) - Bug 398833
+ *******************************************************************************/
+package org.eclipse.equinox.internal.p2.ui.sdk.scheduler.migration;
+
+import java.util.Collection;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.equinox.internal.p2.ui.ProvUIActivator;
+import org.eclipse.equinox.internal.p2.ui.dialogs.ISelectableIUsPage;
+import org.eclipse.equinox.internal.p2.ui.dialogs.InstallWizard;
+import org.eclipse.equinox.internal.p2.ui.model.IUElementListRoot;
+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.operations.InstallOperation;
+import org.eclipse.equinox.p2.ui.LoadMetadataRepositoryJob;
+import org.eclipse.equinox.p2.ui.ProvisioningUI;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IImportWizard;
+import org.eclipse.ui.IWorkbench;
+
+public class ImportFromInstallationWizard_c extends InstallWizard implements IImportWizard {
+ private IProfile toImportFrom;
+
+ public ImportFromInstallationWizard_c() {
+ this(ProvisioningUI.getDefaultUI(), null, null, null);
+ }
+
+ public ImportFromInstallationWizard_c(IProfile toImportFrom) {
+ this(ProvisioningUI.getDefaultUI(), null, null, null);
+ this.toImportFrom = toImportFrom;
+ }
+
+ public ImportFromInstallationWizard_c(ProvisioningUI ui, InstallOperation operation, Collection<IInstallableUnit> initialSelections, LoadMetadataRepositoryJob preloadJob) {
+ super(ui, operation, initialSelections, preloadJob);
+ IDialogSettings workbenchSettings = ProvUIActivator.getDefault().getDialogSettings();
+ String sectionName = "ImportFromInstallationWizard"; //$NON-NLS-1$
+ IDialogSettings section = workbenchSettings.getSection(sectionName);
+ if (section == null) {
+ section = workbenchSettings.addNewSection(sectionName);
+ }
+ setDialogSettings(section);
+ }
+
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ setWindowTitle(ProvUIMessages.ImportWizard_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);
+ return new ImportFromInstallationPage_c(ui, this);
+ }
+
+ @Override
+ protected ProvisioningContext getProvisioningContext() {
+ return ((ImportFromInstallationPage_c) mainPage).getProvisioningContext();
+ }
+}
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
new file mode 100644
index 000000000..e67ae700b
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/ProvUIMessages.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Ericsson AB 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:
+ * Ericsson AB - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.internal.p2.ui.sdk.scheduler.migration;
+
+import org.eclipse.osgi.util.NLS;
+
+public class ProvUIMessages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.equinox.internal.p2.ui.sdk.scheduler.migration.messages"; //$NON-NLS-1$
+ static {
+ // load message values from bundle file
+ NLS.initializeMessages(BUNDLE_NAME, ProvUIMessages.class);
+ }
+
+ public static String AbstractImportPage_HigherVersionInstalled;
+ public static String AbstractImportPage_SameVersionInstalled;
+ public static String Column_Id;
+ public static String Column_Name;
+ public static String Column_Version;
+ public static String AbstractPage_ButtonSelectAll;
+ public static String AbstractPage_ButtonDeselectAll;
+ public static String PAGE_NOINSTALLTION_ERROR;
+ public static String ImportFromInstallationPage_DIALOG_DESCRIPTION;
+ public static String ImportFromInstallationPage_SELECT_COMPONENT;
+ public static String ImportFromInstallationPage_DIALOG_TITLE;
+ public static String ImportWizard_WINDOWTITLE;
+ public static String ImportFromInstallationPage_INVALID_DESTINATION;
+ public static String REMIND_ME_TO_MIGRATE_LATER;
+}
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
new file mode 100644
index 000000000..e26b8fcf8
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/messages.properties
@@ -0,0 +1,14 @@
+AbstractImportPage_HigherVersionInstalled={0} (Disabled because a higher version is already installed)
+AbstractImportPage_SameVersionInstalled={0} (Disabled - item already installed)
+Column_Id=Id
+Column_Name=Name
+Column_Version=Version
+AbstractPage_ButtonSelectAll=&Select All
+AbstractPage_ButtonDeselectAll=&Deselect All
+PAGE_NOINSTALLTION_ERROR=Select at least one available element to be installed.
+ImportFromInstallationPage_DIALOG_DESCRIPTION=Import software items from the existing application installation.
+ImportFromInstallationPage_SELECT_COMPONENT=Select at least one available element to be installed.
+ImportWizard_WINDOWTITLE=Import
+ImportFromInstallationPage_INVALID_DESTINATION=Specify the path to a valid application installation.
+ImportFromInstallationPage_DIALOG_TITLE=A new profile has been created due to a detected change in your base. Eclipse will try to import your previous profile features into the new one.
+REMIND_ME_TO_MIGRATE_LATER= Remind me later.

Back to the top