protected void doShowPopupMenu(MouseEvent ev)
{
if (ev.isPopupTrigger())
{
JPopupMenu menu = new JPopupMenu();
final MouseEvent mouseEv = ev;
JStatusMenuItem menuItem;
final TableModel tblModel = m_table.getModel();
if (tblModel.getColumnCount() != m_table.getColumnCount())
{
menuItem = new JStatusMenuItem(Main.getString("menu_tableheader_add"), Main.getString("statusbar_menutableheader_add_help"), m_statusBar);
menu.add(menuItem);
menuItem.addActionListener(new ActionListener()
{
public void actionPerformed (ActionEvent ev)
{
int i, anzahl = tblModel.getColumnCount(), colIndex, index = 0;
JColChooserData[] dataArray = new JColChooserData[anzahl - m_table.getColumnCount()];
for (i=0; i<anzahl; i++)
{
colIndex = m_table.convertColumnIndexToView(i);
if (colIndex == -1)
dataArray[index++] = new JColChooserData(tblModel.getColumnName(i), i);
}
JColChooserDialog dia = new JColChooserDialog(Main.m_mainFrame, dataArray);
dia.setVisible(true);
if (dia.isOk())
{
JColChooserData data = dia.getSelectedItem();
TableColumn tblCol = new TableColumn();
tblCol.setModelIndex(data.m_modelColIndex);
TableColumnModel colModel = m_table.getColumnModel();
colIndex = colModel.getColumnIndexAtX(mouseEv.getX());
m_table.addColumn(tblCol);
m_table.moveColumn(m_table.getColumnCount()-1, colIndex);
if (JExifDataModel.m_colTag[data.m_modelColIndex] == JExifTag.GPSTAG_TAG_MAPLINK)
{
int w = new ImageIcon(Main.m_url_map).getIconWidth();
tblCol.setPreferredWidth(w);
tblCol.setMaxWidth(w);
tblCol.setMinWidth(w);
}
}
}
});
}
if (m_table.getColumnCount() > 1)
{
menuItem = new JStatusMenuItem(Main.getString("menu_tableheader_delete"), Main.getString("statusbar_menutableheader_delete_help"), m_statusBar);
menuItem.addActionListener(new ActionListener()
{
public void actionPerformed (ActionEvent ev)
{
TableColumnModel colModel = m_table.getColumnModel();
int colIndex = colModel.getColumnIndexAtX(mouseEv.getX());
TableColumn tblCol = colModel.getColumn(colIndex);
m_table.removeColumn(tblCol);
}
});
menu.add(menuItem);