blob: b0b3371ecaa570620c9270ed4ca0e4a1c7562e25 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2007, 2008 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.URI;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
/**
* Operation which removes the artifact repository with the given URL.
*
* @since 3.4
*/
public class RemoveArtifactRepositoryOperation extends RepositoryOperation {
private boolean removed = false;
public RemoveArtifactRepositoryOperation(String label, URI[] repoLocations) {
super(label, repoLocations);
}
protected IStatus doBatchedExecute(IProgressMonitor monitor, IAdaptable uiInfo) throws ProvisionException {
SubMonitor mon = SubMonitor.convert(monitor, locations.length);
for (int i = 0; i < locations.length; i++) {
ProvisioningUtil.removeArtifactRepository(locations[i]);
mon.worked(1);
}
removed = true;
return okStatus();
}
/*
* (non-Javadoc)
*
* @see org.eclipse.core.commands.operations.AbstractOperation#canExecute()
*/
public boolean canExecute() {
return super.canExecute() && !removed;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.core.commands.operations.AbstractOperation#canUndo()
*/
public boolean canUndo() {
return super.canUndo() && removed;
}
protected IStatus doBatchedUndo(IProgressMonitor monitor, IAdaptable uiInfo) throws ProvisionException {
SubMonitor mon = SubMonitor.convert(monitor, locations.length);
for (int i = 0; i < locations.length; i++) {
ProvisioningUtil.addArtifactRepository(locations[i]);
mon.worked(1);
}
removed = false;
return okStatus();
}
}