Setting the name of the launcher from an IU
diff --git a/bundles/org.eclipse.equinox.p2.engine/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.engine/META-INF/MANIFEST.MF
index 71d2a44..0b02a7f 100644
--- a/bundles/org.eclipse.equinox.p2.engine/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.p2.engine/META-INF/MANIFEST.MF
@@ -5,7 +5,7 @@
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Bundle-Version: 0.1.0.qualifier
-Export-Package: org.eclipse.equinox.internal.p2.engine;x-friends:="org.eclipse.equinox.p2.touchpoint.natives",
+Export-Package: org.eclipse.equinox.internal.p2.engine;x-friends:="org.eclipse.equinox.p2.touchpoint.eclipse,org.eclipse.equinox.p2.touchpoint.natives",
org.eclipse.equinox.internal.p2.installregistry,
org.eclipse.equinox.internal.provisional.p2.engine,
org.eclipse.equinox.internal.provisional.p2.engine.phases
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/META-INF/MANIFEST.MF
index 6b653af..88a78a5 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/META-INF/MANIFEST.MF
@@ -7,6 +7,7 @@
Bundle-Version: 0.1.0.qualifier
Import-Package: org.eclipse.core.runtime;common=split,
org.eclipse.equinox.internal.p2.core.helpers,
+ org.eclipse.equinox.internal.p2.engine,
org.eclipse.equinox.internal.p2.garbagecollector,
org.eclipse.equinox.internal.provisional.frameworkadmin,
org.eclipse.equinox.internal.provisional.p2.artifact.repository,
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/EclipseTouchpoint.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/EclipseTouchpoint.java
index a3b1a71..a4c26ab 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/EclipseTouchpoint.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/EclipseTouchpoint.java
@@ -14,8 +14,8 @@
import java.net.URL;
import java.util.*;
import org.eclipse.core.runtime.*;
-import org.eclipse.equinox.internal.provisional.frameworkadmin.BundleInfo;
-import org.eclipse.equinox.internal.provisional.frameworkadmin.Manipulator;
+import org.eclipse.equinox.internal.p2.engine.Profile;
+import org.eclipse.equinox.internal.provisional.frameworkadmin.*;
import org.eclipse.equinox.internal.provisional.p2.artifact.repository.*;
import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
import org.eclipse.equinox.internal.provisional.p2.engine.*;
@@ -41,6 +41,7 @@
private static final String ACTION_UNINSTALL_BUNDLE = "uninstallBundle"; //$NON-NLS-1$
private static final String ACTION_UNINSTALL_FEATURE = "uninstallFeature"; //$NON-NLS-1$
private static final String ACTION_REMOVE_SOURCEBUNDLE = "removeSourceBundle"; //$NON-NLS-1$
+ private static final String ACTION_SET_LAUNCHERNAME = "setLauncherName"; //$NON-NLS-1$
private static final String PARM_ARTIFACT = "@artifact"; //$NON-NLS-1$
private static final String PARM_ARTIFACT_REQUESTS = "artifactRequests"; //$NON-NLS-1$
private static final String PARM_BUNDLE = "bundle"; //$NON-NLS-1$
@@ -65,6 +66,7 @@
private static final String PARM_START_LEVEL = "startLevel"; //$NON-NLS-1$
private static final String PARM_STARTED = "started"; //$NON-NLS-1$
private static final String PARM_DEFAULT_VALUE = "default"; //$NON-NLS-1$
+ private static final String PARAM_LAUNCHERNAME = "name"; //$NON-NLS-1$
// TODO: phase id constants should be defined elsewhere.
private static final String INSTALL_PHASE_ID = "install"; //$NON-NLS-1$
@@ -73,6 +75,8 @@
// private static final String CONFIGURE_PHASE_ID = "configure"; //$NON-NLS-1$
// private static final String UNCONFIGURE_PHASE_ID = "unconfigure"; //$NON-NLS-1$
+ static final String PROFILE_PROP_LAUNCHER_NAME = "eclipse.touchpoint.launcherName"; //$NON-NLS-1$
+
protected static IStatus createError(String message) {
return createError(message, null);
}
@@ -258,6 +262,39 @@
};
}
+ if (actionId.equals(ACTION_SET_LAUNCHERNAME)) {
+ return new ProvisioningAction() {
+ private IStatus changeName(String newName, Manipulator manipulator, Profile profile) {
+ try {
+ //force the load to make sure we read the values in the old filename
+ manipulator.load();
+ } catch (IllegalStateException e) {
+ return createError(Messages.error_loading_manipulator);
+ } catch (FrameworkAdminRuntimeException e) {
+ return createError(Messages.error_loading_manipulator);
+ } catch (IOException e) {
+ return createError(Messages.error_loading_manipulator);
+ }
+ getMemento().put(PROFILE_PROP_LAUNCHER_NAME, profile.getProperty(PROFILE_PROP_LAUNCHER_NAME));
+ profile.setProperty(PROFILE_PROP_LAUNCHER_NAME, newName);
+ manipulator.getLauncherData().setLauncher(Util.getLauncherPath(profile));
+ return Status.OK_STATUS;
+ }
+
+ public IStatus execute(Map parameters) {
+ Manipulator manipulator = (Manipulator) parameters.get(PARM_MANIPULATOR);
+ Profile profile = (Profile) parameters.get(PARM_PROFILE);
+ return changeName((String) parameters.get(PARAM_LAUNCHERNAME), manipulator, profile);
+ }
+
+ public IStatus undo(Map parameters) {
+ Manipulator manipulator = (Manipulator) parameters.get(PARM_MANIPULATOR);
+ Profile profile = (Profile) parameters.get(PARM_PROFILE);
+ return changeName((String) getMemento().get(PROFILE_PROP_LAUNCHER_NAME), manipulator, profile);
+ }
+ };
+ }
+
if (actionId.equals(ACTION_ADD_PROGRAM_ARG)) {
return new ProvisioningAction() {
public IStatus execute(Map parameters) {
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/LazyManipulator.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/LazyManipulator.java
index 5c6580d..6e367a3 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/LazyManipulator.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/LazyManipulator.java
@@ -10,7 +10,6 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.touchpoint.eclipse;
-import java.io.File;
import java.io.IOException;
import org.eclipse.equinox.internal.provisional.frameworkadmin.*;
import org.eclipse.equinox.internal.provisional.p2.engine.IProfile;
@@ -41,7 +40,7 @@
LauncherData launcherData = manipulator.getLauncherData();
launcherData.setFwConfigLocation(Util.getConfigurationFolder(profile));
- launcherData.setLauncher(new File(Util.getInstallFolder(profile), Util.getLauncherName(profile)));
+ launcherData.setLauncher(Util.getLauncherPath(profile));
try {
manipulator.load();
} catch (IllegalStateException e2) {
@@ -115,7 +114,7 @@
manipulator.initialize();
}
- public void load() throws IllegalStateException, IOException, FrameworkAdminRuntimeException {
+ public void load() throws IllegalStateException, FrameworkAdminRuntimeException {
loadDelegate();
}
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/Messages.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/Messages.java
new file mode 100644
index 0000000..bafc546
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/Messages.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.internal.p2.touchpoint.eclipse;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.equinox.internal.p2.touchpoint.eclipse.messages"; //$NON-NLS-1$
+
+ static {
+ // load message values from bundle file and assign to fields below
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ public static String error_loading_manipulator;
+
+}
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/Util.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/Util.java
index 3a55893..4f47c7d 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/Util.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/Util.java
@@ -21,7 +21,6 @@
import org.eclipse.core.runtime.Path;
import org.eclipse.equinox.internal.p2.core.helpers.*;
import org.eclipse.equinox.internal.provisional.frameworkadmin.BundleInfo;
-import org.eclipse.equinox.internal.provisional.frameworkadmin.FrameworkAdmin;
import org.eclipse.equinox.internal.provisional.p2.artifact.repository.*;
import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
import org.eclipse.equinox.internal.provisional.p2.core.location.AgentLocation;
@@ -145,16 +144,19 @@
return new File(profile.getProperty(IProfile.PROP_INSTALL_FOLDER));
}
+ static File getLauncherPath(IProfile profile) {
+ return new File(getInstallFolder(profile), getLauncherName(profile));
+ }
+
/**
* Returns the name of the Eclipse application launcher.
*/
- static String getLauncherName(IProfile profile) {
- String name = profile.getProperty(FrameworkAdmin.SERVICE_PROP_KEY_LAUNCHER_NAME);
+ private static String getLauncherName(IProfile profile) {
+ String name = profile.getProperty(EclipseTouchpoint.PROFILE_PROP_LAUNCHER_NAME);
if (name != null)
return name;
- //create a default name based on platform
- //TODO Need a better solution for launcher name branding
+ //create a default name based on platform
String os = getOSFromProfile(profile);
if (os == null) {
EnvironmentInfo info = (EnvironmentInfo) ServiceHelper.getService(Activator.getContext(), EnvironmentInfo.class.getName());
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/messages.properties b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/messages.properties
new file mode 100644
index 0000000..f02f385
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/messages.properties
@@ -0,0 +1,15 @@
+###############################################################################
+# Copyright (c) 2008 IBM 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:
+# IBM Corporation - initial API and implementation
+###############################################################################
+
+error_loading_manipulator=Error while loading manipulator.
+
+
+