fixes database reopening problem due to locking
This commit is contained in:
@ -62,4 +62,13 @@ public interface IWaveformDb extends IHierNode {
|
||||
*/
|
||||
public boolean isLoaded();
|
||||
|
||||
/**
|
||||
* close an open database.
|
||||
*
|
||||
* @param inp the inp
|
||||
* @return true, if successful
|
||||
*/
|
||||
public void close();
|
||||
|
||||
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
@ -39,6 +40,7 @@ public class WaveformDb extends HierNode implements IWaveformDb, PropertyChangeL
|
||||
/** The loaders. */
|
||||
private static List<IWaveformDbLoaderFactory> loaderFactories = new LinkedList<>();
|
||||
|
||||
private List<IWaveformDbLoader> activeLoader = new ArrayList<>();
|
||||
/** The loaded. */
|
||||
private boolean loaded;
|
||||
|
||||
@ -136,6 +138,7 @@ public class WaveformDb extends HierNode implements IWaveformDb, PropertyChangeL
|
||||
loader.addPropertyChangeListener(this);
|
||||
try {
|
||||
loader.load(inp);
|
||||
activeLoader.add(loader);
|
||||
} catch (Exception e) {
|
||||
LOG.error("error loading file "+inp.getName(), e);
|
||||
retval=false;
|
||||
@ -158,6 +161,12 @@ public class WaveformDb extends HierNode implements IWaveformDb, PropertyChangeL
|
||||
return retval;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
for (IWaveformDbLoader entry : activeLoader) {
|
||||
entry.dispose();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Gets the file basename.
|
||||
*
|
||||
|
@ -124,7 +124,7 @@ public class RelationTypeToolControl extends PartListener implements ISelectionC
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(comboViewer!=null) comboViewer.getCombo().setEnabled(false);
|
||||
if(comboViewer!=null && !comboViewer.getCombo().isDisposed()) comboViewer.getCombo().setEnabled(false);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -35,8 +35,12 @@ public class AddSeparatorHandler {
|
||||
Object sel = ((WaveformViewer)part.getObject()).getSelection();
|
||||
if( sel instanceof IStructuredSelection) {
|
||||
if(((IStructuredSelection)sel).isEmpty()) return false;
|
||||
Object o= ((IStructuredSelection)sel).getFirstElement();
|
||||
return o instanceof TrackEntry;
|
||||
IStructuredSelection isel = (IStructuredSelection) sel;
|
||||
if(isel.size()==1)
|
||||
return isel.getFirstElement() instanceof TrackEntry;
|
||||
else if(isel.size()==2) {
|
||||
return isel.toArray()[1] instanceof TrackEntry;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -23,13 +23,13 @@ public class SelectAllHandler {
|
||||
@CanExecute
|
||||
public boolean canExecute(EPartService partService) {
|
||||
MPart part = partService.getActivePart();
|
||||
return part.getObject() instanceof WaveformViewer;
|
||||
return part!=null && part.getObject() instanceof WaveformViewer;
|
||||
}
|
||||
|
||||
@Execute
|
||||
public void execute(EPartService partService) {
|
||||
MPart part = partService.getActivePart();
|
||||
if(part.getObject() instanceof WaveformViewer)
|
||||
if(part!=null && part.getObject() instanceof WaveformViewer)
|
||||
((WaveformViewer) part.getObject()).selectAll();
|
||||
}
|
||||
|
||||
|
@ -29,6 +29,7 @@ import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.PreDestroy;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
@ -512,6 +513,12 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
||||
showTxDetails(false);
|
||||
}
|
||||
|
||||
@PreDestroy
|
||||
public void closeDatabase() {
|
||||
if(database.isLoaded())
|
||||
database.close();
|
||||
}
|
||||
|
||||
@Inject
|
||||
@Optional
|
||||
public void reactOnPrefsChange(@Preference(nodePath = PreferenceConstants.PREFERENCES_SCOPE) IEclipsePreferences prefs) {
|
||||
|
Reference in New Issue
Block a user