Beispiel #1
0
  static void writeVariables(XMLWriter writer, java.util.Map<String, String> variables)
      throws java.io.IOException {
    for (java.util.Map.Entry<String, String> p : variables.entrySet()) {
      java.util.List<String[]> attributes = new java.util.LinkedList<String[]>();
      attributes.add(createAttribute("name", p.getKey()));
      attributes.add(createAttribute("value", p.getValue()));

      writer.writeElement("variable", attributes);
    }
  }
Beispiel #2
0
 static void writeLogs(
     XMLWriter writer, String[] logs, java.util.List<PropertyDescriptor> properties)
     throws java.io.IOException {
   for (String log : logs) {
     java.util.List<String[]> attributes = new java.util.LinkedList<String[]>();
     attributes.add(createAttribute("path", log));
     String prop = lookupName(log, properties);
     if (prop != null) {
       attributes.add(createAttribute("property", prop));
     }
     writer.writeElement("log", attributes);
   }
 }
Beispiel #3
0
 static void writeParameters(
     XMLWriter writer,
     java.util.List<String> parameters,
     java.util.Map<String, String> defaultValues)
     throws java.io.IOException {
   for (String p : new java.util.LinkedHashSet<String>(parameters)) {
     String val = defaultValues.get(p);
     java.util.List<String[]> attributes = new java.util.LinkedList<String[]>();
     attributes.add(createAttribute("name", p));
     if (val != null) {
       attributes.add(createAttribute("default", val));
     }
     writer.writeElement("parameter", attributes);
   }
 }
Beispiel #4
0
  static void writeDistribution(XMLWriter writer, DistributionDescriptor descriptor)
      throws java.io.IOException {
    if (descriptor.icepatch.length() > 0) {
      java.util.List<String[]> attributes = new java.util.LinkedList<String[]>();
      attributes.add(createAttribute("icepatch", descriptor.icepatch));

      if (descriptor.directories.isEmpty()) {
        writer.writeElement("distrib", attributes);
      } else {
        writer.writeStartTag("distrib", attributes);
        for (String p : descriptor.directories) {
          writer.writeElement("directory", p);
        }
        writer.writeEndTag("distrib");
      }
    }
  }
Beispiel #5
0
  static void writeObjects(
      String elt,
      XMLWriter writer,
      java.util.List<ObjectDescriptor> objects,
      java.util.List<PropertyDescriptor> properties)
      throws java.io.IOException {
    for (ObjectDescriptor p : objects) {
      java.util.List<String[]> attributes = new java.util.LinkedList<String[]>();
      String strId = Ice.Util.identityToString(p.id);
      attributes.add(createAttribute("identity", strId));
      if (p.type.length() > 0) {
        attributes.add(createAttribute("type", p.type));
      }
      if (properties != null) {
        String prop = lookupName(strId, properties);
        if (prop != null) {
          attributes.add(createAttribute("property", prop));
        }
      }

      writer.writeElement(elt, attributes);
    }
  }
Beispiel #6
0
  static void writePropertySet(
      XMLWriter writer,
      String id,
      String idAttrName,
      PropertySetDescriptor psd,
      java.util.List<AdapterDescriptor> adapters,
      String[] logs)
      throws java.io.IOException {
    if (id.length() == 0 && psd.references.length == 0 && psd.properties.size() == 0) {
      return;
    }

    //
    // We don't show the .Endpoint of adapters,
    // since they already appear in the Adapter descriptors
    //
    java.util.Set<String> hiddenPropertyNames = new java.util.HashSet<String>();
    java.util.Set<String> hiddenPropertyValues = new java.util.HashSet<String>();

    if (adapters != null) {
      for (AdapterDescriptor p : adapters) {
        hiddenPropertyNames.add(p.name + ".Endpoints");

        for (ObjectDescriptor q : p.objects) {
          hiddenPropertyValues.add(Ice.Util.identityToString(q.id));
        }
        for (ObjectDescriptor q : p.allocatables) {
          hiddenPropertyValues.add(Ice.Util.identityToString(q.id));
        }
      }
    }

    if (logs != null) {
      for (String log : logs) {
        hiddenPropertyValues.add(log);
      }
    }

    java.util.List<String[]> attributes = new java.util.LinkedList<String[]>();
    if (id.length() > 0) {
      attributes.add(createAttribute(idAttrName, id));
    }
    if (psd.references.length == 0 && psd.properties.size() == 0) {
      writer.writeElement("properties", attributes);
    } else {
      writer.writeStartTag("properties", attributes);

      for (String ref : psd.references) {
        attributes.clear();
        attributes.add(createAttribute("refid", ref));
        writer.writeElement("properties", attributes);
      }

      for (PropertyDescriptor p : psd.properties) {
        if (hiddenPropertyNames.contains(p.name)) {
          //
          // We hide only the first occurence
          //
          hiddenPropertyNames.remove(p.name);
        } else if (hiddenPropertyValues.contains(p.value)) {
          hiddenPropertyValues.remove(p.value);
        } else {
          attributes.clear();
          attributes.add(createAttribute("name", p.name));
          attributes.add(createAttribute("value", p.value));
          writer.writeElement("property", attributes);
        }
      }
      writer.writeEndTag("properties");
    }
  }
Beispiel #7
0
  public void setProperties(
      java.util.List<PropertyDescriptor> properties,
      java.util.List<AdapterDescriptor> adapters,
      String[] logs,
      Utils.Resolver resolver,
      boolean editable) {
    _editable = editable;

    //
    // We don't show the .Endpoint and .PublishedEndpoints of adapters,
    // since they already appear in the Adapter pages
    //
    java.util.Set<String> hiddenPropertyNames = new java.util.HashSet<String>();

    //
    // We also hide properties whose value match an object or allocatable
    //
    java.util.Set<String> hiddenPropertyValues = new java.util.HashSet<String>();

    _hiddenProperties.clear();

    if (adapters != null) {
      //
      // Note that we don't substitute *on purpose*, i.e. the names or values
      // must match before substitution.
      //
      for (AdapterDescriptor p : adapters) {
        hiddenPropertyNames.add(p.name + ".Endpoints");
        hiddenPropertyNames.add(p.name + ".PublishedEndpoints");
        hiddenPropertyNames.add(p.name + ".ProxyOptions");

        for (ObjectDescriptor q : p.objects) {
          hiddenPropertyValues.add(Ice.Util.identityToString(q.id));
        }
        for (ObjectDescriptor q : p.allocatables) {
          hiddenPropertyValues.add(Ice.Util.identityToString(q.id));
        }
      }
    }

    if (logs != null) {
      for (String log : logs) {
        hiddenPropertyValues.add(log);
      }
    }

    //
    // Transform list into vector of vectors
    //
    java.util.Vector<java.util.Vector<String>> vector =
        new java.util.Vector<java.util.Vector<String>>(properties.size());
    for (PropertyDescriptor p : properties) {
      if (hiddenPropertyNames.contains(p.name)) {
        //
        // We keep them at the top of the list
        //
        if (_editable) {
          _hiddenProperties.add(p);
        }

        //
        // We hide only the first occurence
        //
        hiddenPropertyNames.remove(p.name);
      } else if (hiddenPropertyValues.contains(p.value)) {
        //
        // We keep them at the top of the list
        //
        if (_editable) {
          _hiddenProperties.add(p);
        }

        //
        // We hide only the first occurence
        //
        hiddenPropertyValues.remove(p.value);
      } else {
        java.util.Vector<String> row = new java.util.Vector<String>(2);
        row.add(Utils.substitute(p.name, resolver));
        row.add(Utils.substitute(p.value, resolver));
        vector.add(row);
      }
    }

    if (_editable) {
      java.util.Vector<String> newRow = new java.util.Vector<String>(2);
      newRow.add("");
      newRow.add("");
      vector.add(newRow);
    }

    _model =
        new DefaultTableModel(vector, _columnNames) {
          @Override
          public boolean isCellEditable(int row, int column) {
            return _editable;
          }
        };

    _model.addTableModelListener(
        new TableModelListener() {
          @Override
          public void tableChanged(TableModelEvent e) {
            if (_editable) {
              Object lastKey = _model.getValueAt(_model.getRowCount() - 1, 0);
              if (lastKey != null && !lastKey.equals("")) {
                _model.addRow(new Object[] {"", ""});
              }
              _editor.updated();
            }
          }
        });
    setModel(_model);

    setCellSelectionEnabled(_editable);
    setOpaque(_editable);
    setPreferredScrollableViewportSize(getPreferredSize());

    DefaultTableCellRenderer cr = (DefaultTableCellRenderer) getDefaultRenderer(String.class);
    cr.setOpaque(_editable);
  }