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); }
/** * 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(); }
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); }
/** * 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); } }
/** * 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); } }
/** * 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); }
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; }
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()); } } }
/** * Default for textDispatcher */ protected Object _text(Object modelElement) { if (labelProvider instanceof IStyledLabelProvider) return ((IStyledLabelProvider) labelProvider).getStyledText(modelElement); else return labelProvider.getText(modelElement); }
protected ILabelProvider wrapLabelProvider(ILabelProvider labelProvider) { if(labelProvider instanceof IStyledLabelProvider) { return new DecoratingLabelProvider( (IStyledLabelProvider)labelProvider); } return labelProvider; }
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(); }
protected IStyledLabelProvider createdStyledLabelProvider() { IStyledLabelProvider labelProvider = new JenkinsEditorOutlineLabelProvider(); return labelProvider; }
@Override protected IBaseLabelProvider createLabelProvider() { IStyledLabelProvider labelProvider = createdStyledLabelProvider(); return new DelegatingStyledCellLabelProvider(labelProvider); }
protected IStyledLabelProvider createdStyledLabelProvider() { IStyledLabelProvider labelProvider = new GradleEditorOutlineLabelProvider(); return labelProvider; }
protected Object getText(Object modelElement) { if (labelProvider instanceof IStyledLabelProvider) return ((IStyledLabelProvider) labelProvider).getStyledText(modelElement); else return labelProvider.getText(modelElement); }
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; } } } } } } }); }
@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); }
protected abstract IStyledLabelProvider createdStyledLabelProvider() ;
protected abstract IStyledLabelProvider createStyledLabelProvider();