1 /******************************************************************************* 2 * Copyright (c) 2000, 2006 IBM Corporation and others. 3 * 4 * This program and the accompanying materials 5 * are made available under the terms of the Eclipse Public License 2.0 6 * which accompanies this distribution, and is available at 7 * https://www.eclipse.org/legal/epl-2.0/ 8 * 9 * SPDX-License-Identifier: EPL-2.0 10 * 11 * Contributors: 12 * IBM Corporation - initial API and implementation 13 *******************************************************************************/ 14 package org.eclipse.team.internal.ui.synchronize; 15 16 import org.eclipse.team.core.diff.IDiff; 17 import org.eclipse.team.internal.core.subscribers.ActiveChangeSet; 18 import org.eclipse.team.internal.core.subscribers.ActiveChangeSetManager; 19 import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; 20 import org.eclipse.team.ui.synchronize.SynchronizePageActionGroup; 21 22 /** 23 * A change set capability is used by a SubscriberSynchronizePage 24 * to determine what, if any change set capabilities should be enabled 25 * for the pages of the participant. 26 * @since 3.1 27 */ 28 public abstract class ChangeSetCapability { 29 30 /** 31 * Return whether the associated participant supports 32 * the display of checked-in change sets. The default is 33 * unsupported (<code>false</code>). If subclasses support 34 * checked-in change sets, they must override the 35 * <code>createCheckedInChangeSetCollector</code> 36 * method to return an appropriate values. 37 * @return whether the associated participant supports 38 * the display of checked-in change sets 39 */ supportsCheckedInChangeSets()40 public boolean supportsCheckedInChangeSets() { 41 return false; 42 } 43 44 /** 45 * Return whether the associated participant supports 46 * the use of active change sets. The default is unsupported 47 * (<code>false</code>). If a subclass overrides this method in 48 * order to support active change sets, they must also override the methods 49 * <code>getActiveChangeSetManager</code>, 50 * <code>createChangeSet</code> and <code>editChangeSet</code>. 51 * @return whether the associated participant supports 52 * the use of active change sets 53 */ supportsActiveChangeSets()54 public boolean supportsActiveChangeSets() { 55 return false; 56 } 57 58 /** 59 * Return the change set collector that manages the active change 60 * set for the participant associated with this capability. A <code>null</code> 61 * is returned if active change sets are not supported. The default is to 62 * return <code>null</code>. This method must be 63 * overridden by subclasses that support active change sets. 64 * @return the change set collector that manages the active change 65 * set for the participant associated with this capability or 66 * <code>null</code> if active change sets are not supported. 67 */ getActiveChangeSetManager()68 public ActiveChangeSetManager getActiveChangeSetManager() { 69 return null; 70 } 71 72 /** 73 * Create a change set from the given manager that contains the given sync info. 74 * This method is invoked from the UI thread. A <code>null</code> 75 * is returned if active change sets are not supported. The default is to 76 * return <code>null</code>. This method must be 77 * overridden by subclasses that support active change sets. 78 * @param configuration the configuration of the page displaying the change sets 79 * @param diffs the sync info to be added to the change set 80 * @return the created set. 81 */ createChangeSet(ISynchronizePageConfiguration configuration, IDiff[] diffs)82 public ActiveChangeSet createChangeSet(ISynchronizePageConfiguration configuration, IDiff[] diffs) { 83 return null; 84 } 85 86 /** 87 * Edit the title and comment of the given change set. This method must be 88 * overridden by subclasses that support active change sets. 89 * This method is invoked from the UI thread. 90 * @param configuration the configuration of the page displaying the change sets 91 * @param set the set to be edited 92 */ editChangeSet(ISynchronizePageConfiguration configuration, ActiveChangeSet set)93 public void editChangeSet(ISynchronizePageConfiguration configuration, ActiveChangeSet set) { 94 // Default is to do nothing 95 } 96 97 /** 98 * Return a collector that can be used to group a set of checked-in changes 99 * into a set of checked-in change sets. This method must be 100 * overridden by subclasses that support checked-in change sets. 101 * @param configuration the configuration for the page that will be displaying the change sets 102 * @return a change set collector 103 */ createSyncInfoSetChangeSetCollector(ISynchronizePageConfiguration configuration)104 public SyncInfoSetChangeSetCollector createSyncInfoSetChangeSetCollector(ISynchronizePageConfiguration configuration) { 105 return null; 106 } 107 108 /** 109 * Return an action group for contributing context menu items 110 * to the synchronize page while change sets are enabled. 111 * Return <code>null</code> if no custom actions are required. 112 * Note that only context menus can be contributed since the view menu 113 * and toolbar menu are fixed. This method can be overridden by subclasses 114 * who wish to support custom change set actions. 115 * @return an action group for contributing context menu items 116 * to the synchronize page while change sets are enabled or <code>null</code> 117 */ getActionGroup()118 public SynchronizePageActionGroup getActionGroup() { 119 return null; 120 } 121 122 /** 123 * Returns whether checked-in change sets should be enabled for the given state 124 * in the configuration. The default is to enable for three-way incoming mode and 125 * two-way. 126 * @param configuration the configuration for a synchronize page 127 * @return whether checked-in change sets should be enabled for the given state 128 * in the configuration 129 */ enableCheckedInChangeSetsFor(ISynchronizePageConfiguration configuration)130 public boolean enableCheckedInChangeSetsFor(ISynchronizePageConfiguration configuration) { 131 return supportsCheckedInChangeSets() && 132 (configuration.getMode() == ISynchronizePageConfiguration.INCOMING_MODE || 133 configuration.getComparisonType() == ISynchronizePageConfiguration.TWO_WAY); 134 } 135 136 /** 137 * Returns whether active change sets should be enabled for the given state 138 * in the configuration. The default is to enable for three-way outgoing mode. 139 * @param configuration the configuration for a synchronize page 140 * @return whether active change sets should be enabled for the given state 141 * in the configuration 142 */ enableActiveChangeSetsFor(ISynchronizePageConfiguration configuration)143 public boolean enableActiveChangeSetsFor(ISynchronizePageConfiguration configuration) { 144 return supportsActiveChangeSets() && 145 configuration.getMode() == ISynchronizePageConfiguration.OUTGOING_MODE; 146 } 147 148 /** 149 * Return whether change sets should be enabled by default on pages 150 * that display the participant. 151 * @return whether change sets should be enabled by default on pages 152 * that display the participant 153 */ enableChangeSetsByDefault()154 public boolean enableChangeSetsByDefault() { 155 return false; 156 } 157 158 } 159