From 2e34f75b1cbb8097431300f5554dcee3c0b2dabc Mon Sep 17 00:00:00 2001 From: Marko Luukkainen Date: Wed, 5 Feb 2020 18:05:30 +0200 Subject: [PATCH] Getting Resource from ISymbolItem gitlab #460 Change-Id: Ic2eeaf432b974da2094d72794267387dcf7e9562 (cherry picked from commit c6c9e6d7e07a43d1693869163cca19f3ce5fb5f0) --- .../scl/Simantics/Diagram/SymbolLibrary.scl | 4 +++- .../src/org/simantics/diagram/scl/SymbolLibrary.java | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/bundles/org.simantics.diagram/scl/Simantics/Diagram/SymbolLibrary.scl b/bundles/org.simantics.diagram/scl/Simantics/Diagram/SymbolLibrary.scl index 78be7a1de..ce97a9349 100644 --- a/bundles/org.simantics.diagram/scl/Simantics/Diagram/SymbolLibrary.scl +++ b/bundles/org.simantics.diagram/scl/Simantics/Diagram/SymbolLibrary.scl @@ -44,4 +44,6 @@ importJava "org.simantics.diagram.symbolcontribution.IndexRootSymbolProviderFact importJava "org.simantics.diagram.scl.SymbolLibrary" where @JavaName create - itemToContext :: ISymbolItem -> ICanvasContext \ No newline at end of file + itemToContext :: ISymbolItem -> ICanvasContext + + getItemResource :: ISymbolItem -> Resource \ No newline at end of file diff --git a/bundles/org.simantics.diagram/src/org/simantics/diagram/scl/SymbolLibrary.java b/bundles/org.simantics.diagram/src/org/simantics/diagram/scl/SymbolLibrary.java index 6820cad08..9ab2bcd6c 100644 --- a/bundles/org.simantics.diagram/src/org/simantics/diagram/scl/SymbolLibrary.java +++ b/bundles/org.simantics.diagram/src/org/simantics/diagram/scl/SymbolLibrary.java @@ -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(); -- 2.47.1