@Override
 protected void updateConstraints(RadComponent component) {
   GridLayoutManager layout = (GridLayoutManager) component.getParent().getLayout();
   final GridConstraints radConstraints = component.getConstraints();
   final GridConstraints delegeeConstraints =
       layout.getConstraintsForComponent(component.getDelegee());
   if (radConstraints != delegeeConstraints) {
     delegeeConstraints.restore(radConstraints);
   }
   super.updateConstraints(component);
 }
  public static void paintComponentDecoration(
      final GuiEditor editor, final RadComponent component, final Graphics g) {
    // Collect selected components and paint decoration for non selected components
    final ArrayList<RadComponent> selection = new ArrayList<RadComponent>();
    final Rectangle layeredPaneRect = editor.getLayeredPane().getVisibleRect();
    FormEditingUtil.iterate(
        component,
        new FormEditingUtil.ComponentVisitor<RadComponent>() {
          public boolean visit(final RadComponent component) {
            if (!component.getDelegee().isShowing()) { // Skip invisible components
              return true;
            }
            final Shape oldClip = g.getClip();
            final RadContainer parent = component.getParent();
            if (parent != null) {
              final Point p =
                  SwingUtilities.convertPoint(
                      component.getDelegee(), 0, 0, editor.getLayeredPane());
              final Rectangle visibleRect =
                  layeredPaneRect.intersection(
                      new Rectangle(p.x, p.y, parent.getWidth(), parent.getHeight()));
              g.setClip(visibleRect);
            }
            if (component.isSelected()) { // we will paint selection later
              selection.add(component);
            } else {
              paintComponentBoundsImpl(editor, component, g);
            }
            paintGridOutline(editor, component, g);
            if (parent != null) {
              g.setClip(oldClip);
            }
            return true;
          }
        });

    // Let's paint decoration for selected components
    for (int i = selection.size() - 1; i >= 0; i--) {
      final Shape oldClip = g.getClip();
      final RadComponent c = selection.get(i);
      final RadContainer parent = c.getParent();
      if (parent != null) {
        final Point p = SwingUtilities.convertPoint(c.getDelegee(), 0, 0, editor.getLayeredPane());
        final Rectangle visibleRect =
            layeredPaneRect.intersection(
                new Rectangle(p.x, p.y, parent.getWidth(), parent.getHeight()));
        g.setClip(visibleRect);
      }
      paintComponentBoundsImpl(editor, c, g);
      if (parent != null) {
        g.setClip(oldClip);
      }
    }
  }
 private static int getDesignTimeInsets(RadComponent component) {
   while (component != null) {
     Integer designTimeInsets =
         (Integer) component.getDelegee().getClientProperty(GridLayoutManager.DESIGN_TIME_INSETS);
     if (designTimeInsets != null) {
       return designTimeInsets.intValue();
     }
     component = component.getParent();
   }
   return 0;
 }
  /**
   * @param x in component's coord system
   * @param y in component's coord system
   */
  public static int getResizeMask(@NotNull final RadComponent component, final int x, final int y) {
    if (component.getParent() == null || !component.isSelected()) {
      return 0;
    }

    // only components in XY can be resized...
    /*
    if (!component.getParent().isXY()) {
      return 0;
    }
    */

    final int width = component.getWidth();
    final int height = component.getHeight();

    final Point[] points = getPoints(width, height);

    if (isInside(x, y, points[SE])) {
      return EAST_MASK | SOUTH_MASK;
    } else if (isInside(x, y, points[NW])) {
      return WEST_MASK | NORTH_MASK;
    } else if (isInside(x, y, points[N])) {
      return NORTH_MASK;
    } else if (isInside(x, y, points[NE])) {
      return EAST_MASK | NORTH_MASK;
    } else if (isInside(x, y, points[W])) {
      return WEST_MASK;
    } else if (isInside(x, y, points[E])) {
      return EAST_MASK;
    } else if (isInside(x, y, points[SW])) {
      return WEST_MASK | SOUTH_MASK;
    } else if (isInside(x, y, points[S])) {
      return SOUTH_MASK;
    } else {
      return 0;
    }
  }