7 Replies Latest reply on Mar 10, 2009 4:36 AM by sdzmitrovich

    Editing in visual pane

    kukeltje

      For the html elements, you can edit the values of elements in the visual pane. I've been trying to achieve the same for some of my elements (mainly on, a label).

      Changing the children attribute on the template, the modify, textformatting etc, but to no avail. I've been searching in the source as well, but could not find specific things I should do. Any hints? I do not need full examples, just a pointer to something in the source of other editors

        • 1. Re: Editing in visual pane
          mareshkau

          The simplest example it's editing just a text, you can see HtmlTextTemplate class.
          In this class exist such lines
          VpeElementData textElementData = new VpeElementData();
          //here we create mapping for editing between source and visual elements.
          NodeData nodeData = new NodeData(sourceNode, visualNewTextNode);
          textElementData.addNodeData(nodeData);
          Another example AbstractOutputJsfTemplate, line 105.

          • 2. Re: Editing in visual pane
            kukeltje

            tnx, will look into that

            • 3. Re: Editing in visual pane
              kukeltje

              Ok, it works partially now

              
               public VpeCreationData create(VpePageContext pageContext, Node sourceNode, nsIDOMDocument visualDocument) {
               VpeCreationData creationData = null;
               Element sourceElement = (Element) sourceNode;
               readAttributes(sourceElement);
               nsIDOMElement label;
              
               label = visualDocument.createElement(HTML.TAG_LABEL);
               label.setAttribute(HTML.ATTR_STYLE, style);
               label.setAttribute(HTML.ATTR_CLASS, styleClass);
              
               creationData = new VpeCreationData(label);
              
               Node textChild = sourceElement.getFirstChild();
               if (textChild != null) {
              
               VpeElementData elementData = new VpeElementData();
               nsIDOMText text;
               boolean isEditable = true;
              
               text = visualDocument.createTextNode(textChild.getNodeValue());
              
               label.appendChild(text);
               elementData.addNodeData(new NodeData(textChild, label, isEditable));
               creationData.setElementData(elementData);
               }
              
               return creationData;
              


              makes it possible to edit the data inline at least at the place you click. You cannot go left or right with the cursors.

              I'll try to look into this, but any hints would be appreciated

              • 4. Re: Editing in visual pane
                kukeltje

                hmm... ctrl-left and ctrl-right seem to work. Think I have to do something with keybindings... Besides that, If I select the 'label' element in the visual pane, the corresponding xml element in the source is not selected anymore. Think I have to digg a little into the existing jsf/richfaces code again....

                Still.... hints are welcome :-)

                • 5. Re: Editing in visual pane

                  May be It is because you has described label's template as children="no" and label's template add children itself. Try to set children="yes" and not add children by label's template. Look org.jboss.tools.jsf.vpe.jsf.template.JsfOutputLabelTemplate

                  • 6. Re: Editing in visual pane

                    Sorry ... org.jboss.tools.jsf.vpe.jsf.template.JsfOutputLabelTemplate is bad example :)

                    • 7. Re: Editing in visual pane

                      In fact ... Source selection is right in your case :)
                      If an element is "editable" then behavior of selection is changed.
                      In this case cursor just is set to necessary position. But so as focus is not on source part it looks like as selection is not set.