Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 23500 Details for
Bug 100686
Virtual Tables Not populating on Windows 2003 Server
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Sample test dialog with TableViewer component
TestTableDialog.java (text/java), 4.56 KB, created by
Phil Hunt
on 2005-06-17 19:06:58 EDT
(
hide
)
Description:
Sample test dialog with TableViewer component
Filename:
MIME Type:
Creator:
Phil Hunt
Created:
2005-06-17 19:06:58 EDT
Size:
4.56 KB
patch
obsolete
>package com.octetstring.dme.ui.views.dialogs; > >import java.util.LinkedList; > >import org.eclipse.jface.dialogs.IDialogConstants; >import org.eclipse.jface.dialogs.TitleAreaDialog; >import org.eclipse.jface.viewers.IStructuredContentProvider; >import org.eclipse.jface.viewers.ITableLabelProvider; >import org.eclipse.jface.viewers.LabelProvider; >import org.eclipse.jface.viewers.TableViewer; >import org.eclipse.jface.viewers.Viewer; >import org.eclipse.swt.SWT; >import org.eclipse.swt.graphics.Image; >import org.eclipse.swt.graphics.Point; >import org.eclipse.swt.layout.GridData; >import org.eclipse.swt.widgets.Composite; >import org.eclipse.swt.widgets.Control; >import org.eclipse.swt.widgets.Shell; >import org.eclipse.swt.widgets.Table; >import org.eclipse.swt.widgets.TableColumn; > >import com.octetstring.vde.config.adapters.LdapHost; > >public class TestTableDialog extends TitleAreaDialog { > > class HostsLabelProvider extends LabelProvider implements ITableLabelProvider { > > public String getColumnText(Object element, int columnIndex) { > String result = ""; > HostObj host = null; > if (element instanceof HostObj) > host = (HostObj) element; > else return result; > switch (columnIndex) { > case 0: > result = host.getCol1(); > break; > case 1: > result = ""+host.getCol2(); > break; > case 2: > result = ""+host.getCol3(); > break; > case 3: > result = host.getCol4(); > break; > default: > break; > } > return result; > } > > public Image getColumnImage(Object element, int columnIndex) { > return null; > } > } > > class HostObj extends Object { > private String col1,col2,col3,col4; > > public HostObj(String col1, String col2, String col3, String col4) { > this.col1 = col1; > this.col2 = col2; > this.col3 = col3; > this.col4 = col4; > } > > public String getCol1() { > return this.col1; > } > public String getCol2() { > return this.col2; > } > public String getCol3() { > return this.col3; > } > public String getCol4() { > return this.col4; > } > } > > class ContentProvider implements IStructuredContentProvider { > public LinkedList servers; > > public Object[] getElements(Object inputElement) { > if (servers == null) { > servers = new LinkedList(); > for (int i=1; i < 5; i++) { > HostObj host = new HostObj("Server "+i,"Col2 "+i,"Col3 "+i,"Col4 "+i); > servers.add(host); > } > } > > return this.servers.toArray(); > > } > > public LinkedList getList() { > return this.servers; > } > > public void dispose() { > } > public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { > if (oldInput != newInput && newInput instanceof LinkedList) { > this.servers = (LinkedList) newInput; > } > } > } > > private Table table; > public TestTableDialog(Shell parentShell) { > super(parentShell); > } > > protected Control createDialogArea(Composite parent) { > Composite area = (Composite) super.createDialogArea(parent); > Composite container = new Composite(area, SWT.NONE); > container.setLayout(new swing2swt.layout.GridLayout()); > container.setLayoutData(new GridData(GridData.FILL_BOTH)); > > final TableViewer tableViewer = new TableViewer(container, SWT.BORDER); > table = tableViewer.getTable(); > table.setHeaderVisible(true); > table.setLinesVisible(true); > > final TableColumn col1TableColumn = new TableColumn(table, SWT.NONE); > col1TableColumn.setWidth(100); > col1TableColumn.setText("Col1"); > > final TableColumn col2TableColumn = new TableColumn(table, SWT.NONE); > col2TableColumn.setWidth(100); > col2TableColumn.setText("Col2"); > > final TableColumn col3TableColumn = new TableColumn(table, SWT.NONE); > col3TableColumn.setWidth(100); > col3TableColumn.setText("Col3"); > > final TableColumn col4TableColumn = new TableColumn(table, SWT.NONE); > col4TableColumn.setWidth(100); > col4TableColumn.setText("Col4"); > ContentProvider cp = new ContentProvider(); > tableViewer.setContentProvider(cp); > tableViewer.setLabelProvider(new HostsLabelProvider()); > tableViewer.setInput(cp.getList()); > tableViewer.refresh(true); > area.redraw(); > // > return area; > } > > protected void createButtonsForButtonBar(Composite parent) { > createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, > true); > createButton(parent, IDialogConstants.CANCEL_ID, > IDialogConstants.CANCEL_LABEL, false); > } > > protected Point getInitialSize() { > return new Point(500, 375); > } > protected void configureShell(Shell newShell) { > super.configureShell(newShell); > newShell.setText("Test Dialog"); > } > >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 100686
: 23500 |
23568
|
23570
|
23572