Author: vyemialyanchyk
Date: 2007-12-17 07:49:36 -0500 (Mon, 17 Dec 2007)
New Revision: 5327
Removed:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaBaseEventListener.java
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/VpeEditorPart.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeSelectionBuilder.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeSourceDomBuilder.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaDomEventListener.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/template/VpeAbstractTemplate.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeBreackerHelper.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/resize/VpeResizer.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/selbar/SelectionBar.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1457
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 2007-12-17
12:41:00 UTC (rev 5326)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2007-12-17
12:49:36 UTC (rev 5327)
@@ -689,7 +689,7 @@
return;
}
if (VpeDebug.PRINT_VISUAL_MOUSE_EVENT) {
- System.out.println("<<< mouseUp"); //$NON-NLS-1$
+ System.out.println("<<< mouseUp " + (mouseDownSelectionFlag ?
"true" : "false")); //$NON-NLS-1$
}
if (mouseDownSelectionFlag) {
mouseEvent.preventDefault();
@@ -2312,6 +2312,13 @@
public VpeSelectionBuilder getSelectionBuilder() {
return selectionBuilder;
}
+
+ /**
+ * @return the sourceBuilder
+ */
+ public VpeSourceDomBuilder getSourceBuilder() {
+ return sourceBuilder;
+ }
/**
* @param selectionBuilder the selectionBuilder to set
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeEditorPart.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeEditorPart.java 2007-12-17
12:41:00 UTC (rev 5326)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeEditorPart.java 2007-12-17
12:49:36 UTC (rev 5327)
@@ -66,15 +66,11 @@
public class VpeEditorPart extends EditorPart implements ITextEditor,
ITextEditorExtension, IReusableEditor, IVisualEditor {
private SashForm container;
- private StructuredTextEditor sourceEditor = null;
- private MozillaEditor visualEditor;
private IEditorPart activeEditor;
private XModelTreeListener listener;
XModelObject optionsObject;
private SelectionBar selectionBar = new SelectionBar();
private ActivationListener activationListener = new ActivationListener();
- private int visualMode = 0;
- private EditorPart multiPageEditor;
private static final QualifiedName SPLITTER_POSITION_KEY1 = new QualifiedName(
"", "splitter_position1");
private static final QualifiedName SPLITTER_POSITION_KEY2 = new QualifiedName(
@@ -84,16 +80,27 @@
private int controlCount = 0;
+ // parent editor
+ private EditorPart multiPageEditor;
+
+ // 4 tabs - VISUALSOURCE_MODE, VISUAL_MODE, SOURCE_MODE, PREVIEW_MODE
+ private int visualMode = 0;
/** default web-browser */
+ // visible in Preview tab
private MozillaPreview previewWebBrowser = null;
+ // visible in Visual/Source and in Visual tabs
+ private MozillaEditor visualEditor = null;
+ // visible in Visual/Source and in Source tabs - created in anycase active tab
+ private StructuredTextEditor sourceEditor = null;
/** preview content */
+ // preview
private Composite previewContent = null;
+ // visual
+ private Composite visualContent = null;
+ // source
+ private Composite sourceContent = null;
- public StructuredTextEditor getSourceEditor() {
- return sourceEditor;
- }
-
// returns JSPMultipageEditor for closing by ctrl+F4 and ctrl+shift+F4 keys
public EditorPart getParentEditor() {
return multiPageEditor;
@@ -223,7 +230,7 @@
}
public IAction getAction(String actionID) {
- return sourceEditor.getAction(actionID);
+ return getSourceEditor().getAction(actionID);
}
public VpeEditorPart() {
@@ -250,7 +257,7 @@
public void setInput(IEditorInput input) {
super.setInput(input);
- if (visualEditor != null && visualEditor.getEditorInput() != null
+ if (null != visualEditor && visualEditor.getEditorInput() != null
&& visualEditor.getEditorInput() != getEditorInput()) {
visualEditor.setInput(input);
}
@@ -322,80 +329,64 @@
}
}
- Composite sourceContent = null;
- Composite visualContent = null;
+ protected void setVisualMode(String showSelBar,
+ boolean flagSC, boolean flagVC, boolean flagPC) {
+ if (null != selectionBar) {
+ if (flagPC) {
+ getSourceEditor();
+ }
+ selectionBar.showBar(showSelBar);
+ }
+ if (null != sourceContent) {
+ sourceContent.setVisible(flagSC);
+ //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)&&controller!=null) {
+ // getVE().getController().visualRefresh();
+ //}
+ }
+ if (null != visualContent) {
+ if (flagVC) {
+ getVE();
+ }
+ visualContent.setVisible(flagVC);
+ }
+ if (null != previewContent) {
+ if (flagPC) {
+ getWB();
+ }
+ previewContent.setVisible(flagPC);
+ }
+ }
+
public void setVisualMode(int type) {
- String showSelectionBar = VpePreference.SHOW_SELECTION_TAG_BAR
- .getValue();
+ String showSelectionBar = VpePreference.SHOW_SELECTION_TAG_BAR.getValue();
switch (type) {
case VISUALSOURCE_MODE:
- selectionBar.showBar(showSelectionBar);
- if (sourceContent != null)
- sourceContent.setVisible(true);
- if (visualContent != null)
- visualContent.setVisible(true);
- if (previewContent != null) {
- previewContent.setVisible(false);
- }
+ setVisualMode(showSelectionBar, true, true, false);
break;
case VISUAL_MODE:
- selectionBar.showBar(showSelectionBar);
- if (sourceContent != null)
- sourceContent.setVisible(false);
- if (visualContent != null)
- visualContent.setVisible(true);
- if (previewContent != null) {
- previewContent.setVisible(false);
- }
+ setVisualMode(showSelectionBar, false, true, false);
break;
case SOURCE_MODE:
- selectionBar.showBar(showSelectionBar);
- if (sourceContent != null) {
- sourceContent.setVisible(true);
-
- //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)&&controller!=null) {
-//
-// visualEditor.getController().visualRefresh();
-// }
- }
- if (visualContent != null)
- visualContent.setVisible(false);
- if (previewContent != null) {
- previewContent.setVisible(false);
- }
+ setVisualMode(showSelectionBar, true, false, false);
break;
case PREVIEW_MODE:
- if (selectionBar != null) {
- selectionBar.showBar("no");
- }
- if (sourceContent != null) {
- sourceContent.setVisible(false);
- }
-
- if (visualContent != null) {
- visualContent.setVisible(false);
- }
-
- if (previewContent != null) {
- previewWebBrowser.rebuildDom();
- previewContent.setVisible(true);
- }
+ setVisualMode("no", false, false, true);
break;
}
container.layout();
if (visualMode == SOURCE_MODE && type != SOURCE_MODE) {
visualMode = type;
- if (visualEditor.getController() != null) {
- visualEditor.getController().visualRefresh();
- if(type!=PREVIEW_MODE) {
- visualEditor.getController().sourceSelectionChanged();
+ if (getVE().getController() != null) {
+ getVE().getController().visualRefresh();
+ if (type != PREVIEW_MODE) {
+ getVE().getController().sourceSelectionChanged();
}
}
}
@@ -408,10 +399,10 @@
public void createPartControl(Composite parent) {
controlCount++;
- if (controlCount > 1)
+ if (controlCount > 1) {
return;
+ }
// //////////////////////////////////////////////////////////////
-
Composite cmpEdTl = new Composite(parent, SWT.NONE);
GridLayout layoutEdTl = new GridLayout(1, false);
layoutEdTl.verticalSpacing = 0;
@@ -433,30 +424,21 @@
cmpEd.setLayout(layoutEd);
cmpEd.setLayoutData(new GridData(GridData.FILL_BOTH));
// /////////////////////////////////////////////////////////////////
+
container = new SashForm(cmpEd, SWT.VERTICAL);
container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- sourceContent = new Composite(container, SWT.NONE);
- sourceContent.setLayout(new FillLayout());
- visualContent = new Composite(container, SWT.NONE);
- visualContent.setLayout(new FillLayout());
-
- // Create a preview content
- previewContent = new Composite(container, SWT.NONE);
- previewContent.setLayout(new FillLayout());
-
+
// ////////////////////////////////////////////////////
-
selectionBar.createToolBarComposite(cmpEdTl, true);
// ///////////////////////////////////////////////////
- if (sourceEditor == null)
- sourceEditor = new StructuredTextEditor() {
- public void safelySanityCheckState(IEditorInput input) {
- super.safelySanityCheckState(input);
- }
- };
+
+ getSC();
+ getVC();
+ getPC();
int[] weights = loadSplitterPosition();
- if (weights != null)
+ if (weights != null) {
container.setWeights(weights);
+ }
container.addWeightsChangeListener(new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) {
saveSplitterPosition(container.getWeights());
@@ -471,106 +453,11 @@
container.layout();
}
});
- visualEditor = new MozillaEditor();
+ activeEditor = setupSourceEditor();
try {
- visualEditor.init(getEditorSite(), getEditorInput());
- } catch (Exception e) {
- VpePlugin.reportProblem(e);
- }
-
- previewWebBrowser = new MozillaPreview(this, sourceEditor);
- try {
- previewWebBrowser.init(getEditorSite(), getEditorInput());
- } catch (Exception e) {
- VpePlugin.reportProblem(e);
- }
-
- try {
- sourceEditor.addPropertyListener(new IPropertyListener() {
- public void propertyChanged(Object source, int propId) {
- if (propId == IWorkbenchPartConstants.PROP_TITLE) {
- VpeEditorPart.this.setPartName(sourceEditor.getTitle());
- }
- VpeEditorPart.this.firePropertyChange(propId);
- }
- });
- sourceEditor.init(getEditorSite(), getEditorInput());
-
- if (sourceContent != null) {
- sourceEditor.createPartControl(sourceContent);
- }
- if (visualEditor != null) {
- visualEditor
- .setEditorLoadWindowListener(new EditorLoadWindowListener() {
- public void load() {
- visualEditor.setEditorLoadWindowListener(null);
- visualEditor.setController(new VpeController(
- VpeEditorPart.this));
- selectionBar.setVpeController(visualEditor.getController());
- visualEditor.getController().setSelectionBarController(selectionBar);
- try {
- visualEditor.getController().init(sourceEditor, visualEditor);
- } catch (Exception e) {
- VpePlugin.reportProblem(e);
- }
- }
- });
- visualEditor.createPartControl(visualContent);
- }
-
- if (previewWebBrowser != null) {
- previewWebBrowser
- .setEditorLoadWindowListener(new EditorLoadWindowListener() {
- public void load() {
- previewWebBrowser
- .setEditorLoadWindowListener(null);
- previewWebBrowser.buildDom();
- }
- });
- previewWebBrowser.createPartControl(previewContent);
- }
-
- activeEditor = sourceEditor;
-
- sourceContent.addListener(SWT.Activate, new Listener() {
- public void handleEvent(Event event) {
- if (event.type == SWT.Activate) {
- if (activeEditor != sourceEditor) {
- activeEditor = sourceEditor;
- setFocus();
- }
- }
- }
- });
-
- visualContent.addListener(SWT.Activate, new Listener() {
- public void handleEvent(Event event) {
- if (event.type == SWT.Activate) {
- if (visualEditor != null
- && activeEditor != visualEditor) {
- activeEditor = visualEditor;
- setFocus();
- }
- }
- }
- });
-
- previewContent.addListener(SWT.Activate, new Listener() {
- public void handleEvent(Event event) {
- if (event.type == SWT.Activate) {
- if (previewWebBrowser != null
- && activeEditor != previewWebBrowser) {
- activeEditor = previewWebBrowser;
- setFocus();
- }
- }
- }
- });
-
IWorkbenchWindow window = getSite().getWorkbenchWindow();
window.getPartService().addPartListener(activationListener);
window.getShell().addShellListener(activationListener);
-
} catch (Exception e) {
VpePlugin.reportProblem(e);
}
@@ -684,9 +571,6 @@
fIsHandlingActivation = true;
try {
if (sourceEditor != null) {
- if (visualEditor.getController() != null) {
- visualEditor.getController().refreshTemplates();
- }
sourceEditor.safelySanityCheckState(getEditorInput());
}
} finally {
@@ -697,7 +581,146 @@
}
public VpeController getController() {
- return visualEditor.getController();
+ return getVE().getController();
}
+ public StructuredTextEditor getSourceEditor() {
+ return sourceEditor;
+ }
+
+ public Composite getSC() {
+ if (null != sourceContent) {
+ return sourceContent;
+ }
+ sourceContent = new Composite(container, SWT.NONE);
+ sourceContent.setLayout(new FillLayout());
+ return sourceContent;
+ }
+
+ public StructuredTextEditor setupSourceEditor() {
+ if (null == sourceEditor) {
+ sourceEditor = new StructuredTextEditor() {
+ public void safelySanityCheckState(IEditorInput input) {
+ super.safelySanityCheckState(input);
+ }
+ };
+ }
+ sourceEditor.addPropertyListener(new IPropertyListener() {
+ public void propertyChanged(Object source, int propId) {
+ if (propId == IWorkbenchPartConstants.PROP_TITLE) {
+ VpeEditorPart.this.setPartName(sourceEditor.getTitle());
+ }
+ VpeEditorPart.this.firePropertyChange(propId);
+ }
+ });
+ try {
+ sourceEditor.init(getEditorSite(), getEditorInput());
+ } catch (PartInitException e) {
+ VpePlugin.reportProblem(e);
+ }
+ sourceEditor.createPartControl(getSC());
+ getSC().addListener(SWT.Activate, new Listener() {
+ public void handleEvent(Event event) {
+ if (event.type == SWT.Activate) {
+ if (activeEditor != sourceEditor) {
+ activeEditor = sourceEditor;
+ setFocus();
+ }
+ }
+ }
+ });
+ return sourceEditor;
+ }
+
+ public Composite getVC() {
+ if (null != visualContent) {
+ return visualContent;
+ }
+ visualContent = new Composite(container, SWT.NONE);
+ visualContent.setLayout(new FillLayout());
+ return visualContent;
+ }
+
+ public MozillaEditor getVE() {
+ if (null != visualEditor) {
+ return visualEditor;
+ }
+ visualEditor = new MozillaEditor();
+ try {
+ visualEditor.init(getEditorSite(), getEditorInput());
+ } catch (Exception e) {
+ VpePlugin.reportProblem(e);
+ }
+ if (null == visualEditor) {
+ return visualEditor;
+ }
+ visualEditor.setEditorLoadWindowListener(new EditorLoadWindowListener() {
+ public void load() {
+ visualEditor.setEditorLoadWindowListener(null);
+ visualEditor.setController(new VpeController(VpeEditorPart.this));
+ selectionBar.setVpeController(visualEditor.getController());
+ visualEditor.getController().setSelectionBarController(selectionBar);
+ try {
+ visualEditor.getController().init(sourceEditor, visualEditor);
+ } catch (Exception e) {
+ VpePlugin.reportProblem(e);
+ }
+ }
+ });
+ visualEditor.createPartControl(getVC());
+ getVC().addListener(SWT.Activate, new Listener() {
+ public void handleEvent(Event event) {
+ if (event.type == SWT.Activate) {
+ if (null != visualEditor && activeEditor != visualEditor) {
+ activeEditor = visualEditor;
+ setFocus();
+ }
+ }
+ }
+ });
+ return visualEditor;
+ }
+
+ public Composite getPC() {
+ if (null != previewContent) {
+ return previewContent;
+ }
+ previewContent = new Composite(container, SWT.NONE);
+ previewContent.setLayout(new FillLayout());
+ return previewContent;
+ }
+
+ public MozillaPreview getWB() {
+ if (null != previewWebBrowser) {
+ return previewWebBrowser;
+ }
+ previewWebBrowser = new MozillaPreview(this, sourceEditor);
+ try {
+ previewWebBrowser.init(getEditorSite(), getEditorInput());
+ } catch (Exception e) {
+ VpePlugin.reportProblem(e);
+ }
+ if (null == previewWebBrowser) {
+ return previewWebBrowser;
+ }
+ previewWebBrowser.setEditorLoadWindowListener(new EditorLoadWindowListener() {
+ public void load() {
+ previewWebBrowser.setEditorLoadWindowListener(null);
+ previewWebBrowser.buildDom();
+ }
+ });
+ previewWebBrowser.createPartControl(getPC());
+ getPC().addListener(SWT.Activate, new Listener() {
+ public void handleEvent(Event event) {
+ if (event.type == SWT.Activate) {
+ if (null != previewWebBrowser && activeEditor != previewWebBrowser) {
+ activeEditor = previewWebBrowser;
+ setFocus();
+ }
+ }
+ }
+ });
+ return previewWebBrowser;
+ }
+
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeSelectionBuilder.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeSelectionBuilder.java 2007-12-17
12:41:00 UTC (rev 5326)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeSelectionBuilder.java 2007-12-17
12:49:36 UTC (rev 5327)
@@ -69,6 +69,9 @@
}
public void setSelection(nsISelection selection) {
+ if (VpeDebug.PRINT_VISUAL_MOUSE_EVENT) {
+ System.out.println("VpeSelectionBuilder.setSelection: selection.getIsCollapsed()
" + selection.getIsCollapsed());
+ }
if (selection.getIsCollapsed()) {
VisualSelectionInfo info = getVisualFocusSelectedInfo(selection);
if (info != null) {
@@ -367,12 +370,22 @@
private Node getSelectedTextOnly(nsIDOMNode element) {
Node selectedText = null;
nsISelection selection =
visualSelectionController.getSelection(nsISelectionController.SELECTION_NORMAL);
+ if (VpeDebug.PRINT_VISUAL_MOUSE_EVENT) {
+ System.out.println("VpeSelectionBuilder.getSelectedTextOnly: selection " +
+ (selection) +
+ " selection.getIsCollapsed() " +
+ (selection.getIsCollapsed()));
+ }
if (!selection.getIsCollapsed()) {
nsIDOMNode anchorNode = selection.getAnchorNode();
nsIDOMNode focusNode = selection.getFocusNode();
if (anchorNode != null && anchorNode.getNodeType() == Node.TEXT_NODE
&& anchorNode.equals(focusNode)) {
nsIDOMNode anchorParent = anchorNode.getParentNode();
if (anchorParent != null) {
+ if (VpeDebug.PRINT_VISUAL_MOUSE_EVENT) {
+ System.out.println("VpeSelectionBuilder.getSelectedTextOnly:
anchorParent.equals(element) " +
+ (anchorParent.equals(element)));
+ }
if (anchorParent.equals(element)) {
selectedText = domMapping.getSourceNode(anchorNode);
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeSourceDomBuilder.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeSourceDomBuilder.java 2007-12-17
12:41:00 UTC (rev 5326)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeSourceDomBuilder.java 2007-12-17
12:49:36 UTC (rev 5327)
@@ -28,6 +28,7 @@
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
+import org.jboss.tools.vpe.VpeDebug;
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.mapping.VpeDomMapping;
import org.jboss.tools.vpe.editor.mapping.VpeElementMapping;
@@ -162,6 +163,10 @@
}
void setSelection(Node sourceNode, int offset, int length, boolean innerFlag) {
+ if (VpeDebug.PRINT_VISUAL_MOUSE_EVENT) {
+ System.out.println("VpeSourceDomBuilder.setSelection: offset " + offset +
+ " length " + length + " innerFlag " + innerFlag);
+ }
if (sourceNode != null) {
int start = ((IndexedRegion)sourceNode).getStartOffset() + offset;
if (innerFlag && offset == 0 && sourceNode instanceof ElementImpl) {
Deleted:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaBaseEventListener.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaBaseEventListener.java 2007-12-17
12:41:00 UTC (rev 5326)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaBaseEventListener.java 2007-12-17
12:49:36 UTC (rev 5327)
@@ -1,87 +0,0 @@
-/*******************************************************************************
- * 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.mozilla;
-
-
-import org.mozilla.interfaces.nsIClipboardDragDropHooks;
-import org.mozilla.interfaces.nsIDOMEvent;
-import org.mozilla.interfaces.nsIDragSession;
-import org.mozilla.interfaces.nsISupports;
-import org.mozilla.interfaces.nsITransferable;
-import org.mozilla.xpcom.Mozilla;
-
-public class MozillaBaseEventListener implements nsIClipboardDragDropHooks {
- // TODO Max Areshkau add DnD support
-// private XPCOMObject dropListener;
-// private VpeDnD dnd;
-// private int refCount = 0;
-
-
- public MozillaBaseEventListener() {
- // TODO Max Areshkau delete this reference afrer DnD had been added
-// createCOMInterfaces();
- }
-
- void createCOMInterfaces() {
- // TODO Max Areshkau delete this reference afrer DnD had been added
-// // VpeDnD
-// dropListener = new XPCOMObject(new int[]{2,0,0,4,4,3,6,5}) {
-// public int method0(int[] args) {return QueryInterface(args[0], args[1]);}
-// public int method1(int[] args) {return AddRef();}
-// public int method2(int[] args) {return Release();}
-// public int method3(int[] args) {return CanDrag(args[0], args[1], args[2],
args[3]);}
-// public int method4(int[] args) {return CanDrop(args[0], args[1], args[2],
args[3]);}
-// public int method5(int[] args) {return Drop(args[0], args[1], args[2]);}
-// public int method6(int[] args) {return CanDropExternal(args[0], args[1], args[2],
args[3], args[4], args[5]);}
-// public int method7(int[] args) {return DropExternal(args[0], args[1], args[2],
args[3], args[4]);}
-// };
-
- // TODO Max Areshkau delete this reference afrer DnD had been added
-// dnd = getDnD();
- }
-
- /* (non-Javadoc)
- * @see
org.mozilla.interfaces.nsIClipboardDragDropHooks#allowDrop(org.mozilla.interfaces.nsIDOMEvent,
org.mozilla.interfaces.nsIDragSession)
- */
- public boolean allowDrop(nsIDOMEvent event, nsIDragSession dragSession) {
- event.preventDefault();
- event.stopPropagation();
- return false;
- }
-
- /* (non-Javadoc)
- * @see
org.mozilla.interfaces.nsIClipboardDragDropHooks#allowStartDrag(org.mozilla.interfaces.nsIDOMEvent)
- */
- public boolean allowStartDrag(nsIDOMEvent event) {
- return false;
- }
-
- /* (non-Javadoc)
- * @see
org.mozilla.interfaces.nsIClipboardDragDropHooks#onCopyOrDrag(org.mozilla.interfaces.nsIDOMEvent,
org.mozilla.interfaces.nsITransferable)
- */
- public boolean onCopyOrDrag(nsIDOMEvent event, nsITransferable transferable) {
- return false;
- }
-
- /* (non-Javadoc)
- * @see
org.mozilla.interfaces.nsIClipboardDragDropHooks#onPasteOrDrop(org.mozilla.interfaces.nsIDOMEvent,
org.mozilla.interfaces.nsITransferable)
- */
- public boolean onPasteOrDrop(nsIDOMEvent event, nsITransferable transferable) {
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.mozilla.interfaces.nsISupports#queryInterface(java.lang.String)
- */
- public nsISupports queryInterface(String arg0) {
- return Mozilla.queryInterface(this, arg0);
- }
-}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaDomEventListener.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaDomEventListener.java 2007-12-17
12:41:00 UTC (rev 5326)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaDomEventListener.java 2007-12-17
12:49:36 UTC (rev 5327)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.vpe.editor.mozilla;
+import org.jboss.tools.vpe.VpeDebug;
import org.jboss.tools.vpe.VpePlugin;
import org.jboss.tools.vpe.editor.VpeController;
import org.jboss.tools.vpe.xulrunner.editor.XulRunnerEditor;
@@ -196,6 +197,11 @@
* @see
org.mozilla.interfaces.nsISelectionListener#notifySelectionChanged(org.mozilla.interfaces.nsIDOMDocument,
org.mozilla.interfaces.nsISelection, short)
*/
public void notifySelectionChanged(nsIDOMDocument domDocument, nsISelection selection,
short reason) {
+ if (VpeDebug.PRINT_VISUAL_MOUSE_EVENT) {
+ System.out.println("MozillaDomEventListener.notifySelectionChanged:
editorDomEventListener " +
+ (editorDomEventListener) + " reason " +
+ (reason));
+ }
if (editorDomEventListener != null) {
editorDomEventListener.notifySelectionChanged(domDocument, selection, reason);
}
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 2007-12-17
12:41:00 UTC (rev 5326)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaEditor.java 2007-12-17
12:49:36 UTC (rev 5327)
@@ -71,14 +71,11 @@
static String SELECT_BAR = "SELECT_LBAR"; //$NON-NLS-1$
private XulRunnerEditor xulRunnerEditor;
- private nsIDOMDocument domDocument;
private nsIDOMEventTarget documentEventTarget;
private nsIDOMElement contentArea;
private nsIDOMNode headNode;
private nsIDOMEventTarget contentAreaEventTarget;
private MozillaDomEventListener contentAreaEventListener = new
MozillaDomEventListener();
- //TODO Max Areshkau may be we need delete this
- private MozillaBaseEventListener baseEventListener = null;
private EditorLoadWindowListener editorLoadWindowListener;
//
private EditorDomEventListener editorDomEventListener;
@@ -326,19 +323,11 @@
}
public nsIDOMDocument getDomDocument() {
- if (domDocument == null) {
- domDocument = xulRunnerEditor.getDOMDocument();
+ if (null != xulRunnerEditor) {
+ return xulRunnerEditor.getDOMDocument();
}
- return domDocument;
+ return null;
}
-
- /**
- * @param domDocument the domDocument to set
- */
- protected void setDomDocument(nsIDOMDocument domDocument) {
-
- this.domDocument = domDocument;
- }
public nsIDOMElement getContentArea() {
return contentArea;
@@ -482,8 +471,6 @@
contentAreaEventTarget.addEventListener(MozillaDomEventListener.DBLCLICK,
contentAreaEventListener, false);//$NON-NLS-1$
documentEventTarget = (nsIDOMEventTarget)
getDomDocument().queryInterface(nsIDOMEventTarget.NS_IDOMEVENTTARGET_IID);
documentEventTarget.addEventListener(MozillaDomEventListener.KEYPRESS,
contentAreaEventListener, false); //$NON-NLS-1$
- } else {
- baseEventListener = new MozillaBaseEventListener();
}
}
}
@@ -503,7 +490,7 @@
contentAreaEventTarget.removeEventListener(MozillaDomEventListener.DBLCLICK,
contentAreaEventListener, false);//$NON-NLS-1$
}
- if (domDocument != null && documentEventTarget != null) {
+ if (documentEventTarget != null) {
documentEventTarget.removeEventListener(MozillaDomEventListener.KEYPRESS,
contentAreaEventListener, false); //$NON-NLS-1$
}
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAbstractTemplate.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAbstractTemplate.java 2007-12-17
12:41:00 UTC (rev 5326)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAbstractTemplate.java 2007-12-17
12:49:36 UTC (rev 5327)
@@ -340,7 +340,7 @@
case BREAKER_TYPE_IGNORE:
return true;
case BREAKER_TYPE_SELECTITEM:
- return VpeBreackerHelper.selectItem(pageContext, sourceDocument, sourceNode,
visualNode, data, charCode, selection);
+ return VpeBreackerHelper.selectItem(pageContext.getSourceBuilder(), sourceDocument,
sourceNode, visualNode, data, charCode, selection);
default:
return nonctrlKeyPressHandlerImpl(pageContext, sourceDocument, sourceNode,
visualNode, data, charCode, selection, formatter);
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeBreackerHelper.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeBreackerHelper.java 2007-12-17
12:41:00 UTC (rev 5326)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeBreackerHelper.java 2007-12-17
12:49:36 UTC (rev 5327)
@@ -16,14 +16,14 @@
import org.w3c.dom.Document;
import org.w3c.dom.Node;
-import org.jboss.tools.vpe.editor.context.VpePageContext;
+import org.jboss.tools.vpe.editor.VpeSourceDomBuilder;
import org.jboss.tools.vpe.editor.selection.VpeSourceSelection;
import org.jboss.tools.vpe.editor.util.HTML;
import org.mozilla.interfaces.nsIDOMNode;
public class VpeBreackerHelper {
- public static boolean selectItem(VpePageContext pageContext, Document sourceDocument,
Node sourceNode, nsIDOMNode visualNode, Object data, long charCode, VpeSourceSelection
selection) {
+ public static boolean selectItem(VpeSourceDomBuilder sourceBuilder, Document
sourceDocument, Node sourceNode, nsIDOMNode visualNode, Object data, long charCode,
VpeSourceSelection selection) {
Attr attr = selection.getFocusAttribute();
if (attr != null) {
Point range = selection.getFocusAttributeRange();
@@ -43,7 +43,7 @@
if (newAttr != null) {
newAttr.setNodeValue(newAttr.getNodeValue().substring(0, range.x));
}
- pageContext.getSourceBuilder().setAttributeSelection((Attr)attr, 0, 0);
+ sourceBuilder.setAttributeSelection((Attr)attr, 0, 0);
return true;
}
}
@@ -51,7 +51,7 @@
return false;
}
- public static boolean breakInline(VpePageContext pageContext, Document sourceDocument,
Node sourceNode, Node visualNode, Object data, int charCode, VpeSourceSelection selection)
{
+ public static boolean breakInline(VpeSourceDomBuilder sourceBuilder, Document
sourceDocument, Node sourceNode, Node visualNode, Object data, int charCode,
VpeSourceSelection selection) {
Attr attr = selection.getFocusAttribute();
if (attr != null) {
Point range = selection.getFocusAttributeRange();
@@ -72,7 +72,7 @@
if (newAttr != null) {
newAttr.setNodeValue(newAttr.getNodeValue().substring(0, range.x));
}
- pageContext.getSourceBuilder().setAttributeSelection((Attr)attr, 0, 0);
+ sourceBuilder.setAttributeSelection((Attr)attr, 0, 0);
}
Node parent = selectItemNode.getParentNode();
if (parent != null) {
@@ -85,7 +85,7 @@
selectItemNode = parent.removeChild(newSelectItemNode);
p2.appendChild(newSelectItemNode);
- pageContext.getSourceBuilder().getStructuredTextViewer()
+ sourceBuilder.getStructuredTextViewer()
.setSelectedRange(((IndexedRegion)p1).getStartOffset(),
((IndexedRegion)p2).getEndOffset() - ((IndexedRegion)p1).getStartOffset());
return true;
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/resize/VpeResizer.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/resize/VpeResizer.java 2007-12-17
12:41:00 UTC (rev 5326)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/resize/VpeResizer.java 2007-12-17
12:49:36 UTC (rev 5327)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.vpe.editor.template.resize;
+import org.jboss.tools.jst.jsp.preferences.VpePreference;
import org.jboss.tools.vpe.VpePlugin;
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.template.VpeTagDescription;
@@ -80,6 +81,13 @@
}
}
+ public boolean isAbsolutePosition(){
+ if ("yes".equals(VpePreference.USE_ABSOLUTE_POSITION.getValue())) {
+ return true;
+ }
+ return false;
+ }
+
/**
*
* @param pageContext
@@ -95,7 +103,7 @@
*/
public void resize(VpePageContext pageContext, Element sourceElement, nsIDOMDocument
visualDocument, nsIDOMElement visualElement, Object data, int resizeConstrant, int top,
int left, int width, int height) {
pageContext.getEditPart().getSourceEditor().getTextViewer().getUndoManager().beginCompoundChange();
- if (pageContext.isAbsolutePosition() && (
+ if (isAbsolutePosition() && (
resizeConstrant == VpeTagDescription.RESIZE_CONSTRAINS_BOTTOMLEFT||
resizeConstrant == VpeTagDescription.RESIZE_CONSTRAINS_LEFT||
resizeConstrant == VpeTagDescription.RESIZE_CONSTRAINS_TOPLEFT||
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/selbar/SelectionBar.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/selbar/SelectionBar.java 2007-12-17
12:41:00 UTC (rev 5326)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/selbar/SelectionBar.java 2007-12-17
12:49:36 UTC (rev 5327)
@@ -286,9 +286,9 @@
}
private void setSourceFocus(int offset) {
- vpeController.getPageContext().getSourceBuilder()
+ vpeController.getSourceBuilder()
.getStructuredTextViewer().setSelectedRange(offset, 0);
- vpeController.getPageContext().getSourceBuilder()
+ vpeController.getSourceBuilder()
.getStructuredTextViewer().revealRange(offset, 0);
}