コード例 #1
0
public class ShowAllFilter implements devplugin.ProgramFilter {

  private static final util.ui.Localizer mLocalizer =
      util.ui.Localizer.getLocalizerFor(ShowAllFilter.class);

  public boolean accept(devplugin.Program prog) {
    return true;
  }

  public String getName() {
    return toString();
  }

  public String toString() {
    return mLocalizer.msg("ShowAll", "Show all");
  }

  public boolean equals(Object o) {
    if (o instanceof ProgramFilter) {
      return getClass().equals(o.getClass()) && getName().equals(((ProgramFilter) o).getName());
    }

    return false;
  }
}
コード例 #2
0
  /**
   * Shows the PopUp
   *
   * @param e MouseEvent
   */
  protected void showPopUpMenu(MouseEvent e) {
    if (!(e.getSource() instanceof JList)) {
      return;
    }

    JList list = (JList) e.getSource();

    int i = list.locationToIndex(e.getPoint());
    list.setSelectedIndex(i);

    JPopupMenu menu = new JPopupMenu();

    Rating selRating = (Rating) list.getSelectedValue();

    JMenuItem item = new JMenuItem(mLocalizer.msg("showDetails", "Show Details"));
    item.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            view();
          }
        });
    item.setFont(item.getFont().deriveFont(Font.BOLD));

    menu.add(item);
    menu.add(new ListAction(this, selRating.getTitle()));
    menu.add(new ShowDetailsAction(selRating.getRatingId()));

    menu.show(list, e.getX(), e.getY());
  }
コード例 #3
0
  /**
   * Creates the Overview Dialog
   *
   * @param parent Parent-Frame
   * @param tvraterPlugin Database to use
   */
  public DialogOverview(Frame parent, TVRaterPlugin tvraterPlugin) {
    super(parent, true);
    setTitle(mLocalizer.msg("title", "Rating-Overview"));

    mPlugin = tvraterPlugin;

    createGUI();
  }
コード例 #4
0
 @Override
 protected void addField(final ProgramFieldType fieldType, String value) {
   if (fieldType.equals(ProgramFieldType.DESCRIPTION_TYPE)) {
     if (((DataHydraChannelGroup) mChannel.getGroup()).isShowRegister()
         && mDataService.getShowRegisterText()) {
       value +=
           "\n\n" + mLocalizer.msg("register", "Please Register at {0}", mChannel.getWebpage());
     }
   }
   mProgram.setTextField(fieldType, value);
   if (fieldType.equals(ProgramFieldType.TITLE_TYPE)) {
     mProgram.setTitle(value);
   }
 }
コード例 #5
0
  /**
   * Creates the Dialog
   *
   * @param frame Frame for modal
   * @param plugin Plugin for reference
   * @param settings The settings of the ListViewPlugin
   */
  public ListViewDialog(Frame frame, Plugin plugin, Properties settings) {
    super(frame, true);
    setTitle(mLocalizer.msg("viewList", "View List:"));
    mPlugin = plugin;
    mSettings = settings;
    mTimes = Plugin.getPluginManager().getTvBrowserSettings().getTimeButtonTimes();
    mModel = new ListTableModel();
    mPerformingSingleClick = false;

    mCurrentFilter = Plugin.getPluginManager().getFilterManager().getCurrentFilter();

    generateList(new Date(), getCurrentTime());
    createGUI();
    addChangeTimer();
    UiUtilities.registerForClosing(this);
  }
コード例 #6
0
 public String toString() {
   return mLocalizer.msg("ShowAll", "Show all");
 }
コード例 #7
0
/**
 * Creates a Dialog with a List of Programs
 *
 * @author bodo
 */
public class ListViewDialog extends JDialog implements WindowClosingIf {

  /** The localizer used by this class. */
  private static final util.ui.Localizer mLocalizer =
      util.ui.Localizer.getLocalizerFor(ListViewDialog.class);

  /** The Table */
  private ListTable mProgramTable;

  /** The Table-Model */
  private ListTableModel mModel;

  /** Runs at ... */
  private JRadioButton mRuns = new JRadioButton(mLocalizer.msg("runs", "Running"));

  /** Runs on ... */
  private JRadioButton mOn = new JRadioButton(mLocalizer.msg("on", "On"));

  /** Date-Select for mOn */
  private JComboBox mDate;

  /** Time-Spinner for mOn */
  private JSpinner mTimeSpinner = new JSpinner(new SpinnerDateModel());

  /** Text for mRuns */
  private static final String[] TIMETEXT = {
    mLocalizer.msg("now", "Now"),
    mLocalizer.msg("15min", "in 15 minutes"),
    mLocalizer.msg("30min", "in 30 minutes")
  };

  /** Select for mRuns */
  private JComboBox mBox;

  /** channel filter selection */
  private JComboBox mChannels;

  /** Times */
  private int[] mTimes;

  /** Plugin that created the Dialog */
  private Plugin mPlugin;

  /** Timer for Updates */
  private Timer mTimer;

  /** Settings for this Plugin */
  private Properties mSettings;

  private Thread mLeftClickThread;
  private boolean mPerformingSingleClick;

  private Thread mMiddleSingleClickThread;
  private boolean mPerformingMiddleSingleClick;

  private JComboBox mFilterBox;
  private ProgramFilter mCurrentFilter;

  /**
   * Creates the Dialog
   *
   * @param frame Frame for modal
   * @param plugin Plugin for reference
   * @param settings The settings of the ListViewPlugin
   */
  public ListViewDialog(Frame frame, Plugin plugin, Properties settings) {
    super(frame, true);
    setTitle(mLocalizer.msg("viewList", "View List:"));
    mPlugin = plugin;
    mSettings = settings;
    mTimes = Plugin.getPluginManager().getTvBrowserSettings().getTimeButtonTimes();
    mModel = new ListTableModel();
    mPerformingSingleClick = false;

    mCurrentFilter = Plugin.getPluginManager().getFilterManager().getCurrentFilter();

    generateList(new Date(), getCurrentTime());
    createGUI();
    addChangeTimer();
    UiUtilities.registerForClosing(this);
  }

  /** Create Change-Thread that updates the Dialog every 10 seconds */
  private void addChangeTimer() {
    int delay = 2000; // delay for 2 sec.
    int period = 2000; // repeat every 2 secs.
    mTimer = new Timer();

    mTimer.scheduleAtFixedRate(
        new TimerTask() {
          @Override
          public void run() {
            if (mRuns.isSelected()) {
              refreshView();
            }
          }
        },
        delay,
        period);
  }

  /**
   * Returns the current Time in minutes
   *
   * @return Time in minutes
   */
  private int getCurrentTime() {
    Calendar cal = Calendar.getInstance();
    return cal.get(Calendar.HOUR_OF_DAY) * 60 + cal.get(Calendar.MINUTE);
  }

  /** Generates the List of Programs */
  private void generateList(Date date, int time) {
    // If Time > 24 try next Day
    if (time > 60 * 24) {
      date = date.addDays(1);
      time -= 60 * 24;
    }

    Channel[] channels = Plugin.getPluginManager().getSubscribedChannels();
    if ((mChannels != null) && (mChannels.getSelectedIndex() > 0)) {
      FilterComponent component =
          FilterComponentList.getInstance()
              .getFilterComponentByName(mChannels.getSelectedItem().toString());
      if (component instanceof ChannelFilterComponent) {
        channels = ((ChannelFilterComponent) component).getChannels();
      }
    }

    for (Channel channel : channels) {

      Program prg = findProgram(date, time, channel, false);
      Program nprg = null;

      if (prg == null) {
        prg = findProgram(date.addDays(-1), time + 60 * 24, channel, false);
      }

      if (prg != null) {
        nprg = findNextProgram(prg);
      } else {
        Iterator<Program> it = Plugin.getPluginManager().getChannelDayProgram(date, channel);

        if (it.hasNext()) {
          Program p = it.next();

          if (p.getStartTime() > time && mCurrentFilter.accept(p)) {
            nprg = p;
          } else {
            nprg = findProgram(date, time + 60, channel, true);
          }
        } else {
          nprg = findProgram(date, time + 60, channel, true);
        }

        if (nprg == null) {
          it = Plugin.getPluginManager().getChannelDayProgram(date.addDays(1), channel);

          while (it.hasNext() && nprg == null) {
            Program p = it.next();

            if (!p.isExpired() && mCurrentFilter.accept(p)) {
              nprg = p;
            }
          }
        }
      }

      mModel.updateRow(channel, prg, nprg);
    }
  }

  /**
   * Finds the program after the given Program
   *
   * @param prg Search Program after this
   * @return following Program
   */
  private Program findNextProgram(Program prg) {
    Iterator<Program> it =
        Plugin.getPluginManager().getChannelDayProgram(prg.getDate(), prg.getChannel());

    Program nprg = null;
    boolean last = false;

    while (it.hasNext()) {
      Program p = it.next();

      if (prg.equals(p) && it.hasNext()) {
        while (it.hasNext()) {
          Program test = it.next();

          if (!test.isExpired() && mCurrentFilter.accept(test)) {
            return test;
          }
        }

        last = true;
      } else if (prg.equals(p) && !it.hasNext()) {
        last = true;
      }
    }

    if (last) {
      it =
          Plugin.getPluginManager()
              .getChannelDayProgram(prg.getDate().addDays(1), prg.getChannel());

      while (it.hasNext()) {
        Program p = it.next();

        if (!p.isExpired() && mCurrentFilter.accept(p)) {
          return p;
        }
      }
    }

    return nprg;
  }

  /**
   * Finds a Program for a Date/time on a certain Channel
   *
   * @param date Date
   * @param time Time
   * @param channel Channel
   * @return added a Program
   */
  private Program findProgram(Date date, int time, Channel channel, boolean next) {
    for (Iterator<Program> it = Plugin.getPluginManager().getChannelDayProgram(date, channel);
        it.hasNext(); ) {
      Program program = it.next();

      int start = program.getStartTime();
      int ende = program.getStartTime() + program.getLength();

      if (((!next && (start <= time) && (ende > time))
              || (next && start > IOUtilities.getMinutesAfterMidnight()))
          && mCurrentFilter.accept(program)) {
        return program;
      }
    }
    return null;
  }

  /**
   * Calculates the Time based on the current selection
   *
   * @param selectedIndex # of selection
   * @return calculated Time
   */
  private int calcTimeForSelection(int selectedIndex) {
    int time = getCurrentTime();

    if (selectedIndex == 1) {
      return time + 15;
    } else if (selectedIndex == 2) {
      return time + 30;
    } else if (selectedIndex > 2) {
      return mTimes[selectedIndex - 3];
    }

    return time;
  }

  /** Creates the GUI */
  private void createGUI() {
    JPanel content = (JPanel) this.getContentPane();
    content.setLayout(new BorderLayout());
    content.setBorder(UiUtilities.DIALOG_BORDER);

    Vector<String> data = new Vector<String>();

    data.add(TIMETEXT[0]);
    data.add(TIMETEXT[1]);
    data.add(TIMETEXT[2]);

    TimeFormatter formatter = new TimeFormatter();

    for (int time : mTimes) {
      int h = time / 60;
      int m = time % 60;
      StringBuilder builder = new StringBuilder();
      builder.append(mLocalizer.msg("at", "at"));
      builder.append(' ');
      builder.append(formatter.formatTime(h, m));
      data.add(builder.toString());
    }

    data.add(mLocalizer.msg("configureTimes", "Configure Times"));

    mBox = new JComboBox(data);

    mBox.addActionListener(
        new ActionListener() {

          private int lastSelected = 0;

          public void actionPerformed(ActionEvent e) {
            if (mBox.getSelectedIndex() == mBox.getItemCount() - 1) {
              mBox.setSelectedIndex(lastSelected);
              Plugin.getPluginManager().showSettings(SettingsItem.TIMEBUTTONS);
            } else {
              lastSelected = mDate.getSelectedIndex();
              int time = calcTimeForSelection(mBox.getSelectedIndex());
              generateList(new Date(), time);
            }
          }
        });

    ButtonGroup group = new ButtonGroup();
    group.add(mRuns);
    group.add(mOn);

    JPanel datetimeselect = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));

    Vector<Date> dates = new Vector<Date>();

    Date currentDate = Date.getCurrentDate();
    for (int i = 0; i < 14; i++) {
      dates.add(currentDate.addDays(i));
    }

    mDate = new JComboBox(dates);

    datetimeselect.add(mDate);

    datetimeselect.add(new JLabel(" " + mLocalizer.msg("at", "at") + " "));

    JSpinner.DateEditor dateEditor =
        new JSpinner.DateEditor(mTimeSpinner, Settings.getTimePattern());

    mTimeSpinner.setEditor(dateEditor);

    CaretPositionCorrector.createCorrector(dateEditor.getTextField(), new char[] {':'}, -1);

    datetimeselect.add(mTimeSpinner);

    Vector<String> filters = new Vector<String>();
    filters.add(mLocalizer.msg("filterAll", "all channels"));
    for (String filterName : FilterComponentList.getInstance().getChannelFilterNames()) {
      filters.add(filterName);
    }
    filters.add(mLocalizer.ellipsisMsg("filterDefine", "define filter"));
    mChannels = new JComboBox(filters);
    datetimeselect.add(new JLabel("    "));
    datetimeselect.add(mChannels);

    // Event-Handler

    mRuns.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            refreshView();
          }
        });

    mOn.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            refreshView();
          }
        });

    mDate.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            refreshView();
          }
        });

    mTimeSpinner.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent arg0) {
            refreshView();
          }
        });

    mChannels.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // user defined selection
            if (mChannels.getSelectedIndex() == mChannels.getItemCount() - 1) {
              EditFilterComponentDlg dlg =
                  new EditFilterComponentDlg(null, null, ChannelFilterComponent.class);
              FilterComponent rule = dlg.getFilterComponent();
              if (rule == null) {
                return;
              }
              if (!(rule instanceof ChannelFilterComponent)) {
                return;
              }
              FilterComponentList.getInstance().add(rule);
              FilterComponentList.getInstance().store();
              String filterName = rule.getName();
              mChannels.removeAllItems();
              mChannels.addItem(mLocalizer.msg("filterAll", "all channels"));
              for (String channel : FilterComponentList.getInstance().getChannelFilterNames()) {
                mChannels.addItem(channel);
              }
              mChannels.addItem(mLocalizer.ellipsisMsg("filterDefine", "define filter"));
              mChannels.setSelectedItem(filterName);
            }
            mModel.removeAllRows();
            refreshView();
          }
        });

    mRuns.setSelected(true);
    mDate.setEnabled(false);
    mTimeSpinner.setEnabled(false);

    JLabel filterLabel = new JLabel("Filter:");
    filterLabel.setHorizontalAlignment(SwingConstants.RIGHT);

    mFilterBox = new JComboBox(Plugin.getPluginManager().getFilterManager().getAvailableFilters());
    mFilterBox.setSelectedItem(Plugin.getPluginManager().getFilterManager().getCurrentFilter());
    mFilterBox.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
              mCurrentFilter = (ProgramFilter) e.getItem();
              refreshView();
            }
          }
        });

    // Upper Panel

    JPanel topPanel =
        new JPanel(
            new FormLayout(
                "pref, 3dlu, pref, 15dlu, pref, 3dlu, pref, 3dlu, pref", "pref, 1dlu, pref, 3dlu"));

    CellConstraints cc = new CellConstraints();

    topPanel.add(mRuns, cc.xy(1, 1));
    topPanel.add(mBox, cc.xy(3, 1));
    topPanel.add(mOn, cc.xy(5, 1));
    topPanel.add(datetimeselect, cc.xy(7, 1));

    topPanel.add(filterLabel, cc.xy(1, 3));
    topPanel.add(mFilterBox, cc.xyw(3, 3, 5));

    content.add(topPanel, BorderLayout.NORTH);

    // Rest of the GUI
    mProgramTable = new ListTable(mModel);
    mProgramTable.getTableHeader().setReorderingAllowed(false);
    mProgramTable.getTableHeader().setResizingAllowed(false);
    mProgramTable.setToolTipText("");

    mProgramTable.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mousePressed(MouseEvent evt) {
            if (evt.isPopupTrigger()) {
              showPopup(evt);
            }
          }

          @Override
          public void mouseReleased(MouseEvent evt) {
            if (evt.isPopupTrigger()) {
              showPopup(evt);
            }
          }

          @Override
          public void mouseClicked(MouseEvent e) {
            mouseClickedOnTable(e);
          }
        });

    // Dispatch the KeyEvent to the RootPane for Closing the Dialog.
    // Needed for Java 1.4.
    mProgramTable.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyPressed(KeyEvent e) {
            mProgramTable.getRootPane().dispatchEvent(e);
          }
        });

    setTableColumProperties();

    JScrollPane scroll =
        new JScrollPane(
            mProgramTable,
            ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);

    content.add(scroll, BorderLayout.CENTER);

    JPanel buttonPn = new JPanel(new BorderLayout());
    buttonPn.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0));
    content.add(buttonPn, BorderLayout.SOUTH);

    JButton closeButton = new JButton(Localizer.getLocalization(Localizer.I18N_CLOSE));
    closeButton.addActionListener(
        new ActionListener() {

          public void actionPerformed(ActionEvent evt) {
            dispose();
          }
        });

    JPanel p = new JPanel(new FormLayout("pref,5dlu,pref,5dlu,pref", "pref"));
    JButton settings = new JButton(TVBrowserIcons.preferences(TVBrowserIcons.SIZE_SMALL));
    settings.setToolTipText(mLocalizer.msg("settings", "Open settings"));

    settings.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            close();
            Plugin.getPluginManager().showSettings(ListViewPlugin.getInstance());
          }
        });

    final JCheckBox showAtStartup = new JCheckBox(mLocalizer.msg("showAtStart", "Show at start"));
    showAtStartup.setSelected(mSettings.getProperty("showAtStartup", "false").equals("true"));

    showAtStartup.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            if (showAtStartup.isSelected()) {
              mSettings.setProperty("showAtStartup", "true");
            } else {
              mSettings.setProperty("showAtStartup", "false");
            }
          }
        });

    p.add(settings, cc.xy(1, 1));
    p.add(showAtStartup, cc.xy(3, 1));

    buttonPn.add(p, BorderLayout.WEST);

    buttonPn.add(closeButton, BorderLayout.EAST);
    getRootPane().setDefaultButton(closeButton);
  }

  /** Sets the Table-Properties */
  private void setTableColumProperties() {
    ListTableCellRenderer renderer = new ListTableCellRenderer(mModel.getRowCount());
    int width = ListViewPlugin.PROGRAMTABLEWIDTH;
    for (int i = 0; i <= 2; i++) {
      TableColumn column = mProgramTable.getColumnModel().getColumn(i);
      column.setCellRenderer(renderer);
      if (i > 0) {
        column.setMinWidth(width);
      }
    }
  }

  /** Refresh the List with current settings */
  private void refreshView() {
    mBox.setEnabled(mRuns.isSelected());
    mDate.setEnabled(mOn.isSelected());
    mTimeSpinner.setEnabled(mOn.isSelected());

    if (mRuns.isSelected()) {
      int time = calcTimeForSelection(mBox.getSelectedIndex());
      generateList(new Date(), time);
    } else {
      java.util.Date startTime = (java.util.Date) mTimeSpinner.getValue();
      Calendar cal = Calendar.getInstance();
      cal.setTime(startTime);
      int minutes = cal.get(Calendar.HOUR_OF_DAY) * 60 + cal.get(Calendar.MINUTE);
      generateList((Date) mDate.getSelectedItem(), minutes);
    }
  }

  /**
   * Called when a Mouse-Event occurs
   *
   * @param e Event
   */
  private void mouseClickedOnTable(final MouseEvent e) {
    final Program prg = getProgramByClick(e);

    if (prg == null) {
      return;
    }
    if (SwingUtilities.isLeftMouseButton(e)
        && (e.getClickCount() == 1)
        && e.getModifiersEx() == 0) {
      mLeftClickThread =
          new Thread("Single left click") {
            @Override
            public void run() {
              try {
                mPerformingSingleClick = false;
                sleep(Plugin.SINGLE_CLICK_WAITING_TIME);
                mPerformingSingleClick = true;

                Plugin.getPluginManager().handleProgramSingleClick(prg, mPlugin);
                mPerformingSingleClick = false;
              } catch (InterruptedException e) { // ignore
              }
            }
          };

      mLeftClickThread.setPriority(Thread.MIN_PRIORITY);
      mLeftClickThread.start();
    } else if (SwingUtilities.isLeftMouseButton(e)
        && (e.getClickCount() == 2)
        && e.getModifiersEx() == 0) {
      if (!mPerformingSingleClick && mLeftClickThread != null && mLeftClickThread.isAlive()) {
        mLeftClickThread.interrupt();
      }

      if (!mPerformingSingleClick) {
        devplugin.Plugin.getPluginManager().handleProgramDoubleClick(prg, mPlugin);
      }
    } else if (SwingUtilities.isMiddleMouseButton(e) && (e.getClickCount() == 1)) {
      mMiddleSingleClickThread =
          new Thread("Single click") {
            @Override
            public void run() {
              try {
                mPerformingMiddleSingleClick = false;
                sleep(Plugin.SINGLE_CLICK_WAITING_TIME);
                mPerformingMiddleSingleClick = true;

                Plugin.getPluginManager().handleProgramMiddleClick(prg, mPlugin);
                mPerformingMiddleSingleClick = false;
              } catch (InterruptedException e) { // ignore
              }
            }
          };

      mMiddleSingleClickThread.setPriority(Thread.MIN_PRIORITY);
      mMiddleSingleClickThread.start();
    } else if (SwingUtilities.isMiddleMouseButton(e) && (e.getClickCount() == 2)) {
      if (!mPerformingMiddleSingleClick
          && mMiddleSingleClickThread != null
          && mMiddleSingleClickThread.isAlive()) {
        mMiddleSingleClickThread.interrupt();
      }

      if (!mPerformingMiddleSingleClick) {
        devplugin.Plugin.getPluginManager().handleProgramMiddleDoubleClick(prg, mPlugin);
      }
    }
  }

  /**
   * Gets the Program the User has clicked on
   *
   * @param e MouseEvent to determine the Program
   * @return Program the User has clicked on
   */
  private Program getProgramByClick(MouseEvent e) {
    int col = mProgramTable.getColumnModel().getColumnIndexAtX(e.getX());
    int row = mProgramTable.rowAtPoint(e.getPoint());
    mProgramTable.setRowSelectionInterval(row, row);

    Program prg = null;

    if (col == 1) {
      prg = mModel.getProgram(row);
    } else if (col == 2) {
      prg = mModel.getNextProgram(row);
    }

    return prg;
  }

  /**
   * Shows the Popup
   *
   * @param e Mouse-Event
   */
  private void showPopup(MouseEvent e) {
    Program prg = getProgramByClick(e);

    if (prg == null) {
      return;
    }

    JPopupMenu menu = devplugin.Plugin.getPluginManager().createPluginContextMenu(prg, mPlugin);
    menu.show(mProgramTable, e.getX() - 15, e.getY() - 15);
  }

  @Override
  public void setVisible(boolean b) {
    super.setVisible(b);
    mTimer.cancel();
  }

  public void close() {
    dispose();
  }
}
コード例 #8
0
  /** Creates the GUI */
  private void createGUI() {
    JPanel content = (JPanel) this.getContentPane();
    content.setLayout(new BorderLayout());
    content.setBorder(UiUtilities.DIALOG_BORDER);

    Vector<String> data = new Vector<String>();

    data.add(TIMETEXT[0]);
    data.add(TIMETEXT[1]);
    data.add(TIMETEXT[2]);

    TimeFormatter formatter = new TimeFormatter();

    for (int time : mTimes) {
      int h = time / 60;
      int m = time % 60;
      StringBuilder builder = new StringBuilder();
      builder.append(mLocalizer.msg("at", "at"));
      builder.append(' ');
      builder.append(formatter.formatTime(h, m));
      data.add(builder.toString());
    }

    data.add(mLocalizer.msg("configureTimes", "Configure Times"));

    mBox = new JComboBox(data);

    mBox.addActionListener(
        new ActionListener() {

          private int lastSelected = 0;

          public void actionPerformed(ActionEvent e) {
            if (mBox.getSelectedIndex() == mBox.getItemCount() - 1) {
              mBox.setSelectedIndex(lastSelected);
              Plugin.getPluginManager().showSettings(SettingsItem.TIMEBUTTONS);
            } else {
              lastSelected = mDate.getSelectedIndex();
              int time = calcTimeForSelection(mBox.getSelectedIndex());
              generateList(new Date(), time);
            }
          }
        });

    ButtonGroup group = new ButtonGroup();
    group.add(mRuns);
    group.add(mOn);

    JPanel datetimeselect = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));

    Vector<Date> dates = new Vector<Date>();

    Date currentDate = Date.getCurrentDate();
    for (int i = 0; i < 14; i++) {
      dates.add(currentDate.addDays(i));
    }

    mDate = new JComboBox(dates);

    datetimeselect.add(mDate);

    datetimeselect.add(new JLabel(" " + mLocalizer.msg("at", "at") + " "));

    JSpinner.DateEditor dateEditor =
        new JSpinner.DateEditor(mTimeSpinner, Settings.getTimePattern());

    mTimeSpinner.setEditor(dateEditor);

    CaretPositionCorrector.createCorrector(dateEditor.getTextField(), new char[] {':'}, -1);

    datetimeselect.add(mTimeSpinner);

    Vector<String> filters = new Vector<String>();
    filters.add(mLocalizer.msg("filterAll", "all channels"));
    for (String filterName : FilterComponentList.getInstance().getChannelFilterNames()) {
      filters.add(filterName);
    }
    filters.add(mLocalizer.ellipsisMsg("filterDefine", "define filter"));
    mChannels = new JComboBox(filters);
    datetimeselect.add(new JLabel("    "));
    datetimeselect.add(mChannels);

    // Event-Handler

    mRuns.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            refreshView();
          }
        });

    mOn.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            refreshView();
          }
        });

    mDate.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            refreshView();
          }
        });

    mTimeSpinner.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent arg0) {
            refreshView();
          }
        });

    mChannels.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // user defined selection
            if (mChannels.getSelectedIndex() == mChannels.getItemCount() - 1) {
              EditFilterComponentDlg dlg =
                  new EditFilterComponentDlg(null, null, ChannelFilterComponent.class);
              FilterComponent rule = dlg.getFilterComponent();
              if (rule == null) {
                return;
              }
              if (!(rule instanceof ChannelFilterComponent)) {
                return;
              }
              FilterComponentList.getInstance().add(rule);
              FilterComponentList.getInstance().store();
              String filterName = rule.getName();
              mChannels.removeAllItems();
              mChannels.addItem(mLocalizer.msg("filterAll", "all channels"));
              for (String channel : FilterComponentList.getInstance().getChannelFilterNames()) {
                mChannels.addItem(channel);
              }
              mChannels.addItem(mLocalizer.ellipsisMsg("filterDefine", "define filter"));
              mChannels.setSelectedItem(filterName);
            }
            mModel.removeAllRows();
            refreshView();
          }
        });

    mRuns.setSelected(true);
    mDate.setEnabled(false);
    mTimeSpinner.setEnabled(false);

    JLabel filterLabel = new JLabel("Filter:");
    filterLabel.setHorizontalAlignment(SwingConstants.RIGHT);

    mFilterBox = new JComboBox(Plugin.getPluginManager().getFilterManager().getAvailableFilters());
    mFilterBox.setSelectedItem(Plugin.getPluginManager().getFilterManager().getCurrentFilter());
    mFilterBox.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
              mCurrentFilter = (ProgramFilter) e.getItem();
              refreshView();
            }
          }
        });

    // Upper Panel

    JPanel topPanel =
        new JPanel(
            new FormLayout(
                "pref, 3dlu, pref, 15dlu, pref, 3dlu, pref, 3dlu, pref", "pref, 1dlu, pref, 3dlu"));

    CellConstraints cc = new CellConstraints();

    topPanel.add(mRuns, cc.xy(1, 1));
    topPanel.add(mBox, cc.xy(3, 1));
    topPanel.add(mOn, cc.xy(5, 1));
    topPanel.add(datetimeselect, cc.xy(7, 1));

    topPanel.add(filterLabel, cc.xy(1, 3));
    topPanel.add(mFilterBox, cc.xyw(3, 3, 5));

    content.add(topPanel, BorderLayout.NORTH);

    // Rest of the GUI
    mProgramTable = new ListTable(mModel);
    mProgramTable.getTableHeader().setReorderingAllowed(false);
    mProgramTable.getTableHeader().setResizingAllowed(false);
    mProgramTable.setToolTipText("");

    mProgramTable.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mousePressed(MouseEvent evt) {
            if (evt.isPopupTrigger()) {
              showPopup(evt);
            }
          }

          @Override
          public void mouseReleased(MouseEvent evt) {
            if (evt.isPopupTrigger()) {
              showPopup(evt);
            }
          }

          @Override
          public void mouseClicked(MouseEvent e) {
            mouseClickedOnTable(e);
          }
        });

    // Dispatch the KeyEvent to the RootPane for Closing the Dialog.
    // Needed for Java 1.4.
    mProgramTable.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyPressed(KeyEvent e) {
            mProgramTable.getRootPane().dispatchEvent(e);
          }
        });

    setTableColumProperties();

    JScrollPane scroll =
        new JScrollPane(
            mProgramTable,
            ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);

    content.add(scroll, BorderLayout.CENTER);

    JPanel buttonPn = new JPanel(new BorderLayout());
    buttonPn.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0));
    content.add(buttonPn, BorderLayout.SOUTH);

    JButton closeButton = new JButton(Localizer.getLocalization(Localizer.I18N_CLOSE));
    closeButton.addActionListener(
        new ActionListener() {

          public void actionPerformed(ActionEvent evt) {
            dispose();
          }
        });

    JPanel p = new JPanel(new FormLayout("pref,5dlu,pref,5dlu,pref", "pref"));
    JButton settings = new JButton(TVBrowserIcons.preferences(TVBrowserIcons.SIZE_SMALL));
    settings.setToolTipText(mLocalizer.msg("settings", "Open settings"));

    settings.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            close();
            Plugin.getPluginManager().showSettings(ListViewPlugin.getInstance());
          }
        });

    final JCheckBox showAtStartup = new JCheckBox(mLocalizer.msg("showAtStart", "Show at start"));
    showAtStartup.setSelected(mSettings.getProperty("showAtStartup", "false").equals("true"));

    showAtStartup.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            if (showAtStartup.isSelected()) {
              mSettings.setProperty("showAtStartup", "true");
            } else {
              mSettings.setProperty("showAtStartup", "false");
            }
          }
        });

    p.add(settings, cc.xy(1, 1));
    p.add(showAtStartup, cc.xy(3, 1));

    buttonPn.add(p, BorderLayout.WEST);

    buttonPn.add(closeButton, BorderLayout.EAST);
    getRootPane().setDefaultButton(closeButton);
  }
コード例 #9
0
  /** Creates the GUI */
  private void createGUI() {
    UiUtilities.registerForClosing(this);

    JPanel panel = (JPanel) getContentPane();
    panel.setLayout(new BorderLayout());

    RatingComparator comperator = new RatingComparator();

    Vector<Rating> overallData = new Vector<Rating>(mPlugin.getDatabase().getServerRatings());
    Collections.sort(overallData, comperator);

    mTabbedPane = new JTabbedPane();

    mOverallRatings = new JList(overallData);
    mOverallRatings.setCellRenderer(new RatingCellRenderer());
    mOverallRatings.addMouseListener(
        new MouseAdapter() {

          public void mousePressed(MouseEvent evt) {
            if (evt.isPopupTrigger()) {
              showPopUpMenu(evt);
            }
          }

          public void mouseReleased(MouseEvent evt) {
            if (evt.isPopupTrigger()) {
              showPopUpMenu(evt);
            }
          }

          public void mouseClicked(MouseEvent e) {
            if ((e.getButton() == MouseEvent.BUTTON1) && (e.getClickCount() == 2)) {
              view();
            }
            super.mouseClicked(e);
          }
        });

    mTabbedPane.addTab(
        mLocalizer.msg("overall", "Overall Ratings"), new JScrollPane(mOverallRatings));

    Vector<Rating> personalData = new Vector<Rating>(mPlugin.getDatabase().getPersonalRatings());
    Collections.sort(personalData, comperator);

    mPersonalRatings = new JList(personalData);
    mPersonalRatings.setCellRenderer(new RatingCellRenderer());
    mPersonalRatings.addMouseListener(
        new MouseAdapter() {
          public void mousePressed(MouseEvent evt) {
            if (evt.isPopupTrigger()) {
              showPopUpMenu(evt);
            }
          }

          public void mouseReleased(MouseEvent evt) {
            if (evt.isPopupTrigger()) {
              showPopUpMenu(evt);
            }
          }

          public void mouseClicked(MouseEvent e) {
            if ((e.getButton() == MouseEvent.BUTTON1) && (e.getClickCount() == 2)) {
              view();
            }
            super.mouseClicked(e);
          }
        });

    mTabbedPane.addTab(
        mLocalizer.msg("personal", "Your Ratings"), new JScrollPane(mPersonalRatings));

    panel.add(mTabbedPane, BorderLayout.CENTER);

    JPanel buttonpanel = new JPanel(new GridBagLayout());

    GridBagConstraints c4 = new GridBagConstraints();
    c4.gridwidth = GridBagConstraints.REMAINDER;
    c4.fill = GridBagConstraints.HORIZONTAL;
    c4.weightx = 1;
    c4.anchor = GridBagConstraints.CENTER;

    LinkButton linkButton = new LinkButton("http://tvaddicted.de");
    buttonpanel.add(linkButton, c4);

    GridBagConstraints c = new GridBagConstraints();
    c.weightx = 0;
    c.fill = GridBagConstraints.NONE;
    c.insets = new Insets(5, 5, 5, 5);

    mBtnUpdate = new JButton(mLocalizer.msg("update", "Update"));
    buttonpanel.add(mBtnUpdate, c);
    mBtnUpdate.addActionListener(
        new java.awt.event.ActionListener() {

          public void actionPerformed(ActionEvent e) {
            update();
          }
        });

    GridBagConstraints c2 = new GridBagConstraints();
    c2.weightx = 1;
    c2.fill = GridBagConstraints.HORIZONTAL;

    buttonpanel.add(new JPanel(), c2);

    JButton view = new JButton(mLocalizer.msg("view", "View"));
    buttonpanel.add(view, c);
    view.addActionListener(
        new java.awt.event.ActionListener() {

          public void actionPerformed(ActionEvent e) {
            view();
          }
        });

    JButton close = new JButton(Localizer.getLocalization(Localizer.I18N_CLOSE));
    buttonpanel.add(close, c);
    close.addActionListener(
        new java.awt.event.ActionListener() {

          public void actionPerformed(ActionEvent e) {
            setVisible(false);
          }
        });

    getRootPane().setDefaultButton(close);

    panel.add(buttonpanel, BorderLayout.SOUTH);
  }
コード例 #10
0
public class FontsDialog extends JDialog implements WindowClosingIf {

  /** The localizer for this class. */
  private static final util.ui.Localizer mLocalizer =
      util.ui.Localizer.getLocalizerFor(FontsDialog.class);

  private static final int CANCEL = 0;
  protected static final int OK = 1;

  private FontChooserPanel mTitleFontPanel;
  private FontChooserPanel mDescriptionFontPanel;
  private FontChooserPanel mDateFontPanel;
  private int mResult;

  public FontsDialog(Frame parent, Font titleFont, Font descriptionFont, Font dateFont) {
    super(parent, true);
    setTitle(mLocalizer.msg("dialog.title", "Fonts"));
    JPanel content = (JPanel) getContentPane();

    UiUtilities.registerForClosing(this);

    CellConstraints cc = new CellConstraints();
    FormLayout layout = new FormLayout("5dlu,pref:grow", "pref,5dlu,pref,2dlu,pref,5dlu,pref");
    PanelBuilder pb = new PanelBuilder(layout, content);
    pb.setBorder(Borders.DLU4_BORDER);

    pb.addSeparator(mLocalizer.msg("fonts", "Fonts"), cc.xyw(1, 1, 2));

    mTitleFontPanel = new FontChooserPanel(mLocalizer.msg("title", "Title"), titleFont);
    mDescriptionFontPanel =
        new FontChooserPanel(mLocalizer.msg("description", "Description"), descriptionFont);
    if (dateFont != null) {
      mDateFontPanel = new FontChooserPanel(mLocalizer.msg("date", "Date"), dateFont);
    }

    int y = 3;

    pb.add(mTitleFontPanel, cc.xy(2, y++));
    pb.add(mDescriptionFontPanel, cc.xy(2, ++y));

    if (dateFont != null) {
      layout.insertRow(++y, RowSpec.decode("2dlu"));
      layout.insertRow(++y, RowSpec.decode("pref"));

      content.add(mDateFontPanel, cc.xy(2, y));
    }
    y++;

    JPanel btnPn = new JPanel(new FlowLayout());

    JButton okBt = new JButton(Localizer.getLocalization(Localizer.I18N_OK));
    JButton cancelBt = new JButton(Localizer.getLocalization(Localizer.I18N_CANCEL));

    btnPn.add(okBt);
    btnPn.add(cancelBt);

    okBt.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            mResult = OK;
            setVisible(false);
          }
        });

    cancelBt.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            close();
          }
        });

    content.add(btnPn, cc.xyw(1, ++y, 2));

    mResult = CANCEL;
    pack();
  }

  public int getResult() {
    return mResult;
  }

  public Font getTitleFont() {
    return mTitleFontPanel.getChosenFont();
  }

  public Font getDescriptionFont() {
    return mDescriptionFontPanel.getChosenFont();
  }

  public Font getDateFont() {
    if (mDateFontPanel != null) {
      return mDateFontPanel.getChosenFont();
    }
    return null;
  }

  public void close() {
    mResult = CANCEL;
    setVisible(false);
  }
}
コード例 #11
0
/**
 * This Dialog shows an overview of all Ratings in this Database
 *
 * @author bodo tasche
 */
public class DialogOverview extends JDialog implements WindowClosingIf {

  /** Localizer */
  private static final Localizer mLocalizer = Localizer.getLocalizerFor(DialogOverview.class);

  /** The TVRaterPlugin with the Database */
  private TVRaterPlugin mPlugin;

  /** The tabbed Pane */
  private JTabbedPane mTabbedPane;

  /** List of personal Ratings */
  private JList mPersonalRatings;

  /** List of overall Ratings */
  private JList mOverallRatings;

  /** Der Update-Button */
  private JButton mBtnUpdate;

  /**
   * Creates the Overview Dialog
   *
   * @param parent Parent-Frame
   * @param tvraterPlugin Database to use
   */
  public DialogOverview(Frame parent, TVRaterPlugin tvraterPlugin) {
    super(parent, true);
    setTitle(mLocalizer.msg("title", "Rating-Overview"));

    mPlugin = tvraterPlugin;

    createGUI();
  }

  /** Creates the GUI */
  private void createGUI() {
    UiUtilities.registerForClosing(this);

    JPanel panel = (JPanel) getContentPane();
    panel.setLayout(new BorderLayout());

    RatingComparator comperator = new RatingComparator();

    Vector<Rating> overallData = new Vector<Rating>(mPlugin.getDatabase().getServerRatings());
    Collections.sort(overallData, comperator);

    mTabbedPane = new JTabbedPane();

    mOverallRatings = new JList(overallData);
    mOverallRatings.setCellRenderer(new RatingCellRenderer());
    mOverallRatings.addMouseListener(
        new MouseAdapter() {

          public void mousePressed(MouseEvent evt) {
            if (evt.isPopupTrigger()) {
              showPopUpMenu(evt);
            }
          }

          public void mouseReleased(MouseEvent evt) {
            if (evt.isPopupTrigger()) {
              showPopUpMenu(evt);
            }
          }

          public void mouseClicked(MouseEvent e) {
            if ((e.getButton() == MouseEvent.BUTTON1) && (e.getClickCount() == 2)) {
              view();
            }
            super.mouseClicked(e);
          }
        });

    mTabbedPane.addTab(
        mLocalizer.msg("overall", "Overall Ratings"), new JScrollPane(mOverallRatings));

    Vector<Rating> personalData = new Vector<Rating>(mPlugin.getDatabase().getPersonalRatings());
    Collections.sort(personalData, comperator);

    mPersonalRatings = new JList(personalData);
    mPersonalRatings.setCellRenderer(new RatingCellRenderer());
    mPersonalRatings.addMouseListener(
        new MouseAdapter() {
          public void mousePressed(MouseEvent evt) {
            if (evt.isPopupTrigger()) {
              showPopUpMenu(evt);
            }
          }

          public void mouseReleased(MouseEvent evt) {
            if (evt.isPopupTrigger()) {
              showPopUpMenu(evt);
            }
          }

          public void mouseClicked(MouseEvent e) {
            if ((e.getButton() == MouseEvent.BUTTON1) && (e.getClickCount() == 2)) {
              view();
            }
            super.mouseClicked(e);
          }
        });

    mTabbedPane.addTab(
        mLocalizer.msg("personal", "Your Ratings"), new JScrollPane(mPersonalRatings));

    panel.add(mTabbedPane, BorderLayout.CENTER);

    JPanel buttonpanel = new JPanel(new GridBagLayout());

    GridBagConstraints c4 = new GridBagConstraints();
    c4.gridwidth = GridBagConstraints.REMAINDER;
    c4.fill = GridBagConstraints.HORIZONTAL;
    c4.weightx = 1;
    c4.anchor = GridBagConstraints.CENTER;

    LinkButton linkButton = new LinkButton("http://tvaddicted.de");
    buttonpanel.add(linkButton, c4);

    GridBagConstraints c = new GridBagConstraints();
    c.weightx = 0;
    c.fill = GridBagConstraints.NONE;
    c.insets = new Insets(5, 5, 5, 5);

    mBtnUpdate = new JButton(mLocalizer.msg("update", "Update"));
    buttonpanel.add(mBtnUpdate, c);
    mBtnUpdate.addActionListener(
        new java.awt.event.ActionListener() {

          public void actionPerformed(ActionEvent e) {
            update();
          }
        });

    GridBagConstraints c2 = new GridBagConstraints();
    c2.weightx = 1;
    c2.fill = GridBagConstraints.HORIZONTAL;

    buttonpanel.add(new JPanel(), c2);

    JButton view = new JButton(mLocalizer.msg("view", "View"));
    buttonpanel.add(view, c);
    view.addActionListener(
        new java.awt.event.ActionListener() {

          public void actionPerformed(ActionEvent e) {
            view();
          }
        });

    JButton close = new JButton(Localizer.getLocalization(Localizer.I18N_CLOSE));
    buttonpanel.add(close, c);
    close.addActionListener(
        new java.awt.event.ActionListener() {

          public void actionPerformed(ActionEvent e) {
            setVisible(false);
          }
        });

    getRootPane().setDefaultButton(close);

    panel.add(buttonpanel, BorderLayout.SOUTH);
  }

  /**
   * Shows the PopUp
   *
   * @param e MouseEvent
   */
  protected void showPopUpMenu(MouseEvent e) {
    if (!(e.getSource() instanceof JList)) {
      return;
    }

    JList list = (JList) e.getSource();

    int i = list.locationToIndex(e.getPoint());
    list.setSelectedIndex(i);

    JPopupMenu menu = new JPopupMenu();

    Rating selRating = (Rating) list.getSelectedValue();

    JMenuItem item = new JMenuItem(mLocalizer.msg("showDetails", "Show Details"));
    item.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            view();
          }
        });
    item.setFont(item.getFont().deriveFont(Font.BOLD));

    menu.add(item);
    menu.add(new ListAction(this, selRating.getTitle()));
    menu.add(new ShowDetailsAction(selRating.getRatingId()));

    menu.show(list, e.getX(), e.getY());
  }

  /** Creates a DialogRating with the selected Rating */
  protected void view() {
    if ((mTabbedPane.getSelectedIndex() == 0) && (mOverallRatings.getSelectedValue() != null)) {

      DialogRating dlg =
          new DialogRating(
              mPlugin.getParentFrameForTVRater(),
              mPlugin,
              ((Rating) mOverallRatings.getSelectedValue()).getTitle());

      UiUtilities.centerAndShow(dlg);

      updateLists();
    } else if ((mTabbedPane.getSelectedIndex() == 1)
        && (mPersonalRatings.getSelectedValue() != null)) {
      DialogRating dlg =
          new DialogRating(
              mPlugin.getParentFrameForTVRater(),
              mPlugin,
              ((Rating) mPersonalRatings.getSelectedValue()).getTitle());
      UiUtilities.centerAndShow(dlg);
      updateLists();
    }
  }

  /** Updates the Rating-Lists */
  private void updateLists() {
    RatingComparator comperator = new RatingComparator();

    Vector<Rating> personalVector = new Vector<Rating>(mPlugin.getDatabase().getPersonalRatings());
    Collections.sort(personalVector, comperator);
    int index = mPersonalRatings.getSelectedIndex();
    mPersonalRatings.setListData(personalVector);
    mPersonalRatings.setSelectedIndex(index);

    Vector<Rating> overallVector = new Vector<Rating>(mPlugin.getDatabase().getServerRatings());
    Collections.sort(overallVector, comperator);
    index = mOverallRatings.getSelectedIndex();
    mOverallRatings.setListData(overallVector);
    mOverallRatings.setSelectedIndex(index);
  }

  /** Updates the Database from the Server */
  protected void update() {
    mBtnUpdate.setEnabled(false);
    mPlugin.runUpdate(
        true,
        new Runnable() {

          @Override
          public void run() {
            mBtnUpdate.setEnabled(true);
          }
        });
  }

  public void close() {
    setVisible(false);
  }
}
/**
 * This FilterComponent gives the users the opportunity to filter for all ratings of shows. The
 * different categories of the rating are and-linked together, ie a show must be better (or worse)
 * in _all_ categories to be accepted.
 *
 * @author uzi
 */
public class TVRaterFilterAllCategories extends PluginsFilterComponent {
  /** Localizer for messages, labels etc */
  private static final Localizer mLocalizer =
      Localizer.getLocalizerFor(TVRaterFilterAllCategories.class);

  /**
   * the values which will be accepted for the different categories: overall - action - fun - erotic
   * - tension - entitlement. the initial values will be replaced by the values from the different
   * combo boxes. the indices are defined as constants.
   */
  private byte[] mAcceptValues = {3, 3, 3, 3, 3, 3};

  private static final byte OVERALL_INDEX = 0;
  private static final byte ACTION_INDEX = 1;
  private static final byte FUN_INDEX = 2;
  private static final byte EROTIC_INDEX = 3;
  private static final byte TENSION_INDEX = 4;
  private static final byte ENTITLEMENT_INDEX = 5;

  /** Show programs that are better or worse than the <code>_acceptValues</code>. */
  private boolean mBest = true;

  /** Settings: show only good or bad programs. linked to <code>_best</code>. */
  private JComboBox mBetterCombo;

  /**
   * Settings: show only shows, that are better/worse than or equal this overall rating. linked to
   * <code>_acceptValues[0]</code>.
   */
  private JComboBox mOverallRatingBox;

  /**
   * Settings: show only shows, that are better/worse than or equal this action rating. linked to
   * <code>_acceptValues[1]</code>.
   */
  private JComboBox mActionRatingBox;

  /**
   * Settings: show only shows, that are better/worse than or equal this fun rating. linked to
   * <code>_acceptValues[2]</code>.
   */
  private JComboBox mFunRatingBox;

  /**
   * Settings: show only shows, that are better/worse than or equal this erotic rating. linked to
   * <code>_acceptValues[3]</code>.
   */
  private JComboBox mEroticRatingBox;

  /**
   * Settings: show only shows, that are better/worse than or equal this tension rating. linked to
   * <code>_acceptValues[4]</code>.
   */
  private JComboBox mTensionRatingBox;

  /**
   * Settings: show only shows, that are better/worse than or equal this entitlement rating. linked
   * to <code>_acceptValues[5]</code>.
   */
  private JComboBox mEntitlementRatingBox;

  /** @return Name of the Filter */
  public String getUserPresentableClassName() {
    return mLocalizer.msg("PresentableName", "Filter ratings");
  }

  /** @return Version */
  public int getVersion() {
    return 1;
  }

  /**
   * Accept Programs if rating fits
   *
   * @param program check this program
   * @return true, if rating fits
   */
  public boolean accept(Program program) {
    Rating rating = TVRaterPlugin.getInstance().getRating(program);

    if (rating == null) {
      return false;
    }

    if (mBest
        && rating.getOverallRating() >= mAcceptValues[TVRaterFilterAllCategories.OVERALL_INDEX]
        && rating.getActionRating() >= mAcceptValues[TVRaterFilterAllCategories.ACTION_INDEX]
        && rating.getFunRating() >= mAcceptValues[TVRaterFilterAllCategories.FUN_INDEX]
        && rating.getEroticRating() >= mAcceptValues[TVRaterFilterAllCategories.EROTIC_INDEX]
        && rating.getTensionRating() >= mAcceptValues[TVRaterFilterAllCategories.TENSION_INDEX]
        && rating.getEntitlementRating()
            >= mAcceptValues[TVRaterFilterAllCategories.ENTITLEMENT_INDEX]) {
      return true;
    } else if (!mBest
        && rating.getOverallRating() <= mAcceptValues[TVRaterFilterAllCategories.OVERALL_INDEX]
        && rating.getActionRating() <= mAcceptValues[TVRaterFilterAllCategories.ACTION_INDEX]
        && rating.getFunRating() <= mAcceptValues[TVRaterFilterAllCategories.FUN_INDEX]
        && rating.getEroticRating() <= mAcceptValues[TVRaterFilterAllCategories.EROTIC_INDEX]
        && rating.getTensionRating() <= mAcceptValues[TVRaterFilterAllCategories.TENSION_INDEX]
        && rating.getEntitlementRating()
            <= mAcceptValues[TVRaterFilterAllCategories.ENTITLEMENT_INDEX]) {
      return true;
    }
    return false;
  }

  /**
   * Load settings
   *
   * @param in load settings from this stream
   * @param version Version of the stream
   * @throws IOException Problems reading the Data
   * @throws ClassNotFoundException Problems creating classes while reading
   */
  public void read(ObjectInputStream in, int version) throws IOException, ClassNotFoundException {
    if (version >= 1) {
      mAcceptValues = (byte[]) in.readObject();
      mBest = in.readBoolean();
    }
  }

  /**
   * Store Settings
   *
   * @param out store settings here
   * @throws IOException Exception while storing the data
   */
  public void write(ObjectOutputStream out) throws IOException {
    out.writeObject(mAcceptValues);
    out.writeBoolean(mBest);
  }

  @Override
  public JPanel getSettingsPanel() {
    JPanel panel =
        new JPanel(
            new FormLayout(
                "pref, 3dlu, pref",
                "pref, 3dlu, pref, 3dlu, pref, 3dlu, pref, 3dlu, pref, 3dlu, pref, 3dlu, pref"));
    CellConstraints cc = new CellConstraints();

    // better-or-worse-combobox + label
    panel.add(new JLabel(mLocalizer.msg("programsThatAre", "Programs that are")), cc.xy(1, 1));
    mBetterCombo =
        new JComboBox(
            new String[] {
              mLocalizer.msg("betterOrEqual", "better than or equal to"),
              mLocalizer.msg("worseOrEqual", "inferior or equal to")
            });
    if (mBest) {
      mBetterCombo.setSelectedIndex(0);
    } else {
      mBetterCombo.setSelectedIndex(1);
    }
    panel.add(mBetterCombo, cc.xy(3, 1));

    // the rating for the RatingComboBox
    Rating filterRating = new Rating("");
    filterRating.setOverallRating(mAcceptValues[TVRaterFilterAllCategories.OVERALL_INDEX]);
    filterRating.setActionRating(mAcceptValues[TVRaterFilterAllCategories.ACTION_INDEX]);
    filterRating.setFunRating(mAcceptValues[TVRaterFilterAllCategories.FUN_INDEX]);
    filterRating.setEroticRating(mAcceptValues[TVRaterFilterAllCategories.EROTIC_INDEX]);
    filterRating.setTensionRating(mAcceptValues[TVRaterFilterAllCategories.TENSION_INDEX]);
    filterRating.setEntitlementRating(mAcceptValues[TVRaterFilterAllCategories.ENTITLEMENT_INDEX]);

    // overall rating box + label
    panel.add(new JLabel(mLocalizer.msg("overall", "Overall") + ":"), cc.xy(1, 3));
    mOverallRatingBox = new RatingComboBox(filterRating, Rating.OVERALL_RATING_KEY);
    panel.add(mOverallRatingBox, cc.xy(3, 3));

    // action rating box + label
    panel.add(new JLabel(mLocalizer.msg("action", "Action") + ":"), cc.xy(1, 5));
    mActionRatingBox = new RatingComboBox(filterRating, Rating.ACTION_RATING_KEY);
    panel.add(mActionRatingBox, cc.xy(3, 5));

    // fun rating box + label
    panel.add(new JLabel(mLocalizer.msg("fun", "Fun") + ":"), cc.xy(1, 7));
    mFunRatingBox = new RatingComboBox(filterRating, Rating.FUN_RATING_KEY);
    panel.add(mFunRatingBox, cc.xy(3, 7));

    // erotic rating box + label
    panel.add(new JLabel(mLocalizer.msg("erotic", "Erotic") + ":"), cc.xy(1, 9));
    mEroticRatingBox = new RatingComboBox(filterRating, Rating.EROTIC_RATING_KEY);
    panel.add(mEroticRatingBox, cc.xy(3, 9));

    // tension rating box + label
    panel.add(new JLabel(mLocalizer.msg("tension", "Tension") + ":"), cc.xy(1, 11));
    mTensionRatingBox = new RatingComboBox(filterRating, Rating.TENSION_RATING_KEY);
    panel.add(mTensionRatingBox, cc.xy(3, 11));

    // entitlement rating box + label
    panel.add(new JLabel(mLocalizer.msg("entitlement", "Level") + ":"), cc.xy(1, 13));
    mEntitlementRatingBox = new RatingComboBox(filterRating, Rating.ENTITLEMENT_RATING_KEY);
    panel.add(mEntitlementRatingBox, cc.xy(3, 13));

    return panel;
  }

  @Override
  public void saveSettings() {
    mBest = mBetterCombo.getSelectedIndex() < 1;
    mAcceptValues[TVRaterFilterAllCategories.OVERALL_INDEX] =
        (byte) mOverallRatingBox.getSelectedIndex();
    mAcceptValues[TVRaterFilterAllCategories.ACTION_INDEX] =
        (byte) mActionRatingBox.getSelectedIndex();
    mAcceptValues[TVRaterFilterAllCategories.FUN_INDEX] = (byte) mFunRatingBox.getSelectedIndex();
    mAcceptValues[TVRaterFilterAllCategories.EROTIC_INDEX] =
        (byte) mEroticRatingBox.getSelectedIndex();
    mAcceptValues[TVRaterFilterAllCategories.TENSION_INDEX] =
        (byte) mTensionRatingBox.getSelectedIndex();
    mAcceptValues[TVRaterFilterAllCategories.ENTITLEMENT_INDEX] =
        (byte) mEntitlementRatingBox.getSelectedIndex();
  }
}
  @Override
  public JPanel getSettingsPanel() {
    JPanel panel =
        new JPanel(
            new FormLayout(
                "pref, 3dlu, pref",
                "pref, 3dlu, pref, 3dlu, pref, 3dlu, pref, 3dlu, pref, 3dlu, pref, 3dlu, pref"));
    CellConstraints cc = new CellConstraints();

    // better-or-worse-combobox + label
    panel.add(new JLabel(mLocalizer.msg("programsThatAre", "Programs that are")), cc.xy(1, 1));
    mBetterCombo =
        new JComboBox(
            new String[] {
              mLocalizer.msg("betterOrEqual", "better than or equal to"),
              mLocalizer.msg("worseOrEqual", "inferior or equal to")
            });
    if (mBest) {
      mBetterCombo.setSelectedIndex(0);
    } else {
      mBetterCombo.setSelectedIndex(1);
    }
    panel.add(mBetterCombo, cc.xy(3, 1));

    // the rating for the RatingComboBox
    Rating filterRating = new Rating("");
    filterRating.setOverallRating(mAcceptValues[TVRaterFilterAllCategories.OVERALL_INDEX]);
    filterRating.setActionRating(mAcceptValues[TVRaterFilterAllCategories.ACTION_INDEX]);
    filterRating.setFunRating(mAcceptValues[TVRaterFilterAllCategories.FUN_INDEX]);
    filterRating.setEroticRating(mAcceptValues[TVRaterFilterAllCategories.EROTIC_INDEX]);
    filterRating.setTensionRating(mAcceptValues[TVRaterFilterAllCategories.TENSION_INDEX]);
    filterRating.setEntitlementRating(mAcceptValues[TVRaterFilterAllCategories.ENTITLEMENT_INDEX]);

    // overall rating box + label
    panel.add(new JLabel(mLocalizer.msg("overall", "Overall") + ":"), cc.xy(1, 3));
    mOverallRatingBox = new RatingComboBox(filterRating, Rating.OVERALL_RATING_KEY);
    panel.add(mOverallRatingBox, cc.xy(3, 3));

    // action rating box + label
    panel.add(new JLabel(mLocalizer.msg("action", "Action") + ":"), cc.xy(1, 5));
    mActionRatingBox = new RatingComboBox(filterRating, Rating.ACTION_RATING_KEY);
    panel.add(mActionRatingBox, cc.xy(3, 5));

    // fun rating box + label
    panel.add(new JLabel(mLocalizer.msg("fun", "Fun") + ":"), cc.xy(1, 7));
    mFunRatingBox = new RatingComboBox(filterRating, Rating.FUN_RATING_KEY);
    panel.add(mFunRatingBox, cc.xy(3, 7));

    // erotic rating box + label
    panel.add(new JLabel(mLocalizer.msg("erotic", "Erotic") + ":"), cc.xy(1, 9));
    mEroticRatingBox = new RatingComboBox(filterRating, Rating.EROTIC_RATING_KEY);
    panel.add(mEroticRatingBox, cc.xy(3, 9));

    // tension rating box + label
    panel.add(new JLabel(mLocalizer.msg("tension", "Tension") + ":"), cc.xy(1, 11));
    mTensionRatingBox = new RatingComboBox(filterRating, Rating.TENSION_RATING_KEY);
    panel.add(mTensionRatingBox, cc.xy(3, 11));

    // entitlement rating box + label
    panel.add(new JLabel(mLocalizer.msg("entitlement", "Level") + ":"), cc.xy(1, 13));
    mEntitlementRatingBox = new RatingComboBox(filterRating, Rating.ENTITLEMENT_RATING_KEY);
    panel.add(mEntitlementRatingBox, cc.xy(3, 13));

    return panel;
  }
 /** @return Name of the Filter */
 public String getUserPresentableClassName() {
   return mLocalizer.msg("PresentableName", "Filter ratings");
 }
コード例 #15
0
  public FontsDialog(Frame parent, Font titleFont, Font descriptionFont, Font dateFont) {
    super(parent, true);
    setTitle(mLocalizer.msg("dialog.title", "Fonts"));
    JPanel content = (JPanel) getContentPane();

    UiUtilities.registerForClosing(this);

    CellConstraints cc = new CellConstraints();
    FormLayout layout = new FormLayout("5dlu,pref:grow", "pref,5dlu,pref,2dlu,pref,5dlu,pref");
    PanelBuilder pb = new PanelBuilder(layout, content);
    pb.setBorder(Borders.DLU4_BORDER);

    pb.addSeparator(mLocalizer.msg("fonts", "Fonts"), cc.xyw(1, 1, 2));

    mTitleFontPanel = new FontChooserPanel(mLocalizer.msg("title", "Title"), titleFont);
    mDescriptionFontPanel =
        new FontChooserPanel(mLocalizer.msg("description", "Description"), descriptionFont);
    if (dateFont != null) {
      mDateFontPanel = new FontChooserPanel(mLocalizer.msg("date", "Date"), dateFont);
    }

    int y = 3;

    pb.add(mTitleFontPanel, cc.xy(2, y++));
    pb.add(mDescriptionFontPanel, cc.xy(2, ++y));

    if (dateFont != null) {
      layout.insertRow(++y, RowSpec.decode("2dlu"));
      layout.insertRow(++y, RowSpec.decode("pref"));

      content.add(mDateFontPanel, cc.xy(2, y));
    }
    y++;

    JPanel btnPn = new JPanel(new FlowLayout());

    JButton okBt = new JButton(Localizer.getLocalization(Localizer.I18N_OK));
    JButton cancelBt = new JButton(Localizer.getLocalization(Localizer.I18N_CANCEL));

    btnPn.add(okBt);
    btnPn.add(cancelBt);

    okBt.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            mResult = OK;
            setVisible(false);
          }
        });

    cancelBt.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            close();
          }
        });

    content.add(btnPn, cc.xyw(1, ++y, 2));

    mResult = CANCEL;
    pack();
  }
コード例 #16
0
/** @author bananeweizen */
class DataHydraDayParser extends AbstractXmlTvDataHandler {
  private static final Localizer mLocalizer = Localizer.getLocalizerFor(DataHydraDayParser.class);

  private static final Logger mLog = Logger.getLogger(DataHydraDayParser.class.getName());

  private Hashtable<String, MutableChannelDayProgram> mDayProgsHashTable;

  private MutableChannelDayProgram mMcdp;

  private Channel mChannel;

  private SweDBTvDataService mDataService;

  private MutableProgram mProgram;

  /** Creates a new instance of DataHydraDayParser */
  private DataHydraDayParser(
      Channel ch, Hashtable<String, MutableChannelDayProgram> lht, SweDBTvDataService dataService) {
    mChannel = ch;
    mDayProgsHashTable = lht;
    mDataService = dataService;
  }

  public InputSource resolveEntity(String publicId, String systemId) {
    byte[] temp = new byte[0];
    // strib...
    return new InputSource(new ByteArrayInputStream(temp));
  }

  @Override
  protected void startProgram(final Date startDate, final int startTime) {
    if (!mDayProgsHashTable.containsKey(startDate.toString())) {
      mMcdp = new MutableChannelDayProgram(startDate, mChannel);
      mDayProgsHashTable.put(startDate.toString(), mMcdp);
    } else {
      mMcdp = mDayProgsHashTable.get(startDate.toString());
    }
    int startHour = startTime / 60;
    int startMinute = startTime % 60;
    mProgram = new MutableProgram(mMcdp.getChannel(), startDate, startHour, startMinute, true);
  }

  public void fatalError(SAXParseException e) {
    // empty
  }

  public void error(SAXParseException e) {}

  public void warning(SAXParseException e) {}

  protected static void parseNew(
      InputStream in,
      Channel ch,
      devplugin.Date day,
      Hashtable<String, MutableChannelDayProgram> ht,
      SweDBTvDataService dataService)
      throws Exception {
    SAXParserFactory fac = SAXParserFactory.newInstance();
    fac.setValidating(false);
    SAXParser sax = fac.newSAXParser();
    InputSource input = new InputSource(in);
    input.setSystemId(new File("/").toURI().toURL().toString());
    sax.parse(input, new DataHydraDayParser(ch, ht, dataService));
  }

  @Override
  protected void addField(final ProgramFieldType fieldType, final byte[] value) {
    mProgram.setBinaryField(fieldType, value);
  }

  @Override
  protected void addField(final ProgramFieldType fieldType, String value) {
    if (fieldType.equals(ProgramFieldType.DESCRIPTION_TYPE)) {
      if (((DataHydraChannelGroup) mChannel.getGroup()).isShowRegister()
          && mDataService.getShowRegisterText()) {
        value +=
            "\n\n" + mLocalizer.msg("register", "Please Register at {0}", mChannel.getWebpage());
      }
    }
    mProgram.setTextField(fieldType, value);
    if (fieldType.equals(ProgramFieldType.TITLE_TYPE)) {
      mProgram.setTitle(value);
    }
  }

  @Override
  protected void addField(final ProgramFieldType fieldType, final int value) {
    if (fieldType.getFormat() == ProgramFieldType.TIME_FORMAT) {
      mProgram.setTimeField(fieldType, value);
    } else {
      mProgram.setIntField(fieldType, value);
    }
    if (fieldType.equals(ProgramFieldType.END_TIME_TYPE)) {
      int endTime = value;
      int startTime = mProgram.getTimeField(ProgramFieldType.START_TIME_TYPE);
      int progLength = endTime - startTime;
      // Assumption: If the program length is less than 0, the program spans
      // midnight
      if (progLength < 0) {
        progLength += 24 * 60; // adding 24 hours to the length
      }
      // Only allow program length for 12 hours.... This will take care of
      // possible DST problems
      if ((progLength > 0) && (progLength < 12 * 60)) {
        mProgram.setLength(progLength);
      }
    }
  }

  @Override
  protected void addToList(final ProgramFieldType fieldType, String value, final String separator) {
    String currentValue = mProgram.getTextField(fieldType);
    if (currentValue != null && !currentValue.isEmpty()) {
      value = currentValue + separator + value;
    }

    mProgram.setTextField(fieldType, value);
  }

  @Override
  protected void endProgram() {
    // finish the program itself
    mProgram.setProgramLoadingIsComplete();
    mMcdp.addProgram(mProgram);
  }

  @Override
  protected String getChannelCountry() {
    return mProgram.getChannel().getCountry();
  }

  @Override
  protected void logException(final Exception exc) {
    mLog.warning(exc.getMessage());
  }

  @Override
  protected void logMessage(final String message) {
    mLog.info(message);
  }

  @Override
  protected void setInfoBit(final int bit) {
    int infoBits = mProgram.getIntField(ProgramFieldType.INFO_TYPE);
    if (infoBits == -1) {
      infoBits = 0;
    }
    infoBits |= bit;
    mProgram.setIntField(ProgramFieldType.INFO_TYPE, infoBits);
  }
}
コード例 #17
0
  public SettingsDialog(
      final Frame parent, final PrinterJob printerJob, Scheme[] schemes, DialogContent content) {
    super(parent, true);
    UiUtilities.registerForClosing(this);

    mDialogContent = content;
    mPageFormat = printerJob.defaultPage();
    setTitle(content.getDialogTitle());
    JPanel contentPane = (JPanel) getContentPane();
    contentPane.setBorder(BorderFactory.createEmptyBorder(4, 4, 5, 5));
    contentPane.setLayout(new BorderLayout());

    JPanel eastPanel = new JPanel(new BorderLayout());
    JPanel eastBtnPanel = new JPanel();
    eastBtnPanel.setBorder(BorderFactory.createEmptyBorder(0, 3, 0, 0));
    eastBtnPanel.setLayout(new GridLayout(-1, 1));

    JButton printerSetupBtn =
        new JButton(
            mLocalizer.ellipsisMsg("printer", "Printer"),
            PrintPlugin.getInstance().createImageIcon("devices", "printer", 16));
    JButton pageBtn =
        new JButton(
            mLocalizer.ellipsisMsg("page", "Page"),
            PrintPlugin.getInstance().createImageIcon("actions", "document-properties", 16));
    JButton previewBtn =
        new JButton(
            mLocalizer.ellipsisMsg("preview", "Preview"),
            PrintPlugin.getInstance().createImageIcon("actions", "document-print-preview", 16));

    printerSetupBtn.setHorizontalAlignment(SwingConstants.LEFT);
    pageBtn.setHorizontalAlignment(SwingConstants.LEFT);
    previewBtn.setHorizontalAlignment(SwingConstants.LEFT);

    eastBtnPanel.add(printerSetupBtn);
    eastBtnPanel.add(pageBtn);
    eastBtnPanel.add(previewBtn);
    eastPanel.add(eastBtnPanel, BorderLayout.NORTH);

    JPanel southPanel = new JPanel(new BorderLayout());
    JPanel okCancelBtnPanel = new JPanel(new FlowLayout());
    JButton printBt = new JButton(mLocalizer.msg("print", "Drucken"));
    JButton cancelBt = new JButton(Localizer.getLocalization(Localizer.I18N_CANCEL));
    okCancelBtnPanel.add(printBt);
    okCancelBtnPanel.add(cancelBt);
    southPanel.add(okCancelBtnPanel, BorderLayout.EAST);

    printerSetupBtn.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            Thread thread =
                new Thread("Printer setup") {
                  public void run() {
                    printerJob.printDialog();
                  }
                };
            thread.start();
          }
        });

    pageBtn.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            Thread thread =
                new Thread("Document properties (printing)") {
                  public void run() {
                    if (mPageFormat == null) {
                      mPageFormat = printerJob.defaultPage();
                    }
                    mPageFormat = printerJob.pageDialog(mPageFormat);
                  }
                };
            thread.start();
          }
        });

    previewBtn.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            printplugin.printer.PrintJob job = getPrintJob();
            if (job.getNumOfPages() == 0) {
              JOptionPane.showMessageDialog(
                  parent, mLocalizer.msg("noPagesToPrint", "Es sind keine Seiten zu drucken."));
            } else {
              PreviewDlg dlg =
                  new PreviewDlg(parent, job.getPrintable(), mPageFormat, job.getNumOfPages());

              PrintPlugin.getInstance().layoutWindow("previewDlg", dlg);

              dlg.setVisible(true);
            }
          }
        });

    printBt.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            mResult = OK;
            setVisible(false);
          }
        });

    cancelBt.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            close();
          }
        });

    JButton newSchemeBtn = new JButton(TVBrowserIcons.newIcon(TVBrowserIcons.SIZE_SMALL));
    newSchemeBtn.setToolTipText(mLocalizer.msg("newScheme", "New scheme"));
    mEditSchemeBtn = new JButton(TVBrowserIcons.edit(TVBrowserIcons.SIZE_SMALL));
    mEditSchemeBtn.setToolTipText(mLocalizer.msg("editScheme", "Edit scheme"));
    mDeleteSchemeBtn = new JButton(TVBrowserIcons.delete(TVBrowserIcons.SIZE_SMALL));
    mDeleteSchemeBtn.setToolTipText(mLocalizer.msg("deleteScheme", "Delete scheme"));
    mSaveSchemeBtn =
        new JButton(PrintPlugin.getInstance().createImageIcon("actions", "document-save", 16));
    mSaveSchemeBtn.setToolTipText(mLocalizer.msg("saveScheme", "Save scheme"));
    newSchemeBtn.setMargin(UiUtilities.ZERO_INSETS);
    mDeleteSchemeBtn.setMargin(UiUtilities.ZERO_INSETS);
    mEditSchemeBtn.setMargin(UiUtilities.ZERO_INSETS);
    mSaveSchemeBtn.setMargin(UiUtilities.ZERO_INSETS);
    mDeleteSchemeBtn.setEnabled(false);
    mEditSchemeBtn.setEnabled(false);

    newSchemeBtn.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            String newSchemeName =
                JOptionPane.showInputDialog(
                    parent,
                    mLocalizer.msg("enterNewSchemeName", "Enter new name for scheme:"),
                    mLocalizer.msg("newScheme", "New scheme"),
                    JOptionPane.PLAIN_MESSAGE);
            if (newSchemeName != null) {
              if (newSchemeName.trim().length() > 0) {
                Scheme newScheme = mDialogContent.createNewScheme(newSchemeName);
                newScheme.setSettings(mDialogContent.getSettings());
                mSchemeCBModel.addElement(newScheme);
                mSchemeCB.setSelectedItem(newScheme);
                mDialogContent.setSettings(newScheme.getSettings());
              } else {
                JOptionPane.showMessageDialog(
                    parent,
                    mLocalizer.msg("invalidSchemeMsg", "Invalid scheme name"),
                    mLocalizer.msg("invalidInput", "Invalid input"),
                    JOptionPane.INFORMATION_MESSAGE);
              }
            }
          }
        });

    mSaveSchemeBtn.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            Scheme scheme = (Scheme) mSchemeCB.getSelectedItem();
            scheme.setSettings(mDialogContent.getSettings());
          }
        });

    mEditSchemeBtn.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            Scheme scheme = (Scheme) mSchemeCB.getSelectedItem();
            Object newSchemeName =
                JOptionPane.showInputDialog(
                    parent,
                    mLocalizer.msg("enterNewSchemeName", "Enter new name for scheme:"),
                    mLocalizer.msg("editScheme", "Edit scheme"),
                    JOptionPane.PLAIN_MESSAGE,
                    null,
                    null,
                    scheme.getName());
            if (newSchemeName != null) {
              if (newSchemeName.toString().trim().length() > 0) {
                scheme.setName(newSchemeName.toString());
                mSchemeCB.repaint();
              } else {
                JOptionPane.showMessageDialog(
                    parent,
                    mLocalizer.msg("invalidSchemeMsg", "Invalid scheme name"),
                    mLocalizer.msg("invalidInput", "Invalid input"),
                    JOptionPane.INFORMATION_MESSAGE);
              }
            }
          }
        });

    mDeleteSchemeBtn.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            Scheme scheme = (Scheme) mSchemeCB.getSelectedItem();
            if (scheme != null) {
              if (JOptionPane.showConfirmDialog(
                      parent,
                      mLocalizer.msg(
                          "deleteSchemeMsg", "Do you want to delete the selected scheme?"),
                      mLocalizer.msg("deleteScheme", "Delete Scheme"),
                      JOptionPane.YES_NO_OPTION)
                  == JOptionPane.YES_OPTION) {
                mSchemeCBModel.removeElement(scheme);
                mSchemeCB.setSelectedIndex(0);
              }
            }
          }
        });

    mSchemeCBModel = new DefaultComboBoxModel(schemes);
    mSchemeCB = new JComboBox(mSchemeCBModel);
    JPanel schemePanel = new JPanel();
    schemePanel.add(mSchemeCB);
    schemePanel.add(newSchemeBtn);
    schemePanel.add(mEditSchemeBtn);
    schemePanel.add(mSaveSchemeBtn);
    schemePanel.add(mDeleteSchemeBtn);
    southPanel.add(schemePanel, BorderLayout.WEST);
    mSchemeCB.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            mDeleteSchemeBtn.setEnabled(mSchemeCB.getSelectedIndex() != 0);
            mEditSchemeBtn.setEnabled(mSchemeCB.getSelectedIndex() != 0);
            Scheme scheme = (Scheme) mSchemeCB.getSelectedItem();
            mDialogContent.setSettings(scheme.getSettings());
          }
        });

    contentPane.add(eastPanel, BorderLayout.EAST);
    contentPane.add(southPanel, BorderLayout.SOUTH);
    contentPane.add(content.getContent(), BorderLayout.CENTER);

    content.setSettings(schemes[0].getSettings());

    if (mPageFormat == null) {
      mPageFormat = printerJob.defaultPage();
    }

    PrintPlugin.getInstance().layoutWindow("settingsDlg", this, new Dimension(450, 400));

    mResult = CANCEL;
  }