示例#1
0
 /**
  * Select button from the group
  *
  * @param group
  * @param toSelect
  */
 private void setSelectedButton(ButtonGroup group, int toSelect) {
   int i = 0;
   Enumeration buttons = group.getElements();
   JRadioButton temp;
   while (buttons.hasMoreElements()) {
     temp = (JRadioButton) buttons.nextElement();
     String text = temp.getText();
     if ((text.equals(Lang.getString("TedConfigDialog.Never"))
             && toSelect == TedConfig.NEVER) // $NON-NLS-1$
         || (text.equals(Lang.getString("TedConfigDialog.Ask"))
             && toSelect == TedConfig.ASK) // $NON-NLS-1$
         || (text.equals(Lang.getString("TedConfigDialog.Always"))
             && toSelect == TedConfig.ALWAYS)) // $NON-NLS-1$
     {
       temp.setSelected(true);
     } else temp.setSelected(false);
     i++;
   }
 }
  public void run() {
    // loading...
    showInfoPane.setText(
        startHTML + Lang.getString("TedAddShowDialog.ShowInfo.LabelLoadingInfo") + endHTML);

    // when a show is selected
    if (currentShow != null && !done) {
      // and has a TV.com url
      String id = p.gettvID(currentShow.getName());
      if (!id.equals("")) {
        URL url;
        try {
          String location = p.getHostUrl();

          if (!location.equals("") && !done) {
            // open the showinfo url and display
            url = new URL(location + id);
            showInfoPane.setPage(url);
          } else {
            TedLog.error("shows.xml file is corrupt");
          }
        } catch (MalformedURLException e) {
          // url malformed, display error
          showInfoPane.setText(
              startHTML + Lang.getString("TedAddShowDialog.ShowInfo.ErrorMalformedURL") + endHTML);
        } catch (IOException e) {
          // url not found, display error
          showInfoPane.setText(
              startHTML + Lang.getString("TedAddShowDialog.ShowInfo.ErrorIO") + endHTML);
        } catch (Exception e) {
          // unkown error, display error and print stacktrace
          showInfoPane.setText(
              startHTML + Lang.getString("TedAddShowDialog.ShowInfo.ErrorUnknown") + endHTML);
          e.printStackTrace();
        }
      } else {
        // no info url available
        showInfoPane.setText(
            startHTML + Lang.getString("TedAddShowDialog.ShowInfo.LabelNoInfo") + endHTML);
      }
    }
  }
示例#3
0
  /**
   * Get selected state from buttongroup
   *
   * @param group
   * @return
   */
  private int getSelectedButton(ButtonGroup group) {
    int i = 0;
    Enumeration buttons = group.getElements();
    JRadioButton temp;
    while (buttons.hasMoreElements()) {
      temp = (JRadioButton) buttons.nextElement();
      if (temp.isSelected()) {
        // check which state is selected and return it
        String text = temp.getText();
        if (text.equals(Lang.getString("TedConfigDialog.Never"))) // $NON-NLS-1$
        return TedConfig.NEVER;
        else if (text.equals(Lang.getString("TedConfigDialog.Ask"))) // $NON-NLS-1$
        return TedConfig.ASK;
        else if (text.equals((Lang.getString("TedConfigDialog.Always")))) // $NON-NLS-1$
        return TedConfig.ALWAYS;
      } else i++;
    }

    // default return value
    return 1;
  }
示例#4
0
  private void initGUI() {
    try {

      // this.setPreferredSize(new Dimension(width, height));
      updatePanel = new JPanel();
      this.add(updatePanel);
      FormLayout updatePanelLayout =
          new FormLayout(
              "max(p;6dlu), center:60dlu, center:60dlu:grow, center:60dlu, max(p;16dlu)",
              "max(p;5dlu), max(p;5dlu), max(p;5dlu), max(p;10dlu), max(p;15dlu), max(p;15dlu), max(p;15dlu), max(p;15dlu), max(p;15dlu), max(p;15dlu), max(p;15dlu)");
      updatePanel.setPreferredSize(new java.awt.Dimension(500, 500));
      updatePanel.setLayout(updatePanelLayout);

      checkCheckUpdates = new JCheckBox();
      updatePanel.add(checkCheckUpdates, new CellConstraints("2, 2, 3, 1, default, default"));
      checkCheckUpdates.setText(Lang.getString("TedConfigDialog.CheckNewVersions"));
      checkCheckUpdates.setBounds(14, 185, 371, 21);

      labelUpdateShows = new JLabel();
      updatePanel.add(labelUpdateShows, new CellConstraints("2, 5, 3, 1, default, default"));
      labelUpdateShows.setText(Lang.getString("TedConfigDialog.LabelNewShowDefinitions"));
      labelUpdateShows.setBounds(14, 287, 371, 28);

      radioUpdateShowsNever = new JRadioButton();
      updatePanel.add(radioUpdateShowsNever, new CellConstraints("2, 6, 1, 1, default, default"));
      radioUpdateShowsNever.setText(Lang.getString("TedConfigDialog.Never"));
      radioUpdateShowsNever.setBounds(28, 306, 98, 28);

      radioUpdateShowsAsk = new JRadioButton();
      updatePanel.add(radioUpdateShowsAsk, new CellConstraints("3, 6, 1, 1, default, default"));
      radioUpdateShowsAsk.setText(Lang.getString("TedConfigDialog.Ask"));
      radioUpdateShowsAsk.setBounds(140, 306, 84, 28);

      radioUpdateShowsAlways = new JRadioButton();
      updatePanel.add(radioUpdateShowsAlways, new CellConstraints("4, 6, 1, 1, default, default"));
      radioUpdateShowsAlways.setText(Lang.getString("TedConfigDialog.Always"));
      radioUpdateShowsAlways.setBounds(231, 306, 105, 28);

      updateShowsGroup = new ButtonGroup();
      updateShowsGroup.add(radioUpdateShowsNever);
      updateShowsGroup.add(radioUpdateShowsAsk);
      updateShowsGroup.add(radioUpdateShowsAlways);

      radioSyncShowsNever = new JRadioButton();
      updatePanel.add(radioSyncShowsNever, new CellConstraints("2, 10, 1, 1, default, default"));
      radioSyncShowsNever.setText(Lang.getString("TedConfigDialog.Never"));
      radioSyncShowsNever.setBounds(28, 347, 98, 28);

      radioSyncShowsAsk = new JRadioButton();
      updatePanel.add(radioSyncShowsAsk, new CellConstraints("3, 10, 1, 1, default, default"));
      radioSyncShowsAsk.setText(Lang.getString("TedConfigDialog.Ask"));
      radioSyncShowsAsk.setBounds(140, 347, 84, 28);

      radioSyncShowsAlways = new JRadioButton();
      updatePanel.add(radioSyncShowsAlways, new CellConstraints("4, 10, 1, 1, default, default"));
      radioSyncShowsAlways.setText(Lang.getString("TedConfigDialog.Always"));
      radioSyncShowsAlways.setBounds(231, 347, 105, 28);

      syncShowsGroup = new ButtonGroup();
      syncShowsGroup.add(radioSyncShowsNever);
      syncShowsGroup.add(radioSyncShowsAsk);
      syncShowsGroup.add(radioSyncShowsAlways);

      buttonCheckVersionTed = new JButton();
      updatePanel.add(buttonCheckVersionTed, new CellConstraints("2, 3, 3, 1, default, default"));
      buttonCheckVersionTed.setText(Lang.getString("TedConfigDialog.ButtonCheckUpdates"));
      buttonCheckVersionTed.setActionCommand("checktedupdates");
      buttonCheckVersionTed.addActionListener(this);

      buttonUpdateShows = new JButton();
      updatePanel.add(buttonUpdateShows, new CellConstraints("2, 7, 3, 1, default, default"));
      buttonUpdateShows.setText(Lang.getString("TedConfigDialog.ButtonCheckShowUpdates"));
      buttonUpdateShows.setActionCommand("checkshowupdates");
      buttonUpdateShows.addActionListener(this);

      labelSyncShows = new JLabel();
      updatePanel.add(labelSyncShows, new CellConstraints("2, 9, 3, 1, default, default"));
      labelSyncShows.setText(Lang.getString("TedConfigDialog.LabelUpdateShowDefinitions"));

      jSeparator1 = new JSeparator();
      updatePanel.add(jSeparator1, new CellConstraints("2, 4, 3, 1, default, default"));

    } catch (Exception e) {
      e.printStackTrace();
    }
  }