Commit edfdbc41 authored by Alexander Diewald's avatar Alexander Diewald
Browse files

JFX editors: Adapt component and task editors to new kernel 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 6ba71cf9
ComponentStructureFXEditor.java d097c17a4ebc5bc2a87659544d3dd15f2afde254 GREEN
ComponentStructureFXEditorBinding.java 230337d9526109ee2a9df599c370b0b3f2ec0b40 GREEN
ControllerFactory.java 0adaa2e7ab2e3bc73bae21aec736842a5abeb9a1 GREEN
ControllerFactory.java 1e674544cd5bec3ebc883710ab50bfa87a072870 YELLOW
ModelFactory.java d97242e6b8c69ccaad9fbb6adf80ffdb40520f80 GREEN
VisualFactory.java c3f9acf01cb627f07dca673631a4c8f632d2c4a9 GREEN
SubComponentController.java e7361eb33367c160f9a7502721bca13f1ee85128 YELLOW
VisualFactory.java 94d24732b7b3c737ccfdfcb7d981d2edeadd8527 YELLOW
......@@ -22,16 +22,19 @@ 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;
/**
* The implementation of the {@link IControllerFactory} for the component editor.
*
* @author hoelzl
* @author diewald
*/
final class ControllerFactory implements IControllerFactory {
/** {@inheritDoc} */
......@@ -43,24 +46,24 @@ final class ControllerFactory implements IControllerFactory {
/** {@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);
}
}
......@@ -13,28 +13,37 @@
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.af3.component.ui.editor.fx.controller;
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.mvc.IMVCBundle;
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.ui.editor.fx.LayoutedModelElementBasedDiagramAnchorageController;
import org.fortiss.tooling.base.ui.editor.fx.controller.LayoutedRectangularResizableContentController;
import javafx.geometry.Side;
/**
* {@link IController} for the ports of the component displayed in the diagram (i.e. on the
* background).
* {@link IController} for sub-components of the component displayed in the diagram.
*
* @author hoelzl
* @author diewald
*/
public final class DiagramComponentPortController
extends LayoutedModelElementBasedDiagramAnchorageController {
public final class SubComponentController
extends LayoutedRectangularResizableContentController<Component> {
/** 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());
public SubComponentController(IContentMVCBundle mvcb) {
super(mvcb, Component.class);
}
/** {@inheritDoc} */
@Override
protected void moveAnchorageToSideOffset(IContentAnchorageMVCBundle anchorage, Side side,
double offset) {
Object portObj = anchorage.getModel();
if(portObj instanceof Port) {
super.moveAnchorageToSideOffset(anchorage, side, offset);
}
}
}
......@@ -27,15 +27,16 @@ 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.LayoutedLineLinkVisual;
/**
* The implementation of the {@link IVisualFactory} for the component editor.
*
* @author hoelzl
* @author diewald
*/
final class VisualFactory implements IVisualFactory {
/** {@inheritDoc} */
......@@ -43,7 +44,7 @@ final class VisualFactory implements IVisualFactory {
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 LayoutedLineLinkVisual<>(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.ILinkMVCBundle;
import org.fortiss.af3.component.model.Channel;
import org.fortiss.tooling.base.ui.editor.fx.LayoutedModelElementBasedLinkBendPointController;
/**
* {@link IController} for {@link Channel}s.
*
* @author hoelzl
*/
public final class ChannelController extends LayoutedModelElementBasedLinkBendPointController {
/** Constructor. */
public ChannelController(ILinkMVCBundle mvcb) {
super(mvcb);
Object model = mvcb.getModel();
if(!(model instanceof Channel)) {
throw new IllegalArgumentException(
"Expected model of type Channel, but was " + model.getClass().getSimpleName());
}
}
/** Returns the channel model element. */
public Channel getChannel() {
// wild cast works: see constructor
return (Channel)getModel();
}
/** {@inheritDoc} */
@Override
protected boolean clampAndSnapBendPointToGridCenter() {
// disable default mode
return false;
}
/** {@inheritDoc} */
@Override
protected boolean clampAndSnapBendPointToGrid() {
// enable clamping mode
return true;
}
}
/*-------------------------------------------------------------------------+
| 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 YELLOW
ContentComponentVisual.java 9e3e2dbc823722a34c5b1e5fe1268e26ec5f8c38 YELLOW
DiagramComponentPortVisual.java bbee9f118b4f6c6077f58d144643ac974c8526fe YELLOW
SubComponentPortVisual.java e236d8e3ab70dc619bcf586d2d7110ce24c174d0 YELLOW
SubComponentVisual.java e896ead94279a2374860fe4de2a19939a6783acf YELLOW
/*-------------------------------------------------------------------------+
| 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.visual;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.mvc.ILinkMVCBundle;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.visual.ILinkVisual;
import org.fortiss.af3.component.model.Channel;
import org.fortiss.tooling.base.ui.editor.fx.visuals.LayoutedLineLinkVisualBase;
/**
* {@link ILinkVisual} for {@link Channel}s.
*
* @author hoelzl
* @author munaro
*/
public final class ChannelVisual extends LayoutedLineLinkVisualBase {
/** Constructor. */
public ChannelVisual(ILinkMVCBundle mvcb) {
super(mvcb);
Object model = mvcb.getModel();
if(!(model instanceof Channel)) {
throw new IllegalArgumentException(
"Expected model of type Channel, but was " + model.getClass().getSimpleName());
}
}
/** Returns the model element. */
public Channel getChannel() {
// wild cast works: see constructor
return (Channel)super.getModel();
}
/** {@inheritDoc} */
@Override
protected String getLabelText(int currentSegment, int lastSegment) {
if(currentSegment == 0) {
return getChannel().getName();
}
return null;
}
}
......@@ -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 {