本文整理汇总了Java中org.eclipse.uml2.uml.PackageImport类的典型用法代码示例。如果您正苦于以下问题:Java PackageImport类的具体用法?Java PackageImport怎么用?Java PackageImport使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PackageImport类属于org.eclipse.uml2.uml包,在下文中一共展示了PackageImport类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doExecute
import org.eclipse.uml2.uml.PackageImport; //导入依赖的package包/类
/**
* @see org.eclipse.emf.transaction.RecordingCommand#doExecute()
*/
@Override
protected void doExecute() {
if (importPackage) {
element.createPackageImport(importingPackage);
} else {
PackageImport deletingCandidate = null;
for (org.eclipse.uml2.uml.PackageImport packageImport : element.getPackageImports()) {
if (packageImport != null) {
if (packageImport.getImportedPackage().equals(importingPackage)) {
deletingCandidate = packageImport;
break;
}
}
}
if (deletingCandidate != null) {
element.getPackageImports().remove(deletingCandidate);
}
}
}
示例2: getPackageImportText
import org.eclipse.uml2.uml.PackageImport; //导入依赖的package包/类
private static Optional<String> getPackageImportText(
de.cooperateproject.modeling.textual.common.metamodel.textualCommons.PackageImport pkgImport) {
Object result = pkgImport.eGet(TextualCommonsPackage.Literals.UML_REFERENCING_ELEMENT__REFERENCED_ELEMENT,
false);
List<INode> nodes = NodeModelUtils.findNodesForFeature(pkgImport,
TextualCommonsPackage.Literals.UML_REFERENCING_ELEMENT__REFERENCED_ELEMENT);
if (result != null) {
Package umlPackage = ((PackageImport) result).getImportedPackage();
if (umlPackage != null)
// TODO use qualified name provider for this operation
return Optional.of(umlPackage.getQualifiedName().replace(umlPackage.separator(), "."));
}
if (!nodes.isEmpty()) {// TODO: should alway return absolut import path, so we should resolve that text with the
// parent
return Optional.fromNullable(NodeModelUtils.getTokenText(nodes.get(0)));
}
return Optional.absent();
}
开发者ID:Cooperate-Project,项目名称:CooperateModelingEnvironment,代码行数:23,代码来源:ClsCooperateSimpleScopeProvider.java
示例3: searchAllImportedComponents
import org.eclipse.uml2.uml.PackageImport; //导入依赖的package包/类
public static List<Component> searchAllImportedComponents(Package pack) {
List<Component> components = new ArrayList<Component>();
List<PackageImport> packageImports = pack.getPackageImports();
for (PackageImport packageImport : packageImports) {
Package importedPackage = packageImport.getImportedPackage();
if (importedPackage != null) {
List<PackageableElement> packagedElements = importedPackage.getPackagedElements();
for (PackageableElement packageableElement : packagedElements) {
if (packageableElement instanceof Component) {
components.add((Component)packageableElement);
}
}
components.addAll(searchAllImportedComponents(importedPackage));
}
}
return components;
}
示例4: execute
import org.eclipse.uml2.uml.PackageImport; //导入依赖的package包/类
@Override
public void execute() {
// Get its resource
Resource umlResource = UmlUtils.getUmlModel(modelSet).getResource();
// Select the root element to add the wanted imports
root = (org.eclipse.uml2.uml.Package) umlResource.getContents().get(0);
URI templatelibraryURI = URI.createURI(EXAMPLE_PATH).appendFragment(EXAMPLE_ROOT_ID);
libraryPackage = (org.eclipse.uml2.uml.Package) modelSet.getEObject(templatelibraryURI, true);
// Creates the import packages at the root of the model (elements of type packageImport)
this.getCommandStack(modelSet).execute(new RecordingCommand(modelSet.getTransactionalEditingDomain()) {
@Override
protected void doExecute() {
PackageImport importPrimitivePack = root.createPackageImport(libraryPackage);
if (!root.getPackageImports().contains(importPrimitivePack)) {
root.getPackageImports().add(importPrimitivePack);
}
try {
root.eResource().save(Collections.emptyMap());
} catch (IOException e) {
//TODO : log error
}
}
});
}
示例5: getContributorId
import org.eclipse.uml2.uml.PackageImport; //导入依赖的package包/类
/**
* @see org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor#getContributorId()
*/
public String getContributorId() {
if (eobj instanceof PackageImport) {
return UICoreConstant.PROJECT_CONSTANTS__CONTRIBUTOR_ID;
} else {
return CONTRIBUTOR_ID;
}
}
示例6: renderObject
import org.eclipse.uml2.uml.PackageImport; //导入依赖的package包/类
public boolean renderObject(Package package_, IndentedPrintWriter pw, IRenderingSession context) {
renderPrologue(package_, pw, context);
pw.println();
List<ProfileApplication> profileApplications = package_.getProfileApplications();
if (!profileApplications.isEmpty()) {
RenderingUtils.renderAll(context, profileApplications);
pw.println();
}
List<PackageImport> packageImports = package_.getPackageImports();
if (!packageImports.isEmpty()) {
RenderingUtils.renderAll(context, packageImports);
pw.println();
}
List<ElementImport> elementImports = package_.getElementImports();
if (!elementImports.isEmpty()) {
RenderingUtils.renderAll(context, elementImports);
pw.println();
}
final Collection<Classifier> subPackages = EcoreUtil.getObjectsByType(package_.getOwnedElements(),
UMLPackage.Literals.PACKAGE);
RenderingUtils.renderAll(context, subPackages);
final Collection<Classifier> classifiers = EcoreUtil.getObjectsByType(package_.getOwnedElements(),
UMLPackage.Literals.CLASSIFIER);
RenderingUtils.renderAll(context, classifiers);
renderEpilogue(package_, pw, context);
return true;
}
示例7: getAllImportedPackages
import org.eclipse.uml2.uml.PackageImport; //导入依赖的package包/类
protected static List<Package> getAllImportedPackages(Package package_, List<Package> allImportedPackages) {
for (PackageImport packageImport : package_.getPackageImports())
if (packageImport.getVisibility() == VisibilityKind.PUBLIC_LITERAL) {
Package importedPackage = packageImport.getImportedPackage();
if (importedPackage != null && !allImportedPackages.contains(importedPackage)) {
allImportedPackages.add(importedPackage);
getAllImportedPackages(importedPackage, allImportedPackages);
}
}
return allImportedPackages;
}
示例8: addSystemPackage
import org.eclipse.uml2.uml.PackageImport; //导入依赖的package包/类
private void addSystemPackage(Package systemPackage) {
if (!systemResources.add(systemPackage.eResource()))
// already added
return;
for (PackageImport current : systemPackage.getPackageImports())
addSystemPackage(current.getImportedPackage());
}
示例9: renderObject
import org.eclipse.uml2.uml.PackageImport; //导入依赖的package包/类
public boolean renderObject(PackageImport element, IndentedPrintWriter out, IRenderingSession context) {
out.println("import " + qualifiedName(element.getImportedPackage()) + ";");
return true;
}
示例10: caseAImportDecl
import org.eclipse.uml2.uml.PackageImport; //导入依赖的package包/类
@Override
public void caseAImportDecl(final AImportDecl node) {
final Package currentPackageSnapshot = namespaceTracker.currentPackage();
modifierProcessor.collectModifierToken(node.getOptionalImportModifier());
final Set<Modifier> tmpModifiers = modifierProcessor.getModifiers(true);
final VisibilityKind importVisibility = tmpModifiers.isEmpty() ? VisibilityKind.PUBLIC_LITERAL : getVisibility(
tmpModifiers.iterator().next(), VisibilityKind.PUBLIC_LITERAL);
String qualifiedIdentifier = TextUMLCore.getSourceMiner().getQualifiedIdentifier(node.getQualifiedIdentifier());
final String alias;
if (node.getOptionalAlias() instanceof AOptionalAlias) {
AOptionalAlias optionalAlias = (AOptionalAlias) node.getOptionalAlias();
alias = Util.stripEscaping(optionalAlias.getIdentifier().getText());
} else
alias = null;
getRefTracker().add(
new DeferredReference<NamedElement>(qualifiedIdentifier, IRepository.PACKAGE.getNamedElement(),
namespaceTracker.currentPackage()) {
@Override
protected void onBind(NamedElement element) {
if (element == null) {
problemBuilder.addProblem(new UnresolvedSymbol(getSymbolName()),
node.getQualifiedIdentifier());
return;
}
if (element instanceof Package) {
if (alias != null) {
problemBuilder.addError("Imported packages cannot be aliased",
node.getQualifiedIdentifier());
return;
}
Package importedPackage = (Package) element;
if (currentPackageSnapshot.getImportedPackages().contains(importedPackage))
// just ignore
return;
PackageImport created = currentPackageSnapshot.createPackageImport(importedPackage);
created.setVisibility(importVisibility);
} else {
PackageableElement packageableElement = (PackageableElement) element;
ElementImport elementImport = currentPackageSnapshot.createElementImport(packageableElement);
elementImport.setVisibility(importVisibility);
if (alias != null)
elementImport.setAlias(alias);
}
}
}, IReferenceTracker.Step.PACKAGE_IMPORTS);
}
示例11: internalFindNamedElement
import org.eclipse.uml2.uml.PackageImport; //导入依赖的package包/类
private <T extends NamedElement> T internalFindNamedElement(String name, EClass class_, Namespace namespace,
boolean deep, Set<Namespace> visited) {
Assert.isNotNull(name);
if (namespace != null && !visited.add(namespace))
// already visited, avoid infinite recursion
return null;
// tries to resolve the name regardless the contextual namespace
NamedElement element = internalFindNamedElement(name, class_);
if (element != null && (namespace == null || isVisible(namespace, element, MDDUtil.isQualifiedName(name))))
// element found or is fully qualified, no need to look further
return (T) element;
// no contextual namespace provided, there is nothing else we can do
if (namespace == null) {
if (MDDUtil.isQualifiedName(name)) {
namespace = loadPackage(MDDUtil.getFirstSegment(name));
return (T) ((namespace == null) ? null : findNamedElement(MDDUtil.removeFirstSegment(name), class_,
namespace));
} else
return null;
}
if (namespace instanceof TemplateableElement) {
TemplateableElement asTemplate = (TemplateableElement) namespace;
if (asTemplate.isTemplate()) {
TemplateSignature signature = asTemplate.getOwnedTemplateSignature();
// TODO a template may not have a signature (descendant)
if (signature != null)
for (TemplateParameter parameter : signature.getParameters()) {
final ParameterableElement parameteredElement = parameter.getParameteredElement();
if (parameteredElement instanceof NamedElement
&& name.equals(((NamedElement) parameteredElement).getName()))
return (T) parameteredElement;
}
}
}
// uses the contextual namespace to derive a qualified name (assuming
// 'name' is not fully qualified)
if (namespace.getQualifiedName() != null) {
final String fullyQualifiedName = MDDUtil.appendSegment(namespace.getQualifiedName(), name);
element = internalFindNamedElement(fullyQualifiedName, class_);
if (element != null && isVisible(namespace, element, MDDUtil.isQualifiedName(name)))
// element found, no need to look further
return (T) element;
for (ElementImport elementImport : namespace.getElementImports())
if (elementImport.getName().equals(name))
return (T) elementImport.getImportedElement();
if (deep) {
// check imported packages now
List<PackageImport> imports = namespace.getPackageImports();
for (PackageImport packageImport : imports) {
final Package importedPackage = packageImport.getImportedPackage();
element = internalFindNamedElement(name, class_, importedPackage,
packageImport.getVisibility() != VisibilityKind.PRIVATE_LITERAL, visited);
if ((element != null && isVisible(namespace, element, false)))
return (T) element;
}
}
}
// search the parent now
if (namespace.getOwner() == null)
return null;
return (T) internalFindNamedElement(name, class_, (Namespace) namespace.getOwner(), deep, visited);
}
示例12: importPackage
import org.eclipse.uml2.uml.PackageImport; //导入依赖的package包/类
public static PackageImport importPackage(Package importer, Package imported) {
return importer.getPackageImport(imported, true);
}
示例13: qualifiedName
import org.eclipse.uml2.uml.PackageImport; //导入依赖的package包/类
/**
* Converts a UML package import to a qualified name object. The result is
* not the qualified name of the package import but the imported package.
*
* @param packageImport
* The package import to be converted.
* @return The qualified name.
*/
protected QualifiedName qualifiedName(PackageImport packageImport) {
Package importedPackage = packageImport.getImportedPackage();
return QualifiedName.create(importedPackage.getQualifiedName().split(importedPackage.separator()));
}
开发者ID:Cooperate-Project,项目名称:CooperateModelingEnvironment,代码行数:13,代码来源:CooperateQualifiedNameProvider.java
示例14: setReferencedElement
import org.eclipse.uml2.uml.PackageImport; //导入依赖的package包/类
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* This is specialized for the more specific type known in this context.
* @generated
*/
@Override
public void setReferencedElement(PackageImport newReferencedElement) {
super.setReferencedElement(newReferencedElement);
}