Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormzhu2011-07-01 07:22:24 +0000
committermzhu2011-07-01 07:22:24 +0000
commit52e563602ccfd1437b99f7474a720ab55f4f389a (patch)
tree4218988ee0c2a7f58b805268a3668be6d56e5aa1
parent447707f22c716808a600a1845210d1bb783402a0 (diff)
downloadrt.equinox.p2-52e563602ccfd1437b99f7474a720ab55f4f389a.tar.gz
rt.equinox.p2-52e563602ccfd1437b99f7474a720ab55f4f389a.tar.xz
rt.equinox.p2-52e563602ccfd1437b99f7474a720ab55f4f389a.zip
merge the fix of 346401, 346406
-rwxr-xr-xbundles/org.eclipse.equinox.p2.ui.importexport/META-INF/MANIFEST.MF3
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.importexport/pom.xml2
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/ImportExportActivator.java30
-rwxr-xr-xbundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/Messages.java1
-rwxr-xr-xbundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/messages.properties1
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/wizard/AbstractImportPage.java8
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/wizard/AbstractPage.java279
-rwxr-xr-xbundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/wizard/ExportPage.java2
-rwxr-xr-xbundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/wizard/ExportWizard.java11
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/wizard/ImportFromInstallationWizard.java14
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/wizard/ImportPage.java117
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/wizard/ImportWizard.java37
12 files changed, 445 insertions, 60 deletions
diff --git a/bundles/org.eclipse.equinox.p2.ui.importexport/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.ui.importexport/META-INF/MANIFEST.MF
index aca95f575..2f1170dda 100755
--- a/bundles/org.eclipse.equinox.p2.ui.importexport/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.p2.ui.importexport/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.equinox.p2.ui.importexport;singleton:=true
-Bundle-Version: 1.0.0.qualifier
+Bundle-Version: 1.0.1.qualifier
Bundle-Vendor: %providerName
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
@@ -37,3 +37,4 @@ Import-Package: org.eclipse.equinox.internal.p2.metadata.repository.io,
Service-Component: OSGI-INF/importexport.xml
Export-Package: org.eclipse.equinox.internal.p2.importexport;version="1.3.0";x-friends:="org.eclipse.equinox.p2.tests",
org.eclipse.equinox.internal.p2.importexport.internal;x-friends:="org.eclipse.equinox.p2.tests"
+Bundle-Activator: org.eclipse.equinox.internal.p2.importexport.internal.ImportExportActivator
diff --git a/bundles/org.eclipse.equinox.p2.ui.importexport/pom.xml b/bundles/org.eclipse.equinox.p2.ui.importexport/pom.xml
index fa53b1e34..2b09fd748 100644
--- a/bundles/org.eclipse.equinox.p2.ui.importexport/pom.xml
+++ b/bundles/org.eclipse.equinox.p2.ui.importexport/pom.xml
@@ -9,6 +9,6 @@
</parent>
<groupId>org.eclipse</groupId>
<artifactId>org.eclipse.equinox.p2.ui.importexport</artifactId>
- <version>1.0.0.qualifier</version>
+ <version>1.0.1.qualifier</version>
<packaging>eclipse-plugin</packaging>
</project>
diff --git a/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/ImportExportActivator.java b/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/ImportExportActivator.java
new file mode 100644
index 000000000..a7c00c30a
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/ImportExportActivator.java
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+package org.eclipse.equinox.internal.p2.importexport.internal;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+public class ImportExportActivator extends AbstractUIPlugin {
+
+ private static ImportExportActivator instance = null;
+
+ public static ImportExportActivator getDefault() {
+ return instance;
+ }
+
+ @Override
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+
+ instance = this;
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/Messages.java b/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/Messages.java
index b09a6c563..d340f9c9e 100755
--- a/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/Messages.java
+++ b/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/Messages.java
@@ -46,6 +46,7 @@ public class Messages extends NLS {
public static String AbstractPage_ButtonDeselectAll;
public static String AbstractPage_ButtonSelectAll;
public static String ImportPage_TITLE;
+ public static String ImportWizard_CannotQuerySelection;
public static String ImportWizard_WINDOWTITLE;
public static String Page_BUTTON_BROWSER;
public static String PAGE_NOINSTALLTION_ERROR;
diff --git a/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/messages.properties b/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/messages.properties
index 4d27fc969..a72d5d82d 100755
--- a/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/messages.properties
+++ b/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/messages.properties
@@ -43,6 +43,7 @@ AbstractImportPage_SameVersionInstalled={0} (Disabled due to it has been already
AbstractPage_ButtonDeselectAll=&Deselect All
AbstractPage_ButtonSelectAll=&Select All
ImportPage_TITLE=Import Software Configuration
+ImportWizard_CannotQuerySelection=Selected software can't be found from the repository.
ImportWizard_WINDOWTITLE=Import
ImportFromInstallationPage_DESTINATION_LABEL=From &application installation:
ImportFromInstallationPage_DIALOG_TITLE=Import from Application
diff --git a/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/wizard/AbstractImportPage.java b/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/wizard/AbstractImportPage.java
index 8c1584001..81936b0c2 100644
--- a/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/wizard/AbstractImportPage.java
+++ b/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/wizard/AbstractImportPage.java
@@ -49,14 +49,14 @@ public abstract class AbstractImportPage extends AbstractPage {
@Override
protected void createInstallationTable(Composite parent) {
super.createInstallationTable(parent);
- viewer.getTable().addListener(SWT.Selection, new Listener() {
+ 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.getTable().setRedraw(false);
- ((TableItem) event.item).setChecked(false);
- viewer.getTable().setRedraw(true);
+ viewer.getTree().setRedraw(false);
+ ((TreeItem) event.item).setChecked(false);
+ viewer.getTree().setRedraw(true);
}
}
updatePageCompletion();
diff --git a/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/wizard/AbstractPage.java b/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/wizard/AbstractPage.java
index 218a6c505..abc3e788b 100644
--- a/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/wizard/AbstractPage.java
+++ b/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/wizard/AbstractPage.java
@@ -12,19 +12,25 @@
package org.eclipse.equinox.internal.p2.importexport.internal.wizard;
import java.io.File;
+import java.util.*;
+import java.util.List;
import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.jobs.IJobChangeEvent;
+import org.eclipse.core.runtime.jobs.JobChangeAdapter;
import org.eclipse.equinox.internal.p2.importexport.P2ImportExport;
import org.eclipse.equinox.internal.p2.importexport.internal.Constants;
import org.eclipse.equinox.internal.p2.importexport.internal.Messages;
import org.eclipse.equinox.internal.p2.ui.ProvUI;
import org.eclipse.equinox.internal.p2.ui.ProvUIMessages;
-import org.eclipse.equinox.internal.p2.ui.dialogs.ILayoutConstants;
+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.dialogs.IDialogSettings;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.*;
import org.eclipse.jface.wizard.WizardPage;
@@ -34,6 +40,10 @@ 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.util.tracker.ServiceTracker;
@@ -43,25 +53,99 @@ public abstract class AbstractPage extends WizardPage implements Listener {
protected Button destinationBrowseButton;
protected Combo destinationNameField;
protected P2ImportExport importexportService = null;
- protected CheckboxTableViewer viewer = null;
+ protected CheckboxTreeViewer viewer = null;
protected Exception finishException;
protected static IProfileRegistry profileRegistry = null;
- protected static IProvisioningAgent agent = null;
+ static IProvisioningAgent agent = null;
- class TableViewerComparator extends ViewerComparator {
+ // 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 viewer, Object e1, Object e2) {
+ 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 (viewer instanceof TableViewer) {
- TableViewer tableViewer = (TableViewer) viewer;
- IBaseLabelProvider baseLabel = tableViewer.getLabelProvider();
+ 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());
@@ -82,7 +166,7 @@ public abstract class AbstractPage extends WizardPage implements Listener {
// we couldn't determine a secondary sort, call it equal
return 0;
}
- return super.compare(viewer, e1, e2);
+ return super.compare(viewer1, e1, e2);
}
/**
@@ -148,10 +232,10 @@ public abstract class AbstractPage extends WizardPage implements Listener {
return null;
}
- private void createColumns(TableViewer viewer) {
+ private void createColumns(TreeViewer treeViewer) {
String[] titles = {Messages.Column_Name, Messages.Column_Version, Messages.Column_Id};
for (int i = 0; i < titles.length; i++) {
- TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE);
+ TreeViewerColumn column = new TreeViewerColumn(treeViewer, SWT.NONE);
column.getColumn().setText(titles[i]);
column.getColumn().setResizable(true);
column.getColumn().setMoveable(true);
@@ -168,14 +252,14 @@ public abstract class AbstractPage extends WizardPage implements Listener {
}
protected void updateTableSorting(int columnIndex) {
- TableViewerComparator comparator = (TableViewerComparator) viewer.getComparator();
+ 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.getTable().setSortColumn(viewer.getTable().getColumn(columnIndex));
- viewer.getTable().setSortDirection(comparator.isAscending() ? SWT.UP : SWT.DOWN);
+ viewer.getTree().setSortColumn(viewer.getTree().getColumn(columnIndex));
+ viewer.getTree().setSortDirection(comparator.isAscending() ? SWT.UP : SWT.DOWN);
viewer.refresh(false);
}
@@ -215,6 +299,7 @@ public abstract class AbstractPage extends WizardPage implements Listener {
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.addListener(SWT.Modify, this);
@@ -241,31 +326,72 @@ public abstract class AbstractPage extends WizardPage implements Listener {
griddata.verticalSpan = griddata.horizontalSpan = 0;
group.setLayoutData(griddata);
group.setLayout(new GridLayout(1, false));
- viewer = CheckboxTableViewer.newCheckList(group, SWT.MULTI | SWT.BORDER);
- final Table table = viewer.getTable();
- table.setHeaderVisible(true);
- table.setLinesVisible(false);
- viewer.setComparator(new TableViewerComparator());
+ 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);
- viewer.setContentProvider(getContentProvider());
+ 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 = table.computeSize(SWT.DEFAULT, SWT.DEFAULT);
- ScrollBar vBar = table.getVerticalBar();
- int width = area.width - table.computeTrim(0, 0, 0, 0).width - vBar.getSize().x;
- if (size.y > area.height + table.getHeaderHeight()) {
+ 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 = table.getSize();
- TableColumn[] columns = table.getColumns();
+ 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
@@ -276,12 +402,12 @@ public abstract class AbstractPage extends WizardPage implements Listener {
hasUsed += columns[i].getWidth();
}
columns[columns.length - 1].setWidth(width - hasUsed);
- table.setSize(area.width, area.height);
+ 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
- table.setSize(area.width, area.height);
+ tree.setSize(area.width, area.height);
for (; i < columns.length - 1; i++) {
columns[i].setWidth(width * columnRate[i] / 10);
hasUsed += columns[i].getWidth();
@@ -310,7 +436,7 @@ public abstract class AbstractPage extends WizardPage implements Listener {
selectAll.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- for (TableItem item : viewer.getTable().getItems()) {
+ for (TreeItem item : viewer.getTree().getItems()) {
if (!item.getChecked()) {
item.setChecked(true);
Event event = new Event();
@@ -318,7 +444,7 @@ public abstract class AbstractPage extends WizardPage implements Listener {
event.detail = SWT.CHECK;
event.item = item;
event.type = SWT.Selection;
- viewer.getTable().notifyListeners(SWT.Selection, event);
+ viewer.getTree().notifyListeners(SWT.Selection, event);
}
}
updatePageCompletion();
@@ -329,12 +455,18 @@ public abstract class AbstractPage extends WizardPage implements Listener {
deselectAll.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- viewer.setAllChecked(false);
+ for (TreeItem item : viewer.getTree().getItems()) {
+ viewer.setSubtreeChecked(item.getData(), false);
+ }
updatePageCompletion();
}
});
}
+ protected PatternFilter getPatternFilter() {
+ return new AvailableIUPatternFilter(getColumnConfig());
+ }
+
protected ICheckStateProvider getViewerDefaultState() {
return null;
}
@@ -343,8 +475,23 @@ public abstract class AbstractPage extends WizardPage implements Listener {
return new IUDetailsLabelProvider(null, getColumnConfig(), null);
}
- protected IContentProvider getContentProvider() {
- return new DeferredQueryContentProvider();
+ 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() {
@@ -451,6 +598,8 @@ public abstract class AbstractPage extends WizardPage implements Listener {
boolean pageComplete = determinePageCompletion();
setPageComplete(pageComplete);
if (pageComplete) {
+ if (this instanceof AbstractImportPage)
+ saveWidgetValues();
setMessage(null);
}
}
@@ -483,4 +632,68 @@ public abstract class AbstractPage extends WizardPage implements Listener {
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.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/wizard/ExportPage.java b/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/wizard/ExportPage.java
index 0388e6038..401594a0a 100755
--- a/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/wizard/ExportPage.java
+++ b/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/wizard/ExportPage.java
@@ -49,6 +49,8 @@ public class ExportPage extends AbstractPage {
finishException = null;
if (viewer == null)
return;
+ // about to invoke the operation so save our state
+ saveWidgetValues();
final Object[] checked = viewer.getCheckedElements();
OutputStream stream = null;
try {
diff --git a/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/wizard/ExportWizard.java b/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/wizard/ExportWizard.java
index 5a18d537b..86986aa78 100755
--- a/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/wizard/ExportWizard.java
+++ b/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/wizard/ExportWizard.java
@@ -12,8 +12,8 @@ package org.eclipse.equinox.internal.p2.importexport.internal.wizard;
import java.io.File;
import org.eclipse.core.runtime.Platform;
-import org.eclipse.equinox.internal.p2.importexport.internal.Constants;
-import org.eclipse.equinox.internal.p2.importexport.internal.Messages;
+import org.eclipse.equinox.internal.p2.importexport.internal.*;
+import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.IStructuredSelection;
@@ -24,6 +24,13 @@ import org.eclipse.ui.IWorkbench;
public class ExportWizard extends AbstractWizard implements IExportWizard {
public ExportWizard() {
+ IDialogSettings workbenchSettings = ImportExportActivator.getDefault().getDialogSettings();
+ String sectionName = "ExportWizard"; //$NON-NLS-1$
+ IDialogSettings section = workbenchSettings.getSection(sectionName);
+ if (section == null) {
+ section = workbenchSettings.addNewSection(sectionName);
+ }
+ setDialogSettings(section);
}
@Override
diff --git a/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/wizard/ImportFromInstallationWizard.java b/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/wizard/ImportFromInstallationWizard.java
index 38ccc6230..6b89c6488 100644
--- a/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/wizard/ImportFromInstallationWizard.java
+++ b/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/wizard/ImportFromInstallationWizard.java
@@ -12,8 +12,7 @@ package org.eclipse.equinox.internal.p2.importexport.internal.wizard;
import java.util.Collection;
import org.eclipse.core.runtime.Platform;
-import org.eclipse.equinox.internal.p2.importexport.internal.Constants;
-import org.eclipse.equinox.internal.p2.importexport.internal.Messages;
+import org.eclipse.equinox.internal.p2.importexport.internal.*;
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;
@@ -22,6 +21,7 @@ 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;
@@ -35,6 +35,13 @@ public class ImportFromInstallationWizard extends InstallWizard implements IImpo
public ImportFromInstallationWizard(ProvisioningUI ui, InstallOperation operation, Collection<IInstallableUnit> initialSelections, LoadMetadataRepositoryJob preloadJob) {
super(ui, operation, initialSelections, preloadJob);
+ IDialogSettings workbenchSettings = ImportExportActivator.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) {
@@ -44,8 +51,7 @@ public class ImportFromInstallationWizard extends InstallWizard implements IImpo
}
@Override
- protected ISelectableIUsPage createMainPage(IUElementListRoot input,
- Object[] selections) {
+ protected ISelectableIUsPage createMainPage(IUElementListRoot input, Object[] selections) {
return new ImportFromInstallationPage(ui, this);
}
diff --git a/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/wizard/ImportPage.java b/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/wizard/ImportPage.java
index e00f55f02..c673b442b 100644
--- a/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/wizard/ImportPage.java
+++ b/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/wizard/ImportPage.java
@@ -23,6 +23,7 @@ import org.eclipse.equinox.internal.p2.ui.ProvUI;
import org.eclipse.equinox.internal.p2.ui.ProvUIMessages;
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.viewers.IUColumnConfig;
import org.eclipse.equinox.p2.core.ProvisionException;
import org.eclipse.equinox.p2.engine.ProvisioningContext;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
@@ -41,10 +42,11 @@ import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;
+import org.eclipse.ui.dialogs.PatternFilter;
public class ImportPage extends AbstractImportPage implements ISelectableIUsPage {
- private class InstallationContentProvider implements IStructuredContentProvider {
+ class InstallationContentProvider implements ITreeContentProvider {
public void dispose() {
//
@@ -54,13 +56,25 @@ public class ImportPage extends AbstractImportPage implements ISelectableIUsPage
return (Object[]) inputElement;
}
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ public void inputChanged(Viewer viewer1, Object oldInput, Object newInput) {
//
}
+ public Object[] getChildren(Object parentElement) {
+ return new Object[0];
+ }
+
+ public Object getParent(Object element) {
+ return null;
+ }
+
+ public boolean hasChildren(Object element) {
+ return false;
+ }
+
}
- private class InstallationLabelProvider extends LabelProvider implements ITableLabelProvider, IColorProvider {
+ class InstallationLabelProvider extends LabelProvider implements ITableLabelProvider, IColorProvider {
public Image getColumnImage(Object element, int columnIndex) {
return null;
@@ -92,6 +106,89 @@ public class ImportPage extends AbstractImportPage implements ISelectableIUsPage
}
}
+ class P2ImportIUPatternFilter extends PatternFilter {
+
+ boolean checkName, checkVersion, checkId = false;
+ String patternString;
+
+ /**
+ * Create a new instance of a AvailableIUPatternFilter
+ */
+ public P2ImportIUPatternFilter(IUColumnConfig[] columnConfig) {
+ super();
+ for (int i = 0; i < columnConfig.length; i++) {
+ int field = columnConfig[i].getColumnType();
+ if (field == IUColumnConfig.COLUMN_ID)
+ checkId = true;
+ else if (field == IUColumnConfig.COLUMN_NAME)
+ checkName = true;
+ else if (field == IUColumnConfig.COLUMN_VERSION)
+ checkVersion = true;
+ }
+
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.internal.dialogs.PatternFilter#isElementSelectable(java.lang.Object)
+ */
+ public boolean isElementSelectable(Object element) {
+ return element instanceof IUDetail;
+ }
+
+ /*
+ * Overridden to remember the pattern string for an optimization
+ * in isParentMatch
+ * (non-Javadoc)
+ * @see org.eclipse.ui.dialogs.PatternFilter#setPattern(java.lang.String)
+ */
+ public void setPattern(String patternString) {
+ super.setPattern(patternString);
+ this.patternString = patternString;
+ }
+
+ /*
+ * Overridden to avoid getting children unless there is actually
+ * a filter.
+ * (non-Javadoc)
+ * @see org.eclipse.ui.dialogs.PatternFilter#isParentMatch(org.eclipse.jface.viewers.Viewer, java.lang.Object)
+ */
+ protected boolean isParentMatch(Viewer viewer1, Object element) {
+ if (patternString == null || patternString.length() == 0)
+ return true;
+ return super.isParentMatch(viewer1, element);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.dialogs.PatternFilter#isElementMatch(org.eclipse.jface.viewers.Viewer, java.lang.Object)
+ */
+ protected boolean isLeafMatch(Viewer viewer1, Object element) {
+ String text = null;
+ if (element instanceof IUDetail) {
+ IInstallableUnit iu = ((IUDetail) element).getIU();
+ if (checkName) {
+ // Get the iu name in the default locale
+ text = iu.getProperty(IInstallableUnit.PROP_NAME, null);
+ if (text != null && wordMatches(text))
+ return true;
+ }
+ if (checkId || (checkName && text == null)) {
+ text = iu.getId();
+ if (wordMatches(text)) {
+ return true;
+ }
+ }
+ if (checkVersion) {
+ text = iu.getVersion().toString();
+ if (wordMatches(text))
+ return true;
+ }
+ }
+ return false;
+ }
+
+ }
+
private List<IUDetail> features;
private final List<URI> loadRepos = new ArrayList<URI>();
private final Map<IUDetail, IUDetail[]> newProposedFeature = new HashMap<IUDetail, IUDetail[]>();
@@ -128,7 +225,7 @@ public class ImportPage extends AbstractImportPage implements ISelectableIUsPage
}
@Override
- protected IContentProvider getContentProvider() {
+ protected ITreeContentProvider getContentProvider() {
return new InstallationContentProvider();
}
@@ -213,12 +310,12 @@ public class ImportPage extends AbstractImportPage implements ISelectableIUsPage
public Object[] getCheckedIUElements() {
Object[] checked = viewer.getCheckedElements();
- List<IUDetail> features = new ArrayList<IUDetail>(checked.length);
+ List<IUDetail> checkedFeatures = new ArrayList<IUDetail>(checked.length);
for (int i = 0; i < checked.length; i++) {
IUDetail feature = (IUDetail) checked[i];
IUDetail[] existingFeatures = newProposedFeature.get(feature);
if (existingFeatures == null)
- features.add(feature);
+ checkedFeatures.add(feature);
else {
IUDetail matchPolicy = null;
for (IUDetail f : existingFeatures) {
@@ -234,10 +331,10 @@ public class ImportPage extends AbstractImportPage implements ISelectableIUsPage
matchPolicy = f;
}
if (matchPolicy != null)
- features.add(matchPolicy);
+ checkedFeatures.add(matchPolicy);
}
}
- return features.toArray(new IUDetail[features.size()]);
+ return checkedFeatures.toArray(new IUDetail[checkedFeatures.size()]);
}
public Object[] getSelectedIUElements() {
@@ -345,4 +442,8 @@ public class ImportPage extends AbstractImportPage implements ISelectableIUsPage
}
}
}
+
+ protected PatternFilter getPatternFilter() {
+ return new P2ImportIUPatternFilter(getColumnConfig());
+ }
} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/wizard/ImportWizard.java b/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/wizard/ImportWizard.java
index 1fc36a86c..fa8b88ac8 100644
--- a/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/wizard/ImportWizard.java
+++ b/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/wizard/ImportWizard.java
@@ -12,10 +12,10 @@
package org.eclipse.equinox.internal.p2.importexport.internal.wizard;
import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
import java.util.Collection;
import org.eclipse.core.runtime.*;
-import org.eclipse.equinox.internal.p2.importexport.internal.Constants;
-import org.eclipse.equinox.internal.p2.importexport.internal.Messages;
+import org.eclipse.equinox.internal.p2.importexport.internal.*;
import org.eclipse.equinox.internal.p2.ui.ProvUI;
import org.eclipse.equinox.internal.p2.ui.ProvUIMessages;
import org.eclipse.equinox.internal.p2.ui.dialogs.ISelectableIUsPage;
@@ -24,8 +24,10 @@ import org.eclipse.equinox.internal.p2.ui.model.IUElementListRoot;
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.operations.ProvisioningSession;
import org.eclipse.equinox.p2.ui.LoadMetadataRepositoryJob;
import org.eclipse.equinox.p2.ui.ProvisioningUI;
+import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.operation.IRunnableContext;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.resource.ImageDescriptor;
@@ -43,6 +45,13 @@ public class ImportWizard extends InstallWizard implements IImportWizard {
public ImportWizard(ProvisioningUI ui, InstallOperation operation, Collection<IInstallableUnit> initialSelections, LoadMetadataRepositoryJob preloadJob) {
super(ui, operation, initialSelections, preloadJob);
+ IDialogSettings workbenchSettings = ImportExportActivator.getDefault().getDialogSettings();
+ String sectionName = "ImportWizard"; //$NON-NLS-1$
+ IDialogSettings section = workbenchSettings.getSection(sectionName);
+ if (section == null) {
+ section = workbenchSettings.addNewSection(sectionName);
+ }
+ setDialogSettings(section);
}
public void init(IWorkbench workbench, IStructuredSelection selection) {
@@ -73,7 +82,7 @@ public class ImportWizard extends InstallWizard implements IImportWizard {
try {
runnableContext.run(true, true, new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InterruptedException {
- SubMonitor sub = SubMonitor.convert(monitor, 1000);
+ final SubMonitor sub = SubMonitor.convert(monitor, 1000);
((ImportPage) mainPage).recompute(sub.newChild(800));
if (sub.isCanceled())
throw new InterruptedException();
@@ -83,8 +92,17 @@ public class ImportWizard extends InstallWizard implements IImportWizard {
ProvisioningContext context = getProvisioningContext();
initializeResolutionModelElements(getOperationSelections());
if (planSelections.length == 0) {
- operation = null;
- unableToResolve(ProvUIMessages.ResolutionWizardPage_NoSelections);
+ operation = new InstallOperation(new ProvisioningSession(((ImportPage) mainPage).agent), new ArrayList<IInstallableUnit>()) {
+ protected void computeProfileChangeRequest(MultiStatus status, IProgressMonitor monitor) {
+ monitor.done();
+ };
+
+ public IStatus getResolutionResult() {
+ if (sub.isCanceled())
+ return Status.CANCEL_STATUS;
+ return new Status(IStatus.ERROR, Constants.Bundle_ID, Messages.ImportWizard_CannotQuerySelection);
+ }
+ };
} else {
operation = getProfileChangeOperation(planSelections);
operation.setProvisioningContext(context);
@@ -93,7 +111,8 @@ public class ImportWizard extends InstallWizard implements IImportWizard {
});
if (sub.isCanceled())
throw new InterruptedException();
- operation.resolveModal(sub.newChild(200));
+ if (operation.resolveModal(sub.newChild(200)).getSeverity() == IStatus.CANCEL)
+ throw new InterruptedException();
Display.getDefault().asyncExec(new Runnable() {
public void run() {
@@ -103,7 +122,11 @@ public class ImportWizard extends InstallWizard implements IImportWizard {
}
});
} catch (InterruptedException e) {
- // Nothing to report if thread was interrupted
+ operation = new InstallOperation(new ProvisioningSession(AbstractPage.agent), new ArrayList<IInstallableUnit>()) {
+ public IStatus getResolutionResult() {
+ return Status.CANCEL_STATUS;
+ }
+ };
} catch (InvocationTargetException e) {
ProvUI.handleException(e.getCause(), null, StatusManager.SHOW | StatusManager.LOG);
unableToResolve(null);

Back to the top