/** * 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 ); } }
/** * 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 ); } }
/** * 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; }
/** * 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 ); } }
/** * 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(); } } } } }