Flex Scheduling Framework:ScheduleViewer Basic Sample
From Adobe Labs
This sample shows how to setup a ScheduleViewer with default values and 3 entries.
To render schedule entries the dataProvider property by default accepts a collection of com.adobe.ac.controls.scheduleClasses.IScheduleEntry objects. ScheduleViewerSample1 uses com.adobe.ac.controls.scheduleClasses.SimpleScheduleEntry, an implementation of IScheduleEntry.
The dataProvider item gets passed into the entryRenderer, which by default is com.adobe.ac.controls.scheduleClasses.renderers.GradientScheduleEntryRenderer.mxml. You can customize various styles of the entry renderer via the entryStyleName style of ScheduleViewer. In ScheduleViewerSample1, we use the default styles but there is an example CSS inlcuded. Try to assign the included myEntryStyle class selector to the entryStyleName style property of the ScheduleViewer instance.
In addition, for maximum flexibility, you can provide a fully customized entry renderer via the entryRenderer property. The entryRenderer has to implement com.adobe.ac.controls.scheduleClasses.renderers.IScheduleEntryRenderer.
ScheduleViewer layouts the entries according to the rules of a layout manager. You can specify the layout manager with the entryLayout property. Furthermore, the layout manager can handle any changes that occur to the data provider as any updates, additions, deletions etc to the entries.
By default, the com.adobe.ac.controls.scheduleClasses.layout.BestFitLayout is used, which assigns entries to the top most rows without causing any overlaps between entries.
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (c) 2006. Adobe Systems Incorporated.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of Adobe Systems Incorporated nor the names of its
contributors may be used to endorse or promote products derived from this
software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
@ignore
-->
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:controls="com.adobe.ac.controls.*"
creationComplete="onCreationComplete();">
<mx:Style>
.myEntryStyle {
fillAlphas: 1, 1;
fillColors: #ff0000, #990000;
timeStyleName: "myTimeStyle";
color: #000000;
}
.myTimeStyle {
fontSize: 9;
fontWeight: bold;
color: #ffff00;
}
</mx:Style>
<mx:Script>
<![CDATA[
import com.adobe.ac.controls.scheduleClasses.SimpleScheduleEntry;
import com.adobe.ac.util.DateUtil;
import mx.collections.ArrayCollection;
[Bindable]
private var dataProvider : ArrayCollection;
[Bindable]
private var startDate : Date;
[Bindable]
private var endDate : Date;
private function onCreationComplete() : void
{
setTimeframe();
initDataProvider();
}
private function setTimeframe() : void
{
startDate = DateUtil.clearTime( new Date() );
endDate = getEndDate( startDate );
}
private function getEndDate( startDate : Date ) : Date
{
var duration : Number = DateUtil.DAY_IN_MILLISECONDS * 1;
var endDate : Date = new Date( startDate.getTime() + duration );
return endDate;
}
private function initDataProvider() : void
{
var entries : ArrayCollection = new ArrayCollection();
var entry : SimpleScheduleEntry = new SimpleScheduleEntry();
entry.startDate = DateUtil.clearTime( new Date() );
entry.endDate = new Date( entry.startDate.getTime() + DateUtil.HOUR_IN_MILLISECONDS * 5 );
entry.label = "Our first entry!";
entries.addItem( entry );
entry = new SimpleScheduleEntry();
entry.startDate = DateUtil.setTime( new Date(), DateUtil.HOUR_IN_MILLISECONDS );
entry.endDate = new Date( entry.startDate.getTime() + DateUtil.HOUR_IN_MILLISECONDS * 15 );
entry.label = "Our second entry!";
entries.addItem( entry );
entry = new SimpleScheduleEntry();
entry.startDate = DateUtil.setTime( new Date(), DateUtil.HOUR_IN_MILLISECONDS * 13 );
entry.endDate = new Date( entry.startDate.getTime() + DateUtil.HOUR_IN_MILLISECONDS * 5 );
entry.label = "Our third entry!";
entries.addItem( entry );
dataProvider = entries;
}
]]>
</mx:Script>
<controls:ScheduleViewer id="scheduleViewer"
width="600" height="400"
dataProvider="{ dataProvider }"
startDate="{ startDate }" endDate="{ endDate }" />
</mx:Application>
