/** * Gets the global identifier for the panel in the center. * @return the identifier */ public String getCenterIdentifier(){ return getCenterIdentifier( uniqueId ); }
@Override public String findRoot(){ CContentArea center = parent.getContentArea(); String id; if( center == null ) id = CControl.CONTENT_AREA_STATIONS_ID; else id = center.getUniqueId(); switch( side ){ case NORTH: return CContentArea.getNorthIdentifier( id ); case SOUTH: return CContentArea.getSouthIdentifier( id ); case EAST: return CContentArea.getEastIdentifier( id ); case WEST: return CContentArea.getWestIdentifier( id ); default: return null; } }
public CStation<?> getMatchingStation( CStationContainer container, CStation<?> station ){ if( container == this ){ return station; } if( container instanceof CContentArea ){ CContentArea other = (CContentArea)container; if( other.getStationCount() == getStationCount() ){ int index = other.indexOf( station ); if( index != -1 ){ return getStation( index ); } } } return null; }
/** * Ensures the uniqueness of the identifier <code>uniqueId</code>. Throws * various exceptions if the id is not unique. * @param uniqueId the id that might be unique * @param adding the station that is about to be added */ private void checkStationIdentifierUniqueness( String uniqueId, CStation<?> adding ){ if( uniqueId == null ) throw new NullPointerException( "uniqueId must not be null" ); if( CContentArea.getCenterIdentifier( CControl.CONTENT_AREA_STATIONS_ID ).equals( uniqueId ) ) throw new IllegalArgumentException( "The id " + uniqueId + " is reserved for special purposes" ); if( CContentArea.getEastIdentifier( CControl.CONTENT_AREA_STATIONS_ID ).equals( uniqueId ) ) throw new IllegalArgumentException( "The id " + uniqueId + " is reserved for special purposes" ); if( CContentArea.getWestIdentifier( CControl.CONTENT_AREA_STATIONS_ID ).equals( uniqueId ) ) throw new IllegalArgumentException( "The id " + uniqueId + " is reserved for special purposes" ); if( CContentArea.getSouthIdentifier( CControl.CONTENT_AREA_STATIONS_ID ).equals( uniqueId ) ) throw new IllegalArgumentException( "The id " + uniqueId + " is reserved for special purposes" ); if( CContentArea.getNorthIdentifier( CControl.CONTENT_AREA_STATIONS_ID ).equals( uniqueId ) ) throw new IllegalArgumentException( "The id " + uniqueId + " is reserved for special purposes" ); for( CStation<?> station : stations ){ if( station.getUniqueId().equals( uniqueId )){ if( station == adding ){ throw new IllegalArgumentException( "The station has already been registered" ); } throw new IllegalArgumentException( "There exists already a station with id: " + uniqueId ); } } }
/** * Creates a new content area. * @param control the control for which this area will be used * @param uniqueId a unique identifier of this center */ public CContentArea( CControl control, String uniqueId ){ this.control = control; this.uniqueId = uniqueId; CBaseLocation base = new CBaseLocation( this ); center = new CenterStation( getCenterIdentifier(), base.normal() ); north = new MinimizeStation( getNorthIdentifier(), new CMinimizedLocation( base, Side.NORTH ) ); south = new MinimizeStation( getSouthIdentifier(), new CMinimizedLocation( base, Side.SOUTH ) ); east = new MinimizeStation( getEastIdentifier(), new CMinimizedLocation( base, Side.EAST ) ); west = new MinimizeStation( getWestIdentifier(), new CMinimizedLocation( base, Side.WEST ) ); center.getStation().setExpandOnDoubleclick( false ); north.setDirection( Direction.SOUTH ); south.setDirection( Direction.NORTH ); east.setDirection( Direction.WEST ); west.setDirection( Direction.EAST ); setLayout( new BorderLayout() ); add( center.getStation(), BorderLayout.CENTER ); add( north, BorderLayout.NORTH ); add( south, BorderLayout.SOUTH ); add( east, BorderLayout.EAST ); add( west, BorderLayout.WEST ); stations = new CStation[]{ north, south, east, west, center }; }
/** * Gets the global identifier for the panel in the north. * @return the identifier */ public String getNorthIdentifier(){ return getNorthIdentifier( uniqueId ); }
/** * Gets the global identifier for the panel in the south. * @return the identifier */ public String getSouthIdentifier(){ return getSouthIdentifier( uniqueId ); }
/** * Gets the global identifier for the panel in the east. * @return the identifier */ public String getEastIdentifier(){ return getEastIdentifier( uniqueId ); }
@Override public void setupLayout(CControl control, CWorkingArea workingArea, Map<SingleCDockable, ViewDockWindow> docks) { removeDocks(control, docks); CGrid grid = new CGrid(control); grid.add(50, 50, 150, 150, workingArea); setupGrid(grid, docks); control.getContentArea().deploy(grid); }
/** * Exchanges all the {@link CDockable}s on the center panel by * the elements of <code>grid</code>. * @param grid a grid containing some new {@link Dockable}s */ public void deploy( CGrid grid ){ getCenter().dropTree( grid.toTree() ); }
private CContentArea createContentArea( String uniqueId, boolean isDefaultContentArea ){ if( uniqueId == null ) throw new NullPointerException( "uniqueId must not be null" ); if( !isDefaultContentArea && uniqueId.equals( CONTENT_AREA_STATIONS_ID )){ throw new IllegalArgumentException( "the unique identifier '" + uniqueId + "' is reserved for the default CContentArea and may not be used by the client" ); } CContentArea center = new CContentArea( this, uniqueId ); if( isDefaultContentArea ){ register.setDefaultContentArea( center ); } addStationContainer( center ); return center; }
/** * Ensures the uniqueness of the identifier <code>uniqueId</code>. Throws * various exceptions if the id is not unique. * @param uniqueId the id that might be unique * @param adding the station that is about to be added */ private void checkStationIdentifierUniqueness( String uniqueId, CStation<?> adding ){ if( uniqueId == null ) throw new NullPointerException( "uniqueId must not be null" ); if( CContentArea.getCenterIdentifier( CControl.CONTENT_AREA_STATIONS_ID ).equals( uniqueId ) ) throw new IllegalArgumentException( "The id " + uniqueId + " is reserved for special purposes" ); if( CContentArea.getEastIdentifier( CControl.CONTENT_AREA_STATIONS_ID ).equals( uniqueId ) ) throw new IllegalArgumentException( "The id " + uniqueId + " is reserved for special purposes" ); if( CContentArea.getWestIdentifier( CControl.CONTENT_AREA_STATIONS_ID ).equals( uniqueId ) ) throw new IllegalArgumentException( "The id " + uniqueId + " is reserved for special purposes" ); if( CContentArea.getSouthIdentifier( CControl.CONTENT_AREA_STATIONS_ID ).equals( uniqueId ) ) throw new IllegalArgumentException( "The id " + uniqueId + " is reserved for special purposes" ); if( CContentArea.getNorthIdentifier( CControl.CONTENT_AREA_STATIONS_ID ).equals( uniqueId ) ) throw new IllegalArgumentException( "The id " + uniqueId + " is reserved for special purposes" ); for( CStation<?> station : stations ){ if( station.getUniqueId().equals( uniqueId )){ if( station == adding ){ throw new IllegalArgumentException( "The station has already been registered" ); } throw new IllegalArgumentException( "There exists already a station with id: " + uniqueId ); } } }
/** * Creates a new content area. * @param control the control for which this area will be used * @param uniqueId a unique identifier of this center */ public CContentArea( CControl control, String uniqueId ){ this.control = control; this.uniqueId = uniqueId; CBaseLocation base = new CBaseLocation( this ); center = new CenterStation( getCenterIdentifier(), base.normal() ); north = new MinimizeStation( getNorthIdentifier(), new CMinimizedLocation( base, Side.NORTH ) ); south = new MinimizeStation( getSouthIdentifier(), new CMinimizedLocation( base, Side.SOUTH ) ); east = new MinimizeStation( getEastIdentifier(), new CMinimizedLocation( base, Side.EAST ) ); west = new MinimizeStation( getWestIdentifier(), new CMinimizedLocation( base, Side.WEST ) ); center.getStation().setExpandOnDoubleclick( false ); north.setDirection( Direction.SOUTH ); south.setDirection( Direction.NORTH ); east.setDirection( Direction.WEST ); west.setDirection( Direction.EAST ); setLayout( new BorderLayout() ); add( center.getStation(), BorderLayout.CENTER ); add( north, BorderLayout.NORTH ); add( south, BorderLayout.SOUTH ); add( east, BorderLayout.EAST ); add( west, BorderLayout.WEST ); stations = new CStation[]{ north, south, east, west, center }; }
/** * Gets the global identifier for the panel in the north. * @return the identifier */ public String getNorthIdentifier(){ return getNorthIdentifier( uniqueId ); }
/** * Gets the global identifier for the panel in the south. * @return the identifier */ public String getSouthIdentifier(){ return getSouthIdentifier( uniqueId ); }
/** * Gets the global identifier for the panel in the east. * @return the identifier */ public String getEastIdentifier(){ return getEastIdentifier( uniqueId ); }
content.deploy(grid);
/** * Exchanges all the {@link CDockable}s on the center panel by * the elements of <code>grid</code>. * @param grid a grid containing some new {@link Dockable}s */ public void deploy( CGrid grid ){ getCenter().dropTree( grid.toTree() ); }
private CContentArea createContentArea( String uniqueId, boolean isDefaultContentArea ){ if( uniqueId == null ) throw new NullPointerException( "uniqueId must not be null" ); if( !isDefaultContentArea && uniqueId.equals( CONTENT_AREA_STATIONS_ID )){ throw new IllegalArgumentException( "the unique identifier '" + uniqueId + "' is reserved for the default CContentArea and may not be used by the client" ); } CContentArea center = new CContentArea( this, uniqueId ); if( isDefaultContentArea ){ register.setDefaultContentArea( center ); } addStationContainer( center ); return center; }
this.id = id; String center = CContentArea.getCenterIdentifier( id ); String north = CContentArea.getNorthIdentifier( id ); String south = CContentArea.getSouthIdentifier( id ); String east = CContentArea.getEastIdentifier( id ); String west = CContentArea.getWestIdentifier( id );