use of org.eclipse.nebula.widgets.nattable.formula.config.DefaultFormulaConfiguration in project nebula.widgets.nattable by eclipse.
the class FormulaFillHandlePasteTest method setup.
@Before
public void setup() {
InternalCellClipboard clipboard = new InternalCellClipboard();
this.selectionLayer.registerCommandHandler(new InternalCopyDataCommandHandler(this.selectionLayer, clipboard));
this.selectionLayer.registerCommandHandler(new FormulaFillHandlePasteCommandHandler(this.selectionLayer, clipboard, this.formulaDataProvider));
this.natTable.addConfiguration(new DefaultFormulaConfiguration(this.formulaDataProvider, this.selectionLayer, clipboard));
this.natTable.addConfiguration(new AbstractRegistryConfiguration() {
@Override
public void configureRegistry(IConfigRegistry configRegistry) {
configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITABLE_RULE, EditableRule.ALWAYS_EDITABLE);
}
});
this.natTable.configure();
}
use of org.eclipse.nebula.widgets.nattable.formula.config.DefaultFormulaConfiguration in project nebula.widgets.nattable by eclipse.
the class FormulaIntegrationTest method setup.
@Before
public void setup() {
this.natTable.addConfiguration(new DefaultFormulaConfiguration(this.formulaDataProvider, this.gridLayerStack.getBodyLayer().getSelectionLayer(), new InternalCellClipboard()));
this.natTable.configure();
this.natTable.addLayerListener(this.listenerFixture);
// enable caching
this.formulaDataProvider.configureCaching(this.gridLayerStack.getBodyDataLayer());
this.dataProvider.setDataValue(0, 0, "5");
this.dataProvider.setDataValue(1, 0, "3");
this.dataProvider.setDataValue(2, 0, "=A1*B1");
this.dataProvider.setDataValue(0, 2, "5");
this.dataProvider.setDataValue(0, 3, "5");
this.dataProvider.setDataValue(0, 4, "=SUM(A3:A4)");
this.dataProvider.setDataValue(1, 2, "3");
this.dataProvider.setDataValue(1, 3, "3");
this.dataProvider.setDataValue(1, 4, "=SUM(B3:B4)");
this.dataProvider.setDataValue(2, 4, "=SUM(A5;B5)");
}
use of org.eclipse.nebula.widgets.nattable.formula.config.DefaultFormulaConfiguration in project nebula.widgets.nattable by eclipse.
the class _305_FormulaDataExample method createExampleControl.
@Override
public Control createExampleControl(Composite parent) {
Composite panel = new Composite(parent, SWT.NONE);
panel.setLayout(new GridLayout());
GridDataFactory.fillDefaults().grab(true, true).applyTo(panel);
// TODO add combo box and text field for editing formulas
Composite gridPanel = new Composite(panel, SWT.NONE);
gridPanel.setLayout(new GridLayout());
GridDataFactory.fillDefaults().grab(true, true).applyTo(gridPanel);
Composite buttonPanel = new Composite(panel, SWT.NONE);
buttonPanel.setLayout(new GridLayout());
GridDataFactory.fillDefaults().grab(true, false).applyTo(buttonPanel);
ConfigRegistry configRegistry = new ConfigRegistry();
final FormulaGridLayer gridLayer = new FormulaGridLayer();
final NatTable natTable = new NatTable(gridPanel, gridLayer, false);
natTable.setConfigRegistry(configRegistry);
natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
final FormulaBodyLayerStack bodyLayer = gridLayer.getBodyLayer();
natTable.addConfiguration(new FillHandleConfiguration(bodyLayer.getSelectionLayer()));
// This is the formula specific configuration
natTable.addConfiguration(new DefaultFormulaConfiguration(bodyLayer.getFormulaDataProvider(), bodyLayer.getSelectionLayer(), natTable.getInternalCellClipboard()));
bodyLayer.getFormulaDataProvider().setErrorReporter(new FormulaTooltipErrorReporter(natTable, bodyLayer.getDataLayer()));
natTable.addConfiguration(new AbstractRegistryConfiguration() {
@Override
public void configureRegistry(IConfigRegistry configRegistry) {
PoiExcelExporter exporter = new HSSFExcelExporter();
exporter.setApplyBackgroundColor(false);
exporter.setFormulaParser(bodyLayer.getFormulaDataProvider().getFormulaParser());
configRegistry.registerConfigAttribute(ExportConfigAttributes.EXPORTER, exporter);
}
});
natTable.configure();
GridDataFactory.fillDefaults().grab(true, true).applyTo(natTable);
final Button toggleFormulaButton = new Button(panel, SWT.PUSH);
toggleFormulaButton.setText("Disable Formula Evaluation");
toggleFormulaButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
_305_FormulaDataExample.this.evaluationEnabled = !_305_FormulaDataExample.this.evaluationEnabled;
if (_305_FormulaDataExample.this.evaluationEnabled) {
natTable.doCommand(new EnableFormulaEvaluationCommand());
toggleFormulaButton.setText("Disable Formula Evaluation");
} else {
natTable.doCommand(new DisableFormulaEvaluationCommand());
toggleFormulaButton.setText("Enable Formula Evaluation");
}
}
});
return panel;
}
Aggregations