KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > internal > ui > synchronize > ChangeSetCapability


1 /*******************************************************************************
2  * Copyright (c) 2000, 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.ui.synchronize;
12
13 import org.eclipse.team.core.diff.IDiff;
14 import org.eclipse.team.internal.core.subscribers.ActiveChangeSet;
15 import org.eclipse.team.internal.core.subscribers.ActiveChangeSetManager;
16 import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
17 import org.eclipse.team.ui.synchronize.SynchronizePageActionGroup;
18
19 /**
20  * A change set capability is used by a SubscriberSynchronizePage
21  * to determine what, if any change set capabilities should be enabled
22  * for the pages of the participant.
23  * @since 3.1
24  */

25 public abstract class ChangeSetCapability {
26
27     /**
28      * Return whether the associated participant supports
29      * the display of checked-in change sets. The default is
30      * unsupported (<code>false</code>). If subclasses support
31      * checked-in change sets, they must override the
32      * <code>createCheckedInChangeSetCollector</code>
33      * method to return an appropriate values.
34      * @return whether the associated participant supports
35      * the display of checked-in change sets
36      */

37     public boolean supportsCheckedInChangeSets() {
38         return false;
39     }
40     
41     /**
42      * Return whether the associated participant supports
43      * the use of active change sets. The default is unsupported
44      * (<code>false</code>). If a subclass overrides this method in
45      * order to support active change sets, they must also override the methods
46      * <code>getActiveChangeSetManager</code>,
47      * <code>createChangeSet</code> and <code>editChangeSet</code>.
48      * @return whether the associated participant supports
49      * the use of active change sets
50      */

51     public boolean supportsActiveChangeSets() {
52         return false;
53     }
54     
55     /**
56      * Return the change set collector that manages the active change
57      * set for the participant associated with this capability. A <code>null</code>
58      * is returned if active change sets are not supported. The default is to
59      * return <code>null</code>. This method must be
60      * overridden by subclasses that support active change sets.
61      * @return the change set collector that manages the active change
62      * set for the participant associated with this capability or
63      * <code>null</code> if active change sets are not supported.
64      */

65     public ActiveChangeSetManager getActiveChangeSetManager() {
66         return null;
67     }
68     
69     /**
70      * Create a change set from the given manager that contains the given sync info.
71      * This method is invoked from the UI thread. A <code>null</code>
72      * is returned if active change sets are not supported. The default is to
73      * return <code>null</code>. This method must be
74      * overridden by subclasses that support active change sets.
75      * @param configuration the configuration of the page displaying the change sets
76      * @param diffs the sync info to be added to the change set
77      * @return the created set.
78      */

79     public ActiveChangeSet createChangeSet(ISynchronizePageConfiguration configuration, IDiff[] diffs) {
80         return null;
81     }
82     
83     /**
84      * Edit the title and comment of the given change set. This method must be
85      * overridden by subclasses that support active change sets.
86      * This method is invoked from the UI thread.
87      * @param configuration the configuration of the page displaying the change sets
88      * @param set the set to be edited
89      */

90     public void editChangeSet(ISynchronizePageConfiguration configuration, ActiveChangeSet set) {
91         // Default is to do nothing
92
}
93     
94     /**
95      * Return a collector that can be used to group a set of checked-in changes
96      * into a set of checked-in change sets. This method must be
97      * overridden by subclasses that support checked-in change sets.
98      * @param configuration the configuration for the page that will be displaying the change sets
99      * @return a change set collector
100      */

101     public SyncInfoSetChangeSetCollector createSyncInfoSetChangeSetCollector(ISynchronizePageConfiguration configuration) {
102         return null;
103     }
104     
105     /**
106      * Return an action group for contributing context menu items
107      * to the synchronize page while change sets are enabled.
108      * Return <code>null</code> if no custom actions are required.
109      * Note that only context menus can be contributed since the view menu
110      * and toolbar menu are fixed. This method can be overridden by subclasses
111      * who wish to support custom change set actions.
112      * @return an action group for contributing context menu items
113      * to the synchronize page while change sets are enabled or <code>null</code>
114      */

115     public SynchronizePageActionGroup getActionGroup() {
116         return null;
117     }
118     
119     /**
120      * Returns whether checked-in change sets should be enabled for the given state
121      * in the configuration. The default is to enable for three-way incoming mode and
122      * two-way.
123      * @param configuration the configuration for a synchronize page
124      * @return whether checked-in change sets should be enabled for the given state
125      * in the configuration
126      */

127     public boolean enableCheckedInChangeSetsFor(ISynchronizePageConfiguration configuration) {
128         return supportsCheckedInChangeSets() &&
129             (configuration.getMode() == ISynchronizePageConfiguration.INCOMING_MODE ||
130                     configuration.getComparisonType() == ISynchronizePageConfiguration.TWO_WAY);
131     }
132     
133     /**
134      * Returns whether active change sets should be enabled for the given state
135      * in the configuration. The default is to enable for three-way outgoing mode.
136      * @param configuration the configuration for a synchronize page
137      * @return whether active change sets should be enabled for the given state
138      * in the configuration
139      */

140     public boolean enableActiveChangeSetsFor(ISynchronizePageConfiguration configuration) {
141         return supportsActiveChangeSets() &&
142             configuration.getMode() == ISynchronizePageConfiguration.OUTGOING_MODE;
143     }
144
145     /**
146      * Return whether change sets should be enabled by default on pages
147      * that display the participant.
148      * @return whether change sets should be enabled by default on pages
149      * that display the participant
150      */

151     public boolean enableChangeSetsByDefault() {
152         return false;
153     }
154     
155 }
156
Popular Tags