|
|
|
|
Re: Dynamic "Refreshing" of Palette on Object Selection [message #1277680 is a reply to message #1274415] |
Wed, 26 March 2014 10:01 |
Sudharshan Ravi Messages: 12 Registered: March 2014 |
Junior Member |
|
|
A Quick Update on this.
The solution I presented earlier is not the best way to go about the Palette refresh because the getSingleClickFeature() requires the object to first be selected and then the click to be done. So basically two clicks on an object with a pause in between which is not intuitive behavior.
Another problem with this was that Graphiti seems to think that hovering over an object is same as selection? Thus if I have selected an object and hover my mouse over another, then the palette is refreshed on the object that my mouse is hovering over instead of the object selected.
I found instead that the method selectionChanged() worked much better because it responds on selection of the object, not a click after or mouse hover position.
public class MyEditor extends DiagramEditor{
@Override
protected DiagramBehavior createDiagramBehavior() {
return new GuideDiagramBehavior(this);
}
@Override
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
if (selection instanceof IStructuredSelection) {
IStructuredSelection sel = (IStructuredSelection) selection;
if (!sel.isEmpty()
&& sel.getFirstElement() instanceof GraphitiShapeEditPart) {
GraphitiShapeEditPart ep = (GraphitiShapeEditPart) sel.getFirstElement();
if (ep.getPictogramElement() instanceof PictogramElement) {
PictogramElement pe = ep.getPictogramElement();
XmleditorToolBehaviorProvider.setPictogramElement(pe);
getDiagramBehavior().refreshPalette();
}
}
}
}
}
Thus on object selection, the palette is refreshed with new entries based on the object. Hovering over another object does not refresh the palette as before.
I override the selectionChanged() method in my class MyEditor which extends DiagramEditor. I send the pictogram element that is selected to MyToolBehaviorProvider which then does the necessary work required to appropriately refresh the palette based on the pictogram element selected.
If anyone has further questions about my implementation, feel free to ask.
[Updated on: Wed, 26 March 2014 10:04] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.02938 seconds