Tableoperations

Oxygen general issues.
guna@ebscohost.com
Posts: 27
Joined: Tue Nov 17, 2009 10:16 pm

Tableoperations

Post by guna@ebscohost.com »

Hi,
we want to create xhtml table, where user needs ability to set
1) table Background color
2) row background color
3) Table header alignment (both horizontal and vertical)
4) Table row alignment(both horizontal and vertical)
5) cell padding
6) cell spacing
7) indentation


can you guide us , how to implement this functionality. as well us do provide us with information
Radu
Posts: 9496
Joined: Fri Jul 09, 2004 5:18 pm

Re: Tableoperations

Post by Radu »

Hi,

You can create a new Author Operation which presents the user with a Java dialog in which he can choose all these settings.
After presenting the dialog you can use the information provided by the user to create an XML fragment with the table which will get inserted.
Then insert the XML fragment using the Author Document Controller.

As an example you can look at the ro.sync.ecss.extensions.docbook.table.InsertTableOperation operation.

The operation should look like:

Code: Select all


  /**
* @see ro.sync.ecss.extensions.api.AuthorOperation#doOperation(ro.sync.ecss.extensions.api.AuthorAccess, ro.sync.ecss.extensions.api.ArgumentsMap)
*/
public void doOperation(AuthorAccess authorAccess, ArgumentsMap args)
throws IllegalArgumentException, AuthorOperationException {
// Object containing all information collected by the dialog from the user
HTMLTableInfo tableInfo = showTableInformationJDialogToUserAndCollectInformation();
if (tableInfo != null) {
StringBuffer tableXMLFragment = new StringBuffer();
tableXMLFragment.append("<table");
tableXMLFragment.append(" bgcolor='").append(tableInfo.bgColor).append("'");
tableXMLFragment.append(">");
tableXMLFragment.append("<caption>").append(tableInfo.title).append("</caption>");
for (int i = 0; i < tableInfo.numberOfRows; i++) {
tableXMLFragment.append("<tr");
tableXMLFragment.append(" bgcolor='").append(tableInfo.rowBgColor).append("'");
tableXMLFragment.append(" align='").append(tableInfo.rowAlign).append("'");
tableXMLFragment.append(">");
for (int j = 0; j < tableInfo.numberOfCells; j++) {
tableXMLFragment.append("<td/>");
}
tableXMLFragment.append("</tr>");
}
tableXMLFragment.append("</table>");
// Insert the table
authorAccess.getDocumentController().insertXMLFragment(
tableXMLFragment.toString(),
authorAccess.getEditorAccess().getCaretOffset());
} else {
// User canceled the operation
}
}
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply