Revision 43293 trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/extension/ProjectExtension.java

View differences:

ProjectExtension.java
318 318
		this.execute(command, null);
319 319
	}
320 320

  
321
	public void execute(String actionCommand, Object[] args) {
322
		if (actionCommand.equals("application-project-new")) {
323
			if (!askSave()) {
324
				return;
325
			}
321
    public void execute(String actionCommand, Object[] args) {
322
        if (actionCommand.equals("application-project-new")) {
323
            if (!askSave()) {
324
                return;
325
            }
326 326

  
327
			projectPath = null;
328
			PluginServices.getMDIManager().closeAllWindows();
329
			setProject(ProjectManager.getInstance().createProject());
330
			getProjectFrame().setProject(p);
331
			showProjectWindow();
332
			PluginServices.getMainFrame().setTitle(
333
					PluginServices.getText(this, "sin_titulo"));
327
            projectPath = null;
328
            PluginServices.getMDIManager().closeAllWindows();
329
            setProject(ProjectManager.getInstance().createProject());
334 330

  
335
            } else if (actionCommand.equals("application-project-open")) {
336
			if (!askSave()) {
337
				return;
338
			}
339
                        File projectFile = (File) ArrayUtils.get(args, 0, DataTypes.FILE);
340
                        if ( projectFile != null && !projectFile.exists() ) {
341
                            LOG.warn("Can't load project '"
342
                                    + projectFile.getAbsolutePath()
343
                                    + "', file not exist.");
344
                            projectFile = null;
345
                        }
331
            showProjectWindow();
332
            PluginServices.getMainFrame().setTitle(PluginServices.getText(this, "sin_titulo"));
346 333

  
347
			if (projectFile == null) {
348
				Preferences prefs = Preferences.userRoot().node(
349
						"gvsig.foldering");
350
				JFileChooser jfc = new JFileChooser(PROJECT_FILE_CHOOSER_ID,
351
						prefs.get("ProjectsFolder", null));
334
        } else if (actionCommand.equals("application-project-open")) {
335
            if (!askSave()) {
336
                return;
337
            }
352 338

  
353
				GenericFileFilter projExtensionFilter = new GenericFileFilter(
354
						Project.FILE_EXTENSION, PluginServices.getText(this,
355
								"tipo_fichero_proyecto"));
356
        jfc.addChoosableFileFilter(projExtensionFilter);
357
				jfc.setFileFilter(projExtensionFilter);
339
            setProject(ProjectManager.getInstance().createProject());
358 340

  
359
				if (jfc.showOpenDialog((Component) PluginServices
360
						.getMainFrame()) != JFileChooser.APPROVE_OPTION) {
361
					return;
362
				}
363
				// ProjectDocument.initializeNUMS();
341
            File projectFile = (File) ArrayUtils.get(args, 0, DataTypes.FILE);
342
            if (projectFile != null && !projectFile.exists()) {
343
                LOG.warn("Can't load project '" + projectFile.getAbsolutePath() + "', file not exist.");
344
                projectFile = null;
345
            }
364 346

  
347
            if (projectFile == null) {
348
                Preferences prefs = Preferences.userRoot().node("gvsig.foldering");
349
                JFileChooser jfc = new JFileChooser(PROJECT_FILE_CHOOSER_ID, prefs.get("ProjectsFolder", null));
365 350

  
366
				projectFile = jfc.getSelectedFile();
367
			}
351
                GenericFileFilter projExtensionFilter =
352
                    new GenericFileFilter(Project.FILE_EXTENSION, PluginServices.getText(this, "tipo_fichero_proyecto"));
353
                jfc.addChoosableFileFilter(projExtensionFilter);
354
                jfc.setFileFilter(projExtensionFilter);
368 355

  
369
			PluginServices.getMDIManager().closeAllWindows();
356
                if (jfc.showOpenDialog((Component) PluginServices.getMainFrame()) != JFileChooser.APPROVE_OPTION) {
357
                    return;
358
                }
359
                // ProjectDocument.initializeNUMS();
370 360

  
371
			Project o = readProject(projectFile);
372
			setPath(projectFile.getAbsolutePath());
373
			// lastPath = getPath();
374
			if (o != null) {
375
				setProject(o);
376
			}
361
                projectFile = jfc.getSelectedFile();
362
            }
377 363

  
378
			getProjectFrame().setProject(p);
379
			PluginServices.getMainFrame().setTitle(projectFile.getName());
380
			getProjectFrame().refreshControls();
364
            PluginServices.getMDIManager().closeAllWindows();
381 365

  
382
			// p.restoreWindowProperties();
366
            Project o = readProject(projectFile);
367
            setPath(projectFile.getAbsolutePath());
368
            // lastPath = getPath();
369
            if (o != null) {
370
                setProject(o);
371
            }
383 372

  
384
		} else if (actionCommand.equals("application-project-save")) {
385
//			saveProject();
386
			try {
373
            getProjectFrame().setProject(p);
374
            PluginServices.getMainFrame().setTitle(projectFile.getName());
375
            getProjectFrame().refreshControls();
376

  
377
            // p.restoreWindowProperties();
378

  
379
        } else if (actionCommand.equals("application-project-save")) {
380
            // saveProject();
381
            try {
387 382
                Launcher.manageUnsavedData("there_are_unsaved_resources");
388 383
            } catch (Exception e) {
389 384
                LOG.warn("Can't manage unsaved data", e);
390 385
            }
391
		} else if (actionCommand.equals("application-project-save-as")) {
392
			File file = (File) ArrayUtils.get(args, 0, DataTypes.FILE);
393
			saveAsProject(file);
394
		}
386
        } else if (actionCommand.equals("application-project-save-as")) {
387
            File file = (File) ArrayUtils.get(args, 0, DataTypes.FILE);
388
            saveAsProject(file);
389
        }
395 390

  
396
	}
391
    }
397 392

  
398 393

  
399 394
    private void createEmptyProject() {
......
581 576
	 * @param p
582 577
	 */
583 578
	public void setProject(Project p) {
584
		getProjectFrame().setProject(p);
585 579
		this.p = p;
580
		getProjectFrame().setProject(p);
586 581
	}
587 582

  
588 583
	private void registerDocuments() {

Also available in: Unified diff