fixes locking issue preventing reload

This commit is contained in:
Eyck Jentzsch 2024-01-23 17:34:56 +01:00
parent db640808f2
commit 523c266e8d
4 changed files with 13 additions and 8 deletions

View File

@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: CBOR transaction database
Bundle-SymbolicName: com.minres.scviewer.database.ftr
Bundle-Version: 1.0.0.qualifier
Bundle-Version: 1.0.1.qualifier
Bundle-Vendor: MINRES Technologies GmbH
Bundle-RequiredExecutionEnvironment: JavaSE-11
Import-Package: org.osgi.framework;version="1.3.0",

View File

@ -178,7 +178,6 @@ public class FtrDbLoader implements IWaveformDbLoader {
*/
@Override
public void load(File file) throws InputFormatException {
dispose();
this.file=file;
try {
fis = new FileInputStream(file);

View File

@ -366,10 +366,14 @@ public class DesignBrowser {
}
}
@SuppressWarnings("unchecked")
public void setWaveformViewer(WaveformViewer waveformViewerPart) {
this.waveformViewerPart=waveformViewerPart;
IWaveformDb database = waveformViewerPart.getDatabase();
setWaveformDb(database);
}
@SuppressWarnings("unchecked")
public void setWaveformDb(IWaveformDb database) {
Object input = treeViewer.getInput();
if(input instanceof List<?>){
IWaveformDb db = ((List<IWaveformDb>)input).get(0);

View File

@ -176,7 +176,7 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
/** The factory. */
WaveformViewFactory factory = new WaveformViewFactory();
DesignBrowser browser = null;
DesignBrowser designBrowser = null;
TransactionDetails detailsView = null;
@ -206,8 +206,6 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
IEclipsePreferences store = null;
@Inject @Optional DesignBrowser designBrowser;
/** The database. */
private IWaveformDb database;
@ -295,7 +293,7 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
middleSash.setWeights(new int[] {75, 25});
ctx.set(Composite.class, left);
browser = ContextInjectionFactory.make(DesignBrowser.class, ctx);
designBrowser = ContextInjectionFactory.make(DesignBrowser.class, ctx);
ctx.set(Composite.class, right);
detailsView = ContextInjectionFactory.make(TransactionDetails.class, ctx);
@ -623,6 +621,8 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
loadState(partConfig);
if (state != null && !state.isEmpty())
restoreWaveformViewerState(state);
if(designBrowser!=null)
designBrowser.setWaveformDb(database);
fileChecker = null;
if (checkForUpdates)
fileChecker = fileMonitor.addFileChangeListener(WaveformViewer.this, filesToLoad, FILE_CHECK_INTERVAL);
@ -654,9 +654,11 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
Map<String, String> state = new HashMap<>();
saveWaveformViewerState(state);
waveformPane.getStreamList().clear();
if(database.isLoaded())
database.close();
database = dbFactory.getDatabase();
database.addPropertyChangeListener(evt -> {
if (IHierNode.WAVEFORMS.equals(evt.getPropertyName())) { //$NON-NLS-1$
if (IHierNode.WAVEFORMS.equals(evt.getPropertyName()) || IHierNode.LOADING_FINISHED.equals(evt.getPropertyName())) { //$NON-NLS-1$
myParent.getDisplay().syncExec(() -> waveformPane.setMaxTime(database.getMaxTime()));
}
});