/** @generated */ public static int getNodeVisualID(View containerView, EObject domainElement) { if (domainElement == null) { return -1; } String containerModelID = SUC.diagram.part.SUCVisualIDRegistry.getModelID(containerView); if (!SUCmodelEditPart.MODEL_ID.equals(containerModelID)) { return -1; } int containerVisualID; if (SUCmodelEditPart.MODEL_ID.equals(containerModelID)) { containerVisualID = SUC.diagram.part.SUCVisualIDRegistry.getVisualID(containerView); } else { if (containerView instanceof Diagram) { containerVisualID = SUCmodelEditPart.VISUAL_ID; } else { return -1; } } switch (containerVisualID) { case SUCmodelEditPart.VISUAL_ID: if (SUCPackage.eINSTANCE.getRole().isSuperTypeOf(domainElement.eClass())) { return RoleEditPart.VISUAL_ID; } if (SUCPackage.eINSTANCE.getUseCase().isSuperTypeOf(domainElement.eClass())) { return UseCaseEditPart.VISUAL_ID; } break; } return -1; }
/** @generated */ public static int getLinkWithClassVisualID(EObject domainElement) { if (domainElement == null) { return -1; } if (RelationshipPackage.eINSTANCE .getModelElementEndpointReference() .isSuperTypeOf(domainElement.eClass()) && isModelElementEndpointReference_4011((ModelElementEndpointReference) domainElement)) { return ModelElementEndpointReferenceEditPart.VISUAL_ID; } if (RelationshipPackage.eINSTANCE.getBinaryLinkReference().isSuperTypeOf(domainElement.eClass()) && isBinaryLinkReference_4012((BinaryLinkReference) domainElement)) { return BinaryLinkReferenceEditPart.VISUAL_ID; } if (RelationshipPackage.eINSTANCE.getBinaryLinkReference().isSuperTypeOf(domainElement.eClass()) && isBinaryLinkReference_4013((BinaryLinkReference) domainElement)) { return BinaryLinkReference2EditPart.VISUAL_ID; } if (RelationshipPackage.eINSTANCE .getModelElementEndpointReference() .isSuperTypeOf(domainElement.eClass()) && isModelElementEndpointReference_4014((ModelElementEndpointReference) domainElement)) { return ModelElementEndpointReference2EditPart.VISUAL_ID; } return -1; }
@Override public IStatus validate(IValidationContext ctx) { EObject eObj = ctx.getTarget(); EMFEventType eType = ctx.getEventType(); // In the case of batch mode. if (eType == EMFEventType.NULL) { String id = null; if (eObj instanceof BaseElement) { id = ((BaseElement) eObj).getId(); } if (!SyntaxCheckerUtils.isNCName(id)) { return ctx.createFailureStatus(new Object[] {eObj.eClass().getName()}); } // In the case of live mode. } else { String newValue = (String) ctx.getFeatureNewValue(); if (!SyntaxCheckerUtils.isNCName(newValue)) { return ctx.createFailureStatus(new Object[] {eObj.eClass().getName()}); } } return ctx.createSuccessStatus(); }
/* * Fallbacks in case a property provider does not exist */ public static String getDisplayName(EObject object) { String objName = null; if (object instanceof BPMNDiagram) { Bpmn2DiagramType type = ModelUtil.getDiagramType((BPMNDiagram) object); if (type == Bpmn2DiagramType.CHOREOGRAPHY) { objName = "Choreography Diagram"; } else if (type == Bpmn2DiagramType.COLLABORATION) { objName = "Collaboration Diagram"; } else if (type == Bpmn2DiagramType.PROCESS) { objName = "Process Diagram"; } } if (objName == null) { objName = ModelUtil.toDisplayName(object.eClass().getName()); } EStructuralFeature feature = object.eClass().getEStructuralFeature("name"); if (feature != null) { String name = (String) object.eGet(feature); if (name == null || name.isEmpty()) name = "Unnamed " + objName; else name = objName + " \"" + name + "\""; return name; } feature = object.eClass().getEStructuralFeature("id"); if (feature != null) { if (object.eGet(feature) != null) objName = (String) object.eGet(feature); } feature = object.eClass().getEStructuralFeature("qName"); if (feature != null) { Object qName = object.eGet(feature); if (qName != null) { return qName.toString(); } } return objName; }
@Override public void update(ViewerCell cell) { EObject o = (EObject) cell.getElement(); String label = ""; // $NON-NLS-1$ Image img = null; AbstractComponentEditor elementEditor = getEditor().getEditor(o.eClass()); if (elementEditor != null) { label = elementEditor.getDetailLabel(o); label = label == null ? elementEditor.getLabel(o) : label; img = elementEditor.getImage(o, composite.getDisplay()); } List<String> parentPath = new ArrayList<String>(); while (o.eContainer() != null) { o = o.eContainer(); elementEditor = getEditor().getEditor(o.eClass()); if (elementEditor != null) { parentPath.add(0, elementEditor.getLabel(o)); } } String parentString = ""; // $NON-NLS-1$ for (String p : parentPath) { parentString += "/" + p; // $NON-NLS-1$ } StyledString s = new StyledString(label); s.append(" - " + parentString, StyledString.DECORATIONS_STYLER); // $NON-NLS-1$ cell.setStyleRanges(s.getStyleRanges()); cell.setText(s.getString()); cell.setImage(img); }
private EOperation findOperation(EObject object, String className, String methodName) { // We try to find the corresponding EOperation in the execution // metamodel for (EOperation operation : object.eClass().getEAllOperations()) { // TODO !!! this is not super correct yet as overloading allows the // definition of 2 methods with the same name !!! if (operation.getName().equalsIgnoreCase(methodName)) { return operation; } } // If we didn't find it, we try to find the class that should contain // this operation EClass containingEClass = null; if (getFQN(object.eClass(), "").equalsIgnoreCase(className)) containingEClass = object.eClass(); else for (EClass candidate : object.eClass().getEAllSuperTypes()) { if (getFQN(candidate, "").equalsIgnoreCase(className)) containingEClass = candidate; } // Then we create the missing operation (VERY approximatively) EOperation operation = EcoreFactory.eINSTANCE.createEOperation(); if (containingEClass != null) containingEClass.getEOperations().add(operation); operation.setName(methodName); return operation; }
/* * (non-Javadoc) * * @see com.puppetlabs.geppetto.pp.dsl.linking.IMessageAcceptor#accept(org.eclipse.xtext.diagnostics.Severity, java.lang.String, * org.eclipse.emf.ecore.EObject, org.eclipse.emf.ecore.EStructuralFeature, int, java.lang.String, java.lang.String) */ @Override public void accept( Severity severity, String message, EObject source, EStructuralFeature feature, int index, String issueCode, String... issueData) { if (severity == null) throw new IllegalArgumentException("severity can not be null"); if (feature == null) throw new IllegalArgumentException("feature can not be null"); if (source == null) throw new IllegalArgumentException("source can not be null"); if (source.eClass().getEStructuralFeature(feature.getName()) != feature) { throw new IllegalArgumentException( "EClass '" + source.eClass().getName() + "' does not expose a feature '" + feature.getName() + // "' (id: " + feature.getFeatureID() + ")"); } producer.setNode(getNode(source, feature, index)); DiagnosticMessage m = new DiagnosticMessage(message, severity, issueCode, issueData); producer.addDiagnostic(m); }
private void createModel() { EFactory factory = metamodelPackage.getEFactoryInstance(); netObject = factory.create(getNetClass()); place1Object = factory.create(getPlaceClass()); setName(place1Object, "place1"); setTokens(place1Object, 1); place2Object = factory.create(getPlaceClass()); setName(place2Object, "place2"); transitionObject = factory.create(getTransitionClass()); setIncoming(transitionObject, place1Object); setOutgoing(transitionObject, place2Object); EList<EObject> placesValue = new BasicEList<EObject>(); placesValue.add(place1Object); placesValue.add(place2Object); EReference placesReference = getPlacesReference(netObject.eClass()); netObject.eSet(placesReference, placesValue); EList<EObject> transitionsValue = new BasicEList<EObject>(); transitionsValue.add(transitionObject); EReference transitionsReference = getTransitionsReference(netObject.eClass()); netObject.eSet(transitionsReference, transitionsValue); }
@Override public void createSequence(EObject context, EObject semanticObject) { if (semanticObject.eClass().getEPackage() == DomainmodelPackage.eINSTANCE) switch (semanticObject.eClass().getClassifierID()) { case DomainmodelPackage.DATA_TYPE: sequence_DataType(context, (DataType) semanticObject); return; case DomainmodelPackage.DOMAIN_MODEL: sequence_DomainModel(context, (DomainModel) semanticObject); return; case DomainmodelPackage.ENTITY: sequence_Entity(context, (Entity) semanticObject); return; case DomainmodelPackage.FEATURE: sequence_Feature(context, (Feature) semanticObject); return; case DomainmodelPackage.IMPORT: sequence_Import(context, (Import) semanticObject); return; case DomainmodelPackage.PACKAGE_DECLARATION: sequence_PackageDeclaration(context, (PackageDeclaration) semanticObject); return; } if (errorAcceptor != null) errorAcceptor.accept( diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context)); }
public Object eval(EObject expr, LogEntry parentLog) throws InterpreterException { LogEntry localLog = parentLog.child(LogEntry.Kind.eval, expr, "evaluating " + expr.eClass().getName()); throw new InterpreterException( expr, "generated eval(...) method cannot handle type " + expr.eClass().getName()); }
/** @return An Image for an EObject instance */ private Image getObjectImage(EObject eObject) { IElementUIProvider provider = ElementUIFactory.INSTANCE.getProvider(eObject.eClass()); if (provider != null) { return provider.getImage(eObject); } return getEClassImage(eObject.eClass()); }
protected String toClassWithName(EObject obj) { String className = obj.eClass().getName(); EStructuralFeature nameFeature = obj.eClass().getEStructuralFeature("name"); if (nameFeature != null) { Object name = obj.eGet(nameFeature); if (name != null) return className + "'" + name + "'"; } return className; }
public EObject GetObjectRoot(EObject param_obj) { EObject result = dslComponentFactoryImpl.eINSTANCE.create(param_obj.eClass()); EList<EAttribute> result_attr = result.eClass().getEAllAttributes(); for (EAttribute eAttribute : result_attr) { result.eSet(eAttribute, param_obj.eGet(eAttribute)); } return result; }
/** * This basically calls a setter via EMF reflection to set a structural feature. * * <ul> * <li>If <code>value</code> is a {@link List} of elements, the feature <code>ref</code> must, * of course, also be a list. * <li>If <code>value</code> is a single element, then <code>ref</code> might have multiplicity * <code>1</code> or it might also be a list. In the latter case, <code>value</code> is * added to the list. * </ul> * * @param obj The object which holds the feature to set. * @param ref The feature which should be set. * @param value The value that should be set. * @return <code>true</code>, if the value could be set or <b>if it was already set</b>; <code> * false</code> otherwise. */ @SuppressWarnings("unchecked") public static boolean setStructuralFeature(EObject obj, EStructuralFeature ref, Object value) { if (!ref.isChangeable()) { throw new IllegalArgumentException( "Cannot set a non-changeable reference: " + obj.eClass().getName() + "." + ref.getName()); } try { if (ref.isMany()) { final List<Object> list = (List<Object>) obj.eGet(ref); if (value instanceof List) { final List<Object> valueList = (List<Object>) value; for (final Object listValue : valueList) { if (!list.contains(listValue) && !list.add(listValue)) { return false; } } } else { if (!list.contains(value) && !list.add(value)) { return false; } } return true; } else { if (value instanceof List) { final List<Object> valueList = (List<Object>) value; if (valueList.size() > 1) { throw new IllegalArgumentException( "Cannot set a list of values to a non-many feature!"); } else if (valueList.size() == 1) { if (obj.eGet(ref) == null || !obj.eGet(ref).equals(valueList.get(0))) { obj.eSet(ref, valueList.get(0)); } } else { obj.eSet(ref, null); } } else { if (obj.eGet(ref) == null || !obj.eGet(ref).equals(value)) { obj.eSet(ref, value); } } return true; } } catch (final Exception e) { throw new IllegalArgumentException( "Could not set value (" + value + ") to: " + obj.eClass().getName() + "." + ref.getName() + " of object " + obj, e); } }
/** * @param copyObjs * @return 转换为粘贴对象 */ private Collection<Object> getPasteObjs(Collection<Object> copyObjs, EClass eclass) { List<Object> objs = new ArrayList<Object>(); Map<EStructuralFeature, EStructuralFeature> map = new HashMap<EStructuralFeature, EStructuralFeature>(); // 由第一个复制对象,找出复制对象和粘贴对象匹配的属性 Iterator<Object> it = copyObjs.iterator(); if (it.hasNext()) { Object obj = it.next(); if (obj instanceof EObject) { EObject copyObj = (EObject) obj; // 如果是同一个编辑器内进行粘贴,直接返回复制对象集合 if (copyObj.eClass().equals(eclass)) { return copyObjs; } // name一样,则表示属性匹配 for (EStructuralFeature copyFeature : copyObj.eClass().getEAllStructuralFeatures()) { if (!exclude.contains(copyFeature)) { for (EStructuralFeature pasteFeature : eclass.getEAllStructuralFeatures()) { if (StringUtils.equals(copyFeature.getName(), pasteFeature.getName())) { map.put(copyFeature, pasteFeature); break; } } } } } } // 如果没有匹配的属性,则返回空集合 if (map.isEmpty()) { return objs; } for (Object obj : copyObjs) { EObject copyObj = (EObject) obj; EObject pasteObj = eclass.getEPackage().getEFactoryInstance().create(eclass); for (Entry<EStructuralFeature, EStructuralFeature> entry : map.entrySet()) { EStructuralFeature copyFeature = entry.getKey(); EStructuralFeature pasteFeature = entry.getValue(); if (copyFeature instanceof EAttribute) { // 设置匹配属性值 pasteObj.eSet(pasteFeature, copyObj.eGet(copyFeature)); } else if (copyFeature instanceof EReference) { // 设置匹配子集 Collection<Object> tmp = (Collection<Object>) copyObj.eGet(copyFeature); if (tmp != null) { pasteObj.eSet( pasteFeature, getPasteObjs( EcoreUtil.copyAll(tmp), ((EReference) pasteFeature).getEReferenceType())); } } } objs.add(pasteObj); } return objs; }
private static void checkObject( EObject expected, EObject actual, Set<EStructuralFeature> excludeFeatures, Set<EObject> visited) { if (expected == null) { assertThat(actual, is(nullValue())); return; } if (visited.contains(expected)) return; visited.add(expected); assertThat( "Actual instance for type '" + expected.eClass().getName() + "' must not be null", actual, is(notNullValue())); for (EAttribute attribute : expected.eClass().getEAllAttributes()) { if (!excludeFeatures.contains(attribute)) assertThat( "Attribute '" + attribute.getName() + "' on class '" + expected.eClass().getName() + "' did not match", actual.eGet(attribute), is(expected.eGet(attribute))); } for (EReference reference : expected.eClass().getEAllReferences()) { if (excludeFeatures.contains(reference)) continue; if (reference.isMany()) { @SuppressWarnings("unchecked") EList<EObject> expectedObjects = (EList<EObject>) expected.eGet(reference); @SuppressWarnings("unchecked") EList<EObject> actualObjects = (EList<EObject>) actual.eGet(reference); assertThat( "Reference size for '" + reference.getName() + "' does not match", actualObjects.size(), is(expectedObjects.size())); for (int i = 0; i < expectedObjects.size(); i++) checkObject(expectedObjects.get(i), actualObjects.get(i), excludeFeatures, visited); } else checkObject( (EObject) expected.eGet(reference), (EObject) actual.eGet(reference), excludeFeatures, visited); } }
@SuppressWarnings("unchecked") private void writeTable(PrintWriter out, EObject eObject) { out.println("<h1>" + eObject.eClass().getName() + "</h1>"); out.println("<table>"); for (EStructuralFeature eStructuralFeature : eObject.eClass().getEAllStructuralFeatures()) { if (eStructuralFeature.getEAnnotation("hidden") == null) { out.println("<tr>"); out.println("<td>" + eStructuralFeature.getName() + "</td>"); Object eGet = eObject.eGet(eStructuralFeature); if (eStructuralFeature instanceof EAttribute) { if (eStructuralFeature.getUpperBound() == 1) { out.println("<td>" + eGet + "</td>"); } else { List<Object> list = (List<Object>) eGet; out.println("<td>"); for (Object object : list) { out.println(object + " "); } out.println("</td>"); } } else if (eStructuralFeature instanceof EReference) { if (eStructuralFeature.getUpperBound() == 1) { if (eStructuralFeature.getEType().getEAnnotation("wrapped") != null) { EObject value = (EObject) eGet; if (value != null) { out.println( "<td>" + value.eGet(value.eClass().getEStructuralFeature("wrappedValue")) + "</td>"); } } else { } } else { if (eStructuralFeature.getEType().getEAnnotation("wrapped") != null) { List<EObject> list = (List<EObject>) eGet; out.println("<td>"); for (EObject object : list) { out.println( "<td>" + object.eGet(object.eClass().getEStructuralFeature("wrappedValue")) + "</td>"); } out.println("</td>"); } else { } } } } out.println("</tr>"); } out.println("</table>"); }
@Override public void createSequence(EObject context, EObject semanticObject) { if (semanticObject.eClass().getEPackage() == QualifiedNamePackage.eINSTANCE) switch (semanticObject.eClass().getClassifierID()) { case QualifiedNamePackage.ELEMENT: sequence_Element(context, (Element) semanticObject); return; } if (errorAcceptor != null) errorAcceptor.accept( diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context)); }
void checkFile(IResource resource) { if (resource instanceof IFile) { IFile file = (IFile) resource; if (file.getName().endsWith("xfm.xmi")) { String thisUri = resource.getFullPath().toString(); featureModelUri = getFeatureModelUri(file.getProject()); if (thisUri.equals(featureModelUri)) refreshFeatureModel(file.getProject()); } if (file.getName().endsWith(".v")) { builder.deleteMarkers(file); checkFilenameDepenency(file); checkFileContents(file); } if (file.getName().endsWith(".java")) { try { builder.deleteMarkers(file); List<CommentStructure> comments = buildCommentsStructure(loadFile(file)); if (comments.size() > 0) { for (CommentStructure c : comments) { IParseResult result = injector .getInstance(FeaturesParser.class) .parse("FeatureClause", new ByteArrayInputStream(c.clause.getBytes())); if (result.getParseErrors().size() > 0) { String message = ""; for (SyntaxError err : result.getParseErrors()) message += err.getMessage() + "\n"; Exception e = new RuntimeException("parse error: " + message); log.error("error while parsing feature clause", e); } EObject clause = result.getRootASTElement(); if (clause instanceof Feature) { String feature = clause.eGet(clause.eClass().getEStructuralFeature("feature")).toString(); if (!isFeatureDefined(file, feature)) addMarkerIfNotDefined(feature, file, c.line); } else for (EObject e : EcoreUtil2.eAllContentsAsList(clause)) { if (e instanceof Feature || e instanceof Atom) { String feature = e.eGet(e.eClass().getEStructuralFeature("feature")).toString(); if (!isFeatureDefined(file, feature)) addMarkerIfNotDefined(feature, file, c.line); } } } } } catch (ResourceException e) { log.error("error loading file", e); } catch (Throwable e) { log.error("error loading file", e); } } } }
@Override public Object execute(ExecutionEvent event) throws ExecutionException { IWorkbenchWindow win = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); ISelection selection = win.getSelectionService().getSelection(); List<EObject> context = PapyrusSelectionManager.getESelection(selection); EObject selectedEObject = context.get(0); String metamodel = ((EPackage) selectedEObject.eClass().eContainer()).getNsURI(); String contextType = selectedEObject.eClass().getInstanceClass().getSimpleName(); NewRefactoringWizardJava wizard = new NewRefactoringWizardJava(metamodel, contextType); wizard.init(win.getWorkbench(), (IStructuredSelection) selection); WizardDialog dialog = new WizardDialog(win.getShell(), wizard); return dialog.open(); }
public void createSequence(EObject context, EObject semanticObject) { if (semanticObject.eClass().getEPackage() == Bug301935TestPackage.eINSTANCE) switch (semanticObject.eClass().getClassifierID()) { case Bug301935TestPackage.MODEL: if (context == grammarAccess.getDelegateModelRule() || context == grammarAccess.getModelRule()) { sequence_Model(context, (Model) semanticObject); return; } else break; } if (errorAcceptor != null) errorAcceptor.accept( diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context)); }
public void resolveFuzzy( String identifier, org.eclipse.emf.ecore.EObject container, org.eclipse.emf.ecore.EReference reference, int position, org.emftext.language.office.resource.office.IOfficeReferenceResolveResult< org.eclipse.emf.ecore.EObject> result) { if (container == null) { return; } if (org.emftext.language.office.OfficePackage.eINSTANCE.getEmployee().isInstance(container)) { OfficeFuzzyResolveResult<org.emftext.language.office.Office> frr = new OfficeFuzzyResolveResult<org.emftext.language.office.Office>(result); String referenceName = reference.getName(); org.eclipse.emf.ecore.EStructuralFeature feature = container.eClass().getEStructuralFeature(referenceName); if (feature != null && feature instanceof org.eclipse.emf.ecore.EReference && referenceName != null && referenceName.equals("worksIn")) { employeeWorksInReferenceResolver.resolve( identifier, (org.emftext.language.office.Employee) container, (org.eclipse.emf.ecore.EReference) feature, position, true, frr); } } if (org.emftext.language.office.OfficePackage.eINSTANCE.getEmployee().isInstance(container)) { OfficeFuzzyResolveResult<org.emftext.language.office.Employee> frr = new OfficeFuzzyResolveResult<org.emftext.language.office.Employee>(result); String referenceName = reference.getName(); org.eclipse.emf.ecore.EStructuralFeature feature = container.eClass().getEStructuralFeature(referenceName); if (feature != null && feature instanceof org.eclipse.emf.ecore.EReference && referenceName != null && referenceName.equals("worksWith")) { employeeWorksWithReferenceResolver.resolve( identifier, (org.emftext.language.office.Employee) container, (org.eclipse.emf.ecore.EReference) feature, position, true, frr); } } }
private String matches( org.eclipse.emf.ecore.EObject element, String identifier, boolean matchFuzzy) { // first check for attributes that have set the ID flag to true java.util.List<org.eclipse.emf.ecore.EStructuralFeature> features = element.eClass().getEStructuralFeatures(); for (org.eclipse.emf.ecore.EStructuralFeature feature : features) { if (feature instanceof org.eclipse.emf.ecore.EAttribute) { org.eclipse.emf.ecore.EAttribute attribute = (org.eclipse.emf.ecore.EAttribute) feature; if (attribute.isID()) { Object attributeValue = element.eGet(attribute); String match = matches(identifier, attributeValue, matchFuzzy); if (match != null) { return match; } } } } // then check for an attribute that is called 'name' org.eclipse.emf.ecore.EStructuralFeature nameAttr = element.eClass().getEStructuralFeature(NAME_FEATURE); if (nameAttr instanceof org.eclipse.emf.ecore.EAttribute) { Object attributeValue = element.eGet(nameAttr); return matches(identifier, attributeValue, matchFuzzy); } else { // try any other string attribute found for (org.eclipse.emf.ecore.EAttribute stringAttribute : element.eClass().getEAllAttributes()) { if ("java.lang.String".equals(stringAttribute.getEType().getInstanceClassName())) { Object attributeValue = element.eGet(stringAttribute); String match = matches(identifier, attributeValue, matchFuzzy); if (match != null) { return match; } } } for (org.eclipse.emf.ecore.EOperation o : element.eClass().getEAllOperations()) { if (o.getName().toLowerCase().endsWith(NAME_FEATURE) && o.getEParameters().size() == 0) { String result = (String) ssl.resource.ssl.util.SslEObjectUtil.invokeOperation(element, o); String match = matches(identifier, result, matchFuzzy); if (match != null) { return match; } } } } return null; }
/** @generated */ public static int getLinkWithClassVisualID(EObject domainElement) { if (domainElement == null) { return -1; } if (OwlsPackage.eINSTANCE.getOwlsAssign().isSuperTypeOf(domainElement.eClass())) { return OwlsAssignEditPart.VISUAL_ID; } if (OwlsPackage.eINSTANCE.getOwlsAssignInputClient().isSuperTypeOf(domainElement.eClass())) { return OwlsAssignInputClientEditPart.VISUAL_ID; } if (OwlsPackage.eINSTANCE.getOwlsAssignOutputClient().isSuperTypeOf(domainElement.eClass())) { return OwlsAssignOutputClientEditPart.VISUAL_ID; } return -1; }
/** * Returns a list of potential identifiers that may be used to reference the given element. This * method can be overridden to customize the identification of elements. */ public List<String> getNames(EObject element) { List<String> names = new ArrayList<String>(); // first check for attributes that have set the ID flag to true List<EAttribute> attributes = element.eClass().getEAllAttributes(); for (EAttribute attribute : attributes) { if (attribute.isID()) { Object attributeValue = element.eGet(attribute); if (attributeValue != null) { names.add(attributeValue.toString()); } } } // then check for an attribute that is called 'name' EStructuralFeature nameAttr = element.eClass().getEStructuralFeature(NAME_FEATURE); if (nameAttr instanceof EAttribute) { Object attributeValue = element.eGet(nameAttr); if (attributeValue != null) { names.add(attributeValue.toString()); } } else { // try any other string attribute found for (EAttribute attribute : attributes) { if ("java.lang.String".equals(attribute.getEType().getInstanceClassName())) { Object attributeValue = element.eGet(attribute); if (attributeValue != null) { names.add(attributeValue.toString()); } } } // try operations without arguments that return strings and which have a name that // ends with 'name' for (EOperation operation : element.eClass().getEAllOperations()) { if (operation.getName().toLowerCase().endsWith(NAME_FEATURE) && operation.getEParameters().size() == 0) { Object result = org.emftext.sdk.concretesyntax.resource.cs.util.CsEObjectUtil.invokeOperation( element, operation); if (result != null) { names.add(result.toString()); } } } } return names; }
/** @generated */ protected Image getLabelIcon() { EObject parserElement = getParserElement(); if (parserElement == null) { return null; } return ControlElementTypes.getImage(parserElement.eClass()); }
// // Create the ResultValidatableNode,ResultConstrainingNode cross-linkage for all // validateableObject,constraint pairs. // protected void createResults(@NonNull Set<Resource> resources) { for (Resource resource : resources) { System.out.println("createResults " + resource.getURI()); System.out.println(resource); for (TreeIterator<EObject> tit = resource.getAllContents(); tit.hasNext(); ) { @SuppressWarnings("null") @NonNull EObject eObject = tit.next(); EClass eClass = eObject.eClass(); EAnnotation eAnnotation = eClass.getEAnnotation("http://www.eclipse.org/uml2/2.0.0/UML"); if ((eAnnotation != null) && (eAnnotation.getReferences().size() > 0)) { // Stereotype application EObject umlClass = eAnnotation.getReferences().get(0); if (umlClass != null) { createResultNodes(eObject, getURI(umlClass)); // eClass = null; } } else if (eClass != null) { for (@SuppressWarnings("null") @NonNull URI aType : getTypeClosure(eClass)) { // System.out.println(" ... " + getLabel(eObject) + " " + getLabel(aType)); createResultNodes(eObject, aType); } } } } }
/** @generated */ public static int getNodeVisualID(View containerView, EObject domainElement) { if (domainElement == null) { return -1; } String containerModelID = org.eclipse.gmf.tooling.examples.shortcut.diagram.part.ShortcutVisualIDRegistry.getModelID( containerView); if (!DiagramEditPart.MODEL_ID.equals(containerModelID) && !"Shortcut".equals(containerModelID)) { // $NON-NLS-1$ return -1; } int containerVisualID; if (DiagramEditPart.MODEL_ID.equals(containerModelID)) { containerVisualID = org.eclipse.gmf.tooling.examples.shortcut.diagram.part.ShortcutVisualIDRegistry .getVisualID(containerView); } else { if (containerView instanceof Diagram) { containerVisualID = DiagramEditPart.VISUAL_ID; } else { return -1; } } switch (containerVisualID) { case DiagramEditPart.VISUAL_ID: if (ShortcutPackage.eINSTANCE.getDiagramNode().isSuperTypeOf(domainElement.eClass())) { return DiagramNodeEditPart.VISUAL_ID; } break; } return -1; }
/** @generated */ protected Image getLabelIcon() { EObject parserElement = getParserElement(); if (parserElement == null) { return null; } return OntoUML.diagram.providers.OntoUMLElementTypes.getImage(parserElement.eClass()); }
/** @generated */ public boolean canExecute() { EObject target = getElementToEdit(); ModelAddData data = PolicyChecker.getCurrent() .getChildAddData(diagram, target.eClass(), UMLPackage.eINSTANCE.getInformationItem()); return data.isPermitted(); }