Project

General

Profile

Download (1.84 KB) Statistics
| Branch: | Tag: | Revision:
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.gef.dnd;
12

    
13
/**
14
 * Transfer object used to transfer the template of a palette tool. It is used
15
 * for drag-and-drop from the palette as well as copy/paste from the palette.
16
 * 
17
 * @author Eric Bordeau
18
 * @since 2.1
19
 */
20
public final class TemplateTransfer extends SimpleObjectTransfer {
21

    
22
	private static final TemplateTransfer INSTANCE = new TemplateTransfer();
23
	private static final String TYPE_NAME = "Template transfer"//$NON-NLS-1$
24
			+ System.currentTimeMillis() + ":" + INSTANCE.hashCode();//$NON-NLS-1$
25
	private static final int TYPEID = registerType(TYPE_NAME);
26

    
27
	private TemplateTransfer() {
28
	}
29

    
30
	/**
31
	 * Returns the singleton instance
32
	 * 
33
	 * @return the singleton
34
	 */
35
	public static TemplateTransfer getInstance() {
36
		return INSTANCE;
37
	}
38

    
39
	/**
40
	 * Returns the <i>template</i> object.
41
	 * 
42
	 * @return the template
43
	 */
44
	public Object getTemplate() {
45
		return getObject();
46
	}
47

    
48
	/**
49
	 * @see org.eclipse.swt.dnd.Transfer#getTypeIds()
50
	 */
51
	protected int[] getTypeIds() {
52
		return new int[] { TYPEID };
53
	}
54

    
55
	/**
56
	 * @see org.eclipse.swt.dnd.Transfer#getTypeNames()
57
	 */
58
	protected String[] getTypeNames() {
59
		return new String[] { TYPE_NAME };
60
	}
61

    
62
	/**
63
	 * Sets the <i>template</i> Object.
64
	 * 
65
	 * @param template
66
	 *            the template
67
	 */
68
	public void setTemplate(Object template) {
69
		setObject(template);
70
	}
71

    
72
}
(6-6/10)