Page 1 of 1
How to apply a profiling condition set in DITA map manager programmatically ?
Posted: Wed Jan 05, 2022 2:26 pm
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
Re: How to apply a profiling condition set in DITA map manager programmatically ?
Posted: Fri Jan 07, 2022 1:16 pm
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.
Re: How to apply a profiling condition set in DITA map manager programmatically ?
Posted: Sat Jan 08, 2022 2:19 am
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
Re: How to apply a profiling condition set in DITA map manager programmatically ?
Posted: Tue Feb 01, 2022 5:34 pm
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.