Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcbateman2007-08-21 23:33:15 +0000
committercbateman2007-08-21 23:33:15 +0000
commitc2cdd5e1789ff2c4e0126c6c6721a770447053d0 (patch)
treeb0cc534ad7cc9888d5780a100c51eaa64e3c2410
parent3efd21db1aced8e0145b855a6573b744e7257641 (diff)
downloadwebtools.jsf-c2cdd5e1789ff2c4e0126c6c6721a770447053d0.tar.gz
webtools.jsf-c2cdd5e1789ff2c4e0126c6c6721a770447053d0.tar.xz
webtools.jsf-c2cdd5e1789ff2c4e0126c6c6721a770447053d0.zip
Fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=197042. See bug for details.
-rw-r--r--jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/commands/range/SelectAllCommand.java11
-rw-r--r--jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/dom/JSFValidatorSupport.java4
-rw-r--r--jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/validation/caret/JSFRootContainerPositionRule.java32
3 files changed, 34 insertions, 13 deletions
diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/commands/range/SelectAllCommand.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/commands/range/SelectAllCommand.java
index ce6c02078..411801622 100644
--- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/commands/range/SelectAllCommand.java
+++ b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/commands/range/SelectAllCommand.java
@@ -27,13 +27,20 @@ import org.eclipse.jst.pagedesigner.viewer.IHTMLGraphicalViewer;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
+/**
+ * Called in response to a Ctrl-A-style select all action
+ *
+ */
public class SelectAllCommand extends Command {
private IHTMLGraphicalViewer _viewer;
+ /**
+ * @param label
+ * @param viewer
+ */
public SelectAllCommand(String label, IHTMLGraphicalViewer viewer) {
super(label);
_viewer = viewer;
- // TODO Auto-generated constructor stub
}
public void execute() {
@@ -43,7 +50,7 @@ public class SelectAllCommand extends Command {
Node htmlRoot = RootContainerPositionRule
.getBasicContainer((Document) document);
Node jsfRoot = JSFRootContainerPositionRule
- .getBasicContainer((Document) document);
+ .getBasicContainer((Document) document, 3);
Node root;
if (htmlRoot != null && jsfRoot != null) {
if (EditModelQuery.isChild(htmlRoot, jsfRoot)) {
diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/dom/JSFValidatorSupport.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/dom/JSFValidatorSupport.java
index ae6a8247b..cc5c217c7 100644
--- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/dom/JSFValidatorSupport.java
+++ b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/dom/JSFValidatorSupport.java
@@ -34,6 +34,8 @@ public class JSFValidatorSupport {
static private QName _qnameForm = new QName(ITLDConstants.URI_JSF_HTML,
IJSFConstants.TAG_FORM);
+ private static final int MAX_DEPTH_TO_SEARCH_FOR_CONTAINER = 10;
+
// static private QName[] _views = new QName[] { _qnameView,
// new QName(IJMTConstants.URI_JSF_CORE, IJSFConstants.TAG_SUBVIEW) };
@@ -104,7 +106,7 @@ public class JSFValidatorSupport {
//Node view = null;
Document document = EditModelQuery.getDocumentNode(position
.getContainerNode());
- if (JSFRootContainerPositionRule.getBasicContainer(document) == null) {
+ if (!JSFRootContainerPositionRule.hasBasicContainers(document, MAX_DEPTH_TO_SEARCH_FOR_CONTAINER)) {
if (!(IJSFConstants.TAG_VIEW.equals(localname))) {
position = BodyHelper.insertBody(position, _qnameView, "f");
}
diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/validation/caret/JSFRootContainerPositionRule.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/validation/caret/JSFRootContainerPositionRule.java
index 562d6b7df..259d4eab3 100644
--- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/validation/caret/JSFRootContainerPositionRule.java
+++ b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/validation/caret/JSFRootContainerPositionRule.java
@@ -25,6 +25,13 @@ import org.w3c.dom.Node;
* @author mengbo
*/
public class JSFRootContainerPositionRule extends DefaultPositionRule {
+
+ private final static int DEFAULT_MAX_DEPTH_SEARCH = 3;
+
+ /**
+ * TODO: this is not enough because it ignores the uri and keys on only
+ * the name of the tag.
+ */
public static final String[] JSF_ROOT_CONTAINERS = { "view", "subview" };
/**
@@ -43,7 +50,7 @@ public class JSFRootContainerPositionRule extends DefaultPositionRule {
*/
public boolean hasEditableArea(Target target) {
Node node = target.getNode();
- if (hasBasicContainers(EditModelQuery.getDocumentNode(node))) {
+ if (hasBasicContainers(EditModelQuery.getDocumentNode(node),DEFAULT_MAX_DEPTH_SEARCH)) {
ActionData actionData = getActionData();
if (actionData instanceof DropActionData) {
DropActionData dropActionData = (DropActionData) actionData;
@@ -77,7 +84,7 @@ public class JSFRootContainerPositionRule extends DefaultPositionRule {
public boolean isEditable(Target target) {
boolean result = true;
Node node = target.getNode();
- if (hasBasicContainers(EditModelQuery.getDocumentNode(node))) {
+ if (hasBasicContainers(EditModelQuery.getDocumentNode(node), DEFAULT_MAX_DEPTH_SEARCH)) {
ActionData actionData = getActionData();
if (actionData instanceof DropActionData) {
DropActionData dropActionData = (DropActionData) actionData;
@@ -99,12 +106,15 @@ public class JSFRootContainerPositionRule extends DefaultPositionRule {
return super.isEditable(target);
}
- public static boolean isWithinkBasicContainer(Node node) {
- return EditModelQuery.isChild(JSF_ROOT_CONTAINERS, node, false, false);
- }
- public static Node getBasicContainer(Document document) {
- Node node = EditModelQuery.getChild(document, JSF_ROOT_CONTAINERS, 3,
+ /**
+ * @param document
+ * @param maxDepth
+ * @return the closest tag called "view" or "subview" to the root of document
+ * search to a maximum tag depth of maxDepth
+ */
+ public static Node getBasicContainer(Document document, int maxDepth) {
+ Node node = EditModelQuery.getChild(document, JSF_ROOT_CONTAINERS, maxDepth,
false);
return node;
}
@@ -114,10 +124,12 @@ public class JSFRootContainerPositionRule extends DefaultPositionRule {
* second level.
*
* @param document
- * @return
+ * @param maxDepth
+ * @return true if document has a view and subview limited to a maximum search
+ * depth of maxDepth
*/
- public static boolean hasBasicContainers(Document document) {
- return getBasicContainer(document) != null;
+ public static boolean hasBasicContainers(Document document, int maxDepth) {
+ return getBasicContainer(document, maxDepth) != null;
}
/*

Back to the top