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 ); } }
/** * Reads the contents of <code>tree</code> and replaces any content of this perspective * @param tree the tree that represents this perspective * @param fullscreen the one child that is currently in fullscreen-mode, can be <code>null</code> */ public void read( PerspectiveSplitDockTree tree, PerspectiveDockable fullscreen ){ root.setChild( convert( tree.getRoot() ) ); if( fullscreen != null && !children.contains( fullscreen )){ throw new IllegalArgumentException( "fullscreen is not a child of this station" ); } this.fullscreen = fullscreen; }
/** * 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 ); } } }
/** * 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 ); } } }
@Override protected Entry getRootChild( Entry root ){ return ((SplitDockPerspective.Root)root).getChild(); }
/** * Makes sure that <code>placeholder</code> is not found anywhere * @param placeholder the element to remove * @param exception the entry that should not be modified */ private void clearPlaceholder( Path placeholder, Entry exception ){ clearPlaceholder( getRoot().getChild(), placeholder, exception ); }
/** * Searches and returns the leaf that shows <code>child</code>. * @param child some child of this station * @return the leaf showing <code>child</code> or <code>null</code> if not found */ public Leaf getLeaf( PerspectiveDockable child ){ return find( getRoot().getChild(), child ); }
@Override protected Entry getRootChild( Entry root ){ return ((SplitDockPerspective.Root)root).getChild(); }
/** * Reads the contents of the {@link #getRoot() root} and resets the {@link #grid() grid} to reflect that * root. This method is called once during construction of this perspective, it can later be called * to reset the perspective. */ public void gridPrepare(){ gridChanges = false; gridClear(); handle( delegate().getRoot().getChild(), 0, 0, 100, 100 ); }
/** * Reads the contents of the {@link #getRoot() root} and resets the {@link #grid() grid} to reflect that * root. This method is called once during construction of this perspective, it can later be called * to reset the perspective. */ public void gridPrepare(){ gridChanges = false; gridClear(); handle( delegate().getRoot().getChild(), 0, 0, 100, 100 ); }
/** * Searches and returns the leaf that shows <code>child</code>. * @param child some child of this station * @return the leaf showing <code>child</code> or <code>null</code> if not found */ public Leaf getLeaf( PerspectiveDockable child ){ return find( getRoot().getChild(), child ); }
/** * Reads the contents of <code>tree</code> and replaces any content of this perspective * @param tree the tree that represents this perspective * @param fullscreen the one child that is currently in fullscreen-mode, can be <code>null</code> */ public void read( PerspectiveSplitDockTree tree, PerspectiveDockable fullscreen ){ root.setChild( convert( tree.getRoot() ) ); if( fullscreen != null && !children.contains( fullscreen )){ throw new IllegalArgumentException( "fullscreen is not a child of this station" ); } this.fullscreen = fullscreen; }
/** * Makes sure that <code>placeholder</code> is not found anywhere * @param placeholder the element to remove * @param exception the entry that should not be modified */ private void clearPlaceholder( Path placeholder, Entry exception ){ clearPlaceholder( getRoot().getChild(), placeholder, exception ); }