Author: yradtsevich
Date: 2012-08-28 11:54:38 -0400 (Tue, 28 Aug 2012)
New Revision: 43267
Added:
workspace/yradtsevich/simple-WYSWYG-HTML-editor/
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/.classpath
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/.project
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/.settings/
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/.settings/org.eclipse.jdt.core.prefs
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/META-INF/
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/META-INF/MANIFEST.MF
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/build.properties
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/img/
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/img/bold.png
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/img/favicon.ico
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/img/italic.png
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/img/underline.png
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/lib/
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/lib/commons-io-2.4.jar
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/plugin.xml
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/src/
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/src/org/
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/src/org/jboss/
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/src/org/jboss/tools/
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/src/org/jboss/tools/vpe/
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/src/org/jboss/tools/vpe/javascript/
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/src/org/jboss/tools/vpe/javascript/wysiwyg/
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/src/org/jboss/tools/vpe/javascript/wysiwyg/prototype/
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/src/org/jboss/tools/vpe/javascript/wysiwyg/prototype/AbstractBrowserWidgetAction.java
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/src/org/jboss/tools/vpe/javascript/wysiwyg/prototype/ActionsStateListener.java
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/src/org/jboss/tools/vpe/javascript/wysiwyg/prototype/Activator.java
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/src/org/jboss/tools/vpe/javascript/wysiwyg/prototype/BoldAction.java
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/src/org/jboss/tools/vpe/javascript/wysiwyg/prototype/BrowserWidgetEditor.java
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/src/org/jboss/tools/vpe/javascript/wysiwyg/prototype/BrowserWidgetEditorActionBarContributor.java
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/src/org/jboss/tools/vpe/javascript/wysiwyg/prototype/ItalicAction.java
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/src/org/jboss/tools/vpe/javascript/wysiwyg/prototype/UnderlineAction.java
Log:
https://issues.jboss.org/browse/JBIDE-12276 - Research possibilities to use XULRunner
>= 2.0, or WebKit/IE in VPE
- created a prototype of JavaScript to Eclipse interaction via SWT browser widget
Added:
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/.classpath
===================================================================
---
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/.classpath
(rev 0)
+++
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/.classpath 2012-08-28
15:54:38 UTC (rev 43267)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry exported="true" kind="lib"
path="lib/commons-io-2.4.jar"/>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
+ <classpathentry kind="con"
path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added:
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/.project
===================================================================
---
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/.project
(rev 0)
+++
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/.project 2012-08-28
15:54:38 UTC (rev 43267)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.tools.vpe.javascript.wysiwyg.prototype</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added:
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/.settings/org.eclipse.jdt.core.prefs
===================================================================
---
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/.settings/org.eclipse.jdt.core.prefs
(rev 0)
+++
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/.settings/org.eclipse.jdt.core.prefs 2012-08-28
15:54:38 UTC (rev 43267)
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
+org.eclipse.jdt.core.compiler.compliance=1.7
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.7
Added:
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/META-INF/MANIFEST.MF
===================================================================
---
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/META-INF/MANIFEST.MF
(rev 0)
+++
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/META-INF/MANIFEST.MF 2012-08-28
15:54:38 UTC (rev 43267)
@@ -0,0 +1,15 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Pilot
+Bundle-SymbolicName: org.jboss.tools.vpe.javascript.wysiwyg.prototype;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-Activator: org.jboss.tools.vpe.javascript.wysiwyg.prototype.Activator
+Bundle-Vendor: JBoss
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.apache.commons.lang,
+ org.eclipse.core.resources
+Bundle-RequiredExecutionEnvironment: JavaSE-1.7
+Bundle-ActivationPolicy: lazy
+Bundle-ClassPath: lib/commons-io-2.4.jar,
+ .
Added:
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/build.properties
===================================================================
---
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/build.properties
(rev 0)
+++
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/build.properties 2012-08-28
15:54:38 UTC (rev 43267)
@@ -0,0 +1,6 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ lib/commons-io-2.4.jar
Added:
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/img/bold.png
===================================================================
(Binary files differ)
Property changes on:
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/img/bold.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added:
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/img/favicon.ico
===================================================================
(Binary files differ)
Property changes on:
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/img/favicon.ico
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added:
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/img/italic.png
===================================================================
(Binary files differ)
Property changes on:
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/img/italic.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added:
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/img/underline.png
===================================================================
(Binary files differ)
Property changes on:
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/img/underline.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added:
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/lib/commons-io-2.4.jar
===================================================================
(Binary files differ)
Property changes on:
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/lib/commons-io-2.4.jar
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added:
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/plugin.xml
===================================================================
---
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/plugin.xml
(rev 0)
+++
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/plugin.xml 2012-08-28
15:54:38 UTC (rev 43267)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.eclipse.ui.editors">
+ <editor
+
class="org.jboss.tools.vpe.javascript.wysiwyg.prototype.BrowserWidgetEditor"
+
contributorClass="org.jboss.tools.vpe.javascript.wysiwyg.prototype.BrowserWidgetEditorActionBarContributor"
+ default="false"
+ extensions="txt"
+ icon="img/favicon.ico"
+ id="org.jboss.tools.vpe.javascript.wysiwyg.prototype.editor"
+ name="Browser Widget Editor">
+ </editor>
+ </extension>
+
+</plugin>
Added:
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/src/org/jboss/tools/vpe/javascript/wysiwyg/prototype/AbstractBrowserWidgetAction.java
===================================================================
---
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/src/org/jboss/tools/vpe/javascript/wysiwyg/prototype/AbstractBrowserWidgetAction.java
(rev 0)
+++
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/src/org/jboss/tools/vpe/javascript/wysiwyg/prototype/AbstractBrowserWidgetAction.java 2012-08-28
15:54:38 UTC (rev 43267)
@@ -0,0 +1,25 @@
+package org.jboss.tools.vpe.javascript.wysiwyg.prototype;
+
+import org.eclipse.jface.action.Action;
+
+public abstract class AbstractBrowserWidgetAction extends Action implements
ActionsStateListener {
+ private BrowserWidgetEditor editor;
+
+ public AbstractBrowserWidgetAction() {
+ super(null, AS_CHECK_BOX);
+ }
+
+ public void setEditor(BrowserWidgetEditor editor) {
+ if (this.editor != null) {
+ editor.removeStateListener(this);
+ }
+ this.editor = editor;
+ if (this.editor != null) {
+ editor.addStateListener(this);
+ }
+ }
+
+ public BrowserWidgetEditor getEditor() {
+ return editor;
+ }
+}
Added:
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/src/org/jboss/tools/vpe/javascript/wysiwyg/prototype/ActionsStateListener.java
===================================================================
---
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/src/org/jboss/tools/vpe/javascript/wysiwyg/prototype/ActionsStateListener.java
(rev 0)
+++
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/src/org/jboss/tools/vpe/javascript/wysiwyg/prototype/ActionsStateListener.java 2012-08-28
15:54:38 UTC (rev 43267)
@@ -0,0 +1,7 @@
+package org.jboss.tools.vpe.javascript.wysiwyg.prototype;
+
+import java.util.EventListener;
+
+public interface ActionsStateListener extends EventListener {
+ public void stateChanged(boolean bold, boolean italic, boolean underline);
+}
Added:
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/src/org/jboss/tools/vpe/javascript/wysiwyg/prototype/Activator.java
===================================================================
---
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/src/org/jboss/tools/vpe/javascript/wysiwyg/prototype/Activator.java
(rev 0)
+++
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/src/org/jboss/tools/vpe/javascript/wysiwyg/prototype/Activator.java 2012-08-28
15:54:38 UTC (rev 43267)
@@ -0,0 +1,64 @@
+package org.jboss.tools.vpe.javascript.wysiwyg.prototype;
+
+import java.net.URL;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.resource.ImageRegistry;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID =
"org.jboss.tools.vpe.javascript.wysiwyg.prototype"; //$NON-NLS-1$
+
+ // The shared instance
+ private static Activator plugin;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+ public static ImageDescriptor getImageDescriptor(String path) {
+ ImageRegistry imageRegistry = plugin.getImageRegistry();
+ ImageDescriptor imageDescriptor = imageRegistry.getDescriptor(path);
+ if (imageDescriptor == null) {
+ URL url = plugin.getBundle().getResource(path);
+ imageDescriptor = ImageDescriptor.createFromURL(url);
+ imageRegistry.put(path, imageDescriptor);
+ }
+ return imageDescriptor;
+ }
+}
Added:
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/src/org/jboss/tools/vpe/javascript/wysiwyg/prototype/BoldAction.java
===================================================================
---
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/src/org/jboss/tools/vpe/javascript/wysiwyg/prototype/BoldAction.java
(rev 0)
+++
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/src/org/jboss/tools/vpe/javascript/wysiwyg/prototype/BoldAction.java 2012-08-28
15:54:38 UTC (rev 43267)
@@ -0,0 +1,22 @@
+package org.jboss.tools.vpe.javascript.wysiwyg.prototype;
+
+
+public class BoldAction extends AbstractBrowserWidgetAction {
+ public BoldAction() {
+ setText("Bold");
+ setToolTipText("Bold");
+ setImageDescriptor(Activator.getImageDescriptor("img/bold.png"));
+ }
+
+ @Override
+ public void run() {
+ if (getEditor() != null) {
+ getEditor().execute("document.execCommand('bold')");
+ }
+ }
+
+ @Override
+ public void stateChanged(boolean bold, boolean italic, boolean underline) {
+ setChecked(bold);
+ }
+}
Added:
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/src/org/jboss/tools/vpe/javascript/wysiwyg/prototype/BrowserWidgetEditor.java
===================================================================
---
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/src/org/jboss/tools/vpe/javascript/wysiwyg/prototype/BrowserWidgetEditor.java
(rev 0)
+++
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/src/org/jboss/tools/vpe/javascript/wysiwyg/prototype/BrowserWidgetEditor.java 2012-08-28
15:54:38 UTC (rev 43267)
@@ -0,0 +1,173 @@
+package org.jboss.tools.vpe.javascript.wysiwyg.prototype;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.swing.event.EventListenerList;
+
+import org.apache.commons.io.IOUtils;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.browser.Browser;
+import org.eclipse.swt.browser.BrowserFunction;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.part.EditorPart;
+
+public class BrowserWidgetEditor extends EditorPart {
+
+ private Browser browser;
+ private BrowserFunction commandsStateCallback;
+ private EventListenerList listenerList = new EventListenerList();
+ private boolean boldState = false;
+ private boolean italicState = false;
+ private boolean underlineState = false;
+ public static final String BOLD_PROPERTY_ID =
BrowserWidgetEditor.class.getCanonicalName() + "_BOLD";
+
+ public BrowserWidgetEditor() {
+ // TODO Auto-generated constructor stub
+ }
+
+ @Override
+ public void doSave(IProgressMonitor monitor) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void doSaveAs() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void init(IEditorSite site, IEditorInput input)
+ throws PartInitException {
+ setSite(site);
+ setInput(input);
+ }
+
+ @Override
+ public boolean isDirty() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean isSaveAsAllowed() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public void createPartControl(Composite parent) {
+ browser = new Browser(parent, SWT.NONE);
+ IFile iFile = (IFile) getEditorInput().getAdapter(IFile.class);
+ if (iFile != null && iFile.exists()) {
+ InputStream inputStream = null;
+ try {
+ inputStream = iFile.getContents();
+ String content = IOUtils.toString(inputStream);
+ browser.setText(
+ "<!DOCTYPE html>" +
+ "<html>" +
+ "<head>" +
+ "<script>" +
+ "setInterval(function() {" +
+ "if (window.commandsStateCallback) {" +
+ "var boldValue = document.queryCommandValue('bold');" +
+ "var italicValue = document.queryCommandValue('italic');" +
+ "var underlineValue =
document.queryCommandValue('underline');" +
+ "window.commandsStateCallback(boldValue, italicValue,
underlineValue);" +
+ "}" +
+ "}, 1000);" +
+ "</script>" +
+ "</head>" +
+ "<body contenteditable='true'>" +
+ content +
+ "</body>" +
+ "</html>"
+ );
+ commandsStateCallback = new BrowserFunction(browser,
"commandsStateCallback") {
+ @Override
+ public Object function(Object[] args) {
+ boldState = Boolean.TRUE.equals(args[0]);
+ italicState = Boolean.TRUE.equals(args[1]);
+ underlineState = Boolean.TRUE.equals(args[2]);
+ Display.getDefault().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ fireStateChanged();
+ }
+
+ });
+ return super.function(args);
+ }
+ };
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } finally {
+ if (inputStream != null) {
+ try {
+ inputStream.close();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+
+ }
+ }
+
+ public void addStateListener(ActionsStateListener listener) {
+ listenerList.add(ActionsStateListener.class, listener);
+ }
+ public void removeStateListener(ActionsStateListener listener) {
+ listenerList.remove(ActionsStateListener.class, listener);
+ }
+
+
+ private void fireStateChanged() {
+ ActionsStateListener[] listeners =
listenerList.getListeners(ActionsStateListener.class);
+ for (ActionsStateListener listener :listeners) {
+ listener.stateChanged(boldState, italicState, underlineState);
+ }
+ }
+
+ @Override
+ public void dispose() {
+ super.dispose();
+ commandsStateCallback.dispose();
+ }
+
+ @Override
+ public void setFocus() {
+ browser.setFocus();
+ }
+
+ public boolean execute(String script) {
+ return browser.execute(script);
+ }
+
+ public boolean getBoldState() {
+ return boldState;
+ }
+
+ public boolean getItalicState() {
+ return italicState;
+ }
+
+ public boolean getUnderlineState() {
+ return underlineState;
+ }
+}
Added:
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/src/org/jboss/tools/vpe/javascript/wysiwyg/prototype/BrowserWidgetEditorActionBarContributor.java
===================================================================
---
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/src/org/jboss/tools/vpe/javascript/wysiwyg/prototype/BrowserWidgetEditorActionBarContributor.java
(rev 0)
+++
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/src/org/jboss/tools/vpe/javascript/wysiwyg/prototype/BrowserWidgetEditorActionBarContributor.java 2012-08-28
15:54:38 UTC (rev 43267)
@@ -0,0 +1,43 @@
+package org.jboss.tools.vpe.javascript.wysiwyg.prototype;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.part.EditorActionBarContributor;
+
+
+public class BrowserWidgetEditorActionBarContributor extends
+ EditorActionBarContributor {
+
+ private BrowserWidgetEditor editor;
+ private BoldAction boldAction;
+ private ItalicAction italicAction;
+ private UnderlineAction underlineAction;
+
+ public BrowserWidgetEditorActionBarContributor() {
+ }
+
+ @Override
+ public void setActiveEditor(IEditorPart targetEditor) {
+ if (targetEditor instanceof BrowserWidgetEditor) {
+ this.editor = (BrowserWidgetEditor) targetEditor;
+ boldAction.setEditor(editor);
+ italicAction.setEditor(editor);
+ underlineAction.setEditor(editor);
+ }
+ }
+
+ @Override
+ public void init(IActionBars bars) {
+ boldAction = new BoldAction();
+ italicAction = new ItalicAction();
+ underlineAction = new UnderlineAction();
+ super.init(bars);
+ }
+
+ @Override
+ public void contributeToToolBar(IToolBarManager toolBarManager) {
+ toolBarManager.add(boldAction);
+ toolBarManager.add(italicAction);
+ toolBarManager.add(underlineAction);
+ }
+}
Added:
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/src/org/jboss/tools/vpe/javascript/wysiwyg/prototype/ItalicAction.java
===================================================================
---
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/src/org/jboss/tools/vpe/javascript/wysiwyg/prototype/ItalicAction.java
(rev 0)
+++
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/src/org/jboss/tools/vpe/javascript/wysiwyg/prototype/ItalicAction.java 2012-08-28
15:54:38 UTC (rev 43267)
@@ -0,0 +1,21 @@
+package org.jboss.tools.vpe.javascript.wysiwyg.prototype;
+
+public class ItalicAction extends AbstractBrowserWidgetAction {
+ public ItalicAction() {
+ setText("Italic");
+ setToolTipText("Italic");
+ setImageDescriptor(Activator.getImageDescriptor("img/italic.png"));
+ }
+
+ @Override
+ public void run() {
+ if (getEditor() != null) {
+ getEditor().execute("document.execCommand('italic')");
+ }
+ }
+
+ @Override
+ public void stateChanged(boolean bold, boolean italic, boolean underline) {
+ setChecked(italic);
+ }
+}
Added:
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/src/org/jboss/tools/vpe/javascript/wysiwyg/prototype/UnderlineAction.java
===================================================================
---
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/src/org/jboss/tools/vpe/javascript/wysiwyg/prototype/UnderlineAction.java
(rev 0)
+++
workspace/yradtsevich/simple-WYSWYG-HTML-editor/org.jboss.tools.vpe.javascript.wysiwyg.prototype/src/org/jboss/tools/vpe/javascript/wysiwyg/prototype/UnderlineAction.java 2012-08-28
15:54:38 UTC (rev 43267)
@@ -0,0 +1,21 @@
+package org.jboss.tools.vpe.javascript.wysiwyg.prototype;
+
+public class UnderlineAction extends AbstractBrowserWidgetAction {
+ public UnderlineAction() {
+ setText("Underline");
+ setToolTipText("Underline");
+ setImageDescriptor(Activator.getImageDescriptor("img/underline.png"));
+ }
+
+ @Override
+ public void run() {
+ if (getEditor() != null) {
+ getEditor().execute("document.execCommand('underline')");
+ }
+ }
+
+ @Override
+ public void stateChanged(boolean bold, boolean italic, boolean underline) {
+ setChecked(underline);
+ }
+}