Пример #1
0
  private LayoutConstraints<?>[] removeLayoutDelegate(boolean extractConstraints) {
    int componentCount = layoutDelegate.getComponentCount();
    LayoutConstraints<?>[] constraints = null;

    if (componentCount > 0) {
      RADVisualComponent<?>[] radComps = radContainer.getSubComponents();
      if (radComps.length
          == componentCount) { // robustness: might be called after failed layout initialization
        if (extractConstraints) {
          constraints = new LayoutConstraints<?>[componentCount];
        }

        for (int i = 0; i < componentCount; i++) {
          LayoutConstraints<?> constr = layoutDelegate.getConstraints(i);
          if (extractConstraints) {
            constraints[i] = constr;
          }
          if (constr != null) {
            radComps[i].setLayoutConstraints(layoutDelegate.getClass(), constr);
          }
        }
      }
    }
    layoutDelegate.removeAll();
    layoutDelegate.clearContainer(getPrimaryContainer(), getPrimaryContainerDelegate());
    layoutDelegate = null;
    return constraints;
  }
Пример #2
0
 // components adding/removing
 public void injectComponents(
     RADVisualComponent<?>[] components, LayoutConstraints<?>[] aConstraints, int index) {
   if (index <= -1) {
     index = layoutDelegate.getComponentCount();
   }
   layoutDelegate.addComponents(components, aConstraints, index);
   for (RADVisualComponent<?> component : components) {
     component.resetConstraintsProperties();
   }
 }
Пример #3
0
 public LayoutConstraints<?> getConstraints(RADVisualComponent<?> radComp) {
   if (layoutDelegate != null) {
     int index = radComp.getComponentIndex(); // radContainer.getIndexOf(radComp);
     return index >= 0 && index < layoutDelegate.getComponentCount()
         ? layoutDelegate.getConstraints(index)
         : null;
   } else {
     return null;
   }
 }
Пример #4
0
  public void addComponents(
      RADVisualComponent<?>[] components, LayoutConstraints<?>[] aConstraints, int index) {
    if (index <= -1) {
      index = layoutDelegate.getComponentCount();
    }
    injectComponents(components, aConstraints, index);

    Component[] comps = new Component[components.length];
    for (int i = 0; i < components.length; i++) {
      comps[i] = components[i].getBeanInstance();
    }
    layoutDelegate.addComponentsToContainer(
        getPrimaryContainer(), getPrimaryContainerDelegate(), comps, index);
  }
Пример #5
0
 public void removeAll() {
   // first store constraints in meta components
   RADVisualComponent<?>[] components = radContainer.getSubComponents();
   for (int i = 0; i < components.length; i++) {
     LayoutConstraints<?> constr = layoutDelegate.getConstraints(i);
     if (constr != null) {
       components[i].setLayoutConstraints(layoutDelegate.getClass(), constr);
     }
   }
   // remove components from layout
   layoutDelegate.removeAll();
   // clear the primary container instance
   layoutDelegate.clearContainer(getPrimaryContainer(), getPrimaryContainerDelegate());
 }
Пример #6
0
  public boolean isLayoutChanged() {
    Container defaultContainer =
        (Container) BeanSupport.getDefaultInstance(radContainer.getBeanClass());
    Container defaultContDelegate = radContainer.getContainerDelegate(defaultContainer);

    return layoutDelegate.isLayoutChanged(defaultContainer, defaultContDelegate);
  }
Пример #7
0
  public void setLayoutDelegate(LayoutSupportDelegate newDelegate /*,
     boolean fromCode*/) throws Exception {
    LayoutConstraints<?>[] oldConstraints;
    LayoutSupportDelegate oldDelegate = layoutDelegate;

    if (layoutDelegate != null && (layoutDelegate != newDelegate /* || !fromCode*/)) {
      oldConstraints = removeLayoutDelegate(true);
    } else {
      oldConstraints = null;
    }

    layoutDelegate = newDelegate;
    propertySets = null;
    needInit = false;

    if (layoutDelegate != null) {
      try {
        layoutDelegate.initialize(this, null);
        fillLayout(oldConstraints);
        getPropertySets(); // force properties and listeners creation
      } catch (Exception ex) {
        removeLayoutDelegate(false);
        layoutDelegate = oldDelegate;
        if (layoutDelegate != null) {
          fillLayout(null);
        }
        throw ex;
      }
    }
  }
Пример #8
0
  @Override
  public void componentLayoutChanged(int index, PropertyChangeEvent ev)
      throws PropertyVetoException {
    RADVisualComponent<?> radComp = radContainer.getSubComponent(index);

    if (ev != null && ev.getPropertyName() != null) {
      layoutDelegate.acceptComponentLayoutChange(index, ev);

      FormModel formModel = radContainer.getFormModel();
      formModel.fireComponentLayoutChanged(
          radComp, ev.getPropertyName(), ev.getOldValue(), ev.getNewValue());

      if (radComp.getNodeReference() != null) // propagate the change to node
      {
        radComp
            .getNodeReference()
            .firePropertyChangeHelper(ev.getPropertyName(), ev.getOldValue(), ev.getNewValue());
      }
    } else {
      if (radComp.getNodeReference() != null) // propagate the change to node
      {
        radComp.getNodeReference().fireComponentPropertySetsChange();
      }
      radComp.resetConstraintsProperties();
    }
  }
Пример #9
0
  @Override
  public void updatePrimaryContainer() {
    Container cont = getPrimaryContainer();
    Container contDel = getPrimaryContainerDelegate();

    layoutDelegate.clearContainer(cont, contDel);
    layoutDelegate.setLayoutToContainer(cont, contDel);

    RADVisualComponent<?>[] components = radContainer.getSubComponents();
    if (components.length > 0) {
      Component[] comps = new Component[components.length];
      for (int i = 0; i < components.length; i++) {
        comps[i] = (Component) components[i].getBeanInstance();
      }
      layoutDelegate.addComponentsToContainer(cont, contDel, comps, 0);
    }
  }
Пример #10
0
  // copy layout delegate from another container
  public void copyLayoutDelegateFrom(
      LayoutSupportManager sourceLayoutSupport, RADVisualComponent<?>[] newRadComps) {
    LayoutSupportDelegate sourceDelegate = sourceLayoutSupport.getLayoutDelegate();

    int componentCount = sourceDelegate.getComponentCount();

    Container cont = getPrimaryContainer();
    Container contDel = getPrimaryContainerDelegate();

    if (layoutDelegate != null) {
      removeLayoutDelegate(false);
    }

    Component[] primaryComps = new Component[componentCount];

    for (int i = 0; i < componentCount; i++) {
      RADVisualComponent<?> radComp = newRadComps[i];
      primaryComps[i] = (Component) radComp.getBeanInstance();
    }

    LayoutSupportDelegate newDelegate = sourceDelegate.cloneLayoutSupport(this, newRadComps);

    newDelegate.setLayoutToContainer(cont, contDel);
    newDelegate.addComponentsToContainer(cont, contDel, primaryComps, 0);

    layoutDelegate = newDelegate;

    // Ensure correct propagation of copied properties (issue 50011, 72351)
    try {
      layoutDelegate.acceptContainerLayoutChange(null);
    } catch (PropertyVetoException pvex) {
      // should not happen
    }
  }
Пример #11
0
 public void initializeLayoutDelegate() throws Exception {
   if (layoutDelegate != null && needInit) {
     LayoutManager lmInstance =
         initializeFromInstance ? getPrimaryContainerDelegate().getLayout() : null;
     layoutDelegate.initialize(this, lmInstance); // , initializeFromCode);
     fillLayout(null);
     getPropertySets(); // force properties and listeners creation
     needInit = false;
   }
 }
Пример #12
0
 public boolean paintDragFeedback(
     Container container,
     Container containerDelegate,
     Component component,
     LayoutConstraints<?> newConstraints,
     int newIndex,
     Graphics g) {
   return layoutDelegate.paintDragFeedback(
       container, containerDelegate, component, newConstraints, newIndex, g);
 }
Пример #13
0
 public int getNewIndex(
     Container container,
     Container containerDelegate,
     Component component,
     int index,
     Point posInCont,
     Point posInComp) {
   return layoutDelegate.getNewIndex(
       container, containerDelegate, component, index, posInCont, posInComp);
 }
Пример #14
0
 public LayoutConstraints<?> getResizedConstraints(
     Container container,
     Container containerDelegate,
     Component component,
     int index,
     Rectangle originalBounds,
     Insets sizeChanges,
     Point posInCont) {
   return layoutDelegate.getResizedConstraints(
       container, containerDelegate, component, index, originalBounds, sizeChanges, posInCont);
 }
Пример #15
0
  public void removeComponent(RADVisualComponent<?> radComp, int index) {
    // first store constraints in the meta component
    LayoutConstraints<?> constr = layoutDelegate.getConstraints(index);
    if (constr != null) {
      radComp.setLayoutConstraints(layoutDelegate.getClass(), constr);
    }
    // remove the component from layout
    layoutDelegate.removeComponent(index);
    // remove the component instance from the primary container instance
    if (!layoutDelegate.removeComponentFromContainer(
        getPrimaryContainer(),
        getPrimaryContainerDelegate(),
        (Component)
            radComp
                .getBeanInstance())) { // layout delegate does not support removing individual
                                       // components,
      // so we clear the container and add the remaining components again
      layoutDelegate.clearContainer(getPrimaryContainer(), getPrimaryContainerDelegate());

      RADVisualComponent<?>[] radComps = radContainer.getSubComponents();
      if (radComps.length > 1) {
        // we rely on that radcomp was not removed from the model yet
        Component[] comps = new Component[radComps.length - 1];
        for (int i = 0; i < radComps.length; i++) {
          if (i != index) {
            Component comp = (Component) radComps[i].getBeanInstance();
            comps[i < index ? i : i - 1] = comp;
          }
        }
        layoutDelegate.addComponentsToContainer(
            getPrimaryContainer(), getPrimaryContainerDelegate(), comps, 0);
      }
    }
  }
Пример #16
0
  private void fillLayout(LayoutConstraints<?>[] oldConstraints) {
    RADVisualComponent<?>[] radComps = radContainer.getSubComponents();
    int componentCount = radComps.length;
    Component[] primaryComps = new Component[componentCount];
    LayoutConstraints<?>[] newConstraints = new LayoutConstraints<?>[componentCount];

    for (int i = 0; i < componentCount; i++) {
      primaryComps[i] = radComps[i].getBeanInstance();
      newConstraints[i] = radComps[i].getLayoutConstraints(layoutDelegate.getClass());
    }

    layoutDelegate.convertConstraints(oldConstraints, newConstraints, primaryComps);

    if (componentCount > 0) {
      layoutDelegate.acceptNewComponents(radComps, newConstraints, 0);
      layoutDelegate.addComponents(radComps, newConstraints, 0);

      for (int i = 0; i < componentCount; i++) {
        radComps[i].resetConstraintsProperties();
      }
    }

    // setup primary container
    Container cont = getPrimaryContainer();
    Container contDel = getPrimaryContainerDelegate();
    layoutDelegate.setLayoutToContainer(cont, contDel);
    if (componentCount > 0) {
      layoutDelegate.addComponentsToContainer(cont, contDel, primaryComps, 0);
    }
  }
Пример #17
0
  // properties and customizer
  public Node.PropertySet[] getPropertySets() {
    if (propertySets == null) {
      if (layoutDelegate == null) {
        return new Node.PropertySet[0]; // Issue 63916
      }
      propertySets = layoutDelegate.getPropertySets();

      for (Node.PropertySet propertySet : propertySets) {
        FormProperty<?>[] props = (FormProperty<?>[]) propertySet.getProperties();
        for (FormProperty<?> prop : props) {
          prop.addVetoableChangeListener(getLayoutListener());
          prop.addPropertyChangeListener(getLayoutListener());
        }
      }
    }
    return propertySets;
  }
Пример #18
0
  @Override
  public void containerLayoutChanged(PropertyChangeEvent ev) throws PropertyVetoException {
    if (ev != null && ev.getPropertyName() != null) {
      layoutDelegate.acceptContainerLayoutChange(ev);

      FormModel formModel = radContainer.getFormModel();
      formModel.fireContainerLayoutChanged(
          radContainer, ev.getPropertyName(), ev.getOldValue(), ev.getNewValue());
    } else {
      propertySets = null;
    }

    LayoutNode node = radContainer.getLayoutNodeReference();
    if (node != null) {
      // propagate the change to node
      if (ev != null && ev.getPropertyName() != null) {
        node.fireLayoutPropertiesChange();
      } else {
        node.fireLayoutPropertySetsChange();
      }
    }
  }
Пример #19
0
  // drag and drop support
  public LayoutConstraints<?> getNewConstraints(
      Container container,
      Container containerDelegate,
      Component component,
      int index,
      Point posInCont,
      Point posInComp) {

    LayoutConstraints<?> constraints =
        layoutDelegate.getNewConstraints(
            container, containerDelegate, component, index, posInCont, posInComp);
    String context = null;
    Object[] params = null;
    if (layoutDelegate instanceof AbstractLayoutSupport) {
      AbstractLayoutSupport support = (AbstractLayoutSupport) layoutDelegate;
      context = support.getAssistantContext();
      params = support.getAssistantParams();
    }
    context = (context == null) ? "generalPosition" : context; // NOI18N
    radContainer.getFormModel().getAssistantModel().setContext(context, params);
    return constraints;
  }
Пример #20
0
 // managing live components
 public void setLayoutToContainer(Container container, Container containerDelegate) {
   layoutDelegate.setLayoutToContainer(container, containerDelegate);
 }
Пример #21
0
 // arranging support
 public void arrangeContainer(Container container, Container containerDelegate) {
   layoutDelegate.arrangeContainer(container, containerDelegate);
 }
Пример #22
0
 // arranging support
 public void selectComponent(int index) {
   layoutDelegate.selectComponent(index);
 }
Пример #23
0
 // arranging support
 public void processMouseClick(Point p, Container cont, Container contDelegate) {
   layoutDelegate.processMouseClick(p, cont, contDelegate);
 }
Пример #24
0
 // data validation
 public void acceptNewComponents(
     RADVisualComponent<?>[] components, LayoutConstraints<?>[] constraints, int index) {
   layoutDelegate.acceptNewComponents(components, constraints, index);
 }
Пример #25
0
 // resizing support
 public int getResizableDirections(
     Container container, Container containerDelegate, Component component, int index) {
   return layoutDelegate.getResizableDirections(container, containerDelegate, component, index);
 }
Пример #26
0
 public LayoutConstraints<?> getStoredConstraints(RADVisualComponent<?> radComp) {
   return radComp.getLayoutConstraints(layoutDelegate.getClass());
 }
Пример #27
0
 // managing constraints
 public LayoutConstraints<?> getConstraints(int index) {
   return layoutDelegate.getConstraints(index);
 }
Пример #28
0
 public boolean clearContainer(Container container, Container containerDelegate) {
   return layoutDelegate.clearContainer(container, containerDelegate);
 }
Пример #29
0
 public boolean removeComponentFromContainer(
     Container container, Container containerDelegate, Component component) {
   return layoutDelegate.removeComponentFromContainer(container, containerDelegate, component);
 }
Пример #30
0
 public void addComponentsToContainer(
     Container container, Container containerDelegate, Component[] components, int index) {
   layoutDelegate.addComponentsToContainer(container, containerDelegate, components, index);
 }