diff --git a/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/utils/.ratings b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/utils/.ratings index 6d70a178d73efd4cb8c67c1ca2d4c2ff807169c3..a9b216ff7fdff64f7564ff0357bd0cc12f9985d8 100644 --- a/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/utils/.ratings +++ b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/utils/.ratings @@ -1,6 +1,6 @@ AbstractNameEditingSupport.java c57336a0e0da18711a1610ca667dfea76728807f GREEN ActionUtils.java 322f43d4f92f992daef8ac88eb0f9197c840c89b GREEN -ContextMenuUtils.java 74a4264a1d3febb92c7cf9a78f6c12fa1c7ad2f0 GREEN +ContextMenuUtils.java 0f20d4918d0ca48d937c734aaa0c0e55e8fb4610 GREEN DragAndDropBaseUtils.java d375377f9124f6113b2a295e6b0e09ac8966e564 GREEN EllipseLayoutUIUtils.java 4dd9dbd96a45e8c455c019caa19e4a50f18336af GREEN FXDNDUtils.java 6ce94e239e68f9e2b3cc0524b072606f4a120076 GREEN diff --git a/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/utils/ContextMenuUtils.java b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/utils/ContextMenuUtils.java index 74a4264a1d3febb92c7cf9a78f6c12fa1c7ad2f0..0f20d4918d0ca48d937c734aaa0c0e55e8fb4610 100644 --- a/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/utils/ContextMenuUtils.java +++ b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/utils/ContextMenuUtils.java @@ -22,6 +22,7 @@ import java.util.List; import org.eclipse.emf.ecore.EObject; import org.fortiss.tooling.base.dnd.ElementDropContext; +import org.fortiss.tooling.base.model.element.IConnector; import org.fortiss.tooling.base.model.element.IHierarchicElement; import org.fortiss.tooling.base.model.layout.Point; import org.fortiss.tooling.base.ui.layout.auto.IAutoLayouter; @@ -31,6 +32,7 @@ import org.fortiss.tooling.kernel.extension.data.Prototype; import org.fortiss.tooling.kernel.service.ICommandStackService; import org.fortiss.tooling.kernel.service.IElementCompositorService; import org.fortiss.tooling.kernel.service.IPrototypeService; +import org.fortiss.tooling.kernel.ui.service.IModelEditorBindingService; import javafx.scene.control.Menu; import javafx.scene.control.MenuItem; @@ -47,12 +49,19 @@ public final class ContextMenuUtils { IPrototypeService pers = IPrototypeService.getInstance(); IElementCompositorService ecs = IElementCompositorService.getInstance(); ICommandStackService css = ICommandStackService.getInstance(); + EObject editedObject = + IModelEditorBindingService.getInstance().getActiveEditor().getEditedObject(); + List<MenuItem> result = new ArrayList<>(); Menu newMenu = new Menu("New ..."); List<Prototype> protos = pers.getComposablePrototypes(target.getClass()); for(Prototype p : protos) { EObject prototypeCopy = p.getPrototypeCopy(); - if(ecs.canCompose(target, prototypeCopy, context)) { + // If the context menu is created for the currently edited object, offer all composable + // elements. Otherwise (i.e., if context menu is created for a structural element within + // the currently edited object), offer only (composable) connectors. + if((target == editedObject || prototypeCopy instanceof IConnector) && + ecs.canCompose(target, prototypeCopy, context)) { MenuItem mi = new MenuItem(p.getName()); mi.setOnAction(evt -> { css.runAsCommand(target, () -> {