[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.tools.emf] Re: Adding elements to model

Ed Merks wrote:

I imagine you have Puzzel.getBox/setBox or Puzzel.getBoxes() which returns a list. If it's the later, you'd do puzzel.getBoxes().add(b1).


ingelin wrote:
I am new to EMF and working on a Sudoku thing using EMF (ecore) and TEF.
In my model, a Puzzle contains Field (types are Row, Column and Box).

I need to add elements to the model programatically by overriding the check method. The model alreay contains 9 rows, this is handled in the textual editor created in TEF. I need to create 9 boxes and 9 columns.

@Override
public String check(IModelElement modelElement, SemanticsContext context) { //own code
Puzzle puzzle = (Puzzle)((EMFModelElement)modelElement).getEMFObject();


    NewstructureFactory factory = NewstructureFactory.eINSTANCE;

    Box b1 = factory.createBox();     }

How can I add this box to puzzle?



I now have puzzle.getElements.add(b1) and so on, but i get an error message when I try to run it and opening my textual editor:

Error opening the editor.
newstructure.Puzzle.getElements()Lorg/eclipse/emf/common/util/EList;

Maybe it is a TEF problem?