本文整理汇总了Java中org.eclipse.ui.model.IWorkbenchAdapter.getLabel方法的典型用法代码示例。如果您正苦于以下问题:Java IWorkbenchAdapter.getLabel方法的具体用法?Java IWorkbenchAdapter.getLabel怎么用?Java IWorkbenchAdapter.getLabel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.ui.model.IWorkbenchAdapter
的用法示例。
在下文中一共展示了IWorkbenchAdapter.getLabel方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getColumnText
import org.eclipse.ui.model.IWorkbenchAdapter; //导入方法依赖的package包/类
@Override
public String getColumnText(Object element, int columnIndex) {
GraphNode node = getGraphNode(element);
if (null != node) {
switch (columnIndex) {
case INDEX_NAME:
return node.toString();
case INDEX_RANK:
return getRank(node);
case INDEX_PREDS:
return getPredecessorCount(node);
case INDEX_SUCCS:
return getSuccessorCount(node);
}
}
IWorkbenchAdapter item = getWorkbenchAdapter(element);
if (null != item) {
switch (columnIndex) {
case INDEX_NAME:
return item.getLabel(element);
}
}
return null;
}
示例2: getColumnText
import org.eclipse.ui.model.IWorkbenchAdapter; //导入方法依赖的package包/类
@Override
public String getColumnText(Object element, int columnIndex) {
GraphNode node = getGraphNode(element);
if (null != node) {
switch (columnIndex) {
case INDEX_NAME:
return node.toString();
case INDEX_XPOS:
return getXPos(node);
case INDEX_YPOS:
return getYPos(node);
case INDEX_COLOR:
return getColorName(node);
case INDEX_SIZE:
return getSizeName(node);
}
}
IWorkbenchAdapter item = getWorkbenchAdapter(element);
if (null != item) {
switch (columnIndex) {
case INDEX_NAME:
return item.getLabel(element);
}
}
return null;
}
示例3: getNonJavaElementLabel
import org.eclipse.ui.model.IWorkbenchAdapter; //导入方法依赖的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;
}
示例4: tryStructuredSelection
import org.eclipse.ui.model.IWorkbenchAdapter; //导入方法依赖的package包/类
private SearchPatternData tryStructuredSelection(IStructuredSelection selection) {
if (selection == null || selection.size() > 1)
return null;
Object o= selection.getFirstElement();
SearchPatternData res= null;
if (o instanceof IJavaElement) {
res= determineInitValuesFrom((IJavaElement) o);
} else if (o instanceof LogicalPackage) {
LogicalPackage lp= (LogicalPackage)o;
return new SearchPatternData(PACKAGE, REFERENCES, 0, fIsCaseSensitive, lp.getElementName(), null, getLastIncludeMask());
} else if (o instanceof IAdaptable) {
IJavaElement element= (IJavaElement) ((IAdaptable) o).getAdapter(IJavaElement.class);
if (element != null) {
res= determineInitValuesFrom(element);
}
}
if (res == null && o instanceof IAdaptable) {
IWorkbenchAdapter adapter= (IWorkbenchAdapter)((IAdaptable)o).getAdapter(IWorkbenchAdapter.class);
if (adapter != null) {
return new SearchPatternData(TYPE, REFERENCES, 0, fIsCaseSensitive, adapter.getLabel(o), null, getLastIncludeMask());
}
}
return res;
}
示例5: getElementLabel
import org.eclipse.ui.model.IWorkbenchAdapter; //导入方法依赖的package包/类
/**
* A convenience method for getting the label of an adaptable
* object that responds to the IWorkbenchAdapter adapter interface.
* Returns a toString() of the object if it is not adaptable
*/
public static String getElementLabel(IAdaptable a) {
if (a == null) {
return "";//$NON-NLS-1$
}
IWorkbenchAdapter adapter = (IWorkbenchAdapter)a.getAdapter(IWorkbenchAdapter.class);
if (adapter != null) {
return adapter.getLabel(a);
} else {
return a.toString();
}
}
示例6: formatMessage
import org.eclipse.ui.model.IWorkbenchAdapter; //导入方法依赖的package包/类
protected String formatMessage(ISelection sel) {
if (sel instanceof IStructuredSelection && !sel.isEmpty()) {
IStructuredSelection selection= (IStructuredSelection) sel;
int nElements= selection.size();
if (nElements > 1) {
return Messages.format(JavaUIMessages.StatusBarUpdater_num_elements_selected, String.valueOf(nElements));
} else {
Object elem= selection.getFirstElement();
if (elem instanceof IJavaElement) {
return formatJavaElementMessage((IJavaElement) elem);
} else if (elem instanceof IResource) {
return formatResourceMessage((IResource) elem);
} else if (elem instanceof PackageFragmentRootContainer) {
PackageFragmentRootContainer container= (PackageFragmentRootContainer) elem;
return container.getLabel() + JavaElementLabels.CONCAT_STRING + container.getJavaProject().getElementName();
} else if (elem instanceof IJarEntryResource) {
IJarEntryResource jarEntryResource= (IJarEntryResource) elem;
StringBuffer buf= new StringBuffer(BasicElementLabels.getResourceName(jarEntryResource.getName()));
buf.append(JavaElementLabels.CONCAT_STRING);
IPath fullPath= jarEntryResource.getFullPath();
if (fullPath.segmentCount() > 1) {
buf.append(BasicElementLabels.getPathLabel(fullPath.removeLastSegments(1), false));
buf.append(JavaElementLabels.CONCAT_STRING);
}
buf.append(JavaElementLabels.getElementLabel(jarEntryResource.getPackageFragmentRoot(), JavaElementLabels.ROOT_POST_QUALIFIED));
return buf.toString();
} else if (elem instanceof IAdaptable) {
IWorkbenchAdapter wbadapter= (IWorkbenchAdapter) ((IAdaptable)elem).getAdapter(IWorkbenchAdapter.class);
if (wbadapter != null) {
return wbadapter.getLabel(elem);
}
}
}
}
return ""; //$NON-NLS-1$
}
示例7: select
import org.eclipse.ui.model.IWorkbenchAdapter; //导入方法依赖的package包/类
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
if (fMatchers.length == 0) {
return true;
}
String matchName= null;
if (element instanceof IJavaElement) {
matchName= ((IJavaElement) element).getElementName();
} else if (element instanceof IResource) {
matchName= ((IResource) element).getName();
} else if (element instanceof IStorage) {
matchName= ((IStorage) element).getName();
} else if (element instanceof IWorkingSet) {
matchName= ((IWorkingSet) element).getLabel();
} else if (element instanceof IAdaptable) {
IWorkbenchAdapter wbadapter= (IWorkbenchAdapter) ((IAdaptable)element).getAdapter(IWorkbenchAdapter.class);
if (wbadapter != null) {
matchName= wbadapter.getLabel(element);
}
}
if (matchName != null && matchName.length() > 0) {
StringMatcher[] testMatchers= getMatchers();
for (int i = 0; i < testMatchers.length; i++) {
if (testMatchers[i].match(matchName))
return false;
}
return true;
}
return true;
}
示例8: getText
import org.eclipse.ui.model.IWorkbenchAdapter; //导入方法依赖的package包/类
public final String getText(Object element) {
// query the element for its label
IWorkbenchAdapter adapter = getAdapter(element);
if (adapter == null) {
return ""; //$NON-NLS-1$
}
String label = adapter.getLabel(element);
// return the decorated label
return decorateText(label, element);
}
示例9: getText
import org.eclipse.ui.model.IWorkbenchAdapter; //导入方法依赖的package包/类
@Override
public String getText(Object element) {
//query the element for its label
IWorkbenchAdapter adapter = getAdapter(element);
if (adapter == null) {
return ""; //$NON-NLS-1$
}
String label = adapter.getLabel(element);
//return the decorated label
return decorateText(label, element);
}
示例10: getName
import org.eclipse.ui.model.IWorkbenchAdapter; //导入方法依赖的package包/类
/**
* Returns the name of the given element.
*
* @param element
* the element
* @return the name of the element
*/
private String getName(IAdaptable element) {
IWorkbenchAdapter adapter = element.getAdapter(IWorkbenchAdapter.class);
if (adapter != null) {
return adapter.getLabel(element);
}
return "";//$NON-NLS-1$
}
示例11: getText
import org.eclipse.ui.model.IWorkbenchAdapter; //导入方法依赖的package包/类
@Override
public String getText(final Object inElement) {
final IWorkbenchAdapter lAdapter = getAdapter(inElement);
if (lAdapter == null) {
return ""; //$NON-NLS-1$
}
final String lLabel = lAdapter.getLabel(inElement);
return lLabel;
}