本文整理汇总了Java中org.eclipse.nebula.widgets.nattable.layer.DataLayer.setConfigLabelAccumulator方法的典型用法代码示例。如果您正苦于以下问题:Java DataLayer.setConfigLabelAccumulator方法的具体用法?Java DataLayer.setConfigLabelAccumulator怎么用?Java DataLayer.setConfigLabelAccumulator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.nebula.widgets.nattable.layer.DataLayer
的用法示例。
在下文中一共展示了DataLayer.setConfigLabelAccumulator方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createExampleControl
import org.eclipse.nebula.widgets.nattable.layer.DataLayer; //导入方法依赖的package包/类
public Control createExampleControl(Composite parent) {
SelectionExampleGridLayer gridLayer = new SelectionExampleGridLayer();
NatTable natTable = new NatTable(parent, gridLayer, false);
DataLayer bodyDataLayer = gridLayer.getBodyDataLayer();
// Label accumulator - adds labels to all cells with the given data
// value
CellOverrideLabelAccumulator<RowDataFixture> cellLabelAccumulator =
new CellOverrideLabelAccumulator<RowDataFixture>(gridLayer.getBodyDataProvider());
cellLabelAccumulator.registerOverride("AAA", 2, CELL_LABEL);
// Register your cell style, against the label applied to the cell
// Other configuration which can be added (apart from style) include
// CellConfigAttributes, EditConfigAttributes, SortConfigAttributes etc.
IConfigRegistry configRegistry = new ConfigRegistry();
addColumnHighlight(configRegistry);
// Register label accumulator
bodyDataLayer.setConfigLabelAccumulator(cellLabelAccumulator);
gridLayer.getSelectionLayer().addConfiguration(new DefaultSelectionLayerConfiguration());
natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
natTable.setConfigRegistry(configRegistry);
natTable.configure();
return natTable;
}
示例2: init
import org.eclipse.nebula.widgets.nattable.layer.DataLayer; //导入方法依赖的package包/类
protected void init() {
dataProvider = new DataProvider();
headingProvider = new HeadingProvider();
gridLayer = new DefaultGridLayer(dataProvider, headingProvider);
// CellLabelAccumulator determines how cells will be displayed
class CellLabelAccumulator implements IConfigLabelAccumulator {
@Override
public void accumulateConfigLabels(LabelStack configLabels, int columnPosition, int rowPosition) {
configLabels.addLabel("column" + columnPosition);
if (dataProvider.isEditableNonscalarDefinition(rowPosition) && columnPosition == Attr.HEADING_COLUMN)
configLabels.addLabel("nonscalareditor");
}
}
DataLayer bodyDataLayer = (DataLayer) gridLayer.getBodyDataLayer();
CellLabelAccumulator cellLabelAccumulator = new CellLabelAccumulator();
bodyDataLayer.setConfigLabelAccumulator(cellLabelAccumulator);
table = new NatTable(parent, gridLayer, false);
editorConfiguration = new EditorConfiguration();
DefaultNatTableStyleConfiguration defaultStyle = new DefaultNatTableStyleConfiguration();
table.addConfiguration(defaultStyle);
table.addConfiguration(editorConfiguration);
ContributionItem rowMenuItems = new ContributionItem() {
@Override
public void fill(Menu menu, int index) {
MenuItem doesDelete = new MenuItem(menu, SWT.PUSH);
doesDelete.setText("Delete");
doesDelete.setImage(IconLoader.loadIcon("table_row_delete"));
doesDelete.addListener(SWT.Selection, e -> askDeleteSelected());
}
};
table.addConfiguration(new MenuConfiguration(GridRegion.ROW_HEADER,
new PopupMenuBuilder(table).withContributionItem(rowMenuItems)));
// Tabbing wraps and moves up/down
gridLayer.registerCommandHandler(new MoveCellSelectionCommandHandler(
gridLayer.getBodyLayer().getSelectionLayer(), ITraversalStrategy.TABLE_CYCLE_TRAVERSAL_STRATEGY));
table.configure();
// Tooltip for row/column headings
new NatTableContentTooltip(table, GridRegion.ROW_HEADER) {
protected String getText(Event event) {
return "Right-click for options.";
}
};
}
示例3: FilterRowExampleGridLayer
import org.eclipse.nebula.widgets.nattable.layer.DataLayer; //导入方法依赖的package包/类
public FilterRowExampleGridLayer(IConfigRegistry configRegistry) {
super(true);
// Underlying data source
EventList<RowDataFixture> eventList = GlazedLists.eventList(RowDataListFixture.getList());
FilterList<RowDataFixture> filterList = new FilterList<RowDataFixture>(eventList);
String[] propertyNames = RowDataListFixture.getPropertyNames();
Map<String, String> propertyToLabelMap = RowDataListFixture.getPropertyToLabelMap();
// Body layer
IColumnPropertyAccessor<RowDataFixture> columnPropertyAccessor =
new ReflectiveColumnPropertyAccessor<RowDataFixture>(propertyNames);
this.bodyDataProvider =
new ListDataProvider<RowDataFixture>(filterList, columnPropertyAccessor);
DataLayer bodyDataLayer =
new DataLayer(this.bodyDataProvider);
DefaultBodyLayerStack bodyLayer =
new DefaultBodyLayerStack(bodyDataLayer);
ColumnOverrideLabelAccumulator bodyLabelAccumulator =
new ColumnOverrideLabelAccumulator(bodyDataLayer);
bodyDataLayer.setConfigLabelAccumulator(bodyLabelAccumulator);
bodyLabelAccumulator.registerColumnOverrides(
RowDataListFixture.getColumnIndexOfProperty(RowDataListFixture.PRICING_TYPE_PROP_NAME),
"PRICING_TYPE_PROP_NAME");
// Column header layer
IDataProvider columnHeaderDataProvider =
new DefaultColumnHeaderDataProvider(propertyNames, propertyToLabelMap);
DataLayer columnHeaderDataLayer =
new DefaultColumnHeaderDataLayer(columnHeaderDataProvider);
ColumnHeaderLayer columnHeaderLayer =
new ColumnHeaderLayer(columnHeaderDataLayer, bodyLayer, bodyLayer.getSelectionLayer());
// Note: The column header layer is wrapped in a filter row composite.
// This plugs in the filter row functionality
FilterRowHeaderComposite<RowDataFixture> filterRowHeaderLayer =
new FilterRowHeaderComposite<RowDataFixture>(
new DefaultGlazedListsFilterStrategy<RowDataFixture>(filterList, columnPropertyAccessor, configRegistry),
columnHeaderLayer, columnHeaderDataProvider, configRegistry);
ColumnOverrideLabelAccumulator labelAccumulator =
new ColumnOverrideLabelAccumulator(columnHeaderDataLayer);
columnHeaderDataLayer.setConfigLabelAccumulator(labelAccumulator);
// Register labels
labelAccumulator.registerColumnOverrides(
RowDataListFixture.getColumnIndexOfProperty(RowDataListFixture.RATING_PROP_NAME),
"CUSTOM_COMPARATOR_LABEL");
// Row header layer
DefaultRowHeaderDataProvider rowHeaderDataProvider =
new DefaultRowHeaderDataProvider(this.bodyDataProvider);
DefaultRowHeaderDataLayer rowHeaderDataLayer =
new DefaultRowHeaderDataLayer(rowHeaderDataProvider);
RowHeaderLayer rowHeaderLayer =
new RowHeaderLayer(rowHeaderDataLayer, bodyLayer, bodyLayer.getSelectionLayer());
// Corner layer
DefaultCornerDataProvider cornerDataProvider =
new DefaultCornerDataProvider(columnHeaderDataProvider, rowHeaderDataProvider);
DataLayer cornerDataLayer =
new DataLayer(cornerDataProvider);
CornerLayer cornerLayer =
new CornerLayer(cornerDataLayer, rowHeaderLayer, filterRowHeaderLayer);
// Grid
setBodyLayer(bodyLayer);
// Note: Set the filter row as the column header
setColumnHeaderLayer(filterRowHeaderLayer);
setRowHeaderLayer(rowHeaderLayer);
setCornerLayer(cornerLayer);
}
示例4: createExampleControl
import org.eclipse.nebula.widgets.nattable.layer.DataLayer; //导入方法依赖的package包/类
public Control createExampleControl(Composite parent) {
DefaultGridLayer gridLayer = new DefaultGridLayer(
RowDataListFixture.getList(),
RowDataListFixture.getPropertyNames(),
RowDataListFixture.getPropertyToLabelMap());
DataLayer columnHeaderDataLayer = (DataLayer) gridLayer.getColumnHeaderDataLayer();
columnHeaderDataLayer.setConfigLabelAccumulator(new ColumnLabelAccumulator());
final DataLayer bodyDataLayer = (DataLayer) gridLayer
.getBodyDataLayer();
IDataProvider dataProvider = bodyDataLayer.getDataProvider();
// NOTE: Register the accumulator on the body data layer.
// This ensures that the labels are bound to the column index and are
// unaffected by column order.
final ColumnOverrideLabelAccumulator columnLabelAccumulator = new ColumnOverrideLabelAccumulator(
bodyDataLayer);
bodyDataLayer.setConfigLabelAccumulator(columnLabelAccumulator);
NatTable natTable = new NatTable(parent, gridLayer, false);
natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
natTable.addConfiguration(new HeaderMenuConfiguration(natTable));
natTable.addConfiguration(editableGridConfiguration(
columnLabelAccumulator, dataProvider));
final ColumnHeaderCheckBoxPainter columnHeaderCheckBoxPainter = new ColumnHeaderCheckBoxPainter(
bodyDataLayer);
final ICellPainter column9HeaderPainter = new BeveledBorderDecorator(
new CellPainterDecorator(new TextPainter(), CellEdgeEnum.RIGHT,
columnHeaderCheckBoxPainter));
natTable.addConfiguration(new AbstractRegistryConfiguration() {
@Override
public void configureRegistry(IConfigRegistry configRegistry) {
configRegistry.registerConfigAttribute(
CellConfigAttributes.CELL_PAINTER,
column9HeaderPainter, DisplayMode.NORMAL,
ColumnLabelAccumulator.COLUMN_LABEL_PREFIX + 9);
}
@Override
public void configureUiBindings(UiBindingRegistry uiBindingRegistry) {
uiBindingRegistry.registerFirstSingleClickBinding(
new CellPainterMouseEventMatcher(
GridRegion.COLUMN_HEADER,
MouseEventMatcher.LEFT_BUTTON,
columnHeaderCheckBoxPainter),
new ToggleCheckBoxColumnAction(
columnHeaderCheckBoxPainter, bodyDataLayer));
}
});
natTable.configure();
return natTable;
}
示例5: createExampleControl
import org.eclipse.nebula.widgets.nattable.layer.DataLayer; //导入方法依赖的package包/类
public Control createExampleControl(Composite parent) {
// property names of the Person class
String[] propertyNames = { "firstName", "lastName", "password",
"description", "age", "money", "married", "gender",
"address.street", "address.city", "favouriteFood",
"favouriteDrinks" };
// mapping from property to label, needed for column header labels
Map<String, String> propertyToLabelMap = new HashMap<String, String>();
propertyToLabelMap.put("firstName", "Firstname");
propertyToLabelMap.put("lastName", "Lastname");
propertyToLabelMap.put("password", "Password");
propertyToLabelMap.put("description", "Description");
propertyToLabelMap.put("age", "Age");
propertyToLabelMap.put("money", "Money");
propertyToLabelMap.put("married", "Married");
propertyToLabelMap.put("gender", "Gender");
propertyToLabelMap.put("address.street", "Street");
propertyToLabelMap.put("address.city", "City");
propertyToLabelMap.put("favouriteFood", "Food");
propertyToLabelMap.put("favouriteDrinks", "Drinks");
IDataProvider bodyDataProvider =
new ListDataProvider<ExtendedPersonWithAddress>(
PersonService.getExtendedPersonsWithAddress(10),
new ExtendedReflectiveColumnPropertyAccessor<ExtendedPersonWithAddress>(propertyNames));
DefaultGridLayer gridLayer =
new DefaultGridLayer(bodyDataProvider,
new DefaultColumnHeaderDataProvider(propertyNames, propertyToLabelMap));
final DataLayer bodyDataLayer = (DataLayer) gridLayer.getBodyDataLayer();
final ColumnOverrideLabelAccumulator columnLabelAccumulator =
new ColumnOverrideLabelAccumulator(bodyDataLayer);
bodyDataLayer.setConfigLabelAccumulator(columnLabelAccumulator);
registerColumnLabels(columnLabelAccumulator);
this.natTable = new NatTable(parent, gridLayer, false);
this.natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
this.natTable.addConfiguration(new PainterConfiguration());
this.natTable.configure();
new NatTableContentTooltip(this.natTable, GridRegion.BODY);
return this.natTable;
}