![]() |
![]() |
org.eclipse.team.ui_3.6.101.R37x_v20111109-0800e.SynchronizePageConfiguration * Java Class Version: 1.2 (46.0) * JD-Core Version: 0.7.1 */ package org.eclipse.team.internal.ui.synchronize; import org.eclipse.ui.IEditorReference; import org.eclipse.ui.IPartListener2; import org.eclipse.ui.IWorkbenchPartReference; class SynchronizeView$1 implements IPartListener2 { final SynchronizeView this$0; SynchronizeView$1(SynchronizeView paramSynchronizeView) { this$0 = paramSynchronizeView; } public void partVisible(IWorkbenchPartReference partRef) {} public void partBroughtToTop(IWorkbenchPartReference partRef) {} public void partClosed(IWorkbenchPartReference partRef) {} public void partDeactivated(IWorkbenchPartReference partRef) {} public void partHidden(IWorkbenchPartReference partRef) {} public void partOpened(IWorkbenchPartReference partRef) {} public void partInputChanged(IWorkbenchPartReference partRef) { if ((partRef instanceof IEditorReference)) { SynchronizeView.access$0(this$0, ((IEditorReference)partRef).getEditor(true)); } } public void partActivated(IWorkbenchPartReference partRef) { if ((partRef instanceof IEditorReference)) { SynchronizeView.access$0(this$0, ((IEditorReference)partRef).getEditor(true)); } } } /* Location: * Qualified Name: org.eclipse.team.internal.ui.synchronize.SynchronizeView.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.resources.IResource; import org.eclipse.jface.viewers.IElementComparer; import org.eclipse.team.core.synchronize.SyncInfo; import org.eclipse.team.core.variants.IResourceVariant; import org.eclipse.team.internal.ui.Utils; class SynchronizeView$2 implements IElementComparer { private Object getContributedResourceOrResourceVariant(Object o) { IResource[] resources = Utils.getContributedResources(new Object[] { o }); if (resources.length > 0) { return resources[0]; } if ((o instanceof SyncInfoModelElement)) { SyncInfoModelElement sime = (SyncInfoModelElement)o; return sime.getSyncInfo().getRemote(); } return null; } public int hashCode(Object element) { Object r = getContributedResourceOrResourceVariant(element); if (r != null) { return r.hashCode(); } return element.hashCode(); } public boolean equals(Object a, Object b) { if (((a instanceof IResource)) || ((a instanceof IResourceVariant))) { b = getContributedResourceOrResourceVariant(b); } else if (((b instanceof IResource)) || ((b instanceof IResourceVariant))) { a = getContributedResourceOrResourceVariant(a); return b.equals(a); } return a.equals(b); } } /* Location: * Qualified Name: org.eclipse.team.internal.ui.synchronize.SynchronizeView.2 * Java Class Version: 1.2 (46.0) * JD-Core Version: 0.7.1 */ package org.eclipse.team.internal.ui.synchronize; class SynchronizeView$3 implements Runnable { final SynchronizeView this$0; SynchronizeView$3(SynchronizeView paramSynchronizeView) { this$0 = paramSynchronizeView; } public void run() { SynchronizeView.access$1(this$0, 257); } } /* Location: * Qualified Name: org.eclipse.team.internal.ui.synchronize.SynchronizeView.3 * Java Class Version: 1.2 (46.0) * JD-Core Version: 0.7.1 */ package org.eclipse.team.internal.ui.synchronize; import org.eclipse.ui.progress.IWorkbenchSiteProgressService; class SynchronizeView$4 implements Runnable { final SynchronizeView this$0; private final IWorkbenchSiteProgressService val$ps; SynchronizeView$4(SynchronizeView paramSynchronizeView, IWorkbenchSiteProgressService paramIWorkbenchSiteProgressService) { this$0 = paramSynchronizeView;val$ps = paramIWorkbenchSiteProgressService; } public void run() { val$ps.warnOfContentChange(); } } /* Location: * Qualified Name: org.eclipse.team.internal.ui.synchronize.SynchronizeView.4 * Java Class Version: 1.2 (46.0) * JD-Core Version: 0.7.1 */ package org.eclipse.team.internal.ui.synchronize; class SynchronizeView$5 implements Runnable { final SynchronizeView this$0; SynchronizeView$5(SynchronizeView paramSynchronizeView) { this$0 = paramSynchronizeView; } public void run() { SynchronizeView.access$1(this$0, 257); } } /* Location: * Qualified Name: org.eclipse.team.internal.ui.synchronize.SynchronizeView.5 * Java Class Version: 1.2 (46.0) * JD-Core Version: 0.7.1 */ package org.eclipse.team.internal.ui.synchronize; import java.util.Map; import org.eclipse.team.core.TeamException; import org.eclipse.team.ui.TeamUI; import org.eclipse.team.ui.synchronize.ISynchronizeManager; import org.eclipse.team.ui.synchronize.ISynchronizeParticipant; import org.eclipse.team.ui.synchronize.ISynchronizeParticipantReference; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchPartSite; class SynchronizeView$6 implements Runnable { final SynchronizeView this$0; private final ISynchronizeParticipant[] val$participants; SynchronizeView$6(SynchronizeView paramSynchronizeView, ISynchronizeParticipant[] paramArrayOfISynchronizeParticipant) { this$0 = paramSynchronizeView;val$participants = paramArrayOfISynchronizeParticipant; } public void run() { for (int i = 0; i < val$participants.length; i++) { ISynchronizeParticipant participant = val$participants[i]; if (SynchronizeView.access$2(this$0)) { SynchronizeViewWorkbenchPart part = (SynchronizeViewWorkbenchPart)SynchronizeView.access$3(this$0).get(participant); if (part != null) { this$0.partClosed(part); SynchronizeView.access$4(this$0, part, participant); } SynchronizeView.access$5(this$0, participant); if (this$0.getParticipant() == null) { ISynchronizeParticipantReference[] available = TeamUI.getSynchronizeManager().getSynchronizeParticipants(); if (available.length > 0) { try { p = available[(available.length - 1)].getParticipant(); } catch (TeamException localTeamException) { ISynchronizeParticipant p; return; } ISynchronizeParticipant p; this$0.display(p); } else { this$0.getSite().getPage().removePartListener(SynchronizeView.access$6(this$0)); } } } } SynchronizeView.access$1(this$0, 257); } } /* Location: * Qualified Name: org.eclipse.team.internal.ui.synchronize.SynchronizeView.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.resources.IFile; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.StructuredViewer; import org.eclipse.ui.OpenAndLinkWithEditorHelper; import org.eclipse.ui.PartInitException; class SynchronizeView$7 extends OpenAndLinkWithEditorHelper { final SynchronizeView this$0; SynchronizeView$7(SynchronizeView paramSynchronizeView, StructuredViewer $anonymous0) { super($anonymous0);this$0 = paramSynchronizeView; } protected void activate(ISelection selection) { try { Object selectedElement = SynchronizeView.access$7(selection); if ((SynchronizeView.access$8(selectedElement) != null) && ((selectedElement instanceof IFile))) { SynchronizeView.access$9((IFile)selectedElement, true); } } catch (PartInitException localPartInitException) {} } protected void linkToEditor(ISelection selection) { SynchronizeView.access$10(this$0, selection); } protected void open(ISelection selection, boolean activate) {} } /* Location: * Qualified Name: org.eclipse.team.internal.ui.synchronize.SynchronizeView.7 * Java Class Version: 1.2 (46.0) * JD-Core Version: 0.7.1 */ package org.eclipse.team.internal.ui.synchronize; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.ResourceBundle; import java.util.Set; import org.eclipse.compare.CompareEditorInput; import org.eclipse.compare.ITypedElement; import org.eclipse.compare.ResourceNode; import org.eclipse.compare.structuremergeviewer.ICompareInput; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.jface.action.IAction; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.IStatusLineManager; import org.eclipse.jface.action.IToolBarManager; import org.eclipse.jface.commands.ActionHandler; import org.eclipse.jface.dialogs.DialogSettings; import org.eclipse.jface.dialogs.ErrorDialog; import org.eclipse.jface.dialogs.IDialogSettings; import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.jface.viewers.IElementComparer; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.StructuredViewer; import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.osgi.util.NLS; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Tree; import org.eclipse.team.core.TeamException; import org.eclipse.team.core.history.IFileRevision; import org.eclipse.team.core.synchronize.SyncInfo; import org.eclipse.team.core.variants.IResourceVariant; import org.eclipse.team.internal.core.mapping.ResourceVariantFileRevision; import org.eclipse.team.internal.ui.Policy; 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.history.FileRevisionEditorInput; import org.eclipse.team.internal.ui.synchronize.actions.PasteAction; import org.eclipse.team.internal.ui.synchronize.actions.PinParticipantAction; import org.eclipse.team.internal.ui.synchronize.actions.RemoveSynchronizeParticipantAction; import org.eclipse.team.internal.ui.synchronize.actions.SynchronizeAndRefreshAction; import org.eclipse.team.internal.ui.synchronize.actions.SynchronizePageDropDownAction; import org.eclipse.team.internal.ui.synchronize.actions.ToggleLinkingAction; import org.eclipse.team.ui.TeamUI; import org.eclipse.team.ui.synchronize.ISynchronizeManager; import org.eclipse.team.ui.synchronize.ISynchronizePage; import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; import org.eclipse.team.ui.synchronize.ISynchronizeParticipant; 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.IActionBars; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IEditorReference; import org.eclipse.ui.IPartListener2; import org.eclipse.ui.ISaveablePart; import org.eclipse.ui.ISaveablesLifecycleListener; import org.eclipse.ui.ISaveablesSource; import org.eclipse.ui.IStorageEditorInput; import org.eclipse.ui.IViewSite; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.IWorkbenchPartReference; import org.eclipse.ui.IWorkbenchPartSite; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.OpenAndLinkWithEditorHelper; import org.eclipse.ui.PartInitException; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.Saveable; import org.eclipse.ui.SaveablesLifecycleEvent; import org.eclipse.ui.actions.ActionFactory; import org.eclipse.ui.handlers.IHandlerService; import org.eclipse.ui.help.IWorkbenchHelpSystem; import org.eclipse.ui.ide.IDE; import org.eclipse.ui.part.EditorPart; import org.eclipse.ui.part.FileEditorInput; import org.eclipse.ui.part.IPage; import org.eclipse.ui.part.IPageBookViewPage; import org.eclipse.ui.part.IPageSite; import org.eclipse.ui.part.IShowInTarget; import org.eclipse.ui.part.MessagePage; import org.eclipse.ui.part.Page; import org.eclipse.ui.part.PageBook; import org.eclipse.ui.part.PageBookView; import org.eclipse.ui.part.PageBookView.PageRec; import org.eclipse.ui.part.ShowInContext; import org.eclipse.ui.progress.IWorkbenchSiteProgressService; public class SynchronizeView extends PageBookView implements ISynchronizeView, ISynchronizeParticipantListener, IPropertyChangeListener, ISaveablesSource, ISaveablePart, IShowInTarget { public static final int MAX_NAME_LENGTH = 100; private ISynchronizeParticipant activeParticipantRef = null; private Map fParticipantToPart; private Map fPartToParticipant; private SynchronizePageDropDownAction fPageDropDown; private PinParticipantAction fPinAction; private RemoveSynchronizeParticipantAction fRemoveCurrentAction; private RemoveSynchronizeParticipantAction fRemoveAllAction; private ToggleLinkingAction fToggleLinkingAction; private SynchronizeAndRefreshAction fRefreshAction; private PasteAction fPastePatchAction; private boolean fLinkingEnabled; private OpenAndLinkWithEditorHelper fOpenAndLinkWithEditorHelper; private static final String KEY_LAST_ACTIVE_PARTICIPANT_ID = "lastactiveparticipant_id"; private static final String KEY_LAST_ACTIVE_PARTICIPANT_SECONDARY_ID = "lastactiveparticipant_sec_id"; private static final String KEY_LINK_WITH_EDITOR = "linkWithEditor"; private static final String KEY_SETTINGS_SECTION = "SynchronizeViewSettings"; public void propertyChange(PropertyChangeEvent event) { Object source = event.getSource(); if ((source instanceof ISynchronizeParticipant)) { if (event.getProperty().equals("org.eclipse.jface.text")) { if (source.equals(getParticipant())) { updateTitle(); } } else if (event.getProperty().equals("org.eclipse.team.ui.DIRTY")) { Display.getDefault().asyncExec(new Runnable() { public void run() { firePropertyChange(257); } }); } else if (event.getProperty().equals("org.eclipse.team.ui.ACTIVE_SAVEABLE")) { Saveable oldSaveable = (Saveable)event.getOldValue(); Saveable newSaveable = (Saveable)event.getNewValue(); ISaveablesLifecycleListener listener = (ISaveablesLifecycleListener)getSite().getPage().getWorkbenchWindow() .getService(ISaveablesLifecycleListener.class); if ((listener != null) && (oldSaveable != null)) { listener.handleLifecycleEvent(new SaveablesLifecycleEvent(this, 3, new Saveable[] { oldSaveable }, false)); } if ((listener != null) && (newSaveable != null)) { listener.handleLifecycleEvent(new SaveablesLifecycleEvent(this, 1, new Saveable[] { newSaveable }, false)); } } else if (event.getProperty().equals("org.eclipse.team.ui.content")) { IWorkbenchSiteProgressService ps = (IWorkbenchSiteProgressService)getSite().getAdapter(IWorkbenchSiteProgressService.class); if (ps != null) { Display.getDefault().asyncExec(new Runnable() { private final IWorkbenchSiteProgressService val$ps; public void run() { val$ps.warnOfContentChange(); } }); } } } if ((source instanceof ISynchronizePageConfiguration)) { ISynchronizePageConfiguration configuration = (ISynchronizePageConfiguration)source; if (event.getProperty().equals("org.eclipse.team.ui.P_PAGE_DESCRIPTION")) { if (configuration.getParticipant().equals(getParticipant())) { updateTitle(); } } else if ((event.getProperty().equals("org.eclipse.team.ui.P_SYNCVIEWPAGE_MODE")) && (configuration.getParticipant().equals(getParticipant()))) { updateTitle(); } } } public void partClosed(IWorkbenchPart part) { super.partClosed(part); } public ISynchronizeParticipant getParticipant() { return activeParticipantRef; } protected void showPageRec(PageBookView.PageRec pageRec) { super.showPageRec(pageRec); activeParticipantRef = ((ISynchronizeParticipant)fPartToParticipant.get(part)); updateActionEnablements(); updateTitle(); } protected void updateTitle() { ISynchronizeParticipant participant = getParticipant(); if (participant == null) { setContentDescription(""); } else { SynchronizeViewWorkbenchPart part = (SynchronizeViewWorkbenchPart)fParticipantToPart.get(participant); ISynchronizePageConfiguration configuration = part.getConfiguration(); String description = (String)configuration.getProperty("org.eclipse.team.ui.P_PAGE_DESCRIPTION"); if (description == null) { description = part.getParticipant().getName(); } setContentDescription(Utils.shortenText(100, description)); setStatusLineMessage(description, configuration.getMode()); } } protected void doDestroyPage(IWorkbenchPart part, PageBookView.PageRec pageRecord) { IPage page = page; page.dispose(); pageRecord.dispose(); SynchronizeViewWorkbenchPart syncPart = (SynchronizeViewWorkbenchPart)part; ISynchronizeParticipant participant = syncPart.getParticipant(); clearCrossReferenceCache(part, participant); } private void clearCrossReferenceCache(IWorkbenchPart part, ISynchronizeParticipant participant) { participant.removePropertyChangeListener(this); if (part == null) { return; } ISynchronizePageConfiguration configuration = ((SynchronizeViewWorkbenchPart)part).getConfiguration(); if (configuration != null) { configuration.removePropertyChangeListener(this); } fPartToParticipant.remove(part); fParticipantToPart.remove(participant); } protected PageBookView.PageRec doCreatePage(IWorkbenchPart dummyPart) { SynchronizeViewWorkbenchPart part = (SynchronizeViewWorkbenchPart)dummyPart; ISynchronizeParticipant participant = part.getParticipant(); participant.addPropertyChangeListener(this); ISynchronizePageConfiguration configuration = participant.createPageConfiguration(); part.setConfiguration(configuration); configuration.addPropertyChangeListener(this); IPageBookViewPage page = participant.createPage(configuration); if (page != null) { initPage(page); initPage(configuration, page); page.createControl(getPageBook()); PageBookView.PageRec rec = new PageBookView.PageRec(dummyPart, page); return rec; } return null; } protected void initPage(ISynchronizePageConfiguration configuration, IPageBookViewPage page) { ((SynchronizePageConfiguration)configuration).setSite(new WorkbenchPartSynchronizePageSite(this, page.getSite(), getDialogSettings(configuration.getParticipant()))); if ((page instanceof ISynchronizePage)) { try { ((ISynchronizePage)page).init(configuration.getSite()); } catch (PartInitException e) { TeamUIPlugin.log(4, e.getMessage(), e); } } page.getSite().getActionBars().setGlobalActionHandler(ActionFactory.REFRESH.getId(), fRefreshAction); page.getSite().getActionBars().updateActionBars(); } protected boolean isImportant(IWorkbenchPart part) { return part instanceof SynchronizeViewWorkbenchPart; } public void dispose() { super.dispose(); TeamUI.getSynchronizeManager().removeSynchronizeParticipantListener(this); fPinAction.dispose(); fPastePatchAction.dispose(); if (activeParticipantRef != null) { rememberCurrentParticipant(); } fParticipantToPart = null; fPartToParticipant = null; getSite().getPage().removePartListener(fLinkWithEditorListener); } private void rememberCurrentParticipant() { IDialogSettings section = getDialogSettings(); section.put("lastactiveparticipant_id", activeParticipantRef.getId()); section.put("lastactiveparticipant_sec_id", activeParticipantRef.getSecondaryId()); } protected IPage createDefaultPage(PageBook book) { Page page = new MessagePage(); page.createControl(getPageBook()); initPage(page); return page; } public void participantsAdded(ISynchronizeParticipant[] participants) { for (int i = 0; i < participants.length; i++) { ISynchronizeParticipant participant = participants[i]; if ((isAvailable()) && (select(TeamUI.getSynchronizeManager().get(participant.getId(), participant.getSecondaryId())))) { SynchronizeViewWorkbenchPart part = new SynchronizeViewWorkbenchPart(participant, getSite()); fParticipantToPart.put(participant, part); fPartToParticipant.put(part, participant); } } Display.getDefault().asyncExec(new Runnable() { public void run() { firePropertyChange(257); } }); } public void participantsRemoved(ISynchronizeParticipant[] participants) { if (isAvailable()) { Runnable r = new Runnable() { private final ISynchronizeParticipant[] val$participants; public void run() { for (int i = 0; i < val$participants.length; i++) { ISynchronizeParticipant participant = val$participants[i]; if (SynchronizeView.this.isAvailable()) { SynchronizeViewWorkbenchPart part = (SynchronizeViewWorkbenchPart)fParticipantToPart.get(participant); if (part != null) { partClosed(part); SynchronizeView.this.clearCrossReferenceCache(part, participant); } SynchronizeView.this.removeDialogSettings(participant); if (getParticipant() == null) { ISynchronizeParticipantReference[] available = TeamUI.getSynchronizeManager().getSynchronizeParticipants(); if (available.length > 0) { try { p = available[(available.length - 1)].getParticipant(); } catch (TeamException localTeamException) { ISynchronizeParticipant p; return; } ISynchronizeParticipant p; display(p); } else { getSite().getPage().removePartListener(fLinkWithEditorListener); } } } } firePropertyChange(257); } }; asyncExec(r); } } public SynchronizeView() { fParticipantToPart = new HashMap(); fPartToParticipant = new HashMap(); updateTitle(); } protected void createActions() { fPageDropDown = new SynchronizePageDropDownAction(this); fRefreshAction = new SynchronizeAndRefreshAction(this); fPinAction = new PinParticipantAction(); fToggleLinkingAction = new ToggleLinkingAction(this); fRemoveCurrentAction = new RemoveSynchronizeParticipantAction(this, false); fRemoveAllAction = new RemoveSynchronizeParticipantAction(this, true); fPastePatchAction = new PasteAction(this); updateActionEnablements(); } private void updateActionEnablements() { if (fPinAction != null) { fPinAction.setParticipant(activeParticipantRef); } if (fToggleLinkingAction != null) { fToggleLinkingAction.setEnabled(getParticipant() != null); } if (fRemoveAllAction != null) { fRemoveAllAction.setEnabled(getParticipant() != null); } if (fRemoveCurrentAction != null) { fRemoveCurrentAction.setEnabled(getParticipant() != null); } if (fPastePatchAction != null) { fPastePatchAction.setEnabled(true); } } protected void configureToolBar(IActionBars bars) { IToolBarManager mgr = bars.getToolBarManager(); mgr.add(fPageDropDown); mgr.add(fPinAction); IMenuManager menu = bars.getMenuManager(); menu.add(fPinAction); menu.add(fToggleLinkingAction); menu.add(fRemoveCurrentAction); menu.add(fRemoveAllAction); IHandlerService handlerService = (IHandlerService)getViewSite().getService(IHandlerService.class); handlerService.activateHandler("org.eclipse.ui.navigate.linkWithEditor", new ActionHandler(fToggleLinkingAction)); handlerService.activateHandler(ActionFactory.PASTE.getCommandId(), new ActionHandler(fPastePatchAction)); } public void display(ISynchronizeParticipant participant) { SynchronizeViewWorkbenchPart part = (SynchronizeViewWorkbenchPart)fParticipantToPart.get(participant); if (part != null) { partActivated(part); fPageDropDown.update(); createOpenAndLinkWithEditorHelper(getViewer()); rememberCurrentParticipant(); PlatformUI.getWorkbench().getHelpSystem().setHelp(getPageBook().getParent(), participant.getHelpContextId()); } } private void createOpenAndLinkWithEditorHelper(StructuredViewer viewer) { if (fOpenAndLinkWithEditorHelper != null) { fOpenAndLinkWithEditorHelper.dispose(); } fOpenAndLinkWithEditorHelper = new OpenAndLinkWithEditorHelper(viewer) { protected void activate(ISelection selection) { try { Object selectedElement = SynchronizeView.getSingleElement(selection); if ((SynchronizeView.isOpenInEditor(selectedElement) != null) && ((selectedElement instanceof IFile))) { SynchronizeView.openInEditor((IFile)selectedElement, true); } } catch (PartInitException localPartInitException) {} } protected void linkToEditor(ISelection selection) { SynchronizeView.this.linkToEditor(selection); } protected void open(ISelection selection, boolean activate) {} }; fOpenAndLinkWithEditorHelper.setLinkWithEditor(isLinkingEnabled()); setLinkingEnabled(isLinkingEnabled()); } protected IWorkbenchPart getBootstrapPart() { return null; } public void asyncExec(Runnable runnable) { if (isAvailable()) { getPageBook().getDisplay().asyncExec(runnable); } } public void createPartControl(Composite parent) { super.createPartControl(parent); restoreLinkingEnabled(); createActions(); configureToolBar(getViewSite().getActionBars()); updateForExistingParticipants(); getViewSite().getActionBars().updateActionBars(); updateTitle(); IWorkbenchSiteProgressService progress = (IWorkbenchSiteProgressService)getSite().getAdapter(IWorkbenchSiteProgressService.class); if (progress != null) { progress.showBusyForFamily(ISynchronizeManager.FAMILY_SYNCHRONIZE_OPERATION); } PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, "org.eclipse.team.ui.sync_view_context"); } private void updateForExistingParticipants() { ISynchronizeManager manager = TeamUI.getSynchronizeManager(); List participants = Arrays.asList(getParticipants()); boolean errorOccurred = false; for (int i = 0; i < participants.size(); i++) { try { ISynchronizeParticipantReference ref = (ISynchronizeParticipantReference)participants.get(i); participantsAdded(new ISynchronizeParticipant[] { ref.getParticipant() }); } catch (TeamException localTeamException1) { errorOccurred = true; } } if (errorOccurred) { participants = Arrays.asList(getParticipants()); } try { if (participants.size() > 0) { ISynchronizeParticipantReference participantToSelect = (ISynchronizeParticipantReference)participants.get(0); IDialogSettings section = getDialogSettings(); String selectedParticipantId = section.get("lastactiveparticipant_id"); String selectedParticipantSecId = section.get("lastactiveparticipant_sec_id"); if (selectedParticipantId != null) { ISynchronizeParticipantReference selectedParticipant = manager.get(selectedParticipantId, selectedParticipantSecId); if (selectedParticipant != null) { participantToSelect = selectedParticipant; } } display(participantToSelect.getParticipant()); } manager.addSynchronizeParticipantListener(this); } catch (TeamException e) { Utils.handle(e); } } private ISynchronizeParticipantReference[] getParticipants() { ISynchronizeManager manager = TeamUI.getSynchronizeManager(); List participants = new ArrayList(); ISynchronizeParticipantReference[] refs = manager.getSynchronizeParticipants(); for (int i = 0; i < refs.length; i++) { ISynchronizeParticipantReference ref = refs[i]; if (select(ref)) { participants.add(ref); } } return (ISynchronizeParticipantReference[])participants.toArray(new ISynchronizeParticipantReference[participants.size()]); } private boolean isAvailable() { return (getPageBook() != null) && (!getPageBook().isDisposed()); } public IPage getPage(ISynchronizeParticipant participant) { IWorkbenchPart part = (IWorkbenchPart)fParticipantToPart.get(participant); if (part == null) { return null; } try { return getPageRecpage; } catch (NullPointerException localNullPointerException) {} return null; } protected boolean select(ISynchronizeParticipantReference ref) { return true; } private IDialogSettings getDialogSettings() { IDialogSettings workbenchSettings = TeamUIPlugin.getPlugin().getDialogSettings(); IDialogSettings syncViewSettings = workbenchSettings.getSection("SynchronizeViewSettings"); if (syncViewSettings == null) { syncViewSettings = workbenchSettings.addNewSection("SynchronizeViewSettings"); } return syncViewSettings; } private String getSettingsKey(ISynchronizeParticipant participant) { String id = participant.getId(); String secondaryId = participant.getSecondaryId(); return id + '.' + secondaryId; } private IDialogSettings getDialogSettings(ISynchronizeParticipant participant) { String key = getSettingsKey(participant); IDialogSettings viewsSettings = getDialogSettings(); IDialogSettings settings = viewsSettings.getSection(key); if (settings == null) { settings = viewsSettings.addNewSection(key); } return settings; } private void removeDialogSettings(ISynchronizeParticipant participant) { String key = getSettingsKey(participant); IDialogSettings settings = getDialogSettings(); if (settings.getSection(key) != null) { getDialogSettings().addSection(new DialogSettings(key)); } } public Saveable[] getSaveables() { Set result = new HashSet(); for (Iterator iter = fPartToParticipant.keySet().iterator(); iter.hasNext();) { SynchronizeViewWorkbenchPart part = (SynchronizeViewWorkbenchPart)iter.next(); Saveable saveable = getSaveable(part.getParticipant()); if (saveable != null) { result.add(saveable); } } return (Saveable[])result.toArray(new Saveable[result.size()]); } private Saveable getSaveable(ISynchronizeParticipant participant) { if ((participant instanceof ModelSynchronizeParticipant)) { ModelSynchronizeParticipant msp = (ModelSynchronizeParticipant)participant; return msp.getActiveSaveable(); } return null; } public Saveable[] getActiveSaveables() { ISynchronizeParticipant participant = getParticipant(); Saveable s = getSaveable(participant); if (s != null) { return new Saveable[] { s }; } return new Saveable[0]; } public void doSave(IProgressMonitor monitor) { Saveable[] saveables = getSaveables(); if (saveables.length == 0) { return; } monitor.beginTask(null, 100 * saveables.length); for (int i = 0; i < saveables.length; i++) { Saveable saveable = saveables[i]; try { saveable.doSave(Policy.subMonitorFor(monitor, 100)); } catch (CoreException e) { ErrorDialog.openError(getSite().getShell(), null, e.getMessage(), e.getStatus()); } Policy.checkCanceled(monitor); } monitor.done(); firePropertyChange(257); } public void doSaveAs() {} public boolean isDirty() { Saveable[] saveables = getSaveables(); for (int i = 0; i < saveables.length; i++) { Saveable saveable = saveables[i]; if (saveable.isDirty()) { return true; } } return false; } public boolean isSaveAsAllowed() { return false; } public boolean isSaveOnCloseNeeded() { return true; } private void setStatusLineMessage(String description, int mode) { String syncMode = null; ResourceBundle bundle = Policy.getActionBundle(); switch (mode) { case 1: syncMode = Utils.getString("action.directionFilterIncoming.tooltip", bundle); break; case 2: syncMode = Utils.getString("action.directionFilterOutgoing.tooltip", bundle); break; case 4: syncMode = Utils.getString("action.directionFilterBoth.tooltip", bundle); break; case 8: syncMode = Utils.getString("action.directionFilterConflicts.tooltip", bundle); } IViewSite viewSite = getViewSite(); if ((viewSite != null) && (syncMode != null)) { viewSite.getActionBars().getStatusLineManager().setMessage( NLS.bind(TeamUIMessages.SynchronizeView_statusLine, new String[] { description, syncMode })); } } private IPartListener2 fLinkWithEditorListener = new IPartListener2() { public void partVisible(IWorkbenchPartReference partRef) {} public void partBroughtToTop(IWorkbenchPartReference partRef) {} public void partClosed(IWorkbenchPartReference partRef) {} public void partDeactivated(IWorkbenchPartReference partRef) {} public void partHidden(IWorkbenchPartReference partRef) {} public void partOpened(IWorkbenchPartReference partRef) {} public void partInputChanged(IWorkbenchPartReference partRef) { if ((partRef instanceof IEditorReference)) { SynchronizeView.this.editorActivated(((IEditorReference)partRef).getEditor(true)); } } public void partActivated(IWorkbenchPartReference partRef) { if ((partRef instanceof IEditorReference)) { SynchronizeView.this.editorActivated(((IEditorReference)partRef).getEditor(true)); } } }; public boolean isLinkingEnabled() { return fLinkingEnabled; } private static IElementComparer COMPARER = new IElementComparer() { private Object getContributedResourceOrResourceVariant(Object o) { IResource[] resources = Utils.getContributedResources(new Object[] { o }); if (resources.length > 0) { return resources[0]; } if ((o instanceof SyncInfoModelElement)) { SyncInfoModelElement sime = (SyncInfoModelElement)o; return sime.getSyncInfo().getRemote(); } return null; } public int hashCode(Object element) { Object r = getContributedResourceOrResourceVariant(element); if (r != null) { return r.hashCode(); } return element.hashCode(); } public boolean equals(Object a, Object b) { if (((a instanceof IResource)) || ((a instanceof IResourceVariant))) { b = getContributedResourceOrResourceVariant(b); } else if (((b instanceof IResource)) || ((b instanceof IResourceVariant))) { a = getContributedResourceOrResourceVariant(a); return b.equals(a); } return a.equals(b); } }; public void setLinkingEnabled(boolean enabled) { fLinkingEnabled = enabled; IDialogSettings dialogSettings = getDialogSettings(); dialogSettings.put("linkWithEditor", fLinkingEnabled); IWorkbenchPage page = getSite().getPage(); if (enabled) { page.addPartListener(fLinkWithEditorListener); IEditorPart editor = page.getActiveEditor(); if (editor != null) { editorActivated(editor); } } else { page.removePartListener(fLinkWithEditorListener); } fOpenAndLinkWithEditorHelper.setLinkWithEditor(enabled); } private void restoreLinkingEnabled() { fLinkingEnabled = getDialogSettings().getBoolean("linkWithEditor"); } private void linkToEditor(ISelection selection) { Object obj = getSingleElement(selection); if (obj != null) { IEditorPart part = isOpenInEditor(obj); if (part != null) { IWorkbenchPage page = getSite().getPage(); page.bringToTop(part); } } } private void editorActivated(IEditorPart editor) { if (!isLinkingEnabled()) { return; } IEditorInput editorInput = editor.getEditorInput(); if (editorInput == null) { return; } Object input = getInputFromEditor(editorInput); if (input == null) { return; } if (!inputIsSelected(editorInput)) { showInput(input); } else { getViewer().getTree().showSelection(); } } boolean showInput(Object input) { Object element = input; if (element != null) { IElementComparer previousComparer = getViewer().getComparer(); getViewer().setComparer(COMPARER); try { ISelection newSelection = new StructuredSelection(element); if (getViewer().getSelection().equals(newSelection)) { getViewer().reveal(element); } else { getViewer().setSelection(newSelection, true); while ((element != null) && (getViewer().getSelection().isEmpty())) { element = getParent(element); if (element != null) { newSelection = new StructuredSelection(element); getViewer().setSelection(newSelection, true); } else { return false; } } } return true; } finally { getViewer().setComparer(previousComparer); } } return false; } private Object getParent(Object element) { if ((element instanceof IResource)) { return ((IResource)element).getParent(); } return null; } private TreeViewer getViewer() { IPage currentPage = getCurrentPage(); if ((currentPage instanceof ISynchronizePage)) { return (TreeViewer)((ISynchronizePage)currentPage).getViewer(); } Assert.isTrue(false); return null; } private boolean inputIsSelected(IEditorInput input) { IStructuredSelection selection = (IStructuredSelection)getViewer().getSelection(); if (selection.size() != 1) { return false; } IEditorInput selectionAsInput = getEditorInput(selection.getF 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
|