KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > internal > ccvs > ui > subscriber > CreatePatchAction


1 /*******************************************************************************
2  * Copyright (c) 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.team.internal.ccvs.ui.subscriber;
12
13 import org.eclipse.compare.structuremergeviewer.IDiffElement;
14 import org.eclipse.team.core.synchronize.*;
15 import org.eclipse.team.core.synchronize.FastSyncInfoFilter.SyncInfoDirectionFilter;
16 import org.eclipse.team.internal.ccvs.ui.wizards.GenerateDiffFileWizard;
17 import org.eclipse.team.internal.ui.synchronize.SyncInfoModelElement;
18 import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
19 import org.eclipse.team.ui.synchronize.SynchronizeModelOperation;
20
21 public class CreatePatchAction extends CVSParticipantAction {
22
23     protected CreatePatchAction(ISynchronizePageConfiguration configuration) {
24         super(configuration);
25     }
26
27     protected SynchronizeModelOperation getSubscriberOperation(ISynchronizePageConfiguration configuration, IDiffElement[] elements) {
28         return null;
29     }
30     
31     /* (non-Javadoc)
32      * @see org.eclipse.team.ui.sync.SubscriberAction#getSyncInfoFilter()
33      */

34     protected FastSyncInfoFilter getSyncInfoFilter() {
35         return new SyncInfoDirectionFilter(new int[] {SyncInfo.CONFLICTING, SyncInfo.OUTGOING});
36     }
37
38     public void runOperation() {
39         final SyncInfoSet set = getSyncInfoSet();
40         GenerateDiffFileWizard.run(getConfiguration().getSite().getPart(), set.getResources(), false);
41     }
42     
43     /*
44      * Return the selected SyncInfo for which this action is enabled.
45      *
46      * @return the selected SyncInfo for which this action is enabled.
47      */

48     private SyncInfoSet getSyncInfoSet() {
49         IDiffElement [] elements= getFilteredDiffElements();
50         SyncInfoSet filtered = new SyncInfoSet();
51         for (int i = 0; i < elements.length; i++) {
52             IDiffElement e = elements[i];
53             if (e instanceof SyncInfoModelElement) {
54                 filtered.add(((SyncInfoModelElement)e).getSyncInfo());
55             }
56         }
57         return filtered;
58     }
59     
60     protected String JavaDoc getBundleKeyPrefix() {
61         return "GenerateDiffFileAction."; //$NON-NLS-1$
62
}
63 }
64
Popular Tags