KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > internal > ccvs > ui > mappings > ModelMergeOperation


1 /*******************************************************************************
2  * Copyright (c) 2006 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.mappings;
12
13 import org.eclipse.core.resources.mapping.ResourceMapping;
14 import org.eclipse.team.core.mapping.provider.SynchronizationContext;
15 import org.eclipse.team.core.subscribers.Subscriber;
16 import org.eclipse.team.core.subscribers.SubscriberScopeManager;
17 import org.eclipse.team.internal.ccvs.core.CVSMergeSubscriber;
18 import org.eclipse.team.internal.ccvs.ui.CVSUIMessages;
19 import org.eclipse.team.ui.synchronize.ModelSynchronizeParticipant;
20 import org.eclipse.ui.IWorkbenchPart;
21
22 public class ModelMergeOperation extends AbstractModelMergeOperation {
23
24     private final Subscriber subscriber;
25     private final boolean attempAutomerge;
26     
27     /**
28      * Create a merge operation for the given subscriber. The merge operation will cancel the subscriber
29      * when it is no longer needed.
30      * @param part the part
31      * @param mappings the mappings
32      * @param subscriber the subscriber
33      * @param attempAutomerge
34      */

35     public ModelMergeOperation(IWorkbenchPart part, ResourceMapping[] mappings, final CVSMergeSubscriber subscriber, boolean attempAutomerge) {
36         super(part, new SubscriberScopeManager(subscriber.getName(), mappings, subscriber, true){
37             public void dispose() {
38                 subscriber.cancel();
39                 super.dispose();
40             }
41         }, true);
42         this.subscriber = subscriber;
43         this.attempAutomerge = attempAutomerge;
44     }
45
46     /* (non-Javadoc)
47      * @see org.eclipse.team.ui.operations.ModelParticipantMergeOperation#createMergeContext()
48      */

49     protected SynchronizationContext createMergeContext() {
50         return MergeSubscriberContext.createContext(getScopeManager(), subscriber);
51     }
52     
53     /* (non-Javadoc)
54      * @see org.eclipse.team.ui.TeamOperation#getJobName()
55      */

56     protected String JavaDoc getJobName() {
57         return CVSUIMessages.MergeUpdateAction_jobName;
58     }
59     
60     /* (non-Javadoc)
61      * @see org.eclipse.team.internal.ccvs.ui.mappings.AbstractModelMergeOperation#createParticipant()
62      */

63     protected ModelSynchronizeParticipant createParticipant() {
64         setOwnsManager(false);
65         return new ModelMergeParticipant((MergeSubscriberContext)createMergeContext());
66     }
67     
68     protected boolean isPreviewInDialog() {
69         return false;
70     }
71     
72     public boolean isPreviewRequested() {
73         return !attempAutomerge;
74     }
75
76 }
77
Popular Tags