org.eclipse.uml2.uml.NamedElement Java Examples
The following examples show how to use
org.eclipse.uml2.uml.NamedElement.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StateMachineRenderer.java From textuml with Eclipse Public License 1.0 | 6 votes |
@Override public boolean renderObject(StateMachine element, IndentedPrintWriter out, IRenderingSession session) { boolean shouldRender = session.getSettings().getBoolean(SHOW_STATEMACHINES); if (!shouldRender) return false; out.println("compound = true;"); out.println("subgraph \"cluster_" + element.getName() + "\" {"); out.enterLevel(); out.println("graph["); out.enterLevel(); out.println("style=\"rounded, dashed\";"); out.exitLevel(); out.println("];"); out.println("label = \"" + element.getNamespace().getName() + NamedElement.SEPARATOR + element.getName() + "\";"); out.println("labeljust = \"l\";"); out.println("fontcolor = \"blue\";"); RenderingUtils.renderAll(session, element.getRegions()); out.exitLevel(); out.println("}"); return true; }
Example #2
Source File: Repository.java From textuml with Eclipse Public License 1.0 | 6 votes |
/** * Finds a named element given its fully qualified name and class. * <p> * Ensures the resource containing the element is loaded. * </p> * * @param qualifiedName * @param eClass * @return */ private NamedElement internalFindNamedElement(String qualifiedName, EClass eClass) { Assert.isNotNull(qualifiedName); // make sure we loaded the resource for the model potentially containing // the element to be found if (MDDUtil.isQualifiedName(qualifiedName)) { String firstSegment = MDDUtil.getFirstSegment(qualifiedName); Package package_ = loadPackage(firstSegment); if (package_ == null) { // try an alias String resolvedAlias = resolveAlias(firstSegment); if (firstSegment.equals(resolvedAlias)) // no alias return null; package_ = loadPackage(resolvedAlias); if (package_ == null) // could not find the root package return null; } } Collection<NamedElement> found = internalFindNamedElements(qualifiedName, eClass); return found.isEmpty() ? null : found.iterator().next(); }
Example #3
Source File: Uml2Service.java From uml2solidity with Eclipse Public License 1.0 | 6 votes |
/** * Returns the directory for the js file. * * @param an * element * @return */ public static String getJsControllerDirectory(NamedElement clazz) { IPreferenceStore store = getStore(clazz); String c_target = store.getString(PreferenceConstants.GENERATION_TARGET); Path c_path = new Path(c_target); String js_target = store.getString(PreferenceConstants.GENERATE_JS_CONTROLLER_TARGET); Path js_path = new Path(js_target); IPath makeRelativeTo = js_path.makeRelativeTo(c_path); if (makeRelativeTo!=null) { return makeRelativeTo.toString(); } return js_target; }
Example #4
Source File: ElementModifiersAssigner.java From txtUML with Eclipse Public License 1.0 | 6 votes |
public static void assignModifiersForElementBasedOnDeclaration(NamedElement element, BodyDeclaration declaration) { int modifiers = declaration.getModifiers(); VisibilityKind visibility = VisibilityProvider.getVisibilityOfNamedElementFromModifiers(element, modifiers); element.setVisibility(visibility); boolean isAbstract = Modifier.isAbstract(modifiers); boolean isStatic = Modifier.isStatic(modifiers); if (element instanceof Classifier) { Classifier classifierElem = (Classifier) element; classifierElem.setIsAbstract(isAbstract); } if (element instanceof BehavioralFeature) { BehavioralFeature featureElem = (BehavioralFeature) element; featureElem.setIsStatic(isStatic); featureElem.setIsAbstract(isAbstract); } if (element instanceof Property) { Property propertyElem = (Property) element; propertyElem.setIsStatic(isStatic); } }
Example #5
Source File: IRepositoryAliasingTests.java From textuml with Eclipse Public License 1.0 | 6 votes |
public void testBasePackageAliasing() throws CoreException { String modelSource = ""; modelSource += "model myBase;\n"; modelSource += "class Object end;\n"; modelSource += "class Integer end;\n"; modelSource += "end."; assertNull(getRepository().findPackage("base", Literals.PACKAGE)); parseAndCheck(modelSource); getRepository().makeAlias("mdd_types", "myBase"); Package basePackage = getRepository().findPackage("mdd_types", Literals.PACKAGE); assertNotNull(basePackage); assertEquals("myBase", basePackage.getQualifiedName()); NamedElement baseObject = getRepository().findNamedElement("mdd_types::Object", Literals.CLASS, null); assertNotNull(baseObject); assertEquals("myBase::Object", baseObject.getQualifiedName()); NamedElement baseInteger = getRepository().findNamedElement("mdd_types::Integer", Literals.CLASS, null); assertNotNull(baseInteger); assertEquals("myBase::Integer", baseInteger.getQualifiedName()); }
Example #6
Source File: BehaviorGenerator.java From textuml with Eclipse Public License 1.0 | 6 votes |
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; }
Example #7
Source File: NamedElementLookupCache.java From textuml with Eclipse Public License 1.0 | 5 votes |
public <T extends NamedElement> T find(String qualifiedName, EClass eClass) { T found = findInCache(qualifiedName, eClass); if (found != null) return found; found = repository.<T> findNamedElement(qualifiedName, eClass, null); if (found != null) addToCache(qualifiedName, found); return (T) found; }
Example #8
Source File: VisibilityProvider.java From txtUML with Eclipse Public License 1.0 | 5 votes |
private static VisibilityKind getVisibilityOfElementWithoutVisibilityModifier(NamedElement element) { if (element instanceof Property) { return VisibilityKind.PRIVATE_LITERAL; } else if (element instanceof Operation || element instanceof org.eclipse.uml2.uml.Classifier) { return VisibilityKind.PUBLIC_LITERAL; } else { return VisibilityKind.PACKAGE_LITERAL; } }
Example #9
Source File: VisibilityProvider.java From txtUML with Eclipse Public License 1.0 | 5 votes |
public static VisibilityKind getVisibilityOfNamedElementFromModifiers(NamedElement element, int modifiers) { if (Modifier.isPrivate(modifiers)) { return VisibilityKind.PRIVATE_LITERAL; } else if (Modifier.isProtected(modifiers)) { return VisibilityKind.PROTECTED_LITERAL; } else if (Modifier.isPublic(modifiers)) { return VisibilityKind.PUBLIC_LITERAL; } else { return getVisibilityOfElementWithoutVisibilityModifier(element); } }
Example #10
Source File: TextUMLCompletionProcessor.java From textuml with Eclipse Public License 1.0 | 5 votes |
private void findStereotypesForNextLine(List<String> proposals, String nextLine) { NamedElement target = null; for (Object[] targets : TARGET_METACLASSES) { final String targetKeyword = (String) targets[0]; if (nextLine.indexOf(targetKeyword) >= 0) { final EClass targetMetaclass = (EClass) targets[1]; selectProposalsFromStereotypes(proposals, findStereotypesForExtendedClass(getStereotypes(), targetMetaclass)); return; } } }
Example #11
Source File: MDDExtensionUtils.java From textuml with Eclipse Public License 1.0 | 5 votes |
public static Constraint createAccessConstraint(NamedElement constrainedElement, String name, Collection<Class> roles, Collection<AccessCapability> allowed) { Stereotype accessStereotype = StereotypeUtils.findStereotype(ACCESS_STEREOTYPE); Enumeration accessCapabilityEnum = MDDCore.getInProgressRepository() .findNamedElement(ACCESS_CAPABILITY_ENUMERATION, Literals.ENUMERATION, null); boolean isStatic = allowed.stream().filter(it -> !it.isInstance()).findAny().isPresent(); Constraint constraint = createConstraint(constrainedElement, name, accessStereotype, isStatic); constraint.setValue(accessStereotype, ACCESS_ALLOWED, toEnumerationLiterals(accessCapabilityEnum, allowed)); constraint.setValue(accessStereotype, ACCESS_ROLES, new LinkedList<>(roles)); return constraint; }
Example #12
Source File: NamedElementUtils.java From textuml with Eclipse Public License 1.0 | 5 votes |
public static void collectParents(List<Namespace> collected, NamedElement current, Collection<EClass> classes) { Namespace namespace = current.getNamespace(); if (namespace == null) return; if (classes.stream().anyMatch((eClass) -> eClass.isInstance(namespace))) collected.add(namespace); collectParents(collected, namespace, classes); }
Example #13
Source File: CommentRenderer.java From textuml with Eclipse Public License 1.0 | 5 votes |
public boolean renderObject(Comment element, IndentedPrintWriter out, IRenderingSession context) { if (!context.getSettings().getBoolean(UML2DOTPreferences.SHOW_COMMENTS)) return false; List<Element> annotatedElements = element.getAnnotatedElements().stream().filter(it -> context.isRendered(it)).collect(Collectors.toList()); if (annotatedElements.isEmpty()) return false; String commentText = generateCommentText(element); if (commentText == null) return false; String commentNodeId = "comment_" + getXMIID(element); out.println('"' + commentNodeId + "\" [shape=note,width=2,height=1,label=\"" + escapeForDot(commentText) + "\"]"); for (Element commented : annotatedElements) { if (commented != element.getNearestPackage()) { String from = "\"" + ((NamedElement) commented).getName() + "\":port"; String to = "\"" + commentNodeId + "\""; out.print(from + " -- " + to); out.println("["); out.runInNewLevel(() -> { addAttribute(out, "head", "none"); addAttribute(out, "tail", "none"); addAttribute(out, "constraint", Boolean.toString(false)); addAttribute(out, "arrowtail", "none"); addAttribute(out, "arrowhead", "none"); addAttribute(out, "style", "dashed"); addAttribute(out, "rank", "-1"); }); out.println("]"); } } return true; }
Example #14
Source File: NamedElementUtils.java From textuml with Eclipse Public License 1.0 | 5 votes |
public static boolean isWithin(NamedElement toCheck, Namespace potentialParent) { if (toCheck == null) return false; if (potentialParent == toCheck) return true; return isWithin(toCheck.getNamespace(), potentialParent); }
Example #15
Source File: Uml2Service.java From uml2solidity with Eclipse Public License 1.0 | 5 votes |
/** * Returns the directory where the junit tests can pickup the contract code. * * @param an * element * @return */ public static String getContractPathForJava(NamedElement clazz) { IPreferenceStore store = getStore(clazz); String co = store.getString(PreferenceConstants.GENERATION_TARGET); Path path = new Path(co); String javaTestDirectory = getJavaSourceDirectory(clazz); Path path2 = new Path(javaTestDirectory); IPath makeRelativeTo = path.makeRelativeTo(path2); //TODO: this is a hack only working in the default test setup if(makeRelativeTo.segmentCount()>2) makeRelativeTo = makeRelativeTo.removeFirstSegments(2); else if(makeRelativeTo.segmentCount()==2) return ""; return makeRelativeTo.toString(); }
Example #16
Source File: UnknownOperation.java From textuml with Eclipse Public License 1.0 | 5 votes |
public UnknownOperation(String type, String operation, String argList, boolean isStatic) { super(type + NamedElement.SEPARATOR + operation); this.classifier = type; this.operation = operation; this.argList = argList; this.isStatic = isStatic; }
Example #17
Source File: TemplateUtils.java From textuml with Eclipse Public License 1.0 | 5 votes |
/** * Generates an element name for the given template and parameter nodes. * Fails if any of the given objects are not named elements. */ public static <PE extends ParameterableElement> String generateBoundElementName(TemplateableElement template, List<PE> templateParameters) { StringBuffer name = new StringBuffer(((NamedElement) template).getName()); name.append("_of"); for (ParameterableElement parameter : templateParameters) { name.append('_'); name.append(((NamedElement) parameter).getName()); } return name.toString(); }
Example #18
Source File: NamedElementUtils.java From textuml with Eclipse Public License 1.0 | 5 votes |
public static Namespace findNearestNamespace(NamedElement element, EClass... classes) { Namespace namespace = element instanceof Namespace ? (Namespace) element : element.getNamespace(); while (namespace != null) { for (EClass clazz : classes) if (clazz.isInstance(namespace)) return namespace; namespace = namespace.getNamespace(); } throw new IllegalArgumentException("Could not find a namespace of the given types"); }
Example #19
Source File: RendererHelper.java From textuml with Eclipse Public License 1.0 | 5 votes |
public static boolean shouldSkip(IRenderingSession context, NamedElement element) { switch (context.getSettings() .getSelection(ShowMinimumVisibilityOptions.class)) { case Private: break; case Protected: if (element.getVisibility() == VisibilityKind.PRIVATE_LITERAL) return true; default: if (element.getVisibility() != VisibilityKind.PUBLIC_LITERAL) return true; } return false; }
Example #20
Source File: ConstraintUtils.java From textuml with Eclipse Public License 1.0 | 5 votes |
public static List<Constraint> findConstraints(NamedElement element, String optionalStereotype) { List<Constraint> result = new ArrayList<Constraint>(); Namespace namespace = element instanceof Namespace ? (Namespace) element : element.getNamespace(); for (Constraint invariant : namespace.getOwnedRules()) { if (optionalStereotype != null && !StereotypeUtils.hasStereotype(invariant, optionalStereotype)) continue; if (invariant.getConstrainedElements().contains(element)) result.add(invariant); } return result; }
Example #21
Source File: StructureBehaviorGenerator.java From textuml with Eclipse Public License 1.0 | 5 votes |
protected Constraint buildInvariantConstraint(ARegularInvariantConstraint invariantNode, BehavioredClassifier currentBehavioredClassifier, NamedElement constrainedElement) { final String invariantName = TextUMLCore.getSourceMiner().getIdentifier(invariantNode.getIdentifier()); Constraint constraint = MDDExtensionUtils.createConstraint(constrainedElement, invariantName, MDDExtensionUtils.INVARIANT_STEREOTYPE); fillDebugInfo(constraint, invariantNode); if (invariantNode.getConstraintException() != null) assignConstraintException(constraint, (AConstraintException) invariantNode.getConstraintException()); behaviorGenerator.createConstraintBehavior(currentBehavioredClassifier, constraint, invariantNode.getExpressionBlock(), Collections.<Parameter> emptyList()); return constraint; }
Example #22
Source File: StateMachineProcessor.java From textuml with Eclipse Public License 1.0 | 5 votes |
@Override public void process(final T node) { Trigger trigger = transition.createTrigger(null); final Event event = (Event) namespaceTracker.currentPackage().createPackagedElement(null, eventClass); trigger.setEvent(event); // process triggers asynchronously as references may not be // resolvable yet referenceTracker.add(new IDeferredReference() { public void resolve(IBasicRepository repository) { NamedElement source = null; if (sourceClass != null) { String sourceName = sourceMiner.getIdentifier(node); source = repository.findNamedElement(sourceName, sourceClass, namespace); if (source == null) { problemBuilder.addProblem(new UnresolvedSymbol(sourceName), node); return; } } if (event instanceof CallEvent) { Operation sourceOperation = (Operation) source; QueryOperationsMustBeSideEffectFree.ensure(!sourceOperation.isQuery(), problemBuilder, node); ((CallEvent) event).setOperation(sourceOperation); } else if (event instanceof SignalEvent) ((SignalEvent) event).setSignal((Signal) source); else if (event instanceof AnyReceiveEvent) ; else Assert.isTrue(false); } }, Step.GENERAL_RESOLUTION); }
Example #23
Source File: StructureGenerator.java From textuml with Eclipse Public License 1.0 | 5 votes |
private boolean ensureNameAvailable(String name, Node node, EClass... eClasses) { Namespace namespace = namespaceTracker.currentNamespace(null); if (name == null || namespace == null) return true; for (EClass expected : eClasses) { final NamedElement found = namespace.getOwnedMember(name, false, expected); if (found != null && EcoreUtil.equals(found.getNamespace(), namespace)) { problemBuilder.addProblem(new DuplicateSymbol(name, found.eClass()), node); return false; } } return true; }
Example #24
Source File: TemplateProcessor.java From textuml with Eclipse Public License 1.0 | 5 votes |
private void createTemplateParameter(String name) { TemplateSignature signature = classifier.getOwnedTemplateSignature(); if (!classifier.isTemplate()) signature = classifier.createOwnedTemplateSignature(templateSignatureClass); TemplateParameter parameter = signature.createOwnedParameter(templateParameterClass); ParameterableElement parameterableElement = parameter.createOwnedParameteredElement(parameterableElementClass); if (parameterableElement instanceof NamedElement) ((NamedElement) parameterableElement).setName(name); }
Example #25
Source File: UnknownOperation.java From textuml with Eclipse Public License 1.0 | 5 votes |
public UnknownOperation(String type, String operation, String argList, boolean isStatic, Operation alternative) { super(type + NamedElement.SEPARATOR + operation); this.classifier = type; this.operation = operation; this.argList = argList; this.isStatic = isStatic; if (alternative != null) this.alternative = alternative.getName() + MDDUtil.getArgumentListString(FeatureUtils.getInputParameters(alternative.getOwnedParameters())); }
Example #26
Source File: Repository.java From textuml with Eclipse Public License 1.0 | 5 votes |
public <T extends NamedElement> T findNamedElement(String name, EClass class_, Namespace namespace) { if (class_ == null) class_ = UMLPackage.Literals.NAMED_ELEMENT; if (namespace == null) { T cached = lookup.findInCache(name, class_); if (cached != null) return cached; } final T found = internalFindNamedElement(name, class_, namespace, true, new HashSet<Namespace>()); if (found != null) lookup.addToCache(namespace == null ? name : found.getQualifiedName(), found); return found; }
Example #27
Source File: Repository.java From textuml with Eclipse Public License 1.0 | 5 votes |
private String resolveAlias(String toResolve, String tail) { if (hasAlias(toResolve)) return getAlias(toResolve) + tail; int separatorIndex = toResolve.lastIndexOf(NamedElement.SEPARATOR); return separatorIndex < 0 ? (toResolve + tail) : (resolveAlias(toResolve.substring(0, separatorIndex), toResolve.substring(separatorIndex)) + tail); }
Example #28
Source File: Repository.java From textuml with Eclipse Public License 1.0 | 5 votes |
public Operation getEntryPointOperation(Package package_) { for (NamedElement element : package_.getOwnedMembers()) { if (!(element instanceof Classifier)) continue; Classifier classifier = (Classifier) element; for (Operation operation : classifier.getOperations()) if (MDDExtensionUtils.isEntryPoint(operation)) return operation; } return null; }
Example #29
Source File: Repository.java From textuml with Eclipse Public License 1.0 | 5 votes |
private Collection<NamedElement> filterByQualifiedName(String qualifiedName, Collection<NamedElement> toFilter) { List<NamedElement> matching = new ArrayList<NamedElement>(toFilter.size()); for (NamedElement current : toFilter) if (qualifiedName.equals(current.getQualifiedName())) matching.add(current); return matching; }
Example #30
Source File: Repository.java From textuml with Eclipse Public License 1.0 | 5 votes |
private <T extends NamedElement> boolean isVisible(Namespace current, T element, boolean fullyQualified) { // TODO support protected and package visibility if (PACKAGE.getPackage().isInstance(element)) return true; Package elementPackage = element.getNearestPackage(); if (elementPackage == current.getNearestPackage()) return true; if (fullyQualified) return element.getVisibility() == VisibilityKind.PUBLIC_LITERAL; List<Package> importedPackages = current.getImportedPackages(); if (importedPackages.contains(elementPackage)) return true; return current instanceof Package && ((Package) current).visibleMembers().contains(element); }