fixes handling of incomplete databases (missing tx on relation)
This commit is contained in:
@@ -105,7 +105,7 @@ class TxRelation implements ITxRelation {
|
||||
TxStream fiber = loader.txStreams.get(fiberId);
|
||||
fiber.loadStream();
|
||||
tx = loader.getTransaction(txId);
|
||||
return loader.txStreams.get(fiberId);
|
||||
return fiber;
|
||||
} else
|
||||
return tx.getStream();
|
||||
}
|
||||
@@ -116,7 +116,7 @@ class TxRelation implements ITxRelation {
|
||||
loader.txStreams.get(fiberId).loadStream();
|
||||
tx = loader.getTransaction(txId);
|
||||
}
|
||||
return tx.getGenerator();
|
||||
return tx!=null?tx.getGenerator():null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -73,6 +73,7 @@ class TxStream extends AbstractTxStream {
|
||||
}
|
||||
|
||||
public void loadStream() {
|
||||
if(chunks.size()>0) return;
|
||||
try {
|
||||
List<byte[]> chunks = getChunks();
|
||||
int blockid = 0;
|
||||
|
||||
@@ -842,7 +842,7 @@ public class WaveformView implements IWaveformView {
|
||||
|
||||
public void setSelection(ISelection selection, boolean add, boolean addIfNeeded) {
|
||||
boolean selectionChanged = false;
|
||||
currentWaveformSelection.forEach(e -> e.selected = false);
|
||||
currentWaveformSelection.forEach(e -> {if(e!=null) e.selected = false;});
|
||||
if (selection instanceof IStructuredSelection) {
|
||||
IStructuredSelection sel = (IStructuredSelection) selection;
|
||||
if (sel.size() == 0) {
|
||||
@@ -862,10 +862,14 @@ public class WaveformView implements IWaveformView {
|
||||
if (trackEntry == null) {
|
||||
trackEntry = getEntryFor(txSel);
|
||||
if (trackEntry == null && addIfNeeded) {
|
||||
IWaveform stream = txSel.getStream();
|
||||
Optional<TrackEntry> te = streams.stream().filter(e -> stream.equals(e.waveform)).findFirst();
|
||||
if (te.isEmpty()) { // add stream only if really needed
|
||||
trackEntry = new TrackEntry(txSel.getStream(), styleProvider);
|
||||
streams.add(trackEntry);
|
||||
}
|
||||
}
|
||||
}
|
||||
currentTxSelection = txSel;
|
||||
currentWaveformSelection.clear();
|
||||
currentWaveformSelection.add(trackEntry);
|
||||
@@ -885,7 +889,7 @@ public class WaveformView implements IWaveformView {
|
||||
currentTxSelection = null;
|
||||
currentWaveformSelection.clear();
|
||||
}
|
||||
currentWaveformSelection.forEach(e -> e.selected = true);
|
||||
currentWaveformSelection.forEach(e -> {if(e!=null)e.selected = true;});
|
||||
if (selectionChanged) {
|
||||
currentWaveformSelection.forEach(e -> waveformCanvas.reveal(e.waveform));
|
||||
waveformCanvas.setSelected(currentTxSelection);
|
||||
@@ -1376,10 +1380,13 @@ public class WaveformView implements IWaveformView {
|
||||
}
|
||||
|
||||
public TrackEntry getEntryFor(ITx source) {
|
||||
Optional<TrackEntry> optGen = streams.stream().filter(e -> source.getGenerator().equals(e.waveform))
|
||||
if(source.getGenerator()==null) return null;
|
||||
Optional<TrackEntry> optGen = streams.stream()
|
||||
.filter(e -> source.getGenerator().equals(e.waveform))
|
||||
.findFirst();
|
||||
if (optGen.isPresent())
|
||||
return optGen.get();
|
||||
if(source.getStream()==null) return null;
|
||||
Optional<TrackEntry> optStr = streams.stream().filter(e -> source.getStream().equals(e.waveform)).findFirst();
|
||||
if (optStr.isPresent())
|
||||
return optStr.get();
|
||||
|
||||
Reference in New Issue
Block a user