]> git.gag.com Git - debian/openrocket/commitdiff
Fixed two bugs. When the data in the table was sorted, the incorrect row in the...
authorkruland2607 <kruland2607@180e2498-e6e9-4542-8430-84ac67f01cd8>
Tue, 5 Jun 2012 18:13:20 +0000 (18:13 +0000)
committerkruland2607 <kruland2607@180e2498-e6e9-4542-8430-84ac67f01cd8>
Tue, 5 Jun 2012 18:13:20 +0000 (18:13 +0000)
git-svn-id: https://openrocket.svn.sourceforge.net/svnroot/openrocket/trunk@758 180e2498-e6e9-4542-8430-84ac67f01cd8

core/src/net/sf/openrocket/gui/preset/ComponentPresetEditor.java

index 3c9f78784501b5803f3683f1f02a2587372736c3..c8d4a191de47ddd64acf7407cf86100ddf00899c 100644 (file)
@@ -112,20 +112,21 @@ public class ComponentPresetEditor extends JPanel implements PresetResultListene
         table.addMouseListener(new MouseAdapter() {
             public void mouseClicked(MouseEvent e) {
                 JTable target = (JTable) e.getSource();
-                if (target.getSelectedColumn() == 4) {
+                int selectedColumn = table.getColumnModel().getColumnIndexAtX( target.getSelectedColumn() );
+                int selectedRow = table.getRowSorter().convertRowIndexToModel( target.getSelectedRow() );
+                if (selectedColumn == 4) {
                     if (JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(ComponentPresetEditor.this,
                             "Do you want to delete this preset?",
                             "Confirm Delete", JOptionPane.YES_OPTION,
                             JOptionPane.QUESTION_MESSAGE)) {
-                        model.removeRow(target.getSelectedRow());
+                        model.removeRow(selectedRow);
                     }
                 }
                 else {
                     if (e.getClickCount() == 2) {
-                        int row = target.getSelectedRow();
                         editContext.setEditingSelected(true);
                         new PresetEditorDialog(ComponentPresetEditor.this,
-                                (ComponentPreset) model.getAssociatedObject(row), editContext.getMaterialsLoaded()).setVisible(true);
+                                (ComponentPreset) model.getAssociatedObject(selectedRow), editContext.getMaterialsLoaded()).setVisible(true);
                     }
                 }
             }
@@ -431,9 +432,6 @@ public class ComponentPresetEditor extends JPanel implements PresetResultListene
 
         for (int x = 0; x < model.getRowCount(); x++) {
             ComponentPreset preset = (ComponentPreset) model.getAssociatedObject(x);
-            if (!materials.contains(preset.get(ComponentPreset.MATERIAL))) {
-                materials.add(preset.get(ComponentPreset.MATERIAL));
-            }
             presets.add(preset);
         }