org.eclipse.jface.viewers.ILabelProvider Java Examples
The following examples show how to use
org.eclipse.jface.viewers.ILabelProvider.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CTableTreeViewer.java From nebula with Eclipse Public License 2.0 | 6 votes |
protected void doUpdateCell(int index, CContainerCell cell, Object element, String[] properties) { super.doUpdateCell(index, cell, element, properties); IBaseLabelProvider prov = (IBaseLabelProvider) getLabelProvider(); if(prov != null) { CTableTreeCell cttc = (CTableTreeCell) cell; String text = null; if(prov instanceof ICContainerLabelProvider) { cttc.setImages(((ICContainerLabelProvider) prov).getColumnImages(element, index)); text = ((ITableLabelProvider) prov).getColumnText(element, index); } else if(prov instanceof ITableLabelProvider) { cttc.setImage(((ITableLabelProvider) prov).getColumnImage(element, index)); text = ((ITableLabelProvider) prov).getColumnText(element, index); } else if(prov instanceof ILabelProvider) { cttc.setImage(((ILabelProvider) prov).getImage(element)); text = ((ILabelProvider) prov).getText(element); } if(text == null) text = ""; //$NON-NLS-1$ cttc.setText(text); } }
Example #2
Source File: BonitaTreeViewer.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Override protected boolean isLeafMatch(final org.eclipse.jface.viewers.Viewer viewer, final Object element) { final String labelText = ((ILabelProvider) ((StructuredViewer) viewer).getLabelProvider()).getText(element); if (labelText == null) { return false; } if (wordMatches(labelText)) { return true; } for (final EAttribute attribute : ((EObject) element).eClass().getEAllAttributes()) { final Object value = ((EObject) element).eGet(attribute); if (value != null && attribute.getEType().getName().equals("EString") && wordMatches(value.toString())) { return true; } } return false; }
Example #3
Source File: AddGetterSetterAction.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public GetterSetterTreeSelectionDialog(Shell parent, ILabelProvider labelProvider, AddGetterSetterContentProvider contentProvider, CompilationUnitEditor editor, IType type) throws JavaModelException { super(parent, labelProvider, contentProvider, editor, type, false); fContentProvider= contentProvider; fPreviousSelectedFinals= new ArrayList<GetterSetterEntry>(); // http://bugs.eclipse.org/bugs/show_bug.cgi?id=19253 IDialogSettings dialogSettings= JavaPlugin.getDefault().getDialogSettings(); fSettings= dialogSettings.getSection(SETTINGS_SECTION); if (fSettings == null) { fSettings= dialogSettings.addNewSection(SETTINGS_SECTION); fSettings.put(SORT_ORDER, false); fSettings.put(ALLOW_SETTERS_FOR_FINALS, false); } fSortOrder= fSettings.getBoolean(SORT_ORDER); fAllowSettersForFinals= fSettings.getBoolean(ALLOW_SETTERS_FOR_FINALS); fSettersForFinalFieldsFilter= new SettersForFinalFieldsFilter(contentProvider); }
Example #4
Source File: GenerateConstructorUsingFieldsSelectionDialog.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public GenerateConstructorUsingFieldsSelectionDialog(Shell parent, ILabelProvider labelProvider, GenerateConstructorUsingFieldsContentProvider contentProvider, CompilationUnitEditor editor, IType type, IMethodBinding[] superConstructors) throws JavaModelException { super(parent, labelProvider, contentProvider, editor, type, true); fTreeViewerAdapter= new GenerateConstructorUsingFieldsTreeViewerAdapter(); fSuperConstructors= superConstructors; IDialogSettings dialogSettings= JavaPlugin.getDefault().getDialogSettings(); fGenConstructorSettings= dialogSettings.getSection(SETTINGS_SECTION); if (fGenConstructorSettings == null) { fGenConstructorSettings= dialogSettings.addNewSection(SETTINGS_SECTION); fGenConstructorSettings.put(OMIT_SUPER, false); } final boolean isEnum= type.isEnum(); fOmitSuper= fGenConstructorSettings.getBoolean(OMIT_SUPER) || isEnum; if (isEnum) setVisibility(Modifier.PRIVATE); }
Example #5
Source File: SearchLabelProvider.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private ILabelProvider getLabelProvider(Object element) { AbstractTextSearchResult input= fPage.getInput(); if (!(input instanceof JavaSearchResult)) return null; IMatchPresentation participant= ((JavaSearchResult) input).getSearchParticpant(element); if (participant == null) return null; ILabelProvider lp= fLabelProviderMap.get(participant); if (lp == null) { lp= participant.createLabelProvider(); fLabelProviderMap.put(participant, lp); Object[] listeners= fListeners.getListeners(); for (int i= 0; i < listeners.length; i++) { lp.addListener((ILabelProviderListener) listeners[i]); } } return lp; }
Example #6
Source File: AbstractLaunchShortcut.java From Pydev with Eclipse Public License 1.0 | 6 votes |
/** * COPIED/MODIFIED from AntLaunchShortcut */ protected ILaunchConfiguration chooseConfig(List<ILaunchConfiguration> configs) { if (configs.isEmpty()) { return null; } ILabelProvider labelProvider = DebugUITools.newDebugModelPresentation(); ElementListSelectionDialog dialog = new ElementListSelectionDialog(Display.getDefault().getActiveShell(), labelProvider); dialog.setElements(configs.toArray(new ILaunchConfiguration[configs.size()])); dialog.setTitle("Pick a Python configuration"); dialog.setMessage("Choose a python configuration to run"); dialog.setMultipleSelection(false); int result = dialog.open(); labelProvider.dispose(); if (result == Window.OK) { return (ILaunchConfiguration) dialog.getFirstResult(); } else { return null; } }
Example #7
Source File: RoutesKarafRepositoryMavenSetting.java From tesb-studio-se with Apache License 2.0 | 6 votes |
@Override protected RepositoryPreferenceNode createKarafFolderNode(String id, ILabelProvider labelProvider, RepositoryNode node) { RoutesKarafRepositorySettingNode routesKarafNode = null; if (labelProvider == null) { routesKarafNode = new RoutesKarafRepositorySettingNode(id, node); } else { String label = labelProvider.getText(node); ImageDescriptor imageDesc = null; Image image = labelProvider.getImage(node); if (image != null) { imageDesc = ImageDescriptor.createFromImageData(image.getImageData()); } routesKarafNode = new RoutesKarafRepositorySettingNode(id, label, imageDesc, node); } return routesKarafNode; }
Example #8
Source File: ZestContentViewer.java From gef with Eclipse Public License 2.0 | 6 votes |
/** * Creates graph {@link Node nodes} and {@link Edge edges} from the given array * of <i>contentNodes</i>. * * @param graphContentProvider This viewer's {@link IGraphContentProvider} for * convenience. * @param labelProvider This viewer's {@link ILabelProvider} for * convenience. * @param graph The {@link Graph} for which nodes and edges are * created. * @param contentNodes Content elements which represent nodes that are * to be created together with the edges between * them. */ protected void createNodesAndEdges(IGraphContentProvider graphContentProvider, ILabelProvider labelProvider, Graph graph, Object[] contentNodes) { // create nodes List<Node> allNodes = new ArrayList<>(); for (Object node : contentNodes) { Node graphNode = createNode(node, graphContentProvider, labelProvider); allNodes.add(graphNode); } graph.getNodes().addAll(allNodes); // create edges List<Edge> allEdges = new ArrayList<>(); for (Object contentSourceNode : contentNodes) { Node sourceNode = contentNodeMap.get(contentSourceNode); Object[] connectedTo = graphContentProvider.getAdjacentNodes(contentSourceNode); if (connectedTo != null) { for (Object contentTargetNode : connectedTo) { Node targetNode = contentNodeMap.get(contentTargetNode); Edge edge = createEdge(labelProvider, contentSourceNode, sourceNode, contentTargetNode, targetNode); allEdges.add(edge); } } } graph.getEdges().addAll(allEdges); }
Example #9
Source File: AbstractInformationControl.java From typescript.java with MIT License | 6 votes |
@Override public boolean select(Viewer viewer, Object parentElement, Object element) { // Element passes the filter if the string matcher is undefined or // the // viewer is not a tree viewer if ((stringMatcher == null) || !(viewer instanceof TreeViewer)) { return true; } TreeViewer aTreeViewer = (TreeViewer) viewer; // Match the pattern against the label of the given element String matchName = ((ILabelProvider) aTreeViewer.getLabelProvider()).getText(element); // Element passes the filter if it matches the pattern if ((matchName != null) && stringMatcher.match(matchName)) { return true; } // Determine whether the element has children that pass the filter return hasUnfilteredChild(aTreeViewer, element); }
Example #10
Source File: FilteredItemsSelectionDialog.java From tlaplus with MIT License | 5 votes |
/** * 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); } }
Example #11
Source File: LabeledInputField.java From elexis-3-core with Eclipse Public License 1.0 | 5 votes |
public InputData(String anzeige, String feldname, String hashname, Typ typ, org.eclipse.jface.viewers.IContentProvider contentProvider, ILabelProvider labelProvider, IStructuredSelectionResolver selectionResolver, Object input){ sAnzeige = anzeige; sFeldname = feldname; sHashname = hashname; ext = input; tFeldTyp = typ; this.contentProvider = contentProvider; this.labelProvider = labelProvider; this.selectionResolver = selectionResolver; }
Example #12
Source File: MonthCalendarViewer.java From nebula with Eclipse Public License 2.0 | 5 votes |
public void setLabelProvider(IBaseLabelProvider labelProvider) { if (!(labelProvider instanceof ILabelProvider)) { throw new IllegalArgumentException( "label provider must be of type ILabelProvider"); } super.setLabelProvider(labelProvider); }
Example #13
Source File: GlobalDescriptionLabelProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override public String getText(Object element) { if (element == null) { return Messages.GlobalDescriptionLabelProvider_0; } else { ILabelProvider descriptionLabelProvider = lookupDescriptionLabelProvider(element); if (descriptionLabelProvider != null) { return descriptionLabelProvider.getText(element); } else { return element.toString(); } } }
Example #14
Source File: NewSourceFolderWizardPage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private IFolder chooseFolder(String title, String message, IPath initialPath) { Class<?>[] acceptedClasses= new Class[] { IFolder.class }; ISelectionStatusValidator validator= new TypedElementSelectionValidator(acceptedClasses, false); ViewerFilter filter= new TypedViewerFilter(acceptedClasses, null); ILabelProvider lp= new WorkbenchLabelProvider(); ITreeContentProvider cp= new WorkbenchContentProvider(); IProject currProject= fCurrJProject.getProject(); ElementTreeSelectionDialog dialog= new ElementTreeSelectionDialog(getShell(), lp, cp); dialog.setValidator(validator); dialog.setTitle(title); dialog.setMessage(message); dialog.addFilter(filter); dialog.setInput(currProject); dialog.setComparator(new ResourceComparator(ResourceComparator.NAME)); IResource res= currProject.findMember(initialPath); if (res != null) { dialog.setInitialSelection(res); } if (dialog.open() == Window.OK) { return (IFolder) dialog.getFirstResult(); } return null; }
Example #15
Source File: AbstractHistoryElementListSelectionDialog.java From Pydev with Eclipse Public License 1.0 | 5 votes |
/** * Constructs a list selection dialog. * @param parent The parent for the list. * @param renderer ILabelProvider for the list */ protected AbstractHistoryElementListSelectionDialog(Shell parent, ILabelProvider renderer) { super(parent); fRenderer = renderer; int shellStyle = getShellStyle(); setShellStyle(shellStyle | SWT.MAX | SWT.RESIZE); }
Example #16
Source File: ElementTreeSelectionDialog.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
/** * Constructs an instance of <code>ElementTreeSelectionDialog</code>. * @param parent The parent shell for the dialog * @param labelProvider the label provider to render the entries * @param contentProvider the content provider to evaluate the tree structure */ public ElementTreeSelectionDialog(Shell parent, ILabelProvider labelProvider, ITreeContentProvider contentProvider) { super(parent); fLabelProvider = labelProvider; fContentProvider = contentProvider; setResult(new ArrayList(0)); setStatusLineAboveButtons(true); }
Example #17
Source File: CheckboxTreeAndListGroup.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Sets the tree viewer's providers to those passed * * @param contentProvider ITreeContentProvider * @param labelProvider ILabelProvider */ public void setTreeProviders( ITreeContentProvider contentProvider, ILabelProvider labelProvider) { fTreeViewer.setContentProvider(contentProvider); fTreeViewer.setLabelProvider(labelProvider); }
Example #18
Source File: PackageFilterEditor.java From eclipse-cs with GNU Lesser General Public License v2.1 | 5 votes |
/** * Constructs an instance of <code>ElementTreeSelectionDialog</code>. * * @param parent * The shell to parent from. * @param labelProvider * the label provider to render the entries * @param contentProvider * the content provider to evaluate the tree structure */ public CheckedTreeSelectionDialog(Shell parent, ILabelProvider labelProvider, ITreeContentProvider contentProvider) { super(parent); mLabelProvider = labelProvider; mContentProvider = contentProvider; setResult(new ArrayList<>(0)); setStatusLineAboveButtons(true); mExpandedElements = null; int shellStyle = getShellStyle(); setShellStyle(shellStyle | SWT.MAX | SWT.RESIZE); }
Example #19
Source File: ResourceTree.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
public ResourceTree(Composite parent, ITreeContentProvider contentProvider, ILabelProvider labelProvider) { super(parent); this.contentProvider = contentProvider; this.labelProvider = labelProvider; tree = this.getTree(); tree.setLayoutData(new GridData(GridData.FILL_BOTH)); this.setLabelProvider(this.labelProvider); this.setContentProvider(this.contentProvider); this.addCheckStateListener(this); this.addDoubleClickListener(this); }
Example #20
Source File: CategoryFilterActionGroup.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public CategoryFilterSelectionDialog(Shell parent, List<String> categories, List<String> selectedCategories) { super(parent); setTitle(ActionMessages.CategoryFilterActionGroup_JavaCategoryFilter_title); String[] buttons= { ActionMessages.CategoryFilterActionGroup_SelectAllCategories, ActionMessages.CategoryFilterActionGroup_DeselectAllCategories }; fCategoryList= new CheckedListDialogField<String>(this, buttons, new ILabelProvider() { public Image getImage(Object element) {return null;} public String getText(Object element) {return (String)element;} public void addListener(ILabelProviderListener listener) {} public void dispose() {} public boolean isLabelProperty(Object element, String property) {return false;} public void removeListener(ILabelProviderListener listener) {} }); fCategoryList.addElements(categories); fCategoryList.setViewerComparator(new ViewerComparator()); fCategoryList.setLabelText(ActionMessages.CategoryFilterActionGroup_SelectCategoriesDescription); fCategoryList.checkAll(true); for (Iterator<String> iter= selectedCategories.iterator(); iter.hasNext();) { String selected= iter.next(); fCategoryList.setChecked(selected, false); } if (categories.size() == 0) { fCategoryList.setEnabled(false); } }
Example #21
Source File: JavadocConfigurationBlock.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private String chooseWorkspaceArchive() { String initSelection= fArchiveField.getText(); ILabelProvider lp= new WorkbenchLabelProvider(); ITreeContentProvider cp= new WorkbenchContentProvider(); Class<?>[] acceptedClasses= new Class[] { IFile.class }; TypedElementSelectionValidator validator= new TypedElementSelectionValidator(acceptedClasses, true); IResource initSel= null; IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot(); if (initSelection.length() > 0) { initSel= root.findMember(new Path(initSelection)); } FilteredElementTreeSelectionDialog dialog= new FilteredElementTreeSelectionDialog(fShell, lp, cp); dialog.setInitialFilter(ArchiveFileFilter.JARZIP_FILTER_STRING); dialog.setAllowMultiple(false); dialog.setValidator(validator); dialog.setComparator(new ResourceComparator(ResourceComparator.NAME)); dialog.setTitle(PreferencesMessages.JavadocConfigurationBlock_workspace_archive_selection_dialog_title); dialog.setMessage(PreferencesMessages.JavadocConfigurationBlock_workspace_archive_selection_dialog_description); dialog.setInput(root); dialog.setInitialSelection(initSel); dialog.setHelpAvailable(false); if (dialog.open() == Window.OK) { IResource res= (IResource) dialog.getFirstResult(); return res.getFullPath().makeRelative().toString(); } return null; }
Example #22
Source File: NewResourceFileDialog.java From birt with Eclipse Public License 1.0 | 5 votes |
/** * The constructor. * * @param parent * @param labelProvider * @param contentProvider */ public NewResourceFileDialog( Shell parent, ILabelProvider labelProvider, ITreeContentProvider contentProvider ) { super( parent, labelProvider, contentProvider ); setDoubleClickSelects( false ); setSorter( new FileViewerSorter( ) ); }
Example #23
Source File: CompositeOutlineLabelProvider.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
@Override public String getText(Object element) { if (element instanceof ILanguageNode) { String language = ((ILanguageNode) element).getLanguage(); ILabelProvider provider = fProvidersByLanguage.get(language); if (provider != null) { return provider.getText(element); } } return getDefaultText(element); }
Example #24
Source File: JavaEditorBreadcrumb.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Returns the label provider to use for the tool tips. * * @return a label provider for the tool tips */ private ILabelProvider createToolTipLabelProvider() { final AppearanceAwareLabelProvider result= new AppearanceAwareLabelProvider(AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS | JavaElementLabels.F_APP_TYPE_SIGNATURE | JavaElementLabels.ALL_CATEGORY, JavaElementImageProvider.SMALL_ICONS | AppearanceAwareLabelProvider.DEFAULT_IMAGEFLAGS); return new DecoratingJavaLabelProvider(result); }
Example #25
Source File: BreadcrumbViewer.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Creates and returns a new instance of a breadcrumb item. * * @return new instance of a breadcrumb item */ private BreadcrumbItem createItem() { BreadcrumbItem result= new BreadcrumbItem(this, fContainer); result.setLabelProvider((ILabelProvider) getLabelProvider()); if (fToolTipLabelProvider != null) { result.setToolTipLabelProvider(fToolTipLabelProvider); } else { result.setToolTipLabelProvider((ILabelProvider) getLabelProvider()); } result.setContentProvider((ITreeContentProvider) getContentProvider()); return result; }
Example #26
Source File: FilteredItemsSelectionDialog.java From tlaplus with MIT License | 5 votes |
/** * 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); }
Example #27
Source File: PyConfigureExceptionDialog.java From Pydev with Eclipse Public License 1.0 | 5 votes |
public PyConfigureExceptionDialog(Shell parentShell, Object input, IStructuredContentProvider contentProvider, ILabelProvider labelProvider, String message) { super(parentShell); setTitle(WorkbenchMessages.ListSelection_title); this.inputElement = input; this.contentProvider = contentProvider; this.labelProvider = labelProvider; if (message != null) { setMessage(message); } else { setMessage(WorkbenchMessages.ListSelection_message); } }
Example #28
Source File: SearchLabelProvider.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
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(); }
Example #29
Source File: AbstractThemeableEditor.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
protected CommonOutlinePage createOutlinePage() { ITreeContentProvider outlineContentProvider = getOutlineContentProvider(); ILabelProvider outlineLabelProvider = getOutlineLabelProvider(); if (outlineContentProvider == null || outlineLabelProvider == null) { return null; } CommonOutlinePage outline = new CommonOutlinePage(this, getOutlinePreferenceStore()); outline.setContentProvider(outlineContentProvider); outline.setLabelProvider(outlineLabelProvider); return outline; }
Example #30
Source File: AbstractInformationControl.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public boolean select(Viewer viewer, Object parentElement, Object element) { JavaElementPrefixPatternMatcher matcher= getMatcher(); if (matcher == null || !(viewer instanceof TreeViewer)) return true; TreeViewer treeViewer= (TreeViewer) viewer; String matchName= ((ILabelProvider) treeViewer.getLabelProvider()).getText(element); matchName= TextProcessor.deprocess(matchName); if (matchName != null && matcher.matches(matchName)) return true; return hasUnfilteredChild(treeViewer, element); }