The content controller needs to be
associated with an SDM engine and a handler.
Using the content on demand feature
involves the following steps:
To use the content on demand feature:
-
Associate the content controller with the SDM engine and the handler.
_controller = new IlvContentController(); _controller.setSDMEngine(diagrammer.getEngine()); _controller.setContentHandler(new ContentHandler()); private class ContentHandler extends IlvContentHandler() { // here we load/unload objects private void loadObject(Object node, boolean load) { if (load) { model.setObjectProperty(node, CONTENT, ...); } else { // unload values model.setObjectProperty(node, CONTENT, null); } } // callback for loading content public void loadContent(IlvContentController source, Object[] objects) { // prevent too much notifications diagrammer.setAdjusting(true); // loop over objects to load for (int i=0; i<objects.length; i++) { loadObject(objects[i], true); } diagrammer.setAdjusting(false); } // callback for unloading content public void unloadContent(IlvContentController source, Object[] objects) { diagrammer.setAdjusting(true); for (int i=0; i<objects.length; i++) { loadObject(objects[i], false); } diagrammer.setAdjusting(false); } } }
-
Optionally, change the cache value using the
setCacheSize(int size)
method.You can adjust the cache size according to the desired behavior. The default value is infinite, which means that all loaded content is never unloaded._controller.setCacheSize(1024);
-
Install a view listener that will send requests to the controller.
IlvVisibleAreaListener l = new IlvVisibleAreaListener(contentControler); l.installListener(contentControler.getSDMEngine().getReferenceView());
-
Now navigate in the view to automatically load or unload objects.