Skip to content
Snippets Groups Projects
Commit 87e64224 authored by Tiziano Munaro's avatar Tiziano Munaro
Browse files

[Context Menu] Access edited object only if an editor is active

Issue-Ref: 4122
Issue-Url: af3#4122



Signed-off-by: default avatarTiziano Munaro <munaro@fortiss.org>
parent 478ff5a5
No related branches found
No related tags found
1 merge request!137[Context Menu] Access edited object only if an editor is active
Pipeline #28349 failed
AbstractNameEditingSupport.java c57336a0e0da18711a1610ca667dfea76728807f GREEN AbstractNameEditingSupport.java c57336a0e0da18711a1610ca667dfea76728807f GREEN
ActionUtils.java 322f43d4f92f992daef8ac88eb0f9197c840c89b GREEN ActionUtils.java 322f43d4f92f992daef8ac88eb0f9197c840c89b GREEN
ContextMenuUtils.java 0f20d4918d0ca48d937c734aaa0c0e55e8fb4610 GREEN ContextMenuUtils.java 7fbc7e303c42510063841e8ec097563d2c235c0e YELLOW
DragAndDropBaseUtils.java d375377f9124f6113b2a295e6b0e09ac8966e564 GREEN DragAndDropBaseUtils.java d375377f9124f6113b2a295e6b0e09ac8966e564 GREEN
EllipseLayoutUIUtils.java 4dd9dbd96a45e8c455c019caa19e4a50f18336af GREEN EllipseLayoutUIUtils.java 4dd9dbd96a45e8c455c019caa19e4a50f18336af GREEN
FXDNDUtils.java 6ce94e239e68f9e2b3cc0524b072606f4a120076 GREEN FXDNDUtils.java 6ce94e239e68f9e2b3cc0524b072606f4a120076 GREEN
......
...@@ -32,6 +32,7 @@ import org.fortiss.tooling.kernel.extension.data.Prototype; ...@@ -32,6 +32,7 @@ import org.fortiss.tooling.kernel.extension.data.Prototype;
import org.fortiss.tooling.kernel.service.ICommandStackService; import org.fortiss.tooling.kernel.service.ICommandStackService;
import org.fortiss.tooling.kernel.service.IElementCompositorService; import org.fortiss.tooling.kernel.service.IElementCompositorService;
import org.fortiss.tooling.kernel.service.IPrototypeService; import org.fortiss.tooling.kernel.service.IPrototypeService;
import org.fortiss.tooling.kernel.ui.extension.IModelEditor;
import org.fortiss.tooling.kernel.ui.service.IModelEditorBindingService; import org.fortiss.tooling.kernel.ui.service.IModelEditorBindingService;
import javafx.scene.control.Menu; import javafx.scene.control.Menu;
...@@ -49,8 +50,10 @@ public final class ContextMenuUtils { ...@@ -49,8 +50,10 @@ public final class ContextMenuUtils {
IPrototypeService pers = IPrototypeService.getInstance(); IPrototypeService pers = IPrototypeService.getInstance();
IElementCompositorService ecs = IElementCompositorService.getInstance(); IElementCompositorService ecs = IElementCompositorService.getInstance();
ICommandStackService css = ICommandStackService.getInstance(); ICommandStackService css = ICommandStackService.getInstance();
EObject editedObject = IModelEditor<EObject> activeEditor =
IModelEditorBindingService.getInstance().getActiveEditor().getEditedObject(); IModelEditorBindingService.getInstance().getActiveEditor();
boolean isMenuForEditedObject =
activeEditor != null && target == activeEditor.getEditedObject();
List<MenuItem> result = new ArrayList<>(); List<MenuItem> result = new ArrayList<>();
Menu newMenu = new Menu("New ..."); Menu newMenu = new Menu("New ...");
...@@ -60,7 +63,7 @@ public final class ContextMenuUtils { ...@@ -60,7 +63,7 @@ public final class ContextMenuUtils {
// If the context menu is created for the currently edited object, offer all composable // 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 // elements. Otherwise (i.e., if context menu is created for a structural element within
// the currently edited object), offer only (composable) connectors. // the currently edited object), offer only (composable) connectors.
if((target == editedObject || prototypeCopy instanceof IConnector) && if((isMenuForEditedObject || prototypeCopy instanceof IConnector) &&
ecs.canCompose(target, prototypeCopy, context)) { ecs.canCompose(target, prototypeCopy, context)) {
MenuItem mi = new MenuItem(p.getName()); MenuItem mi = new MenuItem(p.getName());
mi.setOnAction(evt -> { mi.setOnAction(evt -> {
......
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