How to invoke direct editing programatically? [message #668137] |
Tue, 03 May 2011 19:06  |
Eclipse User |
|
|
|
In the EClass tutorial sample's TutorialAddEClassFeature, there were some comments about setting up direct-editing info. If I want to invoke the direct-editing feature right after I add an EClass to the diagram, what should I do?
Thanks!
Shenxue
|
|
|
|
|
|
Re: How to invoke direct editing programatically? [message #730859 is a reply to message #668569] |
Thu, 29 September 2011 07:58   |
Eclipse User |
|
|
|
Hi,
i just ran into this error in the tutorial too. // SHAPE WITH TEXT
{
// create shape for text
Shape shape = peCreateService.createShape(containerShape, false);
// create and set text graphics algorithm
Text text = gaService.createDefaultText(getDiagram(), shape, addedClass.getName());
text.setForeground(manageColor(CLASS_TEXT_FOREGROUND));
text.setHorizontalAlignment(Orientation.ALIGNMENT_CENTER);
text.setVerticalAlignment(Orientation.ALIGNMENT_CENTER);
text.getFont().setBold(true);
gaService.setLocationAndSize(text, 0, 0, width, 20);
// create link and wire it
link(shape, addedClass);
// provide information to support direct-editing directly
// after object creation (must be activated additionally)
IDirectEditingInfo directEditingInfo =
getFeatureProvider().getDirectEditingInfo();
// activate direct editing after object creation
getFeatureProvider().getDirectEditingInfo().setActive(true);
// set container shape for direct editing after object creation
directEditingInfo.setMainPictogramElement(containerShape);
// set shape and graphics algorithm where the editor for
// direct editing shall be opened after object creation
directEditingInfo.setPictogramElement(shape);
directEditingInfo.setGraphicsAlgorithm(text);
This way it works fine. You can another mistake in the corresponding code from the tutorial:
Quote: text.setHorizontalAlignment(OrientationEnum.ALIGNMENT_CENTER);
text.setVerticalAlignment(OrientationEnum.ALIGNMENT_CENTER);
should be:
Quote: text.setHorizontalAlignment(Orientation.ALIGNMENT_CENTER);
text.setVerticalAlignment(Orientation.ALIGNMENT_CENTER);
I use Ubuntu 11.04 with gnome.
|
|
|
|
Powered by
FUDForum. Page generated in 0.07565 seconds