001    /**
002     * planningtool - A Planning Tool with Critiquing Support.
003     * 
004     * Copyright (C) 2006 olale
005    
006     * This program is free software; you can redistribute it and/or
007     * modify it under the terms of the GNU General Public License
008     * as published by the Free Software Foundation; either version 2
009     * of the License, or (at your option) any later version.
010    
011     * This program is distributed in the hope that it will be useful,
012     * but WITHOUT ANY WARRANTY; without even the implied warranty of
013     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014     * GNU General Public License for more details.
015    
016     * You should have received a copy of the GNU General Public License
017     * along with this program; if not, write to the Free Software
018     * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
019    
020     * Contact information: 
021     * E-mail: olale@ida.liu.se
022     *         olale@lysator.liu.se
023     */
024    package se.liu.ida.critiquer.activities.parameters;
025    
026    import se.liu.ida.critiquer.activities.Activity;
027    
028    
029    public class LocationParameter extends ActivityParameter<Location> implements GeoViewParameter {
030    
031            
032            public enum Type {
033                    /**
034                     * Use this for locations that are the starting point of a transportation activity
035                     */
036                    ORIG_LOC,
037                    /**
038                     * Use this for the destination of a transportation activity
039                     */
040                    DEST_LOC,
041                    /**
042                     * Use this for locations that are not part of transportations
043                     */
044                    STATIC_LOC;
045            }
046    
047            
048            /**
049             * 
050             */
051            private static final long       serialVersionUID        = 1L;
052            private Type type;
053            
054            
055            public LocationParameter(Type type,String name,Activity a){
056                    super(name,a);
057                    this.type=type;
058                    value = new Location(name,this);
059            }
060            
061            @Override
062            public boolean setValue(Location location) {
063                    boolean consistent = Activity.isConsistent(getActivity(), this, value);
064                    if (consistent) {
065                            oldValue=value;
066                            value.removeParam(this);
067                            location.addParam(this);
068                            value=location;
069                            valueChanged();
070                    }
071                    return consistent;
072            }
073            
074            @Override
075            public String toString() {
076                    return name;
077            }
078    
079            /**
080             * @return Returns the type.
081             */
082            public Type getType() {
083                    return type;
084            }
085    
086    }