public void mouseClicked(MouseEvent ev)
{
int button = ev.getButton();
if (button == MouseEvent.BUTTON1 || button == MouseEvent.BUTTON2)
{
TableColumnModel colModel = m_table.getColumnModel();
int colIndex = colModel.getColumnIndexAtX(ev.getX());
colIndex = m_table.convertColumnIndexToModel(colIndex);
// if (JExifDataModel.m_colTag[colIndex] != JExifTag.GPSTAG_TAG_MAPLINK)
{
if (Main.m_settings.isDebug())
System.err.println("Sort:" + colIndex);
if (m_tableData.getSortCol() != colIndex)
m_tableData.setSortCol(colIndex);
else
m_tableData.setSortUp(!m_tableData.getSortUp());
setTableHeaderValues();
JIfdData jifdData = null;
int selRow = m_table.getSelectedRow();
if (selRow >= 0)
jifdData = m_tableData.getRowData(selRow);
m_tableData.sort();
if (jifdData != null && (selRow = m_tableData.findRow(jifdData)) >= 0)
selectRow(selRow, true);
}
}
}
@Override
public void mousePressed(MouseEvent ev)
{
doShowPopupMenu(ev);
}
@Override
public void mouseReleased(MouseEvent ev)
{
doShowPopupMenu(ev);
}
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);
}