Customize delete keyboard button operation
Are you missing a feature? Request its implementation here.
-
- Posts: 4
- Joined: Thu Oct 05, 2023 8:18 am
Customize delete keyboard button operation
Post by Prateeksha_Dixit »
Hi,
I have added below code for customizing delete operation. The code is working fine in no tag panel view and achieving following scenarios.
But in partial tag panel or full tag panel if I am selecting any tag, it is getting deleted even if it is required element.
Please refer below screenshot having selected Title element through title tag. Even if this element is required this Title element will get deleted since I have selected it through Title tag.
I have added below code for customizing delete operation. The code is working fine in no tag panel view and achieving following scenarios.
- At cursor location it is checking if the element is required it is showing element can't be deleted.
- By selecting the element from outline panel and pressing delete button from keyboard, it is deleting element only if the element is not required.
But in partial tag panel or full tag panel if I am selecting any tag, it is getting deleted even if it is required element.
Code: Select all
public class CustomDeleteHandler implements AuthorSchemaAwareEditingHandler {
@Override
public AuthorDocumentFragment handleCreateDocumentFragment(int arg0, int arg1, int arg2, AuthorAccess authorAcess)
throws BadLocationException {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean handleDelete(int arg0, int arg1, AuthorAccess authorAccess, boolean arg3) throws InvalidEditException {
// TODO Auto-generated method stub
try {
int caretOffset = authorAccess.getEditorAccess().getCaretOffset();
AuthorElement nodeAtCaret = (AuthorElement) authorAccess.getEditorAccess().getFullySelectedNode();
if (nodeAtCaret == null) {
nodeAtCaret = (AuthorElement) authorAccess.getDocumentController().getNodeAtOffset(caretOffset);
}
if(authorAccess.getDocumentController().getAuthorSchemaManager().isRequiredElement(nodeAtCaret))
{
authorAccess.getWorkspaceAccess().showInformationMessage("Selected element can not be deleted");
return true;
}
} catch (BadLocationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
throw new InvalidEditException
(e.getMessage(), "Invalid Delete Operation: " + e.getMessage(), e, false);
}
authorAccess.getWorkspaceAccess().showInformationMessage("Selected element can be deleted");
return false;
}
image.png
You do not have the required permissions to view the files attached to this post.
-
- Posts: 515
- Joined: Wed May 20, 2009 2:40 pm
Re: Customize delete keyboard button operation
Hello,
There are 4 handle delete methods in ro.sync.ecss.extensions.api.AuthorSchemaAwareEditingHandler API. You should implement each one and add your delete restriction code. It is possible that when you delete the node in the second case, another delete method to be called than the one you already implemented.
Best Regards,
Mihaela
There are 4 handle delete methods in ro.sync.ecss.extensions.api.AuthorSchemaAwareEditingHandler API. You should implement each one and add your delete restriction code. It is possible that when you delete the node in the second case, another delete method to be called than the one you already implemented.
Best Regards,
Mihaela
Mihaela Calotescu
http://www.oxygenxml.com
http://www.oxygenxml.com
-
- Posts: 4
- Joined: Thu Oct 05, 2023 8:18 am
Re: Customize delete keyboard button operation
Post by Prateeksha_Dixit »
Thanks Mihaela!!
I'll implement each of the methods as in when required and will see if this gets resolved.
Thanks in advance!!
I'll implement each of the methods as in when required and will see if this gets resolved.
Thanks in advance!!
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