From 0ea6412d57057bf87f9390c9598b692cc48b3545 Mon Sep 17 00:00:00 2001 From: alexj2510 Date: Sun, 16 Jul 2017 21:46:21 +0200 Subject: [PATCH] =?UTF-8?q?icons=20vorl=C3=A4ugi=20aus=20navdrawer=20entfe?= =?UTF-8?q?rnt=20(konflikte=20mit=20listview),=20integerinput=20und=20korr?= =?UTF-8?q?ekte=20synchronization=20zwischen=20widgets=20und=20cps?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wearable/controller/ActivityGen.xtend | 20 ++------ .../wearable/model/ContentProviderGen.xtend | 43 +++++++++++------ .../android/wearable/view/LayoutGen.xtend | 46 +++++++++++++++++++ .../android/wearable/view/ValueGen.xtend | 4 +- 4 files changed, 84 insertions(+), 29 deletions(-) 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 fc2fc98d..a41e655e 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 @@ -34,7 +34,7 @@ import de.wwu.md2.framework.mD2.AttrSensorAxis import java.util.LinkedHashSet import java.util.LinkedList import java.util.Map - +import de.wwu.md2.framework.mD2.IntegerInput class ActivityGen { @@ -258,21 +258,9 @@ class ActivityGen { @Override public Drawable getItemDrawable(int position) { String activity_name=Md2ViewManager.getInstance().getActiveView().getTitle().toString(); - switch(position){ - «var viewnumber = 0» - «FOR rv : rootViews» - «FOR rve : (rv as GridLayoutPaneImpl).params» - «IF rve instanceof GridLayoutPaneIcon» - case «viewnumber»: - return Md2ViewManager.getInstance().getActiveView().getDrawable(R.drawable.«(rve as GridLayoutPaneIcon).value»); - «ENDIF» - «ENDFOR» - «IF viewnumber++ == 0» - «ENDIF» - «ENDFOR» - default: + return Md2ViewManager.getInstance().getActiveView().getDrawable(R.mipmap.ic_launcher); - } + } public int getActive(){ @@ -589,6 +577,8 @@ class ActivityGen { return "Md2Label" TextInput: return "Md2TextInput" + IntegerInput: + return "Md2TextInput" default: return "" } } 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 3c110757..4a0874d2 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 @@ -135,7 +135,9 @@ import «Settings.MD2LIBRARY_PACKAGE»controller.eventhandler.implementation.Md2 public Md2Type getValue(String attribute) { switch (attribute){ «FOR attribute: (content.entity as Entity).attributes» - case "«attribute.name»": return + case "«attribute.name»": + if(((«(content.entity as Entity).name»)content).get«attribute.name.toFirstUpper»() != null){ + return «IF attribute.type instanceof ReferencedType && !attribute.type.many» ((«(content.entity as Entity).name»)content).get«attribute.name.toFirstUpper»(); «ELSE» @@ -143,6 +145,7 @@ import «Settings.MD2LIBRARY_PACKAGE»controller.eventhandler.implementation.Md2 Md2List<«EntityGen.getMd2TypeStringForAttributeType(attribute.type)»> «ELSE» «EntityGen.getMd2TypeStringForAttributeType(attribute.type)»«ENDIF»(((«(content.entity as Entity).name»)content).get«attribute.name.toFirstUpper»()); «ENDIF» + } else { return null;} «ENDFOR» default:return null; } @@ -155,24 +158,38 @@ import «Settings.MD2LIBRARY_PACKAGE»controller.eventhandler.implementation.Md2 } // set only if value is different to current value - if ((this.getValue(name) == null && value != null) || !this.getValue(name).equals(value)) { + if ((this.getValue(name) == null && value != null) || value != null && !this.getValue(name).toString().equals(value.toString())) { switch (name){ «FOR attribute: (content.entity as Entity).attributes» - case "«attribute.name»": ((«(content.entity as Entity).name»)content).set«attribute.name.toFirstUpper»(((«IF attribute.type.many» - Md2List«ELSE»«getMd2TypeStringForAttributeType(attribute.type)»«ENDIF») value)«IF attribute.type instanceof ReferencedType && !attribute.type.many» - ); + case "«attribute.name»": + «IF !(attribute.type instanceof StringType)» + + // Umgang mit anderen Datentypen hier einfügen - derzeit kein Support für Listen innerhalb v. Entities + // angenommen wird entweder Md2String oder passender Md2Type als value + + «IF (attribute.type instanceof IntegerType)» + if(!(value instanceof «getMd2TypeStringForAttributeType(attribute.type)»)){ + if(!(value.getString().toString().isEmpty())) { + ((«(content.entity as Entity).name»)content).set«attribute.name.toFirstUpper»(Integer.parseInt(value.getString().toString())); + notifyChangeHandler(name); + } + } else { + ((«(content.entity as Entity).name»)content).set«attribute.name.toFirstUpper»(((«getMd2TypeStringForAttributeType(attribute.type)»)value).getPlatformValue()); + } + break; + «ENDIF» + «ELSE» + ((«(content.entity as Entity).name»)content).set«attribute.name.toFirstUpper»(((«IF attribute.type.many» + Md2List«ELSE»«getMd2TypeStringForAttributeType(attribute.type)»«ENDIF») value)«IF attribute.type instanceof ReferencedType && !attribute.type.many» + ); «ELSEIF attribute.type.many» - .getContents()); + .getContents()); «ELSE».getPlatformValue());«ENDIF» - break; + notifyChangeHandler(name); + break; + «ENDIF» «ENDFOR» } - - - Md2OnAttributeChangedHandler handler = this.attributeChangedEventHandlers.get(name); - if (handler != null) { - handler.onChange(name); - } } } 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 775e4a22..ece7fe53 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 @@ -31,6 +31,7 @@ import org.eclipse.xtext.naming.DefaultDeclarativeQualifiedNameProvider import org.w3c.dom.Document import org.w3c.dom.Element import de.wwu.md2.framework.mD2.ListView +import de.wwu.md2.framework.mD2.IntegerInput class LayoutGen { @@ -276,6 +277,9 @@ class LayoutGen { TextInput: { newElement = createTextInputElement(doc, viewElement) } + IntegerInput: { + newElement = createIntegerInputElement(doc, viewElement) + } Label: { if(viewElement.name.startsWith("_title")) { return } // Skip title label --> landet das irgendwo anders? newElement = createLabelElement(doc, viewElement) @@ -442,4 +446,46 @@ class LayoutGen { return labelElement } + protected static def createIntegerInputElement(Document doc, IntegerInput integerInput) { + val integerInputElement = doc.createElement(Settings.MD2LIBRARY_VIEW_TEXTINPUT) + val qnp = new DefaultDeclarativeQualifiedNameProvider + val qualifiedName = qnp.getFullyQualifiedName(integerInput).toString("_") + + // id + integerInputElement.setAttribute("android:id", "@id/" + qualifiedName) + + + integerInputElement.setAttribute("android:layout_width", "match_parent") + + integerInputElement.setAttribute("android:layout_height", "wrap_content") + integerInputElement.setAttribute("android:layout_gravity", "fill_horizontal") + + integerInputElement.setAttribute("android:hint", "@string/" + qualifiedName + "_tooltip") + + integerInputElement.setAttribute("android:text", integerInput.defaultValue.toString()) + + // disabled + var isEnabled = true + if (integerInput.isDisabled) + isEnabled = false + + integerInputElement.setAttribute("android:enabled", String.valueOf(isEnabled)) + + integerInputElement.setAttribute("android:inputType", "number"); + + integerInputElement.setAttribute("android:imeOptions","actionDone") + + // type ??? + // switch textInput { + // case textInput.type == TextInputType.PASSWORD: + // textInputElement.setAttribute("android:inputType", "textPassword") + // case textInput.type == TextInputType.TEXTAREA: + // textInputElement.setAttribute("android:inputType", + // "text|textMultiLine") + // default: + // textInputElement.setAttribute("android:inputType", "text") + //} + + return integerInputElement + } } \ No newline at end of file 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 eb6924d2..079c4796 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 @@ -62,7 +62,8 @@ class ValueGen { var String icon; var String view; for(rCe : rootContainerElements) - { + { + if(rCe instanceof GridLayoutPane){ for(param : (rCe as GridLayoutPane).params) { if(param instanceof GridLayoutPaneIcon){ @@ -71,6 +72,7 @@ class ValueGen { view = rCe.name } } + } } println("" + icon + "") return "" + icon + "";