Disabling editing within the editor??
Post here questions and problems related to oXygen frameworks/document types.
-
- Posts: 269
- Joined: Sat Jul 10, 2010 4:03 pm
Disabling editing within the editor??
I'm setting up the applet to have a tabbed interface. Enabling the user to open multiple documents at the same time. Each tab has its own editor instance. This is working fine.
Some of the documents the user can open are for reference only and should not be edited. I can of course not allow them to be saved but it would be more user friendly and understandable to the user if the editor refused any attempt to change the text in these "read-only" documents.
I tried
where I instantiate the editor and set it up for insertion into a jTabbedPane, but this doesn't seem to have any effect?
what am I doing wrong?
Scott
Some of the documents the user can open are for reference only and should not be edited. I can of course not allow them to be saved but it would be more user friendly and understandable to the user if the editor refused any attempt to change the text in these "read-only" documents.
I tried
Code: Select all
editor.setEnabled(false);
Code: Select all
mbepEditor editor = new mbepEditor(factory, true, true, true, true);
editor.setBorder(BorderFactory.createEmptyBorder(15, 0, 0, 0));
editor.setVisibleSideView("outline", true);
editor.setVisibleSideView("attributes", true);
editor.setVisibleSideView("elements", true);
editor.setVisibleSideView("review", false);
editor.setVisibleSideView("validationProblems", false);
editor.setDocumentContent(fullPath, content);
editor.setUserID(userID);
if(url.contains("working_files"))
editor.setEnabled(false);
Scott
-
- Posts: 9420
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Disabling editing within the editor??
Hi Scott,
In your case the mbepEditor is a kind of JPanel, right? Disabling a Swing JPanel does not disable all components inside it. And even if you would recursively disable all descendants, there would still be the toolbar actions which can make modifications to the document.
An opened editor EditorComponentProvider.getWSEditorAccess() can have multiple pages.
The Text and Author pages both implement the WSTextBasedEditorPage interface which has the method:
Regards,
Radu
In your case the mbepEditor is a kind of JPanel, right? Disabling a Swing JPanel does not disable all components inside it. And even if you would recursively disable all descendants, there would still be the toolbar actions which can make modifications to the document.
An opened editor EditorComponentProvider.getWSEditorAccess() can have multiple pages.
The Text and Author pages both implement the WSTextBasedEditorPage interface which has the method:
Code: Select all
/**
* Sets the specified flag to indicate whether or not this page should be editable.
*
* @param editable <code>true</code> if the page should be editable.
*
* @since 12.2
*/
public void setEditable(boolean editable);
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 269
- Joined: Sat Jul 10, 2010 4:03 pm
Re: Disabling editing within the editor??
Radu,
Hopefully I'm doing multiple editors correctly? I took this from the FAQ.
When I add a tab, or document to be edited, I create an mbepEditor which extends a JPane, this uses the views factory to create a editorComponentProvider
for each document. The mbepEditor is inserted into the JTabbedPane.
So each editorComponent edits a single document and the JTabbedPanet handles the tabs... Which I thought was what the FAQ hinted at?
Scott
Hopefully I'm doing multiple editors correctly? I took this from the FAQ.
I create a mbepTabbedView which extends a JPanel. This view has a final member of type AuthorComponentFactory,7, Does the XML Author component support multiple documents being open simultaneously? What are the licensing ramifications?
A single AuthorComponentFactory instance can create multiple EditorComponentProvider editors which can then be added and managed by the developer who is customizing the component in a Swing JTabbedPane. A single license (floating or user-based) is enough for this.
Code: Select all
factory = AuthorComponentFactory.getInstance();
Code: Select all
editorComponent = factory.createEditorComponentProvider(
new String[]{EditorPageConstants.PAGE_AUTHOR, EditorPageConstants.PAGE_TEXT},
// The page
EditorPageConstants.PAGE_TEXT);
So each editorComponent edits a single document and the JTabbedPanet handles the tabs... Which I thought was what the FAQ hinted at?
Scott
-
- Posts: 9420
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Disabling editing within the editor??
Hi Scott,
That looks OK. So after you load XML content in an editorComponent, you can call:
You should also add a page changed listener:
and again disable the selected page after the user changes from Text to Author or the other way around.
Regards,
Radu
That looks OK. So after you load XML content in an editorComponent, you can call:
Code: Select all
((WSTextBasedEditorPage)editorComponent.getWSEditorAccess().getCurrentPage()).setEditable(false);
Code: Select all
editorComponent.getWSEditorAccess().addPageChangedListener(pageChangedListener);
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 9420
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Disabling editing within the editor??
Hi Scott,
Ideally in one of our future version we'll update our API to add this method:
instead of having to disable editing in each editing page which is quite convoluted.
Regards,
Radu
Ideally in one of our future version we'll update our API to add this method:
Code: Select all
editorComponent.getWSEditorAccess().setEditable(false)
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 9420
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Disabling editing within the editor??
Hi,
Just to update this thread, Oxygen 18.0 should have that new API which disables editing in all editor pages that I previously discussed.
Regards,
Radu
Just to update this thread, Oxygen 18.0 should have that new API which disables editing in all editor pages that I previously discussed.
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