|
@@ -232,6 +232,15 @@ Zeichnung* UIMLTextField::parseElement(
|
|
|
{
|
|
|
TextFeld* t = generalFactory.getFactory().createTextFeld(
|
|
|
generalFactory.getFactory().initParam);
|
|
|
+ updateElement(element, *t, generalFactory);
|
|
|
+ return t;
|
|
|
+}
|
|
|
+
|
|
|
+bool Framework::UIMLTextField::updateElement(
|
|
|
+ XML::Element& element, Zeichnung& z, UIMLContainer& generalFactory)
|
|
|
+{
|
|
|
+ TextFeld* t = dynamic_cast<TextFeld*>(&z);
|
|
|
+ if (!t) return false;
|
|
|
if (element.hasAttribute("style"))
|
|
|
{
|
|
|
Text style = element.getAttributeValue("style");
|
|
@@ -243,9 +252,13 @@ Zeichnung* UIMLTextField::parseElement(
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- t->addStyle(TextFeld::Style::TextFeld);
|
|
|
+ TextFeld* tmp = generalFactory.getFactory().createTextFeld(
|
|
|
+ generalFactory.getFactory().initParam);
|
|
|
+ tmp->addStyle(TextFeld::Style::TextFeld);
|
|
|
+ t->setStyle(tmp->getStyles());
|
|
|
+ tmp->release();
|
|
|
}
|
|
|
- return t;
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
void UIMLTextField::layout(XML::Element& element,
|
|
@@ -302,6 +315,15 @@ Zeichnung* UIMLButton::parseElement(
|
|
|
{
|
|
|
Knopf* k = generalFactory.getFactory().createKnopf(
|
|
|
generalFactory.getFactory().initParam);
|
|
|
+ updateElement(element, *k, generalFactory);
|
|
|
+ return k;
|
|
|
+}
|
|
|
+
|
|
|
+bool Framework::UIMLButton::updateElement(
|
|
|
+ XML::Element& element, Zeichnung& z, UIMLContainer& generalFactory)
|
|
|
+{
|
|
|
+ Knopf* k = dynamic_cast<Knopf*>(&z);
|
|
|
+ if (!k) return false;
|
|
|
if (element.hasAttribute("style"))
|
|
|
{
|
|
|
Text style = element.getAttributeValue("style");
|
|
@@ -311,7 +333,14 @@ Zeichnung* UIMLButton::parseElement(
|
|
|
}
|
|
|
k->setStyle((int)style);
|
|
|
}
|
|
|
- return k;
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Knopf* tmp = generalFactory.getFactory().createKnopf(
|
|
|
+ generalFactory.getFactory().initParam);
|
|
|
+ k->setStyle(tmp->getStyles());
|
|
|
+ tmp->release();
|
|
|
+ }
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
void UIMLButton::layout(XML::Element& element,
|
|
@@ -342,6 +371,15 @@ Zeichnung* UIMLCheck::parseElement(
|
|
|
{
|
|
|
KontrollKnopf* k = generalFactory.getFactory().createKontrollKnopf(
|
|
|
generalFactory.getFactory().initParam);
|
|
|
+ updateElement(element, *k, generalFactory);
|
|
|
+ return k;
|
|
|
+}
|
|
|
+
|
|
|
+bool Framework::UIMLCheck::updateElement(
|
|
|
+ XML::Element& element, Zeichnung& z, UIMLContainer& generalFactory)
|
|
|
+{
|
|
|
+ KontrollKnopf* k = dynamic_cast<KontrollKnopf*>(&z);
|
|
|
+ if (!k) return false;
|
|
|
if (element.hasAttribute("style"))
|
|
|
{
|
|
|
Text style = element.getAttributeValue("style");
|
|
@@ -351,7 +389,14 @@ Zeichnung* UIMLCheck::parseElement(
|
|
|
}
|
|
|
k->setStyle((int)style);
|
|
|
}
|
|
|
- return k;
|
|
|
+ else
|
|
|
+ {
|
|
|
+ KontrollKnopf* tmp = generalFactory.getFactory().createKontrollKnopf(
|
|
|
+ generalFactory.getFactory().initParam);
|
|
|
+ k->setStyle(tmp->getStyles());
|
|
|
+ tmp->release();
|
|
|
+ }
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
void UIMLCheck::layout(XML::Element& element,
|
|
@@ -385,6 +430,15 @@ Zeichnung* UIMLText::parseElement(
|
|
|
{
|
|
|
TextFeld* t = generalFactory.getFactory().createTextFeld(
|
|
|
generalFactory.getFactory().initParam);
|
|
|
+ updateElement(element, *t, generalFactory);
|
|
|
+ return t;
|
|
|
+}
|
|
|
+
|
|
|
+bool Framework::UIMLText::updateElement(
|
|
|
+ XML::Element& element, Zeichnung& z, UIMLContainer& generalFactory)
|
|
|
+{
|
|
|
+ TextFeld* t = dynamic_cast<TextFeld*>(&z);
|
|
|
+ if (!t) return false;
|
|
|
if (element.hasAttribute("style"))
|
|
|
{
|
|
|
Text style = element.getAttributeValue("style");
|
|
@@ -396,9 +450,13 @@ Zeichnung* UIMLText::parseElement(
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- t->addStyle(TextFeld::Style::Text);
|
|
|
+ TextFeld* tmp = generalFactory.getFactory().createTextFeld(
|
|
|
+ generalFactory.getFactory().initParam);
|
|
|
+ tmp->addStyle(TextFeld::Style::Text);
|
|
|
+ t->setStyle(tmp->getStyles());
|
|
|
+ tmp->release();
|
|
|
}
|
|
|
- return t;
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
void UIMLText::layout(XML::Element& element,
|
|
@@ -455,6 +513,15 @@ Zeichnung* UIMLTextArea::parseElement(
|
|
|
{
|
|
|
TextFeld* t = generalFactory.getFactory().createTextFeld(
|
|
|
generalFactory.getFactory().initParam);
|
|
|
+ updateElement(element, *t, generalFactory);
|
|
|
+ return t;
|
|
|
+}
|
|
|
+
|
|
|
+bool Framework::UIMLTextArea::updateElement(
|
|
|
+ XML::Element& element, Zeichnung& z, UIMLContainer& generalFactory)
|
|
|
+{
|
|
|
+ TextFeld* t = dynamic_cast<TextFeld*>(&z);
|
|
|
+ if (!t) return false;
|
|
|
if (element.hasAttribute("style"))
|
|
|
{
|
|
|
Text style = element.getAttributeValue("style");
|
|
@@ -466,9 +533,13 @@ Zeichnung* UIMLTextArea::parseElement(
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- t->addStyle(TextFeld::Style::TextGebiet);
|
|
|
+ TextFeld* tmp = generalFactory.getFactory().createTextFeld(
|
|
|
+ generalFactory.getFactory().initParam);
|
|
|
+ tmp->addStyle(TextFeld::Style::TextGebiet);
|
|
|
+ t->setStyle(tmp->getStyles());
|
|
|
+ tmp->release();
|
|
|
}
|
|
|
- return t;
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
void UIMLTextArea::layout(XML::Element& element,
|
|
@@ -528,7 +599,18 @@ Zeichnung* UIMLTable::parseElement(
|
|
|
{
|
|
|
ObjTabelle* t = generalFactory.getFactory().createObjTabelle(
|
|
|
generalFactory.getFactory().initParam);
|
|
|
+ updateElement(element, *t, generalFactory);
|
|
|
+ return t;
|
|
|
+}
|
|
|
+
|
|
|
+DLLEXPORT bool Framework::UIMLTable::updateElement(
|
|
|
+ XML::Element& element, Zeichnung& z, UIMLContainer& generalFactory)
|
|
|
+{
|
|
|
+ ObjTabelle* t = dynamic_cast<ObjTabelle*>(&z);
|
|
|
+ if (!t) return false;
|
|
|
int index = 0;
|
|
|
+ int linePos = 0;
|
|
|
+ int numCols = 0;
|
|
|
for (auto i = element.getChilds(); i; i++)
|
|
|
{
|
|
|
Text id;
|
|
@@ -541,18 +623,51 @@ Zeichnung* UIMLTable::parseElement(
|
|
|
}
|
|
|
if (i->getName().istGleich("tr"))
|
|
|
{
|
|
|
- t->addZeile(id);
|
|
|
- Text line = id;
|
|
|
+ if (t->getZeilenNummer(id) == -1) t->addZeile(id);
|
|
|
+ t->setZeilePosition(id, linePos);
|
|
|
int c = 1;
|
|
|
for (auto j = i->getChilds(); j; j++)
|
|
|
{
|
|
|
- Zeichnung* z
|
|
|
- = generalFactory.parseElement(*i.val(), generalFactory);
|
|
|
if (t->getSpaltenAnzahl() < c) t->addSpalte(Text(c - 1));
|
|
|
- if (z) t->setZeichnungZ(Text(c - 1), line, z);
|
|
|
+ if (numCols < c) numCols = c;
|
|
|
+ Zeichnung* z = t->zZeichnung(Text(c - 1), id);
|
|
|
+ if (!z
|
|
|
+ || !generalFactory.updateElement(
|
|
|
+ element, *z, generalFactory))
|
|
|
+ {
|
|
|
+ if (z) generalFactory.removeZeichnung(*z);
|
|
|
+ z = generalFactory.parseElement(*i.val(), generalFactory);
|
|
|
+ if (z) t->setZeichnungZ(Text(c - 1), id, z);
|
|
|
+ }
|
|
|
c++;
|
|
|
}
|
|
|
}
|
|
|
+ linePos++;
|
|
|
+ }
|
|
|
+ for (int i = 0; i < t->getZeilenAnzahl(); i++)
|
|
|
+ { // remove all lines that are not in the xml
|
|
|
+ if (!element.selectChildsByName("tr")
|
|
|
+ .whereAttributeEquals("id", *t->zZeilenName(i))
|
|
|
+ .exists())
|
|
|
+ {
|
|
|
+ for (int j = 0; j < t->getSpaltenAnzahl(); j++)
|
|
|
+ {
|
|
|
+ Zeichnung* z = t->zZeichnung(j, i);
|
|
|
+ if (z) generalFactory.removeZeichnung(*z);
|
|
|
+ }
|
|
|
+ t->removeZeile(i);
|
|
|
+ i--;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (int i = numCols; i < t->getSpaltenAnzahl(); i++)
|
|
|
+ { // remove all columns that are not in the xml
|
|
|
+ for (int j = 0; j < t->getZeilenAnzahl(); j++)
|
|
|
+ {
|
|
|
+ Zeichnung* z = t->zZeichnung(i, j);
|
|
|
+ if (z) generalFactory.removeZeichnung(*z);
|
|
|
+ }
|
|
|
+ t->removeSpalte(i);
|
|
|
+ i--;
|
|
|
}
|
|
|
if (element.hasAttribute("style"))
|
|
|
{
|
|
@@ -563,7 +678,14 @@ Zeichnung* UIMLTable::parseElement(
|
|
|
}
|
|
|
t->setStyle((int)style);
|
|
|
}
|
|
|
- return t;
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ObjTabelle* tmp = generalFactory.getFactory().createObjTabelle(
|
|
|
+ generalFactory.getFactory().initParam);
|
|
|
+ t->setStyle(tmp->getStyles());
|
|
|
+ tmp->release();
|
|
|
+ }
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
void UIMLTable::layout(XML::Element& element,
|
|
@@ -613,6 +735,40 @@ Zeichnung* UIMLFrame::parseElement(
|
|
|
{
|
|
|
Fenster* f = generalFactory.getFactory().createFenster(
|
|
|
generalFactory.getFactory().initParam);
|
|
|
+ updateElement(element, *f, generalFactory);
|
|
|
+ return f;
|
|
|
+}
|
|
|
+
|
|
|
+bool Framework::UIMLFrame::updateElement(
|
|
|
+ XML::Element& element, Zeichnung& z, UIMLContainer& generalFactory)
|
|
|
+{
|
|
|
+ Fenster* f = dynamic_cast<Fenster*>(&z);
|
|
|
+ if (!f) return false;
|
|
|
+ for (auto member = f->getMembers().begin(); member; member++)
|
|
|
+ { // remove all members that are not in the xml
|
|
|
+ if (!element
|
|
|
+ .selectChildsByAttribute(
|
|
|
+ "id", generalFactory.getZeichnungId(*member.val()))
|
|
|
+ .exists())
|
|
|
+ {
|
|
|
+ member.remove();
|
|
|
+ f->setRender();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ int index = 0;
|
|
|
+ for (auto i = element.getChilds(); i; i++)
|
|
|
+ {
|
|
|
+ Text id = element.getAttributeValue("id");
|
|
|
+ Zeichnung* z = generalFactory.zZeichnungById(id);
|
|
|
+ if (!id.getLength() || !z || f->getMembers().indexOf(z) < 0
|
|
|
+ || !generalFactory.updateElement(*i.val(), *z, generalFactory))
|
|
|
+ {
|
|
|
+ if (z) generalFactory.removeZeichnung(*z);
|
|
|
+ z = generalFactory.parseElement(*i.val(), generalFactory);
|
|
|
+ if (z) f->addMember(z);
|
|
|
+ }
|
|
|
+ if (z) f->setMemberIndex(z, index++);
|
|
|
+ }
|
|
|
if (element.hasAttribute("style"))
|
|
|
{
|
|
|
Text style = element.getAttributeValue("style");
|
|
@@ -622,12 +778,14 @@ Zeichnung* UIMLFrame::parseElement(
|
|
|
}
|
|
|
f->setStyle((int)style);
|
|
|
}
|
|
|
- for (auto i = element.getChilds(); i; i++)
|
|
|
+ else
|
|
|
{
|
|
|
- Zeichnung* z = generalFactory.parseElement(*i.val(), generalFactory);
|
|
|
- if (z) f->addMember(z);
|
|
|
+ Fenster* tmp = generalFactory.getFactory().createFenster(
|
|
|
+ generalFactory.getFactory().initParam);
|
|
|
+ f->setStyle(tmp->getStyles());
|
|
|
+ tmp->release();
|
|
|
}
|
|
|
- return f;
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
void UIMLFrame::layout(XML::Element& element,
|
|
@@ -762,12 +920,14 @@ bool UIMLView::isKnownElement(XML::Element* zElement)
|
|
|
// uiml: Ein xml element gemät des ksg uiml standarts
|
|
|
void UIMLView::setUIML(XML::Element* uiml)
|
|
|
{
|
|
|
- if (dom) dom->release();
|
|
|
- dom = uiml;
|
|
|
- members->leeren();
|
|
|
- nextId = 0;
|
|
|
if (dom)
|
|
|
- {
|
|
|
+ { // update dom and members
|
|
|
+ dom = uiml;
|
|
|
+ update();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ { // initialize dom and members
|
|
|
+ dom = uiml;
|
|
|
for (auto i = dom->getChilds(); i; i++)
|
|
|
{
|
|
|
Zeichnung* z = parseElement(*i.val(), *this);
|
|
@@ -797,6 +957,21 @@ Zeichnung* UIMLView::getZeichnungById(const char* id)
|
|
|
return members->get(id, textLength(id));
|
|
|
}
|
|
|
|
|
|
+void Framework::UIMLView::update()
|
|
|
+{
|
|
|
+ for (auto i = dom->getChilds(); i; i++)
|
|
|
+ {
|
|
|
+ Text id = i->getAttributeValue("id");
|
|
|
+ Zeichnung* z = zZeichnungById(id);
|
|
|
+ if (!id.getLength() || !z || !updateElement(*i.val(), *z, *this))
|
|
|
+ {
|
|
|
+ if (z) removeZeichnung(*z);
|
|
|
+ z = parseElement(*i.val(), *this);
|
|
|
+ if (z) z->release();
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
// aktualisiert größe und position aller Zeichnungen gemäß den spezifikationen
|
|
|
// in UIML
|
|
|
void UIMLView::layout()
|
|
@@ -1042,14 +1217,31 @@ Zeichnung* UIMLView::parseElement(
|
|
|
}
|
|
|
}
|
|
|
if (z)
|
|
|
+ {
|
|
|
members->set(
|
|
|
id, id.getLength(), dynamic_cast<Zeichnung*>(z->getThis()));
|
|
|
+ idList.add(new Text(id));
|
|
|
+ memberList.add(z);
|
|
|
+ }
|
|
|
}
|
|
|
else
|
|
|
z->getThis();
|
|
|
return z;
|
|
|
}
|
|
|
|
|
|
+bool Framework::UIMLView::updateElement(
|
|
|
+ XML::Element& element, Zeichnung& z, UIMLContainer& generalFactory)
|
|
|
+{
|
|
|
+ for (UIMLElement* e : knownElements)
|
|
|
+ {
|
|
|
+ if (e->isApplicableFor(element))
|
|
|
+ {
|
|
|
+ return e->updateElement(element, z, *this);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
void UIMLView::layout(XML::Element& element,
|
|
|
Zeichnung& z,
|
|
|
int pWidth,
|
|
@@ -1066,8 +1258,26 @@ void UIMLView::layout(XML::Element& element,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-DLLEXPORT bool Framework::UIMLView::registerZeichnung(
|
|
|
- const char* id, Zeichnung* z)
|
|
|
+Text Framework::UIMLView::getZeichnungId(Zeichnung& z)
|
|
|
+{
|
|
|
+ int index = memberList.getWertIndex(&z);
|
|
|
+ if (index >= 0) return *idList.z(index);
|
|
|
+ return "";
|
|
|
+}
|
|
|
+
|
|
|
+void Framework::UIMLView::removeZeichnung(Zeichnung& z)
|
|
|
+{
|
|
|
+ int index = memberList.getWertIndex(&z);
|
|
|
+ if (index >= 0)
|
|
|
+ {
|
|
|
+ Text id = *idList.z(index);
|
|
|
+ idList.remove(index);
|
|
|
+ memberList.remove(index);
|
|
|
+ members->remove(id, id.getLength());
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+bool Framework::UIMLView::registerZeichnung(const char* id, Zeichnung* z)
|
|
|
{
|
|
|
Zeichnung* existing = members->z(id, textLength(id));
|
|
|
if (existing)
|