Commit e9ab86b8 authored by Johannes Eder's avatar Johannes Eder

Merge branch 'master' into 3969

parents c1ca72a5 6d5526a8
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;
}
......
......@@ -5,7 +5,7 @@ EllipseLayoutUIUtils.java 4dd9dbd96a45e8c455c019caa19e4a50f18336af GREEN
FXDNDUtils.java 6ce94e239e68f9e2b3cc0524b072606f4a120076 GREEN
FontUtils.java a167a05bdaa8da9853705cc5134f30f6d81bc9f2 GREEN
GCStateManager.java 983973a92376b5c757c1253b32e33d0666ccdf7b GREEN
LWFXEditorUtils.java 24ec0e23dc4b4e768ede8209335985867bdf0e35 GREEN
LWFXEditorUtils.java 32b62765bec43e610e49d11213d58285ccfe9b06 YELLOW
LayoutDataUIUtils.java c85886ac313a6efb122532218eb134047ffd6631 GREEN
PropertiesViewUtils.java d345b4501c4092228edf1c98e0189317d53aaf22 GREEN
RectangleLayoutUIUtils.java ef4b872bb5b4a51174e9a29d9ef05e7cb3bff3a1 GREEN
......
......@@ -109,6 +109,12 @@ public final class LWFXEditorUtils {
*/
public static boolean stickyConnectorHasVisibleConnections(IConnector connector) {
IHierarchicElement elem = connector.getOwner();
if(elem == null) {
// TODO #3985: Work around NPE when deleting Connectors. We need a proper adapter-based
// solution that deregisters any children from the parent bundle via its decompose
// method before it is deleted.
return true;
}
IHierarchicElementContainer diagram = elem.getContainer();
for(IConnection conn : connector.getIncoming()) {
if(conn.getOwner() == diagram) {
......@@ -129,6 +135,12 @@ public final class LWFXEditorUtils {
*/
public static boolean freeConnectorHasVisibleConnections(IConnector connector) {
IHierarchicElement diagram = connector.getOwner();
if(diagram == null) {
// TODO #3985: Work around NPE when deleting Connectors. We need a proper adapter-based
// solution that deregisters any children from the parent bundle via its decompose
// method before it is deleted.
return true;
}
for(IConnection conn : connector.getIncoming()) {
if(conn.getOwner() == diagram) {
return true;
......
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