beforeAttributeChange and attributeChanged in the AuthorListener

<oXygen/> general issues.
SSC
Posts: 206
Joined: Thu Dec 01, 2011 4:22 pm
Location: Hamburg, Germany

beforeAttributeChange and attributeChanged in the AuthorListener

Post by SSC » Mon Jan 30, 2012 11:02 am

Hello,

there are several ways to change attributes of a certain tag element.
Internally I guess they are all changed by the

Code: Select all

documentController.setAttribute(attrName, new AttrValue(attrValue), authorElement);
Is the AuthorListener with its attributeChanged event the correct listener for the setAttribute method of the AuthorDocumentController?
When exactly are the beforeAttributeChange and attributeChanged methods are invoked?

Thanks in advance

Simon
Simon Scholz
vogella GmbH
http://www.vogella.com

Radu
Posts: 7094
Joined: Fri Jul 09, 2004 5:18 pm

Re: beforeAttributeChange and attributeChanged in the AuthorListener

Post by Radu » Mon Jan 30, 2012 12:04 pm

Hi Simon,

So you are referring to this listener class:

ro.sync.ecss.dom.AuthorDocumentListenerExt

It should receive events before and after an attribute was added/removed/changed either through the Attributes Table (or in-place Attributes viewer) provided by Oxygen or when some API call to the document controller is made either by the Oxygen code or by a developer's extension.

What exactly are you trying to accomplish?
If you want to alter the value which is set I would suggest the document filter approach:

ro.sync.ecss.extensions.api.AuthorDocumentFilter.setAttribute(AuthorDocumentFilterBypass, String, AttrValue, AuthorElement)

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

SSC
Posts: 206
Joined: Thu Dec 01, 2011 4:22 pm
Location: Hamburg, Germany

Re: beforeAttributeChange and attributeChanged in the AuthorListener

Post by SSC » Mon Jan 30, 2012 1:17 pm

I was not referring to the ro.sync.ecss.dom.AuthorDocumentListenerExt, but to the ro.sync.ecss.extensions.api.AuthorListener.

I am not able to find the ro.sync.ecss.dom.AuthorDocumentListenerExt class. Maybe it is obfuscated.

How do I get the ro.sync.ecss.extensions.api.AuthorDocumentFilter, you mentioned?

For the usual AuthorDocumentController I use the following method :

Code: Select all

	private AuthorDocumentController getDocumentController() {
IEditorPart activeEditor = PlatformUI.getWorkbench()
.getActiveWorkbenchWindow().getActivePage().getActiveEditor();
if (activeEditor instanceof WSEditor) {
WSEditorPage currentPage = ((WSEditor) activeEditor)
.getCurrentPage();
if (currentPage instanceof WSAuthorEditorPage) {
return ((WSAuthorEditorPage) currentPage)
.getDocumentController();
}
}
return null;
}
Regards,

Simon
Simon Scholz
vogella GmbH
http://www.vogella.com

Radu
Posts: 7094
Joined: Fri Jul 09, 2004 5:18 pm

Re: beforeAttributeChange and attributeChanged in the AuthorListener

Post by Radu » Mon Jan 30, 2012 1:41 pm

Hi Simon,

You are right, I meant this listener:

ro.sync.ecss.extensions.api.AuthorListener

Once you gain access to the AuthorDocumentController you can do the following:

Code: Select all

    documentController.setDocumentFilter(new AuthorDocumentFilter() {
/**
* @see ro.sync.ecss.extensions.api.AuthorDocumentFilter#setAttribute(ro.sync.ecss.extensions.api.AuthorDocumentFilterBypass, java.lang.String, ro.sync.ecss.extensions.api.node.AttrValue, ro.sync.ecss.extensions.api.node.AuthorElement)
*/
@Override
public void setAttribute(AuthorDocumentFilterBypass filterBypass, String attributeName,
AttrValue value, AuthorElement element) {
//Here you can modify the attribute name and/or value before delegating to super.
//TODO your code here
// Delegate to super to perform the default operation on the attribute value and name.
super.setAttribute(filterBypass, attributeName, value, element);
}
});
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

Post Reply