Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 391089

Summary: Add possibility to search and replace in Application Model editor
Product: [Eclipse Project] e4 Reporter: Dirk Fauth <dirk.fauth>
Component: UIAssignee: Project Inbox <e4.ui-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: azerr, Lars.Vogel, marco, nobody, steven, wim.jongman
Version: unspecifiedKeywords: helpwanted
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
screenshot 1 none

Description Dirk Fauth CLA 2012-10-04 03:39:49 EDT
When switching to the XMI view of the Application Model editor, it should be possible to search (and replace) by hitting Ctrl+F
Comment 1 Marco Descher CLA 2012-12-10 03:10:36 EST
Is it possible to employ the org.eclipse.ui.texteditor.FindReplaceAction here, or would the necessary Action have to be ported to the new model?

I will try to find a solution here.
Comment 2 Dirk Fauth CLA 2012-12-10 03:14:51 EST
Haven't looked at it in detail yet, but looking at the package it looks like it is dependent to Eclipse 3.x code. So IMHO it looks like it needs to be ported to the new model.
Comment 3 Marco Descher CLA 2012-12-10 03:25:14 EST
In that case there is a bigger design decision involved in here, as there are already only two actions available (Undo and Redo) which do not require a Dialog. 

So I would need to introduce kind of a ported precedent, or is there already a bundle containing these ported actions?

No chance for me starting this before these question is settled.
Comment 4 Lars Vogel CLA 2012-12-10 03:34:54 EST
We should definitely not add a dependency to org.eclipse.ui.
Comment 5 Marco Descher CLA 2012-12-16 17:12:40 EST
So, what would be the right way to start porting the required Dialogs? In which plug-in would they belong?
Comment 6 Lars Vogel CLA 2014-05-08 14:58:23 EDT
Steven did add / fixes some search functionality in the live application model editor in Bug 432555, Bug 432372. I mark this on as WORKSFORME.
Comment 7 Steven Spungin CLA 2014-05-08 15:17:45 EDT
@Lars, I don't think you can search on the XMI tab yet.
Comment 8 Lars Vogel CLA 2014-05-08 15:21:26 EDT
Thanks Steven for the clarification. Reopening.
Comment 9 Steven Spungin CLA 2014-05-08 15:27:11 EDT
(In reply to Lars Vogel from comment #8)
> Thanks Steven for the clarification. Reopening.

Is it worth it to pull in dependency and use the existing eclipse XML editor?  I have used it on other RCP projects.  It has a bit of overhead but offers decent formatting and auto completion.
Comment 10 Lars Vogel CLA 2014-05-08 15:31:21 EDT
(In reply to Steven Spungin from comment #9)
> (In reply to Lars Vogel from comment #8)
> > Thanks Steven for the clarification. Reopening.
> 
> Is it worth it to pull in dependency and use the existing eclipse XML
> editor?  I have used it on other RCP projects.  It has a bit of overhead but
> offers decent formatting and auto completion.

That would introduce a dependency to WTP, right? I think we should avoid that.
Comment 11 Steven Spungin CLA 2014-05-08 15:38:55 EDT
(In reply to Lars Vogel from comment #10)
> (In reply to Steven Spungin from comment #9)
> > (In reply to Lars Vogel from comment #8)
> > > Thanks Steven for the clarification. Reopening.
> > 
> > Is it worth it to pull in dependency and use the existing eclipse XML
> > editor?  I have used it on other RCP projects.  It has a bit of overhead but
> > offers decent formatting and auto completion.
> 
> That would introduce a dependency to WTP, right? I think we should avoid
> that.

I can understand that.  How about a swing component with XML Editor Kit?
Comment 12 Lars Vogel CLA 2014-05-08 15:43:57 EDT
(In reply to Steven Spungin from comment #11)
> I can understand that.  How about a swing component with XML Editor Kit?

I think swing is even more evil than WTP. :-)
Comment 13 Wim Jongman CLA 2014-05-08 15:45:08 EDT
There was an idea from Angelo Zerr to use the orion editor.
Comment 14 Lars Vogel CLA 2014-05-08 15:47:34 EDT
(In reply to Wim Jongman from comment #13)
> There was an idea from Angelo Zerr to use the orion editor.

+1 for that.
Comment 15 Angelo ZERR CLA 2014-05-08 17:02:48 EDT
> There was an idea from Angelo Zerr to use the orion editor.

Hi Lars, Wim,

I would like to clarify some info about my idea about search and replace. At first, using orion editor will not fix the problem with Application Model editor. There is the same problem with the integration of orion editor in teh e4Tools :  it doesn't provide search/replace capability.

I think this bug should be renamed to "Add possibility to search and replace in any editor". Indeed org.eclipse.ui.texteditor.FindReplaceAction is linked to 3.x Editor, and today E4 provides several editor kind : 

 * 3.x Editors
 * OrionEditorControl which uses SWT Browser to load JS Orion editor.
 * Application Model editor

I had the same problem with my project CodeMirror-Eclipse https://github.com/angelozerr/CodeMirror-Eclipse where I embed CodeMirror in SWT Browser (and I have done the same idea for OrionEditorControl). CodeMirror gives some features for search/replace but I would like to use the SWT "Find/Replace" dialog to fill search/replace. 

It was impossible to use the existing FindReplaceAction, because my CodeMirror editor doesn't extend 3.x TextEditor. That's why I had to implement my own FindReplaceAction https://github.com/angelozerr/CodeMirror-Eclipse/blob/master/core/codemirror.eclipse.ui/src/codemirror/eclipse/ui/internal/search/WorkbenchFindReplaceAction.java (I have copied/pasted the original FindReplaceAction and adpat it for CodeMirror).

The problem with this solution is that my search dialog is not shared between 3.x editors and my CodeMirror editors.

So I think, FindReplaceAction should be removed from org.eclipse.ui.texteditor to E4 project or E4 should provide an E4FindReplaceService in order to any editor (3.x, Embed SWT Browser editor, Application Model editor) can benefit and contribute to search/replace features by using the same SWT "Find/Replace" dialog.

Regards Angelo
Comment 16 Steven Spungin CLA 2014-06-11 16:48:41 EDT
I refactored the XMI code in the model editor to a new class called XmiTab.  At the top of the tab I added a text box that will cycle search the contents (highlight and scroll into view).

See following screenshot for more details.
Comment 17 Steven Spungin CLA 2014-06-11 16:49:28 EDT
Created attachment 244174 [details]
screenshot 1
Comment 18 Wim Jongman CLA 2014-06-11 17:05:56 EDT
(In reply to Steven Spungin from comment #17)
> Created attachment 244174 [details]
> screenshot 1

Cool. A good start. Does the cycle work with CTRL+K / CTRL+L just like in the Java editor.
Comment 19 Steven Spungin CLA 2014-06-11 17:15:24 EDT
Every time the user hits enter the next one is found.  I really don't want to do to much more until we get a better editor.  It's sad that nobody has found an XML editor that does not have 'excess baggage'.

My main goal with this was to put the code into a separate class, so eventually replacing the editor would be an easier task.  The search field is just icing on the cake.
Comment 20 Steven Spungin CLA 2014-06-11 22:17:43 EDT
Gerrit Review: https://git.eclipse.org/r/#/c/28394/