Author: yradtsevich
Date: 2009-05-26 12:37:03 -0400 (Tue, 26 May 2009)
New Revision: 15517
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/MozillaPreview.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/DocTypeUtil.java
trunk/vpe/tests/org.jboss.tools.vpe.html.test/resources/htmlTest/WebContent/pages/components/other/xmp.xhtml.xml
trunk/vpe/tests/org.jboss.tools.vpe.html.test/resources/htmlTest/WebContent/pages/components/text/pre.html.xml
Log:
issue JBIDE-4345: 3 tests fail in HtmlAllTests (testJBIDE3280, testPre, testXmp)
https://jira.jboss.org/jira/browse/JBIDE-4345
- calls to xulRunnerBroswer.setText(initialHtmlCode) are replaced by calls to
setURL(pathToTemporaryInitialHtmlFile)
- JUnit tests are reverted to the initial state with the <BR/> tags
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 2009-05-26
16:14:07 UTC (rev 15516)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaEditor.java 2009-05-26
16:37:03 UTC (rev 15517)
@@ -11,6 +11,9 @@
package org.jboss.tools.vpe.editor.mozilla;
import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.Writer;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
@@ -91,7 +94,7 @@
import org.mozilla.interfaces.nsIPlaintextEditor;
public class MozillaEditor extends EditorPart implements IReusableEditor {
- protected static final String INIT_URL = /*"file://" +*/ (new
File(VpePlugin.getDefault().getResourcePath("ve"),
"init.html")).getAbsolutePath(); //$NON-NLS-1$ //$NON-NLS-2$
+ protected static final File INIT_FILE = new
File(VpePlugin.getDefault().getResourcePath("ve"), "init.html");
//$NON-NLS-1$ //$NON-NLS-2$
public static final String CONTENT_AREA_ID = "__content__area__";
//$NON-NLS-1$
/*
@@ -445,9 +448,7 @@
});
- doctype = DocTypeUtil.getDoctype(getEditorInput());
- xulRunnerEditor.setText(doctype
- + DocTypeUtil.getContentInitFile(new File(INIT_URL)));
+ setInitialContent();
// Wait while visual part is loaded
//commented by mareshkau, fix for jbide-3032
// while (!loaded) {
@@ -474,6 +475,49 @@
}
/**
+ * Sets initial content to the {@link xulRunnerEditor}.
+ *
+ * @see #INIT_FILE
+ */
+ protected void setInitialContent() {
+ final String html = DocTypeUtil.prepareInitFile(
+ INIT_FILE, getEditorInput());
+
+ // Workaround of JBIDE-4345.
+ // Due to a bug in org.eclipse.swt.browser.Mozilla we cannot simply
+ // set initial html code as xulRunnerEditor.setText(html).
+ // Instead of it we create a temporary file containing
+ // the html code and set it to the Mozilla browser as URL.
+ File tmp = null;
+ Writer out = null;
+ try {
+ tmp = File.createTempFile(
+ "temp", ".html"); //$NON-NLS-1$//$NON-NLS-2$
+ tmp.deleteOnExit();
+ out = new FileWriter(tmp);
+ out.write(html);
+ } catch (IOException e) {
+ VpePlugin.getPluginLog().logError(e);
+ } finally {
+ try {
+ if (out != null) {
+ out.close();
+ if (tmp != null) {
+ xulRunnerEditor.setURL("file://" //$NON-NLS-1$
+ + tmp.getCanonicalPath());
+ }
+ }
+ } catch (IOException e) {
+ VpePlugin.getPluginLog().logError(e);
+ } finally {
+ if (tmp != null) {
+ tmp.delete();
+ }
+ }
+ }
+ }
+
+ /**
* Logs given {@code exception} and shows error message in
* the {@code parent} composite.
*/
@@ -851,8 +895,7 @@
doctype = DocTypeUtil.getDoctype(getEditorInput());
//coused page to be refreshed
setRefreshPage(true);
- xulRunnerEditor.setText(doctype
- + DocTypeUtil.getContentInitFile(new File(INIT_URL)));
+ setInitialContent();
}
/**
* Initialized design mode in visual refresh
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 2009-05-26
16:14:07 UTC (rev 15516)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaPreview.java 2009-05-26
16:37:03 UTC (rev 15517)
@@ -24,7 +24,6 @@
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.mapping.VpeDomMapping;
import org.jboss.tools.vpe.editor.template.VpeTemplateManager;
-import org.jboss.tools.vpe.editor.util.DocTypeUtil;
import org.jboss.tools.vpe.xulrunner.XulRunnerException;
import org.jboss.tools.vpe.xulrunner.editor.XulRunnerEditor;
@@ -78,9 +77,7 @@
super.onDispose();
}
});
-// getXulRunnerEditor().setURL(INIT_URL);
- getXulRunnerEditor().setText(DocTypeUtil.prepareInitFile(INIT_URL,
- getEditorInput()));
+ setInitialContent();
getXulRunnerEditor().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
} catch (XulRunnerException e) {
showXulRunnerException(parent, e);
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/DocTypeUtil.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/DocTypeUtil.java 2009-05-26
16:14:07 UTC (rev 15516)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/DocTypeUtil.java 2009-05-26
16:37:03 UTC (rev 15517)
@@ -303,12 +303,9 @@
* @param editorInput
* @return
*/
- public static String prepareInitFile(String initFilePath,
+ public static String prepareInitFile(File initFile,
IEditorInput editorInput) {
-
- return getDoctype(editorInput)
- + getContentInitFile(new File(initFilePath));
-
+ return getDoctype(editorInput) + getContentInitFile(initFile);
}
/**
Modified:
trunk/vpe/tests/org.jboss.tools.vpe.html.test/resources/htmlTest/WebContent/pages/components/other/xmp.xhtml.xml
===================================================================
---
trunk/vpe/tests/org.jboss.tools.vpe.html.test/resources/htmlTest/WebContent/pages/components/other/xmp.xhtml.xml 2009-05-26
16:14:07 UTC (rev 15516)
+++
trunk/vpe/tests/org.jboss.tools.vpe.html.test/resources/htmlTest/WebContent/pages/components/other/xmp.xhtml.xml 2009-05-26
16:37:03 UTC (rev 15517)
@@ -1,27 +1,48 @@
<tests>
<test id="xmp">
<XMP ID="xmp" STYLE="-moz-user-modify: read-only;" >
-<SPAN>
-while (<>) {
- $org=$_;
- s/\\["']//g;
- s/\/\/[^:].*//;
- s/\/\*.*\*\///g;
- if ($comment == 1) {
- if (s/.*\*\///) {
- $comment = 0;
- }
- else {
- next;
- }
- }
- if (s/\/\*.*//) {
- $comment = 1;
- }
- if (/^\s*#/) {
- next;
- }
- }
+<SPAN><BR _MOZ_DIRTY=""/>
+
+while (<>) {<BR _MOZ_DIRTY=""/>
+
+$org=$_;<BR _MOZ_DIRTY=""/>
+
+s/\\["']//g;<BR _MOZ_DIRTY=""/>
+
+s/\/\/[^:].*//;<BR _MOZ_DIRTY=""/>
+
+s/\/\*.*\*\///g;<BR _MOZ_DIRTY=""/>
+
+if ($comment == 1) {<BR _MOZ_DIRTY=""/>
+
+if (s/.*\*\///) {<BR _MOZ_DIRTY=""/>
+
+$comment = 0;<BR _MOZ_DIRTY=""/>
+
+}<BR _MOZ_DIRTY=""/>
+
+else {<BR _MOZ_DIRTY=""/>
+
+next;<BR _MOZ_DIRTY=""/>
+
+}<BR _MOZ_DIRTY=""/>
+
+}<BR _MOZ_DIRTY=""/>
+
+if (s/\/\*.*//) {<BR _MOZ_DIRTY=""/>
+
+$comment = 1;<BR _MOZ_DIRTY=""/>
+
+}<BR _MOZ_DIRTY=""/>
+
+if (/^\s*#/) {<BR _MOZ_DIRTY=""/>
+
+next;<BR _MOZ_DIRTY=""/>
+
+}<BR _MOZ_DIRTY=""/>
+
+}<BR _MOZ_DIRTY=""/>
+
</SPAN>
</XMP>
</test>
Modified:
trunk/vpe/tests/org.jboss.tools.vpe.html.test/resources/htmlTest/WebContent/pages/components/text/pre.html.xml
===================================================================
---
trunk/vpe/tests/org.jboss.tools.vpe.html.test/resources/htmlTest/WebContent/pages/components/text/pre.html.xml 2009-05-26
16:14:07 UTC (rev 15516)
+++
trunk/vpe/tests/org.jboss.tools.vpe.html.test/resources/htmlTest/WebContent/pages/components/text/pre.html.xml 2009-05-26
16:37:03 UTC (rev 15517)
@@ -2,10 +2,16 @@
<test id="pre">
<PRE WIDTH="30" ID="pre" CLASS="preClass"
STYLE="color: red; -moz-user-modify: read-write;">
-<SPAN CLASS="vpe-text">
-string 1
- string 2
-</SPAN>
+ <SPAN CLASS="vpe-text">
+ <BR _MOZ_DIRTY="" />
+
+ string 1
+ <BR _MOZ_DIRTY="" />
+
+ string 2
+ <BR _MOZ_DIRTY="" />
+
+ </SPAN>
</PRE>
</test>
</tests>
\ No newline at end of file