Exemplo n.º 1
0
  private void renderApplianceConfiguration(
      String appRoot, IApplianceConfiguration config, Integer endPointId, PrintWriter pw) {
    if (config == null) return;
    String appliancePid = config.getAppliancePid();
    IAppliance appliance = appliancesProxy.getAppliance(appliancePid);
    if (appliance == null) appliance = appliancesProxy.getInstallingAppliance(appliancePid);

    String name = config.getName(null);
    ICategory category = appliancesProxy.getCategory(config.getCategoryPid(null));
    ILocation location = appliancesProxy.getLocation(config.getLocationPid(null));
    pw.println(
        (appliance.isDriver() ? "<b><u><br/>DRIVER" : "<b><u><br/>VIRTUAL")
            + " APPLIANCE</u>"
            + " (<a href=\""
            + appRoot
            + "/"
            + LABEL
            + "/config/"
            + appliancePid
            + (endPointId != null ? ("/" + endPointId) : "")
            + "\">Reload page</a>"
            + "&nbsp;&nbsp;&nbsp;<a href=\""
            + appRoot
            + "/"
            + LABEL
            + "/"
            + appliancePid
            + "\">Go to appliance details</a>)</br>"
            + "<br/>PID: "
            + appliance.getPid()
            + "<br/>TYPE: "
            + appliance.getDescriptor().getType()
            + ((name != null) ? "<br/>Name: " + name : "")
            + ((category != null) ? "<br/>Category: " + category.getName() : "")
            + ((location != null) ? "<br/>Location: " + location.getName() : "")
            + "</b><br/><hr/>");

    pw.println(
        "<br/><form name=\"ApplianceConfig\""
            + " action=\""
            + appRoot
            + "/"
            + LABEL
            + "/config/"
            + appliancePid
            + (endPointId != null ? ("/" + endPointId) : "")
            + "\" method=\"get\">");
    pw.println("<table id=\"ApplianceConfig\" class=\"nicetable\"><tbody>");
    pw.println("<tr><td width=\"50%\">");
    if (endPointId != null) {
      IEndPoint endPoint = appliance.getEndPoint(endPointId.intValue());
      pw.println(
          "<b>End point configuration (ID: "
              + endPointId
              + ", TYPE: "
              + endPoint.getType()
              + ")</b><br/>");
    } else {
      pw.println("<b>Appliance configuration</b><br/>");
    }
    pw.println("</b></td><td><input type=\"submit\" value=\"update\"/></td></tr>");

    name = config.getName(endPointId);
    String categoryPid = config.getCategoryPid(endPointId);
    String locationPid = config.getLocationPid(endPointId);
    pw.println(
        "<tr><td width=\"50%\">Name: </td><td><input type=\"text\" name=\"param\" size=\"30\" value=\""
            + name
            + "\"/></td></tr>");

    pw.println("</td></tr>");
    String pid = null;
    ICategory[] categories = appliancesProxy.getCategories();
    if (categories != null && categories.length > 0) {
      pw.println("<tr><td width=\"50%\">Category: </td><td><select name=\"param\">");
      for (int i = 0; i < categories.length; i++) {
        pid = categories[i].getPid();
        pw.println(
            "<option value=\""
                + pid
                + (pid.equals(categoryPid) ? "\" selected=\"selected\">" : "\" >")
                + categories[i].getName()
                + "</option>");
      }
      pw.println("</td></tr>");
    }

    ILocation[] locations = appliancesProxy.getLocations();
    if (locations != null && locations.length > 0) {
      pw.println("<tr><td width=\"50%\">Location: </td><td><select name=\"param\">");
      pid = null;
      for (int i = 0; i < locations.length; i++) {
        pid = locations[i].getPid();
        pw.println(
            "<option value=\""
                + pid
                + (pid.equals(locationPid) ? "\" selected=\"selected\">" : "\" >")
                + locations[i].getName()
                + "</option>");
      }
      pw.println("</td></tr>");
    }
    pw.println("</tbody></table></form>");
  }