[DEV] update widget

This commit is contained in:
Edouard DUPIN 2022-03-20 18:59:52 +01:00
parent f29254547d
commit 457f81f1f2
5 changed files with 105 additions and 84 deletions

2
.gitignore vendored
View File

@ -32,6 +32,8 @@ build.number
/.settings/
/junit/
/target/
/__pycache__/
*.pdfd
*.dbc

View File

@ -21,4 +21,15 @@
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
</natures>
<filteredResources>
<filter>
<id>1646149232192</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>

View File

@ -14,4 +14,15 @@
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
<filteredResources>
<filter>
<id>1646149232193</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>

View File

@ -11,8 +11,6 @@ import org.atriasoft.ewol.DrawProperty;
import org.atriasoft.ewol.Gravity;
import org.atriasoft.ewol.internal.Log;
import org.atriasoft.ewol.object.EwolObject;
import org.atriasoft.exml.model.XmlElement;
import org.atriasoft.exml.model.XmlNode;
/*
* @ingroup ewolWidgetGroup
@ -78,50 +76,50 @@ public class Container extends Widget {
return null;
}
@Override
public boolean loadXML(final XmlElement node) {
if (node == null) {
return false;
}
// parse generic properties:
super.loadXML(node);
// remove previous element:
subWidgetRemove();
// parse all the elements:
for (XmlNode it : node.getNodes()) {
if (!it.isElement()) {
// trash here all that is not element
continue;
}
XmlElement pNode = it.toElement();
String widgetName = pNode.getValue();
Log.verbose("[" + getId() + "] t=" + getClass().getCanonicalName() + " Load node name : '" + widgetName + "'");
if (!getWidgetManager().exist(widgetName)) {
Log.error("Unknown basic node='" + widgetName + "' not in : [" + getWidgetManager().list() + "]");
continue;
}
if (getSubWidget() != null) {
Log.error("Can only have one subWidget ??? node='" + widgetName + "'");
continue;
}
Log.debug("try to create subwidget : '" + widgetName + "'");
Widget tmpWidget = getWidgetManager().create(widgetName, pNode);
if (tmpWidget == null) {
Log.error("Can not create the widget : '" + widgetName + "'");
continue;
}
// add widget :
setSubWidget(tmpWidget);
if (!tmpWidget.loadXML(pNode)) {
Log.error("can not load widget properties : '" + widgetName + "'");
return false;
}
}
if (node.getNodes().size() != 0 && this.subWidget == null) {
Log.warning("Load container with no data inside");
}
return true;
}
// @Override
// public boolean loadXML(final XmlElement node) {
// if (node == null) {
// return false;
// }
// // parse generic properties:
// super.loadXML(node);
// // remove previous element:
// subWidgetRemove();
// // parse all the elements:
// for (XmlNode it : node.getNodes()) {
// if (!it.isElement()) {
// // trash here all that is not element
// continue;
// }
// XmlElement pNode = it.toElement();
// String widgetName = pNode.getValue();
// Log.verbose("[" + getId() + "] t=" + getClass().getCanonicalName() + " Load node name : '" + widgetName + "'");
// if (!getWidgetManager().exist(widgetName)) {
// Log.error("Unknown basic node='" + widgetName + "' not in : [" + getWidgetManager().list() + "]");
// continue;
// }
// if (getSubWidget() != null) {
// Log.error("Can only have one subWidget ??? node='" + widgetName + "'");
// continue;
// }
// Log.debug("try to create subwidget : '" + widgetName + "'");
// Widget tmpWidget = getWidgetManager().create(widgetName, pNode);
// if (tmpWidget == null) {
// Log.error("Can not create the widget : '" + widgetName + "'");
// continue;
// }
// // add widget :
// setSubWidget(tmpWidget);
// if (!tmpWidget.loadXML(pNode)) {
// Log.error("can not load widget properties : '" + widgetName + "'");
// return false;
// }
// }
// if (node.getNodes().size() != 0 && this.subWidget == null) {
// Log.warning("Load container with no data inside");
// }
// return true;
// }
@Override
public void onChangeSize() {

View File

@ -1,9 +1,6 @@
package org.atriasoft.ewol.widget;
import java.lang.ref.WeakReference;
import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
import java.util.Map;
import org.atriasoft.ewol.internal.Log;
import org.atriasoft.exml.model.XmlElement;
@ -89,18 +86,18 @@ public class WidgetManager {
* @param klass class interface
*/
public void addWidgetCreator(final String name, final Class<?> klass) throws Exception {
if (klass == null) {
throw new Exception("Can not add widget creator without specified class.");
}
//Keep name in lower case :
final String nameLower = name.toLowerCase();
final Class<?> it = WidgetXmlFactory..creatorList.get(nameLower);
if (it != null) {
Log.warning("Replace Creator of a specify widget : " + nameLower);
return;
}
this.creatorList.put(nameLower, klass);
// TODO check constructors ...
// if (klass == null) {
// throw new Exception("Can not add widget creator without specified class.");
// }
// //Keep name in lower case :
// final String nameLower = name.toLowerCase();
// final Class<?> it = WidgetXmlFactory.creatorList.get(nameLower);
// if (it != null) {
// Log.warning("Replace Creator of a specify widget : " + nameLower);
// return;
// }
// this.creatorList.put(nameLower, klass);
// // TODO check constructors ...
}
/**
@ -110,33 +107,33 @@ public class WidgetManager {
*/
public Widget create(final String name) {
final String nameLower = name.toLowerCase();
final Class<?> it = this.creatorList.get(nameLower);
if (it != null) {
try {
return (Widget) it.getConstructor().newInstance();
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
}
}
// final Class<?> it = this.creatorList.get(nameLower);
// if (it != null) {
// try {
// return (Widget) it.getConstructor().newInstance();
// } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// return null;
// }
// }
Log.warning("try to create an UnExistant widget : " + nameLower);
return null;
}
public Widget create(final String name, final XmlElement node) {
final String nameLower = name.toLowerCase();
final Class<?> it = this.creatorList.get(nameLower);
if (it != null) {
try {
Widget tmp = (Widget) it.getConstructor().newInstance();
tmp.loadXML(node);
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
}
}
// final Class<?> it = this.creatorList.get(nameLower);
// if (it != null) {
// try {
// Widget tmp = (Widget) it.getConstructor().newInstance();
// tmp.loadXML(node);
// } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// return null;
// }
// }
Log.warning("try to create an UnExistant widget : " + nameLower);
return null;
}
@ -148,7 +145,8 @@ public class WidgetManager {
* @return false The Widget Does NOT exist.
*/
public boolean exist(final String name) {
return this.creatorList.get(name.toLowerCase()) != null;
// return this.creatorList.get(name.toLowerCase()) != null;
return false;
}
/**
@ -259,7 +257,8 @@ public class WidgetManager {
* @return Separate with ',' string list.
*/
public String list() {
return this.creatorList.keySet().toString();
//return this.creatorList.keySet().toString();
return "";
}
/**