private IStatus validateTarget ( Object target , TransferData transferType , int dropOperation ) { if ( target instanceof IVdmContainer ) { target = ( ( IVdmContainer ) target ) . getContainer ( ) ; } if ( ! ( target instanceof IResource ) ) { return WorkbenchNavigatorPlugin . createInfoStatus ( WorkbenchNavigatorMessages . DropAdapter_targetMustBeResource ) ; } IResource resource = ( IResource ) target ; if ( ! resource . isAccessible ( ) ) { return WorkbenchNavigatorPlugin . createErrorStatus ( WorkbenchNavigatorMessages . DropAdapter_canNotDropIntoClosedProject ) ; } IContainer destination = getActualTarget ( resource ) ; if ( destination . getType ( ) == IResource . ROOT ) { return WorkbenchNavigatorPlugin . createErrorStatus ( WorkbenchNavigatorMessages . DropAdapter_resourcesCanNotBeSiblings ) ; } String message = null ; // drag within Eclipse? if ( LocalSelectionTransfer . getTransfer ( ) . isSupportedType ( transferType ) ) { IResource [ ] selectedResources = getSelectedResources ( ) ; if ( selectedResources . length == 0 ) { message = WorkbenchNavigatorMessages . DropAdapter_dropOperationErrorOther ; } else { CopyFilesAndFoldersOperation operation ; if ( dropOperation == DND . DROP_COPY ) { operation = new CopyFilesAndFoldersOperation ( getShell ( ) ) ; } else { operation = new MoveFilesAndFoldersOperation ( getShell ( ) ) ; } message = operation . validateDestination ( destination , selectedResources ) ; } } // file import? else if ( FileTransfer . getInstance ( ) . isSupportedType ( transferType ) ) { String [ ] sourceNames = ( String [ ] ) FileTransfer . getInstance ( ) . nativeToJava ( transferType ) ; if ( sourceNames == null ) { // source names will be null on Linux. Use empty names to do // destination validation. // Fixes bug 29778 sourceNames = new String [ 0 ] ; } CopyFilesAndFoldersOperation copyOperation = new CopyFilesAndFoldersOperation ( getShell ( ) ) ; message = copyOperation . validateImportDestination ( destination , sourceNames ) ; } if ( message != null ) { return WorkbenchNavigatorPlugin . createErrorStatus ( message ) ; } return Status . OK_STATUS ; }
Ensures that the drop target meets certain criteria