Author: mareshkau
Date: 2008-06-25 14:47:49 -0400 (Wed, 25 Jun 2008)
New Revision: 8947
Added:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mapping/VpeAttributeData.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/ITemplateKeyEventHandler.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/ITemplateNodesManager.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/ITemplateSelectionManager.java
Removed:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/util/model/VpeElementProxyData.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mapping/AttributeData.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mapping/NodeData.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/IKeyEventHandler.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/ISelectionManager.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/KeyEventManager.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/SelectionManager.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/NodesManagingUtil.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/SelectionUtil.java
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/AbstractEditableJsfTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/AbstractOutputJsfTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfInputTextAreaTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfInputTextTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfOptionSelectItemTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfVerbatim.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/util/NodeProxyUtil.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/util/model/AttributeProxy.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/util/model/NamedNodeMapImpl.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/util/model/NodeProxy.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/AbstractEditableRichFacesTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/InputNumberSliderTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesComboBoxTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesInputNumberSpinnerTemplate.java
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/VpeSelectionBuilder.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeSourceDomBuilder.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualKeyHandler.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mapping/VpeElementData.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaEditor.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAbstractTemplate.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplate.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/TemplateManagingUtil.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/TextUtil.java
Log:
revert changes from 8943 commit
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/AbstractEditableJsfTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/AbstractEditableJsfTemplate.java 2008-06-25
18:32:58 UTC (rev 8946)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/AbstractEditableJsfTemplate.java 2008-06-25
18:47:49 UTC (rev 8947)
@@ -14,7 +14,7 @@
import java.util.Map;
import java.util.Set;
-import org.jboss.tools.vpe.editor.template.VpeAbstractTemplate;
+import org.jboss.tools.vpe.editor.template.EditableTemplateAdapter;
import org.jboss.tools.vpe.editor.util.HTML;
import org.mozilla.interfaces.nsIDOMElement;
import org.w3c.dom.Element;
@@ -25,7 +25,8 @@
* @author Sergey Dzmitrovich
*
*/
-public abstract class AbstractEditableJsfTemplate extends VpeAbstractTemplate {
+public abstract class AbstractEditableJsfTemplate extends
+ EditableTemplateAdapter {
// general jsf attributes
static private Map<String, String> attributes = new HashMap<String,
String>();
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/AbstractOutputJsfTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/AbstractOutputJsfTemplate.java 2008-06-25
18:32:58 UTC (rev 8946)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/AbstractOutputJsfTemplate.java 2008-06-25
18:47:49 UTC (rev 8947)
@@ -4,18 +4,15 @@
import org.jboss.tools.jsf.vpe.jsf.template.util.ComponentUtil;
import org.jboss.tools.jsf.vpe.jsf.template.util.JSF;
import org.jboss.tools.jsf.vpe.jsf.template.util.NodeProxyUtil;
-import org.jboss.tools.jsf.vpe.jsf.template.util.model.VpeElementProxyData;
import org.jboss.tools.vpe.editor.context.VpePageContext;
-import org.jboss.tools.vpe.editor.mapping.AttributeData;
-import org.jboss.tools.vpe.editor.mapping.NodeData;
-import org.jboss.tools.vpe.editor.mapping.VpeDomMapping;
+import org.jboss.tools.vpe.editor.mapping.VpeAttributeData;
import org.jboss.tools.vpe.editor.mapping.VpeElementData;
import org.jboss.tools.vpe.editor.mapping.VpeElementMapping;
import org.jboss.tools.vpe.editor.mapping.VpeNodeMapping;
import org.jboss.tools.vpe.editor.template.VpeChildrenInfo;
import org.jboss.tools.vpe.editor.template.VpeCreationData;
import org.jboss.tools.vpe.editor.util.HTML;
-import org.jboss.tools.vpe.editor.util.NodesManagingUtil;
+import org.jboss.tools.vpe.editor.util.TemplateManagingUtil;
import org.mozilla.interfaces.nsIDOMDocument;
import org.mozilla.interfaces.nsIDOMElement;
import org.mozilla.interfaces.nsIDOMNode;
@@ -69,7 +66,7 @@
nsIDOMDocument visualDocument, Element sourceElement,
nsIDOMElement targetVisualElement, VpeCreationData creationData) {
- VpeElementProxyData elementData = new VpeElementProxyData();
+ VpeElementData elementData = new VpeElementData();
Attr outputAttr = getOutputAttributeNode(sourceElement);
@@ -95,8 +92,8 @@
text = visualDocument.createTextNode(newValue);
// add attribute for ability of editing
- elementData.addNodeData(new AttributeData(outputAttr, text,
- isEditable));
+ elementData.addAttributeData(new VpeAttributeData(outputAttr,
+ text, isEditable));
targetVisualElement.appendChild(text);
@@ -113,8 +110,8 @@
.getValueRegionStartOffset();
// reparse attribute's value
- NodeList list = NodeProxyUtil.reparseAttributeValue(
- elementData, newValue, offset + 1);
+ NodeList list = NodeProxyUtil.reparseAttributeValue(newValue,
+ offset);
// add children to info
for (int i = 0; i < list.getLength(); i++) {
@@ -125,7 +122,7 @@
targetVisualInfo.addSourceChild(child);
}
- elementData.addNodeData(new AttributeData(outputAttr,
+ elementData.addAttributeData(new VpeAttributeData(outputAttr,
targetVisualElement, false));
creationData.addChildrenInfo(targetVisualInfo);
@@ -143,79 +140,114 @@
return ComponentUtil.getBundleValue(pageContext, attr);
}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.jboss.tools.vpe.editor.template.VpeAbstractTemplate#setPseudoContent
- * (org.jboss.tools.vpe.editor.context.VpePageContext, org.w3c.dom.Node,
- * org.mozilla.interfaces.nsIDOMNode, org.mozilla.interfaces.nsIDOMDocument)
- */
@Override
- public void setPseudoContent(VpePageContext pageContext,
- Node sourceContainer, nsIDOMNode visualContainer,
- nsIDOMDocument visualDocument) {
- // Empty
- }
+ public Node getTargetSourceNodeByVisualNode(VpePageContext pageContext,
+ nsIDOMNode visualNode, VpeElementMapping elementMapping) {
- @Override
- public NodeData getNodeData(nsIDOMNode node, VpeElementData elementData,
- VpeDomMapping domMapping) {
- // TODO Auto-generated method stub
- NodeData nodeData = super.getNodeData(node, elementData, domMapping);
- if (nodeData == null) {
+ // try get mapping
+ VpeNodeMapping tempMapping = pageContext.getDomMapping()
+ .getNearElementMapping(visualNode);
- VpeNodeMapping nodeMapping = domMapping.getNodeMapping(node);
+ // if mapping is not null
+ if (tempMapping != null) {
- if (nodeMapping != null) {
- if (nodeMapping.getType() == VpeNodeMapping.ELEMENT_MAPPING) {
- nodeData = super.getNodeData(node,
- ((VpeElementMapping) nodeMapping).getElementData(),
- domMapping);
- } else if (nodeMapping.getType() == VpeNodeMapping.TEXT_MAPPING) {
- nodeData = new NodeData(nodeMapping.getSourceNode(), node,
- true);
- }
+ return super.getTargetSourceNodeByVisualNode(pageContext,
+ visualNode, elementMapping);
+ }
+ // can be only for escape=false
+ else {
+
+ tempMapping = pageContext.getDomMapping()
+ .getNearNodeMappingAtVisualNode(visualNode);
+
+ if (tempMapping != null) {
+
+ Node insertedNode = tempMapping.getSourceNode();
+
+ return getTargetSourceNodeBySourcePosition(pageContext,
+ TemplateManagingUtil.getStartOffsetNode(insertedNode),
+ TemplateManagingUtil.getEndOffsetNode(insertedNode));
+
}
}
- return nodeData;
+
+ return elementMapping.getSourceNode();
+
}
@Override
- public nsIDOMNode getVisualNodeByBySourcePosition(
- VpeElementMapping elementMapping, int focusPosition,
- int anchorPosition, VpeDomMapping domMapping) {
- nsIDOMNode node = null;
+ public nsIDOMNode getTargetVisualNodeByVisualNode(
+ VpePageContext pageContext, nsIDOMNode visualNode,
+ VpeElementMapping elementMapping) {
+ // try get mapping
+ VpeNodeMapping tempMapping = pageContext.getDomMapping()
+ .getNearElementMapping(visualNode);
- if ((elementMapping.getElementData() instanceof VpeElementProxyData)
- && (((VpeElementProxyData) elementMapping.getElementData())
- .getNodelist() != null)) {
+ // if mapping is not null
+ if (tempMapping != null) {
- VpeElementProxyData elementProxyData = (VpeElementProxyData) elementMapping
- .getElementData();
+ return super.getTargetVisualNodeByVisualNode(pageContext,
+ visualNode, elementMapping);
+ }
+ // can be only for escape=false
+ else {
- Node sourceNode = NodeProxyUtil.findNodeByPosition(elementProxyData
- .getNodelist(), focusPosition, anchorPosition);
+ tempMapping = pageContext.getDomMapping()
+ .getNearNodeMappingAtVisualNode(visualNode);
- VpeNodeMapping nodeMapping = NodesManagingUtil.getNodeMapping(
- domMapping, sourceNode);
+ if (tempMapping != null) {
- if (nodeMapping != null) {
+ Node insertedNode = tempMapping.getSourceNode();
- if (nodeMapping.getType() == VpeNodeMapping.ELEMENT_MAPPING) {
- node = super.getVisualNodeByBySourcePosition(
- (VpeElementMapping) nodeMapping, focusPosition,
- anchorPosition, domMapping);
- } else {
- node = nodeMapping.getVisualNode();
- }
+ Node sourceNode = getTargetSourceNodeBySourcePosition(
+ pageContext, TemplateManagingUtil
+ .getStartOffsetNode(insertedNode),
+ TemplateManagingUtil.getEndOffsetNode(insertedNode));
+ return getTargetVisualNodeBySourceNode(sourceNode,
+ elementMapping);
+
}
}
- if (node == null) {
- node = super.getVisualNodeByBySourcePosition(elementMapping,
- focusPosition, anchorPosition, domMapping);
+ return elementMapping.getVisualNode();
+ }
+
+ @Override
+ protected VpeElementMapping getElmentMapping(VpePageContext pageContext,
+ nsIDOMNode node) {
+ // TODO Auto-generated method stub
+ VpeElementMapping elementMapping = super.getElmentMapping(pageContext,
+ node);
+
+ if (elementMapping == null) {
+ VpeNodeMapping insertedMapping = pageContext.getDomMapping()
+ .getNearNodeMappingAtVisualNode(node);
+ if (insertedMapping != null) {
+ Node insertedNode = insertedMapping.getSourceNode();
+
+ int offset = TemplateManagingUtil
+ .getStartOffsetNode(insertedNode);
+ elementMapping = TemplateManagingUtil
+ .getElementMappingBySourceSelection(pageContext,
+ offset, offset);
+
+ }
}
- return node;
+
+ return elementMapping;
}
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.jboss.tools.vpe.editor.template.VpeAbstractTemplate#setPseudoContent(org.jboss.tools.vpe.editor.context.VpePageContext,
+ * org.w3c.dom.Node, org.mozilla.interfaces.nsIDOMNode,
+ * org.mozilla.interfaces.nsIDOMDocument)
+ */
+ @Override
+ public void setPseudoContent(VpePageContext pageContext,
+ Node sourceContainer, nsIDOMNode visualContainer,
+ nsIDOMDocument visualDocument) {
+ // Empty
+ }
}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfInputTextAreaTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfInputTextAreaTemplate.java 2008-06-25
18:32:58 UTC (rev 8946)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfInputTextAreaTemplate.java 2008-06-25
18:47:49 UTC (rev 8947)
@@ -2,7 +2,7 @@
import org.jboss.tools.jsf.vpe.jsf.template.util.JSF;
import org.jboss.tools.vpe.editor.context.VpePageContext;
-import org.jboss.tools.vpe.editor.mapping.AttributeData;
+import org.jboss.tools.vpe.editor.mapping.VpeAttributeData;
import org.jboss.tools.vpe.editor.mapping.VpeElementData;
import org.jboss.tools.vpe.editor.template.VpeCreationData;
import org.jboss.tools.vpe.editor.util.HTML;
@@ -42,12 +42,12 @@
Attr attr = sourceElement.getAttributeNode(JSF.ATTR_VALUE);
text = visualDocument.createTextNode(sourceElement
.getAttribute(JSF.ATTR_VALUE));
- elementData.addNodeData(new AttributeData(attr, textArea,
+ elementData.addAttributeData(new VpeAttributeData(attr, textArea,
true));
} else {
text = visualDocument.createTextNode(""); //$NON-NLS-1$
- elementData.addNodeData(new AttributeData(JSF.ATTR_VALUE,
+ elementData.addAttributeData(new VpeAttributeData(JSF.ATTR_VALUE,
textArea, true));
}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfInputTextTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfInputTextTemplate.java 2008-06-25
18:32:58 UTC (rev 8946)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfInputTextTemplate.java 2008-06-25
18:47:49 UTC (rev 8947)
@@ -2,8 +2,7 @@
import org.jboss.tools.jsf.vpe.jsf.template.util.JSF;
import org.jboss.tools.vpe.editor.context.VpePageContext;
-import org.jboss.tools.vpe.editor.mapping.AttributeData;
-import org.jboss.tools.vpe.editor.mapping.NodeData;
+import org.jboss.tools.vpe.editor.mapping.VpeAttributeData;
import org.jboss.tools.vpe.editor.mapping.VpeElementData;
import org.jboss.tools.vpe.editor.template.VpeCreationData;
import org.jboss.tools.vpe.editor.util.HTML;
@@ -35,11 +34,11 @@
Attr attr = sourceElement.getAttributeNode(JSF.ATTR_VALUE);
elementData
- .addNodeData(new AttributeData(attr, input, true));
+ .addAttributeData(new VpeAttributeData(attr, input, true));
} else {
- elementData.addNodeData(new AttributeData(JSF.ATTR_VALUE,
+ elementData.addAttributeData(new VpeAttributeData(JSF.ATTR_VALUE,
input, true));
}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfOptionSelectItemTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfOptionSelectItemTemplate.java 2008-06-25
18:32:58 UTC (rev 8946)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfOptionSelectItemTemplate.java 2008-06-25
18:47:49 UTC (rev 8947)
@@ -12,9 +12,9 @@
import org.jboss.tools.jsf.vpe.jsf.template.util.ComponentUtil;
import org.jboss.tools.jsf.vpe.jsf.template.util.NodeProxyUtil;
-import org.jboss.tools.jsf.vpe.jsf.template.util.model.VpeElementProxyData;
+import org.jboss.tools.vpe.editor.VpeSourceDomBuilder;
import org.jboss.tools.vpe.editor.context.VpePageContext;
-import org.jboss.tools.vpe.editor.mapping.AttributeData;
+import org.jboss.tools.vpe.editor.template.VpeAbstractTemplate;
import org.jboss.tools.vpe.editor.template.VpeChildrenInfo;
import org.jboss.tools.vpe.editor.template.VpeCreationData;
import org.jboss.tools.vpe.editor.util.HTML;
@@ -30,7 +30,7 @@
* @author dmaliarevich
*
*/
-public class JsfOptionSelectItemTemplate extends AbstractOutputJsfTemplate
/*VpeAbstractTemplate*/ {
+public class JsfOptionSelectItemTemplate extends VpeAbstractTemplate {
public static final String ITEM_DISABLED = "itemDisabled";
@@ -86,9 +86,7 @@
if (element.hasAttribute(ITEM_LABEL)) {
attr = element.getAttributeNode(ITEM_LABEL);
}
-
- VpeElementProxyData elementData = new VpeElementProxyData();
-
+
if (null != attr) {
if (null == escape || "true".equalsIgnoreCase(escape)) {
// show text as is
@@ -103,19 +101,13 @@
} else {
text = visualDocument.createTextNode(itemLabel);
-
- elementData.addNodeData(new AttributeData(attr,
- option, true));
- creationData.setElementData(elementData);
}
-
-
option.appendChild(text);
} else {
// show formatted text
VpeChildrenInfo spanInfo = new VpeChildrenInfo(option);
// re-parse attribute's value
- NodeList list = NodeProxyUtil.reparseAttributeValue(elementData,attr);
+ NodeList list = NodeProxyUtil.reparseAttributeValue(attr);
// add children to info
for (int i = 0; i < list.getLength(); i++) {
Node child = list.item(i);
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfVerbatim.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfVerbatim.java 2008-06-25
18:32:58 UTC (rev 8946)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfVerbatim.java 2008-06-25
18:47:49 UTC (rev 8947)
@@ -14,7 +14,7 @@
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
import org.jboss.tools.vpe.editor.context.VpePageContext;
-import org.jboss.tools.vpe.editor.template.VpeAbstractTemplate;
+import org.jboss.tools.vpe.editor.template.EditableTemplateAdapter;
import org.jboss.tools.vpe.editor.template.VpeChildrenInfo;
import org.jboss.tools.vpe.editor.template.VpeCreationData;
import org.jboss.tools.vpe.editor.util.HTML;
@@ -29,7 +29,7 @@
* @author Sergey Dzmitrovich
*
*/
-public class JsfVerbatim extends VpeAbstractTemplate {
+public class JsfVerbatim extends EditableTemplateAdapter {
/*
* (non-Javadoc)
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/util/NodeProxyUtil.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/util/NodeProxyUtil.java 2008-06-25
18:32:58 UTC (rev 8946)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/util/NodeProxyUtil.java 2008-06-25
18:47:49 UTC (rev 8947)
@@ -23,45 +23,35 @@
import org.jboss.tools.jsf.vpe.jsf.template.util.model.NodeListImpl;
import org.jboss.tools.jsf.vpe.jsf.template.util.model.NodeProxy;
import org.jboss.tools.jsf.vpe.jsf.template.util.model.TextProxy;
-import org.jboss.tools.jsf.vpe.jsf.template.util.model.VpeElementProxyData;
-import org.jboss.tools.vpe.editor.util.NodesManagingUtil;
import org.w3c.dom.Attr;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
public class NodeProxyUtil {
- static public NodeList reparseAttributeValue(VpeElementProxyData data,
- String attrString, int offset) {
+ static public NodeList reparseAttributeValue(String attrString, int offset) {
IStructuredDocument newStructuredDocument = StructuredDocumentFactory
.getNewStructuredDocumentInstance(new JSPSourceParser());
newStructuredDocument.set(attrString);
IDOMModel modelForJSP = new DOMModelForJSP();
-
modelForJSP.setStructuredDocument(newStructuredDocument);
- // data.setModel(modelForJSP);
- // data.setOffset(offset);
-
IDOMDocument document = modelForJSP.getDocument();
NodeList list = document.getChildNodes();
NodeList adaptersList = getNodeAdapterList(list, offset);
- data.setNodelist(adaptersList);
-
return adaptersList;
}
- static public NodeList reparseAttributeValue(VpeElementProxyData data,
- Attr attr) {
+ static public NodeList reparseAttributeValue(Attr attr) {
- return reparseAttributeValue(data, attr.getValue(), ((IDOMAttr) attr)
- .getValueRegionStartOffset() + 1);
+ return reparseAttributeValue(attr.getValue(), ((IDOMAttr) attr)
+ .getValueRegionStartOffset());
}
@@ -94,44 +84,4 @@
}
- /**
- *
- * @param nodeList
- * @param focusPosition
- * @param anchorPosition
- * @return
- */
- static public Node findNodeByPosition(NodeList nodeList, int focusPosition,
- int anchorPosition) {
-
- if (anchorPosition < focusPosition) {
- focusPosition = anchorPosition;
- anchorPosition = focusPosition;
- }
-
- for (int i = 0; i < nodeList.getLength(); i++) {
-
- Node child = nodeList.item(i);
-
- Node result = null;
- if (child.hasChildNodes()) {
-
- result = findNodeByPosition(child.getChildNodes(),
- focusPosition, anchorPosition);
- }
-
- if (result != null)
- return result;
-
- if ((focusPosition >= (NodesManagingUtil.getStartOffsetNode(child)))
- && (anchorPosition <= (NodesManagingUtil
- .getEndOffsetNode(child))))
-
- return child;
- }
-
- return null;
-
- }
-
}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/util/model/AttributeProxy.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/util/model/AttributeProxy.java 2008-06-25
18:32:58 UTC (rev 8946)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/util/model/AttributeProxy.java 2008-06-25
18:47:49 UTC (rev 8947)
@@ -12,6 +12,7 @@
import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr;
+import org.w3c.dom.Attr;
import org.w3c.dom.DOMException;
import org.w3c.dom.Element;
import org.w3c.dom.TypeInfo;
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/util/model/NamedNodeMapImpl.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/util/model/NamedNodeMapImpl.java 2008-06-25
18:32:58 UTC (rev 8946)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/util/model/NamedNodeMapImpl.java 2008-06-25
18:47:49 UTC (rev 8947)
@@ -13,7 +13,10 @@
import java.util.ArrayList;
import java.util.List;
+import org.eclipse.wst.xml.core.internal.document.AttrImpl;
+import org.w3c.dom.Attr;
import org.w3c.dom.DOMException;
+import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/util/model/NodeProxy.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/util/model/NodeProxy.java 2008-06-25
18:32:58 UTC (rev 8946)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/util/model/NodeProxy.java 2008-06-25
18:47:49 UTC (rev 8947)
@@ -24,9 +24,11 @@
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMText;
import org.w3c.dom.DOMException;
import org.w3c.dom.Document;
+import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
+import org.w3c.dom.TypeInfo;
import org.w3c.dom.UserDataHandler;
public class NodeProxy implements IDOMNode {
@@ -312,7 +314,7 @@
}
public int getStartOffset() {
- return ((IDOMNode) basicNode).getStartOffset() + basicOffset;
+ return ((IDOMNode) basicNode).getStartOffset()+ basicOffset;
}
public void addAdapter(INodeAdapter adapter) {
Deleted:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/util/model/VpeElementProxyData.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/util/model/VpeElementProxyData.java 2008-06-25
18:32:58 UTC (rev 8946)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/util/model/VpeElementProxyData.java 2008-06-25
18:47:49 UTC (rev 8947)
@@ -1,38 +0,0 @@
-package org.jboss.tools.jsf.vpe.jsf.template.util.model;
-
-import org.jboss.tools.vpe.editor.mapping.VpeElementData;
-import org.w3c.dom.NodeList;
-
-public class VpeElementProxyData extends VpeElementData {
-
- // private IStructuredModel model;
-
- // private int offset;
- //
- // public void setModel(IStructuredModel model) {
- // this.model = model;
- // }
- //
- // public IStructuredModel getModel() {
- // return model;
- // }
- //
- // public int getOffset() {
- // return offset;
- // }
- //
- // public void setOffset(int offset) {
- // this.offset = offset;
- // }
-
- private NodeList nodelist;
-
- public NodeList getNodelist() {
- return nodelist;
- }
-
- public void setNodelist(NodeList nodelist) {
- this.nodelist = nodelist;
- }
-
-}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/AbstractEditableRichFacesTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/AbstractEditableRichFacesTemplate.java 2008-06-25
18:32:58 UTC (rev 8946)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/AbstractEditableRichFacesTemplate.java 2008-06-25
18:47:49 UTC (rev 8947)
@@ -10,11 +10,11 @@
******************************************************************************/
package org.jboss.tools.jsf.vpe.richfaces.template;
-import org.jboss.tools.vpe.editor.template.VpeAbstractTemplate;
+import org.jboss.tools.vpe.editor.template.EditableTemplateAdapter;
import org.w3c.dom.Element;
public abstract class AbstractEditableRichFacesTemplate extends
- VpeAbstractTemplate {
+ EditableTemplateAdapter {
public String getAttribute(Element sourceElement, String attributeName) {
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/InputNumberSliderTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/InputNumberSliderTemplate.java 2008-06-25
18:32:58 UTC (rev 8946)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/InputNumberSliderTemplate.java 2008-06-25
18:47:49 UTC (rev 8947)
@@ -17,8 +17,7 @@
import org.jboss.tools.jsf.vpe.richfaces.ComponentUtil;
import org.jboss.tools.jsf.vpe.richfaces.template.util.RichFaces;
import org.jboss.tools.vpe.editor.context.VpePageContext;
-import org.jboss.tools.vpe.editor.mapping.AttributeData;
-import org.jboss.tools.vpe.editor.mapping.NodeData;
+import org.jboss.tools.vpe.editor.mapping.VpeAttributeData;
import org.jboss.tools.vpe.editor.mapping.VpeElementData;
import org.jboss.tools.vpe.editor.mapping.VpeElementMapping;
import org.jboss.tools.vpe.editor.template.VpeCreationData;
@@ -282,24 +281,24 @@
.getBackgoundImgStyle(INPUT_BACKGROUND_IMAGE_PATH)
+ getAttribute(sourceElement, RichFaces.ATTR_INPUT_STYLE));
- NodeData attributeData;
+ VpeAttributeData attributeData;
if (sourceElement.hasAttribute(RichFaces.ATTR_VALUE)) {
inputField.setAttribute(HTML.ATTR_VALUE, sourceElement
.getAttribute(RichFaces.ATTR_VALUE));
- attributeData = new NodeData(sourceElement
+ attributeData = new VpeAttributeData(sourceElement
.getAttributeNode(RichFaces.ATTR_VALUE), inputField);
} else {
inputField.setAttribute(HTML.ATTR_VALUE, ""); //$NON-NLS-1$
- attributeData = new AttributeData(RichFaces.ATTR_VALUE,
+ attributeData = new VpeAttributeData(RichFaces.ATTR_VALUE,
inputField);
}
- elementData.addNodeData(attributeData);
+ elementData.addAttributeData(attributeData);
// get class attribute
String inputClass = null;
@@ -419,14 +418,14 @@
if (isShowBoundaryValues(sourceElement)) {
nsIDOMText minValueText;
- NodeData minValueData;
+ VpeAttributeData minValueData;
if (sourceElement.hasAttribute(MIN_VALUE_ATTR)) {
// create minValue text
minValueText = visualDocument.createTextNode(sourceElement
.getAttribute(MIN_VALUE_ATTR));
- minValueData = new NodeData(sourceElement
+ minValueData = new VpeAttributeData(sourceElement
.getAttributeNode(MIN_VALUE_ATTR), minValueText);
} else {
@@ -434,23 +433,23 @@
// create minValue text
minValueText = visualDocument.createTextNode(MIN_VALUE_DEFAULT);
- minValueData = new AttributeData(MIN_VALUE_ATTR,
+ minValueData = new VpeAttributeData(MIN_VALUE_ATTR,
minValueText);
}
// add text to td
minValueTd.appendChild(minValueText);
- elementData.addNodeData(minValueData);
+ elementData.addAttributeData(minValueData);
nsIDOMText maxValueText;
- NodeData maxValueData;
+ VpeAttributeData maxValueData;
if (sourceElement.hasAttribute(MAX_VALUE_ATTR)) {
// create minValue text
maxValueText = visualDocument.createTextNode(sourceElement
.getAttribute(MAX_VALUE_ATTR));
- maxValueData = new NodeData(sourceElement
+ maxValueData = new VpeAttributeData(sourceElement
.getAttributeNode(MAX_VALUE_ATTR), maxValueText);
} else {
@@ -458,13 +457,13 @@
// create minValue text
maxValueText = visualDocument.createTextNode(MAX_VALUE_DEFAULT);
- maxValueData = new AttributeData(MAX_VALUE_ATTR,
+ maxValueData = new VpeAttributeData(MAX_VALUE_ATTR,
maxValueText);
}
// add text to td
maxValueTd.appendChild(maxValueText);
- elementData.addNodeData(maxValueData);
+ elementData.addAttributeData(maxValueData);
}
valuesBlock.appendChild(minValueTd);
@@ -581,4 +580,30 @@
return true;
}
+ /**
+ *
+ */
+ public Node getTargetSourceNodeByVisualNode(VpePageContext pageContext,
+ nsIDOMNode visualNode, VpeElementMapping elementMapping) {
+
+ // if element is not null
+ if (elementMapping != null) {
+
+ // get attributeData
+ VpeAttributeData attributeData = getAttributeData(visualNode,
+ elementMapping.getElementData());
+
+ // attributeData is found
+ if ((attributeData != null)
+ && (attributeData.getSourceAttr() != null)) {
+ return attributeData.getSourceAttr();
+ } else
+ return elementMapping.getSourceNode();
+
+ }
+
+ return null;
+
+ }
+
}
\ No newline at end of file
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesComboBoxTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesComboBoxTemplate.java 2008-06-25
18:32:58 UTC (rev 8946)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesComboBoxTemplate.java 2008-06-25
18:47:49 UTC (rev 8947)
@@ -20,8 +20,7 @@
import org.jboss.tools.jsf.vpe.richfaces.HtmlComponentUtil;
import org.jboss.tools.jsf.vpe.richfaces.template.util.RichFaces;
import org.jboss.tools.vpe.editor.context.VpePageContext;
-import org.jboss.tools.vpe.editor.mapping.AttributeData;
-import org.jboss.tools.vpe.editor.mapping.NodeData;
+import org.jboss.tools.vpe.editor.mapping.VpeAttributeData;
import org.jboss.tools.vpe.editor.mapping.VpeElementData;
import org.jboss.tools.vpe.editor.template.VpeCreationData;
import org.jboss.tools.vpe.editor.util.HTML;
@@ -253,9 +252,9 @@
inputElement.setAttribute(HTML.ATTR_VALUE, getInputValue(sourceElement));
if ((sourceElement).hasAttribute(RichFaces.ATTR_VALUE)) {
- elementData.addNodeData(new
AttributeData(sourceElement.getAttributeNode(RichFaces.ATTR_VALUE), inputElement, true));
+ elementData.addAttributeData(new
VpeAttributeData(sourceElement.getAttributeNode(RichFaces.ATTR_VALUE), inputElement,
true));
} else {
- elementData.addNodeData(new AttributeData(RichFaces.ATTR_VALUE, inputElement,
true));
+ elementData.addAttributeData(new VpeAttributeData(RichFaces.ATTR_VALUE,
inputElement, true));
}
return inputElement;
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesInputNumberSpinnerTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesInputNumberSpinnerTemplate.java 2008-06-25
18:32:58 UTC (rev 8946)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesInputNumberSpinnerTemplate.java 2008-06-25
18:47:49 UTC (rev 8947)
@@ -14,8 +14,7 @@
import org.jboss.tools.jsf.vpe.richfaces.HtmlComponentUtil;
import org.jboss.tools.jsf.vpe.richfaces.template.util.RichFaces;
import org.jboss.tools.vpe.editor.context.VpePageContext;
-import org.jboss.tools.vpe.editor.mapping.AttributeData;
-import org.jboss.tools.vpe.editor.mapping.NodeData;
+import org.jboss.tools.vpe.editor.mapping.VpeAttributeData;
import org.jboss.tools.vpe.editor.mapping.VpeElementData;
import org.jboss.tools.vpe.editor.template.VpeCreationData;
import org.jboss.tools.vpe.editor.util.HTML;
@@ -188,10 +187,10 @@
.setAttribute(HTML.ATTR_VALUE, getInputValue(sourceElement));
if ((sourceElement).hasAttribute(RichFaces.ATTR_VALUE)) {
- elementData.addNodeData(new NodeData(sourceElement
+ elementData.addAttributeData(new VpeAttributeData(sourceElement
.getAttributeNode(RichFaces.ATTR_VALUE), inputElement, true));
} else {
- elementData.addNodeData(new AttributeData(
+ elementData.addAttributeData(new VpeAttributeData(
RichFaces.ATTR_VALUE, inputElement, true));
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2008-06-25
18:32:58 UTC (rev 8946)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2008-06-25
18:47:49 UTC (rev 8947)
@@ -127,10 +127,7 @@
import org.jboss.tools.vpe.editor.mozilla.MozillaEditor;
import org.jboss.tools.vpe.editor.selection.VpeSelectionController;
import org.jboss.tools.vpe.editor.selection.VpeSelectionHelper;
-import org.jboss.tools.vpe.editor.template.IKeyEventHandler;
-import org.jboss.tools.vpe.editor.template.ISelectionManager;
-import org.jboss.tools.vpe.editor.template.KeyEventManager;
-import org.jboss.tools.vpe.editor.template.SelectionManager;
+import org.jboss.tools.vpe.editor.template.ITemplateSelectionManager;
import org.jboss.tools.vpe.editor.template.VpeAnyData;
import org.jboss.tools.vpe.editor.template.VpeEditAnyDialog;
import org.jboss.tools.vpe.editor.template.VpeHtmlTemplate;
@@ -140,7 +137,8 @@
import org.jboss.tools.vpe.editor.template.VpeTemplateManager;
import org.jboss.tools.vpe.editor.toolbar.format.FormatControllerManager;
import org.jboss.tools.vpe.editor.util.DocTypeUtil;
-import org.jboss.tools.vpe.editor.util.SelectionUtil;
+import org.jboss.tools.vpe.editor.util.TemplateManagingUtil;
+import org.jboss.tools.vpe.editor.util.TextUtil;
import org.jboss.tools.vpe.editor.util.VisualDomUtil;
import org.jboss.tools.vpe.editor.util.VpeDndUtil;
import org.jboss.tools.vpe.messages.VpeUIMessages;
@@ -167,391 +165,355 @@
import org.w3c.dom.Text;
public class VpeController implements INodeAdapter, IModelLifecycleListener,
- INodeSelectionListener, ITextSelectionListener, SelectionListener,
- EditorDomEventListener, VpeTemplateListener, XModelTreeListener,
- ResourceReferenceListListener, ISelectionChangedListener,
- IVisualController {
+ INodeSelectionListener, ITextSelectionListener, SelectionListener,
+ EditorDomEventListener, VpeTemplateListener, XModelTreeListener,
+ ResourceReferenceListListener, ISelectionChangedListener,
+ IVisualController {
private boolean visualEditorVisible = true;
- private boolean synced = true;
- StructuredTextEditor sourceEditor;
- private MozillaEditor visualEditor;
- // MozillaBrowser browser;
- XulRunnerEditor xulRunnerEditor;
- // TODO Sergey Vasilyev figure out with nsIPressShell
- // private nsIPresShell presShell;
- // TODO Max Areshkau figure out with nsISelectionController
- private VpeSelectionController visualSelectionController;
- VpeDomMapping domMapping;
- private VpeTemplateManager templateManager;
- private VpeSourceDomBuilder sourceBuilder;
- private VpeVisualDomBuilder visualBuilder;
- /**
- * @deprecated
- */
- private VpeSelectionBuilder selectionBuilder;
- // private VpeVisualKeyHandler visualKeyHandler;
- private ActiveEditorSwitcher switcher = new ActiveEditorSwitcher();
- private Attr lastRemovedAttr;
- private String lastRemovedAttrName;
- private boolean mouseUpSelectionReasonFlag;
- private boolean mouseDownSelectionFlag;
- private boolean sourceChangeFlag;
- private VpePageContext pageContext;
- private BundleMap bundle;
- private VpeEditorPart editPart;
- private static final int AROUND_MENU = 1;
- private static final int BEFORE_MENU = 2;
- private static final int AFTER_MENU = 3;
+ private boolean synced = true;
+ StructuredTextEditor sourceEditor;
+ private MozillaEditor visualEditor;
+ // MozillaBrowser browser;
+ XulRunnerEditor xulRunnerEditor;
+ // TODO Sergey Vasilyev figure out with nsIPressShell
+ // private nsIPresShell presShell;
+ // TODO Max Areshkau figure out with nsISelectionController
+ private VpeSelectionController visualSelectionController;
+ VpeDomMapping domMapping;
+ private VpeTemplateManager templateManager;
+ private VpeSourceDomBuilder sourceBuilder;
+ private VpeVisualDomBuilder visualBuilder;
+ private VpeSelectionBuilder selectionBuilder;
+ private VpeVisualKeyHandler visualKeyHandler;
+ private ActiveEditorSwitcher switcher = new ActiveEditorSwitcher();
+ private Attr lastRemovedAttr;
+ private String lastRemovedAttrName;
+ private boolean mouseUpSelectionReasonFlag;
+ private boolean mouseDownSelectionFlag;
+ private boolean sourceChangeFlag;
+ private VpePageContext pageContext;
+ private BundleMap bundle;
+ private VpeEditorPart editPart;
+ private static final int AROUND_MENU = 1;
+ private static final int BEFORE_MENU = 2;
+ private static final int AFTER_MENU = 3;
- private CSSReferenceList cssReferenceListListener;
- private TaglibReferenceList taglibReferenceListListener;
- private AbsoluteFolderReferenceList absoluteFolderReferenceListListener;
- private RelativeFolderReferenceList relativeFolderReferenceListListener;
- private VpeIncludeList includeList = new VpeIncludeList();
- private VpeVisualInnerDragInfo innerDragInfo = null;
- private FormatControllerManager toolbarFormatControllerManager = null;
- private SelectionBar selectionBar = null;
- private XModelTreeListenerSWTSync optionsListener;
- // Added by Max Areshkau Fix for JBIDE-1479
- private UIJob job = null;
- private IProgressMonitor progressMonitor;
+ private CSSReferenceList cssReferenceListListener;
+ private TaglibReferenceList taglibReferenceListListener;
+ private AbsoluteFolderReferenceList absoluteFolderReferenceListListener;
+ private RelativeFolderReferenceList relativeFolderReferenceListListener;
+ private VpeIncludeList includeList = new VpeIncludeList();
+ private VpeVisualInnerDragInfo innerDragInfo = null;
+ private FormatControllerManager toolbarFormatControllerManager = null;
+ private SelectionBar selectionBar = null;
+ private XModelTreeListenerSWTSync optionsListener;
+ // Added by Max Areshkau Fix for JBIDE-1479
+ private UIJob job = null;
+ private IProgressMonitor progressMonitor;
private UIJob uiJob;
- // JBIDE-675, visual refresh job
+ //JBIDE-675, visual refresh job
private UIJob visualRefresfJob;
-
+
/**
- * Added by Max Areshkau JBIDE-675, stores information about modification
- * events
+ * Added by Max Areshkau
+ * JBIDE-675, stores information about modification events
*/
private LinkedList<VpeEventBean> changeEvents;
+
+ Shell tip;
- Shell tip;
+ public final static String MODEL_FLAVOR = ModelTransfer.MODEL;
- /**
- * selectionManager is used for management of selection
- */
- private ISelectionManager selectionManager;
+ public VpeController(VpeEditorPart editPart) {
- /**
- * keyEventHandler is used for management of key events
- */
- private IKeyEventHandler keyEventHandler;
+ this.editPart = editPart;
+ dropWindow = new VpeDropWindow(editPart.getSite().getShell());
+ }
- public final static String MODEL_FLAVOR = ModelTransfer.MODEL;
-
- public VpeController(VpeEditorPart editPart) {
-
- this.editPart = editPart;
- dropWindow = new VpeDropWindow(editPart.getSite().getShell());
+ void init(StructuredTextEditor sourceEditor, MozillaEditor visualEditor)
+ throws Exception {
+ this.sourceEditor = sourceEditor;
+ if (sourceEditor instanceof IJSPTextEditor) {
+ ((IJSPTextEditor) sourceEditor).setVPEController(this);
+ dropWindow.setEditor((IJSPTextEditor) sourceEditor);
}
+ this.visualEditor = visualEditor;
+ visualEditor.setController(this);
+ templateManager = VpeTemplateManager.getInstance();
+ bundle = new BundleMap();
+ bundle.init(sourceEditor);
+ pageContext = new VpePageContext(templateManager, bundle, editPart);
+ domMapping = new VpeDomMapping(pageContext);
+ sourceBuilder = new VpeSourceDomBuilder(domMapping, this,
+ templateManager, sourceEditor, pageContext);
+ visualBuilder = new VpeVisualDomBuilder(domMapping, this,
+ templateManager, visualEditor, pageContext);
+ pageContext.setSourceDomBuilder(sourceBuilder);
+ pageContext.setVisualDomBuilder(visualBuilder);
+ IDOMModel sourceModel = (IDOMModel) getModel();
+ if (sourceModel == null) {
+ return;
+ }
+ sourceModel.addModelLifecycleListener(this);
+ IDOMDocument sourceDocument = sourceModel.getDocument();
+ visualBuilder.refreshExternalLinks();
+ visualBuilder.buildDom(sourceDocument);
- void init(StructuredTextEditor sourceEditor, MozillaEditor visualEditor)
- throws Exception {
- this.sourceEditor = sourceEditor;
- if (sourceEditor instanceof IJSPTextEditor) {
- ((IJSPTextEditor) sourceEditor).setVPEController(this);
- dropWindow.setEditor((IJSPTextEditor) sourceEditor);
- }
- this.visualEditor = visualEditor;
- visualEditor.setController(this);
- templateManager = VpeTemplateManager.getInstance();
- bundle = new BundleMap();
- bundle.init(sourceEditor);
- pageContext = new VpePageContext(templateManager, bundle, editPart);
- domMapping = new VpeDomMapping(pageContext);
- sourceBuilder = new VpeSourceDomBuilder(domMapping, this,
- templateManager, sourceEditor, pageContext);
- visualBuilder = new VpeVisualDomBuilder(domMapping, this,
- templateManager, visualEditor, pageContext);
- pageContext.setSourceDomBuilder(sourceBuilder);
- pageContext.setVisualDomBuilder(visualBuilder);
- IDOMModel sourceModel = (IDOMModel) getModel();
- if (sourceModel == null) {
- return;
- }
- sourceModel.addModelLifecycleListener(this);
- IDOMDocument sourceDocument = sourceModel.getDocument();
- visualBuilder.refreshExternalLinks();
- visualBuilder.buildDom(sourceDocument);
+ templateManager.addTemplateListener(this);
- templateManager.addTemplateListener(this);
+ xulRunnerEditor = visualEditor.getXulRunnerEditor();
+ // TODO Sergey Vasilyev figure out with nsIPressShell
+ // presShell = browser.getPresShell();
+ visualSelectionController = new VpeSelectionController(xulRunnerEditor
+ .getSelection());
+ selectionBuilder = new VpeSelectionBuilder(domMapping, sourceBuilder,
+ visualBuilder, visualSelectionController);
+ visualKeyHandler = new VpeVisualKeyHandler(sourceEditor, domMapping,
+ pageContext) {
+ public void doSave(IProgressMonitor monitor) {
+ editPart.doSave(monitor);
+ }
+ };
- xulRunnerEditor = visualEditor.getXulRunnerEditor();
- // TODO Sergey Vasilyev figure out with nsIPressShell
- // presShell = browser.getPresShell();
- visualSelectionController = new VpeSelectionController(xulRunnerEditor
- .getSelection());
+ // glory
+ ISelectionProvider provider = sourceEditor.getSelectionProvider();
+ // Max Areshkau JBIDE-1105 If selection event received after selection
+ // in
+ // visual part we lost focus of selection, so we should process
+ // selection event
+ // in time of selection
+ // if (provider instanceof IPostSelectionProvider)
+ // ((IPostSelectionProvider)
+ // provider).addPostSelectionChangedListener(this);
+ // else
+ provider.addSelectionChangedListener(this);
- selectionBuilder = new VpeSelectionBuilder(domMapping, sourceBuilder,
- visualBuilder, visualSelectionController);
+ // ViewerSelectionManager selectionManager =
+ // sourceEditor.getViewerSelectionManager();
+ // selectionManager.addNodeSelectionListener(this);
+ // selectionManager.addTextSelectionListener(this);
+ StyledText textWidget = VpeSelectionHelper
+ .getSourceTextWidget(sourceEditor);
+ if (textWidget != null) {
+ textWidget.addSelectionListener(this);
+ }
- selectionManager = new SelectionManager(pageContext,
- sourceEditor, visualSelectionController);
+ visualEditor.setEditorDomEventListener(this);
+ switcher.initActiveEditor();
- keyEventHandler = new KeyEventManager(sourceEditor, domMapping,
- pageContext);
+ if (optionsListener == null) {
+ XModelObject optionsObject = ModelUtilities.getPreferenceModel()
+ .getByPath(VpePreference.EDITOR_PATH);
+ optionsListener = new XModelTreeListenerSWTSync(this);
+ optionsObject.getModel().addModelTreeListener(optionsListener);
+ }
- // visualKeyHandler = new VpeVisualKeyHandler(sourceEditor, domMapping,
- // pageContext) {
- // public void doSave(IProgressMonitor monitor) {
- // editPart.doSave(monitor);
- // }
- // };
+ cssReferenceListListener = CSSReferenceList.getInstance();
+ cssReferenceListListener.addChangeListener(this);
- // glory
- ISelectionProvider provider = sourceEditor.getSelectionProvider();
- // Max Areshkau JBIDE-1105 If selection event received after selection
- // in
- // visual part we lost focus of selection, so we should process
- // selection event
- // in time of selection
- // if (provider instanceof IPostSelectionProvider)
- // ((IPostSelectionProvider)
- // provider).addPostSelectionChangedListener(this);
- // else
- provider.addSelectionChangedListener(this);
+ taglibReferenceListListener = TaglibReferenceList.getInstance();
+ taglibReferenceListListener.addChangeListener(this);
- // ViewerSelectionManager selectionManager =
- // sourceEditor.getViewerSelectionManager();
- // selectionManager.addNodeSelectionListener(this);
- // selectionManager.addTextSelectionListener(this);
- StyledText textWidget = VpeSelectionHelper
- .getSourceTextWidget(sourceEditor);
- if (textWidget != null) {
- textWidget.addSelectionListener(this);
- }
+ absoluteFolderReferenceListListener = AbsoluteFolderReferenceList
+ .getInstance();
+ absoluteFolderReferenceListListener.addChangeListener(this);
- visualEditor.setEditorDomEventListener(this);
- switcher.initActiveEditor();
+ relativeFolderReferenceListListener = RelativeFolderReferenceList
+ .getInstance();
+ relativeFolderReferenceListListener.addChangeListener(this);
- if (optionsListener == null) {
- XModelObject optionsObject = ModelUtilities.getPreferenceModel()
- .getByPath(VpePreference.EDITOR_PATH);
- optionsListener = new XModelTreeListenerSWTSync(this);
- optionsObject.getModel().addModelTreeListener(optionsListener);
- }
+ // pageContext.fireTaglibsChanged();
+ }
- cssReferenceListListener = CSSReferenceList.getInstance();
- cssReferenceListListener.addChangeListener(this);
-
- taglibReferenceListListener = TaglibReferenceList.getInstance();
- taglibReferenceListListener.addChangeListener(this);
-
- absoluteFolderReferenceListListener = AbsoluteFolderReferenceList
- .getInstance();
- absoluteFolderReferenceListListener.addChangeListener(this);
-
- relativeFolderReferenceListListener = RelativeFolderReferenceList
- .getInstance();
- relativeFolderReferenceListListener.addChangeListener(this);
-
- // pageContext.fireTaglibsChanged();
- }
-
- public void dispose() {
-
- if (job != null) {
+ public void dispose() {
+
+ if (job != null) {
job.cancel();
job = null;
}
+
+ if(uiJob!=null) {
+ uiJob.cancel();
+ getChangeEvents().clear();
+ uiJob=null;
+ }
+
+ if(visualRefresfJob!=null) {
+ visualRefresfJob.cancel();
+ visualRefresfJob=null;
+ }
+
+ if (optionsListener != null) {
+ XModelObject optionsObject = ModelUtilities.getPreferenceModel()
+ .getByPath(VpePreference.EDITOR_PATH);
+ optionsObject.getModel().removeModelTreeListener(optionsListener);
+ optionsListener.dispose();
+ optionsListener = null;
+ }
+ IDOMModel sourceModel = (IDOMModel) getModel();
+ if (sourceModel != null) {
+ sourceModel.removeModelLifecycleListener(this);
+ }
+ switcher.destroyActiveEditor();
+ switcher = null;
- if (uiJob != null) {
- uiJob.cancel();
- getChangeEvents().clear();
- uiJob = null;
- }
+ if (templateManager != null) {
+ templateManager.removeTemplateListener(this);
+ templateManager = null;
+ }
+ if (visualBuilder != null) {
+ visualBuilder.dispose();
+ visualBuilder = null;
+ }
+ sourceBuilder = null;
+ if (sourceEditor != null) {
+ // glory
+ ISelectionProvider provider = sourceEditor.getSelectionProvider();
+ provider.removeSelectionChangedListener(this);
+ // ViewerSelectionManager selectionManager =
+ // sourceEditor.getViewerSelectionManager();
+ // selectionManager.removeNodeSelectionListener(this);
+ // selectionManager.removeTextSelectionListener(this);
+ StyledText textWidget = VpeSelectionHelper
+ .getSourceTextWidget(sourceEditor);
+ if (textWidget != null) {
+ textWidget.removeSelectionListener(this);
+ }
+ ((IJSPTextEditor) sourceEditor).setVPEController(null);
- if (visualRefresfJob != null) {
- visualRefresfJob.cancel();
- visualRefresfJob = null;
- }
-
- if (optionsListener != null) {
- XModelObject optionsObject = ModelUtilities.getPreferenceModel()
- .getByPath(VpePreference.EDITOR_PATH);
- optionsObject.getModel().removeModelTreeListener(optionsListener);
- optionsListener.dispose();
- optionsListener = null;
- }
- IDOMModel sourceModel = (IDOMModel) getModel();
- if (sourceModel != null) {
- sourceModel.removeModelLifecycleListener(this);
- }
- switcher.destroyActiveEditor();
- switcher = null;
-
- if (templateManager != null) {
- templateManager.removeTemplateListener(this);
- templateManager = null;
- }
- if (visualBuilder != null) {
- visualBuilder.dispose();
- visualBuilder = null;
- }
- sourceBuilder = null;
- if (sourceEditor != null) {
- // glory
- ISelectionProvider provider = sourceEditor.getSelectionProvider();
- provider.removeSelectionChangedListener(this);
- // ViewerSelectionManager selectionManager =
- // sourceEditor.getViewerSelectionManager();
- // selectionManager.removeNodeSelectionListener(this);
- // selectionManager.removeTextSelectionListener(this);
- StyledText textWidget = VpeSelectionHelper
- .getSourceTextWidget(sourceEditor);
- if (textWidget != null) {
- textWidget.removeSelectionListener(this);
- }
- ((IJSPTextEditor) sourceEditor).setVPEController(null);
-
- }
- if (dropWindow != null) {
- dropWindow.setEditor(null);
- }
- if (visualEditor != null) {
- visualEditor.setEditorDomEventListener(null);
- if (visualSelectionController != null) {
- // visualSelectionController.Release();
- visualSelectionController = null;
- }
- // TODO Sergey Vasilyev figure out with Press Shell
- // if (presShell != null) {
- // presShell.Release();
- // presShell = null;
- // }
- visualEditor = null;
- }
-
- if (cssReferenceListListener != null) {
- cssReferenceListListener.removeChangeListener(this);
- }
- if (taglibReferenceListListener != null) {
- taglibReferenceListListener.removeChangeListener(this);
- }
- if (absoluteFolderReferenceListListener != null) {
- absoluteFolderReferenceListListener.removeChangeListener(this);
- }
- if (relativeFolderReferenceListListener != null) {
- relativeFolderReferenceListListener.removeChangeListener(this);
- }
- toolbarFormatControllerManager = null;
}
+ if (dropWindow != null) {
+ dropWindow.setEditor(null);
+ }
+ if (visualEditor != null) {
+ visualEditor.setEditorDomEventListener(null);
+ if (visualSelectionController != null) {
+ // visualSelectionController.Release();
+ visualSelectionController = null;
+ }
+ // TODO Sergey Vasilyev figure out with Press Shell
+ // if (presShell != null) {
+ // presShell.Release();
+ // presShell = null;
+ // }
+ visualEditor = null;
+ }
- // INodeAdapter implementation
- public boolean isAdapterForType(Object type) {
- return type == this;
+ if (cssReferenceListListener != null) {
+ cssReferenceListListener.removeChangeListener(this);
}
+ if (taglibReferenceListListener != null) {
+ taglibReferenceListListener.removeChangeListener(this);
+ }
+ if (absoluteFolderReferenceListListener != null) {
+ absoluteFolderReferenceListListener.removeChangeListener(this);
+ }
+ if (relativeFolderReferenceListListener != null) {
+ relativeFolderReferenceListListener.removeChangeListener(this);
+ }
+ toolbarFormatControllerManager = null;
+ }
- // FIX Fox JBIDE-1479 added by Max Areshkau
- public void notifyChanged(final INodeNotifier notifier,
- final int eventType, final Object feature, final Object oldValue,
- final Object newValue, final int pos) {
+ // INodeAdapter implementation
+ public boolean isAdapterForType(Object type) {
+ return type == this;
+ }
+ // FIX Fox JBIDE-1479 added by Max Areshkau
+ public void notifyChanged(final INodeNotifier notifier,
+ final int eventType, final Object feature, final Object oldValue,
+ final Object newValue, final int pos) {
- if (!visualEditorVisible) {
- synced = false;
- return;
- }
+ if (!visualEditorVisible) {
+ synced = false;
+ return;
+ }
- // start job when we modify file in ui thread, without this code
- // changes will be applied with 1 second delay
- Display display = null;
- if (PlatformUI.isWorkbenchRunning())
- display = PlatformUI.getWorkbench().getDisplay();
+ // start job when we modify file in ui thread, without this code
+ // changes will be applied with 1 second delay
+ Display display = null;
+ if (PlatformUI.isWorkbenchRunning())
+ display = PlatformUI.getWorkbench().getDisplay();
- if (display != null && (Thread.currentThread() == display.getThread())) {
+ if (display != null && (Thread.currentThread() == display.getThread())) {
- getChangeEvents().addLast(
- new VpeEventBean(notifier, eventType, feature, oldValue,
- newValue, pos));
- if (uiJob == null) {
- uiJob = new UIJob(VpeUIMessages.VPE_UPDATE_JOB_TITLE) {
- @Override
- public IStatus runInUIThread(IProgressMonitor monitor) {
+ getChangeEvents().addLast(new VpeEventBean(notifier, eventType, feature,
oldValue,newValue, pos));
+ if(uiJob==null) {
+ uiJob = new UIJob(VpeUIMessages.VPE_UPDATE_JOB_TITLE){
+ @Override
+ public IStatus runInUIThread(IProgressMonitor monitor) {
- monitor.beginTask(VpeUIMessages.VPE_UPDATE_JOB_TITLE,
- 100);
- while (getChangeEvents().size() > 0) {
+ monitor.beginTask(VpeUIMessages.VPE_UPDATE_JOB_TITLE, 100);
+ while(getChangeEvents().size()>0) {
- monitor.worked((int) (100 / getChangeEvents()
- .size()));
- VpeEventBean eventBean = getChangeEvents()
- .getFirst();
- if (monitor.isCanceled()) {
- getChangeEvents().clear();
- return Status.CANCEL_STATUS;
- }
- try {
- notifyChangedInUiThread(
- eventBean.getNotifier(), eventBean
- .getEventType(), eventBean
- .getFeature(), eventBean
- .getOldValue(), eventBean
- .getNewValue(), eventBean
- .getPos());
- } catch (VpeDisposeException ex) {
- // JBIDE-675 we will get this exception if user
- // close editor,
- // when update visual editor job is running, we
- // 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
- }
- }
- getChangeEvents().remove(eventBean);
+ monitor.worked((int)(100/getChangeEvents().size()));
+ VpeEventBean eventBean = getChangeEvents().getFirst();
+ if (monitor.isCanceled()) {
+ getChangeEvents().clear();
+ return Status.CANCEL_STATUS;
+ }
+ try {
+ notifyChangedInUiThread(eventBean.getNotifier(), eventBean.getEventType(),
+ eventBean.getFeature(), eventBean.getOldValue(), eventBean.getNewValue(),
+ eventBean.getPos());
+ } catch (VpeDisposeException ex) {
+ //JBIDE-675 we will get this exception if user close editor,
+ //when update visual editor job is running, we 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
}
+ }
+ getChangeEvents().remove(eventBean);
+ }
+ monitor.done();
+
+ return Status.OK_STATUS;
+ }
+
+ };
+ }
- sourceSelectionChanged();
- monitor.done();
+ if(uiJob.getState()!=Job.RUNNING) {
+
+ uiJob.setPriority(Job.LONG);
+ //Fix of JBIDE-1900
+ uiJob.cancel();
+ uiJob.schedule(400L);
+ }
+
+ return;
+ }
+ // start job when we modify file in non ui thread
+ if (job != null) {
+ job.cancel();
+ }
- return Status.OK_STATUS;
- }
+ job = new UIJob("NotifyChangedJob") {
+ @Override
+ public IStatus runInUIThread(IProgressMonitor monitor) {
+ // we checks is job was canceled and if is it true we cancel job
+ if (monitor.isCanceled()) {
+ return Status.CANCEL_STATUS;
+ } else {
+ notifyChangedInUiThread(notifier, eventType, feature,
+ oldValue, newValue, pos);
+ }
+ return Status.OK_STATUS;
+ }
+ };
+ job.setPriority(Job.LONG);
+ job.schedule(1000L);
+ }
- };
- }
-
- if (uiJob.getState() != Job.RUNNING) {
-
- uiJob.setPriority(Job.LONG);
- // Fix of JBIDE-1900
- uiJob.cancel();
- uiJob.schedule(400L);
- }
-
- return;
- }
- // start job when we modify file in non ui thread
- if (job != null) {
- job.cancel();
- }
-
- job = new UIJob("NotifyChangedJob") {
- @Override
- public IStatus runInUIThread(IProgressMonitor monitor) {
- // we checks is job was canceled and if is it true we cancel job
- if (monitor.isCanceled()) {
- return Status.CANCEL_STATUS;
- } else {
- notifyChangedInUiThread(notifier, eventType, feature,
- oldValue, newValue, pos);
- }
- return Status.OK_STATUS;
- }
- };
- job.setPriority(Job.LONG);
- job.schedule(1000L);
- }
-
- public void notifyChangedInUiThread(INodeNotifier notifier, int eventType,
+
+ public void notifyChangedInUiThread(INodeNotifier notifier, int eventType,
Object feature, Object oldValue, Object newValue, int pos) {
if (switcher == null
|| !switcher
@@ -641,21 +603,22 @@
}
break;
}
- } finally {
- // fix for jbide-675, swithcer is null when vpecontroller is
- // disposed
-
- if (switcher != null) {
+ }
+ finally {
+ //fix for jbide-675, swithcer is null when vpecontroller is disposed
+
+ if(switcher!=null) {
+
switcher.stopActiveEditor();
} else {
-
+
throw new VpeDisposeException("VpeController already disposed");
}
}
}
- // INodeSelectionListener implementation
- public void nodeSelectionChanged(NodeSelectionChangedEvent event) {
+ // INodeSelectionListener implementation
+ public void nodeSelectionChanged(NodeSelectionChangedEvent event) {
if (!switcher
.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
return;
@@ -679,9 +642,9 @@
}
}
- // ITextSelectionListener implementation
- // TODO Max Areshau looks like this method don't used
- public void textSelectionChanged(TextSelectionChangedEvent event) {
+ // 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;
@@ -701,8 +664,8 @@
}
}
- // SelectionListener implementation
- public void widgetSelected(SelectionEvent event) {
+ // SelectionListener implementation
+ public void widgetSelected(SelectionEvent event) {
if (!switcher
.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
return;
@@ -721,117 +684,109 @@
}
}
- public void widgetDefaultSelected(SelectionEvent event) {
- if (VpeDebug.PRINT_SOURCE_SELECTION_EVENT) {
- System.out.println(">>>>>>>>>>>>>>
widgetDefaultSelected"); //$NON-NLS-1$
- }
+ public void widgetDefaultSelected(SelectionEvent event) {
+ if (VpeDebug.PRINT_SOURCE_SELECTION_EVENT) {
+ System.out.println(">>>>>>>>>>>>>>
widgetDefaultSelected"); //$NON-NLS-1$
}
+ }
- public void sourceSelectionChanged() {
- sourceSelectionChanged(false);
- }
+ public void sourceSelectionChanged() {
+ sourceSelectionChanged(false);
+ }
- public void sourceSelectionChanged(boolean showCaret) {
+ public void sourceSelectionChanged(boolean showCaret) {
+
+ //we should processed if we have correct view in visual editor,
+ //otherwise we shouldn't process this event
+ if(getChangeEvents().size()>0) {
+
+ return;
+ }
+
+ Point range = sourceEditor.getTextViewer().getSelectedRange();
+ int anchorPosition = range.x;
+ int focusPosition = range.x + range.y;
- // we should processed if we have correct view in visual editor,
- // otherwise we shouldn't process this event
- if (getChangeEvents().size() > 0) {
+ boolean extendFlag = range.y != 0;
+ boolean reversionFlag = extendFlag
+ && anchorPosition == VpeSelectionHelper
+ .getCaretOffset(sourceEditor);
+ if (reversionFlag) {
+ anchorPosition = focusPosition;
+ focusPosition = range.x;
+ }
- return;
- }
+ VpeTemplate template = TemplateManagingUtil
+ .getTemplateBySourceSelection(pageContext, focusPosition,
+ anchorPosition);
-// 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 (template instanceof ITemplateSelectionManager) {
+ ((ITemplateSelectionManager) template).setSelectionBySource(
+ pageContext, visualSelectionController, focusPosition,
+ anchorPosition);
+ return;
+ }
- try {
+ 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;
+ }
- selectionManager.refreshVisualSelection();
-
- } catch (Exception ex) {
- VpePlugin.reportProblem(ex);
+ 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();
}
-
- // 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);
+ 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);
}
- public void sourceSelectionToVisualSelection(boolean showCaret) {
+ selectionBuilder.setVisualSelection(anchorNode, anchorOffset,
+ focusNode, focusOffset, reversionFlag, showCaret);
+ }
+
+ public void sourceSelectionToVisualSelection(boolean showCaret) {
if (!switcher
.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
return;
@@ -845,11 +800,11 @@
}
}
- // IModelLifecycleListener implementation
- public void processPreModelEvent(ModelLifecycleEvent event) {
- }
+ // IModelLifecycleListener implementation
+ public void processPreModelEvent(ModelLifecycleEvent event) {
+ }
- public void processPostModelEvent(ModelLifecycleEvent event) {
+ public void processPostModelEvent(ModelLifecycleEvent event) {
if (!switcher
.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
return;
@@ -891,8 +846,8 @@
}
}
- // EditorDomEventListener implementation
- public void subtreeModified(nsIDOMMutationEvent mutationEvent) {
+ // EditorDomEventListener implementation
+ public void subtreeModified(nsIDOMMutationEvent mutationEvent) {
if (!switcher
.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
return;
@@ -908,7 +863,7 @@
}
}
- public void nodeInserted(nsIDOMMutationEvent mutationEvent) {
+ public void nodeInserted(nsIDOMMutationEvent mutationEvent) {
if (!switcher
.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
return;
@@ -929,7 +884,7 @@
}
}
- public void nodeRemoved(nsIDOMMutationEvent mutationEvent) {
+ public void nodeRemoved(nsIDOMMutationEvent mutationEvent) {
if (!switcher
.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
return;
@@ -951,7 +906,7 @@
}
}
- public void nodeRemovedFromDocument(nsIDOMMutationEvent mutationEvent) {
+ public void nodeRemovedFromDocument(nsIDOMMutationEvent mutationEvent) {
if (!switcher
.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
return;
@@ -967,7 +922,7 @@
}
}
- public void nodeInsertedIntoDocument(nsIDOMMutationEvent mutationEvent) {
+ public void nodeInsertedIntoDocument(nsIDOMMutationEvent mutationEvent) {
if (!switcher
.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
return;
@@ -983,42 +938,42 @@
}
}
- public void attrModified(nsIDOMMutationEvent mutationEvent) {
- if (!switcher
- .startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
- return;
- }
- try {
- if (VpeDebug.PRINT_VISUAL_MUTATION_EVENT) {
- printVisualEvent(mutationEvent);
- }
- } catch (Exception e) {
- VpePlugin.reportProblem(e);
- } finally {
- switcher.stopActiveEditor();
- }
- }
+ public void attrModified(nsIDOMMutationEvent mutationEvent) {
+ if (!switcher
+ .startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
+ return;
+ }
+ try {
+ if (VpeDebug.PRINT_VISUAL_MUTATION_EVENT) {
+ printVisualEvent(mutationEvent);
+ }
+ } catch (Exception e) {
+ VpePlugin.reportProblem(e);
+ } finally {
+ switcher.stopActiveEditor();
+ }
+ }
- 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);
- } catch (Exception e) {
- VpePlugin.reportProblem(e);
- } finally {
- switcher.stopActiveEditor();
- }
- }
+ 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);
+ } catch (Exception e) {
+ VpePlugin.reportProblem(e);
+ } finally {
+ switcher.stopActiveEditor();
+ }
+ }
- public void notifySelectionChanged(nsIDOMDocument doc,
+ public void notifySelectionChanged(nsIDOMDocument doc,
nsISelection selection, short reason) {
if (switcher
.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
@@ -1026,24 +981,14 @@
mouseUpSelectionReasonFlag = (reason & nsISelectionListener.MOUSEUP_REASON) >
0;
if (mouseUpSelectionReasonFlag
|| reason == nsISelectionListener.NO_REASON
-// || reason == nsISelectionListener.KEYPRESS_REASON
+ || reason == nsISelectionListener.KEYPRESS_REASON
|| reason == nsISelectionListener.SELECTALL_REASON
|| (reason & nsISelectionListener.MOUSEDOWN_REASON) > 0) {
-
if (VpeDebug.PRINT_VISUAL_SELECTION_EVENT) {
System.out
.println("<<< notifySelectionChanged: " + reason);
//$NON-NLS-1$
-
}
-
- nsIDOMNode node = SelectionUtil.getSelectedNode(selection);
- if (node != null
- && node.getNodeType() == nsIDOMNode.TEXT_NODE) {
-
- // selectionBuilder.setSelection(selection);
-
- selectionManager.setSelection(selection);
- }
+ selectionBuilder.setSelection(selection);
}
} catch (Exception e) {
VpePlugin.reportProblem(e);
@@ -1053,82 +998,65 @@
}
}
- public void mouseDown(nsIDOMMouseEvent mouseEvent) {
+ public void mouseDown(nsIDOMMouseEvent mouseEvent) {
if (!switcher
.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
return;
}
try {
- // mouseDownSelectionFlag = false;
- // VpeTemplate template = TemplateManagingUtil
- // .getTemplateByVisualSelection(pageContext, VisualDomUtil
- // .getTargetNode(mouseEvent));
- // if (template instanceof ITemplateSelectionManager) {
- // ((ITemplateSelectionManager) template).setSelectionByMouse(
- // pageContext, visualSelectionController, mouseEvent);
- // mouseDownSelectionFlag = true;
- // } else {
- // nsIDOMElement visualDragElement = selectionBuilder
- // .getDragElement(mouseEvent);
- if (VpeDebug.PRINT_VISUAL_MOUSE_EVENT) {
- nsIDOMNode visualNode = VisualDomUtil.getTargetNode(mouseEvent);
- System.out.println("<<< mouseDown targetNode: " /*
- * +visualNode.
- * getNodeName()
- * + " (" +
- * visualNode +
- * ") selectedElement: "
- * +(
- * visualDragElement
- * != null ?
- * visualDragElement
- * .
- * getNodeName()
- * + " (" +
- * visualDragElement
- * + ")" : null)
- */); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
//$NON-NLS-5$
- }
- //
- // if (visualDragElement != null) {
- //
- // // we shouldn't change selection when we click on <input
- // // type="text" /> element,
- // // because if we change after resizing the input element
- // // lost
- // // selection
- // // if(!(HTML.TAG_INPUT.equalsIgnoreCase(visualDragElement.
- // // getNodeName())&&
- // // HTML.ATTR_TEXT.equalsIgnoreCase(visualDragElement.
- // // getAttribute(HTML.ATTR_TYPE))
- // // &&visualDragElement.getAttribute(HTML.ATTR_TYPE)!=null))
- // // {
- //
- // selectionBuilder
- // .setVisualElementSelection(visualDragElement);
- // mouseDownSelectionFlag = true;
- // // }
- // } else {
- // selectionBuilder.setCaretAtMouse(mouseEvent);
- // }
- // }
+ mouseDownSelectionFlag = false;
+ VpeTemplate template = TemplateManagingUtil
+ .getTemplateByVisualSelection(pageContext, VisualDomUtil
+ .getTargetNode(mouseEvent));
+ if (template instanceof ITemplateSelectionManager) {
+ ((ITemplateSelectionManager) template).setSelectionByMouse(
+ pageContext, visualSelectionController, mouseEvent);
+ mouseDownSelectionFlag = true;
+ } else {
+ nsIDOMElement visualDragElement = selectionBuilder
+ .getDragElement(mouseEvent);
+ if (VpeDebug.PRINT_VISUAL_MOUSE_EVENT) {
+ nsIDOMNode visualNode = VisualDomUtil
+ .getTargetNode(mouseEvent);
+ System.out
+ .println("<<< mouseDown targetNode: " +
visualNode.getNodeName() + " (" + visualNode + ") selectedElement: "
+ (visualDragElement != null ? visualDragElement.getNodeName() + " (" +
visualDragElement + ")" : null)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
//$NON-NLS-4$ //$NON-NLS-5$
+ }
+ if (visualDragElement != null) {
- selectionManager.setSelection(mouseEvent);
- } catch (Exception e) {
+ // we shouldn't change selection when we click on <input
+ // type="text" /> element,
+ // because if we change after resizing the input element
+ // lost
+ // selection
+ // if(!(HTML.TAG_INPUT.equalsIgnoreCase(visualDragElement.
+ // getNodeName())&&
+ // HTML.ATTR_TEXT.equalsIgnoreCase(visualDragElement.
+ // getAttribute(HTML.ATTR_TYPE))
+ // &&visualDragElement.getAttribute(HTML.ATTR_TYPE)!=null))
+ // {
+ selectionBuilder
+ .setVisualElementSelection(visualDragElement);
+ mouseDownSelectionFlag = true;
+ // }
+ } else {
+ selectionBuilder.setCaretAtMouse(mouseEvent);
+ }
+ }
+ } catch (Exception e) {
+ VpePlugin.reportProblem(e);
} finally {
switcher.stopActiveEditor();
}
}
- public void mouseUp(nsIDOMMouseEvent mouseEvent) {
+ public void mouseUp(nsIDOMMouseEvent mouseEvent) {
if (!switcher
.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
return;
}
try {
-
if (VpeDebug.PRINT_VISUAL_MOUSE_EVENT) {
System.out.println("<<< mouseUp"); //$NON-NLS-1$
}
@@ -1144,39 +1072,39 @@
}
}
- public void mouseClick(nsIDOMMouseEvent mouseEvent) {
- if (!switcher
- .startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
- return;
- }
- try {
- nsIDOMNode visualNode = VisualDomUtil.getTargetNode(mouseEvent);
- if (visualNode != null) {
- if (!mouseUpSelectionReasonFlag) {
- if (VpeDebug.PRINT_VISUAL_MOUSE_EVENT) {
- System.out
- .println("<<< mouseClick visualNode: " +
visualNode.getNodeName() + " (" + visualNode + ")"); //$NON-NLS-1$
//$NON-NLS-2$ //$NON-NLS-3$
- }
- if (visualBuilder.isContentArea(visualNode)) {
- // selectionBuilder.setClickContentAreaSelection();
- }
- } else {
- mouseUpSelectionReasonFlag = false;
- }
+ public void mouseClick(nsIDOMMouseEvent mouseEvent) {
+ if (!switcher
+ .startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
+ return;
+ }
+ try {
+ nsIDOMNode visualNode = VisualDomUtil.getTargetNode(mouseEvent);
+ if (visualNode != null) {
+ if (!mouseUpSelectionReasonFlag) {
+ if (VpeDebug.PRINT_VISUAL_MOUSE_EVENT) {
+ System.out
+ .println("<<< mouseClick visualNode: " +
visualNode.getNodeName() + " (" + visualNode + ")"); //$NON-NLS-1$
//$NON-NLS-2$ //$NON-NLS-3$
+ }
+ if (visualBuilder.isContentArea(visualNode)) {
+ selectionBuilder.setClickContentAreaSelection();
+ }
+ } else {
+ mouseUpSelectionReasonFlag = false;
+ }
- if (visualBuilder.doToggle(VisualDomUtil
- .getTargetNode(mouseEvent))) {
- // selectionBuilder.setClickContentAreaSelection();
- }
- }
- } catch (Exception e) {
- VpePlugin.reportProblem(e);
- } finally {
- switcher.stopActiveEditor();
- }
- }
+ if (visualBuilder.doToggle(VisualDomUtil
+ .getTargetNode(mouseEvent))) {
+ selectionBuilder.setClickContentAreaSelection();
+ }
+ }
+ } catch (Exception e) {
+ VpePlugin.reportProblem(e);
+ } finally {
+ switcher.stopActiveEditor();
+ }
+ }
- public void mouseDblClick(nsIDOMMouseEvent mouseEvent) {
+ public void mouseDblClick(nsIDOMMouseEvent mouseEvent) {
if (!switcher
.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
return;
@@ -1191,7 +1119,6 @@
System.out
.println("<<< mouseDblClick visualNode: " +
visualNode.getNodeName() + " (" + visualNode + ")"); //$NON-NLS-1$
//$NON-NLS-2$ //$NON-NLS-3$
}
-
}
} catch (Exception e) {
VpePlugin.reportProblem(e);
@@ -1200,7 +1127,7 @@
}
}
- public void mouseMove(nsIDOMMouseEvent mouseEvent) {
+ public void mouseMove(nsIDOMMouseEvent mouseEvent) {
if (!switcher
.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
return;
@@ -1208,11 +1135,11 @@
try {
nsIDOMNode visualNode = VisualDomUtil.getTargetNode(mouseEvent);
if (visualNode != null) {
- // if (VpeDebug.PRINT_VISUAL_MOUSE_EVENT) {
- // System.out.println("<<< mouseMove visualNode: "
- // + visualNode.getNodeName() + " (" + visualNode
- // + ")");
- // }
+ if (VpeDebug.PRINT_VISUAL_MOUSE_EVENT) {
+ System.out.println("<<< mouseMove visualNode: "
+ + visualNode.getNodeName() + " (" + visualNode
+ + ")");
+ }
visualBuilder.setMoveCursor(mouseEvent);
}
} catch (Exception e) {
@@ -1222,7 +1149,7 @@
}
}
- public void keyPress(nsIDOMKeyEvent keyEvent) {
+ public void keyPress(nsIDOMKeyEvent keyEvent) {
if (VpeDebug.PRINT_VISUAL_KEY_EVENT) {
System.out
.println("<<< keyPress type: " + keyEvent.getType() + "
Ctrl: " + keyEvent.getCtrlKey() + " Shift: " + keyEvent.getShiftKey() +
" CharCode: " + keyEvent.getCharCode() + " KeyCode: " +
keyEvent.getKeyCode()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
//$NON-NLS-5$
@@ -1241,8 +1168,7 @@
}
try {
- if (/* visualKeyHandler.keyPressHandler(keyEvent) */keyEventHandler
- .handleKeyPress(keyEvent)) {
+ if (visualKeyHandler.keyPressHandler(keyEvent)) {
switcher
.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL);
try {
@@ -1256,7 +1182,7 @@
}
} else {
// adding calls of core event handlers, for example' CTR+H' or
- // ' CTRL+M' event handler dialog
+ //' CTRL+M' event handler dialog
Event keyboardEvent = new Event();
// widget where event occur
keyboardEvent.widget = xulRunnerEditor.getBrowser();
@@ -1317,357 +1243,357 @@
}
}
- public void elementResized(nsIDOMElement element, int resizerConstrains,
- int top, int left, int width, int height) {
- if (!switcher
- .startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
- return;
- }
- try {
- visualEditor.hideResizer();
- } catch (Exception e) {
- VpePlugin.reportProblem(e);
- } finally {
- switcher.stopActiveEditor();
- }
- visualBuilder.resize(element, resizerConstrains, top, left, width,
- height);
- sourceSelectionChanged();
- }
+ public void elementResized(nsIDOMElement element, int resizerConstrains,
+ int top, int left, int width, int height) {
+ if (!switcher
+ .startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
+ return;
+ }
+ try {
+ visualEditor.hideResizer();
+ } catch (Exception e) {
+ VpePlugin.reportProblem(e);
+ } finally {
+ switcher.stopActiveEditor();
+ }
+ visualBuilder.resize(element, resizerConstrains, top, left, width, height);
+ sourceSelectionChanged();
+ }
- public void dragGesture(nsIDOMEvent domEvent) {
+ public void dragGesture(nsIDOMEvent domEvent) {
- nsIDOMMouseEvent mouseEvent = (nsIDOMMouseEvent) domEvent
- .queryInterface(nsIDOMMouseEvent.NS_IDOMMOUSEEVENT_IID);
- boolean canDragFlag = canInnerDrag(mouseEvent);
- // start drag sessionvpe-element
- if (canDragFlag) {
- startDragSession(domEvent);
- }
+ nsIDOMMouseEvent mouseEvent = (nsIDOMMouseEvent) domEvent
+ .queryInterface(nsIDOMMouseEvent.NS_IDOMMOUSEEVENT_IID);
+ boolean canDragFlag = canInnerDrag(mouseEvent);
+ // start drag sessionvpe-element
+ if (canDragFlag) {
+ startDragSession(domEvent);
}
+ }
- private void createMenuForNode(Node node, MenuManager manager) {
- createMenuForNode(node, manager, false);
- }
+ private void createMenuForNode(Node node, MenuManager manager) {
+ createMenuForNode(node, manager, false);
+ }
- private void createMenuForNode(Node node, MenuManager manager,
- boolean topLevelFlag) {
- NodeActionManager.setTextNodeSplitter(null);
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- VpeElementMapping elementMapping = (VpeElementMapping) domMapping
- .getNodeMapping(node);
- if (elementMapping != null && elementMapping.getTemplate() != null) {
- manager.add(new VpeAction(
- "<" + node.getNodeName() + "> Attributes", node) {
//$NON-NLS-1$ //$NON-NLS-2$
- public void run() {
- showProperties(actionNode);
- }
- });
+ private void createMenuForNode(Node node, MenuManager manager,
+ boolean topLevelFlag) {
+ NodeActionManager.setTextNodeSplitter(null);
+ if (node.getNodeType() == Node.ELEMENT_NODE) {
+ VpeElementMapping elementMapping = (VpeElementMapping) domMapping
+ .getNodeMapping(node);
+ if (elementMapping != null && elementMapping.getTemplate() != null) {
+ manager.add(new VpeAction(
+ "<" + node.getNodeName() + "> Attributes", node) {
//$NON-NLS-1$ //$NON-NLS-2$
+ public void run() {
+ showProperties(actionNode);
+ }
+ });
- if (!topLevelFlag) {
- manager.add(new VpeAction("Select This Tag", node) { //$NON-NLS-1$
- public void run() {
- selectionBuilder.setVisualSelection(
- actionNode, 0, actionNode, 0,
- false, true);
+ if (!topLevelFlag) {
+ manager.add(new VpeAction("Select This Tag", node) { //$NON-NLS-1$
+ public void run() {
+ selectionBuilder.setVisualSelection(
+ actionNode, 0, actionNode, 0,
+ false, true);
- }
- });
}
- Node parent = node.getParentNode();
- if (parent != null && parent.getNodeType() == Node.ELEMENT_NODE) {
- MenuManager menuManager = new MenuManager("Parent Tag"); //$NON-NLS-1$
- menuManager.setParent(manager);
- manager.add(menuManager);
- createMenuForNode(parent, menuManager);
- }
-
- manager.add(new Separator());
- }
+ });
}
- NodeActionManager actionManager = new NodeActionManager(getModel(),
- null);
-
- if (node.getNodeType() == Node.TEXT_NODE) {
- Point range = sourceEditor.getTextViewer().getSelectedRange();
- TextNodeSplitterImpl splitter = new TextNodeSplitterImpl(range,
- (Text) node);
- NodeActionManager.setTextNodeSplitter(splitter);
+ Node parent = node.getParentNode();
+ if (parent != null && parent.getNodeType() == Node.ELEMENT_NODE) {
+ MenuManager menuManager = new MenuManager("Parent Tag"); //$NON-NLS-1$
+ menuManager.setParent(manager);
+ manager.add(menuManager);
+ createMenuForNode(parent, menuManager);
}
- if (actionManager != null) {
- StructuredSelection structuredSelection = new StructuredSelection(
- node);
- actionManager.fillContextMenuForVpe(manager, structuredSelection);
+ manager.add(new Separator());
+ }
+ }
+ NodeActionManager actionManager = new NodeActionManager(getModel(),
+ null);
+ if (node.getNodeType() == Node.TEXT_NODE) {
+ Point range = sourceEditor.getTextViewer().getSelectedRange();
+ TextNodeSplitterImpl splitter = new TextNodeSplitterImpl(range,
+ (Text) node);
+ NodeActionManager.setTextNodeSplitter(splitter);
+ }
+
+ if (actionManager != null) {
+ StructuredSelection structuredSelection = new StructuredSelection(
+ node);
+ actionManager.fillContextMenuForVpe(manager, structuredSelection);
+
+ }
+
+ IContributionItem[] items = manager.getItems();
+
+ for (int i = 0; i < items.length; i++) {
+ if (items[i] instanceof MenuManager) {
+ MenuManager mm = (MenuManager) items[i];
+ if (NodeActionManager.INSERT_AROUND_MENU.equals(mm
+ .getMenuText())) {
+ listenContextMenu(mm, (IndexedRegion) node, AROUND_MENU);
+ } else if (NodeActionManager.INSERT_BEFORE_MENU.equals(mm
+ .getMenuText())) {
+ listenContextMenu(mm, (IndexedRegion) node, BEFORE_MENU);
+ } else if (NodeActionManager.INSERT_AFTER_MENU.equals(mm
+ .getMenuText())) {
+ listenContextMenu(mm, (IndexedRegion) node, AFTER_MENU);
}
+ }
+ }
- IContributionItem[] items = manager.getItems();
+ manager.add(new Separator());
- for (int i = 0; i < items.length; i++) {
- if (items[i] instanceof MenuManager) {
- MenuManager mm = (MenuManager) items[i];
- if (NodeActionManager.INSERT_AROUND_MENU.equals(mm
- .getMenuText())) {
- listenContextMenu(mm, (IndexedRegion) node, AROUND_MENU);
- } else if (NodeActionManager.INSERT_BEFORE_MENU.equals(mm
- .getMenuText())) {
- listenContextMenu(mm, (IndexedRegion) node, BEFORE_MENU);
- } else if (NodeActionManager.INSERT_AFTER_MENU.equals(mm
- .getMenuText())) {
- listenContextMenu(mm, (IndexedRegion) node, AFTER_MENU);
+ if (node.getNodeType() == Node.ELEMENT_NODE) {
+ VpeElementMapping elementMapping = (VpeElementMapping) domMapping
+ .getNodeMapping(node);
+ if (elementMapping != null
+ && elementMapping.getTemplate() != null
+ && elementMapping.getTemplate().getType() == VpeHtmlTemplate.TYPE_ANY) {
+ final VpeTemplate selectedTemplate = elementMapping
+ .getTemplate();
+ manager.add(new VpeAction("Template", node) { //$NON-NLS-1$
+ public void run() {
+ boolean isCorrectNS = pageContext
+ .isCorrectNS(actionNode);
+ VpeAnyData data = null;
+ if (isCorrectNS) {
+ data = selectedTemplate.getAnyData();
+ data.setUri(pageContext
+ .getSourceTaglibUri(actionNode));
+ data.setName(actionNode.getNodeName());
}
- }
- }
+ data = editAnyData(sourceEditor, isCorrectNS,
+ data);
+ if (data != null && data.isChanged())
+ templateManager.setAnyTemplate(data);
+ }
+ });
manager.add(new Separator());
+ }
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- VpeElementMapping elementMapping = (VpeElementMapping) domMapping
- .getNodeMapping(node);
- if (elementMapping != null
- && elementMapping.getTemplate() != null
- && elementMapping.getTemplate().getType() == VpeHtmlTemplate.TYPE_ANY) {
- final VpeTemplate selectedTemplate = elementMapping
- .getTemplate();
- manager.add(new VpeAction("Template", node) { //$NON-NLS-1$
- public void run() {
- boolean isCorrectNS = pageContext
- .isCorrectNS(actionNode);
- VpeAnyData data = null;
- if (isCorrectNS) {
- data = selectedTemplate.getAnyData();
- data.setUri(pageContext
- .getSourceTaglibUri(actionNode));
- data.setName(actionNode.getNodeName());
- }
- data = editAnyData(sourceEditor, isCorrectNS,
- data);
- if (data != null && data.isChanged())
- templateManager.setAnyTemplate(data);
- }
- });
-
- manager.add(new Separator());
+ manager.add(new VpeTextOperationAction(
+ "Cut", ActionFactory.CUT.getId(), (IndexedRegion) node)); //$NON-NLS-1$
+ manager.add(new VpeTextOperationAction(
+ "Copy", ActionFactory.COPY.getId(), (IndexedRegion) node));
//$NON-NLS-1$
+ manager
+ .add(new VpeTextOperationAction(
+ "Paste", ActionFactory.PASTE.getId(), (IndexedRegion) node));
//$NON-NLS-1$
+ } else if (node.getNodeType() == Node.TEXT_NODE) {
+ manager.add(new Action("Cut") { //$NON-NLS-1$
+ public void run() {
+ sourceEditor.getAction(ActionFactory.CUT.getId())
+ .run();
}
+ });
+ manager.add(new Action("Copy") { //$NON-NLS-1$
+ public void run() {
+ sourceEditor.getAction(ActionFactory.COPY.getId())
+ .run();
+ }
+ });
+ manager.add(new Action("Paste") { //$NON-NLS-1$
+ public void run() {
+ sourceEditor.getAction(ActionFactory.PASTE.getId())
+ .run();
+ }
+ });
+ }
+ manager.add(new Separator());
- manager.add(new VpeTextOperationAction(
- "Cut", ActionFactory.CUT.getId(), (IndexedRegion) node)); //$NON-NLS-1$
- manager.add(new VpeTextOperationAction(
- "Copy", ActionFactory.COPY.getId(), (IndexedRegion) node)); //$NON-NLS-1$
- manager
- .add(new VpeTextOperationAction(
- "Paste", ActionFactory.PASTE.getId(), (IndexedRegion) node));
//$NON-NLS-1$
- } else if (node.getNodeType() == Node.TEXT_NODE) {
- manager.add(new Action("Cut") { //$NON-NLS-1$
- public void run() {
- sourceEditor.getAction(ActionFactory.CUT.getId())
- .run();
- }
- });
- manager.add(new Action("Copy") { //$NON-NLS-1$
- public void run() {
- sourceEditor.getAction(ActionFactory.COPY.getId())
- .run();
- }
- });
- manager.add(new Action("Paste") { //$NON-NLS-1$
- public void run() {
- sourceEditor.getAction(ActionFactory.PASTE.getId())
- .run();
- }
- });
- }
- manager.add(new Separator());
+ if (actionManager != null) {
+ StructuredSelection structuredSelection = node.getNodeType() == Node.ELEMENT_NODE ?
new StructuredSelection(
+ node)
+ : null;
+ actionManager.addContextMenuForVpe(manager, structuredSelection);
+ }
- if (actionManager != null) {
- StructuredSelection structuredSelection = node.getNodeType() == Node.ELEMENT_NODE ?
new StructuredSelection(
- node)
- : null;
- actionManager.addContextMenuForVpe(manager, structuredSelection);
+ if (node.getNodeType() == Node.ELEMENT_NODE) {
+ boolean stripEnable = false;
+ NodeImpl impl = (NodeImpl) node;
+ if (impl.isContainer()) {
+ NodeList list = impl.getChildNodes();
+ if (list.getLength() > 0) {
+ if (list.getLength() == 1) {
+ Node child = list.item(0);
+ if (child.getNodeType() == Node.TEXT_NODE) {
+ if ("".equals(child.getNodeValue().trim()))stripEnable = false;
//$NON-NLS-1$
+ else
+ stripEnable = true;
+ } else
+ stripEnable = true;
+ } else
+ stripEnable = true;
}
-
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- boolean stripEnable = false;
- NodeImpl impl = (NodeImpl) node;
- if (impl.isContainer()) {
- NodeList list = impl.getChildNodes();
- if (list.getLength() > 0) {
- if (list.getLength() == 1) {
- Node child = list.item(0);
- if (child.getNodeType() == Node.TEXT_NODE) {
- if ("".equals(child.getNodeValue().trim()))stripEnable = false;
//$NON-NLS-1$
- else
- stripEnable = true;
- } else
- stripEnable = true;
- } else
- stripEnable = true;
+ }
+ if (stripEnable)
+ manager.add(new VpeAction("Strip Tag", node) { //$NON-NLS-1$
+ public void run() {
+ Node parent = actionNode.getParentNode();
+ if (parent != null) {
+ int index = ((NodeImpl) actionNode)
+ .getIndex();
+ parent.removeChild(actionNode);
+ NodeList children = actionNode
+ .getChildNodes();
+ int lengh = children.getLength();
+ Node child;
+ for (int i = 0; i < lengh; i++) {
+ child = children.item(0);
+ actionNode.removeChild(child);
+ insertNode(parent, child, index++);
+ }
}
- }
- if (stripEnable)
- manager.add(new VpeAction("Strip Tag", node) { //$NON-NLS-1$
- public void run() {
- Node parent = actionNode.getParentNode();
- if (parent != null) {
- int index = ((NodeImpl) actionNode)
- .getIndex();
- parent.removeChild(actionNode);
- NodeList children = actionNode
- .getChildNodes();
- int lengh = children.getLength();
- Node child;
- for (int i = 0; i < lengh; i++) {
- child = children.item(0);
- actionNode.removeChild(child);
- insertNode(parent, child, index++);
- }
- }
- }
+ }
- private void insertNode(Node parent, Node node,
- int index) {
- Node oldNode = null;
- int childSize = parent.getChildNodes()
- .getLength();
+ private void insertNode(Node parent, Node node,
+ int index) {
+ Node oldNode = null;
+ int childSize = parent.getChildNodes()
+ .getLength();
- if (index <= (childSize - 1))
- oldNode = parent.getChildNodes()
- .item(index);
- if (oldNode != null)
- parent.insertBefore(node, oldNode);
- else
- parent.appendChild(node);
- }
- });
- }
- if (node.getNodeType() == Node.TEXT_NODE) {
- manager.add(new Action("Delete") { //$NON-NLS-1$
- public void run() {
- sourceEditor
- .getAction(ActionFactory.DELETE.getId())
- .run();
- }
- });
- }
+ if (index <= (childSize - 1))
+ oldNode = parent.getChildNodes()
+ .item(index);
+ if (oldNode != null)
+ parent.insertBefore(node, oldNode);
+ else
+ parent.appendChild(node);
+ }
+ });
+ }
+ if (node.getNodeType() == Node.TEXT_NODE) {
+ manager.add(new Action("Delete") { //$NON-NLS-1$
+ public void run() {
+ sourceEditor
+ .getAction(ActionFactory.DELETE.getId())
+ .run();
+ }
+ });
+ }
- if (VpeDebug.VISUAL_CONTEXTMENU_DUMP_SOURCE) {
- manager.add(new Action("Dump Source") { //$NON-NLS-1$
- public void run() {
- DOMTreeDumper dumper = new DOMTreeDumper(
- VpeDebug.VISUAL_DUMP_PRINT_HASH);
- dumper.dumpToStream(System.out, visualEditor
- .getDomDocument());
- }
- });
- }
+ if (VpeDebug.VISUAL_CONTEXTMENU_DUMP_SOURCE) {
+ manager.add(new Action("Dump Source") { //$NON-NLS-1$
+ public void run() {
+ DOMTreeDumper dumper = new DOMTreeDumper(
+ VpeDebug.VISUAL_DUMP_PRINT_HASH);
+ dumper.dumpToStream(System.out, visualEditor
+ .getDomDocument());
+ }
+ });
+ }
- if (VpeDebug.VISUAL_CONTEXTMENU_DUMP_MAPPING) {
- manager.add(new Action("Dump Mapping") { //$NON-NLS-1$
- public void run() {
- printMapping();
- }
- });
- }
+ if (VpeDebug.VISUAL_CONTEXTMENU_DUMP_MAPPING) {
+ manager.add(new Action("Dump Mapping") { //$NON-NLS-1$
+ public void run() {
+ printMapping();
+ }
+ });
+ }
- if (VpeDebug.VISUAL_CONTEXTMENU_TEST) {
- manager.add(new VpeAction("Test", node) { //$NON-NLS-1$
- public void run() {
- test(actionNode);
- }
- });
- }
+ if (VpeDebug.VISUAL_CONTEXTMENU_TEST) {
+ manager.add(new VpeAction("Test", node) { //$NON-NLS-1$
+ public void run() {
+ test(actionNode);
+ }
+ });
}
+ }
- /**
- * Calls when on when browser receive context menu event.
- *
- * @param contextFlags
- * -not used in this function, just for becouse this parametr
- * exist in nsIContextMenuListener
- * @param event
- * event from browser used here
- * @param node
- * where this event are occur
- */
- public void onShowContextMenu(long contextFlags, nsIDOMEvent event,
- nsIDOMNode node) {
- nsIDOMNode visualNode = VisualDomUtil.getTargetNode(event);
+ /**
+ * Calls when on when browser receive context menu event.
+ *
+ * @param contextFlags
+ * -not used in this function, just for becouse this parametr
+ * exist in nsIContextMenuListener
+ * @param event
+ * event from browser used here
+ * @param node
+ * where this event are occur
+ */
+ public void onShowContextMenu(long contextFlags, nsIDOMEvent event,
+ nsIDOMNode node) {
+ nsIDOMNode visualNode = VisualDomUtil.getTargetNode(event);
- if (visualNode != null) {
- Node selectedSourceNode = null;
- selectedSourceNode = selectionBuilder
- .setContextMenuSelection(visualNode);
- if (selectedSourceNode != null) {
+ if (visualNode != null) {
+ Node selectedSourceNode = null;
+ selectedSourceNode = selectionBuilder
+ .setContextMenuSelection(visualNode);
+ if (selectedSourceNode != null) {
- MenuManager menuManager = new MenuManager("#popup"); //$NON-NLS-1$
- final Menu contextMenu = menuManager
- .createContextMenu(visualEditor.getControl());
- contextMenu.addMenuListener(new MenuListener() {
- Menu menu = contextMenu;
+ MenuManager menuManager = new MenuManager("#popup"); //$NON-NLS-1$
+ final Menu contextMenu = menuManager
+ .createContextMenu(visualEditor.getControl());
+ contextMenu.addMenuListener(new MenuListener() {
+ Menu menu = contextMenu;
- public void menuHidden(MenuEvent e) {
- Display.getCurrent().asyncExec(new Runnable() {
- public void run() {
- menu.dispose();
- }
- });
- }
+ public void menuHidden(MenuEvent e) {
+ Display.getCurrent().asyncExec(new Runnable() {
+ public void run() {
+ menu.dispose();
+ }
+ });
+ }
- public void menuShown(MenuEvent e) {
- }
- });
- createMenuForNode(selectedSourceNode, menuManager, true);
+ public void menuShown(MenuEvent e) {
+ }
+ });
+ createMenuForNode(selectedSourceNode, menuManager, true);
- contextMenu.setVisible(true);
+ contextMenu.setVisible(true);
- }
- }
+ }
}
+ }
- private VpeAnyData editAnyData(StructuredTextEditor sourceEditor,
- boolean isCorrectNS, VpeAnyData data) {
- Shell shell = sourceEditor.getEditorPart().getSite().getShell();
- if (isCorrectNS) {
- VpeEditAnyDialog editDialog = new VpeEditAnyDialog(shell, data);
- editDialog.open();
- } else {
- MessageBox message = new MessageBox(shell, SWT.ICON_WARNING
- | SWT.OK);
- message.setMessage(VpeUIMessages.NAMESPACE_NOT_DEFINED);
- message.open();
- }
- return data;
+ private VpeAnyData editAnyData(StructuredTextEditor sourceEditor,
+ boolean isCorrectNS, VpeAnyData data) {
+ Shell shell = sourceEditor.getEditorPart().getSite().getShell();
+ if (isCorrectNS) {
+ VpeEditAnyDialog editDialog = new VpeEditAnyDialog(shell, data);
+ editDialog.open();
+ } else {
+ MessageBox message = new MessageBox(shell, SWT.ICON_WARNING
+ | SWT.OK);
+ message.setMessage(VpeUIMessages.NAMESPACE_NOT_DEFINED);
+ message.open();
}
+ return data;
+ }
- // VpeTemplateListener implementation
- public void templateReloaded() {
- visualRefresh();
- }
+ // VpeTemplateListener implementation
+ public void templateReloaded() {
+ visualRefresh();
+ }
- public void visualRefresh() {
+ public void visualRefresh() {
+
+ if(visualRefresfJob==null || visualRefresfJob.getState()==Job.NONE) {
+
+ visualRefresfJob =new UIJob(VpeUIMessages.VPE_VISUAL_REFRESH_JOB){
- if (visualRefresfJob == null || visualRefresfJob.getState() == Job.NONE) {
-
- visualRefresfJob = new UIJob(VpeUIMessages.VPE_VISUAL_REFRESH_JOB) {
-
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
-
- if (monitor.isCanceled()) {
-
+
+ if(monitor.isCanceled()) {
+
return Status.CANCEL_STATUS;
}
-
- if (uiJob != null && uiJob.getState() == Job.RUNNING) {
+
+ if(uiJob!=null &&
+ uiJob.getState()==Job.RUNNING) {
uiJob.cancel();
getChangeEvents().clear();
- // wait while ui job is finished
+ //wait while ui job is finished
schedule(500);
} else {
-
- if (uiJob != null) {
-
+
+ if(uiJob!=null) {
+
uiJob.cancel();
getChangeEvents().clear();
}
@@ -1676,41 +1602,36 @@
return Status.CANCEL_STATUS;
}
try {
- monitor.beginTask(
- VpeUIMessages.VPE_VISUAL_REFRESH_JOB,
- IProgressMonitor.UNKNOWN);
+ monitor.beginTask(VpeUIMessages.VPE_VISUAL_REFRESH_JOB,
IProgressMonitor.UNKNOWN);
visualRefreshImpl();
monitor.done();
} catch (VpeDisposeException exc) {
- // just ignore this exception
+ //just ignore this exception
} catch (NullPointerException ex) {
-
- if (switcher != null) {
+
+ 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
+ //class was disposed and exception result of that we can't stop
+ //refresh job in time, so we just ignore this exception
}
} finally {
-
- if (switcher != null) {
-
+
+ if(switcher!=null) {
+
switcher.stopActiveEditor();
}
}
}
return Status.OK_STATUS;
- }
- };
-
- visualRefresfJob.setPriority(Job.SHORT);
- visualRefresfJob.schedule();
- }
+ }};
+
+ visualRefresfJob.setPriority(Job.SHORT);
+ visualRefresfJob.schedule();
+ }
}
- void visualRefreshImpl() {
+ void visualRefreshImpl() {
visualEditor.hideResizer();
@@ -1720,9 +1641,9 @@
if (!visualEditor.getDoctype().equals(currentDoctype)) {
visualEditor.reload();
-
- } else {
-
+
+ }else {
+
visualBuilder.setSelectionRectangle(null);
IDOMModel sourceModel = (IDOMModel) getModel();
if (sourceModel != null) {
@@ -1734,132 +1655,132 @@
}
}
- public void preLongOperation() {
+ public void preLongOperation() {
switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL);
}
- public void postLongOperation() {
+ public void postLongOperation() {
switcher.stopActiveEditor();
visualRefresh();
}
- // for debug
- private void printSourceEvent(INodeNotifier notifier, int eventType,
- Object feature, Object oldValue, Object newValue, int pos) {
+ // 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] + " pos: " + pos + "
notifier: " + ((Node) notifier).getNodeName() + " hashCode: " +
notifier.hashCode()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ if (feature != null) {
+ if (feature instanceof Node) {
System.out
- .println(">>> eventType: " +
INodeNotifier.EVENT_TYPE_STRINGS[eventType] + " pos: " + pos + "
notifier: " + ((Node) notifier).getNodeName() + " hashCode: " +
notifier.hashCode()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- if (feature != null) {
- if (feature instanceof Node) {
- System.out
- .println(" feature: " + ((Node) feature).getNodeType() + "
" + ((Node) feature).getNodeName() + " hashCode: " + feature.hashCode());
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- } else {
- System.out.println(" feature: " + feature); //$NON-NLS-1$
- }
- }
- if (oldValue != null) {
- if (oldValue instanceof Node) {
- System.out
- .println(" oldValue: " + ((Node) oldValue).getNodeName() + "
hashCode: " + oldValue.hashCode()); //$NON-NLS-1$ //$NON-NLS-2$
- } else {
- System.out.println(" oldValue: " + oldValue); //$NON-NLS-1$
- }
- }
- if (newValue != null) {
- if (newValue instanceof Node) {
- System.out
- .println(" newValue: " + ((Node) newValue).getNodeName() + "
hashCode: " + newValue.hashCode() + " " + ((Node)
newValue).getNodeType()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- } else {
- System.out.println(" newValue: " + newValue); //$NON-NLS-1$
- }
- }
+ .println(" feature: " + ((Node) feature).getNodeType() + " "
+ ((Node) feature).getNodeName() + " hashCode: " + feature.hashCode());
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ } else {
+ System.out.println(" feature: " + feature); //$NON-NLS-1$
+ }
}
+ if (oldValue != null) {
+ if (oldValue instanceof Node) {
+ System.out
+ .println(" oldValue: " + ((Node) oldValue).getNodeName() + "
hashCode: " + oldValue.hashCode()); //$NON-NLS-1$ //$NON-NLS-2$
+ } else {
+ System.out.println(" oldValue: " + oldValue); //$NON-NLS-1$
+ }
+ }
+ if (newValue != null) {
+ if (newValue instanceof Node) {
+ System.out
+ .println(" newValue: " + ((Node) newValue).getNodeName() + "
hashCode: " + newValue.hashCode() + " " + ((Node)
newValue).getNodeType()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ } else {
+ System.out.println(" newValue: " + newValue); //$NON-NLS-1$
+ }
+ }
+ }
- private void printVisualEvent(nsIDOMEvent event) {
- System.out.print("<<< " + event.getType()); //$NON-NLS-1$
+ private void printVisualEvent(nsIDOMEvent event) {
+ System.out.print("<<< " + event.getType()); //$NON-NLS-1$
- if (event instanceof nsIDOMMutationEvent) {
- nsIDOMMutationEvent mutationEvent = (nsIDOMMutationEvent) event;
+ if (event instanceof nsIDOMMutationEvent) {
+ nsIDOMMutationEvent mutationEvent = (nsIDOMMutationEvent) event;
- System.out.print(" EventPhase: " + mutationEvent.getEventPhase());
//$NON-NLS-1$
+ 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 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$
+ 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();
+ System.out
+ .print(" PrevValue: " + mutationEvent.getPrevValue().trim());
//$NON-NLS-1$
+ System.out
+ .print(" NewValue: " + mutationEvent.getNewValue().trim());
//$NON-NLS-1$
}
+ System.out.println();
+ }
- private void printMapping() {
- domMapping.printMapping();
- }
+ private void printMapping() {
+ domMapping.printMapping();
+ }
- private class ActiveEditorSwitcher {
- private static final int ACTIVE_EDITOR_CANNOT = 0;
- private static final int ACTIVE_EDITOR_NONE = 1;
- private static final int ACTIVE_EDITOR_SOURCE = 2;
- private static final int ACTIVE_EDITOR_VISUAL = 3;
+ private class ActiveEditorSwitcher {
+ private static final int ACTIVE_EDITOR_CANNOT = 0;
+ private static final int ACTIVE_EDITOR_NONE = 1;
+ private static final int ACTIVE_EDITOR_SOURCE = 2;
+ private static final int ACTIVE_EDITOR_VISUAL = 3;
- private int type = ACTIVE_EDITOR_CANNOT;
+ private int type = ACTIVE_EDITOR_CANNOT;
- private void initActiveEditor() {
- type = ACTIVE_EDITOR_NONE;
- }
+ private void initActiveEditor() {
+ type = ACTIVE_EDITOR_NONE;
+ }
- private void destroyActiveEditor() {
- type = ACTIVE_EDITOR_CANNOT;
- }
+ private void destroyActiveEditor() {
+ type = ACTIVE_EDITOR_CANNOT;
+ }
- private boolean startActiveEditor(int newType) {
- if (type == ACTIVE_EDITOR_NONE) {
- if (newType == ACTIVE_EDITOR_SOURCE
- && editPart.getVisualMode() == VpeEditorPart.SOURCE_MODE) {
- return false;
- }
- type = newType;
- return true;
- } else {
- return false;
- }
+ private boolean startActiveEditor(int newType) {
+ if (type == ACTIVE_EDITOR_NONE) {
+ if (newType == ACTIVE_EDITOR_SOURCE
+ && editPart.getVisualMode() == VpeEditorPart.SOURCE_MODE) {
+ return false;
}
-
- private void stopActiveEditor() {
- onRefresh();
- type = ACTIVE_EDITOR_NONE;
- }
+ type = newType;
+ return true;
+ } else {
+ return false;
+ }
}
- private void showProperties(Node node) {
- ExtendedProperties p = createExtendedProperties(node);
- if (p != null)
- ExtendedPropertiesWizard.run(p);
+ private void stopActiveEditor() {
+ onRefresh();
+ type = ACTIVE_EDITOR_NONE;
}
+ }
- ExtendedProperties createExtendedProperties(Node node) {
- try {
- Class c = ModelFeatureFactory.getInstance().getFeatureClass(
- "org.jboss.tools.jst.jsp.outline.VpeProperties"); //$NON-NLS-1$
- return (ExtendedProperties) c.getDeclaredConstructor(
- new Class[] { Node.class }).newInstance(
- new Object[] { node });
- } catch (Exception e) {
- VpePlugin.reportProblem(e);
- return null;
- }
- }
+ private void showProperties(Node node) {
+ ExtendedProperties p = createExtendedProperties(node);
+ if (p != null)
+ ExtendedPropertiesWizard.run(p);
+ }
- private void test(Node node) {
+ ExtendedProperties createExtendedProperties(Node node) {
+ try {
+ Class c = ModelFeatureFactory.getInstance().getFeatureClass(
+ "org.jboss.tools.jst.jsp.outline.VpeProperties"); //$NON-NLS-1$
+ return (ExtendedProperties) c.getDeclaredConstructor(
+ new Class[] { Node.class }).newInstance(
+ new Object[] { node });
+ } catch (Exception e) {
+ VpePlugin.reportProblem(e);
+ return null;
}
+ }
- void refreshBundleValues() {
+ private void test(Node node) {
+ }
+
+ void refreshBundleValues() {
if (!switcher
.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
return;
@@ -1878,7 +1799,7 @@
}
}
- void refreshTemplates() {
+ void refreshTemplates() {
if (includeList.includesRefresh()) {
visualRefresh();
}
@@ -1903,493 +1824,493 @@
}
}
- // implements XModelTreeListener
- public void nodeChanged(XModelTreeEvent event) {
- visualRefresh();
- }
+ // implements XModelTreeListener
+ public void nodeChanged(XModelTreeEvent event) {
+ visualRefresh();
+ }
- public void structureChanged(XModelTreeEvent event) {
- }
+ public void structureChanged(XModelTreeEvent event) {
+ }
- private Node getSourceNodeAt(int offset) {
- if (sourceEditor != null && getModel() != null) {
- IndexedRegion node = getModel().getIndexedRegion(offset);
- if (node instanceof IDOMNode) {
+ private Node getSourceNodeAt(int offset) {
+ if (sourceEditor != null && getModel() != null) {
+ IndexedRegion node = getModel().getIndexedRegion(offset);
+ if (node instanceof IDOMNode) {
- VpeElementMapping elementMapping = domMapping
- .getNearElementMapping((IDOMNode) node);
+ VpeElementMapping elementMapping = domMapping
+ .getNearElementMapping((IDOMNode) node);
- if (elementMapping != null) {
+ if (elementMapping != null) {
- if (node instanceof IDOMElement) {
- IDOMElement element = (IDOMElement) node;
+ if (node instanceof IDOMElement) {
+ IDOMElement element = (IDOMElement) node;
- if (offset < element.getEndStartOffset()) {
- NamedNodeMap attrs = element.getAttributes();
- if (attrs != null) {
- for (int i = 0; i < attrs.getLength(); i++) {
- if (attrs.item(i) instanceof AttrImpl) {
- AttrImpl attr = (AttrImpl) attrs
- .item(i);
- if (getSourceAttributeOffset(attr,
- offset) != -1) {
+ if (offset < element.getEndStartOffset()) {
+ NamedNodeMap attrs = element.getAttributes();
+ if (attrs != null) {
+ for (int i = 0; i < attrs.getLength(); i++) {
+ if (attrs.item(i) instanceof AttrImpl) {
+ AttrImpl attr = (AttrImpl) attrs
+ .item(i);
+ if (getSourceAttributeOffset(attr,
+ offset) != -1) {
- String[] atributeNames = elementMapping
- .getTemplate()
- .getOutputAtributeNames();
- if (atributeNames != null
- && atributeNames.length > 0
- && attr
- .getName()
- .equalsIgnoreCase(
- atributeNames[0])) {
- return attr;
- }
- }
- }
- }
- }
- }
+ String[] atributeNames = elementMapping
+ .getTemplate()
+ .getOutputAtributeNames();
+ if (atributeNames != null
+ && atributeNames.length > 0
+ && attr
+ .getName()
+ .equalsIgnoreCase(
+ atributeNames[0])) {
+ return attr;
+ }
}
+ }
}
+ }
}
- if (node == null) {
- node = getModel().getIndexedRegion(offset - 1);
- }
- if (node instanceof Node) {
- return (Node) node;
- }
+ }
}
- return null;
+ }
+ if (node == null) {
+ node = getModel().getIndexedRegion(offset - 1);
+ }
+ if (node instanceof Node) {
+ return (Node) node;
+ }
}
+ return null;
+ }
- private int getSourceNodeOffset(Node node, int pos, boolean endFlag) {
- if (node == null)
- return 0;
- int start = ((IndexedRegion) node).getStartOffset();
- int end = ((IndexedRegion) node).getEndOffset();
+ private int getSourceNodeOffset(Node node, int pos, boolean endFlag) {
+ if (node == null)
+ return 0;
+ int start = ((IndexedRegion) node).getStartOffset();
+ int end = ((IndexedRegion) node).getEndOffset();
- switch (node.getNodeType()) {
- case Node.ATTRIBUTE_NODE:
- if (node instanceof AttrImpl) {
- return getSourceAttributeOffset((AttrImpl) node, pos);
- }
- case Node.TEXT_NODE:
- if (pos < start) {
- return 0;
- } else if (pos > end) {
- return end - start;
- } else {
- return pos - start;
- }
- case Node.COMMENT_NODE:
- if (pos > end) {
- pos = end;
- }
- int offset = pos - start - 4;
- return offset < 0 ? 0 : offset;
- case Node.ELEMENT_NODE:
- ElementImpl element = (ElementImpl) node;
- if (element.isContainer()) {
- if (pos < element.getStartEndOffset()) {
- return 0;
- } else {
- return 1;
- }
- } else {
- return endFlag ? 1 : 0;
- }
- default:
- return endFlag ? 1 : 0;
+ switch (node.getNodeType()) {
+ case Node.ATTRIBUTE_NODE:
+ if (node instanceof AttrImpl) {
+ return getSourceAttributeOffset((AttrImpl) node, pos);
+ }
+ case Node.TEXT_NODE:
+ if (pos < start) {
+ return 0;
+ } else if (pos > end) {
+ return end - start;
+ } else {
+ return pos - start;
+ }
+ case Node.COMMENT_NODE:
+ if (pos > end) {
+ pos = end;
+ }
+ int offset = pos - start - 4;
+ return offset < 0 ? 0 : offset;
+ case Node.ELEMENT_NODE:
+ ElementImpl element = (ElementImpl) node;
+ if (element.isContainer()) {
+ if (pos < element.getStartEndOffset()) {
+ return 0;
+ } else {
+ return 1;
}
+ } else {
+ return endFlag ? 1 : 0;
+ }
+ default:
+ return endFlag ? 1 : 0;
}
+ }
- private int getSourceAttributeOffset(AttrImpl attr, int pos) {
- if (attr.getValueRegion() != null) {
- int start = attr.getValueRegionStartOffset();
- String value = attr.getValueRegionText();
- int len = value.length();
- if (pos >= start && pos <= start + len) {
- int offset = pos - start;
- if (len > 1 && value.charAt(0) == '"'
- && value.charAt(len - 1) == '"') {
- if (offset <= 0 || offset >= len) {
- return -1;
- }
- offset--;
- }
- return offset;
- }
+ private int getSourceAttributeOffset(AttrImpl attr, int pos) {
+ if (attr.getValueRegion() != null) {
+ int start = attr.getValueRegionStartOffset();
+ String value = attr.getValueRegionText();
+ int len = value.length();
+ if (pos >= start && pos <= start + len) {
+ int offset = pos - start;
+ if (len > 1 && value.charAt(0) == '"'
+ && value.charAt(len - 1) == '"') {
+ if (offset <= 0 || offset >= len) {
+ return -1;
+ }
+ offset--;
}
- return -1;
+ return offset;
+ }
}
+ return -1;
+ }
- private int getSourceNodeOffset1(Node node, int pos, boolean endFlag) {
- if (node == null)
- return 0;
- int start = ((IndexedRegion) node).getStartOffset();
- int end = ((IndexedRegion) node).getEndOffset();
+ private int getSourceNodeOffset1(Node node, int pos, boolean endFlag) {
+ if (node == null)
+ return 0;
+ int start = ((IndexedRegion) node).getStartOffset();
+ int end = ((IndexedRegion) node).getEndOffset();
- switch (node.getNodeType()) {
- case Node.ATTRIBUTE_NODE:
- if (node instanceof AttrImpl) {
- AttrImpl attr = (AttrImpl) node;
- start = attr.getValueRegionStartOffset();
- end = start + attr.getValueRegion().getLength();
- int ret = 0;
- if (pos > end) {
- ret = end - start;
- } else {
- ret = pos - start;
- }
- if (ret > 0 && attr.getValueRegionText().charAt(0) == '"') {
- ret--;
- }
- return ret;
- }
- case Node.TEXT_NODE:
- if (pos < start) {
- return 0;
- } else if (pos > end) {
- return end - start;
- } else {
- return pos - start;
- }
- case Node.COMMENT_NODE:
- if (pos > end) {
- pos = end;
- }
- int offset = pos - start - 4;
- return offset < 0 ? 0 : offset;
- case Node.ELEMENT_NODE:
- ElementImpl element = (ElementImpl) node;
- if (element.isContainer()) {
- if (pos < element.getStartEndOffset()) {
- return 0;
- } else if (pos < element.getStartEndOffset()) {
- return 1;
- } else if (pos == element.getStartEndOffset()) {
- return 2;
- }
- } else {
- return endFlag ? 1 : 0;
- }
- default:
- return endFlag ? 1 : 0;
+ switch (node.getNodeType()) {
+ case Node.ATTRIBUTE_NODE:
+ if (node instanceof AttrImpl) {
+ AttrImpl attr = (AttrImpl) node;
+ start = attr.getValueRegionStartOffset();
+ end = start + attr.getValueRegion().getLength();
+ int ret = 0;
+ if (pos > end) {
+ ret = end - start;
+ } else {
+ ret = pos - start;
}
- }
-
- private void listenContextMenu(MenuManager manager, IndexedRegion region,
- int type) {
- MenuManager mm = new MyMenuManager("From Palette", true); //$NON-NLS-1$
- manager.add(mm);
- manager.addMenuListener(new VpeMenuListener(mm, region, type));
- }
-
- class VpeMenuListener implements IMenuListener {
- private MenuManager manager;
- private IndexedRegion region;
- private int type;
- private boolean loaded = false;
-
- public VpeMenuListener(MenuManager manager, IndexedRegion region,
- int type) {
- this.manager = manager;
- this.region = region;
- this.type = type;
+ if (ret > 0 && attr.getValueRegionText().charAt(0) == '"') {
+ ret--;
}
-
- public void menuAboutToShow(IMenuManager m) {
- if (loaded)
- return;
- loaded = true;
- fillContextMenuFromPalette(manager, region, type);
- manager.getParent().update(true);
+ return ret;
+ }
+ case Node.TEXT_NODE:
+ if (pos < start) {
+ return 0;
+ } else if (pos > end) {
+ return end - start;
+ } else {
+ return pos - start;
+ }
+ case Node.COMMENT_NODE:
+ if (pos > end) {
+ pos = end;
+ }
+ int offset = pos - start - 4;
+ return offset < 0 ? 0 : offset;
+ case Node.ELEMENT_NODE:
+ ElementImpl element = (ElementImpl) node;
+ if (element.isContainer()) {
+ if (pos < element.getStartEndOffset()) {
+ return 0;
+ } else if (pos < element.getStartEndOffset()) {
+ return 1;
+ } else if (pos == element.getStartEndOffset()) {
+ return 2;
}
+ } else {
+ return endFlag ? 1 : 0;
+ }
+ default:
+ return endFlag ? 1 : 0;
}
+ }
- private MenuManager fillContextMenuFromPalette(MenuManager manager,
- IndexedRegion region, int type) {
- XModelObject model = ModelUtilities.getPreferenceModel().getByPath(
- "%Palette%"); //$NON-NLS-1$
+ private void listenContextMenu(MenuManager manager, IndexedRegion region,
+ int type) {
+ MenuManager mm = new MyMenuManager("From Palette", true); //$NON-NLS-1$
+ manager.add(mm);
+ manager.addMenuListener(new VpeMenuListener(mm, region, type));
+ }
- XModelObject[] folders = model.getChildren();
- for (int i = 0; i < folders.length; i++) {
- if ("yes".equals(folders[i].getAttributeValue("hidden")))continue;
//$NON-NLS-1$ //$NON-NLS-2$
- MenuManager mm = new MenuManager(folders[i]
- .getAttributeValue("name")); //$NON-NLS-1$
- manager.add(mm);
- fillPaletteFolder(mm, region, folders[i], type);
- }
- return manager;
+ class VpeMenuListener implements IMenuListener {
+ private MenuManager manager;
+ private IndexedRegion region;
+ private int type;
+ private boolean loaded = false;
+
+ public VpeMenuListener(MenuManager manager, IndexedRegion region,
+ int type) {
+ this.manager = manager;
+ this.region = region;
+ this.type = type;
}
- private void fillPaletteFolder(MenuManager menu, IndexedRegion region,
- XModelObject folder, int type) {
- XModelObject[] groups = folder.getChildren();
- for (int i = 0; i < groups.length; i++) {
- if ("yes".equals(groups[i].getAttributeValue("hidden")))continue;
//$NON-NLS-1$ //$NON-NLS-2$
- MenuManager mm = new MenuManager(groups[i]
- .getAttributeValue("name")); //$NON-NLS-1$
- menu.add(mm);
- fillPaletteGroup(mm, region, groups[i], type);
- }
+ public void menuAboutToShow(IMenuManager m) {
+ if (loaded)
+ return;
+ loaded = true;
+ fillContextMenuFromPalette(manager, region, type);
+ manager.getParent().update(true);
}
+ }
- private void fillPaletteGroup(MenuManager menu, IndexedRegion region,
- XModelObject group, int type) {
- XModelObject[] items = group.getChildren();
- String endText;
+ private MenuManager fillContextMenuFromPalette(MenuManager manager,
+ IndexedRegion region, int type) {
+ XModelObject model = ModelUtilities.getPreferenceModel().getByPath(
+ "%Palette%"); //$NON-NLS-1$
- for (int i = 0; i < items.length; i++) {
- if ("yes".equals(items[i].getAttributeValue("hidden")))continue;
//$NON-NLS-1$ //$NON-NLS-2$
- endText = items[i].getAttributeValue("end text"); //$NON-NLS-1$
+ XModelObject[] folders = model.getChildren();
+ for (int i = 0; i < folders.length; i++) {
+ if
("yes".equals(folders[i].getAttributeValue("hidden")))continue;
//$NON-NLS-1$ //$NON-NLS-2$
+ MenuManager mm = new MenuManager(folders[i]
+ .getAttributeValue("name")); //$NON-NLS-1$
+ manager.add(mm);
+ fillPaletteFolder(mm, region, folders[i], type);
+ }
+ return manager;
+ }
- if (type == AROUND_MENU && (endText == null ||
"".equals(endText)))continue; //$NON-NLS-1$
- createInsertAction(menu, region, items[i], type);
- }
+ private void fillPaletteFolder(MenuManager menu, IndexedRegion region,
+ XModelObject folder, int type) {
+ XModelObject[] groups = folder.getChildren();
+ for (int i = 0; i < groups.length; i++) {
+ if
("yes".equals(groups[i].getAttributeValue("hidden")))continue;
//$NON-NLS-1$ //$NON-NLS-2$
+ MenuManager mm = new MenuManager(groups[i]
+ .getAttributeValue("name")); //$NON-NLS-1$
+ menu.add(mm);
+ fillPaletteGroup(mm, region, groups[i], type);
}
+ }
- private void createInsertAction(MenuManager menu, IndexedRegion region,
- XModelObject item, int type) {
+ private void fillPaletteGroup(MenuManager menu, IndexedRegion region,
+ XModelObject group, int type) {
+ XModelObject[] items = group.getChildren();
+ String endText;
- XModelObject parent = item.getParent();
- String uri = (parent == null) ? "" :
parent.getAttributeValue(URIConstants.LIBRARY_URI); //$NON-NLS-1$
- String defaultPrefix = (parent == null) ? "" :
parent.getAttributeValue(URIConstants.DEFAULT_PREFIX); //$NON-NLS-1$
- String tagName = item.getAttributeValue("name"); //$NON-NLS-1$
- String[] texts = new String[] { "<" + tagName + ">" };
//$NON-NLS-1$ //$NON-NLS-2$
- if (tagName.indexOf("taglib") < 0) //$NON-NLS-1$
- PaletteInsertHelper.applyPrefix(texts, sourceEditor, tagName, uri,
- defaultPrefix);
- tagName = texts[0];
+ for (int i = 0; i < items.length; i++) {
+ if ("yes".equals(items[i].getAttributeValue("hidden")))continue;
//$NON-NLS-1$ //$NON-NLS-2$
+ endText = items[i].getAttributeValue("end text"); //$NON-NLS-1$
- menu.add(new InsertAction(tagName, region, item, type));
+ if (type == AROUND_MENU && (endText == null ||
"".equals(endText)))continue; //$NON-NLS-1$
+ createInsertAction(menu, region, items[i], type);
}
+ }
- class InsertAction extends Action {
- private XModelObject item;
- private int type;
- private IndexedRegion region;
+ private void createInsertAction(MenuManager menu, IndexedRegion region,
+ XModelObject item, int type) {
- public InsertAction(String title, IndexedRegion region,
- XModelObject item, int type) {
- super(title);
- this.item = item;
- this.type = type;
- this.region = region;
- }
+ XModelObject parent = item.getParent();
+ String uri = (parent == null) ? "" :
parent.getAttributeValue(URIConstants.LIBRARY_URI); //$NON-NLS-1$
+ String defaultPrefix = (parent == null) ? "" :
parent.getAttributeValue(URIConstants.DEFAULT_PREFIX); //$NON-NLS-1$
+ String tagName = item.getAttributeValue("name"); //$NON-NLS-1$
+ String[] texts = new String[] { "<" + tagName + ">" };
//$NON-NLS-1$ //$NON-NLS-2$
+ if (tagName.indexOf("taglib") < 0) //$NON-NLS-1$
+ PaletteInsertHelper.applyPrefix(texts, sourceEditor, tagName, uri,
+ defaultPrefix);
+ tagName = texts[0];
- public void run() {
- try {
- String tagName = item.getAttributeValue("name"); //$NON-NLS-1$
+ menu.add(new InsertAction(tagName, region, item, type));
+ }
- XModelObject parent = item.getParent();
- String uri = (parent == null) ? "" :
parent.getAttributeValue(URIConstants.LIBRARY_URI); //$NON-NLS-1$
- String libraryVersion = (parent == null) ? "" :
parent.getAttributeValue(URIConstants.LIBRARY_VERSION); //$NON-NLS-1$
- String defaultPrefix = (parent == null) ? "" :
parent.getAttributeValue(URIConstants.DEFAULT_PREFIX); //$NON-NLS-1$
- VpeSelectionProvider selProvider = new VpeSelectionProvider(
- region);
+ class InsertAction extends Action {
+ private XModelObject item;
+ private int type;
+ private IndexedRegion region;
- String startText = "" + item.getAttributeValue("start text");
//$NON-NLS-1$ //$NON-NLS-2$
- String endText = "" + item.getAttributeValue("end text");
//$NON-NLS-1$ //$NON-NLS-2$
- if (type == AROUND_MENU) {
- } else if (type == BEFORE_MENU) {
- selProvider = new VpeSelectionProvider(region
- .getStartOffset());
- } else if (type == AFTER_MENU) {
- selProvider = new VpeSelectionProvider(region
- .getEndOffset());
- }
+ public InsertAction(String title, IndexedRegion region,
+ XModelObject item, int type) {
+ super(title);
+ this.item = item;
+ this.type = type;
+ this.region = region;
+ }
- Properties p = new Properties();
- p.setProperty("tag name", tagName); //$NON-NLS-1$
- p.setProperty("start text", startText); //$NON-NLS-1$
- p.setProperty("end text", endText); //$NON-NLS-1$
- p
- .setProperty(
- "automatically reformat tag body", "" +
item.getAttributeValue("automatically reformat tag body")); //$NON-NLS-1$
//$NON-NLS-2$ //$NON-NLS-3$
- p.setProperty(URIConstants.LIBRARY_URI, uri);
- p.setProperty(URIConstants.LIBRARY_VERSION, libraryVersion);
- String addTaglib = item.getParent().getAttributeValue(
- TLDToPaletteHelper.ADD_TAGLIB);
- p.setProperty(URIConstants.DEFAULT_PREFIX, defaultPrefix);
- p.setProperty(PaletteInsertHelper.PROPOPERTY_ADD_TAGLIB,
- addTaglib);
- /*
- * Added by Dzmitry Sakovich Fix for JBIDE-1626
- */
- // if(((Node)region).getNodeType() == Node.ELEMENT_NODE)
- p.put("selectionProvider", selProvider); //$NON-NLS-1$
- PaletteInsertHelper.insertIntoEditor(sourceEditor
- .getTextViewer(), p);
- } catch (Exception e) {
- VpePlugin.reportProblem(e);
- }
+ public void run() {
+ try {
+ String tagName = item.getAttributeValue("name"); //$NON-NLS-1$
+ XModelObject parent = item.getParent();
+ String uri = (parent == null) ? "" :
parent.getAttributeValue(URIConstants.LIBRARY_URI); //$NON-NLS-1$
+ String libraryVersion = (parent == null) ? "" :
parent.getAttributeValue(URIConstants.LIBRARY_VERSION); //$NON-NLS-1$
+ String defaultPrefix = (parent == null) ? "" :
parent.getAttributeValue(URIConstants.DEFAULT_PREFIX); //$NON-NLS-1$
+ VpeSelectionProvider selProvider = new VpeSelectionProvider(
+ region);
+
+ String startText = "" + item.getAttributeValue("start text");
//$NON-NLS-1$ //$NON-NLS-2$
+ String endText = "" + item.getAttributeValue("end text");
//$NON-NLS-1$ //$NON-NLS-2$
+ if (type == AROUND_MENU) {
+ } else if (type == BEFORE_MENU) {
+ selProvider = new VpeSelectionProvider(region
+ .getStartOffset());
+ } else if (type == AFTER_MENU) {
+ selProvider = new VpeSelectionProvider(region
+ .getEndOffset());
}
+ Properties p = new Properties();
+ p.setProperty("tag name", tagName); //$NON-NLS-1$
+ p.setProperty("start text", startText); //$NON-NLS-1$
+ p.setProperty("end text", endText); //$NON-NLS-1$
+ p
+ .setProperty(
+ "automatically reformat tag body", "" +
item.getAttributeValue("automatically reformat tag body")); //$NON-NLS-1$
//$NON-NLS-2$ //$NON-NLS-3$
+ p.setProperty(URIConstants.LIBRARY_URI, uri);
+ p.setProperty(URIConstants.LIBRARY_VERSION, libraryVersion);
+ String addTaglib = item.getParent().getAttributeValue(
+ TLDToPaletteHelper.ADD_TAGLIB);
+ p.setProperty(URIConstants.DEFAULT_PREFIX, defaultPrefix);
+ p.setProperty(PaletteInsertHelper.PROPOPERTY_ADD_TAGLIB,
+ addTaglib);
+ /*
+ * Added by Dzmitry Sakovich Fix for JBIDE-1626
+ */
+ // if(((Node)region).getNodeType() == Node.ELEMENT_NODE)
+ p.put("selectionProvider", selProvider); //$NON-NLS-1$
+ PaletteInsertHelper.insertIntoEditor(sourceEditor
+ .getTextViewer(), p);
+ } catch (Exception e) {
+ VpePlugin.reportProblem(e);
+ }
+
}
- class VpeSelectionProvider implements ISelectionProvider {
- VpeSelection selection;
+ }
- public VpeSelectionProvider(IndexedRegion region) {
- selection = new VpeSelection(region);
- }
+ class VpeSelectionProvider implements ISelectionProvider {
+ VpeSelection selection;
- public VpeSelectionProvider(int position) {
- selection = new VpeSelection(position);
- }
+ public VpeSelectionProvider(IndexedRegion region) {
+ selection = new VpeSelection(region);
+ }
- public VpeSelectionProvider(int offset, int length) {
- selection = new VpeSelection(offset, length);
- }
+ public VpeSelectionProvider(int position) {
+ selection = new VpeSelection(position);
+ }
- public void addSelectionChangedListener(
- ISelectionChangedListener listener) {
- }
+ public VpeSelectionProvider(int offset, int length) {
+ selection = new VpeSelection(offset, length);
+ }
- public ISelection getSelection() {
- return selection;
- }
+ public void addSelectionChangedListener(
+ ISelectionChangedListener listener) {
+ }
- public void removeSelectionChangedListener(
- ISelectionChangedListener listener) {
+ public ISelection getSelection() {
+ return selection;
+ }
- }
+ public void removeSelectionChangedListener(
+ ISelectionChangedListener listener) {
- public void setSelection(ISelection selection) {
- }
}
- class VpeSelection implements ITextSelection {
- String text = ""; //$NON-NLS-1$
- int offset, length;
+ public void setSelection(ISelection selection) {
+ }
+ }
- public VpeSelection(int position) {
- offset = position;
- length = 0;
- }
+ class VpeSelection implements ITextSelection {
+ String text = ""; //$NON-NLS-1$
+ int offset, length;
- public VpeSelection(int offset, int length) {
- this.offset = offset;
- this.length = length;
- if (length > 0) {
- try {
- text = sourceEditor.getTextViewer().getDocument().get(
- offset, length);
- } catch (Exception ex) {
- VpePlugin.reportProblem(ex);
- }
- }
- }
+ public VpeSelection(int position) {
+ offset = position;
+ length = 0;
+ }
- public VpeSelection(IndexedRegion region) {
- offset = region.getStartOffset();
- length = region.getEndOffset() - offset;
- try {
- text = sourceEditor.getTextViewer().getDocument().get(offset,
- length);
- } catch (Exception ex) {
- VpePlugin.reportProblem(ex);
- }
+ public VpeSelection(int offset, int length) {
+ this.offset = offset;
+ this.length = length;
+ if (length > 0) {
+ try {
+ text = sourceEditor.getTextViewer().getDocument().get(
+ offset, length);
+ } catch (Exception ex) {
+ VpePlugin.reportProblem(ex);
}
+ }
+ }
- public int getEndLine() {
- return 0;
- }
+ public VpeSelection(IndexedRegion region) {
+ offset = region.getStartOffset();
+ length = region.getEndOffset() - offset;
+ try {
+ text = sourceEditor.getTextViewer().getDocument().get(offset,
+ length);
+ } catch (Exception ex) {
+ VpePlugin.reportProblem(ex);
+ }
+ }
- public int getLength() {
- return length;
- }
+ public int getEndLine() {
+ return 0;
+ }
- public int getOffset() {
- return offset;
- }
+ public int getLength() {
+ return length;
+ }
- public int getStartLine() {
- return 0;
- }
+ public int getOffset() {
+ return offset;
+ }
- public String getText() {
- return text;
- }
+ public int getStartLine() {
+ return 0;
+ }
- public boolean isEmpty() {
- return false;
- }
+ public String getText() {
+ return text;
}
- class VpeAction extends Action {
- public Node actionNode;
-
- public VpeAction(String name, Node node) {
- super(name);
- this.actionNode = node;
- }
+ public boolean isEmpty() {
+ return false;
}
+ }
- class VpeTextOperationAction extends Action {
- private String id;
- private IndexedRegion region;
+ class VpeAction extends Action {
+ public Node actionNode;
- public VpeTextOperationAction(String name, String id,
- IndexedRegion region) {
- super(name);
- this.id = id;
- this.region = region;
- }
-
- public void run() {
- sourceEditor.getSelectionProvider().setSelection(
- new VpeSelection(region));
- sourceEditor.getAction(id).run();
- }
+ public VpeAction(String name, Node node) {
+ super(name);
+ this.actionNode = node;
}
+ }
- public void refreshExternalLinks() {
- pageContext.getVisualBuilder().refreshExternalLinks();
+ class VpeTextOperationAction extends Action {
+ private String id;
+ private IndexedRegion region;
+
+ public VpeTextOperationAction(String name, String id,
+ IndexedRegion region) {
+ super(name);
+ this.id = id;
+ this.region = region;
}
- public IPath getPath() {
- if (editPart != null) {
- IEditorInput input = editPart.getEditorInput();
- if (input != null && input instanceof IFileEditorInput) {
- return ((IFileEditorInput) input).getFile().getFullPath();
- }
- }
- return null;
+ public void run() {
+ sourceEditor.getSelectionProvider().setSelection(
+ new VpeSelection(region));
+ sourceEditor.getAction(id).run();
}
+ }
- public void changed(Object source) {
- if (cssReferenceListListener == source) {
- pageContext.getVisualBuilder().refreshExternalLinks();
- } else if (absoluteFolderReferenceListListener == source
- || relativeFolderReferenceListListener == source
- || taglibReferenceListListener == source) {
- visualRefresh();
- }
+ public void refreshExternalLinks() {
+ pageContext.getVisualBuilder().refreshExternalLinks();
+ }
+
+ public IPath getPath() {
+ if (editPart != null) {
+ IEditorInput input = editPart.getEditorInput();
+ if (input != null && input instanceof IFileEditorInput) {
+ return ((IFileEditorInput) input).getFile().getFullPath();
+ }
}
+ return null;
+ }
- public void dragEnter(nsIDOMEvent event) {
- if (VpeDebug.PRINT_VISUAL_DRAGDROP_EVENT) {
- System.out.println("<<<<<<<<<<<<<<<<<<<<
DragEnter"); //$NON-NLS-1$
- }
+ public void changed(Object source) {
+ if (cssReferenceListListener == source) {
+ pageContext.getVisualBuilder().refreshExternalLinks();
+ } else if (absoluteFolderReferenceListListener == source
+ || relativeFolderReferenceListListener == source
+ || taglibReferenceListListener == source) {
+ visualRefresh();
}
+ }
- public void dragExit(nsIDOMEvent event) {
- if (VpeDebug.PRINT_VISUAL_DRAGDROP_EVENT) {
- System.out.println("<<<<<<<<<<<<<<<<<<<<
dragExit"); //$NON-NLS-1$
- }
- // TODO Sergey Vasilyev figure out with drag caret
- // xulRunnerEditor.hideDragCaret();
+ public void dragEnter(nsIDOMEvent event) {
+ if (VpeDebug.PRINT_VISUAL_DRAGDROP_EVENT) {
+
System.out.println("<<<<<<<<<<<<<<<<<<<<
DragEnter"); //$NON-NLS-1$
}
+ }
- public void dragOver(nsIDOMEvent event) {
- visualBuilder.getDnd().dragOver(event, this);
+ public void dragExit(nsIDOMEvent event) {
+ if (VpeDebug.PRINT_VISUAL_DRAGDROP_EVENT) {
+
System.out.println("<<<<<<<<<<<<<<<<<<<<
dragExit"); //$NON-NLS-1$
}
+ // TODO Sergey Vasilyev figure out with drag caret
+ // xulRunnerEditor.hideDragCaret();
+ }
- public void _dragOver(nsIDOMEvent event) {
+ public void dragOver(nsIDOMEvent event) {
+ visualBuilder.getDnd().dragOver(event, this);
+ }
+
+ public void _dragOver(nsIDOMEvent event) {
if (!switcher
.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
return;
@@ -2430,565 +2351,564 @@
}
}
- public void drop(nsIDOMEvent event) {
- if (VpeDebug.PRINT_VISUAL_DRAGDROP_EVENT) {
- System.out.println("<<< outerDrop"); //$NON-NLS-1$
- }
- event.preventDefault();
+ public void drop(nsIDOMEvent event) {
+ if (VpeDebug.PRINT_VISUAL_DRAGDROP_EVENT) {
+ System.out.println("<<< outerDrop"); //$NON-NLS-1$
}
+ event.preventDefault();
+ }
- public boolean canInnerDrag(nsIDOMMouseEvent event) {
- onHideTooltip();
+ public boolean canInnerDrag(nsIDOMMouseEvent event) {
+ onHideTooltip();
- if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
- System.out.print("<<<<<< canInnerDrag"); //$NON-NLS-1$
- }
- if (innerDragInfo != null) {
- innerDragInfo.Release();
- innerDragInfo = null;
- }
- boolean canDrag = false;
- VpeVisualInnerDragInfo dragInfo = selectionBuilder
- .getInnerDragInfo(event);
- if (dragInfo != null) {
- nsIDOMNode dragNode = dragInfo.getNode();
- if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
- System.out
- .print(" dragNode: " + dragNode.getNodeName() + "(" + dragNode
+ ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
+ System.out.print("<<<<<< canInnerDrag"); //$NON-NLS-1$
+ }
+ if (innerDragInfo != null) {
+ innerDragInfo.Release();
+ innerDragInfo = null;
+ }
+ boolean canDrag = false;
+ VpeVisualInnerDragInfo dragInfo = selectionBuilder
+ .getInnerDragInfo(event);
+ if (dragInfo != null) {
+ nsIDOMNode dragNode = dragInfo.getNode();
+ if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
+ System.out
+ .print(" dragNode: " + dragNode.getNodeName() + "(" + dragNode +
")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ switch (dragNode.getNodeType()) {
+ case nsIDOMNode.ELEMENT_NODE:
+ canDrag = visualBuilder.canInnerDrag((nsIDOMElement) dragNode);
+ case nsIDOMNode.TEXT_NODE:
+ canDrag = visualBuilder.isTextEditable(dragNode);
+ }
+ if (canDrag) {
+ VpeSourceInnerDragInfo sourceInnerDragInfo = visualBuilder
+ .getSourceInnerDragInfo(dragInfo);
+ if (sourceInnerDragInfo.getNode() != null) {
+ innerDragInfo = dragInfo;
+ InnerDragBuffer.object = sourceInnerDragInfo.getNode();
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ InnerDragBuffer.object = null;
}
- switch (dragNode.getNodeType()) {
- case nsIDOMNode.ELEMENT_NODE:
- canDrag = visualBuilder.canInnerDrag((nsIDOMElement) dragNode);
- case nsIDOMNode.TEXT_NODE:
- canDrag = visualBuilder.isTextEditable(dragNode);
- }
- if (canDrag) {
- VpeSourceInnerDragInfo sourceInnerDragInfo = visualBuilder
- .getSourceInnerDragInfo(dragInfo);
- if (sourceInnerDragInfo.getNode() != null) {
- innerDragInfo = dragInfo;
- InnerDragBuffer.object = sourceInnerDragInfo.getNode();
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- InnerDragBuffer.object = null;
- }
- });
- } else {
- canDrag = false;
- }
- }
- if (!canDrag) {
- dragInfo.Release();
- }
+ });
+ } else {
+ canDrag = false;
}
- if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
- System.out.println(" canDrag: " + canDrag); //$NON-NLS-1$
- }
- return canDrag;
+ }
+ if (!canDrag) {
+ dragInfo.Release();
+ }
}
+ if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
+ System.out.println(" canDrag: " + canDrag); //$NON-NLS-1$
+ }
+ return canDrag;
+ }
- VpeDropWindow dropWindow = null;
+ VpeDropWindow dropWindow = null;
- public MozillaDropInfo canInnerDrop(nsIDOMMouseEvent event) {
- onHideTooltip();
+ public MozillaDropInfo canInnerDrop(nsIDOMMouseEvent event) {
+ onHideTooltip();
- if (dropWindow.active) {
- if (!event.getAltKey()) {
- dropWindow.close();
- } else {
- return null;
- }
- }
- if (event.getAltKey()) {
- nsIDOMNode visualNode = VisualDomUtil.getTargetNode(event);
- Node sourceNode = domMapping.getNearSourceNode(visualNode);
- if (sourceNode != null) {
- dropWindow.active = true;
- dropWindow.setEventPosition(event.getScreenX(), event
- .getScreenY());
- dropWindow.setInitialTargetNode(sourceNode);
- dropWindow.open();
- event.stopPropagation();
- event.preventDefault();
- return null;
- }
- }
+ if (dropWindow.active) {
+ if (!event.getAltKey()) {
+ dropWindow.close();
+ } else {
+ return null;
+ }
+ }
+ if (event.getAltKey()) {
+ nsIDOMNode visualNode = VisualDomUtil.getTargetNode(event);
+ Node sourceNode = domMapping.getNearSourceNode(visualNode);
+ if (sourceNode != null) {
+ dropWindow.active = true;
+ dropWindow.setEventPosition(event.getScreenX(), event
+ .getScreenY());
+ dropWindow.setInitialTargetNode(sourceNode);
+ dropWindow.open();
+ event.stopPropagation();
+ event.preventDefault();
+ return null;
+ }
+ }
+ if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
+ System.out.print("<<<<<< canInnerDrop"); //$NON-NLS-1$
+ }
+ boolean canDrop = false;
+ ;
+ nsIDOMNode caretParent = null;
+ long caretOffset = 0;
+ if (innerDragInfo != null) {
+ VpeVisualInnerDropInfo visualDropInfo = selectionBuilder
+ .getInnerDropInfo(event);
+ if (visualDropInfo.getDropContainer() != null) {
if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
- System.out.print("<<<<<< canInnerDrop"); //$NON-NLS-1$
+ System.out
+ .print(" x: " + visualDropInfo.getMouseX() + " y: " +
visualDropInfo.getMouseY() + //$NON-NLS-1$ //$NON-NLS-2$
+ " container: "
+ + visualDropInfo.getDropContainer()
+ .getNodeName()
+ + //$NON-NLS-1$
+ "("
+ + visualDropInfo.getDropContainer()
+ + ")" + //$NON-NLS-1$ //$NON-NLS-2$
+ " parent: "
+ + visualDropInfo.getDropContainer()
+ .getParentNode().getNodeName()
+ + //$NON-NLS-1$
+ "("
+ + visualDropInfo.getDropContainer()
+ .getParentNode() + ")" + //$NON-NLS-1$ //$NON-NLS-2$
+ " offset: "
+ + visualDropInfo.getDropOffset()); //$NON-NLS-1$
}
- boolean canDrop = false;
- ;
- nsIDOMNode caretParent = null;
- long caretOffset = 0;
- if (innerDragInfo != null) {
- VpeVisualInnerDropInfo visualDropInfo = selectionBuilder
- .getInnerDropInfo(event);
- if (visualDropInfo.getDropContainer() != null) {
- if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
- System.out
- .print(" x: " + visualDropInfo.getMouseX() + " y: " +
visualDropInfo.getMouseY() + //$NON-NLS-1$ //$NON-NLS-2$
- " container: "
- + visualDropInfo.getDropContainer()
- .getNodeName()
- + //$NON-NLS-1$
- "("
- + visualDropInfo.getDropContainer()
- + ")" + //$NON-NLS-1$ //$NON-NLS-2$
- " parent: "
- + visualDropInfo.getDropContainer()
- .getParentNode().getNodeName()
- + //$NON-NLS-1$
- "("
- + visualDropInfo.getDropContainer()
- .getParentNode() + ")" + //$NON-NLS-1$ //$NON-NLS-2$
- " offset: "
- + visualDropInfo.getDropOffset()); //$NON-NLS-1$
- }
- VpeSourceInnerDragInfo sourceInnerDragInfo = visualBuilder
- .getSourceInnerDragInfo(innerDragInfo);
- VpeSourceInnerDropInfo sourceDropInfo = visualBuilder
- .getSourceInnerDropInfo(sourceInnerDragInfo.getNode(),
- visualDropInfo, true);
- canDrop = sourceDropInfo.canDrop();
- if (canDrop) {
- VpeVisualInnerDropInfo newVisualDropInfo = visualBuilder
- .getInnerDropInfo(sourceDropInfo.getContainer(),
- sourceDropInfo.getOffset());
- if (newVisualDropInfo != null) {
- visualBuilder.correctVisualDropPosition(
- newVisualDropInfo, visualDropInfo);
- caretParent = newVisualDropInfo.getDropContainer();
- caretOffset = newVisualDropInfo.getDropOffset();
- }
- }
- }
- visualDropInfo.Release();
+ VpeSourceInnerDragInfo sourceInnerDragInfo = visualBuilder
+ .getSourceInnerDragInfo(innerDragInfo);
+ VpeSourceInnerDropInfo sourceDropInfo = visualBuilder
+ .getSourceInnerDropInfo(sourceInnerDragInfo.getNode(),
+ visualDropInfo, true);
+ canDrop = sourceDropInfo.canDrop();
+ if (canDrop) {
+ VpeVisualInnerDropInfo newVisualDropInfo = visualBuilder
+ .getInnerDropInfo(sourceDropInfo.getContainer(),
+ sourceDropInfo.getOffset());
+ if (newVisualDropInfo != null) {
+ visualBuilder.correctVisualDropPosition(
+ newVisualDropInfo, visualDropInfo);
+ caretParent = newVisualDropInfo.getDropContainer();
+ caretOffset = newVisualDropInfo.getDropOffset();
+ }
}
- if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
- System.out.println(" canDrop: " + canDrop); //$NON-NLS-1$
- }
- return new MozillaDropInfo(canDrop, caretParent, caretOffset);
+ }
+ visualDropInfo.Release();
}
+ if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
+ System.out.println(" canDrop: " + canDrop); //$NON-NLS-1$
+ }
+ return new MozillaDropInfo(canDrop, caretParent, caretOffset);
+ }
- public void innerDrop(nsIDOMMouseEvent event) {
- onHideTooltip();
+ public void innerDrop(nsIDOMMouseEvent event) {
+ onHideTooltip();
+ if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
+ System.out.print("<<<<<< innerDrop"); //$NON-NLS-1$
+ }
+ if (innerDragInfo != null) {
+ VpeVisualInnerDropInfo visualDropInfo = selectionBuilder
+ .getInnerDropInfo(event);
+ if (visualDropInfo.getDropContainer() != null) {
if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
- System.out.print("<<<<<< innerDrop"); //$NON-NLS-1$
+ System.out
+ .print(" container: " + visualDropInfo.getDropContainer().getNodeName()
+ //$NON-NLS-1$
+ "(" + visualDropInfo.getDropContainer()
+ + ")" + //$NON-NLS-1$ //$NON-NLS-2$
+ " offset: "
+ + visualDropInfo.getDropOffset()); //$NON-NLS-1$
}
- if (innerDragInfo != null) {
- VpeVisualInnerDropInfo visualDropInfo = selectionBuilder
- .getInnerDropInfo(event);
- if (visualDropInfo.getDropContainer() != null) {
- if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
- System.out
- .print(" container: " + visualDropInfo.getDropContainer().getNodeName()
+ //$NON-NLS-1$
- "(" + visualDropInfo.getDropContainer()
- + ")" + //$NON-NLS-1$ //$NON-NLS-2$
- " offset: "
- + visualDropInfo.getDropOffset()); //$NON-NLS-1$
- }
- VpeSourceInnerDragInfo sourceInnerDragInfo = visualBuilder
- .getSourceInnerDragInfo(innerDragInfo);
- VpeSourceInnerDropInfo sourceDropInfo = visualBuilder
- .getSourceInnerDropInfo(sourceInnerDragInfo.getNode(),
- visualDropInfo, true);
- if (sourceDropInfo.canDrop()) {
- VpeVisualInnerDropInfo newVisualDropInfo = visualBuilder
- .getInnerDropInfo(sourceDropInfo.getContainer(),
- sourceDropInfo.getOffset());
- if (newVisualDropInfo != null) {
- visualBuilder.correctVisualDropPosition(
- newVisualDropInfo, visualDropInfo);
- sourceDropInfo.setTop(visualDropInfo.getMouseY());
- sourceDropInfo.setLeft(visualDropInfo.getMouseX());
- visualBuilder.innerDrop(sourceInnerDragInfo,
- sourceDropInfo);
- if (innerDragInfo != null) {
- innerDragInfo.Release();
- innerDragInfo = null;
- }
- }
- }
+ VpeSourceInnerDragInfo sourceInnerDragInfo = visualBuilder
+ .getSourceInnerDragInfo(innerDragInfo);
+ VpeSourceInnerDropInfo sourceDropInfo = visualBuilder
+ .getSourceInnerDropInfo(sourceInnerDragInfo.getNode(),
+ visualDropInfo, true);
+ if (sourceDropInfo.canDrop()) {
+ VpeVisualInnerDropInfo newVisualDropInfo = visualBuilder
+ .getInnerDropInfo(sourceDropInfo.getContainer(),
+ sourceDropInfo.getOffset());
+ if (newVisualDropInfo != null) {
+ visualBuilder.correctVisualDropPosition(
+ newVisualDropInfo, visualDropInfo);
+ sourceDropInfo.setTop(visualDropInfo.getMouseY());
+ sourceDropInfo.setLeft(visualDropInfo.getMouseX());
+ visualBuilder.innerDrop(sourceInnerDragInfo,
+ sourceDropInfo);
+ if (innerDragInfo != null) {
+ innerDragInfo.Release();
+ innerDragInfo = null;
}
+ }
}
- if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
- System.out.println();
- }
+ }
}
+ if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
+ System.out.println();
+ }
+ }
- public MozillaDropInfo canExternalDrop(nsIDOMMouseEvent mouseEvent,
- String flavor, String data) {
- InnerDragBuffer.object = null;
- onHideTooltip();
+ public MozillaDropInfo canExternalDrop(nsIDOMMouseEvent mouseEvent,
+ String flavor, String data) {
+ InnerDragBuffer.object = null;
+ onHideTooltip();
- if (dropWindow.active) {
- if (!mouseEvent.getAltKey()) {
- dropWindow.close();
- } else {
- return new MozillaDropInfo(false, null, 0);
- }
+ if (dropWindow.active) {
+ if (!mouseEvent.getAltKey()) {
+ dropWindow.close();
+ } else {
+ return new MozillaDropInfo(false, null, 0);
+ }
+ }
+ if (mouseEvent.getAltKey()) {
+ nsIDOMEvent event = (nsIDOMEvent) mouseEvent
+ .queryInterface(nsIDOMEvent.NS_IDOMEVENT_IID);
+ nsIDOMNode visualNode = (nsIDOMNode) event.getTarget()
+ .queryInterface(nsIDOMNode.NS_IDOMNODE_IID);
+ Node sourceNode = domMapping.getNearSourceNode(visualNode);
+ if (sourceNode != null) {
+ if (ModelTransfer.MODEL.equals(flavor)) { //$NON-NLS-1$
+ // XModelObject object =
+ // PreferenceModelUtilities.getPreferenceModel().getModelBuffer().source();
+ // InnerDragBuffer.object = object;
+ } else {
+ dropWindow.flavor = flavor;
}
- if (mouseEvent.getAltKey()) {
- nsIDOMEvent event = (nsIDOMEvent) mouseEvent
- .queryInterface(nsIDOMEvent.NS_IDOMEVENT_IID);
- nsIDOMNode visualNode = (nsIDOMNode) event.getTarget()
- .queryInterface(nsIDOMNode.NS_IDOMNODE_IID);
- Node sourceNode = domMapping.getNearSourceNode(visualNode);
- if (sourceNode != null) {
- if (ModelTransfer.MODEL.equals(flavor)) { //$NON-NLS-1$
- // XModelObject object =
- // PreferenceModelUtilities.getPreferenceModel().
- // getModelBuffer().source();
- // InnerDragBuffer.object = object;
- } else {
- dropWindow.flavor = flavor;
- }
- dropWindow.active = true;
- dropWindow.setEventPosition(mouseEvent.getScreenX(), mouseEvent
- .getScreenY());
- dropWindow.setInitialTargetNode(sourceNode);
- dropWindow.open();
- mouseEvent.stopPropagation();
- mouseEvent.preventDefault();
- return new MozillaDropInfo(false, null, 0);
- }
- }
- boolean canDrop = false;
- nsIDOMNode caretParent = null;
- long caretOffset = 0;
+ dropWindow.active = true;
+ dropWindow.setEventPosition(mouseEvent.getScreenX(), mouseEvent
+ .getScreenY());
+ dropWindow.setInitialTargetNode(sourceNode);
+ dropWindow.open();
+ mouseEvent.stopPropagation();
+ mouseEvent.preventDefault();
+ return new MozillaDropInfo(false, null, 0);
+ }
+ }
+ boolean canDrop = false;
+ nsIDOMNode caretParent = null;
+ long caretOffset = 0;
- if (MODEL_FLAVOR.equals(flavor)) {
- XModelObject object = PreferenceModelUtilities.getPreferenceModel()
- .getModelBuffer().source();
- if (object.getFileType() == XModelObject.FILE
- && !TLDUtil.isTaglib(object)) {
- IFile f = (IFile) EclipseResourceUtil.getResource(object);
- canDrop = f != null;
- VpeVisualInnerDropInfo visualDropInfo = selectionBuilder
- .getInnerDropInfo(mouseEvent);
- caretParent = visualDropInfo.getDropContainer();
- caretOffset = visualDropInfo.getDropOffset();
- } else {
- String tagname = getTagName(object);
- if (tagname.indexOf("taglib") >= 0)tagname = "taglib";
//$NON-NLS-1$ //$NON-NLS-2$
- Node sourceDragNode = ((Document) getModel().getAdapter(
- Document.class)).createElement(tagname);
- VpeVisualInnerDropInfo visualDropInfo = selectionBuilder
- .getInnerDropInfo(mouseEvent);
- if (visualDropInfo.getDropContainer() != null) {
- VpeSourceInnerDropInfo sourceDropInfo = visualBuilder
- .getSourceInnerDropInfo(sourceDragNode,
- visualDropInfo, true);
- canDrop = sourceDropInfo.canDrop();
- if (canDrop) {
- VpeVisualInnerDropInfo newVisualDropInfo = visualBuilder
- .getInnerDropInfo(
- sourceDropInfo.getContainer(),
- sourceDropInfo.getOffset());
- if (newVisualDropInfo != null) {
- visualBuilder.correctVisualDropPosition(
- newVisualDropInfo, visualDropInfo);
- caretParent = newVisualDropInfo.getDropContainer();
- caretOffset = newVisualDropInfo.getDropOffset();
- }
- }
- }
- visualDropInfo.Release();
+ if (MODEL_FLAVOR.equals(flavor)) {
+ XModelObject object = PreferenceModelUtilities.getPreferenceModel()
+ .getModelBuffer().source();
+ if (object.getFileType() == XModelObject.FILE
+ && !TLDUtil.isTaglib(object)) {
+ IFile f = (IFile) EclipseResourceUtil.getResource(object);
+ canDrop = f != null;
+ VpeVisualInnerDropInfo visualDropInfo = selectionBuilder
+ .getInnerDropInfo(mouseEvent);
+ caretParent = visualDropInfo.getDropContainer();
+ caretOffset = visualDropInfo.getDropOffset();
+ } else {
+ String tagname = getTagName(object);
+ if (tagname.indexOf("taglib") >= 0)tagname = "taglib";
//$NON-NLS-1$ //$NON-NLS-2$
+ Node sourceDragNode = ((Document) getModel().getAdapter(
+ Document.class)).createElement(tagname);
+ VpeVisualInnerDropInfo visualDropInfo = selectionBuilder
+ .getInnerDropInfo(mouseEvent);
+ if (visualDropInfo.getDropContainer() != null) {
+ VpeSourceInnerDropInfo sourceDropInfo = visualBuilder
+ .getSourceInnerDropInfo(sourceDragNode,
+ visualDropInfo, true);
+ canDrop = sourceDropInfo.canDrop();
+ if (canDrop) {
+ VpeVisualInnerDropInfo newVisualDropInfo = visualBuilder
+ .getInnerDropInfo(
+ sourceDropInfo.getContainer(),
+ sourceDropInfo.getOffset());
+ if (newVisualDropInfo != null) {
+ visualBuilder.correctVisualDropPosition(
+ newVisualDropInfo, visualDropInfo);
+ caretParent = newVisualDropInfo.getDropContainer();
+ caretOffset = newVisualDropInfo.getDropOffset();
}
- } else if (XulRunnerEditor.TRANS_FLAVOR_kFileMime.equals(flavor)
- || XulRunnerEditor.TRANS_FLAVOR_kURLMime.equals(flavor)) {
- VpeVisualInnerDropInfo visualDropInfo = selectionBuilder
- .getInnerDropInfo(mouseEvent);
- caretParent = visualDropInfo.getDropContainer();
- caretOffset = visualDropInfo.getDropOffset();
- try {
- canDrop = true;
- } catch (Exception ex) {
- VpePlugin.reportProblem(ex);
- }
+ }
}
- if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
- System.out
- .println(" canDrop: " + canDrop + (canDrop ? " container: " +
caretParent.getNodeName() + " offset: " + caretOffset : ""));
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
- return new MozillaDropInfo(canDrop, caretParent, caretOffset);
-
+ visualDropInfo.Release();
+ }
+ } else if (XulRunnerEditor.TRANS_FLAVOR_kFileMime.equals(flavor)
+ || XulRunnerEditor.TRANS_FLAVOR_kURLMime.equals(flavor)) {
+ VpeVisualInnerDropInfo visualDropInfo = selectionBuilder
+ .getInnerDropInfo(mouseEvent);
+ caretParent = visualDropInfo.getDropContainer();
+ caretOffset = visualDropInfo.getDropOffset();
+ try {
+ canDrop = true;
+ } catch (Exception ex) {
+ VpePlugin.reportProblem(ex);
+ }
}
-
- public VpeSourceInnerDropInfo canExternalDropMacro(XModelObject object,
- Node parentNode, int offset) {
- String tagname = getTagName(object);
- Node sourceDragNode = ((Document) getModel().getAdapter(Document.class))
- .createElement(tagname);
- return visualBuilder.getSourceInnerDropInfo(sourceDragNode, parentNode,
- offset, false);
+ if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
+ System.out
+ .println(" canDrop: " + canDrop + (canDrop ? " container: " +
caretParent.getNodeName() + " offset: " + caretOffset : ""));
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
}
+ return new MozillaDropInfo(canDrop, caretParent, caretOffset);
- public void externalDropAny(final String flavor, final String data,
- final Point range, Node container) {
- if (flavor == null || flavor.length() == 0)
- return;
- IDropCommand dropCommand = DropCommandFactory.getInstance()
- .getDropCommand(flavor, JSPTagProposalFactory.getInstance());
+ }
- boolean promptAttributes = "yes"
- .equals(VpePreference.ALWAYS_REQUEST_FOR_ATTRIBUTE.getValue());
- dropCommand.getDefaultModel().setPromptForTagAttributesRequired(
- promptAttributes);
+ public VpeSourceInnerDropInfo canExternalDropMacro(XModelObject object,
+ Node parentNode, int offset) {
+ String tagname = getTagName(object);
+ Node sourceDragNode = ((Document) getModel().getAdapter(Document.class))
+ .createElement(tagname);
+ return visualBuilder.getSourceInnerDropInfo(sourceDragNode, parentNode,
+ offset, false);
+ }
- dropCommand.execute(new DropData(flavor, data, sourceEditor
- .getEditorInput(), (ISourceViewer) sourceEditor
- .getAdapter(ISourceViewer.class), new VpeSelectionProvider(
- range.x, range.y), container));
- }
+ public void externalDropAny(final String flavor, final String data,
+ final Point range, Node container) {
+ if (flavor == null || flavor.length() == 0)
+ return;
+ IDropCommand dropCommand = DropCommandFactory.getInstance()
+ .getDropCommand(flavor, JSPTagProposalFactory.getInstance());
- private String getTagName(XModelObject object) {
- String tagname = object.getAttributeValue("name"); //$NON-NLS-1$
+ boolean promptAttributes = "yes"
+ .equals(VpePreference.ALWAYS_REQUEST_FOR_ATTRIBUTE.getValue());
+ dropCommand.getDefaultModel().setPromptForTagAttributesRequired(
+ promptAttributes);
- XModelObject parent = object.getParent();
- String uri = (parent == null) ? "" :
parent.getAttributeValue(URIConstants.LIBRARY_URI); //$NON-NLS-1$
- String defaultPrefix = (parent == null) ? "" :
parent.getAttributeValue(URIConstants.DEFAULT_PREFIX); //$NON-NLS-1$
+ dropCommand.execute(new DropData(flavor, data, sourceEditor
+ .getEditorInput(), (ISourceViewer) sourceEditor
+ .getAdapter(ISourceViewer.class), new VpeSelectionProvider(
+ range.x, range.y), container));
+ }
- String[] texts = new String[] { "<" + tagname + ">" };
//$NON-NLS-1$ //$NON-NLS-2$
- PaletteInsertHelper.applyPrefix(texts, sourceEditor, tagname, uri,
- defaultPrefix);
- tagname = texts[0].substring(1, texts[0].length() - 1);
+ private String getTagName(XModelObject object) {
+ String tagname = object.getAttributeValue("name"); //$NON-NLS-1$
- return tagname;
- }
+ XModelObject parent = object.getParent();
+ String uri = (parent == null) ? "" :
parent.getAttributeValue(URIConstants.LIBRARY_URI); //$NON-NLS-1$
+ String defaultPrefix = (parent == null) ? "" :
parent.getAttributeValue(URIConstants.DEFAULT_PREFIX); //$NON-NLS-1$
- public void externalDrop(nsIDOMMouseEvent mouseEvent, String flavor,
- String data) {
- onHideTooltip();
+ String[] texts = new String[] { "<" + tagname + ">" };
//$NON-NLS-1$ //$NON-NLS-2$
+ PaletteInsertHelper.applyPrefix(texts, sourceEditor, tagname, uri,
+ defaultPrefix);
+ tagname = texts[0].substring(1, texts[0].length() - 1);
- VpeVisualInnerDropInfo visualDropInfo = selectionBuilder
- .getInnerDropInfo(mouseEvent);
- Point range = selectionBuilder.getSourceSelectionRangeAtVisualNode(
- visualDropInfo.getDropContainer(), (int) visualDropInfo
- .getDropOffset());
- VpeSourceInnerDropInfo sourceDropInfo = null;
+ return tagname;
+ }
- if (MODEL_FLAVOR.equals(flavor)) {
- XModelObject object = PreferenceModelUtilities.getPreferenceModel()
- .getModelBuffer().source();
- if (object.getFileType() == XModelObject.FILE
- && !TLDUtil.isTaglib(object)) {
- flavor = "application/x-moz-file"; //$NON-NLS-1$
- IFile f = (IFile) EclipseResourceUtil.getResource(object);
- try {
- data = f.getLocation().toFile().toURL().toString();
- } catch (Exception e) {
- VpePlugin.getPluginLog().logError(e);
- }
- } else {
- String tagname = getTagName(object);
- if (tagname.indexOf("taglib") >= 0)tagname = "taglib";
//$NON-NLS-1$ //$NON-NLS-2$
- Node sourceDragNode = ((Document) getModel().getAdapter(
- Document.class)).createElement(tagname);
- if (visualDropInfo.getDropContainer() != null) {
- sourceDropInfo = visualBuilder.getSourceInnerDropInfo(
- sourceDragNode, visualDropInfo, true);
- range = selectionBuilder.getSourceSelectionRange(
- sourceDropInfo.getContainer(), sourceDropInfo
- .getOffset());
- }
- }
- }
+ public void externalDrop(nsIDOMMouseEvent mouseEvent, String flavor,
+ String data) {
+ onHideTooltip();
+ VpeVisualInnerDropInfo visualDropInfo = selectionBuilder
+ .getInnerDropInfo(mouseEvent);
+ Point range = selectionBuilder.getSourceSelectionRangeAtVisualNode(
+ visualDropInfo.getDropContainer(), (int) visualDropInfo
+ .getDropOffset());
+ VpeSourceInnerDropInfo sourceDropInfo = null;
+
+ if (MODEL_FLAVOR.equals(flavor)) {
+ XModelObject object = PreferenceModelUtilities.getPreferenceModel()
+ .getModelBuffer().source();
+ if (object.getFileType() == XModelObject.FILE
+ && !TLDUtil.isTaglib(object)) {
+ flavor = "application/x-moz-file"; //$NON-NLS-1$
+ IFile f = (IFile) EclipseResourceUtil.getResource(object);
+ try {
+ data = f.getLocation().toFile().toURL().toString();
+ } catch (Exception e) {
+ VpePlugin.getPluginLog().logError(e);
+ }
+ } else {
+ String tagname = getTagName(object);
+ if (tagname.indexOf("taglib") >= 0)tagname = "taglib";
//$NON-NLS-1$ //$NON-NLS-2$
+ Node sourceDragNode = ((Document) getModel().getAdapter(
+ Document.class)).createElement(tagname);
if (visualDropInfo.getDropContainer() != null) {
- if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
- System.out
- .println(" drop! container: " +
visualDropInfo.getDropContainer().getNodeName()); //$NON-NLS-1$
- }
- externalDropAny(flavor, data, range, sourceDropInfo == null ? null
- : sourceDropInfo.getContainer());
+ sourceDropInfo = visualBuilder.getSourceInnerDropInfo(
+ sourceDragNode, visualDropInfo, true);
+ range = selectionBuilder.getSourceSelectionRange(
+ sourceDropInfo.getContainer(), sourceDropInfo
+ .getOffset());
}
+ }
}
- public void onShowTooltip(int x, int y, final String text) {
+ if (visualDropInfo.getDropContainer() != null) {
+ if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
+ System.out
+ .println(" drop! container: " +
visualDropInfo.getDropContainer().getNodeName()); //$NON-NLS-1$
+ }
+ externalDropAny(flavor, data, range, sourceDropInfo == null ? null
+ : sourceDropInfo.getContainer());
+ }
+ }
- if (tip != null && !tip.isDisposed())
- tip.dispose();
+ public void onShowTooltip(int x, int y, final String text) {
- Display display = visualEditor.getControl().getDisplay();
- Shell parent = visualEditor.getControl().getShell();
+ if (tip != null && !tip.isDisposed())
+ tip.dispose();
- tip = new Shell(parent, SWT.NO_FOCUS | SWT.ON_TOP);
- Color bckgColor = new Color(tip.getDisplay(), 255, 250, 236);
- tip.setBackground(bckgColor);
+ Display display = visualEditor.getControl().getDisplay();
+ Shell parent = visualEditor.getControl().getShell();
- Composite composite = tip;
- GridLayout layout = new GridLayout();
- layout.numColumns = 2;
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- layout.verticalSpacing = 0;
- layout.horizontalSpacing = 0;
- composite.setLayout(layout);
- GridData gd = new GridData(GridData.FILL_BOTH);
- composite.setLayoutData(gd);
+ tip = new Shell(parent, SWT.NO_FOCUS | SWT.ON_TOP);
+ Color bckgColor = new Color(tip.getDisplay(), 255, 250, 236);
+ tip.setBackground(bckgColor);
- final StyledText tipControlHeaderText = new StyledText(composite,
- SWT.MULTI | SWT.READ_ONLY);
+ Composite composite = tip;
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ layout.verticalSpacing = 0;
+ layout.horizontalSpacing = 0;
+ composite.setLayout(layout);
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ composite.setLayoutData(gd);
- tipControlHeaderText.setForeground(bckgColor);
- tipControlHeaderText.setBackground(bckgColor);
+ final StyledText tipControlHeaderText = new StyledText(composite,
+ SWT.MULTI | SWT.READ_ONLY);
- String formatText = text.trim();
+ tipControlHeaderText.setForeground(bckgColor);
+ tipControlHeaderText.setBackground(bckgColor);
- /**
- * attributeString string containing the pairs attribute and it's value
- * as one string
- */
- String[] attributeString = formatText.split("\n"); //$NON-NLS-1$
- /**
- * buffer string containing the attribute and the value in the different
- * succeding string
- */
- String[] buffer = attributeString[0].split(" "); //$NON-NLS-1$
+ String formatText = text.trim();
- tipControlHeaderText.setText(buffer[0].toString());
+ /**
+ * attributeString string containing the pairs attribute and it's value
+ * as one string
+ */
+ String[] attributeString = formatText.split("\n"); //$NON-NLS-1$
+ /**
+ * buffer string containing the attribute and the value in the different
+ * succeding string
+ */
+ String[] buffer = attributeString[0].split(" "); //$NON-NLS-1$
- tipControlHeaderText.addLineStyleListener(new LineStyleListener() {
- public void lineGetStyle(LineStyleEvent event) {
- Color color = new Color(tipControlHeaderText.getDisplay(), 201,
- 51, 40);
- if (event.lineOffset == 0) {
- StyleRange st = new StyleRange();
- st.fontStyle = SWT.BOLD;
- st.foreground = color;
- event.styles = new StyleRange[] { st };
- st.start = event.lineOffset;
- st.length = event.lineText.length();
- }
- }
- });
+ tipControlHeaderText.setText(buffer[0].toString());
- GridData gridData = new GridData(GridData.BEGINNING
- | GridData.FILL_BOTH);
- gridData.horizontalAlignment = GridData.FILL;
- gridData.horizontalSpan = 2;
- tipControlHeaderText.setLayoutData(gridData);
+ tipControlHeaderText.addLineStyleListener(new LineStyleListener() {
+ public void lineGetStyle(LineStyleEvent event) {
+ Color color = new Color(tipControlHeaderText.getDisplay(), 201,
+ 51, 40);
+ if (event.lineOffset == 0) {
+ StyleRange st = new StyleRange();
+ st.fontStyle = SWT.BOLD;
+ st.foreground = color;
+ event.styles = new StyleRange[] { st };
+ st.start = event.lineOffset;
+ st.length = event.lineText.length();
+ }
+ }
+ });
- StringBuffer tempAttr = new StringBuffer();
- StringBuffer tempValue = new StringBuffer();
+ GridData gridData = new GridData(GridData.BEGINNING
+ | GridData.FILL_BOTH);
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.horizontalSpan = 2;
+ tipControlHeaderText.setLayoutData(gridData);
- if (attributeString.length >= 2) {
- for (int i = 1; i < attributeString.length; i++) {
- buffer = attributeString[i].split(" ", 2); //$NON-NLS-1$
- if (i == 1) {
- tempAttr.append(buffer[0] + " "); //$NON-NLS-1$
- tempValue
- .append((buffer.length >= 2 ? buffer[1] : "") + " ");
//$NON-NLS-1$ //$NON-NLS-2$
- } else {
- tempAttr.append("\n" + buffer[0] + " "); //$NON-NLS-1$
//$NON-NLS-2$
- tempValue
- .append(" \n" + (buffer.length >= 2 ? buffer[1] : "") +
" "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
- }
+ StringBuffer tempAttr = new StringBuffer();
+ StringBuffer tempValue = new StringBuffer();
- final StyledText tipControlAttributeText = new StyledText(
- composite, SWT.MULTI | SWT.READ_ONLY);
+ if (attributeString.length >= 2) {
+ for (int i = 1; i < attributeString.length; i++) {
+ buffer = attributeString[i].split(" ", 2); //$NON-NLS-1$
+ if (i == 1) {
+ tempAttr.append(buffer[0] + " "); //$NON-NLS-1$
+ tempValue
+ .append((buffer.length >= 2 ? buffer[1] : "") + " ");
//$NON-NLS-1$ //$NON-NLS-2$
+ } else {
+ tempAttr.append("\n" + buffer[0] + " "); //$NON-NLS-1$
//$NON-NLS-2$
+ tempValue
+ .append(" \n" + (buffer.length >= 2 ? buffer[1] : "") +
" "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ }
- tipControlAttributeText.setForeground(bckgColor);
- tipControlAttributeText.setBackground(bckgColor);
+ final StyledText tipControlAttributeText = new StyledText(
+ composite, SWT.MULTI | SWT.READ_ONLY);
- tipControlAttributeText.setText(tempAttr.toString());
- tipControlAttributeText
- .addLineStyleListener(new LineStyleListener() {
- public void lineGetStyle(LineStyleEvent event) {
- Color color = new Color(tipControlHeaderText
- .getDisplay(), 42, 148, 0);
- StyleRange st = new StyleRange();
- st.start = event.lineOffset;
- st.length = event.lineText.length();
- st.foreground = color;
- st.fontStyle = SWT.NORMAL;
- event.styles = new StyleRange[] { st };
- }
- });
- GridData gridData1 = new GridData(GridData.BEGINNING
- | GridData.FILL_BOTH);
- gridData1.horizontalAlignment = GridData.FILL;
- tipControlAttributeText.setLayoutData(gridData1);
+ tipControlAttributeText.setForeground(bckgColor);
+ tipControlAttributeText.setBackground(bckgColor);
- final StyledText tipControlValueText = new StyledText(composite,
- SWT.MULTI | SWT.READ_ONLY);
+ tipControlAttributeText.setText(tempAttr.toString());
+ tipControlAttributeText
+ .addLineStyleListener(new LineStyleListener() {
+ public void lineGetStyle(LineStyleEvent event) {
+ Color color = new Color(tipControlHeaderText
+ .getDisplay(), 42, 148, 0);
+ StyleRange st = new StyleRange();
+ st.start = event.lineOffset;
+ st.length = event.lineText.length();
+ st.foreground = color;
+ st.fontStyle = SWT.NORMAL;
+ event.styles = new StyleRange[] { st };
+ }
+ });
+ GridData gridData1 = new GridData(GridData.BEGINNING
+ | GridData.FILL_BOTH);
+ gridData1.horizontalAlignment = GridData.FILL;
+ tipControlAttributeText.setLayoutData(gridData1);
- tipControlValueText.setBackground(bckgColor);
+ final StyledText tipControlValueText = new StyledText(composite,
+ SWT.MULTI | SWT.READ_ONLY);
- tipControlValueText.setText(tempValue.toString());
+ tipControlValueText.setBackground(bckgColor);
- GridData gridData2 = new GridData(GridData.BEGINNING
- | GridData.FILL_BOTH);
- gridData2.horizontalAlignment = GridData.FILL;
- tipControlValueText.setLayoutData(gridData2);
- }
- /*
- * Bug in Mozilla embedded API. Tooltip coordinates are wrong for
- * elements inside an inline frame (IFrame tag). The workaround is to
- * position the tooltip based on the mouse cursor location.
- */
- Point point = display.getCursorLocation();
- /*
- * Assuming cursor is 21x21 because this is the size of the arrow cursor
- * on Windows
- */
- point.y += 21;
- tip.setLocation(point);
- tip.pack();
- tip.setVisible(true);
- }
+ tipControlValueText.setText(tempValue.toString());
- public void onHideTooltip() {
- if (tip != null && !tip.isDisposed())
- tip.dispose();
- tip = null;
+ GridData gridData2 = new GridData(GridData.BEGINNING
+ | GridData.FILL_BOTH);
+ gridData2.horizontalAlignment = GridData.FILL;
+ tipControlValueText.setLayoutData(gridData2);
}
+ /*
+ * Bug in Mozilla embedded API. Tooltip coordinates are wrong for
+ * elements inside an inline frame (IFrame tag). The workaround is to
+ * position the tooltip based on the mouse cursor location.
+ */
+ Point point = display.getCursorLocation();
+ /*
+ * Assuming cursor is 21x21 because this is the size of the arrow cursor
+ * on Windows
+ */
+ point.y += 21;
+ tip.setLocation(point);
+ tip.pack();
+ tip.setVisible(true);
+ }
- public VpePageContext getPageContext() {
+ public void onHideTooltip() {
+ if (tip != null && !tip.isDisposed())
+ tip.dispose();
+ tip = null;
+ }
- return pageContext;
- }
+ public VpePageContext getPageContext() {
- public StructuredTextEditor getSourceEditor() {
- return sourceEditor;
- }
+ return pageContext;
+ }
- public FormatControllerManager getToolbarFormatControllerManager() {
- return toolbarFormatControllerManager;
- }
+ public StructuredTextEditor getSourceEditor() {
+ return sourceEditor;
+ }
- public void setToolbarFormatControllerManager(
- FormatControllerManager formatControllerManager) {
- toolbarFormatControllerManager = formatControllerManager;
- }
+ public FormatControllerManager getToolbarFormatControllerManager() {
+ return toolbarFormatControllerManager;
+ }
- public void setSelectionBarController(SelectionBar selectionBar) {
- this.selectionBar = selectionBar;
- }
+ public void setToolbarFormatControllerManager(
+ FormatControllerManager formatControllerManager) {
+ toolbarFormatControllerManager = formatControllerManager;
+ }
- public IStructuredModel getModel() {
- return sourceEditor.getModel();
- }
+ public void setSelectionBarController(SelectionBar selectionBar) {
+ this.selectionBar = selectionBar;
+ }
- public VpeDomMapping getDomMapping() {
- return domMapping;
- }
+ public IStructuredModel getModel() {
+ return sourceEditor.getModel();
+ }
- public VpeIncludeList getIncludeList() {
- try {
- if (includeList == null)
- throw new Exception("includeList - NULL!!!"); //$NON-NLS-1$
- } catch (Exception e) {
- VpePlugin.getPluginLog().logError(e);
- }
- return includeList;
+ public VpeDomMapping getDomMapping() {
+ return domMapping;
+ }
+
+ public VpeIncludeList getIncludeList() {
+ try {
+ if (includeList == null)
+ throw new Exception("includeList - NULL!!!"); //$NON-NLS-1$
+ } catch (Exception e) {
+ VpePlugin.getPluginLog().logError(e);
}
+ return includeList;
+ }
- public void selectionChanged(SelectionChangedEvent event) {
+ public void selectionChanged(SelectionChangedEvent event) {
// FIX for JBIDE-2114
if (!isVisualEditorVisible()) {
// selection event doesn't changes a content
@@ -3021,128 +2941,128 @@
}
}
- // nsIClipboardDragDropHooks implementation
- public void onPasteOrDrop(nsIDOMMouseEvent mouseEvent, String flavor,
- String data) {
- onHideTooltip();
+ // nsIClipboardDragDropHooks implementation
+ public void onPasteOrDrop(nsIDOMMouseEvent mouseEvent, String flavor,
+ String data) {
+ onHideTooltip();
- VpeVisualInnerDropInfo visualDropInfo = selectionBuilder
- .getInnerDropInfo(mouseEvent);
- Point range = selectionBuilder.getSourceSelectionRangeAtVisualNode(
- visualDropInfo.getDropContainer(), (int) visualDropInfo
- .getDropOffset());
- VpeSourceInnerDropInfo sourceDropInfo = null;
+ VpeVisualInnerDropInfo visualDropInfo = selectionBuilder
+ .getInnerDropInfo(mouseEvent);
+ Point range = selectionBuilder.getSourceSelectionRangeAtVisualNode(
+ visualDropInfo.getDropContainer(), (int) visualDropInfo
+ .getDropOffset());
+ VpeSourceInnerDropInfo sourceDropInfo = null;
- XModelObject object = PreferenceModelUtilities.getPreferenceModel()
- .getModelBuffer().source();
+ XModelObject object = PreferenceModelUtilities.getPreferenceModel()
+ .getModelBuffer().source();
- String tagname = getTagName(object);
- if (tagname.indexOf("taglib") >= 0)tagname = "taglib";
//$NON-NLS-1$ //$NON-NLS-2$
- Node sourceDragNode = ((Document) getModel().getAdapter(Document.class))
- .createElement(tagname);
- if (visualDropInfo.getDropContainer() != null) {
- sourceDropInfo = visualBuilder.getSourceInnerDropInfo(
- sourceDragNode, visualDropInfo, true);
- range = selectionBuilder.getSourceSelectionRange(sourceDropInfo
- .getContainer(), sourceDropInfo.getOffset());
- }
+ String tagname = getTagName(object);
+ if (tagname.indexOf("taglib") >= 0)tagname = "taglib";
//$NON-NLS-1$ //$NON-NLS-2$
+ Node sourceDragNode = ((Document) getModel().getAdapter(Document.class))
+ .createElement(tagname);
+ if (visualDropInfo.getDropContainer() != null) {
+ sourceDropInfo = visualBuilder.getSourceInnerDropInfo(
+ sourceDragNode, visualDropInfo, true);
+ range = selectionBuilder.getSourceSelectionRange(sourceDropInfo
+ .getContainer(), sourceDropInfo.getOffset());
+ }
- if (visualDropInfo.getDropContainer() != null) {
- if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
- System.out
- .println(" drop! container: " +
visualDropInfo.getDropContainer().getNodeName()); //$NON-NLS-1$
- }
- final String finalFlavor = flavor;
- final String finalData = data;
- final Point finalRange = range;
- final Node finalDropContainer = sourceDropInfo == null ? null
- : sourceDropInfo.getContainer();
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- externalDropAny(finalFlavor, finalData, finalRange,
- finalDropContainer);
- }
- });
+ if (visualDropInfo.getDropContainer() != null) {
+ if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
+ System.out
+ .println(" drop! container: " +
visualDropInfo.getDropContainer().getNodeName()); //$NON-NLS-1$
+ }
+ final String finalFlavor = flavor;
+ final String finalData = data;
+ final Point finalRange = range;
+ final Node finalDropContainer = sourceDropInfo == null ? null
+ : sourceDropInfo.getContainer();
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ externalDropAny(finalFlavor, finalData, finalRange,
+ finalDropContainer);
}
+ });
}
+ }
- public void drop(Node node, Node parentNode, int offset) {
- visualBuilder.innerDrop(node, parentNode, offset);
- }
+ public void drop(Node node, Node parentNode, int offset) {
+ visualBuilder.innerDrop(node, parentNode, offset);
+ }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.mozilla.interfaces.nsISupports#queryInterface(java.lang.String)
+ */
+ public nsISupports queryInterface(String arg0) {
+ return Mozilla.getInstance().queryInterface(this, arg0);
+ }
+
+ /**
+ * Calls when editor content should be refreshed
+ */
+ public void onRefresh() {
+ // when we using separate thread to display selection rectangle
+ // it's working better than without
/*
- * (non-Javadoc)
- *
- * @see org.mozilla.interfaces.nsISupports#queryInterface(java.lang.String)
+ * HACK We need wait some time while standart event will be handled and
+ * in process event handles some components are repainted(like buttons)
+ * and flasher are not repainted, so we should paint flasher
*/
- public nsISupports queryInterface(String arg0) {
- return Mozilla.getInstance().queryInterface(this, arg0);
- }
- /**
- * Calls when editor content should be refreshed
- */
- public void onRefresh() {
- // when we using separate thread to display selection rectangle
- // it's working better than without
- /*
- * HACK We need wait some time while standart event will be handled and
- * in process event handles some components are repainted(like buttons)
- * and flasher are not repainted, so we should paint flasher
- */
+ Display.getDefault().asyncExec(new Thread() {
+ public void run() {
- Display.getDefault().asyncExec(new Thread() {
- public void run() {
+ getXulRunnerEditor().showSelectionRectangle();
+ }
+ });
- getXulRunnerEditor().showSelectionRectangle();
- }
- });
+ }
- }
+ /**
+ * @return the xulRunnerEditor
+ */
+ public XulRunnerEditor getXulRunnerEditor() {
+ return xulRunnerEditor;
+ }
- /**
- * @return the xulRunnerEditor
- */
- public XulRunnerEditor getXulRunnerEditor() {
- return xulRunnerEditor;
- }
+ /**
+ * @param xulRunnerEditor
+ * the xulRunnerEditor to set
+ */
+ public void setXulRunnerEditor(XulRunnerEditor xulRunnerEditor) {
+ this.xulRunnerEditor = xulRunnerEditor;
+ }
- /**
- * @param xulRunnerEditor
- * the xulRunnerEditor to set
- */
- public void setXulRunnerEditor(XulRunnerEditor xulRunnerEditor) {
- this.xulRunnerEditor = xulRunnerEditor;
- }
+ /**
+ * Start drag session
+ */
+ public void startDragSession(nsIDOMEvent domEvent) {
- /**
- * Start drag session
- */
- public void startDragSession(nsIDOMEvent domEvent) {
+ visualBuilder.getDnd().startDragSession(domEvent);
+ }
- visualBuilder.getDnd().startDragSession(domEvent);
- }
+ public void dragDrop(nsIDOMEvent domEvent) {
- public void dragDrop(nsIDOMEvent domEvent) {
+ visualBuilder.getDnd().dragDrop(domEvent, this);
+ }
- visualBuilder.getDnd().dragDrop(domEvent, this);
- }
+ /**
+ * @return the selectionBuilder
+ */
+ public VpeSelectionBuilder getSelectionBuilder() {
+ return selectionBuilder;
+ }
- /**
- * @return the selectionBuilder
- */
- public VpeSelectionBuilder getSelectionBuilder() {
- return selectionBuilder;
- }
+ /**
+ * @param selectionBuilder
+ * the selectionBuilder to set
+ */
+ public void setSelectionBuilder(VpeSelectionBuilder selectionBuilder) {
+ this.selectionBuilder = selectionBuilder;
+ }
- /**
- * @param selectionBuilder
- * the selectionBuilder to set
- */
- public void setSelectionBuilder(VpeSelectionBuilder selectionBuilder) {
- this.selectionBuilder = selectionBuilder;
- }
-
public boolean isVisualEditorVisible() {
return visualEditorVisible;
}
@@ -3172,40 +3092,39 @@
synced = true;
}
- /**
- * @return the progressMonitor
- */
- private IProgressMonitor getProgressMonitor() {
+ /**
+ * @return the progressMonitor
+ */
+ private IProgressMonitor getProgressMonitor() {
+
+ if(progressMonitor==null) {
+
+ progressMonitor = Job.getJobManager().createProgressGroup();
+ }
+
+ return progressMonitor;
+ }
- if (progressMonitor == null) {
-
- progressMonitor = Job.getJobManager().createProgressGroup();
- }
-
- return progressMonitor;
- }
-
/**
- * @param progressMonitor
- * the progressMonitor to set
- */
- private void setProgressMonitor(IProgressMonitor progressMonitor) {
+ * @param progressMonitor the progressMonitor to set
+ */
+ private void setProgressMonitor(IProgressMonitor progressMonitor) {
+
+ this.progressMonitor = progressMonitor;
+ }
- this.progressMonitor = progressMonitor;
- }
-
/**
* @return the changeEvents
*/
public LinkedList<VpeEventBean> getChangeEvents() {
-
- if (changeEvents == null) {
-
- changeEvents = new LinkedList<VpeEventBean>();
- }
+
+ if(changeEvents==null) {
+
+ changeEvents = new LinkedList<VpeEventBean>();
+ }
return changeEvents;
}
-
+
public void reinit() {
visualBuilder.setSelectionRectangle(null);
@@ -3218,7 +3137,8 @@
visualBuilder.rebuildDom(null);
}
- visualSelectionController.setSelection(xulRunnerEditor.getSelection());
+ visualSelectionController.setSelection(xulRunnerEditor
+ .getSelection());
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeSelectionBuilder.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeSelectionBuilder.java 2008-06-25
18:32:58 UTC (rev 8946)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeSelectionBuilder.java 2008-06-25
18:47:49 UTC (rev 8947)
@@ -21,7 +21,7 @@
import org.jboss.tools.vpe.editor.mapping.VpeElementMapping;
import org.jboss.tools.vpe.editor.mapping.VpeNodeMapping;
import org.jboss.tools.vpe.editor.selection.VpeSelectionController;
-import org.jboss.tools.vpe.editor.template.ISelectionManager;
+import org.jboss.tools.vpe.editor.template.ITemplateSelectionManager;
import org.jboss.tools.vpe.editor.template.VpePseudoContentCreator;
import org.jboss.tools.vpe.editor.template.VpeTemplate;
import org.jboss.tools.vpe.editor.util.HTML;
@@ -47,11 +47,6 @@
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
-/**
- *
- * @deprecated
- *
- */
public class VpeSelectionBuilder {
private static int HUGE_DISTANCE = 999999;
private VpeDomMapping domMapping;
@@ -81,11 +76,11 @@
VpeTemplate vpeTemplate = TemplateManagingUtil
.getTemplateByVisualSelection(visualBuilder.getPageContext(),
TemplateManagingUtil.getSelectedNode(selection));
-// if (vpeTemplate instanceof ITemplateSelectionManager) {
-// ((ITemplateSelectionManager) vpeTemplate).setSelection(
-// visualBuilder.getPageContext(), selection);
-// return;
-// }
+ if (vpeTemplate instanceof ITemplateSelectionManager) {
+ ((ITemplateSelectionManager) vpeTemplate).setSelection(
+ visualBuilder.getPageContext(), selection);
+ return;
+ }
if (selection.getIsCollapsed()) {
VisualSelectionInfo info = getVisualFocusSelectedInfo(selection);
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeSourceDomBuilder.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeSourceDomBuilder.java 2008-06-25
18:32:58 UTC (rev 8946)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeSourceDomBuilder.java 2008-06-25
18:47:49 UTC (rev 8947)
@@ -35,9 +35,10 @@
import org.jboss.tools.vpe.editor.mapping.VpeElementMapping;
import org.jboss.tools.vpe.editor.mapping.VpeNodeMapping;
import org.jboss.tools.vpe.editor.selection.VpeSelectionHelper;
+import org.jboss.tools.vpe.editor.template.ITemplateNodesManager;
import org.jboss.tools.vpe.editor.template.VpeTemplate;
import org.jboss.tools.vpe.editor.template.VpeTemplateManager;
-import org.jboss.tools.vpe.editor.util.NodesManagingUtil;
+import org.jboss.tools.vpe.editor.util.TemplateManagingUtil;
import org.jboss.tools.vpe.editor.util.TextUtil;
import org.mozilla.interfaces.nsIDOMElement;
import org.mozilla.interfaces.nsIDOMNode;
@@ -251,20 +252,21 @@
}
boolean openBundleEditors(nsIDOMNode visualNode) {
+ VpeElementMapping elementMapping = TemplateManagingUtil
+ .getElementMappingByVisualSelection(pageContext, visualNode);
+ if (elementMapping != null) {
- VpeNodeMapping nodeMapping = NodesManagingUtil.getNodeMapping(
- domMapping, visualNode);
- if (nodeMapping != null
- && nodeMapping.getType() == VpeNodeMapping.ELEMENT_MAPPING) {
-
- VpeElementMapping elementMapping = (VpeElementMapping) nodeMapping;
-
VpeTemplate template = elementMapping.getTemplate();
- if (!template.openBundle(pageContext, visualNode, elementMapping))
+ // if template implements VpeTemplateNodesManager interface
+ if (template instanceof ITemplateNodesManager) {
+ return ((ITemplateNodesManager) template).openBundle(
+ pageContext, visualNode, elementMapping);
+ } else {
template.openBundleEditors(pageContext,
(Element) elementMapping.getSourceNode(),
elementMapping.getData());
+ }
}
return false;
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java 2008-06-25
18:32:58 UTC (rev 8946)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java 2008-06-25
18:47:49 UTC (rev 8947)
@@ -1254,11 +1254,11 @@
return visualEditor.getContentArea();
}
- public void setSelectionRectangle(/*nsIDOMElement*/ nsIDOMNode visualElement) {
+ public void setSelectionRectangle(nsIDOMElement visualElement) {
setSelectionRectangle(visualElement, true);
}
- void setSelectionRectangle(/*nsIDOMElement*/ nsIDOMNode visualElement, boolean
scroll) {
+ void setSelectionRectangle(nsIDOMElement visualElement, boolean scroll) {
int resizerConstrains = getResizerConstrains(visualElement);
visualEditor.setSelectionRectangle(visualElement, resizerConstrains,
scroll);
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualKeyHandler.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualKeyHandler.java 2008-06-25
18:32:58 UTC (rev 8946)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualKeyHandler.java 2008-06-25
18:47:49 UTC (rev 8947)
@@ -42,7 +42,7 @@
import org.jboss.tools.vpe.editor.selection.VpeSelectedNodeInfo;
import org.jboss.tools.vpe.editor.selection.VpeSourceSelection;
import org.jboss.tools.vpe.editor.selection.VpeSourceSelectionBuilder;
-import org.jboss.tools.vpe.editor.template.IKeyEventHandler;
+import org.jboss.tools.vpe.editor.template.ITemplateKeyEventHandler;
import org.jboss.tools.vpe.editor.template.VpeHtmlTemplate;
import org.jboss.tools.vpe.editor.template.VpeTemplate;
import org.jboss.tools.vpe.editor.util.FlatIterator;
@@ -174,11 +174,11 @@
// if template сan handle keyEvent than pass control to him. And if
// template handled event return true
-// if ((template instanceof ITemplateKeyEventHandler)
-// && ((ITemplateKeyEventHandler) template).handleKeyPress(
-// pageContext, keyEvent)) {
-// return true;
-// }
+ if ((template instanceof ITemplateKeyEventHandler)
+ && ((ITemplateKeyEventHandler) template).handleKeyPress(
+ pageContext, keyEvent)) {
+ return true;
+ }
if (keyCode == VK_ENTER) {
return split();
Deleted:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mapping/AttributeData.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mapping/AttributeData.java 2008-06-25
18:32:58 UTC (rev 8946)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mapping/AttributeData.java 2008-06-25
18:47:49 UTC (rev 8947)
@@ -1,57 +0,0 @@
-package org.jboss.tools.vpe.editor.mapping;
-
-import org.mozilla.interfaces.nsIDOMNode;
-import org.w3c.dom.Attr;
-
-/**
- *
- * @author Sergey Dzmitrovich
- *
- * Keep information about output Attribute. Set up a correspondence
- * source node and visual node
- *
- */
-public class AttributeData extends NodeData {
-
- /**
- * some attributes can have a visual representation but have not a source
- * representation
- */
- private String attributeName;
-
- public AttributeData(Attr attr, nsIDOMNode visualNode, boolean editable) {
- super(attr, visualNode, editable);
- }
-
- public AttributeData(String attributeName, nsIDOMNode visualNode,
- boolean editable) {
-
- super(null, visualNode, editable);
-
- // initialize attributeName field
- this.attributeName = attributeName;
-
- }
-
- public AttributeData(String attributeName, nsIDOMNode visualNode) {
-
- super(null, visualNode, true);
-
- // initialize attributeName field
- this.attributeName = attributeName;
-
- }
-
- public String getAttributeName() {
- return attributeName;
- }
-
- public void setAttributeName(String attributeName) {
- this.attributeName = attributeName;
- }
-
- @Override
- public int getType() {
- return ATTRIBUTE;
- }
-}
Deleted:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mapping/NodeData.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mapping/NodeData.java 2008-06-25
18:32:58 UTC (rev 8946)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mapping/NodeData.java 2008-06-25
18:47:49 UTC (rev 8947)
@@ -1,95 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.vpe.editor.mapping;
-
-import org.mozilla.interfaces.nsIDOMNode;
-import org.w3c.dom.Node;
-
-/**
- *
- * @author Sergey Dzmitrovich
- *
- * Keep information about output Node. Set up a correspondence source
- * node and visual node
- *
- *
- */
-public class NodeData {
-
- public static int NODE = 0;
-
- public static int ATTRIBUTE = 1;
-
- /**
- * source presentation of attribute
- */
- protected Node sourceNode;
-
- /**
- * visual presentation of attribute
- */
- protected nsIDOMNode visualNode;
-
- /**
- * mark if editable
- */
- protected boolean isEditable;
-
- public NodeData(Node sourceNode, nsIDOMNode visualNode, boolean isEditable) {
- this.sourceNode = sourceNode;
- this.visualNode = visualNode;
- this.isEditable = isEditable;
-
- }
-
- public NodeData(Node sourceNode, nsIDOMNode visualNode) {
- this.sourceNode = sourceNode;
- this.visualNode = visualNode;
- this.isEditable = true;
-
- }
-
- public NodeData() {
- this.visualNode = null;
- this.sourceNode = null;
- this.isEditable = true;
-
- }
-
- public Node getSourceNode() {
- return sourceNode;
- }
-
- public void setSourceNode(Node sourceNode) {
- this.sourceNode = sourceNode;
- }
-
- public nsIDOMNode getVisualNode() {
- return visualNode;
- }
-
- public void setVisualNode(nsIDOMNode visualNode) {
- this.visualNode = visualNode;
- }
-
- public boolean isEditable() {
- return isEditable;
- }
-
- public void setEditable(boolean isEditable) {
- this.isEditable = isEditable;
- }
-
- public int getType() {
- return NODE;
- }
-
-}
Copied:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mapping/VpeAttributeData.java
(from rev 8942,
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mapping/VpeAttributeData.java)
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mapping/VpeAttributeData.java
(rev 0)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mapping/VpeAttributeData.java 2008-06-25
18:47:49 UTC (rev 8947)
@@ -0,0 +1,140 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.vpe.editor.mapping;
+
+import org.mozilla.interfaces.nsIDOMNode;
+import org.w3c.dom.Attr;
+
+/**
+ *
+ * @author Sergey Dzmitrovich
+ *
+ * Keep information about output attribute. Set up a correspondence source node
+ * and visual node
+ *
+ *
+ */
+public class VpeAttributeData {
+
+ /**
+ * source presentation of attribute
+ */
+ private Attr sourceAttr;
+
+ /**
+ * visual presentation of attribute
+ */
+ private nsIDOMNode visualAttr;
+
+ /**
+ * mark if editable
+ */
+ private boolean isEditable;
+
+ /**
+ * name of attribute. add for cases when attribute has default value and
+ * attribute has not source presentation but has visual presentation
+ */
+ private String attributeName;
+
+ public VpeAttributeData(Attr sourceAttr, nsIDOMNode visualAttr,
+ boolean isEditable) {
+ this.sourceAttr = sourceAttr;
+ this.visualAttr = visualAttr;
+ this.isEditable = isEditable;
+
+ }
+
+ public VpeAttributeData(Attr sourceAttr, nsIDOMNode visualAttr) {
+ this.sourceAttr = sourceAttr;
+ this.visualAttr = visualAttr;
+ this.isEditable = true;
+
+ }
+
+ public VpeAttributeData(String attributeName, nsIDOMNode visualAttr,
+ boolean isEditable) {
+ this.attributeName = attributeName;
+ this.visualAttr = visualAttr;
+ this.isEditable = isEditable;
+
+ }
+
+ public VpeAttributeData(String attributeName, nsIDOMNode visualAttr) {
+ this.attributeName = attributeName;
+ this.visualAttr = visualAttr;
+ this.isEditable = true;
+
+ }
+
+ /**
+ * get source
+ *
+ * @return
+ */
+ public Attr getSourceAttr() {
+ return sourceAttr;
+ }
+
+ /**
+ * set source
+ *
+ * @param sourceAttr
+ */
+ public void setSourceAttr(Attr sourceAttr) {
+ this.sourceAttr = sourceAttr;
+ }
+
+ /**
+ * get visual
+ *
+ * @return
+ */
+ public nsIDOMNode getVisualAttr() {
+ return visualAttr;
+ }
+
+ /**
+ * set visual
+ *
+ * @param visualAttr
+ */
+ public void setVisualAttr(nsIDOMNode visualAttr) {
+ this.visualAttr = visualAttr;
+ }
+
+ /**
+ * is editable
+ *
+ * @return
+ */
+ public boolean isEditable() {
+ return isEditable;
+ }
+
+ /**
+ * set editable
+ *
+ * @param isEditable
+ */
+ public void setEditable(boolean isEditable) {
+ this.isEditable = isEditable;
+ }
+
+ public String getAttributeName() {
+ return attributeName;
+ }
+
+ public void setAttributeName(String attributeName) {
+ this.attributeName = attributeName;
+ }
+
+}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mapping/VpeElementData.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mapping/VpeElementData.java 2008-06-25
18:32:58 UTC (rev 8946)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mapping/VpeElementData.java 2008-06-25
18:47:49 UTC (rev 8947)
@@ -17,47 +17,45 @@
*
* @author Sergey Dzmitrovich
*
- * keep information about element
+ * keep information about element
*/
public class VpeElementData {
/**
- * list of node data
+ * list of attribute data
*
- * keep information about output nodes ( one element can contain some nodes
- * )
+ * keep information about output attributes
*/
- private List<NodeData> nodesData;
+ private List<VpeAttributeData> attributesData;
/**
- * get nodes data
+ * get attributes data
*
* @return
*/
- public List<NodeData> getNodesData() {
- return nodesData;
+ public List<VpeAttributeData> getAttributesData() {
+ return attributesData;
}
/**
- * set nodes data
+ * set attributes data
*
- * @param nodesData
+ * @param attributesData
*/
- public void setNodesData(List<NodeData> nodesData) {
- this.nodesData = nodesData;
+ public void setAttributesData(List<VpeAttributeData> attributesData) {
+ this.attributesData = attributesData;
}
/**
* add <code>VpeAttributeData</code>
- *
* @param attributeData
*/
- public void addNodeData(NodeData nodeData) {
+ public void addAttributeData(VpeAttributeData attributeData) {
- if (nodesData == null)
- nodesData = new ArrayList<NodeData>();
+ if (attributesData == null)
+ attributesData = new ArrayList<VpeAttributeData>();
- nodesData.add(nodeData);
+ attributesData.add(attributeData);
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaEditor.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaEditor.java 2008-06-25
18:32:58 UTC (rev 8946)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaEditor.java 2008-06-25
18:47:49 UTC (rev 8947)
@@ -553,9 +553,9 @@
}
}
- public void setSelectionRectangle(/*nsIDOMElement*/nsIDOMNode element, int
resizerConstrains, boolean scroll) {
+ public void setSelectionRectangle(nsIDOMElement element, int resizerConstrains, boolean
scroll) {
if (getContentAreaEventListener() != null) {
- xulRunnerEditor.setSelectionRectangle(element, resizerConstrains, scroll);
+ xulRunnerEditor.setSelectionRectangle((nsIDOMElement)element, resizerConstrains,
scroll);
}
}
Deleted:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/IKeyEventHandler.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/IKeyEventHandler.java 2008-06-25
18:32:58 UTC (rev 8946)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/IKeyEventHandler.java 2008-06-25
18:47:49 UTC (rev 8947)
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.vpe.editor.template;
-
-import org.mozilla.interfaces.nsIDOMKeyEvent;
-
-/**
- * interface for handling of keyEvent by himself template
- *
- * @author Sergey Dzmitrovich
- *
- */
-public interface IKeyEventHandler {
-
- /**
- * handle keyEvent
- *
- * @param pageContext
- * @param keyEvent -
- * happens when element of current template is selected and
- * is pressed key
- * @return
- */
- boolean handleKeyPress(nsIDOMKeyEvent keyEvent);
-
-}
Deleted:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/ISelectionManager.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/ISelectionManager.java 2008-06-25
18:32:58 UTC (rev 8946)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/ISelectionManager.java 2008-06-25
18:47:49 UTC (rev 8947)
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.vpe.editor.template;
-
-import org.mozilla.interfaces.nsIDOMMouseEvent;
-import org.mozilla.interfaces.nsISelection;
-
-/**
- *
- * interface for template selection
- *
- * @author Sergey Dzmitrovich
- */
-public interface ISelectionManager {
-
- /**
- * set selection
- *
- * @param selection
- */
- public void setSelection(nsISelection selection);
-
- /**
- * set selection by mouse
- *
- * @param mouseEvent
- */
- public void setSelection(nsIDOMMouseEvent mouseEvent);
-
- /**
- * to bring in correspondence visual selection and source selection
- */
- public void refreshVisualSelection();
-
-}
Copied:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/ITemplateKeyEventHandler.java
(from rev 8942,
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/ITemplateKeyEventHandler.java)
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/ITemplateKeyEventHandler.java
(rev 0)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/ITemplateKeyEventHandler.java 2008-06-25
18:47:49 UTC (rev 8947)
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.vpe.editor.template;
+
+import org.jboss.tools.vpe.editor.context.VpePageContext;
+import org.mozilla.interfaces.nsIDOMKeyEvent;
+
+/**
+ * interface for handling of keyEvent by himself template
+ *
+ * @author Sergey Dzmitrovich
+ *
+ */
+public interface ITemplateKeyEventHandler {
+
+ /**
+ * handle keyEvent
+ *
+ * @param pageContext
+ * @param keyEvent -
+ * happens when element of current template is selected and
+ * is pressed key
+ * @return
+ */
+ boolean handleKeyPress(VpePageContext pageContext, nsIDOMKeyEvent keyEvent);
+
+}
Copied:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/ITemplateNodesManager.java
(from rev 8942,
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/ITemplateNodesManager.java)
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/ITemplateNodesManager.java
(rev 0)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/ITemplateNodesManager.java 2008-06-25
18:47:49 UTC (rev 8947)
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.vpe.editor.template;
+
+import org.jboss.tools.vpe.editor.context.VpePageContext;
+import org.jboss.tools.vpe.editor.mapping.VpeElementData;
+import org.jboss.tools.vpe.editor.mapping.VpeElementMapping;
+import org.mozilla.interfaces.nsIDOMNode;
+import org.w3c.dom.Node;
+
+/**
+ * Interface for editing of attributes of a template
+ *
+ * @author Sergey Dzmitrovich
+ *
+ */
+public interface ITemplateNodesManager {
+
+ /**
+ * @param pageContext -
+ * context of vpe
+ * @param visualNode -
+ * selected visual node
+ *
+ * @return true if selected attribute is editable
+ */
+ public boolean isNodeEditable(nsIDOMNode visualNode,
+ VpeElementData elementData);
+
+ /**
+ *
+ * @param pageContext
+ * @param node
+ * @param elementData
+ * @return
+ */
+ public boolean isNodeEditable(Node node, VpeElementData elementData);
+
+ public nsIDOMNode getTargetVisualNodeBySourceNode(Node sourceNode,
+ VpeElementMapping elementMapping);
+
+ public nsIDOMNode getTargetVisualNodeByVisualNode(
+ VpePageContext pageContext, nsIDOMNode visualNode,
+ VpeElementMapping elementMapping);
+
+ public Node getTargetSourceNodeByVisualNode(VpePageContext pageContext,
+ nsIDOMNode visualNode, VpeElementMapping elementMapping);
+
+ public Node getTargetSourceNodeBySourcePosition(VpePageContext pageContext,
+ int focusOffset, int anchorOffset);
+
+ /**
+ * open bundle
+ *
+ * @param pageContext
+ * @param visualNod
+ * @return
+ */
+ boolean openBundle(VpePageContext pageContext, nsIDOMNode visualNode,
+ VpeElementMapping elementMapping);
+}
Copied:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/ITemplateSelectionManager.java
(from rev 8942,
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/ITemplateSelectionManager.java)
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/ITemplateSelectionManager.java
(rev 0)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/ITemplateSelectionManager.java 2008-06-25
18:47:49 UTC (rev 8947)
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.vpe.editor.template;
+
+import org.jboss.tools.vpe.editor.context.VpePageContext;
+import org.jboss.tools.vpe.editor.selection.VpeSelectionController;
+import org.mozilla.interfaces.nsIDOMMouseEvent;
+import org.mozilla.interfaces.nsISelection;
+
+/**
+ *
+ * interface for template selection
+ *
+ * @author Sergey Dzmitrovich
+ */
+public interface ITemplateSelectionManager {
+
+ /**
+ * selection
+ *
+ * @param pageContext
+ * @param selection
+ */
+ public void setSelection(VpePageContext pageContext, nsISelection selection);
+
+ /**
+ * select visual element by source selection
+ *
+ * @param pageContext
+ * @return true if visual element was selected
+ */
+ public void setSelectionBySource(VpePageContext pageContext,
+ VpeSelectionController selectionController, int focus, int anchor);
+
+ /**
+ * set selection by mouse
+ *
+ * @param visualSelectionController
+ *
+ * @param mouseEvent
+ */
+ public void setSelectionByMouse(VpePageContext pageContext,
+ VpeSelectionController selectionController,
+ nsIDOMMouseEvent mouseEvent);
+
+}
Deleted:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/KeyEventManager.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/KeyEventManager.java 2008-06-25
18:32:58 UTC (rev 8946)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/KeyEventManager.java 2008-06-25
18:47:49 UTC (rev 8947)
@@ -1,482 +0,0 @@
-package org.jboss.tools.vpe.editor.template;
-
-import org.eclipse.swt.custom.ST;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.wst.sse.ui.StructuredTextEditor;
-import org.jboss.tools.vpe.editor.context.VpePageContext;
-import org.jboss.tools.vpe.editor.mapping.AttributeData;
-import org.jboss.tools.vpe.editor.mapping.NodeData;
-import org.jboss.tools.vpe.editor.mapping.VpeDomMapping;
-import org.jboss.tools.vpe.editor.mapping.VpeElementData;
-import org.jboss.tools.vpe.editor.mapping.VpeElementMapping;
-import org.jboss.tools.vpe.editor.mapping.VpeNodeMapping;
-import org.jboss.tools.vpe.editor.util.SelectionUtil;
-import org.jboss.tools.vpe.editor.util.TextUtil;
-import org.mozilla.interfaces.nsIDOMKeyEvent;
-import org.mozilla.interfaces.nsIDOMNode;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-/**
- *
- * @author S.Dzmitrovich
- *
- */
-public class KeyEventManager implements IKeyEventHandler {
-
- private static final String EMPTY_STRING = ""; //$NON-NLS-1$
-
- /**
- * source editor
- */
- private StructuredTextEditor sourceEditor;
-
- /**
- * mapping
- */
- private VpeDomMapping domMapping;
-
- /**
- * page context
- */
- private VpePageContext pageContext;
-
- public KeyEventManager(StructuredTextEditor sourceEditor,
- VpeDomMapping domMapping, VpePageContext pageContext) {
- this.sourceEditor = sourceEditor;
- this.domMapping = domMapping;
- this.pageContext = pageContext;
- }
-
- final public boolean handleKeyPress(nsIDOMKeyEvent keyEvent) {
-
- long keyCode = keyEvent.getKeyCode();
-
- if (keyCode == nsIDOMKeyEvent.DOM_VK_ENTER) {
- return handleEnter(keyEvent);
-
- } else if ((keyCode == nsIDOMKeyEvent.DOM_VK_LEFT)
- && (!keyEvent.getShiftKey())) {
- return handleLeft(keyEvent);
-
- } else if ((keyCode == nsIDOMKeyEvent.DOM_VK_UP)
- && (!keyEvent.getShiftKey())) {
- return handleUp(keyEvent);
-
- } else if ((keyCode == nsIDOMKeyEvent.DOM_VK_RIGHT)
- && (!keyEvent.getShiftKey())) {
- return handleRight(keyEvent);
-
- } else if ((keyCode == nsIDOMKeyEvent.DOM_VK_DOWN)
- && (!keyEvent.getShiftKey())) {
- return handleDown(keyEvent);
-
- } else if ((keyCode == nsIDOMKeyEvent.DOM_VK_HOME)
- && (!keyEvent.getShiftKey())) {
- return handleHome(keyEvent);
-
- } else if ((keyCode == nsIDOMKeyEvent.DOM_VK_END)
- && (!keyEvent.getShiftKey())) {
- return handleEnd(keyEvent);
-
- } else if ((keyCode == nsIDOMKeyEvent.DOM_VK_BACK_SPACE)
- && (!keyEvent.getShiftKey())) {
- return handleLeftDelete(keyEvent);
-
- } else if ((keyCode == nsIDOMKeyEvent.DOM_VK_DELETE)
- && (!keyEvent.getShiftKey())) {
- return handleRightDelete(keyEvent);
-
- } else if ((keyCode == nsIDOMKeyEvent.DOM_VK_PAGE_UP)
- && (!keyEvent.getShiftKey())) {
- return handlePageUp(keyEvent);
-
- } else if (keyEvent.getCharCode() != 0) {
- return handleCharacter(keyEvent);
-
- } else if ((keyEvent.getKeyCode() == nsIDOMKeyEvent.DOM_VK_INSERT)
- && keyEvent.getShiftKey()) {
- return handleInsert(keyEvent);
- }
-
- return false;
- }
-
- /**
- * Default handling of a pressing a character event
- *
- *
- * @param keyEvent
- * - event
- * @return whether handled event
- */
- protected boolean handleCharacter(nsIDOMKeyEvent keyEvent) {
-
- VpeNodeMapping selectedNodeMapping = SelectionUtil
- .getNodeMappingBySourceSelection(getSourceEditor(),
- getDomMapping());
-
- if (selectedNodeMapping == null)
- return false;
-
- boolean editable = false;
-
- String enteredChar = TextUtil.getChar(keyEvent);
-
- // if selected node is element
- if (selectedNodeMapping.getType() == VpeNodeMapping.ELEMENT_MAPPING) {
-
- VpeElementMapping elementMapping = (VpeElementMapping) selectedNodeMapping;
-
- VpeElementData elementData = elementMapping.getElementData();
-
- VpeTemplate template = elementMapping.getTemplate();
-
- nsIDOMNode visualNode = SelectionUtil
- .getLastSelectedNode(getPageContext());
-
- NodeData nodeData = template.getNodeData(visualNode, elementData,
- domMapping);
-
- if (nodeData != null) {
-
- editable = nodeData.isEditable();
-
- if (editable && nodeData.getType() == NodeData.ATTRIBUTE
- && nodeData.getSourceNode() == null) {
-
- Node newNode = createAttribute(
- (Element) selectedNodeMapping.getSourceNode(),
- ((AttributeData) nodeData).getAttributeName(),
- enteredChar);
- nodeData.setSourceNode(newNode);
-
- SelectionUtil.setSourceSelection(pageContext, newNode,
- enteredChar.length());
- return true;
-
- }
-
- }
- // if template can't give necessary information
- else {
-
- editable = false;
-
- }
- }
- // if node is simple text
- else {
- editable = true;
- }
-
- if (editable) {
-
- Point range = getSourceEditor().getTextViewer().getSelectedRange();
-
- getSourceEditor().getTextViewer().getTextWidget().replaceTextRange(
- range.x, range.y, enteredChar);
-
- getSourceEditor().getTextViewer().getTextWidget().setSelection(
- range.x + enteredChar.length());
-
- }
-
- return true;
- }
-
- /**
- * Default implementation of a handling of a pressing the "delete" event
- *
- * Override this method for a handling of a pressing the "delete" event
- *
- * @param keyEvent
- * - event
- * @return whether handled event
- */
- protected boolean handleRightDelete(nsIDOMKeyEvent keyEvent) {
-
- VpeNodeMapping selectedNodeMapping = SelectionUtil
- .getNodeMappingBySourceSelection(getSourceEditor(),
- getDomMapping());
-
- if (selectedNodeMapping == null)
- return false;
-
- boolean editable = false;
-
- // if selected node is element
- if (selectedNodeMapping.getType() == VpeNodeMapping.ELEMENT_MAPPING) {
-
- VpeElementMapping elementMapping = (VpeElementMapping) selectedNodeMapping;
-
- VpeElementData elementData = elementMapping.getElementData();
-
- VpeTemplate template = elementMapping.getTemplate();
-
- nsIDOMNode visualNode = SelectionUtil
- .getLastSelectedNode(getPageContext());
-
- NodeData nodeData = template.getNodeData(visualNode, elementData,
- domMapping);
-
- if (nodeData != null) {
- editable = nodeData.isEditable();
-
- if (editable && nodeData.getType() == NodeData.ATTRIBUTE
- && nodeData.getSourceNode() == null) {
-
- Node newNode = createAttribute(
- (Element) selectedNodeMapping.getSourceNode(),
- ((AttributeData) nodeData).getAttributeName(),
- EMPTY_STRING);
-
- nodeData.setSourceNode(newNode);
-
- SelectionUtil.setSourceSelection(pageContext, newNode, 0);
-
- return true;
-
- }
-
- }
- // if template can't give necessary information
- else {
-
- editable = false;
-
- }
- }
- // if node is simple text
- else {
- editable = true;
- }
-
- if (editable) {
-
- sourceEditor.getTextViewer().getTextWidget().invokeAction(
- ST.DELETE_NEXT);
-
- }
-
- return true;
-
- }
-
- /**
- * Default handling of a pressing the "backspace" event
- *
- * Override this method to handle the "backspace" event
- *
- * @param keyEvent
- * - event
- * @return whether handled event
- */
- protected boolean handleLeftDelete(nsIDOMKeyEvent keyEvent) {
- VpeNodeMapping selectedNodeMapping = SelectionUtil
- .getNodeMappingBySourceSelection(getSourceEditor(),
- getDomMapping());
-
- if (selectedNodeMapping == null)
- return false;
-
- boolean editable = false;
-
- // if selected node is element
- if (selectedNodeMapping.getType() == VpeNodeMapping.ELEMENT_MAPPING) {
-
- VpeElementMapping elementMapping = (VpeElementMapping) selectedNodeMapping;
-
- VpeElementData elementData = elementMapping.getElementData();
-
- VpeTemplate template = elementMapping.getTemplate();
-
- nsIDOMNode visualNode = SelectionUtil
- .getLastSelectedNode(getPageContext());
-
- NodeData nodeData = template.getNodeData(visualNode, elementData,
- domMapping);
-
- if (nodeData != null) {
- editable = nodeData.isEditable();
-
- if (editable && nodeData.getType() == NodeData.ATTRIBUTE
- && nodeData.getSourceNode() == null) {
-
- Node newNode = createAttribute(
- (Element) selectedNodeMapping.getSourceNode(),
- ((AttributeData) nodeData).getAttributeName(),
- EMPTY_STRING);
-
- nodeData.setSourceNode(newNode);
-
- SelectionUtil.setSourceSelection(pageContext, newNode, 0);
-
- return true;
-
- }
-
- }
- // if template can't give necessary information
- else {
-
- editable = false;
-
- }
- }
- // if node is simple text
- else {
- editable = true;
- }
-
- if (editable) {
-
- sourceEditor.getTextViewer().getTextWidget().invokeAction(
- ST.DELETE_PREVIOUS);
-
- }
-
- return true;
-
- }
-
- /**
- * Default handling of a pressing the "end" event - always return false.
- *
- * Override this method to handle of a pressing the "end" event
- *
- * @param keyEvent
- * - event
- * @return whether handled event
- */
- protected boolean handleEnd(nsIDOMKeyEvent keyEvent) {
- return false;
- }
-
- /**
- * Default handling of a pressing the "home" event - always return false.
- *
- * Override this method to handle of a pressing the "home" event
- *
- * @param keyEvent
- * - event
- * @return whether handled event
- */
- protected boolean handleHome(nsIDOMKeyEvent keyEvent) {
- return false;
- }
-
- /**
- * Default handling of a pressing the "down" event - always return false.
- *
- * Override this method to handle of a pressing the "down" event
- *
- * @param keyEvent
- * - event
- * @return whether handled event
- */
- protected boolean handleDown(nsIDOMKeyEvent keyEvent) {
- return false;
- }
-
- /**
- * Default handling of a pressing the "right" event - always return false.
- *
- * Override this method to handle of a pressing the "right" event
- *
- * @param keyEvent
- * - event
- * @return whether handled event
- */
- protected boolean handleRight(nsIDOMKeyEvent keyEvent) {
- return false;
-
- }
-
- /**
- * Default handling of a pressing the "up" event - always return false.
- *
- * Override this method to handle of a pressing the "up" event
- *
- * @param keyEvent
- * - event
- * @return whether handled event
- */
- protected boolean handleUp(nsIDOMKeyEvent keyEvent) {
- return false;
- }
-
- /**
- * Default handling of a pressing the "left" event - always return false.
- *
- * Override this method to handle of a pressing the "left" event
- *
- * @param keyEvent
- * - event
- * @return whether handled event
- */
- protected boolean handleLeft(nsIDOMKeyEvent keyEvent) {
- return false;
-
- }
-
- /**
- * Default handling of a pressing the "enter" event - always return false.
- *
- * Override to handling of a pressing the "enter" event
- *
- * @param keyEvent
- * - event
- * @return whether handled event
- */
- protected boolean handleEnter(nsIDOMKeyEvent keyEvent) {
- return true;
- }
-
- /**
- *
- * @param keyEvent
- * @return
- */
- protected boolean handleInsert(nsIDOMKeyEvent keyEvent) {
- return false;
- }
-
- /**
- * Default handling of a pressing the "page up" event - always return false.
- *
- * Override this method for a handling of a pressing the "page up" event
- *
- * @param keyEvent
- * - event
- * @return whether handled event
- */
- protected boolean handlePageUp(nsIDOMKeyEvent keyEvent) {
- return false;
- }
-
- protected StructuredTextEditor getSourceEditor() {
- return sourceEditor;
- }
-
- protected VpeDomMapping getDomMapping() {
- return domMapping;
- }
-
- protected VpePageContext getPageContext() {
- return pageContext;
- }
-
- protected Node createAttribute(Element sourceElement, String attributeName,
- String value) {
-
- if ((sourceElement != null) && (attributeName != null)) {
- sourceElement.setAttribute(attributeName, value != null ? value
- : ""); //$NON-NLS-1$
-
- return sourceElement.getAttributeNode(attributeName);
- }
- return null;
-
- }
-}
Deleted:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/SelectionManager.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/SelectionManager.java 2008-06-25
18:32:58 UTC (rev 8946)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/SelectionManager.java 2008-06-25
18:47:49 UTC (rev 8947)
@@ -1,279 +0,0 @@
-package org.jboss.tools.vpe.editor.template;
-
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.wst.sse.ui.StructuredTextEditor;
-import org.jboss.tools.vpe.editor.context.VpePageContext;
-import org.jboss.tools.vpe.editor.mapping.NodeData;
-import org.jboss.tools.vpe.editor.mapping.VpeDomMapping;
-import org.jboss.tools.vpe.editor.mapping.VpeElementMapping;
-import org.jboss.tools.vpe.editor.mapping.VpeNodeMapping;
-import org.jboss.tools.vpe.editor.selection.VpeSelectionController;
-import org.jboss.tools.vpe.editor.util.NodesManagingUtil;
-import org.jboss.tools.vpe.editor.util.SelectionUtil;
-import org.jboss.tools.vpe.editor.util.VisualDomUtil;
-import org.mozilla.interfaces.nsIDOMMouseEvent;
-import org.mozilla.interfaces.nsIDOMNSUIEvent;
-import org.mozilla.interfaces.nsIDOMNode;
-import org.mozilla.interfaces.nsISelection;
-import org.w3c.dom.Node;
-
-/**
- *
- * @author S. Dzmitrovich
- *
- */
-public class SelectionManager implements ISelectionManager {
-
- /**
- * pageContext keeps information about page
- */
- private VpePageContext pageContext;
-
- /**
- * source editor
- */
- private StructuredTextEditor sourceEditor;
-
- /**
- * selection
- */
- private VpeSelectionController selectionController;
-
- public SelectionManager(VpePageContext pageContext,
- StructuredTextEditor sourceEditor,
- VpeSelectionController selectionController) {
- this.pageContext = pageContext;
- this.sourceEditor = sourceEditor;
- this.selectionController = selectionController;
- }
-
- final public void setSelection(nsISelection selection) {
-
- nsIDOMNode selectedVisualNode = SelectionUtil
- .getSelectedNode(selection);
-
- if (selectedVisualNode == null)
- return;
-
- VpeNodeMapping nodeMapping = NodesManagingUtil.getNodeMapping(
- getDomMapping(), selectedVisualNode);
-
- if (nodeMapping == null)
- return;
-
- // visual node which will be selected
- nsIDOMNode targetVisualNode;
- // source node which will be selected
- Node targetSourceNode;
-
- boolean isNodeEditable;
-
- // if mapping is elementMapping
- if (nodeMapping.getType() == VpeNodeMapping.ELEMENT_MAPPING) {
-
- VpeElementMapping elementMapping = (VpeElementMapping) nodeMapping;
-
- VpeTemplate template = elementMapping.getTemplate();
-
- NodeData nodeData = template.getNodeData(selectedVisualNode,
- elementMapping.getElementData(), getDomMapping());
-
- if (nodeData != null) {
-
- isNodeEditable = nodeData.isEditable();
- if (nodeData.getSourceNode() != null) {
- targetSourceNode = nodeData.getSourceNode();
-
- } else {
-
- targetSourceNode = elementMapping.getSourceNode();
-
- }
-
- targetVisualNode = nodeData.getVisualNode();
- } else {
-
- targetVisualNode = elementMapping.getVisualNode();
- targetSourceNode = elementMapping.getSourceNode();
- isNodeEditable = false;
- }
-
- } else {
-
- targetVisualNode = nodeMapping.getVisualNode();
- targetSourceNode = nodeMapping.getSourceNode();
- isNodeEditable = true;
-
- }
-
- int focusOffset;
- int length;
-
- if (isNodeEditable) {
-
- Point range = SelectionUtil.getSelectionRange(selection);
-
- focusOffset = range.x;
- length = range.y;
-
- } else {
-
- focusOffset = 0;
- length = NodesManagingUtil.getNodeLength(targetSourceNode);
-
- }
-
- // set source selection
- SelectionUtil.setSourceSelection(getPageContext(), targetSourceNode,
- focusOffset, length);
-
- // paint visual selection
- getPageContext().getVisualBuilder().setSelectionRectangle(
- targetVisualNode);
-
- }
-
- final public void setSelection(nsIDOMMouseEvent mouseEvent) {
-
- // get visual node by event
- nsIDOMNode visualNode = VisualDomUtil.getTargetNode(mouseEvent);
-
- // get element mapping
- VpeNodeMapping nodeMapping = NodesManagingUtil.getNodeMapping(
- getDomMapping(), visualNode);
-
- if (nodeMapping == null)
- return;
-
- // visual node which will be selected
- nsIDOMNode targetVisualNode;
- // source node which will be selected
- Node targetSourceNode;
-
- boolean isNodeEditable;
-
- // if mapping is elementMapping
- if (nodeMapping.getType() == VpeNodeMapping.ELEMENT_MAPPING) {
-
- VpeElementMapping elementMapping = (VpeElementMapping) nodeMapping;
-
- VpeTemplate template = elementMapping.getTemplate();
-
- NodeData nodeData = template.getNodeData(visualNode, elementMapping
- .getElementData(), getDomMapping());
-
- if (nodeData != null) {
-
- isNodeEditable = nodeData.isEditable();
-
- if (nodeData.getSourceNode() != null) {
-
- targetSourceNode = nodeData.getSourceNode();
-
- } else {
-
- isNodeEditable = false;
- targetSourceNode = elementMapping.getSourceNode();
-
- }
-
- targetVisualNode = nodeData.getVisualNode();
-
- } else {
-
- targetVisualNode = elementMapping.getVisualNode();
- targetSourceNode = elementMapping.getSourceNode();
- isNodeEditable = false;
-
- }
-
- }
-
- else {
-
- targetVisualNode = nodeMapping.getVisualNode();
- targetSourceNode = nodeMapping.getSourceNode();
- isNodeEditable = true;
-
- }
-
- // get nsIDOMNSUIEvent event
- nsIDOMNSUIEvent nsuiEvent = (nsIDOMNSUIEvent) mouseEvent
- .queryInterface(nsIDOMNSUIEvent.NS_IDOMNSUIEVENT_IID);
-
- int selectionOffset;
- int selectionLength;
-
- if (isNodeEditable) {
- selectionOffset = nsuiEvent.getRangeOffset();
- selectionLength = 0;
- } else {
-
- selectionOffset = 0;
- selectionLength = NodesManagingUtil.getNodeLength(targetSourceNode);
-
- }
-
- SelectionUtil.setSourceSelection(getPageContext(), targetSourceNode,
- selectionOffset, selectionLength);
-
- // paint selection rectangle
- getPageContext().getVisualBuilder().setSelectionRectangle(
- targetVisualNode);
-
- }
-
- final public void refreshVisualSelection() {
-
- Point range = SelectionUtil.getSourceSelection(getSourceEditor());
-
- int focus = range.x;
-
- int anchor = focus + range.y;
-
- // get element mapping
- VpeNodeMapping nodeMapping = SelectionUtil
- .getNodeMappingBySourceSelection(NodesManagingUtil
- .getStructuredModel(getSourceEditor()),
- getDomMapping(), focus, anchor);
-
- if (nodeMapping == null)
- return;
-
- // visual node which will be selected
- nsIDOMNode targetVisualNode;
-
- // if mapping is elementMapping
- if (nodeMapping.getType() == VpeNodeMapping.ELEMENT_MAPPING) {
-
- VpeElementMapping elementMapping = (VpeElementMapping) nodeMapping;
-
- VpeTemplate template = elementMapping.getTemplate();
-
- targetVisualNode = template.getVisualNodeByBySourcePosition(
- elementMapping, focus, anchor, getDomMapping());
-
- } else {
-
- targetVisualNode = nodeMapping.getVisualNode();
-
- }
-
- getPageContext().getVisualBuilder().setSelectionRectangle(
- targetVisualNode);
-
- }
-
- protected VpePageContext getPageContext() {
- return pageContext;
- }
-
- protected VpeDomMapping getDomMapping() {
- return pageContext.getDomMapping();
- }
-
- protected StructuredTextEditor getSourceEditor() {
- return sourceEditor;
- }
-
-}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAbstractTemplate.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAbstractTemplate.java 2008-06-25
18:32:58 UTC (rev 8946)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAbstractTemplate.java 2008-06-25
18:47:49 UTC (rev 8947)
@@ -7,12 +7,11 @@
*
* Contributors:
* Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
+ ******************************************************************************/
package org.jboss.tools.vpe.editor.template;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.List;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.Region;
@@ -25,16 +24,10 @@
import org.jboss.tools.vpe.editor.VpeSourceInnerDragInfo;
import org.jboss.tools.vpe.editor.VpeSourceInnerDropInfo;
import org.jboss.tools.vpe.editor.context.VpePageContext;
-import org.jboss.tools.vpe.editor.mapping.NodeData;
-import org.jboss.tools.vpe.editor.mapping.VpeDomMapping;
-import org.jboss.tools.vpe.editor.mapping.VpeElementData;
-import org.jboss.tools.vpe.editor.mapping.VpeElementMapping;
import org.jboss.tools.vpe.editor.selection.VpeSourceSelection;
import org.jboss.tools.vpe.editor.template.dnd.VpeDnd;
import org.jboss.tools.vpe.editor.template.resize.VpeResizer;
import org.jboss.tools.vpe.editor.template.textformating.TextFormatingData;
-import org.jboss.tools.vpe.editor.util.NodesManagingUtil;
-import org.jboss.tools.vpe.editor.util.SelectionUtil;
import org.mozilla.interfaces.nsIDOMDocument;
import org.mozilla.interfaces.nsIDOMElement;
import org.mozilla.interfaces.nsIDOMNode;
@@ -46,27 +39,26 @@
import org.w3c.dom.Text;
/**
- * Class which response for configuration template element from configuration
- * file.
- *
+ * Class which response for configuration template element from
+ * configuration file.
+ *
*/
public abstract class VpeAbstractTemplate implements VpeTemplate {
protected boolean caseSensitive;
protected boolean children;
- protected boolean modify;
-
+ protected boolean modify;
+
protected boolean hasImaginaryBorder;
-
+
/** a resizer instance */
private VpeResizer resizer;
-
+
// TODO Max Areshkau add DnD support
private VpeDnd dragger;
private TextFormatingData textFormatingData;
private VpePseudoContentCreator pseudoContentCreator;
- private static final String TAG_BREAKER = VpeTemplateManager.VPE_PREFIX
- + "breaker"; //$NON-NLS-1$
+ private static final String TAG_BREAKER = VpeTemplateManager.VPE_PREFIX +
"breaker"; //$NON-NLS-1$
private static final String ATTR_BREAKER_TYPE = "type"; //$NON-NLS-1$
private static final String ATTR_BREAKER_TYPE_IGNORE = "ignore";
//$NON-NLS-1$
private static final String ATTR_BREAKER_TYPE_SELECTITEM = "selectItem";
//$NON-NLS-1$
@@ -74,15 +66,14 @@
private static final int BREAKER_TYPE_IGNORE = 1;
private static final int BREAKER_TYPE_SELECTITEM = 2;
- private static final String TAG_PSEUDOCONTENT = VpeTemplateManager.VPE_PREFIX
- + "pseudoContent"; //$NON-NLS-1$
+ private static final String TAG_PSEUDOCONTENT = VpeTemplateManager.VPE_PREFIX +
"pseudoContent"; //$NON-NLS-1$
private static final String ATTR_PSEUDOCONTENT_DEFAULTTEXT = "defaultText";
//$NON-NLS-1$
private static final String ATTR_PSEUDOCONTENT_ATTRNAME = "attrName";
//$NON-NLS-1$
private int breakerType = BREAKER_TYPE_NONE;
static private HashSet<String> inlineTags = new HashSet<String>();
- static {
+ static{
inlineTags.add("b"); //$NON-NLS-1$
inlineTags.add("i"); //$NON-NLS-1$
inlineTags.add("u"); //$NON-NLS-1$
@@ -99,39 +90,22 @@
inlineTags.add("label"); //$NON-NLS-1$
}
static private HashMap<String, Integer> tagResizeConstrans = new
HashMap<String, Integer>();
- static {
- tagResizeConstrans
- .put(
- "table", Integer.valueOf(VpeTagDescription.RESIZE_CONSTRAINS_ALL));
//$NON-NLS-1$
- tagResizeConstrans.put(
- "tr", Integer.valueOf(VpeTagDescription.RESIZE_CONSTRAINS_ALL));
//$NON-NLS-1$
- tagResizeConstrans
- .put(
- "br", Integer.valueOf(VpeTagDescription.RESIZE_CONSTRAINS_NONE));
//$NON-NLS-1$
- tagResizeConstrans.put(
- "b", Integer.valueOf(VpeTagDescription.RESIZE_CONSTRAINS_NONE));
//$NON-NLS-1$
- tagResizeConstrans.put(
- "i", Integer.valueOf(VpeTagDescription.RESIZE_CONSTRAINS_NONE));
//$NON-NLS-1$
- tagResizeConstrans.put(
- "u", Integer.valueOf(VpeTagDescription.RESIZE_CONSTRAINS_NONE));
//$NON-NLS-1$
- tagResizeConstrans
- .put(
- "sub", Integer.valueOf(VpeTagDescription.RESIZE_CONSTRAINS_NONE));
//$NON-NLS-1$
- tagResizeConstrans
- .put(
- "sup", Integer.valueOf(VpeTagDescription.RESIZE_CONSTRAINS_NONE));
//$NON-NLS-1$
- tagResizeConstrans
- .put(
- "strike", Integer.valueOf(VpeTagDescription.RESIZE_CONSTRAINS_NONE));
//$NON-NLS-1$
- tagResizeConstrans
- .put(
- "font", Integer.valueOf(VpeTagDescription.RESIZE_CONSTRAINS_NONE));
//$NON-NLS-1$
- tagResizeConstrans.put(
- "a", Integer.valueOf(VpeTagDescription.RESIZE_CONSTRAINS_NONE));
//$NON-NLS-1$
+ static{
+ tagResizeConstrans.put("table",
Integer.valueOf(VpeTagDescription.RESIZE_CONSTRAINS_ALL)); //$NON-NLS-1$
+ tagResizeConstrans.put("tr",
Integer.valueOf(VpeTagDescription.RESIZE_CONSTRAINS_ALL)); //$NON-NLS-1$
+ tagResizeConstrans.put("br",
Integer.valueOf(VpeTagDescription.RESIZE_CONSTRAINS_NONE)); //$NON-NLS-1$
+ tagResizeConstrans.put("b",
Integer.valueOf(VpeTagDescription.RESIZE_CONSTRAINS_NONE)); //$NON-NLS-1$
+ tagResizeConstrans.put("i",
Integer.valueOf(VpeTagDescription.RESIZE_CONSTRAINS_NONE)); //$NON-NLS-1$
+ tagResizeConstrans.put("u",
Integer.valueOf(VpeTagDescription.RESIZE_CONSTRAINS_NONE)); //$NON-NLS-1$
+ tagResizeConstrans.put("sub",
Integer.valueOf(VpeTagDescription.RESIZE_CONSTRAINS_NONE)); //$NON-NLS-1$
+ tagResizeConstrans.put("sup",
Integer.valueOf(VpeTagDescription.RESIZE_CONSTRAINS_NONE)); //$NON-NLS-1$
+ tagResizeConstrans.put("strike",
Integer.valueOf(VpeTagDescription.RESIZE_CONSTRAINS_NONE)); //$NON-NLS-1$
+ tagResizeConstrans.put("font",
Integer.valueOf(VpeTagDescription.RESIZE_CONSTRAINS_NONE)); //$NON-NLS-1$
+ tagResizeConstrans.put("a",
Integer.valueOf(VpeTagDescription.RESIZE_CONSTRAINS_NONE)); //$NON-NLS-1$
}
-
+
static private HashSet<String> breakWithParagraphTags = new
HashSet<String>();
- static {
+ static{
breakWithParagraphTags.add("b"); //$NON-NLS-1$
breakWithParagraphTags.add("a"); //$NON-NLS-1$
breakWithParagraphTags.add("abbr"); //$NON-NLS-1$
@@ -161,7 +135,7 @@
breakWithParagraphTags.add("var"); //$NON-NLS-1$
}
static private HashSet<String> breakWithoutParagraphTags = new
HashSet<String>();
- static {
+ static{
breakWithoutParagraphTags.add("p"); //$NON-NLS-1$
breakWithoutParagraphTags.add("address"); //$NON-NLS-1$
breakWithoutParagraphTags.add("blockquote"); //$NON-NLS-1$
@@ -176,15 +150,11 @@
breakWithoutParagraphTags.add("p"); //$NON-NLS-1$
breakWithoutParagraphTags.add("pre"); //$NON-NLS-1$
}
-
+
/**
* Initiates template after its creating
- *
- * @param templateElement
- * <code>Element</code> with a name "vpe:template" from
the
- * template file
- * @param caseSensitive
- * The case sensitive of an element of a source file
+ * @param templateElement <code>Element</code> with a name
"vpe:template" from the template file
+ * @param caseSensitive The case sensitive of an element of a source file
*/
public void init(Element templateElement, boolean caseSensitive) {
this.caseSensitive = caseSensitive;
@@ -203,15 +173,17 @@
init(templateElement);
}
-
+
protected void init(Element templateElement) {
initTemplateSections(templateElement, true, true, true, true, true);
}
-
+
protected void initTemplateSections(Element templateElement,
- boolean resizeHandler, boolean dndHandler,
- boolean textFormatingHandler, boolean breakHandler,
- boolean pseudoContentHandler) {
+ boolean resizeHandler,
+ boolean dndHandler,
+ boolean textFormatingHandler,
+ boolean breakHandler,
+ boolean pseudoContentHandler) {
NodeList children = templateElement.getChildNodes();
if (children != null) {
int len = children.getLength();
@@ -219,71 +191,62 @@
Node section = children.item(i);
if (section.getNodeType() == Node.ELEMENT_NODE) {
String sectionName = section.getNodeName();
- if (resizeHandler
- && VpeTemplateManager.TAG_RESIZE
- .equals(sectionName)) {
- initResizeHandler((Element) section);
- } else if (dndHandler
- && VpeTemplateManager.TAG_DND.equals(sectionName)) {
- initDndHandler((Element) section);
- } else if (textFormatingHandler
- && VpeTemplateManager.TAG_TEXT_FORMATING
- .equals(sectionName)) {
- initTextFormatingHandler((Element) section);
+ if (resizeHandler && VpeTemplateManager.TAG_RESIZE.equals(sectionName)) {
+ initResizeHandler((Element)section);
+ } else if (dndHandler && VpeTemplateManager.TAG_DND.equals(sectionName)) {
+ initDndHandler((Element)section);
+ } else if (textFormatingHandler &&
VpeTemplateManager.TAG_TEXT_FORMATING.equals(sectionName)) {
+ initTextFormatingHandler((Element)section);
} else if (breakHandler && TAG_BREAKER.equals(sectionName)) {
- initBreakHandler((Element) section);
- } else if (pseudoContentHandler
- && TAG_PSEUDOCONTENT.equals(sectionName)) {
- initPseudoContentHandler((Element) section);
+ initBreakHandler((Element)section);
+ } else if (pseudoContentHandler && TAG_PSEUDOCONTENT.equals(sectionName)) {
+ initPseudoContentHandler((Element)section);
} else {
- initTemplateSection((Element) section);
+ initTemplateSection((Element)section);
}
}
}
}
}
-
+
private void initResizeHandler(Element templateSection) {
if (resizer == null) {
resizer = new VpeResizer();
resizer.setResizeData(templateSection);
}
}
-
+
private void initDndHandler(Element templateSection) {
if (getDragger() == null) {
setDragger(new VpeDnd());
getDragger().setDndData(templateSection);
- }
+ }
}
-
+
private void initTextFormatingHandler(Element templateSection) {
if (textFormatingData == null) {
textFormatingData = new TextFormatingData(templateSection);
}
}
-
+
private void initBreakHandler(Element templateSection) {
if (breakerType == BREAKER_TYPE_NONE) {
String typeValue = templateSection.getAttribute(ATTR_BREAKER_TYPE);
if (typeValue != null) {
if (ATTR_BREAKER_TYPE_IGNORE.equalsIgnoreCase(typeValue)) {
breakerType = BREAKER_TYPE_IGNORE;
- } else if (ATTR_BREAKER_TYPE_SELECTITEM
- .equalsIgnoreCase(typeValue)) {
+ } else if (ATTR_BREAKER_TYPE_SELECTITEM.equalsIgnoreCase(typeValue)) {
breakerType = BREAKER_TYPE_SELECTITEM;
}
}
}
}
-
+
private void initPseudoContentHandler(Element templateSection) {
if (pseudoContentCreator == null) {
if
("yes".equalsIgnoreCase(templateSection.getAttribute(ATTR_PSEUDOCONTENT_DEFAULTTEXT)))
{ //$NON-NLS-1$
- pseudoContentCreator = new VpeTextPseudoContentCreator(null,
- templateSection
- .getAttribute(ATTR_PSEUDOCONTENT_ATTRNAME));
+ pseudoContentCreator = new VpeTextPseudoContentCreator(null,
templateSection.getAttribute(ATTR_PSEUDOCONTENT_ATTRNAME));
} else {
NodeList children = templateSection.getChildNodes();
if (children != null) {
@@ -291,8 +254,7 @@
for (int i = 0; i < len; i++) {
Node child = children.item(i);
if (child.getNodeType() == Node.ELEMENT_NODE) {
- pseudoContentCreator = new VpeHtmlPseudoContentCreator(
- (Element) child);
+ pseudoContentCreator = new VpeHtmlPseudoContentCreator((Element)child);
return;
}
}
@@ -301,83 +263,64 @@
if (child.getNodeType() == Node.TEXT_NODE) {
String text = child.getNodeValue().trim();
if (text.length() > 0) {
- pseudoContentCreator = new VpeTextPseudoContentCreator(
- text, null);
+ pseudoContentCreator = new VpeTextPseudoContentCreator(text, null);
return;
}
}
}
}
- pseudoContentCreator = VpeEmptyPseudoContentCreator
- .getInstance();
+ pseudoContentCreator = VpeEmptyPseudoContentCreator.getInstance();
}
}
}
-
+
protected void initTemplateSection(Element templateSection) {
}
/**
- * Is invoked after construction of all child nodes of the current visual
- * node.
- *
- * @param pageContext
- * Contains the information on edited page.
- * @param sourceNode
- * The current node of the source tree.
- * @param visualDocument
- * The document of the visual tree.
- * @param data
- * Object <code>VpeCreationData</code>, built by a method
- * <code>create</code>
+ * Is invoked after construction of all child nodes of the current visual node.
+ * @param pageContext Contains the information on edited page.
+ * @param sourceNode The current node of the source tree.
+ * @param visualDocument The document of the visual tree.
+ * @param data Object <code>VpeCreationData</code>, built by a method
<code>create</code>
*/
- public void validate(VpePageContext pageContext, Node sourceNode,
- nsIDOMDocument visualDocument, VpeCreationData data) {
+ public void validate(VpePageContext pageContext, Node sourceNode, nsIDOMDocument
visualDocument, VpeCreationData data) {
}
IRegion fCurrentRegionToFormat = null;
-
private IRegion getRegionToFormat() {
return fCurrentRegionToFormat;
}
-
private void clearRegionToFormat() {
fCurrentRegionToFormat = null;
}
-
private void updateRegionToFormat(Node node) {
if (node instanceof IndexedRegion) {
- IndexedRegion region = (IndexedRegion) node;
+ IndexedRegion region = (IndexedRegion)node;
int start = region.getStartOffset();
int end = region.getEndOffset();
-
+
if (fCurrentRegionToFormat == null) {
fCurrentRegionToFormat = new Region(start, end - start);
} else {
int cStart = fCurrentRegionToFormat.getOffset();
- int cEnd = fCurrentRegionToFormat.getOffset()
- + fCurrentRegionToFormat.getLength();
-
- if (start < cStart)
- cStart = start;
- if (end > cEnd)
- cEnd = end;
-
+ int cEnd = fCurrentRegionToFormat.getOffset() + fCurrentRegionToFormat.getLength();
+
+ if (start < cStart) cStart = start;
+ if (end > cEnd) cEnd = end;
+
fCurrentRegionToFormat = new Region(cStart, cEnd - cStart);
}
}
}
-
private void reformatCallback(VpePageContext pageContext) {
try {
- StructuredTextEditor editor = pageContext.getEditPart()
- .getSourceEditor();
+ StructuredTextEditor editor = pageContext.getEditPart().getSourceEditor();
StructuredTextViewer viewer = editor.getTextViewer();
- if (getRegionToFormat() != null) {
+ if (getRegionToFormat() != null){
if (editor instanceof ITextFormatter) {
- ((ITextFormatter) editor).formatTextRegion(viewer
- .getDocument(), getRegionToFormat());
- }
+ ((ITextFormatter)editor).formatTextRegion(viewer.getDocument(),
getRegionToFormat());
+ }
}
} catch (Exception e) {
VpePlugin.reportProblem(e);
@@ -385,49 +328,31 @@
clearRegionToFormat();
}
}
-
+
/**
* Processes keyboard input (without the pressed key Ctrl)
- *
- * @param pageContext
- * Contains the information on edited page.
- * @param sourceDocument
- * The document of the source tree.
- * @param sourceNode
- * The current node of the source tree.
- * @param visualNode
- * The current node of the visual tree.
- * @param data
- * The arbitrary data, built by a method <code>create</code>
- * @param charCode
- * Code of the pressed key
- * @param selection
- * The current selection
- * @param formatter
- * Interface for formatting the source text
+ * @param pageContext Contains the information on edited page.
+ * @param sourceDocument The document of the source tree.
+ * @param sourceNode The current node of the source tree.
+ * @param visualNode The current node of the visual tree.
+ * @param data The arbitrary data, built by a method <code>create</code>
+ * @param charCode Code of the pressed key
+ * @param selection The current selection
+ * @param formatter Interface for formatting the source text
* @return <code>true</code> if the key is processed
*/
- public boolean nonctrlKeyPressHandler(VpePageContext pageContext,
- Document sourceDocument, Node sourceNode, nsIDOMNode visualNode,
- Object data, long charCode, VpeSourceSelection selection,
- ITextFormatter formatter) {
+ public boolean nonctrlKeyPressHandler(VpePageContext pageContext, Document
sourceDocument, Node sourceNode, nsIDOMNode visualNode, Object data, long charCode,
VpeSourceSelection selection, ITextFormatter formatter) {
switch (breakerType) {
case BREAKER_TYPE_IGNORE:
return true;
case BREAKER_TYPE_SELECTITEM:
- return VpeBreackerHelper.selectItem(pageContext, sourceDocument,
- sourceNode, visualNode, data, charCode, selection);
+ return VpeBreackerHelper.selectItem(pageContext, sourceDocument, sourceNode,
visualNode, data, charCode, selection);
default:
- return nonctrlKeyPressHandlerImpl(pageContext, sourceDocument,
- sourceNode, visualNode, data, charCode, selection,
- formatter);
+ return nonctrlKeyPressHandlerImpl(pageContext, sourceDocument, sourceNode,
visualNode, data, charCode, selection, formatter);
}
}
-
- private boolean nonctrlKeyPressHandlerImpl(VpePageContext pageContext,
- Document sourceDocument, Node sourceNode, nsIDOMNode visualNode,
- Object data, long charCode, VpeSourceSelection selection,
- ITextFormatter formatter) {
+
+ private boolean nonctrlKeyPressHandlerImpl(VpePageContext pageContext, Document
sourceDocument, Node sourceNode, nsIDOMNode visualNode, Object data, long charCode,
VpeSourceSelection selection, ITextFormatter formatter) {
clearRegionToFormat();
Node focusNode = selection.getFocusNode();
int focusNodeType = focusNode.getNodeType();
@@ -441,17 +366,15 @@
Node newLi = sourceNode.cloneNode(false);
newLi = sourceNode.getParentNode().insertBefore(newLi, where);
- if (focusNodeType == Node.TEXT_NODE
- || (focusNodeType == Node.ELEMENT_NODE && sourceNode != focusNode)) {
+ if (focusNodeType == Node.TEXT_NODE ||
+ (focusNodeType == Node.ELEMENT_NODE && sourceNode != focusNode)) {
Node parent = focusNode.getParentNode();
Node newText = focusNode.cloneNode(false);
Node node1 = newText;
if (focusNodeType == Node.TEXT_NODE) {
- String value1 = focusNode.getNodeValue().substring(0,
- selection.getFocusOffset());
- String value2 = node1.getNodeValue().substring(
- selection.getFocusOffset());
+ String value1 = focusNode.getNodeValue().substring(0, selection.getFocusOffset());
+ String value2 = node1.getNodeValue().substring(selection.getFocusOffset());
if (where != sourceNode) {
focusNode.setNodeValue(value1);
node1.setNodeValue(value2);
@@ -488,28 +411,21 @@
updateRegionToFormat(newLi);
reformatCallback(pageContext);
return true;
- } else if (focusNodeType == Node.ELEMENT_NODE
- && focusNode.getNodeName().equalsIgnoreCase("br")) { //$NON-NLS-1$
- Node newNode = focusNode
- .getParentNode()
- .insertBefore(
- focusNode.getOwnerDocument().createElement("br"), focusNode);
//$NON-NLS-1$
+ } else if (focusNodeType == Node.ELEMENT_NODE &&
focusNode.getNodeName().equalsIgnoreCase("br")) { //$NON-NLS-1$
+ Node newNode =
focusNode.getParentNode().insertBefore(focusNode.getOwnerDocument().createElement("br"),
focusNode); //$NON-NLS-1$
updateRegionToFormat(focusNode);
updateRegionToFormat(newNode);
reformatCallback(pageContext);
return true;
- } else if (focusNodeType == Node.ELEMENT_NODE
- && focusNode.getNodeName().equalsIgnoreCase("p")) { //$NON-NLS-1$
+ } else if (focusNodeType == Node.ELEMENT_NODE &&
focusNode.getNodeName().equalsIgnoreCase("p")) { //$NON-NLS-1$
Node nextElement = focusNode.getNextSibling();
Node parent = focusNode.getParentNode();
if (parent != null) {
Node newP = null;
if (nextElement != null) {
- newP = focusNode.getParentNode().insertBefore(
- focusNode.cloneNode(false), nextElement);
+ newP = focusNode.getParentNode().insertBefore(focusNode.cloneNode(false),
nextElement);
} else {
- newP = focusNode.getParentNode().appendChild(
- focusNode.cloneNode(false));
+ newP = focusNode.getParentNode().appendChild(focusNode.cloneNode(false));
}
setCursor(pageContext, newP);
updateRegionToFormat(newP);
@@ -517,22 +433,16 @@
updateRegionToFormat(focusNode);
reformatCallback(pageContext);
return true;
- } else if (focusNodeType == Node.TEXT_NODE
- && focusNode.getParentNode().getNodeName().equalsIgnoreCase(
- "td")) { //$NON-NLS-1$
- Text newNode = ((Text) focusNode).splitText(selection
- .getFocusOffset());
+ } else if (focusNodeType == Node.TEXT_NODE &&
focusNode.getParentNode().getNodeName().equalsIgnoreCase("td")) { //$NON-NLS-1$
+ Text newNode = ((Text)focusNode).splitText(selection.getFocusOffset());
setCursor(pageContext, newNode);
updateRegionToFormat(focusNode);
updateRegionToFormat(newNode);
reformatCallback(pageContext);
return true;
- } else if (sourceNode.getNodeType() == Node.ELEMENT_NODE
- && sourceNode.getNodeName().equalsIgnoreCase("tr")) {
//$NON-NLS-1$
+ } else if (sourceNode.getNodeType() == Node.ELEMENT_NODE &&
sourceNode.getNodeName().equalsIgnoreCase("tr")) { //$NON-NLS-1$
return true;
- } else if (focusNodeType == Node.TEXT_NODE
- && !focusNode.getParentNode().getNodeName().equalsIgnoreCase(
- "body")) { //$NON-NLS-1$
+ } else if (focusNodeType == Node.TEXT_NODE &&
!focusNode.getParentNode().getNodeName().equalsIgnoreCase("body")) {
//$NON-NLS-1$
Node parent = focusNode.getParentNode();
if (parent != null) {
String parentName = parent.getNodeName();
@@ -542,14 +452,12 @@
if (parentParent != null) {
if (!parentParent.getNodeName().equalsIgnoreCase("p")) { //$NON-NLS-1$
if (parentParent.getNodeType() != Node.DOCUMENT_NODE) {
- p1 = parentParent.getOwnerDocument()
- .createElement("p"); //$NON-NLS-1$
+ p1 = parentParent.getOwnerDocument().createElement("p"); //$NON-NLS-1$
parentParent.insertBefore(p1, parent);
parent = parentParent.removeChild(parent);
p1.appendChild(parent);
} else {
- p1 = ((Document) parentParent)
- .createElement("p"); //$NON-NLS-1$
+ p1 = ((Document)parentParent).createElement("p"); //$NON-NLS-1$
parentParent.insertBefore(p1, parent);
parent = parentParent.removeChild(parent);
p1.appendChild(parent);
@@ -558,16 +466,12 @@
p1 = parentParent;
}
if (p1 != null) {
- Text newNode = ((Text) focusNode)
- .splitText(selection.getFocusOffset());
- p2 = p1.getParentNode().insertBefore(
- p1.cloneNode(false), p1.getNextSibling());
- Node newParent = p2.appendChild(parent
- .cloneNode(false));
+ Text newNode = ((Text)focusNode).splitText(selection.getFocusOffset());
+ p2 = p1.getParentNode().insertBefore(p1.cloneNode(false), p1.getNextSibling());
+ Node newParent = p2.appendChild(parent.cloneNode(false));
Node currentNode = newNode;
while (currentNode != null) {
- Node currentNode1 = currentNode
- .getNextSibling();
+ Node currentNode1 = currentNode.getNextSibling();
currentNode = parent.removeChild(currentNode);
newParent.appendChild(currentNode);
currentNode = currentNode1;
@@ -581,14 +485,11 @@
}
}
} else if (breakWithoutParagraphTags.contains(parentName)) {
- Text newNode = ((Text) focusNode).splitText(selection
- .getFocusOffset());
+ Text newNode = ((Text)focusNode).splitText(selection.getFocusOffset());
Node parentParent = parent.getParentNode();
if (parentParent != null) {
boolean clone = newNode.getNodeValue().trim().length() > 0;
- Node newParent = parentParent.insertBefore(
- makeNewParent(parent, clone), parent
- .getNextSibling());
+ Node newParent = parentParent.insertBefore(makeNewParent(parent, clone),
parent.getNextSibling());
Node currentNode = newNode;
while (currentNode != null) {
Node currentNode1 = currentNode.getNextSibling();
@@ -605,8 +506,7 @@
}
}
}
- } else if (focusNodeType == Node.ELEMENT_NODE
- && selection.getFocusOffset() == 2) {
+ } else if (focusNodeType == Node.ELEMENT_NODE && selection.getFocusOffset() ==
2) {
Node parent = focusNode;
if (parent != null) {
String parentName = parent.getNodeName();
@@ -616,14 +516,12 @@
if (parentParent != null) {
if (!parentParent.getNodeName().equalsIgnoreCase("p")) {
if (parentParent.getNodeType() != Node.DOCUMENT_NODE) {
- p1 = parentParent.getOwnerDocument()
- .createElement("p");
+ p1 = parentParent.getOwnerDocument().createElement("p");
parentParent.insertBefore(p1, parent);
parent = parentParent.removeChild(parent);
p1.appendChild(parent);
} else {
- p1 = ((Document) parentParent)
- .createElement("p");
+ p1 = ((Document)parentParent).createElement("p");
parentParent.insertBefore(p1, parent);
parent = parentParent.removeChild(parent);
p1.appendChild(parent);
@@ -632,12 +530,10 @@
p1 = parentParent;
}
if (p1 != null) {
- p2 = p1.getParentNode().insertBefore(
- p1.cloneNode(false), p1.getNextSibling());
- Node newParent = p2.appendChild(parent
- .cloneNode(false));
+ p2 = p1.getParentNode().insertBefore(p1.cloneNode(false), p1.getNextSibling());
+ Node newParent = p2.appendChild(parent.cloneNode(false));
setCursor(pageContext, newParent);
-
+
updateRegionToFormat(p1);
updateRegionToFormat(p2);
updateRegionToFormat(newParent);
@@ -648,9 +544,7 @@
} else if (breakWithoutParagraphTags.contains(parentName)) {
Node parentParent = parent.getParentNode();
if (parentParent != null) {
- Node newParent = parentParent.insertBefore(
- makeNewParent(parent, false), parent
- .getNextSibling());
+ Node newParent = parentParent.insertBefore(makeNewParent(parent, false),
parent.getNextSibling());
setCursor(pageContext, newParent);
updateRegionToFormat(newParent);
@@ -660,17 +554,14 @@
}
}
}
- } else if (focusNodeType == Node.TEXT_NODE
- && focusNode.getParentNode().getNodeName().equalsIgnoreCase(
- "body")) { //$NON-NLS-1$
+ } else if (focusNodeType == Node.TEXT_NODE &&
focusNode.getParentNode().getNodeName().equalsIgnoreCase("body")) {
//$NON-NLS-1$
Node p1 = focusNode.getOwnerDocument().createElement("p"); //$NON-NLS-1$
Node p2 = focusNode.getOwnerDocument().createElement("p"); //$NON-NLS-1$
- Text newNode = ((Text) focusNode).splitText(selection
- .getFocusOffset());
+ Text newNode = ((Text)focusNode).splitText(selection.getFocusOffset());
focusNode.getParentNode().insertBefore(p1, focusNode);
focusNode.getParentNode().insertBefore(p2, newNode);
focusNode = focusNode.getParentNode().removeChild(focusNode);
- newNode = (Text) newNode.getParentNode().removeChild(newNode);
+ newNode = (Text)newNode.getParentNode().removeChild(newNode);
p1.appendChild(focusNode);
p2.appendChild(newNode);
setCursor(pageContext, newNode);
@@ -681,12 +572,8 @@
reformatCallback(pageContext);
return true;
- } else if (focusNodeType == Node.ELEMENT_NODE
- && selection.getFocusOffset() == 0) {
- Node newNode = focusNode
- .getParentNode()
- .insertBefore(
- focusNode.getOwnerDocument().createElement("br"), focusNode);
//$NON-NLS-1$
+ } else if (focusNodeType == Node.ELEMENT_NODE && selection.getFocusOffset() ==
0) {
+ Node newNode =
focusNode.getParentNode().insertBefore(focusNode.getOwnerDocument().createElement("br"),
focusNode); //$NON-NLS-1$
updateRegionToFormat(focusNode);
updateRegionToFormat(newNode);
reformatCallback(pageContext);
@@ -712,117 +599,79 @@
}
private void setCursor(VpePageContext pageContext, Node node) {
- int nodeOffset = ((IndexedRegion) node).getStartOffset();
+ int nodeOffset = ((IndexedRegion)node).getStartOffset();
if (node.getNodeType() == Node.ELEMENT_NODE) {
- ElementImpl element = (ElementImpl) node;
+ ElementImpl element = (ElementImpl)node;
nodeOffset = element.getStartEndOffset();
}
- pageContext.getSourceBuilder().getStructuredTextViewer()
- .setSelectedRange(nodeOffset, 0);
- pageContext.getSourceBuilder().getStructuredTextViewer().revealRange(
- nodeOffset, 0);
+ pageContext.getSourceBuilder().getStructuredTextViewer().setSelectedRange(nodeOffset,
0);
+ pageContext.getSourceBuilder().getStructuredTextViewer().revealRange(nodeOffset, 0);
}
/**
* Is invoked before removal of the visiblis node from the tree
- *
- * @param pageContext
- * Contains the information on edited page.
- * @param sourceNode
- * The current node of the source tree.
- * @param visualNode
- * The current node of the visual tree.
- * @param data
- * The arbitrary data, built by a method <code>create</code>
+ * @param pageContext Contains the information on edited page.
+ * @param sourceNode The current node of the source tree.
+ * @param visualNode The current node of the visual tree.
+ * @param data The arbitrary data, built by a method <code>create</code>
*/
- public void beforeRemove(VpePageContext pageContext, Node sourceNode,
- nsIDOMNode visualNode, Object data) {
+ public void beforeRemove(VpePageContext pageContext, Node sourceNode, nsIDOMNode
visualNode, Object data) {
}
/**
- * At a modification of the node of an source tree, the method update for
- * this node is invoked. Template can indicate other node for update
- *
- * @param pageContext
- * Contains the information on edited page.
- * @param sourceNode
- * The current node of the source tree.
- * @param visualNode
- * The current node of the visual tree.
- * @param data
- * The arbitrary data, built by a method <code>create</code>
- * @return For this node of an source tree the method update is invoked. If
- * null, that is invoked update for current source node
+ * At a modification of the node of an source tree, the method update
+ * for this node is invoked. Template can indicate other node for update
+ * @param pageContext Contains the information on edited page.
+ * @param sourceNode The current node of the source tree.
+ * @param visualNode The current node of the visual tree.
+ * @param data The arbitrary data, built by a method <code>create</code>
+ * @return For this node of an source tree the method update is invoked.
+ * If null, that is invoked update for current source node
*/
- public Node getNodeForUptate(VpePageContext pageContext, Node sourceNode,
- nsIDOMNode visualNode, Object data) {
+ public Node getNodeForUptate(VpePageContext pageContext, Node sourceNode, nsIDOMNode
visualNode, Object data) {
return null;
}
/**
* Is invoked at resize of an element visual tree
- *
- * @param pageContext
- * Contains the information on edited page.
- * @param sourceElement
- * The current element of the source tree.
- * @param visualDocument
- * The document of the visual tree.
- * @param visualElement
- * The current element of the visual tree.
- * @param data
- * The arbitrary data, built by a method <code>create</code>
- * @param resizerConstrains
- * Code of resizer:<br>
- * top-left: 1<br>
- * top: 2<br>
- * top-right: 4<br>
- * left: 8<br>
- * right: 16<br>
- * bottomleft: 32<br>
- * bottom: 64<br>
- * bottom-right: 128<br>
- * @param top
- * Element top
- * @param left
- * Element left
- * @param width
- * Element width
- * @param height
- * Element height
+ * @param pageContext Contains the information on edited page.
+ * @param sourceElement The current element of the source tree.
+ * @param visualDocument The document of the visual tree.
+ * @param visualElement The current element of the visual tree.
+ * @param data The arbitrary data, built by a method <code>create</code>
+ * @param resizerConstrains Code of resizer:<br>
+ * top-left: 1<br>
+ * top: 2<br>
+ * top-right: 4<br>
+ * left: 8<br>
+ * right: 16<br>
+ * bottomleft: 32<br>
+ * bottom: 64<br>
+ * bottom-right: 128<br>
+ * @param top Element top
+ * @param left Element left
+ * @param width Element width
+ * @param height Element height
*/
- public void resize(VpePageContext pageContext, Element sourceElement,
- nsIDOMDocument visualDocument, nsIDOMElement visualElement,
- Object data, int resizerConstrains, int top, int left, int width,
- int height) {
+ public void resize(VpePageContext pageContext, Element sourceElement, nsIDOMDocument
visualDocument, nsIDOMElement visualElement, Object data, int resizerConstrains, int top,
int left, int width, int height) {
if (resizer != null) {
- resizer.resize(pageContext, sourceElement, visualDocument,
- visualElement, data, resizerConstrains, top, left, width,
- height);
+ resizer.resize(pageContext, sourceElement, visualDocument, visualElement, data,
resizerConstrains, top, left, width, height);
}
}
/**
- * Checks a capability of drag of visual element
- *
- * @param pageContext
- * Contains the information on edited page.
- * @param sourceElement
- * The current element of the source tree.
- * @param visualDocument
- * The document of the visual tree.
- * @param visualElement
- * The current element of the visual tree.
- * @param data
- * The arbitrary data, built by a method <code>create</code>
+ * Checks a capability of drag of visual element
+ * @param pageContext Contains the information on edited page.
+ * @param sourceElement The current element of the source tree.
+ * @param visualDocument The document of the visual tree.
+ * @param visualElement The current element of the visual tree.
+ * @param data The arbitrary data, built by a method <code>create</code>
* @return <code>true</code> The element can be dragged
*/
- public boolean canInnerDrag(VpePageContext pageContext,
- Element sourceElement, nsIDOMDocument visualDocument,
- nsIDOMElement visualElement, Object data) {
+ public boolean canInnerDrag(VpePageContext pageContext, Element sourceElement,
nsIDOMDocument visualDocument, nsIDOMElement visualElement, Object data) {
// TODO Max Areshkau add DnD support
if (getDragger() != null) {
-
+
return getDragger().isDragEnabled();
} else {
return true;
@@ -831,21 +680,15 @@
/**
* Checks a capability to drop an element in the container
- *
- * @param pageContext
- * Contains the information on edited page.
- * @param container
- * Element-Container
- * @param sourceDragNode
- * Node for drop
+ * @param pageContext Contains the information on edited page.
+ * @param container Element-Container
+ * @param sourceDragNode Node for drop
* @return <code>true</code> The node can be dropped
*/
- public boolean canInnerDrop(VpePageContext pageContext, Node container,
- Node sourceDragNode) {
+ public boolean canInnerDrop(VpePageContext pageContext, Node container, Node
sourceDragNode) {
if (dragger != null) {
- return dragger
- .isDropEnabled(pageContext, container, sourceDragNode);
+ return dragger.isDropEnabled(pageContext, container, sourceDragNode);
} else {
return false;
}
@@ -853,62 +696,44 @@
/**
* Is invoked at drop of an element visual tree
- *
- * @param pageContext
- * Contains the information on edited page.
- * @param dragInfo
- * The information on the dragged element
- * @param dropInfo
- * The information on the drop container
+ * @param pageContext Contains the information on edited page.
+ * @param dragInfo The information on the dragged element
+ * @param dropInfo The information on the drop container
*/
- public void innerDrop(VpePageContext pageContext,
- VpeSourceInnerDragInfo dragInfo, VpeSourceInnerDropInfo dropInfo) {
+ public void innerDrop(VpePageContext pageContext, VpeSourceInnerDragInfo dragInfo,
VpeSourceInnerDropInfo dropInfo) {
// TODO Max Areshkau add DnD support
- // if (dragger != null) {
- // dragger.drop(pageContext, dragInfo, dropInfo);
- // }
+// if (dragger != null) {
+// dragger.drop(pageContext, dragInfo, dropInfo);
+// }
}
-
- protected String deleteFromString(String data, String begin, String end) {
+
+ protected String deleteFromString(String data, String begin, String end){
int startPosition = data.indexOf(begin);
-
- if (startPosition < 0)
- return data;
-
+
+ if(startPosition < 0) return data;
+
int endPosition = data.indexOf(end, startPosition);
-
+
String result = data.substring(0, startPosition).trim();
- if (endPosition > 0) {
- result += data.substring(endPosition + 1, data.length()).trim();
+ if(endPosition > 0){
+ result += data.substring(endPosition+1, data.length()).trim();
}
-
+
return result;
}
/**
- * Checks, whether it is necessary to re-create an element at change of
- * attribute
- *
- * @param pageContext
- * Contains the information on edited page.
- * @param sourceElement
- * The current element of the source tree.
- * @param visualDocument
- * The document of the visual tree.
- * @param visualNode
- * The current node of the visual tree.
- * @param data
- * The arbitrary data, built by a method <code>create</code>
- * @param name
- * Atrribute name
- * @param value
- * Attribute value
- * @return <code>true</code> if it is required to re-create an element at a
- * modification of attribute, <code>false</code> otherwise.
+ * Checks, whether it is necessary to re-create an element at change of attribute
+ * @param pageContext Contains the information on edited page.
+ * @param sourceElement The current element of the source tree.
+ * @param visualDocument The document of the visual tree.
+ * @param visualNode The current node of the visual tree.
+ * @param data The arbitrary data, built by a method <code>create</code>
+ * @param name Atrribute name
+ * @param value Attribute value
+ * @return <code>true</code> if it is required to re-create an element at a
modification of attribute, <code>false</code> otherwise.
*/
- public boolean isRecreateAtAttrChange(VpePageContext pageContext,
- Element sourceElement, nsIDOMDocument visualDocument,
- nsIDOMElement visualNode, Object data, String name, String value) {
+ public boolean isRecreateAtAttrChange(VpePageContext pageContext, Element sourceElement,
nsIDOMDocument visualDocument, nsIDOMElement visualNode, Object data, String name, String
value) {
return false;
}
@@ -918,15 +743,15 @@
public boolean isChildren() {
return children;
}
-
+
public boolean isModify() {
return modify;
}
-
+
public void setModify(boolean modify) {
this.modify = modify;
}
-
+
/**
* @return <code>true</code> if the element is case sensitive
*/
@@ -936,38 +761,28 @@
/**
* Returns the data for formatting an element of source tree
- *
* @return <code>TextFormatingData</code>
*/
public TextFormatingData getTextFormatingData() {
return textFormatingData;
}
-
+
/**
* Returns <code>VpeTagDescription</code>
- *
- * @param pageContext
- * Contains the information on edited page.
- * @param sourceElement
- * The current element of the source tree.
- * @param visualDocument
- * The document of the visual tree.
- * @param visualElement
- * The current element of the visual tree.
- * @param data
- * The arbitrary data, built by a method <code>create</code>
+ * @param pageContext Contains the information on edited page.
+ * @param sourceElement The current element of the source tree.
+ * @param visualDocument The document of the visual tree.
+ * @param visualElement The current element of the visual tree.
+ * @param data The arbitrary data, built by a method <code>create</code>
* @return <code>VpeTagDescription</code>
*/
- public VpeTagDescription getTagDescription(VpePageContext pageContext,
- Element sourceElement, nsIDOMDocument visualDocument,
- nsIDOMElement visualElement, Object data) {
+ public VpeTagDescription getTagDescription(VpePageContext pageContext, Element
sourceElement, nsIDOMDocument visualDocument, nsIDOMElement visualElement, Object data){
VpeTagDescription tagDescription = new VpeTagDescription();
if (inlineTags.contains(visualElement.getNodeName().toLowerCase())) {
- tagDescription
- .setDisplayType(VpeTagDescription.DISPLAY_TYPE_INLINE);
+ tagDescription.setDisplayType(VpeTagDescription.DISPLAY_TYPE_INLINE);
}
-
+
if (resizer != null) {
resizer.modifyTagDescription(tagDescription);
}
@@ -975,54 +790,34 @@
}
/**
- * Sets value of attribute of the current visual element. Is invoked at
- * change of attribute of an source element.
- *
- * @param pageContext
- * Contains the information on edited page.
- * @param sourceElement
- * The current element of the source tree.
- * @param visualDocument
- * The document of the visual tree.
- * @param visualNode
- * The current node of the visual tree.
- * @param data
- * The arbitrary data, built by a method <code>create</code>
- * @param name
- * Attribute name.
- * @param value
- * Attribute value.
+ * Sets value of attribute of the current visual element.
+ * Is invoked at change of attribute of an source element.
+ * @param pageContext Contains the information on edited page.
+ * @param sourceElement The current element of the source tree.
+ * @param visualDocument The document of the visual tree.
+ * @param visualNode The current node of the visual tree.
+ * @param data The arbitrary data, built by a method <code>create</code>
+ * @param name Attribute name.
+ * @param value Attribute value.
*/
- public void setAttribute(VpePageContext pageContext, Element sourceElement,
- nsIDOMDocument visualDocument, nsIDOMNode visualNode, Object data,
- String name, String value) {
+ public void setAttribute(VpePageContext pageContext, Element sourceElement,
nsIDOMDocument visualDocument, nsIDOMNode visualNode, Object data, String name, String
value) {
}
/**
* Informs on remove of attribute of the current source element.
- *
- * @param pageContext
- * Contains the information on edited page.
- * @param sourceElement
- * The current element of the source tree.
- * @param visualDocument
- * The document of the visual tree.
- * @param visualNode
- * The current node of the visual tree.
- * @param data
- * The arbitrary data, built by a method <code>create</code>
- * @param name
- * Attribute name.
+ * @param pageContext Contains the information on edited page.
+ * @param sourceElement The current element of the source tree.
+ * @param visualDocument The document of the visual tree.
+ * @param visualNode The current node of the visual tree.
+ * @param data The arbitrary data, built by a method <code>create</code>
+ * @param name Attribute name.
*/
- public void removeAttribute(VpePageContext pageContext,
- Element sourceElement, nsIDOMDocument visualDocument,
- nsIDOMNode visualNode, Object data, String name) {
+ public void removeAttribute(VpePageContext pageContext, Element sourceElement,
nsIDOMDocument visualDocument, nsIDOMNode visualNode, Object data, String name) {
}
/**
- * Returns a list of attributes of an element of the source tree, the values
- * which one are mapped in the visiblis editor
- *
+ * Returns a list of attributes of an element of the source tree,
+ * the values which one are mapped in the visiblis editor
* @return attrubute name array
*/
public String[] getOutputAtributeNames() {
@@ -1030,20 +825,15 @@
}
/**
- * If the value of attribute of an element of an source tree is mapped by
- * the way of text node of a visual treer, this method returns the text
- * node, otherwise - null
- *
- * @param pageContext
- * Contains the information on edited page.
- * @param sourceElement
- * The current element of the source tree.
- * @param data
- * The arbitrary data, built by a method <code>create</code>
+ * If the value of attribute of an element of an source tree
+ * is mapped by the way of text node of a visual treer,
+ * this method returns the text node, otherwise - null
+ * @param pageContext Contains the information on edited page.
+ * @param sourceElement The current element of the source tree.
+ * @param data The arbitrary data, built by a method <code>create</code>
* @return Text node or null
*/
- public nsIDOMText getOutputTextNode(VpePageContext pageContext,
- Element sourceElement, Object data) {
+ public nsIDOMText getOutputTextNode(VpePageContext pageContext, Element sourceElement,
Object data) {
return null;
}
@@ -1072,104 +862,73 @@
/**
* @deprecated
- * @param pageContext
- * Contains the information on edited page.
- * @param sourceElement
- * The current element of the source tree.
+ * @param pageContext Contains the information on edited page.
+ * @param sourceElement The current element of the source tree.
* @param offset
* @param length
* @param data
*/
- public void setSourceAttributeSelection(VpePageContext pageContext,
- Element sourceElement, int offset, int length, Object data) {
+ public void setSourceAttributeSelection(VpePageContext pageContext, Element
sourceElement, int offset, int length, Object data) {
}
/**
* @deprecated
- * @param pageContext
- * Contains the information on edited page.
- * @param sourceElement
- * The current element of the source tree.
- * @param data
- * The arbitrary data, built by a method <code>create</code>
+ * @param pageContext Contains the information on edited page.
+ * @param sourceElement The current element of the source tree.
+ * @param data The arbitrary data, built by a method <code>create</code>
*/
- public void setSourceAttributeValue(VpePageContext pageContext,
- Element sourceElement, Object data) {
+ public void setSourceAttributeValue(VpePageContext pageContext, Element sourceElement,
Object data) {
}
/**
* Is invoked at a change of bundle values
- *
- * @param pageContext
- * Contains the information on edited page.
- * @param sourceElement
- * The current element of the source tree.
- * @param data
- * The arbitrary data, built by a method <code>create</code>
+ * @param pageContext Contains the information on edited page.
+ * @param sourceElement The current element of the source tree.
+ * @param data The arbitrary data, built by a method <code>create</code>
*/
- public void refreshBundleValues(VpePageContext pageContext,
- Element sourceElement, Object data) {
+ public void refreshBundleValues(VpePageContext pageContext, Element sourceElement,
Object data) {
}
/**
- * Opens proprties editor for bundle value Is invoked at double mouse click
- * on visual element
- *
- * @param pageContext
- * Contains the information on edited page.
- * @param sourceElement
- * The current element of the source tree.
- * @param data
- * The arbitrary data, built by a method <code>create</code>
+ * Opens proprties editor for bundle value
+ * Is invoked at double mouse click on visual element
+ * @param pageContext Contains the information on edited page.
+ * @param sourceElement The current element of the source tree.
+ * @param data The arbitrary data, built by a method <code>create</code>
*/
- public void openBundleEditors(VpePageContext pageContext,
- Element sourceElement, Object data) {
+ public void openBundleEditors(VpePageContext pageContext, Element sourceElement, Object
data) {
}
/**
* Opens editor of source file for include-element
- *
- * @param pageContext
- * Contains the information on edited page.
- * @param sourceElement
- * The current element of the source tree.
- * @param data
- * The arbitrary data, built by a method <code>create</code>
+ * @param pageContext Contains the information on edited page.
+ * @param sourceElement The current element of the source tree.
+ * @param data The arbitrary data, built by a method <code>create</code>
*/
- public void openIncludeEditor(VpePageContext pageContext,
- Element sourceElement, Object data) {
+ public void openIncludeEditor(VpePageContext pageContext, Element sourceElement, Object
data) {
}
/**
- * The unfilled element of an source tree can be mapped in the visiblis
- * editor with the default contents This method fills default contents
- *
- * @param pageContext
- * Contains the information on edited page.
- * @param sourceContainer
- * The current element of the source tree.
- * @param visualContainer
- * The current element of the visual tree.
- * @param visualDocument
- * The document of the visual tree.
+ * The unfilled element of an source tree can be mapped
+ * in the visiblis editor with the default contents
+ * This method fills default contents
+ * @param pageContext Contains the information on edited page.
+ * @param sourceContainer The current element of the source tree.
+ * @param visualContainer The current element of the visual tree.
+ * @param visualDocument The document of the visual tree.
*/
- public void setPseudoContent(VpePageContext pageContext,
- Node sourceContainer, nsIDOMNode visualContainer,
- nsIDOMDocument visualDocument) {
+ public void setPseudoContent(VpePageContext pageContext, Node sourceContainer,
nsIDOMNode visualContainer, nsIDOMDocument visualDocument) {
if (pseudoContentCreator != null) {
- pseudoContentCreator.setPseudoContent(pageContext, sourceContainer,
- visualContainer, visualDocument);
+ pseudoContentCreator.setPseudoContent(pageContext, sourceContainer, visualContainer,
visualDocument);
} else {
- VpeDefaultPseudoContentCreator.getInstance().setPseudoContent(
- pageContext, sourceContainer, visualContainer,
- visualDocument);
+ VpeDefaultPseudoContentCreator.getInstance().setPseudoContent(pageContext,
sourceContainer, visualContainer, visualDocument);
}
}
public boolean containsText() {
return true;
}
-
+
public boolean hasImaginaryBorder() {
return hasImaginaryBorder;
}
@@ -1178,126 +937,14 @@
* @return the dragger
*/
public VpeDnd getDragger() {
-
+
return dragger;
}
/**
- * @param dragger
- * the dragger to set
+ * @param dragger the dragger to set
*/
public void setDragger(VpeDnd dragger) {
this.dragger = dragger;
}
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.jboss.tools.vpe.editor.template.VpeTemplate#getNodeData(org.mozilla
- * .interfaces.nsIDOMNode,
- * org.jboss.tools.vpe.editor.mapping.VpeElementData,
- * org.jboss.tools.vpe.editor.mapping.VpeDomMapping)
- */
- public NodeData getNodeData(nsIDOMNode node, VpeElementData elementData,
- VpeDomMapping domMapping) {
-
- // if input data is correct
- if ((node != null) && (elementData != null)
- && (elementData.getNodesData() != null)) {
-
- List<NodeData> nodesData = elementData.getNodesData();
-
- for (NodeData nodeData : nodesData) {
-
- // if source nodes equals
- if (node.equals(nodeData.getVisualNode()))
- return nodeData;
- }
- }
- return null;
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @seeorg.jboss.tools.vpe.editor.template.ITemplateNodesManager#
- * getTargetVisualNodeByBySourcePosition
- * (org.jboss.tools.vpe.editor.mapping.VpeElementMapping, int, int,
- * org.jboss.tools.vpe.editor.mapping.VpeDomMapping)
- */
- public nsIDOMNode getVisualNodeByBySourcePosition(
- VpeElementMapping elementMapping, int focusPosition,
- int anchorPosition, VpeDomMapping domMapping) {
-
- // find focus attribute by position
- nsIDOMNode focusNode = findNodeByPosition(elementMapping
- .getElementData(), focusPosition);
-
- // fond anchor attribute by position
- nsIDOMNode anchorNode = findNodeByPosition(elementMapping
- .getElementData(), anchorPosition);
-
- // if anchor and focus attributes are equal return focused attribute
- if ((focusNode != null) && (focusNode == anchorNode))
- return focusNode;
-
- // else return all element
- return elementMapping.getVisualNode();
-
- }
-
- private nsIDOMNode findNodeByPosition(VpeElementData elementData,
- int position) {
-
- // if data are correct
- if ((elementData != null) && (elementData.getNodesData() != null)) {
-
- List<NodeData> attributesMapping = elementData.getNodesData();
-
- // for each defined attribute
- for (NodeData attributeData : attributesMapping) {
-
- // if position is in attribute's bound
- if ((position >= (NodesManagingUtil
- .getStartOffsetNode(attributeData.getSourceNode())))
- && (position <= (NodesManagingUtil
- .getEndOffsetNode(attributeData.getSourceNode()))))
- return attributeData.getVisualNode();
- }
- }
-
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.jboss.tools.vpe.editor.template.VpeTemplate#openBundle(org.jboss.
- * tools.vpe.editor.context.VpePageContext,
- * org.mozilla.interfaces.nsIDOMNode,
- * org.jboss.tools.vpe.editor.mapping.VpeElementMapping)
- */
- public boolean openBundle(VpePageContext pageContext,
- nsIDOMNode visualNode, VpeElementMapping elementMapping) {
-
- nsIDOMNode lastSelectedNode = SelectionUtil
- .getLastSelectedNode(pageContext);
-
- if (elementMapping == null)
- return false;
-
- NodeData nodeData = getNodeData(lastSelectedNode, elementMapping
- .getElementData(), pageContext.getDomMapping());
-
- if (nodeData != null && nodeData.getSourceNode() != null)
- return pageContext.getBundle().openBundle(
- nodeData.getSourceNode().getNodeValue(),
- NodesManagingUtil.getPageLocale(pageContext, nodeData
- .getSourceNode()));
-
- return false;
- }
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplate.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplate.java 2008-06-25
18:32:58 UTC (rev 8946)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplate.java 2008-06-25
18:47:49 UTC (rev 8947)
@@ -14,10 +14,6 @@
import org.jboss.tools.vpe.editor.VpeSourceInnerDragInfo;
import org.jboss.tools.vpe.editor.VpeSourceInnerDropInfo;
import org.jboss.tools.vpe.editor.context.VpePageContext;
-import org.jboss.tools.vpe.editor.mapping.NodeData;
-import org.jboss.tools.vpe.editor.mapping.VpeDomMapping;
-import org.jboss.tools.vpe.editor.mapping.VpeElementData;
-import org.jboss.tools.vpe.editor.mapping.VpeElementMapping;
import org.jboss.tools.vpe.editor.selection.VpeSourceSelection;
import org.jboss.tools.vpe.editor.template.textformating.TextFormatingData;
import org.mozilla.interfaces.nsIDOMDocument;
@@ -326,7 +322,7 @@
/**
* Returns a list of attributes of an element of the source tree, the values
* which one are mapped in the visiblis editor
- * @deprecated
+ *
* @return attrubute name array
*/
String[] getOutputAtributeNames();
@@ -345,7 +341,6 @@
Object data);
/**
- * @deprecated
* Opens proprties editor for bundle value Is invoked at double mouse click
* on visual element
*
@@ -388,7 +383,7 @@
* If the value of attribute of an element of an source tree is mapped by
* the way of text node of a visual tree, this method returns the text
* node, otherwise - null
- * @deprecated
+ *
* @param pageContext
* Contains the information on edited page.
* @param sourceElement
@@ -452,36 +447,4 @@
public void setModify(boolean modify);
- /**
- * open bundle
- *
- * @param pageContext
- * @param visualNod
- * @return
- */
- public boolean openBundle(VpePageContext pageContext,
- nsIDOMNode visualNode, VpeElementMapping elementMapping);
-
- /**
- *
- * @param node
- * @param elementData
- * @param domMapping
- * @return
- */
- public NodeData getNodeData(nsIDOMNode node, VpeElementData elementData,
- VpeDomMapping domMapping);
-
- /**
- *
- * @param elementMapping
- * @param focusPosition
- * @param anchorPosition
- * @param domMapping
- * @return
- */
- public nsIDOMNode getVisualNodeByBySourcePosition(
- VpeElementMapping elementMapping, int focusPosition,
- int anchorPosition, VpeDomMapping domMapping);
-
}
\ No newline at end of file
Deleted:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/NodesManagingUtil.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/NodesManagingUtil.java 2008-06-25
18:32:58 UTC (rev 8946)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/NodesManagingUtil.java 2008-06-25
18:47:49 UTC (rev 8947)
@@ -1,146 +0,0 @@
-package org.jboss.tools.vpe.editor.util;
-
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.wst.sse.core.StructuredModelManager;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
-import org.eclipse.wst.sse.ui.StructuredTextEditor;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr;
-import org.jboss.tools.vpe.editor.context.VpePageContext;
-import org.jboss.tools.vpe.editor.mapping.VpeDomMapping;
-import org.jboss.tools.vpe.editor.mapping.VpeNodeMapping;
-import org.mozilla.interfaces.nsIDOMNode;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-/**
- *
- * @author S.Dzmitrovich
- *
- */
-public class NodesManagingUtil {
-
- /**
- * name of "view" tag
- */
- private static final String VIEW_TAGNAME = "view"; //$NON-NLS-1$
-
- /**
- * name of "locale" attribute
- */
- private static final String LOCALE_ATTRNAME = "locale"; //$NON-NLS-1$
-
- /**
- *
- * @param domMapping
- * @param node
- * @return
- */
- public static VpeNodeMapping getNodeMapping(VpeDomMapping domMapping,
- Node node) {
-
- return domMapping.getNearNodeMappingAtSourceNode(node);
-
- }
-
- /**
- *
- * @param domMapping
- * @param node
- * @return
- */
- public static VpeNodeMapping getNodeMapping(VpeDomMapping domMapping,
- nsIDOMNode node) {
-
- return domMapping.getNearNodeMappingAtVisualNode(node);
-
- }
-
- /**
- *
- * @param sourceEditor
- * @return
- */
- public static IStructuredModel getStructuredModel(
- StructuredTextEditor sourceEditor) {
-
- IDocument document = sourceEditor.getTextViewer().getDocument();
-
- return StructuredModelManager.getModelManager()
- .getExistingModelForEdit(document);
- }
-
- /**
- *
- * @param node
- * @return
- */
- public static int getNodeLength(Node node) {
-
- if (node instanceof IDOMAttr) {
- return ((IDOMAttr) node).getValueSource().length();
- } else if (node instanceof IndexedRegion) {
- return ((IndexedRegion) node).getEndOffset()
- - ((IndexedRegion) node).getStartOffset();
- }
- return 0;
- }
-
- /**
- * get start offset of node
- *
- * @param node
- * @return
- */
- public static int getStartOffsetNode(Node node) {
-
- if (node instanceof IDOMAttr) {
- return ((IDOMAttr) node).getValueRegionStartOffset() + 1;
- } else if (node instanceof IndexedRegion) {
- return ((IndexedRegion) node).getStartOffset();
- }
- return 0;
- }
-
- /**
- * get end offset of node
- *
- * @param node
- * @return
- */
- public static int getEndOffsetNode(Node node) {
-
- if (node instanceof IndexedRegion) {
- return ((IndexedRegion) node).getEndOffset();
- }
- return 0;
- }
-
- /**
- *
- * @param pageContext
- * @param sourceElement
- * @return
- */
- public static String getPageLocale(VpePageContext pageContext,
- Node sourceNode) {
-
- while (sourceNode != null) {
-
- if (VIEW_TAGNAME.equals(sourceNode.getLocalName())) {
- break;
- }
- sourceNode = sourceNode.getParentNode();
- }
-
- if ((sourceNode == null) || !(sourceNode instanceof Element)
- || !(((Element) sourceNode).hasAttribute(LOCALE_ATTRNAME)))
- return null;
-
- String locale = ((Element) sourceNode).getAttribute(LOCALE_ATTRNAME);
-
- return locale;
-
- }
-
-}
Deleted:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/SelectionUtil.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/SelectionUtil.java 2008-06-25
18:32:58 UTC (rev 8946)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/SelectionUtil.java 2008-06-25
18:47:49 UTC (rev 8947)
@@ -1,215 +0,0 @@
-package org.jboss.tools.vpe.editor.util;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.wst.sse.core.StructuredModelManager;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.sse.ui.StructuredTextEditor;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.jboss.tools.vpe.editor.context.VpePageContext;
-import org.jboss.tools.vpe.editor.mapping.VpeDomMapping;
-import org.jboss.tools.vpe.editor.mapping.VpeNodeMapping;
-import org.mozilla.interfaces.nsIDOMNode;
-import org.mozilla.interfaces.nsIDOMRange;
-import org.mozilla.interfaces.nsISelection;
-import org.w3c.dom.Node;
-
-/**
- *
- * @author S.Dzmitrovich
- *
- */
-public class SelectionUtil {
-
- private static final String EMPTY_STRING = ""; //$NON-NLS-1$
- private static List<String> NO_INPUT_TYPES;
-
- static {
- NO_INPUT_TYPES = new ArrayList<String>();
-
- NO_INPUT_TYPES.add(HTML.VALUE_TEXT_TYPE);
- NO_INPUT_TYPES.add(HTML.VALUE_PASSWORD_TYPE);
- NO_INPUT_TYPES.add(EMPTY_STRING);
- }
-
- /**
- * get selected visual node from nsiDelection
- *
- * @param selection
- * @return
- */
- public static nsIDOMNode getSelectedNode(nsISelection selection) {
-
- if (selection.getAnchorNode() == selection.getFocusNode()) {
- if (selection.getFocusNode() != null) {
- if ((selection.getFocusNode().getNodeType() != nsIDOMNode.TEXT_NODE)
- && (selection.getFocusOffset() != 0)) {
-
- return selection.getFocusNode().getChildNodes().item(
- selection.getFocusOffset() - 1);
- } else
- return selection.getFocusNode();
-
- }
- } else {
- nsIDOMRange range = selection.getRangeAt(0);
- nsIDOMNode visualAncestor = range.getCommonAncestorContainer();
- return visualAncestor;
- }
- return null;
- }
-
- /**
- *
- * @param pageContext
- * @param node
- * @param offset
- * @param length
- */
- public static void setSourceSelection(VpePageContext pageContext,
- Node node, int offset, int length) {
-
- int start = NodesManagingUtil.getStartOffsetNode(node);
-
- pageContext.getSourceBuilder().getStructuredTextViewer()
- .setSelectedRange(start + offset, length);
- pageContext.getSourceBuilder().getStructuredTextViewer().revealRange(
- start + offset, length);
-
- }
-
- public static void setSourceSelection(VpePageContext pageContext,
- Node node, int offset) {
-
- int start = NodesManagingUtil.getStartOffsetNode(node);
-
- pageContext.getSourceBuilder().getStructuredTextViewer()
- .getTextWidget().setSelection(start + offset);
-
- }
-
- public static VpeNodeMapping getNodeMappingBySourceSelection(
- IStructuredModel model, VpeDomMapping domMapping, int focus,
- int anchor) {
-
- /*
- * implementation of IDOMModel's method getIndexedRegion(...) has one
- * feature : if cursor is situated at the border of elements then this
- * method return next element. For example ... <h:inputText
- * ../><h:outputText/>... - if cursor will be situated at the right
- * border of "h:inputText" element then getIndexedRegion() return
- * "h:outputText" element. So for focus position we choose smaller value
- */
-
- if (anchor < focus) {
- focus = anchor;
- anchor = focus;
- }
-
- // get source node by offset
- Node focusNode = getSourceNodeByPosition(model, focus);
-
- // if focus node also contain anchor point (selected only 1 element)
- if ((focusNode != null) && isNodeContainsPosition(focusNode, anchor)) {
-
- return NodesManagingUtil.getNodeMapping(domMapping, focusNode);
-
- }
- return null;
-
- }
-
- /**
- * if position belong to node return true
- *
- * @param node
- * @param position
- * @return
- */
- private static boolean isNodeContainsPosition(Node node, int position) {
-
- if ((((IDOMNode) node).getStartOffset() <= position)
- && (((IDOMNode) node).getEndOffset() >= position))
- return true;
-
- return false;
- }
-
- public static Node getSourceNodeByPosition(IStructuredModel model,
- int position) {
-
- // get source node by position
- Node node = (Node) model.getIndexedRegion(position);
-
- return node;
- }
-
- public static Point getSelectionRange(nsISelection selection) {
- nsIDOMNode focusedNode = getSelectedNode(selection);
-
- Point range = new Point(0, 0);
-
- if (focusedNode != null) {
-
- range.x = selection.getFocusOffset();
- range.y = selection.getAnchorOffset() - selection.getFocusOffset();
-
- }
- return range;
- }
-
- public static VpeNodeMapping getNodeMappingBySourceSelection(
- StructuredTextEditor sourceEditor, VpeDomMapping domMapping) {
-
- Point range = sourceEditor.getTextViewer().getSelectedRange();
-
- IDocument document = sourceEditor.getTextViewer().getDocument();
-
- IStructuredModel model = StructuredModelManager.getModelManager()
- .getExistingModelForEdit(document);
-
- int anchor = range.x;
- int focus = range.x + range.y;
-
- /*
- * implementation of IDOMModel's method getIndexedRegion(...) has one
- * feature : if cursor is situated at the border of elements then this
- * method return next element. For example ... <h:inputText
- * ../><h:outputText/>... - if cursor will be situated at the right
- * border of "h:inputText" element then getIndexedRegion() return
- * "h:outputText" element. So for focus position we choose smaller value
- */
-
- if (anchor < focus) {
- focus = anchor;
- anchor = focus;
- }
-
- // get source node by offset
- Node focusNode = getSourceNodeByPosition(model, focus);
-
- // if focus node also contain anchor point (selected only 1 element)
- if ((focusNode != null) && isNodeContainsPosition(focusNode, anchor)) {
-
- return NodesManagingUtil.getNodeMapping(domMapping, focusNode);
-
- }
- return null;
-
- }
-
- public static nsIDOMNode getLastSelectedNode(VpePageContext pageContext) {
-
- return pageContext.getVisualBuilder().getXulRunnerEditor()
- .getLastSelectedNode();
-
- }
-
- static public Point getSourceSelection(StructuredTextEditor sourceEditor) {
- return sourceEditor.getTextViewer().getSelectedRange();
- }
-
-}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/TemplateManagingUtil.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/TemplateManagingUtil.java 2008-06-25
18:32:58 UTC (rev 8946)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/TemplateManagingUtil.java 2008-06-25
18:47:49 UTC (rev 8947)
@@ -20,7 +20,6 @@
import org.jboss.tools.vpe.editor.mapping.VpeNodeMapping;
import org.jboss.tools.vpe.editor.template.VpeTemplate;
import org.mozilla.interfaces.nsIDOMElement;
-import org.mozilla.interfaces.nsIDOMHTMLInputElement;
import org.mozilla.interfaces.nsIDOMNSHTMLInputElement;
import org.mozilla.interfaces.nsIDOMNSHTMLTextAreaElement;
import org.mozilla.interfaces.nsIDOMNode;
@@ -29,11 +28,6 @@
import org.w3c.dom.Element;
import org.w3c.dom.Node;
-/**
- * @deprecated
- * @author S. Dzmitrovich
- *
- */
public class TemplateManagingUtil {
/**
@@ -434,13 +428,9 @@
if ((node != null) && (range != null))
if (HTML.TAG_INPUT.equalsIgnoreCase(node.getLocalName())) {
-
- nsIDOMHTMLInputElement inputElement = (nsIDOMHTMLInputElement) node
- .queryInterface(nsIDOMHTMLInputElement.NS_IDOMHTMLINPUTELEMENT_IID);
- System.out.print("\ninput:"+inputElement.getType());
-// nsIDOMNSHTMLInputElement inputElement = (nsIDOMNSHTMLInputElement) node
-// .queryInterface(nsIDOMNSHTMLInputElement.NS_IDOMNSHTMLINPUTELEMENT_IID);
-// inputElement.setSelectionRange(range.x, range.x + range.y);
+ nsIDOMNSHTMLInputElement inputElement = (nsIDOMNSHTMLInputElement) node
+ .queryInterface(nsIDOMNSHTMLInputElement.NS_IDOMNSHTMLINPUTELEMENT_IID);
+ inputElement.setSelectionRange(range.x, range.x + range.y);
} else if (HTML.TAG_TEXTAREA.equalsIgnoreCase(node.getLocalName())) {
nsIDOMNSHTMLTextAreaElement textAreaElement = (nsIDOMNSHTMLTextAreaElement) node
.queryInterface(nsIDOMNSHTMLTextAreaElement.NS_IDOMNSHTMLTEXTAREAELEMENT_IID);
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/TextUtil.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/TextUtil.java 2008-06-25
18:32:58 UTC (rev 8946)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/TextUtil.java 2008-06-25
18:47:49 UTC (rev 8947)
@@ -13,8 +13,6 @@
import java.util.HashMap;
import java.util.Map;
-import org.mozilla.interfaces.nsIDOMKeyEvent;
-
public class TextUtil {
private final static String SOURCE_BREAK = "\r\n";
private final static String VISUAL_BREAK = "\n";
@@ -354,17 +352,4 @@
}
return true;
}
-
- public static String getChar(nsIDOMKeyEvent keyEvent) {
- // get inserted string
- long charCode = keyEvent.getCharCode();
- char[] s = new char[1];
- s[0] = (char) charCode;
- String str = new String(s);
- if (TextUtil.containsKey(s[0])) {
- str = TextUtil.getValue(s[0]);
- }
-
- return str;
- }
}
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 2008-06-25
18:32:58 UTC (rev 8946)
+++
trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/XulRunnerEditor.java 2008-06-25
18:47:49 UTC (rev 8947)
@@ -50,8 +50,6 @@
import org.mozilla.xpcom.Mozilla;
import org.mozilla.xpcom.XPCOMException;
-import com.sun.org.apache.bcel.internal.generic.RETURN;
-
/**
* @author Sergey Vasilyev (svasilyev(a)exadel.com)
*
@@ -102,8 +100,7 @@
*/
private static final String STYLE_ATTR="style";
-// private nsIDOMElement lastSelectedElement;
- private nsIDOMNode lastSelectedNode;
+ private nsIDOMElement lastSelectedElement;
private int lastResizerConstrains;
/**
* Scroll selection into view flag
@@ -293,42 +290,30 @@
*/
public nsIDOMElement getLastSelectedElement() {
- return getElement(lastSelectedNode);
+ return lastSelectedElement;
}
-
- public nsIDOMNode getLastSelectedNode() {
- return lastSelectedNode;
+ /**
+ * Function created to restore functionality of MozillaBrowser
+ * @return
+ */
+ private void setLastSelectedElement(nsIDOMElement lastSelectedElement) {
+ this.lastSelectedElement = lastSelectedElement;
}
- // /**
- // * Function created to restore functionality of MozillaBrowser
- // * @return
- // */
- // private void setLastSelectedElement(nsIDOMElement lastSelectedElement) {
- // this.lastSelectedElement = lastSelectedElement;
- // }
-
- private void setLastSelectedNode(nsIDOMNode lastSelectedNode) {
- this.lastSelectedNode = lastSelectedNode;
- }
-
/**
* Draws rectangle around the element.
* @param element
* @param resizerConstrains
* @param scroll
*/
- public void setSelectionRectangle(nsIDOMNode node, int resizerConstrains, boolean
scroll) {
+ public void setSelectionRectangle(nsIDOMElement element, int resizerConstrains, boolean
scroll) {
if (getIFlasher() == null) {
return;
}
-
- nsIDOMElement element = getElement(node);
-
if (getLastSelectedElement() != null) {
- scrollRegtangleFlag = scroll && node != null;
+ scrollRegtangleFlag = scroll && element != null;
if(checkVisability(getLastSelectedElement())){
@@ -400,8 +385,7 @@
}
}
-// setLastSelectedElement(element);
- setLastSelectedNode(node);
+ setLastSelectedElement(element);
lastResizerConstrains = resizerConstrains;
}
@@ -506,8 +490,8 @@
*
*/
public void showResizer() {
- if (xulRunnerVpeResizer != null && getLastSelectedElement() != null &&
lastResizerConstrains != 0) {
- xulRunnerVpeResizer.show(getLastSelectedElement(), lastResizerConstrains);
+ if (xulRunnerVpeResizer != null && lastSelectedElement != null &&
lastResizerConstrains != 0) {
+ xulRunnerVpeResizer.show(lastSelectedElement, lastResizerConstrains);
}
}
@@ -580,37 +564,6 @@
this.selectionListener = selectionListener;
}
- /**
- * get nsIDomElement from nsIDomNode
- *
- * if node is nsIDomElement - return it
- *
- * if node is text node - return it's
- *
- * parent else return null
- *
- * @param node
- * @return
- */
- private nsIDOMElement getElement(nsIDOMNode node) {
-
- if (node != null) {
-
- if (node.getNodeType() == nsIDOMNode.ELEMENT_NODE) {
- return (nsIDOMElement) node
- .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
- } else if (node.getNodeType() == nsIDOMNode.TEXT_NODE) {
-
- return (nsIDOMElement) node.getParentNode().queryInterface(
- nsIDOMElement.NS_IDOMELEMENT_IID);
-
- }
-
- }
-
- return null;
- }
-
}