Revision 38132

View differences:

tags/v2_0_0_Build_2046/applications/appgvSIG/src/org/gvsig/app/addlayer/AddLayerDialog.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 */
19
package org.gvsig.app.addlayer;
20

  
21
import java.awt.BorderLayout;
22
import java.awt.Component;
23
import java.awt.Dimension;
24
import java.awt.event.ActionEvent;
25
import java.awt.event.ActionListener;
26

  
27
import javax.swing.JDialog;
28
import javax.swing.JPanel;
29
import javax.swing.JTabbedPane;
30
import javax.swing.event.ChangeEvent;
31
import javax.swing.event.ChangeListener;
32

  
33
import org.cresques.cts.IProjection;
34
import org.gvsig.andami.PluginServices;
35
import org.gvsig.andami.ui.mdiManager.WindowInfo;
36
import org.gvsig.app.gui.WizardPanel;
37
import org.gvsig.app.gui.wizards.WizardListener;
38
import org.gvsig.app.project.DefaultProject;
39
import org.gvsig.gui.beans.AcceptCancelPanel;
40
import org.gvsig.tools.ToolsLocator;
41
import org.gvsig.tools.dispose.Disposable;
42

  
43
/**
44
 * Frame del cuadro de dialogo que contendra los tabs de aperturas de ficheros
45
 *
46
 * @version 04/09/2007
47
 * @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
48
 */
49
public class AddLayerDialog extends JPanel implements org.gvsig.andami.ui.mdiManager.IWindow , Disposable{
50
	static private IProjection proj           = null;
51
	private JTabbedPane        jTabbedPane    = null;
52
	private AcceptCancelPanel  jPanel         = null;
53
	private boolean            accepted       = false;
54
	private String             title          = PluginServices.getText(this, "add_layer");
55
	private WizardListener     wizardListener = new DialogWizardListener();
56

  
57
	/**
58
   * Creates a new FOpenDialog object.
59
   * @param view Vista que vamos a refrescar
60
   * @param mapControl MapControl que recibe la capa (te puede interesar
61
   *          a?adirla al principal o al Overview.
62
   */
63
	public AddLayerDialog() {
64
		initialize();
65
	}
66

  
67
	/**
68
	 * Constructor con un nombre de Frame
69
	 * @param title
70
	 */
71
	public AddLayerDialog(String title) {
72
		this.title = title;
73
		initialize();
74
	}
75

  
76
	/**
77
   * This method initializes this
78
   */
79
	private void initialize() {
80
		ToolsLocator.getDisposableManager().bind(this);
81
		
82
		this.setLayout(new BorderLayout());
83
		this.setSize(523, 385);
84
		this.setPreferredSize(new Dimension(523, 385));
85
		this.add(getJTabbedPane(), BorderLayout.CENTER);
86
		this.add(getJPanel(), BorderLayout.SOUTH);
87
	}
88

  
89
	/**
90
   * This method initializes jTabbedPane
91
   * @return javax.swing.JTabbedPane
92
   */
93
	private JTabbedPane getJTabbedPane() {
94
		if (jTabbedPane == null) {
95
			jTabbedPane = new JTabbedPane();
96
			jTabbedPane.setBounds(0, 0, getWindowInfo().getWidth() - 10, getWindowInfo().getHeight() - 10);
97
			jTabbedPane.addChangeListener(new ChangeListener() {
98
				public void stateChanged(ChangeEvent e) {
99
					JTabbedPane tabs = (JTabbedPane) e.getSource();
100
//					getJPanel().setOkButtonEnabled(!(tabs.getSelectedComponent() instanceof WizardPanel));
101
				}
102
			});
103
		}
104

  
105
		return jTabbedPane;
106
	}
107

  
108
	/**
109
	 * A?ade en una pesta?a un Jpanel con un titulo
110
	 * @param title
111
	 * @param panel
112
	 */
113
	public void addTab(String title, JPanel panel) {
114
		getJTabbedPane().addTab(title, panel);
115
	}
116

  
117
	/**
118
	 * A?ade en una pesta?a un WizardPanel con un titulo
119
	 * @param title
120
	 * @param panel
121
	 */
122
	public void addWizardTab(String title, WizardPanel panel) {
123
		panel.addWizardListener(wizardListener);
124
		getJTabbedPane().addTab(title, panel);
125
	}
126

  
127
	/**
128
	 * Devuelve el JPanel seleccionado en las pesta?as
129
	 * @return
130
	 */
131
	public JPanel getSelectedTab() {
132
		return (JPanel) getJTabbedPane().getSelectedComponent();
133
	}
134

  
135
	/*
136
	 * (non-Javadoc)
137
	 * @see com.iver.andami.ui.mdiManager.IWindow#getWindowInfo()
138
	 */
139
	public WindowInfo getWindowInfo() {
140
		WindowInfo m_viewinfo = new WindowInfo(WindowInfo.MODALDIALOG);
141
		m_viewinfo.setTitle(this.title);
142
		m_viewinfo.setHeight(500);
143
		m_viewinfo.setWidth(520);
144
		return m_viewinfo;
145
	}
146

  
147
	/**
148
   * This method initializes jPanel
149
   * @return javax.swing.JPanel
150
   */
151
	private AcceptCancelPanel getJPanel() {
152
		if (jPanel == null) {
153
			ActionListener okAction = new ActionListener() {
154
				public void actionPerformed(ActionEvent e) {
155
					accepted = true;
156
					closeWindow();
157
				}
158
			};
159
			ActionListener cancelAction = new ActionListener() {
160
				public void actionPerformed(ActionEvent e) {
161
					closeWindow();
162
				}
163
			};
164
			jPanel = new AcceptCancelPanel(okAction, cancelAction);
165
		}
166
		return jPanel;
167
	}
168

  
169
	/**
170
	 * @return
171
	 */
172
	public boolean isAccepted() {
173
		return accepted;
174
	}
175

  
176
	/**
177
	 * Listener para el Wizard de apertura de fichero
178
	 * @version 05/09/2007
179
	 * @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
180
	 */
181
	public class DialogWizardListener implements WizardListener {
182
		/*
183
		 * (non-Javadoc)
184
		 * @see com.iver.cit.gvsig.gui.wizards.WizardListener#error(java.lang.Exception)
185
		 */
186
		public void error(Exception e) {}
187

  
188
		/*
189
		 * (non-Javadoc)
190
		 * @see com.iver.cit.gvsig.gui.wizards.WizardListener#wizardStateChanged(boolean)
191
		 */
192
		public void wizardStateChanged(boolean finishable) {
193
			getJPanel().setOkButtonEnabled(finishable);
194
		}
195
	}
196

  
197
	/**
198
	 * Devuelve la ultima proyecci?n usada
199
	 * @return
200
	 */
201
	public static IProjection getLastProjection() {
202
		if (proj == null) {
203
			proj = DefaultProject.getDefaultProjection();
204
		}
205
		return proj;
206
	}
207

  
208
	/**
209
	 * Define la ultima proyeccion
210
	 * @param proj
211
	 */
212
	public static void setLastProjection(IProjection proj) {
213
		AddLayerDialog.proj = proj;
214
	}
215

  
216
	public Object getWindowProfile() {
217
		return WindowInfo.DIALOG_PROFILE;
218
	}
219

  
220
	private void closeWindow() {
221
//		JTabbedPane tabbed = getJTabbedPane();
222
//		for (int i = 0; i < tabbed.getTabCount(); i++) {
223
//			Component component = tabbed.getComponentAt(i);
224
//			if (component instanceof WizardPanel) {
225
//				((WizardPanel) component).close();
226
//			}
227
//		}
228
		if (PluginServices.getMainFrame() == null) {
229
			((JDialog) (getParent().getParent().getParent().getParent())).dispose();
230
		} else {
231
			PluginServices.getMDIManager().closeWindow(AddLayerDialog.this);
232
		}
233
	}
234

  
235
	public void dispose() {
236
		JTabbedPane tabbed = getJTabbedPane();
237
		for (int i = 0; i < tabbed.getTabCount(); i++) {
238
			Component component = tabbed.getComponentAt(i);
239
			if (component instanceof WizardPanel) {
240
				((WizardPanel) component).close();
241
			}
242
		}
243
		ToolsLocator.getDisposableManager().release(this);
244
	}
245
	
246
}
0 247

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

  
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2009 {DiSiD Technologies}  {{Task}}
26
 */
27
package org.gvsig.app.imp;
28

  
29
import org.gvsig.app.ApplicationLibrary;
30
import org.gvsig.app.ApplicationLocator;
31
import org.gvsig.installer.lib.api.InstallerLibrary;
32
import org.gvsig.tools.library.AbstractLibrary;
33
import org.gvsig.tools.library.LibraryException;
34

  
35
/**
36
 * Registers the default implementation for the AppGvSigManager.
37
 * @author <a href="mailto:cordinyana@gvsig.org">C?sar Ordi?ana</a>
38
 */
39
public class AppgvSIGDefaultImplLibrary extends AbstractLibrary {
40

  
41
    @Override
42
    public void doRegistration() {
43
        registerAsImplementationOf(ApplicationLibrary.class);
44
        require(InstallerLibrary.class);
45
    }
46

  
47
	@Override
48
	protected void doInitialize() throws LibraryException {
49
		ApplicationLocator
50
				.registerDefaultAppgvSIGManager(DefaultAppgvSIGManager.class);
51
	}
52

  
53
	@Override
54
	protected void doPostInitialize() throws LibraryException {
55
		// do nothing
56
	}
57

  
58
}
tags/v2_0_0_Build_2046/applications/appgvSIG/src/org/gvsig/app/imp/DefaultPreferencesNode.java
1
package org.gvsig.app.imp;
2

  
3
import java.awt.Color;
4

  
5
import org.gvsig.andami.PluginServices;
6
import org.gvsig.app.PreferencesNode;
7
import org.gvsig.utils.StringUtilities;
8
import org.gvsig.utils.XMLEntity;
9

  
10
public class DefaultPreferencesNode implements PreferencesNode {
11

  
12
	private String name;
13
	private XMLEntity node;
14
	
15
	public DefaultPreferencesNode() {
16
		this.name = null;
17
	}
18
	
19
	public DefaultPreferencesNode(String nodeName) {
20
		this.name = nodeName;
21
	}
22
	
23
	protected XMLEntity getRootNode() {
24
		XMLEntity node = PluginServices.getPluginServices("org.gvsig.app")	.getPersistentXML();
25
		return node;
26
	}
27
	
28
	protected XMLEntity getNode() {
29
		if( this.node == null ) {
30
			if( this.name == null ) {
31
				this.node = this.getRootNode();
32
			} else {
33
		        this.node = this.getRootNode().firstChild(this.name);		
34
			}
35
		}
36
        return this.node;
37
	}
38
	
39
	public String name() {
40
		return this.name;
41
	}
42

  
43
	public String[] keys() throws Exception {
44
		XMLEntity node = this.getNode();
45
		int count = node.getChildrenCount();
46
		String[] keys = new String[count];
47
		for(int  i=0 ; i<count ; i++ ) {
48
			keys[i] = node.getChild(i).getName();
49
		}
50
		return keys;
51
	}
52

  
53
	public void clear() throws Exception {
54
		XMLEntity node = this.getNode();
55
		node.removeAllChildren();
56
	}
57

  
58
	public void flush() throws Exception {
59
		// do nothing
60
	}
61

  
62
	public String get(String name, String defaultValue) {
63
		XMLEntity node = this.getNode();
64
		
65
		if (!node.contains(name)) {
66
			return defaultValue;
67
		}
68
		String value = node.getStringProperty(name);
69
		return value;
70
	}
71

  
72
	public boolean getBoolean(String name, boolean defaultValue) {
73
		XMLEntity node = this.getNode();
74
		
75
		if (!node.contains(name)) {
76
			return defaultValue;
77
		}
78
		boolean value = node.getBooleanProperty(name);
79
		return value;
80
	}
81

  
82
	public byte[] getByteArray(String name, byte[] defaultValue) {
83
		XMLEntity node = this.getNode();
84
		
85
		if (!node.contains(name)) {
86
			return defaultValue;
87
		}
88
		byte[] value = node.getByteArrayProperty(name);
89
		return value;
90
	}
91

  
92
	public double getDouble(String name, double defaultValue) {
93
		XMLEntity node = this.getNode();
94
		
95
		if (!node.contains(name)) {
96
			return defaultValue;
97
		}
98
		double value = node.getDoubleProperty(name);
99
		return value;
100
	}
101

  
102
	public float getFloat(String name, float defaultValue) {
103
		XMLEntity node = this.getNode();
104
		
105
		if (!node.contains(name)) {
106
			return defaultValue;
107
		}
108
		float value = node.getFloatProperty(name);
109
		return value;
110
	}
111

  
112
	public int getInt(String name, int defaultValue) {
113
		XMLEntity node = this.getNode();
114
		
115
		if (!node.contains(name)) {
116
			return defaultValue;
117
		}
118
		int value = node.getIntProperty(name);
119
		return value;
120
	}
121

  
122
	public long getLong(String name, long defaultValue) {
123
		XMLEntity node = this.getNode();
124
		
125
		if (!node.contains(name)) {
126
			return defaultValue;
127
		}
128
		long value = node.getLongProperty(name);
129
		return value;
130
	}
131

  
132
	public Color getColor(String name, Color defaultValue) {
133
		XMLEntity node = this.getNode();
134
		
135
		if (!node.contains(name)) {
136
			return defaultValue;
137
		}
138
		String value = node.getStringProperty(name);
139
		return  StringUtilities.string2Color(value);
140
	}
141

  
142
	public void put(String name, String value) {
143
		XMLEntity node = this.getNode();
144
		
145
		node.putProperty(name, value);
146
	}
147

  
148
	public void putBoolean(String name, boolean value) {
149
		XMLEntity node = this.getNode();
150
		
151
		node.putProperty(name, value);
152
	}
153

  
154
	public void putByteArray(String name, byte[] value) {
155
		XMLEntity node = this.getNode();
156
		
157
		node.putProperty(name, value);
158
	}
159

  
160
	public void putDouble(String name, double value) {
161
		XMLEntity node = this.getNode();
162
		
163
		node.putProperty(name, value);
164
	}
165

  
166
	public void putFloat(String name, float value) {
167
		XMLEntity node = this.getNode();
168
		
169
		node.putProperty(name, value);
170
	}
171

  
172
	public void putInt(String name, int value) {
173
		XMLEntity node = this.getNode();
174
		
175
		node.putProperty(name, value);
176
	}
177

  
178
	public void putLong(String name, long value) {
179
		XMLEntity node = this.getNode();
180
		
181
		node.putProperty(name, value);
182
	}
183

  
184
	public void remove(String name) {
185
		XMLEntity node = this.getNode();
186

  
187
		if (!node.contains(name)) {
188
			return;
189
		}
190
		node.remove(name);
191
	}
192

  
193
	public void sync() throws Exception {
194
		// do nothing
195
	}
196

  
197
}
0 198

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

  
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2009 IVER T.I   {{Task}}
26
*/
27

  
28
/**
29
 *
30
 */
31
package org.gvsig.app.imp;
32

  
33
import java.util.ArrayList;
34
import java.util.Iterator;
35
import java.util.List;
36

  
37
import org.cresques.cts.IProjection;
38
import org.gvsig.about.AboutLocator;
39
import org.gvsig.about.AboutManager;
40
import org.gvsig.andami.Launcher;
41
import org.gvsig.andami.PluginServices;
42
import org.gvsig.andami.iconthemes.IconThemeManager;
43
import org.gvsig.andami.ui.mdiManager.IWindow;
44
import org.gvsig.andami.ui.mdiManager.MDIManager;
45
import org.gvsig.app.ApplicationManager;
46
import org.gvsig.app.PreferencesNode;
47
import org.gvsig.app.extension.Version;
48
import org.gvsig.app.gui.WizardPanel;
49
import org.gvsig.app.prepareAction.PrepareContext;
50
import org.gvsig.app.prepareAction.PrepareContextView;
51
import org.gvsig.app.prepareAction.PrepareDataStore;
52
import org.gvsig.app.prepareAction.PrepareDataStoreParameters;
53
import org.gvsig.app.prepareAction.PrepareLayer;
54
import org.gvsig.app.project.DefaultProject;
55
import org.gvsig.app.project.Project;
56
import org.gvsig.app.project.ProjectManager;
57
import org.gvsig.app.project.documents.Document;
58
import org.gvsig.app.project.documents.gui.IDocumentWindow;
59
import org.gvsig.fmap.crs.CRSFactory;
60
import org.gvsig.fmap.dal.DALLocator;
61
import org.gvsig.fmap.dal.DataManager;
62
import org.gvsig.fmap.dal.DataStore;
63
import org.gvsig.fmap.dal.DataStoreParameters;
64
import org.gvsig.fmap.geom.GeometryLocator;
65
import org.gvsig.fmap.geom.GeometryManager;
66
import org.gvsig.fmap.mapcontext.MapContextLocator;
67
import org.gvsig.fmap.mapcontext.MapContextManager;
68
import org.gvsig.fmap.mapcontext.layers.FLayer;
69
import org.gvsig.gui.IColorTablesFactory;
70
import org.gvsig.symbology.swing.SymbologySwingLocator;
71
import org.gvsig.tools.ToolsLocator;
72
import org.gvsig.tools.dataTypes.DataTypesManager;
73
import org.gvsig.tools.dispose.DisposableManager;
74
import org.gvsig.tools.dynobject.DynObjectManager;
75
import org.gvsig.tools.extensionpoint.ExtensionPoint;
76
import org.gvsig.tools.extensionpoint.ExtensionPoint.Extension;
77
import org.gvsig.tools.extensionpoint.ExtensionPointManager;
78
import org.gvsig.tools.persistence.PersistenceManager;
79

  
80

  
81

  
82

  
83
/**
84
 * @author jmvivo
85
 *
86
 */
87
public class DefaultAppgvSIGManager implements ApplicationManager {
88

  
89
	private static final String EPNAME_PREPARE_OPEN_DATASTORE = "org.gvsig.datastore.open.prepare"; //"PrepareOpenDataStore";
90
	private static final String EPNAME_PREPARE_OPEN_DATASTOREPARAMETERS = "org.gvsig.datastoreparameters.open.prepare"; //"PrepareOpenDataStoreParameters";
91
	private static final String EPNAME_PREPARE_OPEN_LAYER = "org.gvsig.layer.open.prepare"; // "PrepareOpenLayer";
92

  
93
	private static final String EPNAME_ADD_TABLE_WIZARD = "AddLayerWizard";
94

  
95
	private ExtensionPointManager epManager;
96

  
97
    private Version version;
98

  
99
	public DefaultAppgvSIGManager() {
100
		epManager = ToolsLocator.getExtensionPointManager();
101
		epManager.add(EPNAME_PREPARE_OPEN_DATASTORE,
102
				"Actions to do when open a DataStore");
103
		epManager.add(EPNAME_PREPARE_OPEN_DATASTOREPARAMETERS,
104
				"Actions to do before open a DataStore with parameters");
105
		epManager.add(EPNAME_PREPARE_OPEN_LAYER,
106
			"Actions to do after create a Layer");
107
		epManager.add(EPNAME_ADD_TABLE_WIZARD,
108
				"Wizards to add new document table");
109

  
110
        version = new Version();
111
	}
112

  
113
	/* (non-Javadoc)
114
	 * @see org.gvsig.appGvSigManager#pepareOpenDataSource(org.gvsig.fmap.dal.DataStore)
115
	 */
116
	@SuppressWarnings("unchecked")
117
	public DataStore pepareOpenDataSource(DataStore store,
118
			PrepareContext context) throws Exception {
119
		ExtensionPoint ep = epManager.get(EPNAME_PREPARE_OPEN_DATASTORE);
120
		if (ep.getCount() == 0) {
121
			return store;
122
		}
123
		DataStore result = store;
124
		Iterator<ExtensionPoint.Extension> iter = ep.iterator();
125
		PrepareDataStore prepare;
126
		while (iter.hasNext()) {
127
			prepare = (PrepareDataStore) iter.next().create();
128
			result = prepare.prepare(store, context);
129
		}
130
		return result;
131
	}
132

  
133
	/* (non-Javadoc)
134
	 * @see org.gvsig.appGvSigManager#prepareOpenDataStoreParameters(org.gvsig.fmap.dal.DataStoreParameters)
135
	 */
136
	@SuppressWarnings("unchecked")
137
	public DataStoreParameters prepareOpenDataStoreParameters(
138
			DataStoreParameters storeParameters, PrepareContext context)
139
			throws Exception {
140

  
141
		ExtensionPoint ep = epManager
142
				.get(EPNAME_PREPARE_OPEN_DATASTOREPARAMETERS);
143
		if (ep.getCount() == 0) {
144
			return storeParameters;
145
		}
146
		DataStoreParameters result = storeParameters;
147
		Iterator<ExtensionPoint.Extension> iter = ep.iterator();
148
		PrepareDataStoreParameters prepare;
149
		while (iter.hasNext()) {
150
			prepare = (PrepareDataStoreParameters) iter.next().create();
151
			result = prepare.prepare(storeParameters, context);
152
		}
153

  
154
		return result;
155
	}
156
	
157
	/*
158
	 * (non-Javadoc)
159
	 * @see org.gvsig.app.ApplicationManager#prepareOpenDataStoreParameters(java.util.List, org.gvsig.app.prepareAction.PrepareContext)
160
	 */
161
	@SuppressWarnings("unchecked")
162
	public List<DataStoreParameters> prepareOpenDataStoreParameters(
163
			List<DataStoreParameters> storeParameters, PrepareContext context)
164
			throws Exception {
165

  
166
		ExtensionPoint ep = epManager
167
				.get(EPNAME_PREPARE_OPEN_DATASTOREPARAMETERS);
168
		if (ep.getCount() == 0) {
169
			return storeParameters;
170
		}
171
		
172
		List<DataStoreParameters> result = new ArrayList<DataStoreParameters>();
173
		
174
		Iterator<ExtensionPoint.Extension> iter = ep.iterator();
175
		List<PrepareDataStoreParameters> prepareList = new ArrayList<PrepareDataStoreParameters>();
176
		while (iter.hasNext()) {
177
			prepareList.add((PrepareDataStoreParameters) iter.next().create());
178
		}
179
		
180
		for (int i = 0; i < storeParameters.size(); i++) {
181
			DataStoreParameters param = storeParameters.get(i);
182
			for (int j = 0; j < prepareList.size(); j++) {
183
				prepareList.get(j).pre(param, context);
184
			}
185
		}
186
		
187
		for (int i = 0; i < storeParameters.size(); i++) {
188
			DataStoreParameters param = storeParameters.get(i);
189
			if(param != null) {
190
				for (int j = 0; j < prepareList.size(); j++) {
191
					param = prepareList.get(j).prepare(param, context);
192
					if(param == null)
193
						break;
194
				}
195
				if(param != null)
196
					result.add(param);
197
			}
198
		}
199
		
200
		for (int i = 0; i < storeParameters.size(); i++) {
201
			DataStoreParameters param = storeParameters.get(i);
202
			for (int j = 0; j < prepareList.size(); j++) {
203
				prepareList.get(j).post(param, context);
204
			}
205
		}
206

  
207
		return result;
208
	}
209

  
210
	public void registerPrepareOpenDataStore(PrepareDataStore action) {
211
		ExtensionPoint ep = epManager.get(EPNAME_PREPARE_OPEN_DATASTORE);
212
		ep.append(action.getName(), action.getDescription(), action);
213
	}
214

  
215
	public void registerPrepareOpenDataStoreParameters(
216
			PrepareDataStoreParameters action) {
217
		ExtensionPoint ep = epManager
218
				.get(EPNAME_PREPARE_OPEN_DATASTOREPARAMETERS);
219
		ep.append(action.getName(), action.getDescription(), action);
220

  
221

  
222
	}
223

  
224
	@SuppressWarnings("unchecked")
225
	public FLayer prepareOpenLayer(FLayer layer,
226
			PrepareContextView context)
227
			throws Exception {
228

  
229
		ExtensionPoint ep = epManager.get(EPNAME_PREPARE_OPEN_LAYER);
230

  
231
		if (ep.getCount() == 0) {
232
			return layer;
233
		}
234
		FLayer result = layer;
235
		Iterator<ExtensionPoint.Extension> iter = ep.iterator();
236
		PrepareLayer prepare;
237
		while (iter.hasNext()) {
238
			prepare = (PrepareLayer) iter.next().create();
239
			result = prepare.prepare(layer, context);
240
		}
241

  
242
		return result;
243

  
244
	}
245

  
246
	public void registerPrepareOpenLayer(PrepareLayer action) {
247
		ExtensionPoint ep = epManager.get(EPNAME_PREPARE_OPEN_LAYER);
248
		ep.append(action.getName(), action.getDescription(), action);
249
	}
250

  
251
	public void registerAddTableWizard(String name, String description,
252
			Class<? extends WizardPanel> wpClass) {
253
		ExtensionPoint ep = epManager.get(EPNAME_ADD_TABLE_WIZARD);
254
		ep.append(name, description, wpClass);
255
	}
256

  
257
	@SuppressWarnings("unchecked")
258
	public List<WizardPanel> getWizardPanels() throws Exception {
259
		ExtensionPoint ep = epManager.get(EPNAME_ADD_TABLE_WIZARD);
260
		List<WizardPanel> result = new ArrayList<WizardPanel>();
261
		Iterator<Extension> iter = ep.iterator();
262
		while (iter.hasNext()) {
263
			result.add((WizardPanel) iter.next().create());
264
		}
265
		return result;
266
	}
267

  
268
	public DataManager getDataManager() {
269
		return DALLocator.getDataManager();
270
	}
271

  
272
	public GeometryManager getGeometryManager() {
273
		return GeometryLocator.getGeometryManager();
274
	}
275

  
276
	public PersistenceManager getPersistenceManager() {
277
		return ToolsLocator.getPersistenceManager();
278
	}
279

  
280
	public DisposableManager getDisposableManager() {
281
		return ToolsLocator.getDisposableManager();
282
	}
283

  
284
	public DynObjectManager getDynObjectManager() {
285
		return ToolsLocator.getDynObjectManager();
286
	}
287

  
288
	public ExtensionPointManager getExtensionPointManager() {
289
		return ToolsLocator.getExtensionPointManager();
290
	}
291

  
292
	public ProjectManager getProjectManager() {
293
		return ProjectManager.getInstance();
294
	}
295

  
296
	public MDIManager getUIManager() {
297
		return PluginServices.getMDIManager();
298
	}
299

  
300
	public MapContextManager getMapContextManager() {
301
		return MapContextLocator.getMapContextManager();
302
	}
303

  
304
	public DataTypesManager getDataTypesManager() {
305
		return ToolsLocator.getDataTypesManager();
306
	}
307
	
308
	public IProjection getCRS(String code) {
309
		return CRSFactory.getCRS(code);
310
	}
311

  
312
	public IconThemeManager getIconThemeManager() {
313
		return IconThemeManager.getIconThemeManager();
314
	}
315

  
316
	public String getArgument(String name) {
317
		return PluginServices.getArgumentByName(name);
318
	}
319

  
320
	public String[] getArguments() {
321
		return PluginServices.getArguments();
322
	}
323

  
324
	public String getFromClipboard() {
325
		return PluginServices.getFromClipboard();
326
	}
327

  
328
	public void putInClipboard(String data) {
329
		PluginServices.putInClipboard(data);
330
	}
331

  
332
	public Project getCurrentProject() {
333
		return ProjectManager.getInstance().getCurrentProject();
334
	}
335

  
336
	public PreferencesNode getPreferences(String node) {
337
		if( node.equalsIgnoreCase("project")) {
338
			return DefaultProject.getPreferences();
339
		}
340
		return new DefaultPreferencesNode(node);
341
	}
342

  
343
	public PreferencesNode getPreferences() {
344
		return new DefaultPreferencesNode();
345
	}
346

  
347
	public Version getVersion() {
348
        return version;
349
	}
350
	
351
	public AboutManager getAbout() {
352
		AboutManager manager = AboutLocator.getManager();
353
		return manager;
354
	}
355

  
356
	public IColorTablesFactory getColorTablesFactory() {
357
		return SymbologySwingLocator.getSwingManager().getColorTablesFactory();
358
	}
359

  
360
	public void registerColorTablesFactory(IColorTablesFactory factory) {
361
		SymbologySwingLocator.getSwingManager().setColorTablesFactory(factory);
362
		
363
	}
364

  
365
    public IWindow getActiveWindow() {
366
        try {
367
            IWindow window = PluginServices.getMDIManager().getActiveWindow();
368
            return window;
369
        } catch (Exception ex) {
370
            return null;
371
        }
372
    }
373

  
374
    public Document getActiveDocument() {
375
        Project project = this.getCurrentProject();
376
        if( project == null ) {
377
            return null;
378
        }
379
        return project.getActiveDocument();
380
    }
381
    
382
    public Document getActiveDocument(String documentTypeName) {
383
        Document document = this.getActiveDocument();
384
        if( document!= null && document.getTypeName().equalsIgnoreCase(documentTypeName) ) {
385
            return document;
386
        }
387
        return null;
388
    }
389
    
390
    public Document getActiveDocument(Class<? extends Document> documentClass) {
391
        Document document = this.getActiveDocument();
392
        if( documentClass.isInstance(document) ) {
393
            return document;
394
        }
395
        return null;
396
    }
397
    
398
    public IDocumentWindow getDocumentWindow(Document document) {
399
        Class<? extends IDocumentWindow> defaultDocumentClass =
400
            document.getFactory().getMainWindowClass();
401
        return (IDocumentWindow) this.getUIManager().getSingletonWindow(defaultDocumentClass, document);
402
    }
403

  
404
	public String getLocaleLanguage() {
405
		return Launcher.getAndamiConfig().getLocaleLanguage();
406
	}
407

  
408
}
0 409

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

  
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2004-2009 IVER TI
26
 *   
27
 */
28

  
29
package org.gvsig.app.project;
30

  
31
import java.awt.Color;
32
import java.beans.PropertyChangeEvent;
33
import java.beans.PropertyChangeListener;
34
import java.beans.PropertyChangeSupport;
35
import java.io.File;
36
import java.io.FileInputStream;
37
import java.io.FileNotFoundException;
38
import java.io.FileOutputStream;
39
import java.io.InputStream;
40
import java.io.OutputStream;
41
import java.io.Serializable;
42
import java.net.MalformedURLException;
43
import java.net.URI;
44
import java.net.URISyntaxException;
45
import java.net.URL;
46
import java.text.DateFormat;
47
import java.text.MessageFormat;
48
import java.util.ArrayList;
49
import java.util.Collections;
50
import java.util.Date;
51
import java.util.HashMap;
52
import java.util.Iterator;
53
import java.util.List;
54
import java.util.Map;
55
import java.util.regex.Pattern;
56

  
57
import org.cresques.cts.IProjection;
58
import org.slf4j.Logger;
59
import org.slf4j.LoggerFactory;
60

  
61
import org.gvsig.andami.PluginServices;
62
import org.gvsig.andami.ui.mdiManager.IWindow;
63
import org.gvsig.andami.ui.mdiManager.MDIManager;
64
import org.gvsig.andami.ui.mdiManager.SingletonWindow;
65
import org.gvsig.andami.ui.mdiManager.WindowInfo;
66
import org.gvsig.app.ApplicationLocator;
67
import org.gvsig.app.ApplicationManager;
68
import org.gvsig.app.extension.ProjectExtension;
69
import org.gvsig.app.extension.Version;
70
import org.gvsig.app.project.documents.AbstractDocument;
71
import org.gvsig.app.project.documents.Document;
72
import org.gvsig.app.project.documents.exceptions.SaveException;
73
import org.gvsig.app.project.documents.gui.IDocumentWindow;
74
import org.gvsig.app.project.documents.gui.ProjectWindow;
75
import org.gvsig.app.project.documents.view.DefaultViewDocument;
76
import org.gvsig.app.project.documents.view.ViewManager;
77
import org.gvsig.fmap.dal.DataTypes;
78
import org.gvsig.fmap.mapcontext.MapContext;
79
import org.gvsig.fmap.mapcontext.layers.FLayer;
80
import org.gvsig.fmap.mapcontext.layers.FLayers;
81
import org.gvsig.tools.ToolsLocator;
82
import org.gvsig.tools.dynobject.DynField;
83
import org.gvsig.tools.dynobject.DynStruct;
84
import org.gvsig.tools.persistence.PersistenceManager;
85
import org.gvsig.tools.persistence.Persistent;
86
import org.gvsig.tools.persistence.PersistentContext;
87
import org.gvsig.tools.persistence.PersistentState;
88
import org.gvsig.tools.persistence.exception.PersistenceException;
89
import org.gvsig.utils.StringUtilities;
90

  
91
/**
92
 * Clase que representa un proyecto de gvSIG
93
 * 
94
 * @author 2004-2005 Fernando Gonz?lez Cort?s
95
 * @author 2006-2009 Jose Manuel Vivo
96
 * @author 2005- Vicente Caballero
97
 * @author 2009- Joaquin del Cerro
98
 * 
99
 */
100

  
101
public class DefaultProject implements Serializable, PropertyChangeListener,
102
		Project {
103

  
104
	private Logger LOG = LoggerFactory.getLogger(DefaultProject.class);
105
	/**
106
	 * @deprecated see ApplicationLocator.getManager().getVersion()
107
	 */
108
	public static String VERSION = Version.format();
109

  
110
	/**
111
	 * 
112
	 */
113
	private static final long serialVersionUID = -4449622027521773178L;
114

  
115
	private static final Logger logger = LoggerFactory.getLogger(Project.class);
116

  
117
	private static ProjectPreferences preferences = new ProjectPreferences();
118

  
119
	/**
120
	 * Index used by the generator of unique names of documents.
121
	 */
122
	private Map<String, Integer> nextDocumentIndexByType = new HashMap<String, Integer>();
123

  
124
	private PropertyChangeSupport change;
125

  
126
	private boolean modified = false;
127

  
128
	private String name = null;
129

  
130
	private String creationDate = null;
131

  
132
	private String modificationDate = null;
133

  
134
	private String owner = null;
135

  
136
	private String comments = null;
137

  
138
	private Color selectionColor = null;
139

  
140
	private List<Document> documents = null;
141

  
142
	private List<ProjectExtent> extents = null;
143

  
144
	private IProjection projection;
145

  
146
	/**
147
	 * Creates a new Project object.
148
	 */
149
	DefaultProject() {
150
		this.change = new PropertyChangeSupport(this);
151
		this.clean();
152
	}
153

  
154
	protected void clean() {
155
		this.owner = "";
156
		this.comments = "";
157
		this.name = PluginServices.getText(this, "untitled");
158
		this.creationDate = DateFormat.getDateInstance().format(new Date());
159
		this.modificationDate = this.creationDate;
160

  
161
		this.documents = new ArrayList<Document>();
162
		this.extents = new ArrayList<ProjectExtent>();
163

  
164
		this.setSelectionColor(getPreferences().getDefaultSelectionColor());
165

  
166
		this.projection = null; // se inicializa en el getProjection()
167
	}
168

  
169
	public static ProjectPreferences getPreferences() {
170
		return preferences;
171
	}
172

  
173
	public void propertyChange(PropertyChangeEvent evt) {
174
		change.firePropertyChange(evt);
175
	}
176

  
177
	public synchronized void addPropertyChangeListener(
178
			PropertyChangeListener arg0) {
179
		change.addPropertyChangeListener(arg0);
180
	}
181

  
182
	/**
183
	 * Return the creation date of the project
184
	 * 
185
	 * @return
186
	 */
187
	public String getCreationDate() {
188
		return creationDate;
189
	}
190

  
191
	protected void setCreationDate(String creationDate) {
192
		this.creationDate = creationDate;
193
		change.firePropertyChange("setCreationDate", null, null);
194
	}
195

  
196
    public Document createDocument(String type) {
197
    	logger.info("createDocument('{}')",type);
198
        return ProjectManager.getInstance().createDocument(type);
199
    }
200

  
201
    /**
202
     * Return the name of the project
203
     * 
204
     * @return
205
     */
206
    public String getName() {
207
        return name;
208
    }
209

  
210
	/**
211
	 * Set the name of he project.
212
	 * 
213
	 * @param string
214
	 */
215
	public void setName(String name) {
216
		this.name = name;
217
		change.firePropertyChange("setName", null, null);
218
	}
219

  
220
	/**
221
	 * Return the comments associateds with the project
222
	 * 
223
	 * @return comments
224
	 */
225
	public String getComments() {
226
		return comments;
227
	}
228

  
229
	/**
230
	 * Set the comments associateds with the project
231
	 * 
232
	 * @param comments
233
	 *            as string
234
	 */
235
	public void setComments(String string) {
236
		comments = string;
237
		change.firePropertyChange("setComments", null, null);
238
	}
239

  
240
	/**
241
	 * Retuen the modification date of the project.
242
	 * 
243
	 * @return modification date as string
244
	 */
245
	public String getModificationDate() {
246
		return modificationDate;
247
	}
248

  
249
	protected void setModificationDate(String string) {
250
		modificationDate = string;
251
		change.firePropertyChange("setModificationDate", null, null);
252
	}
253

  
254
	/**
255
	 * Return the author of the project,
256
	 * 
257
	 * @return author as string
258
	 */
259
	public String getOwner() {
260
		return owner;
261
	}
262

  
263
	/**
264
	 * Sets the author of the project
265
	 * 
266
	 * @param author
267
	 *            name as string
268
	 */
269
	public void setOwner(String owner) {
270
		this.owner = owner;
271
		change.firePropertyChange("setOwner", null, null);
272
	}
273

  
274
	/**
275
	 * Obtiene el color de selecci�n que se usar� en el proyecto
276
	 * 
277
	 * @return
278
	 */
279
	public Color getSelectionColor() {
280
		if (selectionColor == null) {
281
			selectionColor = getPreferences().getDefaultSelectionColor();
282
		}
283
		return selectionColor;
284
	}
285

  
286
	/**
287
	 * Sets the selecction color
288
	 * 
289
	 * @param selection
290
	 *            color as string
291
	 */
292
	public void setSelectionColor(String selectionColor) {
293
		this.setSelectionColor(StringUtilities.string2Color(selectionColor));
294
	}
295

  
296
	/**
297
	 * Sets the selecction color
298
	 * 
299
	 * @param selection
300
	 *            color as Color
301
	 */
302
	public void setSelectionColor(Color selectionColor) {
303
		this.selectionColor = selectionColor;
304
		MapContext.setSelectionColor(selectionColor);
305
		change.firePropertyChange("selectionColor", null, selectionColor);
306
	}
307

  
308
	public IProjection getProjection() {
309
		if (projection == null) {
310
			projection = getPreferences().getDefaultProjection();
311
		}
312
		return projection;
313
	}
314

  
315
	public void setProjection(IProjection projection) {
316
		this.projection = projection;
317
	}
318

  
319
	/**
320
	 * Sets the modified state of project.
321
	 * 
322
	 * Can't set to not modified.
323
	 * 
324
	 * @param modified
325
	 *            as boolean
326
	 */
327
	public void setModified(boolean modified) {
328
		this.modified = modified;
329
		if (modified == false) {
330
			List<Document> documents = this.getDocuments();
331
			for (int i = 0; i < documents.size(); i++) {
332
				documents.get(i).setModified(false);
333
			}
334
		}
335
	}
336

  
337
	public boolean hasChanged() {
338
		// we return true if the project is not empty (until we have a better
339
		// method...)
340
		if ((this.getDocuments().size() != 0) || modified) {
341
			return true;
342
		}
343
		return false;
344
	}
345

  
346
	/**
347
	 * Return a list of documents in the project.
348
	 * 
349
	 * @return documents as List of IProjectDocument
350
	 */
351
	public List<Document> getDocuments() {
352
		return Collections.unmodifiableList(documents);
353
	}
354

  
355
	/**
356
	 * Return a list with all documents of especified type.
357
	 * 
358
	 * @param type
359
	 *            of document
360
	 * 
361
	 * @return List of IProjectDocument
362
	 */
363
	public List<Document> getDocuments(String type) {
364
		List<Document> docs = new ArrayList<Document>();
365
		if (type != null) {
366
			for (Document document : this.documents) {
367
				if (type.equalsIgnoreCase(document.getTypeName())) {
368
					docs.add(document);
369
				}
370
			}
371
		}
372
		return Collections.unmodifiableList(docs);
373
	}
374

  
375
	/**
376
	 * Adds a document to the project
377
	 * 
378
	 * @param document
379
	 *            as IProjectDocument
380
	 */
381
	public void add(Document document) {
382
        logger.info("add('{}')", document.toString());
383

  
384
		document.addPropertyChangeListener(this);
385
		document.setProject(this);
386
		document.setName(this.getUniqueNameForDocument(document.getTypeName(),
387
				document.getName()));
388
		documents.add(document);
389
		document.afterAdd();
390
		this.setModified(true);
391
        change.firePropertyChange("addDocument", null, document);
392
	}
393

  
394
	/**
395
	 * Remove a document of the project
396
	 * 
397
	 * @param document
398
	 *            as IProjectDocument
399
	 */
400
	public void remove(Document doc) {
401
        logger.info("remove('{}')", doc.toString());
402
		documents.remove(doc);
403
		this.setModified(true);
404
        change.firePropertyChange("delDocument", doc, null);
405
		doc.afterRemove();
406
	}
407

  
408
	public Iterator<Document> iterator() {
409
		return documents.iterator();
410
	}
411

  
412
	public boolean isEmpty() {
413
		return documents.isEmpty();
414
	}
415

  
416
	/**
417
	 * Return the view that contains the especified layer.
418
	 * 
419
	 * @param layer
420
	 * 
421
	 * @return name of the view that contains the layer
422
	 * 
423
	 * @throws RuntimeException
424
	 *             Si la capa que se pasa como par�metro no se encuentra en
425
	 *             ninguna vista
426
	 */
427
	public String getViewName(FLayer layer) {
428
		List<Document> views = getDocuments(ViewManager.TYPENAME);
429
		for (int v = 0; v < views.size(); v++) {
430
			DefaultViewDocument pView = (DefaultViewDocument) views.get(v);
431
			FLayers layers = pView.getMapContext().getLayers();
432
			if (isView(layers, layer)) {
433
				return pView.getName();
434
			}
435
		}
436

  
437
		throw new RuntimeException(MessageFormat.format(
438
				"The layer '{1}' is not in a view", layer.getName()));
439
	}
440

  
441
	private boolean isView(FLayers layers, FLayer layer) {
442
		for (int i = 0; i < layers.getLayersCount(); i++) {
443
			if (layers.getLayer(i) instanceof FLayers) {
444
				if (isView((FLayers) layers.getLayer(i), layer)) {
445
					return true;
446
				}
447
			}
448
			if (layers.getLayer(i) == layer) {
449
				return true;
450
			}
451
		}
452
		return false;
453
	}
454

  
455
	public void addExtent(ProjectExtent arg1) {
456
		extents.add(arg1);
457
		change.firePropertyChange("addExtent", null, null);
458
	}
459

  
460
	public ProjectExtent removeExtent(int arg0) {
461
		change.firePropertyChange("delExtent", null, null);
462
		return extents.remove(arg0);
463
	}
464

  
465
	public ProjectExtent[] getExtents() {
466
		return (ProjectExtent[]) extents.toArray(new ProjectExtent[0]);
467
	}
468

  
469
	/**
470
	 * Obtiene un documento a partir de su nombre y el nombre de registro en el
471
	 * pointExtension, este �ltimo se puede obtener del
472
	 * Project****Factory.registerName.
473
	 * 
474
	 * @param name
475
	 *            Nombre del documento
476
	 * @param type
477
	 *            nombre de registro en el extensionPoint
478
	 * 
479
	 * @return Documento
480
	 */
481
	public Document getDocument(String name, String type) {
482
		if (type != null) {
483
			for (int i = 0; i < documents.size(); i++) {
484
				Document document = documents.get(i);
485
				if (type.equalsIgnoreCase(document.getTypeName())
486
						&& name.equalsIgnoreCase(document.getName())) {
487
					return document;
488
				}
489
			}
490
		}
491
		return null;
492
	}
493

  
494
	public String getUniqueNameForDocument(String type, String name) {
495
		Document document = getDocument(name, type);
496
		if (document == null) {
497
			return name;
498
		}
499

  
500
		String newName = null;
501
		int num = this.getNextDocumentIndex(type);
502
		while (document != null) {
503
			newName = name + " - " + num++;
504
			document = getDocument(newName, type);
505
		}
506
		this.setNextDocumentIndex(type, num);
507
		return newName;
508
	}
509

  
510
	private int getNextDocumentIndex(String type) {
511
		if (nextDocumentIndexByType.get(type) == null) {
512
			nextDocumentIndexByType.put(type, new Integer(1));
513
			return 1;
514
		}
515
		return nextDocumentIndexByType.get(type).intValue();
516
	}
517

  
518
	private void setNextDocumentIndex(String type, int newIndex) {
519
		if (nextDocumentIndexByType.get(type) == null) {
520
			nextDocumentIndexByType.put(type, new Integer(newIndex));
521
		} else {
522
			nextDocumentIndexByType.put(type, new Integer(newIndex));
523
		}
524
	}
525

  
526
	public void saveState(File out) throws PersistenceException {
527
		FileOutputStream fout;
528
		try {
529
			fout = new FileOutputStream(out);
530
			saveState(fout, new File(out.getParent()));
531
		} catch (FileNotFoundException e) {
532
			throw new PersistenceException(e);
533
		}
534
	}
535

  
536
	public void saveState(OutputStream out) throws PersistenceException {
537
		saveState(out, null);
538
	}
539

  
540
	public void saveState(OutputStream out, File rootFolder)
541
			throws PersistenceException {
542
		PersistenceManager manager = ToolsLocator.getPersistenceManager();
543
		PersistentState state = null;
544
		state = manager.getState(this, true);
545
		try {
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff