KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > views > navigator > LocalSelectionTransfer


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 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.ui.views.navigator;
12
13 import org.eclipse.jface.viewers.ISelection;
14 import org.eclipse.swt.dnd.TransferData;
15
16 /**
17  * A LocalSelectionTransfer may be used for drag and drop operations within the
18  * same instance of Eclipse. The selection is made available directly for use in
19  * the DropTargetListener. dropAccept method. The DropTargetEvent passed to
20  * dropAccept does not contain the drop data. The selection may be used for
21  * validation purposes so that the drop can be aborted if appropriate. This
22  * class is not intended to be subclassed.
23  *
24  * @since 2.1
25  */

26 public class LocalSelectionTransfer extends
27         org.eclipse.jface.util.LocalSelectionTransfer {
28
29     private static final LocalSelectionTransfer INSTANCE = new LocalSelectionTransfer();
30
31     /**
32      * The get/set methods delegate to JFace's LocalSelectionTransfer to allow
33      * data to be exchanged freely whether the client uses this
34      * LocalSelectionTransfer or JFace's LocalSelectionTransfer. Protected
35      * methods such as getTypeIds() are handled via inheritance, not delegation
36      * due to visibility constraints.
37      */

38     private org.eclipse.jface.util.LocalSelectionTransfer jfaceTransfer = org.eclipse.jface.util.LocalSelectionTransfer
39             .getTransfer();
40
41     /**
42      * Only the singleton instance of this class may be used.
43      */

44     private LocalSelectionTransfer() {
45     }
46
47     /**
48      * Returns the singleton.
49      *
50      * @return the singleton
51      */

52     public static LocalSelectionTransfer getInstance() {
53         return INSTANCE;
54     }
55
56     /*
57      * (non-Javadoc)
58      *
59      * @see org.eclipse.jface.util.LocalSelectionTransfer#getSelection()
60      */

61     public ISelection getSelection() {
62         return jfaceTransfer.getSelection();
63     }
64
65     /*
66      * (non-Javadoc)
67      *
68      * @see org.eclipse.jface.util.LocalSelectionTransfer#getSelectionSetTime()
69      */

70     public long getSelectionSetTime() {
71         return jfaceTransfer.getSelectionSetTime();
72     }
73
74     /*
75      * (non-Javadoc)
76      *
77      * @see org.eclipse.jface.util.LocalSelectionTransfer#setSelection(org.eclipse.jface.viewers.ISelection)
78      */

79     public void setSelection(ISelection s) {
80         jfaceTransfer.setSelection(s);
81     }
82
83     /*
84      * (non-Javadoc)
85      *
86      * @see org.eclipse.jface.util.LocalSelectionTransfer#setSelectionSetTime(long)
87      */

88     public void setSelectionSetTime(long time) {
89         jfaceTransfer.setSelectionSetTime(time);
90     }
91     
92     /* (non-Javadoc)
93      * @see org.eclipse.jface.util.LocalSelectionTransfer#javaToNative(java.lang.Object, org.eclipse.swt.dnd.TransferData)
94      */

95     public void javaToNative(Object JavaDoc object, TransferData transferData) {
96         jfaceTransfer.javaToNative(object, transferData);
97     }
98
99     /* (non-Javadoc)
100      * @see org.eclipse.jface.util.LocalSelectionTransfer#nativeToJava(org.eclipse.swt.dnd.TransferData)
101      */

102     public Object JavaDoc nativeToJava(TransferData transferData) {
103         return jfaceTransfer.nativeToJava(transferData);
104     }
105 }
106
Popular Tags