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

Database presentation
Database presentationDatabase presentation
Database presentation
webhostingguy
 

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

Lucene for Solr Developers
Lucene for Solr DevelopersLucene for Solr Developers
Lucene for Solr Developers
Erik Hatcher
 

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

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

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Dernier (20)

Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 

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