Skip to content

Commit

Permalink
Fixed mouse right-click selection reset
Browse files Browse the repository at this point in the history
  • Loading branch information
vimsh committed Dec 29, 2020
1 parent 8f9c252 commit 1ec4267
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 45 deletions.
Binary file modified MafScaling.jar
Binary file not shown.
24 changes: 13 additions & 11 deletions src/com/vgi/mafscaling/ACompCalc.java
Original file line number Diff line number Diff line change
Expand Up @@ -359,17 +359,19 @@ public void componentResized(ComponentEvent e) {

table.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent event) {
JTable eventTable =(JTable)event.getSource();
int colIdx = eventTable.getSelectedColumn();
int rowIdx = eventTable.getSelectedRow();
JTable[] tables = new JTable[] {origTable, newTable, corrTable, corrCountTable};
for (JTable t : tables) {
if (t == null)
continue;
Utils.setTableHeaderHighlightColor(t, new int[]{ colIdx }, new int[]{ rowIdx });
if (t.getColumnCount() - 1 >= colIdx && t.getRowCount() - 1 >= rowIdx) {
t.setColumnSelectionInterval(colIdx, colIdx);
t.setRowSelectionInterval(rowIdx, rowIdx);
if (event.getButton() == MouseEvent.BUTTON1) {
JTable eventTable =(JTable)event.getSource();
int colIdx = eventTable.getSelectedColumn();
int rowIdx = eventTable.getSelectedRow();
JTable[] tables = new JTable[] {origTable, newTable, corrTable, corrCountTable};
for (JTable t : tables) {
if (t == null)
continue;
Utils.setTableHeaderHighlightColor(t, new int[]{ colIdx }, new int[]{ rowIdx });
if (t.getColumnCount() - 1 >= colIdx && t.getRowCount() - 1 >= rowIdx) {
t.setColumnSelectionInterval(colIdx, colIdx);
t.setRowSelectionInterval(rowIdx, rowIdx);
}
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/com/vgi/mafscaling/LogStats.java
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,6 @@ private void createDataPanel(JPanel dataPanel) {
private static final long serialVersionUID = 6526901361175099297L;
public boolean isCellEditable(int row, int column) { return false; };
};
dataTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
dataTable.setColumnSelectionAllowed(true);
dataTable.setCellSelectionEnabled(true);
dataTable.setBorder(new LineBorder(new Color(0, 0, 0)));
Expand All @@ -307,7 +306,7 @@ private void createDataPanel(JPanel dataPanel) {

JScrollPane scrollPane = new JScrollPane(dataTable);
dataPanel.add(scrollPane, gbc_dataTable);
excelAdapter.addTable(dataTable, false, true, true, true, true, true, true, true, true);
excelAdapter.addTable(dataTable, false, false, true, false, true, true, true, true, true);
}

private JButton addButton(int row, int column, int rowspan, String name, String action) {
Expand Down
48 changes: 24 additions & 24 deletions src/com/vgi/mafscaling/ThrottleMaps.java
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,7 @@ protected void createDataTables(JPanel panel) {
}

protected JTable createDataTable(JPanel panel, String tableName, int colCount, int rowCount, int gridx, int gridy, boolean isOriginalTable, boolean extendRows, boolean extendCols) {
final JTable table = new JTable() {
private static final long serialVersionUID = 3218402382894083287L;
};
final JTable table = new JTable();
ExcelAdapter excelAdapter = new ExcelAdapter() {
protected void onPaste(JTable table, boolean extendRows, boolean extendCols) {
if (table.getSelectedRows() == null || table.getSelectedRows().length == 0 ||
Expand Down Expand Up @@ -226,28 +224,30 @@ public void componentResized(ComponentEvent e) {
if (tableName == newTableName) {
table.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent event) {
if (Utils.isTableEmpty(origTable) || Utils.isTableEmpty(newTable) || Utils.isTableEmpty(corrTable)) {
return;
}
JTable eventTable =(JTable)event.getSource();
int colIdx = eventTable.getSelectedColumn();
int rowIdx = eventTable.getSelectedRow();
ArrayList<Double> t3xAxisArray = new ArrayList<Double>();
for (int i = 1; i < corrTable.getColumnCount(); ++i)
t3xAxisArray.add(Double.valueOf(corrTable.getValueAt(0, i).toString()));

ArrayList<Double> t1yAxisArray = new ArrayList<Double>();
for (int i = 0; i < origTable.getRowCount(); ++i)
t1yAxisArray.add(Double.valueOf(origTable.getValueAt(i, 0).toString()));

ArrayList<Double> t3yAxisArray = new ArrayList<Double>();
for (int i = 1; i < corrTable.getRowCount(); ++i)
t3yAxisArray.add(Double.valueOf(corrTable.getValueAt(i, 0).toString()));
if (colIdx > 0 && rowIdx >= 0) {
try {
calculate(t3xAxisArray, t1yAxisArray, t3yAxisArray, rowIdx, colIdx, true);
if (event.getButton() == MouseEvent.BUTTON1) {
if (Utils.isTableEmpty(origTable) || Utils.isTableEmpty(newTable) || Utils.isTableEmpty(corrTable)) {
return;
}
JTable eventTable =(JTable)event.getSource();
int colIdx = eventTable.getSelectedColumn();
int rowIdx = eventTable.getSelectedRow();
ArrayList<Double> t3xAxisArray = new ArrayList<Double>();
for (int i = 1; i < corrTable.getColumnCount(); ++i)
t3xAxisArray.add(Double.valueOf(corrTable.getValueAt(0, i).toString()));

ArrayList<Double> t1yAxisArray = new ArrayList<Double>();
for (int i = 0; i < origTable.getRowCount(); ++i)
t1yAxisArray.add(Double.valueOf(origTable.getValueAt(i, 0).toString()));

ArrayList<Double> t3yAxisArray = new ArrayList<Double>();
for (int i = 1; i < corrTable.getRowCount(); ++i)
t3yAxisArray.add(Double.valueOf(corrTable.getValueAt(i, 0).toString()));
if (colIdx > 0 && rowIdx >= 0) {
try {
calculate(t3xAxisArray, t1yAxisArray, t3yAxisArray, rowIdx, colIdx, true);
}
catch (Exception e) { }
}
catch (Exception e) { }
}
}
});
Expand Down
18 changes: 10 additions & 8 deletions src/com/vgi/mafscaling/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -334,14 +334,16 @@ public static void initializeTable(JTable table, int columnWidth) {
public static void addTableHeaderHighlight(final JTable table) {
table.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent event) {
JTable eventTable =(JTable)event.getSource();
int colIdx = eventTable.getSelectedColumn();
int rowIdx = eventTable.getSelectedRow();
if (colIdx != -1 && rowIdx != -1) {
Utils.setTableHeaderHighlightColor(eventTable, new int[]{ colIdx }, new int[]{ rowIdx });
if (eventTable.getColumnCount() - 1 >= colIdx && eventTable.getRowCount() - 1 >= rowIdx) {
eventTable.setColumnSelectionInterval(colIdx, colIdx);
eventTable.setRowSelectionInterval(rowIdx, rowIdx);
if (event.getButton() == MouseEvent.BUTTON1) {
JTable eventTable =(JTable)event.getSource();
int colIdx = eventTable.getSelectedColumn();
int rowIdx = eventTable.getSelectedRow();
if (colIdx != -1 && rowIdx != -1) {
Utils.setTableHeaderHighlightColor(eventTable, new int[]{ colIdx }, new int[]{ rowIdx });
if (eventTable.getColumnCount() - 1 >= colIdx && eventTable.getRowCount() - 1 >= rowIdx) {
eventTable.setColumnSelectionInterval(colIdx, colIdx);
eventTable.setRowSelectionInterval(rowIdx, rowIdx);
}
}
}
}
Expand Down

0 comments on commit 1ec4267

Please sign in to comment.