Content Completion > Surround With not schema aware

Post here questions and problems related to oXygen frameworks/document types.
Isabelle
Posts: 142
Joined: Fri Jan 20, 2017 1:11 pm

Content Completion > Surround With not schema aware

Post by Isabelle »

Hello,

We use the version 24.0.0.2 of the SDK.
In Author view, when an element is selected, the content completion (obtained by pressing Enter key) provide the Surround with pop up.
The problem is that this pop up is not schema aware.
Each time you select an element from this pop-up, it surround well but the xml is not valid anymore.

Can we configure this Surround with pop up ?
If yes, how ? I did not find any documentation.

Regards,
Isabelle
Radu
Posts: 9057
Joined: Fri Jul 09, 2004 5:18 pm

Re: Content Completion > Surround With not schema aware

Post by Radu »

Hello Isabelle,

We have an internal issue to enhance the "surround with" functionality, I added your feedback to it and if we manage to implement it in a future version we'll let you know.
We have this API to set an author document filter and from what I looked in our code you should receive a callback in the filter after the end user chose the element to surround with and pressed enter:

Code: Select all

    authorDocumentController.setDocumentFilter(new AuthorDocumentFilter() {
      /**
       * @see ro.sync.ecss.extensions.api.AuthorDocumentFilter#surroundInFragment(ro.sync.ecss.extensions.api.AuthorDocumentFilterBypass, ro.sync.ecss.extensions.api.node.AuthorDocumentFragment, int, int)
       */
      @Override
      public void surroundInFragment(AuthorDocumentFilterBypass filterBypass,
          AuthorDocumentFragment xmlFragment, int startOffset, int endOffset)
          throws AuthorOperationException {
        //You should receive a callback here
        super.surroundInFragment(filterBypass, xmlFragment, startOffset, endOffset);
      }
    });
Maybe you can take a decision not to perform the surround in certain cases by avoiding to call super.surroundInFragment.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Isabelle
Posts: 142
Joined: Fri Jan 20, 2017 1:11 pm

Re: Content Completion > Surround With not schema aware

Post by Isabelle »

Hello Radu,

Thank you for your feedback.
Is it possible to not show this pop up in the Author view, when user select something and press Enter key ?
I think, it would be more user friendly.
User will not understand why select element in this pop up do nothing or why this pop up exist if it never works.

Thank you
Regards,
Isabelle
Radu
Posts: 9057
Joined: Fri Jul 09, 2004 5:18 pm

Re: Content Completion > Surround With not schema aware

Post by Radu »

Hi Isabelle,

About this question:
Is it possible to not show this pop up in the Author view, when user select something and press Enter key ?
I don't know, when in the framework configuration you define an Author action, you can bind it to the "ENTER" shortcut, meaning your action should be called when the end user will press ENTER in the editing area. But this would mean that your action will get called no matter if there is or not selection in the editing area, which is not something that you want.
Another workaround which might work would be for you to add a key listener to the Swing component on which we render the Author visual editing mode and when your key listener is called (and it is called before we interpret the event) to consume the event in certain cases, like:

Code: Select all

    ((JComponent)authorAccess.getEditorAccess().getAuthorComponent()).addKeyListener(new KeyAdapter() {
      /**
       * @see java.awt.event.KeyAdapter#keyPressed(java.awt.event.KeyEvent)
       */
      @Override
      public void keyPressed(KeyEvent e) {
        if(e.getKeyCode() == KeyEvent.VK_ENTER && authorAccess.getEditorAccess().hasSelection()) {
          e.consume();
        }
      }
    });
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Radu
Posts: 9057
Joined: Fri Jul 09, 2004 5:18 pm

Re: Content Completion > Surround With not schema aware

Post by Radu »

Hi,

As an update we just released Oxygen 25 (and its corresponding SDK) which it should no longer propose invalid elements when using "Surround With".

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply