--- a/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/discovery/ui/Messages.java Fri Aug 13 08:37:37 2010 -0500
+++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/discovery/ui/Messages.java Fri Aug 13 11:58:38 2010 -0500
@@ -39,13 +39,57 @@
public static String AbstractDiscoveryPortalPageLayer_GatheringInstallInfoDesc;
public static String AbstractDiscoveryPortalPageLayer_InstallActionLabel;
public static String AbstractDiscoveryPortalPageLayer_InstallActionTooltip;
+ public static String AbstractDiscoveryPortalPageLayer_P2InstallWizardOpenError;
public static String AbstractDiscoveryPortalPageLayer_RefreshActionLabel;
public static String AbstractDiscoveryPortalPageLayer_Title;
public static String AbstractDiscoveryPortalPageLayer_UncheckAllActionLabel;
+ public static String AbstractImportExportPage_BrowseButtonLabel;
+ public static String AbstractImportExportPage_CheckAllLabel;
+ public static String AbstractImportExportPage_CheckNoneLabel;
+ public static String AbstractImportExportPage_FeatureColTitle;
+ public static String AbstractImportExportPage_VersionColTitle;
public static String AbstractRSSPortalPageLayer_ReturnToFeedLabel;
public static String AbstractRSSPortalPageLayer_RSSReadError;
public static String Activator_GetProxyInfoJobTitle;
public static String Activator_MissingConfigURLError;
+ public static String ExportPage_BrowseGroupLabel;
+ public static String ExportPage_Description;
+ public static String ExportPage_FileDialogText;
+ public static String ExportPage_FileOverwriteWarning;
+ public static String ExportPage_GetFeaturesJobName;
+ public static String ExportPage_NoFeaturesError;
+ public static String ExportPage_NoFeaturesSelectedError;
+ public static String ExportPage_NoFileError;
+ public static String ExportPage_Title;
+ public static String ExportPage_ViewerGroupLabel;
+ public static String ExportWizard_ErrorTitle;
+ public static String ExportWizard_Title;
+ public static String ExportWizard_WriteFileError;
+ public static String FeatureInstallOperation_ConfiguringTaskName;
+ public static String FeatureInstallOperation_IdLabel;
+ public static String FeatureInstallOperation_MissingFeaturesError;
+ public static String FeatureInstallOperation_VersionLabel;
+ public static String ImportPage_AllFilesFilterName;
+ public static String ImportPage_BrowseGroupLabel;
+ public static String ImportPage_Description;
+ public static String ImportPage_FileDialogText;
+ public static String ImportPage_NoFeaturesSelectedError;
+ public static String ImportPage_NoValidFeaturesInFileError;
+ public static String ImportPage_NoValidFileError;
+ public static String ImportPage_NoValidReposInFileError;
+ public static String ImportPage_OriginalVersionCheckLabel;
+ public static String ImportPage_ReadFileError;
+ public static String ImportPage_ReadFileJobName;
+ public static String ImportPage_Title;
+ public static String ImportPage_ViewerGroupLabel;
+ public static String ImportPage_XMLFileFilterName;
+ public static String ImportWizard_ErrorTitle;
+ public static String ImportWizard_ImportFailedError;
+ public static String ImportWizard_InstallErrorSimple;
+ public static String ImportWizard_Title;
+ public static String InstallExtensionsPortalExtension_ExportActionLabel;
+ public static String InstallExtensionsPortalExtension_ImportActionLabel;
+ public static String InstallExtensionsPortalExtension_MigrateTitle;
public static String PortalEditor_BadCommandBarFactoryError;
public static String PortalEditor_Name;
public static String PortalEditor_NoLayersError;
@@ -57,6 +101,10 @@
public static String SettingsBarCreator_KeyBindingsActionLabel;
public static String SettingsBarCreator_ProxiesActionLabel;
public static String SettingsBarCreator_Title;
+ public static String SimpleRSSReader_BadURLError;
+ public static String Streamer_BadURIError;
+ public static String Streamer_BadVersionError;
+ public static String Streamer_VersionParseError;
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
--- a/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/discovery/ui/messages.properties Fri Aug 13 08:37:37 2010 -0500
+++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/discovery/ui/messages.properties Fri Aug 13 11:58:38 2010 -0500
@@ -17,13 +17,57 @@
AbstractDiscoveryPortalPageLayer_GatheringInstallInfoDesc=Gathering Install Information
AbstractDiscoveryPortalPageLayer_InstallActionLabel=Install...
AbstractDiscoveryPortalPageLayer_InstallActionTooltip=Install selected items
+AbstractDiscoveryPortalPageLayer_P2InstallWizardOpenError=Could not open install wizard
AbstractDiscoveryPortalPageLayer_RefreshActionLabel=Refresh
AbstractDiscoveryPortalPageLayer_Title=Install Extensions
AbstractDiscoveryPortalPageLayer_UncheckAllActionLabel=Deselect all
+AbstractImportExportPage_BrowseButtonLabel=Browse...
+AbstractImportExportPage_CheckAllLabel=Select All
+AbstractImportExportPage_CheckNoneLabel=Deselect All
+AbstractImportExportPage_FeatureColTitle=Feature
+AbstractImportExportPage_VersionColTitle=Version
AbstractRSSPortalPageLayer_ReturnToFeedLabel=Return to RSS
AbstractRSSPortalPageLayer_RSSReadError=Could not read RSS from: {0}
Activator_GetProxyInfoJobTitle=Getting proxy info
Activator_MissingConfigURLError=Could not find URL in configuration/server.properties file for key={0}
+ExportPage_BrowseGroupLabel=Export file:
+ExportPage_Description=Create an export file with the selected feature configuration
+ExportPage_FileDialogText=Save As
+ExportPage_FileOverwriteWarning=File exists at selected location and will be overwritten
+ExportPage_GetFeaturesJobName=Getting Installed Features
+ExportPage_NoFeaturesError=There are no features to export
+ExportPage_NoFeaturesSelectedError=At least one feature must be selected for export
+ExportPage_NoFileError=A file must be selected in order to export features
+ExportPage_Title=Export Installed Feature Configuration
+ExportPage_ViewerGroupLabel=Export features:
+ExportWizard_ErrorTitle=Error
+ExportWizard_Title=Export
+ExportWizard_WriteFileError=Could not write export file due to error: {0}
+FeatureInstallOperation_ConfiguringTaskName=Configuring install operation
+FeatureInstallOperation_IdLabel=id=
+FeatureInstallOperation_MissingFeaturesError=Install failed. Could not find some features: \n
+FeatureInstallOperation_VersionLabel=version=
+ImportPage_AllFilesFilterName=All Files
+ImportPage_BrowseGroupLabel=Import file:
+ImportPage_Description=Import a feature configurations from a file and install the features
+ImportPage_FileDialogText=Select an Exported Feature Configuration File
+ImportPage_NoFeaturesSelectedError=At least one feature must be selected for import
+ImportPage_NoValidFeaturesInFileError=No valid features found in configurations file
+ImportPage_NoValidFileError=A valid exported feature configuration file must be selected
+ImportPage_NoValidReposInFileError=No valid repositories found in configurations file
+ImportPage_OriginalVersionCheckLabel=Attempt import original feature versions
+ImportPage_ReadFileError=Could not read data from file: {0}
+ImportPage_ReadFileJobName=Reading Feature Configuration File
+ImportPage_Title=Import Feature Configuration and Install
+ImportPage_ViewerGroupLabel=Import Features:
+ImportPage_XMLFileFilterName=XML Files
+ImportWizard_ErrorTitle=Error
+ImportWizard_ImportFailedError=Import operation failed
+ImportWizard_InstallErrorSimple=Could not install due to error: {0}
+ImportWizard_Title=Import Installed Feature Configuration
+InstallExtensionsPortalExtension_ExportActionLabel=Export...
+InstallExtensionsPortalExtension_ImportActionLabel=Import...
+InstallExtensionsPortalExtension_MigrateTitle=Migrate
PortalEditor_BadCommandBarFactoryError=Command bar factory class could not be created for id: {0
PortalEditor_Name=Carbide.c++ Portal
PortalEditor_NoLayersError=Could not load portal page because no layers were found for id: {0}
@@ -35,3 +79,7 @@
SettingsBarCreator_KeyBindingsActionLabel=Key bindings
SettingsBarCreator_ProxiesActionLabel=Proxies
SettingsBarCreator_Title=Settings
+SimpleRSSReader_BadURLError=Bad URL
+Streamer_BadURIError=Could not parse URI: {0}
+Streamer_BadVersionError=Can only read version {0} of <{1}>
+Streamer_VersionParseError=Could not parse version: {0}
--- a/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/editor/SimpleRSSReader.java Fri Aug 13 08:37:37 2010 -0500
+++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/editor/SimpleRSSReader.java Fri Aug 13 11:58:38 2010 -0500
@@ -38,6 +38,7 @@
import org.xml.sax.helpers.DefaultHandler;
import com.nokia.carbide.discovery.ui.Activator;
+import com.nokia.carbide.discovery.ui.Messages;
/**
* A simple RSS reader
@@ -96,7 +97,7 @@
link = new URL(value);
} catch (MalformedURLException e) {
// don't store malformed URLs
- Activator.logError("Bad URL", e);
+ Activator.logError(Messages.SimpleRSSReader_BadURLError, e);
}
}
else if (RSSHandler.DESCRIPTION.equalsIgnoreCase(element) || RSSHandler.SUMMARY.equalsIgnoreCase(element))
--- a/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/extension/AbstractDiscoveryPortalPageLayer.java Fri Aug 13 08:37:37 2010 -0500
+++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/extension/AbstractDiscoveryPortalPageLayer.java Fri Aug 13 11:58:38 2010 -0500
@@ -306,9 +306,9 @@
IHandlerService handlerService =
(IHandlerService) PlatformUI.getWorkbench().getService(IHandlerService.class);
try {
- handlerService.executeCommand("org.eclipse.equinox.p2.ui.sdk.install", null);
+ handlerService.executeCommand("org.eclipse.equinox.p2.ui.sdk.install", null); //$NON-NLS-1$
} catch (Exception e) {
- Activator.logError("Could not open install wizard", e);
+ Activator.logError(Messages.AbstractDiscoveryPortalPageLayer_P2InstallWizardOpenError, e);
}
}
--- a/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/extension/AbstractRSSPortalPageLayer.java Fri Aug 13 08:37:37 2010 -0500
+++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/extension/AbstractRSSPortalPageLayer.java Fri Aug 13 11:58:38 2010 -0500
@@ -144,7 +144,7 @@
if (date != null) {
String dateString = DateFormat.getDateTimeInstance().format(date);
buf.append(dateString);
- buf.append("<br>");
+ buf.append("<br>"); //$NON-NLS-1$
}
buf.append(clean(item.getDescription()));
buf.append("</div></li>"); //$NON-NLS-1$
--- a/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/view/InstallExtensionsPortalExtension.java Fri Aug 13 08:37:37 2010 -0500
+++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/view/InstallExtensionsPortalExtension.java Fri Aug 13 11:58:38 2010 -0500
@@ -31,6 +31,7 @@
import org.eclipse.ui.IWorkbenchWizard;
import org.eclipse.ui.PlatformUI;
+import com.nokia.carbide.discovery.ui.Messages;
import com.nokia.carbide.internal.discovery.ui.extension.AbstractDiscoveryPortalPageLayer;
import com.nokia.carbide.internal.discovery.ui.extension.IActionBar;
import com.nokia.carbide.internal.discovery.ui.extension.IActionUIUpdater;
@@ -42,7 +43,7 @@
private final class MigrateBar implements IActionBar {
@Override
public String getTitle() {
- return "Migrate";
+ return Messages.InstallExtensionsPortalExtension_MigrateTitle;
}
@Override
@@ -53,13 +54,13 @@
@Override
public IAction[] getActions() {
List<IAction> actions = new ArrayList<IAction>();
- actions.add(new Action("Export...") {
+ actions.add(new Action(Messages.InstallExtensionsPortalExtension_ExportActionLabel) {
@Override
public void run() {
showWizard(new ExportWizard());
}
});
- actions.add(new Action("Import...") {
+ actions.add(new Action(Messages.InstallExtensionsPortalExtension_ImportActionLabel) {
@Override
public void run() {
showWizard(new ImportWizard());
--- a/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/wizard/AbstractImportExportPage.java Fri Aug 13 08:37:37 2010 -0500
+++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/wizard/AbstractImportExportPage.java Fri Aug 13 11:58:38 2010 -0500
@@ -44,6 +44,7 @@
import org.eclipse.swt.widgets.Text;
import com.nokia.carbide.discovery.ui.Activator;
+import com.nokia.carbide.discovery.ui.Messages;
/**
* Abstract superclass of import and export page
@@ -92,7 +93,7 @@
}
});
browseButton = new Button(composite, SWT.PUSH);
- browseButton.setText("Browse...");
+ browseButton.setText(Messages.AbstractImportExportPage_BrowseButtonLabel);
browseButton
.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
setButtonLayoutData(browseButton);
@@ -108,7 +109,7 @@
viewer = CheckboxTableViewer.newCheckList(parent, SWT.BORDER);
TableViewerColumn featureColumn = new TableViewerColumn(viewer,
SWT.CENTER);
- featureColumn.getColumn().setText("Feature");
+ featureColumn.getColumn().setText(Messages.AbstractImportExportPage_FeatureColTitle);
featureColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public Image getImage(Object element) {
@@ -124,7 +125,7 @@
});
TableViewerColumn versionColumn = new TableViewerColumn(viewer,
SWT.CENTER);
- versionColumn.getColumn().setText("Version");
+ versionColumn.getColumn().setText(Messages.AbstractImportExportPage_VersionColTitle);
versionColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
@@ -146,7 +147,7 @@
.applyTo(buttonComposite);
buttonComposite.setLayout(new GridLayout());
Button checkAllButton = new Button(buttonComposite, SWT.PUSH);
- checkAllButton.setText("Select All");
+ checkAllButton.setText(Messages.AbstractImportExportPage_CheckAllLabel);
setButtonLayoutData(checkAllButton);
checkAllButton.addSelectionListener(new SelectionAdapter() {
@Override
@@ -155,7 +156,7 @@
}
});
Button checkNoneButton = new Button(buttonComposite, SWT.PUSH);
- checkNoneButton.setText("Deselect All");
+ checkNoneButton.setText(Messages.AbstractImportExportPage_CheckNoneLabel);
setButtonLayoutData(checkNoneButton);
checkNoneButton.addSelectionListener(new SelectionAdapter() {
@Override
--- a/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/wizard/ExportPage.java Fri Aug 13 08:37:37 2010 -0500
+++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/wizard/ExportPage.java Fri Aug 13 11:58:38 2010 -0500
@@ -37,6 +37,7 @@
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.ui.progress.UIJob;
+import com.nokia.carbide.discovery.ui.Messages;
import com.nokia.cpp.internal.api.utils.ui.BrowseDialogUtils;
/**
@@ -50,16 +51,16 @@
protected ExportPage() {
super("ExportPage"); //$NON-NLS-1$
- setTitle("Export Installed Feature Configuration");
- setDescription("Create an export file with the selected feature configuration");
+ setTitle(Messages.ExportPage_Title);
+ setDescription(Messages.ExportPage_Description);
}
public void createControl(Composite parent) {
super.createControl(parent);
Composite composite = (Composite) getControl();
- createViewerGroup(composite, "Export features:");
- createBrowseGroup(composite, "Export file:");
+ createViewerGroup(composite, Messages.ExportPage_ViewerGroupLabel);
+ createBrowseGroup(composite, Messages.ExportPage_BrowseGroupLabel);
featureInfos = new ArrayList<FeatureInfo>();
@@ -90,7 +91,7 @@
@Override
public void widgetSelected(SelectionEvent e) {
FileDialog dialog = new FileDialog(getShell(), SWT.SAVE);
- dialog.setText("Save As");
+ dialog.setText(Messages.ExportPage_FileDialogText);
BrowseDialogUtils.initializeFrom(dialog, pathText.getText());
dialog.setOverwrite(true); // prompt for overwrite
String path = dialog.open();
@@ -104,7 +105,7 @@
}
private void startGetInputJob() {
- UIJob j = new UIJob("Getting Installed Features") {
+ UIJob j = new UIJob(Messages.ExportPage_GetFeaturesJobName) {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
viewer.setInput(P2Utils.getInstalledFeatures(monitor));
@@ -118,22 +119,22 @@
protected boolean validatePage() {
setErrorMessage(null);
if (viewer.getTable().getItemCount() == 0) {
- setErrorMessage("There are no features to export");
+ setErrorMessage(Messages.ExportPage_NoFeaturesError);
return false;
}
if (viewer.getCheckedElements().length == 0) {
- setErrorMessage("At least one feature must be selected for export");
+ setErrorMessage(Messages.ExportPage_NoFeaturesSelectedError);
return false;
}
IPath path = new Path(pathText.getText());
file = path.toFile();
if (!file.isAbsolute()) {
- setErrorMessage("A file must be selected in order to export features");
+ setErrorMessage(Messages.ExportPage_NoFileError);
return false;
}
if (file.exists()) {
- setMessage("File exists at selected location and will be overwritten", DialogPage.WARNING);
+ setMessage(Messages.ExportPage_FileOverwriteWarning, DialogPage.WARNING);
}
return true;
--- a/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/wizard/ExportWizard.java Fri Aug 13 08:37:37 2010 -0500
+++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/wizard/ExportWizard.java Fri Aug 13 11:58:38 2010 -0500
@@ -31,6 +31,7 @@
import org.eclipse.ui.IWorkbench;
import com.nokia.carbide.discovery.ui.Activator;
+import com.nokia.carbide.discovery.ui.Messages;
/**
* Wizard for exporting installed features to a file
@@ -51,15 +52,15 @@
ImportExportData data = new ImportExportData(false, P2Utils.getKnownRepositories(), featureInfos);
Streamer.writeToXML(os, data);
} catch (Exception e) {
- MessageDialog.openError(getShell(), "Error",
- MessageFormat.format("Could not write export file due to error: {0}", e.getLocalizedMessage()));
+ MessageDialog.openError(getShell(), Messages.ExportWizard_ErrorTitle,
+ MessageFormat.format(Messages.ExportWizard_WriteFileError, e.getMessage()));
}
return true;
}
public void init(IWorkbench workbench, IStructuredSelection selection) {
setDefaultPageImageDescriptor(Activator.getImageDescriptor("icons\\install_wiz.gif")); //$NON-NLS-1$
- setWindowTitle("Export");
+ setWindowTitle(Messages.ExportWizard_Title);
exportPage = new ExportPage();
addPage(exportPage);
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/wizard/FeatureInstallOperation.java Fri Aug 13 11:58:38 2010 -0500
@@ -0,0 +1,168 @@
+/*
+ * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+package com.nokia.carbide.internal.discovery.ui.wizard;
+
+import java.lang.reflect.InvocationTargetException;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.SubMonitor;
+import org.eclipse.equinox.p2.core.ProvisionException;
+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.operations.RepositoryTracker;
+import org.eclipse.equinox.p2.query.IQuery;
+import org.eclipse.equinox.p2.query.IQueryResult;
+import org.eclipse.equinox.p2.query.QueryUtil;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
+import org.eclipse.equinox.p2.ui.ProvisioningUI;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.swt.widgets.Display;
+
+import com.nokia.carbide.discovery.ui.Messages;
+
+public class FeatureInstallOperation implements IRunnableWithProgress {
+
+ private Collection<URI> uris;
+ private Collection<FeatureInfo> featureInfos;
+ private boolean wantVersions;
+ private ProvisioningUI provisioningUI;
+ private Collection<IMetadataRepository> repositories;
+ private Collection<IInstallableUnit> ius;
+ private Collection<URI> urisUsed;
+
+ public FeatureInstallOperation(Collection<URI> uris, Collection<FeatureInfo> featureInfos, boolean wantVersions) {
+ this.uris = uris;
+ this.featureInfos = featureInfos;
+ this.wantVersions = wantVersions;
+ provisioningUI = ProvisioningUI.getDefaultUI();
+ }
+
+ @Override
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ try {
+ doInstall(monitor);
+ } catch (OperationCanceledException e) {
+ throw new InterruptedException();
+ } catch (CoreException e) {
+ throw new InvocationTargetException(e);
+ }
+ }
+
+ public void doInstall(IProgressMonitor monitor) throws OperationCanceledException, CoreException {
+ SubMonitor subMonitor = SubMonitor.convert(monitor, Messages.FeatureInstallOperation_ConfiguringTaskName, 100);
+ getRepositories(subMonitor.newChild(30));
+ findInstallableUnits(subMonitor.newChild(40));
+ final InstallOperation operation = resolve(subMonitor.newChild(30));
+ Display.getDefault().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ provisioningUI.openInstallWizard(ius, operation, null);
+ }
+ });
+ }
+
+ private void getRepositories(SubMonitor monitor) throws ProvisionException, OperationCanceledException {
+ monitor.setWorkRemaining(uris.size());
+ repositories = new ArrayList<IMetadataRepository>();
+ ProvisioningSession session = provisioningUI.getSession();
+ RepositoryTracker repositoryTracker = provisioningUI.getRepositoryTracker();
+ IMetadataRepositoryManager manager =
+ (IMetadataRepositoryManager) session.getProvisioningAgent().getService(IMetadataRepositoryManager.SERVICE_NAME);
+ for (URI uri : uris) {
+ checkIfCanceled(monitor);
+ repositoryTracker.addRepository(uri, null, session);
+ repositories.add(manager.loadRepository(uri, monitor.newChild(1)));
+ }
+ }
+
+ private void findInstallableUnits(SubMonitor monitor) throws ProvisionException {
+ monitor.setWorkRemaining(repositories.size() * featureInfos.size());
+ ius = new ArrayList<IInstallableUnit>();
+ urisUsed = new HashSet<URI>();
+ Set<FeatureInfo> remainingInfos = new HashSet<FeatureInfo>(featureInfos);
+ for (IMetadataRepository repository : repositories) {
+ checkIfCanceled(monitor);
+ IQueryResult<IInstallableUnit> iusInRepository = repository.query(QueryUtil.createIUGroupQuery(), monitor.newChild(1));
+ for (FeatureInfo featureInfo : new HashSet<FeatureInfo>(remainingInfos)) {
+ String id = featureInfo.getId();
+ IQuery<IInstallableUnit> iuQuery = wantVersions ?
+ QueryUtil.createIUQuery(id, featureInfo.getVersion()) :
+ QueryUtil.createLatestQuery(QueryUtil.createIUQuery(id));
+ IQueryResult<IInstallableUnit> result = iusInRepository.query(iuQuery, monitor.newChild(1));
+ if (!result.isEmpty()) {
+ ius.add(result.iterator().next());
+ urisUsed.add(repository.getLocation());
+ remainingInfos.remove(featureInfo);
+ if (remainingInfos.isEmpty())
+ break;
+ }
+ }
+ }
+
+ if (!remainingInfos.isEmpty()) {
+ StringBuilder sb = new StringBuilder();
+ sb.append(Messages.FeatureInstallOperation_MissingFeaturesError);
+ for (FeatureInfo featureInfo : remainingInfos) {
+ sb.append(Messages.FeatureInstallOperation_IdLabel);
+ sb.append(featureInfo.getId());
+ if (wantVersions) {
+ sb.append(Messages.FeatureInstallOperation_VersionLabel);
+ sb.append(featureInfo.getVersion().toString());
+ }
+ sb.append("\n"); //$NON-NLS-1$
+ }
+ throw new ProvisionException(sb.toString());
+ }
+ monitor.done();
+ }
+
+// private FeatureInfo findInfo(Collection<FeatureInfo> featureInfos, String id, Version version) {
+// for (FeatureInfo featureInfo : featureInfos) {
+// boolean sameId = featureInfo.getId().equals(id);
+// if (sameId && (!wantVersions || version.toString().equals(featureInfo.getVersion().toString())))
+// return featureInfo;
+// }
+// return null;
+// }
+
+ private InstallOperation resolve(SubMonitor monitor) throws CoreException {
+ checkIfCanceled(monitor);
+ URI[] uris = (URI[]) urisUsed.toArray(new URI[urisUsed.size()]);
+ InstallOperation installOperation = provisioningUI.getInstallOperation(ius, uris);
+ IStatus operationStatus = installOperation.resolveModal(monitor);
+ if (operationStatus.getSeverity() > IStatus.WARNING) {
+ throw new CoreException(operationStatus);
+ }
+ return installOperation;
+ }
+
+ private void checkIfCanceled(IProgressMonitor monitor) {
+ if (monitor.isCanceled()) {
+ throw new OperationCanceledException();
+ }
+ }
+}
--- a/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/wizard/ImportPage.java Fri Aug 13 08:37:37 2010 -0500
+++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/wizard/ImportPage.java Fri Aug 13 11:58:38 2010 -0500
@@ -42,6 +42,7 @@
import org.eclipse.ui.progress.UIJob;
import com.nokia.carbide.discovery.ui.Activator;
+import com.nokia.carbide.discovery.ui.Messages;
import com.nokia.cpp.internal.api.utils.ui.BrowseDialogUtils;
/**
@@ -55,26 +56,27 @@
"*.*" //$NON-NLS-1$
};
static final String[] FILTER_EXT_NAMES = {
- "XML Files",
- "All Files"
+ Messages.ImportPage_XMLFileFilterName,
+ Messages.ImportPage_AllFilesFilterName
};
private String currentPath;
private ImportExportData readData;
- protected boolean wantsOriginalVersions;
+ private boolean wantsOriginalVersions;
protected ImportPage() {
super("ImportPage"); //$NON-NLS-1$
- setTitle("Import Feature Configuration and Install");
- setDescription("Import a feature configurations from a file and install the features");
+ setTitle(Messages.ImportPage_Title);
+ setDescription(Messages.ImportPage_Description);
}
public void createControl(Composite parent) {
super.createControl(parent);
Composite composite = (Composite) getControl();
- createBrowseGroup(composite, "Import file:");
- createViewerGroup(composite, "Import Features:");
+ createBrowseGroup(composite, Messages.ImportPage_BrowseGroupLabel);
+ createViewerGroup(composite, Messages.ImportPage_ViewerGroupLabel);
+ createVersionPrefGroup(composite);
setPageComplete(validatePage());
}
@@ -93,14 +95,13 @@
@Override
public void widgetSelected(SelectionEvent e) {
FileDialog fileDialog = new FileDialog(getShell(), SWT.OPEN);
- fileDialog.setText("Select an Exported Feature Configuration File");
+ fileDialog.setText(Messages.ImportPage_FileDialogText);
fileDialog.setFilterExtensions(FILTER_EXTS);
fileDialog.setFilterNames(FILTER_EXT_NAMES);
BrowseDialogUtils.initializeFrom(fileDialog, pathText);
String pathstr = fileDialog.open();
if (pathstr != null) {
pathText.setText(pathstr);
-// handlePathChanged();
}
}
});
@@ -119,7 +120,7 @@
}
private void startGetInputJob(final String path) {
- UIJob j = new UIJob("Reading Feature Configuration File") {
+ UIJob j = new UIJob(Messages.ImportPage_ReadFileJobName) {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
try {
@@ -131,7 +132,7 @@
} catch (IOException e) {
// may have bad/incomplete path, so don't log this
} catch (Exception e) {
- Activator.logError(MessageFormat.format("Could not read data from file: {0}", path), e);
+ Activator.logError(MessageFormat.format(Messages.ImportPage_ReadFileError, path), e);
}
return Status.OK_STATUS;
}
@@ -139,13 +140,13 @@
j.schedule();
}
- protected void createVersionRadioGroup(Composite parent) {
+ protected void createVersionPrefGroup(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
GridLayoutFactory.fillDefaults().applyTo(composite);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.BEGINNING).grab(true, false).applyTo(composite);
final Button originalVersionCheck = new Button(composite, SWT.CHECK);
- originalVersionCheck.setText("Attempt import original feature versions");
+ originalVersionCheck.setText(Messages.ImportPage_OriginalVersionCheckLabel);
originalVersionCheck.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
@@ -159,21 +160,21 @@
IPath path = new Path(pathText.getText());
if (isFilePath(path.toOSString())) {
if (readData == null || readData.getFeatureInfos().isEmpty()) {
- setErrorMessage("No valid features found in configurations file");
+ setErrorMessage(Messages.ImportPage_NoValidFeaturesInFileError);
return false;
}
if (readData == null || readData.getURIs().isEmpty()) {
- setErrorMessage("No valid repositories found in configurations file");
+ setErrorMessage(Messages.ImportPage_NoValidReposInFileError);
return false;
}
}
else {
- setErrorMessage("A valid exported feature configuration file must be selected");
+ setErrorMessage(Messages.ImportPage_NoValidFileError);
return false;
}
if (viewer.getCheckedElements().length == 0) {
- setErrorMessage("At least one feature must be selected for import");
+ setErrorMessage(Messages.ImportPage_NoFeaturesSelectedError);
return false;
}
@@ -195,4 +196,8 @@
public ImportExportData getData() {
return readData;
}
+
+ public boolean getWantsOriginalVersions() {
+ return wantsOriginalVersions;
+ }
}
--- a/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/wizard/ImportWizard.java Fri Aug 13 08:37:37 2010 -0500
+++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/wizard/ImportWizard.java Fri Aug 13 11:58:38 2010 -0500
@@ -19,15 +19,17 @@
import java.lang.reflect.InvocationTargetException;
import java.text.MessageFormat;
-import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.ui.IImportWizard;
import org.eclipse.ui.IWorkbench;
import com.nokia.carbide.discovery.ui.Activator;
+import com.nokia.carbide.discovery.ui.Messages;
/**
* Wizard for importing installed features from a file and install them
@@ -41,23 +43,21 @@
@Override
public boolean performFinish() {
- final ImportExportData data = importPage.getData();
- IRunnableWithProgress runnable = new IRunnableWithProgress() {
- @Override
- public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- try {
- P2Utils.doInstall(data.getURIs(), data.getFeatureInfos(), data.getWantsVersions(), monitor);
- } catch (Exception e) {
- throw new InvocationTargetException(e);
- }
+ try {
+ ImportExportData data = importPage.getData();
+ getContainer().run(true, true, new FeatureInstallOperation(
+ data.getURIs(), data.getFeatureInfos(), importPage.getWantsOriginalVersions()));
+ } catch (InvocationTargetException e) {
+ Throwable cause = e.getCause();
+ if (cause instanceof CoreException) {
+ IStatus status = ((CoreException) cause).getStatus();
+ Activator.logError(Messages.ImportWizard_ImportFailedError, cause);
+ ErrorDialog.openError(getShell(), Messages.ImportWizard_ErrorTitle, null, status);
+ } else {
+ MessageDialog.openError(getShell(), Messages.ImportWizard_ErrorTitle,
+ MessageFormat.format(Messages.ImportWizard_InstallErrorSimple, cause.getMessage()));
}
- };
-
- try {
- getContainer().run(true, true, runnable);
- } catch (Exception e) {
- MessageDialog.openError(getShell(), "Error",
- MessageFormat.format("Could not install due to error: {0}", e.getLocalizedMessage()));
+ } catch (InterruptedException e) {
}
return true;
}
@@ -65,7 +65,7 @@
public void init(IWorkbench workbench, IStructuredSelection selection) {
setDefaultPageImageDescriptor(Activator.getImageDescriptor("icons\\install_wiz.gif")); //$NON-NLS-1$
setNeedsProgressMonitor(true);
- setWindowTitle("Import Installed Feature Configuration");
+ setWindowTitle(Messages.ImportWizard_Title);
importPage = new ImportPage();
addPage(importPage);
}
--- a/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/wizard/P2Utils.java Fri Aug 13 08:37:37 2010 -0500
+++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/wizard/P2Utils.java Fri Aug 13 11:58:38 2010 -0500
@@ -17,34 +17,21 @@
package com.nokia.carbide.internal.discovery.ui.wizard;
import java.net.URI;
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
-import java.util.List;
import java.util.Set;
-import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.equinox.p2.core.IProvisioningAgent;
-import org.eclipse.equinox.p2.core.ProvisionException;
import org.eclipse.equinox.p2.engine.IProfile;
import org.eclipse.equinox.p2.engine.IProfileRegistry;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.p2.metadata.Version;
-import org.eclipse.equinox.p2.operations.InstallOperation;
import org.eclipse.equinox.p2.operations.ProvisioningSession;
-import org.eclipse.equinox.p2.operations.RepositoryTracker;
import org.eclipse.equinox.p2.query.IQueryResult;
import org.eclipse.equinox.p2.query.QueryUtil;
-import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
-import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
import org.eclipse.equinox.p2.ui.ProvisioningUI;
-import org.eclipse.swt.widgets.Display;
class P2Utils {
@@ -74,101 +61,4 @@
}
return infos;
}
-
- public static void doInstall(Collection<URI> uris, Collection<FeatureInfo> featureInfos,
- boolean wantVersions, IProgressMonitor monitor) throws OperationCanceledException, CoreException {
- SubMonitor subMonitor = SubMonitor.convert(monitor, "Configuring install operation", 100);
- Collection<IMetadataRepository> repositories =
- getRepositories(uris, wantVersions, subMonitor.newChild(30));
- final Collection<IInstallableUnit> ius =
- findInstallableUnits(repositories, featureInfos, wantVersions, subMonitor.newChild(40));
- final InstallOperation operation = resolve(ius, (URI[]) uris.toArray(new URI[uris.size()]), subMonitor.newChild(30));
- Display.getDefault().asyncExec(new Runnable() {
- @Override
- public void run() {
- ProvisioningUI.getDefaultUI().openInstallWizard(ius, operation, null);
- }
- });
- }
-
- private static Collection<IMetadataRepository> getRepositories(Collection<URI> uris,
- boolean wantVersions, SubMonitor monitor) throws ProvisionException, OperationCanceledException {
- monitor.setWorkRemaining(uris.size());
- List<IMetadataRepository> repositories = new ArrayList<IMetadataRepository>();
- ProvisioningUI provisioningUI = ProvisioningUI.getDefaultUI();
- ProvisioningSession session = provisioningUI.getSession();
- RepositoryTracker repositoryTracker = provisioningUI.getRepositoryTracker();
- IMetadataRepositoryManager manager =
- (IMetadataRepositoryManager) session.getProvisioningAgent().getService(IMetadataRepositoryManager.SERVICE_NAME);
- for (URI uri : uris) {
- checkIfCanceled(monitor);
- repositoryTracker.addRepository(uri, null, session);
- repositories.add(manager.loadRepository(uri, monitor.newChild(1)));
- }
-
- return repositories;
- }
-
- private static Collection<IInstallableUnit> findInstallableUnits(Collection<IMetadataRepository> repositories,
- Collection<FeatureInfo> featureInfos, boolean wantVersions, SubMonitor monitor) throws ProvisionException {
- monitor.setWorkRemaining(repositories.size());
- List<IInstallableUnit> ius = new ArrayList<IInstallableUnit>();
- Set<FeatureInfo> remainingInfos = new HashSet<FeatureInfo>(featureInfos);
- for (IMetadataRepository repository : repositories) {
- checkIfCanceled(monitor);
- IQueryResult<IInstallableUnit> result = repository.query(QueryUtil.createIUGroupQuery(), monitor.newChild(1));
- for (Iterator<IInstallableUnit> iter = result.iterator(); iter.hasNext();) {
- IInstallableUnit iu = iter.next();
- String id = iu.getId();
- Version version = iu.getVersion();
- FeatureInfo featureInfo = findInfo(remainingInfos, id, wantVersions ? version : null);
- if (featureInfo != null) {
- ius.add(iu);
- remainingInfos.remove(featureInfo);
- }
- }
- }
- if (!remainingInfos.isEmpty()) {
- StringBuilder sb = new StringBuilder();
- sb.append("Install failed. Could not find some features: \n");
- for (FeatureInfo featureInfo : remainingInfos) {
- sb.append("id=");
- sb.append(featureInfo.getId());
- if (wantVersions) {
- sb.append("version=");
- sb.append(featureInfo.getVersion().toString());
- }
- sb.append("\n");
- }
- throw new ProvisionException(sb.toString());
- }
- return ius;
- }
-
- private static FeatureInfo findInfo(Collection<FeatureInfo> featureInfos, String id, Version version) {
- for (FeatureInfo featureInfo : featureInfos) {
- if (featureInfo.getId().equals(id) &&
- (version == null || version.toString().equals(featureInfo.getVersion().toString())))
- return featureInfo;
- }
- return null;
- }
-
- private static InstallOperation resolve(Collection<IInstallableUnit> ius, URI[] repositories,
- SubMonitor monitor) throws CoreException {
- checkIfCanceled(monitor);
- ProvisioningUI provisioningUI = ProvisioningUI.getDefaultUI();
- InstallOperation installOperation = provisioningUI.getInstallOperation(ius, repositories);
- IStatus operationStatus = installOperation.resolveModal(monitor);
- if (operationStatus.getSeverity() > IStatus.WARNING) {
- throw new CoreException(operationStatus);
- }
- return installOperation;
- }
-
- private static void checkIfCanceled(IProgressMonitor monitor) {
- if (monitor.isCanceled()) {
- throw new OperationCanceledException();
- }
- }
}
--- a/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/wizard/Streamer.java Fri Aug 13 08:37:37 2010 -0500
+++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/wizard/Streamer.java Fri Aug 13 11:58:38 2010 -0500
@@ -33,6 +33,7 @@
import org.xml.sax.helpers.DefaultHandler;
import com.nokia.carbide.discovery.ui.Activator;
+import com.nokia.carbide.discovery.ui.Messages;
/**
* Serializes feature infos and repository URIs into output stream as XML
@@ -62,12 +63,12 @@
private static final String XML_HEADER = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n"; //$NON-NLS-1$
- private static final String ROOT_START = "<" + ROOT_ELEMENT + " " + VERSION_ATTR + "=\"" + CURRENT_VERSION + "\">\n"; //$NON-NLS-1$ //$NON-NLS-2$
- private static final String ROOT_END = "</" + ROOT_ELEMENT + ">\n"; //$NON-NLS-1$
+ private static final String ROOT_START = "<" + ROOT_ELEMENT + " " + VERSION_ATTR + "=\"" + CURRENT_VERSION + "\">\n"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ private static final String ROOT_END = "</" + ROOT_ELEMENT + ">\n"; //$NON-NLS-1$ //$NON-NLS-2$
- private static final String ORIGINAL_VERSION_FMT = "\t<" + WANTS_VERSIONS_ELEMENT + " " + VALUE_ATTR + "=\"{0}\"/>\n"; //$NON-NLS-1$
- private static final String REPOSITORY_FMT = "\t<" + REPOSITORY_ELEMENT + " " + URI_ATTR + "=\"{0}\"/>\n"; //$NON-NLS-1$
- private static final String FEATURE_FMT = "\t<" + FEATURE_ELEMENT + " " + ID_ATTR + "=\"{0}\" " + VERSION_ATTR + "=\"{1}\"/>\n"; //$NON-NLS-1$
+ private static final String ORIGINAL_VERSION_FMT = "\t<" + WANTS_VERSIONS_ELEMENT + " " + VALUE_ATTR + "=\"{0}\"/>\n"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ private static final String REPOSITORY_FMT = "\t<" + REPOSITORY_ELEMENT + " " + URI_ATTR + "=\"{0}\"/>\n"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ private static final String FEATURE_FMT = "\t<" + FEATURE_ELEMENT + " " + ID_ATTR + "=\"{0}\" " + VERSION_ATTR + "=\"{1}\"/>\n"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
public static void writeToXML(OutputStream os, ImportExportData data) throws IOException {
os.write(XML_HEADER.getBytes());
@@ -107,7 +108,7 @@
String versionStr = attributes.getValue(VERSION_ATTR);
if (!CURRENT_VERSION.equals(versionStr))
throw new IllegalArgumentException(
- MessageFormat.format("Can only read version {0} of <{1}>", CURRENT_VERSION, ROOT_ELEMENT));
+ MessageFormat.format(Messages.Streamer_BadVersionError, CURRENT_VERSION, ROOT_ELEMENT));
}
else if (WANTS_VERSIONS_ELEMENT.equals(qName)) {
String wantsVersions = attributes.getValue(VALUE_ATTR);
@@ -118,7 +119,7 @@
try {
data.addURI(new URI(uriStr));
} catch (URISyntaxException e) {
- Activator.logError(MessageFormat.format("Could not parse URI: {0}", uriStr), e);
+ Activator.logError(MessageFormat.format(Messages.Streamer_BadURIError, uriStr), e);
}
}
else if (FEATURE_ELEMENT.equals(qName)) {
@@ -128,7 +129,7 @@
Version version = Version.create(versionStr);
data.addFeatureInfo(new FeatureInfo(id, version));
} catch (IllegalArgumentException e) {
- Activator.logError(MessageFormat.format("Could not parse version: {0}", versionStr), e);
+ Activator.logError(MessageFormat.format(Messages.Streamer_VersionParseError, versionStr), e);
}
}
}