Nattable custom label accumulator





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















A NatTable requires to set cells of column 3 with BACKGROUND_COLOR = GUIHelper.COLOR_GREEN when the property of the Material is of type "Composite".



Material list is the source of data (the DataProvider)



NatTable is configured with StackingTableConfiguration.class



NatTable uses a custom label to set the cell style by means of StackingTableLabelAccumulator.class



As suggested in https://www.eclipse.org/forums/index.php/t/781508/
I have set the cellLabelAccumulator body data layer.



I used AggregateConfigLabelAccumulator since I have the custom label accumulator (AggregateConfigLabelAccumulator) and a columnLabelAccumulator.



When the Material is of type Composite, the label is added to the config labels, but the green color is nor render.



public class StackingTable {

private NatTable natTable;
public static IDataProvider bodyDataProvider;

public static String COLUMN_ONE_LABEL = "ColumnOneLabel";
public static String COLUMN_TWO_LABEL = "ColumnTwoLabel";
public static String COLUMN_THREE_LABEL = "ColumnThreeLabel";

public static String TEST = "Composite_Label";

public StackingTable(Composite parent,
EventList<AncolabStackingLayer> ancolabStackingData,
SelectionLayer stackingTableSelectionLayer ) {

bodyDataProvider = new ListDataProvider<>(ancolabStackingData, colAccessor);
final DataLayer bodyDataLayer = new DataLayer(bodyDataProvider);
final ColumnOverrideLabelAccumulator columnLabelAccumulator =
new ColumnOverrideLabelAccumulator(bodyDataLayer);
columnLabelAccumulator.registerColumnOverrides(0, COLUMN_ONE_LABEL);
columnLabelAccumulator.registerColumnOverrides(1, COLUMN_TWO_LABEL);
columnLabelAccumulator.registerColumnOverrides(2, COLUMN_THREE_LABEL);
//Create the gridLayer
natTable = new NatTable(parent, gridLayer, false);

AggregateConfigLabelAccumulator aggregateConfigLabelAccumulator =
new AggregateConfigLabelAccumulator();
aggregateConfigLabelAccumulator.add(columnLabelAccumulator);
aggregateConfigLabelAccumulator.add(
new StackingTableLabelAccumulator(bodyDataProvider));

bodyDataLayer.setConfigLabelAccumulator(aggregateConfigLabelAccumulator);

bodyDataLayer.addConfiguration(
new DefaultNatTableStyleConfiguration());
bodyDataLayer.addConfiguration(
new StackingTableConfiguration(bodyDataProvider));
bodyDataLayer.addConfiguration(new DefaultEditConfiguration());
bodyDataLayer.addConfiguration(new DefaultEditBindings());

natTable.configure();
}


The configuration registry:



public class StackingTableConfiguration extends AbstractRegistryConfiguration {
private IDataProvider bodyDataProvider;
public StackingTableConfiguration(IDataProvider dp) {
this.bodyDataProvider = dp;
@Override
public void configureRegistry(IConfigRegistry configRegistry) {
//...some configutarion attributes for other columns
Style cellStyle2 = new Style();
cellStyle2.setAttributeValue(
CellStyleAttributes.BACKGROUND_COLOR,
GUIHelper.COLOR_GREEN);

configRegistry.registerConfigAttribute(
CellConfigAttributes.CELL_STYLE, cellStyle2,
DisplayMode.NORMAL, StackingTable.TEST);
}
}


The custom label accumulator:



//Add a label to cells in column 2 when the material of the row is of type = "Composite"
public class StackingTableLabelAccumulator extends AbstractOverrider {
IDataProvider dataProvider;
public StackingTableLabelAccumulator(IDataProvider dataProvider){
this.dataProvider = dataProvider;
}
@Override
public void accumulateConfigLabels(LabelStack configLabels,
int columnPosition, int rowPosition) {
Material mat =
(Material) ((IRowDataProvider) dataProvider).getRowObject(rowPosition);
if(mat.getType().equals("Composite")&& columnPosition == 2) {
configLabels.addLabel(StackingTable.TEST);
//When a material of type composite,
//the code reachs this point, i.e. the label is added to the labelStack
System.out.println(configLabels.getLabels().get(1).toString() +
"t" + columnPosition + "t" + rowPosition);
}
}
}









share|improve this question


















  • 1





    Since not the whole configuration is shown, I can't tell for sure, but typically it is an issue with label ordering and you have another style registered for COLUMN_THREE_LABEL that is used because that label is the first label in the label stack.

    – Dirk Fauth
    Nov 22 '18 at 14:16











  • You´re right. That was the issue and the solution. Conditional label now works fine.

    – J Robes
    Nov 22 '18 at 14:47


















0















A NatTable requires to set cells of column 3 with BACKGROUND_COLOR = GUIHelper.COLOR_GREEN when the property of the Material is of type "Composite".



Material list is the source of data (the DataProvider)



NatTable is configured with StackingTableConfiguration.class



NatTable uses a custom label to set the cell style by means of StackingTableLabelAccumulator.class



As suggested in https://www.eclipse.org/forums/index.php/t/781508/
I have set the cellLabelAccumulator body data layer.



I used AggregateConfigLabelAccumulator since I have the custom label accumulator (AggregateConfigLabelAccumulator) and a columnLabelAccumulator.



When the Material is of type Composite, the label is added to the config labels, but the green color is nor render.



public class StackingTable {

private NatTable natTable;
public static IDataProvider bodyDataProvider;

public static String COLUMN_ONE_LABEL = "ColumnOneLabel";
public static String COLUMN_TWO_LABEL = "ColumnTwoLabel";
public static String COLUMN_THREE_LABEL = "ColumnThreeLabel";

public static String TEST = "Composite_Label";

public StackingTable(Composite parent,
EventList<AncolabStackingLayer> ancolabStackingData,
SelectionLayer stackingTableSelectionLayer ) {

bodyDataProvider = new ListDataProvider<>(ancolabStackingData, colAccessor);
final DataLayer bodyDataLayer = new DataLayer(bodyDataProvider);
final ColumnOverrideLabelAccumulator columnLabelAccumulator =
new ColumnOverrideLabelAccumulator(bodyDataLayer);
columnLabelAccumulator.registerColumnOverrides(0, COLUMN_ONE_LABEL);
columnLabelAccumulator.registerColumnOverrides(1, COLUMN_TWO_LABEL);
columnLabelAccumulator.registerColumnOverrides(2, COLUMN_THREE_LABEL);
//Create the gridLayer
natTable = new NatTable(parent, gridLayer, false);

AggregateConfigLabelAccumulator aggregateConfigLabelAccumulator =
new AggregateConfigLabelAccumulator();
aggregateConfigLabelAccumulator.add(columnLabelAccumulator);
aggregateConfigLabelAccumulator.add(
new StackingTableLabelAccumulator(bodyDataProvider));

bodyDataLayer.setConfigLabelAccumulator(aggregateConfigLabelAccumulator);

bodyDataLayer.addConfiguration(
new DefaultNatTableStyleConfiguration());
bodyDataLayer.addConfiguration(
new StackingTableConfiguration(bodyDataProvider));
bodyDataLayer.addConfiguration(new DefaultEditConfiguration());
bodyDataLayer.addConfiguration(new DefaultEditBindings());

natTable.configure();
}


The configuration registry:



public class StackingTableConfiguration extends AbstractRegistryConfiguration {
private IDataProvider bodyDataProvider;
public StackingTableConfiguration(IDataProvider dp) {
this.bodyDataProvider = dp;
@Override
public void configureRegistry(IConfigRegistry configRegistry) {
//...some configutarion attributes for other columns
Style cellStyle2 = new Style();
cellStyle2.setAttributeValue(
CellStyleAttributes.BACKGROUND_COLOR,
GUIHelper.COLOR_GREEN);

configRegistry.registerConfigAttribute(
CellConfigAttributes.CELL_STYLE, cellStyle2,
DisplayMode.NORMAL, StackingTable.TEST);
}
}


The custom label accumulator:



//Add a label to cells in column 2 when the material of the row is of type = "Composite"
public class StackingTableLabelAccumulator extends AbstractOverrider {
IDataProvider dataProvider;
public StackingTableLabelAccumulator(IDataProvider dataProvider){
this.dataProvider = dataProvider;
}
@Override
public void accumulateConfigLabels(LabelStack configLabels,
int columnPosition, int rowPosition) {
Material mat =
(Material) ((IRowDataProvider) dataProvider).getRowObject(rowPosition);
if(mat.getType().equals("Composite")&& columnPosition == 2) {
configLabels.addLabel(StackingTable.TEST);
//When a material of type composite,
//the code reachs this point, i.e. the label is added to the labelStack
System.out.println(configLabels.getLabels().get(1).toString() +
"t" + columnPosition + "t" + rowPosition);
}
}
}









share|improve this question


















  • 1





    Since not the whole configuration is shown, I can't tell for sure, but typically it is an issue with label ordering and you have another style registered for COLUMN_THREE_LABEL that is used because that label is the first label in the label stack.

    – Dirk Fauth
    Nov 22 '18 at 14:16











  • You´re right. That was the issue and the solution. Conditional label now works fine.

    – J Robes
    Nov 22 '18 at 14:47














0












0








0








A NatTable requires to set cells of column 3 with BACKGROUND_COLOR = GUIHelper.COLOR_GREEN when the property of the Material is of type "Composite".



Material list is the source of data (the DataProvider)



NatTable is configured with StackingTableConfiguration.class



NatTable uses a custom label to set the cell style by means of StackingTableLabelAccumulator.class



As suggested in https://www.eclipse.org/forums/index.php/t/781508/
I have set the cellLabelAccumulator body data layer.



I used AggregateConfigLabelAccumulator since I have the custom label accumulator (AggregateConfigLabelAccumulator) and a columnLabelAccumulator.



When the Material is of type Composite, the label is added to the config labels, but the green color is nor render.



public class StackingTable {

private NatTable natTable;
public static IDataProvider bodyDataProvider;

public static String COLUMN_ONE_LABEL = "ColumnOneLabel";
public static String COLUMN_TWO_LABEL = "ColumnTwoLabel";
public static String COLUMN_THREE_LABEL = "ColumnThreeLabel";

public static String TEST = "Composite_Label";

public StackingTable(Composite parent,
EventList<AncolabStackingLayer> ancolabStackingData,
SelectionLayer stackingTableSelectionLayer ) {

bodyDataProvider = new ListDataProvider<>(ancolabStackingData, colAccessor);
final DataLayer bodyDataLayer = new DataLayer(bodyDataProvider);
final ColumnOverrideLabelAccumulator columnLabelAccumulator =
new ColumnOverrideLabelAccumulator(bodyDataLayer);
columnLabelAccumulator.registerColumnOverrides(0, COLUMN_ONE_LABEL);
columnLabelAccumulator.registerColumnOverrides(1, COLUMN_TWO_LABEL);
columnLabelAccumulator.registerColumnOverrides(2, COLUMN_THREE_LABEL);
//Create the gridLayer
natTable = new NatTable(parent, gridLayer, false);

AggregateConfigLabelAccumulator aggregateConfigLabelAccumulator =
new AggregateConfigLabelAccumulator();
aggregateConfigLabelAccumulator.add(columnLabelAccumulator);
aggregateConfigLabelAccumulator.add(
new StackingTableLabelAccumulator(bodyDataProvider));

bodyDataLayer.setConfigLabelAccumulator(aggregateConfigLabelAccumulator);

bodyDataLayer.addConfiguration(
new DefaultNatTableStyleConfiguration());
bodyDataLayer.addConfiguration(
new StackingTableConfiguration(bodyDataProvider));
bodyDataLayer.addConfiguration(new DefaultEditConfiguration());
bodyDataLayer.addConfiguration(new DefaultEditBindings());

natTable.configure();
}


The configuration registry:



public class StackingTableConfiguration extends AbstractRegistryConfiguration {
private IDataProvider bodyDataProvider;
public StackingTableConfiguration(IDataProvider dp) {
this.bodyDataProvider = dp;
@Override
public void configureRegistry(IConfigRegistry configRegistry) {
//...some configutarion attributes for other columns
Style cellStyle2 = new Style();
cellStyle2.setAttributeValue(
CellStyleAttributes.BACKGROUND_COLOR,
GUIHelper.COLOR_GREEN);

configRegistry.registerConfigAttribute(
CellConfigAttributes.CELL_STYLE, cellStyle2,
DisplayMode.NORMAL, StackingTable.TEST);
}
}


The custom label accumulator:



//Add a label to cells in column 2 when the material of the row is of type = "Composite"
public class StackingTableLabelAccumulator extends AbstractOverrider {
IDataProvider dataProvider;
public StackingTableLabelAccumulator(IDataProvider dataProvider){
this.dataProvider = dataProvider;
}
@Override
public void accumulateConfigLabels(LabelStack configLabels,
int columnPosition, int rowPosition) {
Material mat =
(Material) ((IRowDataProvider) dataProvider).getRowObject(rowPosition);
if(mat.getType().equals("Composite")&& columnPosition == 2) {
configLabels.addLabel(StackingTable.TEST);
//When a material of type composite,
//the code reachs this point, i.e. the label is added to the labelStack
System.out.println(configLabels.getLabels().get(1).toString() +
"t" + columnPosition + "t" + rowPosition);
}
}
}









share|improve this question














A NatTable requires to set cells of column 3 with BACKGROUND_COLOR = GUIHelper.COLOR_GREEN when the property of the Material is of type "Composite".



Material list is the source of data (the DataProvider)



NatTable is configured with StackingTableConfiguration.class



NatTable uses a custom label to set the cell style by means of StackingTableLabelAccumulator.class



As suggested in https://www.eclipse.org/forums/index.php/t/781508/
I have set the cellLabelAccumulator body data layer.



I used AggregateConfigLabelAccumulator since I have the custom label accumulator (AggregateConfigLabelAccumulator) and a columnLabelAccumulator.



When the Material is of type Composite, the label is added to the config labels, but the green color is nor render.



public class StackingTable {

private NatTable natTable;
public static IDataProvider bodyDataProvider;

public static String COLUMN_ONE_LABEL = "ColumnOneLabel";
public static String COLUMN_TWO_LABEL = "ColumnTwoLabel";
public static String COLUMN_THREE_LABEL = "ColumnThreeLabel";

public static String TEST = "Composite_Label";

public StackingTable(Composite parent,
EventList<AncolabStackingLayer> ancolabStackingData,
SelectionLayer stackingTableSelectionLayer ) {

bodyDataProvider = new ListDataProvider<>(ancolabStackingData, colAccessor);
final DataLayer bodyDataLayer = new DataLayer(bodyDataProvider);
final ColumnOverrideLabelAccumulator columnLabelAccumulator =
new ColumnOverrideLabelAccumulator(bodyDataLayer);
columnLabelAccumulator.registerColumnOverrides(0, COLUMN_ONE_LABEL);
columnLabelAccumulator.registerColumnOverrides(1, COLUMN_TWO_LABEL);
columnLabelAccumulator.registerColumnOverrides(2, COLUMN_THREE_LABEL);
//Create the gridLayer
natTable = new NatTable(parent, gridLayer, false);

AggregateConfigLabelAccumulator aggregateConfigLabelAccumulator =
new AggregateConfigLabelAccumulator();
aggregateConfigLabelAccumulator.add(columnLabelAccumulator);
aggregateConfigLabelAccumulator.add(
new StackingTableLabelAccumulator(bodyDataProvider));

bodyDataLayer.setConfigLabelAccumulator(aggregateConfigLabelAccumulator);

bodyDataLayer.addConfiguration(
new DefaultNatTableStyleConfiguration());
bodyDataLayer.addConfiguration(
new StackingTableConfiguration(bodyDataProvider));
bodyDataLayer.addConfiguration(new DefaultEditConfiguration());
bodyDataLayer.addConfiguration(new DefaultEditBindings());

natTable.configure();
}


The configuration registry:



public class StackingTableConfiguration extends AbstractRegistryConfiguration {
private IDataProvider bodyDataProvider;
public StackingTableConfiguration(IDataProvider dp) {
this.bodyDataProvider = dp;
@Override
public void configureRegistry(IConfigRegistry configRegistry) {
//...some configutarion attributes for other columns
Style cellStyle2 = new Style();
cellStyle2.setAttributeValue(
CellStyleAttributes.BACKGROUND_COLOR,
GUIHelper.COLOR_GREEN);

configRegistry.registerConfigAttribute(
CellConfigAttributes.CELL_STYLE, cellStyle2,
DisplayMode.NORMAL, StackingTable.TEST);
}
}


The custom label accumulator:



//Add a label to cells in column 2 when the material of the row is of type = "Composite"
public class StackingTableLabelAccumulator extends AbstractOverrider {
IDataProvider dataProvider;
public StackingTableLabelAccumulator(IDataProvider dataProvider){
this.dataProvider = dataProvider;
}
@Override
public void accumulateConfigLabels(LabelStack configLabels,
int columnPosition, int rowPosition) {
Material mat =
(Material) ((IRowDataProvider) dataProvider).getRowObject(rowPosition);
if(mat.getType().equals("Composite")&& columnPosition == 2) {
configLabels.addLabel(StackingTable.TEST);
//When a material of type composite,
//the code reachs this point, i.e. the label is added to the labelStack
System.out.println(configLabels.getLabels().get(1).toString() +
"t" + columnPosition + "t" + rowPosition);
}
}
}






nattable






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 22 '18 at 11:16









J RobesJ Robes

12711




12711








  • 1





    Since not the whole configuration is shown, I can't tell for sure, but typically it is an issue with label ordering and you have another style registered for COLUMN_THREE_LABEL that is used because that label is the first label in the label stack.

    – Dirk Fauth
    Nov 22 '18 at 14:16











  • You´re right. That was the issue and the solution. Conditional label now works fine.

    – J Robes
    Nov 22 '18 at 14:47














  • 1





    Since not the whole configuration is shown, I can't tell for sure, but typically it is an issue with label ordering and you have another style registered for COLUMN_THREE_LABEL that is used because that label is the first label in the label stack.

    – Dirk Fauth
    Nov 22 '18 at 14:16











  • You´re right. That was the issue and the solution. Conditional label now works fine.

    – J Robes
    Nov 22 '18 at 14:47








1




1





Since not the whole configuration is shown, I can't tell for sure, but typically it is an issue with label ordering and you have another style registered for COLUMN_THREE_LABEL that is used because that label is the first label in the label stack.

– Dirk Fauth
Nov 22 '18 at 14:16





Since not the whole configuration is shown, I can't tell for sure, but typically it is an issue with label ordering and you have another style registered for COLUMN_THREE_LABEL that is used because that label is the first label in the label stack.

– Dirk Fauth
Nov 22 '18 at 14:16













You´re right. That was the issue and the solution. Conditional label now works fine.

– J Robes
Nov 22 '18 at 14:47





You´re right. That was the issue and the solution. Conditional label now works fine.

– J Robes
Nov 22 '18 at 14:47












0






active

oldest

votes












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53429766%2fnattable-custom-label-accumulator%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53429766%2fnattable-custom-label-accumulator%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Biblatex bibliography style without URLs when DOI exists (in Overleaf with Zotero bibliography)

ComboBox Display Member on multiple fields

Is it possible to collect Nectar points via Trainline?