Fixed two bugs. When the data in the table was sorted, the incorrect row in the model was being manipulated. Fixed the problem where the derived materials (based on component's mass value) were being placed in the materials list.
This commit is contained in:
parent
fb1262897d
commit
540097aed4
@ -112,20 +112,21 @@ public class ComponentPresetEditor extends JPanel implements PresetResultListene
|
|||||||
table.addMouseListener(new MouseAdapter() {
|
table.addMouseListener(new MouseAdapter() {
|
||||||
public void mouseClicked(MouseEvent e) {
|
public void mouseClicked(MouseEvent e) {
|
||||||
JTable target = (JTable) e.getSource();
|
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,
|
if (JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(ComponentPresetEditor.this,
|
||||||
"Do you want to delete this preset?",
|
"Do you want to delete this preset?",
|
||||||
"Confirm Delete", JOptionPane.YES_OPTION,
|
"Confirm Delete", JOptionPane.YES_OPTION,
|
||||||
JOptionPane.QUESTION_MESSAGE)) {
|
JOptionPane.QUESTION_MESSAGE)) {
|
||||||
model.removeRow(target.getSelectedRow());
|
model.removeRow(selectedRow);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (e.getClickCount() == 2) {
|
if (e.getClickCount() == 2) {
|
||||||
int row = target.getSelectedRow();
|
|
||||||
editContext.setEditingSelected(true);
|
editContext.setEditingSelected(true);
|
||||||
new PresetEditorDialog(ComponentPresetEditor.this,
|
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++) {
|
for (int x = 0; x < model.getRowCount(); x++) {
|
||||||
ComponentPreset preset = (ComponentPreset) model.getAssociatedObject(x);
|
ComponentPreset preset = (ComponentPreset) model.getAssociatedObject(x);
|
||||||
if (!materials.contains(preset.get(ComponentPreset.MATERIAL))) {
|
|
||||||
materials.add(preset.get(ComponentPreset.MATERIAL));
|
|
||||||
}
|
|
||||||
presets.add(preset);
|
presets.add(preset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user