int GetExpectedListItemsClassAndTargetFieldFromSelectedItem(FieldComboItem selectedItem, out int field) { field = 0; // default if (selectedItem == null) return 0; int listItemsClassId = 0; // if we're only expecting this bulk edit to be used with one list items class, use that one. if (m_bulkEditListItemsClasses.Count == 1) { listItemsClassId = m_bulkEditListItemsClasses[0]; } else { // figure out the class of the expected list items for the corresponding bulk edit item // and make that our target class. if (selectedItem is TargetFieldItem && (selectedItem as TargetFieldItem).ExpectedListItemsClass != 0) { var targetFieldItem = selectedItem as TargetFieldItem; listItemsClassId = targetFieldItem.ExpectedListItemsClass; field = targetFieldItem.TargetFlid; } else { // the expected class of the list items will be the source class // of the first field in the FieldPath; if (selectedItem.Accessor != null) { field = selectedItem.Accessor.FieldPath[0]; } else { BulkEditItem beItem = m_beItems[selectedItem.ColumnIndex]; field = beItem.BulkEditControl.FieldPath[0]; } listItemsClassId = (int)m_cache.DomainDataByFlid.MetaDataCache.GetOwnClsId((int)field); } } return listItemsClassId; }
int GetExpectedListItemsClassFromSelectedItem(FieldComboItem selectedItem) { int field; return GetExpectedListItemsClassAndTargetFieldFromSelectedItem(selectedItem, out field); }
private FieldComboItem AddStringFieldItemsToCombo(ComboBox combo, FieldComboItem selectedItem, bool fIsSourceCombo) { FieldComboItem newSelection = null; int icol = -1; foreach (XmlNode node in m_bv.ColumnSpecs) { icol++; FieldReadWriter accessor = null; string optionLabel = GetColumnLabel(m_mediator, node); try { if (fIsSourceCombo) accessor = new ManyOnePathSortItemReadWriter(m_cache, node, m_bv, (IApp)m_mediator.PropertyTable.GetValue("App")); else accessor = FieldReadWriter.Create(node, m_cache, m_bv.RootObjectHvo); if (accessor == null) continue; // Use the decorated data access - see FWR-376. accessor.DataAccess = m_bv.SpecialCache; } catch { Debug.Fail(String.Format("There was an error creating Delete combo item for column ({0})"), optionLabel); // skip buggy column continue; } FieldComboItem item = new FieldComboItem(optionLabel, icol, accessor); combo.Items.Add(item); if (selectedItem != null && selectedItem.ToString() == item.ToString()) newSelection = item; } return newSelection; }
private void OnTargetComboItemChanged(FieldComboItem selectedItem) { if (TargetComboSelectedIndexChanged == null) return; int flid; m_expectedListItemsClassId = GetExpectedListItemsClassAndTargetFieldFromSelectedItem(selectedItem, out flid); if (m_expectedListItemsClassId != 0) { using (var targetFieldItem = new TargetFieldItem(selectedItem.ToString(), selectedItem.ColumnIndex, m_expectedListItemsClassId, flid)) { var args = new TargetColumnChangedEventArgs(targetFieldItem); //REFACTOR: the BrowseView should not know about BulkEdit - They appear to be too highly coupled. m_bv.BulkEditTargetComboSelectedIndexChanged(args); // may set ForceReload flag on args. if (TargetComboSelectedIndexChanged != null) TargetComboSelectedIndexChanged(this, args); } } }
private void OnTargetComboItemChanged(FieldComboItem selectedItem) { if (TargetComboSelectedIndexChanged == null) return; m_expectedListItemsClassId = GetExpectedListItemsClassFromSelectedItem(selectedItem); if (m_expectedListItemsClassId != 0) { TargetColumnChangedEventArgs args = new TargetColumnChangedEventArgs(new TargetFieldItem(selectedItem.ToString(), selectedItem.ColumnIndex, m_expectedListItemsClassId)); m_bv.BulkEditTargetComboSelectedIndexChanged(args); // may set ForceReload flag on args. if (TargetComboSelectedIndexChanged != null) TargetComboSelectedIndexChanged(this, args); } }