protected Collection<DockTitleFactory> createTitleFactories( DockTitleVersion version ){ if( version.getID().equals( ScreenDockStation.TITLE_ID ) ) { final List<DockTitleFactory> result = new ArrayList<DockTitleFactory>(); result.add( new ScreenToolbarDockTitleFactory( version.getController() ) ); return result; } return null; }
/** * Gets the handle with the key <code>id</code>. If the key is unknown, then * a new handle is created, using <code>factory</code> as default factory. * @param id the key of the handle * @param factory the default factory used when a new handle has to be created, can be <code>null</code> * @return the handle */ public DockTitleVersion getVersion( String id, DockTitleFactory factory ){ DockTitleVersion version = titleVersions.get( id ); if( version == null ){ version = new DockTitleVersion( controller, id ); titleVersions.put( id, version ); } if( version.getFactory( Priority.DEFAULT ) == null ){ version.setFactory( factory, Priority.DEFAULT ); } return version; }
public void request( DockTitleRequest request ){ getControllerVersion( request ).request( request ); }
/** * Registers a factory for the given key * @param id the key of the factory * @param factory the factory * @param priority the priority of this registration * @return the handle to the factory or a factory with higher priority */ public DockTitleVersion register( String id, DockTitleFactory factory, Priority priority ){ DockTitleVersion version = titleVersions.get( id ); if( version == null ){ version = new DockTitleVersion( controller, id ); titleVersions.put( id, version ); } version.setFactory( factory, priority ); return version; }
@Override public void bind(){ DockTitleVersion origin = getOrigin(); if( origin != null ){ connector.setProperties( origin.getController() ); behavior.setProperties( origin.getController() ); } behavior.setDockable( getDockable() ); super.bind(); }
/** * Checks whether the title created by <code>version</code> should * be suppressed. * @param version the version of the title * @return <code>true</code> if no {@link DockTitle} should be created */ protected boolean suppressTitle( DockTitleVersion version ){ if( !isTitleShown() ){ if( version.getID().equals( SplitDockStation.TITLE_ID )) return true; if( version.getID().equals( FlapDockStation.WINDOW_TITLE_ID )) return true; if( version.getID().equals( ScreenDockStation.TITLE_ID )) return true; if( version.getID().equals( StackDockStation.TITLE_ID )) return true; } return false; }
/** * Stores <code>factory</code> at the slot <code>priority</code>. * @param factory the factory * @param priority the importance of the factory */ public void setFactory( DockTitleFactory factory, Priority priority ){ DockTitleFactory oldFactory = getFactory(); factories[ map( priority ) ] = factory; DockTitleFactory newFactory = getFactory(); if( oldFactory != newFactory ){ if( oldFactory != null ){ for( DockTitleRequest request : requests ){ oldFactory.uninstall( request ); } } if( newFactory != null ){ for( DockTitleRequest request : requests ){ newFactory.install( request ); if( !onThemeChange ){ request.request(); } } } } }
/** * Removes <code>request</code> from this version. This method should not be * called by clients, clients should call {@link DockTitleRequest#uninstall()}. * @param request the request to remove */ public void uninstall( DockTitleRequest request ){ requests.remove( request ); DockTitleFactory factory = getFactory(); if( factory != null ){ factory.uninstall( request ); } }
/** * Removes all factories that were added by a theme */ public void clearThemeFactories(){ for( DockTitleVersion version : titleVersions.values() ) version.setFactory( null, Priority.THEME ); } }
/** * Makes this request active. After installation the method {@link ResourceRequest#answer(Object,Object)} may * be called at any time. Please note that installing does not automatically trigger a call * to {@link #request()}. */ public void install(){ if( !installed ){ installed = true; version.install( this ); } }
private DockTitleVersion getControllerVersion( DockTitleRequest request ){ return request.getVersion().getController().getDockTitleManager().getVersion( DockTitleManager.THEME_FACTORY_ID ); }
/** * Checks whether the title created by <code>version</code> should * be suppressed. * @param version the version of the title * @return <code>true</code> if no {@link DockTitle} should be created */ protected boolean suppressTitle( DockTitleVersion version ){ if( !isTitleShown() ){ if( version.getID().equals( SplitDockStation.TITLE_ID )) return true; if( version.getID().equals( FlapDockStation.WINDOW_TITLE_ID )) return true; if( version.getID().equals( ScreenDockStation.TITLE_ID )) return true; if( version.getID().equals( StackDockStation.TITLE_ID )) return true; } return false; }
/** * Registers a factory for the given key * @param id the key of the factory * @param factory the factory * @param priority the priority of this registration * @return the handle to the factory or a factory with higher priority */ public DockTitleVersion register( String id, DockTitleFactory factory, Priority priority ){ DockTitleVersion version = titleVersions.get( id ); if( version == null ){ version = new DockTitleVersion( controller, id ); titleVersions.put( id, version ); } version.setFactory( factory, priority ); return version; }
/** * Adds <code>request</code> to this version. The <code>request</code> will * be installed on the current {@link DockTitleFactory} of this version. * This method should not be called by clients, clients should call {@link DockTitleRequest#install()}. * @param request the new request, not <code>null</code> */ public void install( DockTitleRequest request ){ if( request == null ) throw new IllegalArgumentException( "request must not be null" ); requests.add( request ); DockTitleFactory factory = getFactory(); if( factory != null ){ factory.install( request ); } }
/** * Removes all factories that were added by a theme */ public void clearThemeFactories(){ for( DockTitleVersion version : titleVersions.values() ) version.setFactory( null, Priority.THEME ); } }
public void install( DockTitleRequest request ){ getControllerVersion( request ).install( request ); }
@Override protected void changeBorder(){ int flags; EmptyBorder empty; if( getOrientation().isHorizontal() ){ flags = EclipseButtonBorder.TOP_RIGHT | EclipseButtonBorder.BOTTOM_RIGHT; empty = new EmptyBorder( 2, 2, 2, 4 ); } else{ flags = EclipseButtonBorder.BOTTOM_LEFT | EclipseButtonBorder.BOTTOM_RIGHT; empty = new EmptyBorder( 2, 2, 4, 2 ); } Border border = new EclipseButtonBorder( getOrigin().getController(), true, flags ); setBorder( ThemeManager.BORDER_MODIFIER + ".title.eclipse.button.flat", new CompoundBorder( border, empty ) ); } }
@Override public void requestDockTitle( DockTitleRequest request ){ if( dockable.isTitleShown() ){ super.requestDockTitle( request ); } else{ DockTitleVersion version = request.getVersion(); boolean hide = version.getID().equals( SplitDockStation.TITLE_ID ) || version.getID().equals( StackDockStation.TITLE_ID ) || version.getID().equals( ScreenDockStation.TITLE_ID ) || version.getID().equals( FlapDockStation.WINDOW_TITLE_ID ); if( hide ){ request.answer( null ); } else{ super.requestDockTitle( request ); } } }
/** * Gets the handle with the key <code>id</code>. If the key is unknown, then * a new handle is created, using <code>factory</code> as default factory. * @param id the key of the handle * @param factory the default factory used when a new handle has to be created, can be <code>null</code> * @return the handle */ public DockTitleVersion getVersion( String id, DockTitleFactory factory ){ DockTitleVersion version = titleVersions.get( id ); if( version == null ){ version = new DockTitleVersion( controller, id ); titleVersions.put( id, version ); } if( version.getFactory( Priority.DEFAULT ) == null ){ version.setFactory( factory, Priority.DEFAULT ); } return version; }
/** * Calls {@link DockTitleFactory#request(DockTitleRequest)} for the current * factory. If there are any {@link #DOCK_TITLE_VERSION_EXTENSION extensions} installed, then * these extensions are questioned first. * @param request the request to answer */ public void request( DockTitleRequest request ){ DockTitleFactory client = getFactory( Priority.CLIENT ); if( client != null ){ client.request( request ); return; } if( extensionFactories != null ){ for( DockTitleFactory factory : extensionFactories ){ factory.request( request ); if( request.isAnswered() ){ return; } } } DockTitleFactory factory = getFactory(); if( factory != null ){ factory.request( request ); } }