Package com.gitblit.models

Examples of com.gitblit.models.PathModel$PathChangeModel


          String pattern = "<tr><td><a href=\"{0}/{1}\">{1}</a></td><td>{2}</td><td>{3}</td></tr>";
          final ByteFormat byteFormat = new ByteFormat();
          if (!pathEntries.isEmpty()) {
            if (pathEntries.get(0).path.indexOf('/') > -1) {
              // we are in a subdirectory, add parent directory link
              pathEntries.add(0, new PathModel("..", resource + "/..", 0, FileMode.TREE.getBits(), null, null));
            }
          }

          String basePath = request.getServletPath() + request.getPathInfo();
          if (basePath.charAt(basePath.length() - 1) == '/') {
View Full Code Here


      private static final long serialVersionUID = 1L;
      int counter;

      @Override
      public void populateItem(final Item<PathModel> item) {
        PathModel entry = item.getModelObject();
        item.add(WicketUtils.newImage("docIcon", "file_world_16x16.png"));
        item.add(new Label("docSize", byteFormat.format(entry.size)));
        item.add(new LinkPanel("docName", "list", StringUtils.stripFileExtension(entry.name),
            DocPage.class, WicketUtils.newPathParameter(repositoryName, id, entry.path)));
View Full Code Here

    if (itemsPerPage <= 1) {
      itemsPerPage = 50;
    }

    RevCommit commit = JGitUtils.getCommit(r, objectId);
    PathModel matchingPath = null;
    Map<String, SubmoduleModel> submodules = new HashMap<String, SubmoduleModel>();

    if (commit == null) {
      // commit missing
      String msg = MessageFormat.format("Failed to find history of **{0}** *{1}*",
          path, objectId);
      log.error(msg + " " + repositoryName);
      add(new Label("commitHeader", MarkdownUtils.transformMarkdown(msg)).setEscapeModelStrings(false));
      add(new Label("breadcrumbs"));
    } else {
      // commit found
      List<PathChangeModel> paths = JGitUtils.getFilesInCommit(r, commit);
      add(new CommitHeaderPanel("commitHeader", repositoryName, commit));
      add(new PathBreadcrumbsPanel("breadcrumbs", repositoryName, path, objectId));
      for (SubmoduleModel model : JGitUtils.getSubmodules(r, commit.getTree())) {
        submodules.put(model.path, model);
      }

      for (PathModel p : paths) {
        if (p.path.equals(path)) {
          matchingPath = p;
          break;
        }
      }
      if (matchingPath == null) {
        // path not in commit
        // manually locate path in tree
        TreeWalk tw = new TreeWalk(r);
        tw.reset();
        tw.setRecursive(true);
        try {
          tw.addTree(commit.getTree());
          tw.setFilter(PathFilterGroup.createFromStrings(Collections.singleton(path)));
          while (tw.next()) {
            if (tw.getPathString().equals(path)) {
              matchingPath = new PathChangeModel(tw.getPathString(), tw.getPathString(), 0, tw
                .getRawMode(0), tw.getObjectId(0).getName(), commit.getId().getName(),
                ChangeType.MODIFY);
            }
          }
        } catch (Exception e) {
        } finally {
          tw.release();
        }
      }
    }

    final boolean isTree = matchingPath == null ? true : matchingPath.isTree();
    final boolean isSubmodule = matchingPath == null ? false : matchingPath.isSubmodule();

    // submodule
    final String submodulePath;
    final boolean hasSubmodule;
    if (isSubmodule) {
View Full Code Here

      // add .. parent path entry
      String parentPath = null;
      if (path.lastIndexOf('/') > -1) {
        parentPath = path.substring(0, path.lastIndexOf('/'));
      }
      PathModel model = new PathModel("..", parentPath, 0, FileMode.TREE.getBits(), null, objectId);
      model.isParentPath = true;
      paths.add(0, model);
    }

    final String id = getBestCommitId(commit);
    final ByteFormat byteFormat = new ByteFormat();
    final String baseUrl = WicketUtils.getGitblitURL(getRequest());

    // changed paths list
    ListDataProvider<PathModel> pathsDp = new ListDataProvider<PathModel>(paths);
    DataView<PathModel> pathsView = new DataView<PathModel>("changedPath", pathsDp) {
      private static final long serialVersionUID = 1L;
      int counter;

      @Override
      public void populateItem(final Item<PathModel> item) {
        PathModel entry = item.getModelObject();
        item.add(new Label("pathPermissions", JGitUtils.getPermissionsFromMode(entry.mode)));
        if (entry.isParentPath) {
          // parent .. path
          item.add(WicketUtils.newBlankImage("pathIcon"));
          item.add(new Label("pathSize", ""));
          item.add(new LinkPanel("pathName", null, entry.name, TreePage.class,
              WicketUtils
                  .newPathParameter(repositoryName, id, entry.path)));
          item.add(new Label("pathLinks", ""));
        } else {
          if (entry.isTree()) {
            // folder/tree link
            item.add(WicketUtils.newImage("pathIcon", "folder_16x16.png"));
            item.add(new Label("pathSize", ""));
            item.add(new LinkPanel("pathName", "list", entry.name, TreePage.class,
                WicketUtils.newPathParameter(repositoryName, id,
                    entry.path)));

            // links
            Fragment links = new Fragment("pathLinks", "treeLinks", this);
            links.add(new BookmarkablePageLink<Void>("tree", TreePage.class,
                WicketUtils.newPathParameter(repositoryName, id,
                    entry.path)));
            links.add(new BookmarkablePageLink<Void>("history", HistoryPage.class,
                WicketUtils.newPathParameter(repositoryName, id,
                    entry.path)));
            links.add(new CompressedDownloadsPanel("compressedLinks", baseUrl,
                repositoryName, objectId, entry.path));

            item.add(links);
          } else if (entry.isSubmodule()) {
            // submodule
            String submoduleId = entry.objectId;
            String submodulePath;
            boolean hasSubmodule = false;
            SubmoduleModel submodule = getSubmodule(entry.path);
            submodulePath = submodule.gitblitPath;
            hasSubmodule = submodule.hasSubmodule;

            item.add(WicketUtils.newImage("pathIcon", "git-orange-16x16.png"));
            item.add(new Label("pathSize", ""));
            item.add(new LinkPanel("pathName", "list", entry.name + " @ " +
                getShortObjectId(submoduleId), TreePage.class,
                WicketUtils.newPathParameter(submodulePath, submoduleId, "")).setEnabled(hasSubmodule));

            Fragment links = new Fragment("pathLinks", "submoduleLinks", this);
            links.add(new BookmarkablePageLink<Void>("view", SummaryPage.class,
                WicketUtils.newRepositoryParameter(submodulePath)).setEnabled(hasSubmodule));
            links.add(new BookmarkablePageLink<Void>("tree", TreePage.class,
                WicketUtils.newPathParameter(submodulePath, submoduleId,
                    "")).setEnabled(hasSubmodule));
            links.add(new BookmarkablePageLink<Void>("history", HistoryPage.class,
                WicketUtils.newPathParameter(repositoryName, id,
                    entry.path)));
            links.add(new CompressedDownloadsPanel("compressedLinks", baseUrl,
                submodulePath, submoduleId, "").setEnabled(hasSubmodule));
            item.add(links);
          } else {
            // blob link
            String displayPath = entry.name;
            String path = entry.path;
            if (entry.isSymlink()) {
              path = JGitUtils.getStringContent(getRepository(), getCommit().getTree(), path);
              displayPath = entry.name + " -> " + path;
            }
            item.add(WicketUtils.getFileImage("pathIcon", entry.name));
            item.add(new Label("pathSize", byteFormat.format(entry.size)));
View Full Code Here

    String format = app().settings().getString(Keys.web.datetimestampLongFormat,
        "EEEE, MMMM d, yyyy HH:mm Z");
    final DateFormat df = new SimpleDateFormat(format);
    df.setTimeZone(getTimeZone());

    PathModel pathModel = null;
    List<PathModel> paths = JGitUtils.getFilesInPath(getRepository(), StringUtils.getRootPath(blobPath), commit);
    for (PathModel path : paths) {
      if (path.path.equals(blobPath)) {
        pathModel = path;
        break;
View Full Code Here

        size = tw.getObjectReader().getObjectSize(objectId, Constants.OBJ_BLOB);
      }
    } catch (Throwable t) {
      error(t, null, "failed to retrieve blob size for " + tw.getPathString());
    }
    return new PathModel(name, tw.getPathString(), size, tw.getFileMode(0).getBits(),
        objectId.getName(), commit.getName());
  }
View Full Code Here

        final ByteFormat byteFormat = new ByteFormat();
        if (!pathEntries.isEmpty()) {
          if (pathEntries.get(0).path.indexOf('/') > -1) {
            // we are in a subdirectory, add parent directory link
            String pp = URLEncoder.encode(requestedPath, Constants.ENCODING);
            pathEntries.add(0, new PathModel("..", pp + "/..", 0, FileMode.TREE.getBits(), null, null));
          }
        }

        String basePath = request.getServletPath() + request.getPathInfo();
        if (basePath.charAt(basePath.length() - 1) == '/') {
View Full Code Here

      private static final long serialVersionUID = 1L;
      int counter;

      @Override
      public void populateItem(final Item<PathModel> item) {
        PathModel entry = item.getModelObject();
        item.add(WicketUtils.newImage("docIcon", "file_world_16x16.png"));
        item.add(new Label("docSize", byteFormat.format(entry.size)));
        item.add(new LinkPanel("docName", "list", StringUtils.stripFileExtension(entry.name),
            DocPage.class, WicketUtils.newPathParameter(repositoryName, commitId, entry.path)));
View Full Code Here

      // add .. parent path entry
      String parentPath = null;
      if (path.lastIndexOf('/') > -1) {
        parentPath = path.substring(0, path.lastIndexOf('/'));
      }
      PathModel model = new PathModel("..", parentPath, 0, FileMode.TREE.getBits(), null, objectId);
      model.isParentPath = true;
      paths.add(0, model);
    }

    final String id = getBestCommitId(commit);
    final ByteFormat byteFormat = new ByteFormat();
    final String baseUrl = WicketUtils.getGitblitURL(getRequest());

    // changed paths list
    ListDataProvider<PathModel> pathsDp = new ListDataProvider<PathModel>(paths);
    DataView<PathModel> pathsView = new DataView<PathModel>("changedPath", pathsDp) {
      private static final long serialVersionUID = 1L;
      int counter;

      @Override
      public void populateItem(final Item<PathModel> item) {
        PathModel entry = item.getModelObject();
        item.add(new Label("pathPermissions", JGitUtils.getPermissionsFromMode(entry.mode)));
        if (entry.isParentPath) {
          // parent .. path
          item.add(WicketUtils.newBlankImage("pathIcon"));
          item.add(new Label("pathSize", ""));
          item.add(new LinkPanel("pathName", null, entry.name, TreePage.class,
              WicketUtils
                  .newPathParameter(repositoryName, id, entry.path)));
          item.add(new Label("pathLinks", ""));
        } else {
          if (entry.isTree()) {
            // folder/tree link
            item.add(WicketUtils.newImage("pathIcon", "folder_16x16.png"));
            item.add(new Label("pathSize", ""));
            item.add(new LinkPanel("pathName", "list", entry.name, TreePage.class,
                WicketUtils.newPathParameter(repositoryName, id,
                    entry.path)));

            // links
            Fragment links = new Fragment("pathLinks", "treeLinks", this);
            links.add(new BookmarkablePageLink<Void>("tree", TreePage.class,
                WicketUtils.newPathParameter(repositoryName, id,
                    entry.path)));
            links.add(new BookmarkablePageLink<Void>("history", HistoryPage.class,
                WicketUtils.newPathParameter(repositoryName, id,
                    entry.path)));
            links.add(new CompressedDownloadsPanel("compressedLinks", baseUrl,
                repositoryName, objectId, entry.path));

            item.add(links);
          } else if (entry.isSubmodule()) {
            // submodule
            String submoduleId = entry.objectId;
            String submodulePath;
            boolean hasSubmodule = false;
            SubmoduleModel submodule = getSubmodule(entry.path);
            submodulePath = submodule.gitblitPath;
            hasSubmodule = submodule.hasSubmodule;

            item.add(WicketUtils.newImage("pathIcon", "git-orange-16x16.png"));
            item.add(new Label("pathSize", ""));
            item.add(new LinkPanel("pathName", "list", entry.name + " @ " +
                getShortObjectId(submoduleId), TreePage.class,
                WicketUtils.newPathParameter(submodulePath, submoduleId, "")).setEnabled(hasSubmodule));

            Fragment links = new Fragment("pathLinks", "submoduleLinks", this);
            links.add(new BookmarkablePageLink<Void>("view", SummaryPage.class,
                WicketUtils.newRepositoryParameter(submodulePath)).setEnabled(hasSubmodule));
            links.add(new BookmarkablePageLink<Void>("tree", TreePage.class,
                WicketUtils.newPathParameter(submodulePath, submoduleId,
                    "")).setEnabled(hasSubmodule));
            links.add(new BookmarkablePageLink<Void>("history", HistoryPage.class,
                WicketUtils.newPathParameter(repositoryName, id,
                    entry.path)));
            links.add(new CompressedDownloadsPanel("compressedLinks", baseUrl,
                submodulePath, submoduleId, "").setEnabled(hasSubmodule));
            item.add(links);
          } else {
            // blob link
            String displayPath = entry.name;
            String path = entry.path;
            if (entry.isSymlink()) {
              path = JGitUtils.getStringContent(getRepository(), getCommit().getTree(), path);
              displayPath = entry.name + " -> " + path;
            }
            item.add(WicketUtils.getFileImage("pathIcon", entry.name));
            item.add(new Label("pathSize", byteFormat.format(entry.size)));
View Full Code Here

    if (itemsPerPage <= 1) {
      itemsPerPage = 50;
    }

    RevCommit commit = JGitUtils.getCommit(r, objectId);
    PathModel matchingPath = null;
    Map<String, SubmoduleModel> submodules = new HashMap<String, SubmoduleModel>();

    if (commit == null) {
      // commit missing
      String msg = MessageFormat.format("Failed to find history of **{0}** *{1}*",
          path, objectId);
      logger().error(msg + " " + repositoryName);
      add(new Label("commitHeader", MarkdownUtils.transformMarkdown(msg)).setEscapeModelStrings(false));
      add(new Label("breadcrumbs"));
    } else {
      // commit found
      List<PathChangeModel> paths = JGitUtils.getFilesInCommit(r, commit);
      add(new CommitHeaderPanel("commitHeader", repositoryName, commit));
      add(new PathBreadcrumbsPanel("breadcrumbs", repositoryName, path, objectId));
      for (SubmoduleModel model : JGitUtils.getSubmodules(r, commit.getTree())) {
        submodules.put(model.path, model);
      }

      for (PathModel p : paths) {
        if (p.path.equals(path)) {
          matchingPath = p;
          break;
        }
      }
      if (matchingPath == null) {
        // path not in commit
        // manually locate path in tree
        TreeWalk tw = new TreeWalk(r);
        tw.reset();
        tw.setRecursive(true);
        try {
          tw.addTree(commit.getTree());
          tw.setFilter(PathFilterGroup.createFromStrings(Collections.singleton(path)));
          while (tw.next()) {
            if (tw.getPathString().equals(path)) {
              matchingPath = new PathChangeModel(tw.getPathString(), tw.getPathString(), 0, tw
                .getRawMode(0), tw.getObjectId(0).getName(), commit.getId().getName(),
                ChangeType.MODIFY);
            }
          }
        } catch (Exception e) {
        } finally {
          tw.release();
        }
      }
    }

    final boolean isTree = matchingPath == null ? true : matchingPath.isTree();
    final boolean isSubmodule = matchingPath == null ? false : matchingPath.isSubmodule();

    // submodule
    final String submodulePath;
    final boolean hasSubmodule;
    if (isSubmodule) {
View Full Code Here

TOP

Related Classes of com.gitblit.models.PathModel$PathChangeModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.