Author: jerome
Date: 2008-08-16 14:09:17 +0200 (Sat, 16 Aug 2008)
New Revision: 1516

Modified:
   software_suite_v2/software/tools/chatterTux/trunk/Chatter_tux/.classpath
   
software_suite_v2/software/tools/chatterTux/trunk/Chatter_tux/src/ConfInterface.java
   
software_suite_v2/software/tools/chatterTux/trunk/Chatter_tux/src/IniFile.java
   
software_suite_v2/software/tools/chatterTux/trunk/Chatter_tux/src/Properties.java
Log:
* Fixed bug into hashtable.

Modified: 
software_suite_v2/software/tools/chatterTux/trunk/Chatter_tux/.classpath
===================================================================
--- software_suite_v2/software/tools/chatterTux/trunk/Chatter_tux/.classpath    
2008-08-16 10:32:25 UTC (rev 1515)
+++ software_suite_v2/software/tools/chatterTux/trunk/Chatter_tux/.classpath    
2008-08-16 12:09:17 UTC (rev 1516)
@@ -3,7 +3,5 @@
        <classpathentry kind="src" path="src"/>
        <classpathentry kind="con" 
path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
        <classpathentry combineaccessrules="false" kind="src" path="/TuxAPI"/>
-       <classpathentry kind="lib" path="C:/Users/pc/Desktop/ini4j-0.3.2.jar"/>
-       <classpathentry kind="lib" 
path="C:/Users/pc/Desktop/ini4j-0.3.2-jdk14.jar"/>
        <classpathentry kind="output" path="bin"/>
 </classpath>

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-16 10:32:25 UTC (rev 1515)
+++ 
software_suite_v2/software/tools/chatterTux/trunk/Chatter_tux/src/ConfInterface.java
        2008-08-16 12:09:17 UTC (rev 1516)
@@ -26,14 +26,23 @@
 import javax.swing.JPanel;
 import javax.swing.JSpinner;
 import javax.swing.JComboBox;
+import javax.swing.JTextArea;
 import javax.swing.SpinnerListModel;
+import javax.swing.event.ListDataEvent;
+import javax.swing.event.ListDataListener;
+import javax.swing.event.ListSelectionEvent;
 
+import sun.awt.SunHints.Value;
+
 import com.tuxisalive.api.TuxAPI;
 import com.tuxisalive.api.TuxAPIConst;
 
 import java.awt.Dimension;
 import java.awt.Point;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
 import java.io.File;
+import java.util.Hashtable;
 import java.util.List;
 import java.util.Locale;
 
@@ -47,9 +56,14 @@
        private JPanel voiceConfigPanel;
        private JPanel actionModifier;
        
+       /* Voice configuration */
        private JComboBox locutorSet;
        private JSpinner pitchSet;
        
+       /* Parametrized values */
+       private JComboBox parametrized;
+       private JTextArea parameters = new JTextArea();
+       
        private File iniFile = new 
File("c:\\tuxdroid\\bin\\chattertux\\ChatterTux.ini");
        private String location;
        
@@ -66,13 +80,14 @@
 
        public ConfInterface(){
                if(iniFile.isFile()){
-                       this.getFrame();
-                       locale = Locale.getDefault(); //Getting language.
                        
                        //Getting ini file.
                        this.ini = new IniFile(this.iniFile);
                        this.properties = new 
Properties(this.ini.getHashtable());
                        
+                       this.getFrame();
+                       locale = Locale.getDefault(); //Getting language.
+                       
                        //Create tux api object.
                        this.api = new TuxAPI("127.0.0.1", 270);
                        api.event.handler.register("all", api, "onAllEvent");
@@ -178,13 +193,53 @@
                        this.actionModifier = new JPanel();
                        
this.actionModifier.setBorder(BorderFactory.createTitledBorder("Registered 
actions"));
                        this.actionModifier.setLayout(null);
-                       this.actionModifier.setSize(new 
Dimension(voiceConfigPanel.getSize()));
+                       Dimension d = this.voiceConfigPanel.getSize();
+                       d.height += 40;
+                       this.actionModifier.setSize(d);
                        
this.actionModifier.setPreferredSize(this.actionModifier.getSize());
-                       int x = this.voiceConfigPanel.getX() +4 
+this.voiceConfigPanel.getHeight();
-                       int y = this.voiceConfigPanel.getY() + 4 + 
this.voiceConfigPanel.getWidth();
+                       int x = this.voiceConfigPanel.getX();
+                       int y = this.voiceConfigPanel.getY() + 4 + 
this.voiceConfigPanel.getHeight();
                        this.actionModifier.setLocation(new Point(x, y));
+                       //Setting combobox
+                       this.parametrized = new JComboBox();
+                       
+                       for(int i=1; i < this.ini.getLength(); i++){
+                               
this.parametrized.addItem((String)this.ini.getKeyAtIndex(i));
+                       }
+                       
+                       this.parametrized.setSize(this.locutorSet.getSize());
+                       
this.parametrized.setPreferredSize(this.parametrized.getSize());
+                       
this.parametrized.setLocation(this.locutorSet.getLocation());
+                       this.actionModifier.add(this.parametrized);
+                       
+                       //Setting parameters display area.
+                       this.parameters = new JTextArea();
+                       this.parameters.setEditable(false);
+                       
this.parameters.setBackground(this.frame.getBackground());
+                       
this.parameters.setSize(this.voiceConfigPanel.getWidth() - 52, 60);
+                       this.parameters.setLocation(new 
Point(this.parametrized.getX(), 60));
+                       
+                       this.actionModifier.add(this.parameters);
+                       
+                       this.parametrized.addActionListener(new 
ActionListener(){
+
+                               public void actionPerformed(ActionEvent arg0) {
+                                       
if(arg0.getActionCommand().equalsIgnoreCase("comboboxchanged")){
+                                               String key = 
parametrized.getModel().getSelectedItem().toString();
+                                               Hashtable <String, String> 
values = properties.getProperties(key);
+                                               String text = ("Action: " + 
values.get("action").toString());
+                                               String title = "";
+                                               
if(values.get("action").equalsIgnoreCase("tts")) title = "Message: ";
+                                               else 
if(values.get("action").equalsIgnoreCase("api")) title = "Command: ";
+                                               text += "\n" + title + 
values.get("cmd");
+                                               parameters.setText(text);
+                                       }
+                               }
+                               
+                       });
                }
                return this.actionModifier;
        }
+
        
 }

Modified: 
software_suite_v2/software/tools/chatterTux/trunk/Chatter_tux/src/IniFile.java
===================================================================
--- 
software_suite_v2/software/tools/chatterTux/trunk/Chatter_tux/src/IniFile.java  
    2008-08-16 10:32:25 UTC (rev 1515)
+++ 
software_suite_v2/software/tools/chatterTux/trunk/Chatter_tux/src/IniFile.java  
    2008-08-16 12:09:17 UTC (rev 1516)
@@ -28,39 +28,27 @@
 import java.util.Hashtable;
 import java.util.Vector;
 
-import org.ini4j.Ini;
-
 public class IniFile {
        
        private File file;
-       private Ini ini;
-       private Hashtable<String, Vector<String>> keys;
-       private Hashtable<Integer, String> indexes;
+       private Hashtable<String, Vector<String>> keys = new Hashtable<String, 
Vector<String>>();
+       private Hashtable<Integer, String> indexes = new Hashtable<Integer, 
String>();
        
        public IniFile(File file){
                this.file = file;
-               ini = new Ini();
                try {
-                       //ini.load(new URL(file.getAbsolutePath()));
-                       this.keys = this.getKeys(this.file);
+                       this.getKeys(this.file);
                } catch (Exception except){ except.printStackTrace(); }
        }
        
        
-       public void parse(){
-               
-       }
-       
-       
        /**
         * This function gets keys into .ini file and store an index to each 
key.
         * @param file
         * @return
         * @throws Exception
         */
-       private Hashtable<String, Vector<String>> getKeys(File file) throws 
Exception{
-               Hashtable<String, Vector<String>> keys = new Hashtable<String, 
Vector<String>>();
-               Hashtable<Integer, String> indexes = new Hashtable<Integer, 
String>();
+       private void getKeys(File file) throws Exception{
                Vector<String> values = new Vector<String>();
                String storedKeys = "";
                
@@ -69,8 +57,7 @@
                InputStreamReader ipsr=new InputStreamReader(ips);
                BufferedReader br=new BufferedReader(ipsr);
                String ligne;
-               while ((ligne=br.readLine())!=null){
-                       
+               while ((ligne=br.readLine()) != null){
                        if(ligne.contains("[") && ligne.contains("]")){
                                //then it's a key.
                                storedKeys = ligne.replace("[", 
"").replace("]", "");
@@ -78,18 +65,14 @@
                        }
                        else if(ligne.contains("=")){
                                //then it's a key value.
-                               values.add(ligne);
+                               values.addElement(ligne);
                        }
-                       else{
+                       if(values.size()== 2){
                                keys.put(storedKeys, values);
-                               //Then it's an unwrited ligne. So register new 
Hash table value.
-                               values.removeAllElements();
+                               values = new Vector<String>();
                        }
                }
-               
                br.close(); 
-               this.indexes = indexes;
-               return keys;
        }
        
        
@@ -119,10 +102,19 @@
                return (Vector<String>)this.keys.get(key);
        }
        
+       
        /*
         * Return complete hash table.
         */
        public Hashtable<String, Vector<String>> getHashtable(){
                return this.keys;
        }
+       
+       
+       /*
+        * Return number of keys.
+        */
+       public int getLength(){
+               return this.keys.size();
+       }
 }

Modified: 
software_suite_v2/software/tools/chatterTux/trunk/Chatter_tux/src/Properties.java
===================================================================
--- 
software_suite_v2/software/tools/chatterTux/trunk/Chatter_tux/src/Properties.java
   2008-08-16 10:32:25 UTC (rev 1515)
+++ 
software_suite_v2/software/tools/chatterTux/trunk/Chatter_tux/src/Properties.java
   2008-08-16 12:09:17 UTC (rev 1516)
@@ -47,7 +47,6 @@
                                table.put(tmp, tmp2);
                        }
                }
-               
                return table;
        }
        


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