From: Frederic D. <de...@us...> - 2004-06-11 16:33:29
|
Update of /cvsroot/fudaa/fudaa_devel/dodico/src/org/fudaa/dodico/olb In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv778/src/org/fudaa/dodico/olb Modified Files: OLBExec.java Log Message: Maj Index: OLBExec.java =================================================================== RCS file: /cvsroot/fudaa/fudaa_devel/dodico/src/org/fudaa/dodico/olb/OLBExec.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** OLBExec.java 12 Feb 2004 15:32:46 -0000 1.3 --- OLBExec.java 11 Jun 2004 16:33:13 -0000 1.4 *************** *** 12,15 **** --- 12,16 ---- import java.io.IOException; + import org.fudaa.dodico.commun.DodicoPreferences; import org.fudaa.dodico.commun.DodicoResource; import org.fudaa.dodico.commun.DodicoUI; *************** *** 28,32 **** --- 29,35 ---- */ public class OLBExec { + boolean stop_; + /** * *************** *** 36,109 **** } public void stop() { ! stop_= true; } ! public EfGrid computeGrid( ! EfGrid _init, ! ProgressionInterface _prog, ! DodicoUI _ui) { ! stop_= false; ! File dir= new File("serveurs/olb"); ! if((_ui!=null) && (!dir.exists())) { ! ! _ui.error( ! "OLB", ! DodicoResource.getS( ! "Le dossier {0} du serveur est introuvable", ! dir.getAbsolutePath())); return null; } File inFile; File outFile; try { ! inFile= File.createTempFile("temp", ".olb_in", dir); ! outFile= File.createTempFile("temp", ".olb_out", dir); ! } catch (IOException e) { ! return null; } ! if (stop_) ! return null; ! if ((inFile == null) || (outFile == null)) return null; ! DunesAdapter interfaceDunes= new DunesAdapter(); interfaceDunes.setMaillage(_init); ! FileOperationSynthese op= ! DunesFileFormat.getInstance().getLastVersionImpl().write( ! inFile, ! interfaceDunes, ! _prog); ! if (stop_) ! return null; ! if ((_ui!=null) && (op.containsFatalError())) { _ui.error(op.getAnalyze().getFatalError().toString()); return null; } ! String exe; ! String os= System.getProperty("os.name"); ! if (os.startsWith("Windows")) ! exe= "olb.exe"; ! else ! exe= "olb-" + os + ".x"; ! String[] cmd= new String[3]; ! cmd[0]= new File(dir,exe).getAbsolutePath(); ! cmd[1]= inFile.getName(); ! cmd[2]= outFile.getName(); ! CExec exec=new CExec(cmd); exec.setExecDirectory(dir); exec.exec(); ! if(!outFile.exists()){ ! return null; ! } ! op=DunesFileFormat.getInstance().getLastVersionImpl().read(outFile, _prog); ! if((_ui!=null) && (op.containsFatalError())){ _ui.error("OLB", op.getAnalyze().getFatalError().getMessage()); } ! if(inFile!=null) inFile.delete(); ! if(outFile!=null) outFile.delete(); ! DunesInterface r=(DunesInterface)op.getSource(); ! if(r!=null) return r.getGrid(); return null; } ! } --- 39,125 ---- } + public static String getOlbExecDir() { + return DodicoPreferences.DODICO.getStringProperty("olb.exec.dir", new File("serveurs/olb/") + .getAbsolutePath()); + } + + public static void setOlbExecDir(String path) { + DodicoPreferences.DODICO.putStringProperty("olb.exec.dir", path); + } + + public static void unsetOlbExecDir() { + DodicoPreferences.DODICO.removeProperty("olb.exec.dir"); + } + + public static String getOlbName(){ + String os = System.getProperty("os.name"); + if (os.startsWith("Windows")) return "olb.exe"; + return "olb-" + os + ".x"; + } + + public static File getWindowsOlbExec() { + return new File(getOlbExecDir(), "olb.exe"); + } + + public static File getOlbExecPath(){ + File dir = new File(getOlbExecDir()); + String os = System.getProperty("os.name"); + if (os.startsWith("Windows")) return getWindowsOlbExec(); + else return new File(dir, "olb-" + os + ".x"); + } + public void stop() { ! stop_ = true; } ! public EfGrid computeGrid(EfGrid _init, ProgressionInterface _prog, DodicoUI _ui) { ! stop_ = false; ! File exe=getOlbExecPath(); ! if (!exe.exists()) { ! if (_ui != null) ! _ui.error("OLB", DodicoResource.getS("Le fichier {0} est introuvable", exe ! .getAbsolutePath())); return null; } File inFile; File outFile; + File dir=exe.getParentFile(); try { ! inFile = File.createTempFile("temp", ".olb_in", dir); ! outFile = File.createTempFile("temp", ".olb_out", dir); } ! catch (IOException e) { return null; ! } ! if (stop_) return null; ! if ((inFile == null) || (outFile == null)) return null; ! DunesAdapter interfaceDunes = new DunesAdapter(); interfaceDunes.setMaillage(_init); ! FileOperationSynthese op = DunesFileFormat.getInstance().getLastVersionImpl().write(inFile, ! interfaceDunes, _prog); ! if (stop_) return null; ! if ((_ui != null) && (op.containsFatalError())) { _ui.error(op.getAnalyze().getFatalError().toString()); return null; } ! ! String[] cmd = new String[3]; ! cmd[0] = exe.getAbsolutePath(); ! cmd[1] = inFile.getName(); ! cmd[2] = outFile.getName(); ! CExec exec = new CExec(cmd); exec.setExecDirectory(dir); exec.exec(); ! if (!outFile.exists()) { return null; } ! op = DunesFileFormat.getInstance().getLastVersionImpl().read(outFile, _prog); ! if ((_ui != null) && (op.containsFatalError())) { _ui.error("OLB", op.getAnalyze().getFatalError().getMessage()); } ! if (inFile != null) inFile.delete(); ! if (outFile != null) outFile.delete(); ! DunesInterface r = (DunesInterface) op.getSource(); ! if (r != null) return r.getGrid(); return null; } ! } \ No newline at end of file |