コード例 #1
0
ファイル: URLSerializer.java プロジェクト: seanws/tagsea
  private static void restoreStateFromMemento(IMemento memento) {
    IMemento[] urlMementos = memento.getChildren(URL_WAYPOINT);

    for (IMemento urlMemento : urlMementos) {
      String urlString = urlMemento.getString(URL_ATTRIBUTE);

      String author = urlMemento.getString(AUTHOR_ATTRIBUTE);
      String dateString = urlMemento.getString(DATE_ATTRIBUTE);
      String description = urlMemento.getString(DESCRIPTION_ATTRIBUTE);

      String[] tagNames = getTagNames(urlMemento);

      Date date = null;

      if (dateString != null) {
        try {
          date = SimpleDateFormat.getInstance().parse(dateString);
        } catch (ParseException e) {
          e.printStackTrace();
        }
      }

      IWaypoint waypoint =
          TagSEAPlugin.getWaypointsModel()
              .createWaypoint(URLWaypointPlugin.WAYPOINT_ID, new String[0]);

      for (String tagName : tagNames) {
        waypoint.addTag(tagName);
      }

      waypoint.setAuthor(author);
      waypoint.setDate(date);
      waypoint.setText(description);
      waypoint.setStringValue(URLWaypointUtil.URL_ATTR, urlString);
    }
  }