Author: mareshkau
Date: 2007-09-13 12:47:11 -0400 (Thu, 13 Sep 2007)
New Revision: 3615
Modified:
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeEditorPart.java
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpePreviewDomBuilder.java
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaEditor.java
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaPreview.java
Log:
preview functionality was restored
Modified:
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeEditorPart.java
===================================================================
---
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeEditorPart.java 2007-09-13
15:53:20 UTC (rev 3614)
+++
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeEditorPart.java 2007-09-13
16:47:11 UTC (rev 3615)
@@ -360,7 +360,7 @@
//Added by Max Areshkau
//was fixed bug(border which drawed by iflasher doesn't hide on MACOS when we
swith
// to souce view)
- if(Platform.getOS().equals(Platform.OS_MACOSX)) {
+ if(Platform.getOS().equals(Platform.OS_MACOSX)&&controller!=null) {
controller.visualRefresh();
}
Modified:
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpePreviewDomBuilder.java
===================================================================
---
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpePreviewDomBuilder.java 2007-09-13
15:53:20 UTC (rev 3614)
+++
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpePreviewDomBuilder.java 2007-09-13
16:47:11 UTC (rev 3615)
@@ -10,15 +10,10 @@
******************************************************************************/
package org.jboss.tools.vpe.editor;
-import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IFileEditorInput;
import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter;
import org.jboss.tools.jst.jsp.preferences.VpePreference;
import org.jboss.tools.vpe.editor.context.VpePageContext;
@@ -30,11 +25,8 @@
import org.jboss.tools.vpe.editor.template.VpeTemplateManager;
import org.jboss.tools.vpe.editor.util.HTML;
import org.jboss.tools.vpe.editor.util.TextUtil;
-import org.jboss.tools.vpe.xulrunner.editor.XulRunnerEditor;
-import org.mozilla.interfaces.nsIDOMDocument;
import org.mozilla.interfaces.nsIDOMElement;
import org.mozilla.interfaces.nsIDOMNode;
-import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -43,37 +35,12 @@
* @author A. Yukhovich
*/
public class VpePreviewDomBuilder extends VpeVisualDomBuilder {
- private static final String PSEUDO_ELEMENT = "br";
- private static final String PSEUDO_ELEMENT_ATTR = "vpe:pseudo-element";
- private static final String INIT_ELEMENT_ATTR = "vpe:init-element";
- private static final String MOZ_ANONCLASS_ATTR = "_MOZ_ANONCLASS";
- private static final String COMMENT_STYLE = "font-style:italic; color:green";
- private static final String COMMENT_PREFIX = "";
- private static final String COMMENT_SUFFIX = "";
- private static final String INCLUDE_ELEMENT_ATTR = "vpe:include-element";
- private static final int DRAG_AREA_WIDTH = 10;
- private static final int DRAG_AREA_HEIGHT = 10;
- private static final String ATTR_XMLNS = "xmlns";
-
- private MozillaEditor visualEditor;
- private XulRunnerEditor browser;
-// private MozillaBrowser browser;
- private nsIDOMDocument visualDocument;
- private nsIDOMElement visualContentArea;
- private VpePageContext pageContext;
- private nsIDOMNode headNode;
- private List includeStack;
+
+
boolean rebuildFlag = false;
+
- private static final String EMPTY_STRING = "";
-
- private static final String ATTR_VPE = "vpe";
- private static final String ATTR_VPE_INLINE_LINK_VALUE = "inlinelink";
-
- private static final String ATTR_REL_STYLESHEET_VALUE = "stylesheet";
-
private static final String YES_STRING = "yes";
- private static final String NO_STRING = "no";
/**
*
@@ -85,75 +52,34 @@
*/
public VpePreviewDomBuilder(VpeDomMapping domMapping, INodeAdapter sorceAdapter,
VpeTemplateManager templateManager, MozillaEditor visualEditor, VpePageContext
pageContext) {
super(domMapping, sorceAdapter, templateManager, visualEditor, pageContext);
- this.visualEditor = visualEditor;
- browser = visualEditor.getXulRunnerEditor();
- this.visualDocument = visualEditor.getDomDocument();
- this.visualContentArea = visualEditor.getContentArea();
- this.pageContext = pageContext;
- this.headNode = visualEditor.getHeadNode();
+
}
/**
*
- */
- public void buildDom(Document sourceDocument) {
- includeStack = new ArrayList();
- IEditorInput input = pageContext.getEditPart().getEditorInput();
- if (input instanceof IFileEditorInput) {
- IFile file = ((IFileEditorInput)input).getFile();
- if (file != null) {
- includeStack.add(new VpeIncludeInfo(null, file,
pageContext.getSourceBuilder().getSourceDocument()));
- }
- }
- pageContext.refreshConnector();
- pageContext.installIncludeElements();
- addChildren(null, sourceDocument, visualContentArea);
- registerNodes(new VpeNodeMapping(sourceDocument, visualContentArea));
- }
-
- /**
- *
* @param sourceNode
- * @param visualNextNode
- * @param visualContainer
- * @return
- */
- private boolean addNode(Node sourceNode, nsIDOMNode visualNextNode, nsIDOMNode
visualContainer) {
- nsIDOMNode visualNewNode = createNode(sourceNode, visualContainer);
- if (visualNewNode != null) {
- nsIDOMNode visualAddedNode = visualNextNode == null ?
- visualContainer.appendChild(visualNewNode) :
- visualContainer.insertBefore(visualNewNode, visualNextNode);
- return true;
- } else {
- return false;
- }
- }
-
- /**
- *
- * @param sourceNode
* @param visualOldContainer
* @return
*/
- private nsIDOMNode createNode(Node sourceNode, nsIDOMNode visualOldContainer) {
+ @Override
+ protected nsIDOMNode createNode(Node sourceNode, nsIDOMNode visualOldContainer) {
boolean registerFlag = isCurrentMainDocument();
switch (sourceNode.getNodeType()) {
case Node.ELEMENT_NODE:
Map xmlnsMap = createXmlns((Element)sourceNode);
Set ifDependencySet = new HashSet();
- pageContext.setCurrentVisualNode(visualOldContainer);
- VpeTemplate template = templateManager.getTemplate(pageContext, (Element)sourceNode,
ifDependencySet);
+ getPageContext().setCurrentVisualNode(visualOldContainer);
+ VpeTemplate template = templateManager.getTemplate(getPageContext(),
(Element)sourceNode, ifDependencySet);
VpeCreationData creationData;
if ( template.isHaveVisualPreview() ) {
- creationData = template.create(pageContext, sourceNode, visualDocument);
+ creationData = template.create(getPageContext(), sourceNode, getVisualDocument());
} else {
- nsIDOMElement tempHTMLElement = visualDocument.createElement(HTML.TAG_DIV);
+ nsIDOMElement tempHTMLElement = getVisualDocument().createElement(HTML.TAG_DIV);
creationData = new VpeCreationData(tempHTMLElement);
}
- pageContext.setCurrentVisualNode(null);
+ getPageContext().setCurrentVisualNode(null);
nsIDOMElement visualNewElement;
visualNewElement = (nsIDOMElement)creationData.getNode();
setTooltip((Element)sourceNode, visualNewElement);
@@ -163,25 +89,26 @@
}
if (template.isChildren()) {
- List childrenInfoList = creationData.getChildrenInfoList();
+ List<?> childrenInfoList = creationData.getChildrenInfoList();
if (childrenInfoList == null) {
addChildren(template, sourceNode, visualNewElement != null ? visualNewElement :
visualOldContainer);
} else {
addChildren(template, sourceNode, visualOldContainer, childrenInfoList);
}
}
- pageContext.setCurrentVisualNode(visualOldContainer);
- template.validate(pageContext, (Element)sourceNode, visualDocument, creationData);
- pageContext.setCurrentVisualNode(null);
+ getPageContext().setCurrentVisualNode(visualOldContainer);
+ template.validate(getPageContext(), (Element)sourceNode, getVisualDocument(),
creationData);
+ getPageContext().setCurrentVisualNode(null);
return visualNewElement;
case Node.TEXT_NODE:
+ //TODO Max Areshkau merge with old version
String sourceText = sourceNode.getNodeValue();
if (sourceText.trim().length() <= 0) {
registerNodes(new VpeNodeMapping(sourceNode, null));
return null;
}
String visualText = TextUtil.visualText(sourceText);
- nsIDOMNode visualNewTextNode = visualDocument.createTextNode(visualText);
+ nsIDOMNode visualNewTextNode = getVisualDocument().createTextNode(visualText);
if (registerFlag) {
registerNodes(new VpeNodeMapping(sourceNode, visualNewTextNode));
}
@@ -198,4 +125,5 @@
}
return null;
}
+
}
Modified:
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java
===================================================================
---
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java 2007-09-13
15:53:20 UTC (rev 3614)
+++
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java 2007-09-13
16:47:11 UTC (rev 3615)
@@ -92,7 +92,6 @@
private nsIDOMDocument visualDocument;
private nsIDOMElement visualContentArea;
private VpePageContext pageContext;
- // TODO Max Areshkau figure out with DnD
private VpeDnD dnd;
private nsIDOMNode headNode;
private List includeStack;
@@ -146,11 +145,9 @@
xulRunnerEditor = visualEditor.getXulRunnerEditor();
this.visualDocument = visualEditor.getDomDocument();
this.visualContentArea = visualEditor.getContentArea();
- // TODO Max Areshkau figure out
this.dnd = new VpeDnD();
this.pageContext = pageContext;
this.headNode = visualEditor.getHeadNode();
- // TODO Max Areshkau figure out
dropper = new VpeDnd();
dropper.setDndData(false, true);
}
@@ -291,7 +288,7 @@
return border;
}
- private nsIDOMNode createNode(Node sourceNode, nsIDOMNode visualOldContainer) {
+ protected nsIDOMNode createNode(Node sourceNode, nsIDOMNode visualOldContainer) {
boolean registerFlag = isCurrentMainDocument();
switch (sourceNode.getNodeType()) {
case Node.ELEMENT_NODE:
@@ -1633,4 +1630,32 @@
this.dnd = dnd;
}
+
+ /**
+ * @return the pageContext
+ */
+ protected VpePageContext getPageContext() {
+ return pageContext;
+ }
+
+ /**
+ * @param pageContext the pageContext to set
+ */
+ protected void setPageContext(VpePageContext pageContext) {
+ this.pageContext = pageContext;
+ }
+
+ /**
+ * @return the visualDocument
+ */
+ protected nsIDOMDocument getVisualDocument() {
+ return visualDocument;
+ }
+
+ /**
+ * @param visualDocument the visualDocument to set
+ */
+ protected void setVisualDocument(nsIDOMDocument visualDocument) {
+ this.visualDocument = visualDocument;
+ }
}
Modified:
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaEditor.java
===================================================================
---
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaEditor.java 2007-09-13
15:53:20 UTC (rev 3614)
+++
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaEditor.java 2007-09-13
16:47:11 UTC (rev 3615)
@@ -83,6 +83,7 @@
private IVpeToolBarManager vpeToolBarManager;
private FormatControllerManager formatControllerManager = new
FormatControllerManager();
private VpeController controller;
+ private Link link = null;
public void doSave(IProgressMonitor monitor) {
}
@@ -114,8 +115,6 @@
controller.setToolbarFormatControllerManager(formatControllerManager);
}
- Link link = null;
-
public void createPartControl(final Composite parent) {
vpeToolBarManager = new VpeToolBarManager();
//Setting Layout for the parent Composite
@@ -320,10 +319,6 @@
if (contentAreaEventListener != null) {
contentAreaEventListener.setEditorDomEventListener(listener);
}
- if (xulRunnerEditor != null) {
- // TODO Max Areshkau add context menu listener support
-// xulRunnerEditor.setContextMenuListener(listener);
- }
}
public nsIDOMDocument getDomDocument() {
@@ -332,10 +327,26 @@
}
return domDocument;
}
+
+ /**
+ * @param domDocument the domDocument to set
+ */
+ protected void setDomDocument(nsIDOMDocument domDocument) {
+
+ this.domDocument = domDocument;
+ }
public nsIDOMElement getContentArea() {
return contentArea;
}
+ /**
+ * Sets content area element
+ * @return
+ */
+ protected void setContentArea(nsIDOMElement element) {
+
+ this.contentArea=element;
+ }
public nsIDOMNode getHeadNode() {
return headNode;
@@ -349,16 +360,8 @@
return xulRunnerEditor.getBrowser();
}
- // TODO Max Areshkau add DnD support
-// public VpeDnD getLocalDnD() {
-// if (contentAreaEventListener != null) {
-// return contentAreaEventListener.getLocalDnD();
-// }
-// return null;
-// }
-
protected nsIDOMElement findContentArea() {
- nsIDOMElement area = null;
+ nsIDOMElement area = xulRunnerEditor.getDOMDocument().getDocumentElement();
nsIDOMNodeList nodeList =
xulRunnerEditor.getDOMDocument().getElementsByTagName(HTML.TAG_BODY);
long length = nodeList.getLength();
for(long i=0; i<length; i++) {
@@ -372,7 +375,7 @@
break;
}
}
-// nsIDOMElement area = findContentArea(root);
+// area = findContentArea(root);
if (area == null) {
return null;
}
@@ -450,8 +453,6 @@
contentArea = findContentArea();
addDomEventListeners();
addSelectionListener();
- // TODO Max Areshkau figure out with clipboard drag drop hooks
-// addClipboardDragDropHooks();
if (editorLoadWindowListener != null) {
editorLoadWindowListener.load();
}
@@ -467,7 +468,7 @@
contentAreaEventTarget.addEventListener("click", contentAreaEventListener,
false); //$NON-NLS-1$
contentAreaEventTarget.addEventListener("mousedown",
contentAreaEventListener, false); //$NON-NLS-1$
contentAreaEventTarget.addEventListener("mouseup",
contentAreaEventListener, false); //$NON-NLS-1$
- contentAreaEventTarget.addEventListener("mousemove",
contentAreaEventListener, false); //$NON-NLS-1$
+ contentAreaEventTarget.addEventListener(MozillaDomEventListener.MOUSEMOVEEVENTTYPE,
contentAreaEventListener, false); //$NON-NLS-1$
//context menu event handler(add by Max Areshkau)
contentAreaEventTarget.addEventListener(MozillaDomEventListener.CONTEXTMENUEVENTTYPE,
contentAreaEventListener, false);
@@ -570,5 +571,34 @@
public XulRunnerEditor getXulRunnerEditor() {
return xulRunnerEditor;
}
+
+ /**
+ * @param xulRunnerEditor the xulRunnerEditor to set
+ */
+ protected void setXulRunnerEditor(XulRunnerEditor xulRunnerEditor) {
+ this.xulRunnerEditor = xulRunnerEditor;
+ }
+
+ /**
+ * @return the controller
+ */
+ protected VpeController getController() {
+ return controller;
+ }
+
+ /**
+ * @return the link
+ */
+ protected Link getLink() {
+ return link;
+ }
+
+ /**
+ * @param link the link to set
+ */
+ protected void setLink(Link link) {
+ this.link = link;
+ }
+
}
\ No newline at end of file
Modified:
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaPreview.java
===================================================================
---
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaPreview.java 2007-09-13
15:53:20 UTC (rev 3614)
+++
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaPreview.java 2007-09-13
16:47:11 UTC (rev 3615)
@@ -13,8 +13,6 @@
import java.net.MalformedURLException;
import java.net.URL;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.swt.events.MouseEvent;
@@ -23,10 +21,6 @@
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Link;
-import org.eclipse.swt.widgets.ToolBar;
-import org.eclipse.swt.widgets.ToolItem;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorSite;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.browser.IWorkbenchBrowserSupport;
@@ -34,7 +28,6 @@
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
import org.jboss.tools.vpe.VpePlugin;
-import org.jboss.tools.vpe.editor.VpeController;
import org.jboss.tools.vpe.editor.VpeEditorPart;
import org.jboss.tools.vpe.editor.VpePreviewDomBuilder;
import org.jboss.tools.vpe.editor.VpeSourceDomBuilder;
@@ -45,76 +38,36 @@
import org.jboss.tools.vpe.editor.template.VpeTemplateManager;
import org.jboss.tools.vpe.messages.VpeUIMessages;
import org.jboss.tools.vpe.xulrunner.editor.XulRunnerEditor;
-import org.mozilla.interfaces.nsIDOMDocument;
-import org.mozilla.interfaces.nsIDOMElement;
-import org.mozilla.interfaces.nsIDOMEventTarget;
-import org.mozilla.interfaces.nsIDOMNode;
-import org.w3c.dom.Element;
/**
- * a class implementation of mozilla previre
+ * a class implementation of mozilla preview
* @author A. Yukhovich
*/
public class MozillaPreview extends MozillaEditor {
- private XulRunnerEditor editor;
- private nsIDOMDocument domDocument;
- private nsIDOMEventTarget documentEventTarget;
- private nsIDOMElement contentArea;
- private nsIDOMNode headNode;
- private nsIDOMEventTarget contentAreaEventTarget;
- private MozillaDomEventListener contentAreaEventListener;
- private MozillaBaseEventListener baseEventListener;
+
private EditorLoadWindowListener editorLoadWindowListener;
private EditorDomEventListener editorDomEventListener;
- private VpeController controller;
- private Link link = null;
private VpeTemplateManager templateManager;
private VpePageContext pageContext;
- private BundleMap bundle;
private StructuredTextEditor sourceEditor;
private VpeEditorPart editPart;
- private VpeDomMapping domMapping;
private IDOMDocument sourceDocument;
public MozillaPreview(VpeEditorPart editPart, StructuredTextEditor sourceEditor) {
- templateManager = VpeTemplateManager.getInstance();
-
- this.sourceEditor = sourceEditor;
- this.editPart = editPart;
+ setTemplateManager(VpeTemplateManager.getInstance());
+ setSourceEditor(sourceEditor);
+ setEditPart(editPart);
}
- public void doSave(IProgressMonitor monitor) {
- }
- public void doSaveAs() {
- }
-
- public void init(IEditorSite site, IEditorInput input) throws PartInitException {
- super.setInput(input);
- }
-
- public void setInput(IEditorInput input) {
- boolean isVisualRefreshRequired = (getEditorInput() != null && getEditorInput()
!= input && controller != null);
- super.setInput(input);
- if(isVisualRefreshRequired) controller.visualRefresh();
- }
-
- public boolean isDirty() {
- return false;
- }
-
- public boolean isSaveAsAllowed() {
- return false;
- }
-
-
/* (non-Javadoc)
* @see
org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
*/
+ @Override
public void createPartControl(final Composite parent) {
try {
- editor = new XulRunnerEditor(parent) {
+ setXulRunnerEditor(new XulRunnerEditor(parent) {
public void onLoadWindow() {
super.onLoadWindow();
MozillaPreview.this.onLoadWindow();
@@ -130,21 +83,21 @@
editorDomEventListener.onHideTooltip();
}
}
- };
- editor.setURL(INIT_URL);
- editor.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ });
+ getXulRunnerEditor().setURL(INIT_URL);
+ getXulRunnerEditor().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
} catch (Exception e) {
Label title = new Label(parent, SWT.WRAP);
title.setText(VpeUIMessages.MOZILLA_LOADING_ERROR);
title.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- link = new Link(parent, SWT.WRAP);
- link.setText(VpeUIMessages.MOZILLA_LOADING_ERROR_LINK_TEXT);
- link.setToolTipText(VpeUIMessages.MOZILLA_LOADING_ERROR_LINK);
- link.setForeground(link.getDisplay().getSystemColor(SWT.COLOR_BLUE));
- link.addMouseListener(new MouseListener() {
+ setLink(new Link(parent, SWT.WRAP));
+ getLink().setText(VpeUIMessages.MOZILLA_LOADING_ERROR_LINK_TEXT);
+ getLink().setToolTipText(VpeUIMessages.MOZILLA_LOADING_ERROR_LINK);
+ getLink().setForeground(getLink().getDisplay().getSystemColor(SWT.COLOR_BLUE));
+ getLink().addMouseListener(new MouseListener() {
public void mouseDown(org.eclipse.swt.events.MouseEvent e) {
- BusyIndicator.showWhile(link.getDisplay(), new Runnable() {
+ BusyIndicator.showWhile(getLink().getDisplay(), new Runnable() {
public void run() {
URL theURL=null;;
try {
@@ -168,157 +121,147 @@
public void mouseUp(MouseEvent e) {
}
});
- link.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ getLink().setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
Label fill = new Label(parent, SWT.WRAP);
fill.setLayoutData(new GridData(GridData.FILL_BOTH));
}
}
- private ToolItem createToolItem(ToolBar parent, int type, String image, String
toolTipText) {
- ToolItem item = new ToolItem(parent, type);
- item.setImage(ImageDescriptor.createFromFile(MozillaPreview.class,
image).createImage());
- item.setToolTipText(toolTipText);
- return item;
- }
-
- public void setFocus() {
- if(editor!=null) {
- editor.setFocus();
- } else {
- //link.setFocus();
- }
- }
-
- public void dispose() {
- removeDomEventListeners();
-// removeClipboardDragDropHooks();
- super.dispose();
-
- if (contentArea != null) {
- contentArea = null;
- }
- if (domDocument != null) {
- domDocument = null;
- }
- if (editor != null) {
- editor.dispose();
- editor = null;
- }
- }
-
+ @Override
public void setEditorLoadWindowListener(EditorLoadWindowListener listener) {
editorLoadWindowListener = listener;
}
- public void setEditorDomEventListener(EditorDomEventListener listener) {
- editorDomEventListener = listener;
- if (contentAreaEventListener != null) {
- contentAreaEventListener.setEditorDomEventListener(listener);
- }
- // TODO Max Areshkau add Context Menu Listener
-// if (editor != null) {
-// editor.setContextMenuListener(listener);
-// }
- }
/**
*
*/
private void onLoadWindow() {
- contentArea = findContentArea();
- addDomEventListeners();
- addSelectionListener();
+
+ setContentArea(findContentArea());
if (editorLoadWindowListener != null) {
editorLoadWindowListener.load();
}
}
+ @Override
+ public void showResizer() {
+ }
- private void addDomEventListeners() {
- if (contentArea != null) {
- try {
- contentAreaEventListener = new MozillaDomEventListener();
- } catch (Exception e) {
- }
+ @Override
+ public void hideResizer() {
+ }
- if (contentAreaEventListener != null) {
- contentAreaEventListener.setVisualEditor(editor);
- contentAreaEventTarget = (nsIDOMEventTarget)
contentArea.queryInterface(nsIDOMEventTarget.NS_IDOMEVENTTARGET_IID);
- contentAreaEventTarget.addEventListener("click", contentAreaEventListener,
false); //$NON-NLS-1$
- contentAreaEventTarget.addEventListener("mousedown",
contentAreaEventListener, false); //$NON-NLS-1$
- contentAreaEventTarget.addEventListener("mouseup",
contentAreaEventListener, false); //$NON-NLS-1$
- contentAreaEventTarget.addEventListener("mousemove",
contentAreaEventListener, false); //$NON-NLS-1$
-
- documentEventTarget = (nsIDOMEventTarget)
getDomDocument().queryInterface(nsIDOMEventTarget.NS_IDOMEVENTTARGET_IID);
- documentEventTarget.addEventListener("keypress", contentAreaEventListener,
false); //$NON-NLS-1$
- } else {
- baseEventListener = new MozillaBaseEventListener();
- }
+ //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());
}
}
- private void removeDomEventListeners() {
- if (contentAreaEventTarget != null && contentAreaEventListener != null) {
- contentAreaEventTarget.removeEventListener("click",
contentAreaEventListener, false); //$NON-NLS-1$
- contentAreaEventTarget.removeEventListener("mousedown",
contentAreaEventListener, false); //$NON-NLS-1$
- contentAreaEventTarget.removeEventListener("mouseup",
contentAreaEventListener, false); //$NON-NLS-1$
- contentAreaEventTarget.removeEventListener("mousemove",
contentAreaEventListener, false); //$NON-NLS-1$
- }
- if (domDocument != null && documentEventTarget != null) {
- documentEventTarget.removeEventListener("keypress",
contentAreaEventListener, false); //$NON-NLS-1$
- }
+ //TODO Max Areshkau logic error (we should first call buildDom and only then we can call
rebuildDom)
+ public void buildDom() {
+ BundleMap bundle = new BundleMap();
+ bundle.init(getSourceEditor());
+
+ setPageContext(new VpePageContext(getTemplateManager(), bundle, getEditPart()));
+
+ 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());
+
+ visualBuilder.buildDom(getSourceDocument());
}
- private void addSelectionListener() {
- // TODO Max Areshkau add Selection Controller
-// if (contentAreaEventListener != null) {
-// nsISelectionController selectionController = editor.getSelectionController();
-// selectionController.addSelectionListener(contentAreaEventListener);
-// }
+ /**
+ * @return the sourceDocument
+ */
+ protected IDOMDocument getSourceDocument() {
+ return sourceDocument;
}
- private void removeSelectionListener() {
- // TODO Max Areshkau add Selection Controller
-// nsISelectionController selectionController = editor.getSelectionController();
-// selectionController.removeSelectionListener(contentAreaEventListener.getSelectionListener());
+ /**
+ * @param sourceDocument the sourceDocument to set
+ */
+ protected void setSourceDocument(IDOMDocument sourceDocument) {
+ this.sourceDocument = sourceDocument;
}
- public void setSelectionRectangle(Element element, int resizerConstrains, boolean
scroll) {
- // TODO Sergey Vasilyev figure out with selection in preview
-// if (contentAreaEventListener != null) {
-// editor.setSelectionRectangle((nsIDOMElement)element, resizerConstrains, scroll);
-// }
+
+
+ /**
+ * @return the pageContext
+ */
+ private VpePageContext getPageContext() {
+ return pageContext;
}
- public void showResizer() {
+
+
+ /**
+ * @param pageContext the pageContext to set
+ */
+ private void setPageContext(VpePageContext pageContext) {
+ this.pageContext = pageContext;
}
- public void hideResizer() {
+
+
+ /**
+ * @return the editPart
+ */
+ private VpeEditorPart getEditPart() {
+ return editPart;
}
+
+
/**
- *
+ * @param editPart the editPart to set
*/
- public void rebuildDom() {
- pageContext.getVisualBuilder().rebuildDom(sourceDocument);
+ private void setEditPart(VpeEditorPart editPart) {
+ this.editPart = editPart;
}
+
+
/**
+ * @return the templateManager
*/
- public void buildDom() {
- bundle = new BundleMap();
- bundle.init(sourceEditor);
-
- pageContext = new VpePageContext(templateManager, bundle, editPart);
-
- domMapping = new VpeDomMapping(pageContext);
- VpeSourceDomBuilder sourceBuilder = new VpeSourceDomBuilder(domMapping, null,
templateManager, sourceEditor, pageContext);
- VpeVisualDomBuilder visualBuilder = new VpePreviewDomBuilder(domMapping, null,
templateManager, this, pageContext);
- pageContext.setSourceDomBuilder(sourceBuilder);
- pageContext.setVisualDomBuilder(visualBuilder);
+ private VpeTemplateManager getTemplateManager() {
+ return templateManager;
+ }
- IDOMModel sourceModel = (IDOMModel)sourceEditor.getModel();
- sourceDocument = sourceModel.getDocument();
- visualBuilder.buildDom(sourceDocument);
+
+ /**
+ * @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
+ */
+ private void setSourceEditor(StructuredTextEditor sourceEditor) {
+ this.sourceEditor = sourceEditor;
+ }
+
}
\ No newline at end of file