/** * Calls the method {@link DockUI#updateTheme(DockStation, DockFactory)} * with <code>this</code> as the first argument, and an appropriate factory * as the second argument. * @throws IOException if the DockUI throws an exception */ protected void callDockUiUpdateTheme() throws IOException{ DockUI.updateTheme(this, new SplitDockStationFactory()); }
public SplitDockStation layout( SplitDockStationLayout layout, PlaceholderStrategy placeholders ) { SplitDockStation station = createStation( layout.hasFullscreenAction() ); setLayout( station, layout, placeholders ); return station; }
public SplitDockStationLayout getPerspectiveLayout( SplitDockPerspective element, Map<PerspectiveDockable, Integer> children ){ if( children == null ){ return createLayout( null, -1, element.hasFullscreenAction() ); } Entry root = convert( element.getRoot(), children ); PerspectiveDockable fullscreenDockable = element.getFullscreen(); Integer fullscreen = null; if( fullscreenDockable != null ) fullscreen = children.get( fullscreenDockable ); if( fullscreen == null ) return createLayout( element, root, -1, element.hasFullscreenAction() ); else return createLayout( element, root, fullscreen, element.hasFullscreenAction() ); }
/** * Transforms an entry of a {@link SplitDockStationLayout} into a key * of a {@link SplitDockTree}. * @param entry the element to transform * @param tree the tree into which to add new keys * @param children the set of known children * @return the key or <code>null</code> */ private <D> SplitDockTree<D>.Key handleEntry( SplitDockStationLayout.Entry entry, SplitDockTree<D> tree, Map<Integer, D> children ){ if( entry.asLeaf() != null ) return handleLeaf( entry.asLeaf(), tree, children ); else return handleNode( entry.asNode(), tree, children ); }
public SplitDockStationLayout read( DataInputStream in, PlaceholderStrategy placeholders ) throws IOException { Version version = Version.read( in ); version.checkCurrent(); boolean version8 = Version.VERSION_1_0_8.compareTo( version ) <= 0; boolean version8a = Version.VERSION_1_0_8a.compareTo( version ) <= 0; boolean version110 = Version.VERSION_1_1_0.compareTo( version ) <= 0; SplitDockStationLayout.Entry root = null; if( in.readBoolean() ){ root = readEntry( in, version8, version8a, placeholders ); } int fullscreen = in.readInt(); boolean fullscreenAction = true; if( version110 ){ fullscreenAction = in.readBoolean(); } return createLayout( root, fullscreen, fullscreenAction ); }
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 ); } }
public void setLayout( SplitDockStation station, SplitDockStationLayout splitLayout, Map<Integer,Dockable> children, PlaceholderStrategy placeholders ){ super.setLayout( station, splitLayout, children, placeholders ); WizardSplitDockStation wizard = (WizardSplitDockStation)station; WizardSplitDockStationLayout layout = (WizardSplitDockStationLayout)splitLayout; Column[] columns = layout.getColumns(); Dockable[][] columnsAndCells = new Dockable[ columns.length ][]; int[][] cellSizes = new int[ columnsAndCells.length ][]; int[] columnSizes = new int[ columnsAndCells.length ]; for( int i = 0; i < columns.length; i++ ){ columnsAndCells[i] = new Dockable[ columns[i].getCellKeys().length ]; cellSizes[i] = new int[ columnsAndCells[i].length ]; columnSizes[i] = columns[i].getSize(); for( int j = 0; j < cellSizes[i].length; j++ ){ columnsAndCells[i][j] = children.get( columns[i].getCellKeys()[j] ); cellSizes[i][j] = columns[i].getCellSizes()[j]; } } wizard.setPersistentColumns( columnsAndCells, cellSizes, columnSizes ); }
/** * Creates a new layout for <code>station</code>. The default implementation just calls {@link #createLayout(SplitDockStationLayout.Entry, int, boolean)}. * @param station the station for which the layout is requested * @param root the contents of the layout * @param fullscreen the index of the child that is maximized * @param hasFullscreenAction whether a fullscreen action is shown or not * @return the new layout */ protected SplitDockStationLayout createLayout( SplitDockStation station, Entry root, int fullscreen, boolean hasFullscreenAction ){ return createLayout( root, fullscreen, hasFullscreenAction ); }
public void layoutPerspective( SplitDockPerspective perspective, SplitDockStationLayout layout, Map<Integer,PerspectiveDockable> children ){ if( children != null ){ PerspectiveSplitDockTree tree = new PerspectiveSplitDockTree(); PerspectiveSplitDockTree.Key root = null; if( layout.getRoot() != null ){ root = handleEntry( layout.getRoot(), tree, children ); } if( root != null ){ tree.root( root ); } perspective.read( tree, children.get( layout.getFullscreen() ) ); } perspective.setHasFullscreenAction( layout.hasFullscreenAction() ); }
public void estimateLocations( SplitDockStationLayout layout, LocationEstimationMap children ) { estimateLocations( layout.getRoot(), children ); }
@Override public SplitDockStationLayout getLayout( SplitDockStation station, Map<Dockable, Integer> children ){ WizardSplitDockStation wizard = (WizardSplitDockStation)station; WizardSplitDockStationLayout layout = (WizardSplitDockStationLayout)super.getLayout( station, children ); PersistentColumn[] persistentColumns = wizard.getPersistentColumns(); Column[] columns = new Column[ persistentColumns.length ]; for( int i = 0; i < persistentColumns.length; i++ ){ int size = persistentColumns[i].getSize(); Map<Dockable, PersistentCell> cells = persistentColumns[i].getCells(); int[] keys = new int[ cells.size() ]; int[] sizes = new int[ cells.size() ]; int index = 0; for( Map.Entry<Dockable, PersistentCell> entry : cells.entrySet() ){ keys[ index ] = children.get( entry.getKey() ); sizes[ index ] = entry.getValue().getSize(); index++; } columns[i] = new Column( size, keys, sizes ); } layout.setColumns( columns ); return layout; }
public SplitDockStationLayout read( XElement element, PlaceholderStrategy placeholders ) { SplitDockStationLayout.Entry root = null; XElement xroot = element.getElement( "node" ); if( xroot == null ) xroot = element.getElement( "leaf" ); if( xroot != null ) root = readEntry( xroot, placeholders ); int fullscreen = -1; XElement xfullscreen = element.getElement( "fullscreen" ); if( xfullscreen != null ) fullscreen = xfullscreen.getInt( "id" ); XElement xfullscreenAction = element.getElement( "fullscreen-action" ); boolean fullscreenAction = true; if( xfullscreenAction != null ){ fullscreenAction = xfullscreenAction.getBoolean(); } return createLayout( root, fullscreen, fullscreenAction ); }
/** * Creates a new layout for <code>station</code>. The default implementation just calls {@link #createLayout(SplitDockStationLayout.Entry, int, boolean)}. * @param station the station for which the layout is requested * @param root the contents of the layout * @param fullscreen the index of the child that is maximized * @param hasFullscreenAction whether a fullscreen action is shown or not * @return the new layout */ protected SplitDockStationLayout createLayout( SplitDockPerspective station, Entry root, int fullscreen, boolean hasFullscreenAction ){ return createLayout( root, fullscreen, hasFullscreenAction ); }
/** * Transforms a node of a {@link SplitDockStationLayout} into a key * of a {@link SplitDockTree}. * @param node the element to transform * @param tree the tree into which to add new keys * @param children the set of known children * @return the key or <code>null</code> */ private <D> SplitDockTree<D>.Key handleNode( SplitDockStationLayout.Node node, SplitDockTree<D> tree,Map<Integer, D> children ){ SplitDockTree<D>.Key a = handleEntry( node.getChildA(), tree, children ); SplitDockTree<D>.Key b = handleEntry( node.getChildB(), tree, children ); if( a == null ) return b; if( b == null ) return a; switch( node.getOrientation() ){ case HORIZONTAL: return tree.horizontal( a, b, node.getDivider(), node.getPlaceholders(), node.getPlaceholderMap(), node.getNodeId() ); case VERTICAL: return tree.vertical( a, b, node.getDivider(), node.getPlaceholders(), node.getPlaceholderMap(), node.getNodeId() ); } return null; }
estimateLocations( node.getChildA(), children ); estimateLocations( node.getChildB(), children );
public SplitDockStation layout( SplitDockStationLayout layout, Map<Integer, Dockable> children, PlaceholderStrategy placeholders ) { SplitDockStation station = createStation( layout.hasFullscreenAction() ); setLayout( station, layout, children, placeholders ); return station; }
/** * Calls the method {@link DockUI#updateTheme(DockStation, DockFactory)} * with <code>this</code> as the first argument, and an appropriate factory * as the second argument. * @throws IOException if the DockUI throws an exception */ protected void callDockUiUpdateTheme() throws IOException{ DockUI.updateTheme(this, new SplitDockStationFactory()); }
return createLayout( station, root, -1, station.hasFullScreenAction() ); else return createLayout( station, root, fullscreen, station.hasFullScreenAction() );
public void setLayout( SplitDockStation station, SplitDockStationLayout layout, Map<Integer, Dockable> children, PlaceholderStrategy placeholders ) { DockableSplitDockTree tree = new DockableSplitDockTree(); DockableSplitDockTree.Key root = null; if( layout.getRoot() != null ){ root = handleEntry( layout.getRoot(), tree, children ); } if( root != null ){ tree.root( root ); } station.dropTree( tree, false ); PlaceholderStrategy oldStrategy = station.getPlaceholderStrategy().getStrategy(); if( placeholders != oldStrategy && placeholders != null ){ try{ station.setPlaceholderStrategy( placeholders ); } finally{ station.setPlaceholderStrategy( oldStrategy ); } } Dockable fullscreen = children.get( layout.getFullscreen() ); station.setFullScreen( fullscreen ); }
/** * Constructs a new DockSituation. Factories for {@link DefaultDockable}, * {@link SplitDockStation}, {@link StackDockStation} and * {@link FlapDockStation} will be preinstalled. * @param controller {@link DockController} in whose realm this {@link DockSituation} will be used, the * controller is used to access the {@link ExtensionManager} and load additional factories */ public DockSituation( DockController controller ){ this( new DefaultDockableFactory(), new SplitDockStationFactory(), new StackDockStationFactory(), new FlapDockStationFactory()); @SuppressWarnings("rawtypes") List<DockFactory> factories = controller.getExtensions().load( new ExtensionName<DockFactory>( DOCK_FACTORY_EXTENSION, DockFactory.class, EXTENSION_PARAM, this ) ); for( DockFactory<?,?,?> factory : factories ){ add( factory ); } @SuppressWarnings("rawtypes") List<AdjacentDockFactory> adjacent = controller.getExtensions().load( new ExtensionName<AdjacentDockFactory>( ADJACENT_DOCK_FACTORY_EXTENSION, AdjacentDockFactory.class, EXTENSION_PARAM, this ) ); for( AdjacentDockFactory<?> factory : adjacent ){ addAdjacent( factory ); } }