* @param ie Event
* @return The event status code
*/
public JaspiraEventHandlerCode popup(InteractionEvent ie)
{
Item item = null;
if (ie.isDataFlavorSupported(ClientFlavors.MODEL))
{
item = (Item) ie.getSafeTransferData(ClientFlavors.MODEL);
}
else if (ie.isDataFlavorSupported(ClientFlavors.ITEM))
{
item = (Item) ie.getSafeTransferData(ClientFlavors.ITEM);
}
else if (ie.isDataFlavorSupported(ClientFlavors.ACTIVITY_NODE))
{
// Activity node
ActivityNode activityNode = (ActivityNode) ie.getSafeTransferData(ClientFlavors.ACTIVITY_NODE);
// Create a dummy item, which can hold the activity handler definition,
// so we can start the activity handler source code generator.
item = new JavaActivityItemImpl();
item.setModel(activityNode.getOwningModel());
// Copy the properties of the handler definition from the node to the dummy item
int syncFlags = ItemSynchronization.SYNC_ALL;
((ItemProvider) activityNode).copyToItem(item, syncFlags);
}
else
return EVENT_IGNORED;
if (item != null)
{
if (first)
{
first = false;
}
else
{
// Reload the generator info in case it was modified (for generator development only!)
// TODO Feature 5 Auto-reload of generator definitions should be a modeler option
// GeneratorMgr.getInstance().reload();
}
// Check if there are any generators defined for this item type that operate on an existing item
List list = GeneratorMgr.getInstance().getGenerators(item.getItemType(), false);
if (list != null)
{
// Instantiate the generate wizard
GeneratorWizard wizard = new GeneratorWizard(getPluginResourceCollection(), item);
// Use the item's icon as wizard icon
ImageIcon icon = (ImageIcon) ItemIconMgr.getInstance().getIcon(item.getItemType(), FlexibleSize.HUGE);
wizard.setDefaultWizardImage(icon);
// Create the selection page displaying all available
// generators and add it to the wizard
WizardSelectionPage selectionPage = new WizardSelectionPage(wizard);