public static <ACTION extends Action> ACTION findActionByUrlEndsWith(
     Actionable b, Class<ACTION> type, String suffix) {
   ACTION ret = null;
   for (Action a : b.getActions()) {
     if (type.isInstance(a) && a.getUrlName().endsWith(suffix)) {
       ret = type.cast(a);
     }
     // ProjectSummaryAction だけの特別処理。
     else if (a instanceof ProjectSummaryAction) {
       if (a.getUrlName().endsWith("null")) {
         ret = type.cast(a);
       }
     }
   }
   return ret;
 }
Beispiel #2
0
  protected void addTransientActionsFromBuild(
      MavenModuleSetBuild build, List<Action> collection, Set<Class> added) {
    if (build == null) return;

    for (Action a : build.getActions())
      if (a instanceof MavenAggregatedReport)
        if (added.add(a.getClass()))
          collection.add(((MavenAggregatedReport) a).getProjectAction(this));

    List<MavenReporter> list = build.projectActionReporters;
    if (list == null) return;

    for (MavenReporter step : list) {
      if (!added.add(step.getClass())) continue; // already added
      Action a = step.getAggregatedProjectAction(this);
      if (a != null) collection.add(a);
    }
  }
Beispiel #3
0
  /**
   * Computes the hyperlink to actions, to handle the situation when the {@link Action#getUrlName()}
   * returns absolute URL.
   */
  public static String getActionUrl(String itUrl, Action action) {
    String urlName = action.getUrlName();
    if (urlName == null) return null; // to avoid NPE and fail to render the whole page

    if (SCHEME.matcher(urlName).matches()) return urlName; // absolute URL
    if (urlName.startsWith("/")) return Stapler.getCurrentRequest().getContextPath() + urlName;
    else
      // relative URL name
      return Stapler.getCurrentRequest().getContextPath() + '/' + itUrl + urlName;
  }
    public ContextMenu add(Action a) {
      StaplerRequest req = Stapler.getCurrentRequest();
      String text = a.getDisplayName();
      String base = Functions.getIconFilePath(a);
      if (base == null) return this;
      String icon =
          Stapler.getCurrentRequest().getContextPath()
              + (base.startsWith("images/") ? Functions.getResourcePath() : "")
              + '/'
              + base;

      String url = Functions.getActionUrl(req.findAncestor(ModelObject.class).getUrl(), a);

      return add(url, icon, text);
    }
Beispiel #5
0
 /** Computes the path to the icon of the given action from the context path. */
 public static String getIconFilePath(Action a) {
   String name = a.getIconFileName();
   if (name.startsWith("/")) return name.substring(1);
   else return "images/24x24/" + name;
 }