Change tabs title when Oxygen starts with opened files

Post here questions and problems related to oXygen frameworks/document types.
Lordy
Posts: 8
Joined: Thu Aug 01, 2024 5:22 pm

Change tabs title when Oxygen starts with opened files

Post by Lordy »

Hi team, currently I'm developing a plugin for Oxygen Desktop 24.1.

I'm implementing the tab title change from Dita Maps Manager when you open a Root Map.
I'm using the setEditorTabText() method from WSEditor class.

Code: Select all

WSEditor editorPage = oxygenStandalonePluginWorkspace.getEditorAccess(url, DITA_MAPS_EDITING_AREA);
String openedFileTitle = myOwnFunctionToGetTheFileTitle(url);
editorPage.setEditorTabText(openedFileTitle);
It works very well, but if I close and open Oxygen with opened files, the titles of the tabs don't change until I click on them.

I tried to access each file when the editor triggers the editorOpened event using the next code, but it only brings one file.

Code: Select all

URL[] openedFilesUrl = oxygenStandalonePluginWorkspace.getAllEditorLocations(DITA_MAPS_EDITING_AREA);
Do you have any idea how to change the tabs title when Oxygen starts with opened files?
Thanks a lot!
adrian_sorop
Posts: 78
Joined: Wed Jun 22, 2016 2:48 pm

Re: Change tabs title when Oxygen starts with opened files

Post by adrian_sorop »

Hi,
At first glance, this might be listeners issue.
I'm assuming you're installing a ro.sync.exml.workspace.api.listeners.WSEditorChangeListener that handles the changes.
I don't know what methods you implemented, but you could try with editorAboutToBeOpened​, editorOpened​, editorActivated, editorSelected​ : https://www.oxygenxml.com/InstData/Edit ... tener.html

Code: Select all

oxygenStandalonePluginWorkspace.addEditorChangeListener(new WSEditorChangeListener() {
      @Override
      public void editorAboutToBeOpened(URL editorLocation) {
      }
      @Override
      public void editorActivated(URL editorLocation) {
      }
      @Override
      public void editorOpened(URL editorLocation) {
      }
      @Override
      public void editorSelected(URL editorLocation) {
      }
    }, PluginWorkspace.DITA_MAPS_EDITING_AREA);
Regards,
Adrian S.
Adrian Sorop
<oXygen/> XML Editor
http://www.oxygenxml.com
Lordy
Posts: 8
Joined: Thu Aug 01, 2024 5:22 pm

Re: Change tabs title when Oxygen starts with opened files

Post by Lordy »

Hi Adrian, thanks for your answer.

Yes, we're using WSEditorChangeListener class to trigger the title change, to be more specific the editorOpened function. Something like this:

Code: Select all

@Override
public void editorOpened(URL url) {
	...
	WSEditor editorPage = oxygenStandalonePluginWorkspace.getEditorAccess(url, DITA_MAPS_EDITING_AREA);
	String openedFileTitle = myOwnFunctionToGetTheFileTitle(url);
	editorPage.setEditorTabText(openedFileTitle);
	...
}
And it works fine, but if I close and open Oxygen with opened files, it only updates the current file.

Even if I try to bring all the files, it only gets the current file, omitting the other opened files until I click on them.

Code: Select all

public void editorOpened(URL url) {
	...
	URL[] urls = oxygenStandalonePluginWorkspace.getAllEditorLocations(DITA_MAPS_EDITING_AREA); // Here Oxygen only brings one file, no matter if there are more
	for(URL currentUrl : urls) {
		WSEditor editorPage = oxygenStandalonePluginWorkspace.getEditorAccess(currentUrl , DITA_MAPS_EDITING_AREA);
		String openedFileTitle = myOwnFunctionToGetTheFileTitle(currentUrl);
		editorPage.setEditorTabText(openedFileTitle);
	}
	...
}
I think is because Oxygen doesn't load all the files when it starts
adrian_sorop
Posts: 78
Joined: Wed Jun 22, 2016 2:48 pm

Re: Change tabs title when Oxygen starts with opened files

Post by adrian_sorop »

Hi,
I undestand that now. Thanks for clarifying this.
// Here Oxygen only brings one file, no matter if there are more
oxygenStandalonePluginWorkspace.getAllEditorLocations(DITA_MAPS_EDITING_AREA);
[...]
I think is because Oxygen doesn't load all the files when it starts
You're right.
https://www.oxygenxml.com/InstData/Edit ... tions(int) returns only loaded editors.
I've added an internal issue to update the javadoc and the site documentation.
Unfortunatelly, there's nothig you can do to change the tab titles if the editors are not loaded.
Regards,
Adrian S.
Adrian Sorop
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply