toolbar.setAlignmentY(0.0f);
toolbar.setOpaque(false);
toolbar.setBorder(null);
toolbar.setBorderPainted(false);
ToolBarBuilder subTBbldr = new ToolBarBuilder(toolbar);
final JComboBox comboBox = new JComboBox();
// Indexes of items in this list should correspond to the values of
// filter setting from FeedRenderingSettings class (FILTER_XYZ constants)
createNAddComboBoxAction(comboBox, ActionsTable.CMD_ARTICLE_SHOW_ALL_TB);
createNAddComboBoxAction(comboBox, ActionsTable.CMD_ARTICLE_SHOW_UNREAD_TB);
createNAddComboBoxAction(comboBox, ActionsTable.CMD_ARTICLE_SHOW_PINNED_TB);
if (SentimentsFeature.isAvailable())
{
createNAddComboBoxAction(comboBox, ActionsTable.CMD_ARTICLE_SHOW_POSITIVE_TB);
createNAddComboBoxAction(comboBox, ActionsTable.CMD_ARTICLE_SHOW_NEGATIVE_TB);
createNAddComboBoxAction(comboBox, ActionsTable.CMD_ARTICLE_SHOW_NON_NEGATIVE_TB);
}
int filter = Math.min(RenderingManager.getArticleFilter(), comboBox.getItemCount() - 1);
comboBox.addActionListener(JComboBoxActionItem.getComboBoxListener());
comboBox.setOpaque(!SystemUtils.IS_OS_MAC);
comboBox.setFocusable(false);
comboBox.setSelectedIndex(filter);
// Listen to changes of FILTER property and update the selection
RenderingManager.addPropertyChangeListener(RenderingSettingsNames.ARTICLE_FILTER,
new PropertyChangeListener()
{
public void propertyChange(PropertyChangeEvent evt)
{
comboBox.setSelectedIndex(RenderingManager.getArticleFilter());
}
});
JPanel comboboxPanel = new JPanel(new FormLayout("10px, p", SystemUtils.IS_OS_MAC ? "1px, p" : "0, 20px"));
CellConstraints cc = new CellConstraints();
comboboxPanel.add(comboBox, cc.xy(2, 2));
// Mac OS Aqua look has a bug with JComboBox sizing depending on the font size
// The report: http://lists.apple.com/archives/Java-dev/2005/Jan/msg00510.html
// and the answer: http://lists.apple.com/archives/Java-dev/2005/Jan/msg00511.html
//
// The page with screenshots of how the Quaqua library deals with the JComboBox
// look through the custom component look painting (not a native component):
// http://www.randelshofer.ch/quaqua/guide/jcombobox.html
if (!SystemUtils.IS_OS_MAC)
{
comboBox.setFont(new Font("Tahoma", Font.PLAIN, 10));
}
comboboxPanel.setOpaque(false);
subTBbldr.add(comboboxPanel);
subTBbldr.addGap();
subTBbldr.add(new ViewModeSelector(GlobalModel.SINGLETON.getViewModeValueModel()));
return toolbar;
}