本文整理匯總了Java中org.eclipse.jface.viewers.ListViewer.setLabelProvider方法的典型用法代碼示例。如果您正苦於以下問題:Java ListViewer.setLabelProvider方法的具體用法?Java ListViewer.setLabelProvider怎麽用?Java ListViewer.setLabelProvider使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jface.viewers.ListViewer
的用法示例。
在下文中一共展示了ListViewer.setLabelProvider方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createViewer
import org.eclipse.jface.viewers.ListViewer; //導入方法依賴的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;
}
示例2: createFileListViewer
import org.eclipse.jface.viewers.ListViewer; //導入方法依賴的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;
}
示例3: createDialogArea
import org.eclipse.jface.viewers.ListViewer; //導入方法依賴的package包/類
/**
*
* {@inheritDoc}
*
* @see org.eclipse.jface.dialogs.TitleAreaDialog#createDialogArea(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createDialogArea(Composite parent) {
setMessage("In order to execute your requested operation, you have to select a server.");
setTitle("Please select a Server");
final Composite area = (Composite) super.createDialogArea(parent);
final Composite container = new Composite(area, SWT.NONE);
container.setLayout(new GridLayout(1, false));
container.setLayoutData(new GridData(GridData.FILL_BOTH));
listViewer = new ListViewer(container, SWT.BORDER | SWT.V_SCROLL);
final List list = listViewer.getList();
list.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
listViewer.setContentProvider(ArrayContentProvider.getInstance());
labelProvider = new ServerInfoLabelProvider();
listViewer.setLabelProvider(labelProvider);
listViewer.setInput(servers);
if (servers.size() == 1) {
listViewer.setSelection(new StructuredSelection(servers.get(0)));
}
return area;
}
示例4: createChartsComposite
import org.eclipse.jface.viewers.ListViewer; //導入方法依賴的package包/類
private void createChartsComposite (Composite container)
{
Group grpResources = new Group(container, SWT.NONE);
grpResources.setText("Resources");
grpResources.setLayout(new FillLayout(SWT.HORIZONTAL));
SashForm sashResources = new SashForm(grpResources, SWT.HORIZONTAL | SWT.SMOOTH);
sashResources.setSashWidth(8);
listViewer = new ListViewer(sashResources, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
listResources = listViewer.getList();// new List(sashResources,
// SWT.BORDER | SWT.H_SCROLL |
// SWT.V_SCROLL);
listViewer.setContentProvider(new ArrayContentProvider());
listViewer.setLabelProvider(new LabelProvider()
{
@Override
public String getText(Object element)
{
return element.toString().replaceFirst("-org.spotter.demo.app.", "");
}
});
canvasRes = new Canvas(sashResources, SWT.NONE);
sashResources.setWeights(new int[] {3, 7});
addCanvasListeners();
}
示例5: createPartControl
import org.eclipse.jface.viewers.ListViewer; //導入方法依賴的package包/類
@Override
public void createPartControl(Composite parent) {
viewer = new ListViewer(parent);
viewer.setContentProvider(ArrayContentProvider.getInstance());
viewer.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
Task p = (Task) element;
return p.getSummary();
};
});
viewer.setInput(TaskService.getInstance().getTasks());
getSite().setSelectionProvider(viewer);
hookDoubleClickCommand();
}
示例6: createDialogArea
import org.eclipse.jface.viewers.ListViewer; //導入方法依賴的package包/類
protected Control createDialogArea(Composite parent){
Composite composite = (Composite) super.createDialogArea(parent);
composite.setLayout(new GridLayout(1, false));
Label label = new Label(composite, SWT.NONE);
label.setText("Gruppe: " + group.getName());
viewer =
new ListViewer(composite, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
viewer.getControl().setLayoutData(SWTHelper.getFillGridData(1, true, 1, true));
viewer.setContentProvider(new ItemsContentProvider());
viewer.setLabelProvider(new ItemsLabelProvider());
viewer.setInput(this);
return composite;
}
示例7: createPartControl
import org.eclipse.jface.viewers.ListViewer; //導入方法依賴的package包/類
@Override
public void createPartControl(Composite parent) {
parent.setLayout(new GridLayout(3, false));
Label lblProject = new Label(parent, SWT.NONE);
lblProject.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
lblProject.setText("Project");
cProjects = new Combo(parent, SWT.NONE);
cProjects.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
Button bSync = new Button(parent, SWT.NONE);
bSync.setText("Sync");
new Label(parent, SWT.NONE);
ListViewer listViewer = new ListViewer(parent, SWT.BORDER | SWT.V_SCROLL);
List list = listViewer.getList();
listViewer.setContentProvider(new ContentProvider());
listViewer.setLabelProvider(new ViewerLabelProvider());
new Label(parent, SWT.NONE);
bSync.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
super.widgetSelected(e);
updateProjects();
}
});
}
示例8: createDialogArea
import org.eclipse.jface.viewers.ListViewer; //導入方法依賴的package包/類
@Override
protected Control createDialogArea(Composite parent) {
Composite container = (Composite) super.createDialogArea(parent);
GridLayout gridLayout = (GridLayout) container.getLayout();
gridLayout.numColumns = 1;
container.setLayout(gridLayout);
Composite message = new Composite(container, SWT.NONE);
message.setLayout(new FillLayout());
message.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
createMessageArea(message);
listViewer = new ListViewer(container);
listViewer.getList().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
listViewer.setLabelProvider(labelProvider);
listViewer.setContentProvider(new ArrayContentProvider());
listViewer.setInput(content);
listViewer.setSelection(new StructuredSelection(getInitialElementSelections()));
listViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection)listViewer.getSelection();
setResult(selection.toList());
}
});
return container;
}
示例9: createListComp
import org.eclipse.jface.viewers.ListViewer; //導入方法依賴的package包/類
/**
* This method initializes listComp
*/
private void createListComp() {
GridLayout compGridLayout = new GridLayout();
compGridLayout.numColumns = 3;
GridData listGridData = new GridData();
listGridData.widthHint = 200;
listGridData.verticalAlignment = GridData.FILL;
listGridData.grabExcessVerticalSpace = true;
listGridData.grabExcessHorizontalSpace = true;
listGridData.horizontalAlignment = GridData.FILL;
GridData compGridData = new GridData();
compGridData.widthHint = -1;
compGridData.verticalAlignment = GridData.FILL;
compGridData.grabExcessVerticalSpace = true;
compGridData.horizontalAlignment = GridData.BEGINNING;
listComp = new Composite(mainComp, SWT.NONE);
listComp.setLayoutData(compGridData);
listComp.setLayout(compGridLayout);
Label unusedFileListLbl = new Label(listComp, SWT.NONE);
unusedFileListLbl.setText("Unused files:");
new Label(listComp, SWT.NONE);
Label delFileListLbl = new Label(listComp, SWT.NONE);
delFileListLbl.setText("Files to delete:");
unusedFileList = new ListViewer(listComp, SWT.V_SCROLL | SWT.MULTI);
unusedFileList.setLabelProvider(new FileLabelProvider());
unusedFileList.getList().setLayoutData(listGridData);
createDelListBarComp();
delFileList = new ListViewer(listComp, SWT.V_SCROLL | SWT.MULTI);
delFileList.setLabelProvider(new FileLabelProvider());
delFileList.getList().setLayoutData(listGridData);
}
示例10: construct
import org.eclipse.jface.viewers.ListViewer; //導入方法依賴的package包/類
@Override
public Control construct(Composite parent) {
Composite container = new Composite(parent, SWT.FILL);
container.setLayout(new GridLayout());
container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
listViewer = new ListViewer(container);
listViewer.setContentProvider(new ObjectsContentProvider());
listViewer.setLabelProvider(new ObjectsLabelProvider());
listViewer.setInput(new ObjectsList());
listViewer.addSelectionChangedListener(new ISelectionChangedListener() {
/*
* Mockup to test events on SWT List control
*/@Override
public void selectionChanged(SelectionChangedEvent event) {
String outString = "Select" + "\n";
txt.append(outString);
}
});
txt = new Text(container, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.READ_ONLY);
txt.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
txt.setFocus();
txt.setText("");
return null;
}
示例11: createDialogArea
import org.eclipse.jface.viewers.ListViewer; //導入方法依賴的package包/類
@Override
protected Control createDialogArea(final Composite parent) {
// Superclass recommends this pattern
final Composite composite = (Composite) super.createDialogArea(parent);
final FormToolkit toolkit = searchControl.getToolkit();
SWTUtil.gridLayout(composite, 1, true, 0, 0);
mruControl = new ListViewer(composite, SWT.NONE);
GridDataBuilder.newInstance().hGrab().hFill().applyTo(mruControl.getList());
mruControl.setLabelProvider(new MRULabelProvider());
mruControl.setContentProvider(new PrefixMatchingContentProvider(searchControl));
mruControl.setInput(searchControl.getRecentSearches());
mruControl.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(final DoubleClickEvent event) {
search();
}
});
mruControl.getList().addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(final KeyEvent e) {
switch (e.keyCode) {
case SWT.CR:
search();
break;
}
}
});
separator = toolkit.createSeparator(composite, SWT.HORIZONTAL);
GridDataBuilder.newInstance().hGrab().hFill().applyTo(separator);
final Label instructions =
toolkit.createLabel(composite, Messages.getString("TeamExplorerSearchControlPopup.AddASearchFilter")); //$NON-NLS-1$
GridDataBuilder.newInstance().hGrab().hFill().hIndent(3).applyTo(instructions);
instructions.setEnabled(false);
final Composite filterBar = toolkit.createComposite(composite);
GridDataBuilder.newInstance().hGrab().hFill().applyTo(filterBar);
filterBar.setLayout(new RowLayout(SWT.HORIZONTAL));
createFilterHyperlink(
filterBar,
toolkit,
Messages.getString("TeamExplorerSearchControlPopup.AssignedTo"), //$NON-NLS-1$
"A", //$NON-NLS-1$
WIQLOperators.getLocalizedOperator(WIQLOperators.MACRO_ME),
Messages.getString("TeamExplorerSearchControlPopup.AssignedToTooltip")); //$NON-NLS-1$
createFilterHyperlink(
filterBar,
toolkit,
Messages.getString("TeamExplorerSearchControlPopup.CreatedBy"), //$NON-NLS-1$
"C", //$NON-NLS-1$
WIQLOperators.getLocalizedOperator(WIQLOperators.MACRO_ME),
Messages.getString("TeamExplorerSearchControlPopup.CreatedByTooltip")); //$NON-NLS-1$
createFilterHyperlink(
filterBar,
toolkit,
Messages.getString("TeamExplorerSearchControlPopup.State"), //$NON-NLS-1$
"S", //$NON-NLS-1$
"", //$NON-NLS-1$
Messages.getString("TeamExplorerSearchControlPopup.StateTooltip")); //$NON-NLS-1$
createFilterHyperlink(
filterBar,
toolkit,
Messages.getString("TeamExplorerSearchControlPopup.WorkItemType"), //$NON-NLS-1$
"T", //$NON-NLS-1$
"", //$NON-NLS-1$
Messages.getString("TeamExplorerSearchControlPopup.WorkItemTypeTooltip")); //$NON-NLS-1$
return composite;
}
示例12: showAnnotations
import org.eclipse.jface.viewers.ListViewer; //導入方法依賴的package包/類
/**
* Show the annotation view.
* @param svnFile
* @param svnAnnotateBlocks
* @param contents
* @param useHistoryView
* @throws PartInitException
*/
public void showAnnotations(ISVNRemoteFile svnFile, Collection svnAnnotateBlocks, InputStream contents, boolean useHistoryView) throws PartInitException {
// Disconnect from old annotation editor
disconnect();
// Remove old viewer
Control[] oldChildren = top.getChildren();
if (oldChildren != null) {
for (int i = 0; i < oldChildren.length; i++) {
oldChildren[i].dispose();
}
}
viewer = new ListViewer(top, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
viewer.setContentProvider(new ArrayContentProvider());
viewer.setLabelProvider(new LabelProvider());
viewer.addSelectionChangedListener(this);
viewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
PlatformUI.getWorkbench().getHelpSystem().setHelp(viewer.getControl(), IHelpContextIds.ANNOTATIONS_VIEW);
top.layout();
this.svnFile = svnFile;
this.contents = contents;
this.svnAnnotateBlocks = svnAnnotateBlocks;
page = SVNUIPlugin.getActivePage();
viewer.setInput(svnAnnotateBlocks);
editor = (ITextEditor) openEditor();
IDocumentProvider provider = editor.getDocumentProvider();
document = provider.getDocument(editor.getEditorInput());
setPartName(Policy.bind("SVNAnnotateView.showFileAnnotation", new Object[] {svnFile.getName()})); //$NON-NLS-1$
setTitleToolTip(svnFile.getName());
if (!useHistoryView) {
return;
}
// Get hook to the HistoryView
historyView = (IHistoryView)page.showView(ISVNUIConstants.HISTORY_VIEW_ID);
if (historyView != null) {
historyView.showHistoryFor(svnFile);
}
}
示例13: createControl
import org.eclipse.jface.viewers.ListViewer; //導入方法依賴的package包/類
@Override
public void createControl(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
composite.setLayout(layout);
layout.numColumns = 1;
composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
Group elementType = new Group(composite, SWT.NONE);
elementType.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 3;
elementType.setLayout(gridLayout);
elementType.setText("Select referred type");
radios = new Button[3];
radios[0] = new Button(elementType, SWT.RADIO);
radios[0].setSelection(false);
radios[0].setText(EXISTING_ABSTRACT_ELEMENT);
radios[0].setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
radios[0].addSelectionListener(new ExistingListener());
radios[1] = new Button(elementType, SWT.RADIO);
radios[1].setSelection(false);
radios[1].setText(CONCRETE_ELEMENT);
radios[1].setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
radios[1].addSelectionListener(new NotationListener());
Group element = new Group(composite, SWT.NONE);
element.setBounds(new Rectangle(0, 0, 500, 500));
element.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
GridLayout gridLayout2 = new GridLayout();
gridLayout2.numColumns = 1;
element.setLayout(gridLayout2);
element.setText("Select Element");
elementList = new ListViewer(element, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
elementList.getList().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
elementList.setContentProvider(new SyntaxElementContentProvider());
elementList.setLabelProvider(new SyntaxElementLabelProvider());
setControl(composite);
}
示例14: createControl
import org.eclipse.jface.viewers.ListViewer; //導入方法依賴的package包/類
@Override
public void createControl(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
composite.setLayout(layout);
layout.numColumns = 1;
composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
Group elementType = new Group(composite, SWT.NONE);
elementType.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 3;
elementType.setLayout(gridLayout);
elementType.setText("Select referred type");
radios = new Button[4];
radios[0] = new Button(elementType, SWT.RADIO);
radios[0].setSelection(false);
radios[0].setText(EXISTING_ABSTRACT_ELEMENT);
radios[0].setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
radios[0].addSelectionListener(new ExistingListener());
radios[1] = new Button(elementType, SWT.RADIO);
radios[1].setSelection(false);
radios[1].setText(NEW_ABSTRACT_ELEMENT);
radios[1].setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
radios[1].addSelectionListener(new NewListener());
radios[2] = new Button(elementType, SWT.RADIO);
radios[2].setSelection(false);
radios[2].setText(CONCRETE_ELEMENT);
radios[2].setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
radios[2].addSelectionListener(new NotationListener());
radios[3] = new Button(elementType, SWT.RADIO);
radios[3].setSelection(false);
radios[3].setText(EXISTING_CONCRETE_ELEMENT);
radios[3].setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
radios[3].addSelectionListener(new ExistingNotationListener());
Group element = new Group(composite, SWT.NONE);
element.setBounds(new Rectangle(0, 0, 600, 500));
element.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
GridLayout gridLayout2 = new GridLayout();
gridLayout2.numColumns = 1;
element.setLayout(gridLayout2);
element.setText("Select Element");
elementList = new ListViewer(element, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
elementList.getList().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
elementList.setContentProvider(new SyntaxElementContentProvider());
elementList.setLabelProvider(new NewLabelProvider());
setControl(composite);
}
示例15: createControl
import org.eclipse.jface.viewers.ListViewer; //導入方法依賴的package包/類
@Override
public void createControl(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
composite.setLayout(layout);
layout.numColumns = 1;
composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
Group elementType = new Group(composite, SWT.NONE);
elementType.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 2;
elementType.setLayout(gridLayout);
elementType.setText("Select referred type");
radios = new Button[2];
radios[0] = new Button(elementType, SWT.RADIO);
radios[0].setSelection(false);
radios[0].setText(EXISTING_ABSTRACT_ELEMENT);
radios[0].setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
radios[0].addSelectionListener(new ExistingListener());
radios[1] = new Button(elementType, SWT.RADIO);
radios[1].setSelection(false);
radios[1].setText(CONCRETE_ELEMENT);
radios[1].setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
radios[1].addSelectionListener(new NotationListener());
Group element = new Group(composite, SWT.NONE);
element.setBounds(new Rectangle(0, 0, 500, 500));
element.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
GridLayout gridLayout2 = new GridLayout();
gridLayout2.numColumns = 1;
element.setLayout(gridLayout2);
element.setText("Select Element");
elementList = new ListViewer(element, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
elementList.getList().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
elementList.setContentProvider(new SyntaxElementContentProvider());
elementList.setLabelProvider(new SyntaxElementLabelProvider());
setControl(composite);
}