Program: 143684
Project: 143684
Buggy source:
/** 
 * Construct.
 * @param id The component's id
 * @param group The group of headers the new one will be added to
 * @param cellview
 */
public SortableCellViewHeader(Form form,final WebCellBasedView view,final String id,final SortableCellViewHeaderGroup group,AbstractBase cellview,boolean useAJAX,IApplication application){
  super(id);
  this.id=id;
  this.cellview=cellview;
  this.view=view;
  this.application=application;
  this.form=form;
  headerColumnTable=new WebMarkupContainer("String_Node_Str");
  headerColumnTable.add(labelResolver=new LabelResolverLink("String_Node_Str",useAJAX,group,id));
  labelResolver.add(new AttributeModifier("String_Node_Str",true,group));
  ChangesRecorder changesRecorder=new ChangesRecorder();
  changesRecorder.setBgcolor(view.getHeaderBgColor());
  changesRecorder.setBorder(view.getHeaderBorder());
  final Properties changes=changesRecorder.getChanges();
  if (changes.size() > 0)   applyStyleChanges(headerColumnTable,changes);
  ChangesRecorder textChangesRecorder=new ChangesRecorder();
  textChangesRecorder.setFgcolor(view.getHeaderFgColor());
  textChangesRecorder.setFont(view.getHeaderFont());
  final Properties textChanges=textChangesRecorder.getChanges();
  if (textChanges.size() > 0)   applyStyleChanges(labelResolver,textChanges);
  boolean blockResize=false;
  Iterator<IPersist> iter=cellview.getAllObjects();
  while (iter.hasNext()) {
    IPersist element=iter.next();
    if (element instanceof ISupportAnchors) {
      if (id.equals(ComponentFactory.getWebID(form,element))) {
        int anchors=((ISupportAnchors)element).getAnchors();
        if (((anchors & IAnchorConstants.EAST) == 0) || ((anchors & IAnchorConstants.WEST) == 0)) {
          blockResize=true;
        }
        isUnmovable=((anchors & IAnchorConstants.NORTH) == IAnchorConstants.NORTH) && ((anchors & IAnchorConstants.SOUTH) == IAnchorConstants.SOUTH);
        break;
      }
    }
  }
  if (((!(cellview instanceof Portal) || ((Portal)cellview).getReorderable()) && useAJAX) && !isUnmovable()) {
    DraggableBehavior dragMoveBehavior=new DraggableBehavior(){
      private int startX;
      @Override protected void onDragEnd(      String componentId,      int x,      int y,      int m,      AjaxRequestTarget ajaxRequestTarget){
        view.moveColumn(SortableCellViewHeader.this,x - startX,ajaxRequestTarget);
        labelResolver.setDropped(true);
      }
      @Override protected boolean onDragStart(      String componentId,      int x,      int y,      int m,      AjaxRequestTarget ajaxRequestTarget){
        startX=x;
        return true;
      }
      @Override protected void onDrop(      String componentId,      String targetid,      int x,      int y,      int m,      AjaxRequestTarget ajaxRequestTarget){
      }
      @Override protected void onDropHover(      String componentId,      String targeid,      int m,      AjaxRequestTarget ajaxRequestTarget){
      }
    }
;
    dragMoveBehavior.setRenderOnHead(false);
    dragMoveBehavior.setYConstraint(true);
    dragMoveBehavior.setUseProxy(true);
    dragMoveBehavior.setResizeProxyFrame(true);
    headerColumnTable.add(dragMoveBehavior);
  }
  if (cellview instanceof Portal && !((Portal)cellview).getSortable()) {
    labelResolver.setSortable(false);
    resizeBar=new WebMarkupContainer("String_Node_Str");
  }
 else {
    resizeBar=new Image("String_Node_Str",view.R_ARROW_OFF);
  }
  if (!blockResize && (!(cellview instanceof Portal) || ((Portal)cellview).getResizeble()) && useAJAX) {
    DraggableBehavior dragResizeBehavior=new DraggableBehavior(){
      private int startX;
      @Override protected void onDragEnd(      String componentId,      int x,      int y,      int m,      AjaxRequestTarget ajaxRequestTarget){
        view.resizeColumn(SortableCellViewHeader.this,x - startX);
      }
      @Override protected boolean onDragStart(      String componentId,      int x,      int y,      int m,      AjaxRequestTarget ajaxRequestTarget){
        startX=x;
        return true;
      }
      @Override protected void onDrop(      String componentId,      String targetid,      int x,      int y,      int m,      AjaxRequestTarget ajaxRequestTarget){
      }
      @Override protected void onDropHover(      String componentId,      String targeid,      int m,      AjaxRequestTarget ajaxRequestTarget){
      }
    }
;
    dragResizeBehavior.setRenderOnHead(false);
    dragResizeBehavior.setYConstraint(true);
    resizeBar.add(dragResizeBehavior);
    resizeBar.add(new AttributeModifier("String_Node_Str",true,new Model<String>("String_Node_Str")));
  }
 else {
    resizeBar.add(new AttributeModifier("String_Node_Str",true,new Model<String>("String_Node_Str")));
  }
  headerColumnTable.add(resizeBar);
  add(headerColumnTable);
  try {
    Iterator<IPersist> it2=cellview.getAllObjects(PositionComparator.XY_PERSIST_COMPARATOR);
    int height=-1;
    while (it2.hasNext()) {
      IPersist element=it2.next();
      if (id.equals(ComponentFactory.getWebID(form,element))) {
        final GraphicalComponent gc=(GraphicalComponent)view.labelsFor.get(((ISupportName)element).getName());
        if (gc != null && height < 0) {
          height=gc.getSize().height;
        }
        if (gc != null && gc.getImageMediaID() > 0) {
          final int media_id=gc.getImageMediaID();
          final Media media=application.getFlattenedSolution().getMedia(media_id);
          if (media != null) {
            final int headerHeight=height;
            add(new StyleAppendingModifier(new Model<String>(){
              @Override public String getObject(){
                ResourceReference iconReference=new ResourceReference(media.getName()){
                  private static final long serialVersionUID=1L;
                  @Override protected Resource newResource(){
                    BufferedDynamicImageResource imgRes=new BufferedDynamicImageResource();
                    MediaResource tempIcon=new MediaResource(media.getMediaData(),gc.getMediaOptions());
                    (tempIcon).checkResize(new Dimension(width,headerHeight));
                    ImageIcon icon=new ImageIcon(tempIcon.resized);
                    imgRes.setImage(ImageLoader.imageToBufferedImage((icon).getImage()));
                    return imgRes;
                  }
                }
;
                return "String_Node_Str" + urlFor(iconReference) + "String_Node_Str"+ media_id+ "String_Node_Str";
              }
            }
));
          }
        }
 else         if (gc != null && gc.getToolTipText() != null) {
          tooltip=application.getI18NMessageIfPrefixed(gc.getToolTipText());
          add(TooltipAttributeModifier.INSTANCE);
        }
        if (gc != null) {
          int style_valign=-1;
          Pair<IStyleSheet,IStyleRule> styleInfo=ComponentFactory.getStyleForBasicComponent(application,gc,form);
          if (styleInfo != null) {
            IStyleSheet ss=styleInfo.getLeft();
            IStyleRule s=styleInfo.getRight();
            if (ss != null && s != null) {
              style_valign=ss.getVAlign(s);
            }
          }
          final int styleValign=style_valign;
          add(new StyleAppendingModifier(new Model<String>(){
            private static final long serialVersionUID=1L;
            @Override public String getObject(){
              int valign=ISupportTextSetup.CENTER;
              if (gc.getVerticalAlignment() >= 0) {
                valign=gc.getVerticalAlignment();
              }
 else               if (styleValign >= 0) {
                valign=styleValign;
              }
              return "String_Node_Str" + TemplateGenerator.getVerticalAlignValue(valign) + "String_Node_Str";
            }
          }
));
        }
        if (gc != null && gc.getOnRightClickMethodID() > 0) {
          executor=new WebEventExecutor(this,useAJAX);
          executor.setRightClickCmd(String.valueOf(gc.getOnRightClickMethodID()),null);
          labelName=gc.getName();
        }
      }
    }
  }
 catch (  Exception ex) {
    Debug.error(ex);
  }
  Boolean dir=group.get(id);
  if (dir != null && form.getOnSortCmdMethodID() >= 0) {
    setResizeImage(dir ? view.R_ARROW_DOWN : view.R_ARROW_UP);
  }
}

Fixed version (ground truth):
/** 
 * Construct.
 * @param id The component's id
 * @param group The group of headers the new one will be added to
 * @param cellview
 */
public SortableCellViewHeader(Form form,final WebCellBasedView view,final String id,final SortableCellViewHeaderGroup group,AbstractBase cellview,boolean useAJAX,IApplication application){
  super(id);
  this.id=id;
  this.cellview=cellview;
  this.view=view;
  this.application=application;
  this.form=form;
  headerColumnTable=new WebMarkupContainer("String_Node_Str");
  headerColumnTable.add(labelResolver=new LabelResolverLink("String_Node_Str",useAJAX,group,id));
  labelResolver.add(new AttributeModifier("String_Node_Str",true,group));
  ChangesRecorder changesRecorder=new ChangesRecorder();
  changesRecorder.setBgcolor(view.getHeaderBgColor());
  changesRecorder.setBorder(view.getHeaderBorder());
  if (view.getHeaderBorder() != null) {
    add(new StyleAppendingModifier(new Model<String>("String_Node_Str")));
  }
  final Properties changes=changesRecorder.getChanges();
  if (changes.size() > 0)   applyStyleChanges(headerColumnTable,changes);
  ChangesRecorder textChangesRecorder=new ChangesRecorder();
  textChangesRecorder.setFgcolor(view.getHeaderFgColor());
  textChangesRecorder.setFont(view.getHeaderFont());
  final Properties textChanges=textChangesRecorder.getChanges();
  if (textChanges.size() > 0)   applyStyleChanges(labelResolver,textChanges);
  boolean blockResize=false;
  Iterator<IPersist> iter=cellview.getAllObjects();
  while (iter.hasNext()) {
    IPersist element=iter.next();
    if (element instanceof ISupportAnchors) {
      if (id.equals(ComponentFactory.getWebID(form,element))) {
        int anchors=((ISupportAnchors)element).getAnchors();
        if (((anchors & IAnchorConstants.EAST) == 0) || ((anchors & IAnchorConstants.WEST) == 0)) {
          blockResize=true;
        }
        isUnmovable=((anchors & IAnchorConstants.NORTH) == IAnchorConstants.NORTH) && ((anchors & IAnchorConstants.SOUTH) == IAnchorConstants.SOUTH);
        break;
      }
    }
  }
  if (((!(cellview instanceof Portal) || ((Portal)cellview).getReorderable()) && useAJAX) && !isUnmovable()) {
    DraggableBehavior dragMoveBehavior=new DraggableBehavior(){
      private int startX;
      @Override protected void onDragEnd(      String componentId,      int x,      int y,      int m,      AjaxRequestTarget ajaxRequestTarget){
        view.moveColumn(SortableCellViewHeader.this,x - startX,ajaxRequestTarget);
        labelResolver.setDropped(true);
      }
      @Override protected boolean onDragStart(      String componentId,      int x,      int y,      int m,      AjaxRequestTarget ajaxRequestTarget){
        startX=x;
        return true;
      }
      @Override protected void onDrop(      String componentId,      String targetid,      int x,      int y,      int m,      AjaxRequestTarget ajaxRequestTarget){
      }
      @Override protected void onDropHover(      String componentId,      String targeid,      int m,      AjaxRequestTarget ajaxRequestTarget){
      }
    }
;
    dragMoveBehavior.setRenderOnHead(false);
    dragMoveBehavior.setYConstraint(true);
    dragMoveBehavior.setUseProxy(true);
    dragMoveBehavior.setResizeProxyFrame(true);
    headerColumnTable.add(dragMoveBehavior);
  }
  if (cellview instanceof Portal && !((Portal)cellview).getSortable()) {
    labelResolver.setSortable(false);
    resizeBar=new WebMarkupContainer("String_Node_Str");
  }
 else {
    resizeBar=new Image("String_Node_Str",view.R_ARROW_OFF);
  }
  if (!blockResize && (!(cellview instanceof Portal) || ((Portal)cellview).getResizeble()) && useAJAX) {
    DraggableBehavior dragResizeBehavior=new DraggableBehavior(){
      private int startX;
      @Override protected void onDragEnd(      String componentId,      int x,      int y,      int m,      AjaxRequestTarget ajaxRequestTarget){
        view.resizeColumn(SortableCellViewHeader.this,x - startX);
      }
      @Override protected boolean onDragStart(      String componentId,      int x,      int y,      int m,      AjaxRequestTarget ajaxRequestTarget){
        startX=x;
        return true;
      }
      @Override protected void onDrop(      String componentId,      String targetid,      int x,      int y,      int m,      AjaxRequestTarget ajaxRequestTarget){
      }
      @Override protected void onDropHover(      String componentId,      String targeid,      int m,      AjaxRequestTarget ajaxRequestTarget){
      }
    }
;
    dragResizeBehavior.setRenderOnHead(false);
    dragResizeBehavior.setYConstraint(true);
    resizeBar.add(dragResizeBehavior);
    resizeBar.add(new AttributeModifier("String_Node_Str",true,new Model<String>("String_Node_Str")));
  }
 else {
    resizeBar.add(new AttributeModifier("String_Node_Str",true,new Model<String>("String_Node_Str")));
  }
  headerColumnTable.add(resizeBar);
  add(headerColumnTable);
  try {
    Iterator<IPersist> it2=cellview.getAllObjects(PositionComparator.XY_PERSIST_COMPARATOR);
    int height=-1;
    while (it2.hasNext()) {
      IPersist element=it2.next();
      if (id.equals(ComponentFactory.getWebID(form,element))) {
        final GraphicalComponent gc=(GraphicalComponent)view.labelsFor.get(((ISupportName)element).getName());
        if (gc != null && height < 0) {
          height=gc.getSize().height;
        }
        if (gc != null && gc.getImageMediaID() > 0) {
          final int media_id=gc.getImageMediaID();
          final Media media=application.getFlattenedSolution().getMedia(media_id);
          if (media != null) {
            final int headerHeight=height;
            add(new StyleAppendingModifier(new Model<String>(){
              @Override public String getObject(){
                ResourceReference iconReference=new ResourceReference(media.getName()){
                  private static final long serialVersionUID=1L;
                  @Override protected Resource newResource(){
                    BufferedDynamicImageResource imgRes=new BufferedDynamicImageResource();
                    MediaResource tempIcon=new MediaResource(media.getMediaData(),gc.getMediaOptions());
                    (tempIcon).checkResize(new Dimension(width,headerHeight));
                    ImageIcon icon=new ImageIcon(tempIcon.resized);
                    imgRes.setImage(ImageLoader.imageToBufferedImage((icon).getImage()));
                    return imgRes;
                  }
                }
;
                return "String_Node_Str" + urlFor(iconReference) + "String_Node_Str"+ media_id+ "String_Node_Str";
              }
            }
));
          }
        }
 else         if (gc != null && gc.getToolTipText() != null) {
          tooltip=application.getI18NMessageIfPrefixed(gc.getToolTipText());
          add(TooltipAttributeModifier.INSTANCE);
        }
        if (gc != null) {
          int style_valign=-1;
          Pair<IStyleSheet,IStyleRule> styleInfo=ComponentFactory.getStyleForBasicComponent(application,gc,form);
          if (styleInfo != null) {
            IStyleSheet ss=styleInfo.getLeft();
            IStyleRule s=styleInfo.getRight();
            if (ss != null && s != null) {
              style_valign=ss.getVAlign(s);
            }
          }
          final int styleValign=style_valign;
          add(new StyleAppendingModifier(new Model<String>(){
            private static final long serialVersionUID=1L;
            @Override public String getObject(){
              int valign=ISupportTextSetup.CENTER;
              if (gc.getVerticalAlignment() >= 0) {
                valign=gc.getVerticalAlignment();
              }
 else               if (styleValign >= 0) {
                valign=styleValign;
              }
              return "String_Node_Str" + TemplateGenerator.getVerticalAlignValue(valign) + "String_Node_Str";
            }
          }
));
        }
        if (gc != null && gc.getOnRightClickMethodID() > 0) {
          executor=new WebEventExecutor(this,useAJAX);
          executor.setRightClickCmd(String.valueOf(gc.getOnRightClickMethodID()),null);
          labelName=gc.getName();
        }
      }
    }
  }
 catch (  Exception ex) {
    Debug.error(ex);
  }
  Boolean dir=group.get(id);
  if (dir != null && form.getOnSortCmdMethodID() >= 0) {
    setResizeImage(dir ? view.R_ARROW_DOWN : view.R_ARROW_UP);
  }
}