diff options
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/prov/ui/operations/UninstallOperation.java')
-rw-r--r-- | bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/prov/ui/operations/UninstallOperation.java | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/prov/ui/operations/UninstallOperation.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/prov/ui/operations/UninstallOperation.java new file mode 100644 index 000000000..5d44a1086 --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/prov/ui/operations/UninstallOperation.java @@ -0,0 +1,76 @@ +/******************************************************************************* + * Copyright (c) 2007 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.prov.ui.operations; + +import org.eclipse.core.runtime.*; +import org.eclipse.equinox.prov.core.ProvisionException; +import org.eclipse.equinox.prov.metadata.IInstallableUnit; +import org.eclipse.equinox.prov.metadata.IInstallableUnitConstants; +import org.eclipse.equinox.prov.ui.ProvisioningUtil; + +/** + * An operation that uninstalls the specified IU's from the specified profile + * + * @since 3.4 + */ +public class UninstallOperation extends ProfileModificationOperation { + + private boolean installed = true; + + public UninstallOperation(String label, String profileID, IInstallableUnit[] ius) { + super(label, profileID, ius); + } + + protected IStatus doExecute(IProgressMonitor monitor, IAdaptable uiInfo) throws ProvisionException { + for (int i = 0; i < ius.length; i++) { + if (entryPointName == null) { + String prop = ius[i].getProperty(IInstallableUnitConstants.ENTRYPOINT_IU_KEY); + if (prop != null && Boolean.valueOf(prop).booleanValue()) { + entryPointName = ius[i].getProperty(IInstallableUnitConstants.NAME); + } + } else { + break; + } + } + IStatus status = ProvisioningUtil.uninstall(ius, getProfiles()[0], monitor, uiInfo); + if (status.isOK()) { + installed = false; + } + return status; + } + + protected IStatus doUndo(IProgressMonitor monitor, IAdaptable uiInfo) throws ProvisionException { + IStatus status = ProvisioningUtil.install(ius, entryPointName, getProfiles()[0], monitor, uiInfo); + if (status.isOK()) { + installed = true; + } + return status; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.core.commands.operations.AbstractOperation#canExecute() + */ + public boolean canExecute() { + // TODO should make sure it's actually installed in the profile + return isValid() && installed; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.core.commands.operations.AbstractOperation#canUndo() + */ + public boolean canUndo() { + return isValid() && !installed; + } +} |