JBoss Tools SVN: r37572 - in trunk/vpe/plugins: org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2011-12-28 19:56:12 -0500 (Wed, 28 Dec 2011)
New Revision: 37572
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/XulRunnerEditor.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/util/VpeDebugUtil.java
Log:
VPE refactoring:
1. Moved part of tracing code to VpeDebugUtils class
2. Removed switcher to clean up the code
3. Created factory method for SWT events out of mozilla events
4. Removed unused code and comments
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 2011-12-29 00:03:43 UTC (rev 37571)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2011-12-29 00:56:12 UTC (rev 37572)
@@ -189,8 +189,6 @@
private VpeSourceDomBuilder sourceBuilder;
private VpeVisualDomBuilder visualBuilder;
private VpeDnD vpeDnD;
- // private VpeVisualKeyHandler visualKeyHandler;
- private ActiveEditorSwitcher switcher = new ActiveEditorSwitcher();
private Attr lastRemovedAttr;
private String lastRemovedAttrName;
private boolean mouseUpSelectionReasonFlag;
@@ -344,7 +342,6 @@
}
registerEventTargets();
- switcher.initActiveEditor();
if (optionsListener == null) {
XModelObject optionsObject = ModelUtilities.getPreferenceModel()
@@ -409,8 +406,6 @@
if (sourceModel != null) {
sourceModel.removeModelLifecycleListener(this);
}
- switcher.destroyActiveEditor();
- switcher = null;
VpeTemplateManager.getInstance().removeTemplateListener(this);
@@ -423,10 +418,6 @@
// glory
ISelectionProvider provider = sourceEditor.getSelectionProvider();
provider.removeSelectionChangedListener(this);
- // ViewerSelectionManager selectionManager =
- // sourceEditor.getViewerSelectionManager();
- // selectionManager.removeNodeSelectionListener(this);
- // selectionManager.removeTextSelectionListener(this);
StyledText textWidget = SelectionHelper
.getSourceTextWidget(sourceEditor);
if (textWidget != null) {
@@ -444,11 +435,6 @@
// visualSelectionController.Release();
visualSelectionController = null;
}
- // TODO Sergey Vasilyev figure out with Press Shell
- // if (presShell != null) {
- // presShell.Release();
- // presShell = null;
- // }
visualEditor = null;
}
@@ -573,14 +559,9 @@
public void notifyChangedInUiThread(INodeNotifier notifier, int eventType,
Object feature, Object oldValue, Object newValue, int pos) {
- if (switcher == null
- || !switcher
- .startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
- return;
- }
- try {
+ if (editPart.getVisualMode() != VpeEditorPart.SOURCE_MODE) {
if (VpeDebug.PRINT_SOURCE_MUTATION_EVENT) {
- printSourceEvent(notifier, eventType, feature, oldValue,
+ VpeDebugUtil.printSourceEvent(notifier, eventType, feature, oldValue,
newValue, pos);
}
if (visualBuilder == null) {
@@ -701,51 +682,39 @@
}
break;
}
- } finally {
- // fix for jbide-675, swithcer is null when vpecontroller is
- // disposed
- if (switcher != null) {
- switcher.stopActiveEditor();
- } else {
- throw new VpeDisposeException("VpeController already disposed"); //$NON-NLS-1$
- }
}
}
// INodeSelectionListener implementation
public void nodeSelectionChanged(NodeSelectionChangedEvent event) {
- if (!switcher
- .startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
- return;
- }
- try {
- List<?> nodes = event.getSelectedNodes();
- 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());
- }
- if (event.getSource() instanceof IContentOutlinePage) {
- sourceSelectionChanged();
- }
- }
- } finally {
- switcher.stopActiveEditor();
- }
+// if (!switcher
+// .startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
+// return;
+// }
+// try {
+// List<?> nodes = event.getSelectedNodes();
+// 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());
+// }
+// if (event.getSource() instanceof IContentOutlinePage) {
+// sourceSelectionChanged();
+// }
+// }
+// } finally {
+// switcher.stopActiveEditor();
+// }
}
// ITextSelectionListener implementation
// TODO Max Areshau looks like this method don't used
public void textSelectionChanged(TextSelectionChangedEvent event) {
- if (!switcher
- .startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
- return;
- }
- try {
+ if (editPart.getVisualMode() != VpeEditorPart.SOURCE_MODE) {
if (VpeDebug.PRINT_SOURCE_SELECTION_EVENT) {
System.out
.println(">>>>>>>>>>>>>> textSelectionChanged " + event.getSource()); //$NON-NLS-1$
@@ -753,26 +722,18 @@
// if (event.getSource() instanceof StyledText) {
sourceSelectionChanged();
// }
- } finally {
- switcher.stopActiveEditor();
}
}
// SelectionListener implementation
public void widgetSelected(SelectionEvent event) {
- if (!switcher
- .startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
- return;
- }
- try {
+ if (editPart.getVisualMode() != VpeEditorPart.SOURCE_MODE) {
if (VpeDebug.PRINT_SOURCE_SELECTION_EVENT) {
System.out.println(">>>>>>>>>>>>>> widgetSelected"); //$NON-NLS-1$
}
if (event.getSource() instanceof StyledText) {
sourceSelectionChanged();
}
- } finally {
- switcher.stopActiveEditor();
}
}
@@ -793,101 +754,13 @@
return;
}
- // Point range = sourceEditor.getTextViewer().getSelectedRange();
- // int anchorPosition = range.x;
- // int focusPosition = range.x + range.y;
- //
- // boolean extendFlag = range.y != 0;
- // boolean reversionFlag = extendFlag
- // && anchorPosition == VpeSelectionHelper
- // .getCaretOffset(sourceEditor);
- // if (reversionFlag) {
- // anchorPosition = focusPosition;
- // focusPosition = range.x;
- // }
-
if (selectionManager != null)
selectionManager.refreshVisualSelection();
-
- // VpeTemplate template = TemplateManagingUtil
- // .getTemplateBySourceSelection(pageContext, focusPosition,
- // anchorPosition);
- //
- // if (template instanceof ITemplateSelectionManager) {
- // ((ITemplateSelectionManager) template).setSelectionBySource(
- // pageContext, visualSelectionController, focusPosition,
- // anchorPosition);
- // return;
- // }
- //
- // Node focusNode = getSourceNodeAt(focusPosition);
- // if (focusNode == null) {
- // return;
- // }
- // int focusOffset = getSourceNodeOffset(focusNode, focusPosition,
- // extendFlag && !reversionFlag);
- // Node anchorNode = null;
- // int anchorOffset = 0;
- // if (extendFlag) {
- // anchorNode = getSourceNodeAt(anchorPosition);
- // anchorOffset = getSourceNodeOffset(anchorNode, anchorPosition,
- // reversionFlag);
- // } else {
- // anchorNode = focusNode;
- // anchorOffset = focusOffset;
- // }
- //
- // 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$
- // System.out
- // .println(" focusNode: " + focusNode.getNodeName() + " focusOffset: " + focusOffset + " focusPosition: " + focusPosition); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- // }
- // try {
- // if (anchorNode.getNodeType() == Node.TEXT_NODE
- // || anchorNode.getNodeType() == Node.ATTRIBUTE_NODE) {
- // String text;
- // if (anchorNode.getNodeType() == Node.TEXT_NODE) {
- // IndexedRegion region = (IndexedRegion) anchorNode;
- // text = sourceEditor.getTextViewer().getDocument().get(
- // region.getStartOffset(),
- // region.getEndOffset() - region.getStartOffset());
- // } else {
- // text = ((AttrImpl) anchorNode).getValueRegionText();
- // }
- // anchorOffset = TextUtil.visualPosition(text, anchorOffset);
- // }
- // if (focusNode.getNodeType() == Node.TEXT_NODE
- // || focusNode.getNodeType() == Node.ATTRIBUTE_NODE) {
- // IndexedRegion region = (IndexedRegion) focusNode;
- // String text;
- // if (focusNode.getNodeType() == Node.TEXT_NODE) {
- // text = sourceEditor.getTextViewer().getDocument().get(
- // region.getStartOffset(),
- // region.getEndOffset() - region.getStartOffset());
- // } else {
- // text = ((AttrImpl) focusNode).getValueRegionText();
- // }
- // focusOffset = TextUtil.visualPosition(text, focusOffset);
- // }
- // } catch (Exception ex) {
- // VpePlugin.reportProblem(ex);
- // }
- //
- // selectionBuilder.setVisualSelection(anchorNode, anchorOffset,
- // focusNode, focusOffset, reversionFlag, showCaret);
}
public void sourceSelectionToVisualSelection(boolean showCaret) {
- if (!switcher
- .startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
- return;
- }
- try {
+ if (editPart.getVisualMode() != VpeEditorPart.SOURCE_MODE) {
sourceSelectionChanged(showCaret);
- } finally {
- switcher.stopActiveEditor();
}
}
@@ -897,12 +770,8 @@
public void processPostModelEvent(ModelLifecycleEvent event) {
// A part of fix JBIDE-5066
- if ((switcher == null)
- || (!switcher
- .startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE))) {
- return;
- }
- try {
+ if (editPart.getVisualMode() != VpeEditorPart.SOURCE_MODE) {
+
/*
* Added by Max Areshkau JBIDE-1457
* ModelLifecycleEvent.MODEL_RELEASED is generated when model in
@@ -934,266 +803,107 @@
// visualBuilder.rebuildDom(sourceDocument);
// pageContext.fireTaglibsChanged();
}
- } finally {
- // A part of fix JBIDE-5066
- if (switcher != null) {
- switcher.stopActiveEditor();
- }
}
}
- // EditorDomEventListener implementation
-// this method is never used
-// public void subtreeModified(nsIDOMMutationEvent mutationEvent) {
-// if (!switcher
-// .startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
-// return;
-// }
-// try {
-// if (VpeDebug.PRINT_VISUAL_MUTATION_EVENT) {
-// printVisualEvent(mutationEvent);
-// }
-// } finally {
-// switcher.stopActiveEditor();
-// }
-// }
-
-// this method is never used
-// public void nodeInserted(nsIDOMMutationEvent mutationEvent) {
-// if (!switcher
-// .startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
-// return;
-// }
-// try {
-// if (VpeDebug.PRINT_VISUAL_MUTATION_EVENT) {
-// printVisualEvent(mutationEvent);
-// }
-// nsIDOMNode targetNode = mutationEvent.getRelatedNode();
-// if (!VpeVisualDomBuilder.isAnonElement(targetNode)) {
-// sourceBuilder.addNode(targetNode);
-// visualBuilder.resetPseudoElement(targetNode);
-// }
-// } finally {
-// switcher.stopActiveEditor();
-// }
-// }
-
-// this method is never used
-// public void nodeRemoved(nsIDOMMutationEvent mutationEvent) {
-// if (!switcher
-// .startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
-// return;
-// }
-// try {
-// if (VpeDebug.PRINT_VISUAL_MUTATION_EVENT) {
-// printVisualEvent(mutationEvent);
-// }
-// nsIDOMNode targetNode = VisualDomUtil.getTargetNode(mutationEvent);
-// if (!VpeVisualDomBuilder.isAnonElement(targetNode)) {
-// visualBuilder.setSelectionRectangle(null);
-// sourceBuilder.removeNode(targetNode);
-// visualBuilder.resetPseudoElement(targetNode);
-// }
-// } finally {
-// switcher.stopActiveEditor();
-// }
-// }
-
public void nodeRemovedFromDocument(nsIDOMMutationEvent mutationEvent) {
- if (!switcher
- .startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
- return;
- }
- try {
if (VpeDebug.PRINT_VISUAL_MUTATION_EVENT) {
- printVisualEvent(mutationEvent);
+ VpeDebugUtil.printVisualEvent(mutationEvent);
}
- } finally {
- switcher.stopActiveEditor();
- }
}
-// this method is never used
-// public void nodeInsertedIntoDocument(nsIDOMMutationEvent mutationEvent) {
-// if (!switcher
-// .startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
-// return;
-// }
-// try {
-// if (VpeDebug.PRINT_VISUAL_MUTATION_EVENT) {
-// printVisualEvent(mutationEvent);
-// }
-// } finally {
-// switcher.stopActiveEditor();
-// }
-// }
-// this method is never used
-// public void attrModified(nsIDOMMutationEvent mutationEvent) {
-// if (!switcher
-// .startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
-// return;
-// }
-// try {
-// if (VpeDebug.PRINT_VISUAL_MUTATION_EVENT) {
-// printVisualEvent(mutationEvent);
-// }
-// } finally {
-// switcher.stopActiveEditor();
-// }
-// }
-
-// this method is never used
-// public void characterDataModified(nsIDOMMutationEvent mutationEvent) {
-// if (!switcher
-// .startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
-// return;
-// }
-// try {
-// if (VpeDebug.PRINT_VISUAL_MUTATION_EVENT) {
-// printVisualEvent(mutationEvent);
-// }
-// nsIDOMNode targetNode = VisualDomUtil.getTargetNode(mutationEvent);
-// sourceBuilder.setText(targetNode);
-// visualBuilder.resetPseudoElement(targetNode);
-// } finally {
-// switcher.stopActiveEditor();
-// }
-// }
-
public void notifySelectionChanged(nsIDOMDocument doc,
- nsISelection selection, short reason) {
- if (switcher
- .startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
- try {
- mouseUpSelectionReasonFlag = (reason & nsISelectionListener.MOUSEUP_REASON) != 0;
- if (
- // commited by Dzmitrovich - experimental
- // TODO check selection and if are appear errors then
- // uncommented next code
- // reason != nsISelectionListener.NO_REASON
- (reason & (nsISelectionListener.KEYPRESS_REASON
- | nsISelectionListener.SELECTALL_REASON
- | nsISelectionListener.MOUSEDOWN_REASON)) != 0) {
- if (VpeDebug.PRINT_VISUAL_SELECTION_EVENT) {
- System.out
- .println("<<< notifySelectionChanged: " + reason); //$NON-NLS-1$
- }
- nsIDOMNode node = SelectionUtil.getSelectedNode(selection);
- /*
- * Fixes https://jira.jboss.org/jira/browse/JBIDE-2571
- * Checking if the node is of text type was removed to allow
- * <select> node to be selected on the first click.
- */
- if (node != null) {
- selectionManager.setSelection(SelectionUtil.getSelectedNode(selection),
- selection.getFocusOffset(), selection.getAnchorOffset());
- }
- }
- // enables cursor on selection event
- visualSelectionController.setCaretEnabled(true);
- } finally {
- switcher.stopActiveEditor();
+ nsISelection selection, short reason) {
+ mouseUpSelectionReasonFlag = (reason & nsISelectionListener.MOUSEUP_REASON) != 0;
+ if (
+ // commited by Dzmitrovich - experimental
+ // TODO check selection and if are appear errors then
+ // uncommented next code
+ // reason != nsISelectionListener.NO_REASON
+ (reason & (nsISelectionListener.KEYPRESS_REASON
+ | nsISelectionListener.SELECTALL_REASON
+ | nsISelectionListener.MOUSEDOWN_REASON)) != 0) {
+ if (VpeDebug.PRINT_VISUAL_SELECTION_EVENT) {
+ System.out
+ .println("<<< notifySelectionChanged: " + reason); //$NON-NLS-1$
}
+ nsIDOMNode node = SelectionUtil.getSelectedNode(selection);
+ /*
+ * Fixes https://jira.jboss.org/jira/browse/JBIDE-2571
+ * Checking if the node is of text type was removed to allow
+ * <select> node to be selected on the first click.
+ */
+ if (node != null) {
+ selectionManager.setSelection(SelectionUtil.getSelectedNode(selection),
+ selection.getFocusOffset(), selection.getAnchorOffset());
+ }
}
+ // enables cursor on selection event
+ visualSelectionController.setCaretEnabled(true);
+ // enables cursor on selection event
+ visualSelectionController.setCaretEnabled(true);
}
public void mouseDown(nsIDOMMouseEvent mouseEvent) {
- if (!switcher
- .startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
- return;
+ if (VpeDebug.PRINT_VISUAL_MOUSE_EVENT) {
+ System.out.println("<<< mouseDown targetNode:"); //$NON-NLS-1$
}
- try {
- if (VpeDebug.PRINT_VISUAL_MOUSE_EVENT) {
- System.out.println("<<< mouseDown targetNode:"); //$NON-NLS-1$
+ // selection will be set only if press left button
+ if (mouseEvent.getButton() == LEFT_BUTTON) {
+ // drag gesture isn't generated in XR 1.9 for Linux Platforms,
+ // so we start it's manually
+ // mareshkau
+ if (vpeDnD.isDragIconClicked(mouseEvent)) {
+ vpeDnD.dragStart(mouseEvent);
+ } else {
+ int rangeOffset = queryInterface(mouseEvent, nsIDOMNSUIEvent.class).getRangeOffset();
+
+ // set source selection at the point where mouse is clicked
+ selectionManager.setSelection(
+ VisualDomUtil.getTargetNode(mouseEvent),
+ rangeOffset, rangeOffset);
}
- // selection will be set only if press left button
- if (mouseEvent.getButton() == LEFT_BUTTON) {
- // drag gesture isn't generated in XR 1.9 for Linux Platforms,
- // so we start it's manually
- // mareshkau
- if (vpeDnD.isDragIconClicked(mouseEvent)) {
- vpeDnD.dragStart(mouseEvent);
- } else {
- int rangeOffset = queryInterface(mouseEvent, nsIDOMNSUIEvent.class).getRangeOffset();
-
- // set source selection at the point where mouse is clicked
- selectionManager.setSelection(
- VisualDomUtil.getTargetNode(mouseEvent),
- rangeOffset, rangeOffset);
- }
- }
- } finally {
- switcher.stopActiveEditor();
}
}
public void mouseUp(nsIDOMMouseEvent mouseEvent) {
- if (!switcher
- .startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
- return;
+ if (VpeDebug.PRINT_VISUAL_MOUSE_EVENT) {
+ System.out.println("<<< mouseUp"); //$NON-NLS-1$
}
- try {
- if (VpeDebug.PRINT_VISUAL_MOUSE_EVENT) {
- System.out.println("<<< mouseUp"); //$NON-NLS-1$
- }
- } finally {
- switcher.stopActiveEditor();
- }
}
public void mouseClick(nsIDOMMouseEvent mouseEvent) {
- if (!switcher
- .startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
- return;
- }
- try {
- nsIDOMNode visualNode = VisualDomUtil.getTargetNode(mouseEvent);
- if (visualNode != null) {
- if (VpeDebug.PRINT_VISUAL_MOUSE_EVENT) {
- System.out.println(MessageFormat.format(
- "<<< mouseClick visualNode: {0} ({1})", //$NON-NLS-1$
- visualNode.getNodeName(),
- visualNode));
+ nsIDOMNode visualNode = VisualDomUtil.getTargetNode(mouseEvent);
+ if (visualNode != null) {
+ if (VpeDebug.PRINT_VISUAL_MOUSE_EVENT) {
+ VpeDebugUtil.printVisualMouseEvent(visualNode);
+ }
+ if (!mouseUpSelectionReasonFlag) {
+ if (visualBuilder.isContentArea(visualNode)) {
+ // selectionBuilder.setClickContentAreaSelection();
}
- if (!mouseUpSelectionReasonFlag) {
- if (visualBuilder.isContentArea(visualNode)) {
- // selectionBuilder.setClickContentAreaSelection();
- }
- } else {
- mouseUpSelectionReasonFlag = false;
- }
+ } else {
+ mouseUpSelectionReasonFlag = false;
+ }
- Element toggledElement = visualBuilder.doToggle(visualNode);
- if (toggledElement != null) {
- VpeNodeMapping toggledMapping
- = getDomMapping().getNearNodeMapping(toggledElement);
- if (toggledMapping != null && toggledMapping.getVisualNode() != null) {
- selectionManager.setSelection(toggledMapping.getVisualNode(), 0, 0);
- }
+ Element toggledElement = visualBuilder.doToggle(visualNode);
+ if (toggledElement != null) {
+ VpeNodeMapping toggledMapping
+ = getDomMapping().getNearNodeMapping(toggledElement);
+ if (toggledMapping != null && toggledMapping.getVisualNode() != null) {
+ selectionManager.setSelection(toggledMapping.getVisualNode(), 0, 0);
}
}
- } finally {
- switcher.stopActiveEditor();
}
}
public void mouseDblClick(nsIDOMMouseEvent mouseEvent) {
- if (!switcher
- .startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
- return;
- }
- try {
- nsIDOMNode visualNode = VisualDomUtil.getTargetNode(mouseEvent);
- if (visualNode != null) {
- sourceBuilder.openOn(visualNode);
- if (VpeDebug.PRINT_VISUAL_MOUSE_EVENT) {
- System.out
- .println("<<< mouseDblClick visualNode: " + visualNode.getNodeName() + //$NON-NLS-1$
- " (" + visualNode + ")"); //$NON-NLS-1$ //$NON-NLS-2$
- }
+ nsIDOMNode visualNode = VisualDomUtil.getTargetNode(mouseEvent);
+ if (visualNode != null) {
+ sourceBuilder.openOn(visualNode);
+ if (VpeDebug.PRINT_VISUAL_MOUSE_EVENT) {
+ VpeDebugUtil.printVisualMouseEvent(visualNode);
}
- } finally {
- switcher.stopActiveEditor();
}
}
@@ -1203,75 +913,19 @@
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$
+ VpeDebugUtil.printKeyEvent(keyEvent);
}
- if (!switcher
- .startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
- switcher.stopActiveEditor();
- return;
- }
- try {
- visualEditor.hideResizer();
- } finally {
- switcher.stopActiveEditor();
- }
+ visualEditor.hideResizer();
setVpeUpdateDelayTime(0);
/*
* adding calls of core event handlers, for example' CTR+H' or 'CTRL+M'
* event handler dialog
*/
- boolean keyBindingPressed = false;
- Event keyboardEvent = new Event();
+ Event keyboardEvent = xulRunnerEditor.createSWTKeyEvent(keyEvent);
+
/*
- * widget where event occur
- */
- keyboardEvent.widget = xulRunnerEditor.getBrowser();
-
- keyboardEvent.stateMask = (keyEvent.getAltKey() ? SWT.ALT : 0)
- | (keyEvent.getCtrlKey() ? SWT.CTRL : 0)
- | (keyEvent.getShiftKey() ? SWT.SHIFT : 0)
- | (keyEvent.getMetaKey() ? SWT.MOD1 : 0);
- keyboardEvent.x = 0;
- keyboardEvent.y = 0;
- keyboardEvent.type = SWT.KeyDown;
-
- if (keyEvent.getKeyCode() == 0) {
- keyboardEvent.keyCode = (int) keyEvent.getCharCode();
- } else {
- keyboardEvent.keyCode = (int) keyEvent.getKeyCode();
- }
- /*
* JBIDE-1627
*/
- List<KeyStroke> possibleKeyStrokes = WorkbenchKeyboard
- .generatePossibleKeyStrokes(keyboardEvent);
- IWorkbench iWorkbench = VpePlugin.getDefault().getWorkbench();
- if (iWorkbench.hasService(IBindingService.class)) {
- IBindingService iBindingService = (IBindingService) iWorkbench
- .getService(IBindingService.class);
-
- KeySequence sequenceBeforeKeyStroke = KeySequence.getInstance();
-
- for (Iterator<KeyStroke> iterator = possibleKeyStrokes.iterator(); iterator
- .hasNext();) {
- KeySequence 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)) {
- keyBindingPressed = true;
- }
- }
- }
- }
/*
* Sends xulrunner event to eclipse environment. dmaliarevich: while
* fixing JBIDE-2562 I found that eclipse handles key shortcuts without
@@ -1286,9 +940,7 @@
*
* When shortcut key is pressed do not handle this event in the handler.
*/
- boolean isHandleCurrentEvent = !keyBindingPressed
- || isZoomEvent(keyEvent);
- if (isHandleCurrentEvent) {
+ if (!isKeyBinding(keyboardEvent) || isZoomEvent(keyEvent)) {
if (keyEventHandler instanceof KeyEventManager) {
IZoomEventManager zoomEventManager = ((KeyEventManager) keyEventHandler)
.getZoomEventManager();
@@ -1306,7 +958,36 @@
}
onRefresh();
}
+
+ public boolean isKeyBinding(Event keyboardEvent) {
+ boolean keyBindingPressed = false;
+ List<KeyStroke> possibleKeyStrokes = WorkbenchKeyboard
+ .generatePossibleKeyStrokes(keyboardEvent);
+
+ if (PlatformUI.getWorkbench().hasService(IBindingService.class)) {
+ IBindingService iBindingService = (IBindingService) PlatformUI.getWorkbench()
+ .getService(IBindingService.class);
+
+ KeySequence sequenceBeforeKeyStroke = KeySequence.getInstance();
+
+ for (KeyStroke keyStroke : possibleKeyStrokes) {
+ KeySequence sequenceAfterKeyStroke = KeySequence.getInstance(
+ sequenceBeforeKeyStroke, keyStroke);
+ if (iBindingService.isPerfectMatch(sequenceAfterKeyStroke)) {
+ final Binding binding = iBindingService
+ .getPerfectMatch(sequenceAfterKeyStroke);
+ if ((binding != null)
+ && (binding.getParameterizedCommand() != null)
+ && (binding.getParameterizedCommand().getCommand() != null)) {
+ keyBindingPressed = true;
+ }
+ }
+ }
+ }
+ return keyBindingPressed;
+ }
+
private boolean isZoomEvent(nsIDOMKeyEvent keyEvent) {
return keyEvent.getCtrlKey()
&& (keyEvent.getCharCode() == IZoomEventManager.ZOOM_IN_CH_CODE
@@ -1316,15 +997,7 @@
public void elementResized(nsIDOMElement element, int constrains, int top,
int left, int width, int height) {
- if (!switcher
- .startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
- return;
- }
- try {
- visualEditor.hideResizer();
- } finally {
- switcher.stopActiveEditor();
- }
+ visualEditor.hideResizer();
visualBuilder.resize(element, constrains, top, left, width, height);
sourceSelectionChanged();
}
@@ -1340,13 +1013,10 @@
/**
* Calls when on when browser receive context menu event.
*
- * @param contextFlags
- * -not used in this function, just for because this parameter
- * exist in nsIContextMenuListener
- * @param event
- * event from browser used here
- * @param node
- * where this event are occur
+ * @param contextFlags is not used in this function, just for because this parameter
+ * exist in nsIContextMenuListener
+ * @param event comes from browser is used here
+ * @param node where the event has occurred
*/
public void onShowContextMenu(long contextFlags, nsIDOMEvent event,
nsIDOMNode node) {
@@ -1417,11 +1087,7 @@
}
public void visualRefreshImpl() {
- if (!switcher
- .startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
- return;
- }
- try {
+ if (editPart.getVisualMode() != VpeEditorPart.SOURCE_MODE) {
visualEditor.hideResizer();
String currentDoctype = DocTypeUtil.getDoctype(visualEditor
@@ -1438,87 +1104,18 @@
// Fix bugs JBIDE-2750
visualBuilder.clearSelectionRectangle();
visualEditor.reload();
- // IDOMModel sourceModel = (IDOMModel) getModel();
- // if (sourceModel != null) {
- // IDOMDocument sourceDocument = sourceModel.getDocument();
- // visualBuilder.rebuildDom(sourceDocument);
- // } else {
- // visualBuilder.rebuildDom(null);
- // }
}
- } finally {
- if (switcher != null) {
- switcher.stopActiveEditor();
- }
}
-
}
public void preLongOperation() {
- switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL);
+
}
public void postLongOperation() {
- switcher.stopActiveEditor();
visualRefresh();
}
- // 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$
- 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$
- } 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$
- } else {
- 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$
- } else {
- System.out.println(" newValue: " + newValue); //$NON-NLS-1$
- }
- }
- }
-
- private void printVisualEvent(nsIDOMEvent event) {
- System.out.print("<<< " + event.getType()); //$NON-NLS-1$
-
- if (event instanceof nsIDOMMutationEvent) {
- nsIDOMMutationEvent mutationEvent = (nsIDOMMutationEvent) event;
-
- System.out.print(" EventPhase: " + mutationEvent.getEventPhase()); //$NON-NLS-1$
-
- nsIDOMNode relatedNode = mutationEvent.getRelatedNode();
- System.out
- .print(" RelatedNode: " + (relatedNode == null ? null : relatedNode.getNodeName())); //$NON-NLS-1$
-
- 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(" PrevValue: " + mutationEvent.getPrevValue().trim()); //$NON-NLS-1$
- System.out
- .print(" NewValue: " + mutationEvent.getNewValue().trim()); //$NON-NLS-1$
- }
- System.out.println();
- }
-
private class VPEUpdateJob extends UIJob {
private boolean cancelled = false;
@@ -1540,9 +1137,7 @@
if (changeEvents.size() > MAX_EVENTS_TILL_REFRESH) {
monitor.worked((int) (10000 / 2));
- System.out.println("full refresh is started");
reinitImpl();
- System.out.println("full refresh is finished");
monitor.worked(10000);
changeEvents.clear();
return Status.OK_STATUS;
@@ -1565,40 +1160,26 @@
// shoud ignore this
// exception
break;
- } catch (NullPointerException ex) {
- if (switcher != null) {
- throw ex;
- } else {
- // class was disposed and exception result
- // of that we can't stop
- // refresh job in time, so we just ignore
- // this exception
- }
- } catch(RuntimeException ex) {
- VpePlugin.getPluginLog().logError(ex);
} finally {
getChangeEvents().remove(eventBean);
}
}
// cause is to lock calls others events
- if (switcher != null && 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. New nodes
- * haven't been put into dom mapping thus
- * toolbar becomes desabled. Updating toolbar
- * state here takes into account updated vpe
- * nodes.
- */
- if (toolbarFormatControllerManager != null) {
- toolbarFormatControllerManager.selectionChanged();
- }
- } finally {
- switcher.stopActiveEditor();
+ if (editPart.getVisualMode() != VpeEditorPart.SOURCE_MODE) {
+ sourceSelectionChanged();
+ /*
+ * https://jira.jboss.org/jira/browse/JBIDE-3619
+ * 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.
+ */
+ if (toolbarFormatControllerManager != null) {
+ toolbarFormatControllerManager.selectionChanged();
}
+ }
monitor.done();
notifyVpeUpdateListeners();
return Status.OK_STATUS;
@@ -1609,38 +1190,6 @@
}
}
- public class ActiveEditorSwitcher {
- public static final int ACTIVE_EDITOR_CANNOT = 0;
- public static final int ACTIVE_EDITOR_NONE = 1;
- public static final int ACTIVE_EDITOR_SOURCE = 2;
- public static final int ACTIVE_EDITOR_VISUAL = 3;
-
- private int type = ACTIVE_EDITOR_CANNOT;
-
- private void initActiveEditor() {
- type = ACTIVE_EDITOR_NONE;
- }
-
- private void destroyActiveEditor() {
- type = ACTIVE_EDITOR_CANNOT;
- }
-
- public boolean startActiveEditor(int newType) {
- if (type != ACTIVE_EDITOR_NONE || type == ACTIVE_EDITOR_NONE && newType == ACTIVE_EDITOR_SOURCE
- && editPart.getVisualMode() == VpeEditorPart.SOURCE_MODE) {
- return false;
- } else {
- type = newType;
- return true;
- }
- }
-
- public void stopActiveEditor() {
- onRefresh();
- type = ACTIVE_EDITOR_NONE;
- }
- }
-
void refreshTemplates() {
if (includeList.includesRefresh()) {
visualRefresh();
@@ -1650,16 +1199,8 @@
if (bundleMap != null) {
bundleMap.refresh();
- if (pageContext != null) {
- if (!switcher
- .startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
- return;
- }
- try {
- pageContext.refreshBundleValues();
- } finally {
- switcher.stopActiveEditor();
- }
+ if (pageContext != null && editPart.getVisualMode() != VpeEditorPart.SOURCE_MODE) {
+ pageContext.refreshBundleValues();
}
}
}
@@ -2005,19 +1546,11 @@
toolbarFormatControllerManager.selectionChanged();
}
- if (!switcher
- .startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
- return;
- }
- try {
-
+ if (editPart.getVisualMode() != VpeEditorPart.SOURCE_MODE) {
if (VpeDebug.PRINT_SOURCE_SELECTION_EVENT) {
- System.out
- .println(">>>>>>>>>>>>>> selectionChanged " + event.getSource()); //$NON-NLS-1$
+ System.out.println(">>>>>>>>>>>>>> selectionChanged " + event.getSource()); //$NON-NLS-1$
}
sourceSelectionChanged();
- } finally {
- switcher.stopActiveEditor();
}
}
@@ -2107,57 +1640,48 @@
}
private void reinitImpl() {
- try {
- if (switcher == null
- || !switcher
- .startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
- return;
+ if (editPart.getVisualMode() != VpeEditorPart.SOURCE_MODE){
+ try {
+ // this method must be invoked before any visual
+ // node is created, see JBIDE-5105
+ visualEditor.reinitDesignMode();
+ visualBuilder.clearSelectionRectangle();
+ // this is required because fullRefresh cannot be interrupded by messages from OS queue
+ selectionManager = null;
+ IDOMModel sourceModel = (IDOMModel) getModel();
+ if (sourceModel != null) {
+ IDOMDocument sourceDocument = sourceModel.getDocument();
+ visualBuilder.rebuildDom(sourceDocument);
+ } else {
+ visualBuilder.rebuildDom(null);
+ }
+ // reinits selection controller+ controller
+ visualSelectionController = new VpeSelectionController(visualEditor
+ .getEditor().getSelectionController());
+
+ visualSelectionController.setSelectionFlags(nsISelectionDisplay.DISPLAY_ALL);
+
+ selectionManager = new SelectionManager(pageContext, sourceEditor,
+ visualSelectionController);
+ // selection should be restored after full refresh
+ selectionManager.refreshVisualSelection();
+
+ keyEventHandler = new KeyEventManager(sourceEditor, domMapping,
+ pageContext);
+ float currentZoom = zoomEventManager.getCurrentZoom();
+ zoomEventManager = new ZoomEventManager(getXulRunnerEditor());
+ zoomEventManager.setCurrentZoom(currentZoom);
+ ((KeyEventManager) keyEventHandler)
+ .setZoomEventManager(zoomEventManager);
+ // restore selection in visula part
+ sourceSelectionChanged();
+ } catch (VpeDisposeException ex) {
+ // vpe vas closed when refresh job is running, so just
+ // ignore this exception
+ } catch(RuntimeException ex) {
+ VpePlugin.getPluginLog().logError(ex);
}
-
- // this method must be invoked before any visual
- // node is created, see JBIDE-5105
- visualEditor.reinitDesignMode();
- visualBuilder.clearSelectionRectangle();
- // this is required because fullRefresh cannot be interrupded by messages from OS queue
- selectionManager = null;
- IDOMModel sourceModel = (IDOMModel) getModel();
- if (sourceModel != null) {
- IDOMDocument sourceDocument = sourceModel.getDocument();
- visualBuilder.rebuildDom(sourceDocument);
- } else {
- visualBuilder.rebuildDom(null);
- }
- // reinits selection controller+ controller
- visualSelectionController = new VpeSelectionController(visualEditor
- .getEditor().getSelectionController());
-
- visualSelectionController.setSelectionFlags(nsISelectionDisplay.DISPLAY_ALL);
-
- selectionManager = new SelectionManager(pageContext, sourceEditor,
- visualSelectionController);
- // selection should be restored after full refresh
- selectionManager.refreshVisualSelection();
-
- keyEventHandler = new KeyEventManager(sourceEditor, domMapping,
- pageContext);
- float currentZoom = zoomEventManager.getCurrentZoom();
- zoomEventManager = new ZoomEventManager(getXulRunnerEditor());
- zoomEventManager.setCurrentZoom(currentZoom);
- ((KeyEventManager) keyEventHandler)
- .setZoomEventManager(zoomEventManager);
- // restore selection in visula part
- sourceSelectionChanged();
- } catch (VpeDisposeException ex) {
- // vpe vas closed when refresh job is running, so just
- // ignore this exception
- } catch(RuntimeException ex) {
- VpePlugin.getPluginLog().logError(ex);
- } finally {
- if (switcher != null) {
- switcher.stopActiveEditor();
- }
}
-
}
public void refreshCommands(){
@@ -2244,11 +1768,9 @@
public void setZoomEventManager(IZoomEventManager zoomEventManager) {
this.zoomEventManager = zoomEventManager;
- }
+ }
- public ActiveEditorSwitcher getSwitcher() {
- return switcher;
- }
+
public VpeDropWindow getDropWindow() {
return dropWindow;
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeDebugUtil.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeDebugUtil.java 2011-12-29 00:03:43 UTC (rev 37571)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeDebugUtil.java 2011-12-29 00:56:12 UTC (rev 37572)
@@ -13,7 +13,13 @@
import java.text.SimpleDateFormat;
import java.util.Date;
import org.eclipse.core.runtime.Platform;
+import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
import org.jboss.tools.vpe.VpeDebug;
+import org.mozilla.interfaces.nsIDOMEvent;
+import org.mozilla.interfaces.nsIDOMKeyEvent;
+import org.mozilla.interfaces.nsIDOMMutationEvent;
+import org.mozilla.interfaces.nsIDOMNode;
+import org.w3c.dom.Node;
/**
* @author Max Areshkau (mareshkau(a)exadel.com)
@@ -46,4 +52,72 @@
System.out.println(formatter.format(new Date())+":"+ msg); //$NON-NLS-1$
}
}
+ public static void printVisualEvent(nsIDOMEvent event) {
+ System.out.print("<<< " + event.getType()); //$NON-NLS-1$
+
+ if (event instanceof nsIDOMMutationEvent) {
+ nsIDOMMutationEvent mutationEvent = (nsIDOMMutationEvent) event;
+
+ System.out.print(" EventPhase: " + mutationEvent.getEventPhase()); //$NON-NLS-1$
+
+ nsIDOMNode relatedNode = mutationEvent.getRelatedNode();
+ System.out
+ .print(" RelatedNode: " + (relatedNode == null ? null : relatedNode.getNodeName())); //$NON-NLS-1$
+
+ 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(" PrevValue: " + mutationEvent.getPrevValue().trim()); //$NON-NLS-1$
+ System.out
+ .print(" NewValue: " + mutationEvent.getNewValue().trim()); //$NON-NLS-1$
+ }
+ System.out.println();
+ }
+ // for debug
+ public static 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$
+ 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$
+ } 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$
+ } else {
+ 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$
+ } else {
+ System.out.println(" newValue: " + newValue); //$NON-NLS-1$
+ }
+ }
+ }
+ public static void printKeyEvent(nsIDOMKeyEvent keyEvent) {
+ 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$
+ }
+ public static void printVisualMouseEvent(nsIDOMNode visualNode) {
+ System.out
+ .println("<<< mouseDblClick visualNode: " + visualNode.getNodeName() + //$NON-NLS-1$
+ " (" + visualNode + ")"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
}
Modified: trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/XulRunnerEditor.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/XulRunnerEditor.java 2011-12-29 00:03:43 UTC (rev 37571)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/XulRunnerEditor.java 2011-12-29 00:56:12 UTC (rev 37572)
@@ -32,6 +32,7 @@
import org.mozilla.interfaces.nsIBaseWindow;
import org.mozilla.interfaces.nsIDOMDocument;
import org.mozilla.interfaces.nsIDOMElement;
+import org.mozilla.interfaces.nsIDOMKeyEvent;
import org.mozilla.interfaces.nsIDOMNode;
import org.mozilla.interfaces.nsIDOMWindow;
import org.mozilla.interfaces.nsISupports;
@@ -500,4 +501,24 @@
}
return resizeElement;
}
+
+ public Event createSWTKeyEvent(nsIDOMKeyEvent keyEvent) {
+ Event keyboardEvent = new Event();
+ keyboardEvent.widget = getBrowser();
+
+ keyboardEvent.stateMask = (keyEvent.getAltKey() ? SWT.ALT : 0)
+ | (keyEvent.getCtrlKey() ? SWT.CTRL : 0)
+ | (keyEvent.getShiftKey() ? SWT.SHIFT : 0)
+ | (keyEvent.getMetaKey() ? SWT.MOD1 : 0);
+ keyboardEvent.x = 0;
+ keyboardEvent.y = 0;
+ keyboardEvent.type = SWT.KeyDown;
+
+ if (keyEvent.getKeyCode() == 0) {
+ keyboardEvent.keyCode = (int) keyEvent.getCharCode();
+ } else {
+ keyboardEvent.keyCode = (int) keyEvent.getKeyCode();
+ }
+ return keyboardEvent;
+ }
}
12 years, 12 months
JBoss Tools SVN: r37571 - trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2011-12-28 19:03:43 -0500 (Wed, 28 Dec 2011)
New Revision: 37571
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/XHTMLValidator.java
Log:
https://issues.jboss.org/browse/JBIDE-10472 CLONE - XHTML Validator hangs eclipse
Modified: trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/XHTMLValidator.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/XHTMLValidator.java 2011-12-28 23:34:54 UTC (rev 37570)
+++ trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/XHTMLValidator.java 2011-12-29 00:03:43 UTC (rev 37571)
@@ -348,8 +348,8 @@
InputStream stream = null;
try {
URL location = new URL(getSystemId());
- String protocal = location.getProtocol();
- if(!"http".equalsIgnoreCase(protocal) && !"https".equalsIgnoreCase(protocal)) {
+ String protocol = location.getProtocol();
+ if(!"http".equalsIgnoreCase(protocol) && !"https".equalsIgnoreCase(protocol)) {
URLConnection connect = location.openConnection();
if (!(connect instanceof HttpURLConnection)) {
stream = connect.getInputStream();
12 years, 12 months
JBoss Tools SVN: r37570 - trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2011-12-28 18:34:54 -0500 (Wed, 28 Dec 2011)
New Revision: 37570
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/XHTMLValidator.java
Log:
https://issues.jboss.org/browse/JBIDE-10472 CLONE - XHTML Validator hangs eclipse
Modified: trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/XHTMLValidator.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/XHTMLValidator.java 2011-12-28 08:32:27 UTC (rev 37569)
+++ trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/XHTMLValidator.java 2011-12-28 23:34:54 UTC (rev 37570)
@@ -18,20 +18,12 @@
import java.net.URL;
import java.net.URLConnection;
import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Stack;
-import org.apache.xerces.impl.Constants;
-import org.apache.xerces.impl.XMLErrorReporter;
-import org.apache.xerces.impl.msg.XMLMessageFormatter;
-import org.apache.xerces.util.MessageFormatter;
import org.apache.xerces.xni.XMLResourceIdentifier;
import org.apache.xerces.xni.XNIException;
import org.apache.xerces.xni.parser.XMLEntityResolver;
import org.apache.xerces.xni.parser.XMLInputSource;
import org.apache.xerces.xni.parser.XMLParseException;
-import org.apache.xerces.xni.parser.XMLParserConfiguration;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
@@ -50,7 +42,6 @@
import org.eclipse.wst.xml.core.internal.validation.eclipse.Validator;
import org.jboss.tools.common.util.FileUtil;
import org.jboss.tools.jsf.JSFModelPlugin;
-import org.xml.sax.Attributes;
import org.xml.sax.InputSource;
import org.xml.sax.Locator;
import org.xml.sax.SAXException;
@@ -63,21 +54,15 @@
import org.xml.sax.helpers.LocatorImpl;
/**
- *
* @author Victor V. Rubezhny
- *
*/
@SuppressWarnings("restriction")
public class XHTMLValidator extends Validator {
- private static final String END_TAG_STRATEGY = "END_TAG";
- private static final String START_TAG_STRATEGY = "START_TAG";
- private static final String NO_START_TAG = "NO_START_TAG";
- private static final String NO_END_TAG = "NO_END_TAG";
public static final String PROBLEM_ID = JSFModelPlugin.PLUGIN_ID + "xhtmlsyntaxproblem";
-
+
IProgressMonitor monitor;
IResource resource;
-
+
private String[] SAX_PARSER_FEATURES_TO_DISABLE = {
"http://xml.org/sax/features/namespaces",
"http://xml.org/sax/features/use-entity-resolver2",
@@ -90,10 +75,7 @@
"http://apache.org/xml/features/xinclude",
"http://xml.org/sax/features/resolve-dtd-uris"
};
- private String[] SAX_PARSER_FEATURES_TO_ENABLE = {
- "http://apache.org/xml/features/continue-after-fatal-error"
- };
-
+
private void setSAXParserFeatures(XMLReader reader, String[] features, boolean set) {
for (String feature : features) {
try {
@@ -113,8 +95,9 @@
}
private IDocument getDocument(IFile file) {
- if (file == null)
+ if (file == null) {
return null;
+ }
String content;
try {
@@ -123,10 +106,10 @@
JSFModelPlugin.getDefault().logError(e);
return null;
}
-
+
return (content == null ? null : new Document(content));
}
-
+
/*
* (non-Javadoc)
* @see org.eclipse.wst.xml.core.internal.validation.core.AbstractNestedValidator#validate(org.eclipse.core.resources.IResource, int, org.eclipse.wst.validation.ValidationState, org.eclipse.core.runtime.IProgressMonitor)
@@ -154,31 +137,20 @@
XHTMLElementHandler handler = new XHTMLElementHandler(uri,
(resource instanceof IFile ? getDocument((IFile)resource) : null),
report);
-
+
try {
- if (!handler.isWellFormedXHTML()) {
- SAXParseException ex = handler.getException();
- if (ex != null) {
- report.addError(ex.getLocalizedMessage(), ex.getLineNumber(), ex.getColumnNumber(), uri);
- }
- return report;
- }
-
XMLReader xmlReader = new MySAXParser();
setSAXParserFeatures(xmlReader, SAX_PARSER_FEATURES_TO_DISABLE, false);
- setSAXParserFeatures(xmlReader, SAX_PARSER_FEATURES_TO_ENABLE, true);
setSAXParserProperty(xmlReader, "http://xml.org/sax/properties/lexical-handler", handler);
-
+
xmlReader.setProperty("http://apache.org/xml/properties/internal/entity-resolver", new NullXMLEntityResolver());
xmlReader.setContentHandler(handler);
xmlReader.setDTDHandler(handler);
xmlReader.setErrorHandler(handler);
xmlReader.setEntityResolver(handler);
-
- handler.setCurrentReader(xmlReader);
-
+
xmlReader.parse(uri);
} catch (IOException e) {
JSFModelPlugin.getDefault().logError(e);
@@ -187,57 +159,42 @@
} catch (SAXNotSupportedException e) {
JSFModelPlugin.getDefault().logError(e);
} catch (SAXException e) {
- report.addError(e.getLocalizedMessage(), 0, 0, uri);
- }
-
- List<ElementLocation> locations = handler.getNonPairedOpenElements();
- if (!locations.isEmpty()) {
- for (ElementLocation location : locations) {
- String messageText = MessageFormat.format(JSFValidationMessage.XHTML_VALIDATION_NO_END_TAG, location.getName());
- report.addError(messageText, location.getLine(), location.getColumn(), uri, NO_END_TAG, new Object[] {location});
+ int max = handler.document.getLength();
+ int currentLocation = handler.getCurrentLocation();
+ int length = 0;
+ if(max>0) {
+ if(currentLocation+1>max) {
+ currentLocation--;
+ } else {
+ length = 1;
+ }
}
+ ElementLocation location = new ElementLocation(handler.locator.getLineNumber(), handler.locator.getColumnNumber(), currentLocation, length);
+ report.addError(e.getLocalizedMessage(), handler.locator.getLineNumber(), handler.locator.getColumnNumber(), uri, null, new Object[] {location});
}
-
- locations = handler.getNonPairedCloseElements();
- if (!locations.isEmpty()) {
- for (ElementLocation location : locations) {
- String messageText = MessageFormat.format(JSFValidationMessage.XHTML_VALIDATION_NO_START_TAG, location.getName());
- report.addError(messageText, location.getLine(), location.getColumn(), uri, NO_START_TAG, new Object[] {location});
- }
- }
-
+
return report;
}
-
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.wst.xml.core.internal.validation.eclipse.Validator#addInfoToMessage(org.eclipse.wst.xml.core.internal.validation.core.ValidationMessage, org.eclipse.wst.validation.internal.provisional.core.IMessage)
+ */
@Override
- protected void addInfoToMessage(ValidationMessage validationMessage,
- IMessage message) {
+ protected void addInfoToMessage(ValidationMessage validationMessage, IMessage message) {
ElementLocation location = validationMessage.getMessageArguments() == null || validationMessage.getMessageArguments().length < 1 ?
null: (ElementLocation)validationMessage.getMessageArguments()[0];
-
- String nameOrValue = location == null ? "" : location.getName();
- String key = validationMessage.getKey();
- if(key != null && (NO_START_TAG.equals(key) || NO_END_TAG.equals(key)) )
- {
- String selectionStrategy = START_TAG_STRATEGY;
- if (NO_START_TAG.equals(key)) {
- selectionStrategy = START_TAG_STRATEGY;
- } else if (NO_END_TAG.equals(key)) {
- selectionStrategy = END_TAG_STRATEGY;
- }
- message.setAttribute(COLUMN_NUMBER_ATTRIBUTE, new Integer(validationMessage.getColumnNumber()));
- message.setAttribute(SQUIGGLE_SELECTION_STRATEGY_ATTRIBUTE, selectionStrategy);
- message.setAttribute(SQUIGGLE_NAME_OR_VALUE_ATTRIBUTE, nameOrValue);
- if (location != null) {
- message.setLineNo(location.getLine());
- message.setOffset(location.getStart());
- message.setLength(location.getLength());
- }
- } else {
- super.addInfoToMessage(validationMessage, message);
+ if (location != null) {
+ message.setLineNo(location.getLine());
+ message.setOffset(location.getStart());
+ message.setLength(location.getLength());
}
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.wst.xml.core.internal.validation.eclipse.Validator#validationStarting(org.eclipse.core.resources.IProject, org.eclipse.wst.validation.ValidationState, org.eclipse.core.runtime.IProgressMonitor)
+ */
@Override
public void validationStarting(IProject project, ValidationState state,
IProgressMonitor monitor) {
@@ -254,30 +211,24 @@
monitor.subTask(MessageFormat.format(message, arguments));
}
}
-
+
class ElementLocation {
- String name;
int line;
int column;
int start;
int length;
-
- ElementLocation (String name, int line, int column, int start, int length) {
- this.name = name;
+
+ ElementLocation (int line, int column, int start, int length) {
this.line = line;
this.column = column;
this.start = start;
this.length = length;
}
-
- String getName() {
- return name;
- }
-
+
int getLine() {
return line;
}
-
+
int getColumn() {
return column;
}
@@ -285,17 +236,16 @@
int getStart() {
return start;
}
-
+
int getLength() {
return length;
}
-
+
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("'");
- sb.append(name);
- sb.append("', Line: ");
+ sb.append("Line: ");
sb.append(line);
sb.append(", Column: ");
sb.append(column);
@@ -310,139 +260,38 @@
}
class NullXMLEntityResolver implements XMLEntityResolver {
-
- public XMLInputSource resolveEntity(XMLResourceIdentifier rid)
- throws XNIException, IOException {
-
+ public XMLInputSource resolveEntity(XMLResourceIdentifier rid) throws XNIException, IOException {
return new XMLInputSource(rid.getPublicId(),
rid.getBaseSystemId()==null?rid.getLiteralSystemId():rid.getExpandedSystemId(),
rid.getBaseSystemId(), new StringReader(""), null);
}
-
}
-
+
class XHTMLElementHandler extends DefaultHandler implements LexicalHandler {
- private String uri;
private Locator locator;
private IDocument document;
- private XMLValidationInfo valinfo;
- public boolean isXHTMLDoctype = false;
- private boolean isWellFormed = false;
- private XMLReader currentReader = null;
-
- List<ElementLocation> elements = new ArrayList<ElementLocation>();
- Stack<ElementLocation> nonPairedOpenElements = new Stack<XHTMLValidator.ElementLocation>();
- Stack<ElementLocation> nonPairedCloseElements = new Stack<XHTMLValidator.ElementLocation>();
-
+
public XHTMLElementHandler(String uri, IDocument document, XMLValidationInfo valinfo) {
super();
- this.uri = uri;
this.document = document;
- this.valinfo = valinfo;
}
-
- public void setCurrentReader (XMLReader reader) {
- this.currentReader = reader;
- }
-
- public XMLReader getCurrentReader() {
- return this.currentReader;
- }
+
@Override
public void setDocumentLocator(Locator locator) {
this.locator = locator;
- }
-
- @Override
- public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
- if (!isWellFormed || !isXHTMLDoctype)
- return;
-
- int end = getCurrentLocation(), start = 0;
- if(end > 0) {
- start = document.get().lastIndexOf("<", end - 1);
- }
- currentElementLocation = new ElementLocation(qName, getLine(start), getColumn(start), start, end - start);
- nonPairedOpenElements.push(currentElementLocation);
}
-
- ElementLocation currentElementLocation = null;
- @Override
- public void endElement(String uri, String localName, String qName) throws SAXException {
- if (!isWellFormed || !isXHTMLDoctype)
- return;
- int end = getCurrentLocation(), start = 0;
- if(end > 0) {
- start = document.get().lastIndexOf('<', end - 1);
- }
- if (document.get().charAt(end - 1) != '>') {
- int newEnd = document.get().indexOf('>', end);
- if (newEnd > 0) {
- qName = getName(document.get().substring(start, newEnd));
- end = newEnd+1;
- }
- }
- currentElementLocation = new ElementLocation(qName, getLine(start), getColumn(start), start, end - start);
- // Try to find according pair open element
- ElementLocation pairOpenElement = null;
- for (int i = nonPairedOpenElements.size() - 1; i >= 0 && pairOpenElement == null; i--) {
- ElementLocation openedElement = nonPairedOpenElements.get(i);
- if (openedElement != null && openedElement.getName().equals(qName)) {
- pairOpenElement = openedElement;
- }
- }
- if (pairOpenElement == null) {
- // There is no open element for the current closing element
- nonPairedCloseElements.push(currentElementLocation);
- } else {
- // The pair open element is found for the current closing element
- nonPairedOpenElements.remove(pairOpenElement);
- }
- }
-
- private String getName(String text) {
- if (text.startsWith("<"))
- text = text.substring(1);
- if (text.startsWith("/"))
- text = text.substring(1);
- StringBuilder qName = new StringBuilder();
- int i = 0;
- while(i < text.length() && (Character.isJavaIdentifierPart(text.charAt(i)) || text.charAt(i) == ':')) {
- qName.append(text.charAt(i));
- i++;
- }
- return qName.toString();
- }
-
@Override
- public void fatalError(SAXParseException e) throws SAXException {
- if (!isWellFormed) {
- if (isNonWellFormedException(e, getCurrentReader() instanceof MySAXParser ? ((MySAXParser)getCurrentReader()).getConfiguration() : null)) {
- super.fatalError(e);
- }
- }
- // We do not need to throw any exceptions here in case of well-formed xhtml (opposite to what super method does)!
- }
-
- @Override
public InputSource resolveEntity(String publicId, String systemId)
throws IOException, SAXException {
return new InputSource(new StringReader("")); //$NON-NLS-1$
}
- List<ElementLocation> getNonPairedOpenElements() {
- return nonPairedOpenElements;
- }
-
- List<ElementLocation> getNonPairedCloseElements() {
- return nonPairedCloseElements;
- }
-
private int getCurrentLocation() {
- if (locator == null)
+ if (locator == null) {
return 0;
-
+ }
+
int line = locator.getLineNumber() - 1;
int lineOffset = locator.getColumnNumber() - 1;
try {
@@ -453,52 +302,7 @@
return 0;
}
- /**
- * Returns line number in text for offset 'start'; the first line has number 1.
- *
- * @param start
- * @return
- */
- private int getLine(int start) {
- try {
- return document.getLineOfOffset(start) + 1;
- } catch (BadLocationException e) {
- JSFModelPlugin.getPluginLog().logError(e);
- return -1;
- }
- }
-
- /**
- * Returns line number in text for offset 'start'; the first line has number 1.
- *
- * @param start
- * @return
- */
- private int getColumn(int start) {
- try {
- int line = getLine(start);
- int lineStart = document.getLineOffset(line - 1);
- return (start - lineStart) + 1;
- } catch (BadLocationException e) {
- JSFModelPlugin.getPluginLog().logError(e);
- return -1;
- }
- }
-
@Override
- public void startDTD(String name, String publicId, String systemId)
- throws SAXException {
- if (!isWellFormed) {
- valinfo.setGrammarEncountered(true);
- valinfo.setDTDEncountered(true);
- if (publicId != null && publicId.indexOf("W3C") != -1 &&
- publicId.indexOf("DTD") != -1 && publicId.indexOf("XHTML") != -1) {
- this.isXHTMLDoctype = true;
- }
- }
- }
-
- @Override
public void endDTD() throws SAXException {
}
@@ -519,137 +323,15 @@
}
@Override
- public void comment(char[] ch, int start, int length)
- throws SAXException {
+ public void comment(char[] ch, int start, int length) throws SAXException {
}
-
- private SAXParseException exception = null;
-
- SAXParseException getException() {
- return exception;
- }
-
- public boolean isWellFormedXHTML() throws IOException, SAXException {
- exception = null;
- isXHTMLDoctype = false;
- isWellFormed = false;
-
- MySAXParser reader = new MySAXParser();
- try {
- setSAXParserFeatures(reader, SAX_PARSER_FEATURES_TO_DISABLE, false);
- setSAXParserFeatures(reader, SAX_PARSER_FEATURES_TO_ENABLE, true); // Disabling this feature
- // due to prevent validation
- // on non-well-formed xhtml files
- setSAXParserProperty(reader, "http://xml.org/sax/properties/lexical-handler", this);
- reader.setProperty("http://apache.org/xml/properties/internal/entity-resolver", new NullXMLEntityResolver());
- reader.setContentHandler(this);
- reader.setDTDHandler(this);
- reader.setErrorHandler(this);
- reader.setEntityResolver(this);
-
- this.setCurrentReader(reader);
-
- isXHTMLDoctype = false;
- reader.parse(uri);
- } catch (SAXParseException e) {
- // We have to prevent further validation in case we've met the following exception:
- // "The markup in the document preceding the root element must be well-formed"
- // If the markup is not well-formed, not doing this may cause the validation to stuck
- // in Throwable.fillInStackTrace() method (it may come into an infinite loop) for some reason
- //
- if (isNonWellFormedException(e, reader.getConfiguration())) {
- exception = e;
- isXHTMLDoctype = false;
- return false;
- }
- }
- isWellFormed = true;
- return this.isXHTMLDoctype;
- }
-
- private static final String MARKUP_NOT_RECOGNIZED_ERROR_MESSAGE_ID = "MarkupNotRecognizedInProlog";
- private static final String ERROR_REPORTER_PROPERTY = Constants.XERCES_PROPERTY_PREFIX + Constants.ERROR_REPORTER_PROPERTY;
-
- private boolean isNonWellFormedException (SAXParseException e, XMLParserConfiguration parserConfiguration) {
- if (parserConfiguration == null) return true;
-
- XMLErrorReporter errorReporter = (XMLErrorReporter)parserConfiguration.getProperty(ERROR_REPORTER_PROPERTY);
- if (errorReporter == null) return true;
-
- MessageFormatter messageFormatter = errorReporter.getMessageFormatter(XMLMessageFormatter.XML_DOMAIN);
- String templateMessage = null;
- if (messageFormatter != null) {
- templateMessage = messageFormatter.formatMessage(parserConfiguration.getLocale(), MARKUP_NOT_RECOGNIZED_ERROR_MESSAGE_ID, null);
- }
- String message = e.getMessage() == null ? null : e.getMessage().toLowerCase();
- if (templateMessage == null) {
- return (message != null && message.contains(XMLMessageFormatter.XML_DOMAIN) &&
- message.contains("MarkupNotRecognizedInProlog"));
- }
-
- return (message != null && message.equals(templateMessage.toLowerCase()));
- }
- }
-
- class FilteredInputStream extends InputStream {
- InputStream base;
-
- public FilteredInputStream(InputStream base) {
- this.base = base;
- }
-
@Override
- public int read() throws IOException {
- int ch = base.read();
- return (ch == '&' ? ' ' : ch);
+ public void startDTD(String name, String publicId, String systemId)
+ throws SAXException {
}
-
- @Override
- public int read(byte[] b) throws IOException {
- return base.read(b);
- }
-
- @Override
- public int read(byte[] b, int off, int len) throws IOException {
- int length = base.read(b, off, len);
- for (int i = 0; i < length; i++) {
- if (b[i] == '&') b[i] = ' ';
- }
- return length;
- }
-
- @Override
- public long skip(long n) throws IOException {
- return base.skip(n);
- }
-
- @Override
- public int available() throws IOException {
- return base.available();
- }
-
- @Override
- public void close() throws IOException {
- base.close();
- }
-
- @Override
- public synchronized void mark(int readlimit) {
- base.mark(readlimit);
- }
-
- @Override
- public synchronized void reset() throws IOException {
- base.reset();
- }
-
- @Override
- public boolean markSupported() {
- return base.markSupported();
- }
}
-
+
class MyXMLInputSource extends XMLInputSource {
public MyXMLInputSource(String publicId, String systemId,
@@ -657,15 +339,22 @@
super(publicId, systemId, baseSystemId);
}
+ /*
+ * (non-Javadoc)
+ * @see org.apache.xerces.xni.parser.XMLInputSource#getByteStream()
+ */
@Override
public InputStream getByteStream() {
InputStream stream = null;
try {
URL location = new URL(getSystemId());
- URLConnection connect = location.openConnection();
- if (!(connect instanceof HttpURLConnection)) {
- stream = new FilteredInputStream(connect.getInputStream());
- }
+ String protocal = location.getProtocol();
+ if(!"http".equalsIgnoreCase(protocal) && !"https".equalsIgnoreCase(protocal)) {
+ URLConnection connect = location.openConnection();
+ if (!(connect instanceof HttpURLConnection)) {
+ stream = connect.getInputStream();
+ }
+ }
} catch (MalformedURLException e) {
// Ignore (null will be returned as result)
JSFModelPlugin.getPluginLog().logError(e);
@@ -676,14 +365,13 @@
return stream;
}
}
-
+
class MySAXParser extends org.apache.xerces.parsers.SAXParser {
- public XMLParserConfiguration getConfiguration() {
- return fConfiguration;
- }
-
-
+ /*
+ * (non-Javadoc)
+ * @see org.apache.xerces.parsers.AbstractSAXParser#parse(java.lang.String)
+ */
@Override
public void parse(String systemId) throws SAXException, IOException {
// parse document
@@ -691,7 +379,6 @@
try {
parse(source);
}
-
// wrap XNI exceptions as SAX exceptions
catch (XMLParseException e) {
Exception ex = e.getException();
@@ -725,8 +412,7 @@
throw (IOException)ex;
}
throw new SAXException(ex);
- }
- catch (XNIException e) {
+ } catch (XNIException e) {
Exception ex = e.getException();
if (ex == null) {
throw new SAXException(e.getMessage());
@@ -739,11 +425,8 @@
}
throw new SAXException(ex);
}
-
}
-
-
@Override
public void parse(InputSource inputSource) throws SAXException,
IOException {
@@ -758,7 +441,6 @@
xmlInputSource.setEncoding(inputSource.getEncoding());
parse(xmlInputSource);
}
-
// wrap XNI exceptions as SAX exceptions
catch (XMLParseException e) {
Exception ex = e.getException();
@@ -792,8 +474,7 @@
throw (IOException)ex;
}
throw new SAXException(ex);
- }
- catch (XNIException e) {
+ } catch (XNIException e) {
Exception ex = e.getException();
if (ex == null) {
throw new SAXException(e.getMessage());
@@ -807,8 +488,5 @@
throw new SAXException(ex);
}
}
-
-
}
-
-}
+}
\ No newline at end of file
12 years, 12 months
JBoss Tools SVN: r37569 - in trunk/vpe: tests/org.jboss.tools.vpe.html.test/resources/htmlTest/WebContent/pages and 2 other directories.
by jbosstools-commits@lists.jboss.org
Author: dmaliarevich
Date: 2011-12-28 03:32:27 -0500 (Wed, 28 Dec 2011)
New Revision: 37569
Added:
trunk/vpe/tests/org.jboss.tools.vpe.html.test/resources/htmlTest/WebContent/pages/jbide10126/
trunk/vpe/tests/org.jboss.tools.vpe.html.test/resources/htmlTest/WebContent/pages/jbide10126/complexStyle.html
trunk/vpe/tests/org.jboss.tools.vpe.html.test/resources/htmlTest/WebContent/pages/jbide10126/complexStyle.html.xml
trunk/vpe/tests/org.jboss.tools.vpe.html.test/resources/htmlTest/WebContent/pages/jbide10126/css.css
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe.html/templates/vpe-templates-html.xml
trunk/vpe/tests/org.jboss.tools.vpe.html.test/src/org/jboss/tools/vpe/html/test/HtmlComponentContentTest.java
Log:
https://issues.jboss.org/browse/JBIDE-10126 - Copy all the attributes from the source node to the coresponding visual node for HTML templates.
Modified: trunk/vpe/plugins/org.jboss.tools.vpe.html/templates/vpe-templates-html.xml
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.html/templates/vpe-templates-html.xml 2011-12-28 08:26:36 UTC (rev 37568)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.html/templates/vpe-templates-html.xml 2011-12-28 08:32:27 UTC (rev 37569)
@@ -28,7 +28,7 @@
<vpe:tag name="abbr" case-sensitive="no">
<vpe:template children="yes" modify="yes">
- <vpe:copy attrs="id,style,class,dir" />
+ <vpe:copy />
<vpe:textFormatting>
<vpe:format type="BlockFormat" addChildren="deny"
handler="org.jboss.tools.vpe.editor.toolbar.format.handler.BlockFormatHandler" />
@@ -67,7 +67,7 @@
<vpe:tag name="acronym" case-sensitive="no">
<vpe:template children="yes" modify="yes">
- <vpe:copy attrs="id,style,class,dir" />
+ <vpe:copy />
<vpe:textFormatting use-default-formats="yes">
<vpe:format type="BlockFormat" addChildren="deny"
handler="org.jboss.tools.vpe.editor.toolbar.format.handler.BlockFormatHandler" />
@@ -91,7 +91,7 @@
<vpe:tag name="address" case-sensitive="no">
<vpe:template children="yes" modify="yes">
- <vpe:copy attrs="id,style,class,dir" />
+ <vpe:copy />
<vpe:textFormatting>
<vpe:format type="BlockFormat" addChildren="allow"
handler="org.jboss.tools.vpe.editor.toolbar.format.handler.BlockFormatHandler" />
@@ -166,7 +166,7 @@
<vpe:tag name="b" case-sensitive="no">
<vpe:template children="yes" modify="yes">
- <vpe:copy attrs="id,style,class,dir" />
+ <vpe:copy />
<vpe:dnd>
<vpe:drag start-enable="yes" />
<vpe:drop container="yes">
@@ -195,13 +195,13 @@
<vpe:tag name="basefont" case-sensitive="no">
<vpe:template children="yes" modify="yes">
- <vpe:copy attrs="id,size,color,face" />
+ <vpe:copy />
</vpe:template>
</vpe:tag>
<vpe:tag name="bdo" case-sensitive="no">
<vpe:template children="yes" modify="yes">
- <vpe:copy attrs="id,style,class,dir,lang" />
+ <vpe:copy />
<vpe:textFormatting>
<vpe:format type="BlockFormat" addChildren="deny"
handler="org.jboss.tools.vpe.editor.toolbar.format.handler.BlockFormatHandler" />
@@ -246,7 +246,7 @@
<vpe:tag name="big" case-sensitive="no">
<vpe:template children="yes" modify="yes">
- <vpe:copy attrs="id,style,class,dir" />
+ <vpe:copy />
<vpe:textFormatting use-default-formats="yes">
<vpe:format type="BlockFormat" addChildren="deny"
handler="org.jboss.tools.vpe.editor.toolbar.format.handler.BlockFormatHandler" />
@@ -268,7 +268,7 @@
<vpe:tag name="blockquote" case-sensitive="no">
<vpe:template children="yes" modify="yes">
- <vpe:copy attrs="id,style,class,dir" />
+ <vpe:copy />
<vpe:textFormatting>
<vpe:format type="BlockFormat" addParent="deny" addChildren="allow"
handler="org.jboss.tools.vpe.editor.toolbar.format.handler.BlockFormatHandler" />
@@ -337,7 +337,7 @@
<vpe:tag name="br" case-sensitive="no">
<vpe:template children="no" modify="yes">
- <vpe:copy attrs="id,style,class,clear" />
+ <vpe:copy />
</vpe:template>
</vpe:tag>
@@ -459,13 +459,13 @@
<vpe:tag name="caption" case-sensitive="no">
<vpe:template children="yes" modify="yes">
- <vpe:copy attrs="id,style,class,dir" />
+ <vpe:copy />
</vpe:template>
</vpe:tag>
<vpe:tag name="center" case-sensitive="no">
<vpe:template children="yes" modify="yes">
- <vpe:copy attrs="id,style,class,dir" />
+ <vpe:copy />
<vpe:textFormatting>
<vpe:format type="BlockFormat" addParent="deny" addChildren="allow"
handler="org.jboss.tools.vpe.editor.toolbar.format.handler.BlockFormatHandler" />
@@ -502,7 +502,7 @@
<vpe:tag name="cite" case-sensitive="no">
<vpe:template children="yes" modify="yes">
- <vpe:copy attrs="id,style,class,dir" />
+ <vpe:copy />
<vpe:textFormatting use-default-formats="yes">
<vpe:format type="BlockFormat" addChildren="deny"
handler="org.jboss.tools.vpe.editor.toolbar.format.handler.BlockFormatHandler" />
@@ -524,7 +524,7 @@
<vpe:tag name="code" case-sensitive="no">
<vpe:template children="yes" modify="yes">
- <vpe:copy attrs="id,style,class,dir" />
+ <vpe:copy />
<vpe:textFormatting>
<vpe:format type="BlockFormat" addChildren="deny"
handler="org.jboss.tools.vpe.editor.toolbar.format.handler.BlockFormatHandler" />
@@ -597,7 +597,7 @@
<vpe:tag name="dd" case-sensitive="no">
<vpe:template children="yes" modify="yes">
- <vpe:copy attrs="id,style,class,dir" />
+ <vpe:copy />
<vpe:textFormatting use-default-formats="yes">
<vpe:format type="BlockFormat" addChildren="allow" addParent="deny"
handler="org.jboss.tools.vpe.editor.toolbar.format.handler.BlockFormatHandler" />
@@ -619,7 +619,7 @@
<vpe:tag name="del" case-sensitive="no">
<vpe:template children="yes" modify="yes">
- <vpe:copy attrs="id,style,class,dir" />
+ <vpe:copy />
<vpe:textFormatting>
<vpe:format type="BlockFormat" addChildren="allow"
handler="org.jboss.tools.vpe.editor.toolbar.format.handler.BlockFormatHandler" />
@@ -656,14 +656,14 @@
<vpe:tag name="details" case-sensitive="no">
<vpe:template children="yes" modify="yes">
- <vpe:copy attrs="id,style,class,dir,hidden,open" />
+ <vpe:copy />
<vpe:textFormatting use-default-formats="yes" />
</vpe:template>
</vpe:tag>
<vpe:tag name="dfn" case-sensitive="no">
<vpe:template children="yes" modify="yes">
- <vpe:copy attrs="id,style,class,dir" />
+ <vpe:copy />
<vpe:textFormatting use-default-formats="yes">
<vpe:format type="BlockFormat" addChildren="deny"
handler="org.jboss.tools.vpe.editor.toolbar.format.handler.BlockFormatHandler" />
@@ -685,13 +685,14 @@
<vpe:tag name="dir" case-sensitive="no">
<vpe:template children="yes" modify="no">
- <vpe:copy attrs="id,style,class,dir" />
+ <vpe:copy />
</vpe:template>
</vpe:tag>
<vpe:tag name="div" case-sensitive="no">
<vpe:template children="yes" modify="yes">
- <vpe:copy attrs="id,style,class,align,dir" />
+ <!-- vpe:copy attrs="id,style,class,align,dir,title" /-->
+ <vpe:copy />
<vpe:resize>
<vpe:width width-attr="style.width" />
<vpe:height height-attr="style.height" />
@@ -736,7 +737,7 @@
<vpe:tag name="dl" case-sensitive="no">
<vpe:template children="yes" modify="no">
- <vpe:copy attrs="id,style,class,dir" />
+ <vpe:copy />
<vpe:textFormatting use-default-formats="yes">
<vpe:format type="BlockFormat" addChildren="deny" addParent="deny"/>
<vpe:format type="BoldFormat" addParent="deny" addChildren="deny">
@@ -751,7 +752,7 @@
<vpe:tag name="dt" case-sensitive="no">
<vpe:template children="yes" modify="yes">
- <vpe:copy attrs="id,style,class,dir" />
+ <vpe:copy />
<vpe:textFormatting>
<vpe:format type="BlockFormat" addChildren="deny" addParent="deny"/>
<vpe:format type="BoldFormat" addParent="deny" addChildren="allow" handler="org.jboss.tools.vpe.editor.toolbar.format.handler.BoldFormatHandler" />
@@ -787,7 +788,7 @@
<vpe:tag name="em" case-sensitive="no">
<vpe:template children="yes" modify="yes">
- <vpe:copy attrs="id,style,class,dir" />
+ <vpe:copy />
<vpe:textFormatting use-default-formats="yes">
<vpe:format type="BlockFormat" addChildren="deny"
handler="org.jboss.tools.vpe.editor.toolbar.format.handler.BlockFormatHandler" />
@@ -809,7 +810,7 @@
<vpe:tag name="fieldset" case-sensitive="no">
<vpe:template children="yes" modify="no">
- <vpe:copy attrs="id,style,class,dir" />
+ <vpe:copy />
<vpe:resize>
<vpe:width width-attr="style.width" />
<vpe:height height-attr="style.height" />
@@ -868,7 +869,7 @@
<vpe:tag name="font" case-sensitive="no">
<vpe:template children="yes" modify="yes">
- <vpe:copy attrs="id,style,class,size,color,face,dir" />
+ <vpe:copy />
<vpe:textFormatting use-default-formats="yes">
<vpe:format type="BlockFormat" addChildren="deny"
handler="org.jboss.tools.vpe.editor.toolbar.format.handler.BlockFormatHandler" />
@@ -890,7 +891,7 @@
<vpe:tag name="form" case-sensitive="no">
<vpe:template children="yes" modify="yes">
- <vpe:copy attrs="id,style,class,align,dir" />
+ <vpe:copy />
<form />
<vpe:dnd>
<vpe:drag start-enable="yes" />
@@ -910,7 +911,7 @@
<vpe:tag name="frameset" case-sensitive="no">
<vpe:template children="yes" modify="no" >
- <vpe:copy attrs="border,bordercolor,cols,frameborder,framespacing,rows" />
+ <vpe:copy />
</vpe:template>
</vpe:tag>
@@ -923,7 +924,7 @@
<vpe:tag name="h1" case-sensitive="no">
<vpe:template children="yes" modify="yes">
- <vpe:copy attrs="id,style,class,align,dir" />
+ <vpe:copy />
<vpe:dnd>
<vpe:drag start-enable="yes" />
<vpe:drop container="yes" />
@@ -964,7 +965,7 @@
<vpe:tag name="h2" case-sensitive="no">
<vpe:template children="yes" modify="yes">
- <vpe:copy attrs="id,style,class,align,dir" />
+ <vpe:copy />
<vpe:dnd>
<vpe:drag start-enable="yes" />
<vpe:drop container="yes" />
@@ -990,7 +991,7 @@
<vpe:tag name="h3" case-sensitive="no">
<vpe:template children="yes" modify="yes">
- <vpe:copy attrs="id,style,class,align,dir" />
+ <vpe:copy />
<vpe:dnd>
<vpe:drag start-enable="yes" />
<vpe:drop container="yes" />
@@ -1031,7 +1032,7 @@
<vpe:tag name="h4" case-sensitive="no">
<vpe:template children="yes" modify="yes">
- <vpe:copy attrs="id,style,class,align,dir" />
+ <vpe:copy />
<vpe:dnd>
<vpe:drag start-enable="yes" />
<vpe:drop container="yes" />
@@ -1057,7 +1058,7 @@
<vpe:tag name="h5" case-sensitive="no">
<vpe:template children="yes" modify="yes">
- <vpe:copy attrs="id,style,class,align,dir" />
+ <vpe:copy />
<vpe:dnd>
<vpe:drag start-enable="yes" />
<vpe:drop container="yes" />
@@ -1098,7 +1099,7 @@
<vpe:tag name="h6" case-sensitive="no">
<vpe:template children="yes" modify="yes">
- <vpe:copy attrs="id,style,class,align,dir" />
+ <vpe:copy />
<vpe:dnd>
<vpe:drag start-enable="yes" />
<vpe:drop container="yes" />
@@ -1147,7 +1148,7 @@
<vpe:tag name="hr" case-sensitive="no">
<vpe:template children="no" modify="no">
- <vpe:copy attrs="id,style,class,align,size,width,color,dir" />
+ <vpe:copy />
</vpe:template>
</vpe:tag>
@@ -1168,7 +1169,7 @@
<vpe:tag name="i" case-sensitive="no">
<vpe:template children="yes" modify="yes">
- <vpe:copy attrs="id,style,class,dir" />
+ <vpe:copy />
<vpe:dnd>
<vpe:drag start-enable="yes" />
<vpe:drop container="yes" />
@@ -1245,7 +1246,7 @@
</vpe:if>
<vpe:if test="(@type='submit')|(@type='button')">
<vpe:template children="yes" modify="yes">
- <vpe:copy attrs="id,type,value,style,class,dir,disabled,height,width,placeholder,name" />
+ <vpe:copy />
<!--span class="__button__tag" style="{@style}">
<nobr><vpe:value expr="{@value}"/></nobr>
</span-->
@@ -1278,7 +1279,7 @@
</vpe:if>
<vpe:if test="not(@value='')">
<vpe:template children="yes" modify="yes">
- <vpe:copy attrs="id,type,checked,value,class,style,disabled,height,width,placeholder" />
+ <vpe:copy />
<!--span class="__button__tag" style="{@style}">
<nobr><vpe:value expr="{@value}"/></nobr>
</span-->
@@ -1315,7 +1316,7 @@
</vpe:template>
</vpe:if>
<vpe:template children="no" modify="no">
- <vpe:copy attrs="id,type,style,class,value,size,dir,disabled,height,width,placeholder,name" />
+ <vpe:copy />
<!--span class="__input__tag" style="{@style}">
<nobr><vpe:value expr="{@value}"/></nobr>
</span-->
@@ -1333,7 +1334,7 @@
<vpe:tag name="ins" case-sensitive="no">
<vpe:template children="yes" modify="no">
- <vpe:copy attrs="id,style,class,dir" />
+ <vpe:copy />
<vpe:textFormatting use-default-formats="yes">
<vpe:format type="BlockFormat" addChildren="allow"
handler="org.jboss.tools.vpe.editor.toolbar.format.handler.BlockFormatHandler" />
@@ -1354,7 +1355,7 @@
<vpe:tag name="isindex" case-sensitive="no">
<vpe:template children="yes" modify="no">
- <vpe:copy attrs="id,style,class,prompt,dir" />
+ <vpe:copy />
</vpe:template>
</vpe:tag>
@@ -1369,7 +1370,7 @@
<vpe:tag name="kbd" case-sensitive="no">
<vpe:template children="yes" modify="yes">
- <vpe:copy attrs="id,style,class,dir" />
+ <vpe:copy />
<vpe:textFormatting>
<vpe:format type="BlockFormat" addChildren="allow"
handler="org.jboss.tools.vpe.editor.toolbar.format.handler.BlockFormatHandler" />
@@ -1406,7 +1407,7 @@
<vpe:tag name="label" case-sensitive="no">
<vpe:template children="yes" modify="yes">
- <vpe:copy attrs="id,style,class,for,dir" />
+ <vpe:copy />
<vpe:dnd>
<vpe:drag start-enable="yes" />
<vpe:drop container="yes">
@@ -1479,13 +1480,13 @@
<vpe:tag name="legend" case-sensitive="no">
<vpe:template children="yes" modify="yes">
- <vpe:copy attrs="id,style,class,align,dir" />
+ <vpe:copy />
</vpe:template>
</vpe:tag>
<vpe:tag name="li" case-sensitive="no">
<vpe:template children="yes" modify="yes">
- <vpe:copy attrs="id,style,class,type,value,dir" />
+ <vpe:copy />
<vpe:textFormatting>
<vpe:format type="BlockFormat" addChildren="allow" addParent="deny"
handler="org.jboss.tools.vpe.editor.toolbar.format.handler.BlockFormatHandler" />
@@ -1528,13 +1529,13 @@
<vpe:tag name="map" case-sensitive="no">
<vpe:template children="yes" modify="no">
- <vpe:copy attrs="id,style,class,name,dir" />
+ <vpe:copy />
</vpe:template>
</vpe:tag>
<vpe:tag name="mark" case-sensitive="no">
<vpe:template children="yes" modify="yes">
- <vpe:copy attrs="id,style,class,dir,hidden" />
+ <vpe:copy />
</vpe:template>
</vpe:tag>
@@ -1547,7 +1548,7 @@
<vpe:tag name="menu" case-sensitive="no">
<vpe:template children="yes" modify="no">
- <vpe:copy attrs="id,style,class,dir" />
+ <vpe:copy />
<vpe:textFormatting use-default-formats="yes">
</vpe:textFormatting>
</vpe:template>
@@ -1559,13 +1560,13 @@
<vpe:tag name="meter" case-sensitive="no">
<vpe:template children="yes" modify="yes">
- <vpe:copy attrs="id,style,class,dir,hidden,form,high,low,max,min,optimum,value" />
+ <vpe:copy />
</vpe:template>
</vpe:tag>
<vpe:tag name="nav" case-sensitive="no">
<vpe:template children="yes" modify="yes">
- <vpe:copy attrs="id,style,class,dir,hidden" />
+ <vpe:copy />
</vpe:template>
</vpe:tag>
@@ -1611,7 +1612,7 @@
<vpe:tag name="ol" case-sensitive="no">
<vpe:template children="yes" modify="no">
- <vpe:copy attrs="id,style,class,type,start,dir,reversed" />
+ <vpe:copy />
<vpe:dnd>
<vpe:drop container="yes">
<vpe:container-child tag-name="del" />
@@ -1626,7 +1627,7 @@
<vpe:tag name="optgroup" case-sensitive="no">
<vpe:template children="yes" modify="no">
- <vpe:copy attrs="id,style,class,label,dir,disabled"/>
+ <vpe:copy />
<vpe:dnd>
<vpe:drop container="yes">
<vpe:container-child tag-name="del" />
@@ -1639,19 +1640,19 @@
<vpe:tag name="option" case-sensitive="no">
<vpe:template children="yes" modify="yes">
- <vpe:copy attrs="id,style,class,value,label,dir,disabled,selected" />
+ <vpe:copy />
</vpe:template>
</vpe:tag>
<vpe:tag name="output" case-sensitive="no">
<vpe:template children="yes" modify="yes">
- <vpe:copy attrs="id,style,class,dir,hidden,for,form,name" />
+ <vpe:copy />
</vpe:template>
</vpe:tag>
<vpe:tag name="p" case-sensitive="no">
<vpe:template children="yes" modify="yes">
- <vpe:copy attrs="id,style,class,align,dir" />
+ <vpe:copy />
<vpe:dnd>
<vpe:drag start-enable="yes" />
<vpe:drop container="yes" />
@@ -1683,7 +1684,7 @@
<vpe:tag name="pre" case-sensitive="no">
<vpe:template children="yes" modify="yes">
- <vpe:copy attrs="id,style,class,width,dir" />
+ <vpe:copy />
<vpe:textFormatting>
<vpe:format type="BlockFormat" addChildren="deny" addParent = "deny"
handler="org.jboss.tools.vpe.editor.toolbar.format.handler.BlockFormatHandler" />
@@ -1720,13 +1721,13 @@
<vpe:tag name="progress" case-sensitive="no">
<vpe:template children="yes" modify="yes">
- <vpe:copy attrs="id,style,class,dir,hidden,max,value" />
+ <vpe:copy />
</vpe:template>
</vpe:tag>
<vpe:tag name="q" case-sensitive="no">
<vpe:template children="yes" modify="yes">
- <vpe:copy attrs="id,style,class,dir" />
+ <vpe:copy />
<vpe:textFormatting use-default-formats="yes">
<vpe:format type="BlockFormat" addChildren="allow"
handler="org.jboss.tools.vpe.editor.toolbar.format.handler.BlockFormatHandler" />
@@ -1748,25 +1749,25 @@
<vpe:tag name="rp" case-sensitive="no">
<vpe:template children="yes" modify="yes">
- <vpe:copy attrs="id,style,class,dir,hidden" />
+ <vpe:copy />
</vpe:template>
</vpe:tag>
<vpe:tag name="rt" case-sensitive="no">
<vpe:template children="yes" modify="yes">
- <vpe:copy attrs="id,style,class,dir,hidden" />
+ <vpe:copy />
</vpe:template>
</vpe:tag>
<vpe:tag name="ruby" case-sensitive="no">
<vpe:template children="yes" modify="yes">
- <vpe:copy attrs="id,style,class,dir,hidden" />
+ <vpe:copy />
</vpe:template>
</vpe:tag>
<vpe:tag name="s" case-sensitive="no">
<vpe:template children="yes" modify="yes">
- <vpe:copy attrs="id,style,class,dir" />
+ <vpe:copy />
<vpe:textFormatting>
<vpe:format type="BlockFormat" addChildren="allow"
handler="org.jboss.tools.vpe.editor.toolbar.format.handler.BlockFormatHandler" />
@@ -1803,7 +1804,7 @@
<vpe:tag name="samp" case-sensitive="no">
<vpe:template children="yes" modify="yes">
- <vpe:copy attrs="id,style,class,dir" />
+ <vpe:copy />
<vpe:textFormatting use-default-formats="yes">
<vpe:format type="BlockFormat" addChildren="allow"
handler="org.jboss.tools.vpe.editor.toolbar.format.handler.BlockFormatHandler" />
@@ -1829,13 +1830,13 @@
<vpe:tag name="section" case-sensitive="no">
<vpe:template children="yes" modify="yes">
- <vpe:copy attrs="id,style,class,dir,hidden" />
+ <vpe:copy />
</vpe:template>
</vpe:tag>
<vpe:tag name="select" case-sensitive="no">
<vpe:template children="yes" modify="yes">
- <vpe:copy attrs="id,style,class,size,dir,disabled,multiple" />
+ <vpe:copy />
<vpe:resize>
<vpe:width width-attr="style.width" />
<vpe:height height-attr="style.height" />
@@ -1883,7 +1884,7 @@
<vpe:tag name="small" case-sensitive="no">
<vpe:template children="yes" modify="yes">
- <vpe:copy attrs="id,style,class,dir" />
+ <vpe:copy />
<vpe:textFormatting use-default-formats="yes">
<vpe:format type="BlockFormat" addChildren="allow" handler="org.jboss.tools.vpe.editor.toolbar.format.handler.BlockFormatHandler" />
<vpe:format type="BoldFormat">
@@ -1903,13 +1904,13 @@
<vpe:tag name="source" case-sensitive="no">
<vpe:template children="yes" modify="yes">
- <vpe:copy attrs="id,style,class,dir,hidden,media,src,type" />
+ <vpe:copy />
</vpe:template>
</vpe:tag>
<vpe:tag name="span" case-sensitive="no">
<vpe:template children="yes" modify="yes">
- <vpe:copy attrs="id,style,class,dir" />
+ <vpe:copy />
<vpe:dnd>
<vpe:drag start-enable="yes" />
<vpe:drop container="yes" />
@@ -1933,7 +1934,7 @@
<vpe:tag name="strike" case-sensitive="no">
<vpe:template children="yes" modify="yes">
- <vpe:copy attrs="id,style,class,dir" />
+ <vpe:copy />
<vpe:textFormatting use-default-formats="yes">
<vpe:format type="BlockFormat" addChildren="allow" handler="org.jboss.tools.vpe.editor.toolbar.format.handler.BlockFormatHandler" />
<vpe:format type="BoldFormat">
@@ -1953,7 +1954,7 @@
<vpe:tag name="strong" case-sensitive="no">
<vpe:template children="yes" modify="yes">
- <vpe:copy attrs="id,style,class,dir" />
+ <vpe:copy />
<vpe:textFormatting use-default-formats="yes">
<vpe:format type="BlockFormat" addChildren="deny" handler="org.jboss.tools.vpe.editor.toolbar.format.handler.BlockFormatHandler" />
<vpe:format type="BoldFormat" setDefault="true">
@@ -1979,7 +1980,7 @@
<vpe:tag name="sub" case-sensitive="no">
<vpe:template children="yes" modify="yes">
- <vpe:copy attrs="id,style,class,dir" />
+ <vpe:copy />
<vpe:textFormatting>
<vpe:format type="BlockFormat" addChildren="allow" handler="org.jboss.tools.vpe.editor.toolbar.format.handler.BlockFormatHandler" />
<vpe:format type="BoldFormat">
@@ -2014,13 +2015,13 @@
<vpe:tag name="summary" case-sensitive="no">
<vpe:template children="yes" modify="yes">
- <vpe:copy attrs="id,style,class,dir,hidden" />
+ <vpe:copy />
</vpe:template>
</vpe:tag>
<vpe:tag name="sup" case-sensitive="no">
<vpe:template children="yes" modify="yes">
- <vpe:copy attrs="id,style,class,dir" />
+ <vpe:copy />
<vpe:textFormatting use-default-formats="yes">
<vpe:format type="BlockFormat" addChildren="allow" handler="org.jboss.tools.vpe.editor.toolbar.format.handler.BlockFormatHandler" />
<vpe:format type="BoldFormat">
@@ -2066,7 +2067,7 @@
<vpe:tag name="tbody" case-sensitive="no">
<vpe:template children="yes" modify="yes">
- <vpe:copy attrs="id,style,class,align,char,charoff,valign,dir,bgcolor" />
+ <vpe:copy />
<vpe:dnd>
<vpe:drop container="yes">
<vpe:container-child tag-name="del" />
@@ -2184,7 +2185,7 @@
<vpe:tag name="tfoot" case-sensitive="no">
<vpe:template children="yes" modify="no">
- <vpe:copy attrs="id,style,class,align,char,charoff,valign,dir,bgcolor" />
+ <vpe:copy />
<vpe:textFormatting use-default-formats="yes">
</vpe:textFormatting>
</vpe:template>
@@ -2228,7 +2229,7 @@
<vpe:tag name="thead" case-sensitive="no">
<vpe:template children="yes" modify="no">
- <vpe:copy attrs="id,style,class,align,char,charoff,valign,dir,bgcolor" />
+ <vpe:copy />
<vpe:dnd>
<vpe:drop container="yes">
<vpe:container-child tag-name="del" />
@@ -2247,7 +2248,7 @@
<vpe:tag name="time" case-sensitive="no">
<vpe:template children="yes" modify="yes">
- <vpe:copy attrs="id,style,class,dir,hidden,datetime,pubdate" />
+ <vpe:copy />
</vpe:template>
</vpe:tag>
@@ -2277,7 +2278,7 @@
<vpe:tag name="tt" case-sensitive="no">
<vpe:template children="yes" modify="yes">
- <vpe:copy attrs="id,style,class,dir" />
+ <vpe:copy />
<vpe:textFormatting use-default-formats="yes">
<vpe:format type="BlockFormat" addChildren="allow" handler="org.jboss.tools.vpe.editor.toolbar.format.handler.BlockFormatHandler" />
<vpe:format type="UnderlineFormat" addChildren="allow" handler="org.jboss.tools.vpe.editor.toolbar.format.handler.UnderlineFormatHandler" />
@@ -2298,7 +2299,7 @@
<vpe:tag name="u" case-sensitive="no">
<vpe:template children="yes" modify="yes">
- <vpe:copy attrs="id,style,class,dir" />
+ <vpe:copy />
<vpe:textFormatting>
<vpe:format type="BlockFormat" addChildren="allow"
handler="org.jboss.tools.vpe.editor.toolbar.format.handler.BlockFormatHandler" />
@@ -2337,7 +2338,7 @@
<vpe:tag name="ul" case-sensitive="no">
<vpe:template children="yes" modify="yes">
- <vpe:copy attrs="id,style,class,type,dir" />
+ <vpe:copy />
<vpe:dnd>
<vpe:drop container="yes">
<vpe:container-child tag-name="del" />
@@ -2352,7 +2353,7 @@
<vpe:tag name="var" case-sensitive="no">
<vpe:template children="yes" modify="no">
- <vpe:copy attrs="id,style,class,dir" />
+ <vpe:copy />
<vpe:textFormatting use-default-formats="yes">
<vpe:format type="BlockFormat" addChildren="allow"
handler="org.jboss.tools.vpe.editor.toolbar.format.handler.BlockFormatHandler" />
@@ -2374,7 +2375,7 @@
<vpe:tag name="video" case-sensitive="no">
<vpe:template children="yes" modify="yes">
- <vpe:copy attrs="id,style,class,dir,hidden,audio,autoplay,controls,height,loop,poster,preload,src,width" />
+ <vpe:copy />
</vpe:template>
</vpe:tag>
Added: trunk/vpe/tests/org.jboss.tools.vpe.html.test/resources/htmlTest/WebContent/pages/jbide10126/complexStyle.html
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.html.test/resources/htmlTest/WebContent/pages/jbide10126/complexStyle.html (rev 0)
+++ trunk/vpe/tests/org.jboss.tools.vpe.html.test/resources/htmlTest/WebContent/pages/jbide10126/complexStyle.html 2011-12-28 08:32:27 UTC (rev 37569)
@@ -0,0 +1,37 @@
+<html>
+<head>
+ <title>Hello!</title>
+ <link href="css.css" rel="stylesheet" type="text/css"/>
+</head>
+<body id="id1">
+<p class="styleA">
+ .styleA {color: FF0000}
+ </p>
+ <p class="styleA">
+ .styleA {color: FF0000}
+ <br/>
+ <b class="styleB">.styleA .styleB {color: FF8000}</b>
+ </p>
+ <div class="styleA">
+ div.styleA {color: FF0080}
+ </div>
+ <div myTitle="x" class="styleA">
+ div[myTitle="x"].styleA {color: 0000FF}
+ </div>
+ <p>
+ <input type="button" class="styleA" value="p input.styleA {color: CCAA00}"/>
+ </p>
+ <div>
+ <p>
+ <input type="button" class="styleA" value="div p input.styleA {color: CC00FF}"/>
+ </p>
+ </div>
+ <div myTitle="y">
+ <div>
+ <p>
+ <input type="button" class="styleA" value="[myTitle='y'] div p input.styleA {color: 00CCFF}"/>
+ </p>
+ </div>
+ </div>
+</body>
+</html>
Added: trunk/vpe/tests/org.jboss.tools.vpe.html.test/resources/htmlTest/WebContent/pages/jbide10126/complexStyle.html.xml
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.html.test/resources/htmlTest/WebContent/pages/jbide10126/complexStyle.html.xml (rev 0)
+++ trunk/vpe/tests/org.jboss.tools.vpe.html.test/resources/htmlTest/WebContent/pages/jbide10126/complexStyle.html.xml 2011-12-28 08:32:27 UTC (rev 37569)
@@ -0,0 +1,50 @@
+<tests>
+ <test id="id1">
+ <DIV ID="id1">
+ <P CLASS="styleA" STYLE="-moz-user-modify: read-write;">
+ <SPAN CLASS="vpe-text">
+ .styleA {color: FF0000}
+ </SPAN>
+ </P>
+ <P CLASS="styleA" STYLE="-moz-user-modify: read-write;">
+ <SPAN CLASS="vpe-text">
+ .styleA {color: FF0000}
+ </SPAN>
+ <BR STYLE="-moz-user-modify: read-write;" />
+ <B CLASS="styleB" STYLE="-moz-user-modify: read-write;">
+ <SPAN CLASS="vpe-text">
+ .styleA .styleB {color: FF8000}
+ </SPAN>
+ </B>
+ </P>
+ <DIV CLASS="styleA" STYLE="-moz-user-modify: read-write;">
+ <SPAN CLASS="vpe-text">
+ div.styleA {color: FF0080}
+ </SPAN>
+ </DIV>
+ <DIV MYTITLE="x" CLASS="styleA" STYLE="-moz-user-modify: read-write;">
+ <SPAN CLASS="vpe-text">
+ div[myTitle="x"].styleA {color: 0000FF}
+ </SPAN>
+ </DIV>
+ <P STYLE="-moz-user-modify: read-write;">
+ <INPUT TYPE="button" CLASS="styleA" VALUE="p input.styleA {color: CCAA00}"
+ STYLE="-moz-user-modify: read-write;" />
+ </P>
+ <DIV STYLE="-moz-user-modify: read-write;">
+ <P STYLE="-moz-user-modify: read-write;">
+ <INPUT TYPE="button" CLASS="styleA"
+ VALUE="div p input.styleA {color: CC00FF}" STYLE="-moz-user-modify: read-write;" />
+ </P>
+ </DIV>
+ <DIV MYTITLE="y" STYLE="-moz-user-modify: read-write;">
+ <DIV STYLE="-moz-user-modify: read-write;">
+ <P STYLE="-moz-user-modify: read-write;">
+ <INPUT TYPE="button" CLASS="styleA"
+ VALUE="[myTitle='y'] div p input.styleA {color: 00CCFF}" STYLE="-moz-user-modify: read-write;" />
+ </P>
+ </DIV>
+ </DIV>
+ </DIV>
+ </test>
+</tests>
\ No newline at end of file
Added: trunk/vpe/tests/org.jboss.tools.vpe.html.test/resources/htmlTest/WebContent/pages/jbide10126/css.css
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.html.test/resources/htmlTest/WebContent/pages/jbide10126/css.css (rev 0)
+++ trunk/vpe/tests/org.jboss.tools.vpe.html.test/resources/htmlTest/WebContent/pages/jbide10126/css.css 2011-12-28 08:32:27 UTC (rev 37569)
@@ -0,0 +1,7 @@
+ .styleA {color: #FF0000}
+ .styleA .styleB {color: #FF8000}
+ div.styleA {color: #FF0080}
+ div[myTitle="x"].styleA {color: #0000FF}
+ p input.styleA {color: #CCAA00}
+ div p input.styleA {color: #CC00FF}
+ [myTitle="y"] p input.styleA {color: #00CCFF}
\ No newline at end of file
Modified: trunk/vpe/tests/org.jboss.tools.vpe.html.test/src/org/jboss/tools/vpe/html/test/HtmlComponentContentTest.java
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.html.test/src/org/jboss/tools/vpe/html/test/HtmlComponentContentTest.java 2011-12-28 08:26:36 UTC (rev 37568)
+++ trunk/vpe/tests/org.jboss.tools.vpe.html.test/src/org/jboss/tools/vpe/html/test/HtmlComponentContentTest.java 2011-12-28 08:32:27 UTC (rev 37569)
@@ -489,6 +489,10 @@
performStyleTest("jbide9975( 1 )/CSSImportConstruction.html"); //$NON-NLS-1$
}
+ public void testComplexStyle() throws Throwable {
+ performContentTest("jbide10126/complexStyle.html"); //$NON-NLS-1$
+ }
+
protected String getTestProjectName() {
return HtmlAllTests.IMPORT_PROJECT_NAME;
}
12 years, 12 months
JBoss Tools SVN: r37568 - trunk/vpe/tests/org.jboss.tools.vpe.base.test/src/org/jboss/tools/vpe/base/test.
by jbosstools-commits@lists.jboss.org
Author: dmaliarevich
Date: 2011-12-28 03:26:36 -0500 (Wed, 28 Dec 2011)
New Revision: 37568
Modified:
trunk/vpe/tests/org.jboss.tools.vpe.base.test/src/org/jboss/tools/vpe/base/test/ComponentContentTest.java
Log:
https://issues.jboss.org/browse/JBIDE-10126 - ComponentContentTest was updated to show detailed message.
Modified: trunk/vpe/tests/org.jboss.tools.vpe.base.test/src/org/jboss/tools/vpe/base/test/ComponentContentTest.java
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.base.test/src/org/jboss/tools/vpe/base/test/ComponentContentTest.java 2011-12-28 00:45:26 UTC (rev 37567)
+++ trunk/vpe/tests/org.jboss.tools.vpe.base.test/src/org/jboss/tools/vpe/base/test/ComponentContentTest.java 2011-12-28 08:26:36 UTC (rev 37568)
@@ -119,10 +119,12 @@
private void compareStylesJob(VpeController controller, Document xmlTestDocument,
String elementId, String xmlTestId) throws DOMComparisonException {
nsIDOMElement vpeElement = findElementById(controller, elementId);
- assertNotNull("Cannot find element with id = "+elementId, vpeElement); //$NON-NLS-1$
+ assertNotNull("Cannot find element with id = [" + elementId //$NON-NLS-1$
+ + "] in VPE page", vpeElement); //$NON-NLS-1$
Element xmlModelElement = TestDomUtil.getFirstChildElement(
TestDomUtil.getElemenById(xmlTestDocument, xmlTestId));
- assertNotNull(xmlModelElement);
+ assertNotNull("Cannot find element with id = [" + xmlTestId //$NON-NLS-1$
+ + "] in XML file", xmlModelElement); //$NON-NLS-1$
TestDomUtil.compareComputedStyle(vpeElement, xmlModelElement);
}
@@ -159,7 +161,8 @@
throws DOMComparisonException {
// get element by id
nsIDOMElement vpeElement = findElementById(controller, elementId);
- assertNotNull("Cannot find element with id="+elementId,vpeElement); //$NON-NLS-1$
+ assertNotNull("Cannot find element with id = [" + elementId //$NON-NLS-1$
+ + "] in VPE page", vpeElement); //$NON-NLS-1$
// DOMTreeDumper dumper = new DOMTreeDumper(
// VpeDebug.VISUAL_DUMP_PRINT_HASH);
@@ -170,7 +173,8 @@
Element xmlModelElement = TestDomUtil.getFirstChildElement(TestDomUtil
.getElemenById(xmlTestDocument, xmlTestId));
- assertNotNull(xmlModelElement);
+ assertNotNull("Cannot find element with id = [" + xmlTestId //$NON-NLS-1$
+ + "] in XML file", xmlModelElement); //$NON-NLS-1$
TestDomUtil.compareNodes(vpeElement, xmlModelElement);
}
12 years, 12 months
JBoss Tools SVN: r37567 - trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/refactoring.
by jbosstools-commits@lists.jboss.org
Author: dazarov
Date: 2011-12-27 19:45:26 -0500 (Tue, 27 Dec 2011)
New Revision: 37567
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/refactoring/AddQualifiersToBeanProcessor.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/refactoring/CDIFileChange.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/refactoring/CDIRefactoringProcessor.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/refactoring/CDIRenameProcessor.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/refactoring/DeleteAllDisposerAnnotationsProcessor.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/refactoring/DeleteAllInjectedConstructorsProcessor.java
Log:
Java Seam and CDI quick fixes: after quick fix, editor is scrolled to the beginning. If Undo/Redo commands are used, the entire file content gets selected https://issues.jboss.org/browse/JBIDE-10536
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/refactoring/AddQualifiersToBeanProcessor.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/refactoring/AddQualifiersToBeanProcessor.java 2011-12-28 00:05:31 UTC (rev 37566)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/refactoring/AddQualifiersToBeanProcessor.java 2011-12-28 00:45:26 UTC (rev 37567)
@@ -21,7 +21,6 @@
import org.eclipse.ltk.core.refactoring.Change;
import org.eclipse.ltk.core.refactoring.CompositeChange;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-import org.eclipse.ltk.core.refactoring.TextFileChange;
import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext;
import org.eclipse.text.edits.MultiTextEdit;
import org.jboss.tools.cdi.core.CDICoreMessages;
@@ -87,11 +86,7 @@
ICompilationUnit compilationUnit = original.getWorkingCopy(pm);
- TextFileChange fileChange = new CDIFileChange(file.getName(), file);
- if(CDIFileChange.getAndReloadEditor(file) != null)
- fileChange.setSaveMode(TextFileChange.LEAVE_DIRTY);
- else
- fileChange.setSaveMode(TextFileChange.FORCE_SAVE);
+ CDIFileChange fileChange = new CDIFileChange(file);
MultiTextEdit edit = new MultiTextEdit();
@@ -107,11 +102,7 @@
fileChange.setEdit(edit);
rootChange.add(fileChange);
}
- fileChange = new CDIFileChange(file2.getName(), file2);
- if(CDIFileChange.getAndReloadEditor(file2) != null)
- fileChange.setSaveMode(TextFileChange.LEAVE_DIRTY);
- else
- fileChange.setSaveMode(TextFileChange.FORCE_SAVE);
+ fileChange = new CDIFileChange(file2);
edit = new MultiTextEdit();
}else{
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/refactoring/CDIFileChange.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/refactoring/CDIFileChange.java 2011-12-28 00:05:31 UTC (rev 37566)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/refactoring/CDIFileChange.java 2011-12-28 00:45:26 UTC (rev 37567)
@@ -13,60 +13,85 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility;
+import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.jface.text.IDocument;
+import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.MultiStateTextFileChange;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.eclipse.ltk.core.refactoring.TextChange;
import org.eclipse.ltk.core.refactoring.TextFileChange;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PartInitException;
-import org.jboss.tools.cdi.core.CDICorePlugin;
+import org.eclipse.text.edits.TextEdit;
+import org.eclipse.text.edits.UndoEdit;
-public class CDIFileChange extends TextFileChange{
+public class CDIFileChange extends MultiStateTextFileChange{
+ private IFile file;
+ private CDITextChange rootChange = null;
- public CDIFileChange(String name, IFile file) {
- super(name, file);
+ public CDIFileChange(IFile file) {
+ super(file.getName(), file);
+ this.file = file;
+ setSaveMode(TextFileChange.FORCE_SAVE);
}
-
- @Override
- protected void releaseDocument(final IDocument document, IProgressMonitor pm)
- throws CoreException {
- super.releaseDocument(document, pm);
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- IEditorPart editor = getEditor(getFile());
- if(editor != null){
- editor.doSave(new NullProgressMonitor());
- }
- }
-
- });
+
+ public IFile getFile(){
+ return file;
}
- public static IEditorPart getAndReloadEditor(IFile file){
- IEditorInput input = EditorUtility.getEditorInput(file);
-
- if(EditorUtility.isOpenInEditor(input) != null){
- try {
- return EditorUtility.openInEditor(input, false);
- } catch (PartInitException e) {
- CDICorePlugin.getDefault().logError(e);
- }
- }
- return null;
+ public void setEdit(TextEdit edit) {
+ rootChange = new CDITextChange();
+ rootChange.setEdit(edit);
+ super.addChange(rootChange);
}
- public static IEditorPart getEditor(IFile file){
- IEditorInput input = EditorUtility.getEditorInput(file);
+ public TextEdit getEdit(){
+ return rootChange.getEdit();
+ }
+
+ public void addEdit(TextEdit edit){
+ rootChange.addEdit(edit);
+ }
+
+ class CDITextChange extends TextChange{
+
+ protected CDITextChange() {
+ super("");
+ }
+
+ @Override
+ protected IDocument acquireDocument(IProgressMonitor pm)
+ throws CoreException {
+ return null;
+ }
+
+ @Override
+ protected void commit(IDocument document, IProgressMonitor pm)
+ throws CoreException {
+ }
+
+ @Override
+ protected void releaseDocument(IDocument document, IProgressMonitor pm)
+ throws CoreException {
+ }
+
+ @Override
+ protected Change createUndoChange(UndoEdit edit) {
+ return null;
+ }
+
+ @Override
+ public void initializeValidationData(IProgressMonitor pm) {
+ }
+
+ @Override
+ public RefactoringStatus isValid(IProgressMonitor pm)
+ throws CoreException, OperationCanceledException {
+ return null;
+ }
+
+ @Override
+ public Object getModifiedElement() {
+ return null;
+ }
- IWorkbenchWindow[] windows = CDICorePlugin.getDefault().getWorkbench().getWorkbenchWindows();
- for(IWorkbenchWindow window : windows){
- IEditorPart editor = window.getActivePage().findEditor(input);
- if(editor != null)
- return editor;
- }
- return null;
}
}
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/refactoring/CDIRefactoringProcessor.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/refactoring/CDIRefactoringProcessor.java 2011-12-28 00:05:31 UTC (rev 37566)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/refactoring/CDIRefactoringProcessor.java 2011-12-28 00:45:26 UTC (rev 37567)
@@ -18,7 +18,6 @@
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.ltk.core.refactoring.CompositeChange;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-import org.eclipse.ltk.core.refactoring.TextFileChange;
import org.eclipse.text.edits.MultiTextEdit;
import org.jboss.tools.cdi.core.CDICoreMessages;
import org.jboss.tools.cdi.core.CDICoreNature;
@@ -30,7 +29,7 @@
public abstract class CDIRefactoringProcessor extends AbstractCDIProcessor {
protected IFile file;
- protected TextFileChange change;
+ protected CDIFileChange change;
protected IClassBean bean;
public CDIRefactoringProcessor(IFile file, String label){
@@ -44,17 +43,12 @@
protected void createRootChange(){
rootChange = new CompositeChange(getLabel());
- change = new CDIFileChange(file.getName(), file);
+ change = new CDIFileChange(file);
- if(CDIFileChange.getAndReloadEditor(file) != null)
- change.setSaveMode(TextFileChange.LEAVE_DIRTY);
- else
- change.setSaveMode(TextFileChange.FORCE_SAVE);
-
MultiTextEdit root = new MultiTextEdit();
change.setEdit(root);
rootChange.add(change);
- rootChange.markAsSynthetic();
+ //rootChange.markAsSynthetic();
}
private IClassBean findClassBean(){
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/refactoring/CDIRenameProcessor.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/refactoring/CDIRenameProcessor.java 2011-12-28 00:05:31 UTC (rev 37566)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/refactoring/CDIRenameProcessor.java 2011-12-28 00:45:26 UTC (rev 37567)
@@ -20,7 +20,6 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-import org.eclipse.ltk.core.refactoring.TextFileChange;
import org.eclipse.osgi.util.NLS;
import org.eclipse.text.edits.MultiTextEdit;
import org.eclipse.text.edits.ReplaceEdit;
@@ -36,7 +35,7 @@
* @author Daniel Azarov
*/
public abstract class CDIRenameProcessor extends AbstractCDIProcessor {
- protected TextFileChange lastChange;
+ protected CDIFileChange lastChange;
protected IFile declarationFile=null;
private String newName;
@@ -85,24 +84,19 @@
}
// lets collect all changes for the same files in one MultiTextEdit
- protected TextFileChange getChange(IFile file){
+ protected CDIFileChange getChange(IFile file){
if(lastChange != null && lastChange.getFile().equals(file))
return lastChange;
for(int i=0; i < rootChange.getChildren().length; i++){
- TextFileChange change = (TextFileChange)rootChange.getChildren()[i];
+ CDIFileChange change = (CDIFileChange)rootChange.getChildren()[i];
if(change.getFile().equals(file)){
lastChange = change;
return lastChange;
}
}
- lastChange = new CDIFileChange(file.getName(), file);
+ lastChange = new CDIFileChange(file);
- if(CDIFileChange.getAndReloadEditor(file) != null)
- lastChange.setSaveMode(TextFileChange.LEAVE_DIRTY);
- else
- lastChange.setSaveMode(TextFileChange.FORCE_SAVE);
-
MultiTextEdit root = new MultiTextEdit();
lastChange.setEdit(root);
rootChange.add(lastChange);
@@ -121,7 +115,7 @@
protected void change(IFile file, int offset, int length, String text){
String key = file.getFullPath().toString()+" "+offset;
if(!keys.contains(key)){
- TextFileChange change = getChange(file);
+ CDIFileChange change = getChange(file);
TextEdit edit = new ReplaceEdit(offset, length, text);
change.addEdit(edit);
keys.add(key);
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/refactoring/DeleteAllDisposerAnnotationsProcessor.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/refactoring/DeleteAllDisposerAnnotationsProcessor.java 2011-12-28 00:05:31 UTC (rev 37566)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/refactoring/DeleteAllDisposerAnnotationsProcessor.java 2011-12-28 00:45:26 UTC (rev 37567)
@@ -16,19 +16,19 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IMethod;
+import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext;
-import org.eclipse.text.edits.ReplaceEdit;
-import org.eclipse.text.edits.TextEdit;
+import org.eclipse.text.edits.MultiTextEdit;
import org.jboss.tools.cdi.core.CDIConstants;
-import org.jboss.tools.cdi.core.CDIUtil;
import org.jboss.tools.cdi.core.IBeanMethod;
import org.jboss.tools.cdi.core.IClassBean;
import org.jboss.tools.cdi.core.IProducer;
import org.jboss.tools.cdi.core.IProducerMethod;
-import org.jboss.tools.common.text.ITextSourceReference;
public class DeleteAllDisposerAnnotationsProcessor extends CDIRefactoringProcessor {
private IMethod method;
@@ -38,7 +38,7 @@
this.method = method;
}
- private void changeDisposers(IClassBean bean) {
+ private void changeDisposers(IClassBean bean) throws JavaModelException {
Set<IBeanMethod> disposers = bean.getDisposers();
if (disposers.isEmpty()) {
return;
@@ -51,15 +51,19 @@
IProducerMethod producerMethod = (IProducerMethod) producer;
Set<IBeanMethod> disposerMethods = producer.getCDIProject().resolveDisposers(producerMethod);
boundDisposers.addAll(disposerMethods);
+ ICompilationUnit original = producerMethod.getMethod().getCompilationUnit();
+ ICompilationUnit compilationUnit = original.getWorkingCopy(new NullProgressMonitor());
for (IBeanMethod disposerMethod : disposerMethods) {
if(!disposerMethod.getMethod().isSimilar(method)){
- Set<ITextSourceReference> disposerDeclarations = CDIUtil.getAnnotationPossitions(disposerMethod, CDIConstants.DISPOSES_ANNOTATION_TYPE_NAME);
- for (ITextSourceReference declaration : disposerDeclarations) {
- TextEdit edit = new ReplaceEdit(declaration.getStartPosition(), declaration.getLength(), "");
- change.addEdit(edit);
- }
+ CDIMarkerResolutionUtils.deleteAnnotation(CDIConstants.DISPOSES_ANNOTATION_TYPE_NAME, compilationUnit, disposerMethod.getMethod().getParameters()[0], (MultiTextEdit)change.getEdit());
+// Set<ITextSourceReference> disposerDeclarations = CDIUtil.getAnnotationPossitions(disposerMethod, CDIConstants.DISPOSES_ANNOTATION_TYPE_NAME);
+// for (ITextSourceReference declaration : disposerDeclarations) {
+// TextEdit edit = new ReplaceEdit(declaration.getStartPosition(), declaration.getLength(), "");
+// change.addEdit(edit);
+// }
}
}
+ compilationUnit.discardWorkingCopy();
}
}
}
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/refactoring/DeleteAllInjectedConstructorsProcessor.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/refactoring/DeleteAllInjectedConstructorsProcessor.java 2011-12-28 00:05:31 UTC (rev 37566)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/refactoring/DeleteAllInjectedConstructorsProcessor.java 2011-12-28 00:45:26 UTC (rev 37567)
@@ -10,22 +10,22 @@
******************************************************************************/
package org.jboss.tools.cdi.internal.core.refactoring;
-import java.util.HashSet;
import java.util.Set;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IMethod;
+import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext;
-import org.eclipse.text.edits.ReplaceEdit;
-import org.eclipse.text.edits.TextEdit;
+import org.eclipse.text.edits.MultiTextEdit;
import org.jboss.tools.cdi.core.CDIConstants;
import org.jboss.tools.cdi.core.IBeanMethod;
import org.jboss.tools.cdi.core.IClassBean;
-import org.jboss.tools.common.java.IAnnotationDeclaration;
public class DeleteAllInjectedConstructorsProcessor extends CDIRefactoringProcessor {
private IMethod method;
@@ -35,22 +35,26 @@
this.method = method;
}
- private void changeConstructors(IClassBean bean) {
+ private void changeConstructors(IClassBean bean) throws JavaModelException {
Set<IBeanMethod> constructors = bean.getBeanConstructors();
if(constructors.size()>1) {
- Set<IAnnotationDeclaration> injects = new HashSet<IAnnotationDeclaration>();
+ //Set<IAnnotationDeclaration> injects = new HashSet<IAnnotationDeclaration>();
+ ICompilationUnit original = constructors.iterator().next().getMethod().getCompilationUnit();
+ ICompilationUnit compilationUnit = original.getWorkingCopy(new NullProgressMonitor());
for (IBeanMethod constructor : constructors) {
if(!constructor.getMethod().isSimilar(method)){
- IAnnotationDeclaration inject = constructor.getAnnotation(CDIConstants.INJECT_ANNOTATION_TYPE_NAME);
- if(inject!=null) {
- injects.add(inject);
- }
+ CDIMarkerResolutionUtils.deleteAnnotation(CDIConstants.INJECT_ANNOTATION_TYPE_NAME, compilationUnit, constructor.getMethod(), (MultiTextEdit)change.getEdit());
+ //IAnnotationDeclaration inject = constructor.getAnnotation(CDIConstants.INJECT_ANNOTATION_TYPE_NAME);
+ //if(inject!=null) {
+ // injects.add(inject);
+ //}
}
}
- for (IAnnotationDeclaration inject : injects) {
- TextEdit edit = new ReplaceEdit(inject.getStartPosition(), inject.getLength(), "");
- change.addEdit(edit);
- }
+ compilationUnit.discardWorkingCopy();
+ //for (IAnnotationDeclaration inject : injects) {
+ // TextEdit edit = new ReplaceEdit(inject.getStartPosition(), inject.getLength(), "");
+ // change.addEdit(edit);
+ //}
}
}
12 years, 12 months
JBoss Tools SVN: r37566 - trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2011-12-27 19:05:31 -0500 (Tue, 27 Dec 2011)
New Revision: 37566
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPTextEditor.java
Log:
doOperation(int) method changed to check if current operation is long only once
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPTextEditor.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPTextEditor.java 2011-12-27 13:19:24 UTC (rev 37565)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPTextEditor.java 2011-12-28 00:05:31 UTC (rev 37566)
@@ -663,22 +663,18 @@
}
public void doOperation(int operation) {
- if (operation == UNDO || operation == REDO
+ boolean isLongOperation = operation == UNDO
+ || operation == REDO
|| operation == FORMAT_DOCUMENT
- || operation == FORMAT_ACTIVE_ELEMENTS) {
- if (editor.getVPEController() != null) {
+ || operation == FORMAT_ACTIVE_ELEMENTS;
+ if (isLongOperation && editor.getVPEController() != null) {
editor.getVPEController().preLongOperation();
- }
}
try {
super.doOperation(operation);
} finally {
- if (operation == UNDO || operation == REDO
- || operation == FORMAT_DOCUMENT
- || operation == FORMAT_ACTIVE_ELEMENTS) {
- if (editor.getVPEController() != null) {
+ if (isLongOperation && editor.getVPEController() != null) {
editor.getVPEController().postLongOperation();
- }
}
}
}
12 years, 12 months
JBoss Tools SVN: r37565 - trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console.
by jbosstools-commits@lists.jboss.org
Author: dgeraskov
Date: 2011-12-27 08:19:24 -0500 (Tue, 27 Dec 2011)
New Revision: 37565
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.properties
Log:
https://issues.jboss.org/browse/JBIDE-10414
There are different hibernate versions available
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.properties
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.properties 2011-12-27 13:12:17 UTC (rev 37564)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.properties 2011-12-27 13:19:24 UTC (rev 37565)
@@ -96,7 +96,7 @@
HibernatePropertyPage_default_hibernate_console_config=Default Hibernate Console configuration:
HibernatePropertyPage_details=<a>Details ...</a>
-HibernatePropertyPage_enable_hibernate3_support=Enable Hibernate 3 support
+HibernatePropertyPage_enable_hibernate3_support=Enable Hibernate support
HibernatePropertyPage_open_url=Open URL
HibernatePropertyPage_unable_open_webbrowser_for_url=Unable to open webbrowser for url:
HibernatePropertyPage_use_naming_strategy=Use NamingStrategy for validation.
12 years, 12 months
JBoss Tools SVN: r37564 - in trunk/hibernatetools/plugins/org.jboss.tools.hibernate4_0: src/org/jboss/tools/hibernate4_0 and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: dgeraskov
Date: 2011-12-27 08:12:17 -0500 (Tue, 27 Dec 2011)
New Revision: 37564
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate4_0/.classpath
trunk/hibernatetools/plugins/org.jboss.tools.hibernate4_0/src/org/jboss/tools/hibernate4_0/HibernateExtension4_0.java
Log:
https://issues.jboss.org/browse/JBIDE-10560
Fixed exception: Inline evaluation error while using criteria editor with Hibernate 4
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate4_0/.classpath
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate4_0/.classpath 2011-12-23 18:29:41 UTC (rev 37563)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate4_0/.classpath 2011-12-27 13:12:17 UTC (rev 37564)
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry exported="true" kind="lib" path="lib/required/slf4j-api-1.5.8.jar"/>
- <classpathentry exported="true" kind="lib" path="lib/jpa/hibernate-entitymanager-4.0.0.CR6.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/jpa/hibernate-entitymanager-4.0.0.CR6.jar" sourcepath="C:/Documents and Settings/dgeraskov/.m2/repository/org/hibernate/hibernate-entitymanager/4.0.0.CR6/hibernate-entitymanager-4.0.0.CR6-sources.jar"/>
<classpathentry exported="true" kind="lib" path="lib/required/antlr-2.7.7.jar"/>
<classpathentry exported="true" kind="lib" path="lib/required/classmate-0.5.4.jar"/>
<classpathentry exported="true" kind="lib" path="lib/required/commons-collections-3.2.1.jar"/>
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate4_0/src/org/jboss/tools/hibernate4_0/HibernateExtension4_0.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate4_0/src/org/jboss/tools/hibernate4_0/HibernateExtension4_0.java 2011-12-23 18:29:41 UTC (rev 37563)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate4_0/src/org/jboss/tools/hibernate4_0/HibernateExtension4_0.java 2011-12-27 13:12:17 UTC (rev 37564)
@@ -95,28 +95,33 @@
}
@Override
- public QueryResult executeCriteriaQuery(String criteriaCode,
- QueryInputModel model) {
- Session session = null;
- try {
- try {
- session = sessionFactory.openSession();
- return QueryExecutor.executeCriteriaQuery(session, criteriaCode, model);
- } catch (Throwable e){
- //Incompatible library versions could throw subclasses of Error, like AbstractMethodError
- //may be there is a sense to say to user that the reason is probably a wrong CC version
- //(when catch a subclass of Error)
- return new QueryResultImpl(e);
- }
- } finally {
- if (session != null && session.isOpen()){
+ public QueryResult executeCriteriaQuery(final String criteriaCode,
+ final QueryInputModel model) {
+ return (QueryResult) execute(new Command() {
+ public Object execute() {
+ Session session = null;
try {
- session.close();
- } catch (HibernateException e) {
- return new QueryResultImpl(e);
- }
+ try {
+ session = sessionFactory.openSession();
+ return QueryExecutor.executeCriteriaQuery(session, criteriaCode, model);
+ } catch (Throwable e){
+ //Incompatible library versions could throw subclasses of Error, like AbstractMethodError
+ //may be there is a sense to say to user that the reason is probably a wrong CC version
+ //(when catch a subclass of Error)
+ return new QueryResultImpl(e);
+ }
+ } finally {
+ if (session != null && session.isOpen()){
+ try {
+ session.close();
+ } catch (HibernateException e) {
+ return new QueryResultImpl(e);
+ }
+ }
+ }
}
- }
+ });
+
}
/**
12 years, 12 months
JBoss Tools SVN: r37563 - trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker.
by jbosstools-commits@lists.jboss.org
Author: dazarov
Date: 2011-12-23 13:29:41 -0500 (Fri, 23 Dec 2011)
New Revision: 37563
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/ChangeAnnotationMarkerResolution.java
Log:
Java Seam and CDI quick fixes: after quick fix, editor is scrolled to the beginning. If Undo/Redo commands are used, the entire file content gets selected https://issues.jboss.org/browse/JBIDE-10536
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/ChangeAnnotationMarkerResolution.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/ChangeAnnotationMarkerResolution.java 2011-12-23 17:49:39 UTC (rev 37562)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/ChangeAnnotationMarkerResolution.java 2011-12-23 18:29:41 UTC (rev 37563)
@@ -101,12 +101,9 @@
IAnnotation workingCopyAnnotation = CDIMarkerResolutionUtils.findWorkingCopy(compilationUnit, annotation);
- //IBuffer buffer = compilationUnit.getBuffer();
TextEdit re = new ReplaceEdit(workingCopyAnnotation.getSourceRange().getOffset(), workingCopyAnnotation.getSourceRange().getLength(), changeString);
edit.addChild(re);
- //buffer.replace(workingCopyAnnotation.getSourceRange().getOffset(), workingCopyAnnotation.getSourceRange().getLength(), changeString);
-
if(edit.hasChildren()){
change.perform(new NullProgressMonitor());
original.reconcile(ICompilationUnit.NO_AST, false, null, new NullProgressMonitor());
13 years