Fixed N_SE-38563, N_SE-38552
[apps/osp/Settings.git] / src / StAppSettingForm.cpp
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Flora License, Version 1.1 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //     http://floralicense.org/license/
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 /**
18  * @file                StAppSettingForm.cpp
19  * @brief               This is the implementation file for AppSettingForm class.
20  */
21
22 #include "StAppSettingForm.h"
23 #include "StResourceManager.h"
24 #include "StTypes.h"
25
26 using namespace Tizen::App;
27 using namespace Tizen::Base;
28 using namespace Tizen::Base::Collection;
29 using namespace Tizen::Base::Utility;
30 using namespace Tizen::Graphics;
31 using namespace Tizen::Io;
32 using namespace Tizen::Ui;
33 using namespace Tizen::Ui::Controls;
34 using namespace Tizen::Ui::Scenes;
35
36 static const int APPSETTING_DEFAULT_COUNT = 1;
37 static const int ID_APPSETTTING_ARGUMENT_DEFAULT = 0;
38 static const int ID_APPSETTTING_ARGUMENT_APP_ID = 1;
39 static const int ID_APPSETTTING_ARGUMENT_COUNT = 2;
40
41 static const wchar_t* DEFAULT_VALUE_STRING = L"1";
42 static const wchar_t* ID_POST_FIX_BUTTON_DONE = L"DONE";
43 static const wchar_t* ID_POST_FIX_BUTTON_CANCEL = L"CANCEL";
44
45 static const wchar_t* ID_APPSETTING_ITEM_TYPE_BOOL = L"bool";
46 static const wchar_t* ID_APPSETTING_ITEM_TYPE_INTEGER = L"integer";
47 static const wchar_t* ID_APPSETTING_ITEM_TYPE_STRING = L"string";
48 static const wchar_t* ID_APPSETTING_ITEM_TYPE_LABEL = L"label";
49 static const wchar_t* ID_APPSETTING_ITEM_TYPE_EXPAND_LIST = L"expandlist";
50 static const wchar_t* ID_APPSETTING_ITEM_TYPE_EXPAND_ITEM = L"expanditem";
51 static const wchar_t* ID_APPSETTING_ITEM_TYPE_SEPARATOR = L"separator";
52
53 static const wchar_t* ID_APPSETTING_ATTRIBUTE_TYPE_TITLE = L"title";
54 static const wchar_t* ID_APPSETTING_ATTRIBUTE_TYPE_MIN = L"min";
55 static const wchar_t* ID_APPSETTING_ATTRIBUTE_TYPE_MAX = L"max";
56 static const wchar_t* ID_APPSETTING_ATTRIBUTE_TYPE_VALUE = L"value";
57 static const wchar_t* ID_APPSETTING_ATTRIBUTE_TYPE_MIN_LENGTH = L"minlength";
58 static const wchar_t* ID_APPSETTING_ATTRIBUTE_TYPE_MAX_LENGTH = L"maxlength";
59
60 static const int ITEM_WIDTH_GAP = 100;
61 static const int H_RESIZE_LANDSCAPE_CLIPBOARD = 292;
62 static const int H_RESIZE_PORTRAIT_CLIPBOARD = 614;
63
64 static const int APP_SETTING_DEFAULT_COUNT = 1;
65 static const int IDA_HEADER_BACK_BUTTON = 500;
66
67 AppSettingForm::AppSettingForm(void)
68         : __filePath(L"")
69         , __appId(L"")
70         , __isNoTitleGroup(true)
71         , __pIOAppSetting(null)
72         , __pGroupItemNodeList(null)
73         , __pTranslateTableIndexToHashCode(null)
74         , __pTranslateTableHashCodeToItemTag(null)
75         , __pItemHashcodeHashMap(null)
76 {
77 }
78
79 AppSettingForm::~AppSettingForm(void)
80 {
81 }
82
83 void
84 AppSettingForm::CreateFooter(void)
85 {
86         Footer* pFooter = GetFooter();
87         AppAssert(pFooter);
88
89         pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
90         pFooter->SetBackButton();
91         pFooter->AddActionEventListener(*this);
92         SetFormBackEventListener(this);
93 }
94
95 void
96 AppSettingForm::SetHeaderTitle(void)
97 {
98         if (__pGroupItemNodeList == null)
99         {
100                 AppLogDebug("__pGroupItemNodeList is null");
101                 CreateHeader(L"AppSettingDefault");
102                 return;
103         }
104
105         Node* pNode = null;
106         result r = __pGroupItemNodeList->GetAt(0, pNode);
107         if ((pNode == null)
108                 || (IsFailed(r)))
109         {
110                 if (pNode == null)
111                 {
112                         AppLogDebug("pNode is null");
113                 }
114                 else
115                 {
116                         AppLogDebug("GetAt fail [%s]", GetErrorMessage(r));
117                 }
118                 CreateHeader(L"AppSettingDefault");
119                 return;
120         }
121
122         Node* pParent = pNode->GetParent();
123         if ((pParent == null)
124                 || (!pParent->GetType().Equals(L"setting", false)))
125         {
126                 if (pParent == null)
127                 {
128                         AppLogDebug("pParent is null");
129                 }
130                 else
131                 {
132                         AppLogDebug("pParent is not setting element [%ls]", pParent->GetType().GetPointer());
133                 }
134                 CreateHeader(L"AppSettingDefault");
135                 return;
136         }
137
138         String* pTitle = pParent->GetAttributeN(L"title");
139         if (pTitle == null)
140         {
141                 AppLogDebug("pTitle is null");
142                 CreateHeader(L"AppSettingDefault");
143                 return;
144         }
145
146         CreateHeader(*pTitle);
147         delete pTitle;
148 }
149
150 result
151 AppSettingForm::OnInitializing(void)
152 {
153         return E_SUCCESS;
154 }
155
156 result
157 AppSettingForm::AppSettingManagerInit(Tizen::Base::String rootId, Tizen::Base::String filePath)
158 {
159         __pAppSettingManager = AppSettingManager::GetInstance();
160         if (__pAppSettingManager == null)
161         {
162                 AppLogDebug("AppSettingManager::GetInstance fail");
163                 return E_FAILURE;
164         }
165
166         ElementNode* pRoot = __pAppSettingManager->AddAppSettingRootNode(rootId);
167         result r = __pAppSettingManager->XmlAppSettingFileRead(filePath, pRoot);
168         if (IsFailed(r))
169         {
170                 __pAppSettingManager->RemoveAppSettingRootNode(rootId);
171                 AppLogDebug("XmlAppSettingFileRead fail [%s]", GetErrorMessage(r));
172                 return r;
173         }
174
175         return E_SUCCESS;
176 }
177
178 result
179 AppSettingForm::SetGroupItemNodeList(Tizen::Base::String rootId)
180 {
181         InitGroupItemNodeList();
182
183         if (__pAppSettingManager == null)
184         {
185                 AppLogDebug("__pAppSettingManager is null");
186                 return E_FAILURE;
187         }
188
189         ElementNode* pRoot = __pAppSettingManager->GetAppSettingRootNode(rootId);
190
191         if (pRoot == null)
192         {
193                 AppLogDebug("AppId is not found");
194                 return E_FAILURE;
195         }
196
197         bool isFindSttingElement = false;
198         Node* pNode = null;
199         Enumerator* pEnum = pRoot->CreateEnumerator();
200         while (pEnum->MoveNext() == E_SUCCESS)
201         {
202                 pNode = static_cast<Node*>(pEnum->GetCurrentObject());
203                 if (pNode->GetType().Equals(L"setting", false))
204                 {
205                         isFindSttingElement = true;
206                         break;
207                 }
208         }
209         delete pEnum;
210
211         if ((isFindSttingElement == false)
212                 || (pNode == null)
213                 || (pNode->GetNodeType() == Node::NODE_TYPE_LEAF))
214         {
215                 if (isFindSttingElement == false)
216                 {
217                         AppLogDebug("Setting Element is not found");
218                 }
219                 else
220                 {
221                         AppLogDebug("Child is not found");
222                 }
223                 return E_FAILURE;
224         }
225
226         ElementNode* pElementNode = dynamic_cast<ElementNode*>(pNode);
227         if (pElementNode == null)
228         {
229                 AppLogDebug("dynamic_cast<ElementNode*>(pNode) is null");
230                 return E_FAILURE;
231         }
232         unsigned int childCount = pElementNode->GetChildCount();
233         if (childCount == 0)
234         {
235                 AppLogDebug("Child is zero");
236                 return E_FAILURE;
237         }
238
239         result r = E_FAILURE;
240         for (unsigned int i = 0; i < childCount; i++)
241         {
242                 if (pElementNode->GetChild(i)->GetType().Equals(L"navigationbar", false))
243                 {
244                         continue;
245                 }
246
247                 r = __pGroupItemNodeList->Add(pElementNode->GetChild(i));
248                 if (IsFailed(r))
249                 {
250                         AppLogDebug("Add fail");
251                         RemoveAllGroupItemNodeList();
252                         break;
253                 }
254
255                 r = AddItemHashCodeMap(pElementNode->GetChild(i)->GetId().GetHashCode(), pElementNode->GetChild(i));
256                 if (IsFailed(r))
257                 {
258                         AppLogDebug("AddItemHashCodeMap fail");
259                         RemoveAllGroupItemNodeList();
260                         break;
261                 }
262         }
263
264         return r;
265 }
266
267 void
268 AppSettingForm::RemoveAllGroupItemNodeList(void)
269 {
270         if (__pGroupItemNodeList != null)
271         {
272                 __pGroupItemNodeList->RemoveAll();
273                 delete __pGroupItemNodeList;
274                 __pGroupItemNodeList = null;
275         }
276 }
277
278 result
279 AppSettingForm::InitGroupItemNodeList(void)
280 {
281         RemoveAllGroupItemNodeList();
282
283         __pGroupItemNodeList = new (std::nothrow) LinkedListT<Node*>;
284         if (__pGroupItemNodeList == null)
285         {
286                 AppLogDebug("__pGroupItemNodeList create fail");
287                 return E_FAILURE;
288         }
289
290         return E_SUCCESS;
291 }
292
293 result
294 AppSettingForm::InitItemHashCodeMap(void)
295 {
296         RemoveAllItemHashCodeMap();
297
298         __pItemHashcodeHashMap = new (std::nothrow) HashMapT<unsigned int, Node*>;
299         if (__pItemHashcodeHashMap == null)
300         {
301                 AppLogDebug("__pItemHashcodeHashMap create fail");
302                 return E_FAILURE;
303         }
304
305         result r = __pItemHashcodeHashMap->Construct();
306         if (IsFailed(r))
307         {
308                 AppLogDebug("Construct fail [%s]", GetErrorMessage(r));
309                 RemoveAllItemHashCodeMap();
310         }
311
312         return r;
313 }
314
315 result
316 AppSettingForm::AddItemHashCodeMap(unsigned int hashCode, Node* pNode)
317 {
318         if (__pItemHashcodeHashMap == null)
319         {
320                 AppLogDebug("__pItemHashcodeHashMap is null");
321                 return E_FAILURE;
322         }
323
324         result r = __pItemHashcodeHashMap->Add(hashCode, pNode);
325
326         return r;
327 }
328
329 result
330 AppSettingForm::MakeTranslateTable(void)
331 {
332         if ((__pGroupItemNodeList == null)
333                 || (__pItemHashcodeHashMap == null))
334         {
335                 AppLogDebug("__pGroupItemNodeList or __pItemHashcodeHashMap is null");
336                 return E_FAILURE;
337         }
338
339         unsigned int groupItemListCount = __pGroupItemNodeList->GetCount();
340         if (groupItemListCount == 0)
341         {
342                 AppLogDebug("groupItemListCount is zero");
343                 return E_FAILURE;
344         }
345
346         result r = E_FAILURE;
347         Node* pNode = null;
348         Enumerator* pEnum = null;
349
350         for (unsigned int i = 0; i < groupItemListCount; i++)
351         {
352                 r = __pGroupItemNodeList->GetAt(i, pNode);
353                 if ((pNode == null)
354                         || (IsFailed(r)))
355                 {
356                         if (pNode == null)
357                         {
358                                 AppLogDebug("pNode is null");
359                                 r = E_FAILURE;
360                         }
361                         else
362                         {
363                                 AppLogDebug("GetAt fail [%s]", GetErrorMessage(r));
364                         }
365
366                         RemoveAllTranslateTableIndexToHashCode();
367                         RemoveAllItemHashCodeMap();
368
369                         return r;
370                 }
371
372                 ArrayListT<unsigned int>* pGroupItemHashCode = new (std::nothrow) ArrayListT<unsigned int>;
373                 if (pGroupItemHashCode == null)
374                 {
375                         AppLogDebug("pNode is null");
376
377                         RemoveAllTranslateTableIndexToHashCode();
378                         RemoveAllItemHashCodeMap();
379
380                         return E_FAILURE;
381                 }
382
383                 r = pGroupItemHashCode->Construct();
384                 if (IsFailed(r))
385                 {
386                         AppLogDebug("Construct fail [%s]", GetErrorMessage(r));
387                         RemoveAllTranslateTableIndexToHashCode();
388                         RemoveAllItemHashCodeMap();
389
390                         pGroupItemHashCode->RemoveAll();
391                         delete pGroupItemHashCode;
392
393                         return E_FAILURE;
394                 }
395
396                 int enumLoopCount = 0;
397                 pEnum = pNode->CreateEnumerator();
398                 while (pEnum->MoveNext() == E_SUCCESS)
399                 {
400                         Node* pCurrent = static_cast<Node*>(pEnum->GetCurrentObject());
401                         if (pCurrent == null)
402                         {
403                                 AppLogDebug("pNode is null");
404                                 RemoveAllTranslateTableIndexToHashCode();
405                                 RemoveAllItemHashCodeMap();
406                                 delete pEnum;
407
408                                 pGroupItemHashCode->RemoveAll();
409                                 delete pGroupItemHashCode;
410
411                                 return E_FAILURE;
412                         }
413
414                         unsigned int idHashCode = pCurrent->GetId().GetHashCode();
415
416                         r = AddItemHashCodeMap(idHashCode, pCurrent);
417                         if (IsFailed(r))
418                         {
419                                 AppLogDebug("Add fail [%s]", GetErrorMessage(r));
420                                 RemoveAllTranslateTableIndexToHashCode();
421                                 RemoveAllItemHashCodeMap();
422                                 delete pEnum;
423
424                                 pGroupItemHashCode->RemoveAll();
425                                 delete pGroupItemHashCode;
426
427                                 return r;
428                         }
429
430                         r = pGroupItemHashCode->Add(idHashCode);
431                         if (IsFailed(r))
432                         {
433                                 AppLogDebug("Add fail [%s]", GetErrorMessage(r));
434                                 RemoveAllTranslateTableIndexToHashCode();
435                                 RemoveAllItemHashCodeMap();
436                                 delete pEnum;
437
438                                 pGroupItemHashCode->RemoveAll();
439                                 delete pGroupItemHashCode;
440
441                                 return r;
442                         }
443                         SetTranslateTableHashCodeToItemTag(idHashCode, new (std::nothrow) ItemTag(i, enumLoopCount));
444                         enumLoopCount = enumLoopCount + APPSETTING_DEFAULT_COUNT;
445                 }
446                 if (enumLoopCount == 0)
447                 {
448                         if (pNode)
449                         {
450                                 unsigned int idHashCode = pNode->GetId().GetHashCode();
451
452                                 r = pGroupItemHashCode->Add(idHashCode);
453                                 if (IsFailed(r))
454                                 {
455                                         AppLogDebug("Add fail [%s]", GetErrorMessage(r));
456                                         RemoveAllTranslateTableIndexToHashCode();
457                                         RemoveAllItemHashCodeMap();
458                                         delete pEnum;
459
460                                         pGroupItemHashCode->RemoveAll();
461                                         delete pGroupItemHashCode;
462
463                                         return r;
464                                 }
465                                 SetTranslateTableHashCodeToItemTag(idHashCode, new (std::nothrow) ItemTag(i, enumLoopCount));
466                         }
467                 }
468                 delete pEnum;
469
470                 r = SetTranslateTableIndexToHashCode(pGroupItemHashCode);
471                 if (IsFailed(r))
472                 {
473                         AppLogDebug("SetTranslateTableIndexToHashCode fail [%s]", GetErrorMessage(r));
474                         RemoveAllTranslateTableIndexToHashCode();
475                         RemoveAllItemHashCodeMap();
476
477                         pGroupItemHashCode->RemoveAll();
478                         delete pGroupItemHashCode;
479
480                         return r;
481                 }
482         }
483
484         return r;
485 }
486
487 Node*
488 AppSettingForm::GetItemHashCodeMap(unsigned int hashCode)
489 {
490         if (__pItemHashcodeHashMap == null)
491         {
492                 AppLogDebug("__pItemHashcodeHashMap is null");
493                 return null;
494         }
495
496         bool isFindKey = false;
497         result r = __pItemHashcodeHashMap->ContainsKey(hashCode, isFindKey);
498         if ((isFindKey == false)
499                 || (IsFailed(r)))
500         {
501                 if (isFindKey == false)
502                 {
503                         AppLogDebug("Key is not found");
504                 }
505                 else
506                 {
507                         AppLogDebug("ContainsKey fail [%s]", GetErrorMessage(r));
508                 }
509
510                 return null;
511         }
512
513         Node* pValueNode = null;
514         r = __pItemHashcodeHashMap->GetValue(hashCode, pValueNode);
515         if ((pValueNode == null)
516                 || (IsFailed(r)))
517         {
518                 if (pValueNode == null)
519                 {
520                         AppLogDebug("pValueNode is null");
521                 }
522                 else
523                 {
524                         AppLogDebug("GetValue fail [%s]", GetErrorMessage(r));
525                 }
526
527                 return null;
528         }
529
530         return pValueNode;
531 }
532
533 void
534 AppSettingForm::RemoveAllItemHashCodeMap(void) // must be modify
535 {
536         if (__pItemHashcodeHashMap != null)
537         {
538                 __pItemHashcodeHashMap->RemoveAll();
539                 delete __pItemHashcodeHashMap;
540                 __pItemHashcodeHashMap = null;
541         }
542 }
543
544 result
545 AppSettingForm::InitTranslateTableIndexToHashCode(void)
546 {
547         if (__pTranslateTableIndexToHashCode != null)
548         {
549                 AppLogDebug("__pTranslateTableIndexToHashCode is not null");
550                 return E_FAILURE;
551         }
552
553         __pTranslateTableIndexToHashCode = new (std::nothrow) ArrayListT<ArrayListT<unsigned int>*>;
554         if (__pTranslateTableIndexToHashCode == null)
555         {
556                 AppLogDebug("__pTranslateTableIndexToHashCode create fail");
557                 return E_FAILURE;
558         }
559
560         result r = __pTranslateTableIndexToHashCode->Construct();
561         if (IsFailed(r))
562         {
563                 AppLogDebug("Construct fail [%s]", GetErrorMessage(r));
564                 RemoveAllTranslateTableIndexToHashCode();
565         }
566
567         return r;
568 }
569
570 result
571 AppSettingForm::InitTranslateTableHashCodeToItemTag(void)
572 {
573         if (__pTranslateTableHashCodeToItemTag != null)
574         {
575                 AppLogDebug("__pTranslateTableIndexToHashCode is not null");
576                 return E_FAILURE;
577         }
578         __pTranslateTableHashCodeToItemTag = new (std::nothrow) HashMapT<unsigned int, ItemTag*>;
579         if (__pTranslateTableHashCodeToItemTag == null)
580         {
581                 AppLogDebug("__pTranslateTableHashCodeToItemTag create fail");
582                 return E_FAILURE;
583         }
584         result r = __pTranslateTableHashCodeToItemTag->Construct();
585         if (IsFailed(r))
586         {
587                 AppLogDebug("Construct fail [%s]", GetErrorMessage(r));
588                 RemoveAllTranslateTableHashCodeToItemTag();
589         }
590         return r;
591 }
592
593 result
594 AppSettingForm::SetTranslateTableHashCodeToItemTag(int hashCode, ItemTag* itemTag)
595 {
596         InitTranslateTableHashCodeToItemTag();
597         if (__pTranslateTableHashCodeToItemTag == null)
598         {
599                 AppLogDebug("__pTranslateTableHashCodeToItemTag is null");
600                 return E_FAILURE;
601         }
602         return __pTranslateTableHashCodeToItemTag->Add(hashCode, itemTag);
603 }
604
605 ItemTag*
606 AppSettingForm::GetTranslateTableHashCodeToItemTag(unsigned int hashCode)
607 {
608         if (__pTranslateTableHashCodeToItemTag == null)
609         {
610                 AppLogDebug("__pTranslateTableHashCodeToItemTag is null");
611                 return null;
612         }
613         bool isFindKey = false;
614         result r = __pTranslateTableHashCodeToItemTag->ContainsKey(hashCode, isFindKey);
615         if ((isFindKey == false)
616                 || (IsFailed(r)))
617         {
618                 if (isFindKey == false)
619                 {
620                         AppLogDebug("Key is not found");
621                 }
622                 else
623                 {
624                         AppLogDebug("ContainsKey fail [%s]", GetErrorMessage(r));
625                 }
626                 return null;
627         }
628         ItemTag* pValueItemTag = null;
629         r = __pTranslateTableHashCodeToItemTag->GetValue(hashCode, pValueItemTag);
630         if ((pValueItemTag == null)
631                 || (IsFailed(r)))
632         {
633                 if (pValueItemTag == null)
634                 {
635                         AppLogDebug("pValueItemTag is null");
636                 }
637                 else
638                 {
639                         AppLogDebug("GetValue fail [%s]", GetErrorMessage(r));
640                 }
641                 return null;
642         }
643         return pValueItemTag;
644 }
645
646 void
647 AppSettingForm::RemoveAllTranslateTableHashCodeToItemTag(void)
648 {
649         if (__pTranslateTableHashCodeToItemTag != null)
650         {
651                 __pTranslateTableHashCodeToItemTag->RemoveAll();
652                 delete __pTranslateTableHashCodeToItemTag;
653                 __pTranslateTableHashCodeToItemTag = null;
654         }
655 }
656
657 result
658 AppSettingForm::SetTranslateTableIndexToHashCode(Tizen::Base::Collection::ArrayListT<unsigned int>* groupItemHashCode)
659 {
660         InitTranslateTableIndexToHashCode();
661
662         if (__pTranslateTableIndexToHashCode == null)
663         {
664                 AppLogDebug("__pTranslateTableIndexToHashCode is null");
665                 return E_FAILURE;
666         }
667
668         result r = __pTranslateTableIndexToHashCode->Add(groupItemHashCode);
669         if (IsFailed(r))
670         {
671                 AppLogDebug("Add fail [%s]", GetErrorMessage(r));
672         }
673
674         return r;
675 }
676
677 unsigned int
678 AppSettingForm::GetTranslateTableIndexToHashCode(unsigned int groupIndex, unsigned int itemIndex)
679 {
680         unsigned int retHashCode = 0;
681
682         if (__pTranslateTableIndexToHashCode == null)
683         {
684                 AppLogDebug("__pTranslateTableIndexToHashCode is null");
685                 return retHashCode;
686         }
687
688         unsigned int groupCount = __pTranslateTableIndexToHashCode->GetCount();
689         if ((groupIndex >= groupCount)
690                 || (groupCount == 0))
691         {
692                 AppLogDebug("groupIndex is not found");
693                 return retHashCode;
694         }
695
696         ArrayListT<unsigned int>* pItemList = null;
697         result r = __pTranslateTableIndexToHashCode->GetAt(groupIndex, pItemList);
698         if ((pItemList == null)
699                 || (IsFailed(r)))
700         {
701                 if (pItemList == null)
702                 {
703                         AppLogDebug("pItemList is null");
704                 }
705                 else
706                 {
707                         AppLogDebug("GetAt fail [%s]", GetErrorMessage(r));
708                 }
709
710                 return retHashCode;
711         }
712
713         unsigned int itemCount = pItemList->GetCount();
714         if ((itemIndex >= itemCount)
715                 || (itemCount == 0))
716         {
717                 AppLogDebug("itemIndex is not found");
718                 return retHashCode;
719         }
720
721         r = pItemList->GetAt(itemIndex, retHashCode);
722         if (IsFailed(r))
723         {
724                 AppLogDebug("GetAt fail [%s]", GetErrorMessage(r));
725                 retHashCode = 0;
726
727                 return retHashCode;
728         }
729
730         return retHashCode;
731 }
732
733 unsigned int
734 AppSettingForm::GetItemCountByTranslateTable(unsigned int groupIndex)
735 {
736         unsigned int itemCount = 0;
737         if (__pTranslateTableIndexToHashCode == null)
738         {
739                 AppLogDebug("__pTranslateTableIndexToHashCode is null");
740                 return itemCount;
741         }
742
743         unsigned int groupCount = __pTranslateTableIndexToHashCode->GetCount();
744         if ((groupIndex >= groupCount)
745                 || (groupCount == 0))
746         {
747                 AppLogDebug("groupIndex is not found");
748                 return itemCount;
749         }
750
751         ArrayListT<unsigned int>* pItemList = null;
752         result r = __pTranslateTableIndexToHashCode->GetAt(groupIndex, pItemList);
753         if ((pItemList == null)
754                 || (IsFailed(r)))
755         {
756                 if (pItemList == null)
757                 {
758                         AppLogDebug("pItemList is null");
759                 }
760                 else
761                 {
762                         AppLogDebug("GetAt fail [%s]", GetErrorMessage(r));
763                 }
764
765                 return itemCount;
766         }
767
768         itemCount = pItemList->GetCount();
769         if (itemCount == 0)
770         {
771                 itemCount = APPSETTING_DEFAULT_COUNT;
772         }
773
774         return itemCount;
775 }
776
777 void
778 AppSettingForm::RemoveAllTranslateTableIndexToHashCode(void)
779 {
780         if (__pTranslateTableIndexToHashCode != null)
781         {
782                 unsigned int groupCount = __pTranslateTableIndexToHashCode->GetCount();
783                 if (groupCount != 0)
784                 {
785                         for (unsigned int i = 0; i < groupCount; i++)
786                         {
787                                 ArrayListT<unsigned int>* itemList = null;
788                                 __pTranslateTableIndexToHashCode->GetAt(i, itemList);
789
790                                 if (itemList != null)
791                                 {
792                                         itemList->RemoveAll();
793                                         delete itemList;
794                                 }
795                         }
796                 }
797
798                 __pTranslateTableIndexToHashCode->RemoveAll();
799                 delete __pTranslateTableIndexToHashCode;
800                 __pTranslateTableIndexToHashCode = null;
801         }
802 }
803
804 result
805 AppSettingForm::IOAppSettingInit(Tizen::Base::String appId)
806 {
807         __pIOAppSetting = new (std::nothrow) IOAppSetting();
808         if (__pIOAppSetting == null)
809         {
810                 AppLogDebug("__pIOAppSetting Create failed");
811                 return E_FAILURE;
812         }
813
814         result r = __pIOAppSetting->Constructor(appId);
815         if (IsFailed(r))
816         {
817                 RemoveIOAppSetting();
818         }
819
820         return r;
821 }
822
823 void
824 AppSettingForm::RemoveIOAppSetting(void)
825 {
826         if (__pIOAppSetting != null)
827         {
828                 delete __pIOAppSetting;
829                 __pIOAppSetting = null;
830         }
831 }
832
833 result
834 AppSettingForm::OnTerminating(void)
835 {
836         if (__pTableView)
837         {
838                 __pTableView->SetItemProvider(null);
839         }
840         else
841         {
842                 int contorlCount = GetControlCount();
843                 for (int i = 0; i < contorlCount; i++)
844                 {
845                         RemoveControl(GetControl(0));
846                 }
847 //              RemoveAllControls();
848         }
849         RemoveAllGroupItemNodeList();
850         RemoveAllItemHashCodeMap();
851         RemoveAllTranslateTableIndexToHashCode();
852         RemoveAllTranslateTableHashCodeToItemTag();
853         RemoveIOAppSetting();
854
855         __pAppSettingManager->RemoveAppSettingRootNode(__appId);
856         __pAppSettingManager = null;
857
858         SceneManager* pSceneManager = SceneManager::GetInstance();
859         AppAssert(pSceneManager);
860
861         pSceneManager->UnregisterScene(__appId);
862
863         SetFormBackEventListener(null);
864         return E_SUCCESS;
865 }
866
867 void
868 AppSettingForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
869 {
870         Node* pRootNode = null;
871         Enumerator* pEnum = null;
872         String* pArgsValue[ID_APPSETTTING_ARGUMENT_COUNT] = {null, };
873         int argsCount = 0;
874
875         if (pArgs == null)
876         {
877                 AppLogDebug("pArgs is null");
878                 return;
879         }
880
881         argsCount = pArgs->GetCount();
882         if (argsCount != ID_APPSETTTING_ARGUMENT_COUNT)
883         {
884                 AppLogDebug("Wrong count of pArgs");
885                 delete pArgs;
886                 return;
887         }
888
889         for (int i = 0; i < argsCount; i++)
890         {
891                 pArgsValue[i] = static_cast<String*>(pArgs->GetAt(i));
892                 if (pArgsValue[i] == null)
893                 {
894                         AppLogDebug("pArgsValue[%d] is null", i);
895                         delete pArgs;
896                         return;
897                 }
898         }
899
900         String appId;
901         StringTokenizer stringTokenizer(*pArgsValue[ID_APPSETTTING_ARGUMENT_DEFAULT], L":");
902         result r = stringTokenizer.GetNextToken(appId);
903         TryCatch(r == E_SUCCESS, , "GetNextToken fail[%s]", GetErrorMessage(r));
904
905         r = stringTokenizer.GetNextToken(appId);
906         if ((IsFailed(r))
907                 || (appId.IsEmpty() == true))
908         {
909                 if (!IsFailed(r))
910                 {
911                         r = E_FAILURE;
912                 }
913                 TryCatch(r == E_SUCCESS, , "GetNextToken fail[%s]", GetErrorMessage(r));
914         }
915
916         r = AppSettingManagerInit(appId, *pArgsValue[ID_APPSETTTING_ARGUMENT_APP_ID]);
917         TryCatch(r == E_SUCCESS, , "AppSettingManagerInit fail [%s]", GetErrorMessage(r));
918
919         InitItemHashCodeMap();
920         r = SetGroupItemNodeList(appId);
921         TryCatch(r == E_SUCCESS, , "SetGroupItemNodeList fail");
922
923         r = MakeTranslateTable();
924         TryCatch(r == E_SUCCESS, , "MakeTranslateTable fail");
925         if (__appId.IsEmpty() == true)
926         {
927                 __appId.Append(appId);
928         }
929
930         IOAppSettingInit(__appId);
931
932         SetHeaderTitle();
933         CreateFooter();
934         CreateTableView();
935
936         __pTableView->UpdateTableView();
937         pRootNode = __pAppSettingManager->GetAppSettingRootNode(__appId);
938         pEnum = pRootNode->CreateEnumerator();
939         while (pEnum->MoveNext() == E_SUCCESS)
940         {
941                 Node* pCurrent = static_cast<Node*>(pEnum->GetCurrentObject());
942                 if (pCurrent->GetType().Equals(ID_APPSETTING_ITEM_TYPE_BOOL, false))
943                 {
944                         unsigned int hashCode = pCurrent->GetId().GetHashCode();
945                         ItemTag* itemTag = GetTranslateTableHashCodeToItemTag(hashCode);
946                         if (itemTag == null)
947                         {
948                                 continue;
949                         }
950                         String* pValue = pCurrent->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_VALUE);
951                         if ((pValue->Equals(L"true", false))
952                                 || (pValue->Equals(L"1", false)))
953                         {
954                                 __pTableView->SetItemChecked(itemTag->GetGroupIndex(), itemTag->GetItemIndex(), true);
955                         }
956                         delete pValue;
957                 }
958                 else if (pCurrent->GetType().Equals(ID_APPSETTING_ITEM_TYPE_EXPAND_LIST, false))
959                 {
960                         int itemSelect = 0;
961                         ElementNode* pExpandListItem = dynamic_cast<ElementNode*>(pCurrent);
962                         if (pExpandListItem == null)
963                         {
964                                 continue;
965                         }
966                         String* pExpandListValue = pExpandListItem->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_VALUE);
967                         for (int i = 0; i < pExpandListItem->GetChildCount(); i++)
968                         {
969                                 ElementLeaf* pElementLeaf = dynamic_cast<ElementLeaf*>(pExpandListItem->GetChild(i));
970                                 if (pElementLeaf == null)
971                                 {
972                                         continue;
973                                 }
974                                 String* pExpandItemValue = pElementLeaf->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_TITLE);
975                                 if (!pExpandListValue->Equals(*pExpandItemValue, false))
976                                 {
977                                         delete pExpandItemValue;
978                                         continue;
979                                 }
980                                 itemSelect++;
981                                 unsigned int hashCode = pElementLeaf->GetId().GetHashCode();
982                                 ItemTag* itemTag = GetTranslateTableHashCodeToItemTag(hashCode);
983                                 if (itemTag == null)
984                                 {
985                                         continue;
986                                 }
987                                 __pTableView->SetItemChecked(itemTag->GetGroupIndex(), itemTag->GetItemIndex(), true);
988                                 delete pExpandItemValue;
989                         }
990                         delete pExpandListValue;
991
992                         if (itemSelect == 0)
993                         {
994                                 ElementLeaf* pElementLeaf = dynamic_cast<ElementLeaf*>(pExpandListItem->GetChild(0));
995                                 unsigned int hashCode = pElementLeaf->GetId().GetHashCode();
996                                 String* value = pElementLeaf->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_TITLE);
997
998                                 AppLogDebug("value[%ls]", value->GetPointer());
999                                 ItemTag* itemTag = GetTranslateTableHashCodeToItemTag(hashCode);
1000                                 if (itemTag == null)
1001                                 {
1002                                         AppLogDebug("itemTag == null");
1003                                 }
1004                                 __pTableView->SetItemChecked(itemTag->GetGroupIndex(), itemTag->GetItemIndex(), true);
1005                                 pExpandListItem->SetAttribute(ID_APPSETTING_ATTRIBUTE_TYPE_VALUE, *value);
1006                                 RefreshExpandListItem(itemTag->GetGroupIndex());
1007                                 delete value;
1008                         }
1009                 }
1010         }
1011         delete pEnum;
1012         return;
1013
1014 CATCH:
1015         if (pArgs != null)
1016         {
1017                 pArgs->RemoveAll();
1018                 delete pArgs;
1019         }
1020
1021         CreateHeader(L"Error");
1022         CreateNoContents();
1023         AppLogDebug("AppSettingForm Initialize fail");
1024 }
1025
1026 void
1027 AppSettingForm::CreateNoContents(void)
1028 {
1029         Rectangle clientRect = GetClientAreaBounds();
1030         clientRect.y = 0;
1031         String labelText = ResourceManager::GetString(L"IDS_RSSR_BODY_INVALID_FORMAT");
1032
1033         if (labelText.IsEmpty())
1034         {
1035                 labelText = L"Invalid Format.. \ncheck XML file again";
1036         }
1037
1038         Label* pInvalidFormatLabel = new (std::nothrow) Label();
1039         pInvalidFormatLabel->Construct(clientRect, labelText);
1040         pInvalidFormatLabel->SetTextHorizontalAlignment(ALIGNMENT_CENTER);
1041         pInvalidFormatLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
1042         pInvalidFormatLabel->SetTextConfig(GetFontSize(), LABEL_TEXT_STYLE_NORMAL);
1043         pInvalidFormatLabel->SetBackgroundColor(COLOR_BG_GROUP_ITEM_LISTITEM);
1044         pInvalidFormatLabel->SetName(L"InvalidFormat");
1045         AddControl(pInvalidFormatLabel);
1046         Invalidate(true);
1047 }
1048
1049 void
1050 AppSettingForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId)
1051 {
1052 }
1053
1054 void
1055 AppSettingForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
1056 {
1057         bool errorStatus = false;
1058         int currentLength = 0;
1059         int stringLengthMax = 0;
1060         int stringLengthMin = 0;
1061
1062         if (__pIOAppSetting != null)
1063         {
1064                 Node* pRootNode = null;
1065                 Enumerator* pEnum = null;
1066                 pRootNode = __pAppSettingManager->GetAppSettingRootNode(__appId);
1067                 pEnum = pRootNode->CreateEnumerator();
1068                 while (pEnum->MoveNext() == E_SUCCESS)
1069                 {
1070                         Node* pCurrent = static_cast<Node*>(pEnum->GetCurrentObject());
1071                         if (pCurrent->GetType().Equals(ID_APPSETTING_ITEM_TYPE_STRING, false))
1072                         {
1073                                 String* itemText = pCurrent->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_VALUE);
1074                                 String* pMinLength = pCurrent->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_MIN_LENGTH);
1075                                 String* pMaxLength = pCurrent->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_MAX_LENGTH);
1076
1077                                 currentLength = itemText->GetLength();
1078                                 Integer::Parse(*pMinLength, stringLengthMin);
1079                                 Integer::Parse(*pMaxLength, stringLengthMax);
1080
1081                                 delete itemText;
1082                                 delete pMinLength;
1083                                 delete pMaxLength;
1084
1085                                 if ((currentLength > stringLengthMax) || (currentLength < stringLengthMin))
1086                                 {
1087                                         if (currentLength > stringLengthMax)
1088                                         {
1089                                                 AppLogDebug("value length(%d) greater than maximum range(%d), show popup", currentLength, stringLengthMax);
1090                                         }
1091                                         else
1092                                         {
1093                                                 AppLogDebug("value length(%d) smaller than minimum range(%d), show popup", currentLength, stringLengthMin);
1094                                         }
1095
1096                                         MessageBox messageBox;
1097                                         int result = E_SUCCESS;
1098
1099                                         messageBox.Construct(ResourceManager::GetString(L"IDS_EMAIL_POP_ALERT"), ResourceManager::GetString(L"IDS_COM_POP_FAILED"), MSGBOX_STYLE_NONE, MESSAGEBOX_DISPLAY_TIME_2_SEC);
1100                                         messageBox.ShowAndWait(result);
1101
1102                                         errorStatus = true;
1103                                         break;
1104                                 }
1105                         }
1106                 }
1107                 delete pEnum;
1108
1109                 if (errorStatus == false)
1110                 {
1111                         __pIOAppSetting->UpdateChangedValue();
1112                 }
1113                 else
1114                 {
1115                         return;
1116                 }
1117         }
1118         SceneManager* pSceneManager = SceneManager::GetInstance();
1119         AppAssert(pSceneManager);
1120
1121         pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
1122 }
1123
1124 int
1125 AppSettingForm::GetGroupCount(void)
1126 {
1127         if (__pGroupItemNodeList != null)
1128         {
1129                 return __pGroupItemNodeList->GetCount();
1130         }
1131
1132         return APPSETTING_DEFAULT_COUNT;
1133 }
1134
1135 int
1136 AppSettingForm::GetItemCount(int groupIndex)
1137 {
1138         return GetItemCountByTranslateTable(groupIndex);
1139 }
1140
1141 TableViewGroupItem*
1142 AppSettingForm::CreateGroupItem(int groupIndex, int itemWidth)
1143 {
1144         AppLogDebug("ENTER");
1145
1146         int itemHeight = H_GROUP_INDEX_DEFAULT;
1147         int yItemOffset = Y_GROUP_INDEX_DEFAULT;
1148         LabelTextStyle style = LABEL_TEXT_STYLE_NORMAL;
1149         Rectangle itemMainRectangle;
1150         String* groupText = null;
1151         Node* pNode = null;
1152         Label* pLabel = null;
1153         TableViewGroupItem* pItem = new (std::nothrow) TableViewGroupItem();
1154
1155         __pGroupItemNodeList->GetAt(groupIndex, pNode);
1156
1157         itemMainRectangle.x = X_GROUP_ITEM_DEFAULT_LABEL;
1158         itemMainRectangle.y = yItemOffset;
1159         itemMainRectangle.width = itemWidth;
1160         itemMainRectangle.height = itemHeight;
1161
1162         itemHeight = H_GROUP_INDEX_DEFAULT;
1163         itemMainRectangle.y = H_GROUP_INDEX_TITLE_TEXT;
1164         itemMainRectangle.height = H_GROUP_INDEX_DEFAULT - H_GROUP_INDEX_TITLE_TEXT;
1165         groupText = pNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_TITLE);
1166         if (groupText == null)
1167         {
1168                 AppLogDebug("grpText null");
1169                 delete pItem;
1170                 return null;
1171         }
1172
1173         if (!pNode->GetType().Equals(L"group", false))
1174         {
1175                 if (__isNoTitleGroup == true)
1176                 {
1177                         itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
1178                         __isNoTitleGroup = false;
1179                 }
1180                 else
1181                 {
1182                         itemHeight = 0;
1183                 }
1184         }
1185         else
1186         {
1187                 __isNoTitleGroup = true;
1188         }
1189
1190         if (pNode->GetType().Equals(ID_APPSETTING_ITEM_TYPE_EXPAND_LIST, false))
1191         {
1192                 ItemTypeOneLine(itemMainRectangle);
1193                 itemHeight = itemMainRectangle.height;
1194         }
1195
1196         if ((pNode->GetType()).Equals(ID_APPSETTING_ITEM_TYPE_EXPAND_LIST, false))
1197         {
1198                 String* value = pNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_VALUE);
1199                 String expendList;
1200
1201                 AppLogDebug("groupText [%ls] value [%ls]", groupText->GetPointer(), value->GetPointer());
1202
1203                 pNode->RegisterObserverlistener(__pIOAppSetting);
1204
1205                 pItem->Construct(Dimension(itemMainRectangle.width, itemMainRectangle.height));
1206                 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
1207
1208                 expendList.Append(groupText->GetPointer());
1209                 expendList.Append(L" : ");
1210                 expendList.Append(value->GetPointer());
1211
1212                 delete value;
1213
1214                 pLabel = new (std::nothrow) Label();
1215                 pLabel->Construct(itemMainRectangle, expendList);
1216                 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
1217                 pLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
1218                 pLabel->SetName(pNode->GetId());
1219
1220                 pItem->AddControl(pLabel);
1221                 pItem->SetBackgroundColor(COLOR_BG_GROUP_INDEX_DEFAULT, TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED);
1222                 pItem->SetEnabled(true);
1223                 delete groupText;
1224                 return pItem;
1225         }
1226         else
1227         {
1228                 pItem->Construct(Dimension(itemWidth, itemHeight));
1229                 pItem->SetBackgroundColor(COLOR_BG_GROUP_INDEX_DEFAULT);
1230
1231                 Label* pLabel = new (std::nothrow) Label();
1232
1233                 pLabel->Construct(itemMainRectangle, (*groupText).GetPointer());
1234                 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
1235                 pLabel->SetTextVerticalAlignment(ALIGNMENT_TOP);
1236
1237                 pItem->AddControl(pLabel);
1238
1239                 pLabel->SetTextConfig(FONT_SIZE_GROUP_TITLE_TEXT, style);
1240                 pLabel->SetTextColor(COLOR_HELP_TEXT_TYPE_01);
1241
1242                 pItem->SetEnabled(false);
1243
1244                 delete groupText;
1245                 return pItem;
1246         }
1247 }
1248
1249 TableViewItem*
1250 AppSettingForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
1251 {
1252         Rectangle itemMainRectangle;
1253         Label* pLabel = null;
1254         String itemType;
1255         String* itemText = null;
1256
1257         TableViewAnnexStyle style = TABLE_VIEW_ANNEX_STYLE_NORMAL;
1258
1259         unsigned int hashCode = GetTranslateTableIndexToHashCode(groupIndex, itemIndex);
1260
1261         Node* pItemNode = GetItemHashCodeMap(hashCode);
1262         if (pItemNode == null)
1263         {
1264                 result r = __pGroupItemNodeList->GetAt(groupIndex, pItemNode);
1265                 if (IsFailed(r))
1266                 {
1267                         AppLogDebug("pItemNode is null");
1268                         return null;
1269                 }
1270
1271                 pItemNode = GetItemHashCodeMap(pItemNode->GetId().GetHashCode());
1272                 if (pItemNode == null)
1273                 {
1274                         AppLogDebug("pItemNode is null");
1275                         return null;
1276                 }
1277         }
1278
1279         TableViewItem* pItem = new (std::nothrow) TableViewItem();
1280
1281         itemText = pItemNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_TITLE);
1282         itemType = pItemNode->GetType();
1283         ItemTypeOneLine(itemMainRectangle);
1284
1285         if ((pItemNode->GetType()).Equals(ID_APPSETTING_ITEM_TYPE_BOOL, false))
1286         {
1287                 bool toggleValue = false;
1288                 String* valueString = pItemNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_VALUE);
1289
1290                 pItemNode->RegisterObserverlistener(__pIOAppSetting);
1291
1292                 style = TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING;
1293
1294                 RelativeLayout relativeLayout;
1295                 relativeLayout.Construct();
1296
1297                 pItem->Construct(relativeLayout, Dimension(itemWidth, itemMainRectangle.height), style);
1298                 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
1299
1300                 pLabel = new (std::nothrow) Label();
1301                 pLabel->Construct(itemMainRectangle, (itemText)->GetPointer());
1302                 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
1303                 pLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
1304
1305                 pItem->AddControl(pLabel);
1306                 relativeLayout.SetMargin(*pLabel, 0, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
1307                 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
1308                 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
1309
1310                 pItem->SetBackgroundColor(COLOR_BG_GROUP_INDEX_DEFAULT, TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED);
1311
1312                 toggleValue = Boolean::Parse((*valueString).GetPointer(), true);
1313
1314                 if ((toggleValue != false) || (*valueString == DEFAULT_VALUE_STRING))
1315                 {
1316                         __pTableView->SetItemChecked(groupIndex, itemIndex, true);
1317                 }
1318                 delete valueString;
1319         }
1320         else if ((pItemNode->GetType()).Equals(ID_APPSETTING_ITEM_TYPE_INTEGER, false))
1321         {
1322                 Slider* pSlider = null;
1323                 int minValue = 0;
1324                 int maxValue = 0;
1325                 int setValue = 0;
1326
1327                 pItemNode->RegisterObserverlistener(__pIOAppSetting);
1328
1329                 itemMainRectangle.width = (itemWidth - ITEM_WIDTH_GAP);
1330                 itemMainRectangle.height = H_GROUP_ITEM_DEFAULT_SLIDER;
1331
1332                 RelativeLayout relativeLayout;
1333                 relativeLayout.Construct();
1334                 pItem->Construct(relativeLayout, Dimension(itemWidth, itemMainRectangle.height), style);
1335                 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
1336
1337                 String* minValueString = pItemNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_MIN);
1338                 String* maxValueString = pItemNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_MAX);
1339                 String* setValueString = pItemNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_VALUE);
1340
1341                 Integer::Parse((*minValueString).GetPointer(), minValue);
1342                 Integer::Parse((*maxValueString).GetPointer(), maxValue);
1343                 Integer::Parse((*setValueString).GetPointer(), setValue);
1344
1345                 pSlider = new (std::nothrow) Slider();
1346                 result r = pSlider->Construct(itemMainRectangle, BACKGROUND_STYLE_NONE, true, minValue, maxValue);
1347                 if (IsFailed(r))
1348                 {
1349                         delete minValueString;
1350                         delete maxValueString;
1351                         delete setValueString;
1352
1353                         return null;
1354                 }
1355                 pSlider->SetTitleText((*itemText).GetPointer());
1356                 pSlider->SetValue(setValue);
1357                 pSlider->AddAdjustmentEventListener(*this);
1358                 pSlider->AddSliderEventListener(*this);
1359                 pSlider->SetName(pItemNode->GetId());
1360
1361                 pItem->AddControl(pSlider);
1362                 relativeLayout.SetMargin(*pSlider, 0, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
1363                 relativeLayout.SetRelation(*pSlider, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
1364                 relativeLayout.SetRelation(*pSlider, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
1365
1366                 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT, TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL);
1367                 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT, TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED);
1368                 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT, TABLE_VIEW_ITEM_DRAWING_STATUS_HIGHLIGHTED);
1369                 delete minValueString;
1370                 delete maxValueString;
1371                 delete setValueString;
1372         }
1373         else if ((pItemNode->GetType()).Equals(ID_APPSETTING_ITEM_TYPE_STRING, false))
1374         {
1375                 itemMainRectangle.x = 0;
1376                 int stringLengthMin = 0;
1377                 int stringLengthMax = 0;
1378
1379                 String* pMinLength = static_cast<String*>(pItemNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_MIN_LENGTH));
1380                 if (pMinLength != null)
1381                 {
1382                         Integer::Parse(*pMinLength, stringLengthMin);
1383                         delete pMinLength;
1384                         AppLogDebug("max String size [%d]", stringLengthMin);
1385                 }
1386
1387                 String* pMaxLength = static_cast<String*>(pItemNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_MAX_LENGTH));
1388                 if (pMaxLength != null)
1389                 {
1390                         Integer::Parse(*pMaxLength, stringLengthMax);
1391                         delete pMaxLength;
1392                         AppLogDebug("max String size [%d]", stringLengthMax);
1393                 }
1394
1395                 RelativeLayout relativeLayout;
1396                 relativeLayout.Construct();
1397                 pItem->Construct(relativeLayout, Dimension(itemWidth, itemMainRectangle.height), style);
1398                 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
1399
1400                 pItemNode->RegisterObserverlistener(__pIOAppSetting);
1401
1402                 String id = pItemNode->GetId();
1403                 String setActionIdDone(id);
1404                 String setActionIdCancel(id);
1405
1406                 setActionIdDone.Append(ID_POST_FIX_BUTTON_DONE);
1407                 setActionIdCancel.Append(ID_POST_FIX_BUTTON_CANCEL);
1408
1409                 EditField* pEditField = new (std::nothrow) EditField();
1410                 String* secondLine = pItemNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_VALUE);
1411
1412                 itemMainRectangle.x = X_GROUP_DEFAULT;
1413                 pEditField->Construct(itemMainRectangle, EDIT_FIELD_STYLE_NORMAL, INPUT_STYLE_OVERLAY, EDIT_FIELD_TITLE_STYLE_TOP, true, stringLengthMax, GROUP_STYLE_NONE);
1414                 pEditField->SetGuideText((*itemText).GetPointer());
1415                 pEditField->SetTitleText((*itemText).GetPointer());
1416                 pEditField->SetText((*secondLine).GetPointer());
1417                 delete secondLine;
1418
1419                 pEditField->SetTextSize(FONT_SIZE_SUB_TEXT);
1420                 pEditField->SetTitleTextColor(EDIT_STATUS_NORMAL, COLOR_HELP_TEXT_TYPE_01);
1421                 pEditField->SetColor(EDIT_STATUS_NORMAL, COLOR_BG_GROUP_ITEM_DEFAULT);
1422                 pEditField->SetColor(EDIT_STATUS_PRESSED, COLOR_BG_GROUP_ITEM_DEFAULT);
1423                 pEditField->SetColor(EDIT_STATUS_HIGHLIGHTED, COLOR_BG_GROUP_ITEM_DEFAULT);
1424                 pEditField->SetColor(EDIT_STATUS_DISABLED, COLOR_BG_GROUP_ITEM_DEFAULT);
1425                 pEditField->AddActionEventListener(*this);
1426                 pEditField->AddTextEventListener(*this);
1427                 pEditField->SetName(id);
1428                 pEditField->AddKeypadEventListener(*this);
1429
1430                 pItem->AddControl(pEditField);
1431                 pItem->SetBackgroundColor(COLOR_BG_GROUP_INDEX_DEFAULT, TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED);
1432                 pItem->SetIndividualSelectionEnabled(pEditField, true);
1433
1434                 relativeLayout.SetMargin(*pEditField, 0, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
1435                 relativeLayout.SetRelation(*pEditField, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
1436                 relativeLayout.SetRelation(*pEditField, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
1437         }
1438         else if ((pItemNode->GetType()).Equals(ID_APPSETTING_ITEM_TYPE_LABEL, false))
1439         {
1440                 pItem->Construct(Dimension(itemWidth, itemMainRectangle.height), style);
1441                 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
1442
1443                 pLabel = new (std::nothrow) Label();
1444                 pLabel->Construct(itemMainRectangle, (itemText)->GetPointer());
1445                 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
1446                 pLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
1447
1448                 pItem->AddControl(pLabel);
1449                 pItem->SetBackgroundColor(COLOR_BG_GROUP_INDEX_DEFAULT, TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED);
1450         }
1451         else if ((pItemNode->GetType()).Equals(ID_APPSETTING_ITEM_TYPE_EXPAND_LIST, false))
1452         {
1453                 IEnumerator* pCurrentIEnumerator =  pItemNode->GetCurrentIEnumerator();
1454
1455                 if (!((pCurrentIEnumerator != null)
1456                         && (pCurrentIEnumerator->MoveNext() == E_SUCCESS)))
1457                 {
1458                         AppLogDebug("Expandlist has no expandItems & remove");
1459                         delete pCurrentIEnumerator;
1460                         delete pItem;
1461                         delete itemText;
1462                         return null;
1463                 }
1464
1465                 String* value = pItemNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_VALUE);
1466                 String expendList;
1467
1468                 pItemNode->RegisterObserverlistener(__pIOAppSetting);
1469
1470                 pItem->Construct(Dimension(itemWidth, itemMainRectangle.height), style);
1471                 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
1472
1473                 expendList.Append(itemText->GetPointer());
1474                 expendList.Append(L" : ");
1475                 expendList.Append(value->GetPointer());
1476
1477                 delete value;
1478
1479                 pLabel = new (std::nothrow) Label();
1480                 pLabel->Construct(itemMainRectangle, expendList);
1481                 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
1482                 pLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
1483                 pLabel->SetName(pItemNode->GetId());
1484
1485                 pItem->AddControl(pLabel);
1486                 pItem->SetBackgroundColor(COLOR_BG_GROUP_INDEX_DEFAULT, TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED);
1487         }
1488         else if ((pItemNode->GetType()).Equals(ID_APPSETTING_ITEM_TYPE_EXPAND_ITEM, false))
1489         {
1490                 style = TABLE_VIEW_ANNEX_STYLE_RADIO;
1491
1492                 RelativeLayout relativeLayout;
1493                 relativeLayout.Construct();
1494                 pItem->Construct(relativeLayout, Dimension(itemWidth, itemMainRectangle.height), style);
1495                 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_LISTITEM);
1496
1497                 Node* parent = pItemNode->GetParent();
1498
1499                 String* pParentValue = (parent->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_VALUE));
1500                 String* pCurrentValue = (pItemNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_TITLE));
1501
1502                 if (pCurrentValue->Equals(*pParentValue, true))
1503                 {
1504                         __pTableView->SetItemChecked(groupIndex, itemIndex, true);
1505                 }
1506
1507                 pLabel = new (std::nothrow) Label();
1508                 pLabel->Construct(itemMainRectangle, (itemText)->GetPointer());
1509                 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
1510                 pLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
1511
1512                 pItem->AddControl(pLabel);
1513                 delete pParentValue;
1514                 delete pCurrentValue;
1515                 relativeLayout.SetMargin(*pLabel, RELATIVE_LAYOUT_LEFT_MARGIN, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
1516                 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
1517                 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
1518         }
1519         else if ((pItemNode->GetType()).Equals(ID_APPSETTING_ITEM_TYPE_SEPARATOR, false))
1520         {
1521                 Bitmap* pBitmap = ResourceManager::GetBitmapN(IDB_SEPARATOR);
1522                 itemMainRectangle.height = H_GROUP_INDEX_NO_TITLE_DEFAULT;
1523
1524                 if (pBitmap == null)
1525                 {
1526                         AppLogDebug("bitmap is null ");
1527                         AppLogDebug("separator id [%ls]", pItemNode->GetId().GetPointer());
1528                 }
1529
1530                 RelativeLayout relativeLayout;
1531                 relativeLayout.Construct();
1532                 pItem->Construct(relativeLayout, Dimension(itemWidth, itemMainRectangle.height), TABLE_VIEW_ANNEX_STYLE_NORMAL);
1533
1534                 pLabel = new (std::nothrow) Label();
1535                 pLabel->Construct(itemMainRectangle, L" ");
1536                 pLabel->SetBackgroundBitmap(*pBitmap);
1537                 pItem->AddControl(pLabel);
1538
1539                 delete pBitmap;
1540                 pItem->SetEnabled(false);
1541
1542                 relativeLayout.SetMargin(*pLabel, RELATIVE_LAYOUT_RIGHT_MARGIN, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
1543                 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
1544                 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
1545         }
1546         else
1547         {
1548                 AppLogDebug("pItem is null");
1549                 delete itemText;
1550                 delete pItem;
1551                 return null;
1552         }
1553         delete itemText;
1554         return pItem;
1555 }
1556
1557 bool
1558 AppSettingForm::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem)
1559 {
1560         delete pItem;
1561         pItem = null;
1562
1563         return true;
1564 }
1565
1566 bool
1567 AppSettingForm::DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem)
1568 {
1569         delete pItem;
1570         pItem = null;
1571
1572         return true;
1573 }
1574
1575 void
1576 AppSettingForm::OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
1577 {
1578         unsigned int hashCode = GetTranslateTableIndexToHashCode(groupIndex, itemIndex);
1579         AppLogDebug("%d %d", groupIndex, itemIndex);
1580         Node* pItemNode = GetItemHashCodeMap(hashCode);
1581         if (pItemNode == null)
1582         {
1583                 AppLogDebug("pItemNode is null");
1584                 return;
1585         }
1586
1587         if ((pItemNode->GetType()).Equals(ID_APPSETTING_ITEM_TYPE_EXPAND_ITEM, false))
1588         {
1589                 ElementNode* pParent = dynamic_cast<ElementNode*>(pItemNode->GetParent());
1590                 if (pParent == null)
1591                 {
1592                         AppLogDebug("pParent is null");
1593                         return;
1594                 }
1595
1596                 if (!pParent->GetType().Equals(ID_APPSETTING_ITEM_TYPE_EXPAND_LIST, false))
1597                 {
1598                         AppLogDebug("pParent is not ITEM_TYPE_EXPAND_LIST");
1599                         return;
1600                 }
1601
1602                 String* pValue = pItemNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_TITLE);
1603                 if (pValue == null)
1604                 {
1605                         AppLogDebug("pValue is null");
1606                         return;
1607                 }
1608
1609                 pParent->SetAttribute(ID_APPSETTING_ATTRIBUTE_TYPE_VALUE, *pValue);
1610                 delete pValue;
1611
1612                 unsigned int hashCode = pParent->GetId().GetHashCode();
1613                 ItemTag* itemTag = GetTranslateTableHashCodeToItemTag(hashCode);
1614
1615                 if (itemTag == null)
1616                 {
1617                         int itemCount = __pTableView->GetItemCountAt(groupIndex);
1618
1619                         for (int count = 0; count < itemCount; count++)
1620                         {
1621                                 bool itemSelectStatus = false;
1622                                 if (count == itemIndex)
1623                                 {
1624                                         itemSelectStatus = true;
1625                                 }
1626                                 __pTableView->SetItemChecked(groupIndex, count, itemSelectStatus);
1627                         }
1628                         RefreshExpandListItem(groupIndex);
1629
1630                         Invalidate(true);
1631                         return;
1632                 }
1633
1634                 int loopCount = pParent->GetChildCount() + itemTag->GetItemIndex() + APPSETTING_DEFAULT_COUNT;
1635
1636                 for (int pos = itemTag->GetItemIndex() + APPSETTING_DEFAULT_COUNT; pos < loopCount; pos++)
1637                 {
1638                         if (pos != itemIndex)
1639                         {
1640                                 __pTableView->SetItemChecked(groupIndex, pos, false);
1641                         }
1642                         else
1643                         {
1644                                 __pTableView->SetItemChecked(groupIndex, pos, true);
1645                         }
1646                 }
1647                 __pTableView->RefreshItem(itemTag->GetGroupIndex(), itemTag->GetItemIndex(), TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
1648
1649                 if (__pIOAppSetting != null)
1650                 {
1651                         __pIOAppSetting->UpdateChangedValue();
1652                 }
1653
1654                 Invalidate(true);
1655         }
1656         else if (pItemNode->GetType().Equals(ID_APPSETTING_ITEM_TYPE_BOOL, false))
1657         {
1658                 bool itemSelectStatus = tableView.IsItemChecked(groupIndex, itemIndex);
1659
1660                 if (status == TABLE_VIEW_ITEM_STATUS_SELECTED)
1661                 {
1662                         itemSelectStatus = (!itemSelectStatus);
1663                 }
1664                 tableView.SetItemChecked(groupIndex, itemIndex, itemSelectStatus);
1665                 pItemNode->SetAttribute(ID_APPSETTING_ATTRIBUTE_TYPE_VALUE, Boolean::ToString(itemSelectStatus));
1666
1667                 if (__pIOAppSetting != null)
1668                 {
1669                         __pIOAppSetting->UpdateChangedValue();
1670                 }
1671         }
1672         else
1673         {
1674                 AppLogDebug("null");
1675         }
1676         SetFocus();
1677 }
1678
1679 void
1680 AppSettingForm::OnActionPerformed(const Control& source, int actionId)
1681 {
1682         String sourceNametmp(source.GetName());
1683         String sourceName(L"");
1684
1685         StringTokenizer stringTokenizer(sourceNametmp, L":");
1686         stringTokenizer.GetNextToken(sourceName);
1687
1688         Node* pNode = GetItemHashCodeMap(sourceName.GetHashCode());
1689         if (pNode == null)
1690         {
1691                 AppLogDebug("pNode is null");
1692                 return;
1693         }
1694 }
1695
1696 int
1697 AppSettingForm::GetDefaultGroupItemHeight(void)
1698 {
1699         return H_GROUP_INDEX_NO_TITLE_DEFAULT;
1700 }
1701
1702 int
1703 AppSettingForm::GetDefaultItemHeight(void)
1704 {
1705         return H_GROUP_ITEM_DEFAULT;
1706 }
1707
1708 void
1709 AppSettingForm::RefreshExpandListItem(int groupIndex)
1710 {
1711         int itemCount = __pTableView->GetItemCountAt(groupIndex);
1712
1713         for (int count = -1; count < itemCount; count++)
1714         {
1715                 __pTableView->RefreshItem(groupIndex, count, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
1716         }
1717 }
1718
1719 void
1720 AppSettingForm::UpdateGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem)
1721 {
1722         Node* pNode = null;
1723         __pGroupItemNodeList->GetAt(groupIndex, pNode);
1724
1725         if (pNode->GetType().Equals(ID_APPSETTING_ITEM_TYPE_EXPAND_LIST, false))
1726         {
1727                 Label* pLabel = static_cast<Label*>(pItem->GetControl(0));
1728                 String expandList;
1729
1730                 String* groupText = pNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_TITLE);
1731                 String* value = pNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_VALUE);
1732
1733                 expandList.Append(groupText->GetPointer());
1734                 expandList.Append(L" : ");
1735                 expandList.Append(value->GetPointer());
1736
1737                 AppLogDebug("itemChanged [%ls]", expandList.GetPointer());
1738                 pLabel->SetText(expandList);
1739                 pLabel->Invalidate(false);
1740                 delete groupText;
1741                 delete value;
1742         }
1743 }
1744
1745 void
1746 AppSettingForm::UpdateItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
1747 {
1748         unsigned int hashCode = GetTranslateTableIndexToHashCode(groupIndex, itemIndex);
1749         Node* pItemNode = GetItemHashCodeMap(hashCode);
1750         if (pItemNode == null)
1751         {
1752                 AppLogDebug("GetItemHashCodeMap is null");
1753                 return;
1754         }
1755
1756         if (!pItemNode->GetType().Equals(ID_APPSETTING_ITEM_TYPE_EXPAND_LIST, false))
1757         {
1758                 if (pItemNode->GetType().Equals(ID_APPSETTING_ITEM_TYPE_EXPAND_ITEM, false))
1759                 {
1760                         AppLogDebug("pItemNode->GetType not equal ID_APPSETTING_ITEM_TYPE_EXPAND_LIST [%ls]", pItemNode->GetType().GetPointer());
1761                         pItem->Invalidate(false);
1762                 }
1763                 return;
1764         }
1765
1766         Label* pLabel = static_cast<Label*>(pItem->GetControl(pItemNode->GetId(), false));
1767         if (pLabel == null)
1768         {
1769                 AppLogDebug("pItem->GetControl is null");
1770                 return;
1771         }
1772
1773         String* pTitle = pItemNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_TITLE);
1774         String* pValue = pItemNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_VALUE);
1775         if (pValue == null || pTitle == null)
1776         {
1777                 AppLogDebug("GetAttributeN is null");
1778                 delete pValue;
1779                 delete pTitle;
1780                 return;
1781         }
1782
1783         String expendList(*pTitle);
1784         expendList.Append(L" : ");
1785         expendList.Append(*pValue);
1786
1787         pLabel->SetText(expendList);
1788         pLabel->Invalidate(false);
1789
1790         delete pTitle;
1791         delete pValue;
1792 }
1793
1794 void
1795 AppSettingForm::OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated)
1796 {
1797 }
1798
1799 void
1800 AppSettingForm::OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
1801 {
1802 }
1803
1804 void
1805 AppSettingForm::OnAdjustmentValueChanged(const Tizen::Ui::Control& source, int adjustment)
1806 {
1807         String sourceName = source.GetName();
1808
1809         Node* pNode = GetItemHashCodeMap(sourceName.GetHashCode());
1810         if (pNode == null)
1811         {
1812                 AppLogDebug("pNode is null");
1813                 return;
1814         }
1815
1816         pNode->SetAttribute(ID_APPSETTING_ATTRIBUTE_TYPE_VALUE, Integer::ToString(adjustment));
1817         SetFocus();
1818
1819         if (__pIOAppSetting != null)
1820         {
1821                 __pIOAppSetting->UpdateChangedValue();
1822         }
1823 }
1824
1825 void
1826 AppSettingForm::OnSliderBarMoved(Tizen::Ui::Controls::Slider& source, int value)
1827 {
1828 }
1829
1830 void
1831 AppSettingForm::OnTextValueChanged(const Tizen::Ui::Control& source)
1832 {
1833         String sourceName = source.GetName();
1834         String changedText;
1835         Node* pNode = GetItemHashCodeMap(sourceName.GetHashCode());
1836         if (pNode == null)
1837         {
1838                 AppLogDebug("pNode is null");
1839                 return;
1840         }
1841
1842         EditField* pEditField = static_cast<EditField*>(&const_cast<Control&>(source));
1843
1844         if (pEditField)
1845         {
1846                 changedText = pEditField->GetText();
1847         }
1848
1849         pNode->SetAttribute(ID_APPSETTING_ATTRIBUTE_TYPE_VALUE, changedText);
1850
1851         String* pMin = pNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_MIN_LENGTH);
1852         String* pMax = pNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_MAX_LENGTH);
1853
1854         int minLength = 0;
1855         int maxLength = 0;
1856         int currentLength = pEditField->GetTextLength();
1857
1858         Integer::Parse(*pMin, minLength);
1859         Integer::Parse(*pMax, maxLength);
1860
1861         if ((minLength <= currentLength) && (maxLength >= currentLength))
1862         {
1863                 if (__pIOAppSetting != null)
1864                 {
1865                         AppLogDebug(" current[%d]  min [%d] max[%d]", currentLength, minLength, maxLength);
1866                         __pIOAppSetting->UpdateChangedValue();
1867                 }
1868         }
1869
1870         delete pMin;
1871         delete pMax;
1872 }
1873
1874 void
1875 AppSettingForm::OnKeypadOpened(Tizen::Ui::Control& source)
1876 {
1877         unsigned int hashCode = source.GetName().GetHashCode();
1878         ItemTag* itemTag = GetTranslateTableHashCodeToItemTag(hashCode);
1879         if (itemTag)
1880         {
1881                 __pTableView->ScrollToItem(itemTag->GetGroupIndex(), itemTag->GetItemIndex(), TABLE_VIEW_SCROLL_ITEM_ALIGNMENT_BOTTOM);
1882         }
1883 }
1884
1885 void
1886 AppSettingForm::OnKeypadActionPerformed(Tizen::Ui::Control& source, Tizen::Ui::KeypadAction keypadAction)
1887 {
1888 }
1889
1890 void
1891 AppSettingForm::OnOrientationChanged(const Tizen::Ui::Control& source, Tizen::Ui::OrientationStatus orientationStatus)
1892 {
1893         if (__pTableView == null)
1894         {
1895                 Label* pLabel = static_cast<Label*>(GetControl(L"InvalidFormat"));
1896
1897                 if (pLabel)
1898                 {
1899                         Rectangle clientRect = GetClientAreaBounds();
1900                         Rectangle labelRect = pLabel->GetBounds();
1901
1902                         labelRect = clientRect;
1903                         labelRect.y = 0;
1904
1905                         pLabel->SetBounds(labelRect);
1906                         pLabel->Invalidate(false);
1907                 }
1908         }
1909         Invalidate(true);
1910 }
1911
1912 void
1913 ItemTag::SetItemTag(int groupIndex, int itemIndex)
1914 {
1915         __groupIndex = groupIndex;
1916         __itemIndex = itemIndex;
1917 }
1918
1919 void
1920 ItemTag::GetItemTag(int& groupIndex, int& itemIndex)
1921 {
1922         groupIndex = __groupIndex;
1923         itemIndex = __itemIndex;
1924 }