Eclipse RCP update a View after changes in the editor - java

i am new to Eclipse RCP and have the following Scenario:
One plugin which is the Application
Another witch is a view and does show
some Data
And a third which is the
editor.
in the view I can right click on a record and choose edit what does open the Editor and lets me change the data.
No I'd like to refresh the View when I save the Editor. I think this is a classical scenario to implement a Whiteboard pattern. Unfortunately I am not really familiar with it, may be some one could show a simple example how to implement it in Eclipse RCP.
Thanks in Advance
Johannes

Your view needs to implements IPartListener2 (http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/api/org/eclipse/ui/IPartListener2.html)
you can override the method partInputChanged(IWorkbenchPartReference partRef) to refresh thw view in two ways:
1) If the plug-in with view has dependency to plugin with editor
If (partRef instanceOf YourEditorClass){
YourData yourData = editor.getInput().getxxx();
}
2) If the plug-in with view doesn't have dependency to plugin with editor
you need to use an adapter. You override the getAdapter method in the editor to return the Data that you need and the view get the data from the adapter
If (partRef instanceOf EditorPart){
YourData yourData = Platform.getAdapterManager().getAdapter(this, YourData.class);
}
Two codes are just an example to show the idea!
I hope I helped you

The view has to listen to the editor or - even better - to the edited model. If it listens to the editor, look for some "save" events. Personally I would make the model itself observable and notify listeners (like your view) of actual changes.
The view then needs some logic to extract its information from the model. So instead of a whitboard - the observer pattern should be the right choice for your design.
This is worth a try: add an IPropertyListener to the IEditorPart instance of your editor and wait for property changes. The IEditorPart.PROP_DIRTY property should change from "is dirty" to "is not dirty" after a save. Snippets/code example for eclipse rcp stuff are hard to develop and to communicate. Use the buzzwords from my answer for some searches on the eclipse help, API and on google. And: good luck ;) - btw, consider buying some good books on eclipse plugin/rcp development, they're worth every €/$ spent.

Related

Eclipse Scout (re-)activate Form in SWT Client

yet a new Eclipse Scout question from me:
In my Scout Application which is roughly based on the template "Outline Tree and Table Form" I managed to add new instances of a (search)form with a click on a node. My form's display properties are configured like this:
#Override
protected int getConfiguredDisplayHint() { return DISPLAY_HINT_VIEW; }
#Override
protected String getConfiguredDisplayViewId() { return VIEW_ID_PAGE_DETAIL; }
I'm not adding the forms to pages with the built-in methods(e.g. setDetailForm(IForm form)), but I set them as a new attribute to the pages and start them via their FormHandler. In this way I achieve that the Scout renderer tabs the forms next to each other and this is exactly what I want. Adding them as forms to the page causes the renderer to close the other forms whenever a page is activated, so only one form is displayed at one time.
My problems with this implementation are:
Reactivation of the tabs is only possible in the RAP client. For the RAP client it is enough to call the activate() method of the form to reactivate and focus the corresponding tab.
On the other hand the SWT client (which I depend on) doesn't seem to care at all about the activate() call and therefore does not reactivate the page.
So I'm searching for a safe and easy way to persuade the SWT renderer of
tabbing the forms next to each other preferably without the use of a Scout TabField. As described above, this is already working, but I'm not sure if this is the recommended way.
reactivate the tabs on a NodeClick as the RAP client already does
Receive events when clicking on the tab closing the tab (X-button in SWT, no button in RAP -.-), or whatever. I think this question is bit broader as it is a general problem in Scout to step into product-specific processes which are not part of the abstract programming model of Scout. Nevertheless, it would be nice to process those event and others out of the global client without tweaking the specific rendering products.
A screenshot of my program's UI to make things easier to follow:
In the screenshot the fifth form is activated as a view and the corresponding node in the outline tree on the left is also marked. As you see, there are multiple forms added which all belong to a node in the outline tree. When I click a node in the tree, I want the corresponding form to be activated and focuse if it hasn't been openend before. Apart from that the tabs should stay the same. I don't want to reinitialize the forms that already exist.
I'm using Scout Version 5.0
The RAP UI is nearer to the SWING UI than to the SWT. This is why, out of the box, the views can not be closed with the x in RAP (similar to Swing).
For SWT we rely on the workbench provided by the Eclipse Platform. This defines how views are opened and tabbed in a View Stack.
For me it is Ok to use scout (SWT renderer) that way. Here an example:
The ComplexForm is opened as a SWT View next to the already opened Form.
I am surpised to hear that activate() on the scout Form doesn't work for you. I had a similar problem, raised Bug 433010 and we decided to close it, exactly because the activate() method was the solution.
ComplexForm form = new ComplexForm();
form.startNew();
form.activate();
I guess that on any event (a click somewhere on a Menu or on a Node) you can get call activate() on the form instance.
Which version of Scout are you using?
Maybe you could add a Screenshot in your question, because I am missing your point.

how to limit the reorder in draglinearlayout (need some idea!)

i want to use draglinearlayout to do drag and drop action. See the link in Github https://github.com/justasm/DragLinearLayout
This source library allow user to drag those view added by the AddDragView(View,(View) findViewById(R.id.controller)).
In my draglinearlayout, i have various views (cannot drag) and many dragView. i want to limit the drag action across the normal view(cannot be drag). That mean if i try to drag the dragView across those normal view, it should detect it and stop my action.
Do I need to override which part of the source codes??
I have search for google using keyword 'draglinearlayout', but there are only few of relevant website and i cannot found what i want!!!
I guess the easiest way is to remove your elements non-draggable from the DragLinearLayout and put it in a separate LinearLayout. I honestly don't think it is possible otherwhise.
Also you can't override some parts of the code ( like the ontouch events ) otherwhise it will cancel the draglinearlayout effect.
If you can't find what you want you can also open a new issue on the related github.
Because of addDragView(...) is actually addView(...) followed by setViewDraggable(...)
Try to use
layout.addView(view);
layout.setViewDraggable(view, view); // only if you want it dragable
instead of
layout.addDragView(imageView, imageView);

Multiple Page Development in Java with Eclipse and GWT

I have been writing some basic code for an application I am designing. I have learned the basics and gotten some simple database connection working with RPC calls etc. What I need to do now and am completely lost (as I am traditionally a c# developer with windows forms).
In c# if I wanted a new form I would just create it, and then call the show method.
How does one create multiple pages in GWT, and switch between them?
Thanks in advance,
Chris
The simplest way would be to
Make a new java class (GwtHome.java, GwtHelp.java etc)
Extend these classes by using the Composite class
Make the equivalent of a Master Page and add it to the rootPanel as a class with the appropriate headers, menu, footer and Content Placeholder (Could be any of the AbsolutePanel, VerticalPanel, HorizontalPanel objects provided by the GWT Framework)
By clicking on the menu clear the Placeholder and add the appropriate object of GwtHome, GwtHelp etc.
After getting aquanted with the above procedure, you might want to break up the code in many files using a design pattern as suggested by Andrei.
Simply clear the root panel (RootPanel.get().clear()) and add the widget for your new "page", the same way you added your first one.
If you're using LayoutPanels, do RootLayoutPanel.get().clear() instead.
Look at Activities and Places design pattern: https://developers.google.com/web-toolkit/doc/latest/DevGuideMvpActivitiesAndPlaces
I highly recommend it for a multipage GWT app. It explains pretty well how you create different "views", that are driven by their "activities", and tied to specific "places" (pages) that users can navigate.
Typically you use a LayoutPanel as your "page" container that occupies the entire available browser window. You split this LayoutPanel into 2-3 layers (zones), like top menu, side menu, main area. Each area contains one widget, usually a ScrollPanel, FlowPanel, or HtmlPanel. Then you use different widgets or HTML inside each of these widgets to display whatever you need. You may also create your own composite widgets that you can reuse in different pages.

How do I show quick fixes when I hover over an error in my custom editor

I've written an eclipse editor for my own DSL. When an editor is opened or saved I check the contents and create problem markers for any syntax errors. The markers show up in my editor as expected, and also in the Problems view.
I've got an extension point org.eclipse.ui.ide.markerResolution and provide an implementation of IMarkerResolutionGenerator which creates resolutions for problem markers. This works fine; when I right click a problem in the Problems view the Quick Fix option shows in the context menu and works fine.
My editor extends SourceViewerConfiguration and I override getQuickAssistAssistant(), returning an extension of QuickAssistAssistant. This allows me to right click a problem in the editor and see the Quick Fix option in the menu.
I'd really like to get the quick fix resolutions to appear when I hover over the problem in the editor, just like in the java editor. Currently just the problem text appears in the tooltip. Is there a seperate hook into this or should it be covered in two quick fix hooks I've already implemented?
I had the same problem and found a solution for myself: How to implement Quick Fix / Quick Assist for custom eclipse editor?
From what I've understood, Markers show up in the Problems View and Annotations show up in the editor (on the ruler and on mouse hover).
I use the org.eclipse.ui.editors.annotationTypes extension point to register my own annotation type and the org.eclipse.ui.editors.markerAnnotationSpecification extension point to specify the look and feel. In my custom SourceViewerConfiguration class I override getAnnotationHover(...) to return a DefaultAnnotationHover object and getTextHover(...) to return a DefaultTextHover object, so the annotations are shown in my source viewer.
To create annotations, you could use org.eclipse.ui.texteditor.SimpleMarkerAnnotation, you can construct a SimpleMarkerAnnotation passing a marker object to the constructor.
Then you need to add the annotation to the annotation model. You can use getAnnotationModel() on your SourceViewer and then addAnnotation(Annotation annotation, Position position) on the AnnotationModel. All annotations in the model will be shown in the editor.
You could also use org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel as your annotation model. Then you won't need to create annotation objects first, since AbstractMarkerAnnotationModel provides a method addMarkerAnnotation(IMarker marker).
Have a look at the IAnnotationModel interface.

How to extend Eclipse's compare context menu?

I want to create a plugin that displays additional information about Eclipse's compare results. For example, clicking a difference in Eclipse will bring up additional meta-information in my new view about who made the change, when it was made, what are the related changes, etc. I've got everything else figured out except how to call the view from the compare editor. I am thinking of using a context menu.
I was able to implement a context menu for the text editor. I used a targetID of targetID="#TextEditorContext and the action to inherit from IViewActionDelegate. But somehow the compare editor is not the same as the normal text editor. What targetID should I use? Is this even possible? Or if someone has a better idea than context menu, do share.
I was able to add additional commands (Handlers) to the compare view's context menu using the popup menu id popup:org.eclipse.compare.CompareEditor?after=additions

Categories

Resources