Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "JFace Data Binding/SSE"

(JFace DOM-SSE Databinding)
(JFace DOM-SSE Databinding)
Line 16: Line 16:
 
== JFace DOM-SSE Databinding ==  
 
== JFace DOM-SSE Databinding ==  
  
Before explain the features of <b>JFace DOM-SSE Databinding</b>, if you don't know DOM-SSE, I adwice you to read the section [[#What is DOM-SSE?]]
+
Before explaining features of <b>JFace DOM-SSE Databinding</b>, if you don't know DOM-SSE, I adwice you to read the section [[#What is DOM-SSE?]]
  
 
=== JFace DOM-SSE Databinding ===
 
=== JFace DOM-SSE Databinding ===
Line 50: Line 50:
 
</ul>
 
</ul>
  
INodeNotifier provide the capability to add org.eclipse.wst.sse.core.internal.provisional.<b>INodeAdapter</b> to add event listener and observe the change of the node.
+
DOM-SSE can be observed by using :
 +
 
 +
<ul>
 +
  <li>IDOMModel#<b>addModelStateListener(IModelStateListener listener)</b> : as soon as DOM-SSE is updated (add/remove/update any Nodes), you can use IModelStateListener#modelChanged(IStructuredModel model) to detect that :
 +
 
 +
<pre>IDOModel model = ...
 +
model.addModelStateListener(new IModelStateListener(){
 +
  ...
 +
  public void modelChanged(IStructuredModel model) {
 +
 +
  }
 +
});</pre>
 +
 
 +
  <li>org.eclipse.wst.sse.core.internal.provisional.<b>INodeNotifier</b> provide the capability to add org.eclipse.wst.sse.core.internal.provisional.<b>INodeAdapter</b> to add event listener and observe the change of the node.
  
 
<pre>
 
<pre>
Line 66: Line 79:
 
   }
 
   }
 
});</pre>
 
});</pre>
 
+
</li>
DOM-SSE can be observed by using :
+
 
+
<ul>
+
  <li>IDOMModel#<b>addModelStateListener(IModelStateListener listener)</b> : as soon as DOM-SSE is updated (add/remove/update any Nodes), you can use IModelStateListener#modelChanged(IStructuredModel model) to detect that :
+
 
+
<pre>IDOModel model = ...
+
model.addModelStateListener(new IModelStateListener(){
+
  ...
+
  public void modelChanged(IStructuredModel model) {
+
+
  }
+
});</pre>
+
  
 
</li>
 
</li>
 
</ul>
 
</ul>

Revision as of 13:07, 13 March 2009

Target

Project Structured Source Editing (SSE) which is sub-project of WTP provides the capability to manage structured document (like DOM XML, CSS document..).

Target of JFace Data Binding/SSE is to support bindings with SSE nodes (DOM, CSS...). Today sources of this project are not available because we are discussing with Eclipse Team to see where we can put this project. This project can be used for instance when you wish manage XML content with an UI editor like :

  • PDE which manage plugin.xml with an UI (Extensions page).
  • JSF Web Tools which manage faces-config.xml with an UI.


Into JFace Data Binding/SSE sample you can find a Shapes Editor which manage XML content. Here you can see that SWT Text title UI is bounded with title attribute of diagram element :

ShapesDOMSSEEditor.png

JFace DOM-SSE Databinding

Before explaining features of JFace DOM-SSE Databinding, if you don't know DOM-SSE, I adwice you to read the section #What is DOM-SSE?

JFace DOM-SSE Databinding

This project provides the capability to manage binding with DOM-SSE nodes (IDOMNode). It is based on JFace DOM Databinding. Why having JFace DOM-SSE Databinding although JFace DOM Databinding manage DOM bindings.? The answer is :

  • DOM event listener problem.
  • Instance node problem.

What is DOM-SSE?

DOM-SSE is W3c DOM Document comming from IFile or TextEditor. XML Editor from WTP which is based on StructuredTextEditor manage internally DOM-SSE. The DOM-SSE is updated as soon as user type XML content. DOM-SSE is getted from WST IDOMModel like this :

IFile file = ... 
IModelManager manager = StructuredModelManager.getModelManager(); 
IDOMModel model = (IDOMModel)manager.getExistingModelForRead(file); 
if (model == null) { 
  model = manager.getModelForRead(file); 
} 

Document document = model.getDocument();

Each Nodes of DOM Document implements org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode interface which extends :

  • W3C org.w3c.dom.Node.
  • org.eclipse.wst.sse.core.internal.provisional.INodeNotifier.

DOM-SSE can be observed by using :

  • IDOMModel#addModelStateListener(IModelStateListener listener) : as soon as DOM-SSE is updated (add/remove/update any Nodes), you can use IModelStateListener#modelChanged(IStructuredModel model) to detect that :
    IDOModel model = ...
    model.addModelStateListener(new IModelStateListener(){
      ...
      public void modelChanged(IStructuredModel model) {
    	
      }
    });
  • org.eclipse.wst.sse.core.internal.provisional.INodeNotifier provide the capability to add org.eclipse.wst.sse.core.internal.provisional.INodeAdapter to add event listener and observe the change of the node.
    IDOMElement element = ...
    element.addAdapter(new INodeAdapter() {
      public boolean isAdapterForType(Object type) {
        return true;
      }
      public void notifyChanged(INodeNotifier notifier, int eventType,
        Object changedFeature, Object oldValue, Object newValue, int pos) {
        
        // Element has changed (attribute changed, ...)
        // Do something
    				
      }
    });

Back to the top