Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/BuddiesView.java13
-rw-r--r--plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/dnd/DNDTransfer.java96
2 files changed, 109 insertions, 0 deletions
diff --git a/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/BuddiesView.java b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/BuddiesView.java
index b62bc43fee..62bf9e3832 100644
--- a/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/BuddiesView.java
+++ b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/BuddiesView.java
@@ -16,6 +16,9 @@ import org.eclipse.net4j.buddies.protocol.ICollaboration;
import org.eclipse.net4j.util.container.ContainerUtil;
import org.eclipse.net4j.util.container.IContainer;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+
public class BuddiesView extends SessionManagerView
{
public BuddiesView()
@@ -29,6 +32,16 @@ public class BuddiesView extends SessionManagerView
}
@Override
+ protected Control createControl(Composite parent)
+ {
+ Control control = super.createControl(parent);
+ // Transfer[] transfers = new Transfer[] { GadgetTransfer.getInstance() };
+ // getViewer().addDragSupport(DND.DROP_LINK, transfers, new GadgetDragListener(viewer));
+
+ return control;
+ }
+
+ @Override
protected void doubleClicked(Object object)
{
if (getSession() != null && object instanceof IBuddy)
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
new file mode 100644
index 0000000000..bee568ad53
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/dnd/DNDTransfer.java
@@ -0,0 +1,96 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2007 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;
+
+ private 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 };
+ }
+
+ @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;
+} \ No newline at end of file

Back to the top