B4J=true Group=Default Group ModulesStructureVersion=1 Type=Class Version=6.01 @EndOfDesignText@ 'Class module '* Copyright (c) 2008, Shlomy Gantz/BlueBrick Inc. '* 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 Shlomy Gantz Or BlueBrick Inc. 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 SHLOMY GANTZ/BLUEBRICK INC. ''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 SHLOMY GANTZ/BLUEBRICK INC. 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. Sub Class_Globals Public ABMComp As ABMCustomComponent Private Page As ABMPage Public compid As String Private Element As HTMLElement Public Visibility As String Private JavaCalls As List Private ABM As ABMaterial Private style As HTMLElement Private tasks As Map Type JSGanttTask(pID As Int, pName As String, pStart As String, pEnd As String, pClass As String, pLink As String, pMile As Int, pRes As String, pComp As Int, pGroup As Int, _ pParent As Int, pOpen As Int, pDepend As String, pCaption As String, pNotes As String) Type JSGanttFormatT(hour As String, day As String, week As String,month As String, quarter As String) Public JSGanttFormat As JSGanttFormatT Public GanttFormat As String Type JSGanttTaskTypeT(NormalTask As Int, StandardGroupTask As Int, CombinedGroupTask As Int) Public JSGanttTaskType As JSGanttTaskTypeT Type JSGanttCaptionTypeT(None As String,Caption As String,Resource As String,Duration As String,Complete As String) Public JSGanttCaptionType As JSGanttCaptionTypeT Public CaptionType As String Type JSGanttDateInputFormatT(yyyy_mm_dd As String, dd_mm_yyyy As String, mm_dd_yyyy As String) Public DateInputFormat As String Public JSGanttDateInputFormat As JSGanttDateInputFormatT Public RowHeight As Int Public DateTaskTableDisplayFormat As String Public DateTaskDisplayFormat As String Type JSGanttDateOutputFormatT(yyyy_mm_dd As String, dd_mm_yyyy As String, mm_dd_yyyy As String,yyyy_mm_dd_day As String, dd_mm_yyyy_day As String, mm_dd_yyyy_day As String, _ yyyy_mon_dd As String, dd_mon_yyyy As String, mon_dd_yyyy As String,yyyy_mon_dd_day As String, dd_mon_yyyy_day As String, mon_dd_yyyy_day As String) Public JSGanttDateOutputFormat As JSGanttDateOutputFormatT Public ShowResource As Boolean Public ShowDuration As Boolean Public ShowPercentComplete As Boolean Public ShowStartDate As Boolean Public ShowEndDate As Boolean Public ShowEndWeekDate As Boolean Public WeekMinorDateDisplayFormat As String Public DayMajorDateDisplayFormat As String Public DateInputFormat As String Type JSGanttColorT(Black As String, Blue As String,Red As String,Green As String,Yellow As String,Purple As String,Pink As String,MileStone As String) Public JSGanttColor As JSGanttColorT End Sub 'create a new task private Sub CreateTask() As JSGanttTask Dim tt As JSGanttTask tt.Initialize tt.pID = -1 tt.pName = "" tt.pStart = "" tt.pEnd = "" tt.pLink = "" tt.pClass="" tt.pMile = 0 tt.pRes = "" tt.pComp = 0 tt.pGroup = 1 tt.pParent = 0 tt.pOpen = 0 tt.pDepend = "" tt.pCaption = "" tt.pNotes = "" Return tt End Sub 'Initializes the object. You can add parameters to this method if needed. Public Sub Initialize(InternalPage As ABMPage, ID As String) style = style.CreateCSSClass("jsgantt") ABMComp.Initialize("ABMComp", Me, InternalPage, ID,style.BuildStyleClasses("")) ' InternalPage.InjectCSS(style.BuildStyleClasses) Page = InternalPage compid = ID JavaCalls.Initialize Element.Initialize(ID,"div") Visibility= "" JSGanttFormat.Initialize JSGanttFormat.day = "day" JSGanttFormat.hour = "hour" JSGanttFormat.month = "month" JSGanttFormat.quarter = "quarter" JSGanttFormat.week = "week" JSGanttTaskType.Initialize JSGanttTaskType.CombinedGroupTask = 2 JSGanttTaskType.NormalTask = 0 JSGanttTaskType.StandardGroupTask = 1 DateTime.DateFormat = "yyyy-MM-dd" DateTime.TimeFormat = "HH:mm" GanttFormat = JSGanttFormat.day JSGanttCaptionType.Initialize JSGanttCaptionType.Caption = "Caption" JSGanttCaptionType.Complete = "Complete" JSGanttCaptionType.Duration = "Duration" JSGanttCaptionType.None = "None" JSGanttCaptionType.Resource = "Resource" CaptionType = JSGanttCaptionType.Complete JSGanttDateInputFormat.Initialize JSGanttDateInputFormat.dd_mm_yyyy = "dd/mm/yyyy" JSGanttDateInputFormat.mm_dd_yyyy = "mm/dd/yyyy" JSGanttDateInputFormat.yyyy_mm_dd = "yyyy-mm-dd" DateInputFormat = JSGanttDateInputFormat.yyyy_mm_dd JSGanttDateOutputFormat.Initialize JSGanttDateOutputFormat.dd_mm_yyyy = "dd/mm/yyyy" JSGanttDateOutputFormat.dd_mm_yyyy_day = "dd/mm/yyyy,day" JSGanttDateOutputFormat.mm_dd_yyyy = "mm/dd/yyyy" JSGanttDateOutputFormat.mm_dd_yyyy_day ="mm/dd/yyyy,day" JSGanttDateOutputFormat.yyyy_mm_dd = "yyyy-mm-dd" JSGanttDateOutputFormat.yyyy_mm_dd_day = "yyyy-mm-dd,day" JSGanttDateOutputFormat.yyyy_mon_dd = "yyyy-mon-dd" JSGanttDateOutputFormat.dd_mon_yyyy = "dd-mon-yyyy" JSGanttDateOutputFormat.mon_dd_yyyy = "mon-dd-yyyy" JSGanttDateOutputFormat.yyyy_mon_dd_day = "yyyy-mon-dd,day" JSGanttDateOutputFormat.dd_mon_yyyy_day = "dd-mon-yyyy,day" JSGanttDateOutputFormat.mon_dd_yyyy_day = "mon-dd-yyyy,day" RowHeight = 20 DateTaskTableDisplayFormat = JSGanttDateOutputFormat.yyyy_mm_dd_day DateTaskDisplayFormat = JSGanttDateOutputFormat.yyyy_mm_dd_day ShowResource = True ShowDuration = True ShowPercentComplete = True ShowStartDate = True ShowEndDate = True ShowEndWeekDate = False WeekMinorDateDisplayFormat = "dd mon" DayMajorDateDisplayFormat = "mon yyyy - Week ww" DateInputFormat = "yyyy-mm-dd" JSGanttColor.Initialize JSGanttColor.Black = "ggroupblack" JSGanttColor.Blue = "gtaskblue" JSGanttColor.Green = "gtaskgreen" JSGanttColor.Pink = "gtaskpink" JSGanttColor.Purple = "gtaskpurple" JSGanttColor.Red = "gtaskred" JSGanttColor.Yellow = "gtaskyellow" JSGanttColor.MileStone = "gmilestone" Clear End Sub 'clear the tasks Sub Clear tasks.Initialize tasks.clear End Sub 'return the html portion of the component private Sub HTML As String Element.ID = compid Element.MaterialVisibility(Visibility) Element.AddStyleAttribute("position","relative") Element.AddClass("gantt") Return Element.html End Sub Sub AddProject(ProjectName As String) As MashJSGantt AddTask(0,1,ProjectName,"","",0,"","") Return Me End Sub Sub AddTask(ParentTaskID As Int, TaskID As Int, TaskName As String, StartDate As String, EndDate As String, PercentComplete As Int, Resource As String, Dependencies As String) As MashJSGantt AddTask1(TaskID,TaskName,StartDate,EndDate,"gtaskblue","",False,Resource,PercentComplete,JSGanttTaskType.NormalTask,ParentTaskID,False,Dependencies,"","") 'check the parent If ParentTaskID <> 0 Then Dim pType As Int = GetTaskType(ParentTaskID) Select Case pType Case JSGanttTaskType.CombinedGroupTask,JSGanttTaskType.StandardGroupTask SetStartDate(ParentTaskID,"") SetEndDate(ParentTaskID,"") SetBlack(ParentTaskID) SetPercentComplete(ParentTaskID,0) Case JSGanttTaskType.NormalTask SetTaskType(ParentTaskID,JSGanttTaskType.StandardGroupTask) SetBlack(ParentTaskID) SetStartDate(ParentTaskID,"") SetEndDate(ParentTaskID,"") SetPercentComplete(ParentTaskID,0) End Select End If Return Me End Sub Sub SetNormalTask(TaskID As Int) As MashJSGantt SetTaskType(TaskID,JSGanttTaskType.NormalTask) Return Me End Sub Sub SetStandardGroupTask(TaskID As Int) As MashJSGantt SetTaskType(TaskID,JSGanttTaskType.StandardGroupTask) Return Me End Sub Sub SetCombinedGroupTask(TaskID As Int) As MashJSGantt SetTaskType(TaskID,JSGanttTaskType.CombinedGroupTask) Return Me End Sub Sub GetTaskType(TaskID As Int) As Int Dim tKey As String = "task-" & TaskID If tasks.ContainsKey(tKey) Then Dim tt As JSGanttTask = tasks.Get(tKey) Return tt.pGroup Else Return -1 End If End Sub Sub SetStartDate(TaskID As Int, StartDate As String) As MashJSGantt Dim tKey As String = "task-" & TaskID If tasks.ContainsKey(tKey) Then Dim tt As JSGanttTask = tasks.Get(tKey) tt.pStart = StartDate tasks.Put(tKey,tt) End If Return Me End Sub Sub SetEndDate(TaskID As Int, EndDate As String) As MashJSGantt Dim tKey As String = "task-" & TaskID If tasks.ContainsKey(tKey) Then Dim tt As JSGanttTask = tasks.Get(tKey) tt.pEnd = EndDate tasks.Put(tKey,tt) End If Return Me End Sub Sub SetTaskType(TaskID As Int, TaskType As String) As MashJSGantt Dim tKey As String = "task-" & TaskID If tasks.ContainsKey(tKey) Then Dim tt As JSGanttTask = tasks.Get(tKey) tt.pGroup = TaskType tasks.Put(tKey,tt) End If Return Me End Sub Sub SetDependencies(TaskID As Int, Dependencies As String) As MashJSGantt Dim tKey As String = "task-" & TaskID If tasks.ContainsKey(tKey) Then Dim tt As JSGanttTask = tasks.Get(tKey) tt.pDepend = Dependencies tasks.Put(tKey,tt) End If Return Me End Sub Sub SetCaption(TaskID As Int, Caption As String) As MashJSGantt Dim tKey As String = "task-" & TaskID If tasks.ContainsKey(tKey) Then Dim tt As JSGanttTask = tasks.Get(tKey) tt.pCaption = Caption tasks.Put(tKey,tt) End If Return Me End Sub Sub SetNotes(TaskID As Int, Notes As String) As MashJSGantt Dim tKey As String = "task-" & TaskID If tasks.ContainsKey(tKey) Then Dim tt As JSGanttTask = tasks.Get(tKey) tt.pNotes = Notes tasks.Put(tKey,tt) End If Return Me End Sub Sub SetMileStone(TaskID As Int, MileStone As Boolean) As MashJSGantt Dim tKey As String = "task-" & TaskID If tasks.ContainsKey(tKey) Then Dim tt As JSGanttTask = tasks.Get(tKey) tt.pMile = MashPlugIns.iif(MileStone,1,0) tasks.Put(tKey,tt) If MileStone = True Then SetColor(TaskID,JSGanttColor.MileStone) End If Return Me End Sub Sub SetParentTask(TaskID As Int, ParentTaskID As Int) As MashJSGantt Dim tKey As String = "task-" & TaskID If tasks.ContainsKey(tKey) Then Dim tt As JSGanttTask = tasks.Get(tKey) tt.pParent = ParentTaskID tasks.Put(tKey,tt) End If Return Me End Sub Sub SetResource(TaskID As Int, Resource As String) As MashJSGantt Dim tKey As String = "task-" & TaskID If tasks.ContainsKey(tKey) Then Dim tt As JSGanttTask = tasks.Get(tKey) tt.pRes = Resource tasks.Put(tKey,tt) End If Return Me End Sub Sub SetPercentComplete(TaskID As Int, PercentComplete As Int) As MashJSGantt Dim tKey As String = "task-" & TaskID If tasks.ContainsKey(tKey) Then Dim tt As JSGanttTask = tasks.Get(tKey) tt.pComp = PercentComplete tasks.Put(tKey,tt) End If Return Me End Sub Sub SetColor(TaskID As Int, Color As String) As MashJSGantt Dim tKey As String = "task-" & TaskID If tasks.ContainsKey(tKey) Then Dim tt As JSGanttTask = tasks.Get(tKey) tt.pClass = Color tasks.Put(tKey,tt) End If Return Me End Sub Sub SetBlack(TaskID As Int) As MashJSGantt SetColor(TaskID,"ggroupblack") Return Me End Sub Sub SetBlue(TaskID As Int) As MashJSGantt SetColor(TaskID,"gtaskblue") Return Me End Sub Sub SetRed(TaskID As Int) As MashJSGantt SetColor(TaskID,"gtaskred") Return Me End Sub Sub SetGreen(TaskID As Int) As MashJSGantt SetColor(TaskID,"gtaskgreen") Return Me End Sub Sub SetYellow(TaskID As Int) As MashJSGantt SetColor(TaskID,"gtaskyellow") Return Me End Sub Sub SetPurple(TaskID As Int) As MashJSGantt SetColor(TaskID,"gtaskpurple") Return Me End Sub Sub SetPink(TaskID As Int) As MashJSGantt SetColor(TaskID,"gtaskpink") Return Me End Sub 'add a task to the gantt Sub AddTask1(TaskID As Int, TaskName As String, StartDate As String, EndDate As String, TaskClass As String, TaskURL As String, MileStone As Boolean, Resource As String, PercentComplete As Int, TaskType As Int, _ ParentTaskID As Int, Open As Boolean, Dependencies As String, Caption As String, Notes As String) As MashJSGantt Dim tt As JSGanttTask = CreateTask tt.pID = TaskID tt.pName = TaskName tt.pStart = StartDate tt.pEnd = EndDate tt.pClass=TaskClass tt.pLink = TaskURL tt.pMile = MashPlugIns.iif(MileStone,1,0) tt.pRes = Resource tt.pComp = PercentComplete tt.pGroup = TaskType tt.pParent = ParentTaskID tt.pOpen = MashPlugIns.iif(Open,1,0) tt.pDepend = Dependencies tt.pCaption = Caption tt.pNotes = Notes tasks.Put("task-" & TaskID,tt) Return Me End Sub 'build the tasks private Sub BuildTasks() As String Dim sb As StringBuilder sb.Initialize For Each tskKey As String In tasks.Keys Dim tt As JSGanttTask = tasks.Get(tskKey) Dim tskValue As String = $"g.AddTaskItem(new JSGantt.TaskItem(${tt.pID},'${tt.pName}','${tt.pStart}','${tt.pEnd}','${tt.pClass}','${tt.plink}',${tt.pMile},'${tt.pRes}',${tt.pComp},${tt.pgroup},${tt.pParent},${tt.pOpen},'${tt.pDepend}','${tt.pcaption}','${tt.pnotes}',g));"$ sb.Append(tskValue) Next Return sb.tostring End Sub 'refresh the gantt chart Sub Refresh ABM.ReplaceMyHTML(Page,compid,HTML) Dim script As String script = $"var g = new JSGantt.GanttChart(document.getElementById('${compid}'), '${GanttFormat}'); g.setCaptionType('${CaptionType}'); g.setDateInputFormat('${DateInputFormat}'); g.setUseSingleCell(10000); g.setFormatArr('Hour', 'Day', 'Week', 'Month', 'Quarter'); g.setQuarterColWidth(36); g.setDateInputFormat('${DateInputFormat}'); g.setRowHeight(${RowHeight}); g.setDateTaskTableDisplayFormat('${DateTaskTableDisplayFormat}'); g.setDateTaskDisplayFormat('${DateTaskDisplayFormat}'); g.setWeekMinorDateDisplayFormat('${WeekMinorDateDisplayFormat}'); g.setDayMajorDateDisplayFormat('${DayMajorDateDisplayFormat}'); g.setShowRes(${MashPlugIns.iif(ShowResource,1,0)}); g.setShowDur(${MashPlugIns.iif(ShowDuration,1,0)}); g.setShowComp(${MashPlugIns.iif(ShowPercentComplete,1,0)}); g.setShowStartDate(${MashPlugIns.iif(ShowStartDate,1,0)}); g.setShowEndDate(${MashPlugIns.iif(ShowEndDate,1,0)}); g.setShowEndWeekDate(${MashPlugIns.iif(ShowEndWeekDate,1,0)}); ${BuildTasks} g.Draw();"$ 'add to global scripts JavaCalls.Add(script) Dim scripta As String = Element.MvFromList(JavaCalls,"") If MashPlugIns.Debug = True Then Element.VerifyJavaScript(JavaCalls) Element.VerifyHTML(HTML) Page.ws.Eval(scripta, Array As String(compid)) Else Page.ws.Eval(scripta, Array As String(compid)) End If End Sub Sub ABMComp_Build(InternalPage As ABMPage,internalID As String) As String 'lets try and inject the page with css Page = InternalPage compid = internalID Return Element.GetComponentBuilder End Sub ' Is useful to run some initalisation script. Sub ABMComp_FirstRun(InternalPage As ABMPage, internalID As String) Page = InternalPage compid = internalID Refresh End Sub ' runs when a refresh is called Sub ABMComp_Refresh(InternalPage As ABMPage, internalID As String) Page = InternalPage compid = internalID End Sub ' do the stuff needed when the object is removed Sub ABMComp_CleanUp(InternalPage As ABMPage, internalID As String) End Sub