Skip to content
Snippets Groups Projects
Commit 0468c56c authored by Alexander Diewald's avatar Alexander Diewald
Browse files

Merge remote-tracking branch 'origin/master' into 3870_delegating_factories

parents 2cd8f1a5 039eaf4e
No related branches found
No related tags found
2 merge requests!81JFX: Base classes,!75Kernel: JavaFX editor. Added base classes for extendable LWFXEF editor.
Showing
with 545 additions and 6 deletions
......@@ -25,6 +25,7 @@ Export-Package: org.fortiss.tooling.base.ui,
org.fortiss.tooling.base.ui.editor,
org.fortiss.tooling.base.ui.editor.annotations,
org.fortiss.tooling.base.ui.editor.fx,
org.fortiss.tooling.base.ui.editor.fx.visuals,
org.fortiss.tooling.base.ui.editpart,
org.fortiss.tooling.base.ui.editpart.allocation,
org.fortiss.tooling.base.ui.editpart.command,
......
CoordinateCorrections.java f78a936ba49c5fc4daf29237ecb4e86a446316d4 GREEN
LayoutedCircularContentAnchorageVisualBase.java aa546c0c9d975972a33cf22682b5d6634e56d271 GREEN
LayoutedCircularDiagramAnchorageVisualBase.java c5cc5fb41777166bc169011324585e51acda04c3 GREEN
LayoutedLineLinkVisualBase.java 429483c1222a26345fbc3bf5c9b2dbe41c6ad5f1 GREEN
LayoutedRectangularContentVisualBase.java d4cd07a8056df99927b160f2d4ce1cf4778d1dfa 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.tooling.base.ui.editor.fx.visuals;
import static org.fortiss.tooling.base.layout.DefaultLayoutConstants.DEFAULT_CONNECTOR_SIZE;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.visual.base.ContentAnchorageVisualBase;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.visual.rectangular.RectangularContentVisualBase;
import org.fortiss.tooling.base.layout.DefaultLayoutConstants;
import javafx.geometry.Dimension2D;
/**
* This class contains corrections of {@link DefaultLayoutConstants}.
*
* @author hoelzl
*/
class CoordinateCorrections {
/** The insets of the {@link RectangularContentVisualBase}s. */
/* package */ static final Dimension2D RECTANGLE_INSETS =
new Dimension2D(DEFAULT_CONNECTOR_SIZE / 2, DEFAULT_CONNECTOR_SIZE / 2);
/** The default size of {@link ContentAnchorageVisualBase}s. */
/* package */ static final Dimension2D ANCHOR_DIMENSION =
new Dimension2D(DEFAULT_CONNECTOR_SIZE, DEFAULT_CONNECTOR_SIZE);
/** The insets of the {@link ContentAnchorageVisualBase}s. */
/* package */ static final double ANCHOR_INSET = DEFAULT_CONNECTOR_SIZE / 4.5;
}
/*-------------------------------------------------------------------------+
| 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.tooling.base.ui.editor.fx.visuals;
import static javafx.scene.paint.Color.BLACK;
import static javafx.scene.paint.Color.rgb;
import static org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.DiagramViewerDefaultTags.LINK_TARGET_ALLOWED_TAG;
import static org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.DiagramViewerDefaultTags.LINK_TARGET_DENIED_TAG;
import static org.fortiss.tooling.base.ui.editor.fx.visuals.CoordinateCorrections.ANCHOR_DIMENSION;
import static org.fortiss.tooling.base.ui.editor.fx.visuals.CoordinateCorrections.ANCHOR_INSET;
import static org.fortiss.tooling.base.ui.utils.LWFXEditorUtils.convertEOrientationToSide;
import static org.fortiss.tooling.base.ui.utils.LayoutDataUIUtils.getConnectorOffsetOrientation;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.model.layout.ILayout;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.model.layout.IOffsetLayout;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.model.layout.ISideLayout;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.mvc.IContentAnchorageMVCBundle;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.visual.elliptic.CircularContentAnchorageVisualBase;
import org.fortiss.tooling.base.model.layout.EOrientation;
import org.fortiss.tooling.base.model.layout.ILayoutedModelElement;
import org.fortiss.tooling.base.model.layout.OffsetOrientation;
import javafx.geometry.Dimension2D;
import javafx.geometry.Point2D;
import javafx.geometry.Rectangle2D;
import javafx.geometry.Side;
import javafx.scene.paint.Color;
import javafx.scene.paint.Paint;
/**
* {@link CircularContentAnchorageVisualBase} providing a default visual for ports attached to boxes
* in standard boxes-and-wires diagrams based on {@link ILayoutedModelElement}s.
*
* @author munaro
*/
public abstract class LayoutedCircularContentAnchorageVisualBase
extends CircularContentAnchorageVisualBase implements ISideLayout, IOffsetLayout {
/** Constructor. */
public LayoutedCircularContentAnchorageVisualBase(IContentAnchorageMVCBundle mvcb) {
super(mvcb);
// TODO(#3877): Move type checks to a common base class.
Object model = mvcb.getModel();
if(!(model instanceof ILayoutedModelElement)) {
throw new IllegalArgumentException(
"Expected model of type ILayoutedModelElement, but was " +
model.getClass().getSimpleName() + ".");
}
}
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override
public <T extends ILayout> T getLayout(Class<T> type) {
return (T)this;
}
/** {@inheritDoc} */
@Override
public Rectangle2D getModelBounds() {
Point2D locOnParent = getLocationOnParent();
Dimension2D dim = getDimensions();
return new Rectangle2D(locOnParent.getX(), locOnParent.getY(), dim.getWidth(),
dim.getHeight());
}
/** {@inheritDoc} */
@Override
public Dimension2D getDimensions() {
return ANCHOR_DIMENSION;
}
/** {@inheritDoc} */
@Override
protected double getInset() {
return ANCHOR_INSET;
}
/** {@inheritDoc} */
@Override
public double getOffset() {
OffsetOrientation offsetOrientation = getConnectorOffsetOrientation(getLayoutedModelElement());
double inset = getDimensions().getWidth() / 2;
return offsetOrientation.getOffset() - inset;
}
/** {@inheritDoc} */
@Override
public Side getSide() {
// TODO (#3868): Remove null check.
OffsetOrientation offsetOrientation = getConnectorOffsetOrientation(getLayoutedModelElement());
EOrientation orientation = EOrientation.NORTH;
if(offsetOrientation != null) {
orientation = offsetOrientation.getOrientation();
}
return convertEOrientationToSide(orientation);
}
/** {@inheritDoc} */
@Override
protected Paint getBorderColor() {
return BLACK;
}
/** {@inheritDoc} */
@Override
protected double getOpacity() {
return 1.0;
}
/** {@inheritDoc} */
@Override
protected double getBorderWidth() {
return 1.0;
}
/** {@inheritDoc} */
@Override
protected Color getInteractionColor() {
IContentAnchorageMVCBundle mvcBundle = getMVCBundle();
if(mvcBundle.hasTag(LINK_TARGET_DENIED_TAG)) {
return rgb(255, 0, 0, .25);
}
if(mvcBundle.hasTag(LINK_TARGET_ALLOWED_TAG)) {
return rgb(0, 255, 0, .25);
}
return super.getInteractionColor();
}
/** Return the {@link ILayoutedModelElement}. */
// TODO(#3877): Implement an equivalent, but generic method in a common base class.
private ILayoutedModelElement getLayoutedModelElement() {
// Safe wild cast due to type check in constructor
return (ILayoutedModelElement)getModel();
}
}
/*-------------------------------------------------------------------------+
| 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.tooling.base.ui.editor.fx.visuals;
import static javafx.scene.paint.Color.BLACK;
import static javafx.scene.paint.Color.rgb;
import static org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.DiagramViewerDefaultTags.LINK_TARGET_ALLOWED_TAG;
import static org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.DiagramViewerDefaultTags.LINK_TARGET_DENIED_TAG;
import static org.fortiss.tooling.base.ui.editor.fx.visuals.CoordinateCorrections.ANCHOR_DIMENSION;
import static org.fortiss.tooling.base.ui.editor.fx.visuals.CoordinateCorrections.ANCHOR_INSET;
import static org.fortiss.tooling.base.utils.LayoutDataUtils.getNodePosition;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.mvc.IDiagramAnchorageMVCBundle;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.visual.elliptic.CircularDiagramAnchorageVisualBase;
import org.fortiss.tooling.base.model.layout.ILayoutedModelElement;
import org.fortiss.tooling.base.model.layout.Point;
import javafx.geometry.Dimension2D;
import javafx.geometry.Rectangle2D;
import javafx.scene.paint.Color;
import javafx.scene.paint.Paint;
/**
* {@link CircularDiagramAnchorageVisualBase} providing a default visual for diagram ports in
* standard boxes-and-wires diagrams based on {@link ILayoutedModelElement}s.
*
* @author munaro
*/
public abstract class LayoutedCircularDiagramAnchorageVisualBase
extends CircularDiagramAnchorageVisualBase {
/** Constructor. */
public LayoutedCircularDiagramAnchorageVisualBase(
IDiagramAnchorageMVCBundle mvcb) {
super(mvcb);
// TODO(#3877): Move type checks to a common base class.
Object model = mvcb.getModel();
if(!(model instanceof ILayoutedModelElement)) {
throw new IllegalArgumentException(
"Expected model of type ILayoutedModelElement, but was " +
model.getClass().getSimpleName());
}
}
/** {@inheritDoc} */
@Override
public Rectangle2D getModelBounds() {
Point p = getNodePosition(getLayoutedModelElement());
Dimension2D dim = getDimensions();
return new Rectangle2D(p.getX(), p.getY(), dim.getWidth(), dim.getHeight());
}
/** {@inheritDoc} */
@Override
public Dimension2D getDimensions() {
return ANCHOR_DIMENSION;
}
/** {@inheritDoc} */
@Override
protected double getInset() {
return ANCHOR_INSET;
}
/** {@inheritDoc} */
@Override
protected Paint getBorderColor() {
return BLACK;
}
/** {@inheritDoc} */
@Override
protected double getOpacity() {
return 1.0;
}
/** {@inheritDoc} */
@Override
protected double getBorderWidth() {
return 1.0;
}
/** {@inheritDoc} */
@Override
protected Color getInteractionColor() {
IDiagramAnchorageMVCBundle mvcBundle = getMVCBundle();
if(mvcBundle.hasTag(LINK_TARGET_DENIED_TAG)) {
return rgb(255, 0, 0, .25);
}
if(mvcBundle.hasTag(LINK_TARGET_ALLOWED_TAG)) {
return rgb(0, 255, 0, .25);
}
return super.getInteractionColor();
}
/** Return the {@link ILayoutedModelElement}. */
// TODO(#3877): Move type checks to a common base class.
private ILayoutedModelElement getLayoutedModelElement() {
// Safe wild cast due to type check in constructor
return (ILayoutedModelElement)getModel();
}
}
/*-------------------------------------------------------------------------+
| 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.tooling.base.ui.editor.fx.visuals;
import static java.util.Collections.emptyList;
import static org.fortiss.tooling.base.ui.utils.LWFXEditorUtils.computeLinkToCircleLocation;
import static org.fortiss.tooling.base.ui.utils.LayoutDataUIUtils.getConnectionPoints;
import java.util.List;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.DiagramCoordinate;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.mvc.ILinkMVCBundle;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.visual.rectangular.LineLinkVisualBase;
import org.fortiss.tooling.base.model.layout.ILayoutedModelElement;
import org.fortiss.tooling.base.model.layout.Point;
import org.fortiss.tooling.base.model.layout.Points;
import javafx.geometry.Rectangle2D;
/**
* {@link LineLinkVisualBase} providing a default visual for wires in standard
* boxes-and-wires diagrams based on {@link ILayoutedModelElement}s.
*
* @author munaro
*/
public abstract class LayoutedLineLinkVisualBase extends LineLinkVisualBase {
/** Constructor. */
public LayoutedLineLinkVisualBase(ILinkMVCBundle mvcb) {
super(mvcb);
// TODO(#3877): Move type checks to a common base class.
Object model = mvcb.getModel();
if(!(model instanceof ILayoutedModelElement)) {
throw new IllegalArgumentException(
"Expected model of type ILayoutedModelElement, but was " +
model.getClass().getSimpleName());
}
}
/** {@inheritDoc} */
@Override
public DiagramCoordinate getBendPointLocation(int bpIndex) {
Point point = getBendPointList().get(bpIndex);
return new DiagramCoordinate(point.getX(), point.getY());
}
/** {@inheritDoc} */
@Override
protected DiagramCoordinate getStartAnchorLocation(Rectangle2D anchorBounds,
DiagramCoordinate target) {
return computeLinkToCircleLocation(anchorBounds, target);
}
/** {@inheritDoc} */
@Override
protected DiagramCoordinate getEndAnchorLocation(Rectangle2D anchorBounds,
DiagramCoordinate target) {
return computeLinkToCircleLocation(anchorBounds, target);
}
/** {@inheritDoc} */
@Override
protected Object getBendPointModel(int i) {
return getBendPointList().get(i);
}
/** {@inheritDoc} */
@Override
protected int getNumberOfBendPoints() {
return getBendPointList().size();
}
/** Returns the list of bend-points. */
private List<Point> getBendPointList() {
Points connectionPoints = getConnectionPoints(getLayoutedModelElement());
if(connectionPoints == null) {
return emptyList();
}
List<Point> pointList = connectionPoints.getPoints();
if(pointList == null) {
return emptyList();
}
return pointList;
}
/** {@inheritDoc} */
@Override
protected boolean showArrowOnLastSegment() {
return true;
}
/** {@inheritDoc} */
@Override
protected double getInvisibleSelectionLineWidth() {
return 3;
}
/** Return the {@link ILayoutedModelElement}. */
// TODO(#3877): Move type checks to a common base class.
private ILayoutedModelElement getLayoutedModelElement() {
// Safe wild cast due to type check in constructor
return (ILayoutedModelElement)getModel();
}
}
/*-------------------------------------------------------------------------+
| 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.tooling.base.ui.editor.fx.visuals;
import static java.lang.Math.min;
import static org.fortiss.tooling.base.ui.editor.fx.visuals.CoordinateCorrections.RECTANGLE_INSETS;
import static org.fortiss.tooling.base.utils.LayoutDataUtils.getNodeBounds;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.DiagramCoordinate;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.model.layout.IOffsetLayout;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.model.layout.ISideLayout;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.mvc.IContentMVCBundle;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.visual.IContentAnchorageVisual;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.visual.rectangular.RectangularBorderLocation;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.visual.rectangular.RectangularContentVisualBase;
import org.fortiss.tooling.base.model.layout.ILayoutedModelElement;
import org.fortiss.tooling.base.model.layout.Rectangle;
import javafx.geometry.Dimension2D;
import javafx.geometry.Rectangle2D;
import javafx.geometry.Side;
/**
* {@link RectangularContentVisualBase} providing a default visual for boxes in standard
* boxes-and-wires diagrams based on {@link ILayoutedModelElement}s.
*
* @author munaro
*/
public abstract class LayoutedRectangularContentVisualBase extends RectangularContentVisualBase {
/** Constructor. */
public LayoutedRectangularContentVisualBase(IContentMVCBundle mvcb) {
super(mvcb);
// TODO(#3877): Move type checks to a common base class.
Object model = mvcb.getModel();
if(!(model instanceof ILayoutedModelElement)) {
throw new IllegalArgumentException(
"Expected model of type ILayoutedModelElement, but was " +
model.getClass().getSimpleName());
}
}
/** {@inheritDoc} */
@Override
public Rectangle2D getModelBounds() {
Rectangle rectangle = getNodeBounds(getLayoutedModelElement());
double insetRadius = RECTANGLE_INSETS.getWidth();
double insetDiameter = insetRadius * 2;
return new Rectangle2D(rectangle.getX() + insetRadius, rectangle.getY() + insetRadius,
rectangle.getWidth() - insetDiameter, rectangle.getHeight() - insetDiameter);
}
/** {@inheritDoc} */
@Override
public DiagramCoordinate getAnchorageLocation(IContentAnchorageVisual visual) {
Rectangle2D contentRectangle = getCurrentBounds();
Side rectangleSide = visual.getLayout(ISideLayout.class).getSide();
double sideOffset = visual.getLayout(IOffsetLayout.class).getOffset();
Dimension2D anchorageDimensions = visual.getDimensions();
DiagramCoordinate location = new RectangularBorderLocation(rectangleSide, sideOffset,
contentRectangle, anchorageDimensions).getLocation();
double x = min(location.getX(),
contentRectangle.getWidth() - anchorageDimensions.getWidth() / 2);
double y = min(location.getY(),
contentRectangle.getHeight() - anchorageDimensions.getHeight() / 2);
return new DiagramCoordinate(x, y);
}
/** {@inheritDoc} */
@Override
protected double getBorderWidth() {
return 1;
}
/** {@inheritDoc} */
@Override
protected double getOpacity() {
return 1.0;
}
/** {@inheritDoc} */
@Override
protected boolean requireSelectionForMoveGesture() {
return false;
}
/** {@inheritDoc} */
@Override
protected boolean requireSelectionForResizeGesture() {
return false;
}
/** Return the {@link ILayoutedModelElement}. */
// TODO(#3877): Move type checks to a common base class.
private ILayoutedModelElement getLayoutedModelElement() {
// Safe wild cast due to type check in constructor
return (ILayoutedModelElement)getModel();
}
}
......@@ -3,8 +3,8 @@
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="external-src"/>
<classpathentry kind="src" path="res"/>
<classpathentry exported="true" kind="lib" path="lib/org.eclipse.systemfocus.kernel.common_0.0.4.20191111.jar"/>
<classpathentry exported="true" kind="lib" path="lib/org.eclipse.systemfocus.kernel.common.ui_0.0.4.20191111.jar"/>
<classpathentry exported="true" kind="lib" path="lib/org.eclipse.systemfocus.kernel.common_0.0.5.20191126.jar"/>
<classpathentry exported="true" kind="lib" path="lib/org.eclipse.systemfocus.kernel.common.ui_0.0.5.20191126.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
<attributes>
<attribute name="module" value="true"/>
......
......@@ -25,8 +25,8 @@ Bundle-ClassPath: .,
lib/org.conqat.ide.commons.gef.jar,
lib/org.conqat.ide.commons.ui.jar,
lib/swt-grouplayout.jar,
lib/org.eclipse.systemfocus.kernel.common_0.0.4.20191111.jar,
lib/org.eclipse.systemfocus.kernel.common.ui_0.0.4.20191111.jar
lib/org.eclipse.systemfocus.kernel.common_0.0.5.20191126.jar,
lib/org.eclipse.systemfocus.kernel.common.ui_0.0.5.20191126.jar
Export-Package: aerofx,
aquafx,
jfxtras,
......
......@@ -6,8 +6,8 @@ bin.includes = .,\
lib/org.conqat.ide.commons.ui.jar,\
lib/swt-grouplayout.jar,\
res/,\
lib/org.eclipse.systemfocus.kernel.common_0.0.4.20191111.jar,\
lib/org.eclipse.systemfocus.kernel.common.ui_0.0.4.20191111.jar
lib/org.eclipse.systemfocus.kernel.common_0.0.5.20191126.jar,\
lib/org.eclipse.systemfocus.kernel.common.ui_0.0.5.20191126.jar
jars.compile.order = .
source.. = src/,\
res/,\
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment