1 19 20 21 package org.netbeans.core.windows.view; 22 23 import java.awt.Rectangle ; 24 import java.util.Map ; 25 import org.netbeans.core.windows.Constants; 26 import org.netbeans.core.windows.WindowManagerImpl; 27 import org.netbeans.core.windows.view.dnd.WindowDnDManager; 28 import org.netbeans.core.windows.view.ui.slides.SlideBarContainer; 29 import org.openide.windows.TopComponent; 30 31 32 37 public class SlidingView extends ModeView { 38 39 40 private final String side; 41 private Rectangle slideBounds; 42 private Map <TopComponent,Integer > slideInSizes; 43 44 public SlidingView(Controller controller, WindowDnDManager windowDnDManager, 45 TopComponent[] topComponents, 46 TopComponent selectedTopComponent, 47 String side, Map <TopComponent,Integer > slideInSizes) { 48 super(controller); 49 this.side = side; 50 this.slideInSizes = slideInSizes; 51 this.container = new SlideBarContainer(this, windowDnDManager); 53 setTopComponents(topComponents, selectedTopComponent); 54 } 55 56 public String getSide() { 57 return side; 58 } 59 60 public Rectangle getTabBounds(int tabIndex) { 61 return ((SlideBarContainer)this.container).getTabBounds(tabIndex); 62 } 63 64 public Rectangle getSlideBounds() { 65 Rectangle res = slideBounds; 66 67 TopComponent tc = getSelectedTopComponent(); 68 if( null != tc ) { 70 WindowManagerImpl wm = WindowManagerImpl.getInstance(); 71 String tcID = wm.findTopComponentID( tc ); 72 if( wm.isTopComponentMaximizedWhenSlidedIn( tcID ) ) { 73 if( Constants.BOTTOM.equals( side ) ) { 76 res.height = Integer.MAX_VALUE; 77 } else { 78 res.width = Integer.MAX_VALUE; 79 } 80 } else { 81 Integer prevSlideSize = slideInSizes.get( tc ); 82 if( null != prevSlideSize ) { 83 if( null == res ) 84 res = tc.getBounds(); 85 if( Constants.BOTTOM.equals( side ) ) { 86 res.height = prevSlideSize.intValue(); 87 } else { 88 res.width = prevSlideSize.intValue(); 89 } 90 } 91 } 92 } 93 return res; 94 } 95 96 public void setSlideBounds(Rectangle slideBounds) { 97 this.slideBounds = slideBounds; 98 } 99 100 public void setSlideInSizes(Map <TopComponent,Integer > slideInSizes) { 101 this.slideInSizes = slideInSizes; 102 } 103 } 104 105 | Popular Tags |