Exemplo n.º 1
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;
                }
            }
        }
Exemplo n.º 2
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;
                }
            }
        }
Exemplo n.º 3
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;
                }
            }
        }
Exemplo n.º 4
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;
                    }
                }
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Checks whether the new multiplicity is a correct one
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CheckCorrectMultiplicity(object sender, RoutedEventArgs e)
        {
            TextBox        t      = (TextBox)sender;
            AssociationEnd oldEnd = (AssociationEnd)t.DataContext;

            NUml.Uml2.UnlimitedNatural oldUpper = oldEnd.Upper;
            uint?oldLower = oldEnd.Lower;

            Regex numbers = new Regex("^[0-9]+$");

            Match m = numbers.Match(((TextBox)sender).Text);

            if (m.Success) // correct numerical imput
            {
                if (t.Name.Equals("upperBox") && int.Parse(t.Text) >= oldLower)
                {
                    return;
                }
                else
                if (t.Name.Equals("lowerBox"))
                {
                    if (oldUpper.ToString().Equals("*") || int.Parse(t.Text) <= oldUpper.Value)
                    {
                        return;
                    }
                }
            }
            else
            if (t.Text.Equals("*") && t.Name.Equals("upperBox"))
            {
                return;
            }

            // New value refused

            ErrDialog ed = new ErrDialog();

            ed.SetText("Change element multiplicity\n", "Lower bound cannot be greater than upper bound");
            ed.Show();

            ((TextBox)sender).DataContext = null;
            ((TextBox)sender).DataContext = oldEnd;
            return;
        }