Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnsgar Radermacher2014-03-11 12:07:36 +0000
committerAnsgar Radermacher2014-03-11 12:28:53 +0000
commite6e5f0e360117e271e761d1e345d266f4479c5a0 (patch)
tree4757a4b82bbbc5dd7a9abc9147c89b3375c9f3bb /plugins/uml
parent7189e085bbe7e64f027d4465bd92f1717c17d76b (diff)
downloadorg.eclipse.papyrus-e6e5f0e360117e271e761d1e345d266f4479c5a0.tar.gz
org.eclipse.papyrus-e6e5f0e360117e271e761d1e345d266f4479c5a0.tar.xz
org.eclipse.papyrus-e6e5f0e360117e271e761d1e345d266f4479c5a0.zip
Bug 315231 - [All Diagrams] Direct Edit : Xtext / Papyrus integration: xtext property editor - support not-impored scoped names
Diffstat (limited to 'plugins/uml')
-rw-r--r--plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.property.xtext.ui/src/org/eclipse/papyrus/uml/textedit/property/xtext/ui/contentassist/UmlPropertyProposalProvider.java9
-rw-r--r--plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.property.xtext.ui/src/org/eclipse/papyrus/uml/textedit/property/xtext/ui/contributions/UMLPropertyEditorPropertyUtil.java1
-rw-r--r--plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.property.xtext/META-INF/MANIFEST.MF3
-rw-r--r--plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.property.xtext/src/org/eclipse/papyrus/uml/textedit/property/xtext/scoping/UmlPropertyScopeProvider.java3
-rw-r--r--plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/PackageUtil.java18
5 files changed, 29 insertions, 5 deletions
diff --git a/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.property.xtext.ui/src/org/eclipse/papyrus/uml/textedit/property/xtext/ui/contentassist/UmlPropertyProposalProvider.java b/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.property.xtext.ui/src/org/eclipse/papyrus/uml/textedit/property/xtext/ui/contentassist/UmlPropertyProposalProvider.java
index a8b0fc909e8..cb97ac01a50 100644
--- a/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.property.xtext.ui/src/org/eclipse/papyrus/uml/textedit/property/xtext/ui/contentassist/UmlPropertyProposalProvider.java
+++ b/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.property.xtext.ui/src/org/eclipse/papyrus/uml/textedit/property/xtext/ui/contentassist/UmlPropertyProposalProvider.java
@@ -28,6 +28,7 @@ import org.eclipse.papyrus.uml.textedit.property.xtext.umlProperty.MultiplicityR
import org.eclipse.papyrus.uml.textedit.property.xtext.umlProperty.PropertyRule;
import org.eclipse.papyrus.uml.textedit.property.xtext.umlProperty.QualifiedName;
import org.eclipse.papyrus.uml.textedit.property.xtext.umlProperty.TypeRule;
+import org.eclipse.papyrus.uml.tools.utils.PackageUtil;
import org.eclipse.papyrus.uml.xtext.integration.CompletionProposalUtils;
import org.eclipse.papyrus.uml.xtext.integration.CustomCompletionProposal;
import org.eclipse.papyrus.uml.xtext.integration.core.ContextElementUtil;
@@ -50,7 +51,7 @@ import org.eclipse.xtext.ui.editor.contentassist.ICompletionProposalAcceptor;
* http://www.eclipse.org/Xtext/documentation/latest/xtext.html#contentAssist on
* how to customize content assistant
*/
-
+@SuppressWarnings("nls")
public class UmlPropertyProposalProvider extends AbstractUmlPropertyProposalProvider {
/**
@@ -96,9 +97,9 @@ public class UmlPropertyProposalProvider extends AbstractUmlPropertyProposalProv
CustomCompletionProposal completionProposal = CompletionProposalUtils.createCompletionProposalWithReplacementOfPrefix(root, completionString, displayString, context);
acceptor.accept(completionProposal);
- // then accepts all packages imported by Model
- List<Package> importedPackages = root.getImportedPackages();
- for(Package p : importedPackages) {
+ // then accept all packages imported by Model
+ List<Package> topLevelPackages = PackageUtil.getTopLevelPackages(root);
+ for(Package p : topLevelPackages) {
if(p.getName().toLowerCase().contains(context.getPrefix().toLowerCase())) {
completionString = p.getName() + "::";
displayString = p.getName() + "::";
diff --git a/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.property.xtext.ui/src/org/eclipse/papyrus/uml/textedit/property/xtext/ui/contributions/UMLPropertyEditorPropertyUtil.java b/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.property.xtext.ui/src/org/eclipse/papyrus/uml/textedit/property/xtext/ui/contributions/UMLPropertyEditorPropertyUtil.java
index 4db9abc488e..726b7618a16 100644
--- a/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.property.xtext.ui/src/org/eclipse/papyrus/uml/textedit/property/xtext/ui/contributions/UMLPropertyEditorPropertyUtil.java
+++ b/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.property.xtext.ui/src/org/eclipse/papyrus/uml/textedit/property/xtext/ui/contributions/UMLPropertyEditorPropertyUtil.java
@@ -23,6 +23,7 @@ import org.eclipse.uml2.uml.Property;
public class UMLPropertyEditorPropertyUtil extends PropertyUtil {
+ @SuppressWarnings("nls")
public static String getLabel(Property property) {
StringBuffer buffer = new StringBuffer();
// visibility
diff --git a/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.property.xtext/META-INF/MANIFEST.MF b/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.property.xtext/META-INF/MANIFEST.MF
index 5ee10ddbae6..91d4f82ed9c 100644
--- a/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.property.xtext/META-INF/MANIFEST.MF
+++ b/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.property.xtext/META-INF/MANIFEST.MF
@@ -27,7 +27,8 @@ Require-Bundle: org.eclipse.xtext,
org.eclipse.papyrus.infra.gmfdiag.xtext.glue;bundle-version="1.0.0",
org.apache.log4j;bundle-version="1.2.15",
org.eclipse.papyrus.uml.alf.common;bundle-version="1.0.0",
- org.eclipse.papyrus.uml.xtext.integration.core;bundle-version="1.0.0"
+ org.eclipse.papyrus.uml.xtext.integration.core;bundle-version="1.0.0",
+ org.eclipse.papyrus.uml.tools.utils;bundle-version="1.0.0"
Bundle-Vendor: %providerName
Bundle-ActivationPolicy: lazy
Bundle-Version: 1.0.0.qualifier
diff --git a/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.property.xtext/src/org/eclipse/papyrus/uml/textedit/property/xtext/scoping/UmlPropertyScopeProvider.java b/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.property.xtext/src/org/eclipse/papyrus/uml/textedit/property/xtext/scoping/UmlPropertyScopeProvider.java
index e210aaef8ab..e5b3447bdd8 100644
--- a/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.property.xtext/src/org/eclipse/papyrus/uml/textedit/property/xtext/scoping/UmlPropertyScopeProvider.java
+++ b/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.property.xtext/src/org/eclipse/papyrus/uml/textedit/property/xtext/scoping/UmlPropertyScopeProvider.java
@@ -25,6 +25,7 @@ import org.eclipse.papyrus.uml.textedit.property.xtext.umlProperty.QualifiedName
import org.eclipse.papyrus.uml.textedit.property.xtext.umlProperty.RedefinesRule;
import org.eclipse.papyrus.uml.textedit.property.xtext.umlProperty.SubsetsRule;
import org.eclipse.papyrus.uml.textedit.property.xtext.umlProperty.TypeRule;
+import org.eclipse.papyrus.uml.tools.utils.PackageUtil;
import org.eclipse.papyrus.uml.xtext.integration.core.ContextElementUtil;
import org.eclipse.uml2.uml.Classifier;
import org.eclipse.uml2.uml.Element;
@@ -140,6 +141,8 @@ public class UmlPropertyScopeProvider extends AbstractDeclarativeScopeProvider {
namespaces.add((Namespace)eImport.getImportedElement());
}
}
+ // get top-level packages (imported or not)
+ namespaces.addAll(PackageUtil.getTopLevelPackages(visited));
return namespaces;
}
diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/PackageUtil.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/PackageUtil.java
index f8f000c683d..03bc22422d8 100644
--- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/PackageUtil.java
+++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/PackageUtil.java
@@ -27,6 +27,7 @@ import java.util.TreeSet;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.emf.common.notify.Notifier;
+import org.eclipse.emf.common.util.BasicEList;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.TreeIterator;
import org.eclipse.emf.common.util.URI;
@@ -422,6 +423,23 @@ public class PackageUtil {
}
/**
+ * Return all top-level packages within a resource set.
+ * @param element an element
+ * @return the list of top-level packages
+ */
+ public static List<Package> getTopLevelPackages(Element element) {
+ List<Package> topLevelPackages = new BasicEList<Package>();
+ if (element.eResource() != null) {
+ for (Resource resource : element.eResource().getResourceSet().getResources()) {
+ if ((resource.getContents().size() > 0) && (resource.getContents().get(0) instanceof Package)) {
+ topLevelPackages.add((Package) resource.getContents().get(0));
+ }
+ }
+ }
+ return topLevelPackages;
+ }
+
+ /**
* Returns all accessible Collaboration in the model
*
* @param element

Back to the top