Author: dgeraskov
Date: 2011-12-21 01:29:43 -0500 (Wed, 21 Dec 2011)
New Revision: 37482
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/OpenMappingAction.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/utils/OpenMappingUtils.java
Log:
https://issues.jboss.org/browse/JBIDE-10277
Make possible to find embedded property
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/OpenMappingAction.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/OpenMappingAction.java 2011-12-21
04:19:09 UTC (rev 37481)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/OpenMappingAction.java 2011-12-21
06:29:43 UTC (rev 37482)
@@ -276,6 +276,29 @@
} catch (BadLocationException e) {
HibernateConsolePlugin.getDefault().logErrorMessage(HibernateConsoleMessages.OpenMappingAction_selection_not_found,
e);
}
+ if (propRegion == null && parentProperty.isComposite()){
+ String[] componentPatterns = new String[]{
+ OpenMappingUtils.createPattern("embeddable", "class",
((Component)parentProperty.getValue()).getComponentClassName()),
+ OpenMappingUtils.createPattern("embeddable", "class",
OpenMappingUtils.getShortClassName(
+ ((Component)parentProperty.getValue()).getComponentClassName()))
+ };
+ IRegion componentRegion = null;
+ for (int i = 0; i < componentPatterns.length && componentRegion == null;
i++) {
+ try {
+ componentRegion = findAdapter.find(0, componentPatterns[i], true, true, false,
true);
+ } catch (BadLocationException e) {
+ //ignore
+ }
+ }
+ if (componentRegion != null){
+ try {
+ propRegion = findAdapter.find(parentRegion.getOffset() + parentRegion.getLength(),
+ OpenMappingUtils.generateOrmEmbeddablePropertyPattern(compositeProperty), true,
true, false, true);
+ } catch (BadLocationException e) {
+ //ignore
+ }
+ }
+ }
if (propRegion == null) {
return false;
}
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/utils/OpenMappingUtils.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/utils/OpenMappingUtils.java 2011-12-21
04:19:09 UTC (rev 37481)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/utils/OpenMappingUtils.java 2011-12-21
06:29:43 UTC (rev 37482)
@@ -64,8 +64,8 @@
import org.hibernate.mapping.ToOne;
import org.hibernate.mapping.Value;
import org.hibernate.tool.hbm2x.Cfg2HbmTool;
+import org.hibernate.util.XMLHelper;
import org.hibernate.util.xpl.StringHelper;
-import org.hibernate.util.XMLHelper;
import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource;
@@ -1004,6 +1004,10 @@
}
return createPattern(toolTag, HIBERNATE_TAG_NAME, property.getName());
}
+
+ public static String generateOrmEmbeddablePropertyPattern(Property property) {
+ return createPattern("basic", "name", property.getName());
+ }
/**
* Generates a property xml tag search pattern, which corresponds ejb3 syntax.