本文整理汇总了Java中org.eclipse.jface.viewers.ILabelProvider.getText方法的典型用法代码示例。如果您正苦于以下问题:Java ILabelProvider.getText方法的具体用法?Java ILabelProvider.getText怎么用?Java ILabelProvider.getText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jface.viewers.ILabelProvider
的用法示例。
在下文中一共展示了ILabelProvider.getText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ProjectCombo
import org.eclipse.jface.viewers.ILabelProvider; //导入方法依赖的package包/类
/**
* Creates a new project selector combo
*
* @param helper associated {@link ProjectChooserHelper} for looking up
* projects
* @param parent parent composite to add the combo to
* @param initialProject the initial project to select, or null (which
* will show a "Please Choose Project..." label instead.)
*/
public ProjectCombo(ProjectChooserHelper helper, Composite parent,
IProject initialProject) {
super(parent, SWT.BORDER | SWT.FLAT | SWT.READ_ONLY);
mProject = initialProject;
mAvailableProjects = helper.getAguiProjects(null);
String[] items = new String[mAvailableProjects.length + 1];
items[0] = "--- Choose Project ---";
ILabelProvider labelProvider = new JavaElementLabelProvider(
JavaElementLabelProvider.SHOW_DEFAULT);
int selectionIndex = 0;
for (int i = 0, n = mAvailableProjects.length; i < n; i++) {
IProject project = mAvailableProjects[i].getProject();
items[i + 1] = labelProvider.getText(project);
if (project == initialProject) {
selectionIndex = i + 1;
}
}
setItems(items);
select(selectionIndex);
addSelectionListener(this);
}
示例2: compare
import org.eclipse.jface.viewers.ILabelProvider; //导入方法依赖的package包/类
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
ILabelProvider lprov = (ILabelProvider) ((ContentViewer) viewer).getLabelProvider();
String name1 = lprov.getText(e1);
String name2 = lprov.getText(e2);
if (name1 == null) {
name1 = "";
}
if (name2 == null) {
name2 = "";
}
if (name1.length() > 0 && name2.length() > 0) {
char char1 = name1.charAt(name1.length() - 1);
char char2 = name2.charAt(name2.length() - 1);
if (char1 == '*' && char1 != char2) {
return -1;
}
if (char2 == '*' && char2 != char1) {
return 1;
}
}
return name1.compareTo(name2);
}
示例3: compare
import org.eclipse.jface.viewers.ILabelProvider; //导入方法依赖的package包/类
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
ILabelProvider lprov = (ILabelProvider) ((ContentViewer) viewer).getLabelProvider();
String name1 = lprov.getText(e1);
String name2 = lprov.getText(e2);
if (name1 == null) {
name1 = ""; //$NON-NLS-1$
}
if (name2 == null) {
name2 = ""; //$NON-NLS-1$
}
if (name1.length() > 0 && name2.length() > 0) {
char char1 = name1.charAt(name1.length() - 1);
char char2 = name2.charAt(name2.length() - 1);
if (char1 == '*' && char1 != char2) {
return -1;
}
if (char2 == '*' && char2 != char1) {
return 1;
}
}
return name1.compareTo(name2);
}
示例4: findElement
import org.eclipse.jface.viewers.ILabelProvider; //导入方法依赖的package包/类
public Object findElement(Widget[] items, ILabelProvider labelProvider) {
for (int i = 0; i < items.length; i++) {
Object element = items[i].getData();
if (pattern == null) {
return element;
}
if (element != null) {
String label = labelProvider.getText(element);
if(label == null) {
return null;
}
// remove the dirty prefix from the editor's label
String prefix = PartTab.DIRTY_PREFIX;
if (label.startsWith(prefix)) {
label = label.substring(prefix.length());
}
if (matches(pattern, label)) {
return element;
}
}
}
return null;
}
示例5: getLabel
import org.eclipse.jface.viewers.ILabelProvider; //导入方法依赖的package包/类
private String getLabel(final Viewer viewer, final Object e1) {
String name1;
if (viewer == null || !(viewer instanceof ContentViewer)) {
name1 = e1.toString();
} else {
final IBaseLabelProvider prov = ((ContentViewer) viewer).getLabelProvider();
if (prov instanceof ILabelProvider) {
final ILabelProvider lprov = (ILabelProvider) prov;
name1 = lprov.getText(e1);
} else {
name1 = e1.toString();
}
}
if (name1 == null) {
name1 = "";//$NON-NLS-1$
}
return name1;
}
示例6: getText
import org.eclipse.jface.viewers.ILabelProvider; //导入方法依赖的package包/类
public String getText(Object element)
{
List<ILabelProvider> providers = this.getProcessors();
String result = StringUtil.EMPTY;
for (ILabelProvider provider : providers)
{
String text = provider.getText(element);
if (!StringUtil.isEmpty(text))
{
result = text;
break;
}
}
return result;
}
示例7: getLabel
import org.eclipse.jface.viewers.ILabelProvider; //导入方法依赖的package包/类
protected String getLabel(Object element) {
if (hasConfiguration(AttributeControlConfigurations.LABEL_PROVIDER)) {
ILabelProvider labelProvider = getConfiguration(AttributeControlConfigurations.LABEL_PROVIDER, ILabelProvider.class);
if (labelProvider != null) {
return labelProvider.getText(element);
}
}
return element.toString();
}
示例8: getValuesAsString
import org.eclipse.jface.viewers.ILabelProvider; //导入方法依赖的package包/类
protected String[] getValuesAsString(T[] values) {
ILabelProvider labelProvider = getConfiguration(AttributeControlConfigurations.LABEL_PROVIDER, ILabelProvider.class);
String[] valuesAsString = new String[values.length];
for (int i = 0; i < valuesAsString.length; i++) {
T val = values[i];
valuesAsString[i] = labelProvider.getText(val);
}
return valuesAsString;
}
示例9: getForeignObjectLabel
import org.eclipse.jface.viewers.ILabelProvider; //导入方法依赖的package包/类
/**
* Get the label from the given eObject's {@link IResourceServiceProvider}.
*
* @param eObject
* the target object
* @return the label for the given eObject
*/
private String getForeignObjectLabel(final EObject eObject) {
IResourceServiceProvider serviceProvider = ((XtextResource) eObject.eResource()).getResourceServiceProvider();
ILabelProvider labelProvider = serviceProvider.get(ILabelProvider.class);
if (labelProvider != null) {
return labelProvider.getText(eObject);
}
return null;
}
示例10: findFirstMatchToPattern
import org.eclipse.jface.viewers.ILabelProvider; //导入方法依赖的package包/类
/**
* Recursively searches the first element in the tree which matches the current
* filter pattern.
*
* @param items
* tree root items
* @return tree element
*/
private Object findFirstMatchToPattern(TreeItem[] items) {
// Match the string pattern against labels
ILabelProvider labelProvider = (ILabelProvider) treeViewer.getLabelProvider();
// Process each item in the tree
for (int i = 0; i < items.length; i++) {
Object element = items[i].getData();
// Return the first element if no pattern is set
if (stringMatcher == null) {
return element;
}
// Return the element if it matches the pattern
if (element != null) {
String label = labelProvider.getText(element);
if (stringMatcher.match(label)) {
return element;
}
}
// Recursively check the elements children for a match
element = findFirstMatchToPattern(items[i].getItems());
// Return the child element match if found
if (element != null) {
return element;
}
}
// No match found
return null;
}
示例11: getText
import org.eclipse.jface.viewers.ILabelProvider; //导入方法依赖的package包/类
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();
}
}
}
示例12: getStyledText
import org.eclipse.jface.viewers.ILabelProvider; //导入方法依赖的package包/类
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());
}
}
}
示例13: compare
import org.eclipse.jface.viewers.ILabelProvider; //导入方法依赖的package包/类
public int compare(Viewer viewer, Object e1, Object e2)
{
int cat1 = category(e1);
int cat2 = category(e2);
if (cat1 != cat2) return cat1 - cat2;
String name1, name2;
if (viewer == null || !(viewer instanceof ContentViewer))
{
name1 = e1.toString();
name2 = e2.toString();
}
else
{
IBaseLabelProvider prov = ((ContentViewer) viewer)
.getLabelProvider();
if (prov instanceof ILabelProvider)
{
ILabelProvider lprov = (ILabelProvider) prov;
name1 = lprov.getText(e1);
name2 = lprov.getText(e2);
}
else
{
name1 = e1.toString();
name2 = e2.toString();
}
}
if (name1 == null) name1 = "";
if (name2 == null) name2 = "";
return name1.compareToIgnoreCase(name2);
}
示例14: compare
import org.eclipse.jface.viewers.ILabelProvider; //导入方法依赖的package包/类
public int compare(Viewer viewer, Object e1, Object e2) {
if(!sortTabList){
return 0;
}
String name1;
String name2;
if (viewer == null || !(viewer instanceof ContentViewer)) {
name1 = e1.toString();
name2 = e2.toString();
} else {
IBaseLabelProvider prov = ((ContentViewer) viewer)
.getLabelProvider();
if (prov instanceof ILabelProvider) {
ILabelProvider lprov = (ILabelProvider) prov;
name1 = lprov.getText(e1);
name2 = lprov.getText(e2);
} else {
name1 = e1.toString();
name2 = e2.toString();
}
}
if (name1 == null) {
name1 = "";
}
if (name2 == null) {
name2 = "";
}
return getComparator().compare(name1, name2);
}
示例15: getValueAsString
import org.eclipse.jface.viewers.ILabelProvider; //导入方法依赖的package包/类
@Override
public String getValueAsString() {
ILabelProvider provider = getDescriptor().getLabelProvider();
if (provider instanceof CheckBoxLabelProvider) {
return provider.getText(editValue);//$NON-NLS-1$
}
if (provider == null) {
return editValue.toString();
}
String text = provider.getText(editValue);
if (text == null) {
return "";//$NON-NLS-1$
}
return text;
}