Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » How to hide Images (Labels)(Icons are replacing column headers, how to switch back and forth)
How to hide Images (Labels) [message #1850717] Tue, 15 March 2022 10:16 Go to next message
Peter Vilhelmsen is currently offline Peter VilhelmsenFriend
Messages: 7
Registered: March 2022
Junior Member
Hello,
I have replaced column headers by 16x16 images using a Cell Painter:

private void addCellPainter(IConfigRegistry configRegistry, String header, Image image) {
        ICellPainter imagePainter = new ImagePainter(image);
    	configRegistry.registerConfigAttribute(
                CellConfigAttributes.CELL_PAINTER,
                imagePainter,	
                DisplayMode.NORMAL,
                header);
	}

addCellPainter(configRegistry, TIME, vi.getIcon(ViewImage.IMAGE_TIME));


I have added a check mark option for the user to choose between text and icon. How can I easily switch between text and icons?

Is there a doCommand(new ...)?

I have tried looping all columns, removing the label (two different ways), but either doesn't have effect.

loop over i:
LabelStack ls = columnHeaderLayer.getConfigLabelsByPosition(i, 0);
ls.removeLabel(TIME);
columnHeaderLayer.getConfigLabelsByPosition(i, 0).removeLabel(TIME);


Best regards
Peter
Re: How to hide Images (Labels) [message #1850724 is a reply to message #1850717] Tue, 15 March 2022 13:41 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Modifications on the LabelStack only work via a IConfigLabelAccumulator on the Layers. If you modify the LabelStack outside of that mechanism, a reload will re-calculate the LabelStack and therefore override your changes again.

There are two options to solve your requirement:
1. make your label mechanism aware of a configuration from the outside (your check mark option) and only add the label if needed (reactive approach)
2. register/unregister your painter dynamically on clicks on the check mark option (active approach)
Re: How to hide Images (Labels) [message #1850887 is a reply to message #1850724] Mon, 21 March 2022 09:24 Go to previous message
Peter Vilhelmsen is currently offline Peter VilhelmsenFriend
Messages: 7
Registered: March 2022
Junior Member
Hi Dirk
I just want to thank you, it works perfectly and as intended now.
Thanks :-)
/Peter
Previous Topic:ComboBoxCellEditor events on linux, a follow up to the mac issue
Next Topic:Column Width Listener
Goto Forum:
  


Current Time: Thu Apr 25 14:05:52 GMT 2024

Powered by FUDForum. Page generated in 0.03295 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top