1 11 package org.eclipse.team.internal.ccvs.ui.actions; 12 13 import java.lang.reflect.InvocationTargetException ; 14 15 import org.eclipse.core.runtime.CoreException; 16 import org.eclipse.core.runtime.IProgressMonitor; 17 import org.eclipse.jface.action.IAction; 18 import org.eclipse.jface.operation.IRunnableWithProgress; 19 import org.eclipse.jface.window.Window; 20 import org.eclipse.swt.widgets.Display; 21 import org.eclipse.team.internal.ccvs.core.CVSTag; 22 import org.eclipse.team.internal.ccvs.ui.*; 23 import org.eclipse.team.internal.ccvs.ui.operations.ReplaceOperation; 24 25 28 public abstract class ReplaceWithTagAction extends WorkspaceTraversalAction { 29 30 33 public void execute(IAction action) throws InterruptedException , InvocationTargetException { 34 35 final CVSTag[] tag = new CVSTag[] {null}; 37 38 final ReplaceOperation replaceOperation = new ReplaceOperation(getTargetPart(), getCVSResourceMappings(), tag[0]); 39 if (hasOutgoingChanges(replaceOperation)) { 40 final boolean[] keepGoing = new boolean[] { true }; 41 Display.getDefault().syncExec(new Runnable () { 42 public void run() { 43 OutgoingChangesDialog dialog = new OutgoingChangesDialog(getShell(), replaceOperation.getScopeManager(), 44 CVSUIMessages.ReplaceWithTagAction_2, 45 CVSUIMessages.ReplaceWithTagAction_0, 46 CVSUIMessages.ReplaceWithTagAction_1); 47 dialog.setHelpContextId(IHelpContextIds.REPLACE_OUTGOING_CHANGES_DIALOG); 48 int result = dialog.open(); 49 keepGoing[0] = result == Window.OK; 50 } 51 }); 52 if (!keepGoing[0]) 53 return; 54 } 55 56 run(new IRunnableWithProgress() { 58 public void run(IProgressMonitor monitor) throws InterruptedException , InvocationTargetException { 59 monitor = Policy.monitorFor(monitor); 60 tag[0] = getTag(replaceOperation); 61 62 try { 65 if(!CVSAction.checkForMixingTags(getShell(), replaceOperation.getScope().getRoots(), tag[0])) { 66 tag[0] = null; 67 return; 68 } 69 } catch (CoreException e) { 70 throw new InvocationTargetException (e); 71 } 72 } 73 }, false , PROGRESS_BUSYCURSOR); 74 75 if (tag[0] == null) return; 76 77 replaceOperation.setTag(tag[0]); 79 replaceOperation.run(); 80 } 81 82 85 protected String getErrorTitle() { 86 return CVSUIMessages.ReplaceWithTagAction_replace; 87 } 88 89 92 protected boolean isEnabledForNonExistantResources() { 93 return true; 94 } 95 96 103 abstract protected CVSTag getTag(final ReplaceOperation replaceOperation); 104 105 } 106 | Popular Tags |