Commit 308b977c authored by Steffen Michels's avatar Steffen Michels

- removed group core combinator

- derived simple group combinators (-&&-,-||-,...) from new parallel
- temporary commented out dynamic group & MDI combinators and newsgroup, formatted text & text editor example

git-svn-id: https://svn.cs.ru.nl/repos/iTask-system/trunk@1443 63da3aa8-80fd-4f01-9db8-e6ea747a3da2
parent d35b34e0
......@@ -47,7 +47,6 @@
,{"text":"FinishedContainer.js","path":"src/js/ttc/"}
,{"text":"ResultContainer.js","path":"src/js/ttc/"}
,{"text":"ParallelContainer.js","path":"src/js/ttc/"}
,{"text":"GroupContainer.js","path":"src/js/ttc/"}
,{"text":"itasks.LoginWindow.js","path":"src/js/"}
,{"text":"itasks.RemoteDataPanel.js","path":"src/js/"}
......
Ext.ns('itasks.ttc')
itasks.ttc.GroupContainer = Ext.extend(itasks.ttc.TTCBase,{
initComponent: function(){
Ext.apply(this,
{ layout:'auto'
, cls: 'TTCGroupContainer'
, autoScroll: true
, unstyled: true
, fixedCont: new Ext.util.MixedCollection() // collection of all fixed containers
, floatingCont: new Ext.util.MixedCollection() // collection of all floating containers
, url: itasks.config.serviceUrl + "/json/tasks/" + this.taskId + "/tui"
});
itasks.ttc.GroupContainer.superclass.initComponent.apply(this,arguments);
for(var i=0; i < this.content.length; i++) {
var cont = this.createContainer(this.content[i].panel,this.content[i].behaviour,this.content[i].index);
if(this.content[i].behaviour == 'Floating' || this.content[i].behaviour == 'Modal') {
this.floatingCont.add(this.content[i].index, cont);
} else {
this.fixedCont.add(this.content[i].index, cont);
}
}
},
createContainer: function(cont, behaviour, idx) {
if(behaviour == 'Floating' || behaviour == 'Modal') {
return this.add(new itasks.ttc.GroupItemWindow({
id: this.taskId + '_' + idx,
index: idx,
cls: 'TTCGroupItemWindow',
closable: false,
autoScroll: true,
maximizable: true,
constrainHeader: true,
modal: behaviour == 'Modal',
items: [cont],
title: cont.subject
}));
} else {
//Default is fixed items on the main canvas.
return this.add(new Ext.Panel({
index: idx,
cls: 'TTCGroupItemPanel',
items: [cont],
unstyled: true
}));
}
},
onLayout: function() {
itasks.ttc.GroupContainer.superclass.onLayout.call(this,arguments);
//Show the floating windows after layouting the components
this.floatingCont.each(function(cont) {
cont.show();
});
},
update: function(data) {
var content = data.content;
// During the update, keep track of two sets of containers
// The 'old' containers that already existed and 'new' containers
// that exist after the update
var oldFixed = this.fixedCont;
var newFixed = new Ext.util.MixedCollection();
var oldFloating = this.floatingCont;
var newFloating = new Ext.util.MixedCollection();
var focusFloating = new Ext.util.MixedCollection();
//Loop over content and update/add child items
for(var i=0; i < content.length; i++) {
var cont;
var panel = content[i].panel;
var index = content[i].index;
var behaviour = content[i].behaviour;
var focus = content[i].focus;
if(cont = oldFixed.key(index)) {
// update existing fixed container
this.updateItem(cont, panel, behaviour, index);
oldFixed.remove(cont);
newFixed.add(index, cont);
} else if(cont = oldFloating.key(index)) {
// update existing floating container
this.updateItem(cont, panel, behaviour);
oldFloating.remove(cont);
newFloating.add(index, cont);
if (focus)
focusFloating.add(cont);
} else {
// Create a new item new container
cont = this.createContainer(panel, behaviour, index);
// Add the component to this component's items
if(behaviour == 'Floating' || behaviour == 'Modal') {
newFloating.add(index, cont);
this.doLayout();
cont.show();
} else {
newFixed.add(index, cont);
this.doLayout();
}
}
}
// destroy containers that are left in the old sets
oldFixed.each(function(item) {item.destroy();});
oldFloating.each(function(item) {item.destroy();});
// from now on, use the new container sets
this.fixedCont = newFixed;
this.floatingCont = newFloating;
// focus the floating windows
focusFloating.each(function(c) {
c.toFront();
}, this);
this.menu = data.menu;
var bbar = this.getBottomToolbar();
bbar.removeAll();
bbar.add(data.bbar);
this.doLayout();
},
updateItem: function(container, panel, behaviour, index) {
var oldPanel = container.get(0);
if(oldPanel.getXType() == panel.xtype && oldPanel.taskId == panel.taskId) {
// update container contents
oldPanel.update(panel);
var tbar = container.getTopToolbar();
if (tbar) {
tbar.removeAll();
tbar.add(oldPanel.menu);
}
} else {
//if not same xtype or taskId - completely replace container contents
container.removeAll();
container.add(panel);
}
return container;
}
});
itasks.ttc.GroupItemWindow = Ext.extend(Ext.Window,{
initComponent: function() {
this.width = 750;
this.height = 300;
if(this.items.length > 0 && this.items[0].menu) {
this.tbar = this.items[0].menu;
}
itasks.ttc.GroupItemWindow.superclass.initComponent.apply(this,arguments);
}
});
Ext.reg('itasks.ttc.group',itasks.ttc.GroupContainer);
\ No newline at end of file
......@@ -23,9 +23,6 @@ itasks.ttc.InteractiveContainer = Ext.extend(itasks.ttc.TTCBase, {
}
itasks.ttc.InteractiveContainer.superclass.initComponent.apply(this,arguments);
this.addEvents("taskRedundant","taskDone");
this.enableBubble("taskRedundant","taskDone");
},
buildComponents: function(data){
this.interactionpanel = {
......@@ -41,38 +38,7 @@ itasks.ttc.InteractiveContainer = Ext.extend(itasks.ttc.TTCBase, {
update: function(data) {
//var content = data.content;
if (data == "done" || data == "redundant"){
if(data == "redundant"){
msg = "The completion of this task is no longer required.<br />It has been removed. Thank you for your effort.";
this.fireEvent("taskRedundant");
}else{
msg = "This task is completed. Thank you.";
this.fireEvent("taskDone");
}
var par = this.findParentByType("itasks.ttc.parallel");
if(par){
var destroyCmp = this;
}else{
var destroyCmp = this.findParentByType("itasks.work");
}
var height = this.descriptionpanel.getHeight() + this.interactionpanel.getHeight();
this.removeAll();
this.add({
xtype: "itasks.ttc.finished",
subject: "Task completed",
description: msg,
descriptionHeight: height,
destroyCmp: destroyCmp
});
this.getEl().fadeOut(
{ duration: itasks.ttc.TTC_FADE_DURATION
, useDisplay: true
}
);
this.doLayout();
this.fadeOut(data);
} else if(data.updates) {
//errors and hints are updated separately
var num = data.updates.length;
......
......@@ -13,18 +13,22 @@ itasks.ttc.ParallelContainer = Ext.extend(itasks.ttc.TTCBase, {
buildComponents: function(data) {
},
update : function(data) {
var curItemCount = this.items.getCount()-2;
for(var i=0; i < curItemCount; i++) {
this.get(i+2).update(data.content[i]);
}
var add = function(){
for(var i=curItemCount; i < data.content.length; i++) {
this.add(data.content[i]);
if (data == "done" || data == "redundant"){
this.fadeOut(data);
} else {
var curItemCount = this.items.getCount()-2;
for(var i=0; i < curItemCount; i++) {
this.get(i+2).update(data.content[i]);
}
this.doLayout();
};
add.defer(itasks.ttc.TTC_FADE_DURATION * 1500,this);
var add = function(){
for(var i=curItemCount; i < data.content.length; i++) {
this.add(data.content[i]);
}
this.doLayout();
};
add.defer(itasks.ttc.TTC_FADE_DURATION * 1500,this);
}
}
});
......
......@@ -25,8 +25,8 @@ itasks.ttc.TTCBase = Ext.extend(Ext.Panel, {
itasks.ttc.TTCBase.superclass.initComponent.apply(this,arguments);
this.addEvents('tuievent');
this.enableBubble('tuievent');
this.addEvents('tuievent','taskRedundant','taskDone');
this.enableBubble('tuievent','taskRedundant','taskDone');
},
onTuiChange: function(name,value) {
//Re-fire 'tuichange' events as 'tuievent' with the task number added
......@@ -96,5 +96,39 @@ itasks.ttc.TTCBase = Ext.extend(Ext.Panel, {
//Default update is to reconstruct the component
this.menu = data.menu;
this.rebuildComponents(data);
},
fadeOut: function(data) {
if(data == "redundant"){
msg = "The completion of this task is no longer required.<br />It has been removed. Thank you for your effort.";
this.fireEvent("taskRedundant");
}else{
msg = "This task is completed. Thank you.";
this.fireEvent("taskDone");
}
var par = this.findParentByType("itasks.ttc.parallel");
if(par){
var destroyCmp = this;
}else{
var destroyCmp = this.findParentByType("itasks.work");
}
var height = this.descriptionpanel.getHeight() + (this.interactionpanel ? this.interactionpanel.getHeight() : 0);
this.removeAll();
this.add({
xtype: "itasks.ttc.finished",
subject: "Task completed",
description: msg,
descriptionHeight: height,
destroyCmp: destroyCmp
});
this.getEl().fadeOut(
{ duration: itasks.ttc.TTC_FADE_DURATION
, useDisplay: true
}
);
this.doLayout();
}
});
\ No newline at end of file
......@@ -180,13 +180,10 @@
<script type="text/javascript" src="../js/ttc/Button.js"></script>
<script type="text/javascript" src="../js/ttc/MenuItem.js"></script>
<script type="text/javascript" src="../js/ttc/GroupContainer.js"></script>
<script type="text/javascript" src="../js/ttc/ParallelContainer.js"></script>
<script type="text/javascript" src="../js/ttc/FinishedContainer.js"></script>
<script type="text/javascript" src="../js/ttc/InteractiveContainer.js"></script>
<script type="text/javascript" src="../js/ttc/MonitorContainer.js"></script>
<script type="text/javascript" src="../js/ttc/ProcessControlContainer.js"></script>
<script type="text/javascript" src="../js/ttc/ResultContainer.js"></script>
<!-- core -->
......
......@@ -103,7 +103,6 @@
<script type="text/javascript" src="../js/ttc/Button.js"></script>
<script type="text/javascript" src="../js/ttc/MenuItem.js"></script>
<script type="text/javascript" src="../js/ttc/GroupContainer.js"></script>
<script type="text/javascript" src="../js/ttc/ParallelContainer.js"></script>
<script type="text/javascript" src="../js/ttc/FinishedContainer.js"></script>
......
......@@ -71,81 +71,6 @@
background-repeat: repeat;
}
/* Group Container */
.TTCGroupContainer {
}
.TTCGroupItemPanel {
background-image: url('img/ttc-icons/TTCBackground90.png') !important;
}
.TTCGroupItemWindow .x-window-body {
background-color: #eee;
}
.GroupContainer {
/* background-color: #eee; */
}
.GroupFixed .x-plain-tbar {
display: none;
}
.GroupFixedNoFocus .TTCSubject {
background-image: url("img/ttc-icons/TTCDescriptionBackgroundNoFocus.png") !important;
border:1px solid #ddd;
color:#888899;
}
.GroupFloating .x-window-body {
background-color: white;
}
.GroupFloating .GroupUnpinButton {
display: none;
}
.GroupFloating .TTCDescription,
.GroupFloating .FormPanel,
.GroupFloating .ProcessControlPanel,
.GroupFloating .InstructionContainer-Text,
.GroupFloating .InstructionContainer-Context,
.GroupFloating .MessagePanel,
.GroupFloating .MonitorPanel {
margin: 0px;
border: none;
width: auto;
}
.GroupFloating .TTCSubject {
display: none;
}
.GroupFloating .ToolbarNoEnabledItems,
.GroupFloating .ToolbarGroupActionsOnly {
display: none;
}
.x-window-maximized .ToolbarGroupActionsOnly {
display: block;
}
/* Process Control Container */
.TTCProcessControlContainer{
background-color: #eee;
background-image : url('img/ttc-icons/TTCProcessControlContainer.png') !important;
background-repeat: no-repeat ;
background-position: 3px 3px;
}
.TTCProcessControlPanel {
background-image : url('img/ttc-icons/TTCBackground80.png') !important;
padding: 4px;
border-left: 1px solid #99BBE8;
border-bottom: 1px solid #99BBE8;
border-right: 1px solid #99BBE8;
margin: 0px 0px 0px 10px;
width: 700px;
background-repeat: repeat;
}
/* Parallel Container */
.TTCParallelControlContainer{
background-color: #eee;
......
......@@ -17,9 +17,9 @@ import SmallExamples
import GUIDemo
import BugReport
import Coffeemachine
import Newsgroups
//import Newsgroups
import ChangeHandling
import textEditor
//import textEditor
import CoffeeTime
import TableExamples
import GeoTracker
......@@ -62,11 +62,11 @@ where
, guiDemoExample
, bugReportExample
, coffeemachineExample
, textEditor
//, textEditor
, coffeeTimeExample
, tableExamples
, geoTrackerExamples
, newsgroupsExample
//, newsgroupsExample
, exceptionHandlingExample
, changeHandlingExample
, ambulanceDispatchExamples
......
......@@ -156,7 +156,7 @@ where
emptyL = []
//Different Views on Formatted Text
formattedText :: Task Void
/*formattedText :: Task Void
formattedText =
[Menu "Example" [MenuItem ActionQuit Nothing]]
@>> createSharedStore (mkEmptyFormattedText {allControls & sourceEditControl = False})
......@@ -171,7 +171,7 @@ where
]
actions = [(ActionQuit, Always)]
actionsGenFunc actionQuit = GOStop
actionsGenFunc actionQuit = GOStop*/
//Use a share to simplify data entry by allowing a choice from known values instead of entry
:: Order =
......@@ -273,6 +273,6 @@ sharedValueExamples = [ workflow "Examples/Shared Variables/Text-Lines (grouped
, workflow "Examples/Shared Variables/Merge Test (Documents)" "" (Title "Merge Test (Documents)" @>> mergeTestDocuments)
, workflow "Examples/Shared Variables/Google Maps Example" "" (Title "Google Maps Example" @>> googleMaps)
, workflow "Examples/Shared Variables/Sorted List" "" (Title "Sorted List" @>> autoSortedList)
, workflow "Examples/Shared Variables/Formatted Text" "" (Title "Formatted Text" @>> formattedText)
//, workflow "Examples/Shared Variables/Formatted Text" "" (Title "Formatted Text" @>> formattedText)
, workflow "Examples/Shared Variables/Choose or add" "" (Title "Choose or add" @>> chooseOrAdd)
]
......@@ -241,7 +241,7 @@ repeatTask :: !(a -> Task a) !(a -> Bool) a -> Task a | iTask a
*
* @param List of initial tasks
*/
dynamicGroup :: ![Task GAction] -> Task Void
/*dynamicGroup :: ![Task GAction] -> Task Void
/**
* Tasks and group-actions can dynamically add other tasks or stop execution of group.
*
......@@ -308,4 +308,4 @@ mdiApplication ::
:: MDIExistsEditor editorState :== (editorState -> Bool) -> Task (Maybe (EditorId editorState))
:: EditorId est :== Int
:: EditorCollection est :== Map (EditorId est) est
:: EditorCollection est :== Map (EditorId est) est*/
......@@ -103,33 +103,32 @@ justdo task
Nothing = throw ("The task " +++ taskTitle task +++ " returned nothing.")
(-||-) infixr 3 :: !(Task a) !(Task a) -> (Task a) | iTask a
(-||-) taska taskb = group ("-||-", "Done when either subtask is finished.") orfunc hd [] [taska,taskb] [] undef
(-||-) taska taskb = parallel ("-||-", "Done when either subtask is finished.") ([],orfunc,\_ l -> hd l) [] [taska,taskb]
where
orfunc (val,_) [] = ([val],Just Stop)
orfunc (val,_) _ = abort "Multiple results in OR"
orfunc _ val [] = ([val],Just Stop)
orfunc _ val _ = abort "Multiple results in OR"
(||-) infixr 3 :: !(Task a) !(Task b) -> Task b | iTask a & iTask b
(||-) taska taskb
= group ("||-", "Done when the second subtask is finished.") rorfunc hd [] [(taska >>= \a -> return (Left a)), (taskb >>= \b -> return (Right b))] [] undef
= parallel ("||-", "Done when the second subtask is finished.") ([],rorfunc,\_ l -> hd l) [] [(taska >>= \a -> return (Left a)), (taskb >>= \b -> return (Right b))]
where
rorfunc (Right val,_) [] = ([val],Just Stop)
rorfunc (Left val, _) [] = ([],Nothing)
rorfunc _ _ = abort "Illegal result in ||-"
rorfunc _ (Right val) [] = ([val],Just Stop)
rorfunc _ (Left val) [] = ([],Nothing)
rorfunc _ _ _ = abort "Illegal result in ||-"
(-||) infixl 3 :: !(Task a) !(Task b) -> Task a | iTask a & iTask b
(-||) taska taskb
= group ("-||", "Done when the first subtask is finished") lorfunc hd [] [(taska >>= \a -> return (Left a)),(taskb >>= \b -> return (Right b))] [] undef
= parallel ("-||", "Done when the first subtask is finished") ([],lorfunc,\_ l -> hd l) [] [(taska >>= \a -> return (Left a)),(taskb >>= \b -> return (Right b))]
where
lorfunc (Right val,_) [] = ([],Nothing)
lorfunc (Left val, _) [] = ([val],Just Stop)
lorfunc _ _ = abort "Illegal result in -||"
lorfunc _ (Right val) [] = ([],Nothing)
lorfunc _ (Left val) [] = ([val],Just Stop)
lorfunc _ _ _ = abort "Illegal result in -||"
(-&&-) infixr 4 :: !(Task a) !(Task b) -> (Task (a,b)) | iTask a & iTask b
(-&&-) taska taskb = group ("-&&-", "Done when both subtasks are finished") andfunc parseresult (Nothing,Nothing) [(taska >>= \a -> return (Left a)), (taskb >>= \b -> return (Right b))] [] undef
(-&&-) taska taskb = parallel ("-&&-", "Done when both subtasks are finished") ((Nothing,Nothing),andfunc,parseresult) [] [(taska >>= \a -> return (Left a)), (taskb >>= \b -> return (Right b))]
where
andfunc :: ((Either a b),Int) (Maybe a, Maybe b) -> ((Maybe a, Maybe b),Maybe (PAction (Either a b) (Maybe a,Maybe b)))
andfunc (val,_) (left,right)
= case val of
andfunc :: !Int !(Either a b) (Maybe a, Maybe b) -> ((Maybe a, Maybe b),Maybe (PAction (Either a b) (Maybe a,Maybe b)))
andfunc _ val (left,right) = case val of
(Left a)
# state = (Just a,right)
= case state of
......@@ -141,27 +140,27 @@ where
(Just l, Just r) = (state,Just Stop)
_ = (state,Nothing)
parseresult (Just a,Just b) = (a,b)
parseresult _ = abort "AND not finished"
parseresult _ (Just a,Just b) = (a,b)
parseresult _ _ = abort "AND not finished"
(-&?&-) infixr 4 :: !(Task (Maybe a)) !(Task (Maybe b)) -> Task (Maybe (a,b)) | iTask a & iTask b
(-&?&-) taska taskb
= group ("-&?&-", "Done when both subtasks are finished. Yields only a result of both subtasks have a result") mbandfunc parsefunc (Nothing,Nothing) [(taska >>= \a -> return (Left a)), (taskb >>= \b -> return (Right b))] [] undef
= parallel ("-&?&-", "Done when both subtasks are finished. Yields only a result of both subtasks have a result") ((Nothing,Nothing),mbandfunc,parsefunc) [] [(taska >>= \a -> return (Left a)), (taskb >>= \b -> return (Right b))]
where
mbandfunc (val,_) (left,right)
= case val of
Left v
# state = (Just v,right)
= case state of
(Just a, Just b) = (state,Just Stop)
_ = (state,Nothing)
Right v
# state = (left,Just v)
= case state of
(Just a, Just b) = (state,Just Stop)
_ = (state,Nothing)
parsefunc (Just (Just a), Just (Just b)) = Just (a,b)
parsefunc _ = Nothing
mbandfunc _ val (left,right) = case val of
Left v
# state = (Just v,right)
= case state of
(Just a, Just b) = (state,Just Stop)
_ = (state,Nothing)
Right v
# state = (left,Just v)
= case state of
(Just a, Just b) = (state,Just Stop)
_ = (state,Nothing)
parsefunc _ (Just (Just a), Just (Just b)) = Just (a,b)
parsefunc _ _ = Nothing
oldParallel :: !TaskParallelType !d !(ValueMerger taskResult pState pResult) ![Task taskResult] -> Task pResult | iTask taskResult & iTask pState & iTask pResult & descr d
oldParallel parType d valueMerger initTasks = parallel d valueMerger [overviewControl] initTasks
......@@ -190,27 +189,27 @@ derive class iTask ProcessOverviewView
anyTask :: ![Task a] -> Task a | iTask a
anyTask [] = getDefaultValue
anyTask tasks = group ("any", "Done when any subtask is finished") anyfunc hd [] tasks [] undef
anyTask tasks = parallel ("any", "Done when any subtask is finished")