Home » Eclipse Projects » NatTable » Simple Cell Editing
Simple Cell Editing [message #1053708] |
Tue, 07 May 2013 10:43 |
Aljoscha Steffens Messages: 302 Registered: November 2012 |
Senior Member |
|
|
Hi,
I'm tinker with this problem since a couple of hours and even if it's so basic, I can't get it working.
So all I need is a simple Text(Cell)Editor for selected cells and maybe a check an input check (so that only numbers can be put in).
This is the code:
dataProvider = new DataProvider();
final ViewportLayer layer = new ViewportLayer( new DataLayer(dataProvider) );
IConfigLabelAccumulator cellLabelAccumulator = new IConfigLabelAccumulator() {
public void accumulateConfigLabels(LabelStack configLabels, int columnPosition, int rowPosition) {
configLabels.addLabel("myCellLabel");
}
};
layer.setConfigLabelAccumulator(cellLabelAccumulator);
natTable = new NatTable(container, layer, false);
natTable.addConfiguration(new AbstractRegistryConfiguration() {
public void configureRegistry(IConfigRegistry configRegistry) {
TextCellEditor textCellEditor = new TextCellEditor();
configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITOR, textCellEditor, DisplayMode.EDIT, "myCellLabel");
//configRegistry.registerConfigAttribute( EditConfigAttributes.CELL_EDITABLE_RULE, IEditableRule.ALWAYS_EDITABLE, DisplayMode.EDIT, "myCellLabel");
}
});
natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
natTable.configure();
Neither of the "configRegistry.registerConfigAttribute(..)" functions work. What did I do wrong?
|
|
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
Re: Simple Cell Editing [message #1057801 is a reply to message #1057760] |
Wed, 08 May 2013 20:46 |
Aljoscha Steffens Messages: 302 Registered: November 2012 |
Senior Member |
|
|
Okay. Another two and a half hours without any glimpse of success.
I tried to understand EditableGridExample and failed when I tried to implement a DefaultGridLayer. (But at least I learned sth about Reflection ).
So.. before I do any more research: Is the GridLayer necessary for editing cells? I can remember that I chose the ViewPortLayer for a certain reason, so I would like to keep it.
I tried to add the configuration to the ViewPortLayer but nothing happens.
Also I tried to find the topic you mentioned, but I couldn't find any other than I found previously.
This is my code now..
final ViewportLayer layer = new ViewportLayer( new DataLayer(dataProvider) );
IConfigLabelAccumulator cellLabelAccumulator = new IConfigLabelAccumulator() {
public void accumulateConfigLabels(LabelStack configLabels, int columnPosition, int rowPosition) {
configLabels.addLabel("myCellLabel");
}
};
layer.setConfigLabelAccumulator(cellLabelAccumulator);
layer.setRegionName(GridRegion.BODY);
layer.addConfiguration(new AbstractRegistryConfiguration() {
public void configureRegistry(IConfigRegistry configRegistry) {
TextCellEditor textCellEditor = new TextCellEditor();
configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITOR, textCellEditor, DisplayMode.EDIT, "myCellLabel");
configRegistry.registerConfigAttribute( EditConfigAttributes.CELL_EDITABLE_RULE, IEditableRule.ALWAYS_EDITABLE, DisplayMode.EDIT, "myCellLabel");
configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITABLE_RULE, IEditableRule.ALWAYS_EDITABLE);
}
});
natTable = new NatTable(container, layer, false);
natTable.addConfiguration(new AbstractRegistryConfiguration() {
public void configureRegistry(IConfigRegistry configRegistry) {
TextCellEditor textCellEditor = new TextCellEditor();
configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITOR, textCellEditor, DisplayMode.EDIT, "myCellLabel");
configRegistry.registerConfigAttribute( EditConfigAttributes.CELL_EDITABLE_RULE, IEditableRule.ALWAYS_EDITABLE, DisplayMode.EDIT, "myCellLabel");
configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITABLE_RULE, IEditableRule.ALWAYS_EDITABLE);
}
});
natTable.addConfiguration(new DefaultEditConfiguration());
natTable.addConfiguration(new DefaultEditBindings());
natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
natTable.configure();
By the way: I think that its really good how many example classes you provide as an "how to do". But for example the "EditableGridExample ": why does it need to be so big? I would much more appreciate a 4by4 table with as few configurations as possible. But on the other hand you do a great job in the forum Thanks
|
|
| | | | | |
Goto Forum:
Current Time: Mon Dec 09 08:31:12 GMT 2024
Powered by FUDForum. Page generated in 0.15556 seconds
|