@Test public void perspectiveIsInitializedOnlyOnce() throws KettleException { SpoonPerspectiveManager.PerspectiveManager perspectiveManager = perspectiveManagerMap.get( perspective ); spoonPerspectiveManager.activatePerspective( perspective.getClass() ); verify( perspectiveManager ).performInit(); spoonPerspectiveManager.activatePerspective( perspective.getClass() ); verify( perspectiveManager ).performInit(); }
public void activatePerspective( Class<? extends SpoonPerspective> clazz ) throws KettleException { if ( this.forcePerspective ) { return; } SpoonPerspective sp = perspectives.get( clazz ); if ( sp == null ) { throw new KettleException( "Could not locate perspective by class: " + clazz ); } PerspectiveManager perspectiveManager = getPerspectiveManagerMap().get( sp ); if ( perspectiveManager != null ) { perspectiveManager.initializeIfNeeded(); } unloadPerspective( activePerspective ); activePerspective = sp; List<XulOverlay> overlays = sp.getOverlays(); if ( overlays != null ) { for ( XulOverlay overlay : overlays ) { try { ResourceBundle res = null; if ( overlay.getResourceBundleUri() != null ) { try { res = ResourceBundle.getBundle( overlay.getResourceBundleUri() ); } catch ( MissingResourceException ignored ) { } } else { try { res = ResourceBundle.getBundle( overlay.getOverlayUri().replace( ".xul", ".properties" ) ); } catch ( MissingResourceException ignored ) { } } if ( res == null ) { res = new XulSpoonResourceBundle( sp.getClass() ); } domContainer.loadOverlay( overlay.getOverlayUri(), res ); } catch ( XulException e ) { log.logError( "Error activate perspective", e ); } } } List<XulEventHandler> theXulEventHandlers = sp.getEventHandlers(); if ( theXulEventHandlers != null ) { for ( XulEventHandler handler : theXulEventHandlers ) { domContainer.addEventHandler( handler ); } } sp.setActive( true ); deck.setSelectedIndex( deck.getChildNodes().indexOf( deck.getElementById( "perspective-" + sp.getId() ) ) ); getSpoon().enableMenus(); }
SpoonPerspectiveManager { public void activatePerspective( Class<? extends SpoonPerspective> clazz ) throws KettleException { if ( this.forcePerspective ) { return; } SpoonPerspective sp = perspectives.get( clazz ); if ( sp == null ) { throw new KettleException( "Could not locate perspective by class: " + clazz ); } PerspectiveManager perspectiveManager = getPerspectiveManagerMap().get( sp ); if ( perspectiveManager != null ) { perspectiveManager.initializeIfNeeded(); } unloadPerspective( activePerspective ); activePerspective = sp; List<XulOverlay> overlays = sp.getOverlays(); if ( overlays != null ) { for ( XulOverlay overlay : overlays ) { try { ResourceBundle res = null; if ( overlay.getResourceBundleUri() != null ) { try { res = ResourceBundle.getBundle( overlay.getResourceBundleUri() ); } catch ( MissingResourceException ignored ) { } } else { try { res = ResourceBundle.getBundle( overlay.getOverlayUri().replace( ".xul", ".properties" ) ); } catch ( MissingResourceException ignored ) { } } if ( res == null ) { res = new XulSpoonResourceBundle( sp.getClass() ); } domContainer.loadOverlay( overlay.getOverlayUri(), res ); } catch ( XulException e ) { log.logError( "Error activate perspective", e ); } } } List<XulEventHandler> theXulEventHandlers = sp.getEventHandlers(); if ( theXulEventHandlers != null ) { for ( XulEventHandler handler : theXulEventHandlers ) { domContainer.addEventHandler( handler ); } } sp.setActive( true ); deck.setSelectedIndex( deck.getChildNodes().indexOf( deck.getElementById( "perspective-" + sp.getId() ) ) ); getSpoon().enableMenus(); } }
SpoonPerspectiveManager { public void activatePerspective( Class<? extends SpoonPerspective> clazz ) throws KettleException { if ( this.forcePerspective ) { return; } SpoonPerspective sp = perspectives.get( clazz ); if ( sp == null ) { throw new KettleException( "Could not locate perspective by class: " + clazz ); } PerspectiveManager perspectiveManager = getPerspectiveManagerMap().get( sp ); if ( perspectiveManager != null ) { perspectiveManager.initializeIfNeeded(); } unloadPerspective( activePerspective ); activePerspective = sp; List<XulOverlay> overlays = sp.getOverlays(); if ( overlays != null ) { for ( XulOverlay overlay : overlays ) { try { ResourceBundle res = null; if ( overlay.getResourceBundleUri() != null ) { try { res = ResourceBundle.getBundle( overlay.getResourceBundleUri() ); } catch ( MissingResourceException ignored ) { } } else { try { res = ResourceBundle.getBundle( overlay.getOverlayUri().replace( ".xul", ".properties" ) ); } catch ( MissingResourceException ignored ) { } } if ( res == null ) { res = new XulSpoonResourceBundle( sp.getClass() ); } domContainer.loadOverlay( overlay.getOverlayUri(), res ); } catch ( XulException e ) { log.logError( "Error activate perspective", e ); } } } List<XulEventHandler> theXulEventHandlers = sp.getEventHandlers(); if ( theXulEventHandlers != null ) { for ( XulEventHandler handler : theXulEventHandlers ) { domContainer.addEventHandler( handler ); } } sp.setActive( true ); deck.setSelectedIndex( deck.getChildNodes().indexOf( deck.getElementById( "perspective-" + sp.getId() ) ) ); getSpoon().enableMenus(); } @SuppressWarnings( "rawtypes" ) private  SpoonPerspectiveManager(); }
SpoonPerspectiveManager { public void activatePerspective( Class<? extends SpoonPerspective> clazz ) throws KettleException { if ( this.forcePerspective ) { return; } SpoonPerspective sp = perspectives.get( clazz ); if ( sp == null ) { throw new KettleException( "Could not locate perspective by class: " + clazz ); } PerspectiveManager perspectiveManager = getPerspectiveManagerMap().get( sp ); if ( perspectiveManager != null ) { perspectiveManager.initializeIfNeeded(); } unloadPerspective( activePerspective ); activePerspective = sp; List<XulOverlay> overlays = sp.getOverlays(); if ( overlays != null ) { for ( XulOverlay overlay : overlays ) { try { ResourceBundle res = null; if ( overlay.getResourceBundleUri() != null ) { try { res = ResourceBundle.getBundle( overlay.getResourceBundleUri() ); } catch ( MissingResourceException ignored ) { } } else { try { res = ResourceBundle.getBundle( overlay.getOverlayUri().replace( ".xul", ".properties" ) ); } catch ( MissingResourceException ignored ) { } } if ( res == null ) { res = new XulSpoonResourceBundle( sp.getClass() ); } domContainer.loadOverlay( overlay.getOverlayUri(), res ); } catch ( XulException e ) { log.logError( "Error activate perspective", e ); } } } List<XulEventHandler> theXulEventHandlers = sp.getEventHandlers(); if ( theXulEventHandlers != null ) { for ( XulEventHandler handler : theXulEventHandlers ) { domContainer.addEventHandler( handler ); } } sp.setActive( true ); deck.setSelectedIndex( deck.getChildNodes().indexOf( deck.getElementById( "perspective-" + sp.getId() ) ) ); getSpoon().enableMenus(); } @SuppressWarnings( "rawtypes" ) private  SpoonPerspectiveManager(); String getStartupPerspective(); void setStartupPerspective( String startupPerspective ); static SpoonPerspectiveManager getInstance(); void setDeck( XulDeck deck ); void setXulDoc( XulDomContainer doc ); void addPerspective( SpoonPerspective perspective ); void showPerspective( final String perspectiveId ); void hidePerspective( final String perspectiveId ); @SuppressWarnings( "unchecked" ) List<SpoonPerspective> getPerspectives(); void activatePerspective( Class<? extends SpoonPerspective> clazz ); SpoonPerspective getActivePerspective(); boolean isForcePerspective(); void setForcePerspective( boolean forcePerspective ); void removePerspective( SpoonPerspective per ); void initialize(); }
SpoonPerspectiveManager { public void activatePerspective( Class<? extends SpoonPerspective> clazz ) throws KettleException { if ( this.forcePerspective ) { return; } SpoonPerspective sp = perspectives.get( clazz ); if ( sp == null ) { throw new KettleException( "Could not locate perspective by class: " + clazz ); } PerspectiveManager perspectiveManager = getPerspectiveManagerMap().get( sp ); if ( perspectiveManager != null ) { perspectiveManager.initializeIfNeeded(); } unloadPerspective( activePerspective ); activePerspective = sp; List<XulOverlay> overlays = sp.getOverlays(); if ( overlays != null ) { for ( XulOverlay overlay : overlays ) { try { ResourceBundle res = null; if ( overlay.getResourceBundleUri() != null ) { try { res = ResourceBundle.getBundle( overlay.getResourceBundleUri() ); } catch ( MissingResourceException ignored ) { } } else { try { res = ResourceBundle.getBundle( overlay.getOverlayUri().replace( ".xul", ".properties" ) ); } catch ( MissingResourceException ignored ) { } } if ( res == null ) { res = new XulSpoonResourceBundle( sp.getClass() ); } domContainer.loadOverlay( overlay.getOverlayUri(), res ); } catch ( XulException e ) { log.logError( "Error activate perspective", e ); } } } List<XulEventHandler> theXulEventHandlers = sp.getEventHandlers(); if ( theXulEventHandlers != null ) { for ( XulEventHandler handler : theXulEventHandlers ) { domContainer.addEventHandler( handler ); } } sp.setActive( true ); deck.setSelectedIndex( deck.getChildNodes().indexOf( deck.getElementById( "perspective-" + sp.getId() ) ) ); getSpoon().enableMenus(); } @SuppressWarnings( "rawtypes" ) private  SpoonPerspectiveManager(); String getStartupPerspective(); void setStartupPerspective( String startupPerspective ); static SpoonPerspectiveManager getInstance(); void setDeck( XulDeck deck ); void setXulDoc( XulDomContainer doc ); void addPerspective( SpoonPerspective perspective ); void showPerspective( final String perspectiveId ); void hidePerspective( final String perspectiveId ); @SuppressWarnings( "unchecked" ) List<SpoonPerspective> getPerspectives(); void activatePerspective( Class<? extends SpoonPerspective> clazz ); SpoonPerspective getActivePerspective(); boolean isForcePerspective(); void setForcePerspective( boolean forcePerspective ); void removePerspective( SpoonPerspective per ); void initialize();  }