Author: vyemialyanchyk
Date: 2007-12-20 14:20:25 -0500 (Thu, 20 Dec 2007)
New Revision: 5414
Added:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/context/VpePageContext.java
Removed:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/context/VpePageContext.java
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/VpeElementMapping.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaDomEventListener.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/dnd/VpeDnd.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionSrc.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/resize/VpeResizer.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/toolbar/format/FormatControllerManager.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/toolbar/format/handler/BlockFormatHandler.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/toolbar/format/handler/SimpleTagHandler.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/selbar/SelectionBar.java
Log:
code revert
http://jira.jboss.com/jira/browse/JBIDE-1457 and
http://jira.jboss.com/jira/browse/JBIDE-788
Deleted:
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-20
18:14:12 UTC (rev 5413)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/context/VpePageContext.java 2007-12-20
19:20:25 UTC (rev 5414)
@@ -1,490 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and 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:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.vpe.editor.context;
-
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-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.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.IFileEditorInput;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.ide.IDE;
-import org.eclipse.wst.xml.core.internal.document.ElementImpl;
-import org.jboss.tools.common.kb.KbConnectorFactory;
-import org.jboss.tools.common.kb.KbConnectorType;
-import org.jboss.tools.common.kb.KbTldResource;
-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.XModel;
-import org.jboss.tools.common.model.project.IModelNature;
-import org.jboss.tools.common.model.util.EclipseResourceUtil;
-import org.jboss.tools.jst.jsp.editor.IVisualContext;
-import org.jboss.tools.jst.jsp.editor.TLDRegisterHelper;
-import org.jboss.tools.jst.jsp.preferences.VpePreference;
-import org.jboss.tools.jst.web.tld.TaglibData;
-import org.jboss.tools.jst.web.tld.VpeTaglibListener;
-import org.jboss.tools.jst.web.tld.VpeTaglibManager;
-import org.jboss.tools.vpe.VpeDebug;
-import org.jboss.tools.vpe.VpePlugin;
-import org.jboss.tools.vpe.editor.VpeEditorPart;
-import org.jboss.tools.vpe.editor.VpeSourceDomBuilder;
-import org.jboss.tools.vpe.editor.VpeVisualDomBuilder;
-import org.jboss.tools.vpe.editor.bundle.BundleMap;
-import org.jboss.tools.vpe.editor.css.AbsoluteFolderReferenceList;
-import org.jboss.tools.vpe.editor.css.CSSReferenceList;
-import org.jboss.tools.vpe.editor.css.RelativeFolderReferenceList;
-import org.jboss.tools.vpe.editor.css.ResourceReference;
-import org.jboss.tools.vpe.editor.css.TaglibReferenceList;
-import org.jboss.tools.vpe.editor.mapping.VpeDomMapping;
-import org.jboss.tools.vpe.editor.template.VpeTemplateManager;
-import org.jboss.tools.vpe.editor.util.FileUtil;
-import org.mozilla.interfaces.nsIDOMNode;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-/**
- * Contains the information on edited page.
- */
-
-// vitali: Attention!!! this is refactoring intermediate version
-// because of bugfixing
-//
http://jira.jboss.com/jira/browse/JBIDE-788 and
-//
http://jira.jboss.com/jira/browse/JBIDE-1457
-
-//public class VpePageContext implements IVisualContext {
-public class VpePageContext {
-
- // vitali: time solution - set connector from JSPTextEditorPageContext
- public WtpKbConnector getConnector() {
- return getVisualContext().getConnector();
- }
- IVisualContext visualContext;
- public void setVisualContext(IVisualContext visualContext) {
- this.visualContext = visualContext;
- VpeTemplateManager.getInstance().initVisualContext(visualContext);
- }
- public IVisualContext getVisualContext() {
- return visualContext;
- }
-
-
-
- private ArrayList taglibs = new ArrayList();
- private Map taglibMap = new HashMap();
- private VpeTaglibListener[] taglibListeners = new VpeTaglibListener[0];
- private BundleMap bundle;
- private Set bundleDependencySet = new HashSet();
- private VpeSourceDomBuilder sourceBuilder;
- private VpeVisualDomBuilder visualBuilder;
- private VpeEditorPart editPart;
- private List lastTaglibs = new ArrayList();
- private boolean taglibChanged = false;
- WtpKbConnector connector;
- private nsIDOMNode currentVisualNode;
-
- public VpePageContext(BundleMap bundle, VpeEditorPart editPart) {
- this.bundle = bundle;
- this.editPart = editPart;
- }
-
- //+
- public void setSourceBuilder(VpeSourceDomBuilder sourceBuilder) {
- this.sourceBuilder = sourceBuilder;
- }
- //+
- public VpeSourceDomBuilder getSourceBuilder() {
- return sourceBuilder;
- }
-
- //+
- public VpeVisualDomBuilder getVisualBuilder(){
- return visualBuilder;
- }
- //+
- public void setVisualBuilder(VpeVisualDomBuilder visualBuilder) {
- this.visualBuilder = visualBuilder;
- }
-
- // vitali: delete this function with the class - use
VpeController->getVisualBuilder()
- public VpeDomMapping getDomMapping () {
- return visualBuilder.getDomMapping();
- }
-
- // vitali: delete this function with the class
- public void clearAll() {
- taglibs.clear();
- taglibMap.clear();
- bundleDependencySet.clear();
- bundle.clearAll();
- }
-
- // vitali: delete this function with the class
- public void dispose() {
- bundle.dispose();
- clearAll();
- }
-
- // 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);
- if (taglib.getId() == id) {
- if (newUri != null && newPrefix != null) {
- if (!newUri.equals(taglib.getUri()) || !newPrefix.equals(taglib.getPrefix())) {
- taglibs.set(i, new TaglibData(id, newUri, newPrefix, ns));
- rebuildTaglibMap();
- }
- } else {
- taglibs.remove(i);
- rebuildTaglibMap();
- }
- return;
- }
- }
- if (newUri != null && newPrefix != null) {
- taglibs.add(new TaglibData(id, newUri, newPrefix, ns));
- rebuildTaglibMap();
- }
- }
-
- //+
- 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();
- for (int i = 0; i < taglibs.size(); i++) {
- TaglibData taglib = (TaglibData)taglibs.get(i);
- String prefix = taglib.getPrefix();
- if (!prefixSet.contains(prefix)) {
- String templatePrefix = templateManager.getTemplateTaglibPrefix(taglib.getUri());
- if (templatePrefix != null) {
- taglibMap.put(prefix, templatePrefix);
- }
- prefixSet.add(prefix);
- }
- }
- taglibChanged = true;
- /** /
- try {
- registerTaglibs(connector, this,
getSourceBuilder().getStructuredTextViewer().getDocument());
- } catch (Exception e) {
- VpePlugin.getPluginLog().logError(e);
- }
- /**/
- }
-
- /** /
- // vitali: parent
- public void addTaglibListener(VpeTaglibListener listener) {
- if (listener != null) {
- VpeTaglibListener[] newTaglibListeners = new VpeTaglibListener[taglibListeners.length
+ 1];
- System.arraycopy(taglibListeners, 0, newTaglibListeners, 0, taglibListeners.length);
- taglibListeners = newTaglibListeners;
- taglibListeners[taglibListeners.length - 1] = listener;
- }
- }
-
- // vitali: parent
- public void removeTaglibListener(VpeTaglibListener listener) {
- if (listener == null || taglibListeners.length == 0) return;
- int index = -1;
- for (int i = 0; i < taglibListeners.length; i++) {
- if (listener == taglibListeners[i]){
- index = i;
- break;
- }
- }
- if (index == -1) return;
- if (taglibListeners.length == 1) {
- taglibListeners = new VpeTaglibListener[0];
- return;
- }
- VpeTaglibListener[] newTaglibListeners = new VpeTaglibListener[taglibListeners.length -
1];
- System.arraycopy(taglibListeners, 0, newTaglibListeners, 0, index);
- System.arraycopy(taglibListeners, index + 1, newTaglibListeners, index,
taglibListeners.length - index - 1);
- taglibListeners = newTaglibListeners;
- }
- /**/
-
- // vitali: delete this function with the class - save and getBundle() from other place
- // for examle visualBuilder
- public BundleMap getBundle() {
- return bundle;
- }
-
- // vitali: delete this function with the class - save and getBundle() from other place
- // for examle visualBuilder
- public void addBundleDependency(Element sourceNode) {
- bundleDependencySet.add(sourceNode);
- }
-
- // vitali: delete this function with the class - save and getBundle() from other place
- // for examle visualBuilder
- public void removeBundleDependency(Element sourceNode) {
- bundleDependencySet.remove(sourceNode);
- }
-
- /** /
- // vitali: parent
- public void refreshBundleValues() {
- Iterator iterator = bundleDependencySet.iterator();
- while (iterator.hasNext()) {
- Element sourceElement = (Element) iterator.next();
- visualBuilder.refreshBundleValues(sourceElement);
- }
- }
- /**/
-
- // vitali: put this function in to JSPTextEditorPageContext
- // VpeController ask JSPTextEditorPageContext via sourceEditor
- public boolean isCorrectNS(Node sourceNode) {
- String sourcePrefix = sourceNode.getPrefix();
- if (sourcePrefix == null || ((ElementImpl)sourceNode).isJSPTag()) {
- return true;
- }
- for (int i = 0; i < taglibs.size(); i++) {
- TaglibData taglib = (TaglibData)taglibs.get(i);
- if (sourcePrefix.equals(taglib.getPrefix())) {
- return true;
- }
- }
- return false;
- }
-
- // vitali: 2 places - RichFacesDataDefinitionListTemplate & VpeController
- // should implement this function & get taglibs from
sourceEditor->JSPTextEditorPageContext
- public String getSourceTaglibUri(Node sourceNode) {
- String sourcePrefix = sourceNode.getPrefix();
- if (sourcePrefix == null || ((ElementImpl)sourceNode).isJSPTag()) {
- return null;
- }
- for (int i = 0; i < taglibs.size(); i++) {
- TaglibData taglib = (TaglibData)taglibs.get(i);
- if (sourcePrefix.equals(taglib.getPrefix())) {
- return taglib.getUri();
- }
- }
- return null;
- }
-
- // vitali: 24 places - !!! use other way to get VpeEditorPart
- public VpeEditorPart getEditPart() {
- return editPart;
- }
-
- // vitali: this is not right place to the function - put in into editPart -
VpeEditorPart
- public void openIncludeFile(String file) {
- IEditorInput input = editPart.getEditorInput();
- IWorkbenchPage workbenchPage =
VpePlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
- try{
- IFile f = FileUtil.getFile(input, file);
- if (f != null) {
- IDE.openEditor(workbenchPage, f, true);
- }
- }catch(Exception ex){
- VpePlugin.reportProblem(ex);
- }
- }
-
- // vitali: public - can be protected!
- protected ResourceReference[] getIncludeTaglibs() {
- IEditorInput input = getEditPart().getEditorInput();
- IFile file = null;
- if (input instanceof IFileEditorInput) {
- file = ((IFileEditorInput)input).getFile();
- }
- ResourceReference[] resourceReferences = new ResourceReference[0];
- if (file != null) {
- resourceReferences = TaglibReferenceList.getInstance().getAllResources(file);
- }
- return resourceReferences;
- }
-
- // vitali: public - can be protected!
- protected ResourceReference[] getIncludeCss() {
- IEditorInput input = getEditPart().getEditorInput();
- IFile file = null;
- if (input instanceof IFileEditorInput) {
- file = ((IFileEditorInput)input).getFile();
- }
- ResourceReference[] resourceReferences = new ResourceReference[0];
- if (file != null) {
- resourceReferences = CSSReferenceList.getInstance().getAllResources(file);
- }
- return resourceReferences;
- }
-
- // vitali: 1 place - VpeVisualDomBuilder - put this into VpeVisualDomBuilder
- // and getIncludeTaglibs and getIncludeCss
- public void installIncludeElements() {
- ResourceReference[] list = getIncludeTaglibs();
- for (int i = 0; i < list.length; i++) {
- ResourceReference reference = list[i];
- setTaglib(i, reference.getLocation(), reference.getProperties(), false);
- }
-
- list = getIncludeCss();
- for (int i = 0; i < list.length; i++) {
- visualBuilder.addLinkNodeToHead(list[i].getLocation(), "yes");
- }
- }
-
- /** /
- // vitali: parent
- public List<TaglibData> getTagLibs() {
- List<TaglibData> clone = new ArrayList<TaglibData>();
- Iterator iter = taglibs.iterator();
- while (iter.hasNext()) {
- TaglibData taglib = (TaglibData)iter.next();
- if (!taglib.inList(clone)) {
- clone.add(taglib);
- }
- }
- return clone;
- }
- /**/
-
- // vitali: public
- private boolean buildTaglibsDifferences(List newTaglibs, List delTaglibs) {
- Iterator lastIter = lastTaglibs.iterator();
- while (lastIter.hasNext()) {
- TaglibData oldTaglib = (TaglibData)lastIter.next();
- Iterator newIter = newTaglibs.iterator();
- while (newIter.hasNext()) {
- if (oldTaglib.isEquals((TaglibData)newIter.next())) {
- newIter.remove();
- oldTaglib = null;
- break;
- }
- }
- if (oldTaglib != null) {
- delTaglibs.add(oldTaglib);
- }
- }
- return newTaglibs.size() > 0 || delTaglibs.size() > 0;
- }
-
- /** /
- // vitali: 5 places - all in VpeController -
- public void fireTaglibsChanged() {
- List newTaglibs = getTagLibs();
- List delTaglibs = new ArrayList();
- if (buildTaglibsDifferences(newTaglibs, delTaglibs)) {
- if (VpeDebug.PRINT_SOURCE_MUTATION_EVENT) {
- System.out.println(">>> TaglibsChanged");
- }
- for (int i = 0; i < taglibListeners.length; i++) {
- taglibListeners[i].taglibPrefixChanged(null);
- fireTaglibChanged(taglibListeners[i], newTaglibs, delTaglibs);
- }
- lastTaglibs = getTagLibs();
- }
- taglibChanged = false;
- }
- /**/
-
- private void fireTaglibChanged(VpeTaglibListener taglibListener, List newTaglibs, List
delTaglibs) {
- Iterator iter = delTaglibs.iterator();
- while (iter.hasNext()) {
- TaglibData taglib = (TaglibData)iter.next();
- taglibListener.removeTaglib(taglib.getUri(), taglib.getPrefix());
- }
- iter = newTaglibs.iterator();
- while (iter.hasNext()) {
- TaglibData taglib = (TaglibData)iter.next();
- taglibListener.addTaglib(taglib.getUri(), taglib.getPrefix());
- }
- }
-
- // vitali: 1 place VpeController -
- public boolean isTaglibChanged() {
- if (!taglibChanged) return false;
- //vitali
- List newTaglibs = null;//getTagLibs();
- List delTaglibs = new ArrayList();
- return buildTaglibsDifferences(newTaglibs, delTaglibs);
- }
-
- /** /
- // vitali: parent
- public WtpKbConnector getConnector() {
- return connector;
- }
- /**/
-
- boolean registerTaglibs(WtpKbConnector wtpKbConnector, VpeTaglibManager taglibManager,
IDocument document) {
- if(wtpKbConnector == null) return false;
- TLDCMDocumentManager manager = TaglibController.getTLDCMDocumentManager(document);
- if(taglibManager != null) {
- List list = taglibManager.getTagLibs();
- if(list != null) {
- Iterator it = list.iterator();
- while(it.hasNext()) {
- TaglibData data = (TaglibData)it.next();
- IEditorInput ei = editPart.getEditorInput();
- TLDRegisterHelper.registerTld(data, (JspWtpKbConnector)wtpKbConnector, document,
ei);
- }
- return true;
- }
- }
- if(manager != null) {
- List list = manager.getTaglibTrackers();
- for (int i = 0; i < list.size(); i++) {
- TaglibTracker tracker = (TaglibTracker)list.get(i);
- if(tracker == null) continue;
- String version = TLDVersionHelper.getTldVersion(tracker);
- KbTldResource resource = new KbTldResource(tracker.getURI(), "",
tracker.getPrefix(), version);
- wtpKbConnector.registerResource(resource);
- }
- return true;
- }
- return false;
- }
-
- // vitali: 2 places - VpeDataTableColumnCreator & VpeDataTableCreator
- public nsIDOMNode getCurrentVisualNode() {
- return currentVisualNode;
- }
-
- // vitali: 8 places in VpePreviewDomBuilder & VpeVisualDomBuilder
- // use - setCurrentVisualNode(XXX)
- // - getCurrentVisualNode()
- // then - setCurrentVisualNode(null)
- // just use other way to send current node as parameter
- public void setCurrentVisualNode(nsIDOMNode currentVisualNode) {
- this.currentVisualNode = currentVisualNode;
- }
-
-}
Copied:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/context/VpePageContext.java
(from rev 5352,
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
(rev 0)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/context/VpePageContext.java 2007-12-20
19:20:25 UTC (rev 5414)
@@ -0,0 +1,443 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.vpe.editor.context;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+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.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.IFileEditorInput;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.ide.IDE;
+import org.eclipse.wst.xml.core.internal.document.ElementImpl;
+import org.jboss.tools.common.kb.KbConnectorFactory;
+import org.jboss.tools.common.kb.KbConnectorType;
+import org.jboss.tools.common.kb.KbTldResource;
+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.XModel;
+import org.jboss.tools.common.model.project.IModelNature;
+import org.jboss.tools.common.model.util.EclipseResourceUtil;
+import org.jboss.tools.jst.jsp.editor.IVisualContext;
+import org.jboss.tools.jst.jsp.editor.TLDRegisterHelper;
+import org.jboss.tools.jst.jsp.preferences.VpePreference;
+import org.jboss.tools.jst.web.tld.TaglibData;
+import org.jboss.tools.jst.web.tld.VpeTaglibListener;
+import org.jboss.tools.jst.web.tld.VpeTaglibManager;
+import org.jboss.tools.vpe.VpeDebug;
+import org.jboss.tools.vpe.VpePlugin;
+import org.jboss.tools.vpe.editor.VpeEditorPart;
+import org.jboss.tools.vpe.editor.VpeSourceDomBuilder;
+import org.jboss.tools.vpe.editor.VpeVisualDomBuilder;
+import org.jboss.tools.vpe.editor.bundle.BundleMap;
+import org.jboss.tools.vpe.editor.css.AbsoluteFolderReferenceList;
+import org.jboss.tools.vpe.editor.css.CSSReferenceList;
+import org.jboss.tools.vpe.editor.css.RelativeFolderReferenceList;
+import org.jboss.tools.vpe.editor.css.ResourceReference;
+import org.jboss.tools.vpe.editor.css.TaglibReferenceList;
+import org.jboss.tools.vpe.editor.mapping.VpeDomMapping;
+import org.jboss.tools.vpe.editor.template.VpeTemplateManager;
+import org.jboss.tools.vpe.editor.util.FileUtil;
+import org.mozilla.interfaces.nsIDOMNode;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ * Contains the information on edited page.
+ */
+
+public class VpePageContext implements VpeTaglibManager, IVisualContext {
+ private VpeTemplateManager templateManager;
+ private ArrayList taglibs = new ArrayList();
+ private Map taglibMap = new HashMap();
+ private VpeTaglibListener[] taglibListeners = new VpeTaglibListener[0];
+ private BundleMap bundle;
+ private Set bundleDependencySet = new HashSet();
+ private VpeSourceDomBuilder sourceBuilder;
+ private VpeVisualDomBuilder visualBuilder;
+ private VpeEditorPart editPart;
+ private List lastTaglibs = new ArrayList();
+ private boolean taglibChanged = false;
+ WtpKbConnector connector;
+ private nsIDOMNode currentVisualNode;
+
+ public VpePageContext(VpeTemplateManager templateManager, BundleMap bundle,
VpeEditorPart editPart) {
+ this.templateManager = templateManager;
+ this.bundle = bundle;
+ this.editPart = editPart;
+ }
+
+ public VpeSourceDomBuilder getSourceBuilder(){
+ return sourceBuilder;
+ }
+
+ public boolean isAbsolutePosition(){
+ if("yes".equals(VpePreference.USE_ABSOLUTE_POSITION.getValue()))return true;
+ else return false;
+ }
+
+ public void setSourceDomBuilder(VpeSourceDomBuilder sourceBuilder) {
+ this.sourceBuilder = sourceBuilder;
+ refreshConnector();
+ }
+
+ public void refreshConnector() {
+ try {
+ IDocument document = sourceBuilder.getStructuredTextViewer().getDocument();
+ connector =
(WtpKbConnector)KbConnectorFactory.getIntstance().createConnector(KbConnectorType.JSP_WTP_KB_CONNECTOR,
document);
+ } catch (Exception e) {
+ VpePlugin.getPluginLog().logError(e);
+ }
+ }
+
+ public VpeVisualDomBuilder getVisualBuilder(){
+ return visualBuilder;
+ }
+
+ public void setVisualDomBuilder(VpeVisualDomBuilder visualBuilder) {
+ this.visualBuilder = visualBuilder;
+ }
+
+ public VpeDomMapping getDomMapping () {
+ return visualBuilder.getDomMapping();
+ }
+
+ public void clearAll() {
+ taglibs.clear();
+ taglibMap.clear();
+ bundleDependencySet.clear();
+ bundle.clearAll();
+ }
+
+ public void dispose() {
+ bundle.dispose();
+ clearAll();
+ }
+
+ 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);
+ if (taglib.getId() == id) {
+ if (newUri != null && newPrefix != null) {
+ if (!newUri.equals(taglib.getUri()) || !newPrefix.equals(taglib.getPrefix())) {
+ taglibs.set(i, new TaglibData(id, newUri, newPrefix, ns));
+ rebuildTaglibMap();
+ }
+ } else {
+ taglibs.remove(i);
+ rebuildTaglibMap();
+ }
+ return;
+ }
+ }
+ if (newUri != null && newPrefix != null) {
+ taglibs.add(new TaglibData(id, newUri, newPrefix, ns));
+ rebuildTaglibMap();
+ }
+ }
+
+ public String getTemplateTaglibPrefix(String sourceTaglibPrefix) {
+ return (String) taglibMap.get(sourceTaglibPrefix);
+ }
+
+ private void rebuildTaglibMap() {
+ taglibMap.clear();
+ Set prefixSet = new HashSet();
+ for (int i = 0; i < taglibs.size(); i++) {
+ TaglibData taglib = (TaglibData)taglibs.get(i);
+ String prefix = taglib.getPrefix();
+ if (!prefixSet.contains(prefix)) {
+ String templatePrefix = templateManager.getTemplateTaglibPrefix(taglib.getUri());
+ if (templatePrefix != null) {
+ taglibMap.put(prefix, templatePrefix);
+ }
+ prefixSet.add(prefix);
+ }
+ }
+ taglibChanged = true;
+
+ try {
+ registerTaglibs(connector, this,
getSourceBuilder().getStructuredTextViewer().getDocument());
+ } catch (Exception e) {
+ VpePlugin.getPluginLog().logError(e);
+ }
+ }
+
+ public void addTaglibListener(VpeTaglibListener listener) {
+ if (listener != null) {
+ VpeTaglibListener[] newTaglibListeners = new VpeTaglibListener[taglibListeners.length
+ 1];
+ System.arraycopy(taglibListeners, 0, newTaglibListeners, 0, taglibListeners.length);
+ taglibListeners = newTaglibListeners;
+ taglibListeners[taglibListeners.length - 1] = listener;
+ }
+ }
+
+ public void removeTaglibListener(VpeTaglibListener listener) {
+ if (listener == null || taglibListeners.length == 0) return;
+ int index = -1;
+ for (int i = 0; i < taglibListeners.length; i++) {
+ if (listener == taglibListeners[i]){
+ index = i;
+ break;
+ }
+ }
+ if (index == -1) return;
+ if (taglibListeners.length == 1) {
+ taglibListeners = new VpeTaglibListener[0];
+ return;
+ }
+ VpeTaglibListener[] newTaglibListeners = new VpeTaglibListener[taglibListeners.length -
1];
+ System.arraycopy(taglibListeners, 0, newTaglibListeners, 0, index);
+ System.arraycopy(taglibListeners, index + 1, newTaglibListeners, index,
taglibListeners.length - index - 1);
+ taglibListeners = newTaglibListeners;
+ }
+
+ public BundleMap getBundle() {
+ return bundle;
+ }
+
+ public void addBundleDependency(Element sourceNode) {
+ bundleDependencySet.add(sourceNode);
+ }
+
+ public void removeBundleDependency(Element sourceNode) {
+ bundleDependencySet.remove(sourceNode);
+ }
+
+ public void refreshBundleValues() {
+ Iterator iterator = bundleDependencySet.iterator();
+ while (iterator.hasNext()) {
+ Element sourceElement = (Element) iterator.next();
+ visualBuilder.refreshBundleValues(sourceElement);
+ }
+ }
+
+ public boolean isCorrectNS(Node sourceNode) {
+ String sourcePrefix = sourceNode.getPrefix();
+ if (sourcePrefix == null || ((ElementImpl)sourceNode).isJSPTag()) {
+ return true;
+ }
+ for (int i = 0; i < taglibs.size(); i++) {
+ TaglibData taglib = (TaglibData)taglibs.get(i);
+ if (sourcePrefix.equals(taglib.getPrefix())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public String getSourceTaglibUri(Node sourceNode) {
+ String sourcePrefix = sourceNode.getPrefix();
+ if (sourcePrefix == null || ((ElementImpl)sourceNode).isJSPTag()) {
+ return null;
+ }
+ for (int i = 0; i < taglibs.size(); i++) {
+ TaglibData taglib = (TaglibData)taglibs.get(i);
+ if (sourcePrefix.equals(taglib.getPrefix())) {
+ return taglib.getUri();
+ }
+ }
+ return null;
+ }
+
+ public VpeEditorPart getEditPart() {
+ return editPart;
+ }
+
+ public void openIncludeFile(String file) {
+ IEditorInput input = editPart.getEditorInput();
+ IWorkbenchPage workbenchPage =
VpePlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ try{
+ IFile f = FileUtil.getFile(input, file);
+ if (f != null) {
+ IDE.openEditor(workbenchPage, f, true);
+ }
+ }catch(Exception ex){
+ VpePlugin.reportProblem(ex);
+ }
+ }
+
+ public ResourceReference[] getIncludeTaglibs() {
+ IEditorInput input = getEditPart().getEditorInput();
+ IFile file = null;
+ if (input instanceof IFileEditorInput) {
+ file = ((IFileEditorInput)input).getFile();
+ }
+ ResourceReference[] resourceReferences = new ResourceReference[0];
+ if (file != null) {
+ resourceReferences = TaglibReferenceList.getInstance().getAllResources(file);
+ }
+ return resourceReferences;
+ }
+
+ public ResourceReference[] getIncludeCss() {
+ IEditorInput input = getEditPart().getEditorInput();
+ IFile file = null;
+ if (input instanceof IFileEditorInput) {
+ file = ((IFileEditorInput)input).getFile();
+ }
+ ResourceReference[] resourceReferences = new ResourceReference[0];
+ if (file != null) {
+ resourceReferences = CSSReferenceList.getInstance().getAllResources(file);
+ }
+ return resourceReferences;
+ }
+
+ public void installIncludeElements() {
+ ResourceReference[] list = getIncludeTaglibs();
+ for (int i = 0; i < list.length; i++) {
+ ResourceReference reference = list[i];
+ setTaglib(i, reference.getLocation(), reference.getProperties(), false);
+ }
+
+ list = getIncludeCss();
+ for (int i = 0; i < list.length; i++) {
+ visualBuilder.addLinkNodeToHead(list[i].getLocation(), "yes");
+ }
+ }
+
+ public ResourceReference getRuntimeRelativeFolder(IFile file) {
+ ResourceReference[] list =
RelativeFolderReferenceList.getInstance().getAllResources(file);
+ if (list.length > 0) {
+ return list[list.length - 1];
+ }
+ return null;
+ }
+
+ public ResourceReference getRuntimeAbsoluteFolder(IFile file) {
+ ResourceReference[] list =
AbsoluteFolderReferenceList.getInstance().getAllResources(file);
+ if (list.length > 0) {
+ return list[list.length - 1];
+ }
+ return null;
+ }
+
+ public List<TaglibData> getTagLibs() {
+ List<TaglibData> clone = new ArrayList<TaglibData>();
+ Iterator iter = taglibs.iterator();
+ while (iter.hasNext()) {
+ TaglibData taglib = (TaglibData)iter.next();
+ if (!taglib.inList(clone)) {
+ clone.add(taglib);
+ }
+ }
+ return clone;
+ }
+
+ private boolean buildTaglibsDifferences(List newTaglibs, List delTaglibs) {
+ Iterator lastIter = lastTaglibs.iterator();
+ while (lastIter.hasNext()) {
+ TaglibData oldTaglib = (TaglibData)lastIter.next();
+ Iterator newIter = newTaglibs.iterator();
+ while (newIter.hasNext()) {
+ if (oldTaglib.isEquals((TaglibData)newIter.next())) {
+ newIter.remove();
+ oldTaglib = null;
+ break;
+ }
+ }
+ if (oldTaglib != null) {
+ delTaglibs.add(oldTaglib);
+ }
+ }
+ return newTaglibs.size() > 0 || delTaglibs.size() > 0;
+ }
+
+ public void fireTaglibsChanged() {
+ List newTaglibs = getTagLibs();
+ List delTaglibs = new ArrayList();
+ if (buildTaglibsDifferences(newTaglibs, delTaglibs)) {
+ if (VpeDebug.PRINT_SOURCE_MUTATION_EVENT) {
+ System.out.println(">>> TaglibsChanged");
+ }
+ for (int i = 0; i < taglibListeners.length; i++) {
+ taglibListeners[i].taglibPrefixChanged(null);
+ fireTaglibChanged(taglibListeners[i], newTaglibs, delTaglibs);
+ }
+ lastTaglibs = getTagLibs();
+ }
+ taglibChanged = false;
+ }
+
+ private void fireTaglibChanged(VpeTaglibListener taglibListener, List newTaglibs, List
delTaglibs) {
+ Iterator iter = delTaglibs.iterator();
+ while (iter.hasNext()) {
+ TaglibData taglib = (TaglibData)iter.next();
+ taglibListener.removeTaglib(taglib.getUri(), taglib.getPrefix());
+ }
+ iter = newTaglibs.iterator();
+ while (iter.hasNext()) {
+ TaglibData taglib = (TaglibData)iter.next();
+ taglibListener.addTaglib(taglib.getUri(), taglib.getPrefix());
+ }
+ }
+
+ public boolean isTaglibChanged() {
+ if (!taglibChanged) return false;
+ List newTaglibs = getTagLibs();
+ List delTaglibs = new ArrayList();
+ return buildTaglibsDifferences(newTaglibs, delTaglibs);
+ }
+
+ public WtpKbConnector getConnector() {
+ return connector;
+ }
+
+ boolean registerTaglibs(WtpKbConnector wtpKbConnector, VpeTaglibManager taglibManager,
IDocument document) {
+ if(wtpKbConnector == null) return false;
+ TLDCMDocumentManager manager = TaglibController.getTLDCMDocumentManager(document);
+ if(taglibManager != null) {
+ List list = taglibManager.getTagLibs();
+ if(list != null) {
+ Iterator it = list.iterator();
+ while(it.hasNext()) {
+ TaglibData data = (TaglibData)it.next();
+ IEditorInput ei = editPart.getEditorInput();
+ TLDRegisterHelper.registerTld(data, (JspWtpKbConnector)wtpKbConnector, document,
ei);
+ }
+ return true;
+ }
+ }
+ if(manager != null) {
+ List list = manager.getTaglibTrackers();
+ for (int i = 0; i < list.size(); i++) {
+ TaglibTracker tracker = (TaglibTracker)list.get(i);
+ if(tracker == null) continue;
+ String version = TLDVersionHelper.getTldVersion(tracker);
+ KbTldResource resource = new KbTldResource(tracker.getURI(), "",
tracker.getPrefix(), version);
+ wtpKbConnector.registerResource(resource);
+ }
+ return true;
+ }
+ return false;
+ }
+
+ public nsIDOMNode getCurrentVisualNode() {
+ return currentVisualNode;
+ }
+
+ public void setCurrentVisualNode(nsIDOMNode currentVisualNode) {
+ this.currentVisualNode = currentVisualNode;
+ }
+
+}
\ No newline at end of file
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-20
18:14:12 UTC (rev 5413)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mapping/VpeDomMapping.java 2007-12-20
19:20:25 UTC (rev 5414)
@@ -281,9 +281,6 @@
}
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();) {
@@ -291,7 +288,6 @@
}
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-20
18:14:12 UTC (rev 5413)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mapping/VpeElementMapping.java 2007-12-20
19:20:25 UTC (rev 5414)
@@ -22,11 +22,7 @@
public class VpeElementMapping extends VpeNodeMapping {
private VpeTemplate template;
private Set ifDependencySet;
- /**/
- //vitali
- //-
private Map xmlnsMap;
- /**/
private Object data;
private nsIDOMElement border;
@@ -48,19 +44,13 @@
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/MozillaDomEventListener.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaDomEventListener.java 2007-12-20
18:14:12 UTC (rev 5413)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaDomEventListener.java 2007-12-20
19:20:25 UTC (rev 5414)
@@ -10,7 +10,6 @@
******************************************************************************/
package org.jboss.tools.vpe.editor.mozilla;
-import org.jboss.tools.vpe.VpeDebug;
import org.jboss.tools.vpe.VpePlugin;
import org.jboss.tools.vpe.editor.VpeController;
import org.jboss.tools.vpe.xulrunner.editor.XulRunnerEditor;
@@ -197,11 +196,6 @@
* @see
org.mozilla.interfaces.nsISelectionListener#notifySelectionChanged(org.mozilla.interfaces.nsIDOMDocument,
org.mozilla.interfaces.nsISelection, short)
*/
public void notifySelectionChanged(nsIDOMDocument domDocument, nsISelection selection,
short reason) {
- if (VpeDebug.PRINT_VISUAL_MOUSE_EVENT) {
- System.out.println("MozillaDomEventListener.notifySelectionChanged:
editorDomEventListener " +
- (editorDomEventListener) + " reason " +
- (reason));
- }
if (editorDomEventListener != null) {
editorDomEventListener.notifySelectionChanged(domDocument, selection, reason);
}
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-20
18:14:12 UTC (rev 5413)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaEditor.java 2007-12-20
19:20:25 UTC (rev 5414)
@@ -43,7 +43,6 @@
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;
@@ -64,7 +63,6 @@
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();
@@ -73,11 +71,14 @@
static String SELECT_BAR = "SELECT_LBAR"; //$NON-NLS-1$
private XulRunnerEditor xulRunnerEditor;
+ private nsIDOMDocument domDocument;
private nsIDOMEventTarget documentEventTarget;
private nsIDOMElement contentArea;
private nsIDOMNode headNode;
private nsIDOMEventTarget contentAreaEventTarget;
private MozillaDomEventListener contentAreaEventListener = new
MozillaDomEventListener();
+ //TODO Max Areshkau may be we need delete this
+ //private MozillaBaseEventListener baseEventListener = null;
private EditorLoadWindowListener editorLoadWindowListener;
//
private EditorDomEventListener editorDomEventListener;
@@ -325,11 +326,19 @@
}
public nsIDOMDocument getDomDocument() {
- if (null != xulRunnerEditor) {
- return xulRunnerEditor.getDOMDocument();
+ if (domDocument == null) {
+ domDocument = xulRunnerEditor.getDOMDocument();
}
- return null;
+ return domDocument;
}
+
+ /**
+ * @param domDocument the domDocument to set
+ */
+ protected void setDomDocument(nsIDOMDocument domDocument) {
+
+ this.domDocument = domDocument;
+ }
public nsIDOMElement getContentArea() {
return contentArea;
@@ -473,6 +482,8 @@
contentAreaEventTarget.addEventListener(MozillaDomEventListener.DBLCLICK,
contentAreaEventListener, false);//$NON-NLS-1$
documentEventTarget = (nsIDOMEventTarget)
getDomDocument().queryInterface(nsIDOMEventTarget.NS_IDOMEVENTTARGET_IID);
documentEventTarget.addEventListener(MozillaDomEventListener.KEYPRESS,
contentAreaEventListener, false); //$NON-NLS-1$
+ } else {
+ //baseEventListener = new MozillaBaseEventListener();
}
}
}
@@ -492,7 +503,7 @@
contentAreaEventTarget.removeEventListener(MozillaDomEventListener.DBLCLICK,
contentAreaEventListener, false);//$NON-NLS-1$
}
- if (documentEventTarget != null) {
+ if (domDocument != null && documentEventTarget != null) {
documentEventTarget.removeEventListener(MozillaDomEventListener.KEYPRESS,
contentAreaEventListener, false); //$NON-NLS-1$
}
}
@@ -561,20 +572,6 @@
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-20
18:14:12 UTC (rev 5413)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaPreview.java 2007-12-20
19:20:25 UTC (rev 5414)
@@ -27,8 +27,6 @@
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;
@@ -49,12 +47,14 @@
private EditorLoadWindowListener editorLoadWindowListener;
private EditorDomEventListener editorDomEventListener;
+ private VpeTemplateManager templateManager;
private VpePageContext pageContext;
private StructuredTextEditor sourceEditor;
private VpeEditorPart editPart;
private IDOMDocument sourceDocument;
public MozillaPreview(VpeEditorPart editPart, StructuredTextEditor sourceEditor) {
+ setTemplateManager(VpeTemplateManager.getInstance());
setSourceEditor(sourceEditor);
setEditPart(editPart);
}
@@ -153,8 +153,9 @@
//TODO Max Areshkau logic error (we should first call buildDom and only then we can call
rebuildDom)
public void rebuildDom() {
- if (null != pageContext && null != pageContext.getVisualBuilder() &&
null != getSourceDocument()) {
- pageContext.getVisualBuilder().rebuildDom(getSourceDocument());
+ if(getPageContext()!=null&&getPageContext().getVisualBuilder()!=null&&getSourceDocument()!=null)
{
+
+ getPageContext().getVisualBuilder().rebuildDom(getSourceDocument());
}
}
@@ -163,15 +164,13 @@
BundleMap bundle = new BundleMap();
bundle.init(getSourceEditor());
- pageContext = new VpePageContext(bundle, getEditPart());
+ setPageContext(new VpePageContext(getTemplateManager(), bundle, getEditPart()));
- // 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);
+ VpeDomMapping domMapping = new VpeDomMapping(getPageContext());
+ VpeSourceDomBuilder sourceBuilder = new VpeSourceDomBuilder(domMapping, null,
getTemplateManager(), getSourceEditor(), getPageContext());
+ VpeVisualDomBuilder visualBuilder = new VpePreviewDomBuilder(domMapping, null,
getTemplateManager(), this, getPageContext());
+ getPageContext().setSourceDomBuilder(sourceBuilder);
+ getPageContext().setVisualDomBuilder(visualBuilder);
IDOMModel sourceModel = (IDOMModel)getSourceEditor().getModel();
setSourceDocument(sourceModel.getDocument());
@@ -182,7 +181,7 @@
/**
* @return the sourceDocument
*/
- public IDOMDocument getSourceDocument() {
+ protected IDOMDocument getSourceDocument() {
return sourceDocument;
}
@@ -193,15 +192,27 @@
this.sourceDocument = sourceDocument;
}
- public IVisualContext getPageContext() {
- IVisualContext visualContext = null;
- if (sourceEditor instanceof IJSPTextEditor) {
- visualContext = ((IJSPTextEditor)sourceEditor).getPageContext();
- }
- return visualContext;
+
+
+ /**
+ * @return the pageContext
+ */
+ private VpePageContext getPageContext() {
+ return pageContext;
}
+
+
/**
+ * @param pageContext the pageContext to set
+ */
+ private void setPageContext(VpePageContext pageContext) {
+ this.pageContext = pageContext;
+ }
+
+
+
+ /**
* @return the editPart
*/
private VpeEditorPart getEditPart() {
@@ -209,6 +220,7 @@
}
+
/**
* @param editPart the editPart to set
*/
@@ -216,13 +228,35 @@
this.editPart = editPart;
}
+
+
/**
+ * @return the templateManager
+ */
+ private VpeTemplateManager getTemplateManager() {
+ return templateManager;
+ }
+
+
+
+ /**
+ * @param templateManager the templateManager to set
+ */
+ private void setTemplateManager(VpeTemplateManager templateManager) {
+ this.templateManager = templateManager;
+ }
+
+
+
+ /**
* @return the sourceEditor
*/
private StructuredTextEditor getSourceEditor() {
return sourceEditor;
}
+
+
/**
* @param sourceEditor the sourceEditor to set
*/
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/dnd/VpeDnd.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/dnd/VpeDnd.java 2007-12-20
18:14:12 UTC (rev 5413)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/dnd/VpeDnd.java 2007-12-20
19:20:25 UTC (rev 5414)
@@ -12,7 +12,6 @@
import java.util.HashSet;
-import org.jboss.tools.jst.jsp.preferences.VpePreference;
import org.jboss.tools.vpe.editor.VpeSourceInnerDragInfo;
import org.jboss.tools.vpe.editor.VpeSourceInnerDropInfo;
import org.jboss.tools.vpe.editor.context.VpePageContext;
@@ -105,7 +104,7 @@
}
public boolean isDropEnabled(VpePageContext pageContext, Node container, Node node){
- if(!VpePreference.isAbsolutePosition() && isAncestor(container, node)) return
false;
+ if(!pageContext.isAbsolutePosition() && isAncestor(container, node)) return
false;
if(isContainer){
if(enabledTags != null && enabledTags.size() > 0){
String name = node.getNodeType() == Node.ELEMENT_NODE ?
node.getLocalName().toLowerCase() : node.getNodeName();
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionSrc.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionSrc.java 2007-12-20
18:14:12 UTC (rev 5413)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionSrc.java 2007-12-20
19:20:25 UTC (rev 5414)
@@ -33,8 +33,6 @@
import org.jboss.tools.jst.web.tld.IFilePathEncoder;
import org.jboss.tools.vpe.VpePlugin;
import org.jboss.tools.vpe.editor.context.VpePageContext;
-import org.jboss.tools.vpe.editor.css.AbsoluteFolderReferenceList;
-import org.jboss.tools.vpe.editor.css.RelativeFolderReferenceList;
import org.jboss.tools.vpe.editor.css.ResourceReference;
import org.w3c.dom.Node;
@@ -88,10 +86,10 @@
if (null != file) {
ResourceReference resourceReference = null;
if ("/".equals(tagValue.substring(0, 1))) {
- resourceReference = getRuntimeAbsoluteFolder(file);
+ resourceReference = pageContext.getRuntimeAbsoluteFolder(file);
tagValue = tagValue.substring(1);
} else {
- resourceReference = getRuntimeRelativeFolder(file);
+ resourceReference = pageContext.getRuntimeRelativeFolder(file);
}
String location = null;
@@ -115,22 +113,6 @@
return new VpeValue(getUnresolved());
}
- public static ResourceReference getRuntimeRelativeFolder(IFile file) {
- ResourceReference[] list =
RelativeFolderReferenceList.getInstance().getAllResources(file);
- if (list.length > 0) {
- return list[list.length - 1];
- }
- return null;
- }
-
- public static ResourceReference getRuntimeAbsoluteFolder(IFile file) {
- ResourceReference[] list =
AbsoluteFolderReferenceList.getInstance().getAllResources(file);
- if (list.length > 0) {
- return list[list.length - 1];
- }
- return null;
- }
-
protected IPath getInputParentPath(IEditorInput input) {
IPath inputPath = null;
if (input instanceof ILocationProvider) {
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/resize/VpeResizer.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/resize/VpeResizer.java 2007-12-20
18:14:12 UTC (rev 5413)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/resize/VpeResizer.java 2007-12-20
19:20:25 UTC (rev 5414)
@@ -10,7 +10,6 @@
******************************************************************************/
package org.jboss.tools.vpe.editor.template.resize;
-import org.jboss.tools.jst.jsp.preferences.VpePreference;
import org.jboss.tools.vpe.VpePlugin;
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.template.VpeTagDescription;
@@ -96,7 +95,7 @@
*/
public void resize(VpePageContext pageContext, Element sourceElement, nsIDOMDocument
visualDocument, nsIDOMElement visualElement, Object data, int resizeConstrant, int top,
int left, int width, int height) {
pageContext.getEditPart().getSourceEditor().getTextViewer().getUndoManager().beginCompoundChange();
- if (VpePreference.isAbsolutePosition() && (
+ if (pageContext.isAbsolutePosition() && (
resizeConstrant == VpeTagDescription.RESIZE_CONSTRAINS_BOTTOMLEFT||
resizeConstrant == VpeTagDescription.RESIZE_CONSTRAINS_LEFT||
resizeConstrant == VpeTagDescription.RESIZE_CONSTRAINS_TOPLEFT||
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/toolbar/format/FormatControllerManager.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/toolbar/format/FormatControllerManager.java 2007-12-20
18:14:12 UTC (rev 5413)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/toolbar/format/FormatControllerManager.java 2007-12-20
19:20:25 UTC (rev 5414)
@@ -82,7 +82,7 @@
ElementImpl elementImpl = (ElementImpl)newNode;
int startOffset = elementImpl.getStartOffset();
int startEndOffset = elementImpl.getStartEndOffset();
- StructuredTextViewer viewer =
getVpeController().getSourceBuilder().getStructuredTextViewer();
+ StructuredTextViewer viewer =
getVpeController().getPageContext().getSourceBuilder().getStructuredTextViewer();
try {
String newSelectedTagValue = viewer.getDocument().get(startOffset,
startEndOffset-startOffset);
if(currentSelectedTagValue!=null &&
currentSelectedTagValue.equals(newSelectedTagValue)) {
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/toolbar/format/handler/BlockFormatHandler.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/toolbar/format/handler/BlockFormatHandler.java 2007-12-20
18:14:12 UTC (rev 5413)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/toolbar/format/handler/BlockFormatHandler.java 2007-12-20
19:20:25 UTC (rev 5414)
@@ -47,7 +47,7 @@
Node selectedNode = manager.getCurrentSelectedNodeInfo().getNode();
- StructuredTextViewer viewer =
manager.getVpeController().getSourceBuilder().getStructuredTextViewer();
+ StructuredTextViewer viewer =
manager.getVpeController().getPageContext().getSourceBuilder().getStructuredTextViewer();
Node replacedNode = null;
Node parentNode = selectedNode.getParentNode();
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/toolbar/format/handler/SimpleTagHandler.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/toolbar/format/handler/SimpleTagHandler.java 2007-12-20
18:14:12 UTC (rev 5413)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/toolbar/format/handler/SimpleTagHandler.java 2007-12-20
19:20:25 UTC (rev 5414)
@@ -33,7 +33,7 @@
* @see org.jboss.tools.vpe.editor.toolbar.format.handler.FormatHandler#run()
*/
protected void run() {
- StructuredTextViewer viewer =
manager.getVpeController().getSourceBuilder().getStructuredTextViewer();
+ StructuredTextViewer viewer =
manager.getVpeController().getPageContext().getSourceBuilder().getStructuredTextViewer();
Node selectedNode = manager.getCurrentSelectedNodeInfo().getNode();
if(selectedNode==null) {
return;
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/selbar/SelectionBar.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/selbar/SelectionBar.java 2007-12-20
18:14:12 UTC (rev 5413)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/selbar/SelectionBar.java 2007-12-20
19:20:25 UTC (rev 5414)
@@ -286,9 +286,9 @@
}
private void setSourceFocus(int offset) {
- vpeController.getSourceBuilder()
+ vpeController.getPageContext().getSourceBuilder()
.getStructuredTextViewer().setSelectedRange(offset, 0);
- vpeController.getSourceBuilder()
+ vpeController.getPageContext().getSourceBuilder()
.getStructuredTextViewer().revealRange(offset, 0);
}