From: jaeyeol lee Date: Sat, 26 Apr 2014 06:26:57 +0000 (+0900) Subject: DATABIND : modify the code generation for system APIs X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=eb2aeeb00480a7de22e09d3a51f48755d9f81b5b;p=sdk%2Fide%2Fweb-ui-builder-eplugin.git DATABIND : modify the code generation for system APIs Change-Id: I61f39f8b4d4628b6a47180ec6242d958d2b57c90 Signed-off-by: jaeyeol lee --- diff --git a/org.tizen.webuibuilder/res/xslt/index_managed_js_ver0_0_1.xslt b/org.tizen.webuibuilder/res/xslt/index_managed_js_ver0_0_1.xslt index 5d33f36..e634cd3 100644 --- a/org.tizen.webuibuilder/res/xslt/index_managed_js_ver0_0_1.xslt +++ b/org.tizen.webuibuilder/res/xslt/index_managed_js_ver0_0_1.xslt @@ -175,24 +175,66 @@ app.init = function() { - + - - + + + + + + + + + + + + + + + - + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -235,12 +277,12 @@ app.init = function() { - + - + @@ -253,7 +295,7 @@ app.init = function() { - + @@ -265,7 +307,7 @@ app.init = function() { - + @@ -280,6 +322,33 @@ app.init = function() { + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -293,7 +362,7 @@ app.init = function() { - + diff --git a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/BuilderConstants.java b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/BuilderConstants.java index c6b687c..7106683 100644 --- a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/BuilderConstants.java +++ b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/BuilderConstants.java @@ -227,6 +227,14 @@ public class BuilderConstants { public static final String ATTRIBUTE_JSONDATA = "jsonData"; //$NON-NLS-1$ public static final String ATTRIBUTE_FILEPATH = "filePath"; //$NON-NLS-1$ public static final String ATTRIBUTE_API = "api"; //$NON-NLS-1$ + public static final String ATTRIBUTE_METHOD = "method"; //$NON-NLS-1$ + public static final String ATTRIBUTE_ADDRESS_BOOK_ID = "addressBookId"; //$NON-NLS-1$ + public static final String ATTRIBUTE_CALENDAR_TYPE = "calendarType"; //$NON-NLS-1$ + public static final String ATTRIBUTE_CALENDAR_ID = "calendarId"; //$NON-NLS-1$ + public static final String ATTRIBUTE_DIRECTION = "direction"; //$NON-NLS-1$ + public static final String ATTRIBUTE_START_TIME_ORDER = "starttimeorder"; //$NON-NLS-1$ + public static final String ATTRIBUTE_HEADERS = "headers"; //$NON-NLS-1$ + public static final String ATTRIBUTE_DATA_BIND = "data-bind"; //$NON-NLS-1$ // Project file attribute value diff --git a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/model/app/io/AppMetaReader_ver_2.java b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/model/app/io/AppMetaReader_ver_2.java index d732fa2..0f550eb 100644 --- a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/model/app/io/AppMetaReader_ver_2.java +++ b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/model/app/io/AppMetaReader_ver_2.java @@ -25,7 +25,9 @@ package org.tizen.webuibuilder.model.app.io; import java.util.AbstractMap; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Map.Entry; import org.w3c.dom.Document; @@ -230,10 +232,14 @@ public class AppMetaReader_ver_2 { String sourceType = element2.getAttribute(BuilderConstants.ATTRIBUTE_SOURCETYPE); String timeout = element2.getAttribute(BuilderConstants.ATTRIBUTE_TIMEOUT); String jsonData = element2.getAttribute(BuilderConstants.ATTRIBUTE_JSONDATA); + String headersInfo = element2.getAttribute(BuilderConstants.ATTRIBUTE_HEADERS); + Map headers = makeHeaders(headersInfo); BindingData dataModel = new BindingData(name, modelType, url, type, proxy, query, sourceType, - timeout, jsonData); + timeout, jsonData, headers); + + descriptor.addDataSource(dataModel); } else if ((modelType != null) && (modelType.equals(BuilderConstants.DATABINDING_TYPE_STATIC))) { String jsonData = element2.getAttribute(BuilderConstants.ATTRIBUTE_JSONDATA); @@ -257,6 +263,18 @@ public class AppMetaReader_ver_2 { } } } + + private static Map makeHeaders(String headersInfo) { + Map headers = new HashMap(); + String[] headersInfoArray; + headersInfoArray = headersInfo.split("&"); + for (String info : headersInfoArray) { + String[] infoArray = info.split("="); + headers.put(infoArray[0], infoArray[1]); + } + + return headers; + } private static void parseObservableObject(Element element, BindingData dataModel, BindingObject parentObject) { diff --git a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/model/app/io/HtmlMetaReader_ver_1.java b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/model/app/io/HtmlMetaReader_ver_1.java index f8d7c29..a6cb6d7 100644 --- a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/model/app/io/HtmlMetaReader_ver_1.java +++ b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/model/app/io/HtmlMetaReader_ver_1.java @@ -24,8 +24,10 @@ package org.tizen.webuibuilder.model.app.io; import java.util.ArrayList; +import java.util.HashMap; import java.util.Iterator; import java.util.List; +import java.util.Map; import org.w3c.dom.Attr; import org.w3c.dom.Document; @@ -189,10 +191,12 @@ public class HtmlMetaReader_ver_1 { String sourceType = element2.getAttribute(BuilderConstants.ATTRIBUTE_SOURCETYPE); String timeout = element2.getAttribute(BuilderConstants.ATTRIBUTE_TIMEOUT); String jsonData = element2.getAttribute(BuilderConstants.ATTRIBUTE_JSONDATA); + String headersInfo = element2.getAttribute(BuilderConstants.ATTRIBUTE_HEADERS); + Map headers = makeHeaders(headersInfo); BindingData dataModel = new BindingData(sourceName, modelType, url, type, proxy, query, sourceType, - timeout, jsonData); + timeout, jsonData, headers); parseObservableObject(element2, dataModel); @@ -206,10 +210,42 @@ public class HtmlMetaReader_ver_1 { parseObservableObject(element2, dataModel); fileData.addDataSource(dataModel); - } else if ((modelType != null) && (modelType.equals("RUNTIMEAPI"))) { - String api = element2.getAttribute(BuilderConstants.ATTRIBUTE_API); + } else if ((modelType != null) && (modelType.equals("Contact"))) { + String method = element2.getAttribute(BuilderConstants.ATTRIBUTE_METHOD); + String addressBookId = element2.getAttribute(BuilderConstants.ATTRIBUTE_ADDRESS_BOOK_ID); - BindingData dataModel = new BindingData(sourceName, modelType, api); + BindingData dataModel = new BindingData(); + dataModel.setSourceName(sourceName); + dataModel.setModelType(modelType); + dataModel.setRuntimeApiName(method); + dataModel.setRuntimeApiAddressBookID(addressBookId); + parseObservableObject(element2, dataModel); + fileData.addDataSource(dataModel); + } else if ((modelType != null) && (modelType.equals("Calendar"))) { + String method = element2.getAttribute(BuilderConstants.ATTRIBUTE_METHOD); + String calendarType = element2.getAttribute(BuilderConstants.ATTRIBUTE_CALENDAR_TYPE); + String calendarId = element2.getAttribute(BuilderConstants.ATTRIBUTE_CALENDAR_ID); + + BindingData dataModel = new BindingData(); + dataModel.setSourceName(sourceName); + dataModel.setModelType(modelType); + dataModel.setCalendarName(method); + dataModel.setCalendarType(calendarType); + dataModel.setCalendarID(calendarId); + parseObservableObject(element2, dataModel); + fileData.addDataSource(dataModel); + } else if ((modelType != null) && (modelType.equals("Call History"))) { + String type = element2.getAttribute(BuilderConstants.ATTRIBUTE_TYPE); + String direction = element2.getAttribute(BuilderConstants.ATTRIBUTE_DIRECTION); + String startTimeOrder = element2.getAttribute(BuilderConstants.ATTRIBUTE_START_TIME_ORDER); + + BindingData dataModel = new BindingData(); + dataModel.setSourceName(sourceName); + dataModel.setModelType(modelType); + dataModel.setCallHistoryType(type); + dataModel.setCallHistoryDirection(direction); + dataModel.setCallHistoryStartTimeOrder(startTimeOrder); + parseObservableObject(element2, dataModel); fileData.addDataSource(dataModel); } else { BindingData dataModel = new BindingData(); @@ -220,7 +256,22 @@ public class HtmlMetaReader_ver_1 { } } - private static void parseViewModel(HtmlMetaFileData fileData, Element element) { + private static Map makeHeaders(String headersInfo) { + Map headers = new HashMap(); + if (!headersInfo.isEmpty()) { + String[] headersInfoArray; + headersInfoArray = headersInfo.split("&"); + for (String info : headersInfoArray) { + String[] infoArray = info.split("="); + if (infoArray.length == 2) { + headers.put(infoArray[0], infoArray[1]); + } + } + } + return headers; + } + + private static void parseViewModel(HtmlMetaFileData fileData, Element element) { NodeList elementList = element.getElementsByTagName(BuilderConstants.ELEMENT_VIEWMODEL); for (int i = 0; i < elementList.getLength(); i++) { Element element2 = (Element) elementList.item(i); diff --git a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/model/app/io/HtmlMetaWriter_ver_1.java b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/model/app/io/HtmlMetaWriter_ver_1.java index f53347b..f275b4b 100644 --- a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/model/app/io/HtmlMetaWriter_ver_1.java +++ b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/model/app/io/HtmlMetaWriter_ver_1.java @@ -340,6 +340,13 @@ public class HtmlMetaWriter_ver_1 { element.setAttribute(BuilderConstants.ATTRIBUTE_MODELTYPE, dataModel.getModelType()); if ((dataModel.getModelType() != null) && (dataModel.getModelType().equals(BuilderConstants.DATABINDING_TYPE_REMOTECALL))) { + String headerInfo = ""; + if (dataModel.getHeaders() != null) { + for (Entry info : dataModel.getHeaders().entrySet()) { + headerInfo += info.getKey() + "=" + info.getValue() + "&"; + } + } + element.setAttribute(BuilderConstants.ATTRIBUTE_URL, dataModel.getURL()); element.setAttribute(BuilderConstants.ATTRIBUTE_TYPE, dataModel.getMethod()); element.setAttribute(BuilderConstants.ATTRIBUTE_PROXY, dataModel.getProxy()); @@ -347,6 +354,7 @@ public class HtmlMetaWriter_ver_1 { element.setAttribute(BuilderConstants.ATTRIBUTE_SOURCETYPE, dataModel.getSourceType()); element.setAttribute(BuilderConstants.ATTRIBUTE_TIMEOUT, dataModel.getTimeout()); element.setAttribute(BuilderConstants.ATTRIBUTE_JSONDATA, dataModel.getJsonData()); + element.setAttribute(BuilderConstants.ATTRIBUTE_HEADERS, headerInfo); List observableObjects = dataModel.getDataSourceObjects(); int size = observableObjects.size(); @@ -367,9 +375,35 @@ public class HtmlMetaWriter_ver_1 { element.setAttribute(BuilderConstants.ATTRIBUTE_JSONDATA, jsonData); element.setAttribute(BuilderConstants.ATTRIBUTE_FILEPATH, dataModel.getStaticFilePath()); } else if ((dataModel.getModelType() != null) - && (dataModel.getModelType().equals("RUNTIMEAPI"))) { - element.setAttribute(BuilderConstants.ATTRIBUTE_API, dataModel.getRuntimeApiName()); - } + && (dataModel.getModelType().equals("Contact"))) { + element.setAttribute(BuilderConstants.ATTRIBUTE_METHOD, dataModel.getRuntimeApiName()); + element.setAttribute(BuilderConstants.ATTRIBUTE_ADDRESS_BOOK_ID, dataModel.getRuntimeApiAddressBookID()); + List observableObjects = dataModel.getDataSourceObjects(); + int size = observableObjects.size(); + for (int i = 0; i < size; i++) { + element.appendChild(writeObservableObjects(doc, observableObjects.get(i))); + } + } else if ((dataModel.getModelType() != null) + && (dataModel.getModelType().equals("Calendar"))) { + element.setAttribute(BuilderConstants.ATTRIBUTE_METHOD, dataModel.getCalendarName()); + element.setAttribute(BuilderConstants.ATTRIBUTE_CALENDAR_TYPE, dataModel.getCalendarType()); + element.setAttribute(BuilderConstants.ATTRIBUTE_CALENDAR_ID, dataModel.getCalendarID()); + List observableObjects = dataModel.getDataSourceObjects(); + int size = observableObjects.size(); + for (int i = 0; i < size; i++) { + element.appendChild(writeObservableObjects(doc, observableObjects.get(i))); + } + } else if ((dataModel.getModelType() != null) + && (dataModel.getModelType().equals("Call History"))) { + element.setAttribute(BuilderConstants.ATTRIBUTE_TYPE, dataModel.getCallHistoryType()); + element.setAttribute(BuilderConstants.ATTRIBUTE_DIRECTION, dataModel.getCallHistoryDirection()); + element.setAttribute(BuilderConstants.ATTRIBUTE_START_TIME_ORDER, dataModel.getCallHistoryStartTimeOrder()); + List observableObjects = dataModel.getDataSourceObjects(); + int size = observableObjects.size(); + for (int i = 0; i < size; i++) { + element.appendChild(writeObservableObjects(doc, observableObjects.get(i))); + } + } return element; } diff --git a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/databinding/model/BindingData.java b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/databinding/model/BindingData.java index 708be2c..6eb19a9 100644 --- a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/databinding/model/BindingData.java +++ b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/databinding/model/BindingData.java @@ -77,7 +77,7 @@ public class BindingData { * @param jsonData */ public BindingData( String sourceName, String modelType, String url, String type, String proxy, - String query, String sourceType, String timeout, String jsonData ) { + String query, String sourceType, String timeout, String jsonData, Map headers ) { this.sourceName = sourceName; this.modelType = modelType; this.url = url; @@ -87,6 +87,7 @@ public class BindingData { this.sourceType = sourceType; this.timeout = timeout; this.jsonData = jsonData; + this.headers = headers; } /**