Package org.eclipse.swt.program

Examples of org.eclipse.swt.program.Program


    shell.open();

    link1.addListener(SWT.Selection, new Listener() {
      public void handleEvent(Event event) {
        System.out.println("Selection: " + event.text);
        Program pBrowse = Program.findProgram(".html");
        pBrowse.execute(event.text);
      }
    });
    link2.addListener(SWT.Selection, new Listener() {
      public void handleEvent(Event event) {
        System.out.println("Selection: " + event.text);
        if (event.text.contains("mailto")
            || event.text.contains("http")) {
          Program pBrowse = Program.findProgram(".html");
          pBrowse.execute(event.text);
        }

      }
    });
    link3.addListener(SWT.Selection, new Listener() {
      public void handleEvent(Event event) {
        System.out.println("Selection: " + event.text);
        if (event.text.contains("http")) {
          Program pBrowse = Program.findProgram(".html");
          pBrowse.execute(event.text);
        }
        if (event.text.contains("mailto")) {
          Program pBrowse = Program.findProgram(".html");
          pBrowse.execute(event.text);
        }
      }
    });
    link4.addListener(SWT.Selection, new Listener() {
      public void handleEvent(Event event) {
        System.out.println("Selection: " + event.text);
        Program pBrowse = Program.findProgram(".html");
        pBrowse.execute(event.text);
      }
    });
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
View Full Code Here


          if (rCode == SWT.YES) {
            /*
             * Opens the default browser. Or any program which opens
             * .html files by default
             */
            Program pBrowse = Program.findProgram(".html");

            pBrowse
                .execute("http://code.google.com/p/indic-keyboards");

          } else {

            sh.dispose();
          }

        }
      });

      /**
       * Menu object contains the Items - Languages, Help, Links, About,
       * Userdefined Keyboard Layouts..
       */
      final Menu menu = new Menu(shell, SWT.POP_UP); /*
                               * The main menu
                               * obtained when the
                               * tray is right
                               * clicked
                               */
      /* Used to load user defined keyboard layouts */
      final MenuItem currentLayout = new MenuItem(menu, SWT.PUSH);
      currentLayout.setText("Show Current Layout");
      currentLayout.setEnabled(false);
      new MenuItem(menu, SWT.SEPARATOR);

      final MenuItem bengali = new MenuItem(menu, SWT.CASCADE);
      bengali.setText("Bengali");
      final Menu submenu_ben = new Menu(shell, SWT.DROP_DOWN);
      bengali.setMenu(submenu_ben);
      final MenuItem benInscript = new MenuItem(submenu_ben, SWT.PUSH);
      benInscript.setText("Inscript");

      final MenuItem gujarati = new MenuItem(menu, SWT.CASCADE);
      gujarati.setText("Gujarati");
      final Menu submenu_guj = new Menu(shell, SWT.DROP_DOWN);
      gujarati.setMenu(submenu_guj);
      final MenuItem gujInscript = new MenuItem(submenu_guj, SWT.PUSH);
      gujInscript.setText("Inscript");
      new MenuItem(submenu_guj, SWT.SEPARATOR);
      final MenuItem gujPhonetic = new MenuItem(submenu_guj, SWT.PUSH);
      gujPhonetic.setText("Phonetic");

      final MenuItem gurmukhi = new MenuItem(menu, SWT.CASCADE);
      gurmukhi.setText("Gurmukhi");
      final Menu submenu_gur = new Menu(shell, SWT.DROP_DOWN);
      gurmukhi.setMenu(submenu_gur);
      final MenuItem gurInscript = new MenuItem(submenu_gur, SWT.PUSH);
      gurInscript.setText("Inscript");

      final MenuItem hindi = new MenuItem(menu, SWT.CASCADE);
      hindi.setText("Hindi");
      final Menu submenu_hin = new Menu(shell, SWT.DROP_DOWN);
      hindi.setMenu(submenu_hin);
      final MenuItem hinLay = new MenuItem(submenu_hin, SWT.PUSH);
      hinLay.setText("Remington");
      final MenuItem hinInscript = new MenuItem(submenu_hin, SWT.PUSH);
      hinInscript.setText("Inscript");
      new MenuItem(submenu_hin, SWT.SEPARATOR);
      final MenuItem hinPhonetic = new MenuItem(submenu_hin, SWT.PUSH);
      hinPhonetic.setText("Phonetic");

      final MenuItem kannada = new MenuItem(menu, SWT.CASCADE);
      kannada.setText("Kannada");
      final Menu submenu_kan = new Menu(shell, SWT.DROP_DOWN);
      kannada.setMenu(submenu_kan);
      final MenuItem kgp = new MenuItem(submenu_kan, SWT.PUSH);
      kgp.setText("KaGaPa");
      final MenuItem kanInscript = new MenuItem(submenu_kan, SWT.PUSH);
      kanInscript.setText("Inscript");
      new MenuItem(submenu_kan, SWT.SEPARATOR);
      final MenuItem kanPhonetic = new MenuItem(submenu_kan, SWT.PUSH);
      kanPhonetic.setText("Phonetic");

      final MenuItem malayalam = new MenuItem(menu, SWT.CASCADE);
      malayalam.setText("Malayalam");
      final Menu submenu_mal = new Menu(shell, SWT.DROP_DOWN);
      malayalam.setMenu(submenu_mal);
      final MenuItem malInscript = new MenuItem(submenu_mal, SWT.PUSH);
      malInscript.setText("Inscript");

      final MenuItem marathi = new MenuItem(menu, SWT.CASCADE);
      marathi.setText("Marathi");
      final Menu submenu_mar = new Menu(shell, SWT.DROP_DOWN);
      marathi.setMenu(submenu_mar);
      final MenuItem marLay = new MenuItem(submenu_mar, SWT.PUSH);
      marLay.setText("Remington");
      final MenuItem marInscript = new MenuItem(submenu_mar, SWT.PUSH);
      marInscript.setText("Inscript");
      new MenuItem(submenu_mar, SWT.SEPARATOR);
      final MenuItem marPhonetic = new MenuItem(submenu_mar, SWT.PUSH);
      marPhonetic.setText("Phonetic");

      final MenuItem oriya = new MenuItem(menu, SWT.CASCADE);
      oriya.setText("Oriya");
      final Menu submenu_ori = new Menu(shell, SWT.DROP_DOWN);
      oriya.setMenu(submenu_ori);
      final MenuItem oriInscript = new MenuItem(submenu_ori, SWT.PUSH);
      oriInscript.setText("Inscript");

      final MenuItem tamil = new MenuItem(menu, SWT.CASCADE);
      tamil.setText("Tamil");
      final Menu submenu_tam = new Menu(shell, SWT.DROP_DOWN);
      tamil.setMenu(submenu_tam);
      final MenuItem tamil99 = new MenuItem(submenu_tam, SWT.PUSH);
      tamil99.setText("Tamil99");
      final MenuItem tamInscript = new MenuItem(submenu_tam, SWT.PUSH);
      tamInscript.setText("Inscript");
      final MenuItem tamBamini = new MenuItem(submenu_tam, SWT.PUSH);
      tamBamini.setText("Bamini");
      final MenuItem tamRemington = new MenuItem(submenu_tam, SWT.PUSH);
      tamRemington.setText("Remington");
      new MenuItem(submenu_tam, SWT.SEPARATOR);
      final MenuItem tamPhonetic = new MenuItem(submenu_tam, SWT.PUSH);
      tamPhonetic.setText("Phonetic");

      final MenuItem telugu = new MenuItem(menu, SWT.CASCADE);
      telugu.setText("Telugu");
      final Menu submenu_tel = new Menu(shell, SWT.DROP_DOWN);
      telugu.setMenu(submenu_tel);
      final MenuItem telInscript = new MenuItem(submenu_tel, SWT.PUSH);
      telInscript.setText("Inscript");
      new MenuItem(submenu_tel, SWT.SEPARATOR);
      final MenuItem telPhonetic = new MenuItem(submenu_tel, SWT.PUSH);
      telPhonetic.setText("Phonetic");

      /*
       * Adding user defined layouts to the menu. First check whether the
       * userdefined directory exists then read the files in it one by
       * one. Add them to the menu.
       */
      new MenuItem(menu, SWT.SEPARATOR);
      File dirname = new File(System.getProperty("user.dir"),
          "/kblayouts/userdefined");

      String[] userDefinedLayouts = dirname.list();
      if (userDefinedLayouts == null) {
        // Either dir does not exist or is not a directory
      } else {
        final MenuItem user_def = new MenuItem(menu, SWT.CASCADE);
        user_def.setText("User Defined");
        final Menu submenu_user_def = new Menu(shell, SWT.DROP_DOWN);
        user_def.setMenu(submenu_user_def);
        new MenuItem(menu, SWT.SEPARATOR);
        for (int i = 0; i < userDefinedLayouts.length; i++) {
          // Get filename of file or directory
          final String filename = userDefinedLayouts[i];
          final MenuItem mi = new MenuItem(submenu_user_def, SWT.PUSH);
          mi.setText(filename.substring(0, filename.length() - 4));

          // Listeners for the user defined keyboard layout menu items
          mi.addListener(SWT.Selection, new Listener() {

            public void handleEvent(Event event) {
              {
                layoutImg = "na";
                currentLayout.setEnabled(false);
                Image image1 = new Image(display,
                    IndicKeyboards.workingDirectory
                        + "/resources/UD.ico");
                item.setImage(image1);
                tip.setMessage("Custom Created  - "
                    + filename.substring(0, filename
                        .length() - 4));
                tip.setVisible(true);
                ParseXML.setlang("userdefined/" + filename);
                PhoneticParseXML.PhoneticFlag = 0;
                item
                    .setToolTipText("indic-keyboards - User Defined - "
                        + filename.substring(0,
                            filename.length() - 4));
              }
            }
          });
          // End of listener
        }
      }

      final MenuItem addLayouts = new MenuItem(menu, SWT.CASCADE);
      addLayouts.setText("Add New Layouts");
      final Menu submenu_newLay = new Menu(shell, SWT.DROP_DOWN);
      addLayouts.setMenu(submenu_newLay);

      final MenuItem XMLCreateIns = new MenuItem(submenu_newLay, SWT.PUSH);
      XMLCreateIns.setText("Add Inscript Layout");

      /*
       * final MenuItem XMLCreateOth = new MenuItem(submenu_newLay,
       * SWT.PUSH); XMLCreateOth.setText("Add Other Layout");
       */
      new MenuItem(menu, SWT.SEPARATOR);

      enableDisable = new MenuItem(menu, SWT.PUSH);
      enableDisable.setText("Enable [Alt+F12]");

      new MenuItem(menu, SWT.SEPARATOR);

      final MenuItem links = new MenuItem(menu, SWT.CASCADE);
      links.setText("Useful Links");
      final Menu submenu2 = new Menu(shell, SWT.DROP_DOWN);
      links.setMenu(submenu2);
      final MenuItem langtech = new MenuItem(submenu2, SWT.PUSH);
      langtech.setText("Language Technology");
      final MenuItem codegoogle = new MenuItem(submenu2, SWT.PUSH);
      codegoogle.setText("indic-keyboards code.google.com");
      final MenuItem IKdev = new MenuItem(submenu2, SWT.PUSH);
      IKdev.setText("indic-keyboards Developer mailing list");
      final MenuItem IKscm = new MenuItem(submenu2, SWT.PUSH);
      IKscm.setText("indic-keyboards SCM group");
      final MenuItem IKuser = new MenuItem(submenu2, SWT.PUSH);
      IKuser.setText("indic-keyboards User mailing list");

      new MenuItem(menu, SWT.SEPARATOR);

      final MenuItem help = new MenuItem(menu, SWT.PUSH);
      help.setText("Help");

      new MenuItem(menu, SWT.SEPARATOR);

      final MenuItem about = new MenuItem(menu, SWT.PUSH);
      about.setText("About indic-keyboards");

      new MenuItem(menu, SWT.SEPARATOR);

      final MenuItem exit = new MenuItem(menu, SWT.PUSH);
      exit.setText("Exit");

      exit.addListener(SWT.Selection, new Listener() {
        public void handleEvent(Event event) {
          Shell sh = new Shell(display, SWT.APPLICATION_MODAL);
          sh.setImage(image);
          MessageBox messageBox = new MessageBox(sh, SWT.YES | SWT.NO
              | SWT.ICON_QUESTION);
          messageBox.setText("Exit");
          if (System.getProperty("os.name").contains("Windows")) {
            messageBox.setMessage("Do you want to exit indic-keyboards?");
          } else {
//            String pid = ManagementFactory.getRuntimeMXBean()
//                .getName();
//            int index = pid.indexOf("@");
            messageBox.setMessage("Do you want to exit indic-keyboards?"
                    + "\n\nIf the application doesn't close\nwhen Exit is selected, "
                    + "kill the process.\n\n(The process ID is "
//                    + pid.substring(0, index)
                    + ")");
          }
          int rCode = messageBox.open();
          if (rCode == SWT.YES) {
            image.dispose();
            shell.dispose();
            display.dispose();
            /*
             * When the program stops running, if the Key Logging is
             * enabled, auto repeat will stop working. So make sure
             * that auto repeat is ON when the program quits.
             */
            if (System.getProperty("os.name").contains("Windows")) {
              System.runFinalization();
              System.exit(0);
            } else {
              KeyMonitorMethods quit = new KeyMonitorMethods();
              KeyMonitorMethods.loggingEnabled = true;
              quit.printKeys(88); // Enable Auto Repeat.
              try {
                InitLinux.socket.close();
              } catch (IOException e) {
                e.printStackTrace();
              }
              System.runFinalization();
              System.exit(0);
            }
          } else {
            sh.dispose();
          }
        }
      });

      help.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event event) {
          File docsDir = new File("./docs/index.html");
          if (!docsDir.exists()) {
            Shell sh = new Shell(display, SWT.APPLICATION_MODAL);
            sh.setImage(image);
            MessageBox messageBox = new MessageBox(sh, SWT.OK
                | SWT.ICON_ERROR);
            messageBox.setText("Help File Not Found");
            messageBox
                .setMessage("index.html not found! Make sure it is present in docs\ndirectory");
            messageBox.open();
          } else {
            Program pBrowse = Program.findProgram(".html");
            pBrowse.execute("./docs/index.html");
          }

        }
      });

      // XML Create Listener for Inscript like keyboards
      XMLCreateIns.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event event) {
          XMLGenerator.GenerateXMLUI();
        }
      });
      /*
       * // XML Create Listener for other keyboards
       * XMLCreateOth.addListener(SWT.Selection, new Listener() {
       *
       * public void handleEvent(Event event) { String d =
       * XMLCreateOth.getText(); exit.setSelection(false); if
       * (d.compareTo("Add Other Layout") == 0) {
       * XMLGenerator.GenerateXMLUI(); } else {
       *
       * } } });
       */
      // All the kannada layouts go here
      {

        kgp.addListener(SWT.Selection, new Listener() {
          public void handleEvent(Event event) {
            kgp.setSelection(false);
            {
              layoutImg = "kagapa";
              currentLayout.setEnabled(true);
              tip.setMessage("KaGaPa");
              tip.setVisible(true);
              // Set the selected language to be kan_kagapa.xml.
              ParseXML.setlang("kan_kagapa.xml");
              PhoneticParseXML.PhoneticFlag = 0;
              Image image1 = new Image(display,
                  IndicKeyboards.workingDirectory
                      + "/resources/kannada.ico");
              item.setImage(image1);
              item
                  .setToolTipText("indic-keyboards - KANNADA KaGaPa");
              previousKeyboardIcon = item.getImage();
            }
          }
        });

        kanInscript.addListener(SWT.Selection, new Listener() {
          public void handleEvent(Event event) {
            {
              layoutImg = "kannada_inscript";
              currentLayout.setEnabled(true);
              tip.setMessage("Kannada Inscript");
              tip.setVisible(true);
              ParseXML.setlang("kan_inscript.xml");
              PhoneticParseXML.PhoneticFlag = 0;
              Image image1 = new Image(display,
                  IndicKeyboards.workingDirectory
                      + "/resources/kannada.ico");
              item.setImage(image1);
              item
                  .setToolTipText("indic-keyboards - KANNADA Inscript");
              previousKeyboardIcon = item.getImage();
            }
          }
        });

        kanPhonetic.addListener(SWT.Selection, new Listener() {
          public void handleEvent(Event event) {
            {
              currentLayout.setEnabled(false);
              tip.setMessage("Kannada Phonetic");
              tip.setVisible(true);
              PhoneticParseXML.setlang("kan_phonetic.xml");
              PhoneticParseXML.PhoneticFlag = 1;
              Image image1 = new Image(display,
                  IndicKeyboards.workingDirectory
                      + "/resources/kannada.ico");
              item.setImage(image1);
              item
                  .setToolTipText("indic-keyboards - KANNADA Phonetic");
              previousKeyboardIcon = item.getImage();
            }
          }
        });

      }// End of kannada section

      // All the tamil layouts go here
      {
        tamil99.addListener(SWT.Selection, new Listener() {
          public void handleEvent(Event event) {
            {
              layoutImg = "tamil99";
              currentLayout.setEnabled(true);
              tip.setMessage("Tamil99");
              tip.setVisible(true);
              ParseXML.setlang("tamil99.xml");
              PhoneticParseXML.PhoneticFlag = 0;
              Image image1 = new Image(display,
                  IndicKeyboards.workingDirectory
                      + "/resources/tamil.ico");
              item.setImage(image1);
              item
                  .setToolTipText("indic-keyboards - TAMIL Tamil99");
              previousKeyboardIcon = item.getImage();
            }

          }
        });

        tamInscript.addListener(SWT.Selection, new Listener() {

          public void handleEvent(Event event) {
            {
              layoutImg = "tamil_inscript";
              currentLayout.setEnabled(true);
              tip.setMessage("Tamil Inscript");
              tip.setVisible(true);
              ParseXML.setlang("tam_inscript.xml");
              PhoneticParseXML.PhoneticFlag = 0;
              Image image1 = new Image(display,
                  IndicKeyboards.workingDirectory
                      + "/resources/tamil.ico");
              item.setImage(image1);
              item
                  .setToolTipText("indic-keyboards - TAMIL Inscript");
              previousKeyboardIcon = item.getImage();
            }

          }
        });

        tamBamini.addListener(SWT.Selection, new Listener() {

          public void handleEvent(Event event) {
            {
              layoutImg = "tamil_bamini_inscript";
              currentLayout.setEnabled(true);
              tip.setMessage("Tamil Bamini");
              tip.setVisible(true);
              ParseXML.setlang("tam_bamini_inscript.xml");
              PhoneticParseXML.PhoneticFlag = 0;
              Image image1 = new Image(display,
                  IndicKeyboards.workingDirectory
                      + "/resources/tamil.ico");
              item.setImage(image1);
              item
                  .setToolTipText("indic-keyboards - TAMIL Bamini");
              previousKeyboardIcon = item.getImage();
            }

          }
        });
        tamRemington.addListener(SWT.Selection, new Listener() {

          public void handleEvent(Event event) {
            {
              layoutImg = "tamil_remington";
              currentLayout.setEnabled(true);
              tip.setMessage("Tamil Remington");
              tip.setVisible(true);
              ParseXML.setlang("tam_remington_inscript.xml");
              PhoneticParseXML.PhoneticFlag = 0;
              Image image1 = new Image(display,
                  IndicKeyboards.workingDirectory
                      + "/resources/tamil.ico");
              item.setImage(image1);
              item
                  .setToolTipText("indic-keyboards - TAMIL Remington");
              previousKeyboardIcon = item.getImage();
            }

          }
        });

        // Tamil Phonetic keyboard layout
        tamPhonetic.addListener(SWT.Selection, new Listener() {

          public void handleEvent(Event event) {
            {
              tip.setMessage("Tamil Phonetic");
              tip.setVisible(true);
              PhoneticParseXML.setlang("tam_phonetic.xml");
              PhoneticParseXML.PhoneticFlag = 1;
              Image image1 = new Image(display,
                  IndicKeyboards.workingDirectory
                      + "/resources/tamil.ico");
              item.setImage(image1);
              item
                  .setToolTipText("indic-keyboards - TAMIL Phonetic");
              previousKeyboardIcon = item.getImage();
            }
          }
        });

      }// End of tamil section

      // All telugu layouts go here
      {
        telInscript.addListener(SWT.Selection, new Listener() {

          public void handleEvent(Event event) {
            {
              layoutImg = "telugu_inscript";
              currentLayout.setEnabled(true);
              tip.setMessage("Telugu Inscript");
              tip.setVisible(true);
              ParseXML.setlang("tel_inscript.xml");
              PhoneticParseXML.PhoneticFlag = 0;
              Image image1 = new Image(display,
                  IndicKeyboards.workingDirectory
                      + "/resources/telugu.ico");
              item.setImage(image1);
              item
                  .setToolTipText("indic-keyboards - TELUGU Inscript");
              previousKeyboardIcon = item.getImage();
            }

          }
        });
        // Telugu phonetic keyboard listener
        telPhonetic.addListener(SWT.Selection, new Listener() {

          public void handleEvent(Event event) {
            {
              tip.setMessage("Telugu Phonetic");
              currentLayout.setEnabled(false);
              tip.setVisible(true);
              PhoneticParseXML.setlang("tel_phonetic.xml");
              PhoneticParseXML.PhoneticFlag = 1;
              Image image1 = new Image(display,
                  IndicKeyboards.workingDirectory
                      + "/resources/telugu.ico");
              item.setImage(image1);
              item
                  .setToolTipText("indic-keyboards - TELUGU Phonetic");
              previousKeyboardIcon = item.getImage();
            }
          }
        });

      }

      // All the gujarati layouts go here
      {

        gujInscript.addListener(SWT.Selection, new Listener() {
          public void handleEvent(Event event) {
            gujInscript.setSelection(false);
            {
              layoutImg = "gujarati_inscript";
              currentLayout.setEnabled(true);
              tip.setMessage("Gujrathi Inscript");
              tip.setVisible(true);
              ParseXML.setlang("guj_inscript.xml");
              PhoneticParseXML.PhoneticFlag = 0;
              Image image1 = new Image(display,
                  IndicKeyboards.workingDirectory
                      + "/resources/gujarati.ico");
              item.setImage(image1);
              item
                  .setToolTipText("indic-keyboards - GUJRATI Inscript");
              previousKeyboardIcon = item.getImage();
            }

          }
        });
        // Gujarati Phonetic keyboard listener
        gujPhonetic.addListener(SWT.Selection, new Listener() {

          public void handleEvent(Event event) {
            gujPhonetic.setSelection(false);
            {
              tip.setMessage("Gujarati Phonetic");
              currentLayout.setEnabled(false);
              tip.setVisible(true);
              PhoneticParseXML.setlang("guj_phonetic.xml");
              PhoneticParseXML.PhoneticFlag = 1;
              Image image1 = new Image(display,
                  IndicKeyboards.workingDirectory
                      + "/resources/gujarati.ico");
              item.setImage(image1);
              item
                  .setToolTipText("indic-keyboards - GUJARATI Phonetic");
              previousKeyboardIcon = item.getImage();
            }
          }
        });

      }// End of gujarati section

      // All the Hindi layouts go here
      {
        hinLay.addListener(SWT.Selection, new Listener() {

          public void handleEvent(Event event) {
            hinLay.setSelection(false);
            {
              layoutImg = "hindi_remington";
              currentLayout.setEnabled(true);
              tip.setMessage("Hindi Remington");
              tip.setVisible(true);
              ParseXML.setlang("hin_remington_inscript.xml");
              PhoneticParseXML.PhoneticFlag = 0;
              Image image1 = new Image(display,
                  IndicKeyboards.workingDirectory
                      + "/resources/hindi.ico");
              item.setImage(image1);
              item
                  .setToolTipText("indic-keyboards - HINDI Remington");
              previousKeyboardIcon = item.getImage();

            }

          }
        });

        hinInscript.addListener(SWT.Selection, new Listener() {

          public void handleEvent(Event event) {
            hinInscript.setSelection(false);
            {
              layoutImg = "hindi_inscript";
              currentLayout.setEnabled(true);
              tip.setMessage("Hindi Inscript");
              tip.setVisible(true);

              ParseXML.setlang("hin_inscript.xml");
              PhoneticParseXML.PhoneticFlag = 0;
              Image image1 = new Image(display,
                  IndicKeyboards.workingDirectory
                      + "/resources/hindi.ico");
              item.setImage(image1);
              item
                  .setToolTipText("indic-keyboards - HINDI Inscript");
              previousKeyboardIcon = item.getImage();
            }

          }
        });
        // Hindi Phonetic keyboard listener
        hinPhonetic.addListener(SWT.Selection, new Listener() {

          public void handleEvent(Event event) {
            hinPhonetic.setSelection(false);
            {
              tip.setMessage("Hindi Phonetic");
              currentLayout.setEnabled(false);
              tip.setVisible(true);
              PhoneticParseXML.setlang("hin_phonetic.xml");
              PhoneticParseXML.PhoneticFlag = 1;
              Image image1 = new Image(display,
                  IndicKeyboards.workingDirectory
                      + "/resources/hindi.ico");
              item.setImage(image1);
              item
                  .setToolTipText("indic-keyboards - HINDI Phonetic");
              previousKeyboardIcon = item.getImage();
            }
          }
        });

      }// End of hindi section

      // All the marathi layouts go here
      {
        marLay.addListener(SWT.Selection, new Listener() {

          public void handleEvent(Event event) {
            marLay.setSelection(false);
            {
              layoutImg = "hindi_remington";
              currentLayout.setEnabled(true);
              tip.setMessage("Marathi Remington");
              tip.setVisible(true);
              ParseXML.setlang("hin_remington_inscript.xml");
              PhoneticParseXML.PhoneticFlag = 0;
              Image image1 = new Image(display,
                  IndicKeyboards.workingDirectory
                      + "/resources/hindi.ico");
              item.setImage(image1);
              item.setToolTipText("indic-keyboards - MARATHI");
              previousKeyboardIcon = item.getImage();
            }

          }
        });

        marInscript.addListener(SWT.Selection, new Listener() {

          public void handleEvent(Event event) {
            marInscript.setSelection(false);
            {
              layoutImg = "hindi_inscript";
              currentLayout.setEnabled(true);
              tip.setMessage("Marathi Inscript");
              tip.setVisible(true);
              ParseXML.setlang("mar_inscript.xml");
              PhoneticParseXML.PhoneticFlag = 0;
              Image image1 = new Image(display,
                  IndicKeyboards.workingDirectory
                      + "/resources/hindi.ico");
              item.setImage(image1);
              item
                  .setToolTipText("indic-keyboards - MARATHI Inscript");
              previousKeyboardIcon = item.getImage();
            }

          }
        });
        // Marathi phonetic keyboard listener
        marPhonetic.addListener(SWT.Selection, new Listener() {

          public void handleEvent(Event event) {
            marPhonetic.setSelection(false);
            {
              tip.setMessage("Marathi Phonetic");
              currentLayout.setEnabled(false);
              tip.setVisible(true);
              PhoneticParseXML.setlang("hin_phonetic.xml");
              PhoneticParseXML.PhoneticFlag = 1;
              Image image1 = new Image(display,
                  IndicKeyboards.workingDirectory
                      + "/resources/hindi.ico");
              item.setImage(image1);
              item
                  .setToolTipText("indic-keyboards - MARATHI Phonetic");
              previousKeyboardIcon = item.getImage();
            }
          }
        });

      }// End of marathi section

      // Bengali layout listener goes here
      benInscript.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event event) {
          benInscript.setSelection(false);
          {
            layoutImg = "bengali_inscript";
            currentLayout.setEnabled(true);
            tip.setMessage("Bengali Inscript");
            tip.setVisible(true);
            ParseXML.setlang("ben_inscript.xml");
            PhoneticParseXML.PhoneticFlag = 0;
            Image image1 = new Image(display,
                IndicKeyboards.workingDirectory
                    + "/resources/bengali.ico");
            item.setImage(image1);
            item
                .setToolTipText("indic-keyboards - BENGALI Inscript");
            previousKeyboardIcon = item.getImage();
          }

        }
      });

      // Punjabi layout listeners goes here
      gurInscript.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event event) {
          gurInscript.setSelection(false);
          {
            layoutImg = "gurmukhi_inscript";
            currentLayout.setEnabled(true);
            tip.setMessage("Gurmukhi Inscript");
            tip.setVisible(true);
            ParseXML.setlang("gur_inscript.xml");
            PhoneticParseXML.PhoneticFlag = 0;
            Image image1 = new Image(display,
                IndicKeyboards.workingDirectory
                    + "/resources/gurmukhi.ico");
            item.setImage(image1);
            item
                .setToolTipText("indic-keyboards - GURMUKHI Inscript");
            previousKeyboardIcon = item.getImage();
          }

        }
      });

      // Malayalam layout listener goes here
      malInscript.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event event) {
          malInscript.setSelection(false);
          {
            layoutImg = "malayalam_inscript";
            currentLayout.setEnabled(true);
            tip.setMessage("Malayalam Inscript");
            tip.setVisible(true);
            ParseXML.setlang("mal_inscript.xml");
            PhoneticParseXML.PhoneticFlag = 0;
            Image image1 = new Image(display,
                IndicKeyboards.workingDirectory
                    + "/resources/malayalam.ico");
            item.setImage(image1);
            item
                .setToolTipText("indic-keyboards - MALAYALAM Inscript");
            previousKeyboardIcon = item.getImage();
          }

        }
      });

      // Oriya layout listeners goes here
      oriInscript.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event event) {
          oriInscript.setSelection(false);
          {
            layoutImg = "oriya_inscript";
            currentLayout.setEnabled(true);
            tip.setMessage("Oriya Inscript");
            tip.setVisible(true);
            ParseXML.setlang("ori_inscript.xml");
            PhoneticParseXML.PhoneticFlag = 0;
            Image image1 = new Image(display,
                IndicKeyboards.workingDirectory
                    + "/resources/oriya.ico");
            item.setImage(image1);
            item.setToolTipText("indic-keyboards - ORIYA Inscript");
            previousKeyboardIcon = item.getImage();
          }

        }
      });

      // Listener for displaying the current layout image.
      currentLayout.addListener(SWT.Selection, new Listener() {
        public void handleEvent(Event event) {
          try {
            if (layoutImg.compareTo("kagapa") == 0) {
              showCurrentLayout("KaGaPa",
                  IndicKeyboards.workingDirectory
                      + "/resources/kagapa.png");
            }
            if (layoutImg.compareTo("kannada_inscript") == 0) {
              showCurrentLayout("Kannada Inscript",
                  IndicKeyboards.workingDirectory
                      + "/resources/kannada_inscript.png");
            }
            if (layoutImg.compareTo("tamil99") == 0) {
              showCurrentLayout("Tamil 99",
                  IndicKeyboards.workingDirectory
                      + "/resources/tamil99.png");
            }
            if (layoutImg.compareTo("tamil_inscript") == 0) {
              showCurrentLayout("Tamil Inscript",
                  IndicKeyboards.workingDirectory
                      + "/resources/tamil_inscript.png");
            }
            if (layoutImg.compareTo("tamil_bamini_inscript") == 0) {
              showCurrentLayout("Tamil Bamini",
                  IndicKeyboards.workingDirectory
                      + "/resources/tamil_bamini_inscript.png");
            }
            if (layoutImg.compareTo("tamil_remington") == 0) {
              showCurrentLayout("Tamil Remington",
                  IndicKeyboards.workingDirectory
                      + "/resources/tamil_remington.gif");
            }
            if (layoutImg.compareTo("hindi_inscript") == 0) {
              showCurrentLayout("Hindi Inscript",
                  IndicKeyboards.workingDirectory
                      + "/resources/hindi_inscript.png");
            }
            if (layoutImg.compareTo("hindi_remington") == 0) {
              showCurrentLayout("Hindi Remington",
                  IndicKeyboards.workingDirectory
                      + "/resources/hindi_remington.png");
            }
            if (layoutImg.compareTo("gujarati_inscript") == 0) {
              showCurrentLayout(
                  "Gujarati Inscript",
                  IndicKeyboards.workingDirectory
                      + "/resources/gujarati_inscript.png");
            }
            if (layoutImg.compareTo("telugu_inscript") == 0) {
              showCurrentLayout("Telugu Inscript",
                  IndicKeyboards.workingDirectory
                      + "/resources/telugu_inscript.png");
            }
            if (layoutImg.compareTo("bengali_inscript") == 0) {
              showCurrentLayout("Bengali Inscript",
                  IndicKeyboards.workingDirectory
                      + "/resources/bengali_inscript.png");
            }
            if (layoutImg.compareTo("gurmukhi_inscript") == 0) {
              showCurrentLayout(
                  "Gurmukhi Inscript",
                  IndicKeyboards.workingDirectory
                      + "/resources/gurmukhi_inscript.png");
            }
            if (layoutImg.compareTo("malayalam_inscript") == 0) {
              showCurrentLayout(
                  "Malayalam Inscript",
                  IndicKeyboards.workingDirectory
                      + "/resources/malayalam_inscript.png");
            }
            if (layoutImg.compareTo("oriya_inscript") == 0) {
              showCurrentLayout("Oriya Inscript",
                  IndicKeyboards.workingDirectory
                      + "/resources/oriya_inscript.png");
            }
            if (layoutImg.compareTo("na") == 0) {
              currentLayout.setEnabled(false);
            }
          } catch (NullPointerException e) {

          } catch (org.eclipse.swt.SWTException e) {

          }

        }
      });

      // Enable and disable listener - should be differnet for Linux and
      // windows
      if (System.getProperty("os.name").contains("Windows")) {
        enableDisable.addListener(SWT.Selection, new Listener() {
          public void handleEvent(Event event) {
            InitWin.enable = !InitWin.enable;
            if (InitWin.enable) {

              item.setImage(previousKeyboardIcon);
              tip.setMessage("Enabled");
              tip.setVisible(true);
              enableDisable.setText("Disable [Alt + F12]");
              System.gc();
            } else {
              previousKeyboardIcon = item.getImage();
              Image image1 = new Image(
                  display,
                  IndicKeyboards.workingDirectory
                      + "/resources/trayicon_disabled.ico");
              item.setImage(image1);
              tip.setMessage("Disabled");
              tip.setVisible(true);
              enableDisable.setText("Enable [Alt + F12]");
              System.gc();
            }
          }
        });
      } else {
        enableDisable.addListener(SWT.Selection, new Listener() {
          public void handleEvent(Event event) {
            if (KeyMonitorMethods.loggingEnabled == false) {
              KeyMonitorMethods enable = new KeyMonitorMethods();
              enable.printKeys(666);
              item.setImage(previousKeyboardIcon);
              tip.setMessage("Enabled");
              tip.setVisible(true);
              enableDisable.setText("Disable [Alt+F12]");
              System.gc();
            } else if (KeyMonitorMethods.loggingEnabled == true) {
              KeyMonitorMethods disable = new KeyMonitorMethods();
              disable.printKeys(666);
              previousKeyboardIcon = item.getImage();
              Image image1 = new Image(
                  display,
                  IndicKeyboards.workingDirectory
                      + "/resources/trayicon_disabled.ico");
              item.setImage(image1);
              tip.setMessage("Disabled");
              tip.setVisible(true);
              enableDisable.setText("Enable [Alt+F12]");
              System.gc();
            }
          }
        });
      }

      langtech.addListener(SWT.Selection, new Listener() {
        public void handleEvent(Event event) {

          Program pBrowse = Program.findProgram(".html");
          pBrowse.execute("http://languagetechnology.org");

        }
      });

      codegoogle.addListener(SWT.Selection, new Listener() {
        public void handleEvent(Event event) {

          Program pBrowse = Program.findProgram(".html");
          pBrowse.execute("http://code.google.com/p/indic-keyboards");

        }
      });

      IKdev.addListener(SWT.Selection, new Listener() {
        public void handleEvent(Event event) {

          Program pBrowse = Program.findProgram(".html");
          pBrowse.execute("http://groups.google.com/group/cki-dev/");

        }
      });

      IKscm.addListener(SWT.Selection, new Listener() {
        public void handleEvent(Event event) {

          Program pBrowse = Program.findProgram(".html");
          pBrowse
              .execute("http://groups.google.com/group/indic-keyboards-scm");

        }
      });

      IKuser.addListener(SWT.Selection, new Listener() {
        public void handleEvent(Event event) {

          Program pBrowse = Program.findProgram(".html");
          pBrowse.execute("http://groups.google.com/group/cki-users");

        }
      });

      about.addListener(SWT.Selection, new Listener() {
View Full Code Here

   
    private ImageData getFileImageData(File file) {
        if (file != null) {
            final String extension = DocUtils.getExtension(file);
            if (extension != null) {
                final Program program = Program.findProgram(extension);
                if (program != null) {
                    return program.getImageData();   
                }               
            }
        }
        return null;
    }
View Full Code Here

            try {
                String script = omsView.generateScriptForSelectedModule();
                if (script == null) {
                    return;
                }
                Program program = Program.findProgram(".txt");
                if (program != null) {
                    File tempFile = File.createTempFile("omsbox_", ".oms");
                    if (tempFile == null || !tempFile.exists() || tempFile.getAbsolutePath() == null) {
                        // try with user's home folder
                        String ts = new DateTime().toString(OmsBoxConstants.dateTimeFormatterYYYYMMDDHHMMSS);
                        String userHomePath = System.getProperty("user.home"); //$NON-NLS-1$

                        File userHomeFile = new File(userHomePath);
                        if (!userHomeFile.exists()) {
                            String message = "Unable to create the oms script both in the temp folder and user home. Check your permissions.";
                            ExceptionDetailsDialog.openError(null, message, IStatus.ERROR, OmsBoxPlugin.PLUGIN_ID,
                                    new RuntimeException());
                            return;
                        }
                        tempFile = new File(userHomeFile, "omsbox_" + ts + ".oms");
                    }
                    FileUtils.writeStringToFile(tempFile, script);

                    program.execute(tempFile.getAbsolutePath());

                    // cleanup when leaving uDig
                    // tempFile.deleteOnExit();
                } else {
                    // make it the good old way prompting
View Full Code Here

  private static void viewFileWithExtension(
      FileWithExtension fileWithExtension, String customFileExtension)
      throws FileViewingException {
    try {
      final Program program = selectChosenProgramForFileExtension(
        fileWithExtension.fileExtension, customFileExtension);

      executeProgramWithFile(program, fileWithExtension.file);
    } catch (NoProgramFoundException noProgramFoundException) {
      String exceptionMessage = String.format(
View Full Code Here

      chosenFileExtension = defaultFileExtension;
    } else {
      chosenFileExtension = customFileExtension;
    }
   
    Program chosenProgram =
      getProgramForFileExtension(chosenFileExtension);
   
    if (chosenProgram != null) {
      return chosenProgram;
    } else {
      /*
       * The chosen program doesn't exist, so try to get the
       *  default viewer.
       */
      Program defaultProgram =
        getProgramForFileExtension(defaultFileExtension);
     
      if (defaultProgram != null) {
        return defaultProgram;
      } else {
View Full Code Here

      if(Statics.isADir(e))
        return imgFolder;
      int lastDotPos = new File(e.getStringValue()).getName().lastIndexOf('.');
        if (lastDotPos == -1||lastDotPos==0)
          return imgFile;
        Program program = Program.findProgram(e.getStringValue().substring(lastDotPos + 1));
        if(program==null)
          return imgFile;
        return new Image(PlatformUI.getWorkbench().getDisplay(),program.getImageData());
       
    }
    return null;
  }
View Full Code Here

        setLayout(new FormLayout());

        fileViewerIconContainerLabel = new Label(this, SWT.NONE);
        fileViewerIconContainerLabel.setText("X");
        Image image = null;
        Program p = Program.findProgram(fileType);
        if(p != null) {
            ImageData data = p.getImageData();
            if(data != null) {
                image = new Image(getDisplay(), data);
                fileViewerIconContainerLabel.setImage(image);
            }
        }
View Full Code Here

        return;
      }
    }

    // Programmatically try to find something that can handle html files
    Program browserProgram = Program.findProgram("html");
    if (browserProgram != null) {
      if (browserProgram.execute(location)) {
        return;
      } else {
        logger.log(TreeLogger.ERROR, "Error launching external HTML program '"
            + browserProgram.getName() + "'", null);
        return;
      }
    }

    // We're out of options, so fail.
View Full Code Here

     * info from the descriptor.
     * @exception  Throws a CoreException if the external editor could not be opened.
     */
    public void open() throws CoreException {

        Program program = this.descriptor.getProgram();
        if (program == null) {
            openWithUserDefinedProgram();
        } else {
            String path = ""; //$NON-NLS-1$
            if (filePath != null) {
                path = filePath.toOSString();
                if (program.execute(path)) {
          return;
        }
            }
            throw new CoreException(
                    new Status(
View Full Code Here

TOP

Related Classes of org.eclipse.swt.program.Program

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.