return new Leaf( dockable, toSet( tree.getPlaceholders( key ) ), tree.getPlaceholderMap( key ), key.getNodeId() );
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 ); } }
SplitDockPerspective perspective = getPerspective(); if( perspective == null ){ throw new IllegalStateException( "this method can only be applied to leafs that have a root as anchestor" ); setPlaceholderMap( placeholders ); if( placeholders != null ){ for( PlaceholderMap.Key key : placeholders.getPlaceholders() ){ setDockable( null ); if( getPlaceholderMap() == null && getPlaceholders().isEmpty() ){ delete();
SplitDockPerspective.Leaf leaf = new SplitDockPerspective.Leaf( dockable, null, null, -1 );
SplitDockPerspective.Leaf leaf = new SplitDockPerspective.Leaf( dockable, null, null, -1 );
return new Leaf( dockable, toSet( tree.getPlaceholders( key ) ), tree.getPlaceholderMap( key ), key.getNodeId() );
SplitDockPerspective perspective = getPerspective(); if( perspective == null ){ throw new IllegalStateException( "this method can only be applied to leafs that have a root as anchestor" ); setPlaceholderMap( placeholders ); if( placeholders != null ){ for( PlaceholderMap.Key key : placeholders.getPlaceholders() ){ setDockable( null ); if( getPlaceholderMap() == null && getPlaceholders().isEmpty() ){ delete();
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) ); } } } }
/** * Exchanges the element that is represented by this perspective. This operation does not change any * placeholders. * @param dockable the new element, can be <code>null</code> */ public void setDockable( PerspectiveDockable dockable ){ SplitDockPerspective perspective = getPerspective(); if( perspective == null ){ this.dockable = dockable; } else{ PerspectiveDockable oldDockable = this.dockable; this.dockable = dockable; for( EntryListener listener : perspective.listeners() ){ listener.modified( this, oldDockable, dockable ); } } }
/** * Exchanges the element that is represented by this perspective. This operation does not change any * placeholders. * @param dockable the new element, can be <code>null</code> */ public void setDockable( PerspectiveDockable dockable ){ SplitDockPerspective perspective = getPerspective(); if( perspective == null ){ this.dockable = dockable; } else{ PerspectiveDockable oldDockable = this.dockable; this.dockable = dockable; for( EntryListener listener : perspective.listeners() ){ listener.modified( this, oldDockable, dockable ); } } }
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; }
public void replace( PerspectiveDockable oldDockable, PerspectiveDockable newDockable ){ Leaf leaf = getLeaf( oldDockable ); if( leaf == null ){ throw new IllegalArgumentException( "oldDockable not child of this station" ); } DockUtilities.ensureTreeValidity( this, newDockable ); PlaceholderMap map = leaf.getPlaceholderMap(); if( oldDockable.asStation() != null ){ map = oldDockable.asStation().getPlaceholders(); } Leaf copy = new Leaf( newDockable, leaf.getPlaceholders(), map, leaf.getNodeId() ); leaf.replace( copy ); Path placeholder = oldDockable.getPlaceholder(); if( placeholder != null ){ addPlaceholder( copy, placeholder ); } }
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() ); } } }
private void remove( Entry child ){ if( child != null ){ if( child.asNode() != null ){ remove( child.asNode().getChildA() ); remove( child.asNode().getChildB() ); } else{ PerspectiveDockable dockable = child.asLeaf().getDockable(); if( dockable != null ){ remove( dockable ); } } } }