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?
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.
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.
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.
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