Node factories

If I have Concept with Child. Child has ordinal number. Concrete syntax is like this:
1.message 1
2.message 2
3.message 3

I want to implement in my language that ordinal number (step) is set automatically. It is not problem if I put new message at the end. I use node factories for this purpose, calculate the number of messages and increase for 1.

But, I have some problem if I put new message somewhere between 1 and 3 message.

node factories insertNewMessage         
node concept: Messages
   description : <none>           
   set-up : (sampleNode, newNode, model, enclosingNode)->void {

  node<Step> ss = new node<Step>();  

  node<Message> aa;   
  aa = (node<Message>) newNode;
  if (aa.isInstanceOf(Messages)) {
    // increase step
    newNode.step = ss;
  } else {


  //update all messages number
  node<RootConcept> ms = (node<RootConcept>) enclosingNode;

Updates work when I insert next message.

How can I get information where I want to insert new message, what is the message before? or
how to update message steps.
Comment actions Permalink
I don't know how to update node Step as you want, however if that number is automatically generate you could  display the node.index of your Message, number that it owns because it's inside a list (I suppose).

Into the Concept Editor of Message add a new cell where you prefere, and select read only model access, then specify String.valueOf(node.index); into the Value function that you find into the Inspection editor.
Comment actions Permalink
Marco's pointing you in the correct direction, I think.
node.index will give you the order number of a node in a collection.
Additionally, previous/next-sibling may help you touch the immediate neighbours of your node.


Please sign in to leave a comment.