Package org.apache.wicket.markup.html.link

Examples of org.apache.wicket.markup.html.link.ExternalLink


  protected void setupPage(String repositoryName, String pageName) {
    add(new Label("title", getPageTitle(repositoryName)));

    String rootLinkUrl = app().settings().getString(Keys.web.rootLink, urlFor(GitBlitWebApp.get().getHomePage(), null).toString());
    ExternalLink rootLink = new ExternalLink("rootLink", rootLinkUrl);
    WicketUtils.setHtmlTooltip(rootLink, app().settings().getString(Keys.web.siteName, Constants.NAME));
    add(rootLink);

    // Feedback panel for info, warning, and non-fatal error messages
    add(new FeedbackPanel("feedback"));
View Full Code Here


              .newObjectParameter(model.name, entry.getName())));
          fragment.add(new BookmarkablePageLink<Void>("tree", TreePage.class, WicketUtils
              .newObjectParameter(model.name, entry.getName())));
          fragment.add(new BookmarkablePageLink<Void>("metrics", MetricsPage.class,
              WicketUtils.newObjectParameter(model.name, entry.getName())));
          fragment.add(new ExternalLink("syndication", SyndicationServlet.asLink(
              getRequest().getRelativePathPrefixToContextRoot(), model.name,
              entry.getName(), 0)));
          if (showDelete) {
            fragment.add(createDeleteBranchLink(model, entry));
          }
View Full Code Here

    add(new Label("projectTitle", project.getDisplayName()));
    add(new Label("projectDescription", project.description));

    String feedLink = SyndicationServlet.asLink(getRequest().getRelativePathPrefixToContextRoot(), projectName, null, 0);
    add(new ExternalLink("syndication", feedLink));

    add(WicketUtils.syndicationDiscoveryLink(SyndicationServlet.getTitle(project.getDisplayName(),
        null), feedLink));

    // project markdown message
View Full Code Here

                  .newRepositoryParameter(entry.name)));
          row.add(repositoryLinks);
        } else {
          row.add(new Label("repositoryLinks"));
        }
        row.add(new ExternalLink("syndication", SyndicationServlet.asLink(baseUrl,
            entry.name, null, 0)).setVisible(linksActive));
        WicketUtils.setAlternatingBackground(item, counter);
        counter++;
      }
    };
View Full Code Here

        }


        // quick links
        if (entry.isSubmodule()) {
          item.add(new ExternalLink("raw", "").setEnabled(false));

          // submodule
          item.add(new BookmarkablePageLink<Void>("diff", BlobDiffPage.class, WicketUtils
              .newPathParameter(repositoryName, entry.commitId, entry.path))
              .setEnabled(!entry.changeType.equals(ChangeType.ADD)));
          item.add(new BookmarkablePageLink<Void>("view", CommitPage.class, WicketUtils
              .newObjectParameter(submodulePath, entry.objectId)).setEnabled(hasSubmodule));
          item.add(new ExternalLink("blame", "").setEnabled(false));
          item.add(new BookmarkablePageLink<Void>("history", HistoryPage.class, WicketUtils
              .newPathParameter(repositoryName, entry.commitId, entry.path))
              .setEnabled(!entry.changeType.equals(ChangeType.ADD)));
        } else {
          // tree or blob
View Full Code Here

          }

          // quick links
          if (entry.isSubmodule()) {
            // submodule
            item.add(new ExternalLink("patch", "").setEnabled(false));
            item.add(new BookmarkablePageLink<Void>("view", CommitPage.class, WicketUtils
                .newObjectParameter(submodulePath, entry.objectId)).setEnabled(hasSubmodule));
            item.add(new ExternalLink("raw", "").setEnabled(false));
            item.add(new ExternalLink("blame", "").setEnabled(false));
            item.add(new BookmarkablePageLink<Void>("history", HistoryPage.class, WicketUtils
                .newPathParameter(repositoryName, endId, entry.path))
                .setEnabled(!entry.changeType.equals(ChangeType.ADD)));
          } else {
            // tree or blob
View Full Code Here

        }
    }

    private void addHomePageLinkAndApplicationName() {
        // this is a bit hacky, but it'll do...
        ExternalLink homePageLink = new ExternalLink(ID_HOME_PAGE_LINK, "/wicket/");
        homePageLink.setContextRelative(true);
        themeDiv.add(homePageLink);
        homePageLink.add(new Label(ID_APPLICATION_NAME, applicationName));
    }
View Full Code Here

    CharSequence relativeUrl = urlFor(new PackageResourceReference(MailTemplate.class,
      "resource.txt"), null);
    String href = getRequestCycle().getUrlRenderer().renderFullUrl(
      Url.parse(relativeUrl.toString()));
    ExternalLink downloadLink = new ExternalLink("downloadLink", href);
    add(downloadLink);
  }
View Full Code Here

    /*
     * TICKET HEADER
     */
    String href = urlFor(TicketsPage.class, params).toString();
    add(new ExternalLink("ticketNumber", href, "#" + ticket.number));
    Label headerStatus = new Label("headerStatus", ticket.status.toString());
    WicketUtils.setCssClass(headerStatus, TicketsUI.getLozengeClass(ticket.status, false));
    add(headerStatus);
    add(new Label("ticketTitle", ticket.title));
    if (currentPatchset == null) {
      add(new Label("diffstat").setVisible(false));
    } else {
      // calculate the current diffstat of the patchset
      add(new DiffStatPanel("diffstat", ticket.insertions, ticket.deletions));
    }


    /*
     * TAB TITLES
     */
    add(new Label("commentCount", "" + comments.size()).setVisible(!comments.isEmpty()));
    add(new Label("commitCount", "" + (currentPatchset == null ? 0 : currentPatchset.commits)).setVisible(currentPatchset != null));


    /*
     * TICKET AUTHOR and DATE (DISCUSSION TAB)
     */
    UserModel createdBy = app().users().getUserModel(ticket.createdBy);
    if (createdBy == null) {
      add(new Label("whoCreated", ticket.createdBy));
    } else {
      add(new LinkPanel("whoCreated", null, createdBy.getDisplayName(),
          UserPage.class, WicketUtils.newUsernameParameter(createdBy.username)));
    }

    if (ticket.isProposal()) {
      // clearly indicate this is a change ticket
      add(new Label("creationMessage", getString("gb.proposedThisChange")));
    } else {
      // standard ticket
      add(new Label("creationMessage", getString("gb.createdThisTicket")));
    }

    String dateFormat = app().settings().getString(Keys.web.datestampLongFormat, "EEEE, MMMM d, yyyy");
    String timestampFormat = app().settings().getString(Keys.web.datetimestampLongFormat, "EEEE, MMMM d, yyyy");
    final TimeZone timezone = getTimeZone();
    final DateFormat df = new SimpleDateFormat(dateFormat);
    df.setTimeZone(timezone);
    final DateFormat tsf = new SimpleDateFormat(timestampFormat);
    tsf.setTimeZone(timezone);
    final Calendar cal = Calendar.getInstance(timezone);

    String fuzzydate;
    TimeUtils tu = getTimeUtils();
    Date createdDate = ticket.created;
    if (TimeUtils.isToday(createdDate, timezone)) {
      fuzzydate = tu.today();
    } else if (TimeUtils.isYesterday(createdDate, timezone)) {
      fuzzydate = tu.yesterday();
    } else {
      // calculate a fuzzy time ago date
          cal.setTime(createdDate);
          cal.set(Calendar.HOUR_OF_DAY, 0);
          cal.set(Calendar.MINUTE, 0);
          cal.set(Calendar.SECOND, 0);
          cal.set(Calendar.MILLISECOND, 0);
          createdDate = cal.getTime();
      fuzzydate = getTimeUtils().timeAgo(createdDate);
    }
    Label when = new Label("whenCreated", fuzzydate + ", " + df.format(createdDate));
    WicketUtils.setHtmlTooltip(when, tsf.format(ticket.created));
    add(when);

    String exportHref = urlFor(ExportTicketPage.class, params).toString();
    add(new ExternalLink("exportJson", exportHref, "json"));


    /*
     * RESPONSIBLE (DISCUSSION TAB)
     */
    if (StringUtils.isEmpty(ticket.responsible)) {
      add(new Label("responsible"));
    } else {
      UserModel responsible = app().users().getUserModel(ticket.responsible);
      if (responsible == null) {
        add(new Label("responsible", ticket.responsible));
      } else {
        add(new LinkPanel("responsible", null, responsible.getDisplayName(),
            UserPage.class, WicketUtils.newUsernameParameter(responsible.username)));
      }
    }

    /*
     * MILESTONE PROGRESS (DISCUSSION TAB)
     */
    if (StringUtils.isEmpty(ticket.milestone)) {
      add(new Label("milestone"));
    } else {
      // link to milestone query
      TicketMilestone tm = app().tickets().getMilestone(repository, ticket.milestone);
      if (tm == null) {
        tm = new TicketMilestone(ticket.milestone);
      }
      PageParameters milestoneParameters;
      if (tm.isOpen()) {
        milestoneParameters = WicketUtils.newOpenTicketsParameter(repositoryName);
      } else {
        milestoneParameters = WicketUtils.newRepositoryParameter(repositoryName);
      }
      milestoneParameters.put(Lucene.milestone.name(), ticket.milestone);
      int progress = 0;
      int open = 0;
      int closed = 0;
      if (tm != null) {
        progress = tm.getProgress();
        open = tm.getOpenTickets();
        closed = tm.getClosedTickets();
      }

      Fragment milestoneProgress = new Fragment("milestone", "milestoneProgressFragment", this);
      milestoneProgress.add(new LinkPanel("link", null, ticket.milestone, TicketsPage.class, milestoneParameters));
      Label label = new Label("progress");
      WicketUtils.setCssStyle(label, "width:" + progress + "%;");
      milestoneProgress.add(label);
      WicketUtils.setHtmlTooltip(milestoneProgress, MessageFormat.format(getString("gb.milestoneProgress"), open, closed));
      add(milestoneProgress);
    }


    /*
     * TICKET DESCRIPTION (DISCUSSION TAB)
     */
    String desc;
    if (StringUtils.isEmpty(ticket.body)) {
      desc = getString("gb.noDescriptionGiven");
    } else {
      String bugtraq = bugtraqProcessor().processText(getRepository(), repositoryName, ticket.body);
      String html = MarkdownUtils.transformGFM(app().settings(), bugtraq, ticket.repository);
      String safeHtml = app().xssFilter().relaxed(html);
      desc = safeHtml;
    }
    add(new Label("ticketDescription", desc).setEscapeModelStrings(false));


    /*
     * PARTICIPANTS (DISCUSSION TAB)
     */
    if (app().settings().getBoolean(Keys.web.allowGravatar, true)) {
      // gravatar allowed
      List<String> participants = ticket.getParticipants();
      add(new Label("participantsLabel", MessageFormat.format(getString(participants.size() > 1 ? "gb.nParticipants" : "gb.oneParticipant"),
          "<b>" + participants.size() + "</b>")).setEscapeModelStrings(false));
      ListDataProvider<String> participantsDp = new ListDataProvider<String>(participants);
      DataView<String> participantsView = new DataView<String>("participants", participantsDp) {
        private static final long serialVersionUID = 1L;

        @Override
        public void populateItem(final Item<String> item) {
          String username = item.getModelObject();
          UserModel user = app().users().getUserModel(username);
          if (user == null) {
            user = new UserModel(username);
          }
          item.add(new GravatarImage("participant", user.getDisplayName(),
              user.emailAddress, null, 25, true));
        }
      };
      add(participantsView);
    } else {
      // gravatar prohibited
      add(new Label("participantsLabel").setVisible(false));
      add(new Label("participants").setVisible(false));
    }


    /*
     * LARGE STATUS INDICATOR WITH ICON (DISCUSSION TAB->SIDE BAR)
     */
    Fragment ticketStatus = new Fragment("ticketStatus", "ticketStatusFragment", this);
    Label ticketIcon = TicketsUI.getStateIcon("ticketIcon", ticket);
    ticketStatus.add(ticketIcon);
    ticketStatus.add(new Label("ticketStatus", ticket.status.toString()));
    WicketUtils.setCssClass(ticketStatus, TicketsUI.getLozengeClass(ticket.status, false));
    add(ticketStatus);


    /*
     * UPDATE FORM (DISCUSSION TAB)
     */
    if (user.canEdit(ticket, repository) && app().tickets().isAcceptingTicketUpdates(repository)) {
      if (user.canAdmin(ticket, repository) && ticket.isOpen()) {
        /*
         * OPEN TICKET
         */
        Fragment controls = new Fragment("controls", "openControlsFragment", this);

        /*
         * STATUS
         */
        List<Status> choices = new ArrayList<Status>();
        if (ticket.isProposal()) {
          choices.addAll(Arrays.asList(TicketModel.Status.proposalWorkflow));
        } else if (ticket.isBug()) {
          choices.addAll(Arrays.asList(TicketModel.Status.bugWorkflow));
        } else {
          choices.addAll(Arrays.asList(TicketModel.Status.requestWorkflow));
        }
        choices.remove(ticket.status);

        ListDataProvider<Status> workflowDp = new ListDataProvider<Status>(choices);
        DataView<Status> statusView = new DataView<Status>("newStatus", workflowDp) {
          private static final long serialVersionUID = 1L;

          @Override
          public void populateItem(final Item<Status> item) {
            SimpleAjaxLink<Status> link = new SimpleAjaxLink<Status>("link", item.getModel()) {

              private static final long serialVersionUID = 1L;

              @Override
              public void onClick(AjaxRequestTarget target) {
                Status status = getModel().getObject();
                Change change = new Change(user.username);
                change.setField(Field.status, status);
                if (!ticket.isWatching(user.username)) {
                  change.watch(user.username);
                }
                TicketModel update = app().tickets().updateTicket(repository, ticket.number, change);
                app().tickets().createNotifier().sendMailing(update);
                setResponsePage(TicketsPage.class, getPageParameters());
              }
            };
            String css = TicketsUI.getStatusClass(item.getModel().getObject());
            WicketUtils.setCssClass(link, css);
            item.add(link);
          }
        };
        controls.add(statusView);

        /*
         * RESPONSIBLE LIST
         */
        Set<String> userlist = new TreeSet<String>(ticket.getParticipants());
        if (UserModel.ANONYMOUS.canPush(getRepositoryModel())
            || AuthorizationControl.AUTHENTICATED == getRepositoryModel().authorizationControl) {
          //   authorization is ANONYMOUS or AUTHENTICATED (i.e. all users can be set responsible)
          userlist.addAll(app().users().getAllUsernames());
        } else {
          // authorization is by NAMED users (users with PUSH permission can be set responsible)
          for (RegistrantAccessPermission rp : app().repositories().getUserAccessPermissions(getRepositoryModel())) {
            if (rp.permission.atLeast(AccessPermission.PUSH)) {
              userlist.add(rp.registrant);
            }
          }
        }
        List<TicketResponsible> responsibles = new ArrayList<TicketResponsible>();
        if (!StringUtils.isEmpty(ticket.responsible)) {
          // exclude the current responsible
          userlist.remove(ticket.responsible);
        }
        for (String username : userlist) {
          UserModel u = app().users().getUserModel(username);
          if (u != null) {
            responsibles.add(new TicketResponsible(u));
          }
        }
        Collections.sort(responsibles);
        responsibles.add(new TicketResponsible(ESC_NIL, "", ""));
        ListDataProvider<TicketResponsible> responsibleDp = new ListDataProvider<TicketResponsible>(responsibles);
        DataView<TicketResponsible> responsibleView = new DataView<TicketResponsible>("newResponsible", responsibleDp) {
          private static final long serialVersionUID = 1L;

          @Override
          public void populateItem(final Item<TicketResponsible> item) {
            SimpleAjaxLink<TicketResponsible> link = new SimpleAjaxLink<TicketResponsible>("link", item.getModel()) {

              private static final long serialVersionUID = 1L;

              @Override
              public void onClick(AjaxRequestTarget target) {
                TicketResponsible responsible = getModel().getObject();
                Change change = new Change(user.username);
                change.setField(Field.responsible, responsible.username);
                if (!StringUtils.isEmpty(responsible.username)) {
                  if (!ticket.isWatching(responsible.username)) {
                    change.watch(responsible.username);
                  }
                }
                if (!ticket.isWatching(user.username)) {
                  change.watch(user.username);
                }
                TicketModel update = app().tickets().updateTicket(repository, ticket.number, change);
                app().tickets().createNotifier().sendMailing(update);
                setResponsePage(TicketsPage.class, getPageParameters());
              }
            };
            item.add(link);
          }
        };
        controls.add(responsibleView);

        /*
         * MILESTONE LIST
         */
        List<TicketMilestone> milestones = app().tickets().getMilestones(repository, Status.Open);
        if (!StringUtils.isEmpty(ticket.milestone)) {
          for (TicketMilestone milestone : milestones) {
            if (milestone.name.equals(ticket.milestone)) {
              milestones.remove(milestone);
              break;
            }
          }
        }
        milestones.add(new TicketMilestone(ESC_NIL));
        ListDataProvider<TicketMilestone> milestoneDp = new ListDataProvider<TicketMilestone>(milestones);
        DataView<TicketMilestone> milestoneView = new DataView<TicketMilestone>("newMilestone", milestoneDp) {
          private static final long serialVersionUID = 1L;

          @Override
          public void populateItem(final Item<TicketMilestone> item) {
            SimpleAjaxLink<TicketMilestone> link = new SimpleAjaxLink<TicketMilestone>("link", item.getModel()) {

              private static final long serialVersionUID = 1L;

              @Override
              public void onClick(AjaxRequestTarget target) {
                TicketMilestone milestone = getModel().getObject();
                Change change = new Change(user.username);
                if (NIL.equals(milestone.name) || ESC_NIL.equals(milestone.name)) {
                  change.setField(Field.milestone, "");
                } else {
                  change.setField(Field.milestone, milestone.name);
                }
                if (!ticket.isWatching(user.username)) {
                  change.watch(user.username);
                }
                TicketModel update = app().tickets().updateTicket(repository, ticket.number, change);
                app().tickets().createNotifier().sendMailing(update);
                setResponsePage(TicketsPage.class, getPageParameters());
              }
            };
            item.add(link);
          }
        };
        controls.add(milestoneView);

        String editHref = urlFor(EditTicketPage.class, params).toString();
        controls.add(new ExternalLink("editLink", editHref, getString("gb.edit")));

        add(controls);
      } else {
        /*
         * CLOSED TICKET
         */
        Fragment controls = new Fragment("controls", "closedControlsFragment", this);

        String editHref = urlFor(EditTicketPage.class, params).toString();
        controls.add(new ExternalLink("editLink", editHref, getString("gb.edit")));

        add(controls);
      }
    } else {
      add(new Label("controls").setVisible(false));
View Full Code Here

    // set the id attribute
    if (entry.hasComment()) {
      container.setOutputMarkupId(true);
      container.add(new AttributeModifier("id", Model.of(entry.getId())));
      ExternalLink link = new ExternalLink("changeLink", "#" + entry.getId());
      container.add(link);
    } else {
      container.add(new Label("changeLink").setVisible(false));
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.wicket.markup.html.link.ExternalLink

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.