using resultsmanager in workspaceaccessplugin

Post here questions and problems related to oXygen frameworks/document types.
bk-one
Posts: 13
Joined: Mon Oct 23, 2017 3:42 pm

using resultsmanager in workspaceaccessplugin

Post by bk-one »

hi,
how can i use the ResultsManager in a javascript-based workspace access plugin?
i can't figure out how to add the right Listener to check if an operation produces results. So if someone runs an Xpath Operation, i would like to use the results in my plugin view.
and if i would be able to use the ResultsManager.getAllResults method, whats an example for the tabKey param?
thanks,
barbara
sorin_carbunaru
Posts: 402
Joined: Mon May 09, 2016 9:37 am

Re: using resultsmanager in workspaceaccessplugin

Post by sorin_carbunaru »

Hello Barbara,

For getting access to the results manager you have to call getResultsManager() on the pluginWorkspaceAccess object:

Code: Select all


function applicationStarted(pluginWorkspaceAccess) {
var resultsManager = pluginWorkspaceAccess.getResultsManager();
}
But getAllResults() will only return the results that were previously presented to the user by calling resultsManager.setResults() or resultsManager.addResult(s)(), so I don't know if this is what you are looking for.

What XPath operation are you referring to? Have you created your own operation by extending AuthorOperation? If not, how do you execute the XPath?

Kind regards,
Sorin Carbunaru
oXygen XML
bk-one
Posts: 13
Joined: Mon Oct 23, 2017 3:42 pm

Re: using resultsmanager in workspaceaccessplugin

Post by bk-one »

Hi Sorin,

thanks for your quick response.
sorry, i guess i misunderstood the ResultManager.

I would like to use the results produced by operations run from Oxygens Xpath Toolbar.
Here's a screenshot: https://drive.google.com/file/d/0B1jIsa ... 9icFk/view

Best wishes,
Barbara
sorin_carbunaru
Posts: 402
Joined: Mon May 09, 2016 9:37 am

Re: using resultsmanager in workspaceaccessplugin

Post by sorin_carbunaru »

Hi Barbara,

If you use our toolbar for executing XPath expressions, the results are presented in a panel at the bottom of the editor. That's perfect, because you can use the results manager. In my previous post, instead of saying that getAllResults() returns the results presented when calling some other methods of the manager, I should have said that it returns all the results that are presented in a results panel. My bad...

To use the results presented at the bottom of oXygen after executing an XPath expression in the designated toolbar, you have to write something like this (in Java):

Code: Select all


  WSEditor currentEditorAccess = pluginWorkspaceAccess.getCurrentEditorAccess(PluginWorkspace.MAIN_EDITING_AREA);
if (currentEditorAccess != null) {
URL editorLocation = currentEditorAccess.getEditorLocation();
String fileName = URLUtil.extractFileName(editorLocation);
ResultsManager resultsManager = pluginWorkspaceAccess.getResultsManager();
List<DocumentPositionedInfo> allResults = resultsManager.getAllResults("XPath - " + fileName);
}
For the exact JavaScript/Rhino syntax, please consult the resources from https://developer.mozilla.org/en-US/doc ... ects/Rhino (mainly https://developer.mozilla.org/en-US/doc ... pting_Java). You can also take a look at some of our JavaScript plug-in samples from GitHub (https://github.com/oxygenxml/wsaccess-j ... le-plugins).

Sorin C.
bk-one
Posts: 13
Joined: Mon Oct 23, 2017 3:42 pm

Re: using resultsmanager in workspaceaccessplugin

Post by bk-one »

wow, now i feel stupid :)
should have been able to figure that out by myself.

just one last question and then i'll stop bothering you.

my goal is to display the results in a table in my plugin-view (so the use case would be: user runs xpath => reviews results, maybe deletes some => clicks a button in the plugin view => gets the remaining results presented in a table => the table displays the result nodes attribute values and allows the user to modify them)

so i guess it's a mix of the refactoring tool and gridview.

is there an "easy" way to get nodes/elements/tags from results at the right offset? or do i need to detect first, if the current page is type author or text and - depending on that - either find the corresponding author nodes or the right text to modify?

(sorry if i'm not explaining it well enough - if necessary i could provide a mock up)

thanks again and best wishes,
barbara
sorin_carbunaru
Posts: 402
Joined: Mon May 09, 2016 9:37 am

Re: using resultsmanager in workspaceaccessplugin

Post by sorin_carbunaru »

Hello Barbara,

You need to check what page you are in, Author or Text, and based on that work in a certain way.

If you are in the Author page, then you can cast the DocumentPositionedInfo (DPI) objects returned by the results manager to AuthorDocumentPositionedInfo and call AuthorDocumentPositionedInfo#getNode().

For the Text page... Well... I don't have much experience with the Text page API. But I can tell you that you have to work with WSTextEditorPage and WSTextEditorPage#getDocument(). What I've seen exploring the text page API is that, to get the start and end offsets of a DPI, you can use WSTextBasedEditorPage.getStartEndOffsets(DocumentPositionedInfo), and you can get the text from between the offset using Document.getText(int, int). You might find this to be helpful at some point.

Sorin C.
Post Reply