Workspace access to Map Manager and validation console?
-
- Posts: 48
- Joined: Sat Jan 04, 2020 1:17 am
Workspace access to Map Manager and validation console?
If I have a WorkspaceAccessPluginExtension object, are there APIs to access the following?
1. The current root map select in Map Manager and it's values.
2. The values in the validation console.
Please see the screenshot below for clarification.
Thank you,
Will
-
- Posts: 9431
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Workspace access to Map Manager and validation console?
We have a static access using the method "ro.sync.ecss.dita.DITAAccess.getRootMapURL();" to retrieve the root map URL. But we do not have API to retrieve all values from the root map combo box. Could you elaborate? Why are you interested in those values?1. The current root map select in Map Manager and it's values.
We have API to add a validation problems filter to each opened document:2. The values in the validation console.
https://www.oxygenxml.com/InstData/Edit ... emsFilter-
For example you can use this filter to receive notifications when the document is validated and to even add more validation problems or filter out existing validation problems before they are shown to the end user. Like in this Javascript-based Oxygen plugin:
https://github.com/oxygenxml/wsaccess-j ... sAccess.js
Regards,
Radu
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 48
- Joined: Sat Jan 04, 2020 1:17 am
Re: Workspace access to Map Manager and validation console?
Thanks for your response.
ValidationProblemsFilter looks good - thanks!
ro.sync.ecss.dita.DITAAccess.getRootMapURL(); looks like a good place to start. Is this the correct Javadoc?
https://www.oxygenxml.com/InstData/Edit ... ccess.html
Our use case - we are maintaining, separately from the maps, a list of all files in a rootmap and it's submaps, and modify that list as writers edit a publication, like adding topics and map and images. We have a way to do this with one root map at a time.
But, we want writers to be able to have multiple root maps open at one time, but be able to identify specifically the current root map in:
They would be able to switch between maps, and we would be able to maintain two or more separate lists using the GUID of the root map to identify the correct list.
- There is no way to get the current map in Map Manager?
- Is there some other way to identify a list of current root maps, and designate one as current?
Will
-
- Posts: 9431
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Workspace access to Map Manager and validation console?
Let's say you have multiple DITA Maps opened in the DITA Maps Manager view. We have API to know which one of them is selected, or which one is opened/closed/saved:
Code: Select all
public void applicationStarted(StandalonePluginWorkspace pluginWorkspaceAccess) {
pluginWorkspaceAccess.addEditorChangeListener(new WSEditorChangeListener() {
public void editorSelected(URL editorLocation) {
//The map identified by the "editorLocation" URL was selected in the DITA Maps Manager view
};
}, PluginWorkspace.DITA_MAPS_EDITING_AREA);
}
If the "Root map" combo box is set to <Current map> then indeed the current selected map in the DITA Maps Manager view is the root map. But it may be set to another value, in which case the "DITAAccess.getRootMapURL()" is a better way to get that reference to the root map.
For example for the Oxygen User's manual we have one root map "Userguide.ditamap" and about 20 submaps. We always set the "Root map" combo box to "Userguide.ditamap" so that whatever submaps are currently edited in the DITA Maps Manager view the keys are always gathered from the "Userguide.ditamap" by Oxygen.
Regards,
Radu
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 168
- Joined: Fri Feb 28, 2020 4:02 pm
Re: Workspace access to Map Manager and validation console?
Post by vishwavaranasi »
but this never printing the problems list ,
would you suggest us , is there anything we are doing wrong here?
Code: Select all
public static List<DocumentPositionedInfo> CustomValidationProblemsFilter(StandalonePluginWorkspace pluginWorkspaceAccess)
{
URL[] allOpenedEditorLocations = pluginWorkspaceAccess.getAllEditorLocations(pluginWorkspaceAccess.MAIN_EDITING_AREA);
for (int i = 0; i < allOpenedEditorLocations.length; i++) {
System.out.println("this got printed" + allOpenedEditorLocations[i].getFile());
WSEditor openedEditor = pluginWorkspaceAccess.getEditorAccess(allOpenedEditorLocations[i], pluginWorkspaceAccess.MAIN_EDITING_AREA);
/*Add validation problems filter*/
if(openedEditor!=null)
{ System.out.println("THIS GOT PRINTED ---1------ValidationProblemsFilter" +openedEditor.getEditorLocation().getPath());
openedEditor.addValidationProblemsFilter(new ValidationProblemsFilter() {
public void filterValidationProblems(ValidationProblems validationProblems) {
validationProblems.getProblemsList().stream().forEach(problem->System.out.println("----printing validationProblems----"+problem.getMessage())); [b][u]// never reached here , it's not printing the problems list[/u][/b]
}
});
}else {
System.out.println("editorAccess is null");
}
}
return validationProblemsWithErrorSeverity;
}
}
vishwa
-
- Posts: 9431
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Workspace access to Map Manager and validation console?
So when is the "CustomValidationProblemsFilter" class instantiated?
If it's instantiated on the "WorkspaceAccessPluginExtension.applicationStarted(StandalonePluginWorkspace)" callback, this callback is received when Oxygen is started, there are no files opened in Oxygen at that time so the method "pluginWorkspaceAccess.getAllEditorLocations" returns an empty array.
Also while Oxygen is running, other files may be opened by the end user, you need to add the filter on those files as well.
So this is why you should add the filter like this (add a listener to be notified when a file is opened and add the filter to it):
Code: Select all
void applicationStarted(StandalonePluginWorkspace pluginWorkspaceAccess) {
pluginWorkspaceAccess.addEditorChangeListener(new WSEditorChangeListener() {
@Override
public void editorOpened(URL editorLocation) {
pluginWorkspaceAccess.getEditorAccess(editorLocation, PluginWorkspace.MAIN_EDITING_AREA).addValidationProblemsFilter(...);
}
}, PluginWorkspace.MAIN_EDITING_AREA);
}
Radu
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 168
- Joined: Fri Feb 28, 2020 4:02 pm
Re: Workspace access to Map Manager and validation console?
Post by vishwavaranasi »
"CustomValidationProblemsFilter" class is NOT instantiated inside WorkspaceAccessPluginExtension.applicationStarted(StandalonePluginWorkspace)"
instead
we are instantiating inside actionPerforemd method of one of our custom ActionListner class
vishwa
-
- Posts: 9431
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Workspace access to Map Manager and validation console?
I need more details, what is the purpose of that custom action which creates the "CustomValidationProblemsFilter" object?
Is it called by the end user? Can it be called multiple times? If it's called multiple times, it's implementation will add a filter to the opened documents each time so this is a bad idea.
Also if you add a filter does not mean that the validation will be called immediately after you add it. Validation of an opened document is usually called when editing the document or when using the "Validate" toolbar action.
Or you can call programmatically "openedEditor.checkValid()" to force validation to be done on an opened "WSEditor".
Regards,
Radu
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 168
- Joined: Fri Feb 28, 2020 4:02 pm
Re: Workspace access to Map Manager and validation console?
Post by vishwavaranasi »
Code: Select all
addValidationProblemsFilter(new ValidationProblemsFilter() {
public void filterValidationProblems(ValidationProblems validationProblems) {
validationProblems.getProblemsList().stream().forEach(problem->System.out.println("----printing validationProblems----"+problem.getMessage()));
}
but we have a requirement when we wanted the topic file to be checked in to a DB having the validation problems should not allowed.
for that reason we wanted to put this inside a action listener of DB action.
if we put the ValidationProblemsFilter inside WorkspaceAccessPluginExtension.applicationStarted() , here is the question how can i access the problem list from my custom action listener?
vishwa
-
- Posts: 9431
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Workspace access to Map Manager and validation console?
So when the "Check in" action is pressed you want to reject checking in topics if one or more of the current opened topics are invalid, right?
I see two possible ways:
1)
Code: Select all
private HashMap<URL, List> lastValidationErrors = new HashMap();
@Override
public void applicationStarted(StandalonePluginWorkspace pluginWorkspaceAccess) {
pluginWorkspaceAccess.addEditorChangeListener(new WSEditorChangeListener() {
@Override
public void editorOpened(URL editorLocation) {
WSEditor ed = pluginWorkspaceAccess.getEditorAccess(editorLocation, StandalonePluginWorkspace.MAIN_EDITING_AREA);
ed.addValidationProblemsFilter(new ValidationProblemsFilter() {
@Override
public void filterValidationProblems(
ro.sync.exml.workspace.api.editor.validation.ValidationProblems validationProblems) {
lastValidationErrors.put(ed.getEditorLocation(), validationProblems.getProblemsList());
};
});
};
}, StandalonePluginWorkspace.MAIN_EDITING_AREA);
AbstractAction checkout = new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
URL[] locations = pluginWorkspaceAccess.getAllEditorLocations(StandalonePluginWorkspace.MAIN_EDITING_AREA);
for (int i = 0; i < locations.length; i++) {
List problems = lastValidationErrors.get(locations[i]);
if(problems != null && ! problems.isEmpty()) {
//We had a validation problem for this editor location...
}
}
}
};
}
Code: Select all
@Override
public void applicationStarted(StandalonePluginWorkspace pluginWorkspaceAccess) {
AbstractAction checkout = new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
URL[] locations = pluginWorkspaceAccess.getAllEditorLocations(StandalonePluginWorkspace.MAIN_EDITING_AREA);
for (int i = 0; i < locations.length; i++) {
WSEditor editor = pluginWorkspaceAccess.getEditorAccess(locations[i], StandalonePluginWorkspace.MAIN_EDITING_AREA);
boolean valid = editor.checkValid();
if(! valid) {
//Reject the action
}
}
}
};
}
Radu
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 168
- Joined: Fri Feb 28, 2020 4:02 pm
Re: Workspace access to Map Manager and validation console?
Post by vishwavaranasi »
Since my Custom Action outside of WorkspaceAccessPluginExtension.applicationStarted(StandalonePluginWorkspace)"
i am planning to do this - inside applicationStarted()
javax.swing.UIManager.put("DOCS_VALIDATIONS", lastValidationErrors);
and at the other end
HashMap<URL, List> lastValidationErrors = (HashMap<URL, List>) UIManager.get("DOCS_VALIDATIONS");
am checking if the lastValidationErrors size is not zero before check in file to DB action will show error.
is this a good approach ?
vishwa
-
- Posts: 9431
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Workspace access to Map Manager and validation console?
I do not know anything about how your code is structured, where the custom action is created... if you give me enough small code snippets to understand how the action is created, in what part of the code, I can give you better advice, otherwise... what you did is not elegant but probably works.
Regards,
Radu
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 168
- Joined: Fri Feb 28, 2020 4:02 pm
Re: Workspace access to Map Manager and validation console?
Post by vishwavaranasi »
the checkin action what we are doing outside of WorkspaceAccessPluginExtension class , from there we have launched another Jframe , and this JFrame has some checkin action.
from previous reply I did do this , this am calling from checkin action listener class every time when user clicks checkin button on a file, here we know the file opened in oxygen editor , and i need to see this is a valid file by calling the below method.
Code: Select all
public static boolean CustomValidationProblemsFilter(StandalonePluginWorkspace pluginWorkspaceAccess)
{
logger.info("CustomValidationProblemsFilter Called..");
boolean isxmlDocumentValid=false;
URL[] locations = pluginWorkspaceAccess.getAllEditorLocations(StandalonePluginWorkspace.MAIN_EDITING_AREA);
for (int i = 0; i < locations.length; i++) {
WSEditor editor = pluginWorkspaceAccess.getEditorAccess(locations[i], StandalonePluginWorkspace.MAIN_EDITING_AREA);
if(editor.checkValid())
{
isxmlDocumentValid=true;
}
}
return isxmlDocumentValid;
}
this method works fine for the first time i have errors then its not allowed checkin , but next time i have fixed errors to a file and saved , and then try checkin the above still returns that it is invalid file.
vishwa
-
- Posts: 9431
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Workspace access to Map Manager and validation console?
Your implementation has various problems, if for example the files F1 and F2 are opened in the editor and the file F1 is invalid and F2 is valid, your method returns "valid" although it should return invalid as F1 is invalid.
In my opinion the method should look like this:
Code: Select all
public static boolean checkAllOpenedEditorsValid(
StandalonePluginWorkspace pluginWorkspaceAccess) {
boolean allOpenedEditorsAreValid = true;
URL[] locations = pluginWorkspaceAccess
.getAllEditorLocations(StandalonePluginWorkspace.MAIN_EDITING_AREA);
for (int i = 0; i < locations.length; i++) {
WSEditor editor = pluginWorkspaceAccess.getEditorAccess(locations[i],
StandalonePluginWorkspace.MAIN_EDITING_AREA);
allOpenedEditorsAreValid = allOpenedEditorsAreValid && editor.checkValid();
if (!allOpenedEditorsAreValid) {
//At least one file is invalid
break;
}
}
return allOpenedEditorsAreValid;
}
Code: Select all
booleanAllOpenedFilesAreValid = checkAllOpenedEditorsValid((StandalonePluginWorkspace) ro.sync.exml.workspace.api.PluginWorkspaceProvider.getPluginWorkspace());
You should also try to have a more clear perspective about how you should check if invalid files are about to be checked in.
For example you have files F1, F2 and F3 opened. File F3 is opened from the local disk, it's not opened from the CMS, the fact that it's valid or not should not influence the check in operation. Or you open file F1 from the CMS, make it invalid, save it and close it. The file is no longer opened but you still need to check it in.
Regards,
Radu
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 168
- Joined: Fri Feb 28, 2020 4:02 pm
Re: Workspace access to Map Manager and validation console?
Post by vishwavaranasi »
here editor.checkValid(); is also considering WARNINGS. is that expected?
I have observed only file with below in GREEN are valid?
vishwa
-
- Posts: 9431
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Workspace access to Map Manager and validation console?
Yes, the Javadoc is available here:
https://www.oxygenxml.com/InstData/Edit ... eckValid--
Regards,Check if the current editor is valid, performs manual validation and returns true if the last validation was finished without errors or warnings.
Radu
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 168
- Joined: Fri Feb 28, 2020 4:02 pm
Re: Workspace access to Map Manager and validation console?
Post by vishwavaranasi »
vishwa
-
- Posts: 9431
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Workspace access to Map Manager and validation console?
The "checkValid() " cannot make this distinction.
If you want this distinction between errors and warnings, you would need to go back to using the "ValidationProblemsFilter" API as the list of problems that you receive "validationProblems.getProblemsList()" can be iterated and each problem has a "ro.sync.document.DocumentPositionedInfo.getSeverity()" method which can be used to find out the severity of the problem (info/warning/error).
Regards,
Radu
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 168
- Joined: Fri Feb 28, 2020 4:02 pm
Re: Workspace access to Map Manager and validation console?
Post by vishwavaranasi »
here not able to declare the correct place for
List<DocumentPositionedInfo> validationProblemsWithErrorSeverity=new ArrayList<DocumentPositionedInfo>();
as i defined in the below method
but the last 2 lines showing me error
//error here variable validationProblemsWithErrorSeverity not accessable
NOTE : as i mentioned previous replies my custom checkin action has to invoking this after a call checkValid() , here the problem list with SeverityAs error or fatal error where the sysout below printing fine.
System.out.println("----printing ERROR and Fatal validationProblems----"
+ problem.getMessage() + " " + problem.getSeverityAsString()));
Code: Select all
public int CustomValidationProblemsFilter() {
URL[] locations1 = ro.sync.exml.workspace.api.PluginWorkspaceProvider.getPluginWorkspace().getAllEditorLocations(StandalonePluginWorkspace.MAIN_EDITING_AREA);
for (int i = 0; i < locations1.length; i++) {
ro.sync.exml.workspace.api.PluginWorkspaceProvider.getPluginWorkspace().getEditorAccess(locations1[i], StandalonePluginWorkspace.MAIN_EDITING_AREA)
.addValidationProblemsFilter(new ValidationProblemsFilter() {
public void filterValidationProblems(ValidationProblems validationProblems) {
List<DocumentPositionedInfo> validationProblemsWithErrorSeverity=new ArrayList<DocumentPositionedInfo>();
if (validationProblems.getProblemsList() != null) {
validationProblemsWithErrorSeverity = validationProblems.getProblemsList().stream()
.filter(problem -> problem.getSeverityAsString().equals("error")
|| problem.getSeverityAsString().equals("fatal error"))
.collect(Collectors.toList());
validationProblemsWithErrorSeverity.stream().forEach(
problem -> System.out.println("----printing ERROR and Fatal validationProblems----"
+ problem.getMessage() + " " + problem.getSeverityAsString()));
}
}
});
}
System.out.println("2---printing validationProblemsWithErrorSeverity.size()" + validationProblemsWithErrorSeverity.size()); //error here variable validationProblemsWithErrorSeverity not accessable
return validationProblemsWithErrorSeverity.size(); //error here variable validationProblemsWithErrorSeverity not accessable
}
vishwa
-
- Posts: 9431
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Workspace access to Map Manager and validation console?
I proposed to you previously at some point to keep a hash map between editor location and problems.
So the code would look something like this:
Code: Select all
private Map<URL, List<DocumentPositionedInfo>> locationToErrorsMap = new HashMap<>();
@Override
public void applicationStarted(StandalonePluginWorkspace pluginWorkspaceAccess) {
pluginWorkspaceAccess.addEditorChangeListener(new WSEditorChangeListener() {
@Override
public void editorOpened(URL editorLocation) {
pluginWorkspaceAccess.getEditorAccess(editorLocation, PluginWorkspace.MAIN_EDITING_AREA)
.addValidationProblemsFilter(new ValidationProblemsFilter() {
@Override
public void filterValidationProblems(ValidationProblems validationProblems) {
List<DocumentPositionedInfo> validationProblemsWithErrorSeverity = new ArrayList<DocumentPositionedInfo>();
if (validationProblems.getProblemsList() != null) {
validationProblemsWithErrorSeverity = validationProblems.getProblemsList().stream()
.filter(problem -> problem.getSeverity() == DocumentPositionedInfo.SEVERITY_ERROR
|| problem.getSeverity() == DocumentPositionedInfo.SEVERITY_FATAL)
.collect(Collectors.toList());
}
locationToErrorsMap.put(editorLocation, validationProblemsWithErrorSeverity);
}
});
}
}, PluginWorkspace.MAIN_EDITING_AREA);
}
public int getNumberOfErrorsFromAllOpenedDocuments() {
URL[] locations = ro.sync.exml.workspace.api.PluginWorkspaceProvider.getPluginWorkspace().getAllEditorLocations(StandalonePluginWorkspace.MAIN_EDITING_AREA);
int counterWithAllErrorsFromAllOpenedDocuments = 0;
for (int i = 0; i < locations.length; i++) {
List<DocumentPositionedInfo> problems = locationToErrorsMap.get(locations[i]);
if(problems != null) {
counterWithAllErrorsFromAllOpenedDocuments += problems.size();
}
}
return counterWithAllErrorsFromAllOpenedDocuments;
}
Radu
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 168
- Joined: Fri Feb 28, 2020 4:02 pm
Re: Workspace access to Map Manager and validation console?
Post by vishwavaranasi »
vishwa
-
- Posts: 9431
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Workspace access to Map Manager and validation console?
You could try for example to make the map "locationToErrorsMap" static and also make the method "getNumberOfErrorsFromAllOpenedDocuments" static so that you can call it like CustomWorkspaceAccessPluginExtension.getNumberOfErrorsFromAllOpenedDocuments().
Regards,
Radu
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 168
- Joined: Fri Feb 28, 2020 4:02 pm
Re: Workspace access to Map Manager and validation console?
Post by vishwavaranasi »
vishwa
-
- Posts: 168
- Joined: Fri Feb 28, 2020 4:02 pm
Re: Workspace access to Map Manager and validation console?
Post by vishwavaranasi »
would it possible to check the validations problems even in case of file not opened inside a editor?
Thanks,
vishwa
vishwa
-
- Posts: 9431
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Workspace access to Map Manager and validation console?
We have an API for this as well but it works only with Oxygen 25.0 and newer:
ro.sync.exml.workspace.api.PluginWorkspace.getValidationUtilAccess()
https://www.oxygenxml.com/InstData/Edit ... ccess.html
For older versions of Oxygen you would need to open the XML file in Oxygen using our APis and validate it.
Regards,
Radu
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 168
- Joined: Fri Feb 28, 2020 4:02 pm
Re: Workspace access to Map Manager and validation console?
Post by vishwavaranasi »
vishwa
-
- Posts: 2879
- Joined: Tue May 17, 2005 4:01 pm
Re: Workspace access to Map Manager and validation console?
What are you looking for, exactly? A distribution of Oxygen with a different version of Java, or a distribution with no Java bundle?
Officially Oxygen 25.0 only supports Java 11 and Java 17. The officially supported distribution bundles Java 17.
Unofficially there are also some distributions of v25.0 with Java 8 (Windows and macOS), but they are unsupported (a warning appears at startup). Please contact us on support@oxygenxml.com, if you require these (Java 8 ). Starting with v26.0 these will no longer be available, Java 17 only.
If you want a distribution with no Java bundle, please download the Other > All platforms distribution, or the Windows ZIP and remove the jre folder.
Regards,
Adrian
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
-
- Posts: 168
- Joined: Fri Feb 28, 2020 4:02 pm
Re: Workspace access to Map Manager and validation console?
Post by vishwavaranasi »
vishwa
Return to “SDK-API, Frameworks - Document Types”
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service