Page 1 of 1

Style filter on dita maps manager

Posted: Wed Nov 04, 2015 4:05 pm
by sebastienlavandier
Hello,

Is it possible to make an style filter plugin to customized DitaMaps Manager node.

Thanks in advance for your help.
Sébastien.L

Re: Style filter on dita maps manager

Posted: Wed Nov 04, 2015 4:37 pm
by Radu
Hi Sébastien,

The DITA Maps Manager does not use the styles filter API to render the nodes in the tree.
It uses a Swing JTree with our custom javax.swing.tree.TreeCellRenderer set to it.
One possibility for you would be to gain access to the custom JTree by using the API ro.sync.exml.workspace.api.editor.page.ditamap.WSDITAMapEditorPage.getDITAMapTreeComponent().
Then you can obtain the custom renderer from the JTree and create your own renderer which wraps it.
Your custom cell renderer would delegate to ours which returns a JPanel with labels inside, would modify that content and return it.

Regards,
Radu

Re: Style filter on dita maps manager

Posted: Thu Nov 05, 2015 5:59 pm
by sebastienlavandier
Hello,

I think I must to be more explicit...
So, by default each topic title appear on dita maps manager.
Just I want to add an information (linked to the topic content) after each topic title on the ditamaps manager.

Maybe I find a better solution... but I need help to finalize.
I'm implementing a CMS Plugin, and I have found this in the Oxygen plugin extensions samples :

Code: Select all


//Add a DITA Map Topic Ref resolver.
pluginWorkspaceAccess.addTopicRefTargetInfoProvider("cms", new TopicRefTargetInfoProvider() {
@Override
public void computeTopicRefTargetInfo(
Map<TopicRefInfo, TopicRefTargetInfo> ditaMapTargetReferences) {
Iterator<TopicRefInfo> keys = ditaMapTargetReferences.keySet().iterator();
while(keys.hasNext()) {
//Here you can see for what "href" the target information should be resolved
TopicRefInfo ti = keys.next();
TopicRefTargetInfo target = ditaMapTargetReferences.get(ti);
String href = (String) ti.getProperty(TopicRefInfo.HREF_VALUE);
//The plugin will handle this reference
target.setProperty(TopicRefTargetInfo.RESOLVED, "true");
//And then resolve the different properties from the CMS Metadata
//The title from the target topic
target.setProperty(TopicRefTargetInfo.TITLE, href + " TEST");
//The class attribute of the target element name
target.setProperty(TopicRefTargetInfo.CLASS_VALUE, " topic/topic ");
//The target element name
target.setProperty(TopicRefTargetInfo.ELEMENT_NAME, "topic");
//A parse error if something happened retrieving the data (maybe the target does not exist).
target.setProperty(TopicRefTargetInfo.PARSE_ERROR, null);
}
}
});
Unfortunately, when I use this solution, topic title don't appear on the dita maps manager like it's made by default.

How I can execute the standard process and add an information on each topic's title on ditamaps manager ?
Thanks in advance for your help.

Sébastien.L

Re: Style filter on dita maps manager

Posted: Fri Nov 06, 2015 11:03 am
by Radu
Hi Sébastien,

So you are using the Author Component SDK, right?
If so, have you added some logging to see that you receive the callback?
Did you use the singleton access to the plugin workspace provider? That singleton access in the author component might not have all its API functional.
In the AuthorComponentFactory there is a special API:

Code: Select all

ro.sync.ecss.extensions.api.component.AuthorComponentFactory.addDITAMapTreeTargetInformationProvider(String, TopicRefTargetInfoProvider)
which you should try to use instead.

I made a test like:

Code: Select all

    AuthorComponentFactory.getInstance().addDITAMapTreeTargetInformationProvider("file", new TopicRefTargetInfoProvider() {
@Override
public void computeTopicRefTargetInfo(
Map<TopicRefInfo, TopicRefTargetInfo> ditaMapTargetReferences) {
Iterator<TopicRefInfo> iterator = ditaMapTargetReferences.keySet().iterator();
if(iterator.hasNext()) {
TopicRefInfo topicRef = iterator.next();
TopicRefTargetInfo target = ditaMapTargetReferences.get(topicRef);
target.setProperty(TopicRefTargetInfo.RESOLVED, "true");
target.setProperty(TopicRefTargetInfo.TITLE, "TEST");
target.setProperty(TopicRefTargetInfo.CLASS_VALUE, " topic/topic ");
target.setProperty(TopicRefTargetInfo.ELEMENT_NAME, "topic");
target.setProperty(TopicRefTargetInfo.PARSE_ERROR, null);
}
}
});
and it seemed to work for me.

Regards,
Radu

Re: Style filter on dita maps manager

Posted: Fri Nov 06, 2015 12:30 pm
by sebastienlavandier
Hi Radu,

No I don't use Author Component SDK on this project.
Just I extending Oxygen XML Author to build a Custom CMS Plugins.
So I use PluginWorkspaceProvider.getPluginWorkspace() to access to the plugin workspace provider.

When I use PluginWorkspaceProvider.getPluginWorkspace().addTopicRefTargetInfoProvider() like in the previous post, I can add an information on TITLE property, but
if I set target.setProperty(TopicRefTargetInfo.RESOLVED, "true"); => title don't appear in ditamaps manager (like in standard process),
else if target.setProperty(TopicRefTargetInfo.RESOLVED, "false"); => title appear in diatamaos manager but added information is removed.

How I can use the standard process and add a information to the resolved title ?

Thanks in advance for your help.

Sébastien.L

Re: Style filter on dita maps manager

Posted: Fri Nov 06, 2015 2:47 pm
by Radu
Hi Sébastien,

This API was developed specific for CMSs which could obtain titles my querying the server faster than Oxygen would by individually parsing referenced topics.
The problem is that once you set the resolved property on the topicref:

Code: Select all

target.setProperty(TopicRefTargetInfo.RESOLVED, "true");
you will be responsible by your own means to compute a complete title for the topic (possibly using its @href to parse the referenced topic yourself).
So you cannot append content to an existing title this way, you need to return the entire title.

So if you want to just let Oxygen compute the title itself and append to it, you will probably need to use the tree cell renderer approach I initially gave you.

Regards,
Radu