Show
Ignore:
Timestamp:
05/17/08 11:34:28 (8 months ago)
Author:
Frank Benoit <benoit@tionex.de>
branch:
default
Message:

Update to SWT 3.4M7

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • dwt/dnd/URLTransfer.d

    r212 r213  
    11/******************************************************************************* 
    2  * Copyright (c) 2000, 2004 IBM Corporation and others. 
     2 * Copyright (c) 2000, 20007 IBM Corporation and others. 
    33 * All rights reserved. This program and the accompanying materials 
    44 * are made available under the terms of the Eclipse Public License v1.0 
     
    1212 *******************************************************************************/ 
    1313module dwt.dnd.URLTransfer; 
    14  
    15 //import java.net.URL; 
    1614 
    1715import dwt.internal.ole.win32.COM; 
     
    2927/** 
    3028 * The class <code>URLTransfer</code> provides a platform specific mechanism 
    31  * for converting text in URL format represented as a java <code>String[]</code> 
     29 * for converting text in URL format represented as a java <code>String</code>  
    3230 * to a platform specific representation of the data and vice versa.  See 
    33  * <code>Transfer</code> for additional information. The first string in the 
    34  * array is mandatory and must contain the fully specified url.  The second 
    35  * string in the array is optional and if present contains the title for the 
    36  * page. 
     31 * <code>Transfer</code> for additional information. The string  
     32 * must contain a fully specified url. 
    3733 * 
    38  * <p>An example of a java <code>String[]</code> containing a URL is shown 
     34 * <p>An example of a java <code>String</code> containing a URL is shown  
    3935 * below:</p> 
    4036 * 
    4137 * <code><pre> 
    42  *     String[] urlData = new String[] {"http://www.eclipse.org", "Eclipse.org Main Page"}
     38 *     String url = "http://www.eclipse.org"
    4339 * </code></pre> 
    4440 */ 
    45 /*public*/ class URLTransfer : ByteArrayTransfer { 
     41public class URLTransfer : ByteArrayTransfer { 
    4642 
    4743    static URLTransfer _instance; 
     
    7268 
    7369/** 
    74  * This implementation of <code>javaToNative</code> converts a URL and optionally a title 
    75  * represented by a java <code>String[]</code> to a platform specific representation. 
     70 * This implementation of <code>javaToNative</code> converts a URL 
     71 * represented by a java <code>String</code> to a platform specific representation. 
    7672 * For additional information see <code>Transfer#javaToNative</code>. 
    7773 * 
    78  * @param object a java <code>String[]</code> containing a URL and optionally, a title 
     74 * @param object a java <code>String</code> containing a URL 
    7975 * @param transferData an empty <code>TransferData</code> object; this 
    8076 *  object will be filled in on return with the platform specific format of the data 
     
    8682    transferData.result = COM.E_FAIL; 
    8783    // URL is stored as a null terminated byte array 
    88     String url = (cast(ArrayWrapperString2)object).array[0]
     84    String url = (cast(ArrayWrapperString)object).array
    8985    int codePage = OS.GetACP(); 
    9086    wchar[] chars = StrToWCHARs(codePage, url, true ); 
     
    107103/** 
    108104 * This implementation of <code>nativeToJava</code> converts a platform specific 
    109  * representation of a URL and optionally, a title to a java <code>String[]</code>. 
     105 * representation of a URL to a java <code>String</code>. 
    110106 * For additional information see <code>Transfer#nativeToJava</code>. 
    111107 * 
    112108 * @param transferData the platform specific representation of the data to be 
    113  * been converted 
    114  * @return a java <code>String[]</code> containing a URL and optionally a title if the 
     109 * converted 
     110 * @return a java <code>String</code> containing a URL if the  
    115111 * conversion was successful; otherwise null 
    116112 */ 
     
    135131            wchar[] lpWideCharStr = new wchar [cchWideChar - 1]; 
    136132            OS.MultiByteToWideChar (codePage, OS.MB_PRECOMPOSED, lpMultiByteStr, -1, lpWideCharStr.ptr, lpWideCharStr.length); 
    137             return new ArrayWrapperString2( [ WCHARzToStr( lpWideCharStr.ptr) ]); 
     133            return new ArrayWrapperString( WCHARzToStr( lpWideCharStr.ptr) ); 
    138134        } finally { 
    139135            OS.GlobalUnlock(hMem); 
     
    153149 
    154150bool checkURL(Object object) { 
    155     if( auto s = cast(ArrayWrapperString2)object ){ 
    156         if( s.array.length is 0 ) return false; 
    157         String[] strings = s.array; 
    158         if (strings[0] is null || strings[0].length is 0) return false; 
    159         //PORTING_FIXME: how to validata URL? 
    160         /+try { 
    161             new URL(strings[0]); 
    162         } catch (java.net.MalformedURLException e) { 
    163             return false; 
    164         }+/ 
    165         return true; 
    166     } 
    167     return false; 
     151    return object !is null && (null !is cast(ArrayWrapperString)object) && (cast(ArrayWrapperString)object).array.length > 0; 
     152 
    168153} 
    169154