Example #1
0
 @Override
 public void frameArrived(MessageObjectFrame frame) {
   Object obj = frame.getObject();
   if (obj instanceof CellInfo[]) {
     _infos = (CellInfo[]) obj;
     _list.removeAll();
     int systemIndex = -1;
     TreeSet<String> sorted = new TreeSet<>();
     for (CellInfo cellInfo : _infos) {
       sorted.add(cellInfo.getCellName());
     }
     Iterator<String> it = sorted.iterator();
     for (int i = 0; it.hasNext(); i++) {
       String name = it.next();
       _list.add(name);
       if (name.equals("System")) {
         systemIndex = i;
       }
     }
     if (systemIndex > -1) {
       _cellPanel.showCell(_infos[systemIndex], _domainNode.getAddress());
       _commandPanel.showCell(_infos[systemIndex], _domainNode.getAddress() + ":System");
       _list.select("System");
     }
   }
 }
 /**
  * Web service operation to get information of a spy in spy list.
  *
  * @param name name of spy to be gotten
  * @return spy info
  */
 @WebMethod(operationName = "getSpy")
 public String getSpy(@WebParam(name = "name") String name) {
   if (spyList.get(name) == null) {
     return "No such spy.";
   }
   return spyList.get(name).toString();
 }
 /**
  * Web service operation to delete a spy in spy list.
  *
  * @param name name of spy to be deleted
  * @return result of deleting
  */
 @WebMethod(operationName = "deleteSpy")
 public String deleteSpy(@WebParam(name = "name") String name) {
   Spy spy;
   if ((spy = spyList.get(name)) == null) {
     return "Spy doesn't exist. No deletion made.";
   }
   spyList.delete(spy);
   return String.format("Spy <%s> was deleted from the list.", name);
 }
  /**
   * Web service operation to update a spy in spy list.
   *
   * @param name name of spy to be updated
   * @param title title of spy to be updated
   * @param location location of spy to be updated
   * @param password password of spy to be updated
   * @return result of updating
   */
  @WebMethod(operationName = "updateSpy")
  public String updateSpy(
      @WebParam(name = "name") String name,
      @WebParam(name = "title") String title,
      @WebParam(name = "location") String location,
      @WebParam(name = "password") String password) {
    if (spyList.get(name) == null) {
      return "Spy doesn't exist. No update made.";
    }

    Spy spy = new Spy(name, title, location, password);
    spyList.add(spy);
    return spy.toString();
  }
 /**
  * Web service operation to add spy to the spy list.
  *
  * @param name name of spy to be added
  * @param title title of spy to be added
  * @param location location of spy to be added
  * @param password password of spy to be added
  * @return result of adding
  */
 @WebMethod(operationName = "addSpy")
 public String addSpy(
     @WebParam(name = "name") String name,
     @WebParam(name = "title") String title,
     @WebParam(name = "location") String location,
     @WebParam(name = "password") String password) {
   // TODO write your implementation code here:
   if (spyList.get(name) != null) {
     return "Spy already exists. No update made.";
   }
   Spy spy = new Spy(name, title, location, password);
   spyList.add(spy);
   return spy.toString();
 }
Example #6
0
  DomainPanel(DomainConnection connection) {
    _connection = connection;
    _useColor = System.getProperty("bw") == null;
    if (_useColor) {
      setBackground(Color.red);
    }
    setLayout(new BorderLayout());
    _leftPanel = new LeftPanel();
    _topLabel = new Label("Domain", Label.CENTER);
    _topLabel.setFont(new Font("fixed", Font.ITALIC, 18));
    add(_topLabel, "North");
    add(new BorderPanel(_leftPanel), "West");

    _cellPanel = new CellPanel(_connection);
    _commandPanel = new CommandPanel(_connection);

    _cardPanel = new Panel(_cards);
    _cardPanel.add(new BorderPanel(_cellPanel), "cell");
    _cardPanel.add(new BorderPanel(_commandPanel), "command");
    _cards.show(_cardPanel, "cell");

    add(_cardPanel, "Center");

    _updateButton.addActionListener(this);
    _detailButton.addActionListener(this);
    _commandButton.addActionListener(this);
    _list.addItemListener(this);
  }
Example #7
0
 public void clear() {
   _list.removeAll();
   _cellPanel.clear();
   _commandPanel.clear();
 }
/**
 * This class is the web server providing functions for adding, updating, deleting spy and getting
 * spy information.
 *
 * @author changyilong
 */
@WebService(serviceName = "SpyService")
public class SpyService {

  // Spy list
  SpyList spyList = SpyList.getInstance();

  /**
   * Web service operation to add spy to the spy list.
   *
   * @param name name of spy to be added
   * @param title title of spy to be added
   * @param location location of spy to be added
   * @param password password of spy to be added
   * @return result of adding
   */
  @WebMethod(operationName = "addSpy")
  public String addSpy(
      @WebParam(name = "name") String name,
      @WebParam(name = "title") String title,
      @WebParam(name = "location") String location,
      @WebParam(name = "password") String password) {
    // TODO write your implementation code here:
    if (spyList.get(name) != null) {
      return "Spy already exists. No update made.";
    }
    Spy spy = new Spy(name, title, location, password);
    spyList.add(spy);
    return spy.toString();
  }

  /**
   * Web service operation to update a spy in spy list.
   *
   * @param name name of spy to be updated
   * @param title title of spy to be updated
   * @param location location of spy to be updated
   * @param password password of spy to be updated
   * @return result of updating
   */
  @WebMethod(operationName = "updateSpy")
  public String updateSpy(
      @WebParam(name = "name") String name,
      @WebParam(name = "title") String title,
      @WebParam(name = "location") String location,
      @WebParam(name = "password") String password) {
    if (spyList.get(name) == null) {
      return "Spy doesn't exist. No update made.";
    }

    Spy spy = new Spy(name, title, location, password);
    spyList.add(spy);
    return spy.toString();
  }

  /**
   * Web service operation to get information of a spy in spy list.
   *
   * @param name name of spy to be gotten
   * @return spy info
   */
  @WebMethod(operationName = "getSpy")
  public String getSpy(@WebParam(name = "name") String name) {
    if (spyList.get(name) == null) {
      return "No such spy.";
    }
    return spyList.get(name).toString();
  }

  /**
   * Web service operation to delete a spy in spy list.
   *
   * @param name name of spy to be deleted
   * @return result of deleting
   */
  @WebMethod(operationName = "deleteSpy")
  public String deleteSpy(@WebParam(name = "name") String name) {
    Spy spy;
    if ((spy = spyList.get(name)) == null) {
      return "Spy doesn't exist. No deletion made.";
    }
    spyList.delete(spy);
    return String.format("Spy <%s> was deleted from the list.", name);
  }

  /**
   * Web service operation to get the text representation of all spies in spy list.
   *
   * @return text representation of all spies
   */
  @WebMethod(operationName = "getList")
  public String getList() {
    return spyList.toString();
  }

  /**
   * Web service operation to get the XML representation of all spies in spy list.
   *
   * @return XML representation of all spies
   */
  @WebMethod(operationName = "getListAsXML")
  public String getListAsXML() {
    return spyList.toXML();
  }
}
 /**
  * Web service operation to get the XML representation of all spies in spy list.
  *
  * @return XML representation of all spies
  */
 @WebMethod(operationName = "getListAsXML")
 public String getListAsXML() {
   return spyList.toXML();
 }
 /**
  * Web service operation to get the text representation of all spies in spy list.
  *
  * @return text representation of all spies
  */
 @WebMethod(operationName = "getList")
 public String getList() {
   return spyList.toString();
 }