Selection Listeners [message #756707] |
Mon, 14 November 2011 18:18 |
Bjoern Ickx Messages: 17 Registered: June 2011 |
Junior Member |
|
|
Hello together,
Simple Scenario: I have a RCP Application with a Graphiti-Editor-View and a TableView.
To react on selection changes within the GraphitiEditor I use the selection listener provided by the ToolBehaviorProvider.
When I select a shape within the diagram I get the corresponding business object in this way:
public PictogramElement getSelection(PictogramElement originalPE, PictogramElement[] oldSelection) { IFeatureProvider featureProvider = getFeatureProvider();
Object businessObject = featureProvider.getBusinessObjectForPictogramElement(PictogramElement);
if (businessObject instanceof Process) {
System.out.println("It is a process");
}
...
Now I want to display some properties of the selected (shape) business object in the table view.
As it seems to me, the Eclipse-way to do this is by adding a selection listener to the tableViewer.
But the problem with this is that I only get internal Graphiti objects from the selection listener e.g. Type: org.eclipse.graphiti.ui.internal.parts.ContainerShapeEditPart
I think I can't use these internal Graphiti objects to get the underlying business object as it was possible in the ToolBehaviorProvider.
Does anyone has an Idea how to solve this issue elegantly in the model view controller way? I am a liitle bit lost at the moment. In fact I don't know how to handover the business object to the tableView without violating the MVC paradigm.
I hint or explanation would make me very happy.
Best regards
Bjoern
[Updated on: Mon, 14 November 2011 18:20] Report message to a moderator
|
|
|
|
|
Re: Selection Listeners [message #758847 is a reply to message #756951] |
Thu, 24 November 2011 17:34 |
Bjoern Ickx Messages: 17 Registered: June 2011 |
Junior Member |
|
|
Hey Tim,
I really tried it to solve it myself, but I am totally lost. Would you mind help me with a short example?
I tried to find out what getBusinessObjectForPictogramElement() is doing internally, but I couldn't find the method in the source code.
Another problem is the documentation (JavaDoc) of Graphiti. Most classes and interfaces only contain the automatically generated components. No describing text. Puuh. So hard to get in.
EDIT:
ok, with the last try I found a way. But I think it is a very very dirty one. Here is the code of the selection listener in my TableVew class
...selection listener ...
Object element = structuredSelection.getFirstElement();
...
if (element instanceof ContainerShapeEditPart) {
editPart = (ContainerShapeEditPart) element;
IFeatureProvider fp = editPart.getFeatureProvider();
Object bo = fp.getBusinessObjectForPictogramElement(editPart.getPictogramElement());
if (bo instanceof Process) {
System.out.println("It is a process");
}
}
I think the problem with this solution is, that I use some internal methods, i.a. the getFeatureProvider() and getPictogramElement() which shouldn't be used here.
For both I get this type of warning:
Quote:"Discouraged access: The method getPictogramElement() from the type ShapeEditPart is not accessible due to restriction on required library /Applications/eclipse/"
But at least it is working somehow. What would be a better (clean) way to get the business object?
[Updated on: Thu, 24 November 2011 18:14] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.23147 seconds