gvsig-educa / org.gvsig.educa.portableview / trunk / org.gvsig.educa.portableview / org.gvsig.educa.portableview.swing / org.gvsig.educa.portableview.swing.impl / src / main / java / org / gvsig / educa / portableview / swing / impl / DefaultPortableViewSwingManager.java @ 256
History | View | Annotate | Download (8.82 KB)
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.swing.impl; |
23 |
|
24 |
import java.io.IOException; |
25 |
import java.util.ArrayList; |
26 |
import java.util.Collections; |
27 |
import java.util.List; |
28 |
|
29 |
import org.gvsig.educa.portableview.PortableViewLocator; |
30 |
import org.gvsig.educa.portableview.PortableViewManager; |
31 |
import org.gvsig.educa.portableview.PortableViewRuntimeException; |
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.InformationJPanelComponent; |
37 |
import org.gvsig.educa.portableview.swing.PortableViewSwingManager; |
38 |
import org.gvsig.educa.portableview.swing.PortableViewWindowManager; |
39 |
import org.gvsig.educa.portableview.swing.editor.PortableViewAddLayerComponent; |
40 |
import org.gvsig.educa.portableview.swing.editor.PortableViewCompilationEditor; |
41 |
import org.gvsig.educa.portableview.swing.editor.PortableViewLayerPropertiesEditor; |
42 |
import org.gvsig.educa.portableview.swing.editor.PortableViewLayersEditor; |
43 |
import org.gvsig.educa.portableview.swing.impl.editor.DefaultPortableViewCompilationEditor; |
44 |
import org.gvsig.educa.portableview.swing.impl.editor.addlayer.DefaultPortableViewAddLayerComponent; |
45 |
import org.gvsig.educa.portableview.swing.impl.editor.layers.DefaultPortableViewLayerPropertiesEditor; |
46 |
import org.gvsig.educa.portableview.swing.impl.editor.layers.DefaultPortableViewLayersEditor; |
47 |
import org.gvsig.educa.portableview.swing.impl.viewer.DefaultPortableViewInformationViewer; |
48 |
import org.gvsig.educa.portableview.swing.impl.viewer.DefaultPortableViewToc; |
49 |
import org.gvsig.educa.portableview.swing.impl.viewer.DefaultPortableViewViewer; |
50 |
import org.gvsig.educa.portableview.swing.viewer.MapControlToolRegistrant; |
51 |
import org.gvsig.educa.portableview.swing.viewer.PortableViewInforamtionViewer; |
52 |
import org.gvsig.educa.portableview.swing.viewer.PortableViewToc; |
53 |
import org.gvsig.educa.portableview.swing.viewer.PortableViewTocImageProvider; |
54 |
import org.gvsig.educa.portableview.swing.viewer.PortableViewViewer; |
55 |
import org.gvsig.i18n.Messages; |
56 |
import org.gvsig.tools.dynobject.DynObject; |
57 |
|
58 |
/**
|
59 |
* Default implementation of the {@link PortableViewSwingManager}.
|
60 |
*
|
61 |
* @author gvSIG Team
|
62 |
* @version $Id$
|
63 |
*/
|
64 |
public class DefaultPortableViewSwingManager implements |
65 |
PortableViewSwingManager { |
66 |
|
67 |
private final PortableViewManager manager; |
68 |
// private I18nManager i18nmanager = null;
|
69 |
private PortableViewWindowManager windowManager;
|
70 |
public static final String MODE_FORM = "form"; |
71 |
|
72 |
/**
|
73 |
* Class to use for {@link #newToc()}
|
74 |
*/
|
75 |
private Class<? extends PortableViewToc> tocClass = DefaultPortableViewToc.class; |
76 |
|
77 |
/**
|
78 |
* Class to use for {@link #informationViewerClass}
|
79 |
*/
|
80 |
private Class<? extends PortableViewInforamtionViewer> informationViewerClass = DefaultPortableViewInformationViewer.class; |
81 |
|
82 |
/**
|
83 |
* Class to use for {@link #newLayersEditor()}
|
84 |
*/
|
85 |
private Class<? extends PortableViewLayersEditor> layersEditorClass = DefaultPortableViewLayersEditor.class; |
86 |
|
87 |
/**
|
88 |
* Class to use for {@link #newLayerPropertiesEditor()}
|
89 |
*/
|
90 |
private Class<? extends PortableViewLayerPropertiesEditor> layerPropertiesEditorClass = DefaultPortableViewLayerPropertiesEditor.class; |
91 |
|
92 |
/**
|
93 |
* Class to use for {@link #newAddLayerComponent()}
|
94 |
*/
|
95 |
private Class<? extends PortableViewAddLayerComponent> addLayerClass = DefaultPortableViewAddLayerComponent.class; |
96 |
|
97 |
private PortableViewTocImageProvider tocImageProvider;
|
98 |
|
99 |
private final List<MapControlToolRegistrant> mapControlToolRegistrants = new ArrayList<MapControlToolRegistrant>(); |
100 |
|
101 |
private final List<MapControlToolRegistrant> mapControlToolRegistrants_readonly = Collections |
102 |
.unmodifiableList(mapControlToolRegistrants); |
103 |
|
104 |
public DefaultPortableViewSwingManager() {
|
105 |
this.manager = PortableViewLocator.getManager();
|
106 |
// this.i18nmanager = ToolsLocator.getI18nManager();
|
107 |
this.windowManager = new DefaultPortableViewWindowManager(this); |
108 |
} |
109 |
|
110 |
/** {@inheridDoc} */
|
111 |
public PortableViewManager getManager() {
|
112 |
return this.manager; |
113 |
} |
114 |
|
115 |
/** {@inheridDoc} */
|
116 |
public String getTranslation(String key) { |
117 |
// TODO: add I18nManager usage when org.gvsig.tools.lib 2.1.0 becomes
|
118 |
// available
|
119 |
// return this.i18nmanager.getTranslation(key);
|
120 |
return Messages.getText(key);
|
121 |
} |
122 |
|
123 |
/** {@inheridDoc} */
|
124 |
public void registerWindowManager(PortableViewWindowManager manager) { |
125 |
this.windowManager = manager;
|
126 |
} |
127 |
|
128 |
/** {@inheridDoc} */
|
129 |
public PortableViewWindowManager getWindowManager() {
|
130 |
return this.windowManager; |
131 |
} |
132 |
|
133 |
/** {@inheridDoc} */
|
134 |
public PortableViewViewer getViewer(PortableView portableView)
|
135 |
throws InvalidPortableViewFormatException,
|
136 |
CantLoadContextException, IOException {
|
137 |
return new DefaultPortableViewViewer(portableView); |
138 |
} |
139 |
|
140 |
/** {@inheridDoc} */
|
141 |
public PortableViewCompilationEditor getCopilationEditor(
|
142 |
PortableViewCompilation portableViewCompilation, boolean editLayers) {
|
143 |
return new DefaultPortableViewCompilationEditor( |
144 |
portableViewCompilation, editLayers); |
145 |
} |
146 |
|
147 |
/** {@inheridDoc} */
|
148 |
public PortableViewToc newToc() {
|
149 |
try {
|
150 |
return tocClass.newInstance();
|
151 |
} catch (Exception e) { |
152 |
throw new PortableViewRuntimeException( |
153 |
"Problem creating Portable View viewer TOC", e);
|
154 |
} |
155 |
} |
156 |
|
157 |
/** {@inheridDoc} */
|
158 |
public void registerTocComponent( |
159 |
Class<? extends PortableViewToc> tocComponentClass) { |
160 |
tocClass = tocComponentClass; |
161 |
} |
162 |
|
163 |
/** {@inheridDoc} */
|
164 |
public PortableViewAddLayerComponent newAddLayerComponent() {
|
165 |
try {
|
166 |
return addLayerClass.newInstance();
|
167 |
} catch (Exception e) { |
168 |
throw new PortableViewRuntimeException( |
169 |
"Problem creating Portable View Compilation editor add Layer component",
|
170 |
e); |
171 |
} |
172 |
} |
173 |
|
174 |
/** {@inheridDoc} */
|
175 |
public void registerAddLayerComponent( |
176 |
Class<? extends PortableViewAddLayerComponent> addLayerComponent) { |
177 |
addLayerClass = addLayerComponent; |
178 |
} |
179 |
|
180 |
/** {@inheridDoc} */
|
181 |
public PortableViewLayerPropertiesEditor newLayerPropertiesEditor() {
|
182 |
try {
|
183 |
return layerPropertiesEditorClass.newInstance();
|
184 |
} catch (Exception e) { |
185 |
throw new PortableViewRuntimeException( |
186 |
"Problem creating Portable View Copilation editor layer propierties",
|
187 |
e); |
188 |
} |
189 |
} |
190 |
|
191 |
/** {@inheridDoc} */
|
192 |
public void registerLayerPropertiesEditor( |
193 |
Class<? extends PortableViewLayerPropertiesEditor> layerPropertiesEditorClass) { |
194 |
this.layerPropertiesEditorClass = layerPropertiesEditorClass;
|
195 |
} |
196 |
|
197 |
/** {@inheridDoc} */
|
198 |
public PortableViewLayersEditor newLayersEditor() {
|
199 |
try {
|
200 |
return layersEditorClass.newInstance();
|
201 |
} catch (Exception e) { |
202 |
throw new PortableViewRuntimeException( |
203 |
"Problem creating Portable View Copilation editor layers editor",
|
204 |
e); |
205 |
} |
206 |
} |
207 |
|
208 |
/** {@inheridDoc} */
|
209 |
public void registerLayersEditor( |
210 |
Class<? extends PortableViewLayersEditor> layersEditorClass) { |
211 |
this.layersEditorClass = layersEditorClass;
|
212 |
|
213 |
} |
214 |
|
215 |
/** {@inheridDoc} */
|
216 |
public PortableViewInforamtionViewer newInformationViewer() {
|
217 |
try {
|
218 |
return informationViewerClass.newInstance();
|
219 |
} catch (Exception e) { |
220 |
throw new PortableViewRuntimeException( |
221 |
"Problem creating Portable View Information viewer", e);
|
222 |
} |
223 |
} |
224 |
|
225 |
/** {@inheridDoc} */
|
226 |
public void registerInformationViewer( |
227 |
Class<? extends PortableViewInforamtionViewer> informationViewerClass) { |
228 |
this.informationViewerClass = informationViewerClass;
|
229 |
|
230 |
} |
231 |
|
232 |
/** {@inheridDoc} */
|
233 |
public void setDefaultTocImageProvider( |
234 |
PortableViewTocImageProvider imageProvider) { |
235 |
this.tocImageProvider = imageProvider;
|
236 |
} |
237 |
|
238 |
/** {@inheridDoc} */
|
239 |
public PortableViewTocImageProvider getDefaultTocImageProvider() {
|
240 |
return tocImageProvider;
|
241 |
} |
242 |
|
243 |
/** {@inheridDoc} */
|
244 |
public List<MapControlToolRegistrant> getMapControlRegistrantList() { |
245 |
return mapControlToolRegistrants_readonly;
|
246 |
} |
247 |
|
248 |
/** {@inheridDoc} */
|
249 |
public void addMapControlRegistrant(MapControlToolRegistrant registrant) { |
250 |
mapControlToolRegistrants.add(registrant); |
251 |
} |
252 |
|
253 |
public InformationJPanelComponent createInformationJpanelComponent(
|
254 |
DynObject mapInfo) { |
255 |
return new DefaultInformationJPanelComponent(mapInfo); |
256 |
} |
257 |
} |