Skip to content
Snippets Groups Projects
Commit e1ef531e authored by Simon Barner's avatar Simon Barner
Browse files

Offer only connectors in context menu of structural elements

Issue-Ref: 4113
Issue-Url: af3#4113



Signed-off-by: default avatarSimon Barner <barner@fortiss.org>
parent 43eb3a5f
No related branches found
No related tags found
1 merge request!1344113 Offer only connectors in context menu of structural elements
Pipeline #27859 passed
Pipeline: maven-releng

#27860

    AbstractNameEditingSupport.java c57336a0e0da18711a1610ca667dfea76728807f GREEN
    ActionUtils.java 322f43d4f92f992daef8ac88eb0f9197c840c89b GREEN
    ContextMenuUtils.java 74a4264a1d3febb92c7cf9a78f6c12fa1c7ad2f0 GREEN
    ContextMenuUtils.java 0f20d4918d0ca48d937c734aaa0c0e55e8fb4610 YELLOW
    DragAndDropBaseUtils.java d375377f9124f6113b2a295e6b0e09ac8966e564 GREEN
    EllipseLayoutUIUtils.java 4dd9dbd96a45e8c455c019caa19e4a50f18336af GREEN
    FXDNDUtils.java 6ce94e239e68f9e2b3cc0524b072606f4a120076 GREEN
    ......
    ......@@ -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, () -> {
    ......
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Finish editing this message first!
    Please register or to comment