本文整理汇总了Java中org.eclipse.uml2.uml.Element类的典型用法代码示例。如果您正苦于以下问题:Java Element类的具体用法?Java Element怎么用?Java Element使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Element类属于org.eclipse.uml2.uml包,在下文中一共展示了Element类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getContainedValidElementCount
import org.eclipse.uml2.uml.Element; //导入依赖的package包/类
/**
* 입력된 패키지의 하위패키지 중 의미있는 엘리먼트를 가지고 있는지 카운트를 반환한다. 몇개가 있는지가 중요한것이 아니라, 있는지
* 없는지만 알면 되므로 cnt 가 0을 넘으면 더 이상 수행하지 않고 그냥 cnt 를 반환한다. 이 메소드는 전개 후 불필요하게
* 생성된 빈 패키지를 없애기 위해 수행된다. 재귀 메소드 임. 의미있는 엘리먼트 : 더 필요하면 추가 할 것 - 클래스, 인터페이스,
* Collaboration, Actor, Component, Interaction
*
* @param targetPackage
* @param cnt
* @return int
*/
public static int getContainedValidElementCount(Package targetPackage, int cnt) {
if (cnt > 0)
return cnt;
for (Package p : targetPackage.getNestedPackages()) {
for (Element element : p.getOwnedElements()) {
if (element instanceof Class || element instanceof Interface || element instanceof Collaboration
|| element instanceof Actor || element instanceof Component || element instanceof Interaction) {
cnt++;
}
}
cnt = getContainedValidElementCount(p, cnt);
}
return cnt;
}
示例2: isAllowed
import org.eclipse.uml2.uml.Element; //导入依赖的package包/类
/**
*
* @see org.eclipse.papyrus.infra.nattable.tester.ITableTester#isAllowed(java.lang.Object)
*
* @param context
* @return
*/
@Override
public IStatus isAllowed(Object context) {
if (context instanceof Element) {
Element el = (Element) context;
ISpecializationType type = (ISpecializationType) ElementTypeRegistry.getInstance().getType("org.eclipse.papyrus.training.library.profile.extlibrary.Book");
IElementMatcher matcher = type.getMatcher();
if (context instanceof Package || matcher.matches(el)) {
Profile profile = UMLUtil.getProfile(LibraryPackage.eINSTANCE, el);
if (profile != null){
final String packageQN = profile.getQualifiedName();
if (el.getNearestPackage().getAppliedProfile(packageQN, true) != null) {
return new Status(IStatus.OK, Activator.PLUGIN_ID, "The context allowed to create a Book Table"); //$NON-NLS-1$
} else {
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "The profile "+packageQN+" is not applied on the model"); //$NON-NLS-1$ //$NON-NLS-2$
}
}
}
}
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "The context is not an UML Element"); //$NON-NLS-1$
}
示例3: getHyperlinks
import org.eclipse.uml2.uml.Element; //导入依赖的package包/类
/**
* @see org.eclipse.papyrus.infra.hyperlink.service.HyperlinkContributor#getHyperlinks(java.lang.Object)
*
* @param object
* @return
*/
@Override
public List<HyperLinkObject> getHyperlinks(Object object) {
List<HyperLinkObject> hyperlinks = new ArrayList<>();
if (object instanceof Class) {
Class clazz = (Class) object;
if (UMLUtil.getStereotypeApplication(clazz, Book.class) != null) {
// TODO: extract a method to get the borrower from a book in the
// java implementation of the profile
EList<DirectedRelationship> targetDirectedRelationships = clazz.getTargetDirectedRelationships();
for (DirectedRelationship dependency : targetDirectedRelationships) {
if (UMLUtil.getStereotypeApplication(dependency, Borrows.class) != null) {
EList<Element> targets = dependency.getSources();
for (Element element : targets) {
Set<View> crossReferencingViews = CrossReferencerUtil.getCrossReferencingViews(element,null);
// we take the first available view
Object firstView = crossReferencingViews.toArray()[0];
HyperLinkSpecificObject hyperlink = new HyperLinkSpecificObject((EObject) firstView);
hyperlinks.add(hyperlink);
}
}
}
}
}
return hyperlinks;
}
示例4: getNavigableElements
import org.eclipse.uml2.uml.Element; //导入依赖的package包/类
@Override
public List<NavigableElement> getNavigableElements(Object fromElement) {
List<NavigableElement> result = new LinkedList<>();
Element element = org.eclipse.papyrus.uml.tools.utils.UMLUtil.resolveUMLElement(fromElement);
if (element instanceof Class){
final Book book = UMLUtil.getStereotypeApplication(element, Book.class);
if (book != null) {
final BookCategory category = book.getCategory();
Resource eResource = book.eResource();
EList<EObject> contents = eResource.getContents();
result =
contents.stream()
.filter(l -> !l.equals(book))
.filter(l -> l instanceof Book)
.map(l -> (Book) l)
.filter(l -> category.equals(l.getCategory()))
.map(l -> l.getBase_Class())
.map(clazz -> new SameCategoryNavigableElement(clazz))
.collect(Collectors.toList());
}
}
return result;
}
示例5: getStereotypeListValue
import org.eclipse.uml2.uml.Element; //导入依赖的package包/类
/**
* Returns the value cast as an List.
*
* @param clazz
* @param stereotypeName
* @param propertyName
* @return
*/
public static List<?> getStereotypeListValue(Element clazz, String stereotypeName, String propertyName) {
Stereotype stereotype = getStereotype(clazz, stereotypeName);
if (stereotype != null) {
try {
Object value = clazz.getValue(stereotype, propertyName);
if (value instanceof List) {
List<?> new_name = (List<?>) value;
return new_name;
}
} catch (IllegalArgumentException e) {
}
}
return new ArrayList<Object>();
}
示例6: loopModel
import org.eclipse.uml2.uml.Element; //导入依赖的package包/类
private void loopModel(ModelImpl model, String path) throws IOException {
EList<Element> elementsList = model.getOwnedElements();
for (Element element : elementsList) {
if (myEAEObjInfoManager.isPackage(element)) {
PackageImpl packageEle = (PackageImpl) element;
String packagePath = path + packageEle.getName();
loopPackageTofindDiagrams(packageEle, packagePath);
} else if (myEAEObjInfoManager.isDiagram(element)) {
ClassImpl eDiagram = (ClassImpl) element;
addDiagramToMapInDiagram(eDiagram, path);
} else if (myEAEObjInfoManager.isNonDiaClassImpl(element)) {
ClassImpl classImplEle = (ClassImpl) element;
addNonDiaClassImplToMap(classImplEle, path);
}
}
}
示例7: loopPackageTofindDiagrams
import org.eclipse.uml2.uml.Element; //导入依赖的package包/类
private void loopPackageTofindDiagrams(PackageImpl packageEle, String path)
throws IOException {
EList<Element> elementList = packageEle.getOwnedElements();
for (Element element : elementList) {
if (myEAEObjInfoManager.isPackage(element)) {
PackageImpl subPackageEle = (PackageImpl) element;
String packagePath = path + "/" + subPackageEle.getName();
loopPackageTofindDiagrams(subPackageEle, packagePath);
} else if (myEAEObjInfoManager.isDiagram(element)) {
ClassImpl eDiagram = (ClassImpl) element;
addDiagramToMapInDiagram(eDiagram, path);
} else if (myEAEObjInfoManager.isNonDiaClassImpl(element)) {
ClassImpl classImplEle = (ClassImpl) element;
addNonDiaClassImplToMap(classImplEle, path);
}
}
}
示例8: applyTyped
import org.eclipse.uml2.uml.Element; //导入依赖的package包/类
@Override
protected void applyTyped(Require object) {
if (object.eContainer() instanceof Classifier) {
Classifier classifier = (Classifier) object.eContainer();
if (classifier.getReferencedElement() != null && object.getInterface() != null
&& object.getInterface().getReferencedElement() != null) {
Element umlClassifier = classifier.getReferencedElement();
EList<DirectedRelationship> usages = umlClassifier
.getSourceDirectedRelationships(UMLPackage.eINSTANCE.getUsage());
Optional<Usage> umlUsage = usages.stream().map(Usage.class::cast)
.filter(u -> u.getSuppliers().contains(object.getInterface().getReferencedElement()))
.filter(u -> object.getName() == null? true : u.getName().equals(object.getName()))
.findFirst();
if (umlUsage.isPresent()) {
object.setReferencedElement(umlUsage.get());
}
}
}
}
示例9: sendCurrentlyFocusedElement
import org.eclipse.uml2.uml.Element; //导入依赖的package包/类
@Override
public void sendCurrentlyFocusedElement() {
Optional<Element> element = focusManager.getFocusedElement();
if (!element.isPresent()) {
LOGGER.info("No element focused.");
return;
}
Optional<IDiagramType> currentDiagramType = focusManager.getDiagramType();
if (!currentDiagramType.isPresent()) {
LOGGER.info("Diagram type could not be detected.");
return;
}
Element focusedElement = element.get();
try {
CDOObject cdoObject = CDOUtil.getCDOObject(focusedElement);
messageHandler.sendFocus(cdoObject);
LOGGER.debug("sendCurrentlyFocusedElement element={}", cdoObject);
} catch (Exception e) {
LOGGER.error("Could not send focus request.", e);
}
}
示例10: getComponentElementList
import org.eclipse.uml2.uml.Element; //导入依赖的package包/类
/**
* 선택된 요소 전체목록 중에서 component 메타데이터 생성에 쓰이는 스테레오타입이 적용된 요소의 목록을 반환
*
* @param selectedElementList
* @return List<Element>
*/
public static List<Element> getComponentElementList(List<Element> selectedElementList) {
List<Element> componentElementList = null;
for (Element element : selectedElementList) {
for (Stereotype appliedStereotype : element.getAppliedStereotypes()) {
if (appliedStereotype.getLabel().equals(
MDDCoreConstant.COMPONENT_METADATA_STEREOTYPE_NAME)) {
if (componentElementList == null) {
componentElementList = new ArrayList<Element>();
}
componentElementList.add(element);
}
}
}
return componentElementList;
}
示例11: getTargetBasePackage
import org.eclipse.uml2.uml.Element; //导入依赖的package包/类
/**
* Source모델(분석 모델) 요소 기반으로 Target모델(설계 모델)의 Base 패키지를 찾는 메소드
*
* @param sourceElement
* @param transformationData
* @return Package
*/
private static Package getTargetBasePackage(Element sourceElement, MDADesignerTransformationData transformationData) {
// null 확인
if (sourceElement == null || sourceElement.getModel() == null || !isValid(transformationData)) {
return null;
}
// Source모델(분석 모델) 가져오기
Model sourceModel = null;
if (transformationData.getSourceModelURI() != null) {
sourceModel = DomainModelHandlerUtil.openModel(transformationData.getSourceModelURI());
}
// Source모델(분석 모델) null 확인
if (!sourceModel.getName().equals(sourceElement.getModel().getName())) {// ||
// !(transformationData.getSourceModel().getName().equals(sourceElement.getModel().getName()))
return null;
}
// Model targetModel = transformationData.getTargetModel();
// Target모델(설계 모델) 가져오기
Model targetModel = null;
if (transformationData.getTargetModelURI() != null) {
targetModel = DomainModelHandlerUtil.openModel(transformationData.getTargetModelURI());
}
// Target모델(설계 모델) Base 패키지 획득
Package sourceBase = getBasePackage(sourceElement, transformationData.getRuleSet());
String sourceModelName = sourceBase.getModel().getName();
String sourceBaseQName = sourceBase.getQualifiedName();
String targetBaseQName = targetModel.getName() + sourceBaseQName.substring(sourceModelName.length());
Package targetBase = transformPackage(sourceBase, targetModel, targetBaseQName, false);
return targetBase;
}
示例12: findResource
import org.eclipse.uml2.uml.Element; //导入依赖的package包/类
/**
* 다이어그램이 포함된 리소스 가져오는 메소드
*
* @param diagram
* @return Resource
*/
public static Resource findResource(Diagram diagram) {
Element parent = (Element) diagram.getParent();
EList<Resource> resourceList = null;
Object obj = null;
if (domainModelHandler != null) {
resourceList = domainModelHandler.getResourceSet().getResources();
} else {
resourceList = getHandlerInstance().getResourceSet().getResources();
}
for (Resource resource : resourceList) {
for (Iterator iter = EcoreUtil.getAllContents(resource, true); iter.hasNext();) {
obj = iter.next();
if (parent.equals(obj)) {
return resource;
}
}
}
return null;
}
示例13: getDiagramList
import org.eclipse.uml2.uml.Element; //导入依赖的package包/类
/**
* 특정 엘리먼트 하위의 다이어그램 목록 반환하는 메소드
*
* @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;
}
示例14: addElementsToDiagram
import org.eclipse.uml2.uml.Element; //导入依赖的package包/类
@Override
protected void addElementsToDiagram(Diagram diagram, IProgressMonitor monitor) {
AbstractDiagramElementsManager diagramElementsManager;
DiagramEditPart diagep = diagramManager.getActiveDiagramEditPart();
if(diagram.getType().equals(diagramType_CD)){
diagramElementsManager = new ClassDiagramElementsManager(diagep);
}else if(diagram.getType().equals(diagramType_SMD)){
diagramElementsManager = new StateMachineDiagramElementsManager(diagep);
}else if(diagram.getType().equals(diagramType_CSD)){
diagramElementsManager = new CompositeDiagramElementsManager(diagep);
}else{
return;
}
List<Element> baseElements = new ArrayList<Element>();
List<Element> nodes = txtumlregistry.getNodes(diagram.getName());
List<Element> connections = txtumlregistry.getConnections(diagram.getName());
baseElements.addAll(nodes);
baseElements.addAll(connections);
diagramElementsManager.addElementsToDiagram(baseElements);
}
示例15: findClassDiagramElements
import org.eclipse.uml2.uml.Element; //导入依赖的package包/类
/**
* Interaction LifeLine들의 유형들을 찾아 클래스 다이어그램 생성시 사용하는 클래스 다이어그램 요소 목록에 추가하는
* 메소드
*
* @param classDgm
* @param interaction
* void
*/
private static void findClassDiagramElements(Interaction interaction, List<Element> classDiagramElementList) {
// Interaction이 가지는 LifeLine 요소 목록 가져오기
EList<Lifeline> lifeLines = interaction.getLifelines();
Element element = null;
// LifeLine의 유형을 클래스 다이어그램 요소 목록에 추가
for (Lifeline lifeLine : lifeLines) {
if (lifeLine != null && lifeLine.getRepresents() != null && lifeLine.getRepresents().getType() != null) {
element = lifeLine.getRepresents().getType();
if (element instanceof Actor) {
continue;
}
if (!classDiagramElementList.contains(element)) {
classDiagramElementList.add(element);
}
}
}
}