Customize track changes

Having trouble installing Oxygen? Got a bug to report? Post it all here.
Kasturi999
Posts: 15
Joined: Fri Jan 08, 2010 2:50 pm

Customize track changes

Post by Kasturi999 »

Hi,
I would like to customize the track changes functionality by renaming the Accept and Reject changes with something else in the context menu.
Also I would do not wish to see a strike through for a delete. Is it possible? If so please let me know.
Thanks
KK
Radu
Posts: 9041
Joined: Fri Jul 09, 2004 5:18 pm

Re: Customize track changes

Post by Radu »

Hi,

What type of XML files are you editing? Do you have a custom document type configured?
Have you previously worked with our Java Author SDK?
Depending on your current knowledge of our API I could give you more details.

http://www.oxygenxml.com/oxygen_sdk.htm ... horing_SDK
I would like to customize the track changes functionality by renaming the Accept and Reject changes with something else in the context menu.
We have some Java API which would allow you to set a pop-up menu customizer in the Author page:

Code: Select all

ro.sync.exml.workspace.api.editor.page.author.WSAuthorEditorPageBase.setPopUpMenuCustomizer(AuthorPopupMenuCustomizer)
Also I would do not wish to see a strike through for a delete. Is it possible? If so please let me know.
Using our API you can set your own delete change tracking renderer:

Code: Select all

ro.sync.ecss.extensions.api.AuthorReviewController.setReviewRenderer(PersistentHighlightRenderer)
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Kasturi999
Posts: 15
Joined: Fri Jan 08, 2010 2:50 pm

Re: Customize track changes

Post by Kasturi999 »

Yes we have a custom documenttype configured.As I am new to this oxygen, not sure where exactly needs to be looking at - for customizing the track changes functionality. Can you point me where exactly to look at or provide me with sample code please?
mihaela
Posts: 490
Joined: Wed May 20, 2009 2:40 pm

Re: Customize track changes

Post by mihaela »

Hi,

If you already have a custom document type configured then you probably have an ExtensiondBundle configured for this document type.

If not, you can read the following topic from our online documentation:
http://oxygenxml.com/doc/ug-editor/task ... undle.html

In your ExtensionsBundle implementation you can create an AuthorExtensionStateListener that contains the following method, called when the Author extension is activated:

Code: Select all

void activated(AuthorAccess authorAccess);


In this method you can add your code for customizing the popup menu items and change highlights rendering.
Here is a code sample that changes the popup menu item text from "Accept Change(s)" to "New text" and paints a gray background to delete changes highlights:

Code: Select all


  public void activated(AuthorAccess authorAccess) {
// Customize popup menu
authorAccess.getEditorAccess().setPopUpMenuCustomizer(
new AuthorPopupMenuCustomizer() {
public void customizePopUpMenu(Object popUp, AuthorAccess authorAccess) {
JPopupMenu contextualMenu = ((JPopupMenu)popUp);
// Find the popup menu item with "Accept Change(s)" text
Component[] components = contextualMenu.getComponents();
for (Component component : components) {
if (component instanceof JMenuItem) {
String itemText = ((JMenuItem)component).getText();
if ("Accept Change(s)".equals(itemText)) {
((JMenuItem)component).setText("New text");
break;
}
}
}
}
});

// Set a review renderer to change the painter of delete changes highlights
authorAccess.getReviewController().setReviewRenderer(new PersistentHighlightRenderer() {

public String getTooltip(AuthorPersistentHighlight authorpersistenthighlight) {
// If a <code>null</code> value is returned, the default tooltip is used.
return null;
}

public HighlightPainter getHighlightPainter(AuthorPersistentHighlight highlight) {
HighlightPainter painter = null;
if (highlight.getType() == PersistentHighlightType.CHANGE_DELETE) {
painter = new ColorHighlightPainter();
((ColorHighlightPainter)painter).setBgColor(Color.COLOR_GRAY);
}
// If a <code>null</code> value is returned, the default highlight painter is used.
return painter;
}
});
}
Please let us know if you need more guidance.

Best regards,
Mihaela
Mihaela Calotescu
http://www.oxygenxml.com
Kasturi999
Posts: 15
Joined: Fri Jan 08, 2010 2:50 pm

Re: Customize track changes

Post by Kasturi999 »

HI,
I've got Oxygen version 11.2 and it seems like this feature isn't available in 11.2. Can you provide me any other options with 11.2 version please? In the meantime I am going to try this on version 14.

Thanks
mihaela
Posts: 490
Joined: Wed May 20, 2009 2:40 pm

Re: Customize track changes

Post by mihaela »

Hi,

From what I see the AuthorPopupMenuCustomizer is available starting with version 11.2 so you can customize the popup menu entries.

The PersistentHighlightRenderer was introduced in oXygen version 12. This means that there is no API available for version 11.2 to customize the appearance of the change tracking highlights.

Best regards,
Mihaela
Mihaela Calotescu
http://www.oxygenxml.com
Kasturi999
Posts: 15
Joined: Fri Jan 08, 2010 2:50 pm

Re: Customize track changes

Post by Kasturi999 »

Hi,
I will once again check AuthorPopupMenuCustomizer.

Is it possible to render the content in custom processing instruction with a different color in version 11.2 please?
For example:- <?abc_insert_start?> Text inserted here 123 <?abc_insert_end?>
In the above example “ Text inserted here 123 ” should be rendered in RED.
Thanks
mihaela
Posts: 490
Joined: Wed May 20, 2009 2:40 pm

Re: Customize track changes

Post by mihaela »

Hi,

No, it is not possible in 11.2 to customize the rendering of the text content found between two processing instructions.

If you want to do this in oXygen version 14 you can use the ro.sync.ecss.extensions.api.highlights.AuthorPersistentHighlighter API that offers the possibility to add, manage and customize the rendering of custom persistent highlights which are serialized in the XML as processing instructions with the following form:

Code: Select all

<?oxy_custom_start prop1="val1"....?> xml content <?oxy_custom_end?>
To add this type of highlights you can use the method:

Code: Select all

ro.sync.ecss.extensions.api.highlights.AuthorPersistentHighlighter.addHighlight(int, int, LinkedHashMap<String, String>)
To customize this highlights rendering use:

Code: Select all

ro.sync.ecss.extensions.api.highlights.AuthorPersistentHighlighter.setHighlightRenderer(PersistentHighlightRenderer)

Here is the online javadoc for more information:
http://www.oxygenxml.com/InstData/Edito ... ghter.html

Furthermore, we have added the possibility to display callouts in Author mode for this custom highlights. See our online documentation for more details:
http://www.oxygenxml.com/doc/ug-author/ ... louts.html

Regards,
Mihaela
Mihaela Calotescu
http://www.oxygenxml.com
Kasturi999
Posts: 15
Joined: Fri Jan 08, 2010 2:50 pm

Re: Customize track changes

Post by Kasturi999 »

Can you please provide me with some sample code to exactly do this?
Thanks
mihaela
Posts: 490
Joined: Wed May 20, 2009 2:40 pm

Re: Customize track changes

Post by mihaela »

Hi,

If you need a code sample, you have to give me more details about your use-case.
For example, when you want to mark the text content with a different color? Do you need an action that can be executed by the user to highlight the selection?

Best regards,
Mihaela
Mihaela Calotescu
http://www.oxygenxml.com
Kasturi999
Posts: 15
Joined: Fri Jan 08, 2010 2:50 pm

Re: Customize track changes

Post by Kasturi999 »

When an user opens a xml document from the application, they should be able to see the content inside two different processing instructions in two different colors as below
1. <?abc_delete content=” Text 213” ?>  Here the string “Text 213” should render as RED
2. <?abc_insert_start?>Example text<?abc_insert_end?>  Here the text “Example text” should be BLUE

Thanks
mihaela
Posts: 490
Joined: Wed May 20, 2009 2:40 pm

Re: Customize track changes

Post by mihaela »

Hello,

By using the API that I have described you before (the AuthorPersistentHighlighter) you can insert and render only the PIs with the following form:

Code: Select all

<?oxy_custom_start prop1="val1"....?> xml content <?oxy_custom_end?>
Do you want to handle only the processing instructions having exactly the <?abc_delete...?> and <?abc_insert_start?>...<?abc_insert_end?> form? In this case, you cannot use the API and, as I already told you, there is no way to customize the color of the text between two processing instructions.

Regards,
Mihaela
Mihaela Calotescu
http://www.oxygenxml.com
Kasturi999
Posts: 15
Joined: Fri Jan 08, 2010 2:50 pm

Re: Customize track changes

Post by Kasturi999 »

Ok - I am flexible with the tags name
So can the below be possible please? If yes can you provide the sample code?
if(prop1="insert")
"Text Inserted" should be in RED
else
"Text Deleted" should be in BLUE
<?oxy_custom_start prop1="insert"?> Text Inserted <?oxy_custom_end?>  RED
<?oxy_custom_start prop1="delete"?> Text Deleted <?oxy_custom_end?>  BLUE
mihaela
Posts: 490
Joined: Wed May 20, 2009 2:40 pm

Re: Customize track changes

Post by mihaela »

Hi,

Here is the code sample:

Code: Select all


AuthorPersistentHighlighter highlighter = authorAccess.getEditorAccess().getPersistentHighlighter();
highlighter.setHighlightRenderer(new PersistentHighlightRenderer() {

public String getTooltip(AuthorPersistentHighlight highlight) {
return null;
}

public HighlightPainter getHighlightPainter(AuthorPersistentHighlight highlight) {
LinkedHashMap<String, String> properties = highlight.getClonedProperties();
String prop1Value = properties.get("prop1");
ColorHighlightPainter painter = null;
if (prop1Value != null) {
if ("insert".equals(prop1Value)) {
// Red text
painter = new ColorHighlightPainter();
painter.setTextDecoration(TextDecoration.NONE);
painter.setTextForegroundColor(Color.COLOR_RED);
} else if("delete".equals(prop1Value)) {
// Blue text
painter = new ColorHighlightPainter();
painter.setTextDecoration(TextDecoration.NONE);
painter.setTextForegroundColor(Color.COLOR_BLUE);
}
}
return painter;
}
});
You can add this code also in the activated() method of your AuthorExtensionStateListener implementation.

Regards,
Mihaela
Mihaela Calotescu
http://www.oxygenxml.com
Kasturi999
Posts: 15
Joined: Fri Jan 08, 2010 2:50 pm

Re: Customize track changes

Post by Kasturi999 »

Thanks alot...
That worked.
mihaela
Posts: 490
Joined: Wed May 20, 2009 2:40 pm

Re: Customize track changes

Post by mihaela »

Hi,

I'm glad that the code sample helped you.

I have a question for you. From your requests it seems that you are trying to mark the content as deleted or as inserted, by using your own mechanism (through custom processing instructions). Why don't you use the oXygen Change Tracking mechanism?

Best Regards,
Mihaela
Mihaela Calotescu
http://www.oxygenxml.com
Post Reply