Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 71868 Details for
Bug 193324
[Sync View] Provide compare editor input for a single file that support editing on both sides
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Patch at initial stage
patch_193324_20070620.txt (text/plain), 12.11 KB, created by
Tomasz Zarna
on 2007-06-20 08:11:14 EDT
(
hide
)
Description:
Patch at initial stage
Filename:
MIME Type:
Creator:
Tomasz Zarna
Created:
2007-06-20 08:11:14 EDT
Size:
12.11 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.team.ui >Index: plugin.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.team.ui/plugin.properties,v >retrieving revision 1.71 >diff -u -r1.71 plugin.properties >--- plugin.properties 16 Mar 2007 21:03:35 -0000 1.71 >+++ plugin.properties 20 Jun 2007 11:27:55 -0000 >@@ -79,3 +79,5 @@ > CompareLocalHistory.tooltip= Compare the Selected Resource with Local History > ReplaceLocalHistory.label= &Local History... > ReplaceLocalHistory.tooltip= Replace the Selected Resource with Local History >+CompareWithEachOtherAction.label= &Each Other >+CompareWithEachOtherAction.tooltip= Compare the Selected Resources >\ No newline at end of file >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.team.ui/plugin.xml,v >retrieving revision 1.186 >diff -u -r1.186 plugin.xml >--- plugin.xml 19 Apr 2007 14:26:05 -0000 1.186 >+++ plugin.xml 20 Jun 2007 11:27:56 -0000 >@@ -154,6 +154,15 @@ > enablesFor="1" > overrideActionId="replaceFromHistory" > tooltip="%ReplaceLocalHistory.tooltip"/> >+ <action >+ class="org.eclipse.team.internal.ui.actions.CompareAction" >+ enablesFor="2+" >+ id="org.eclipse.team.ui.compareWithEachOther" >+ label="%CompareWithEachOtherAction.label" >+ menubarPath="compareWithMenu/compareWithGroup" >+ overrideActionId="compareWithEachOther" >+ tooltip="CompareWithEachOtherAction.tooltip"> >+ </action> > </objectContribution> > </extension> > <!-- ************** Views ********************** --> >Index: src/org/eclipse/team/internal/ui/synchronize/TwoSidesSaveableCompareEditorInput.java >=================================================================== >RCS file: src/org/eclipse/team/internal/ui/synchronize/TwoSidesSaveableCompareEditorInput.java >diff -N src/org/eclipse/team/internal/ui/synchronize/TwoSidesSaveableCompareEditorInput.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/team/internal/ui/synchronize/TwoSidesSaveableCompareEditorInput.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,198 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.team.internal.ui.synchronize; >+ >+import java.lang.reflect.InvocationTargetException; >+ >+import org.eclipse.compare.*; >+import org.eclipse.compare.structuremergeviewer.Differencer; >+import org.eclipse.compare.structuremergeviewer.ICompareInput; >+import org.eclipse.core.resources.IResource; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.osgi.util.NLS; >+import org.eclipse.team.internal.ui.mapping.AbstractCompareInput; >+import org.eclipse.team.internal.ui.mapping.CompareInputChangeNotifier; >+import org.eclipse.team.ui.synchronize.SaveableCompareEditorInput; >+import org.eclipse.ui.IWorkbenchPage; >+ >+public class TwoSidesSaveableCompareEditorInput extends >+ SaveableCompareEditorInput { >+ >+ private ITypedElement left; >+ private ITypedElement right; >+ >+ public TwoSidesSaveableCompareEditorInput(ITypedElement left, >+ ITypedElement right, IWorkbenchPage page) { >+ super(new CompareConfiguration(), page); >+ this.left = left; >+ this.right = right; >+ } >+ >+ public String getToolTipText() { >+ >+ IResource leftResource = getLeftResource(); >+ IResource rightResource = getRightResource(); >+ >+ if (leftResource != null && rightResource != null) { >+ String leftLabel = leftResource.getFullPath().makeRelative() >+ .toString(); >+ String rightLabel = rightResource.getFullPath().makeRelative() >+ .toString(); >+ return NLS >+ .bind( >+ "Two-way compare of {0} with {1}", new String[] { leftLabel, rightLabel }); //$NON-NLS-1$ >+ } >+ >+ return NLS >+ .bind( >+ "Two-way compare of {0} with {1}", new String[] { left.getName(), right.getName() }); //$NON-NLS-1$ >+ } >+ >+ //XXX: from CompareFileRevisionEditorInput >+ protected void fireInputChange() { >+ ((MyDiffNode)getCompareResult()).fireChange(); >+ >+ } >+ //XXX: from CompareFileRevisionEditorInput* >+ protected ICompareInput prepareCompareInput(IProgressMonitor monitor) >+ throws InvocationTargetException, InterruptedException { >+ ICompareInput input = createCompareInput(); >+ getCompareConfiguration().setLeftEditable(isLeftEditable(input)); >+ getCompareConfiguration().setRightEditable(isRightEditable(input)); >+ // both are local >+// ensureContentsCached(getLeftRevision(), getRightRevision(), monitor); >+ initLabels(input); >+ return input; >+ } >+ >+ //XXX: from CompareFileRevisionEditorInput >+ private boolean isLeftEditable(ICompareInput input) { >+ Object left = input.getLeft(); >+ if (left instanceof IEditableContent) { >+ return ((IEditableContent) left).isEditable(); >+ } >+ return false; >+ } >+ >+ private boolean isRightEditable(ICompareInput input) { >+ Object right = input.getRight(); >+ if (right instanceof IEditableContent) { >+ return ((IEditableContent) right).isEditable(); >+ } >+ return false; >+ } >+ >+ private void initLabels(ICompareInput input) { >+ CompareConfiguration cc = getCompareConfiguration(); >+ >+ IResource leftResource = getLeftResource(); >+ IResource rightResource = getRightResource(); >+ >+ if (leftResource != null && rightResource != null) { >+ String leftLabel = leftResource.getFullPath().makeRelative() >+ .toString(); >+ String rightLabel = rightResource.getFullPath().makeRelative() >+ .toString(); >+ >+ cc.setLeftLabel(leftLabel); >+ cc.setRightLabel(rightLabel); >+ } >+ >+ } >+ >+ private IResource getLeftResource() { >+ if (left instanceof LocalResourceTypedElement) { >+ LocalResourceTypedElement lrte = (LocalResourceTypedElement) left; >+ return lrte.getResource(); >+ } >+ return null; >+ } >+ >+ private IResource getRightResource() { >+ if (left instanceof LocalResourceTypedElement) { >+ LocalResourceTypedElement lrte = (LocalResourceTypedElement) right; >+ return lrte.getResource(); >+ } >+ return null; >+ } >+ >+ >+ private ICompareInput createCompareInput() { >+ MyDiffNode input = new MyDiffNode(left,right); >+ return input; >+ } >+ >+ //XXX: from CompareFileRevisionEditorInput* >+ CompareInputChangeNotifier notifier = new CompareInputChangeNotifier() { >+ protected IResource[] getResources(ICompareInput input) { >+ IResource leftResource = getLeftResource(input); >+ IResource rightResource = getRightResource(input); >+ if (leftResource == null && rightResource == null) >+ return new IResource[0]; >+ if (leftResource == null && rightResource != null) >+ return new IResource[] { rightResource }; >+ if (leftResource != null && rightResource == null) >+ return new IResource[] { leftResource }; >+ return new IResource[] { leftResource, rightResource }; >+ } >+ }; >+ >+ //XXX: from CompareFileRevisionEditorInput >+ public class MyDiffNode extends AbstractCompareInput { >+ public MyDiffNode(ITypedElement left, ITypedElement right) { >+ super(Differencer.CHANGE, null, left, right); >+ } >+ public void fireChange() { >+ super.fireChange(); >+ } >+ protected CompareInputChangeNotifier getChangeNotifier() { >+ return notifier; >+ } >+ public boolean needsUpdate() { >+ // The remote never changes >+ return false; >+ } >+ public void update() { >+ fireChange(); >+ } >+ } >+ >+ //XXX: from CompareFileRevisionEditorInput >+ private IResource getLeftResource(ICompareInput input) { >+ if (getLeftLocalElement() instanceof IResourceProvider) { >+ return ((IResourceProvider) getLeftLocalElement()).getResource(); >+ } >+ return null; >+ } >+ >+ //XXX: from CompareFileRevisionEditorInput >+ public LocalResourceTypedElement getLeftLocalElement() { >+ if (left instanceof LocalResourceTypedElement) { >+ return (LocalResourceTypedElement) left; >+ } >+ return null; >+ } >+ >+ private IResource getRightResource(ICompareInput input) { >+ if (getRightLocalElement() instanceof IResourceProvider) { >+ return ((IResourceProvider) getRightLocalElement()).getResource(); >+ } >+ return null; >+ } >+ >+ public LocalResourceTypedElement getRightLocalElement() { >+ if (right instanceof LocalResourceTypedElement) { >+ return (LocalResourceTypedElement) right; >+ } >+ return null; >+ } >+ >+} >Index: src/org/eclipse/team/internal/ui/actions/CompareAction.java >=================================================================== >RCS file: src/org/eclipse/team/internal/ui/actions/CompareAction.java >diff -N src/org/eclipse/team/internal/ui/actions/CompareAction.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/team/internal/ui/actions/CompareAction.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,84 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.team.internal.ui.actions; >+ >+import java.lang.reflect.InvocationTargetException; >+ >+import org.eclipse.compare.*; >+import org.eclipse.core.resources.IFile; >+import org.eclipse.core.resources.IResource; >+import org.eclipse.jface.action.IAction; >+import org.eclipse.jface.viewers.ISelection; >+import org.eclipse.team.internal.ui.synchronize.TwoSidesSaveableCompareEditorInput; >+import org.eclipse.team.ui.synchronize.SaveableCompareEditorInput; >+import org.eclipse.ui.*; >+ >+public class CompareAction extends TeamAction { >+ >+ >+ protected void execute(IAction action) throws InvocationTargetException, >+ InterruptedException { >+ >+ IResource[] selectedResources = getSelectedResources(); >+ >+ if (selectedResources.length == 2) { >+ >+ ITypedElement left = null; >+ if (selectedResources[0] != null) { >+ left = getElementFor(selectedResources[0]); >+ } >+ >+ ITypedElement right = null; >+ if (selectedResources[1] != null) { >+ right = getElementFor(selectedResources[1]); >+ } >+ >+ openInCompare(left, right); >+ } >+ } >+ >+ //XXX: from CompareRevisionAction* >+ private void openInCompare(ITypedElement left, ITypedElement right) { >+ IWorkbenchPage workBenchPage = getTargetPage(); >+ CompareEditorInput input = createCompareEditorInput(left, right, workBenchPage); >+ IEditorPart editor = CompareRevisionAction.findReusableCompareEditor(workBenchPage); >+ if (editor != null) { >+ IEditorInput otherInput = editor.getEditorInput(); >+ if (otherInput.equals(input)) { >+ // simply provide focus to editor >+ workBenchPage.activate(editor); >+ } else { >+ // if editor is currently not open on that input either re-use >+ // existing >+ CompareUI.reuseCompareEditor(input, (IReusableEditor) editor); >+ workBenchPage.activate(editor); >+ } >+ } else { >+ CompareUI.openCompareEditor(input); >+ } >+ } >+ >+ protected TwoSidesSaveableCompareEditorInput createCompareEditorInput( >+ ITypedElement left, ITypedElement right, IWorkbenchPage page) { >+ return new TwoSidesSaveableCompareEditorInput(left, >+ right, page); >+ } >+ >+ public void selectionChanged(IAction action, ISelection selection) { >+ super.selectionChanged(action, selection); >+ } >+ >+ //XXX: from CompareRevisionAction >+ private ITypedElement getElementFor(IResource resource) { >+ return SaveableCompareEditorInput.createFileElement((IFile)resource); >+ } >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 193324
:
71868
|
71869
|
72494
|
73935
|
74552
|
75050
|
77123
|
118372
|
118373
|
118899
|
118928
|
118929