Author: jerome Date: 2008-08-16 18:20:16 +0200 (Sat, 16 Aug 2008) New Revision: 1520
Removed: software_suite_v2/software/tools/chatterTux/trunk/Chatter_tux/src/ChatterTux.java Modified: software_suite_v2/software/tools/chatterTux/trunk/Chatter_tux/src/ConfInterface.java software_suite_v2/software/tools/chatterTux/trunk/Chatter_tux/src/ct_main.java Log: * Merged action chooser interface with configuration interface. Deleted: software_suite_v2/software/tools/chatterTux/trunk/Chatter_tux/src/ChatterTux.java =================================================================== --- software_suite_v2/software/tools/chatterTux/trunk/Chatter_tux/src/ChatterTux.java 2008-08-16 15:34:59 UTC (rev 1519) +++ software_suite_v2/software/tools/chatterTux/trunk/Chatter_tux/src/ChatterTux.java 2008-08-16 16:20:16 UTC (rev 1520) @@ -1,167 +0,0 @@ -/* This file is part of "TuxDroid Chatter Tux tool". - * Copyright 2008, kysoh - * Author : Conan Jerome - * eMail : [EMAIL PROTECTED] - * Site : http://www.kysoh.com/ - * - * "TuxDroid Chatter Tux tool" is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * "TuxDroid Chatter Tux tool" is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with "TuxDroid Control Center"; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ - -import java.awt.Dimension; -import java.awt.Font; -import java.awt.Point; - -import javax.swing.ButtonGroup; -import javax.swing.JButton; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JRadioButton; - -public class ChatterTux { - - /** Chatter Tux component **/ - private JFrame frame; - private JPanel jContentPane; - private JRadioButton configure; - private JRadioButton startServer; - private JRadioButton stopServer; - private ButtonGroup group; - private JLabel Message = new JLabel("Select Chatter Tux action"); - private JButton ok; - private JButton cancel; - - /** - * Class constructor. - */ - public ChatterTux(){ - - frame = this.getFrame(); - frame.add(this.getContentPane()); - frame.setResizable(false); - - frame.pack(); - } - - - /** - * @return application frame. - */ - public JFrame getFrame(){ - if(this.frame == null){ - frame = new JFrame("Chatter Tux"); - frame.setSize(new Dimension(250, 180)); - frame.setPreferredSize(frame.getSize()); - - frame.setVisible(true); - } - return this.frame; - } - - /** - * @return contentPane. - */ - public JPanel getContentPane(){ - if(this.jContentPane == null){ - jContentPane = new JPanel(); - jContentPane.setLayout(null); - jContentPane.add(this.getConfigure()); - jContentPane.add(this.getStartServer()); - jContentPane.add(this.getStopServer()); - this.Message.setSize(new Dimension(200, 20)); - this.Message.setLocation(new Point(10, 4)); - this.Message.setFont(new Font("verdana", Font.BOLD, 11)); - jContentPane.add(this.Message); - jContentPane.add(this.getOkButton()); - jContentPane.add(this.getCancelButton()); - this.group = new ButtonGroup(); - this.group.add(this.configure); - this.group.add(this.startServer); - this.group.add(this.stopServer); - } - return jContentPane; - } - - - public JRadioButton getConfigure(){ - if(this.configure == null){ - configure = new JRadioButton("Configure"); - configure.setSize(new Dimension(100,25)); - configure.setLocation(new Point(20, 30)); - } - return this.configure; - } - - public JRadioButton getStartServer(){ - if(this.startServer == null){ - this.startServer = new JRadioButton("Start Chatter"); - this.startServer.setSize(new Dimension(100, 25)); - this.startServer.setLocation(new Point(20, 55)); - } - return this.startServer; - } - - - public JRadioButton getStopServer(){ - if(this.stopServer == null){ - this.stopServer = new JRadioButton("Stop Chatter"); - this.stopServer.setSize(new Dimension(100, 25)); - this.stopServer.setLocation(new Point(20, 80)); - } - return this.stopServer; - } - - public JButton getOkButton(){ - if(this.ok == null){ - this.ok = new JButton("Ok"); - this.ok.setSize(new Dimension(80,24)); - this.ok.setLocation(new Point(24, 115)); - this.ok.addMouseListener(new java.awt.event.MouseAdapter(){ - public void mousePressed(java.awt.event.MouseEvent event){ - if(group.getSelection().equals(configure.getModel())){ - new ConfInterface(); //launch configuration interface. - frame.setVisible(false); - }else if(group.getSelection().equals(startServer.getModel())){ - //Start chatter Tux - ChatterTuxServer.start(); - System.exit(0); - } - else{ //Stop chatter tux. - ChatterTuxServer.stop(); - System.exit(0); - } - } - }); - } - return this.ok; - } - - - public JButton getCancelButton(){ - if(this.cancel == null){ - this.cancel = new JButton("Cancel"); - cancel.setSize(new Dimension(80, 24)); - cancel.setLocation(new Point(110, 115)); - cancel.addMouseListener(new java.awt.event.MouseAdapter(){ - public void mouseClicked(java.awt.event.MouseEvent event){ - System.exit(0); - } - }); - } - return this.cancel; - } - -} 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 15:34:59 UTC (rev 1519) +++ software_suite_v2/software/tools/chatterTux/trunk/Chatter_tux/src/ConfInterface.java 2008-08-16 16:20:16 UTC (rev 1520) @@ -21,9 +21,12 @@ */ import javax.swing.BorderFactory; +import javax.swing.ButtonGroup; +import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JOptionPane; import javax.swing.JPanel; +import javax.swing.JRadioButton; import javax.swing.JSpinner; import javax.swing.JComboBox; import javax.swing.JTextArea; @@ -32,6 +35,7 @@ import com.tuxisalive.api.TuxAPI; import com.tuxisalive.api.TuxAPIConst; +import java.awt.Color; import java.awt.Dimension; import java.awt.Font; import java.awt.Point; @@ -51,7 +55,15 @@ private JPanel jContentPane; private JPanel voiceConfigPanel; private JPanel actionModifier; + private JPanel buttonsPanel; + /* Server functions objects */ + private JRadioButton startServer; + private JRadioButton stopServer; + private ButtonGroup group; + private JButton ok; + private JButton cancel; + /* Voice configuration */ private JComboBox locutorSet; private JSpinner pitchSet; @@ -146,6 +158,7 @@ this.jContentPane.setLayout(null); this.jContentPane.add(this.getVoiceConfigurationPanel()); this.jContentPane.add(this.getActionsPanel()); + this.jContentPane.add(this.getButtonsPanel()); } return jContentPane; } @@ -198,6 +211,15 @@ //Displaying registered pitch configuration. this.pitchSet.setValue(Integer.valueOf(pitch)); + + //Getting server start / stop function buttons. + this.jContentPane.add(this.getStartServer()); + this.jContentPane.add(this.getStopServer()); + + //adding radios buttons to a group to allow only one selection. + this.group = new ButtonGroup(); + this.group.add(this.startServer); + this.group.add(this.stopServer); } return this.voiceConfigPanel; } @@ -253,6 +275,76 @@ } + public JRadioButton getStartServer(){ + if(this.startServer == null){ + this.startServer = new JRadioButton("Start Chatter"); + this.startServer.setSize(new Dimension(100, 25)); + this.startServer.setLocation(new Point(200, 26)); + this.startServer.addActionListener(new ServerControlActionListener()); + } + return this.startServer; + } + + + public JRadioButton getStopServer(){ + if(this.stopServer == null){ + this.stopServer = new JRadioButton("Stop Chatter"); + this.stopServer.setSize(new Dimension(100, 25)); + this.stopServer.setLocation(new Point(200, 60)); + this.stopServer.addActionListener(new ServerControlActionListener()); + } + return this.stopServer; + } + + + public JButton getOkButton(){ + if(this.ok == null){ + this.ok = new JButton("Ok"); + this.ok.setSize(new Dimension(73,23)); + this.ok.setLocation(new Point(215, 2)); + this.ok.addMouseListener(new java.awt.event.MouseAdapter(){ + public void mousePressed(java.awt.event.MouseEvent event){ + //Register configuration. + } + }); + } + return this.ok; + } + + + public JButton getCancelButton(){ + if(this.cancel == null){ + this.cancel = new JButton("Cancel"); + cancel.setSize(new Dimension(73, 23)); + cancel.setLocation(new Point(294, 2)); + cancel.addMouseListener(new java.awt.event.MouseAdapter(){ + public void mousePressed(java.awt.event.MouseEvent event){ + System.gc(); + System.exit(0); + } + }); + } + return this.cancel; + } + + + public JPanel getButtonsPanel(){ + if(this.buttonsPanel == null){ + this.buttonsPanel = new JPanel(); + this.buttonsPanel.setLayout(null); + this.buttonsPanel.add(this.getOkButton()); + this.buttonsPanel.add(this.getCancelButton()); + this.buttonsPanel.setSize(this.actionModifier.getWidth(), this.ok.getHeight() +8); + this.buttonsPanel.setPreferredSize(this.buttonsPanel.getSize()); + int x = this.actionModifier.getX(); + int y = this.actionModifier.getY() + 4 + this.actionModifier.getHeight(); + this.buttonsPanel.setLocation(new Point(x, y)); + } + return this.buttonsPanel; + } + +/*****************************************************************************/ +/** Other internals functions. ********************************************/ /* * Sets values into parameters area. */ @@ -276,4 +368,18 @@ } + + private class ServerControlActionListener implements ActionListener{ + + public void actionPerformed(ActionEvent e) { + if(group.getSelection().equals(startServer.getModel())){ + //Start chatter Tux + ChatterTuxServer.start(); + } + else{ //Stop chatter tux. + ChatterTuxServer.stop(); + } + } + } + } Modified: software_suite_v2/software/tools/chatterTux/trunk/Chatter_tux/src/ct_main.java =================================================================== --- software_suite_v2/software/tools/chatterTux/trunk/Chatter_tux/src/ct_main.java 2008-08-16 15:34:59 UTC (rev 1519) +++ software_suite_v2/software/tools/chatterTux/trunk/Chatter_tux/src/ct_main.java 2008-08-16 16:20:16 UTC (rev 1520) @@ -23,7 +23,7 @@ public class ct_main { public static void main(String[] args){ - new ChatterTux(); + new ConfInterface(); } } ------------------------------------------------------------------------- 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
