SlideShare a Scribd company logo
1 of 21
Download to read offline
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

More Related Content

What's hot

What's hot (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
 

Similar to How to Use JavaStates

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
 

Similar to How to Use JavaStates (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
 

More from 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
 

More from 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
 

Recently uploaded

Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Hyundai Motor Group
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 

Recently uploaded (20)

Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 

How to Use JavaStates

  • 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