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 Project: typescript.java   Author: angelozerr   File: AbstractInformationControl.java    License: MIT License 6 votes vote down vote up
@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 #2
Source Project: nebula   Author: eclipse   File: CTableTreeViewer.java    License: Eclipse Public License 2.0 6 votes vote down vote up
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 #3
Source Project: Eclipse-Postfix-Code-Completion   Author: trylimits   File: AddGetterSetterAction.java    License: Eclipse Public License 1.0 6 votes vote down vote up
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 Project: tesb-studio-se   Author: Talend   File: RoutesKarafRepositoryMavenSetting.java    License: Apache License 2.0 6 votes vote down vote up
@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 #5
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 #6
Source Project: Eclipse-Postfix-Code-Completion   Author: trylimits   File: SearchLabelProvider.java    License: Eclipse Public License 1.0 6 votes vote down vote up
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 #7
Source Project: gef   Author: eclipse   File: ZestContentViewer.java    License: Eclipse Public License 2.0 6 votes vote down vote up
/**
 * 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 #8
Source Project: bonita-studio   Author: bonitasoft   File: BonitaTreeViewer.java    License: GNU General Public License v2.0 6 votes vote down vote up
@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 #9
Source Project: Pydev   Author: fabioz   File: AbstractLaunchShortcut.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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 #10
Source Project: nebula   Author: eclipse   File: MonthCalendarViewer.java    License: Eclipse Public License 2.0 5 votes vote down vote up
public void setLabelProvider(IBaseLabelProvider labelProvider) {
	if (!(labelProvider instanceof ILabelProvider)) {
		throw new IllegalArgumentException(
				"label provider must be of type ILabelProvider");
	}
	super.setLabelProvider(labelProvider);
}
 
Example #11
Source Project: tlaplus   Author: tlaplus   File: FilteredItemsSelectionDialog.java    License: MIT License 5 votes vote down vote up
/**
 * 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 #12
Source Project: Pydev   Author: fabioz   File: AbstractHistoryElementListSelectionDialog.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 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 #13
Source Project: Eclipse-Postfix-Code-Completion   Author: trylimits   File: CheckboxTreeAndListGroup.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
 *	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 #14
Source Project: eclipse-cs   Author: checkstyle   File: PackageFilterEditor.java    License: GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * 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 #15
Source Project: tlaplus   Author: tlaplus   File: FilteredItemsSelectionDialog.java    License: MIT License 5 votes vote down vote up
public void refresh() {
	Object input = this.getInput();
	if (input != null) {
		ILabelProvider labelProvider = (ILabelProvider) getLabelProvider();
		doRefresh(labelProvider.getText(input), labelProvider
				.getImage(input));
	} else {
		doRefresh(null, null);
	}
}
 
Example #16
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 #17
Source Project: APICloud-Studio   Author: apicloudcom   File: CompositeOutlineLabelProvider.java    License: GNU General Public License v3.0 5 votes vote down vote up
@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 #18
Source Project: Eclipse-Postfix-Code-Completion   Author: trylimits   File: JavaEditorBreadcrumb.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 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 #19
Source Project: tlaplus   Author: tlaplus   File: FilteredItemsSelectionDialog.java    License: MIT License 5 votes vote down vote up
/**
 * 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 #20
@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);
}
 
Example #21
Source Project: Eclipse-Postfix-Code-Completion   Author: trylimits   File: SearchLabelProvider.java    License: Eclipse Public License 1.0 5 votes vote down vote up
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 #22
Source Project: tmxeditor8   Author: heartsome   File: ElementTreeSelectionDialog.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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 #23
Source Project: Eclipse-Postfix-Code-Completion   Author: trylimits   File: BreadcrumbViewer.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 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 #24
Source Project: APICloud-Studio   Author: apicloudcom   File: AbstractThemeableEditor.java    License: GNU General Public License v3.0 5 votes vote down vote up
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 #25
Source Project: Pydev   Author: fabioz   File: PyConfigureExceptionDialog.java    License: Eclipse Public License 1.0 5 votes vote down vote up
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 #26
Source Project: birt   Author: eclipse   File: NewResourceFileDialog.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 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 #27
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 #28
Source Project: xtext-eclipse   Author: eclipse   File: GlobalDescriptionLabelProvider.java    License: Eclipse Public License 2.0 5 votes vote down vote up
@Override
public Image getImage(Object element) {
	ILabelProvider descriptionLabelProvider = lookupDescriptionLabelProvider(element);
	if (descriptionLabelProvider != null) {
		return descriptionLabelProvider.getImage(element);
	} else {
		return null;
	}
}
 
Example #29
Source Project: xtext-eclipse   Author: eclipse   File: GlobalDescriptionLabelProvider.java    License: Eclipse Public License 2.0 5 votes vote down vote up
@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 #30
Source Project: translationstudio8   Author: heartsome   File: ResourceTree.java    License: GNU General Public License v2.0 5 votes vote down vote up
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);
	
}