Example #1
0
 private String formatLogicalPackageMessage(LogicalPackage logicalPackage) {
   IScriptFolder[] fragments = logicalPackage.getScriptFolders();
   StringBuffer buf = new StringBuffer(logicalPackage.getElementName());
   buf.append(ScriptElementLabels.CONCAT_STRING);
   String message = ""; // $NON-NLS-1$
   boolean firstTime = true;
   for (int i = 0; i < fragments.length; i++) {
     IScriptFolder fragment = fragments[i];
     IModelElement element = fragment.getParent();
     if (element instanceof IProjectFragment) {
       IProjectFragment root = (IProjectFragment) element;
       String label =
           ScriptElementLabels.getDefault()
               .getElementLabel(
                   root,
                   ScriptElementLabels.DEFAULT_QUALIFIED | ScriptElementLabels.ROOT_QUALIFIED);
       if (firstTime) {
         buf.append(label);
         firstTime = false;
       } else
         message =
             Messages.format(
                 ScriptBrowsingMessages.StatusBar_concat, new String[] {message, label});
     }
   }
   buf.append(message);
   return buf.toString();
 }
  /**
   * Returns the tool tip text for the given element.
   *
   * @param element the element
   * @return the tooltip for the element
   */
  String getToolTipText(Object element) {
    String result;
    if (!(element instanceof IResource)) {
      result =
          ScriptElementLabels.getDefault()
              .getTextLabel(element, AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS);
    } else {
      IPath path = ((IResource) element).getFullPath();
      if (path.isRoot()) {
        result = getConfigurationElement().getAttribute("name"); // $NON-NLS-1$
      } else {
        result = path.makeRelative().toString();
      }
    }

    if (fWorkingSetFilterActionGroup == null
        || fWorkingSetFilterActionGroup.getWorkingSet() == null) return result;

    IWorkingSet ws = fWorkingSetFilterActionGroup.getWorkingSet();
    String wsstr =
        Messages.format(
            ScriptBrowsingMessages.JavaBrowsingPart_toolTip, new String[] {ws.getLabel()});
    if (result.length() == 0) return wsstr;
    return Messages.format(
        ScriptBrowsingMessages.JavaBrowsingPart_toolTip2, new String[] {result, ws.getLabel()});
  }
 private void doSetInput(Object input) {
   setInput(input);
   Object in = getInput();
   fGotoInputAction.setEnabled(in instanceof IModelElement);
   if (in instanceof IModelElement) {
     IModelElement me = (IModelElement) in;
     setContentDescription(ScriptElementLabels.getDefault().getElementLabel(me, TITLE_FLAGS));
     setTitleToolTip(ScriptElementLabels.getDefault().getElementLabel(me, TOOLTIP_LABEL_FLAGS));
   } else if (in instanceof ModelElementArray) {
     final ModelElementArray array = (ModelElementArray) in;
     setContentDescription(array.getContentDescription());
     setTitleToolTip(array.getTitleTooltip());
   } else if (in instanceof KeywordInput) {
     final KeywordInput keyword = (KeywordInput) in;
     setContentDescription(keyword.getValue());
     setTitleToolTip(keyword.getValue());
   } else {
     setContentDescription(in.toString());
     setTitleToolTip(in.toString());
   }
 }