1 11 package org.eclipse.team.internal.ui.synchronize; 12 13 import org.eclipse.core.runtime.IAdaptable; 14 import org.eclipse.swt.widgets.Composite; 15 import org.eclipse.team.core.synchronize.FastSyncInfoFilter; 16 import org.eclipse.team.core.synchronize.SyncInfo; 17 import org.eclipse.team.internal.core.subscribers.SubscriberSyncInfoCollector; 18 import org.eclipse.team.internal.core.subscribers.WorkingSetFilteredSyncInfoCollector; 19 import org.eclipse.team.internal.ui.synchronize.actions.DefaultSynchronizePageActions; 20 import org.eclipse.team.internal.ui.synchronize.actions.SubscriberActionContribution; 21 import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; 22 import org.eclipse.team.ui.synchronize.SubscriberParticipant; 23 24 35 public final class SubscriberParticipantPage extends AbstractSynchronizePage implements IAdaptable { 36 37 private SubscriberParticipant participant; 38 39 private final static int[] INCOMING_MODE_FILTER = new int[] {SyncInfo.CONFLICTING, SyncInfo.INCOMING}; 40 private final static int[] OUTGOING_MODE_FILTER = new int[] {SyncInfo.CONFLICTING, SyncInfo.OUTGOING}; 41 private final static int[] BOTH_MODE_FILTER = new int[] {SyncInfo.CONFLICTING, SyncInfo.INCOMING, SyncInfo.OUTGOING}; 42 private final static int[] CONFLICTING_MODE_FILTER = new int[] {SyncInfo.CONFLICTING}; 43 44 47 private WorkingSetFilteredSyncInfoCollector collector; 48 49 52 public SubscriberParticipantPage(ISynchronizePageConfiguration configuration, SubscriberSyncInfoCollector subscriberCollector) { 53 super(configuration); 54 this.participant = (SubscriberParticipant)configuration.getParticipant(); 55 configuration.setComparisonType(isThreeWay() 56 ? ISynchronizePageConfiguration.THREE_WAY 57 : ISynchronizePageConfiguration.TWO_WAY); 58 configuration.addActionContribution(new DefaultSynchronizePageActions()); 59 configuration.addActionContribution(new SubscriberActionContribution()); 60 initializeCollector(configuration, subscriberCollector); 61 } 62 63 66 public SubscriberParticipant getParticipant() { 67 return participant; 68 } 69 70 protected AbstractViewerAdvisor createViewerAdvisor(Composite parent) { 71 return new TreeViewerAdvisor(parent, getConfiguration()); 72 } 73 74 82 protected void updateMode(int mode) { 83 if(collector != null && isThreeWay()) { 84 85 int[] modeFilter = BOTH_MODE_FILTER; 86 switch(mode) { 87 case ISynchronizePageConfiguration.INCOMING_MODE: 88 modeFilter = INCOMING_MODE_FILTER; break; 89 case ISynchronizePageConfiguration.OUTGOING_MODE: 90 modeFilter = OUTGOING_MODE_FILTER; break; 91 case ISynchronizePageConfiguration.BOTH_MODE: 92 modeFilter = BOTH_MODE_FILTER; break; 93 case ISynchronizePageConfiguration.CONFLICTING_MODE: 94 modeFilter = CONFLICTING_MODE_FILTER; break; 95 } 96 97 collector.setFilter( 98 new FastSyncInfoFilter.AndSyncInfoFilter( 99 new FastSyncInfoFilter[] { 100 new FastSyncInfoFilter.SyncInfoDirectionFilter(modeFilter) 101 })); 102 } 103 } 104 105 private void initializeCollector(ISynchronizePageConfiguration configuration, SubscriberSyncInfoCollector subscriberCollector) { 106 SubscriberParticipant participant = getParticipant(); 107 collector = new WorkingSetFilteredSyncInfoCollector(subscriberCollector, participant.getSubscriber().roots()); 108 updateMode(configuration.getMode()); 109 collector.reset(); 110 configuration.setProperty(ISynchronizePageConfiguration.P_SYNC_INFO_SET, collector.getSyncInfoTree()); 111 configuration.setProperty(SynchronizePageConfiguration.P_WORKING_SET_SYNC_INFO_SET, collector.getWorkingSetSyncInfoSet()); 112 } 113 114 117 protected boolean isThreeWay() { 118 return getParticipant().getSubscriber().getResourceComparator().isThreeWay(); 119 } 120 121 124 public void reset() { 125 getParticipant().reset(); 126 } 127 128 132 public WorkingSetFilteredSyncInfoCollector getCollector() { 133 return collector; 134 } 135 136 public void dispose() { 137 super.dispose(); 138 collector.dispose(); 139 } 140 141 144 protected ChangesSection createChangesSection(Composite parent) { 145 return new SyncInfoSetChangesSection(parent, this, getConfiguration()); 146 } 147 } 148 | Popular Tags |