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

Having trouble installing Oxygen? Got a bug to report? Post it all here.
SmitaPatil
Posts: 93
Joined: Mon Aug 08, 2022 2:32 pm

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

Post 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
mihaela
Posts: 515
Joined: Wed May 20, 2009 2:40 pm

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

Post 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).
Mihaela Calotescu
http://www.oxygenxml.com
mihaela
Posts: 515
Joined: Wed May 20, 2009 2:40 pm

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

Post 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
Mihaela Calotescu
http://www.oxygenxml.com
SmitaPatil
Posts: 93
Joined: Mon Aug 08, 2022 2:32 pm

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

Post 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
You do not have the required permissions to view the files attached to this post.
mihaela
Posts: 515
Joined: Wed May 20, 2009 2:40 pm

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

Post 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?
Mihaela Calotescu
http://www.oxygenxml.com
SmitaPatil
Posts: 93
Joined: Mon Aug 08, 2022 2:32 pm

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

Post 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
You do not have the required permissions to view the files attached to this post.
chrispitude
Posts: 922
Joined: Thu May 02, 2019 2:32 pm

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

Post 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.
You do not have the required permissions to view the files attached to this post.
mihaela
Posts: 515
Joined: Wed May 20, 2009 2:40 pm

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

Post 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
Mihaela Calotescu
http://www.oxygenxml.com
Post Reply