Creating a fixed node on new diagram start up [message #114184] |
Sun, 25 March 2007 18:49  |
Eclipse User |
|
|
|
Originally posted by: evaandoli.dodo.com.au
Hi,
I'd like to create a node in the top left corner when a diagram is created.
Its a singleton (no creating more than one) and has to exists so no deleting
either.
Any clues on where to start to do this.
Thanks,
Stu
|
|
|
Re: Creating a fixed node on new diagram start up [message #114198 is a reply to message #114184] |
Mon, 26 March 2007 03:20  |
Eclipse User |
|
|
|
Stu schrieb:
> Hi,
> I'd like to create a node in the top left corner when a diagram is created.
> Its a singleton (no creating more than one) and has to exists so no deleting
> either.
>
> Any clues on where to start to do this.
>
> Thanks,
> Stu
>
>
Hi,
my solution for your problem in creating a new node:
search in the XXX.diagram.part package for the class XXXDiagramEditorUtil,
there you can find a method createInitialModel(). In this method you can
add the node to your Root of the diagram. This works fine for me.
Second problem with deleting: In your xxx.diagram.edit.parts search for
the editpart of your node. In method createDefaultEditPolicies() you
have to change editpolicy of CREATION_ROLE, if the command for delete is
requested you return UnexecutableCommand. Like this:
installEditPolicy(EditPolicyRoles.CREATION_ROLE,
new CreationEditPolicy() {
public Command getCommand(Request request) {
here---> if ((request instanceof GroupRequest)
&& (request.getType().equals("delete")))
---> return UnexecutableCommand.INSTANCE;
if (understandsRequest(request))
return super.getCommand(request);
return null;}
});
I think this will help you!
Bye,
Jens
|
|
|
Powered by
FUDForum. Page generated in 0.08102 seconds