Revision 39484 branches/v2_0_0_prep/applications/appgvSIG/src/org/gvsig/app/imp/DefaultAppgvSIGManager.java

View differences:

DefaultAppgvSIGManager.java
31 31
package org.gvsig.app.imp;
32 32

  
33 33
import java.awt.Component;
34
import java.io.File;
34 35
import java.util.ArrayList;
35 36
import java.util.Iterator;
36 37
import java.util.List;
37 38

  
39
import javax.swing.JFileChooser;
40
import javax.swing.filechooser.FileFilter;
41

  
38 42
import org.cresques.cts.IProjection;
39 43
import org.gvsig.about.AboutLocator;
40 44
import org.gvsig.about.AboutManager;
......
380 384
    }
381 385

  
382 386
    public Document getActiveDocument() {
383
        Project project = this.getCurrentProject();
384
        if( project == null ) {
385
            return null;
386
        }
387
        return project.getActiveDocument();
387
    	return this.getActiveDocument((Class<? extends Document>)null);
388 388
    }
389 389
    
390 390
    public Document getActiveDocument(String documentTypeName) {
......
396 396
    }
397 397
    
398 398
    public Document getActiveDocument(Class<? extends Document> documentClass) {
399
        Document document = this.getActiveDocument();
400
        if( documentClass.isInstance(document) ) {
401
            return document;
399
        Project project = this.getCurrentProject();
400
        if( project == null ) {
401
            return null;
402 402
        }
403
        return null;
403
        return project.getActiveDocument(documentClass);
404 404
    }
405 405
    
406 406
    public IDocumentWindow getDocumentWindow(Document document) {
......
463 463
		return main.createComponentWithParams(theClass, parameters);
464 464
	}
465 465

  
466

  
467
	public File[] showChooserDialog(
468
			final String title,
469
			final int type, // SAVE_DIALOG / OPEN_DIALOG
470
			final int selectionMode, //    JFileChooser.FILES_ONLY, JFileChooser.DIRECTORIES_ONLY, JFileChooser.FILES_AND_DIRECTORIES
471
			final boolean multiselection, 
472
			final File initialPath,
473
			final FileFilter filter,
474
			final boolean fileHidingEnabled
475
			) {
476
		MainFrame main = PluginServices.getMainFrame();
477
		return main.showChooserDialog(title, type, selectionMode, multiselection, initialPath, filter, fileHidingEnabled);
478
	}
479
	
480
	public File[] showOpenDirectoryDialog(String title, File initialPath) {
481
		return showChooserDialog(title, JFileChooser.OPEN_DIALOG, JFileChooser.DIRECTORIES_ONLY, false, initialPath, null, false);
482
	}
483

  
484
	
485
	public File[] showOpenFileDialog(String title, File initialPath) {
486
		return showChooserDialog(title, JFileChooser.OPEN_DIALOG, JFileChooser.FILES_ONLY, false, initialPath, null, false);
487
	}
488

  
489
	
490
	public File[] showSaveFileDialog(String title, File initialPath) {
491
		return showChooserDialog(title, JFileChooser.SAVE_DIALOG, JFileChooser.FILES_ONLY, false, initialPath, null, false);
492
	}
493
	
466 494
	public String translate(String message, String... args) {
467 495
		return org.gvsig.i18n.Messages.translate(message, args);
468 496
	}
......
474 502
	public void refreshMenusAndToolBars() {
475 503
		PluginServices.getMainFrame().refreshControls();
476 504
	}
505

  
506
	
477 507
}

Also available in: Unified diff