if( childB.asLeaf() == null && childB.asNode() == null ){ throw new IllegalArgumentException( "child must either be a leaf or a node" ); this.childB.setParent( null ); if( perspective != null ){ perspective.fireRemoved( this, this.childB ); this.childB.setParent( this ); if( perspective != null ){ perspective.fireAdded( this, this.childB );
/** * Adds a placeholder to <code>destination</code> and makes sure at the same time that * <code>placeholder</code> is not used by any other node. * @param destination a child of this perspective * @param placeholder the placeholder to insert */ public void addPlaceholder( Entry destination, Path placeholder ){ if( !destination.isAnchestor( getRoot() ) ){ throw new IllegalArgumentException( "destination is not child of this perspective" ); } clearPlaceholder( placeholder, destination ); destination.getPlaceholders().add( placeholder ); }
Entry parent = getParent(); if( parent == null ){ return;
Entry parent = getParent(); if( parent == null ){ return;
if( childB.asLeaf() == null && childB.asNode() == null ){ throw new IllegalArgumentException( "child must either be a leaf or a node" ); this.childB.setParent( null ); if( perspective != null ){ perspective.fireRemoved( this, this.childB ); this.childB.setParent( this ); if( perspective != null ){ perspective.fireAdded( this, this.childB );
if( childA.asLeaf() == null && childA.asNode() == null ){ throw new IllegalArgumentException( "child must either be a leaf or a node" ); this.childA.setParent( null ); if( perspective != null ){ perspective.fireRemoved( this, this.childA ); this.childA.setParent( this ); if( perspective != null ){ perspective.fireAdded( this, this.childA );
if( childA.asLeaf() == null && childA.asNode() == null ){ throw new IllegalArgumentException( "child must either be a leaf or a node" ); this.childA.setParent( null ); if( perspective != null ){ perspective.fireRemoved( this, this.childA ); this.childA.setParent( this ); if( perspective != null ){ perspective.fireAdded( this, this.childA );
private Entry convert( SplitDockPerspective.Entry entry, Map<PerspectiveDockable, Integer> children ){ if( entry == null ){ return null; } if( entry.asNode() != null ){ SplitDockPerspective.Node node = entry.asNode(); Entry childA = convert( node.getChildA(), children ); Entry childB = convert( node.getChildB(), children ); if( childA == null ){ return childB; } if( childB == null ){ return childA; } return new SplitDockStationLayout.Node( node.getOrientation(), node.getDivider(), childA, childB, toArray( node.getPlaceholders() ), node.getPlaceholderMap(), node.getNodeId() ); } else if( entry.asLeaf() != null ){ SplitDockPerspective.Leaf leaf = entry.asLeaf(); Integer id = children.get( leaf.getDockable() ); return new SplitDockStationLayout.Leaf( id == null ? -1 : id.intValue(), toArray( leaf.getPlaceholders() ), leaf.getPlaceholderMap(), leaf.getNodeId() ); } else{ return convert( ((Root)entry).getChild(), children ); } }
/** * Replaces <code>this</code> with <code>next</code>. * @param next the element which replaces this */ public void replace( Entry next ){ Entry parent = getParent(); if( parent == null ){ return; } if( parent instanceof Root ){ ((Root)parent).setChild( next ); } else{ Node parentNode = (Node)parent; if( parentNode.getChildA() == this ){ parentNode.setChildA( next ); } else{ parentNode.setChildB( next ); } } }
private void handle( Entry entry, double x, double y, double width, double height ){ if( entry != null ){ if( entry.asLeaf() != null ) { PerspectiveDockable dockable = entry.asLeaf().getDockable(); if( dockable != null ) { grid.addDockable( x, y, width, height, dockable ); } } else{ Node node = entry.asNode(); double divider = node.getDivider(); if( node.getOrientation() == Orientation.HORIZONTAL ){ handle( node.getChildA(), x, y, width*divider, height ); handle( node.getChildB(), x+width*divider, y, width*(1-divider), height ); } else{ handle( node.getChildA(), x, y, width, height*divider ); handle( node.getChildB(), x, y+height*divider, width, height*(1-divider) ); } } } }
private void handle( Entry entry, double x, double y, double width, double height ){ if( entry != null ){ if( entry.asLeaf() != null ) { PerspectiveDockable dockable = entry.asLeaf().getDockable(); if( dockable != null ) { grid.addDockable( x, y, width, height, dockable ); } } else{ Node node = entry.asNode(); double divider = node.getDivider(); if( node.getOrientation() == Orientation.HORIZONTAL ){ handle( node.getChildA(), x, y, width*divider, height ); handle( node.getChildB(), x+width*divider, y, width*(1-divider), height ); } else{ handle( node.getChildA(), x, y, width, height*divider ); handle( node.getChildB(), x, y+height*divider, width, height*(1-divider) ); } } } }
/** * Sets the child of this root. * @param child the child, can be <code>null</code> */ public void setChild( Entry child ){ if( child != null ){ if( child.asLeaf() == null && child.asNode() == null ){ throw new IllegalArgumentException( "child must either be a leaf or a node" ); } } if( this.child != null ){ this.child.setParent( null ); fireRemoved( this, this.child ); } this.child = child; if( this.child != null ){ this.child.setParent( this ); fireAdded( this, this.child ); } } }
/** * Sets the child of this root. * @param child the child, can be <code>null</code> */ public void setChild( Entry child ){ if( child != null ){ if( child.asLeaf() == null && child.asNode() == null ){ throw new IllegalArgumentException( "child must either be a leaf or a node" ); } } if( this.child != null ){ this.child.setParent( null ); fireRemoved( this, this.child ); } this.child = child; if( this.child != null ){ this.child.setParent( this ); fireAdded( this, this.child ); } } }
/** * Replaces <code>this</code> with <code>next</code>. * @param next the element which replaces this */ public void replace( Entry next ){ Entry parent = getParent(); if( parent == null ){ return; } if( parent instanceof Root ){ ((Root)parent).setChild( next ); } else{ Node parentNode = (Node)parent; if( parentNode.getChildA() == this ){ parentNode.setChildA( next ); } else{ parentNode.setChildB( next ); } } }
/** * Tells whether <code>anchestor</code> is an anchestor of this entry. * @param anchestor the item to search * @return <code>true</code> if <code>anchestor</code> is <code>this</code> or a * parent of <code>this</code> */ public boolean isAnchestor( Entry anchestor ){ Entry current = this; while( current != null ){ if( current == anchestor ){ return true; } current = current.getParent(); } return false; }
private void remove( Entry child ){ if( child != null ){ if( child.asLeaf() != null ){ PerspectiveDockable dockable = child.asLeaf().getDockable(); if( dockable != null ){ children.remove( dockable ); dockable.setParent( null ); } } else{ remove( child.asNode().getChildA() ); remove( child.asNode().getChildB() ); } } } });
private Leaf find( Entry start, PerspectiveDockable child ){ if( start == null ){ return null; } if( start.asLeaf() != null ){ if( start.asLeaf().getDockable() == child ){ return start.asLeaf(); } return null; } Leaf result = find( start.asNode().getChildA(), child ); if( result == null ){ result = find( start.asNode().getChildB(), child ); } return result; }
private void add( Entry child ){ if( child != null ){ if( child.asLeaf() != null ){ PerspectiveDockable dockable = child.asLeaf().getDockable(); if( dockable != null ){ DockUtilities.ensureTreeValidity( SplitDockPerspective.this, dockable ); dockable.setParent( SplitDockPerspective.this ); children.add( dockable ); } } else{ add( child.asNode().getChildA() ); add( child.asNode().getChildB() ); } } }