Skip to content
Snippets Groups Projects
Commit 44c3ef26 authored by Kevin Kassin's avatar Kevin Kassin
Browse files

#Commit 28.10 19:00

made some classes abstract as they should be,
implemented first version of checks for reconnecting connections
parent d976c149
Branches
No related tags found
No related merge requests found
package org.framed.iorm.ui.graphitifeatures;
import org.eclipse.graphiti.features.IFeatureProvider;
import org.eclipse.graphiti.features.context.IReconnectionContext;
import org.eclipse.graphiti.features.impl.DefaultReconnectionFeature;
import org.eclipse.graphiti.mm.pictograms.Anchor;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
import org.framed.iorm.model.Relation;
import org.framed.iorm.model.Type;
import org.framed.iorm.ui.util.ConnectionPatternUtil;
//TODO
public class FRaMEDReconnectFeature extends DefaultReconnectionFeature {
//TODO
public FRaMEDReconnectFeature(IFeatureProvider featureProvider) {
super(featureProvider);
}
//TODO
@Override
public boolean canReconnect(IReconnectionContext context) {
Relation relation = (Relation) getBusinessObjectForPictogramElement(context.getConnection());
if(relation.getType() == Type.INHERITANCE) return canReconnectInheritance(context);
if(relation.getType() == Type.RELATIONSHIP) return canReconnectRelationship(context);
if(relation.getType() == Type.RELATIONSHIP_EXCLUSION ||
relation.getType() == Type.RELATIONSHIP_IMPLICATION) return canReconnectInterRelCon(context);
return false;
}
//TODO
private boolean canReconnectInheritance(IReconnectionContext context) {
Anchor oldAnchor = context.getOldAnchor();
Anchor newAnchor = context.getNewAnchor();
org.framed.iorm.model.ModelElement oldShape = ConnectionPatternUtil.getModelElementForAnchor(oldAnchor);
org.framed.iorm.model.ModelElement newShape = ConnectionPatternUtil.getModelElementForAnchor(newAnchor);
if(oldShape != null && newShape != null) {
if(oldShape.getContainer() == newShape.getContainer()) {
if(newShape.getType() == oldShape.getType()) {
return true;
} } }
return false;
}
//TODO
private boolean canReconnectRelationship(IReconnectionContext context) {
Anchor newAnchor = context.getNewAnchor();
org.framed.iorm.model.ModelElement newShape = ConnectionPatternUtil.getModelElementForAnchor(newAnchor);
if(newShape != null)
return newShape.getType()==Type.ROLE_TYPE;
return false;
}
//TODO
private boolean canReconnectInterRelCon(IReconnectionContext context) {
Anchor newAnchor = context.getNewAnchor();
org.framed.iorm.model.ModelElement newRelation = ConnectionPatternUtil.getModelElementForAnchor(newAnchor);
if(newRelation != null)
return (newRelation.getType() == Type.RELATIONSHIP);
return false;
}
}
......@@ -11,7 +11,7 @@ import org.eclipse.graphiti.services.IPeCreateService;
* It collects common attributes and operations of these classes.
* @author Kevin Kassin
*/
public class FRaMEDConnectionPattern extends AbstractConnectionPattern {
public abstract class FRaMEDConnectionPattern extends AbstractConnectionPattern {
/**
* Class constructor
......
......@@ -26,7 +26,7 @@ import org.framed.iorm.ui.pattern.connections.RelationshipPattern; //*import for
* {@link RelationshipExclusionConstraintPattern}.
* @author Kevin Kassin
*/
public class AbstractInterRelationshipConstraintPattern extends FRaMEDConnectionPattern {
public abstract class AbstractInterRelationshipConstraintPattern extends FRaMEDConnectionPattern {
/**
* values for the property shape id gathered from {@link IdentifierLiterals}
......
......@@ -2,10 +2,12 @@ package org.framed.iorm.ui.providers;
import org.eclipse.graphiti.dt.IDiagramTypeProvider;
import org.eclipse.graphiti.features.IDeleteFeature;
import org.eclipse.graphiti.features.IReconnectionFeature;
import org.eclipse.graphiti.features.IRemoveFeature;
import org.eclipse.graphiti.features.context.IContext;
import org.eclipse.graphiti.features.context.ICustomContext;
import org.eclipse.graphiti.features.context.IDeleteContext;
import org.eclipse.graphiti.features.context.IReconnectionContext;
import org.eclipse.graphiti.features.context.IRemoveContext;
import org.eclipse.graphiti.features.custom.ICustomFeature;
import org.eclipse.graphiti.features.impl.DefaultRemoveFeature;
......@@ -99,4 +101,10 @@ public class FeatureProvider extends DefaultFeatureProviderWithPatterns {
public IDeleteFeature getDeleteFeatureAdditional(IDeleteContext Context) {
return new FRaMEDDeleteConnectionFeature(this);
}
//TODO
@Override
public IReconnectionFeature getReconnectionFeature(IReconnectionContext context) {
return new FRaMEDReconnectFeature(this);
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment