Revision 31496 branches/v2_0_0_prep/extensions/extWMS/src/org/gvsig/wmc/ExportWebMapContextExtension.java

View differences:

ExportWebMapContextExtension.java
124 124
import java.io.FileWriter;
125 125
import java.io.IOException;
126 126
import java.util.ArrayList;
127
import java.util.List;
127 128

  
128 129
import org.gvsig.andami.PluginServices;
129 130
import org.gvsig.andami.messages.NotificationManager;
......
132 133
import org.gvsig.andami.ui.mdiManager.IWindow;
133 134
import org.gvsig.app.extension.ProjectExtension;
134 135
import org.gvsig.app.project.Project;
135
import org.gvsig.app.project.documents.view.ProjectView;
136
import org.gvsig.app.project.documents.view.ProjectViewFactory;
137
import org.gvsig.app.project.documents.view.gui.View;
136
import org.gvsig.app.project.Project;
137
import org.gvsig.app.project.ProjectManager;
138
import org.gvsig.app.project.documents.Document;
139
import org.gvsig.app.project.documents.view.DefaultViewDocument;
140
import org.gvsig.app.project.documents.view.ViewManager;
141
import org.gvsig.app.project.documents.view.gui.DefaultViewPanel;
138 142
import org.gvsig.fmap.mapcontext.layers.FLayer;
139 143
import org.gvsig.fmap.mapcontext.layers.FLayers;
140 144
import org.gvsig.wms.fmap.layers.FLyrWMS;
......
150 154
 */
151 155
public class ExportWebMapContextExtension extends Extension {
152 156
	private static ArrayList supportedVersions;
153
	private View viewToExport;
157
	private DefaultViewPanel viewToExport;
154 158
	private WebMapContextSettingsPanel mc;
155 159
	private static IExtension thisExtension;
156 160

  
......
167 171
	public void execute(String actionCommand) {
168 172
		if (actionCommand.equals("EXPORT")) {
169 173
			// Here we collect the info
170
			ProjectView[] views = getExportableViews();
174
			DefaultViewDocument[] views = getExportableViews();
171 175
			if (views.length <= 0) {
172 176
				return;
173 177
			}
......
214 218

  
215 219
	public boolean isVisible() {
216 220
		// Will be visible if the current project has, at least, one FLyrWMS.
217
		Project project = ((ProjectExtension) PluginServices
218
				.getExtension(ProjectExtension.class)).getProject();
221
//		Project project = ((ProjectExtension) PluginServices.getExtension(ProjectExtension.class)).getProject();
222
		final Project project = ProjectManager.getInstance().getCurrentProject();
223

  
219 224
		if (project == null) {
220 225
			return false;
221 226
		}
222 227
		IWindow f = PluginServices.getMDIManager().getActiveWindow();
223
		if (f instanceof View) {
224
			View v = (View) f;
225
			if (v != null && v  instanceof View) {
228
		if (f instanceof DefaultViewPanel) {
229
			DefaultViewPanel v = (DefaultViewPanel) f;
230
			if (v != null && v  instanceof DefaultViewPanel) {
226 231
				// Check if the active contains WMS layers. If so, this view
227 232
				// will be the one to be exported.
228 233
				FLayers lyrs = v.getMapControl().getMapContext().getLayers();
......
240 245
		// see what about the others. In this case, no view is set to be
241 246
		// the exported one.
242 247
		viewToExport = null;
243
		ArrayList views = project.getDocumentsByType(ProjectViewFactory.registerName);
248
		List<Document> views = project.getDocuments(ViewManager.TYPENAME);
244 249
		for (int i = 0; i < views.size(); i++) {
245
			ProjectView v = ((ProjectView) views.get(i));
250
			DefaultViewDocument v = ((DefaultViewDocument) views.get(i));
246 251
			if (v != null) {
247 252
				FLayers lyrs = v.getMapContext().getLayers();
248 253
				for (int j = 0; j < lyrs.getLayersCount(); j++) {
......
270 275
	 * </p>
271 276
	 * @return
272 277
	 */
273
	private ProjectView[] getExportableViews() {
274
		Project project = ((ProjectExtension) PluginServices
275
				.getExtension(ProjectExtension.class)).getProject();
278
	private DefaultViewDocument[] getExportableViews() {
279
//		Project project = ((ProjectExtension) PluginServices.getExtension(ProjectExtension.class)).getProject();
280
//		ArrayList views = project.getDocumentsByType(ProjectViewFactory.registerName);
281
		final Project project = ProjectManager.getInstance().getCurrentProject();
276 282

  
277
		ArrayList views = project.getDocumentsByType(ProjectViewFactory.registerName);
278
		ArrayList exportableViews = new ArrayList();
283
		List<Document> views = project.getDocuments(ViewManager.TYPENAME);
284

  
285
		List exportableViews = new ArrayList();
279 286
		if (viewToExport!=null) {
280 287
			exportableViews.add(viewToExport.getModel());
281 288
		}
282 289

  
283 290
		for (int i = 0; i < views.size(); i++) {
284
			ProjectView v = ((ProjectView) views.get(i));
291
			DefaultViewDocument v = ((DefaultViewDocument) views.get(i));
285 292
			if (v != null) {
286 293
				FLayers lyrs = v.getMapContext().getLayers();
287 294
				for (int j = 0; j < lyrs.getLayersCount(); j++) {
......
293 300
				}
294 301
			}
295 302
		}
296
		return (ProjectView[]) exportableViews.toArray(new ProjectView[0]);
303
		return (DefaultViewDocument[]) exportableViews.toArray(new DefaultViewDocument[0]);
297 304
	}
298 305

  
299 306
}

Also available in: Unified diff