001    //$HeadURL: https://svn.wald.intevation.org/svn/deegree/base/branches/2.3_testing/src/org/deegree/portal/context/AbstractFrontend.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 java.util.ArrayList;
039    import java.util.List;
040    
041    /**
042     * this class encapsulates the description of the front end of a GUI setting up on a web map
043     * context. this is a deegree specific form of description. beside some
044     *
045     * @author <a href="mailto:poth@lat-lon.de">Andreas Poth</a>
046     * @author last edited by: $Author: mschneider $
047     *
048     * @version $Revision: 18195 $, $Date: 2009-06-18 17:55:39 +0200 (Do, 18. Jun 2009) $
049     */
050    public abstract class AbstractFrontend implements Frontend {
051    
052        private GUIArea center = null;
053    
054        private GUIArea east = null;
055    
056        private GUIArea north = null;
057    
058        private GUIArea south = null;
059    
060        private GUIArea west = null;
061    
062        private String controller = null;
063    
064        /**
065         * Creates a new Frontend object.
066         *
067         * @param controller
068         * @param west
069         * @param east
070         * @param south
071         * @param north
072         * @param center
073         */
074        public AbstractFrontend( String controller, GUIArea west, GUIArea east, GUIArea south, GUIArea north, GUIArea center ) {
075            setController( controller );
076            setWest( west );
077            setEast( east );
078            setSouth( south );
079            setNorth( north );
080            setCenter( center );
081        }
082    
083        /**
084         * @return the name of the central controller of the front end. depending on the implementation
085         *         this may be the name of a HTML/JSP-page, a java class or something else.
086         */
087        public String getController() {
088            return controller;
089        }
090    
091        /**
092         * @return the description of the west GUI area
093         */
094        public GUIArea getWest() {
095            return west;
096        }
097    
098        /**
099         * @return the description of the east GUI area
100         */
101        public GUIArea getEast() {
102            return east;
103        }
104    
105        /**
106         * @return the description of the south GUI area
107         */
108        public GUIArea getSouth() {
109            return south;
110        }
111    
112        /**
113         * @return the description of the north GUI area
114         */
115        public GUIArea getNorth() {
116            return north;
117        }
118    
119        /**
120         * @return the description of the central GUI area
121         */
122        public GUIArea getCenter() {
123            return center;
124        }
125    
126        /**
127         * sets the name of the central controller of the front end. depending on the implementation
128         * this may be the name of a HTML/JSP-page a java class or something else.
129         *
130         * @param controller
131         */
132        public void setController( String controller ) {
133            this.controller = controller;
134        }
135    
136        /**
137         * sets the description of the west GUI area
138         *
139         * @param west
140         */
141        public void setWest( GUIArea west ) {
142            this.west = west;
143        }
144    
145        /**
146         * sets the description of the east GUI area
147         *
148         * @param east
149         */
150        public void setEast( GUIArea east ) {
151            this.east = east;
152        }
153    
154        /**
155         * sets the description of the south GUI area
156         *
157         * @param south
158         */
159        public void setSouth( GUIArea south ) {
160            this.south = south;
161        }
162    
163        /**
164         * sets the description of the north GUI area
165         *
166         * @param north
167         */
168        public void setNorth( GUIArea north ) {
169            this.north = north;
170        }
171    
172        /**
173         * sets the description of the central GUI area
174         *
175         * @param center
176         */
177        public void setCenter( GUIArea center ) {
178            this.center = center;
179        }
180    
181        /**
182         * Returns the Modules of the given name (search order is north-east-south-west-center).
183         *
184         * @param moduleName
185         *            the name of the Module to extract from this Frontend.
186         * @return an array of Modules of the given name. The array length may be 0, if no module of the
187         *         given name is found.
188         */
189        public Module[] getModulesByName( String moduleName ) {
190    
191            List<Module> moduleList = new ArrayList<Module>( 5 );
192    
193            if ( getNorth() != null && getNorth().getModule( moduleName ) != null ) {
194                moduleList.add( getNorth().getModule( moduleName ) );
195            }
196            if ( getEast() != null && getEast().getModule( moduleName ) != null ) {
197                moduleList.add( getEast().getModule( moduleName ) );
198            }
199            if ( getSouth() != null && getSouth().getModule( moduleName ) != null ) {
200                moduleList.add( getSouth().getModule( moduleName ) );
201            }
202            if ( getWest() != null && getWest().getModule( moduleName ) != null ) {
203                moduleList.add( getWest().getModule( moduleName ) );
204            }
205            if ( getCenter() != null && getCenter().getModule( moduleName ) != null ) {
206                moduleList.add( getCenter().getModule( moduleName ) );
207            }
208            return moduleList.toArray( new Module[moduleList.size()] );
209        }
210    
211    }