Exemplo n.º 1
0
 @Override
 public String getLabel() {
   String label =
       DartElementLabels.getTextLabel(
           fElement, DartElementLabels.ALL_DEFAULT | DartElementLabels.ALL_FULLY_QUALIFIED);
   return Messages.format(DartUIMessages.JavaUIHelp_link_label, label);
 }
Exemplo n.º 2
0
  public DartDocHelpContext(IContext context, Object[] elements) throws DartModelException {
    Assert.isNotNull(elements);
    if (context instanceof IContext2) {
      fTitle = ((IContext2) context).getTitle();
    }

    List<IHelpResource> helpResources = new ArrayList<IHelpResource>();

    String javadocSummary = null;
    for (int i = 0; i < elements.length; i++) {
      if (elements[i] instanceof DartElement) {
        DartElement element = (DartElement) elements[i];
        // if element isn't on the build path skip it
        if (!ActionUtil.isOnBuildPath(element)) {
          continue;
        }

        // Create Javadoc summary
        if (BUG_85719_FIXED) {
          if (javadocSummary == null) {
            javadocSummary = retrieveText(element);
            if (javadocSummary != null) {
              String elementLabel =
                  DartElementLabels.getTextLabel(element, DartElementLabels.ALL_DEFAULT);

              // FIXME: needs to be NLSed once the code becomes active
              javadocSummary =
                  "<b>DartDoc for "
                      + elementLabel
                      + ":</b><br>"
                      + javadocSummary; //$NON-NLS-1$//$NON-NLS-2$
            }
          } else {
            javadocSummary = ""; // no Javadoc summary for multiple selection //$NON-NLS-1$
          }
        }

        URL url = DartUI.getDartDocLocation(element, true);
        if (url == null || doesNotExist(url)) {
          DartX.todo();
          //          IPackageFragmentRoot root = DartModelUtil.getPackageFragmentRoot(element);
          //          if (root != null) {
          //            url = DartUI.getJSdocBaseLocation(element);
          //            if (root.getKind() == IPackageFragmentRoot.K_SOURCE) {
          //              element = element.getDartProject();
          //            } else {
          //              element = root;
          //            }
          //            url = DartUI.getJSdocLocation(element, false);
          //          }
        }
        if (url != null) {
          IHelpResource javaResource = new JavaUIHelpResource(element, getURLString(url));
          helpResources.add(javaResource);
        }
      }
    }

    // Add static help topics
    if (context != null) {
      IHelpResource[] resources = context.getRelatedTopics();
      if (resources != null) {
        for (int j = 0; j < resources.length; j++) {
          helpResources.add(resources[j]);
        }
      }
    }

    fHelpResources = helpResources.toArray(new IHelpResource[helpResources.size()]);

    if (context != null) {
      fText = context.getText();
    }

    if (BUG_85719_FIXED) {
      if (javadocSummary != null && javadocSummary.length() > 0) {
        if (fText != null) {
          fText = context.getText() + "<br><br>" + javadocSummary; // $NON-NLS-1$
        } else {
          fText = javadocSummary;
        }
      }
    }

    if (fText == null) {
      fText = ""; // $NON-NLS-1$
    }
  }