Program: 66432
Project: 66432
Buggy source:
protected void handleDrop(){
  updateTargetRequest();
  updateTargetEditPart();
  if (DNDService.getInstance().performDrop(TemplateTransfer.getInstance().getTemplate(),getTargetEditPart(),DND.DROP_DEFAULT,new DNDLocation(getDropLocation()))) {
    return;
  }
  boolean isScalarparameter=false;
  boolean isResultSetColumn=false;
  boolean isEmbeddImage=false;
  final Object template=TemplateTransfer.getInstance().getTemplate();
  Assert.isNotNull(template);
  Assert.isTrue(handleValidateDrag(template));
  AbstractToolHandleExtends preHandle=null;
  String transName=null;
  if (template instanceof String) {
    PaletteEntryExtension[] entries=EditpartExtensionManager.getPaletteEntries();
    if (template.toString().startsWith(IReportElementConstants.REPORT_ELEMENT_EXTENDED)) {
      String extensionName=template.toString().substring(IReportElementConstants.REPORT_ELEMENT_EXTENDED.length());
      for (int i=0; i < entries.length; i++) {
        if (entries[i].getItemName().equals(extensionName)) {
          try {
            CommandUtils.setVariable("String_Node_Str",getTargetEditPart());
            CommandUtils.setVariable("String_Node_Str",getTargetRequest());
            getCreateRequest().getExtendedData().put(DesignerConstants.KEY_NEWOBJECT,entries[i].executeCreate());
            selectAddedObject();
            return;
          }
 catch (          Exception e) {
            ExceptionHandler.handle(e);
          }
        }
      }
    }
    transName=TRANS_LABEL_CREATE_ELEMENT;
    preHandle=BasePaletteFactory.getAbstractToolHandleExtendsFromPaletteName(template);
  }
 else   if (handleValidateInsert(template)) {
    transName=InsertInLayoutAction.DISPLAY_TEXT;
    Object objectType=getFactory(template).getObjectType();
    if (objectType instanceof DataSetHandle) {
      preHandle=new DataSetToolExtends();
    }
 else     if (objectType instanceof DataSetItemModel) {
      preHandle=new DataSetColumnToolExtends();
    }
 else     if (objectType instanceof ResultSetColumnHandle) {
      isResultSetColumn=true;
      preHandle=new DataSetColumnToolExtends();
    }
 else     if (objectType instanceof ScalarParameterHandle) {
      isScalarparameter=true;
      preHandle=new ParameterToolExtends();
    }
 else     if (objectType instanceof DimensionHandle) {
      preHandle=new DimensionHandleToolExtends();
    }
 else     if (objectType instanceof MeasureHandle) {
      preHandle=new MeasureHandleToolExtends();
    }
  }
 else   if (handleValidateLibrary(template)) {
    Object dragObj=getSingleTransferData(template);
    if (dragObj instanceof EmbeddedImageHandle) {
      isEmbeddImage=true;
      preHandle=new ImageToolExtends();
    }
 else     preHandle=new LibraryElementsToolHandleExtends((DesignElementHandle)dragObj);
  }
 else   if (handleValidateOutline(template)) {
    Object dragObj=getSingleTransferData(template);
    if (dragObj instanceof EmbeddedImageHandle) {
      isEmbeddImage=true;
      preHandle=new ImageToolExtends();
    }
  }
  if (preHandle != null) {
    CommandStack stack=SessionHandleAdapter.getInstance().getCommandStack();
    stack.startTrans(transName);
    preHandle.setRequest(this.getCreateRequest());
    preHandle.setTargetEditPart(getTargetEditPart());
    if (isEmbeddImage) {
      Object dragObj=getSingleTransferData(template);
      if (dragObj instanceof EmbeddedImageHandle) {
        if (((EmbeddedImageHandle)dragObj).getElementHandle().getRoot() instanceof LibraryHandle) {
          ModuleHandle moduleHandle=SessionHandleAdapter.getInstance().getReportDesignHandle();
          LibraryHandle library=(LibraryHandle)((EmbeddedImageHandle)dragObj).getElementHandle().getRoot();
          try {
            if (moduleHandle.getFileName() != library.getFileName() && UIUtil.includeLibrary(moduleHandle,library)) {
              EmbeddedImage image=StructureFactory.newEmbeddedImageFrom((EmbeddedImageHandle)dragObj,moduleHandle);
              image.setType(((EmbeddedImageHandle)dragObj).getType());
              DNDUtil.addEmbeddedImageHandle(getTargetEditPart().getModel(),image);
            }
          }
 catch (          Exception e) {
            ExceptionHandler.handle(e);
          }
        }
      }
    }
    Command command=this.getCommand();
    if (command != null && command.canExecute()) {
      if (!(preHandle.preHandleMouseUp())) {
        stack.rollback();
        return;
      }
    }
    boolean isTheme=checkTheme(preHandle,getSingleTransferData(template));
    if (!isTheme) {
      super.handleDrop();
      if (!preHandle.postHandleCreation()) {
        stack.rollback();
        return;
      }
      Request request=new Request();
      if (getCreateRequest().getExtendedData().get(DesignerConstants.NEWOBJECT_FROM_LIBRARY) != null) {
        request.getExtendedData().put(DesignerConstants.NEWOBJECT_FROM_LIBRARY,getCreateRequest().getExtendedData().get(DesignerConstants.NEWOBJECT_FROM_LIBRARY));
      }
      if (isScalarparameter || isResultSetColumn) {
        request.setType(ReportRequest.CREATE_SCALARPARAMETER_OR_RESULTSETCOLUMN);
        Object model=getCreateRequest().getExtendedData().get(DesignerConstants.KEY_NEWOBJECT);
        if (model instanceof GroupHandle) {
          GroupHandle handle=(GroupHandle)model;
          getCreateRequest().getExtendedData().put(DesignerConstants.KEY_NEWOBJECT,((CellHandle)((RowHandle)handle.getHeader().get(0)).getCells().get(0)).getContent().get(0));
        }
        selectAddedObject(request);
      }
 else       if (isEmbeddImage) {
        Object dragObj=getSingleTransferData(template);
        final Object model=getCreateRequest().getExtendedData().get(DesignerConstants.KEY_NEWOBJECT);
        try {
          ((ImageHandle)model).setImageName(((EmbeddedImageHandle)dragObj).getName());
        }
 catch (        SemanticException e) {
          ExceptionHandler.handle(e);
        }
        request.setType(ReportRequest.SELECTION);
        selectAddedObject(request);
      }
 else {
        request.setType(ReportRequest.CREATE_ELEMENT);
        selectAddedObject(request);
      }
    }
    stack.commit();
  }
}

Fixed version (ground truth):
protected void handleDrop(){
  updateTargetRequest();
  updateTargetEditPart();
  if (DNDService.getInstance().performDrop(TemplateTransfer.getInstance().getTemplate(),getTargetEditPart(),DND.DROP_DEFAULT,new DNDLocation(getDropLocation()))) {
    return;
  }
  boolean isScalarparameter=false;
  boolean isResultSetColumn=false;
  boolean isEmbeddImage=false;
  final Object template=TemplateTransfer.getInstance().getTemplate();
  Assert.isNotNull(template);
  Assert.isTrue(handleValidateDrag(template));
  AbstractToolHandleExtends preHandle=null;
  String transName=null;
  if (template instanceof String) {
    PaletteEntryExtension[] entries=EditpartExtensionManager.getPaletteEntries();
    if (template.toString().startsWith(IReportElementConstants.REPORT_ELEMENT_EXTENDED)) {
      String extensionName=template.toString().substring(IReportElementConstants.REPORT_ELEMENT_EXTENDED.length());
      for (int i=0; i < entries.length; i++) {
        if (entries[i].getItemName().equals(extensionName)) {
          try {
            CommandUtils.setVariable("String_Node_Str",getTargetEditPart());
            CommandUtils.setVariable("String_Node_Str",getTargetRequest());
            getCreateRequest().getExtendedData().put(DesignerConstants.KEY_NEWOBJECT,entries[i].executeCreate());
            selectAddedObject();
            return;
          }
 catch (          Exception e) {
            ExceptionHandler.handle(e);
          }
        }
      }
    }
    transName=TRANS_LABEL_CREATE_ELEMENT;
    preHandle=BasePaletteFactory.getAbstractToolHandleExtendsFromPaletteName(template);
  }
 else   if (handleValidateInsert(template)) {
    transName=InsertInLayoutAction.DISPLAY_TEXT;
    Object objectType=getFactory(template).getObjectType();
    if (objectType instanceof DataSetHandle) {
      preHandle=new DataSetToolExtends();
    }
 else     if (objectType instanceof DataSetItemModel) {
      preHandle=new DataSetColumnToolExtends();
    }
 else     if (objectType instanceof ResultSetColumnHandle) {
      isResultSetColumn=true;
      preHandle=new DataSetColumnToolExtends();
    }
 else     if (objectType instanceof ScalarParameterHandle) {
      isScalarparameter=true;
      preHandle=new ParameterToolExtends();
    }
 else     if (objectType instanceof DimensionHandle) {
      preHandle=new DimensionHandleToolExtends();
    }
 else     if (objectType instanceof MeasureHandle) {
      preHandle=new MeasureHandleToolExtends();
    }
  }
 else   if (handleValidateLibrary(template)) {
    Object dragObj=getSingleTransferData(template);
    if (dragObj instanceof EmbeddedImageHandle) {
      isEmbeddImage=true;
      preHandle=new ImageToolExtends();
    }
 else     preHandle=new LibraryElementsToolHandleExtends((DesignElementHandle)dragObj);
  }
 else   if (handleValidateOutline(template)) {
    Object dragObj=getSingleTransferData(template);
    if (dragObj instanceof EmbeddedImageHandle) {
      isEmbeddImage=true;
      preHandle=new ImageToolExtends();
    }
  }
  if (preHandle != null) {
    CommandStack stack=SessionHandleAdapter.getInstance().getCommandStack();
    if (stack == null && getTargetEditPart() != null) {
      Object obj=DNDUtil.unwrapToModel(getTargetEditPart().getModel());
      ModuleHandle moduleHandle=null;
      if (obj instanceof DesignElementHandle) {
        moduleHandle=((DesignElementHandle)obj).getModuleHandle();
      }
 else       if (obj instanceof SlotHandle) {
        moduleHandle=((SlotHandle)obj).getElementHandle().getModuleHandle();
      }
      if (moduleHandle != null) {
        SessionHandleAdapter.getInstance().setReportDesignHandle(moduleHandle);
        stack=moduleHandle.getCommandStack();
      }
    }
    if (stack == null) {
      return;
    }
    stack.startTrans(transName);
    preHandle.setRequest(this.getCreateRequest());
    preHandle.setTargetEditPart(getTargetEditPart());
    if (isEmbeddImage) {
      Object dragObj=getSingleTransferData(template);
      if (dragObj instanceof EmbeddedImageHandle) {
        if (((EmbeddedImageHandle)dragObj).getElementHandle().getRoot() instanceof LibraryHandle) {
          ModuleHandle moduleHandle=SessionHandleAdapter.getInstance().getReportDesignHandle();
          LibraryHandle library=(LibraryHandle)((EmbeddedImageHandle)dragObj).getElementHandle().getRoot();
          try {
            if (moduleHandle.getFileName() != library.getFileName() && UIUtil.includeLibrary(moduleHandle,library)) {
              EmbeddedImage image=StructureFactory.newEmbeddedImageFrom((EmbeddedImageHandle)dragObj,moduleHandle);
              image.setType(((EmbeddedImageHandle)dragObj).getType());
              DNDUtil.addEmbeddedImageHandle(getTargetEditPart().getModel(),image);
            }
          }
 catch (          Exception e) {
            ExceptionHandler.handle(e);
          }
        }
      }
    }
    Command command=this.getCommand();
    if (command != null && command.canExecute()) {
      if (!(preHandle.preHandleMouseUp())) {
        stack.rollback();
        return;
      }
    }
    boolean isTheme=checkTheme(preHandle,getSingleTransferData(template));
    if (!isTheme) {
      super.handleDrop();
      if (!preHandle.postHandleCreation()) {
        stack.rollback();
        return;
      }
      Request request=new Request();
      if (getCreateRequest().getExtendedData().get(DesignerConstants.NEWOBJECT_FROM_LIBRARY) != null) {
        request.getExtendedData().put(DesignerConstants.NEWOBJECT_FROM_LIBRARY,getCreateRequest().getExtendedData().get(DesignerConstants.NEWOBJECT_FROM_LIBRARY));
      }
      if (isScalarparameter || isResultSetColumn) {
        request.setType(ReportRequest.CREATE_SCALARPARAMETER_OR_RESULTSETCOLUMN);
        Object model=getCreateRequest().getExtendedData().get(DesignerConstants.KEY_NEWOBJECT);
        if (model instanceof GroupHandle) {
          GroupHandle handle=(GroupHandle)model;
          getCreateRequest().getExtendedData().put(DesignerConstants.KEY_NEWOBJECT,((CellHandle)((RowHandle)handle.getHeader().get(0)).getCells().get(0)).getContent().get(0));
        }
        selectAddedObject(request);
      }
 else       if (isEmbeddImage) {
        Object dragObj=getSingleTransferData(template);
        final Object model=getCreateRequest().getExtendedData().get(DesignerConstants.KEY_NEWOBJECT);
        try {
          ((ImageHandle)model).setImageName(((EmbeddedImageHandle)dragObj).getName());
        }
 catch (        SemanticException e) {
          ExceptionHandler.handle(e);
        }
        request.setType(ReportRequest.SELECTION);
        selectAddedObject(request);
      }
 else {
        request.setType(ReportRequest.CREATE_ELEMENT);
        selectAddedObject(request);
      }
    }
    stack.commit();
  }
}