Page 1 of 1

How to get list of elements with which we can rename selected element and how to rename element

Posted: Thu Aug 25, 2022 11:17 am
by SmitaPatil
Hi Team,
Currently we know public String doOperation(AuthorDocumentModel model, ArgumentsMap args) method using which we can get access to the document and its element and data, but is there any other method which has access to document with return type as list.
My requirement is :
I want to get list of elements using which we can rename selected element (or where the cursor is placed) in document and also I want to rename the element.
I saw ElementRename method in framework so I am hoping there may be a inbuilt method to rename element in document.
Can you please suggest way or any inbuilt method of oxygen to do this?

Thanks,
Smita

Re: How to get list of elements with which we can rename selected element and how to rename element

Posted: Thu Aug 25, 2022 1:12 pm
by mihaela
There is a specific operation available for renaming elements, that you can use: ro.sync.ecss.extensions.commons.operations.RenameElementOperation.

To get the list of available elements at caret position, you can use the following API: ro.sync.ecss.extensions.api.AuthorSchemaManager.whatElementsCanGoHere(WhatElementsCanGoHereContext).
To create the context to be passed to the previous mentioned method, use the ro.sync.ecss.extensions.api.AuthorSchemaManager.createWhatElementsCanGoHereContext(int) API.

If you need more details please let us know, specifying also the product that you are using (Oxygen XML Editor or Web Author).

Re: How to get list of elements with which we can rename selected element and how to rename element

Posted: Fri Aug 26, 2022 11:07 am
by mihaela
Hello,
There is a "Rename Element" action in the contextual menu (in both Oxygen XML Editor and Web Author products) that presents a list of all elements available at caret position and you can choose one of them to rename the current element.
In order to help you with more information can you please explain what is your use-case? What do you want to obtain different than the current rename behavior?

Best regards,
Mihaela

Re: How to get list of elements with which we can rename selected element and how to rename element

Posted: Tue Aug 30, 2022 11:18 am
by SmitaPatil
Hi,
We want give popup to attribute as well.
I tried to implement the method which you suggested to get the set of elements using which we can rename the element in which cursor is placed,
but irrespective of cursor position I am getting same set of elements every time. Just want to check if there is something wrong.
implementation of method as shown below
image.png
calling of method
image.png
Can you please check let me know if there is anything missing while using this method.

Thanks,
Smita

Re: How to get list of elements with which we can rename selected element and how to rename element

Posted: Tue Aug 30, 2022 2:56 pm
by mihaela
Hello,
We want give popup to attribute as well.
Sorry, I don't understand what you are trying to obtain (different than the default rename operation).
Can you please check let me know if there is anything missing while using this method.
The code from the first image should give you the list of elements that are valid at the caret possition. I don't know why you otain the same elements, regardless of the offset. What type of documents are you using? Do you have a custom framework, a custom schema?

Re: How to get list of elements with which we can rename selected element and how to rename element

Posted: Thu Sep 01, 2022 12:42 pm
by SmitaPatil
Hi,
I am using xml document and below is the screenshot of list of elements which I am getting separated by "+"
image.png
is there any parameter we need to pass to get the valid elements which we can use to rename element in which cursor is present.
I have seen following are some parameter which we need to pass . Can you please tell if inbuilt methods are there to get this values using caretoffset ?
parentElementName the qName of the parent element
previousElementNames the list of qNames of the previous elements
previousElementNamespaces the list of qNames of the previous elements
proxyNamespaceMapping the proxy - uri mappings defined before the insertion point.


Thanks,
Smita

Re: How to get list of elements with which we can rename selected element and how to rename element

Posted: Thu Sep 01, 2022 3:47 pm
by chrispitude
Hi Smita,

Note that you can rename an element simply by selecting the opening tag, then pressing Enter:

oxygen_element_rename.gif

If you are trying to make element renaming easier for your writers, this might save you some effort.

Re: How to get list of elements with which we can rename selected element and how to rename element

Posted: Fri Sep 02, 2022 11:39 am
by mihaela
Hi Smita,

If you use the ro.sync.ecss.extensions.api.AuthorSchemaManager.createWhatElementsCanGoHereContext(int) API, you will obtain the context that you need to find the valid elements that can be inserted at caret position (there is no need to provide any of the parameters that you listed).

From your screenshot I see that you are using custom elements, so in order to help you we need to find more about your customization.
If you want, you can write to us at contact@oxygenxml.com and provide the schema that you use for your documents, to see if the problem that you encounter is related to it. Also, any other information about your customization or use case would be helpful.

Best regards,
Mihaela