Plugin API: force Oxygen to open a file in the archive browser
Post here questions and problems related to oXygen frameworks/document types.
Plugin API: force Oxygen to open a file in the archive browser
Hi Oxygen team,
I hope you are all fine and you had a good start in the new year!
I'm currently trying to implement for an Oxygen plugin an option to open an archive that has a custrom file extension (which is not in the default list of known archive file extensions). Currently I do it this way:
This works fine, but at the first time it shows the message: "Unknown archive extension 'ocf'. Do you want to map this extension to an archive type?" If the user chooses "Yes" the archive preference page opens and the extension was added to the list. After submitting the file is opened in the archive browser. But in case of "No" Oxygen tries to open the archive as text in the main area.
I think we can live with this, but the dialogs are maybe a bit surprising for the user. It would be a great enhancement if there is a way to force the Oxygen to open the file in the archive browser without this dialogs (e.g. ignoring un/known file extensions). Is there a way to do this?
An alternative would be to add the extension to the list of known archive types in the background. But I'm not sure how to do that. I think it should be possible by using the ro.sync.exml.workspace.api.options.WSOptionsStorage but I don't not know what option keys I have to use.
Do you have any hint for me, how I could achieve one of the alternatives?
Best Regards,
Nico
I hope you are all fine and you had a good start in the new year!
I'm currently trying to implement for an Oxygen plugin an option to open an archive that has a custrom file extension (which is not in the default list of known archive file extensions). Currently I do it this way:
Code: Select all
spw.open(url, EditorPageConstants.PAGE_UNKNOWN, "application/zip");
I think we can live with this, but the dialogs are maybe a bit surprising for the user. It would be a great enhancement if there is a way to force the Oxygen to open the file in the archive browser without this dialogs (e.g. ignoring un/known file extensions). Is there a way to do this?
An alternative would be to add the extension to the list of known archive types in the background. But I'm not sure how to do that. I think it should be possible by using the ro.sync.exml.workspace.api.options.WSOptionsStorage but I don't not know what option keys I have to use.
Do you have any hint for me, how I could achieve one of the alternatives?
Best Regards,
Nico
Re: Plugin API: force Oxygen to open a file in the archive browser
Hello Nico,
Looking at our code, I do not see a way in which that dialog could be avoided unless the Preferences->"Archive" page has an entry for your custom archive extension.
The WSOptionsStorage is a way to store/retrieve your own key/value pairs without interfering with Oxygen's preferences.
We do have another global options storage through which you could influence the global options.
The code would look something like this:
but from what I tested it would take effect on the second time you start Oxygen.
Regards,
Radu
Looking at our code, I do not see a way in which that dialog could be avoided unless the Preferences->"Archive" page has an entry for your custom archive extension.
The WSOptionsStorage is a way to store/retrieve your own key/value pairs without interfering with Oxygen's preferences.
We do have another global options storage through which you could influence the global options.
The code would look something like this:
Code: Select all
@Override
public void applicationStarted(StandalonePluginWorkspace pluginWorkspaceAccess) {
ro.sync.exml.zip.ArchiveDescriptor[] archiveDescriptors = (ArchiveDescriptor[]) pluginWorkspaceAccess.getGlobalObjectProperty(APIAccessibleOptionTags.ARCHIVE_DESCRIPTORS);
boolean addExtra = true;
for (int i = 0; i < archiveDescriptors.length; i++) {
String[] extensions = archiveDescriptors[i].getExtensions();
if(Arrays.toString(extensions).contains("zup")) {
addExtra = false;
break;
}
}
if(addExtra) {
List<ArchiveDescriptor> newDescriptors = new ArrayList<>(Arrays.asList(archiveDescriptors));
newDescriptors.add(new ArchiveDescriptor("zup descr", new String[] {"zup"}, ArchiveDescriptor.ARCHIVE_TYPE_ZIP));
pluginWorkspaceAccess.setGlobalObjectProperty(APIAccessibleOptionTags.ARCHIVE_DESCRIPTORS, newDescriptors.toArray(new ArchiveDescriptor[0]));
}
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
Re: Plugin API: force Oxygen to open a file in the archive browser
Thanks, Radu! I will try this out.
It just comes to my mind: The GlobalOptionsStorage.setGlobalObjectProperty() points to the global preferences of Oxygen. If the user has open a project which overwrites this settings it has no effect, right?
Well, I can try that out as well...
It just comes to my mind: The GlobalOptionsStorage.setGlobalObjectProperty() points to the global preferences of Oxygen. If the user has open a project which overwrites this settings it has no effect, right?
Well, I can try that out as well...
Re: Plugin API: force Oxygen to open a file in the archive browser
Hi,
The project level options come as a layer over the global options.
From what I think if that particular Preferences->"Archive" page would be switched to "Project options", then using the API will change the setting directly in the project xpr options so that would still work.
Regards,
Radu
The project level options come as a layer over the global options.
From what I think if that particular Preferences->"Archive" page would be switched to "Project options", then using the API will change the setting directly in the project xpr options so that would still work.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
Return to “SDK-API, Frameworks - Document Types”
Jump to
- 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