Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
titleLoading Community Save Data
public function onLoadWidgetOptions( widgetOptions:WidgetSaveObject ):void
{               
    if ( widgetOptions != null )
    {
        //this holds a users last map 
        if ( widgetOptions.userSave != null )
        {
              //...code from above here
        }
		if ( widgetOptions.communitySave != null )
		{
			//Any shares you have access to with type widgetSave will be provided here
			//Here we will be given a map of community ids to shares e.g. { "commid12345": {"key1":"value1"}, "commid67890":{"anotherkey",["blue","green","red"]}}
			for ( var commid:String in widgetOptions.communitySave )
			{
				//this is the object saved in the share for community <commid>
				//Now you can do what you want with it (we printed it out)
				var community_save_object = widgetOptions.communitySave[commid];
				for ( var key:String in community_save_object )
				{					
					trace("CommId: " + commid + " key: " + key + " value: " + community_save_object[key]);
					
				}
			}
		}
 	}
}

Widget Drag and Drop

A generic drag and drop interface is implemented for sending document, entities, and associations between widgets.  To accept these things a widget only needs to implement an event handler for the widgetDrop event on WidgetModule

Code Block
<components:WidgetModule xmlns:fx="http://ns.adobe.com/mxml/2009"
    xmlns:components="com.ikanow.infinit.e.widget.library.components.*"
    xmlns:s="library://ns.adobe.com/flex/spark"
    xmlns:mx="library://ns.adobe.com/flex/mx" 
    implements="com.ikanow.infinit.e.widget.library.widget.IWidget"
    widgetDrop="widgetmodule1_widgetDropHandler(event)">
	
	<fx:Script>
        <![CDATA[
			import com.ikanow.infinit.e.widget.library.events.WidgetDropEvent;

			protected function widgetmodule1_widgetDropHandler(event:WidgetDropEvent):void
            {                
                trace("Ents: " + event.entities.length);
                trace("Assocs: " + event.associations.length);
                trace("Docs: " + event.documents.length);                    
            }
		]]>
    </fx:Script>
</components:WidgetModule>

The WidgetDropEvent object holds 3 anonymous arrays: entities,associations,documents, any/all of these may have data in them.

 

To send dragged items to another widget, dispatch an drag event with the dataformat using WidgetDragUtil.WIDGET_DRAG_FORMAT:

Code Block
protected function widgetheaderdragimage1_mouseDownHandler(event:MouseEvent):void
{
	var docs:Array = new Array();
	for each ( var doc:Object in docList.selectedItems )
	{                    
		docs.push(doc);
	}                
	var dragObject:WidgetDragObject = new WidgetDragObject();
	dragObject.documents = new ArrayCollection(docs);                
	var ds:DragSource = new DragSource();
	ds.addData(dragObject, WidgetDragUtil.WIDGET_DRAG_FORMAT );           
	DragManager.doDrag(dragImage, ds, event);
}

 

A widget header icon has been supplied in the widget library to allow uniformity between widgets, this icon can be added to a widget by adding it to the header block on all widgets (and implement the mousedown handler as shown above, supplying your specific data):

Code Block
<components:WidgetHeaderDragImage id="dragImage" paddingLeft="5" mouseDown="widgetheaderdragimage1_mouseDownHandler(event)" toolTip="Drag this to another widget/the query bar to send selected documents" />

When added to a widget it will look like:

Image Added