001    //$HeadURL: svn+ssh://jwilden@svn.wald.intevation.org/deegree/base/branches/2.5_testing/src/org/deegree/portal/context/Module.java $
002    /*----------------------------------------------------------------------------
003     This file is part of deegree, http://deegree.org/
004     Copyright (C) 2001-2009 by:
005     Department of Geography, University of Bonn
006     and
007     lat/lon GmbH
008    
009     This library is free software; you can redistribute it and/or modify it under
010     the terms of the GNU Lesser General Public License as published by the Free
011     Software Foundation; either version 2.1 of the License, or (at your option)
012     any later version.
013     This library is distributed in the hope that it will be useful, but WITHOUT
014     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
015     FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
016     details.
017     You should have received a copy of the GNU Lesser General Public License
018     along with this library; if not, write to the Free Software Foundation, Inc.,
019     59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
020    
021     Contact information:
022    
023     lat/lon GmbH
024     Aennchenstr. 19, 53177 Bonn
025     Germany
026     http://lat-lon.de/
027    
028     Department of Geography, University of Bonn
029     Prof. Dr. Klaus Greve
030     Postfach 1147, 53001 Bonn
031     Germany
032     http://www.geographie.uni-bonn.de/deegree/
033    
034     e-mail: info@deegree.org
035     ----------------------------------------------------------------------------*/
036    package org.deegree.portal.context;
037    
038    import org.deegree.framework.util.Parameter;
039    import org.deegree.framework.util.ParameterList;
040    
041    /**
042     * this class encapsulates the basic informations of a module that is part of an area of the GUI. Other classes may
043     * extent this class by adding special attributes for more specialazied GUIs.
044     * 
045     * @author <a href="mailto:poth@lat-lon.de">Andreas Poth</a>
046     * @author last edited by: $Author: jmays $
047     * 
048     * @version $Revision: 23790 $, $Date: 2010-04-23 14:22:04 +0200 (Fr, 23 Apr 2010) $
049     */
050    public class Module {
051        private ModuleConfiguration moduleConfiguration = null;
052    
053        private String content = null;
054    
055        private String name = null;
056    
057        private String title = null;
058    
059        private boolean hidden = false;
060    
061        private ParameterList parameterList = null;
062    
063        private String type = "content";
064    
065        private int width = 0;
066    
067        private int height = 0;
068    
069        private int left = 0;
070    
071        private int right = 0;
072    
073        private int top = 0;
074    
075        private int bottom = 0;
076    
077        private boolean header;
078    
079        private boolean closable;
080    
081        private boolean overlay;
082        
083        private boolean collapsed;
084    
085        private String[] moduleJSList = new String[0];
086    
087        private String scrolling = "auto";
088        
089        /**
090         * @deprecated use other constructor with extra parameter for collapsed state
091         */
092        @Deprecated 
093        public Module( String name, String title, String content, boolean hidden, String type, int left, int top,
094                       int right, int bottom, int width, int height, boolean overlay, boolean header, boolean closable,
095                       String scrolling, String[] moduleJSList, ModuleConfiguration moduleConfiguration,
096                       ParameterList parameterList ) {
097            this( name, title, content, hidden, type, left, top, right, bottom, width, height, overlay, header, closable,
098                  false, scrolling, moduleJSList, moduleConfiguration, parameterList );
099        }
100    
101        /**
102         * Creates a new Module object.
103         * 
104         * @param name
105         *            name of the module
106         * @param title
107         *            title of the module
108         * @param content
109         *            the name of the page/class/file etc. containing the content of the module
110         * @param hidden
111         *            indicates if the module is visible or not
112         * @param type
113         * @param left
114         * @param top
115         * @param right
116         * @param bottom
117         * @param width
118         * @param height
119         * @param overlay
120         * @param header
121         * @param closable
122         * @param collapsed
123         *            the state of the module in table layout of ExtJS. default is false
124         * @param scrolling
125         * @param moduleJSList
126         * @param moduleConfiguration
127         *            encapsulates the access to the modules configuration (may be <tt>null</tt>)
128         * @param parameterList
129         */
130        public Module( String name, String title, String content, boolean hidden, String type, int left, int top, int right,
131                       int bottom, int width, int height, boolean overlay, boolean header, boolean closable, boolean collapsed, 
132                       String scrolling, String[] moduleJSList, ModuleConfiguration moduleConfiguration, ParameterList parameterList ) {
133            setName( name );
134            setTitle( title );
135            setContent( content );
136            setHidden( hidden );
137            setModuleConfiguration( moduleConfiguration );
138            setParameter( parameterList );
139            setType( type );
140            setWidth( width );
141            setHeight( height );
142            setLeft( left );
143            setTop( top );
144            setRight( right );
145            setHeader( header );
146            setClosable( closable );
147            setCollapsed( collapsed );
148            setOverlay( overlay );
149            setBottom( bottom );
150            setModuleJSList( moduleJSList );
151            setScrolling( scrolling );
152        }
153    
154        /**
155         * returns the name of a module
156         * 
157         * @return the name of a module
158         */
159        public String getName() {
160            return name;
161        }
162    
163        /**
164         * sets the name of a module
165         * 
166         * @param name
167         */
168        public void setName( String name ) {
169            this.name = name;
170        }
171    
172        /**
173         * @return the title
174         */
175        public String getTitle() {
176            return title;
177        }
178    
179        /**
180         * @param title
181         *            the title to set; if <code>title</code> == <code>null</code> the modules name will be used as title
182         */
183        public void setTitle( String title ) {
184            if ( title == null ) {
185                this.title = name;
186            } else {
187                this.title = title;
188            }
189        }
190    
191        /**
192         * returns the name of the page/class/file etc. containing the content of the module
193         * 
194         * @return the name of the page/class/file etc. containing the content of the module
195         */
196        public String getContent() {
197            return content;
198        }
199    
200        /**
201         * sets the name of the page/class/file etc. containing the content of the module
202         * 
203         * @param content
204         */
205        public void setContent( String content ) {
206            this.content = content;
207        }
208    
209        /**
210         * returns true if the module is hidden. this will always be the case for modules that just offers functions to the
211         * context. visible modules may offere the capability to be turned to visible or not.
212         * 
213         * @return <code>true</code> if the module is hidden.
214         */
215        public boolean isHidden() {
216            return hidden;
217        }
218    
219        /**
220         * sets the module to be hidden or visible. modules that only adds functions to a context will ignore this because
221         * they are always hidden
222         * 
223         * @param hidden
224         */
225        public void setHidden( boolean hidden ) {
226            this.hidden = hidden;
227        }
228    
229        /**
230         * returns the a specific confguration for a module. This may be <tt>null</tt> if the module doesn't need to be
231         * configured.
232         * 
233         * @return the a specific confguration for a module. This may be <code>null</code>if the module doesn't need to be
234         *         configured.
235         */
236        public ModuleConfiguration getModuleConfiguration() {
237            return moduleConfiguration;
238        }
239    
240        /**
241         * sets the specific configuration for a module.
242         * 
243         * @param configuration
244         */
245        public void setModuleConfiguration( ModuleConfiguration configuration ) {
246            this.moduleConfiguration = configuration;
247        }
248    
249        /**
250         * returns a list of parameters that will be passed to a class/object etc. that represents a module
251         * 
252         * @return parameters
253         */
254        public ParameterList getParameter() {
255            return parameterList;
256        }
257    
258        /**
259         * sets a list of parameters that will be passed to a class/object etc. that represents a module
260         * 
261         * @param parameterList
262         */
263        public void setParameter( ParameterList parameterList ) {
264            this.parameterList = parameterList;
265        }
266    
267        /**
268         * adds a parameter to the list of parameters that will be passed to a class/object etc. that represents a module
269         * 
270         * @param parameter
271         */
272        public void addParameter( Parameter parameter ) {
273            parameterList.addParameter( parameter );
274        }
275    
276        /**
277         * removes a parameter to the list of parameters that will be passed to a class/object etc. that represents a module
278         * 
279         * @param name
280         */
281        public void removeParameter( String name ) {
282            parameterList.removeParameter( name );
283        }
284    
285        /**
286         * see also org.deegree.clients.context.Module#setType(java.lang.String)
287         * 
288         * @param type
289         *            to set
290         */
291        public void setType( String type ) {
292            if ( type != null ) {
293                this.type = type.toLowerCase();
294            }
295        }
296    
297        /**
298         * see also org.deegree.clients.context.Module#getType()
299         * 
300         * @return the type.
301         */
302        public String getType() {
303            return type;
304        }
305    
306        /**
307         * returns the width of the module in the GUI. If '0' will be returned the GUI can set the with like it is best
308         * 
309         * @return the width of the module in the GUI. If '0' will be returned the GUI can set the with like it is best
310         */
311        public int getWidth() {
312            return this.width;
313        }
314    
315        /**
316         * sets the desired width of the module in the GUI. If '0' ist passed the GUI can set the with like it is best
317         * 
318         * @param width
319         *            desired width of the module
320         */
321        public void setWidth( int width ) {
322            this.width = width;
323        }
324    
325        /**
326         * returns the height of the module in the GUI. If '0' will be returned the GUI can set the with like it is best
327         * 
328         * @return the height of the module in the GUI. If '0' will be returned the GUI can set the with like it is best
329         */
330        public int getHeight() {
331            return this.height;
332        }
333    
334        /**
335         * sets the desired height of the module in the GUI. If '0' ist passed the GUI can set the with like it is best
336         * 
337         * @param height
338         *            desired width of the module
339         */
340        public void setHeight( int height ) {
341            this.height = height;
342        }
343    
344        /**
345         * @return the bottom
346         */
347        public int getBottom() {
348            return bottom;
349        }
350    
351        /**
352         * @param bottom
353         *            the bottom to set
354         */
355        public void setBottom( int bottom ) {
356            this.bottom = bottom;
357        }
358    
359        /**
360         * @return the left
361         */
362        public int getLeft() {
363            return left;
364        }
365    
366        /**
367         * @param left
368         *            the left to set
369         */
370        public void setLeft( int left ) {
371            this.left = left;
372        }
373    
374        /**
375         * @return the right
376         */
377        public int getRight() {
378            return right;
379        }
380    
381        /**
382         * @param right
383         *            the right to set
384         */
385        public void setRight( int right ) {
386            this.right = right;
387        }
388    
389        /**
390         * @return the top
391         */
392        public int getTop() {
393            return top;
394        }
395    
396        /**
397         * @param top
398         *            the top to set
399         */
400        public void setTop( int top ) {
401            this.top = top;
402        }
403    
404        /**
405         * @return the closable
406         */
407        public boolean isClosable() {
408            return closable;
409        }
410    
411        /**
412         * @param closable
413         *            the closable to set
414         */
415        public void setClosable( boolean closable ) {
416            this.closable = closable;
417        }
418    
419        /**
420         * @return the header
421         */
422        public boolean hasHeader() {
423            return header;
424        }
425    
426        /**
427         * @param header
428         *            the header to set
429         */
430        public void setHeader( boolean header ) {
431            this.header = header;
432        }
433    
434        /**
435         * @return the overlay
436         */
437        public boolean isOverlay() {
438            return overlay;
439        }
440    
441        /**
442         * @param overlay
443         *            the overlay to set
444         */
445        public void setOverlay( boolean overlay ) {
446            this.overlay = overlay;
447        }
448    
449        /**
450         * @return moduleJSList
451         */
452        public String[] getModuleJSList() {
453            return moduleJSList;
454        }
455    
456        /**
457         * @param list
458         */
459        public void setModuleJSList( String[] list ) {
460            this.moduleJSList = list;
461        }
462    
463        /**
464         * return true is the module should has scrollbars in the GUI<br>
465         * possible values are
466         * <UL>
467         * <li>no
468         * <li>yes
469         * <li>auto
470         * </UL>
471         * default is auto
472         * 
473         * @return <code>true</code> is the module should has scrollbars in the GUI possible values are
474         */
475        public String getScrolling() {
476            return scrolling;
477        }
478    
479        /**
480         * @see #getScrolling()
481         * @param scrollable
482         */
483        public void setScrolling( String scrollable ) {
484            this.scrolling = scrollable;
485        }
486    
487        /**
488         * @param collapsed
489         *            default value is false
490         */
491        public void setCollapsed( boolean collapsed ) {
492            this.collapsed = collapsed;
493        }
494    
495        /**
496         * @return collapsed
497         */
498        public boolean isCollapsed() {
499            return collapsed;
500        }
501    }