本文整理汇总了Java中org.eclipse.jface.viewers.IBaseLabelProvider类的典型用法代码示例。如果您正苦于以下问题:Java IBaseLabelProvider类的具体用法?Java IBaseLabelProvider怎么用?Java IBaseLabelProvider使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IBaseLabelProvider类属于org.eclipse.jface.viewers包,在下文中一共展示了IBaseLabelProvider类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import org.eclipse.jface.viewers.IBaseLabelProvider; //导入依赖的package包/类
@Override
public void run() {
Shell shell = getActiveWorkbenchShell();
if (shell == null || fViewer == null) return;
IBaseLabelProvider labelProvider = fViewer.getLabelProvider();
String lineDelim = System.getProperty("line.separator"); //$NON-NLS-1$
StringBuffer buf = new StringBuffer();
Iterator<?> iter = getSelection();
while (iter.hasNext()) {
if (buf.length() > 0) {
buf.append(lineDelim);
}
buf.append(getText(labelProvider, iter.next()));
}
if (buf.length() > 0) {
copyToClipboard(buf.toString(), shell);
}
}
示例2: getLabel
import org.eclipse.jface.viewers.IBaseLabelProvider; //导入依赖的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;
}
示例3: getPostQualifiedLabelProvider
import org.eclipse.jface.viewers.IBaseLabelProvider; //导入依赖的package包/类
public static IBaseLabelProvider getPostQualifiedLabelProvider() {
return new DelegatingStyledCellLabelProvider(new JavaElementLabelProvider(
JavaElementLabelProvider.SHOW_POST_QUALIFIED | JavaElementLabelProvider.SHOW_SMALL_ICONS)) {
@Override
protected StyledString getStyledText(Object element) {
String nameWithQualifier = getStyledStringProvider().getStyledText(element).getString() + " ";
int separatorIndex = nameWithQualifier.indexOf('-');
if (separatorIndex == -1)
return new StyledString(nameWithQualifier);
StyledString name = new StyledString(nameWithQualifier.substring(0, separatorIndex));
String qualifier = nameWithQualifier.substring(separatorIndex);
return name.append(new StyledString(qualifier, StyledString.QUALIFIER_STYLER));
};
};
}
示例4: updateDayViewerFonts
import org.eclipse.jface.viewers.IBaseLabelProvider; //导入依赖的package包/类
private void updateDayViewerFonts() {
Font font = getDaysTreeFont(true);
for (DayViewer dayViewer : dayViewers) {
MergeTreeViewer treeViewer = dayViewer.getTreeTableViewer();
treeViewer.getTree().setFont(font);
MergeTotalComposite totalComposite = (MergeTotalComposite)dayViewer.getTotalViewer().getControl();
totalComposite.getTable().setFont(font);
IBaseLabelProvider labelProvider = treeViewer.getLabelProvider();
if (labelProvider instanceof MergeTreeLabelProvider) {
MergeTreeLabelProvider mergeTreeLabelProvider = (MergeTreeLabelProvider)labelProvider;
mergeTreeLabelProvider.setLabelFontSize(getDaysTreeFontSize());
mergeTreeLabelProvider.updateFonts();
}
treeViewer.refresh(true);
}
}
示例5: getNonJavaElementLabel
import org.eclipse.jface.viewers.IBaseLabelProvider; //导入依赖的package包/类
private String getNonJavaElementLabel(Viewer viewer, Object element) {
// try to use the workbench adapter for non - java resources or if not available, use the viewers label provider
if (element instanceof IResource) {
return ((IResource) element).getName();
}
if (element instanceof IStorage) {
return ((IStorage) element).getName();
}
if (element instanceof IAdaptable) {
IWorkbenchAdapter adapter= (IWorkbenchAdapter) ((IAdaptable) element).getAdapter(IWorkbenchAdapter.class);
if (adapter != null) {
return adapter.getLabel(element);
}
}
if (viewer instanceof ContentViewer) {
IBaseLabelProvider prov = ((ContentViewer) viewer).getLabelProvider();
if (prov instanceof ILabelProvider) {
return ((ILabelProvider) prov).getText(element);
}
}
return null;
}
示例6: compare
import org.eclipse.jface.viewers.IBaseLabelProvider; //导入依赖的package包/类
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
int cat1 = category(e1);
int cat2 = category(e2);
if (cat1 != cat2)
return cat1 - cat2;
if (cat1 == ATTRIBUTE || cat1 == CONTAINER_ENTRY) {
return 0; // do not sort attributes or container entries
}
if (viewer instanceof ContentViewer) {
IBaseLabelProvider prov = ((ContentViewer) viewer).getLabelProvider();
if (prov instanceof ILabelProvider) {
ILabelProvider lprov = (ILabelProvider) prov;
String name1 = lprov.getText(e1);
String name2 = lprov.getText(e2);
return getComparator().compare(name1, name2);
}
}
return 0;
}
示例7: compare
import org.eclipse.jface.viewers.IBaseLabelProvider; //导入依赖的package包/类
public int compare( Viewer viewer, Object e1, Object e2 )
{
IBaseLabelProvider provider = null;
if ( viewer instanceof TreeViewer )
{
provider =( ( TreeViewer )viewer ).getLabelProvider( );
}
if ( provider != null && provider instanceof SampleReportsExplorerProvider )
{
if( ( ( SampleReportsExplorerProvider )provider ).getText( e1 ).equals( "Contribute Samples" ) ) //$NON-NLS-1$
{
return 1;
}
else if ( ( ( SampleReportsExplorerProvider )provider ).getText( e2 ).equals( "Contribute Samples" ) ) //$NON-NLS-1$
{
return -1;
}
}
return 0;
}
示例8: getLabel
import org.eclipse.jface.viewers.IBaseLabelProvider; //导入依赖的package包/类
private String getLabel(Viewer viewer, Object e1) {
String name1;
if (viewer == null || !(viewer instanceof ContentViewer)) {
name1 = e1.toString();
} else {
IBaseLabelProvider prov = ((ContentViewer) viewer).getLabelProvider();
if (prov instanceof ILabelProvider) {
ILabelProvider lprov = (ILabelProvider) prov;
name1 = lprov.getText(e1);
} else {
name1 = e1.toString();
}
}
if (name1 == null) {
name1 = ""; //$NON-NLS-1$
}
return name1;
}
示例9: compareColumn
import org.eclipse.jface.viewers.IBaseLabelProvider; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private int compareColumn(final Viewer inViewer, final Object inA,
final Object inB, final int inColumnNumber) {
if (inColumnNumber == USER_DELTA_COLUMN) {
return sortUser(inA, inB);
}
final IBaseLabelProvider lBaseLabel = ((TreeViewer) inViewer)
.getLabelProvider();
if (lBaseLabel instanceof ITableLabelProvider) {
final ITableLabelProvider lTableProvider = (ITableLabelProvider) lBaseLabel;
final String lProvider1 = lTableProvider.getColumnText(inA,
inColumnNumber);
final String lProvider2 = lTableProvider.getColumnText(inB,
inColumnNumber);
if (lProvider1 != null && lProvider2 != null) {
return getComparator().compare(lProvider1, lProvider2);
}
}
return 0;
}
示例10: getLabel
import org.eclipse.jface.viewers.IBaseLabelProvider; //导入依赖的package包/类
private String getLabel(Viewer viewer, Object e1) {
if (viewer == null || !(viewer instanceof ContentViewer))
return e1.toString();
IBaseLabelProvider prov = ((ContentViewer) viewer).getLabelProvider();
if (prov instanceof ILabelProvider) {
ILabelProvider lprov = (ILabelProvider) prov;
String label = lprov.getText(e1);
if (label == null)
return "";
String changed = RepositoryLabel.CHANGED_STATE;
if (label.startsWith(changed))
return label.substring(changed.length());
return label;
}
return e1.toString();
}
示例11: createViewer
import org.eclipse.jface.viewers.IBaseLabelProvider; //导入依赖的package包/类
public static TreeViewer createViewer(Composite parent, String[] headers, IBaseLabelProvider label) {
TreeViewer viewer = new TreeViewer(parent, SWT.BORDER | SWT.FULL_SELECTION | SWT.VIRTUAL | SWT.MULTI);
Tree tree = viewer.getTree();
boolean hasColumns = headers != null && headers.length > 0;
tree.setLinesVisible(hasColumns);
tree.setHeaderVisible(hasColumns);
if (hasColumns) {
createColumns(viewer, headers, label);
}
if (label != null) {
viewer.setLabelProvider(label);
}
GridData data = UI.gridData(tree, true, true);
data.minimumHeight = 150;
return viewer;
}
示例12: createViewer
import org.eclipse.jface.viewers.IBaseLabelProvider; //导入依赖的package包/类
/**
* Creates a default table viewer with the given properties. The properties
* are also used to create columns where each column label is the respective
* property of this column. The viewer is configured in the following way:
* <ul>
* <li>content provider = {@link ArrayContentProvider}
* <li>lines and header are visible
* <li>grid data with horizontal and vertical fill
*
*/
public static TableViewer createViewer(Composite parent, String[] properties, IBaseLabelProvider labelProvider) {
TableViewer viewer = new TableViewer(parent, SWT.BORDER | SWT.FULL_SELECTION | SWT.VIRTUAL | SWT.MULTI);
viewer.setContentProvider(new ArrayContentProvider());
boolean hasColumns = properties != null && properties.length > 0;
Table table = viewer.getTable();
table.setLinesVisible(hasColumns);
table.setHeaderVisible(hasColumns);
if (hasColumns) {
createColumns(viewer, properties, labelProvider);
}
if (labelProvider != null) {
viewer.setLabelProvider(labelProvider);
}
GridData data = UI.gridData(table, true, true);
data.minimumHeight = 120;
return viewer;
}
示例13: getLabelProvider
import org.eclipse.jface.viewers.IBaseLabelProvider; //导入依赖的package包/类
protected IBaseLabelProvider getLabelProvider() {
return new LabelProvider() {
@Override
public String getText(Object element) {
return ((IEditCommand) element).getLabel();
}
};
}
示例14: compare
import org.eclipse.jface.viewers.IBaseLabelProvider; //导入依赖的package包/类
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
if (viewer instanceof TableViewer) {
IBaseLabelProvider baseLabel = ((TableViewer) viewer).getLabelProvider();
String left = ((ITableLabelProvider) baseLabel).getColumnText(e1, fSortColumn);
String right = ((ITableLabelProvider) baseLabel).getColumnText(e2, fSortColumn);
int sortResult = getComparator().compare(left != null ? left : "", right != null ? right : "");
return sortResult * fSortOrder;
}
return super.compare(viewer, e1, e2);
}
示例15: refreshTFSLabelDecorator
import org.eclipse.jface.viewers.IBaseLabelProvider; //导入依赖的package包/类
/**
* Refreshes labels for the entire workspace on the workbench's active
* {@link TFSLabelDecorator} (if there is one).
*
* @throws CoreException
* if there was an error collecting folder contents from a given
* resource
*/
public static void refreshTFSLabelDecorator() {
final IBaseLabelProvider decorator =
PlatformUI.getWorkbench().getDecoratorManager().getBaseLabelProvider(TFSLabelDecorator.DECORATOR_ID);
// It's possible the decorator is not yet available
if (decorator == null || decorator instanceof TFSLabelDecorator == false) {
log.debug("Couldn't find TFSLabelDecorator for refresh"); //$NON-NLS-1$
return;
}
((TFSLabelDecorator) decorator).refresh();
}