Author: estherbin
Date: 2008-07-18 07:02:17 -0400 (Fri, 18 Jul 2008)
New Revision: 9170
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/VpePreviewDomBuilder.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/util/ElService.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/IELService.java
Log:
Restore not worked selection
https://jira.jboss.com:8443/jira/browse/JBIDE-2010
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-07-18
11:02:10 UTC (rev 9169)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2008-07-18
11:02:17 UTC (rev 9170)
@@ -114,6 +114,7 @@
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.css.AbsoluteFolderReferenceList;
import org.jboss.tools.vpe.editor.css.CSSReferenceList;
+import org.jboss.tools.vpe.editor.css.ELReferenceList;
import org.jboss.tools.vpe.editor.css.RelativeFolderReferenceList;
import org.jboss.tools.vpe.editor.css.ResourceReferenceListListener;
import org.jboss.tools.vpe.editor.css.TaglibReferenceList;
@@ -205,6 +206,7 @@
private CSSReferenceList cssReferenceListListener;
private TaglibReferenceList taglibReferenceListListener;
+ private ELReferenceList elReferenceListListener;
private AbsoluteFolderReferenceList absoluteFolderReferenceListListener;
private RelativeFolderReferenceList relativeFolderReferenceListListener;
private VpeIncludeList includeList = new VpeIncludeList();
@@ -338,6 +340,9 @@
relativeFolderReferenceListListener = RelativeFolderReferenceList
.getInstance();
relativeFolderReferenceListListener.addChangeListener(this);
+
+ elReferenceListListener = ELReferenceList.getInstance();
+ elReferenceListListener.addChangeListener(this);
// pageContext.fireTaglibsChanged();
}
@@ -426,6 +431,9 @@
if (absoluteFolderReferenceListListener != null) {
absoluteFolderReferenceListListener.removeChangeListener(this);
}
+ if(elReferenceListListener!=null){
+ elReferenceListListener.removeChangeListener(this);
+ }
if (relativeFolderReferenceListListener != null) {
relativeFolderReferenceListListener.removeChangeListener(this);
}
@@ -2360,7 +2368,8 @@
pageContext.getVisualBuilder().refreshExternalLinks();
} else if (absoluteFolderReferenceListListener == source
|| relativeFolderReferenceListListener == source
- || taglibReferenceListListener == source) {
+ || taglibReferenceListListener == source
+ || elReferenceListListener == source) {
visualRefresh();
}
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpePreviewDomBuilder.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpePreviewDomBuilder.java 2008-07-18
11:02:10 UTC (rev 9169)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpePreviewDomBuilder.java 2008-07-18
11:02:17 UTC (rev 9170)
@@ -24,6 +24,7 @@
import org.jboss.tools.vpe.editor.template.VpeCreationData;
import org.jboss.tools.vpe.editor.template.VpeTemplate;
import org.jboss.tools.vpe.editor.template.VpeTemplateManager;
+import org.jboss.tools.vpe.editor.util.ElService;
import org.jboss.tools.vpe.editor.util.HTML;
import org.jboss.tools.vpe.editor.util.TextUtil;
import org.mozilla.interfaces.nsIDOMElement;
@@ -79,7 +80,7 @@
//FIX FOR JBIDE-1568, added by Max Areshkau
try {
- if (template.getClass().getName().contains("Rich") ||
template.getClass().getName().contains("Jsf")) {
+ if (ElService.getInstance().isCloneableNode(getPageContext(), (Element)
sourceNode)) {
final Element sourceNodeClone = (Element) ((Element)
sourceNode).cloneNode(true);
template.beforeTemplateCreated(getPageContext(), sourceNodeClone,
getVisualDocument());
creationData = template.create(getPageContext(), sourceNodeClone,
getVisualDocument());
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-07-18
11:02:10 UTC (rev 9169)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java 2008-07-18
11:02:17 UTC (rev 9170)
@@ -67,6 +67,7 @@
import org.jboss.tools.vpe.editor.template.VpeTemplateManager;
import org.jboss.tools.vpe.editor.template.VpeToggableTemplate;
import org.jboss.tools.vpe.editor.template.dnd.VpeDnd;
+import org.jboss.tools.vpe.editor.util.ElService;
import org.jboss.tools.vpe.editor.util.FaceletUtil;
import org.jboss.tools.vpe.editor.util.HTML;
import org.jboss.tools.vpe.editor.util.TextUtil;
@@ -436,9 +437,7 @@
//
// }
- if (template.getClass().getName().contains("Rich") ||
template.getClass().getName().contains("Jsf")
- ||
template.getClass().getName().toLowerCase().contains("vpehtmltemplate")
- /*||
template.getClass().getName().toLowerCase().contains("vpecomposition")*/) {
+ if (ElService.getInstance().isCloneableNode(getPageContext(),(Element)
sourceNode)) {
final Element sourceNodeClone = (Element) ((Element)
sourceNode).cloneNode(true);
template.beforeTemplateCreated(getPageContext(), sourceNodeClone,
getVisualDocument());
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ElService.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ElService.java 2008-07-18
11:02:10 UTC (rev 9169)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ElService.java 2008-07-18
11:02:17 UTC (rev 9170)
@@ -1,12 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
-
package org.jboss.tools.vpe.editor.util;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.Assert;
+import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.css.ELReferenceList;
import org.jboss.tools.vpe.editor.css.ResourceReference;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
/**
@@ -35,6 +49,7 @@
}
return rst;
}
+
/**
* Gets the singleton instance.
@@ -90,4 +105,77 @@
return result;
}
+
+ /**
+ * Checks if is cloneable node.
+ *
+ * @param sourceNode the source node
+ * @param pageContext the page context
+ *
+ * @return true, if is cloneable node
+ */
+ public boolean isCloneableNode(VpePageContext pageContext,Element sourceNode) {
+ boolean rst = false;
+ final IFile file =
pageContext.getVisualBuilder().getCurrentIncludeInfo().getFile();
+
+ if(this.isAvailable(file) && this.isAvailableForNode(sourceNode,file)){
+ rst = true;
+ }
+ return rst;
+ }
+
+
+ /**
+ * Checks if is available for node.
+ *
+ * @param resourceFile the resource file
+ * @param sourceNode the source node
+ *
+ * @return true, if is available for node
+ */
+ private boolean isAvailableForNode(Element sourceNode, IFile resourceFile) {
+ boolean rst = false;
+ final NamedNodeMap nodeMap = sourceNode.getAttributes();
+ final ResourceReference[] references =
ELReferenceList.getInstance().getAllResources(resourceFile);
+ String textValue = null;
+ if (sourceNode.getFirstChild() != null &&
sourceNode.getFirstChild().getNodeType() == Node.TEXT_NODE) {
+ textValue = sourceNode.getFirstChild().getNodeValue();
+ }
+ if (textValue != null) {
+ if (isInReferenceResourcesList(references, textValue)) {
+ return true;
+ }
+ }
+ if ((nodeMap != null) && (nodeMap.getLength() > 0)) {
+ for (int i = 0; i < nodeMap.getLength(); i++) {
+ if (isInReferenceResourcesList(references, ((Attr)
nodeMap.item(i)).getValue())) {
+ rst = true;
+ break;
+ }
+ }
+ }
+
+ return rst;
+ }
+
+
+ /**
+ * Checks if is in reference resources list.
+ *
+ * @param value the value
+ * @param references the references
+ *
+ * @return true, if is in reference resources list
+ */
+ private boolean isInReferenceResourcesList(ResourceReference[] references, String
value) {
+ boolean rst = false;
+
+ for (ResourceReference ref : references) {
+ if (value.contains(ref.getLocation())) {
+ rst = true;
+ }
+ }
+ return rst;
+ }
+
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/IELService.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/IELService.java 2008-07-18
11:02:10 UTC (rev 9169)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/IELService.java 2008-07-18
11:02:17 UTC (rev 9170)
@@ -4,14 +4,13 @@
import org.eclipse.core.resources.IFile;
+import org.jboss.tools.vpe.editor.context.VpePageContext;
+import org.w3c.dom.Element;
-// TODO: Auto-generated Javadoc
/**
- * The service that substitute El values in vpe source editor.
- * For more details see issues
- *
http://jira.jboss.com/jira/browse/JBIDE-2010
- * and
+ * The service that substitute El values in vpe source editor. For more details
+ * see issues
http://jira.jboss.com/jira/browse/JBIDE-2010 and
*
http://jira.jboss.com/jira/browse/JBIDE-1410
*
* @author Eugeny Stherbin
@@ -27,8 +26,7 @@
* @return string where el values was substituted.
*/
String replaceEl(IFile resourceFile, String resourceString);
-
-
+
/**
* Checks if is available.
*
@@ -38,4 +36,14 @@
*/
boolean isAvailable(IFile resourceFile);
+ /**
+ * Checks if is cloneable node.
+ *
+ * @param sourceNode the source node
+ * @param pageContext the page context
+ *
+ * @return true, if is cloneable node
+ */
+ public boolean isCloneableNode(VpePageContext pageContext, Element sourceNode);
+
}