Enable sorting in Simulation Table.
This commit is contained in:
parent
ec5dfbd4e6
commit
8221dd7e06
@ -117,9 +117,9 @@ public class SimulationPanel extends JPanel {
|
|||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
int[] selection = simulationTable.getSelectedRows();
|
int[] selection = simulationTable.getSelectedRows();
|
||||||
if (selection.length == 0)
|
if (selection.length == 0) {
|
||||||
return; // TODO: LOW: "None selected" dialog
|
return;
|
||||||
|
}
|
||||||
Simulation[] sims = new Simulation[selection.length];
|
Simulation[] sims = new Simulation[selection.length];
|
||||||
for (int i = 0; i < selection.length; i++) {
|
for (int i = 0; i < selection.length; i++) {
|
||||||
selection[i] = simulationTable.convertRowIndexToModel(selection[i]);
|
selection[i] = simulationTable.convertRowIndexToModel(selection[i]);
|
||||||
@ -138,9 +138,9 @@ public class SimulationPanel extends JPanel {
|
|||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
int[] selection = simulationTable.getSelectedRows();
|
int[] selection = simulationTable.getSelectedRows();
|
||||||
if (selection.length == 0)
|
if (selection.length == 0) {
|
||||||
return; // TODO: LOW: "None selected" dialog
|
return;
|
||||||
|
}
|
||||||
Simulation[] sims = new Simulation[selection.length];
|
Simulation[] sims = new Simulation[selection.length];
|
||||||
for (int i = 0; i < selection.length; i++) {
|
for (int i = 0; i < selection.length; i++) {
|
||||||
selection[i] = simulationTable.convertRowIndexToModel(selection[i]);
|
selection[i] = simulationTable.convertRowIndexToModel(selection[i]);
|
||||||
@ -164,9 +164,9 @@ public class SimulationPanel extends JPanel {
|
|||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
int[] selection = simulationTable.getSelectedRows();
|
int[] selection = simulationTable.getSelectedRows();
|
||||||
if (selection.length == 0)
|
if (selection.length == 0) {
|
||||||
return; // TODO: LOW: "None selected" dialog
|
return;
|
||||||
|
}
|
||||||
// Verify deletion
|
// Verify deletion
|
||||||
boolean verify = Application.getPreferences().getBoolean(Preferences.CONFIRM_DELETE_SIMULATION, true);
|
boolean verify = Application.getPreferences().getBoolean(Preferences.CONFIRM_DELETE_SIMULATION, true);
|
||||||
if (verify) {
|
if (verify) {
|
||||||
@ -218,9 +218,9 @@ public class SimulationPanel extends JPanel {
|
|||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
int selected = simulationTable.getSelectedRow();
|
int selected = simulationTable.getSelectedRow();
|
||||||
if (selected < 0)
|
if (selected < 0) {
|
||||||
return; // TODO: MEDIUM: "None selected" dialog
|
return;
|
||||||
|
}
|
||||||
selected = simulationTable.convertRowIndexToModel(selected);
|
selected = simulationTable.convertRowIndexToModel(selected);
|
||||||
simulationTable.clearSelection();
|
simulationTable.clearSelection();
|
||||||
simulationTable.addRowSelectionInterval(selected, selected);
|
simulationTable.addRowSelectionInterval(selected, selected);
|
||||||
@ -480,6 +480,7 @@ public class SimulationPanel extends JPanel {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
simulationTable.setAutoCreateRowSorter(true);
|
||||||
simulationTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
|
simulationTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
|
||||||
simulationTable.setDefaultRenderer(Object.class, new JLabelRenderer());
|
simulationTable.setDefaultRenderer(Object.class, new JLabelRenderer());
|
||||||
simulationTableModel.setColumnWidths(simulationTable.getColumnModel());
|
simulationTableModel.setColumnWidths(simulationTable.getColumnModel());
|
||||||
@ -490,17 +491,19 @@ public class SimulationPanel extends JPanel {
|
|||||||
@Override
|
@Override
|
||||||
public void mouseClicked(MouseEvent e) {
|
public void mouseClicked(MouseEvent e) {
|
||||||
if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 2) {
|
if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 2) {
|
||||||
int selected = simulationTable.getSelectedRow();
|
int selectedRow = simulationTable.getSelectedRow();
|
||||||
if (selected < 0)
|
if (selectedRow < 0) {
|
||||||
return;
|
return;
|
||||||
selected = simulationTable.convertRowIndexToModel(selected);
|
}
|
||||||
|
int selected = simulationTable.convertRowIndexToModel(selectedRow);
|
||||||
|
|
||||||
int column = simulationTable.columnAtPoint(e.getPoint());
|
int column = simulationTable.columnAtPoint(e.getPoint());
|
||||||
if (column == 0) {
|
if (column == 0) {
|
||||||
SimulationWarningDialog.showWarningDialog(SimulationPanel.this, document.getSimulations().get(selected));
|
SimulationWarningDialog.showWarningDialog(SimulationPanel.this, document.getSimulations().get(selected));
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
simulationTable.clearSelection();
|
simulationTable.clearSelection();
|
||||||
simulationTable.addRowSelectionInterval(selected, selected);
|
simulationTable.addRowSelectionInterval(selectedRow, selectedRow);
|
||||||
|
|
||||||
openDialog(document.getSimulations().get(selected));
|
openDialog(document.getSimulations().get(selected));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user