org.eclipse.emf.ecore.EAnnotation Java Examples

The following examples show how to use org.eclipse.emf.ecore.EAnnotation. 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: NoDocumentationXcoreEcoreBuilder.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected void handleAnnotations(XModelElement xModelElement, EModelElement eModelElement) {
	super.handleAnnotations(xModelElement, eModelElement);

	// the following special handling only applies to EPackages
	if (!(eModelElement instanceof EPackage)) {
		return;
	}

	// obtain annotation that was created based on the automatic inference of copyright headers
	Optional<EAnnotation> inferredAnnotations = eModelElement.getEAnnotations().stream()
			.filter(a -> a.getSource().equals(GenModelPackage.eNS_URI))
			// find annotation that is added automatically by inferring copyright header
			.filter(a -> a.getDetails().containsKey("documentation") && a.getDetails().size() == 1)
			.findFirst();

	// removes annotation from container
	inferredAnnotations.ifPresent(a -> eModelElement.getEAnnotations().remove(a));
}
 
Example #2
Source File: PredicateHandler.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
public String getAttributeName(EStructuralFeature feature,
	Class<? extends EntityWithId> entityClazz){
	String ret = feature.getName();
	EAnnotation mappingAnnotation =
		feature.getEAnnotation(IModelService.EANNOTATION_ENTITY_ATTRIBUTE_MAPPING);
	if (mappingAnnotation != null) {
		// test class specific first
		ret = mappingAnnotation.getDetails().get(entityClazz.getSimpleName() + "#"
			+ IModelService.EANNOTATION_ENTITY_ATTRIBUTE_MAPPING_NAME);
		if (ret == null) {
			// fallback to direct mapping
			ret = mappingAnnotation.getDetails()
				.get(IModelService.EANNOTATION_ENTITY_ATTRIBUTE_MAPPING_NAME);
		}
	}
	return ret;
}
 
Example #3
Source File: TreeLayoutUtil.java    From statecharts with Eclipse Public License 1.0 6 votes vote down vote up
public static void setTreeNodesPositionAnnotation(List<View> viewElements) {
	if (viewElements != null) {
		for (int index = 0; index < viewElements.size(); index++) {
			final View view = viewElements.get(index);
			EAnnotation xmiIdAnnotation = view
					.getEAnnotation(TREE_LAYOUT_ANNOTATION);
			if (xmiIdAnnotation == null) {
				xmiIdAnnotation = EcoreFactory.eINSTANCE
						.createEAnnotation();
				xmiIdAnnotation.setSource(TREE_LAYOUT_ANNOTATION);
			}
			xmiIdAnnotation.getDetails().put(TREE_NODE_POSITION,
					Integer.toString(index));
			xmiIdAnnotation.setEModelElement(view);
		}
	}
}
 
Example #4
Source File: FieldItemSemanticEditPolicy.java    From scava with Eclipse Public License 2.0 6 votes vote down vote up
/**
* @generated
*/
protected Command getDestroyElementCommand(DestroyElementRequest req) {
	View view = (View) getHost().getModel();
	CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
	cmd.setTransactionNestingEnabled(false);
	EAnnotation annotation = view.getEAnnotation("Shortcut"); //$NON-NLS-1$
	if (annotation == null) {
		// there are indirectly referenced children, need extra commands: false
		addDestroyShortcutsCommand(cmd, view);
		// delete host element
		cmd.add(new DestroyElementCommand(req));
	} else {
		cmd.add(new DeleteCommand(getEditingDomain(), view));
	}
	return getGEFWrapper(cmd.reduce());
}
 
Example #5
Source File: Field2ItemSemanticEditPolicy.java    From scava with Eclipse Public License 2.0 6 votes vote down vote up
/**
* @generated
*/
protected Command getDestroyElementCommand(DestroyElementRequest req) {
	View view = (View) getHost().getModel();
	CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
	cmd.setTransactionNestingEnabled(false);
	EAnnotation annotation = view.getEAnnotation("Shortcut"); //$NON-NLS-1$
	if (annotation == null) {
		// there are indirectly referenced children, need extra commands: false
		addDestroyShortcutsCommand(cmd, view);
		// delete host element
		cmd.add(new DestroyElementCommand(req));
	} else {
		cmd.add(new DeleteCommand(getEditingDomain(), view));
	}
	return getGEFWrapper(cmd.reduce());
}
 
Example #6
Source File: ParameterItemSemanticEditPolicy.java    From scava with Eclipse Public License 2.0 6 votes vote down vote up
/**
* @generated
*/
protected Command getDestroyElementCommand(DestroyElementRequest req) {
	View view = (View) getHost().getModel();
	CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
	cmd.setTransactionNestingEnabled(false);
	EAnnotation annotation = view.getEAnnotation("Shortcut"); //$NON-NLS-1$
	if (annotation == null) {
		// there are indirectly referenced children, need extra commands: false
		addDestroyShortcutsCommand(cmd, view);
		// delete host element
		cmd.add(new DestroyElementCommand(req));
	} else {
		cmd.add(new DeleteCommand(getEditingDomain(), view));
	}
	return getGEFWrapper(cmd.reduce());
}
 
Example #7
Source File: LanguageItemSemanticEditPolicy.java    From scava with Eclipse Public License 2.0 6 votes vote down vote up
/**
* @generated
*/
protected Command getDestroyElementCommand(DestroyElementRequest req) {
	View view = (View) getHost().getModel();
	CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
	cmd.setTransactionNestingEnabled(false);
	EAnnotation annotation = view.getEAnnotation("Shortcut"); //$NON-NLS-1$
	if (annotation == null) {
		// there are indirectly referenced children, need extra commands: false
		addDestroyChildNodesCommand(cmd);
		addDestroyShortcutsCommand(cmd, view);
		// delete host element
		cmd.add(new DestroyElementCommand(req));
	} else {
		cmd.add(new DeleteCommand(getEditingDomain(), view));
	}
	return getGEFWrapper(cmd.reduce());
}
 
Example #8
Source File: Field3ItemSemanticEditPolicy.java    From scava with Eclipse Public License 2.0 6 votes vote down vote up
/**
* @generated
*/
protected Command getDestroyElementCommand(DestroyElementRequest req) {
	View view = (View) getHost().getModel();
	CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
	cmd.setTransactionNestingEnabled(false);
	EAnnotation annotation = view.getEAnnotation("Shortcut"); //$NON-NLS-1$
	if (annotation == null) {
		// there are indirectly referenced children, need extra commands: false
		addDestroyShortcutsCommand(cmd, view);
		// delete host element
		cmd.add(new DestroyElementCommand(req));
	} else {
		cmd.add(new DeleteCommand(getEditingDomain(), view));
	}
	return getGEFWrapper(cmd.reduce());
}
 
Example #9
Source File: NoDocumentationInferenceXcoreEcoreBuilder.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected void handleAnnotations(XModelElement xModelElement, EModelElement eModelElement) {
	super.handleAnnotations(xModelElement, eModelElement);

	// the following special handling only applies to EPackages
	if (!(eModelElement instanceof EPackage)) {
		return;
	}

	// obtain annotation that was created based on the automatic inference of copyright headers
	Optional<EAnnotation> inferredAnnotations = eModelElement.getEAnnotations().stream()
			.filter(a -> a.getSource().equals(GenModelPackage.eNS_URI))
			// find annotation that is added automatically by inferring copyright header
			.filter(a -> a.getDetails().containsKey("documentation") && a.getDetails().size() == 1)
			.findFirst();

	// delete @Ecore annotation as it is not present in an incremental build
	Optional<EAnnotation> ecoreAnnotation = eModelElement.getEAnnotations().stream()
			.filter(a -> a.getSource().equals(EcorePackage.eNS_URI))
			.findFirst();

	// removes annotation from container
	inferredAnnotations.ifPresent(a -> eModelElement.getEAnnotations().remove(a));
	ecoreAnnotation.ifPresent(a -> eModelElement.getEAnnotations().remove(a));
}
 
Example #10
Source File: ExclusiveGroups.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Make a set of group ids present in the object collection
 * 
 * @param objects
 *            the objects to check
 * @return the group set, never <code>null</code>
 */
public static Set<String> makeGroupIds ( final Collection<? extends EObject> objects )
{
    final Set<String> result = new HashSet<> ();

    for ( final EObject obj : objects )
    {
        final EAnnotation annotation = findAnnotation ( obj );
        if ( annotation == null )
        {
            continue;
        }
        final String groupId = annotation.getDetails ().get ( VALUE_GROUP_ID );
        if ( groupId == null )
        {
            continue;
        }
        result.add ( groupId );
    }

    return result;
}
 
Example #11
Source File: ExclusiveGroups.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Finds the annotation even on supertypes
 * 
 * @param target
 *            the object to check
 * @return the annotation or <code>null</code> the object or its supertypes
 *         don't have the annotation
 */
public static EAnnotation findAnnotation ( final EObject target )
{
    EAnnotation annotation;

    annotation = target.eClass ().getEAnnotation ( SOURCE_NAME );
    if ( annotation != null )
    {
        logger.debug ( "Found direct annotation - target: {}, annotation: {}", target, annotation );
        return annotation;
    }

    for ( final EClass clazz : target.eClass ().getEAllSuperTypes () )
    {
        logger.debug ( "Checking supertype: {}", clazz );
        annotation = clazz.getEAnnotation ( SOURCE_NAME );
        if ( annotation != null )
        {
            logger.debug ( "Found annotation - target: {}, superclass: {}, annotation: {}", target, clazz, annotation );
            return annotation;
        }
    }
    logger.debug ( "Annotation on {} not found", target );
    return null;
}
 
Example #12
Source File: WorldRunner.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
private NodeElementProcessor createProcessor ( final EObject element, final World world, final ApplicationNode applicationNode ) throws CoreException
{
    final EAnnotation an = element.eClass ().getEAnnotation ( "http://eclipse.org/SCADA/Configuration/World" );

    if ( an != null && Boolean.parseBoolean ( an.getDetails ().get ( "ignore" ) ) )
    {
        return new NodeElementProcessor () {

            @Override
            public void process ( final String phase, final IFolder baseDir, final IProgressMonitor monitor, final Map<String, String> properties ) throws Exception
            {
                // no-op
            }
        };
    }

    for ( final IConfigurationElement ele : Platform.getExtensionRegistry ().getConfigurationElementsFor ( Activator.EXTP_GENERATOR ) )
    {
        if ( !ele.getName ().equals ( ELE_NODE_ELEMENT_PROCESSOR ) )
        {
            continue;
        }
        if ( isMatch ( Activator.getDefault ().getBundle ().getBundleContext (), ele, element ) )
        {
            final NodeElementProcessorFactory factory = (NodeElementProcessorFactory)ele.createExecutableExtension ( "factoryClass" );
            return factory.createProcessor ( element, world, applicationNode );
        }
    }

    throw new IllegalStateException ( String.format ( "No processor found for element: %s", element ) );
}
 
Example #13
Source File: Ecore2UimaTypeSystem.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * Eenum 2 uima type.
 *
 * @param aEEnum the a E enum
 * @param aUimaNamespace the a uima namespace
 * @param aOptions the a options
 * @return the type description
 * @throws URISyntaxException the URI syntax exception
 */
private static TypeDescription eenum2UimaType(EEnum aEEnum, String aUimaNamespace, Map aOptions)
        throws URISyntaxException {
  TypeDescription type = uimaFactory.createTypeDescription();
  // set name
  if (aUimaNamespace != null) {
    type.setName(aUimaNamespace + "." + aEEnum.getName());
  } else {
    type.setName(aEEnum.getName());
  }
  // set supetype to String
  type.setSupertypeName(CAS.TYPE_NAME_STRING);
  // try to get desecription from EAnnotation
  EAnnotation eannot = aEEnum.getEAnnotation("http://uima.apache.org");
  if (eannot != null) {
    type.setDescription((String) eannot.getDetails().get("description"));
  }
  // set allowed values
  EList literals = aEEnum.getELiterals();
  AllowedValue[] vals = new AllowedValue[literals.size()];
  for (int i = 0; i < literals.size(); i++) {
    EEnumLiteral literal = (EEnumLiteral) literals.get(i);
    vals[i] = uimaFactory.createAllowedValue();
    vals[i].setString(literal.getName());
    EAnnotation literalAnnot = literal.getEAnnotation("http://uima.apache.org");
    if (literalAnnot != null) {
      vals[i].setDescription((String) literalAnnot.getDetails().get("description"));
    }
  }
  type.setAllowedValues(vals);
  return type;
}
 
Example #14
Source File: Ecore2UimaTypeSystem.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * Converts an Ecore model to a UIMA TypeSytemDescription.
 * 
 * @param aEcoreResource
 *          An EMF Resource containing the Ecore model
 * @param aOptions
 *          a Map defining options for the conversion. Valid keys for this map are defined as
 *          constants on this class.
 * 
 * @return The UIMA TypeSystemDescription corresponding to the Ecore model
 * @throws URISyntaxException
 *           if there is a problem reading from the resource
 */
public static TypeSystemDescription ecore2UimaTypeSystem(Resource aEcoreResource, Map aOptions)
        throws URISyntaxException {
  if (aOptions == null) {
    aOptions = Collections.EMPTY_MAP;
  }

  TypeSystemDescription tsDesc = uimaFactory.createTypeSystemDescription();

  // try to get descriptive info from EAnnotation with NS "http://uima.apache.org",
  // on the first EPackage in the Resource
  EPackage ePackage = (EPackage) aEcoreResource.getContents().get(0);
  EAnnotation eannot = ePackage.getEAnnotation("http://uima.apache.org");
  if (eannot != null) {
    tsDesc.setName((String) eannot.getDetails().get("name"));
    tsDesc.setDescription((String) eannot.getDetails().get("description"));
    tsDesc.setVendor((String) eannot.getDetails().get("vendor"));
    tsDesc.setVersion((String) eannot.getDetails().get("version"));
  }

  // convert types
  List types = new ArrayList();
  Iterator iter = aEcoreResource.getContents().iterator();
  while (iter.hasNext()) {
    Object obj = iter.next();
    if (obj instanceof EPackage) {
      ePackage2UimaTypes((EPackage) obj, types, aOptions);
    }
  }
  TypeDescription[] typeArr = new TypeDescription[types.size()];
  types.toArray(typeArr);
  tsDesc.setTypes(typeArr);
  return tsDesc;
}
 
Example #15
Source File: ProcessViewProvider.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
private void stampShortcut(View containerView, Node target) {
	if (!MainProcessEditPart.MODEL_ID.equals(ProcessVisualIDRegistry.getModelID(containerView))) {
		EAnnotation shortcutAnnotation = EcoreFactory.eINSTANCE.createEAnnotation();
		shortcutAnnotation.setSource("Shortcut"); //$NON-NLS-1$
		shortcutAnnotation.getDetails().put("modelID", MainProcessEditPart.MODEL_ID); //$NON-NLS-1$
		target.getEAnnotations().add(shortcutAnnotation);
	}
}
 
Example #16
Source File: SubProcessEventItemSemanticEditPolicy.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
protected Command getDestroyElementCommand(DestroyElementRequest req) {
	View view = (View) getHost().getModel();
	CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
	cmd.setTransactionNestingEnabled(false);
	for (Iterator<?> it = view.getTargetEdges().iterator(); it.hasNext();) {
		Edge incomingLink = (Edge) it.next();
		if (ProcessVisualIDRegistry.getVisualID(incomingLink) == TextAnnotationAttachmentEditPart.VISUAL_ID) {
			DestroyElementRequest r = new DestroyElementRequest(incomingLink.getElement(), false);
			cmd.add(new DestroyElementCommand(r));
			cmd.add(new DeleteCommand(getEditingDomain(), incomingLink));
			continue;
		}
	}
	EAnnotation annotation = view.getEAnnotation("Shortcut"); //$NON-NLS-1$
	if (annotation == null) {
		// there are indirectly referenced children, need extra commands: false
		addDestroyChildNodesCommand(cmd);
		addDestroyShortcutsCommand(cmd, view);
		// delete host element
		cmd.add(new DestroyElementCommand(req));
	} else {
		cmd.add(new DeleteCommand(getEditingDomain(), view));
	}

	final EObject pool = req.getElementToDestroy();
	if (pool instanceof Pool) {
		for (MessageFlow f : ModelHelper.getMainProcess(pool).getMessageConnections()) {
			if (pool.equals(ModelHelper.getParentProcess(f.getSource()))) {
				cmd.add(new DestroyElementCommand(new DestroyElementRequest(f, false)));
			}
		}
	}

	return getGEFWrapper(cmd.reduce());
}
 
Example #17
Source File: LaneItemSemanticEditPolicy.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
protected Command getDestroyElementCommand(DestroyElementRequest req) {
	View view = (View) getHost().getModel();
	CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
	cmd.setTransactionNestingEnabled(false);
	for (Iterator<?> it = view.getTargetEdges().iterator(); it.hasNext();) {
		Edge incomingLink = (Edge) it.next();
		if (ProcessVisualIDRegistry.getVisualID(incomingLink) == TextAnnotationAttachmentEditPart.VISUAL_ID) {
			DestroyElementRequest r = new DestroyElementRequest(incomingLink.getElement(), false);
			cmd.add(new DestroyElementCommand(r));
			cmd.add(new DeleteCommand(getEditingDomain(), incomingLink));
			continue;
		}
	}
	EAnnotation annotation = view.getEAnnotation("Shortcut"); //$NON-NLS-1$
	if (annotation == null) {
		// there are indirectly referenced children, need extra commands: false
		addDestroyChildNodesCommand(cmd);
		addDestroyShortcutsCommand(cmd, view);
		// delete host element
		cmd.add(new DestroyElementCommand(req));
	} else {
		cmd.add(new DeleteCommand(getEditingDomain(), view));
	}

	final EObject pool = req.getElementToDestroy();
	if (pool instanceof Pool) {
		for (MessageFlow f : ModelHelper.getMainProcess(pool).getMessageConnections()) {
			if (pool.equals(ModelHelper.getParentProcess(f.getSource()))) {
				cmd.add(new DestroyElementCommand(new DestroyElementRequest(f, false)));
			}
		}
	}

	return getGEFWrapper(cmd.reduce());
}
 
Example #18
Source File: SubProcessEvent2ItemSemanticEditPolicy.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
protected Command getDestroyElementCommand(DestroyElementRequest req) {
	View view = (View) getHost().getModel();
	CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
	cmd.setTransactionNestingEnabled(false);
	for (Iterator<?> it = view.getTargetEdges().iterator(); it.hasNext();) {
		Edge incomingLink = (Edge) it.next();
		if (ProcessVisualIDRegistry.getVisualID(incomingLink) == TextAnnotationAttachmentEditPart.VISUAL_ID) {
			DestroyElementRequest r = new DestroyElementRequest(incomingLink.getElement(), false);
			cmd.add(new DestroyElementCommand(r));
			cmd.add(new DeleteCommand(getEditingDomain(), incomingLink));
			continue;
		}
	}
	EAnnotation annotation = view.getEAnnotation("Shortcut"); //$NON-NLS-1$
	if (annotation == null) {
		// there are indirectly referenced children, need extra commands: false
		addDestroyChildNodesCommand(cmd);
		addDestroyShortcutsCommand(cmd, view);
		// delete host element
		cmd.add(new DestroyElementCommand(req));
	} else {
		cmd.add(new DeleteCommand(getEditingDomain(), view));
	}

	final EObject pool = req.getElementToDestroy();
	if (pool instanceof Pool) {
		for (MessageFlow f : ModelHelper.getMainProcess(pool).getMessageConnections()) {
			if (pool.equals(ModelHelper.getParentProcess(f.getSource()))) {
				cmd.add(new DestroyElementCommand(new DestroyElementRequest(f, false)));
			}
		}
	}

	return getGEFWrapper(cmd.reduce());
}
 
Example #19
Source File: PoolItemSemanticEditPolicy.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
protected Command getDestroyElementCommand(DestroyElementRequest req) {
	View view = (View) getHost().getModel();
	CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
	cmd.setTransactionNestingEnabled(false);
	for (Iterator<?> it = view.getTargetEdges().iterator(); it.hasNext();) {
		Edge incomingLink = (Edge) it.next();
		if (ProcessVisualIDRegistry.getVisualID(incomingLink) == TextAnnotationAttachmentEditPart.VISUAL_ID) {
			DestroyElementRequest r = new DestroyElementRequest(incomingLink.getElement(), false);
			cmd.add(new DestroyElementCommand(r));
			cmd.add(new DeleteCommand(getEditingDomain(), incomingLink));
			continue;
		}
	}
	EAnnotation annotation = view.getEAnnotation("Shortcut"); //$NON-NLS-1$
	if (annotation == null) {
		// there are indirectly referenced children, need extra commands: false
		addDestroyChildNodesCommand(cmd);
		addDestroyShortcutsCommand(cmd, view);
		// delete host element
		cmd.add(new DestroyElementCommand(req));
	} else {
		cmd.add(new DeleteCommand(getEditingDomain(), view));
	}

	final EObject pool = req.getElementToDestroy();
	if (pool instanceof Pool) {
		for (MessageFlow f : ModelHelper.getMainProcess(pool).getMessageConnections()) {
			if (pool.equals(ModelHelper.getParentProcess(f.getSource()))) {
				cmd.add(new DestroyElementCommand(new DestroyElementRequest(f, false)));
			}
		}
	}

	return getGEFWrapper(cmd.reduce());
}
 
Example #20
Source File: ModelValidator.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Validate OCL constraints and return true if OCL constraint holds, false
 * otherwise.
 */
private boolean validate_EveryInvariant(Instance instance,
	DiagnosticChain diagnostics, Map<Object, Object> context) {
	final EClass eClass = instance.getEClass();
	final EAnnotation annotation = eClass.getEAnnotation(OCL_SOURCE_URI);
	if (annotation != null) {
		for (final Entry<String, String> entry : annotation.getDetails()) {
			try {
				final String expression = entry.getValue();
				if (!(Boolean) evaluate(instance, expression)) {
					if (diagnostics != null) {
						diagnostics.add(new BasicDiagnostic(
							Diagnostic.ERROR, DIAGNOSTIC_SOURCE, 0,
							EcorePlugin.INSTANCE.getString(
								"_UI_GenericConstraint_diagnostic", //$NON-NLS-1$
								new Object[] {
									entry.getKey(),
									getObjectLabel(
										(EObject) instance,
										context) }),
							new Object[] { instance }));
					}
					return false;
				}
			} catch (final ParserException e) {
				System.out.println(e);
			}
		}
	}
	return true;
}
 
Example #21
Source File: Schema.java    From BIMserver with GNU Affero General Public License v3.0 5 votes vote down vote up
public void addIndex(EStructuralFeature eStructuralFeature) {
	for (EAnnotation eAnnotation : eStructuralFeature.getEAnnotations()) {
		if (eAnnotation.getSource().equals("singleindex")) {
			throw new RuntimeException(eStructuralFeature + " already has an index");
		}
	}
	changes.add(new AddIndexChange(this, eStructuralFeature));
	EAnnotation index = EcoreFactory.eINSTANCE.createEAnnotation();
	index.setSource("singleindex");
	eStructuralFeature.getEAnnotations().add(index);
}
 
Example #22
Source File: ClassifierTests.java    From textuml with Eclipse Public License 1.0 5 votes vote down vote up
public void testSourceInfo() throws CoreException {
    String source = "";
    source += "model someModel;\n";
    source += "import base;\n";
    source += "class SomeClassifier\n";
    source += "end;\n";
    source += "end.";
    parseAndCheck(source);
    Classifier classifier = (Classifier) getRepository().findNamedElement("someModel::SomeClassifier",
            Literals.CLASS, null);
    EAnnotation unitInfo = classifier.getEAnnotation(MDDUtil.UNIT);
    assertNotNull(unitInfo);
    assertNotNull(unitInfo.getDetails());
    assertEquals("foo0." + fixtureHelper.getExtension(), unitInfo.getDetails().get("name"));
}
 
Example #23
Source File: MDDUtil.java    From textuml with Eclipse Public License 1.0 5 votes vote down vote up
public static String getGeneratedTimestamp(Package package_) {
    final Package root = getRootPackage(package_);
    EAnnotation eAnnotation = root.getEAnnotation(MDDUtil.GENERATED);
    if (eAnnotation == null)
        return null;
    return eAnnotation.getDetails().get("dateCreated");
}
 
Example #24
Source File: MDDUtil.java    From textuml with Eclipse Public License 1.0 5 votes vote down vote up
public static void markGenerated(Package package_) {
      if (MDDUtil.isGenerated(package_))
          return;
      final Package root = getRootPackage(package_);
      EAnnotation annotation = root.createEAnnotation(MDDUtil.GENERATED);
EMap<String, String> details = annotation.getDetails();
details.put("dateCreated", new SimpleDateFormat("yyyy/MM/dd hh:mm:ss SSS Z").format(new Date()));
details.put("version", getMetamodelVersion());
  }
 
Example #25
Source File: CrossflowCreateShortcutDecorationsCommand.java    From scava with Eclipse Public License 2.0 5 votes vote down vote up
/**
* @generated
*/
protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
	for (Iterator it = myDescriptors.iterator(); it.hasNext();) {
		CreateViewRequest.ViewDescriptor nextDescriptor = (CreateViewRequest.ViewDescriptor) it.next();
		View view = (View) nextDescriptor.getAdapter(View.class);
		if (view != null && view.getEAnnotation("Shortcut") == null) { //$NON-NLS-1$
			EAnnotation shortcutAnnotation = EcoreFactory.eINSTANCE.createEAnnotation();
			shortcutAnnotation.setSource("Shortcut"); //$NON-NLS-1$
			shortcutAnnotation.getDetails().put("modelID", WorkflowEditPart.MODEL_ID); //$NON-NLS-1$
			view.getEAnnotations().add(shortcutAnnotation);
		}
	}
	return CommandResult.newOKCommandResult();
}
 
Example #26
Source File: TreeLayoutUtil.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Returns the index of a tree node from the view position annotation.
 * 
 * @param editPart
 * @return
 */
public static int getTreeNodePosition(IGraphicalEditPart editPart) {
	final EAnnotation xmiIdAnnotation = editPart.getNotationView()
			.getEAnnotation(TREE_LAYOUT_ANNOTATION);
	if (xmiIdAnnotation != null) {
		final String pos = xmiIdAnnotation.getDetails().get(
				TREE_NODE_POSITION);
		if (pos != null) {
			return Integer.parseInt(pos);
		}
	}
	return getConstrainedTreeNodePosition(editPart.getFigure());
}
 
Example #27
Source File: TreeLayoutUtil.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Returns the parent view of a tree node from the parent view annotation.
 * 
 * @param editPart
 * @return
 */
public static View getTreeNodeParentView(View view) {
	final EAnnotation xmiIdAnnotation = view
			.getEAnnotation(TREE_LAYOUT_ANNOTATION);
	if (xmiIdAnnotation != null) {
		return (View) view.eResource().getEObject(
				xmiIdAnnotation.getDetails().get(TREE_NODE_PARENT_URI));
	}
	return null;
}
 
Example #28
Source File: ExclusiveGroups.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Group objects by groupId
 * <p>
 * Note that object without are group are not returned
 * </p>
 * 
 * @param objects
 *            the object to group
 * @return the grouped objects
 */
public static Map<String, Set<EObject>> aggregateGroups ( final EList<? extends EObject> objects )
{
    final Map<String, Set<EObject>> map = new HashMap<> ();

    for ( final EObject obj : objects )
    {
        final EAnnotation annotation = findAnnotation ( obj );
        if ( annotation == null )
        {
            continue;
        }
        final String groupId = annotation.getDetails ().get ( VALUE_GROUP_ID );
        if ( groupId == null )
        {
            continue;
        }

        Set<EObject> set = map.get ( groupId );
        if ( set == null )
        {
            set = new HashSet<> ();
            map.put ( groupId, set );
        }
        set.add ( obj );
    }

    return map;
}
 
Example #29
Source File: ExclusiveGroups.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Remove exclusive groups from a collection of objects
 * 
 * @param objects
 *            the objects to process
 * @param groupIds
 *            the groups to remove
 */
public static void removeGroups ( final Collection<? extends EObject> objects, final Set<String> groupIds )
{
    if ( groupIds == null || groupIds.isEmpty () )
    {
        return;
    }

    for ( final Iterator<? extends EObject> i = objects.iterator (); i.hasNext (); )
    {
        final EObject obj = i.next ();

        final EAnnotation annotation = findAnnotation ( obj );
        if ( annotation == null )
        {
            continue;
        }

        final String groupId = annotation.getDetails ().get ( VALUE_GROUP_ID );
        if ( groupId == null )
        {
            continue;
        }

        if ( groupIds.contains ( groupId ) )
        {
            i.remove ();
        }
    }
}
 
Example #30
Source File: CrossflowShortcutPropertyTester.java    From scava with Eclipse Public License 2.0 5 votes vote down vote up
/**
* @generated
*/
public boolean test(Object receiver, String method, Object[] args, Object expectedValue) {
	if (false == receiver instanceof View) {
		return false;
	}
	View view = (View) receiver;
	if (SHORTCUT_PROPERTY.equals(method)) {
		EAnnotation annotation = view.getEAnnotation("Shortcut"); //$NON-NLS-1$
		if (annotation != null) {
			return WorkflowEditPart.MODEL_ID.equals(annotation.getDetails().get("modelID")); //$NON-NLS-1$
		}
	}
	return false;
}