at.spardat.xma.event.swt.XMADragSourceAdapter Maven / Gradle / Ivy
/*
* @(#) $Id: XMADragSourceAdapter.java 2605 2008-06-20 13:21:29Z gub $
*
* Copyright 2004/2005 by SPARDAT Sparkassen-Datendienst Ges.m.b.H.,
* A-1110 Wien, Geiselbergstr.21-25.
* All rights reserved.
*
*/
package at.spardat.xma.event.swt;
import org.eclipse.swt.dnd.DragSourceEvent;
import org.eclipse.swt.dnd.DragSourceListener;
import at.spardat.xma.page.IDialogPage;
import at.spardat.xma.page.PageClient;
/**
* DragSourceAdapter for DragSourceListener.
* It wraps event-disabling code of XMA around your event handling code.
* (see package description>)
*/
public class XMADragSourceAdapter implements DragSourceListener {
PageClient page;
/**
*
* @param page The page containing the widget on which you want to listen for events.
*/
public XMADragSourceAdapter(PageClient page) {
this.page=page;
}
/**
* Returns the page passed to the contructor
*/
public PageClient getPage() {
return page;
}
/**
* The drop has successfully completed(mouse up over a valid target) or has been terminated (such as hitting
* the ESC key). Perform cleanup such as removing data from the source side on a successful move operation.
*
* The following fields in the DragSourceEvent apply:
*
* - (in)widget
*
- (in)time
*
- (in)doit
*
- (in)detail
*
*
* @param event the information associated with the drag finished event
*
* @see DragSourceEvent
*/
public void dragFinishedImpl(DragSourceEvent event){
}
/**
* The method called by SWT whenever the corresponding event happends.
* To not overload this method, overload {@link #dragFinishedImpl(DragSourceEvent)}
* instead.
* @param event The event send by SWT.
*/
final public void dragFinished(DragSourceEvent event) {
if(!page.isEventsEnabled()) return;
IDialogPage dialog = page.getDialogPage();
try {
dialog.setEventsEnabled(false);
dragFinishedImpl(event);
} catch (Exception exc) {
page.showException(exc);
} finally {
dialog.setEventsEnabled(true);
}
}
/**
* The data is required from the drag source.
*
* The following fields in the DragSourceEvent apply:
*
* - (in)widget
*
- (in)time
*
- (in)dataType - the type of data requested.
*
- (out)data - the application inserts the actual data here (must match the dataType)
*
*
* @param event the information associated with the drag set data event
*
* @see DragSourceEvent
*/
public void dragSetDataImpl(DragSourceEvent event) {
}
/**
* The method called by SWT whenever the corresponding event happends.
* To not overload this method, overload {@link #dragSetDataImpl(DragSourceEvent)}
* instead.
* @param event The event send by SWT.
*/
final public void dragSetData(DragSourceEvent event) {
if(!page.isEventsEnabled()) return;
IDialogPage dialog = page.getDialogPage();
try {
dialog.setEventsEnabled(false);
dragSetDataImpl(event);
} catch (Exception exc) {
page.showException(exc);
} finally {
dialog.setEventsEnabled(true);
}
}
/**
* The user has begun the actions required to drag the widget. This event gives the application
* the chance to decide if a drag should be started.
*
* The following fields in the DragSourceEvent apply:
*
* - (in)widget
*
- (in)time
*
- (in,out)doit
*
*
* @param event the information associated with the drag start event
*
* @see DragSourceEvent
*/
public void dragStartImpl(DragSourceEvent event) {
}
/**
* The method called by SWT whenever the corresponding event happends.
* To not overload this method, overload {@link #dragStartImpl(DragSourceEvent)}
* instead.
* @param event The event send by SWT.
*/
final public void dragStart(DragSourceEvent event) {
if(!page.isEventsEnabled()) return;
IDialogPage dialog = page.getDialogPage();
try {
dialog.setEventsEnabled(false);
dragStartImpl(event);
} catch (Exception exc) {
page.showException(exc);
} finally {
dialog.setEventsEnabled(true);
}
}
}