Show Diff of two trees in Eclipse - eclipse

In Eclipse, I am using a TreeViewer to show a custom tree, whose contents are drawn from an ITreeContentProvider. Now I am trying to create a second view that allows me to automatically show a two-way comparisons of two such trees. I found various views for textual comparison within Eclipse, but I could not find an easy way to show the structural differences between two arbitrary trees. Any thoughts?

When the Data Model the ContentProvider is creating and the labelProvider is diplaying is the Same, you could use the same viewer in the right and the left of a view.
You could than compare the TreeItem Elements of both TreeViewer and mark the ones, which has changed.
The other solution is to compare the DataModels and add a special flag to the changed elements. The LabelProvider can check this flag and draw a special color to indicate, that this element is different.
I do not know an Editor inside Eclipse, providing this functionality.

Related

figures do not display in Eclipse GEF viewer

I create a ScrollingGraphicalViewer to show my figures, but no figure displays.
I debugged the source and it seems all object (figures, editparts, models) are created, no exceptions. Why the figures do not display?
Since the code is larege and spread many Java files, I briefly depict what I did.
creating model objects. In my model, there are two kinds of elements, directory and file. A directory may contain other directories or files.
figure objects. I create two kinds of figures, one for directory, the other for file.
the directory figure can have nested figures for nested directories and files.
editpart objects. for each kind of model elements, i.e., directory and file, to connect relation between model and figures.
an editpart factory object, for create each editpart object.
create a ScrollingGraphicalViewer object (viewer). and invoke the following methods on viewer: viewer.createControl(), viewer.setRootEditPart(), viewer.setEditPartFactory, and viewer.setContents().
Anything missing?
Any clues and comments will be appriciated.
Thanks.
Overriding refreshVisuals() in your EditParts will do the trick. This is the correct place to react to constraint changes as dictated by your model. You will have to set the figures constraint relative to the parent EditPart (and its figure's FreeformLayout) as well, so for FileEditPart (cf. cross-posting on the Eclipse GEF Forum) do something like the following in refreshVisuals().
getParent().setLayoutConstraint(this, figure, layout);
layout here will have to be a draw2d Rectangle. You can calculate that by giving it x and y values, and getFigure().getPreferredSize().width for the layout.width, and dto. for height.
For basic GEF usage - of which this is a case - I'd suggest you have a look at Rubel et al.'s GEF Book.

Hiding nodes in the model tree of EMF Compare

I would like to hide some tree nodes in the match results of EMF Compare, since they are just containers with no meaning to our users.
I have tried two approaches, but both result in some unwanted side-effects.
Using a more narrow scope
Details: https://www.eclipse.org/forums/index.php/t/781759/This
results in the separate diffs being available, but without the
enclosing tree structure of the model.
Using a post processor to remove some container objects from the tree of matches.
Details: https://www.eclipse.org/forums/index.php/t/781794/
This is more of a success in that the resulting tree structure is exactly what I'm after. This however breaks navigation in the bottom pane.
I'd be really happy if someone could have a look and see what my attempts are missing.
Thanks,
Mattias
I got a reply in the Eclipse forum. An EMF Compare core dev let me know that this is not possible without breaking behaviour as I described.
So for the rest of you trying: no dice.

Dynamic form with binding in GXT

What would be the best approach to implement a form with a variable number of text fields? I'm thinking something like this:
textField1 (removeButton)
textField2 (removeButton)
textField3 (removeButton)
addNewTextFieldButton
I would like this to bind to a list of strings.
I achieved this with an editable grid with a single column and buttons to add/delete rows.
This component is very well integrated with GWT Editor framework so you can bind your grid to a list of objects using a ListStoreEditor
The best approach would be to use the GWT Editor framework. GXT's fields are very well integrated with the Editor framework.
Here is a very rough example of how you might approach this problem.
You would start by creating one Editor for the thing you are wanting to bind to. In your case, I think a composite which contains a TextField (which is bound to the string) and a button. The button won't actually bind to anything, but you will provide a way for something which uses this class to register a SelectHandler against it. Let's call this editor SubEditor.
Once you create a UI component which is designed to bind to one string, you will next create a ListEditor<String, SubEditor> which will bind to a List<String> which will compose a view, consisting of one SubEditor per each String in the bound list.
You don't really need to create the SubEditor, as you could construct something as simple as what you want within your ListEditor's EditorSource class (read through the tutorials on ListEditors).
Again, I want to emphasize the this is a ROUGH example on how to get started. I hope there is enough information here for you to fill in the pieces.
The following SO question has helped me out a lot:
Using GWT Editors with a complex usecase

Eclipse plugin that allows customized view of variables/objects while debugging

While using C++ I have to deal with programs that have objects like matrices, linked lists etc
The default view of eclipse for variables while debugging is not very useful. It normally shows pointer values with value of only the first element in the array.
Below is how it is in eclipse:
As we can see the matrix object has rows and columns integers and a double 2D array. I cannot see the values of the array in user friendly manner.
My question is that, is there anyway in eclipse (using plugin etc) through which I can define custom user interfaces (popups) for each object/class of my interest.
For example I would like to have the following (Matlab's view) kind of popup when I hover over an initialized matrix object:
The JDT has a feature called detail formatters to make that possible. The corresponding implementation for the CDT seems to have stalled after a first prototype however, and did not make it into Eclipse.

Is there a way to replace the Eclipse JDT's code completion list with a multi-level tree?

I know that the eclipse code completion widget can be customized to add new suggestions and even to change the order.
I'm wondering whether there's a way to replace the current list format (or single-level tree, if this is a tree control) with a tree of multiple levels.
Thus, for example, instead of selecting from a list of methods sorted by name, I will select from a category and then from a subcategory, and then from the items.
I'm not too familiar with that part of the SDK, but I'd like to know if this is feasible.
Thanks!