protected void AddDefaultAttributeValues(Domain.AttributeValue parent) { Domain.AttributeValue addNewAttribute = new Kernel.Domain.AttributeValue(); addNewAttribute.IsAddNewItem = true; addNewAttribute.name = "Add new value..."; addNewAttribute.parent = this.Root; this.Root.childrenListChangeHandler.Items.Add(addNewAttribute); if (parent.isCompleted && parent.HasMoreElements()) { Domain.AttributeValue showModeAttributes = new Domain.AttributeValue(); showModeAttributes.IsShowMoreItem = true; showModeAttributes.name = "Show more value..."; showModeAttributes.parent = parent; parent.childrenListChangeHandler.Items.Add(showModeAttributes); } if (parent != this.Root && this.Root.isCompleted && this.Root.HasMoreElements()) { Domain.AttributeValue showModeAttributes = new Domain.AttributeValue(); showModeAttributes.IsShowMoreItem = true; showModeAttributes.name = "Show more values..."; showModeAttributes.parent = this.Root; this.Root.childrenListChangeHandler.Items.Add(showModeAttributes); } }
private void OnPasteClick(object sender, RoutedEventArgs e) { Domain.AttributeValue parent = GetSelectedValue(); if (parent == null || parent.IsDefault) { parent = this.Root; } List <Domain.AttributeValue> attributeValues = Kernel.Util.ClipbordUtil.GetAttributeValues(); if (attributeValues != null && attributeValues.Count > 0) { foreach (Domain.AttributeValue attributeValue in attributeValues) { attributeValue.name = GetNewAttributeValueName(attributeValue.name); ForgetDefaultAttributeValues(parent); attributeValue.SetParent(parent); parent.AddChild(attributeValue); AddDefaultAttributeValues(parent); addToSource(attributeValue); } if (Changed != null) { Changed(); } } }
/// <summary> /// /// </summary> /// <param name="selectedItems"></param> /// <returns></returns> protected bool isContiguous(List <Domain.AttributeValue> selectedItems) { if (selectedItems.Count == 1) { return(true); } selectedItems.BubbleSort(); Domain.AttributeValue parent = null; int i = 0; int index = -1; foreach (Domain.AttributeValue attributeValue in selectedItems) { Domain.AttributeValue newparent = attributeValue.parent; int newindex = newparent != null?newparent.childrenListChangeHandler.Items.IndexOf(attributeValue) : -1; if (++i > 1) { if (parent != newparent) { return(false); } if (index + 1 != newindex) { return(false); } } parent = newparent; index = newindex; } return(true); }
/// <summary> /// Add default nodes /// </summary> /// <param name="parent"></param> protected virtual void AddDefaultItems(Persistent parent) { if (parent == null || parent.IsDefault) { return; } if (parent.isCompleted && parent.HasMoreElements()) { AttributeValue showModeAttributes = new Domain.AttributeValue(); showModeAttributes.IsShowMoreItem = true; showModeAttributes.name = SHOW_MORE_LABEL; if (parent is Domain.Attribute) { Domain.Attribute attribute = (Domain.Attribute)parent; showModeAttributes.attribut = attribute; attribute.Items.Add(showModeAttributes); } else if (parent is AttributeValue) { AttributeValue value = (AttributeValue)parent; showModeAttributes.parent = value; value.childrenListChangeHandler.Items.Add(showModeAttributes); } } }
private void removeFromSource(Domain.AttributeValue attributeValue) { Source.Remove(attributeValue); foreach (Domain.AttributeValue child in attributeValue.childrenListChangeHandler.Items) { removeFromSource(child); } }
private bool IsUsedToGenerateUniverse(Domain.AttributeValue value) { if (value != null && value.usedToGenerateUniverse && Kernel.Application.ApplicationManager.Instance.AllocationCount > 0) { string message = "You're not allowed to modify value." + "\n" + "You have to clear allocation before modify value."; Kernel.Util.MessageDisplayer.DisplayWarning("Modify value", message); return(true); } return(false); }
private void OnExpanded(object sender, TreeListNodeAllowEventArgs e) { Domain.AttributeValue value = (Domain.AttributeValue)e.Row; if (value != null && value != this.Root && Expanded != null) { ForgetDefaultAttributeValues(value); Expanded(value); AddDefaultAttributeValues(value); } }
private void OnOutdentClick(object sender, RoutedEventArgs e) { List <Domain.AttributeValue> attributeValues = GetSelectedValues(); if (attributeValues.Count == 0) { return; } attributeValues.BubbleSort(); foreach (Domain.AttributeValue attributeValue in attributeValues) { Domain.AttributeValue parent = attributeValue.parent; if (parent == null) { parent = this.Root; } Domain.AttributeValue grandParent = parent.parent; if (grandParent == null) { return; } ForgetDefaultAttributeValues(grandParent); parent.ForgetChild(attributeValue); grandParent.AddChild(attributeValue); parent.IsExpanded = true; int row = Source.IndexOf(grandParent); if (row >= 0) { Source.Remove(grandParent); Source.Insert(row, grandParent); } else { row = Source.Count; Source.Remove(attributeValue); if (row - 2 >= 0) { Source.Insert(row - 2, attributeValue); } else { Source.Add(attributeValue); } } AddDefaultAttributeValues(grandParent); } treeList.SelectedItems = attributeValues; if (Changed != null) { Changed(); } }
/// <summary> /// Display children od root node /// </summary> /// <param name="root"> AttributeValue representing the root node </param> private void DisplayRoot(Domain.AttributeValue root) { Source = new ObservableCollection <Domain.AttributeValue>(); this.Root = root; if (this.Root != null) { ForgetDefaultAttributeValues(this.Root); AddDefaultAttributeValues(this.Root); RefreshParent(this.Root); } treeList.ItemsSource = Source; }
/// <summary> /// Can given items be outdent /// </summary> /// <param name="selectedItems"></param> /// <returns></returns> protected bool canIndent(List <Domain.AttributeValue> selectedItems) { foreach (Domain.AttributeValue attributeValue in selectedItems) { Domain.AttributeValue parent = attributeValue != null ? attributeValue.parent : null; int index = parent != null?parent.childrenListChangeHandler.Items.IndexOf(attributeValue) : -1; if (index <= 0) { return(false); } } return(selectedItems.Count > 0); }
protected Domain.AttributeValue GetCopy(Domain.AttributeValue attributeValue) { Domain.AttributeValue copy = new Domain.AttributeValue(); copy.name = "Copy Of " + attributeValue.name; copy.IsDefault = false; copy.position = attributeValue.position; copy.parent = null; foreach (Domain.AttributeValue child in attributeValue.childrenListChangeHandler.Items) { Domain.AttributeValue childcopy = GetCopy(child); copy.AddChild(childcopy); childcopy.parent = null; } return(copy); }
protected Domain.AttributeValue GetNewAttributeValue() { Domain.AttributeValue attribute = new Domain.AttributeValue(); attribute.name = "AttributeValue"; if (Root != null) { Kernel.Domain.AttributeValue m = null; int i = 1; do { attribute.name = "AttributeValue" + i++; m = (Domain.AttributeValue)Root.GetChildByName(attribute.name); }while (m != null); } return(attribute); }
/// <summary> /// /// </summary> /// <param name="attribute"></param> /// <param name="name"></param> /// <returns>La attribute à copier</returns> private bool ValidateName(Kernel.Domain.AttributeValue value, string name) { if (string.IsNullOrWhiteSpace(name)) { Kernel.Util.MessageDisplayer.DisplayError("Empty value name", "Name can't be empty! "); return(false); } Domain.AttributeValue found = getAttributeValueByName(this.Root, name); if (found == null || found.Equals(value)) { return(true); } Kernel.Util.MessageDisplayer.DisplayError("Duplicate value", "There is another value named : '" + name + "'!"); return(false); }
/// <summary> /// Can given items be move down /// </summary> /// <param name="selectedItems"></param> /// <returns></returns> protected bool canMoveDown(List <Domain.AttributeValue> selectedItems) { foreach (Domain.AttributeValue attributeValue in selectedItems) { Domain.AttributeValue parent = attributeValue != null ? attributeValue.parent : null; int index = parent != null?parent.childrenListChangeHandler.Items.IndexOf(attributeValue) : -1; int count = parent != null ? parent.childrenListChangeHandler.Items.Count : -1; bool moveDown = count - 1 > index && !parent.childrenListChangeHandler.Items[index + 1].IsDefault; if (!moveDown) { return(false); } } return(selectedItems.Count > 0); }
protected String GetNewAttributeValueName(string name) { Domain.AttributeValue attribute = new Domain.AttributeValue(); attribute.name = name; if (Root != null) { Kernel.Domain.AttributeValue m = (Domain.AttributeValue)Root.GetChildByName(attribute.name); int i = 1; while (m != null) { attribute.name = name + i++; m = (Domain.AttributeValue)Root.GetChildByName(attribute.name); } } return(attribute.name); }
private void OnMove(bool up) { List <Domain.AttributeValue> attributeValues = GetSelectedValues(); if (attributeValues.Count == 0) { return; } if (up) { attributeValues.BubbleSort(); } else { attributeValues.BubbleSortDesc(); } foreach (Domain.AttributeValue attributeValue in attributeValues) { Domain.AttributeValue parent = attributeValue.parent; if (parent == null) { parent = this.Root; } ForgetDefaultAttributeValues(parent); int position = attributeValue.position + (up ? -1 : 1); Domain.AttributeValue child = (Domain.AttributeValue)parent.GetChildByPosition(position); if (child != null) { child.SetPosition(attributeValue.position); parent.UpdateChild(child); attributeValue.SetPosition(position); parent.UpdateChild(attributeValue); int row = Source.IndexOf(child); Source.Remove(attributeValue); Source.Insert(row, attributeValue); } AddDefaultAttributeValues(parent); } treeList.SelectedItems = attributeValues; if (Changed != null) { Changed(); } }
private void OnDeleteClick(object sender, RoutedEventArgs e) { List <Domain.AttributeValue> attributeValues = GetSelectedValues(); if (attributeValues.Count == 0) { return; } String message = "Do you want to delete AttributeValue: '" + attributeValues[0] + "' ?"; if (attributeValues.Count > 1) { message = "Do you want to delete the " + attributeValues.Count + " selected attributeValues ?"; } MessageBoxResult result = Kernel.Util.MessageDisplayer.DisplayYesNoQuestion("Delete AttributeValue", message); if (result == MessageBoxResult.Yes) { foreach (Domain.AttributeValue attributeValue in attributeValues) { if (IsUsedToGenerateUniverse(attributeValue)) { return; } Domain.AttributeValue parent = attributeValue.parent; ForgetDefaultAttributeValues(parent); if (attributeValue.oid.HasValue) { parent.RemoveChild(attributeValue); } else { parent.ForgetChild(attributeValue); } AddDefaultAttributeValues(parent); removeFromSource(attributeValue); } if (Changed != null) { Changed(); } } }
protected Domain.AttributeValue getAttributeValueByName(Domain.AttributeValue parent, string name) { foreach (Domain.AttributeValue value in parent.childrenListChangeHandler.Items) { if (value.IsDefault) { continue; } if (value.name.ToUpper().Equals(name.ToUpper())) { return(value); } Domain.AttributeValue child = getAttributeValueByName(value, name); if (child != null) { return(child); } } return(null); }
public void addPage(Domain.AttributeValue selection, BrowserDataPage <Domain.AttributeValue> page) { if (!selection.isCompleted) { foreach (Domain.AttributeValue value in selection.childrenListChangeHandler.originalList.ToArray()) { selection.childrenListChangeHandler.forget(value); removeFromSource(value); } } Domain.AttributeValue sel = null; foreach (Domain.AttributeValue value in page.rows) { value.parent = selection; addToSource(value); sel = value; } selection.childrenListChangeHandler.Items.BubbleSort(); SetSelectedValue(sel); }
/// <summary> /// Select /// </summary> /// <param name="attribute">The AttributeValue to select</param> public void SetSelectedValue(Domain.AttributeValue value) { if (value != null) { if (value.parent != null) { value.parent.IsExpanded = true; } value.IsSelected = true; treeList.SelectedItem = value; } else { Domain.AttributeValue selection = GetSelectedValue(); if (selection != null) { selection.IsSelected = false; } treeList.SelectedItem = null; } }
/// <summary> /// Remove default nodes from root attribute /// </summary> protected void ForgetDefaultAttributeValues(Domain.AttributeValue parent) { foreach (Domain.AttributeValue value in parent.childrenListChangeHandler.Items.ToArray()) { if (value.IsDefault) { parent.childrenListChangeHandler.Items.Remove(value); } //this.Source.Remove(value); } if (parent != this.Root) { foreach (Domain.AttributeValue value in this.Root.childrenListChangeHandler.Items.ToArray()) { if (value.IsDefault) { this.Root.childrenListChangeHandler.Items.Remove(value); //this.Source.Remove(value); } } } }
private void OnIndentClick(object sender, RoutedEventArgs e) { List <Domain.AttributeValue> attributeValues = GetSelectedValues(); if (attributeValues.Count == 0) { return; } attributeValues.BubbleSort(); foreach (Domain.AttributeValue attributeValue in attributeValues) { Domain.AttributeValue parent = attributeValue.parent; if (parent == null) { parent = this.Root; } int position = attributeValue.GetPosition(); Domain.AttributeValue brother = (Domain.AttributeValue)parent.GetChildByPosition(position - 1); if (brother == null) { return; } ForgetDefaultAttributeValues(parent); parent.ForgetChild(attributeValue); brother.AddChild(attributeValue); brother.IsExpanded = true; int row = Source.IndexOf(brother); Source.Remove(brother); Source.Insert(row, brother); AddDefaultAttributeValues(parent); } treeList.SelectedItems = attributeValues; if (Changed != null) { Changed(); } }
private void addToSource(Domain.AttributeValue attributeValue) { int row = Source.Count; if (row - 2 >= 0) { Source.Insert(row - 2, attributeValue); } else if (row - 1 >= 0) { Source.Insert(row - 1, attributeValue); } else { Source.Add(attributeValue); } attributeValue.childrenListChangeHandler.Items = new ObservableCollection <Domain.AttributeValue>(attributeValue.childrenListChangeHandler.newItems); foreach (Domain.AttributeValue child in attributeValue.childrenListChangeHandler.Items) { child.SetParent(attributeValue); child.name = GetNewAttributeValueName(child.name); addToSource(child); } }
private void OnNewClick(object sender, RoutedEventArgs e) { Domain.AttributeValue parent = GetSelectedValue(); if (IsUsedToGenerateUniverse(parent)) { return; } Kernel.Domain.AttributeValue attributeValue = GetNewAttributeValue(); if (parent == null) { parent = this.Root; } if (parent != null) { ForgetDefaultAttributeValues(parent); parent.AddChild(attributeValue); AddDefaultAttributeValues(parent); int row = Source.Count; Source.Remove(attributeValue); if (row - 2 >= 0) { Source.Insert(row - 2, attributeValue); } else { Source.Add(attributeValue); } SetSelectedValue(attributeValue); if (Changed != null) { Changed(); } } }
/// <summary> /// Display entity AttributeValues. /// Builds the root node and calls DisplayRoot() /// </summary> /// <param name="entity"> Entity to display </param> public void DisplayAttributeValue(Domain.AttributeValue attributeValue) { this.DisplayRoot(attributeValue); }
/// <summary> /// Cette méthode vérifie si le presse-papier contient un type de donnés et /// renvoie un objet de ce type /// </summary> /// <param name="format">Le format du type de données</param> /// <returns>L'objet présent dans le presse-papiers</returns> public static List <Domain.IHierarchyObject> GetHierarchyObject(string format) { List <Domain.IHierarchyObject> copiedElements = new List <Domain.IHierarchyObject>(0); if (format == null) { return(copiedElements); } if (System.Windows.Clipboard.ContainsData(format)) { try { if (System.Windows.Clipboard.GetData(format) is IList) { copiedElements = (List <Domain.IHierarchyObject>)System.Windows.Clipboard.GetData(format); } else { copiedElements.Add(System.Windows.Clipboard.GetData(format) as Domain.IHierarchyObject); } return(copiedElements); } catch (Exception) { Kernel.Util.MessageDisplayer.DisplayError("Error copy", "Unable to paste " + format.Split('.')[1]); return(null); } } else if (System.Windows.Clipboard.ContainsText()) { string name = System.Windows.Clipboard.GetText(); if (format.Equals(GROUP_CLIPBOARD_FORMAT)) { foreach (string copies in ExcelCellsCopies(name)) { Domain.BGroup group = new Domain.BGroup(); group.name = copies; group.subjectType = Domain.SubjectType.DEFAULT.label; copiedElements.Add(group as Domain.BGroup); } return(copiedElements); } if (format.Equals(ATTRIBUTE_CLIPBOARD_FORMAT)) { List <String> listeResult = ExcelCellsCopies(name); if (listeResult[0] == IS_PARENT_CHILD_MODE) { listeResult.RemoveAt(0); } foreach (string copies in listeResult) { Domain.Attribute attribute = new Domain.Attribute(); attribute.name = copies; copiedElements.Add(attribute as Domain.Attribute); } return(copiedElements); } if (format.Equals(ATTRIBUTE_VALUE_CLIPBOARD_FORMAT)) { Kernel.Domain.AttributeValue parent = null; List <String> listeResult = ExcelCellsCopies(name); if (listeResult == null) { return(null); } if (listeResult[0] == IS_PARENT_CHILD_MODE) { parent = new Domain.AttributeValue() { name = listeResult[1] }; listeResult.RemoveAt(0); listeResult.RemoveAt(0); } foreach (string copies in listeResult) { Domain.AttributeValue value = new Domain.AttributeValue(); value.name = copies; if (parent != null) { parent.AddChild(value as Domain.AttributeValue); } else { copiedElements.Add(value as Domain.AttributeValue); } } if (parent != null) { copiedElements.Add(parent as Domain.AttributeValue); } return(copiedElements); // List<String> listeResult = ExcelGetCellsCopies(name); // List<Kernel.Domain.AttributeValue> Liste = ExcelGetCellsCopies(name, ATTRIBUTE_VALUE_CLIPBOARD_FORMAT); //if (listeResult == null) return null; //if (listeResult[0] == IS_PARENT_CHILD_MODE) //{ // parent = new Domain.AttributeValue() // { // name = listeResult[1] // }; // listeResult.RemoveAt(0); // listeResult.RemoveAt(0); //} //foreach (string copies in listeResult) //{ // Domain.AttributeValue value = new Domain.AttributeValue(); // value.name = copies; // if (parent != null) parent.AddChild(value as Domain.AttributeValue); // else copiedElements.Add(value as Domain.AttributeValue); //} //if (parent != null) copiedElements.Add(parent as Domain.AttributeValue); //return copiedElements; } } return(null); }
private void OnCellValueChanged(object sender, TreeListCellValueChangedEventArgs e) { if (e.Row != null) { String name = e.Value != null?e.Value.ToString().Trim() : ""; String oldName = e.OldValue != null?e.OldValue.ToString().Trim() : ""; Domain.AttributeValue attributeValue = (Domain.AttributeValue)e.Row; if (!ValidateName(attributeValue, name)) { attributeValue.name = oldName; e.Handled = true; return; } if (!name.Equals(oldName.Trim())) { if (attributeValue.IsDefault) { attributeValue.name = oldName; Domain.AttributeValue newAttributeValue = new Domain.AttributeValue(); newAttributeValue.name = name; newAttributeValue.parent = this.Root; ForgetDefaultAttributeValues(this.Root); this.Root.AddChild(newAttributeValue); AddDefaultAttributeValues(this.Root); int row = Source.Count; if (row - 2 >= 0) { if (Source[row - 2].IsDefault) { Source.Insert(row - 2, newAttributeValue); } else { Source.Insert(row - 1, newAttributeValue); } } else if (row - 1 >= 0) { Source.Insert(row - 1, newAttributeValue); } else { Source.Add(newAttributeValue); } SetSelectedValue(newAttributeValue); DisplayRoot(this.Root); } else { attributeValue.name = name; ForgetDefaultAttributeValues(attributeValue.parent); attributeValue.parent.UpdateChild(attributeValue); AddDefaultAttributeValues(attributeValue.parent); SetSelectedValue(attributeValue); } if (Changed != null) { Changed(); } } } }
public static List <Object> GetTextDatas(string format) { List <Object> datas = new List <Object>(0); if (format != null && System.Windows.Clipboard.ContainsText()) { string name = System.Windows.Clipboard.GetText(); if (format.Equals(GROUP_CLIPBOARD_FORMAT)) { foreach (string copies in ExcelCellsCopies(name)) { Domain.BGroup group = new Domain.BGroup(); group.name = copies; group.subjectType = Domain.SubjectType.DEFAULT.label; datas.Add(group as Domain.BGroup); } } else if (format.Equals(MEASURE_CLIPBOARD_FORMAT)) { Kernel.Domain.Measure parent = null; List <String> listeResult = ExcelCellsCopies(name); if (listeResult == null) { return(null); } if (listeResult[0] == IS_PARENT_CHILD_MODE) { parent = new Domain.Measure() { name = listeResult[1] }; listeResult.RemoveAt(0); listeResult.RemoveAt(0); } foreach (string copies in listeResult) { Domain.Measure value = new Domain.Measure(); value.name = copies.Trim(); if (parent != null) { parent.AddChild(value as Domain.Measure); } else { datas.Add(value as Domain.Measure); } } if (parent != null) { datas.Add(parent as Domain.Measure); } } else if (format.Equals(ATTRIBUTE_CLIPBOARD_FORMAT)) { List <String> listeResult = ExcelCellsCopies(name); if (listeResult[0] == IS_PARENT_CHILD_MODE) { listeResult.RemoveAt(0); } foreach (string copies in listeResult) { Domain.Attribute attribute = new Domain.Attribute(); attribute.name = copies; datas.Add(attribute as Domain.Attribute); } } else if (format.Equals(ATTRIBUTE_VALUE_CLIPBOARD_FORMAT)) { Kernel.Domain.AttributeValue parent = null; List <String> listeResult = ExcelCellsCopies(name); if (listeResult == null) { return(null); } if (listeResult[0] == IS_PARENT_CHILD_MODE) { parent = new Domain.AttributeValue() { name = listeResult[1] }; listeResult.RemoveAt(0); listeResult.RemoveAt(0); } foreach (string copies in listeResult) { Domain.AttributeValue value = new Domain.AttributeValue(); value.name = copies; if (parent != null) { parent.AddChild(value as Domain.AttributeValue); } else { datas.Add(value as Domain.AttributeValue); } } if (parent != null) { datas.Add(parent as Domain.AttributeValue); } } } return(datas); }