RowSelectionModel shows all Column Header cells - eclipse

I have created a NatTable with a RowSelectionModel and a RowSelectionProvider:
dataProvider = new ListDataProvider<>(rowData, columnAccessor);
bodyDataLayer = new DataLayer(dataProvider);
glazedListEventsLayer = new GlazedListsEventLayer<>(bodyDataLayer, rowData);
columnReorderLayer = new ColumnReorderLayer(glazedListEventsLayer);
columnHideShowLayer = new ColumnHideShowLayer(columnReorderLayer);
selectionLayer = new SelectionLayer(columnHideShowLayer);
ViewportLayer viewportLayer = new ViewportLayer(selectionLayer);
selectionProvider = new RowSelectionProvider<>(selectionLayer, dataProvider, true);
selectionLayer.setSelectionModel(new RowSelectionModel<>(selectionLayer, dataProvider, idAccessor, false));
Basically, the table does what I want it to do. There is but one exception:
The table looks like this:
As intended, the table shows the row as selected (1). Also it highlights the actually selected cell (2), which is very nice. But, it renders the whole table column header as selected (3). I don't want that. I want either not highlight the header cells at all, or (even better:) I'd like only the column header cell of the cursor-cell (2) to be highlighted.
I thought that maybe there is a configuration label attached to the column header cells which results in the highlighting (so I could just change the style for this kind of label to get rid of the highlighting), but COLUMN_HEADER is the only configuration label, I can see when debugging.
So, I am bit stuck now. What causes the header cells to be highlighted and how can I change this behavior? Is it possible to highlight only the header of the cursor cell (as is done with the selected row's cursor cell (2))?

It is not the label you need to check, for selection it is the DisplayMode. So to not render the column header highlighted if you select a row you need to register the same style configuration for DisplayMode.SELECT as you register for DisplayMode.NORMAL.
If you only want to highlight the selection anchor in the column header you will need to register a custom IConfigLabelAccumulator to the DataLayer of the column header that is connected to the SelectionLayer and adds a custom label in case the cell in the column header is in the same column as the selection anchor.
For only highlighting the selection anchor, there is no default in NatTable itself. Although it should be easy to add. Feel free to create an enhancement ticket for this and even contribute. :)

Related

Get current height of xwpf row, cell, paragraph

I am using XWPF to read .docx file which contain a table. In this table I get row then cell then I add a paragraph inside and in this paragraph I add multiple Run (with different style of font)
My question is (I know I don’t have posibility to get when word add new page or it is out of scope to me...?) But what I want achieve is get current height in my loop of the tableRow or tableCell is this possible? I mean something like this squelette code
XWPFTableRow r = ...;
For(...){
r.getCell(0).addNewParagraph(0).newRun().setText(...);
// at this step of programm I want height of each cell and each paragraph,
// is this possible? Because each iteration my table row height increment..
}
I tried tableRow.getHeight() to get row height but it get always 0, someone have idea to get row or cell or paragraph height?

Disable JFace TableViwer single row

Does anyone know how to disable a single row of a JFace TableViwer? I have a TableViwer constructed as follows:
TableViwer tv = new TableViwer(composite, SWT.NONE| SWT.FULL_SELECTION | SWT.BORDER);
tv can have many rows, but I am adding a particular unique row to the table dynamically(when an external button is clicked) and I need to make only that row disabled (grayed out and not selectable. Not selectable can also be achieved through existing handler, if there is no other option).
I searched in google but did not get much information. I am new to SWT/JFace, so any help would be appreciated.
You would have to do something in the selection listener to reject selection of the row.
To make the row gray you can make your Label Provider implement IColorProvider which lets you define the two methods:
public Color getForeground(Object element);
public Color getBackground(Object element);
which can color the row.
You could also use a label provider derived from StyledCellLabelProvider which lets you define more complex coloring.

Align a table to bottom of page using Itext

I have a velocity template which has a nested table. I want to align the content of last cell
which has a table inside it to the bottom of the page. I am writing the xml in velocity template and processing the pdf using IText.
I'm not sure I've understood your question, but there is the method setExtendLastRow on PdfPTable object that make the last row on the table high as long as needed to fill the current page, until bottom margin. Example:
PdfPTable tabella = new PdfPTable(4);
PdfPCell cell = new PdfPCell(new Phrase("some text here"));
tabella.addCell(cell);
tabella.addCell(cell);
tabella.addCell(cell);
tabella.addCell(cell);
tabella.setExtendLastRow(true);
the table has only 4 cells that extends to the bottom of the page.

Eclipse layout for table and two buttons

I am trying to lay out a form for an Eclipse editor and running into a few problems.
The idea is to have a page which contains 2 sections - the left hand section contains a table and two buttons. The table should line up with the top of the section and expand right to the bottom. I want the buttons to sit to the right of the table in the section with each button under the other and for them to align with the top of the table.
Does anyone know what settings for GridLayouts I need to make this work? I've tried every combination I can think of with no luck.
The closest I can get ends up with the second button at the bottom of the page.
Here is an excerpt of my code so far:-
Section section = toolkit.createSection(sashForm, ExpandableComposite.TITLE_BAR | ExpandableComposite.EXPANDED | ExpandableComposite.NO_TITLE_FOCUS_BOX);
section.setText("All Items");
Composite client = toolkit.createComposite(section);
section.setClient(client);
client.setLayout(new GridLayout(2, false));
Table table = toolkit.createTable(client, SWT.NULL);
table.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING));
TableViewer viewer = new TableViewer(table);
Button addButton = toolkit.createButton(client, "Add", SWT.PUSH);
addButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING));
Button removeButton = toolkit.createButton(client, "Remove", SWT.PUSH);
removeButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING));
Have a look at SWT Layout Tutorials it has a good section on GridLayout.
You will want to use the GridData.verticalSpan for the table to get it to cover two rows. That should put the two buttons on the right. But then the buttons will take the same space as the table which is probably not what you want, so you may need to give vertical size hint to the table.

Creating columns with editable cells in Gtk treeview using Glade

I am trying to create a simple GUI with table containing x and y coordinates of samples. I use treeview, and I want the cells of the table to be editable by user. Is it possible to specify if the cells should be editable directly in Glade in cellrenderer properties, or do I have to specify it in my code? I use Glade 3.6.1
I have just found out that unticking box "Editable" in the Tree View Editor when editing my treeview, enables me to specify whether the cells shall be editable or not, because if the box is unticked, the cells editable property is no longer connected with the model.
But if I run the program, cells are editable, but the value that I write inside disappears. How can I fix that? Why doesn't the cell store the value I type inside?
Thanks for any hint
For anyone dealing with a similar problem, I have solved it - whenever a cell is edited, appropriate record in the model needs to be changed, example code in Python:
cell.connect("edited", self.text_edited, model, column)
def text_edited( self, w, row, new_text, model, column)
model[row][column] = new_text
I found I had to do something just a little different, but I am also using Ubuntu's Quickly development environment. I did have to go into Glade and uncheck the "Editable" box in my cellrenderer, which then brought up a toggable "Yes/No" button. Then my code looks like:
#psuedo-code function definition
cellcolumn_widget.connect("edited", self.function, list_or_treestore, columnnumber)
#actual code, editing second column so column is passed as 1
self.builder.get_object("cellrenderer_chapter").connect("edited", self.cell_edited, self.builder.get_object("liststore_chapters"),1)
def cell_edited(self, widget, row, new_text, model, column):
model.set_value(model.get_iter(row),column,new_text)
for python GTK, by default, text in Gtk.CellRendererText widgets is not editable, you can change this by setting the value of the “editable” property to True:
renderer = Gtk.CellRendererText();
renderer.set_property("editable", True);
then you can connect to the “edited” signal and update your Gtk.TreeModel and/or database accordingly:
renderer.connect("edited", self.entry_edited);
def entry_edited(self, widget, path, text):
self.listStore[path][number_of_row] = text; # put the number_of_row to be edited
check this tutorial for more information python gtk 3 tutorial - CellRendererText