DITAMAPS Manager custom insert action showing prompt to discard or load changes
Posted: Thu May 02, 2024 1:04 pm
Hello Team , with our custom insert actions we are inserting a topicref from DITAMAPS Manager -> Insert Before ->{custom insert action} to ditamap opened inside the DITA Maps Manager
this action works fine , inside the insert action method we also calling the the following method() to save the ditamap and reload the map.
but after this method executed , we keep getting the prompt as below
when we click "NO" then only the newly added topicref showsup , if we click "YES" then it not loads newly added topicref
would you please help us here , how do we avoid the prompt
this action works fine , inside the insert action method we also calling the the following method() to save the ditamap and reload the map.
Code: Select all
WSEditor mainEditor = null;
if(DITAAccess.getRootMapURL()==null) {
logger.info("Selected RootMap is null, no map will be updated");
return;
}
String rootMapPath = DITAAccess.getRootMapURL().getPath();
File rootMap = new File(rootMapPath);
boolean isRootmapLocked = !rootMap.canWrite();
rootMap.setWritable(true);
URL[] editorLocations = PluginWorkspaceProvider.getPluginWorkspace().getAllEditorLocations(DITA_MAPS_EDITING_AREA);
mainEditor = PluginWorkspaceProvider.getPluginWorkspace().getCurrentEditorAccess(MAIN_EDITING_AREA);
logger.info(">>>>>Saving file: {}", mainEditor.getEditorLocation().getPath());
mainEditor.save();
URL enabledRootmap = null;
// Update only the references in the .ditamap file since it's not needed to save it at this point
for (URL location : editorLocations) {
WSEditor ditMapsEditor = PluginWorkspaceProvider.getPluginWorkspace().getEditorAccess(location, DITA_MAPS_EDITING_AREA);
logger.info("11>>>>>Saving and reloading ditamap: {}", mainEditor.getEditorLocation().getPath());
String path=mainEditor.getEditorLocation().getPath();
String finalName = path.substring(path. lastIndexOf('/'));
if(DITAAccess.getRootMapURL().toString().contains(finalName) && !mainEditor.getCurrentPage().isEditable()){
mainEditor.getCurrentPage().setEditable(true);
enabledRootmap=location;
}
WSDITAMapEditorPage page = (WSDITAMapEditorPage) ditMapsEditor.getCurrentPage();
ditMapsEditor.save();
page.refreshReferences();
}
ActionsProvider actionsProvider = ((StandalonePluginWorkspace)PluginWorkspaceProvider.getPluginWorkspace()).getActionsProvider();
Map<String, Object> globalActions = actionsProvider.getGlobalActions();
AbstractAction reloadAction = (AbstractAction)globalActions.get("File/Reload");
SwingUtilities.invokeLater(() -> actionsProvider.invokeAction(reloadAction));
//actionsProvider.invokeAction(reloadAction);
if(enabledRootmap!=null){
PluginWorkspaceProvider.getPluginWorkspace().getEditorAccess(enabledRootmap, DITA_MAPS_EDITING_AREA).getCurrentPage().setEditable(false);;
}
if(isRootmapLocked) {
rootMap.setWritable(false);
}
}
would you please help us here , how do we avoid the prompt