Commit 38870f67 authored by Tiziano Munaro's avatar Tiziano Munaro
Browse files

Merge remote-tracking branch 'origin/master' into 3437

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

Signed-off-by: Tiziano Munaro's avatarTiziano Munaro <munaro@fortiss.org>
parents 57aa7b38 4e8d62ff
ComponentStructureFXEditor.java d097c17a4ebc5bc2a87659544d3dd15f2afde254 GREEN
ComponentStructureFXEditorBinding.java 230337d9526109ee2a9df599c370b0b3f2ec0b40 GREEN
ControllerFactory.java 0adaa2e7ab2e3bc73bae21aec736842a5abeb9a1 GREEN
ModelFactory.java d97242e6b8c69ccaad9fbb6adf80ffdb40520f80 GREEN
VisualFactory.java c3f9acf01cb627f07dca673631a4c8f632d2c4a9 GREEN
ComponentControllerFactory.java 4995e5cc92b2ce5c3d178f7c047e76bf05844c44 GREEN
ComponentModelFactory.java 7e58831949f50a9887bcbf31959f887a87f703cb GREEN
ComponentStructureFXEditor.java d662863a84c9e3f24e46de19dad1d750a1462cd3 GREEN
ComponentStructureFXEditorBinding.java 370fe5c458f15bd8299364f858250d5c2bda6729 GREEN
ComponentVisualFactory.java 4b5f4e36726d65422719d628765d176aa077b673 GREEN
......@@ -22,45 +22,49 @@ import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.mvc.IContentMVCBun
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.mvc.IDiagramAnchorageMVCBundle;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.mvc.IDiagramMVCBundle;
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;
import org.fortiss.af3.component.model.Channel;
import org.fortiss.af3.component.model.Component;
import org.fortiss.af3.component.model.Port;
import org.fortiss.tooling.base.ui.editor.fx.controller.EObjectDiagramController;
import org.fortiss.tooling.base.ui.editor.fx.controller.LayoutedContentAnchorageController;
import org.fortiss.tooling.base.ui.editor.fx.controller.LayoutedDiagramAnchorageController;
import org.fortiss.tooling.base.ui.editor.fx.controller.LayoutedLinkBendPointController;
import org.fortiss.tooling.base.ui.editor.fx.controller.LayoutedRectangularResizableContentController;
/**
* The implementation of the {@link IControllerFactory} for the component editor.
*
* @author hoelzl
* @author diewald
*/
final class ControllerFactory implements IControllerFactory {
public final class ComponentControllerFactory implements IControllerFactory {
/** {@inheritDoc} */
@Override
public IController createContentController(IContentMVCBundle model) {
return new SubComponentController(model);
return new LayoutedRectangularResizableContentController<Component>(model, Component.class);
}
/** {@inheritDoc} */
@Override
public IController createDiagramAnchorageController(IDiagramAnchorageMVCBundle modelBundle) {
return new DiagramComponentPortController(modelBundle);
return new LayoutedDiagramAnchorageController<>(modelBundle, Port.class);
}
/** {@inheritDoc} */
@Override
public IController createContentAnchorageController(IContentAnchorageMVCBundle modelBundle) {
return new SubComponentPortController(modelBundle);
return new LayoutedContentAnchorageController<>(modelBundle, Port.class);
}
/** {@inheritDoc} */
@Override
public IController createLinkController(ILinkMVCBundle modelBundle) {
return new ChannelController(modelBundle);
return new LayoutedLinkBendPointController<>(modelBundle, Channel.class);
}
/** {@inheritDoc} */
@Override
public IController createDiagramController(IDiagramMVCBundle diagramBundle) {
return new DiagramController(diagramBundle);
return new EObjectDiagramController<>(diagramBundle, Component.class);
}
}
......@@ -31,12 +31,12 @@ import org.fortiss.tooling.base.model.element.IConnection;
*
* @author hoelzl
*/
final class ModelFactory implements IModelFactory {
public final class ComponentModelFactory implements IModelFactory {
/** The currently edited component. */
private final Component rootElement;
/** Constructor. */
public ModelFactory(Component root) {
public ComponentModelFactory(Component root) {
this.rootElement = requireNonNull(root);
}
......
......@@ -19,9 +19,6 @@ import static javafx.scene.paint.Color.LIGHTGRAY;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.DiagramViewerFeatures;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.controller.IControllerFactory;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.model.IModelFactory;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.visual.IVisualFactory;
import org.fortiss.af3.component.model.Component;
import org.fortiss.af3.component.model.InputPort;
import org.fortiss.af3.component.model.OutputPort;
......@@ -49,22 +46,4 @@ public class ComponentStructureFXEditor extends LWFXEFEditorBase<Component> {
features.setIndicatorSpacing(new Dimension2D(12, 12));
features.setBackgroundColor(LIGHTGRAY);
}
/** {@inheritDoc} */
@Override
protected IModelFactory createModelFactory() {
return new ModelFactory(editedObject);
}
/** {@inheritDoc} */
@Override
protected IVisualFactory createVisualFactory() {
return new VisualFactory();
}
/** {@inheritDoc} */
@Override
protected IControllerFactory createControllerFactory() {
return new ControllerFactory();
}
}
......@@ -15,6 +15,9 @@
+--------------------------------------------------------------------------*/
package org.fortiss.af3.component.ui.editor.fx;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.controller.IControllerFactory;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.model.IModelFactory;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.visual.IVisualFactory;
import org.eclipse.ui.IEditorPart;
import org.fortiss.af3.component.model.Component;
import org.fortiss.tooling.kernel.ui.extension.base.ModelEditorBindingBase;
......@@ -31,6 +34,24 @@ public final class ComponentStructureFXEditorBinding extends ModelEditorBindingB
return ComponentStructureFXEditor.class;
}
/** {@inheritDoc} */
@Override
public Class<? extends IModelFactory> getModelFactory() {
return ComponentModelFactory.class;
}
/** {@inheritDoc} */
@Override
public Class<? extends IVisualFactory> getVisualFactory() {
return ComponentVisualFactory.class;
}
/** {@inheritDoc} */
@Override
public Class<? extends IControllerFactory> getControllerFactory() {
return ComponentControllerFactory.class;
}
/** {@inheritDoc} */
@Override
public String getLabel() {
......
......@@ -27,23 +27,24 @@ import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.visual.IVisualFact
import org.fortiss.af3.component.model.Channel;
import org.fortiss.af3.component.model.Component;
import org.fortiss.af3.component.model.Port;
import org.fortiss.af3.component.ui.editor.fx.visual.ChannelVisual;
import org.fortiss.af3.component.ui.editor.fx.visual.ContentComponentPortVisual;
import org.fortiss.af3.component.ui.editor.fx.visual.ContentComponentVisual;
import org.fortiss.af3.component.ui.editor.fx.visual.DiagramComponentPortVisual;
import org.fortiss.af3.component.ui.editor.fx.visual.SubComponentPortVisual;
import org.fortiss.af3.component.ui.editor.fx.visual.SubComponentVisual;
import org.fortiss.tooling.base.ui.editor.fx.visual.NamedLayoutedLineLinkVisual;
/**
* The implementation of the {@link IVisualFactory} for the component editor.
*
* @author hoelzl
* @author diewald
*/
final class VisualFactory implements IVisualFactory {
public final class ComponentVisualFactory implements IVisualFactory {
/** {@inheritDoc} */
@Override
public IContentVisual createContentVisual(IContentMVCBundle modelBundle) {
Object modelObj = modelBundle.getModel();
if(modelObj instanceof Component) {
return new SubComponentVisual(modelBundle);
return new ContentComponentVisual(modelBundle);
}
return null;
}
......@@ -65,7 +66,7 @@ final class VisualFactory implements IVisualFactory {
createContentAnchorageVisual(IContentAnchorageMVCBundle modelBundle) {
Object anchorageObj = modelBundle.getModel();
if(anchorageObj instanceof Port) {
return new SubComponentPortVisual(modelBundle);
return new ContentComponentPortVisual(modelBundle);
}
return null;
}
......@@ -75,7 +76,7 @@ final class VisualFactory implements IVisualFactory {
public ILinkVisual createLinkVisual(ILinkMVCBundle modelBundle) {
Object linkObj = modelBundle.getModel();
if(linkObj instanceof Channel) {
return new ChannelVisual(modelBundle);
return new NamedLayoutedLineLinkVisual<>(modelBundle, Channel.class);
}
return null;
}
......
ChannelController.java fe3fd8b71f320e93fa8581298581af6a9d5f8aee GREEN
DiagramComponentPortController.java c99d075a9bc6b9c4214dee19aa5fd634ca5be379 GREEN
DiagramController.java 74e96ce04d715a8084eb5d20b74567bc0168910d GREEN
SubComponentController.java 3fe6f80d4fec036983523b78a8a1892c7716cbda GREEN
SubComponentPortController.java ce6b20088baeb1ddd5c98111316f707f71cd133e GREEN
/*-------------------------------------------------------------------------+
| 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.IMVCBundle;
import org.fortiss.af3.component.model.Port;
import org.fortiss.tooling.base.ui.editor.fx.LayoutedModelElementBasedDiagramAnchorageController;
/**
* {@link IController} for the ports of the component displayed in the diagram (i.e. on the
* background).
*
* @author hoelzl
*/
public final class DiagramComponentPortController
extends LayoutedModelElementBasedDiagramAnchorageController {
/** Constructor. */
public DiagramComponentPortController(IMVCBundle mvcb) {
super(mvcb);
Object model = mvcb.getModel();
if(!(model instanceof Port)) {
throw new IllegalArgumentException(
"Expected model of type Port, but was " + model.getClass().getSimpleName());
}
}
}
/*-------------------------------------------------------------------------+
| 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.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);
}
}
/*-------------------------------------------------------------------------+
| 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 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;
import static org.fortiss.tooling.base.utils.LayoutDataUtils.setNodeSize;
import static org.fortiss.tooling.base.utils.LayoutDataUtils.setStickyConnectorLayoutData;
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.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 javafx.geometry.Dimension2D;
import javafx.geometry.Side;
/**
* {@link IController} for sub-components of the component displayed in the diagram.
*
* @author hoelzl
*/
public final class SubComponentController
extends EObjectBasedRectangularResizableContentControllerBase {
/** Constructor. */
public SubComponentController(IContentMVCBundle mvcb) {
super(mvcb);
Object model = mvcb.getModel();
if(!(model instanceof Component)) {
throw new IllegalArgumentException("Expected model of type Component, but was " +
model.getClass().getSimpleName());
}
}
/** Returns the component. */
private Component getComponent() {
// wild cast works: see constructor
return (Component)getModel();
}
/** {@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,
double offset) {
Object portObj = anchorage.getModel();
if(portObj instanceof Port) {
Port port = (Port)portObj;
// the following correction compensates for SubComponentPortVisual.getOffset()
Dimension2D portDim = anchorage.getVisual().getDimensions();
int correction;
if(side == Side.TOP || side == Side.BOTTOM) {
correction = (int)portDim.getWidth() / 2;
} else {
correction = (int)portDim.getHeight() / 2;
}
int corrected = (int)offset + correction;
setStickyConnectorLayoutData(port, convertSideToEOrientation(side), corrected);
}
}
/** {@inheritDoc} */
@Override
protected void move(FeedbackChange deltaChange) {
moveNode(getComponent(), (int)deltaChange.getDeltaX(), (int)deltaChange.getDeltaY());
}
/** {@inheritDoc} */
@Override
protected void resize(FeedbackChange delta) {
Component component = getComponent();
Dimension d = getNodeSize(component);
int w = d.getWidth() + (int)delta.getDeltaW();
int h = d.getHeight() + (int)delta.getDeltaH();
setNodeSize(component, w, h);
}
/** {@inheritDoc} */
@Override
protected Dimension2D getMinimumSize() {
return new Dimension2D(DEFAULT_SHAPE_MINIMUM_WIDTH, DEFAULT_SHAPE_MINIMUM_HEIGHT);
}
}
/*-------------------------------------------------------------------------+
| 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);
}
}
<!-- (c) 2019 fortiss GmbH -->
<body>
Package for controllers of the JavaFX-based editors of the AF3 component language.
</body>
ChannelVisual.java b381c8ff8d3c807b0efc0408f873a96d5db865a6 GREEN
DiagramComponentPortVisual.java 604db6f8979fdb307247fdce9aa1ca28837b55a4 GREEN
SubComponentPortVisual.java 5ccd54942b0306bc1354611856e9103fb174b0a8 GREEN
SubComponentVisual.java 88d6a2aa0a161d3f869b48c25eed93672092f986 YELLOW
ContentComponentPortVisual.java 8c4b9e27d3bd314c9e11fd544dd2ff9ecd7b70d6 GREEN
ContentComponentVisual.java 9e3e2dbc823722a34c5b1e5fe1268e26ec5f8c38 GREEN
DiagramComponentPortVisual.java bbee9f118b4f6c6077f58d144643ac974c8526fe GREEN
......@@ -22,7 +22,7 @@ import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.mvc.IContentAnchor
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.visual.IContentVisual;
import org.fortiss.af3.component.model.InputPort;
import org.fortiss.af3.component.model.Port;
import org.fortiss.tooling.base.ui.editor.fx.visuals.LayoutedCircularContentAnchorageVisualBase;
import org.fortiss.tooling.base.ui.editor.fx.visual.NamedLayoutedCircularAnchorageContentVisual;
import javafx.scene.paint.Paint;
......@@ -32,36 +32,20 @@ import javafx.scene.paint.Paint;
*
* @author hoelzl
* @author munaro
* @author diewald
*/
public final class SubComponentPortVisual
extends LayoutedCircularContentAnchorageVisualBase {
public final class ContentComponentPortVisual
extends NamedLayoutedCircularAnchorageContentVisual<Port> {
/** Constructor. */
public SubComponentPortVisual(IContentAnchorageMVCBundle mvcb) {
super(mvcb);
Object model = mvcb.getModel();
if(!(model instanceof Port)) {
throw new IllegalArgumentException(
"Expected model of type Port, but was " + model.getClass().getSimpleName());
}
}
/** Returns the port model element. */
private Port getPort() {
// wild cast works: see constructor.
return (Port)super.getModel();
}
/** {@inheritDoc} */
@Override
protected String getHoverText() {
return getPort().getName();
public ContentComponentPortVisual(IContentAnchorageMVCBundle mvcb) {
super(mvcb, Port.class);
}
/** {@inheritDoc} */
@Override
protected Paint getFillColor() {
Port p = getPort();
Port p = getModelElement();
if(p instanceof InputPort) {
return WHITE;
}
......
......@@ -25,7 +25,7 @@ import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.mvc.IContentMVCBun
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.visual.IContentVisual;
import org.fortiss.af3.component.model.Component;
import org.fortiss.af3.component.ui.AF3ComponentUIActivator;
import org.fortiss.tooling.base.ui.editor.fx.visuals.LayoutedRectangularContentVisualBase;
import org.fortiss.tooling.base.ui.editor.fx.visual.NamedLayoutedRectangularContentVisual;
import javafx.scene.image.Image;
import javafx.scene.paint.Color;
......@@ -36,8 +36,9 @@ import javafx.scene.paint.Paint;
*
* @author hoelzl
* @author munaro
* @author diewald
*/
public final class SubComponentVisual extends LayoutedRectangularContentVisualBase {
public final class ContentComponentVisual extends NamedLayoutedRectangularContentVisual<Component> {
/** The plug-in ID. */
public static final String PLUGIN_ID = AF3ComponentUIActivator.class.getPackage().getName();
......@@ -53,25 +54,14 @@ public final class SubComponentVisual extends LayoutedRectangularContentVisualBa
convertColor(WEAKLY_CAUSAL_COMPONENT_BACKGROUND);
/** Constructor. */
public SubComponentVisual(IContentMVCBundle mvcb) {
super(mvcb);
Object model = mvcb.getModel();
if(!(model instanceof Component)) {
throw new IllegalArgumentException("Expected model of type Component, but was " +
model.getClass().getSimpleName());
}
}
/** Returns the component model element. */
private Component getComponent() {
// wild cast works: see constructor
return (Component)getModel();
public ContentComponentVisual(IContentMVCBundle mvcb) {
super(mvcb, Component.class);
}
/** {@inheritDoc} */
@Override
protected Paint getFillColor() {
Component cmp = getComponent();
Component cmp = getModelElement();
if(cmp.getSubComponents().isEmpty()) {
if(cmp.isStronglyCausal()) {