Commit 8ebd0c58 authored by Bas Lijnse's avatar Bas Lijnse

More UI diff improvements

git-svn-id: https://svn.cs.ru.nl/repos/iTask-system/trunk@2370 63da3aa8-80fd-4f01-9db8-e6ea747a3da2
parent 55382fe3
......@@ -26,10 +26,8 @@ Ext.define('itwc.container.Panel',{
this.callParent(arguments);
},
afterRender: function() {
var me = this;
me.callParent();
me.initHotkeys();
this.callParent(arguments);
this.initHotkeys();
},
onDestroy: function () {
this.destroyHotkeys();
......
......@@ -2,7 +2,8 @@ Ext.define('itwc.container.Window',{
extend: 'Ext.window.Window',
alias: 'widget.itwc_window',
requires: ['itwc.layout.container.Box'],
mixins: ['itwc.component.edit.Editable'],
mixins: ['itwc.component.edit.Editable','itwc.container.HotkeyArea'],
autoShow: true,
autoScroll: true,
......@@ -45,5 +46,13 @@ Ext.define('itwc.container.Window',{
me.viewport = me.findViewport();
me.viewport.fireEvent('action',me.closeTaskId,'Close');
return false;
},
afterRender: function() {
this.callParent(arguments);
this.initHotkeys();
},
onDestroy: function () {
this.destroyHotkeys();
this.callParent(arguments);
}
});
......@@ -223,28 +223,34 @@ Ext.define('itwc.controller.Controller', {
partialUpdate: function(updates) {
var me = this,
numUpdates = updates.length,
update, cmp, i;
update,
cmp, operations, numOperations, operation, i, j;
for(i = 0; i < numUpdates; i++) {
update = updates[i];
try {
if(cmp = me.viewport.getComponentByPath(update.path)) {
//Try to call the update method
if(cmp && typeof cmp[update.method] == 'function') {
cmp[update.method].apply(cmp,update.arguments);
} else {
//If replace is not defined as function, try remove followed by add
if(update.method == 'replace' && typeof cmp['remove'] == 'function' && typeof cmp['insert'] == 'function') {
me.warn("Doing inefficient replace by using remove followed by add in " + update.arguments[1].xtype);
cmp.suspendLayout = true; //Don't layout in between remove and add
cmp.remove(update.arguments[0]);
cmp.insert(update.arguments[0],update.arguments[1]);
cmp.suspendLayout = false;
cmp.doLayout(); //Now do the layout
operations = update.operations;
numOperations = operations.length;
//If multiple operations need to be done on the same component, don't layout in between
if(numOperations > 1 && cmp.doLayout) {
cmp.suspendLayout = true;
}
for(j = 0; j < numOperations; j++) {
operation = operations[j];
//Try to call the update method
if(cmp && typeof cmp[operation.method] == 'function') {
cmp[operation.method].apply(cmp,operation.arguments);
} else {
me.error("Can't apply " + update.method + " to " + cmp.getId() + " (" + cmp.getXType() + ")");
me.error("Can't apply " + operation.method + " to " + cmp.getId() + " (" + cmp.getXType() + ")");
}
}
if(cmp.suspendLayout) {
cmp.suspendLayout = false;
cmp.doLayout();
}
} else {
me.error("Could not find user interface component at location " + update.path);
}
......
......@@ -301,22 +301,22 @@ sequenceMerge :: ParallelLayout
sequenceMerge = merge
where
merge prompt=:{UIControlSequence|attributes,controls,direction} defs
# (actions,parts) = unzip (map processDef defs)
# controls = decoratePrompt controls ++ [c \\ Just (Left c) <- parts]
# windows = [w \\ Just (Right w) <- parts]
# actions = foldr (++) [] actions
# parts = (map processDef defs)
# controls = decoratePrompt controls ++ [c \\ (_,_,Just c) <- parts]
# actions = flatten [a \\ (a,_,_) <- parts]
# windows = flatten [w \\ (_,w,_) <- parts]
= UIAbstractContainer {UIAbstractContainer|attributes=attributes,controls=controls,direction=direction,actions=actions,windows=windows,hotkeys=[]}
//Action sets do not get a panel in the sequence. Their actions are passed upwards
processDef (UIActionSet {UIActionSet|actions})
= (actions,Nothing)
= (actions,[],Nothing)
processDef def
| hasWindowAttr (uiDefAttributes def) //TODO: Pass hotkeys along
# (actions,_, window) = placeWindowActions (uiDefActions def) (defToWindow (layoutControls def))
= ([],Just (Right window))
= ([],[window:uiDefWindows def],Nothing)
| otherwise
# (actions,_, panel) = placePanelActions (uiDefActions def) False (defToPanel (layoutControls def))
= (actions,Just (Left panel))
= (actions,uiDefWindows def,Just panel)
sideMerge :: UISide Int ParallelLayout -> ParallelLayout
sideMerge side size restMerge = merge
......@@ -395,7 +395,7 @@ where
# (tabsAndWindows,actions) = unzip [mkTabOrWindow (i == active) d \\ d <- defs & i <- [0..]]
= ((setDirection Horizontal o setHeight WrapSize o setBaseCls "x-tab-bar") (defaultContainer [tab \\Left tab <- tabsAndWindows])
,[window \\ Right window <- tabsAndWindows]
,foldr (++) [] actions
,flatten actions
)
mkTabOrWindow active def
......@@ -412,7 +412,6 @@ where
# tabOpts = {text = text ,focusTaskId = taskId, active = active, closeTaskId = close,iconCls=iconCls}
= (Left (UITab defaultSizeOpts tabOpts), if active actions [])
hideLayout :: Layout
hideLayout =
{ editor = \prompt -> []
......
......@@ -3,34 +3,9 @@ definition module UIDiff
import UIDefinition
from Task import :: Event
:: UIUpdate = UIUpdate !UIPath !UIUpdateOperation
:: UIUpdateOperation
//Component updates
= UISetValue !JSONNode // Set the value of a component
| UISetOptions !JSONNode // Change the options in a choice component
| UISetTaskId !String // Set taskId a component belongs to
| UISetCloseTaskId !(Maybe String)
| UISetFocusTaskId !(Maybe String)
| UISetEditorId !String // Set editorId a component belongs to
| UISetActionId !String // Set actionId a component belongs to
| UISetName !String // Set name of a component
| UISetEnabled !Bool // Enable/disable form elements
| UISetActive !Bool // Make a tab active/inactive
| UISetTitle !(Maybe String) // Set/reset title of a container
| UISetText !(Maybe String) // Set/reset text of a button
| UISetIconCls !(Maybe String) // Set/reset icon of component
| UISetTooltip !(Maybe String) // Set/reset tooltip of a component
| UISetHotkeys ![UIKeyAction] // Set hotkeys for a container
| UISelfUpdate !UIControl // Let a component update itself with a new UI definition (for custom components)
//Structure edits
| UIAdd !Int !UIControl //Add child element at index
| UIRemove !Int //Remove child element at index
| UIReplace !Int !UIControl //Replace child element at index
| UIAddWindow !Int !UIWindow //Add a window
| UIRemoveWindow !Int //Remove a window
//Changing size
| UIResize !UISizeOpts
:: UIUpdate = UIUpdate !UIPath ![UIUpdateOperation]
:: UIUpdateOperation :== (String,[JSONNode])
:: UIPath :== [UIStep]
:: UIStep
= ItemStep !Int //Select item i
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment