Search in sources :

Example 51 with StyledString

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

the class CompletionProposalCollector method createFieldWithCastedReceiverProposal.

/**
	 * Creates the Java completion proposal for the JDT Core
	 * {@link org.eclipse.jdt.core.CompletionProposal#FIELD_REF_WITH_CASTED_RECEIVER} proposal.
	 *
	 * @param proposal the JDT Core proposal
	 * @return the Java completion proposal
	 * @since 3.4
	 */
private IJavaCompletionProposal createFieldWithCastedReceiverProposal(CompletionProposal proposal) {
    String completion = String.valueOf(proposal.getCompletion());
    //$NON-NLS-1$
    completion = CodeFormatterUtil.format(CodeFormatter.K_EXPRESSION, completion, 0, "\n", fJavaProject);
    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 JavaFieldWithCastedReceiverCompletionProposal(completion, start, length, image, label, relevance, getContext().isInJavadoc(), getInvocationContext(), proposal);
    if (fJavaProject != null)
        javaProposal.setProposalInfo(new FieldProposalInfo(fJavaProject, proposal));
    javaProposal.setTriggerCharacters(VAR_TRIGGER);
    return javaProposal;
}
Also used : JavaFieldWithCastedReceiverCompletionProposal(org.eclipse.jdt.internal.ui.text.java.JavaFieldWithCastedReceiverCompletionProposal) StyledString(org.eclipse.jface.viewers.StyledString) StyledString(org.eclipse.jface.viewers.StyledString) Image(org.eclipse.swt.graphics.Image) JavaCompletionProposal(org.eclipse.jdt.internal.ui.text.java.JavaCompletionProposal) LazyJavaCompletionProposal(org.eclipse.jdt.internal.ui.text.java.LazyJavaCompletionProposal) FieldProposalInfo(org.eclipse.jdt.internal.ui.text.java.FieldProposalInfo)

Example 52 with StyledString

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

the class CompletionProposalCollector method createLocalVariableProposal.

private IJavaCompletionProposal createLocalVariableProposal(CompletionProposal proposal) {
    String completion = String.valueOf(proposal.getCompletion());
    int start = proposal.getReplaceStart();
    int length = getLength(proposal);
    Image image = getImage(fLabelProvider.createLocalImageDescriptor(proposal));
    StyledString label = fLabelProvider.createSimpleLabelWithType(proposal);
    int relevance = computeRelevance(proposal);
    final JavaCompletionProposal javaProposal = new JavaCompletionProposal(completion, start, length, image, label, relevance);
    javaProposal.setTriggerCharacters(VAR_TRIGGER);
    return javaProposal;
}
Also used : StyledString(org.eclipse.jface.viewers.StyledString) StyledString(org.eclipse.jface.viewers.StyledString) Image(org.eclipse.swt.graphics.Image) JavaCompletionProposal(org.eclipse.jdt.internal.ui.text.java.JavaCompletionProposal) LazyJavaCompletionProposal(org.eclipse.jdt.internal.ui.text.java.LazyJavaCompletionProposal)

Example 53 with StyledString

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

the class CompletionProposalCollector method createAnonymousTypeProposal.

private IJavaCompletionProposal createAnonymousTypeProposal(CompletionProposal proposal, JavaContentAssistInvocationContext invocationContext) {
    if (fCompilationUnit == null || fJavaProject == null)
        return null;
    char[] declarationKey = proposal.getDeclarationKey();
    if (declarationKey == null)
        return null;
    try {
        IJavaElement element = fJavaProject.findElement(new String(declarationKey), null);
        if (!(element instanceof IType))
            return null;
        IType type = (IType) element;
        String completion = String.valueOf(proposal.getCompletion());
        int start = proposal.getReplaceStart();
        int length = getLength(proposal);
        int relevance = computeRelevance(proposal);
        StyledString label = fLabelProvider.createAnonymousTypeLabel(proposal);
        JavaCompletionProposal javaProposal = new AnonymousTypeCompletionProposal(fJavaProject, fCompilationUnit, invocationContext, start, length, completion, label, String.valueOf(proposal.getDeclarationSignature()), type, relevance);
        javaProposal.setProposalInfo(new AnonymousTypeProposalInfo(fJavaProject, proposal));
        return javaProposal;
    } catch (JavaModelException e) {
        return null;
    }
}
Also used : IJavaElement(org.eclipse.jdt.core.IJavaElement) JavaModelException(org.eclipse.jdt.core.JavaModelException) AnonymousTypeProposalInfo(org.eclipse.jdt.internal.ui.text.java.AnonymousTypeProposalInfo) StyledString(org.eclipse.jface.viewers.StyledString) StyledString(org.eclipse.jface.viewers.StyledString) AnonymousTypeCompletionProposal(org.eclipse.jdt.internal.ui.text.java.AnonymousTypeCompletionProposal) IType(org.eclipse.jdt.core.IType) JavaCompletionProposal(org.eclipse.jdt.internal.ui.text.java.JavaCompletionProposal) LazyJavaCompletionProposal(org.eclipse.jdt.internal.ui.text.java.LazyJavaCompletionProposal)

Example 54 with StyledString

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

the class CompletionProposalLabelProvider method createOverrideMethodProposalLabel.

StyledString createOverrideMethodProposalLabel(CompletionProposal methodProposal) {
    StyledString nameBuffer = new StyledString();
    // method name
    nameBuffer.append(methodProposal.getName());
    // parameters
    nameBuffer.append('(');
    appendUnboundedParameterList(nameBuffer, methodProposal);
    nameBuffer.append(')');
    nameBuffer.append(RETURN_TYPE_SEPARATOR);
    // return type
    // TODO remove SignatureUtil.fix83600 call when bugs are fixed
    char[] returnType = createTypeDisplayName(SignatureUtil.getUpperBound(Signature.getReturnType(SignatureUtil.fix83600(methodProposal.getSignature()))));
    nameBuffer.append(returnType);
    // declaring type
    nameBuffer.append(QUALIFIER_SEPARATOR, StyledString.QUALIFIER_STYLER);
    String declaringType = extractDeclaringTypeFQN(methodProposal);
    declaringType = Signature.getSimpleName(declaringType);
    nameBuffer.append(Messages.format(JavaTextMessages.ResultCollector_overridingmethod, BasicElementLabels.getJavaElementName(declaringType)), StyledString.QUALIFIER_STYLER);
    return nameBuffer;
}
Also used : StyledString(org.eclipse.jface.viewers.StyledString) StyledString(org.eclipse.jface.viewers.StyledString)

Example 55 with StyledString

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

the class CompletionProposalLabelProvider method createJavadocTypeProposalLabel.

StyledString createJavadocTypeProposalLabel(char[] fullName) {
    // only display innermost type name as type name, using any
    // enclosing types as qualification
    int qIndex = findSimpleNameStart(fullName);
    //$NON-NLS-1$
    StyledString buf = new StyledString("{@link ");
    buf.append(new String(fullName, qIndex, fullName.length - qIndex));
    buf.append('}');
    if (qIndex > 0) {
        buf.append(JavaElementLabels.CONCAT_STRING, StyledString.QUALIFIER_STYLER);
        buf.append(new String(fullName, 0, qIndex - 1), StyledString.QUALIFIER_STYLER);
    }
    return Strings.markJavaElementLabelLTR(buf);
}
Also used : StyledString(org.eclipse.jface.viewers.StyledString) StyledString(org.eclipse.jface.viewers.StyledString)

Aggregations

StyledString (org.eclipse.jface.viewers.StyledString)95 Image (org.eclipse.swt.graphics.Image)17 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 Styler (org.eclipse.jface.viewers.StyledString.Styler)4 Capability (org.osgi.resource.Capability)4 EObject (org.eclipse.emf.ecore.EObject)3 ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)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 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)2 IStatus (org.eclipse.core.runtime.IStatus)2