Author: scabanovich
Date: 2009-10-01 12:04:58 -0400 (Thu, 01 Oct 2009)
New Revision: 17852
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.xml.ui/src/org/jboss/tools/hibernate/ui/xml/editor/HibernatePropertiesContentAssistProcessor.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.xml.ui/src/org/jboss/tools/hibernate/ui/xml/editor/HibernatePropertiesContentProposalProvider.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4916
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.xml.ui/src/org/jboss/tools/hibernate/ui/xml/editor/HibernatePropertiesContentAssistProcessor.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.xml.ui/src/org/jboss/tools/hibernate/ui/xml/editor/HibernatePropertiesContentAssistProcessor.java 2009-10-01
16:04:21 UTC (rev 17851)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.xml.ui/src/org/jboss/tools/hibernate/ui/xml/editor/HibernatePropertiesContentAssistProcessor.java 2009-10-01
16:04:58 UTC (rev 17852)
@@ -67,10 +67,7 @@
String[] ps = attributes.keySet().toArray(new String[0]);
for (int i = 0; i < ps.length; i++) {
if(context.hasProperty(ps[i])) continue;
- String description = WizardKeys.getString(ps[i] + ".description");
//$NON-NLS-1$
- if("@NULL_KEY(a)".equals(description) || description == null) {
- description = ps[i] + "<p>TODO - add description into
keys-hibernate-config.properties";
- }
+ String description = getDescription(ps[i]);
if(ps[i].startsWith(namePrefix)) {
CompletionProposal proposal = new CompletionProposal(
ps[i],
@@ -120,13 +117,7 @@
IJavaProject jp = EclipseResourceUtil.getJavaProject(project);
if(ps != null) for (int i = 0; i < ps.length; i++) {
String value = ps[i].getContent();
- String descr = null;
- if(jp != null) try {
- IType type = EclipseJavaUtil.findType(jp, value);
- if(type != null) descr = JavadocContentAccess2.getHTMLContent(type, true);
- } catch (JavaModelException e) {
- //ignore
- }
+ String descr = getDescription(jp, value);
CompletionProposal proposal = new CompletionProposal(
value,
valueOffset,
@@ -170,4 +161,26 @@
}
+ public static String getDescription(String propertyName) {
+ String dot = "."; //$NON-NLS-1$
+ String key = propertyName;
+ if(!key.endsWith(dot)) key += dot;
+ key += "description"; //$NON-NLS-1$
+ String description = WizardKeys.getString(key);
+ if("@NULL_KEY(a)".equals(description) || description == null) {
+ description = propertyName + "<p>TODO - add description into
keys-hibernate-config.properties";
+ }
+ return description;
+ }
+
+ public static String getDescription(IJavaProject jp, String value) {
+ String descr = null;
+ if(jp != null) try {
+ IType type = EclipseJavaUtil.findType(jp, value);
+ if(type != null) descr = JavadocContentAccess2.getHTMLContent(type, true);
+ } catch (JavaModelException e) {
+ //ignore
+ }
+ return descr;
+ }
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.xml.ui/src/org/jboss/tools/hibernate/ui/xml/editor/HibernatePropertiesContentProposalProvider.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.xml.ui/src/org/jboss/tools/hibernate/ui/xml/editor/HibernatePropertiesContentProposalProvider.java 2009-10-01
16:04:21 UTC (rev 17851)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.xml.ui/src/org/jboss/tools/hibernate/ui/xml/editor/HibernatePropertiesContentProposalProvider.java 2009-10-01
16:04:58 UTC (rev 17852)
@@ -16,6 +16,8 @@
import java.util.Map;
import java.util.Set;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jface.fieldassist.IContentProposal;
import org.eclipse.jface.fieldassist.IContentProposalProvider;
import org.jboss.tools.common.meta.XAttribute;
@@ -26,6 +28,7 @@
import
org.jboss.tools.common.model.ui.attribute.AttributeContentProposalProviderFactory;
import org.jboss.tools.common.model.ui.attribute.adapter.JavaClassContentAssistProvider;
import
org.jboss.tools.common.model.ui.attribute.adapter.PropertiesContentProposalProvider;
+import org.jboss.tools.common.model.util.EclipseResourceUtil;
import org.jboss.tools.hibernate.xml.model.impl.HibConfigComplexPropertyImpl;
/**
@@ -52,7 +55,7 @@
String prop = (dot < 0) ? ps[i] : ps[i].substring(0, dot + 1);
if(unique.contains(prop)) continue;
unique.add(prop);
- IContentProposal cp =
AttributeContentProposalProviderFactory.makeContentProposal(prop, prop);
+ IContentProposal cp =
AttributeContentProposalProviderFactory.makeContentProposal(prop, prop,
HibernatePropertiesContentAssistProcessor.getDescription(prop));
result.add(cp);
}
}
@@ -70,7 +73,7 @@
for (int i = 0; i < vs.length; i++) {
if(vs[i].length() == 0) continue;
if(vs[i].startsWith(valuePrefix)) {
- IContentProposal cp =
AttributeContentProposalProviderFactory.makeContentProposal(vs[i], vs[i]);
+ IContentProposal cp =
AttributeContentProposalProviderFactory.makeContentProposal(vs[i], vs[i], null);
result.add(cp);
}
}
@@ -79,7 +82,18 @@
p.init(object, null, attr);
IContentProposalProvider pp = p.getContentProposalProvider();
IContentProposal[] ps = pp.getProposals(valuePrefix, valuePrefix.length());
- return ps;
+ IJavaProject jp = getJavaProject();
+ for (int i = 0; i < ps.length; i++) {
+ String descr = ps[i].getDescription();
+ if(descr == null || descr.length() == 0) {
+ String value = ps[i].getContent();
+ descr = HibernatePropertiesContentAssistProcessor.getDescription(jp, value);
+ IContentProposal p2 =
AttributeContentProposalProviderFactory.makeContentProposal(value, ps[i].getLabel(),
descr);
+ result.add(p2);
+ } else {
+ result.add(ps[i]);
+ }
+ }
} else {
//TODO
}
@@ -108,4 +122,8 @@
}
+ IJavaProject getJavaProject() {
+ IProject project = EclipseResourceUtil.getProject(object);
+ return EclipseResourceUtil.getJavaProject(project);
+ }
}