001: /*
002: * The Unified Mapping Platform (JUMP) is an extensible, interactive GUI
003: * for visualizing and manipulating spatial features with geometry and attributes.
004: *
005: * Copyright (C) 2003 Vivid Solutions
006: *
007: * This program is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU General Public License
009: * as published by the Free Software Foundation; either version 2
010: * of the License, or (at your option) any later version.
011: *
012: * This program is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
015: * GNU General Public License for more details.
016: *
017: * You should have received a copy of the GNU General Public License
018: * along with this program; if not, write to the Free Software
019: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
020: *
021: * For more information, contact:
022: *
023: * Vivid Solutions
024: * Suite #1A
025: * 2328 Government Street
026: * Victoria BC V8T 5G5
027: * Canada
028: *
029: * (250)385-6040
030: * www.vividsolutions.com
031: */
032:
033: package com.vividsolutions.jump.workbench.model;
034:
035: import java.io.File;
036: import java.util.ArrayList;
037: import java.util.Collection;
038: import java.util.Iterator;
039:
040: /**
041: * Whatever the user needs to do a particular task. Currently a thin wrapper
042: * around a LayerManager.
043: */
044: //I wonder if this class should be named "Project" instead. [Jon Aquino]
045: public class Task implements LayerManagerProxy {
046: private String name = "";
047: private ArrayList nameListeners = new ArrayList();
048: private File projectFile = null;
049:
050: //No parameters so it can be created by Java2XML.
051: public Task() {
052: layerManager = new LayerManager();
053: }
054:
055: private LayerManager layerManager;
056:
057: public void add(NameListener nameListener) {
058: nameListeners.add(nameListener);
059: }
060:
061: public void setName(String name) {
062: this .name = name;
063: fireNameChanged(name);
064: }
065:
066: public void setProjectFile(File projectFile) {
067: this .projectFile = projectFile;
068: }
069:
070: public LayerManager getLayerManager() {
071: return layerManager;
072: }
073:
074: public File getProjectFile() {
075: return projectFile;
076: }
077:
078: public String toString() {
079: return getName();
080: }
081:
082: public String getName() {
083: return name;
084: }
085:
086: private void fireNameChanged(String name) {
087: for (Iterator i = nameListeners.iterator(); i.hasNext();) {
088: NameListener nameListener = (NameListener) i.next();
089: nameListener.taskNameChanged(name);
090: }
091: }
092:
093: public Collection getCategories() {
094: return getLayerManager().getCategories();
095: }
096:
097: /**
098: * Called by Java2XML
099: */
100: public void addCategory(Category category) {
101: getLayerManager().addCategory(category.getName());
102:
103: Category actual = getLayerManager().getCategory(
104: category.getName());
105:
106: for (Iterator i = category.getLayerables().iterator(); i
107: .hasNext();) {
108: Layerable layerable = (Layerable) i.next();
109: actual.addPersistentLayerable(layerable);
110: }
111: }
112:
113: /**
114: * Interface: NameListener must respond to task name changing.
115: */
116: public static interface NameListener {
117: public void taskNameChanged(String name);
118: }
119:
120: }
|