Revision 371

View differences:

org.gvsig.educa.portableview/tags/org.gvsig.educa.portableview-1.0.18/README.txt
1
===============
2
gvSIG Educa
3
===============
4

  
5
---------------------
6
Portable View
7
---------------------
8

  
9
Description
10
==============
11

  
12
This folder contains the sources of the Portable View functionality.
13

  
14
Requirements
15
==============
16

  
17
* Maven 2.6 or higher
18

  
19
* Java JDK 1.5 or higher
20

  
21
For eclipse
22
-------------
23

  
24
See `developer guide at gvSIG.org <http://www.gvsig.org/plone/projects/gvsig-desktop/docs/devel/gvsig-devel-guide/2-1-0/introduccion>`_ and the file ``REAME-ECLIPSE.txt``
25

  
26

  
27
Contents
28
==========
29

  
30
org.gvsig.educa.portableview.lib
31
---------------------------------
32

  
33
Functionality sources. This project just contain the main process and the logic without any dependency with User Interface.
34

  
35
org.gvsig.educa.portableview.swing
36
-------------------------------------
37

  
38
User Interface components to access a manage the application services.
39

  
40
org.gvsig.educa.portableview.main
41
-----------------------------------
42

  
43
Little test application which allow run the main functionality of application.
44

  
45
See `Execute little test application`_ to know how run it.
46

  
47
pom.xml
48
---------
49

  
50
Maven project definition file
51

  
52
README.rst
53
--------------
54

  
55
This file (in reStructureText format, for more info this format look at `gvSIG portal <https://gvsig.org/web/projects/gvsig-desktop/docs/devel/guia-para-documentar/el-formato-restructuredtext>`_  or at `docUtils reference <http://docutils.sourceforge.net/rst.html>`_)
56

  
57

  
58
Compilation
59
================
60

  
61
From shell
62
------------
63

  
64
Execute this command::
65

  
66
    org.gvsig.educa.portableview$ mvn clean install
67

  
68

  
69
From eclipse
70
--------------
71

  
72
See `work in a proyect of the developer guide at gvSIG.org <https://gvsig.org/web/projects/gvsig-desktop/docs/devel/gvsig-devel-guide/2.0.0/trabajar-con-un-proyecto>`_
73

  
74
In some project, could be better use ``mvn eclipse:clean eclipse:eclipse``  than import project as a *Maven project*. Maven plugin of eclipse does not set classpath correctly in some project.
75

  
76

  
77
Packing
78
========
79

  
80
This functionality has no stand-alone packing process.
81

  
82
Version
83
---------------
84

  
85
To changes version number just set in in ``project/version`` tag of *pom.xml* in this folder. Sub-projects will inherit it.
86

  
87
Version polity is the standard in project. Changes in version number:
88

  
89
* third number: Bug fixes and minors improvements. API must have no changes from previous version.
90
* second number: Bug fixes and mayor improvements. API can have minor changes. Previously deprecated classes could be removed. No architectural changes.
91
* first number: Mayor changes.
92

  
93
Create a tag
94
------------------
95

  
96
TODO: use *maven release* plugin
97

  
98
Use svn copy command to copy version in server. Process could be like this:
99

  
100

  
101
#. Check that there ins no changes in workspace::
102

  
103
   svn up ; svn status
104

  
105
#. Check that project compiles and passes all test.
106

  
107
   mvn clean install
108

  
109
#. Update *pom.xml* to set version of tag (usually removing *-SNAPSHOT*)
110
#. create tag folder on server::
111

  
112
   svn mkdir -m "Create {version} tag folder" https://devel.gvsig.org/svn/gvsig-educa/org.gvsig.educa.portablewview/tags/{version}
113

  
114
#. Copy current workcopy to tag folder::
115

  
116
   svn copy -m "Create {version} tag" * https://devel.gvsig.org/svn/gvsig-educa/org.gvsig.educa.portablewview/tags/{version}
117

  
118
#. Update *pom.xml* to next version
119
#. Commit *pom.xml* changes::
120

  
121
   svn commit -m "Set new version {version}-SNAPSHOT" pom.xml
122

  
123

  
124
i18n
125
======
126

  
127
The files for internationalization can be found in this folders:
128

  
129
+ *org.gvsig.educa.portablewview.app.viewer/src/main/resources-plugin*
130
+ *org.gvsig.educa.portablewview.app.editor/src/main/resources-plugin*
131

  
132
The internationalization of this application is based on standard java resource bundle mechanism. So, to add a new language just add the file with the language code to every related folder.
133

  
134
Execute little test application
135
=================================
136

  
137
From shell
138
------------
139

  
140
After compile the application, execute this command::
141

  
142
    org.gvsig.educa.portablewview$ cd org.gvsig.educa.thematicmap.main
143
    org.gvsig.educa.portablewview/org.gvsig.educa.portablewview.main$ mvn exec:java
144

  
145
Form eclipse
146
------------------
147

  
148
Select ``org.gvsig.educa.portableview.main`` project in *Project tree* using *Java perspective*, click with right mouse button and select ``Run as.../Java application``. Select ``Main`` class for project.
149

  
org.gvsig.educa.portableview/tags/org.gvsig.educa.portableview-1.0.18/org.gvsig.educa.portableview.lib/org.gvsig.educa.portableview.lib.api/src/main/resources/META-INF/services/org.gvsig.tools.library.Library
1
org.gvsig.educa.portableview.PortableViewLibrary
org.gvsig.educa.portableview/tags/org.gvsig.educa.portableview-1.0.18/org.gvsig.educa.portableview.lib/org.gvsig.educa.portableview.lib.api/src/main/java/org/gvsig/educa/portableview/PortableViewRuntimeException.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.educa.portableview;
23

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

  
26
/**
27
 * Generic exception thrown in the PortableView 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 PortableView API.
30
 *
31
 * @see {@link PortableViewService}
32
 * @see {@link PortableViewManager}
33
 * @author gvSIG team.
34
 * @version $Id$
35
 */
36
public class PortableViewRuntimeException extends BaseRuntimeException {
37

  
38

  
39
    /**
40
     *
41
     */
42
    private static final long serialVersionUID = -4039843730204021312L;
43

  
44
    private static final String MESSAGE =
45
        "An error has been produced in the PortableView library";
46

  
47
    private static final String KEY = "_PortableViewRuntimeException";
48

  
49
    public PortableViewRuntimeException(String message) {
50
        super(message, KEY, serialVersionUID);
51
    }
52

  
53
    /**
54
     *
55
     * @param cause
56
     *            the original cause of the exception
57
     */
58
    public PortableViewRuntimeException(String message, Exception cause) {
59
        super(message, cause, KEY, serialVersionUID);
60
    }
61

  
62
    /**
63
     *
64
     * @param cause
65
     *            the original cause of the exception
66
     */
67
    public PortableViewRuntimeException(Exception cause) {
68
        super(MESSAGE, cause, KEY, serialVersionUID);
69
    }
70

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

  
84
    /**
85
     * @see BaseException#BaseException(String, Throwable, String, long).
86
     * @param message
87
     *            the default messageFormat to describe the exception
88
     * @param cause
89
     *            the original cause of the exception
90
     * @param key
91
     *            the key to use to search a localized messageFormnata
92
     * @param code
93
     *            the unique code to identify the exception
94
     */
95
    protected PortableViewRuntimeException(String message, Throwable cause, String key,
96
        long code) {
97
        super(message, cause, key, code);
98
    }
99
}
org.gvsig.educa.portableview/tags/org.gvsig.educa.portableview-1.0.18/org.gvsig.educa.portableview.lib/org.gvsig.educa.portableview.lib.api/src/main/java/org/gvsig/educa/portableview/PortableViewFileServices.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.educa.portableview;
23

  
24
import java.io.File;
25
import java.io.IOException;
26
import java.util.zip.ZipException;
27

  
28
import org.gvsig.fmap.mapcontext.MapContext;
29
import org.gvsig.tools.persistence.exception.PersistenceException;
30

  
31
/**
32
 * Portable View Utilities related to files
33
 *
34
 * @author gvSIG Team
35
 * @version $Id$
36
 *
37
 */
38
/**
39
 * @author gvSIG Team
40
 * @version $Id$
41
 * 
42
 */
43
public interface PortableViewFileServices {
44

  
45
    /**
46
     * <p>
47
     * Unzip a file into a folder
48
     * </p>
49
     * 
50
     * @param zipFile
51
     * @param outputFloder
52
     *            must exists. WARNING: <b>Contents will be removed before
53
     *            unzip</b>
54
     * @throws IOException
55
     * @throws ZipException
56
     * @throws IllegalArgumentException
57
     *             if zipFile is not a file or outputFloder doesn't exists or is
58
     *             read-only
59
     */
60
    void unzipFile(File zipFile, File outputFloder) throws ZipException,
61
        IOException;
62

  
63
    /**
64
     * <p>
65
     * Create a zip file which will contains all contents of a folder
66
     * </p>
67
     * <p>
68
     * Files will be use relative path to <code>rootFolder</code>
69
     * </p>
70
     * 
71
     * @param rootFolder
72
     *            rootFolder (must be an existing folder)
73
     * @param targetFile
74
     *            final file (must not exists)
75
     * @throws IOException
76
     * @throws IllegalArgumentException
77
     *             if there are any problem in parameters
78
     */
79
    void zipFolder(File rootFolder, File targetFile) throws IOException;
80

  
81
    /**
82
     * Informs if <code>folder</code> is a writable folder( exists & isDir &
83
     * canWrite)
84
     * 
85
     * @param folder
86
     * @return
87
     */
88
    boolean isWritableFolder(File folder);
89

  
90
    /**
91
     * Informs if <code>folder</code> is a readable folder( exists & isDir &
92
     * canRead)
93
     * 
94
     * @param folder
95
     * @return
96
     */
97
    boolean isReadableFolder(File folder);
98

  
99
    /**
100
     * Informs if <code>file</code> is a readable file ( exists & isFile &
101
     * canRead)
102
     * 
103
     * @param file
104
     * @return
105
     */
106
    boolean isReadableFile(File file);
107

  
108
    /**
109
     * <p>
110
     * Look for a folder on a <code>baseFolder</code> starts with
111
     * <code>baseName</code> which is writable.
112
     * </p>
113
     * <p>
114
     * The pattern is: <code>baseFolder/baseName.0000</code> where
115
     * <code>000</code> it's a counter.
116
     * </p>
117
     * 
118
     * @param baseFolder
119
     *            existing and writable folder
120
     * @param baseName
121
     *            start of new folder
122
     * @return new folder
123
     * @throws IllegalArgumentException
124
     *             if base folder is not a writable folder
125
     * @throws IllegalStateException
126
     *             if can't found a suitable folder
127
     */
128
    File getWritableFolder(File baseFolder, String baseName);
129

  
130
    /**
131
     * <p>
132
     * Create a new folder on a <code>baseFolder</code> starts with
133
     * <code>baseName</code> which is new and writable.
134
     * </p>
135
     * <p>
136
     * The pattern is: <code>baseFolder/baseName.0000</code> where
137
     * <code>000</code> it's a counter.
138
     * </p>
139
     * 
140
     * @param baseFolder
141
     *            existing and writable folder
142
     * @param baseName
143
     *            start of new folder
144
     * @return new folder
145
     * @throws IllegalArgumentException
146
     *             if base folder is not a writable folder
147
     * @throws IllegalStateException
148
     *             if can't found a suitable folder
149
     */
150
    File getNewWritableFolder(File baseFolder, String baseName);
151

  
152
    /**
153
     * <p>
154
     * Create {@link File} instance for a new file on a <code>baseFolder</code>
155
     * starts with <code>baseName</code>.
156
     * </p>
157
     * <p>
158
     * The pattern is: <code>baseFolder/baseName.0000.ext</code> where
159
     * <code>000</code> it's a counter.
160
     * </p>
161
     * <p>
162
     * This <b>no create</b> the file into the file system.
163
     * </p>
164
     * 
165
     * @param baseFolder
166
     *            existing and writable folder
167
     * @param name
168
     *            start of new file
169
     * @return new folder
170
     * @throws IllegalArgumentException
171
     *             if base folder is not a writable folder
172
     * @throws IllegalStateException
173
     *             if can't found a suitable folder
174
     */
175
    File getNewFileName(File baseFolder, String name);
176

  
177
    /**
178
     * <p>
179
     * Return <code>path</code> as relative from <code>basePath</code> only if
180
     * <code>basePath</code> is an ancestor of <code>path</code>:
181
     * </p>
182
     * 
183
     * @param path
184
     * @param basePath
185
     * @return
186
     * @see FilenameUtils#getRelativeTo(String, String)
187
     */
188
    File getRelativeTo(File path, File basePath);
189

  
190
    /**
191
     * <p>
192
     * Load a mapContext from a file adjusting file paths which are supposed
193
     * relatives to a folder
194
     * </p>
195
     * 
196
     * @param mapContext
197
     *            persistence file
198
     * @param relativaPathFolder
199
     *            for files refered in mapContext
200
     * @return
201
     * @throws IOException
202
     * @throws PersistenceException
203
     */
204
    MapContext loadMapContext(File mapContext, File relativaPathFolder)
205
        throws IOException, PersistenceException;
206
}
org.gvsig.educa.portableview/tags/org.gvsig.educa.portableview-1.0.18/org.gvsig.educa.portableview.lib/org.gvsig.educa.portableview.lib.api/src/main/java/org/gvsig/educa/portableview/PortableViewLocator.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.educa.portableview;
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 PortableView library, providing
30
 * access to all PortableView services through the {@link PortableViewManager} .
31
 *
32
 * @author gvSIG team
33
 * @version $Id$
34
 */
35
public class PortableViewLocator extends BaseLocator {
36

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

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

  
47
    /**
48
     * PortableView file services name.
49
     */
50
    public static final String FILESERVICES_NAME = "PortableView.fileservices";
51

  
52
    /**
53
     * PortableView file services manager description.
54
     */
55
    public static final String FILESERVICES_DESCRIPTION =
56
        "PortableView File Servides";
57

  
58
    private static final String LOCATOR_NAME = "PortableView.locator";
59

  
60
    /**
61
     * Unique instance.
62
     */
63
    private static final PortableViewLocator INSTANCE = new PortableViewLocator();
64

  
65
    /**
66
     * Return the singleton instance.
67
     *
68
     * @return the singleton instance
69
     */
70
    public static PortableViewLocator getInstance() {
71
        return INSTANCE;
72
    }
73

  
74
    /**
75
     * Return the Locator's name.
76
     *
77
     * @return a String with the Locator's name
78
     */
79
    @Override
80
    public final String getLocatorName() {
81
        return LOCATOR_NAME;
82
    }
83

  
84
    /**
85
     * Return a reference to the PortableViewManager.
86
     *
87
     * @return a reference to the PortableViewManager
88
     * @throws LocatorException
89
     *             if there is no access to the class or the class cannot be
90
     *             instantiated
91
     * @see Locator#get(String)
92
     */
93
    public static PortableViewManager getManager() throws LocatorException {
94
        return (PortableViewManager) getInstance().get(MANAGER_NAME);
95
    }
96

  
97
    /**
98
     * Registers the Class implementing the PortableViewManager interface.
99
     *
100
     * @param clazz
101
     *            implementing the PortableViewManager interface
102
     */
103
    public static void registerManager(Class<? extends PortableViewManager> clazz) {
104
        getInstance().register(MANAGER_NAME, MANAGER_DESCRIPTION, clazz);
105
    }
106

  
107
    /**
108
     * Return a reference to the PortableViewFileServices.
109
     *
110
     * @return a reference to the PortableViewFileServices
111
     * @throws LocatorException
112
     *             if there is no access to the class or the class cannot be
113
     *             instantiated
114
     * @see Locator#get(String)
115
     */
116
    public static PortableViewFileServices getFileServices()
117
        throws LocatorException {
118
        return (PortableViewFileServices) getInstance().get(FILESERVICES_NAME);
119
    }
120

  
121
    /**
122
     * Registers the Class implementing the PortableViewFileServices interface.
123
     *
124
     * @param clazz
125
     *            implementing the PortableViewFileServices interface
126
     */
127
    public static void registerFileServices(
128
        Class<? extends PortableViewFileServices> clazz) {
129
        getInstance().register(FILESERVICES_NAME, FILESERVICES_DESCRIPTION,
130
            clazz);
131
    }
132

  
133
}
org.gvsig.educa.portableview/tags/org.gvsig.educa.portableview-1.0.18/org.gvsig.educa.portableview.lib/org.gvsig.educa.portableview.lib.api/src/main/java/org/gvsig/educa/portableview/PortableViewLibrary.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.educa.portableview;
23

  
24
import org.gvsig.fmap.dal.DALLibrary;
25
import org.gvsig.fmap.mapcontext.MapContextLibrary;
26
import org.gvsig.tools.library.AbstractLibrary;
27
import org.gvsig.tools.library.LibraryException;
28
import org.gvsig.tools.locator.ReferenceNotRegisteredException;
29

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

  
38
    @Override
39
    public void doRegistration() {
40
        registerAsAPI(PortableViewLibrary.class);
41
        require(DALLibrary.class);
42
        require(MapContextLibrary.class);
43

  
44
    }
45

  
46
    @Override
47
    protected void doInitialize() throws LibraryException {
48
        // Do nothing
49
    }
50

  
51
    @Override
52
    protected void doPostInitialize() throws LibraryException {
53
        // Validate there is any implementation registered.
54
        PortableViewManager manager = PortableViewLocator.getManager();
55
        if (manager == null) {
56
            throw new ReferenceNotRegisteredException(
57
                PortableViewLocator.MANAGER_NAME,
58
                PortableViewLocator.getInstance());
59
        }
60
    }
61

  
62
}
org.gvsig.educa.portableview/tags/org.gvsig.educa.portableview-1.0.18/org.gvsig.educa.portableview.lib/org.gvsig.educa.portableview.lib.api/src/main/java/org/gvsig/educa/portableview/map/PortableView.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.educa.portableview.map;
23

  
24
import java.io.IOException;
25

  
26
import org.gvsig.educa.portableview.PortableViewManager;
27
import org.gvsig.fmap.mapcontext.MapContext;
28
import org.gvsig.tools.dispose.Disposable;
29

  
30
/**
31
 * <i>Portable View</i> instance.
32
 * </p>
33
 * This class' instances contains information about a installed <i>Portable
34
 * View</i>
35
 *
36
 * @author <a href="http://www.disid.com">DiSiD Technologies S.L.</a>
37
 * @version $Rev$
38
 * @since {version}
39
 */
40
public interface PortableView extends Disposable {
41

  
42
    /**
43
     * Gets information about this <i>Portable View</i>
44
     *
45
     * @return
46
     */
47
    PortableViewInformation getInformation();
48

  
49
    /**
50
     * Opens this <i>Portable View</i>
51
     * </p>
52
     * This unzip <i>Portable View</i> contents into temporal folder (if it isn't
53
     * created yet)
54
     * and prepares data
55
     * </p>
56
     * unzip folder is defined in {@link PortableViewManager#getTemporalFolder()}
57
     * </p>
58
     *
59
     * @throws InvalidPortableViewFormatException
60
     * @throws CantLoadContextException
61
     * @throws IOException
62
     */
63
    void open() throws InvalidPortableViewFormatException,
64
        CantLoadContextException, IOException;
65

  
66
    /**
67
     * Informs if <i>Portable View</i> it's already opened or not
68
     *
69
     * @return if it's opened
70
     */
71
    boolean isOpen();
72

  
73
    /**
74
     * Unloads all data loaded in memory and cleans its temporal folder
75
     *
76
     * @throws IOException
77
     *             if any problem is found cleaning temporal folder
78
     *
79
     */
80
    void close() throws IOException;
81

  
82
    /**
83
     * Gets MapContext with <i>Portable View</i> representation
84
     *
85
     * @return MapContext instance
86
     * @throws IllegalStateException
87
     *             if {@link #isOpen()} == false
88
     */
89
    MapContext getMapContext();
90

  
91
    /**
92
     * Gets the file which PortableView data
93
     *
94
     * @return
95
     */
96
    String getSourceFilePath();
97

  
98
}
org.gvsig.educa.portableview/tags/org.gvsig.educa.portableview-1.0.18/org.gvsig.educa.portableview.lib/org.gvsig.educa.portableview.lib.api/src/main/java/org/gvsig/educa/portableview/map/CantLoadContextException.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.educa.portableview.map;
23

  
24
import java.io.File;
25

  
26
import org.gvsig.educa.portableview.PortableViewException;
27

  
28
/**
29
 * Exception Throws when try to load the MapContext of a PortableView file
30
 *
31
 * @author gvSIG Team
32
 * @version $Id$
33
 *
34
 */
35
public class CantLoadContextException extends PortableViewException {
36

  
37
    /**
38
     *
39
     */
40
    private static final long serialVersionUID = -6565034273641780414L;
41

  
42
    private static final String MESSAGE =
43
        "Problem loading MapContext file [%(mapContextPath)] of a PortableView file [%(mapPath)]: %(info)";
44

  
45
    private static final String KEY = "_CantLoadContextException";
46

  
47
    /**
48
     * Cannot load mapContext from a Portable view file
49
     *
50
     * @param mapFile
51
     * @param mapContextFile
52
     * @param message
53
     *            problem description
54
     * @param cause
55
     */
56
    public CantLoadContextException(File mapFile, File mapContextFile,
57
        String message, Throwable cause) {
58
        super(MESSAGE, cause, KEY, serialVersionUID);
59
        setValue("info", message);
60
        setValue("mapPath", mapFile.getAbsolutePath());
61
        setValue("mapContextPath", mapContextFile.getAbsolutePath());
62
    }
63

  
64
    /**
65
     * Cannot load mapContext from a Portable view file
66
     *
67
     * @param mapFile
68
     * @param mapContextFile
69
     * @param cause
70
     */
71
    public CantLoadContextException(File mapFile, File mapContextFile,
72
        Throwable cause) {
73
        this(mapFile, mapContextFile, "loading problem", cause);
74
    }
75

  
76
}
org.gvsig.educa.portableview/tags/org.gvsig.educa.portableview-1.0.18/org.gvsig.educa.portableview.lib/org.gvsig.educa.portableview.lib.api/src/main/java/org/gvsig/educa/portableview/map/InvalidInstalledPortableViewException.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.educa.portableview.map;
23

  
24
import java.io.File;
25

  
26
import org.gvsig.educa.portableview.PortableViewException;
27

  
28
/**
29
 * Exception Throws when try to open an installed PortableView folder with
30
 * invalid format (missing package.info file or no match data)
31
 *
32
 * @author gvSIG Team
33
 * @version $Id$
34
 *
35
 */
36
public class InvalidInstalledPortableViewException extends PortableViewException {
37

  
38
    /**
39
     *
40
     */
41
    private static final long serialVersionUID = 1L;
42

  
43
    private static final String MESSAGE =
44
        "Invalid format of an installed PortableView [%(folderPath)]: %(info)";
45

  
46
    private static final String KEY = "_InvalidInstalledPortableViewException";
47

  
48
    /**
49
     * Invalid format of an installed portable view folder by unspecified problem
50
     *
51
     * @param mapFile
52
     */
53
    public InvalidInstalledPortableViewException(File mapFolder) {
54
        this(mapFolder, "unspecified problem");
55
    }
56

  
57
    /**
58
     * Invalid format of a portable view file
59
     *
60
     * @param mapFile
61
     * @param message
62
     *            problem description
63
     */
64
    public InvalidInstalledPortableViewException(File mapFolder, String message) {
65
        super(MESSAGE, KEY, serialVersionUID);
66
        setValue("info", message);
67
        setValue("folderPath", mapFolder.getAbsolutePath());
68
    }
69

  
70
    /**
71
     * Invalid format of a portable view file
72
     *
73
     * @param mapFile
74
     * @param message
75
     *            problem description
76
     * @param cause
77
     */
78
    public InvalidInstalledPortableViewException(File mapFolder, String message,
79
        Throwable cause) {
80
        super(MESSAGE, cause, KEY, serialVersionUID);
81
        setValue("info", message);
82
        setValue("folderPath", mapFolder.getAbsolutePath());
83
    }
84

  
85
    /**
86
     * Invalid format of a portable view file
87
     *
88
     * @param mapFile
89
     */
90
    public InvalidInstalledPortableViewException(File mapFile, Throwable cause) {
91
        this(mapFile, "initializing problem", cause);
92
    }
93

  
94
}
org.gvsig.educa.portableview/tags/org.gvsig.educa.portableview-1.0.18/org.gvsig.educa.portableview.lib/org.gvsig.educa.portableview.lib.api/src/main/java/org/gvsig/educa/portableview/map/PortableViewInformation.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.educa.portableview.map;
23

  
24
import java.util.Date;
25

  
26
import org.cresques.cts.IProjection;
27
import org.omg.CORBA.DynValue;
28

  
29
import org.gvsig.fmap.geom.primitive.Envelope;
30
import org.gvsig.tools.dynobject.DynObject;
31
import org.gvsig.tools.dynobject.DynStruct;
32

  
33
/**
34
 * Information about a <i>Portable View</i>:
35
 * <ul>
36
 * <li>Name and description</li>
37
 * <li>Author</li>
38
 * <li>License</li>
39
 * </ul>
40
 *
41
 * TODO Add more data
42
 *
43
 * @author <a href="http://www.disid.com">DiSiD Technologies S.L.</a>
44
 * @version $Rev$
45
 * @since {version}
46
 */
47
public interface PortableViewInformation {
48

  
49
    public static final String DYN_DEFINITION_NAME = "PortableViewInformation";
50

  
51
    /**
52
     * Gets <i>Portable View</i> identifier
53
     *
54
     * @return
55
     */
56
    String getId();
57

  
58
    /**
59
     * Gets <i>Portable View</i> name
60
     *
61
     * @return
62
     */
63
    String getName();
64

  
65
    /**
66
     * Gets <i>Portable View</i> description
67
     *
68
     * @return
69
     */
70
    String getDescription();
71

  
72
    /**
73
     * Gets <i>Portable View</i> version
74
     *
75
     * @return
76
     */
77
    int getVersion();
78

  
79
    /**
80
     * Gets <i>Portable View</i> build number
81
     *
82
     * @return
83
     */
84
    int getBuildNumber();
85

  
86
    /**
87
     * Gets <i>Portable View</i> creation timestamp
88
     *
89
     * @return
90
     */
91
    Date getCreationTimestamp();
92

  
93
    /**
94
     * Gets full envelope
95
     *
96
     * @return
97
     */
98
    Envelope getFullEnvelope();
99

  
100
    /**
101
     * Returns CRS
102
     *
103
     * @return
104
     */
105
    IProjection getCRS();
106

  
107
    /**
108
     * Returns {@link DynValue} definition
109
     *
110
     * @return
111
     */
112
    DynStruct getDynDefinition();
113

  
114
    /**
115
     * Returns {@link DynObject} description
116
     *
117
     * @return
118
     */
119
    DynObject getDynObject();
120
}
org.gvsig.educa.portableview/tags/org.gvsig.educa.portableview-1.0.18/org.gvsig.educa.portableview.lib/org.gvsig.educa.portableview.lib.api/src/main/java/org/gvsig/educa/portableview/map/InvalidPortableViewFormatException.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.educa.portableview.map;
23

  
24
import java.io.File;
25

  
26
import org.gvsig.educa.portableview.PortableViewException;
27

  
28
/**
29
 * Exception Throws when try to open a PortableView file with invalid format
30
 *
31
 * @author gvSIG Team
32
 * @version $Id$
33
 *
34
 */
35
public class InvalidPortableViewFormatException extends PortableViewException {
36

  
37
    /**
38
     *
39
     */
40
    private static final long serialVersionUID = 8895685032043751029L;
41

  
42
    private static final String MESSAGE =
43
        "Invalid format of a PortableView file [%(filePath)]: %(info)";
44

  
45
    private static final String KEY = "_InvalidPortableViewFormatException";
46

  
47
    /**
48
     * Invalid format of a portable view file by unspecified problem
49
     *
50
     * @param mapFile
51
     */
52
    public InvalidPortableViewFormatException(File mapFile) {
53
        this(mapFile, "unspecified problem");
54
    }
55

  
56
    /**
57
     * Invalid format of a portable view file
58
     *
59
     * @param mapFile
60
     * @param message
61
     *            problem description
62
     */
63
    public InvalidPortableViewFormatException(File mapFile, String message) {
64
        super(MESSAGE, KEY, serialVersionUID);
65
        setValue("info", message);
66
        setValue("filePath", mapFile.getAbsolutePath());
67
    }
68

  
69
    /**
70
     * Invalid format of a portable view file
71
     *
72
     * @param mapFile
73
     * @param message
74
     *            problem description
75
     * @param cause
76
     */
77
    public InvalidPortableViewFormatException(File mapFile, String message,
78
        Throwable cause) {
79
        super(MESSAGE, cause, KEY, serialVersionUID);
80
        setValue("info", message);
81
        setValue("filePath", mapFile.getAbsolutePath());
82
    }
83

  
84
    /**
85
     * Invalid format of a portable view file
86
     *
87
     * @param mapFile
88
     */
89
    public InvalidPortableViewFormatException(File mapFile, Throwable cause) {
90
        this(mapFile, "initializing problem", cause);
91
    }
92

  
93
}
org.gvsig.educa.portableview/tags/org.gvsig.educa.portableview-1.0.18/org.gvsig.educa.portableview.lib/org.gvsig.educa.portableview.lib.api/src/main/java/org/gvsig/educa/portableview/PortableViewManager.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.educa.portableview;
23

  
24
import java.io.File;
25
import java.io.IOException;
26
import java.util.List;
27

  
28
import org.gvsig.educa.portableview.compilation.PortableViewCompilation;
29
import org.gvsig.educa.portableview.compilation.PortableViewCompiler;
30
import org.gvsig.educa.portableview.map.CantLoadContextException;
31
import org.gvsig.educa.portableview.map.InvalidPortableViewFormatException;
32
import org.gvsig.educa.portableview.map.PortableView;
33
import org.gvsig.educa.portableview.map.PortableViewInformation;
34
import org.gvsig.tools.dispose.Disposable;
35

  
36
/**
37
 * Library Manager.
38
 * </p>
39
 * Expose main library's functionalities:
40
 * <ul>
41
 * <li>Set default folders configuration</li>
42
 * <li>Get installed <i>Portable View</i></li>
43
 * <li>Identify and get a <i>Portable View</i> from a file</li>
44
 * <li>Create a new {@link PortableViewCompilation} instance</li>
45
 * <li>Create a new {@link PortableViewCompiler} instance</li>
46
 * </ul>
47
 *
48
 * @author gvSIG team
49
 * @version $Id$
50
 */
51
public interface PortableViewManager extends Disposable {
52

  
53
    /**
54
     * Gets default folder to locate installed <i>Portable View</i>
55
     *
56
     * @return default installation folder
57
     */
58
    String getInstallationMapFolder();
59

  
60
    /**
61
     * Sets default folder to locate installed <i>Portable View</i>
62
     *
63
     * @param folder
64
     * @throws IllegalArgumentException
65
     *             if <code>folder</code> is a file or can't read or not exists
66
     */
67
    void setInstallationMapFolder(String folder);
68

  
69
    /**
70
     * Gets the folder to use to <i>open</i> any <i>Portable
71
     * View</i> before access to the information contained in it.
72
     *
73
     * @return temporal folder
74
     */
75
    String getTemporalFolder();
76

  
77
    /**
78
     * Sets the folder to use to <i>open</i> any <i>Portable View</i>
79
     *
80
     * @param folder
81
     * @throws IllegalArgumentException
82
     *             if <code>folder</code> is a file or can't write
83
     */
84
    void setTemporalFolder(String folder);
85

  
86
    /**
87
     * Clear all data in temporal folder
88
     */
89
    void cleanAllTemporalData();
90

  
91
    /**
92
     * Returns all <i>Portable View</i> installed
93
     * </p>
94
     * Uses installation folder to locate them
95
     *
96
     * @return All <i>Portable View></i> installed
97
     */
98
    List<PortableView> getInstalledMaps();
99

  
100
    /**
101
     * Returns all <i>Portable View</i> installed into the specified folder
102
     * </p>
103
     * Uses installation folder to locate them
104
     *
105
     * @param folder
106
     *            to analyze
107
     * @return All <i>Portable View></i> installed
108
     * @throws IllegalArgumentException
109
     *             if folder is not valid (a readable folder)
110
     */
111
    List<PortableView> getInstalledMaps(String folder);
112

  
113
    /**
114
     * Gets a {@link PortableView} from a file
115
     * </p>
116
     *
117
     * @param file
118
     * @return the <i>Portable View</i>
119
     * @throws InvalidPortableViewFormatException
120
     */
121
    PortableView getMapFromFile(File file)
122
        throws InvalidPortableViewFormatException;
123

  
124
    /**
125
     * Gets a {@link PortableView} from intalledMaps
126
     * by its id
127
     * </p>
128
     *
129
     * @param mapid
130
     *            PortableView id
131
     * @return the <i>Portable View</i>
132
     */
133
    PortableView getMapById(String mapId);
134

  
135
    /**
136
     * Informs if a file is a valid <i>Portable View</i> file
137
     *
138
     * @param file
139
     * @return
140
     */
141
    boolean isMap(File file);
142

  
143
    /**
144
     * Informs if a folder is a valid <i>Portable View</i> installed folder
145
     *
146
     * @param file
147
     * @return
148
     */
149
    boolean isAPortableViewIntalledFolder(File folder);
150

  
151
    /**
152
     * Creates a new instance of a {@link PortableViewCompilation}
153
     *
154
     * @return
155
     */
156
    PortableViewCompilation createCompilationInstance();
157

  
158
    /**
159
     * Creates a new instance of a {@link PortableViewCompilation} based on
160
     * values <code>map</code>
161
     *
162
     * @param map
163
     *            to use as template
164
     * @return
165
     * @throws IOException
166
     * @throws CantLoadContextException
167
     * @throws InvalidPortableViewFormatException
168
     */
169
    PortableViewCompilation createCompilationInstanceFromMap(PortableView map)
170
        throws InvalidPortableViewFormatException, CantLoadContextException,
171
        IOException;
172

  
173
    /**
174
     * Create a new instance of a {@link PortableViewCompiler}
175
     *
176
     * @return
177
     */
178
    PortableViewCompiler createCompilerInstance();
179

  
180
    /**
181
     * Generates the base name for a PortableView file using its info data
182
     *
183
     * @param info
184
     * @return
185
     */
186
    String getBaseFileNameFromInfo(PortableViewInformation info);
187

  
188
    /**
189
     * Generates the base name for a PortableView file
190
     *
191
     * @param info
192
     * @return
193
     */
194
    String getBaseFileNameFromInfo(String id, String name, int version,
195
        int buildNumber);
196

  
197
    /**
198
     * Create a gvSIG package file (gvspkg) from a portableView
199
     *
200
     * @param mapId
201
     *            id of map to export
202
     * @param targetFolder
203
     *            where write package file
204
     * @return
205
     * @throws PortableViewException
206
     * @throws IOException
207
     */
208
    File generatePackageFile(String mapId, File targetFolder)
209
        throws PortableViewException, IOException;
210

  
211
    /**
212
     * Create a gvSIG package file (gvspkg) from a portableView installed folder
213
     *
214
     * @param portableViewIntallFolder
215
     *            folder of a installed PortableView
216
     * @param targetFolder
217
     *            where write package file
218
     * @return
219
     * @throws PortableViewException
220
     * @throws IOException
221
     */
222
    File generatePackageFile(File portableViewIntallFolder, File targetFolder)
223
        throws PortableViewException, IOException;
224

  
225
    /**
226
     * Returns the translation of a string.
227
     *
228
     * @param key
229
     *            String to translate
230
     * @return a String with the translation of the string passed by parameter
231
     */
232
    public String getTranslation(String key);
233
}
org.gvsig.educa.portableview/tags/org.gvsig.educa.portableview-1.0.18/org.gvsig.educa.portableview.lib/org.gvsig.educa.portableview.lib.api/src/main/java/org/gvsig/educa/portableview/compilation/CompilationException.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.educa.portableview.compilation;
23

  
24
import org.gvsig.educa.portableview.PortableViewException;
25

  
26
/**
27
 * Exception Throws in a PortableView compilation process
28
 *
29
 * @author gvSIG Team
30
 * @version $Id$
31
 *
32
 */
33
public class CompilationException extends PortableViewException {
34

  
35
    /**
36
     *
37
     */
38
    private static final long serialVersionUID = -1052257268555865780L;
39

  
40
    private static final String MESSAGE =
41
        "Problem found compiling Portable view [%(portableViewId)]: %(info)";
42

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

  
45
    /**
46
     * Invalid format of a portable view file
47
     *
48
     * @param mapFile
49
     * @param mapContextFile
50
     * @param message
51
     *            problem description
52
     * @param cause
53
     */
54
    public CompilationException(String portableViewId, String message,
55
        Throwable cause) {
56
        super(MESSAGE, cause, KEY, serialVersionUID);
57
        setValue("info", message);
58
        setValue("portableViewId", portableViewId);
59
    }
60

  
61
    /**
62
     * Invalid format of a portable view file
63
     *
64
     * @param mapFile
65
     * @param mapContextFile
66
     * @param cause
67
     */
68
    public CompilationException(String portableViewId, Throwable cause) {
69
        this(portableViewId, "compilation problem", cause);
70
    }
71

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

Also available in: Unified diff