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 CopyTableWorker copyTableWorker;
|
||||||
protected CopySelectionWorker copySelectionWorker;
|
protected CopySelectionWorker copySelectionWorker;
|
||||||
protected RefreshTableCompareWorker refreshTableCompareWorker;
|
protected RefreshTableCompareWorker refreshTableCompareWorker;
|
||||||
|
protected RefreshDataBoundsWorker refreshDataBoundsWorker;
|
||||||
|
|
||||||
protected boolean loaded = false;
|
protected boolean loaded = false;
|
||||||
|
|
||||||
|
@ -656,39 +657,17 @@ public abstract class Table extends JPanel implements Serializable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void refreshDataBounds(){
|
public void refreshDataBounds() {
|
||||||
try {
|
Window ancestorWindow = SwingUtilities.getWindowAncestor(this);
|
||||||
double maxBin = data[0].getBinValue();
|
|
||||||
double minBin = data[0].getBinValue();
|
|
||||||
|
|
||||||
double maxCompare = data[0].getCompareValue();
|
if(null != ancestorWindow) {
|
||||||
double minCompare = data[0].getCompareValue();
|
ancestorWindow.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||||
|
|
||||||
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) {
|
ECUEditorManager.getECUEditor().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||||
maxCompare = compareVal;
|
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||||
}
|
refreshDataBoundsWorker = new RefreshDataBoundsWorker(this);
|
||||||
if(compareVal < minCompare) {
|
refreshDataBoundsWorker.execute();
|
||||||
minCompare = compareVal;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.maxBin = maxBin;
|
|
||||||
this.minBin = minBin;
|
|
||||||
this.maxCompare = maxCompare;
|
|
||||||
this.minCompare = minCompare;
|
|
||||||
} catch (Exception ex) {
|
|
||||||
; // Do Nothing.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getMaxValue() {
|
public double getMaxValue() {
|
||||||
|
@ -1372,3 +1351,58 @@ class RefreshTableCompareWorker extends SwingWorker<Void, Void> {
|
||||||
ECUEditorManager.getECUEditor().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);
|
||||||
|
if(null != ancestorWindow) {
|
||||||
|
ancestorWindow.setCursor(null);
|
||||||
|
}
|
||||||
|
table.setCursor(null);
|
||||||
|
ECUEditorManager.getECUEditor().setCursor(null);
|
||||||
|
}
|
||||||
|
}
|
|
@ -60,6 +60,7 @@ public class Table3D extends Table {
|
||||||
|
|
||||||
CopyTable3DWorker copyTable3DWorker;
|
CopyTable3DWorker copyTable3DWorker;
|
||||||
CopySelection3DWorker copySelection3DWorker;
|
CopySelection3DWorker copySelection3DWorker;
|
||||||
|
RefreshDataBounds3DWorker refreshDataBounds3DWorker;
|
||||||
|
|
||||||
public Table3D() {
|
public Table3D() {
|
||||||
super();
|
super();
|
||||||
|
@ -129,41 +130,16 @@ public class Table3D extends Table {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void refreshDataBounds(){
|
public void refreshDataBounds(){
|
||||||
try {
|
Window ancestorWindow = SwingUtilities.getWindowAncestor(this);
|
||||||
double maxBin = data[0][0].getBinValue();
|
|
||||||
double minBin = data[0][0].getBinValue();
|
|
||||||
|
|
||||||
double maxCompare = data[0][0].getCompareValue();
|
if(null != ancestorWindow) {
|
||||||
double minCompare = data[0][0].getCompareValue();
|
ancestorWindow.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||||
|
}
|
||||||
|
|
||||||
for(DataCell[] column : data) {
|
ECUEditorManager.getECUEditor().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||||
for(DataCell cell : column) {
|
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||||
double cellVal = cell.getBinValue();
|
refreshDataBounds3DWorker = new RefreshDataBounds3DWorker(this);
|
||||||
double compareVal = cell.getCompareValue();
|
refreshDataBounds3DWorker.execute();
|
||||||
|
|
||||||
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.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1030,3 +1006,61 @@ class CopyTable3DWorker extends SwingWorker<Void, Void> {
|
||||||
ECUEditorManager.getECUEditor().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