Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • af3/kernel
  • diewald/kernel
2 results
Show changes
Showing
with 339 additions and 387 deletions
/*-------------------------------------------------------------------------+
| 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.utils;
import static org.fortiss.tooling.base.utils.LayoutModelElementFactory.createPoint;
import static org.fortiss.tooling.kernel.service.IPrototypeService.PROTOTYPE_DATA_FORMAT;
import org.eclipse.emf.ecore.EObject;
import org.fortiss.tooling.base.dnd.ElementDropContext;
import org.fortiss.tooling.base.model.layout.Point;
import org.fortiss.tooling.common.ui.javafx.lwfxef.DiagramCoordinate;
import org.fortiss.tooling.kernel.extension.data.Prototype;
import org.fortiss.tooling.kernel.service.ICommandStackService;
import org.fortiss.tooling.kernel.service.IElementCompositorService;
import org.fortiss.tooling.kernel.service.IPrototypeService;
import javafx.scene.input.Dragboard;
/**
* Utility methods for JavaFX drag-and-drop.
*
* @author hoelzl
*/
public final class FXDNDUtils {
/** Returns whether element composition can be done via {@link IElementCompositorService}. */
public static boolean canCompose(Dragboard db, EObject container) {
Prototype proto = extractPrototype(db);
if(proto != null) {
return IElementCompositorService.getInstance().canCompose(container,
proto.getPrototypeCopy(), null);
}
return false;
}
/** Returns whether element composition can be done via {@link IElementCompositorService}. */
public static boolean canCompose(Dragboard db, DiagramCoordinate location, EObject container,
boolean isRootContainer, double zoom) {
Prototype proto = extractPrototype(db);
if(proto != null) {
ElementDropContext ctx =
createElementDropContext(location, container, isRootContainer, zoom);
return IElementCompositorService.getInstance().canCompose(container,
proto.getPrototypeCopy(), ctx);
}
return false;
}
/** Composes the elements using {@link IElementCompositorService}. */
public static boolean compose(Dragboard db, EObject container) {
Prototype proto = extractPrototype(db);
if(proto != null) {
EObject copy = proto.getPrototypeCopy();
return doElementComposition(container, copy, null);
}
return false;
}
/**
* Composes the elements using {@link IElementCompositorService} creating an
* {@link ElementDropContext} for the given location, root element, and zoom factor.
*/
public static boolean compose(Dragboard db, DiagramCoordinate location, EObject container,
boolean isRootContainer, double zoom) {
Prototype proto = extractPrototype(db);
if(proto != null) {
EObject copy = proto.getPrototypeCopy();
ElementDropContext ctx =
createElementDropContext(location, container, isRootContainer, zoom);
return doElementComposition(container, copy, ctx);
}
return false;
}
/** Delegates to {@link IElementCompositorService} in order to compose the elements. */
private static boolean doElementComposition(EObject container, EObject contained,
ElementDropContext context) {
IElementCompositorService ecs = IElementCompositorService.getInstance();
if(ecs.canCompose(container, contained, context)) {
ICommandStackService.getInstance().runAsCommand(container, () -> {
ecs.compose(container, contained, context);
});
return true;
}
return false;
}
/** Creates the {@link ElementDropContext} containing the drop location. */
private static ElementDropContext createElementDropContext(DiagramCoordinate location,
EObject container, boolean isRootContainer, double zoom) {
Point dcLocation = createPoint((int)location.getX(), (int)location.getY(), "");
ElementDropContext ctx =
new ElementDropContext(container, dcLocation, isRootContainer, zoom);
return ctx;
}
/** Extracts the prototype from the dragboard. */
private static Prototype extractPrototype(Dragboard db) {
Object data = db.getContent(PROTOTYPE_DATA_FORMAT);
if(data instanceof String) {
return IPrototypeService.getInstance().getPrototypeByUniqueID((String)data);
}
return null;
}
/** Constructor. */
private FXDNDUtils() {
// prevent instantiation
}
}
/*-------------------------------------------------------------------------+
| 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.utils;
import static java.lang.Math.atan2;
import static java.lang.Math.cos;
import static java.lang.Math.sin;
import org.fortiss.tooling.common.ui.javafx.lwfxef.DiagramCoordinate;
import org.fortiss.tooling.base.model.layout.EOrientation;
import javafx.geometry.Point2D;
import javafx.geometry.Rectangle2D;
import javafx.geometry.Side;
/**
* Utility methods for the JavaFX-based graphical LWFXEF editors.
*
* @author hoelzl
*/
public final class LWFXEditorUtils {
/** Computes the location of the link w.r.t. the given anchor bounds and target position. */
public static DiagramCoordinate computeLinkToAnchorLocation(Rectangle2D anchorBounds,
DiagramCoordinate target) {
double x = 0;
if(target.getX() < anchorBounds.getMinX()) {
x = -1.0;
} else if(target.getX() > anchorBounds.getMaxX()) {
x = 1.0;
}
double y = 0;
if(target.getY() < anchorBounds.getMinY()) {
y = -1.0;
} else if(target.getY() > anchorBounds.getMaxY()) {
y = 1.0;
}
double w2 = anchorBounds.getWidth() / 2;
double h2 = anchorBounds.getHeight() / 2;
x = anchorBounds.getMinX() + w2 + x * w2;
y = anchorBounds.getMinY() + h2 + y * h2;
return new DiagramCoordinate(x, y);
}
/** Returns the {@link EOrientation} for the given {@link Side}. */
public static EOrientation convertSideToEOrientation(Side s) {
switch(s) {
case TOP:
return EOrientation.NORTH;
case BOTTOM:
return EOrientation.SOUTH;
case LEFT:
return EOrientation.WEST;
case RIGHT:
return EOrientation.EAST;
}
return null;
}
/** Returns the {@link Side} for the given {@link EOrientation}. */
public static Side convertEOrientationToSide(EOrientation eo) {
switch(eo) {
case NORTH:
return Side.TOP;
case SOUTH:
return Side.BOTTOM;
case WEST:
return Side.LEFT;
case EAST:
return Side.RIGHT;
}
return null;
}
/**
* Returns the point on a circle centered in the current bounds intersecting with a line between
* the center point and the given point.
*/
public static DiagramCoordinate computeLinkToCircleLocation(Rectangle2D bounds,
Point2D target) {
double sx = bounds.getMinX() + bounds.getWidth() / 2;
double sy = bounds.getMinY() + bounds.getHeight() / 2;
double a = atan2(target.getY() - sy, target.getX() - sx);
double nx = sx + cos(a) * (bounds.getWidth() / 2 - 1);
double ny = sy + sin(a) * (bounds.getHeight() / 2 - 1);
return new DiagramCoordinate(nx, ny);
}
/** Constructor. */
private LWFXEditorUtils() {
// prevent instantiation
}
}
Subproject commit d117b3db1742a745f515d2b6c52cc9a02e57c299
Subproject commit 310d1c04f28f6252d5a02dd8fde1b76ae4a4da51
base.ecore 598ac2f27293be7344b762471a3570f45e63950d GREEN
base.ecore 6ba521f3458eaf64fc3ee0359e236c9a1201d259 GREEN
......@@ -181,26 +181,6 @@
<eGenericType eTypeParameter="#//element/IDerivedAnnotation/T"/>
</eOperations>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="IConstraintBasedProcess" abstract="true"
interface="true">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="Marker interface for metaclasses to describe constraint-based development processes.&#xD;&#xA;&#xD;&#xA;TODO (refs #3469) Clarify relation to constraint metaclasses in tooling.kernel."/>
</eAnnotations>
<eStructuralFeatures xsi:type="ecore:EReference" name="currentObjective" eType="#//element/ConstraintConfiguration"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="constraintInstanceContainer"
eType="ecore:EClass platform:/resource/org.fortiss.tooling.kernel/model/kernel.ecore#//constraints/IConstraintInstanceContainer"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="configurations" upperBound="-1"
eType="#//element/ConstraintConfiguration" containment="true"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="ConstraintConfiguration" eSuperTypes="platform:/resource/org.fortiss.tooling.kernel/model/kernel.ecore#//INamedElement">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="Hierarchical description of constraint configuration.&#xD;&#xA;&#xD;&#xA;TODO (refs #3469): Clarify relation to constraint metaclasses in tooling.kernel."/>
</eAnnotations>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="activeConstraints" upperBound="-1"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="includedConfigurations"
upperBound="-1" eType="#//element/ConstraintConfiguration"/>
</eClassifiers>
</eSubpackages>
<eSubpackages name="layout" nsURI="http://www.fortiss.org/tooling/base/model/layout"
nsPrefix="org-fortiss-tooling-base-model-layout">
......@@ -478,16 +458,6 @@
<eTypeArguments eTypeParameter="#//base/DerivedAnnotationBase/T"/>
</eGenericSuperTypes>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="ConstraintInstanceContainer" eSuperTypes="platform:/resource/org.fortiss.tooling.kernel/model/kernel.ecore#//constraints/IConstraintInstanceContainer">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="@deprecated Currently unused. TODO (refs #3469) Caveat: Base class is defined in tooling.kernel."/>
</eAnnotations>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="ConstraintBasedProcess" eSuperTypes="#//element/IConstraintBasedProcess">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="Base class for {@link IConstraintBasedProcess}es.&#xD;&#xA;&#xD;&#xA;TODO (refs #3469): Clarify relation to constraint metaclasses in tooling.kernel."/>
</eAnnotations>
</eClassifiers>
</eSubpackages>
<eSubpackages name="visualization" nsURI="http://www.fortiss.org/tooling/base/model/visualization"
nsPrefix="org-fortiss-tooling-base-model-visualization">
......
......@@ -58,18 +58,6 @@
<genOperations ecoreOperation="base.ecore#//element/IDerivedAnnotation/isUserAnnotatedValuePreferred"/>
<genOperations ecoreOperation="base.ecore#//element/IDerivedAnnotation/getUserAnnotatedValue"/>
</genClasses>
<genClasses image="false" ecoreClass="base.ecore#//element/IConstraintBasedProcess">
<genFeatures notify="false" createChild="false" propertySortChoices="true"
ecoreFeature="ecore:EReference base.ecore#//element/IConstraintBasedProcess/currentObjective"/>
<genFeatures notify="false" createChild="false" propertySortChoices="true"
ecoreFeature="ecore:EReference base.ecore#//element/IConstraintBasedProcess/constraintInstanceContainer"/>
<genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference base.ecore#//element/IConstraintBasedProcess/configurations"/>
</genClasses>
<genClasses image="false" ecoreClass="base.ecore#//element/ConstraintConfiguration">
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute base.ecore#//element/ConstraintConfiguration/activeConstraints"/>
<genFeatures notify="false" createChild="false" propertySortChoices="true"
ecoreFeature="ecore:EReference base.ecore#//element/ConstraintConfiguration/includedConfigurations"/>
</genClasses>
</nestedGenPackages>
<nestedGenPackages prefix="Layout" basePackage="org.fortiss.tooling.base.model"
disposableProviderFactory="true" ecorePackage="base.ecore#//layout">
......@@ -172,8 +160,6 @@
<genOperations ecoreOperation="base.ecore#//base/DerivedAnnotationBase/getUserAnnotatedValue"
body="return null;"/>
</genClasses>
<genClasses ecoreClass="base.ecore#//base/ConstraintInstanceContainer"/>
<genClasses ecoreClass="base.ecore#//base/ConstraintBasedProcess"/>
</nestedGenPackages>
<nestedGenPackages prefix="Visualization" basePackage="org.fortiss.tooling.base.model"
disposableProviderFactory="true" ecorePackage="base.ecore#//visualization">
......
AddMissingAnnotationsMigrationProvider.java a3f2b3cbcd39f85e15bc998650f899f55d9f563e GREEN
RemoveDuplicatedAnnotationsMigrationProvider.java f1bdb4733d5b9c6003a2b7fee59b89240a0a3b61 GREEN
RemoveOutdatedAnnotationInstanceMigrationProvider.java 29c29f2bb7515cad1de45a30ffc185001b47a016 GREEN
AddMissingAnnotationsMigrationProvider.java ebc5b9348b61ffb23493942949ecccf1c1fa2ae1 GREEN
RemoveDuplicatedAnnotationsMigrationProvider.java 6920909f8f211b9c5b5990644b5abcd8c4abaa3a GREEN
RemoveOutdatedAnnotationInstanceMigrationProvider.java 245530d6026f9ff29ffc577983d9de03ae5e75e5 GREEN
......@@ -15,6 +15,7 @@
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.base.migration;
import static java.util.Collections.emptyMap;
import static org.fortiss.tooling.base.utils.AnnotationUtils.instantiateAnnotationsRecursive;
import java.util.ArrayList;
......@@ -49,9 +50,11 @@ public class AddMissingAnnotationsMigrationProvider implements IMigrationProvide
/** {@inheritDoc} */
@Override
public void migrate(ITopLevelElement modelElement, Map<EObject, AnyType> unknownFeatures) {
public Map<EObject, AnyType> migrate(ITopLevelElement modelElement,
Map<EObject, AnyType> unknownFeatures) {
EObject rootElement = modelElement.getRootModelElement();
instantiateAnnotationsRecursive(rootElement);
migratedProjects.add(modelElement);
return emptyMap();
}
}
......@@ -6,6 +6,7 @@ ConstraintsBaseUtils.java bba938b43756ce6f35c338f6cef21c3ab5d49a9d GREEN
DimensionUtils.java 0dc67f9de11a84e6e4c6e1eb627817dee91ff30a GREEN
EllipseLayoutUtils.java 5c3a0126fdca5d5b4fb441694747e1cb0f49cd9f GREEN
LayoutDataUtils.java 5739dd16f0212e8f94927c0a0f51503390f2be69 GREEN
LayoutModelElementAdapter.java d81dfc551baa832f2761b4804760dcd8f57b7c5b YELLOW
LayoutModelElementFactory.java c49fca2de5a8cb7502fb28cc2b7e64a272df11b0 GREEN
MigrationUtils.java ab9d8682233313c21c6a52b8b03e1c796aacd29c GREEN
OffsetOrientationUtils.java 913cebbac2a5628bdd08b4df669b9412d6e07d94 GREEN
......
Subproject commit d117b3db1742a745f515d2b6c52cc9a02e57c299
Subproject commit 310d1c04f28f6252d5a02dd8fde1b76ae4a4da51
AF3FXViewPart.java 865b996b5eb092bb30c161d026163a0f8fc66c41 GREEN
AF3FXViewPart.java 3e4510f9e9f86ecf5ba29432342acd50e030aaaa GREEN