issue with the custom css -- setPseudoClass

Post here questions and problems related to oXygen frameworks/document types.
vishwavaranasi
Posts: 159
Joined: Fri Feb 28, 2020 4:02 pm

issue with the custom css -- setPseudoClass

Post by vishwavaranasi »

Hello Team , we have a custom css style as below

/** read-only topics or maps will be displayed with gray back ground color*/
:root:read-only{
background-color:#C0C0C0;
}


and in the plugin extension file we have our code like this , when we open a read-only file it is setting the bgcolor using the code

Code: Select all

if (currentPage instanceof WSAuthorEditorPage && !currentPage.isEditable()) {
					WSAuthorEditorPage authorPage = ((WSAuthorEditorPage) currentPage);
					
					authorPage.getDocumentController().setPseudoClass("read-only", authorPage.getDocumentController().getAuthorDocumentNode().getRootElement());
				}
here is the use case
1. ditamap file opened in main editing area - as read only file - and the bgcolor is showing as gray from css.
2. we have a our custom Action called check-out , which check-out(gets a lock) the file ditamap file on the right click of root node of the ditamap file. means here we are removed read-only (checkout action makes this a writable). and we are trying the below to remove bgcolor as part of check-out action.

Code: Select all

log.info("checkout done and next steps");
			WSEditor mainEditorAccess = pluginWorkspaceAccess.getCurrentEditorAccess(StandalonePluginWorkspace.MAIN_EDITING_AREA);
			WSEditorPage currentPage = mainEditorAccess.getCurrentPage();

			
			if (currentPage instanceof WSAuthorEditorPage && currentPage.isEditable()) {
				
				
				log.info("current page is writable");
				WSAuthorEditorPage authorPage = ((WSAuthorEditorPage) currentPage);
				log.info(authorPage.getDocumentController().getAuthorDocumentNode().getRootElement().getName());
				authorPage.getDocumentController().setPseudoClassUndoable("read-only", authorPage.getDocumentController().getAuthorDocumentNode().getRootElement());
				
				log.info("removed BG Color");
			}

3. problem is , the bgcolor is not going away until unless we click on the main editing area.
4. our requirement is as soon as checkout completed the bgcolor should go away (even with out clicking any where in the oxygen editor).

would you please help us to achieve the same.
Thanks,
vishwa
Radu
Posts: 9233
Joined: Fri Jul 09, 2004 5:18 pm

Re: issue with the custom css -- setPseudoClass

Post by Radu »

Hi,
I think this should have worked, I would advise you to use "authorPage.getDocumentController().setPseudoClass" instead of "authorPage.getDocumentController().setPseudoClassUndoable". On what execution thread is your code called? If you log the "Thread.currentThread()" object, what does it output in the console? If all else fails you could try to call "authorPage.refresh()".

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply