01: /* uDig - User Friendly Desktop Internet GIS client
02: * http://udig.refractions.net
03: * (C) 2004, Refractions Research Inc.
04: *
05: * This library is free software; you can redistribute it and/or
06: * modify it under the terms of the GNU Lesser General Public
07: * License as published by the Free Software Foundation;
08: * version 2.1 of the License.
09: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: */
15: package net.refractions.udig.ui;
16:
17: import net.refractions.udig.internal.ui.UDIGTransfer;
18:
19: import org.eclipse.swt.dnd.TextTransfer;
20: import org.eclipse.swt.dnd.TransferData;
21:
22: /**
23: * An abstract class for all the Types of text transfers supported by uDig. Drag and
24: * Drop is extremely platform dependent (I'm really disappointed with the SWT design)
25: * so this class is handling the Linux requirements. It depends on getTypeIds and getTypeNames
26: * being implemented which to me is stupid.
27:
28: * @author jones
29: * @since 1.1.0
30: */
31: public abstract class AbstractTextStrategizedTransfer extends
32: AbstractStrategizedTransfer implements UDIGTransfer {
33:
34: private static final String COMPOUND_TEXT = "COMPOUND_TEXT"; //$NON-NLS-1$
35: private static final String UTF8_STRING = "UTF8_STRING"; //$NON-NLS-1$
36: private static final int COMPOUND_TEXT_ID = registerType(COMPOUND_TEXT);
37: private static final int UTF8_STRING_ID = registerType(UTF8_STRING);
38:
39: @Override
40: public Object nativeToJava(TransferData transferData) {
41: return TextTransfer.getInstance().nativeToJava(transferData);
42: }
43:
44: protected int[] getTypeIds() {
45: return new int[] { UTF8_STRING_ID, COMPOUND_TEXT_ID };
46: }
47:
48: protected String[] getTypeNames() {
49: return new String[] { UTF8_STRING, COMPOUND_TEXT };
50: }
51:
52: }
|