Author: mareshkau
Date: 2008-07-15 13:41:08 -0400 (Tue, 15 Jul 2008)
New Revision: 9146
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/XPCOM.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.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/selection/VpeSelectionController.java
Log:
JBIDE-2505
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2008-07-15
13:51:27 UTC (rev 9145)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2008-07-15
17:41:08 UTC (rev 9146)
@@ -180,7 +180,6 @@
XulRunnerEditor xulRunnerEditor;
// TODO Sergey Vasilyev figure out with nsIPressShell
// private nsIPresShell presShell;
- // TODO Max Areshkau figure out with nsISelectionController
private VpeSelectionController visualSelectionController;
VpeDomMapping domMapping;
private VpeTemplateManager templateManager;
@@ -280,8 +279,8 @@
xulRunnerEditor = visualEditor.getXulRunnerEditor();
// TODO Sergey Vasilyev figure out with nsIPressShell
// presShell = browser.getPresShell();
- visualSelectionController = new VpeSelectionController(xulRunnerEditor
- .getSelection());
+
+ visualSelectionController = new
VpeSelectionController(visualEditor.getEditor().getSelectionController());
selectionBuilder = new VpeSelectionBuilder(domMapping, sourceBuilder,
visualBuilder, visualSelectionController);
@@ -412,7 +411,8 @@
if (visualEditor != null) {
visualEditor.setEditorDomEventListener(null);
if (visualSelectionController != null) {
- // visualSelectionController.Release();
+
+// visualSelectionController.Release();
visualSelectionController = null;
}
// TODO Sergey Vasilyev figure out with Press Shell
@@ -3217,9 +3217,6 @@
} else {
visualBuilder.rebuildDom(null);
}
-
- visualSelectionController.setSelection(xulRunnerEditor.getSelection());
-
}
}
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 2008-07-15
13:51:27 UTC (rev 9145)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaEditor.java 2008-07-15
17:41:08 UTC (rev 9146)
@@ -59,6 +59,7 @@
import org.jboss.tools.vpe.editor.util.DocTypeUtil;
import org.jboss.tools.vpe.editor.util.HTML;
import org.jboss.tools.vpe.messages.VpeUIMessages;
+import org.jboss.tools.vpe.xulrunner.XPCOM;
import org.jboss.tools.vpe.xulrunner.editor.XulRunnerEditor;
import org.mozilla.interfaces.nsIDOMDocument;
import org.mozilla.interfaces.nsIDOMElement;
@@ -66,10 +67,15 @@
import org.mozilla.interfaces.nsIDOMNamedNodeMap;
import org.mozilla.interfaces.nsIDOMNode;
import org.mozilla.interfaces.nsIDOMNodeList;
+import org.mozilla.interfaces.nsIEditingSession;
+import org.mozilla.interfaces.nsIEditor;
+import org.mozilla.interfaces.nsIHTMLAbsPosEditor;
+import org.mozilla.interfaces.nsIHTMLInlineTableEditor;
+import org.mozilla.interfaces.nsIHTMLObjectResizer;
+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$ //$NON-NLS-3$
-// private static final String INIT_URL = "chrome://vpe/content/init.html";
//$NON-NLS-1$
+ protected static final String INIT_URL = /*"file://" +*/ (new
File(VpePlugin.getDefault().getResourcePath("ve"),
"init.html")).getAbsolutePath(); //$NON-NLS-1$ //$NON-NLS-2$
private static final String CONTENT_AREA_ID = "__content__area__";
//$NON-NLS-1$
static String SELECT_BAR = "SELECT_LBAR"; //$NON-NLS-1$
@@ -90,6 +96,11 @@
private boolean loaded;
private boolean isRefreshPage = false;
private String doctype;
+ /**
+ * Used for manupalation of browser in design mode,
+ * for example enable or disable readOnlyMode
+ */
+ private nsIEditor editor;
public void doSave(IProgressMonitor monitor) {
}
@@ -120,7 +131,10 @@
formatControllerManager.setVpeController(controller);
controller.setToolbarFormatControllerManager(formatControllerManager);
}
-
+ /*
+ * (non-Javadoc)
+ * @see
org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
+ */
public void createPartControl(final Composite parent) {
vpeToolBarManager = new VpeToolBarManager();
//Setting Layout for the parent Composite
@@ -258,6 +272,7 @@
public void completed(ProgressEvent event) {
loaded = true;
xulRunnerEditor.getBrowser().removeProgressListener(this);
+ //here we switchs xulrunner to design mode JBIDE-2505
}
});
@@ -316,7 +331,7 @@
});
link.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
Label fill = new Label(cmpEd, SWT.WRAP);
- fill.setLayoutData(new GridData(GridData.FILL_BOTH));
+ fill.setLayoutData(new GridData(GridData.FILL_BOTH));
}
}
@@ -512,7 +527,7 @@
getContentAreaEventTarget().addEventListener(MozillaDomEventListener.DRAGOVEREVENT,
getContentAreaEventListener(), false);
getContentAreaEventTarget().addEventListener(MozillaDomEventListener.DBLCLICK,
getContentAreaEventListener(), false);
documentEventTarget = (nsIDOMEventTarget)
getDomDocument().queryInterface(nsIDOMEventTarget.NS_IDOMEVENTTARGET_IID);
- documentEventTarget.addEventListener(MozillaDomEventListener.KEYPRESS,
getContentAreaEventListener(), false);
+ documentEventTarget.addEventListener(MozillaDomEventListener.KEYPRESS,
getContentAreaEventListener(), false);
} else {
//baseEventListener = new MozillaBaseEventListener();
}
@@ -670,8 +685,7 @@
}
/**
- *
- * @return
+ * @return Doctype for document
*/
public String getDoctype() {
return doctype;
@@ -684,4 +698,35 @@
public void setRefreshPage(boolean isRefreshPage) {
this.isRefreshPage = isRefreshPage;
}
+ /**
+ * Returns Editor for This Document
+ * @return
+ */
+ public nsIEditor getEditor() {
+
+ if(editor==null) {
+ //creating editing session
+ nsIEditingSession iEditingSession = (nsIEditingSession) getXulRunnerEditor().
+ getComponentManager().createInstanceByContractID(XPCOM.NS_EDITINGSESSION_CONTRACTID,
null, nsIEditingSession.NS_IEDITINGSESSION_IID);
+ //make window editable
+ iEditingSession.makeWindowEditable(getXulRunnerEditor().getWebBrowser().getContentDOMWindow(),
"html", true); //$NON-NLS-1$
+ //here we setup editor for window
+ iEditingSession.setupEditorOnWindow(getXulRunnerEditor().getWebBrowser().getContentDOMWindow());
+ //getting some editor to disable some actions
+ editor =
iEditingSession.getEditorForWindow(getXulRunnerEditor().getWebBrowser().getContentDOMWindow());
+ editor.setFlags(nsIPlaintextEditor.eEditorReadonlyMask);
+ //here we hide nsIHTMLObjectResizers
+ nsIHTMLObjectResizer htmlObjectResizer = (nsIHTMLObjectResizer)
editor.queryInterface(nsIHTMLObjectResizer.NS_IHTMLOBJECTRESIZER_IID);
+ //we disable abject resizers
+ htmlObjectResizer.hideResizers();
+ htmlObjectResizer.setObjectResizingEnabled(false);
+ //here we getting position editor and disable it's too
+ nsIHTMLAbsPosEditor htmlAbsPosEditor = (nsIHTMLAbsPosEditor)
editor.queryInterface(nsIHTMLAbsPosEditor.NS_IHTMLABSPOSEDITOR_IID);
+ htmlAbsPosEditor.setAbsolutePositioningEnabled(false);
+ //here we getting inline table editor and disable it's too
+ nsIHTMLInlineTableEditor inlineTableEditor = (nsIHTMLInlineTableEditor)
editor.queryInterface(nsIHTMLInlineTableEditor.NS_IHTMLINLINETABLEEDITOR_IID);
+ inlineTableEditor.setInlineTableEditingEnabled(false);
+ }
+ return editor;
+ }
}
\ No newline at end of file
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/selection/VpeSelectionController.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/selection/VpeSelectionController.java 2008-07-15
13:51:27 UTC (rev 9145)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/selection/VpeSelectionController.java 2008-07-15
17:41:08 UTC (rev 9146)
@@ -12,41 +12,61 @@
package org.jboss.tools.vpe.editor.selection;
import org.mozilla.interfaces.nsISelection;
+import org.mozilla.interfaces.nsISelectionController;
/**
+ * Class decorator for nsISelectionController
* @author Maxim Areshkau
- * Class which replace nsISelectionController functionality
*/
public class VpeSelectionController {
- private nsISelection selection;
+ private nsISelectionController selectionController;
/**
* @param selection
*/
- public VpeSelectionController(nsISelection selection) {
- this.selection = selection;
+ public VpeSelectionController(nsISelectionController selectionController) {
+
+ setSelectionController(selectionController);
}
/**
* type - not used in
* @return the selection
*/
- public nsISelection getSelection(long type) {
- return selection;
+ public nsISelection getSelection(short type) {
+
+ return getSelectionController().getSelection(type);
}
-
+
/**
- * @param selection the selection to set
+ * Sets caret enables or disabled
+ * @param value
*/
- public void setSelection(nsISelection selection) {
- this.selection = selection;
- }
-
- //method stub just because it is exist in nsISelectionController
public void setCaretEnabled(boolean value){
+
+ getSelectionController().setCaretEnabled(value);
}
- //method stub just because it is exist in nsISelectionController
+ /**
+ * Sets selection flags
+ * @param selectionFlags
+ */
public void setSelectionFlags(short selectionFlags){
+
+ getSelectionController().setSelectionFlags(selectionFlags);
}
+
+ /**
+ * @return the selectionController
+ */
+ private nsISelectionController getSelectionController() {
+ return selectionController;
+ }
+
+ /**
+ * @param selectionController the selectionController to set
+ */
+ private void setSelectionController(nsISelectionController selectionController) {
+ this.selectionController = selectionController;
+ }
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/XPCOM.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/XPCOM.java 2008-07-15
13:51:27 UTC (rev 9145)
+++
trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/XPCOM.java 2008-07-15
17:41:08 UTC (rev 9146)
@@ -28,7 +28,12 @@
public static final String NS_SUPPORTSARRAY_CONTRACTID =
"(a)mozilla.org/supports-array;1"; //$NON-NLS-1$
public static final String IN_FLASHER_CONTRACTID =
"(a)mozilla.org/inspector/flasher;1"; //$NON-NLS-1$
+ /**
+ * Editing Session Contract ID
+ * see
http://www.xulplanet.com/references/xpcomref/ifaces/nsIEditingSession.html
+ */
+ public static final String
NS_EDITINGSESSION_CONTRACTID="(a)mozilla.org/editor/editingsession;1";
//$NON-NLS-1$
- public static final String NS_IWEBBROWSER_CID =
"F1EAC761-87E9-11d3-AF80-00A024FFC08C"; //$NON-NLS-1$
+ public static final String NS_IWEBBROWSER_CID =
"F1EAC761-87E9-11d3-AF80-00A024FFC08C"; //$NON-NLS-1$
public static final String NS_IAPPSHELL_CID =
"2d96b3df-c051-11d1-a827-0040959a28c9"; //$NON-NLS-1$
}