uidesigner/com.nokia.sdt.uimodel.tests/data/nodepath/CBA_reconcile.js
changeset 2 d760517a8095
equal deleted inserted replaced
-1:000000000000 2:d760517a8095
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 /**
       
    18  *	Script for reconciling the CBA property of a CBA component.
       
    19  *	Implements IReconcileProperty
       
    20  *
       
    21  */
       
    22 
       
    23 var summaryIndex = 0;
       
    24 var leftIdIndex = 1;
       
    25 var leftTextIndex = 2;
       
    26 var rightIdIndex = 3;
       
    27 var rightTextIndex = 4;
       
    28 
       
    29 var text_softkey_option = lookupString("text_softkey_option");
       
    30 var text_softkey_select = lookupString("text_softkey_select");
       
    31 var text_softkey_ok = lookupString("text_softkey_ok");
       
    32 var text_softkey_done = lookupString("text_softkey_done");
       
    33 var text_softkey_call = lookupString("text_softkey_call");
       
    34 var text_softkey_yes = lookupString("text_softkey_yes");
       
    35 var text_softkey_no = lookupString("text_softkey_no");
       
    36 var text_softkey_cancel = lookupString("text_softkey_cancel");
       
    37 var text_softkey_exit = lookupString("text_softkey_exit");
       
    38 var text_softkey_quit = lookupString("text_softkey_quit");
       
    39 var text_softkey_back = lookupString("text_softkey_back");
       
    40 var text_softkey_insert_char = lookupString("text_softkey_insert_char");
       
    41 var text_softkey_close = lookupString("text_softkey_close");
       
    42 var text_softkey_empty = "";
       
    43 var text_softkey_save = lookupString("text_softkey_save");
       
    44 var text_softkey_show = lookupString("text_softkey_show");
       
    45 var text_softkey_search = lookupString("text_softkey_search");
       
    46 var text_softkey_read = lookupString("text_softkey_read");
       
    47 var text_softkey_listen = lookupString("text_softkey_listen");
       
    48 var text_softkey_answer = lookupString("text_softkey_answer");
       
    49 var text_softkey_again = lookupString("text_softkey_again");
       
    50 var text_softkey_unlock = lookupString("text_softkey_unlock");
       
    51 var text_softkey_mark = lookupString("text_softkey_mark");
       
    52 var text_softkey_unmark = lookupString("text_softkey_unmark");
       
    53 var text_softkey_copy = lookupString("text_softkey_copy");
       
    54 var text_softkey_paste = lookupString("text_softkey_paste");
       
    55 var text_softkey_details = lookupString("text_softkey_details");
       
    56 var text_softkey_stop = lookupString("text_softkey_stop");
       
    57 var text_softkey_pause = lookupString("text_softkey_pause");
       
    58 var text_softkey_accept = lookupString("text_softkey_accept");
       
    59 
       
    60 var FIXED_CBA_PREFIX = "r_avkon_softkeys_";
       
    61 
       
    62 var EMPTY = new Array("empty", "EAknSoftkeyEmpty", text_softkey_empty, "EAknSoftkeyEmpty", text_softkey_empty);
       
    63 var EMPTY_WITH_IDS = new Array("empty_with_ids", "EAknSoftkeyEmpty", text_softkey_empty, "EAknSoftkeyEmpty", text_softkey_empty);
       
    64 var OK_EMPTY = new Array("ok_empty", "EAknSoftkeyOk", text_softkey_ok, "", text_softkey_empty);
       
    65 var SELECT_CANCEL = new Array("select_cancel", "EAknSoftkeySelect", text_softkey_select, "EAknSoftkeyCancel", text_softkey_cancel);
       
    66 var OK_CANCEL = new Array("ok_cancel", "EAknSoftkeyOk", text_softkey_ok, "EAknSoftkeyCancel", text_softkey_cancel);
       
    67 var OK_DETAILS = new Array("ok_details", "EAknSoftkeyOk", text_softkey_ok, "EAknSoftkeyDetails", text_softkey_details);
       
    68 var CALL_CANCEL = new Array("call_cancel", "EAknSoftkeyCall", text_softkey_call, "EAknSoftkeyCancel", text_softkey_cancel);
       
    69 var OPTIONS_BACK = new Array("options_back", "EAknSoftkeyOptions", text_softkey_option, "EAknSoftkeyBack", text_softkey_back);
       
    70 var OPTIONS_DONE = new Array("options_done", "EAknSoftkeyOptions", text_softkey_option, "EAknSoftkeyDone", text_softkey_done);
       
    71 var OPTIONS_CANCEL = new Array("options_cancel", "EAknSoftkeyOptions", text_softkey_option, "EAknSoftkeyCancel", text_softkey_cancel);
       
    72 var OPTIONS_EXIT = new Array("options_exit", "EAknSoftkeyOptions", text_softkey_option, "EAknSoftkeyExit", text_softkey_exit);
       
    73 var OK_BACK = new Array("ok_back", "EAknSoftkeyOk", text_softkey_ok, "EAknSoftkeyBack", text_softkey_back);
       
    74 var CANCEL = new Array("cancel", "", text_softkey_empty, " EAknSoftkeyCancel", text_softkey_cancel);
       
    75 var BACK = new Array("back", "", text_softkey_empty, " EAknSoftkeyBack", text_softkey_back);
       
    76 var CLOSE = new Array("close", "", text_softkey_empty, "EAknSoftkeyClose", text_softkey_close);
       
    77 var DONE_BACK = new Array("done_back", "EAknSoftkeyDone", text_softkey_done, "EAknSoftkeyBack", text_softkey_back);
       
    78 var DONE_CANCEL = new Array("done_cancel", "EAknSoftkeyDone", text_softkey_done, "EAknSoftkeyCancel", text_softkey_cancel);
       
    79 var SELECT_BACK = new Array("select_back", "EAknSoftkeySelect", text_softkey_select, "EEikBidCancel", text_softkey_back);
       
    80 var MARK_BACK = new Array("mark_back", "EAknSoftkeyMark", text_softkey_mark, "EAknSoftkeyOk", text_softkey_back);
       
    81 var UNMARK_BACK = new Array("unmark_back", "EAknSoftkeyUnmark", text_softkey_unmark, "EAknSoftkeyOk", text_softkey_back);
       
    82 var YES_NO = new Array("yes_no", "EAknSoftkeyYes", text_softkey_yes, "EAknSoftkeyNo", text_softkey_no);
       
    83 var UNLOCK_EMPTY = new Array("unlock_empty", "EAknSoftkeyUnlock", text_softkey_unlock, "", text_softkey_empty);
       
    84 var SAVE_BACK = new Array("save_back", "EAknSoftkeySave", text_softkey_save, "EAknSoftkeyBack", text_softkey_back);
       
    85 var SHOW_CANCEL = new Array("show_cancel", "EAknSoftkeyShow", text_softkey_show, "EAknSoftkeyCancel", text_softkey_cancel);
       
    86 var SHOW_EXIT = new Array("show_exit", "EAknSoftkeyShow", text_softkey_show, "EAknSoftkeyExit", text_softkey_exit);
       
    87 var ANSWER_EXIT = new Array("answer_exit", "EAknSoftkeyShow", text_softkey_answer, "EAknSoftkeyExit", text_softkey_exit);
       
    88 var EXIT = new Array("exit", "", text_softkey_empty, "EAknSoftkeyBack", text_softkey_exit);
       
    89 var READ_EXIT = new Array("read_exit", "EAknSoftkeyRead", text_softkey_read, "EAknSoftkeyExit", text_softkey_exit);
       
    90 var LISTEN_EXIT = new Array("listen_exit", "EAknSoftkeyListen", text_softkey_listen, "EAknSoftkeyExit", text_softkey_exit);
       
    91 var SEARCH_BACK = new Array("search_back", "EAknSoftkeySearch", text_softkey_search, "EAknSoftkeyBack", text_softkey_back);
       
    92 var AGAIN_QUIT = new Array("again_quit", "EAknSoftkeyAgain", text_softkey_again, "EAknSoftkeyQuit", text_softkey_quit);
       
    93 var QUIT = new Array("quit", "", text_softkey_empty, "EAknSoftkeyQuit", text_softkey_quit);
       
    94 var INSERT_BACK = new Array("insert_back", "EAknSoftkeyInsert", text_softkey_insert_char, "EAknSoftkeyBack", text_softkey_back);
       
    95 
       
    96 var cbaTable = new Array(EMPTY, EMPTY_WITH_IDS, OK_EMPTY, SELECT_CANCEL, OK_CANCEL, OK_DETAILS, CALL_CANCEL, OPTIONS_BACK, OPTIONS_DONE, OPTIONS_CANCEL, OPTIONS_EXIT, OK_BACK, CANCEL, BACK, CLOSE, DONE_BACK, DONE_CANCEL, SELECT_BACK, MARK_BACK, UNMARK_BACK, YES_NO, UNLOCK_EMPTY, SAVE_BACK, SHOW_CANCEL, SHOW_EXIT, ANSWER_EXIT, EXIT, READ_EXIT, LISTEN_EXIT, SEARCH_BACK, AGAIN_QUIT, QUIT, INSERT_BACK);
       
    97 
       
    98 var CUSTOM = "com.nokia.sdt.series60.test.CBA.Type.CUSTOM";
       
    99 var PROPERTY_TYPE = "com.nokia.sdt.series60.test.CBAProperty"
       
   100 
       
   101 function CBAReconcile() {
       
   102 }
       
   103 
       
   104 CBAReconcile.prototype.createDisplayValue = function(instance, propertyTypeName, propertyValue) {
       
   105 	if (!propertyTypeName.equals(PROPERTY_TYPE)) {
       
   106 		return null;
       
   107 	}
       
   108 	
       
   109 //	java.lang.System.out.println("createDisplayValue: lid(" + propertyValue.leftId + "), ltext(" + propertyValue.leftText + "), rid(" + propertyValue.rightId + "), rtext(" + propertyValue.rightText + ")");
       
   110 	for (var i = 0; i < cbaTable.length; i++) {
       
   111 		if (propertyValue.leftId.equals(cbaTable[i][leftIdIndex]) &&
       
   112 			propertyValue.leftText.equals(cbaTable[i][leftTextIndex]) &&
       
   113 			propertyValue.rightId.equals(cbaTable[i][rightIdIndex]) &&
       
   114 			propertyValue.rightText.equals(cbaTable[i][rightTextIndex])) {
       
   115 //				java.lang.System.out.println("createDisplayValue: found property value, returning displayValue");
       
   116 				return FIXED_CBA_PREFIX + cbaTable[i][summaryIndex];
       
   117 			}
       
   118 	}
       
   119 	
       
   120 	return CUSTOM;
       
   121 }
       
   122 
       
   123 CBAReconcile.prototype.isDisplayValueEditable = function(instance, propertyTypeName) {
       
   124 	if (!propertyTypeName.equals(PROPERTY_TYPE)) {
       
   125 		return true;
       
   126 	}
       
   127 				
       
   128 	return true;
       
   129 }
       
   130 	
       
   131 CBAReconcile.prototype.applyDisplayValue = function(instance, propertyTypeName, displayValue, propertyValue) {
       
   132 	if (!propertyTypeName.equals(PROPERTY_TYPE)) {
       
   133 		return;
       
   134 	}
       
   135 		
       
   136 //	java.lang.System.out.println("applyDisplayValue(" + displayValue + ")");
       
   137 //	java.lang.System.out.println("applyDisplayValue: lid(" + propertyValue.leftId + "), ltext(" + propertyValue.leftText + "), rid(" + propertyValue.rightId + "), rtext(" + propertyValue.rightText + ")");
       
   138 	for (var i = 0; i < cbaTable.length; i++) {
       
   139 		if (displayValue.equals(FIXED_CBA_PREFIX + cbaTable[i][summaryIndex])) {
       
   140 //			java.lang.System.out.println("applyDisplayValue: found display value, setting propertyValue");
       
   141 			propertyValue.leftId = cbaTable[i][leftIdIndex];
       
   142 			propertyValue.leftText = cbaTable[i][leftTextIndex];
       
   143 			propertyValue.rightId = cbaTable[i][rightIdIndex];
       
   144 			propertyValue.rightText = cbaTable[i][rightTextIndex];
       
   145 			return;
       
   146 		}
       
   147 	}
       
   148 }
       
   149 
       
   150