this.hierarchy=hierarchy;
this.dataFactory = dataFactory;
}
public void addBefore(LinkedList siblings,Node newNode,int actionType){
Node previous,next,parent;
boolean firstChild;
if (siblings.size()==0){
return;
}else if (siblings.size()==1){
previous=null;
next=(Node)siblings.removeLast();
parent=null;
firstChild=true;
}else{
previous=(Node)siblings.removeFirst(); //no need to clone, list used only here, see CommonSpreadSheetModel
next=(Node)siblings.removeLast();
parent=(Node)next.getParent();
firstChild=(parent==previous);
if (firstChild) parent=previous;
else parent=(Node)previous.getParent();
remove(siblings, NodeModel.SILENT);
}
siblings.add(newNode);
add(parent,siblings,(firstChild)?0:(parent.getIndex(previous)+1),NodeModel.SILENT);