本文整理汇总了Java中org.eclipse.uml2.uml.Association类的典型用法代码示例。如果您正苦于以下问题:Java Association类的具体用法?Java Association怎么用?Java Association使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Association类属于org.eclipse.uml2.uml包,在下文中一共展示了Association类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: unsetAssociation
import org.eclipse.uml2.uml.Association; //导入依赖的package包/类
/**
* association설정지움
*
* @param umlModel
* void
*/
public static void unsetAssociation(Association umlModel) {
umlModel.getNearestPackage().getPackagedElements().remove(umlModel);
EList<Property> propertyList = umlModel.getMemberEnds();
Property property;
Element element;
for (Iterator<Property> iter = propertyList.iterator(); iter.hasNext();) {
property = iter.next();
element = property.getOwner();
if (!umlModel.equals(element)) {
((StructuredClassifier) element).getOwnedAttributes().remove(property);
deleteElement(property);
}
}
umlModel.getMemberEnds().clear();
deleteElement(umlModel);
}
示例2: createAssociation
import org.eclipse.uml2.uml.Association; //导入依赖的package包/类
/**
* 클래스간 관계 생성
*
* @param type1
* @param end1IsNavigable
* @param end1Aggregation
* @param end1Name
* @param end1LowerBound
* @param end1UpperBound
* @param type2
* @param end2IsNavigable
* @param end2Aggregation
* @param end2Name
* @param end2LowerBound
* @param end2UpperBound
* @return Association
*/
public static Association createAssociation(Type type1, boolean end1IsNavigable, AggregationKind end1Aggregation,
String end1Name, int end1LowerBound, int end1UpperBound, Type type2,
boolean end2IsNavigable, AggregationKind end2Aggregation,
String end2Name, int end2LowerBound, int end2UpperBound) {
Association association = type1.createAssociation(end1IsNavigable,
end1Aggregation,
end1Name,
end1LowerBound,
end1UpperBound,
type2,
end2IsNavigable,
end2Aggregation,
end2Name,
end2LowerBound,
end2UpperBound);
return association;
}
示例3: createConnectionNameLabel
import org.eclipse.uml2.uml.Association; //导入依赖的package包/类
/**
*
*
* @param association
* @param relation
* @param sourceAnchorLocation
* @param targetAnchorLocation
* @param hasNameLabel
* void
*/
private void createConnectionNameLabel(Association association, AbstractConnection relation,
Point sourceAnchorLocation, Point targetAnchorLocation, boolean hasNameLabel) {
LabelNode associationLabel = UMLDiagramFactory.eINSTANCE.createLabelNode();
associationLabel.setType(LabelType.COMPARTMENT);
associationLabel.setName(association.getName());
associationLabel.setUmlModel(association);
associationLabel.setX(0);
associationLabel.setY(0);
associationLabel.setParent(relation);
int associationWidth = DiagramUtil.getWidthSize(association.getName(), UiCorePlugin.getDefault()
.getFont("default"));
associationLabel.setWidth(associationWidth);
associationLabel.setHeight(40);
if (!hasNameLabel) {
relation.getLabels().add(associationLabel);
}
}
示例4: selectionChanged
import org.eclipse.uml2.uml.Association; //导入依赖的package包/类
/**
* @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction,
* org.eclipse.jface.viewers.ISelection)
*/
public void selectionChanged(IAction action, ISelection selection) {
objList.clear();
objList = ProjectUtil.getSelectedEObjects(selection);
if (objList == null || objList.size() < 1) {
return;
}
for (EObject eobject : objList) {
if (eobject instanceof Lifeline || eobject instanceof Abstraction || eobject instanceof Association
|| eobject instanceof BehaviorExecutionSpecification || eobject instanceof CombinedFragment
|| eobject instanceof Comment || eobject instanceof Connector || eobject instanceof ControlFlow
|| eobject instanceof Dependency || eobject instanceof ExecutionEvent
|| eobject instanceof ExecutionOccurrenceSpecification || eobject instanceof Extend
|| eobject instanceof Generalization || eobject instanceof Include
|| eobject instanceof InteractionOperand || eobject instanceof InterfaceRealization
|| eobject instanceof Message || eobject instanceof MessageOccurrenceSpecification
|| eobject instanceof ObjectFlow || eobject instanceof Realization
|| eobject instanceof ReceiveOperationEvent || eobject instanceof SendOperationEvent
|| eobject instanceof Usage) {
objList.clear();
return;
}
}
}
示例5: checkAssociationsUnambigous
import org.eclipse.uml2.uml.Association; //导入依赖的package包/类
@Check
private void checkAssociationsUnambigous(XtextAssociation association) {
if (StringUtils.isNotEmpty(association.getName())) {
return;
}
List<Classifier<? extends org.eclipse.uml2.uml.Classifier>> chosenTypes = getTypes(association);
if (association.getOwningPackage().getConnectors().stream().filter(XtextAssociation.class::isInstance)
.map(XtextAssociation.class::cast).filter(a -> a != association).map(ClsValidator::getTypes)
.anyMatch(chosenTypes::equals)) {
error("The association is not clearly distinguishable from other associations in this diagram.",
ClsPackage.Literals.XTEXT_ASSOCIATION__MEMBER_END_TYPES, ASSOCIATION_AMBIGUOUS);
return;
}
Collection<Association> candidates = Optional.ofNullable(association.getOwningPackage().getReferencedElement())
.map(umlPackage -> AssociationMatcher.findUMLElements(association, umlPackage))
.orElse(Collections.emptySet());
candidates.remove(association.getReferencedElement());
if (!candidates.isEmpty()) {
error("The association is not clearly distinguishable from other associations in the UML model.",
ClsPackage.Literals.XTEXT_ASSOCIATION__MEMBER_END_TYPES, ASSOCIATION_AMBIGUOUS);
}
}
示例6: match
import org.eclipse.uml2.uml.Association; //导入依赖的package包/类
/**
* Matches the given textual with the given UML association based on the involved member end types.
*
* @param txtAssociation
* The textual association.
* @param umlAssociation
* The UML association.
* @return True if all types match. False otherwise.
*/
public static boolean match(XtextAssociation txtAssociation, Association umlAssociation) {
Optional<List<org.eclipse.uml2.uml.Classifier>> txtUMLTypes = findUMLTypes(txtAssociation);
if (!txtUMLTypes.isPresent()) {
return false;
}
List<Type> umlUMLTypes = umlAssociation.getMemberEnds().stream().map(Property::getType)
.collect(Collectors.toList());
if (txtUMLTypes.get().size() != umlUMLTypes.size() || txtUMLTypes.get().stream().anyMatch(Objects::isNull)) {
return false;
}
for (int i = 0; i < txtUMLTypes.get().size(); ++i) {
if (txtUMLTypes.get().get(i) != umlUMLTypes.get(mapIndexTxt2Uml(i, txtUMLTypes.get().size()))) {
return false;
}
}
return true;
}
示例7: validateCooperateModel
import org.eclipse.uml2.uml.Association; //导入依赖的package包/类
@Override
public boolean validateCooperateModel(IValidationContext ctx, Association target) {
Collection<java.lang.Class<?>> relevantEndTypes = Arrays.asList(Class.class, Interface.class);
if (!target.getEndTypes().stream().allMatch(
testType -> relevantEndTypes.stream().anyMatch(relevantType -> relevantType.isInstance(testType)))) {
// The association is not in a class diagram and therefore not relevant for this constraint
return true;
}
if (!StringUtils.isBlank(target.getName())) {
return true;
}
Collection<Type> wantedTypes = getTypes(target);
return target.getNearestPackage().getMembers().stream().filter(Association.class::isInstance)
.map(Association.class::cast).filter(a -> a != target).allMatch(a -> !getTypes(a).equals(wantedTypes));
}
开发者ID:Cooperate-Project,项目名称:CooperateModelingEnvironment,代码行数:18,代码来源:ClassDiagramAssociationConstraint.java
示例8: ClassAttributeLink
import org.eclipse.uml2.uml.Association; //导入依赖的package包/类
/**
* Creates a ClassAttributeLink based on the EMF-UML model-elements and
* layout information provided
*
* @param layout
* the layout informations of this link
* @param assoc
* the EMF-UML model-element which holds informations of this
* diagram element
* @param fromClass
* the EMF-UML model Class belonging to the from end of this
* association
* @param toClass
* the EMF-UML model Class belonging to the to end of this
* association
* @throws UnexpectedEndException
* Exception is thrown if an association's end could not be
* linked to the EMF-UML model
*/
public ClassAttributeLink(LineAssociation layout, Association assoc, Classifier fromClass, Classifier toClass)
throws UnexpectedEndException {
super(layout);
name = assoc.getLabel();
from = null;
to = null;
for (Property end : assoc.getMemberEnds()) {
Class endClass = (Class) end.getType();
// when handling reflexive links then first add the to end's, then
// the from end's model information (to match the Papyrus exporter
// behavior)
if (endClass == toClass && to == null) {
to = new AssociationEnd(end);
} else if (endClass == fromClass && from == null) {
from = new AssociationEnd(end);
} else {
throw new UnexpectedEndException(end.getName());
}
}
}
示例9: buildAssociationModel
import org.eclipse.uml2.uml.Association; //导入依赖的package包/类
private FHIMInformationModel.Association buildAssociationModel(Association association) {
String name = association.getName();
FHIMInformationModel.Association associationModel = new FHIMInformationModel.Association(name);
LOG.debug("Association: " + name);
// Expect binary associations.
Preconditions.checkArgument(association.isBinary());
// "Owned" ends.
EList<Property> ownedEnds = association.getOwnedEnds();
// Member ends.
EList<Property> memberEnds = association.getMemberEnds();
for (Property memberEnd : memberEnds) {
LOG.debug(" memberEnd: " + memberEnd.getName());
FHIMInformationModel.Attribute memberEndModel = getAttributeModel(memberEnd);
associationModel.addMemberEnd(memberEndModel);
boolean owned = ownedEnds.contains(memberEnd);
LOG.debug(" owned: " + owned);
associationModel.setOwned(memberEndModel, owned);
}
return associationModel;
}
示例10: caseALinkIdentifierExpression
import org.eclipse.uml2.uml.Association; //导入依赖的package包/类
@Override
public void caseALinkIdentifierExpression(ALinkIdentifierExpression node) {
ReadLinkAction action = (ReadLinkAction) builder.createAction(IRepository.PACKAGE.getReadLinkAction());
try {
InputPin linkEndValue = builder.registerInput(action.createInputValue(null, null));
node.getIdentifierExpression().apply(this);
ObjectNode source = ActivityUtils.getSource(linkEndValue);
Classifier targetClassifier = (Classifier) TypeUtils.getTargetType(getRepository(), source, true);
Property openEnd = parseRole(targetClassifier, node.getAssociationTraversal());
Association association = openEnd.getAssociation();
linkEndValue.setType(targetClassifier);
int openEndIndex = association.getMemberEnds().indexOf(openEnd);
Property fedEnd = association.getMemberEnds().get(1 - openEndIndex);
LinkEndData endData = action.createEndData();
endData.setEnd(fedEnd);
endData.setValue(linkEndValue);
builder.registerOutput(action.createResult(null, openEnd.getType()));
TypeUtils.copyType(openEnd, action.getResult());
fillDebugInfo(action, node);
} finally {
builder.closeAction();
}
checkIncomings(action, node.getAssociationTraversal(), getBoundElement());
}
示例11: parseSimpleTraversal
import org.eclipse.uml2.uml.Association; //导入依赖的package包/类
private Property parseSimpleTraversal(Classifier sourceType, ASimpleAssociationTraversal node) {
final String openEndName = TextUMLCore.getSourceMiner().getIdentifier(node.getIdentifier());
Property openEnd = sourceType.getAttribute(openEndName, null);
Association association;
if (openEnd == null) {
EList<Association> associations = sourceType.getAssociations();
for (Association current : associations)
if ((openEnd = current.getMemberEnd(openEndName, null)) != null)
break;
if (openEnd == null) {
problemBuilder.addProblem(new UnknownRole(sourceType.getQualifiedName() + NamedElement.SEPARATOR
+ openEndName), node.getIdentifier());
throw new AbortedStatementCompilationException();
}
}
association = openEnd.getAssociation();
if (association == null) {
problemBuilder.addError(openEndName + " is not an association member end", node.getIdentifier());
throw new AbortedStatementCompilationException();
}
return openEnd;
}
示例12: testSimpleAggregation
import org.eclipse.uml2.uml.Association; //导入依赖的package包/类
public void testSimpleAggregation() throws CoreException {
String source = "";
source += "model simple;\n";
source += "aggregation AccountClient\n";
source += " navigable role account : Account[*];\n";
source += " navigable role client : Client[1];\n";
source += "end;\n";
source += "end.";
parseAndCheck(getSimpleModelSource(), source);
final Association association = (Association) getRepository().findNamedElement("simple::AccountClient",
IRepository.PACKAGE.getAssociation(), null);
assertNotNull(association);
Property accountEnd = association.getOwnedEnd("account", null);
assertNotNull(accountEnd);
assertEquals(AggregationKind.SHARED_LITERAL, accountEnd.getAggregation());
Property clientEnd = association.getOwnedEnd("client", null);
assertNotNull(clientEnd);
assertEquals(AggregationKind.NONE_LITERAL, clientEnd.getAggregation());
}
示例13: testSimpleComposition
import org.eclipse.uml2.uml.Association; //导入依赖的package包/类
public void testSimpleComposition() throws CoreException {
String source = "";
source += "model simple;\n";
source += "composition AccountClient\n";
source += " navigable role account : Account[*];\n";
source += " navigable role client : Client[1];\n";
source += "end;\n";
source += "end.";
parseAndCheck(getSimpleModelSource(), source);
final Association association = getRepository().findNamedElement("simple::AccountClient",
IRepository.PACKAGE.getAssociation(), null);
assertNotNull(association);
Property accountEnd = association.getOwnedEnd("account", null);
assertNotNull(accountEnd);
assertEquals(AggregationKind.COMPOSITE_LITERAL, accountEnd.getAggregation());
Property clientEnd = association.getOwnedEnd("client", null);
assertNotNull(clientEnd);
assertEquals(AggregationKind.NONE_LITERAL, clientEnd.getAggregation());
}
示例14: checkRelationTarget
import org.eclipse.uml2.uml.Association; //导入依赖的package包/类
/**
* relation의 source와 target이 같은지 검사
*
* @param relationship
* @param sourceElement
* @param targetElement
* @return boolean
*/
private static boolean checkRelationTarget(Relationship relationship, NamedElement targetElement) {
if (relationship instanceof Dependency) {
Dependency dependency = (Dependency) relationship;
EList<NamedElement> suppliers = dependency.getSuppliers();
for (NamedElement element : suppliers) {
if (targetElement.equals(element)) {
return true;
}
}
} else if (relationship instanceof Generalization) {
Generalization generalization = (Generalization) relationship;
if (targetElement.equals(generalization.getGeneral())) {
return true;
}
} else if (relationship instanceof Association) {
Association association = (Association) relationship;
EList<Type> endTypes = association.getEndTypes();
for (Type type : endTypes) {
if (targetElement.equals(type)) {
return true;
}
}
}
return false;
}
示例15: setAssociationForStructuredClassifier
import org.eclipse.uml2.uml.Association; //导入依赖的package包/类
/**
* Association설정
*
* @param relationType
* @param umlModel
* @param supplier
* @param isNevigableSupplier
* @param client
* @param isNevigableClient
* void
*/
public static void setAssociationForStructuredClassifier(Association umlModel, NamedElement supplier,
boolean isNevigableSupplier,
AggregationKind aggregationKindSupplier,
NamedElement client, boolean isNevigableClient,
AggregationKind aggregationKindClient) {
Property supplierProperty = UMLHelper.createProperty();
Property clientProperty = UMLHelper.createProperty();
supplierProperty.setType((Type) client);
clientProperty.setType((Type) supplier);
clientProperty.setName(supplier.getName().toLowerCase());
supplierProperty.setName(client.getName().toLowerCase());
supplierProperty.setAggregation(aggregationKindSupplier);
clientProperty.setAggregation(aggregationKindClient);
supplierProperty.setAssociation(umlModel);
clientProperty.setAssociation(umlModel);
if (isNevigableSupplier) {
setProperty(supplier, supplierProperty);
} else {
umlModel.getOwnedEnds().add(supplierProperty);
}
if (isNevigableClient) {
setProperty(client, clientProperty);
} else {
umlModel.getOwnedEnds().add(clientProperty);
}
org.eclipse.uml2.uml.Package packageElement = client.getNearestPackage();
if (client instanceof Component) {
((Component) client).getPackagedElements().add(umlModel);
} else {
packageElement.getPackagedElements().add(umlModel);
}
}