Пример #1
0
  private static void writeMemento(IMemento memento) {
    IWaypoint[] waypoints =
        TagSEAPlugin.getWaypointsModel().getWaypoints(URLWaypointPlugin.WAYPOINT_ID);

    for (IWaypoint waypoint : waypoints) {
      IMemento waypointMemento = memento.createChild(URL_WAYPOINT);

      waypointMemento.putString(
          URL_ATTRIBUTE, waypoint.getStringValue(URLWaypointUtil.URL_ATTR, ""));
      waypointMemento.putString(AUTHOR_ATTRIBUTE, waypoint.getAuthor());

      if (waypoint.getDate() != null) {
        SimpleDateFormat format = new SimpleDateFormat();
        String dateString = format.format(waypoint.getDate());
        waypointMemento.putString(DATE_ATTRIBUTE, dateString);
      }

      waypointMemento.putString(DESCRIPTION_ATTRIBUTE, waypoint.getText());

      ITag[] tags = waypoint.getTags();

      for (ITag tag : tags) {
        IMemento tagMemento = waypointMemento.createChild(TAG);
        tagMemento.putString(NAME_ATTRIBUTE, tag.getName());
      }
    }
  }