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
Commits on Source (203)
Showing
with 1566 additions and 1217 deletions
Subproject commit d117b3db1742a745f515d2b6c52cc9a02e57c299
Subproject commit 310d1c04f28f6252d5a02dd8fde1b76ae4a4da51
......@@ -17,13 +17,15 @@ Export-Package: org.fortiss.tooling.base.ui,
org.fortiss.tooling.base.ui.annotation.view,
org.fortiss.tooling.base.ui.annotation.view.generic,
org.fortiss.tooling.base.ui.annotation.view.generic.filter,
org.fortiss.tooling.base.ui.compose,
org.fortiss.tooling.base.ui.contentprovider,
org.fortiss.tooling.base.ui.dialog,
org.fortiss.tooling.base.ui.dnd.gef,
org.fortiss.tooling.base.ui.dnd.jface,
org.fortiss.tooling.base.ui.editor,
org.fortiss.tooling.base.ui.editor.annotations,
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.allocation,
org.fortiss.tooling.base.ui.editpart.command,
......
ConstraintBasedProcessCompositor.java 6b98bc9c8096ff6553ffc49040a0919dadb20bae GREEN
/*-------------------------------------------------------------------------+
| Copyright 2017 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;
import static org.eclipse.jface.resource.FontDescriptor.createFrom;
import org.eclipse.jface.resource.FontDescriptor;
import org.eclipse.jface.viewers.StyledString.Styler;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.TextStyle;
import org.eclipse.swt.widgets.Display;
import org.fortiss.tooling.base.model.element.ConstraintConfiguration;
import org.fortiss.tooling.kernel.extension.IConstraint;
// TODO Refactor together with ConstraintBasedProcessEditor and provide a dedicated perspective (see #3189)
/**
* This class is a helper class that provides, 1) the colors for the constraint groups,
* 2) manage the references between the constraint configurations and
* 3) manages the tree manipulation that is used to visualize the constraintsGroups,
* constraintConfigurations and constraints.
*
* @author abid
*
*/
public class ConstraintBasedProcessEditorHelper {
/** Color Array for at least seven groups. */
private static int[] colorArray =
{SWT.COLOR_DARK_GREEN, SWT.COLOR_DARK_BLUE, SWT.COLOR_DARK_YELLOW, SWT.COLOR_BLACK,
SWT.COLOR_DARK_RED, SWT.COLOR_GREEN, SWT.COLOR_CYAN};
/** Counter for the colorArray */
private static int colorCtr = 0;
/** Reference to a constraint configuration. */
private static class WithContextualConfiguration {
/** Contextual constraint configuration. */
ConstraintConfiguration config;
/** Constructor. */
public WithContextualConfiguration(ConstraintConfiguration config) {
this.config = config;
}
}
/** Constraint accompanied with a configuration providing the context. */
public static class ConstraintWithContextualConfiguration extends WithContextualConfiguration {
/** Constraint. */
/* package */Class<? extends IConstraint> cstr;
/** Constructor. */
public ConstraintWithContextualConfiguration(Class<? extends IConstraint> cstr,
ConstraintConfiguration config) {
super(config);
this.cstr = cstr;
}
}
/**
* Configuration accompanied with another configuration providing the context.
* Intent is that the contained configuration is a dependency of the context one.
*/
public static class ConfigurationRefWithContextualConfiguration
extends WithContextualConfiguration {
/** Constraint. */
/* package */ConstraintConfiguration target;
/** Constructor. */
public ConfigurationRefWithContextualConfiguration(ConstraintConfiguration configRef,
ConstraintConfiguration config) {
super(config);
this.target = configRef;
}
/** {@inheritDoc} */
@Override
public boolean equals(Object obj) {
if(obj instanceof ConfigurationRefWithContextualConfiguration) {
// current target name
String currentTargetName = this.target.getName();
// contextualRef Target of the configuration
String configRefTrgtObjName =
((ConfigurationRefWithContextualConfiguration)obj).target.getName();
// current configuration
String currentConfigName = this.config.getName();
// contextualRef Object of the configuration
String configRefObjName =
((ConfigurationRefWithContextualConfiguration)obj).config.getName();
return currentTargetName.equalsIgnoreCase(configRefTrgtObjName) &&
currentConfigName.equalsIgnoreCase(configRefObjName);
}
return false;
}
/** {@inheritDoc} */
@Override
public int hashCode() {
return target.hashCode();
}
}
/** Class to manipulate and store parent of elements. */
public static class TreeStructureNode {
/** Parent object variable. */
/* package */Object parent;
/** Data object variable. */
/* package */Object data;
/** Constructor. */
public TreeStructureNode(Object parent, Object children) {
this.parent = parent;
this.data = children;
}
/** {@inheritDoc} */
@Override
public boolean equals(Object obj) {
if(obj instanceof TreeStructureNode) {
// the current tree node to be compared with
String currentStructureNode = this.data.toString();
// the tree node to be checked
String treeStructureNode = ((TreeStructureNode)obj).data.toString();
// parent of the current tree node
String currentParentNode = this.parent.toString();
// parent of the object that needs to be checked
String objectParentNode = ((TreeStructureNode)obj).parent.toString();
return currentStructureNode.equalsIgnoreCase(treeStructureNode) &&
currentParentNode.equalsIgnoreCase(objectParentNode);
}
return false;
}
/** {@inheritDoc} */
@Override
public int hashCode() {
return parent.hashCode();
}
}
/** Styler class to create colored bold labels for constraint group name. */
public static class NormalFontStyler extends Styler {
/** Counter to keep track of currently used color in color array. */
private int colorIndex = 0;
/** Constructor. */
public NormalFontStyler() {
this.colorIndex = colorCtr;
}
/** {@inheritDoc} */
@Override
public void applyStyles(final TextStyle textStyle) {
FontDescriptor boldDescriptor = createFrom(new FontData()).setStyle(SWT.BOLD);
Font boldFont = boldDescriptor.createFont(Display.getCurrent());
textStyle.font = boldFont;
textStyle.foreground = Display.getCurrent().getSystemColor(colorArray[colorIndex]);
}
}
/** Styler class to create red color labels. */
public static class RedFontStyler extends Styler {
/** {@inheritDoc} */
@Override
public void applyStyles(final TextStyle textStyle) {
FontDescriptor boldDescriptor = createFrom(new FontData()).setStyle(SWT.BOLD);
Font boldFont = boldDescriptor.createFont(Display.getCurrent());
textStyle.font = boldFont;
textStyle.foreground = Display.getCurrent().getSystemColor(SWT.COLOR_DARK_RED);
}
}
/** Styler class to create green color labels. */
public static class GreenFontStyler extends Styler {
/** {@inheritDoc} */
@Override
public void applyStyles(final TextStyle textStyle) {
FontDescriptor boldDescriptor = createFrom(new FontData()).setStyle(SWT.BOLD);
Font boldFont = boldDescriptor.createFont(Display.getCurrent());
textStyle.font = boldFont;
textStyle.foreground = Display.getCurrent().getSystemColor(SWT.COLOR_DARK_GREEN);
}
}
/**
* This function is responsible for updating the color of the constraints groups as they are
* added by updating the color counter (i.e., ColorCtr)
*
* @param groupSize
* is the size of the constraints groups
*/
public static void adjustColorIndex(int groupSize) {
colorCtr++;
colorCtr %= groupSize;
}
}
ContextMenuUtil.java 405387151d45b09dffb3b6ba44f980313c8edcaf GREEN
CurvedLinkLayoutedContentAnchorangeController.java 67c20e31ddb82fe2fd499117193353b0545839a0 GREEN
EObjectDiagramController.java 2b253941592ee25ead95223470f983f23ef9776f GREEN
EObjectEllipticResizableContentControllerBase.java 7c862a03b97d2f2cfdcc2fcee7434de2e1e257d2 GREEN
EObjectModelChangeProvider.java f4b60cebb088a5c81ca92a41614e1a5d40030502 GREEN
EObjectRectangularResizableContentControllerBase.java 28a17bf87f6a7222d927bc1c6b80967cb14b5f03 GREEN
KernelServiceBasedModelChangeProviderBase.java 8d1f8ef79ecd383ff74e5a2bbcf24345aabe70af GREEN
LayoutModelChangeProvider.java b5449d02eaf39086909720c43e21bd061005fc9e GREEN
LayoutedContentAnchorageController.java 9fc513a7404277514c730f7702d45588f2d81878 GREEN
LayoutedCurveLinkBendPointController.java 54d7c294c4afaeadb6787408fbfe2ca1958c2de0 GREEN
LayoutedDiagramAnchorageController.java 32d7d77daf252d021458c39ebcfe502f26f29a98 GREEN
LayoutedEllipticResizableContentController.java 93bdeb7ecd5f7386724a9d7df5fff3174ab8ce10 GREEN
LayoutedLineLinkBendPointController.java f5fac4fe8e4b4c0259407acb6bfc80dbe9c3a1fb GREEN
LayoutedLinkBendPointController.java 3203d946de233274934dca1bcd47bbdc1d0a3b13 GREEN
LayoutedRectangularResizableContentController.java 3232d423572924363702898cf8ba240ce7042b65 GREEN
ModelElementFXEditorUIProviderBase.java b81bf7fc945d40f1f842876f07ba70799ab65f6d 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.controller;
import static org.fortiss.tooling.base.utils.LayoutModelElementFactory.createPoint;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.emf.ecore.EObject;
import org.fortiss.tooling.common.ui.javafx.lwfxef.DiagramViewer;
import org.fortiss.tooling.common.ui.javafx.lwfxef.DiagramViewerFeatures;
import org.fortiss.tooling.base.dnd.ElementDropContext;
import org.fortiss.tooling.base.model.layout.Point;
import org.fortiss.tooling.kernel.extension.data.IElementCompositionContext;
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.control.Menu;
import javafx.scene.control.MenuItem;
/**
* Helper class for creating context menus.
*
* @author hoelzl
*/
public final class ContextMenuUtil {
/** Creates the menu populated with composable prototypes. */
public static List<MenuItem> createPrototypeMenu(EObject target,
IElementCompositionContext context) {
IPrototypeService pers = IPrototypeService.getInstance();
IElementCompositorService ecs = IElementCompositorService.getInstance();
ICommandStackService css = ICommandStackService.getInstance();
List<MenuItem> result = new ArrayList<>();
Menu newMenu = new Menu("New ...");
List<Prototype> protos = pers.getComposablePrototypes(target.getClass());
for(Prototype p : protos) {
EObject prototypeCopy = p.getPrototypeCopy();
if(ecs.canCompose(target, prototypeCopy, context)) {
MenuItem mi = new MenuItem(p.getName());
mi.setOnAction(evt -> {
css.runAsCommand(target, () -> {
ecs.compose(target, prototypeCopy, context);
});
});
newMenu.getItems().add(mi);
}
}
if(!newMenu.getItems().isEmpty()) {
result.add(newMenu);
}
return result;
}
/** Creates the element composition context. */
public static IElementCompositionContext createElementCompositionContext(EObject target,
double x, double y, boolean isRoot, double zoom) {
Point loc = createPoint((int)x, (int)y, "CompositionPoint");
return new ElementDropContext(target, loc, isRoot, zoom);
}
/** Returns the default display menu for interaction with diagram viewer features. */
public static Menu createDisplayMenu(DiagramViewer viewer) {
Menu menu = new Menu("Display ...");
DiagramViewerFeatures features = viewer.getFeatures();
// link highlighting
if(features.isLinkHighlightingEnabled()) {
MenuItem disableLinkHighlighting = new MenuItem("Disable Link Highlighting");
disableLinkHighlighting.setOnAction(evt -> {
features.setLinkHighlightingEnabled(false);
});
menu.getItems().add(disableLinkHighlighting);
} else {
MenuItem enableLinkHighlighting = new MenuItem("Enable Link Highlighting");
enableLinkHighlighting.setOnAction(evt -> {
features.setLinkHighlightingEnabled(true);
});
menu.getItems().add(enableLinkHighlighting);
}
// interaction area shading
if(features.isInteractionAreaShadingEnabled()) {
MenuItem disableInteractionShading = new MenuItem("Disable Interactive Area Shading");
disableInteractionShading.setOnAction(evt -> {
features.setInteractionAreaShadingEnabled(false);
});
menu.getItems().add(disableInteractionShading);
} else {
MenuItem enableInteractionShading = new MenuItem("Enable Interactive Area Shading");
enableInteractionShading.setOnAction(evt -> {
features.setInteractionAreaShadingEnabled(true);
});
menu.getItems().add(enableInteractionShading);
}
return menu;
}
}
/*-------------------------------------------------------------------------+
| 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.fortiss.tooling.base.model.base.EntryConnectorBase;
import org.fortiss.tooling.base.model.base.ExitConnectorBase;
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.controller.base.DelegatingContentAnchorageController;
import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.IContentAnchorageMVCBundle;
import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.IMVCBundle;
/**
* {@link DelegatingContentAnchorageController} for diagrams with curved links.
*
* @author munaro
*/
public class CurvedLinkLayoutedContentAnchorangeController<T extends IConnector & ILayoutedModelElement>
extends LayoutedContentAnchorageController<T> {
/** Constructor. */
public CurvedLinkLayoutedContentAnchorangeController(IContentAnchorageMVCBundle mvcb,
Class<T> modelType) {
super(mvcb, modelType);
}
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override
protected void link(IMVCBundle startBundle, DiagramCoordinate startLocation,
IMVCBundle endBundle, DiagramCoordinate endLocation) {
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();
// 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());
}
}
/*******************************************************************************
* Copyright (c) 2017, 2018 fortiss GmbH.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v2.0 which is available at
* http://www.eclipse.org/legal/epl-v20.html
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Florian Hoelzl (fortiss GmbH) - initial implementation
*
*******************************************************************************/
package org.fortiss.tooling.base.ui.editor.fx.controller;
import static java.lang.Math.max;
import static java.util.Objects.requireNonNull;
import static org.fortiss.tooling.base.ui.editor.fx.controller.ContextMenuUtil.createDisplayMenu;
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 static org.fortiss.tooling.base.ui.utils.FXDNDUtils.canCompose;
import static org.fortiss.tooling.base.ui.utils.FXDNDUtils.compose;
import java.util.List;
import org.eclipse.emf.ecore.EObject;
import org.fortiss.tooling.common.ui.javafx.lwfxef.DiagramCoordinate;
import org.fortiss.tooling.common.ui.javafx.lwfxef.DiagramViewerFeatures;
import org.fortiss.tooling.common.ui.javafx.lwfxef.controller.base.ControllerBase;
import org.fortiss.tooling.common.ui.javafx.lwfxef.model.IModelChangeProvider;
import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.IMVCBundle;
import org.fortiss.tooling.kernel.extension.data.IElementCompositionContext;
import org.fortiss.tooling.kernel.service.IElementCompositorService;
import org.fortiss.tooling.kernel.ui.service.IContextMenuService;
import javafx.scene.Node;
import javafx.scene.control.MenuItem;
import javafx.scene.input.Dragboard;
/**
* Diagram controller that uses the {@link IElementCompositorService} to create context menu
* entries for prototypes provided by the {@link IContextMenuService}.
*
* @author hoelzl
*/
public class EObjectDiagramController<T extends EObject> extends ControllerBase {
/** The model change provider. */
private final EObjectModelChangeProvider modelChangeProvider;
/** Constructor. */
public EObjectDiagramController(IMVCBundle mvcb, Class<T> modelType) {
super(mvcb);
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());
}
this.modelChangeProvider = new EObjectModelChangeProvider(getModelElement());
}
/** {@inheritDoc} */
@Override
public IModelChangeProvider getModelChangeProvider() {
return modelChangeProvider;
}
/** Returns the {@link EObject} model element. */
@SuppressWarnings("unchecked")
protected T getModelElement() {
// wild cast works: see constructor check with exception
return (T)getModel();
}
/** {@inheritDoc} */
@Override
public List<MenuItem> contextMenuContributions(Node node, DiagramCoordinate diagramLocation) {
// outer-most grid areas of the diagram are inaccessible
DiagramViewerFeatures features = getViewer().getFeatures();
double x = max(features.getHorizontalSpacing(), diagramLocation.getX());
double y = max(features.getVerticalSpacing(), diagramLocation.getY());
// wild cast works: see constructor exception
T modelParent = getModelElement();
IElementCompositionContext edc = createElementCompositionContext(modelParent, x, y, true,
getViewer().getFeatures().getCurrentZoomFactor());
List<MenuItem> result = createPrototypeMenu(modelParent, edc);
result.add(createDisplayMenu(getViewer()));
return result;
}
/** {@inheritDoc} */
@Override
public boolean handleExternalDNDDragOver(Dragboard db, DiagramCoordinate diagramLocation) {
double zoom = getViewer().getFeatures().getCurrentZoomFactor();
return canCompose(db, diagramLocation, getModelElement(), true, zoom);
}
/** {@inheritDoc} */
@Override
public boolean handleExternalDNDDrop(Dragboard db, DiagramCoordinate diagramLocation) {
double zoom = getViewer().getFeatures().getCurrentZoomFactor();
return compose(db, diagramLocation, getModelElement(), true, zoom);
}
}
/*******************************************************************************
* Copyright (c) 2017, 2018 fortiss GmbH.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v2.0 which is available at
* http://www.eclipse.org/legal/epl-v20.html
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Florian Hoelzl (fortiss GmbH) - initial implementation
*
*******************************************************************************/
package org.fortiss.tooling.base.ui.editor.fx.controller;
import static java.lang.Math.max;
import static java.util.Objects.requireNonNull;
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 static org.fortiss.tooling.base.ui.utils.FXDNDUtils.canCompose;
import static org.fortiss.tooling.base.ui.utils.FXDNDUtils.compose;
import java.util.List;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.ecore.EObject;
import org.fortiss.tooling.base.model.element.ElementPackage;
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.DiagramViewerFeatures;
import org.fortiss.tooling.common.ui.javafx.lwfxef.change.Change;
import org.fortiss.tooling.common.ui.javafx.lwfxef.controller.IClickController;
import org.fortiss.tooling.common.ui.javafx.lwfxef.controller.base.ClickControllerBase;
import org.fortiss.tooling.common.ui.javafx.lwfxef.controller.elliptic.EllipticResizableContentControllerBase;
import org.fortiss.tooling.common.ui.javafx.lwfxef.model.IModelChangeProvider;
import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.IContentMVCBundle;
import org.fortiss.tooling.kernel.extension.data.IElementCompositionContext;
import org.fortiss.tooling.kernel.service.IElementCompositorService;
import org.fortiss.tooling.kernel.ui.extension.IModelElementHandler;
import org.fortiss.tooling.kernel.ui.service.IModelEditorBindingService;
import org.fortiss.tooling.kernel.ui.service.IModelElementHandlerService;
import javafx.scene.Node;
import javafx.scene.control.MenuItem;
import javafx.scene.input.Dragboard;
import javafx.scene.input.MouseEvent;
/**
* {@link EllipticResizableContentControllerBase} with a listener mechanism for the layout of the
* connected {@link EObject model element}.
*
* @author hoelzl
*/
public abstract class EObjectEllipticResizableContentControllerBase<T extends EObject>
extends EllipticResizableContentControllerBase {
/** {@link IModelChangeProvider} for this controller */
private final LayoutModelChangeProvider layoutModelChangeProvider;
/** The click controller handling double-click to open editor. */
private final IClickController openEditorDoubleClickController = new ClickControllerBase() {
@Override
public Change singleClick(MouseEvent event, Node node, DiagramCoordinate diagramLocation) {
return EObjectEllipticResizableContentControllerBase.super.getClickController(node,
diagramLocation).singleClick(event, node, diagramLocation);
}
@Override
public Change secondaryClick(MouseEvent event, Node node,
DiagramCoordinate diagramLocation) {
return EObjectEllipticResizableContentControllerBase.super.getClickController(node,
diagramLocation).secondaryClick(event, node, diagramLocation);
}
@Override
public Change doubleClick(MouseEvent event, Node node, DiagramCoordinate diagramLocation) {
EObject eo = getModelElement();
IModelElementHandler<EObject> handler =
IModelElementHandlerService.getInstance().getModelElementHandler(eo);
if(handler != null) {
eo = handler.handleOpenModelElementRequest(eo);
}
IModelEditorBindingService.getInstance().openInEditor(eo);
return null; // no changes to model
}
};
/** Constructor. */
public EObjectEllipticResizableContentControllerBase(IContentMVCBundle mvcb,
Class<T> modelType) {
super(mvcb);
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());
}
ILayoutedModelElement lme = (ILayoutedModelElement)mvcb.getModel();
this.layoutModelChangeProvider = new LayoutModelChangeProvider(lme) {
/** {@inheritDoc} */
@Override
protected boolean acceptNotification(Notification notification) {
if(notification.getNotifier() != getModelElement()) {
return false;
}
return isAnchorageFeature(notification.getFeature());
}
};
}
/** Returns the correctly casted model element. */
@SuppressWarnings("unchecked")
protected T getModelElement() {
// wild cast works: see constructor check with exception
return (T)getModel();
}
/** {@inheritDoc} */
@Override
public IModelChangeProvider getModelChangeProvider() {
return layoutModelChangeProvider;
}
/** {@inheritDoc} */
@Override
public List<MenuItem> contextMenuContributions(Node node, DiagramCoordinate diagramLocation) {
// outer-most grid areas of the diagram are inaccessible
DiagramViewerFeatures features = getViewer().getFeatures();
double x = max(features.getHorizontalSpacing(), diagramLocation.getX());
double y = max(features.getVerticalSpacing(), diagramLocation.getY());
// wild cast works: see constructor exception
EObject modelParent = (EObject)getModel();
IElementCompositionContext edc = createElementCompositionContext(modelParent, x, y, false,
getViewer().getFeatures().getCurrentZoomFactor());
return createPrototypeMenu(modelParent, edc);
}
/** {@inheritDoc} */
@Override
public void delete() {
IElementCompositorService.getInstance().decompose(getModelElement());
}
/** Checks whether the given feature corresponds to an anchorage model element. */
protected boolean isAnchorageFeature(Object feature) {
return feature == ElementPackage.Literals.IHIERARCHIC_ELEMENT__CONNECTORS;
}
/** {@inheritDoc} */
@Override
public IClickController getClickController(Node node, DiagramCoordinate diagramLocation) {
return openEditorDoubleClickController;
}
/** {@inheritDoc} */
@Override
public boolean handleExternalDNDDragOver(Dragboard db, DiagramCoordinate diagramLocation) {
double zoom = getViewer().getFeatures().getCurrentZoomFactor();
return canCompose(db, diagramLocation, getModelElement(), false, zoom);
}
/** {@inheritDoc} */
@Override
public boolean handleExternalDNDDrop(Dragboard db, DiagramCoordinate diagramLocation) {
double zoom = getViewer().getFeatures().getCurrentZoomFactor();
return compose(db, diagramLocation, getModelElement(), false, zoom);
}
}
/*-------------------------------------------------------------------------+
| Copyright 2016 fortiss GmbH |
| 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. |
......@@ -13,40 +13,48 @@
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.kernel.ui.internal.introspection.items;
package org.fortiss.tooling.base.ui.editor.fx.controller;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.fortiss.tooling.kernel.introspection.IIntrospectionDetailsItem;
import org.fortiss.tooling.kernel.ui.extension.IConstraintUI;
import org.fortiss.tooling.kernel.ui.service.IConstraintUIService;
import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.impl.AdapterImpl;
import org.eclipse.emf.ecore.EObject;
/**
* {@link IIntrospectionDetailsItem} for {@link IConstraintUIService}.
* An {@link KernelServiceBasedModelChangeProviderBase} for {@link EObject}s.
*
* @author hoelzl
*/
public final class ConstraintUIServiceIntrospectionDetailsItem
implements IIntrospectionDetailsItem {
/** Read-only copy of the services handler maps. */
protected final Map<String, Class<? extends IConstraintUI>> handlerMap;
final class EObjectModelChangeProvider extends KernelServiceBasedModelChangeProviderBase<EObject> {
/** The model element. */
private final EObject modelElement;
/** The EMF notification listener. */
private final EObjectElementAdapter notificationListener;
/** Constructor. */
public ConstraintUIServiceIntrospectionDetailsItem(
Map<String, Class<? extends IConstraintUI>> handlerMap) {
this.handlerMap = handlerMap;
public EObjectModelChangeProvider(EObject modelElement) {
this.modelElement = modelElement;
this.notificationListener = new EObjectElementAdapter();
}
/** {@inheritDoc} */
@Override
protected EObject getModelElement() {
return modelElement;
}
/** Returns the registered constraint UI's along with their non-UI counterparts. */
public Set<Entry<String, Class<? extends IConstraintUI>>> getHandlerKeyClasses() {
return handlerMap.entrySet();
/** {@inheritDoc} */
@Override
protected Adapter getNotificationListener() {
return notificationListener;
}
/** Returns the handler list for the given registration class. */
public Class<? extends IConstraintUI> getHandler(String regClass) {
return handlerMap.get(regClass);
/** Specialized adapter listening to model changes of {@link EObject}. */
private class EObjectElementAdapter extends AdapterImpl {
/** {@inheritDoc} */
@Override
public void notifyChanged(Notification event) {
addNotification(event);
}
}
}
/*******************************************************************************
* Copyright (c) 2017, 2018 fortiss GmbH.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v2.0 which is available at
* http://www.eclipse.org/legal/epl-v20.html
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Florian Hoelzl (fortiss GmbH) - initial implementation
*
*******************************************************************************/
package org.fortiss.tooling.base.ui.editor.fx.controller;
import static java.lang.Math.max;
import static java.util.Objects.requireNonNull;
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 static org.fortiss.tooling.base.ui.utils.FXDNDUtils.canCompose;
import static org.fortiss.tooling.base.ui.utils.FXDNDUtils.compose;
import java.util.List;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.ecore.EObject;
import org.fortiss.tooling.base.model.element.ElementPackage;
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.DiagramViewerFeatures;
import org.fortiss.tooling.common.ui.javafx.lwfxef.change.Change;
import org.fortiss.tooling.common.ui.javafx.lwfxef.controller.IClickController;
import org.fortiss.tooling.common.ui.javafx.lwfxef.controller.IDragController;
import org.fortiss.tooling.common.ui.javafx.lwfxef.controller.base.ClickControllerBase;
import org.fortiss.tooling.common.ui.javafx.lwfxef.controller.rectangular.RectangularContentAnchorageMoveController;
import org.fortiss.tooling.common.ui.javafx.lwfxef.controller.rectangular.RectangularResizableContentControllerBase;
import org.fortiss.tooling.common.ui.javafx.lwfxef.model.IModelChangeProvider;
import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.IContentAnchorageMVCBundle;
import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.IContentMVCBundle;
import org.fortiss.tooling.kernel.extension.data.IElementCompositionContext;
import org.fortiss.tooling.kernel.service.IElementCompositorService;
import org.fortiss.tooling.kernel.ui.extension.IModelElementHandler;
import org.fortiss.tooling.kernel.ui.service.IModelEditorBindingService;
import org.fortiss.tooling.kernel.ui.service.IModelElementHandlerService;
import javafx.geometry.Dimension2D;
import javafx.scene.Node;
import javafx.scene.control.MenuItem;
import javafx.scene.input.Dragboard;
import javafx.scene.input.MouseEvent;
/**
* {@link RectangularResizableContentControllerBase} with a listener mechanism for the layout of the
* connected {@link EObject model element}.
*
* @author hoelzl
*/
public abstract class EObjectRectangularResizableContentControllerBase<T extends EObject>
extends RectangularResizableContentControllerBase {
/** {@link IModelChangeProvider} for this controller */
private final LayoutModelChangeProvider layoutModelChangeProvider;
/** The click controller handling double-click to open editor. */
private final IClickController openEditorDoubleClickController = new ClickControllerBase() {
@Override
public Change singleClick(MouseEvent event, Node node, DiagramCoordinate diagramLocation) {
return EObjectRectangularResizableContentControllerBase.super.getClickController(node,
diagramLocation).singleClick(event, node, diagramLocation);
}
@Override
public Change secondaryClick(MouseEvent event, Node node,
DiagramCoordinate diagramLocation) {
return EObjectRectangularResizableContentControllerBase.super.getClickController(node,
diagramLocation).secondaryClick(event, node, diagramLocation);
}
@Override
public Change doubleClick(MouseEvent event, Node node, DiagramCoordinate diagramLocation) {
EObject eo = getModelElement();
IModelElementHandler<EObject> handler =
IModelElementHandlerService.getInstance().getModelElementHandler(eo);
if(handler != null) {
eo = handler.handleOpenModelElementRequest(eo);
}
IModelEditorBindingService.getInstance().openInEditor(eo);
return null; // no changes to model
}
};
/** Constructor. */
public EObjectRectangularResizableContentControllerBase(IContentMVCBundle mvcb,
Class<T> modelType) {
super(mvcb);
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());
}
ILayoutedModelElement lme = (ILayoutedModelElement)mvcb.getModel();
this.layoutModelChangeProvider = new LayoutModelChangeProvider(lme) {
/** {@inheritDoc} */
@Override
protected boolean acceptNotification(Notification notification) {
if(notification.getNotifier() != getModelElement()) {
return false;
}
return isAnchorageFeature(notification.getFeature());
}
};
}
/** Returns the correctly casted model element. */
@SuppressWarnings("unchecked")
protected T getModelElement() {
// wild cast works: see constructor check with exception
return (T)getModel();
}
/** {@inheritDoc} */
@Override
public IModelChangeProvider getModelChangeProvider() {
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} */
@Override
public List<MenuItem> contextMenuContributions(Node node, DiagramCoordinate diagramLocation) {
// outer-most grid areas of the diagram are inaccessible
DiagramViewerFeatures features = getViewer().getFeatures();
double x = max(features.getHorizontalSpacing(), diagramLocation.getX());
double y = max(features.getVerticalSpacing(), diagramLocation.getY());
// wild cast works: see constructor exception
EObject modelParent = (EObject)getModel();
IElementCompositionContext edc = createElementCompositionContext(modelParent, x, y, false,
getViewer().getFeatures().getCurrentZoomFactor());
return createPrototypeMenu(modelParent, edc);
}
/** {@inheritDoc} */
@Override
public void delete() {
IElementCompositorService.getInstance().decompose(getModelElement());
}
/** Checks whether the given feature corresponds to an anchorage model element. */
protected boolean isAnchorageFeature(Object feature) {
return feature == ElementPackage.Literals.IHIERARCHIC_ELEMENT__CONNECTORS;
}
/** {@inheritDoc} */
@Override
public IClickController getClickController(Node node, DiagramCoordinate diagramLocation) {
return openEditorDoubleClickController;
}
/** {@inheritDoc} */
@Override
public boolean handleExternalDNDDragOver(Dragboard db, DiagramCoordinate diagramLocation) {
double zoom = getViewer().getFeatures().getCurrentZoomFactor();
return canCompose(db, diagramLocation, getModelElement(), false, zoom);
}
/** {@inheritDoc} */
@Override
public boolean handleExternalDNDDrop(Dragboard db, DiagramCoordinate diagramLocation) {
double zoom = getViewer().getFeatures().getCurrentZoomFactor();
return compose(db, diagramLocation, getModelElement(), false, zoom);
}
}
/*-------------------------------------------------------------------------+
| Copyright 2018 fortiss GmbH |
| 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. |
......@@ -13,83 +13,77 @@
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.kernel.extension.base;
package org.fortiss.tooling.base.ui.editor.fx.controller;
import static org.conqat.lib.commons.reflect.ReflectionUtils.isInstanceOfAny;
import static org.eclipse.emf.ecore.util.EcoreUtil.delete;
import static org.fortiss.tooling.common.util.LambdaUtils.asStream;
import java.util.Collection;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Stream;
import java.util.ArrayList;
import java.util.EventObject;
import java.util.List;
import org.eclipse.emf.common.command.CommandStackListener;
import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.xml.type.AnyType;
import org.fortiss.tooling.kernel.extension.IMigrationProvider;
import org.fortiss.tooling.common.ui.javafx.lwfxef.model.IModelChangeProvider;
import org.fortiss.tooling.common.ui.javafx.lwfxef.model.ModelChangeProviderBase;
import org.fortiss.tooling.kernel.extension.data.ITopLevelElement;
import org.fortiss.tooling.kernel.model.INamedCommentedElement;
import org.fortiss.tooling.kernel.service.ICommandStackService;
import org.fortiss.tooling.kernel.service.IPersistencyService;
/**
* Remove artificats related to deprecated use case model.
* Base class for {@link IModelChangeProvider}s using kernel services.
*
* @author barner
* @author hoelzl
*/
public abstract class RemoveDeprecatedArtifactsMigrationProviderBase implements IMigrationProvider { // NO_UCD
// Migrators are retired after a release, but this base class should be available when needed.
// See https://af3-developer.fortiss.org/projects/autofocus3/wiki/Model_Migration
abstract class KernelServiceBasedModelChangeProviderBase<T extends EObject>
extends ModelChangeProviderBase implements CommandStackListener {
/** The persistency service reference. */
private static final IPersistencyService persistencyService = IPersistencyService.getInstance();
/** The command stack service. */
private static final ICommandStackService commandStackService =
ICommandStackService.getInstance();
/** List of relevant {@link Notification}s recorded during a change transaction. */
private final List<Notification> notifications = new ArrayList<>();
/** Returns the {@link Collection} of deprecated artifact types to be removed from the model. */
protected abstract Collection<Class<? extends EObject>> getDeprecatedArtifacts();
/** Returns the model element. */
protected abstract T getModelElement();
/**
* Returns the {@link Collection} of deprecated root artifact types (possibly empty subset of
* {@link #getDeprecatedArtifacts()}) for which a comment is added to the migrated model that
* deprecated artifacts have been removed.
*/
protected abstract Collection<Class<? extends EObject>> getDeprecatedRootArtifacts();
/** Returns the EMF notification listener. */
protected abstract Adapter getNotificationListener();
/** Returns the {@link Stream} of deprecated model elements to be removed. */
private Stream<EObject> getDeprecatedModelElements(ITopLevelElement modelElement) {
Stream<EObject> root = asStream(modelElement.getRootModelElement().eAllContents());
Collection<Class<? extends EObject>> deprArtifacts = getDeprecatedArtifacts();
return root.filter(
e -> isInstanceOfAny(e, deprArtifacts.toArray(new Class[deprArtifacts.size()])));
/** Adds the given {@link Notification} to list of notifications. */
protected final void addNotification(Notification event) {
notifications.add(event);
}
/** {@inheritDoc} */
@Override
public boolean needMigration(ITopLevelElement modelElement,
Map<EObject, AnyType> unknownFeatures) {
protected final void connectToModel() {
notifications.clear();
T modelElement = getModelElement();
Adapter notificationListener = getNotificationListener();
ITopLevelElement root = persistencyService.getTopLevelElementFor(modelElement);
commandStackService.addCommandStackListener(root, this);
modelElement.eAdapters().add(notificationListener);
}
return getDeprecatedModelElements(modelElement).findAny().isPresent();
/** {@inheritDoc} */
@Override
protected final void disconnectFromModel() {
T modelElement = getModelElement();
Adapter notificationListener = getNotificationListener();
modelElement.eAdapters().remove(notificationListener);
ITopLevelElement root = persistencyService.getTopLevelElementFor(modelElement);
commandStackService.removeCommandStackListener(root, this);
notifications.clear();
}
/** {@inheritDoc} */
@Override
public void migrate(ITopLevelElement modelElement, Map<EObject, AnyType> unknownFeatures) {
EObject object;
do {
object = null;
Stream<EObject> deprecatedModelElements = getDeprecatedModelElements(modelElement);
Optional<EObject> anyObject = deprecatedModelElements.findAny();
if(anyObject.isPresent()) {
object = anyObject.get();
if(object.eContainer() instanceof INamedCommentedElement) {
INamedCommentedElement parent = (INamedCommentedElement)object.eContainer();
if(parent.getComment() == null || parent.getComment().isEmpty()) {
for(Class<? extends EObject> rootType : getDeprecatedRootArtifacts()) {
if(rootType.isAssignableFrom(object.getClass())) {
parent.setComment(rootType.getSimpleName() +
" models are no longer supported. This sub-model has been removed automatically!");
break;
}
}
}
}
delete(object);
}
} while(object != null);
public void commandStackChanged(EventObject event) {
if(notifications.isEmpty()) {
return;
}
fireUpdateComplete();
notifications.clear();
}
}
/*-------------------------------------------------------------------------+
| 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 org.fortiss.tooling.base.model.layout.LayoutPackage.ILAYOUTED_MODEL_ELEMENT__LAYOUT_DATA;
import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.util.EContentAdapter;
import org.fortiss.tooling.base.model.layout.ILayoutData;
import org.fortiss.tooling.base.model.layout.ILayoutedModelElement;
import org.fortiss.tooling.base.model.layout.LayoutPackage;
/**
* A {@link KernelServiceBasedModelChangeProviderBase} for {@link ILayoutedModelElement}s.
*
* @author hoelzl
*/
class LayoutModelChangeProvider
extends KernelServiceBasedModelChangeProviderBase<ILayoutedModelElement> {
/** The layouted model element. */
private final ILayoutedModelElement modelElement;
/** The layout EMF notification listener. */
private final LayoutModelElementAdapter notificationListener;
/** Constructor. */
public LayoutModelChangeProvider(ILayoutedModelElement modelElement) {
this.modelElement = modelElement;
this.notificationListener = new LayoutModelElementAdapter();
}
/** {@inheritDoc} */
@Override
protected ILayoutedModelElement getModelElement() {
return modelElement;
}
/** {@inheritDoc} */
@Override
protected Adapter getNotificationListener() {
return notificationListener;
}
/**
* Checks whether the given notification should be accepted.
*
* @param notification
* the notification
* @return whether the notification should be accepted
*/
protected boolean acceptNotification(Notification notification) {
return false;
}
/** Specific {@link EContentAdapter} listening to layout data changes. */
public class LayoutModelElementAdapter extends EContentAdapter {
/** {@inheritDoc} */
@Override
public void notifyChanged(Notification notification) {
if(acceptNotification(notification)) {
addNotification(notification);
return;
}
Object notifier = notification.getNotifier();
if(notifier == modelElement) {
Object feature = notification.getFeature();
if(feature == LayoutPackage.Literals.ILAYOUTED_MODEL_ELEMENT__LAYOUT_DATA) {
// self adapt to layout data
super.notifyChanged(notification);
addNotification(notification);
return;
}
} else if(notifier instanceof ILayoutData) {
// self adapt to layout data
super.notifyChanged(notification);
addNotification(notification);
return;
}
// prevent self-adapt for all other cases
}
/** Called when layout data of the underlying model element changed. */
protected void layoutChanged() {
// default does nothing
}
/** {@inheritDoc} */
@Override
protected void selfAdapt(Notification notification) {
// ignore resources and resource sets
if(notification.getNotifier() instanceof EObject) {
super.selfAdapt(notification);
}
}
/** {@inheritDoc} */
@Override
protected void handleContainment(Notification notification) {
// only adapt to layout data
if(notification.getNotifier() instanceof ILayoutData) {
super.handleContainment(notification);
return;
}
Class<?> instanceClass =
LayoutPackage.Literals.ILAYOUTED_MODEL_ELEMENT.getInstanceClass();
// only adapt to layout data
if(notification.getFeatureID(instanceClass) == ILAYOUTED_MODEL_ELEMENT__LAYOUT_DATA) {
super.handleContainment(notification);
}
}
}
}
/*******************************************************************************
* Copyright (c) 2017, 2018 fortiss GmbH.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v2.0 which is available at
* http://www.eclipse.org/legal/epl-v20.html
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Florian Hoelzl (fortiss GmbH) - initial implementation
*
*******************************************************************************/
package org.fortiss.tooling.base.ui.editor.fx.controller;
import static java.util.Objects.requireNonNull;
import static org.fortiss.tooling.common.ui.javafx.lwfxef.DiagramViewerDefaultTags.LINK_TARGET_ALLOWED_TAG;
import static org.fortiss.tooling.common.ui.javafx.lwfxef.DiagramViewerDefaultTags.LINK_TARGET_DENIED_TAG;
import org.eclipse.emf.ecore.EObject;
import org.fortiss.tooling.common.ui.javafx.lwfxef.DiagramCoordinate;
import org.fortiss.tooling.common.ui.javafx.lwfxef.controller.base.DelegatingContentAnchorageController;
import org.fortiss.tooling.common.ui.javafx.lwfxef.model.IModelChangeProvider;
import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.IContentAnchorageMVCBundle;
import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.IMVCBundle;
import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.MVCBundleTag;
import org.fortiss.tooling.base.model.element.IConnector;
import org.fortiss.tooling.base.model.layout.ILayoutedModelElement;
import org.fortiss.tooling.kernel.service.IConnectionCompositorService;
import org.fortiss.tooling.kernel.service.IElementCompositorService;
/**
* {@link DelegatingContentAnchorageController} for {@link ILayoutedModelElement}s.
*
* @author hoelzl
*/
public class LayoutedContentAnchorageController<T extends ILayoutedModelElement>
extends DelegatingContentAnchorageController {
/** {@link IModelChangeProvider} for this controller */
private final LayoutModelChangeProvider layoutModelChangeProvider;
/** Constructor. */
public LayoutedContentAnchorageController(IContentAnchorageMVCBundle mvcb, Class<T> modelType) {
super(mvcb);
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());
}
ILayoutedModelElement lme = (ILayoutedModelElement)mvcb.getModel();
this.layoutModelChangeProvider = new LayoutModelChangeProvider(lme);
}
/** Returns the model element. */
public ILayoutedModelElement getLayoutedME() {
return (ILayoutedModelElement)getModel();
}
/** {@inheritDoc} */
@Override
public IModelChangeProvider getModelChangeProvider() {
return layoutModelChangeProvider;
}
/** {@inheritDoc} */
@Override
public void delete() {
IElementCompositorService.getInstance().decompose(getLayoutedME());
}
/** {@inheritDoc} */
@Override
protected boolean canLink(IMVCBundle startBundle, DiagramCoordinate startLocation,
IMVCBundle endBundle, DiagramCoordinate endLocation) {
IConnectionCompositorService ccs = IConnectionCompositorService.getInstance();
EObject start = (EObject)startBundle.getModel();
EObject end = (EObject)endBundle.getModel();
EObject root = (EObject)getViewer().getRootElement();
return ccs.canConnect(start, end, root, null);
}
/** {@inheritDoc} */
@Override
protected void link(IMVCBundle startBundle, DiagramCoordinate startLocation,
IMVCBundle endBundle, DiagramCoordinate endLocation) {
EObject start = (EObject)startBundle.getModel();
EObject end = (EObject)endBundle.getModel();
EObject root = (EObject)getViewer().getRootElement();
IConnectionCompositorService.getInstance().connect(start, end, root, null);
}
/** {@inheritDoc} */
@Override
public boolean isPossibleLinkTarget() {
return true;
}
/** {@inheritDoc} */
@Override
public MVCBundleTag getLinkTargetEffectForNewLinkFrom(IMVCBundle linkSourceBundle) {
Object srcModel = linkSourceBundle.getModel();
if(srcModel instanceof ILayoutedModelElement && srcModel instanceof IConnector) {
EObject startModel = (EObject)srcModel;
ILayoutedModelElement endModel = getLayoutedME();
EObject root = (EObject)getViewer().getRootElement();
IConnectionCompositorService srv = IConnectionCompositorService.getInstance();
if(srv.canConnect(startModel, endModel, root, null)) {
return LINK_TARGET_ALLOWED_TAG;
}
}
return LINK_TARGET_DENIED_TAG;
}
}
/*-------------------------------------------------------------------------+
| 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 java.util.Arrays.asList;
import static org.fortiss.tooling.base.utils.LayoutModelElementFactory.createPoint;
import static org.fortiss.tooling.common.ui.javafx.lwfxef.FeedbackChange.locationFeedbackChange;
import org.fortiss.tooling.base.model.layout.ILayoutedModelElement;
import org.fortiss.tooling.base.model.layout.Point;
import org.fortiss.tooling.common.ui.javafx.lwfxef.DiagramCoordinate;
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.FeedbackChange;
import org.fortiss.tooling.common.ui.javafx.lwfxef.controller.IController;
import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.ILinkMVCBundle;
import org.fortiss.tooling.common.ui.javafx.lwfxef.visual.ILinkVisual;
import javafx.geometry.Point2D;
/**
* {@link IController} for {@link ILayoutedModelElement}s representing curved links and connections
* in a {@link DiagramViewer}.
*
* @author munaro
*/
public class LayoutedCurveLinkBendPointController<T extends ILayoutedModelElement>
extends LayoutedLinkBendPointController<T> {
/** Constructor. */
public LayoutedCurveLinkBendPointController(ILinkMVCBundle mvcb, Class<T> modelType) {
super(mvcb, modelType);
}
/** {@inheritDoc} */
@Override
protected final void createBendPointAt(int bpIndex, DiagramCoordinate location) {
DiagramViewerFeatures features = getViewer().getFeatures();
Point c2 = createPoint((int)(location.getX() - 2 * features.getHorizontalSpacing()),
(int)location.getY(), null);
Point c1 = createPoint((int)(location.getX() + 2 * features.getHorizontalSpacing()),
(int)location.getY(), null);
Point bp = createPoint((int)location.getX(), (int)location.getY(), null);
getBendPointList(getModelElement()).addAll(bpIndex - 1, asList(c2, bp, c1));
}
/** {@inheritDoc} */
@Override
protected final void moveBendPointVisually(int bpIndex, Point2D delta) {
super.moveBendPointVisually(bpIndex, delta);
if(bpIndex <= 0 || bpIndex >= getNumerOfBendPoints() - 1) {
// first and last bend-point move unconnected
return;
}
ILinkVisual linkVisual = getLinkVisual();
FeedbackChange centerPointChange = getMoveDeltaFeedback(bpIndex, delta);
int indexMod3 = bpIndex % 3;
if(indexMod3 == 2) {
// bend-points between curve segments also drag the previous and next point
linkVisual.setFeedbackChangeForBendPoint(bpIndex - 1, centerPointChange);
linkVisual.setFeedbackChangeForBendPoint(bpIndex + 1, centerPointChange);
} else {
// otherwise the connected bend-point is moved in the opposite direction
FeedbackChange inv = locationFeedbackChange(-centerPointChange.getDeltaX(),
-centerPointChange.getDeltaY());
int otherIndex = (indexMod3 == 1) ? bpIndex + 2 : bpIndex - 2;
linkVisual.setFeedbackChangeForBendPoint(otherIndex, inv);
}
// linkVisual.update();
return;
}
/** {@inheritDoc} */
@Override
protected final void moveBendPointInModel(int bpIndex, Point2D delta) {
FeedbackChange chg = getMoveDeltaFeedback(bpIndex, delta);
getLinkVisual().setFeedbackChangeForBendPoint(bpIndex, null);
updateModelAfterBendPointMove(bpIndex, chg.getDeltaX(), chg.getDeltaY());
if(bpIndex <= 0 || bpIndex >= getNumerOfBendPoints() - 1) {
// first and last bend-point move unconnected
return;
}
ILinkVisual linkVisual = getLinkVisual();
int indexMod3 = bpIndex % 3;
if(indexMod3 == 2) {
// bend-points between curve segments also drag the previous and next point
linkVisual.setFeedbackChangeForBendPoint(bpIndex - 1, null);
updateModelAfterBendPointMove(bpIndex - 1, chg.getDeltaX(), chg.getDeltaY());
linkVisual.setFeedbackChangeForBendPoint(bpIndex + 1, null);
updateModelAfterBendPointMove(bpIndex + 1, chg.getDeltaX(), chg.getDeltaY());
} else {
// otherwise the connected bend-point is moved in the opposite direction
int otherIndex = (indexMod3 == 1) ? bpIndex + 2 : bpIndex - 2;
linkVisual.setFeedbackChangeForBendPoint(otherIndex, null);
updateModelAfterBendPointMove(otherIndex, -chg.getDeltaX(), -chg.getDeltaY());
}
}
}
/*******************************************************************************
* Copyright (c) 2017, 2018 fortiss GmbH.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v2.0 which is available at
* http://www.eclipse.org/legal/epl-v20.html
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Florian Hoelzl (fortiss GmbH) - initial implementation
*
*******************************************************************************/
package org.fortiss.tooling.base.ui.editor.fx.controller;
import static java.util.Objects.requireNonNull;
import static org.fortiss.tooling.common.ui.javafx.lwfxef.DiagramViewerDefaultTags.LINK_TARGET_ALLOWED_TAG;
import static org.fortiss.tooling.common.ui.javafx.lwfxef.DiagramViewerDefaultTags.LINK_TARGET_DENIED_TAG;
import static org.fortiss.tooling.base.utils.LayoutDataUtils.moveNode;
import org.eclipse.emf.ecore.EObject;
import org.fortiss.tooling.common.ui.javafx.lwfxef.DiagramCoordinate;
import org.fortiss.tooling.common.ui.javafx.lwfxef.FeedbackChange;
import org.fortiss.tooling.common.ui.javafx.lwfxef.controller.base.MoveControllerBase;
import org.fortiss.tooling.common.ui.javafx.lwfxef.model.IModelChangeProvider;
import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.IMVCBundle;
import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.MVCBundleTag;
import org.fortiss.tooling.base.model.element.IConnector;
import org.fortiss.tooling.base.model.layout.ILayoutedModelElement;
import org.fortiss.tooling.kernel.service.IConnectionCompositorService;
import org.fortiss.tooling.kernel.service.IElementCompositorService;
/**
* {@link MoveControllerBase} for {@link ILayoutedModelElement}s.
*
* @author hoelzl
*/
public class LayoutedDiagramAnchorageController<T extends ILayoutedModelElement>
extends MoveControllerBase {
/** {@link IModelChangeProvider} for this controller */
private final LayoutModelChangeProvider layoutModelChangeProvider;
/** Constructor. */
public LayoutedDiagramAnchorageController(IMVCBundle mvcb, Class<T> modelType) {
super(mvcb);
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());
}
ILayoutedModelElement lme = (ILayoutedModelElement)mvcb.getModel();
this.layoutModelChangeProvider = new LayoutModelChangeProvider(lme);
}
/** Returns the model element. */
public ILayoutedModelElement getLayoutedME() {
return (ILayoutedModelElement)getModel();
}
/** {@inheritDoc} */
@Override
public IModelChangeProvider getModelChangeProvider() {
return layoutModelChangeProvider;
}
/** {@inheritDoc} */
@Override
public void move(FeedbackChange delta) {
ILayoutedModelElement model = getLayoutedME();
int dx = (int)delta.getDeltaX();
int dy = (int)delta.getDeltaY();
moveNode(model, dx, dy);
}
/** {@inheritDoc} */
@Override
public void delete() {
IElementCompositorService.getInstance().decompose(getLayoutedME());
}
/** {@inheritDoc} */
@Override
protected boolean canLink(IMVCBundle startBundle, DiagramCoordinate startLocation,
IMVCBundle endBundle, DiagramCoordinate endLocation) {
IConnectionCompositorService ccs = IConnectionCompositorService.getInstance();
EObject start = (EObject)startBundle.getModel();
EObject end = (EObject)endBundle.getModel();
EObject root = (EObject)getViewer().getRootElement();
return ccs.canConnect(start, end, root, null);
}
/** {@inheritDoc} */
@Override
protected void link(IMVCBundle startBundle, DiagramCoordinate startLocation,
IMVCBundle endBundle, DiagramCoordinate endLocation) {
EObject start = (EObject)startBundle.getModel();
EObject end = (EObject)endBundle.getModel();
EObject root = (EObject)getViewer().getRootElement();
IConnectionCompositorService.getInstance().connect(start, end, root, null);
}
/** {@inheritDoc} */
@Override
public boolean isPossibleLinkTarget() {
return true;
}
/** {@inheritDoc} */
@Override
public MVCBundleTag getLinkTargetEffectForNewLinkFrom(IMVCBundle linkSourceBundle) {
Object srcModel = linkSourceBundle.getModel();
if(srcModel instanceof ILayoutedModelElement && srcModel instanceof IConnector) {
EObject startModel = (EObject)srcModel;
ILayoutedModelElement endModel = getLayoutedME();
EObject root = (EObject)getViewer().getRootElement();
IConnectionCompositorService srv = IConnectionCompositorService.getInstance();
if(srv.canConnect(startModel, endModel, root, null)) {
return LINK_TARGET_ALLOWED_TAG;
}
}
return LINK_TARGET_DENIED_TAG;
}
}
/*-------------------------------------------------------------------------+
| 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 java.lang.Math.toRadians;
import static java.util.Objects.requireNonNull;
import static org.fortiss.tooling.base.ui.utils.LayoutDataUIUtils.setConnectorAngle;
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 org.fortiss.tooling.base.model.element.IConnector;
import org.fortiss.tooling.base.model.layout.Dimension;
import org.fortiss.tooling.base.model.layout.ILayoutedModelElement;
import org.fortiss.tooling.common.ui.javafx.lwfxef.FeedbackChange;
import org.fortiss.tooling.common.ui.javafx.lwfxef.controller.IController;
import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.IContentAnchorageMVCBundle;
import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.IContentMVCBundle;
/**
* {@link IController} for {@link ILayoutedModelElement}s that have a elliptical shape.
*
* @author munaro
*/
public class LayoutedEllipticResizableContentController<T extends ILayoutedModelElement>
extends EObjectEllipticResizableContentControllerBase<T> {
/** Constructor */
public LayoutedEllipticResizableContentController(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 moveAnchorageToAngle(IContentAnchorageMVCBundle anchorage,
double angleInDegree) {
Object connObj = anchorage.getModel();
if(connObj instanceof IConnector && connObj instanceof ILayoutedModelElement) {
ILayoutedModelElement conn = (ILayoutedModelElement)connObj;
setConnectorAngle(conn, toRadians(angleInDegree));
}
}
/** {@inheritDoc} */
@Override
protected void move(FeedbackChange deltaChange) {
moveNode(getModelElement(), (int)deltaChange.getDeltaX(), (int)deltaChange.getDeltaY());
}
/** {@inheritDoc} */
@Override
protected boolean allowLink() {
return false;
}
/** {@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);
}
}
/*******************************************************************************
* Copyright (c) 2017, 2018 fortiss GmbH.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v2.0 which is available at
* http://www.eclipse.org/legal/epl-v20.html
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Florian Hoelzl (fortiss GmbH) - initial implementation
*
*******************************************************************************/
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.layout.ILayoutedModelElement;
import org.fortiss.tooling.common.ui.javafx.lwfxef.DiagramCoordinate;
import org.fortiss.tooling.common.ui.javafx.lwfxef.DiagramViewer;
import org.fortiss.tooling.common.ui.javafx.lwfxef.controller.IController;
import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.ILinkMVCBundle;
/**
* {@link IController} for {@link ILayoutedModelElement}s representing straight links and
* connections in a {@link DiagramViewer}.
*
* @author hoelzl
*/
public class LayoutedLineLinkBendPointController<T extends ILayoutedModelElement>
extends LayoutedLinkBendPointController<T> {
/** Constructor. */
public LayoutedLineLinkBendPointController(ILinkMVCBundle mvcb, Class<T> modelType) {
super(mvcb, modelType);
}
/** {@inheritDoc} */
@Override
protected void createBendPointAt(int bpIndex, DiagramCoordinate location) {
int x = (int)location.getX();
int y = (int)location.getY();
addConnectionPoint(getModelElement(), bpIndex, x, y);
}
}
/*-------------------------------------------------------------------------+
| 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 java.util.Objects.requireNonNull;
import static org.fortiss.tooling.base.ui.utils.LayoutDataUIUtils.getConnectionPoints;
import static org.fortiss.tooling.base.ui.utils.LayoutDataUIUtils.removeConnectionPoint;
import java.util.List;
import org.eclipse.emf.common.util.EList;
import org.fortiss.tooling.base.model.layout.ILayoutedModelElement;
import org.fortiss.tooling.base.model.layout.Point;
import org.fortiss.tooling.common.ui.javafx.lwfxef.DiagramViewer;
import org.fortiss.tooling.common.ui.javafx.lwfxef.controller.IController;
import org.fortiss.tooling.common.ui.javafx.lwfxef.controller.base.LinkControllerBase;
import org.fortiss.tooling.common.ui.javafx.lwfxef.model.IModelChangeProvider;
import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.ILinkMVCBundle;
import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.IMVCBundle;
import org.fortiss.tooling.kernel.service.IConnectionCompositorService;
/**
* Base class for {@link IController}s for {@link ILayoutedModelElement}s representing links and
* connections in a {@link DiagramViewer}.
*
* @author munaro
*/
public abstract class LayoutedLinkBendPointController<T extends ILayoutedModelElement>
extends LinkControllerBase {
/** {@link IModelChangeProvider} for this controller */
protected final LayoutModelChangeProvider layoutModelChangeProvider;
/** Returns the model element. */
@SuppressWarnings("unchecked")
public T getModelElement() {
return (T)getModel();
}
/** {@inheritDoc} */
@Override
public IModelChangeProvider getModelChangeProvider() {
return layoutModelChangeProvider;
}
/** Constructor. */
public LayoutedLinkBendPointController(ILinkMVCBundle mvcb, Class<T> modelType) {
super(mvcb);
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());
}
ILayoutedModelElement lme = (ILayoutedModelElement)mvcb.getModel();
this.layoutModelChangeProvider = new LayoutModelChangeProvider(lme);
}
/** {@inheritDoc} */
@Override
public void delete() {
deleteLink();
}
/** {@inheritDoc} */
@Override
protected boolean clampAndSnapBendPointToGridCenter() {
// disable default mode
return false;
}
/** {@inheritDoc} */
@Override
protected boolean clampAndSnapBendPointToGrid() {
// enable clamping mode
return true;
}
/** {@inheritDoc} */
@Override
protected void deleteBendPoint(int bpIndex) {
removeConnectionPoint(getModelElement(), bpIndex);
}
/** {@inheritDoc} */
@Override
protected void updateModelAfterBendPointMove(int bpIndex, double dx, double dy) {
List<Point> oldPoints = getBendPointList(getModelElement());
Point point = oldPoints.get(bpIndex);
int oldX = point.getX();
int oldY = point.getY();
int newX = oldX + (int)dx;
int newY = oldY + (int)dy;
point.setX(newX);
point.setY(newY);
}
/** {@inheritDoc} */
@Override
protected void deleteLink() {
IConnectionCompositorService.getInstance().disconnect(getModelElement());
}
/** {@inheritDoc} */
@Override
protected void updateModelAfterLinkMove(ILinkMVCBundle linkBundle, IMVCBundle startBundle,
IMVCBundle endBundle) {
// ignored
}
/** Returns the list of bend-points. */
protected EList<Point> getBendPointList(ILayoutedModelElement modelElement) {
return getConnectionPoints(modelElement).getPoints();
}
/** {@inheritDoc} */
@Override
protected int getNumerOfBendPoints() {
return getBendPointList(getModelElement()).size();
}
}