KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > layout > TrimDescriptor


1 /*******************************************************************************
2  * Copyright (c) 2005, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.ui.internal.layout;
13
14
15 /**
16  * Manages the internal piece of trim for each trim area.
17  *
18  * @since 3.2
19  */

20 public class TrimDescriptor {
21
22     /**
23      * The window trim object.
24      */

25     private IWindowTrim fTrim;
26
27     /**
28      * The cache for the window trim object's control.
29      */

30     private SizeCache fCache;
31
32     /**
33      * The cache for the common drag affordance, if available.
34      */

35     private SizeCache fDockingHandle = null;
36
37     /**
38      * The current area that we belong to.
39      *
40      * @see TrimLayout#getAreaIds()
41      */

42     private int fAreaId;
43
44     /**
45      * Create a trim descriptor for the trim manager.
46      *
47      * @param trim
48      * the window trim
49      * @param areaId
50      * the trim area we belong to.
51      */

52     public TrimDescriptor(IWindowTrim trim, int areaId) {
53         fTrim = trim;
54         fAreaId = areaId;
55     }
56
57     /**
58      * @return Returns the fCache.
59      */

60     public SizeCache getCache() {
61         return fCache;
62     }
63
64     /**
65      * Set the trim cache. Because of the requirements of possibly changing
66      * orientation when docking on a different side, the same IWindowTrim
67      * sometimes needs to have it's control SizeCache replaced.
68      *
69      * @param c
70      * cache.
71      */

72     public void setCache(SizeCache c) {
73         fCache = c;
74     }
75
76     /**
77      * @return Returns the fTrim.
78      */

79     public IWindowTrim getTrim() {
80         return fTrim;
81     }
82
83     /**
84      * Return the cache for the common drag affordance.
85      *
86      * @return return the docking handle cache
87      */

88     public SizeCache getDockingCache() {
89         return fDockingHandle;
90     }
91
92     /**
93      * The trim ID.
94      *
95      * @return the trim ID. This should not be <code>null</code>.
96      */

97     public String JavaDoc getId() {
98         return fTrim.getId();
99     }
100
101     /**
102      * Returns whether the control for this trim is visible.
103      *
104      * @return <code>true</code> if the control is visible.
105      */

106     public boolean isVisible() {
107         if (!fTrim.getControl().isDisposed()) {
108             return fTrim.getControl().isVisible();
109         }
110         return false;
111     }
112
113     /**
114      * Set the cache for the common drag affordance.
115      *
116      * @param cache
117      * the sizecache for the docking control
118      */

119     public void setDockingCache(SizeCache cache) {
120         fDockingHandle = cache;
121     }
122
123     /**
124      * The area ID this descriptor belongs to.
125      *
126      * @return the ID
127      * @see TrimLayout#getAreaIds()
128      */

129     public int getAreaId() {
130         return fAreaId;
131     }
132
133     /**
134      * Set the current area this descriptor belongs to.
135      *
136      * @param id
137      * the area ID.
138      * @see TrimLayout#getAreaIds()
139      */

140     public void setAreaId(int id) {
141         fAreaId = id;
142     }
143
144     /**
145      * Flush any contained size caches.
146      */

147     public void flush() {
148         if (fCache != null) {
149             fCache.flush();
150         }
151         if (fDockingHandle != null) {
152             fDockingHandle.flush();
153         }
154     }
155
156     /**
157      * Update the visibility of the trim controls.
158      *
159      * @param visible
160      * visible or not.
161      */

162     public void setVisible(boolean visible) {
163         if (fTrim.getControl() != null && !fTrim.getControl().isDisposed()) {
164             fTrim.getControl().setVisible(visible);
165         }
166         if (fDockingHandle != null && fDockingHandle.getControl() != null
167                 && !fDockingHandle.getControl().isDisposed()) {
168             fDockingHandle.getControl().setVisible(visible);
169         }
170     }
171 }
172
Popular Tags