Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/prov/ui/operations/AddProfileOperation.java')
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/prov/ui/operations/AddProfileOperation.java59
1 files changed, 59 insertions, 0 deletions
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/prov/ui/operations/AddProfileOperation.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/prov/ui/operations/AddProfileOperation.java
new file mode 100644
index 000000000..09e7a2319
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/prov/ui/operations/AddProfileOperation.java
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * 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.engine.Profile;
+import org.eclipse.equinox.prov.ui.ProvisioningUtil;
+
+/**
+ * Operation that adds the given profile to the profile registry.
+ *
+ * @since 3.4
+ */
+public class AddProfileOperation extends ProfileOperation {
+ private boolean added = false;
+
+ public AddProfileOperation(String label, Profile profile) {
+ super(label, new Profile[] {profile});
+ }
+
+ protected IStatus doExecute(IProgressMonitor monitor, IAdaptable uiInfo) throws ProvisionException {
+ ProvisioningUtil.addProfile(getProfiles()[0], monitor, uiInfo);
+ added = true;
+ return okStatus();
+ }
+
+ protected IStatus doUndo(IProgressMonitor monitor, IAdaptable uiInfo) throws ProvisionException {
+ ProvisioningUtil.removeProfile(profileIds[0], monitor, uiInfo);
+ added = false;
+ return okStatus();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.core.commands.operations.AbstractOperation#canExecute()
+ */
+ public boolean canExecute() {
+ return super.canExecute() && !added;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.core.commands.operations.AbstractOperation#canUndo()
+ */
+ public boolean canUndo() {
+ return super.canUndo() && added;
+ }
+}

Back to the top