KickJava   Java API By Example, From Geeks To Geeks.

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


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 java.lang.reflect.InvocationTargetException JavaDoc;
14
15 import org.eclipse.core.runtime.IProgressMonitor;
16 import org.eclipse.team.core.mapping.ISynchronizationScopeManager;
17 import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
18 import org.eclipse.team.internal.ccvs.ui.ICVSUIConstants;
19 import org.eclipse.team.ui.synchronize.ModelParticipantMergeOperation;
20 import org.eclipse.team.ui.synchronize.ModelSynchronizeParticipant;
21 import org.eclipse.ui.IWorkbenchPart;
22
23 public abstract class AbstractModelMergeOperation extends ModelParticipantMergeOperation {
24     
25     private boolean ownsManager = false;
26     
27     public AbstractModelMergeOperation(IWorkbenchPart part, ISynchronizationScopeManager manager, boolean ownsManager) {
28         super(part, manager);
29         this.ownsManager = ownsManager;
30     }
31     
32     /* (non-Javadoc)
33      * @see org.eclipse.team.ui.TeamOperation#canRunAsJob()
34      */

35     protected boolean canRunAsJob() {
36         return true;
37     }
38     
39     /* (non-Javadoc)
40      * @see org.eclipse.team.ui.operations.ResourceMappingMergeOperation#isPreviewInDialog()
41      */

42     protected boolean isPreviewInDialog() {
43         return CVSUIPlugin.getPlugin().getPreferenceStore().getString(ICVSUIConstants.PREF_UPDATE_PREVIEW).equals(ICVSUIConstants.PREF_UPDATE_PREVIEW_IN_DIALOG);
44     }
45     
46     protected void endOperation(IProgressMonitor monitor) throws InvocationTargetException JavaDoc {
47         if (ownsManager) {
48             ISynchronizationScopeManager manager = getScopeManager();
49             manager.dispose();
50         }
51         super.endOperation(monitor);
52     }
53     
54     protected ModelSynchronizeParticipant createParticipant() {
55         ModelSynchronizeParticipant participant = super.createParticipant();
56         // Transfer ownership of the manager to the participant
57
setOwnsManager(false);
58         return participant;
59     }
60
61     public boolean isOwnsManager() {
62         return ownsManager;
63     }
64
65     public void setOwnsManager(boolean ownsManager) {
66         this.ownsManager = ownsManager;
67     }
68
69 }
70
Popular Tags