Revision 38749

View differences:

tags/v2_0_0_Build_2051/libraries/org.gvsig.exportto/prepare-workspace.xml
1
<project name="org.gvsig.initial.build" default="prepare-workspace">
2

  
3
	<dirname property="org.gvsig.initial.build.basedir" file="${ant.file.org.gvsig.initial.build}" />
4

  
5
	<property name="workspace.basedir" value="${org.gvsig.initial.build.basedir}/.." />
6
	<property name="build.basedir" value="${workspace.basedir}/org.gvsig.maven.base.build" description="Eclipse workspace location" />
7
	<property name="build.jar.version" value="1.0.8-SNAPSHOT" />
8
	<property name="build.jar.file" value="org.gvsig.maven.base.build-${build.jar.version}.jar" />
9

  
10
	<property name="ant.libs.dir" location="${build.basedir}" description="Additional ant tasks libs folder" />
11

  
12
	<target name="check-maven-base-build-available">
13
		<available file="${user.home}/.m2/repository/org/gvsig/org.gvsig.maven.base.build/${build.jar.version}/${build.jar.file}" property="maven-base-build-available" />
14
	</target>
15

  
16
	<target name="get-maven-base-build-local" depends="check-maven-base-build-available" if="maven-base-build-available">
17
		<!-- Unzip de build jar file from the maven repository into the workspace root folder -->
18
		<copy todir="${workspace.basedir}" preservelastmodified="false" filtering="false">
19
			<zipfileset src="${user.home}/.m2/repository/org/gvsig/org.gvsig.maven.base.build/${build.jar.version}/${build.jar.file}">
20
				<patternset>
21
					<exclude name="META-INF/**" />
22
				</patternset>
23
			</zipfileset>
24
		</copy>
25
	</target>
26

  
27
	<target name="get-maven-base-build-remote" depends="check-maven-base-build-available" unless="maven-base-build-available">
28
		<mkdir dir="target" />
29

  
30
		<!-- Download the build jar file -->
31
		<get src="http://devel.gvsig.org/m2repo/j2se/org/gvsig/org.gvsig.maven.base.build/${build.jar.version}/${build.jar.file}" dest="target/${build.jar.file}" verbose="true" />
32

  
33
		<!-- Unzip de build jar file into the workspace root folder -->
34
		<copy todir="${workspace.basedir}" preservelastmodified="false" filtering="false">
35
			<zipfileset src="target/${build.jar.file}">
36
				<patternset>
37
					<exclude name="META-INF/**" />
38
				</patternset>
39
			</zipfileset>
40
		</copy>
41

  
42
	</target>
43
	
44
	<target name="find.depends.natives.file">
45
	    <condition property="depends.natives.file.exists">
46
            <available file="${org.gvsig.initial.build.basedir}/DEPENDS_ON_NATIVE_LIBRARIES"/>
47
	    </condition>	
48
	</target>
49
	
50
	<target name="find.gvsig.platform.properties.file" 
51
			depends="find.depends.natives.file"
52
			if="depends.natives.file.exists">
53
	    <condition property="gvsig.platform.exists">
54
            <available file="${user.home}/.gvsig.platform.properties"/>
55
	    </condition>	
56
	</target>
57
	
58
	<target name="check.gvsig.platform.properties" 
59
			depends="find.gvsig.platform.properties.file">
60
		<fail if="depends.natives.file.exists" unless="gvsig.platform.exists">
61
ERROR!!
62
	
63
You have to define your gvSIG platform properties, 
64
by creating the file: ${user.home}/.gvsig.platform.properties
65
with the following content:
66

  
67
native_platform=linux
68
native_distribution=all
69
native_compiler=gcc4
70
native_arch=i386
71
native_libraryType=dynamic
72
export native_classifier=${native_platform}-${native_distribution}-${native_compiler}-${native_arch}-${native_libraryType}
73

  
74
Replace the fifth initial variables values with the ones appropiate 
75
to your platform.
76
	
77
If you use maven in the command line, you can use the previous file also
78
to define the MAVEN_OPTS environment variable, by adding to your 
79
.bash_rc file something like this:
80

  
81
if [ -f "${HOME}/.gvsig.platform.properties" ]
82
then
83
    . ${HOME}/.gvsig.platform.properties
84
    export MAVEN_OPTS="-Xmx256M -XX:MaxPermSize=64m -Dnative-classifier=${native_classifier}"
85
else
86
    export MAVEN_OPTS="-Xmx256M -XX:MaxPermSize=64m"
87
fi
88

  
89
It will work if you use the bash shell. In any other case or platform, you'll
90
have to define your MAVEN_OPTS environment variable and set the 
91
"native-classifier" parameter directly.
92
		</fail>			
93
	
94
	</target>
95

  
96
	<target name="prepare-workspace" depends="get-maven-base-build-local,get-maven-base-build-remote,check.gvsig.platform.properties">
97

  
98
		<mkdir dir="target" />
99

  
100
		<chmod dir="${build.basedir}/maven/bin" perm="u+x" includes="m2,mvn,mvnDebug" />
101

  
102
		<!-- Copy the maven launchers to the workspace metadata folder -->
103
		<copy todir="${workspace.basedir}/.metadata">
104
			<fileset dir="${build.basedir}/eclipse-launchers">
105
				<exclude name="**/org.eclipse.jdt.core.prefs" />
106
				<exclude name="**/org.eclipse.core.variables.prefs" />
107
			</fileset>
108
		</copy>
109

  
110
		<concat destfile="${workspace.basedir}/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.core.prefs" append="true">
111
			<filelist dir="${build.basedir}/eclipse-launchers/.plugins/org.eclipse.core.runtime/.settings" files="org.eclipse.jdt.core.prefs" />
112
		</concat>
113
		<concat destfile="${workspace.basedir}/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.variables.prefs" append="true">
114
			<filelist dir="${build.basedir}/eclipse-launchers/.plugins/org.eclipse.core.runtime/.settings" files="org.eclipse.core.variables.prefs" />
115
		</concat>
116

  
117
		<!-- Configure the eclipse workspace -->
118
		<ant antfile="${build.basedir}/maven-goals.xml" target="mvn-configure-eclipse-workspace" />
119

  
120
		<!-- Configure the gvSIG profile -->
121
		<ant antfile="${build.basedir}/check-gvsig-profile.xml" />
122

  
123
		<property name="user-settings-file-location" value="${user.home}/.m2/settings.xml" />
124

  
125
		<taskdef name="xmltask" classname="com.oopsconsultancy.xmltask.ant.XmlTask">
126
			<classpath>
127
				<pathelement location="${ant.libs.dir}/com.oopsconsultancy.xmltask-1.16.1.jar" />
128
			</classpath>
129
		</taskdef>
130

  
131
		<xmltask source="${user-settings-file-location}" dest="${user-settings-file-location}">
132
			<copy path="//:settings/:profiles/:profile[:id/text() = 'gvsig-install']/:properties/:gvsig.install.dir/text()" property="current-gvsig-location" />
133
		</xmltask>
134

  
135
		<replace file="${workspace.basedir}/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.core.prefs" token="@GVSIG_HOME@" value="${current-gvsig-location}" />
136
		<replace file="${workspace.basedir}/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.variables.prefs" token="@GVSIG_HOME@" value="${current-gvsig-location}" />
137

  
138
		<!-- Compile, install and generate eclipse projects -->
139
		<ant antfile="${build.basedir}/maven-goals.xml" target="mvn-install-and-eclipse-eclipse" />
140

  
141
		<echo>INFORMATION!!!</echo>
142
		<echo>Restart eclipse and then proceed to import the subprojects contained into the main project</echo>
143

  
144
		<!-- TODO: copiar al proyecto de configuraciĆ³n general -->
145
	</target>
146

  
147
	<target name="clean">
148
		<delete dir="target" />
149
	</target>
150
	
151
</project>
0 152

  
tags/v2_0_0_Build_2051/libraries/org.gvsig.exportto/pom.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2

  
3
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5
	<modelVersion>4.0.0</modelVersion>
6
	<artifactId>org.gvsig.exportto</artifactId>
7
	<packaging>pom</packaging>
8
	<version>1.0.0-SNAPSHOT</version>
9
	<name>org.gvsig.exportto</name>
10
	<description>Exportto example project</description>
11
	<parent>
12
		<groupId>org.gvsig</groupId>
13
		<artifactId>org.gvsig.maven.base.pom</artifactId>
14
		<version>1.0.8-SNAPSHOT</version>
15
	</parent>
16

  
17
    <scm>
18
        <connection>scm:svn:https://devel.gvsig.org/svn/gvsig-desktop/branches/v2_0_0_prep/libraries/org.gvsig.exportto</connection>
19
        <developerConnection>scm:svn:https://devel.gvsig.org/svn/gvsig-desktop/branches/v2_0_0_prep/libraries/org.gvsig.exportto</developerConnection>
20
        <url>https://devel.gvsig.org/redmine/projects/gvsig-desktop/repository/show/branches/v2_0_0_prep/libraries/org.gvsig.exportto</url>
21
    </scm>
22

  
23
	<developers>
24
        <developer>
25
            <id>jpiera</id>
26
            <name>Jorge Piera</name>
27
            <email>jpiera@gvsig.org</email>
28
            <roles>
29
                <role>Architect</role>
30
                <role>Developer</role>
31
            </roles>
32
        </developer>
33
        <developer>
34
            <id>jjdelcerro</id>
35
            <name>Joaqu?n Jos? del Cerro</name>
36
            <email>jjdelcerro@gvsig.org</email>
37
            <roles>
38
                <role>Architect</role>          
39
            </roles>
40
        </developer>        
41
    </developers>
42
	<repositories>
43
		<repository>
44
			<id>gvsig-public-http-repository</id>
45
			<name>gvSIG maven public HTTP repository</name>
46
            <url>http://devel.gvsig.org/m2repo/j2se</url>
47
			<releases>
48
				<enabled>true</enabled>
49
				<updatePolicy>daily</updatePolicy>
50
				<checksumPolicy>warn</checksumPolicy>
51
			</releases>
52
			<snapshots>
53
				<enabled>true</enabled>
54
				<updatePolicy>daily</updatePolicy>
55
				<checksumPolicy>warn</checksumPolicy>
56
			</snapshots>
57
		</repository>
58
	</repositories>
59
	<dependencyManagement>
60
		<dependencies>			
61
            <dependency>
62
                <groupId>org.gvsig</groupId>
63
                <artifactId>org.gvsig.core.maven.dependencies</artifactId>
64
                <version>2.0.1-SNAPSHOT</version>
65
                <type>pom</type>
66
                <scope>import</scope>
67
            </dependency>
68
		</dependencies>
69
	</dependencyManagement>
70

  
71
	<dependencies>
72
		<dependency>
73
			<groupId>org.gvsig</groupId>
74
			<artifactId>org.gvsig.tools.lib</artifactId>
75
		</dependency>
76
		<dependency>
77
			<groupId>org.gvsig</groupId>
78
			<artifactId>org.gvsig.tools.lib</artifactId>
79
			<type>test-jar</type>
80
		</dependency>
81
		
82
		<!-- 
83
        <dependency>
84
            <groupId>org.gvsig</groupId>
85
            <artifactId>org.gvsig.geodb</artifactId>
86
            <version>2.0-SNAPSHOT</version>
87
            <scope>compile</scope>
88
        </dependency>
89
         -->
90
	</dependencies>
91

  
92
	<modules>
93
		<module>org.gvsig.exportto.lib</module>
94
		<module>org.gvsig.exportto.swing</module>
95
		<module>org.gvsig.exportto.main</module>
96
	</modules>
97

  
98
</project>
0 99

  
tags/v2_0_0_Build_2051/libraries/org.gvsig.exportto/README.txt
1
The first time you checkout the current project to a new workspace, 
2
you have to prepare it to be able to work easily with maven from
3
eclipse itself.
4

  
5
Perform the following steps:
6

  
7
1.- Launch the *prepare-workspace.xml* ant build file. 
8
    You can do it by loading the file into the ant view, 
9
    and running the default task, or right-clicking the 
10
    file from the package explorer or the navigator and
11
    select the option: *Run as > Ant build*. 
12
    
13
2.- Restart eclipse.
14

  
15
3.- Import the subprojects of the project you have just checked out.
16

  
17
Those steps are only needed once per workspace.     
18

  
0 19

  
tags/v2_0_0_Build_2051/libraries/org.gvsig.exportto/org.gvsig.exportto.main/src/main/resources/README.txt
1
Put into this folder the resources needed by your classes.
2

  
3
This folder is added to the classpath, so you can load any resources 
4
through the ClassLoader.
5

  
6
By default, in this folder you can find an example of log4j configuration,
7
prepared to log messages through the console, so logging works when you
8
run your classes.
0 9

  
tags/v2_0_0_Build_2051/libraries/org.gvsig.exportto/org.gvsig.exportto.main/src/main/resources/log4j.xml
1
<?xml version="1.0" encoding="ISO-8859-1" ?>
2
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
3

  
4
<!-- 
5
Log4J configuration file for unit tests execution.
6
 -->
7
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
8

  
9
	<!-- Appender configuration to show logging messages through the console -->
10
	<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
11
		<layout class="org.apache.log4j.PatternLayout">
12
			<param name="ConversionPattern" value="%d{HH:mm:ss,SSS} %-5p [%c{2}.%M()]\n  %m%n" />
13
		</layout>
14
	</appender>
15

  
16
	<!-- 
17
	Activate logging messages of DEBUG level of higher only for the
18
	org.gvsig.tools packages.
19
	You can put full classes names or packages instead, to configure
20
	logging for all the classes and subpackages of the package.
21
	-->
22
	<category name="org.gvsig.tools">
23
		<priority value="DEBUG" />
24
	</category>
25
	<category name="org.gvsig.exportto">
26
		<priority value="DEBUG" />
27
	</category>
28

  
29
	<!-- 
30
	By default, show only logging messages of INFO level or higher, 
31
	through the previously configured CONSOLE appender. 
32
	-->
33
	<root>
34
		<priority value="INFO" />
35
		<appender-ref ref="CONSOLE" />
36
	</root>
37
</log4j:configuration>
0 38

  
tags/v2_0_0_Build_2051/libraries/org.gvsig.exportto/org.gvsig.exportto.main/src/main/java/org/gvsig/exportto/main/package.html
1
<?xml version="1.0" encoding="UTF-8" ?>
2
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
<html xmlns="http://www.w3.org/1999/xhtml">
4
<head>
5
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6
<title>org.gvsig.exportto package documentation</title>
7
</head>
8
<body>
9

  
10
	<p>Exportto library testing and demo application.</p>
11

  
12
</body>
13
</html>
0 14

  
tags/v2_0_0_Build_2051/libraries/org.gvsig.exportto/org.gvsig.exportto.main/src/main/java/org/gvsig/exportto/main/Main.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.exportto.main;
23

  
24
import java.awt.BorderLayout;
25
import java.awt.Dimension;
26
import java.awt.event.ActionEvent;
27

  
28
import javax.swing.AbstractAction;
29
import javax.swing.Action;
30
import javax.swing.JButton;
31
import javax.swing.JFrame;
32
import javax.swing.JMenu;
33
import javax.swing.JMenuBar;
34
import javax.swing.JMenuItem;
35
import javax.swing.JToolBar;
36
import javax.swing.WindowConstants;
37

  
38
import org.slf4j.Logger;
39
import org.slf4j.LoggerFactory;
40

  
41
import org.gvsig.exportto.ExporttoLocator;
42
import org.gvsig.exportto.ExporttoManager;
43
import org.gvsig.exportto.swing.ExporttoSwingLocator;
44
import org.gvsig.exportto.swing.ExporttoSwingManager;
45
import org.gvsig.exportto.swing.ExporttoWindowManager;
46
import org.gvsig.exportto.swing.JExporttoServicePanel;
47
import org.gvsig.exportto.swing.preferences.ExporttoSwingPreferencesComponent;
48
import org.gvsig.exportto.swing.spi.ExporttoSwingProviderLocator;
49
import org.gvsig.fmap.crs.CRSFactory;
50
import org.gvsig.fmap.dal.DALLocator;
51
import org.gvsig.fmap.dal.DataManager;
52
import org.gvsig.fmap.dal.DataStoreParameters;
53
import org.gvsig.fmap.dal.exception.InitializeException;
54
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException;
55
import org.gvsig.fmap.dal.exception.ValidateDataParametersException;
56
import org.gvsig.fmap.dal.feature.FeatureStore;
57
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer;
58

  
59
/**
60
 * Main executable class for testing the Exportto library.
61
 * 
62
 * @author gvSIG Team
63
 * @version $Id$
64
 */
65
public class Main {
66

  
67
    private static final Logger LOG = LoggerFactory.getLogger(Main.class);
68

  
69
    private ExporttoManager manager;
70
    private ExporttoSwingManager swingManager;
71
    private DataManager dataManager;
72

  
73
    public static void main(String args[]) {
74
        new DefaultLibrariesInitializer().fullInitialize();
75
        Main main = new Main();
76
        main.show();
77
    }
78

  
79
    @SuppressWarnings("serial")
80
    public void show() {
81
        manager = ExporttoLocator.getManager();
82
        swingManager = ExporttoSwingLocator.getSwingManager();
83
        dataManager = DALLocator.getDataManager();
84

  
85
        Action showCookie = new AbstractAction("Get a Exportto") {
86

  
87
            public void actionPerformed(ActionEvent e) {
88
                showExportto(manager);
89
            }
90
        };
91

  
92
        Action preferences = new AbstractAction("Exportto preferences") {
93

  
94
            public void actionPerformed(ActionEvent e) {
95
                showExporttoPreferences();
96
            }
97

  
98
        };
99

  
100
        Action exit = new AbstractAction("Exit") {
101

  
102
            public void actionPerformed(ActionEvent e) {
103
                System.exit(0);
104
            }
105
        };
106

  
107
        JFrame frame = new JFrame("Exportto example app");
108
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
109

  
110
        // Create the menu bar.
111
        JMenuBar menuBar = new JMenuBar();
112

  
113
        // Build the menu.
114
        JMenu menuFile = new JMenu("File");
115
        menuFile.add(new JMenuItem(showCookie));
116
        menuFile.add(new JMenuItem(preferences));
117
        menuFile.add(new JMenuItem(exit));
118

  
119
        menuBar.add(menuFile);
120

  
121
        JToolBar toolBar = new JToolBar();
122
        toolBar.add(new JButton(showCookie));
123
        toolBar.add(new JButton(exit));
124

  
125
        frame.setPreferredSize(new Dimension(200, 100));
126
        frame.setJMenuBar(menuBar);
127
        frame.add(toolBar, BorderLayout.PAGE_START);
128

  
129
        // Display the window.
130
        frame.pack();
131
        frame.setVisible(true);
132
    }
133

  
134
    private void showExporttoPreferences() {
135
        ExporttoSwingPreferencesComponent preferences =
136
            ExporttoSwingProviderLocator.getManager()
137
                .createExporttoSwingProvidersPreferences();
138

  
139
        JFrame preferencesFrame = new JFrame("Export to preferences");
140
        preferencesFrame.add(preferences.asJComponent());
141

  
142
        preferencesFrame.pack();
143
        preferencesFrame.setVisible(true);
144
    }
145

  
146
    public void showExportto(ExporttoManager manager) {
147
        try {
148
            JExporttoServicePanel panel =
149
                swingManager.createExportto(createFeatureStore(),
150
                    CRSFactory.getCRS("EPSG:23030"));
151
            panel.setPreferredSize(new Dimension(800, 400));
152
            swingManager.getWindowManager().showWindow(panel, "Exportto",
153
                ExporttoWindowManager.MODE_WINDOW);
154
        } catch (ValidateDataParametersException e) {
155
            LOG.error("Error showing a Exportto", e);
156
        } catch (InitializeException e) {
157
            LOG.error("Error showing a Exportto", e);
158
        } catch (ProviderNotRegisteredException e) {
159
            LOG.error("Error showing a Exportto", e);
160
        }
161
    }
162

  
163
    private FeatureStore createFeatureStore() throws InitializeException,
164
        ProviderNotRegisteredException, ValidateDataParametersException {
165
        String sourceFileName =
166
            getClass().getClassLoader()
167
                .getResource("org/gvsig/exportto/data/andalucia.shp").getFile();
168
        DataStoreParameters sourceParameters =
169
            dataManager.createStoreParameters("Shape");
170
        sourceParameters.setDynValue("shpfile", sourceFileName);
171
        sourceParameters.setDynValue("crs", CRSFactory.getCRS("EPSG:23030"));
172
        return (FeatureStore) dataManager.openStore("Shape", sourceParameters);
173
    }
174
}
0 175

  
tags/v2_0_0_Build_2051/libraries/org.gvsig.exportto/org.gvsig.exportto.main/pom.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4
    <modelVersion>4.0.0</modelVersion>
5
    <artifactId>org.gvsig.exportto.main</artifactId>
6
    <packaging>jar</packaging>
7
    <name>org.gvsig.exportto.main</name>
8
    <parent>
9
        <groupId>org.gvsig</groupId>
10
        <artifactId>org.gvsig.exportto</artifactId>
11
        <version>1.0.0-SNAPSHOT</version>
12
    </parent>
13
    <dependencies>
14
        <dependency>
15
            <groupId>org.gvsig</groupId>
16
            <artifactId>org.gvsig.exportto.lib.api</artifactId>
17
            <version>1.0.0-SNAPSHOT</version>
18
        </dependency>
19
        <dependency>
20
            <groupId>org.gvsig</groupId>
21
            <artifactId>org.gvsig.exportto.lib.impl</artifactId>
22
            <version>1.0.0-SNAPSHOT</version>
23
            <scope>runtime</scope>
24
        </dependency>
25
        <dependency>
26
            <groupId>org.gvsig</groupId>
27
            <artifactId>org.gvsig.exportto.swing.api</artifactId>
28
            <version>1.0.0-SNAPSHOT</version>
29
        </dependency>
30
        <dependency>
31
            <groupId>org.gvsig</groupId>
32
            <artifactId>org.gvsig.exportto.swing.spi</artifactId>
33
            <version>1.0.0-SNAPSHOT</version>
34
        </dependency>
35
        <dependency>
36
            <groupId>org.gvsig</groupId>
37
            <artifactId>org.gvsig.exportto.swing.impl</artifactId>
38
            <version>1.0.0-SNAPSHOT</version>
39
            <scope>runtime</scope>
40
        </dependency>
41
        <dependency>
42
            <groupId>org.gvsig</groupId>
43
            <artifactId>org.gvsig.exportto.swing.prov.generic</artifactId>
44
            <version>1.0.0-SNAPSHOT</version>
45
            <scope>runtime</scope>
46
        </dependency>
47
        <dependency>
48
            <groupId>org.gvsig</groupId>
49
            <artifactId>org.gvsig.exportto.swing.prov.shape</artifactId>
50
            <version>1.0.0-SNAPSHOT</version>
51
            <scope>runtime</scope>
52
        </dependency>
53
        <dependency>
54
            <groupId>org.gvsig</groupId>
55
            <artifactId>org.gvsig.exportto.swing.prov.dxf</artifactId>
56
            <version>1.0.0-SNAPSHOT</version>
57
            <scope>runtime</scope>
58
        </dependency>
59
        <dependency>
60
            <groupId>org.gvsig</groupId>
61
            <artifactId>org.gvsig.exportto.swing.prov.dbf</artifactId>
62
            <version>1.0.0-SNAPSHOT</version>
63
            <scope>runtime</scope>
64
        </dependency>
65
        <dependency>
66
            <groupId>org.gvsig</groupId>
67
            <artifactId>org.gvsig.exportto.swing.prov.postgresql</artifactId>
68
            <version>1.0.0-SNAPSHOT</version>
69
            <scope>runtime</scope>
70
        </dependency>
71
        <dependency>
72
            <groupId>org.gvsig</groupId>
73
            <artifactId>org.gvsig.exportto.swing.prov.mysql</artifactId>
74
            <version>1.0.0-SNAPSHOT</version>
75
            <scope>runtime</scope>
76
        </dependency>
77
        <dependency>
78
            <groupId>org.gvsig</groupId>
79
            <artifactId>org.gvsig.tools.lib</artifactId>
80
            <scope>compile</scope>
81
        </dependency>
82
        <dependency>
83
            <groupId>org.gvsig</groupId>
84
            <artifactId>org.gvsig.projection</artifactId>
85
            <scope>compile</scope>
86
        </dependency>
87
        <dependency>
88
            <groupId>org.gvsig</groupId>
89
            <artifactId>org.gvsig.fmap.dal</artifactId>
90
            <scope>compile</scope>
91
        </dependency>
92
        <dependency>
93
            <groupId>org.gvsig</groupId>
94
            <artifactId>org.gvsig.fmap.dal.file</artifactId>
95
            <classifier>store.shp</classifier>
96
            <scope>runtime</scope>
97
        </dependency>
98
        <dependency>
99
            <groupId>org.gvsig</groupId>
100
            <artifactId>org.gvsig.fmap.dal.file</artifactId>
101
            <classifier>store.dxf</classifier>
102
            <scope>runtime</scope>
103
        </dependency>
104
        <dependency>
105
            <groupId>org.gvsig</groupId>
106
            <artifactId>org.gvsig.fmap.dal.db</artifactId>
107
            <classifier>store.postgresql</classifier>
108
            <scope>runtime</scope>
109
        </dependency>
110
        <dependency>
111
            <groupId>org.gvsig</groupId>
112
            <artifactId>org.gvsig.fmap.mapcontext</artifactId>
113
            <scope>runtime</scope>
114
        </dependency>
115
        <dependency>
116
            <groupId>org.gvsig</groupId>
117
            <artifactId>org.gvsig.fmap.dal.db</artifactId>
118
            <classifier>store.mysql</classifier>
119
            <scope>runtime</scope>
120
        </dependency>
121
        <dependency>
122
            <groupId>org.gvsig</groupId>
123
            <artifactId>org.gvsig.tools.swing.api</artifactId>
124
            <scope>compile</scope>
125
        </dependency>
126
        <dependency>
127
            <groupId>org.gvsig</groupId>
128
            <artifactId>org.gvsig.tools.swing.serv.field</artifactId>
129
            <scope>compile</scope>
130
        </dependency>
131
        <dependency>
132
            <groupId>org.gvsig</groupId>
133
            <artifactId>org.gvsig.metadata.lib.basic.api</artifactId>
134
            <scope>compile</scope>
135
        </dependency>
136
        <dependency>
137
            <groupId>org.gvsig</groupId>
138
            <artifactId>org.gvsig.i18n</artifactId>
139
            <scope>runtime</scope>
140
        </dependency>
141
    </dependencies>
142
</project>
0 143

  
tags/v2_0_0_Build_2051/libraries/org.gvsig.exportto/org.gvsig.exportto.lib/org.gvsig.exportto.lib.api/src/test/java/org/gvsig/exportto/ExporttoServiceTest.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.exportto;
23

  
24
import org.gvsig.fmap.dal.DALLocator;
25
import org.gvsig.fmap.dal.DataManager;
26
import org.gvsig.fmap.dal.DataServerExplorer;
27
import org.gvsig.fmap.dal.DataServerExplorerParameters;
28
import org.gvsig.fmap.dal.DataStoreParameters;
29
import org.gvsig.fmap.dal.NewDataStoreParameters;
30
import org.gvsig.fmap.dal.exception.DataException;
31
import org.gvsig.fmap.dal.exception.ValidateDataParametersException;
32
import org.gvsig.fmap.dal.feature.FeatureStore;
33
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase;
34

  
35
/**
36
 * API compatibility tests for {@link ExporttoService} implementations.
37
 * 
38
 * @author gvSIG Team
39
 * @version $Id$
40
 */
41
public abstract class ExporttoServiceTest extends
42
    AbstractLibraryAutoInitTestCase {
43

  
44
    protected ExporttoManager manager;
45
    protected DataManager dataManager = null;
46

  
47
    @Override
48
    protected void doSetUp() throws Exception {
49
        manager = ExporttoLocator.getManager();
50
        dataManager = DALLocator.getDataManager();
51
    }
52

  
53
    /**
54
     * Returns an instance of the {@link ExporttoService}.
55
     * 
56
     * @return a {@link ExporttoService} instance
57
     * @throws ValidateDataParametersException
58
     * @throws DataException
59
     * @throws Exception
60
     *             if there is any error creating the instance
61
     */
62
    protected ExporttoService createService()
63
        throws ValidateDataParametersException, DataException {
64
        DataServerExplorerParameters dataServerExplorerParameters =
65
            dataManager.createServerExplorerParameters("FilesystemExplorer");
66
        DataServerExplorer dataServerExplorer =
67
            dataManager.openServerExplorer("FilesystemExplorer",
68
                dataServerExplorerParameters);
69
        NewDataStoreParameters newDataStoreParameters =
70
            dataServerExplorer.getAddParameters("Shape");
71
        return manager.getExporttoService(dataServerExplorer,
72
            newDataStoreParameters);
73
    }
74

  
75
    /**
76
     * Test for the
77
     * {@link ExporttoService#export(org.gvsig.fmap.dal.feature.FeatureSet)}
78
     * method.
79
     */
80
    public void testExporttoServiceCreation() {
81
        ExporttoService exportService;
82
        try {
83
            exportService = createService();
84
            assertNotNull(exportService);
85
            // TODO a test for the export service
86
            // exportService.export(featureSet);
87

  
88
        } catch (ValidateDataParametersException e) {
89
            assertNull(e);
90
        } catch (DataException e) {
91
            assertNull(e);
92
        }
93
    }
94

  
95
    @SuppressWarnings("unused")
96
    private FeatureStore createMemoryFeatureStore()
97
        throws ValidateDataParametersException, DataException {
98
        DataStoreParameters memoryParameters =
99
            dataManager.createStoreParameters("Memory");
100
        FeatureStore featureStore =
101
            (FeatureStore) dataManager.openStore("Memory", memoryParameters);
102
        return (FeatureStore) featureStore.getFeatureSet();
103
    }
104
}
0 105

  
tags/v2_0_0_Build_2051/libraries/org.gvsig.exportto/org.gvsig.exportto.lib/org.gvsig.exportto.lib.api/src/test/java/org/gvsig/exportto/ExporttoManagerTest.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.exportto;
23

  
24
import org.gvsig.fmap.dal.DALLocator;
25
import org.gvsig.fmap.dal.DataManager;
26
import org.gvsig.fmap.dal.DataServerExplorer;
27
import org.gvsig.fmap.dal.DataServerExplorerParameters;
28
import org.gvsig.fmap.dal.NewDataStoreParameters;
29
import org.gvsig.fmap.dal.exception.DataException;
30
import org.gvsig.fmap.dal.exception.ValidateDataParametersException;
31
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase;
32

  
33
/**
34
 * API compatibility tests for {@link ExporttoManager} implementations.
35
 * 
36
 * @author gvSIG Team
37
 * @version $Id$
38
 */
39
public abstract class ExporttoManagerTest extends
40
    AbstractLibraryAutoInitTestCase {
41

  
42
    protected ExporttoManager manager;
43
    protected DataManager dataManager = null;
44

  
45
    @Override
46
    protected void doSetUp() throws Exception {
47
        manager = ExporttoLocator.getManager();
48
        dataManager = DALLocator.getDataManager();
49
    }
50

  
51
    /**
52
     * Test for the {@link ExporttoManager#getExporttoService()} method.
53
     * 
54
     * @throws Exception
55
     *             if there is any error in the tests
56
     */
57
    public void testGetExporttoService() throws Exception {
58
        ExporttoService exportService;
59
        try {
60
            exportService = createService();
61
            assertNotNull(exportService);
62
        } catch (ValidateDataParametersException e) {
63
            assertNull(e);
64
        } catch (DataException e) {
65
            assertNull(e);
66
        }
67
    }
68

  
69
    protected ExporttoService createService()
70
        throws ValidateDataParametersException, DataException {
71
        DataServerExplorerParameters dataServerExplorerParameters =
72
            dataManager.createServerExplorerParameters("FilesystemExplorer");
73
        DataServerExplorer dataServerExplorer =
74
            dataManager.openServerExplorer("FilesystemExplorer",
75
                dataServerExplorerParameters);
76
        NewDataStoreParameters newDataStoreParameters =
77
            dataServerExplorer.getAddParameters("Shape");
78
        return manager.getExporttoService(dataServerExplorer,
79
            newDataStoreParameters);
80
    }
81

  
82
}
0 83

  
tags/v2_0_0_Build_2051/libraries/org.gvsig.exportto/org.gvsig.exportto.lib/org.gvsig.exportto.lib.api/src/main/resources/filters.txt
1
point_geometries_only=
2
curve_geometries_only=
3
surface_geometries_only=
0 4

  
tags/v2_0_0_Build_2051/libraries/org.gvsig.exportto/org.gvsig.exportto.lib/org.gvsig.exportto.lib.api/src/main/resources/META-INF/services/org.gvsig.tools.library.Library
1
org.gvsig.exportto.ExporttoLibrary
tags/v2_0_0_Build_2051/libraries/org.gvsig.exportto/org.gvsig.exportto.lib/org.gvsig.exportto.lib.api/src/main/java/org/gvsig/exportto/ExporttoException.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.exportto;
23

  
24
import org.gvsig.tools.exception.BaseException;
25

  
26
/**
27
 * Generic exception thrown in the Exportto API when the exception or error
28
 * may be dealt by the program or the user of the program which is a client of
29
 * the Exportto API.
30
 * 
31
 * @see {@link ExporttoService}
32
 * @see {@link ExporttoManager}
33
 * @author gvSIG team.
34
 * @version $Id$
35
 */
36
public class ExporttoException extends BaseException {
37

  
38
    private static final long serialVersionUID = 6756475060924237176L;
39

  
40
    private static final String MESSAGE =
41
        "An error has been produced in the Exportto library";
42

  
43
    private static final String KEY = "_ExporttoException";
44

  
45
    /**
46
     * Constructor to be used in rare cases, usually you must create a new child
47
     * exception class for each case.
48
     * <strong>Don't use this constructor in child classes.</strong>
49
     */
50
    public ExporttoException() {
51
        super(MESSAGE, KEY, serialVersionUID);
52
    }
53

  
54
    /**
55
     * Constructor to be used in rare cases, usually you must create a new child
56
     * exception class for each case.
57
     * <p>
58
     * <strong>Don't use this constructor in child classes.</strong>
59
     * </p>
60
     * 
61
     * @param cause
62
     *            the original cause of the exception
63
     */
64
    public ExporttoException(Exception cause) {
65
        super(MESSAGE, cause, KEY, serialVersionUID);
66
    }
67

  
68
    /**
69
     * @see BaseException#BaseException(String, String, long).
70
     * @param message
71
     *            the default messageFormat to describe the exception
72
     * @param key
73
     *            the key to use to search a localized messageFormnata
74
     * @param code
75
     *            the unique code to identify the exception
76
     */
77
    protected ExporttoException(String message, String key, long code) {
78
        super(message, key, code);
79
    }
80

  
81
    /**
82
     * @see BaseException#BaseException(String, Throwable, String, long).
83
     * @param message
84
     *            the default messageFormat to describe the exception
85
     * @param cause
86
     *            the original cause of the exception
87
     * @param key
88
     *            the key to use to search a localized messageFormnata
89
     * @param code
90
     *            the unique code to identify the exception
91
     */
92
    protected ExporttoException(String message, Throwable cause, String key,
93
        long code) {
94
        super(message, cause, key, code);
95
    }
96
}
0 97

  
tags/v2_0_0_Build_2051/libraries/org.gvsig.exportto/org.gvsig.exportto.lib/org.gvsig.exportto.lib.api/src/main/java/org/gvsig/exportto/ExporttoServiceException.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.exportto;
23

  
24
import org.gvsig.tools.service.ServiceException;
25

  
26
/**
27
 * Exception thrown when there is an error getting a Exportto message.
28
 * 
29
 * @author gvSIG team
30
 * @version $Id$
31
 */
32
public class ExporttoServiceException extends ServiceException {
33

  
34
    private static final long serialVersionUID = -7423501876634702709L;
35

  
36
    private static final String MESSAGE =
37
        "An error has been produced exporting a store";
38

  
39
    private static final String KEY = "_ExporttoServiceException";
40

  
41
    /**
42
     * Creates a new {@link ExporttoServiceException}.
43
     * 
44
     * @param cause
45
     *            the original cause
46
     */
47
    public ExporttoServiceException(Throwable cause) {
48
        super(MESSAGE, cause, KEY, serialVersionUID);
49
    }
50

  
51
    public ExporttoServiceException(String message, Throwable cause) {
52
        super(message, cause, KEY, serialVersionUID);
53
    }
54
}
0 55

  
tags/v2_0_0_Build_2051/libraries/org.gvsig.exportto/org.gvsig.exportto.lib/org.gvsig.exportto.lib.api/src/main/java/org/gvsig/exportto/ExporttoServiceFinishAction.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.exportto;
23

  
24
import org.gvsig.fmap.dal.DataStoreParameters;
25
import org.gvsig.fmap.dal.feature.FeatureStore;
26

  
27
/**
28
 * Action that can be executed at the end of the export process.
29
 * An example of action can be load the destination {@link FeatureStore} like a
30
 * layer in a view.
31
 * 
32
 * @author gvSIG Team
33
 * @version $Id$
34
 * 
35
 */
36
public interface ExporttoServiceFinishAction {
37

  
38
    /**
39
     * This method is called at the end of an export process.
40
     * 
41
     * @param layerName
42
     *            name of the new layer that can be added to gvSIG.
43
     * @param dataStoreParameters
44
     *            the parameters that can be used to create the exported store.
45
     */
46
    public void finished(String layerName,
47
        DataStoreParameters dataStoreParameters);
48
}
0 49

  
tags/v2_0_0_Build_2051/libraries/org.gvsig.exportto/org.gvsig.exportto.lib/org.gvsig.exportto.lib.api/src/main/java/org/gvsig/exportto/ExporttoService.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22

  
23
package org.gvsig.exportto;
24

  
25
import org.gvsig.fmap.dal.feature.FeatureSet;
26
import org.gvsig.fmap.dal.feature.FeatureStore;
27
import org.gvsig.tools.task.MonitorableTask;
28

  
29
/**
30
 * <p>
31
 * This service is used to export a source {@link FeatureStore} to a target
32
 * {@link FeatureStore}.
33
 * </p>
34
 * <p>
35
 * It inherits if {@link MonitorableTask}, and it means that the export process
36
 * can be monitorized by one or more observers that can listen all the export
37
 * events.
38
 * <p>
39
 * 
40
 * @author gvSIG team
41
 * @version $Id$
42
 */
43
public interface ExporttoService extends MonitorableTask {
44

  
45
    /**
46
     * This method export a {@link FeatureSet} to other {@link FeatureSet}.
47
     * The other necessary parameters to make this conversion are specific
48
     * for every {@link ExporttoService}. e.g: a shape exporter needs a
49
     * file and a projection, a database exporter needs a connection
50
     * parameters...
51
     * 
52
     * @param featureSet
53
     *            the set of features hat have to be exported.
54
     * @throws ExporttoServiceException
55
     *             if there is any exception in the exporting process
56
     */
57
    public void export(FeatureSet featureSet) throws ExporttoServiceException;
58

  
59
    /**
60
     * Sets the {@link ExporttoServiceFinishAction} that is used at the end
61
     * of the {@link ExporttoService}.
62
     * 
63
     * @param exporttoServiceFinishAction
64
     *            it contains an action that can be executed at the end of the
65
     *            export process
66
     * 
67
     */
68
    public void setFinishAction(
69
        ExporttoServiceFinishAction exporttoServiceFinishAction);
70

  
71
}
0 72

  
tags/v2_0_0_Build_2051/libraries/org.gvsig.exportto/org.gvsig.exportto.lib/org.gvsig.exportto.lib.api/src/main/java/org/gvsig/exportto/ExporttoLocator.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.exportto;
23

  
24
import org.gvsig.tools.locator.BaseLocator;
25
import org.gvsig.tools.locator.Locator;
26
import org.gvsig.tools.locator.LocatorException;
27

  
28
/**
29
 * This locator is the entry point for the Exportto library, providing
30
 * access to all Exportto services through the {@link ExporttoManager} .
31
 * 
32
 * @author gvSIG team
33
 * @version $Id$
34
 */
35
public class ExporttoLocator extends BaseLocator {
36

  
37
    /**
38
     * Exportto manager name.
39
     */
40
    public static final String MANAGER_NAME = "Exportto.manager";
41

  
42
    /**
43
     * Exportto manager description.
44
     */
45
    public static final String MANAGER_DESCRIPTION = "Exportto Manager";
46

  
47
    private static final String LOCATOR_NAME = "Exportto.locator";
48

  
49
    /**
50
     * Unique instance.
51
     */
52
    private static final ExporttoLocator INSTANCE = new ExporttoLocator();
53

  
54
    /**
55
     * Return the singleton instance.
56
     * 
57
     * @return the singleton instance
58
     */
59
    public static ExporttoLocator getInstance() {
60
        return INSTANCE;
61
    }
62

  
63
    /**
64
     * Return the Locator's name.
65
     * 
66
     * @return a String with the Locator's name
67
     */
68
    public final String getLocatorName() {
69
        return LOCATOR_NAME;
70
    }
71

  
72
    /**
73
     * Return a reference to the ExporttoManager.
74
     * 
75
     * @return a reference to the ExporttoManager
76
     * @throws LocatorException
77
     *             if there is no access to the class or the class cannot be
78
     *             instantiated
79
     * @see Locator#get(String)
80
     */
81
    public static ExporttoManager getManager() throws LocatorException {
82
        return (ExporttoManager) getInstance().get(MANAGER_NAME);
83
    }
84

  
85
    /**
86
     * Registers the Class implementing the ExporttoManager interface.
87
     * 
88
     * @param clazz
89
     *            implementing the ExporttoManager interface
90
     */
91
    public static void registerManager(Class<? extends ExporttoManager> clazz) {
92
        getInstance().register(MANAGER_NAME, MANAGER_DESCRIPTION, clazz);
93
    }
94

  
95
}
0 96

  
tags/v2_0_0_Build_2051/libraries/org.gvsig.exportto/org.gvsig.exportto.lib/org.gvsig.exportto.lib.api/src/main/java/org/gvsig/exportto/ExporttoLibrary.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.exportto;
23

  
24
import org.gvsig.tools.library.AbstractLibrary;
25
import org.gvsig.tools.library.LibraryException;
26
import org.gvsig.tools.locator.ReferenceNotRegisteredException;
27

  
28
/**
29
 * Library for API initialization and configuration.
30
 * 
31
 * @author gvSIG team
32
 * @version $Id$
33
 */
34
public class ExporttoLibrary extends AbstractLibrary {
35

  
36
    @Override
37
    public void doRegistration() {
38
        registerAsAPI(ExporttoLibrary.class);
39
    }
40

  
41
    @Override
42
    protected void doInitialize() throws LibraryException {
43
        // Do nothing
44
    }
45

  
46
    @Override
47
    protected void doPostInitialize() throws LibraryException {
48
        // Validate there is any implementation registered.
49
        ExporttoManager manager = ExporttoLocator.getManager();
50
        if (manager == null) {
51
            throw new ReferenceNotRegisteredException(
52
                ExporttoLocator.MANAGER_NAME, ExporttoLocator.getInstance());
53
        }
54
    }
55

  
56
}
0 57

  
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff