Bug 73923 - [Actions] Add "compare with arbitrary file"
Summary: [Actions] Add "compare with arbitrary file"
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Compare (show other bugs)
Version: 3.0   Edit
Hardware: PC Linux
: P3 enhancement with 3 votes (vote)
Target Milestone: 3.5 M2   Edit
Assignee: Platform-Compare-Inbox CLA
QA Contact:
URL: http://wiki.eclipse.org/The_%22Compar...
Whiteboard:
Keywords:
: 23779 75225 142232 (view as bug list)
Depends on: 239959 244623
Blocks: 224562 240298 241088 243744
  Show dependency tree
 
Reported: 2004-09-14 15:57 EDT by Dirk Bergstrom CLA
Modified: 2009-06-02 05:13 EDT (History)
9 users (show)

See Also:


Attachments
patch #1 (19.33 KB, patch)
2008-08-11 08:35 EDT, Aleksandra Wozniak CLA
no flags Details | Diff
patch #2 (20.17 KB, patch)
2008-08-20 07:24 EDT, Aleksandra Wozniak CLA
no flags Details | Diff
patch #3 (19.30 KB, patch)
2008-08-25 03:40 EDT, Aleksandra Wozniak CLA
no flags Details | Diff
NPE (3.59 KB, text/plain)
2008-08-25 07:06 EDT, Tomasz Zarna CLA
no flags Details
patch #4 (26.61 KB, patch)
2008-08-26 18:35 EDT, Aleksandra Wozniak CLA
no flags Details | Diff
patch #5 (28.06 KB, patch)
2008-09-05 10:01 EDT, Aleksandra Wozniak CLA
no flags Details | Diff
patch #6 (28.21 KB, patch)
2008-09-09 07:14 EDT, Aleksandra Wozniak CLA
tomasz.zarna: iplog+
Details | Diff
patch #7 (33.32 KB, patch)
2008-09-16 07:15 EDT, Tomasz Zarna CLA
no flags Details | Diff
mylyn/context/zip (71.57 KB, application/octet-stream)
2008-09-16 07:15 EDT, Tomasz Zarna CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Dirk Bergstrom CLA 2004-09-14 15:57:41 EDT
I would like to be able to compare a file in my workspace with a file elsewhere
on the filesystem (eg. an old workspace).  The eclipse compare/merge editor is
better than any of the available opensource alternatives, but it's crippled by
being limited to files in the workspace.

I finally found a workaround by copying files into my workspace under "assumed"
names.  This allowed me to use "compare with each other", but it's a hack.

Yes, this pretty much the same as bug 23779, but that one is 1) old, 2) assigned
to "team", 3) assigned to 2.0.
Comment 1 Michael Valenta CLA 2007-03-23 09:15:04 EDT
*** Bug 142232 has been marked as a duplicate of this bug. ***
Comment 2 Michael Valenta CLA 2007-03-23 09:16:01 EDT
Bug 142232 has requested similar behavior without the requirement of any file being in the workspace.
Comment 3 Michael Valenta CLA 2007-06-21 15:33:04 EDT
*** Bug 75225 has been marked as a duplicate of this bug. ***
Comment 4 Andrey Loskutov CLA 2008-05-07 01:50:20 EDT
Isn't a dup of bug 198701?
Comment 5 Tomasz Zarna CLA 2008-05-12 04:09:03 EDT
*** Bug 23779 has been marked as a duplicate of this bug. ***
Comment 6 Andrey Loskutov CLA 2008-05-12 05:56:26 EDT
FUI, I've implemented the solution for this and some other "compare" bugs (see  bug 198701 comment 16) in the last version of AnyEdit tools (http://andrei.gmxhome.de/anyedit/index.html) and I offer my code for the next Eclipse release.

Regards,
Andrei
Comment 7 Tomasz Zarna CLA 2008-05-13 04:26:34 EDT
Thanks for the info Andrei. As you probably already know, there is GSOC project[1][2] I'm happy to mentor, which will address bug 224562 and all related. Including this one. As soon as Aleksandra stars to work with the code I will contact her with you, if you don't mind. I'm pretty sure she'll be happy to hear that some part of the work is already done and can be reused/integrated. Of course this would be done in respect of the IP you own. How does is sound Andrei?

PS. Please be patient, GSOC students are still in so called "Community Bonding Period". Coding starts in June.

[1] http://code.google.com/soc/2008/eclipse/appinfo.html?csaid=C3E6F99E4309702A
[2] http://eclipser-blog.blogspot.com/2008/05/poznans-eclipse-gsoc-students-at-ibm.html
Comment 8 Andrey Loskutov CLA 2008-05-13 14:40:15 EDT
Interestingly I had no idea about this bug and also about GSOC too, until one of AnyEdit users pointed me after the 2.0.0 release that there are many opened enhancement requests in this area.

You should also provide not only "Compare with" but also "Replace with" enhancements, as they are very similar in many places.

The code of AnyEdit is lizensed under BSD and is witten by myself (no other third-party IP), it means, it can be freely used by Eclipse project running under EPL.
Comment 9 Tomasz Zarna CLA 2008-05-20 15:35:14 EDT
Once again, this bug as well as all related are going to be realized as GSOC project. Here is a wiki page[1] with planned features and project roadmap. Please take a moment and visit the page. Feel free to add your comments/request/mockup screens. We will eventually transform them into real bugs.

[1] http://wiki.eclipse.org/The_%22Compare_with%22_dialog
Comment 10 Holger CLA 2008-05-21 02:33:34 EDT
(In reply to comment #9)
> [1] http://wiki.eclipse.org/The_%22Compare_with%22_dialog

Hello Mr. Zarna

- I'd really like to drag and drop files from Konqueror or another filesystem-browser.
- The dialog could be invoked via a rightclick on the editor tab (but as of bug #216710 the normal rightclickmenue will do)
- I second the request, to paste clipboard contents in a temp-file as another source. It should be possible, to first pass one portion of text, select the next text and create a second temp file before invoking the compare. Therefore the dialog should not be modal (but may or may not hover in front?).
- It might be worthwhile to rearrange the order of the files. If several files are dragged, it would be nice to sort them for last modification. But a manual reorder without the tedious copying of filenames around should be possible.
- Last, if there is too much time :-) I envision a feature like the formula-editor in spreadsheet-applications offer. A button to click, that reduces the whole dialog to a single line of textinput, that stays in front, to monitor, where the user clicked / which editor-.tab got the focus last / which entry of the package explorer was clicked.

Thank you so much
Holger
Comment 11 Aleksandra Wozniak CLA 2008-08-11 08:32:41 EDT
(In reply to comment #10)
> - I second the request, to paste clipboard contents in a temp-file as another
> source. It should be possible, to first pass one portion of text, select the
> next text and create a second temp file before invoking the compare. Therefore
> the dialog should not be modal (but may or may not hover in front?).

See bug 241088 and last patch attached to it. I think that's what you thought about.

Comment 12 Aleksandra Wozniak CLA 2008-08-11 08:35:15 EDT
Created attachment 109656 [details]
patch #1

The patch is created against branch_20080710_CompareWithDialog. Comparing external files or folders is now possible.
Comment 13 Tomasz Zarna CLA 2008-08-20 06:30:49 EDT
Ola, could you please update the patch, I can't apply it, it has some conflicting changes. I know you submitted it over a week ago, my fault, I should have reviewed earlier.
Comment 14 Aleksandra Wozniak CLA 2008-08-20 07:24:33 EDT
Created attachment 110437 [details]
patch #2

Here is the update.
Comment 15 Aleksandra Wozniak CLA 2008-08-25 03:40:38 EDT
Created attachment 110778 [details]
patch #3
Comment 16 Tomasz Zarna CLA 2008-08-25 07:06:49 EDT
Created attachment 110788 [details]
NPE

Steps to reproduce:
1. Open the dialog
2. Click on "External File..." button
3. Click "Cancel"
Comment 17 Tomasz Zarna CLA 2008-08-25 07:17:25 EDT
Except the error above I've observed couple of things I would like to comment on:
1. I'm not able to compare with an external file. The compare editor opens but the part for an external file is blank and the message says "Resource ... does not exits".
2. imo, showing an absolute path for a file in workspace isn't needed. The same thing for an external file/folder, don't show its path within workspace (including a temporary project, this shouldn't be reveled to a user)
3. Have you considered adding radio buttons (like in Create Patch wizard) to group controls for workspace resources, external files/folders and clipboard. This would make the dialog clearer.
4. Is there a way to provide a singe dialog for selecting file or folder at the same time?
5. The patch from bug 243873 has been reverted
Comment 18 Aleksandra Wozniak CLA 2008-08-26 18:35:53 EDT
Created attachment 111014 [details]
patch #4

Main change here is adding radio buttons (like suggested in comment 17, 3). For each content "type" there is a separate Text field, so for workspace file only workspace path is shown and for external file -- only it's location in the filesystem (comment 17, 4).
Comment 19 Tomasz Zarna CLA 2008-09-01 05:47:11 EDT
I think you are going in the right direction but I have a few comments:

1. Cannot browse when Workspace option is selected. No error found in the Error log.
2. After I selected two external files I got a message saying "Ancestor is not a valid resource...". I didn't touch the ancestor part at all.
3. Select an external file in the right part and then drop a workspace file on the left part. You should get the following error:

java.lang.NullPointerException
	at org.eclipse.compare.internal.CompareWithOtherResourceDialog.access$0(CompareWithOtherResourceDialog.java:653)
	at org.eclipse.compare.internal.CompareWithOtherResourceDialog$FileTextDropListener.drop(CompareWithOtherResourceDialog.java:176)
	at org.eclipse.swt.dnd.DNDListener.handleEvent(DNDListener.java:90)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1027)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1012)
	at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:770)
	at org.eclipse.swt.dnd.DropTarget.Drop(DropTarget.java:455)
	at org.eclipse.swt.dnd.DropTarget$3.method6(DropTarget.java:257)
	at org.eclipse.swt.internal.ole.win32.COMObject.callback6(COMObject.java:119)
	at org.eclipse.swt.internal.ole.win32.COM.DoDragDrop(Native Method)
	at org.eclipse.swt.dnd.DragSource.drag(DragSource.java:362)
	at org.eclipse.swt.dnd.DragSource.access$0(DragSource.java:288)
	at org.eclipse.swt.dnd.DragSource$1.handleEvent(DragSource.java:171)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3841)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3439)
	at org.eclipse.jface.window.Window.runEventLoop(Window.java:825)
	at org.eclipse.jface.window.Window.open(Window.java:801)
	at org.eclipse.compare.internal.ResourceCompareInput.showCompareWithOtherResourceDialog(ResourceCompareInput.java:238)
	at org.eclipse.compare.internal.ResourceCompareInput.setSelection(ResourceCompareInput.java:208)
	at org.eclipse.compare.internal.CompareAction.run(CompareAction.java:37)
	at org.eclipse.compare.internal.CompareWithOtherResourceAction.run(CompareWithOtherResourceAction.java:28)
	at org.eclipse.compare.internal.BaseCompareAction.run(BaseCompareAction.java:26)
	at org.eclipse.ui.internal.handlers.ActionDelegateHandlerProxy.execute(ActionDelegateHandlerProxy.java:289)
	at org.eclipse.core.commands.Command.executeWithChecks(Command.java:476)
	at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:508)
	at org.eclipse.ui.internal.handlers.HandlerService.executeCommand(HandlerService.java:169)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.executeCommand(WorkbenchKeyboard.java:472)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.press(WorkbenchKeyboard.java:824)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.processKeyEvent(WorkbenchKeyboard.java:882)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.filterKeySequenceBindings(WorkbenchKeyboard.java:571)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.access$3(WorkbenchKeyboard.java:512)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard$KeyDownFilter.handleEvent(WorkbenchKeyboard.java:127)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Display.filterEvent(Display.java:1187)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1002)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1027)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1012)
	at org.eclipse.swt.widgets.Control.traverse(Control.java:3499)
	at org.eclipse.swt.widgets.Control.translateMnemonic(Control.java:3343)
	at org.eclipse.swt.widgets.Composite.translateMnemonic(Composite.java:1064)
	at org.eclipse.swt.widgets.Control.translateMnemonic(Control.java:3361)
	at org.eclipse.swt.widgets.Display.translateMnemonic(Display.java:4362)
	at org.eclipse.swt.widgets.Display.filterMessage(Display.java:1201)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3435)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2382)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2346)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2198)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:493)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:288)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:488)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:113)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:193)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:370)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:549)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1236)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1212)
	
4. Perhaps we should hide ".org.eclipse.compare.tmp/ExternalFilesFolder" title for external resources in the Compare Editor
5. I'm missing support for dropping files/folders from outside workbench. Do we have a bug for it?
6. And the last one, layout issue: Open the dialog, make it wider, open the ancestor part. Dialog's size changes so I need to resize it again. You may want open a separate bug for it.
Comment 20 Aleksandra Wozniak CLA 2008-09-05 10:01:55 EDT
Created attachment 111817 [details]
patch #5

(In reply to comment #19)
> 1. Cannot browse when Workspace option is selected. No error found in the Error
> log.

For now the button's visibility is set to false but I didn't remove it because we will need it to solve bug 243744. 

> 2. After I selected two external files I got a message saying "Ancestor is not
> a valid resource...". I didn't touch the ancestor part at all.

Initially I thought that it would be the way to inform the user that two-way compare is going to be performed. But if it looks like a bug maybe it would be better to get rid of this warning. 

> 4. Perhaps we should hide ".org.eclipse.compare.tmp/ExternalFilesFolder" title
> for external resources in the Compare Editor

In case there is external resource in the Compare Editor the label above a pane is now set to resource's location rather than its path in workspace. 

> 5. I'm missing support for dropping files/folders from outside workbench. Do we
> have a bug for it?

Not yet, I'm going to open one. 

> 6. And the last one, layout issue: Open the dialog, make it wider, open the
> ancestor part. Dialog's size changes so I need to resize it again. You may want
> open a separate bug for it.

I think we can solve all resizing issues in bug 21649.
Comment 21 Aleksandra Wozniak CLA 2008-09-09 07:14:03 EDT
Created attachment 112070 [details]
patch #6
Comment 22 Tomasz Zarna CLA 2008-09-15 12:45:30 EDT
Sorry for the late response. The patch looks much better, but again, bunch of things I've observed:
1. Wouldn't it be better to use IResource.isLinked() in org.eclipse.compare.internal.ResourceCompareInput.buildLabel(IResource)? We shouldn't mix the input with the dialog.
2. Would return super.isEnabled(selection) || selection.length==1 work in CompareWithOtherResourceAction's isEnabled method?
3. I would gathered all the methods related to the hidden project into a single internal class in CompareWithOtherResourcesDialog.
4. Instead of cleaning the temporary project every time the action is called you could keep it, but at the same time make sure there are only 3 files available (for left, right and ancestor participants). Just an idea.
5. Have you looked for a singe dialog for selecting files or folders? We could get rid of one checkbox.
6. Please rename org.eclipse.compare.internal.CompareWithOtherResourceDialog.fselection to selection. 
Comment 23 Tomasz Zarna CLA 2008-09-16 04:35:16 EDT
(In reply to comment #22)
> 1. Wouldn't it be better to use IResource.isLinked() in
> org.eclipse.compare.internal.ResourceCompareInput.buildLabel(IResource)? We
> shouldn't mix the input with the dialog.
The isLinked() check might be not enough, this would change label of linked resources from other projects being compared. How about combining it with IResource.isHidden()?
Comment 24 Tomasz Zarna CLA 2008-09-16 07:15:26 EDT
Created attachment 112655 [details]
patch #7

Patch that addresses all issues from comment 22, except the one about a single dialog for selecting files and folders (I will open a separate bug for it). Ola what do you think about it?
Comment 25 Tomasz Zarna CLA 2008-09-16 07:15:37 EDT
Created attachment 112656 [details]
mylyn/context/zip
Comment 26 Aleksandra Wozniak CLA 2008-09-16 08:07:33 EDT
(In reply to comment #22)
> 5. Have you looked for a singe dialog for selecting files or folders? We could
> get rid of one checkbox.

There is no single dialog for selecting files and folders. There were even a request for that in bug 88676 (now closed as wontfix). Implementation of a dialog like that can be more problematic as it seems: http://dev.eclipse.org/mhonarc/lists/platform-swt-dev/msg04922.html

Comment 27 Tomasz Zarna CLA 2008-09-16 10:06:17 EDT
Latest patch released to HEAD. Marking as fixed, at the same time Ola, could you remind us which points from comment 10 have you addressed?
Comment 28 Aleksandra Wozniak CLA 2008-09-16 10:17:25 EDT
Here they are: 

(In reply to comment #10)
> - I'd really like to drag and drop files from Konqueror or another
> filesystem-browser.

See bug 246599.

> - I second the request, to paste clipboard contents in a temp-file as another
> source. It should be possible, to first pass one portion of text, select the
> next text and create a second temp file before invoking the compare. Therefore
> the dialog should not be modal (but may or may not hover in front?).

This issue is the subject of bug 241088. I think hovering in front is not necessary here and could be somewhat confusing.

> - Last, if there is too much time :-) I envision a feature like the
> formula-editor in spreadsheet-applications offer. A button to click, that
> reduces the whole dialog to a single line of textinput, that stays in front, to
> monitor, where the user clicked / which editor-.tab got the focus last / which
> entry of the package explorer was clicked.

I'm not convinced if introducing a feature like that is worthy. As I understand it, this feature can be useful when you want to compare a file with a portion of text or compare two portions of text. So it's very close to comparing something to clipboard's content which is mentioned in bug 241088. 
Comment 29 Pawel Pogorzelski CLA 2008-09-18 08:28:01 EDT
Verified in build I20080918-0100.
Comment 30 Szymon Brandys CLA 2008-09-18 08:41:48 EDT
Verified by Pawel.