Source Code Cross Referenced for UDigByteAndLocalTransfer.java in  » GIS » udig-1.1 » net » refractions » udig » internal » ui » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » GIS » udig 1.1 » net.refractions.udig.internal.ui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package net.refractions.udig.internal.ui;
002:
003:        import java.io.ByteArrayInputStream;
004:        import java.io.IOException;
005:        import java.io.InputStreamReader;
006:        import java.util.ArrayList;
007:        import java.util.Iterator;
008:        import java.util.List;
009:
010:        import org.eclipse.jface.viewers.IStructuredSelection;
011:        import org.eclipse.swt.dnd.ByteArrayTransfer;
012:        import org.eclipse.swt.dnd.Transfer;
013:        import org.eclipse.swt.dnd.TransferData;
014:
015:        public class UDigByteAndLocalTransfer extends ByteArrayTransfer
016:                implements  UDIGTransfer {
017:            private static UDigByteAndLocalTransfer _instance = new UDigByteAndLocalTransfer();
018:
019:            static final String CFSTR_INETURL = "UniformResourceLocator"; //$NON-NLS-1$
020:
021:            private static final int CFSTR_INETURLID = Transfer
022:                    .registerType(CFSTR_INETURL);
023:
024:            private long startTime;
025:
026:            public Object object;
027:
028:            @Override
029:            public boolean isSupportedType(TransferData transferData) {
030:                return super .isSupportedType(transferData);
031:            }
032:
033:            public UDigByteAndLocalTransfer() {
034:
035:                // do nothing.
036:            }
037:
038:            public static UDigByteAndLocalTransfer getInstance() {
039:
040:                return _instance;
041:            }
042:
043:            protected int[] getTypeIds() {
044:
045:                return new int[] { CFSTR_INETURLID };
046:            }
047:
048:            public String[] getTypeNames() {
049:
050:                return new String[] { CFSTR_INETURL };
051:            }
052:
053:            @Override
054:            public TransferData[] getSupportedTypes() {
055:                return super .getSupportedTypes();
056:            }
057:
058:            @SuppressWarnings("unchecked")
059:            @Override
060:            public void javaToNative(Object object, TransferData transferData) {
061:
062:                startTime = System.currentTimeMillis();
063:                if (object instanceof  IStructuredSelection) {
064:                    IStructuredSelection selection = (IStructuredSelection) object;
065:                    List<Object> elements = new ArrayList<Object>();
066:                    for (Iterator<Object> iter = selection.iterator(); iter
067:                            .hasNext();) {
068:                        elements.add(iter.next());
069:                    }
070:                    this .object = elements.toArray();
071:                }
072:                this .object = object;
073:                if (transferData != null) {
074:                    super .javaToNative(String.valueOf(startTime).getBytes(),
075:                            transferData);
076:                }
077:            }
078:
079:            /**
080:             * This implementation of <code>nativeToJava</code> converts a platform
081:             * specific representation of a URL and optionally, a title to a java
082:             * <code>String[]</code>. For additional information see
083:             * <code>Transfer#nativeToJava</code>.
084:             * 
085:             * @param transferData
086:             *            the platform specific representation of the data to be been
087:             *            converted
088:             * @return a java <code>String[]</code> containing a URL and optionally a
089:             *         title if the conversion was successful; otherwise null
090:             */
091:            public Object nativeToJava(TransferData transferData) {
092:
093:                byte[] bytes = (byte[]) super .nativeToJava(transferData);
094:                if (bytes == null)
095:                    return null;
096:
097:                try {
098:                    long startTime = Long.valueOf(new String(bytes))
099:                            .longValue();
100:                    return this .startTime == startTime ? object : null;
101:                } catch (NumberFormatException exception) {
102:                    InputStreamReader reader = new InputStreamReader(
103:                            new ByteArrayInputStream(bytes));
104:                    StringBuffer buf = new StringBuffer();
105:                    char[] chars = new char[bytes.length / 2];
106:                    int read = 0;
107:                    try {
108:                        read = reader.read(chars);
109:                    } catch (IOException e) {
110:                        UiPlugin.log("Error reading transfer data", e); //$NON-NLS-1$
111:                    }
112:                    buf.append(chars, 0, read);
113:                    return buf.toString().trim();
114:                }
115:
116:            }
117:
118:            public boolean validate(Object object) {
119:                return true;
120:            }
121:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.