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