![]() |
![]() |
org.eclipse.team.ui_3.6.101.R37x_v20111109-0800ArrayList; import java.util.Arrays; import java.util.List; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IWorkspaceRunnable; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.team.core.ITeamStatus; import org.eclipse.team.core.synchronize.ISyncInfoSetChangeEvent; import org.eclipse.team.core.synchronize.ISyncInfoSetChangeListener; import org.eclipse.team.core.synchronize.SyncInfo; import org.eclipse.team.core.synchronize.SyncInfoSet; import org.eclipse.team.core.synchronize.SyncInfoTree; import org.eclipse.team.internal.core.subscribers.ChangeSet; import org.eclipse.team.internal.core.subscribers.ChangeSetManager; import org.eclipse.team.internal.core.subscribers.CheckedInChangeSet; import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; public abstract class SyncInfoSetChangeSetCollector extends ChangeSetManager { private final ISynchronizePageConfiguration configuration; private ChangeSetModelProvider provider; ISyncInfoSetChangeListener changeSetListener = new ISyncInfoSetChangeListener() { public void syncInfoSetReset(SyncInfoSet set, IProgressMonitor monitor) { handleChangeEvent(set); } public void syncInfoChanged(ISyncInfoSetChangeEvent event, IProgressMonitor monitor) { handleChangeEvent(event.getSet()); } public void syncInfoSetErrors(SyncInfoSet set, ITeamStatus[] errors, IProgressMonitor monitor) {} private void handleChangeEvent(SyncInfoSet set) { if (set.isEmpty()) { ChangeSet changeSet = getChangeSet(set); if (changeSet != null) { remove(changeSet); } } } }; public SyncInfoSetChangeSetCollector(ISynchronizePageConfiguration configuration) { this.configuration = configuration; } protected abstract void add(SyncInfo[] paramArrayOfSyncInfo); protected void remove(IResource[] resources) { ChangeSet[] sets = getSets(); for (int i = 0; i < sets.length; i++) { ChangeSet set = sets[i]; set.remove(resources); } } protected ISyncInfoSetChangeListener getChangeSetChangeListener() { return changeSetListener; } public void reset(SyncInfoSet seedSet) { ChangeSet[] sets = getSets(); for (int i = 0; i < sets.length; i++) { ChangeSet set2 = sets[i]; remove(set2); } if (seedSet != null) { add(seedSet.getSyncInfos()); } } public void handleChange(ISyncInfoSetChangeEvent event) { List removals = new ArrayList(); List additions = new ArrayList(); removals.addAll(Arrays.asList(event.getRemovedResources())); additions.addAll(Arrays.asList(event.getAddedResources())); SyncInfo[] changed = event.getChangedResources(); for (int i = 0; i < changed.length; i++) { SyncInfo info = changed[i]; additions.add(info); removals.add(info.getLocal()); } if (!removals.isEmpty()) { remove((IResource[])removals.toArray(new IResource[removals.size()])); } if (!additions.isEmpty()) { add((SyncInfo[])additions.toArray(new SyncInfo[additions.size()])); } } public final ISynchronizePageConfiguration getConfiguration() { return configuration; } protected final void performUpdate(IWorkspaceRunnable runnable, boolean preserveExpansion, IProgressMonitor monitor) { provider.performUpdate(runnable, preserveExpansion, false); } public final void setProvider(ChangeSetModelProvider provider) { this.provider = provider; } public void waitUntilDone(IProgressMonitor monitor) {} protected void handleSetAdded(ChangeSet set) { ((CheckedInChangeSet)set).getSyncInfoSet().addSyncSetChangedListener(getChangeSetChangeListener()); super.handleSetAdded(set); } protected void handleSetRemoved(ChangeSet set) { ((CheckedInChangeSet)set).getSyncInfoSet().removeSyncSetChangedListener(getChangeSetChangeListener()); super.handleSetRemoved(set); } protected ChangeSet getChangeSet(SyncInfoSet set) { ChangeSet[] sets = getSets(); for (int i = 0; i < sets.length; i++) { ChangeSet changeSet = sets[i]; if (((CheckedInChangeSet)changeSet).getSyncInfoSet() == set) { return changeSet; } } return null; } public SyncInfoTree getSyncInfoSet(ChangeSet set) { return ((CheckedInChangeSet)set).getSyncInfoSet(); } } /* Location: * Qualified Name: org.eclipse.team.internal.ui.synchronize.SyncInfoSetChangeSetCollector * Java Class Version: 1.2 (46.0) * JD-Core Version: 0.7.1 */ package org.eclipse.team.internal.ui.synchronize; import org.eclipse.team.ui.synchronize.ISynchronizeModelElement; import org.eclipse.team.ui.synchronize.SynchronizePageActionGroup; class SyncInfoSetChangesSection$1 extends SynchronizePageActionGroup { final SyncInfoSetChangesSection this$0; SyncInfoSetChangesSection$1(SyncInfoSetChangesSection paramSyncInfoSetChangesSection) { this$0 = paramSyncInfoSetChangesSection; } public void modelChanged(ISynchronizeModelElement root) { this$0.calculateDescription(); } } /* Location: * Qualified Name: org.eclipse.team.internal.ui.synchronize.SyncInfoSetChangesSection.1 * Java Class Version: 1.2 (46.0) * JD-Core Version: 0.7.1 */ package org.eclipse.team.internal.ui.synchronize; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.team.core.ITeamStatus; import org.eclipse.team.core.synchronize.ISyncInfoSetChangeEvent; import org.eclipse.team.core.synchronize.ISyncInfoSetChangeListener; import org.eclipse.team.core.synchronize.SyncInfoSet; class SyncInfoSetChangesSection$2 implements ISyncInfoSetChangeListener { final SyncInfoSetChangesSection this$0; SyncInfoSetChangesSection$2(SyncInfoSetChangesSection paramSyncInfoSetChangesSection) { this$0 = paramSyncInfoSetChangesSection; } public void syncInfoSetReset(SyncInfoSet set, IProgressMonitor monitor) {} public void syncInfoChanged(ISyncInfoSetChangeEvent event, IProgressMonitor monitor) { this$0.calculateDescription(); } public void syncInfoSetErrors(SyncInfoSet set, ITeamStatus[] errors, IProgressMonitor monitor) {} } /* Location: * Qualified Name: org.eclipse.team.internal.ui.synchronize.SyncInfoSetChangesSection.2 * Java Class Version: 1.2 (46.0) * JD-Core Version: 0.7.1 */ package org.eclipse.team.internal.ui.synchronize; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.team.core.ITeamStatus; import org.eclipse.team.core.synchronize.ISyncInfoSetChangeEvent; import org.eclipse.team.core.synchronize.ISyncInfoSetChangeListener; import org.eclipse.team.core.synchronize.SyncInfoSet; class SyncInfoSetChangesSection$3 implements ISyncInfoSetChangeListener { final SyncInfoSetChangesSection this$0; SyncInfoSetChangesSection$3(SyncInfoSetChangesSection paramSyncInfoSetChangesSection) { this$0 = paramSyncInfoSetChangesSection; } public void syncInfoSetReset(SyncInfoSet set, IProgressMonitor monitor) { this$0.calculateDescription(); } public void syncInfoChanged(ISyncInfoSetChangeEvent event, IProgressMonitor monitor) {} public void syncInfoSetErrors(SyncInfoSet set, ITeamStatus[] errors, IProgressMonitor monitor) { this$0.calculateDescription(); } } /* Location: * Qualified Name: org.eclipse.team.internal.ui.synchronize.SyncInfoSetChangesSection.3 * Java Class Version: 1.2 (46.0) * JD-Core Version: 0.7.1 */ package org.eclipse.team.internal.ui.synchronize; class SyncInfoSetChangesSection$4 implements Runnable { final SyncInfoSetChangesSection this$0; SyncInfoSetChangesSection$4(SyncInfoSetChangesSection paramSyncInfoSetChangesSection) { this$0 = paramSyncInfoSetChangesSection; } public void run() { this$0.updatePage(SyncInfoSetChangesSection.access$0(this$0, this$0.getContainer())); SyncInfoSetChangesSection.access$1(this$0, true); } } /* Location: * Qualified Name: org.eclipse.team.internal.ui.synchronize.SyncInfoSetChangesSection.4 * Java Class Version: 1.2 (46.0) * JD-Core Version: 0.7.1 */ package org.eclipse.team.internal.ui.synchronize; import org.eclipse.ui.forms.events.HyperlinkAdapter; import org.eclipse.ui.forms.events.HyperlinkEvent; class SyncInfoSetChangesSection$5 extends HyperlinkAdapter { final SyncInfoSetChangesSection this$0; SyncInfoSetChangesSection$5(SyncInfoSetChangesSection paramSyncInfoSetChangesSection) { this$0 = paramSyncInfoSetChangesSection; } public void linkActivated(HyperlinkEvent e) { this$0.showErrors(); } } /* Location: * Qualified Name: org.eclipse.team.internal.ui.synchronize.SyncInfoSetChangesSection.5 * Java Class Version: 1.2 (46.0) * JD-Core Version: 0.7.1 */ package org.eclipse.team.internal.ui.synchronize; import org.eclipse.ui.forms.events.HyperlinkAdapter; import org.eclipse.ui.forms.events.HyperlinkEvent; class SyncInfoSetChangesSection$6 extends HyperlinkAdapter { final SyncInfoSetChangesSection this$0; SyncInfoSetChangesSection$6(SyncInfoSetChangesSection paramSyncInfoSetChangesSection) { this$0 = paramSyncInfoSetChangesSection; } public void linkActivated(HyperlinkEvent e) { this$0.getPage().reset(); } } /* Location: * Qualified Name: org.eclipse.team.internal.ui.synchronize.SyncInfoSetChangesSection.6 * Java Class Version: 1.2 (46.0) * JD-Core Version: 0.7.1 */ package org.eclipse.team.internal.ui.synchronize; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.MultiStatus; import org.eclipse.jface.dialogs.ErrorDialog; import org.eclipse.osgi.util.NLS; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.team.core.ITeamStatus; import org.eclipse.team.core.synchronize.ISyncInfoSetChangeEvent; import org.eclipse.team.core.synchronize.ISyncInfoSetChangeListener; import org.eclipse.team.core.synchronize.SyncInfoSet; import org.eclipse.team.core.synchronize.SyncInfoTree; import org.eclipse.team.internal.ui.TeamUIMessages; import org.eclipse.team.internal.ui.TeamUIPlugin; import org.eclipse.team.internal.ui.Utils; import org.eclipse.team.ui.synchronize.ISynchronizeModelElement; import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; import org.eclipse.team.ui.synchronize.ISynchronizeParticipant; import org.eclipse.team.ui.synchronize.SynchronizePageActionGroup; import org.eclipse.ui.forms.events.HyperlinkAdapter; import org.eclipse.ui.forms.events.HyperlinkEvent; import org.eclipse.ui.forms.widgets.Hyperlink; public class SyncInfoSetChangesSection extends ForwardingChangesSection { private boolean showingError; private SynchronizePageActionGroup changedListener = new SynchronizePageActionGroup() { public void modelChanged(ISynchronizeModelElement root) { calculateDescription(); } }; private ISyncInfoSetChangeListener subscriberListener = new ISyncInfoSetChangeListener() { public void syncInfoSetReset(SyncInfoSet set, IProgressMonitor monitor) {} public void syncInfoChanged(ISyncInfoSetChangeEvent event, IProgressMonitor monitor) { calculateDescription(); } public void syncInfoSetErrors(SyncInfoSet set, ITeamStatus[] errors, IProgressMonitor monitor) {} }; private ISyncInfoSetChangeListener outputSetListener = new ISyncInfoSetChangeListener() { public void syncInfoSetReset(SyncInfoSet set, IProgressMonitor monitor) { calculateDescription(); } public void syncInfoChanged(ISyncInfoSetChangeEvent event, IProgressMonitor monitor) {} public void syncInfoSetErrors(SyncInfoSet set, ITeamStatus[] errors, IProgressMonitor monitor) { calculateDescription(); } }; public SyncInfoSetChangesSection(Composite parent, AbstractSynchronizePage page, ISynchronizePageConfiguration configuration) { super(parent, page, configuration); } protected void initializeChangesViewer() { super.initializeChangesViewer(); getConfiguration().addActionContribution(changedListener); getParticipantSyncInfoSet().addSyncSetChangedListener(subscriberListener); getVisibleSyncInfoSet().addSyncSetChangedListener(outputSetListener); } protected void calculateDescription() { SyncInfoTree syncInfoTree = getVisibleSyncInfoSet(); if (syncInfoTree.getErrors().length > 0) { if (!showingError) { TeamUIPlugin.getStandardDisplay().asyncExec(new Runnable() { public void run() { updatePage(SyncInfoSetChangesSection.this.getErrorComposite(getContainer())); showingError = true; } }); } return; } showingError = false; super.calculateDescription(); } protected long getChangesInMode(int candidateMode) { SyncInfoSet participantSet = getParticipantSyncInfoSet(); long numChanges; long numChanges; long numChanges; long numChanges; switch (candidateMode) { case 2: numChanges = participantSet.countFor(4, 12); break; case 1: numChanges = participantSet.countFor(8, 12); break; case 4: numChanges = participantSet.countFor(8, 12) + participantSet.countFor(4, 12); break; case 3: default: numChanges = 0L; } return numChanges; } protected int getCandidateMode() { SyncInfoSet participantSet = getParticipantSyncInfoSet(); SynchronizePageConfiguration configuration = (SynchronizePageConfiguration)getConfiguration(); long outgoingChanges = participantSet.countFor(4, 12); if (outgoingChanges > 0L) { if (configuration.isModeSupported(2)) { return 2; } if (configuration.isModeSupported(4)) { return 4; } } long incomingChanges = participantSet.countFor(8, 12); if (incomingChanges > 0L) { if (configuration.isModeSupported(1)) { return 1; } if (configuration.isModeSupported(4)) { return 4; } } return configuration.getMode(); } public void dispose() { super.dispose(); getConfiguration().removeActionContribution(changedListener); getParticipantSyncInfoSet().removeSyncSetChangedListener(subscriberListener); getVisibleSyncInfoSet().removeSyncSetChangedListener(outputSetListener); } private Composite getErrorComposite(Composite parent) { Composite composite = new Composite(parent, 0); composite.setBackground(getListBackgroundColor()); GridLayout layout = new GridLayout(); numColumns = 2; composite.setLayout(layout); GridData data = new GridData(1808); grabExcessVerticalSpace = true; composite.setLayoutData(data); Hyperlink link = new Hyperlink(composite, 64); link.setText(TeamUIMessages.ChangesSection_8); link.addHyperlinkListener(new HyperlinkAdapter() { public void linkActivated(HyperlinkEvent e) { showErrors(); } }); link.setBackground(getListBackgroundColor()); link.setUnderlined(true); link = new Hyperlink(composite, 64); link.setText(TeamUIMessages.ChangesSection_9); link.addHyperlinkListener(new HyperlinkAdapter() { public void linkActivated(HyperlinkEvent e) { getPage().reset(); } }); link.setBackground(getListBackgroundColor()); link.setUnderlined(true); createDescriptionLabel(composite, NLS.bind(TeamUIMessages.ChangesSection_10, new String[] { Utils.shortenText(100, getConfiguration().getParticipant().getName()) })); return composite; } void showErrors() { ITeamStatus[] status = getVisibleSyncInfoSet().getErrors(); String title = TeamUIMessages.ChangesSection_11; if (status.length == 1) { ErrorDialog.openError(getShell(), title, status[0].getMessage(), status[0]); } else { MultiStatus multi = new MultiStatus("org.eclipse.team.ui", 0, status, TeamUIMessages.ChangesSection_12, null); ErrorDialog.openError(getShell(), title, null, multi); } } protected int getChangesCount() { return getParticipantSyncInfoSet().size(); } protected long getVisibleChangesCount() { return getVisibleSyncInfoSet().size(); } private SyncInfoTree getVisibleSyncInfoSet() { return (SyncInfoTree)getConfiguration().getProperty("org.eclipse.team.ui.P_SYNC_INFO_SET"); } private SyncInfoSet getParticipantSyncInfoSet() { return (SyncInfoSet)getConfiguration().getProperty("org.eclipse.team.ui.P_WORKING_SET_SYNC_INFO_SET"); } } /* Location: * Qualified Name: org.eclipse.team.internal.ui.synchronize.SyncInfoSetChangesSection * Java Class Version: 1.2 (46.0) * JD-Core Version: 0.7.1 */ package org.eclipse.team.internal.ui.synchronize; import java.util.HashMap; import java.util.Map; import org.eclipse.core.runtime.CoreException; import org.eclipse.osgi.util.NLS; import org.eclipse.team.core.TeamException; import org.eclipse.team.internal.ui.TeamUIMessages; import org.eclipse.team.internal.ui.TeamUIPlugin; import org.eclipse.team.internal.ui.Utils; import org.eclipse.team.internal.ui.registry.SynchronizeParticipantDescriptor; import org.eclipse.team.ui.synchronize.ISynchronizeParticipant; import org.eclipse.team.ui.synchronize.ISynchronizeParticipantDescriptor; import org.eclipse.team.ui.synchronize.ISynchronizeParticipantReference; import org.eclipse.ui.IMemento; import org.eclipse.ui.PartInitException; class SynchronizeManager$ParticipantInstance implements ISynchronizeParticipantReference { private Map participants; private IMemento savedState; private SynchronizeParticipantDescriptor descriptor; private String secondaryId; private String displayName; private boolean dead; final SynchronizeManager this$0; public SynchronizeManager$ParticipantInstance(SynchronizeManager paramSynchronizeManager, SynchronizeParticipantDescriptor descriptor, String secondaryId, String displayName, IMemento savedState) { this$0 = paramSynchronizeManager; participants = new HashMap(); this.secondaryId = secondaryId; this.savedState = savedState; this.descriptor = descriptor; this.displayName = displayName; } public void save(IMemento memento) { if (dead) { return; } String key = Utils.getKey(descriptor.getId(), getSecondaryId()); ISynchronizeParticipant ref = (ISynchronizeParticipant)participants.get(key); if (ref != null) { ref.saveState(memento); } else if (savedState != null) { memento.putMemento(savedState); } } public boolean equals(Object other) { if (other == this) { return true; } if (!(other instanceof ISynchronizeParticipantReference)) { return false; } ISynchronizeParticipantReference otherRef = (ISynchronizeParticipantReference)other; String otherSecondaryId = otherRef.getSecondaryId(); return (otherRef.getId().equals(getId())) && (Utils.equalObject(getSecondaryId(), otherSecondaryId)); } public String getId() { return descriptor.getId(); } public String getSecondaryId() { return secondaryId; } public String getDisplayName() { String key = Utils.getKey(descriptor.getId(), getSecondaryId()); ISynchronizeParticipant participant = (ISynchronizeParticipant)participants.get(key); if (participant != null) { return participant.getName(); } return displayName != null ? displayName : descriptor.getName(); } public boolean isInstantiated() { String key = Utils.getKey(descriptor.getId(), getSecondaryId()); return (ISynchronizeParticipant)participants.get(key) != null; } public ISynchronizeParticipant getParticipant() throws TeamException { if (dead) { return null; } String key = Utils.getKey(descriptor.getId(), getSecondaryId()); try { ISynchronizeParticipant participant = (ISynchronizeParticipant)participants.get(key); if (participant == null) { participant = instantiate(); if (participant != null) { participants.put(key, participant); } } return participant; } catch (TeamException e) { TeamUIPlugin.log(e); SynchronizeManager.access$1(this$0).remove(key); throw new TeamException(TeamUIMessages.SynchronizeManager_8, e); } } public void setParticipant(ISynchronizeParticipant participant) { String key = Utils.getKey(descriptor.getId(), getSecondaryId()); participants.put(key, participant); } public ISynchronizeParticipantDescriptor getDescriptor() { return descriptor; } private ISynchronizeParticipant instantiate() throws TeamException { try { ISynchronizeParticipant participant = (ISynchronizeParticipant)TeamUIPlugin.createExtension(descriptor.getConfigurationElement(), "class"); participant.setInitializationData(descriptor.getConfigurationElement(), null, null); participant.init(getSecondaryId(), savedState); savedState = null; return participant; } catch (PartInitException e) { throw new TeamException(NLS.bind(TeamUIMessages.SynchronizeManager_11, new String[] { descriptor.getName() }), e); } catch (CoreException e) { throw TeamException.asTeamException(e); } catch (Exception e) { throw new TeamException(NLS.bind(TeamUIMessages.SynchronizeManager_11, new String[] { descriptor.getName() }), e); } } /* Error */ public void dispose() { // Byte code: // 0: aload_0 // 1: invokevirtual 180 org/eclipse/team/internal/ui/synchronize/SynchronizeManager$ParticipantInstance:getParticipant ()Lorg/eclipse/team/ui/synchronize/ISynchronizeParticipant; // 4: astore_1 // 5: aload_1 // 6: ifnull +29 -> 35 // 9: aload_1 // 10: invokeinterface 185 1 0 // 15: goto +20 -> 35 // 18: pop // 19: aload_0 // 20: iconst_1 // 21: putfield 157 org/eclipse/team/internal/ui/synchronize/SynchronizeManager$ParticipantInstance:dead Z // 24: goto +16 -> 40 // 27: astore_2 // 28: aload_0 // 29: iconst_1 // 30: putfield 157 org/eclipse/team/internal/ui/synchronize/SynchronizeManager$ParticipantInstance:dead Z // 33: aload_2 // 34: athrow // 35: aload_0 // 36: iconst_1 // 37: putfield 157 org/eclipse/team/internal/ui/synchronize/SynchronizeManager$ParticipantInstance:dead Z // 40: return // Line number table: // Java source line #262 -> byte code offset #0 // Java source line #263 -> byte code offset #5 // Java source line #264 -> byte code offset #9 // Java source line #265 -> byte code offset #18 // Java source line #268 -> byte code offset #19 // Java source line #267 -> byte code offset #27 // Java source line #268 -> byte code offset #28 // Java source line #269 -> byte code offset #33 // Java source line #268 -> byte code offset #35 // Java source line #270 -> byte code offset #40 // Local variable table: // start length slot name signature // 0 41 0 this ParticipantInstance // 4 6 1 participant ISynchronizeParticipant // 27 7 2 localObject Object // 18 1 3 localTeamException TeamException // Exception table: // from to target type // 0 15 18 org/eclipse/team/core/TeamException // 0 19 27 finally } } /* Location: * Qualified Name: org.eclipse.team.internal.ui.synchronize.SynchronizeManager.ParticipantInstance * Java Class Version: 1.2 (46.0) * JD-Core Version: 0.7.1 */ package org.eclipse.team.internal.ui.synchronize; import org.eclipse.core.runtime.ISafeRunnable; import org.eclipse.core.runtime.ListenerList; import org.eclipse.core.runtime.SafeRunner; import org.eclipse.team.internal.ui.TeamUIMessages; import org.eclipse.team.internal.ui.TeamUIPlugin; import org.eclipse.team.ui.synchronize.ISynchronizeParticipant; import org.eclipse.team.ui.synchronize.ISynchronizeParticipantListener; class SynchronizeManager$SynchronizeViewPageNotifier implements ISafeRunnable { private ISynchronizeParticipantListener fListener; private int fType; private ISynchronizeParticipant[] fChanged; final SynchronizeManager this$0; SynchronizeManager$SynchronizeViewPageNotifier(SynchronizeManager paramSynchronizeManager) { this$0 = paramSynchronizeManager; } public void handleException(Throwable exception) { TeamUIPlugin.log(4, TeamUIMessages.SynchronizeManager_7, exception); } public void run() throws Exception { switch (fType) { case 1: fListener.participantsAdded(fChanged); break; case 2: fListener.participantsRemoved(fChanged); } } public void notify(ISynchronizeParticipant[] participants, int update) { if (SynchronizeManager.access$0(this$0) == null) { return; } fChanged = participants; fType = update; Object[] copiedListeners = SynchronizeManager.access$0(this$0).getListeners(); for (int i = 0; i < copiedListeners.length; i++) { fListener = ((ISynchronizeParticipantListener)copiedListeners[i]); SafeRunner.run(this); } fChanged = null; fListener = null; } } /* Location: * Qualified Name: org.eclipse.team.internal.ui.synchronize.SynchronizeManager.SynchronizeViewPageNotifier * Java Class Version: 1.2 (46.0) * JD-Core Version: 0.7.1 */ package org.eclipse.team.internal.ui.synchronize; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.Reader; import java.io.Writer; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.ISafeRunnable; import org.eclipse.core.runtime.ListenerList; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.SafeRunner; import org.eclipse.core.runtime.Status; import org.eclipse.jface.dialogs.MessageDialogWithToggle; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.osgi.util.NLS; import org.eclipse.team.core.TeamException; import org.eclipse.team.internal.ui.TeamUIMessages; import org.eclipse.team.internal.ui.TeamUIPlugin; import org.eclipse.team.internal.ui.Utils; import org.eclipse.team.internal.ui.registry.SynchronizeParticipantDescriptor; import org.eclipse.team.internal.ui.registry.SynchronizeParticipantRegistry; import org.eclipse.team.internal.ui.registry.SynchronizeWizardDescription; import org.eclipse.team.internal.ui.registry.SynchronizeWizardRegistry; import org.eclipse.team.ui.synchronize.ISynchronizeManager; import org.eclipse.team.ui.synchronize.ISynchronizeParticipant; import org.eclipse.team.ui.synchronize.ISynchronizeParticipantDescriptor; import org.eclipse.team.ui.synchronize.ISynchronizeParticipantListener; import org.eclipse.team.ui.synchronize.ISynchronizeParticipantReference; import org.eclipse.team.ui.synchronize.ISynchronizeView; import org.eclipse.team.ui.synchronize.ModelSynchronizeParticipant; import org.eclipse.ui.IMemento; import org.eclipse.ui.IPerspectiveDescriptor; import org.eclipse.ui.IPerspectiveRegistry; import org.eclipse.ui.IViewPart; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PartInitException; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.Saveable; import org.eclipse.ui.WorkbenchException; import org.eclipse.ui.XMLMemento; public class SynchronizeManager implements ISynchronizeManager { private ListenerList fListeners = null; private SynchronizeParticipantRegistry participantRegistry = new SynchronizeParticipantRegistry(); private SynchronizeWizardRegistry wizardRegistry = new SynchronizeWizardRegistry(); private Map participantReferences = Collections.synchronizedMap(new HashMap(10)); private static final int ADDED = 1; private static final int REMOVED = 2; private static final String CTX_PARTICIPANTS = "syncparticipants"; private static final String CTX_PARTICIPANT = "participant"; private static final String CTX_ID = "id"; private static final String CTX_SECONDARY_ID = "secondary_id"; private static final String CTX_PARTICIPANT_DISPLAY_NAME = "displayName"; private static final String CTX_PARTICIPANT_DATA = "data"; private static final String FILENAME = "syncParticipants.xml"; class SynchronizeViewPageNotifier implements ISafeRunnable { private ISynchronizeParticipantListener fListener; private int fType; private ISynchronizeParticipant[] fChanged; SynchronizeViewPageNotifier() {} public void handleException(Throwable exception) { TeamUIPlugin.log(4, TeamUIMessages.SynchronizeManager_7, exception); } public void run() throws Exception { switch (fType) { case 1: fListener.participantsAdded(fChanged); break; case 2: fListener.participantsRemoved(fChanged); } } public void notify(ISynchronizeParticipant[] participants, int update) { if (fListeners == null) { return; } fChanged = participants; fType = update; Object[] copiedListeners = fListeners.getListeners(); for (int i = 0; i < copiedListeners.length; i++) { fListener = ((ISynchronizeParticipantListener)copiedListeners[i]); SafeRunner.run(this); } fChanged = null; fListener = null; } } private class ParticipantInstance implements ISynchronizeParticipantReference { private Map participants; private IMemento savedState; private SynchronizeParticipantDescriptor descriptor; private String secondaryId; private String displayName; private boolean dead; public ParticipantInstance(SynchronizeParticipantDescriptor descriptor, String secondaryId, String displayName, IMemento savedState) { participants = new HashMap(); this.secondaryId = secondaryId; this.savedState = savedState; this.descriptor = descriptor; this.displayName = displayName; } public void save(IMemento memento) { if (dead) { return; } String key = Utils.getKey(descriptor.getId(), getSecondaryId()); ISynchronizeParticipant ref = (ISynchronizeParticipant)participants.get(key); if (ref != null) { ref.saveState(memento); } else if (savedState != null) { memento.putMemento(savedState); } } public boolean equals(Object other) { if (other == this) { return true; } if (!(other instanceof ISynchronizeParticipantReference)) { return false; } ISynchronizeParticipantReference otherRef = (ISynchronizeParticipantReference)other; String otherSecondaryId = otherRef.getSecondaryId(); return (otherRef.getId().equals(getId())) && (Utils.equalObject(getSecondaryId(), otherSecondaryId)); } public String getId() { return descriptor.getId(); } public String getSecondaryId() { return secondaryId; } public String getDisplayName() { String key = Utils.getKey(descriptor.getId(), getSecondaryId()); ISynchronizeParticipant participant = (ISynchronizeParticipant)participants.get(key); if (participant != null) { return participant.getName(); } return displayName != null ? displayName : descriptor.getName(); } public boolean isInstantiated() { String key = Utils.getKey(descriptor.getId(), getSecondaryId()); return (ISynchronizeParticipant)participants.get(key) != null; } public ISynchronizeParticipant getParticipant() throws TeamException { if (dead) { return null; } String key = Utils.getKey(descriptor.getId(), getSecondaryId()); try { ISynchronizeParticipant participant = (ISynchronizeParticipant)participants.get(key); if (participant == null) { participant = instantiate(); if (participant != null) { participants.put(key, participant); } } return participant; } catch (TeamException e) { TeamUIPlugin.log(e); participantReferences.remove(key); throw new TeamException(TeamUIMessages.SynchronizeManager_8, e); } } public void setParticipant(ISynchronizeParticipant participant) { String key = Utils.getKey(descriptor.getId(), getSecondaryId()); participants.put(key, participant); } public ISynchronizeParticipantDescriptor getDescriptor() { return descriptor; } private ISynchronizeParticipant instantiate() throws TeamException { try { ISynchronizeParticipant participant = (ISynchronizeParticipant)TeamUIPlugin.createExtension(descriptor.getConfigurationElement(), "class"); participant.setInitializationData(descriptor.getConfigurationElement(), null, null); participant.init(getSecondaryId(), savedState); savedState = null; return participant; } catch (PartInitException e) { throw new TeamException(NLS.bind(TeamUIMessages.SynchronizeManager_11, new String[] { descriptor.getName() }), e); } catch (CoreException e) { throw TeamException.asTeamException(e); } catch (Exception e) { throw new TeamException(NLS.bind(TeamUIMessages.SynchronizeManager_11, new String[] { descriptor.getName() }), e); } } /* Error */ public void dispose() { // Byte code: // 0: aload_0 // 1: invokevirtual 180 org/eclipse/team/internal/ui/synchronize/SynchronizeManager$ParticipantInstance:getParticipant ()Lorg/eclipse/team/ui/synchronize/ISynchronizeParticipant; // 4: astore_1 // 5: aload_1 // 6: ifnull +29 -> 35 // 9: aload_1 // 10: invokeinterface 185 1 0 // 15: goto +20 -> 35 // 18: pop // 19: aload_0 // 20: iconst_1 // 21: putfield 157 org/eclipse/team/internal/ui/synchronize/SynchronizeManager$ParticipantInstance:dead Z // 24: goto +16 -> 40 // 27: astore_2 // 28: aload_0 // 29: iconst_1 // 30: putfield 157 org/eclipse/team/internal/ui/synchronize/SynchronizeManager$ParticipantInstance:dead Z // 33: aload_2 // 34: athrow // 35: aload_0 // 36: iconst_1 // 37: putfield 157 org/eclipse/team/internal/ui/synchronize/SynchronizeManager$ParticipantInstance:dead Z // 40: return // Line number table: // Java source line #262 -> byte code offset #0 // Java source line #263 -> byte code offset #5 // Java source line #264 -> byte code offset #9 // Java source line #265 -> byte code offset #18 // Java source line #268 -> byte code offset #19 // Java source line #267 -> byte code offset #27 // Java source line #268 -> byte code offset #28 // Java source line #269 -> byte code offset #33 // Java source line #268 -> byte code offset #35 // Java source line #270 -> byte code offset #40 // Local variable table: // start length slot name signature // 0 41 0 this ParticipantInstance // 4 6 1 participant ISynchronizeParticipant // 27 7 2 localObject Object // 18 1 3 localTeamException TeamException // Exception table: // from to target type // 0 15 18 org/eclipse/team/core/TeamException // 0 19 27 finally } } public SynchronizeManager() { init(); } public void addSynchronizeParticipantListener(ISynchronizeParticipantListener listener) { if (fListeners == null) { fListeners = new ListenerList(1); } fListeners.add(listener); } public void removeSynchronizeParticipantListener(ISynchronizeParticipantListener listener) { if (fListeners != null) { fListeners.remove(listener); } } private ParticipantInstance createParticipantReference(String type, String secondaryId, String displayName) throws PartInitException { SynchronizeParticipantDescriptor desc = participantRegistry.find(type); if (desc == null) { throw new PartInitException(NLS.bind(TeamUIMessages.SynchronizeManager_19, new String[] { type })); } String key = Utils.getKey(type, secondaryId); ParticipantInstance ref = (ParticipantInstance)participantReferences.get(key); if (ref == null) { ref = new ParticipantInstance(desc, secondaryId, displayName, null); } return ref; } public synchronized void addSynchronizeParticipants(ISynchronizeParticipant[] participants) { List added = new ArrayList(participants.length); for (int i = 0; i < participants.length; i++) { ISynchronizeParticipant participant = participants[i]; String key = Utils.getKey(participant.getId(), participant.getSecondaryId()); if (!participantReferences.containsKey(key)) { try { ParticipantInstance ref = createParticipantReference(participant.getId(), participant.getSecondaryId(), participant.getName()); ref.setParticipant(participant); removeMatchingParticipant(participant.getId()); participantReferences.put(key, ref); added.add(participant); } catch (PartInitException e) { TeamUIPlugin.log(e); } } } if (!added.isEmpty()) { saveState(); fireUpdate((ISynchronizeParticipant[])added.toArray(new ISynchronizeParticipant[added.size()]), 1); } } private void removeMatchingParticipant(String id) { ISynchronizeParticipantReference[] refs = get(id); if (refs.length > 0) { for (int i = 0; i < refs.length; i++) { ISynchronizeParticipantReference reference = refs[i]; try { ISynchronizeParticipant p = reference.getParticipant(); if ((!p.isPinned()) && (!isDirty(p))) { removeSynchronizeParticipants(new ISynchronizeParticipant[] { p }); } } catch (TeamException localTeamException) {} } } } private boolean isDirty(ISynchronizeParticipant p) { if ((p instanceof ModelSynchronizeParticipant)) { ModelSynchronizeParticipant msp = (ModelSynchronizeParticipant)p; Saveable s = msp.getActiveSaveable(); if ((s != null) && (s.isDirty())) { return true; } } return false; } public synchronized void removeSynchronizeParticipants(ISynchronizeParticipant[] participants) { List removed = new ArrayList(participants.length); for (int i = 0; i < participants.length; i++) { ISynchronizeParticipant participant = participants[i]; String key = Utils.getKey(participant.getId(), participant.getSecondaryId()); if (participantReferences.containsKey(key)) { ParticipantInstance ref = (ParticipantInstance)participantReferences.remove(key); if (ref.isInstantiated()) { ref.dispose(); } removed.add Further reading...For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.New!JAR listings
|