Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Tanasenko2016-05-23 09:39:36 -0400
committerAnton Tanasenko2016-05-23 09:47:21 -0400
commitc4fcfe7fad8fb709bbc6a4ba774a85be9872767b (patch)
tree8dae0561628101a15b731baf1f953974c330d5d3
parent8831217581c793aac6d62691d9e24da262d70e82 (diff)
downloadm2e-core-c4fcfe7fad8fb709bbc6a4ba774a85be9872767b.tar.gz
m2e-core-c4fcfe7fad8fb709bbc6a4ba774a85be9872767b.tar.xz
m2e-core-c4fcfe7fad8fb709bbc6a4ba774a85be9872767b.zip
494308 Add content assist for properties section
Change-Id: I6f6265e2ef719f6deb248effb8fa2224321e4376 Signed-off-by: Anton Tanasenko <atg.sleepless@gmail.com>
-rw-r--r--org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/PomContentAssistProcessor.java4
-rw-r--r--org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/PomTemplateContext.java50
-rw-r--r--org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/Messages.java2
-rw-r--r--org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/messages.properties1
-rw-r--r--pom.xml3
5 files changed, 48 insertions, 12 deletions
diff --git a/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/PomContentAssistProcessor.java b/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/PomContentAssistProcessor.java
index 9c33d4c0..fa653f2f 100644
--- a/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/PomContentAssistProcessor.java
+++ b/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/PomContentAssistProcessor.java
@@ -366,10 +366,6 @@ public class PomContentAssistProcessor extends DefaultXMLCompletionProposalCompu
image = ((PomTemplate) template).getImage();
}
- if(image == null && context == PomTemplateContext.CONFIGURATION) {
- image = MvnImages.IMG_PARAMETER;
- }
-
TemplateProposal proposal = createProposalForTemplate(prefix, region, templateContext, image, template, false);
if(proposal != null) {
matches.add(proposal);
diff --git a/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/PomTemplateContext.java b/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/PomTemplateContext.java
index 2f45c17b..ddcf78ad 100644
--- a/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/PomTemplateContext.java
+++ b/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/PomTemplateContext.java
@@ -29,6 +29,7 @@ import java.util.EnumSet;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
+import java.util.Map;
import java.util.Properties;
import java.util.Set;
@@ -98,8 +99,6 @@ public enum PomTemplateContext {
RELATIVE_PATH("relativePath"), // //$NON-NLS-1$
- PROPERTIES("properties"), // //$NON-NLS-1$
-
DEPENDENCIES("dependencies"), // //$NON-NLS-1$
DEPENDENCY_MANAGEMENT("dependencyManagement"), // //$NON-NLS-1$
@@ -120,6 +119,43 @@ public enum PomTemplateContext {
REPOSITORIES("repositories"), // //$NON-NLS-1$
+ PROPERTIES("properties") { // //$NON-NLS-1$
+
+ protected void addTemplates(MavenProject project, IProject eclipsePrj, Collection<Template> templates,
+ Node currentNode, String prefix) {
+
+ // propose overridable properties
+
+ Set<String> currentNodeProps = new HashSet<>();
+ NodeList nodes = currentNode.getChildNodes();
+ for(int i = 0; i < nodes.getLength(); i++ ) {
+ currentNodeProps.add(nodes.item(i).getNodeName());
+ }
+
+ if(project != null) {
+ Properties props = project.getProperties();
+ if(props != null) {
+ for(Map.Entry<Object, Object> e : props.entrySet()) {
+ String name = e.getKey().toString();
+ String value = e.getValue().toString();
+
+ if(currentNodeProps.contains(name))
+ continue;
+
+ if(!name.startsWith(prefix))
+ continue;
+
+ String template = "<" + name + ">${cursor}" + value + "</" + name + ">"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ String desc = NLS.bind(Messages.PomTemplateContext_property_override, value);
+ templates.add(new PomTemplate(name, desc, getContextTypeId(), template, false).image(MvnImages.IMG_PROPERTY)
+ .relevance(2000));
+ }
+ }
+ }
+
+ }
+ },
+
CONFIGURATION("configuration") { //$NON-NLS-1$
public boolean handlesSubtree() {
@@ -230,16 +266,18 @@ public enum PomTemplateContext {
text += desc.startsWith("<p>") ? desc : "<br>" + desc; //$NON-NLS-1$ //$NON-NLS-2$
}
- proposals.add(new Template(name, text, getContextTypeId(), //
- "<" + name + ">${cursor}</" + name + ">", false)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ proposals.add(new PomTemplate(name, text, getContextTypeId(), //
+ "<" + name + ">${cursor}</" + name + ">", false) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ .image(MvnImages.IMG_PARAMETER).relevance(1900));
}
}
if(param.isMap()) {
if(prefix != null && !prefix.trim().isEmpty()) {
- proposals.add(new Template(NLS.bind(Messages.PomTemplateContext_insertParameter, prefix), "", //$NON-NLS-1$
- getContextTypeId(), "<" + prefix + ">${cursor}</" + prefix + ">", true)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ proposals.add(new PomTemplate(NLS.bind(Messages.PomTemplateContext_insertParameter, prefix), "", //$NON-NLS-1$
+ getContextTypeId(), "<" + prefix + ">${cursor}</" + prefix + ">", true) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ .image(MvnImages.IMG_PARAMETER).relevance(1500));
}
diff --git a/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/Messages.java b/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/Messages.java
index 1ab91673..b3fa5559 100644
--- a/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/Messages.java
+++ b/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/Messages.java
@@ -158,6 +158,8 @@ public class Messages extends NLS {
public static String PomTemplateContext_project_version_hint;
+ public static String PomTemplateContext_property_override;
+
public static String PomTemplateContext_site;
public static String PomTemplateContext_sitedeploy;
diff --git a/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/messages.properties b/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/messages.properties
index 7e60e908..989081e6 100644
--- a/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/messages.properties
+++ b/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/messages.properties
@@ -67,6 +67,7 @@ PomTemplateContext_processtestclasses=Post-process the generated files from test
PomTemplateContext_processtestresources=Copy and process the resources into the test destination directory
PomTemplateContext_processtestsources=Process the test source code, for example to filter any values
PomTemplateContext_project_version_hint=For projects developed in sync only.
+PomTemplateContext_property_override=Override property value <b>{0}</b>
PomTemplateContext_resolvingPlugin=Resolving plugin
PomTemplateContext_site=Generates the project's site documentation
PomTemplateContext_sitedeploy=Deploys the generated site documentation to the specified web server
diff --git a/pom.xml b/pom.xml
index e2828cdf..0e36a67f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -40,8 +40,7 @@
<tycho-extras-version>${tycho-version}</tycho-extras-version>
<!-- eclipse version m2e is built against -->
- <eclipse.stream>staging</eclipse.stream>
- <!-- eclipse.stream>neon</eclipse.stream-->
+ <eclipse.stream>neon</eclipse.stream>
<eclipse-repo.url>http://download.eclipse.org/releases/${eclipse.stream}</eclipse-repo.url>
</properties>

Back to the top