/** Debug function: prints info about a given dataflow port. */ public static void inspectDataFlowPort(Port port) { // Stereotype pst = port.getAppliedStereotypes().get(0); // Type du port if (port.getType() != null) { java.lang.System.out.println("\t\t* type: " + port.getType().getName()); } else { java.lang.System.err.println("\t\t\t* port " + port.getName() + " has no type ! "); } // // // A partir des attributs ci-dessous, on peut récupérer: // - la taille du buffer // - la direction (énuméré IN ou OUT) // - le protocole de synchronization (énuméré SYNCH ou ASYNCH ou UNDEFINED) // for (Property propSt : pst.getAllAttributes()) { java.lang.System.out.println( "\t\t* port stereotype has attribute: " + propSt.getName() + " - " + port.getValue(pst, propSt.getName())); } }
@Override protected boolean isCompatibleMetaclass(Object containerElement, Object metaclass) { Element semanticElement = UMLUtil.resolveUMLElement(containerElement); if (semanticElement == null) { return false; } if (metaclass instanceof Stereotype) { Stereotype stereotype = (Stereotype) metaclass; boolean res = semanticElement.getAppliedStereotype(stereotype.getQualifiedName()) != null; if (!res) { EClass definition = stereotype.getDefinition(); for (EObject e : semanticElement.getStereotypeApplications()) { EClass c = e.eClass(); if (definition != null && definition.isSuperTypeOf(c)) { res = true; break; } } } return res; } // TODO : We should use super.isCompatibleMetaclass(), but the super-implementation // may not be compatible with our implementation of getAdaptedValue() if (metaclass instanceof EClassifier) { return ((EClassifier) metaclass).isInstance(semanticElement); } return false; }
/** Refreshes the stereotype display */ protected void refreshAppliedStereotypesPropertiesInCompartment( String stereotypesPropertiesToDisplay, IPapyrusNodeUMLElementFigure figure) { final boolean displayInCompartment = AppliedStereotypeHelper.hasAppliedStereotypesPropertiesToDisplay( (View) (View) getHost().getModel(), UMLVisualInformationPapyrusConstant.STEREOTYPE_COMPARTMENT_LOCATION); // if the string is not empty, then, the figure has to display it. Else, // it displays nothing final GraphicalEditPart editPart = (GraphicalEditPart) getHost(); final View node = editPart.getNotationView(); int i = 0; // we go through all sub nodes while (i < node.getChildren().size()) { if ((node.getChildren().get(i)) instanceof Node) { final Node currentNode = (Node) (node.getChildren().get(i)); if (currentNode.getType().equals(AppliedStereotypeConpartmentEditPart.ID)) { EObject stereotypeApplication = currentNode.getElement(); Stereotype stereotype = UMLUtil.getStereotype(stereotypeApplication); if (stereotype != null && stereotypesPropertiesToDisplay.contains(stereotype.getQualifiedName())) { setVisivility(currentNode, displayInCompartment); } else { setVisivility(currentNode, false); } } } i++; } }
/** * Gets the proposals. * * @param contents the contents * @param position the position * @return the proposals */ @Override public DecoratedContentProposal[] getProposals(String contents, int position) { ArrayList<DecoratedContentProposal> proposals = new ArrayList<DecoratedContentProposal>(); if (possibleElementList != null) { Iterator it = possibleElementList.getElements().iterator(); while (it.hasNext()) { final Stereotype stereotype = (Stereotype) it.next(); final String simpleName = stereotype.getName(); final String qualifiedName = stereotype.getQualifiedName(); if (position < simpleName.length() && contents .substring(0, position) .equalsIgnoreCase(simpleName.substring(0, position))) { proposals.add(new DecoratedContentProposal(stereotype, labelProvider)); } if (position < qualifiedName.length() && contents .substring(0, position) .equalsIgnoreCase(qualifiedName.substring(0, position))) { proposals.add(new DecoratedContentProposal(stereotype, qualifiedLabelProvider)); } } } Collections.sort(proposals); return proposals.toArray(new DecoratedContentProposal[proposals.size()]); }
public RefOntoUML.Association DealAssociationStereotype(org.eclipse.uml2.uml.Association a1) { System.out.print("<Association> "); RefOntoUML.Association a2 = null; if (a1.getAppliedStereotypes().size() == 1) { org.eclipse.uml2.uml.Stereotype s = a1.getAppliedStereotypes().get(0); System.out.print("<<" + s.getName() + ">> "); String stereoname = s.getName(); if (stereoname.compareTo("Formal") == 0) { a2 = myfactory.createFormalAssociation(); } else if (stereoname.compareTo("Material") == 0) { a2 = myfactory.createMaterialAssociation(); } else if (stereoname.compareTo("Mediation") == 0) { a2 = myfactory.createMediation(); } else if (stereoname.compareTo("Derivation") == 0) { a2 = myfactory.createDerivation(); } else if (stereoname.compareTo("Characterization") == 0) { a2 = myfactory.createCharacterization(); } else if (stereoname.compareTo("componentOf") == 0) { a2 = myfactory.createcomponentOf(); } else if (stereoname.compareTo("memberOf") == 0) { a2 = myfactory.creatememberOf(); } else if (stereoname.compareTo("subCollectionOf") == 0) { a2 = myfactory.createsubCollectionOf(); } else if (stereoname.compareTo("subQuantityOf") == 0) { a2 = myfactory.createsubQuantityOf(); } if (a2 instanceof RefOntoUML.Meronymic) { boolean isShareable = (Boolean) a1.getValue(s, "isShareable"); boolean isEssential = (Boolean) a1.getValue(s, "isEssential"); boolean isInseparable = (Boolean) a1.getValue(s, "isInseparable"); boolean isImmutablePart = (Boolean) a1.getValue(s, "isImmutablePart"); boolean isImmutableWhole = (Boolean) a1.getValue(s, "isImmutableWhole"); ((RefOntoUML.Meronymic) a2).setIsShareable(isShareable); ((RefOntoUML.Meronymic) a2).setIsEssential(isEssential); ((RefOntoUML.Meronymic) a2).setIsInseparable(isInseparable); ((RefOntoUML.Meronymic) a2).setIsImmutablePart(isImmutablePart); ((RefOntoUML.Meronymic) a2).setIsImmutableWhole(isImmutableWhole); } } else if (a1.getAppliedStereotypes().size() == 0) { org.eclipse.uml2.uml.Property memberEnd2 = a1.getMemberEnds().get(1); org.eclipse.uml2.uml.AggregationKind ak = memberEnd2.getAggregation(); if (ak.getValue() == org.eclipse.uml2.uml.AggregationKind.NONE) { a2 = myfactory.createAssociation(); } else { a2 = myfactory.createcomponentOf(); } } DealAssociation(a1, a2); return a2; }
/** * Checks if is selectable element. * * @param text the text * @return true, if is selectable element */ @Override protected boolean isSelectableElement(String text) { // iterate through all possibilities and return true if text corresponds Iterator<Stereotype> it = possibleElementList.getElements().iterator(); while (it.hasNext()) { Stereotype element = it.next(); if (text.equalsIgnoreCase(element.getName()) || text.equalsIgnoreCase(element.getQualifiedName())) { return true; } } return false; }
public static List<org.eclipse.uml2.uml.Property> getOnPort( org.eclipse.uml2.uml.Parameter param) { LinkedList<org.eclipse.uml2.uml.Property> result = new LinkedList<org.eclipse.uml2.uml.Property>(); for (Stereotype st : param.getAppliedStereotypes()) { if (st.getName().contains("OnPort")) { for (Property p : st.getAttributes()) { result.add(p); } } } return result; }
/** * * <!-- begin-user-doc --> * Images registered in Profile are : * * <p>0 - ServicePort Provided 1 - ServicePort Required * <!-- end-user-doc --> * . * * @return the icon of the port * @generated NOT */ public Image getIcon() { Image ImageNotFound = null; if (getBase_Port() != null) { Stereotype st = getBase_Port().getAppliedStereotype("RobotML::ServicePort"); Image image = st.getIcons().get(0); if (getKind() == ServiceFlowKind.REQUIRED) { image = st.getIcons().get(1); } return image; } else { return ImageNotFound; } }
/** * Run add element. * * @param name the name */ @Override protected void runAddElement(String name) { // find the stereotype in the list Stereotype stereotype = null; Iterator<Stereotype> it = possibleElementList.getElements().iterator(); while (it.hasNext()) { Stereotype element = it.next(); if (name.equalsIgnoreCase(element.getName()) || name.equalsIgnoreCase(element.getQualifiedName())) { stereotype = element; } } if (stereotype != null) { runActionAdd(stereotype); } }
/** * Returns the new Id for the section * * @param selectionClass the selected class * @param selectionSize size of the selection * @return the new Id for the section */ protected String getNewFragmentId( EClassifier selectionClass, Stereotype stereotype, int selectionSize) { for (int i = 0; i < 100; i++) { // no need to go to more than 100, because 100 is already a very big number of // fragments boolean found = false; // indicates if the id has been found in already fragments or not StringBuffer buffer = new StringBuffer(); buffer.append("fragment_"); if (selectionSize == 1) { buffer.append("single"); } else if (selectionSize < 0) { buffer.append("multi"); } else { buffer.append(selectionSize); } buffer.append("_"); if (selectionClass != null && selectionClass.getInstanceClass() != null) { buffer.append(selectionClass.getInstanceClass().getSimpleName()); } else if (stereotype != null && stereotype.getName() != null) { buffer.append(stereotype.getName()); } else { buffer.append("NoName"); } if (i > 0) { buffer.append(i); } String name = buffer.toString(); Iterator<IFragmentDescriptorState> it = sectionDescriptorState.getFragmentDescriptorStates().iterator(); while (it.hasNext()) { IFragmentDescriptorState fragmentDescriptorState = it.next(); String id = fragmentDescriptorState.getDescriptor().getId(); if (name.equalsIgnoreCase(id)) { found = true; } } if (!found) { return name; } } return ""; }
public RefOntoUML.Class DealClassStereotype(org.eclipse.uml2.uml.Class c1) { System.out.print("<Class> "); RefOntoUML.Class c2 = null; if (c1.getAppliedStereotypes().size() == 1) { org.eclipse.uml2.uml.Stereotype s = c1.getAppliedStereotypes().get(0); System.out.print("<<" + s.getName() + ">> "); String stereoname = s.getName(); if (stereoname.compareTo("Kind") == 0) { c2 = myfactory.createKind(); } else if (stereoname.compareTo("SubKind") == 0) { c2 = myfactory.createSubKind(); } else if (stereoname.compareTo("Collective") == 0) { c2 = myfactory.createCollective(); boolean isExtensional = (Boolean) c1.getValue(s, "isExtensional"); ((RefOntoUML.Collective) c2).setIsExtensional(isExtensional); } else if (stereoname.compareTo("Quantity") == 0) { c2 = myfactory.createQuantity(); } else if (stereoname.compareTo("Role") == 0) { c2 = myfactory.createRole(); } else if (stereoname.compareTo("Phase") == 0) { c2 = myfactory.createPhase(); } else if (stereoname.compareTo("Category") == 0) { c2 = myfactory.createCategory(); } else if (stereoname.compareTo("Mixin") == 0) { c2 = myfactory.createMixin(); } else if (stereoname.compareTo("RoleMixin") == 0) { c2 = myfactory.createRoleMixin(); } else if (stereoname.compareTo("Relator") == 0) { c2 = myfactory.createRelator(); } else if (stereoname.compareTo("Mode") == 0) { c2 = myfactory.createMode(); } else if (stereoname.compareTo("Quality") == 0) { c2 = myfactory.createQuality(); } } else if (c1.getAppliedStereotypes().size() == 0) { c2 = myfactory.createSubKind(); } DealClass(c1, c2); return c2; }
/** @generated */ public void init_Stereotype_2001(Stereotype instance) { try { Object value_0 = UMLOCLFactory.getExpression(1, UMLPackage.eINSTANCE.getStereotype(), null) .evaluate(instance); instance.setName((String) value_0); } catch (RuntimeException e) { UMLDiagramEditorPlugin.getInstance() .logError("Element initialization failed", e); // $NON-NLS-1$ } }
/** * {@inheritDoc} * * @see * org.eclipse.emf.eef.runtime.impl.components.StandardPropertiesEditionComponent#updateSemanticModel(org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent) * @generated */ public void updateSemanticModel(final IPropertiesEditionEvent event) { Stereotype stereotype = (Stereotype) semanticObject; if (UmlViewsRepository.General.name == event.getAffectedEditor()) { stereotype.setName( (java.lang.String) EEFConverterUtil.createFromString( TypesPackage.Literals.STRING, (String) event.getNewValue())); } if (UmlViewsRepository.General.visibility == event.getAffectedEditor()) { stereotype.setVisibility((VisibilityKind) event.getNewValue()); } if (UmlViewsRepository.General.Qualifiers.abstract_ == event.getAffectedEditor()) { stereotype.setIsAbstract((Boolean) event.getNewValue()); } if (UmlViewsRepository.General.Qualifiers.leaf == event.getAffectedEditor()) { stereotype.setIsLeaf((Boolean) event.getNewValue()); } if (UmlViewsRepository.General.icon == event.getAffectedEditor()) { // FIXME INVALID CASE you must override the template 'declareEObjectUpdater' for the case : // icon, General, Stereotype. } if (UmlViewsRepository.General.Qualifiers.active == event.getAffectedEditor()) { stereotype.setIsActive((Boolean) event.getNewValue()); } }
@Override public Image stereotypeIconToDisplay() { // retrieve the first stereotype in the list of displayed stereotype // String firstStereotypeName = tokenizer.nextToken(); EList<Stereotype> stereotype_list = getUMLElement().getAppliedStereotypes(); if (stereotype_list.size() != 0) { Stereotype stereotype = stereotype_list.get(0); if (stereotype.getName().equals("DataFlowPort") || stereotype.getName().equals("ServicePort")) { Image icon = Activator.getIconElement(getUMLElement(), stereotype, false); IFigure portView = getHostFigure(); IFigure parentView = portView.getParent().getParent(); Rectangle parentBounds = parentView.getBounds(); Rectangle portBounds = portView.getBounds(); if (portBounds.x() <= parentBounds.x()) { // left return icon; } else if (portBounds.x() >= (parentBounds.right() - portBounds.width())) { // right return new Image(icon.getDevice(), RotationHelper.rotateImage(icon, 180)); } else if (portBounds.y() <= parentBounds.y()) { // top return new Image(icon.getDevice(), RotationHelper.rotateImage(icon, 90)); } else if (portBounds.y() >= parentBounds.bottom() - portBounds.height()) { // bottom return new Image(icon.getDevice(), RotationHelper.rotateImage(icon, -90)); } else { return null; } } return Activator.getIconElement(getUMLElement(), stereotype, false); } return null; }
protected void appendStereotype( final Element element, final StringBuffer sb, final boolean includeWrappers) { boolean first = true; final List stereotypes = element.getAppliedStereotypes(); if (stereotypes.isEmpty()) { return; } if (includeWrappers) { sb.append("<<"); // $NON-NLS-1$ } final Iterator iter = stereotypes.iterator(); while (iter.hasNext()) { final Stereotype stereotype = (Stereotype) iter.next(); if (!first) { sb.append(","); // $NON-NLS-1$ } first = false; sb.append(stereotype.getName()); } if (includeWrappers) { sb.append(">>"); // $NON-NLS-1$ } }
/** Debug function. Prints info about a given service port. */ public static void inspectServicePort(Port port) { // Stereotype pst = port.getAppliedStereotypes().get(0); // if (port.getType() != null) { java.lang.System.out.println("\t\t* type: " + port.getType().getName()); } else { java.lang.System.err.println("\t\t\t* port " + port.getName() + " has no type ! "); } // A partir des attributs ci-dessous, on peut récupérer: // - le type d'interface(énuméré Provided ou Required) // - le protocole de synchronization (énuméré SYNCH ou ASYNCH ou UNDEFINED) // for (Property propSt : pst.getAllAttributes()) { java.lang.System.out.println( "\t\t* port stereotype has attribute: " + propSt.getName() + " - " + port.getValue(pst, propSt.getName())); } }
@Override public String stereotypesOnlyToDisplay() { Object hostModel = getHost().getModel(); String result = ""; // $NON-NLS-1$ View view = (View) hostModel; EObject viewElement = view.getElement(); Element element = (Element) viewElement; Iterator<Stereotype> listStereotype = element.getAppliedStereotypes().iterator(); StringBuffer buffer = new StringBuffer(); while (listStereotype.hasNext()) { Stereotype stereotypec = listStereotype.next(); String stereotype_string = stereotypec.getQualifiedName(); buffer.append(stereotype_string); if (listStereotype.hasNext()) { buffer.append(","); // $NON-NLS-1$ } } result = buffer.toString(); if (result.length() != 0) { String stereotypespresentationKind = AppliedStereotypeHelper.getAppliedStereotypePresentationKind(view); // vertical representation if (UMLVisualInformationPapyrusConstant.STEREOTYPE_TEXT_VERTICAL_PRESENTATION.equals( stereotypespresentationKind)) { return Activator.ST_LEFT + stereotypesToDisplay(Activator.ST_RIGHT + "\n" + Activator.ST_LEFT, result, "") + Activator.ST_RIGHT; } else { // horizontal representation return Activator.ST_LEFT + stereotypesToDisplay(", ", result, "") + Activator.ST_RIGHT; } } return result; }
/** * * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ public Stereotype getStereotype() { if (stereotype != null && stereotype.eIsProxy()) { InternalEObject oldStereotype = (InternalEObject) stereotype; stereotype = (Stereotype) eResolveProxy(oldStereotype); if (stereotype != oldStereotype) { if (eNotificationRequired()) eNotify( new ENotificationImpl( this, Notification.RESOLVE, UML2DiffPackage.UML_STEREOTYPE_UPDATE_ATTRIBUTE__STEREOTYPE, oldStereotype, stereotype)); } } return stereotype; }
/** * {@inheritDoc} * * @see * org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#initPart(java.lang.Object, * int, org.eclipse.emf.ecore.EObject, org.eclipse.emf.ecore.resource.ResourceSet) * @generated */ public void initPart(Object key, int kind, EObject elt, ResourceSet allResource) { setInitializing(true); if (editingPart != null && key == partKey) { editingPart.setContext(elt, allResource); final Stereotype stereotype = (Stereotype) elt; final GeneralPropertiesEditionPart generalPart = (GeneralPropertiesEditionPart) editingPart; // init values if (isAccessible(UmlViewsRepository.General.name)) generalPart.setName( EEFConverterUtil.convertToString(TypesPackage.Literals.STRING, stereotype.getName())); if (isAccessible(UmlViewsRepository.General.visibility)) { generalPart.initVisibility( EEFUtils.choiceOfValues(stereotype, UMLPackage.eINSTANCE.getNamedElement_Visibility()), stereotype.getVisibility()); } generalPart.setAbstract_(stereotype.isAbstract()); generalPart.setLeaf(stereotype.isLeaf()); // FIXME NO VALID CASE INTO template public updater(editionElement : PropertiesEditionElement, // view : View, pec : PropertiesEditionComponent) in widgetControl.mtl module, with the values // : icon, General, Stereotype. generalPart.setActive(stereotype.isActive()); // init filters // FIXME NO VALID CASE INTO template public filterUpdater(editionElement : // PropertiesEditionElement, view : View, pec : PropertiesEditionComponent) in // widgetControl.mtl module, with the values : icon, General, Stereotype. // init values for referenced views // init filters for referenced views } setInitializing(false); }
/** * Returns a String that displays stereotypes (using their simple name or their qualified name) * and their properties * * @param editPart the edit part for which the label is edited * @param separator the separator used to split the string representing the stereotypes. * @param stereotypesToDisplay the list of stereotypes displayed * @param stereotypeWithQualifiedName the list of stereotypes displayed using their qualified * names * @param stereotypesPropertiesToDisplay the list of properties to display * @return a string that displays stereotypes (using their simple name or their qualified name) * and their properties */ public String stereotypesAndPropertiesToDisplay( GraphicalEditPart editPart, String separator, String stereotypesToDisplay, String stereotypeWithQualifiedName, String stereotypesPropertiesToDisplay) { // Get the preference from PreferenceStore. there should be an assert final IPreferenceStore store = Activator.getDefault().getPreferenceStore(); if (store == null) { Activator.log.warn("The preference store was not found"); return ""; } // retrieve if the name of the stereotype has to put to lower case or // not String sNameAppearance = store.getString(UMLVisualInformationPapyrusConstant.P_STEREOTYPE_NAME_APPEARANCE); // changes the string of properties into a map, where the entries of the // map are the // stereotype qualified name, and the properties to display are the data Map<String, List<String>> propertiesToDisplay = parseStereotypeProperties(editPart, stereotypesToDisplay, stereotypesPropertiesToDisplay); StringTokenizer strQualifiedName = new StringTokenizer(stereotypesToDisplay, ","); String out = ""; while (strQualifiedName.hasMoreElements()) { String currentStereotype = strQualifiedName.nextToken(); // check if current stereotype is applied final Element umlElement = getUMLElement(editPart); Stereotype stereotype = umlElement.getAppliedStereotype(currentStereotype); if (stereotype != null) { String name = currentStereotype; if ((stereotypeWithQualifiedName.indexOf(currentStereotype)) == -1) { // property value contains qualifiedName ==> extract name // from it StringTokenizer strToken = new StringTokenizer(currentStereotype, "::"); while (strToken.hasMoreTokens()) { name = strToken.nextToken(); } } // AL Changes Feb. 07 - Beg // Handling STEREOTYPE_NAME_APPEARANCE preference (from // ProfileApplicationPreferencePage) // Previously lowercase forced onto first letter (standard UML) // stereotypesToDisplay = stereotypesToDisplay+name.substring(0, // 1).toLowerCase()+name.substring(1, // name.length())+","+separator; // check that the name has not already been added to the // displayed string if (sNameAppearance.equals( UMLVisualInformationPapyrusConstant.P_STEREOTYPE_NAME_DISPLAY_USER_CONTROLLED)) { if (out.indexOf(name) == -1) { out = out + Activator.ST_LEFT + name + Activator.ST_RIGHT + separator; } } else { // VisualInformationPapyrusConstants.P_STEREOTYPE_NAME_DISPLAY_UML_CONFORM)) // { name = name.substring(0, 1).toLowerCase() + name.substring(1, name.length()); if (out.indexOf(name) == -1) { out = out + Activator.ST_LEFT + name + Activator.ST_RIGHT + separator; } } // now should add all properties associated to this stereotype List<String> properties = propertiesToDisplay.get(stereotype.getQualifiedName()); if (properties != null) { // retrieve property for (String propertyName : properties) { out = out + StereotypeUtil.displayPropertyValue( stereotype, StereotypeUtil.getPropertyByName(stereotype, propertyName), getUMLElement(editPart), " "); } } } } if (out.endsWith(",")) { return out.substring(0, out.length() - 1); } if (out.endsWith(separator)) { return out.substring(0, out.length() - separator.length()); } return out; }