src
|
BabelApp.java,
BabelConfigPanel.java,
BabelPanel.java,
ChemAppThread.java,
ChemConsole.java,
ChemConsoleFrame.java,
ChemMessage.java,
ChemToolFrame.java,
ConfigPanel.java,
DataFileEditorPanel.java,
FileListFilter.java,
GaussConfigPanel.java,
GuassianPanel.java,
Help.java,
MopacApp.java,
MopacConfigPanel.java,
MopacPanel.java,
NetworkPanel.java,
ServerConfigPanel.java,
StatusPanel.java,
TextFileViewer.java,
TextInputFile.java,
TextOutputFile.java,
Timer.java,
fDialog.java,
mk.sh
|
|
|
/**
* BabelApp.java
* This acts as the main interface between the Chem console GUI and the legacy
* Babel v 1.1 application
* Created: Fri Apr 23 18:58:51 1999
*
* @author Nathan Stevens
* @version
*/
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;
import com.sun.java.swing.*;
//import javax.swing.*;
public class BabelApp extends ChemAppThread
{
private String Mode;
private String com;
private int intype;
private String infile;
private String keyw1;
private int outtype;
private String outfile;
private String keyw2;
private String rnum;
private String adh;
private BabelPanel Bp;
private String itype, otype;
private ChemMessage m;
private Process process;
BabelApp(BabelPanel bp)
{
Bp = bp;
m = new ChemMessage(Bp);
Mode = Bp.getMode(); // get the mode
com = Bp.getCommand(); // get the command
infile = Bp.getInfile(); // get the infile
keyw1 = Bp.getKeyw1(); // get the first key word
outfile = Bp.getOutfile(); // get the outfile
keyw2 = Bp.getKeyw2(); // get the second key word
rnum = Bp.getRn(); // get the renum string
adh = Bp.getAdh(); // get the add/del hydrogen
// variable
}
//The run method
public void run()
{
// Convert the intype an out type String to intergers
try
{
intype = Integer.parseInt(Bp.getIntype());
outtype = Integer.parseInt(Bp.getOuttype());
}
catch(NumberFormatException e)
{
String[] emsg = {"Unable to Convert Input or Output entry",
"to an Integer. Please check values. "};
m.errPrint(emsg, "NumberFormat Error");
this.stop();
}
checkfile();
}
synchronized private void checkfile()
{
// first thing we do is check to see if the input file really exist
File inputfile = new File(infile);
String[] emsg = {"The input file " + infile + " doesn't exist.",
"Please check that the correct inputfile name was",
"entered..."};
if(inputfile.isFile())
{
setCommand(); // this method set the command
}
else
{
m.errPrint(emsg, "File Error");
this.stop();
}
}
// method that set the command String according to the variables that were
// passed to the constructor
synchronized private void setCommand()
{
itype = "-i" + getInputType();
otype = "-o" + getOutputType();
/*now we make a String of the commmand. the format is:
babel -i [keywords] -o [keywords2]
*/
Vector commandv = new Vector();
//seed the vector with required arguments
commandv.addElement(com);
commandv.addElement(itype);
commandv.addElement(infile);
commandv.addElement(otype);
commandv.addElement(outfile);
// Now add the rest of supplemental arguments
if(keyw2 != null)
commandv.addElement(keyw2);
if(rnum != null)
commandv.insertElementAt(rnum, 3);
if(adh != null)
commandv.insertElementAt(adh, 3);
if(keyw1 != null)
commandv.insertElementAt(keyw1, 3);
// now copy the vector into an array of type String
String[] command = new String[commandv.size()];
commandv.copyInto(command);
runApp(command);
}
// Method to return the type of inpute
synchronized private String getInputType()
{
switch(intype)
{
case 1:
return "alc";
case 2:
return "prep";
case 3:
return "bs";
case 4:
return "bgf";
case 5:
return "car";
case 6:
return "boog";
case 7:
return "caccrt";
case 8:
return "cadpac";
case 9:
return "charmm";
case 10:
return "c3d1";
case 11:
return "c3d2";
case 12:
return "cssr";
case 13:
return "fdat";
case 14:
return "gstat";
case 15:
return "dock";
case 16:
return "dpdb";
case 17:
return "feat";
case 18:
return "fract";
case 19:
return "gamout";
case 20:
return "gzmat";
case 21:
return "guout";
case 22:
return "g94";
case 23:
return "gr96A";
case 24:
return "gr96N";
case 25:
return "hin";
case 26:
return "sdf";
case 27:
return "m3d";
case 28:
return "macmol";
case 29:
return "macmod";
case 30:
return "mocro";
case 31:
return "mm2in";
case 32:
return "mm2out";
case 33:
return "mm3";
case 34:
return "mmads";
case 35:
return "mdl";
case 36:
return "molen";
case 37:
return "mopcrt";
case 38:
return "mopint";
case 39:
return "mopout";
case 40:
return "pcmod";
case 41:
return "pdb";
case 42:
return "psin";
case 43:
return "psout";
case 44:
return "msf";
case 45:
return "schakal";
case 46:
return "shelx";
case 47:
return "smiles";
case 48:
return "spar";
case 49:
return "semi";
case 50:
return "spmm";
case 51:
return "mol";
case 52:
return "mol2";
case 53:
return "wiz";
case 54:
return "unixyz";
case 55:
return "xyz";
case 56:
return "xed";
default:
{
String[] emsg = {"This is not a supported input type"};
m.errPrint(emsg, "Input Type Error");
}
}
this.stop(); // prevent any other method from executing
//we never get to this point
return "xxx";
}
// Method to return type of output
public String getOutputType()
{
switch(outtype)
{
case 1:
return "diag";
case 2:
return "alc";
case 3:
return "bs";
case 4:
return "bgf";
case 5:
return "bmin";
case 6:
return "box";
case 7:
return "caccrt";
case 8:
return "cacint";
case 9:
return "cache";
case 10:
return "c3d1";
case 11:
return "c3d2";
case 12:
return "cdct";
case 13:
return "dock";
case 14:
return "wiz";
case 15:
return "contmp";
case 16:
return "cssr";
case 17:
return "dpdb";
case 18:
return "feat";
case 19:
return "fhz";
case 20:
return "gamin";
case 21:
return "gcart";
case 22:
return "gzmart";
case 23:
return "gotmp";
case 24:
return "gr96A";
case 25:
return "gr96N";
case 26:
return "hin";
case 27:
return "icon";
case 28:
return "idatm";
case 29:
return "sdf";
case 30:
return "m3d";
case 31:
return "macmol";
case 32:
return "macmod";
case 33:
return "micro";
case 34:
return "mm2in";
case 35:
return "mm2out";
case 36:
return "mm3";
case 37:
return "mmads";
case 38:
return "mdl";
case 39:
return "miv";
case 40:
return "mopcrt";
case 41:
return "mopint";
case 42:
return "csr";
case 43:
return "pcmod";
case 44:
return "pdb";
case 45:
return "psz";
case 46:
return "psc";
case 47:
return "report";
case 48:
return "smiles";
case 49:
return "spar";
case 50:
return "mol";
case 51:
return "mol2";
case 52:
return "maccs";
case 53:
return "torlist";
case 54:
return "tinker";
case 55:
return "unixyz";
case 56:
return "xyz";
case 57:
return "xed";
default:
{
String[] emsg = {"This is not a supported output type"};
m.errPrint(emsg, "Output Type Error");
}
}
this.stop(); //prevent any other thing from executing
//we never get to this point
return "xxx";
}
// Method that runs the native babel app. it will check the mode of the babel
// panel to see weather it is runing in local or native mode;
synchronized public void runApp(String[] Command)
{
if(Mode.equals("local"))
{
try
{
/*test code
for(int i = 0; i < Command.length; i++)
System.out.println(Command[i]); */
process = Runtime.getRuntime().exec(Command);
process.waitFor();
String msg = "Conversion of " + infile + " completed.";
m.msgPrint(msg, "Status");
}
catch(IOException e)
{
String[] emsg = {"Babel failed to execute",""+ e};
m.errPrint(emsg, "Babel Error");
}
catch(Exception e)
{
String[] emsg = {"The following Error(s) occured", ""+e};
m.errPrint(emsg, "Error");
}
//Check to if out put file was produced am move it to
// the output directory.
}
}
}
|