Java 类org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider 实例源码

项目: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);
}
项目: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();
}
项目:Environment    文件:AlternativeResourceNode.java   
public AlternativeResourceNode(IEclipseContext context, IFile file) {
    super(context, file.getName(), null, null);

    setResource(file);

    ModelType type = ModelType.getModelType(file.getFileExtension());
    if(type != null){
        setName(type.getDisplayName());
    }
    else{
        setName(file.getName());
    }

    getContext().set(IExplorerConstants.NODE_DATA, file);
    getContext().set(IFile.class, file);
    getContext().set(IStyledLabelProvider.class, DEFAULT_LABEL_STYLE);
}
项目:dsl-devkit    文件:AbstractOutlineTreeProvider.java   
/**
 * Default for textDispatcher with two arguments.
 *
 * @param modelElement
 *          the {@link EObject} model element
 * @return the label text
 */
// CHECKSTYLE:CHECK-OFF Name (dispatcher enforces names starting with underscore)
protected Object _text(final Object modelElement) {
  // CHECKSTYLE:CHECK-ON
  if (getLabelProvider() instanceof IStyledLabelProvider) {
    return ((IStyledLabelProvider) getLabelProvider()).getStyledText(modelElement);
  } else {
    return getLabelProvider().getText(modelElement);
  }
}
项目:tlaplus    文件:FilteredItemsSelectionDialog.java   
/**
 * Creates a new instance of the class.
 *
 * @param provider
 *            the label provider for all items, not <code>null</code>
 * @param selectionDecorator
 *            the decorator for selected items, can be <code>null</code>
 */
public ItemsListLabelProvider(ILabelProvider provider,
        ILabelDecorator selectionDecorator) {
    Assert.isNotNull(provider);
    this.provider = provider;
    this.selectionDecorator = selectionDecorator;

    setOwnerDrawEnabled(showColoredLabels() && provider instanceof IStyledLabelProvider);

    provider.addListener(this);

    if (selectionDecorator != null) {
        selectionDecorator.addListener(this);
    }
}
项目:tlaplus    文件:FilteredItemsSelectionDialog.java   
/**
 * Sets new label provider.
 *
 * @param newProvider
 *            new label provider for items in the list, not
 *            <code>null</code>
 */
public void setProvider(ILabelProvider newProvider) {
    Assert.isNotNull(newProvider);
    provider.removeListener(this);
    provider.dispose();

    provider = newProvider;

    if (provider != null) {
        provider.addListener(this);
    }

    setOwnerDrawEnabled(showColoredLabels() && provider instanceof IStyledLabelProvider);
}
项目:tlaplus    文件:FilteredItemsSelectionDialog.java   
private StyledString getStyledText(Object element,
        IStyledLabelProvider provider) {
    StyledString string = provider.getStyledText(element);

    if (selectionDecorator != null && isSelected(element)) {
        String decorated = selectionDecorator.decorateText(string
                .getString(), element);
        return StyledCellLabelProvider.styleDecoratedString(decorated, null, string);
        // no need to add colors when element is selected
    }
    return string;
}
项目:bts    文件:GlobalDescriptionLabelProvider.java   
public StyledString getStyledText(Object element) {
    if (element == null) {
        return new StyledString(Messages.GlobalDescriptionLabelProvider_0);
    } else {
        ILabelProvider descriptionLabelProvider = lookupDescriptionLabelProvider(element);
        if (descriptionLabelProvider instanceof IStyledLabelProvider)
            return ((IStyledLabelProvider) descriptionLabelProvider).getStyledText(element);
        else if(descriptionLabelProvider != null) {
            return new StyledString(descriptionLabelProvider.getText(element));
        } else {
            return new StyledString(element.toString());
        }
    }
}
项目:bts    文件:DefaultOutlineTreeProvider.java   
/**
 * Default for textDispatcher
 */
protected Object _text(Object modelElement) {
    if (labelProvider instanceof IStyledLabelProvider)
        return ((IStyledLabelProvider) labelProvider).getStyledText(modelElement);
    else
        return labelProvider.getText(modelElement);
}
项目:hssd    文件:MultiPageEditorWithTextPage.java   
protected ILabelProvider wrapLabelProvider(ILabelProvider labelProvider) {
    if(labelProvider instanceof IStyledLabelProvider) {
        return new DecoratingLabelProvider(
                (IStyledLabelProvider)labelProvider);
    }
    return labelProvider;
}
项目:Eclipse-Postfix-Code-Completion    文件:SearchLabelProvider.java   
protected StyledString getStyledParticipantText(Object element) {
    ILabelProvider labelProvider= getLabelProvider(element);
    if (labelProvider instanceof IStyledLabelProvider)
        return ((IStyledLabelProvider) labelProvider).getStyledText(element);
    if (labelProvider != null)
        return new StyledString(labelProvider.getText(element));
    return new StyledString();
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:SearchLabelProvider.java   
protected StyledString getStyledParticipantText(Object element) {
    ILabelProvider labelProvider= getLabelProvider(element);
    if (labelProvider instanceof IStyledLabelProvider)
        return ((IStyledLabelProvider) labelProvider).getStyledText(element);
    if (labelProvider != null)
        return new StyledString(labelProvider.getText(element));
    return new StyledString();
}
项目:eclipse-jenkins-editor    文件:JenkinsQuickOutlineDialog.java   
protected IStyledLabelProvider createdStyledLabelProvider() {
    IStyledLabelProvider labelProvider = new JenkinsEditorOutlineLabelProvider();
    return labelProvider;
}
项目:egradle    文件:AbstractGroovyBasedQuickOutline.java   
@Override
protected IBaseLabelProvider createLabelProvider() {
    IStyledLabelProvider labelProvider = createdStyledLabelProvider();
    return new DelegatingStyledCellLabelProvider(labelProvider);
}
项目:egradle    文件:GradleQuickOutlineDialog.java   
protected IStyledLabelProvider createdStyledLabelProvider() {
    IStyledLabelProvider labelProvider = new GradleEditorOutlineLabelProvider();
    return labelProvider;
}
项目:bts    文件:BackgroundOutlineTreeProvider.java   
protected Object getText(Object modelElement) {
    if (labelProvider instanceof IStyledLabelProvider)
        return ((IStyledLabelProvider) labelProvider).getStyledText(modelElement);
    else
        return labelProvider.getText(modelElement);
}
项目:OpenSPIFe    文件:PlanSearchResultPage.java   
private void initializeViewer(ColumnViewer viewer, boolean flat) {
    this.viewer = viewer;

    // set content provider
    fContentProvider= new PlanSearchContentProvider(flat);
    viewer.setContentProvider(fContentProvider);

    // set label provider
    IStyledLabelProvider styleLabel = getStyledLabelProvider();
    ILabelDecorator labelDecorator = getLabelDecorator();
    viewer.setLabelProvider(new DecoratingStyledCellLabelProvider(styleLabel, labelDecorator, null));
    viewer.setUseHashlookup(true);

    // set listeners
    viewer.addSelectionChangedListener(new ISelectionChangedListener(){
        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection realSelect = (IStructuredSelection) event.getSelection();
            if (realSelect == null || realSelect.size() == 0){
                return;
            }           
            Object elem = realSelect.getFirstElement();
            if (elem instanceof EPlanElement){
                EPlan selectedPlan = EPlanUtils.getPlan((EPlanElement)elem);
                IWorkbench workbench = PlatformUI.getWorkbench();
                for (IWorkbenchWindow w : workbench.getWorkbenchWindows()) {
                    for (IWorkbenchPage p : w.getPages()) {
                        for (IEditorPart part : p.getEditors()) {
                            EPlan plan = CommonUtils.getAdapter(part, EPlan.class);
                            if (selectedPlan.equals(plan)){
                                //PlanEditorUtil.openPlanEditor(plan, w, true);
                                ISelectionProvider provider = part.getSite().getSelectionProvider();
                                provider.setSelection(realSelect);
                                IWorkbenchWindow activeWorkbenchWindow = workbench.getActiveWorkbenchWindow();
                                if(activeWorkbenchWindow != null) {
                                    IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
                                    if(activePage != null) {
                                        IViewPart searchView = activePage.findView("org.eclipse.search.ui.views.SearchView");
                                        if(searchView != null) {
                                            IWorkbenchPartSite site = searchView.getSite();
                                            Shell shell = site.getShell();
                                            shell.moveAbove(part.getSite().getShell());
                                        }

                                    }
                                }
                                return;
                            }
                        }
                    }
                }
            }
        }   
    });
}
项目:Environment    文件:ExplorerLabelProvider.java   
@Override
public StyledString getStyledText(Object element) {
    if(element instanceof IExplorerNode){
        IExplorerNode node = (IExplorerNode)element;

        StyledString currentText = null;

        IStyledLabelProvider styledLabelProvider = (IStyledLabelProvider)node.getAdapter(IStyledLabelProvider.class);
        if(styledLabelProvider != null){
            currentText = styledLabelProvider.getStyledText(element);
        }

        ILabelProvider labelProvider = (ILabelProvider)node.getAdapter(ILabelProvider.class);
        if(currentText == null && labelProvider != null){
            String text = labelProvider.getText(element);
            currentText = new StyledString(text, DEFAULT_STYLER);
        }

        ILabelDecorator labelDecorator = node.getContext().get(ILabelDecorator.class);

        if(labelDecorator != null){

            if(currentText == null){
                currentText = new StyledString(node.getName(), DEFAULT_STYLER);
            }

            String decoratedText = labelDecorator.decorateText(currentText.getString(), element);
            currentText = StyledCellLabelProvider.styleDecoratedString(decoratedText, DEFAULT_DECORATOR_STYLER, currentText);
        }

        if(currentText != null){
            return currentText;
        }

        if(element instanceof AlternativeNode){
            return new StyledString(node.getName());
        }
        if(element instanceof AlternativeResourceNode){
            return new StyledString(node.getName());
        }

        return new StyledString(node.getName(), DEFAULT_STYLER);
    }
    return new StyledString(element.toString(), DEFAULT_STYLER);
}
项目:egradle    文件:AbstractGroovyBasedQuickOutline.java   
protected abstract IStyledLabelProvider createdStyledLabelProvider() ;
项目:egradle    文件:AbstractGroovyBasedContentOutlinePage.java   
protected abstract IStyledLabelProvider createStyledLabelProvider();