Ejemplo n.º 1
0
 public static bool ParseMultiplicityString(string newCardinality, out uint?lower, out UnlimitedNatural upper)
 {
     try
     {
         if (newCardinality.Contains(".."))
         {
             int pos = newCardinality.IndexOf("..");
             lower = ParseNullabelUint(newCardinality.Substring(0, pos));
             upper = ParseUnlimitedNatural(newCardinality.Substring(pos + 2));
         }
         else
         {
             lower = uint.Parse(newCardinality);
             upper = (UnlimitedNatural)lower;
         }
         return(true);
     }
     catch (FormatException)
     {
         ErrDialog errorDialog = new ErrDialog();
         errorDialog.Title              = "Bad cardinality format";
         errorDialog.label1.Text        = "Solution:";
         errorDialog.textBlock1.Content = CommandError.CMDERR_CARDINALITY_FORMAT + newCardinality;
         errorDialog.label2.Text        = "";
         errorDialog.tbCommand.Text     = "Input cardinality in following format: '<lower>..<upper>' or '<cardinality>' or '<lower>..*'";
         errorDialog.tbExMsg.Visibility = Visibility.Collapsed;
         errorDialog.ShowDialog();
         lower = 0;
         upper = 0;
         return(false);
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Checks whether the new operation name is unique
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CheckUniqueOperationName(object sender, RoutedEventArgs e)
        {
            Operation oldContext = (Operation)((TextBox)sender).DataContext;

            if (oldContext.Name.Equals(((TextBox)sender).Text))
            {
                return;
            }

            foreach (Operation p in oldContext.Class.Operations)
            {
                if (p.Name.Equals(((TextBox)sender).Text))
                {
                    // Refuse new value

                    ErrDialog d = new ErrDialog();
                    d.SetText("Update operation\n", "Name \"" + ((TextBox)sender).Text + "\" cannot be used because it is already used in the collection.");
                    d.ShowDialog();

                    ((TextBox)sender).DataContext = null;
                    ((TextBox)sender).DataContext = oldContext;
                    return;
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Checks whether the new class name is unique
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CheckUniqueClassName(object sender, RoutedEventArgs e)
        {
            Class oldContext = (Class)((TextBox)sender).DataContext;

            if (oldContext.Name.Equals(((TextBox)sender).Text))
            {
                return;
            }

            foreach (Class c in oldContext.Schema.Model.Classes)
            {
                if (c.Name.Equals(((TextBox)sender).Text))
                {
                    // Refuse new value

                    ErrDialog d = new ErrDialog();
                    d.SetText("Rename element\n", "Name \"" + ((TextBox)sender).Text + "\" cannot be used because it is already used in the collection.");
                    d.ShowDialog();

                    ((TextBox)sender).DataContext = null;
                    ((TextBox)sender).DataContext = oldContext;
                    return;
                }
            }
        }
Ejemplo n.º 4
0
        private void CheckUniqueAliasName(object sender, RoutedEventArgs e)
        {
            PSMAttribute oldContext = (PSMAttribute)((TextBox)sender).DataContext;

            string text = ((TextBox)sender).Text;

            if (text == String.Empty)
            {
                text = null;
            }

            if (oldContext.AliasOrName == text)
            {
                return;
            }

            foreach (PSMAttribute p in oldContext.AttributeContainer.PSMAttributes)
            {
                if (p.AliasOrName == text)
                {
                    ErrDialog d = new ErrDialog();
                    d.SetText("Change alias of an attribute on a PSM diagram\n", "Name \"" + text + "\" cannot be used because it is already used in the collection.");
                    d.ShowDialog();

                    ((TextBox)sender).DataContext = null;
                    ((TextBox)sender).DataContext = oldContext;
                    return;
                }
            }
        }
Ejemplo n.º 5
0
        private void CheckUniqueAliasName(object sender, RoutedEventArgs e)
        {
            PSMAttribute oldContext = (PSMAttribute)((TextBox)sender).DataContext;

            string alias = oldContext.AliasOrName;

            if (alias.Equals(((TextBox)sender).Text))
            {
                return;
            }

            if (oldContext.AttributeContainer != null)
            {
                foreach (PSMAttribute p in oldContext.AttributeContainer.PSMAttributes)
                {
                    if (p.Alias.Equals(((TextBox)sender).Text))
                    {
                        ErrDialog d = new ErrDialog();
                        d.SetText("Change alias of an attribute on a PSM diagram\n", "Name \"" + ((TextBox)sender).Text + "\" cannot be used because it is already used in the collection.");
                        d.ShowDialog();

                        ((TextBox)sender).DataContext = null;
                        ((TextBox)sender).DataContext = oldContext;
                        return;
                    }
                }
            }
            else
            if (oldContext.Class != null)
            {
                foreach (PSMAttribute p in oldContext.Class.PSMAttributes)
                {
                    if (!string.IsNullOrEmpty(p.Alias) &&
                        p.Alias.Equals(((TextBox)sender).Text))
                    {
                        ErrDialog d = new ErrDialog();
                        d.SetText("Change alias of an attribute on a PSM diagram\n", "Name \"" + ((TextBox)sender).Text + "\" cannot be used because it is already used in the collection.");
                        d.ShowDialog();

                        ((TextBox)sender).DataContext = null;
                        ((TextBox)sender).DataContext = oldContext;
                        return;
                    }
                }
            }
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Executes "Undo" of the command. This means removing the command from the "Undo" stack and moving it
 /// to the "Redo" stack and calling
 /// <see cref="CommandBase.UndoOperation"/>.
 /// </summary>
 public override sealed void UnExecute()
 {
     // assert the command is at the top of the undo stack
     Debug.Assert(UndoStack != null && UndoStack.Count > 0 && UndoStack.Peek() == this);
     // pop command from the undo stack
     UndoStack.Pop();
     // push command to the redo stack
     // call the actual undo method
     if (UndoOperation() == OperationResult.OK)
     {
         Debug.WriteLine(string.Format("Undo of command {0} executed", this));
         RedoStack.Push(this);
     }
     else
     {
         Debug.WriteLine(string.Format("ERROR: undo of command {0} failed!", this));
         ErrDialog d = new ErrDialog();
         d.tbCommand.Text = string.Format("Undo of command {0} failed.", this);
         d.tbExMsg.Text   = this.ErrorDescription;
         d.ShowDialog();
         UndoStack.Invalidate();
     }
 }