Skip to content
Snippets Groups Projects
Commit 0e3f10fd authored by Johannes Eder's avatar Johannes Eder
Browse files

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


Conflicts:
	org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/.ratings


Signed-off-by: default avatarJohannes Eder <eder@fortiss.org>
parents e26ac5ff 89bd5d19
No related branches found
No related tags found
1 merge request!853891: FOCUSer removal
Showing
with 442 additions and 147 deletions
...@@ -24,7 +24,9 @@ Export-Package: org.fortiss.tooling.base.ui, ...@@ -24,7 +24,9 @@ Export-Package: org.fortiss.tooling.base.ui,
org.fortiss.tooling.base.ui.editor, org.fortiss.tooling.base.ui.editor,
org.fortiss.tooling.base.ui.editor.annotations, org.fortiss.tooling.base.ui.editor.annotations,
org.fortiss.tooling.base.ui.editor.fx, org.fortiss.tooling.base.ui.editor.fx,
org.fortiss.tooling.base.ui.editor.fx.visuals, org.fortiss.tooling.base.ui.editor.fx.controller,
org.fortiss.tooling.base.ui.editor.fx.model,
org.fortiss.tooling.base.ui.editor.fx.visual,
org.fortiss.tooling.base.ui.editpart, org.fortiss.tooling.base.ui.editpart,
org.fortiss.tooling.base.ui.editpart.allocation, org.fortiss.tooling.base.ui.editpart.allocation,
org.fortiss.tooling.base.ui.editpart.command, org.fortiss.tooling.base.ui.editpart.command,
......
ContextMenuUtil.java 3e04dbd52ee99a59735d39b4087c55b07fb91076 GREEN ContextMenuUtil.java 3e04dbd52ee99a59735d39b4087c55b07fb91076 GREEN
EObjectBasedDiagramControllerBase.java b25bbbaa6eef3878b9aea73ca67d66de9beebb18 GREEN EObjectBasedDiagramControllerBase.java 3564ece9b3cac29caaf9201e0be3451a6a3c2b21 GREEN
EObjectBasedRectangularResizableContentControllerBase.java a263a6c123ee96015e0a5c37b6e3c13ebd0e8a75 GREEN EObjectBasedRectangularResizableContentControllerBase.java a263a6c123ee96015e0a5c37b6e3c13ebd0e8a75 GREEN
HierarchicModelElementModelChangeProvider.java 05217577a99d78038763bbcd841a032bb84f0553 GREEN EObjectModelChangeProvider.java 664e4db2e32124832682aff8235ac380ed4db1c0 GREEN
KernelServiceBasedModelChangeProviderBase.java 7c30347fb0c7cc4aacc79aeaf85167872afc1958 GREEN KernelServiceBasedModelChangeProviderBase.java 7c30347fb0c7cc4aacc79aeaf85167872afc1958 GREEN
LayoutModelElementModelChangeProvider.java 70c50b789c0088a7e5363bf662bc707a5b5ddf10 GREEN LayoutModelElementModelChangeProvider.java 70c50b789c0088a7e5363bf662bc707a5b5ddf10 GREEN
LayoutedModelElementBasedContentAnchorageController.java c4dfb9dbcd16078c63321d5dec13a902e4088949 GREEN LayoutedModelElementBasedContentAnchorageController.java c4dfb9dbcd16078c63321d5dec13a902e4088949 GREEN
......
ContextMenuUtil.java 7be87ce47b775d90c533078e22d4d445d9864caf GREEN
EObjectDiagramController.java 66b14c1c77953cad7caecae1e04f455958943f28 GREEN
EObjectModelChangeProvider.java f4b60cebb088a5c81ca92a41614e1a5d40030502 GREEN
EObjectRectangularResizableContentControllerBase.java 787a540213f29e8daaecd9afe98af8b3f4088db7 GREEN
KernelServiceBasedModelChangeProviderBase.java 18e48f17ea8dfba90de024a8959fc5a4b0d05d45 GREEN
LayoutModelChangeProvider.java b5449d02eaf39086909720c43e21bd061005fc9e GREEN
LayoutedContentAnchorageController.java 3794b41d76e9ce14ead0bd812cde5c1a6d348d5c GREEN
LayoutedDiagramAnchorageController.java 1e1ac7c5fa26c632736f5023e90f05d09bc0710d GREEN
LayoutedLinkBendPointController.java a8372485ae96f2abf773d1baeb1f8c7b2b25985f GREEN
LayoutedRectangularResizableContentController.java 1e18af3ee10dd3754325ed389fed664da65a0b61 GREEN
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
| See the License for the specific language governing permissions and | | See the License for the specific language governing permissions and |
| limitations under the License. | | limitations under the License. |
+--------------------------------------------------------------------------*/ +--------------------------------------------------------------------------*/
package org.fortiss.tooling.base.ui.editor.fx; package org.fortiss.tooling.base.ui.editor.fx.controller;
import static org.fortiss.tooling.base.utils.LayoutModelElementFactory.createPoint; import static org.fortiss.tooling.base.utils.LayoutModelElementFactory.createPoint;
......
...@@ -11,12 +11,13 @@ ...@@ -11,12 +11,13 @@
* Florian Hoelzl (fortiss GmbH) - initial implementation * Florian Hoelzl (fortiss GmbH) - initial implementation
* *
*******************************************************************************/ *******************************************************************************/
package org.fortiss.tooling.base.ui.editor.fx; package org.fortiss.tooling.base.ui.editor.fx.controller;
import static java.lang.Math.max; import static java.lang.Math.max;
import static org.fortiss.tooling.base.ui.editor.fx.ContextMenuUtil.createDisplayMenu; import static java.util.Objects.requireNonNull;
import static org.fortiss.tooling.base.ui.editor.fx.ContextMenuUtil.createElementCompositionContext; import static org.fortiss.tooling.base.ui.editor.fx.controller.ContextMenuUtil.createDisplayMenu;
import static org.fortiss.tooling.base.ui.editor.fx.ContextMenuUtil.createPrototypeMenu; import static org.fortiss.tooling.base.ui.editor.fx.controller.ContextMenuUtil.createElementCompositionContext;
import static org.fortiss.tooling.base.ui.editor.fx.controller.ContextMenuUtil.createPrototypeMenu;
import java.util.List; import java.util.List;
...@@ -26,7 +27,6 @@ import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.DiagramViewerFeatu ...@@ -26,7 +27,6 @@ import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.DiagramViewerFeatu
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.controller.base.ControllerBase; import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.controller.base.ControllerBase;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.model.IModelChangeProvider; import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.model.IModelChangeProvider;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.mvc.IMVCBundle; import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.mvc.IMVCBundle;
import org.fortiss.tooling.base.model.element.IHierarchicElement;
import org.fortiss.tooling.kernel.extension.data.IElementCompositionContext; import org.fortiss.tooling.kernel.extension.data.IElementCompositionContext;
import org.fortiss.tooling.kernel.service.IElementCompositorService; import org.fortiss.tooling.kernel.service.IElementCompositorService;
import org.fortiss.tooling.kernel.ui.service.IContextMenuService; import org.fortiss.tooling.kernel.ui.service.IContextMenuService;
...@@ -40,19 +40,20 @@ import javafx.scene.control.MenuItem; ...@@ -40,19 +40,20 @@ import javafx.scene.control.MenuItem;
* *
* @author hoelzl * @author hoelzl
*/ */
public abstract class EObjectBasedDiagramControllerBase extends ControllerBase { public class EObjectDiagramController<T extends EObject> extends ControllerBase {
/** The model change provider. */ /** The model change provider. */
private final HierarchicModelElementModelChangeProvider modelChangeProvider; private final EObjectModelChangeProvider modelChangeProvider;
/** Constructor. */ /** Constructor. */
public EObjectBasedDiagramControllerBase(IMVCBundle mvcb) { public EObjectDiagramController(IMVCBundle mvcb, Class<T> modelType) {
super(mvcb); super(mvcb);
if(!(getModel() instanceof IHierarchicElement)) { Object model = requireNonNull(mvcb.getModel(), "The given model is null!");
throw new IllegalArgumentException( if(!modelType.isAssignableFrom(model.getClass())) {
"Model element must be an instance of an IHierarchicElement."); throw new IllegalArgumentException("Expected model of type " +
modelType.getSimpleName() + ", but was " + model.getClass().getSimpleName());
} }
this.modelChangeProvider = this.modelChangeProvider = new EObjectModelChangeProvider(getModelElement());
new HierarchicModelElementModelChangeProvider(getHierarchicElement());
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
...@@ -61,10 +62,11 @@ public abstract class EObjectBasedDiagramControllerBase extends ControllerBase { ...@@ -61,10 +62,11 @@ public abstract class EObjectBasedDiagramControllerBase extends ControllerBase {
return modelChangeProvider; return modelChangeProvider;
} }
/** Returns the {@link IHierarchicElement} model element. */ /** Returns the {@link EObject} model element. */
protected IHierarchicElement getHierarchicElement() { @SuppressWarnings("unchecked")
protected T getModelElement() {
// wild cast works: see constructor check with exception // wild cast works: see constructor check with exception
return (IHierarchicElement)getModel(); return (T)getModel();
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
...@@ -76,7 +78,7 @@ public abstract class EObjectBasedDiagramControllerBase extends ControllerBase { ...@@ -76,7 +78,7 @@ public abstract class EObjectBasedDiagramControllerBase extends ControllerBase {
double y = max(features.getVerticalSpacing(), diagramLocation.getY()); double y = max(features.getVerticalSpacing(), diagramLocation.getY());
// wild cast works: see constructor exception // wild cast works: see constructor exception
EObject modelParent = getHierarchicElement(); T modelParent = getModelElement();
IElementCompositionContext edc = createElementCompositionContext(modelParent, x, y, true, IElementCompositionContext edc = createElementCompositionContext(modelParent, x, y, true,
getViewer().getFeatures().getCurrentZoomFactor()); getViewer().getFeatures().getCurrentZoomFactor());
List<MenuItem> result = createPrototypeMenu(modelParent, edc); List<MenuItem> result = createPrototypeMenu(modelParent, edc);
......
...@@ -13,34 +13,33 @@ ...@@ -13,34 +13,33 @@
| See the License for the specific language governing permissions and | | See the License for the specific language governing permissions and |
| limitations under the License. | | limitations under the License. |
+--------------------------------------------------------------------------*/ +--------------------------------------------------------------------------*/
package org.fortiss.tooling.base.ui.editor.fx; package org.fortiss.tooling.base.ui.editor.fx.controller;
import org.eclipse.emf.common.notify.Adapter; import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.notify.Notification; import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.impl.AdapterImpl; import org.eclipse.emf.common.notify.impl.AdapterImpl;
import org.fortiss.tooling.base.model.element.IHierarchicElement; import org.eclipse.emf.ecore.EObject;
/** /**
* An {@link KernelServiceBasedModelChangeProviderBase} for {@link IHierarchicElement}s. * An {@link KernelServiceBasedModelChangeProviderBase} for {@link EObject}s.
* *
* @author hoelzl * @author hoelzl
*/ */
final class HierarchicModelElementModelChangeProvider final class EObjectModelChangeProvider extends KernelServiceBasedModelChangeProviderBase<EObject> {
extends KernelServiceBasedModelChangeProviderBase<IHierarchicElement> {
/** The model element. */ /** The model element. */
private final IHierarchicElement modelElement; private final EObject modelElement;
/** The EMF notification listener. */ /** The EMF notification listener. */
private final HierarchicElementAdapter notificationListener; private final EObjectElementAdapter notificationListener;
/** Constructor. */ /** Constructor. */
public HierarchicModelElementModelChangeProvider(IHierarchicElement modelElement) { public EObjectModelChangeProvider(EObject modelElement) {
this.modelElement = modelElement; this.modelElement = modelElement;
this.notificationListener = new HierarchicElementAdapter(); this.notificationListener = new EObjectElementAdapter();
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
protected IHierarchicElement getModelElement() { protected EObject getModelElement() {
return modelElement; return modelElement;
} }
...@@ -50,8 +49,8 @@ final class HierarchicModelElementModelChangeProvider ...@@ -50,8 +49,8 @@ final class HierarchicModelElementModelChangeProvider
return notificationListener; return notificationListener;
} }
/** Specialized adapter listening to model changes of {@link IHierarchicElement}. */ /** Specialized adapter listening to model changes of {@link EObject}. */
private class HierarchicElementAdapter extends AdapterImpl { private class EObjectElementAdapter extends AdapterImpl {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public void notifyChanged(Notification event) { public void notifyChanged(Notification event) {
......
...@@ -11,11 +11,14 @@ ...@@ -11,11 +11,14 @@
* Florian Hoelzl (fortiss GmbH) - initial implementation * Florian Hoelzl (fortiss GmbH) - initial implementation
* *
*******************************************************************************/ *******************************************************************************/
package org.fortiss.tooling.base.ui.editor.fx; package org.fortiss.tooling.base.ui.editor.fx.controller;
import static java.lang.Math.max; import static java.lang.Math.max;
import static org.fortiss.tooling.base.ui.editor.fx.ContextMenuUtil.createElementCompositionContext; import static java.util.Objects.requireNonNull;
import static org.fortiss.tooling.base.ui.editor.fx.ContextMenuUtil.createPrototypeMenu; 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.editor.fx.controller.ContextMenuUtil.createElementCompositionContext;
import static org.fortiss.tooling.base.ui.editor.fx.controller.ContextMenuUtil.createPrototypeMenu;
import java.util.List; import java.util.List;
...@@ -25,9 +28,12 @@ import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.DiagramCoordinate; ...@@ -25,9 +28,12 @@ import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.DiagramCoordinate;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.DiagramViewerFeatures; import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.DiagramViewerFeatures;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.change.Change; import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.change.Change;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.controller.IClickController; import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.controller.IClickController;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.controller.IDragController;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.controller.base.ClickControllerBase; import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.controller.base.ClickControllerBase;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.controller.rectangular.RectangularContentAnchorageMoveController;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.controller.rectangular.RectangularResizableContentControllerBase; import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.controller.rectangular.RectangularResizableContentControllerBase;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.model.IModelChangeProvider; import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.model.IModelChangeProvider;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.mvc.IContentAnchorageMVCBundle;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.mvc.IContentMVCBundle; import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.mvc.IContentMVCBundle;
import org.fortiss.tooling.base.model.element.ElementPackage; import org.fortiss.tooling.base.model.element.ElementPackage;
import org.fortiss.tooling.base.model.layout.ILayoutedModelElement; import org.fortiss.tooling.base.model.layout.ILayoutedModelElement;
...@@ -37,6 +43,7 @@ import org.fortiss.tooling.kernel.ui.extension.IModelElementHandler; ...@@ -37,6 +43,7 @@ import org.fortiss.tooling.kernel.ui.extension.IModelElementHandler;
import org.fortiss.tooling.kernel.ui.service.IModelEditorBindingService; import org.fortiss.tooling.kernel.ui.service.IModelEditorBindingService;
import org.fortiss.tooling.kernel.ui.service.IModelElementHandlerService; import org.fortiss.tooling.kernel.ui.service.IModelElementHandlerService;
import javafx.geometry.Dimension2D;
import javafx.scene.Node; import javafx.scene.Node;
import javafx.scene.control.MenuItem; import javafx.scene.control.MenuItem;
import javafx.scene.input.MouseEvent; import javafx.scene.input.MouseEvent;
...@@ -47,28 +54,29 @@ import javafx.scene.input.MouseEvent; ...@@ -47,28 +54,29 @@ import javafx.scene.input.MouseEvent;
* *
* @author hoelzl * @author hoelzl
*/ */
public abstract class EObjectBasedRectangularResizableContentControllerBase public abstract class EObjectRectangularResizableContentControllerBase<T extends EObject>
extends RectangularResizableContentControllerBase { extends RectangularResizableContentControllerBase {
/** {@link IModelChangeProvider} for this controller */ /** {@link IModelChangeProvider} for this controller */
private final LayoutModelElementModelChangeProvider layoutModelChangeProvider; private final LayoutModelChangeProvider layoutModelChangeProvider;
/** The click controller handling double-click to open editor. */ /** The click controller handling double-click to open editor. */
private final IClickController openEditorDoubleClickController = new ClickControllerBase() { private final IClickController openEditorDoubleClickController = new ClickControllerBase() {
@Override @Override
public Change singleClick(MouseEvent event, Node node, DiagramCoordinate diagramLocation) { public Change singleClick(MouseEvent event, Node node, DiagramCoordinate diagramLocation) {
return EObjectBasedRectangularResizableContentControllerBase.super.getClickController( return EObjectRectangularResizableContentControllerBase.super.getClickController(node,
node, diagramLocation).singleClick(event, node, diagramLocation); diagramLocation).singleClick(event, node, diagramLocation);
} }
@Override @Override
public Change secondaryClick(MouseEvent event, Node node, public Change secondaryClick(MouseEvent event, Node node,
DiagramCoordinate diagramLocation) { DiagramCoordinate diagramLocation) {
return EObjectBasedRectangularResizableContentControllerBase.super.getClickController( return EObjectRectangularResizableContentControllerBase.super.getClickController(node,
node, diagramLocation).secondaryClick(event, node, diagramLocation); diagramLocation).secondaryClick(event, node, diagramLocation);
} }
@Override @Override
public Change doubleClick(MouseEvent event, Node node, DiagramCoordinate diagramLocation) { public Change doubleClick(MouseEvent event, Node node, DiagramCoordinate diagramLocation) {
EObject eo = getLayoutedME(); EObject eo = getModelElement();
IModelElementHandler<EObject> handler = IModelElementHandler<EObject> handler =
IModelElementHandlerService.getInstance().getModelElementHandler(eo); IModelElementHandlerService.getInstance().getModelElementHandler(eo);
if(handler != null) { if(handler != null) {
...@@ -80,18 +88,22 @@ public abstract class EObjectBasedRectangularResizableContentControllerBase ...@@ -80,18 +88,22 @@ public abstract class EObjectBasedRectangularResizableContentControllerBase
}; };
/** Constructor. */ /** Constructor. */
public EObjectBasedRectangularResizableContentControllerBase(IContentMVCBundle mvcb) { public EObjectRectangularResizableContentControllerBase(IContentMVCBundle mvcb,
Class<T> modelType) {
super(mvcb); super(mvcb);
if(!(mvcb.getModel() instanceof ILayoutedModelElement)) {
throw new IllegalArgumentException( Object model = requireNonNull(mvcb.getModel(), "The given model is null!");
"Model element must be an instance of an ILayoutedModelElement."); if(!modelType.isAssignableFrom(model.getClass())) {
throw new IllegalArgumentException("Expected model of type " +
modelType.getSimpleName() + ", but was " + model.getClass().getSimpleName());
} }
ILayoutedModelElement lme = (ILayoutedModelElement)mvcb.getModel(); ILayoutedModelElement lme = (ILayoutedModelElement)mvcb.getModel();
this.layoutModelChangeProvider = new LayoutModelElementModelChangeProvider(lme) { this.layoutModelChangeProvider = new LayoutModelChangeProvider(lme) {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
protected boolean acceptNotification(Notification notification) { protected boolean acceptNotification(Notification notification) {
if(notification.getNotifier() != getLayoutedME()) { if(notification.getNotifier() != getModelElement()) {
return false; return false;
} }
return isAnchorageFeature(notification.getFeature()); return isAnchorageFeature(notification.getFeature());
...@@ -99,10 +111,11 @@ public abstract class EObjectBasedRectangularResizableContentControllerBase ...@@ -99,10 +111,11 @@ public abstract class EObjectBasedRectangularResizableContentControllerBase
}; };
} }
/** Returns the {@link ILayoutedModelElement} model element. */ /** Returns the correctly casted model element. */
protected ILayoutedModelElement getLayoutedME() { @SuppressWarnings("unchecked")
protected T getModelElement() {
// wild cast works: see constructor check with exception // wild cast works: see constructor check with exception
return (ILayoutedModelElement)getModel(); return (T)getModel();
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
...@@ -111,6 +124,28 @@ public abstract class EObjectBasedRectangularResizableContentControllerBase ...@@ -111,6 +124,28 @@ public abstract class EObjectBasedRectangularResizableContentControllerBase
return layoutModelChangeProvider; return layoutModelChangeProvider;
} }
/** {@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 Dimension2D getMinimumSize() {
return new Dimension2D(DEFAULT_SHAPE_MINIMUM_WIDTH, DEFAULT_SHAPE_MINIMUM_HEIGHT);
}
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public List<MenuItem> contextMenuContributions(Node node, DiagramCoordinate diagramLocation) { public List<MenuItem> contextMenuContributions(Node node, DiagramCoordinate diagramLocation) {
...@@ -129,7 +164,7 @@ public abstract class EObjectBasedRectangularResizableContentControllerBase ...@@ -129,7 +164,7 @@ public abstract class EObjectBasedRectangularResizableContentControllerBase
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public void delete() { public void delete() {
IElementCompositorService.getInstance().decompose(getLayoutedME()); IElementCompositorService.getInstance().decompose(getModelElement());
} }
/** Checks whether the given feature corresponds to an anchorage model element. */ /** Checks whether the given feature corresponds to an anchorage model element. */
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
| See the License for the specific language governing permissions and | | See the License for the specific language governing permissions and |
| limitations under the License. | | limitations under the License. |
+--------------------------------------------------------------------------*/ +--------------------------------------------------------------------------*/
package org.fortiss.tooling.base.ui.editor.fx; package org.fortiss.tooling.base.ui.editor.fx.controller;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.EventObject; import java.util.EventObject;
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
| See the License for the specific language governing permissions and | | See the License for the specific language governing permissions and |
| limitations under the License. | | limitations under the License. |
+--------------------------------------------------------------------------*/ +--------------------------------------------------------------------------*/
package org.fortiss.tooling.base.ui.editor.fx; package org.fortiss.tooling.base.ui.editor.fx.controller;
import static org.fortiss.tooling.base.model.layout.LayoutPackage.ILAYOUTED_MODEL_ELEMENT__LAYOUT_DATA; import static org.fortiss.tooling.base.model.layout.LayoutPackage.ILAYOUTED_MODEL_ELEMENT__LAYOUT_DATA;
...@@ -26,11 +26,11 @@ import org.fortiss.tooling.base.model.layout.ILayoutedModelElement; ...@@ -26,11 +26,11 @@ import org.fortiss.tooling.base.model.layout.ILayoutedModelElement;
import org.fortiss.tooling.base.model.layout.LayoutPackage; import org.fortiss.tooling.base.model.layout.LayoutPackage;
/** /**
* An {@link KernelServiceBasedModelChangeProviderBase} for {@link ILayoutedModelElement}s. * A {@link KernelServiceBasedModelChangeProviderBase} for {@link ILayoutedModelElement}s.
* *
* @author hoelzl * @author hoelzl
*/ */
class LayoutModelElementModelChangeProvider class LayoutModelChangeProvider
extends KernelServiceBasedModelChangeProviderBase<ILayoutedModelElement> { extends KernelServiceBasedModelChangeProviderBase<ILayoutedModelElement> {
/** The layouted model element. */ /** The layouted model element. */
private final ILayoutedModelElement modelElement; private final ILayoutedModelElement modelElement;
...@@ -38,7 +38,7 @@ class LayoutModelElementModelChangeProvider ...@@ -38,7 +38,7 @@ class LayoutModelElementModelChangeProvider
private final LayoutModelElementAdapter notificationListener; private final LayoutModelElementAdapter notificationListener;
/** Constructor. */ /** Constructor. */
public LayoutModelElementModelChangeProvider(ILayoutedModelElement modelElement) { public LayoutModelChangeProvider(ILayoutedModelElement modelElement) {
this.modelElement = modelElement; this.modelElement = modelElement;
this.notificationListener = new LayoutModelElementAdapter(); this.notificationListener = new LayoutModelElementAdapter();
} }
......
...@@ -11,8 +11,9 @@ ...@@ -11,8 +11,9 @@
* Florian Hoelzl (fortiss GmbH) - initial implementation * Florian Hoelzl (fortiss GmbH) - initial implementation
* *
*******************************************************************************/ *******************************************************************************/
package org.fortiss.tooling.base.ui.editor.fx; package org.fortiss.tooling.base.ui.editor.fx.controller;
import static java.util.Objects.requireNonNull;
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_ALLOWED_TAG;
import static org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.DiagramViewerDefaultTags.LINK_TARGET_DENIED_TAG; import static org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.DiagramViewerDefaultTags.LINK_TARGET_DENIED_TAG;
...@@ -34,20 +35,23 @@ import org.fortiss.tooling.kernel.service.IElementCompositorService; ...@@ -34,20 +35,23 @@ import org.fortiss.tooling.kernel.service.IElementCompositorService;
* *
* @author hoelzl * @author hoelzl
*/ */
public class LayoutedModelElementBasedContentAnchorageController public class LayoutedContentAnchorageController<T extends ILayoutedModelElement>
extends DelegatingContentAnchorageController { extends DelegatingContentAnchorageController {
/** {@link IModelChangeProvider} for this controller */ /** {@link IModelChangeProvider} for this controller */
private final LayoutModelElementModelChangeProvider layoutModelChangeProvider; private final LayoutModelChangeProvider layoutModelChangeProvider;
/** Constructor. */ /** Constructor. */
public LayoutedModelElementBasedContentAnchorageController(IContentAnchorageMVCBundle mvcb) { public LayoutedContentAnchorageController(IContentAnchorageMVCBundle mvcb, Class<T> modelType) {
super(mvcb); super(mvcb);
if(!(mvcb.getModel() instanceof ILayoutedModelElement)) {
throw new IllegalArgumentException( Object model = requireNonNull(mvcb.getModel(), "The given model is null!");
"Model element must be an instance of an ILayoutedModelElement."); if(!modelType.isAssignableFrom(model.getClass())) {
throw new IllegalArgumentException("Expected model of type " +
modelType.getSimpleName() + ", but was " + model.getClass().getSimpleName());
} }
ILayoutedModelElement lme = (ILayoutedModelElement)mvcb.getModel(); ILayoutedModelElement lme = (ILayoutedModelElement)mvcb.getModel();
this.layoutModelChangeProvider = new LayoutModelElementModelChangeProvider(lme); this.layoutModelChangeProvider = new LayoutModelChangeProvider(lme);
} }
/** Returns the model element. */ /** Returns the model element. */
......
...@@ -11,8 +11,9 @@ ...@@ -11,8 +11,9 @@
* Florian Hoelzl (fortiss GmbH) - initial implementation * Florian Hoelzl (fortiss GmbH) - initial implementation
* *
*******************************************************************************/ *******************************************************************************/
package org.fortiss.tooling.base.ui.editor.fx; package org.fortiss.tooling.base.ui.editor.fx.controller;
import static java.util.Objects.requireNonNull;
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_ALLOWED_TAG;
import static org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.DiagramViewerDefaultTags.LINK_TARGET_DENIED_TAG; import static org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.DiagramViewerDefaultTags.LINK_TARGET_DENIED_TAG;
import static org.fortiss.tooling.base.utils.LayoutDataUtils.moveNode; import static org.fortiss.tooling.base.utils.LayoutDataUtils.moveNode;
...@@ -34,19 +35,23 @@ import org.fortiss.tooling.kernel.service.IElementCompositorService; ...@@ -34,19 +35,23 @@ import org.fortiss.tooling.kernel.service.IElementCompositorService;
* *
* @author hoelzl * @author hoelzl
*/ */
public class LayoutedModelElementBasedDiagramAnchorageController extends MoveControllerBase { public class LayoutedDiagramAnchorageController<T extends ILayoutedModelElement>
extends MoveControllerBase {
/** {@link IModelChangeProvider} for this controller */ /** {@link IModelChangeProvider} for this controller */
private final LayoutModelElementModelChangeProvider layoutModelChangeProvider; private final LayoutModelChangeProvider layoutModelChangeProvider;
/** Constructor. */ /** Constructor. */
public LayoutedModelElementBasedDiagramAnchorageController(IMVCBundle mvcb) { public LayoutedDiagramAnchorageController(IMVCBundle mvcb, Class<T> modelType) {
super(mvcb); super(mvcb);
if(!(mvcb.getModel() instanceof ILayoutedModelElement)) {
throw new IllegalArgumentException( Object model = requireNonNull(mvcb.getModel(), "The given model is null!");
"Model element must be an instance of an ILayoutedModelElement."); if(!modelType.isAssignableFrom(model.getClass())) {
throw new IllegalArgumentException("Expected model of type " +
modelType.getSimpleName() + ", but was " + model.getClass().getSimpleName());
} }
ILayoutedModelElement lme = (ILayoutedModelElement)mvcb.getModel(); ILayoutedModelElement lme = (ILayoutedModelElement)mvcb.getModel();
this.layoutModelChangeProvider = new LayoutModelElementModelChangeProvider(lme); this.layoutModelChangeProvider = new LayoutModelChangeProvider(lme);
} }
/** Returns the model element. */ /** Returns the model element. */
......
...@@ -11,8 +11,9 @@ ...@@ -11,8 +11,9 @@
* Florian Hoelzl (fortiss GmbH) - initial implementation * Florian Hoelzl (fortiss GmbH) - initial implementation
* *
*******************************************************************************/ *******************************************************************************/
package org.fortiss.tooling.base.ui.editor.fx; package org.fortiss.tooling.base.ui.editor.fx.controller;
import static java.util.Objects.requireNonNull;
import static org.fortiss.tooling.base.ui.utils.LayoutDataUIUtils.addConnectionPoint; import static org.fortiss.tooling.base.ui.utils.LayoutDataUIUtils.addConnectionPoint;
import static org.fortiss.tooling.base.ui.utils.LayoutDataUIUtils.getConnectionPoints; import static org.fortiss.tooling.base.ui.utils.LayoutDataUIUtils.getConnectionPoints;
import static org.fortiss.tooling.base.ui.utils.LayoutDataUIUtils.removeConnectionPoint; import static org.fortiss.tooling.base.ui.utils.LayoutDataUIUtils.removeConnectionPoint;
...@@ -37,24 +38,43 @@ import org.fortiss.tooling.kernel.service.IConnectionCompositorService; ...@@ -37,24 +38,43 @@ import org.fortiss.tooling.kernel.service.IConnectionCompositorService;
* *
* @author hoelzl * @author hoelzl
*/ */
public class LayoutedModelElementBasedLinkBendPointController extends LinkControllerBase { public class LayoutedLinkBendPointController<T extends ILayoutedModelElement>
extends LinkControllerBase {
/** {@link IModelChangeProvider} for this controller */ /** {@link IModelChangeProvider} for this controller */
private final LayoutModelElementModelChangeProvider layoutModelChangeProvider; private final LayoutModelChangeProvider layoutModelChangeProvider;
/** Constructor. */ /** Constructor. */
public LayoutedModelElementBasedLinkBendPointController(ILinkMVCBundle mvcb) { public LayoutedLinkBendPointController(ILinkMVCBundle mvcb, Class<T> modelType) {
super(mvcb); super(mvcb);
if(!(mvcb.getModel() instanceof ILayoutedModelElement)) {
throw new IllegalArgumentException( Object model = requireNonNull(mvcb.getModel(), "The given model is null!");
"Model element must be an instance of an ILayoutedModelElement."); if(!modelType.isAssignableFrom(model.getClass())) {
throw new IllegalArgumentException("Expected model of type " +
modelType.getSimpleName() + ", but was " + model.getClass().getSimpleName());
} }
ILayoutedModelElement lme = (ILayoutedModelElement)mvcb.getModel(); ILayoutedModelElement lme = (ILayoutedModelElement)mvcb.getModel();
this.layoutModelChangeProvider = new LayoutModelElementModelChangeProvider(lme); this.layoutModelChangeProvider = new LayoutModelChangeProvider(lme);
} }
/** Returns the model element. */ /** Returns the model element. */
public ILayoutedModelElement getLayoutedME() { @SuppressWarnings("unchecked")
return (ILayoutedModelElement)getModel(); public T getModelElement() {
return (T)getModel();
}
/** {@inheritDoc} */
@Override
protected boolean clampAndSnapBendPointToGridCenter() {
// disable default mode
return false;
}
/** {@inheritDoc} */
@Override
protected boolean clampAndSnapBendPointToGrid() {
// enable clamping mode
return true;
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
...@@ -66,7 +86,7 @@ public class LayoutedModelElementBasedLinkBendPointController extends LinkContro ...@@ -66,7 +86,7 @@ public class LayoutedModelElementBasedLinkBendPointController extends LinkContro
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
protected int getNumerOfBendPoints() { protected int getNumerOfBendPoints() {
return getBendPointList(getLayoutedME()).size(); return getBendPointList(getModelElement()).size();
} }
/** Returns the list of bend-points. */ /** Returns the list of bend-points. */
...@@ -79,13 +99,13 @@ public class LayoutedModelElementBasedLinkBendPointController extends LinkContro ...@@ -79,13 +99,13 @@ public class LayoutedModelElementBasedLinkBendPointController extends LinkContro
protected void createBendPointAt(int bpIndex, DiagramCoordinate location) { protected void createBendPointAt(int bpIndex, DiagramCoordinate location) {
int x = (int)location.getX(); int x = (int)location.getX();
int y = (int)location.getY(); int y = (int)location.getY();
addConnectionPoint(getLayoutedME(), bpIndex, x, y); addConnectionPoint(getModelElement(), bpIndex, x, y);
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
protected void updateModelAfterBendPointMove(int bpIndex, double dx, double dy) { protected void updateModelAfterBendPointMove(int bpIndex, double dx, double dy) {
List<Point> oldPoints = getBendPointList(getLayoutedME()); List<Point> oldPoints = getBendPointList(getModelElement());
Point point = oldPoints.get(bpIndex); Point point = oldPoints.get(bpIndex);
int oldX = point.getX(); int oldX = point.getX();
int oldY = point.getY(); int oldY = point.getY();
...@@ -98,7 +118,7 @@ public class LayoutedModelElementBasedLinkBendPointController extends LinkContro ...@@ -98,7 +118,7 @@ public class LayoutedModelElementBasedLinkBendPointController extends LinkContro
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
protected void deleteBendPoint(int bpIndex) { protected void deleteBendPoint(int bpIndex) {
removeConnectionPoint(getLayoutedME(), bpIndex); removeConnectionPoint(getModelElement(), bpIndex);
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
...@@ -111,7 +131,7 @@ public class LayoutedModelElementBasedLinkBendPointController extends LinkContro ...@@ -111,7 +131,7 @@ public class LayoutedModelElementBasedLinkBendPointController extends LinkContro
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
protected void deleteLink() { protected void deleteLink() {
IConnectionCompositorService.getInstance().disconnect(getLayoutedME()); IConnectionCompositorService.getInstance().disconnect(getModelElement());
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
......
/*-------------------------------------------------------------------------+
| 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.controller;
import static java.util.Objects.requireNonNull;
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.mvc.IContentAnchorageMVCBundle;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.mvc.IContentMVCBundle;
import org.fortiss.tooling.base.model.element.IConnector;
import org.fortiss.tooling.base.model.layout.Dimension;
import org.fortiss.tooling.base.model.layout.ILayoutedModelElement;
import javafx.geometry.Dimension2D;
import javafx.geometry.Side;
/**
* {@link IController} for {@link ILayoutedModelElement}s that have a rectangular shape.
*
* @author diewald
*/
public class LayoutedRectangularResizableContentController<T extends ILayoutedModelElement>
extends EObjectRectangularResizableContentControllerBase<T> {
/** Constructor. */
public LayoutedRectangularResizableContentController(IContentMVCBundle mvcb,
Class<T> modelType) {
super(mvcb, modelType);
Object model = requireNonNull(mvcb.getModel(), "The given model is null!");
if(!modelType.isAssignableFrom(model.getClass())) {
throw new IllegalArgumentException("Expected model of type " +
modelType.getSimpleName() + ", but was " + model.getClass().getSimpleName());
}
}
/** {@inheritDoc} */
@Override
protected void moveAnchorageToSideOffset(IContentAnchorageMVCBundle anchorage, Side side,
double offset) {
Object connObj = anchorage.getModel();
if(connObj instanceof IConnector && connObj instanceof ILayoutedModelElement) {
ILayoutedModelElement conn = (ILayoutedModelElement)connObj;
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(conn, convertSideToEOrientation(side), corrected);
}
}
/** {@inheritDoc} */
@Override
protected void move(FeedbackChange deltaChange) {
moveNode(getModelElement(), (int)deltaChange.getDeltaX(), (int)deltaChange.getDeltaY());
}
/** {@inheritDoc} */
@Override
protected void resize(FeedbackChange delta) {
T element = getModelElement();
Dimension d = getNodeSize(element);
int w = d.getWidth() + (int)delta.getDeltaW();
int h = d.getHeight() + (int)delta.getDeltaH();
setNodeSize(element, w, h);
}
}
HierarchicElementModelFactoryBase.java 9996bfc1402c27424f0ae69e64560acce0ef81f4 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.model;
import static java.util.Collections.emptyList;
import static java.util.Objects.requireNonNull;
import static org.fortiss.tooling.common.util.LambdaUtils.filterList;
import java.util.List;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.model.IModelFactory;
import org.fortiss.tooling.base.model.element.IConnection;
import org.fortiss.tooling.base.model.element.IHierarchicElement;
/**
* {@link IModelFactory} for {@link IHierarchicElement}s of editors.
*
* @author diewald
*/
public abstract class HierarchicElementModelFactoryBase<T extends IHierarchicElement>
implements IModelFactory {
/** The currently edited element. */
private final T rootElement;
/** Constructor. */
public HierarchicElementModelFactoryBase(T root) {
this.rootElement = requireNonNull(root);
}
/** {@inheritDoc} */
@Override
public T getRootModel() {
return rootElement;
}
/** {@inheritDoc} */
@Override
public List<?> getDiagramAnchorageModels() {
return rootElement.getConnectors();
}
/** {@inheritDoc} */
@Override
public List<?> getContentAnchorageModels(Object parent) {
if(parent instanceof IHierarchicElement) {
return ((IHierarchicElement)parent).getConnectors();
}
return emptyList();
}
/** {@inheritDoc} */
@Override
public List<?> getLinkModels() {
return filterList(rootElement.getConnections(),
c -> filterPartiallyInitializedConnections(c));
}
/** Checks whether the given connection is only partially initialized. */
private boolean filterPartiallyInitializedConnections(IConnection c) {
return c.getSource() != null && c.getTarget() != null && c.eContainer() != null;
}
/** {@inheritDoc} */
@Override
public Object getLinkStart(Object link) {
if(link instanceof IConnection) {
return ((IConnection)link).getSource();
}
return null;
}
/** {@inheritDoc} */
@Override
public Object getLinkEnd(Object link) {
if(link instanceof IConnection) {
return ((IConnection)link).getTarget();
}
return null;
}
/** {@inheritDoc} */
@Override
public Object getParent(Object element) {
// Not used at the moment, so return null.
return null;
}
/** {@inheritDoc} */
@Override
public void update() {
// Not used at the moment.
}
}
CoordinateCorrections.java c5cc475b45de38c56fc2e888a2d3093cd2efb52a GREEN
LayoutedCircularAnchorageContentVisualBase.java 2aa292444671bf644e37bc923b877c92de0235b1 GREEN
LayoutedCircularAnchorageDiagramVisualBase.java f06e3b908020408e3cd268a3c63edcd75ef74f8b GREEN
LayoutedLineLinkVisual.java feea85e0bd288590fbe06c152a8a8b138ea85ca2 GREEN
LayoutedRectangularContentVisualBase.java c2a3937b99284713e0bbcd3ce458874567b25ac5 GREEN
NamedLayoutedCircularAnchorageContentVisual.java c680002469ce897679fa5a3f4af51d1b19cb53d6 GREEN
NamedLayoutedCircularAnchorageDiagramVisual.java 714a176a0569a2049efb4009f710ca66bf3a57fb GREEN
NamedLayoutedLineLinkVisual.java e66e5b2aaa40fe8b22a292e175bb8f3af4539b9d GREEN
NamedLayoutedRectangularContentVisual.java 122e193ac587857d1dad23b42583a0bcf465f0d0 GREEN
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
| See the License for the specific language governing permissions and | | See the License for the specific language governing permissions and |
| limitations under the License. | | limitations under the License. |
+--------------------------------------------------------------------------*/ +--------------------------------------------------------------------------*/
package org.fortiss.tooling.base.ui.editor.fx.visuals; package org.fortiss.tooling.base.ui.editor.fx.visual;
import static org.fortiss.tooling.base.layout.DefaultLayoutConstants.DEFAULT_CONNECTOR_SIZE; import static org.fortiss.tooling.base.layout.DefaultLayoutConstants.DEFAULT_CONNECTOR_SIZE;
...@@ -27,14 +27,15 @@ import javafx.geometry.Dimension2D; ...@@ -27,14 +27,15 @@ import javafx.geometry.Dimension2D;
* This class contains corrections of {@link DefaultLayoutConstants}. * This class contains corrections of {@link DefaultLayoutConstants}.
* *
* @author hoelzl * @author hoelzl
* @author diewald
*/ */
class CoordinateCorrections { public class CoordinateCorrections {
/** The insets of the {@link RectangularContentVisualBase}s. */ /** The insets of the {@link RectangularContentVisualBase}s. */
/* package */ static final Dimension2D RECTANGLE_INSETS = public static final Dimension2D RECTANGLE_INSETS =
new Dimension2D(DEFAULT_CONNECTOR_SIZE / 2, DEFAULT_CONNECTOR_SIZE / 2); new Dimension2D(DEFAULT_CONNECTOR_SIZE / 2, DEFAULT_CONNECTOR_SIZE / 2);
/** The default size of {@link ContentAnchorageVisualBase}s. */ /** The default size of {@link ContentAnchorageVisualBase}s. */
/* package */ static final Dimension2D ANCHOR_DIMENSION = public static final Dimension2D ANCHOR_DIMENSION =
new Dimension2D(DEFAULT_CONNECTOR_SIZE, DEFAULT_CONNECTOR_SIZE); new Dimension2D(DEFAULT_CONNECTOR_SIZE, DEFAULT_CONNECTOR_SIZE);
/** The insets of the {@link ContentAnchorageVisualBase}s. */ /** The insets of the {@link ContentAnchorageVisualBase}s. */
/* package */ static final double ANCHOR_INSET = DEFAULT_CONNECTOR_SIZE / 4.5; public static final double ANCHOR_INSET = DEFAULT_CONNECTOR_SIZE / 4.5;
} }
...@@ -13,14 +13,14 @@ ...@@ -13,14 +13,14 @@
| See the License for the specific language governing permissions and | | See the License for the specific language governing permissions and |
| limitations under the License. | | limitations under the License. |
+--------------------------------------------------------------------------*/ +--------------------------------------------------------------------------*/
package org.fortiss.tooling.base.ui.editor.fx.visuals; package org.fortiss.tooling.base.ui.editor.fx.visual;
import static javafx.scene.paint.Color.BLACK; import static javafx.scene.paint.Color.BLACK;
import static javafx.scene.paint.Color.rgb; 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_ALLOWED_TAG;
import static org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.DiagramViewerDefaultTags.LINK_TARGET_DENIED_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.visual.CoordinateCorrections.ANCHOR_DIMENSION;
import static org.fortiss.tooling.base.ui.editor.fx.visuals.CoordinateCorrections.ANCHOR_INSET; import static org.fortiss.tooling.base.ui.editor.fx.visual.CoordinateCorrections.ANCHOR_INSET;
import static org.fortiss.tooling.base.ui.utils.LWFXEditorUtils.convertEOrientationToSide; import static org.fortiss.tooling.base.ui.utils.LWFXEditorUtils.convertEOrientationToSide;
import static org.fortiss.tooling.base.ui.utils.LayoutDataUIUtils.getConnectorOffsetOrientation; import static org.fortiss.tooling.base.ui.utils.LayoutDataUIUtils.getConnectorOffsetOrientation;
...@@ -46,26 +46,36 @@ import javafx.scene.paint.Paint; ...@@ -46,26 +46,36 @@ import javafx.scene.paint.Paint;
* *
* @author munaro * @author munaro
*/ */
public abstract class LayoutedCircularContentAnchorageVisualBase public abstract class LayoutedCircularAnchorageContentVisualBase<T extends ILayoutedModelElement>
extends CircularContentAnchorageVisualBase implements ISideLayout, IOffsetLayout { extends CircularContentAnchorageVisualBase implements ISideLayout, IOffsetLayout {
/** Constructor. */ /** Constructor. */
public LayoutedCircularContentAnchorageVisualBase(IContentAnchorageMVCBundle mvcb) { public LayoutedCircularAnchorageContentVisualBase(IContentAnchorageMVCBundle mvcb,
Class<T> modelType) {
super(mvcb); super(mvcb);
// TODO(#3877): Move type checks to a common base class. // TODO(#3877): Move type checks to a common base class.
Object model = mvcb.getModel(); Object model = mvcb.getModel();
if(!(model instanceof ILayoutedModelElement)) { if(model == null) {
throw new IllegalArgumentException( throw new IllegalArgumentException("The given model is null!");
"Expected model of type ILayoutedModelElement, but was " + }
model.getClass().getSimpleName() + "."); if(!modelType.isAssignableFrom(model.getClass())) {
throw new IllegalArgumentException("Expected model of type " +
modelType.getSimpleName() + ", but was " + model.getClass().getSimpleName());
} }
} }
/** Returns the model element in the correct type. */
@SuppressWarnings("unchecked")
protected T getModelElement() {
return (T)getModel();
}
/** {@inheritDoc} */ /** {@inheritDoc} */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public <T extends ILayout> T getLayout(Class<T> type) { public <S extends ILayout> S getLayout(Class<S> type) {
return (T)this; return (S)this;
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
...@@ -92,7 +102,7 @@ public abstract class LayoutedCircularContentAnchorageVisualBase ...@@ -92,7 +102,7 @@ public abstract class LayoutedCircularContentAnchorageVisualBase
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public double getOffset() { public double getOffset() {
OffsetOrientation offsetOrientation = getConnectorOffsetOrientation(getLayoutedModelElement()); OffsetOrientation offsetOrientation = getConnectorOffsetOrientation(getModelElement());
double inset = getDimensions().getWidth() / 2; double inset = getDimensions().getWidth() / 2;
return offsetOrientation.getOffset() - inset; return offsetOrientation.getOffset() - inset;
} }
...@@ -101,7 +111,7 @@ public abstract class LayoutedCircularContentAnchorageVisualBase ...@@ -101,7 +111,7 @@ public abstract class LayoutedCircularContentAnchorageVisualBase
@Override @Override
public Side getSide() { public Side getSide() {
// TODO (#3868): Remove null check. // TODO (#3868): Remove null check.
OffsetOrientation offsetOrientation = getConnectorOffsetOrientation(getLayoutedModelElement()); OffsetOrientation offsetOrientation = getConnectorOffsetOrientation(getModelElement());
EOrientation orientation = EOrientation.NORTH; EOrientation orientation = EOrientation.NORTH;
if(offsetOrientation != null) { if(offsetOrientation != null) {
orientation = offsetOrientation.getOrientation(); orientation = offsetOrientation.getOrientation();
...@@ -139,11 +149,4 @@ public abstract class LayoutedCircularContentAnchorageVisualBase ...@@ -139,11 +149,4 @@ public abstract class LayoutedCircularContentAnchorageVisualBase
} }
return super.getInteractionColor(); 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();
}
} }
...@@ -13,14 +13,14 @@ ...@@ -13,14 +13,14 @@
| See the License for the specific language governing permissions and | | See the License for the specific language governing permissions and |
| limitations under the License. | | limitations under the License. |
+--------------------------------------------------------------------------*/ +--------------------------------------------------------------------------*/
package org.fortiss.tooling.base.ui.editor.fx.visuals; package org.fortiss.tooling.base.ui.editor.fx.visual;
import static javafx.scene.paint.Color.BLACK; import static javafx.scene.paint.Color.BLACK;
import static javafx.scene.paint.Color.rgb; 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_ALLOWED_TAG;
import static org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.DiagramViewerDefaultTags.LINK_TARGET_DENIED_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.visual.CoordinateCorrections.ANCHOR_DIMENSION;
import static org.fortiss.tooling.base.ui.editor.fx.visuals.CoordinateCorrections.ANCHOR_INSET; import static org.fortiss.tooling.base.ui.editor.fx.visual.CoordinateCorrections.ANCHOR_INSET;
import static org.fortiss.tooling.base.utils.LayoutDataUtils.getNodePosition; 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.mvc.IDiagramAnchorageMVCBundle;
...@@ -39,26 +39,35 @@ import javafx.scene.paint.Paint; ...@@ -39,26 +39,35 @@ import javafx.scene.paint.Paint;
* *
* @author munaro * @author munaro
*/ */
public abstract class LayoutedCircularDiagramAnchorageVisualBase public abstract class LayoutedCircularAnchorageDiagramVisualBase<T extends ILayoutedModelElement>
extends CircularDiagramAnchorageVisualBase { extends CircularDiagramAnchorageVisualBase {
/** Constructor. */ /** Constructor. */
public LayoutedCircularDiagramAnchorageVisualBase( public LayoutedCircularAnchorageDiagramVisualBase(IDiagramAnchorageMVCBundle mvcb,
IDiagramAnchorageMVCBundle mvcb) { Class<T> modelType) {
super(mvcb); super(mvcb);
// TODO(#3877): Move type checks to a common base class. // TODO(#3877): Move type checks to a common base class.
Object model = mvcb.getModel(); Object model = mvcb.getModel();
if(!(model instanceof ILayoutedModelElement)) { if(model == null) {
throw new IllegalArgumentException( throw new IllegalArgumentException("The given model is null!");
"Expected model of type ILayoutedModelElement, but was " + }
model.getClass().getSimpleName()); if(!modelType.isAssignableFrom(model.getClass())) {
throw new IllegalArgumentException("Expected model of type " +
modelType.getSimpleName() + ", but was " + model.getClass().getSimpleName());
} }
} }
/** Returns the wrapped model as the expected type. */
@SuppressWarnings("unchecked")
protected T getModelElement() {
return (T)getModel();
}
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public Rectangle2D getModelBounds() { public Rectangle2D getModelBounds() {
Point p = getNodePosition(getLayoutedModelElement()); Point p = getNodePosition(getModelElement());
Dimension2D dim = getDimensions(); Dimension2D dim = getDimensions();
return new Rectangle2D(p.getX(), p.getY(), dim.getWidth(), dim.getHeight()); return new Rectangle2D(p.getX(), p.getY(), dim.getWidth(), dim.getHeight());
} }
...@@ -105,11 +114,4 @@ public abstract class LayoutedCircularDiagramAnchorageVisualBase ...@@ -105,11 +114,4 @@ public abstract class LayoutedCircularDiagramAnchorageVisualBase
} }
return super.getInteractionColor(); 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();
}
} }
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
| See the License for the specific language governing permissions and | | See the License for the specific language governing permissions and |
| limitations under the License. | | limitations under the License. |
+--------------------------------------------------------------------------*/ +--------------------------------------------------------------------------*/
package org.fortiss.tooling.base.ui.editor.fx.visuals; package org.fortiss.tooling.base.ui.editor.fx.visual;
import static java.util.Collections.emptyList; import static java.util.Collections.emptyList;
import static org.fortiss.tooling.base.ui.utils.LWFXEditorUtils.computeLinkToCircleLocation; import static org.fortiss.tooling.base.ui.utils.LWFXEditorUtils.computeLinkToCircleLocation;
...@@ -36,20 +36,33 @@ import javafx.geometry.Rectangle2D; ...@@ -36,20 +36,33 @@ import javafx.geometry.Rectangle2D;
* *
* @author munaro * @author munaro
*/ */
public abstract class LayoutedLineLinkVisualBase extends LineLinkVisualBase { // TODO (TM): As this class already requires the generic type to implement INamedElement
// NamedLayoutedLineLinkVisual becomes useless. Remove INamedElement here and make class
// abstract (consistent with the other Layouted*VisualBase classes)
public abstract class LayoutedLineLinkVisual<T extends ILayoutedModelElement>
extends LineLinkVisualBase {
/** Constructor. */ /** Constructor. */
public LayoutedLineLinkVisualBase(ILinkMVCBundle mvcb) { public LayoutedLineLinkVisual(ILinkMVCBundle mvcb, Class<T> modelType) {
super(mvcb); super(mvcb);
// TODO(#3877): Move type checks to a common base class. // TODO(#3877): Move type checks to a common base class.
Object model = mvcb.getModel(); Object model = mvcb.getModel();
if(!(model instanceof ILayoutedModelElement)) { if(model == null) {
throw new IllegalArgumentException( throw new IllegalArgumentException("The given model is null!");
"Expected model of type ILayoutedModelElement, but was " + }
model.getClass().getSimpleName()); if(!modelType.isAssignableFrom(model.getClass())) {
throw new IllegalArgumentException("Expected model of type " +
modelType.getSimpleName() + ", but was " + model.getClass().getSimpleName());
} }
} }
/** Returns the model element with the expected type. */
@SuppressWarnings("unchecked")
protected T getModelElement() {
return (T)getModel();
}
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public DiagramCoordinate getBendPointLocation(int bpIndex) { public DiagramCoordinate getBendPointLocation(int bpIndex) {
...@@ -85,7 +98,7 @@ public abstract class LayoutedLineLinkVisualBase extends LineLinkVisualBase { ...@@ -85,7 +98,7 @@ public abstract class LayoutedLineLinkVisualBase extends LineLinkVisualBase {
/** Returns the list of bend-points. */ /** Returns the list of bend-points. */
private List<Point> getBendPointList() { private List<Point> getBendPointList() {
Points connectionPoints = getConnectionPoints(getLayoutedModelElement()); Points connectionPoints = getConnectionPoints(getModelElement());
if(connectionPoints == null) { if(connectionPoints == null) {
return emptyList(); return emptyList();
} }
...@@ -107,11 +120,4 @@ public abstract class LayoutedLineLinkVisualBase extends LineLinkVisualBase { ...@@ -107,11 +120,4 @@ public abstract class LayoutedLineLinkVisualBase extends LineLinkVisualBase {
protected double getInvisibleSelectionLineWidth() { protected double getInvisibleSelectionLineWidth() {
return 3; 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();
}
} }
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