コード例 #1
0
  /**
   * Writes the location of the views of the known {@link Note}s.
   *
   * @param element the xml-element to write into, the attributes of <code>element</code> will not
   *     be changed
   */
  public void writeXML(XElement element) throws IOException {
    PropertyTransformer transformer = new PropertyTransformer();

    for (Map.Entry<Note, Tuple<DockStation, DockableProperty>> location : locations.entrySet()) {
      XElement xnote = element.addElement("note");
      xnote.addString("id", location.getKey().getId());
      xnote.addString("station", manager.getName(location.getValue().getA()));
      transformer.writeXML(location.getValue().getB(), xnote);
    }
  }
コード例 #2
0
  /**
   * Reads the location of the views of all known <code>Note</code>s.
   *
   * @param element the xml-element to read from
   */
  public void readXML(XElement element) {
    PropertyTransformer transformer = new PropertyTransformer();

    for (XElement xnote : element.getElements("note")) {
      Note note = model.getNote(xnote.getString("id"));
      DockStation station = manager.getStation(xnote.getString("station"));
      DockableProperty property = transformer.readXML(xnote);
      if (note != null) {
        locations.put(note, new Tuple<DockStation, DockableProperty>(station, property));
      }
    }
  }
コード例 #3
0
  public <B> void write(XElement element, ModeSettingsConverter<Location, B> converter) {
    Set<String> keys = new HashSet<String>();
    if (lastMaximizedLocation != null) {
      keys.addAll(lastMaximizedLocation.keySet());
    }
    if (lastMaximizedMode != null) {
      keys.addAll(lastMaximizedMode.keySet());
    }

    if (!keys.isEmpty()) {
      XElement xmaximized = element.addElement("maximized");

      for (String key : keys) {
        Path mode = lastMaximizedMode.get(key);
        Location location = lastMaximizedLocation.get(key);

        if (mode != null || location != null) {
          XElement xitem = xmaximized.addElement("item");
          xitem.addString("id", key);
          if (mode != null) {
            xitem.addElement("mode").setString(mode.toString());
          }
          if (location != null) {
            converter.writePropertyXML(
                converter.convertToSetting(location), xitem.addElement("location"));
          }
        }
      }
    }
  }
コード例 #4
0
  public <B> void read(XElement element, ModeSettingsConverter<Location, B> converter) {
    lastMaximizedLocation = new HashMap<String, Location>();
    lastMaximizedMode = new HashMap<String, Path>();

    XElement xmaximized = element.getElement("maximized");

    if (xmaximized != null) {
      for (XElement xitem : xmaximized.getElements("item")) {
        String key = xitem.getString("id");

        XElement xmode = xitem.getElement("mode");
        if (xmode != null) {
          lastMaximizedMode.put(key, new Path(xmode.getString()));
        }

        XElement xlocation = xitem.getElement("location");
        if (xlocation != null) {
          lastMaximizedLocation.put(
              key, converter.convertToWorld(converter.readPropertyXML(xlocation)));
        }
      }
    }
  }
コード例 #5
0
 public void writeXML(XElement element) {
   element.addElement("name").setString(fileName);
   element.addElement("content").setString(fileContent);
   element.addElement("background").setInt(background.getRGB());
 }
コード例 #6
0
 public void readXML(XElement element) {
   fileName = element.getElement("name").getString();
   fileContent = element.getElement("content").getString();
   background = new Color(element.getElement("background").getInt());
 }
コード例 #7
0
 public void writeXML(XElement element) {
   element.setInt(color.getRGB());
 }
コード例 #8
0
 public void readXML(XElement element) {
   color = new Color(element.getInt());
 }