Author: yradtsevich
Date: 2009-04-25 09:51:51 -0400 (Sat, 25 Apr 2009)
New Revision: 14920
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java
Log:
issue JBIDE-3197: Add support for custom facelets tags
https://jira.jboss.org/jira/browse/JBIDE-3197
- the rule for VPE jobs (VisualTreeChangingRule) has been adjusted in such a way that it
can contain any resource-changing rules. It is needed for the custom facelets when the
properties are being saved.
- minor: the code has been formatted
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 2009-04-25
11:29:26 UTC (rev 14919)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2009-04-25
13:51:51 UTC (rev 14920)
@@ -16,6 +16,7 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
@@ -245,7 +246,8 @@
domMapping = new VpeDomMapping(pageContext);
sourceBuilder = new VpeSourceDomBuilder(domMapping, this,
VpeTemplateManager.getInstance(), sourceEditor, pageContext);
- visualBuilder = new VpeVisualDomBuilder(domMapping, this, visualEditor, pageContext);
+ visualBuilder = new VpeVisualDomBuilder(domMapping, this, visualEditor,
+ pageContext);
pageContext.setSourceDomBuilder(sourceBuilder);
pageContext.setVisualDomBuilder(visualBuilder);
IDOMModel sourceModel = (IDOMModel) getModel();
@@ -270,7 +272,8 @@
}
IDOMDocument sourceDocument = sourceModel.getDocument();
- // FIXED FOR JBIDE-3799 by sdzmitrovich, moved calling of this method to buid dom
+ // FIXED FOR JBIDE-3799 by sdzmitrovich, moved calling of
+ // this method to buid dom
// visualBuilder.refreshExternalLinks();
visualBuilder.buildDom(sourceDocument);
@@ -281,7 +284,8 @@
// presShell = browser.getPresShell();
//initialization visual selection controller
- visualSelectionController = new
VpeSelectionController(visualEditor.getEditor().getSelectionController());
+ visualSelectionController = new VpeSelectionController(
+ visualEditor.getEditor().getSelectionController());
selectionBuilder = new VpeSelectionBuilder(domMapping, sourceBuilder,
visualBuilder, visualSelectionController);
@@ -346,7 +350,8 @@
vpeUpdateDelayTime = 400;
// pageContext.fireTaglibsChanged();
- // yradtsevich: we have to refresh VPE selection on init (fix of JBIDE-4037)
+ // yradtsevich: we have to refresh VPE selection on init
+ // (fix of JBIDE-4037)
sourceSelectionChanged(true);
}
@@ -368,7 +373,8 @@
}
if (optionsListener != null) {
- XModelObject optionsObject =
ModelUtilities.getPreferenceModel().getByPath(VpePreference.EDITOR_PATH);
+ XModelObject optionsObject = ModelUtilities.getPreferenceModel()
+ .getByPath(VpePreference.EDITOR_PATH);
optionsObject.getModel().removeModelTreeListener(optionsListener);
optionsListener.dispose();
optionsListener = null;
@@ -457,7 +463,7 @@
if (PlatformUI.isWorkbenchRunning())
display = PlatformUI.getWorkbench().getDisplay();
- if (display != null && (Thread.currentThread() == display.getThread())) {
+ if (display != null && Thread.currentThread() == display.getThread()) {
getChangeEvents().addLast(
new VpeEventBean(notifier, eventType, feature, oldValue,
newValue, pos));
@@ -465,17 +471,22 @@
uiJob = new UIJob(VpeUIMessages.VPE_UPDATE_JOB_TITLE) {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
- monitor.beginTask(VpeUIMessages.VPE_UPDATE_JOB_TITLE, 100);
+ monitor.beginTask(VpeUIMessages.VPE_UPDATE_JOB_TITLE,
+ 100);
while (getChangeEvents().size() > 0) {
- monitor.worked((int) (100 / getChangeEvents().size()));
- VpeEventBean eventBean = getChangeEvents().getFirst();
+ monitor.worked(
+ (int) (100 / getChangeEvents().size()));
+ VpeEventBean eventBean = getChangeEvents()
+ .getFirst();
if (monitor.isCanceled()) {
- /* Yahor Radtsevich: the following line is commented
- * as fix of JBIDE-3758: VPE autorefresh is broken in some cases.
- * Now if the change events queue should be cleared, the programmer
- * have to do it explicitly.
+ /* Yahor Radtsevich: the following line is
+ * commented as the fix of JBIDE-3758:
+ * VPE autorefresh is broken in some cases.
+ * Now if the change events queue should be
+ * cleared, the programmer have to do it
+ * explicitly.
*/
- // getChangeEvents().clear();
+ // getChangeEvents().clear();
return Status.CANCEL_STATUS;
}
try {
@@ -506,18 +517,22 @@
}
// cause is to lock calls others events
if (switcher != null &&
- switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE))
+ switcher.startActiveEditor(ActiveEditorSwitcher
+ .ACTIVE_EDITOR_SOURCE))
try {
sourceSelectionChanged();
/*
*
https://jira.jboss.org/jira/browse/JBIDE-3619
- * VpeViewUpdateJob takes place after toolbar selection have been updated.
+ * VpeViewUpdateJob takes place after toolbar
+ * selection have been updated.
* New nodes haven't been put into dom mapping
* thus toolbar becomes desabled.
- * Updating toolbar state here takes into account updated vpe nodes.
+ * Updating toolbar state here takes into
+ * account updated vpe nodes.
*/
if (toolbarFormatControllerManager != null) {
- toolbarFormatControllerManager.selectionChanged();
+ toolbarFormatControllerManager
+ .selectionChanged();
}
} finally {
switcher.stopActiveEditor();
@@ -548,11 +563,12 @@
job = new UIJob("NotifyChangedJob") {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
- // we checks is job was canceled and if is it true we cancel job
+ // we check if job was canceled and if is it true cancel the job
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
} else {
- notifyChangedInUiThread(notifier, eventType, feature, oldValue, newValue, pos);
+ notifyChangedInUiThread(notifier, eventType, feature,
+ oldValue, newValue, pos);
}
return Status.OK_STATUS;
}
@@ -564,12 +580,14 @@
public void notifyChangedInUiThread(INodeNotifier notifier, int eventType,
Object feature, Object oldValue, Object newValue, int pos) {
if (switcher == null ||
- !switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
+ !switcher.startActiveEditor(ActiveEditorSwitcher
+ .ACTIVE_EDITOR_SOURCE)) {
return;
}
try {
if (VpeDebug.PRINT_SOURCE_MUTATION_EVENT) {
- printSourceEvent(notifier, eventType, feature, oldValue, newValue, pos);
+ printSourceEvent(notifier, eventType, feature,
+ oldValue, newValue, pos);
}
if (visualBuilder == null) {
return;
@@ -588,25 +606,28 @@
if (!update)
visualBuilder.updateNode((Node) notifier);
} else if (type == Node.COMMENT_NODE) {
- if ("yes".equals(VpePreference.SHOW_COMMENTS.getValue())) { //$NON-NLS-1$
+ if ("yes".equals( //$NON-NLS-1$
+ VpePreference.SHOW_COMMENTS.getValue())) {
visualBuilder.setSelectionRectangle(null);
visualBuilder.updateNode((Node) notifier);
}
} else if (feature != null
- && ((Node) feature).getNodeType() == Node.ATTRIBUTE_NODE) {
+ && ((Node)feature).getNodeType()==Node.ATTRIBUTE_NODE) {
if (newValue != null) {
String attrName = ((Attr) feature).getName();
if ((Attr) feature == lastRemovedAttr
&& !attrName.equals(lastRemovedAttrName)) {
lastRemovedAttr = null;
- visualBuilder.removeAttribute((Element) notifier, lastRemovedAttrName);
+ visualBuilder.removeAttribute((Element) notifier,
+ lastRemovedAttrName);
}
visualBuilder.setAttribute((Element) notifier,
((Attr) feature).getName(), (String) newValue);
} else {
lastRemovedAttr = (Attr) feature;
lastRemovedAttrName = ((Attr) feature).getName();
- visualBuilder.removeAttribute((Element) notifier, lastRemovedAttrName);
+ visualBuilder.removeAttribute((Element) notifier,
+ lastRemovedAttrName);
}
}
visualEditor.showResizer();
@@ -630,7 +651,8 @@
case INodeNotifier.CONTENT_CHANGED:
if (!sourceChangeFlag) {
if (feature != null
- && ((Node) feature).getNodeType() == Node.TEXT_NODE) {
+ && ((Node) feature).getNodeType()
+ == Node.TEXT_NODE) {
// if
// (((Node)notifier).getNodeName().equalsIgnoreCase(
// "style"))
@@ -659,7 +681,8 @@
// INodeSelectionListener implementation
public void nodeSelectionChanged(NodeSelectionChangedEvent event) {
- if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
+ if (!switcher.startActiveEditor(
+ ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
return;
}
try {
@@ -667,8 +690,11 @@
if (nodes != null && nodes.size() > 0) {
Node sourceNode = (Node) nodes.get(0);
if (VpeDebug.PRINT_SOURCE_SELECTION_EVENT) {
- System.out.println(">>>>>>>>>>>>>>
nodeSelectionChanged sourceNode: " + //$NON-NLS-1$
- sourceNode.getNodeName() + Constants.WHITE_SPACE + event.getCaretPosition());
+ System.out.println(">>>>>>>>>>>>>>
" //$NON-NLS-1$
+ + "nodeSelectionChanged " //$NON-NLS-1$
+ + "sourceNode: " //$NON-NLS-1$
+ + sourceNode.getNodeName()
+ + " " + event.getCaretPosition()); //$NON-NLS-1$
}
if (event.getSource() instanceof IContentOutlinePage) {
sourceSelectionChanged();
@@ -682,12 +708,15 @@
// ITextSelectionListener implementation
// TODO Max Areshau looks like this method don't used
public void textSelectionChanged(TextSelectionChangedEvent event) {
- if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
+ if (!switcher.startActiveEditor(
+ ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
return;
}
try {
if (VpeDebug.PRINT_SOURCE_SELECTION_EVENT) {
- System.out.println(">>>>>>>>>>>>>>
textSelectionChanged " + event.getSource()); //$NON-NLS-1$
+ System.out.println(">>>>>>>>>>>>>>
" //$NON-NLS-1$
+ + "textSelectionChanged " //$NON-NLS-1$
+ + event.getSource());
}
// if (event.getSource() instanceof StyledText) {
sourceSelectionChanged();
@@ -699,12 +728,14 @@
// SelectionListener implementation
public void widgetSelected(SelectionEvent event) {
- if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
+ if (!switcher.startActiveEditor(
+ ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
return;
}
try {
if (VpeDebug.PRINT_SOURCE_SELECTION_EVENT) {
- System.out.println(">>>>>>>>>>>>>>
widgetSelected"); //$NON-NLS-1$
+ System.out.println(">>>>>>>>>>>>>>
" //$NON-NLS-1$
+ + "widgetSelected"); //$NON-NLS-1$
}
if (event.getSource() instanceof StyledText) {
sourceSelectionChanged();
@@ -716,7 +747,8 @@
public void widgetDefaultSelected(SelectionEvent event) {
if (VpeDebug.PRINT_SOURCE_SELECTION_EVENT) {
- System.out.println(">>>>>>>>>>>>>>
widgetDefaultSelected"); //$NON-NLS-1$
+ System.out.println(">>>>>>>>>>>>>>
" //$NON-NLS-1$
+ + "widgetDefaultSelected"); //$NON-NLS-1$
}
}
@@ -778,9 +810,15 @@
// if (VpeDebug.PRINT_SOURCE_SELECTION_EVENT) {
// System.out.println("sourceSelectionChanged"); //$NON-NLS-1$
// System.out
- // .println(" anchorNode: " + anchorNode.getNodeName() +
" anchorOffset: " + anchorOffset); //$NON-NLS-1$ //$NON-NLS-2$
+ // .println(" anchorNode: " //$NON-NLS-1$
+ // + anchorNode.getNodeName()
+ // + " anchorOffset: " //$NON-NLS-1$
+ // + anchorOffset);
// System.out
- // .println(" focusNode: " + focusNode.getNodeName() +
" focusOffset: " + focusOffset + " focusPosition: " +
focusPosition); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ // .println(" focusNode: " //$NON-NLS-1$
+ // + focusNode.getNodeName()
+ // + " focusOffset: " + focusOffset //$NON-NLS-1$
+ // + " focusPosition: " + focusPosition); //$NON-NLS-1$
// }
// try {
// if (anchorNode.getNodeType() == Node.TEXT_NODE
@@ -818,7 +856,8 @@
}
public void sourceSelectionToVisualSelection(boolean showCaret) {
- if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
+ if (!switcher.startActiveEditor(
+ ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
return;
}
try {
@@ -833,15 +872,17 @@
}
public void processPostModelEvent(ModelLifecycleEvent event) {
- if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
+ if (!switcher.startActiveEditor(
+ ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
return;
}
try {
/*
* Added by Max Areshkau JBIDE-1457
- * ModelLifecycleEvent.MODEL_RELEASED is generated when model in model
- * calls methods releaseFromRead() or releaseFromEdit(). When editor
- * is open he has only when href on model, so nothing can generated
+ * ModelLifecycleEvent.MODEL_RELEASED is generated
+ * when model in model calls methods releaseFromRead()
+ * or releaseFromEdit(). When editor is open he has only
+ * when href on model, so nothing can generated
* this event.When editor closes generation of this event depends
* from containing any service href on model or not. It's can be a
* reason of problems on reopen file.
@@ -850,9 +891,12 @@
*/
if (event.getType() == ModelLifecycleEvent.MODEL_RELEASED) {
if (VpeDebug.PRINT_SOURCE_MODEL_LIFECYCLE_EVENT) {
- System.out.println(">>> processPostModelEvent: " +
event.toString()); //$NON-NLS-1$
+ System.out.println(">>> " //$NON-NLS-1$
+ + "processPostModelEvent: " //$NON-NLS-1$
+ + event.toString());
}
- // commented to fix org.mozilla.xpcom.XPCOMException: The function
"repaint" returned an error condition (0x8000ffff)
+ // commented to fix org.mozilla.xpcom.XPCOMException: The
+ // function "repaint" returned an error condition (0x8000ffff)
//visualBuilder.setSelectionRectangle(null);
IStructuredModel model = event.getModel();
model.removeModelLifecycleListener(this);
@@ -873,7 +917,8 @@
// EditorDomEventListener implementation
public void subtreeModified(nsIDOMMutationEvent mutationEvent) {
- if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
+ if (!switcher.startActiveEditor(
+ ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
return;
}
try {
@@ -886,7 +931,8 @@
}
public void nodeInserted(nsIDOMMutationEvent mutationEvent) {
- if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
+ if (!switcher.startActiveEditor(
+ ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
return;
}
try {
@@ -904,7 +950,8 @@
}
public void nodeRemoved(nsIDOMMutationEvent mutationEvent) {
- if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
+ if (!switcher.startActiveEditor(
+ ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
return;
}
try {
@@ -923,7 +970,8 @@
}
public void nodeRemovedFromDocument(nsIDOMMutationEvent mutationEvent) {
- if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
+ if (!switcher.startActiveEditor(
+ ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
return;
}
try {
@@ -936,7 +984,8 @@
}
public void nodeInsertedIntoDocument(nsIDOMMutationEvent mutationEvent) {
- if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
+ if (!switcher.startActiveEditor(
+ ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
return;
}
try {
@@ -949,7 +998,8 @@
}
public void attrModified(nsIDOMMutationEvent mutationEvent) {
- if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
+ if (!switcher.startActiveEditor(
+ ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
return;
}
try {
@@ -962,7 +1012,8 @@
}
public void characterDataModified(nsIDOMMutationEvent mutationEvent) {
- if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
+ if (!switcher.startActiveEditor(
+ ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
return;
}
try {
@@ -977,10 +1028,13 @@
}
}
- public void notifySelectionChanged(nsIDOMDocument doc, nsISelection selection, short
reason) {
- if (switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
+ public void notifySelectionChanged(nsIDOMDocument doc,
+ nsISelection selection, short reason) {
+ if (switcher.startActiveEditor(
+ ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
try {
- mouseUpSelectionReasonFlag = (reason & nsISelectionListener.MOUSEUP_REASON) >
0;
+ mouseUpSelectionReasonFlag
+ = (reason & nsISelectionListener.MOUSEUP_REASON) > 0;
if (mouseUpSelectionReasonFlag
// commited by Dzmitrovich - experimental
// TODO check selection and if are appear errors then
@@ -988,9 +1042,11 @@
// || reason == nsISelectionListener.NO_REASON
|| reason == nsISelectionListener.KEYPRESS_REASON
|| reason == nsISelectionListener.SELECTALL_REASON
- || (reason & nsISelectionListener.MOUSEDOWN_REASON) > 0) {
+ || (reason&nsISelectionListener.MOUSEDOWN_REASON) > 0) {
if (VpeDebug.PRINT_VISUAL_SELECTION_EVENT) {
- System.out.println("<<< notifySelectionChanged: " + reason);
//$NON-NLS-1$
+ System.out.println("<<< " //$NON-NLS-1$
+ + "notifySelectionChanged: " //$NON-NLS-1$
+ + reason);
}
nsIDOMNode node = SelectionUtil.getSelectedNode(selection);
/*
@@ -1011,7 +1067,8 @@
}
public void mouseDown(nsIDOMMouseEvent mouseEvent) {
- if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
+ if (!switcher.startActiveEditor(
+ ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
return;
}
try {
@@ -1028,22 +1085,22 @@
// .getDragElement(mouseEvent);
if (VpeDebug.PRINT_VISUAL_MOUSE_EVENT) {
nsIDOMNode visualNode = VisualDomUtil.getTargetNode(mouseEvent);
- System.out.println("<<< mouseDown targetNode: " /* //$NON-NLS-1$
- * +visualNode.
- * getNodeName()
- * + " (" +
- * visualNode +
- * ") selectedElement: "
- * +(
- * visualDragElement
- * != null ?
- * visualDragElement
- * .
- * getNodeName()
- * + " (" +
- * visualDragElement
- * + ")" : null)
- */);
+ System.out.println("<<< mouseDown targetNode: " //$NON-NLS-1$
+ /* +visualNode.
+ * getNodeName()
+ * + " (" +
+ * visualNode +
+ * ") selectedElement: "
+ * +(
+ * visualDragElement
+ * != null ?
+ * visualDragElement
+ * .
+ * getNodeName()
+ * + " (" +
+ * visualDragElement
+ * + ")" : null)
+ */);
}
//
// if (visualDragElement != null) {
@@ -1078,7 +1135,8 @@
}
public void mouseUp(nsIDOMMouseEvent mouseEvent) {
- if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
+ if (!switcher.startActiveEditor(
+ ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
return;
}
try {
@@ -1097,7 +1155,8 @@
}
public void mouseClick(nsIDOMMouseEvent mouseEvent) {
- if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
+ if (!switcher.startActiveEditor(
+ ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
return;
}
try {
@@ -1105,8 +1164,11 @@
if (visualNode != null) {
if (!mouseUpSelectionReasonFlag) {
if (VpeDebug.PRINT_VISUAL_MOUSE_EVENT) {
- System.out.println("<<< mouseClick visualNode: " +
visualNode.getNodeName() + //$NON-NLS-1$
- " (" + visualNode + ")"); //$NON-NLS-1$ //$NON-NLS-2$
+ System.out.println("<<< " //$NON-NLS-1$
+ + "mouseClick visualNode: " //$NON-NLS-1$
+ + visualNode.getNodeName()
+ + " (" //$NON-NLS-1$
+ + visualNode + ")"); //$NON-NLS-1$
}
if (visualBuilder.isContentArea(visualNode)) {
// selectionBuilder.setClickContentAreaSelection();
@@ -1115,7 +1177,8 @@
mouseUpSelectionReasonFlag = false;
}
- if (visualBuilder.doToggle(VisualDomUtil.getTargetNode(mouseEvent))) {
+ if (visualBuilder.doToggle(
+ VisualDomUtil.getTargetNode(mouseEvent))) {
// selectionBuilder.setClickContentAreaSelection();
}
}
@@ -1125,7 +1188,8 @@
}
public void mouseDblClick(nsIDOMMouseEvent mouseEvent) {
- if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
+ if (!switcher.startActiveEditor(
+ ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
return;
}
try {
@@ -1135,8 +1199,11 @@
sourceBuilder.openIncludeEditor(visualNode);
}
if (VpeDebug.PRINT_VISUAL_MOUSE_EVENT) {
- System.out.println("<<< mouseDblClick visualNode: " +
visualNode.getNodeName() + //$NON-NLS-1$
- " (" + visualNode + ")"); //$NON-NLS-1$ //$NON-NLS-2$
+ System.out.println("<<< " //$NON-NLS-1$
+ + "mouseDblClick visualNode: " //$NON-NLS-1$
+ + visualNode.getNodeName()
+ + " (" //$NON-NLS-1$
+ + visualNode + ")"); //$NON-NLS-1$
}
}
} finally {
@@ -1145,7 +1212,8 @@
}
public void mouseMove(nsIDOMMouseEvent mouseEvent) {
- if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
+ if (!switcher.startActiveEditor(
+ ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
return;
}
try {
@@ -1165,11 +1233,15 @@
public void keyPress(nsIDOMKeyEvent keyEvent) {
if (VpeDebug.PRINT_VISUAL_KEY_EVENT) {
- System.out.println("<<< keyPress type: " + keyEvent.getType() +
//$NON-NLS-1$
- " Ctrl: " + keyEvent.getCtrlKey() + " Shift: " +
keyEvent.getShiftKey() + //$NON-NLS-1$ //$NON-NLS-2$
- " CharCode: " + keyEvent.getCharCode() + " KeyCode: " +
keyEvent.getKeyCode()); //$NON-NLS-1$ //$NON-NLS-2$
+ System.out.println("<<< keyPress type: " //$NON-NLS-1$
+ + keyEvent.getType()
+ + " Ctrl: " + keyEvent.getCtrlKey()
+ + " Shift: " + keyEvent.getShiftKey() //$NON-NLS-1$
+ + " CharCode: " + keyEvent.getCharCode() //$NON-NLS-1$
+ + " KeyCode: " + keyEvent.getKeyCode()); //$NON-NLS-1$
}
- if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
+ if (!switcher.startActiveEditor(
+ ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
switcher.stopActiveEditor();
return;
}
@@ -1215,14 +1287,19 @@
KeySequence sequenceBeforeKeyStroke = KeySequence.getInstance();
- for (Iterator<KeyStroke> iterator = possibleKeyStrokes.iterator();
iterator.hasNext();) {
+ Iterator<KeyStroke> iterator = possibleKeyStrokes.iterator();
+ while (iterator.hasNext()) {
KeySequence sequenceAfterKeyStroke =
- KeySequence.getInstance(sequenceBeforeKeyStroke, iterator.next());
- if (iBindingService.isPerfectMatch(sequenceAfterKeyStroke)) {
- final Binding binding = iBindingService.getPerfectMatch(sequenceAfterKeyStroke);
+ KeySequence.getInstance(sequenceBeforeKeyStroke,
+ iterator.next());
+ if (iBindingService.isPerfectMatch(
+ sequenceAfterKeyStroke)) {
+ final Binding binding = iBindingService
+ .getPerfectMatch(sequenceAfterKeyStroke);
if ((binding != null)
&& (binding.getParameterizedCommand() != null)
- && (binding.getParameterizedCommand().getCommand() != null)) {
+ && (binding.getParameterizedCommand()
+ .getCommand() != null)) {
keyBindingPressed = true;
}
}
@@ -1249,8 +1326,8 @@
* JBIDE-2670
*/
keyEvent.preventDefault();
-// switcher
-// .startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL);
+// switcher.startActiveEditor(
+// ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL);
// try {
/*
* Edward
@@ -1271,7 +1348,8 @@
public void elementResized(nsIDOMElement element, int constrains,
int top, int left, int width, int height) {
- if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
+ if (!switcher.startActiveEditor(
+ ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
return;
}
try {
@@ -1285,7 +1363,8 @@
public void dragGesture(nsIDOMEvent domEvent) {
nsIDOMMouseEvent mouseEvent =
- (nsIDOMMouseEvent) domEvent.queryInterface(nsIDOMMouseEvent.NS_IDOMMOUSEEVENT_IID);
+ (nsIDOMMouseEvent) domEvent.queryInterface(
+ nsIDOMMouseEvent.NS_IDOMMOUSEEVENT_IID);
boolean canDragFlag = canInnerDrag(mouseEvent);
// start drag sessionvpe-element
if (canDragFlag) {
@@ -1304,20 +1383,23 @@
* @param node
* where this event are occur
*/
- public void onShowContextMenu(long contextFlags, nsIDOMEvent event, nsIDOMNode node) {
+ public void onShowContextMenu(long contextFlags, nsIDOMEvent event,
+ nsIDOMNode node) {
//FIXED FOR JBIDE-3072 by sdzmitrovich
// nsIDOMNode visualNode = VisualDomUtil.getTargetNode(event);
// if (visualNode != null) {
Node selectedSourceNode = null;
- VpeNodeMapping nodeMapping =
SelectionUtil.getNodeMappingBySourceSelection(sourceEditor, domMapping);
+ VpeNodeMapping nodeMapping = SelectionUtil
+ .getNodeMappingBySourceSelection(sourceEditor, domMapping);
if (nodeMapping != null) {
selectedSourceNode = nodeMapping.getSourceNode();
}
MenuManager menuManager = new MenuManager("#popup"); //$NON-NLS-1$
- final Menu contextMenu = menuManager.createContextMenu(visualEditor.getControl());
+ final Menu contextMenu = menuManager.createContextMenu(visualEditor
+ .getControl());
contextMenu.addMenuListener(new MenuListener() {
Menu menu = contextMenu;
public void menuHidden(MenuEvent e) {
@@ -1333,8 +1415,10 @@
// create context menu
MenuCreationHelper menuCreationHelper =
- new MenuCreationHelper(domMapping, pageContext, sourceEditor, visualEditor);
- menuCreationHelper.createMenuForNode(selectedSourceNode, menuManager, true);
+ new MenuCreationHelper(domMapping, pageContext,
+ sourceEditor, visualEditor);
+ menuCreationHelper.createMenuForNode(selectedSourceNode,
+ menuManager, true);
contextMenu.setVisible(true);
// }
@@ -1353,18 +1437,21 @@
if (uiJob != null && uiJob.getState() != Job.NONE) {
return;
}
- if (visualRefreshJob == null || visualRefreshJob.getState() == Job.NONE) {
+ if (visualRefreshJob == null
+ || visualRefreshJob.getState() == Job.NONE) {
visualRefreshJob = new UIJob(VpeUIMessages.VPE_VISUAL_REFRESH_JOB) {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
- if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
+ if (!switcher.startActiveEditor(
+ ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
return Status.CANCEL_STATUS;
}
try {
- monitor.beginTask(VpeUIMessages.VPE_VISUAL_REFRESH_JOB, IProgressMonitor.UNKNOWN);
+ monitor.beginTask(VpeUIMessages.VPE_VISUAL_REFRESH_JOB,
+ IProgressMonitor.UNKNOWN);
visualRefreshImpl();
monitor.done();
setSynced(true);
@@ -1387,7 +1474,7 @@
return Status.OK_STATUS;
}
};
-// visualRefreshJob.setRule(new GreedyRule(this));
+ visualRefreshJob.setRule(new VisualTreeChangingRule(this));
visualRefreshJob.setPriority(Job.SHORT);
visualRefreshJob.schedule();
}
@@ -1396,7 +1483,8 @@
void visualRefreshImpl() {
visualEditor.hideResizer();
- String currentDoctype = DocTypeUtil.getDoctype(visualEditor.getEditorInput());
+ String currentDoctype = DocTypeUtil.getDoctype(
+ visualEditor.getEditorInput());
/*
*
https://jira.jboss.org/jira/browse/JBIDE-3591
* Avoid using missing resource.
@@ -1431,30 +1519,38 @@
// for debug
private void printSourceEvent(INodeNotifier notifier, int eventType,
Object feature, Object oldValue, Object newValue, int pos) {
- System.out.println(">>> eventType: " +
INodeNotifier.EVENT_TYPE_STRINGS[eventType] + //$NON-NLS-1$
- " pos: " + pos + " notifier: " + ((Node)
notifier).getNodeName() + //$NON-NLS-1$ //$NON-NLS-2$
- " hashCode: " + notifier.hashCode()); //$NON-NLS-1$
+ System.out.println(">>> eventType: " //$NON-NLS-1$
+ + INodeNotifier.EVENT_TYPE_STRINGS[eventType]
+ + " pos: " + pos //$NON-NLS-1$
+ + " notifier: " //$NON-NLS-1$
+ + ((Node) notifier).getNodeName()
+ + " hashCode: " + notifier.hashCode()); //$NON-NLS-1$
if (feature != null) {
if (feature instanceof Node) {
- System.out.println(" feature: " + ((Node) feature).getNodeType() +
//$NON-NLS-1$
- Constants.WHITE_SPACE + ((Node) feature).getNodeName() +
- " hashCode: " + feature.hashCode()); //$NON-NLS-1$
+ System.out.println(" feature: " //$NON-NLS-1$
+ + ((Node) feature).getNodeType()
+ + Constants.WHITE_SPACE + ((Node) feature).getNodeName()
+ + " hashCode: " + feature.hashCode()); //$NON-NLS-1$
} else {
System.out.println(" feature: " + feature); //$NON-NLS-1$
}
}
if (oldValue != null) {
if (oldValue instanceof Node) {
- System.out.println(" oldValue: " + ((Node) oldValue).getNodeName() +
//$NON-NLS-1$
- " hashCode: " + oldValue.hashCode()); //$NON-NLS-1$
+ System.out.println(" oldValue: " //$NON-NLS-1$
+ + ((Node) oldValue).getNodeName()
+ + " hashCode: " + oldValue.hashCode());//$NON-NLS-1$
} else {
- System.out.println(" oldValue: " + oldValue); //$NON-NLS-1$
+ System.out.println(" oldValue: " + oldValue);//$NON-NLS-1$
}
}
if (newValue != null) {
if (newValue instanceof Node) {
- System.out.println(" newValue: " + ((Node) newValue).getNodeName() +
//$NON-NLS-1$
- " hashCode: " + newValue.hashCode() + Constants.WHITE_SPACE + ((Node)
newValue).getNodeType()); //$NON-NLS-1$
+ System.out.println(" newValue: " //$NON-NLS-1$
+ + ((Node) newValue).getNodeName()
+ + " hashCode: " + newValue.hashCode() //$NON-NLS-1$
+ + Constants.WHITE_SPACE
+ + ((Node) newValue).getNodeType());
} else {
System.out.println(" newValue: " + newValue); //$NON-NLS-1$
}
@@ -1467,17 +1563,22 @@
if (event instanceof nsIDOMMutationEvent) {
nsIDOMMutationEvent mutationEvent = (nsIDOMMutationEvent) event;
- System.out.print(" EventPhase: " + mutationEvent.getEventPhase());
//$NON-NLS-1$
+ System.out.print(" EventPhase: " //$NON-NLS-1$
+ + mutationEvent.getEventPhase());
nsIDOMNode relatedNode = mutationEvent.getRelatedNode();
- System.out.print(" RelatedNode: " + (relatedNode == null ? null :
relatedNode.getNodeName())); //$NON-NLS-1$
+ System.out.print(" RelatedNode: " //$NON-NLS-1$
+ + (relatedNode == null ? null : relatedNode.getNodeName()));
nsIDOMNode targetNode = VisualDomUtil.getTargetNode(mutationEvent);
String name = targetNode != null ? targetNode.getNodeName() : null;
- System.out.print(" TargetNode: " + name + " (" + targetNode +
")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ System.out.print(" TargetNode: " + name //$NON-NLS-1$
+ + " (" + targetNode + ")"); //$NON-NLS-1$ //$NON-NLS-2$
- System.out.print(" PrevValue: " + mutationEvent.getPrevValue().trim());
//$NON-NLS-1$
- System.out.print(" NewValue: " + mutationEvent.getNewValue().trim());
//$NON-NLS-1$
+ System.out.print(" PrevValue: " //$NON-NLS-1$
+ + mutationEvent.getPrevValue().trim());
+ System.out.print(" NewValue: " //$NON-NLS-1$
+ + mutationEvent.getNewValue().trim());
}
System.out.println();
}
@@ -1501,7 +1602,8 @@
private boolean startActiveEditor(int newType) {
if (type == ACTIVE_EDITOR_NONE) {
if (newType == ACTIVE_EDITOR_SOURCE
- && editPart.getVisualMode() == VpeEditorPart.SOURCE_MODE) {
+ && editPart.getVisualMode()
+ == VpeEditorPart.SOURCE_MODE) {
return false;
}
type = newType;
@@ -1518,7 +1620,8 @@
}
// void refreshBundleValues() {
-// if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
+// if (!switcher.startActiveEditor(
+// ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
// return;
// }
// try {
@@ -1543,7 +1646,8 @@
if (bundle != null) {
bundle.refresh();
if (pageContext != null) {
- if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
+ if (!switcher.startActiveEditor(
+ ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
return;
}
try {
@@ -1578,12 +1682,18 @@
// if (attrs != null) {
// for (int i = 0; i < attrs.getLength(); i++) {
// if (attrs.item(i) instanceof AttrImpl) {
-// AttrImpl attr = (AttrImpl) attrs.item(i);
-// if (getSourceAttributeOffset(attr, offset) != -1) {
-// String[] atributeNames =
elementMapping.getTemplate().getOutputAtributeNames();
+// AttrImpl attr = (AttrImpl)attrs.item(i);
+// if (getSourceAttributeOffset(attr,
+// offset) != -1) {
+// String[] atributeNames
+// = elementMapping
+// .getTemplate()
+// .getOutputAtributeNames();
// if (atributeNames != null
// && atributeNames.length > 0
-// && attr.getName().equalsIgnoreCase(atributeNames[0])) {
+// && attr.getName()
+// .equalsIgnoreCase(
+// atributeNames[0])) {
// return attr;
// }
// }
@@ -1735,10 +1845,12 @@
selection = new VpeSelection(offset, length);
}
- public void addSelectionChangedListener(ISelectionChangedListener listener) {
+ public void addSelectionChangedListener(
+ ISelectionChangedListener listener) {
}
- public void removeSelectionChangedListener(ISelectionChangedListener listener) {
+ public void removeSelectionChangedListener(
+ ISelectionChangedListener listener) {
}
public ISelection getSelection() {
@@ -1764,8 +1876,8 @@
if (length > 0) {
try {
- text = sourceEditor.getTextViewer().getDocument().get(
- offset, length);
+ text = sourceEditor.getTextViewer().getDocument()
+ .get(offset, length);
} catch (BadLocationException e) {
VpePlugin.getPluginLog().logError(e);
}
@@ -1777,8 +1889,8 @@
offset = region.getStartOffset();
length = region.getEndOffset() - offset;
try {
- text = sourceEditor.getTextViewer().getDocument().get(offset,
- length);
+ text = sourceEditor.getTextViewer().getDocument()
+ .get(offset, length);
} catch (BadLocationException ex) {
VpePlugin.reportProblem(ex);
}
@@ -1836,13 +1948,13 @@
public void dragEnter(nsIDOMEvent event) {
if (VpeDebug.PRINT_VISUAL_DRAGDROP_EVENT) {
- System.out.println("<<<<<<<<<<<<<<<<<<<<
DragEnter"); //$NON-NLS-1$
+ System.out.println("<<<<<<<<<<<<<<<<<<<
DragEnter"); //$NON-NLS-1$
}
}
public void dragExit(nsIDOMEvent event) {
if (VpeDebug.PRINT_VISUAL_DRAGDROP_EVENT) {
- System.out.println("<<<<<<<<<<<<<<<<<<<<
dragExit"); //$NON-NLS-1$
+ System.out.println("<<<<<<<<<<<<<<<<<<<
dragExit"); //$NON-NLS-1$
}
// TODO Sergey Vasilyev figure out with drag caret
// xulRunnerEditor.hideDragCaret();
@@ -1859,13 +1971,14 @@
}
try {
if (VpeDebug.PRINT_VISUAL_DRAGDROP_EVENT) {
- System.out.println("<<<<<<<<<<<<<<<<<<<<
dragOver"); //$NON-NLS-1$
+ System.out.println("<<<<<<<<<<<<<<<<<<<
dragOver");//$NON-NLS-1$
}
// browser.computeDropPosition(event);
boolean canDrop = !xulRunnerEditor.isMozillaDragFlavor();
if (canDrop) {
Clipboard clipboard = new Clipboard(Display.getCurrent());
- canDrop = clipboard.getContents(ModelTransfer.getInstance()) != null;
+ canDrop = clipboard.getContents(ModelTransfer.getInstance())
+ != null;
}
if (canDrop) {
canDrop = VpeDndUtil
@@ -1914,8 +2027,9 @@
if (dragInfo != null) {
nsIDOMNode dragNode = dragInfo.getNode();
if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
- System.out
- .print(" dragNode: " + dragNode.getNodeName() + "(" + dragNode
+ ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ System.out.print(" dragNode: " //$NON-NLS-1$
+ + dragNode.getNodeName()
+ + "(" + dragNode + ")"); //$NON-NLS-1$ //$NON-NLS-2$
}
switch (dragNode.getNodeType()) {
case nsIDOMNode.ELEMENT_NODE:
@@ -1994,7 +2108,8 @@
+ "(" //$NON-NLS-1$
+ visualDropInfo.getDropContainer()
+ ") parent: " //$NON-NLS-1$
- + visualDropInfo.getDropContainer().getParentNode().getNodeName()
+ + visualDropInfo.getDropContainer().getParentNode()
+ .getNodeName()
+ "(" //$NON-NLS-1$
+ visualDropInfo.getDropContainer().getParentNode()
+ ") offset: " //$NON-NLS-1$
@@ -2037,16 +2152,17 @@
.getInnerDropInfo(event);
if (visualDropInfo.getDropContainer() != null) {
if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
- System.out
- .print(" container: " + visualDropInfo.getDropContainer().getNodeName()
+ //$NON-NLS-1$
- "(" + visualDropInfo.getDropContainer()
- + ")" + //$NON-NLS-1$ //$NON-NLS-2$
- " offset: "
- + visualDropInfo.getDropOffset()); //$NON-NLS-1$
+ System.out.print(" container: " //$NON-NLS-1$
+ + visualDropInfo.getDropContainer().getNodeName()
+ + "(" //$NON-NLS-1$
+ + visualDropInfo.getDropContainer()
+ + ")" //$NON-NLS-1$
+ + " offset: " //$NON-NLS-1$
+ + visualDropInfo.getDropOffset());
}
- VpeSourceInnerDragInfo sourceInnerDragInfo = visualBuilder
- .getSourceInnerDragInfo(innerDragInfo);
+ VpeSourceInnerDragInfo sourceInnerDragInfo
+ = visualBuilder.getSourceInnerDragInfo(innerDragInfo);
VpeSourceInnerDropInfo sourceDropInfo = visualBuilder
.getSourceInnerDropInfo(sourceInnerDragInfo.getNode(),
visualDropInfo, true);
@@ -2102,8 +2218,8 @@
dropWindow.flavor = flavor;
}
dropWindow.active = true;
- dropWindow.setEventPosition(mouseEvent.getScreenX(), mouseEvent
- .getScreenY());
+ dropWindow.setEventPosition(mouseEvent.getScreenX(),
+ mouseEvent.getScreenY());
dropWindow.setInitialTargetNode(sourceNode);
dropWindow.open();
mouseEvent.stopPropagation();
@@ -2128,7 +2244,9 @@
caretOffset = visualDropInfo.getDropOffset();
} else {
String tagname = getTagName(object);
- if (tagname.indexOf("taglib") >= 0)tagname = "taglib";
//$NON-NLS-1$ //$NON-NLS-2$
+ if (tagname.indexOf("taglib") >= 0) { //$NON-NLS-1$
+ tagname = "taglib"; //$NON-NLS-1$
+ }
Node sourceDragNode = ((Document) getModel().getAdapter(
Document.class)).createElement(tagname);
VpeVisualInnerDropInfo visualDropInfo = selectionBuilder
@@ -2139,8 +2257,8 @@
visualDropInfo, true);
canDrop = sourceDropInfo.canDrop();
if (canDrop) {
- VpeVisualInnerDropInfo newVisualDropInfo = visualBuilder
- .getInnerDropInfo(
+ VpeVisualInnerDropInfo newVisualDropInfo
+ = visualBuilder.getInnerDropInfo(
sourceDropInfo.getContainer(),
sourceDropInfo.getOffset());
if (newVisualDropInfo != null) {
@@ -2163,11 +2281,15 @@
}
if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
- System.out
- .println(" canDrop: " + canDrop + (canDrop ? " container: " +
caretParent.getNodeName() + " offset: " + caretOffset : ""));
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ System.out.println(" canDrop: " + canDrop //$NON-NLS-1$
+ + (canDrop
+ ? " container: " //$NON-NLS-1$
+ + caretParent.getNodeName()
+ + " offset: " //$NON-NLS-1$
+ + caretOffset
+ : "")); //$NON-NLS-1$
}
return new MozillaDropInfo(canDrop, caretParent, caretOffset);
-
}
public VpeSourceInnerDropInfo canExternalDropMacro(XModelObject object,
@@ -2204,10 +2326,15 @@
String tagname = object.getAttributeValue("name"); //$NON-NLS-1$
XModelObject parent = object.getParent();
- String uri = (parent == null) ? "" :
parent.getAttributeValue(URIConstants.LIBRARY_URI); //$NON-NLS-1$
- String defaultPrefix = (parent == null) ? "" :
parent.getAttributeValue(URIConstants.DEFAULT_PREFIX); //$NON-NLS-1$
+ String uri = (parent == null)
+ ? "" //$NON-NLS-1$
+ : parent.getAttributeValue(URIConstants.LIBRARY_URI);
+ String defaultPrefix = (parent == null)
+ ? "" //$NON-NLS-1$
+ : parent.getAttributeValue(URIConstants.DEFAULT_PREFIX);
- String[] texts = new String[] { "<" + tagname + ">" };
//$NON-NLS-1$ //$NON-NLS-2$
+ String[] texts = new String[] {
+ "<" + tagname + ">" }; //$NON-NLS-1$ //$NON-NLS-2$
PaletteInsertHelper.applyPrefix(texts, sourceEditor, tagname, uri,
defaultPrefix);
tagname = texts[0].substring(1, texts[0].length() - 1);
@@ -2215,12 +2342,15 @@
return tagname;
}
- public void externalDrop(nsIDOMMouseEvent mouseEvent, String flavor, String data) {
+ public void externalDrop(nsIDOMMouseEvent mouseEvent, String flavor,
+ String data) {
onHideTooltip();
- VpeVisualInnerDropInfo visualDropInfo =
selectionBuilder.getInnerDropInfo(mouseEvent);
- Point range =
selectionBuilder.getSourceSelectionRangeAtVisualNode(visualDropInfo.getDropContainer(),
(int) visualDropInfo
- .getDropOffset());
+ VpeVisualInnerDropInfo visualDropInfo
+ = selectionBuilder.getInnerDropInfo(mouseEvent);
+ Point range = selectionBuilder.getSourceSelectionRangeAtVisualNode(
+ visualDropInfo.getDropContainer(),
+ (int) visualDropInfo.getDropOffset());
VpeSourceInnerDropInfo sourceDropInfo = null;
// if (MODEL_FLAVOR.equals(flavor)) {
@@ -2231,7 +2361,8 @@
nsISupports aValue = DndUtil.getDnDValue(mouseEvent);
String aFlavor = ""; //$NON-NLS-1$
if (VpeDndUtil.isNsIFileInstance(aValue)) {
- nsIFile aFile = (nsIFile) aValue.queryInterface(nsIFile.NS_IFILE_IID);
+ nsIFile aFile
+ = (nsIFile) aValue.queryInterface(nsIFile.NS_IFILE_IID);
if (aValue != null) {
data = aFile.getPath();
@@ -2239,11 +2370,15 @@
}
} else if (VpeDndUtil.isNsICStringInstance(aValue)) {
- nsISupportsCString aString = (nsISupportsCString)
aValue.queryInterface(nsISupportsCString.NS_ISUPPORTSCSTRING_IID);
+ nsISupportsCString aString
+ = (nsISupportsCString) aValue.queryInterface(
+ nsISupportsCString.NS_ISUPPORTSCSTRING_IID);
data = aString.getData();
aFlavor = DndUtil.kHTMLMime;
} else if (VpeDndUtil.isNsIStringInstance(aValue)) {
- nsISupportsString aString = (nsISupportsString)
aValue.queryInterface(nsISupportsString.NS_ISUPPORTSSTRING_IID);
+ nsISupportsString aString
+ = (nsISupportsString) aValue.queryInterface(
+ nsISupportsString.NS_ISUPPORTSSTRING_IID);
data = aString.getData();
aFlavor = DndUtil.kURLMime;
}
@@ -2259,7 +2394,9 @@
// }
// } else {
// String tagname = getTagName(object);
- // if (tagname.indexOf("taglib") >= 0)tagname =
"taglib"; //$NON-NLS-1$ //$NON-NLS-2$
+ // if (tagname.indexOf("taglib") >= 0) {//$NON-NLS-1$
+ // tagname = "taglib";//$NON-NLS-1$
+ // }
// Node sourceDragNode = ((Document) getModel().getAdapter(
// Document.class)).createElement(tagname);
// if (visualDropInfo.getDropContainer() != null) {
@@ -2273,12 +2410,16 @@
if (visualDropInfo.getDropContainer() != null && data != null) {
if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
- System.out.println(" drop! container: " +
visualDropInfo.getDropContainer().getNodeName()); //$NON-NLS-1$
+ System.out.println(" drop! container: " //$NON-NLS-1$
+ + visualDropInfo.getDropContainer().getNodeName());
}
- externalDropAny(aFlavor, data, range, sourceDropInfo == null ? null :
sourceDropInfo.getContainer());
+ externalDropAny(aFlavor, data, range, sourceDropInfo == null
+ ? null
+ : sourceDropInfo.getContainer());
DropContext dropContext = new DropContext();
- IDNDTextEditor textEditor = (IDNDTextEditor)
VpeController.this.editPart.getSourceEditor();
+ IDNDTextEditor textEditor = (IDNDTextEditor)
+ VpeController.this.editPart.getSourceEditor();
// TypedEvent tEvent = new TypedEvent(mouseEvent);
// tEvent.data = data;
@@ -2325,8 +2466,8 @@
*/
String[] attributeString = formatText.split("\n"); //$NON-NLS-1$
/**
- * buffer string containing the attribute and the value in the different
- * succeding string
+ * buffer string containing the attribute and
+ * the value in the different succeding string
*/
String[] buffer = attributeString[0].split(" "); //$NON-NLS-1$
@@ -2361,12 +2502,19 @@
buffer = attributeString[i].split(" ", 2); //$NON-NLS-1$
if (i == 1) {
tempAttr.append(buffer[0] + " "); //$NON-NLS-1$
- tempValue
- .append((buffer.length >= 2 ? buffer[1] : "") + " ");
//$NON-NLS-1$ //$NON-NLS-2$
+ tempValue.append(
+ (buffer.length >= 2
+ ? buffer[1]
+ : "") //$NON-NLS-1$
+ + " "); //$NON-NLS-1$
} else {
- tempAttr.append("\n" + buffer[0] + " "); //$NON-NLS-1$
//$NON-NLS-2$
- tempValue
- .append(" \n" + (buffer.length >= 2 ? buffer[1] : "") +
" "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ tempAttr.append(
+ "\n" + buffer[0] + " "); //$NON-NLS-1$ //$NON-NLS-2$
+ tempValue.append(" \n" //$NON-NLS-1$
+ + (buffer.length >= 2
+ ? buffer[1]
+ : "") //$NON-NLS-1$
+ + " "); //$NON-NLS-1$
}
}
@@ -2414,8 +2562,8 @@
*/
Point point = display.getCursorLocation();
/*
- * Assuming cursor is 21x21 because this is the size of the arrow cursor
- * on Windows
+ * Assuming cursor is 21x21 because this is
+ * the size of the arrow cursor on Windows
*/
point.y += 21;
tip.setLocation(point);
@@ -2488,13 +2636,16 @@
toolbarFormatControllerManager.selectionChanged();
}
- if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
+ if (!switcher.startActiveEditor(
+ ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
return;
}
try {
if (VpeDebug.PRINT_SOURCE_SELECTION_EVENT) {
- System.out.println(">>>>>>>>>>>>>>
selectionChanged " + event.getSource()); //$NON-NLS-1$
+ System.out.println(">>>>>>>>>>>>>>
" //$NON-NLS-1$
+ + "selectionChanged " //$NON-NLS-1$
+ + event.getSource());
}
sourceSelectionChanged();
} finally {
@@ -2503,7 +2654,8 @@
}
// nsIClipboardDragDropHooks implementation
- public void onPasteOrDrop(nsIDOMMouseEvent mouseEvent, String flavor, String data) {
+ public void onPasteOrDrop(nsIDOMMouseEvent mouseEvent,
+ String flavor, String data) {
onHideTooltip();
VpeVisualInnerDropInfo visualDropInfo = selectionBuilder
@@ -2517,7 +2669,9 @@
.getModelBuffer().source();
String tagname = getTagName(object);
- if (tagname.indexOf("taglib") >= 0)tagname = "taglib";
//$NON-NLS-1$ //$NON-NLS-2$
+ if (tagname.indexOf("taglib") >= 0) { //$NON-NLS-1$
+ tagname = "taglib"; //$NON-NLS-1$
+ }
Node sourceDragNode = ((Document) getModel().getAdapter(Document.class))
.createElement(tagname);
if (visualDropInfo.getDropContainer() != null) {
@@ -2529,7 +2683,8 @@
if (visualDropInfo.getDropContainer() != null) {
if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
- System.out.println(" drop! container: " +
visualDropInfo.getDropContainer().getNodeName()); //$NON-NLS-1$
+ System.out.println(" drop! container: " //$NON-NLS-1$
+ + visualDropInfo.getDropContainer().getNodeName());
}
final String finalFlavor = flavor;
final String finalData = data;
@@ -2664,7 +2819,7 @@
return Status.OK_STATUS;
}
};
-// reinitJob.setRule(new GreedyRule(this));
+ reinitJob.setRule(new VisualTreeChangingRule(this));
reinitJob.schedule();
}
@@ -2685,11 +2840,12 @@
}
//reinits selection controller+ controller
visualEditor.reinitDesignMode();
- visualSelectionController = new
VpeSelectionController(visualEditor.getEditor().getSelectionController());
+ visualSelectionController = new VpeSelectionController(
+ visualEditor.getEditor().getSelectionController());
- selectionBuilder = new VpeSelectionBuilder(domMapping, sourceBuilder,
- visualBuilder, visualSelectionController);
-
+ selectionBuilder = new VpeSelectionBuilder(domMapping,
+ sourceBuilder, visualBuilder, visualSelectionController);
+
selectionManager = new SelectionManager(pageContext,
sourceEditor, visualSelectionController);
@@ -2754,23 +2910,35 @@
}
/**
- * Jobs with different instances of {@code GreedyRule}
- * but the same {@code grredyObject} are
- * never run concurrently.
+ * Jobs with the same instances of {@code VisualTreeChangingRule}
+ * but different {@code vpeController} are
+ * never run concurrently. Any resource-changing rule can
+ * be nested inside this rule.
*
* @author yradtsevich
*/
- private final class GreedyRule implements ISchedulingRule {
- private Object greedyObject;
- public GreedyRule(Object greedyObject) {
- this.greedyObject = greedyObject;
+ private static final class VisualTreeChangingRule
+ implements ISchedulingRule {
+ private VpeController vpeController;
+ public VisualTreeChangingRule(VpeController vpeController) {
+ this.vpeController = vpeController;
}
public boolean contains(ISchedulingRule rule) {
- return this == rule;
+ if (this == rule) {
+ return true;
+ } else if (rule instanceof IResource) {
+ /* can contain any resource-changing rule
+ * (it is needed during preferences-saving operations) */
+ return true;
+ } else {
+ return false;
+ }
}
public boolean isConflicting(ISchedulingRule rule) {
- if (rule instanceof GreedyRule) {
- return ((GreedyRule) rule).greedyObject == this.greedyObject;
+ if (rule instanceof VisualTreeChangingRule
+ && ((VisualTreeChangingRule) rule).vpeController
+ == this.vpeController) {
+ return true;
} else {
return false;
}