diff --git a/de.wwu.md2.framework/src/de/wwu/md2/framework/MD2.xtext b/de.wwu.md2.framework/src/de/wwu/md2/framework/MD2.xtext index 384c9e2e..ab78dff6 100644 --- a/de.wwu.md2.framework/src/de/wwu/md2/framework/MD2.xtext +++ b/de.wwu.md2.framework/src/de/wwu/md2/framework/MD2.xtext @@ -546,7 +546,7 @@ SubViewContainer: * A ListView for using a whole Activity as a List */ ListView: - 'ListView' name = EID '{' + 'ListView' name = EID ('(' params += ListViewLayoutParam (',' params += ListViewLayoutParam)* ')')? '{' ('connectedProvider' connectedProvider = ContentProviderPath) ('onClickAction' onClickAction = [Action | QUALIFIED_NAME])? ('leftSwipeAction' leftSwipeAction = [Action | QUALIFIED_NAME])? @@ -558,6 +558,19 @@ ListViewParam: {PlaceholderParam} 'placeholder' value = INT ; +ListViewLayoutParam: + //{ViewIcon} 'icon' value = ("close_button"|"common_full_open_on_phone"|"common_google_signin_btn_icon_light")? + {ViewIcon} 'icon' value = ViewIcon? +; + +ViewIcon: + "close_button"|"common_full_open_on_phone"|"common_google_signin_btn_icon_light"|"preference_wrapped_icon" | "open_on_phone_animation" | "open_on_phone" +; + +ViewIconActionDrawer: + "btn_star_big_on" | "arrow_up_float" +; + /* * A GridLayoutPane allows the arrangement of ViewGUIElements in a grid structure. The user can specify the * number of columns or the number of rows. If one of those is specified the other one will be calculated by @@ -575,7 +588,7 @@ GridLayoutPane: * These are besides the number of columns and rows all TabSpecificParams. */ GridLayoutPaneParam: - {GridLayoutPaneColumnsParam} 'columns' value = INT | {GridLayoutPaneRowsParam} 'rows' value = INT | CommonContainerParam | {GridLayoutPaneIcon} 'icon' value = ("close_button"|"common_full_open_on_phone"|"common_google_signin_btn_icon_light")? + {GridLayoutPaneColumnsParam} 'columns' value = INT | {GridLayoutPaneRowsParam} 'rows' value = INT | CommonContainerParam | {ViewIcon} 'icon' value = ViewIcon? //{ViewIcon} 'icon' value = ("close_button"|"common_full_open_on_phone"|"common_google_signin_btn_icon_light")? ; /* @@ -592,7 +605,7 @@ FlowLayoutPane: * These are besides the flowDirection all TabSpecificParams. */ FlowLayoutPaneParam: - {FlowLayoutPaneFlowDirectionParam} flowDirection = FlowDirection | CommonContainerParam + {FlowLayoutPaneFlowDirectionParam} flowDirection = FlowDirection | CommonContainerParam | {ViewIcon} 'icon' value = ViewIcon? //{ViewIcon} 'icon' value = ("close_button"|"common_full_open_on_phone"|"common_google_signin_btn_icon_light")? ; /* @@ -607,7 +620,7 @@ enum FlowDirection: * or Labels in a single-column view structure. */ ActionDrawer: - 'ActionDrawer' name = EID '(' params += ActionDrawerParam ')' '{' + 'ActionDrawer' name = EID ('('(params += ActionDrawerParam (',' params += ActionDrawerParam)*)?')')? '{' 'Actions' '{' onItemClickAction += [Action | QUALIFIED_NAME] (',' onItemClickAction += [Action | QUALIFIED_NAME ])* @@ -618,7 +631,8 @@ ActionDrawer: ; ActionDrawerParam: - {ActionDrawerTitleParam} 'title' value = STRING + {ActionDrawerTitleParam} 'titles' ('('(values += STRING (',' values += STRING)*)?')') | //STRING | + {ViewIconActionDrawer} 'icons' ('('(values += ViewIconActionDrawer(',' values += ViewIconActionDrawer)*)?')') ; /* diff --git a/de.wwu.md2.framework/src/de/wwu/md2/framework/generator/android/wearable/controller/ActivityGen.xtend b/de.wwu.md2.framework/src/de/wwu/md2/framework/generator/android/wearable/controller/ActivityGen.xtend index 21aa3820..903a9f5b 100644 --- a/de.wwu.md2.framework/src/de/wwu/md2/framework/generator/android/wearable/controller/ActivityGen.xtend +++ b/de.wwu.md2.framework/src/de/wwu/md2/framework/generator/android/wearable/controller/ActivityGen.xtend @@ -15,9 +15,7 @@ import de.wwu.md2.framework.mD2.WorkflowElementReference import de.wwu.md2.framework.mD2.ContentContainer import de.wwu.md2.framework.mD2.Entity import de.wwu.md2.framework.mD2.SensorType -import de.wwu.md2.framework.mD2.GridLayoutPaneIcon import de.wwu.md2.framework.mD2.impl.GridLayoutPaneImpl -import de.wwu.md2.framework.mD2.impl.GridLayoutPaneIconImpl import de.wwu.md2.framework.generator.android.wearable.view.ValueGen import de.wwu.md2.framework.mD2.ListView @@ -36,6 +34,12 @@ import java.util.LinkedHashSet import java.util.LinkedList import java.util.Map import de.wwu.md2.framework.mD2.IntegerInput +import java.awt.GridBagLayout +import de.wwu.md2.framework.mD2.FlowLayoutPane +import de.wwu.md2.framework.mD2.impl.FlowLayoutPaneImpl +import de.wwu.md2.framework.mD2.impl.ListViewImpl +import de.wwu.md2.framework.mD2.ViewIcon +import de.wwu.md2.framework.mD2.ListViewLayoutParam class ActivityGen { @@ -258,10 +262,7 @@ class ActivityGen { @Override public Drawable getItemDrawable(int position) { - String activity_name=Md2ViewManager.getInstance().getActiveView().getTitle().toString(); - - return Md2ViewManager.getInstance().getActiveView().getDrawable(R.mipmap.ic_launcher); - + «println(generateIcons(rootViews))» } public int getActive(){ @@ -292,6 +293,52 @@ class ActivityGen { } ''' + def private static String generateIcons(Iterable rootViews){ + var String result = "switch(position){" + var viewnumber = 0; + + for (rv : rootViews) { + println(rv) + switch (rv) { + GridLayoutPaneImpl: { + for (rve : (rv as GridLayoutPaneImpl).params) { + if(rve instanceof ViewIcon){ + result += "\r\n case " + viewnumber + ":"; + result += "\r\n return Md2ViewManager.getInstance().getActiveView().getDrawable(R.drawable."+(rve as ViewIcon).value+");" + } + } + } + FlowLayoutPaneImpl: { + println("FlowLAyoutPane") + for (rve : (rv as FlowLayoutPaneImpl).params) { + if(rve instanceof ViewIcon){ + result += "\r\n case " + viewnumber + ":"; + result += "\r\n return Md2ViewManager.getInstance().getActiveView().getDrawable(R.drawable."+(rve as ViewIcon).value+");" + } + } + } + ListViewImpl: { + println("ListView gefunden" + rv); + for (rve : rv.params) { + println("RVE ListView:" + rve); + if(rve instanceof ViewIcon){ + result += "\r\n case " + viewnumber + ":"; + result += "\r\n return Md2ViewManager.getInstance().getActiveView().getDrawable(R.drawable."+(rve as ViewIcon).value+");" + } + } + } + default: { + println("Kein GridLayoutPAne") + } + } + + viewnumber++; + } + + result+="\r\ndefault:\r\n return Md2ViewManager.getInstance().getActiveView().getDrawable(R.mipmap.ic_launcher);}" + return result; + } + def static generateStartActivity(String mainPackage, Iterable startableWorkflowElements, Iterable entities)''' // generated in de.wwu.md2.framework.generator.android.wearable.controller.Activity.generateStartActivity() package «mainPackage»; @@ -397,6 +444,8 @@ class ActivityGen { «MD2AndroidLollipopUtil.generateImportAllWidgets» «MD2AndroidLollipopUtil.generateImportAllTypes» «MD2AndroidLollipopUtil.generateImportAllEventHandler» + + import de.uni_muenster.wi.md2library.controller.action.interfaces.Md2Action; «FOR viewElement: rv.eAllContents.toIterable» «IF viewElement instanceof ActionDrawer» @@ -527,7 +576,8 @@ class ActivityGen { @Override public boolean onMenuItemClick(MenuItem menuItem) { - + //TODO + return true; «FOR viewElement: rv.eAllContents.toIterable» «IF viewElement instanceof ActionDrawer» @@ -538,8 +588,9 @@ class ActivityGen { final int itemId = menuItem.getItemId(); switch(itemId) { + «var ElementCounter = 0» «FOR itemClickAction: viewElement.onItemClickAction» - case R.id.«itemClickAction.name»_item: + case R.id.«itemClickAction.name»_item«ElementCounter++»: ca = new «MD2AndroidLollipopUtil.getQualifiedNameAsString(itemClickAction, "_").toFirstUpper»_Action(); break; diff --git a/de.wwu.md2.framework/src/de/wwu/md2/framework/generator/android/wearable/controller/ApplicationGen.xtend b/de.wwu.md2.framework/src/de/wwu/md2/framework/generator/android/wearable/controller/ApplicationGen.xtend index 7f246d21..7fabd2ee 100644 --- a/de.wwu.md2.framework/src/de/wwu/md2/framework/generator/android/wearable/controller/ApplicationGen.xtend +++ b/de.wwu.md2.framework/src/de/wwu/md2/framework/generator/android/wearable/controller/ApplicationGen.xtend @@ -18,6 +18,8 @@ class ApplicationGen { import «Settings.MD2LIBRARY_TASKQUEUE_PACKAGE_NAME»; import «Settings.MD2LIBRARY_VIEWMANAGER_PACKAGE_NAME»; import «Settings.MD2LIBRARY_WIDGETREGISTRY_PACKAGE_NAME»; + import «Settings.MD2LIBRARY_PACKAGE»model.contentProvider.implementation.Polling; + public class «app.name.toFirstUpper» extends Application { @@ -40,6 +42,9 @@ class ApplicationGen { wr = Md2WidgetRegistry.getInstance(); context = getApplicationContext(); Controller.getInstance().run(); + Thread t = new Thread(new Polling(cpr)); + t.start(); + } public static Context getAppContext() { diff --git a/de.wwu.md2.framework/src/de/wwu/md2/framework/generator/android/wearable/model/ContentProviderGen.xtend b/de.wwu.md2.framework/src/de/wwu/md2/framework/generator/android/wearable/model/ContentProviderGen.xtend index 71436939..509e7a5b 100644 --- a/de.wwu.md2.framework/src/de/wwu/md2/framework/generator/android/wearable/model/ContentProviderGen.xtend +++ b/de.wwu.md2.framework/src/de/wwu/md2/framework/generator/android/wearable/model/ContentProviderGen.xtend @@ -249,8 +249,11 @@ import «Settings.MD2LIBRARY_PACKAGE»controller.eventhandler.implementation.Md2 public void newEntity(){ content = new «(content.entity as Entity).name»(); } - + public void update() { + System.out.println("single wurde geupdated"); + } } + '''} @@ -319,7 +322,10 @@ import de.uni_muenster.wi.md2library.model.contentProvider.implementation.Abstra } } - } + public void update() { + System.out.println("multi wurde geupdated"); + } + ''' } diff --git a/de.wwu.md2.framework/src/de/wwu/md2/framework/generator/android/wearable/model/EntityGen.xtend b/de.wwu.md2.framework/src/de/wwu/md2/framework/generator/android/wearable/model/EntityGen.xtend index 668bce30..6a4cfe3a 100644 --- a/de.wwu.md2.framework/src/de/wwu/md2/framework/generator/android/wearable/model/EntityGen.xtend +++ b/de.wwu.md2.framework/src/de/wwu/md2/framework/generator/android/wearable/model/EntityGen.xtend @@ -108,7 +108,7 @@ public class «entity.name.toFirstUpper» extends AbstractMd2Entity { @DatabaseTable(tableName = "«entity.name.toFirstLower»") public class «entity.name.toFirstUpper» implements Serializable,Md2Entity{ - @SerializedName("__internalId") +««« @SerializedName("__internalId") @DatabaseField(generatedId = true, columnName = "id") private long id; diff --git a/de.wwu.md2.framework/src/de/wwu/md2/framework/generator/android/wearable/view/LayoutGen.xtend b/de.wwu.md2.framework/src/de/wwu/md2/framework/generator/android/wearable/view/LayoutGen.xtend index bfc771e3..d84a34b5 100644 --- a/de.wwu.md2.framework/src/de/wwu/md2/framework/generator/android/wearable/view/LayoutGen.xtend +++ b/de.wwu.md2.framework/src/de/wwu/md2/framework/generator/android/wearable/view/LayoutGen.xtend @@ -37,7 +37,12 @@ import de.wwu.md2.framework.mD2.Action import de.wwu.md2.framework.mD2.ListView import de.wwu.md2.framework.mD2.IntegerInput - +import de.wwu.md2.framework.mD2.ActionDrawerParam +import de.wwu.md2.framework.mD2.ActionDrawerTitleParam +import de.wwu.md2.framework.mD2.impl.ActionDrawerImpl +import de.wwu.md2.framework.mD2.ViewIcon +import de.wwu.md2.framework.mD2.ViewIconActionDrawer +import java.util.List class LayoutGen { @@ -156,7 +161,7 @@ class LayoutGen { navElement.setAttribute("android:id", "@+id/navigation_drawer_"+rv.name) navElement.setAttribute("android:layout_height", "match_parent") navElement.setAttribute("android:layout_width", "match_parent") - navElement.setAttribute("android:background", "@android:color/holo_blue_bright") + navElement.setAttribute("android:background", "@color/PSWatchappSemiTransparentDarkBlue") //create WearableRecyclerView für Listendarstellung var Element listElement = doc.createElement("android.support.wearable.view.WearableRecyclerView") listElement.setAttribute("android:id","@+id/wearable_recycler_view_"+rv.name) @@ -189,7 +194,7 @@ class LayoutGen { navElement.setAttribute("android:layout_height", "match_parent") navElement.setAttribute("android:layout_width", "match_parent") - navElement.setAttribute("android:background", "@color/PSWatchappSemiTransperentDarkBlue") + navElement.setAttribute("android:background", "@color/PSWatchappSemiTransparentDarkBlue") //create ActionDrawer var Element drawerElement = doc.createElement("android.support.wearable.view.drawer.WearableActionDrawer") @@ -197,7 +202,7 @@ class LayoutGen { drawerElement.setAttribute("android:layout_height", "match_parent") drawerElement.setAttribute("android:layout_width", "match_parent") drawerElement.setAttribute("app:action_menu", "@menu/" + rv.name.toLowerCase + "_action_drawer_menu") - + drawerElement.setAttribute("android:theme","@style/PSWatchappActionDrawer") // create BoxInsetLayout var Element boxElement = doc.createElement("android.support.wearable.view.BoxInsetLayout") @@ -297,20 +302,47 @@ class LayoutGen { rootElement.setAttribute("android:layout_width", "match_parent") rootElement.setAttribute("tools:deviceIds", "wear") + val ActionsIcons = newArrayList() + val ActionTitel = newArrayList() + //Generate menu items in the menu for(viewElement: rv.eAllContents.toIterable) { if(viewElement instanceof ActionDrawer) { + //Titel für die Beschriftung im ActionDrawer + var ActionDrawerTitel = ""; + var iconAction = "ic_dialog_info"; //default Icon + + for (acd : (viewElement as ActionDrawerImpl).params) { + if(acd instanceof ActionDrawerTitleParam){ + for (title : acd.values) { + ActionTitel.add(title.toString); + } + } + if(acd instanceof ViewIconActionDrawer){ + for (icon : acd.values) { + iconAction = icon.toString; //falls ein anderes Icon angegeben wurde wird dies verwendet + ActionsIcons.add(iconAction); + } + } + + } + + if(!(viewElement.onItemClickAction === null)) { + var ElementCounter = 0; for(itemClickAction: viewElement.onItemClickAction) { + println("ActionDrawer itemClickAction:" + itemClickAction) var Element item = doc.createElement("item") - item.setAttribute("android:id", "@+id/" + itemClickAction.name + "_item") - item.setAttribute("android:icon", "@android:drawable/ic_dialog_info") // TODO: Icons auswählen können - item.setAttribute("android:title", MD2AndroidLollipopUtil.getQualifiedNameAsString(itemClickAction, "").toFirstUpper) + item.setAttribute("android:id", ("@+id/" + (itemClickAction.name + "_item" + (ElementCounter++).toString))) + item.setAttribute("android:icon", ("@android:drawable/" + ActionsIcons.get(ElementCounter-1))) // TODO: Icons auswählen können + item.setAttribute("android:title", ActionTitel.get(ElementCounter-1));//MD2AndroidLollipopUtil.getQualifiedNameAsString(itemClickAction, "").toFirstUpper) rootElement.appendChild(item) } } } } + + //Append doc.appendChild(rootElement) diff --git a/de.wwu.md2.framework/src/de/wwu/md2/framework/generator/android/wearable/view/ValueGen.xtend b/de.wwu.md2.framework/src/de/wwu/md2/framework/generator/android/wearable/view/ValueGen.xtend index c18a4353..ff28d883 100644 --- a/de.wwu.md2.framework/src/de/wwu/md2/framework/generator/android/wearable/view/ValueGen.xtend +++ b/de.wwu.md2.framework/src/de/wwu/md2/framework/generator/android/wearable/view/ValueGen.xtend @@ -15,7 +15,6 @@ import de.wwu.md2.framework.mD2.ContentContainer import de.wwu.md2.framework.mD2.GridLayoutPane import de.wwu.md2.framework.mD2.FlowLayoutPane import org.apache.log4j.Layout -import de.wwu.md2.framework.mD2.GridLayoutPaneIcon class ValueGen { @@ -143,7 +142,7 @@ class ValueGen { + + ''' @@ -174,7 +178,7 @@ class ValueGen { #0d568f #00a2d3 #ff0909 - #bd00a2d3 + #bd00a2d3 ''' } \ No newline at end of file