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;
034:
035: import java.io.File;
036: import java.io.IOException;
037: import java.util.ArrayList;
038: import java.util.Iterator;
039: import java.util.List;
040:
041: import org.jdom.Document;
042: import org.jdom.Element;
043: import org.jdom.JDOMException;
044: import org.jdom.input.SAXBuilder;
045:
046: import com.vividsolutions.jump.workbench.ui.ErrorHandler;
047:
048: public class WorkbenchPropertiesFile implements WorkbenchProperties {
049: private ErrorHandler errorHandler;
050:
051: private Element root;
052:
053: public WorkbenchPropertiesFile(File file, ErrorHandler errorHandler)
054: throws JDOMException, IOException {
055: //alainvm [mav92@tiscali.fr] reports that he needs IOException in the throws
056: //clause. I think he may be using a different version of JDOM.
057: //[Jon Aquino 1/12/2004]
058: SAXBuilder builder = new SAXBuilder();
059: Document document = builder.build(file);
060: root = document.getRootElement();
061: this .errorHandler = errorHandler;
062: }
063:
064: public List getPlugInClasses() {
065: return getPlugInClasses(null); //null invokes default ClassLoader
066: }
067:
068: public List getPlugInClasses(ClassLoader classLoader) {
069: ArrayList plugInClasses = new ArrayList();
070:
071: for (Iterator i = root.getChildren("plug-in").iterator(); i
072: .hasNext();) {
073: Element plugInElement = (Element) i.next();
074: try {
075: plugInClasses.add(Class.forName(plugInElement
076: .getTextTrim(), false, classLoader));
077: } catch (ClassNotFoundException e) {
078: errorHandler.handleThrowable(e);
079: }
080: }
081:
082: return plugInClasses;
083: }
084:
085: public List getInputDriverClasses() throws ClassNotFoundException {
086: ArrayList inputDriverClasses = new ArrayList();
087:
088: for (Iterator i = root.getChildren("input-driver").iterator(); i
089: .hasNext();) {
090: Element inputDriverElement = (Element) i.next();
091: inputDriverClasses.add(Class.forName(inputDriverElement
092: .getTextTrim()));
093: }
094:
095: return inputDriverClasses;
096: }
097:
098: public List getOutputDriverClasses() throws ClassNotFoundException {
099: ArrayList outputDriverClasses = new ArrayList();
100:
101: for (Iterator i = root.getChildren("output-driver").iterator(); i
102: .hasNext();) {
103: Element outputDriverElement = (Element) i.next();
104: outputDriverClasses.add(Class.forName(outputDriverElement
105: .getTextTrim()));
106: }
107:
108: return outputDriverClasses;
109: }
110:
111: public List getConfigurationClasses() throws ClassNotFoundException {
112: ArrayList getConfigurationClasses = new ArrayList();
113:
114: for (Iterator i = root.getChildren("extension").iterator(); i
115: .hasNext();) {
116: Element configurationElement = (Element) i.next();
117: getConfigurationClasses.add(Class
118: .forName(configurationElement.getTextTrim()));
119: }
120:
121: return getConfigurationClasses;
122: }
123: }
|