X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.ui%2Fsrc%2Forg%2Fsimantics%2Fui%2Fdnd%2FLocalSelectionDragSourceListener.java;h=3bd5ee5ef2fda38dd129a054ec60ae691c636ce9;hb=HEAD;hp=20272e9468daec2da8bb0a685ca7cac471311f34;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.ui/src/org/simantics/ui/dnd/LocalSelectionDragSourceListener.java b/bundles/org.simantics.ui/src/org/simantics/ui/dnd/LocalSelectionDragSourceListener.java index 20272e946..3bd5ee5ef 100644 --- a/bundles/org.simantics.ui/src/org/simantics/ui/dnd/LocalSelectionDragSourceListener.java +++ b/bundles/org.simantics.ui/src/org/simantics/ui/dnd/LocalSelectionDragSourceListener.java @@ -1,70 +1,70 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 Association for Decentralized Information Management - * in Industry THTH ry. - * 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: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.ui.dnd; - -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.swt.dnd.DragSourceEvent; -import org.eclipse.swt.dnd.DragSourceListener; -import org.eclipse.swt.dnd.DropTargetListener; - -/** - * An SWT drag source listener that provides the specified selection provider's - * {@link ISelection} as the dragged data to {@link DropTargetListener}s. - * - *

- * Only guaranteed to work with {@link LocalObjectTransfer} which will only work - * within a single application. - * - * @author Tuukka Lehtonen - */ -public class LocalSelectionDragSourceListener implements DragSourceListener { - - ISelectionProvider selectionProvider; - ISelection selection; - - public LocalSelectionDragSourceListener(ISelectionProvider selectionProvider) { - this.selectionProvider = selectionProvider; - } - - public ISelection getSelection() { - return selection; - } - - @Override - public void dragFinished(DragSourceEvent event) { - //System.out.println("SOURCE FINISH " + event); - LocalObjectTransfer.getTransfer().clear(); - selection = null; - } - - @Override - public void dragSetData(DragSourceEvent event) { - //System.out.println("SOURCE PUT " + event + " " + selection); - event.data = selection; - LocalObjectTransfer.getTransfer().setObject(selection); - - } - - @Override - public void dragStart(DragSourceEvent event) { - //System.out.println("SOURCE START " + event + " " + selectionProvider.getSelection()); - selection = selectionProvider.getSelection(); - if (selection == null || selection.isEmpty()) - event.doit = false; - else { - event.doit = true; - LocalObjectTransfer.getTransfer().setObject(selection); - } - } - -} +/******************************************************************************* + * Copyright (c) 2007, 2010 Association for Decentralized Information Management + * in Industry THTH ry. + * 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: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ +package org.simantics.ui.dnd; + +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.ISelectionProvider; +import org.eclipse.swt.dnd.DragSourceEvent; +import org.eclipse.swt.dnd.DragSourceListener; +import org.eclipse.swt.dnd.DropTargetListener; + +/** + * An SWT drag source listener that provides the specified selection provider's + * {@link ISelection} as the dragged data to {@link DropTargetListener}s. + * + *

+ * Only guaranteed to work with {@link LocalObjectTransfer} which will only work + * within a single application. + * + * @author Tuukka Lehtonen + */ +public class LocalSelectionDragSourceListener implements DragSourceListener { + + ISelectionProvider selectionProvider; + ISelection selection; + + public LocalSelectionDragSourceListener(ISelectionProvider selectionProvider) { + this.selectionProvider = selectionProvider; + } + + public ISelection getSelection() { + return selection; + } + + @Override + public void dragFinished(DragSourceEvent event) { + //System.out.println("SOURCE FINISH " + event); + LocalObjectTransfer.getTransfer().clear(); + selection = null; + } + + @Override + public void dragSetData(DragSourceEvent event) { + //System.out.println("SOURCE PUT " + event + " " + selection); + event.data = selection; + LocalObjectTransfer.getTransfer().setObject(selection); + + } + + @Override + public void dragStart(DragSourceEvent event) { + //System.out.println("SOURCE START " + event + " " + selectionProvider.getSelection()); + selection = selectionProvider.getSelection(); + if (selection == null || selection.isEmpty()) + event.doit = false; + else { + event.doit = true; + LocalObjectTransfer.getTransfer().setObject(selection); + } + } + +}