AMAPstudio

User Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
file_preview_and_checking_in_file_chooser [2017/12/08 16:22]
coligny [Checking file format in the CheckingFileChooser: 2 methods]
file_preview_and_checking_in_file_chooser [2018/03/12 15:42] (current)
coligny
Line 53: Line 53:
 <code java> <code java>
 // fc-4.12.2017 A file chooser showing which files can be loaded // fc-4.12.2017 A file chooser showing which files can be loaded
-JFileChooser chooser = new CheckingFileChooser(Settings.getProperty("​capsis.inventory.path",​+JFileChooser chooser = new CheckingFileChooser(Settings.getProperty("​samsara2.inventory.path",​
  PathManager.getDir("​data"​))) {  PathManager.getDir("​data"​))) {
  
- public ​boolean ​check(File f) {+ public ​void check(File f) throws Exception ​{
  String fileName = f.getAbsolutePath();​  String fileName = f.getAbsolutePath();​
  
- // Specific code, returns true if the file is ok...+ // Throws an exception ​if file can not be loaded
  
- try { + // Use fake objects to avoid side effects 
- // Use fake objects to avoid side effects + Samsa2Model modelFake = new Samsa2Model();​ 
- Samsa2Model modelFake = new Samsa2Model();​ + Samsa2InitialParameters ipFake = modelFake.getSettings();​
- Samsa2InitialParameters ipFake = modelFake.getSettings();​+
  
- // Check if the file can be loaded + // Check if the file can be loaded 
- ipFake.vParamMS.virtualStand = false; + ipFake.vParamMS.virtualStand = false; 
- ipFake.fileName = fileName; + ipFake.fileName = fileName; 
- ipFake.buildInitScene(modelFake);​+ ipFake.buildInitScene(modelFake);​
  
- // Seems ok 
- return true; 
- 
- } catch (Throwable e) { 
- // Seems problematic 
- return false; 
- 
- } 
  }  }
 }; };
file_preview_and_checking_in_file_chooser.1512750141.txt · Last modified: 2017/12/08 16:22 by coligny