Revision 376

View differences:

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

  
5
---------------------
6
Vistas Portables
7
---------------------
8

  
9
Descripci?n
10
==============
11

  
12
Este directorio contiene los fuentes de la funcionalidad Vistas Portables.
13

  
14
Requisitos
15
==============
16

  
17
* Maven 2.6 or higher
18

  
19
* Java JDK 1.5 or higher
20

  
21
Para trabajar con eclipse
22
--------------------------
23

  
24
Ver `Gu?a del desarrollador en gvSIG.org <https://gvsig.org/web/projects/gvsig-desktop/docs/devel/gvsig-devel-guide/2.0.0/>`_ y el fichero ``REAME-ECLIPSE.txt``
25

  
26
Contenido
27
==========
28

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

  
32
Fuentes de la funcionalidad. Estos proyectos contienen los procesos y l?gica principal sin dependencias de interface de usuario.
33

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

  
37
Componentes de interface de usuario para gestionar los servicios que ofrece la librer??a.
38

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

  
42
Peque?a aplicaci?n que permite ejecutar las funcionalidades y realizar pruebas funcionales.
43

  
44
Ver `Ejecutar aplicaci?n de pruebas`_ para saber como arrancarla.
45

  
46
pom.xml
47
---------
48

  
49
Archivo de definici?n de proyecto Maven.
50

  
51
README.txt LEEME.txt
52
----------------------
53

  
54
Este fichero (en formato reStructureText, para mas informaci?n sobre este ver el `portal de gvSIG <https://gvsig.org/web/projects/gvsig-desktop/docs/devel/guia-para-documentar/el-formato-restructuredtext>`_  en la `referencia de docUtils  <http://docutils.sourceforge.net/rst.html>`_)
55

  
56

  
57
Compilaci?n
58
================
59

  
60
Desde el shell
61
----------------
62

  
63
Ejecute este comando::
64

  
65
    org.gvsig.educa.portablewview$ mvn clean install
66

  
67

  
68
Desde eclipse
69
--------------
70
Ver `Trabajar con un proyecto de la gu?a de desarrollador en gvSIG.org <https://gvsig.org/web/projects/gvsig-desktop/docs/devel/gvsig-devel-guide/2.0.0/trabajar-con-un-proyecto>`_
71

  
72
En algunos proyectos puede que sea necesario user el comando ``mvn eclipse:clean eclipse:eclipse`` e importar como *Standar/Import existing project...* en vez de cargar como *Maven Project*. Esto es debido a que, en algunas circunstancias, parece que el plugin de Maven del eclipse no prepara el *classpath* de forma correcta.
73

  
74

  
75
Empaquetado
76
===============
77

  
78
Esta funcionalidad no tiene ning?n proyecto pensado para empaquetar de forma independiente.
79

  
80
Versionado
81
--------------
82

  
83
Para cambiar el n?mero de versi?n de los plugins solo es necesario ajustar la etiqueta ``project/version`` del fichero *pom.xml*. Los subproyectos heredar?n el valor.
84

  
85
La pol??tica de versi?n es la est?ndar. Los cambios en los numeroso son:
86

  
87
* tercer n?mero: Arreglo de errores y mejoras menores. Sin cambios en el API.
88
* segundo n?mero: Arreglo de erroes y mejoras. Pueden haber cambios menores en el API. Los elementos marcados como *deprecated* en versiones anteriores pueden eliminarse. Sin cambios de arquitectura.
89
* primer n?mero: Cambios mayores.
90

  
91
Crear un tag
92
------------------
93

  
94
TODO: usar el plugin *release* de maven
95

  
96
Usar el comando *svn copy*. El proceso podr?a ser:
97

  
98
#. Comprobar que no hay cambios en la copia local::
99

  
100
   svn up ; svn status
101

  
102
#. Comprobar que los proyecto compilan y pasan todas las bater?as de test::
103

  
104
   mvn clean install
105

  
106
#. Actualizar el fichero *pom.xml* con la versi?n de tag (normalmente quitando el sufijo *-SNAPSHOT*)
107
#. Crear el directorio para el tag en el servidor::
108

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

  
111
#. Subir la copia local al directorio del tag en el servidor::
112

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

  
115
#. Actualizar el *pom.xml* a la siguiente version (y a?adirle el sufijo *-SNAPSHOT*)
116
#. Subir los cambios del *pom.xml*::
117

  
118
   svn commit -m "Set new version {version}-SNAPSHOT" pom.xml
119

  
120

  
121
i18n
122
======
123

  
124
Los ficheros de internacionalizaci?n se pueden encontrar en los directorios:
125

  
126
+ */org.gvsig.educa.portableview.swing/org.gvsig.educa.portableview.swing.impl/src/main/resources/org/gvsig/educa/portableview/swing/impl/i18n*
127
+ *org.gvsig.educa.portableview.lib/org.gvsig.educa.portableview.lib.impl/src/main/resources/org/gvsig/educa/portableview/impl/i18n*
128

  
129
La internacionalizaci?n est? basada en el mecanismo est?ndar de los *resource bundle*. Para a?adir un nuevo idioma es necesario a?adir el fichero de propiedades en todos los directorio con el codigo de idioma adecuado.
130

  
131
Ejecutar aplicaci?n de pruebas
132
=================================
133

  
134
Desde el Shell
135
----------------
136

  
137
Despu?s del proceso de `Compilaci?n`_ , ejecute estos comandos::
138

  
139
    org.gvsig.educa.portablewview$ cd org.gvsig.educa.portablewview.main
140
    org.gvsig.educa.portablewview/org.gvsig.educa.portablewview.main$ mvn exec:java
141

  
142
Desde el eclipse
143
------------------
144

  
145
Seleccione el proyecto ``org.gvsig.educa.portableview.main`` en el *Project tree* de la *Java perspective*, haga click con el bot?n derecho y seleccione ``Run as.../Java application``. Seleccione la clase ``Main`` del propio proyecto.
146

  
147
Si tiene problemas al ejecutar, compruebe la nota de la secci?n `Compilaci?n`_ sobre la importaci?n del proyecto.
148

  
org.gvsig.educa.portableview/tags/org.gvsig.educa.portableview-1.0.19/org.gvsig.educa.portableview.app/org.gvsig.educa.portableview.app.editor/pom.xml
1
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2
	<modelVersion>4.0.0</modelVersion>
3
	<parent>
4
		<groupId>org.gvsig</groupId>
5
		<artifactId>org.gvsig.educa.portableview.app</artifactId>
6
		<version>1.0.19</version>
7
	</parent>
8
	<artifactId>org.gvsig.educa.portableview.app.editor</artifactId>
9
	<name>org.gvsig.educa.portableview.app.editor</name>
10

  
11
	<dependencies>
12
            <dependency>
13
                <groupId>org.gvsig</groupId>
14
                <artifactId> org.gvsig.educa.portableview.app.viewer </artifactId>
15
                <scope>compile</scope>
16
            </dependency>
17
            <dependency>
18
                <groupId>org.gvsig</groupId>
19
                <artifactId>org.gvsig.about.api</artifactId>
20
                <scope>compile</scope>
21
            </dependency>
22
	</dependencies>
23
	  	<properties>
24
		<gvsig.package.info.state>testing</gvsig.package.info.state>
25
        <gvsig.package.info.official>true</gvsig.package.info.official>
26
		<gvsig.package.info.dependencies>required: org.gvsig.app -ge 2.1.0</gvsig.package.info.dependencies>
27
        <gvsig.package.info.categories>Portable View</gvsig.package.info.categories>
28
        <gvsig.package.info.name>Portable View: editor</gvsig.package.info.name>
29
        <gvsig.package.info.description>Portable View document: Provides tools to create and generate packages of Portable View.</gvsig.package.info.description>
30
        <gvsig.package.info.owner>gvSIG Association</gvsig.package.info.owner>
31
        <gvsig.package.info.javaVM>j1_6</gvsig.package.info.javaVM>
32
        <gvsig.package.info.sourcesURL>${project.scm.url}</gvsig.package.info.sourcesURL>
33
		<gvsig.package.info.poolURL>https://devel.gvsig.org/download/projects/gvsig-educa/pool/</gvsig.package.info.poolURL>
34
    </properties>
35

  
36
</project>
org.gvsig.educa.portableview/tags/org.gvsig.educa.portableview-1.0.19/org.gvsig.educa.portableview.app/org.gvsig.educa.portableview.app.editor/buildNumber.properties
1
#Thu Oct 29 16:19:58 CET 2015
2
buildNumber=29
org.gvsig.educa.portableview/tags/org.gvsig.educa.portableview-1.0.19/org.gvsig.educa.portableview.app/org.gvsig.educa.portableview.app.editor/src/main/java/org/gvsig/educa/portableview/app/editor/impl/CompilationListenerAdapter.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.app.editor.impl;
23

  
24
import org.gvsig.andami.messages.NotificationManager;
25
import org.gvsig.educa.portableview.app.editor.CompilationListener;
26
import org.gvsig.educa.portableview.compilation.PortableViewCompilation;
27
import org.gvsig.educa.portableview.compilation.PortableViewCompilerStatus;
28

  
29
/**
30
 * 
31
 * Utility class which allow just override {@link CompilationListener} that you
32
 * need without override the other (useful for inner class)
33
 * 
34
 * @author gvSIG Team
35
 * @version $Id$
36
 * 
37
 */
38
public abstract class CompilationListenerAdapter implements CompilationListener {
39

  
40
    /** {@inheridDoc} */
41
    public void finished(PortableViewCompilerStatus status) {
42
        // Nothing to do
43
    }
44

  
45
    /** {@inheridDoc} */
46
    public void fail(PortableViewCompilerStatus status) {
47
        // Nothing to do
48
    }
49

  
50
    /** {@inheridDoc} */
51
    public void canceledCompilation(PortableViewCompilerStatus status) {
52
        // Nothing to do
53
    }
54

  
55
    /** {@inheridDoc} */
56
    public void canceledEditing(PortableViewCompilation compilation) {
57
        // Nothing to do
58
    }
59

  
60
    public void exception(String message, Throwable exception) {
61
        // use notification manager by default
62
        NotificationManager.addError(message, exception);
63
    }
64
}
org.gvsig.educa.portableview/tags/org.gvsig.educa.portableview-1.0.19/org.gvsig.educa.portableview.app/org.gvsig.educa.portableview.app.editor/src/main/java/org/gvsig/educa/portableview/app/editor/impl/PortableViewEditorDefaultImplLibrary.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.app.editor.impl;
23

  
24
import org.gvsig.educa.portableview.app.editor.PortableViewEditorLibrary;
25
import org.gvsig.educa.portableview.app.editor.PortableViewEditorLocator;
26
import org.gvsig.educa.portableview.app.editor.PortableViewEditorManager;
27
import org.gvsig.tools.library.AbstractLibrary;
28
import org.gvsig.tools.library.LibraryException;
29

  
30
/**
31
 * Library for default {@link PortableViewEditorManager} implementation
32
 * register.
33
 *
34
 * @author gvSIG team
35
 * @version $Id$
36
 */
37
public class PortableViewEditorDefaultImplLibrary extends AbstractLibrary {
38

  
39
    @Override
40
    public void doRegistration() {
41
        registerAsImplementationOf(PortableViewEditorLibrary.class);
42
    }
43

  
44
    /** {@inheridDoc} */
45
    @Override
46
    protected void doInitialize() throws LibraryException {
47
        PortableViewEditorLocator
48
            .registerManager(DefaultPortableViewEditorManager.class);
49
    }
50

  
51
    /** {@inheridDoc} */
52
    @Override
53
    protected void doPostInitialize() throws LibraryException {
54
        // Do Nothing
55
    }
56

  
57
}
org.gvsig.educa.portableview/tags/org.gvsig.educa.portableview-1.0.19/org.gvsig.educa.portableview.app/org.gvsig.educa.portableview.app.editor/src/main/java/org/gvsig/educa/portableview/app/editor/impl/DefaultPortableViewEditorManager.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.app.editor.impl;
23

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

  
28
import javax.swing.JFileChooser;
29
import javax.swing.SwingUtilities;
30

  
31
import org.apache.commons.lang3.ObjectUtils;
32
import org.apache.commons.lang3.StringUtils;
33
import org.gvsig.andami.PluginServices;
34
import org.gvsig.andami.messages.NotificationManager;
35
import org.gvsig.andami.ui.mdiManager.IWindow;
36
import org.gvsig.app.project.Project;
37
import org.gvsig.app.project.ProjectManager;
38
import org.gvsig.app.project.documents.Document;
39
import org.gvsig.app.project.documents.view.ViewDocument;
40
import org.gvsig.app.project.documents.view.ViewManager;
41
import org.gvsig.educa.portableview.PortableViewException;
42
import org.gvsig.educa.portableview.PortableViewFileServices;
43
import org.gvsig.educa.portableview.PortableViewLocator;
44
import org.gvsig.educa.portableview.PortableViewManager;
45
import org.gvsig.educa.portableview.app.editor.CompilationListener;
46
import org.gvsig.educa.portableview.app.editor.PortableViewEditorManager;
47
import org.gvsig.educa.portableview.app.viewer.PortableViewDocument;
48
import org.gvsig.educa.portableview.app.viewer.PortableViewDocumentManager;
49
import org.gvsig.educa.portableview.compilation.PortableViewCompilation;
50
import org.gvsig.educa.portableview.compilation.PortableViewCompilationInformation;
51
import org.gvsig.educa.portableview.compilation.PortableViewCompiler;
52
import org.gvsig.educa.portableview.compilation.PortableViewCompilerStatus;
53
import org.gvsig.educa.portableview.map.CantLoadContextException;
54
import org.gvsig.educa.portableview.map.InvalidPortableViewFormatException;
55
import org.gvsig.educa.portableview.map.PortableView;
56
import org.gvsig.educa.portableview.map.PortableViewInformation;
57
import org.gvsig.educa.portableview.swing.PortableViewSwingLocator;
58
import org.gvsig.educa.portableview.swing.PortableViewSwingManager;
59
import org.gvsig.educa.portableview.swing.PortableViewWindowManager;
60
import org.gvsig.educa.portableview.swing.PortableViewWindowManager.MESSAGE_DIALOG_TYPE;
61
import org.gvsig.educa.portableview.swing.editor.PortableViewCompilationEditor;
62
import org.gvsig.educa.portableview.swing.editor.PortableViewCompilationEditorListener;
63
import org.gvsig.fmap.mapcontext.MapContext;
64
import org.gvsig.tools.persistence.exception.PersistenceException;
65
import org.gvsig.tools.swing.api.windowmanager.WindowManager.MODE;
66

  
67
/**
68
 * <p>
69
 * Default implementation of {@link PortableViewEditorManager}
70
 * </p>
71
 *
72
 * @author gvSIG Team
73
 * @version $Id$
74
 *
75
 */
76
public class DefaultPortableViewEditorManager implements
77
		PortableViewEditorManager {
78

  
79
	private PortableViewDocumentManager docManager;
80
	private final PortableViewManager manager;
81
	private final PortableViewSwingManager swingManager;
82
	private final PortableViewWindowManager winManager;
83
	private final PortableViewFileServices fileServices;
84
	private File workFolder;
85
	private final JFileChooser fileChooser;
86

  
87
	/**
88
     *
89
     */
90
	public DefaultPortableViewEditorManager() {
91
		swingManager = PortableViewSwingLocator.getSwingManager();
92
		manager = swingManager.getManager();
93
		fileServices = PortableViewLocator.getFileServices();
94
		winManager = swingManager.getWindowManager();
95
		fileChooser = new JFileChooser();
96
	}
97

  
98
	/**
99
	 * <p>
100
	 * {@link CompilationListener} instance which create a new
101
	 * {@link PortableViewDocument} from a {@link ViewDocument}
102
	 * </p>
103
	 * <p>
104
	 * Delegates on previously received listener (if any)
105
	 * </p>
106
	 *
107
	 * @author gvSIG Team
108
	 * @version $Id$
109
	 *
110
	 */
111
	private class CreateDocumentListener implements CompilationListener {
112

  
113
		private final CompilationListener delegate;
114
		private final boolean openWindow;
115
		private final ViewDocument sourceView;
116

  
117
		/**
118
		 * @param openWindow
119
		 *
120
		 */
121
		public CreateDocumentListener(ViewDocument sourceView,
122
				CompilationListener delegate, boolean openWindow) {
123
			this.sourceView = sourceView;
124
			this.delegate = delegate;
125
			this.openWindow = openWindow;
126
		}
127

  
128
		/** {@inheridDoc} */
129
		public void finished(PortableViewCompilerStatus status) {
130
			// Gets created map
131
			PortableView map = manager.getMapById(status.getResultCompilation()
132
					.getInformation().getId());
133

  
134
			// Check if a document already exist for this map
135
			PortableViewDocumentManager docManager = getDocManager();
136
			PortableViewDocument doc = docManager.getDocumentForMap(map);
137
			if (doc == null) {
138
				doc = docManager.createDocument(map);
139
				getProject().add(doc);
140
			} else {
141
				// If exist reload
142
				try {
143
					doc.reloadPortableView();
144
				} catch (Exception ex) {
145
					NotificationManager
146
							.addError(
147
									swingManager
148
											.getTranslation("problems_reloading_portable_view"),
149
									ex);
150
				}
151
			}
152
			// Link view to portable view
153
			doc.setSourceView(sourceView);
154

  
155
			if (openWindow) {
156
				final IWindow window = docManager.getMainWindow(doc);
157
				SwingUtilities.invokeLater(new Runnable() {
158

  
159
					public void run() {
160
						PluginServices.getMDIManager().addWindow(window);
161
					}
162
				});
163
			}
164

  
165
			if (delegate != null) {
166
				delegate.finished(status);
167
			}
168
		}
169

  
170
		/** {@inheridDoc} */
171
		public void canceledCompilation(PortableViewCompilerStatus status) {
172
			if (delegate != null) {
173
				delegate.canceledCompilation(status);
174
			}
175
		}
176

  
177
		/** {@inheridDoc} */
178
		public void canceledEditing(PortableViewCompilation compilation) {
179
			if (delegate != null) {
180
				delegate.canceledEditing(compilation);
181
			}
182
		}
183

  
184
		/** {@inheridDoc} */
185
		public void fail(PortableViewCompilerStatus status) {
186
			if (delegate != null) {
187
				delegate.fail(status);
188
			} else {
189
				String msg = swingManager
190
						.getTranslation(
191
								"problems_creating_portable_view_from_a_view")
192
						.concat(": ").concat(status.getFailMessage());
193
				if (status.getException() != null) {
194
					NotificationManager.addWarning(msg, status.getException());
195
				} else {
196
					NotificationManager.addWarning(msg);
197
				}
198
			}
199
		}
200

  
201
		public void exception(String message, Throwable exception) {
202
			if (delegate != null) {
203
				delegate.exception(message, exception);
204
			} else {
205
				String msg = swingManager
206
						.getTranslation(
207
								"problems_creating_portable_view_from_a_view")
208
						.concat(": ").concat(message);
209
				NotificationManager.addError(msg, exception);
210
			}
211
		}
212

  
213
	}
214

  
215
	/**
216
	 * <p>
217
	 * {@link CompilationListener} instance which update the
218
	 * {@link PortableViewDocument} from its related {@link ViewDocument} (
219
	 * {@link PortableViewDocument#getSourceView()})
220
	 * </p>
221
	 * <p>
222
	 * Delegates on previously received listener (if any)
223
	 * </p>
224
	 *
225
	 * @author gvSIG Team
226
	 * @version $Id$
227
	 *
228
	 */
229
	private class UpdateDocumentListener implements CompilationListener {
230

  
231
		private final CompilationListener delegate;
232
		private final boolean openWindow;
233
		private final PortableViewDocument toUpdate;
234

  
235
		/**
236
		 * @param openWindow
237
		 *
238
		 */
239
		public UpdateDocumentListener(PortableViewDocument toUpdate,
240
				CompilationListener delegate, boolean openWindow) {
241
			this.toUpdate = toUpdate;
242
			this.delegate = delegate;
243
			this.openWindow = openWindow;
244
		}
245

  
246
		/** {@inheridDoc} */
247
		public void finished(PortableViewCompilerStatus status) {
248

  
249
			// close doc windows if it was opened
250
			PluginServices.getMDIManager().closeSingletonWindow(toUpdate);
251

  
252
			// Reload maps
253
			try {
254
				toUpdate.reloadPortableView();
255
			} catch (Exception ex) {
256
				NotificationManager
257
						.addError(
258
								swingManager
259
										.getTranslation("problems_reloading_portable_view"),
260
								ex);
261
				return;
262
			}
263

  
264
			if (openWindow) {
265
				final IWindow window = toUpdate.getFactory().getMainWindow(
266
						toUpdate);
267
				SwingUtilities.invokeLater(new Runnable() {
268

  
269
					public void run() {
270
						PluginServices.getMDIManager().addWindow(window);
271
					}
272
				});
273
			}
274

  
275
			if (delegate != null) {
276
				delegate.finished(status);
277
			}
278
		}
279

  
280
		/** {@inheridDoc} */
281
		public void canceledCompilation(PortableViewCompilerStatus status) {
282
			if (delegate != null) {
283
				delegate.canceledCompilation(status);
284
			}
285
		}
286

  
287
		/** {@inheridDoc} */
288
		public void canceledEditing(PortableViewCompilation compilation) {
289
			if (delegate != null) {
290
				delegate.canceledEditing(compilation);
291
			}
292
		}
293

  
294
		/** {@inheridDoc} */
295
		public void fail(PortableViewCompilerStatus status) {
296
			if (delegate != null) {
297
				delegate.fail(status);
298
			} else {
299
				String msg = swingManager
300
						.getTranslation("problems_regeneration_portable_view")
301
						.concat(": ").concat(status.getFailMessage());
302
				if (status.getException() != null) {
303
					NotificationManager.addWarning(msg, status.getException());
304
				} else {
305
					NotificationManager.addWarning(msg);
306
				}
307
			}
308
		}
309

  
310
		public void exception(String message, Throwable exception) {
311
			if (delegate != null) {
312
				delegate.exception(message, exception);
313
			} else {
314
				String msg = swingManager
315
						.getTranslation("problems_regeneration_portable_view")
316
						.concat(": ").concat(message);
317
				NotificationManager.addError(msg, exception);
318
			}
319
		}
320

  
321
	}
322

  
323
	/** {@inheridDoc} */
324
	public void createPortableViewFromView(ViewDocument view,
325
			CompilationListener listener, boolean openWindow) {
326

  
327
		if (view == null) {
328
			throw new IllegalArgumentException("View document required");
329
		}
330

  
331
		PortableViewCompilation compilation = manager
332
				.createCompilationInstance();
333

  
334
		PortableViewCompilationInformation info = compilation.getInformation();
335
		info.setName(view.getName());
336
		info.setId(generateIdForViewName(view.getName()));
337
		info.setVersion(1);
338

  
339
		compilation.setMapContext(view.getMapContext().cloneFMap());
340

  
341
		PortableViewCompilationEditor editor = swingManager
342
				.getCopilationEditor(compilation, false);
343

  
344
		final CreateDocumentListener myListener = new CreateDocumentListener(
345
				view, listener, openWindow);
346

  
347
		editor.setListener(new PortableViewCompilationEditorListener() {
348

  
349
			public void finished(final PortableViewCompilationEditor editor) {
350
				editor.getSwingComponent().setVisible(false);
351
				SwingUtilities.invokeLater(new Runnable() {
352

  
353
					public void run() {
354
						try {
355
							compileInInstallFolder(editor.getCompilation(),
356
									myListener);
357
						} catch (Exception ex) {
358
							myListener.exception("Exception compiling", ex);
359
						}
360
					}
361
				});
362
			}
363

  
364
			public void canceled(final PortableViewCompilationEditor editor) {
365
				editor.getSwingComponent().setVisible(false);
366
				SwingUtilities.invokeLater(new Runnable() {
367

  
368
					public void run() {
369
						myListener.canceledEditing(editor.getCompilation());
370
					}
371
				});
372
			}
373

  
374
		});
375

  
376
		winManager.showCompilationEditor(editor, MODE.WINDOW);
377
	}
378

  
379
	/** {@inheridDoc} */
380
	public void compileInInstallFolder(PortableViewCompilation compilation,
381
			CompilationListener listener) {
382

  
383
		if (compilation == null) {
384
			throw new IllegalArgumentException("Compilation required");
385
		}
386

  
387
		PortableViewCompiler compiler = manager.createCompilerInstance();
388

  
389
		compiler.setTargetFolder(manager.getInstallationMapFolder());
390

  
391
		// prepare a temp folder
392
		compiler.setWorkFolder(getWorkFolder());
393

  
394
		PortableViewCompilerStatus result = compiler.compile(compilation);
395
		if (listener != null) {
396
			if (result.getStatus() == PortableViewCompilerStatus.Status.finished_ok) {
397
				listener.finished(result);
398
				return;
399
			}
400
			if (result.getStatus() == PortableViewCompilerStatus.Status.canceled) {
401
				listener.canceledCompilation(result);
402
				return;
403
			}
404
			listener.fail(result);
405
		}
406
	}
407

  
408
	/**
409
	 * Generates a PortableView id from a View Document name
410
	 *
411
	 * @param viewName
412
	 * @return
413
	 */
414
	private String generateIdForViewName(String viewName) {
415
		String name = StringUtils.replace(viewName.trim(), " ", "_");
416
		return name;
417
	}
418

  
419
	/**
420
	 * Prepare a work folder for compiler base on
421
	 * {@link PortableViewManager#getTemporalFolder()}
422
	 *
423
	 * @return
424
	 */
425
	private String getWorkFolder() {
426
		if (workFolder == null) {
427
			workFolder = fileServices.getNewWritableFolder(
428
					new File(manager.getTemporalFolder()), "_compiler_");
429
			workFolder.deleteOnExit();
430
		}
431
		return workFolder.getAbsolutePath();
432
	}
433

  
434
	/** {@inheridDoc} */
435
	public PortableViewDocumentManager getDocManager() {
436
		if (docManager == null) {
437
			docManager = (PortableViewDocumentManager) ProjectManager
438
					.getInstance().getDocumentManager(
439
							PortableViewDocumentManager.TYPENAME);
440
		}
441
		return docManager;
442
	}
443

  
444
	/** {@inheridDoc} */
445
	public File generatePackage(PortableViewDocument portableView,
446
			File targetFolder) throws PortableViewException, IOException {
447

  
448
		if (portableView == null) {
449
			throw new IllegalArgumentException(
450
					"Portable View document required");
451
		}
452

  
453
		return manager.generatePackageFile(portableView.getPortableView()
454
				.getInformation().getId(), targetFolder);
455

  
456
	}
457

  
458
	/** {@inheridDoc} */
459
	public File generatePackage(PortableViewDocument portableView)
460
			throws PortableViewException, IOException {
461
		File target = askForAOutputFolder(swingManager
462
				.getTranslation("Select_folder_to_store_package"));
463
		if (target != null) {
464
			return generatePackage(portableView, target);
465
		}
466
		return null;
467

  
468
	}
469

  
470
	/** {@inheridDoc} */
471
	public PortableViewDocument getPortableViewDocumentByView(ViewDocument view) {
472

  
473
		if (view == null) {
474
			throw new IllegalArgumentException("View document required");
475
		}
476

  
477
		List<Document> documents = getProject().getDocuments(
478
				PortableViewDocumentManager.TYPENAME);
479
		PortableViewDocument map;
480
		for (Document doc : documents) {
481
			map = (PortableViewDocument) doc;
482
			if (ObjectUtils.equals(map.getSourceView(), view)) {
483
				return map;
484
			}
485
		}
486
		return null;
487
	}
488

  
489
	/**
490
	 * Gets current gvSIG project
491
	 *
492
	 * @return
493
	 */
494
	public Project getProject() {
495
		return ProjectManager.getInstance().getCurrentProject();
496
	}
497

  
498
	/**
499
	 * Shows a dialog to ask a output folder
500
	 *
501
	 * @param description
502
	 *            of the file is for
503
	 * @return
504
	 */
505
	public File askForAOutputFolder(String description) {
506
		fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
507
		int targetFolderAnswere = fileChooser.showDialog(null, description);
508
		if (targetFolderAnswere != JFileChooser.APPROVE_OPTION) {
509
			return null;
510
		}
511
		return fileChooser.getSelectedFile();
512
	}
513

  
514
	/** {@inheridDoc} */
515
	public ViewDocument exportPortableViewToView(PortableViewDocument map,
516
			boolean openViewWindow) throws IOException,
517
			InvalidPortableViewFormatException, PersistenceException {
518
		File target;
519
		while (true) {
520
			target = askForAOutputFolder(swingManager
521
					.getTranslation("Select_folder_to_extract_data"));
522
			if (target == null) {
523
				return null;
524
			}
525
			if (!target.exists()) {
526
				continue;
527
			}
528
			if (target.list().length == 0) {
529
				break;
530
			} else {
531
				winManager.showMessageDialog(swingManager
532
						.getTranslation("Select_folder_to_extract_data"),
533
						swingManager.getTranslation("folder_must_be_empty"),
534
						MESSAGE_DIALOG_TYPE.WARNING);
535
			}
536
		}
537
		return exportPortableViewToView(map, target, openViewWindow);
538
	}
539

  
540
	/** {@inheridDoc} */
541
	public ViewDocument exportPortableViewToView(PortableViewDocument map,
542
			File exportFolder, boolean openViewWindow) throws IOException,
543
			InvalidPortableViewFormatException, PersistenceException {
544

  
545
		if (map == null) {
546
			throw new IllegalArgumentException(
547
					"Portable View document required");
548
		}
549

  
550
		if (!fileServices.isWritableFolder(exportFolder)) {
551
			throw new IllegalArgumentException(
552
					"Not a writable folder: ".concat(exportFolder
553
							.getAbsolutePath()));
554
		}
555
		if (exportFolder.list().length > 0) {
556
			throw new IllegalArgumentException(
557
					"Not a empty folder: ".concat(exportFolder
558
							.getAbsolutePath()));
559
		}
560

  
561
		File mapFile = new File(map.getPortableView().getSourceFilePath());
562
		fileServices.unzipFile(mapFile, exportFolder);
563

  
564
		// Prepares mapContext file path
565
		File mapContextFile = new File(exportFolder,
566
				"mapContext/mapContext.xml");
567

  
568
		// Check if mapContext file exists
569
		if (!mapContextFile.exists()) {
570
			throw new InvalidPortableViewFormatException(mapFile,
571
					"Missing mapContext/mapContext.xml file in deployed map: "
572
							.concat(mapContextFile.getAbsolutePath()));
573
		}
574
		if (!mapContextFile.isFile()) {
575
			throw new InvalidPortableViewFormatException(mapFile,
576
					"mapContext/mapContext.xml file in deployed map is not a file: "
577
							.concat(mapContextFile.getAbsolutePath()));
578
		}
579

  
580
		// Load map context
581
		MapContext mapContext = fileServices.loadMapContext(mapContextFile,
582
				exportFolder);
583

  
584
		// Create view document
585
		ProjectManager projectManager = ProjectManager.getInstance();
586
		final ViewDocument view = (ViewDocument) projectManager
587
				.createDocument(ViewManager.TYPENAME);
588

  
589
		PortableViewInformation info = map.getPortableView().getInformation();
590

  
591
		// Fill view values
592
		view.setName(map.getName());
593
		view.setComment(String.format(
594
				swingManager.getTranslation("generated_from_portable_view"),
595
				info.getId(), info.getName(), info.getVersion(),
596
				info.getBuildNumber()));
597
		view.setMapContext(mapContext);
598

  
599
		// Add view document to project
600
		getProject().add(view);
601

  
602
		if (openViewWindow) {
603
			// Open view window
604
			SwingUtilities.invokeLater(new Runnable() {
605

  
606
				public void run() {
607
					IWindow viewWindow = view.getFactory().getMainWindow(view);
608
					PluginServices.getMDIManager().addWindow(viewWindow);
609

  
610
				}
611
			});
612
		}
613

  
614
		// If map has no source view link it to the new one
615
		if (map.getSourceView() == null) {
616
			map.setSourceView(view);
617
		}
618

  
619
		return view;
620
	}
621

  
622
	/** {@inheridDoc} */
623
	public void regeneratePortableView(PortableViewDocument map,
624
			CompilationListener listener, boolean openWindow)
625
			throws InvalidPortableViewFormatException,
626
			CantLoadContextException, IOException {
627
		if (map == null) {
628
			throw new IllegalArgumentException(
629
					"Portable View document is required");
630
		}
631
		if (map.getSourceView() == null) {
632
			// No source view it can't regenerate it
633
			return;
634
		}
635
		ViewDocument document = map.getSourceView();
636

  
637
		// Get a compilation instance from map
638
		PortableViewCompilation compilation = manager
639
				.createCompilationInstanceFromMap(map.getPortableView());
640

  
641
		// Update map context from view
642
		compilation.setMapContext(document.getMapContext());
643

  
644
		// Create a editor and disable id change
645
		PortableViewCompilationEditor editor = swingManager
646
				.getCopilationEditor(compilation, false);
647
		editor.allowChangeId(false);
648

  
649
		// Add update listener
650
		final UpdateDocumentListener myListener = new UpdateDocumentListener(
651
				map, listener, openWindow);
652

  
653
		// Add editor listener which call to compiler or notify cancel to
654
		// listener
655
		editor.setListener(new PortableViewCompilationEditorListener() {
656

  
657
			public void finished(final PortableViewCompilationEditor editor) {
658
				editor.getSwingComponent().setVisible(false);
659
				SwingUtilities.invokeLater(new Runnable() {
660

  
661
					public void run() {
662
						try {
663
							compileInInstallFolder(editor.getCompilation(),
664
									myListener);
665
						} catch (Exception ex) {
666
							myListener.exception("Exception compiling", ex);
667
						}
668

  
669
					}
670
				});
671
			}
672

  
673
			public void canceled(final PortableViewCompilationEditor editor) {
674
				editor.getSwingComponent().setVisible(false);
675
				SwingUtilities.invokeLater(new Runnable() {
676

  
677
					public void run() {
678
						myListener.canceledEditing(editor.getCompilation());
679
					}
680
				});
681
			}
682

  
683
		});
684

  
685
		// Show editor
686
		winManager.showCompilationEditor(editor, MODE.WINDOW);
687

  
688
	}
689
}
org.gvsig.educa.portableview/tags/org.gvsig.educa.portableview-1.0.19/org.gvsig.educa.portableview.app/org.gvsig.educa.portableview.app.editor/src/main/java/org/gvsig/educa/portableview/app/editor/RegeneratePortableViewExtension.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.app.editor;
23

  
24
import javax.swing.SwingUtilities;
25

  
26
import org.gvsig.andami.PluginServices;
27
import org.gvsig.andami.messages.NotificationManager;
28
import org.gvsig.andami.plugins.Extension;
29
import org.gvsig.andami.ui.mdiManager.IWindow;
30
import org.gvsig.app.project.documents.view.gui.IView;
31
import org.gvsig.educa.portableview.app.viewer.PortableViewDocument;
32
import org.gvsig.educa.portableview.app.viewer.ui.PortableViewDocumentViewer;
33
import org.gvsig.educa.portableview.swing.PortableViewSwingLocator;
34
import org.gvsig.educa.portableview.swing.PortableViewSwingManager;
35

  
36
/**
37
 * Andami extension to update a Portable View from its source View.
38
 *
39
 * @author gvSIG Team
40
 * @version $Id$
41
 */
42
public class RegeneratePortableViewExtension extends Extension {
43

  
44
    private PortableViewEditorManager editorManager;
45
    private PortableViewSwingManager swingManager;
46

  
47
    public void initialize() {
48
        // Do nothing
49
    }
50

  
51
    @Override
52
    public void postInitialize() {
53
        editorManager = PortableViewEditorLocator.getManager();
54
        swingManager = PortableViewSwingLocator.getSwingManager();
55
    }
56

  
57
    public void execute(String actionCommand) {
58
        IWindow window = PluginServices.getMDIManager().getActiveWindow();
59
        final PortableViewDocument tmDocument = getRelatedPortableView(window);
60

  
61
        SwingUtilities.invokeLater(new Runnable() {
62

  
63
            public void run() {
64
                try {
65
                    editorManager.regeneratePortableView(tmDocument, null, true);
66
                } catch (Exception ex) {
67
                    NotificationManager.addError(swingManager
68
                        .getTranslation("problems_regeneration_portable_view"),
69
                        ex);
70
                }
71

  
72
            }
73
        });
74
    }
75

  
76
    /** {@inheridDoc} */
77
    public boolean isEnabled() {
78
        IWindow window = PluginServices.getMDIManager().getActiveWindow();
79
        PortableViewDocument thMap = getRelatedPortableView(window);
80
        return thMap != null && thMap.getSourceView() != null;
81
    }
82

  
83
    /** {@inheridDoc} */
84
    public boolean isVisible() {
85
        // it's a Portable View view
86
        IWindow window = PluginServices.getMDIManager().getActiveWindow();
87
        return window instanceof PortableViewDocumentViewer
88
            || window instanceof IView;
89
    }
90

  
91
    /**
92
     * <p>
93
     * Returns related portable view of a window
94
     * </p>
95
     *
96
     * @param window
97
     * @return
98
     */
99
    private PortableViewDocument getRelatedPortableView(IWindow window) {
100
        if (editorManager == null) {
101
            // initialization process not finished yet
102
            return null;
103
        }
104
        if (window instanceof IView) {
105
            return editorManager.getPortableViewDocumentByView(((IView) window)
106
                .getViewDocument());
107
        } else
108
            if (window instanceof PortableViewDocumentViewer) {
109
                return ((PortableViewDocumentViewer) window)
110
                    .getPortableViewDocument();
111

  
112
            }
113
        return null;
114

  
115
    }
116
}
org.gvsig.educa.portableview/tags/org.gvsig.educa.portableview-1.0.19/org.gvsig.educa.portableview.app/org.gvsig.educa.portableview.app.editor/src/main/java/org/gvsig/educa/portableview/app/editor/OpenRelatedPortableViewExtension.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.app.editor;
23

  
24
import org.gvsig.andami.PluginServices;
25
import org.gvsig.andami.ui.mdiManager.IWindow;
26
import org.gvsig.app.project.documents.view.gui.IView;
27

  
28
/**
29
 * Andami extension which opens related portable view of a view
30
 * 
31
 * @author gvSIG Team
32
 * @version $Id$
33
 * 
34
 */
35
public class OpenRelatedPortableViewExtension extends
36
    OpenRelatedDocumentExtension {
37

  
38
    @Override
39
    public boolean isVisible() {
40
        IWindow window = PluginServices.getMDIManager().getActiveWindow();
41
        return window instanceof IView && super.isVisible();
42
    }
43
}
org.gvsig.educa.portableview/tags/org.gvsig.educa.portableview-1.0.19/org.gvsig.educa.portableview.app/org.gvsig.educa.portableview.app.editor/src/main/java/org/gvsig/educa/portableview/app/editor/CompilationListener.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.app.editor;
23

  
24
import org.gvsig.educa.portableview.compilation.PortableViewCompilation;
25
import org.gvsig.educa.portableview.compilation.PortableViewCompilerStatus;
26

  
27
/**
28
 * Portable View Document compilation listener
29
 * 
30
 * @author gvSIG Team
31
 * @version $Id$
32
 * 
33
 */
34
public interface CompilationListener {
35

  
36
    /**
37
     * Call when process is success
38
     * 
39
     * @param status
40
     */
41
    void finished(PortableViewCompilerStatus status);
42

  
43
    /**
44
     * Call when process is canceled in the compilation step
45
     * 
46
     * @param status
47
     */
48
    void canceledCompilation(PortableViewCompilerStatus status);
49

  
50
    /**
51
     * Call when user cancel the editor
52
     * 
53
     * @param compilation
54
     */
55
    void canceledEditing(PortableViewCompilation compilation);
56

  
57
    /**
58
     * Call when compilation process is not sucess
59
     * 
60
     * @param status
61
     */
62
    void fail(PortableViewCompilerStatus status);
63

  
64
    /**
65
     * Call when an exception is throw
66
     * 
67
     * @param message
68
     * @param exception
69
     */
70
    void exception(String message, Throwable exception);
71
}
org.gvsig.educa.portableview/tags/org.gvsig.educa.portableview-1.0.19/org.gvsig.educa.portableview.app/org.gvsig.educa.portableview.app.editor/src/main/java/org/gvsig/educa/portableview/app/editor/PortableViewEditorManager.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.app.editor;
23

  
24
import java.io.File;
25
import java.io.IOException;
26

  
27
import org.gvsig.app.project.documents.view.ViewDocument;
28
import org.gvsig.educa.portableview.PortableViewException;
29
import org.gvsig.educa.portableview.PortableViewManager;
30
import org.gvsig.educa.portableview.app.viewer.PortableViewDocument;
31
import org.gvsig.educa.portableview.app.viewer.PortableViewDocumentManager;
32
import org.gvsig.educa.portableview.compilation.PortableViewCompilation;
33
import org.gvsig.educa.portableview.map.CantLoadContextException;
34
import org.gvsig.educa.portableview.map.InvalidPortableViewFormatException;
35
import org.gvsig.educa.portableview.map.PortableView;
36
import org.gvsig.educa.portableview.swing.PortableViewSwingManager;
37
import org.gvsig.tools.persistence.exception.PersistenceException;
38

  
39
/**
40
 * <p>
41
 * Manager which make easy the creation, editing and share PortableView
42
 * </p>
43
 * <p>
44
 * This uses all services of {@link PortableViewManager} and
45
 * {@link PortableViewSwingManager} in a high level way.
46
 * </p>
47
 *
48
 * <p>
49
 * This manager provides the most important services which provides this add-on
50
 * </p>
51
 *
52
 * @author gvSIG Team
53
 * @version $Id$
54
 *
55
 */
56
public interface PortableViewEditorManager {
57

  
58
    /**
59
     * Returns {@link PortableViewDocumentManager} instance
60
     *
61
     * @return
62
     */
63
    PortableViewDocumentManager getDocManager();
64

  
65
    /**
66
     * Compile a {@link PortableViewCompilation} and deploy it in current install
67
     * folder ( {@link PortableViewManager#getInstallationMapFolder()} )
68
     *
69
     * @param compilation
70
     *            to compile
71
     *
72
     * @param listener
73
     *            of the process
74
     */
75
    void compileInInstallFolder(PortableViewCompilation compilation,
76
        CompilationListener listener);
77

  
78
    /**
79
     * <p>
80
     * Create a new {@link PortableView} from a view contents and open it as a
81
     * {@link PortableViewDocument}
82
     * </p>
83
     * <p>
84
     * {@link PortableViewDocument} will be linked to source view so it can be
85
     * regenerated.
86
     * </p>
87
     *
88
     * @param view
89
     * @param listener
90
     * @param openWindow
91
     */
92
    void createPortableViewFromView(ViewDocument view,
93
        CompilationListener listener, boolean openWindow);
94

  
95
    /**
96
     * Gets the {@link PortableViewDocument} linked to a {@link ViewDocument}
97
     *
98
     * @param view
99
     * @return the document or null if not found
100
     */
101
    PortableViewDocument getPortableViewDocumentByView(ViewDocument view);
102

  
103
    /**
104
     * Generate a gvSIG add-ons installer package from a
105
     * {@link PortableViewDocument}
106
     *
107
     * @param portableView
108
     *            to packing
109
     * @param targetFolder
110
     *            to store result file
111
     * @return
112
     * @throws IOException
113
     * @throws PortableViewException
114
     */
115
    File generatePackage(PortableViewDocument portableView, File targetFolder)
116
        throws PortableViewException, IOException;
117

  
118
    /**
119
     * <p>
120
     * Generate a gvSIG add-ons installer package from a
121
     * {@link PortableViewDocument}
122
     * </p>
123
     * <p>
124
     * User will be prompted for folder to store result file
125
     * </p>
126
     *
127
     * @param portableView
128
     * @return
129
     * @throws IOException
130
     * @throws PortableViewException
131
     */
132
    File generatePackage(PortableViewDocument portableView)
133
        throws PortableViewException, IOException;
134

  
135
    /**
136
     * Export the contents of a Portable View into a folder and create a
137
     * {@link ViewDocument} in project with it's layers
138
     * <p>
139
     * User will be prompted for extract folder
140
     * </p>
141
     * <p>
142
     * If Portable view document has no related view link the new one to it
143
     * </p>
144
     *
145
     * @param map
146
     * @param openViewWindow
147
     * @return
148
     * @throws IOException
149
     * @throws InvalidPortableViewFormatException
150
     * @throws PersistenceException
151
     */
152
    ViewDocument exportPortableViewToView(PortableViewDocument map,
153
        boolean openViewWindow) throws IOException,
154
        InvalidPortableViewFormatException, PersistenceException;
155

  
156
    /**
157
     * Export the contents of a Portable View into a folder and create a
158
     * {@link ViewDocument} in project with it's layers
159
     * <p>
160
     * If Portable view document has no related view link the new one to it
161
     * </p>
162
     *
163
     * @param map
164
     * @param exportFolder
165
     *            <b>Warning:</b> this folder must be empty
166
     * @return
167
     * @throws IOException
168
     * @throws InvalidPortableViewFormatException
169
     * @throws PersistenceException
170
     */
171
    ViewDocument exportPortableViewToView(PortableViewDocument map,
172
        File exportFolder, boolean openViewWindow) throws IOException,
173
        InvalidPortableViewFormatException, PersistenceException;
174

  
175
    /**
176
     * <p>
177
     * Regenerates the Portable View from current state of source View
178
     * </p>
179
     * <p>
180
     * Portable View document must be linked to a view, otherwise this method do
181
     * nothing.
182
     * </p>
183
     *
184
     * @param map
185
     * @param listener
186
     * @param openWindow
187
     * @throws IOException
188
     * @throws CantLoadContextException
189
     * @throws InvalidPortableViewFormatException
190
     */
191
    void regeneratePortableView(PortableViewDocument map,
192
        CompilationListener listener, boolean openWindow)
193
        throws InvalidPortableViewFormatException, CantLoadContextException,
194
        IOException;
195

  
196
}
org.gvsig.educa.portableview/tags/org.gvsig.educa.portableview-1.0.19/org.gvsig.educa.portableview.app/org.gvsig.educa.portableview.app.editor/src/main/java/org/gvsig/educa/portableview/app/editor/GeneratePackagePortableViewExtension.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.app.editor;
23

  
24
import java.io.File;
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff