Esempio n. 1
0
 public void Initialize(EditSession session)
 {
     this.objectTypeComboBox = new ObjectTypeComboBox(this.repository)
     {
         ActiveItem = (ObjectType)session.Property.GetValue(session.Instance)
     };
     this.objectTypeComboBox.Changed += this.ObjectTypeComboBoxChanged;
     this.Add(this.objectTypeComboBox);
     this.objectTypeComboBox.ShowAll();
     this.ShowAll();
 }
        public AddRelationTypeWizard(Repository repository, ObjectType associationObjectType)
        {
            this.repository = repository;

            this.Title         = Mono.Unix.Catalog.GetString("Allors Add RelationType Wizard");
            this.Icon          = Gdk.Pixbuf.LoadFromResource("Allors.R1.Development.GtkSharp.Icons.allors.ico");
            this.DefaultWidth  = 800;
            this.DefaultHeight = 1;

            var headerBox = new VBox
            {
                Spacing     = 10,
                BorderWidth = 10
            };

            this.VBox.PackStart(headerBox, false, false, 0);

            headerBox.PackStart(new HtmlLabel("<span size=\"large\"><b>Welcome to the Allors Add RelationType Wizard</b></span>", 0.5f));
            headerBox.PackStart(new HtmlLabel("This wizard adds a new relation type to your domain.", 0.5f));

            var form = new Form();

            this.VBox.PackStart(form);

            // Association Type
            var associationLabel = new HtmlLabel("<b>Association</b>");

            var associationObjectTypeLabel = new HtmlLabel("Object Type");

            this.associationObjectTypeComboBox          = new ObjectTypeComboBox(repository);
            this.associationObjectTypeComboBox.Changed += this.OnAssociationObjectTypeComboBoxOnChanged;
            this.associationObjectTypeErrorMessage      = new ErrorMessage();

            var associationSingularNameLabel = new HtmlLabel("Singular name");

            this.associationSingularNameEntry        = new Entry();
            this.associationSingularNameErrorMessage = new ErrorMessage();

            var associationPluralNameLabel = new HtmlLabel("Plural name");

            this.associationPluralNameEntry        = new Entry();
            this.associationPluralNameErrorMessage = new ErrorMessage();

            // Role Type
            var roleLabel = new HtmlLabel("<b>Role</b>");

            var roleObjectTypeLabel = new HtmlLabel("Object Type");

            this.roleObjectTypeComboBox          = new ObjectTypeComboBox(repository);
            this.roleObjectTypeComboBox.Changed += this.OnRoleObjectTypeComboBoxOnChanged;
            this.roleObjectTypeErrorMessage      = new ErrorMessage();

            var roleSingularNameLabel = new HtmlLabel("Singular name");

            this.roleSingularNameEntry        = new Entry();
            this.roleSingularNameErrorMessage = new ErrorMessage();

            var rolePluralNameLabel = new HtmlLabel("Plural name");

            this.rolePluralNameEntry        = new Entry();
            this.rolePluralNameErrorMessage = new ErrorMessage();

            // Relation Type
            var relationTypeLabel = new HtmlLabel("<b>Relation</b>");

            var multiplicityLabel = new HtmlLabel("Multiplicity");

            this.multiplicityComboBox          = new MultiplicityComboBox();
            this.multiplicityComboBox.Changed += this.OnMultiplicityComboBoxOnChanged;

            var explanationLabel = new HtmlLabel("Explanation");

            this.explanationEntry = new Entry {
                Sensitive = false
            };

            var buttonCancel = new Button
            {
                CanDefault   = true,
                UseStock     = true,
                UseUnderline = true,
                Label        = "gtk-cancel"
            };

            this.AddActionWidget(buttonCancel, -6);

            var buttonOk = new Button
            {
                CanDefault   = true,
                UseStock     = true,
                UseUnderline = true,
                Label        = "gtk-ok"
            };

            buttonOk.Clicked += this.OnButtonOkClicked;
            this.ActionArea.PackStart(buttonOk);

            // Table Layout
            // Association Type
            form.Attach(associationLabel, 0, 3, 0, 1, AttachOptions.Fill, AttachOptions.Fill, 0, 0);

            form.Attach(associationObjectTypeLabel, 0, 1, 1, 2, AttachOptions.Fill, AttachOptions.Fill, 0, 0);
            form.Attach(this.associationObjectTypeComboBox, 0, 1, 2, 3, AttachOptions.Fill | AttachOptions.Expand, AttachOptions.Fill, 0, 0);
            form.Attach(this.associationObjectTypeErrorMessage, 0, 1, 3, 4, AttachOptions.Fill, AttachOptions.Fill, 0, 0);

            form.Attach(associationSingularNameLabel, 1, 2, 1, 2, AttachOptions.Fill, AttachOptions.Fill, 0, 0);
            form.Attach(this.associationSingularNameEntry, 1, 2, 2, 3, AttachOptions.Fill | AttachOptions.Expand, AttachOptions.Fill, 0, 0);
            form.Attach(this.associationSingularNameErrorMessage, 1, 2, 3, 4, AttachOptions.Fill, AttachOptions.Fill, 0, 0);

            form.Attach(associationPluralNameLabel, 2, 3, 1, 2, AttachOptions.Fill, AttachOptions.Fill, 0, 0);
            form.Attach(this.associationPluralNameEntry, 2, 3, 2, 3, AttachOptions.Fill | AttachOptions.Expand, AttachOptions.Fill, 0, 0);
            form.Attach(this.associationPluralNameErrorMessage, 2, 3, 3, 4, AttachOptions.Fill, AttachOptions.Fill, 0, 0);

            // Role Type
            form.Attach(roleLabel, 0, 3, 4, 5, AttachOptions.Fill, AttachOptions.Fill, 0, 0);

            form.Attach(roleObjectTypeLabel, 0, 1, 5, 6, AttachOptions.Fill, AttachOptions.Fill, 0, 0);
            form.Attach(this.roleObjectTypeComboBox, 0, 1, 6, 7, AttachOptions.Fill | AttachOptions.Expand, AttachOptions.Fill, 0, 0);
            form.Attach(this.roleObjectTypeErrorMessage, 0, 1, 7, 8, AttachOptions.Fill | AttachOptions.Expand, AttachOptions.Fill, 0, 0);

            form.Attach(roleSingularNameLabel, 1, 2, 5, 6, AttachOptions.Fill, AttachOptions.Fill, 0, 0);
            form.Attach(this.roleSingularNameEntry, 1, 2, 6, 7, AttachOptions.Fill | AttachOptions.Expand, AttachOptions.Fill, 0, 0);
            form.Attach(this.roleSingularNameErrorMessage, 1, 2, 7, 8, AttachOptions.Fill, AttachOptions.Fill, 0, 0);

            form.Attach(rolePluralNameLabel, 2, 3, 5, 6, AttachOptions.Fill, AttachOptions.Fill, 0, 0);
            form.Attach(this.rolePluralNameEntry, 2, 3, 6, 7, AttachOptions.Fill | AttachOptions.Expand, AttachOptions.Fill, 0, 0);
            form.Attach(this.rolePluralNameErrorMessage, 2, 3, 7, 8, AttachOptions.Fill, AttachOptions.Fill, 0, 0);

            // Relation Type
            form.Attach(relationTypeLabel, 0, 3, 8, 9, AttachOptions.Fill, AttachOptions.Fill, 0, 0);

            form.Attach(multiplicityLabel, 0, 1, 9, 10, AttachOptions.Fill, AttachOptions.Fill, 0, 0);
            form.Attach(this.multiplicityComboBox, 0, 1, 10, 11, AttachOptions.Fill | AttachOptions.Expand, AttachOptions.Fill, 0, 0);

            form.Attach(explanationLabel, 1, 3, 9, 10, AttachOptions.Fill, AttachOptions.Fill, 0, 0);
            form.Attach(this.explanationEntry, 1, 3, 10, 11, AttachOptions.Fill | AttachOptions.Expand, AttachOptions.Fill, 0, 0);

            this.ShowAll();

            this.ResetErrorMessages();

            this.associationObjectTypeComboBox.ActiveItem = associationObjectType;
            this.multiplicityComboBox.ActiveItem          = Multiplicity.ManyToOne;
        }