Page 1 of 1

Adding insert table dialogs to Author view

Posted: Fri Dec 06, 2013 6:21 pm
by tgrantham
We've created some DITA specializations of <simpletable>, and I would like to add buttons to the standalone Author view toolbar to enable authors to insert these tables.

I've looked at the SADITATableCustomizerDialog class, but it looks like I will need to create a custom dialog, rather than extend SADITATableCustomizerDialog.

Can you tell me where I would start? Create a dialog class that extends ro.sync.ecss.extensions.commons.ui.OKCancelDialog?

Thanks,
Tim.

Re: Adding insert table dialogs to Author view

Posted: Fri Dec 06, 2013 6:28 pm
by Radu
Hi Tim,

If the dialog "SADITATableCustomizerDialog" is too complex or too simple to be used from your action you could either extend it or create a new similar one.
You should find the Java sources for ro.sync.ecss.extensions.dita.topic.table.SADITATableCustomizerDialog in the Author SDK.

Regards,
Radu

Re: Adding insert table dialogs to Author view

Posted: Thu Dec 12, 2013 5:54 pm
by tgrantham
Hi, Radu.

The <simpletable> specializations we have defined pick up the default styling of <simpletable> in the Author view, which is great, but the Author view does not seem to support the column resizing features. The user can't drag the column border to resize it, and if they change the values in the @relcolwidth attribute, the Author view does not change the width of the columns accordingly.

Is there some way we can get this functionality for our <simpletable> specializations?

Thanks,
Tim.

Re: Adding insert table dialogs to Author view

Posted: Thu Dec 12, 2013 6:18 pm
by Radu
Hi Tim,

There are three distinct angles to working with tables in the Author editing mode:

1) Simple table layout. This can be done via the CSS, you copied the DITA CSSs as a starter so that should be fine.

2) Table interactions like dragging the margins to resize, updating the table layout based on the set colspecs.

3) Actions which modify a table like Insert Row, Insert Column.

Both (2) and (3) are done with Java extensions. For (3) you need to define actions which trigger certain operations, like you are doing with the Insert Table action.
For (2), if you edit the DITA document type in the Oxygen Document Type Association Preferences page it has an Extensions tab in which it specifies an Extensions Bundle implementation:

ro.sync.ecss.extensions.dita.DITAExtensionsBundle

You can also find the Java sources for that in the Author SDK project.
The DITAExtensionsBundle has a couple of methods which are interesting when dealing with tables:

Code: Select all


ro.sync.ecss.extensions.dita.DITAExtensionsBundle.createAuthorTableColumnWidthProvider()
ro.sync.ecss.extensions.dita.DITAExtensionsBundle.createAuthorTableCellSpanProvider()
So you need your custom extensions bundle implementation which overwrites those 2 table-related providers with your custom implementations based on the DITA ones.

Regards,
Radu

Re: Adding insert table dialogs to Author view

Posted: Fri Dec 13, 2013 12:57 am
by tgrantham
Thanks, Radu. That was exactly the information I needed.

Re: Adding insert table dialogs to Author view

Posted: Mon Dec 16, 2013 7:20 pm
by tgrantham
So here is my insert table override:

Code: Select all

  /**
* @see ro.sync.ecss.extensions.commons.table.operations.InsertTableOperationBase#insertTable(ro.sync.ecss.extensions.api.node.AuthorDocumentFragment[], boolean, ro.sync.ecss.extensions.api.AuthorAccess, java.lang.String, ro.sync.ecss.extensions.commons.table.operations.AuthorTableHelper)
*/
@Override
public void insertTable(AuthorDocumentFragment[] fragments, boolean cellsFragments,
AuthorAccess authorAccess, String namespace, AuthorTableHelper tableHelper)
throws AuthorOperationException {
PCTableInfo pctableinfo = new PCTableInfo(PCTableInfo.DEFAULT_ROWS_COUNT,PCTableInfo.TABLE_MODEL_WHENTHEN);


// Show the 'Insert table' dialog
if(authorAccess.getWorkspaceAccess().isStandalone()) {
PrecisionContentTableDialog pcTableDialog = new PrecisionContentTableDialog((Frame)authorAccess.getWorkspaceAccess().getParentFrame(),pctableinfo,true);
pcTableDialog.setLocationRelativeTo((Frame)authorAccess.getWorkspaceAccess().getParentFrame());
pcTableDialog.setVisible(true);
}

if (pctableinfo.getTableModel() != 0 && pctableinfo.getRowsNumber() != 0) {

// Create the table XML fragment
StringBuilder tableXMLFragment = new StringBuilder();
if (pctableinfo.getTableModel() == PCTableInfo.TABLE_MODEL_WHENTHEN) {
int rowsCount = pctableinfo.getRowsNumber();
String whenthenTableTag = "<whenthen relcolwidth=\"1* 1*\"><whenhead><whenhd><p>When...</p></whenhd><thenhd><p>Then...</p></thenhd></whenhead>";
String whenrowTableTag = "<whenrow><when><p></p></when><then><p></p></then></whenrow>";
tableXMLFragment.append(whenthenTableTag);


for (int i=0;i<rowsCount;i++) {
tableXMLFragment.append(whenrowTableTag);
}

tableXMLFragment.append("</whenthen>");

} else if (pctableinfo.getTableModel() == PCTableInfo.TABLE_MODEL_IFTHEN) {
String ifthenTableTag = "<ifthen relcolwidth=\"1* 1*\"><ifhead><ifhd><p>If...</p></ifhd><thenhd><p>Then...</p></thenhd></ifhead>";
String ifrowTableTag = "<ifrow><if><p></p></if><then><p></p></then></ifrow>";
int rowsCount = pctableinfo.getRowsNumber();
tableXMLFragment.append(ifthenTableTag);

for (int i=0;i<rowsCount;i++) {
tableXMLFragment.append(ifrowTableTag);
}

tableXMLFragment.append("</ifthen>");

}

// Insert the table
authorAccess.getDocumentController().insertXMLFragmentSchemaAware(
tableXMLFragment.toString(),
authorAccess.getEditorAccess().getCaretOffset());

} else {
// User canceled the operation
throw new AuthorOperationStoppedByUserException("Cancelled by user");
}
}
As you can see, it inserts the basic structure of the specialized simpletable, including the relcolwidth attribute values.

This works great, except that the author cannot resize the columns in the Author view with the mouse, nor does the width of the columns change in the Author view when the author changes the values of the relcolwidth attribute.

What am I missing?

Re: Adding insert table dialogs to Author view

Posted: Tue Dec 17, 2013 9:57 am
by Radu
Hi Tim,

In my previous post on the same thread I mentioned there were three aspects which need to be implemented regarding tables. You understood how (1) and (3) are done. I also gave you some advice how to make (2) work. Did you try to follow my advice?

Regards,
Radu

Re: Adding insert table dialogs to Author view

Posted: Tue Dec 17, 2013 7:24 pm
by tgrantham
I did indeed.

Re: Adding insert table dialogs to Author view

Posted: Wed Dec 18, 2013 9:48 am
by Radu
Hi Tim,

I need to know more details about what you tried in order to help further.
You could also send us your framework to support@oxygenxml.com and I'll try to have a look at it.

Regards,
Radu

Re: Adding insert table dialogs to Author view

Posted: Thu Dec 19, 2013 12:39 am
by tgrantham
Hi, Radu.

Here's what I want to do for my client.

As I mentioned before, I have created a custom DTD that constrains the DITA 1.2 DTD, and adds a few specializations, including three specializations of <simpletable>.

I want to add author operations to support the specializations. These operations would be similar to the ones oXygen currently provides for <simpletable>, <choicetable>, etc.: insert a table, insert and delete rows and columns, resize the column widths, and so on. Authors will select separate toolbar buttons and menu items for these specializations, because we want to keep them separate from the existing ones for <simpletable> (which they will still be able to use, since I haven't constrained those out).

I hope that I don't have to create a new framework. I hope that I can use the existing DITA framework and/or the existing DITA Extensions Bundle. But if I can't, I need to know as soon as possible.

I have read the Author SDK documents, and what information is there is not unhelpful, but what it lacks is a clear overview of the interaction model, so it is always very hard to know where to start. Going through the source code to the DITA framework to try and understand how the different parts work together is also very time-consuming.

So far, as you know, I have created a custom implementation of AuthorOperation to enable the author to insert one of the two specialized <simpletables> by clicking on a custom toolbar icon and selecting the type of table they want and the number of rows they want in the dialog that opens. This works very well, except that the Author view cannot provide the column resizing functionality for it.

After looking today through the source code in the DITA framework for the insert table operation (InsertTableOperation.java), which is what I based my custom operation on, I don't see how the column resizing functionality is provided there either. Is this source code up to date?

The functionality that supports the interactive column resizing appears instead to be implemented in the commitColumnWidthModifications method of the DITATableCellInfoProvider class.

If this is correct, how do I go about using or extending this class in my custom table insertion operation?

Tim.
P.S. I will email the files for my custom insert table operation to support@oxygenxml.com.

Re: Adding insert table dialogs to Author view

Posted: Thu Dec 19, 2013 2:01 pm
by Radu
Hi Tim,
The functionality that supports the interactive column resizing appears instead to be implemented in the commitColumnWidthModifications method of the DITATableCellInfoProvider class.
If this is correct, how do I go about using or extending this class in my custom table insertion operation?
Right, you would create your custom Java implementations for the interfaces ro.sync.ecss.extensions.api.AuthorTableCellSpanProvider and ro.sync.ecss.extensions.api.AuthorTableColumnWidthProvider based on the Java sources available in the Author SDK for ro.sync.ecss.extensions.commons.table.support.DITATableCellInfoProvider.DITATableCellInfoProvider() class.

Then you would bundle the custom compiled classes in a JAR library (you can use the same library you have now for the custom Insert Table operation).

Then you will edit the document type in the Oxygen Preferences->"Document Type Association" page and if you created an additional library you would first add it to the Classpath tab.
Then in the Extensions tab you have an Individual Extensions section where you can make the Cell spanning provider and Column Width Provider fields to point to your implementation classes which should be found by Oxygen in the JAR library.

Regards,
Radu

Re: Adding insert table dialogs to Author view

Posted: Thu Dec 19, 2013 5:23 pm
by tgrantham
Thanks, Radu.

The Author SDK Developer Guide says:
Starting with Oxygen XML Editor 10.3 version a single bundle was introduced acting as a provider for all other extensions. The individual extensions can still be set and if present they take precedence over the single provider, but this practice is being discouraged and the single provider should be used instead.
Does this mean that my custom version of the DITATableCellInfoProvider has to retain support for the regular <simpletable> and <table> elements, as well as my specializations of <simpletable>?

Tim.

Re: Adding insert table dialogs to Author view

Posted: Thu Dec 19, 2013 5:33 pm
by Radu
Hi Tim,
Does this mean that my custom version of the DITATableCellInfoProvider has to retain support for the regular <simpletable> and <table> elements, as well as my specializations of <simpletable>?
No, you should strip it down to contain only what you need. You can also leave the DITA stuff inside it but it will not matter in any way as your framework will be used to edit only your specific set of XML files.

What that quote you gave me really meant:

If you edit a document type in the Document Type Association Preferences page and you switch to the Extensions tab the first extension which can be set there is an "Extensions Bundle" API implementation.
That kind of implementation also has callbacks which can be used to provide cell span and column width providers. But you can also set the providers as separate extensions, as I explained in the previous email. So you can set up those providers either as separate extensions (the suggestion I gave you) or you can create an implementation of ro.sync.ecss.extensions.api.ExtensionsBundle which has callbacks allowing you to create those providers there.

Regards,
Radu

Re: Adding insert table dialogs to Author view

Posted: Thu Dec 19, 2013 9:27 pm
by tgrantham
Hi, Radu.
No, you should strip it down to contain only what you need. You can also leave the DITA stuff inside it but it will not matter in any way as your framework will be used to edit only your specific set of XML files.
This doesn't seem to be true. I took your suggestion and just added my custom providers as separate extensions, without changing the ro.sync.ecss.extensions.dita.DITAExtensionsBundle used for the DITA document type extension. It worked perfectly for my specialized tables, but removed the column resizing capability from the standard <table> and <simpletable> elements. When I added support for those elements back in to my custom extension, it started working again.

Regards,
Tim.

Re: Adding insert table dialogs to Author view

Posted: Fri Dec 20, 2013 9:45 am
by Radu
Hi Tim,

You are right, I went over the entire thread again and you explained earlier:
because we want to keep them separate from the existing ones for <simpletable> (which they will still be able to use, since I haven't constrained those out)
that you wanted to keep the existing support for table and simple table in your customization.
Somehow I thought you wanted to remove completely the support for the two standard DITA table structures.
The individual cell span and column width implementations need to be complete, they are not merged with the ones created in the extensions bundle implementation.
But there's nothing stopping you for example to extend directly the ro.sync.ecss.extensions.commons.table.support.DITATableCellInfoProvider implementation from the dita.jar with your own extension class which deals with your kind of tables and delegates to the super implementation for the other two kinds of tables. In this way, you would still use code from the dita.jar to handle the basic stuff.
As a similar approach you can extend directly the ro.sync.ecss.extensions.dita.DITAExtensionsBundle class to overwrite only part of its behavior.

We plan to provide in a future version a way of extending an existing document type without the need of copying stuff from it in order for example to be able to benefit of all changes which Oxygen does to the DITA document type in a future version without needing to merge your changes each time a new Oxygen version is released. I will add your use case to the issue and we'll update the forum thread when we make this improvement.

Regards,
Radu

Re: Adding insert table dialogs to Author view

Posted: Fri Dec 20, 2013 9:56 am
by Radu
Hi,

In addition to this, I will look over our bundled ro.sync.ecss.extensions.commons.table.support.DITATableCellInfoProvider implementation, try to make some changes to it so that if you create a simple table specialization you do not need to rewrite the code in this class, the class should be modified by us to work just as good for DITA <simpletable> or any specialization of it.

Regards,
Radu