Author: jerome
Date: 2008-08-17 08:39:36 +0200 (Sun, 17 Aug 2008)
New Revision: 1529

Modified:
   
software_suite_v2/software/tools/chatterTux/trunk/Chatter_tux/src/ConfInterface.java
Log:
* Displaying currents values of selected action into ChatterTux Configuration 
tool "modify" section.

Modified: 
software_suite_v2/software/tools/chatterTux/trunk/Chatter_tux/src/ConfInterface.java
===================================================================
--- 
software_suite_v2/software/tools/chatterTux/trunk/Chatter_tux/src/ConfInterface.java
        2008-08-17 05:15:57 UTC (rev 1528)
+++ 
software_suite_v2/software/tools/chatterTux/trunk/Chatter_tux/src/ConfInterface.java
        2008-08-17 06:39:36 UTC (rev 1529)
@@ -30,6 +30,7 @@
 import javax.swing.JSpinner;
 import javax.swing.JComboBox;
 import javax.swing.JTextArea;
+import javax.swing.JTextField;
 import javax.swing.SpinnerListModel;
 
 import com.tuxisalive.api.TuxAPI;
@@ -61,23 +62,31 @@
        /* Server functions objects */
        private JRadioButton startServer;
        private JRadioButton stopServer;
+       
        private ButtonGroup group;
        private JButton ok;
        private JButton cancel;
-       private JButton okEdition; //TODO 
+       private JButton okEdition;
+       private JButton deleteEdition;
        private JButton okAdd; //TODO 
        
        /* Voice configuration */
        private JComboBox locutorSet;
+       private JComboBox tuxBody;
        private JSpinner pitchSet;
        
        /* Parametrized values */
        private JComboBox parametrized;
+       private JComboBox actionType;
        private JTextArea parameters = new JTextArea();
+       private JTextField ttsSet;
        
        private File iniFile = new 
File("c:\\tuxdroid\\bin\\chattertux\\ChatterTux.ini");
        private String location;
        
+       //Current tts parsed action.
+       public static String action = "none";
+       
        //** Configuration objects
        Locale locale;
        List<String> installedTuxLanguages;
@@ -168,10 +177,10 @@
                        this.jContentPane = new JPanel();
                        this.jContentPane.setLayout(null);
                        
this.jContentPane.add(this.getVoiceConfigurationPanel());
-                       this.jContentPane.add(this.getActionsPanel());
                        //Adding edition and add Chatter Tux entries panel.
                        this.jContentPane.add(this.getEditPanel());
                        //this.jContentPane.add(this.getAddEntry());
+                       this.jContentPane.add(this.getActionsPanel());
                        
                        this.jContentPane.add(this.getButtonsPanel());
                }
@@ -249,7 +258,7 @@
                        
this.actionModifier.setBorder(BorderFactory.createTitledBorder("Registered 
actions"));
                        this.actionModifier.setLayout(null);
                        Dimension d = this.voiceConfigPanel.getSize();
-                       d.height += 40;
+                       d.height += 20;
                        this.actionModifier.setSize(d);
                        
this.actionModifier.setPreferredSize(this.actionModifier.getSize());
                        int x = this.voiceConfigPanel.getX();
@@ -272,7 +281,7 @@
                        this.parameters = new JTextArea();
                        this.parameters.setEditable(false);
                        
this.parameters.setBackground(this.frame.getBackground());
-                       
this.parameters.setSize(this.voiceConfigPanel.getWidth() - 52, 60);
+                       
this.parameters.setSize(this.voiceConfigPanel.getWidth() - 52, 40);
                        this.parameters.setLocation(new 
Point(this.parametrized.getX(), 60));
                        
                        this.actionModifier.add(this.parameters);
@@ -283,7 +292,6 @@
                                        
if(arg0.getActionCommand().equalsIgnoreCase("comboboxchanged")){
                                                String key = 
parametrized.getModel().getSelectedItem().toString();
                                                setAreaValues(key);
-                                               //TODO set edition panel values 
from selected key.
                                        }
                                }
                                
@@ -364,25 +372,36 @@
                        
this.buttonsPanel.setSize(this.actionModifier.getWidth(), this.ok.getHeight() 
+8);
                        
this.buttonsPanel.setPreferredSize(this.buttonsPanel.getSize());
                        int x = this.editPanel.getX();
-                       int y = this.editPanel.getY() + 4 + 
this.actionModifier.getHeight();
+                       int y = this.editPanel.getY() + 24 + 
this.actionModifier.getHeight();
                        this.buttonsPanel.setLocation(new Point(x, y));
                }
                return this.buttonsPanel;
        }
        
        
-       //TODO 
        //Gets Edit panel.
        public JPanel getEditPanel(){
                if(this.editPanel == null){
                        this.editPanel = new JPanel();
                        this.editPanel.setLayout(null);
-                       this.editPanel.setSize(this.actionModifier.getWidth(), 
this.actionModifier.getHeight());
+                       Dimension d = this.voiceConfigPanel.getSize();
+                       d.height += 40;
+                       this.editPanel.setSize(d);
                        
this.editPanel.setPreferredSize(this.editPanel.getSize());
                        
this.editPanel.setBorder(BorderFactory.createTitledBorder("Modify"));
                        this.editPanel.setVisible(true);
                        
                        //Gettin button.
+                       this.deleteEdition = new JButton("Delete");
+                       this.deleteEdition.setSize(new Dimension(73, 23));
+                       
this.deleteEdition.setPreferredSize(this.deleteEdition.getSize());
+                       this.deleteEdition.setFocusPainted(false);
+                       this.deleteEdition.setLocation(new Point(215, 100));
+                       this.deleteEdition.addMouseListener(new 
java.awt.event.MouseAdapter(){
+                               public void 
mousePressed(java.awt.event.MouseEvent event){
+                                       removeFromIni();
+                               }
+                       });
                        this.okEdition = new JButton("Save");
                        this.okEdition.setSize(new Dimension(73,23));
                        
this.okEdition.setPreferredSize(this.okEdition.getSize());
@@ -394,9 +413,40 @@
                        });
                        this.okEdition.setLocation(new Point(294, 100));
                        this.editPanel.add(this.okEdition);
-                       int x = this.actionModifier.getX();
-                       int y = this.actionModifier.getY() + 4 + 
this.actionModifier.getHeight();
+                       this.editPanel.add(this.deleteEdition);
+                       
+                       int x = this.voiceConfigPanel.getX();
+                       int y = this.voiceConfigPanel.getY() + 26 + 
(this.voiceConfigPanel.getHeight() * 2);
                        this.editPanel.setLocation(new Point(x, y));
+                       
+                       //Create global setting
+                       this.actionType = new JComboBox(new String[]{"Tux 
movement", "Tux TTS"});
+                       this.actionType.setSize(this.locutorSet.getSize());
+                       
this.actionType.setPreferredSize(this.actionType.getSize());
+                       this.actionType.setFocusable(false);
+                       
this.actionType.setLocation(this.locutorSet.getLocation());
+                       this.editPanel.add(this.actionType);
+                       //Create api modification gfx.
+                       this.tuxBody = new JComboBox();
+                       this.tuxBody.addItem("Mouth");
+                       this.tuxBody.addItem("Flippers");
+                       this.tuxBody.addItem("Eyes");
+                       this.tuxBody.addItem("Right led");
+                       this.tuxBody.addItem("Left led");
+                       this.tuxBody.addItem("Both leds");
+                       this.tuxBody.addItem("Spin left");
+                       this.tuxBody.addItem("Spin right");
+                       this.tuxBody.setSize(this.actionType.getSize());
+                       this.tuxBody.setPreferredSize(this.tuxBody.getSize());
+                       this.tuxBody.setFocusable(false);
+                       this.tuxBody.setLocation(new 
Point(this.actionType.getX(), 60));
+                       this.editPanel.add(this.tuxBody);
+                       //Create tts modification gfx.
+                       this.ttsSet = new JTextField();
+                       this.ttsSet.setSize(this.actionType.getSize());
+                       this.ttsSet.setPreferredSize(this.ttsSet.getSize());
+                       this.ttsSet.setLocation(new 
Point(this.actionType.getX(), 60));
+                       this.editPanel.add(this.ttsSet);
                }
                return this.editPanel;
        }
@@ -415,6 +465,11 @@
                
        }
        
+       //TODO remove entry from ini.
+       public void removeFromIni(){
+               
+       }
+       
 /*****************************************************************************/
 /**    Other internals functions. ********************************************/
        /*
@@ -431,11 +486,17 @@
                        action = "Tux say a message";
                        title = "Message: ";
                        value = values.get("cmd");
+                       this.actionType.setSelectedIndex(1);
+                       this.setTTSEditComponentsVivible(true);
+                       this.setEditPanelValues("tts", value);
                }
                else if(values.get("action").equalsIgnoreCase("api")){
                        action = "Tux moves his body";
                        title = "Command: ";
                        value = this.parseCommand(values.get("cmd"));
+                       this.actionType.setSelectedIndex(0);
+                       this.setAPIEditComponentsVisible(true);
+                       this.setEditPanelValues("api", value);
                }
                
                text = "Action: " + action + "\n" + title + value;
@@ -446,23 +507,65 @@
        /*
         * Set modify panel values.
         */
-       //TODO 
-       public void setEditPanelValues(String action){
-               
+       public void setEditPanelValues(String action,String arg){
+               if(action.equalsIgnoreCase("api")){
+                       this.tuxBody.setSelectedItem(ConfInterface.action);
+               }
+               else if(action.equalsIgnoreCase("tts")){
+                       this.ttsSet.setText(arg);
+               }
        }
        
+       
+       public void setTTSEditComponentsVivible(boolean arg0){
+               this.tuxBody.setVisible(false);
+               this.ttsSet.setVisible(true);
+       }
+       
+       
+       public void setAPIEditComponentsVisible(boolean arg0){
+               this.ttsSet.setVisible(false);
+               this.tuxBody.setVisible(true);
+       }
+       
        /*
         * Parse tux api command to return a human comprehensive sentense.
         */
        public String parseCommand(String command){
                StringBuffer returns = new StringBuffer();
                if(command.contains("tux")) returns.append("Tux ");
-               if(command.contains("eyes")) returns.append("open his eyes");
-               else if(command.contains("mouth")) returns.append("open his 
mouth");
-               else if(command.contains("flippers")) returns.append("moves his 
flippers");
-               else if(command.contains("led.both")) returns.append("blink his 
leds");
-               else if(command.contains("led.left")) returns.append("blink his 
left led");
-               else if(command.contains("left.right")) returns.append("blink 
his right led");
+               if(command.contains("eyes")){
+                       ConfInterface.action = "Eyes";
+                       returns.append("open his eyes");
+               }
+               else if(command.contains("mouth")){
+                       ConfInterface.action = "Mouth";
+                       returns.append("open his mouth");
+               }
+               else if(command.contains("flippers")){
+                       ConfInterface.action = "Flippers";
+                       returns.append("moves his flippers");
+               }
+               else if(command.contains("led.both")){
+                       ConfInterface.action = "Both leds";
+                       returns.append("blink his leds");
+               }
+               else if(command.contains("led.left")){
+                       ConfInterface.action = "Left led";
+                       returns.append("blink his left led");
+               }
+               else if(command.contains("left.right")){
+                       ConfInterface.action = "Right led";
+                       returns.append("blink his right led");
+               }
+               else if(command.contains("spinning.left")){
+                       ConfInterface.action = "Spin left";
+                       returns.append("moves to the left");
+               }
+               else if(command.contains("spinning.right")){
+                       ConfInterface.action = "Spin right";
+                       returns.append("moves to the right");
+               }
                
                return returns.toString();
        }


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn

Reply via email to