001    //$HeadURL: svn+ssh://rbezema@svn.wald.intevation.org/deegree/base/branches/2.2_testing/src/org/deegree/portal/context/AbstractFrontend.java $ 
002    /*----------------    FILE HEADER  ------------------------------------------
003    
004     This file is part of deegree.
005     Copyright (C) 2001-2008 by:
006     EXSE, Department of Geography, University of Bonn
007     http://www.giub.uni-bonn.de/deegree/
008     lat/lon GmbH
009     http://www.lat-lon.de
010    
011     This library is free software; you can redistribute it and/or
012     modify it under the terms of the GNU Lesser General Public
013     License as published by the Free Software Foundation; either
014     version 2.1 of the License, or (at your option) any later version.
015    
016     This library is distributed in the hope that it will be useful,
017     but WITHOUT ANY WARRANTY; without even the implied warranty of
018     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
019     Lesser General Public License for more details.
020    
021     You should have received a copy of the GNU Lesser General Public
022     License along with this library; if not, write to the Free Software
023     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
024    
025     Contact:
026    
027     Andreas Poth
028     lat/lon GmbH
029     Aennchenstr. 19
030     53115 Bonn
031     Germany
032     E-Mail: poth@lat-lon.de
033    
034     Prof. Dr. Klaus Greve
035     Department of Geography
036     University of Bonn
037     Meckenheimer Allee 166
038     53115 Bonn
039     Germany
040     E-Mail: greve@giub.uni-bonn.de
041    
042     
043     ---------------------------------------------------------------------------*/
044    package org.deegree.portal.context;
045    
046    import java.util.ArrayList;
047    import java.util.List;
048    
049    /**
050     * this class encapsulates the description of the front end of a GUI setting up on a web map
051     * context. this is a deegree specific form of description. beside some
052     * 
053     * @author <a href="mailto:poth@lat-lon.de">Andreas Poth</a>
054     * @author last edited by: $Author: apoth $
055     * 
056     * @version $Revision: 9346 $, $Date: 2007-12-27 17:39:07 +0100 (Do, 27 Dez 2007) $
057     */
058    public abstract class AbstractFrontend implements Frontend {
059    
060        private GUIArea center = null;
061    
062        private GUIArea east = null;
063    
064        private GUIArea north = null;
065    
066        private GUIArea south = null;
067    
068        private GUIArea west = null;
069    
070        private String controller = null;
071    
072        /**
073         * Creates a new Frontend object.
074         * 
075         * @param controller
076         * @param west
077         * @param east
078         * @param south
079         * @param north
080         * @param center
081         */
082        public AbstractFrontend( String controller, GUIArea west, GUIArea east, GUIArea south, GUIArea north, GUIArea center ) {
083            setController( controller );
084            setWest( west );
085            setEast( east );
086            setSouth( south );
087            setNorth( north );
088            setCenter( center );
089        }
090    
091        /**
092         * @return the name of the central controller of the front end. depending on the implementation
093         *         this may be the name of a HTML/JSP-page, a java class or something else.
094         */
095        public String getController() {
096            return controller;
097        }
098    
099        /**
100         * @return the description of the west GUI area
101         */
102        public GUIArea getWest() {
103            return west;
104        }
105    
106        /**
107         * @return the description of the east GUI area
108         */
109        public GUIArea getEast() {
110            return east;
111        }
112    
113        /**
114         * @return the description of the south GUI area
115         */
116        public GUIArea getSouth() {
117            return south;
118        }
119    
120        /**
121         * @return the description of the north GUI area
122         */
123        public GUIArea getNorth() {
124            return north;
125        }
126    
127        /**
128         * @return the description of the central GUI area
129         */
130        public GUIArea getCenter() {
131            return center;
132        }
133    
134        /**
135         * sets the name of the central controller of the front end. depending on the implementation
136         * this may be the name of a HTML/JSP-page a java class or something else.
137         * 
138         * @param controller
139         */
140        public void setController( String controller ) {
141            this.controller = controller;
142        }
143    
144        /**
145         * sets the description of the west GUI area
146         * 
147         * @param west
148         */
149        public void setWest( GUIArea west ) {
150            this.west = west;
151        }
152    
153        /**
154         * sets the description of the east GUI area
155         * 
156         * @param east
157         */
158        public void setEast( GUIArea east ) {
159            this.east = east;
160        }
161    
162        /**
163         * sets the description of the south GUI area
164         * 
165         * @param south
166         */
167        public void setSouth( GUIArea south ) {
168            this.south = south;
169        }
170    
171        /**
172         * sets the description of the north GUI area
173         * 
174         * @param north
175         */
176        public void setNorth( GUIArea north ) {
177            this.north = north;
178        }
179    
180        /**
181         * sets the description of the central GUI area
182         * 
183         * @param center
184         */
185        public void setCenter( GUIArea center ) {
186            this.center = center;
187        }
188    
189        /**
190         * Returns the Modules of the given name (search order is north-east-south-west-center).
191         * 
192         * @param moduleName
193         *            the name of the Module to extract from this Frontend.
194         * @return an array of Modules of the given name. The array length may be 0, if no module of the
195         *         given name is found.
196         */
197        public Module[] getModulesByName( String moduleName ) {
198    
199            List<Module> moduleList = new ArrayList<Module>( 5 );
200    
201            if ( getNorth() != null && getNorth().getModule( moduleName ) != null ) {
202                moduleList.add( getNorth().getModule( moduleName ) );
203            }
204            if ( getEast() != null && getEast().getModule( moduleName ) != null ) {
205                moduleList.add( getEast().getModule( moduleName ) );
206            }
207            if ( getSouth() != null && getSouth().getModule( moduleName ) != null ) {
208                moduleList.add( getSouth().getModule( moduleName ) );
209            }
210            if ( getWest() != null && getWest().getModule( moduleName ) != null ) {
211                moduleList.add( getWest().getModule( moduleName ) );
212            }
213            if ( getCenter() != null && getCenter().getModule( moduleName ) != null ) {
214                moduleList.add( getCenter().getModule( moduleName ) );
215            }
216            return moduleList.toArray( new Module[moduleList.size()] );
217        }
218    
219    }