Commit 4f10309a authored by Alexander Diewald's avatar Alexander Diewald
Browse files

JFX controllers: Move functions to appropriate base classes

Issue-Ref: 3883
Issue-Url: https://af3-developer.fortiss.org/issues/3883

Signed-off-by: Alexander Diewald's avatarAlexander Diewald <diewald@fortiss.org>
parent 231eecac
ContextMenuUtil.java 7be87ce47b775d90c533078e22d4d445d9864caf GREEN
EObjectBasedDiagramController.java bb2835572a07878dcbf33e3a727f931a33f54dbe YELLOW
EObjectBasedRectangularResizableContentControllerBase.java b7dd4ee94a8144229c807c8a441bcb99d8e71e18 YELLOW
EObjectModelChangeProvider.java f4b60cebb088a5c81ca92a41614e1a5d40030502 GREEN
HierarchicElementController.java f7fc3b919736f782955b89b8f6fcbe24b935dd5a RED
EObjectRectangularResizableContentControllerBase.java 63b3765e583e33d2dc5233c0241b494255f872a7 YELLOW
KernelServiceBasedModelChangeProviderBase.java 18e48f17ea8dfba90de024a8959fc5a4b0d05d45 GREEN
LayoutModelElementModelChangeProvider.java dae8650dc5a8a63e18182521e0f59eb5452239b6 GREEN
LayoutedModelElementBasedContentAnchorageController.java 874a17f8ed7fa9510020f0c05a1eaf45b99a7216 YELLOW
LayoutedModelElementBasedDiagramAnchorageController.java 9e005b36b9f183cbbfcb4e08adc6b5056d0cf29a YELLOW
LayoutedModelElementBasedLinkBendPointController.java 2b6cca10a19e17a62e4820eea630d7bc7476b8b4 YELLOW
LayoutedRectangularResizableContentController.java aebb2c0de11e90d16f40bcbf346112a9d792bdf9 YELLOW
......@@ -14,6 +14,8 @@
package org.fortiss.tooling.base.ui.editor.fx.controller;
import static java.lang.Math.max;
import static org.fortiss.tooling.base.layout.DefaultLayoutConstants.DEFAULT_SHAPE_MINIMUM_HEIGHT;
import static org.fortiss.tooling.base.layout.DefaultLayoutConstants.DEFAULT_SHAPE_MINIMUM_WIDTH;
import static org.fortiss.tooling.base.ui.editor.fx.controller.ContextMenuUtil.createElementCompositionContext;
import static org.fortiss.tooling.base.ui.editor.fx.controller.ContextMenuUtil.createPrototypeMenu;
......@@ -25,9 +27,12 @@ import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.DiagramCoordinate;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.DiagramViewerFeatures;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.change.Change;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.controller.IClickController;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.controller.IDragController;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.controller.base.ClickControllerBase;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.controller.rectangular.RectangularContentAnchorageMoveController;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.controller.rectangular.RectangularResizableContentControllerBase;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.model.IModelChangeProvider;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.mvc.IContentAnchorageMVCBundle;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.mvc.IContentMVCBundle;
import org.fortiss.tooling.base.model.element.ElementPackage;
import org.fortiss.tooling.base.model.layout.ILayoutedModelElement;
......@@ -37,6 +42,7 @@ import org.fortiss.tooling.kernel.ui.extension.IModelElementHandler;
import org.fortiss.tooling.kernel.ui.service.IModelEditorBindingService;
import org.fortiss.tooling.kernel.ui.service.IModelElementHandlerService;
import javafx.geometry.Dimension2D;
import javafx.scene.Node;
import javafx.scene.control.MenuItem;
import javafx.scene.input.MouseEvent;
......@@ -47,23 +53,24 @@ import javafx.scene.input.MouseEvent;
*
* @author hoelzl
*/
public abstract class EObjectBasedRectangularResizableContentControllerBase<T extends ILayoutedModelElement>
public abstract class EObjectRectangularResizableContentControllerBase<T extends EObject>
extends RectangularResizableContentControllerBase {
/** {@link IModelChangeProvider} for this controller */
private final LayoutModelElementModelChangeProvider layoutModelChangeProvider;
/** The click controller handling double-click to open editor. */
private final IClickController openEditorDoubleClickController = new ClickControllerBase() {
@Override
public Change singleClick(MouseEvent event, Node node, DiagramCoordinate diagramLocation) {
return EObjectBasedRectangularResizableContentControllerBase.super.getClickController(
node, diagramLocation).singleClick(event, node, diagramLocation);
return EObjectRectangularResizableContentControllerBase.super.getClickController(node,
diagramLocation).singleClick(event, node, diagramLocation);
}
@Override
public Change secondaryClick(MouseEvent event, Node node,
DiagramCoordinate diagramLocation) {
return EObjectBasedRectangularResizableContentControllerBase.super.getClickController(
node, diagramLocation).secondaryClick(event, node, diagramLocation);
return EObjectRectangularResizableContentControllerBase.super.getClickController(node,
diagramLocation).secondaryClick(event, node, diagramLocation);
}
@Override
......@@ -80,7 +87,7 @@ public abstract class EObjectBasedRectangularResizableContentControllerBase<T ex
};
/** Constructor. */
public EObjectBasedRectangularResizableContentControllerBase(IContentMVCBundle mvcb,
public EObjectRectangularResizableContentControllerBase(IContentMVCBundle mvcb,
Class<T> modelType) {
super(mvcb);
......@@ -119,6 +126,28 @@ public abstract class EObjectBasedRectangularResizableContentControllerBase<T ex
return layoutModelChangeProvider;
}
/** {@inheritDoc} */
@Override
protected IDragController createAnchorageMoveController(IContentAnchorageMVCBundle anchorage) {
// we need an overridden port move controller due to the frameworks default snapping
// behavior, which snaps to anchorage size while AF3 ports snap to half their size
return new RectangularContentAnchorageMoveController(this, anchorage) {
/** {@inheritDoc} */
@Override
protected Dimension2D overrideBorderSnap(Dimension2D anchorageSize) {
// this override is required because ports can be moved by half their size
// while the default implementation would only allow for full size of the port
return new Dimension2D(anchorageSize.getWidth() / 2, anchorageSize.getHeight() / 2);
}
};
}
/** {@inheritDoc} */
@Override
protected Dimension2D getMinimumSize() {
return new Dimension2D(DEFAULT_SHAPE_MINIMUM_WIDTH, DEFAULT_SHAPE_MINIMUM_HEIGHT);
}
/** {@inheritDoc} */
@Override
public List<MenuItem> contextMenuContributions(Node node, DiagramCoordinate diagramLocation) {
......
......@@ -15,8 +15,6 @@
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.base.ui.editor.fx.controller;
import static org.fortiss.tooling.base.layout.DefaultLayoutConstants.DEFAULT_SHAPE_MINIMUM_HEIGHT;
import static org.fortiss.tooling.base.layout.DefaultLayoutConstants.DEFAULT_SHAPE_MINIMUM_WIDTH;
import static org.fortiss.tooling.base.ui.utils.LWFXEditorUtils.convertSideToEOrientation;
import static org.fortiss.tooling.base.utils.LayoutDataUtils.getNodeSize;
import static org.fortiss.tooling.base.utils.LayoutDataUtils.moveNode;
......@@ -25,12 +23,9 @@ import static org.fortiss.tooling.base.utils.LayoutDataUtils.setStickyConnectorL
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.FeedbackChange;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.controller.IController;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.controller.IDragController;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.controller.rectangular.RectangularContentAnchorageMoveController;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.mvc.IContentAnchorageMVCBundle;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.mvc.IContentMVCBundle;
import org.fortiss.tooling.base.model.element.IConnector;
import org.fortiss.tooling.base.model.element.IHierarchicElement;
import org.fortiss.tooling.base.model.layout.Dimension;
import org.fortiss.tooling.base.model.layout.ILayoutedModelElement;
......@@ -38,35 +33,18 @@ import javafx.geometry.Dimension2D;
import javafx.geometry.Side;
/**
* {@link IController} for {@link IHierarchicElement}s that are also {@link ILayoutedModelElement}s.
* {@link IController} for {@link ILayoutedModelElement}s that have a rectangular shape.
*
* @author diewald
*/
// TODO(AD): I guess it would make sense to swap inheritance between the Hierarchic and the
// RectengularController.
public class HierarchicElementController<T extends IHierarchicElement & ILayoutedModelElement>
extends EObjectBasedRectangularResizableContentControllerBase<T> {
public class LayoutedRectangularResizableContentController<T extends ILayoutedModelElement>
extends EObjectRectangularResizableContentControllerBase<T> {
/** Constructor. */
public HierarchicElementController(IContentMVCBundle mvcb, Class<T> modelType) {
public LayoutedRectangularResizableContentController(IContentMVCBundle mvcb,
Class<T> modelType) {
super(mvcb, modelType);
}
/** {@inheritDoc} */
@Override
protected IDragController createAnchorageMoveController(IContentAnchorageMVCBundle anchorage) {
// we need an overridden port move controller due to the frameworks default snapping
// behavior, which snaps to anchorage size while AF3 ports snap to half their size
return new RectangularContentAnchorageMoveController(this, anchorage) {
/** {@inheritDoc} */
@Override
protected Dimension2D overrideBorderSnap(Dimension2D anchorageSize) {
// this override is required because ports can be moved by half their size
// while the default implementation would only allow for full size of the port
return new Dimension2D(anchorageSize.getWidth() / 2, anchorageSize.getHeight() / 2);
}
};
}
/** {@inheritDoc} */
@Override
protected void moveAnchorageToSideOffset(IContentAnchorageMVCBundle anchorage, Side side,
......@@ -102,10 +80,4 @@ public class HierarchicElementController<T extends IHierarchicElement & ILayoute
int h = d.getHeight() + (int)delta.getDeltaH();
setNodeSize(element, w, h);
}
/** {@inheritDoc} */
@Override
protected Dimension2D getMinimumSize() {
return new Dimension2D(DEFAULT_SHAPE_MINIMUM_WIDTH, DEFAULT_SHAPE_MINIMUM_HEIGHT);
}
}
Supports Markdown
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