JBoss Tools SVN: r21613 - branches/jbosstools-3.1.x/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/contentassist.
by jbosstools-commits@lists.jboss.org
Author: vrubezhny
Date: 2010-04-22 10:51:31 -0400 (Thu, 22 Apr 2010)
New Revision: 21613
Modified:
branches/jbosstools-3.1.x/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/contentassist/SortingCompoundContentAssistProcessor.java
Log:
JBIDE-6039: CA calculation is too slow for tag attribute values
The proposals merge procedure is re-factored
Patch is applied in branch 3.1.x
Modified: branches/jbosstools-3.1.x/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/contentassist/SortingCompoundContentAssistProcessor.java
===================================================================
--- branches/jbosstools-3.1.x/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/contentassist/SortingCompoundContentAssistProcessor.java 2010-04-22 14:46:15 UTC (rev 21612)
+++ branches/jbosstools-3.1.x/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/contentassist/SortingCompoundContentAssistProcessor.java 2010-04-22 14:51:31 UTC (rev 21613)
@@ -32,7 +32,7 @@
import org.eclipse.swt.graphics.Image;
import org.eclipse.wst.sse.core.internal.provisional.IModelManager;
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.sse.core.internal.provisional.StructuredModelManager;
+import org.eclipse.wst.sse.core.StructuredModelManager;
import org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal;
import org.eclipse.wst.sse.ui.internal.contentassist.IRelevanceCompletionProposal;
import org.eclipse.wst.sse.ui.internal.util.Sorter;
@@ -46,6 +46,7 @@
*
*/
+@SuppressWarnings("restriction")
public class SortingCompoundContentAssistProcessor implements IContentAssistProcessor {
private ISourceViewer fSourceViewer;
private String fPartitionType;
@@ -148,6 +149,7 @@
}
}
+ @SuppressWarnings("unchecked")
boolean containsAnObjectOfTheSameType(Collection collection, Object obj) {
if (collection == null || obj == null)
return false;
@@ -229,7 +231,6 @@
return new ICompletionProposal[0];
}
-
for (IContentAssistProcessor p : processors) {
ICompletionProposal[] proposals = p.computeCompletionProposals(viewer, offset);
if (proposals != null && proposals.length > 0) {
@@ -244,12 +245,11 @@
}
}
}
-
ICompletionProposal[] resultArray = ret.toArray(new ICompletionProposal[ret.size()]);
Object[] sorted = createSorter().sort(resultArray);
System.arraycopy(sorted, 0, resultArray, 0, sorted.length);
resultArray = makeUnique(resultArray);
-
+
return resultArray;
}
@@ -260,37 +260,16 @@
* @return a list of unique completion suggestions.
*/
public ICompletionProposal[] makeUnique(ICompletionProposal[] proposals) {
- ArrayList<ICompletionProposal> unique = new ArrayList<ICompletionProposal>();
-
- for (int i = 0; proposals != null && i < proposals.length; i++) {
- if (proposals[i] == null)
+ if (proposals == null)
+ return null;
+
+ Map <String, ICompletionProposal> existingProposals = new HashMap<String, ICompletionProposal>(proposals.length);
+ ArrayList<ICompletionProposal> unique = new ArrayList<ICompletionProposal>(proposals.length);
+
+ for (ICompletionProposal proposal : proposals) {
+ if (proposal == null)
continue;
-
- ICompletionProposal existingProposal = findExistingProposal(unique, proposals[i]);
- if (existingProposal == null) {
- unique.add(proposals[i]);
- }
- }
- return unique.toArray(new ICompletionProposal[unique.size()]);
- }
- private ICompletionProposal findExistingProposal(
- List<ICompletionProposal> proposals, ICompletionProposal proposal) {
- if (proposals == null || proposal == null)
- return null;
-
- for (ICompletionProposal existingProposal : proposals) {
- String exReplString = null;
- String exDispString = null;
-
- if (existingProposal instanceof CustomCompletionProposal) {
- exReplString = ((CustomCompletionProposal) existingProposal)
- .getReplacementString();
- }
- exDispString = unQuote(existingProposal.getDisplayString());
- exReplString = getReplacementWord(exReplString == null ? exDispString
- : exReplString);
-
String replString = null;
String dispString = null;
@@ -301,19 +280,20 @@
dispString = unQuote(proposal.getDisplayString());
replString = getReplacementWord(replString == null ? dispString
: replString);
-
- if (exReplString != null && replString != null
- && exReplString.equals(replString))
- return existingProposal;
+
+ ICompletionProposal existingProposal = existingProposals.get(replString);
+ if (existingProposal == null) {
+ existingProposals.put(replString, proposal);
+ unique.add(proposal);
+ }
}
-
- return null;
+ return unique.toArray(new ICompletionProposal[unique.size()]);
}
private String getReplacementWord(String replacement) {
replacement = (replacement == null ? "" : //$NON-NLS-1$
replacement);
- int index = replacement.indexOf('>'); //$NON-NLS-1$
+ int index = replacement.indexOf('>');
if (index != -1) {
replacement = replacement.substring(0, index).trim();
if (replacement.endsWith("/")) //$NON-NLS-1$
@@ -422,6 +402,7 @@
* @return the auto activation characters for completion proposal or <code>null</code>
* if no auto activation is desired
*/
+ @SuppressWarnings("unchecked")
public char[] getCompletionProposalAutoActivationCharacters() {
String contentType = getContentType(fSourceViewer);
if (contentType == null)
@@ -480,7 +461,7 @@
char[] chars = new char[ret.size()];
int i = 0;
- for (Iterator it = ret.iterator(); it.hasNext(); i++) {
+ for (Iterator<Character> it = ret.iterator(); it.hasNext(); i++) {
Character ch = (Character) it.next();
chars[i] = ch.charValue();
}
@@ -508,14 +489,14 @@
public IContextInformationValidator getContextInformationValidator() {
boolean hasValidator = false;
boolean hasPresenter = false;
- boolean hasExtension = false;
+// boolean hasExtension = false;
String contentType = getContentType(fSourceViewer);
if (contentType == null)
return null;
- List<Character> ret = new LinkedList<Character>();
+// List<Character> ret = new LinkedList<Character>();
if (fProcessorsMap.get(contentType) == null)
return null;
@@ -618,7 +599,7 @@
}
private static class SortingCompoundContentAssistValidator implements IContextInformationValidator {
- List fValidators = new ArrayList();
+ List<IContextInformationValidator> fValidators = new ArrayList<IContextInformationValidator>();
IContextInformationValidator fValidator;
void add(IContextInformationValidator validator) {
@@ -636,7 +617,7 @@
if (fValidator != null)
fValidator.install(realInfo, viewer, documentPosition);
else {
- for (Iterator it = fValidators.iterator(); it.hasNext();) {
+ for (Iterator<IContextInformationValidator> it = fValidators.iterator(); it.hasNext();) {
IContextInformationValidator v = (IContextInformationValidator) it.next();
v.install(realInfo, viewer, documentPosition);
}
@@ -671,7 +652,7 @@
if (fValidator != null)
isValid = fValidator.isContextInformationValid(documentPosition);
else {
- for (Iterator it = fValidators.iterator(); it.hasNext();) {
+ for (Iterator<IContextInformationValidator> it = fValidators.iterator(); it.hasNext();) {
IContextInformationValidator v = (IContextInformationValidator) it.next();
isValid |= v.isContextInformationValid(documentPosition);
}
@@ -688,7 +669,7 @@
if (fValidator instanceof IContextInformationPresenter)
presentationUpdated = ((IContextInformationPresenter) fValidator).updatePresentation(offset, presentation);
else {
- for (Iterator it = fValidators.iterator(); it.hasNext();) {
+ for (Iterator<IContextInformationValidator> it = fValidators.iterator(); it.hasNext();) {
IContextInformationValidator v = (IContextInformationValidator) it.next();
if (v instanceof IContextInformationPresenter)
presentationUpdated |= ((IContextInformationPresenter) v).updatePresentation(offset, presentation);
14 years, 8 months
JBoss Tools SVN: r21612 - in branches/jbosstools-3.1.x: common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: vrubezhny
Date: 2010-04-22 10:46:15 -0400 (Thu, 22 Apr 2010)
New Revision: 21612
Added:
branches/jbosstools-3.1.x/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/ca/ELTextProposal.java
branches/jbosstools-3.1.x/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/AutoELContentAssistantProposal.java
Modified:
branches/jbosstools-3.1.x/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/ca/AbstractELCompletionEngine.java
branches/jbosstools-3.1.x/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/JavaMemberELSegment.java
branches/jbosstools-3.1.x/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/JavaMemberELSegmentImpl.java
branches/jbosstools-3.1.x/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/TypeInfoCollector.java
branches/jbosstools-3.1.x/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/FaceletPageContectAssistProcessor.java
branches/jbosstools-3.1.x/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/XmlContentAssistProcessor.java
Log:
JBIDE-6167: Move Proposal Info gathering for EL Proposals from resolve cycles to the proposal itself
The long-running Javadoc Info calculation operation is moved out of proposals gathering cycle
Patch is applied in branch 3.1.x
Modified: branches/jbosstools-3.1.x/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/ca/AbstractELCompletionEngine.java
===================================================================
--- branches/jbosstools-3.1.x/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/ca/AbstractELCompletionEngine.java 2010-04-22 14:33:41 UTC (rev 21611)
+++ branches/jbosstools-3.1.x/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/ca/AbstractELCompletionEngine.java 2010-04-22 14:46:15 UTC (rev 21612)
@@ -19,11 +19,9 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jdt.core.IMember;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.Signature;
-import org.eclipse.jdt.internal.ui.text.java.ProposalInfo;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.swt.graphics.Image;
@@ -61,7 +59,6 @@
import org.jboss.tools.common.text.TextProposal;
public abstract class AbstractELCompletionEngine<V extends IVariable> implements ELResolver, ELCompletionEngine {
-
public AbstractELCompletionEngine() {}
public abstract Image getELProposalImage();
@@ -251,6 +248,9 @@
: operand;
ELResolutionImpl resolution = resolveELOperand(file, newOperand, returnEqualedVariablesOnly, prefixWasChanged);
+ if(resolution==null) {
+ return null;
+ }
if(prefixWasChanged) {
resolution.setSourceOperand(operand);
@@ -296,12 +296,18 @@
var.resolveValue("#{" + var.getElToken().getText() + suffix + "}"); //$NON-NLS-1$ //$NON-NLS-2$
ELResolutionImpl oldElResolution = resolveELOperand(file, operand, returnEqualedVariablesOnly, false);
- resolution.getProposals().addAll(oldElResolution.getProposals());
+ if(oldElResolution!=null) {
+ resolution.getProposals().addAll(oldElResolution.getProposals());
+ }
} else {
resolution = resolveELOperand(file, operand, returnEqualedVariablesOnly, false);
}
}
+ if(resolution==null) {
+ return null;
+ }
+
// JBIDE-512, JBIDE-2541 related changes ===>>>
if(!returnEqualedVariablesOnly && vars!=null) {
@@ -310,10 +316,12 @@
if(v.getName().startsWith(prefix)) {
ELResolution r = resolveEL(file, v.getElToken(), true, vars, varSearcher);
ELSegment lastSegment = r.getLastSegment();
- MemberInfo memberInfo = null;
+ JavaMemberELSegment jmSegment = null;
+
if(lastSegment instanceof JavaMemberELSegment) {
- memberInfo = ((JavaMemberELSegment)lastSegment).getMemberInfo();
+ jmSegment = ((JavaMemberELSegment)lastSegment);
}
+ MemberInfo memberInfo = jmSegment == null ? null : jmSegment.getMemberInfo();
String sourceTypeName = memberInfo == null ? null : memberInfo.getDeclaringTypeQualifiedName();
if (sourceTypeName != null && sourceTypeName.indexOf('.') != -1) {
@@ -324,18 +332,21 @@
typeName = Signature.getSimpleName(typeName);
}
- IJavaElement element = memberInfo == null ? null : memberInfo.getJavaElement();
- String attachedJavaDoc = (element instanceof IMember)?(new ProposalInfo((IMember)element)).getInfo(null):null;
-
String varNameProposal = v.getName().substring(prefix.length());
- TextProposal proposal = new TextProposal();
+ ELTextProposal proposal = new ELTextProposal();
proposal.setLabel(v.getName());
proposal.setReplacementString(varNameProposal);
proposal.setLabel(v.getName());
proposal.setImage(getELProposalImage());
proposal.setType(typeName);
proposal.setSourceType(sourceTypeName);
- proposal.setContextInfo(attachedJavaDoc);
+ if (jmSegment != null) {
+ IJavaElement[] javaElements = jmSegment.getAllJavaElements();
+ for (int jeIndex = 0; javaElements != null && jeIndex < javaElements.length; jeIndex++) {
+ proposal.addJavaElement(javaElements[jeIndex]);
+ }
+ }
+
resolution.getProposals().add(proposal);
}
}
@@ -442,16 +453,17 @@
typeName = Signature.getSimpleName(typeName);
IJavaElement element = member == null ? null : member.getJavaElement();
- String attachedJavaDoc = (element instanceof IMember)?(new ProposalInfo((IMember)element)).getInfo(null):null;
- TextProposal proposal = new TextProposal();
+ ELTextProposal proposal = new ELTextProposal();
proposal.setLabel(varName);
proposal.setReplacementString(varName.substring(operand.getLength()));
setImage(proposal, var);
proposal.setType(typeName);
proposal.setSourceType(sourceTypeName);
- proposal.setContextInfo(attachedJavaDoc);
-
+ if (element != null) {
+ proposal.addJavaElement(element);
+ }
+
proposals.add(proposal);
// <<<=== JBIDE-512, JBIDE-2541 related changes
}
@@ -482,6 +494,7 @@
if(isSingularAttribute(var)) {
bijectedAttribute = getMemberInfoByVariable(var, true);
}
+
MemberInfo member = getMemberInfoByVariable(var, true);
String sourceTypeName = member == null ? null : member.getDeclaringTypeQualifiedName();
if (sourceTypeName != null && sourceTypeName.indexOf('.') != -1)
@@ -489,27 +502,33 @@
String typeName = member == null ? null : member.getType().getName();
if (typeName != null && typeName.indexOf('.') != -1)
typeName = Signature.getSimpleName(typeName);
+
IJavaElement element = member == null ? null : member.getJavaElement();
- String attachedJavaDoc = (element instanceof IMember)?(new ProposalInfo((IMember)element)).getInfo(null):null;
-
+
String varName = var.getName();
if(operand.getLength()<=varName.length()) {
- TextProposal proposal = new TextProposal();
+ ELTextProposal proposal = new ELTextProposal();
proposal.setReplacementString(varName.substring(operand.getLength()));
proposal.setLabel(varName);
setImage(proposal, var);
proposal.setType(typeName);
proposal.setSourceType(sourceTypeName);
- proposal.setContextInfo(attachedJavaDoc);
+ if (element != null) {
+ proposal.addJavaElement(element);
+ }
+
proposals.add(proposal);
} else if(returnEqualedVariablesOnly) {
- TextProposal proposal = new TextProposal();
+ ELTextProposal proposal = new ELTextProposal();
proposal.setReplacementString(varName);
proposal.setLabel(varName);
setImage(proposal, var);
proposal.setType(typeName);
proposal.setSourceType(sourceTypeName);
- proposal.setContextInfo(attachedJavaDoc);
+ if (element != null) {
+ proposal.addJavaElement(element);
+ }
+
proposals.add(proposal);
}
segment.setMemberInfo(bijectedAttribute!=null?bijectedAttribute:member);
@@ -707,16 +726,19 @@
String typeName = member == null ? null : member.getType().getName();
if (typeName != null && typeName.indexOf('.') != -1)
typeName = Signature.getSimpleName(typeName);
- IJavaElement element = member == null ? null : member.getJavaElement();
- String attachedJavaDoc = (element instanceof IMember)?(new ProposalInfo((IMember)element)).getInfo(null):null;
- TextProposal proposal = new TextProposal();
+ ELTextProposal proposal = new ELTextProposal();
proposal.setReplacementString(presentationString);
proposal.setLabel(presentationString);
proposal.setImage(getELProposalImage());
proposal.setType(typeName);
proposal.setSourceType(sourceTypeName);
- proposal.setContextInfo(attachedJavaDoc);
+ for (MemberInfo mi : presentation.getAllMembers()) {
+ IJavaElement element = mi.getJavaElement();
+ if (element != null) {
+ proposal.addJavaElement(element);
+ }
+ }
kbProposals.add(proposal);
}
@@ -749,17 +771,20 @@
String typeName = member == null ? null : member.getType().getName();
if (typeName != null && typeName.indexOf('.') != -1)
typeName = Signature.getSimpleName(typeName);
- IJavaElement element = member == null ? null : member.getJavaElement();
- String attachedJavaDoc = (element instanceof IMember)?(new ProposalInfo((IMember)element)).getInfo(null):null;
- TextProposal proposal = new TextProposal();
+ ELTextProposal proposal = new ELTextProposal();
proposal.setReplacementString(presentationString);
proposal.setLabel(presentationString);
proposal.setImage(getELProposalImage());
proposal.setType(typeName);
proposal.setSourceType(sourceTypeName);
- proposal.setContextInfo(attachedJavaDoc);
-
+ for (MemberInfo mi : presentation.getAllMembers()) {
+ IJavaElement element = mi.getJavaElement();
+ if (element != null) {
+ proposal.addJavaElement(element);
+ }
+ }
+
kbProposals.add(proposal);
}
}
@@ -788,13 +813,16 @@
proposalsToFilter.addAll(infos.getPropertyPresentations(segment.getUnpairedGettersOrSetters()));
// segment.setMemberInfo(mbr);
}
+
for (TypeInfoCollector.MemberPresentation proposal : proposalsToFilter) {
// We do expect nothing but name for method tokens (No round brackets)
String filter = expr.getMemberName();
if(filter == null) filter = ""; //$NON-NLS-1$
+ String presentationString = proposal.getPresentation();
+
if(returnEqualedVariablesOnly) {
// This is used for validation.
- if (proposal.getPresentation().equals(filter)) {
+ if (presentationString.equals(filter)) {
TextProposal kbProposal = new TextProposal();
kbProposal.setReplacementString(proposal.getPresentation());
@@ -803,6 +831,14 @@
kbProposals.add(kbProposal);
segment.setMemberInfo(proposal.getMember());
+ if (proposal.getAllMembers() != null && !proposal.getAllMembers().isEmpty()) {
+ for (MemberInfo mi : proposal.getAllMembers()) {
+ IJavaElement je = mi.getJavaElement();
+ if (je != null) {
+ segment.addJavaElement(je);
+ }
+ }
+ }
if(segment.getUnpairedGettersOrSetters()!=null) {
TypeInfoCollector.MethodInfo unpirMethod = segment.getUnpairedGettersOrSetters().get(filter);
segment.clearUnpairedGettersOrSetters();
@@ -812,7 +848,7 @@
}
break;
}
- } else if (proposal.getPresentation().startsWith(filter)) {
+ } else if (presentationString.startsWith(filter)) {
// JBIDE-512, JBIDE-2541 related changes ===>>>
// This is used for CA.
@@ -823,16 +859,19 @@
String typeName = member == null ? null : member.getType().getName();
if (typeName != null && typeName.indexOf('.') != -1)
typeName = Signature.getSimpleName(typeName);
- IJavaElement element = member == null ? null : member.getJavaElement();
- String attachedJavaDoc = (element instanceof IMember)?(new ProposalInfo((IMember)element)).getInfo(null):null;
- TextProposal kbProposal = new TextProposal();
+ ELTextProposal kbProposal = new ELTextProposal();
kbProposal.setReplacementString(proposal.getPresentation().substring(filter.length()));
kbProposal.setLabel(proposal.getPresentation());
kbProposal.setImage(getELProposalImage());
kbProposal.setType(typeName);
kbProposal.setSourceType(sourceTypeName);
- kbProposal.setContextInfo(attachedJavaDoc);
+ for (MemberInfo mi : proposal.getAllMembers()) {
+ IJavaElement element = mi.getJavaElement();
+ if (element != null) {
+ kbProposal.addJavaElement(element);
+ }
+ }
kbProposals.add(kbProposal);
// <<<=== JBIDE-512, JBIDE-2541 related changes
@@ -890,6 +929,16 @@
kbProposals.add(kbProposal);
segment.setMemberInfo(proposal.getMember());
+
+ if (proposal.getAllMembers() != null && !proposal.getAllMembers().isEmpty()) {
+ for (MemberInfo mi : proposal.getAllMembers()) {
+ IJavaElement je = mi.getJavaElement();
+ if (je != null) {
+ segment.addJavaElement(je);
+ }
+ }
+ }
+
if(segment.getUnpairedGettersOrSetters()!=null) {
TypeInfoCollector.MethodInfo unpirMethod = segment.getUnpairedGettersOrSetters().get(filter);
segment.clearUnpairedGettersOrSetters();
@@ -910,10 +959,8 @@
String typeName = member == null ? null : member.getType().getName();
if (typeName != null && typeName.indexOf('.') != -1)
typeName = Signature.getSimpleName(typeName);
- IJavaElement element = member == null ? null : member.getJavaElement();
- String attachedJavaDoc = (element instanceof IMember)?(new ProposalInfo((IMember)element)).getInfo(null):null;
- TextProposal kbProposal = new TextProposal();
+ ELTextProposal kbProposal = new ELTextProposal();
String replacementString = proposal.getPresentation().substring(filter.length());
if (bSurroundWithQuotes) {
@@ -924,7 +971,12 @@
kbProposal.setImage(getELProposalImage());
kbProposal.setType(typeName);
kbProposal.setSourceType(sourceTypeName);
- kbProposal.setContextInfo(attachedJavaDoc);
+ for (MemberInfo mi : proposal.getAllMembers()) {
+ IJavaElement element = mi.getJavaElement();
+ if (element != null) {
+ kbProposal.addJavaElement(element);
+ }
+ }
kbProposals.add(kbProposal);
// <<<=== JBIDE-512, JBIDE-2541 related changes
Added: branches/jbosstools-3.1.x/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/ca/ELTextProposal.java
===================================================================
--- branches/jbosstools-3.1.x/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/ca/ELTextProposal.java (rev 0)
+++ branches/jbosstools-3.1.x/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/ca/ELTextProposal.java 2010-04-22 14:46:15 UTC (rev 21612)
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.el.core.ca;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.jdt.core.IJavaElement;
+import org.jboss.tools.common.text.TextProposal;
+
+/**
+ * Class to store proposals generated by ELResolver implementers
+ *
+ * @author Victor Rubezhny
+ */
+public class ELTextProposal extends TextProposal {
+ private Set<IJavaElement> allElements;
+
+ /**
+ * Adds a Java Element for the proposal
+ *
+ * @param element
+ */
+ public void addJavaElement(IJavaElement element) {
+ if (this.allElements == null) {
+ this.allElements = new HashSet<IJavaElement>();
+ }
+ this.allElements.add(element);
+ }
+
+ /**
+ * returns all the Java elements for the proposal
+ * @return
+ */
+ public IJavaElement[] getAllJavaElements() {
+ if (this.allElements == null || this.allElements.size() == 0) {
+ return new IJavaElement[0];
+ }
+ return (IJavaElement[])this.allElements.toArray(new IJavaElement[this.allElements.size()]);
+ }
+}
Property changes on: branches/jbosstools-3.1.x/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/ca/ELTextProposal.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: branches/jbosstools-3.1.x/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/JavaMemberELSegment.java
===================================================================
--- branches/jbosstools-3.1.x/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/JavaMemberELSegment.java 2010-04-22 14:33:41 UTC (rev 21611)
+++ branches/jbosstools-3.1.x/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/JavaMemberELSegment.java 2010-04-22 14:46:15 UTC (rev 21612)
@@ -29,6 +29,13 @@
IJavaElement getJavaElement();
/**
+ * Returns the array of Java Elements collected for the segment
+ *
+ * @return The Array of collected Java Elements
+ */
+ IJavaElement[] getAllJavaElements();
+
+ /**
* @return true if an underlying object is field and this field has getter.
*/
boolean hasGetter();
Modified: branches/jbosstools-3.1.x/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/JavaMemberELSegmentImpl.java
===================================================================
--- branches/jbosstools-3.1.x/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/JavaMemberELSegmentImpl.java 2010-04-22 14:33:41 UTC (rev 21611)
+++ branches/jbosstools-3.1.x/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/JavaMemberELSegmentImpl.java 2010-04-22 14:46:15 UTC (rev 21612)
@@ -11,7 +11,9 @@
package org.jboss.tools.common.el.core.resolver;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Map;
+import java.util.Set;
import org.eclipse.jdt.core.IJavaElement;
import org.jboss.tools.common.el.core.resolver.TypeInfoCollector.MemberInfo;
@@ -22,6 +24,7 @@
public class JavaMemberELSegmentImpl extends ELSegmentImpl implements JavaMemberELSegment {
protected IJavaElement element;
+ protected Set<IJavaElement> allElements;
protected MemberInfo memberInfo;
protected boolean hasSetter;
protected boolean hasGetter;
@@ -66,6 +69,29 @@
}
/**
+ * Adds a Java Element for the Segment
+ *
+ * @param element
+ */
+ public void addJavaElement(IJavaElement element) {
+ if (this.allElements == null) {
+ this.allElements = new HashSet<IJavaElement>();
+ }
+ this.allElements.add(element);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.common.el.core.resolver.JavaMemberELSegment#getAllJavaElements()
+ */
+ public IJavaElement[] getAllJavaElements() {
+ if (this.allElements == null || this.allElements.size() == 0) {
+ return new IJavaElement[0];
+ }
+ return (IJavaElement[])this.allElements.toArray(new IJavaElement[this.allElements.size()]);
+ }
+
+ /**
* @return the hasSetter
*/
public boolean isHasSetter() {
Modified: branches/jbosstools-3.1.x/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/TypeInfoCollector.java
===================================================================
--- branches/jbosstools-3.1.x/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/TypeInfoCollector.java 2010-04-22 14:33:41 UTC (rev 21611)
+++ branches/jbosstools-3.1.x/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/TypeInfoCollector.java 2010-04-22 14:46:15 UTC (rev 21612)
@@ -38,7 +38,7 @@
/**
* This class helps to collect information of java elements used in Seam EL.
- * @author Viktor Rubezhny, Alexey Kazakov
+ * @author Victor Rubezhny, Alexey Kazakov
*/
public class TypeInfoCollector {
IType fType;
@@ -971,11 +971,13 @@
public static class MemberPresentation {
private String presentation;
private MemberInfo member;
+ private Set<MemberInfo> allMembers = new HashSet<MemberInfo>();
public MemberPresentation(String presentation, MemberInfo member) {
super();
this.presentation = presentation;
this.member = member;
+ addMember(member);
}
public String getPresentation() {
@@ -1003,6 +1005,28 @@
public String toString() {
return presentation;
}
+
+ /**
+ * Adds a pair member to the member info
+ * In case of a property there may be up to 2 members added: getter and setter
+ * In case of a method there will be a single member added (the method itself)
+ *
+ * @param pair
+ */
+ public void addMember(MemberInfo pair) {
+ this.allMembers.add(pair);
+ }
+
+ /**
+ * Returns all the members collected
+ * In case of a property there may be up to 2 members returned: getter and setter
+ * In case of a method there will be a single member returned (the method itself)
+ *
+ * @return
+ */
+ public Set<MemberInfo> getAllMembers() {
+ return allMembers;
+ }
}
private static class MemberPresentationComparator implements Comparator<MemberPresentation> {
@@ -1138,6 +1162,7 @@
*/
public Set<MemberPresentation> getPropertyPresentations(Map<String, MethodInfo> unpairedGettersOrSetters) {
Set<MemberPresentation> properties = new TreeSet<MemberPresentation>(MEMBER_PRESENTATION_COMPARATOR);
+ HashMap<String, MemberPresentation> presentations = new HashMap<String, MemberPresentation>();
List<MemberInfo> props = getProperties();
HashMap<String, MethodInfo> getters = new HashMap<String, MethodInfo>();
HashMap<String, MethodInfo> setters = new HashMap<String, MethodInfo>();
@@ -1159,6 +1184,10 @@
MemberPresentation pr = new MemberPresentation(propertyName, m);
if(!properties.contains(pr)) {
properties.add(pr);
+ presentations.put(pr.getPresentation(), pr);
+ } else {
+ MemberPresentation existingPresentation = presentations.get(pr.getPresentation());
+ existingPresentation.addMember(m);
}
if(unpairedGettersOrSetters!=null) {
MethodInfo previousGetter = getters.get(propertyName);
@@ -1176,7 +1205,9 @@
}
}
} else {
- properties.add(new MemberPresentation(info.getName(), info));
+ MemberPresentation pr = new MemberPresentation(info.getName(), info);
+ properties.add(pr);
+ presentations.put(pr.getPresentation(), pr);
}
}
return properties;
Added: branches/jbosstools-3.1.x/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/AutoELContentAssistantProposal.java
===================================================================
--- branches/jbosstools-3.1.x/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/AutoELContentAssistantProposal.java (rev 0)
+++ branches/jbosstools-3.1.x/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/AutoELContentAssistantProposal.java 2010-04-22 14:46:15 UTC (rev 21612)
@@ -0,0 +1,183 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.jsp.contentassist;
+
+import java.io.Reader;
+import java.io.StringReader;
+
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IMember;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.internal.ui.JavaPlugin;
+import org.eclipse.jdt.internal.ui.text.javadoc.JavadocContentAccess2;
+import org.eclipse.jdt.internal.ui.viewsupport.JavaElementLinks;
+import org.eclipse.jdt.ui.JavaElementLabels;
+import org.eclipse.jface.internal.text.html.HTMLPrinter;
+import org.eclipse.jface.text.contentassist.IContextInformation;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * Class to provide EL proposals to Content Assistant.
+ * The main purpose is to provide correct additional proposal information based on
+ * IJavaElement objects collected for the proposal.
+ *
+ * @author Victor Rubezhny
+ */
+@SuppressWarnings("restriction")
+public class AutoELContentAssistantProposal extends AutoContentAssistantProposal {
+ private IJavaElement[] fJavaElements;
+ private String fAdditionalProposalInfo;
+
+ /**
+ * Constructs the proposal object
+ *
+ * @param replacementString
+ * @param replacementOffset
+ * @param replacementLength
+ * @param cursorPosition
+ * @param image
+ * @param displayString
+ * @param contextInformation
+ * @param elements
+ * @param relevance
+ */
+ public AutoELContentAssistantProposal(String replacementString, int replacementOffset, int replacementLength, int cursorPosition, Image image, String displayString, IContextInformation contextInformation, IJavaElement[] elements, int relevance) {
+ super(replacementString, replacementOffset, replacementLength, cursorPosition, image, displayString, contextInformation, null, relevance);
+ this.fJavaElements = elements;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal#getAdditionalProposalInfo()
+ */
+ public String getAdditionalProposalInfo() {
+ if (fAdditionalProposalInfo == null) {
+ if (this.fJavaElements != null && this.fJavaElements.length > 0) {
+ this.fAdditionalProposalInfo = extractProposalContextInfo(fJavaElements);
+ }
+ }
+ return fAdditionalProposalInfo;
+ }
+
+ /*
+ * Extracts the additional proposal information based on Javadoc for the stored IJavaElement objects
+ */
+ private String extractProposalContextInfo(IJavaElement[] elements) {
+ int nResults= elements.length;
+ StringBuffer buffer= new StringBuffer();
+ boolean hasContents= false;
+ IJavaElement element= null;
+
+ if (nResults > 1) {
+ for (int i= 0; i < elements.length; i++) {
+ if (elements[i] == null) continue;
+ if (elements[i] instanceof IMember ||
+ elements[i].getElementType() == IJavaElement.LOCAL_VARIABLE ||
+ elements[i].getElementType() == IJavaElement.TYPE_PARAMETER) {
+ buffer.append('�').append(' ').append(getInfoText(elements[i]));
+ hasContents= true;
+ }
+ buffer.append("<br/>"); //$NON-NLS-1$
+ }
+
+ for (int i=0; i < elements.length; i++) {
+ if (elements[i] == null) continue;
+ if (elements[i] instanceof IMember ||
+ elements[i].getElementType() == IJavaElement.LOCAL_VARIABLE ||
+ elements[i].getElementType() == IJavaElement.TYPE_PARAMETER) {
+ buffer.append("<br/>"); //$NON-NLS-1$
+ addFullInfo(buffer, elements[i]);
+ hasContents = true;
+ }
+ }
+ } else {
+ element= elements[0];
+ if (element instanceof IMember ||
+ element.getElementType() == IJavaElement.LOCAL_VARIABLE ||
+ element.getElementType() == IJavaElement.TYPE_PARAMETER) {
+ addFullInfo(buffer, element);
+ hasContents= true;
+ }
+ }
+
+ if (!hasContents)
+ return null;
+
+ if (buffer.length() > 0) {
+ HTMLPrinter.insertPageProlog(buffer, 0, (String)null);
+ HTMLPrinter.addPageEpilog(buffer);
+ return buffer.toString();
+ }
+
+ return null;
+ }
+
+ private static final long LABEL_FLAGS= JavaElementLabels.ALL_FULLY_QUALIFIED
+ | JavaElementLabels.M_PRE_RETURNTYPE | JavaElementLabels.M_PARAMETER_TYPES | JavaElementLabels.M_PARAMETER_NAMES | JavaElementLabels.M_EXCEPTIONS
+ | JavaElementLabels.F_PRE_TYPE_SIGNATURE | JavaElementLabels.M_PRE_TYPE_PARAMETERS | JavaElementLabels.T_TYPE_PARAMETERS
+ | JavaElementLabels.USE_RESOLVED;
+ private static final long LOCAL_VARIABLE_FLAGS= LABEL_FLAGS & ~JavaElementLabels.F_FULLY_QUALIFIED | JavaElementLabels.F_POST_QUALIFIED;
+ private static final long TYPE_PARAMETER_FLAGS= LABEL_FLAGS | JavaElementLabels.TP_POST_QUALIFIED;
+
+ /*
+ * Returns the label for the IJavaElement objects
+ */
+ private String getInfoText(IJavaElement element) {
+ long flags;
+ switch (element.getElementType()) {
+ case IJavaElement.LOCAL_VARIABLE:
+ flags= LOCAL_VARIABLE_FLAGS;
+ break;
+ case IJavaElement.TYPE_PARAMETER:
+ flags= TYPE_PARAMETER_FLAGS;
+ break;
+ default:
+ flags= LABEL_FLAGS;
+ break;
+ }
+ StringBuffer label= new StringBuffer(JavaElementLinks.getElementLabel(element, flags));
+
+ StringBuffer buf= new StringBuffer();
+ buf.append("<span style='word-wrap:break-word;'>"); //$NON-NLS-1$
+ buf.append(label);
+ buf.append("</span>"); //$NON-NLS-1$
+
+ return buf.toString();
+ }
+
+ /*
+ * Adds full information to the additional proposal information
+ *
+ * @param buffer
+ * @param element
+ * @return
+ */
+ private void addFullInfo(StringBuffer buffer, IJavaElement element) {
+ if (element instanceof IMember) {
+ IMember member= (IMember) element;
+ HTMLPrinter.addSmallHeader(buffer, getInfoText(member));
+ Reader reader = null;
+ try {
+ String content= JavadocContentAccess2.getHTMLContent(member, true);
+ reader= content == null ? null : new StringReader(content);
+ } catch (JavaModelException ex) {
+ JavaPlugin.log(ex);
+ }
+
+ if (reader != null) {
+ HTMLPrinter.addParagraph(buffer, reader);
+ }
+
+ } else if (element.getElementType() == IJavaElement.LOCAL_VARIABLE || element.getElementType() == IJavaElement.TYPE_PARAMETER) {
+ HTMLPrinter.addSmallHeader(buffer, getInfoText(element));
+ }
+ }
+}
Property changes on: branches/jbosstools-3.1.x/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/AutoELContentAssistantProposal.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: branches/jbosstools-3.1.x/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/FaceletPageContectAssistProcessor.java
===================================================================
--- branches/jbosstools-3.1.x/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/FaceletPageContectAssistProcessor.java 2010-04-22 14:33:41 UTC (rev 21611)
+++ branches/jbosstools-3.1.x/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/FaceletPageContectAssistProcessor.java 2010-04-22 14:46:15 UTC (rev 21612)
@@ -10,9 +10,10 @@
******************************************************************************/
package org.jboss.tools.jst.jsp.contentassist;
-import org.eclipse.jface.text.contentassist.IContextInformation;
+import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.swt.graphics.Image;
import org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest;
+import org.jboss.tools.common.el.core.ca.ELTextProposal;
import org.jboss.tools.common.el.core.resolver.ELContext;
import org.jboss.tools.common.text.TextProposal;
import org.jboss.tools.jst.jsp.messages.JstUIMessages;
@@ -105,10 +106,10 @@
KbQuery kbQuery = createKbQuery(Type.TEXT, query, stringQuery);
TextProposal[] proposals = PageProcessor.getInstance().getProposals(kbQuery, getContext());
-
- for (int i = 0; proposals != null && i < proposals.length; i++) {
- TextProposal textProposal = proposals[i];
-
+ if (proposals == null || proposals.length == 0)
+ return;
+
+ for (TextProposal textProposal : proposals) {
int replacementOffset = beginChangeOffset;
int replacementLength = prefix.getLength();
String replacementString = prefix.getText().substring(0, replacementLength) + textProposal.getReplacementString();
@@ -127,17 +128,26 @@
displayString = textProposal.getReplacementString() == null ? replacementString : textProposal.getReplacementString();
// <<<=== JBIDE-512, JBIDE-2541 related changes
- IContextInformation contextInformation = null;
- String additionalProposalInfo = textProposal.getContextInfo();
int relevance = textProposal.getRelevance();
if (relevance == TextProposal.R_NONE) {
relevance = TextProposal.R_JSP_JSF_EL_VARIABLE_ATTRIBUTE_VALUE;
}
- AutoContentAssistantProposal proposal = new AutoContentAssistantProposal(replacementString,
- replacementOffset, replacementLength, cursorPosition, image, displayString,
- contextInformation, additionalProposalInfo, relevance);
+ AutoContentAssistantProposal proposal = null;
+ if (textProposal instanceof ELTextProposal) {
+ IJavaElement[] javaElements = ((ELTextProposal)textProposal).getAllJavaElements();
+
+ proposal = new AutoELContentAssistantProposal(replacementString,
+ replacementOffset, replacementLength, cursorPosition, image, displayString,
+ null, javaElements, relevance);
+ } else {
+ String additionalProposalInfo = (textProposal.getContextInfo() == null ? "" : textProposal.getContextInfo()); //$NON-NLS-1$
+ proposal = new AutoContentAssistantProposal(replacementString,
+ replacementOffset, replacementLength, cursorPosition, image, displayString,
+ null, additionalProposalInfo, relevance);
+ }
+
contentAssistRequest.addProposal(proposal);
}
@@ -157,9 +167,11 @@
protected void addAttributeNameProposals(
ContentAssistRequest contentAssistRequest) {
super.addAttributeNameProposals(contentAssistRequest);
- this.replaceJsfcTags = true;
- super.addAttributeNameProposals(contentAssistRequest);
- this.replaceJsfcTags = false;
+ if (isExistingAttribute(JSFC_ATTRIBUTE_NAME)) {
+ this.replaceJsfcTags = true;
+ super.addAttributeNameProposals(contentAssistRequest);
+ this.replaceJsfcTags = false;
+ }
}
/*
@@ -169,9 +181,11 @@
@Override
protected void addAttributeValueProposals(ContentAssistRequest contentAssistRequest) {
super.addAttributeValueProposals(contentAssistRequest);
- this.replaceJsfcTags = true;
- super.addAttributeValueProposals(contentAssistRequest);
- this.replaceJsfcTags = false;
+ if (isExistingAttribute(JSFC_ATTRIBUTE_NAME)) {
+ this.replaceJsfcTags = true;
+ super.addAttributeValueProposals(contentAssistRequest);
+ this.replaceJsfcTags = false;
+ }
}
/*
Modified: branches/jbosstools-3.1.x/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/XmlContentAssistProcessor.java
===================================================================
--- branches/jbosstools-3.1.x/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/XmlContentAssistProcessor.java 2010-04-22 14:33:41 UTC (rev 21611)
+++ branches/jbosstools-3.1.x/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/XmlContentAssistProcessor.java 2010-04-22 14:46:15 UTC (rev 21612)
@@ -13,14 +13,14 @@
import java.util.List;
import java.util.Map;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jface.text.contentassist.IContextInformation;
import org.eclipse.swt.graphics.Image;
import org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest;
import org.eclipse.wst.xml.ui.internal.contentassist.XMLRelevanceConstants;
import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImageHelper;
import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImages;
+import org.jboss.tools.common.el.core.ca.ELTextProposal;
import org.jboss.tools.common.el.core.resolver.ELContext;
import org.jboss.tools.common.el.core.resolver.ELResolver;
import org.jboss.tools.common.text.TextProposal;
@@ -286,7 +286,7 @@
contentAssistRequest.addProposal(proposal);
}
-
+
addELPredicateProposals(contentAssistRequest, TextProposal.R_JSP_ATTRIBUTE_VALUE, false);
}
@@ -317,13 +317,14 @@
}
int beginChangeOffset = prefix.getStartOffset() + prefix.getOffset();
-
+
KbQuery kbQuery = createKbQuery(Type.ATTRIBUTE_VALUE, query, stringQuery);
TextProposal[] proposals = PageProcessor.getInstance().getProposals(kbQuery, getContext());
- for (int i = 0; proposals != null && i < proposals.length; i++) {
- TextProposal textProposal = proposals[i];
-
+ if (proposals == null || proposals.length == 0)
+ return;
+
+ for (TextProposal textProposal : proposals) {
int replacementOffset = beginChangeOffset;
int replacementLength = prefix.getLength();
String replacementString = "#{" + prefix.getText().substring(0, replacementLength) + textProposal.getReplacementString(); //$NON-NLS-1$
@@ -348,23 +349,30 @@
displayString = textProposal.getReplacementString() == null ? replacementString : textProposal.getReplacementString();
// <<<=== JBIDE-512, JBIDE-2541 related changes
- IContextInformation contextInformation = null;
- String additionalProposalInfo = (textProposal.getContextInfo() == null ? "" : textProposal.getContextInfo()); //$NON-NLS-1$
int relevance = textProposal.getRelevance();
if (relevance == TextProposal.R_NONE) {
relevance = baseRelevance;
}
relevance += relevanceShift;
- AutoContentAssistantProposal proposal = new AutoContentAssistantProposal(replacementString,
- replacementOffset, replacementLength, cursorPosition, image, displayString,
- contextInformation, additionalProposalInfo, relevance);
+ AutoContentAssistantProposal proposal = null;
+ if (textProposal instanceof ELTextProposal) {
+ IJavaElement[] javaElements = ((ELTextProposal)textProposal).getAllJavaElements();
+
+ proposal = new AutoELContentAssistantProposal(replacementString,
+ replacementOffset, replacementLength, cursorPosition, image, displayString,
+ null, javaElements, relevance);
+ } else {
+ String additionalProposalInfo = (textProposal.getContextInfo() == null ? "" : textProposal.getContextInfo()); //$NON-NLS-1$
+ proposal = new AutoContentAssistantProposal(replacementString,
+ replacementOffset, replacementLength, cursorPosition, image, displayString,
+ null, additionalProposalInfo, relevance);
+ }
contentAssistRequest.addProposal(proposal);
}
}
-
@Override
protected void addAttributeValueELProposals(ContentAssistRequest contentAssistRequest) {
if (!isELCAToBeShown())
@@ -394,10 +402,11 @@
KbQuery kbQuery = createKbQuery(Type.ATTRIBUTE_VALUE, query, stringQuery);
TextProposal[] proposals = PageProcessor.getInstance().getProposals(kbQuery, getContext());
-
- for (int i = 0; proposals != null && i < proposals.length; i++) {
- TextProposal textProposal = proposals[i];
-
+
+ if (proposals == null || proposals.length == 0)
+ return;
+
+ for (TextProposal textProposal : proposals) {
int replacementOffset = beginChangeOffset;
int replacementLength = prefix.getLength();
String replacementString = prefix.getText().substring(0, replacementLength) + textProposal.getReplacementString();
@@ -425,17 +434,25 @@
displayString = textProposal.getReplacementString() == null ? replacementString : textProposal.getReplacementString();
// <<<=== JBIDE-512, JBIDE-2541 related changes
- IContextInformation contextInformation = null;
- String additionalProposalInfo = (textProposal.getContextInfo() == null ? "" : textProposal.getContextInfo()); //$NON-NLS-1$
int relevance = textProposal.getRelevance();
if (relevance == TextProposal.R_NONE) {
relevance = TextProposal.R_JSP_JSF_EL_VARIABLE_ATTRIBUTE_VALUE;
}
- AutoContentAssistantProposal proposal = new AutoContentAssistantProposal(replacementString,
- replacementOffset, replacementLength, cursorPosition, image, displayString,
- contextInformation, additionalProposalInfo, relevance);
+ AutoContentAssistantProposal proposal = null;
+ if (textProposal instanceof ELTextProposal) {
+ IJavaElement[] javaElements = ((ELTextProposal)textProposal).getAllJavaElements();
+
+ proposal = new AutoELContentAssistantProposal(replacementString,
+ replacementOffset, replacementLength, cursorPosition, image, displayString,
+ null, javaElements, relevance);
+ } else {
+ String additionalProposalInfo = (textProposal.getContextInfo() == null ? "" : textProposal.getContextInfo()); //$NON-NLS-1$
+ proposal = new AutoContentAssistantProposal(replacementString,
+ replacementOffset, replacementLength, cursorPosition, image, displayString,
+ null, additionalProposalInfo, relevance);
+ }
contentAssistRequest.addProposal(proposal);
}
@@ -475,9 +492,10 @@
KbQuery kbQuery = createKbQuery(Type.TEXT, query, stringQuery);
TextProposal[] proposals = PageProcessor.getInstance().getProposals(kbQuery, getContext());
- for (int i = 0; proposals != null && i < proposals.length; i++) {
- TextProposal textProposal = proposals[i];
-
+ if (proposals == null || proposals.length == 0)
+ return;
+
+ for (TextProposal textProposal : proposals) {
int replacementOffset = beginChangeOffset;
int replacementLength = prefix.getLength();
String replacementString = prefix.getText().substring(0, replacementLength) + textProposal.getReplacementString();
@@ -496,17 +514,25 @@
displayString = textProposal.getReplacementString() == null ? replacementString : textProposal.getReplacementString();
// <<<=== JBIDE-512, JBIDE-2541 related changes
- IContextInformation contextInformation = null;
- String additionalProposalInfo = textProposal.getContextInfo();
int relevance = textProposal.getRelevance();
if (relevance == TextProposal.R_NONE) {
relevance = TextProposal.R_JSP_JSF_EL_VARIABLE_ATTRIBUTE_VALUE;
}
- AutoContentAssistantProposal proposal = new AutoContentAssistantProposal(replacementString,
- replacementOffset, replacementLength, cursorPosition, image, displayString,
- contextInformation, additionalProposalInfo, relevance);
+ AutoContentAssistantProposal proposal = null;
+ if (textProposal instanceof ELTextProposal) {
+ IJavaElement[] javaElements = ((ELTextProposal)textProposal).getAllJavaElements();
+
+ proposal = new AutoELContentAssistantProposal(replacementString,
+ replacementOffset, replacementLength, cursorPosition, image, displayString,
+ null, javaElements, relevance);
+ } else {
+ String additionalProposalInfo = (textProposal.getContextInfo() == null ? "" : textProposal.getContextInfo()); //$NON-NLS-1$
+ proposal = new AutoContentAssistantProposal(replacementString,
+ replacementOffset, replacementLength, cursorPosition, image, displayString,
+ null, additionalProposalInfo, relevance);
+ }
contentAssistRequest.addProposal(proposal);
}
14 years, 8 months
JBoss Tools SVN: r21611 - branches/modular_build.
by jbosstools-commits@lists.jboss.org
Author: nickboldt
Date: 2010-04-22 10:33:41 -0400 (Thu, 22 Apr 2010)
New Revision: 21611
Modified:
branches/modular_build/build.xml
Log:
https://jira.jboss.org/jira/browse/JBQA-3313 Use static, shared space outside workspace, instead of working directly in the workspace
Modified: branches/modular_build/build.xml
===================================================================
--- branches/modular_build/build.xml 2010-04-22 14:22:46 UTC (rev 21610)
+++ branches/modular_build/build.xml 2010-04-22 14:33:41 UTC (rev 21611)
@@ -4,7 +4,9 @@
<!-- Configuration Start -->
<!-- must set name of component to build/test -->
<!-- <property name="COMPONENTS" value="tests,common" /> -->
- <property name="COMPONENTS" value="tests, common, flow, jbpm, jmx, archives, as, drools, bpel, smooks, freemarker, profiler, portlet, xulrunner, jst, vpe, jsf, esb, tptp, ws, cdi, struts, seam, examples, birt, maven, hibernatetools" />
+ <property name="COMPONENTS"
+ value="tests, common, flow, jbpm, jmx, archives, as, drools, bpel, smooks, freemarker, profiler, portlet, xulrunner, jst, vpe, jsf, esb, tptp, ws, cdi, struts, seam, examples, birt, maven, hibernatetools"
+ />
<!-- default maven version -->
<property name="maven.version" value="3.0-alpha-7" />
@@ -20,7 +22,7 @@
-->
<target name="run" depends="init, genpoms, install" />
-
+
<!-- override for local build -->
<condition property="isInHudson" value="true">
<or>
@@ -55,7 +57,13 @@
<target name="init" depends="local">
<property name="WORKINGDIR" value="${basedir}" />
- <property name="COMMON_TOOLS" value="${WORKINGDIR}/../tools" />
+ <!-- https://jira.jboss.org/jira/browse/JBQA-3313 Use static, shared space outside workspace, instead of working directly in the workspace -->
+ <condition property="COMMON_TOOLS"
+ value="/home/hudson/static_build_env/jbds/tools"
+ else="${WORKINGDIR}/../tools"
+ >
+ <available file="/home/hudson/static_build_env/jbds" type="dir" />
+ </condition>
<mkdir dir="${COMMON_TOOLS}" />
<available file="${COMMON_TOOLS}/ant-contrib.jar" type="file" property="ant-contrib.jar.exists" />
14 years, 8 months
JBoss Tools SVN: r21610 - branches/modular_build.
by jbosstools-commits@lists.jboss.org
Author: nickboldt
Date: 2010-04-22 10:22:46 -0400 (Thu, 22 Apr 2010)
New Revision: 21610
Modified:
branches/modular_build/genpom.xml
Log:
exclude sampleprojects/ dir from hibernatetools build
Modified: branches/modular_build/genpom.xml
===================================================================
--- branches/modular_build/genpom.xml 2010-04-22 14:08:20 UTC (rev 21609)
+++ branches/modular_build/genpom.xml 2010-04-22 14:22:46 UTC (rev 21610)
@@ -5,7 +5,7 @@
<property name="COMPONENT" value="trunk" />
<property name="pomVersion" value="0.0.1-SNAPSHOT" />
<property name="dirsToExclude"
- value="**/*.sdk.*, **/doc*, **/download.jboss.org, **/util/**, **/test, **/builders, **/contrib, **/releng/**, ."
+ value="**/*.sdk.*, **/doc*, **/download.jboss.org, **/sampleprojects/**, **/util/**, **/test, **/builders, **/contrib, **/releng/**, ."
/>
<property name="overwrite.existing.pom.xml" value="false" />
<!-- Configuration Ends -->
14 years, 8 months
JBoss Tools SVN: r21609 - in branches/jbosstools-3.1.x: jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/WebContent/pages/JBIDE/5985 and 3 other directories.
by jbosstools-commits@lists.jboss.org
Author: mareshkau
Date: 2010-04-22 10:08:20 -0400 (Thu, 22 Apr 2010)
New Revision: 21609
Added:
branches/jbosstools-3.1.x/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/WebContent/pages/JBIDE/5985/
branches/jbosstools-3.1.x/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/WebContent/pages/JBIDE/5985/testFacesContextResolution.jsp
branches/jbosstools-3.1.x/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/WebContent/pages/JBIDE/5985/testFacesContextResolution.jsp.xml
branches/jbosstools-3.1.x/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/TestContextPathResolution.java
Modified:
branches/jbosstools-3.1.x/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionHref.java
branches/jbosstools-3.1.x/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionSrc.java
branches/jbosstools-3.1.x/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ElService.java
branches/jbosstools-3.1.x/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/Jsf2ResourceUtil.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-5985 patch for 3.1.1
Added: branches/jbosstools-3.1.x/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/WebContent/pages/JBIDE/5985/testFacesContextResolution.jsp
===================================================================
--- branches/jbosstools-3.1.x/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/WebContent/pages/JBIDE/5985/testFacesContextResolution.jsp (rev 0)
+++ branches/jbosstools-3.1.x/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/WebContent/pages/JBIDE/5985/testFacesContextResolution.jsp 2010-04-22 14:08:20 UTC (rev 21609)
@@ -0,0 +1,16 @@
+<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
+<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
+
+<f:loadBundle var="Message" basename="demo.Messages"/>
+
+<html>
+ <head>
+ <title>Input User Name Page</title>
+ </head>
+ <body>
+ <f:view id="jbide-5985">
+ <h:graphicImage value="#{facesContext.externalContext.requestContextPath}/resources/img/img.gif"></h:graphicImage>
+ <img src="#{facesContext.externalContext.requestContextPath}/resources/img/img.gif"/>
+ </f:view>
+ </body>
+</html>
Added: branches/jbosstools-3.1.x/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/WebContent/pages/JBIDE/5985/testFacesContextResolution.jsp.xml
===================================================================
--- branches/jbosstools-3.1.x/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/WebContent/pages/JBIDE/5985/testFacesContextResolution.jsp.xml (rev 0)
+++ branches/jbosstools-3.1.x/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/WebContent/pages/JBIDE/5985/testFacesContextResolution.jsp.xml 2010-04-22 14:08:20 UTC (rev 21609)
@@ -0,0 +1,14 @@
+<tests>
+<test id="jbide-5985">
+<TABLE STYLE="border: 1px dotted rgb(255, 102, 0); padding: 5px; width: 100%;">
+<TR>
+<TD>
+<DIV>
+<IMG SRC="/.*jsf2test/WebContent/resources/img/img.gif/" STYLE="-moz-user-modify: read-write;"/>
+<IMG SRC="/.*jsf2test/WebContent/resources/img/img.gif/"/>
+</DIV>
+</TD>
+</TR>
+</TABLE>
+</test>
+</tests>
Added: branches/jbosstools-3.1.x/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/TestContextPathResolution.java
===================================================================
--- branches/jbosstools-3.1.x/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/TestContextPathResolution.java (rev 0)
+++ branches/jbosstools-3.1.x/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/TestContextPathResolution.java 2010-04-22 14:08:20 UTC (rev 21609)
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jsf.vpe.jsf.test.jbide;
+
+import org.jboss.tools.jsf.vpe.jsf.test.JsfAllTests;
+import org.jboss.tools.vpe.ui.test.ComponentContentTest;
+
+/**
+ * https://jira.jboss.org/jira/browse/JBIDE-5985
+ *
+ * @author mareshkau
+ *
+ */
+public class TestContextPathResolution extends ComponentContentTest{
+
+ public TestContextPathResolution(String name) {
+ super(name);
+ }
+
+ public void testContextPathResolution() throws Throwable{
+ performContentTest("JBIDE/5985/testFacesContextResolution.jsp"); //$NON-NLS-1$
+ }
+
+ @Override
+ protected String getTestProjectName() {
+ return JsfAllTests.IMPORT_JSF_20_PROJECT_NAME;
+ }
+}
Modified: branches/jbosstools-3.1.x/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionHref.java
===================================================================
--- branches/jbosstools-3.1.x/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionHref.java 2010-04-22 13:02:29 UTC (rev 21608)
+++ branches/jbosstools-3.1.x/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionHref.java 2010-04-22 14:08:20 UTC (rev 21609)
@@ -36,7 +36,7 @@
public VpeValue exec(VpePageContext pageContext, Node sourceNode) throws VpeExpressionException {
String tagValue = getParameter(0).exec(pageContext, sourceNode).stringValue();
- tagValue = resolveEL(pageContext,tagValue);
+ //tagValue = resolveEL(pageContext,tagValue);
IPath tagPath = new Path(tagValue);
if (tagPath.isEmpty()) {
Modified: branches/jbosstools-3.1.x/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionSrc.java
===================================================================
--- branches/jbosstools-3.1.x/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionSrc.java 2010-04-22 13:02:29 UTC (rev 21608)
+++ branches/jbosstools-3.1.x/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionSrc.java 2010-04-22 14:08:20 UTC (rev 21609)
@@ -52,7 +52,7 @@
public VpeValue exec(VpePageContext pageContext, Node sourceNode) throws VpeExpressionException {
String tagValue = getParameter(0).exec(pageContext, sourceNode)
.stringValue();
- tagValue = resolveEL(pageContext,tagValue);
+// tagValue = resolveEL(pageContext,tagValue);
IFile iFile = VpeCreatorUtil.getFile(tagValue, pageContext);
if (iFile != null) {
@@ -251,24 +251,24 @@
* temporary solution to solve #{facesContext.externalContext.requestContextPath}
* JBIDE-1410
*/
- protected String resolveEL(VpePageContext pageContext, String value) {
- String resolvedValue = value.replaceFirst("^\\s*(\\#|\\$)\\{facesContext.externalContext.requestContextPath\\}", ""); //$NON-NLS-1$ //$NON-NLS-2$
-
- //fix for JBIDE-2550, author Maksim Areshkau
- if(Jsf2ResourceUtil.isJSF2ResourceString(resolvedValue)){
- resolvedValue = Jsf2ResourceUtil.processCustomJSFAttributes(pageContext, resolvedValue);
- }
-
- //Fix for JBIDE-3030
- if(pageContext.getVisualBuilder().getCurrentIncludeInfo()==null
- || !(pageContext.getVisualBuilder().getCurrentIncludeInfo() instanceof IFile)){
- return resolvedValue;
- }
- final IFile file = (IFile) pageContext.getVisualBuilder().getCurrentIncludeInfo().getStorage();
-
- resolvedValue = ElService.getInstance().replaceEl(file, resolvedValue);
- return resolvedValue;
- }
+// protected String resolveEL(VpePageContext pageContext, String value) {
+// String resolvedValue = value.replaceFirst("^\\s*(\\#|\\$)\\{facesContext.externalContext.requestContextPath\\}", ""); //$NON-NLS-1$ //$NON-NLS-2$
+//
+// //fix for JBIDE-2550, author Maksim Areshkau
+// if(Jsf2ResourceUtil.isJSF2ResourceString(resolvedValue)){
+// resolvedValue = Jsf2ResourceUtil.processCustomJSFAttributes(pageContext, resolvedValue);
+// }
+//
+// //Fix for JBIDE-3030
+// if(pageContext.getVisualBuilder().getCurrentIncludeInfo()==null
+// || !(pageContext.getVisualBuilder().getCurrentIncludeInfo() instanceof IFile)){
+// return resolvedValue;
+// }
+// final IFile file = (IFile) pageContext.getVisualBuilder().getCurrentIncludeInfo().getStorage();
+//
+// resolvedValue = ElService.getInstance().replaceEl(file, resolvedValue);
+// return resolvedValue;
+// }
public static String getAbsoluteResourcePath(String resourcePathInPlugin) {
String pluginPath = VpePlugin.getPluginResourcePath();
Modified: branches/jbosstools-3.1.x/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ElService.java
===================================================================
--- branches/jbosstools-3.1.x/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ElService.java 2010-04-22 13:02:29 UTC (rev 21608)
+++ branches/jbosstools-3.1.x/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ElService.java 2010-04-22 14:08:20 UTC (rev 21609)
@@ -186,7 +186,9 @@
if (((this.isAvailable(file) && this.isAvailableForNode(sourceNode, file)))
|| isInResourcesBundle(pageContext, sourceNode)){
rst = true;
- }else if(Jsf2ResourceUtil.isContainJSF2ResourceAttributes(sourceNode)) {
+ }else if(Jsf2ResourceUtil.isContainJSFExternalContextPath(sourceNode)){
+ rst = true;
+ }if(Jsf2ResourceUtil.isContainJSF2ResourceAttributes(sourceNode)) {
//added by Maksim Areshkau, see JBIDE-4812
rst = true;
}
@@ -386,6 +388,10 @@
//replace custom attributes
rst = replaceCustomAttributes(pageContext,rst);
+ if(Jsf2ResourceUtil.isExternalContextPathString(value)){
+ rst = Jsf2ResourceUtil.processExternalContextPath(value);
+ }
+
if(Jsf2ResourceUtil.isJSF2ResourceString(rst)){
rst = Jsf2ResourceUtil.processCustomJSFAttributes(pageContext, rst);
}
Modified: branches/jbosstools-3.1.x/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/Jsf2ResourceUtil.java
===================================================================
--- branches/jbosstools-3.1.x/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/Jsf2ResourceUtil.java 2010-04-22 13:02:29 UTC (rev 21608)
+++ branches/jbosstools-3.1.x/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/Jsf2ResourceUtil.java 2010-04-22 14:08:20 UTC (rev 21609)
@@ -29,12 +29,60 @@
.compile("[#\\$]\\{\\s*resource\\s*\\[\\s*'(.*)'\\s*\\]\\s*\\}"); //$NON-NLS-1$
private static final Pattern resourcePatternWithDoableCoat = Pattern
.compile("[#\\$]\\{\\s*resource\\s*\\[\\s*\"(.*)\"\\s*\\]\\s*\\}"); //$NON-NLS-1$
+ private static final Pattern jsfExternalContextPath = Pattern
+ .compile("^\\s*(\\#|\\$)\\{facesContext.externalContext.requestContextPath\\}"); //$NON-NLS-1$
+ /**
+ * Check if node contains attributes like this src="#{facesContext.externalContext.requestContextPath}/images/sample.gif"
+ * @param sourceNode
+ * @return true if node contains #{facesContext.externalContext.requestContextPath}/images/sample.gif
+ * @author mareshkau, fix for https://jira.jboss.org/jira/browse/JBIDE-5985
+ */
+ public static boolean isContainJSFExternalContextPath(Node sourceNode) {
+ boolean result = false;
+ if (sourceNode.getNodeType() == Node.TEXT_NODE) {
+ String textValue = sourceNode.getNodeValue();
+ if (textValue != null) {
+ if (Jsf2ResourceUtil.isExternalContextPathString(textValue)) {
+ result = true;
+ }
+ }
+ } else {
+ final NamedNodeMap nodeMap = sourceNode.getAttributes();
+ if ((nodeMap != null) && (nodeMap.getLength() > 0)) {
+ for (int i = 0; i < nodeMap.getLength(); i++) {
+ if (Jsf2ResourceUtil
+ .isExternalContextPathString(((Attr) nodeMap
+ .item(i)).getValue())) {
+ result = true;
+ }
+ }
+ }
+ }
+ return result;
+ }
/**
+ * Checks string for jsf declaration
+ * @param attributeValue
+ * @return true is string contains #{facesContext.externalContext.requestContextPath}
+ * @author mareshkau, fix for https://jira.jboss.org/jira/browse/JBIDE-5985
+ */
+ public static boolean isExternalContextPathString(String attributeValue) {
+ Matcher externalContextPathMatcher = jsfExternalContextPath
+ .matcher(attributeValue);
+ boolean result = false;
+ if (externalContextPathMatcher.find()) {
+ result = true;
+ }
+ return result;
+ }
+
+ /**
* Checks is node contained jsf attributes declaration
+ *
* @param sourceNode
- * @return true if node has #{resource[...]} declarations
- * false otherwise
+ * @return true if node has #{resource[...]} declarations false otherwise
+ * @author mareshkau
*/
public static boolean isContainJSF2ResourceAttributes(Node sourceNode) {
boolean result = false;
@@ -59,25 +107,31 @@
}
return result;
}
+
/**
* Replaces custom jsf attribute with attribute from VPE
+ *
* @param pageContext
* @param value
* @return
*/
- public static final String processCustomJSFAttributes(VpePageContext pageContext, String value){
- String result =null;
- //fix for JBIDE-2550, author Maksim Areshkau
- Matcher singleCoatMatcher = resourcePatternWithSinglCoat.matcher(value);
- Matcher doubleCoatMatcher = resourcePatternWithDoableCoat.matcher(value);
- if(doubleCoatMatcher.find()) {
- result = FileUtil.getJSF2ResourcePath(pageContext, doubleCoatMatcher.group(1));
- }else if(singleCoatMatcher.find()){
- result = FileUtil.getJSF2ResourcePath(pageContext, singleCoatMatcher.group(1));
- }
+ public static final String processCustomJSFAttributes(
+ VpePageContext pageContext, String value) {
+ String result = null;
+ // fix for JBIDE-2550, author Maksim Areshkau
+ Matcher singleCoatMatcher = resourcePatternWithSinglCoat.matcher(value);
+ Matcher doubleCoatMatcher = resourcePatternWithDoableCoat
+ .matcher(value);
+ if (doubleCoatMatcher.find()) {
+ result = FileUtil.getJSF2ResourcePath(pageContext,
+ doubleCoatMatcher.group(1));
+ } else if (singleCoatMatcher.find()) {
+ result = FileUtil.getJSF2ResourcePath(pageContext,
+ singleCoatMatcher.group(1));
+ }
- return result;
- }
+ return result;
+ }
/**
* Checks if string is jsf 2 resource
@@ -96,4 +150,12 @@
}
return result;
}
+ /**
+ * Replaced "^\\s*(\\#|\\$)\\{facesContext.externalContext.requestContextPath\\}" with ""
+ * @param value
+ * @return replaced "^\\s*(\\#|\\$)\\{facesContext.externalContext.requestContextPath\\}" with ""
+ */
+ public static String processExternalContextPath(String value) {
+ return value.replaceFirst("^\\s*(\\#|\\$)\\{facesContext.externalContext.requestContextPath\\}", ""); //$NON-NLS-1$ //$NON-NLS-2$
+ }
}
14 years, 8 months
JBoss Tools SVN: r21608 - branches/jbosstools-3.1.x/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide.
by jbosstools-commits@lists.jboss.org
Author: mareshkau
Date: 2010-04-22 09:02:29 -0400 (Thu, 22 Apr 2010)
New Revision: 21608
Added:
branches/jbosstools-3.1.x/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/UnclosedELExpressionTest.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-6064 adding missed junit test class
Added: branches/jbosstools-3.1.x/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/UnclosedELExpressionTest.java
===================================================================
--- branches/jbosstools-3.1.x/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/UnclosedELExpressionTest.java (rev 0)
+++ branches/jbosstools-3.1.x/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/UnclosedELExpressionTest.java 2010-04-22 13:02:29 UTC (rev 21608)
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jsf.vpe.jsf.test.jbide;
+
+import org.jboss.tools.jsf.vpe.jsf.test.JsfAllTests;
+import org.jboss.tools.vpe.ui.test.ComponentContentTest;
+
+/**
+ * Junit test for https://jira.jboss.org/jira/browse/JBIDE-6064
+ *
+ * @author mareshkau
+ *
+ */
+public class UnclosedELExpressionTest extends ComponentContentTest {
+
+ public UnclosedELExpressionTest(String name) {
+ super(name);
+ }
+
+ public void testCheckContetnForDefaultNamespace() throws Throwable{
+ performContentTest("JBIDE/6064/jbide6064.xhtml"); //$NON-NLS-1$
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.vpe.ui.test.ComponentContentTest#getTestProjectName()
+ */
+ @Override
+ protected String getTestProjectName() {
+ return JsfAllTests.IMPORT_PROJECT_NAME;
+ }
+
+}
14 years, 8 months
JBoss Tools SVN: r21607 - branches/jbosstools-3.1.x/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist.
by jbosstools-commits@lists.jboss.org
Author: vrubezhny
Date: 2010-04-22 08:56:52 -0400 (Thu, 22 Apr 2010)
New Revision: 21607
Modified:
branches/jbosstools-3.1.x/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/FaceletPageContectAssistProcessor.java
branches/jbosstools-3.1.x/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/XmlContentAssistProcessor.java
Log:
JBIDE-6055: Seam EL code completion requaires JSF nature.
The EL CA availability is validated thru number of EL Resolvers defined for the project (EL CA will be shown if and only if there is at least one EL resolver defined for the project)
The "New EL Expression" proposal appearance is corrected (this proposal will not appear in case of no EL Proposals defined for project)
Patch is applied in branch 3.1.x
Modified: branches/jbosstools-3.1.x/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/FaceletPageContectAssistProcessor.java
===================================================================
--- branches/jbosstools-3.1.x/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/FaceletPageContectAssistProcessor.java 2010-04-22 11:53:35 UTC (rev 21606)
+++ branches/jbosstools-3.1.x/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/FaceletPageContectAssistProcessor.java 2010-04-22 12:56:52 UTC (rev 21607)
@@ -82,7 +82,7 @@
*/
@Override
protected void addTextELProposals(ContentAssistRequest contentAssistRequest) {
- if (!isJsfProject())
+ if (!isELCAToBeShown())
return;
TextRegion prefix = getELPrefix(contentAssistRequest);
Modified: branches/jbosstools-3.1.x/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/XmlContentAssistProcessor.java
===================================================================
--- branches/jbosstools-3.1.x/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/XmlContentAssistProcessor.java 2010-04-22 11:53:35 UTC (rev 21606)
+++ branches/jbosstools-3.1.x/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/XmlContentAssistProcessor.java 2010-04-22 12:56:52 UTC (rev 21607)
@@ -22,6 +22,7 @@
import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImageHelper;
import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImages;
import org.jboss.tools.common.el.core.resolver.ELContext;
+import org.jboss.tools.common.el.core.resolver.ELResolver;
import org.jboss.tools.common.text.TextProposal;
import org.jboss.tools.jst.jsp.JspEditorPlugin;
import org.jboss.tools.jst.jsp.messages.JstUIMessages;
@@ -296,6 +297,9 @@
* @param contentAssistRequest
*/
protected void addELPredicateProposals(ContentAssistRequest contentAssistRequest, int baseRelevance, boolean shiftRelevanceAgainstTagNameProposals) {
+ if (!isELCAToBeShown())
+ return;
+
// Need to check if the cursor is placed right after a word part.
// If there is no word part found then just quit
TextRegion prefix = getELPredicatePrefix(contentAssistRequest);
@@ -363,7 +367,7 @@
@Override
protected void addAttributeValueELProposals(ContentAssistRequest contentAssistRequest) {
- if (!isJsfProject())
+ if (!isELCAToBeShown())
return;
TextRegion prefix = getELPrefix(contentAssistRequest);
@@ -447,6 +451,9 @@
@Override
protected void addTextELProposals(ContentAssistRequest contentAssistRequest) {
+ if (!isELCAToBeShown())
+ return;
+
TextRegion prefix = getELPrefix(contentAssistRequest);
if (prefix == null || !prefix.isELStarted()) {
AutoContentAssistantProposal proposal = new AutoContentAssistantProposal(true, "#{}", //$NON-NLS-1$
@@ -513,21 +520,12 @@
}
/**
- * A temporary fix to decide if JSF-tricks are to play
+ * Checks is we need to show EL proposals
*
* @return
*/
- protected boolean isJsfProject() {
- if (getContext() == null || getContext().getResource() == null)
- return false;
-
- IProject project = getContext().getResource().getProject();
- try {
- if (project.getNature("org.jboss.tools.jsf.jsfnature") != null) //$NON-NLS-1$
- return true;
- } catch (CoreException e) {
- JspEditorPlugin.getDefault().logError(e);
- }
- return false;
+ protected boolean isELCAToBeShown() {
+ ELResolver[] resolvers = getContext().getElResolvers();
+ return (resolvers != null && resolvers.length > 0);
}
}
\ No newline at end of file
14 years, 8 months
JBoss Tools SVN: r21606 - in trunk: drools/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke and 3 other directories.
by jbosstools-commits@lists.jboss.org
Author: vpakan(a)redhat.com
Date: 2010-04-22 07:53:35 -0400 (Thu, 22 Apr 2010)
New Revision: 21606
Added:
trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/DroolsRulesEditorTest.java
Modified:
trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/DroolsAllBotTests.java
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTUtilExt.java
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/parts/ContentAssistBot.java
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/parts/SWTBotEditorExt.java
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/IDELabel.java
Log:
Added Drools Rule Editor test.
Modified: trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/DroolsAllBotTests.java
===================================================================
--- trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/DroolsAllBotTests.java 2010-04-22 09:29:00 UTC (rev 21605)
+++ trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/DroolsAllBotTests.java 2010-04-22 11:53:35 UTC (rev 21606)
@@ -17,6 +17,7 @@
import org.jboss.tools.drools.ui.bot.test.smoke.ManageDroolsRuntime;
import org.jboss.tools.drools.ui.bot.test.smoke.ManageDroolsProject;
import org.jboss.tools.drools.ui.bot.test.smoke.ManageDroolsRules;
+import org.jboss.tools.drools.ui.bot.test.smoke.DroolsRulesEditorTest;
import org.jboss.tools.ui.bot.ext.SWTTestExt;
import org.jboss.tools.ui.bot.ext.SWTUtilExt;
import org.jboss.tools.ui.bot.ext.types.IDELabel;
@@ -29,7 +30,7 @@
/**
*
- * This is struts swtbot testcase for JBoss Tools.
+ * This is Drools swtbot test case for JBoss Tools.
*
* @author Vladimir Pakan
*
@@ -37,7 +38,8 @@
@RunWith(Suite.class)
@SuiteClasses({ManageDroolsRuntime.class,
ManageDroolsProject.class,
- ManageDroolsRules.class})
+ ManageDroolsRules.class,
+ DroolsRulesEditorTest.class})
public class DroolsAllBotTests extends SWTTestExt {
public static final String DROOLS_PROJECT_NAME = "droolsTest";
public static final String DROOLS_RUNTIME_NAME = "Drools Test Runtime";
Added: trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/DroolsRulesEditorTest.java
===================================================================
--- trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/DroolsRulesEditorTest.java (rev 0)
+++ trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/DroolsRulesEditorTest.java 2010-04-22 11:53:35 UTC (rev 21606)
@@ -0,0 +1,96 @@
+ /*******************************************************************************
+ * Copyright (c) 2007-2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.drools.ui.bot.test.smoke;
+
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor;
+import org.eclipse.swtbot.swt.finder.utils.Position;
+import org.jboss.tools.ui.bot.ext.SWTTestExt;
+import org.jboss.tools.ui.bot.ext.parts.ContentAssistBot;
+import org.jboss.tools.ui.bot.ext.parts.SWTBotEditorExt;
+import org.jboss.tools.ui.bot.ext.types.IDELabel;
+import org.jboss.tools.drools.ui.bot.test.DroolsAllBotTests;
+import org.junit.Test;
+// import org.eclipse.ui.forms.editor.FormEditor;
+/**
+ * Tests Drools Rule Editor
+ * @author Vladimir Pakan
+ *
+ */
+public class DroolsRulesEditorTest extends SWTTestExt{
+ /**
+ * Tests Drools Rule Editor
+ */
+ private static final String CONTENT_ASSIST_IMPORT = "import";
+ private static final String CONTENT_ASSIST_MESSAGE = "Message";
+ @Test
+ public void testManageDroolsProject() {
+ codeCompletionCheck(DroolsAllBotTests.SAMPLE_DROOLS_RULE_NAME);
+ reteViewCheck(DroolsAllBotTests.SAMPLE_DROOLS_RULE_NAME);
+ }
+ /**
+ * Check code completion for Drools Rule
+ * @param droolsRuleName
+ */
+ private void codeCompletionCheck(String droolsRuleName){
+
+ packageExplorer.show();
+ packageExplorer.openFile(DroolsAllBotTests.DROOLS_PROJECT_NAME ,
+ DroolsAllBotTests.SRC_MAIN_RULES_TREE_NODE,droolsRuleName);
+ SWTBotEditorExt ruleEditor = bot.swtBotEditorExtByTitle(droolsRuleName);
+ ruleEditor.selectPage(IDELabel.DroolsEditor.TEXT_EDITOR_TAB);
+ ruleEditor.typeText(3, 0, "i");
+ ContentAssistBot contentAssist = ruleEditor.contentAssist();
+ contentAssist.checkContentAssist(DroolsRulesEditorTest.CONTENT_ASSIST_IMPORT, true);
+ ruleEditor.typeText(6, 0, "m");
+ contentAssist.checkContentAssist(DroolsRulesEditorTest.CONTENT_ASSIST_MESSAGE, true);
+
+ SWTBotEclipseEditor ruleTextEditor = ruleEditor.toTextEditor();
+ String lineText = ruleTextEditor.getTextOnLine(3).trim();
+ assertTrue("Content Assist for " + DroolsRulesEditorTest.CONTENT_ASSIST_IMPORT +
+ " was not inserted properly.\n" +
+ "Inserted text is: " + lineText + "\n" +
+ "Expected text is: " + DroolsRulesEditorTest.CONTENT_ASSIST_IMPORT,
+ lineText.equals(DroolsRulesEditorTest.CONTENT_ASSIST_IMPORT));
+
+ lineText = ruleTextEditor.getTextOnLine(6).trim();
+ String messageContentAssistText = DroolsRulesEditorTest.CONTENT_ASSIST_MESSAGE + "( )";
+ assertTrue("Content Assist for " + DroolsRulesEditorTest.CONTENT_ASSIST_MESSAGE +
+ " was not inserted properly.\n" +
+ "Inserted text is: " + lineText + "\n" +
+ "Expected text has to stard with: " + messageContentAssistText,
+ lineText.startsWith(messageContentAssistText));
+
+ Position cursorPosition = ruleTextEditor.cursorPosition();
+ assertTrue("Content Assist for " + DroolsRulesEditorTest.CONTENT_ASSIST_MESSAGE +
+ " was not inserted properly.\n" +
+ "Position of cursor is wrong: " + cursorPosition + "\n" +
+ "Expected X cursor position is: " + 9,
+ cursorPosition.column == 9);
+
+ ruleEditor.close();
+
+ }
+ /**
+ * Check Rete View of Drools Rule
+ * @param droolsRuleName
+ */
+ private void reteViewCheck(String droolsRuleName){
+
+ packageExplorer.show();
+ packageExplorer.openFile(DroolsAllBotTests.DROOLS_PROJECT_NAME ,
+ DroolsAllBotTests.SRC_MAIN_RULES_TREE_NODE,droolsRuleName);
+ SWTBotEditorExt ruleEditor = bot.swtBotEditorExtByTitle(droolsRuleName);
+ ruleEditor.selectPage(IDELabel.DroolsEditor.RETE_TREE_TAB);
+
+ }
+}
+
Property changes on: trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/DroolsRulesEditorTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTUtilExt.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTUtilExt.java 2010-04-22 09:29:00 UTC (rev 21605)
+++ trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTUtilExt.java 2010-04-22 11:53:35 UTC (rev 21606)
@@ -618,6 +618,19 @@
}
}
/**
+ * Display all active widgets within parent widget
+ * @param bot
+ * @param parent
+ */
+ public static void displayAllBotWidgets (SWTBot bot, Widget parent){
+ List<?> widgets = bot.widgets(new SWTUtilExt.AlwaysMatchMatcher<Widget>(),parent);
+ for (Object object : widgets){
+ System.out.println(object +
+ " Text: " + SWTUtilExt.invokeMethod(object, "getText") +
+ " Tooltip: " + SWTUtilExt.invokeMethod(object, "getToolTipText"));
+ }
+ }
+ /**
* Display all Toolbar Buttons of view
* @param view
*/
@@ -639,7 +652,13 @@
String result = "<null>";
try {
- result = SWTUtils.invokeMethod(object, "getText").toString();
+ Object oResult = SWTUtils.invokeMethod(object, "getText");
+ if (oResult != null){
+ result = oResult.toString();
+ }
+ else{
+ result = "<null>";
+ }
} catch (NoSuchMethodException e) {
result = "<null>";
} catch (IllegalAccessException e) {
Modified: trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/parts/ContentAssistBot.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/parts/ContentAssistBot.java 2010-04-22 09:29:00 UTC (rev 21605)
+++ trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/parts/ContentAssistBot.java 2010-04-22 11:53:35 UTC (rev 21606)
@@ -1,6 +1,8 @@
private package org.jboss.tools.ui.bot.ext.parts;
import static org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable.syncExec;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.util.ArrayList;
@@ -16,11 +18,14 @@
import org.eclipse.swtbot.swt.finder.results.VoidResult;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable;
+import org.eclipse.ui.editors.text.TextEditor;
+import org.eclipse.ui.forms.editor.FormEditor;
import org.eclipse.ui.texteditor.ITextEditor;
+import org.eclipse.swtbot.swt.finder.results.Result;
/**
* This provides working Content assist functionality.
- * SWTBot (2.0.0#467) funcionality provided in SWTEclipseEditor doesn't work (at least on GTK linux)
+ * SWTBot (2.0.0#467) functionality provided in SWTEclipseEditor doesn't work (at least on GTK linux)
* @author jpeterka
*
*/
@@ -39,14 +44,16 @@
// ------------------------------------------------------------
// Constructor
// ------------------------------------------------------------
- /**
- * Basic constructor
- */
- public ContentAssistBot(SWTBotEditorExt editor) {
- this.editor = editor;
- this.bot = editor.bot();
- }
+ /**
+ * Basic constructor
+ */
+ public ContentAssistBot(SWTBotEditorExt editor) {
+ this.editor = editor;
+ this.bot = editor.bot();
+ }
+
+
// ------------------------------------------------------------
// Public
// ------------------------------------------------------------
@@ -77,17 +84,26 @@
* @param text
*/
public void logProposalList() {
- SWTBotShell shell = openProposalList();
- SWTBotTable table = getProposalTable(shell);
- List<String> list = getTableItems(table);
+ List<String> list = getProposalList();
log.info("Proposal item list: " + list.size() + " item(s)");
for (int i = 0; i < list.size(); i++) {
log.info("Item i:" + list.get(i));
}
-
- shell.close();
}
-
+ /**
+ * Logs proposal list contents, usual for debug purposes
+ *
+ * @param text
+ */
+ public List<String>getProposalList() {
+ List<String> result = null;
+ SWTBotShell shell = openProposalList();
+ SWTBotTable table = getProposalTable(shell);
+ result = getTableItems(table);
+ shell.close();
+
+ return result;
+ }
// ------------------------------------------------------------
// Private
// ------------------------------------------------------------
@@ -97,8 +113,31 @@
private void invokeContentAssist() {
String actionId = "ContentAssistProposal";
//final IAction action = ((ITextEditor) partReference.getEditor(false)).getAction(actionId);
+ Object oEditor = editor.getReference().getEditor(false);
+ ITextEditor textEditor = null;
+ // When editor is instance of FormEditor we have to get editor from page specified by pageIndex
+ if (oEditor instanceof FormEditor){
+ final FormEditor formEditor = (FormEditor)oEditor;
+ textEditor = syncExec(new Result<ITextEditor>() {
+ public ITextEditor run() {
+ ITextEditor textEditor = null;
+ Object oEditor2 = formEditor.getActiveEditor();
+ if (oEditor2 instanceof TextEditor){
+ textEditor = (ITextEditor)oEditor2;
+ }
+ return textEditor;
+ }
+ });
+
+ }
+ else{
+ textEditor = (ITextEditor)oEditor;
+ }
+/*
final IAction action = ((ITextEditor) editor.getReference().getEditor(
false)).getAction(actionId);
+*/
+ final IAction action = textEditor.getAction(actionId);
syncExec(new VoidResult() {
public void run() {
action.run();
@@ -189,4 +228,27 @@
}
return ccShell;
}
+ /**
+ * Check if contentAssistItemLabel is present within Content Assist and
+ * choose it when applyContentAssist is true
+ * @param contentAssistItemLabel
+ * @param applyContentAssist
+ */
+ public void checkContentAssist(String contentAssistItemLabel,boolean applyContentAssist){
+ List<String> proposalList = getProposalList();
+
+ assertNotNull("Editor Content Assist doesn't containt item with label: " + contentAssistItemLabel +
+ ". It's null",
+ proposalList);
+
+ int itemIndex = proposalList.indexOf(contentAssistItemLabel);
+
+ assertTrue("Editor Content Assist doesn't containt item with label: " + contentAssistItemLabel,
+ itemIndex > -1);
+
+ if (applyContentAssist){
+ useProposal(itemIndex);
+ }
+
+ }
}
Modified: trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/parts/SWTBotEditorExt.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/parts/SWTBotEditorExt.java 2010-04-22 09:29:00 UTC (rev 21605)
+++ trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/parts/SWTBotEditorExt.java 2010-04-22 11:53:35 UTC (rev 21606)
@@ -1,8 +1,26 @@
+ /*******************************************************************************
+ * Copyright (c) 2007-2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
package org.jboss.tools.ui.bot.ext.parts;
+import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.allOf;
+import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.widgetOfType;
+import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.withText;
+
+import org.eclipse.swt.custom.CTabFolder;
+import org.eclipse.swt.custom.CTabItem;
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor;
import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotCTabItem;
import org.eclipse.ui.IEditorReference;
public class SWTBotEditorExt extends SWTBotEclipseEditor {
@@ -19,5 +37,32 @@
return caBot;
}
+ public void selectPage(int pageIndex){
+ try{
+ final CTabFolder tabFolder = this.findWidget(widgetOfType(CTabFolder.class));
+ final int tabFolderPageIndex = pageIndex;
+ bot.getDisplay().syncExec(new Runnable() {
+ public void run() {
+ if (tabFolder.getItemCount() > tabFolderPageIndex){
+ tabFolder.setSelection(tabFolderPageIndex);
+ }
+ }
+ });
+ } catch (WidgetNotFoundException wnfe){
+ // do nothing there is no tabfolder in editor
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public void selectPage(String pageLabel){
+ try{
+ final CTabFolder tabFolder = this.findWidget(widgetOfType(CTabFolder.class));
+ final CTabItem tabItem = ((CTabItem)this.bot.widget(allOf(widgetOfType(CTabItem.class),withText(pageLabel)),
+ tabFolder));
+ new SWTBotCTabItem(tabItem).activate();
+ } catch (WidgetNotFoundException wnfe){
+ // do nothing there is no tabfolder in editor
+ }
+ }
}
Modified: trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/IDELabel.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/IDELabel.java 2010-04-22 09:29:00 UTC (rev 21605)
+++ trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/IDELabel.java 2010-04-22 11:53:35 UTC (rev 21606)
@@ -380,4 +380,11 @@
public static final String BUTTON_RESUME_TOOLTIP = "Resume (F8)";
}
+
+ public static class DroolsEditor {
+
+ public static final String TEXT_EDITOR_TAB = "Text Editor";
+ public static final String RETE_TREE_TAB = "Rete Tree";
+
+ }
}
14 years, 8 months
JBoss Tools SVN: r21605 - in trunk/vpe: tests/org.jboss.tools.vpe.html.test/resources/htmlTest/WebContent/pages/components/core and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: yzhishko
Date: 2010-04-22 05:29:00 -0400 (Thu, 22 Apr 2010)
New Revision: 21605
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe.html/templates/vpe-templates-html.xml
trunk/vpe/tests/org.jboss.tools.vpe.html.test/resources/htmlTest/WebContent/pages/components/core/object.html.xml
Log:
https://jira.jboss.org/jira/browse/JBIDE-6168 - fixed in trunk
Modified: trunk/vpe/plugins/org.jboss.tools.vpe.html/templates/vpe-templates-html.xml
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.html/templates/vpe-templates-html.xml 2010-04-22 09:28:27 UTC (rev 21604)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.html/templates/vpe-templates-html.xml 2010-04-22 09:29:00 UTC (rev 21605)
@@ -1422,7 +1422,7 @@
<vpe:tag name="object" case-sensitive="no">
<vpe:template children="yes" modify="no">
<vpe:copy
- attrs="align,code,codebase,codetype,data,height,hspace,type,vspace,width,class,id,dir" />
+ attrs="align,height,hspace,vspace,width,id,dir" />
<vpe:dnd>
<vpe:drop container="yes">
<vpe:container-child tag-name="param" />
@@ -1436,7 +1436,7 @@
<vpe:tag name="embed" case-sensitive="no">
<vpe:template children="yes" modify="no">
<vpe:copy
- attrs="align,height,hidden,hspace,pluginspage,src,type,vspace,width" />
+ attrs="align,height,hidden,hspace,pluginspage,src,vspace,width" />
</vpe:template>
</vpe:tag>
Modified: trunk/vpe/tests/org.jboss.tools.vpe.html.test/resources/htmlTest/WebContent/pages/components/core/object.html.xml
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.html.test/resources/htmlTest/WebContent/pages/components/core/object.html.xml 2010-04-22 09:28:27 UTC (rev 21604)
+++ trunk/vpe/tests/org.jboss.tools.vpe.html.test/resources/htmlTest/WebContent/pages/components/core/object.html.xml 2010-04-22 09:29:00 UTC (rev 21605)
@@ -1,7 +1,7 @@
<tests>
<test id="object">
- <OBJECT WIDTH="500" VSPACE="10" HEIGHT="200" ALIGN="top"
- STYLE="-moz-user-modify: read-only;" >
+ <OBJECT WIDTH="500" VSPACE="10" HEIGHT="200" ALIGN="top" ID="object"
+ STYLE="-moz-user-modify: read-only;">
</OBJECT>
</test>
</tests>
\ No newline at end of file
14 years, 8 months
JBoss Tools SVN: r21604 - in branches/jbosstools-3.1.x/vpe: tests/org.jboss.tools.vpe.html.test/resources/htmlTest/WebContent/pages/components/core and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: yzhishko
Date: 2010-04-22 05:28:27 -0400 (Thu, 22 Apr 2010)
New Revision: 21604
Modified:
branches/jbosstools-3.1.x/vpe/plugins/org.jboss.tools.vpe.html/templates/vpe-templates-html.xml
branches/jbosstools-3.1.x/vpe/tests/org.jboss.tools.vpe.html.test/resources/htmlTest/WebContent/pages/components/core/object.html
branches/jbosstools-3.1.x/vpe/tests/org.jboss.tools.vpe.html.test/resources/htmlTest/WebContent/pages/components/core/object.html.xml
Log:
https://jira.jboss.org/jira/browse/JBIDE-6168 - fixed in branch
Modified: branches/jbosstools-3.1.x/vpe/plugins/org.jboss.tools.vpe.html/templates/vpe-templates-html.xml
===================================================================
--- branches/jbosstools-3.1.x/vpe/plugins/org.jboss.tools.vpe.html/templates/vpe-templates-html.xml 2010-04-22 08:47:28 UTC (rev 21603)
+++ branches/jbosstools-3.1.x/vpe/plugins/org.jboss.tools.vpe.html/templates/vpe-templates-html.xml 2010-04-22 09:28:27 UTC (rev 21604)
@@ -1422,7 +1422,7 @@
<vpe:tag name="object" case-sensitive="no">
<vpe:template children="yes" modify="no">
<vpe:copy
- attrs="align,classid,code,codebase,codetype,data,height,hspace,type,vspace,width,class,id,dir" />
+ attrs="align,height,hspace,vspace,width,id,dir" />
<vpe:dnd>
<vpe:drop container="yes">
<vpe:container-child tag-name="param" />
@@ -1436,7 +1436,7 @@
<vpe:tag name="embed" case-sensitive="no">
<vpe:template children="yes" modify="no">
<vpe:copy
- attrs="align,height,hidden,hspace,pluginspage,src,type,vspace,width" />
+ attrs="align,height,hidden,hspace,pluginspage,src,vspace,width" />
</vpe:template>
</vpe:tag>
Modified: branches/jbosstools-3.1.x/vpe/tests/org.jboss.tools.vpe.html.test/resources/htmlTest/WebContent/pages/components/core/object.html
===================================================================
--- branches/jbosstools-3.1.x/vpe/tests/org.jboss.tools.vpe.html.test/resources/htmlTest/WebContent/pages/components/core/object.html 2010-04-22 08:47:28 UTC (rev 21603)
+++ branches/jbosstools-3.1.x/vpe/tests/org.jboss.tools.vpe.html.test/resources/htmlTest/WebContent/pages/components/core/object.html 2010-04-22 09:28:27 UTC (rev 21604)
@@ -5,7 +5,7 @@
<h1>object</h1>
-<object id="object" classid="someClass" width="500" height="200" align="top"
+<object id="object" width="500" height="200" align="top"
border="10" class="objectClass" dir="ltr" id="object"
style="color: red;" vspace="10">
<param name="someParam" value="5">
Modified: branches/jbosstools-3.1.x/vpe/tests/org.jboss.tools.vpe.html.test/resources/htmlTest/WebContent/pages/components/core/object.html.xml
===================================================================
--- branches/jbosstools-3.1.x/vpe/tests/org.jboss.tools.vpe.html.test/resources/htmlTest/WebContent/pages/components/core/object.html.xml 2010-04-22 08:47:28 UTC (rev 21603)
+++ branches/jbosstools-3.1.x/vpe/tests/org.jboss.tools.vpe.html.test/resources/htmlTest/WebContent/pages/components/core/object.html.xml 2010-04-22 09:28:27 UTC (rev 21604)
@@ -1,7 +1,7 @@
<tests>
<test id="object">
- <OBJECT WIDTH="500" VSPACE="10" HEIGHT="200" ALIGN="top"
- CLASSID="someClass" STYLE="-moz-user-modify: read-only;" >
+ <OBJECT WIDTH="500" VSPACE="10" HEIGHT="200" ALIGN="top" ID="object"
+ STYLE="-moz-user-modify: read-only;">
</OBJECT>
</test>
</tests>
\ No newline at end of file
14 years, 8 months