#118287 Fixing selection of drop down inside layout panel. cnd6_asm_root
authorpzavadsky@netbeans.org
Wed, 10 Oct 2007 01:02:19 +0000
changeset 172978ec9d812d3c
parent 1728 aefaca52c9f8
child 1730 87bf2e167551
#118287 Fixing selection of drop down inside layout panel.
visualweb.designer/src/org/netbeans/modules/visualweb/css2/LineBoxGroup.java
visualweb.designer/src/org/netbeans/modules/visualweb/css2/ModelViewMapper.java
     1.1 --- a/visualweb.designer/src/org/netbeans/modules/visualweb/css2/LineBoxGroup.java	Tue Oct 09 22:59:04 2007 +0000
     1.2 +++ b/visualweb.designer/src/org/netbeans/modules/visualweb/css2/LineBoxGroup.java	Wed Oct 10 01:02:19 2007 +0000
     1.3 @@ -1188,7 +1188,8 @@
     1.4                      // multiple separate segments for different live beans? If so
     1.5                      // I guess I should only join rectangles for -contiguous-
     1.6                      // sections of boxes
     1.7 -                    if (hasComponentAncestor(leaf, componentRootElement)) {
     1.8 +                    Element element = leaf == null ? null : leaf.getElement();
     1.9 +                    if (isParentElementOf(componentRootElement, element) || hasComponentAncestor(leaf, componentRootElement)) {
    1.10                          // Yessss
    1.11                          Rectangle r =
    1.12                              new Rectangle(leaf.getAbsoluteX(), leaf.getAbsoluteY(),
    1.13 @@ -1274,7 +1275,8 @@
    1.14                  for (int j = 0, m = lb.getBoxCount(); j < m; j++) {
    1.15                      CssBox leaf = lb.getBox(j);
    1.16  
    1.17 -                    if (hasComponentAncestor(leaf, componentRootElement)) {
    1.18 +                    Element element = leaf == null ? null : leaf.getElement();
    1.19 +                    if (isParentElementOf(componentRootElement, element) || hasComponentAncestor(leaf, componentRootElement)) {
    1.20                          // Yessss
    1.21                          Rectangle r =
    1.22                              new Rectangle(leaf.getAbsoluteX(), leaf.getAbsoluteY(),
    1.23 @@ -1338,6 +1340,22 @@
    1.24  
    1.25          return false;
    1.26      }
    1.27 +    
    1.28 +    // XXX #118287 Also when the root box is not part of the tree (see also #107084).
    1.29 +    private static boolean isParentElementOf(Element parentElement, Element element) {
    1.30 +        if (parentElement == null || element == null) {
    1.31 +            return false;
    1.32 +        }
    1.33 +        
    1.34 +        Node node = element;
    1.35 +        while (node != null) {
    1.36 +            if (node == parentElement) {
    1.37 +                return true;
    1.38 +            }
    1.39 +            node = node.getParentNode();
    1.40 +        }
    1.41 +        return false;
    1.42 +    }
    1.43  
    1.44      /** FOR TESTSUITE ONLY! */
    1.45      public BoxList getManagedBoxes() {
     2.1 --- a/visualweb.designer/src/org/netbeans/modules/visualweb/css2/ModelViewMapper.java	Tue Oct 09 22:59:04 2007 +0000
     2.2 +++ b/visualweb.designer/src/org/netbeans/modules/visualweb/css2/ModelViewMapper.java	Wed Oct 10 01:02:19 2007 +0000
     2.3 @@ -2828,7 +2828,11 @@
     2.4              // XXX #113773 Fixing selecting of some element whose parent box 
     2.5              // is excluded from the hierarchy (suspicous architecture).
     2.6              Element element = box.getElement();
     2.7 -            if (WebForm.getDomProviderService().isPrincipalElement(element, null)) {
     2.8 +            // XXX #118287 Also pass the parent box to determine the principal element
     2.9 +            // (the real one might be excluded from the tree)
    2.10 +            CssBox parentBox = box.getParent();
    2.11 +            Element parentElement = parentBox == null ? null : parentBox.getElement();
    2.12 +            if (WebForm.getDomProviderService().isPrincipalElement(element, parentElement)) {
    2.13                  if (WebForm.getDomProviderService().isSpecialComponent(element)) {
    2.14                      continue;
    2.15                  }