@Override public IAddFeature getAddFeature(IAddContext context) { if (context instanceof IAddConnectionContext) { return new AddWrittenByFeature(this); } else if (context.getNewObject() instanceof Author){ return new AddAuthorFeature(this); } else if (context.getNewObject() instanceof Book){ return new AddBookFeature(this); } // TODO Auto-generated method stub return super.getAddFeature(context); }
public Object[] create(ICreateContext context) { String newAuthorName = ExampleUtil.askString("Insert author name", "Provide a name for the new author", "NewAuthor"); Author author = GraphitilibraryFactory.eINSTANCE.createAuthor(); // Add model element to resource. // We add the model element to the resource of the diagram for // simplicity's sake. Normally, a customer would use its own // model persistence layer for storing the business model separately. getDiagram().eResource().getContents().add(author); author.setName(newAuthorName); addGraphicalRepresentation(context, author); return new Object[] { author }; }