Search in sources :

Example 81 with StyledString

use of org.eclipse.jface.viewers.StyledString in project xtext-xtend by eclipse.

the class XtendJvmLabelProvider method text.

@Override
protected Object text(final JvmField element) {
    String _simpleName = element.getSimpleName();
    StyledString _styledString = new StyledString(_simpleName);
    String _simpleName_1 = element.getType().getSimpleName();
    String _plus = (" : " + _simpleName_1);
    StyledString _styledString_1 = new StyledString(_plus, StyledString.DECORATIONS_STYLER);
    return _styledString.append(_styledString_1);
}
Also used : StyledString(org.eclipse.jface.viewers.StyledString) StyledString(org.eclipse.jface.viewers.StyledString)

Example 82 with StyledString

use of org.eclipse.jface.viewers.StyledString in project xtext-xtend by eclipse.

the class XtendLabelProvider method text.

protected StyledString text(final XtendFunction element) {
    final String simpleName = element.getName();
    if ((simpleName != null)) {
        final QualifiedName qnName = QualifiedName.create(simpleName);
        final QualifiedName operator = this.operatorMapping.getOperator(qnName);
        if ((operator != null)) {
            final StyledString result = this.signature(operator.getFirstSegment(), this._iXtendJvmAssociations.getDirectlyInferredOperation(element));
            result.append(((" (" + simpleName) + ")"), StyledString.COUNTER_STYLER);
            return result;
        }
    }
    return this.signature(element.getName(), this._iXtendJvmAssociations.getDirectlyInferredOperation(element));
}
Also used : QualifiedName(org.eclipse.xtext.naming.QualifiedName) StyledString(org.eclipse.jface.viewers.StyledString) StyledString(org.eclipse.jface.viewers.StyledString)

Example 83 with StyledString

use of org.eclipse.jface.viewers.StyledString in project xtext-xtend by eclipse.

the class XtendProposalProvider method completeMember_Name.

@Override
public void completeMember_Name(final EObject model, Assignment assignment, final ContentAssistContext context, final ICompletionProposalAcceptor acceptor) {
    if (announceProcessing(Lists.newArrayList("completeMember_Name", model, assignment.getFeature()))) {
        EObject previousModel = context.getPreviousModel();
        if (previousModel instanceof XExpression) {
            if (!(previousModel instanceof XBlockExpression)) {
                return;
            }
        }
        if (model instanceof XtendField) {
            // TODO go up type hierarchy and collect all local fields
            final List<XtendField> siblings = EcoreUtil2.getSiblingsOfType(model, XtendField.class);
            Set<String> alreadyTaken = Sets.newHashSet();
            for (XtendField sibling : siblings) {
                alreadyTaken.add(sibling.getName());
            }
            alreadyTaken.addAll(getAllKeywords());
            completions.getVariableProposals(model, XtendPackage.Literals.XTEND_FIELD__TYPE, VariableType.INSTANCE_FIELD, alreadyTaken, new JdtVariableCompletions.CompletionDataAcceptor() {

                @Override
                public void accept(String replaceText, StyledString label, Image img) {
                    acceptor.accept(createCompletionProposal(replaceText, label, img, context));
                }
            });
        } else if (model instanceof XtendFunction) {
            for (QualifiedName operator : operatorMapping.getOperators()) {
                StyledString displayString = new StyledString(operator.getFirstSegment());
                displayString.append(" " + operatorMapping.getMethodName(operator), StyledString.DECORATIONS_STYLER);
                acceptor.accept(createCompletionProposal(operator.getFirstSegment(), displayString, getImage(model), context));
            }
            super.completeMember_Name(model, assignment, context, acceptor);
        } else {
            super.completeMember_Name(model, assignment, context, acceptor);
        }
    }
}
Also used : XBlockExpression(org.eclipse.xtext.xbase.XBlockExpression) XtendFunction(org.eclipse.xtend.core.xtend.XtendFunction) QualifiedName(org.eclipse.xtext.naming.QualifiedName) JdtVariableCompletions(org.eclipse.xtext.common.types.xtext.ui.JdtVariableCompletions) StyledString(org.eclipse.jface.viewers.StyledString) StyledString(org.eclipse.jface.viewers.StyledString) Image(org.eclipse.swt.graphics.Image) XtendField(org.eclipse.xtend.core.xtend.XtendField) EObject(org.eclipse.emf.ecore.EObject) XExpression(org.eclipse.xtext.xbase.XExpression)

Example 84 with StyledString

use of org.eclipse.jface.viewers.StyledString in project xtext-xtend by eclipse.

the class XtendOutlineJvmTreeProvider method buildXtendNode.

@Override
public IXtendOutlineContext buildXtendNode(EObject modelElement, IXtendOutlineContext context) {
    IXtendOutlineContext resultedContext = super.buildXtendNode(modelElement, context);
    if (!context.isShowInherited()) {
        EclipseXtendOutlineContext eclipseXtendOutlineContext = (EclipseXtendOutlineContext) context;
        IOutlineNode parentNode = eclipseXtendOutlineContext.getParentNode();
        if (parentNode instanceof DocumentRootNode) {
            if (modelElement instanceof JvmDeclaredType) {
                JvmDeclaredType jvmDeclaredType = (JvmDeclaredType) modelElement;
                String packageName = jvmDeclaredType.getPackageName();
                if (packageName != null) {
                    EObject rootElement = modelElement.eResource().getContents().get(0);
                    if (rootElement instanceof XtendFile) {
                        XtendFile xtendFile = (XtendFile) rootElement;
                        String primaryPackage = xtendFile.getPackage();
                        if (!packageName.equals(primaryPackage)) {
                            EObjectNode typeNode = (EObjectNode) ((EclipseXtendOutlineContext) resultedContext).getParentNode();
                            if (typeNode.getText() instanceof StyledString) {
                                typeNode.setText(((StyledString) typeNode.getText()).append(new StyledString(" - " + packageName, StyledString.QUALIFIER_STYLER)));
                            }
                        }
                    }
                }
            }
        }
    }
    return resultedContext;
}
Also used : XtendFile(org.eclipse.xtend.core.xtend.XtendFile) DocumentRootNode(org.eclipse.xtext.ui.editor.outline.impl.DocumentRootNode) IXtendOutlineContext(org.eclipse.xtend.ide.common.outline.IXtendOutlineContext) EObject(org.eclipse.emf.ecore.EObject) JvmDeclaredType(org.eclipse.xtext.common.types.JvmDeclaredType) StyledString(org.eclipse.jface.viewers.StyledString) StyledString(org.eclipse.jface.viewers.StyledString) EObjectNode(org.eclipse.xtext.ui.editor.outline.impl.EObjectNode) IOutlineNode(org.eclipse.xtext.ui.editor.outline.IOutlineNode)

Example 85 with StyledString

use of org.eclipse.jface.viewers.StyledString in project eclipse.platform.text by eclipse.

the class FileLabelProvider method getColoredLabelWithCounts.

private StyledString getColoredLabelWithCounts(Object element, StyledString coloredName) {
    AbstractTextSearchResult result = fPage.getInput();
    if (result == null)
        return coloredName;
    int matchCount = result.getMatchCount(element);
    if (matchCount <= 1)
        return coloredName;
    String countInfo = Messages.format(SearchMessages.FileLabelProvider_count_format, Integer.valueOf(matchCount));
    coloredName.append(' ').append(countInfo, StyledString.COUNTER_STYLER);
    return coloredName;
}
Also used : StyledString(org.eclipse.jface.viewers.StyledString) AbstractTextSearchResult(org.eclipse.search.ui.text.AbstractTextSearchResult)

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