blob: 461b64930bc99bf4fea5c128b346d36d51b4fc71 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.ui.actions;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.help.WorkbenchHelp;
import org.eclipse.ui.internal.ide.IDEWorkbenchMessages;
import org.eclipse.ui.internal.ide.IIDEHelpContextIds;
/**
* Standard action for scrubbing the local content in the local file system of
* the selected resources and all of their descendents.
* <p>
* This class may be instantiated; it is not intended to be subclassed.
* </p>
*/
public class ScrubLocalAction extends WorkspaceAction {
/**
* The id of this action.
*/
public static final String ID = "org.eclipse.ui.ScrubLocalAction";//$NON-NLS-1$
/**
* Creates a new action.
*
* @param shell the shell for any dialogs
*/
public ScrubLocalAction(Shell shell) {
super(shell, IDEWorkbenchMessages.getString("ScrubLocalAction.text")); //$NON-NLS-1$
setToolTipText(IDEWorkbenchMessages
.getString("ScrubLocalAction.toolTip")); //$NON-NLS-1$
setId(ID);
WorkbenchHelp.setHelp(this, IIDEHelpContextIds.SCRUB_LOCAL_ACTION);
}
/* (non-Javadoc)
* Method declared on WorkspaceAction.
*/
String getOperationMessage() {
return IDEWorkbenchMessages.getString("ScrubLocalAction.progress"); //$NON-NLS-1$
}
/* (non-Javadoc)
* Method declared on WorkspaceAction.
*/
String getProblemsMessage() {
return IDEWorkbenchMessages
.getString("ScrubLocalAction.problemsMessage"); //$NON-NLS-1$
}
/* (non-Javadoc)
* Method declared on WorkspaceAction.
*/
String getProblemsTitle() {
return IDEWorkbenchMessages.getString("ScrubLocalAction.problemsTitle"); //$NON-NLS-1$
}
/* (non-Javadoc)
* Method declared on WorkspaceAction.
*/
void invokeOperation(IResource resource, IProgressMonitor monitor)
throws CoreException {
resource.setLocal(false, IResource.DEPTH_INFINITE, monitor);
}
/**
* The <code>ScrubLocalAction</code> implementation of this
* <code>SelectionListenerAction</code> method ensures that this action is
* disabled if any of the selections are not resources.
*/
protected boolean updateSelection(IStructuredSelection s) {
return super.updateSelection(s)
&& getSelectedNonResources().size() == 0;
}
}