I implemented a custom PropertySheet as described in here.
So I have a main view, which implements the selectionprovider and it works to show the properties in my custom PropertySheet view.
My problem is now, that I want to edit the some properties of the selection in the property view and prevent changing the selection in the main view, if there are unsaved changes in the property view.
What is the best way to solve that problem?
If I implement the ISaveablePart in my custom property view, I can mark it as dirty. How can I prevent to change the selection, if my property view is dirty?
Thanks in advance!
As a view is a non-modal (e.g. non-blocking) UI component, there is no real way to prevent selection changes outside the view. For this reason, the expected way of Properties view to work is to save as soon as possible.
The default, TreeViewer based implementation of EMF models uses a CellEditor to change its values; when the value in a CellEditor changes, the changed values are written back to the original model automatically to avoid the data loss scenarios you have mentioned.
In other words, you have to rely on your data source (e.g. the editor that provides the selection) to store the permanent changes, and the changes can be serialized through that source (editor).
Related
We have an RCP app which uses a Tree and its corresponding TreeViewer. This tree uses an ObservableMapLabelProvider which provides the label text and an ObservableListTreeContentProvider for the content. We're using org.eclipse.jface.databinding-1.5.0-SDK-3.7.2.
We supply an array of IObservableMap using EMFObservables.observeMaps(contentProvider.getKnownElements(), new EStructuralFeature[]) to construct the ObservableMapLabelProvider.
We have an implementation of IPropertySourceProvider which seems to be used for populating the property view by overriding getPropertySource(Object).
Now I can see that when I modify the property sheet entry for a label, IPropertySource#setPropertyValue(Object, Object) is invoked. I want to add a change listener to our ObservableMapLabelProvider or IObservableMap to ensure that the tree columns get packed once the label text is modified. I tried adding change map listener to each element of IObservableMap but it doesn't seem to work.
Any suggestions/pointers on where should I be adding the change listener to pack tree columns once label text is changed on the property sheet?
The Properties view part is implemented by the PropertySheet class, and it's worth reading its Javadoc. PropertySheet is a type of PageBookView, a view that shows one of many managed pages. The Properties view's current page shows the properties of the current selection.
So you could try obtaining the tree viewer from the current page from the Properties view part (based on its view ID, org.eclipse.ui.views.PropertySheet) via getCurrentPage().getControl(), and then perform whatever column voodoo is required.
Alternatively you could provide your own IPropertySheetPage that behaves how you want.
In texts about a selections (like this https://www.eclipse.org/articles/Article-WorkbenchSelections/article.html) it is usually said to provide selection by commands like this:
getSite().setSelectionProvider(tableviewer);
This is good if a view has only one control, for example, TableViewer.
But what to do if view has several controls?
I can't delegate selection providing to any ONE of them. Probably I should track which one is selected and switch selection provider appropriately?
You can create a selection provider which wraps all of your viewers (or other selection providers) and switches between them automatically. Unfortunately, something like that isn't included in the framework.
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.
I want to do something like this pseudo-code
MyView v = new MyView(); //yeah, I know i can't do this
v.setObject(myObject);
v.show();
my case is: i'm using swtjasperviewer to show my reports, and i have to instantiate the report in this jasperviewer, which leave the view opened if the report has no pages...
I want to use a command to open a view, and pass the report to a view, this way, I can use a generic view.
thanks a lot
There are basically two ways to do this:
If the object is somehow related to the selection of another view or an editor, then you could use write a SelectionListener that gets the current selection, and then sets the correct object using the following method: getViewSite().getPage().addSelectionListener(mySelectionListener)
Otherwise, define an object that both your code and the view can reach (e.g. using a static attribute, an OSGi service or an Eclipse extension), and you can use that object to pass information. Your data source updates this object, and you can define a change listener/callback that the view can register himself to.
I'm going out on a limb here, and hoping that someone has used IT Mill Toolkit before:
I have a Table with a bunch of Items inside. I edit one of them – how do I get the Table to refresh and re-render itself? I've tried with requestRepaint(), requestRepaintAll() on both the table, and the Layout that contains the Table, but I can't get it to refresh itself. When I reload the page, or scroll back and forth (so that the Item goes from view and comes back into view), the Item has been updated.
Is there a way to programmatically get the Table to refresh its current view?
Doesn't the item container implement this feature? Say that you use a IndexedContainer in your Table. AFAIK the IndexedContainer notices when you change the content, and it in turn sends a notice to everything using it as a datasource (= table). So a normal table should pick this up.
Edit- checked this:
IndexedContainer implements Property.ValueChangeNotifier
Table implements ValueChangeListener which runs a requestRepaint().
In other words, your container also has to implement the notifier so that the automatic repaint can be called.