Java 类org.eclipse.emf.ecore.EAnnotation 实例源码

项目:neoscada    文件:ExclusiveGroups.java   
/**
 * 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;
}
项目:neoscada    文件:ExclusiveGroups.java   
/**
 * 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;
}
项目:OCCI-Studio    文件:OCCIExtension2Ecore.java   
private EDataType createStringType(StringType type) {
    EDataType edatatype = EcoreFactory.eINSTANCE.createEDataType();
    edatatype.setName(type.getName());
    edatatype.setInstanceTypeName("java.lang.String");
    if (type.getDocumentation() != null) {
        attachInfo(edatatype, type.getDocumentation());
    }
    if (type.isSetLength() || type.isSetMaxLength() || type.isSetMinLength() || type.getPattern() != null) {
        EAnnotation eannotation = EcoreFactory.eINSTANCE.createEAnnotation();
        edatatype.getEAnnotations().add(eannotation);
        eannotation.setSource("http:///org/eclipse/emf/ecore/util/ExtendedMetaData");
        if (type.isSetLength())
            eannotation.getDetails().put("length", Integer.toString(type.getLength()));
        if (type.isSetMaxLength())
            eannotation.getDetails().put("maxLength", Integer.toString(type.getMaxLength()));
        if (type.isSetMinLength())
            eannotation.getDetails().put("minLength", Integer.toString(type.getMinLength()));
        if (type.getPattern() != null) {
            if (type.getPattern() != "")
                eannotation.getDetails().put("pattern", type.getPattern());
        }
    }
    return edatatype;
}
项目:OCCI-Studio    文件:OCCIExtension2Ecore.java   
protected void convertConstraints(EClass eClass, Type type) {
    if (type.getConstraints().size() > 0) {
        // EMF Annotation
        EAnnotation annotation_emf = EcoreFactory.eINSTANCE.createEAnnotation();
        annotation_emf.setSource("http://www.eclipse.org/emf/2002/Ecore");
        String value = "";
        // OCL Annotation
        EAnnotation annotation_ocl = EcoreFactory.eINSTANCE.createEAnnotation();
        annotation_ocl.setSource("http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot");
        for (Constraint constraint : type.getConstraints()) {
            annotation_ocl.getDetails().put(constraint.getName(),
                    convertbody(constraint.getBody(), (Extension) type.eContainer()));
            if (value.equals("")) {
                value += constraint.getName();
            } else {
                value += " ";
                value += constraint.getName();
            }
            // convertbody(constraint.getBody(), (Extension)
            // type.eContainer());
        }
        annotation_emf.getDetails().put("constraints", value);
        eClass.getEAnnotations().add(annotation_emf);
        eClass.getEAnnotations().add(annotation_ocl);
    }
}
项目:OCCI-Studio    文件:ConverterUtils.java   
public static void persistMetamodel(ResourceSet resourceSet, EPackage generated, String path) throws IOException {
    if (new File(path).exists()) {
        EPackage existing = (EPackage) OcciHelper.getRootElement(resourceSet, "file:/" + path);
        for (Iterator<EObject> iterator = existing.eAllContents(); iterator.hasNext();) {
            EObject eo = iterator.next();
            if (eo instanceof EAnnotation && isOCLRelated((EAnnotation) eo)) {
                EModelElement existingContainer = (EModelElement) eo.eContainer();
                EModelElement generatedContainer = (EModelElement) getGeneratedElement(generated,
                        existingContainer);
                if (generatedContainer == null) {
                    throw new RuntimeException("Unable to find " + existingContainer + " to reattach " + eo + " "
                            + ((EAnnotation) eo).getEAnnotations());
                } else {
                    generatedContainer.getEAnnotations().add((EAnnotation) EcoreUtil.copy(eo));
                }
            }
        }
    }
    ConverterUtils.save(resourceSet, generated, "file:/" + path);
}
项目:NEXCORE-UML-Modeler    文件:UMLModelerNotationModelHandlerUtil.java   
/**
 * 특정 엘리먼트 하위의 다이어그램 목록 반환하는 메소드
 * 
 * @param element
 * @param diagramType
 * @return List<Diagram>
 */
public static List<Diagram> getDiagramList(Element element, DiagramType diagramType) {
    List<Diagram> list = new ArrayList<Diagram>();

    EAnnotation annotation = element.getEAnnotation(ManagerConstant.UMLDOMAIN_CONSTANT__DIAGRAM_ANNOTATION_NAME);

    if (annotation == null) {
        return null;
    }

    EList<EObject> contents = annotation.getContents();
    EObject object;
    for (int i = 0; i < contents.size(); i++) {
        object = contents.get(i);
        if (object instanceof Diagram) {
            if (diagramType.equals(((Diagram) object).getType())) {
                list.add((Diagram) object);
            }
        }
    }

    return list;
}
项目:NEXCORE-UML-Modeler    文件:UMLModelerNotationModelHandlerUtil.java   
/**
 * 부모가 가진 다이어그램의 이름을 반환하는 메소드 - 없을 경우엔, 부모의 이름을 반환
 * 
 * @param parent
 * @return String
 */
public static String getDiagramName(Element parent) {
    String diagramName = null;
    EAnnotation diagramAnnotation = ((Element) parent).getEAnnotation(ManagerConstant.UMLDOMAIN_CONSTANT__DIAGRAM_ANNOTATION_NAME);
    Diagram diagram = null;

    if (diagramAnnotation != null) {
        diagram = (Diagram) diagramAnnotation.getContents().get(0);
    }

    if (diagram != null) {
        diagramName = diagram.getName();
    } else {
        diagramName = ((NamedElement) parent).getName();
    }

    return diagramName;
}
项目:NEXCORE-UML-Modeler    文件:SemanticModelHandler.java   
/**
 * 시퀀스 다이어그램 생성
 * 
 * @param intact
 * @param name
 *            void
 */
private Diagram createSequenceDiagram(Interaction intact, String name) {
    EAnnotation eAnnotation = intact.getEAnnotation("Diagram");
    if (eAnnotation != null) {
        EList<EObject> contents = eAnnotation.getContents();
        for (EObject eObj : contents) {
            if (eObj instanceof Diagram) {
                Diagram diagram = (Diagram) eObj;
                if (diagram.getType() == DiagramType.SEQUENCE_DIAGRAM) {
                    return diagram;
                }
            }
        }
    }
    INotationModelHandler modelHandler = new UMLModelerNotationModelHandler();

    return modelHandler.createDiagram(intact, name, DiagramType.SEQUENCE_DIAGRAM);
}
项目:NEXCORE-UML-Modeler    文件:UMLModelerNotationModelHandler.java   
/**
 * createDiagram
 * 
 * @param parent
 * @param diagramName
 * @param diagramType
 * @return EObject
 */
public static Diagram createDiagram(Element parent, String diagramName, DiagramType diagramType) {
    EAnnotation diagramAnnotation = ((Element) parent).getEAnnotation(ManagerConstant.UMLDOMAIN_CONSTANT__DIAGRAM_ANNOTATION_NAME);

    if (diagramAnnotation == null) {
        diagramAnnotation = ((Element) parent).createEAnnotation(ManagerConstant.UMLDOMAIN_CONSTANT__DIAGRAM_ANNOTATION_NAME);
        ((Element) parent).getEAnnotations().add(diagramAnnotation);
    }

    Diagram diagram = UMLDiagramFactory.eINSTANCE.createDiagram();

    diagram.setName(diagramName);
    diagram.setType(diagramType);
    diagram.setId(UUID.randomUUID().toString());

    if (diagramAnnotation.getContents().contains(diagram)) {
        diagramAnnotation.getContents().remove(diagram);
    }

    diagramAnnotation.getContents().add(diagram);
    diagram.setParent(parent);

    return diagram;
}
项目:NEXCORE-UML-Modeler    文件:UMLManager.java   
/**
 * 
 * 
 * @param uniqueIndex
 * @param diagramName
 * @param parent
 * @return int
 */
private static int getUniqueIndex(int uniqueIndex, String diagramName, Element parent) {

    EAnnotation diagramAnnotation = parent.getEAnnotation(ManagerConstant.UMLDOMAIN_CONSTANT__DIAGRAM_ANNOTATION_NAME);
    if (diagramAnnotation == null) {
        return 0;
    }
    for (EObject child : diagramAnnotation.getContents()) {
        if (child instanceof Diagram) {

            Diagram diagram = (Diagram) child;
            if (uniqueIndex == 0) {
                if (diagram.getName().equals(diagramName)) {
                    uniqueIndex++;
                    uniqueIndex = getUniqueIndex(uniqueIndex, diagramName, parent);
                }
            } else {
                if (diagram.getName().equals(diagramName + uniqueIndex)) {
                    uniqueIndex++;
                    uniqueIndex = getUniqueIndex(uniqueIndex, diagramName, parent);
                }
            }
        }
    }
    return uniqueIndex;
}
项目:NEXCORE-UML-Modeler    文件:UMLHelper.java   
/**
 * 
 * 
 * @param parent
 *            : 다이어그램이 위치해야할 상위 Element
 * @param diagramType
 *            : 생성할 다이어그램 타입
 * @param diagramName
 *            : 다이어그램 이름 명
 * @return Diagram
 */
public static Diagram createDiagram(org.eclipse.uml2.uml.PackageableElement parent, DiagramType diagramType,
                                       String diagramName) {
    EAnnotation eAnnotation = parent.getEAnnotation(DIAGRAM_SOURCE_NAME);
    if (null == eAnnotation) {
        eAnnotation = parent.createEAnnotation(DIAGRAM_SOURCE_NAME);
        parent.getEAnnotations().add(eAnnotation);
    }
    Diagram diagram = UMLDiagramFactory.eINSTANCE.createDiagram();
    diagram.setId(UUID.randomUUID().toString());
    diagram.setType(diagramType);
    diagram.setName(diagramName);
    diagram.setParent(parent);

    eAnnotation.getContents().add(diagram);
    return diagram;
}
项目:NEXCORE-UML-Modeler    文件:UMLDomainTest.java   
/**
 * 선택된 UML모델 요소의 다이어그램 모델 생성
 * 
 * @param parentUMLModel
 * @param diagramType
 * @param diagramName
 * @return Diagram
 */
public Diagram createDiagram(Element parentUMLModel, DiagramType diagramType, String diagramName) {
    EAnnotation diagramAnnotation = parentUMLModel.getEAnnotation(ManagerConstant.UMLDOMAIN_CONSTANT__DIAGRAM_ANNOTATION_NAME); //$NON-NLS-1$

    if (diagramAnnotation == null) {
        diagramAnnotation = parentUMLModel.createEAnnotation(ManagerConstant.UMLDOMAIN_CONSTANT__DIAGRAM_ANNOTATION_NAME); //$NON-NLS-1$
    }
    parentUMLModel.getEAnnotations().add(diagramAnnotation);

    Diagram diagram = UMLDiagramFactory.eINSTANCE.createDiagram();
    diagram.setType(diagramType);
    diagram.setName(diagramName);
    diagram.setParent(parentUMLModel);

    return diagram;
}
项目:statecharts    文件:TreeLayoutUtil.java   
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);
        }
    }
}
项目:NEXCORE-UML-Modeler    文件:ProjectUtil.java   
/**
 * setSelectonNodeInExplorer
 *  
 * @param target void
 */
public static void setSelectonNodeInExplorer(EObject target) {
    if (null == target) {
        return;
    }
    if (target instanceof EAnnotation) {
        return;
    }
    CommonViewer commonViewer = ViewerRegistry.getViewer();
    if (commonViewer.getControl().isDisposed()) {
        return;
    }
    ITreeNode targetNode = null;
    targetNode = UMLTreeNodeRegistry.getTreeNode(target);
    if (null != targetNode) {
        commonViewer.setSelection(new StructuredSelection(targetNode), true);
    }
}
项目:NEXCORE-UML-Modeler    文件:ProjectUtil.java   
/**
 * 해당 Element 하위에 있는 타입별 다이어그램을 리스트로 반환.
 * 
 * @param eobject
 * @param diagramType
 * @return List<Diagram>
 */
public static List<Diagram> getDiagrams(Element element, DiagramType diagramType) {

    List<Diagram> list = new ArrayList<Diagram>();
    EAnnotation annotation = element.getEAnnotation(UICoreConstant.PROJECT_CONSTANTS__DIAGRAM);

    if (annotation != null) {

        EList<EObject> contents = annotation.getContents();
        Diagram diagram;
        for (EObject eobject : contents) {
            if (eobject instanceof Diagram) {
                diagram = (Diagram) eobject;
                if (diagramType.equals(diagram.getType())) {
                    list.add(diagram);
                }
            }
        }

    }

    return list;

}
项目:NEXCORE-UML-Modeler    文件:ProjectUtil.java   
/**
 * getFragmentContainerAnnotation
 *  
 * @param eobject
 * @return EAnnotation
 */
public static EAnnotation getFragmentContainerAnnotation(EObject eobject) {
    if (eobject instanceof org.eclipse.uml2.uml.Package) {
        org.eclipse.uml2.uml.Package myPackage = (org.eclipse.uml2.uml.Package) eobject;
        EAnnotation eAnnotation = myPackage.getEAnnotation(UICoreConstant.PROJECT_CONSTANTS__FRAGMENT_CONTAINER);
        if (eAnnotation == null)
            eAnnotation = myPackage.createEAnnotation(UICoreConstant.PROJECT_CONSTANTS__FRAGMENT_CONTAINER);

        // FragmentContainer 가 첫번째 배열오 오도록 한다.
        // 이유 : 단편화된 패키지의 스테레오 타입이 사라지는 문제 발생 때문에 추가함.
        int size = myPackage.getEAnnotations().size();
        if (size > 1 && myPackage.getEAnnotations().indexOf(eAnnotation) != 0) {
            List<EAnnotation> tempList = new ArrayList<EAnnotation>();
            tempList.addAll(myPackage.getEAnnotations());
            Collections.sort(tempList, EANNOTATION_COMPARATOR);
            int i = 0;
            for (EAnnotation e : tempList) {
                myPackage.getEAnnotations().remove(e);
                myPackage.getEAnnotations().add(i++, e);
            }
        }

        return eAnnotation;
    }
    return null;
}
项目:NEXCORE-UML-Modeler    文件:ModelUpdater.java   
/**
 * 
 * 
 * @param file
 * @param obj
 *            void
 */
public boolean checkViewModelVersion(org.eclipse.uml2.uml.Package package1, IFile file) {
    ProjectElement projectInfo = null;
    for (EAnnotation eAnnotation : package1.getEAnnotations()) {
        if (eAnnotation instanceof ProjectElement) {
            projectInfo = (ProjectElement) eAnnotation;
        }
    }

    if (projectInfo == null) {
        return false;
    } else if (!UICoreConstant.PROJECT_CONSTANTS__MODEL_VERSION.equals(projectInfo.getModelVersion())) {
        return false;
    } else {
        return true;
    }
}
项目:NEXCORE-UML-Modeler    文件:ResourceManager.java   
/**
     * 
     * 
     *  
     * @param parentResource void
     */
    public void removeFragmentResource(Resource parentResource) {
        EList<EObject> contents = parentResource.getContents();
        if (contents != null && contents.size() > 0) {
            EObject eobject = contents.get(0);

            if (!AdapterFactoryEditingDomain.isControlled(eobject)) {
                EAnnotation eAnnotation = getFragmentAnnotation(eobject);
                if (eAnnotation == null)
                    return;
                EList<EObject> references = eAnnotation.getReferences();
                for (EObject reference : references) {
                    if (reference != null && reference.eResource() != null) {
//                        removeResource(reference.eResource());
                        ResourceUnloader.getInstance().put(reference.eResource());
                    }
                }
            }
        }
    }
项目:NEXCORE-UML-Modeler    文件:LabelNodeEditPart.java   
/**
 * activate에서 등록한 어댑터를 삭제한다.
 * 
 * @see nexcore.tool.uml.ui.core.diagram.edit.part.AbstractNotationNodeEditPart#deactivate()
 */
@Override
public void deactivate() {
    super.deactivate();
    LabelNode node = (LabelNode) getModel();

    if (node.getParent() != null) {
        node.getParent().eAdapters().remove(this);

        Element umlModel = ((AbstractView) node.getParent()).getUmlModel();
        if (umlModel != null) {
            umlModel.eAdapters().remove(this);

            for (Stereotype stereotype : ((Element) umlModel).getAppliedStereotypes()) {
                stereotype.eAdapters().remove(this);
            }

            for (EAnnotation annotation : ((EModelElement) umlModel).getEAnnotations()) {
                annotation.eAdapters().remove(this);
            }
        }
    }
}
项目:NEXCORE-UML-Modeler    文件:CompartmentLabelNodeEditPart.java   
/**
 * @see nexcore.tool.uml.ui.core.diagram.edit.part.AbstractNotationNodeEditPart#deactivate()
 */
@Override
public void deactivate() {
    super.deactivate();

    LabelNode node = (LabelNode) getModel();

    if (node.getParent() != null) {
        node.getParent().eAdapters().remove(this);
        ((AbstractView) node.getParent()).getParent().eAdapters().remove(this);

        ((AbstractView) node.getParent()).getUmlModel().eAdapters().remove(this);

        for (Stereotype stereotype : ((Element) ((AbstractView) node.getParent()).getUmlModel()).getAppliedStereotypes()) {
            stereotype.eAdapters().remove(this);
        }

        for (EAnnotation annotation : ((EModelElement) ((AbstractView) node.getParent()).getUmlModel()).getEAnnotations()) {
            annotation.eAdapters().remove(this);
        }
    }
}
项目:NEXCORE-UML-Modeler    文件:ElementUtil.java   
/**
 * 파라미터로 넘긴 UML 모델을 가지는 Diagram을 반환하는 메소드
 * 
 * @param umlModel
 * @return AbstractView
 */
public static AbstractView findDiagram(Element umlModel) {
    Model model = umlModel.getModel();
    if (model == null) {
        return null;
    }
    EAnnotation diagramAnnotation = model.getEAnnotation("Diagram"); //$NON-NLS-1$
    Diagram diagram = null;

    if (diagramAnnotation == null) {
        return null;
    }

    for (int diagramIdx = 0; diagramIdx < diagramAnnotation.getContents().size(); diagramIdx++) {
        diagram = (Diagram) diagramAnnotation.getContents().get(diagramIdx);

        for (AbstractNode diagramNode : diagram.getNodeList()) {
            if (diagramNode.getUmlModel().equals(umlModel)) {
                return diagram;
            }
        }
    }

    return null;
}
项目:NEXCORE-UML-Modeler    文件:AbstractControlNodeEditPart.java   
/**
 * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#activate()
 */
public void activate() {
    if (!isActive()) {
        super.activate();
        EObject model = (EObject) getModel();
        model.eAdapters().add(this);

        model = ((AbstractNode) getModel()).getUmlModel();
        model.eAdapters().add(this);

        model = ((AbstractNode) getModel()).getUmlModel();
        for (Stereotype stereotype : ((Element) model).getAppliedStereotypes()) {
            stereotype.eAdapters().add(this);
        }

        model = ((AbstractNode) getModel()).getUmlModel();
        for (EAnnotation annotation : ((EModelElement) model).getEAnnotations()) {
            annotation.eAdapters().add(this);
        }
    }
}
项目:NEXCORE-UML-Modeler    文件:AbstractControlNodeEditPart.java   
/**
 * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#deactivate()
 */
public void deactivate() {
    if (isActive()) {
        super.deactivate();
        EObject model = (EObject) getModel();
        model.eAdapters().remove(this);

        model = ((AbstractNode) getModel()).getUmlModel();
        model.eAdapters().remove(this);

        model = ((AbstractNode) getModel()).getUmlModel();
        for (Stereotype stereotype : ((Element) model).getAppliedStereotypes()) {
            stereotype.eAdapters().remove(this);
        }

        model = ((AbstractNode) getModel()).getUmlModel();
        for (EAnnotation annotation : ((EModelElement) model).getEAnnotations()) {
            annotation.eAdapters().remove(this);
        }
    }
}
项目:NEXCORE-UML-Modeler    文件:CreateClassDefinitionToXMLFileJob.java   
/**
 * Diagram 데이터 모델 리스트를 생성합니다.
 * 
 * @param pkg
 * @return List<DataModel>
 */
private List<DataModel> createDiagramDataModelList(Package pack) throws Exception {
    List<DataModel> diagramModelList = new ArrayList<DataModel>();
    EAnnotation annotation = null;
    Diagram diagram;
    for (PackageableElement element : pack.getPackagedElements()) {
        if (element.eClass() == UMLPackage.Literals.COLLABORATION) {
            annotation = element.getEAnnotation(UICoreConstant.PROJECT_CONSTANTS__DIAGRAM);
            if (annotation != null) {
                for (EObject eobj : annotation.getContents()) {
                    if (eobj.eClass() == UMLDiagramPackage.Literals.DIAGRAM) {
                        diagram = (Diagram) eobj;
                        if (diagram.getType() == DiagramType.CLASS_DIAGRAM) {
                            diagramModelList.add(createDiagramModel(diagram));
                        }
                    }
                }
            }
        }
    }

    // if (eObject.eClass() == UMLPackage.Literals.PACKAGE
    // || eObject.eClass() == UMLPackage.Literals.MODEL) {
    // Package pkg = (Package) eObject;
    // for (PackageableElement element : pkg.getPackagedElements()) {
    // diagramModelList.addAll(createDiagramDataModelList(element));
    // }
    // }

    return diagramModelList;
}
项目:NEXCORE-UML-Modeler    文件:ReportContentManager.java   
/**
 * 패키지 내부에 있는 다이어그램 데이터모델의 리스트를 반환한다.
 * 
 * @param pkg
 * @param type
 * @return List<DataModel>
 */
protected List<DataModel> createDiagramDataModelList(Package pkg, DiagramType type) {
    List<DataModel> diagramModelList = new ArrayList<DataModel>();
    DataModel diagramModel;
    EAnnotation annotation = pkg.getEAnnotation(UICoreConstant.PROJECT_CONSTANTS__DIAGRAM);
    if (annotation != null) {
        Diagram diagram;
        for (EObject eobj : annotation.getContents()) {
            if (eobj.eClass() == UMLDiagramPackage.Literals.DIAGRAM) {
                diagram = (Diagram) eobj;

                if (diagram.getType() == type) {
                    diagramModel = createDiagramModel(diagram);
                    diagramModelList.add(diagramModel);
                }
            }
        }
    }

    return diagramModelList;
}
项目:NEXCORE-UML-Modeler    文件:UsecaseRealizationContentManager.java   
/**
 * 클래스 다이어그램 데이터 모델 리스트를 생성합니다.
 * 
 * @param pkg
 * @return List<DataModel>
 */
private List<DataModel> createClassdiagramModelList(Collaboration collaboration, List<Diagram> diagramList) {
    List<DataModel> diagramModelList = new ArrayList<DataModel>();
    EAnnotation annotation;
    Diagram diagram;

    annotation = collaboration.getEAnnotation(UICoreConstant.PROJECT_CONSTANTS__DIAGRAM);
    if (annotation != null) {
        for (EObject eobj : annotation.getContents()) {
            if (eobj.eClass() == UMLDiagramPackage.Literals.DIAGRAM) {
                diagram = (Diagram) eobj;
                if (diagram.getType() == DiagramType.CLASS_DIAGRAM) {
                    diagramList.add(diagram);
                    diagramModelList.add(createDiagramModel(diagram));
                }
            }
        }
    }

    return diagramModelList;
}
项目:NEXCORE-UML-Modeler    文件:UsecaseRealizationContentManager.java   
/**
 * createSequencediagramModelList
 *  
 * @param collaboration
 * @return List<DataModel>
 */
private List<DataModel> createSequencediagramModelList(Collaboration collaboration) {
    List<DataModel> diagramModelList = new ArrayList<DataModel>();
    EAnnotation annotation;
    Diagram diagram;

    for (Behavior behavior : collaboration.getOwnedBehaviors()) {
        annotation = behavior.getEAnnotation(UICoreConstant.PROJECT_CONSTANTS__DIAGRAM);
        if (annotation != null) {
            for (EObject eobj : annotation.getContents()) {
                if (eobj.eClass() == UMLDiagramPackage.Literals.DIAGRAM) {
                    diagram = (Diagram) eobj;
                    if (diagram.getType() == DiagramType.SEQUENCE_DIAGRAM) {
                        diagramModelList.add(createDiagramModel(diagram));
                    }
                }
            }
        }
    }

    return diagramModelList;
}
项目:NEXCORE-UML-Modeler    文件:UsecaseContentManager.java   
/**
 * 해당 유스케이스의 사전 조건, 사후 조건을 가져온다.
 * 
 * @param uc
 * @return List<String>
 */
private List<String> getConditions(UseCase uc) {
    List<String> conditions = new ArrayList<String>();

    EAnnotation annotation = uc.getEAnnotation(UICoreConstant.PROJECT_CONSTANTS__USECASE_DETAIL);
    String preCondition = null;
    String postCondition = null;
    if (annotation != null && annotation instanceof UseCaseDetail) {
        preCondition = ((UseCaseDetail) annotation).getPreCondition();
        postCondition = ((UseCaseDetail) annotation).getPostCondition();
    }

    conditions.add(preCondition);
    conditions.add(postCondition);

    return conditions;
}
项目:NEXCORE-UML-Modeler    文件:UMLManipulation.java   
/**
 * getDiagramList
 *  
 * @param namespace
 * @param type
 * @return List<Diagram>
 */
public static List<Diagram> getDiagramList(Namespace namespace, DiagramType type) {
    List<Diagram> diagramModelList = new ArrayList<Diagram>();

    if (DiagramType.SEQUENCE_DIAGRAM.equals(type)) {
        diagramModelList.addAll(ModelManager.getAllDiagramList(namespace, type));

    } else {
        EAnnotation annotation = namespace.getEAnnotation(UICoreConstant.PROJECT_CONSTANTS__DIAGRAM);
        if (annotation != null) {
            Diagram diagram;
            for (EObject eobj : annotation.getContents()) {
                if (eobj.eClass() == UMLDiagramPackage.Literals.DIAGRAM) {
                    diagram = (Diagram) eobj;

                    if (type == diagram.getType()) {
                        diagramModelList.add(diagram);
                    }
                }
            }
        }
    }
    return ModelManager.sortDiagramList(diagramModelList);

}
项目:NEXCORE-UML-Modeler    文件:ModelUpdateAction.java   
/**
 * 
 * 
 * @param file
 * @param obj
 *            void
 */
private boolean checkViewModelVersion(org.eclipse.uml2.uml.Package package1, IFile file) {
    ProjectElement projectInfo = null;
    for (EAnnotation eAnnotation : package1.getEAnnotations()) {
        if (eAnnotation instanceof ProjectElement) {
            projectInfo = (ProjectElement) eAnnotation;
        }
    }

    if (projectInfo == null) {
        return false;
    } else if (!UICoreConstant.PROJECT_CONSTANTS__MODEL_VERSION.equals(projectInfo.getModelVersion())) {
        return false;
    } else {
        return true;
    }
}
项目:NEXCORE-UML-Modeler    文件:AbstractPropertySectionWithAdapter.java   
/**
 * 모델에서 어답터를 제거함 void
 */
protected void deactivate() {
    if (null == this.selectedModel) {
        return;
    }
    if (this.selectedModel.eAdapters().contains(this)) {
        this.selectedModel.eAdapters().remove(this);
    }
    for (Stereotype stereotype : ((Element) selectedModel).getAppliedStereotypes()) {
        stereotype.eAdapters().remove(this);
    }
    for (EAnnotation annotation : ((EModelElement) selectedModel).getEAnnotations()) {
        annotation.eAdapters().remove(this);
    }
    if (selectedModel instanceof InteractionConstraint) {
        InteractionConstraint constraint = (InteractionConstraint) selectedModel;
        OpaqueExpression expression = (OpaqueExpression) constraint.getSpecification();
        expression.eAdapters().remove(this);
    }
}
项目:NEXCORE-UML-Modeler    文件:UsecaseDisplayIdSection.java   
/**
     * @see nexcore.tool.uml.ui.property.section.TemplateTextSection#get()
     */
    @Override
    protected String get() {
        Element element = this.getData();
        EAnnotation eAnnotation = element.getEAnnotation(ManagerConstant.USECASE_DISPLAY_ID_EANNOTATION_SOURCE_NAME);
        UseCaseDisplayId displayId = null;

        if (eAnnotation != null) {
            displayId = (UseCaseDisplayId) eAnnotation;
        } else {
            return "";
//            displayId = UsecasedisplayIdFactory.eINSTANCE.createUseCaseDisplayId();
//            displayId.setSource(ManagerConstant.USECASE_DISPLAY_ID_EANNOTATION_SOURCE_NAME);
//            setElementInfo(element, displayId);
        }

        String usecaseId = displayId.getDisplayId();
        return usecaseId;
    }
项目:NEXCORE-UML-Modeler    文件:UsecasePreconditionSection.java   
/**
 * @see nexcore.tool.uml.ui.property.section.TemplateTextSection#set(java.lang.String)
 */
@Override
protected void set(String value) {
    try {
        if (value == null)
            return;
        EAnnotation annotation = getData().getEAnnotation(UICoreConstant.PROJECT_CONSTANTS__USECASE_DETAIL);
        if (null == annotation) {
            UseCaseDetail detail = UseCaseDetailFactory.eINSTANCE.createUseCaseDetail();
            detail.setSource(UICoreConstant.PROJECT_CONSTANTS__USECASE_DETAIL);
            detail.setPreCondition(value);
            getData().getEAnnotations().add(detail);

        } else {
            if (annotation instanceof UseCaseDetail) {
                ((UseCaseDetail) annotation).setPreCondition(value);
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
项目:neoscada    文件:ExclusiveGroups.java   
/**
 * 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 ();
        }
    }
}
项目:neoscada    文件:ExclusiveGroups.java   
/**
 * 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;
}
项目:neoscada    文件:WorldRunner.java   
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 ) );
}
项目:OCCI-Studio    文件:OCCIExtension2Ecore.java   
private void attachInfo(EModelElement element, String value) {

        EAnnotation annotation = EcoreFactory.eINSTANCE.createEAnnotation();
        annotation.setSource("http://www.eclipse.org/emf/2002/GenModel");
        element.getEAnnotations().add(annotation);
        if (value != null)
            annotation.getDetails().put("documentation", value);
        else
            annotation.getDetails().put("documentation", "");
    }
项目:M2Doc    文件:EcoreDocumentationServices.java   
/**
 * Returns the documentation of an element.
 * 
 * @param element
 * @return
 */
String documentation(EPackage element) {
    for (EAnnotation annotation : element.getEAnnotations()) {
        if (annotation.getSource().equals(ECORE_SOURCE)) {
            return annotation.getDetails().get(DOC_KEY);
        }
    }
    return "";
}
项目:M2Doc    文件:EcoreDocumentationServices.java   
/**
 * Returns the constraints of an EClass.
 * 
 * @param element
 * @return
 */
String documentation(EClass eClass) {
    for (EAnnotation annotation : eClass.getEAnnotations()) {
        if (annotation.getSource().equals(ECORE_SOURCE)) {
            return annotation.getDetails().get(CONSTRAINT_KEY);
        }
    }
    return "";
}
项目:NEXCORE-UML-Modeler    文件:DomainModelHandlerUtil.java   
/**
 * 해당 Element에서 특정 Annotation 반환
 * 
 * @param element
 * @param annotationName
 * @return EAnnotation
 */
public static EAnnotation findSpecificAnnotation(Element element, String annotationName) {
    if (annotationName != null) {
        if (element.getEAnnotation(annotationName) != null) {
            return element.getEAnnotation(annotationName);
        } else {
            return element.createEAnnotation(annotationName);
        }
    }

    return null;
}