1 11 package org.eclipse.team.internal.ccvs.ui.mappings; 12 13 import java.util.HashSet ; 14 import java.util.Set ; 15 16 import org.eclipse.core.resources.IResource; 17 import org.eclipse.jface.window.Window; 18 import org.eclipse.team.core.diff.IDiff; 19 import org.eclipse.team.core.mapping.provider.ResourceDiffTree; 20 import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin; 21 import org.eclipse.team.internal.ccvs.ui.CVSUIMessages; 22 import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; 23 import org.eclipse.team.internal.ccvs.ui.subscriber.CommitSetDialog; 24 import org.eclipse.team.internal.core.subscribers.ActiveChangeSet; 25 import org.eclipse.team.internal.core.subscribers.ActiveChangeSetManager; 26 import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; 27 28 public class WorkspaceChangeSetCapability extends ModelParticipantChangeSetCapability { 29 30 33 public boolean supportsActiveChangeSets() { 34 return true; 35 } 36 37 40 public boolean enableActiveChangeSetsFor(ISynchronizePageConfiguration configuration) { 41 return supportsActiveChangeSets() && 42 configuration.getMode() != ISynchronizePageConfiguration.INCOMING_MODE; 43 } 44 45 48 public ActiveChangeSet createChangeSet(ISynchronizePageConfiguration configuration, IDiff[] infos) { 49 ActiveChangeSet set = getActiveChangeSetManager().createSet(CVSUIMessages.WorkspaceChangeSetCapability_1, new IDiff[0]); 50 CommitSetDialog dialog = new CommitSetDialog(configuration.getSite().getShell(), set, getResources(infos), CommitSetDialog.NEW); 51 dialog.open(); 52 if (dialog.getReturnCode() != Window.OK) return null; 53 set.add(infos); 54 return set; 55 } 56 57 private IResource[] getResources(IDiff[] diffs) { 58 Set result = new HashSet (); 59 for (int i = 0; i < diffs.length; i++) { 60 IDiff diff = diffs[i]; 61 IResource resource = ResourceDiffTree.getResourceFor(diff); 62 if (resource != null) 63 result.add(resource); 64 } 65 return (IResource[]) result.toArray(new IResource[result.size()]); 66 } 67 68 71 public void editChangeSet(ISynchronizePageConfiguration configuration, ActiveChangeSet set) { 72 CommitSetDialog dialog = new CommitSetDialog(configuration.getSite().getShell(), set, set.getResources(), CommitSetDialog.EDIT); 73 dialog.open(); 74 if (dialog.getReturnCode() != Window.OK) return; 75 } 77 78 81 public ActiveChangeSetManager getActiveChangeSetManager() { 82 return CVSUIPlugin.getPlugin().getChangeSetManager(); 83 } 84 85 public CheckedInChangeSetCollector createCheckedInChangeSetCollector(ISynchronizePageConfiguration configuration) { 86 return new CheckedInChangeSetCollector(configuration, CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber()); 87 } 88 } 89 | Popular Tags |