### Eclipse Workspace Patch 1.0 #P org.eclipse.team.ui Index: src/org/eclipse/team/internal/ui/synchronize/SynchronizeView.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeView.java,v retrieving revision 1.56 diff -u -r1.56 SynchronizeView.java --- src/org/eclipse/team/internal/ui/synchronize/SynchronizeView.java 23 Feb 2010 15:28:13 -0000 1.56 +++ src/org/eclipse/team/internal/ui/synchronize/SynchronizeView.java 4 Mar 2010 13:17:55 -0000 @@ -926,17 +926,41 @@ IStructuredSelection selection= (IStructuredSelection) getViewer().getSelection(); if (selection.size() != 1) return false; - IEditorInput selectionAsInput= getEditorInput(selection.getFirstElement()); - return input.equals(selectionAsInput); + IEditorInput[] selectionAsInput= getEditorInput(selection.getFirstElement()); + for (int i = 0; i < selectionAsInput.length; i++) { + if (input.equals(selectionAsInput[i])) + return true; + } + return false; } - private static IEditorInput getEditorInput(Object input) { + private static IEditorInput[] getEditorInput(Object input) { + Set/**/ result = new HashSet(1); + boolean checkSynchronizeModelElement = false; IResource[] resources = Utils.getContributedResources(new Object[] { input }); - if (resources.length > 0) - input = resources[0]; - if (input instanceof IFile) - return new FileEditorInput((IFile) input); - return null; + for (int i = 0; i < resources.length; i++) { + if (!resources[i].exists()) + checkSynchronizeModelElement = true; + if (resources[i] instanceof IFile) + result.add(new FileEditorInput((IFile) resources[i])); + } + if (checkSynchronizeModelElement) { + if (input instanceof ISynchronizeModelElement){ + ITypedElement right = ((ISynchronizeModelElement)input).getRight(); + if (right instanceof RemoteResourceTypedElement) { + RemoteResourceTypedElement rrte = (RemoteResourceTypedElement) right; + try { + rrte.cacheContents(new NullProgressMonitor()); + IEditorInput remoteEditorInput = rrte.getDocumentKey(rrte); + if (remoteEditorInput != null) + result.add(remoteEditorInput); + } catch (CoreException e) { + // ignore + } + } + } + } + return (IEditorInput[]) result.toArray(new IEditorInput[0]); } private Object getInputFromEditor(IEditorInput editorInput) { @@ -959,19 +983,22 @@ // copy-pasted from org.eclipse.jdt.internal.ui.javaeditor.EditorUtility and modified private static IEditorPart isOpenInEditor(Object inputElement) { - IEditorInput input = getEditorInput(inputElement); - if (input != null) { + IEditorInput[] input = getEditorInput(inputElement); + if (input != null && input.length > 0) { IWorkbenchPage p = TeamUIPlugin.getActivePage(); if (p != null) { - IEditorPart editor = p.findEditor(input); - if (editor == null) { - IEditorReference[] er = p.getEditorReferences(); - for (int i = 0; i < er.length; i++) - if (er[i].getId().equals( - "org.eclipse.compare.CompareEditor") && matches(er[i], input)) //$NON-NLS-1$ - editor = er[i].getEditor(false); + for (int i = 0; i < input.length; i++) { + IEditorPart editor = p.findEditor(input[i]); + if (editor == null) { + IEditorReference[] er = p.getEditorReferences(); + for (int j = 0; j < er.length; j++) + if (er[j].getId().equals( + "org.eclipse.compare.CompareEditor") && matches(er[j], input[i])) //$NON-NLS-1$ + editor = er[j].getEditor(false); + } + if (editor != null) + return editor; } - return editor; } } return null;