示例#1
0
 /// <summary>
 /// A constructor to initialise a new instance, with a UIForm object 
 /// specified
 /// </summary>
 /// <param name="bo">The business object to be represented</param>
 /// <param name="uiForm"></param>
 /// <param name="controlFactory">the control factory used to create controls</param>
 public PanelFactory(BusinessObject bo, UIForm uiForm, IControlFactory controlFactory)
 {
     if (uiForm == null) throw new ArgumentNullException("uiForm");
     _uiForm = uiForm;
     _controlFactory = controlFactory;
     InitialiseFactory(bo);
 }
示例#2
0
        internal static void OpenWindow(WindowBase window)
        {
            UIForm form = new UIForm(window);
            form.CreateControl();
            //form.target = new SwapChainRenderTarget(GraphicsManager.device, form.Handle, form.ClientSize.Width, form.ClientSize.Height, false, SurfaceFormat.Color, DepthFormat.Depth24, 0, RenderTargetUsage.PreserveContents, PresentInterval.Default);
            //window.canvas = new Canvas(form.target);

            windows.Add(form);
            form.window.QueueFullRedraw();
            form.Show();
        }
示例#3
0
        public void Test_Construct_ShouldSetUIDefOnUIForm()
        {
            //---------------Set up test pack-------------------
            UIForm uiForm = new UIForm();

            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            UIDef uiDef = new UIDef("test", uiForm, null);

            //---------------Test Result -----------------------
            Assert.AreSame(uiDef, uiForm.UIDef);
        }
示例#4
0
 public void Test_Construct_WithUIFormTabs()
 {
     //---------------Set up test pack-------------------
     UIFormTab uiFormTab1 = new UIFormTab();
     UIFormTab uiFormTab2 = new UIFormTab();
     UIFormTab uiFormTab3 = new UIFormTab();
     //---------------Assert Precondition----------------
     //---------------Execute Test ----------------------
     UIForm uiForm = new UIForm(uiFormTab1, uiFormTab2, uiFormTab3);
     //---------------Test Result -----------------------
     Assert.AreEqual(3, uiForm.Count);
     Assert.AreSame(uiFormTab1, uiForm[0]);
     Assert.AreSame(uiFormTab2, uiForm[1]);
     Assert.AreSame(uiFormTab3, uiForm[2]);
 }
示例#5
0
        public void TestProtectedSets()
        {
            UIDefStub uiDef = new UIDefStub();

            Assert.AreEqual("uidef", uiDef.Name);
            uiDef.SetName("newuidef");
            Assert.AreEqual("newuidef", uiDef.Name);

            UIForm uiForm = new UIForm();
            Assert.IsNull(uiDef.UIForm);
            uiDef.SetUIForm(uiForm);
            Assert.AreEqual(uiForm, uiDef.UIForm);

            UIGrid uiGrid = new UIGrid();
            Assert.IsNull(uiDef.UIGrid);
            uiDef.SetUIGrid(uiGrid);
            Assert.AreEqual(uiGrid, uiDef.UIGrid);
        }
        public void UpdateForForm(UIForm form)
        {
            if (valueInspectorModel != null)
            valueInspectorModel.DetachEvents();

              propertiesTreeView.SuspendLayout();
              propertiesTreeView.Model = null;
              valueInspector = null;
              valueInspectorModel = null;

              if (form != null)
              {
            List<String> items;

            valueInspector = wbContext.get_inspector_for_selection(form, out items);

            if (valueInspector != null)
            {
              valueInspectorModel = new SimpleGrtTreeModel(propertiesTreeView, valueInspector, false);
              valueInspectorModel.AddColumn(nameNodeControl, (int)GrtValueInspector.Columns.Name, false);
              //!valueInspectorModel.AddColumn(_valueNodeControl, (int)GrtValueInspector.Columns.Value, true);
              _valueNodeControl.GrtTreeModel = valueInspectorModel.GrtTree;

              {
            TreeModelTooltipProvider tp = new TreeModelTooltipProvider();
            tp.Model = valueInspectorModel.GrtTree;
            tp.TooltipColumn = (int)GrtValueInspector.Columns.Description;
            nameNodeControl.ToolTipProvider = tp;
            _valueNodeControl.ToolTipProvider = tp;
              }

              propertiesTreeView.Model = valueInspectorModel;

             // TabText = "Selection Properties";
            }
              }

              propertiesTreeView.ResumeLayout();
        }
示例#7
0
 public SqlIdeForm(WbContext wbContext, UIForm uiForm)
     : base((uiForm as SqlEditorFormWrapper).grt_manager())
 {
     this.wbContext = wbContext;
       dbSqlEditorBE = uiForm as SqlEditorFormWrapper;
       Initialize();
       UpdateColors();
 }
 public void OpenGui()
 {
     _gui = new UIForm(); _gui.ShowDialog();
 }
示例#9
0
 public void Test_SetClassDef_ShouldSetClassDefOnFormFields()
 {
     //---------------Set up test pack-------------------
     var uiForm = new UIForm();
     var uiFormTab = new UIFormTab();
     var uiFormColumn = new UIFormColumn();
     var uiFormField = new UIFormField("fdafad", "fdafasd");
     uiForm.Add(uiFormTab);
     uiFormTab.Add(uiFormColumn);
     uiFormColumn.Add(uiFormField);
     var classDef = MockRepository.GenerateStub<IClassDef>();
     //---------------Assert Precondition----------------
     Assert.IsNull(uiFormField.ClassDef);
     //---------------Execute Test ----------------------
     uiForm.ClassDef = classDef;
     //---------------Test Result -----------------------
     Assert.AreSame(classDef, uiFormField.ClassDef);
 }
示例#10
0
        public void TestAddUIFormTab()
        {
            //---------------Set up test pack-------------------
            UIForm form = new UIForm();
            UIFormTab tab = new UIFormTab();

            //---------------Assert Precondition----------------
            Assert.IsNull(tab.UIForm);
            //---------------Execute Test ----------------------
            form.Add(tab);
            //---------------Test Result -----------------------
            Assert.AreSame(form, tab.UIForm);
        }
示例#11
0
        public void TestRemove()
        {
            UIFormTab tab = new UIFormTab();
            UIForm uiForm = new UIForm();
            uiForm.Add(tab);

            Assert.IsTrue(uiForm.Contains(tab));
            uiForm.Remove(tab);
            Assert.IsFalse(uiForm.Contains(tab));
        }
示例#12
0
        private static UIForm GetUiForm()
        {
            UIFormField field1 = new UIFormField("label1", "prop1", "control", null, null, null, true, null, null, null, LayoutStyle.Label);
            UIFormField field2 = new UIFormField("label2", "prop2", "control", null, null, null, true, null, null, null, LayoutStyle.Label);
            UIFormColumn uiFormColumn = new UIFormColumn();
            uiFormColumn.Add(field1);
            uiFormColumn.Add(field2);

            UIFormTab uiFormTab = new UIFormTab("Tab1");
            uiFormTab.Add(uiFormColumn);

            UIForm uiForm = new UIForm();
            uiForm.Add(uiFormTab);
            uiForm.Title = "ddd";
            uiForm.Height = 1;
            uiForm.Width = 3;
            return uiForm;
        }
        public void UpdateForView(UIForm Form)
        {
            if (changeTimer.Enabled)
            PushChanges();

              // Make sure we are initializing
              Initializing = true;

              try
              {
            List<String> items;
            GrtValue newObjList;
            String objDescr;
            form = Form;

            if (null != form)
              objDescr = wbContext.get_description_for_selection(form, out newObjList, out items);
            else
              objDescr = wbContext.get_description_for_selection(out newObjList, out items);

            // update only if selection was changed
            if (!wbContext.are_lists_equal(activeObjList, newObjList))
            {
              objSelComboBox.Items.Clear();

              // Set description text
              if (null != activeObjList)
            activeObjList.Dispose();
              activeObjList = newObjList;

              // Set properties
              NoItemsSelected = (null == items) || (0 == items.Count);
              MultipleItemsSelected = (items.Count > 1);

              // handle different number of selected items
              if (!NoItemsSelected)
              {
            objSelComboBox.SuspendLayout();
            objSelComboBox.Items.Clear();
            objSelComboBox.Items.AddRange(items.ToArray());
            objSelComboBox.ResumeLayout();

            objSelComboBox.SelectedIndex = 0;

            // lock on multi selection
            if (MultipleItemsSelected)
            {
              objDescr = "<double-click to overwrite multiple objects>";
              ObjectDescriptionEnabled = false;
            }
            else
              ObjectDescriptionEnabled = true;
              }
              else
              {
            objSelComboBox.SuspendLayout();
            objSelComboBox.Items.Clear();
            objSelComboBox.Items.Add("No Selection");
            objSelComboBox.ResumeLayout();

            objSelComboBox.SelectedIndex = 0;

            objDescr = "";
            ObjectDescriptionEnabled = false;
              }

              ObjectDescription = objDescr;
            }
              }
              finally
              {
            Initializing = false;
              }
        }
示例#14
0
        public void Test_NotSameType()
        {
            //---------------Set up test pack-------------------
            UIForm uiForm1 = new UIForm();
            //--------------Assert PreConditions----------------            

            //---------------Execute Test ----------------------
            bool methodEquals = uiForm1.Equals("fedafds");

            //---------------Test Result -----------------------
            Assert.IsFalse(methodEquals);
            //---------------Tear Down -------------------------          
        }
示例#15
0
        public void Test_NotEqual_DifWidth()
        {
            //---------------Set up test pack-------------------
            UIForm uiForm1 = new UIForm();
            uiForm1.Title = "Form1";
            uiForm1.Width = 100;
            UIForm uiForm2 = new UIForm();
            uiForm2.Title = "Form1";
            uiForm2.Width = 200;
            //--------------Assert PreConditions----------------            

            //---------------Execute Test ----------------------
            bool operatorEquals = uiForm1 == uiForm2;
            bool operatorNotEquals = uiForm1 != uiForm2;
            bool methodEquals = uiForm1.Equals(uiForm2);

            //---------------Test Result -----------------------
            Assert.IsFalse(operatorEquals);
            Assert.IsTrue(operatorNotEquals);
            Assert.IsFalse(methodEquals);
            //---------------Tear Down -------------------------          
        }
示例#16
0
 public void Test_NotEqualsNull()
 {
     UIForm uiForm1 = new UIForm();
     UIForm uiForm2 = null;
     Assert.IsFalse(uiForm1 == uiForm2);
     Assert.IsTrue(uiForm1 != uiForm2);
     Assert.IsFalse(uiForm1.Equals(uiForm2));
     Assert.AreNotEqual(uiForm1, uiForm2);
 }
示例#17
0
        public void TestCloneUIForm()
        {
            //---------------Set up test pack-------------------
            UIFormField field1 = new UIFormField("label1", "prop1", "control", null, null, null, true, null, null, null, LayoutStyle.Label);
            UIFormField field2 = new UIFormField("label2", "prop2", "control", null, null, null, true, null, null, null, LayoutStyle.Label);
            UIFormColumn uiFormColumn = new UIFormColumn();
            uiFormColumn.Add(field1);
            uiFormColumn.Add(field2);

            UIFormTab uiFormTab = new UIFormTab("Tab1");
            uiFormTab.Add(uiFormColumn);

            UIForm uiForm = new UIForm();
            uiForm.Add(uiFormTab);
            uiForm.Title = "ddd";
            uiForm.Height = 1;
            uiForm.Width = 3;

            //---------------Execute Test ----------------------
            IUIForm clonedForm = uiForm.Clone();

            //---------------Test Result -----------------------
            Assert.IsTrue(uiForm == (UIForm) clonedForm);
            Assert.IsTrue(uiForm.Equals(clonedForm));
            Assert.AreNotSame(uiForm, clonedForm);

            IUIFormTab clonedUIFormTab = clonedForm[0];
            Assert.AreEqual(uiForm[0], clonedUIFormTab,
                              "Should be a deep copy and the columns should be equal but copied");
            Assert.AreNotSame(uiFormTab, clonedUIFormTab, "Should be a deep copy and the columns should be equal but copied (not same)");
            //Verif cloned columns
            Assert.AreEqual(uiFormTab[0], clonedUIFormTab[0]);
            Assert.AreNotSame(uiFormTab[0], clonedUIFormTab[0]);
        }
示例#18
0
 public void TestSync()
 {
     UIForm uiForm = new UIForm();
     Assert.AreEqual(typeof(object), uiForm.SyncRoot.GetType());
     Assert.IsFalse(uiForm.IsSynchronized);
 }
示例#19
0
        public void TestCopyTo()
        {
            UIFormTab tab1 = new UIFormTab();
            UIFormTab tab2 = new UIFormTab();
            UIForm uiForm = new UIForm();
            uiForm.Add(tab1);
            uiForm.Add(tab2);

            UIFormTab[] target = new UIFormTab[2];
            uiForm.CopyTo(target, 0);
            Assert.AreEqual(tab1, target[0]);
            Assert.AreEqual(tab2, target[1]);
        }
示例#20
0
        public void TestUIForm()
        {
            //---------------Set up test pack-------------------
            UIFormTab uiFormTab = new UIFormTab("tab1");
            UIForm form = new UIForm();
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            uiFormTab.UIForm = form;
            //---------------Test Result -----------------------
            Assert.AreSame(form, uiFormTab.UIForm);
        }
        private static ClassDef GetClassDef()
        {
            PropDef propDefPK = new PropDef(ENUM_PKPROP_NAME, typeof(Guid), PropReadWriteRule.WriteNew, null);
            PropDef propDef = new PropDef(ENUM_PROP_NAME, typeof(TestEnum), PropReadWriteRule.ReadWrite, TestEnum.Option1);
            PropDef propDef2 = new PropDef(ENUM_PROP_NAME_EMPTY, typeof(TestEnumEmpty), PropReadWriteRule.ReadWrite, null);
            PropDef propDef3 = new PropDef(ENUM_PROP_NAME_PASCAL, typeof(TestEnumPascalCase), PropReadWriteRule.ReadWrite, null);
            PrimaryKeyDef primaryKeyDef = new PrimaryKeyDef { propDefPK };
            PropDefCol propDefCol = new PropDefCol { propDefPK, propDef, propDef2, propDef3 };

            UIFormField uiFormField = new UIFormField(TestUtil.GetRandomString(), propDef.PropertyName,
                                                      typeof(IComboBox), "EnumComboBoxMapper", "Habanero.Faces.Base", true, null, null, LayoutStyle.Label);
            UIFormColumn uiFormColumn = new UIFormColumn { uiFormField };
            UIFormTab uiFormTab = new UIFormTab { uiFormColumn };
            UIForm uiForm = new UIForm { uiFormTab };
            UIDef uiDef = new UIDef("default", uiForm, null);
            UIDefCol uiDefCol = new UIDefCol { uiDef };

            ClassDef classDef = new ClassDef(typeof(EnumBO), primaryKeyDef, propDefCol, new KeyDefCol(), null, uiDefCol);
            return classDef;
        }
示例#22
0
 public void Test_SetClassDef_ShouldSetClassDefOnRelatedFormDef()
 {
     //---------------Set up test pack-------------------
     var uiForm = new UIForm();
     var uiDef = new UIDef("test", null, null) {UIForm = uiForm};
     var classDef = MockRepository.GenerateStub<IClassDef>();
     //---------------Assert Precondition----------------
     Assert.IsNull(uiForm.ClassDef);
     //---------------Execute Test ----------------------
     uiDef.ClassDef = classDef;
     //---------------Test Result -----------------------
     Assert.AreSame(classDef, uiForm.ClassDef);
 }
 public void Test_BuildPanelForForm_WhenNoTabs_ShouldReturnPanelSizedCorrectly()
 {
     //---------------Set up test pack-------------------
     IClassDef classDef = Sample.CreateClassDefWithTwoPropsOneInteger();
     IUIForm form = new UIForm();
     PanelBuilder panelBuilder = CreatePanelBuilder();
     //---------------Assert Precondition----------------
     Assert.AreEqual(0, form.Count);
     //---------------Execute Test ----------------------
     IPanelInfo panelInfo = panelBuilder.BuildPanelForForm(form);
     //---------------Test Result -----------------------
     IPanel panel = panelInfo.Panel;
     Assert.AreEqual(form.Height, panel.Height, "Height should be correct");
     Assert.AreEqual(form.Width, panel.Width, "Width should be correct");
 }
示例#24
0
        /// <summary>
        /// Prepares the given document to conform to the overall layout. This requires to draw an
        /// intermediate set of controls (panels) and add menu + toolbar.
        /// </summary>
        /// <param name="document">The document to adjust, which comes with the actual content.</param>
        /// <param name="backend">The backend UI form used to get toolbar and menu.</param>
        /// <param name="withPadding">Indicates if we need padding around the content or not.</param>
        private void SetupDockLayout(ITabDocument document, UIForm backend, bool withPadding)
        {
            // Setting up the layout requires some additional nesting of controls.
              // A tab document should have only one container as top level control, which we re-host.
              Control root = document.Content;
              Control content = (root.Controls.Count > 0) ? root.Controls[0] : null;

              // If there's already a drawable panel then this document has already been set up
              // and just needs to be shown. Happens for re-used views (like the Output view).
              if (content is DrawablePanel)
            return;

              root.Controls.Clear();

              // Content area.
              DrawablePanel contentPanel = new DrawablePanel();
              contentPanel.BackColor = MySQL.Conversions.GetApplicationColor(ApplicationColor.AppColorMainBackground, false);
              contentPanel.CustomBackground = false;
              contentPanel.Dock = DockStyle.Fill;
              contentPanel.Padding = withPadding ? new Padding(6) : new Padding(0);
              root.Controls.Add(contentPanel);
              if (content != null)
              {
            contentPanel.Controls.Add(content);
            content.Dock = DockStyle.Fill;
              }

              // Menu + toolbar area. We have two types of tab documents:
              // - appview based (and hence backend-managed)
              // - native Form (with interface via WBContext).
              // Appview based documents have own methods to return their menu and toolbar because
              // retrieval via managed code requires a managed UIForm. However appview classes are
              // already managed via mforms and adding another reference management via UIForm
              // will lead to unpredictable results.
              ToolStrip toolbar;
              MenuStrip menu;
              if (backend != null)
              {
            // Retrieval via WBContext will return a default toolbar if no other is defined.
            toolbar = wbContext.toolbar_for_form(backend);
            menu = wbContext.menu_for_form(backend);
              }
              else
              {
            AppViewDockContent dockContent = document as AppViewDockContent;
            toolbar = dockContent.GetToolBar();
            if (toolbar == null)
              toolbar = wbContext.toolbar_for_form(null); // Currently never returns a toolbar.
            menu = wbContext.menu_for_appview(dockContent);
              }
              DrawablePanel menuPanel = new DrawablePanel();
              if (toolbar != null || menu != null)
              {
            menuPanel.BackColor = Color.Transparent;
            menuPanel.CustomBackground = true;
            menuPanel.Dock = DockStyle.Top;
            menuPanel.AutoSize = true;
            root.Controls.Add(menuPanel);
            if (toolbar != null)
            {
              toolbar.BackColor = Conversions.GetApplicationColor(ApplicationColor.AppColorMainTab, false);

              menuPanel.Controls.Add(toolbar);
              toolbar.Dock = DockStyle.Top;
            }

            if (menu != null)
            {
              menu.BackColor = Conversions.GetApplicationColor(ApplicationColor.AppColorMainTab, false);

              menuPanel.Controls.Add(menu);
              menu.Dock = DockStyle.Top;
              menu.AutoSize = true;
            }
              }
        }
示例#25
0
        public void TestEquals_SameTab()
        {
            UIFormTab uiFormTab1 = CreateUIFormTab();

            UIForm uiForm1 = new UIForm();
            uiForm1.Add(uiFormTab1);

            UIForm uiForm2 = new UIForm();
            uiForm2.Add(uiFormTab1);

            Assert.IsTrue(uiForm1 == uiForm2);
            Assert.IsFalse(uiForm1 != uiForm2);
            Assert.IsTrue(uiForm1.Equals(uiForm2));
        }
示例#26
0
 public void CreateMainFormView(String ViewName, UIForm viewBE)
 {
     try
       {
     DockablePlugin form = null;
     switch (ViewName)
     {
       case "dbquery":
     form = new SqlIdeForm(wbContext, viewBE);
     break;
     }
     if (form != null)
     {
       form.Context = wbContext;
       DockDocument(form, true, true);
     }
       }
       catch (Exception e)
       {
     Program.HandleException(e);
       }
 }
示例#27
0
 public void SetUIForm(UIForm uiForm)
 {
     UIForm = uiForm;
 }
示例#28
0
        public void Test_Equal_DiffTabs_SameTabName()
        {
            //---------------Set up test pack-------------------
            UIFormTab uiFormTab1 = CreateUIFormTab();
            uiFormTab1.Name = "tab1";
            UIForm uiForm1 = new UIForm();
            uiForm1.Add(uiFormTab1);
            UIFormTab uiFormTab2 = CreateUIFormTab();
            uiFormTab2.Name = "tab1";
            UIForm uiForm2 = new UIForm();
            uiForm2.Add(uiFormTab2);

            //--------------Assert PreConditions----------------            

            //---------------Execute Test ----------------------
            bool operatorEquals = uiForm1 == uiForm2;
            bool operatorNotEquals = uiForm1 != uiForm2;
            bool methodEquals = uiForm1.Equals(uiForm2);

            //---------------Test Result -----------------------
            Assert.IsTrue(operatorEquals);
            Assert.IsFalse(operatorNotEquals);
            Assert.IsTrue(methodEquals);
            //---------------Tear Down -------------------------          
        }
 public void Test_BuildPanelForForm_WhenNoTabs_ShouldReturnPanelWithCorrectMinimumSize()
 {
     //---------------Set up test pack-------------------
     IClassDef classDef = Sample.CreateClassDefWithTwoPropsOneInteger();
     IUIForm form = new UIForm();
     PanelBuilder panelBuilder = CreatePanelBuilder();
     //---------------Assert Precondition----------------
     Assert.AreEqual(0, form.Count);
     //---------------Execute Test ----------------------
     IPanelInfo panelInfo = panelBuilder.BuildPanelForForm(form);
     //---------------Test Result -----------------------
     IPanel panel = panelInfo.Panel;
     Assert.AreEqual(new Size(0, 0), panel.MinimumSize, "Minimum size should be correct");
 }
 public void Test_Constructor_WhenUIDefIsInherited_ShouldUseInheritedUIDef()
 {
     //---------------Set up test pack-------------------
     IClassDef classDef = Entity.LoadDefaultClassDef();
     IClassDef subClassDef = LegalEntity.LoadClassDef_WithSingleTableInheritance();
     IClassDef subSubClassDef = Vehicle.LoadClassDef_WithClassTableInheritance();
     UIForm uiForm = new UIForm(new UIFormTab(new UIFormColumn(new UIFormField("My Form Field", "EntityType"))));
     string uiDefName = "EntityUiDef";
     classDef.UIDefCol.Add(new UIDef(uiDefName, uiForm, null));
     IBusinessObject businessObject = subSubClassDef.CreateNewBusinessObject();
     //---------------Assert Precondition----------------
     //---------------Execute Test ----------------------
     IDefaultBOEditorForm defaultBOEditorForm = GetControlFactory().CreateBOEditorForm((BusinessObject)businessObject, uiDefName);
     //---------------Test Result -----------------------
     IPanelInfo panelInfo = defaultBOEditorForm.PanelInfo;
     Assert.IsNotNull(panelInfo);
     Assert.AreSame(uiForm, panelInfo.UIForm);
 }