5: DesignBrowser should indicate loading of database
Task-Url: https://github.com/eyck/txviewer/issues/issue/5
This commit is contained in:
parent
0007ab9322
commit
31ed3e4858
Binary file not shown.
After Width: | Height: | Size: 698 B |
|
@ -363,7 +363,7 @@ public class DesignBrowser {
|
||||||
if(db==database) return; // do nothing if old and new daabase is the same
|
if(db==database) return; // do nothing if old and new daabase is the same
|
||||||
((List<IWaveformDb>)input).get(0).removePropertyChangeListener(treeViewerPCL);
|
((List<IWaveformDb>)input).get(0).removePropertyChangeListener(treeViewerPCL);
|
||||||
}
|
}
|
||||||
treeViewer.setInput(database.isLoaded()?Arrays.asList(new IWaveformDb[]{database}):null);
|
treeViewer.setInput(Arrays.asList(database.isLoaded()?new IWaveformDb[]{database}:new IWaveformDb[]{new LoadingWaveformDb()}));
|
||||||
Object state=this.waveformViewerPart.retrieveDesignBrowerState();
|
Object state=this.waveformViewerPart.retrieveDesignBrowerState();
|
||||||
if(state!=null && state instanceof DBState)
|
if(state!=null && state instanceof DBState)
|
||||||
((DBState)state).apply();
|
((DBState)state).apply();
|
||||||
|
|
|
@ -0,0 +1,88 @@
|
||||||
|
package com.minres.scviewer.e4.application.parts;
|
||||||
|
|
||||||
|
import java.beans.PropertyChangeListener;
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.minres.scviewer.database.IHierNode;
|
||||||
|
import com.minres.scviewer.database.IWaveform;
|
||||||
|
import com.minres.scviewer.database.IWaveformDb;
|
||||||
|
import com.minres.scviewer.database.IWaveformEvent;
|
||||||
|
import com.minres.scviewer.database.RelationType;
|
||||||
|
|
||||||
|
public class LoadingWaveformDb implements IWaveformDb {
|
||||||
|
|
||||||
|
private final String label = "Database loading...";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addPropertyChangeListener(PropertyChangeListener l) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removePropertyChangeListener(PropertyChangeListener l) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getFullName() {
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setName(String name) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setParentName(String name) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<IHierNode> getChildNodes() {
|
||||||
|
return new ArrayList<IHierNode>();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compareTo(IHierNode o) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long getMaxTime() {
|
||||||
|
return new Long(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IWaveform<? extends IWaveformEvent> getStreamByName(String name) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<IWaveform<?>> getAllWaves() {
|
||||||
|
return new ArrayList<IWaveform<?>>();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<RelationType> getAllRelationTypes() {
|
||||||
|
return new ArrayList<RelationType>();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean load(File inp) throws Exception {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isLoaded() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clear() {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -297,22 +297,21 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
||||||
*/
|
*/
|
||||||
protected void loadDatabase(final Map<String, String> state) {
|
protected void loadDatabase(final Map<String, String> state) {
|
||||||
fileMonitor.removeFileChangeListener(this);
|
fileMonitor.removeFileChangeListener(this);
|
||||||
Job job = new Job(" My Job") {
|
Job job = new Job("Database Load Job") {
|
||||||
@Override
|
@Override
|
||||||
protected IStatus run(IProgressMonitor monitor) {
|
protected IStatus run(IProgressMonitor monitor) {
|
||||||
// convert to SubMonitor and set total number of work units
|
// convert to SubMonitor and set total number of work units
|
||||||
SubMonitor subMonitor = SubMonitor.convert(monitor, filesToLoad.size());
|
SubMonitor subMonitor = SubMonitor.convert(monitor, filesToLoad.size()+1);
|
||||||
subMonitor.setTaskName("Loading database");
|
|
||||||
try {
|
try {
|
||||||
|
subMonitor.worked(1);
|
||||||
for (File file : filesToLoad) {
|
for (File file : filesToLoad) {
|
||||||
// TimeUnit.SECONDS.sleep(2);
|
subMonitor.setTaskName("Loading "+file.getName());
|
||||||
database.load(file);
|
database.load(file);
|
||||||
database.addPropertyChangeListener(waveformPane);
|
database.addPropertyChangeListener(waveformPane);
|
||||||
subMonitor.worked(1);
|
subMonitor.worked(1);
|
||||||
if (monitor.isCanceled())
|
if (monitor.isCanceled())
|
||||||
return Status.CANCEL_STATUS;
|
return Status.CANCEL_STATUS;
|
||||||
}
|
}
|
||||||
// sleep a second
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
database = null;
|
database = null;
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
|
@ -20,6 +20,7 @@ import com.google.common.base.Predicate;
|
||||||
import com.google.common.collect.Collections2;
|
import com.google.common.collect.Collections2;
|
||||||
import com.minres.scviewer.database.IHierNode;
|
import com.minres.scviewer.database.IHierNode;
|
||||||
import com.minres.scviewer.database.IWaveform;
|
import com.minres.scviewer.database.IWaveform;
|
||||||
|
import com.minres.scviewer.database.IWaveformDb;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class TxDbContentProvider providing the tree content of a database for the respective viewer.
|
* The Class TxDbContentProvider providing the tree content of a database for the respective viewer.
|
||||||
|
@ -79,9 +80,11 @@ public class TxDbContentProvider implements ITreeContentProvider {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return res.toArray();
|
return res.toArray();
|
||||||
}else if(inputElement instanceof List<?>)
|
}else if(inputElement instanceof List<?>){
|
||||||
return ((List<?>)inputElement).toArray();
|
return ((List<?>)inputElement).toArray();
|
||||||
else
|
}else if(inputElement instanceof IWaveformDb){
|
||||||
|
return new Object[]{};
|
||||||
|
} else
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@ import com.minres.scviewer.database.ISignal;
|
||||||
import com.minres.scviewer.database.ISignalChangeMulti;
|
import com.minres.scviewer.database.ISignalChangeMulti;
|
||||||
import com.minres.scviewer.database.ITxStream;
|
import com.minres.scviewer.database.ITxStream;
|
||||||
import com.minres.scviewer.database.IWaveformDb;
|
import com.minres.scviewer.database.IWaveformDb;
|
||||||
|
import com.minres.scviewer.e4.application.parts.LoadingWaveformDb;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class TxDbLabelProvider providing the labels for the respective viewers.
|
* The Class TxDbLabelProvider providing the labels for the respective viewers.
|
||||||
|
@ -33,7 +34,7 @@ public class TxDbLabelProvider implements ILabelProvider {
|
||||||
private List<ILabelProviderListener> listeners = new ArrayList<ILabelProviderListener>();
|
private List<ILabelProviderListener> listeners = new ArrayList<ILabelProviderListener>();
|
||||||
|
|
||||||
/** The wave. */
|
/** The wave. */
|
||||||
private Image database, stream, signal, folder, wave;
|
private Image loadinDatabase, database, stream, signal, folder, wave;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -41,6 +42,7 @@ public class TxDbLabelProvider implements ILabelProvider {
|
||||||
*/
|
*/
|
||||||
public TxDbLabelProvider() {
|
public TxDbLabelProvider() {
|
||||||
super();
|
super();
|
||||||
|
loadinDatabase=ResourceManager.getPluginImage("com.minres.scviewer.e4.application", "icons/database_go.png");
|
||||||
database=ResourceManager.getPluginImage("com.minres.scviewer.e4.application", "icons/database.png");
|
database=ResourceManager.getPluginImage("com.minres.scviewer.e4.application", "icons/database.png");
|
||||||
stream=ResourceManager.getPluginImage("com.minres.scviewer.e4.application", "icons/stream.png");
|
stream=ResourceManager.getPluginImage("com.minres.scviewer.e4.application", "icons/stream.png");
|
||||||
folder=ResourceManager.getPluginImage("com.minres.scviewer.e4.application", "icons/folder.png");
|
folder=ResourceManager.getPluginImage("com.minres.scviewer.e4.application", "icons/folder.png");
|
||||||
|
@ -61,6 +63,7 @@ public class TxDbLabelProvider implements ILabelProvider {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
|
if(loadinDatabase!=null) database.dispose();
|
||||||
if(database!=null) database.dispose();
|
if(database!=null) database.dispose();
|
||||||
if(stream!=null) stream.dispose();
|
if(stream!=null) stream.dispose();
|
||||||
if(folder!=null) folder.dispose();
|
if(folder!=null) folder.dispose();
|
||||||
|
@ -90,6 +93,9 @@ public class TxDbLabelProvider implements ILabelProvider {
|
||||||
@Override
|
@Override
|
||||||
public Image getImage(Object element) {
|
public Image getImage(Object element) {
|
||||||
if(element instanceof IWaveformDb){
|
if(element instanceof IWaveformDb){
|
||||||
|
if(element instanceof LoadingWaveformDb)
|
||||||
|
return loadinDatabase;
|
||||||
|
else
|
||||||
return database;
|
return database;
|
||||||
}else if(element instanceof ITxStream){
|
}else if(element instanceof ITxStream){
|
||||||
return stream;
|
return stream;
|
||||||
|
|
Loading…
Reference in New Issue