本文整理汇总了Java中org.eclipse.uml2.uml.UMLFactory类的典型用法代码示例。如果您正苦于以下问题:Java UMLFactory类的具体用法?Java UMLFactory怎么用?Java UMLFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
UMLFactory类属于org.eclipse.uml2.uml包,在下文中一共展示了UMLFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createCollaboration
import org.eclipse.uml2.uml.UMLFactory; //导入依赖的package包/类
/**
* Collaboration 생성
*
* @param realizePkg
* @param useCase
* @return Collaboration
*/
private Collaboration createCollaboration(Package realizePkg, UseCase useCase) {
Package ucPackage = realizePkg.getNestedPackage(useCase.getName());
if (ucPackage == null) {
ucPackage = realizePkg.createNestedPackage(useCase.getName());
}
PackageableElement packagedElement = ucPackage.getPackagedElement(useCase.getName());
Collaboration collabo = null;
if (packagedElement instanceof Collaboration) {
collabo = (Collaboration) packagedElement;
} else {
EClass eClass = UMLFactory.eINSTANCE.getUMLPackage().getCollaboration();
collabo = (Collaboration) ucPackage.createPackagedElement(useCase.getName(), eClass);
}
ModelUtility.copyDocumentation(collabo, useCase);
ModelUtility.copyKeywords(useCase, collabo);
return collabo;
}
示例2: createCopyOfOperation
import org.eclipse.uml2.uml.UMLFactory; //导入依赖的package包/类
/**
* Creates new UML operation which is a shallow copy of the specified source
* operation. It copies the name and the visibility of the source operation
* as well as the parameters. For the parameters, it copies the name, type
* and direction of the parameters of the source operation.
*
* @param srcOp
* Source operation
* @return the copy of the operation
*/
public static Operation createCopyOfOperation(Operation srcOp) {
Operation targetOp = UMLFactory.eINSTANCE.createOperation();
targetOp.setName(srcOp.getName());
targetOp.setVisibility(srcOp.getVisibility());
// EList srcParameters = srcOp.getOwnedParameters();
EList srcParameters = srcOp.getOwnedMembers();
for (Iterator piter = srcParameters.iterator(); piter.hasNext();) {
Object element = piter.next();
if (element instanceof Parameter) {
Parameter srcParm = (Parameter) element;
Parameter targetParm = targetOp.createOwnedParameter(srcParm.getName(), srcParm.getType());
targetParm.setDirection(srcParm.getDirection());
}
}
return targetOp;
}
示例3: createUMLModelRoot
import org.eclipse.uml2.uml.UMLFactory; //导入依赖的package包/类
/**
* 최상위 UML 모델 생성
*
* @param uri
* @return Resource
*/
public Resource createUMLModelRoot(URI uri, final String modelName) {
final Resource resource = transactionEditingDomain.getResourceSet().createResource(uri);
DomainUtil.registerDefaultPathmaps();
transactionEditingDomain.getCommandStack().execute(new RecordingCommand(transactionEditingDomain) {
/**
* @see org.eclipse.emf.transaction.RecordingCommand#doExecute()
*/
@Override
protected void doExecute() {
Model umlModelRoot = UMLFactory.eINSTANCE.createModel();
umlModelRoot.setName(modelName);
Model umlLibrary = (Model) DomainUtil.load(URI.createURI(UMLResource.UML_PRIMITIVE_TYPES_LIBRARY_URI));
umlModelRoot.createPackageImport(umlLibrary);
resource.getContents().add(umlModelRoot);
}
});
return resource;
}
示例4: addComment
import org.eclipse.uml2.uml.UMLFactory; //导入依赖的package包/类
/**
* @see nexcore.tool.uml.ui.property.section.DocumentSection#addComment(java.lang.String)
*/
protected void addComment(final String value) {
MessageOccurrenceSpecification mos = (MessageOccurrenceSpecification) getData().getSendEvent();
SendOperationEvent soe = (SendOperationEvent) mos.getEvent();
if (mos != null && soe != null) {
if (soe.getOperation() == null) {
MessageDialog.openWarning(UiCorePlugin.getShell(),
UMLMessage.UML_MODELER,
UMLMessage.getMessage(UMLMessage.MESSAGE_NO_ASSIGNED_OPERATION));
return;
} else {
comment = UMLFactory.eINSTANCE.createComment();
comment.setBody(value);
soe.getOperation().getOwnedComments().clear();
soe.getOperation().getOwnedComments().add(comment);
}
}
}
示例5: setReplyMessage
import org.eclipse.uml2.uml.UMLFactory; //导入依赖的package包/类
/**
* setReplyMessage
*
* @param interaction
* @param client
* @param supplier void
*/
protected void setReplyMessage(Interaction interaction, Lifeline client, Lifeline supplier) {
sendMessageOccurrenceSpecificationForReply = null;
receiveMessageOccurrenceSpecificationForReply = null;
sendEventForReply = null;
receiveEventForReply = null;
replyMessage = UMLFactory.eINSTANCE.createMessage();
replyMessage.setMessageSort(MessageSort.REPLY_LITERAL);
sendMessageOccurrenceSpecificationForReply = UMLFactory.eINSTANCE.createMessageOccurrenceSpecification();
receiveMessageOccurrenceSpecificationForReply = UMLFactory.eINSTANCE.createMessageOccurrenceSpecification();
// Reply Block
if (null != sendMessageOccurrenceSpecificationForReply) {
setReplyMessageFragment(interaction, client, supplier);
setReplyViewModel();
}
replyMessage = SequenceUtil.setOperationToMessage(operation, replyMessage);
}
示例6: createTestModel
import org.eclipse.uml2.uml.UMLFactory; //导入依赖的package包/类
private static Container createTestModel() {
Model umlRoot = UMLFactory.eINSTANCE.createModel();
Container rootElement = DummyFactory.eINSTANCE.createContainer();
ReferencingElement refElem11 = rootElement.createReferencingElement();
setElement(umlRoot, refElem11);
ReferencingElement refElem12 = rootElement.createReferencingElement();
setElement(umlRoot, refElem12);
Container cont11 = rootElement.createContainer();
Container cont21 = cont11.createContainer();
ReferencingElement refElem21 = cont11.createReferencingElement();
setElement(umlRoot, refElem21);
ReferencingElement2 refElem22 = cont11.createReferencingElement2();
refElem22.setReferencedElement(refElem21.getReferencedElement());
return rootElement;
}
开发者ID:Cooperate-Project,项目名称:CooperateModelingEnvironment,代码行数:18,代码来源:UMLReferencingElementFinderTest.java
示例7: testSimpleGetInitializer
import org.eclipse.uml2.uml.UMLFactory; //导入依赖的package包/类
@Test
public void testSimpleGetInitializer() {
Model model = UMLFactory.eINSTANCE.createModel();
IAtomicDerivedStateProcessor simpleProcessor = createMock(IAtomicDerivedStateProcessor.class);
expect(simpleProcessor.getReplacements()).andReturn(Collections.emptyList());
expect(simpleProcessor.getRequirements()).andReturn(Collections.emptyList());
simpleProcessor.accept(model);
replay(simpleProcessor);
initializerMocks.put(Model.class, simpleProcessor);
subject.initState(model);
subject.calculateState(model);
subject.cleanState(model);
verify(simpleProcessor);
}
开发者ID:Cooperate-Project,项目名称:CooperateModelingEnvironment,代码行数:18,代码来源:DerivedStateProcessorTest.java
示例8: testState
import org.eclipse.uml2.uml.UMLFactory; //导入依赖的package包/类
@Test
public void testState() {
// given
org.eclipse.uml2.uml.State s = UMLFactory.eINSTANCE.createState();
s.setContainer(region);
s.setName("S1");
// when
State state = new State(s, "package.A.S1");
state.setLayout(new Rectangle(1, 2, 3, 4));
// then
Assert.assertEquals("package.A.S1", state.getId());
Assert.assertEquals("S1", state.getName());
Assert.assertEquals(1, state.getPosition().getX());
Assert.assertEquals(2, state.getPosition().getY());
Assert.assertEquals(3, state.getWidth().intValue());
Assert.assertEquals(4, state.getHeight().intValue());
}
示例9: createUMLFile
import org.eclipse.uml2.uml.UMLFactory; //导入依赖的package包/类
private void createUMLFile(URI uri, String modelname){
Model model = UMLFactory.eINSTANCE.createModel();
model.setName(modelname);
ResourceSet resourceSet = new ResourceSetImpl();
resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(
UMLResource.FILE_EXTENSION,
UMLResource.Factory.INSTANCE
);
Resource modelResource = resourceSet.createResource(uri);
modelResource.getContents().add(model);
try {
modelResource.save(null);
} catch (IOException e) {
e.printStackTrace();
}
}
示例10: serializeInstance
import org.eclipse.uml2.uml.UMLFactory; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private void serializeInstance(String fileName, Map<String, Boolean> options) {
ResourceSet rscSet = new ResourceSetImpl();
UMLResourcesUtil.init(rscSet);
fileName+=".uml";
Resource resource = rscSet.createResource(URI.createURI(fileName).appendFileExtension(UMLResource.FILE_EXTENSION));
Iterator<EObject> objIt = objList.iterator();
EObject model = UMLFactory.eINSTANCE.createModel();
resource.getContents().add(model);
while (objIt.hasNext()) {
EObject obj = objIt.next();
if (isRoot(obj))
resource.getContents().add(obj);
((List<EObject>) model.eGet(UMLPackage.eINSTANCE.getPackage_PackagedElement())).add(obj);
}
try{
resource.save(options);
}catch (IOException e) {
e.printStackTrace();
}
}
示例11: mapXSDAnnotation
import org.eclipse.uml2.uml.UMLFactory; //导入依赖的package包/类
@Operation(contextual = true, kind = Operation.Kind.HELPER)
public static Boolean mapXSDAnnotation(final XSDAnnotation self, final Element owner) {
final Iterator<org.w3c.dom.Element> elements = self.getUserInformation().iterator();
if (elements.hasNext()) {
final Comment theComment = UMLFactory.eINSTANCE.createComment();
final StringBuilder b = new StringBuilder();
b.append(elements.next().getTextContent());
while (elements.hasNext()) {
b.append('\n');
b.append(elements.next().getTextContent());
}
theComment.setBody(b.toString());
owner.getOwnedComments().add(theComment);
return true;
}
return false;
}
示例12: longTest
import org.eclipse.uml2.uml.UMLFactory; //导入依赖的package包/类
@Test
public void longTest() {
Model model = UMLFactory.eINSTANCE.createModel();
model.setName("myUmlModel");
Interface it1 = UMLFactory.eINSTANCE.createInterface();
it1.setName("it1");
model.getPackagedElements().add(it1);
Interface it2 = UMLFactory.eINSTANCE.createInterface();
it2.setName("it2");
model.getPackagedElements().add(it2);
Generalization gen = UMLFactory.eINSTANCE.createGeneralization();
gen.setGeneral(it2);
it2.getGeneralizations().add(gen);
Interface it3 = UMLFactory.eINSTANCE.createInterface();
it3.setName("it3");
model.getPackagedElements().add(it3);
gen.setGeneral(it3);
Operation op = UMLFactory.eINSTANCE.createOperation();
op.setName("op1");
it3.getOwnedOperations().add(op);
Parameter parameter = UMLFactory.eINSTANCE.createParameter();
parameter.setName("par1");
parameter.setDirection(ParameterDirectionKind.RETURN_LITERAL);
parameter.setType(it1);
op.getOwnedParameters().add(parameter);
assertEquals(1, it2.getAllOperations().size());
}
示例13: createUmlModelWithProperty
import org.eclipse.uml2.uml.UMLFactory; //导入依赖的package包/类
private Property createUmlModelWithProperty() {
Package umlPackage = UMLFactory.eINSTANCE.createPackage();
Class umlClass = UMLFactory.eINSTANCE.createClass();
umlPackage.getPackagedElements().add(umlClass);
Property umlProperty = UMLFactory.eINSTANCE.createProperty();
umlClass.getOwnedAttributes().add(umlProperty);
return umlProperty;
}
示例14: createInteraction
import org.eclipse.uml2.uml.UMLFactory; //导入依赖的package包/类
/**
* Interaction 생성
*
* @param collabo
* @param name
* @return Interaction
*/
private Interaction createInteraction(Collaboration collabo, String name) {
EClass eClass = UMLFactory.eINSTANCE.getUMLPackage().getInteraction();
Behavior ownedBehavior = collabo.getOwnedBehavior(name);
if (ownedBehavior != null && ownedBehavior instanceof Interaction) {
return (Interaction) ownedBehavior;
} else {
return (Interaction) collabo.createOwnedBehavior(name, eClass);
}
}
示例15: createGetter
import org.eclipse.uml2.uml.UMLFactory; //导入依赖的package包/类
/**
* Creates a "getter" UML operation for a UML property.
*
* @param srcProperty
* The UML property
* @return The "getter" operation
*/
public static Operation createGetter(Property srcProperty) {
Operation getter = UMLFactory.eINSTANCE.createOperation();
getter.setName("get_" + srcProperty.getName()); //$NON-NLS-1$
getter.createReturnResult(srcProperty.getName(), srcProperty.getType());
return getter;
}