////////////////////////////////////////////////////////////////// // CONTROLS EDITOR MENUBARS Configure COMMANDS MENUBARS TABS ////////////////////////////////////////////////////////////////// // BOARD DEFINITION $ENV.defineTab({ id: '#NS[CONTROLS_EDITOR]', name: '#TEXT[XMIT_CMD_DETAILED_CONFIGURATION]', type: 'HTM', impl: '#URL[common.ControlsEditor.htm]', visible: function(def) { return true; }, priority: 100, category: "DETAILED_VIEW" }); // Activate the defineUIConfiguration RULE, by calling the Element's getUiConfiguration method, and return the matching value function __getUiConfiguration(object, key) { if (!key || !object) { return null; } var uiConfiguration = object.getUiConfiguration(); // RULE('defineUIConfiguration',unit, object); if (ISEMPTY(uiConfiguration)) return null; var config = uiConfiguration[UPPER(key)]; if(undefined == config || null == config) { return null; } return config; } // Look in the uiConfiguration metadata property for requests to disable a specific button function __disableButton(control, _interactor, def) { if (!_interactor || !def) return false; // currnetly patetrns cannot override controls, so this check is 'disabled'. We keep the variable to minimize future modifications. // var byControl = __getUiConfiguration(control, def.id+'_disable'); var byControl = false; var byInteractor = __getUiConfiguration(_interactor, def.id+'_disable'); // disable the button if at least one of control/interactor requests to disable if ( (true == byInteractor) || (true == byControl) ) { return true; } return false; } // Checks whether the control can be a child of the 'candidate parent' function __canBeChildOf(control, parent, _interactor) { if (!control || !_interactor) return false; var allowedControls = _interactor.getAllowedControls(parent); for (var k in allowedControls) { if ( ISA(control,allowedControls[k]) )return true; } return false; } function __isEnabled(_interactor) { return (_interactor && _interactor.unit && _interactor.unit.isEnabled()); } $ENV.defineCommand({ id: '#NS[CONTROL_LEFT]', signal: 'DETAILS->controlLeft', text: '#TEXT[XMIT_CMD_CONTROL_LEFT]', icon: '#URL[dev~skin:icons.RemoveFromGroup.gif]', category: 'STANDARD', disable: function (control, _interactor, def){ if(!control) return true; if (! __isEnabled(_interactor) ) return true; if (ISA(control.parent,'core.gml:Interactor' )) return true; if (control.parent && !__canBeChildOf(control, control.parent.parent, _interactor)) return true; return __disableButton(control, _interactor, def); } }); $ENV.defineCommand({ id: '#NS[CONTROL_RIGHT]', signal: 'DETAILS->controlRight', text: '#TEXT[XMIT_CMD_CONTROL_RIGHT]', icon: '#URL[dev~skin:icons.AddToGroup.gif]', category: 'STANDARD', disable: function (control, _interactor, def){ if(!control) return true; if (! __isEnabled(_interactor) ) return true; var parent = control.parent; if(!parent) return true; var childs = parent.getControls(); var prevControl = null; for (var id in childs){ if(childs[id].index == control.index - 1) { prevControl = childs[id]; break; } } if(!ISA(prevControl,'core.gml:ControlGroup')) return true; if (!__canBeChildOf(control, prevControl, _interactor)) return true; return __disableButton(control, _interactor, def); } }); $ENV.defineCommand({ id: '#NS[CONTROL_UP]', signal: 'DETAILS->controlUp', text: '#TEXT[XMIT_CMD_CONTROL_UP]', icon: '#URL[dev~skin:icons.up.gif]', category: 'STANDARD', disable: function (control, _interactor, def){ if(!control) return true; if (! __isEnabled(_interactor) ) return true; if (control && control.index <=0) return true; return __disableButton(control, _interactor, def); } }); $ENV.defineCommand({ id: '#NS[CONTROL_DOWN]', signal: 'DETAILS->controlDown', text: '#TEXT[XMIT_CMD_CONTROL_DOWN]', icon: '#URL[dev~skin:icons.down.gif]', category: 'STANDARD', disable: function (control, _interactor, def){ if(!control) return true; if (! __isEnabled(_interactor) ) return true; var parent = control.parent; var controls = parent && parent.getControls() || {}; var i = 0 ; for (var id in controls) i++; if (control && control.index == (i - 1)) return true; return __disableButton(control, _interactor, def); } }); $ENV.defineCommand({ id: '#NS[ADD_CONTROL]', signal: 'DETAILS->addControl', text: '#TEXT[XMIT_CMD_ADD_CONTROL]', icon: '#URL[dev~skin:icons.plus.gif]', category: 'STANDARD', disable: function (control, _interactor, def){ if (! __isEnabled(_interactor) ) return true; return __disableButton(control, _interactor, def); } }); $ENV.defineCommand({ id: '#NS[REMOVE_CONTROL]', signal: 'DETAILS->deleteControl', text: '#TEXT[XMIT_CMD_REMOVE_CONTROL]', icon: '#URL[dev~skin:icons.remove.gif]', category: 'STANDARD', disable: function (control, _interactor, def){ if(!control) return true; if (! __isEnabled(_interactor) ) return true; return __disableButton(control, _interactor, def); } }); $ENV.defineCommand({ id: '#NS[OPEN_FIELDS_SELECTOR]', signal: 'DETAILS->fieldSelectorDlg', text: '#TEXT[XTOL_SELECT_FIELDS]', icon: '#URL[~skin:icons.fieldSelector.gif]', category: 'STANDARD', disable: function(control, _interactor, def) { var fields; if (_interactor && _interactor.getInfoshape) { var infoshape = _interactor.getInfoshape(); if (infoshape) { fields = infoshape.getFields(); } } if ((! __isEnabled(_interactor)) || (!fields)) return true; return __disableButton(control, _interactor, def); },textlabel: true }); $ENV.defineCommand({ id: '#NS[OPEN_CONTROL_EDITOR]', signal: 'DETAILS->controlEditorDlg', text: '#TEXT[XTOL_CONTROL_DETAILES]', icon: '#URL[~skin:icons.controlEditor.gif]', category: 'STANDARD', disable: function (control, _interactor, def){ if(control) return __disableButton(control, _interactor, def); return true; },textlabel: true }); $ENV.defineCommand({ id: '#NS[SHOW_ALL_CONTROLS]', signal: 'DETAILS->showAllControls', text: '#TEXT[XBUT_SHOW_ALL_CTRLS]', category: 'STANDARD', icon: '#URL[dev~skin:icons.showall_new.gif]', disable: function (control, _interactor, def){ return true; }, textlabel: true }); $ENV.defineCommand({ id: '#NS[CUT_CONTROL]', signal: 'DETAILS->cutControl', text: '#TEXT[XBUT_CUT]', category: 'STANDARD', icon: '#URL[dev~skin:icons.cut.gif]', disable: function (control, _interactor, def){ if (!control) return true; return !$ENV.triggerEvent("canRemoveElement",control.parent,control,control.unit,"uicontrols","cutEvent"); }, textlabel: true }); $ENV.defineCommand({ id: '#NS[PASTE_CONTROL]', signal: 'DETAILS->pasteControl', text: '#TEXT[XBUT_PASTE]', category: 'STANDARD', icon: '#URL[dev~skin:icons.paste.gif]', disable: function (control, _interactor, def){ var cutControl = $ENV.model.getClipboard("control"); if (!cutControl) return true ; return !$ENV.triggerEvent("canInsertElement",_interactor,cutControl,cutControl.unit,"uicontrols","pasteEvent"); }, textlabel: true }); $ENV.defineCommand({ id: '#NS[MOVE_TO_TOP]', signal: 'DETAILS->moveToTop', text: '#TEXT[XMIT_CMD_MOVE_TO_TOP]', icon: '#URL[dev~skin:icons.move_to_top.gif]', category: 'STANDARD', disable: function (control, _interactor, def){ if(!control) return true; if (! __isEnabled(_interactor) ) return true; if (control && control.index <=0) return true; var parent = control.parent; if (!parent || !ISA(parent,'core.gml:Interactor' )) return true; return __disableButton(control, _interactor, def); } }); $ENV.defineCommand({ id: '#NS[MOVE_TO_BOTTOM]', signal: 'DETAILS->moveToBottom', text: '#TEXT[XMIT_CMD_MOVE_TO_BOTTOM]', icon: '#URL[dev~skin:icons.move_to_bottom.gif]', category: 'STANDARD', disable: function (control, _interactor, def){ if(!control) return true; if (! __isEnabled(_interactor) ) return true; var parent = control.parent; if (!parent || !ISA(parent,'core.gml:Interactor' )) return true; var controls = parent.getControls() || {}; var i = 0 ; for (var id in controls) i++; if (control && control.index == (i - 1)) return true; return __disableButton(control, _interactor, def); } }); var toolbar = $ENV.defineMenubar('#NS[CONTROLS_EDITOR_TOOLBAR]', 'STANDARD', '#TEXT[XMEN_STANDARD]', false); toolbar.append({button:'#NS[ADD_CONTROL]'}); toolbar.append({button:'#NS[REMOVE_CONTROL]'}); toolbar.append(); toolbar.append({button:'#NS[MOVE_TO_TOP]'}); toolbar.append({button:'#NS[CONTROL_UP]'}); toolbar.append(); toolbar.append({button:'#NS[CONTROL_DOWN]'}); toolbar.append({button:'#NS[MOVE_TO_BOTTOM]'}); toolbar.append(); toolbar.append({button:'#NS[CONTROL_LEFT]'}); toolbar.append({button:'#NS[CONTROL_RIGHT]'}); toolbar.append(); toolbar.append({button:'#NS[CUT_CONTROL]'}); toolbar.append({button:'#NS[PASTE_CONTROL]'}); toolbar.append(); toolbar.append({button:'#NS[OPEN_CONTROL_EDITOR]'}); toolbar.append({button:'#NS[OPEN_FIELDS_SELECTOR]'}); toolbar.append(); toolbar.append({button:'#NS[SHOW_ALL_CONTROLS]'}); toolbar.append();