本文整理汇总了Java中org.eclipse.uml2.uml.Package类的典型用法代码示例。如果您正苦于以下问题:Java Package类的具体用法?Java Package怎么用?Java Package使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Package类属于org.eclipse.uml2.uml包,在下文中一共展示了Package类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getContainedValidElementCount
import org.eclipse.uml2.uml.Package; //导入依赖的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: createCollaboration
import org.eclipse.uml2.uml.Package; //导入依赖的package包/类
/**
* Collaboration 생성
*
* @param realizePkg
* @param useCase
* @return Collaboration
*/
private Collaboration createCollaboration(Package realizePkg, UseCase useCase) {
Package ucPackage = realizePkg.getNestedPackage(useCase.getName());
if (ucPackage == null) {
ucPackage = realizePkg.createNestedPackage(useCase.getName());
}
PackageableElement packagedElement = ucPackage.getPackagedElement(useCase.getName());
Collaboration collabo = null;
if (packagedElement instanceof Collaboration) {
collabo = (Collaboration) packagedElement;
} else {
EClass eClass = UMLFactory.eINSTANCE.getUMLPackage().getCollaboration();
collabo = (Collaboration) ucPackage.createPackagedElement(useCase.getName(), eClass);
}
ModelUtility.copyDocumentation(collabo, useCase);
ModelUtility.copyKeywords(useCase, collabo);
return collabo;
}
示例3: getFragmentedPackageList
import org.eclipse.uml2.uml.Package; //导入依赖的package包/类
/**
*
* 모델에 포함된 단편화 패키지 목록을 반환 한다.
*
* @param model
* @return TreeMap<String,Package>
*/
public static TreeMap<String, Package> getFragmentedPackageList(Package model) {
TreeMap<String, Package> packageList = new TreeMap<String, Package>();
SELECT statement = new SELECT(new FROM(model),
new WHERE(new EObjectTypeRelationCondition(UMLPackage.eINSTANCE.getPackage())));
IQueryResult result = statement.execute();
for (Iterator<?> ir = result.iterator(); ir.hasNext();) {
Package pkg = (Package) ir.next();
if (pkg == null || pkg.getQualifiedName() == null) {
continue;
}
if (AdapterFactoryEditingDomain.isControlled(pkg)) {
packageList.put(pkg.getQualifiedName(), pkg);
continue;
}
}
return packageList;
}
示例4: getSortedAllPackageChildrenList
import org.eclipse.uml2.uml.Package; //导入依赖的package包/类
/**
* getSortedAllPackageChildrenList
*
* @param parent
* @return List<T>
*/
@SuppressWarnings("unchecked")
public List<T> getSortedAllPackageChildrenList(Package parent) {
List<PackageableElement> packagedElements = parent.getPackagedElements();
List<T> list = new ArrayList<T>();
for (PackageableElement packagedElement : packagedElements) {
if (packagedElement.eClass().equals(UMLPackage.Literals.PACKAGE)) {
list.add((T) packagedElement);
}
}
sorting(list);
if (list.size() > 0) {
Object arrayList[] = list.toArray();
for (int i = 0; i < arrayList.length; i++) {
Package packageElement = (Package) arrayList[i];
List<T> childrenList = getSortedAllPackageChildrenList(packageElement);
if (childrenList.size() > 0) {
list.addAll(childrenList);
}
}
}
return list;
}
示例5: isAllowed
import org.eclipse.uml2.uml.Package; //导入依赖的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$
}
示例6: getTargetBasePackage
import org.eclipse.uml2.uml.Package; //导入依赖的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;
}
示例7: createPackage
import org.eclipse.uml2.uml.Package; //导入依赖的package包/类
/**
* parent 패키지에 특정 name의 패키지 생성
*
* @param parent
* @param name
* @return
*/
public static Package createPackage(Package parent, String name) {
// null 확인
if (parent == null || name == null) {
return null;
}
NamedElement namedElement = parent.getOwnedMember(name);
if (namedElement != null && namedElement instanceof Package) {
return (Package) namedElement;
} else {
Package createdPackage = parent.createNestedPackage(name);
return createdPackage;
}
}
示例8: createDiagrams
import org.eclipse.uml2.uml.Package; //导入依赖的package包/类
@Override
protected void createDiagrams(IProgressMonitor monitor){
monitor.beginTask("Generating empty diagrams", 100);
monitor.subTask("Creating empty diagrams...");
if(PreferencesManager.getBoolean(PreferencesManager.CLASS_DIAGRAM_PREF)){
List<Element> packages = modelManager.getElementsOfTypes(Arrays.asList(Model.class, Package.class));
diagramManager.createDiagrams(packages, new CreateClassDiagramCommand());
}
if(PreferencesManager.getBoolean(PreferencesManager.ACTIVITY_DIAGRAM_PREF)){
List<Element> activities = modelManager.getElementsOfTypes(Arrays.asList(Activity.class));
diagramManager.createDiagrams(activities, new CreateActivityDiagramCommand());
}
if(PreferencesManager.getBoolean(PreferencesManager.STATEMACHINE_DIAGRAM_PREF)){
List<Element> statemachines = modelManager.getElementsOfTypes(Arrays.asList(StateMachine.class));
diagramManager.createDiagrams(statemachines, new CreateStateMachineDiagramCommand());
}
monitor.worked(100);
}
示例9: loadLibrary
import org.eclipse.uml2.uml.Package; //导入依赖的package包/类
/**
* load library with provided path
*
*
* @param libraryPath
* @return Package
*/
public static Package loadLibrary(String libraryPath) {
ResourceSet resourceSet = new ResourceSetImpl();
Resource inputResource = resourceSet.createResource(URI.createFileURI(libraryPath));
try {
inputResource.load(null);
} catch (IOException ioe) {
ioe.printStackTrace();
}
Package library = DomainUtil.getUMLModelRoot(inputResource);
return library;
}
示例10: removeEmptyPackages
import org.eclipse.uml2.uml.Package; //导入依赖的package包/类
/**
* 설계모델 전개 후 아무것도 없는 빈 패키지를 제거한다. Usecase Realization 패키지는 제거하지 않는다.
*
* @param targetModel
* void
*/
public static void removeEmptyPackages(MDADesignerTransformationData data) {
Model targetModel = DomainModelHandlerUtil.openModel(data.getTargetModelURI());
for (Package pack : targetModel.getNestedPackages()) {
if (MDDCommonUtil.getUsecaseRealizationPackageName().equals(pack.getName())) { // Usecase
// Realization
// 패키지는
// 제거하지
// 않는다.
continue;
}
if (getContainedValidElementCount(pack, 0) == 0) { // 패키지 내에 클래스,
// 인터페이스가 하나도 없으면.
// 삭제함.
pack.destroy();
}
}
}
示例11: load
import org.eclipse.uml2.uml.Package; //导入依赖的package包/类
/**
* 패키지형 객체 반환
*
* @param uri
* @return Package
*/
public static Package load(URI uri) {
org.eclipse.uml2.uml.Package newPackage = null;
Resource resource = null;
try {
if (domainModelHandler != null) {
resource = domainModelHandler.getResourceSet().getResource(uri, true);
} else {
resource = getHandlerInstance().getResourceSet().getResource(uri, true);
}
newPackage = (org.eclipse.uml2.uml.Package) EcoreUtil.getObjectByType(resource.getContents(),
UMLPackage.Literals.PACKAGE);
} catch (WrappedException we) {
Log.error(we);
}
return newPackage;
}
示例12: createActivityDiagram
import org.eclipse.uml2.uml.Package; //导入依赖的package包/类
/**
* 다이어그램이 위치할 부모 타입이 Activity타입인경우 다이어그램 생성 그렇지 않은 경우 Activity를 부모에 생성하고 그
* 하위에 다이어그램 생성
*
* @param parent
* @param diagramName
* @return Diagram
*/
public static Diagram createActivityDiagram(org.eclipse.uml2.uml.PackageableElement parent, String diagramName) {
Diagram diagram;
Activity activity = null;
if (parent instanceof Activity) {
activity = (org.eclipse.uml2.uml.Activity) parent;
} else {
if (parent instanceof Package) {
activity = createActivity();
((Package) parent).getPackagedElements().add(activity);
}
}
diagram = createDiagram(activity, DiagramType.ACTIVITY_DIAGRAM, diagramName);
return diagram;
}
示例13: getApplicableLibraryList
import org.eclipse.uml2.uml.Package; //导入依赖的package包/类
/**
* getApplicableLibraryList
*
* @return List<Object>
*/
private List<Object> getApplicableLibraryList() {
Resource resource = null;
URI libraryURI = null;
Package library = null;
List<Object> applicableLibraryList = new ArrayList<Object>();
for (String libraryName : UICoreConstant.PROJECT_CONSTANTS__CORE_LIBRARY_NAMES) {
// UML 기본 라이브러리 로딩
libraryURI = URI.createURI(UMLResource.LIBRARIES_PATHMAP + libraryName + ManagerConstant.DOT
+ UMLResource.LIBRARY_FILE_EXTENSION);
resource = DomainRegistry.getEditingDomain().getResourceSet().getResource(libraryURI, true);
if (!resource.isLoaded()) {
try {
resource.load(DomainUtil.getLoadOptions());
} catch (IOException ioe) {
Log.error(ioe);
}
}
library = DomainUtil.getUMLModelRoot(resource);
applicableLibraryList.add(library);
}
return applicableLibraryList;
}
示例14: getFragmentContainerAnnotation
import org.eclipse.uml2.uml.Package; //导入依赖的package包/类
/**
* 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;
}
示例15: checkViewModelVersion
import org.eclipse.uml2.uml.Package; //导入依赖的package包/类
/**
*
*
* @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;
}
}