Elements Side Panel how to disable/enable (not hide)

Post here questions and problems related to oXygen frameworks/document types.
MikeH
Posts: 5
Joined: Tue Apr 19, 2022 1:28 pm

Elements Side Panel how to disable/enable (not hide)

Post by MikeH »

When the caret is inside an element the Elements side panel displays the correct list of possible elements.
But when the element is selected, the Elements side panel displays the possible elements for the element's parent - probably this is technically correct, but it is not intuitive for our users. This same issue applied to the context menu for inserting elements.

We have our framework set up to not allow insertion of invalid XML, but despite that I can (via the Elements side panel) insert XML that is immediately detected by Oxygen as invalid. It looks like the Surround with context menu is not following out schema, and neither does the Elements panel when there is a selection.

As a fix, I would like to detect whenever their is a selection in the document and disable the Elements side panel and block the elements context menu. I think I can create a plugin to listen and detect whenever there is a selection in the document, but I don't know how to disable the panel or block the context menu.

Example of issue:
In current doc, select a <listitem>, the Elements panel allows me to insert another <listitem> (it wraps around the selected <listitem>). This is against our schema and is immediately detected by Oxygen as invalid.
alex_jitianu
Posts: 1009
Joined: Wed Nov 16, 2005 11:11 am

Re: Elements Side Panel how to disable/enable (not hide)

Post by alex_jitianu »

Hello,

1. First of all, you need to intercept the view through a ViewComponentCustomizer. The ViewInfo.getComponent() will give you the main component and afterwards you can recursively iterate its hierarchy (using getComponents()) and enable/disable them using setEnabled().

2. To listen for selection events, you can use an caret listener. When an event is detected, you can check if it's a selection using the selection model. Depending on detecting a selection or not, you use the JComponent obtained at step 1. to enable/diable the entire view.

The sample-plugin-workspace-access project can be used as a starting point for an Oxygen plugin.

Best regards,
Alex
Post Reply