<@doc alias="elem" hierarchy="GMLDOM" also="NavigationLink, DataLink"> Represents a data mapping between two elements. (c) SAP AG 2003-2006. All rights reserved. #INCLUDE[svg:defs.inc] /////////////////////////////////////////////////////////////////////// // CLASS HEADER Class EventLink inherit Link; metadata title = '#TEXT[XTIT_EVENT_LINK]'; metadata descr = '#TEXT[XTOL_EVENT_LINK]'; attach svg:OrthogonalLine override { arrowHead: #[SVG_BLOCK_ARROW|SVG_FILLED], cornerRadius: 5 } /////////////////////////////////////////////////////////////////////// // PROPERTIES <@doc>Gets the string representing the event carried by this link (optional). property eventName = ''; metadata for eventName = { editor: 'combo', group: 'Behavior', label: '#TEXT[XFLD_EVENT]', priority: 100, sideEffects: true, domain: function (context) { var res = new Array(); var arr = context.getPossibleEventNames(); for (var i = 0; i < arr.length; ++i) { res.push({text:arr[i], value:arr[i]}); } return res; }, visible: 'ISA(data, "core.gml:EventLink")' } <@doc>Gets the string representing the event trigged at the target of this link (optional). If no value is specified, then the event at the target is equal to the event at the source. property targetEventName = ''; <@doc scope="private">Gets the mappings on the link strong property mappings = ^core.gml:Mapping[id]; <@doc>Gets the array of mapping objects from source field to target field. method getMappings() return this.mappings; end /////////////////////////////////////////////////////////////////////// // METHODS <@doc> Add one mapping object between a source and a destination field. Full Id of source field (in the form ~unitId.elemId) Full Id of target field (in the form ~unitId.elemId) source field target field method addMapping(sourcefield, targetfield) if (typeof sourcefield == 'string') sourcefield = $ENV.getElement(sourcefield); if (typeof targetfield == 'string') targetfield = $ENV.getElement(targetfield); if (!ISA(sourcefield, 'core.gml:Field')) return null; if (!ISA(targetfield, 'core.gml:Field')) return null; return this.createElement('core.gml:Mapping', 'mappings', {name:'', source:sourcefield, target:targetfield}); end method removeAllMappings() var mappings = this.getMappings(); for (var m in mappings) { var map = mappings[m]; this.removeElement(map.id, 'mappings'); //remove the mapping if the source field was not } end override method notifyOnInfoshapeChange(changeType, changeData) this.supercall(); switch (changeType) { case #[INFOSHAPE_CHANGE_FIELD_DELETE]: // remove mapping related to the removed field. for (var i = 0; i< changeData.fields.length; ++i) { var field_id = changeData.fields[i].id; var mappings = this.getMappings(); for (var m in mappings) { var map = mappings[m]; var sid = map.getProperty('source') && map.getProperty('source').id; var tid = map.getProperty('target') && map.getProperty('target').id; // The check (sid == null || tid == null) occurs if the mapping is invalid if (sid == null || tid == null ){ var mapUnitId = map.unit.id; this.removeElement(map.id, 'mappings'); #TRACE[4,'An invalid mapping was found, map id:'+ map.id+ ' in unit:'+mapUnitId +', This mapping was deleted.']; }else if (sid == field_id || tid == field_id){ this.removeElement(map.id, 'mappings'); } } } break; case #[INFOSHAPE_CHANGE_BO_REPLACED]: // remove all mappings... this.removeAllMappings(); break; case #[INFOSHAPE_CHANGE_REF_REPLACED]: //remove all mappings if BO changed.. var old_ref = $ENV.model.infoshape_pool.getRefInfoshape(changeData.old_id); var new_ref = $ENV.model.infoshape_pool.getRefInfoshape(changeData.new_id); if (old_ref && new_ref && old_ref.getBOInfoshape().getUniqueID() == new_ref.getBOInfoshape().getUniqueID()) break; this.removeAllMappings(); break; } end <@doc scope="private"> Returns an array of event names that can be set as the link's ~eventName property. an array of event names that can be set as the link's ~eventName property. method getPossibleEventNames() var selem = this.source && this.source.parent || null; var list = selem && selem.getEvents && selem.getEvents(#[DIR_OUT]); return list || []; end <@doc scope="private"> Returns an array of event names that can be set as the link's ~targetEventName property. an array of event names that can be set as the link's ~targetEventName property. method getPossibleTargetEventNames() var telem = this.target && this.target.parent || null; var list = telem && telem.getEvents && telem.getEvents(#[DIR_IN]); return list || []; end