|
|
|
|
|
Re: Performing custom operation after loading the diagram [message #639891 is a reply to message #638766] |
Thu, 18 November 2010 10:00 |
Michael Wenz Messages: 1931 Registered: July 2009 Location: Walldorf, Germany |
Senior Member |
|
|
Hi Vincent,
Graphiti initializes the FigureCanvas only when it really starts drawing the
diagram, so you cannot rely on the Canvas being initialized in any feature
or any hook from the editor. Modifying pictogram model data is possible of
course (including properties at these model objects), which I understood as
your usecase.
If you want to access the canvas you might have a look at the so-called
PlatformGraphicsAlgorithms that can be used to provide custom shapes that
are drawn using standard GEF means.
Michael
"Vincent L." <lapointe_vincent_1975@hotmail.com> wrote in message
news:ibjhe9$ai6$1@news.eclipse.org...
>
> Hi Michael,
>
> I tryed your two suggestions but it seems that that my code is called to
> early in the initialisation process. Here is my explanation:
>
> 1- Using isAutoUpdateAtStartup = true
>
> In this case my update feature is called correctly but when I get the
> canvas reference it seems that it doesn't exist yet.
>
> public class MyUpdateFeature extends AbstractUpdateFeature {
> ...
> public boolean update(IUpdateContext context) {
> ...
> DiagramEditor de = (DiagramEditor) getDiagramEditor();
> FigureCanvas canvas = de.getFigureCanvas();
>
> // !!! canvas is null in the update at startup !!!
>
> 2- Using a custom feature in the initialization of the DiagramTypeProvider
>
> In this case I have a similar problem. When my feature is executed, the
> canvas doesn't exist yet.
>
> public class DiagramTypeProvider extends AbstractDiagramTypeProvider {
> ...
> public void init(Diagram diagram, IDiagramEditor diagramEditor) {
>
> super.init(diagram, diagramEditor);
> callMyCustomFeature(); //call my custom feature
> }
> ...
>
> public class UpdateSWTCompositeFeature extends AbstractCustomFeature {
> ...
> public void execute(ICustomContext context) {
> ...
> DiagramEditor de = (DiagramEditor) getDiagramEditor();
> FigureCanvas canvas = de.getFigureCanvas();
>
> // !!! canvas is null in the update at startup !!!
>
>
> What could I do? Is there any way to force canvas initialisation? Is there
> another 'hook' I could use to modify the canvas after the diagram was
> loaded ?
>
> Thanks
>
> Regards,
>
> Vincent
|
|
|
|
Powered by
FUDForum. Page generated in 0.04212 seconds