Author: mareshkau
Date: 2008-02-12 09:58:42 -0500 (Tue, 12 Feb 2008)
New Revision: 6261
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/editor/IVisualContext.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPTextEditor.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/SourceEditorPageContext.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/ValueHelper.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/util/XmlUtil.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1769
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/editor/IVisualContext.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/editor/IVisualContext.java 2008-02-12
14:49:44 UTC (rev 6260)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/editor/IVisualContext.java 2008-02-12
14:58:42 UTC (rev 6261)
@@ -11,7 +11,6 @@
package org.jboss.tools.jst.jsp.editor;
import org.jboss.tools.common.kb.wtp.WtpKbConnector;
-import org.jboss.tools.jst.web.tld.VpeTaglibManager;
public interface IVisualContext {
public void refreshBundleValues();
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPTextEditor.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPTextEditor.java 2008-02-12
14:49:44 UTC (rev 6260)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPTextEditor.java 2008-02-12
14:58:42 UTC (rev 6261)
@@ -184,9 +184,7 @@
if (pageContext==null) {
pageContext = new SourceEditorPageContext();
}
- // IDocument document = getTextViewer().getDocument();
- // pageContext.setDocument(document);
- IDOMDocument document = ((DOMModelImpl) getModel()).getDocument();
+ IDocument document = getTextViewer().getDocument();
pageContext.setDocument(document);
return pageContext;
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/SourceEditorPageContext.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/SourceEditorPageContext.java 2008-02-12
14:49:44 UTC (rev 6260)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/SourceEditorPageContext.java 2008-02-12
14:58:42 UTC (rev 6261)
@@ -14,6 +14,8 @@
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+
+import org.eclipse.jface.text.IDocument;
import org.jboss.tools.common.kb.KbConnectorFactory;
import org.jboss.tools.common.kb.KbConnectorType;
import org.jboss.tools.common.kb.wtp.WtpKbConnector;
@@ -34,9 +36,17 @@
*/
public class SourceEditorPageContext implements IVisualContext,VpeTaglibManager {
- protected List<TaglibData> taglibs = null;
-
+ /**
+ * Contains information about taglibs on edited page
+ */
+ private List<TaglibData> taglibs = null;
+ /**
+ * Kb connector
+ */
private WtpKbConnector connector = null;
+ /**
+ * references node
+ */
private Node referenceNode = null;
public void clearAll() {
@@ -46,8 +56,8 @@
public void dispose() {
clearAll();
- connector = null;
- referenceNode = null;
+ setConnector(null);
+ setReferenceNode(null);
}
/**
@@ -56,19 +66,22 @@
*/
public void setReferenceNode(Node refNode) {
- if ((refNode==null)||(refNode.equals(referenceNode))) {
+ if ((refNode==null)||(refNode.equals(getReferenceNode()))) {
return;
}
- referenceNode = refNode;
+ setReferenceNode(refNode);
updateTagLibs();
}
-
- public void setDocument(Document doc) {
-
-// setReferenceNode(doc);
+ /**
+ * This method will be called if we work with jsp pages
+ * @param iDocument
+ */
+ public void setDocument(IDocument iDocument) {
+
+ setTaglibs(XmlUtil.getTaglibsForJSPDocument(iDocument));
try {
- connector =
(WtpKbConnector)KbConnectorFactory.getIntstance().createConnector(KbConnectorType.JSP_WTP_KB_CONNECTOR,
doc);
+ connector =
(WtpKbConnector)KbConnectorFactory.getIntstance().createConnector(KbConnectorType.JSP_WTP_KB_CONNECTOR,
iDocument);
} catch (InstantiationException e) {
JspEditorPlugin.getPluginLog().logError(e);
} catch (IllegalAccessException e) {
@@ -80,12 +93,12 @@
public void collectRefNodeTagLibs() {
- if(referenceNode==null) {
+ if(getReferenceNode()==null) {
return;
}
- if(referenceNode.getNodeType()==Node.DOCUMENT_NODE) {
- NodeList nodes =referenceNode.getChildNodes();
+ if(getReferenceNode().getNodeType()==Node.DOCUMENT_NODE) {
+ NodeList nodes =getReferenceNode().getChildNodes();
for(int i=0;i<nodes.getLength();i++) {
Node node =nodes.item(i);
@@ -97,7 +110,7 @@
}
} else {
- setTaglibs(XmlUtil.processNode(referenceNode));
+ setTaglibs(XmlUtil.processNode(getReferenceNode()));
}
}
@@ -159,4 +172,18 @@
this.taglibs = taglibs;
}
+ /**
+ * @return the referenceNode
+ */
+ public Node getReferenceNode() {
+ return referenceNode;
+ }
+
+ /**
+ * @param connector the connector to set
+ */
+ public void setConnector(WtpKbConnector connector) {
+ this.connector = connector;
+ }
+
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/ValueHelper.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/ValueHelper.java 2008-02-12
14:49:44 UTC (rev 6260)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/ValueHelper.java 2008-02-12
14:58:42 UTC (rev 6261)
@@ -10,49 +10,54 @@
******************************************************************************/
package org.jboss.tools.jst.jsp.outline;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
-import org.eclipse.core.resources.*;
-import org.jboss.tools.jst.jsp.JspEditorPlugin;
-import org.jboss.tools.jst.jsp.jspeditor.*;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
import org.eclipse.jface.text.IDocument;
-import org.eclipse.jst.jsp.core.internal.contentmodel.*;
-import org.eclipse.jst.jsp.core.internal.contentmodel.tld.*;
-import org.eclipse.ui.*;
-import org.eclipse.ui.texteditor.AbstractTextEditor;
-import org.eclipse.ui.texteditor.ITextEditor;
+import org.eclipse.jst.jsp.core.internal.contentmodel.TaglibController;
+import org.eclipse.jst.jsp.core.internal.contentmodel.tld.TLDCMDocumentManager;
+import org.eclipse.jst.jsp.core.internal.contentmodel.tld.TaglibTracker;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.wst.sse.core.StructuredModelManager;
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
import org.eclipse.wst.sse.ui.StructuredTextEditor;
-import org.eclipse.wst.sse.ui.internal.IModelProvider;
-import org.jboss.tools.jst.jsp.editor.IVisualContext;
-import org.jboss.tools.jst.jsp.editor.IVisualController;
-import org.jboss.tools.jst.jsp.editor.IVisualEditor;
-
-import org.jboss.tools.jst.jsp.contentassist.RedHatHtmlContentAssistProcessor;
-import org.jboss.tools.jst.jsp.drop.treeviewer.model.AttributeValueResource;
-import org.jboss.tools.jst.jsp.drop.treeviewer.model.AttributeValueResourceFactory;
-import org.jboss.tools.jst.jsp.drop.treeviewer.model.ModelElement;
-import org.jboss.tools.jst.jsp.drop.treeviewer.model.RootElement;
import org.jboss.tools.common.kb.AttributeDescriptor;
import org.jboss.tools.common.kb.AttributeValueDescriptor;
import org.jboss.tools.common.kb.KbConnectorFactory;
import org.jboss.tools.common.kb.KbConnectorType;
import org.jboss.tools.common.kb.KbException;
-import org.jboss.tools.common.kb.KbQuery;
import org.jboss.tools.common.kb.KbTldResource;
import org.jboss.tools.common.kb.TagDescriptor;
import org.jboss.tools.common.kb.wtp.JspWtpKbConnector;
import org.jboss.tools.common.kb.wtp.TLDVersionHelper;
import org.jboss.tools.common.kb.wtp.WtpKbConnector;
-import org.jboss.tools.common.model.plugin.ModelPlugin;
import org.jboss.tools.common.model.project.IPromptingProvider;
import org.jboss.tools.common.model.ui.ModelUIPlugin;
import org.jboss.tools.common.model.util.ModelFeatureFactory;
+import org.jboss.tools.jst.jsp.JspEditorPlugin;
+import org.jboss.tools.jst.jsp.contentassist.RedHatHtmlContentAssistProcessor;
+import org.jboss.tools.jst.jsp.drop.treeviewer.model.AttributeValueResource;
+import org.jboss.tools.jst.jsp.drop.treeviewer.model.AttributeValueResourceFactory;
+import org.jboss.tools.jst.jsp.drop.treeviewer.model.ModelElement;
+import org.jboss.tools.jst.jsp.drop.treeviewer.model.RootElement;
+import org.jboss.tools.jst.jsp.editor.IVisualContext;
+import org.jboss.tools.jst.jsp.editor.IVisualController;
+import org.jboss.tools.jst.jsp.editor.IVisualEditor;
+import org.jboss.tools.jst.jsp.jspeditor.JSPMultiPageEditor;
+import org.jboss.tools.jst.jsp.jspeditor.JSPTextEditor;
import org.jboss.tools.jst.jsp.support.kb.WTPTextJspKbConnector;
import org.jboss.tools.jst.web.tld.TaglibData;
-import org.jboss.tools.jst.web.tld.TaglibMapping;
import org.jboss.tools.jst.web.tld.VpeTaglibManager;
import org.w3c.dom.Attr;
import org.w3c.dom.Element;
@@ -73,8 +78,7 @@
}
}
-// VpePageContext
- IVisualContext pageContext = null;
+ IVisualContext iVisualContext = null;
WtpKbConnector pageConnector = null;
public ValueHelper() {
@@ -92,23 +96,23 @@
}
boolean init() {
- if(pageContext != null || pageConnector != null) return true;
+ if(iVisualContext != null || pageConnector != null) return true;
IEditorPart editor =
ModelUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
if(!(editor instanceof JSPMultiPageEditor)) return false;
JSPTextEditor jspEditor = ((JSPMultiPageEditor)editor).getJspEditor();
//Added By Max Areshkau
//Fix for JBIDE-788
- pageContext = jspEditor.getPageContext();
+ iVisualContext = jspEditor.getPageContext();
editorInput = jspEditor.getEditorInput();
wtpTextJspKbConnector = jspEditor.getWTPTextJspKbConnector();
- if(pageContext != null) {
+ if(iVisualContext != null) {
updateFacelets();
}
- return pageContext != null || pageConnector != null;
+ return iVisualContext != null || pageConnector != null;
}
public ModelElement getInitalInput(String query) {
@@ -185,9 +189,9 @@
public VpeTaglibManager getTaglibManager() {
init();
- if(pageContext!=null && pageContext instanceof VpeTaglibManager) {
+ if(iVisualContext!=null && iVisualContext instanceof VpeTaglibManager) {
- return (VpeTaglibManager)pageContext;
+ return (VpeTaglibManager)iVisualContext;
} else {
return null;
@@ -195,7 +199,7 @@
}
public WtpKbConnector getPageConnector() {
- if(pageContext != null) return pageContext.getConnector();
+ if(iVisualContext != null) return iVisualContext.getConnector();
return pageConnector;
}
@@ -214,7 +218,7 @@
//Support of StructuredTextEditor
boolean init2() {
- if(pageContext != null || pageConnector != null) return true;
+ if(iVisualContext != null || pageConnector != null) return true;
IEditorPart editor =
ModelUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
if(!(editor instanceof StructuredTextEditor)) return false;
StructuredTextEditor jspEditor = ((StructuredTextEditor)editor);
@@ -223,7 +227,7 @@
if(document == null) return false;
installActivePropmtSupport(jspEditor, document);
getConnector(document);
- return pageContext != null || pageConnector != null;
+ return iVisualContext != null || pageConnector != null;
}
private void installActivePropmtSupport(StructuredTextEditor jspEditor, IDocument
document) {
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/util/XmlUtil.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/util/XmlUtil.java 2008-02-12
14:49:44 UTC (rev 6260)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/util/XmlUtil.java 2008-02-12
14:58:42 UTC (rev 6261)
@@ -15,6 +15,11 @@
import java.util.List;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jst.jsp.core.internal.contentmodel.TaglibController;
+import org.eclipse.jst.jsp.core.internal.contentmodel.tld.TLDCMDocumentManager;
+import org.eclipse.jst.jsp.core.internal.contentmodel.tld.TaglibTracker;
import org.jboss.tools.jst.jsp.JspEditorPlugin;
import org.jboss.tools.jst.web.tld.TaglibData;
import org.w3c.dom.Attr;
@@ -92,7 +97,25 @@
return taglibs;
}
+
/**
+ * Finds and returns taglibs for JSP documents
+ * @return
+ */
+ public static List<TaglibData> getTaglibsForJSPDocument(IDocument document) {
+
+ List<TaglibData> taglibData = new ArrayList<TaglibData>();
+
+ TLDCMDocumentManager tldcmDocumentManager=
TaglibController.getTLDCMDocumentManager(document);
+ if(tldcmDocumentManager!=null) {
+ List<TaglibTracker> taglibs_JSP = tldcmDocumentManager.getTaglibTrackers();
+ for (TaglibTracker taglibTracker : taglibs_JSP) {
+ addTaglib(taglibData, taglibTracker.getURI(), taglibTracker.getPrefix(),
true,false);
+ }
+ }
+ return taglibData;
+ }
+ /**
* Processes taglib attribute
* @param taglibs
* @param attr