本文整理汇总了Java中org.eclipse.jface.viewers.LabelProvider类的典型用法代码示例。如果您正苦于以下问题:Java LabelProvider类的具体用法?Java LabelProvider怎么用?Java LabelProvider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LabelProvider类属于org.eclipse.jface.viewers包,在下文中一共展示了LabelProvider类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: showComponentTypeSelectionDialog
import org.eclipse.jface.viewers.LabelProvider; //导入依赖的package包/类
public static Optional<ComponentType> showComponentTypeSelectionDialog(Shell parentShell) throws CoreException {
ElementListSelectionDialog dialog = new ElementListSelectionDialog(parentShell, new LabelProvider());
dialog.setElements(loadAllComponentTypes().toArray(new String[0]));
dialog.setTitle("Select subcomponent's type");
// user pressed cancel
if (dialog.open() == Window.OK) {
Object[] objects = dialog.getResult();
for (Object result : objects) {
System.out.println("result = " + result);
}
String typeName = objects[0].toString();
ComponentType type = loadComponentType(typeName);
return Optional.of(type);
}
return Optional.empty();
}
示例2: calculateLogicallyQualifiedDisplayName
import org.eclipse.jface.viewers.LabelProvider; //导入依赖的package包/类
/**
* Calculate the hierarchically qualified name of an EObject.
*
* @param eob
* the EObject to calculate logical name for
* @param labelProvider
* the label provider that knows how to display EObject instances
*
* @return the hierarchically
*/
public static String calculateLogicallyQualifiedDisplayName(EObject eob, LabelProvider labelProvider,
boolean includeRoot) {
// Calculate hierarchical logical name, e.g. C.m
String text = labelProvider.getText(eob);
EObject currContainer = eob.eContainer();
while (currContainer != null) {
if (isShowable(currContainer)) {
text = labelProvider.getText(currContainer) + "." + text;
}
currContainer = currContainer.eContainer();
if (currContainer != null && !includeRoot && currContainer instanceof Script)
break;
}
return text;
}
示例3: ColumnViewerBuilder
import org.eclipse.jface.viewers.LabelProvider; //导入依赖的package包/类
/**
* Creates a new {@link TableViewer table viewer} builder with the given list of table column labels.
*
* @param columnLabels
* a list of table column labels to use for the new table viewer. Cannot be {@code null}. Must not be
* empty.
*
*/
protected ColumnViewerBuilder(final List<String> columnLabels, final CP contentProvider) {
this.columnLabels = checkNotNull(columnLabels, "columnLabels");
this.contentProvider = checkNotNull(contentProvider, "contentProvider");
checkArgument(!this.columnLabels.isEmpty(),
"Empty column labels are not allowed. At least one column should be specified.");
headerVisible = true;
linesVisible = true;
useHashlookup = false;
labelProvider = new LabelProvider();
multipleSelection = false;
fullSelection = true;
resizable = true;
hasBorder = false;
moveable = true;
}
示例4: ThreeStateComboChoice
import org.eclipse.jface.viewers.LabelProvider; //导入依赖的package包/类
public ThreeStateComboChoice(Composite parent,ISelectionChangedListener listener) {
super(parent, SWT.READ_ONLY);
setContentProvider(ArrayContentProvider.getInstance());
setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
if (element instanceof ThreeStateChoice) {
ThreeStateChoice choice = (ThreeStateChoice) element;
return choice.getLabel();
}
return "";
}
});
addSelectionChangedListener(listener);
setInput(choices);
}
示例5: createViewer
import org.eclipse.jface.viewers.LabelProvider; //导入依赖的package包/类
@Override
protected ListViewer createViewer(Composite parent) {
ListViewer viewerObjs = new ListViewer(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 5);
gd.widthHint = PREF_PAGE.WIDTH_HINT_PX;
viewerObjs.getControl().setLayoutData(gd);
viewerObjs.setContentProvider(ArrayContentProvider.getInstance());
viewerObjs.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
return ((DbInfo) element).getName();
}
});
return viewerObjs;
}
示例6: createControl
import org.eclipse.jface.viewers.LabelProvider; //导入依赖的package包/类
@Override
public void createControl(Composite parent) {
super.createControl(parent);
getTreeViewer().setContentProvider(new OutlineContentProvider());
getTreeViewer().setLabelProvider(new LabelProvider() {
@Override
public Image getImage(Object element) {
if (element instanceof Segments) {
Segments seg = (Segments)element;
return Activator.getDbObjImage(seg.getType());
}
return super.getImage(element);
}
});
getTreeViewer().addSelectionChangedListener(this);
// argument doesn't matter
getTreeViewer().setInput(sqlEditor);
}
示例7: ChooseRootUrlDialog
import org.eclipse.jface.viewers.LabelProvider; //导入依赖的package包/类
/**
*
* @param parent
* @param url : the url from which we want to get the root url
*/
public ChooseRootUrlDialog(Shell parent, SVNUrl url) {
super(parent);
this.url = url;
List list = new ArrayList();
// we want the user can select "no root url", ie a blank url
list.add(""); // we cannot add null, we would have a NullPointerException //$NON-NLS-1$
SVNUrl possibleRoot = this.url;
while (possibleRoot != null) {
list.add(possibleRoot);
possibleRoot = possibleRoot.getParent();
}
setTitle(Policy.bind("ChooseRootUrlDialog.rootUrlDialogTitle")); //$NON-NLS-1$
setAddCancelButton(true);
setLabelProvider(new LabelProvider());
setMessage(Policy.bind("ChooseRootUrlDialog.chooseRootUrl")); //$NON-NLS-1$
setContentProvider(new ListContentProvider());
setInput(list);
}
示例8: createFileListViewer
import org.eclipse.jface.viewers.LabelProvider; //导入依赖的package包/类
/**
* Creates a ListViewer whose input is an array of IFiles.
*
* @param parent the parent of the viewer
* @param title the text for the title label
* @param heightHint the nominal height of the list
* @return the created list viewer
*/
public ListViewer createFileListViewer(Composite parent, String title, int heightHint) {
createLabel(parent, title);
ListViewer listViewer = new ListViewer(parent, SWT.READ_ONLY | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
listViewer.setContentProvider(new IStructuredContentProvider() {
public Object[] getElements(Object inputElement) {
return (Object[]) inputElement;
}
public void dispose() {
}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
});
listViewer.setLabelProvider(new LabelProvider() {
public String getText(Object element) {
return ((IFile) element).getFullPath().toString();
}
});
listViewer.setSorter(new WorkbenchViewerSorter());
GridData data = new GridData(GridData.FILL_BOTH);
data.heightHint = heightHint;
listViewer.getList().setLayoutData(data);
return listViewer;
}
示例9: createRuntimeField
import org.eclipse.jface.viewers.LabelProvider; //导入依赖的package包/类
@Override
protected void createRuntimeField(Composite composite) {
Label runtimeLabel = new Label(composite, SWT.LEAD);
runtimeLabel.setText(Messages.getString("app.engine.standard.project.runtimetype")); //$NON-NLS-1$
runtimeField = new ComboViewer(composite, SWT.READ_ONLY);
runtimeField.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
return ((AppEngineRuntime) element).getLabel();
}
});
runtimeField.setContentProvider(ArrayContentProvider.getInstance());
runtimeField.setInput(AppEngineRuntime.STANDARD_RUNTIMES);
runtimeField.setSelection(new StructuredSelection(DEFAULT_RUNTIME), true);
runtimeField.addPostSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
revalidate();
}
});
}
示例10: create
import org.eclipse.jface.viewers.LabelProvider; //导入依赖的package包/类
private void create(Composite parent) {
displayExecutor = DisplayExecutor.create(parent.getDisplay());
comboViewer = new ComboViewer(parent, SWT.READ_ONLY | SWT.DROP_DOWN);
comboViewer.setComparator(new ViewerComparator());
comboViewer.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
if (element instanceof GcpProject) {
GcpProject project = (GcpProject) element;
return project.getName() + " (" + project.getId() + ")";
}
return super.getText(element);
}
});
comboViewer.setContentProvider(ArrayContentProvider.getInstance());
comboViewer.setInput(EMPTY_PROJECTS);
parent.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent event) {
cancelFetch();
}
});
fetch();
}
示例11: getDetailLabelProvider
import org.eclipse.jface.viewers.LabelProvider; //导入依赖的package包/类
/**
* Creates a label provider for the detail section below the list<br>
* The label provider prints out the name of operation definition and the module the operation is defined in
*/
private ILabelProvider getDetailLabelProvider()
{
return new LabelProvider() {
public String getText(Object element)
{
if (element instanceof OpDefNode)
{
OpDefNode node = (OpDefNode) element;
return node.getSource().getName().toString()
+ ((node.getSource().getOriginallyDefinedInModuleNode() != null) ? " : "
+ node.getSource().getOriginallyDefinedInModuleNode().getName().toString() : "");
}
return super.getText(element);
}
};
}
示例12: getListLabelProvider
import org.eclipse.jface.viewers.LabelProvider; //导入依赖的package包/类
/**
* Creates label provider for the elements in the list
*/
private ILabelProvider getListLabelProvider()
{
return new LabelProvider() {
public String getText(Object element)
{
if (element instanceof OpDefNode)
{
OpDefNode node = (OpDefNode) element;
if (node.getSource() == node)
{
return node.getName().toString();
} else
{
return node.getSource().getName().toString() + " ["
+ node.getSource().getOriginallyDefinedInModuleNode().getName().toString() + "]";
}
}
return super.getText(element);
}
};
}
示例13: createDomainCombo
import org.eclipse.jface.viewers.LabelProvider; //导入依赖的package包/类
protected void createDomainCombo(Composite leftColumn) {
Label label = getToolkit().createLabel(leftColumn, "Statechart domain");
GridDataFactory.fillDefaults().span(2, 1).align(SWT.FILL, SWT.CENTER).applyTo(label);
domainCombo = new ComboViewer(leftColumn);
GridDataFactory.fillDefaults().span(1, 1).align(SWT.FILL, SWT.CENTER).applyTo(domainCombo.getCombo());
Label spacer = getToolkit().createLabel(leftColumn, "");
GridDataFactory.fillDefaults().applyTo(spacer);
domainCombo.setContentProvider(new ArrayContentProvider());
domainCombo.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
return ((IDomain) element).getName();
}
});
List<IDomain> domains = DomainRegistry.getDomains();
for (IDomain domainDescriptor : domains) {
domainCombo.add(domainDescriptor);
}
if (domains.size() <= 1) {
domainCombo.getControl().setEnabled(false);
}
}
示例14: ProjectSelectionDialog
import org.eclipse.jface.viewers.LabelProvider; //导入依赖的package包/类
public ProjectSelectionDialog(Shell parentShell, Object input,
IStructuredContentProvider contentProvider,
ILabelProvider labelProvider, String message, String unifiedDiff) {
super(parentShell);
this.unifiedDiff = unifiedDiff;
featureController.getFeatures(VariantSyncPlugin.getDefault()
.getSupportProjectList());
setTitle(WorkbenchMessages.ListSelection_title);
inputElement = input;
projectSelectionDiaglog = this;
this.projectContentProvider = contentProvider;
this.featureContentProvider = new FeatureListViewerContentProvider();
this.projectLabelProvider = labelProvider;
this.featureLabelProvider = new LabelProvider();
if (message != null) {
setMessage(message);
} else {
setMessage(WorkbenchMessages.ListSelection_message);
}
}
示例15: deletePre
import org.eclipse.jface.viewers.LabelProvider; //导入依赖的package包/类
private void deletePre() {
try {
String[] sa = pref.node("fileList").keys();
if (sa.length == 0){
return;
}
ElementListSelectionDialog dialog = new ElementListSelectionDialog(input.getShell(), new LabelProvider());
dialog.setTitle("Select file list that you want to remove");
dialog.setElements(sa);
dialog.setMessage("Type to filter by name:");
dialog.setMultipleSelection(true);
if (dialog.open() == ElementListSelectionDialog.OK) {
Object[] oa = dialog.getResult();
Preferences p = pref.node("fileList");
for (int i = 0; i < oa.length; i++) {
String key = (String)oa[i];
remove(key);
p.remove(key);
}
pref.put("selectedList", "");
}
} catch (Exception e) {
TFMPlugin.error("FileListMenuMgr deletePre", e);
}
}