Filter initial features from export wizard + sort wizards by feature id + version
--- a/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/wizard/AbstractImportExportPage.java Wed Aug 25 14:02:53 2010 -0500
+++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/wizard/AbstractImportExportPage.java Wed Aug 25 15:24:01 2010 -0500
@@ -30,6 +30,7 @@
import org.eclipse.jface.viewers.ColumnLabelProvider;
import org.eclipse.jface.viewers.ICheckStateListener;
import org.eclipse.jface.viewers.TableViewerColumn;
+import org.eclipse.jface.viewers.ViewerSorter;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
@@ -137,6 +138,7 @@
return null;
}
});
+ viewer.setSorter(new ViewerSorter());
viewer.getControl().setLayoutData(
new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL
--- a/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/wizard/ExportPage.java Wed Aug 25 14:02:53 2010 -0500
+++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/wizard/ExportPage.java Wed Aug 25 15:24:01 2010 -0500
@@ -21,6 +21,8 @@
import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -46,9 +48,11 @@
private File file;
private Collection<FeatureInfo> featureInfos;
private static String saveAsParent;
+ private Set<String> filteredFeatureIds;
- protected ExportPage() {
+ protected ExportPage(Collection<String> filteredFeatureIds) {
super("ExportPage"); //$NON-NLS-1$
+ this.filteredFeatureIds = new HashSet<String>(filteredFeatureIds);
setTitle(Messages.ExportPage_Title);
setDescription(Messages.ExportPage_Description);
}
@@ -100,14 +104,25 @@
UIJob j = new UIJob(Messages.ExportPage_GetFeaturesJobName) {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
- viewer.setInput(P2Utils.getInstalledFeatures(monitor));
+ viewer.setInput(getInstalledFeatureInfos(monitor));
updateViewer();
return Status.OK_STATUS;
- }
+ }
};
j.schedule();
}
+ private Collection<FeatureInfo> getInstalledFeatureInfos(IProgressMonitor monitor) {
+ Collection<FeatureInfo> featureInfos = new ArrayList<FeatureInfo>();
+ // filter out the filtered ids
+ for (FeatureInfo featureInfo : P2Utils.getInstalledFeatures(monitor)) {
+ if (!filteredFeatureIds.contains(featureInfo.getId()))
+ featureInfos.add(featureInfo);
+ }
+
+ return featureInfos;
+ }
+
protected boolean validatePage() {
setErrorMessage(null);
if (viewer.getTable().getItemCount() == 0) {
--- a/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/wizard/ExportWizard.java Wed Aug 25 14:02:53 2010 -0500
+++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/wizard/ExportWizard.java Wed Aug 25 15:24:01 2010 -0500
@@ -19,14 +19,24 @@
package com.nokia.carbide.internal.discovery.ui.wizard;
import java.io.File;
+import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.OutputStream;
+import java.net.URI;
+import java.net.URL;
import java.text.MessageFormat;
+import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.osgi.service.datalocation.Location;
import org.eclipse.ui.IExportWizard;
import org.eclipse.ui.IWorkbench;
@@ -61,8 +71,42 @@
public void init(IWorkbench workbench, IStructuredSelection selection) {
setDefaultPageImageDescriptor(Activator.getImageDescriptor("icons\\install_wiz.gif")); //$NON-NLS-1$
setWindowTitle(Messages.ExportWizard_Title);
- exportPage = new ExportPage();
+ exportPage = new ExportPage(getFilteredFeatureIds());
addPage(exportPage);
}
+ private Collection<String> getFilteredFeatureIds() {
+ Collection<FeatureInfo> installedFeatures = null;
+ Location installLocation = Platform.getInstallLocation();
+ URL url = installLocation.getURL();
+ IPath path = new Path(url.getPath());
+ path = path.append("configuration/installedFeatures.xml"); //$NON-NLS-1$
+ File file = path.toFile();
+ if (!file.exists()) {
+ installedFeatures = P2Utils.getInstalledFeatures(new NullProgressMonitor());
+ ImportExportData data = new ImportExportData(false, Collections.<URI>emptyList(), installedFeatures);
+ try {
+ Streamer.writeToXML(new FileOutputStream(file), data);
+ } catch (Exception e) {
+ Activator.logError("Could not write installed features file: " + file, e);
+ }
+ }
+ else {
+ try {
+ ImportExportData data = Streamer.readFromXML(new FileInputStream(file));
+ installedFeatures = data.getFeatureInfos();
+ } catch (Exception e) {
+ Activator.logError("Could not read installed features file: " + file, e);
+ }
+ }
+
+ Collection<String> filteredIds = new ArrayList<String>();
+ if (installedFeatures != null) {
+ for (FeatureInfo featureInfo : installedFeatures) {
+ filteredIds.add(featureInfo.getId());
+ }
+ }
+ return filteredIds;
+ }
+
}
--- a/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/wizard/FeatureInfo.java Wed Aug 25 14:02:53 2010 -0500
+++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/wizard/FeatureInfo.java Wed Aug 25 15:24:01 2010 -0500
@@ -70,4 +70,9 @@
return false;
return true;
}
+
+ @Override
+ public String toString() {
+ return getId() + " " + getVersion().toString();
+ }
}
\ No newline at end of file