Author: mareshkau
Date: 2009-06-25 09:13:37 -0400 (Thu, 25 Jun 2009)
New Revision: 16202
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/menu/MenuCreationHelper.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/action/EditAttributesAction.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/selection/VpeSourceSelectionBuilder.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeDefineContainerTemplate.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeLabeledFormCreator.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeListCreator.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/resize/VpeResizer.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeStyleUtil.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4526, fixing copy past
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 2009-06-25
11:39:30 UTC (rev 16201)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualKeyHandler.java 2009-06-25
13:13:37 UTC (rev 16202)
@@ -676,24 +676,11 @@
}
if (focusNodeOffset > 0) {
focusNodeOffset--;
- return getSourceNodeAt(focusNodeOffset);
+ return VpeSourceSelectionBuilder.getSourceNodeAt(this.sourceEditor,focusNodeOffset);
}
}
return null;
}
-
- private Node getSourceNodeAt(int offset) {
- if (sourceEditor != null && sourceEditor.getModel() != null) {
- IndexedRegion node = sourceEditor.getModel().getIndexedRegion(offset);
- if (node == null) {
- node = sourceEditor.getModel().getIndexedRegion(offset - 1);
- }
- if (node instanceof Node) {
- return (Node) node;
- }
- }
- return null;
- }
private VpeSourceSelection deleteLeftChar(VpeSourceSelectionBuilder
sourceSelectionBuilder, VpeSourceSelection selection) {
boolean atLeastOneCharIsDeleted = false;
@@ -1150,8 +1137,8 @@
if (focusNode.getNodeType() == Node.TEXT_NODE) {
if (focusNode.getParentNode().getNodeType() == Node.DOCUMENT_NODE) {
Point range = sourceEditor.getTextViewer().getSelectedRange();
- Node p1 = focusNode.getOwnerDocument().createElement("p");
- Node p2 = focusNode.getOwnerDocument().createElement("p");
+ Node p1 = focusNode.getOwnerDocument().createElement(HTML.TAG_P);
+ Node p2 = focusNode.getOwnerDocument().createElement(HTML.TAG_P);
Text newNode = ((Text)focusNode).splitText(getSourceNodeOffset(focusNode,
range.x));
focusNode.getParentNode().insertBefore(p1, focusNode);
focusNode.getParentNode().insertBefore(p2, newNode);
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/MenuCreationHelper.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/MenuCreationHelper.java 2009-06-25
11:39:30 UTC (rev 16201)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/MenuCreationHelper.java 2009-06-25
13:13:37 UTC (rev 16202)
@@ -41,6 +41,7 @@
import org.jboss.tools.vpe.editor.mapping.VpeElementMapping;
import org.jboss.tools.vpe.editor.mapping.VpeNodeMapping;
import org.jboss.tools.vpe.editor.menu.BaseActionManager.MyMenuManager;
+import org.jboss.tools.vpe.editor.menu.action.EditAttributesAction;
import org.jboss.tools.vpe.editor.menu.action.InsertAction;
import org.jboss.tools.vpe.editor.menu.action.VpeMenuListener;
import org.jboss.tools.vpe.editor.menu.action.VpeTextOperationAction;
@@ -393,39 +394,12 @@
* @param node the Node object
*/
private void showProperties(Node node) {
- ExtendedProperties p = createExtendedProperties(node);
+ ExtendedProperties p = EditAttributesAction.createExtendedProperties(node);
if (p != null) {
ExtendedPropertiesWizard.run(p);
}
}
- /**
- * Create extended properties list for the node passed by parameter.
- *
- * @param node the Node to be processed
- * @return an extended properties
- */
- private ExtendedProperties createExtendedProperties(Node node) {
- Class c = ModelFeatureFactory.getInstance().getFeatureClass(
- "org.jboss.tools.jst.jsp.outline.VpeProperties"); //$NON-NLS-1$
- try {
- return (ExtendedProperties) c.getDeclaredConstructor(
- new Class[] { Node.class }).newInstance(new Object[] { node });
- } catch (IllegalArgumentException e) {
- VpePlugin.getPluginLog().logError(e);
- } catch (SecurityException e) {
- VpePlugin.getPluginLog().logError(e);
- } catch (InstantiationException e) {
- VpePlugin.getPluginLog().logError(e);
- } catch (IllegalAccessException e) {
- VpePlugin.getPluginLog().logError(e);
- } catch (InvocationTargetException e) {
- VpePlugin.getPluginLog().logError(e);
- } catch (NoSuchMethodException e) {
- VpePlugin.getPluginLog().logError(e);
- }
- return null;
- }
/**
* Method is used to print dump mapping.
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/action/EditAttributesAction.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/action/EditAttributesAction.java 2009-06-25
11:39:30 UTC (rev 16201)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/action/EditAttributesAction.java 2009-06-25
13:13:37 UTC (rev 16202)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.vpe.editor.menu.action;
+import java.awt.Menu;
import java.lang.reflect.InvocationTargetException;
import java.text.MessageFormat;
@@ -20,6 +21,7 @@
import org.jboss.tools.vpe.VpePlugin;
import org.jboss.tools.vpe.editor.mapping.VpeDomMapping;
import org.jboss.tools.vpe.editor.mapping.VpeElementMapping;
+import org.jboss.tools.vpe.editor.menu.MenuCreationHelper;
import org.jboss.tools.vpe.editor.menu.VpeMenuUtil;
import org.jboss.tools.vpe.messages.VpeUIMessages;
import org.w3c.dom.Node;
@@ -80,7 +82,7 @@
* @param node the Node object
*/
private void showProperties(Node node) {
- ExtendedProperties p = createExtendedProperties(node);
+ ExtendedProperties p = EditAttributesAction.createExtendedProperties(node);
if (p != null) {
ExtendedPropertiesWizard.run(p);
}
@@ -92,7 +94,7 @@
* @param node the Node to be processed
* @return an extended properties
*/
- private ExtendedProperties createExtendedProperties(Node node) {
+ public static ExtendedProperties createExtendedProperties(Node node) {
final Class<?> c = ModelFeatureFactory.getInstance().getFeatureClass(
"org.jboss.tools.jst.jsp.outline.VpeProperties"); //$NON-NLS-1$
try {
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/selection/VpeSourceSelectionBuilder.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/selection/VpeSourceSelectionBuilder.java 2009-06-25
11:39:30 UTC (rev 16201)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/selection/VpeSourceSelectionBuilder.java 2009-06-25
13:13:37 UTC (rev 16202)
@@ -42,7 +42,7 @@
anchorPosition = focusPosition;
focusPosition = range.x;
}
- Node focusNode = getSourceNodeAt(focusPosition);
+ Node focusNode = getSourceNodeAt(this.sourceEditor,focusPosition);
if (focusNode == null) {
return null;
}
@@ -51,7 +51,7 @@
Node anchorNode = null;
int anchorOffset = 0;
if (extendFlag) {
- anchorNode = getSourceNodeAt(anchorPosition);
+ anchorNode = getSourceNodeAt(this.sourceEditor,anchorPosition);
anchorOffset = getSourceNodeOffset(anchorNode, anchorPosition, reversionFlag);
} else {
anchorNode = focusNode;
@@ -105,11 +105,11 @@
return selection;
}
- private Node getSourceNodeAt(int offset) {
- if (sourceEditor != null && sourceEditor.getModel() != null) {
- IndexedRegion node = sourceEditor.getModel().getIndexedRegion(offset);
+ public static Node getSourceNodeAt(StructuredTextEditor srcEditor,int offset) {
+ if (srcEditor != null && srcEditor.getModel() != null) {
+ IndexedRegion node = srcEditor.getModel().getIndexedRegion(offset);
if (node == null) {
- node = sourceEditor.getModel().getIndexedRegion(offset - 1);
+ node = srcEditor.getModel().getIndexedRegion(offset - 1);
}
if (node instanceof Node) {
return (Node) node;
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeDefineContainerTemplate.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeDefineContainerTemplate.java 2009-06-25
11:39:30 UTC (rev 16201)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeDefineContainerTemplate.java 2009-06-25
13:13:37 UTC (rev 16202)
@@ -16,19 +16,11 @@
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-
import org.eclipse.core.resources.IFile;
import org.jboss.tools.vpe.editor.VpeIncludeInfo;
import org.jboss.tools.vpe.editor.VpeVisualDomBuilder;
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.mapping.VpeElementMapping;
-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.template.VpeCreatorUtil;
-import org.jboss.tools.vpe.editor.template.VpeTemplate;
-import org.jboss.tools.vpe.editor.template.VpeTemplateManager;
-import org.jboss.tools.vpe.editor.util.FileUtil;
import org.jboss.tools.vpe.editor.util.HTML;
import org.mozilla.interfaces.nsIDOMDocument;
import org.mozilla.interfaces.nsIDOMElement;
@@ -337,15 +329,6 @@
}
-// @Override
-// public void openIncludeEditor(VpePageContext pageContext,
-// Element sourceElement, Object data) {
-//
-// if (data instanceof TemplateFileInfo) {
-// FileUtil.openEditor(((TemplateFileInfo) data).getTemplateFile());
-// }
-// }
-
protected VpeCreationData createStub(String fileName,
Node sourceElement, nsIDOMDocument visualDocument) {
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeLabeledFormCreator.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeLabeledFormCreator.java 2009-06-25
11:39:30 UTC (rev 16201)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeLabeledFormCreator.java 2009-06-25
13:13:37 UTC (rev 16202)
@@ -79,6 +79,7 @@
}
}
+ @Override
public VpeCreatorInfo create(VpePageContext pageContext, Node sourceNode, nsIDOMDocument
visualDocument, nsIDOMElement visualElement, Map visualNodeMap) throws
VpeExpressionException {
String labelAttrName = VpeTemplateManager.ATTR_LABELED_FORM_DEFAULT_LABEL;
if (labelNameExpr != null) {
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeListCreator.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeListCreator.java 2009-06-25
11:39:30 UTC (rev 16201)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeListCreator.java 2009-06-25
13:13:37 UTC (rev 16202)
@@ -79,6 +79,7 @@
}
}
+ @Override
public VpeCreatorInfo create(VpePageContext pageContext, Node sourceNode, nsIDOMDocument
visualDocument, nsIDOMElement visualElement, Map visualNodeMap) throws
VpeExpressionException {
String strValue=null;
int listSize = 0;
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/resize/VpeResizer.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/resize/VpeResizer.java 2009-06-25
11:39:30 UTC (rev 16201)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/resize/VpeResizer.java 2009-06-25
13:13:37 UTC (rev 16202)
@@ -166,10 +166,10 @@
String positionAttribute = resizeData.getPositionAttribute();
if(absolute && resizeData.isAbsolutePositionEnabled()){
VpeStyleUtil.setAbsolute(sourceElement);
- VpeStyleUtil.setSizeInStyle(sourceElement,
VpeStyleUtil.ATTRIBUTE_STYLE+VpeStyleUtil.DOT_STRING+positionAttribute, position);
+ VpeStyleUtil.setParameterInStyle(sourceElement,
VpeStyleUtil.ATTRIBUTE_STYLE+VpeStyleUtil.DOT_STRING+positionAttribute,
position+VpeStyleUtil.PX_STRING);
}else{
if(VpeStyleUtil.getAbsolute(sourceElement)){
- VpeStyleUtil.setSizeInStyle(sourceElement,
VpeStyleUtil.ATTRIBUTE_STYLE+VpeStyleUtil.DOT_STRING+positionAttribute, position);
+ VpeStyleUtil.setParameterInStyle(sourceElement,
VpeStyleUtil.ATTRIBUTE_STYLE+VpeStyleUtil.DOT_STRING+positionAttribute,
position+VpeStyleUtil.PX_STRING);
}
}
if(resizeData.getTagXpath() != null){
@@ -178,14 +178,14 @@
if(sizeAttribute.indexOf(VpeStyleUtil.DOT_STRING) < 0){
ancestor.setAttribute(sizeAttribute, ""+size);
}else{
- VpeStyleUtil.setSizeInStyle(ancestor, sizeAttribute, size);
+ VpeStyleUtil.setParameterInStyle(ancestor, sizeAttribute,
size+VpeStyleUtil.PX_STRING);
}
}
}else{
if(sizeAttribute.indexOf(VpeStyleUtil.DOT_STRING) < 0){
sourceElement.setAttribute(sizeAttribute, ""+size);
}else{
- VpeStyleUtil.setSizeInStyle(sourceElement, sizeAttribute, size);
+ VpeStyleUtil.setParameterInStyle(sourceElement, sizeAttribute,
size+VpeStyleUtil.PX_STRING);
}
}
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeStyleUtil.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeStyleUtil.java 2009-06-25
11:39:30 UTC (rev 16201)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeStyleUtil.java 2009-06-25
13:13:37 UTC (rev 16202)
@@ -226,32 +226,6 @@
// sets value of parameter described in sizeAttribute, for example
// "style.width"
- public static void setSizeInStyle(Element sourceElement,
- String sizeAttribute, int size) {
- int dotPosition = sizeAttribute.indexOf(DOT_STRING);
- String attribute = sizeAttribute.substring(0, dotPosition);
- String parameter = sizeAttribute.substring(dotPosition + 1,
- sizeAttribute.length());
-
- String style = sourceElement.getAttribute(attribute);
- if (style == null) {
- style = EMPTY_STRING;
- } else { // remove old sizes
- style = deleteFromString(style, parameter, SEMICOLON_STRING);
- }
- if (style.length() > 0) {
- if (!style.endsWith(SEMICOLON_STRING))
- style += SEMICOLON_STRING;
- }
-
- style += SPACE_STRING + parameter + SPACE_STRING + COLON_STRING
- + SPACE_STRING + size + PX_STRING + SEMICOLON_STRING;
-
- sourceElement.setAttribute(attribute, style);
- }
-
- // sets value of parameter described in sizeAttribute, for example
- // "style.width"
public static void setParameterInStyle(Element sourceElement,
String sizeAttribute, String value) {
int dotPosition = sizeAttribute.indexOf(DOT_STRING);
@@ -401,22 +375,6 @@
String filePath = urls[i].substring(startPathIndex + 1,
endPathIndex);
-// if (filePath.indexOf(FILE_PROTOCOL) != -1) {
-// continue;
-// }
-//
-// if (!new File(filePath).isAbsolute()) {
-// filePath = getFilePath(input, filePath);
-// }
-//
-// filePath = FILE_PROTOCOL + SLASH + SLASH + filePath.replace('\\',
'/');
-// URL url = null;
-// try {
-// url = new URL(filePath);
-// } catch (MalformedURLException e) {
-// continue;
-// }
-// filePath = url.toString();
IFile file = null;
if (pageContext.getVisualBuilder().getCurrentIncludeInfo() != null)