SlideShare une entreprise Scribd logo
1  sur  21
Télécharger pour lire hors ligne
HOW TO USE JAVASTATES
CREATIVE COMMONS



• This
     document is shared under the terms of the Attribution-
 Share Alike 2.0 Generic Creative Commons license

• http://creativecommons.org/licenses/by-sa/2.0/
WHAT IS JAVASTATES?

• JavaStatesis a Java library that allows for defining the internal
 dynamics of a man machine interface declaratively in terms of
 states rather than in programmatic ways.

• JavaStatescan be used to implement Java Swing applications,
 but also any program based upon objects obeying the Java
 Bean conventions (“resource”->getResource/setResource/
 isResource), or the Listener API
 (addListener,removeListener,getListeners)
WHERE DO I GET JAVASTATES?


• JavaStates   is shared under the terms of a BSD license.

• https://sourceforge.net/projects/javastates/

• http://laurent.henocque.free.fr/javastates.php
STATE INTEGRITY

• The main feature of JavaStates is that the library will take care
 for all the cleanup needed when switching from state to state

• JavaStates
          also cares for this integrity in the presence of
 concurrent (independent) sub regions in states.

• The main advantage is that the interface designer/implementor
 concentrates on the specification, under the warranty that the
 resulting application will be defect free.
THE SIMPLEST TWO STATE
   JAVA SWING APPLICATION
public class HelloWorld {
      public static void main(String[] args) {
           try { new HelloWorld(); } catch(Exception e) { System.out.println(e);}}
      HelloWorld() throws Exception{
           JFrame mainFrame= new JFrame("HelloWorld");
           JButton hellobutton=new JButton("Hello ?");
           mainFrame.add(hellobutton);
           JavaStates.MAIN_("Main").
               req(mainFrame, "Visible", true).
               req(mainFrame, "Size", new Dimension(500,100)).
               req(mainFrame, "Title", "Hello! World, powered with JavaStates").
               lis(mainFrame, WindowListener.class, new WindowAdapter(){
                    public void windowClosing(WindowEvent e) {System.exit(0); }}).
               set(hellobutton,"world").
               STATE_("world").
                    req(hellobutton,"Label","World !").
                    set(hellobutton,"root").
               _STATE("world").
           _MAIN().start();
      }}
HELLO WORLD RUNNING
INITIALIZING JAVASTATES

• Two initialize JavaStates, and at the same time create a main
 region, use the static function JavaStates.MAIN_(String name)

 JavaStates.MAIN_("Main")

• The   name parameter is the name of the most global region.

• The   root state in this region is called “root”.
STATE REQUIREMENTS AS
             TRIPLES
•A state requirement is a triple: a mandatory setting of a given
 resource, of a given object to a certain value. The function

 req(Object, String resource, Object value)

• creates   such a requirement. For example:

• req(hellobutton,        “Label”, “World!”)

• JavaStates   expects a Java Bean api to exist on target object:
CREATING STATES

• States   are declared using the function

 STATE_(String name)

• Statedeclarations must be closed at the end, like parentheses,
 using the function

 _STATE(String name)

• JavaStates
           checks the identity of the names. This prevents from
 copy/paste errors or forgotten/extraneous closures.
STATES AS PLACEHOLDERS

• Statesare placeholders for requirements and other
 states.There are no limits to the embedding of states.

• Embedded  states inherit, and may override the requirements
 from enclosing states.

• Embedding states obeys the UML State Diagrams
 conventions, borrowed from Harel Statecharts

• State   requirements have no equivalent in UML
LISTENER REQUIREMENTS

• Interface dynamics are implemented in Java by using listeners.
  A listener requirement is set using the function
  lis(Object, Class<?>listener, Object value)
• creates such a requirement. For example:
  lis(mainFrame, WindowListener.class, new
  WindowAdapter(){...}).
• JavaStates supports listener requirements by fully relying upon
  introspection. Any class having a resource that obeys the
  Listener convention can be used: if there exist three functions
  getListener, addListener, getListeners.
CHANGING STATE

•A function for creating Action Listeners that change state is
 predefined:

• set(Object      target, String name)

• ”set” expects  target to implement the Java AbstractButton
 interface. It does not use introspection.

• In
   a state that specifies ‘set(hellobutton,"world")’, the
 action listener of object ‘hello button’ has the effect of
 changing to state “world”.
SETTING THE ROOT STATE

• Every   region owns a “root” state, placeholder for all other
 states
• When  the state containing this region is set, the region state is
 by default set to this root state.
• When  explicit setting to this root state is needed, one can use
 the function reset(Object target). This is almost
 equivalent to set(Object target,”root”), with the
 advantage of being independent from a change in the root
 state name
CREATING REGIONS

• Regions   are declared using the function

 REGION_(String name)

• Regiondeclarations must be closed at the end, like
 parentheses, using the function

 _REGION(String name)

• JavaStates
           checks the identity of the names. This prevents from
 copy/paste errors or forgotten/extraneous closures.
THE TWO REGION DEMO
JavaStates.MAIN_("Main").
  req(mainFrame, "Visible", true).
  req(mainFrame, "Size", new Dimension(500,100)).
  req(mainFrame, "Title", "Two Region demo, powered with JavaStates").
  lis(mainFrame, WindowListener.class, new WindowAdapter() {...}).
  set(button1,"world").
  STATE_("world").
     req(button1,"Label","World Region 1").
     reset(button1).
  _STATE("world").
  REGION_("2").
     set(button2,"world").
     STATE_("world").
       req(button2,"Label","World Region 2").
       reset(button2).
     _STATE("world").
  _REGION("2").
_MAIN().start();
THE RUNNING DEMO
LAUNCHING JAVASTATES


• Launching   JavaStates is performed using the function

 start()

• This call sets the main region to its root state. Any subregion
 in this state gets started as well, and so on recursively.
SETTING AN INITIAL STATE

• It often happens that the desired initial state in a region is not
  its root state.

• To   specify the root state in a region, use the function

  initial (String name)

• The  name parameter must match a valid state name in the
  region at run time. “initial” may be called before the state is
  declared (usually just after the region is created, and before
  any requirement or state is declared.
TO CONTINUE
• You   may check and then adapt the full featured Editor demo.
CONCLUSION, FURTHER
            LINKS

• JavaStates   offers state support in Java Interface development.

• Further   details, and the programs are present at

• http://sourceforge.net/projects/javastates

• http://laurent.henocque.free.fr

Contenu connexe

Tendances

Tendances (20)

Oak Lucene Indexes
Oak Lucene IndexesOak Lucene Indexes
Oak Lucene Indexes
 
SQL Tutorial - Basic Commands
SQL Tutorial - Basic CommandsSQL Tutorial - Basic Commands
SQL Tutorial - Basic Commands
 
Omnisearch in AEM 6.2 - Search All the Things
Omnisearch in AEM 6.2 - Search All the ThingsOmnisearch in AEM 6.2 - Search All the Things
Omnisearch in AEM 6.2 - Search All the Things
 
New in cakephp3
New in cakephp3New in cakephp3
New in cakephp3
 
Agile database access with CakePHP 3
Agile database access with CakePHP 3Agile database access with CakePHP 3
Agile database access with CakePHP 3
 
Future of HTTP in CakePHP
Future of HTTP in CakePHPFuture of HTTP in CakePHP
Future of HTTP in CakePHP
 
PHP Data Objects
PHP Data ObjectsPHP Data Objects
PHP Data Objects
 
The Zen of Lithium
The Zen of LithiumThe Zen of Lithium
The Zen of Lithium
 
Mysql & Php
Mysql & PhpMysql & Php
Mysql & Php
 
Mysql
MysqlMysql
Mysql
 
Oracle: Basic SQL
Oracle: Basic SQLOracle: Basic SQL
Oracle: Basic SQL
 
2012 03 08_dbi
2012 03 08_dbi2012 03 08_dbi
2012 03 08_dbi
 
View & index in SQL
View & index in SQLView & index in SQL
View & index in SQL
 
Drupal7 dbtng
Drupal7  dbtngDrupal7  dbtng
Drupal7 dbtng
 
Drupal II: The SQL
Drupal II: The SQLDrupal II: The SQL
Drupal II: The SQL
 
Mysql
MysqlMysql
Mysql
 
Dependency Injection in Laravel
Dependency Injection in LaravelDependency Injection in Laravel
Dependency Injection in Laravel
 
что нового в мире Services
что нового в мире Servicesчто нового в мире Services
что нового в мире Services
 
Paging Like A Pro
Paging Like A ProPaging Like A Pro
Paging Like A Pro
 
Database presentation
Database presentationDatabase presentation
Database presentation
 

Similaire à JavaStates Simple Tutorial

Effiziente Datenpersistierung mit JPA 2.1 und Hibernate
Effiziente Datenpersistierung mit JPA 2.1 und HibernateEffiziente Datenpersistierung mit JPA 2.1 und Hibernate
Effiziente Datenpersistierung mit JPA 2.1 und HibernateThorben Janssen
 
比XML更好用的Java Annotation
比XML更好用的Java Annotation比XML更好用的Java Annotation
比XML更好用的Java Annotationjavatwo2011
 
Teste de Integração com DbUnit e jIntegrity
Teste de Integração com DbUnit e jIntegrityTeste de Integração com DbUnit e jIntegrity
Teste de Integração com DbUnit e jIntegrityWashington Botelho
 
Effiziente persistierung
Effiziente persistierungEffiziente persistierung
Effiziente persistierungThorben Janssen
 
Java 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from OredevJava 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from OredevMattias Karlsson
 
Droidjam 2019 flutter isolates pdf
Droidjam 2019 flutter isolates pdfDroidjam 2019 flutter isolates pdf
Droidjam 2019 flutter isolates pdfAnvith Bhat
 
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ Silicon Val...
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ Silicon Val...Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ Silicon Val...
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ Silicon Val...Arun Gupta
 
Beyond DOMReady: Ultra High-Performance Javascript
Beyond DOMReady: Ultra High-Performance JavascriptBeyond DOMReady: Ultra High-Performance Javascript
Beyond DOMReady: Ultra High-Performance Javascriptaglemann
 
Lucene for Solr Developers
Lucene for Solr DevelopersLucene for Solr Developers
Lucene for Solr DevelopersErik Hatcher
 
Intro to JavaScript
Intro to JavaScriptIntro to JavaScript
Intro to JavaScriptYakov Fain
 

Similaire à JavaStates Simple Tutorial (20)

Introduction to Spring Boot
Introduction to Spring BootIntroduction to Spring Boot
Introduction to Spring Boot
 
Cis 274 intro
Cis 274   introCis 274   intro
Cis 274 intro
 
Dropwizard
DropwizardDropwizard
Dropwizard
 
Effiziente Datenpersistierung mit JPA 2.1 und Hibernate
Effiziente Datenpersistierung mit JPA 2.1 und HibernateEffiziente Datenpersistierung mit JPA 2.1 und Hibernate
Effiziente Datenpersistierung mit JPA 2.1 und Hibernate
 
Spring data requery
Spring data requerySpring data requery
Spring data requery
 
Ejb3 Dan Hinojosa
Ejb3 Dan HinojosaEjb3 Dan Hinojosa
Ejb3 Dan Hinojosa
 
What's new in Java EE 6
What's new in Java EE 6What's new in Java EE 6
What's new in Java EE 6
 
Aop clustering
Aop clusteringAop clustering
Aop clustering
 
Hibernate
HibernateHibernate
Hibernate
 
比XML更好用的Java Annotation
比XML更好用的Java Annotation比XML更好用的Java Annotation
比XML更好用的Java Annotation
 
Teste de Integração com DbUnit e jIntegrity
Teste de Integração com DbUnit e jIntegrityTeste de Integração com DbUnit e jIntegrity
Teste de Integração com DbUnit e jIntegrity
 
Effiziente persistierung
Effiziente persistierungEffiziente persistierung
Effiziente persistierung
 
React&redux
React&reduxReact&redux
React&redux
 
Java 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from OredevJava 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from Oredev
 
Json generation
Json generationJson generation
Json generation
 
Droidjam 2019 flutter isolates pdf
Droidjam 2019 flutter isolates pdfDroidjam 2019 flutter isolates pdf
Droidjam 2019 flutter isolates pdf
 
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ Silicon Val...
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ Silicon Val...Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ Silicon Val...
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ Silicon Val...
 
Beyond DOMReady: Ultra High-Performance Javascript
Beyond DOMReady: Ultra High-Performance JavascriptBeyond DOMReady: Ultra High-Performance Javascript
Beyond DOMReady: Ultra High-Performance Javascript
 
Lucene for Solr Developers
Lucene for Solr DevelopersLucene for Solr Developers
Lucene for Solr Developers
 
Intro to JavaScript
Intro to JavaScriptIntro to JavaScript
Intro to JavaScript
 

Plus de Laurent Henocque

Projet MeRS restitution finale kx-lh-2019-12-02-xuheh-gofig
Projet MeRS restitution finale kx-lh-2019-12-02-xuheh-gofigProjet MeRS restitution finale kx-lh-2019-12-02-xuheh-gofig
Projet MeRS restitution finale kx-lh-2019-12-02-xuheh-gofigLaurent Henocque
 
The KeeeX Messenger teaser 2016-05-19-lh-xofad-bosop
The KeeeX Messenger teaser 2016-05-19-lh-xofad-bosopThe KeeeX Messenger teaser 2016-05-19-lh-xofad-bosop
The KeeeX Messenger teaser 2016-05-19-lh-xofad-bosopLaurent Henocque
 
Le teaser KeeeX Messenger 2016-05-17-lh-xucel-kisac
Le teaser KeeeX Messenger 2016-05-17-lh-xucel-kisacLe teaser KeeeX Messenger 2016-05-17-lh-xucel-kisac
Le teaser KeeeX Messenger 2016-05-17-lh-xucel-kisacLaurent Henocque
 
The KeeeX teaser 2015-12-23-lh-xovoz-tonos
The KeeeX teaser 2015-12-23-lh-xovoz-tonosThe KeeeX teaser 2015-12-23-lh-xovoz-tonos
The KeeeX teaser 2015-12-23-lh-xovoz-tonosLaurent Henocque
 
Le teaser KeeeX 2015-11-24-lh-xosiv-puten
Le teaser KeeeX 2015-11-24-lh-xosiv-putenLe teaser KeeeX 2015-11-24-lh-xosiv-puten
Le teaser KeeeX 2015-11-24-lh-xosiv-putenLaurent Henocque
 
The KeeeX Teaser xukih-masav-dafik
The KeeeX Teaser xukih-masav-dafikThe KeeeX Teaser xukih-masav-dafik
The KeeeX Teaser xukih-masav-dafikLaurent Henocque
 
Le teaser KeeeX xoloh-lypin-cemem
Le teaser KeeeX xoloh-lypin-cememLe teaser KeeeX xoloh-lypin-cemem
Le teaser KeeeX xoloh-lypin-cememLaurent Henocque
 
How One to One Sharing Enforces Secure Collaboration - xonom
How One to One Sharing Enforces Secure Collaboration - xonomHow One to One Sharing Enforces Secure Collaboration - xonom
How One to One Sharing Enforces Secure Collaboration - xonomLaurent Henocque
 
Présentation Trophées Euro Cloud (KeeeX version xunab)
Présentation Trophées Euro Cloud (KeeeX version xunab)Présentation Trophées Euro Cloud (KeeeX version xunab)
Présentation Trophées Euro Cloud (KeeeX version xunab)Laurent Henocque
 
KeeeX Simple Tutorial 20150106-lh-keeex-xovek-zidec-bocyk
KeeeX Simple Tutorial 20150106-lh-keeex-xovek-zidec-bocykKeeeX Simple Tutorial 20150106-lh-keeex-xovek-zidec-bocyk
KeeeX Simple Tutorial 20150106-lh-keeex-xovek-zidec-bocykLaurent Henocque
 
KeeeX le tutoriel simple 20150106-lh-keeex-xutar-velec-bumak
KeeeX le tutoriel simple 20150106-lh-keeex-xutar-velec-bumakKeeeX le tutoriel simple 20150106-lh-keeex-xutar-velec-bumak
KeeeX le tutoriel simple 20150106-lh-keeex-xutar-velec-bumakLaurent Henocque
 
KeeeX as a Survival Kit in the Digital Jungle 20141229-LH-KX-xulig-nimyr-buder
KeeeX as a Survival Kit in the Digital Jungle 20141229-LH-KX-xulig-nimyr-buderKeeeX as a Survival Kit in the Digital Jungle 20141229-LH-KX-xulig-nimyr-buder
KeeeX as a Survival Kit in the Digital Jungle 20141229-LH-KX-xulig-nimyr-buderLaurent Henocque
 
KeeeX - Kit de Survie dans la Jungle Numérique - xuros-zebom-vesih
KeeeX  - Kit de Survie dans la Jungle Numérique - xuros-zebom-vesihKeeeX  - Kit de Survie dans la Jungle Numérique - xuros-zebom-vesih
KeeeX - Kit de Survie dans la Jungle Numérique - xuros-zebom-vesihLaurent Henocque
 
Keeex - On data governance - xofos-bafek-zebug
Keeex - On data governance - xofos-bafek-zebugKeeex - On data governance - xofos-bafek-zebug
Keeex - On data governance - xofos-bafek-zebugLaurent Henocque
 

Plus de Laurent Henocque (14)

Projet MeRS restitution finale kx-lh-2019-12-02-xuheh-gofig
Projet MeRS restitution finale kx-lh-2019-12-02-xuheh-gofigProjet MeRS restitution finale kx-lh-2019-12-02-xuheh-gofig
Projet MeRS restitution finale kx-lh-2019-12-02-xuheh-gofig
 
The KeeeX Messenger teaser 2016-05-19-lh-xofad-bosop
The KeeeX Messenger teaser 2016-05-19-lh-xofad-bosopThe KeeeX Messenger teaser 2016-05-19-lh-xofad-bosop
The KeeeX Messenger teaser 2016-05-19-lh-xofad-bosop
 
Le teaser KeeeX Messenger 2016-05-17-lh-xucel-kisac
Le teaser KeeeX Messenger 2016-05-17-lh-xucel-kisacLe teaser KeeeX Messenger 2016-05-17-lh-xucel-kisac
Le teaser KeeeX Messenger 2016-05-17-lh-xucel-kisac
 
The KeeeX teaser 2015-12-23-lh-xovoz-tonos
The KeeeX teaser 2015-12-23-lh-xovoz-tonosThe KeeeX teaser 2015-12-23-lh-xovoz-tonos
The KeeeX teaser 2015-12-23-lh-xovoz-tonos
 
Le teaser KeeeX 2015-11-24-lh-xosiv-puten
Le teaser KeeeX 2015-11-24-lh-xosiv-putenLe teaser KeeeX 2015-11-24-lh-xosiv-puten
Le teaser KeeeX 2015-11-24-lh-xosiv-puten
 
The KeeeX Teaser xukih-masav-dafik
The KeeeX Teaser xukih-masav-dafikThe KeeeX Teaser xukih-masav-dafik
The KeeeX Teaser xukih-masav-dafik
 
Le teaser KeeeX xoloh-lypin-cemem
Le teaser KeeeX xoloh-lypin-cememLe teaser KeeeX xoloh-lypin-cemem
Le teaser KeeeX xoloh-lypin-cemem
 
How One to One Sharing Enforces Secure Collaboration - xonom
How One to One Sharing Enforces Secure Collaboration - xonomHow One to One Sharing Enforces Secure Collaboration - xonom
How One to One Sharing Enforces Secure Collaboration - xonom
 
Présentation Trophées Euro Cloud (KeeeX version xunab)
Présentation Trophées Euro Cloud (KeeeX version xunab)Présentation Trophées Euro Cloud (KeeeX version xunab)
Présentation Trophées Euro Cloud (KeeeX version xunab)
 
KeeeX Simple Tutorial 20150106-lh-keeex-xovek-zidec-bocyk
KeeeX Simple Tutorial 20150106-lh-keeex-xovek-zidec-bocykKeeeX Simple Tutorial 20150106-lh-keeex-xovek-zidec-bocyk
KeeeX Simple Tutorial 20150106-lh-keeex-xovek-zidec-bocyk
 
KeeeX le tutoriel simple 20150106-lh-keeex-xutar-velec-bumak
KeeeX le tutoriel simple 20150106-lh-keeex-xutar-velec-bumakKeeeX le tutoriel simple 20150106-lh-keeex-xutar-velec-bumak
KeeeX le tutoriel simple 20150106-lh-keeex-xutar-velec-bumak
 
KeeeX as a Survival Kit in the Digital Jungle 20141229-LH-KX-xulig-nimyr-buder
KeeeX as a Survival Kit in the Digital Jungle 20141229-LH-KX-xulig-nimyr-buderKeeeX as a Survival Kit in the Digital Jungle 20141229-LH-KX-xulig-nimyr-buder
KeeeX as a Survival Kit in the Digital Jungle 20141229-LH-KX-xulig-nimyr-buder
 
KeeeX - Kit de Survie dans la Jungle Numérique - xuros-zebom-vesih
KeeeX  - Kit de Survie dans la Jungle Numérique - xuros-zebom-vesihKeeeX  - Kit de Survie dans la Jungle Numérique - xuros-zebom-vesih
KeeeX - Kit de Survie dans la Jungle Numérique - xuros-zebom-vesih
 
Keeex - On data governance - xofos-bafek-zebug
Keeex - On data governance - xofos-bafek-zebugKeeex - On data governance - xofos-bafek-zebug
Keeex - On data governance - xofos-bafek-zebug
 

Dernier

AI mind or machine power point presentation
AI mind or machine power point presentationAI mind or machine power point presentation
AI mind or machine power point presentationyogeshlabana357357
 
State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!Memoori
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMKumar Satyam
 
How to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cfHow to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cfdanishmna97
 
Working together SRE & Platform Engineering
Working together SRE & Platform EngineeringWorking together SRE & Platform Engineering
Working together SRE & Platform EngineeringMarcus Vechiato
 
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...panagenda
 
Navigating the Large Language Model choices_Ravi Daparthi
Navigating the Large Language Model choices_Ravi DaparthiNavigating the Large Language Model choices_Ravi Daparthi
Navigating the Large Language Model choices_Ravi DaparthiRaviKumarDaparthi
 
Intro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptxIntro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptxFIDO Alliance
 
ADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxFIDO Alliance
 
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptxCyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptxMasterG
 
Generative AI Use Cases and Applications.pdf
Generative AI Use Cases and Applications.pdfGenerative AI Use Cases and Applications.pdf
Generative AI Use Cases and Applications.pdfalexjohnson7307
 
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdfMuhammad Subhan
 
Design Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptxDesign Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptxFIDO Alliance
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
Introduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptxIntroduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptxFIDO Alliance
 
Simplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptxSimplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptxMarkSteadman7
 
Design and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data ScienceDesign and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data SciencePaolo Missier
 
الأمن السيبراني - ما لا يسع للمستخدم جهله
الأمن السيبراني - ما لا يسع للمستخدم جهلهالأمن السيبراني - ما لا يسع للمستخدم جهله
الأمن السيبراني - ما لا يسع للمستخدم جهلهMohamed Sweelam
 
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider  Progress from Awareness to Implementation.pptxTales from a Passkey Provider  Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider Progress from Awareness to Implementation.pptxFIDO Alliance
 

Dernier (20)

AI mind or machine power point presentation
AI mind or machine power point presentationAI mind or machine power point presentation
AI mind or machine power point presentation
 
State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDM
 
How to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cfHow to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cf
 
Working together SRE & Platform Engineering
Working together SRE & Platform EngineeringWorking together SRE & Platform Engineering
Working together SRE & Platform Engineering
 
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
 
Navigating the Large Language Model choices_Ravi Daparthi
Navigating the Large Language Model choices_Ravi DaparthiNavigating the Large Language Model choices_Ravi Daparthi
Navigating the Large Language Model choices_Ravi Daparthi
 
Intro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptxIntro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptx
 
ADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptx
 
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptxCyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
 
Generative AI Use Cases and Applications.pdf
Generative AI Use Cases and Applications.pdfGenerative AI Use Cases and Applications.pdf
Generative AI Use Cases and Applications.pdf
 
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
 
Design Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptxDesign Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptx
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Introduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptxIntroduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptx
 
Simplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptxSimplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptx
 
Design and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data ScienceDesign and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data Science
 
الأمن السيبراني - ما لا يسع للمستخدم جهله
الأمن السيبراني - ما لا يسع للمستخدم جهلهالأمن السيبراني - ما لا يسع للمستخدم جهله
الأمن السيبراني - ما لا يسع للمستخدم جهله
 
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider  Progress from Awareness to Implementation.pptxTales from a Passkey Provider  Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
 

JavaStates Simple Tutorial

  • 1. HOW TO USE JAVASTATES
  • 2. CREATIVE COMMONS • This document is shared under the terms of the Attribution- Share Alike 2.0 Generic Creative Commons license • http://creativecommons.org/licenses/by-sa/2.0/
  • 3. WHAT IS JAVASTATES? • JavaStatesis a Java library that allows for defining the internal dynamics of a man machine interface declaratively in terms of states rather than in programmatic ways. • JavaStatescan be used to implement Java Swing applications, but also any program based upon objects obeying the Java Bean conventions (“resource”->getResource/setResource/ isResource), or the Listener API (addListener,removeListener,getListeners)
  • 4. WHERE DO I GET JAVASTATES? • JavaStates is shared under the terms of a BSD license. • https://sourceforge.net/projects/javastates/ • http://laurent.henocque.free.fr/javastates.php
  • 5. STATE INTEGRITY • The main feature of JavaStates is that the library will take care for all the cleanup needed when switching from state to state • JavaStates also cares for this integrity in the presence of concurrent (independent) sub regions in states. • The main advantage is that the interface designer/implementor concentrates on the specification, under the warranty that the resulting application will be defect free.
  • 6. THE SIMPLEST TWO STATE JAVA SWING APPLICATION public class HelloWorld { public static void main(String[] args) { try { new HelloWorld(); } catch(Exception e) { System.out.println(e);}} HelloWorld() throws Exception{ JFrame mainFrame= new JFrame("HelloWorld"); JButton hellobutton=new JButton("Hello ?"); mainFrame.add(hellobutton); JavaStates.MAIN_("Main"). req(mainFrame, "Visible", true). req(mainFrame, "Size", new Dimension(500,100)). req(mainFrame, "Title", "Hello! World, powered with JavaStates"). lis(mainFrame, WindowListener.class, new WindowAdapter(){ public void windowClosing(WindowEvent e) {System.exit(0); }}). set(hellobutton,"world"). STATE_("world"). req(hellobutton,"Label","World !"). set(hellobutton,"root"). _STATE("world"). _MAIN().start(); }}
  • 8. INITIALIZING JAVASTATES • Two initialize JavaStates, and at the same time create a main region, use the static function JavaStates.MAIN_(String name) JavaStates.MAIN_("Main") • The name parameter is the name of the most global region. • The root state in this region is called “root”.
  • 9. STATE REQUIREMENTS AS TRIPLES •A state requirement is a triple: a mandatory setting of a given resource, of a given object to a certain value. The function req(Object, String resource, Object value) • creates such a requirement. For example: • req(hellobutton, “Label”, “World!”) • JavaStates expects a Java Bean api to exist on target object:
  • 10. CREATING STATES • States are declared using the function STATE_(String name) • Statedeclarations must be closed at the end, like parentheses, using the function _STATE(String name) • JavaStates checks the identity of the names. This prevents from copy/paste errors or forgotten/extraneous closures.
  • 11. STATES AS PLACEHOLDERS • Statesare placeholders for requirements and other states.There are no limits to the embedding of states. • Embedded states inherit, and may override the requirements from enclosing states. • Embedding states obeys the UML State Diagrams conventions, borrowed from Harel Statecharts • State requirements have no equivalent in UML
  • 12. LISTENER REQUIREMENTS • Interface dynamics are implemented in Java by using listeners. A listener requirement is set using the function lis(Object, Class<?>listener, Object value) • creates such a requirement. For example: lis(mainFrame, WindowListener.class, new WindowAdapter(){...}). • JavaStates supports listener requirements by fully relying upon introspection. Any class having a resource that obeys the Listener convention can be used: if there exist three functions getListener, addListener, getListeners.
  • 13. CHANGING STATE •A function for creating Action Listeners that change state is predefined: • set(Object target, String name) • ”set” expects target to implement the Java AbstractButton interface. It does not use introspection. • In a state that specifies ‘set(hellobutton,"world")’, the action listener of object ‘hello button’ has the effect of changing to state “world”.
  • 14. SETTING THE ROOT STATE • Every region owns a “root” state, placeholder for all other states • When the state containing this region is set, the region state is by default set to this root state. • When explicit setting to this root state is needed, one can use the function reset(Object target). This is almost equivalent to set(Object target,”root”), with the advantage of being independent from a change in the root state name
  • 15. CREATING REGIONS • Regions are declared using the function REGION_(String name) • Regiondeclarations must be closed at the end, like parentheses, using the function _REGION(String name) • JavaStates checks the identity of the names. This prevents from copy/paste errors or forgotten/extraneous closures.
  • 16. THE TWO REGION DEMO JavaStates.MAIN_("Main"). req(mainFrame, "Visible", true). req(mainFrame, "Size", new Dimension(500,100)). req(mainFrame, "Title", "Two Region demo, powered with JavaStates"). lis(mainFrame, WindowListener.class, new WindowAdapter() {...}). set(button1,"world"). STATE_("world"). req(button1,"Label","World Region 1"). reset(button1). _STATE("world"). REGION_("2"). set(button2,"world"). STATE_("world"). req(button2,"Label","World Region 2"). reset(button2). _STATE("world"). _REGION("2"). _MAIN().start();
  • 18. LAUNCHING JAVASTATES • Launching JavaStates is performed using the function start() • This call sets the main region to its root state. Any subregion in this state gets started as well, and so on recursively.
  • 19. SETTING AN INITIAL STATE • It often happens that the desired initial state in a region is not its root state. • To specify the root state in a region, use the function initial (String name) • The name parameter must match a valid state name in the region at run time. “initial” may be called before the state is declared (usually just after the region is created, and before any requirement or state is declared.
  • 20. TO CONTINUE • You may check and then adapt the full featured Editor demo.
  • 21. CONCLUSION, FURTHER LINKS • JavaStates offers state support in Java Interface development. • Further details, and the programs are present at • http://sourceforge.net/projects/javastates • http://laurent.henocque.free.fr