Author: vrubezhny
Date: 2009-12-24 13:27:06 -0500 (Thu, 24 Dec 2009)
New Revision: 19579
Added:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/JsfJspJbide1813Test/WebContent/WEB-INF/
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/JsfJspJbide1813Test/WebContent/WEB-INF/web.xml
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/AbstractXMLContentAssistProcessor.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/PageContextFactory.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/XmlContextImpl.java
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/JsfJspJbide1813Test/.project
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/ContentAssistantTestCase.java
Log:
JBIDE-5479: Changes to File in VPE Editor are saved even when user decide to not save
them.
JBIDE-5478: "Unsupported Content Type" warning when reopening .jsp file.
Issues are fixed
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/AbstractXMLContentAssistProcessor.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/AbstractXMLContentAssistProcessor.java 2009-12-24
17:04:18 UTC (rev 19578)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/AbstractXMLContentAssistProcessor.java 2009-12-24
18:27:06 UTC (rev 19579)
@@ -944,7 +944,8 @@
*/
protected TextRegion getELPrefix(ContentAssistRequest request) {
if (!DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE.equals(request.getRegion().getType())
&&
- !DOMRegionContext.XML_CONTENT.equals(request.getRegion().getType()))
+ !DOMRegionContext.XML_CONTENT.equals(request.getRegion().getType()) &&
+ !DOMRegionContext.BLOCK_TEXT.equals(request.getRegion().getType()))
return null;
String text = request.getDocumentRegion().getFullText(request.getRegion());
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/PageContextFactory.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/PageContextFactory.java 2009-12-24
17:04:18 UTC (rev 19578)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/PageContextFactory.java 2009-12-24
18:27:06 UTC (rev 19579)
@@ -41,9 +41,6 @@
import org.eclipse.jdt.ui.text.IJavaPartitions;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentListener;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.Region;
import org.eclipse.jface.text.rules.IToken;
@@ -112,7 +109,7 @@
* @author Alexey Kazakov
*/
@SuppressWarnings("restriction")
-public class PageContextFactory implements IResourceChangeListener, IDocumentListener {
+public class PageContextFactory implements IResourceChangeListener {
private static PageContextFactory fInstance;
private static final String XHTML_TAG_LIB_URI =
"http://www.w3.org/1999/xhtml"; //$NON-NLS-1$
public static final String XML_PAGE_CONTEXT_TYPE = "XML_PAGE_CONTEXT_TYPE";
//$NON-NLS-1$
@@ -145,32 +142,18 @@
private void saveConvext(ELContext context) {
if (context != null && context.getResource() != null) {
-// int size = 0; // remove this line
synchronized (cache) {
cache.put(context.getResource(), context);
-// size = cache.size(); // remove this line
}
-// System.out.println("Saved Context : " +
-// (System.currentTimeMillis() - ctm) + "ms, "
-// + context.getResource().getFullPath().toString() + ", " +
context.getClass().getSimpleName() + ", Totals: " + size);
}
}
private ELContext removeSavedContext(IFile resource) {
- ELContext removedContext = null; // Remove this line
+ ELContext removedContext = null;
synchronized (cache) {
removedContext = cache.remove(resource);
- if (removedContext instanceof XmlContextImpl &&
- ((XmlContextImpl)removedContext).getDocument() != null) {
- ((XmlContextImpl)removedContext).getDocument().removeDocumentListener(this);
- }
}
-
-// if (removedContext != null) { // TODO: Remove this statement
-// System.out.println("Removed Context : " +
removedContext.getResource().getFullPath().toString() + ", " +
removedContext.getClass().getSimpleName() + ", Totals: " + cache.size());
-// }
-
return removedContext;
}
@@ -346,15 +329,19 @@
* @return
*/
private ELContext createPageContext(IFile file, List<String> parents) {
- ELContext context = getSavedContext(file);
+ ELContext context = parents == null ? null : getSavedContext(file);
if (context != null) {
return context;
}
+ if (file == null)
+ return createPageContextInstance(null);
+
IContentType type = IDE.getContentType(file);
-
- if(JavaCore.JAVA_SOURCE_CONTENT_TYPE.equalsIgnoreCase(type.getId())) {
+ String typeId = (type == null ? null : type.getId());
+
+ if(JavaCore.JAVA_SOURCE_CONTENT_TYPE.equalsIgnoreCase(typeId)) {
context = createJavaContext(file);
- } else if(JAVA_PROPERTIES_CONTENT_TYPE.equalsIgnoreCase(type.getId())) {
+ } else if(JAVA_PROPERTIES_CONTENT_TYPE.equalsIgnoreCase(typeId)) {
context = createPropertiesContext(file);
} else {
// ctm = System.currentTimeMillis();
@@ -366,6 +353,11 @@
// there is no need to report it, just stop validation.
return context;
}
+
+ if (file == null) {
+ System.out.println();
+ }
+
IStructuredModel model = null;
try {
model = manager.getModelForRead(file);
@@ -400,14 +392,8 @@
}
}
- if (context != null) {
- if (context instanceof XmlContextImpl) {
- IDocument contextDocument = ((XmlContextImpl) context).getDocument();
- if (contextDocument != null) {
- contextDocument.addDocumentListener(this);
- }
- }
- saveConvext(context);
+ if (context != null && parents != null) {
+ saveConvext(context);
}
return context;
@@ -1138,35 +1124,4 @@
}
}
}
-
- /*
- * (non-Javadoc)
- * @see
org.eclipse.jface.text.IDocumentListener#documentAboutToBeChanged(org.eclipse.jface.text.DocumentEvent)
- */
- public void documentAboutToBeChanged(DocumentEvent event) {
- // Nothing to do
- }
-
- /*
- * (non-Javadoc)
- * @see
org.eclipse.jface.text.IDocumentListener#documentChanged(org.eclipse.jface.text.DocumentEvent)
- */
- public void documentChanged(DocumentEvent event) {
- if (event.getDocument() == null)
- return;
-
- synchronized (cache) {
- // Remove all the contexts that are parent to the removed context
- ELContext[] contexts = cache.values().toArray(new ELContext[0]);
- if (contexts != null) {
- for (ELContext context : contexts) {
- if (context instanceof XmlContextImpl &&
- event.getDocument().equals(((XmlContextImpl)context).getDocument())) {
- cleanUp(context.getResource());
- return;
- }
- }
- }
- }
- }
}
\ No newline at end of file
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/XmlContextImpl.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/XmlContextImpl.java 2009-12-24
17:04:18 UTC (rev 19578)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/XmlContextImpl.java 2009-12-24
18:27:06 UTC (rev 19579)
@@ -21,7 +21,6 @@
public class XmlContextImpl extends ELContextImpl implements IXmlContext {
protected IDocument document;
- private FileEditorInput editorInput;
// Fix for JBIDE-5097: It must be a map of <IRegion to Map of <NS-Prefix to
NS>>
protected Map<IRegion, Map<String, INameSpace>> nameSpaces = new
HashMap<IRegion, Map<String, INameSpace>>();
@@ -32,16 +31,14 @@
@Override
public void setResource(IFile resource) {
super.setResource(resource);
- if (this.document != null) {
- if (!resource.equals(editorInput.getFile())) {
- releaseConnectedDocument(editorInput);
- editorInput = null;
- }
- }
- if (editorInput == null)
- editorInput = new FileEditorInput(resource);
- document = getConnectedDocument(editorInput);
+ FileEditorInput editorInput = null;
+ try {
+ editorInput = new FileEditorInput(resource);
+ document = getConnectedDocument(editorInput);
+ } finally {
+ releaseConnectedDocument(editorInput);
+ }
}
/*
@@ -119,18 +116,6 @@
}
nameSpaces.get(region).put(nameSpace.getPrefix(), nameSpace); // Fix for JBIDE-5097
}
-
-
- /**
- * Disconnects the editor input from the document provider
- */
- @Override
- protected void finalize() throws Throwable {
- if (editorInput != null) {
- releaseConnectedDocument(editorInput);
- }
- super.finalize();
- }
private IDocument getConnectedDocument(IEditorInput input) {
IDocumentProvider provider=
DocumentProviderRegistry.getDefault().getDocumentProvider(input);
Modified:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/JsfJspJbide1813Test/.project
===================================================================
---
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/JsfJspJbide1813Test/.project 2009-12-24
17:04:18 UTC (rev 19578)
+++
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/JsfJspJbide1813Test/.project 2009-12-24
18:27:06 UTC (rev 19579)
@@ -21,5 +21,6 @@
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
+ <nature>org.jboss.tools.jsf.jsfnature</nature>
</natures>
</projectDescription>
Added:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/JsfJspJbide1813Test/WebContent/WEB-INF/web.xml
===================================================================
---
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/JsfJspJbide1813Test/WebContent/WEB-INF/web.xml
(rev 0)
+++
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/JsfJspJbide1813Test/WebContent/WEB-INF/web.xml 2009-12-24
18:27:06 UTC (rev 19579)
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
+ <display-name>JsfJspJbide1813Test</display-name>
+ <context-param>
+ <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
+ <param-value>server</param-value>
+ </context-param>
+ <listener>
+ <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
+ </listener>
+ <!-- Faces Servlet -->
+ <servlet>
+ <servlet-name>Faces Servlet</servlet-name>
+ <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+ <!-- Faces Servlet Mapping -->
+ <servlet-mapping>
+ <servlet-name>Faces Servlet</servlet-name>
+ <url-pattern>*.jsf</url-pattern>
+ </servlet-mapping>
+ <login-config>
+ <auth-method>BASIC</auth-method>
+ </login-config>
+</web-app>
Property changes on:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/JsfJspJbide1813Test/WebContent/WEB-INF/web.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/ContentAssistantTestCase.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/ContentAssistantTestCase.java 2009-12-24
17:04:18 UTC (rev 19578)
+++
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/ContentAssistantTestCase.java 2009-12-24
18:27:06 UTC (rev 19579)
@@ -114,6 +114,13 @@
if (replacementStringParts[0].equalsIgnoreCase(proposalName)) return true;
}
+ // for an Unclosed EL the closing character is appended to the proposal string (i.e.
person} )
+ // perform case sensitive compare operation
+ replacementStringParts = replacementString.split("}");
+ if (replacementStringParts != null && replacementStringParts.length > 0)
{
+ if (replacementStringParts[0].equals(proposalName)) return true;
+ }
+
// For an attribute value proposal there will be the quote characters
replacementString = Utils.trimQuotes(replacementString);
if (replacementString.equalsIgnoreCase(proposalName)) return true;