public void addChild( Command childCommand, Style childStyle ) { boolean inserted = false; CommandItem child = new CommandItem( childCommand, this, childStyle ); if ( this.children == null ) { int layer = getLayer(); if (layer == 0) {  this.children = new Container( true ); } else if (layer == 1) {  this.children = new Container( true ); } else if (layer == 2) {  this.children = new Container( true ); } if (this.children == null) { this.children = new Container( true, this.parent.style ); } else if (this.children.style == null) { this.children.style = this.parent.style; } this.hasChildren = true; this.children.parent = this; } else { int priority = childCommand.getPriority(); for (int i = 0; i < this.children.size(); i++) { CommandItem item = (CommandItem) this.children.get(i); if (item.command.getPriority() > priority ) { this.children.add( i, child ); inserted = true; break; } } } if (!inserted) { this.children.add( child ); }
public void addChild( Command childCommand ) { addChild( childCommand, null );
	public void addChild( Command childCommand, Style childStyle ) {		boolean inserted = false;		CommandItem child = new CommandItem( childCommand, this, childStyle );		if ( this.children == null ) {			int layer = getLayer();			if (layer == 0) {				//#style menu1?				this.children = new Container( true );			} else if (layer == 1) {				//#style menu2?				this.children = new Container( true );			} else if (layer == 2) {				//#style menu3?				this.children = new Container( true );			}			if (this.children == null) {				this.children = new Container( true, this.parent.style );			} else if (this.children.style == null) {				this.children.style = this.parent.style;			}			this.hasChildren = true;			this.children.parent = this;		} else {			int priority = childCommand.getPriority();			for (int i = 0; i < this.children.size(); i++) {				CommandItem item = (CommandItem) this.children.get(i);				if (item.command.getPriority() > priority ) {					this.children.add( i, child );					inserted = true;					break;				}			}		}		if (!inserted) {			this.children.add( child );		}	}