JBoss Tools SVN: r11291 - trunk/vpe/plugins/org.jboss.tools.vpe.resref/src/org/jboss/tools/vpe/resref/core.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2008-10-29 10:28:24 -0400 (Wed, 29 Oct 2008)
New Revision: 11291
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe.resref/src/org/jboss/tools/vpe/resref/core/VpeElVariableValidator.java
Log:
Pool for EL parsers implemented.
Modified: trunk/vpe/plugins/org.jboss.tools.vpe.resref/src/org/jboss/tools/vpe/resref/core/VpeElVariableValidator.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.resref/src/org/jboss/tools/vpe/resref/core/VpeElVariableValidator.java 2008-10-29 14:13:50 UTC (rev 11290)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.resref/src/org/jboss/tools/vpe/resref/core/VpeElVariableValidator.java 2008-10-29 14:28:24 UTC (rev 11291)
@@ -12,6 +12,7 @@
import java.util.Properties;
+import org.jboss.tools.common.el.core.model.ELModel;
import org.jboss.tools.common.el.core.parser.ELParser;
import org.jboss.tools.common.el.core.parser.ELParserUtil;
import org.jboss.tools.common.meta.action.impl.DefaultWizardDataValidator;
@@ -45,8 +46,8 @@
}
String location = (String) data.get("location"); //$NON-NLS-1$
ELParser elParser = ELParserUtil.getDefaultFactory().createParser();
- elParser.parse("#{"+location+'}'); //$NON-NLS-1$
- if(elParser.getSyntaxErrors().size()>0) {
+ ELModel model = elParser.parse("#{"+location+'}'); //$NON-NLS-1$
+ if(model == null || model.getSyntaxErrors().size()>0) {
message=Messages.INVALID_EL_EXPRESSION;
}
16 years, 2 months
JBoss Tools SVN: r11290 - trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/collect.
by jbosstools-commits@lists.jboss.org
Author: vyemialyanchyk
Date: 2008-10-29 10:13:50 -0400 (Wed, 29 Oct 2008)
New Revision: 11290
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/collect/AllEntitiesInfoCollector.java
Log:
JBIDE-3033 - fix: use user suggestions
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/collect/AllEntitiesInfoCollector.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/collect/AllEntitiesInfoCollector.java 2008-10-29 14:13:37 UTC (rev 11289)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/collect/AllEntitiesInfoCollector.java 2008-10-29 14:13:50 UTC (rev 11290)
@@ -140,13 +140,70 @@
if (pi.refEntityInfo == null || pi.refEntityInfo2 == null) {
return false;
}
- boolean hasPrompt = false;
+ int hasPrompt = 0; // no user prompt
// - use it as prompting from the user
- if ((pi.fieldId != null && pi.fieldId.equals(pi.refEntityInfo2.mappedBy)) ||
- (pi.fieldId2 != null && pi.fieldId2.equals(pi.refEntityInfo.mappedBy))) {
- hasPrompt = true;
+ if ((pi.fieldId != null && pi.fieldId.equals(pi.refEntityInfo2.mappedBy))) {
+ hasPrompt |= 1;
}
- if (hasPrompt) {
+ if ((pi.fieldId2 != null && pi.fieldId2.equals(pi.refEntityInfo.mappedBy))) {
+ hasPrompt |= 2;
+ }
+ if (hasPrompt != 0) {
+ // remember: in case of incorrect user prompts - we proceed his suggestions
+ if (hasPrompt == 1) {
+ if (pi.refEntityInfo2.refType == RefType.ONE2ONE) {
+ pi.refEntityInfo.refType = RefType.ONE2ONE;
+ pi.refEntityInfo.mappedBy = pi.fieldId2;
+ pi.refEntityInfo2.refType = RefType.ONE2ONE;
+ pi.refEntityInfo2.mappedBy = pi.fieldId;
+ }
+ else if (pi.refEntityInfo2.refType == RefType.ONE2MANY) {
+ pi.refEntityInfo.refType = RefType.MANY2ONE;
+ pi.refEntityInfo.mappedBy = pi.fieldId2;
+ pi.refEntityInfo2.refType = RefType.ONE2MANY;
+ pi.refEntityInfo2.mappedBy = pi.fieldId;
+ }
+ else if (pi.refEntityInfo2.refType == RefType.MANY2ONE) {
+ pi.refEntityInfo.refType = RefType.ONE2MANY;
+ pi.refEntityInfo.mappedBy = pi.fieldId2;
+ pi.refEntityInfo2.refType = RefType.MANY2ONE;
+ pi.refEntityInfo2.mappedBy = pi.fieldId;
+ }
+ else if (pi.refEntityInfo2.refType == RefType.MANY2MANY) {
+ pi.refEntityInfo.refType = RefType.MANY2MANY;
+ pi.refEntityInfo.mappedBy = pi.fieldId2;
+ pi.refEntityInfo2.refType = RefType.MANY2MANY;
+ pi.refEntityInfo2.mappedBy = pi.fieldId;
+ }
+ }
+ else if (hasPrompt == 2) {
+ if (pi.refEntityInfo.refType == RefType.ONE2ONE) {
+ pi.refEntityInfo.refType = RefType.ONE2ONE;
+ pi.refEntityInfo.mappedBy = pi.fieldId;
+ pi.refEntityInfo2.refType = RefType.ONE2ONE;
+ pi.refEntityInfo2.mappedBy = pi.fieldId2;
+ }
+ else if (pi.refEntityInfo.refType == RefType.ONE2MANY) {
+ pi.refEntityInfo.refType = RefType.ONE2MANY;
+ pi.refEntityInfo.mappedBy = pi.fieldId;
+ pi.refEntityInfo2.refType = RefType.MANY2ONE;
+ pi.refEntityInfo2.mappedBy = pi.fieldId2;
+ }
+ else if (pi.refEntityInfo.refType == RefType.MANY2ONE) {
+ pi.refEntityInfo.refType = RefType.MANY2ONE;
+ pi.refEntityInfo.mappedBy = pi.fieldId;
+ pi.refEntityInfo2.refType = RefType.ONE2MANY;
+ pi.refEntityInfo2.mappedBy = pi.fieldId2;
+ }
+ else if (pi.refEntityInfo.refType == RefType.MANY2MANY) {
+ pi.refEntityInfo.refType = RefType.MANY2MANY;
+ pi.refEntityInfo.mappedBy = pi.fieldId;
+ pi.refEntityInfo2.refType = RefType.MANY2MANY;
+ pi.refEntityInfo2.mappedBy = pi.fieldId2;
+ }
+ }
+ //if (hasPrompt == 3) - this is case where we get prompt from both sides -
+ // and it is possible this is not correct info... so try to adjust it.
if (pi.refEntityInfo.refType == RefType.ONE2ONE) {
if (pi.refEntityInfo2.refType == RefType.ONE2ONE) {
pi.refEntityInfo.refType = RefType.ONE2ONE;
16 years, 2 months
JBoss Tools SVN: r11289 - branches/jbosstools-3.0.0.Beta1/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/collect.
by jbosstools-commits@lists.jboss.org
Author: vyemialyanchyk
Date: 2008-10-29 10:13:37 -0400 (Wed, 29 Oct 2008)
New Revision: 11289
Modified:
branches/jbosstools-3.0.0.Beta1/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/collect/AllEntitiesInfoCollector.java
Log:
JBIDE-3033 - fix: use user suggestions
Modified: branches/jbosstools-3.0.0.Beta1/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/collect/AllEntitiesInfoCollector.java
===================================================================
--- branches/jbosstools-3.0.0.Beta1/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/collect/AllEntitiesInfoCollector.java 2008-10-29 13:13:08 UTC (rev 11288)
+++ branches/jbosstools-3.0.0.Beta1/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/collect/AllEntitiesInfoCollector.java 2008-10-29 14:13:37 UTC (rev 11289)
@@ -140,13 +140,70 @@
if (pi.refEntityInfo == null || pi.refEntityInfo2 == null) {
return false;
}
- boolean hasPrompt = false;
+ int hasPrompt = 0; // no user prompt
// - use it as prompting from the user
- if ((pi.fieldId != null && pi.fieldId.equals(pi.refEntityInfo2.mappedBy)) ||
- (pi.fieldId2 != null && pi.fieldId2.equals(pi.refEntityInfo.mappedBy))) {
- hasPrompt = true;
+ if ((pi.fieldId != null && pi.fieldId.equals(pi.refEntityInfo2.mappedBy))) {
+ hasPrompt |= 1;
}
- if (hasPrompt) {
+ if ((pi.fieldId2 != null && pi.fieldId2.equals(pi.refEntityInfo.mappedBy))) {
+ hasPrompt |= 2;
+ }
+ if (hasPrompt != 0) {
+ // remember: in case of incorrect user prompts - we proceed his suggestions
+ if (hasPrompt == 1) {
+ if (pi.refEntityInfo2.refType == RefType.ONE2ONE) {
+ pi.refEntityInfo.refType = RefType.ONE2ONE;
+ pi.refEntityInfo.mappedBy = pi.fieldId2;
+ pi.refEntityInfo2.refType = RefType.ONE2ONE;
+ pi.refEntityInfo2.mappedBy = pi.fieldId;
+ }
+ else if (pi.refEntityInfo2.refType == RefType.ONE2MANY) {
+ pi.refEntityInfo.refType = RefType.MANY2ONE;
+ pi.refEntityInfo.mappedBy = pi.fieldId2;
+ pi.refEntityInfo2.refType = RefType.ONE2MANY;
+ pi.refEntityInfo2.mappedBy = pi.fieldId;
+ }
+ else if (pi.refEntityInfo2.refType == RefType.MANY2ONE) {
+ pi.refEntityInfo.refType = RefType.ONE2MANY;
+ pi.refEntityInfo.mappedBy = pi.fieldId2;
+ pi.refEntityInfo2.refType = RefType.MANY2ONE;
+ pi.refEntityInfo2.mappedBy = pi.fieldId;
+ }
+ else if (pi.refEntityInfo2.refType == RefType.MANY2MANY) {
+ pi.refEntityInfo.refType = RefType.MANY2MANY;
+ pi.refEntityInfo.mappedBy = pi.fieldId2;
+ pi.refEntityInfo2.refType = RefType.MANY2MANY;
+ pi.refEntityInfo2.mappedBy = pi.fieldId;
+ }
+ }
+ else if (hasPrompt == 2) {
+ if (pi.refEntityInfo.refType == RefType.ONE2ONE) {
+ pi.refEntityInfo.refType = RefType.ONE2ONE;
+ pi.refEntityInfo.mappedBy = pi.fieldId;
+ pi.refEntityInfo2.refType = RefType.ONE2ONE;
+ pi.refEntityInfo2.mappedBy = pi.fieldId2;
+ }
+ else if (pi.refEntityInfo.refType == RefType.ONE2MANY) {
+ pi.refEntityInfo.refType = RefType.ONE2MANY;
+ pi.refEntityInfo.mappedBy = pi.fieldId;
+ pi.refEntityInfo2.refType = RefType.MANY2ONE;
+ pi.refEntityInfo2.mappedBy = pi.fieldId2;
+ }
+ else if (pi.refEntityInfo.refType == RefType.MANY2ONE) {
+ pi.refEntityInfo.refType = RefType.MANY2ONE;
+ pi.refEntityInfo.mappedBy = pi.fieldId;
+ pi.refEntityInfo2.refType = RefType.ONE2MANY;
+ pi.refEntityInfo2.mappedBy = pi.fieldId2;
+ }
+ else if (pi.refEntityInfo.refType == RefType.MANY2MANY) {
+ pi.refEntityInfo.refType = RefType.MANY2MANY;
+ pi.refEntityInfo.mappedBy = pi.fieldId;
+ pi.refEntityInfo2.refType = RefType.MANY2MANY;
+ pi.refEntityInfo2.mappedBy = pi.fieldId2;
+ }
+ }
+ //if (hasPrompt == 3) - this is case where we get prompt from both sides -
+ // and it is possible this is not correct info... so try to adjust it.
if (pi.refEntityInfo.refType == RefType.ONE2ONE) {
if (pi.refEntityInfo2.refType == RefType.ONE2ONE) {
pi.refEntityInfo.refType = RefType.ONE2ONE;
16 years, 2 months
JBoss Tools SVN: r11288 - branches/jbosstools-3.0.0.Beta1/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/actions.
by jbosstools-commits@lists.jboss.org
Author: vyemialyanchyk
Date: 2008-10-29 09:13:08 -0400 (Wed, 29 Oct 2008)
New Revision: 11288
Modified:
branches/jbosstools-3.0.0.Beta1/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/actions/JPAMapToolActor.java
Log:
fix: empty selection
Modified: branches/jbosstools-3.0.0.Beta1/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/actions/JPAMapToolActor.java
===================================================================
--- branches/jbosstools-3.0.0.Beta1/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/actions/JPAMapToolActor.java 2008-10-29 13:12:20 UTC (rev 11287)
+++ branches/jbosstools-3.0.0.Beta1/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/actions/JPAMapToolActor.java 2008-10-29 13:13:08 UTC (rev 11288)
@@ -327,7 +327,7 @@
synchronized public void setSelection(ISelection selection) {
//System.out.println("Blah! " + selection); //$NON-NLS-1$
- if (selection instanceof StructuredSelection) {
+ if (selection instanceof StructuredSelection && selection.isEmpty()) {
//System.out.println("This! " + this.selection); //$NON-NLS-1$
clearSelectionCU();
this.selection = null;
16 years, 2 months
JBoss Tools SVN: r11287 - trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/actions.
by jbosstools-commits@lists.jboss.org
Author: vyemialyanchyk
Date: 2008-10-29 09:12:20 -0400 (Wed, 29 Oct 2008)
New Revision: 11287
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/actions/JPAMapToolActor.java
Log:
fix: empty selection
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/actions/JPAMapToolActor.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/actions/JPAMapToolActor.java 2008-10-29 13:09:09 UTC (rev 11286)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/actions/JPAMapToolActor.java 2008-10-29 13:12:20 UTC (rev 11287)
@@ -327,7 +327,7 @@
synchronized public void setSelection(ISelection selection) {
//System.out.println("Blah! " + selection); //$NON-NLS-1$
- if (selection instanceof StructuredSelection) {
+ if (selection instanceof StructuredSelection && selection.isEmpty()) {
//System.out.println("This! " + this.selection); //$NON-NLS-1$
clearSelectionCU();
this.selection = null;
16 years, 2 months
JBoss Tools SVN: r11286 - in trunk: vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor and 3 other directories.
by jbosstools-commits@lists.jboss.org
Author: mareshkau
Date: 2008-10-29 09:09:09 -0400 (Wed, 29 Oct 2008)
New Revision: 11286
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/ComponentUtil.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAbstractTemplate.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionSrc.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ElService.java
Log:
JBIDE-3030
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/ComponentUtil.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/ComponentUtil.java 2008-10-29 13:02:13 UTC (rev 11285)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/ComponentUtil.java 2008-10-29 13:09:09 UTC (rev 11286)
@@ -467,6 +467,10 @@
public static void setImgFromResources(VpePageContext pageContext, nsIDOMElement img, String fileImageName, String undefinedImgName) {
IEditorInput input = pageContext.getEditPart().getEditorInput();
IPath inputPath = getInputParentPath(input);
+ //Fix For JBIDE-3030
+ if(pageContext.getVisualBuilder().getCurrentIncludeInfo()==null) {
+ return;
+ }
String path = ElService.getInstance().replaceEl(pageContext.getVisualBuilder().getCurrentIncludeInfo().getFile(), fileImageName);
File file = new File(inputPath.toOSString() + File.separator + path);
if (file.exists()) {
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java 2008-10-29 13:02:13 UTC (rev 11285)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java 2008-10-29 13:09:09 UTC (rev 11286)
@@ -2208,7 +2208,10 @@
VpeIncludeInfo info = (VpeIncludeInfo) includeStack.get(1);
return ((IndexedRegion) info.getElement()).getStartOffset();
}
-
+ /**
+ * Can be a null in some cases, for example when we open an external file, see JBIDE-3030
+ * @return file include info
+ */
public VpeIncludeInfo getCurrentIncludeInfo() {
if (includeStack.size() <= 0)
return null;
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAbstractTemplate.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAbstractTemplate.java 2008-10-29 13:02:13 UTC (rev 11285)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAbstractTemplate.java 2008-10-29 13:09:09 UTC (rev 11286)
@@ -1488,10 +1488,12 @@
// System.err.println("Hello world4");
}
- @SuppressWarnings("restriction")
public void beforeTemplateCreated(VpePageContext pageContext, Node sourceNode, nsIDOMDocument domDocument) {
- final IFile file = pageContext.getVisualBuilder().getCurrentIncludeInfo().getFile();
-
+ IFile file = null;
+ //Fix for JBIDE-3030
+ if(pageContext.getVisualBuilder().getCurrentIncludeInfo()!=null) {
+ file = pageContext.getVisualBuilder().getCurrentIncludeInfo().getFile();
+ }
if ((file != null)) {
// Node first((Element
if (sourceNode.getNodeType() == Node.TEXT_NODE) {
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionSrc.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionSrc.java 2008-10-29 13:02:13 UTC (rev 11285)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionSrc.java 2008-10-29 13:09:09 UTC (rev 11286)
@@ -238,6 +238,10 @@
*/
protected String resolveEL(VpePageContext pageContext, String value) {
String resolvedValue = value.replaceFirst("^\\s*(\\#|\\$)\\{facesContext.externalContext.requestContextPath\\}", ""); //$NON-NLS-1$ //$NON-NLS-2$
+ //Fix for JBIDE-3030
+ if(pageContext.getVisualBuilder().getCurrentIncludeInfo()==null){
+ return resolvedValue;
+ }
final IFile file = pageContext.getVisualBuilder().getCurrentIncludeInfo().getFile();
resolvedValue = ElService.getInstance().replaceEl(file, resolvedValue);
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ElService.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ElService.java 2008-10-29 13:02:13 UTC (rev 11285)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ElService.java 2008-10-29 13:09:09 UTC (rev 11286)
@@ -376,7 +376,7 @@
}
public String replaceElAndResources(VpePageContext pageContext, Node attributeNode) {
- final IFile file = pageContext.getVisualBuilder().getCurrentIncludeInfo().getFile();
+
String attribuString = null;
if (attributeNode instanceof Attr) {
@@ -387,6 +387,11 @@
String rst = attribuString;
rst = ResourceUtil.getBundleValue(pageContext, attributeNode);
+ //fix for JBIDE-3030
+ if(pageContext.getVisualBuilder().getCurrentIncludeInfo()==null) {
+ return rst;
+ }
+ final IFile file = pageContext.getVisualBuilder().getCurrentIncludeInfo().getFile();
rst = replaceEl(file, rst);
return rst;
16 years, 2 months
JBoss Tools SVN: r11285 - trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2008-10-29 09:02:13 -0400 (Wed, 29 Oct 2008)
New Revision: 11285
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamELValidator.java
Log:
Pool for EL parsers implemented.
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamELValidator.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamELValidator.java 2008-10-29 12:58:56 UTC (rev 11284)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamELValidator.java 2008-10-29 13:02:13 UTC (rev 11285)
@@ -259,7 +259,7 @@
if(startEl>-1) {
ELParser parser = ELParserUtil.getJbossFactory().createParser();
ELModel model = parser.parse(string);
- List<SyntaxError> errors = parser.getSyntaxErrors();
+ List<SyntaxError> errors = model.getSyntaxErrors();
if(errors.size() > 0) {
for (SyntaxError error: errors) {
//TODO 1) make message more informative
16 years, 2 months
JBoss Tools SVN: r11284 - trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2008-10-29 08:58:56 -0400 (Wed, 29 Oct 2008)
New Revision: 11284
Modified:
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/ELParserTest.java
Log:
Pool for EL parsers implemented.
Modified: trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/ELParserTest.java
===================================================================
--- trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/ELParserTest.java 2008-10-29 12:57:57 UTC (rev 11283)
+++ trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/ELParserTest.java 2008-10-29 12:58:56 UTC (rev 11284)
@@ -11,7 +11,12 @@
package org.jboss.tools.common.el.core.test;
import java.util.List;
+import java.util.Random;
+import org.jboss.tools.common.el.core.model.ELModel;
+import org.jboss.tools.common.el.core.parser.ELParser;
+import org.jboss.tools.common.el.core.parser.ELParserFactory;
+import org.jboss.tools.common.el.core.parser.ELParserUtil;
import org.jboss.tools.common.el.core.parser.LexicalToken;
import org.jboss.tools.common.el.core.parser.SyntaxError;
import org.jboss.tools.common.el.core.parser.Tokenizer;
@@ -194,4 +199,72 @@
return sb.toString();
}
+ static int TREAD_NUMBER = 20;
+ static int CALL_NUMBER = 1000;
+
+ public void testMultiThreadAccess() {
+
+ final ELParserFactory factory = ELParserUtil.getJbossFactory();
+ final Random random = new Random();
+ class Z {
+ int counter = 0;
+ int parserErrors = 0;
+ int syntaxErrors = 0;
+ int expectedSyntaxErrors = 0;
+ synchronized void addParserError() {
+ parserErrors++;
+ }
+ synchronized void addSyntaxError() {
+ syntaxErrors++;
+ }
+ synchronized void addExpectedSyntaxError() {
+ expectedSyntaxErrors++;
+ }
+ }
+ final Z z = new Z();
+
+ for (int i = 0; i < TREAD_NUMBER; i++) {
+ Runnable r = new Runnable() {
+ public void run() {
+ z.counter++;
+ try {
+ for (int j = 0; j < CALL_NUMBER; j++) {
+ boolean addError = random.nextInt(100) < 50;
+ if(addError) z.addExpectedSyntaxError();
+ ELParser parser = factory.createParser();
+ String el = "#{(a + b(c.d" + random.nextInt(1000) + ") + c().k" + (addError ? "." : "") + ") + 9.7}";
+ ELModel model = parser.parse(el);
+ LexicalToken t = model.getFirstToken();
+ if(!el.equals(restore(t))) {
+ z.addParserError();
+ }
+ if(model.getSyntaxErrors() != null && model.getSyntaxErrors().size() > 0) {
+ z.addSyntaxError();
+ }
+ }
+ } finally {
+ z.counter--;
+ }
+ }
+ };
+ new Thread(r).start();
+ }
+
+ while(z.counter > 0) {
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
+
+ }
+ }
+
+ System.out.println("testMultiThreadAccess: Expected syntax errors=" + z.expectedSyntaxErrors);
+
+ assertEquals(0, z.parserErrors);
+
+ assertEquals(z.expectedSyntaxErrors, z.syntaxErrors);
+
+
+ }
+
}
16 years, 2 months
JBoss Tools SVN: r11283 - in trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el: core/parser and 3 other directories.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2008-10-29 08:57:57 -0400 (Wed, 29 Oct 2008)
New Revision: 11283
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/model/ELModel.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/ELParser.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/ELParserUtil.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/Tokenizer.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/TokenizerFactory.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/Var.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELModelImpl.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/ELParserImpl.java
Log:
Pool for EL parsers implemented.
Modified: trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/model/ELModel.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/model/ELModel.java 2008-10-29 12:54:37 UTC (rev 11282)
+++ trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/model/ELModel.java 2008-10-29 12:57:57 UTC (rev 11283)
@@ -12,6 +12,8 @@
import java.util.List;
+import org.jboss.tools.common.el.core.parser.SyntaxError;
+
/**
* ELModel object is the result of EL parsing that includes
* all found instances of EL in the source string.
@@ -25,6 +27,8 @@
public List<ELInstance> getInstances();
+ public List<SyntaxError> getSyntaxErrors();
+
public void shift(int delta);
}
Modified: trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/ELParser.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/ELParser.java 2008-10-29 12:54:37 UTC (rev 11282)
+++ trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/ELParser.java 2008-10-29 12:57:57 UTC (rev 11283)
@@ -25,6 +25,4 @@
public ELModel parse(String source, int start, int length);
- public List<SyntaxError> getSyntaxErrors();
-
}
Modified: trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/ELParserUtil.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/ELParserUtil.java 2008-10-29 12:54:37 UTC (rev 11282)
+++ trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/ELParserUtil.java 2008-10-29 12:57:57 UTC (rev 11283)
@@ -11,6 +11,7 @@
package org.jboss.tools.common.el.core.parser;
import java.util.List;
+import java.util.Stack;
import org.jboss.tools.common.el.core.model.ELModel;
import org.jboss.tools.common.el.internal.core.model.ELModelImpl;
@@ -23,53 +24,104 @@
*/
public class ELParserUtil {
+ private static ELParserFactory DEFAULT_FACTORY = new DefaultFactory() {
+ public ELParser newParser() {
+ return new DefaultParser() {
+ protected Tokenizer createTokenizer() {
+ return TokenizerFactory.createDefaultTokenizer();
+ }
+ public void dispose() {
+ super.dispose();
+ release(this);
+ }
+ };
+ }
+ };
+
public static ELParserFactory getDefaultFactory() {
- return new ELParserFactory() {
- public ELParser createParser() {
- return new DefaultParser() {
- protected Tokenizer createTokenizer() {
- return TokenizerFactory.createDefaultTokenizer();
- }
- };
- }
- };
+ return DEFAULT_FACTORY;
}
+ private static ELParserFactory JBOSS_FACTORY = new DefaultFactory() {
+ public ELParser newParser() {
+ return new DefaultParser() {
+ protected Tokenizer createTokenizer() {
+ return TokenizerFactory.createJbossTokenizer();
+ }
+ public void dispose() {
+ super.dispose();
+ release(this);
+ }
+ };
+ }
+ };
+
public static ELParserFactory getJbossFactory() {
- return new ELParserFactory() {
- public ELParser createParser() {
- return new DefaultParser() {
- protected Tokenizer createTokenizer() {
- return TokenizerFactory.createJbossTokenizer();
- }
- };
+ return JBOSS_FACTORY;
+ }
+
+ private static abstract class DefaultFactory implements ELParserFactory {
+ protected Stack<ELParser> inUse = new Stack<ELParser>();
+ protected Stack<ELParser> free = new Stack<ELParser>();
+
+ public ELParser createParser() {
+ synchronized(this) {
+ if(!free.isEmpty()) {
+ //reuse
+ ELParser parser = free.pop();
+ inUse.push(parser);
+ return parser;
+ }
}
- };
+ ELParser parser = newParser();
+ synchronized(this) {
+ //new
+ inUse.push(parser);
+ }
+ return parser;
+ }
+
+ protected abstract ELParser newParser();
+
+ public void release(ELParser parser) {
+ synchronized(this) {
+ //release
+ boolean b = inUse.remove(parser);
+ if(!b) return;
+ free.push(parser);
+ }
+ }
}
private static abstract class DefaultParser implements ELParser {
ELParserImpl impl = new ELParserImpl();
List<SyntaxError> errors = null;
+ Tokenizer t = createTokenizer();
public ELModel parse(String source) {
return parse(source, 0, source.length());
}
public ELModel parse(String source, int start, int length) {
- Tokenizer t = createTokenizer();
- LexicalToken token = t.parse(source, start, length);
- errors = t.getErrors();
- ELModelImpl model = impl.parse(token);
- model.setSource(source);
- model.setErrors(errors);
- return model;
+ try {
+ LexicalToken token = t.parse(source, start, length);
+ errors = t.getErrors();
+ ELModelImpl model = impl.parse(token);
+ model.setSource(source);
+ model.setErrors(errors);
+ return model;
+ } finally {
+ t.dispose();
+ dispose();
+ }
}
- public List<SyntaxError> getSyntaxErrors() {
- return errors;
+ protected abstract Tokenizer createTokenizer();
+
+ public void dispose() {
+ errors = null;
}
- protected abstract Tokenizer createTokenizer();
}
}
Modified: trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/Tokenizer.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/Tokenizer.java 2008-10-29 12:54:37 UTC (rev 11282)
+++ trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/Tokenizer.java 2008-10-29 12:57:57 UTC (rev 11283)
@@ -32,8 +32,8 @@
private String sourceString;
private int index = 0;
- private LexicalToken start = new LexicalToken(0, 0, "", -1000);
- private LexicalToken last = start;
+ private LexicalToken start;
+ private LexicalToken last;
private int state;
private Properties context = new Properties();
@@ -42,7 +42,21 @@
public Tokenizer() {}
+ /**
+ * Prepares this tokenizer to be reused with the same token descriptions and rules.
+ *
+ */
+ public void dispose() {
+ sourceString = null;
+ index = 0;
+ start = null;
+ last = null;
+ context.clear();
+ errors.clear();
+ }
+
public void setTokenDescriptions(ITokenDescription[] ds) {
+ tokenDescriptions.clear();
for (int i = 0; i < ds.length; i++) {
int type = ds[i].getType();
if(tokenDescriptions.containsKey(type)) {
@@ -57,6 +71,7 @@
}
public void setRules(IRule[] rules) {
+ this.rules.clear();
for (int i = 0; i < rules.length; i++) {
int[] ss = rules[i].getStartStates();
for (int j = 0; j < ss.length; j++) {
@@ -122,8 +137,17 @@
return result;
}
+ private static List<SyntaxError> EMPTY = new ArrayList<SyntaxError>();
+
+ /**
+ * Copies errors in order to reuse this object.
+ * @return
+ */
public List<SyntaxError> getErrors() {
- return errors;
+ if(errors.size() == 0) return EMPTY;
+ List<SyntaxError> copy = new ArrayList<SyntaxError>();
+ copy.addAll(errors);
+ return copy;
}
public void addToken(int type, int start, int end) {
@@ -195,4 +219,5 @@
public int getCurrentIndex() {
return index;
}
+
}
Modified: trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/TokenizerFactory.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/TokenizerFactory.java 2008-10-29 12:54:37 UTC (rev 11282)
+++ trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/TokenizerFactory.java 2008-10-29 12:57:57 UTC (rev 11283)
@@ -44,61 +44,69 @@
*/
public class TokenizerFactory {
+ private static ITokenDescription[] DEFAULT_DESCRIPTION_SET = new ITokenDescription[] {
+ ArgEndTokenDescription.INSTANCE,
+ ArgStartTokenDescription.INSTANCE,
+ DotTokenDescription.INSTANCE,
+ EndELTokenDescription.INSTANCE,
+ JavaNameTokenDescription.INSTANCE,
+ OperationTokenDescription.INSTANCE,
+ UnaryTokenDescription.INSTANCE,
+ PrimitiveValueTokenDescription.INSTANCE,
+ StartELTokenDescription.INSTANCE,
+ StringTokenDescription.INSTANCE,
+ WhiteSpaceTokenDescription.INSTANCE,
+ };
+
+ private static IRule[] DEFAULT_RULE_SET = new IRule[] {
+ ExpressionRule.INSTANCE,
+ CallRule.INSTANCE,
+ OperationRule.INSTANCE,
+ ErrorRecoveryRule.INSTANCE,
+ };
+
public static Tokenizer createDefaultTokenizer() {
Tokenizer t = new Tokenizer();
- t.setTokenDescriptions(new ITokenDescription[]{
- ArgEndTokenDescription.INSTANCE,
- ArgStartTokenDescription.INSTANCE,
- DotTokenDescription.INSTANCE,
- EndELTokenDescription.INSTANCE,
- JavaNameTokenDescription.INSTANCE,
- OperationTokenDescription.INSTANCE,
- UnaryTokenDescription.INSTANCE,
- PrimitiveValueTokenDescription.INSTANCE,
- StartELTokenDescription.INSTANCE,
- StringTokenDescription.INSTANCE,
- WhiteSpaceTokenDescription.INSTANCE,
- });
- t.setRules(new IRule[]{
- ExpressionRule.INSTANCE,
- CallRule.INSTANCE,
- OperationRule.INSTANCE,
- ErrorRecoveryRule.INSTANCE,
- });
+ t.setTokenDescriptions(DEFAULT_DESCRIPTION_SET);
+ t.setRules(DEFAULT_RULE_SET);
return t;
}
+ private static ITokenDescription[] JBOSS_DESCRIPTION_SET = new ITokenDescription[]{
+ ArgEndTokenDescription.INSTANCE,
+ ArgStartTokenDescription.INSTANCE,
+ CommaTokenDescription.INSTANCE,
+ DotTokenDescription.INSTANCE,
+ EndELTokenDescription.INSTANCE,
+ JavaNameTokenDescription.INSTANCE,
+ OperationTokenDescription.INSTANCE,
+ ParamEndTokenDescription.INSTANCE,
+ ParamStartTokenDescription.INSTANCE,
+ ExprStartTokenDescription.INSTANCE,
+ ExprEndTokenDescription.INSTANCE,
+ UnaryTokenDescription.INSTANCE,
+ PrimitiveValueTokenDescription.INSTANCE,
+ StartELTokenDescription.INSTANCE,
+ StringTokenDescription.INSTANCE,
+ WhiteSpaceTokenDescription.INSTANCE,
+ };
+
+ private static IRule[] JBOSS_RULE_SET = new IRule[] {
+ ExpressionRule.INSTANCE,
+ CallRule.INSTANCE,
+ OperationRule.INSTANCE,
+ ErrorRecoveryRule.INSTANCE,
+ };
+
public static Tokenizer createJbossTokenizer() {
Tokenizer t = new Tokenizer();
- t.setTokenDescriptions(new ITokenDescription[]{
- ArgEndTokenDescription.INSTANCE,
- ArgStartTokenDescription.INSTANCE,
- CommaTokenDescription.INSTANCE,
- DotTokenDescription.INSTANCE,
- EndELTokenDescription.INSTANCE,
- JavaNameTokenDescription.INSTANCE,
- OperationTokenDescription.INSTANCE,
- ParamEndTokenDescription.INSTANCE,
- ParamStartTokenDescription.INSTANCE,
- ExprStartTokenDescription.INSTANCE,
- ExprEndTokenDescription.INSTANCE,
- UnaryTokenDescription.INSTANCE,
- PrimitiveValueTokenDescription.INSTANCE,
- StartELTokenDescription.INSTANCE,
- StringTokenDescription.INSTANCE,
- WhiteSpaceTokenDescription.INSTANCE,
- });
- t.setRules(new IRule[]{
- ExpressionRule.INSTANCE,
- CallRule.INSTANCE,
- OperationRule.INSTANCE,
- ErrorRecoveryRule.INSTANCE,
- });
+ t.setTokenDescriptions(JBOSS_DESCRIPTION_SET);
+ t.setRules(JBOSS_RULE_SET);
return t;
}
public static void main(String[] args) {
- String text = "ioioio#{1.2e1}ioioio#{0}";
+ String text = "ioioio#{a(1.2e1i) + b c + d}ioioio#{0}";
//"#{a[b()['l'].j]}";
//"#{g11.g12.y13} #{#{ #{a14.b15(x.t.u(uu.ii[9], j)).b16(m17(v18(i19[2]).u20).)+ a21(c.).b.}";
//"#{not a.b(x,y) + s.h((6 != -8) & (7 + -iy88.g[9].h(7 div 8).i.j)+(8) ? 4 : 7,'p', a.b.c.d[null])}";
Modified: trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/Var.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/Var.java 2008-10-29 12:54:37 UTC (rev 11282)
+++ trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/Var.java 2008-10-29 12:57:57 UTC (rev 11283)
@@ -51,7 +51,7 @@
if(el.length()>3 && el.startsWith("#{") && el.endsWith("}")) {
ELParser parser = factory.createParser();
ELModel model = parser.parse(el);
- if(model == null || parser.getSyntaxErrors().size() > 0) return null;
+ if(model == null || model.getSyntaxErrors().size() > 0) return null;
List<ELInstance> is = model.getInstances();
if(is.size() == 0) return null;
return is.get(0).getExpression();
Modified: trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELModelImpl.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELModelImpl.java 2008-10-29 12:54:37 UTC (rev 11282)
+++ trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELModelImpl.java 2008-10-29 12:57:57 UTC (rev 11283)
@@ -24,6 +24,7 @@
*
*/
public class ELModelImpl extends ELObjectImpl implements ELModel {
+ List<SyntaxError> errors = null;
String source;
List<ELInstance> instances = new ArrayList<ELInstance>();
int delta = 0;
@@ -72,6 +73,7 @@
}
public void setErrors(List<SyntaxError> errors) {
+ this.errors = errors;
for (SyntaxError e: errors) {
for (ELInstance i: instances) {
ELInstanceImpl im = (ELInstanceImpl)i;
@@ -84,10 +86,15 @@
}
+ public List<SyntaxError> getSyntaxErrors() {
+ return errors;
+ }
+
public void shift(int delta) {
this.delta = delta;
if(instances.size() > 0) {
instances.get(0).getFirstToken().shift(delta);
}
}
+
}
Modified: trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/ELParserImpl.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/ELParserImpl.java 2008-10-29 12:54:37 UTC (rev 11282)
+++ trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/ELParserImpl.java 2008-10-29 12:57:57 UTC (rev 11283)
@@ -10,7 +10,6 @@
******************************************************************************/
package org.jboss.tools.common.el.internal.core.parser;
-import org.jboss.tools.common.el.core.model.ELObjectType;
import org.jboss.tools.common.el.core.parser.LexicalToken;
import org.jboss.tools.common.el.core.parser.Tokenizer;
import org.jboss.tools.common.el.internal.core.model.ELArgumentImpl;
@@ -49,30 +48,35 @@
*
*/
public class ELParserImpl {
- ELModelImpl model;
-
LexicalToken current;
public ELModelImpl parse(LexicalToken start) {
- model = new ELModelImpl();
- model.setFirstToken(start);
- current = start;
- while(current != null) {
- if(current.getType() == StartELTokenDescription.START_EL) {
- ELInstanceImpl instance = readELInstance();
- if(instance != null) {
- model.addInstance(instance);
- }
- } else if(!hasNextToken()) {
- break;
- } else {
- if(lookUpNextToken(current) == null) {
+ if(current != null) {
+ throw new RuntimeException("Cannot reuse parser while it is running.");
+ }
+ try {
+ ELModelImpl model = new ELModelImpl();
+ model.setFirstToken(start);
+ current = start;
+ while (current != null) {
+ if (current.getType() == StartELTokenDescription.START_EL) {
+ ELInstanceImpl instance = readELInstance();
+ if (instance != null) {
+ model.addInstance(instance);
+ }
+ } else if (!hasNextToken()) {
break;
+ } else {
+ if (lookUpNextToken(current) == null) {
+ break;
+ }
+ setNextToken();
}
- setNextToken();
}
+ return model;
+ } finally {
+ current = null;
}
- return model;
}
protected ELInstanceImpl readELInstance() {
16 years, 2 months
JBoss Tools SVN: r11282 - trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/actions.
by jbosstools-commits@lists.jboss.org
Author: vyemialyanchyk
Date: 2008-10-29 08:54:37 -0400 (Wed, 29 Oct 2008)
New Revision: 11282
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/actions/JPAMapToolActor.java
Log:
fix: menu disable with StructuredSelection
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/actions/JPAMapToolActor.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/actions/JPAMapToolActor.java 2008-10-29 12:54:18 UTC (rev 11281)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/actions/JPAMapToolActor.java 2008-10-29 12:54:37 UTC (rev 11282)
@@ -24,6 +24,7 @@
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IPackageFragmentRoot;
+import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.dom.AST;
@@ -73,13 +74,6 @@
}
return actor;
}
-
- protected org.eclipse.jdt.core.dom.CompilationUnit getCompilationUnit(ICompilationUnit source) {
- ASTParser parser = ASTParser.newParser(AST.JLS3);
- parser.setSource(source);
- org.eclipse.jdt.core.dom.CompilationUnit result = (org.eclipse.jdt.core.dom.CompilationUnit) parser.createAST(null);
- return result;
- }
public void clearSelectionCU() {
selectionCU.clear();
@@ -87,6 +81,15 @@
public void addCompilationUnit(ICompilationUnit cu) {
if (cu != null) {
+ IType[] types = null;
+ try {
+ types = cu.getTypes();
+ } catch (JavaModelException e) {
+ // just ignore it
+ }
+ if (types != null) {
+
+ }
selectionCU.add(cu);
}
}
@@ -96,6 +99,12 @@
updateSelectedItems(selection);
selection = null;
}
+ else {
+ if (selectionCU.size() == 0) {
+ updateOpen();
+ return;
+ }
+ }
if (selectionCU.size() == 0) {
processor.modify(null, new HashMap<String, EntityInfo>(), true);
return;
@@ -155,7 +164,8 @@
synchronized public int getSelectedSourceSize() {
int res = 0;
if (selection == null) {
- res = selectionCU.size();
+ //res = selectionCU.size();
+ res = 1;
}
else if (selection instanceof TextSelection) {
res = 1;
@@ -316,12 +326,14 @@
}
synchronized public void setSelection(ISelection selection) {
- if ((selection instanceof StructuredSelection) && selection.isEmpty()) {
- // just miss this selection
+ //System.out.println("Blah! " + selection); //$NON-NLS-1$
+ if (selection instanceof StructuredSelection) {
+ //System.out.println("This! " + this.selection); //$NON-NLS-1$
+ clearSelectionCU();
+ this.selection = null;
return;
}
this.selection = selection;
- //System.out.println("Blah! " + selection); //$NON-NLS-1$
}
}
16 years, 2 months