_comboBox = new JComboBox<ViewEntry>();
_comboBox.setModel(getViewComboBoxModel());
_comboBox.setRenderer(getViewListCellRenderer());
viewSelectionPanel.add(_comboBox);
final ConfigSource configSource = getToolContext().getConfigSource();
final PositionSource positionSource = getToolContext().getPositionSource();
final SecuritySource securitySource = getToolContext().getSecuritySource();
_failuresTreeTable = new JXTreeTable(new DefaultTreeTableModel());
_failuresTreeTable.setShowsRootHandles(true);
_failuresTreeTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
JPanel panel = new JPanel();
mainPanel.add(panel, BorderLayout.CENTER);
panel.setLayout(new BorderLayout(0, 0));
_splitPane = new JSplitPane();
panel.add(_splitPane);
JScrollPane failuresScrollPane = new JScrollPane(_failuresTreeTable);
_splitPane.setRightComponent(failuresScrollPane);
_portfolioTree = new JPortfolioTree(new DefaultTreeModel(null), getToolContext().getConfigSource());
JScrollPane scrollPane = new JScrollPane(_portfolioTree);
_splitPane.setLeftComponent(scrollPane);
_portfolioTree.addTreeSelectionListener(new TreeSelectionListener() {
@Override
public void valueChanged(TreeSelectionEvent e) {
JTree portfolioTree = (JTree) e.getSource();
updateTreeTableModel(portfolioTree);
}
});
_comboBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JComboBox<ViewEntry> cb = (JComboBox<ViewEntry>) e.getSource();
final ViewEntry viewEntry = (ViewEntry) cb.getSelectedItem();
if (viewEntry != null) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
ConfigItem<ViewDefinition> configItem = (ConfigItem<ViewDefinition>) configSource.get(viewEntry.getUniqueId());
if (configItem.getValue() != null) {
_portfolioTree.setModel(getPortfolioTreeModel(configItem.getValue().getPortfolioId(), getToolContext()));
} else {
JOptionPane.showMessageDialog(null, "There is no portfolio set in the selected view", "No portfolio", JOptionPane.ERROR_MESSAGE);
}