Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » How to invoke direct editing programatically?
How to invoke direct editing programatically? [message #668137] Tue, 03 May 2011 23:06 Go to next message
Shenxue Zhou is currently offline Shenxue ZhouFriend
Messages: 60
Registered: July 2009
Member
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 #668198 is a reply to message #668137] Wed, 04 May 2011 13:18 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
Registered: July 2009
Location: Walldorf, Germany
Senior Member
This is done in the add method of the TutorialAddEClassFeature by providing the direct editing information:

// provide information to support direct-editing directly
// after object creation (must be activated additionally)
final IDirectEditingInfo directEditingInfo = getFeatureProvider().getDirectEditingInfo();
// 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);

HTH,
Michael
Re: How to invoke direct editing programatically? [message #668240 is a reply to message #668198] Wed, 04 May 2011 15:48 Go to previous messageGo to next message
Shenxue Zhou is currently offline Shenxue ZhouFriend
Messages: 60
Registered: July 2009
Member
I did notice that piece of code in TutorialAddEClassFeature class. I also noticed this line of code in TutorialCreateEClassFeature:

// activate direct editing after object creation
getFeatureProvider().getDirectEditingInfo().setActive(true);

But when I run the EClass tutorial, right after I drop an EClass object to the diagram canvas, I'm not able to type in the EClass name directly. I have to click on top section the EClass to activate the direct editing.

I forgot whether at one point the EClass tutorial did activate the direct editing feature right after the EClass object was dropped on the canvas. Is there some regression here or I'm missing something?

Thanks!

Shenxue
Re: How to invoke direct editing programatically? [message #668569 is a reply to message #668240] Fri, 06 May 2011 09:17 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Thanks, I missed that line while copying...

Strange, in our tests direct editing worked in the tutorial the way it
should. We're testing on windows machines, do you have any other OS?

Michael


"Shenxue Zhou" wrote in message news:iprs0r$1tp$1@news.eclipse.org...

I did notice that piece of code in TutorialAddEClassFeature class. I also
noticed this line of code in TutorialCreateEClassFeature:

// activate direct editing after object creation
getFeatureProvider().getDirectEditingInfo().setActive(true);

But when I run the EClass tutorial, right after I drop an EClass object to
the diagram canvas, I'm not able to type in the EClass name directly. I have
to click on top section the EClass to activate the direct editing.

I forgot whether at one point the EClass tutorial did activate the direct
editing feature right after the EClass object was dropped on the canvas. Is
there some regression here or I'm missing something?

Thanks!

Shenxue
Re: How to invoke direct editing programatically? [message #730859 is a reply to message #668569] Thu, 29 September 2011 11:58 Go to previous messageGo to next message
Michael  is currently offline Michael Friend
Messages: 1
Registered: September 2011
Junior Member
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.
Re: How to invoke direct editing programatically? [message #731171 is a reply to message #730859] Fri, 30 September 2011 07:43 Go to previous message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Thanks for pointing out! This has already been fixed in the docu.

Michael
Previous Topic:How to disable the remove?
Next Topic:Grahical editor refresh on underlying resource changed
Goto Forum:
  


Current Time: Thu Apr 25 17:16:58 GMT 2024

Powered by FUDForum. Page generated in 0.03685 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top