Commit 6d5526a8 authored by Alexander Diewald's avatar Alexander Diewald

Merge branch '3974' into 'master'

[3974] auto-layout context menu for fx-based diagram editors

See merge request !106
parents 65587cd0 d358d60b
ContextMenuUtil.java 405387151d45b09dffb3b6ba44f980313c8edcaf GREEN
ContextMenuUtil.java 6d270ba4c239c35ee487192427d02797e73ee109 GREEN
CurvedLinkLayoutedContentAnchorangeController.java e22faedbe98c3dab660b5d2df8ebd004e116c5ba GREEN
CurvedLinkLayoutedDiagramAnchorangeController.java f2e5e2a7cc9b6a070871e200e57371286bb15222 GREEN
EObjectDiagramController.java 019e37a9016e895a720374f31667972744080e3b GREEN
EObjectDiagramController.java 18cbb2f092409adeb728233dae6e084faf357d6d GREEN
EObjectEllipticResizableContentControllerBase.java 958d3856daf5337cd75d0a6f163a27dcc8717160 GREEN
EObjectModelChangeProvider.java f4b60cebb088a5c81ca92a41614e1a5d40030502 GREEN
EObjectRectangularResizableContentControllerBase.java 7cbc3e89b7b74106d56b8b4f845087e96e13d109 GREEN
......
......@@ -21,10 +21,13 @@ import java.util.ArrayList;
import java.util.List;
import org.eclipse.emf.ecore.EObject;
import org.fortiss.tooling.common.ui.javafx.lwfxef.DiagramViewer;
import org.fortiss.tooling.common.ui.javafx.lwfxef.DiagramViewerFeatures;
import org.fortiss.tooling.base.dnd.ElementDropContext;
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;
import org.fortiss.tooling.base.ui.layout.auto.KielerAutoLayouter;
import org.fortiss.tooling.common.ui.javafx.lwfxef.DiagramViewer;
import org.fortiss.tooling.common.ui.javafx.lwfxef.DiagramViewerFeatures;
import org.fortiss.tooling.kernel.extension.data.IElementCompositionContext;
import org.fortiss.tooling.kernel.extension.data.Prototype;
import org.fortiss.tooling.kernel.service.ICommandStackService;
......@@ -67,6 +70,20 @@ public final class ContextMenuUtil {
return result;
}
/** Creates an auto-layout menu entry for {@link IHierarchicElement}s. */
public static MenuItem createAutoLayoutMenu(IHierarchicElement target) {
final String MENU_NAME = "Automatic layout";
MenuItem mi = new MenuItem(MENU_NAME);
ICommandStackService css = ICommandStackService.getInstance();
mi.setOnAction(evt -> {
css.runAsCommand(target, () -> {
IAutoLayouter layouter = new KielerAutoLayouter();
layouter.performAutoLayout(target);
});
});
return mi;
}
/** Creates the element composition context. */
public static IElementCompositionContext createElementCompositionContext(EObject target,
double x, double y, boolean isRoot, double zoom) {
......
......@@ -15,6 +15,7 @@ package org.fortiss.tooling.base.ui.editor.fx.controller;
import static java.lang.Math.max;
import static java.util.Objects.requireNonNull;
import static org.fortiss.tooling.base.ui.editor.fx.controller.ContextMenuUtil.createAutoLayoutMenu;
import static org.fortiss.tooling.base.ui.editor.fx.controller.ContextMenuUtil.createDisplayMenu;
import static org.fortiss.tooling.base.ui.editor.fx.controller.ContextMenuUtil.createElementCompositionContext;
import static org.fortiss.tooling.base.ui.editor.fx.controller.ContextMenuUtil.createPrototypeMenu;
......@@ -24,6 +25,7 @@ import static org.fortiss.tooling.base.ui.utils.FXDNDUtils.compose;
import java.util.List;
import org.eclipse.emf.ecore.EObject;
import org.fortiss.tooling.base.model.element.IHierarchicElement;
import org.fortiss.tooling.common.ui.javafx.lwfxef.DiagramCoordinate;
import org.fortiss.tooling.common.ui.javafx.lwfxef.DiagramViewerFeatures;
import org.fortiss.tooling.common.ui.javafx.lwfxef.controller.base.DefaultDiagramController;
......@@ -85,6 +87,9 @@ public class EObjectDiagramController<T extends EObject> extends DefaultDiagramC
getViewer().getFeatures().getCurrentZoomFactor());
List<MenuItem> result = createPrototypeMenu(modelParent, edc);
result.add(createDisplayMenu(getViewer()));
if(modelParent instanceof IHierarchicElement) {
result.add(createAutoLayoutMenu((IHierarchicElement)modelParent));
}
return result;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment