How to apply a profiling condition set in DITA map manager programmatically ?

Post here questions and problems related to oXygen frameworks/document types.
Vince
Posts: 64
Joined: Wed Dec 03, 2014 11:25 am

How to apply a profiling condition set in DITA map manager programmatically ?

Post by Vince »

Hello,

Is there any way to apply a profiling condition set in DITA map manager programmatically ?

I'm able to define available profiling condition sets with :

Code: Select all

ProfileConditionsSetInfoPO[] array = ...
PluginWorkspaceProvider.getPluginWorkspace().setGlobalObjectProperty(APIAccessibleOptionTags.PROFILING_CONDITIONS_SET_LIST, array);
After doing it, I'm looking for a method to select the first profile condition as we can do with UI dropdown menu
conditions.set.png
Thank in advance for your help.

Vince
You do not have the required permissions to view the files attached to this post.
adrian_sorop
Posts: 78
Joined: Wed Jun 22, 2016 2:48 pm

Re: How to apply a profiling condition set in DITA map manager programmatically ?

Post by adrian_sorop »

Hi Vince!

That drop-down menu can't be accessed in a direct manner, but the actions from that menu could be retrieved and called.

Using the WSAuthorEditorPageBase.getActionsProvider() get getAuthorCommonActions.
In the resulted map, you can find the action that applies that condition set; the id is something like

Code: Select all

Profiling_Condition_Sets/Condition_Set_Apply theNameYouSetForThatConditionSet
Now, call the corresponding action for that id and the condition set will apply.

The snippet

Code: Select all


// define the condtion set
SerializableLinkedHashMap<String, String[]> conditions = new SerializableLinkedHashMap<String, String[]>();
ProfileConditionsSetInfoPO condSet1 = new ProfileConditionsSetInfoPO(conditions, "DITA*", "apiCondSet1");

SerializableLinkedHashMap<String, String[]> conditions2 = new SerializableLinkedHashMap<String, String[]>();
ProfileConditionsSetInfoPO condSet2 = new ProfileConditionsSetInfoPO(conditions2, "DITA*", "apiCondSet2");

ProfileConditionsSetInfoPO[] array = new ProfileConditionsSetInfoPO[] {condSet1, condSet2};
pluginWSAccess.setGlobalObjectProperty(APIAccessibleOptionTags.PROFILING_CONDITIONS_SET_LIST, array);

.................................

// get all the author actions
WSAuthorEditorPage authorEditorPage = ....
Map<String, Object> authorCommonActions = authorEditorPage.getActionsProvider().getAuthorCommonActions();

Set<Entry<String, Object>> entrySet = authorCommonActions.entrySet();
for (Entry<String, Object> entry : entrySet) {
  
  // find the action created for that condition set
  String key = entry.getKey();
  if (key.contains("apiCondSet1")) {
    SwingUtilities.invokeLater(() -> {
    // call the action
      javax.swing.Action action = (javax.swing.Action)entry.getValue();
      action.actionPerformed(null);
    });
    break;
  }
}
Let me know if this is helpful.
Adrian S.
Adrian Sorop
<oXygen/> XML Editor
http://www.oxygenxml.com
Vince
Posts: 64
Joined: Wed Dec 03, 2014 11:25 am

Re: How to apply a profiling condition set in DITA map manager programmatically ?

Post by Vince »

Thanks a lot

It's help me.

But what about the case user only open map in Dita map manager ?

In this case, I have no access to an WSAuthorEditorPage.

And I did not find how to access to common actions from the WSDITAMapEditorPage.
Conditions sets actions are not provided by DITAMapActionsProvider.

I use

Code: Select all

 var editor = PluginWorkspaceProvider.getPluginWorkspace().getEditorAccess(url, PluginWorkspace.DITA_MAPS_EDITING_AREA);
var ditaMapEditorPage= (WSDITAMapEditorPage) editor.getCurrentPage();
var actions = authorPage.getActionsProvider().getActions();
Thanks
adrian_sorop
Posts: 78
Joined: Wed Jun 22, 2016 2:48 pm

Re: How to apply a profiling condition set in DITA map manager programmatically ?

Post by adrian_sorop »

Hi Vince,

Sorry for the late response. I didn't receive the notification you posted.
Anyway, I don't bring good news. It seems like you can't access the actions from DITA Maps Manager.
I've added an internal issue to allow dirrect API access for profiling condtion sets.

Regards,
Adrian S.
Adrian Sorop
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply