Search in sources :

Example 11 with StyledString

use of org.eclipse.jface.viewers.StyledString in project che by eclipse.

the class CompletionProposalLabelProvider method createParameterList.

/**
     * 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>
     *
     * </p>
     *
     * @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);
            // dummy
            return null;
    }
}
Also used : StyledString(org.eclipse.jface.viewers.StyledString) StyledString(org.eclipse.jface.viewers.StyledString)

Example 12 with StyledString

use of org.eclipse.jface.viewers.StyledString in project che by eclipse.

the class CompletionProposalLabelProvider method createLabelWithTypeAndDeclaration.

StyledString createLabelWithTypeAndDeclaration(CompletionProposal proposal) {
    char[] name = proposal.getCompletion();
    if (!isThisPrefix(name))
        name = proposal.getName();
    StyledString buf = new StyledString();
    buf.append(name);
    char[] typeName = Signature.getSignatureSimpleName(proposal.getSignature());
    if (typeName.length > 0) {
        buf.append(VAR_TYPE_SEPARATOR);
        buf.append(typeName);
    }
    char[] declaration = proposal.getDeclarationSignature();
    if (declaration != null) {
        declaration = Signature.getSignatureSimpleName(declaration);
        if (declaration.length > 0) {
            buf.append(QUALIFIER_SEPARATOR, StyledString.QUALIFIER_STYLER);
            if (proposal.getRequiredProposals() != null) {
                String declaringType = extractDeclaringTypeFQN(proposal);
                String qualifier = Signature.getQualifier(declaringType);
                if (qualifier.length() > 0) {
                    buf.append(qualifier, StyledString.QUALIFIER_STYLER);
                    buf.append('.', StyledString.QUALIFIER_STYLER);
                }
            }
            buf.append(declaration, StyledString.QUALIFIER_STYLER);
        }
    }
    return Strings.markJavaElementLabelLTR(buf);
}
Also used : StyledString(org.eclipse.jface.viewers.StyledString) StyledString(org.eclipse.jface.viewers.StyledString)

Example 13 with StyledString

use of org.eclipse.jface.viewers.StyledString in project che by eclipse.

the class CompletionProposalLabelProvider method createAnonymousTypeLabel.

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(')');
    //$NON-NLS-1$
    buffer.append("  ");
    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);
}
Also used : StyledString(org.eclipse.jface.viewers.StyledString)

Example 14 with StyledString

use of org.eclipse.jface.viewers.StyledString in project che by eclipse.

the class JavaElementLabels method getStyledContainerEntryLabel.

/**
	 * Returns the styled label of a classpath container.
	 * The returned label is BiDi-processed with {@link TextProcessor#process(String, String)}.
	 *
	 * @param containerPath the path of the container
	 * @param project the project the container is resolved in
	 * @return the label of the classpath container
	 *
	 * @since 3.4
	 */
public static StyledString getStyledContainerEntryLabel(IPath containerPath, IJavaProject project) {
    try {
        IClasspathContainer container = JavaCore.getClasspathContainer(containerPath, project);
        String description = null;
        if (container != null) {
            description = container.getDescription();
        }
        if (description == null) {
            ClasspathContainerInitializer initializer = JavaCore.getClasspathContainerInitializer(containerPath.segment(0));
            if (initializer != null) {
                description = initializer.getDescription(containerPath, project);
            }
        }
        if (description != null) {
            StyledString str = new StyledString(description);
            //				}
            return Strings.markLTR(str);
        }
    } catch (JavaModelException e) {
    // ignore
    }
    return new StyledString(BasicElementLabels.getPathLabel(containerPath, false));
}
Also used : JavaModelException(org.eclipse.jdt.core.JavaModelException) StyledString(org.eclipse.jface.viewers.StyledString) StyledString(org.eclipse.jface.viewers.StyledString) IClasspathContainer(org.eclipse.jdt.core.IClasspathContainer) ClasspathContainerInitializer(org.eclipse.jdt.core.ClasspathContainerInitializer)

Example 15 with StyledString

use of org.eclipse.jface.viewers.StyledString in project che by eclipse.

the class MethodDeclarationCompletionProposal method getDisplayName.

private static StyledString getDisplayName(String methodName, String returnTypeSig) {
    StyledString buf = new StyledString();
    buf.append(methodName);
    buf.append('(');
    buf.append(')');
    if (returnTypeSig != null) {
        //$NON-NLS-1$
        buf.append(" : ");
        buf.append(Signature.toString(returnTypeSig));
        //$NON-NLS-1$
        buf.append(" - ", StyledString.QUALIFIER_STYLER);
        buf.append(JavaTextMessages.MethodCompletionProposal_method_label, StyledString.QUALIFIER_STYLER);
    } else {
        //$NON-NLS-1$
        buf.append(" - ", StyledString.QUALIFIER_STYLER);
        buf.append(JavaTextMessages.MethodCompletionProposal_constructor_label, StyledString.QUALIFIER_STYLER);
    }
    return buf;
}
Also used : StyledString(org.eclipse.jface.viewers.StyledString)

Aggregations

StyledString (org.eclipse.jface.viewers.StyledString)69 Image (org.eclipse.swt.graphics.Image)14 JavaCompletionProposal (org.eclipse.jdt.internal.ui.text.java.JavaCompletionProposal)8 LazyJavaCompletionProposal (org.eclipse.jdt.internal.ui.text.java.LazyJavaCompletionProposal)8 ViewerCell (org.eclipse.jface.viewers.ViewerCell)5 GridData (org.eclipse.swt.layout.GridData)5 Table (org.eclipse.swt.widgets.Table)5 Entry (java.util.Map.Entry)4 StyledCellLabelProvider (org.eclipse.jface.viewers.StyledCellLabelProvider)4 Capability (org.osgi.resource.Capability)4 ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)3 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)3 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)3 Styler (org.eclipse.jface.viewers.StyledString.Styler)3 TableViewer (org.eclipse.jface.viewers.TableViewer)3 GridLayout (org.eclipse.swt.layout.GridLayout)3 Composite (org.eclipse.swt.widgets.Composite)3 Label (org.eclipse.swt.widgets.Label)3 Version (org.osgi.framework.Version)3 Resource (org.osgi.resource.Resource)3