1 11 package org.eclipse.team.internal.ccvs.ui.subscriber; 12 13 import org.eclipse.compare.structuremergeviewer.IDiffElement; 14 import org.eclipse.jface.viewers.ISelectionProvider; 15 import org.eclipse.swt.widgets.Shell; 16 import org.eclipse.team.core.synchronize.*; 17 import org.eclipse.team.core.synchronize.FastSyncInfoFilter.SyncInfoDirectionFilter; 18 import org.eclipse.team.internal.ccvs.core.CVSException; 19 import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; 20 import org.eclipse.team.internal.ccvs.ui.ICVSUIConstants; 21 import org.eclipse.team.internal.ccvs.ui.wizards.CommitWizard; 22 import org.eclipse.team.internal.ui.synchronize.SyncInfoModelElement; 23 import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; 24 import org.eclipse.team.ui.synchronize.SynchronizeModelOperation; 25 import org.eclipse.ui.PlatformUI; 26 27 public class WorkspaceCommitAction extends CVSParticipantAction { 28 29 public WorkspaceCommitAction(ISynchronizePageConfiguration configuration) { 30 super(configuration); 31 setId(ICVSUIConstants.CMD_COMMIT); 32 setActionDefinitionId(ICVSUIConstants.CMD_COMMIT); 33 } 34 35 public WorkspaceCommitAction(ISynchronizePageConfiguration configuration, ISelectionProvider provider, String bundleKey) { 36 super(configuration, provider, bundleKey); 37 setId(ICVSUIConstants.CMD_COMMIT_ALL); 38 setActionDefinitionId(ICVSUIConstants.CMD_COMMIT_ALL); 39 } 40 41 44 protected FastSyncInfoFilter getSyncInfoFilter() { 45 return new SyncInfoDirectionFilter(new int[] { SyncInfo.OUTGOING }); 46 } 47 48 51 protected SynchronizeModelOperation getSubscriberOperation(ISynchronizePageConfiguration configuration, IDiffElement[] elements) { 52 return new WorkspaceCommitOperation(configuration, elements, false ); 53 } 54 55 public void runOperation() { 56 final SyncInfoSet set = getSyncInfoSet(); 57 final Shell shell= PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); 58 try { 59 CommitWizard.run(shell, set, getSubscriberOperation(getConfiguration(), getFilteredDiffElements())); 62 } catch (CVSException e) { 63 CVSUIPlugin.log(e); 64 } 65 } 66 67 72 private SyncInfoSet getSyncInfoSet() { 73 IDiffElement [] elements= getFilteredDiffElements(); 74 SyncInfoSet filtered = new SyncInfoSet(); 75 for (int i = 0; i < elements.length; i++) { 76 IDiffElement e = elements[i]; 77 if (e instanceof SyncInfoModelElement) { 78 filtered.add(((SyncInfoModelElement)e).getSyncInfo()); 79 } 80 } 81 return filtered; 82 } 83 } 84 | Popular Tags |