I am trying to work out how JFace's structural elements work. I made the following simple interface:
protected Control createContents(Composite parent)
{
Composite container = new Composite(parent, SWT.NONE);
container.setLayout(new FillLayout(SWT.HORIZONTAL));
TableViewer tableViewer = new TableViewer(container, SWT.BORDER | SWT.FULL_SELECTION);
table = tableViewer.getTable();
table.setLinesVisible(true);
table.setHeaderVisible(true);
tableViewer.setContentProvider(ArrayContentProvider.getInstance());
tableViewer.setInput(new String[][]{{"1", "2", "3"},{"1", "2", "3"},{"1", "2", "3"}});
TableViewerColumn tableViewerColumn = new TableViewerColumn(tableViewer, SWT.NONE);
TableColumn tblclmnTest = tableViewerColumn.getColumn();
tblclmnTest.setWidth(58);
tblclmnTest.setText("Test1");
tableViewerColumn.setLabelProvider(new ColumnLabelProvider()
{
#Override
public String getText(Object element)
{
return super.getText(((String[])element)[0]);
}
});
TableViewerColumn tableViewerColumn2 = new TableViewerColumn(tableViewer, SWT.NONE);
TableColumn tblclmnTest2 = tableViewerColumn2.getColumn();
tblclmnTest2.setWidth(58);
tblclmnTest2.setText("Test2");
tableViewerColumn2.setLabelProvider(new ColumnLabelProvider()
{
#Override
public String getText(Object element)
{
return super.getText(((String[])element)[1]);
}
});
TableViewerColumn tableViewerColumn3 = new TableViewerColumn(tableViewer, SWT.NONE);
TableColumn tblclmnTest3 = tableViewerColumn3.getColumn();
tblclmnTest3.setWidth(58);
tblclmnTest3.setText("Test3");
tableViewerColumn3.setLabelProvider(new ColumnLabelProvider()
{
#Override
public String getText(Object element)
{
return super.getText(((String[])element)[2]);
}
});
return container;
}
I did everything similar to the tutorial but the problem is: getText() methods aren't being called. I figured it out by inserting System.out.prinln into them. And the result doesn't look like it supposed to look:
What is my mistake?
You are calling tableViewer.setInput before setting up the table columns - you must do the setInput after all the columns are defined.
Related
I am reading excel data and taking headers(only first row) as my columns and added to list and this list is added as input to my tableviewer to display data in my table.I am creating tablecolumns and added the label provider. I am able to see the data in the table. Now i want to display the all textboxes as combos in each column . How can i can add combos for each column? my code is like
my tableviewer class
public class TableViewerExample {
public TableViewerExample(Shell shell) {
TableViewer viewer = new TableViewer(shell, SWT.BORDER | SWT.FULL_SELECTION);
TableViewerColumn upDownColumn = new TableViewerColumn(viewer, SWT.NONE);
upDownColumn.getColumn().setText("Display Order");
upDownColumn.getColumn().setWidth(200);
upDownColumn.setLabelProvider(new ColumnLabelProvider() {
#Override
public String getText(Object element) {
return ((DataSourceModel) element).getDisplayOrder();
}
});
TableViewerColumn checkboxColumn = new TableViewerColumn(viewer, SWT.NONE);
checkboxColumn.getColumn().setText("Checkbox Selection");
checkboxColumn.getColumn().setWidth(200);
checkboxColumn.setLabelProvider(new ColumnLabelProvider() {
#Override
public String getText(Object element) {
return ((DataSourceModel) element).getCheckboxSelection();
}
});
TableViewerColumn uniqueFieldsColumn = new TableViewerColumn(viewer, SWT.NONE);
uniqueFieldsColumn.getColumn().setText("Unique Fields");
uniqueFieldsColumn.getColumn().setWidth(200);
uniqueFieldsColumn.setLabelProvider(new ColumnLabelProvider() {
#Override
public String getText(Object element) {
return ((DataSourceModel) element).getUniqueFields();
}
});
TableViewerColumn inputFieldNameColumn = new TableViewerColumn(viewer, SWT.NONE);
inputFieldNameColumn.getColumn().setText("Input Field Name");
inputFieldNameColumn.getColumn().setWidth(200);
inputFieldNameColumn.setLabelProvider(new ColumnLabelProvider() {
#Override
public String getText(Object element) {
return ((DataSourceModel) element).getInputFieldName();
}
});
TableViewerColumn dataTypeColumn = new TableViewerColumn(viewer, SWT.NONE);
dataTypeColumn.getColumn().setText("Data Type");
dataTypeColumn.getColumn().setWidth(200);
dataTypeColumn.setLabelProvider(new ColumnLabelProvider() {
#Override
public String getText(Object element) {
return ((DataSourceModel) element).getDataType();
}
});
TableViewerColumn inputFieldFormatColumn = new TableViewerColumn(viewer, SWT.NONE);
inputFieldFormatColumn.getColumn().setText("Input Field Format");
inputFieldFormatColumn.getColumn().setWidth(200);
inputFieldFormatColumn.setLabelProvider(new ColumnLabelProvider() {
#Override
public String getText(Object element) {
return ((DataSourceModel) element).getInputFieldFormat();
}
});
TableViewerColumn displayNameColumn = new TableViewerColumn(viewer, SWT.NONE);
displayNameColumn.getColumn().setText("Display Name");
displayNameColumn.getColumn().setWidth(200);
displayNameColumn.setLabelProvider(new ColumnLabelProvider() {
#Override
public String getText(Object element) {
return ((DataSourceModel) element).getDisplayName();
}
});
TableViewerColumn displayFormatColumn = new TableViewerColumn(viewer, SWT.NONE);
displayFormatColumn.getColumn().setText("Display Format");
displayFormatColumn.getColumn().setWidth(200);
displayFormatColumn.setLabelProvider(new ColumnLabelProvider() {
#Override
public String getText(Object element) {
return ((DataSourceModel) element).getDisplayFormat();
}
});
viewer.setContentProvider(ArrayContentProvider.getInstance());
System.out.println(RetrieveExcelData.getDataSourceFieldsList());
viewer.setInput(RetrieveExcelData.getDataSourceFieldsList());
viewer.getTable().setLinesVisible(true);
viewer.getTable().setHeaderVisible(true);
}
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
new TableViewerExample(shell);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
setinput class
public class RetrieveExcelData {
public static List getDataSourceFieldsList() {
String filename = "D:\\ServiceOrders_point_Org_morethan500.xlsx";
List<List<XSSFCell>> sheetData = new ArrayList<>();
try (FileInputStream fis = new FileInputStream(filename)) {
XSSFWorkbook workbook = new XSSFWorkbook(fis);
XSSFSheet myExcelSheet = workbook.getSheetAt(0);
XSSFRow row = (XSSFRow )myExcelSheet.getRow(0);
Iterator cells=row.cellIterator();
List<XSSFCell> data = new ArrayList<>();
while (cells.hasNext()) {
XSSFCell cell = (XSSFCell) cells.next();
data.add(cell);
}
sheetData.add(data);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return showExcelData(sheetData);
}
private static List showExcelData(List<List<XSSFCell>> sheetData) {
List<DataSourceModel> resultList = new ArrayList();
// Iterates the data and print it out to the console.
for (List<XSSFCell> data : sheetData) {
for (XSSFCell cell : data) {
DataSourceModel dataSourceModel=new DataSourceModel(cell.getStringCellValue(), cell.getStringCellValue(), cell.getStringCellValue(), cell.getStringCellValue(), cell.getStringCellValue(), cell.getStringCellValue(), cell.getStringCellValue(), cell.getStringCellValue());
resultList.add(dataSourceModel);
}
}
return resultList;
}
my model class
public class DataSourceModel {
private String displayOrder;
private String checkboxSelection;
private String uniqueFields;
private String inputFieldName;
private String dataType;
private String inputFieldFormat;
private String displayName;
private String displayFormat;
public DataSourceModel(String displayOrder,String checkboxSelection,String uniqueFields,String inputFieldName,String dataType, String inputFieldFormat, String displayName,String displayFormat) {
this.displayOrder=displayOrder;
this.checkboxSelection=checkboxSelection;
this.uniqueFields=uniqueFields;
this.inputFieldName=inputFieldName;
this.dataType=dataType;
this.inputFieldFormat=inputFieldFormat;
this.displayName=displayName;
this.displayFormat=displayFormat;
}
public String getDisplayOrder() {
return displayOrder;
}
public void setDisplayOrder(String displayOrder) {
this.displayOrder = displayOrder;
}
public String getCheckboxSelection() {
return checkboxSelection;
}
public void setCheckboxSelection(String checkboxSelection) {
this.checkboxSelection = checkboxSelection;
}
public String getUniqueFields() {
return uniqueFields;
}
public void setUniqueFields(String uniqueFields) {
this.uniqueFields = uniqueFields;
}
public String getInputFieldName() {
return inputFieldName;
}
public void setInputFieldName(String inputFieldName) {
this.inputFieldName = inputFieldName;
}
public String getDataType() {
return dataType;
}
public void setDataType(String dataType) {
this.dataType = dataType;
}
public String getInputFieldFormat() {
return inputFieldFormat;
}
public void setInputFieldFormat(String inputFieldFormat) {
this.inputFieldFormat = inputFieldFormat;
}
public String getDisplayName() {
return displayName;
}
public void setDisplayName(String displayName) {
this.displayName = displayName;
}
public String getDisplayFormat() {
return displayFormat;
}
public void setDisplayFormat(String displayFormat) {
this.displayFormat = displayFormat;
}
and the table looks like
Now i want to make combos instead of text in the columns . Colud you please help how can i change to combos instead of text boxes using my code for all
I am using Tree and in this tree I have a five treecolumn. Also create two treeItem one is parent and other child, put their values in treecolumn by programatically. Now I need a dropdown List(Combobox) in each tree column(except first one) to view the list data. Currently getting only single value. Please see the below code to get tree item values editable in treecolumn.
private void editTreeTable(final Tree table){
final TreeEditor editor = new TreeEditor(table);
editor.horizontalAlignment = SWT.LEFT;
editor.grabHorizontal = true;
table.addMouseListener(new MouseAdapter() {
#Override
public void mouseUp(final MouseEvent e) {
final Control oldEditor = editor.getEditor();
if (oldEditor != null) {
oldEditor.dispose();
}
final Point p = new Point(e.x, e.y);
final TreeItem item = table.getItem(p);
if (item == null) {
return;
}
for (int i = 1; i < table.getColumnCount(); ++i) {
if (item.getBounds(i).contains(p)) {
final int columnIndex = i;
// The control that will be the editor must be a
final Text newEditor = new Text(table, SWT.NONE);
newEditor.setText(item.getText(columnIndex ));
newEditor.addModifyListener(new ModifyListener() {
public void modifyText(final ModifyEvent e) {
final Text text = (Text) editor.getEditor();
editor.getItem().setText(columnIndex , text.getText());
}
});
newEditor.selectAll();
newEditor.setFocus();
editor.setEditor(newEditor, item, columnIndex );
}
}
}
});
}
Now find the below code to get the tree item value from API
private void createTestSuiteTable( final Tree table)
{
//Dispose all elements
TreeItem items[] = table.getItems();
for(int i=0;i<items.length;i++)
{
items[i].dispose();
}
TSGson tsGsons[] = TestSuiteAPIHandler.getInstance().getAllTestSuites();
boolean checked=false;
for (TSGson tsGson : tsGsons)
{
parentTestSuite = new TreeItem(table, SWT.NONE|SWT.MULTI);
parentTestSuite.setText(new String[] { "" +tsGson.tsName, "", "","","","" });
parentTestSuite.setData("EltType","TESTSUITE");
if(tsGson.tsTCLink==null)
continue;
for(TSTCGson tsTCGson : tsGson.tsTCLink)
{
TreeItem trtmTestcases = new TreeItem(parentTestSuite, SWT.NONE|SWT.MULTI);
trtmTestcases.setText(new String[] {tsTCGson.tcName,
tsTCGson.tcParams.get(0)!=null ?tsTCGson.tcParams.get(0).tcparamValue:"",
tsTCGson.tcParams.get(1)!=null ?tsTCGson.tcParams.get(1).tcparamValue:"",
tsTCGson.tcParams.get(2)!=null ?tsTCGson.tcParams.get(2).tcparamValue:"",
"local",
tsTCGson.tcParams.get(4)!=null ?tsTCGson.tcParams.get(4).tcparamValue:"" });
trtmTestcases.setData("EltType","TESTCASE");
table.setSelection(parentTestSuite);
if(checked)
{
trtmTestcases.setChecked(checked);
}
}
}
}
Find the below code for tree column creation in SWT
localHostTable = new Tree(composite_2,SWT.BORDER | SWT.CHECK | SWT.FULL_SELECTION | SWT.VIRTUAL);
localHostTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
localHostTable.setLinesVisible(true);
localHostTable.setHeaderVisible(true);
TreeColumn trclmnNewColumn_1 = new TreeColumn(localHostTable, SWT.NONE);
trclmnNewColumn_1.setWidth(113);
trclmnNewColumn_1.setText("TestSuite/TestCase");
TreeColumn trclmnColumn_5 = new TreeColumn(localHostTable, SWT.NONE);
trclmnColumn_5.setWidth(73);
trclmnColumn_5.setText("Exe_Platform");
TreeColumn trclmnColumn_6 = new TreeColumn(localHostTable, SWT.NONE);
trclmnColumn_6.setWidth(77);
trclmnColumn_6.setText("Exe_Type");
TreeColumn trclmnColumn_7 = new TreeColumn(localHostTable, SWT.NONE);
trclmnColumn_7.setWidth(85);
trclmnColumn_7.setText("Run_On");
TreeColumn trclmnColumn_8 = new TreeColumn(localHostTable, SWT.NONE);
trclmnColumn_8.setWidth(81);
trclmnColumn_8.setText("Thread-Count");
final TreeColumn trclmnColumn_9 = new TreeColumn(localHostTable, SWT.NONE);
trclmnColumn_9.setWidth(97);
trclmnColumn_9.setText("Column5");
please suggest
Since there's nothing in your question about Combo or CCombo controls, I can't help you troubleshoot an issue. I also am not going to write your code for you, but I can try to point you in the right direction with a short example.
Yes, i want the combo to always be visible.
You can still use a TreeEditor to accomplish this, and it will actually be simpler than the code snippet you posted with the MouseListener.
Create the CCombo (or Combo) as you would in any other situation, and use TreeEditor.setEditor(...) methods to specify that the CCombo control should be displayed in that cell:
// ...
final CCombo combo = new CCombo(tree, SWT.NONE);
final TreeEditor editor = new TreeEditor(tree);
editor.setEditor(combo, item, 1);
// ...
Full MCVE:
public class TreeComboBoxTest {
private final Display display;
private final Shell shell;
public TreeComboBoxTest() {
display = new Display();
shell = new Shell(display);
shell.setLayout(new FillLayout());
final Tree tree = new Tree(shell, SWT.BORDER | SWT.VIRTUAL | SWT.FULL_SELECTION);
tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
tree.setLinesVisible(true);
tree.setHeaderVisible(true);
final TreeColumn column1 = new TreeColumn(tree, SWT.NONE);
column1.setWidth(75);
column1.setText("Column 1");
final TreeColumn column2 = new TreeColumn(tree, SWT.NONE);
column2.setWidth(75);
column2.setText("Column 2");
final TreeItem item = new TreeItem(tree, SWT.NONE);
item.setText(0, "Hello");
final CCombo combo = new CCombo(tree, SWT.NONE);
combo.setItems(new String[] { "Item 1", "Item 2", "Item 3" });
final TreeEditor editor = new TreeEditor(tree);
editor.setEditor(combo, item, 1);
editor.horizontalAlignment = SWT.LEFT;
editor.grabHorizontal = true;
// Optional, but allows you to get the current value by calling
// item.getText() instead of going through the TreeEditor and
// calling ((CCombo) editor.getEditor()).getText()
combo.addSelectionListener(new SelectionAdapter() {
#Override
public void widgetSelected(final SelectionEvent e) {
item.setText(1, combo.getText());
}
});
}
public void run() {
shell.setSize(200, 200);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
public static void main(final String... args) {
new TreeComboBoxTest().run();
}
}
Note the SelectionListener added to the CCombo. Even though you've used the TreeEditor, if you call item.getText(index), it will return an empty String because setText(...) has not been called. By calling setText(...) in the listener, you won't have to go through the TreeEditor to get the value.
So you can call item.getText(index) instead of ((CCombo) editor.getEditor()).getText().
When I create combo box in particular only one 3rd column using table viewer in Eclipse SWT.
I think I've done everything ok until now, however when I compile the code then i get error:
Code:
public void createPartControl(Composite parent) {
Composite tableComposite = new Composite(parent, SWT.NONE);
tableColumnLayout = new TableColumnLayout();
tableComposite.setLayout(tableColumnLayout);
tableComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true,
true));
tableViewer = new TableViewer(tableComposite, SWT.MULTI | SWT.H_SCROLL
| SWT.V_SCROLL);
tableViewer.setContentProvider(ArrayContentProvider.getInstance());
// TODO viewer.setLabelProvider(new ViewLabelProvider());
table = tableViewer.getTable();
// Table table = tableViewer.getTable();
table.setHeaderVisible(true);
table.setLinesVisible(true);
String[] titles = { "Threat Name", "Category Name", "Status",
"Priority", "Description", "Justification" };
int[] bounds = { 100, 100, 100, 100 };
TableViewerColumn col = createTableViewerColumn(titles[2], bounds[2], 2);
col.setLabelProvider(new ColumnLabelProvider() {
#Override
public String getText(Object element) {
Dummy p = (Dummy) element;
return p.getValue();
}
});
col.setEditingSupport(new FirstValueEditingSupport(tableViewer));
}
private SelectionAdapter getSelectionAdapter(final TableColumn column,
final int index) {
SelectionAdapter selectionAdapter = new SelectionAdapter() {
#Override
public void widgetSelected(SelectionEvent e) {
tableViewer.refresh();
}
};
return selectionAdapter;
}
private static class Dummy {
public String value;
public Dummy(String value) {
this.value = value;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
public static class FirstValueEditingSupport extends EditingSupport {
private final TableViewer viewer;
private final CellEditor editor;
private final String[] possibleValues = { "Mitigated",
"Not Applicable", "Not Started", "Needs Investigation" };
public FirstValueEditingSupport(TableViewer viewer) {
super(viewer);
this.viewer = viewer;
this.editor = new ComboBoxCellEditor(viewer.getTable(),
possibleValues);
}
#Override
protected CellEditor getCellEditor(Object element) {
return editor;
}
#Override
protected boolean canEdit(Object element) {
return true;
}
#Override
protected Object getValue(Object element) {
Dummy dummy = (Dummy) element;
int index = 0;
for (int i = 0; i < possibleValues.length; i++) {
if (Objects.equals(possibleValues[i], dummy.getValue())) {
index = i;
break;
}
}
return index;
}
#Override
protected void setValue(Object element, Object value) {
Dummy dummy = (Dummy) element;
int index = (Integer) value;
dummy.setValue(possibleValues[index]);
viewer.update(element, null);
}
}
private void fillRows(String shortdesc, String categ, String descp) {
System.out.println("fillRows call from above method.");
TableColumn status_Name_Col = tableViewer.getTable().getColumn(2);
System.out.println("**************** status_Name_Col ************ "
+ status_Name_Col);
tableViewer
.addSelectionChangedListener(new ISelectionChangedListener() {
#Override
public void selectionChanged(
SelectionChangedEvent selectionChangedEvent) {
StructuredSelection selection = (StructuredSelection) selectionChangedEvent
.getSelection();
System.out.println(((Dummy) selection.getFirstElement())
.getValue());
}
});
List<Dummy> elements = new ArrayList<>();
for (int i = 0; i < Connection.Number_Of_Connection; i++) {
elements.add(new Dummy("First option"));
}
tableViewer.setInput(elements);
tableColumnLayout.setColumnData(status_Name_Col, new ColumnWeightData(
1, true));
tableViewerColumn.setEditingSupport(new FirstValueEditingSupport(
tableViewer));
}
Questions:
how to display combo box in particular only one column?
You must not do the TableViewer setInput call until you have set up everything on the table. All the content providers, label providers, column layouts, editing support, .... must be set before setInput is called.
You must also call setColumnData for every column you create.
I am trying to make a combobox in table viewer in Eclipse SWT.pointing me in the right direction.I think I've done everything ok until now, problem is the combo box not display in the table,I got error this:
Error:
Block of Code is:
public void createPartControl(Composite parent) {
System.out.println("createPartControl call");
// For Testing
Composite tableComposite = new Composite(parent, SWT.NONE);
tableColumnLayout = new TableColumnLayout();
tableComposite.setLayout(tableColumnLayout);
tableComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true,
true));
tableViewer = new TableViewer(tableComposite, SWT.MULTI | SWT.H_SCROLL
| SWT.V_SCROLL);
tableViewer.setContentProvider(ArrayContentProvider.getInstance());
// TODO viewer.setLabelProvider(new ViewLabelProvider());
table = tableViewer.getTable();
// Table table = tableViewer.getTable();
table.setHeaderVisible(true);
table.setLinesVisible(true);
String[] titles = { "Threat Name", "Category Name", "Status",
"Priority", "Description", "Justification" };
for (int loopIndex = 0; loopIndex < titles.length; loopIndex++) {
tableViewerColumn = new TableViewerColumn(tableViewer, SWT.NONE);
TableColumn tblclmn = tableViewerColumn.getColumn();
tableColumnLayout.setColumnData(tblclmn, new ColumnPixelData(200,
true, true));
tblclmn.setText(titles[loopIndex]);
}
}
private void fillRows(String shortdesc, String categ, String descp) {
System.out.println("fillRows call from above method.");
TableColumn status_Name_Col = tableViewer.getTable().getColumn(2);
System.out.println("**************** status_Name_Col ************ "+ status_Name_Col);
tableViewerColumn.setLabelProvider(new ColumnLabelProvider()
{
#Override
public String getText(Object element)
{
Dummy p = (Dummy) element;
return p.getValue();
}
});
tableViewer.addSelectionChangedListener(new ISelectionChangedListener()
{
#Override
public void selectionChanged(SelectionChangedEvent selectionChangedEvent)
{
StructuredSelection selection = (StructuredSelection) selectionChangedEvent.getSelection();
System.out.println(((Dummy) selection.getFirstElement()).getValue());
}
});
List<Dummy> elements = new ArrayList<>();
for (int i = 0; i < Connection.Number_Of_Connection; i++) {
elements.add(new Dummy("First option"));
}
tableViewer.setInput(elements);
tableColumnLayout.setColumnData(status_Name_Col, new ColumnWeightData(1, true));
tableViewerColumn.setEditingSupport(new FirstValueEditingSupport(tableViewer));
}
The assertion message is pretty clear - you must set a label provider for each column in the table.
You don't show us where you are calling fillRows but setting the column label provider in that method looks wrong - set the label providers in your loop creating the columns.
The code below creates 2 tabs.
Each tab has a grid with 1 column.
In the first tab the table header displays the dropdown with hide/show columns and sort.
In the second tab the dropdown is missing from the table header.
What am I doing wrong?
Thanks
public void onModuleLoad()
{
Grid table1 = createTable();
Grid table2 = createTable();
TabPanel tabPanel = new TabPanel();
tabPanel.add(table1, "Grid 1");
tabPanel.add(table2, "Grid 2");
RootLayoutPanel.get().add(tabPanel);
}
Grid createTable()
{
ColumnConfig<HashMap, String> nameCol = new ColumnConfig<HashMap, String>(
new ValueProvider<HashMap, String>()
{
#Override
public String getValue(HashMap object)
{
return (String) object.get("COL1");
}
#Override
public void setValue(HashMap object, String value)
{
object.put("COL1", value);
}
#Override
public String getPath()
{
// TODO Auto-generated method stub
return "1";
}
}, 200, SafeHtmlUtils.fromTrustedString("<b>Column 1</b>"));
List<ColumnConfig<HashMap, ?>> l = new ArrayList<ColumnConfig<HashMap, ?>>();
l.add(nameCol);
ColumnModel<HashMap> cm = new ColumnModel<HashMap>(l);
ModelKeyProvider<HashMap> modelKeyProvider = new ModelKeyProvider<HashMap>()
{
#Override
public String getKey(HashMap item)
{
return (String) item.get("COL1");
}
};
ListStore<HashMap> store = new ListStore<HashMap>(modelKeyProvider);
store.addAll(getStocks());
Grid table = new Grid(store, cm);
return table;
}
public static List<HashMap> getStocks()
{
List<HashMap> stocks = new ArrayList<HashMap>();
for (int i = 0; i < 1000; i++)
{
HashMap hashMap = new HashMap();
hashMap.put("COL1", "Line: " + i);
stocks.add(hashMap);
}
return stocks;
}
Looks like that the little button with the dropdown has 0 height. It must be because it's inside a tab that is not visible.
Refreshing the header solves this.
TabPanel tabPanel = new TabPanel();
tabPanel.addSelectionHandler(new SelectionHandler<Widget>()
{
#Override
public void onSelection(SelectionEvent<Widget> event)
{
if(table1.getView() != null && table1.getView().getHeader() != null)
table1.getView().getHeader().refresh();
}
});