KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > core > windows > view > SlidingView


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20
21 package org.netbeans.core.windows.view;
22
23 import java.awt.Rectangle JavaDoc;
24 import java.util.Map JavaDoc;
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 /**
33  * Model of sliding mode element for GUI hierarchy.
34  *
35  * @author Dafe Simonek
36  */

37 public class SlidingView extends ModeView {
38
39     /** Orientation of sliding view, means side where it is located */
40     private final String JavaDoc side;
41     private Rectangle JavaDoc slideBounds;
42     private Map JavaDoc<TopComponent,Integer JavaDoc> slideInSizes;
43
44     public SlidingView(Controller controller, WindowDnDManager windowDnDManager,
45                         TopComponent[] topComponents,
46                         TopComponent selectedTopComponent,
47                         String JavaDoc side, Map JavaDoc<TopComponent,Integer JavaDoc> slideInSizes) {
48         super(controller);
49         this.side = side;
50         this.slideInSizes = slideInSizes;
51         // mkleint - needs to be called after side is defined.
52
this.container = new SlideBarContainer(this, windowDnDManager);
53         setTopComponents(topComponents, selectedTopComponent);
54     }
55     
56     public String JavaDoc getSide() {
57         return side;
58     }
59     
60     public Rectangle JavaDoc getTabBounds(int tabIndex) {
61         return ((SlideBarContainer)this.container).getTabBounds(tabIndex);
62     }
63
64     public Rectangle JavaDoc getSlideBounds() {
65         Rectangle JavaDoc res = slideBounds;
66         
67         TopComponent tc = getSelectedTopComponent();
68         //check if the slided-in TopComponent has a custom size defined
69
if( null != tc ) {
70             WindowManagerImpl wm = WindowManagerImpl.getInstance();
71             String JavaDoc tcID = wm.findTopComponentID( tc );
72             if( wm.isTopComponentMaximizedWhenSlidedIn( tcID ) ) {
73                 //force maximum size when the slided-in window is maximized,
74
//the DesktopImpl will adjust the size to fit the main window
75
if( Constants.BOTTOM.equals( side ) ) {
76                     res.height = Integer.MAX_VALUE;
77                 } else {
78                     res.width = Integer.MAX_VALUE;
79                 }
80             } else {
81                 Integer JavaDoc 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 JavaDoc slideBounds) {
97         this.slideBounds = slideBounds;
98     }
99     
100     public void setSlideInSizes(Map JavaDoc<TopComponent,Integer JavaDoc> slideInSizes) {
101         this.slideInSizes = slideInSizes;
102     }
103 }
104
105
Popular Tags