/** * Gets an array containing all the {@link ScreenDockWindow}s that are currently shown by the {@link #getStation() station}. * @return all the windows */ public ScreenDockWindow[] getWindows(){ int count = station.getDockableCount(); ScreenDockWindow[] windows = new ScreenDockWindow[ count ]; for( int i = 0; i < count; i++ ){ windows[i] = station.getWindow( i ); } return windows; }
public void drop( Dockable dockable ) { Window owner = getOwner(); int x = 30; int y = 30; if( owner != null ){ x += owner.getX(); y += owner.getY(); } Dimension preferred = dropSizeStrategy.getValue().getAddSize( this, dockable ); int width = Math.max( preferred.width, 100 ); int height = Math.max( preferred.height, 100 ); if( !drop( dockable, new ScreenDockProperty( x, y, width, height ) ) ){ addDockable( dockable, new Rectangle( x, y, width, height ) ); } }
public void checkWindowBounds() { Rectangle valid = getStation().getBoundaryRestriction().check( this ); if( valid != null ){ window.setBounds( valid ); } }
/** * Searches the {@link ScreenDockWindow} which displays the <code>dockable</code>. * @param dockable the {@link Dockable} to search * @return the window or <code>null</code> */ public ScreenDockWindow getWindow( Dockable dockable ){ int index = indexOf( dockable ); if( index < 0 ) return null; return getWindow( index ); }
public void install( ScreenDockStation station ){ boolean empty = dockables.isEmpty(); station.addDockStationListener( stationListener ); station.addScreenDockStationListener( screenListener ); dockables.put( station, station.getFullscreenChildren() ); if( empty ){ desktop.addComponentListener( componentListener ); } }
public void handleResizeRequest( CControl control ) { for( int i = 0, n = station.getDockableCount(); i<n; i++ ){ ScreenDockWindow window = station.getWindow( i ); RequestDimension size = getAndClearResizeRequest( station.getDockable( i ) ); if( size != null ){ Insets insets = window.getDockableInsets(); Rectangle bounds = window.getWindowBounds(); int width; if( size.isWidthSet() ) width = size.getWidth() + insets.left + insets.right; else width = bounds.width; int height; if( size.isHeightSet() ) height = size.getHeight() + insets.top + insets.bottom; else height = bounds.height; window.setWindowBounds( new Rectangle( bounds.x + (bounds.width - width)/2, bounds.y + (bounds.height - height)/2, width, height ) ); } } }
station.setFullscreen( dockable, true ); if( !station.drop( dockable, child ) ){ throw new IllegalStateException( "cannot drop dockable on this station" ); station.setFullscreen( dockable, true ); station.setFullscreen( dockable, false ); ScreenDockProperty location = station.getLocation( child, dockable ); if( !station.drop( dockable, location, true )){ throw new IllegalStateException( "could not drop dockable on this station" );
/** * Changes the fullscreen mode of <code>dockable</code>. * @param dockable the element whose mode is to be changed * @param fullscreen the new mode * @throws IllegalArgumentException if <code>dockable</code> is not known to this station */ public void setFullscreen( Dockable dockable, boolean fullscreen ){ ScreenDockWindow window = getWindow( dockable ); if( window == null ){ throw new IllegalArgumentException( "dockable is not known to this station" ); } window.setFullscreen( fullscreen ); }
final ScreenDockWindow window = station.getWindow(child); final Insets insets = window.getDockableInsets(); final MagnetizedOperation operation = station.getMagnetController() .start(window); final Rectangle validated = station.getBoundaryRestriction().check( window, bounds); if (validated != null){
public void setPlaceholders( PlaceholderMap placeholders ){ DockUtilities.checkLayoutLocked(); if( getDockableCount() > 0 ){ throw new IllegalStateException( "there are children on this station" ); } try{ DockablePlaceholderList<ScreenDockWindowHandle> next = new DockablePlaceholderList<ScreenDockWindowHandle>( placeholders ); if( getController() != null ){ dockables.setStrategy( null ); dockables.unbind(); dockables = next; dockables.bind(); dockables.setStrategy( getPlaceholderStrategy() ); } else{ dockables = next; } } catch( IllegalArgumentException ex ){ // ignore } }
ScreenDockWindowFactory factory = getWindowFactory(); DockController controller = getController(); if( controller != null ){ delay = controller.getProperties().get( PREVENT_FOCUS_STEALING_DELAY ); configuration = getConfiguration( oldWindow.getDockable() ); newWindow = createWindow( configuration ); oldWindow.setFullscreenStrategy( null ); for( ScreenDockStationListener listener : screenDockStationListeners() ){ listener.windowDeregistering( this, dockable, oldWindow ); handle.setWindow( newWindow, configuration ); newWindow.setController( getController() ); newWindow.setFullscreenStrategy( getFullscreenStrategy() ); newWindow.setWindowBounds( bounds ); newWindow.setFullscreen( fullscreen ); for( ScreenDockStationListener listener : screenDockStationListeners() ){ listener.windowRegistering( this, dockable, newWindow ); if( visible && isShowing() ){ if( delay == null || delay.intValue() <= 0 ){ newWindow.setVisible( true );
private ScreenDockWindowClosingStrategy getWindowClosingStrategy(){ DockController controller = getController(); if( controller == null ){ return null; } return controller.getProperties().get( WINDOW_CLOSING_STRATEGY ); }
DockController controller = getController(); DockAcceptance acceptance = controller == null ? null : controller.getAcceptance(); Dockable old = best.getDockable(); if( old.accept( this, dockable ) && dockable.accept( this, old ) && (acceptance == null || acceptance.accept( this, old, dockable ))){ combine( old, dockable, property.getSuccessor() ); done = true; boolean accept = accept( dockable ) && dockable.accept( this ) && (acceptance == null || acceptance.accept( this, dockable )); if( accept ){ addDockable( dockable, new Rectangle( property.getX(), property.getY(), property.getWidth(), property.getHeight() ), property.getPlaceholder(), args.isBoundsIncludeWindow() ); done = true; setFullscreen( dockable, true );
public void action( Dockable dockable ) { while( dockable.getDockParent() != screen ){ DockStation station = dockable.getDockParent(); if( station == null ) return; dockable = station.asDockable(); if( dockable == null ) return; } boolean state = screen.isFullscreen( dockable ); screen.setFullscreen( dockable, !state ); }
convertPointToScreen( startPoint, e.getComponent() ); magnet = window.getStation().getMagnetController().start( window ); DockController controller = window.getStation().getController(); if( controller != null ){ relocator = controller.getRelocator().createRemote( window.getDockable() );
public boolean drop( Dockable dockable, DockableProperty property ){ if( property instanceof ScreenDockProperty ) return drop( dockable, (ScreenDockProperty)property ); else return false; }
/** * Drops <code>dockable</code> at the same coordinates as <code>location</code>, a * direct child of this station. * @param dockable a new dockable * @param location a known dockable * @return whether the operation completed */ public boolean drop( Dockable dockable, Dockable location ){ boolean accept = accept( dockable ) && dockable.accept( this ); if( !accept ){ return false; } ScreenDockWindow window = getWindow( location ); if( window == null ){ throw new IllegalArgumentException( "location is now known to this station" ); } Rectangle bounds = null; if( window.isFullscreen() ){ bounds = window.getNormalBounds(); } if( bounds == null ){ bounds = window.getWindowBounds(); } addDockable( dockable, bounds, true ); return true; }
public void setLayout( ScreenDockStation station, ScreenDockStationLayout layout, Map<Integer, Dockable> children, PlaceholderStrategy placeholders ) { for( int i = station.getDockableCount()-1; i >= 0; i-- ) station.removeDockable( i ); if( layout instanceof RetroScreenDockStationLayout ){ RetroScreenDockStationLayout retro = (RetroScreenDockStationLayout) layout; for( int i = 0, n = retro.size(); i<n; i++ ){ Dockable dockable = children.get( retro.id( i ) ); if( dockable != null ){ Rectangle location = new Rectangle( retro.x( i ), retro.y( i ), retro.width( i ), retro.height( i )); station.addDockable( dockable, location, true ); } } } else{ station.setPlaceholders( layout.getPlaceholders().filter( placeholders ), children ); } }
int index = indexOf( dockable ); ScreenDockWindow window = getWindow( index ); if( window == null ){ throw new IllegalArgumentException( "dockable not child of this station" ); PlaceholderStrategy strategy = getPlaceholderStrategy(); Path placeholder = null; if( strategy != null ){
WindowConfiguration configuration = getConfiguration( dockable ); ScreenDockWindow window = createWindow( configuration ); ScreenDockWindowHandle handle = new ScreenDockWindowHandle( dockable, window, configuration ); window.setController( getController() ); window.setFullscreenStrategy( getFullscreenStrategy() ); window.setDockable( dockable ); window.setWindowBounds( new Rectangle( x, y, width, height ) ); window.setVisible( isShowing() ); window.validate(); window.setFullscreen( fullscreen );