cz.cuni.pogamut.shed.presenter
Class AbstractAcceptAction<DROPPED extends cz.cuni.amis.pogamut.sposh.elements.PoshElement,TARGET extends cz.cuni.amis.pogamut.sposh.elements.PoshElement>

Package class diagram package AbstractAcceptAction
java.lang.Object
  extended by cz.cuni.pogamut.shed.presenter.AbstractAcceptAction<DROPPED,TARGET>
Type Parameters:
DROPPED - We are dragging PoshElement of DROPPED type. This is the source.
TARGET - Type of PoshElement this action drops to, it is destination element.
All Implemented Interfaces:
org.netbeans.api.visual.action.AcceptProvider

public abstract class AbstractAcceptAction<DROPPED extends cz.cuni.amis.pogamut.sposh.elements.PoshElement,TARGET extends cz.cuni.amis.pogamut.sposh.elements.PoshElement>
extends Object
implements org.netbeans.api.visual.action.AcceptProvider

Ancestor for accept providers of widgets. This action takes an element of type TARGET and performs some sort of accept action (accepting drag and drop) when user drops an element of type DROPPED on it. The performAction(cz.cuni.amis.pogamut.sposh.elements.PoshElement) will perform action when user drops transferable with correct data flavor. The action will take dataNode which is accepting the dropped element and does something.

Author:
Honza Havlicek

Field Summary
protected  DataFlavor dataFlavor
          Data flavor this action desires in order to accept the dropped Transferable.
protected  TARGET dataNode
          Node that is accepting dropped node.
 
Constructor Summary
protected AbstractAcceptAction(DataFlavor dataFlavor, TARGET dataNode)
          Create an abstract action in the widget widget that will do something to data node dataNode when transferable of same data flavor as dataFlavor is dropped onto widget.
 
Method Summary
 void accept(org.netbeans.api.visual.widget.Widget widget, Point point, Transferable transferable)
          Basically take the data from @transferable (use our getDataFlavor()) and perform the action (performAction(cz.cuni.amis.pogamut.sposh.elements.PoshElement)).
protected  void displayMessage(String message, int messageType)
          Display message using NotifyDescriptor.
 DataFlavor getDataFlavor()
          Get data flavor this accept provider accepts.
 org.netbeans.api.visual.action.ConnectorState isAcceptable(org.netbeans.api.visual.widget.Widget arg0, Point arg1, Transferable transferable)
          Does @transferable support dataFlavor?
abstract  void performAction(DROPPED droppedData)
          When deriving from this widget, implement what should actually be done in this function.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dataFlavor

protected DataFlavor dataFlavor
Data flavor this action desires in order to accept the dropped Transferable.


dataNode

protected TARGET extends cz.cuni.amis.pogamut.sposh.elements.PoshElement dataNode
Node that is accepting dropped node.

Constructor Detail

AbstractAcceptAction

protected AbstractAcceptAction(DataFlavor dataFlavor,
                               TARGET dataNode)
Create an abstract action in the widget widget that will do something to data node dataNode when transferable of same data flavor as dataFlavor is dropped onto widget.

Parameters:
dataFlavor - data flavor we are accepting, no multiple flavors accepted
dataNode - data node that will be used somehow when accept action happens.
widget - widget transferable is dropped onto for this accept provider to work.
Method Detail

isAcceptable

public final org.netbeans.api.visual.action.ConnectorState isAcceptable(org.netbeans.api.visual.widget.Widget arg0,
                                                                        Point arg1,
                                                                        Transferable transferable)
Does @transferable support dataFlavor?

Specified by:
isAcceptable in interface org.netbeans.api.visual.action.AcceptProvider
Parameters:
transferable - Transferable that is being tested if it supports the data flavor that is accepted by this action.
Returns:
True if transferable can be dropped on this.

accept

public final void accept(org.netbeans.api.visual.widget.Widget widget,
                         Point point,
                         Transferable transferable)
Basically take the data from @transferable (use our getDataFlavor()) and perform the action (performAction(cz.cuni.amis.pogamut.sposh.elements.PoshElement)). If @transferable is empty (its dataflavored data is null), don't perform the action, only log it.

Specified by:
accept in interface org.netbeans.api.visual.action.AcceptProvider
Parameters:
widget - Not used, widget at which was the transferable dropped
point - Not used, location at which was the transferable dropped, local coordinatin system of the @widget.
transferable - Transferable used to get the data.

getDataFlavor

public final DataFlavor getDataFlavor()
Get data flavor this accept provider accepts.

Returns:
data flavour passed in the constructor

performAction

public abstract void performAction(DROPPED droppedData)
When deriving from this widget, implement what should actually be done in this function. Basically the accepting element is supposed to accept the

Parameters:
droppedData - Object that was dropped to the accepting element (in case of drag and drop, data that was stored in the Transferable).

displayMessage

protected final void displayMessage(String message,
                                    int messageType)
Display message using NotifyDescriptor.

Parameters:
message - Message to display
messageType - Type of message, from NotifyDescriptor.*_MESSAGE


Copyright © 2015 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.