/** * Tells whether the layout of <code>element</code> itself should be stored * or loaded, that will not prevent the <code>element</code> from showing * up but from changing its content. The default implementation uses the maps * of <code>perspective</code> and this {@link DockSituation} to convert <code>element</code> * into a preset {@link DockElement} and calls {@link #shouldLayout(DockElement)}. If the * element is not found, <code>true</code> is returned. * @param element the element whose contents might or might not be stored * or loaded * @param perspective the perspective for which the question has to be answered * @return <code>true</code> if the contents should be handled, <code>false</code> * if they should be discarded */ protected boolean shouldLayout( PerspectiveElement element, PredefinedPerspective perspective ){ String key = perspective.get( element ); if( key != null ){ DockElement dock = stringToElement.get( key ); if( dock != null ){ return shouldLayout( dock ); } } return true; }
/** * Tells whether the layout of <code>element</code> itself should be stored * or loaded, that will not prevent the <code>element</code> from showing * up but from changing its content. The default implementation uses the maps * of <code>perspective</code> and this {@link DockSituation} to convert <code>element</code> * into a preset {@link DockElement} and calls {@link #shouldLayout(DockElement)}. If the * element is not found, <code>true</code> is returned. * @param element the element whose contents might or might not be stored * or loaded * @param perspective the perspective for which the question has to be answered * @return <code>true</code> if the contents should be handled, <code>false</code> * if they should be discarded */ protected boolean shouldLayout( PerspectiveElement element, PredefinedPerspective perspective ){ String key = perspective.get( element ); if( key != null ){ DockElement dock = stringToElement.get( key ); if( dock != null ){ return shouldLayout( dock ); } } return true; }
@SuppressWarnings("unchecked") public PredefinedLayout getLayout( DockElement element, Map<Dockable, Integer> children ) { if( shouldLayout( element )){ String factoryId = UNKNOWN + PredefinedDockSituation.super.getID( element ); DockFactory<DockElement,?,Object> factory = (DockFactory<DockElement,?,Object>)getFactory( factoryId ); if( factory == null ) throw new IllegalStateException( "Missing factory: " + factoryId ); Object data = factory.getLayout( element, children ); DockLayout<Object> layout = new DockLayout<Object>( factoryId, data ); return new PredefinedLayout( elementToString.get( element ), new DockLayoutInfo( layout )); } else{ return new PredefinedLayout( elementToString.get( element ), new DockLayoutInfo() ); } }
@SuppressWarnings("unchecked") public PredefinedLayout getLayout( DockElement element, Map<Dockable, Integer> children ) { if( shouldLayout( element )){ String factoryId = UNKNOWN + PredefinedDockSituation.super.getID( element ); DockFactory<DockElement,?,Object> factory = (DockFactory<DockElement,?,Object>)getFactory( factoryId ); if( factory == null ) throw new IllegalStateException( "Missing factory: " + factoryId ); Object data = factory.getLayout( element, children ); DockLayout<Object> layout = new DockLayout<Object>( factoryId, data ); return new PredefinedLayout( elementToString.get( element ), new DockLayoutInfo( layout )); } else{ return new PredefinedLayout( elementToString.get( element ), new DockLayoutInfo() ); } }
@SuppressWarnings("unchecked") public PredefinedLayout getPerspectiveLayout( PerspectiveElement element, Map<PerspectiveDockable, Integer> children ){ if( perspective == null ){ throw new IllegalStateException( "the perspective of this factory is not set, meaning this factory cannot be used handling perspective dependent tasks" ); } DockLayoutInfo info; if( shouldLayout( element, perspective )){ String factoryId = UNKNOWN + PredefinedDockSituation.super.getID( element ); DockFactory factory = getFactory( factoryId ); if( factory == null ) throw new IllegalStateException( "Missing factory: " + factoryId ); Object data = factory.getPerspectiveLayout( element, children ); DockLayout<Object> layout = new DockLayout<Object>( factoryId, data ); info = new DockLayoutInfo( layout ); } else{ info = new DockLayoutInfo(); } String key = perspective.get( element ); if( key == null ){ throw new IllegalStateException( "Expected a key for an element, the element should be known to the perspective, otherwise this method would not have been called: '" + element +"'" ); } return new PredefinedLayout( key, info ); }
@SuppressWarnings("unchecked") public PredefinedLayout getPerspectiveLayout( PerspectiveElement element, Map<PerspectiveDockable, Integer> children ){ if( perspective == null ){ throw new IllegalStateException( "the perspective of this factory is not set, meaning this factory cannot be used handling perspective dependent tasks" ); } DockLayoutInfo info; if( shouldLayout( element, perspective )){ String factoryId = UNKNOWN + PredefinedDockSituation.super.getID( element ); DockFactory factory = getFactory( factoryId ); if( factory == null ) throw new IllegalStateException( "Missing factory: " + factoryId ); Object data = factory.getPerspectiveLayout( element, children ); DockLayout<Object> layout = new DockLayout<Object>( factoryId, data ); info = new DockLayoutInfo( layout ); } else{ info = new DockLayoutInfo(); } String key = perspective.get( element ); if( key == null ){ throw new IllegalStateException( "Expected a key for an element, the element should be known to the perspective, otherwise this method would not have been called: '" + element +"'" ); } return new PredefinedLayout( key, info ); }
@SuppressWarnings("unchecked") public void layoutPerspective( PerspectiveElement element, PredefinedLayout layout, Map<Integer, PerspectiveDockable> children ){ DockLayoutInfo delegate = layout.getDelegate(); if( delegate.getKind() == DockLayoutInfo.Data.DOCK_LAYOUT && shouldLayout( element, perspective )){ String factoryId = delegate.getDataLayout().getFactoryID(); DockFactory factory = getFactory( factoryId ); if( factory != null ){ factory.layoutPerspective( element, delegate.getDataLayout().getData(), children ); } } }
@SuppressWarnings("unchecked") public void layoutPerspective( PerspectiveElement element, PredefinedLayout layout, Map<Integer, PerspectiveDockable> children ){ DockLayoutInfo delegate = layout.getDelegate(); if( delegate.getKind() == DockLayoutInfo.Data.DOCK_LAYOUT && shouldLayout( element, perspective )){ String factoryId = delegate.getDataLayout().getFactoryID(); DockFactory factory = getFactory( factoryId ); if( factory != null ){ factory.layoutPerspective( element, delegate.getDataLayout().getData(), children ); } } }
@SuppressWarnings("unchecked") public void setLayout( DockElement element, PredefinedLayout layout, PlaceholderStrategy placeholders ) { DockLayoutInfo delegate = layout.getDelegate(); if( delegate.getKind() == DockLayoutInfo.Data.DOCK_LAYOUT && shouldLayout( element )){ String factoryId = delegate.getDataLayout().getFactoryID(); DockFactory<DockElement,?,Object> factory = (DockFactory<DockElement,?,Object>)getFactory( factoryId ); if( factory != null ){ DockController controller = element.getController(); try{ if( controller != null ) controller.freezeLayout(); factory.setLayout( element, delegate.getDataLayout().getData(), placeholders ); } finally{ if( controller != null ) controller.meltLayout(); } } } }
@SuppressWarnings("unchecked") public void setLayout( DockElement element, PredefinedLayout layout, Map<Integer, Dockable> children, PlaceholderStrategy placeholders ) { DockLayoutInfo delegate = layout.getDelegate(); if( delegate.getKind() == DockLayoutInfo.Data.DOCK_LAYOUT && shouldLayout( element )){ String factoryId = delegate.getDataLayout().getFactoryID(); DockFactory<DockElement,?,Object> factory = (DockFactory<DockElement,?,Object>)getFactory( factoryId ); if( factory != null ){ DockController controller = element.getController(); try{ if( controller != null ) controller.freezeLayout(); factory.setLayout( element, delegate.getDataLayout().getData(), children, placeholders ); } finally{ if( controller != null ) controller.meltLayout(); } } } }
@SuppressWarnings("unchecked") public void setLayout( DockElement element, PredefinedLayout layout, Map<Integer, Dockable> children, PlaceholderStrategy placeholders ) { DockLayoutInfo delegate = layout.getDelegate(); if( delegate.getKind() == DockLayoutInfo.Data.DOCK_LAYOUT && shouldLayout( element )){ String factoryId = delegate.getDataLayout().getFactoryID(); DockFactory<DockElement,?,Object> factory = (DockFactory<DockElement,?,Object>)getFactory( factoryId ); if( factory != null ){ DockController controller = element.getController(); try{ if( controller != null ) controller.freezeLayout(); factory.setLayout( element, delegate.getDataLayout().getData(), children, placeholders ); } finally{ if( controller != null ) controller.meltLayout(); } } } }
@SuppressWarnings("unchecked") public void setLayout( DockElement element, PredefinedLayout layout, PlaceholderStrategy placeholders ) { DockLayoutInfo delegate = layout.getDelegate(); if( delegate.getKind() == DockLayoutInfo.Data.DOCK_LAYOUT && shouldLayout( element )){ String factoryId = delegate.getDataLayout().getFactoryID(); DockFactory<DockElement,?,Object> factory = (DockFactory<DockElement,?,Object>)getFactory( factoryId ); if( factory != null ){ DockController controller = element.getController(); try{ if( controller != null ) controller.freezeLayout(); factory.setLayout( element, delegate.getDataLayout().getData(), placeholders ); } finally{ if( controller != null ) controller.meltLayout(); } } } }