Skip to content
Snippets Groups Projects
Commit bc347a26 authored by Andreas Bayha's avatar Andreas Bayha
Browse files

Merge remote-tracking branch 'remotes/origin/master' into 3977

parents 388bc84c 624d96a4
No related branches found
No related tags found
1 merge request!973977
Showing
with 117 additions and 20 deletions
ContextMenuUtil.java 405387151d45b09dffb3b6ba44f980313c8edcaf GREEN
CurvedLinkLayoutedContentAnchorangeController.java 6d2b64c3d6c813ac001b1500ed0529ad6e561aaf GREEN
CurvedLinkLayoutedContentAnchorangeController.java a206a297cfc51281b31d02c751c3090b49fc7341 GREEN
CurvedLinkLayoutedDiagramAnchorangeController.java 41b7cc1ad066aa677eb3005a5bceeaa200d01eaa GREEN
EObjectDiagramController.java 2b253941592ee25ead95223470f983f23ef9776f GREEN
EObjectEllipticResizableContentControllerBase.java 7c862a03b97d2f2cfdcc2fcee7434de2e1e257d2 GREEN
EObjectModelChangeProvider.java f4b60cebb088a5c81ca92a41614e1a5d40030502 GREEN
......
......@@ -17,8 +17,9 @@ package org.fortiss.tooling.base.ui.editor.fx.controller;
import static org.fortiss.tooling.base.ui.utils.LayoutDataUIUtils.addConnectionPoint;
import org.fortiss.tooling.base.model.base.EntryConnectorBase;
import org.fortiss.tooling.base.model.base.ExitConnectorBase;
import org.eclipse.emf.common.util.BasicEList;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.fortiss.tooling.base.model.base.HierarchicElementBase;
import org.fortiss.tooling.base.model.element.IConnection;
import org.fortiss.tooling.base.model.element.IConnector;
......@@ -43,7 +44,7 @@ public class CurvedLinkLayoutedContentAnchorangeController<T extends IConnector
}
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
// TODO(3978): Resolve code duplication in the link-method of link visuals
@Override
protected void link(IMVCBundle startBundle, DiagramCoordinate startLocation,
IMVCBundle endBundle, DiagramCoordinate endLocation) {
......@@ -53,18 +54,22 @@ public class CurvedLinkLayoutedContentAnchorangeController<T extends IConnector
return;
}
// Create the connection
// The call to `super.link` (see next lines) does not return a reference to the
// newly created connection. However, as it is needed in order to add the handles
// we get it by comparing the root element's connections before and after the
// creation of the new link:
// 1) Here we get the list of existing connections
EList<IConnection> connectionsBefore = new BasicEList<IConnection>(
((HierarchicElementBase)(EObject)getViewer().getRootElement()).getConnections());
// 2) Here we create the new connection
super.link(startBundle, startLocation, endBundle, endLocation);
// Fetch newly created connection by comparing incoming and outgoing connections of the
// given connectors. As only one connection is allowed between a pair of connectors, this
// 'findFirst' is safe.
T startConnector = (T)(startBundle.getModel() instanceof ExitConnectorBase
? startBundle.getModel() : endBundle.getModel());
T endConnector = (T)(endBundle.getModel() instanceof EntryConnectorBase
? endBundle.getModel() : startBundle.getModel());
IConnection connection = startConnector.getOutgoing().stream()
.filter(segment -> endConnector.getIncoming().contains(segment)).findFirst().get();
// 3) Here we get the updated list of connections
EList<IConnection> connectionsAfter = new BasicEList<IConnection>(
((HierarchicElementBase)(EObject)getViewer().getRootElement()).getConnections());
// 4) We remove all existing ones
connectionsAfter.removeAll(connectionsBefore);
// 5) And we are left with the newly added one.
IConnection connection = connectionsAfter.stream().findFirst().get();
// Create handles
DiagramCoordinate startPosition =
......
/*-------------------------------------------------------------------------+
| Copyright 2020 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.controller;
import static org.fortiss.tooling.base.ui.utils.LayoutDataUIUtils.addConnectionPoint;
import org.eclipse.emf.common.util.BasicEList;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.fortiss.tooling.base.model.base.HierarchicElementBase;
import org.fortiss.tooling.base.model.element.IConnection;
import org.fortiss.tooling.base.model.element.IConnector;
import org.fortiss.tooling.base.model.layout.ILayoutedModelElement;
import org.fortiss.tooling.common.ui.javafx.lwfxef.DiagramCoordinate;
import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.IMVCBundle;
/**
* {@link LayoutedDiagramAnchorageController} for diagrams with curved links.
*
* @author munaro
*/
public class CurvedLinkLayoutedDiagramAnchorangeController<T extends IConnector & ILayoutedModelElement>
extends LayoutedDiagramAnchorageController<T> {
/** Constructor. */
public CurvedLinkLayoutedDiagramAnchorangeController(IMVCBundle mvcb, Class<T> modelType) {
super(mvcb, modelType);
}
/** {@inheritDoc} */
// TODO(3978): Resolve code duplication in the link-method of link visuals
@Override
protected void link(IMVCBundle startBundle, DiagramCoordinate startLocation,
IMVCBundle endBundle, DiagramCoordinate endLocation) {
// Disable direct links between hierarchic element bases
if(startBundle.getModel() instanceof HierarchicElementBase ||
endBundle.getModel() instanceof HierarchicElementBase) {
return;
}
// The call to `super.link` (see next lines) does not return a reference to the
// newly created connection. However, as it is needed in order to add the handles
// we get it by comparing the root element's connections before and after the
// creation of the new link:
// 1) Here we get the list of existing connections
EList<IConnection> connectionsBefore = new BasicEList<IConnection>(
((HierarchicElementBase)(EObject)getViewer().getRootElement()).getConnections());
// 2) Here we create the new connection
super.link(startBundle, startLocation, endBundle, endLocation);
// 3) Here we get the updated list of connections
EList<IConnection> connectionsAfter = new BasicEList<IConnection>(
((HierarchicElementBase)(EObject)getViewer().getRootElement()).getConnections());
// 4) We remove all existing ones
connectionsAfter.removeAll(connectionsBefore);
// 5) And we are left with the newly added one.
IConnection connection = connectionsAfter.stream().findFirst().get();
// Create handles
DiagramCoordinate startPosition =
new DiagramCoordinate(startBundle.getVisual().getCurrentBounds().getMaxX(),
startBundle.getVisual().getCurrentBounds().getMaxY());
DiagramCoordinate endPosition =
new DiagramCoordinate(endBundle.getVisual().getCurrentBounds().getMaxX(),
endBundle.getVisual().getCurrentBounds().getMaxY());
DiagramCoordinate middle =
new DiagramCoordinate((startPosition.getX() + endPosition.getX()) / 2,
(startPosition.getY() + endPosition.getY()) / 2);
addConnectionPoint((ILayoutedModelElement)connection, 0, (int)middle.getX(),
(int)middle.getY());
addConnectionPoint((ILayoutedModelElement)connection, 1, (int)middle.getX(),
(int)middle.getY());
}
}
CoordinateCorrections.java 018bf229e5686afcb8540b61dd9d05b6e4a23e93 GREEN
LayoutedCircularAnchorageContentVisualBase.java cd85ff478e9b8e6b6d6f6c75cc5bf61522a63f3e GREEN
LayoutedCircularAnchorageContentVisualBase.java bf71e5e84ede0c26bd0632e4218aae55ab915ade GREEN
LayoutedCircularAnchorageDiagramVisualBase.java 7634416bcb88a014d985143bf00a8d29ff1e3ff5 GREEN
LayoutedCurveLinkVisual.java 5b06cd7e80eaf7cf6af37a4769eaafe2a1e591f3 GREEN
LayoutedEllipticContentVisualBase.java 6f3daf386d5120793b90ce4569dd9bea33dd2a0f GREEN
......
......@@ -157,6 +157,6 @@ public abstract class LayoutedCircularAnchorageContentVisualBase<T extends ILayo
/** {@inheritDoc} */
@Override
public double getAngleInDegree() {
return toDegrees(getConnectorAngleAsDouble(getModelElement()));
return 360 - toDegrees(getConnectorAngleAsDouble(getModelElement()));
}
}
CircularResizableContentControllerBase.java daf05a58eac298462a5f092503e506575b31dff1 GREEN
CurveLinkBendPointControllerBase.java 4d119cd640b864f2193ea5c1a7f816310b7a57a4 GREEN
EllipticResizableContentControllerBase.java 42bcbdbf29c1cf2b71177e55f74358d1517d623f GREEN
EllipticResizableContentControllerBase.java 636f7c8683f90035d240411f96d1f40d504ffb19 GREEN
......@@ -68,7 +68,7 @@ public abstract class EllipticResizableContentControllerBase
@Override
protected void moveAnchorage(DiagramCoordinate delta) {
EllipticBorderLocation rbl = getBorderLocation(delta);
moveAnchorageToAngle(anchorage, rbl.getAngleInDegree());
moveAnchorageToAngle(anchorage, 360 - rbl.getAngleInDegree());
}
}
......
......@@ -6,7 +6,7 @@ EReferencePropertySectionBase.java 0548da6778516003257f59d0b4c2b60d458be3b6 GREE
EditorBase.java 9c09fff92945256bb8680992ae7bb2c78f47b150 GREEN
FXEditorBase.java 40caf638c7b4c02da5aece0d9d58883bce630e76 GREEN
IListPropertySection.java 8bb00fe7959583e794ff9437b7a77404c9a9e70f GREEN
LWFXEFEditorBase.java f6b160b700a0287021402b5702beb2bfdce3dc2e GREEN
LWFXEFEditorBase.java 86fb5b558794ffa6471ca343934592b6fa4277f6 GREEN
ModelEditorBindingBase.java b9b1a1c5a48a6e677d1f57ad55a6126d9703c4b5 GREEN
ModelElementHandlerBase.java d0efc1e9ca2fbbefb861f1ae8176ad9ec08a08a8 GREEN
MultiEObjectActionBase.java 9e237d8ea640c4194e4877af4a9cfce88698e543 GREEN
......
......@@ -27,6 +27,7 @@ import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.ui.IEditorPart;
import org.fortiss.tooling.common.ui.javafx.lwfxef.DiagramViewer;
import org.fortiss.tooling.common.ui.javafx.lwfxef.DiagramViewerFeatures;
import org.fortiss.tooling.common.ui.javafx.lwfxef.DiagramViewerSelection;
import org.fortiss.tooling.common.ui.javafx.lwfxef.change.Change;
import org.fortiss.tooling.common.ui.javafx.lwfxef.controller.IControllerFactory;
......@@ -68,6 +69,10 @@ public abstract class LWFXEFEditorBase<T extends EObject> extends FXEditorBase<T
viewer = new DiagramViewer(delegatingModelFactory, delegatingVisualFactory,
delegatingControllerFactory, cb -> modelSelected(), chg -> applyModelChange(chg));
DiagramViewerFeatures features = viewer.getFeatures();
// extend zoom factors
features.setZoomFactors(new double[] {0.5, 0.75, 1, 1.5, 2, 4, 6});
features.setZoomFactorIndex(2); // Zoom x1
customizeViewer();
return viewer.getVisualNode();
}
......
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