crashanalysis/crashanalyser/com.nokia.s60tools.crashanalyser/src/com/nokia/s60tools/crashanalyser/model/PEBClip.java
changeset 0 5ad7ad99af01
equal deleted inserted replaced
-1:000000000000 0:5ad7ad99af01
       
     1 /*
       
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 package com.nokia.s60tools.crashanalyser.model;
       
    19 
       
    20 import sun.awt.windows.*;
       
    21 import java.lang.reflect.*;
       
    22 
       
    23 /**
       
    24  * Access the native clipboard, windows only, write only.
       
    25  */
       
    26 public class PEBClip extends WClipboard {
       
    27 	private final Method m;
       
    28 
       
    29 	public PEBClip() throws NoSuchMethodException {
       
    30 		m = WClipboard.class.getDeclaredMethod("publishClipboardData",
       
    31 				new Class[]  {Long.TYPE, (new byte[0]).getClass()});
       
    32 		m.setAccessible(true);
       
    33 	}
       
    34 	
       
    35 	public synchronized void setData(long format, byte[] data) throws IllegalAccessException, InvocationTargetException {
       
    36 		setData(new long[]{format}, new byte[][]{data});
       
    37 	}
       
    38 
       
    39 	public synchronized void setData(long[] format, byte[][] data) throws IllegalAccessException, InvocationTargetException {
       
    40 		openClipboard(this);
       
    41 		try{
       
    42 			for(int i=0;i<format.length && i<data.length;i++)
       
    43 				myPublishClipboardData(format[i], data[i]);
       
    44 		} finally {
       
    45 			closeClipboard();
       
    46 		}
       
    47 	}
       
    48 
       
    49 	protected void myPublishClipboardData(long format, byte[] bytes) throws IllegalAccessException, InvocationTargetException{
       
    50 		m.invoke(this, new Object[]{new Long(format),bytes});
       
    51 	}
       
    52 }