Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Visual Editor (VE) » How to create new control object on context menu.
How to create new control object on context menu. [message #143996] Wed, 12 March 2008 08:20
Eclipse UserFriend
Originally posted by: bran.mm.xxxxx.xx.xx

Hi all.
I'm trying to create new awt.Button object on context menu.
I've added the "add Button" to the menu.(I refered other contribution)

And,I made MyAddButtonActionDelegate(based IObjectActionDelegate).
but, I can't create new awt.Button object.
A cause is CommandInstance was UnExecutableCommand...
I read "Extending The Visual Editor", but deeper info was not there.
Please give me some advice.

This is my code.( MyAddButtonActionDelegate#run())
--
EditPart targetEp = (EditPart)selectedEditParts.get( 0 );
JavaObjectInstance targetObj = (JavaObjectInstance)targetEp.getModel();

Rectangle rect = new Rectangle(0,0,30,30);

CreateRequest cReq = new CreateRequest();
EClass eBtnCls = EcoreFactory.eINSTANCE.createEClass();

eBtnCls.setInstanceClass(Button.class);
eBtnCls.setAbstract(false);
eBtnCls.setInterfase(false);
eBtnCls.setName("sampleBtn");

CreationFactory cFct = new EMFCreationFactory( eBtnCls );
cReq.setFactory(cFct);
cReq.setLocation(rect.getLocation());
cReq.setSize(rect.getSize());

Command cmd = targetEp.getCommand(cReq); // UnexecutableCommand...
EditDomain ed = targetEp.getViewer().getEditDomain();
ed.getCommandStack().execute(cmd);
Previous Topic:My vision for SWT editors
Next Topic:How to create new control object on context menu.
Goto Forum:
  


Current Time: Fri Apr 19 05:32:54 GMT 2024

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

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

Back to the top