[NUI] add exception code for NUIWidgetApplication (#1802)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / NUIWidgetApplication.cs
old mode 100755 (executable)
new mode 100644 (file)
index c0de24c..a34bb89
  * limitations under the License.
  *
  */
-
-using System;
 using Tizen.Applications;
 using Tizen.Applications.CoreBackend;
-using Tizen.NUI;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System;
 
 namespace Tizen.NUI
 {
-
     /// <summary>
     /// Represents an application that have UI screen. The NUIWidgetApplication class has a default stage.
     /// </summary>
+    /// <since_tizen> 4 </since_tizen>
     public class NUIWidgetApplication : CoreApplication
     {
-
         /// <summary>
         /// The default constructor.
         /// </summary>
-        public NUIWidgetApplication() : base(new NUIWidgetCoreBackend())
+        /// <remarks>Widget ID will be replaced as the application ID.</remarks>
+        /// <param name="widgetType">Derived widget class type.</param>
+        public NUIWidgetApplication( System.Type widgetType ) : base(new NUIWidgetCoreBackend())
+        {
+            NUIWidgetCoreBackend core = Backend as NUIWidgetCoreBackend;
+            core?.RegisterWidgetInfo(new Dictionary<System.Type, string> { { widgetType, ApplicationInfo.ApplicationId } });
+        }
+
+        /// <summary>
+        /// The constructor for multi widget class and instance.
+        /// </summary>
+        /// <param name="widgetTypes">List of derived widget class type.</param>
+        public NUIWidgetApplication(Dictionary<System.Type, string> widgetTypes) : base(new NUIWidgetCoreBackend())
+        {
+            if( widgetTypes == null )
+            {
+              throw new InvalidOperationException("Dictionary is null");
+            }
+            else
+            {
+                NUIWidgetCoreBackend core = Backend as NUIWidgetCoreBackend;
+                core?.RegisterWidgetInfo(widgetTypes);
+            }
+        }
+
+        /// <summary>
+        /// The default constructor with stylesheet.
+        /// </summary>
+        /// <remarks>Widget ID will be replaced as the application ID.</remarks>
+        /// <param name="widgetType">Derived widget class type.</param>
+        /// <param name="styleSheet">The styleSheet url.</param>
+        /// <since_tizen> 4 </since_tizen>
+        public NUIWidgetApplication(System.Type widgetType, string styleSheet) : base(new NUIWidgetCoreBackend(styleSheet))
+        {
+            NUIWidgetCoreBackend core = Backend as NUIWidgetCoreBackend;
+            core?.RegisterWidgetInfo(new Dictionary<System.Type, string> { { widgetType, ApplicationInfo.ApplicationId } });
+        }
+
+        /// <summary>
+        /// Add WidgetInfo in runtime
+        /// </summary>
+        /// <param name="widgetType">Derived widget class type.</param>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public void AddWidgetType( System.Type widgetType )
+        {
+            NUIWidgetCoreBackend core = Backend as NUIWidgetCoreBackend;
+            core?.AddWidgetInfo(new Dictionary<System.Type, string> { { widgetType, ApplicationInfo.ApplicationId } });
+        }
+
+        /// <summary>
+        /// Add WidgetInfo in runtime
+        /// </summary>
+        /// <param name="widgetTypes">Derived widget class type.</param>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public void AddWidgetType( Dictionary<System.Type, string> widgetTypes )
+        {
+            NUIWidgetCoreBackend core = Backend as NUIWidgetCoreBackend;
+            core?.AddWidgetInfo(widgetTypes);
+        }
+
+        internal WidgetApplication ApplicationHandle
+        {
+            get
+            {
+                return ((NUIWidgetCoreBackend)this.Backend).WidgetApplicationHandle;
+            }
+        }
+
+        /// <summary>
+        /// Run NUIWidgetApplication.
+        /// </summary>
+        /// <param name="args">Arguments from commandline.</param>
+        /// <since_tizen> 4 </since_tizen>
+        public override void Run(string[] args)
         {
-            Tizen.Log.Fatal("NUI", "### NUIWidgetApplication called");
+            Backend.AddEventHandler(EventType.PreCreated, OnPreCreate);
+            base.Run(args);
         }
 
         /// <summary>
-        /// The constructor with stylesheet.
+        /// Exit NUIWidgetApplication.
         /// </summary>
-        public NUIWidgetApplication(string stylesheet) : base(new NUIWidgetCoreBackend(stylesheet))
+        /// <since_tizen> 4 </since_tizen>
+        public override void Exit()
         {
-            Tizen.Log.Fatal("NUI", "### NUIWidgetApplication(string) called");
+            Tizen.Log.Fatal("NUI", "### NUIWidgetApplication Exit called");
+            base.Exit();
         }
 
         /// <summary>
-        /// Overrides this method if want to handle behavior.
+        /// Overrides this method if want to handle OnLocaleChanged behavior.
         /// </summary>
+        /// <since_tizen> 4 </since_tizen>
         protected override void OnLocaleChanged(LocaleChangedEventArgs e)
         {
             Log.Fatal("NUI", "OnLocaleChanged() is called!");
@@ -55,8 +131,9 @@ namespace Tizen.NUI
         }
 
         /// <summary>
-        /// Overrides this method if want to handle behavior.
+        /// Overrides this method if want to handle OnLowBattery behavior.
         /// </summary>
+        /// <since_tizen> 4 </since_tizen>
         protected override void OnLowBattery(LowBatteryEventArgs e)
         {
             Log.Fatal("NUI", "OnLowBattery() is called!");
@@ -64,8 +141,9 @@ namespace Tizen.NUI
         }
 
         /// <summary>
-        /// Overrides this method if want to handle behavior.
+        /// Overrides this method if want to handle OnLowMemory behavior.
         /// </summary>
+        /// <since_tizen> 4 </since_tizen>
         protected override void OnLowMemory(LowMemoryEventArgs e)
         {
             Log.Fatal("NUI", "OnLowMemory() is called!");
@@ -73,8 +151,9 @@ namespace Tizen.NUI
         }
 
         /// <summary>
-        /// Overrides this method if want to handle behavior.
+        /// Overrides this method if want to handle OnRegionFormatChanged behavior.
         /// </summary>
+        /// <since_tizen> 4 </since_tizen>
         protected override void OnRegionFormatChanged(RegionFormatChangedEventArgs e)
         {
             Log.Fatal("NUI", "OnRegionFormatChanged() is called!");
@@ -82,8 +161,9 @@ namespace Tizen.NUI
         }
 
         /// <summary>
-        /// Overrides this method if want to handle behavior.
+        /// Overrides this method if want to handle OnTerminate behavior.
         /// </summary>
+        /// <since_tizen> 4 </since_tizen>
         protected override void OnTerminate()
         {
             Log.Fatal("NUI", "OnTerminate() is called!");
@@ -91,16 +171,18 @@ namespace Tizen.NUI
         }
 
         /// <summary>
-        /// Overrides this method if want to handle behavior.
+        /// Overrides this method if want to handle OnPreCreate behavior.
         /// </summary>
+        /// <since_tizen> 4 </since_tizen>
         protected virtual void OnPreCreate()
         {
             Log.Fatal("NUI", "OnPreCreate() is called!");
         }
 
         /// <summary>
-        /// Overrides this method if want to handle behavior.
+        /// Overrides this method if want to handle OnCreate behavior.
         /// </summary>
+        /// <since_tizen> 4 </since_tizen>
         protected override void OnCreate()
         {
             // This is also required to create DisposeQueue on main thread.
@@ -109,44 +191,5 @@ namespace Tizen.NUI
             Log.Fatal("NUI","OnCreate() is called!");
             base.OnCreate();
         }
-
-        /// <summary>
-        /// Run NUIWidgetApplication.
-        /// </summary>
-        /// <param name="args">Arguments from commandline.</param>
-        public override void Run(string[] args)
-        {
-            Backend.AddEventHandler(EventType.PreCreated, OnPreCreate);
-            base.Run(args);
-        }
-
-        /// <summary>
-        /// Exit NUIWidgetApplication.
-        /// </summary>
-        public override void Exit()
-        {
-            Tizen.Log.Fatal("NUI", "### NUIWidgetApplication Exit called");
-            base.Exit();
-        }
-
-        internal WidgetApplication ApplicationHandle
-        {
-            get
-            {
-                return ((NUIWidgetCoreBackend)this.Backend).WidgetApplicationHandle;
-            }
-        }
-
-        /// <summary>
-        /// Get the window instance.
-        /// </summary>
-        public Window Window
-        {
-            get
-            {
-                //return Window.Instance;
-                return ApplicationHandle.GetWindow();
-            }
-        }
     }
-}
+}
\ No newline at end of file