Coverage Report - cs.pancava.caltha.MainMenu
 
Classes in this File Line Coverage Branch Coverage Complexity
MainMenu
0%
0/358
0%
0/132
2.443
MainMenu$1
0%
0/14
N/A
2.443
MainMenu$10
0%
0/3
N/A
2.443
MainMenu$11
0%
0/3
N/A
2.443
MainMenu$12
0%
0/3
N/A
2.443
MainMenu$13
0%
0/3
N/A
2.443
MainMenu$14
0%
0/3
N/A
2.443
MainMenu$2
0%
0/3
N/A
2.443
MainMenu$3
0%
0/3
N/A
2.443
MainMenu$4
0%
0/3
N/A
2.443
MainMenu$5
0%
0/3
N/A
2.443
MainMenu$6
0%
0/3
N/A
2.443
MainMenu$7
0%
0/3
N/A
2.443
MainMenu$8
0%
0/3
N/A
2.443
MainMenu$9
0%
0/3
N/A
2.443
 
 1  
 /* $Id: MainMenu.java 14 2008-12-07 16:56:26Z mihlon $ */
 2  
 
 3  
 //////////////////////////////////////////////////////////////////////////////
 4  
 //                                                                          //
 5  
 //   This program is free software: you can redistribute it and/or modify   //
 6  
 //   it under the terms of the GNU General Public License as published by   //
 7  
 //   the Free Software Foundation, either version 3 of the License, or      //
 8  
 //   at your option any later version.                                      //
 9  
 //                                                                          //
 10  
 //   This program is distributed in the hope that it will be useful,        //
 11  
 //   but WITHOUT ANY WARRANTY; without even the implied warranty of         //
 12  
 //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          //
 13  
 //   GNU General Public License for more details.                           //
 14  
 //                                                                          //
 15  
 //   You should have received a copy of the GNU General Public License      //
 16  
 //   along with this program.  If not, see <http://www.gnu.org/licenses/>.  //
 17  
 //                                                                          //
 18  
 //////////////////////////////////////////////////////////////////////////////
 19  
 
 20  
 package cs.pancava.caltha;
 21  
 
 22  
 import cs.pancava.caltha.desktop.EditorDesktop;
 23  
 import cs.pancava.caltha.menu.World2DPopupMenuListener;
 24  
 import java.awt.event.ActionEvent;
 25  
 import java.awt.event.ActionListener;
 26  
 import java.awt.event.ItemEvent;
 27  
 import java.awt.event.ItemListener;
 28  
 import java.util.Locale;
 29  
 import java.util.MissingResourceException;
 30  
 import java.util.ResourceBundle;
 31  
 import javax.swing.JCheckBoxMenuItem;
 32  
 import javax.swing.JMenu;
 33  
 import javax.swing.JMenuBar;
 34  
 import javax.swing.JMenuItem;
 35  
 import javax.swing.JOptionPane;
 36  
 import javax.swing.SwingUtilities;
 37  
 import javax.swing.UIManager;
 38  
 import javax.swing.UnsupportedLookAndFeelException;
 39  
 import javax.swing.plaf.metal.DefaultMetalTheme;
 40  
 import javax.swing.plaf.metal.MetalLookAndFeel;
 41  
 import javax.swing.plaf.metal.OceanTheme;
 42  
 
 43  
 /**
 44  
  * <p><b>Definuje hlavni menu programu.</b></p>
 45  
  *
 46  
  * @author Milan Vaclavik<br />
 47  
  * @version $Revision: 14 $<br />
 48  
  * $LastChangedBy: mihlon $
 49  
  */
 50  0
 public class MainMenu
 51  
 {
 52  
     /**
 53  
      * Panel pro hlavni menu.
 54  
      */
 55  
     private JMenuBar menuBar;
 56  
 
 57  
     /**
 58  
      * Nabidka menu - Soubor.
 59  
      */
 60  
     private JMenu fileMenu;
 61  
       /**
 62  
        * Nabidka menu Soubor - Novy.
 63  
        */
 64  
       private JMenu newMenu;
 65  
         /**
 66  
          * Nabidka menu Novy - Textova hra.
 67  
          */
 68  
         private JMenuItem textBasedGamesIM;
 69  
       /**
 70  
        * Polozka menu Soubor - Konec.
 71  
        */
 72  
       private JMenuItem exitIM;
 73  
 
 74  
     /**
 75  
      * Nabidka menu - Napoveda.
 76  
      */
 77  
     private JMenu helpMenu;
 78  
       /**
 79  
        * Polozka menu Napoveda - O programu Caltha - Editor.
 80  
        */
 81  
       private JMenuItem aboutIM;
 82  
 
 83  
     /**
 84  
      * Nabidka menu - Nastaveni.
 85  
      */
 86  
     private JMenu optionsMenu;
 87  
       /**
 88  
        * Nabidka menu Nastaveni - Jazyk.
 89  
        */
 90  
       private JMenu languageMenu;
 91  
         /**
 92  
          * Nabidka menu Jazyk - Cestina.
 93  
          */
 94  
         private JCheckBoxMenuItem czechIM;
 95  
         /**
 96  
          * Nabidka menu Jazyk - Anglictina.
 97  
          */
 98  
         private JCheckBoxMenuItem englishIM;
 99  
       /**
 100  
        * Nabidka menu Vzhled.
 101  
        */
 102  
       private JMenu lookAndFeelMenu;
 103  
         /**
 104  
          * Nabidka menu Vzhled - Vychozi.
 105  
          */
 106  
         private JCheckBoxMenuItem defaultLaFIM;
 107  
         /**
 108  
          * Nabidka menu Vzhled - GTK.
 109  
          */
 110  
         private JCheckBoxMenuItem gtkLaFIM;
 111  
         /**
 112  
          * Nabidka menu Vzhled - Sun Mac OS.
 113  
          */
 114  
         private JCheckBoxMenuItem macLaFIM;
 115  
         /**
 116  
          * Nabidka menu Vzhled - Metal (Java).
 117  
          */
 118  
         private JCheckBoxMenuItem metalLaFIM;
 119  
         /**
 120  
          * Nabidka menu Vzhled - Motif.
 121  
          */
 122  
         private JCheckBoxMenuItem motifLaFIM;
 123  
         /**
 124  
          * Nabidka menu Vzhled - Windows.
 125  
          */
 126  
         private JCheckBoxMenuItem windowsLaFIM;
 127  
         /**
 128  
          * Nabidka menu Vzhled - Tema Metal.
 129  
          */
 130  
         private JMenu metalThemeMenu;
 131  
           /**
 132  
            * Nabidka menu Vzhled - Tema Metal - Vychozi.
 133  
            */
 134  
           private JCheckBoxMenuItem defaultMetalThemeIM;
 135  
           /**
 136  
            * Nabidka menu Vzhled - Tema Metal - Ocean.
 137  
            */
 138  
           private JCheckBoxMenuItem oceanMetalThemeIM;
 139  
           /**
 140  
            * Nabidka menu Vzhled - Tema Metal - Vlastni tema.
 141  
            */
 142  
           private JCheckBoxMenuItem myMetalThemeIM;
 143  
 
 144  
     /**
 145  
      * Vytvari hlavni menu programu.
 146  
      */
 147  
     MainMenu()
 148  0
     {
 149  
         // Definovani panelu pro menu
 150  0
         this.menuBar = new JMenuBar();
 151  
 
 152  
         // Vytvori podmenu Soubor
 153  0
         this.createMenuFile();
 154  
 
 155  
         // Vytvori podmenu Nastaveni
 156  0
         this.createMenuOptions();
 157  
 
 158  
         // Vytvori podmenu Napoveda
 159  0
         this.createMenuHelp();
 160  0
     }
 161  
 
 162  
     /**
 163  
      * Vrati referenci na hlavni menu programu.
 164  
      * @return JMenuBar : Reference na hlavni menu programu.
 165  
      */
 166  
     public final JMenuBar getMenuBar()
 167  
     {
 168  0
         return this.menuBar;
 169  
     }
 170  
 
 171  
     /**
 172  
      * Vytori novou zaskrtavaci polozku menu.
 173  
      * @param name String    : Nazev polozky menu.
 174  
      * @param stav boolean   : Urcuje, zda je/neni zaskrtnuta polozka menu.
 175  
      * @param tip String     : Tip - informace o polozce menu.
 176  
      * @param enable boolean : True = polozka je aktivni, Flase = polozka je neaktivni
 177  
      * @return JMenuItem     : Vraci referenci na prave vytvorenou zaskrtavaci polozku menu.
 178  
      */
 179  
     private JCheckBoxMenuItem addCheckBoxMenuItem(final String name, final boolean stav, final String tip, final boolean enable)
 180  
     {
 181  
         try
 182  
         {
 183  
             JCheckBoxMenuItem cbmi;
 184  
 
 185  0
             cbmi = new JCheckBoxMenuItem(Editor.getResourcesBundleString(name), stav);
 186  0
             if (tip != null)
 187  
             {
 188  0
                 if (!MainMenu.isEmpty(Editor.getResourcesBundleString(tip)))
 189  
                 {
 190  0
                     cbmi.setToolTipText(Editor.getResourcesBundleString(tip));
 191  
                 }
 192  
             }
 193  0
             cbmi.setEnabled(enable);
 194  0
             return cbmi;
 195  
         }
 196  0
         catch (MissingResourceException e)
 197  
         {
 198  0
             Editor.showDialogMissingResources(e.getMessage());
 199  
         }
 200  
 
 201  
         // Vraci se null, je treba osetrit tuto honotu tam, kde je tato metoda volana !!!
 202  
         // Diky metode Editor.showDialogMissingResources() neni null treba osetrovat, protoze
 203  
         // jde o blokujici metodu, ktera ukonci program.
 204  0
         return null;
 205  
       }
 206  
 
 207  
     /**
 208  
     * Vytvori nove menu - podmenu.
 209  
     * @param name String : Nazev polozky menu.
 210  
     * @param help String : Mapovani na tema napovedy.
 211  
     * @param tip String  : Tip - informace o polozce menu.
 212  
     * @return JMenuItem  : Vraci referenci na prave vytvorenou polozku menu.
 213  
     */
 214  
     private JMenu addMenu(final String name, final String help, final String tip)
 215  
     {
 216  
         try
 217  
         {
 218  
             JMenu m;
 219  
 
 220  0
             m = new JMenu(Editor.getResourcesBundleString(name));
 221  
 
 222  0
             if (help != null)
 223  
             {
 224  
                 // TODO: Pridat
 225  
                 // Pripojeni napovedy k polozce hlavniho menu
 226  
                 // Editor.helpBroker.enableHelp(m, help, Editor.helpSet);
 227  
             }
 228  
 
 229  0
             if (tip != null)
 230  
             {
 231  
                 try
 232  
                 {
 233  0
                     if (!MainMenu.isEmpty(Editor.getResourcesBundleString(tip)))
 234  
                     {
 235  0
                         m.setToolTipText(Editor.getResourcesBundleString(tip));
 236  
                     }
 237  
                 }
 238  0
                 catch (MissingResourceException e)
 239  
                 {
 240  0
                     Editor.showDialogMissingResources(e.getMessage());
 241  0
                 }
 242  
             }
 243  
 
 244  0
             return m;
 245  
         }
 246  0
         catch (MissingResourceException e)
 247  
         {
 248  0
             Editor.showDialogMissingResources(e.getMessage());
 249  
         }
 250  
 
 251  
         // Vraci se null, je treba osetrit tuto honotu tam, kde je tato metoda volana !!!
 252  
         // Diky metode Editor.showDialogMissingResources() neni null treba osetrovat, protoze
 253  
         // jde o blokujici metodu, ktera ukonci program.
 254  0
         return null;
 255  
     }
 256  
 
 257  
     /**
 258  
      * Vytvori novou polozku menu.
 259  
      * @param name String    : Nazev polozky menu.
 260  
      * @param tip String     : Tip - informace o polozce menu.
 261  
      * @param enable boolean : True = polozka je aktivni, Flase = polozka je neaktivni
 262  
      * @return JMenuItem     : Vraci referenci na prave vytvorenou polozku menu.
 263  
      */
 264  
     public static JMenuItem addMenuItem(final String name, final String tip, final boolean enable)
 265  
     {
 266  
         try
 267  
         {
 268  
             JMenuItem mi;
 269  
 
 270  0
             mi = new JMenuItem(Editor.getResourcesBundleString(name));
 271  
 
 272  0
             if (tip != null)
 273  
             {
 274  
                 try
 275  
                 {
 276  0
                     if (!MainMenu.isEmpty(Editor.getResourcesBundleString(tip)))
 277  
                     {
 278  0
                         mi.setToolTipText(Editor.getResourcesBundleString(tip));
 279  
                     }
 280  
                 }
 281  0
                 catch (MissingResourceException e)
 282  
                 {
 283  0
                     Editor.showDialogMissingResources(e.getMessage());
 284  0
                 }
 285  
             }
 286  
 
 287  0
             mi.setEnabled(enable);
 288  0
             return mi;
 289  
         }
 290  0
         catch (MissingResourceException e)
 291  
         {
 292  0
             Editor.showDialogMissingResources(e.getMessage());
 293  
         }
 294  
 
 295  
         // Vraci se null, je treba osetrit tuto honotu tam, kde je tato metoda volana !!!
 296  
         // Diky metode Editor.showDialogMissingResources() neni null treba osetrovat, protoze
 297  
         // jde o blokujici metodu, ktera ukonci program.
 298  0
         return null;
 299  
     }
 300  
 
 301  
     /**
 302  
      * Zobrazi plochu editoru pro vytvoreni textove hry.
 303  
      */
 304  
     private void createEditorTextBasedGames()
 305  
     {
 306  0
         Editor.setEditorDesktop(EditorDesktop.EDITOR_TEXT_BASED_GAMES);
 307  0
     }
 308  
 
 309  
     /**
 310  
      * Vytvori koncovou polozku menu Soubor - Konec.
 311  
      */
 312  
     private void createItemMenuFileExit()
 313  
     {
 314  0
         this.exitIM = MainMenu.addMenuItem("cs.pancava.caltha.MainMenu-createItemMenuFileExit_exitIM",
 315  
                                            "cs.pancava.caltha.MainMenu-createItemMenuFileExit_exitIM_tip",
 316  
                                            true);
 317  
 
 318  0
         this.exitIM.addActionListener(new ActionListener()
 319  0
         {
 320  
             @Override
 321  
             public void actionPerformed(final ActionEvent e)
 322  
             {
 323  0
                 final Object[] options = {"OK", "CANCEL", "HELP"};
 324  0
                 int index = 0;
 325  
                 try
 326  
                 {
 327  0
                     index = JOptionPane.showOptionDialog(null,
 328  
                                   Editor.getResourcesBundleString("cs.pancava.caltha.MainMenu-createItemMenuFileExit_Dialog_msg"),
 329  
                                   Editor.getResourcesBundleString("cs.pancava.caltha.MainMenu-createItemMenuFileExit_Dialog_tit"),
 330  
                                   JOptionPane.DEFAULT_OPTION,
 331  
                                   JOptionPane.QUESTION_MESSAGE,
 332  
                                   null,
 333  
                                   options,
 334  
                                   options[0]
 335  
                                 );
 336  
 
 337  
                 }
 338  0
                 catch (MissingResourceException mre)
 339  
                 {
 340  0
                     Editor.showDialogMissingResources(mre.getMessage());
 341  0
                 }
 342  
 
 343  0
                 switch (index)
 344  
                 {
 345  
                     case 0:
 346  
                              // Ukonceni aplikace po vyberu polozky menu Exit
 347  0
                              System.exit(0);
 348  0
                              break;
 349  
                     case 1:
 350  0
                              break;
 351  
                     case 2:
 352  
                     default:
 353  0
                              this.helpMenuFileExit();
 354  
                              break;
 355  
                 }
 356  0
             }
 357  
 
 358  
             /**
 359  
              * Poskytne napovedu pro ukonceni programu.
 360  
              */
 361  
             private void helpMenuFileExit()
 362  
             {
 363  
                 // TODO: Zobrazit napovedu o ukonceni programu.
 364  0
             }
 365  
         });
 366  
 
 367  0
         this.fileMenu.addSeparator();
 368  0
         this.fileMenu.add(this.exitIM);
 369  0
      }
 370  
 
 371  
     /**
 372  
      * Vytvori koncovou plozku menu Novy - Textova hra.
 373  
      */
 374  
     private void createItemMenuFileNewTextBasedGames()
 375  
     {
 376  0
         this.textBasedGamesIM = MainMenu.addMenuItem("cs.pancava.caltha.MainMenu-createItemMenuFileNewTextBasedGames_textBasedGamesIM",
 377  
                                                      "cs.pancava.caltha.MainMenu-createItemMenuFileNewTextBasedGames_textBasedGamesIM_tip",
 378  
                                                      true);
 379  
 
 380  0
         this.textBasedGamesIM.addActionListener(new ActionListener()
 381  0
         {
 382  
             @Override
 383  
             public void actionPerformed(final ActionEvent e)
 384  
             {
 385  0
                 createEditorTextBasedGames();
 386  0
             }
 387  
         });
 388  
 
 389  0
         this.newMenu.add(this.textBasedGamesIM);
 390  0
     }
 391  
 
 392  
     /**
 393  
      * Vytvori koncovou polozku O programu Caltha - Editor.
 394  
      */
 395  
     private void createItemMenuHelpAbout()
 396  
     {
 397  0
         this.helpMenu.addSeparator();
 398  
 
 399  0
         this.aboutIM = MainMenu.addMenuItem("cs.pancava.caltha.MainMenu-createItemMenuHelpAbout_aboutIM",
 400  
                                             "cs.pancava.caltha.MainMenu-createItemMenuHelpAbout_aboutIM_tip",
 401  
                                             true);
 402  
 
 403  0
         this.aboutIM.addActionListener(new ActionListener()
 404  0
         {
 405  
             @Override
 406  
             public void actionPerformed(final ActionEvent e)
 407  
             {
 408  0
                 showAboutDialog();
 409  0
             }
 410  
         });
 411  
 
 412  0
         this.helpMenu.add(this.aboutIM);
 413  0
     }
 414  
 
 415  
     /**
 416  
      * Vytvori koncovou polozku Cestina.
 417  
      */
 418  
     private void createItemMenuOptionsLanguageCzech()
 419  
     {
 420  0
         this.czechIM = this.addCheckBoxMenuItem("cs.pancava.caltha.MainMenu-createItemMenuOptionsLanguageCzech_czechIM",
 421  
                                                 true,
 422  
                                                 "cs.pancava.caltha.MainMenu-createItemMenuOptionsLanguageCzech_czechIM",
 423  
                                                 true);
 424  
 
 425  0
         this.czechIM.addItemListener(new ItemListener()
 426  0
         {
 427  
             @Override
 428  
             public void itemStateChanged(final ItemEvent e)
 429  
             {
 430  0
                 czechIM_itemStateChanged(e);
 431  0
             }
 432  
         });
 433  
 
 434  0
         this.languageMenu.add(this.czechIM);
 435  0
     }
 436  
 
 437  
     /**
 438  
      * Vytvori koncovou polozku Anglictina.
 439  
      */
 440  
     private void createItemMenuOptionsLanguageEnglish()
 441  
     {
 442  0
         this.englishIM = this.addCheckBoxMenuItem("cs.pancava.caltha.MainMenu-createItemMenuOptionsLanguageEnglish_englishIM",
 443  
                                                   false,
 444  
                                                   "cs.pancava.caltha.MainMenu-createItemMenuOptionsLanguageEnglish_englishIM_tip",
 445  
                                                   true);
 446  
 
 447  0
         this.englishIM.addItemListener(new ItemListener()
 448  0
         {
 449  
             @Override
 450  
             public void itemStateChanged(final ItemEvent e)
 451  
             {
 452  0
                 englishIM_itemStateChanged(e);
 453  0
             }
 454  
         });
 455  
 
 456  0
         this.languageMenu.add(this.englishIM);
 457  0
     }
 458  
 
 459  
     /**
 460  
      * Vytvori koncovou polozku Vychozi vzhled.
 461  
      */
 462  
     private void createItemMenuOptionsLookAndFeelDefaultLaF()
 463  
     {
 464  0
          this.defaultLaFIM  = this.addCheckBoxMenuItem("cs.pancava.caltha.MainMenu-createItemMenuOptionsLookAndFeelDefaultLaF_defaultLaFIM",
 465  
                                                        true,
 466  
                                                        "cs.pancava.caltha.MainMenu-createItemMenuOptionsLookAndFeelDefaultLaF_defaultLaFIM_tip",
 467  
                                                        true);
 468  
 
 469  0
          this.defaultLaFIM.addItemListener(new ItemListener()
 470  0
          {
 471  
             @Override
 472  
              public void itemStateChanged(final ItemEvent e)
 473  
              {
 474  0
                 defaultLaFIM_itemStateChanged(e);
 475  0
              }
 476  
          });
 477  
 
 478  0
          this.lookAndFeelMenu.add(this.defaultLaFIM);
 479  0
     }
 480  
 
 481  
     /**
 482  
      * Vytvori koncovou polozku vzhled GTK.
 483  
      */
 484  
     private void createItemMenuOptionsLookAndFeelGtkLaF()
 485  
     {
 486  0
         this.gtkLaFIM  = this.addCheckBoxMenuItem("cs.pancava.caltha.MainMenu-createItemMenuOptionsLookAndFeelGtkLaF_gtkLaFIM",
 487  
                                                   false,
 488  
                                                   "cs.pancava.caltha.MainMenu-createItemMenuOptionsLookAndFeelGtkLaF_gtkLaFIM_tip",
 489  
                                                   true);
 490  
 
 491  0
         this.gtkLaFIM.addItemListener(new ItemListener()
 492  0
         {
 493  
             @Override
 494  
             public void itemStateChanged(final ItemEvent e)
 495  
             {
 496  0
                 gtkLaFIM_itemStateChanged(e);
 497  0
             }
 498  
         });
 499  
 
 500  0
         this.lookAndFeelMenu.add(this.gtkLaFIM);
 501  0
    }
 502  
 
 503  
     /**
 504  
      * Vytvori koncovou polozku vzhled Sun Mac OS.
 505  
      */
 506  
     private void createItemMenuOptionsLookAndFeelMacLaF()
 507  
     {
 508  0
         this.macLaFIM  = this.addCheckBoxMenuItem("cs.pancava.caltha.MainMenu-createItemMenuOptionsLookAndFeelMacLaF_macLaFIM",
 509  
                                                   false,
 510  
                                                   "cs.pancava.caltha.MainMenu-createItemMenuOptionsLookAndFeelMacLaF_macLaFIM_tip",
 511  
                                                   true);
 512  
 
 513  0
         this.macLaFIM.addItemListener(new ItemListener()
 514  0
         {
 515  
             @Override
 516  
             public void itemStateChanged(final ItemEvent e)
 517  
             {
 518  0
                 macLaFIM_itemStateChanged(e);
 519  0
             }
 520  
         });
 521  
 
 522  0
         this.lookAndFeelMenu.add(this.macLaFIM);
 523  0
    }
 524  
 
 525  
     /**
 526  
      * Vytvori koncovou polozku vzhled Metal.
 527  
      */
 528  
     private void createItemMenuOptionsLookAndFeelMetalLaF()
 529  
     {
 530  0
         this.metalLaFIM  = this.addCheckBoxMenuItem("cs.pancava.caltha.MainMenu-createItemMenuOptionsLookAndFeelMetalLaF_metalLaFIM",
 531  
                                                     false,
 532  
                                                     "cs.pancava.caltha.MainMenu-createItemMenuOptionsLookAndFeelMetalLaF_metalLaFIM_tip",
 533  
                                                     true);
 534  
 
 535  0
         this.metalLaFIM.addItemListener(new ItemListener()
 536  0
         {
 537  
             @Override
 538  
             public void itemStateChanged(final ItemEvent e)
 539  
             {
 540  0
                 metalLaFIM_itemStateChanged(e);
 541  0
             }
 542  
         });
 543  
 
 544  0
         this.lookAndFeelMenu.add(this.metalLaFIM);
 545  0
     }
 546  
 
 547  
     /**
 548  
      * Vytvori koncovou polozku tema vzhledu Metal - vychozi.
 549  
      */
 550  
     private void createItemMenuOptionsLookAndFeelMetalThemeDefault()
 551  
     {
 552  0
         this.defaultMetalThemeIM  = this.addCheckBoxMenuItem("cs.pancava.caltha.MainMenu-createItemMenuOptionsLookAndFeelMetalThemeDefault_defaultMetalThemeIM",
 553  
                                                              true,
 554  
                                                              "cs.pancava.caltha.MainMenu-createItemMenuOptionsLookAndFeelMetalThemeDefault_defaultMetalThemeIM_tip",
 555  
                                                              true);
 556  
 
 557  0
         this.defaultMetalThemeIM.addItemListener(new ItemListener()
 558  0
         {
 559  
             @Override
 560  
             public void itemStateChanged(final ItemEvent e)
 561  
             {
 562  0
                 defaultMetalThemeIM_itemStateChanged(e);
 563  0
             }
 564  
         });
 565  
 
 566  0
         this.metalThemeMenu.add(this.defaultMetalThemeIM);
 567  0
     }
 568  
 
 569  
     /**
 570  
      * Vytvori koncovou polozku tema vzhledu Metal - Vlastni.
 571  
      */
 572  
     private void createItemMenuOptionsLookAndFeelMetalThemeMyMetal()
 573  
     {
 574  0
         this.myMetalThemeIM  = this.addCheckBoxMenuItem("cs.pancava.caltha.MainMenu-createItemMenuOptionsLookAndFeelMetalThemeMyMetal_myMetalThemeIM",
 575  
                                                         false,
 576  
                                                         "cs.pancava.caltha.MainMenu-createItemMenuOptionsLookAndFeelMetalThemeMyMetal_myMetalThemeIM_tip",
 577  
                                                         true);
 578  
 
 579  0
         this.myMetalThemeIM.addItemListener(new ItemListener()
 580  0
         {
 581  
             @Override
 582  
             public void itemStateChanged(final ItemEvent e)
 583  
             {
 584  0
                 myMetalThemeIM_itemStateChanged(e);
 585  0
             }
 586  
         });
 587  
 
 588  0
         this.metalThemeMenu.add(this.myMetalThemeIM);
 589  0
     }
 590  
 
 591  
     /**
 592  
      * Vytvori koncovou polozku tema vzhledu Metal - Ocean.
 593  
      */
 594  
     private void createItemMenuOptionsLookAndFeelMetalThemeOcean()
 595  
     {
 596  0
         this.oceanMetalThemeIM  = this.addCheckBoxMenuItem("cs.pancava.caltha.MainMenu-createItemMenuOptionsLookAndFeelMetalThemeOcean_oceanMetalThemeIM",
 597  
                                                            false,
 598  
                                                            "cs.pancava.caltha.MainMenu-createItemMenuOptionsLookAndFeelMetalThemeOcean_oceanMetalThemeIM_tip",
 599  
                                                            true);
 600  
 
 601  0
         this.oceanMetalThemeIM.addItemListener(new ItemListener()
 602  0
         {
 603  
             @Override
 604  
             public void itemStateChanged(final ItemEvent e)
 605  
             {
 606  0
                 oceanMetalThemeIM_itemStateChanged(e);
 607  0
             }
 608  
         });
 609  
 
 610  0
         this.metalThemeMenu.add(this.oceanMetalThemeIM);
 611  0
     }
 612  
 
 613  
     /**
 614  
      * Vytvori koncovou polozku vzhled Motif.
 615  
      */
 616  
     private void createItemMenuOptionsLookAndFeelMotifLaF()
 617  
     {
 618  0
         this.motifLaFIM  = this.addCheckBoxMenuItem("cs.pancava.caltha.MainMenu-createItemMenuOptionsLookAndFeelMotifLaF_motifLaFIM",
 619  
                                                     false,
 620  
                                                     "cs.pancava.caltha.MainMenu-createItemMenuOptionsLookAndFeelMotifLaF_motifLaFIM_tip",
 621  
                                                     true);
 622  
 
 623  0
         this.motifLaFIM.addItemListener(new ItemListener()
 624  0
         {
 625  
             @Override
 626  
             public void itemStateChanged(final ItemEvent e)
 627  
             {
 628  0
                 motifLaFIM_itemStateChanged(e);
 629  0
             }
 630  
         });
 631  
 
 632  0
         this.lookAndFeelMenu.add(this.motifLaFIM);
 633  0
     }
 634  
 
 635  
     /**
 636  
      * Vytvori koncovou polozku vzhled Windows.
 637  
      */
 638  
     private void createItemMenuOptionsLookAndFeelWindowsLaF()
 639  
     {
 640  0
         this.windowsLaFIM  = this.addCheckBoxMenuItem("cs.pancava.caltha.MainMenu-createItemMenuOptionsLookAndFeelWindowsLaF_windowsLaFIM",
 641  
                                                       false,
 642  
                                                       "cs.pancava.caltha.MainMenu-createItemMenuOptionsLookAndFeelWindowsLaF_windowsLaFIM_tip",
 643  
                                                       true);
 644  
 
 645  0
         this.windowsLaFIM.addItemListener(new ItemListener()
 646  0
         {
 647  
             @Override
 648  
             public void itemStateChanged(final ItemEvent e)
 649  
             {
 650  0
                 windowsLaFIM_itemStateChanged(e);
 651  0
             }
 652  
         });
 653  
 
 654  0
         this.lookAndFeelMenu.add(this.windowsLaFIM);
 655  0
     }
 656  
 
 657  
     /**
 658  
      * Vytvori podmenu Soubor v hlavnim menu.
 659  
      */
 660  
     private void createMenuFile()
 661  
     {
 662  0
         this.fileMenu = this.addMenu("cs.pancava.caltha.MainMenu-createMenuFile_fileMenu",
 663  
                                      "cs.pancava.caltha.MainMenu-createMenuFile_fileMenu",
 664  
                                      "cs.pancava.caltha.MainMenu-createMenuFile_fileMenu_tip");
 665  
 
 666  0
         this.createMenuFileNew();
 667  0
         this.createItemMenuFileExit();
 668  
 
 669  0
         this.menuBar.add(this.fileMenu);
 670  0
     }
 671  
 
 672  
     /**
 673  
      * Vytvori podmenu Novy v nabidce Soubor.
 674  
      */
 675  
     private void createMenuFileNew()
 676  
     {
 677  0
         this.newMenu = this.addMenu("cs.pancava.caltha.MainMenu-createMenuFileNew_newMenu",
 678  
                                     "cs.pancava.caltha.MainMenu-createMenuFileNew_newMenu",
 679  
                                     "cs.pancava.caltha.MainMenu-createMenuFileNew_newMenu_tip");
 680  
 
 681  0
         this.createItemMenuFileNewTextBasedGames();
 682  
 
 683  0
         this.fileMenu.add(this.newMenu);
 684  0
     }
 685  
 
 686  
     /**
 687  
      * Vytvori podmenu Napoveda.
 688  
      */
 689  
     private void createMenuHelp()
 690  
     {
 691  0
         this.helpMenu = this.addMenu("cs.pancava.caltha.MainMenu-createMenuHelp_helpMenu",
 692  
                                      "cs.pancava.caltha.MainMenu-createMenuHelp_helpMenu",
 693  
                                      "cs.pancava.caltha.MainMenu-createMenuHelp_helpMenu_tip");
 694  
 
 695  
         //createItemMenuHelpEditorHelp(); // Napoveda pro program Caltha - Editor
 696  
         //createItemMenuHelpWhatThis();   // Co je to ?
 697  0
         this.createItemMenuHelpAbout();
 698  
 
 699  0
         this.menuBar.add(this.helpMenu);
 700  0
     }
 701  
 
 702  
     /**
 703  
      * Vytvori podmenu Nastaveni v hlavnim menu.
 704  
      */
 705  
     private void createMenuOptions()
 706  
     {
 707  0
         this.optionsMenu = this.addMenu("cs.pancava.caltha.MainMenu-createMenuOptions_optionsMenu",
 708  
                                         "cs.pancava.caltha.MainMenu-createMenuOptions_optionsMenu",
 709  
                                         "cs.pancava.caltha.MainMenu-createMenuOptions_optionsMenu_tip");
 710  
 
 711  0
         this.createMenuOptionsLanguage();
 712  
 
 713  0
         this.optionsMenu.addSeparator();
 714  
 
 715  0
         this.createMenuOptionsLookAndFeel();
 716  
 
 717  0
         this.menuBar.add(this.optionsMenu);
 718  0
     }
 719  
 
 720  
     /**
 721  
      * Podmenu Jazyk v nabidce Nastaveni.
 722  
      */
 723  
     private void createMenuOptionsLanguage()
 724  
     {
 725  0
         this.languageMenu = this.addMenu("cs.pancava.caltha.MainMenu-createMenuOptionsLanguage_languageMenu",
 726  
                                          "cs.pancava.caltha.MainMenu-createMenuOptionsLanguage_languageMenu",
 727  
                                          "cs.pancava.caltha.MainMenu-createMenuOptionsLanguage_languageMenu_tip");
 728  
 
 729  0
         this.createItemMenuOptionsLanguageCzech();
 730  0
         this.createItemMenuOptionsLanguageEnglish();
 731  
 
 732  0
         this.optionsMenu.add(this.languageMenu);
 733  0
     }
 734  
 
 735  
     /**
 736  
      * Podmenu Vzhled v nabidce Nastaveni.
 737  
      */
 738  
     private void createMenuOptionsLookAndFeel()
 739  
     {
 740  0
         this.lookAndFeelMenu = this.addMenu("cs.pancava.caltha.MainMenu-createMenuOptionsLookAndFeel_lookAndFeelMenu",
 741  
                                             "cs.pancava.caltha.MainMenu-createMenuOptionsLookAndFeel_lookAndFeelMenu",
 742  
                                             "cs.pancava.caltha.MainMenu-createMenuOptionsLookAndFeel_lookAndFeelMenu_tip");
 743  
 
 744  0
         this.createItemMenuOptionsLookAndFeelDefaultLaF();
 745  0
         this.createItemMenuOptionsLookAndFeelGtkLaF();
 746  0
         this.createItemMenuOptionsLookAndFeelMacLaF();
 747  0
         this.createItemMenuOptionsLookAndFeelMetalLaF();
 748  0
         this.createItemMenuOptionsLookAndFeelMotifLaF();
 749  0
         this.createItemMenuOptionsLookAndFeelWindowsLaF();
 750  0
         this.createMenuOptionsLookAndFeelMetalTheme();
 751  
 
 752  0
         this.optionsMenu.add(this.lookAndFeelMenu);
 753  0
     }
 754  
 
 755  
     /**
 756  
      * Podmenu Tema Metal v nabidce Vzhled v nabidce Nastaveni.
 757  
      */
 758  
     private void createMenuOptionsLookAndFeelMetalTheme()
 759  
     {
 760  0
         this.metalThemeMenu = this.addMenu("cs.pancava.caltha.MainMenu-createMenuOptionsLookAndFeelMetalTheme_metalThemeMenu",
 761  
                                            null,
 762  
                                            "cs.pancava.caltha.MainMenu-createMenuOptionsLookAndFeelMetalTheme_metalThemeMenu_tip");
 763  
 
 764  0
         this.createItemMenuOptionsLookAndFeelMetalThemeDefault();
 765  0
         this.createItemMenuOptionsLookAndFeelMetalThemeOcean();
 766  0
         this.createItemMenuOptionsLookAndFeelMetalThemeMyMetal();
 767  
 
 768  0
         this.metalThemeMenu.setEnabled(false);
 769  
 
 770  0
         this.lookAndFeelMenu.add(this.metalThemeMenu);
 771  0
     }
 772  
 
 773  
     /**
 774  
      * Obsluha udalosti pri zaskrtnuti/odsrtnuti polozky menu Jazyk - Vyber cestiny.
 775  
      * @param e ItemEvent
 776  
      */
 777  
     private void czechIM_itemStateChanged(final ItemEvent e)
 778  
     {
 779  0
         if (e.getStateChange() == ItemEvent.SELECTED)
 780  
         {
 781  0
             this.englishIM.setSelected(false);
 782  
 
 783  
             try
 784  
             {
 785  0
                 Editor.setResourcesBundle(ResourceBundle.getBundle("Caltha", Editor.getCzLocale()));
 786  
             }
 787  0
             catch (MissingResourceException mre)
 788  
             {
 789  0
                 Editor.errorMissingResource(mre.getMessage());
 790  0
             }
 791  
 
 792  0
             this.updateText();
 793  
         }
 794  
         else
 795  
         {
 796  0
             if (!this.englishIM.isSelected())
 797  
             {
 798  0
                 this.czechIM.setSelected(true);
 799  
             }
 800  
         }
 801  0
     }
 802  
 
 803  
     /**
 804  
      * Obsluha udalosti pri zaskrtnuti/odsrtnuti polozky menu Vzhled - Vychozi.
 805  
      * @param e ItemEvent
 806  
      */
 807  
     private void defaultLaFIM_itemStateChanged(final ItemEvent e)
 808  
     {
 809  0
         if (e.getStateChange() == ItemEvent.SELECTED)
 810  
         {
 811  0
             this.gtkLaFIM.setSelected(false);
 812  0
             this.macLaFIM.setSelected(false);
 813  0
             this.metalLaFIM.setSelected(false);
 814  0
             this.motifLaFIM.setSelected(false);
 815  0
             this.windowsLaFIM.setSelected(false);
 816  
 
 817  0
             this.metalThemeMenu.setEnabled(false);
 818  
 
 819  0
             this.setLookAndFeel(UIManager.getSystemLookAndFeelClassName(), null);
 820  
         }
 821  
         else
 822  
         {
 823  0
             if ((!this.gtkLaFIM.isSelected())
 824  
                  && (!this.macLaFIM.isSelected())
 825  
                  && (!this.metalLaFIM.isSelected())
 826  
                  && (!this.motifLaFIM.isSelected())
 827  
                  && (!this.windowsLaFIM.isSelected()))
 828  
             {
 829  0
                 this.defaultLaFIM.setSelected(true);
 830  
             }
 831  
         }
 832  0
    }
 833  
 
 834  
     /**
 835  
      * Obsluha udalosti pri zaskrtnuti/odsrtnuti polozky menu Tema Metal - Vychozi nastaveni.
 836  
      * @param e ItemEvent
 837  
      */
 838  
     private void defaultMetalThemeIM_itemStateChanged(final ItemEvent e)
 839  
     {
 840  0
         if (e.getStateChange() == ItemEvent.SELECTED)
 841  
         {
 842  0
             this.oceanMetalThemeIM.setSelected(false);
 843  0
             this.myMetalThemeIM.setSelected(false);
 844  
 
 845  0
             this.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel", "DefaultMetal");
 846  
         }
 847  
         else
 848  
         {
 849  0
             if ((!this.oceanMetalThemeIM.isSelected())
 850  
                  && (!this.myMetalThemeIM.isSelected()))
 851  
             {
 852  0
                 this.defaultMetalThemeIM.setSelected(true);
 853  
             }
 854  
         }
 855  0
     }
 856  
 
 857  
     /**
 858  
      * Obsluha udalosti pri zaskrtnuti/odsrtnuti polozky menu Jazyk - Vyber anglictiny.
 859  
      * @param e ItemEvent
 860  
      */
 861  
     private void englishIM_itemStateChanged(final ItemEvent e)
 862  
     {
 863  0
         if (e.getStateChange() == ItemEvent.SELECTED)
 864  
         {
 865  0
             this.czechIM.setSelected(false);
 866  
 
 867  
             try
 868  
             {
 869  0
                 Editor.setResourcesBundle(ResourceBundle.getBundle("Caltha", Locale.ENGLISH));
 870  
             }
 871  0
             catch (MissingResourceException mre)
 872  
             {
 873  0
                 Editor.errorMissingResource(mre.getMessage());
 874  0
             }
 875  
 
 876  0
             this.updateText();
 877  
         }
 878  
         else
 879  
         {
 880  0
             if (!this.czechIM.isSelected())
 881  
             {
 882  0
                 this.englishIM.setSelected(true);
 883  
             }
 884  
         }
 885  0
    }
 886  
 
 887  
     /**
 888  
      * Obsluha udalosti pri zaskrtnuti/odsrtnuti polozky menu Vzhled - GTK.
 889  
      * @param e ItemEvent
 890  
      */
 891  
     private void gtkLaFIM_itemStateChanged(final ItemEvent e)
 892  
     {
 893  0
         if (e.getStateChange() == ItemEvent.SELECTED)
 894  
         {
 895  0
             this.defaultLaFIM.setSelected(false);
 896  0
             this.macLaFIM.setSelected(false);
 897  0
             this.metalLaFIM.setSelected(false);
 898  0
             this.motifLaFIM.setSelected(false);
 899  0
             this.windowsLaFIM.setSelected(false);
 900  
 
 901  0
             this.metalThemeMenu.setEnabled(false);
 902  
 
 903  0
             this.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel", null);
 904  
         }
 905  
         else
 906  
         {
 907  0
             if ((!this.defaultLaFIM.isSelected())
 908  
                  && (!this.macLaFIM.isSelected())
 909  
                  && (!this.metalLaFIM.isSelected())
 910  
                  && (!this.motifLaFIM.isSelected())
 911  
                  && (!this.windowsLaFIM.isSelected()))
 912  
             {
 913  0
                 gtkLaFIM.setSelected(true);
 914  
             }
 915  
         }
 916  0
     }
 917  
 
 918  
     /**
 919  
      * Zjisti, zda je retezec prazdny.
 920  
      * @param s String : Retezec k prozkoumani.
 921  
      * @return boolean : true - je prazdny; false - neni prazdny.
 922  
      */
 923  
     public static boolean isEmpty(final String s)
 924  
     {
 925  
         // funkce trim odstrani vsechny mezery, tabulatory, ridici znaky ze zacatku a z konce retezce.
 926  0
         final String t = s.trim();
 927  
 
 928  0
         if (t.length() == 0)
 929  
         {
 930  0
             return true;
 931  
         }
 932  
 
 933  0
         return false;
 934  
     }
 935  
 
 936  
     /**
 937  
      * Obsluha udalosti pri zaskrtnuti/odsrtnuti polozky menu Vzhled - Sun Mac OS.
 938  
      * @param e ItemEvent
 939  
      */
 940  
     private void macLaFIM_itemStateChanged(final ItemEvent e)
 941  
     {
 942  0
         if (e.getStateChange() == ItemEvent.SELECTED)
 943  
         {
 944  0
             this.defaultLaFIM.setSelected(false);
 945  0
             this.gtkLaFIM.setSelected(false);
 946  0
             this.metalLaFIM.setSelected(false);
 947  0
             this.motifLaFIM.setSelected(false);
 948  0
             this.windowsLaFIM.setSelected(false);
 949  
 
 950  0
             this.metalThemeMenu.setEnabled(false);
 951  
 
 952  0
             this.setLookAndFeel("com.sun.java.swing.plaf.mac.MacLookAndFeel", null);
 953  
         }
 954  
         else
 955  
         {
 956  0
             if ((!this.defaultLaFIM.isSelected())
 957  
                 && (!this.gtkLaFIM.isSelected())
 958  
                 && (!this.metalLaFIM.isSelected())
 959  
                 && (!this.motifLaFIM.isSelected())
 960  
                 && (!this.windowsLaFIM.isSelected()))
 961  
             {
 962  0
                 this.macLaFIM.setSelected(true);
 963  
             }
 964  
         }
 965  0
     }
 966  
 
 967  
     /**
 968  
      * Obsluha udalosti pri zaskrtnuti/odsrtnuti polozky menu Vzhled - Metal.
 969  
      * @param e ItemEvent
 970  
      */
 971  
     private void metalLaFIM_itemStateChanged(final ItemEvent e)
 972  
     {
 973  0
         if (e.getStateChange() == ItemEvent.SELECTED)
 974  
         {
 975  0
             this.defaultLaFIM.setSelected(false);
 976  0
             this.gtkLaFIM.setSelected(false);
 977  0
             this.macLaFIM.setSelected(false);
 978  0
             this.motifLaFIM.setSelected(false);
 979  0
             this.windowsLaFIM.setSelected(false);
 980  
 
 981  0
             this.metalThemeMenu.setEnabled(true);
 982  
 
 983  0
             this.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel", "DefaultMetal");
 984  
         }
 985  
         else
 986  
         {
 987  0
             if ((!this.defaultLaFIM.isSelected())
 988  
                  && (!this.gtkLaFIM.isSelected())
 989  
                  && (!this.macLaFIM.isSelected())
 990  
                  && (!this.motifLaFIM.isSelected())
 991  
                  && (!this.windowsLaFIM.isSelected()))
 992  
             {
 993  0
                 this.metalLaFIM.setSelected(true);
 994  
             }
 995  
         }
 996  0
     }
 997  
 
 998  
     /**
 999  
      * Obsluha udalosti pri zaskrtnuti/odsrtnuti polozky menu Vzhled - Motif.
 1000  
      * @param e ItemEvent
 1001  
      */
 1002  
     private void motifLaFIM_itemStateChanged(final ItemEvent e)
 1003  
     {
 1004  0
         if (e.getStateChange() == ItemEvent.SELECTED)
 1005  
         {
 1006  0
             this.defaultLaFIM.setSelected(false);
 1007  0
             this.gtkLaFIM.setSelected(false);
 1008  0
             this.macLaFIM.setSelected(false);
 1009  0
             this.metalLaFIM.setSelected(false);
 1010  0
             this.windowsLaFIM.setSelected(false);
 1011  
 
 1012  0
             this.metalThemeMenu.setEnabled(false);
 1013  
 
 1014  0
             this.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel", null);
 1015  
         }
 1016  
         else
 1017  
         {
 1018  0
             if ((!this.defaultLaFIM.isSelected())
 1019  
                  && (!this.gtkLaFIM.isSelected())
 1020  
                  && (!this.macLaFIM.isSelected())
 1021  
                  && (!this.metalLaFIM.isSelected())
 1022  
                  && (!this.windowsLaFIM.isSelected()))
 1023  
             {
 1024  0
                 this.motifLaFIM.setSelected(true);
 1025  
             }
 1026  
         }
 1027  0
     }
 1028  
 
 1029  
     /**
 1030  
      * Obsluha udalosti pri zaskrtnuti/odsrtnuti polozky menu Tema Metal - Vlastni tema.
 1031  
      * @param e ItemEvent
 1032  
      */
 1033  
     private void myMetalThemeIM_itemStateChanged(final ItemEvent e)
 1034  
     {
 1035  0
         if (e.getStateChange() == ItemEvent.SELECTED)
 1036  
         {
 1037  0
             this.oceanMetalThemeIM.setSelected(false);
 1038  0
             this.defaultMetalThemeIM.setSelected(false);
 1039  
 
 1040  0
             this.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel", "MyMetal");
 1041  
         }
 1042  
         else
 1043  
         {
 1044  0
             if ((!this.defaultMetalThemeIM.isSelected())
 1045  
                  && (!this.oceanMetalThemeIM.isSelected()))
 1046  
             {
 1047  0
                 this.myMetalThemeIM.setSelected(true);
 1048  
             }
 1049  
         }
 1050  0
     }
 1051  
 
 1052  
     /**
 1053  
      * Obsluha udalosti pri zaskrtnuti/odsrtnuti polozky menu Tema Metal - Ocean.
 1054  
      * @param e ItemEvent
 1055  
      */
 1056  
     private void oceanMetalThemeIM_itemStateChanged(final ItemEvent e)
 1057  
     {
 1058  0
         if (e.getStateChange() == ItemEvent.SELECTED)
 1059  
         {
 1060  0
             this.defaultMetalThemeIM.setSelected(false);
 1061  0
             this.myMetalThemeIM.setSelected(false);
 1062  
 
 1063  0
             this.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel", "Ocean");
 1064  
         }
 1065  
         else
 1066  
         {
 1067  0
             if ((!this.defaultMetalThemeIM.isSelected())
 1068  
                  && (this.myMetalThemeIM.isSelected()))
 1069  
             {
 1070  0
                 this.oceanMetalThemeIM.setSelected(true);
 1071  
             }
 1072  
         }
 1073  0
     }
 1074  
 
 1075  
     /**
 1076  
      * Nastavi novy vzhled aplikace.
 1077  
      * @param vzhled String : Druh kolekce tematu.
 1078  
      * @param tema String   : Konkretni tema z dane kolekce.
 1079  
      */
 1080  
     private void setLookAndFeel(final String vzhled, final String tema)
 1081  
     {
 1082  
         try
 1083  
         {
 1084  0
             UIManager.setLookAndFeel(vzhled);
 1085  
 
 1086  0
             if (vzhled.equals("javax.swing.plaf.metal.MetalLookAndFeel"))
 1087  
             {
 1088  0
                 if (tema != null)
 1089  
                 {
 1090  0
                     if (tema.equals("DefaultMetal"))
 1091  
                     {
 1092  0
                         MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme());
 1093  
                     }
 1094  0
                     else if (tema.equals("Ocean"))
 1095  
                     {
 1096  0
                         MetalLookAndFeel.setCurrentTheme(new OceanTheme());
 1097  
                     }
 1098  0
                     else if (tema.equals("MyMetal"))
 1099  
                     {
 1100  0
                         MetalLookAndFeel.setCurrentTheme(new MyTheme());
 1101  
                     }
 1102  
                     else
 1103  
                     {
 1104  0
                         MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme());
 1105  
                     }
 1106  
                 }
 1107  0
                 UIManager.setLookAndFeel(new MetalLookAndFeel());
 1108  
             }
 1109  
 
 1110  0
             SwingUtilities.updateComponentTreeUI(Editor.getCalthaEditor());
 1111  
         }
 1112  0
         catch (ClassNotFoundException e)
 1113  
         {
 1114  
             try
 1115  
             {
 1116  0
                 final String msg1 = Editor.getResourcesBundleString("cs.pancava.caltha.MainMenu-setLookAndFeel_ClassNotFoundException_msg1");
 1117  0
                 final String msg2 = Editor.getResourcesBundleString("cs.pancava.caltha.MainMenu-setLookAndFeel_ClassNotFoundException_msg2");
 1118  0
                 final String msg3 = Editor.getResourcesBundleString("cs.pancava.caltha.MainMenu-setLookAndFeel_ClassNotFoundException_msg3");
 1119  0
                 final String  tit = Editor.getResourcesBundleString("cs.pancava.caltha.MainMenu-setLookAndFeel_ClassNotFoundException_tit");
 1120  
 
 1121  0
                 Editor.showDialog(msg1 + " " + vzhled + " " + msg2 + "\n" + e.getMessage() + "\n" + msg3,
 1122  
                                   tit,
 1123  
                                   JOptionPane.WARNING_MESSAGE);
 1124  
 
 1125  0
                 this.defaultLaFIM.doClick();
 1126  
             }
 1127  0
             catch (MissingResourceException mre)
 1128  
             {
 1129  0
                 Editor.showDialogMissingResources(mre.getMessage());
 1130  0
             }
 1131  
         }
 1132  0
         catch (UnsupportedLookAndFeelException e)
 1133  
         {
 1134  
             try
 1135  
             {
 1136  0
                 final String msg1 = Editor.getResourcesBundleString("cs.pancava.caltha.MainMenu-setLookAndFeel_UnsupportedLookAndFeelException_msg1");
 1137  0
                 final String msg2 = Editor.getResourcesBundleString("cs.pancava.caltha.MainMenu-setLookAndFeel_UnsupportedLookAndFeelException_msg2");
 1138  0
                 final String  tit = Editor.getResourcesBundleString("cs.pancava.caltha.MainMenu-setLookAndFeel_UnsupportedLookAndFeelException_tit");
 1139  
 
 1140  0
                 Editor.showDialog(msg1 + " " + vzhled + "\n" + e.getMessage() + "\n" + msg2,
 1141  
                               tit,
 1142  
                               JOptionPane.WARNING_MESSAGE);
 1143  
 
 1144  0
                 this.defaultLaFIM.doClick();
 1145  
             }
 1146  0
             catch (MissingResourceException mre)
 1147  
             {
 1148  0
                 Editor.showDialogMissingResources(mre.getMessage());
 1149  0
             }
 1150  
         }
 1151  0
         catch (Exception e)
 1152  
         {
 1153  
             try
 1154  
             {
 1155  0
                 final String msg1 = Editor.getResourcesBundleString("cs.pancava.caltha.MainMenu-setLookAndFeel_Exception_msg1");
 1156  0
                 final String msg2 = Editor.getResourcesBundleString("cs.pancava.caltha.MainMenu-setLookAndFeel_Exception_msg2");
 1157  0
                 final String  tit = Editor.getResourcesBundleString("cs.pancava.caltha.MainMenu-setLookAndFeel_Exception_tit");
 1158  
 
 1159  0
                 Editor.showDialog(msg1 + " " + vzhled + "\n" + e.getMessage() + "\n" + msg2,
 1160  
                                   tit,
 1161  
                                   JOptionPane.WARNING_MESSAGE);
 1162  
 
 1163  0
                 this.defaultLaFIM.doClick();
 1164  
             }
 1165  0
             catch (MissingResourceException mre)
 1166  
             {
 1167  0
                 Editor.showDialogMissingResources(mre.getMessage());
 1168  0
             }
 1169  0
          }
 1170  0
     }
 1171  
 
 1172  
     /**
 1173  
      * Zobrazi strucne informace o programu.
 1174  
      */
 1175  
     private void showAboutDialog()
 1176  
     {
 1177  0
         final AboutDialog ad = new AboutDialog();
 1178  0
         ad.setVisible(true);
 1179  0
     }
 1180  
 
 1181  
     /**
 1182  
      * Aktualizace vsech textu v menu.
 1183  
      * Volano pri zmene jazyka - lokalizace.
 1184  
      */
 1185  
     private void updateText()
 1186  
     {
 1187  0
         Editor.getCalthaEditor().updateText();
 1188  
 
 1189  0
         World2DPopupMenuListener.updateText();
 1190  
 
 1191  
         try
 1192  
         {
 1193  0
             this.fileMenu.setText(Editor.getResourcesBundleString("cs.pancava.caltha.MainMenu-createMenuFile_fileMenu"));
 1194  0
             this.updateTextTipMenu(this.fileMenu, "cs.pancava.caltha.MainMenu-createMenuFile_fileMenu_tip");
 1195  
 
 1196  0
               this.newMenu.setText(Editor.getResourcesBundleString("cs.pancava.caltha.MainMenu-createMenuFileNew_newMenu"));
 1197  0
               this.updateTextTipMenu(this.newMenu, "cs.pancava.caltha.MainMenu-createMenuFileNew_newMenu_tip");
 1198  
 
 1199  0
                 this.textBasedGamesIM.setText(Editor.getResourcesBundleString("cs.pancava.caltha.MainMenu-createItemMenuFileNewTextBasedGames_textBasedGamesIM"));
 1200  0
                 MainMenu.updateTextTipMenuItem(this.textBasedGamesIM, "cs.pancava.caltha.MainMenu-createItemMenuFileNewTextBasedGames_textBasedGamesIM_tip");
 1201  
 
 1202  0
               this.exitIM.setText(Editor.getResourcesBundleString("cs.pancava.caltha.MainMenu-createItemMenuFileExit_exitIM"));
 1203  0
               MainMenu.updateTextTipMenuItem(this.exitIM, "cs.pancava.caltha.MainMenu-createItemMenuFileExit_exitIM_tip");
 1204  
 
 1205  0
             this.optionsMenu.setText(Editor.getResourcesBundleString("cs.pancava.caltha.MainMenu-createMenuOptions_optionsMenu"));
 1206  0
             this.updateTextTipMenu(this.optionsMenu, "cs.pancava.caltha.MainMenu-createMenuOptions_optionsMenu_tip");
 1207  
 
 1208  0
               this.languageMenu.setText(Editor.getResourcesBundleString("cs.pancava.caltha.MainMenu-createMenuOptionsLanguage_languageMenu"));
 1209  0
               this.updateTextTipMenu(this.languageMenu, "cs.pancava.caltha.MainMenu-createMenuOptionsLanguage_languageMenu_tip");
 1210  
 
 1211  0
                 this.czechIM.setText(Editor.getResourcesBundleString("cs.pancava.caltha.MainMenu-createItemMenuOptionsLanguageCzech_czechIM"));
 1212  0
                 this.updateTextTipCheckBoxMenuItem(this.czechIM, "cs.pancava.caltha.MainMenu-createItemMenuOptionsLanguageCzech_czechIM_tip");
 1213  
 
 1214  0
                 this.englishIM.setText(Editor.getResourcesBundleString("cs.pancava.caltha.MainMenu-createItemMenuOptionsLanguageEnglish_englishIM"));
 1215  0
                 this.updateTextTipCheckBoxMenuItem(this.englishIM, "cs.pancava.caltha.MainMenu-createItemMenuOptionsLanguageEnglish_englishIM_tip");
 1216  
 
 1217  0
               this.lookAndFeelMenu.setText(Editor.getResourcesBundleString("cs.pancava.caltha.MainMenu-createMenuOptionsLookAndFeel_lookAndFeelMenu"));
 1218  0
               this.updateTextTipMenu(this.lookAndFeelMenu, "cs.pancava.caltha.MainMenu-createMenuOptionsLookAndFeel_lookAndFeelMenu_tip");
 1219  
 
 1220  0
                 this.defaultLaFIM.setText(Editor.getResourcesBundleString("cs.pancava.caltha.MainMenu-createItemMenuOptionsLookAndFeelDefaultLaF_defaultLaFIM"));
 1221  0
                 this.updateTextTipCheckBoxMenuItem(this.defaultLaFIM, "cs.pancava.caltha.MainMenu-createItemMenuOptionsLookAndFeelDefaultLaF_defaultLaFIM_tip");
 1222  
 
 1223  0
                 this.gtkLaFIM.setText(Editor.getResourcesBundleString("cs.pancava.caltha.MainMenu-createItemMenuOptionsLookAndFeelGtkLaF_gtkLaFIM"));
 1224  0
                 this.updateTextTipCheckBoxMenuItem(this.gtkLaFIM, "cs.pancava.caltha.MainMenu-createItemMenuOptionsLookAndFeelGtkLaF_gtkLaFIM_tip");
 1225  
 
 1226  0
                 this.macLaFIM.setText(Editor.getResourcesBundleString("cs.pancava.caltha.MainMenu-createItemMenuOptionsLookAndFeelMacLaF_macLaFIM"));
 1227  0
                 this.updateTextTipCheckBoxMenuItem(this.macLaFIM, "cs.pancava.caltha.MainMenu-createItemMenuOptionsLookAndFeelMacLaF_macLaFIM_tip");
 1228  
 
 1229  0
                 this.metalLaFIM.setText(Editor.getResourcesBundleString("cs.pancava.caltha.MainMenu-createItemMenuOptionsLookAndFeelMetalLaF_metalLaFIM"));
 1230  0
                 this.updateTextTipCheckBoxMenuItem(this.metalLaFIM, "cs.pancava.caltha.MainMenu-createItemMenuOptionsLookAndFeelMetalLaF_metalLaFIM_tip");
 1231  
 
 1232  0
                 this.motifLaFIM.setText(Editor.getResourcesBundleString("cs.pancava.caltha.MainMenu-createItemMenuOptionsLookAndFeelMotifLaF_motifLaFIM"));
 1233  0
                 this.updateTextTipCheckBoxMenuItem(this.motifLaFIM, "cs.pancava.caltha.MainMenu-createItemMenuOptionsLookAndFeelMotifLaF_motifLaFIM_tip");
 1234  
 
 1235  0
                 this.windowsLaFIM.setText(Editor.getResourcesBundleString("cs.pancava.caltha.MainMenu-createItemMenuOptionsLookAndFeelWindowsLaF_windowsLaFIM"));
 1236  0
                 this.updateTextTipCheckBoxMenuItem(this.windowsLaFIM, "cs.pancava.caltha.MainMenu-createItemMenuOptionsLookAndFeelWindowsLaF_windowsLaFIM_tip");
 1237  
 
 1238  0
                 this.metalThemeMenu.setText(Editor.getResourcesBundleString("cs.pancava.caltha.MainMenu-createMenuOptionsLookAndFeelMetalTheme_metalThemeMenu"));
 1239  0
                 this.updateTextTipCheckBoxMenuItem(this.metalThemeMenu, "cs.pancava.caltha.MainMenu-createMenuOptionsLookAndFeelMetalTheme_metalThemeMenu_tip");
 1240  
 
 1241  0
                   this.defaultMetalThemeIM.setText(Editor.getResourcesBundleString("cs.pancava.caltha.MainMenu-createItemMenuOptionsLookAndFeelMetalThemeDefault_defaultMetalThemeIM"));
 1242  0
                   this.updateTextTipCheckBoxMenuItem(this.defaultMetalThemeIM, "cs.pancava.caltha.MainMenu-createItemMenuOptionsLookAndFeelMetalThemeDefault_defaultMetalThemeIM_tip");
 1243  
 
 1244  0
                   this.oceanMetalThemeIM.setText(Editor.getResourcesBundleString("cs.pancava.caltha.MainMenu-createItemMenuOptionsLookAndFeelMetalThemeOcean_oceanMetalThemeIM"));
 1245  0
                   this.updateTextTipCheckBoxMenuItem(this.oceanMetalThemeIM, "cs.pancava.caltha.MainMenu-createItemMenuOptionsLookAndFeelMetalThemeOcean_oceanMetalThemeIM_tip");
 1246  
 
 1247  0
                   this.myMetalThemeIM.setText(Editor.getResourcesBundleString("cs.pancava.caltha.MainMenu-createItemMenuOptionsLookAndFeelMetalThemeMyMetal_myMetalThemeIM"));
 1248  0
                   this.updateTextTipCheckBoxMenuItem(this.myMetalThemeIM, "cs.pancava.caltha.MainMenu-createItemMenuOptionsLookAndFeelMetalThemeMyMetal_myMetalThemeIM_tip");
 1249  
 
 1250  0
             this.helpMenu.setText(Editor.getResourcesBundleString("cs.pancava.caltha.MainMenu-createMenuHelp_helpMenu"));
 1251  0
             this.updateTextTipMenu(this.helpMenu, "cs.pancava.caltha.MainMenu-createMenuHelp_helpMenu_tip");
 1252  
 
 1253  0
               this.aboutIM.setText(Editor.getResourcesBundleString("cs.pancava.caltha.MainMenu-createItemMenuHelpAbout_aboutIM"));
 1254  0
               MainMenu.updateTextTipMenuItem(this.aboutIM, "cs.pancava.caltha.MainMenu-createItemMenuHelpAbout_aboutIM");
 1255  
         }
 1256  0
         catch (MissingResourceException e)
 1257  
         {
 1258  0
             Editor.showDialogMissingResources(e.getMessage());
 1259  0
         }
 1260  0
     }
 1261  
 
 1262  
     /**
 1263  
      * Zmeni tip zaskrtavaci polozce menu, pokud je definovan.
 1264  
      * @param cbmi JMenuItem : Polozka, ktere menime tip.
 1265  
      * @param tip String     : Klic k tipu.
 1266  
      */
 1267  
     private void updateTextTipCheckBoxMenuItem(final JCheckBoxMenuItem cbmi, final String tip)
 1268  
     {
 1269  0
         if (Editor.getResourcesBundleString(tip).trim().length() != 0)
 1270  
         {
 1271  0
             cbmi.setToolTipText(Editor.getResourcesBundleString(tip));
 1272  
         }
 1273  0
     }
 1274  
 
 1275  
     /**
 1276  
      * Zmeni tip zaskrtavaci polozce menu, pokud je definovan.
 1277  
      * @param m JMenu    : Polozka, ktere menime tip.
 1278  
      * @param tip String : Klic k tipu.
 1279  
      */
 1280  
     private void updateTextTipCheckBoxMenuItem(final JMenu m, final String tip)
 1281  
     {
 1282  0
         if (Editor.getResourcesBundleString(tip).trim().length() != 0)
 1283  
         {
 1284  0
             m.setToolTipText(Editor.getResourcesBundleString(tip));
 1285  
         }
 1286  0
     }
 1287  
 
 1288  
     /**
 1289  
      * Zmeni tip menu, pokud je definovan.
 1290  
      * @param m JMenu    : Menu, kteremu menime tip.
 1291  
      * @param tip String : Klic k tipu.
 1292  
      */
 1293  
     private void updateTextTipMenu(final JMenu m, final String tip)
 1294  
     {
 1295  0
         if (Editor.getResourcesBundleString(tip).trim().length() != 0)
 1296  
         {
 1297  0
             m.setToolTipText(Editor.getResourcesBundleString(tip));
 1298  
         }
 1299  0
     }
 1300  
 
 1301  
     /**
 1302  
      * Zmeni tip polozce menu, pokud je definovan.
 1303  
      * @param mi JMenuItem : Polozka, ktere menime tip.
 1304  
      * @param tip String   : Klic k tipu.
 1305  
      */
 1306  
     public static void updateTextTipMenuItem(final JMenuItem mi, final String tip)
 1307  
     {
 1308  0
           if (Editor.getResourcesBundleString(tip).trim().length() != 0)
 1309  
           {
 1310  0
               mi.setToolTipText(Editor.getResourcesBundleString(tip));
 1311  
           }
 1312  0
     }
 1313  
 
 1314  
     /**
 1315  
      * Obsluha udalosti pri zaskrtnuti/odsrtnuti polozky menu Vzhled - Windows.
 1316  
      * @param e ItemEvent
 1317  
      */
 1318  
     private void windowsLaFIM_itemStateChanged(final ItemEvent e)
 1319  
     {
 1320  0
         if (e.getStateChange() == ItemEvent.SELECTED)
 1321  
         {
 1322  0
             this.defaultLaFIM.setSelected(false);
 1323  0
             this.gtkLaFIM.setSelected(false);
 1324  0
             this.macLaFIM.setSelected(false);
 1325  0
             this.metalLaFIM.setSelected(false);
 1326  0
             this.motifLaFIM.setSelected(false);
 1327  
 
 1328  0
             this.metalThemeMenu.setEnabled(false);
 1329  
 
 1330  0
             this.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel", null);
 1331  
         }
 1332  
         else
 1333  
         {
 1334  0
             if ((!this.defaultLaFIM.isSelected())
 1335  
                  && (!this.gtkLaFIM.isSelected())
 1336  
                  && (!this.macLaFIM.isSelected())
 1337  
                  && (!this.metalLaFIM.isSelected())
 1338  
                  && (!this.motifLaFIM.isSelected()))
 1339  
             {
 1340  0
                 this.windowsLaFIM.setSelected(true);
 1341  
             }
 1342  
         }
 1343  0
     }
 1344  
 }