Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/operations/AddArtifactRepositoryOperation.java')
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/operations/AddArtifactRepositoryOperation.java64
1 files changed, 64 insertions, 0 deletions
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/operations/AddArtifactRepositoryOperation.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/operations/AddArtifactRepositoryOperation.java
new file mode 100644
index 000000000..50a384671
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/operations/AddArtifactRepositoryOperation.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * 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.internal.provisional.p2.ui.operations;
+
+import java.net.URL;
+import org.eclipse.core.runtime.*;
+import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
+
+/**
+ * Operation which adds an artifact repository given its URL.
+ *
+ * @since 3.4
+ */
+public class AddArtifactRepositoryOperation extends RepositoryOperation {
+
+ boolean added = false;
+
+ public AddArtifactRepositoryOperation(String label, URL url) {
+ super(label, new URL[] {url});
+ }
+
+ protected IStatus doExecute(IProgressMonitor monitor, IAdaptable uiInfo) throws ProvisionException {
+ for (int i = 0; i < urls.length; i++) {
+ ProvisioningUtil.addArtifactRepository(urls[i]);
+ }
+ added = true;
+ return okStatus();
+ }
+
+ protected IStatus doUndo(IProgressMonitor monitor, IAdaptable uiInfo) throws ProvisionException {
+ for (int i = 0; i < urls.length; i++) {
+ ProvisioningUtil.removeArtifactRepository(urls[i], monitor);
+ }
+ // assume the best if no exception is thrown;
+ 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