Java 类org.eclipse.jface.viewers.StyledString 实例源码

项目:n4js    文件:OpenTypeSelectionDialog.java   
@Override
public StyledString getStyledText(final Object element) {
    if (element instanceof IEObjectDescription) {
        final String text = getText(element);
        final StyledString string = new StyledString(text);

        final int[] matchingRegion = getMatchingRegions(text);
        if (null != matchingRegion) {
            for (int i = 0; i < matchingRegion.length; i = i + 2) {
                string.setStyle(matchingRegion[i], matchingRegion[i + 1], boldStyler);
            }
        }

        final int indexOf = text.indexOf(NAME_SEPARATOR);
        if (-1 < indexOf) {
            string.setStyle(indexOf, text.length() - indexOf, qualifierStyler);
        }
        return string;
    }
    return new StyledString();
}
项目:n4js    文件:WorkingSetLabelProvider.java   
@Override
public StyledString getStyledText(Object element) {
    if (element instanceof WorkingSet) {
        final WorkingSet workingSet = (WorkingSet) element;
        final WorkingSetManager manager = workingSet.getWorkingSetManager();

        final String name = workingSet.getName();
        final List<String> allNames = transform(manager.getAllWorkingSets(), ws -> ws.getName());
        if (containsDuplicates(name, allNames)) {
            final String suffix = " [" + workingSet.getId() + "]";
            final StyledString string = new StyledString(name);
            string.append(suffix, COUNTER_STYLER);
            return string;
        }
    }
    return new StyledString(getText(element));
}
项目:neoscada    文件:ConnectionLabelProvider.java   
private StyledString getConnectionString ( final ConnectionHolder holder )
{
    final ConnectionService service = holder.getConnectionService ();

    final ConnectionDescriptor desc = holder.getConnectionInformation ();

    final StyledString str = new StyledString ( makeLabel ( desc.getConnectionInformation () ) );

    if ( service != null )
    {
        str.append ( " [", StyledString.DECORATIONS_STYLER ); //$NON-NLS-1$
        final Connection connection = service.getConnection ();
        if ( connection != null )
        {
            str.append ( String.format ( "%s", holder.getConnectionState () ), StyledString.DECORATIONS_STYLER ); //$NON-NLS-1$
        }
        str.append ( "]", StyledString.DECORATIONS_STYLER ); //$NON-NLS-1$
    }

    if ( desc.getServiceId () != null )
    {
        str.append ( String.format ( " (%s)", desc.getServiceId () ), StyledString.QUALIFIER_STYLER ); //$NON-NLS-1$ 
    }

    return str;
}
项目:neoscada    文件:LabelProvider.java   
@Override
public void updateLabel ( final StyledViewerLabel label, final Object element )
{
    if ( element instanceof QueryListWrapper )
    {
        label.setText ( "Test Queries" );
    }
    else if ( element instanceof QueryBean )
    {
        final QueryBean query = (QueryBean)element;
        final StyledString text = new StyledString ();
        text.append ( String.format ( "%.20s:%.40s", query.getFilterType (), query.getFilterData () ) );
        text.append ( " " );
        text.append ( String.format ( "%s", query.getCount () ), StyledString.COUNTER_STYLER );
        text.append ( " " );
        text.append ( String.format ( "[%s]", query.getState () ), StyledString.DECORATIONS_STYLER );
        label.setStyledText ( text );
        label.setTooltipText ( String.format ( "%s%n%s", query.getFilterType (), query.getFilterData () ) );
    }
    else
    {
        super.updateLabel ( label, element );
    }
}
项目:neoscada    文件:FlagsDetailsPart.java   
@Override
public void update ( final ViewerCell cell )
{
    final Object ele = cell.getElement ();
    if ( ele instanceof GroupEntry )
    {
        cell.setText ( String.format ( Messages.FlagsDetailsPart_GroupSumFormat, ( (GroupEntry)ele ).getActiveCount (), ( (GroupEntry)ele ).getCount () ) );
    }
    else if ( ele instanceof AttributeEntry )
    {
        final StyledString str = new StyledString ();

        if ( ( (AttributeEntry)ele ).isActive () )
        {
            str.append ( Messages.FlagsDetailsPart_ActiveMarker, this.activeStyler );
        }
        else
        {
            str.append ( Messages.FlagsDetailsPart_InactiveMarker, this.inactiveStyler );
        }

        cell.setText ( str.getString () );
        cell.setStyleRanges ( str.getStyleRanges () );
    }
}
项目:neoscada    文件:ConnectionLabelProvider.java   
@Override
public void updateLabel ( final StyledViewerLabel label, final Object element )
{
    logger.debug ( "Update label: {}", element ); //$NON-NLS-1$

    if ( element instanceof BrowserEntryBean )
    {
        final BrowserEntryBean entry = (BrowserEntryBean)element;
        final StyledString string = new StyledString ( entry.getEntry ().getId () );
        label.setStyledText ( string );

        final Set<BrowserType> types = entry.getEntry ().getTypes ();
        if ( types.contains ( BrowserType.EVENTS ) )
        {
            label.setImage ( Activator.getDefault ().getImageRegistry ().get ( ImageConstants.IMG_EVENTS ) );
        }
        else if ( types.contains ( BrowserType.MONITORS ) )
        {
            label.setImage ( Activator.getDefault ().getImageRegistry ().get ( ImageConstants.IMG_MONITORS ) );
        }
    }
    else
    {
        super.updateLabel ( label, element );
    }
}
项目:neoscada    文件:ServerLabelProvider.java   
protected void update ( final ViewerCell cell, final ServerEndpoint element )
{
    final StyledString str = new StyledString ();

    final boolean running = element.isRunning ();

    str.append ( element.getLabel () );

    cell.setText ( str.getString () );
    cell.setStyleRanges ( str.getStyleRanges () );

    if ( element.getError () != null )
    {
        cell.setImage ( this.errorImage );
    }
    else
    {
        cell.setImage ( running ? this.runningImage : this.stoppedImage );
    }
}
项目:scanning    文件:ScannableValueLabelProvider.java   
@Override
public StyledString getStyledText(Object element) {

    if(!(element instanceof IScannable<?>)) return new StyledString();

    final String       text       = getText(element);
    final StyledString styledText = new StyledString(text!=null?text:"");

    IScannable<?> scannable = (IScannable<?>)element;
    try {

        if (scannable.getUnit() != null) {
            styledText.append("    ");
            styledText.append(scannable.getUnit(), StyledString.DECORATIONS_STYLER);

        } else {

            // Intentionally do nothing!
        }
    } catch (Exception ne) {
        String message = ne.getMessage() == null ? "" : ne.getMessage();
        return styledText.append(message, StyledString.QUALIFIER_STYLER);
    }

    return styledText;
}
项目:scanning    文件:ValidateResultsView.java   
/**
 * Turn the results into a styled string for display to user, highlighting key values
 * @param results The ValidationResults
 * @return a StyledString to display on the view
 */
private StyledString appendResultsToStyledString(ValidateResults results) {
    StyledString styledString = new StyledString();
    if (results.getResults() != null) {
        if (results.getResults() instanceof String) {
            // Print out all the results from the raw PVStructure string, but style key information
            String resultString = (String)results.getResults();
            styledString.append(resultString);

            // Style the duration
            adjustStyleOfDuration(styledString, resultString);

            // Style the axes to move
            adjustStyleOfAxesToMove(styledString, resultString);

        } else {
            // not a string, just print out the results object
             styledString.append(results.getResults().toString());
        }
    }

    return styledString;

}
项目:ec4e    文件:EditorConfigCompletionProposal.java   
@Override
public StyledString getStyledDisplayString(IDocument document, int offset, BoldStylerProvider boldStylerProvider) {
    // Highlight matched prefix
    StyledString styledDisplayString = new StyledString();
    styledDisplayString.append(getStyledDisplayString());

    String pattern = getPatternToEmphasizeMatch(document, offset);
    if (pattern != null && pattern.length() > 0) {
        String displayString = styledDisplayString.getString();
        int[] bestSequence = completionEntry.getMatcher().bestSubsequence(displayString, pattern);
        int highlightAdjustment = 0;
        for (int index : bestSequence) {
            styledDisplayString.setStyle(index + highlightAdjustment, 1, boldStylerProvider.getBoldStyler());
        }
    }
    return styledDisplayString;
}
项目:mesfavoris    文件:GDriveBookmarkFolderLabelProvider.java   
@Override
public StyledString getStyledText(Context context, Bookmark bookmark) {
    StyledString styledString = super.getStyledText(context, bookmark);
    BookmarkFolder bookmarkFolder = (BookmarkFolder) bookmark;
    BookmarkId bookmarkId = bookmarkFolder.getId();
    Optional<BookmarkMapping> bookmarkMapping = bookmarkMappings.getMapping(bookmarkId);
    if (!bookmarkMapping.isPresent()) {
        return styledString;
    }
    String sharingUser = bookmarkMapping.get().getProperties().get(BookmarkMapping.PROP_SHARING_USER);
    if (sharingUser == null) {
        return styledString;
    }
    Styler styler = stylerProvider.getStyler(null, Display.getCurrent().getSystemColor(SWT.COLOR_DARK_YELLOW),
            null);
    styledString.append(String.format(" [Shared by %s]", sharingUser), styler);
    return styledString;
}
项目:mesfavoris    文件:PathPlaceholderTableLabelProvider.java   
@Override
public StyledString getStyledText(Object element) {
    PathPlaceholder pathPlaceholder = (PathPlaceholder) element;
    StyledString sb = new StyledString();
    sb.append(pathPlaceholder.getName());
    sb.append(" (");
    if (isUnmodifiable(pathPlaceholder)) {
        sb.append("non modifiable, ");
    }
    sb.append(
            MessageFormat.format("{0} matches",
                    Integer.toString(placeholderStats.getUsageCount(pathPlaceholder.getName()))),
            StyledString.COUNTER_STYLER);
    sb.append(')');
    sb.append(" - ");
    if (pathPlaceholder.getPath() != null) {
        sb.append(pathPlaceholder.getPath().toString());
    }
    return sb;
}
项目:mesfavoris    文件:BookmarkFolderLabelProvider.java   
@Override
public StyledString getStyledText(Context context, Bookmark bookmark) {
    BookmarkFolder bookmarkFolder = (BookmarkFolder) bookmark;
    StyledString result = super.getStyledText(context, bookmark);
    RemoteBookmarkFolder remoteBookmarkFolder = remoteBookmarksStoreManager
            .getRemoteBookmarkFolder(bookmarkFolder.getId());
    if (remoteBookmarkFolder != null) {
        IRemoteBookmarksStore remoteBookmarksStore = remoteBookmarksStoreManager
                .getRemoteBookmarksStore(remoteBookmarkFolder.getRemoteBookmarkStoreId());
        Optional<Integer> bookmarksCount = getBookmarksCount(remoteBookmarkFolder);
        if (bookmarksCount.isPresent()) {
            result.append(String.format(" (%d)", bookmarksCount.get()), stylerProvider.getStyler(null,
                    Display.getCurrent().getSystemColor(SWT.COLOR_DARK_YELLOW), null));
        }
        if (remoteBookmarksStore.getState() == State.connected && isReadOnly(remoteBookmarkFolder)) {
            result.append(" [readonly]", stylerProvider.getStyler(null,
                    Display.getCurrent().getSystemColor(SWT.COLOR_DARK_YELLOW), null));
        }
    }

    return result;
}
项目:tlaplus    文件:FilteredItemsSelectionDialog.java   
public void update(ViewerCell cell) {
    Object element = cell.getElement();

    if (!(element instanceof ItemsListSeparator)
            && provider instanceof IStyledLabelProvider) {
        IStyledLabelProvider styledLabelProvider = (IStyledLabelProvider) provider;
        StyledString styledString = getStyledText(element,
                styledLabelProvider);

        cell.setText(styledString.getString());
        cell.setStyleRanges(styledString.getStyleRanges());
        cell.setImage(styledLabelProvider.getImage(element));
    } else {
        cell.setText(getText(element));
        cell.setImage(getImage(element));
    }
    cell.setFont(getFont(element));
    cell.setForeground(getForeground(element));
    cell.setBackground(getBackground(element));

    super.update(cell);
}
项目:tlaplus    文件:TLAFilteredItemsSelectionDialog.java   
public StyledString getStyledText(Object element) {
    final String text = getText(element);
    if (text == null || EMPTY_STRING.equals(text)) {
        return new StyledString();
    }

    final StyledString string = new StyledString(text);

    if (element instanceof Spec) {
        string.setStyle(0, string.length(), StyledString.QUALIFIER_STYLER);
    } else if (element instanceof Model && text.indexOf(DELIM) != -1) {
        final int index = text.indexOf(DELIM);
        string.setStyle(index, text.length() - index, StyledString.DECORATIONS_STYLER);
    } else if (element instanceof ItemsListSeparator) {
        string.setStyle(0, string.length(), StyledString.QUALIFIER_STYLER);
    }
    return string;
}
项目:typescript.java    文件:TypeScriptCompletionProposalWithExtension7.java   
@Override
public StyledString getStyledDisplayString(IDocument document, int offset, BoldStylerProvider boldStylerProvider) {
    // Highlight matched prefix
    StyledString styledDisplayString = new StyledString();
    styledDisplayString.append(getStyledDisplayString());

    String pattern = getPatternToEmphasizeMatch(document, offset);
    if (pattern != null && pattern.length() > 0) {
        String displayString = styledDisplayString.getString();
        int[] bestSequence = getMatcher().bestSubsequence(displayString, pattern);
        int highlightAdjustment = 0;
        for (int index : bestSequence) {
            styledDisplayString.setStyle(index + highlightAdjustment, 1, boldStylerProvider.getBoldStyler());
        }
    }
    return styledDisplayString;
}
项目:jsbuild-eclipse    文件:JSBuildFileLabelProvider.java   
@Override
public StyledString getStyledText(Object element) {
    if (element instanceof IJSBuildFile) {
        IJSBuildFile node = (IJSBuildFile) element;
        StyledString buff = new StyledString(node.getLabel());
        IFile buildfile = node.getBuildFileResource();
        if (buildfile != null) {
            buff.append("  "); //$NON-NLS-1$
            buff.append('[', StyledString.DECORATIONS_STYLER);
            buff.append(buildfile.getFullPath().makeRelative().toString(),
                    StyledString.DECORATIONS_STYLER);
            buff.append(']', StyledString.DECORATIONS_STYLER);
        }
        return buff;
    } else if (element instanceof ITask) {
        return new StyledString(((ITask) element).getLabel());
    }
    return null;
}
项目:NEXCORE-UML-Modeler    文件:UMLLabelProvider.java   
/**
 * @see org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider#getStyledText(java.lang.Object)
 */
public StyledString getStyledText(Object element) {
    if (element instanceof ClosedTreeNode) {
        return new StyledString(getText(element), StyledString.createColorRegistryStyler("QUALIFIER_COLOR", null));// gray color
    } else if (element instanceof ITreeNode) {
        EObject eobject = ((ITreeNode) element).getEObject();
        if (eobject instanceof ProfileApplication) {
            ProfileApplication profileApplication = (ProfileApplication) eobject;

            Profile profile = profileApplication.getAppliedProfile();
            if (profile.eIsProxy()) {
                String text = String.format("'%s' does not exist.", getText(element));
                return new StyledString(text, StyledString.createColorRegistryStyler("ERROR_COLOR", null));// red color
            }
        }
    }

    return new StyledString(getText(element));
}
项目:bts    文件:AbstractLabelProvider.java   
/**
 * Subclasses should rather override {@link #doGetText}.
 */
public StyledString getStyledText(Object element) {
    StyledString styledText = convertToStyledString(doGetText(element));
    if (styledText != null) {
        return styledText;
    } else if (delegate != null) {
        if (delegate instanceof IStyledLabelProvider) {
            styledText = ((IStyledLabelProvider) delegate).getStyledText(element);
            if (styledText != null) {
                return styledText;
            }
        } else {
            styledText = convertToStyledString(delegate.getText(element));
            if (styledText != null) {
                return styledText;
            }
        }
    }
    return getDefaultStyledText();
}
项目:che    文件:JavaTypeCompletionProposal.java   
public JavaTypeCompletionProposal(
    String replacementString,
    ICompilationUnit cu,
    int replacementOffset,
    int replacementLength,
    Image image,
    StyledString displayString,
    int relevance,
    String fullyQualifiedTypeName,
    JavaContentAssistInvocationContext invocationContext) {
  super(
      replacementString,
      replacementOffset,
      replacementLength,
      image,
      displayString,
      relevance,
      false,
      invocationContext);
  fCompilationUnit = cu;
  fFullyQualifiedTypeName = fullyQualifiedTypeName;
  fUnqualifiedTypeName =
      fullyQualifiedTypeName != null ? Signature.getSimpleName(fullyQualifiedTypeName) : null;
}
项目:PDFReporter-Studio    文件:ReportTreeLabelProvider.java   
@Override
public void update(ViewerCell cell) {
    try {
        Object element = cell.getElement();
        StyledString st = getStyledText(element);
        cell.setText(st.getString());
        cell.setStyleRanges(getStyledText(element).getStyleRanges());
        cell.setImage(getImage(element));
        cell.setBackground(getBackground(element));
        cell.setForeground(getForeground(element));
        cell.setFont(getFont(element));
    } catch (Exception e) {
        e.printStackTrace();
    }

}
项目:bts    文件:AbstractJavaBasedContentProposalProvider.java   
public ICompletionProposal apply(IEObjectDescription candidate) {
    if (candidate == null)
        return null;
    ICompletionProposal result = null;
    String proposal = qualifiedNameConverter.toString(candidate.getName());
    if (ruleName != null) {
        try {
            proposal = getValueConverter().toString(proposal, ruleName);
        } catch (ValueConverterException e) {
            log.debug(e.getMessage(), e);
            return null;
        }
    }
    EObject objectOrProxy = candidate.getEObjectOrProxy();
    StyledString displayString = getStyledDisplayString(candidate);
    Image image = getImage(objectOrProxy);
    result = createCompletionProposal(proposal, displayString, image, contentAssistContext);
    if (result instanceof ConfigurableCompletionProposal) {
        ((ConfigurableCompletionProposal) result).setProposalContextResource(contentAssistContext.getResource());
        ((ConfigurableCompletionProposal) result).setAdditionalProposalInfo(objectOrProxy);
        ((ConfigurableCompletionProposal) result).setHover(hover);
    }
    getPriorityHelper().adjustCrossReferencePriority(result, contentAssistContext.getPrefix());
    return result;
}
项目:bts    文件:ConfigurableCompletionProposal.java   
/**
 * Creates a new completion proposal. All fields are initialized based on the provided information.
 *
 * @param replacementString the actual string to be inserted into the document
 * @param replacementOffset the offset of the text to be replaced
 * @param replacementLength the length of the text to be replaced
 * @param cursorPosition the position of the cursor following the insert relative to replacementOffset
 * @param image the image to display for this proposal
 * @param displayString the string to be displayed for the proposal
 * @param contextInformation the context information associated with this proposal
 * @param additionalProposalInfo the additional information associated with this proposal
 */
public ConfigurableCompletionProposal(String replacementString, int replacementOffset, int replacementLength, int cursorPosition, Image image, StyledString displayString, IContextInformation contextInformation, String additionalProposalInfo) {
    Assert.isNotNull(replacementString);
    Assert.isTrue(replacementOffset >= 0);
    Assert.isTrue(replacementLength >= 0);
    Assert.isTrue(cursorPosition >= 0);

    this.replacementString= replacementString;
    this.replacementOffset= replacementOffset;
    this.replacementLength= replacementLength;
    this.cursorPosition= cursorPosition;
    this.selectionStart = replacementOffset + cursorPosition;
    this.image= image;
    this.displayString= displayString==null ? new StyledString(this.replacementString) : displayString;
    this.contextInformation= contextInformation;
    this.additionalProposalInfo= additionalProposalInfo;
}
项目:hssd    文件:ValueTreeLP.java   
@Override
   public void update(ViewerCell cell) {
    if(!(cell.getElement() instanceof TreeNode)) {
        final String text = String.format(
                "(%s, %s)", 
                cell.getElement(),
                cell.getColumnIndex()
        );
        cell.setText(text);
        super.update(cell);
        return;
    }

    final TreeNode node = (TreeNode)cell.getElement();
    final int columnIndex = cell.getColumnIndex();
    final StyledString styledText = getStyledText(node, columnIndex);

    if(columnIndex == Column.CAPTION.ordinal()) {
           cell.setImage(getImage(node));
       }

    cell.setText(styledText.toString());
    cell.setStyleRanges(styledText.getStyleRanges());
    super.update(cell);
}
项目:che    文件:OverrideCompletionProposal.java   
public OverrideCompletionProposal(
    IJavaProject jproject,
    ICompilationUnit cu,
    String methodName,
    String[] paramTypes,
    int start,
    int length,
    StyledString displayName,
    String completionProposal) {
  super(completionProposal, cu, start, length, null, displayName, 0);
  Assert.isNotNull(jproject);
  Assert.isNotNull(methodName);
  Assert.isNotNull(paramTypes);
  Assert.isNotNull(cu);

  fParamTypes = paramTypes;
  fMethodName = methodName;

  fJavaProject = jproject;

  StringBuffer buffer = new StringBuffer();
  buffer.append(completionProposal);
  buffer.append(" {};"); // $NON-NLS-1$

  setReplacementString(buffer.toString());
}
项目:che    文件:CompletionProposalLabelProvider.java   
/**
 * Creates and returns a parameter list of the given method or type proposal suitable for display.
 * The list does not include parentheses. The lower bound of parameter types is returned.
 *
 * <p>Examples:
 *
 * <pre>
 *   &quot;void method(int i, String s)&quot; -&gt; &quot;int i, String s&quot;
 *   &quot;? extends Number method(java.lang.String s, ? super Number n)&quot; -&gt; &quot;String s, Number n&quot;
 * </pre>
 *
 * @param proposal the proposal to create the parameter list for
 * @return the list of comma-separated parameters suitable for display
 */
public String createParameterList(CompletionProposal proposal) {
  String paramList;
  int kind = proposal.getKind();
  switch (kind) {
    case CompletionProposal.METHOD_REF:
    case CompletionProposal.CONSTRUCTOR_INVOCATION:
      paramList = appendUnboundedParameterList(new StyledString(), proposal).getString();
      return Strings.markJavaElementLabelLTR(paramList);
    case CompletionProposal.TYPE_REF:
    case CompletionProposal.JAVADOC_TYPE_REF:
      paramList = appendTypeParameterList(new StyledString(), proposal).getString();
      return Strings.markJavaElementLabelLTR(paramList);
    case CompletionProposal.ANONYMOUS_CLASS_DECLARATION:
    case CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION:
      paramList = appendUnboundedParameterList(new StyledString(), proposal).getString();
      return Strings.markJavaElementLabelLTR(paramList);
    default:
      Assert.isLegal(false);
      return null; // dummy
  }
}
项目:che    文件:CompletionProposalLabelProvider.java   
/**
 * Appends the parameter list to <code>buffer</code>.
 *
 * @param buffer the buffer to append to
 * @param methodProposal the method proposal
 * @return the modified <code>buffer</code>
 */
private StyledString appendUnboundedParameterList(
    StyledString buffer, CompletionProposal methodProposal) {
  // TODO remove once https://bugs.eclipse.org/bugs/show_bug.cgi?id=85293
  // gets fixed.
  char[] signature = SignatureUtil.fix83600(methodProposal.getSignature());
  char[][] parameterNames = methodProposal.findParameterNames(null);
  char[][] parameterTypes = Signature.getParameterTypes(signature);

  for (int i = 0; i < parameterTypes.length; i++)
    parameterTypes[i] = createTypeDisplayName(SignatureUtil.getLowerBound(parameterTypes[i]));

  if (Flags.isVarargs(methodProposal.getFlags())) {
    int index = parameterTypes.length - 1;
    parameterTypes[index] = convertToVararg(parameterTypes[index]);
  }
  return appendParameterSignature(buffer, parameterTypes, parameterNames);
}
项目:che    文件:CompletionProposalLabelProvider.java   
/**
 * Creates a display string of a parameter list (without the parentheses) for the given parameter
 * types and names.
 *
 * @param buffer the string buffer
 * @param parameterTypes the parameter types
 * @param parameterNames the parameter names
 * @return the display string of the parameter list defined by the passed arguments
 */
private final StyledString appendParameterSignature(
    StyledString buffer, char[][] parameterTypes, char[][] parameterNames) {
  if (parameterTypes != null) {
    for (int i = 0; i < parameterTypes.length; i++) {
      if (i > 0) {
        buffer.append(',');
        buffer.append(' ');
      }
      buffer.append(parameterTypes[i]);
      if (parameterNames != null && parameterNames[i] != null) {
        buffer.append(' ');
        buffer.append(parameterNames[i]);
      }
    }
  }
  return buffer;
}
项目:txtUML    文件:WizardUtils.java   
public static IBaseLabelProvider getPostQualifiedLabelProvider() {
    return new DelegatingStyledCellLabelProvider(new JavaElementLabelProvider(
            JavaElementLabelProvider.SHOW_POST_QUALIFIED | JavaElementLabelProvider.SHOW_SMALL_ICONS)) {
        @Override
        protected StyledString getStyledText(Object element) {
            String nameWithQualifier = getStyledStringProvider().getStyledText(element).getString() + " ";
            int separatorIndex = nameWithQualifier.indexOf('-');

            if (separatorIndex == -1)
                return new StyledString(nameWithQualifier);

            StyledString name = new StyledString(nameWithQualifier.substring(0, separatorIndex));
            String qualifier = nameWithQualifier.substring(separatorIndex);
            return name.append(new StyledString(qualifier, StyledString.QUALIFIER_STYLER));
        };
    };
}
项目:PDFReporter-Studio    文件:MExpressionX.java   
@Override
public StyledString getStyledDisplayText() {
    String dt = getDisplayText();
    StyledString ss = new StyledString(dt);
    if (!isFirst()) {
        if (getParent() instanceof MFromTableJoin && getParent().getValue() instanceof MQueryTable) {
            int ind = dt.indexOf(" AS ");
            if (ind >= 0)
                ss.setStyle(ind, " AS ".length(), FontUtils.KEYWORDS_STYLER);
            ind = (dt).indexOf(" ON ");
            if (ind >= 0)
                ss.setStyle(ind, " ON ".length(), FontUtils.KEYWORDS_STYLER);
        } else
            ss.setStyle(0, (prevCond + " ").length(), FontUtils.KEYWORDS_STYLER);
    }
    ss.setStyle(dt.lastIndexOf("$X{"), 3, FontUtils.CLASSTYPE_STYLER);
    ss.setStyle(dt.lastIndexOf("}"), 1, FontUtils.CLASSTYPE_STYLER);
    return ss;
}
项目:che    文件:CompletionProposalLabelProvider.java   
StyledString createAnonymousTypeLabel(CompletionProposal proposal) {
  char[] declaringTypeSignature = proposal.getDeclarationSignature();
  declaringTypeSignature = Signature.getTypeErasure(declaringTypeSignature);

  StyledString buffer = new StyledString();
  buffer.append(Signature.getSignatureSimpleName(declaringTypeSignature));
  buffer.append('(');
  appendUnboundedParameterList(buffer, proposal);
  buffer.append(')');
  buffer.append("  "); // $NON-NLS-1$
  buffer.append(JavaTextMessages.ResultCollector_anonymous_type);

  if (proposal.getRequiredProposals() != null) {
    char[] signatureQualifier = Signature.getSignatureQualifier(declaringTypeSignature);
    if (signatureQualifier.length > 0) {
      buffer.append(JavaElementLabels.CONCAT_STRING, StyledString.QUALIFIER_STYLER);
      buffer.append(signatureQualifier, StyledString.QUALIFIER_STYLER);
    }
  }

  return Strings.markJavaElementLabelLTR(buffer);
}
项目:che    文件:CompletionProposalCollector.java   
private IJavaCompletionProposal createAnnotationAttributeReferenceProposal(
    CompletionProposal proposal) {
  StyledString displayString = fLabelProvider.createLabelWithTypeAndDeclaration(proposal);
  ImageDescriptor descriptor = fLabelProvider.createMethodImageDescriptor(proposal);
  String completion = String.valueOf(proposal.getCompletion());
  JavaCompletionProposal javaProposal =
      new JavaCompletionProposal(
          completion,
          proposal.getReplaceStart(),
          getLength(proposal),
          getImage(descriptor),
          displayString,
          computeRelevance(proposal));
  if (fJavaProject != null)
    javaProposal.setProposalInfo(new AnnotationAtttributeProposalInfo(fJavaProject, proposal));
  return javaProposal;
}
项目:che    文件:CompletionProposalCollector.java   
private IJavaCompletionProposal createFieldProposal(CompletionProposal proposal) {
  String completion = String.valueOf(proposal.getCompletion());
  int start = proposal.getReplaceStart();
  int length = getLength(proposal);
  StyledString label = fLabelProvider.createStyledLabel(proposal);
  Image image = getImage(fLabelProvider.createFieldImageDescriptor(proposal));
  int relevance = computeRelevance(proposal);

  JavaCompletionProposal javaProposal =
      new JavaCompletionProposal(
          completion,
          start,
          length,
          image,
          label,
          relevance,
          getContext().isInJavadoc(),
          getInvocationContext());
  if (fJavaProject != null)
    javaProposal.setProposalInfo(new FieldProposalInfo(fJavaProject, proposal));

  javaProposal.setTriggerCharacters(VAR_TRIGGER);

  return javaProposal;
}
项目:che    文件:MethodDeclarationCompletionProposal.java   
private static StyledString getDisplayName(String methodName, String returnTypeSig) {
  StyledString buf = new StyledString();
  buf.append(methodName);
  buf.append('(');
  buf.append(')');
  if (returnTypeSig != null) {
    buf.append(" : "); // $NON-NLS-1$
    buf.append(Signature.toString(returnTypeSig));
    buf.append(" - ", StyledString.QUALIFIER_STYLER); // $NON-NLS-1$
    buf.append(
        JavaTextMessages.MethodCompletionProposal_method_label, StyledString.QUALIFIER_STYLER);
  } else {
    buf.append(" - ", StyledString.QUALIFIER_STYLER); // $NON-NLS-1$
    buf.append(
        JavaTextMessages.MethodCompletionProposal_constructor_label,
        StyledString.QUALIFIER_STYLER);
  }
  return buf;
}
项目:che    文件:JavaCompletionProposal.java   
/**
 * Creates a new completion proposal. All fields are initialized based on the provided
 * information.
 *
 * @param replacementString the actual string to be inserted into the document
 * @param replacementOffset the offset of the text to be replaced
 * @param replacementLength the length of the text to be replaced
 * @param image the image to display for this proposal
 * @param displayString the string to be displayed for the proposal If set to <code>null</code>,
 *     the replacement string will be taken as display string.
 * @param relevance the relevance
 * @param inJavadoc <code>true</code> for a javadoc proposal
 * @param invocationContext the invocation context of this completion proposal or <code>null
 *     </code> not available
 */
public JavaCompletionProposal(
    String replacementString,
    int replacementOffset,
    int replacementLength,
    Image image,
    StyledString displayString,
    int relevance,
    boolean inJavadoc,
    JavaContentAssistInvocationContext invocationContext) {
  super(invocationContext);
  Assert.isNotNull(replacementString);
  Assert.isTrue(replacementOffset >= 0);
  Assert.isTrue(replacementLength >= 0);

  setReplacementString(replacementString);
  setReplacementOffset(replacementOffset);
  setReplacementLength(replacementLength);
  setImage(image);
  setStyledDisplayString(
      displayString == null ? new StyledString(replacementString) : displayString);
  setRelevance(relevance);
  setCursorPosition(replacementString.length());
  setInJavadoc(inJavadoc);
  setSortString(displayString == null ? replacementString : displayString.getString());
}
项目:che    文件:JavaElementLabels.java   
/**
 * Returns the styled label of the given object. The object must be of type {@link IJavaElement}
 * or adapt to {@link IWorkbenchAdapter}. If the element type is not known, the empty string is
 * returned. The returned label is BiDi-processed with {@link TextProcessor#process(String,
 * String)}.
 *
 * @param obj object to get the label for
 * @param flags the rendering flags
 * @return the label or the empty string if the object type is not supported
 * @since 3.4
 */
public static StyledString getStyledTextLabel(Object obj, long flags) {
  if (obj instanceof IJavaElement) {
    return getStyledElementLabel((IJavaElement) obj, flags);

  } else if (obj instanceof IResource) {
    return getStyledResourceLabel((IResource) obj);

    //      } else if (obj instanceof ClassPathContainer) {
    //          ClassPathContainer container= (ClassPathContainer) obj;
    //          return getStyledContainerEntryLabel(container.getClasspathEntry().getPath(),
    // container.getJavaProject());
    //
    //      } else if (obj instanceof IStorage) {
    //          return getStyledStorageLabel((IStorage) obj);
    //
    //      } else if (obj instanceof IAdaptable) {
    //          IWorkbenchAdapter wbadapter= (IWorkbenchAdapter)
    // ((IAdaptable)obj).getAdapter(IWorkbenchAdapter.class);
    //          if (wbadapter != null) {
    //              return Strings.markLTR(new StyledString(wbadapter.getLabel(obj)));
    //          }
  }
  return new StyledString();
}
项目:che    文件:JavaCompletionProposal.java   
/**
 * Creates a new completion proposal. All fields are initialized based on the provided
 * information.
 *
 * @param replacementString the actual string to be inserted into the document
 * @param replacementOffset the offset of the text to be replaced
 * @param replacementLength the length of the text to be replaced
 * @param image the image to display for this proposal
 * @param displayString the string to be displayed for the proposal If set to <code>null</code>,
 *     the replacement string will be taken as display string.
 * @param relevance the relevance
 */
public JavaCompletionProposal(
    String replacementString,
    int replacementOffset,
    int replacementLength,
    Image image,
    String displayString,
    int relevance) {
  this(
      replacementString,
      replacementOffset,
      replacementLength,
      image,
      new StyledString(displayString),
      relevance,
      false);
}
项目:n4js    文件:N4JSProjectExplorerLabelProvider.java   
@Override
public StyledString getStyledText(final Object element) {
    if (element instanceof WorkingSet) {
        return WorkingSetLabelProvider.INSTANCE.getStyledText(element);
    }
    return workbenchLabelProvider.getStyledText(element);
}
项目:n4js    文件:N4JSCompletionProposal.java   
/**
 * Creates a new proposal.
 */
public N4JSCompletionProposal(String replacementString, int replacementOffset, int replacementLength,
        int cursorPosition, Image image, StyledString displayString, IContextInformation contextInformation,
        String additionalProposalInfo) {
    super(replacementString, replacementOffset, replacementLength, cursorPosition, image, displayString,
            contextInformation, additionalProposalInfo);
}
项目:eclipse-jenkins-editor    文件:JenkinsEditorOutlineLabelProvider.java   
private void handleParameters(StyledString styled, Item item) {
    /* show add parameters if existing */
    boolean paramsMustBeShown=false;

    ItemType itemType = item.getItemType();
    paramsMustBeShown=paramsMustBeShown || ItemType.METHOD.equals(itemType);
    paramsMustBeShown=paramsMustBeShown || ItemType.CONSTRUCTOR.equals(itemType);

    if (!paramsMustBeShown){
        return;
    }
    String[] parameters = item.getParameters();
    if (parameters == null) {
        return;
    }
    int length = parameters.length;
    styled.append("(");
    if (parameters != null && length > 0) {
        int last = length - 1;
        for (int i = 0; i < length; i++) {
            String parameter = parameters[i];
            if (parameter == null) {
                continue;
            }
            styled.append(parameter);
            if (i != last) {
                styled.append(',');
            }
        }
    }
    styled.append(")");
}