Getting Resource from ISymbolItem 32/3832/2
authorMarko Luukkainen <marko.luukkainen@semantum.fi>
Wed, 5 Feb 2020 16:05:30 +0000 (18:05 +0200)
committerMarko Luukkainen <marko.luukkainen@semantum.fi>
Wed, 5 Feb 2020 16:07:31 +0000 (16:07 +0000)
gitlab #460

Change-Id: Ic2eeaf432b974da2094d72794267387dcf7e9562

bundles/org.simantics.diagram/scl/Simantics/Diagram/SymbolLibrary.scl
bundles/org.simantics.diagram/src/org/simantics/diagram/scl/SymbolLibrary.java

index 78be7a1dee64600f77b94ba0e5f622822ff3d225..ce97a9349b4910cc24eb6a76f47eebbd5c40a5bc 100644 (file)
@@ -44,4 +44,6 @@ importJava "org.simantics.diagram.symbolcontribution.IndexRootSymbolProviderFact
 importJava "org.simantics.diagram.scl.SymbolLibrary" where
   
   @JavaName create
-  itemToContext :: ISymbolItem -> <Proc> ICanvasContext
\ No newline at end of file
+  itemToContext :: ISymbolItem -> <Proc> ICanvasContext
+  
+  getItemResource :: ISymbolItem -> <Proc> Resource
\ No newline at end of file
index 6820cad0824d264a364c9e09c3d83d3cae6bc229..9ab2bcd6ce3497ed6ae339e485ab87531d383437 100644 (file)
@@ -2,6 +2,7 @@ package org.simantics.diagram.scl;
 
 import java.awt.Color;
 
+import org.simantics.db.Resource;
 import org.simantics.diagram.symbollibrary.ISymbolItem;
 import org.simantics.g2d.canvas.Hints;
 import org.simantics.g2d.canvas.ICanvasContext;
@@ -52,15 +53,22 @@ public class SymbolLibrary {
         ElementClass ec = item.getElementClass(diagram);
         StaticSymbol ss = ec.getSingleItem(StaticSymbol.class);
         Image source = ss == null ? DefaultImages.UNKNOWN2.get() : ss.getImage();
+        //ImageProxy proxy = new ImageProxy(source);
         
         IElement element = Element.spawnNew(ec);
         element.setHint(ElementHints.KEY_OBJECT, item);
         element.setHint(GalleryItemSGNode.KEY_IMAGE, source);
         diagram.addElement(element);
         
+        //element.getElementClass().getSingleItem(GalleryItemSGNode.class).update(element);
+        
         return ctx;
        }
        
+       public static Resource getItemResource(ISymbolItem item) {
+               return item.getAdapter(Resource.class);
+       }
+       
         private static void initializeCanvasContext(final CanvasContext canvasContext) {
                // Create canvas context and a layer of interactors
                final IHintContext h = canvasContext.getDefaultHintContext();