package WebFlow.MSU; import java.applet.*; import java.awt.*; import java.awt.event.*; import org.omg.CORBA.*; import WebFlow.*; import WebFlow.event.*; import WebFlow.submitJob2.*; import java.io.*; import java.net.*; import java.util.*; public class adcirc1 extends Applet { public ORB orb; public String IOR; public WebFlowContext ws = null; public submitJob2 submit; private TextField status; private AdcircFrame1 f; private String message; private boolean ready; public void init() { ready=false; setLayout(new BorderLayout()); status = new TextField("welcome!"); status.setEditable(false); Panel buttonPanel = new Panel(); buttonPanel.setLayout(new GridLayout(1,2)); Button connectButton = new Button("connect"); connectButton.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent ev){ makeConnection(); } }); Button startButton = new Button("run Adcirc"); startButton.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent ev){ startJob(); } }); buttonPanel.add(connectButton); buttonPanel.add(startButton); Label author = new Label("WebPortal by T. Haupt, NPAC at Syracuse University", Label.CENTER); add(status,BorderLayout.NORTH); add(buttonPanel,BorderLayout.CENTER); add(author, BorderLayout.SOUTH); } public void makeConnection(){ status.setText("wait: connecting to the server"); if (connected()) { ready=true; status.setText("ready"); } else { status.setText(message); } } // maximum displacement calculator public void startJob(){ if(ready) { f = new AdcircFrame1(this); f.setSize(950,450); f.show(); } else { status.setText("Connect to the server first, please"); } } public boolean connected() { boolean c=true; String IorUrl="http://titan.erc.msstate.edu:8081/IOR/titan_master.txt"; try { orb = ORB.init(this, new java.util.Properties()); } catch (Exception e) {orb=null;} if(orb != null){ System.out.println("got ORB"); try { java.net.URL url = new java.net.URL(IorUrl); InputStream istream; String ref = ""; try { istream = url.openStream(); BufferedReader in = new BufferedReader(new InputStreamReader(istream)); ref = in.readLine(); istream.close(); System.out.println("read IOR"); try { org.omg.CORBA.Object MasterObj=orb.string_to_object(ref); ws = WebFlowContextHelper.narrow(MasterObj); if(MasterObj == null) System.out.println("Oops: MasterObj is null!"); System.out.println("Master narrowed"); System.out.println("connected to master"); // org.omg.CORBA.Object xo = ws.addNewModule("XmlServer"); // parser = XmlServerHelper.narrow(xo); // parser.test(); org.omg.CORBA.Object so = ws.addNewModule("submitJob"); submit = submitJob2Helper.narrow(so); submit.test(); // ws.attachPushEvent(xo,"submit",so,"submit"); System.out.println("got all modules"); }catch(Exception e) { message="Sorry, the server is down"; System.out.println("CORBA problem: "+e); c=false; } } catch(IOException e) { message="Sorry, the server is down"; System.out.println("stream problem: "+e); c=false; } } catch (Exception urle) { message="Sorry, the server is down"; System.out.println("URL problem"+urle); c=false; } return c; } else { c = false; message = "cannot initialize ORB"; System.out.println(message); return c; } } }