Beispiel #1
1
 public void fireEvent(NCCPConnection.ConnectionEvent e) {
   ConnectionListener l;
   int max = listeners.size();
   for (int i = 0; i < max; ++i) {
     ExpCoordinator.print(
         new String(
             "NCCPConnection.fireEvent ("
                 + toString()
                 + ") event: "
                 + e.getType()
                 + " max:"
                 + max
                 + " i:"
                 + i),
         2);
     l = (ConnectionListener) (listeners.elementAt(i));
     switch (e.getType()) {
       case ConnectionEvent.CONNECTION_FAILED:
         l.connectionFailed(e);
         break;
       case ConnectionEvent.CONNECTION_CLOSED:
         l.connectionClosed(e);
         break;
       case ConnectionEvent.CONNECTION_OPENED:
         ExpCoordinator.printer.print(
             new String("Opened control connection (" + toString() + ")"));
         l.connectionOpened(e);
     }
   }
 }
Beispiel #2
0
 public void setConnected(boolean b, boolean process_pending) {
   if (b && state != ConnectionEvent.CONNECTION_OPENED) {
     if (host.length() > 0)
       ExpCoordinator.print(
           "NCCPConnection open connection to ipaddress " + host + " port " + port);
     state = ConnectionEvent.CONNECTION_OPENED;
     // connected = true;
     fireEvent(new ConnectionEvent(this, state));
     ExpCoordinator.printer.print("NCCPConnection.setConnected " + b + " event fired", 8);
     if (process_pending) {
       int max = pendingMessages.size();
       ExpCoordinator.printer.print(new String("   pendingMessages " + max + " elements"), 8);
       for (int i = 0; i < max; ++i) {
         sendMessage((NCCP.Message) pendingMessages.elementAt(i));
       }
       pendingMessages.removeAllElements();
     }
   } else {
     if (!b
         && (state != ConnectionEvent.CONNECTION_CLOSED
             || state != ConnectionEvent.CONNECTION_FAILED)) {
       if (host.length() > 0)
         ExpCoordinator.print(
             new String(
                 "NCCPConnection.setConnected -- Closed control socket for " + host + "." + port));
       state = ConnectionEvent.CONNECTION_CLOSED;
       fireEvent(new ConnectionEvent(this, state));
     }
   }
 }
Beispiel #3
0
 public Object getUIRep() {
   if (uiRepCopy == null) {
     if (field == null)
       ExpCoordinator.print(
           new String("FieldParam(" + getLabel() + ").getUIRep field is null"), TEST_UIREP);
     else
       ExpCoordinator.print(
           new String("FieldParam(" + getLabel() + ").getUIRep field:" + field.toString()),
           TEST_UIREP);
     uiRepCopy = field.getUIRepCopy(isEditable());
     setUIRep(uiRepCopy.getComponent());
   }
   return (super.getUIRep());
 }
Beispiel #4
0
  private boolean connectSPPMon() {
    if (state == ConnectionEvent.CONNECTION_PENDING) {
      ExpCoordinator.print(
          new String("NCCPConnection(" + host + ", " + port + ").connect connection pending"), 0);
      while (state == ConnectionEvent.CONNECTION_PENDING) {
        try {
          Thread.sleep(500);
        } catch (java.lang.InterruptedException e) {
        }
      }
      return (isConnected());
    }

    state = ConnectionEvent.CONNECTION_PENDING;
    if (nonProxy != null) {
      try {
        nonProxy.connect();
      } catch (UnknownHostException e) {
        boolean rtn = informUserError("Don't know about host: " + host + ":" + e.getMessage());
        return rtn;
      } catch (SocketTimeoutException e) {
        boolean rtn = informUserError("Socket time out for " + host + ":" + e.getMessage());
        return rtn;
      } catch (IOException e) {
        boolean rtn = informUserError("Couldnt get I/O for " + host + ":" + e.getMessage());
        return rtn;
      }
    }
    return (isConnected());
  }
Beispiel #5
0
 public boolean connect() {
   ExpCoordinator.printer.print("NCCPConnection.connect", 3);
   if (host.length() == 0) {
     ExpCoordinator.printer.print("NCCPConnection.connect host is not set", 6);
     return false;
   }
   if (proxy == null && nonProxy == null) {
     ExpCoordinator.printer.print("NCCPConnection.connect proxy null");
     return false;
   }
   if (ExpCoordinator.isSPPMon()) return (connectSPPMon());
   if (state == ConnectionEvent.CONNECTION_CLOSED || state == ConnectionEvent.CONNECTION_FAILED) {
     state = ConnectionEvent.CONNECTION_PENDING;
     if (proxy != null) {
       proxy.openConnection(this);
     }
   }
   /*
   if (nonProxy != null && proxy == null)
   {
   	return (nonProxy.connect());
   }
   */
   return true;
 }
Beispiel #6
0
 public void read(ONL.Reader rdr) throws java.io.IOException {
   setHost(new String(rdr.readString()));
   setPort(rdr.readInt());
   short cid = (short) rdr.readShort();
   ExpCoordinator.print(
       new String("NCCPConnection.read host:" + getHost() + " port:" + getPort() + " cid:" + cid),
       5);
   if (proxy != null) proxy.setConnectionID(this, cid);
 }
Beispiel #7
0
 protected boolean informUserError(String msg) // this is just for SPPmon
     {
   if (!ExpCoordinator.isSPPMon()) return false;
   final String opt0 = "Try Again";
   final String opt1 = "Cancel";
   JLabel lbl = new JLabel(msg);
   TextFieldwLabel tfaddress = new TextFieldwLabel(30, "daemon addr:");
   tfaddress.setText(host);
   TextFieldwLabel tfport = new TextFieldwLabel(30, "daemon port:");
   tfport.setText(String.valueOf(port));
   Object[] params = {lbl, tfaddress, tfport};
   Object[] options = {opt0, opt1};
   int rtn =
       JOptionPane.showOptionDialog(
           ExpCoordinator.getMainWindow(),
           params,
           "Connection Error",
           JOptionPane.YES_NO_OPTION,
           JOptionPane.WARNING_MESSAGE,
           null,
           options,
           options[0]);
   if (rtn == JOptionPane.NO_OPTION) {
     connectionFailed();
     return false;
   } else {
     String tmp_host = host;
     boolean change = false;
     if (tfaddress.getText().length() > 0) tmp_host = tfaddress.getText();
     int tmp_port = port;
     if (tfport.getText().length() > 0) tmp_port = Integer.parseInt(tfport.getText());
     if (!tmp_host.equals(host)) {
       host = new String(tmp_host);
       change = true;
     }
     if (port != tmp_port) {
       port = tmp_port;
       change = true;
     }
     if (change) fireEvent(new ConnectionEvent(this, ConnectionEvent.ADDRESS_CHANGED));
     state = ConnectionEvent.CONNECTION_CLOSED;
     return (connect());
   }
 }
Beispiel #8
0
 public FieldParam(FieldParam p) {
   super((Param) p);
   field = p.field;
   fieldOwner = p.fieldOwner;
   // uiRepCopy = field.getUIRepCopy();//REMOVED 8/10/10
   // setUIRep(uiRepCopy.getComponent());//REMOVED 8/10/10
   ExpCoordinator.print(
       new String("FieldParam(" + label + ")(FieldParam) default:" + p.getDefaultValue()),
       TEST_FIELDPARAM);
 }
Beispiel #9
0
    public void print(int dlevel) {
      if (msgtype == NCCP.MessageResponse)
        ExpCoordinator.print(
            new String("NCCPConnection.Message Response size = " + msgsize), dlevel);
      else
        ExpCoordinator.print(
            new String("NCCPConnection.Message type = " + msgtype + " size = " + msgsize), dlevel);
      String tmp_str = "";
      int max = msgsize - 2;
      for (int i = 0; i < max; ++i) {
        for (int j = 0; j < 4; ++j) {
          if (i < max) {
            tmp_str = tmp_str.concat(new String(msgbytes[i] + " "));
            ++i;
          }
        }

        ExpCoordinator.print(new String("     " + tmp_str), dlevel);
        tmp_str = "";
      }
    }
Beispiel #10
0
 public void setConnectionID(short cid) {
   ExpCoordinator.print(
       new String(
           "NCCPConnection.setConnectionID host:"
               + getHost()
               + " port:"
               + getPort()
               + " cid:"
               + cid),
       5);
   if (proxy != null) proxy.setConnectionID(this, cid);
 }
Beispiel #11
0
 public FieldParam(ParamSpec fps, ONLComponent pc, Command cs) {
   super((ParamSpec) fps, pc, cs);
   if (cs.getFieldOwner() == null && pc instanceof Field.Owner) fieldOwner = (Field.Owner) pc;
   else fieldOwner = cs.getFieldOwner();
   getField();
   setDefaultValue(fps.getDefaultValue());
   ExpCoordinator.print(
       new String(
           "FieldParam("
               + label
               + ")(ParamSpec, ONLComponent, Command) command:"
               + cs.getLabel()
               + " default:"
               + fps.getDefaultValue()),
       TEST_FIELDPARAM);
 }
Beispiel #12
0
 public void processMessage(DataInputStream dataIn) throws IOException {
   count = 0;
   int msgsize = dataIn.readInt();
   count = 1;
   int msgtype = 0;
   if (msgsize >= 2) msgtype = dataIn.readUnsignedShort();
   else {
     if (msgsize == 1) dataIn.readByte();
     ExpCoordinator.printer.print(
         new String("ERROR:NCCPConnection.run msgsize(" + msgsize + ") < 2 msgtype = " + msgtype));
     ExpCoordinator.printer.printHistory();
     return;
   }
   count = 2;
   switch (msgtype) {
     case NCCP.MessageResponse:
       ExpCoordinator.print(
           new String(
               "NCCPConnection::run message is  NCCP.MessageResponse " + msgsize + " " + msgtype),
           3);
       MessageRunnable tmp_msg = new MessageRunnable(msgsize, msgtype, dataIn);
       tmp_msg.print(5);
       SwingUtilities.invokeLater(tmp_msg);
       break;
     case NCCP.MessagePeriodic:
       ExpCoordinator.printer.print(
           new String(
               "NCCPConnection::run message is  NCCP.MessagePeriodic " + msgsize + " " + msgtype),
           3);
       processPeriodicMsg(msgsize, msgtype, dataIn);
       break;
     default:
       ExpCoordinator.printer.print(
           new String("NCCPConnection::run message is  Other " + msgsize + " " + msgtype));
       SwingUtilities.invokeLater(new MessageRunnable(msgsize, msgtype, dataIn));
   }
 }