Commit 0acd6bfc authored by Florian Hölzl's avatar Florian Hölzl
Browse files

Components: JavaFX editor. Using base classes for controllers.

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

Signed-off-by: Florian Hölzl's avatarFlorian Hoelzl <hoelzl@fortiss.org>
parent 5c7f8e66
......@@ -17,8 +17,6 @@ package org.fortiss.af3.component.ui.editor.fx;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.controller.IController;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.controller.IControllerFactory;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.controller.base.DefaultDiagramController;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.controller.base.DelegatingContentAnchorageController;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.mvc.IContentAnchorageMVCBundle;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.mvc.IContentMVCBundle;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.mvc.IDiagramAnchorageMVCBundle;
......@@ -26,7 +24,9 @@ import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.mvc.IDiagramMVCBun
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.mvc.ILinkMVCBundle;
import org.fortiss.af3.component.ui.editor.fx.controller.ChannelController;
import org.fortiss.af3.component.ui.editor.fx.controller.DiagramComponentPortController;
import org.fortiss.af3.component.ui.editor.fx.controller.DiagramController;
import org.fortiss.af3.component.ui.editor.fx.controller.SubComponentController;
import org.fortiss.af3.component.ui.editor.fx.controller.SubComponentPortController;
/**
* The implementation of the {@link IControllerFactory} for the component editor.
......@@ -49,7 +49,7 @@ final class ControllerFactory implements IControllerFactory {
/** {@inheritDoc} */
@Override
public IController createContentAnchorageController(IContentAnchorageMVCBundle modelBundle) {
return new DelegatingContentAnchorageController(modelBundle);
return new SubComponentPortController(modelBundle);
}
/** {@inheritDoc} */
......@@ -61,6 +61,6 @@ final class ControllerFactory implements IControllerFactory {
/** {@inheritDoc} */
@Override
public IController createDiagramController(IDiagramMVCBundle diagramBundle) {
return new DefaultDiagramController(diagramBundle);
return new DiagramController(diagramBundle);
}
}
ChannelController.java 0ea8eb3cad6817dfe3347e84b88ac5e60476f96f RED
DiagramComponentPortController.java 19a0bd869cfaf2720db87760b9664936a3dd57cf YELLOW
DiagramComponentPortController.java 98f2b9c069c48d98fbf3a51fd086a3f5cffce911 RED
DiagramController.java 4d184103feefcaf9a74ed63538d227b975f9c4f8 RED
SubComponentController.java 4ab19d9f7fc2b0cb837ac1c3a5c3bb4e9010d156 RED
SubComponentPortController.java ce6b20088baeb1ddd5c98111316f707f71cd133e RED
......@@ -19,16 +19,18 @@ import static org.fortiss.tooling.base.utils.LayoutDataUtils.moveNode;
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.base.MoveControllerBase;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.mvc.IMVCBundle;
import org.fortiss.af3.component.model.Port;
import org.fortiss.tooling.base.ui.editor.fx.LayoutedModelElementBasedDiagramAnchorageController;
/**
* {@link IController} for the ports of component displayed in the diagram.
* {@link IController} for the ports of the component displayed in the diagram (i.e. on the
* background).
*
* @author hoelzl
*/
public final class DiagramComponentPortController extends MoveControllerBase {
public final class DiagramComponentPortController
extends LayoutedModelElementBasedDiagramAnchorageController {
/** Constructor. */
public DiagramComponentPortController(IMVCBundle mvcb) {
super(mvcb);
......@@ -47,7 +49,7 @@ public final class DiagramComponentPortController extends MoveControllerBase {
/** {@inheritDoc} */
@Override
protected void move(FeedbackChange deltaChange) {
public void move(FeedbackChange deltaChange) {
Port p = getPort();
int dx = (int)deltaChange.getDeltaX();
int dy = (int)deltaChange.getDeltaY();
......
/*-------------------------------------------------------------------------+
| Copyright 2019 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.af3.component.ui.editor.fx.controller;
import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.impl.AdapterImpl;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.controller.IController;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.mvc.IMVCBundle;
import org.fortiss.tooling.base.ui.editor.fx.EObjectBasedDiagramControllerBase;
/**
* {@link IController} for the diagram model element.
*
* @author hoelzl
*/
public final class DiagramController extends EObjectBasedDiagramControllerBase {
/** Constructor. */
public DiagramController(IMVCBundle mvcb) {
super(mvcb);
}
/** Notification adapter for model change events. */
private final Adapter notificationListener = new AdapterImpl() {
@Override
public void notifyChanged(Notification event) {
fireUpdateComplete();
}
};
/** {@inheritDoc} */
@Override
protected void connectToModel() {
getEObject().eAdapters().add(notificationListener);
}
/** {@inheritDoc} */
@Override
protected void disconnectFromModel() {
getEObject().eAdapters().remove(notificationListener);
}
}
......@@ -26,12 +26,12 @@ import static org.fortiss.tooling.base.utils.LayoutDataUtils.setStickyConnectorL
import org.eclipse.emf.common.notify.Notification;
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.rectangular.RectangularResizableContentControllerBase;
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.af3.component.model.Component;
import org.fortiss.af3.component.model.Port;
import org.fortiss.tooling.base.model.layout.Dimension;
import org.fortiss.tooling.base.ui.editor.fx.EObjectBasedRectangularResizableContentControllerBase;
import org.fortiss.tooling.base.utils.LayoutModelElementAdapter;
import javafx.geometry.Dimension2D;
......@@ -42,7 +42,8 @@ import javafx.geometry.Side;
*
* @author hoelzl
*/
public final class SubComponentController extends RectangularResizableContentControllerBase {
public final class SubComponentController
extends EObjectBasedRectangularResizableContentControllerBase {
/** Listener for model changes. */
private final LayoutModelElementAdapter modelListener;
......
/*-------------------------------------------------------------------------+
| Copyright 2019 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.af3.component.ui.editor.fx.controller;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.controller.IController;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.mvc.IContentAnchorageMVCBundle;
import org.fortiss.tooling.base.ui.editor.fx.LayoutedModelElementBasedContentAnchorageController;
/**
* {@link IController} for ports on sub-components.
*
* @author hoelzl
*/
public final class SubComponentPortController
extends LayoutedModelElementBasedContentAnchorageController {
/** Constructor. */
public SubComponentPortController(IContentAnchorageMVCBundle mvcb) {
super(mvcb);
}
}
ChannelVisual.java 1d2f0f0b5be74ed9225dc4cadc5d0d6b542d3299 YELLOW
DiagramComponentPortVisual.java 4a2e4f089bf55d8642d0f334a6978cc2bf8bf954 YELLOW
SubComponentPortVisual.java 02acdb8ebc050148cbf123e0ab593ac5b076113b YELLOW
SubComponentPortVisual.java 90fb107e57fe107b56b38fcf66a273f286b50760 RED
SubComponentVisual.java 84f6549016ae4a0e8b430918bc00c682645c7724 YELLOW
......@@ -21,7 +21,6 @@ import static org.fortiss.af3.component.ui.editor.fx.FXComponentEditorUtils.conv
import static org.fortiss.af3.component.ui.editor.fx.visual.DiagramComponentPortVisual.PORT_DIMENSION;
import static org.fortiss.af3.component.ui.editor.fx.visual.DiagramComponentPortVisual.PORT_INSET;
import static org.fortiss.tooling.base.ui.utils.LayoutDataUIUtils.getConnectorOffset;
import static org.fortiss.tooling.base.ui.utils.LayoutDataUIUtils.getConnectorOrientation;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.model.layout.ILayout;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.model.layout.IOffsetLayout;
......@@ -32,6 +31,8 @@ import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.visual.elliptic.Ci
import org.fortiss.af3.component.model.InputPort;
import org.fortiss.af3.component.model.Port;
import org.fortiss.tooling.base.model.layout.EOrientation;
import org.fortiss.tooling.base.model.layout.OffsetOrientation;
import org.fortiss.tooling.base.ui.utils.LayoutDataUIUtils;
import javafx.geometry.Dimension2D;
import javafx.geometry.Point2D;
......@@ -94,7 +95,12 @@ public final class SubComponentPortVisual extends CircularContentAnchorageVisual
/** {@inheritDoc} */
@Override
public double getOffset() {
EOrientation eo = getConnectorOrientation(getPort());
// FIXME: after bugfix #3868
OffsetOrientation oo = LayoutDataUIUtils.getConnectorOffsetOrientation(getPort());
EOrientation eo = EOrientation.NORTH;
if(oo != null) {
eo = oo.getOrientation();
}
double dy = 0;
if(eo == EOrientation.WEST || eo == EOrientation.EAST) {
dy = PORT_DIMENSION.getHeight() / 2;
......@@ -105,7 +111,12 @@ public final class SubComponentPortVisual extends CircularContentAnchorageVisual
/** {@inheritDoc} */
@Override
public Side getSide() {
EOrientation eo = getConnectorOrientation(getPort());
// FIXME: after bugfix #3868
OffsetOrientation oo = LayoutDataUIUtils.getConnectorOffsetOrientation(getPort());
EOrientation eo = EOrientation.NORTH;
if(oo != null) {
eo = oo.getOrientation();
}
return convertEOrientationToSide(eo);
}
......
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