Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/dnd/DNDTransfer.java')
-rw-r--r--plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/dnd/DNDTransfer.java97
1 files changed, 0 insertions, 97 deletions
diff --git a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/dnd/DNDTransfer.java b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/dnd/DNDTransfer.java
deleted file mode 100644
index fa2aae1976..0000000000
--- a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/dnd/DNDTransfer.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2004 - 2008 Eike Stepper, Germany.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- **************************************************************************/
-package org.eclipse.net4j.util.ui.dnd;
-
-import org.eclipse.net4j.util.internal.ui.bundle.OM;
-import org.eclipse.net4j.util.io.ExtendedDataInputStream;
-import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
-import org.eclipse.swt.dnd.ByteArrayTransfer;
-import org.eclipse.swt.dnd.TransferData;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-
-/**
- * @author Eike Stepper
- */
-public abstract class DNDTransfer<TYPE> extends ByteArrayTransfer
-{
- private String typeName;
-
- private int typeID;
-
- protected DNDTransfer(String typeName)
- {
- this.typeName = typeName;
- typeID = registerType(typeName);
- }
-
- @Override
- protected int[] getTypeIds()
- {
- return new int[] { typeID };
- }
-
- @Override
- protected String[] getTypeNames()
- {
- return new String[] { typeName };
- }
-
- @SuppressWarnings("unchecked")
- @Override
- protected void javaToNative(Object object, TransferData transferData)
- {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ExtendedDataOutputStream out = new ExtendedDataOutputStream(baos);
- byte[] bytes = null;
-
- try
- {
- writeObject(out, ((TYPE)object));
- out.close();
- bytes = baos.toByteArray();
- }
- catch (Exception ex)
- {
- OM.LOG.error(ex);
- }
-
- if (bytes != null)
- {
- super.javaToNative(bytes, transferData);
- }
- }
-
- @Override
- protected Object nativeToJava(TransferData transferData)
- {
- byte[] bytes = (byte[])super.nativeToJava(transferData);
- ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
- ExtendedDataInputStream in = new ExtendedDataInputStream(bais);
-
- try
- {
- return readObject(in);
- }
- catch (Exception ex)
- {
- OM.LOG.error(ex);
- return null;
- }
- }
-
- protected abstract void writeObject(ExtendedDataOutputStream out, TYPE object) throws IOException;
-
- protected abstract TYPE readObject(ExtendedDataInputStream in) throws IOException;
-}

Back to the top