Opening keyref links

Having trouble installing <oXygen/>? Got a bug to report? Post it all here.
Konstantin
Posts: 61
Joined: Tue Oct 27, 2015 11:49 am

Opening keyref links

Post by Konstantin » Tue Oct 27, 2015 1:17 pm

Hi !!!
We use Oxygen applet 16.1 for our application and we have problem with opening keyref links

We have two type xref links:

Code: Select all

<xref keyref="s01"/>
and

Code: Select all

<xref keyref="s01/p_topic_body_p_6"/>
First case works good. When I click on it open new document.
But in second case (with elementId) don't work. When I click on it open as usual link in default browser with URL:
http ://127.0.0.1:8888/.../props/source_props_01.dita#%5BANY%5D/p_topic_body_p_6

In map this reference looks like:

Code: Select all

<topicref href="..%2F..%2Fprops%2Fsource_props_01.dita" keys="s01"/>
We process this reference in method handleOpenURL():

Code: Select all


	...

final AuthorComponentFactory factory = AuthorComponentFactory.getInstance();

...

// Open a clicked link in the same component
factory.setOpenURLHandler(new OpenURLHandler() {

@Override
public void handleOpenURL(final URL arg0) throws IOException {
String path = arg0.getPath();
...

}
...
The problem is that the request misses in the method handleOpenURL when <xref keyref="s01/p_topic_body_p_6"/> has elementId (/p_topic_body_p_6) without it (<xref keyref="s01"/>) links work good.

Where can I processed incoming URL?

Radu
Posts: 7094
Joined: Fri Jul 09, 2004 5:18 pm

Re: Opening keyref links

Post by Radu » Thu Oct 29, 2015 9:55 am

Hi Konstantin,

What exactly are you doing right now on the "handleOpenURL" callback? You did not post enough code.
My recommendation when you receive the "handleOpenURL" callback would be to call the componentProvider.showLocation(URL, Reader) which should know how to handle the link information. Usually the URL you receive in the callback has an anchor which should contain enough details to help the component locate the target element.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

Konstantin
Posts: 61
Joined: Tue Oct 27, 2015 11:49 am

Re: Opening keyref links

Post by Konstantin » Thu Oct 29, 2015 11:30 am

Radu wrote:My recommendation when you receive the "handleOpenURL" callback
That's the problem I do not receive this callback


Sorry for the bad description of the issue
The issue is that I don't receive the "handleOpenURL" callback

Code: Select all

<xref keyref="s01/p_topic_body_p_6"/>
when there is elementId (/p_topic_body_p_6)

But method - handleOpenURL (final URL arg0) good works in cases:

Code: Select all

<xref keyref="s01"/>
or

Code: Select all

<xref href="source_props_01.dita#topicId0001/p_topic_body_p_2"/>
I never can catch the event of opening links.
I need somewhere to catch the opening event of reference for

Code: Select all

<xref keyref="s01/p_topic_body_p_6"/>
but it never caught
Link opens in a different browser to the page 404 and URL:
http ://127.0.0.1:8888/.../props/source_props_01.dita#%5BANY%5D/p_topic_body_p_6

Code: Select all



public class AuthorComponentApplet extends JApplet {
...
@Override
public void start() {
super.start();
new Thread() {

@Override
public void run() {
try {
...
final AuthorComponentFactory factory = AuthorComponentFactory.getInstance();
...
factory.setOpenURLHandler(new OpenURLHandler() {

@Override
public void handleOpenURL(final URL arg0) throws IOException {
String path = arg0.getPath();
...
getJSobjectPrototype().call("onOpenNewEditor", argums);
}
});

Radu
Posts: 7094
Joined: Fri Jul 09, 2004 5:18 pm

Re: Opening keyref links

Post by Radu » Fri Oct 30, 2015 9:42 am

Hi Kostantin,

I tested with the 17.1 Author Component libraries.
I created an Author Component Provider which loaded the initial topic (with the keyref link <xref keyref="keyName/pid"/>) and a DITA Map Component Provider which loaded the DITA Map which defines the key and binds it to the target topic.
I clicked the link and I received the callback on the open handler I have previously set up:

Code: Select all

    AuthorComponentFactory.getInstance().setOpenURLHandler(new OpenURLHandler() {
/**
* @see ro.sync.ecss.extensions.api.component.listeners.OpenURLHandler#handleOpenURL(java.net.URL)
*/
@Override
public void handleOpenURL(URL toOpen) throws IOException {
System.err.println("HANDLE OPEN " + toOpen);
}
});
The callback I received was something like:

Code: Select all

HANDLE OPEN file:/C:/path/to/testKeyref/t1.dita#[ANY]/pid
So this seemed to work for me.
I'm not sure if we had an issue in 16.1 related to this, I cannot find one.
Could you possibly also test with the updated Oxygen 17.1 libraries?
If it still does not work for you, maybe this depends on the way in which you are using the code and you could give me more code samples. Are you opening the DITA Map by creating a DITA Map Component Provider or are you setting up an external key definition provider using the API?

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

Konstantin
Posts: 61
Joined: Tue Oct 27, 2015 11:49 am

Re: Opening keyref links

Post by Konstantin » Wed Dec 09, 2015 4:51 pm

Hi again !!!
Upgrade to 17.1.0.1 didn't help.

We use custom DefinitionManager
We overrided the method :

Code: Select all

List <KeyDefinitionInfo> getContextKeyDefinitions()
it now returns a list of KeyDefinitionInfo for opened document.

In our case it contains one element:

Code: Select all


KeyDefInfo:
{
definitionLocation=http://localhost:8888/servlet?sourceDocPath=null&destDocPath=/DWDev/OOrg/P1/Main/Content/library/Default%20context%20variant/contextMap.ditamap,
name=s01,
href=/DWDev/OOrg/P1/Main/Content/source_props_01.dita
}
definition Location - the path to the servlet that returns Map which describes topicref (<topicref href = "..% 2F ..% 2Fprops% 2Fsource_props_01.dita" keys = "s01" />)
name - the name topicref
href - the path to a topic in the repository

When I click on keyref the debugger shows that is taken a list of KeyDefInfo from SustomDefinitionManager, but the document is opened in another browser tab.

We can not understand why we can not get a callback if we use

Code: Select all

<xref keyref = "s01 / p_topic_body_p_6" />
, but it turns out, if we use

Code: Select all

<xref keyref = "s01" />
In the case of

Code: Select all

<href keyref = "s01" />
callback comes URL:
http: // localhost: 8888 / DWDev / OOrg / P1 / Main / Content / NewFile_1.dita

and in the case of

Code: Select all

<xref keyref = "s01 / p_topic_body_p_6" />
- opens a tab browser by
http: // localhost: 8888 / DWDev / OOrg / P1 / Main / Content / NewFile_1.dita #% 5BANY% 5D / p_topic_body_p.

Radu
Posts: 7094
Joined: Fri Jul 09, 2004 5:18 pm

Re: Opening keyref links

Post by Radu » Thu Dec 10, 2015 10:48 am

Hi Konstantin,

The method "AuthorComponentFactory.setOpenURLHandler" is static, you can set a single open URL handler which handles the open events in your entire custom application.
So you should set the open url handler only once. And for each tab you open you should keep a global mapping between the tab's URL and it's authorComponentProvider.
Then when you receive the "handleOpenURL" event you should try to see in that mapping if there is already an authorComponentProvider created in one of the opened tabs for that URL and delegate the showLocation call to it. If there is no component opened for the URL you can add a new tab with that component and delegate the showLocation call to it.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

Post Reply