Author: ezheleznyakov
Date: 2007-09-26 04:34:58 -0400 (Wed, 26 Sep 2007)
New Revision: 3802
Added:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/HtmlBodyTemplate.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/HTML.java
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/VpeDebug.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/template/VpeCopyCreator.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeStyleUtil.java
trunk/vpe/plugins/org.jboss.tools.vpe/templates/vpe-templates-html.xml
Log:
http://jira.jboss.com/jira/browse/JBIDE-897
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/VpeDebug.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/VpeDebug.java 2007-09-25
20:37:32 UTC (rev 3801)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/VpeDebug.java 2007-09-26
08:34:58 UTC (rev 3802)
@@ -25,7 +25,7 @@
public static final boolean visualAddPseudoElement = false;
- public static final boolean visualContextMenuDumpSource = false;
+ public static final boolean visualContextMenuDumpSource = true;
public static final boolean visualContextMenuDumpMapping = false;
public static final boolean visualContextMenuTest = false;
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-09-25
20:37:32 UTC (rev 3801)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java 2007-09-26
08:34:58 UTC (rev 3802)
@@ -58,6 +58,7 @@
import org.jboss.tools.vpe.editor.template.VpeTemplateManager;
import org.jboss.tools.vpe.editor.template.VpeToggableTemplate;
import org.jboss.tools.vpe.editor.template.dnd.VpeDnd;
+import org.jboss.tools.vpe.editor.util.HTML;
import org.jboss.tools.vpe.editor.util.MozillaSupports;
import org.jboss.tools.vpe.editor.util.TextUtil;
import org.jboss.tools.vpe.editor.util.VpeStyleUtil;
@@ -335,6 +336,10 @@
pageContext.setCurrentVisualNode(null);
Element visualNewElement;
visualNewElement = (Element)creationData.getNode();
+
+ if (visualNewElement != null)
+ correctVisualAttribute(visualNewElement);
+
Element border = null;
setTooltip((Element)sourceNode, visualNewElement);
if (YES_STRING.equals(VpePreference.SHOW_BORDER_FOR_ALL_TAGS.getValue()) &&
visualNewElement != null) {
@@ -380,6 +385,26 @@
return null;
}
+ private void correctVisualAttribute(Element element) {
+
+ String styleValue = element.getAttribute(HTML.TAG_STYLE);
+ String backgroundValue = element
+ .getAttribute(VpeStyleUtil.PARAMETR_BACKGROND);
+
+ if (styleValue != null) {
+ styleValue = VpeStyleUtil.addFullPathIntoURLValue(styleValue,
+ pageContext.getEditPart().getEditorInput());
+ element.setAttribute(HTML.TAG_STYLE, styleValue);
+ }
+ if (backgroundValue != null) {
+ backgroundValue = VpeStyleUtil
+ .addFullPathIntoBackgroundValue(backgroundValue,
+ pageContext.getEditPart().getEditorInput());
+ element.setAttribute(VpeStyleUtil.PARAMETR_BACKGROND,
+ backgroundValue);
+ }
+ }
+
/**
* Create a visual element for text node
* @param sourceNode
Added:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/HtmlBodyTemplate.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/HtmlBodyTemplate.java
(rev 0)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/HtmlBodyTemplate.java 2007-09-26
08:34:58 UTC (rev 3802)
@@ -0,0 +1,99 @@
+/*******************************************************************************
+ * 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.template;
+
+import org.jboss.tools.vpe.editor.context.VpePageContext;
+import org.jboss.tools.vpe.editor.util.HTML;
+import org.jboss.tools.vpe.editor.util.VpeStyleUtil;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ *
+ * @author ezheleznyakov(a)exadel.com
+ *
+ */
+public class HtmlBodyTemplate extends VpeAbstractTemplate {
+
+ private Element bodyOld;
+ private static String STYLE_FOR_DIV = "width: 100%; height: 100%";
+
+ /**
+ *
+ */
+ public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
+ Document visualDocument) {
+
+ goToTree(visualDocument.getChildNodes().item(0));
+
+ for (int i = 0; i < sourceNode.getAttributes().getLength(); i++) {
+ String name = sourceNode.getAttributes().item(i).getNodeName();
+ String value = sourceNode.getAttributes().item(i).getNodeValue();
+ // all full path for 'url'
+ if (VpeStyleUtil.ATTRIBUTE_STYLE.equalsIgnoreCase(name))
+ value = VpeStyleUtil.addFullPathIntoURLValue(value, pageContext
+ .getEditPart().getEditorInput());
+ if (VpeStyleUtil.PARAMETR_BACKGROND.equalsIgnoreCase(name))
+ value = VpeStyleUtil.addFullPathIntoBackgroundValue(value,
+ pageContext.getEditPart().getEditorInput());
+
+ bodyOld.setAttribute(name, value);
+
+ }
+
+ Element div = visualDocument.createElement(HTML.TAG_DIV);
+ div.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE, STYLE_FOR_DIV);
+
+ return new VpeCreationData(div);
+ }
+
+ /**
+ *
+ * @param node
+ */
+ private void goToTree(Node node) {
+
+ for (int i = 0; i < node.getChildNodes().getLength(); i++)
+ if (HTML.TAG_BODY.equalsIgnoreCase(node.getChildNodes().item(i)
+ .getNodeName()))
+ bodyOld = (Element) node.getChildNodes().item(i);
+ else
+ goToTree(node.getChildNodes().item(i));
+ }
+
+ /**
+ * Checks, whether it is necessary to re-create an element at change of
+ * attribute
+ *
+ * @param pageContext
+ * Contains the information on edited page.
+ * @param sourceElement
+ * The current element of the source tree.
+ * @param visualDocument
+ * The document of the visual tree.
+ * @param visualNode
+ * The current node of the visual tree.
+ * @param data
+ * The arbitrary data, built by a method <code>create</code>
+ * @param name
+ * Attribute name
+ * @param value
+ * Attribute value
+ * @return <code>true</code> if it is required to re-create an element at
+ * a modification of attribute, <code>false</code> otherwise.
+ */
+ public boolean isRecreateAtAttrChange(VpePageContext pageContext,
+ Element sourceElement, Document visualDocument,
+ Element visualNode, Object data, String name, String value) {
+ return true;
+ }
+}
\ No newline at end of file
Property changes on:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/HtmlBodyTemplate.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeCopyCreator.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeCopyCreator.java 2007-09-25
20:37:32 UTC (rev 3801)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeCopyCreator.java 2007-09-26
08:34:58 UTC (rev 3802)
@@ -125,9 +125,7 @@
String name = sourceAttr.getName();
String value = sourceAttr.getValue();
- if (name.equalsIgnoreCase(STYLE_ATTR_NAME))
- value = VpeStyleUtil.addFullPathIntoURLValue(sourceAttr.getValue(),
pageContext.getEditPart().getEditorInput());
-
+
if (isAttribute(name)) {
visualElement.setAttribute(name, value);
}
Added:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/HTML.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/HTML.java
(rev 0)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/HTML.java 2007-09-26
08:34:58 UTC (rev 3802)
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.vpe.editor.util;
+
+/**
+ * @author Sergey Vasilyev (svasilyev(a)exadel.com)
+ *
+ */
+public final class HTML {
+
+ private HTML() {}
+
+ public static final String TAG_HTML = "HTML";
+ public static final String TAG_HEAD = "HEAD";
+ public static final String TAG_BODY = "BODY";
+ public static final String TAG_IMG = "IMG";
+ public static final String TAG_LINK = "LINK";
+ public static final String TAG_SELECT = "SELECT";
+ public static final String TAG_OPTION = "OPTION";
+ public static final String TAG_STYLE = "STYLE";
+ public static final String TAG_TABLE = "TABLE";
+ public static final String TAG_TBODY = "TBODY";
+ public static final String TAG_THEAD = "THEAD";
+ public static final String TAG_TFOOT = "TFOOT";
+ public static final String TAG_TH = "TH";
+ public static final String TAG_TR = "TR";
+ public static final String TAG_TD = "TD";
+ public static final String TAG_COL = "COL";
+ public static final String TAG_COLS = "COLS";
+ public static final String TAG_COLGROUP = "COLGROUP";
+ public static final String TAG_BR = "BR";
+ public static final String TAG_LI = "LI";
+ public static final String TAG_DIV = "DIV";
+ public static final String TAG_SPAN = "SPAN";
+ public static final String TAG_P = "P";
+ public static final String TAG_TEXTAREA = "TEXTAREA";
+ public static final String TAG_INPUT = "INPUT";
+ public static final String TAG_BUTTON = "BUTTON";
+ public static final String TAG_OL = "OL";
+ public static final String TAG_UL = "UL";
+
+
+
+ public static final String ATTR_ID = "ID";
+}
\ No newline at end of file
Property changes on:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/HTML.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeStyleUtil.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeStyleUtil.java 2007-09-25
20:37:32 UTC (rev 3801)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeStyleUtil.java 2007-09-26
08:34:58 UTC (rev 3802)
@@ -30,6 +30,7 @@
public static final String PARAMETER_LEFT = "left";
public static final String PARAMETER_WIDTH = "width";
public static final String PARAMETER_HEIGHT = "height";
+ public static final String PARAMETR_BACKGROND = "background";
public static final String VALUE_ABSOLUTE = "absolute";
@@ -335,7 +336,35 @@
}
return inputPath;
}
+
+ /**
+ *
+ * @param value
+ * Css string
+ * @param input
+ * The editor input
+ * @return format style string
+ */
+ public static String addFullPathIntoBackgroundValue(String value,
+ IEditorInput input) {
+ if (value.indexOf(FILE_STR) != -1)
+ return value;
+
+ if (!new File(value).isAbsolute())
+ value = getFilePath(input, value);
+
+ value = FILE_PRTOCOL + value;
+ URL url = null;
+ try {
+ url = new URL(value);
+ } catch (MalformedURLException e) {
+ return value;
+ }
+
+ return url.toString();
+ }
+
/**
*
* @param value
@@ -410,7 +439,7 @@
try {
url = new URL(pathCssAbsolute);
} catch (MalformedURLException e) {
-
+ return pathImgRelative;
}
pathCssAbsolute = url.toString();
while (j != -1) {
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/templates/vpe-templates-html.xml
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/templates/vpe-templates-html.xml 2007-09-25
20:37:32 UTC (rev 3801)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/templates/vpe-templates-html.xml 2007-09-26
08:34:58 UTC (rev 3802)
@@ -352,35 +352,17 @@
</vpe:template>
</vpe:tag>
- <vpe:tag name="body" case-sensitive="no">
- <vpe:if test="attrpresent('background')">
- <vpe:template children="yes" modify="yes">
- <div
- style="background-color:{@bgcolor};background-image:url({src(@background)});"
/>
- <vpe:dnd>
- <vpe:drop container="yes" />
- </vpe:dnd>
- <vpe:textFormating>
- <vpe:format type="BlockFormat" addParent="deny"
addChildren="allow"
- handler="org.jboss.tools.vpe.editor.toolbar.format.handler.BlockFormatHandler"
/>
- <vpe:format type="BoldFormat" addParent="deny"
addChildren="allow"
handler="org.jboss.tools.vpe.editor.toolbar.format.handler.BoldFormatHandler"
/>
- <vpe:format type="ItalicFormat" addParent="deny"
addChildren="allow"
handler="org.jboss.tools.vpe.editor.toolbar.format.handler.ItalicFormatHandler"
/>
- <vpe:format type="UnderlineFormat" addParent="deny"
addChildren="allow"
handler="org.jboss.tools.vpe.editor.toolbar.format.handler.UnderlineFormatHandler"
/>
- </vpe:textFormating>
- </vpe:template>
- </vpe:if>
- <vpe:template children="yes" modify="yes">
- <div style="background-color:{@bgcolor};" />
+ <vpe:tag name="body" case-sensitive="yes">
+ <vpe:template children="yes" modify="yes"
+ class="org.jboss.tools.vpe.editor.template.HtmlBodyTemplate">
+ <vpe:resize>
+ <vpe:width width-attr="style.width" />
+ <vpe:height height-attr="style.height" />
+ </vpe:resize>
<vpe:dnd>
- <vpe:drop container="yes" />
+ <vpe:drag start-enable="yes" />
+ <vpe:drop container="no"></vpe:drop>
</vpe:dnd>
- <vpe:textFormating>
- <vpe:format type="BlockFormat" addParent="deny"
addChildren="allow"
- handler="org.jboss.tools.vpe.editor.toolbar.format.handler.BlockFormatHandler"
/>
- <vpe:format type="BoldFormat" addParent="deny"
addChildren="allow"
handler="org.jboss.tools.vpe.editor.toolbar.format.handler.BoldFormatHandler"
/>
- <vpe:format type="ItalicFormat" addParent="deny"
addChildren="allow"
handler="org.jboss.tools.vpe.editor.toolbar.format.handler.ItalicFormatHandler"
/>
- <vpe:format type="UnderlineFormat" addParent="deny"
addChildren="allow"
handler="org.jboss.tools.vpe.editor.toolbar.format.handler.UnderlineFormatHandler"
/>
- </vpe:textFormating>
</vpe:template>
</vpe:tag>
@@ -2293,7 +2275,7 @@
<vpe:tag name="table" case-sensitive="no">
<vpe:template children="yes" modify="yes">
<vpe:copy
- attrs="style,class,width,border,frame,rules,cellspacing,cellpadding,align,bgcolor"
/>
+ attrs="style,class,width,border,frame,rules,cellspacing,cellpadding,align,bgcolor,background"
/>
<vpe:resize>
<vpe:width width-attr="style.width" />
<vpe:height height-attr="style.height" />