Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/EclipseTouchpoint.java')
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/EclipseTouchpoint.java47
1 files changed, 39 insertions, 8 deletions
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 dda2c4f2f..a0fbc7f02 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
@@ -12,6 +12,7 @@ import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.Map;
+import java.util.WeakHashMap;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.core.helpers.LogHelper;
import org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions.ActionFactory;
@@ -30,6 +31,7 @@ public class EclipseTouchpoint extends Touchpoint {
// TODO: phase id constants should be defined elsewhere.
public static final String INSTALL_PHASE_ID = "install"; //$NON-NLS-1$
public static final String UNINSTALL_PHASE_ID = "uninstall"; //$NON-NLS-1$
+ public static final String CONFIGURE_PHASE_ID = "configure"; //$NON-NLS-1$
public static final String PROFILE_PROP_LAUNCHER_NAME = "eclipse.touchpoint.launcherName"; //$NON-NLS-1$
public static final String PARM_MANIPULATOR = "manipulator"; //$NON-NLS-1$
@@ -38,14 +40,43 @@ public class EclipseTouchpoint extends Touchpoint {
public static final String PARM_IU = "iu"; //$NON-NLS-1$
public static final String PARM_INSTALL_FOLDER = "installFolder"; //$NON-NLS-1$
- public IStatus completePhase(IProgressMonitor monitor, IProfile profile, String phaseId, Map touchpointParameters) {
- Manipulator manipulator = (Manipulator) touchpointParameters.get(EclipseTouchpoint.PARM_MANIPULATOR);
- try {
+ private static Map manipulators = new WeakHashMap();
+
+ private static synchronized LazyManipulator getManipulator(IProfile profile) {
+ LazyManipulator manipulator = (LazyManipulator) manipulators.get(profile);
+ if (manipulator == null) {
+ manipulator = new LazyManipulator(profile);
+ manipulators.put(profile, manipulator);
+ }
+ return manipulator;
+ }
+
+ private static synchronized void saveManipulator(IProfile profile) throws FrameworkAdminRuntimeException, IOException {
+ LazyManipulator manipulator = (LazyManipulator) manipulators.remove(profile);
+ if (manipulator != null)
manipulator.save(false);
- } catch (RuntimeException e) {
- return Util.createError(Messages.error_saving_manipulator, e);
- } catch (IOException e) {
- return Util.createError(Messages.error_saving_manipulator, e);
+ }
+
+ public static final boolean WRITE_ONCE = !"false".equals(org.eclipse.equinox.internal.p2.touchpoint.eclipse.Activator.getContext().getProperty("eclipse.p2.eclipseTouchpoint.writeOnce")); //$NON-NLS-1$//$NON-NLS-2$
+
+ public IStatus completePhase(IProgressMonitor monitor, IProfile profile, String phaseId, Map touchpointParameters) {
+ if (!WRITE_ONCE) {
+ Manipulator manipulator = (Manipulator) touchpointParameters.get(EclipseTouchpoint.PARM_MANIPULATOR);
+ try {
+ manipulator.save(false);
+ } catch (RuntimeException e) {
+ return Util.createError(Messages.error_saving_manipulator, e);
+ } catch (IOException e) {
+ return Util.createError(Messages.error_saving_manipulator, e);
+ }
+ } else if (CONFIGURE_PHASE_ID.equals(phaseId)) {
+ try {
+ saveManipulator(profile);
+ } catch (RuntimeException e) {
+ return Util.createError(Messages.error_saving_manipulator, e);
+ } catch (IOException e) {
+ return Util.createError(Messages.error_saving_manipulator, e);
+ }
}
if (INSTALL_PHASE_ID.equals(phaseId) || UNINSTALL_PHASE_ID.equals(phaseId)) {
@@ -78,7 +109,7 @@ public class EclipseTouchpoint extends Touchpoint {
public IStatus initializePhase(IProgressMonitor monitor, IProfile profile, String phaseId, Map touchpointParameters) {
touchpointParameters.put(PARM_INSTALL_FOLDER, Util.getInstallFolder(profile));
- LazyManipulator manipulator = new LazyManipulator(profile);
+ LazyManipulator manipulator = getManipulator(profile);
touchpointParameters.put(PARM_MANIPULATOR, manipulator);
touchpointParameters.put(PARM_SOURCE_BUNDLES, new SourceManipulator(profile));
File configLocation = Util.getConfigurationFolder(profile);

Back to the top