Example #1
0
  public void layout() {
    super.layout();

    add(CSSPackageResource.getHeaderContribution(getClass(), "change.css"));

    Project project = getProject();
    String id = getPageParameters().getString("id");

    if (project == null) {
      notFoundError();
      return;
    }

    String prefix = "";
    Project root = getProject();
    File searchDir = getStorage().getWorkingDirectory(getProject());
    while (root.getParent() != null) {
      prefix = searchDir.getName() + File.separatorChar + prefix;
      root = root.getParent();
      searchDir = searchDir.getParentFile();
    }
    final String stripPrefix = prefix;

    ChangeSet changeSet = Manager.getInstance().getScmService().getChangeSet(root, id);
    if (changeSet == null) {
      notFoundError();
      return;
    }

    revision = changeSet.getId();
    ((HibernateRequestCycle) getRequestCycle()).getHibernateSession().refresh(changeSet);

    if (changeSet.getPrevious() != null) {
      PageParameters params = getProjectPageParameters();
      params.add("id", changeSet.getPrevious().getId());

      addLink(new BookmarkableMenuLink(getClass(), params, "\u25c0 previous changeset"));
    }
    if (changeSet.getNext() != null) {
      PageParameters params = getProjectPageParameters();
      params.add("id", changeSet.getNext().getId());

      addLink(new BookmarkableMenuLink(getClass(), params, "\u25ba next changeset"));
    }

    add(new ChangeSetPanel("changeset", changeSet, stripPrefix));
  }
  public static List<ScmChange> getChanges(Project project, String path) {
    Session session = ((HibernateStorage) Manager.getStorageInstance()).getHibernateSession();

    String prefix = "";
    java.io.File searchDir = Manager.getStorageInstance().getWorkingDirectory(project);
    while (project.getParent() != null) {
      prefix = searchDir.getName() + java.io.File.separatorChar + prefix;
      project = project.getParent();
      searchDir = searchDir.getParentFile();
    }

    Query q =
        session.createQuery(
            "from ScmChange c where c.set.id.project = :project and name = :path order by c.set.date desc");
    q.setEntity("project", project);
    q.setString("path", prefix + path);

    return q.list();
  }