Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/prov/ui/operations/RemoveMetadataRepositoryOperation.java')
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/prov/ui/operations/RemoveMetadataRepositoryOperation.java75
1 files changed, 75 insertions, 0 deletions
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/prov/ui/operations/RemoveMetadataRepositoryOperation.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/prov/ui/operations/RemoveMetadataRepositoryOperation.java
new file mode 100644
index 000000000..30e2fa282
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/prov/ui/operations/RemoveMetadataRepositoryOperation.java
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * 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 java.net.URL;
+import org.eclipse.core.runtime.*;
+import org.eclipse.equinox.prov.core.ProvisionException;
+import org.eclipse.equinox.prov.metadata.repository.IMetadataRepository;
+import org.eclipse.equinox.prov.ui.ProvisioningUtil;
+
+/**
+ * Operation that removes the metadata repository with the given URL. *
+ *
+ * @since 3.4
+ */
+public class RemoveMetadataRepositoryOperation extends RepositoryOperation {
+
+ private boolean removed = false;
+
+ public RemoveMetadataRepositoryOperation(String label, IMetadataRepository[] repos) {
+ super(label, new URL[repos.length], new String[repos.length]);
+ for (int i = 0; i < repos.length; i++) {
+ urls[i] = repos[i].getLocation();
+ names[i] = repos[i].getName();
+ }
+ }
+
+ protected IStatus doExecute(IProgressMonitor monitor, IAdaptable uiInfo) throws ProvisionException {
+ for (int i = 0; i < urls.length; i++) {
+ ProvisioningUtil.removeMetadataRepository(urls[i], monitor, uiInfo);
+ }
+ removed = true;
+ return okStatus();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.core.commands.operations.AbstractOperation#canExecute()
+ */
+ public boolean canExecute() {
+ return !removed && super.canExecute();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.core.commands.operations.AbstractOperation#canUndo()
+ */
+ public boolean canUndo() {
+ return removed && super.canUndo();
+ }
+
+ protected IStatus doUndo(IProgressMonitor monitor, IAdaptable uiInfo) throws ProvisionException {
+ for (int i = 0; i < urls.length; i++) {
+ IMetadataRepository repo = ProvisioningUtil.addMetadataRepository(urls[i], monitor, uiInfo);
+ if (repo == null) {
+ return failureStatus();
+ }
+ if (names[i] != null) {
+ ProvisioningUtil.setRepositoryName(repo, names[i]);
+ }
+ }
+ removed = false;
+ return okStatus();
+ }
+}

Back to the top