}
});
mFindAsYouType = new TextComponentFindAction(mInfoEP, true);
final JScrollPane scrollPane = new JScrollPane(mInfoEP);
scrollPane.getVerticalScrollBar().setUnitIncrement(30);
// ScrollActions
mUpAction = new AbstractAction() {
public void actionPerformed(ActionEvent e) {
scrollPane.getVerticalScrollBar().setValue(
scrollPane.getVerticalScrollBar().getValue()
- scrollPane.getVerticalScrollBar().getUnitIncrement());
}
};
mDownAction = new AbstractAction() {
public void actionPerformed(ActionEvent e) {
scrollPane.getVerticalScrollBar().setValue(
scrollPane.getVerticalScrollBar().getValue()
+ scrollPane.getVerticalScrollBar().getUnitIncrement());
}
};
mPluginsPane = new JTaskPane();
mPluginsPane.add(mFunctionGroup);
mActionsPane = new JScrollPane(mPluginsPane);
mConfigBtn = new JButton(mLocalizer.msg("config", "Configure view"));
mConfigBtn.setIcon(TVBrowserIcons.preferences(TVBrowserIcons.SIZE_SMALL));
ButtonBarBuilder2 buttonBuilder = new ButtonBarBuilder2();
buttonBuilder.addButton(mConfigBtn);
mConfigBtn.setVisible(showSettings);
if (pluginsSize == null) {
mActionsPane.setPreferredSize(new Dimension(250, 500));
} else {
mActionsPane.setPreferredSize(pluginsSize);
}
if (ProgramInfo.getInstance().getSettings().getShowFunctions()) {
JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
split.setDividerSize(5);
split.setContinuousLayout(true);
split.setDividerLocation(mActionsPane.getPreferredSize().width + 1);
split.setLeftComponent(mActionsPane);
split.setRightComponent(scrollPane);
mMainPanel.add(split, BorderLayout.CENTER);
mFindAsYouType.installKeyListener(split);
} else {
final JButton functions = new JButton(mLocalizer.msg("functions",
"Functions"));
functions.setFocusable(false);
functions.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 1) {
JPopupMenu popupMenu = PluginProxyManager.createPluginContextMenu(
mProgram, ProgramInfoProxy.getInstance());
popupMenu.show(functions, e.getX(), e.getY()
- popupMenu.getPreferredSize().height);
}
}
});
buttonBuilder.addUnrelatedGap();
buttonBuilder.addButton(functions);
mMainPanel.add(scrollPane, BorderLayout.CENTER);
}
// buttons
JPanel buttonPn = new JPanel(new BorderLayout(0, 5));
buttonPn.add(mFindAsYouType.getSearchBar(), BorderLayout.NORTH);
buttonPn.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0));
mMainPanel.add(buttonPn, BorderLayout.SOUTH);
mConfigBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
exit();
MainFrame.getInstance().showSettingsDialog(SettingsItem.PROGRAMINFO);
}
});
mHighlight = new JCheckBox(mLocalizer
.msg("highlight", "Highlight favorite"), ProgramInfo.getInstance()
.getSettings().getHighlightFavorite());
mHighlight.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
ProgramInfo.getInstance().getSettings().setHighlightFavorite(
mHighlight.isSelected());
highlightFavorites();
}
});
buttonBuilder.addUnrelatedGap();
buttonBuilder.addFixed(mHighlight);
mCloseBtn = new JButton(Localizer.getLocalization(Localizer.I18N_CLOSE));
mCloseBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
exit();
}
});
buttonBuilder.addGlue();
buttonBuilder.addButton(mCloseBtn);
buttonPn.add(buttonBuilder.getPanel(), BorderLayout.SOUTH);
/*
* The action for the search button in the function panel.
*/
final Action searchAction = new AbstractAction() {
private static final long serialVersionUID = 1L;
public void actionPerformed(ActionEvent e) {
// Open the SearchPanel
if (mFindAsYouType.getCloseButton().isVisible()) {
mFindAsYouType.interrupt();
mFindAsYouType.getSearchBar().setVisible(false);
mFindAsYouType.getCloseButton().setVisible(false);
} else {
mFindAsYouType.showSearchBar();
}
}
};
searchAction.putValue(Action.SMALL_ICON, TVBrowserIcons
.search(TVBrowserIcons.SIZE_SMALL));
searchAction.putValue(Action.ACTION_COMMAND_KEY, "action");
searchAction.putValue(Action.NAME, mLocalizer.msg("search", "Search Text"));
mSearchMenu = new ActionMenu(searchAction);
mFindAsYouType.installKeyListener(scrollPane);
mFindAsYouType.installKeyListener(mMainPanel);
mFindAsYouType.installKeyListener(mConfigBtn);
mFindAsYouType.installKeyListener(mCloseBtn);
mFindAsYouType.installKeyListener(buttonPn);
mFindAsYouType.installKeyListener(mPluginsPane);
mFindAsYouType.installKeyListener(mActionsPane);
mFindAsYouType.installKeyListener(mFunctionGroup);
mFindAsYouType.installKeyListener(mActionsPane.getVerticalScrollBar());
mFindAsYouType.installKeyListener(scrollPane.getVerticalScrollBar());
mFindAsYouType.getCloseButton().addComponentListener(
new ComponentAdapter() {
@Override
public void componentHidden(ComponentEvent e) {
if (mTextSearch != null) {
mTextSearch.setText(mLocalizer.msg("search", "Search Text"));
}
searchAction.putValue(Action.NAME, mLocalizer.msg("search",
"Search Text"));
}
@Override
public void componentShown(ComponentEvent e) {
if (mTextSearch != null) {
mTextSearch.setText(mLocalizer.msg("closeSearch",
"Close search bar"));
}
searchAction.putValue(Action.NAME, mLocalizer.msg("closeSearch",
"Close search bar"));
}
});
// Scroll to the beginning
Runnable runnable = new Runnable() {
public void run() {
scrollPane.getVerticalScrollBar().setValue(0);
}
};
SwingUtilities.invokeLater(runnable);
if (ProgramInfo.getInstance().getSettings().getShowSearch()) {