1 11 package org.eclipse.team.internal.ccvs.ui.actions; 12 13 import java.lang.reflect.InvocationTargetException ; 14 15 import org.eclipse.jface.action.IAction; 16 import org.eclipse.jface.window.Window; 17 import org.eclipse.swt.widgets.Display; 18 import org.eclipse.team.internal.ccvs.core.CVSException; 19 import org.eclipse.team.internal.ccvs.core.ICVSResource; 20 import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo; 21 import org.eclipse.team.internal.ccvs.ui.CVSUIMessages; 22 import org.eclipse.team.internal.ccvs.ui.IHelpContextIds; 23 import org.eclipse.team.internal.ccvs.ui.operations.ReplaceOperation; 24 25 public class ReplaceWithRemoteAction extends WorkspaceTraversalAction { 26 27 public void execute(IAction action) throws InvocationTargetException , InterruptedException { 28 29 final ReplaceOperation replaceOperation = new ReplaceOperation(getTargetPart(), getCVSResourceMappings(), null); 30 if (hasOutgoingChanges(replaceOperation)) { 31 final boolean[] keepGoing = new boolean[] { true }; 32 Display.getDefault().syncExec(new Runnable () { 33 public void run() { 34 OutgoingChangesDialog dialog = new OutgoingChangesDialog(getShell(), replaceOperation.getScopeManager(), 35 CVSUIMessages.ReplaceWithTagAction_2, 36 CVSUIMessages.ReplaceWithTagAction_0, 37 CVSUIMessages.ReplaceWithTagAction_1); 38 dialog.setHelpContextId(IHelpContextIds.REPLACE_OUTGOING_CHANGES_DIALOG); 39 int result = dialog.open(); 40 keepGoing[0] = result == Window.OK; 41 } 42 }); 43 if (!keepGoing[0]) 44 return; 45 } 46 replaceOperation.run(); 47 } 48 49 52 protected String getErrorTitle() { 53 return CVSUIMessages.ReplaceWithRemoteAction_problemMessage; 54 } 55 56 59 protected boolean isEnabledForAddedResources() { 60 return false; 61 } 62 63 66 protected boolean isEnabledForNonExistantResources() { 67 return true; 68 } 69 70 73 protected boolean isEnabledForCVSResource(ICVSResource cvsResource) throws CVSException { 74 if (super.isEnabledForCVSResource(cvsResource)) { 75 if (!cvsResource.isFolder()) { 77 ResourceSyncInfo info = cvsResource.getSyncInfo(); 78 if (info != null && info.getTag() != null) { 79 String revision = info.getRevision(); 80 String tag = info.getTag().getName(); 81 if (revision.equals(tag)) return false; 82 } 83 } 84 return true; 85 } else { 86 return false; 87 } 88 } 89 90 96 protected void setActionEnablement(IAction action) { 97 super.setActionEnablement(action); 98 99 action.setText(calculateActionTagValue()); 100 } 101 } 102 | Popular Tags |