import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
+import javax.swing.JPopupMenu;
import javax.swing.JTable;
import javax.swing.SwingUtilities;
import javax.swing.table.AbstractTableModel;
}
@Override
- protected boolean showPopupFor(int selectedRow)
+ protected boolean showPopupFor(int selectedRow, int x, int y)
{
FilterOption selectedFilterOpt = ((FilterOption) cmb_filterOption
.getSelectedItem());
String currentView = selectedFilterOpt.getView();
+
if (currentView == VIEWS_FILTER && data instanceof ThreeDBStructureChooserQuerySource)
{
- TDB_FTSData row=null;
- int i=1;
- for (FTSData el:discoveredStructuresSet) {
- if (i==selectedRow) {
- row = (TDB_FTSData) el;
- break;
- }
- i++;
- }
+ TDB_FTSData row=((ThreeDBStructureChooserQuerySource)data).getFTSDataFor(getResultTable(), selectedRow, discoveredStructuresSet);
String pageUrl = row.getModelViewUrl();
- JMenu popup = new JMenu("3D Beacons");
+ JPopupMenu popup = new JPopupMenu("3D Beacons");
JMenuItem viewUrl = new JMenuItem("View model web page");
viewUrl.addActionListener(
new ActionListener() {
);
popup.add(viewUrl);
SwingUtilities.invokeLater(new Runnable() {
- public void run() { popup.setVisible(true); }
+ public void run() { popup.show(getResultTable(), x, y); }
});
return true;
}
return upResponse;
}
+ public TDB_FTSData getFTSDataFor(JTable restable, int selectedRow,
+ Collection<FTSData> discoveredStructuresSet)
+ {
+ int idColumnIndex = restable.getColumn("Model id").getModelIndex();
+
+ String modelId = (String) restable.getValueAt(selectedRow, idColumnIndex);
+ for (FTSData row:discoveredStructuresSet)
+ {
+ if (row instanceof TDB_FTSData && ((TDB_FTSData)row).getModelId().equals(modelId))
+ {
+ return ((TDB_FTSData)row);
+ }
+ }
+ return null;
+ }
+
}
\ No newline at end of file
{
Point pt = e.getPoint();
int selectedRow = tbl_summary.rowAtPoint(pt);
- if (showPopupFor(selectedRow))
+ if (showPopupFor(selectedRow,pt.x,pt.y))
{
return true;
}
}
-protected abstract boolean showPopupFor(int selectedRow);
+protected abstract boolean showPopupFor(int selectedRow, int x, int y);
protected void closeAction(int preferredHeight)
{
// System.out.println(">>>>>>>>>> closing internal frame!!!");