How to combine Eclipse Databinding and UndoableOperations? - eclipse

in my RCP - Project i'm using eclipse databinding to connect the ui with the backend. I want every change in an open editor to be undoable. My Domainmodell and UI are seperated in two different plugins.
My current approach is to implement my own UpdateValueStrategy class for the databinding. I extend the normal UpdateValueStrategy and override the doSet Methode.
From there i get the OperationHistory and the Global UndoContext, then i create a new Operation. I have various Operations like "ChangeCustomerName" and "ChangeCustomerNote".
Questions:
Do i need to implement the undo/redo - logic by my own, or is the framework somehow supporting my with this?
Is there a better place or way to create the undoable Operation then the doSet() of the UpdateValue - Strategy class. To access the textfield, which was changed is not to easy.

The answer you will get mostly is: Use EMF.Edit, it includes it out of the box with org.eclipse.emf.databinding.edit and there's an excellent tutorial on the net.
There is an open feature request in the Eclipse bugtracker about including undo/redo also in JFace databinding without EMF but it's not finished yet. It has also be discussed in the eclipse forum.

Related

Integrate existing TouchUI component into RTE - AEM 6.1

I'm looking to see if it's possible to integrate an existing AEM Component that I've developed (lets say button component) into the RTE.
I've read the following blog posts
http://experience-aem.blogspot.com/2015/01/aem-6-sp1-touchui-richtext-editor-color-picker-plugin.html
http://experience-aem.blogspot.com/2015/09/aem-61-touch-ui-rich-text-editor-rte-browse-insert-image.html
I've also read the documentation (which is non existent).
I'm not looking to recreate the exact same component just for the RTE, this would need us to maintain two separate code bases, recreate the custom logic we have in the already existing component which has been tested and automation.
But most of all, go against best practices as we want everything to be agnostic.

Xtext UI model validation and messaging via markers

Currently I have some validation in the main project which the UI project interprets as markers. I would like move that validation from the main project to the UI project, so that the parser is not concerned about it. Also I would like to add validations and marker messaging which need some data from preferences, so these have to be in the UI project as well, aimed to enrich the UI experience. What is the best way to plug in several model validations (preferably separate) which would get the marker-displaying support of Xtext?
Don't do that. The validation is part of your model. If you move it to the UI plugin, other EMF tools can access your model without being bound to the validation and could create invalid models (because they do not trigger your validations).
Preference pages are shown in UI plugins, but preference values are stored in so called preference stores, which are accessible from non UI plugins. Therefore using preferences to tune validations is no reason to move them to the UI plugin.

How to add JFace table to Eclipse RCP New Project Wizard

I have a Wizard with two pages: pageone extending WizardNewProjectCreationPage, and pagetwo is extending WizardPage. I want the user to be able to create the project first, and then add files to the project on the second page.
For the latter I want to use a SWT Table (?) like when you pick an interface in the Java Class Wizard in Eclipse IDE (cf. picture here). Also the "Add" button next to it.
How can I achieve this? Do I have to use Eclipse Forms API for this? Or simply add a SWT Table? I have used the Plug-In Spy but the source code given in NewClassWizardPage and NewTypeWizardPage seems to be very specific to this example and I cannot make sense of it.
I've also had a look at vogella's tutorial for JFace table, but I can't get my head around it.
Just some basic steps would be great, or maybe somebody has done this before?
I can easily understand why you're confused... there are indeed many ways to do this. You even left out Data Binding which provides you with yet another way to populate and decorate the table in question.
To sum up the usage of the different APIs:
SWT provides the basic widgets and controls. Often these have a rather irregular low-level interface - especially compared with Swing - but you need to access the SWT controls to lay them out (an exercise that can be complicated in itself). Also many of the listeners are on the controls.
JFace provides a set of viewers on top of the corresponding structured SWT controls - e.g. TableViewer on top of Table. These viewers provides a high-level interface to the functionality of the underlying control - e.g. with models, label providers, sorting, filtering and more. (The viewers can easily be compared with the Swing counterparts...)
Eclipse Forms provides a (relatively) simple way to create views, dialogs, etc that looks like web pages. Examples of this are the various PDE editors.
Data Binding provides a (somewhat complicated) way to bind controls (including Tables) to a data structure (Bean, EMF or POJO based).
So... you have to decide on whether to use the model facet of JFace and Data Binding, but the rest of the APIs are often combined in the same view or dialog.
NewClassWizardPage and NewTypeWizardPage are both particular complicated examples of wizards - don't base your own work on these!
For your particular case - as I understand it - I would use a simple JFace TableViewer to hold the list of interfaces... (I use a TableViewer rather than a ListViewer as the later cannot have an image as part of the label provider.) The "Add" and "Remove" buttons will manipulate the model of the viewer and then update the viewer. You don't need Eclipse Forms as the wizards usually don't look like web pages. And Data Binding is also an overkill here given the very, very simple data for the wizard.
Please note that the function of a wizard is only performed after all the wizard pages has been shown and the "Finish" button is pressed.

Windowbuilder Pro - selectedElement binding not working

Following a tutorial trying to learn Windowbuilder Pro and running into some problems.
I have a list of an object, and want to create a binding function so that that when I've selected an object in the list, the corresponding objects name will appear in a button.
This type of operation never works for me. No object-specific options appear in the "selectedElement" column, just .
If I try to bind say a button to a specific beans property, it works well.
The documentation for Windowbuilder is so sparse I didn't think of anywhere else to turn.
Greatly appreciate any help with solving the problem or resources for learning Windowbuilder indepth.
I should point out the WindowBuilder docs on Swing Data Binding are expressly intended to document how to use the WB tools and not how to use the Swing Data Binding API itself. In fact, WindowBuilder expects you to have a fairly good grasp of Swing Data Binding fundamentals before you can effectively use the tools it provides.
Based on your question, it sounds like you need to create an as described in the WB docs here. To understand what an is and how to use it, you should refer to the Swing Data Binding docs themselves.
The bottom line is that, if you know how to create the Swing Data Bindings that you need by hand (in source), you should be able to more rapidly create then using WindowBuilder. WB strives to expose the Swing DB API in as pure a form as possible (warts and all). We have intentionally tried to expose the full power of the DB API without adding any simplification layer on top of it. The downside is that, if you are new to the Swing DB API and don't know how it all is intended to work, WB will not help you or teach you how to use it.

Dynamically creating GWT screens using Metadata?

I have an AWT applet application that needs to be ported over to GWT. The applet screens are described in meta data and the applet renders each screen dynamically using reflection.
We'd like the same thing in GWT/ExtGWT.
I've built a working version of this ExtJS whereby the metadata is turned into ExtJS Screen configs in the form of JSON. The drawback with this approach is the "wiring" of controls to data needs to be written in Javascript.
GWT is preferred since it'd be all Java code, no JS. Upon digging in it's possible to render the screens using GWT off the metadata using GWT.create().
The problem I'm having is the wiring to hook a dynamically created button for example to an event handler requires reflection which is not supported in GWT.
Is this conclusion correct? and if so, are there any other ways to achieve this type of dynamic UI using ExtGWT?
For extGWT where we don't have declarative UI's the easiest solution might be to just add a mapping/config your handlers in java which refer to instantiated classes. of the handlers, i.e.:
Map<String, ActionListener> mapping = new HashMap<String, ActionListener>();
mapping.put("HandleClicked", new HandleClickedActionListener());
then you can try to find an implementing class for your meta data.
For pure GWT 2 you can take a look at http://code.google.com/intl/de-DE/webtoolkit/doc/latest/DevGuideUiBinder.html#Simple_binding on how it's done there. it might be possible to create a similiar solution which annotated methods for you own extgwt solution like the one in gwt.