public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { float propertyHeight = EditorGUIUtility.singleLineHeight; if (property.isExpanded) { var keysProperty = property.FindPropertyRelative(KeysFieldName); var valuesProperty = property.FindPropertyRelative(ValuesFieldName); foreach (var entry in EnumerateEntries(keysProperty, valuesProperty)) { var keyProperty = entry.keyProperty; var valueProperty = entry.valueProperty; float keyPropertyHeight = EditorGUI.GetPropertyHeight(keyProperty); float valuePropertyHeight = valueProperty != null?EditorGUI.GetPropertyHeight(valueProperty) : 0f; float lineHeight = Mathf.Max(keyPropertyHeight, valuePropertyHeight); propertyHeight += lineHeight; } ConflictState conflictState = GetConflictState(property); if (conflictState.conflictIndex != -1) { propertyHeight += conflictState.conflictLineHeight; } } return(propertyHeight); }
public static List <Conflict> SearchConflicts(ConflictState state, bool shouldLookUpper = false) { using (var repo = new CRUDRepository <Conflict>()) { var res = repo.GetQuery <Conflict>(); if (!shouldLookUpper) { return(res.Where(c => c.State == (int)state) .Include("UsersInConflicts.User") .Include(c => c.Invitations) .Include(c => c.ConflictType) .Include(c => c.Arbiter) .OrderByDescending(c => c.Id) .ToList()); } else { return(res.Where(c => c.State >= (int)state) .Include("UsersInConflicts.User") .Include(c => c.Arbiter) .Include(c => c.ConflictType) .Include(c => c.Invitations) .OrderByDescending(c => c.Id) .ToList()); } } }
/// <summary> /// Creates a new empty MergeChunk /// </summary> /// <param name="sequenceIndex">determines to which sequence this chunks belongs to. Same as in <see cref="MergeResult.add"/> /// </param> /// <param name="begin">the first element from the specified sequence which should be included in the merge result. Indexes start with 0.</param> /// <param name="end"> /// specifies the end of the range to be added. The element this index points to is the first element which not added to the /// merge result. All elements between begin (including begin) and this element are added. /// </param> /// <param name="conflictState">the state of this chunk. See <see cref="ConflictState"/></param> public MergeChunk(int sequenceIndex, int begin, int end, ConflictState conflictState) { this.sequenceIndex = sequenceIndex; this.begin = begin; this.end = end; this.conflictState = conflictState; }
private static ConflictState GetConflictState(SerializedProperty property) { PropertyIdentity propId = new PropertyIdentity(property); if (!s_conflictStateDict.TryGetValue(propId, out ConflictState conflictState)) { conflictState = new ConflictState(); s_conflictStateDict.Add(propId, conflictState); } return(conflictState); }
private static ConflictState GetConflictState(SerializedProperty property) { var conflictState = default(ConflictState); var propId = new PropertyIdentity(property); if (!conflictStateMap.TryGetValue(propId, out conflictState)) { conflictState = new ConflictState(); conflictStateMap.Add(propId, conflictState); } return(conflictState); }
protected virtual ConflictState GetConflictState(SerializedProperty property) { ConflictState conflictState; PropertyIdentity propId = new PropertyIdentity(property); if (!conflictStateDict.TryGetValue(propId, out conflictState)) { conflictState = new ConflictState(); conflictStateDict.Add(propId, conflictState); } return(conflictState); }
internal Conflict(string key, string labelKey, string[] pks, ConflictType type, ConflictState state, IGeometry shape, string updateUser, DateTime updateTime, string pkField) { this.key = key; this.pks = pks; this.type = type; this.state = state; this.updateUser = updateUser; this.updateTime = updateTime; this.shape = shape; this.resolved_label = ResolveLabel(labelKey,pks,updateUser,updateTime); }
static void SaveProperty(SerializedProperty keyProperty, SerializedProperty valueProperty, int index, int otherIndex, ConflictState conflictState) { conflictState.conflictKey = GetPropertyValue(keyProperty); conflictState.conflictValue = GetPropertyValue(valueProperty); var keyPropertyHeight = EditorGUI.GetPropertyHeight(keyProperty); var valuePropertyHeight = EditorGUI.GetPropertyHeight(valueProperty); var lineHeight = Mathf.Max(keyPropertyHeight, valuePropertyHeight); conflictState.conflictLineHeight = lineHeight; conflictState.conflictIndex = index; conflictState.conflictOtherIndex = otherIndex; conflictState.conflictKeyPropertyExpanded = keyProperty.isExpanded; conflictState.conflictValuePropertyExpanded = valueProperty.isExpanded; }
static ConflictState GetConflictState(SerializedProperty property) { var propId = new PropertyIdentity(property); if (s_conflictStateDict.TryGetValue(propId, out var conflictState)) { return(conflictState); } conflictState = new ConflictState(); s_conflictStateDict.Add(propId, conflictState); return(conflictState); }
private static void SaveProperty(SerializedProperty keyProperty, SerializedProperty valueProperty, int index, int otherIndex, ConflictState conflictState) { conflictState.ConflictKey = GetPropertyValue(keyProperty); conflictState.ConflictValue = valueProperty != null?GetPropertyValue(valueProperty) : null; float keyPropertyHeight = EditorGUI.GetPropertyHeight(keyProperty); float valuePropertyHeight = valueProperty != null?EditorGUI.GetPropertyHeight(valueProperty) : 0f; float lineHeight = Mathf.Max(keyPropertyHeight, valuePropertyHeight); conflictState.ConflictLineHeight = lineHeight; conflictState.ConflictIndex = index; conflictState.ConflictOtherIndex = otherIndex; conflictState.ConflictKeyPropertyExpanded = keyProperty.isExpanded; conflictState.ConflictValuePropertyExpanded = valueProperty?.isExpanded ?? false; }
public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { float propertyHeight = EditorGUIUtility.singleLineHeight; if (property.isExpanded) { var keysProperty = property.FindPropertyRelative(KeysFieldName); var valuesProperty = property.FindPropertyRelative(ValuesFieldName); foreach (var entry in EnumerateEntries(keysProperty, valuesProperty)) { if (entry.keyProperty.isExpanded) { propertyHeight += 4 * (EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing); } else { propertyHeight += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; } } ConflictState conflictState = GetConflictState(property); if (conflictState.conflictIndex != -1) { if (conflictState.conflictKeyPropertyExpanded) { propertyHeight += 4 * (EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing); } else { propertyHeight += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; } } } return(propertyHeight); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { label = EditorGUI.BeginProperty(position, label, property); Action buttonAction = Action.None; int buttonActionIndex = 0; var keyArrayProperty = property.FindPropertyRelative(KeysFieldName); var valueArrayProperty = property.FindPropertyRelative(ValuesFieldName); ConflictState conflictState = GetConflictState(property); if (conflictState.conflictIndex != -1) { keyArrayProperty.InsertArrayElementAtIndex(conflictState.conflictIndex); var keyProperty = keyArrayProperty.GetArrayElementAtIndex(conflictState.conflictIndex); SetPropertyValue(keyProperty, conflictState.conflictKey); keyProperty.isExpanded = conflictState.conflictKeyPropertyExpanded; if (valueArrayProperty != null) { valueArrayProperty.InsertArrayElementAtIndex(conflictState.conflictIndex); var valueProperty = valueArrayProperty.GetArrayElementAtIndex(conflictState.conflictIndex); SetPropertyValue(valueProperty, conflictState.conflictValue); valueProperty.isExpanded = conflictState.conflictValuePropertyExpanded; } } var buttonWidth = s_buttonStyle.CalcSize(s_iconPlus).x; var labelPosition = position; labelPosition.height = EditorGUIUtility.singleLineHeight; if (property.isExpanded) { labelPosition.xMax -= s_buttonStyle.CalcSize(s_iconPlus).x; } EditorGUI.PropertyField(labelPosition, property, label, false); // property.isExpanded = EditorGUI.Foldout(labelPosition, property.isExpanded, label); if (property.isExpanded) { var buttonPosition = position; buttonPosition.xMin = buttonPosition.xMax - buttonWidth; buttonPosition.height = EditorGUIUtility.singleLineHeight; EditorGUI.BeginDisabledGroup(conflictState.conflictIndex != -1); if (GUI.Button(buttonPosition, s_iconPlus, s_buttonStyle)) { buttonAction = Action.Add; buttonActionIndex = keyArrayProperty.arraySize; } EditorGUI.EndDisabledGroup(); EditorGUI.indentLevel++; var linePosition = position; linePosition.y += EditorGUIUtility.singleLineHeight; linePosition.xMax -= buttonWidth; foreach (var entry in EnumerateEntries(keyArrayProperty, valueArrayProperty)) { var keyProperty = entry.keyProperty; var valueProperty = entry.valueProperty; int i = entry.index; float lineHeight = DrawKeyValueLine(keyProperty, valueProperty, linePosition, i); buttonPosition = linePosition; buttonPosition.x = linePosition.xMax; buttonPosition.height = EditorGUIUtility.singleLineHeight; if (GUI.Button(buttonPosition, s_iconMinus, s_buttonStyle)) { buttonAction = Action.Remove; buttonActionIndex = i; } if (i == conflictState.conflictIndex && conflictState.conflictOtherIndex == -1) { var iconPosition = linePosition; iconPosition.size = s_buttonStyle.CalcSize(s_warningIconNull); GUI.Label(iconPosition, s_warningIconNull); } else if (i == conflictState.conflictIndex) { var iconPosition = linePosition; iconPosition.size = s_buttonStyle.CalcSize(s_warningIconConflict); GUI.Label(iconPosition, s_warningIconConflict); } else if (i == conflictState.conflictOtherIndex) { var iconPosition = linePosition; iconPosition.size = s_buttonStyle.CalcSize(s_warningIconOther); GUI.Label(iconPosition, s_warningIconOther); } linePosition.y += lineHeight; } EditorGUI.indentLevel--; } if (buttonAction == Action.Add) { keyArrayProperty.InsertArrayElementAtIndex(buttonActionIndex); if (valueArrayProperty != null) { valueArrayProperty.InsertArrayElementAtIndex(buttonActionIndex); } } else if (buttonAction == Action.Remove) { DeleteArrayElementAtIndex(keyArrayProperty, buttonActionIndex); if (valueArrayProperty != null) { DeleteArrayElementAtIndex(valueArrayProperty, buttonActionIndex); } } conflictState.conflictKey = null; conflictState.conflictValue = null; conflictState.conflictIndex = -1; conflictState.conflictOtherIndex = -1; conflictState.conflictLineHeight = 0f; conflictState.conflictKeyPropertyExpanded = false; conflictState.conflictValuePropertyExpanded = false; foreach (var entry1 in EnumerateEntries(keyArrayProperty, valueArrayProperty)) { var keyProperty1 = entry1.keyProperty; int i = entry1.index; object keyProperty1Value = GetPropertyValue(keyProperty1); if (keyProperty1Value == null) { var valueProperty1 = entry1.valueProperty; SaveProperty(keyProperty1, valueProperty1, i, -1, conflictState); DeleteArrayElementAtIndex(keyArrayProperty, i); if (valueArrayProperty != null) { DeleteArrayElementAtIndex(valueArrayProperty, i); } break; } foreach (var entry2 in EnumerateEntries(keyArrayProperty, valueArrayProperty, i + 1)) { var keyProperty2 = entry2.keyProperty; int j = entry2.index; object keyProperty2Value = GetPropertyValue(keyProperty2); if (ComparePropertyValues(keyProperty1Value, keyProperty2Value)) { var valueProperty2 = entry2.valueProperty; SaveProperty(keyProperty2, valueProperty2, j, i, conflictState); DeleteArrayElementAtIndex(keyArrayProperty, j); if (valueArrayProperty != null) { DeleteArrayElementAtIndex(valueArrayProperty, j); } goto breakLoops; } } } breakLoops: EditorGUI.EndProperty(); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { label = EditorGUI.BeginProperty(position, label, property); var pairsProperty = property.FindPropertyRelative(PairsFieldName); _conflictState = GetConflictState(property); if (_conflictState.conflictIndex != -1 && _conflictState.conflictIndex <= pairsProperty.arraySize) { pairsProperty.InsertArrayElementAtIndex(_conflictState.conflictIndex); var pairProperty = pairsProperty.GetArrayElementAtIndex(_conflictState.conflictIndex); SetPropertyValue(pairProperty, _conflictState.conflictPair); pairProperty.isExpanded = _conflictState.conflictPairPropertyExpanded; } var labelPosition = position; labelPosition.height = EditorGUIUtility.singleLineHeight; EditorGUI.PropertyField(labelPosition, property, label, false); if (property.isExpanded) { ReorderableList reorderableList = GetList(pairsProperty, label); var listRect = position; listRect.y += EditorGUIUtility.singleLineHeight; reorderableList.DoList(listRect); } _conflictState.conflictPair = null; _conflictState.conflictIndex = -1; _conflictState.conflictOtherIndex = -1; _conflictState.conflictLineHeight = 0f; _conflictState.conflictPairPropertyExpanded = false; for (int i = 0; i < pairsProperty.arraySize; i++) { var pairProperty1 = pairsProperty.GetArrayElementAtIndex(i); var keyProperty1 = pairProperty1.FindPropertyRelative(KeyFieldName); object keyProperty1Value = GetPropertyValue(keyProperty1); if (keyProperty1Value == null) { SaveProperty(pairProperty1, i, -1, _conflictState); pairsProperty.DeleteArrayElementAtIndex(i); break; } for (int j = i + 1; j < pairsProperty.arraySize; j++) { var pairProperty2 = pairsProperty.GetArrayElementAtIndex(j); var keyProperty2 = pairProperty2.FindPropertyRelative(KeyFieldName); if (SerializedProperty.DataEquals(keyProperty1, keyProperty2)) { SaveProperty(pairProperty2, j, i, _conflictState); pairsProperty.DeleteArrayElementAtIndex(j); goto breakLoops; } } } breakLoops: EditorGUI.EndProperty(); }
static void SaveProperty(SerializedProperty pairProperty, int index, int otherIndex, ConflictState conflictState) { conflictState.conflictPair = GetPropertyValue(pairProperty); float pairPropertyHeight = EditorGUI.GetPropertyHeight(pairProperty); conflictState.conflictLineHeight = pairPropertyHeight; conflictState.conflictIndex = index; conflictState.conflictOtherIndex = otherIndex; conflictState.conflictPairPropertyExpanded = pairProperty.isExpanded; }