diff --git a/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/.ratings b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/.ratings index e653166242491b3ca417726ed14323d4c8283f2b..21108b1edd907c85abeb1a45d9b92e0fcc5e7941 100644 --- a/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/.ratings +++ b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/.ratings @@ -1,7 +1,7 @@ ContextMenuUtil.java 3e04dbd52ee99a59735d39b4087c55b07fb91076 GREEN -EObjectBasedDiagramControllerBase.java b25bbbaa6eef3878b9aea73ca67d66de9beebb18 GREEN +EObjectBasedDiagramControllerBase.java 3564ece9b3cac29caaf9201e0be3451a6a3c2b21 GREEN EObjectBasedRectangularResizableContentControllerBase.java a263a6c123ee96015e0a5c37b6e3c13ebd0e8a75 GREEN -HierarchicModelElementModelChangeProvider.java 05217577a99d78038763bbcd841a032bb84f0553 GREEN +EObjectModelChangeProvider.java 664e4db2e32124832682aff8235ac380ed4db1c0 GREEN KernelServiceBasedModelChangeProviderBase.java 7c30347fb0c7cc4aacc79aeaf85167872afc1958 GREEN LayoutModelElementModelChangeProvider.java 70c50b789c0088a7e5363bf662bc707a5b5ddf10 GREEN LayoutedModelElementBasedContentAnchorageController.java c4dfb9dbcd16078c63321d5dec13a902e4088949 GREEN diff --git a/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/EObjectBasedDiagramControllerBase.java b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/EObjectBasedDiagramControllerBase.java index b25bbbaa6eef3878b9aea73ca67d66de9beebb18..3564ece9b3cac29caaf9201e0be3451a6a3c2b21 100644 --- a/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/EObjectBasedDiagramControllerBase.java +++ b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/EObjectBasedDiagramControllerBase.java @@ -26,7 +26,6 @@ import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.DiagramViewerFeatu import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.controller.base.ControllerBase; import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.model.IModelChangeProvider; import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.mvc.IMVCBundle; -import org.fortiss.tooling.base.model.element.IHierarchicElement; import org.fortiss.tooling.kernel.extension.data.IElementCompositionContext; import org.fortiss.tooling.kernel.service.IElementCompositorService; import org.fortiss.tooling.kernel.ui.service.IContextMenuService; @@ -41,18 +40,17 @@ import javafx.scene.control.MenuItem; * @author hoelzl */ public abstract class EObjectBasedDiagramControllerBase extends ControllerBase { + /** The model change provider. */ - private final HierarchicModelElementModelChangeProvider modelChangeProvider; + private final EObjectModelChangeProvider modelChangeProvider; /** Constructor. */ public EObjectBasedDiagramControllerBase(IMVCBundle mvcb) { super(mvcb); - if(!(getModel() instanceof IHierarchicElement)) { - throw new IllegalArgumentException( - "Model element must be an instance of an IHierarchicElement."); + if(!(getModel() instanceof EObject)) { + throw new IllegalArgumentException("Model element must be an instance of an EObject."); } - this.modelChangeProvider = - new HierarchicModelElementModelChangeProvider(getHierarchicElement()); + this.modelChangeProvider = new EObjectModelChangeProvider(getEObject()); } /** {@inheritDoc} */ @@ -61,10 +59,10 @@ public abstract class EObjectBasedDiagramControllerBase extends ControllerBase { return modelChangeProvider; } - /** Returns the {@link IHierarchicElement} model element. */ - protected IHierarchicElement getHierarchicElement() { + /** Returns the {@link EObject} model element. */ + protected EObject getEObject() { // wild cast works: see constructor check with exception - return (IHierarchicElement)getModel(); + return (EObject)getModel(); } /** {@inheritDoc} */ @@ -76,7 +74,7 @@ public abstract class EObjectBasedDiagramControllerBase extends ControllerBase { double y = max(features.getVerticalSpacing(), diagramLocation.getY()); // wild cast works: see constructor exception - EObject modelParent = getHierarchicElement(); + EObject modelParent = getEObject(); IElementCompositionContext edc = createElementCompositionContext(modelParent, x, y, true, getViewer().getFeatures().getCurrentZoomFactor()); List<MenuItem> result = createPrototypeMenu(modelParent, edc); diff --git a/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/HierarchicModelElementModelChangeProvider.java b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/EObjectModelChangeProvider.java similarity index 73% rename from org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/HierarchicModelElementModelChangeProvider.java rename to org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/EObjectModelChangeProvider.java index 05217577a99d78038763bbcd841a032bb84f0553..664e4db2e32124832682aff8235ac380ed4db1c0 100644 --- a/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/HierarchicModelElementModelChangeProvider.java +++ b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/EObjectModelChangeProvider.java @@ -18,29 +18,28 @@ package org.fortiss.tooling.base.ui.editor.fx; import org.eclipse.emf.common.notify.Adapter; import org.eclipse.emf.common.notify.Notification; import org.eclipse.emf.common.notify.impl.AdapterImpl; -import org.fortiss.tooling.base.model.element.IHierarchicElement; +import org.eclipse.emf.ecore.EObject; /** - * An {@link KernelServiceBasedModelChangeProviderBase} for {@link IHierarchicElement}s. + * An {@link KernelServiceBasedModelChangeProviderBase} for {@link EObject}s. * * @author hoelzl */ -final class HierarchicModelElementModelChangeProvider - extends KernelServiceBasedModelChangeProviderBase<IHierarchicElement> { +final class EObjectModelChangeProvider extends KernelServiceBasedModelChangeProviderBase<EObject> { /** The model element. */ - private final IHierarchicElement modelElement; + private final EObject modelElement; /** The EMF notification listener. */ - private final HierarchicElementAdapter notificationListener; + private final EObjectElementAdapter notificationListener; /** Constructor. */ - public HierarchicModelElementModelChangeProvider(IHierarchicElement modelElement) { + public EObjectModelChangeProvider(EObject modelElement) { this.modelElement = modelElement; - this.notificationListener = new HierarchicElementAdapter(); + this.notificationListener = new EObjectElementAdapter(); } /** {@inheritDoc} */ @Override - protected IHierarchicElement getModelElement() { + protected EObject getModelElement() { return modelElement; } @@ -50,8 +49,8 @@ final class HierarchicModelElementModelChangeProvider return notificationListener; } - /** Specialized adapter listening to model changes of {@link IHierarchicElement}. */ - private class HierarchicElementAdapter extends AdapterImpl { + /** Specialized adapter listening to model changes of {@link EObject}. */ + private class EObjectElementAdapter extends AdapterImpl { /** {@inheritDoc} */ @Override public void notifyChanged(Notification event) { diff --git a/org.fortiss.tooling.common.ui/.classpath b/org.fortiss.tooling.common.ui/.classpath index 58729d820ca7fbc879e1a6737fa930dff1cdd2be..cb4939f8345486a25a29b4f18626b12cc24eae60 100644 --- a/org.fortiss.tooling.common.ui/.classpath +++ b/org.fortiss.tooling.common.ui/.classpath @@ -3,8 +3,8 @@ <classpathentry kind="src" path="src"/> <classpathentry kind="src" path="external-src"/> <classpathentry kind="src" path="res"/> - <classpathentry exported="true" kind="lib" path="lib/org.eclipse.systemfocus.kernel.common_0.0.5.20191126.jar"/> - <classpathentry exported="true" kind="lib" path="lib/org.eclipse.systemfocus.kernel.common.ui_0.0.5.20191126.jar"/> + <classpathentry exported="true" kind="lib" path="lib/org.eclipse.systemfocus.kernel.common_0.0.5.20191213.jar"/> + <classpathentry exported="true" kind="lib" path="lib/org.eclipse.systemfocus.kernel.common.ui_0.0.5.20191213.jar"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"> <attributes> <attribute name="module" value="true"/> diff --git a/org.fortiss.tooling.common.ui/META-INF/MANIFEST.MF b/org.fortiss.tooling.common.ui/META-INF/MANIFEST.MF index a746ba0a13dd72fd314f4185d175b5a3e6d1fd6e..1898771c2202bd22a084d201e92eafb0f18d3b02 100644 --- a/org.fortiss.tooling.common.ui/META-INF/MANIFEST.MF +++ b/org.fortiss.tooling.common.ui/META-INF/MANIFEST.MF @@ -25,8 +25,8 @@ Bundle-ClassPath: ., lib/org.conqat.ide.commons.gef.jar, lib/org.conqat.ide.commons.ui.jar, lib/swt-grouplayout.jar, - lib/org.eclipse.systemfocus.kernel.common_0.0.5.20191126.jar, - lib/org.eclipse.systemfocus.kernel.common.ui_0.0.5.20191126.jar + lib/org.eclipse.systemfocus.kernel.common_0.0.5.20191213.jar, + lib/org.eclipse.systemfocus.kernel.common.ui_0.0.5.20191213.jar Export-Package: aerofx, aquafx, jfxtras, diff --git a/org.fortiss.tooling.common.ui/build.properties b/org.fortiss.tooling.common.ui/build.properties index 9047dcbc4a556cdf98555184d764e06f30757767..e4293a8077ba272c17cde3f615f0c17be7389027 100644 --- a/org.fortiss.tooling.common.ui/build.properties +++ b/org.fortiss.tooling.common.ui/build.properties @@ -6,8 +6,8 @@ bin.includes = .,\ lib/org.conqat.ide.commons.ui.jar,\ lib/swt-grouplayout.jar,\ res/,\ - lib/org.eclipse.systemfocus.kernel.common_0.0.5.20191126.jar,\ - lib/org.eclipse.systemfocus.kernel.common.ui_0.0.5.20191126.jar + lib/org.eclipse.systemfocus.kernel.common_0.0.5.20191213.jar,\ + lib/org.eclipse.systemfocus.kernel.common.ui_0.0.5.20191213.jar jars.compile.order = . source.. = src/,\ res/,\ diff --git a/org.fortiss.tooling.common.ui/lib/org.eclipse.systemfocus.kernel.common.ui_0.0.5.20191126.jar b/org.fortiss.tooling.common.ui/lib/org.eclipse.systemfocus.kernel.common.ui_0.0.5.20191126.jar deleted file mode 100644 index f657fb4f02b9b01d153b27ac9354b60e4aa82648..0000000000000000000000000000000000000000 Binary files a/org.fortiss.tooling.common.ui/lib/org.eclipse.systemfocus.kernel.common.ui_0.0.5.20191126.jar and /dev/null differ diff --git a/org.fortiss.tooling.common.ui/lib/org.eclipse.systemfocus.kernel.common.ui_0.0.5.20191213.jar b/org.fortiss.tooling.common.ui/lib/org.eclipse.systemfocus.kernel.common.ui_0.0.5.20191213.jar new file mode 100644 index 0000000000000000000000000000000000000000..fb24b39f087a12b919462f58014ae5cc13d42a41 Binary files /dev/null and b/org.fortiss.tooling.common.ui/lib/org.eclipse.systemfocus.kernel.common.ui_0.0.5.20191213.jar differ diff --git a/org.fortiss.tooling.common.ui/lib/org.eclipse.systemfocus.kernel.common_0.0.5.20191126.jar b/org.fortiss.tooling.common.ui/lib/org.eclipse.systemfocus.kernel.common_0.0.5.20191126.jar deleted file mode 100644 index 919bfd21e5e7be75c346982183cdf51085ae7b33..0000000000000000000000000000000000000000 Binary files a/org.fortiss.tooling.common.ui/lib/org.eclipse.systemfocus.kernel.common_0.0.5.20191126.jar and /dev/null differ diff --git a/org.fortiss.tooling.common.ui/lib/org.eclipse.systemfocus.kernel.common_0.0.5.20191213.jar b/org.fortiss.tooling.common.ui/lib/org.eclipse.systemfocus.kernel.common_0.0.5.20191213.jar new file mode 100644 index 0000000000000000000000000000000000000000..a7d80f27a40d52955285adc3b5a211581b4e93e7 Binary files /dev/null and b/org.fortiss.tooling.common.ui/lib/org.eclipse.systemfocus.kernel.common_0.0.5.20191213.jar differ diff --git a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/util/.ratings b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/util/.ratings index c6b18d0797ce6dd79d499e4c5ecbf66c10b36beb..5daffda45b2c2766042b182aaff6349abe2a9ef3 100644 --- a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/util/.ratings +++ b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/util/.ratings @@ -1,3 +1,2 @@ -FXMLUtils.java 4f62cc98d504b978cc8480432c1f53d0fa6fefcf RED +GraphicUtils.java 4d471a310a52bda1c090f956dcdbe90775b12cb8 GREEN JavaFXUtils.java db3cf28289109ffec64c8f96c7b2de779a977b3b YELLOW -SceneGraphUtils.java f54304c2eb604934de9afdf9d2a8ca88a762398a GREEN diff --git a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/util/GraphicUtils.java b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/util/GraphicUtils.java new file mode 100644 index 0000000000000000000000000000000000000000..4d471a310a52bda1c090f956dcdbe90775b12cb8 --- /dev/null +++ b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/util/GraphicUtils.java @@ -0,0 +1,67 @@ +/*-------------------------------------------------------------------------+ +| Copyright 2019 fortiss GmbH | +| | +| Licensed under the Apache License, Version 2.0 (the "License"); | +| you may not use this file except in compliance with the License. | +| You may obtain a copy of the License at | +| | +| http://www.apache.org/licenses/LICENSE-2.0 | +| | +| Unless required by applicable law or agreed to in writing, software | +| distributed under the License is distributed on an "AS IS" BASIS, | +| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | +| See the License for the specific language governing permissions and | +| limitations under the License. | ++--------------------------------------------------------------------------*/ +package org.fortiss.tooling.common.ui.javafx.util; + +import java.io.InputStream; +import java.net.URL; +import java.util.HashMap; + +import javafx.scene.image.Image; +import javafx.scene.paint.Color; + +/** + * Utility methods for handling graphics in JavaFX-based views. + * + * @author munaro + */ +public class GraphicUtils { + + /** The image cache of loaded images. */ + private static final HashMap<String, Image> imageCache = new HashMap<>(); + + /** Returns the plugin-local URI string for the given resource. */ + public static String getURIString(String pluginId, String localPath) { + return "platform:/plugin/" + pluginId + localPath; + } + + /** Returns the Java FX Image load from the local path. */ + public static Image getFXImage(String pluginId, String localPath) { + String uri = getURIString(pluginId, localPath); + if(uri == null) { + return null; + } + Image cacheImage = imageCache.get(uri); + if(cacheImage == null) { + InputStream in = null; + try { + in = new URL(uri).openStream(); + } catch(Exception e) { + e.printStackTrace(); + } + if(in != null) { + cacheImage = new Image(in); + } + imageCache.put(uri, cacheImage); + } + return cacheImage; + } + + /** Converts the given SWT color to Java FX color. */ + public static Color convertColor(org.eclipse.swt.graphics.Color swtColor) { + return Color.rgb(swtColor.getRed(), swtColor.getGreen(), swtColor.getBlue(), + swtColor.getAlpha() / 255.0); + } +}