|
|
Re: How to define a selection provider for my editor ? [message #1114829 is a reply to message #1113017] |
Mon, 23 September 2013 09:06 |
Laurent Le Moux Messages: 184 Registered: September 2011 |
Senior Member |
|
|
Hi Michael,
Thanks for the tip. I tried the following :
public class GraphitiEditor extends DiagramEditor implements ISelectionProvider {
private ListenerList listeners = new ListenerList();
/*
* Extend the editor to make it also an ISelectionProvider for properties.
* @see org.eclipse.graphiti.ui.editor.DiagramEditor#init(org.eclipse.ui.IEditorSite, org.eclipse.ui.IEditorInput)
*/
@Override
public void init(IEditorSite site, IEditorInput input) throws PartInitException {
super.init(site, input);
getSite().setSelectionProvider(this);
}
@Override
public void addSelectionChangedListener(ISelectionChangedListener listener) {
listeners.add(listener);
}
@Override
public ISelection getSelection() {
// Pass the EObject corresponding to the first selected PE
PictogramElement[] peArray = getSelectedPictogramElements();
if (peArray != null && peArray.length > 0) {
EObject element = (EObject)Graphiti.getLinkService()
.getBusinessObjectForLinkedPictogramElement(getSelectedPictogramElements()[0]);
if (element != null)
return new StructuredSelection(element);
}
return StructuredSelection.EMPTY;
}
@Override
public void removeSelectionChangedListener(ISelectionChangedListener listener) {
listeners.remove(listener);
}
@Override
public void setSelection(ISelection selection) {
Object[] list = listeners.getListeners();
for (int i = 0; i < list.length; i++)
((ISelectionChangedListener)list[i]).selectionChanged(new SelectionChangedEvent(this, selection));
}
But nothing is displayed in my property view...
Setting a breakpoint in addSelectionChangedListener(), it appears the method is not even called. So no listener registers to my provider. Should I "force" the registration in init() ? If so, how ?
As additionnal information, I also tried the two solutions discribed in Graphiti tutorial (setting up an adapter factory and overriding DefaultToolBehaviorProvider#getAdapter or embedding a standard table property sheet into a tabbeb one).
The emf transaction extended property sheet page gets properly displayed but I get the following exception when selecting an editable property...
java.lang.ClassCastException: org.eclipse.emf.edit.provider.ItemPropertyDescriptor$PropertyValueWrapper cannot be cast to java.lang.String
I found a few posts about this problem but no working solution.
And this problem does not show up with my explorer.
That's the reason why I now try the "ISelectionProvider approach".
But I'm stuckked and would really appreciate if anybody could tell me what to do...
Regards,
Laurent
|
|
|
|
Powered by
FUDForum. Page generated in 0.02739 seconds