Skip to content

Commit

Permalink
icons vorläugi aus navdrawer entfernt (konflikte mit listview),
Browse files Browse the repository at this point in the history
integerinput und korrekte synchronization zwischen widgets und cps
  • Loading branch information
alexj2510 committed Jul 16, 2017
1 parent 9dd6ce2 commit 0ea6412
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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(){
Expand Down Expand Up @@ -589,6 +577,8 @@ class ActivityGen {
return "Md2Label"
TextInput:
return "Md2TextInput"
IntegerInput:
return "Md2TextInput"
default: return ""
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,17 @@ 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»
new «IF attribute.type.many»
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;
}
Expand All @@ -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);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand All @@ -71,6 +72,7 @@ class ValueGen {
view = rCe.name
}
}
}
}
println("<string name=\"" + view + "\">" + icon + "</string>")
return "<string name=\"" + "icon_" + view + "\">" + icon + "</string>";
Expand Down

0 comments on commit 0ea6412

Please sign in to comment.