To jest stara wersja strony!


Opis

Maciej Dudek (4AR) md5@o2.pl

ARD

GEF and Eclipse based editor for ARD and XTT. Evaluation, feasibility, prototype. XTTv2 Editor requirements

Feasibility study, a description how to create such editors with GEF, a prototype editor MS Thesis regarding GEF: Interfejs graficzny do budowy aplikacji komponentowych zapewniający weryfikację semantyczną, ARD+ Editor requirements

Spotkania

080304

Wykonano:

Powstałe wątpliwości:

  • Finalizacja.
  • Zbiór wszystkich możliwych operacji wykonywanych przez użytkownika.
  • Język opisu powstałego grafu: RGML? ATTML hekate_markup_language
  • Przestrzeń nazw.
  • Czy również implementacja drzewa TPH? Na ile bezpieczne w sytuacji cykli, split/merge, manual refactoring.
  • Liczba korzeni w drzewie, czy istnieje coś takiego jak korzeń?
  • XSD z opisem ARD+.
  • Co jak na końcu „liścia” jest Conceptual Attribute? Jaki wpływ na system?
  • Physical Attribute a XTT.
  • Attribute a Property. W prologu deklarowane oba.

080318

  • varda - uruchomiono i przeanalizowano funkcjonalność.
  • Zapoznano się ze specyfikacją ATTML
  • Zapoznano się z UServ case study

080415

Planowano:

  • prototyp

Zrealizowano:

080429

Planowano:

  • model xsd, translacja do ecore
  • automatyczny edytor

Zrealizowano:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
  <xs:element name="hml">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="type_set"/>
        <xs:element ref="attribute_set"/>
        <xs:element minOccurs="0" ref="property_set"/>
        <xs:element minOccurs="0" ref="tph"/>
        <xs:element minOccurs="0" ref="ard"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="type_set">
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="0" maxOccurs="unbounded" ref="type"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="type">
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="0" ref="desc"/>
        <xs:element ref="domain"/>
      </xs:sequence>
      <xs:attribute name="id" use="required" type="xs:ID"/>
      <xs:attribute name="name" use="required"/>
      <xs:attribute name="base" use="required">
        <xs:simpleType>
          <xs:restriction base="xs:token">
            <xs:enumeration value="integer"/>
            <xs:enumeration value="numeric"/>
            <xs:enumeration value="string"/>
            <xs:enumeration value="bool"/>
            <xs:enumeration value="date"/>
            <xs:enumeration value="time"/>
            <xs:enumeration value="timestamp"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:attribute>
      <xs:attribute name="length"/>
      <xs:attribute name="scale"/>
    </xs:complexType>
  </xs:element>
  <!-- id should begin with 'tpe_...' -->
  <xs:element name="desc" type="xs:string"/>
  <xs:element name="domain">
    <xs:complexType>
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element ref="range"/>
        <xs:element ref="value"/>
      </xs:choice>
      <xs:attribute name="type">
        <xs:simpleType>
          <xs:restriction base="xs:token">
            <xs:enumeration value="ordered"/>
            <xs:enumeration value="unordered"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:attribute>
    </xs:complexType>
  </xs:element>
  <xs:element name="range">
    <xs:complexType>
      <xs:attribute name="from" use="required"/>
      <xs:attribute name="to" use="required"/>
    </xs:complexType>
  </xs:element>
  <xs:element name="value" type="xs:string"/>
  <xs:element name="attribute_set">
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="0" maxOccurs="unbounded" ref="att"/>
        <xs:element minOccurs="0" maxOccurs="unbounded" ref="group"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="att">
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="0" ref="desc"/>
      </xs:sequence>
      <xs:attribute name="id" use="required" type="xs:ID"/>
      <xs:attribute name="type" type="xs:IDREF"/>
      <xs:attribute name="name" use="required"/>
      <xs:attribute name="abbrev"/>
      <xs:attribute name="value" use="required">
        <xs:simpleType>
          <xs:restriction base="xs:token">
            <xs:enumeration value="single"/>
            <xs:enumeration value="multiple"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:attribute>
      <xs:attribute name="class" use="required">
        <xs:simpleType>
          <xs:restriction base="xs:token">
            <xs:enumeration value="ro"/>
            <xs:enumeration value="rw"/>
            <xs:enumeration value="wo"/>
            <xs:enumeration value="state"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:attribute>
    </xs:complexType>
  </xs:element>
  <!-- id should begin with 'att_...' -->
  <xs:element name="group">
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="0" ref="desc"/>
        <xs:element maxOccurs="unbounded" ref="attref"/>
      </xs:sequence>
      <xs:attribute name="id" use="required" type="xs:ID"/>
      <xs:attribute name="name" use="required"/>
      <xs:attribute name="abbrev"/>
    </xs:complexType>
  </xs:element>
  <!-- id should begin with 'grp_...' -->
  <xs:element name="attref">
    <xs:complexType>
      <xs:attribute name="ref" use="required" type="xs:IDREF"/>
    </xs:complexType>
  </xs:element>
  <xs:element name="property_set">
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="0" maxOccurs="unbounded" ref="property"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="property">
    <xs:complexType>
      <xs:sequence>
        <xs:element maxOccurs="unbounded" ref="attref"/>
      </xs:sequence>
      <xs:attribute name="id" use="required" type="xs:ID"/>
    </xs:complexType>
  </xs:element>
  <!-- id should begin with 'prp_...' -->
  <xs:element name="tph">
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="0" maxOccurs="unbounded" ref="trans"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="trans">
    <xs:complexType>
      <xs:attribute name="src" use="required" type="xs:IDREF"/>
      <xs:attribute name="dst" use="required" type="xs:IDREF"/>
    </xs:complexType>
  </xs:element>
  <xs:element name="ard">
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="0" maxOccurs="unbounded" ref="dep"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="dep">
    <xs:complexType>
      <xs:attribute name="independent" use="required" type="xs:IDREF"/>
      <xs:attribute name="dependent" use="required" type="xs:IDREF"/>
    </xs:complexType>
  </xs:element>
</xs:schema>

Dokument hml-test.xml poprawnie przechodzi walidację przy użyciu powyższej definicji. Konwersji dokonano przy użyciu programu Trang.

080527

Edytor ARD powinien umożliwić tworzenie i edytowanie następujących elementów języka HML:

  • Property
  • Attribute
  • połączenia między elementami Property

Okazuję się jednak, iż framework GMF nie jest na tyle elastyczny, aby stworzyć edytor o powyższych założeniach na podstawie modelu hml.xsd. Framework GMF bazuje na modelach Ecore. Model Ecore można utworzyć samemu lub też otrzymać na drodze konwersji ze schematu XSD Schema. Dokładny opis konwersji opisany jest w niniejszym dokumencie. Jedynym sposobem wpływania na mapowanie są tzw EAnnotation (str. 13) umieszczane w samym pliku xsd. W ten sposób można np zamienić atrybut IDREF na element, zmianę korzenia dokumentu albo zignorowanie danego elementu. Jednak adnotacje nie dają możliwości reorganizacji struktury elementów, zawierania się. Konwerter oprócz pliku Ecore zwraca także plik mapowania .xsd2ecore. Można w nim podglądnąć szczegóły mapowania. Sam konwerter nie daje się jednak skonfigurować. Konwersja jest jednoznaczna. Mówią o tym następująca odpowiedź programisty frameworku GMF.

Matthew Rawlings wrote:
> While reverse engineering a XSD to eCore I generate a .xsd2ecore file. 
> Having changed the mapping in the .xsd2ecore file how I can a re-run it from 
> inside Eclipse? 
>

# From: Ed Merks <merks@xxxxxxxxxx>
# Date: Sat, 19 Aug 2006 18:01:31 -0400

Matthew,
That file is produced only to reflect what the XSDEcoreBuilder does, i.e., the relationship between the 
input schema and the output Ecore.  It's not used as input to drive anything else.  Short of writing a 
derived XSDEcoreBuilder, the best way to affect the mapping is to use the annotations in described in:
    http://www.eclipse.org/emf/docs/overviews/XMLSchemaToEcoreMapping.pdf
Support for quite a few new annotations was added in 2.2 and are not yet documented.
You'll note that the XML Schema information is recorded as EAnnotations and this annotation syntax can 
be used directly on any Ecore model to affect not only how instances of that model are serialized to XML 
but also to influence how that model itself is mapped to XML Schema when exported...
_____
Ed Merks is a co-lead of the top-level Eclipse Modeling project as well as the lead of the Eclipse Modeling Framework project. He has many years of in-depth experience in the design and implementation of languages, frameworks and application development environments. He holds a Ph.D. in computing science and is a co-author of the authoritative "Eclipse Modeling Framework, A Developer's Guide" (Addison-Wesley 2003). He works for IBM Rational at the Toronto Lab.

Problem stanowią połączenia między elementami w modelu hml.xsd. W przypadku Ecore, aby element A posiadał element B i mógł być z nim połączony bezpośrednim linkiem, to element B musi być bezpośrednim składnikiem elementu A. Na przykład:

  <xs:element name="A">
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="0" maxOccurs="unbounded" ref="B"/>
        <xs:element minOccurs="0" maxOccurs="unbounded" ref="C"/>
      </xs:sequence>
    </xs:complexType>

Jeśli natomiast jeśli B nie jest składnikiem elementu A, to niemożliwe jest utworzenie bezpośredniego połączenia między nimi. Gdybyśmy chcieli mieć możliwość tworzenia i edytowania Property jak i Attribute musielibyśmy wybrać korzeń pliku element Hml jako korzeń modelu Ecore. Tylko ten element „zawiera w sobie” elementy zarówno Property jak i Attribute. Ale wtedy aby stworzyć pojedynczy element Property z jednym Atrribute'm musielibyśmy wykonać następujący szereg czynności:

  1. dodać z Palety element PropertySet
  2. dodać z Palety element Property i połączyć go linkiem z PropertySet (relacja posiadania)
  3. dodać z Palety AttributeSet
  4. dodać z Palety Attribute i połączyć go linkiem z AttributeSet
  5. dodać z Palety Attref i połączyć go z Property oraz z Attribute

Jest to sprzeczne z oczekiwaniami stawianymi edytorowi graficznemu.


Próby utworzenia edytorów:

  • Nie udało się utworzyć za pomocą standardowych narzędzi GMF edytora na podstawie hml.xsd.
  • Dokonano próby utworzenia edytora wszystkich elementów (bez żadnej customizacji) za pomocą pluginu do GMF o nazwie dynamic gmf. Ten plugin ma w założeniu dać możliwość wygenerowania edytora jedynie przez wybranie pliku xsd. Pojawiał się jednak błąd wewnętrzny programu „Null pointer exception”. Takiego błędu nie było gdy użyłem pliku mindmap.xsd. Sądzę, iż obecność elementów IDREF mogła się do tego przyczynić.

Wnioski:

  • Model hml.xsd nie pasuje do frameworku GMF.
  • Uważam, że prościej i przejrzyściej byłoby stworzenie nowego modelu Ecore uwzględniając przy tym tylko te elementy, które są potrzebne w diagramie ARD.
  • Automatycznie generowany plik xml nowego edytora można by przy pomocy utworzonego pliku XSLT przekształcić do pliku kompatybilnego z hml.xsd.

080610

Moja propozycja ard.xsd (wersja 1.0)

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<xsd:schema xmlns:hml="hml" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="hml">
  <xsd:element name="Ard" type="hml:Ard"/>
  <xsd:element name="Property" type="hml:Property"/>
  <xsd:element name="Atrybut" type="hml:Atrybut"/>
  <xsd:complexType name="Ard">
    <xsd:sequence>
      <xsd:element maxOccurs="unbounded" minOccurs="0" name="property" type="hml:Property"/>
    </xsd:sequence>
  </xsd:complexType>
  <xsd:complexType name="Property">
    <xsd:sequence>
      <xsd:element maxOccurs="unbounded" minOccurs="0" name="atrybut" type="hml:Atrybut"/>
    </xsd:sequence>
    <xsd:attribute name="dependant">
      <xsd:simpleType>
        <xsd:list itemType="xsd:anyURI"/>
      </xsd:simpleType>
    </xsd:attribute>
  </xsd:complexType>
  <xsd:complexType name="Atrybut">
    <xsd:attribute name="nazwa"/>
  </xsd:complexType>
</xsd:schema>

W powyższym modelu brakuje TPH oraz całego XTT. W przypadku TPH jestem na etapie szukania możliwości automatycznej generacji części xml'a odpowiadającej za TPH. Jednak z powodu dużego zautomatyzowania GMF'a nie wiem na ile to będzie możliwe lub kiedy uda mi się to zrobić.

Screen z prostego edytora ard oraz odpowiadający mu plik xml.

Przykład 1: Diagram Ard

hyper.ia.agh.edu.pl_dudekm_zdj_przykladowy_edytor_1.jpg

Wygenerowany XML

<?xml version="1.0" encoding="UTF-8"?>
<hml:Ard xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:hml="hml">
  <property dependant="//@property.1 //@property.2">
    <atrybut nazwa="jeden"/>
    <atrybut nazwa="dwa"/>
  </property>
  <property>
    <atrybut nazwa="trzy"/>
    <atrybut nazwa="cztery"/>
  </property>
  <property>
    <atrybut nazwa="pięć"/>
    <atrybut nazwa="sześć"/>
  </property>
</hml:Ard>

Sprawdzono zgodność pliku xml ze schematem xsd.


Perspektywy

  • XSLT?
  • Automatyczne TPH
  • Menu kontekstowe na operacje Finalizacji i Splitu?

Projekt

Sprawozdanie

Przygotowanie

Swoją pracę rozpocząłem od lektury następujących prac:

Dalsze kroki to:

  • Uruchomienie programu Varda.
  • Zainstalowanie EMF, GEF, GMF.
  • Uruchomienie przykładowych edytorów: Logic Diagram, Flow Diagram, Shapes Diagram.

Ponieważ skróty EMF, GEF i GMF są do siebie podobne, po krótce wyjaśnię między różnice między tymi frameworkami:

  • EMF - służy do tworzenia modeli, logiki biznesowej. Modele zapisywane są w plikach ecore. Jest możliwa konwersja między modelami w ecore oraz modelem opisanym przy pomocy XSD (XML Schema).
  • GEF - służy do tworzenia edytorów graficznych. Opiera się na bibliotece draw2d, z której czerpie narzędzia do rysowania. Jest dość skomplikowany i trudny w opanowaniu. Daje za to szerokie możliwości. Uwaga, nie mylić z innym GEF, który nie jest projektem Eclipse.
  • GMF - plugin do Eclipse - w stosunku do GEF znacznie ułatwia tworzenie edytorów. Jest niejako graficzną „nakładką” na framework GEF pomagając programiście stworzyć edytor. Można skorzystać z narzędzia dashboard, który jest zaimplementowany jako jeden z widoków w Eclipse. Prowadzi on programistę przez proces tworzenia edytora używając do tego szeregu wizardów i łącząc drobne części ze sobą. Na końcu generowany jest kod edytora w GEF uzupełniony o Runtime GMF. Jednak trudno wykorzystać GMF do zaawansowanych problemów. Dla niestandardowych problemów trzeba edytować kod na własną rękę korzystając z klas GEF. Podsumowując, zastosowanie GMF daje zautomatyzowanie generacji kodu, ale może nie wystarczyć w niestandardowych projektach.

Zatem tworząc aplikację z pewnością użycie wszystkich z nich będzie nieodzowne a ich działanie będzie się przenikało.

Pierwsza próba stworzenia edytora

Aby skorzystać z możliwości EMF importując model XSD, przekształcono definicję HML.dtd z postaci DTD do postaci XSD. Efekt został przedstawiony poniżej:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
  <xs:element name="hml">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="type_set"/>
        <xs:element ref="attribute_set"/>
        <xs:element minOccurs="0" ref="property_set"/>
        <xs:element minOccurs="0" ref="tph"/>
        <xs:element minOccurs="0" ref="ard"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="type_set">
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="0" maxOccurs="unbounded" ref="type"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="type">
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="0" ref="desc"/>
        <xs:element ref="domain"/>
      </xs:sequence>
      <xs:attribute name="id" use="required" type="xs:ID"/>
      <xs:attribute name="name" use="required"/>
      <xs:attribute name="base" use="required">
        <xs:simpleType>
          <xs:restriction base="xs:token">
            <xs:enumeration value="integer"/>
            <xs:enumeration value="numeric"/>
            <xs:enumeration value="string"/>
            <xs:enumeration value="bool"/>
            <xs:enumeration value="date"/>
            <xs:enumeration value="time"/>
            <xs:enumeration value="timestamp"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:attribute>
      <xs:attribute name="length"/>
      <xs:attribute name="scale"/>
    </xs:complexType>
  </xs:element>
  <!-- id should begin with 'tpe_...' -->
  <xs:element name="desc" type="xs:string"/>
  <xs:element name="domain">
    <xs:complexType>
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element ref="range"/>
        <xs:element ref="value"/>
      </xs:choice>
      <xs:attribute name="type">
        <xs:simpleType>
          <xs:restriction base="xs:token">
            <xs:enumeration value="ordered"/>
            <xs:enumeration value="unordered"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:attribute>
    </xs:complexType>
  </xs:element>
  <xs:element name="range">
    <xs:complexType>
      <xs:attribute name="from" use="required"/>
      <xs:attribute name="to" use="required"/>
    </xs:complexType>
  </xs:element>
  <xs:element name="value" type="xs:string"/>
  <xs:element name="attribute_set">
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="0" maxOccurs="unbounded" ref="att"/>
        <xs:element minOccurs="0" maxOccurs="unbounded" ref="group"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="att">
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="0" ref="desc"/>
      </xs:sequence>
      <xs:attribute name="id" use="required" type="xs:ID"/>
      <xs:attribute name="type" type="xs:IDREF"/>
      <xs:attribute name="name" use="required"/>
      <xs:attribute name="abbrev"/>
      <xs:attribute name="value" use="required">
        <xs:simpleType>
          <xs:restriction base="xs:token">
            <xs:enumeration value="single"/>
            <xs:enumeration value="multiple"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:attribute>
      <xs:attribute name="class" use="required">
        <xs:simpleType>
          <xs:restriction base="xs:token">
            <xs:enumeration value="ro"/>
            <xs:enumeration value="rw"/>
            <xs:enumeration value="wo"/>
            <xs:enumeration value="state"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:attribute>
    </xs:complexType>
  </xs:element>
  <!-- id should begin with 'att_...' -->
  <xs:element name="group">
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="0" ref="desc"/>
        <xs:element maxOccurs="unbounded" ref="attref"/>
      </xs:sequence>
      <xs:attribute name="id" use="required" type="xs:ID"/>
      <xs:attribute name="name" use="required"/>
      <xs:attribute name="abbrev"/>
    </xs:complexType>
  </xs:element>
  <!-- id should begin with 'grp_...' -->
  <xs:element name="attref">
    <xs:complexType>
      <xs:attribute name="ref" use="required" type="xs:IDREF"/>
    </xs:complexType>
  </xs:element>
  <xs:element name="property_set">
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="0" maxOccurs="unbounded" ref="property"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="property">
    <xs:complexType>
      <xs:sequence>
        <xs:element maxOccurs="unbounded" ref="attref"/>
      </xs:sequence>
      <xs:attribute name="id" use="required" type="xs:ID"/>
    </xs:complexType>
  </xs:element>
  <!-- id should begin with 'prp_...' -->
  <xs:element name="tph">
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="0" maxOccurs="unbounded" ref="trans"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="trans">
    <xs:complexType>
      <xs:attribute name="src" use="required" type="xs:IDREF"/>
      <xs:attribute name="dst" use="required" type="xs:IDREF"/>
    </xs:complexType>
  </xs:element>
  <xs:element name="ard">
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="0" maxOccurs="unbounded" ref="dep"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="dep">
    <xs:complexType>
      <xs:attribute name="independent" use="required" type="xs:IDREF"/>
      <xs:attribute name="dependent" use="required" type="xs:IDREF"/>
    </xs:complexType>
  </xs:element>
</xs:schema>

Dokument hml-test.xml poprawnie przechodzi walidację przy użyciu powyższej definicji. Konwersji dokonano przy użyciu programu Trang.

Problem z użyciem powyższej definicji

Powyższa definicja, choć poprawna, okazała się niekompatybilna z frameworkiem GMF. Podstawowe problemy to:

  • Relacja zawierania się - brak bezpośredniego połączenia korzenia z property. W definicji oryginalnej występuje następujące zawieranie: ard → property_set → property. Zgodnie z takim modelem, aby utworzyć property, musielibyśmy tworzyć pośredni element property_set oraz połączenia między nimi. Jest to naturalnie sprzeczne z naszym założeniem.
  • Wybór korzenia - edytor tworzony jest dla konkretnego elementu w modelu. Wybierając korzeń K możemy edytować elementy zawarte w K, ale innych nie. Więc jeśli chcemy mieć możliwość edycji property_set oraz ard to naszym korzeniem musiałby być element hml. Lecz wtedy nasz edytor rozrósłby się jeszcze bardziej - o element ard.
  • Elementy IDREF - korzystanie z elementów IDREF nie uniemożliwia, lecz czyni trudniejszym tworzenie modelu. Trzeba jednak użyć Ecore Annotations.

Dokonano próby utworzenia edytora wszystkich elementów (bez żadnej customizacji) za pomocą pluginu do GMF o nazwie Dynamic GMF. Ten plugin ma w założeniu dać możliwość wygenerowania edytora jedynie przez wybranie pliku xsd. Pojawiał się jednak błąd wewnętrzny programu „Null pointer exception”. Takiego błędu nie było gdy użyłem pliku mindmap.xsd. Sądzę, iż obecność elementów IDREF mogła się do tego przyczynić.

Metodologia tworzenia modeli

Dużo bardziej naturalnym, prostszym i efektywniejszym sposobem jest tworzenie modelu ecore pasującego do GMF. I tak import z XSD następuje do pliku ECORE, na którym później się operuje.

Kolejnym krokiem mogłoby być eksportowanie tego modelu do XSD. W razie potrzeby można by dokonywać konwersji między róznymi definicjami XSD za pomocą szablonów XSLT.

Własny model

Stworzyłem zatem edytor opierając się o własny model. Model powstał przy pomocy EMF, który następnie wyeksportowałem do formatu XSD.

Nowa wersja Ard.xsd:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<xsd:schema xmlns:hml="hml" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="hml">
  <xsd:element name="Ard" type="hml:Ard"/>
  <xsd:element name="Property" type="hml:Property"/>
  <xsd:element name="Atrybut" type="hml:Atrybut"/>
  <xsd:complexType name="Ard">
    <xsd:sequence>
      <xsd:element maxOccurs="unbounded" minOccurs="0" name="property" type="hml:Property"/>
    </xsd:sequence>
  </xsd:complexType>
  <xsd:complexType name="Property">
    <xsd:sequence>
      <xsd:element maxOccurs="unbounded" minOccurs="0" name="atrybut" type="hml:Atrybut"/>
    </xsd:sequence>
    <xsd:attribute name="dependant">
      <xsd:simpleType>
        <xsd:list itemType="xsd:anyURI"/>
      </xsd:simpleType>
    </xsd:attribute>
  </xsd:complexType>
  <xsd:complexType name="Atrybut">
    <xsd:attribute name="nazwa"/>
  </xsd:complexType>
</xsd:schema>

Niestety, zawiera on jedynie opis ARD, bez TPH ani XTT.

Poniżej zamieszczono screen z edytora oraz odpowiadający mu plik xml.

Przykład 1: Diagram Ard

hyper.ia.agh.edu.pl_dudekm_zdj_przykladowy_edytor_1.jpg

Wygenerowany plik XML:

<?xml version="1.0" encoding="UTF-8"?>
<hml:Ard xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:hml="hml">
  <property dependant="//@property.1 //@property.2">
    <atrybut nazwa="jeden"/>
    <atrybut nazwa="dwa"/>
  </property>
  <property>
    <atrybut nazwa="trzy"/>
    <atrybut nazwa="cztery"/>
  </property>
  <property>
    <atrybut nazwa="pięć"/>
    <atrybut nazwa="sześć"/>
  </property>
</hml:Ard>

Sprawdzono zgodność pliku xml ze schematem xsd.

Możliwości edytora ważne z punktu widzenia ARD:

  • Dodawanie nowych elementów property.
  • Dodawanie elementów attribute do property.
  • Łączenie elementów property.
  • Zapis do pliku xml.

Perspektywy

Jest to wstępny zarys edytora. Docelowy edytor miałby posiadać bogatą funkcjonalność. Dalsze elementy, które należałoby zaimplementować to:

  • Menu kontekstowe zawierające komendy split dla elementów attribute oraz finalize dla elementów property. Custom Actions
  • Utworzenie dwóch dodatkowych warstw: do pierwszej należałyby elementy i połączenia ard bez tph, do drugiego same elementy tph bez ard. Następnie należałoby umożliwić włączanie oraz wyłączanie widoczności warstw. W szczególności obie warstwy mogłyby być widoczne aby widzieć zarówno drzewo TPH jak i ARD.
  • Utworzenie połączenia edytora ARD z edytorem XTT. To połączenie mogłoby przyjąć różną formę:
  1. otwarcia property w edytorze XTT link
  2. edycji XTT poprzez duże zbliżenie (zoom) na sfinalizowany element property.
  • Utworzenie edytora XTT.

Wnioski

  • Model warto tworzyć od podstaw w EMF.
  • GEF to potężne narzędzie, lecz trudne w opanowaniu.
  • API GMF oraz GEF zostało w ostatnim czasie uzupełnione o komentarze, lecz nadal jest wiele miejsc, gdzie ich brakuje.
  • Tutoriale są ukierunkowane na kilka zagadnień, w sprawie innych trzeba się pytać na forach dyskusyjnych, lub wręcz pisać do twórców frameworku.

Linki

Poniżej zamieszczam wartościowe linki związane z moim projektem:

Instalacja
Nauka
Troubleshooting

Problemy, które napotkałem oraz linki pomocne w ich rozwiązaniu:

Support
Inne

Materiały

pl/miw/miw08_gefardxtt_1.1213470746.txt.gz · ostatnio zmienione: 2019/06/27 15:58 (edycja zewnętrzna)
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0