Author: vyemialyanchyk
Date: 2007-12-19 10:27:42 -0500 (Wed, 19 Dec 2007)
New Revision: 5371
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeEditorPart.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpePreviewDomBuilder.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeSourceDomBuilder.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/context/VpePageContext.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mapping/VpeDomMapping.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mapping/VpeElementMapping.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaEditor.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaPreview.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplateManager.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1457 http://jira.jboss.com/jira/browse/JBIDE-788
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2007-12-19
15:27:33 UTC (rev 5370)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2007-12-19
15:27:42 UTC (rev 5371)
@@ -211,8 +211,8 @@
domMapping = new VpeDomMapping(pageContext);
sourceBuilder = new VpeSourceDomBuilder(domMapping, this, sourceEditor, pageContext);
visualBuilder = new VpeVisualDomBuilder(domMapping, this, visualEditor, pageContext);
- pageContext.setSourceDomBuilder(sourceBuilder);
- pageContext.setVisualDomBuilder(visualBuilder);
+ pageContext.setSourceBuilder(sourceBuilder);
+ pageContext.setVisualBuilder(visualBuilder);
IDOMModel sourceModel = (IDOMModel)getModel();
if (sourceModel == null) {
return;
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeEditorPart.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeEditorPart.java 2007-12-19
15:27:33 UTC (rev 5370)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeEditorPart.java 2007-12-19
15:27:42 UTC (rev 5371)
@@ -356,6 +356,7 @@
if (null != previewContent) {
if (flagPC) {
getWB();
+ getWB().rebuildDom();
}
previewContent.setVisible(flagPC);
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpePreviewDomBuilder.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpePreviewDomBuilder.java 2007-12-19
15:27:33 UTC (rev 5370)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpePreviewDomBuilder.java 2007-12-19
15:27:42 UTC (rev 5371)
@@ -66,7 +66,11 @@
boolean registerFlag = isCurrentMainDocument();
switch (sourceNode.getNodeType()) {
case Node.ELEMENT_NODE:
+ /**/
+ // vitali TODO: this is wrong temporary way - get rid of it
+ //-
Map xmlnsMap = createXmlns((Element)sourceNode);
+ /**/
Set ifDependencySet = new HashSet();
getPageContext().setCurrentVisualNode(visualOldContainer);
VpeTemplateManager templateManager = VpeTemplateManager.getInstance();
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeSourceDomBuilder.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeSourceDomBuilder.java 2007-12-19
15:27:33 UTC (rev 5370)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeSourceDomBuilder.java 2007-12-19
15:27:42 UTC (rev 5371)
@@ -386,7 +386,7 @@
return structuredTextViewer;
}
- Document getSourceDocument() {
+ public Document getSourceDocument() {
return sourceDocument;
}
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java 2007-12-19
15:27:33 UTC (rev 5370)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java 2007-12-19
15:27:42 UTC (rev 5371)
@@ -185,8 +185,7 @@
if (input instanceof IFileEditorInput) {
IFile file = ((IFileEditorInput) input).getFile();
if (file != null) {
- includeStack.add(new VpeIncludeInfo(null, file, visualEditor.getController()
- .getSourceBuilder().getSourceDocument()));
+ includeStack.add(new VpeIncludeInfo(null, file, visualEditor.getSourceDocument()));
}
}
pageContext.installIncludeElements();
@@ -360,7 +359,11 @@
boolean registerFlag = isCurrentMainDocument();
switch (sourceNode.getNodeType()) {
case Node.ELEMENT_NODE:
+ /**/
+ // vitali TODO: this is wrong temporary way - get rid of it
+ //-
Map<?, ?> xmlnsMap = createXmlns((Element) sourceNode);
+ /**/
Set<Node> ifDependencySet = new HashSet<Node>();
pageContext.setCurrentVisualNode(visualOldContainer);
VpeTemplateManager templateManager = VpeTemplateManager.getInstance();
@@ -395,7 +398,11 @@
VpeElementMapping elementMapping = new VpeElementMapping(
(Element) sourceNode, visualNewElement, border,
template, ifDependencySet, creationData.getData());
+ /**/
+ // vitali TODO: this is wrong temporary way - get rid of it
+ //-
elementMapping.setXmlnsMap(xmlnsMap);
+ /**/
registerNodes(elementMapping);
}
if (template.isChildren()) {
@@ -900,7 +907,11 @@
updateElement(sourceElement);
}
}
+ /**/
+ // vitali TODO: this is wrong temporary way - get rid of it
+ //-
setXmlnsAttribute(elementMapping, name, value);
+ /**/
template.setAttribute(pageContext, sourceElement,
visualDocument, visualElement, elementMapping
.getData(), name, value);
@@ -1006,7 +1017,11 @@
name, null)) {
updateElement(sourceElement);
} else {
+ /**/
+ // vitali TODO: this is wrong temporary way - get rid of it
+ //-
removeXmlnsAttribute(elementMapping, name);
+ /**/
template.removeAttribute(pageContext, sourceElement,
visualDocument, (nsIDOMElement) elementMapping
.getVisualNode(), elementMapping.getData(),
@@ -1872,6 +1887,9 @@
pageContext.dispose();
}
+ /**/
+ // vitali TODO: this is wrong temporary way - get rid of it
+ //-
protected Map createXmlns(Element sourceNode) {
NamedNodeMap attrs = ((Element) sourceNode).getAttributes();
if (attrs != null) {
@@ -1886,7 +1904,11 @@
}
return null;
}
+ /**/
+ /**/
+ // vitali TODO: this is wrong temporary way - get rid of it
+ //-
private void setXmlnsAttribute(VpeElementMapping elementMapping,
String name, String value) {
Element sourceElement = (Element) elementMapping.getSourceNode();
@@ -1898,7 +1920,11 @@
elementMapping.setXmlnsMap(xmlnsMap.size() > 0 ? xmlnsMap : null);
}
}
+ /**/
+ /**/
+ // vitali TODO: this is wrong temporary way - get rid of it
+ //-
private void removeXmlnsAttribute(VpeElementMapping elementMapping,
String name) {
Element sourceElement = (Element) elementMapping.getSourceNode();
@@ -1915,16 +1941,22 @@
}
}
}
+ /**/
+ /**/
+ // vitali TODO: this is wrong temporary way - get rid of it
+ //-
private void addTaglib(Element sourceElement, Map xmlnsMap,
String attrName, boolean ns) {
Attr attr = sourceElement.getAttributeNode(attrName);
if (ATTR_XMLNS.equals(attr.getPrefix())) {
- xmlnsMap.put(attr.getNodeName(), Integer.valueOf(attr.hashCode()));
+ //vitali
+ //xmlnsMap.put(attr.getNodeName(), Integer.valueOf(attr.hashCode()));
pageContext.setTaglib(attr.hashCode(), attr.getNodeValue(), attr
.getLocalName(), ns);
}
}
+ /**/
/**
* @return the dnd
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/context/VpePageContext.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/context/VpePageContext.java 2007-12-19
15:27:33 UTC (rev 5370)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/context/VpePageContext.java 2007-12-19
15:27:42 UTC (rev 5371)
@@ -82,6 +82,7 @@
IVisualContext visualContext;
public void setVisualContext(IVisualContext visualContext) {
this.visualContext = visualContext;
+ VpeTemplateManager.getInstance().initVisualContext(visualContext);
}
public IVisualContext getVisualContext() {
return visualContext;
@@ -107,26 +108,21 @@
this.editPart = editPart;
}
- //public VpeSourceDomBuilder getSourceBuilder(){
- // return sourceBuilder;
- //}
-
- // vitali: delete this function with the class
- public void setSourceDomBuilder(VpeSourceDomBuilder sourceBuilder) {
+ //+
+ public void setSourceBuilder(VpeSourceDomBuilder sourceBuilder) {
this.sourceBuilder = sourceBuilder;
- //refreshConnector();
}
+ //+
public VpeSourceDomBuilder getSourceBuilder() {
return sourceBuilder;
}
- // vitali: delete this function with the class - use VpeController
+ //+
public VpeVisualDomBuilder getVisualBuilder(){
return visualBuilder;
}
-
- // vitali: delete this function with the class - delete from MozillaPreview
- public void setVisualDomBuilder(VpeVisualDomBuilder visualBuilder) {
+ //+
+ public void setVisualBuilder(VpeVisualDomBuilder visualBuilder) {
this.visualBuilder = visualBuilder;
}
@@ -150,6 +146,7 @@
}
// vitali: delete this function with the class - from all places
+ //-
public void setTaglib(int id, String newUri, String newPrefix, boolean ns) {
for (int i = 0; i < taglibs.size(); i++) {
TaglibData taglib = (TaglibData)taglibs.get(i);
@@ -171,13 +168,19 @@
rebuildTaglibMap();
}
}
-
- // vitali: put taglibMap to VpeTemplateManager
+
+ //+
public String getTemplateTaglibPrefix(String sourceTaglibPrefix) {
+ // vitali TODO: this is wrong temporary way - get rid of it
return (String) taglibMap.get(sourceTaglibPrefix);
+ // vitali TODO: this is right way to use - for refactoring
+ //return getVisualContext().getTemplateTaglibPrefix(sourceTaglibPrefix);
}
+ //-
private void rebuildTaglibMap() {
+ /**/
+ // vitali TODO: this is wrong temporary way - get rid of it
taglibMap.clear();
VpeTemplateManager templateManager = VpeTemplateManager.getInstance();
Set prefixSet = new HashSet();
@@ -193,7 +196,6 @@
}
}
taglibChanged = true;
-
/** /
try {
registerTaglibs(connector, this,
getSourceBuilder().getStructuredTextViewer().getDocument());
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mapping/VpeDomMapping.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mapping/VpeDomMapping.java 2007-12-19
15:27:33 UTC (rev 5370)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mapping/VpeDomMapping.java 2007-12-19
15:27:42 UTC (rev 5371)
@@ -281,6 +281,9 @@
}
if (nodeMapping.getType() == VpeNodeMapping.ELEMENT_MAPPING) {
VpeElementMapping elementMapping = (VpeElementMapping)nodeMapping;
+ /**/
+ // vitali TODO: this is wrong temporary way - get rid of it
+ //-
Map xmlnsMap = elementMapping.getXmlnsMap();
if (xmlnsMap != null) {
for (Iterator iter = xmlnsMap.values().iterator(); iter.hasNext();) {
@@ -288,6 +291,7 @@
}
elementMapping.setXmlnsMap(null);
}
+ /**/
if (elementMapping.getBorder() != null) {
visualMap.remove(elementMapping.getBorder());
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mapping/VpeElementMapping.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mapping/VpeElementMapping.java 2007-12-19
15:27:33 UTC (rev 5370)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mapping/VpeElementMapping.java 2007-12-19
15:27:42 UTC (rev 5371)
@@ -22,7 +22,11 @@
public class VpeElementMapping extends VpeNodeMapping {
private VpeTemplate template;
private Set ifDependencySet;
+ /**/
+ //vitali
+ //-
private Map xmlnsMap;
+ /**/
private Object data;
private nsIDOMElement border;
@@ -44,13 +48,19 @@
return template;
}
+ /**/
+ // vitali TODO: this is wrong temporary way - get rid of it
+ //-
public Map getXmlnsMap() {
return xmlnsMap;
}
+ // vitali TODO: this is wrong temporary way - get rid of it
+ //-
public void setXmlnsMap(Map xmlnsMap) {
this.xmlnsMap = xmlnsMap;
}
+ /**/
public Object getData() {
return data;
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaEditor.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaEditor.java 2007-12-19
15:27:33 UTC (rev 5370)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaEditor.java 2007-12-19
15:27:42 UTC (rev 5371)
@@ -43,6 +43,7 @@
import org.eclipse.ui.browser.IWorkbenchBrowserSupport;
import org.eclipse.ui.editors.text.ILocationProvider;
import org.eclipse.ui.part.EditorPart;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
import org.jboss.tools.vpe.VpePlugin;
import org.jboss.tools.vpe.editor.VpeController;
import org.jboss.tools.vpe.editor.css.VpeResourcesDialog;
@@ -63,6 +64,7 @@
import org.mozilla.interfaces.nsIDOMNodeList;
import org.mozilla.interfaces.nsISelection;
import org.mozilla.interfaces.nsISelectionPrivate;
+import org.w3c.dom.Document;
public class MozillaEditor extends EditorPart implements IReusableEditor {
protected static final String INIT_URL = "file://" + (new
File(VpePlugin.getDefault().getResourcePath("ve"),
"init.html")).getAbsolutePath();
@@ -559,6 +561,20 @@
return controller;
}
+ public IDOMDocument getSourceDocument() {
+ if (null == getController()) {
+ return null;
+ }
+ if (null == getController().getSourceBuilder()) {
+ return null;
+ }
+ Document doc = getController().getSourceBuilder().getSourceDocument();
+ if (doc instanceof IDOMDocument) {
+ return (IDOMDocument)doc;
+ }
+ return null;
+ }
+
/**
* @return the link
*/
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaPreview.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaPreview.java 2007-12-19
15:27:33 UTC (rev 5370)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaPreview.java 2007-12-19
15:27:42 UTC (rev 5371)
@@ -27,6 +27,8 @@
import org.eclipse.wst.sse.ui.StructuredTextEditor;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
+import org.jboss.tools.jst.jsp.editor.IJSPTextEditor;
+import org.jboss.tools.jst.jsp.editor.IVisualContext;
import org.jboss.tools.vpe.VpePlugin;
import org.jboss.tools.vpe.editor.VpeEditorPart;
import org.jboss.tools.vpe.editor.VpePreviewDomBuilder;
@@ -151,9 +153,8 @@
//TODO Max Areshkau logic error (we should first call buildDom and only then we can call
rebuildDom)
public void rebuildDom() {
- if(getPageContext()!=null&&getPageContext().getVisualBuilder()!=null&&getSourceDocument()!=null)
{
-
- getPageContext().getVisualBuilder().rebuildDom(getSourceDocument());
+ if (null != pageContext && null != pageContext.getVisualBuilder() &&
null != getSourceDocument()) {
+ pageContext.getVisualBuilder().rebuildDom(getSourceDocument());
}
}
@@ -162,13 +163,15 @@
BundleMap bundle = new BundleMap();
bundle.init(getSourceEditor());
- setPageContext(new VpePageContext(bundle, getEditPart()));
+ pageContext = new VpePageContext(bundle, getEditPart());
- VpeDomMapping domMapping = new VpeDomMapping(getPageContext());
- VpeSourceDomBuilder sourceBuilder = new VpeSourceDomBuilder(domMapping, null,
getSourceEditor(), getPageContext());
- VpeVisualDomBuilder visualBuilder = new VpePreviewDomBuilder(domMapping, null, this,
getPageContext());
- getPageContext().setSourceDomBuilder(sourceBuilder);
- getPageContext().setVisualDomBuilder(visualBuilder);
+ // vitali - temp solution
+ pageContext.setVisualContext(getPageContext());
+ VpeDomMapping domMapping = new VpeDomMapping(pageContext);
+ VpeSourceDomBuilder sourceBuilder = new VpeSourceDomBuilder(domMapping, null,
getSourceEditor(), pageContext);
+ VpeVisualDomBuilder visualBuilder = new VpePreviewDomBuilder(domMapping, null, this,
pageContext);
+ pageContext.setSourceBuilder(sourceBuilder);
+ pageContext.setVisualBuilder(visualBuilder);
IDOMModel sourceModel = (IDOMModel)getSourceEditor().getModel();
setSourceDocument(sourceModel.getDocument());
@@ -179,7 +182,7 @@
/**
* @return the sourceDocument
*/
- protected IDOMDocument getSourceDocument() {
+ public IDOMDocument getSourceDocument() {
return sourceDocument;
}
@@ -190,27 +193,15 @@
this.sourceDocument = sourceDocument;
}
-
-
- /**
- * @return the pageContext
- */
- private VpePageContext getPageContext() {
- return pageContext;
+ public IVisualContext getPageContext() {
+ IVisualContext visualContext = null;
+ if (sourceEditor instanceof IJSPTextEditor) {
+ visualContext = ((IJSPTextEditor)sourceEditor).getPageContext();
+ }
+ return visualContext;
}
-
-
/**
- * @param pageContext the pageContext to set
- */
- private void setPageContext(VpePageContext pageContext) {
- this.pageContext = pageContext;
- }
-
-
-
- /**
* @return the editPart
*/
private VpeEditorPart getEditPart() {
@@ -218,7 +209,6 @@
}
-
/**
* @param editPart the editPart to set
*/
@@ -233,8 +223,6 @@
return sourceEditor;
}
-
-
/**
* @param sourceEditor the sourceEditor to set
*/
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplateManager.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplateManager.java 2007-12-19
15:27:33 UTC (rev 5370)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplateManager.java 2007-12-19
15:27:42 UTC (rev 5371)
@@ -32,6 +32,7 @@
import org.w3c.dom.NodeList;
import org.jboss.tools.common.xml.XMLUtilities;
+import org.jboss.tools.jst.jsp.editor.IVisualContext;
import org.jboss.tools.vpe.VpePlugin;
import org.jboss.tools.vpe.editor.context.VpePageContext;
@@ -793,4 +794,8 @@
defTemplate.init(createDefTemplateElement(), true);
return defTemplate;
}
+
+ public void initVisualContext(IVisualContext visualContext) {
+ visualContext.setTemplateTaglibs(templateTaglibs);
+ }
}