Set GRID page not editable
Post here questions and problems related to oXygen frameworks/document types.
-
- Posts: 124
- Joined: Tue May 29, 2012 5:42 pm
Set GRID page not editable
Post by sebastienlavandier »
Hello,
I want to know how I must cast the editorAccess.getCurrentPage() to set grid page not editable ?
Thanks in advance for your help.
Sébastien.L
I want to know how I must cast the editorAccess.getCurrentPage() to set grid page not editable ?
Code: Select all
if (url != null) {
final boolean isEditable = EditorTabsMap.getInstance().get(url).isEditable();
WSEditor editorAccess = pluginWorkspaceAccess.getEditorAccess(url, PluginWorkspace.MAIN_EDITING_AREA);
if (editorAccess != null) {
if (EditorPageConstants.PAGE_AUTHOR.equals(editorAccess.getCurrentPageID())) {
((WSAuthorEditorPage) editorAccess.getCurrentPage()).setEditable(isEditable);
} else if (EditorPageConstants.PAGE_TEXT.equals(editorAccess.getCurrentPageID())) {
((WSTextEditorPage) editorAccess.getCurrentPage()).setEditable(isEditable);
} else if (EditorPageConstants.PAGE_GRID.equals(editorAccess.getCurrentPageID())) {
?????
}
}
}
Sébastien.L
-
- Posts: 1008
- Joined: Wed Nov 16, 2005 11:11 am
Re: Set GRID page not editable
Post by alex_jitianu »
Hello,
Unfortunately the Grid page doesn't have this API. If you don't really need the Grid page, as a workaround, you could stop the author going into it by using one of the following approaches:
1. by using an WSEditorChangeListener you can listen for page change events. When the active page is the grid page you can automatically switch to another page (by calling WSEditor.changePage(String)).
2. you can look inside the components hierarchy and identify and disable the button that switches to Grid page. Is not really API but it should work. The code below does this but you will also have to handle the case when the user is in the text page (and start the search from ro.sync.exml.workspace.api.editor.page.text.WSTextEditorPage.getTextComponent()) or in the grid page (and switch to a different page)
Best regards,
Alex
Unfortunately the Grid page doesn't have this API. If you don't really need the Grid page, as a workaround, you could stop the author going into it by using one of the following approaches:
1. by using an WSEditorChangeListener you can listen for page change events. When the active page is the grid page you can automatically switch to another page (by calling WSEditor.changePage(String)).
2. you can look inside the components hierarchy and identify and disable the button that switches to Grid page. Is not really API but it should work. The code below does this but you will also have to handle the case when the user is in the text page (and start the search from ro.sync.exml.workspace.api.editor.page.text.WSTextEditorPage.getTextComponent()) or in the grid page (and switch to a different page)
Code: Select all
if (EditorPageConstants.PAGE_GRID.equals(editorAccess.getCurrentPageID())) {
WSEditorPage currentPage = editorAccess.getCurrentPage();
if (currentPage instanceof WSAuthorEditorPage) {
final WSAuthorEditorPage authorEditorPage = (WSAuthorEditorPage) currentPage;
JComponent comp = (JComponent) authorEditorPage.getAuthorComponent();
AbstractButton pageSwitchButton = getPageSwitchButton(comp, "Grid");
pageSwitchButton.setEnabled(false);
}
}
private AbstractButton getPageSwitchButton(Container component, String text) {
AbstractButton toReturn = null;
Container parent = component.getParent();
int componentCount = parent.getComponentCount();
for (int i = 0; i < componentCount; i++) {
Component candidate = parent.getComponent(i);
if (candidate != component) {
toReturn = goDeep(candidate, text);
if (toReturn != null) {
break;
}
}
}
if (toReturn == null) {
toReturn = getPageSwitchButton(parent, text);
}
return toReturn;
}
private AbstractButton goDeep(Component candidate, String text) {
AbstractButton toReturn = null;
if (candidate instanceof AbstractButton && text.equals(((AbstractButton) candidate).getText())) {
toReturn = (AbstractButton) candidate;
} else if (candidate instanceof JComponent) {
int componentCount = ((JComponent) candidate).getComponentCount();
for (int i = 0; i < componentCount; i++) {
toReturn = goDeep(((JComponent) candidate).getComponent(i), text);
if (toReturn != null) {
break;
}
}
}
return toReturn;
}
Alex
-
- Posts: 124
- Joined: Tue May 29, 2012 5:42 pm
Re: Set GRID page not editable
Post by sebastienlavandier »
It works.
It's a solution.
Thanks for you your help.
Sébastien.L
It's a solution.
Thanks for you your help.
Sébastien.L
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