Author: remi
Date: 2008-08-12 19:27:22 +0200 (Tue, 12 Aug 2008)
New Revision: 1464

Added:
   software_suite_v2/software/tools/attitunesStudio/trunk/META-INF/
   software_suite_v2/software/tools/attitunesStudio/trunk/META-INF/MANIFEST.MF
   software_suite_v2/software/tools/attitunesStudio/trunk/META-INF/services/
   
software_suite_v2/software/tools/attitunesStudio/trunk/META-INF/services/javax.swing.LookAndFeel
   
software_suite_v2/software/tools/attitunesStudio/trunk/src/GUI/AttituneFileFilter.java
Modified:
   software_suite_v2/software/tools/attitunesStudio/trunk/.classpath
   software_suite_v2/software/tools/attitunesStudio/trunk/src/MainFrame.java
   
software_suite_v2/software/tools/attitunesStudio/trunk/src/com/tuxisalive/attitunes/format/ATTBlockParams.java
   
software_suite_v2/software/tools/attitunesStudio/trunk/src/com/tuxisalive/attitunes/format/ATTFormatReadWrite.java
   
software_suite_v2/software/tools/attitunesStudio/trunk/src/com/tuxisalive/attitunes/format/ATTXmlParser.java
   
software_suite_v2/software/tools/attitunesStudio/trunk/src/com/tuxisalive/attitunes/visual/ATTBlockViewer.java
Log:
* update

Modified: software_suite_v2/software/tools/attitunesStudio/trunk/.classpath
===================================================================
--- software_suite_v2/software/tools/attitunesStudio/trunk/.classpath   
2008-08-11 14:00:52 UTC (rev 1463)
+++ software_suite_v2/software/tools/attitunesStudio/trunk/.classpath   
2008-08-12 17:27:22 UTC (rev 1464)
@@ -2,6 +2,7 @@
 <classpath>
        <classpathentry kind="src" path="src"/>
        <classpathentry including="*.PNG|*.att|*.png" kind="src" path="images"/>
-       <classpathentry kind="con" 
path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+       <classpathentry exported="true" kind="con" 
path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+       <classpathentry kind="lib" path="C:/tuxdroid/lib/looks-2.1.4.jar"/>
        <classpathentry kind="output" path="bin"/>
 </classpath>

Added: 
software_suite_v2/software/tools/attitunesStudio/trunk/META-INF/MANIFEST.MF
===================================================================
--- software_suite_v2/software/tools/attitunesStudio/trunk/META-INF/MANIFEST.MF 
                        (rev 0)
+++ software_suite_v2/software/tools/attitunesStudio/trunk/META-INF/MANIFEST.MF 
2008-08-12 17:27:22 UTC (rev 1464)
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Main-Class: main
+Class-Path: ./attitunesStudio.jar; ./looks-2.1.4.jar

Added: 
software_suite_v2/software/tools/attitunesStudio/trunk/META-INF/services/javax.swing.LookAndFeel
===================================================================
--- 
software_suite_v2/software/tools/attitunesStudio/trunk/META-INF/services/javax.swing.LookAndFeel
                            (rev 0)
+++ 
software_suite_v2/software/tools/attitunesStudio/trunk/META-INF/services/javax.swing.LookAndFeel
    2008-08-12 17:27:22 UTC (rev 1464)
@@ -0,0 +1,8 @@
+# JGoodies Plastic L&F - replacement for Metal
+com.jgoodies.looks.plastic.PlasticLookAndFeel
+# JGoodies Plastic 3D L&F
+com.jgoodies.looks.plastic.Plastic3DLookAndFeel
+# JGoodies Plastic XP L&F
+com.jgoodies.looks.plastic.PlasticXPLookAndFeel
+# JGoodies Windows L&F
+com.jgoodies.looks.windows.WindowsLookAndFeel

Added: 
software_suite_v2/software/tools/attitunesStudio/trunk/src/GUI/AttituneFileFilter.java
===================================================================
--- 
software_suite_v2/software/tools/attitunesStudio/trunk/src/GUI/AttituneFileFilter.java
                              (rev 0)
+++ 
software_suite_v2/software/tools/attitunesStudio/trunk/src/GUI/AttituneFileFilter.java
      2008-08-12 17:27:22 UTC (rev 1464)
@@ -0,0 +1,23 @@
+package GUI;
+
+import java.io.*;
+
+public class AttituneFileFilter extends javax.swing.filechooser.FileFilter
+{
+       public boolean accept(File file) {
+        String filename = file.getName();
+        if (file.isDirectory())
+        {
+               return true;
+        }
+        else
+        {
+               return filename.endsWith(".att");
+        }
+    }
+       
+    public String getDescription() {
+        return "Attitune files";
+    }
+
+}

Modified: 
software_suite_v2/software/tools/attitunesStudio/trunk/src/MainFrame.java
===================================================================
--- software_suite_v2/software/tools/attitunesStudio/trunk/src/MainFrame.java   
2008-08-11 14:00:52 UTC (rev 1463)
+++ software_suite_v2/software/tools/attitunesStudio/trunk/src/MainFrame.java   
2008-08-12 17:27:22 UTC (rev 1464)
@@ -7,11 +7,10 @@
 import java.awt.event.MouseEvent;
 import java.awt.event.WindowAdapter;
 import java.awt.event.WindowEvent;
-import java.awt.Color;
 import java.awt.*;
 import java.util.Hashtable;
 
-import javax.swing.ImageIcon;
+import javax.swing.*;
 import com.tuxisalive.attitunes.*;
 import com.tuxisalive.attitunes.format.*;
 import com.tuxisalive.attitunes.block.ATTBlock;
@@ -19,6 +18,8 @@
 import com.tuxisalive.attitunes.visual.ATTBlockViewer;
 import com.tuxisalive.attitunes.visual.ATTSButton;
 
+import java.io.*;
+
 //import javax.swing.JOptionPane;
 
 /**
@@ -46,6 +47,17 @@
        private ATTSButton pastButton;
        private ATTSButton playButton;
        private ATTSButton stopButton;
+       
+       private JFileChooser fileChooser;
+       
+       {
+               //Set Look & Feel
+               try {
+                       
javax.swing.UIManager.setLookAndFeel("com.jgoodies.looks.plastic.Plastic3DLookAndFeel");
+               } catch(Exception e) {
+                       e.printStackTrace();
+               }
+       }
 
        /**
         * MainFrame constructor
@@ -132,9 +144,6 @@
                        
attBlockViewer.events.register(ATTConfig.EVENT_ATTITUNE_LOADED, this, 
"onAttituneLoaded");
                        
attBlockViewer.events.register(ATTConfig.EVENT_ATTITUNE_SAVED, this, 
"onAttituneSaved");
                        
-                       /* Load a file */
-                       
attBlockViewer.loadAttitune(ATTResources.getRealPath("aero.att"));
-                       
                        /* Zoom plus button */
                        zoomPlusButton = new ATTSButton("/zoomPlusButton.png");
                        zoomPlusButton.setPressedIcon(new 
ImageIcon(getClass().getResource("/zoomPressedButton.png")));
@@ -235,9 +244,18 @@
                        attBlockViewer.add(stopButton, new AnchorConstraint(10, 
273));
                        attBlockViewer.repaint();
                        
+                       /* Create the file chooser */
+                       fileChooser = new JFileChooser();
+                       
fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
+                       fileChooser.addChoosableFileFilter(new 
AttituneFileFilter());
+                       
                        /* Pack the components and set the frame size */
                        pack();
                        setSize(648, 400);
+                       
+                       /* Load the template file */
+                       
attBlockViewer.loadAttitune("C:/tuxdroid/resources/templates/template.att");
+                       attBlockViewer.setAttituneIsTemplate(true);
                }
                catch (Exception e)
                {
@@ -254,8 +272,7 @@
         */
        private void thisWindowClosing(WindowEvent evt)
        {
-               attBlockViewer.destroy();
-               System.exit(0);
+               onMenuItemQuit(null);
        }
        
        /* 
------------------------------------------------------------------------
@@ -267,7 +284,25 @@
         */
        public void onMenuItemNew(MenuItem menuItem)
        {
-               System.out.println("New");
+               /* Check if the current scene need to be saved */
+               if (attBlockViewer.getSceneHaveChanged())
+               {
+                       /* Save the changes first */
+                       int result = JOptionPane.showConfirmDialog(
+                                       this,
+                                       "Save changes before to continue ?",
+                                       "Scene have changed",
+                                       JOptionPane.YES_NO_OPTION);
+                       if (result == JOptionPane.YES_OPTION)
+                       {
+                               onMenuItemSave(menuItem);
+                       }
+               }
+               /* Load the template */
+               if 
(attBlockViewer.loadAttitune("C:/tuxdroid/resources/templates/template.att"))
+               {
+                       attBlockViewer.setAttituneIsTemplate(true);
+               }       
        }
        
        /*
@@ -279,9 +314,33 @@
                if (attBlockViewer.getSceneHaveChanged())
                {
                        /* Save the changes first */
-                       /* if not changed exit the function */
+                       int result = JOptionPane.showConfirmDialog(
+                                       this,
+                                       "Save changes before to continue ?",
+                                       "Scene have changed",
+                                       JOptionPane.YES_NO_OPTION);
+                       if (result == JOptionPane.YES_OPTION)
+                       {
+                               onMenuItemSave(menuItem);
+                       }
                }
                /* Load a file viewer to select an attitune */
+               if (fileChooser.showOpenDialog(this) == 1)
+               {
+                       return;
+               }
+               File selFile = fileChooser.getSelectedFile();
+               if (selFile == null)
+               {
+                       return;
+               }
+               if (selFile.getPath().endsWith(".att"))
+               {
+                       if (attBlockViewer.loadAttitune(selFile.getPath()))
+                       {
+                               attBlockViewer.setAttituneIsTemplate(false);
+                       }
+               }
        }
        
        /*
@@ -289,13 +348,16 @@
         */
        public void onMenuItemSave(MenuItem menuItem)
        {
-               /* Check if the current scene if the template */
+               /* Check if the current scene is the template */
                if (attBlockViewer.getAttituneIsTemplate())
                {
                        onMenuItemSaveAs(menuItem);
                }
                /* Save the attitune */
-               //attBlockViewer
+               else
+               {
+                       
attBlockViewer.saveAttitune(attBlockViewer.attituneFile.getAttFilePath());
+               }
        }
 
        /*
@@ -303,7 +365,26 @@
         */
        public void onMenuItemSaveAs(MenuItem menuItem)
        {
-               System.out.println("Save as");
+               /* Open a file viewer to select an attitune */
+               if (fileChooser.showSaveDialog(this) == 1)
+               {
+                       return;
+               }
+               File selFile = fileChooser.getSelectedFile();
+               if (selFile == null)
+               {
+                       return;
+               }
+               
+               attBlockViewer.checkHeader();
+               
+               if (selFile.getPath().endsWith(".att"))
+               {
+                       if (attBlockViewer.saveAttitune(selFile.getPath()))
+                       {
+                               attBlockViewer.setAttituneIsTemplate(false);
+                       }
+               }
        }
        
        /*
@@ -319,7 +400,23 @@
         */
        public void onMenuItemQuit(MenuItem menuItem)
        {
-               System.out.println("Quit");
+               /* Check if the current scene need to be saved */
+               if (attBlockViewer.getSceneHaveChanged())
+               {
+                       /* Save the changes first */
+                       int result = JOptionPane.showConfirmDialog(
+                                       this,
+                                       "Save changes before to continue ?",
+                                       "Scene have changed",
+                                       JOptionPane.YES_NO_OPTION);
+                       if (result == JOptionPane.YES_OPTION)
+                       {
+                               onMenuItemSave(menuItem);
+                       }
+               }
+               /* Destroy the viewer an exit the application */
+               attBlockViewer.destroy();
+               System.exit(0);
        }
        
        /*
@@ -462,6 +559,7 @@
        {
                statusBar.setLabel1("Position : " + 
ATTMisc.timeToString(attBlockViewer.getCurrentPosition()));
                statusBar.setLabel2("Duration : " + 
ATTMisc.timeToString(attBlockViewer.getLength()));
+               statusBar.setLabel3("Block start : 00:00:00");
        }
        
        /*
@@ -543,7 +641,6 @@
        public void onPlayButtonPressed(MouseEvent evt)
        {
                attBlockViewer.playScene(attBlockViewer.getCurrentPosition());
-               attBlockViewer.saveAttitune("c:\\aero3.att");
        }
        
        /*

Modified: 
software_suite_v2/software/tools/attitunesStudio/trunk/src/com/tuxisalive/attitunes/format/ATTBlockParams.java
===================================================================
--- 
software_suite_v2/software/tools/attitunesStudio/trunk/src/com/tuxisalive/attitunes/format/ATTBlockParams.java
      2008-08-11 14:00:52 UTC (rev 1463)
+++ 
software_suite_v2/software/tools/attitunesStudio/trunk/src/com/tuxisalive/attitunes/format/ATTBlockParams.java
      2008-08-12 17:27:22 UTC (rev 1464)
@@ -427,7 +427,7 @@
        /*
         * Locutor name list
         */
-       private static String[] LOCUTOR_NAMES_LIST = {
+       public static String[] LOCUTOR_NAMES_LIST = {
                              "Bruno8k", "Julie8k", "Ryan8k", 
"Heather8k","Sofie8k", 
                              "Klaus8k", "Sarah8k", "Graham8k","Lucy8k", 
"Salma8k", 
                              "Mette8k", "Maria8k", "Chiara8k", "Femke8k", 
"Kari8k", 

Modified: 
software_suite_v2/software/tools/attitunesStudio/trunk/src/com/tuxisalive/attitunes/format/ATTFormatReadWrite.java
===================================================================
--- 
software_suite_v2/software/tools/attitunesStudio/trunk/src/com/tuxisalive/attitunes/format/ATTFormatReadWrite.java
  2008-08-11 14:00:52 UTC (rev 1463)
+++ 
software_suite_v2/software/tools/attitunesStudio/trunk/src/com/tuxisalive/attitunes/format/ATTFormatReadWrite.java
  2008-08-12 17:27:22 UTC (rev 1464)
@@ -95,7 +95,15 @@
                /* Get the blocks structure from the xml structure */
                blocksStruct = (Hashtable)xmlStruct.get("body");
                blocksStruct = (Hashtable)blocksStruct.get("script");
-               blocksStruct = (Hashtable)blocksStruct.get("timeline");
+               if (((Hashtable)blocksStruct).containsKey("timeline"))
+               {
+                       blocksStruct = (Hashtable)blocksStruct.get("timeline");
+               }
+               else
+               {
+                       blocksStruct = new Hashtable<String,Object>();
+               }
+               System.out.println(blocksStruct);
                
                /* Get the header structure */
                headerStruct = (Hashtable)xmlStruct.get("header");
@@ -145,7 +153,7 @@
                String newWorkPath = tmpAttDir.getPath() + File.separator + 
newFileName + File.separator;
                
                /* Copy the new directory if != of the current one */
-               if (newFileName != attFileName)
+               if (!newFileName.equals(attFileName))
                {
                        String destDir = newWorkPath + newFileName + 
File.separator;
                        String srcDir = attWorkPath + attFileName + 
File.separator;
@@ -174,7 +182,16 @@
                return attFilePath;
        }
        
+       /**
+        * 
+        * @return
+        */
+       public String getAttFileName()
+       {
+               return attFileName;
+       }
        
+       
        /**
         * 
         * @return

Modified: 
software_suite_v2/software/tools/attitunesStudio/trunk/src/com/tuxisalive/attitunes/format/ATTXmlParser.java
===================================================================
--- 
software_suite_v2/software/tools/attitunesStudio/trunk/src/com/tuxisalive/attitunes/format/ATTXmlParser.java
        2008-08-11 14:00:52 UTC (rev 1463)
+++ 
software_suite_v2/software/tools/attitunesStudio/trunk/src/com/tuxisalive/attitunes/format/ATTXmlParser.java
        2008-08-12 17:27:22 UTC (rev 1464)
@@ -186,7 +186,15 @@
                                e = (Element)childNode;
                                childType = e.getAttribute("type");
                                childName = childNode.getNodeName();
-                               childValue = 
childNode.getFirstChild().getNodeValue();
+                               if (!childNode.hasChildNodes())
+                               {
+                                       childValue = "";
+                                       childType = "str";
+                               }
+                               else
+                               {
+                                       childValue = 
childNode.getFirstChild().getNodeValue();
+                               }
                                
                                if (childType.equals("str"))
                                {

Modified: 
software_suite_v2/software/tools/attitunesStudio/trunk/src/com/tuxisalive/attitunes/visual/ATTBlockViewer.java
===================================================================
--- 
software_suite_v2/software/tools/attitunesStudio/trunk/src/com/tuxisalive/attitunes/visual/ATTBlockViewer.java
      2008-08-11 14:00:52 UTC (rev 1463)
+++ 
software_suite_v2/software/tools/attitunesStudio/trunk/src/com/tuxisalive/attitunes/visual/ATTBlockViewer.java
      2008-08-12 17:27:22 UTC (rev 1464)
@@ -261,6 +261,15 @@
        
        /**
         * 
+        * @param value
+        */
+       public void setAttituneIsTemplate(boolean value)
+       {
+               attituneIsTemplate = value;
+       }
+       
+       /**
+        * 
         * @param path
         * @return
         */
@@ -462,12 +471,12 @@
                        if (scrollbarIsFocused)
                        {
                                scrollbarIsFocused = false;
-                               sceneHaveChanged = true;
                                
events.emit(ATTConfig.EVENT_SCROLLBAR_DRAG_STOPPED);
                        }
                        if (draggingBlock)
                        {
                                draggingBlock = false;
+                               sceneHaveChanged = true;
                                events.emit(ATTConfig.EVENT_BLOCK_DRAG_STOPPED, 
(ATTBlock)focusedBlock);
                        }
                        
@@ -1202,6 +1211,23 @@
        
        /**
         * 
+        */
+       public void deleteAllBlocks()
+       {
+               for (int i = 0; i < blockContainers.length; i++)
+               {
+                       for (int j = 0; j < blockContainers[i].blocks.size(); 
j++)
+                       {
+                               blockContainers[i].deleteBlock(j);
+                       }
+               }
+               recalcFullTime();
+               this.repaint();
+               sceneHaveChanged = true;
+       }
+       
+       /**
+        * 
         * @param attFilePath
         * @return
         */
@@ -1216,6 +1242,9 @@
                        return false;
                }
                
+               /* Delete old blocks */
+               deleteAllBlocks();
+               
                /* Load blocks */
                Hashtable<String,Object> blocksStruct = 
attituneFile.getBocksStruct();
                Hashtable<String,Object> blockStruct;
@@ -1225,6 +1254,10 @@
                while (it.hasNext())
                {
                        key = (String)it.next();
+                       if (key.equals("truc"))
+                       {
+                               break;
+                       }
                        blockStruct = 
(Hashtable<String,Object>)blocksStruct.get(key);
                        Double startTime = 
(Double)blockStruct.get("start_time");
                        Double duration = (Double)blockStruct.get("duration");
@@ -1258,6 +1291,8 @@
                
                this.repaint();
                attituneIsTemplate = false;
+               sceneHaveChanged = false;
+               focusedRowIndex = 0;
                events.emit(ATTConfig.EVENT_ATTITUNE_LOADED, this);
                return true;
        }
@@ -1277,7 +1312,7 @@
                {
                        return false;
                }
-               sceneHaveChanged = true;
+               sceneHaveChanged = false;
                events.emit(ATTConfig.EVENT_ATTITUNE_SAVED, this);
                
                /* Reload the attitune */
@@ -1486,4 +1521,127 @@
                
                return newBlock;
        }
+       
+       /**
+        * 
+        * @return
+        */
+       public List<String> checkHeader()
+       {
+               List<String> result = new ArrayList<String>();
+               
+               /* Check author */
+               if (attituneFile.getHeaderAuthor().equals(""))
+               {
+                       attituneFile.setHeaderAuthor("Attitune freak");
+               }
+               
+               /* Check name */
+               if (attituneFile.getHeaderName().equals("") ||
+                       attituneFile.getHeaderName().equals("template"))
+               {
+                       
attituneFile.setHeaderName(attituneFile.getAttFileName());
+               }
+               
+               /* Set the length */
+               attituneFile.setHeaderLength(getLength());
+               
+               /* Check version */
+               if (attituneFile.getHeaderVersion().equals(""))
+               {
+                       attituneFile.setHeaderVersion("1.0");
+               }
+               
+               /* Check description */
+               if (attituneFile.getHeaderDescription().equals(""))
+               {
+                       result.add("description");
+               }
+               
+               /* Check category */
+               if (attituneFile.getHeaderCategory().equals(""))
+               {
+                       result.add("category");
+               }
+               
+               /* Check sub category */
+               if (attituneFile.getHeaderSubCategory().equals(""))
+               {
+                       result.add("sub_category");
+               }
+               
+               /* Check keywords */
+               if (attituneFile.getHeaderKeywords().equals(""))
+               {
+                       
attituneFile.setHeaderKeywords(attituneFile.getHeaderCategory() + ", " + 
attituneFile.getHeaderSubCategory());
+               }
+               
+               /*
+                * Check language
+                */
+               /* Get the first tts block */
+               if (blockContainers[ATTConfig.BLOCK_TYPE_TTS].blocks.size() > 0)
+               {
+                       ATTBlock block = 
blockContainers[ATTConfig.BLOCK_TYPE_TTS].blocks.get(0);
+                       Hashtable<String,Object> blockStruct = 
block.getFunctionParams();
+                       if (blockStruct.containsKey("speaker"))
+                       {
+                               String speakerName = 
ATTBlockParams.LOCUTOR_NAMES_LIST[(Integer)blockStruct.get("speaker")-1];
+                               if (speakerName.equals("Bruno8k"))
+                               {
+                                       
attituneFile.setHeaderLanguage("French");
+                               }
+                               else if (speakerName.equals("Julie8k"))
+                               {
+                                       
attituneFile.setHeaderLanguage("French");
+                               }
+                               else if (speakerName.equals("Ryan8k"))
+                               {
+                                       attituneFile.setHeaderLanguage("US 
English");
+                               }
+                               else if (speakerName.equals("Heather8k"))
+                               {
+                                       attituneFile.setHeaderLanguage("US 
English");
+                               }
+                               else if (speakerName.equals("Sofie8k"))
+                               {
+                                       attituneFile.setHeaderLanguage("Be 
Dutch");
+                               }
+                               else if (speakerName.equals("Klaus8k"))
+                               {
+                                       
attituneFile.setHeaderLanguage("German");
+                               }
+                               else if (speakerName.equals("Sarah8k"))
+                               {
+                                       
attituneFile.setHeaderLanguage("German");
+                               }
+                               else if (speakerName.equals("Graham8k"))
+                               {
+                                       attituneFile.setHeaderLanguage("UK 
English");
+                               }
+                               else if (speakerName.equals("Lucy8k"))
+                               {
+                                       attituneFile.setHeaderLanguage("UK 
English");
+                               }
+                               else if (speakerName.equals("Femke8k"))
+                               {
+                                       attituneFile.setHeaderLanguage("Nl 
Dutch");
+                               }
+                               else
+                               {
+                                       attituneFile.setHeaderLanguage("None");
+                               }
+                       }
+                       else
+                       {
+                               attituneFile.setHeaderLanguage("None");
+                       }
+               }
+               else
+               {
+                       attituneFile.setHeaderLanguage("None");
+               }
+               
+               return result;
+       }
 }


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