mirror of https://github.com/rusefi/RomRaider.git
Resolves Fast Decrement Issues:
Helps to limit issue where decrementing cells several times really fast and then highlighting another cell causes the newly highlighted cell to be decremented. Note: Similar issues may exist. Long running tasks like refreshing the data bounds needs to happen on a worker thread. The cursor could be disabled while these tasks are running to avoid these sorts of issues. I prefer to show the wait cursor but allow clicks.
This commit is contained in:
parent
861f87bc56
commit
218f8ddd8f
|
@ -99,6 +99,7 @@ public abstract class Table extends JPanel implements Serializable {
|
|||
protected CopyTableWorker copyTableWorker;
|
||||
protected CopySelectionWorker copySelectionWorker;
|
||||
protected RefreshTableCompareWorker refreshTableCompareWorker;
|
||||
protected RefreshDataBoundsWorker refreshDataBoundsWorker;
|
||||
|
||||
protected boolean loaded = false;
|
||||
|
||||
|
@ -656,39 +657,17 @@ public abstract class Table extends JPanel implements Serializable {
|
|||
}
|
||||
}
|
||||
|
||||
public void refreshDataBounds(){
|
||||
try {
|
||||
double maxBin = data[0].getBinValue();
|
||||
double minBin = data[0].getBinValue();
|
||||
public void refreshDataBounds() {
|
||||
Window ancestorWindow = SwingUtilities.getWindowAncestor(this);
|
||||
|
||||
double maxCompare = data[0].getCompareValue();
|
||||
double minCompare = data[0].getCompareValue();
|
||||
|
||||
for(DataCell cell : data) {
|
||||
double cellVal = cell.getBinValue();
|
||||
double compareVal = cell.getCompareValue();
|
||||
|
||||
if(cellVal > maxBin) {
|
||||
maxBin = cellVal;
|
||||
}
|
||||
if(cellVal < minBin) {
|
||||
minBin = cellVal;
|
||||
}
|
||||
|
||||
if(compareVal > maxCompare) {
|
||||
maxCompare = compareVal;
|
||||
}
|
||||
if(compareVal < minCompare) {
|
||||
minCompare = compareVal;
|
||||
}
|
||||
}
|
||||
this.maxBin = maxBin;
|
||||
this.minBin = minBin;
|
||||
this.maxCompare = maxCompare;
|
||||
this.minCompare = minCompare;
|
||||
} catch (Exception ex) {
|
||||
; // Do Nothing.
|
||||
if(null != ancestorWindow) {
|
||||
ancestorWindow.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||
}
|
||||
|
||||
ECUEditorManager.getECUEditor().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||
refreshDataBoundsWorker = new RefreshDataBoundsWorker(this);
|
||||
refreshDataBoundsWorker.execute();
|
||||
}
|
||||
|
||||
public double getMaxValue() {
|
||||
|
@ -1362,6 +1341,61 @@ class RefreshTableCompareWorker extends SwingWorker<Void, Void> {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void done() {
|
||||
Window ancestorWindow = SwingUtilities.getWindowAncestor(table);
|
||||
if(null != ancestorWindow) {
|
||||
ancestorWindow.setCursor(null);
|
||||
}
|
||||
table.setCursor(null);
|
||||
ECUEditorManager.getECUEditor().setCursor(null);
|
||||
}
|
||||
}
|
||||
|
||||
class RefreshDataBoundsWorker extends SwingWorker<Void, Void> {
|
||||
Table table;
|
||||
|
||||
public RefreshDataBoundsWorker(Table table) {
|
||||
this.table = table;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void doInBackground() throws Exception {
|
||||
try {
|
||||
double maxBin = table.getData()[0].getBinValue();
|
||||
double minBin = table.getData()[0].getBinValue();
|
||||
|
||||
double maxCompare = table.getData()[0].getCompareValue();
|
||||
double minCompare = table.getData()[0].getCompareValue();
|
||||
|
||||
for(DataCell cell : table.getData()) {
|
||||
double cellVal = cell.getBinValue();
|
||||
double compareVal = cell.getCompareValue();
|
||||
|
||||
if(cellVal > maxBin) {
|
||||
maxBin = cellVal;
|
||||
}
|
||||
if(cellVal < minBin) {
|
||||
minBin = cellVal;
|
||||
}
|
||||
|
||||
if(compareVal > maxCompare) {
|
||||
maxCompare = compareVal;
|
||||
}
|
||||
if(compareVal < minCompare) {
|
||||
minCompare = compareVal;
|
||||
}
|
||||
}
|
||||
table.setMaxBin(maxBin);
|
||||
table.setMinBin(minBin);
|
||||
table.setMaxCompare(maxCompare);
|
||||
table.setMinCompare(minCompare);
|
||||
} catch (Exception ex) {
|
||||
; // Do Nothing.
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void done() {
|
||||
Window ancestorWindow = SwingUtilities.getWindowAncestor(table);
|
||||
|
|
|
@ -60,6 +60,7 @@ public class Table3D extends Table {
|
|||
|
||||
CopyTable3DWorker copyTable3DWorker;
|
||||
CopySelection3DWorker copySelection3DWorker;
|
||||
RefreshDataBounds3DWorker refreshDataBounds3DWorker;
|
||||
|
||||
public Table3D() {
|
||||
super();
|
||||
|
@ -129,41 +130,16 @@ public class Table3D extends Table {
|
|||
|
||||
@Override
|
||||
public void refreshDataBounds(){
|
||||
try {
|
||||
double maxBin = data[0][0].getBinValue();
|
||||
double minBin = data[0][0].getBinValue();
|
||||
Window ancestorWindow = SwingUtilities.getWindowAncestor(this);
|
||||
|
||||
double maxCompare = data[0][0].getCompareValue();
|
||||
double minCompare = data[0][0].getCompareValue();
|
||||
|
||||
for(DataCell[] column : data) {
|
||||
for(DataCell cell : column) {
|
||||
double cellVal = cell.getBinValue();
|
||||
double compareVal = cell.getCompareValue();
|
||||
|
||||
if(cellVal > maxBin) {
|
||||
maxBin = cellVal;
|
||||
}
|
||||
if(cellVal < minBin) {
|
||||
minBin = cellVal;
|
||||
}
|
||||
if(compareVal > maxCompare) {
|
||||
maxCompare = compareVal;
|
||||
}
|
||||
if(compareVal < minCompare) {
|
||||
minCompare = compareVal;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.maxBin = maxBin;
|
||||
this.minBin = minBin;
|
||||
this.maxCompare = maxCompare;
|
||||
this.minCompare = minCompare;
|
||||
xAxis.refreshDataBounds();
|
||||
yAxis.refreshDataBounds();
|
||||
} catch (Exception ex) {
|
||||
;// Do nothing.
|
||||
if(null != ancestorWindow) {
|
||||
ancestorWindow.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||
}
|
||||
|
||||
ECUEditorManager.getECUEditor().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||
refreshDataBounds3DWorker = new RefreshDataBounds3DWorker(this);
|
||||
refreshDataBounds3DWorker.execute();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1029,4 +1005,62 @@ class CopyTable3DWorker extends SwingWorker<Void, Void> {
|
|||
table.setCursor(null);
|
||||
ECUEditorManager.getECUEditor().setCursor(null);
|
||||
}
|
||||
}
|
||||
|
||||
class RefreshDataBounds3DWorker extends SwingWorker<Void, Void> {
|
||||
Table3D table;
|
||||
|
||||
public RefreshDataBounds3DWorker(Table3D table) {
|
||||
this.table = table;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void doInBackground() throws Exception {
|
||||
try {
|
||||
double maxBin = table.get3dData()[0][0].getBinValue();
|
||||
double minBin = table.get3dData()[0][0].getBinValue();
|
||||
|
||||
double maxCompare = table.get3dData()[0][0].getCompareValue();
|
||||
double minCompare = table.get3dData()[0][0].getCompareValue();
|
||||
|
||||
for(DataCell[] column : table.get3dData()) {
|
||||
for(DataCell cell : column) {
|
||||
double cellVal = cell.getBinValue();
|
||||
double compareVal = cell.getCompareValue();
|
||||
|
||||
if(cellVal > maxBin) {
|
||||
maxBin = cellVal;
|
||||
}
|
||||
if(cellVal < minBin) {
|
||||
minBin = cellVal;
|
||||
}
|
||||
if(compareVal > maxCompare) {
|
||||
maxCompare = compareVal;
|
||||
}
|
||||
if(compareVal < minCompare) {
|
||||
minCompare = compareVal;
|
||||
}
|
||||
}
|
||||
}
|
||||
table.setMaxBin(maxBin);
|
||||
table.setMinBin(minBin);
|
||||
table.setMaxCompare(maxCompare);
|
||||
table.setMinCompare(minCompare);
|
||||
table.getXAxis().refreshDataBounds();
|
||||
table.getYAxis().refreshDataBounds();
|
||||
} catch (Exception ex) {
|
||||
;// Do nothing.
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void done() {
|
||||
Window ancestorWindow = SwingUtilities.getWindowAncestor(table);
|
||||
if(null != ancestorWindow) {
|
||||
ancestorWindow.setCursor(null);
|
||||
}
|
||||
table.setCursor(null);
|
||||
ECUEditorManager.getECUEditor().setCursor(null);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue