IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

AWT/Swing Java Discussion :

Demande d'aide pour tester AL - Swing - JavaFX


Sujet :

AWT/Swing Java

  1. #21
    Rédacteur
    Avatar de CyaNnOrangehead
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Mai 2008
    Messages
    777
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : France, Haute Savoie (Rhône Alpes)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : Aéronautique - Marine - Espace - Armement

    Informations forums :
    Inscription : Mai 2008
    Messages : 777
    Points : 1 731
    Points
    1 731
    Par défaut
    Alors, voilà, j'ai ajouté les contrôles déclarés dans la class controller dans la portée du script. Voilà comment accéder à des contrôles FX depuis AL :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
     
    <?xml version="1.0" encoding="UTF-8"?>
     
    <?import java.lang.*?>
    <?import java.util.*?>
    <?import javafx.scene.*?>
    <?import javafx.scene.control.*?>
    <?import javafx.scene.layout.*?>
    <?language al?>
     
    <AnchorPane id="AnchorPane" prefHeight="200" prefWidth="320" xmlns:fx="http://javafx.com/fxml" fx:controller="alscriptfxml.ALScriptFXMLController">
    	<fx:script>
    		set sayHello = function (event) {
    		print("AL'O Word!");
    		label.setText("Calling the AL-Script");
    		}
     
    		set sayGoodBy = function (event) {
    		print("See ya !");
    		label.setText("");
    		}
    	</fx:script>
    	<children>
    		<Button layoutX="126" layoutY="90" text="Click Me!" onAction="sayHello(event);" fx:id="button1" />
    		<Button layoutX="126" layoutY="120" text="Click Me!" onAction="sayGoodBy(event);" fx:id="button2" />
    		<Label layoutX="126" layoutY="150" minHeight="16" minWidth="69" fx:id="label" />
    	</children>
    </AnchorPane>
    Et voilà le controller :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
     
    public class ALScriptFXMLController implements Initializable {
     
    	@FXML
    	public Label label;
     
    }
    Retrouvez tous mes tutoriels : http://caron-yann.developpez.com/

    Et mon projet en cours : Algoid - programming language

    N'oubliez pas de consulter les FAQ Java (http://java.developpez.com/faq/) et les cours et tutoriels Java (http://java.developpez.com/cours/)

  2. #22
    Rédacteur/Modérateur

    Avatar de bouye
    Homme Profil pro
    Information Technologies Specialist (Scientific Computing)
    Inscrit en
    Août 2005
    Messages
    6 840
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 47
    Localisation : Nouvelle-Calédonie

    Informations professionnelles :
    Activité : Information Technologies Specialist (Scientific Computing)
    Secteur : Agroalimentaire - Agriculture

    Informations forums :
    Inscription : Août 2005
    Messages : 6 840
    Points : 22 851
    Points
    22 851
    Billets dans le blog
    51
    Par défaut
    Hum ... ce n'est pas normal qu'il faille spécifier un contrôleur pour que cela fonctionne.
    Avec JavaScript, il suffit de faire :
    Code XML : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    <?xml version="1.0" encoding="UTF-8"?>
     
    <?import java.lang.*?>
    <?import java.util.*?>
    <?import javafx.scene.*?>
    <?import javafx.scene.control.*?>
    <?import javafx.scene.layout.*?>
    <?language javascript?>
     
    <AnchorPane id="AnchorPane" prefHeight="400.0" prefWidth="600.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/2.2">
      <fx:script>
          function sayHello() {
              println("Hello World!");
              myButton.setText("Foo!");
          }
      </fx:script>
      <children>
        <Button fx:id="myButton" layoutX="14.0" layoutY="14.0" mnemonicParsing="false" text="Button" onAction="sayHello(event);" />
      </children>
    </AnchorPane>

    Et il n'y aucun soucis, tout fonctionne comme prévu.

    Tandis qu'avec Al :
    Code XML : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    <?xml version="1.0" encoding="UTF-8"?>
     
    <?import java.lang.*?>
    <?import java.util.*?>
    <?import javafx.scene.*?>
    <?import javafx.scene.control.*?>
    <?import javafx.scene.layout.*?>
    <?language al?>
     
    <AnchorPane id="AnchorPane" prefHeight="400.0" prefWidth="600.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/2.2">
        <fx:script>
            set sayHello = function(event) {
                print("Hello world!");
                myButton.setText("Foo!");
            }
        </fx:script>
      <children>
        <Button fx:id="myButton" layoutX="14.0" layoutY="14.0" mnemonicParsing="false" text="Button" onAction="sayHello(event);" />
      </children>
    </AnchorPane>

    On a au chargement le message suivant sur la sortie standard :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    ERROR WITH NULL [resources]
    BUILD OBJECT location CLASS class java.net.URL
    Et ensuite lorsqu'on clique sur le bouton :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    fr.cyann.al.exception.VariableNotFoundException: Variable myButton.setText() not found in current scope !
    	at fr.cyann.al.visitor.RuntimeVisitor$6.visite(RuntimeVisitor.java:552)
    	at fr.cyann.al.visitor.RuntimeVisitor$6.visite(RuntimeVisitor.java:500)
    	at fr.cyann.jasi.ast.AST.visite(AST.java:92)
    	at fr.cyann.al.visitor.RuntimeVisitor.executeBlock(RuntimeVisitor.java:229)
    	at fr.cyann.al.visitor.RuntimeVisitor$17.visite(RuntimeVisitor.java:1415)
    	at fr.cyann.al.visitor.RuntimeVisitor$17.visite(RuntimeVisitor.java:1399)
    	at fr.cyann.jasi.ast.AST.visite(AST.java:92)
    	at fr.cyann.al.visitor.RuntimeVisitor.callFunction(RuntimeVisitor.java:189)
    	at fr.cyann.al.visitor.RuntimeVisitor$7.visite(RuntimeVisitor.java:632)
    	at fr.cyann.al.visitor.RuntimeVisitor$7.visite(RuntimeVisitor.java:595)
    	at fr.cyann.jasi.ast.AST.visite(AST.java:92)
    	at fr.cyann.al.visitor.RuntimeVisitor$6.visite(RuntimeVisitor.java:586)
    	at fr.cyann.al.visitor.RuntimeVisitor$6.visite(RuntimeVisitor.java:500)
    	at fr.cyann.jasi.ast.AST.visite(AST.java:92)
    	at fr.cyann.al.visitor.RuntimeVisitor.executeBlock(RuntimeVisitor.java:229)
    	at fr.cyann.al.visitor.RuntimeVisitor$16.visite(RuntimeVisitor.java:1395)
    	at fr.cyann.al.visitor.RuntimeVisitor$16.visite(RuntimeVisitor.java:1391)
    	at fr.cyann.jasi.ast.AST.visite(AST.java:92)
    	at fr.cyann.jasi.builder.ASTBuilder.visite(ASTBuilder.java:114)
    	at fr.cyann.al.Main.executeScript(Main.java:190)
    	at fr.cyann.al.ALScriptEngine.eval(ALScriptEngine.java:152)
    	at fr.cyann.al.ALScriptEngine.eval(ALScriptEngine.java:115)
    	at javafx.fxml.FXMLLoader$ScriptEventHandler.handle(FXMLLoader.java:1483)
    	at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:69)
    	at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:217)
    	at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:170)
    	at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:38)
    	at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:37)
    	at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
    	at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)
    	at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
    	at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:53)
    	at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:28)
    	at javafx.event.Event.fireEvent(Event.java:171)
    	at javafx.scene.Node.fireEvent(Node.java:6867)
    	at javafx.scene.control.Button.fire(Button.java:179)
    	at com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(ButtonBehavior.java:193)
    	at com.sun.javafx.scene.control.skin.SkinBase$4.handle(SkinBase.java:336)
    	at com.sun.javafx.scene.control.skin.SkinBase$4.handle(SkinBase.java:329)
    	at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:64)
    	at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:217)
    	at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:170)
    	at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:38)
    	at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:37)
    	at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
    	at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)
    	at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
    	at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)
    	at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
    	at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:53)
    	at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:33)
    	at javafx.event.Event.fireEvent(Event.java:171)
    	at javafx.scene.Scene$MouseHandler.process(Scene.java:3369)
    	at javafx.scene.Scene$MouseHandler.process(Scene.java:3209)
    	at javafx.scene.Scene$MouseHandler.access$1900(Scene.java:3164)
    	at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1582)
    	at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2267)
    	at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:250)
    	at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:173)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:292)
    	at com.sun.glass.ui.View.handleMouseEvent(View.java:530)
    	at com.sun.glass.ui.View.notifyMouse(View.java:924)
    	at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    	at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:17)
    	at com.sun.glass.ui.win.WinApplication$3$1.run(WinApplication.java:67)
    	at java.lang.Thread.run(Thread.java:744)
    Merci de penser au tag quand une réponse a été apportée à votre question. Aucune réponse ne sera donnée à des messages privés portant sur des questions d'ordre technique. Les forums sont là pour que vous y postiez publiquement vos problèmes.

    suivez mon blog sur Développez.

    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning. ~ Rich Cook

  3. #23
    Rédacteur/Modérateur

    Avatar de bouye
    Homme Profil pro
    Information Technologies Specialist (Scientific Computing)
    Inscrit en
    Août 2005
    Messages
    6 840
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 47
    Localisation : Nouvelle-Calédonie

    Informations professionnelles :
    Activité : Information Technologies Specialist (Scientific Computing)
    Secteur : Agroalimentaire - Agriculture

    Informations forums :
    Inscription : Août 2005
    Messages : 6 840
    Points : 22 851
    Points
    22 851
    Billets dans le blog
    51
    Par défaut
    Une autre erreur lorsque je charge un script externe :

    Code XML : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    <?xml version="1.0" encoding="UTF-8"?>
     
    <?import java.lang.*?>
    <?import java.util.*?>
    <?import javafx.scene.*?>
    <?import javafx.scene.control.*?>
    <?import javafx.scene.layout.*?>
    <?language al?>
     
    <AnchorPane id="AnchorPane" prefHeight="400.0" prefWidth="600.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/2.2">
      <fx:script source="script.al"/>
      <children>
        <Button layoutX="14.0" layoutY="14.0" mnemonicParsing="false" text="Button" onAction="sayHello(event);" />
      </children>
    </AnchorPane>

    Code python : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    set sayHello = function(event) {
        print("Hello world!");
    }

    Cela génère l'erreur suivante :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    fr.cyann.jasi.exception.InvalidSymbolException: Invalid symbol '
    ' at [line: 1, col: 33]
    	at fr.cyann.jasi.lexer.Lexer.match(Lexer.java:91)
    	at fr.cyann.jasi.parser.PEG.parse(PEG.java:95)
    	at fr.cyann.al.Main.executeScript(Main.java:183)
    	at fr.cyann.al.ALScriptEngine.eval(ALScriptEngine.java:152)
    	at fr.cyann.al.ALScriptEngine.eval(ALScriptEngine.java:115)
    	at fr.cyann.al.ALScriptEngine.eval(ALScriptEngine.java:167)
    	at javafx.fxml.FXMLLoader$ScriptElement.processStartElement(FXMLLoader.java:1339)
    	at javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2356)
    	at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2172)
    	at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2069)
    	at alinfxml.AlInFXML.loadTest(AlInFXML.java:89)
    	at alinfxml.AlInFXML.start(AlInFXML.java:76)
    	at com.sun.javafx.application.LauncherImpl$5.run(LauncherImpl.java:319)
    	at com.sun.javafx.application.PlatformImpl$5.run(PlatformImpl.java:219)
    	at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:182)
    	at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:179)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:179)
    	at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:76)
    	at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    	at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:17)
    	at com.sun.glass.ui.win.WinApplication$3$1.run(WinApplication.java:67)
    	at java.lang.Thread.run(Thread.java:744)
    Mais cette erreur doit être catchee quelques part car cela ne provoque pas le plantage de l'application et donc la fenetre apparait. Par contre, quand on clique sur le bouton on a :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    fr.cyann.al.exception.VariableNotFoundException: Variable sayHello() not found in current scope !
    	at fr.cyann.al.visitor.RuntimeVisitor$6.visite(RuntimeVisitor.java:552)
    	at fr.cyann.al.visitor.RuntimeVisitor$6.visite(RuntimeVisitor.java:500)
    	at fr.cyann.jasi.ast.AST.visite(AST.java:92)
    	at fr.cyann.al.visitor.RuntimeVisitor.executeBlock(RuntimeVisitor.java:229)
    	at fr.cyann.al.visitor.RuntimeVisitor$16.visite(RuntimeVisitor.java:1395)
    	at fr.cyann.al.visitor.RuntimeVisitor$16.visite(RuntimeVisitor.java:1391)
    	at fr.cyann.jasi.ast.AST.visite(AST.java:92)
    	at fr.cyann.jasi.builder.ASTBuilder.visite(ASTBuilder.java:114)
    	at fr.cyann.al.Main.executeScript(Main.java:190)
    	at fr.cyann.al.ALScriptEngine.eval(ALScriptEngine.java:152)
    	at fr.cyann.al.ALScriptEngine.eval(ALScriptEngine.java:115)
    	at javafx.fxml.FXMLLoader$ScriptEventHandler.handle(FXMLLoader.java:1483)
    	at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:69)
    	at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:217)
    	at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:170)
    	at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:38)
    	at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:37)
    	at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
    	at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)
    	at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
    	at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:53)
    	at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:28)
    	at javafx.event.Event.fireEvent(Event.java:171)
    	at javafx.scene.Node.fireEvent(Node.java:6867)
    	at javafx.scene.control.Button.fire(Button.java:179)
    	at com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(ButtonBehavior.java:193)
    	at com.sun.javafx.scene.control.skin.SkinBase$4.handle(SkinBase.java:336)
    	at com.sun.javafx.scene.control.skin.SkinBase$4.handle(SkinBase.java:329)
    	at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:64)
    	at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:217)
    	at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:170)
    	at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:38)
    	at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:37)
    	at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
    	at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)
    	at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
    	at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)
    	at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
    	at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:53)
    	at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:33)
    	at javafx.event.Event.fireEvent(Event.java:171)
    	at javafx.scene.Scene$MouseHandler.process(Scene.java:3369)
    	at javafx.scene.Scene$MouseHandler.process(Scene.java:3209)
    	at javafx.scene.Scene$MouseHandler.access$1900(Scene.java:3164)
    	at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1582)
    	at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2267)
    	at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:250)
    	at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:173)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:292)
    	at com.sun.glass.ui.View.handleMouseEvent(View.java:530)
    	at com.sun.glass.ui.View.notifyMouse(View.java:924)
    	at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    	at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:17)
    	at com.sun.glass.ui.win.WinApplication$3$1.run(WinApplication.java:67)
    	at java.lang.Thread.run(Thread.java:744)
    Merci de penser au tag quand une réponse a été apportée à votre question. Aucune réponse ne sera donnée à des messages privés portant sur des questions d'ordre technique. Les forums sont là pour que vous y postiez publiquement vos problèmes.

    suivez mon blog sur Développez.

    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning. ~ Rich Cook

  4. #24
    Rédacteur
    Avatar de CyaNnOrangehead
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Mai 2008
    Messages
    777
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : France, Haute Savoie (Rhône Alpes)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : Aéronautique - Marine - Espace - Armement

    Informations forums :
    Inscription : Mai 2008
    Messages : 777
    Points : 1 731
    Points
    1 731
    Par défaut
    Citation Envoyé par bouye Voir le message
    Hum ... ce n'est pas normal qu'il faille spécifier un contrôleur pour que cela fonctionne.
    Avec JavaScript, il suffit de faire
    Oui je sais. J'ai vu. C'est parce que je ne sais pas du tout comment explorer le contexte FX au lancement du script.
    Le seul moyen que j'ai trouvé pour le moment, c'est fouiller dans l'objet controller, lequel expose les composants FX s'il sont déclarés avec l'annotation @FXML

    Je ne sais vraiment pas comment récupérer ces objet. J'ai regardé dans les sources de rhino, mais je n'ai rien trouvé (cela dit elles ne sont pas facile à lire ces sources)....
    As tu une idée ? Toi qui connait FX mieux que moi ;-)

    Je regarde l'autre problème de plus près en attendant (je soupçone un problème de \r\n à la windaube) ;-)
    mici ^_^
    Retrouvez tous mes tutoriels : http://caron-yann.developpez.com/

    Et mon projet en cours : Algoid - programming language

    N'oubliez pas de consulter les FAQ Java (http://java.developpez.com/faq/) et les cours et tutoriels Java (http://java.developpez.com/cours/)

  5. #25
    Rédacteur
    Avatar de CyaNnOrangehead
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Mai 2008
    Messages
    777
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : France, Haute Savoie (Rhône Alpes)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : Aéronautique - Marine - Espace - Armement

    Informations forums :
    Inscription : Mai 2008
    Messages : 777
    Points : 1 731
    Points
    1 731
    Par défaut
    Citation Envoyé par bouye Voir le message
    Une autre erreur lorsque je charge un script externe :
    Cela génère l'erreur suivante :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    fr.cyann.jasi.exception.InvalidSymbolException: Invalid symbol '
    ' at [line: 1, col: 33]
    Ok ça doit être corrigé ! Je pense que c'est le caractère \n de windows qui n'était pas géré pas l'analyseur syntaxique comme caractère d'espacement.
    Pour être tranquil voici les caractères considérés comme espacement : " \t\n\r\f\x0b\0"

    Citation Envoyé par bouye Voir le message
    Mais cette erreur doit être catchee quelques part car cela ne provoque pas le plantage de l'application et donc la fenetre apparait. Par contre, quand on clique sur le bouton on a :
    Oui comme c'est une erreur de syntaxe AL, elle est du type ALRuntimeException et est catché dans la méthode eval du scriptengine.

    Citation Envoyé par bouye Voir le message
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    fr.cyann.al.exception.VariableNotFoundException: Variable sayHello() not found in current scope !
    Normal, le script a planté, il n'est donc pas chargé.


    Vala m'sieur, la lib est à jour, ça ne devrait plus planter maintenant. ;-)
    Retrouvez tous mes tutoriels : http://caron-yann.developpez.com/

    Et mon projet en cours : Algoid - programming language

    N'oubliez pas de consulter les FAQ Java (http://java.developpez.com/faq/) et les cours et tutoriels Java (http://java.developpez.com/cours/)

  6. #26
    Rédacteur/Modérateur

    Avatar de bouye
    Homme Profil pro
    Information Technologies Specialist (Scientific Computing)
    Inscrit en
    Août 2005
    Messages
    6 840
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 47
    Localisation : Nouvelle-Calédonie

    Informations professionnelles :
    Activité : Information Technologies Specialist (Scientific Computing)
    Secteur : Agroalimentaire - Agriculture

    Informations forums :
    Inscription : Août 2005
    Messages : 6 840
    Points : 22 851
    Points
    22 851
    Billets dans le blog
    51
    Par défaut
    Citation Envoyé par CyaNnOrangehead Voir le message
    Oui je sais. J'ai vu. C'est parce que je ne sais pas du tout comment explorer le contexte FX au lancement du script.
    Le seul moyen que j'ai trouvé pour le moment, c'est fouiller dans l'objet controller, lequel expose les composants FX s'il sont déclarés avec l'annotation @FXML

    Je ne sais vraiment pas comment récupérer ces objet. J'ai regardé dans les sources de rhino, mais je n'ai rien trouvé (cela dit elles ne sont pas facile à lire ces sources)....
    As tu une idée ? Toi qui connait FX mieux que moi ;-)
    Pas la moindre idee non plus.
    J'ai juste fait qq test en plus avec JavaScript, R et Python.

    Si en JavaScript, je fais :

    Code JavaScript : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    println(this);
    println(" ");
    for (var obj in this) {
      println(obj + "\t" + typeof obj + "\t" + typeof this[obj]);
    }

    Avec un script interne j'ai :

    Code text : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    [object Global]
     
    event	        string	    object
    myButton	string	    object
    resources	string	    object
    println	string	    function
    location	string	    object
    context	string	    object
    sayHello	string	    function
    print	        string	    function
    JavaAdapter	string	    object

    Et donc je peux referencer myButton.

    Tandis qu'avec un script externe j'ai :
    Code text : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    [object Global]
     
    event   	string    object
    resources	string    object
    println	string	   function
    location	string	   object
    context	string	   object
    sayHello	string	   function
    print	        string    function
    JavaAdapter	string	    object

    Et donc on ne peut plus référencer myButton. Donc le loader ne fonctionne pas de la même manière dans ces deux cas de figure.

    Avec R :
    Code R : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    for ( m in ls() ) { 
      print(m); 
    }

    En script interne cela donne:


    Sauf erreur, a priori, le seul objet référence est a priori l'objet événement.

    Le script externe ne fonctionne pas a cause d'un bug dans Renjin au niveau de l'extension de fichier retournee par le ScriptingEngine qui fait que le FXMLLoader ne peut pas le charger (le moteur retourne ".R" au lieu de "R").

    Avec Python :
    Code Python : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    ret = dir()
    print ret

    En externe :

    On a également seulement accès a l'objet événement.
    Le script interne ne fonctionne pas car Python attend un EOF que je ne peux pas lui fournir bien sur.

    Pour le moment imposible d'executer du Groovy, Scala ou Ruby.

    M'enfin c'est moins critique, on peut déjà utiliser les bases du langage pour faire du scripting et avec ta méthode d’accès au contrôleur cela fonctionne aussi.

    EDIT - sinon c'est peut-etre plus du cote des sources de FXMLLoader qu'il faut voir sur comment tout cela est initialisé.
    Merci de penser au tag quand une réponse a été apportée à votre question. Aucune réponse ne sera donnée à des messages privés portant sur des questions d'ordre technique. Les forums sont là pour que vous y postiez publiquement vos problèmes.

    suivez mon blog sur Développez.

    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning. ~ Rich Cook

  7. #27
    Rédacteur
    Avatar de CyaNnOrangehead
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Mai 2008
    Messages
    777
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : France, Haute Savoie (Rhône Alpes)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : Aéronautique - Marine - Espace - Armement

    Informations forums :
    Inscription : Mai 2008
    Messages : 777
    Points : 1 731
    Points
    1 731
    Par défaut
    En AL tu peux faire
    Code al : Sélectionner tout - Visualiser dans une fenêtre à part
    al.allObjects().each(print);

    Ca c'est de l'écriture fonctionnelle comme on aime ;-) !!!!

    Sinon ça y est, j'ai trouvé comment récupérer tous les controles sans passer par le controller. En fait il suffisait de faire un
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    ((Node)event.getSource()).getScene().getRoot().lookupAll("*")
    Qui te retourne un Set<Node> et tout ça en introspection histoire de rester en JRE6 pour Android..... la classe....

    Voilà
    Voie tu d'autre choses que je devrai travailler ? Sinon je passe à la partie sur Android....
    L'idée serait de créer un projet qui permet d'écrire un application Android directement depuis Android ..... c'te fête si j'y arrive.... ;-)
    Retrouvez tous mes tutoriels : http://caron-yann.developpez.com/

    Et mon projet en cours : Algoid - programming language

    N'oubliez pas de consulter les FAQ Java (http://java.developpez.com/faq/) et les cours et tutoriels Java (http://java.developpez.com/cours/)

  8. #28
    Rédacteur/Modérateur

    Avatar de bouye
    Homme Profil pro
    Information Technologies Specialist (Scientific Computing)
    Inscrit en
    Août 2005
    Messages
    6 840
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 47
    Localisation : Nouvelle-Calédonie

    Informations professionnelles :
    Activité : Information Technologies Specialist (Scientific Computing)
    Secteur : Agroalimentaire - Agriculture

    Informations forums :
    Inscription : Août 2005
    Messages : 6 840
    Points : 22 851
    Points
    22 851
    Billets dans le blog
    51
    Par défaut
    Nop c'est tout Ok pour moi, pour le moment.
    Merci de penser au tag quand une réponse a été apportée à votre question. Aucune réponse ne sera donnée à des messages privés portant sur des questions d'ordre technique. Les forums sont là pour que vous y postiez publiquement vos problèmes.

    suivez mon blog sur Développez.

    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning. ~ Rich Cook

  9. #29
    Rédacteur
    Avatar de CyaNnOrangehead
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Mai 2008
    Messages
    777
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : France, Haute Savoie (Rhône Alpes)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : Aéronautique - Marine - Espace - Armement

    Informations forums :
    Inscription : Mai 2008
    Messages : 777
    Points : 1 731
    Points
    1 731
    Par défaut
    Citation Envoyé par bouye Voir le message
    Nop c'est tout Ok pour moi, pour le moment.
    Super !!!! En tous cas, merci beaucoup de ton aide. Je sais à quel point on est occupé quand on fait partis du team dvp ;-)
    Donc un grand merci à toi.

    De mon coté il me reste à publier cet article et à faire joujou sous android.
    Retrouvez tous mes tutoriels : http://caron-yann.developpez.com/

    Et mon projet en cours : Algoid - programming language

    N'oubliez pas de consulter les FAQ Java (http://java.developpez.com/faq/) et les cours et tutoriels Java (http://java.developpez.com/cours/)

Discussions similaires

  1. [xsl][xalan]Demande d'aide pour un comptage
    Par HomoErectus dans le forum XSL/XSLT/XPATH
    Réponses: 2
    Dernier message: 19/09/2005, 09h22
  2. Demande d'aide pour query difficile
    Par ericjean514 dans le forum MS SQL Server
    Réponses: 4
    Dernier message: 22/02/2005, 18h52
  3. Demande d'aide pour une requête
    Par arkzor dans le forum Requêtes
    Réponses: 3
    Dernier message: 28/12/2004, 02h40
  4. [TPW][cours]Demande d'aide pour finir un programme
    Par jf dans le forum Turbo Pascal
    Réponses: 21
    Dernier message: 16/06/2003, 18h10

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo