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 #616986] Wed, 12 March 2008 08:20
Eclipse User
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:How to create new control object on context menu.
Next Topic:My tip for how to improve RCP
Goto Forum:
  


Current Time: Tue Sep 23 20:24:00 GMT 2014

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

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