/usr/share/mozart/doc/demo/node6.html is in mozart-doc 1.4.0-8ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>Widget to display and edit tasks: TaskBoard.oz</TITLE><LINK href="ozdoc.css" rel="stylesheet" type="text/css"></HEAD><BODY><TABLE align="center" border="0" cellpadding="6" cellspacing="6" class="nav"><TR bgcolor="#DDDDDD"><TD><A href="node5.html#code.jobshop.scheduler"><< Prev</A></TD><TD><A href="jobshop.html">- Up -</A></TD><TD><A href="node7.html#code.jobshop.tools">Next >></A></TD></TR></TABLE><DIV class="unnumbered" id="code.jobshop.taskboard"><H3><A name="code.jobshop.taskboard">Widget to display and edit tasks: <CODE>TaskBoard.oz</CODE></A></H3><P class="margin"><A href="JobShop/TaskBoard.oz">Source File</A></P><P> </P><BLOCKQUOTE><PRE><SPAN class="keyword">functor</SPAN> <BR> <BR><SPAN class="keyword">import</SPAN> <BR> Tk<BR> <BR> Configure(maxJobs: MaxJobs<BR> maxSpan: MaxSpan<BR> <BR> durUnit: DurUnit<BR> durFrame: DurFrame<BR> jobDistance: JobDistance<BR> <BR> type: Courier<BR> resColors: ResColors)<BR> <BR><SPAN class="keyword">export</SPAN> <BR> <SPAN class="string">'class'</SPAN>: TaskBoard<BR> <BR><SPAN class="keyword">prepare</SPAN> <BR> <BR> <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">GetTaskName</SPAN> J T}<BR> {VirtualString<SPAN class="keyword">.</SPAN>toAtom j<SPAN class="keyword">#</SPAN>J<SPAN class="keyword">#</SPAN>t<SPAN class="keyword">#</SPAN>T}<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">GetResourceName</SPAN> R}<BR> {VirtualString<SPAN class="keyword">.</SPAN>toAtom r<SPAN class="keyword">#</SPAN>R}<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">TaskNameTo</SPAN> TN ?J ?T}<BR> S = {Atom<SPAN class="keyword">.</SPAN>toString TN}<SPAN class="keyword">.</SPAN>2<BR> <SPAN class="keyword">in</SPAN> <BR> J = {String<SPAN class="keyword">.</SPAN>toInt {List<SPAN class="keyword">.</SPAN>takeWhile S Char<SPAN class="keyword">.</SPAN>isDigit}}<BR> T = {String<SPAN class="keyword">.</SPAN>toInt {List<SPAN class="keyword">.</SPAN>dropWhile S Char<SPAN class="keyword">.</SPAN>isDigit}<SPAN class="keyword">.</SPAN>2}<BR> <SPAN class="keyword">end</SPAN> <BR> <BR><SPAN class="keyword">define</SPAN> <BR> <BR> OffX = 20<BR> OffY = JobDistance<BR> <BR> <SPAN class="keyword">class</SPAN> <SPAN class="type">Task</SPAN> <BR> <SPAN class="keyword">from</SPAN><SPAN class="type"> Tk.canvasTag</SPAN> <BR> <SPAN class="keyword">attr</SPAN> <BR> X0:0 Y0:0 X1:0<BR> Duration: 0<BR> Resource: <SPAN class="keyword">unit</SPAN> <BR> EditMode: <SPAN class="keyword">true</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">init</SPAN>(parent:P resource:R duration:D x:X y:Y)<BR> Task<SPAN class="keyword">,</SPAN> tkInit(parent:P)<BR> X0 <SPAN class="keyword"><-</SPAN> X<BR> Y0 <SPAN class="keyword"><-</SPAN> Y<BR> Duration <SPAN class="keyword"><-</SPAN> D<BR> Resource <SPAN class="keyword"><-</SPAN> R<BR> {P tk(create rectangle<BR> X Y <SPAN class="keyword">-</SPAN> DurUnit <SPAN class="keyword">div</SPAN> 2<BR> X <SPAN class="keyword">+</SPAN> D<SPAN class="keyword">*</SPAN>DurUnit <SPAN class="keyword">-</SPAN> DurFrame Y <SPAN class="keyword">+</SPAN> DurUnit <SPAN class="keyword">div</SPAN> 2<BR> fill:ResColors<SPAN class="keyword">.</SPAN>R tags:<SPAN class="keyword">self</SPAN>)}<BR> Task<SPAN class="keyword">,</SPAN> tkBind(event: <SPAN class="string">'<1>'</SPAN> <BR> args: [int(y)]<BR> action: P <SPAN class="keyword">#</SPAN> action(<SPAN class="keyword">self</SPAN>))<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">setDuration</SPAN>(D)<BR> Duration <SPAN class="keyword"><-</SPAN> D<BR> Task<SPAN class="keyword">,</SPAN> tk(coords<BR> <SPAN class="keyword">@</SPAN>X0 <SPAN class="keyword">@</SPAN>Y0 <SPAN class="keyword">-</SPAN> DurUnit <SPAN class="keyword">div</SPAN> 2<BR> <SPAN class="keyword">@</SPAN>X0 <SPAN class="keyword">+</SPAN> D<SPAN class="keyword">*</SPAN>DurUnit<SPAN class="keyword">-</SPAN>DurFrame <SPAN class="keyword">@</SPAN>Y0 <SPAN class="keyword">+</SPAN> DurUnit <SPAN class="keyword">div</SPAN> 2)<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">getDuration</SPAN>($)<BR> <SPAN class="keyword">@</SPAN>Duration<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">setResource</SPAN>(R)<BR> Resource <SPAN class="keyword"><-</SPAN> R<BR> Task<SPAN class="keyword">,</SPAN> tk(itemconfigure fill:ResColors<SPAN class="keyword">.</SPAN>R)<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">getResource</SPAN>($)<BR> <SPAN class="keyword">@</SPAN>Resource<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">move</SPAN>(ByX)<BR> X0 <SPAN class="keyword"><-</SPAN> <SPAN class="keyword">@</SPAN>X0 <SPAN class="keyword">+</SPAN> ByX<BR> Task<SPAN class="keyword">,</SPAN>tk(move ByX 0)<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">setSol</SPAN>(S)<BR> X = S <SPAN class="keyword">*</SPAN> DurUnit<BR> <SPAN class="keyword">in</SPAN> <BR> <SPAN class="keyword">if</SPAN> <SPAN class="keyword">@</SPAN>EditMode <SPAN class="keyword">then</SPAN> Task<SPAN class="keyword">,</SPAN>tk(move X<SPAN class="keyword">-@</SPAN>X0 0)<BR> <SPAN class="keyword">else</SPAN> Task<SPAN class="keyword">,</SPAN>tk(move X<SPAN class="keyword">-@</SPAN>X1 0)<BR> <SPAN class="keyword">end</SPAN> <BR> EditMode <SPAN class="keyword"><-</SPAN> <SPAN class="keyword">false</SPAN> <BR> X1 <SPAN class="keyword"><-</SPAN> X<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">setEdit</SPAN> <BR> <SPAN class="keyword">if</SPAN> <SPAN class="keyword">@</SPAN>EditMode <SPAN class="keyword">then</SPAN> <SPAN class="keyword">skip</SPAN> <SPAN class="keyword">else</SPAN> <BR> EditMode <SPAN class="keyword"><-</SPAN> <SPAN class="keyword">true</SPAN> <BR> Task<SPAN class="keyword">,</SPAN>tk(move <SPAN class="keyword">@</SPAN>X0<SPAN class="keyword">-@</SPAN>X1 0)<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <BR> <SPAN class="keyword">class</SPAN> <SPAN class="type">Job</SPAN> <BR> <SPAN class="keyword">feat</SPAN> <BR> Number<BR> Parent<BR> <SPAN class="keyword">attr</SPAN> <BR> Tasks: nil<BR> NextX: 0<BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">init</SPAN>(parent:P number:N)<BR> <SPAN class="keyword">self.</SPAN>Parent = P<BR> <SPAN class="keyword">self.</SPAN>Number = N<BR> Tasks <SPAN class="keyword"><-</SPAN> nil<BR> NextX <SPAN class="keyword"><-</SPAN> 0<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">newTask</SPAN>(resource:R duration:D)<BR> Tasks <SPAN class="keyword"><-</SPAN> {Append <SPAN class="keyword">@</SPAN>Tasks<BR> [{New Task<BR> init(parent: <SPAN class="keyword">self.</SPAN>Parent<BR> resource: R<BR> duration: D<BR> x: <SPAN class="keyword">@</SPAN>NextX<BR> y: (<SPAN class="keyword">self.</SPAN>Number <SPAN class="keyword">-</SPAN> 1) <SPAN class="keyword">*</SPAN> JobDistance)}]}<BR> NextX <SPAN class="keyword"><-</SPAN> <SPAN class="keyword">@</SPAN>NextX <SPAN class="keyword">+</SPAN> DurUnit <SPAN class="keyword">*</SPAN> D<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">DelTask</SPAN>(Ts D $)<BR> <SPAN class="keyword">case</SPAN> Ts <SPAN class="keyword">of</SPAN> nil <SPAN class="keyword">then</SPAN> nil<BR> <SPAN class="keyword">[]</SPAN> T<SPAN class="keyword">|</SPAN>Tr <SPAN class="keyword">then</SPAN> <BR> <SPAN class="keyword">if</SPAN> T<SPAN class="keyword">==</SPAN>D <SPAN class="keyword">then</SPAN> <BR> {ForAll Tr<BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> T}<BR> {T move(<SPAN class="keyword">~</SPAN>{D getDuration($)} <SPAN class="keyword">*</SPAN> DurUnit)}<BR> <SPAN class="keyword">end</SPAN>} Tr<BR> <SPAN class="keyword">else</SPAN> T<SPAN class="keyword">|</SPAN>Job<SPAN class="keyword">,</SPAN>DelTask(Tr D $)<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">deleteTask</SPAN>(D)<BR> {D tk(delete)}<BR> NextX <SPAN class="keyword"><-</SPAN> <SPAN class="keyword">@</SPAN>NextX <SPAN class="keyword">-</SPAN> {D getDuration($)} <SPAN class="keyword">*</SPAN> DurUnit<BR> Tasks <SPAN class="keyword"><-</SPAN> Job<SPAN class="keyword">,</SPAN>DelTask(<SPAN class="keyword">@</SPAN>Tasks D $)<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">SetDur</SPAN>(Ts S D)<BR> <SPAN class="keyword">case</SPAN> Ts <SPAN class="keyword">of</SPAN> nil <SPAN class="keyword">then</SPAN> <SPAN class="keyword">skip</SPAN> <BR> <SPAN class="keyword">[]</SPAN> T<SPAN class="keyword">|</SPAN>Tr <SPAN class="keyword">then</SPAN> <BR> <SPAN class="keyword">if</SPAN> T<SPAN class="keyword">==</SPAN>S <SPAN class="keyword">then</SPAN> <BR> {ForAll Tr<BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> T}<BR> {T move((D<SPAN class="keyword">-</SPAN>{S getDuration($)}) <SPAN class="keyword">*</SPAN> DurUnit)}<BR> <SPAN class="keyword">end</SPAN>}<BR> <SPAN class="keyword">else</SPAN> Job<SPAN class="keyword">,</SPAN>SetDur(Tr S D)<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">setDuration</SPAN>(T D)<BR> NextX <SPAN class="keyword"><-</SPAN> <SPAN class="keyword">@</SPAN>NextX <SPAN class="keyword">+</SPAN> (D <SPAN class="keyword">-</SPAN> {T getDuration($)}) <SPAN class="keyword">*</SPAN> DurUnit<BR> Job<SPAN class="keyword">,</SPAN>SetDur(<SPAN class="keyword">@</SPAN>Tasks T D) <BR> {T setDuration(D)}<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">setSol</SPAN>(S)<BR> {Record<SPAN class="keyword">.</SPAN>forAllInd S<BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> A S}<BR> <SPAN class="keyword">if</SPAN> A<SPAN class="keyword">\=</SPAN>pa <SPAN class="keyword">andthen</SPAN> A<SPAN class="keyword">\=</SPAN>pe <SPAN class="keyword">then</SPAN> J T <SPAN class="keyword">in</SPAN> <BR> {TaskNameTo A ?J ?T}<BR> <SPAN class="keyword">if</SPAN> <SPAN class="keyword">self.</SPAN>Number<SPAN class="keyword">==</SPAN>J <SPAN class="keyword">then</SPAN> {{Nth <SPAN class="keyword">@</SPAN>Tasks T} setSol(S)} <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN>}<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">setEdit</SPAN> <BR> {ForAll <SPAN class="keyword">@</SPAN>Tasks <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> T} {T setEdit} <SPAN class="keyword">end</SPAN>}<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">getLastSpec</SPAN>($)<BR> <SPAN class="keyword">case</SPAN> <SPAN class="keyword">@</SPAN>Tasks <SPAN class="keyword">of</SPAN> nil <SPAN class="keyword">then</SPAN> nil <SPAN class="keyword">else</SPAN> <BR> [{GetTaskName <SPAN class="keyword">self.</SPAN>Number {Length <SPAN class="keyword">@</SPAN>Tasks}}]<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">getSpec</SPAN>($)<BR> {List<SPAN class="keyword">.</SPAN>mapInd <SPAN class="keyword">@</SPAN>Tasks<BR> <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> I T}<BR> Task={GetTaskName <SPAN class="keyword">self.</SPAN>Number I}<BR> Dur ={T getDuration($)}<BR> Res ={GetResourceName {T getResource($)}}<BR> Pre = <SPAN class="keyword">if</SPAN> I<SPAN class="keyword">==</SPAN>1 <SPAN class="keyword">then</SPAN> [pa]<BR> <SPAN class="keyword">else</SPAN> [{GetTaskName <SPAN class="keyword">self.</SPAN>Number I<SPAN class="keyword">-</SPAN>1}]<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">in</SPAN> <BR> Task(dur:Dur pre:Pre res:Res)<BR> <SPAN class="keyword">end</SPAN>}<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <BR> <SPAN class="keyword">class</SPAN> <SPAN class="type">TaskBoard</SPAN> <BR> <SPAN class="keyword">from</SPAN><SPAN class="type"> Tk.canvas</SPAN> <BR> <SPAN class="keyword">feat</SPAN> <BR> Jobs Tools BackTag<BR> <SPAN class="keyword">attr</SPAN> <BR> EditMode: <SPAN class="keyword">true</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">tkInit</SPAN>(parent:P tools:T spec:Spec)<BR> <SPAN class="keyword">self.</SPAN>Jobs = {NewArray 1 MaxJobs 1}<BR> {For 1 MaxJobs 1<BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> J}<BR> {Put <SPAN class="keyword">self.</SPAN>Jobs J {New Job init(number:J parent:<SPAN class="keyword">self</SPAN>)}}<BR> <SPAN class="keyword">end</SPAN>}<BR> <SPAN class="keyword">self.</SPAN>Tools = T<BR> Tk<SPAN class="keyword">.</SPAN>canvas<SPAN class="keyword">,</SPAN> tkInit(parent: P<BR> bg: ivory<BR> width: 400<BR> height: 220<BR> bd:2 relief:sunken<BR> scrollregion: q(<SPAN class="keyword">~</SPAN>OffX<BR> <SPAN class="keyword">~</SPAN>OffY<BR> MaxSpan <SPAN class="keyword">*</SPAN> DurUnit<BR> MaxJobs <SPAN class="keyword">*</SPAN> JobDistance)<BR> xscrollincrement: 1<BR> yscrollincrement: 1)<BR> TaskBoard<SPAN class="keyword">,</SPAN> tk(xview scroll <SPAN class="keyword">~</SPAN>OffX<SPAN class="keyword">-</SPAN>6 units)<BR> TaskBoard<SPAN class="keyword">,</SPAN> tk(yview scroll <SPAN class="keyword">~</SPAN>OffY units)<BR> <SPAN class="keyword">self.</SPAN>BackTag = {New Tk<SPAN class="keyword">.</SPAN>canvasTag tkInit(parent:<SPAN class="keyword">self</SPAN>)}<BR> {For 1 MaxJobs 1<BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> J}<BR> Y = (MaxJobs <SPAN class="keyword">-</SPAN> J) <SPAN class="keyword">*</SPAN> JobDistance <BR> <SPAN class="keyword">in</SPAN> <BR> {<SPAN class="keyword">self</SPAN> tk(create text <SPAN class="keyword">~</SPAN>5 Y font:Courier<BR> text: <SPAN class="keyword">if</SPAN> J<SPAN class="keyword">==</SPAN>1 <SPAN class="keyword">then</SPAN> 10 <SPAN class="keyword">else</SPAN> 0<SPAN class="keyword">#</SPAN>(MaxJobs <SPAN class="keyword">-</SPAN> J <SPAN class="keyword">+</SPAN> 1) <SPAN class="keyword">end</SPAN> <BR> anchor:e)}<BR> <SPAN class="keyword">end</SPAN>}<BR> {For 1 MaxJobs 1<BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> J}<BR> Y = (MaxJobs <SPAN class="keyword">-</SPAN> J) <SPAN class="keyword">*</SPAN> JobDistance<BR> Y0 = Y <SPAN class="keyword">-</SPAN> JobDistance <SPAN class="keyword">div</SPAN> 2 <SPAN class="keyword">+</SPAN> 1<BR> Y1 = Y <SPAN class="keyword">+</SPAN> JobDistance <SPAN class="keyword">div</SPAN> 2 <SPAN class="keyword">-</SPAN> 1<BR> <SPAN class="keyword">in</SPAN> <BR> {<SPAN class="keyword">self</SPAN> tk(create rectangle 0 Y0 MaxSpan<SPAN class="keyword">*</SPAN>DurUnit Y1<BR> fill:ivory outline:<SPAN class="string">''</SPAN> tags:<SPAN class="keyword">self.</SPAN>BackTag)}<BR> <SPAN class="keyword">end</SPAN>}<BR> {For 1 MaxJobs<SPAN class="keyword">+</SPAN>1 1<BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> J}<BR> Y = (MaxJobs <SPAN class="keyword">-</SPAN> J) <SPAN class="keyword">*</SPAN> JobDistance <SPAN class="keyword">+</SPAN> JobDistance <SPAN class="keyword">div</SPAN> 2<BR> <SPAN class="keyword">in</SPAN> <BR> {<SPAN class="keyword">self</SPAN> tk(create line 0 Y MaxSpan<SPAN class="keyword">*</SPAN>DurUnit Y<BR> fill:gray50)}<BR> <SPAN class="keyword">end</SPAN>}<BR> {<SPAN class="keyword">self.</SPAN>BackTag tkBind(event: <SPAN class="string">'<1>'</SPAN> <BR> args: [int(y)]<BR> action: <SPAN class="keyword">self</SPAN> <SPAN class="keyword">#</SPAN> action(<SPAN class="keyword">unit</SPAN>))}<BR> {List<SPAN class="keyword">.</SPAN>forAllInd Spec<BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> JN Ts}<BR> J={Get <SPAN class="keyword">self.</SPAN>Jobs JN}<BR> <SPAN class="keyword">in</SPAN> <BR> {ForAll Ts <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> D<SPAN class="keyword">#</SPAN>R}<BR> {J newTask(resource:R duration:D)}<BR> <SPAN class="keyword">end</SPAN>}<BR> <SPAN class="keyword">end</SPAN>}<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">action</SPAN>(T SY)<BR> <SPAN class="keyword">if</SPAN> <SPAN class="keyword">@</SPAN>EditMode <SPAN class="keyword">then</SPAN> <BR> Y = SY <SPAN class="keyword">-</SPAN> OffY<BR> J = {Get <SPAN class="keyword">self.</SPAN>Jobs<BR> {Min {Max 1 (Y <SPAN class="keyword">+</SPAN> JobDistance <SPAN class="keyword">div</SPAN> 2 ) <SPAN class="keyword">div</SPAN> JobDistance <SPAN class="keyword">+</SPAN> 1}<BR> MaxJobs}}<BR> <SPAN class="keyword">in</SPAN> <BR> <SPAN class="keyword">case</SPAN> {<SPAN class="keyword">self.</SPAN>Tools getTool($)}<BR> <SPAN class="keyword">of</SPAN> create(R D) <SPAN class="keyword">then</SPAN> <BR> {J newTask(resource:R duration:D)}<BR> <SPAN class="keyword">[]</SPAN> delete <SPAN class="keyword">then</SPAN> <BR> <SPAN class="keyword">if</SPAN> T<SPAN class="keyword">\=unit</SPAN> <SPAN class="keyword">then</SPAN> {J deleteTask(T)} <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">[]</SPAN> resource(GR) <SPAN class="keyword">then</SPAN> <BR> <SPAN class="keyword">if</SPAN> T<SPAN class="keyword">\=unit</SPAN> <SPAN class="keyword">then</SPAN> {T setResource({GR})} <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">[]</SPAN> duration(GD) <SPAN class="keyword">then</SPAN> <BR> <SPAN class="keyword">if</SPAN> T<SPAN class="keyword">\=unit</SPAN> <SPAN class="keyword">then</SPAN> {J setDuration(T {GD})} <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">getSpec</SPAN>($)<BR> pa(dur:0) <SPAN class="keyword">|</SPAN> <BR> pe(dur:0 pre:{ForThread 1 MaxJobs 1<BR> <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> Js J}<BR> {Append {{Get <SPAN class="keyword">self.</SPAN>Jobs J}<BR> getLastSpec($)}<BR> Js}<BR> <SPAN class="keyword">end</SPAN> nil}) <SPAN class="keyword">|</SPAN> <BR> {ForThread 1 MaxJobs 1<BR> <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> Ss J}<BR> {Append {{Get <SPAN class="keyword">self.</SPAN>Jobs J} getSpec($)} Ss}<BR> <SPAN class="keyword">end</SPAN> nil}<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">setEdit</SPAN> <BR> EditMode <SPAN class="keyword"><-</SPAN> <SPAN class="keyword">true</SPAN> <BR> {For 1 MaxJobs 1<BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> J}<BR> {{Get <SPAN class="keyword">self.</SPAN>Jobs J} setEdit}<BR> <SPAN class="keyword">end</SPAN>}<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">setSol</SPAN>(Sol)<BR> EditMode <SPAN class="keyword"><-</SPAN> <SPAN class="keyword">false</SPAN> <BR> {For 1 MaxJobs 1<BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> J}<BR> {{Get <SPAN class="keyword">self.</SPAN>Jobs J} setSol(Sol)}<BR> <SPAN class="keyword">end</SPAN>}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">displaySol</SPAN>(Sol)<BR> {For 1 MaxJobs 1<BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> J}<BR> {{Get <SPAN class="keyword">self.</SPAN>Jobs J} setSol(Sol)}<BR> <SPAN class="keyword">end</SPAN>}<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">end</SPAN> <BR> <BR><SPAN class="keyword">end</SPAN> <BR></PRE></BLOCKQUOTE><P></P></DIV><TABLE align="center" border="0" cellpadding="6" cellspacing="6" class="nav"><TR bgcolor="#DDDDDD"><TD><A href="node5.html#code.jobshop.scheduler"><< Prev</A></TD><TD><A href="jobshop.html">- Up -</A></TD><TD><A href="node7.html#code.jobshop.tools">Next >></A></TD></TR></TABLE><HR><ADDRESS><SPAN class="version">Version 1.4.0 (20110908185330)</SPAN></ADDRESS></BODY></HTML>
|