add dynamic update of waveform list
This commit is contained in:
parent
15fb825548
commit
73b21cb80b
@ -11,9 +11,11 @@
|
||||
package com.minres.scviewer.database.sqlite;
|
||||
|
||||
import java.beans.IntrospectionException;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.beans.PropertyChangeSupport;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
@ -40,6 +42,11 @@ public class SQLiteDbLoader implements IWaveformDbLoader {
|
||||
|
||||
private ScvSimProps scvSimProps;
|
||||
|
||||
private static final byte[] x = "SQLite format 3".getBytes();
|
||||
|
||||
/** The pcs. */
|
||||
protected PropertyChangeSupport pcs = new PropertyChangeSupport(this);
|
||||
|
||||
@Override
|
||||
public Long getMaxTime() {
|
||||
SQLiteDatabaseSelectHandler<ScvTxEvent> handler = new SQLiteDatabaseSelectHandler<>(ScvTxEvent.class,
|
||||
@ -71,21 +78,28 @@ public class SQLiteDbLoader implements IWaveformDbLoader {
|
||||
return streams;
|
||||
}
|
||||
|
||||
private byte[] x = "SQLite format 3".getBytes();
|
||||
@Override
|
||||
public boolean canLoad(File inputFile) {
|
||||
if (!inputFile.isDirectory() && inputFile.exists()) {
|
||||
try(InputStream stream = new FileInputStream(inputFile)){
|
||||
byte[] buffer = new byte[x.length];
|
||||
int readCnt = stream.read(buffer, 0, x.length);
|
||||
if (readCnt == x.length) {
|
||||
for (int i = 0; i < x.length; i++)
|
||||
if (buffer[i] != x[i])
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean load(IWaveformDb db, File file) throws InputFormatException {
|
||||
public void load(IWaveformDb db, File file) throws InputFormatException {
|
||||
dispose();
|
||||
if(file.isDirectory() || !file.exists()) return false;
|
||||
try(FileInputStream fis = new FileInputStream(file)) {
|
||||
byte[] buffer = new byte[x.length];
|
||||
int read = fis.read(buffer, 0, x.length);
|
||||
if (read == x.length)
|
||||
for (int i = 0; i < x.length; i++)
|
||||
if (buffer[i] != x[i]) return false;
|
||||
} catch(IOException e) {
|
||||
return false;
|
||||
}
|
||||
database=new SQLiteDatabase(file.getAbsolutePath(), db);
|
||||
database.setData("TIMERESOLUTION", 1L);
|
||||
SQLiteDatabaseSelectHandler<ScvSimProps> handler = new SQLiteDatabaseSelectHandler<>(ScvSimProps.class, database);
|
||||
@ -94,12 +108,11 @@ public class SQLiteDbLoader implements IWaveformDbLoader {
|
||||
scvSimProps=simProps;
|
||||
database.setData("TIMERESOLUTION", scvSimProps.getTime_resolution());
|
||||
}
|
||||
return true;
|
||||
pcs.firePropertyChange(IWaveformDbLoader.LOADING_FINISHED, null, null);
|
||||
} catch (SecurityException | IllegalArgumentException | InstantiationException | IllegalAccessException
|
||||
| InvocationTargetException | SQLException | IntrospectionException e) {
|
||||
e.printStackTrace();
|
||||
throw new InputFormatException();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
@ -112,4 +125,24 @@ public class SQLiteDbLoader implements IWaveformDbLoader {
|
||||
return usedRelationsList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the property change listener.
|
||||
*
|
||||
* @param l the l
|
||||
*/
|
||||
@Override
|
||||
public void addPropertyChangeListener(PropertyChangeListener l) {
|
||||
pcs.addPropertyChangeListener(l);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the property change listener.
|
||||
*
|
||||
* @param l the l
|
||||
*/
|
||||
@Override
|
||||
public void removePropertyChangeListener(PropertyChangeListener l) {
|
||||
pcs.removePropertyChangeListener(l);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -11,6 +11,8 @@
|
||||
*******************************************************************************/
|
||||
package com.minres.scviewer.database.text;
|
||||
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.beans.PropertyChangeSupport;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
@ -89,6 +91,12 @@ public class TextDbLoader implements IWaveformDbLoader {
|
||||
/** The threads. */
|
||||
List<Thread> threads = new ArrayList<>();
|
||||
|
||||
/** The pcs. */
|
||||
protected PropertyChangeSupport pcs = new PropertyChangeSupport(this);
|
||||
|
||||
/** The Constant x. */
|
||||
static final byte[] x = "scv_tr_stream".getBytes();
|
||||
|
||||
/**
|
||||
* Gets the max time.
|
||||
*
|
||||
@ -109,8 +117,31 @@ public class TextDbLoader implements IWaveformDbLoader {
|
||||
return new ArrayList<>(txStreams.values());
|
||||
}
|
||||
|
||||
/** The Constant x. */
|
||||
static final byte[] x = "scv_tr_stream".getBytes();
|
||||
/**
|
||||
* Can load.
|
||||
*
|
||||
* @param inputFile the input file
|
||||
* @return true, if successful
|
||||
*/
|
||||
@Override
|
||||
public boolean canLoad(File inputFile) {
|
||||
if (!inputFile.isDirectory() && inputFile.exists()) {
|
||||
boolean gzipped = isGzipped(inputFile);
|
||||
try(InputStream stream = gzipped ? new GZIPInputStream(new FileInputStream(inputFile)) : new FileInputStream(inputFile)){
|
||||
byte[] buffer = new byte[x.length];
|
||||
int readCnt = stream.read(buffer, 0, x.length);
|
||||
if (readCnt == x.length) {
|
||||
for (int i = 0; i < x.length; i++)
|
||||
if (buffer[i] != x[i])
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load.
|
||||
@ -122,19 +153,9 @@ public class TextDbLoader implements IWaveformDbLoader {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public boolean load(IWaveformDb db, File file) throws InputFormatException {
|
||||
public void load(IWaveformDb db, File file) throws InputFormatException {
|
||||
dispose();
|
||||
if (file.isDirectory() || !file.exists())
|
||||
return false;
|
||||
TextDbParser parser = new TextDbParser(this);
|
||||
boolean gzipped = isGzipped(file);
|
||||
try {
|
||||
if (!isTxfile(gzipped ? new GZIPInputStream(new FileInputStream(file)) : new FileInputStream(file)))
|
||||
return false;
|
||||
} catch (Exception e) {
|
||||
throw new InputFormatException();
|
||||
}
|
||||
|
||||
if (file.length() < 75000000 * (gzipped ? 1 : 10)
|
||||
|| "memory".equals(System.getProperty("ScvBackingDB", "file")))
|
||||
mapDb = DBMaker.memoryDirectDB().allocateStartSize(512l * 1024l * 1024l)
|
||||
@ -145,13 +166,14 @@ public class TextDbLoader implements IWaveformDbLoader {
|
||||
mapDbFile = File.createTempFile("." + file.getName(), ".mapdb", null /* file.parentFile */);
|
||||
Files.delete(Paths.get(mapDbFile.getPath()));
|
||||
} catch (IOException e1) {
|
||||
return false;
|
||||
throw new InputFormatException();
|
||||
}
|
||||
mapDb = DBMaker.fileDB(mapDbFile).fileMmapEnable() // Always enable mmap
|
||||
.fileMmapEnableIfSupported().fileMmapPreclearDisable().allocateStartSize(512l * 1024l * 1024l)
|
||||
.allocateIncrement(128l * 1024l * 1024l).cleanerHackEnable().make();
|
||||
mapDbFile.deleteOnExit();
|
||||
}
|
||||
TextDbParser parser = new TextDbParser(this);
|
||||
try {
|
||||
parser.txSink = mapDb.treeMap("transactions", Serializer.LONG, Serializer.JAVA).createFromSink();
|
||||
parser.parseInput(gzipped ? new GZIPInputStream(new FileInputStream(file)) : new FileInputStream(file));
|
||||
@ -160,7 +182,7 @@ public class TextDbLoader implements IWaveformDbLoader {
|
||||
} catch (Exception e) {
|
||||
System.out.println("---->>> Exception " + e.toString() + " caught while loading database");
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
throw new InputFormatException();
|
||||
}
|
||||
for (TxStream stream : txStreams.values()) {
|
||||
Thread t = new Thread() {
|
||||
@ -175,7 +197,6 @@ public class TextDbLoader implements IWaveformDbLoader {
|
||||
threads.add(t);
|
||||
t.start();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -197,28 +218,6 @@ public class TextDbLoader implements IWaveformDbLoader {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is txfile.
|
||||
*
|
||||
* @param istream the istream
|
||||
* @return true, if is txfile
|
||||
*/
|
||||
private static boolean isTxfile(InputStream istream) {
|
||||
byte[] buffer = new byte[x.length];
|
||||
try {
|
||||
int readCnt = istream.read(buffer, 0, x.length);
|
||||
istream.close();
|
||||
if (readCnt == x.length) {
|
||||
for (int i = 0; i < x.length; i++)
|
||||
if (buffer[i] != x[i])
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is gzipped.
|
||||
*
|
||||
@ -416,7 +415,7 @@ public class TextDbLoader implements IWaveformDbLoader {
|
||||
if (matcher.matches()) {
|
||||
Long id = Long.parseLong(matcher.group(1));
|
||||
TxStream stream = new TxStream(loader, id, matcher.group(2), matcher.group(3));
|
||||
loader.txStreams.put(id, stream);
|
||||
add(id, stream);
|
||||
}
|
||||
} else if ("scv_tr_generator".equals(tokens[0])) {
|
||||
Matcher matcher = scv_tr_generator.matcher(curLine);
|
||||
@ -424,7 +423,7 @@ public class TextDbLoader implements IWaveformDbLoader {
|
||||
Long id = Long.parseLong(matcher.group(1));
|
||||
TxStream stream = loader.txStreams.get(Long.parseLong(matcher.group(3)));
|
||||
generator = new TxGenerator(loader, id, matcher.group(2), stream);
|
||||
loader.txGenerators.put(id, generator);
|
||||
add(id, generator);
|
||||
}
|
||||
} else if ("begin_attribute".equals(tokens[0])) {
|
||||
Matcher matcher = begin_attribute.matcher(curLine);
|
||||
@ -497,6 +496,16 @@ public class TextDbLoader implements IWaveformDbLoader {
|
||||
return 1000000000000000L;
|
||||
return 1L;
|
||||
}
|
||||
private void add(Long id, TxStream stream) {
|
||||
loader.txStreams.put(id, stream);
|
||||
loader.pcs.firePropertyChange(IWaveformDbLoader.STREAM_ADDED, null, stream);
|
||||
}
|
||||
|
||||
private void add(Long id, TxGenerator generator) {
|
||||
loader.txGenerators.put(id, generator);
|
||||
loader.pcs.firePropertyChange(IWaveformDbLoader.GENERATOR_ADDED, null, generator);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -513,4 +522,24 @@ public class TextDbLoader implements IWaveformDbLoader {
|
||||
return tx;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the property change listener.
|
||||
*
|
||||
* @param l the l
|
||||
*/
|
||||
@Override
|
||||
public void addPropertyChangeListener(PropertyChangeListener l) {
|
||||
pcs.addPropertyChangeListener(l);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the property change listener.
|
||||
*
|
||||
* @param l the l
|
||||
*/
|
||||
@Override
|
||||
public void removePropertyChangeListener(PropertyChangeListener l) {
|
||||
pcs.removePropertyChangeListener(l);
|
||||
}
|
||||
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -10,6 +10,8 @@
|
||||
*******************************************************************************/
|
||||
package com.minres.scviewer.database.vcd;
|
||||
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.beans.PropertyChangeSupport;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
@ -23,6 +25,7 @@ import java.util.TreeMap;
|
||||
import java.util.Vector;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.minres.scviewer.database.BitVector;
|
||||
import com.minres.scviewer.database.DoubleVal;
|
||||
import com.minres.scviewer.database.IEvent;
|
||||
@ -50,6 +53,9 @@ public class VCDDbLoader implements IWaveformDbLoader, IVCDDatabaseBuilder {
|
||||
/** The max time. */
|
||||
private long maxTime;
|
||||
|
||||
/** The pcs. */
|
||||
protected PropertyChangeSupport pcs = new PropertyChangeSupport(this);
|
||||
|
||||
private static boolean isGzipped(File f) {
|
||||
try (InputStream is = new FileInputStream(f)) {
|
||||
byte [] signature = new byte[2];
|
||||
@ -62,23 +68,44 @@ public class VCDDbLoader implements IWaveformDbLoader, IVCDDatabaseBuilder {
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.minres.scviewer.database.ITrDb#load(java.io.File)
|
||||
/**
|
||||
* Can load.
|
||||
*
|
||||
* @param inputFile the input file
|
||||
* @return true, if successful
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public boolean load(IWaveformDb db, File file) throws InputFormatException {
|
||||
dispose();
|
||||
if(file.isDirectory() || !file.exists()) return false;
|
||||
this.maxTime=0;
|
||||
boolean res = false;
|
||||
try {
|
||||
String name = file.getCanonicalFile().getName();
|
||||
public boolean canLoad(File inputFile) {
|
||||
if(!inputFile.isDirectory() || inputFile.exists()) {
|
||||
String name = inputFile.getName();
|
||||
if(!(name.endsWith(".vcd") ||
|
||||
name.endsWith(".vcdz") ||
|
||||
name.endsWith(".vcdgz") ||
|
||||
name.endsWith(".vcd.gz")) )
|
||||
return false;
|
||||
boolean gzipped = isGzipped(inputFile);
|
||||
try(InputStream stream = gzipped ? new GZIPInputStream(new FileInputStream(inputFile)) : new FileInputStream(inputFile)){
|
||||
byte[] buffer = new byte[8];
|
||||
if (stream.read(buffer, 0, buffer.length) == buffer.length) {
|
||||
return buffer[0]=='$';
|
||||
}
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.minres.scviewer.database.ITrDb#load(java.io.File)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void load(IWaveformDb db, File file) throws InputFormatException {
|
||||
dispose();
|
||||
this.maxTime=0;
|
||||
boolean res = false;
|
||||
try {
|
||||
signals = new Vector<>();
|
||||
moduleStack= new ArrayDeque<>();
|
||||
FileInputStream fis = new FileInputStream(file);
|
||||
@ -89,13 +116,13 @@ public class VCDDbLoader implements IWaveformDbLoader, IVCDDatabaseBuilder {
|
||||
throw new InputFormatException();
|
||||
}
|
||||
if(!res) throw new InputFormatException();
|
||||
// calculate max time of database
|
||||
// calculate max time of this database
|
||||
for(IWaveform waveform:signals) {
|
||||
NavigableMap<Long, IEvent[]> events =waveform.getEvents();
|
||||
if(events.size()>0)
|
||||
if(!events.isEmpty())
|
||||
maxTime= Math.max(maxTime, events.lastKey());
|
||||
}
|
||||
// extend signals to hav a last value set at max time
|
||||
// extend signals to have a last value set at max time
|
||||
for(IWaveform s:signals){
|
||||
if(s instanceof VCDSignal<?>) {
|
||||
TreeMap<Long,?> events = (TreeMap<Long, ?>) ((VCDSignal<?>)s).getEvents();
|
||||
@ -108,7 +135,7 @@ public class VCDDbLoader implements IWaveformDbLoader, IVCDDatabaseBuilder {
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
pcs.firePropertyChange(IWaveformDbLoader.LOADING_FINISHED, null, null);
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
@ -167,6 +194,7 @@ public class VCDDbLoader implements IWaveformDbLoader, IVCDDatabaseBuilder {
|
||||
signals.add( i<0 ? new VCDSignal<BitVector>(id, netName, width) :
|
||||
new VCDSignal<BitVector>((VCDSignal<BitVector>)signals.get(i), id, netName));
|
||||
}
|
||||
pcs.firePropertyChange(IWaveformDbLoader.SIGNAL_ADDED, null, Iterables.getLast(signals));
|
||||
return id;
|
||||
}
|
||||
|
||||
@ -209,4 +237,25 @@ public class VCDDbLoader implements IWaveformDbLoader, IVCDDatabaseBuilder {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the property change listener.
|
||||
*
|
||||
* @param l the l
|
||||
*/
|
||||
@Override
|
||||
public void addPropertyChangeListener(PropertyChangeListener l) {
|
||||
pcs.addPropertyChangeListener(l);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the property change listener.
|
||||
*
|
||||
* @param l the l
|
||||
*/
|
||||
@Override
|
||||
public void removePropertyChangeListener(PropertyChangeListener l) {
|
||||
pcs.removePropertyChangeListener(l);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -161,12 +161,9 @@ class VCDFileParser {
|
||||
else if (tokenizer.sval.equals("$enddefinitions")) {
|
||||
match("$end");
|
||||
return false;
|
||||
} else {
|
||||
// Ignore this defintion
|
||||
do {
|
||||
if (!nextToken()) return false;
|
||||
} while (!tokenizer.sval.equals("$end"));
|
||||
}
|
||||
} else do {
|
||||
if (!nextToken()) return false;
|
||||
} while (!tokenizer.sval.equals("$end"));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ package com.minres.scviewer.database;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.beans.PropertyChangeSupport;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -27,18 +28,10 @@ public class HierNode implements IHierNode {
|
||||
protected IHierNode parent = null;
|
||||
|
||||
/** The childs. */
|
||||
protected ArrayList<IHierNode> childs;
|
||||
protected List<IHierNode> childNodes = Collections.synchronizedList(new ArrayList<>());
|
||||
|
||||
/** The pcs. */
|
||||
protected PropertyChangeSupport pcs;
|
||||
|
||||
/**
|
||||
* Instantiates a new hier node.
|
||||
*/
|
||||
public HierNode() {
|
||||
childs = new ArrayList<>();
|
||||
pcs = new PropertyChangeSupport(this);
|
||||
}
|
||||
protected PropertyChangeSupport pcs = new PropertyChangeSupport(this);
|
||||
|
||||
/**
|
||||
* Instantiates a new hier node.
|
||||
@ -46,7 +39,6 @@ public class HierNode implements IHierNode {
|
||||
* @param name the name
|
||||
*/
|
||||
public HierNode(String name) {
|
||||
this();
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@ -57,11 +49,16 @@ public class HierNode implements IHierNode {
|
||||
* @param parent the parent
|
||||
*/
|
||||
public HierNode(String name, IHierNode parent) {
|
||||
this();
|
||||
this.name = name;
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new hier node.
|
||||
*/
|
||||
public HierNode() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the property change listener.
|
||||
*
|
||||
@ -115,6 +112,16 @@ public class HierNode implements IHierNode {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the parent.
|
||||
*
|
||||
* @return the parent
|
||||
*/
|
||||
@Override
|
||||
public IHierNode getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the parent.
|
||||
*
|
||||
@ -132,7 +139,7 @@ public class HierNode implements IHierNode {
|
||||
*/
|
||||
@Override
|
||||
public List<IHierNode> getChildNodes() {
|
||||
return childs;
|
||||
return Collections.unmodifiableList(childNodes);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -140,9 +147,10 @@ public class HierNode implements IHierNode {
|
||||
*
|
||||
* @param child the child
|
||||
*/
|
||||
@Override
|
||||
public void addChild(IHierNode child) {
|
||||
if (!childs.contains(child)) {
|
||||
childs.add(child);
|
||||
if (!childNodes.contains(child)) {
|
||||
childNodes.add(child);
|
||||
child.setParent(this);
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,15 @@ import java.util.List;
|
||||
*/
|
||||
public interface IHierNode extends Comparable<IHierNode> {
|
||||
|
||||
/** The Constant WAVEFORMS. */
|
||||
static final String WAVEFORMS = "Waveforms";
|
||||
|
||||
/** The Constant CHILDS. */
|
||||
static final String CHILDS = "Childs";
|
||||
|
||||
/** The Constant LOADING_FINISHED. */
|
||||
static final String LOADING_FINISHED = "LoadingFinished";
|
||||
|
||||
/**
|
||||
* Attach a non-null PropertyChangeListener to this object.
|
||||
*
|
||||
@ -61,6 +70,13 @@ public interface IHierNode extends Comparable<IHierNode> {
|
||||
*/
|
||||
public void setParent(IHierNode parent);
|
||||
|
||||
/**
|
||||
* Gets the parent.
|
||||
*
|
||||
* @return the parent
|
||||
*/
|
||||
public IHierNode getParent();
|
||||
|
||||
/**
|
||||
* Gets the child nodes.
|
||||
*
|
||||
@ -68,6 +84,12 @@ public interface IHierNode extends Comparable<IHierNode> {
|
||||
*/
|
||||
public List<IHierNode> getChildNodes();
|
||||
|
||||
/**
|
||||
* Adds the child.
|
||||
*
|
||||
* @param child the child
|
||||
*/
|
||||
public void addChild(IHierNode child);
|
||||
/**
|
||||
* Derive waveform.
|
||||
*
|
||||
|
@ -10,6 +10,7 @@
|
||||
*******************************************************************************/
|
||||
package com.minres.scviewer.database;
|
||||
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
|
||||
@ -17,38 +18,51 @@ import java.util.Collection;
|
||||
* The Interface IWaveformDbLoader.
|
||||
*/
|
||||
public interface IWaveformDbLoader {
|
||||
// static final String STREAM_ADDED = "StreamAdded";
|
||||
//
|
||||
// static final String GENERATOR_ADDED = "GeneratorAdded";
|
||||
//
|
||||
// static final String LOADING_FINISHED = "LoadingFinished";
|
||||
// /**
|
||||
// * Attach a non-null PropertyChangeListener to this object.
|
||||
// *
|
||||
// * @param l
|
||||
// * a non-null PropertyChangeListener instance
|
||||
// * @throws IllegalArgumentException
|
||||
// * if the parameter is null
|
||||
// */
|
||||
// public void addPropertyChangeListener(PropertyChangeListener l);
|
||||
//
|
||||
// /**
|
||||
// * Remove a PropertyChangeListener from this component.
|
||||
// *
|
||||
// * @param l
|
||||
// * a PropertyChangeListener instance
|
||||
// */
|
||||
// public void removePropertyChangeListener(PropertyChangeListener l) ;
|
||||
|
||||
/** The Constant STREAM_ADDED. */
|
||||
static final String STREAM_ADDED = "StreamAdded";
|
||||
|
||||
/** The Constant STREAM_ADDED. */
|
||||
static final String SIGNAL_ADDED = "SignalAdded";
|
||||
|
||||
/** The Constant GENERATOR_ADDED. */
|
||||
static final String GENERATOR_ADDED = "GeneratorAdded";
|
||||
|
||||
/** The Constant LOADING_FINISHED. */
|
||||
static final String LOADING_FINISHED = "LoadingFinished";
|
||||
/**
|
||||
* Attach a non-null PropertyChangeListener to this object.
|
||||
*
|
||||
* @param l
|
||||
* a non-null PropertyChangeListener instance
|
||||
* @throws IllegalArgumentException
|
||||
* if the parameter is null
|
||||
*/
|
||||
public void addPropertyChangeListener(PropertyChangeListener l);
|
||||
|
||||
/**
|
||||
* Remove a PropertyChangeListener from this component.
|
||||
*
|
||||
* @param l
|
||||
* a PropertyChangeListener instance
|
||||
*/
|
||||
public void removePropertyChangeListener(PropertyChangeListener l) ;
|
||||
|
||||
/**
|
||||
* Can load the given file.
|
||||
*
|
||||
* @param inputFile the input file
|
||||
* @return true, if successful
|
||||
*/
|
||||
public boolean canLoad(File inputFile);
|
||||
/**
|
||||
* Load.
|
||||
*
|
||||
* @param db the db
|
||||
* @param inp the inp
|
||||
* @return true, if successful
|
||||
* @param inputFile the input file
|
||||
* @throws InputFormatException the input format exception
|
||||
*/
|
||||
public boolean load(IWaveformDb db, File inp) throws InputFormatException;
|
||||
public void load(IWaveformDb db, File inputFile) throws InputFormatException;
|
||||
|
||||
/**
|
||||
* Gets the max time.
|
||||
|
@ -10,6 +10,8 @@
|
||||
*******************************************************************************/
|
||||
package com.minres.scviewer.database.internal;
|
||||
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@ -28,7 +30,7 @@ import com.minres.scviewer.database.RelationType;
|
||||
/**
|
||||
* The Class WaveformDb.
|
||||
*/
|
||||
public class WaveformDb extends HierNode implements IWaveformDb {
|
||||
public class WaveformDb extends HierNode implements IWaveformDb, PropertyChangeListener {
|
||||
|
||||
/** The loaders. */
|
||||
private static List<IWaveformDbLoader> loaders = new LinkedList<>();
|
||||
@ -122,8 +124,11 @@ public class WaveformDb extends HierNode implements IWaveformDb {
|
||||
@Override
|
||||
public boolean load(File inp) {
|
||||
for (IWaveformDbLoader loader : loaders) {
|
||||
try {
|
||||
if (loader.load(this, inp)) {
|
||||
if(loader.canLoad(inp)) {
|
||||
try {
|
||||
loader.addPropertyChangeListener(this);
|
||||
loader.load(this, inp);
|
||||
loader.removePropertyChangeListener(this);
|
||||
for (IWaveform w : loader.getAllWaves()) {
|
||||
waveforms.put(w.getFullName(), w);
|
||||
}
|
||||
@ -134,13 +139,12 @@ public class WaveformDb extends HierNode implements IWaveformDb {
|
||||
name = getFileBasename(inp.getName());
|
||||
buildHierarchyNodes();
|
||||
relationTypes.addAll(loader.getAllRelationTypes());
|
||||
pcs.firePropertyChange("WAVEFORMS", null, waveforms);
|
||||
pcs.firePropertyChange("CHILDS", null, childs);
|
||||
pcs.firePropertyChange(IHierNode.LOADING_FINISHED, null, null);
|
||||
loaded = true;
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@ -167,7 +171,7 @@ public class WaveformDb extends HierNode implements IWaveformDb {
|
||||
@Override
|
||||
public void clear() {
|
||||
waveforms.clear();
|
||||
childs.clear();
|
||||
childNodes.clear();
|
||||
loaded = false;
|
||||
}
|
||||
|
||||
@ -180,49 +184,60 @@ public class WaveformDb extends HierNode implements IWaveformDb {
|
||||
return loaded;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent evt) {
|
||||
if(IWaveformDbLoader.SIGNAL_ADDED.equals(evt.getPropertyName()) ||
|
||||
IWaveformDbLoader.STREAM_ADDED.equals(evt.getPropertyName())) {
|
||||
IWaveform waveform = (IWaveform) evt.getNewValue();
|
||||
putInHierarchy(waveform);
|
||||
pcs.firePropertyChange(IHierNode.WAVEFORMS, null, waveforms);
|
||||
pcs.firePropertyChange(IHierNode.CHILDS, null, childNodes);
|
||||
} else if(IWaveformDbLoader.GENERATOR_ADDED.equals(evt.getPropertyName())) {
|
||||
pcs.firePropertyChange(IHierNode.CHILDS, null, childNodes);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the hierarchy nodes.
|
||||
*/
|
||||
private void buildHierarchyNodes() {
|
||||
boolean needsSorting=false;
|
||||
for (IWaveform stream : getAllWaves()) {
|
||||
String[] hier = stream.getName().split("\\.");
|
||||
IHierNode node = this;
|
||||
for (int i = 0; i < hier.length - 1; ++i) {
|
||||
String name = hier[i];
|
||||
IHierNode childNode = null;
|
||||
for (IHierNode n : node.getChildNodes()) {
|
||||
if (n.getName().equals(name)) {
|
||||
childNode = n;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (childNode != null) {
|
||||
node = childNode;
|
||||
break;
|
||||
}
|
||||
HierNode newNode = new HierNode(name, node);
|
||||
node.getChildNodes().add(newNode);
|
||||
node = newNode;
|
||||
|
||||
if(stream.getParent()==null) {
|
||||
putInHierarchy(stream);
|
||||
needsSorting=true;
|
||||
}
|
||||
node.getChildNodes().add(stream);
|
||||
stream.setParent(node);
|
||||
stream.setName(hier[hier.length - 1]);
|
||||
}
|
||||
sortRecursive(this);
|
||||
if(needsSorting) {
|
||||
pcs.firePropertyChange(IHierNode.WAVEFORMS, null, waveforms);
|
||||
pcs.firePropertyChange(IHierNode.CHILDS, null, childNodes);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort recursive.
|
||||
*
|
||||
* @param node the node
|
||||
*/
|
||||
private void sortRecursive(IHierNode node) {
|
||||
Collections.sort(node.getChildNodes(), (IHierNode o1, IHierNode o2) -> o1.getName().compareTo(o2.getName()));
|
||||
for (IHierNode n : node.getChildNodes()) {
|
||||
if (!n.getChildNodes().isEmpty())
|
||||
sortRecursive(n);
|
||||
private synchronized void putInHierarchy(IWaveform waveform) {
|
||||
String[] hier = waveform.getName().split("\\.");
|
||||
IHierNode node = this;
|
||||
for (int i = 0; i < hier.length - 1; ++i) {
|
||||
String name = hier[i];
|
||||
IHierNode childNode = null;
|
||||
for (IHierNode n : node.getChildNodes()) {
|
||||
if (n.getName().equals(name)) {
|
||||
childNode = n;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (childNode != null) {
|
||||
node = childNode;
|
||||
break;
|
||||
}
|
||||
HierNode newNode = new HierNode(name, node);
|
||||
node.addChild(newNode);
|
||||
node = newNode;
|
||||
|
||||
}
|
||||
node.addChild(waveform);
|
||||
waveform.setParent(node);
|
||||
waveform.setName(hier[hier.length - 1]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -234,4 +249,5 @@ public class WaveformDb extends HierNode implements IWaveformDb {
|
||||
public List<RelationType> getAllRelationTypes() {
|
||||
return relationTypes;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,9 @@
|
||||
package com.minres.scviewer.e4.application;
|
||||
|
||||
public class Constants {
|
||||
|
||||
public static final String PLUGIN_ID = "com.minres.scviewer.e4.application"; //$NON-NLS-1$
|
||||
|
||||
private Constants() {}
|
||||
|
||||
}
|
@ -29,8 +29,8 @@ import com.minres.scviewer.e4.application.parts.DesignBrowser;
|
||||
|
||||
public class AddWaveformHandler {
|
||||
|
||||
public final static String PARAM_WHERE_ID="com.minres.scviewer.e4.application.command.addwaveform.where"; //$NON-NLS-1$
|
||||
public final static String PARAM_ALL_ID="com.minres.scviewer.e4.application.command.addwaveform.all"; //$NON-NLS-1$
|
||||
public static final String PARAM_WHERE_ID="com.minres.scviewer.e4.application.command.addwaveform.where"; //$NON-NLS-1$
|
||||
public static final String PARAM_ALL_ID="com.minres.scviewer.e4.application.command.addwaveform.all"; //$NON-NLS-1$
|
||||
|
||||
@Inject @Optional DesignBrowser designBrowser;
|
||||
|
||||
@ -42,8 +42,11 @@ public class AddWaveformHandler {
|
||||
if(designBrowser==null || designBrowser.getActiveWaveformViewerPart()==null) return false;
|
||||
boolean before = "before".equalsIgnoreCase(where); //$NON-NLS-1$
|
||||
IStructuredSelection waveformSelection = null;
|
||||
if(designBrowser.getActiveWaveformViewerPart()!=null)
|
||||
if(designBrowser.getActiveWaveformViewerPart()!=null) {
|
||||
if(!designBrowser.getActiveWaveformViewerPart().getDatabase().isLoaded())
|
||||
return false;
|
||||
waveformSelection = (IStructuredSelection)designBrowser.getActiveWaveformViewerPart().getSelection();
|
||||
}
|
||||
if("true".equalsIgnoreCase(all)) //$NON-NLS-1$
|
||||
return designBrowser.getFilteredChildren().length>0 &&
|
||||
(!before || (waveformSelection!=null && waveformSelection.size()>0));
|
||||
|
@ -36,6 +36,8 @@ import org.eclipse.wb.swt.ResourceManager;
|
||||
import org.eclipse.wb.swt.SWTResourceManager;
|
||||
import org.osgi.service.prefs.Preferences;
|
||||
|
||||
import com.minres.scviewer.e4.application.Constants;
|
||||
|
||||
/**
|
||||
* The Heap Status control, which shows the heap usage statistics in the window trim.
|
||||
* Part of the code is taken from the eclipse internal implementation
|
||||
@ -162,7 +164,7 @@ public class HeapStatus extends Composite {
|
||||
button = new Canvas(this, SWT.NONE);
|
||||
button.setToolTipText("Run Garbage Collection");
|
||||
|
||||
ImageDescriptor imageDesc = ResourceManager.getPluginImageDescriptor("com.minres.scviewer.e4.application", "icons/trash.png"); //$NON-NLS-1$
|
||||
ImageDescriptor imageDesc = ResourceManager.getPluginImageDescriptor(Constants.PLUGIN_ID, "icons/trash.png"); //$NON-NLS-1$
|
||||
Display display = getDisplay();
|
||||
gcImage = imageDesc.createImage();
|
||||
if (gcImage != null) {
|
||||
@ -228,6 +230,8 @@ public class HeapStatus extends Composite {
|
||||
arm(false);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -301,8 +305,8 @@ public class HeapStatus extends Composite {
|
||||
long max = Long.MAX_VALUE;
|
||||
try {
|
||||
// Must use reflect to allow compilation against JCL/Foundation
|
||||
Method maxMemMethod = Runtime.class.getMethod("maxMemory", new Class[0]); //$NON-NLS-1$
|
||||
Object o = maxMemMethod.invoke(Runtime.getRuntime(), new Object[0]);
|
||||
Method maxMemMethod = Runtime.class.getMethod("maxMemory"); //$NON-NLS-1$
|
||||
Object o = maxMemMethod.invoke(Runtime.getRuntime());
|
||||
if (o instanceof Long) {
|
||||
max = ((Long) o).longValue();
|
||||
}
|
||||
@ -441,14 +445,7 @@ public class HeapStatus extends Composite {
|
||||
@Override
|
||||
public void run() {
|
||||
busyGC();
|
||||
getDisplay().asyncExec(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!isDisposed()) {
|
||||
gcRunning(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
getDisplay().asyncExec(() -> { if (!isDisposed()) gcRunning(false); });
|
||||
}
|
||||
};
|
||||
t.start();
|
||||
@ -669,7 +666,7 @@ public class HeapStatus extends Composite {
|
||||
* @return the string
|
||||
*/
|
||||
private String convertToMegString(long numBytes) {
|
||||
return new Long(convertToMeg(numBytes)).toString()+"M";
|
||||
return Long.toString(convertToMeg(numBytes))+"M";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -26,8 +26,6 @@ import org.eclipse.osgi.util.NLS;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.custom.StyleRange;
|
||||
import org.eclipse.swt.custom.StyledText;
|
||||
import org.eclipse.swt.events.PaintEvent;
|
||||
import org.eclipse.swt.events.PaintListener;
|
||||
import org.eclipse.swt.graphics.Color;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
import org.eclipse.swt.graphics.Point;
|
||||
@ -36,13 +34,12 @@ import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Canvas;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.swt.widgets.Event;
|
||||
import org.eclipse.swt.widgets.Listener;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.wb.swt.ResourceManager;
|
||||
import org.eclipse.wb.swt.SWTResourceManager;
|
||||
import org.osgi.framework.Version;
|
||||
|
||||
import com.minres.scviewer.e4.application.Constants;
|
||||
import com.minres.scviewer.e4.application.Messages;
|
||||
|
||||
/**
|
||||
@ -73,34 +70,32 @@ public class AboutDialog extends Dialog {
|
||||
@Override
|
||||
protected Control createDialogArea(Composite parent) {
|
||||
Composite composite = new Composite(parent, SWT.NONE);
|
||||
GridData gd_composite = new GridData(SWT.LEFT, SWT.FILL, true, true);
|
||||
gd_composite.widthHint = 600;
|
||||
gd_composite.heightHint =300;
|
||||
composite.setLayoutData(gd_composite);
|
||||
GridData gdComposite = new GridData(SWT.LEFT, SWT.FILL, true, true);
|
||||
gdComposite.widthHint = 600;
|
||||
gdComposite.heightHint =300;
|
||||
composite.setLayoutData(gdComposite);
|
||||
composite.setLayout(new GridLayout(2, false));
|
||||
|
||||
final Color white=SWTResourceManager.getColor(SWT.COLOR_WHITE);
|
||||
final Image scviewerLogo=ResourceManager.getPluginImage("com.minres.scviewer.e4.application", "icons/SCViewer_logo.png"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
final Image minresLogo=ResourceManager.getPluginImage("com.minres.scviewer.e4.application", "icons/Minres_logo.png"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
final Image scviewerLogo=ResourceManager.getPluginImage(Constants.PLUGIN_ID, "icons/SCViewer_logo.png"); //$NON-NLS-1$
|
||||
final Image minresLogo=ResourceManager.getPluginImage(Constants.PLUGIN_ID, "icons/Minres_logo.png"); //$NON-NLS-1$
|
||||
|
||||
Canvas canvas = new Canvas(composite,SWT.NO_REDRAW_RESIZE);
|
||||
GridData gd_canvas = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
|
||||
gd_canvas.widthHint = 200;
|
||||
gd_canvas.heightHint =300;
|
||||
canvas.setLayoutData(gd_canvas);
|
||||
canvas.addPaintListener(new PaintListener() {
|
||||
public void paintControl(PaintEvent e) {
|
||||
GridData gdCanvas = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
|
||||
gdCanvas.widthHint = 200;
|
||||
gdCanvas.heightHint =300;
|
||||
canvas.setLayoutData(gdCanvas);
|
||||
canvas.addPaintListener(e -> {
|
||||
e.gc.setBackground(white);
|
||||
e.gc.fillRectangle(e.x, e.y, e.width, e.height);
|
||||
e.gc.drawImage(scviewerLogo,4,0);
|
||||
e.gc.drawImage(minresLogo,0,200);
|
||||
}
|
||||
});
|
||||
|
||||
StyledText styledText = new StyledText(composite, SWT.V_SCROLL | SWT.BORDER);
|
||||
styledText.setEditable(false);
|
||||
GridData gd_styledText = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
|
||||
styledText.setLayoutData(gd_styledText);
|
||||
GridData gdStyledText = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
|
||||
styledText.setLayoutData(gdStyledText);
|
||||
Version version = Platform.getProduct().getDefiningBundle().getVersion();
|
||||
String versionString = String.format("%d.%d.%d", version.getMajor(), version.getMinor(), version.getMicro());
|
||||
String productTitle = NLS.bind(Messages.AboutDialog_0, versionString);
|
||||
@ -129,22 +124,17 @@ public class AboutDialog extends Dialog {
|
||||
styleRange.length = matcher.end()-matcher.start();
|
||||
styledText.setStyleRange(styleRange);
|
||||
}
|
||||
styledText.addListener(SWT.MouseDown, new Listener() {
|
||||
@Override
|
||||
public void handleEvent(Event event) {
|
||||
// It is up to the application to determine when and how a link should be activated.
|
||||
// links are activated on mouse down when the control key is held down
|
||||
// if ((event.stateMask & SWT.MOD1) != 0) {
|
||||
try {
|
||||
@SuppressWarnings("deprecation")
|
||||
int offset = ((StyledText)event.widget).getOffsetAtLocation(new Point (event.x, event.y));
|
||||
StyleRange style = ((StyledText)event.widget).getStyleRangeAtOffset(offset);
|
||||
if (style != null && style.underline && style.underlineStyle == SWT.UNDERLINE_LINK) {
|
||||
Desktop.getDesktop().browse(new java.net.URI(style.data.toString()));
|
||||
}
|
||||
} catch (IOException | URISyntaxException | IllegalArgumentException e) {}
|
||||
// }
|
||||
}
|
||||
styledText.addListener(SWT.MouseDown, event -> {
|
||||
// It is up to the application to determine when and how a link should be activated.
|
||||
// links are activated on mouse down when the control key is held down
|
||||
try {
|
||||
@SuppressWarnings("deprecation")
|
||||
int offset = ((StyledText)event.widget).getOffsetAtLocation(new Point (event.x, event.y));
|
||||
StyleRange style = ((StyledText)event.widget).getStyleRangeAtOffset(offset);
|
||||
if (style != null && style.underline && style.underlineStyle == SWT.UNDERLINE_LINK) {
|
||||
Desktop.getDesktop().browse(new java.net.URI(style.data.toString()));
|
||||
}
|
||||
} catch (IOException | URISyntaxException | IllegalArgumentException e) {}
|
||||
});
|
||||
|
||||
styleRange.start = 0;
|
||||
@ -154,6 +144,7 @@ public class AboutDialog extends Dialog {
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
|
||||
*/
|
||||
@Override
|
||||
protected void createButtonsForButtonBar(Composite parent) {
|
||||
// create OK button
|
||||
createButton(parent, IDialogConstants.OK_ID, IDialogConstants.CLOSE_LABEL, true);
|
||||
|
@ -13,7 +13,6 @@ package com.minres.scviewer.e4.application.parts;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.regex.PatternSyntaxException;
|
||||
@ -65,6 +64,7 @@ import com.minres.scviewer.database.HierNode;
|
||||
import com.minres.scviewer.database.IHierNode;
|
||||
import com.minres.scviewer.database.IWaveform;
|
||||
import com.minres.scviewer.database.IWaveformDb;
|
||||
import com.minres.scviewer.e4.application.Constants;
|
||||
import com.minres.scviewer.e4.application.Messages;
|
||||
import com.minres.scviewer.e4.application.handlers.AddWaveformHandler;
|
||||
import com.minres.scviewer.e4.application.provider.TxDbContentProvider;
|
||||
@ -125,12 +125,17 @@ public class DesignBrowser {
|
||||
|
||||
/** The tree viewer pcl. */
|
||||
private PropertyChangeListener treeViewerPCL = evt -> {
|
||||
if("CHILDS".equals(evt.getPropertyName())){ //$NON-NLS-1$
|
||||
if(IHierNode.CHILDS.equals(evt.getPropertyName())){ //$NON-NLS-1$
|
||||
treeViewer.getTree().getDisplay().asyncExec(() -> treeViewer.refresh());
|
||||
} else if("WAVEFORMS".equals(evt.getPropertyName())) {
|
||||
} else if(IHierNode.WAVEFORMS.equals(evt.getPropertyName())) {
|
||||
treeViewer.getTree().getDisplay().asyncExec(() -> {
|
||||
IWaveformDb database = waveformViewerPart.getDatabase();
|
||||
treeViewer.setInput(Arrays.asList(database.isLoaded()?new IWaveformDb[]{database}:new IWaveformDb[]{new LoadingWaveformDb()}));
|
||||
treeViewer.setInput(new IWaveformDb[]{waveformViewerPart.getDatabase()});
|
||||
treeViewer.refresh();
|
||||
});
|
||||
} else if(IHierNode.LOADING_FINISHED.equals(evt.getPropertyName())) {
|
||||
treeViewer.getTree().getDisplay().asyncExec(() -> {
|
||||
treeViewer.update(waveformViewerPart.getDatabase(), null);
|
||||
DesignBrowser.this.updateButtons();
|
||||
});
|
||||
}
|
||||
};
|
||||
@ -195,7 +200,12 @@ public class DesignBrowser {
|
||||
|
||||
treeViewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
|
||||
treeViewer.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));
|
||||
treeViewer.setContentProvider(new TxDbContentProvider());
|
||||
treeViewer.setContentProvider(new TxDbContentProvider() {
|
||||
@Override
|
||||
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
|
||||
updateButtons();
|
||||
}
|
||||
});
|
||||
treeViewer.setLabelProvider(new TxDbLabelProvider());
|
||||
treeViewer.addFilter(treeAttributeFilter);
|
||||
treeViewer.setUseHashlookup(true);
|
||||
@ -236,7 +246,12 @@ public class DesignBrowser {
|
||||
tableAttributeFilter = new StreamTableFilter();
|
||||
|
||||
txTableViewer = new TableViewer(parent);
|
||||
txTableViewer.setContentProvider(new TxDbContentProvider(true));
|
||||
txTableViewer.setContentProvider(new TxDbContentProvider(true) {
|
||||
@Override
|
||||
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
|
||||
updateButtons();
|
||||
}
|
||||
});
|
||||
txTableViewer.setLabelProvider(new TxDbLabelProvider());
|
||||
txTableViewer.getTable().setLayoutData(new GridData(GridData.FILL_BOTH));
|
||||
txTableViewer.addFilter(tableAttributeFilter);
|
||||
@ -258,7 +273,7 @@ public class DesignBrowser {
|
||||
|
||||
appendItem = new ToolItem(toolBar, SWT.NONE);
|
||||
appendItem.setToolTipText(Messages.DesignBrowser_4);
|
||||
appendItem.setImage(ResourceManager.getPluginImage("com.minres.scviewer.e4.application", "icons/append_wave.png")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
appendItem.setImage(ResourceManager.getPluginImage(Constants.PLUGIN_ID, "icons/append_wave.png")); //$NON-NLS-1$
|
||||
appendItem.setEnabled(false);
|
||||
appendItem.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
@ -273,7 +288,7 @@ public class DesignBrowser {
|
||||
|
||||
insertItem = new ToolItem(toolBar, SWT.NONE);
|
||||
insertItem.setToolTipText(Messages.DesignBrowser_8);
|
||||
insertItem.setImage(ResourceManager.getPluginImage("com.minres.scviewer.e4.application", "icons/insert_wave.png")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
insertItem.setImage(ResourceManager.getPluginImage(Constants.PLUGIN_ID, "icons/insert_wave.png")); //$NON-NLS-1$
|
||||
insertItem.setEnabled(false);
|
||||
insertItem.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
@ -356,7 +371,7 @@ public class DesignBrowser {
|
||||
if(db==database) return; // do nothing if old and new database is the same
|
||||
((List<IWaveformDb>)input).get(0).removePropertyChangeListener(treeViewerPCL);
|
||||
}
|
||||
treeViewer.setInput(Arrays.asList(database.isLoaded()?new IWaveformDb[]{database}:new IWaveformDb[]{new LoadingWaveformDb()}));
|
||||
treeViewer.setInput(new IWaveformDb[]{database});
|
||||
Object state=this.waveformViewerPart.retrieveDesignBrowerState();
|
||||
if(state instanceof DBState)
|
||||
((DBState)state).apply();
|
||||
|
@ -5,7 +5,6 @@ import java.nio.file.FileSystems;
|
||||
import java.nio.file.PathMatcher;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -48,6 +47,8 @@ import org.eclipse.swt.widgets.ToolBar;
|
||||
import org.eclipse.swt.widgets.ToolItem;
|
||||
import org.eclipse.wb.swt.ResourceManager;
|
||||
|
||||
import com.minres.scviewer.e4.application.Constants;
|
||||
|
||||
public class FileBrowserDialog extends TrayDialog {
|
||||
|
||||
private Image folderImage;
|
||||
@ -80,9 +81,9 @@ public class FileBrowserDialog extends TrayDialog {
|
||||
|
||||
public FileBrowserDialog(Shell parentShell) {
|
||||
super(parentShell);
|
||||
folderImage=ResourceManager.getPluginImage("com.minres.scviewer.e4.application", "icons/folder.png"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
dbImage=ResourceManager.getPluginImage("com.minres.scviewer.e4.application", "icons/database.png"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
fileImage=ResourceManager.getPluginImage("com.minres.scviewer.e4.application", "icons/page_white.png"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
folderImage=ResourceManager.getPluginImage(Constants.PLUGIN_ID, "icons/folder.png"); //$NON-NLS-1$
|
||||
dbImage=ResourceManager.getPluginImage(Constants.PLUGIN_ID, "icons/database.png"); //$NON-NLS-1$
|
||||
fileImage=ResourceManager.getPluginImage(Constants.PLUGIN_ID, "icons/page_white.png"); //$NON-NLS-1$
|
||||
currentDirFile = new File(".");
|
||||
}
|
||||
|
||||
@ -148,7 +149,7 @@ public class FileBrowserDialog extends TrayDialog {
|
||||
toolBar.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));
|
||||
final ToolItem toolbarItemUp = new ToolItem(toolBar, SWT.PUSH);
|
||||
toolbarItemUp.setToolTipText("up one level");
|
||||
toolbarItemUp.setImage(ResourceManager.getPluginImage("com.minres.scviewer.e4.application", "icons/arrow_up.png")); //$NON-NLS-1$ //$NON-NLS-2$);
|
||||
toolbarItemUp.setImage(ResourceManager.getPluginImage(Constants.PLUGIN_ID, "icons/arrow_up.png")); //$NON-NLS-1$
|
||||
toolbarItemUp.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
@ -158,7 +159,7 @@ public class FileBrowserDialog extends TrayDialog {
|
||||
}
|
||||
}
|
||||
});
|
||||
tableViewer = new TableViewer(tableViewerParent, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.MULTI);
|
||||
tableViewer = new TableViewer(tableViewerParent, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
|
||||
tableViewer.getTable().setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL));
|
||||
tableViewer.addSelectionChangedListener(event -> {
|
||||
IStructuredSelection sel = event.getStructuredSelection();
|
||||
@ -187,8 +188,8 @@ public class FileBrowserDialog extends TrayDialog {
|
||||
public void mouseDown(MouseEvent e) { mouseUp(e); }
|
||||
@Override
|
||||
public void mouseUp(MouseEvent e) {
|
||||
TableItem element = (TableItem)tableViewer.getTable().getItem(new Point(e.x, e.y));
|
||||
final Table table = tableViewer.getTable();
|
||||
TableItem element = table.getItem(new Point(e.x, e.y));
|
||||
if (element == null )//&& (e.stateMask&SWT.MODIFIER_MASK)!=0)
|
||||
table.deselectAll();
|
||||
else {
|
||||
@ -231,7 +232,6 @@ public class FileBrowserDialog extends TrayDialog {
|
||||
colEmpty.setLabelProvider(new FileTableLabelProvider() {
|
||||
@Override public String getText(Object element) { return ""; }
|
||||
});
|
||||
//colEmpty.getColumn().setWidth(200);
|
||||
colEmpty.getColumn().setText("");
|
||||
|
||||
fileTableComparator = new FileTableComparator();
|
||||
@ -268,7 +268,7 @@ public class FileBrowserDialog extends TrayDialog {
|
||||
}
|
||||
|
||||
private SelectionAdapter getSelectionAdapter(final TableColumn column, final int index) {
|
||||
SelectionAdapter selectionAdapter = new SelectionAdapter() {
|
||||
return new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
fileTableComparator.setColumn(index);
|
||||
@ -278,7 +278,6 @@ public class FileBrowserDialog extends TrayDialog {
|
||||
tableViewer.refresh();
|
||||
}
|
||||
};
|
||||
return selectionAdapter;
|
||||
}
|
||||
|
||||
private void setDirSelection(File f) {
|
||||
@ -334,10 +333,11 @@ public class FileBrowserDialog extends TrayDialog {
|
||||
}
|
||||
|
||||
public boolean matches(Object f) {
|
||||
assert(f instanceof File);
|
||||
if(matchers.size()==0) return true;
|
||||
for (PathMatcher m : matchers) {
|
||||
if(m.matches(((File)f).toPath())) return true;
|
||||
if(f instanceof File) {
|
||||
if(matchers.isEmpty()) return true;
|
||||
for (PathMatcher m : matchers) {
|
||||
if(m.matches(((File)f).toPath())) return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -349,10 +349,8 @@ public class FileBrowserDialog extends TrayDialog {
|
||||
if(entries != null) {
|
||||
List<File> res = Arrays.stream(entries)
|
||||
.filter(file -> !(file.isFile()||file.getName().startsWith(".") ||globber.matches(file)))
|
||||
.sorted(new Comparator<File>(){
|
||||
public int compare(File f1, File f2){return f1.getName().compareTo(f2.getName());}
|
||||
})
|
||||
.collect(Collectors.toList()); ;
|
||||
.sorted( (f1, f2) -> f1.getName().compareTo(f2.getName()))
|
||||
.collect(Collectors.toList());
|
||||
return res.toArray();
|
||||
} else
|
||||
return new Object[0];
|
||||
@ -364,25 +362,20 @@ public class FileBrowserDialog extends TrayDialog {
|
||||
|
||||
public boolean hasChildren(Object arg0) {
|
||||
Object[] obj = getChildren(arg0);
|
||||
return obj == null ? false : obj.length > 0;
|
||||
return obj != null && obj.length > 0;
|
||||
}
|
||||
|
||||
public Object[] getElements(Object arg0) {
|
||||
return File.listRoots();
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
}
|
||||
|
||||
public void inputChanged(Viewer arg0, Object arg1, Object arg2) {
|
||||
}
|
||||
}
|
||||
|
||||
class FileTreeLabelProvider implements ILabelProvider {
|
||||
private List<ILabelProviderListener> listeners;
|
||||
|
||||
public FileTreeLabelProvider() {
|
||||
listeners = new ArrayList<ILabelProviderListener>();
|
||||
listeners = new ArrayList<>();
|
||||
}
|
||||
|
||||
public Image getImage(Object arg0) {
|
||||
@ -400,6 +393,7 @@ public class FileBrowserDialog extends TrayDialog {
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
// nothing to ispose
|
||||
}
|
||||
|
||||
public boolean isLabelProperty(Object arg0, String arg1) {
|
||||
@ -425,15 +419,12 @@ public class FileBrowserDialog extends TrayDialog {
|
||||
private int propertyIndex = 0;
|
||||
private boolean descending = false;
|
||||
|
||||
public FileTableComparator() {
|
||||
}
|
||||
|
||||
public int getDirection() {
|
||||
return descending ? SWT.DOWN : SWT.UP;
|
||||
}
|
||||
|
||||
public void setColumn(int column) {
|
||||
descending = column == this.propertyIndex?!descending : false;
|
||||
descending = column == this.propertyIndex && !descending;
|
||||
this.propertyIndex = column;
|
||||
}
|
||||
|
||||
|
@ -1,94 +0,0 @@
|
||||
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.IDerivedWaveform;
|
||||
import com.minres.scviewer.database.IHierNode;
|
||||
import com.minres.scviewer.database.IWaveform;
|
||||
import com.minres.scviewer.database.IWaveformDb;
|
||||
import com.minres.scviewer.database.RelationType;
|
||||
import com.minres.scviewer.e4.application.Messages;
|
||||
|
||||
public class LoadingWaveformDb implements IWaveformDb {
|
||||
|
||||
private final String label = Messages.LoadingWaveformDb_0;
|
||||
|
||||
@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 setParent(IHierNode 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 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) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLoaded() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDerivedWaveform deriveWaveform() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -85,9 +85,6 @@ public class TransactionDetails {
|
||||
/** The selection service. */
|
||||
@Inject ESelectionService selectionService;
|
||||
|
||||
/** The name filter. */
|
||||
private Text nameFilter;
|
||||
|
||||
/** The tree viewer. */
|
||||
private TreeViewer treeViewer;
|
||||
|
||||
@ -122,7 +119,7 @@ public class TransactionDetails {
|
||||
top = new Composite(parent, SWT.NONE);
|
||||
top.setLayout(new GridLayout(1, false));
|
||||
|
||||
nameFilter = new Text(top, SWT.BORDER);
|
||||
Text nameFilter = new Text(top, SWT.BORDER);
|
||||
nameFilter.setMessage(Messages.TransactionDetails_0);
|
||||
nameFilter.addModifyListener(e -> {
|
||||
attributeFilter.setSearchText(((Text) e.widget).getText());
|
||||
@ -204,11 +201,6 @@ public class TransactionDetails {
|
||||
treeViewer.refresh();
|
||||
}
|
||||
});
|
||||
// Pack the columns
|
||||
// for (int i = 0, n = table.getColumnCount(); i < n; i++) {
|
||||
// table.getColumn(i).pack();
|
||||
// }
|
||||
|
||||
// Turn on the header and the lines
|
||||
tree.setHeaderVisible(true);
|
||||
tree.setLinesVisible(true);
|
||||
|
@ -75,6 +75,7 @@ import org.eclipse.swt.widgets.Widget;
|
||||
|
||||
import com.minres.scviewer.database.DataType;
|
||||
import com.minres.scviewer.database.IEvent;
|
||||
import com.minres.scviewer.database.IHierNode;
|
||||
import com.minres.scviewer.database.IWaveform;
|
||||
import com.minres.scviewer.database.IWaveformDb;
|
||||
import com.minres.scviewer.database.IWaveformDbFactory;
|
||||
@ -251,7 +252,7 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
||||
showHover=hover;
|
||||
database = dbFactory.getDatabase();
|
||||
database.addPropertyChangeListener(evt -> {
|
||||
if ("WAVEFORMS".equals(evt.getPropertyName())) { //$NON-NLS-1$
|
||||
if (IHierNode.WAVEFORMS.equals(evt.getPropertyName())) { //$NON-NLS-1$
|
||||
myParent.getDisplay().syncExec(() -> waveformPane.setMaxTime(database.getMaxTime()));
|
||||
}
|
||||
});
|
||||
@ -536,6 +537,7 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
||||
|
||||
protected void loadDatabase(final Map<String, String> state, long delay) {
|
||||
fileMonitor.removeFileChangeListener(this);
|
||||
database.setName(filesToLoad.stream().map(File::getName).reduce(null, (prefix, element) -> prefix==null? element : prefix + ","+ element));
|
||||
Job job = new Job(Messages.WaveformViewer_15) {
|
||||
@Override
|
||||
protected IStatus run(IProgressMonitor monitor) {
|
||||
@ -683,9 +685,7 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
||||
//clear old streams before loading tab settings
|
||||
if(!waveformPane.getStreamList().isEmpty()) {
|
||||
waveformPane.getStreamList().clear();
|
||||
for (TrackEntry trackEntry : waveformPane.getStreamList()) {
|
||||
trackEntry.selected = false;
|
||||
}
|
||||
waveformPane.getStreamList().stream().forEach(e -> e.selected=false);
|
||||
}
|
||||
try (FileInputStream in = new FileInputStream(fileName)) {
|
||||
Properties props = new Properties();
|
||||
@ -916,15 +916,6 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
||||
return ext;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the model.
|
||||
*
|
||||
* @return the model
|
||||
*/
|
||||
public IWaveformDb getModel() {
|
||||
return database;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the database.
|
||||
*
|
||||
|
@ -10,13 +10,15 @@
|
||||
*******************************************************************************/
|
||||
package com.minres.scviewer.e4.application.preferences;
|
||||
|
||||
import com.minres.scviewer.e4.application.Constants;
|
||||
|
||||
/**
|
||||
* The Class PreferenceConstants for the preferences dialog & setting.
|
||||
*/
|
||||
public class PreferenceConstants {
|
||||
|
||||
/** The Constant PREFERENCES_SCOPE. */
|
||||
public static final String PREFERENCES_SCOPE="com.minres.scviewer.e4.application"; //$NON-NLS-1$
|
||||
public static final String PREFERENCES_SCOPE=Constants.PLUGIN_ID; //$NON-NLS-1$
|
||||
|
||||
/** The Constant DATABASE_RELOAD. */
|
||||
public static final String DATABASE_RELOAD="databaseReload"; //$NON-NLS-1$
|
||||
@ -81,5 +83,5 @@ public class PreferenceConstants {
|
||||
/** The Constant MARKER_TEXT_COLOR. */
|
||||
public static final String MARKER_TEXT_COLOR="MARKER_TEXT_COLOR"; //$NON-NLS-1$
|
||||
|
||||
|
||||
private PreferenceConstants() {}
|
||||
}
|
||||
|
@ -10,7 +10,8 @@
|
||||
*******************************************************************************/
|
||||
package com.minres.scviewer.e4.application.provider;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -35,7 +36,7 @@ public class TxDbContentProvider implements ITreeContentProvider {
|
||||
super();
|
||||
this.tableEntries = false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Instantiates a new tx db content provider.
|
||||
*
|
||||
@ -54,12 +55,15 @@ public class TxDbContentProvider implements ITreeContentProvider {
|
||||
if(tableEntries && inputElement instanceof IWaveformDb){
|
||||
return new Object[]{};
|
||||
}else if(inputElement instanceof IHierNode){
|
||||
Collection<IHierNode> res = ((IHierNode)inputElement).getChildNodes().stream().filter(n ->
|
||||
// make a copy as the laoder might continue to add waveforms
|
||||
ArrayList<IHierNode> nodes = new ArrayList<>(((IHierNode)inputElement).getChildNodes());
|
||||
return nodes.stream().filter(n ->
|
||||
tableEntries? n instanceof IWaveform : !n.getChildNodes().isEmpty()
|
||||
).collect(Collectors.toList());
|
||||
return res.toArray();
|
||||
).sorted(Comparator.comparing(IHierNode::getName)).collect(Collectors.toList()).toArray();
|
||||
}else if(inputElement instanceof List<?>){
|
||||
return ((List<?>)inputElement).toArray();
|
||||
}else if(inputElement instanceof Object[]){
|
||||
return (Object[]) inputElement;
|
||||
} else
|
||||
return new Object[]{};
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ import org.eclipse.wb.swt.ResourceManager;
|
||||
import com.minres.scviewer.database.IHierNode;
|
||||
import com.minres.scviewer.database.IWaveform;
|
||||
import com.minres.scviewer.database.IWaveformDb;
|
||||
import com.minres.scviewer.e4.application.parts.LoadingWaveformDb;
|
||||
import com.minres.scviewer.e4.application.Constants;
|
||||
|
||||
/**
|
||||
* The Class TxDbLabelProvider providing the labels for the respective viewers.
|
||||
@ -29,25 +29,44 @@ import com.minres.scviewer.e4.application.parts.LoadingWaveformDb;
|
||||
public class TxDbLabelProvider implements ILabelProvider {
|
||||
|
||||
/** The listeners. */
|
||||
private List<ILabelProviderListener> listeners = new ArrayList<ILabelProviderListener>();
|
||||
private List<ILabelProviderListener> listeners = new ArrayList<>();
|
||||
|
||||
/** The wave. */
|
||||
private Image loadinDatabase, database, stream, signal, folder, wave;
|
||||
private Image loadinDatabase;
|
||||
|
||||
/** The database. */
|
||||
private Image database;
|
||||
|
||||
/** The stream. */
|
||||
private Image stream;
|
||||
|
||||
/** The signal. */
|
||||
private Image signal;
|
||||
|
||||
/** The folder. */
|
||||
private Image folder;
|
||||
|
||||
/** The wave. */
|
||||
private Image wave;
|
||||
|
||||
/**
|
||||
* Instantiates a new tx db label provider.
|
||||
*/
|
||||
public TxDbLabelProvider() {
|
||||
super();
|
||||
loadinDatabase=ResourceManager.getPluginImage("com.minres.scviewer.e4.application", "icons/database_go.png"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
database=ResourceManager.getPluginImage("com.minres.scviewer.e4.application", "icons/database.png"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
stream=ResourceManager.getPluginImage("com.minres.scviewer.e4.application", "icons/stream.png"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
folder=ResourceManager.getPluginImage("com.minres.scviewer.e4.application", "icons/folder.png"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
signal=ResourceManager.getPluginImage("com.minres.scviewer.e4.application", "icons/signal.png"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
wave=ResourceManager.getPluginImage("com.minres.scviewer.e4.application", "icons/wave.png"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
loadinDatabase=ResourceManager.getPluginImage(Constants.PLUGIN_ID, "icons/database_go.png"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
database=ResourceManager.getPluginImage(Constants.PLUGIN_ID, "icons/database.png"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
stream=ResourceManager.getPluginImage(Constants.PLUGIN_ID, "icons/stream.png"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
folder=ResourceManager.getPluginImage(Constants.PLUGIN_ID, "icons/folder.png"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
signal=ResourceManager.getPluginImage(Constants.PLUGIN_ID, "icons/signal.png"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
wave=ResourceManager.getPluginImage(Constants.PLUGIN_ID, "icons/wave.png"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the listener.
|
||||
*
|
||||
* @param listener the listener
|
||||
*/
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener)
|
||||
*/
|
||||
@ -56,13 +75,24 @@ public class TxDbLabelProvider implements ILabelProvider {
|
||||
listeners.add(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispose.
|
||||
*/
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose()
|
||||
*/
|
||||
@Override
|
||||
public void dispose() {
|
||||
// no resources to dispose
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is label property.
|
||||
*
|
||||
* @param element the element
|
||||
* @param property the property
|
||||
* @return true, if is label property
|
||||
*/
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object, java.lang.String)
|
||||
*/
|
||||
@ -71,6 +101,11 @@ public class TxDbLabelProvider implements ILabelProvider {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the listener.
|
||||
*
|
||||
* @param listener the listener
|
||||
*/
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener)
|
||||
*/
|
||||
@ -79,16 +114,19 @@ public class TxDbLabelProvider implements ILabelProvider {
|
||||
listeners.remove(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the image.
|
||||
*
|
||||
* @param element the element
|
||||
* @return the image
|
||||
*/
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public Image getImage(Object element) {
|
||||
if(element instanceof IWaveformDb){
|
||||
if(element instanceof LoadingWaveformDb)
|
||||
return loadinDatabase;
|
||||
else
|
||||
return database;
|
||||
return ((IWaveformDb)element).isLoaded()?database:loadinDatabase;
|
||||
}else if(element instanceof IWaveform){
|
||||
switch(((IWaveform) element).getType()) {
|
||||
case TRANSACTION:
|
||||
@ -110,6 +148,12 @@ public class TxDbLabelProvider implements ILabelProvider {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the text.
|
||||
*
|
||||
* @param element the element
|
||||
* @return the text
|
||||
*/
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
|
||||
*/
|
||||
|
@ -13,8 +13,6 @@ package org.eclipse.wb.swt;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.HashMap;
|
||||
@ -61,7 +59,7 @@ public class ResourceManager extends SWTResourceManager {
|
||||
/**
|
||||
* The map where we store our images.
|
||||
*/
|
||||
private static Map<ImageDescriptor, Image> m_descriptorImageMap = new HashMap<ImageDescriptor, Image>();
|
||||
private static Map<ImageDescriptor, Image> descriptorImageMap = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Returns an {@link ImageDescriptor} stored in the file at the specified path
|
||||
@ -97,22 +95,16 @@ public class ResourceManager extends SWTResourceManager {
|
||||
* @return the {@link Image} based on the specified {@link ImageDescriptor}.
|
||||
*/
|
||||
public static Image getImage(ImageDescriptor descriptor) {
|
||||
if (descriptor == null) {
|
||||
if (descriptor == null)
|
||||
return null;
|
||||
}
|
||||
Image image = m_descriptorImageMap.get(descriptor);
|
||||
if (image == null) {
|
||||
image = descriptor.createImage();
|
||||
m_descriptorImageMap.put(descriptor, image);
|
||||
}
|
||||
return image;
|
||||
return descriptorImageMap.computeIfAbsent(descriptor, ImageDescriptor::createImage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps images to decorated images.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private static Map<Image, Map<Image, Image>>[] m_decoratedImageMap = new Map[LAST_CORNER_KEY];
|
||||
private static Map<Image, Map<Image, Image>>[] decoratedImageMap = new Map[LAST_CORNER_KEY];
|
||||
|
||||
/**
|
||||
* Returns an {@link Image} composed of a base image decorated by another image.
|
||||
@ -140,17 +132,12 @@ public class ResourceManager extends SWTResourceManager {
|
||||
if (corner <= 0 || corner >= LAST_CORNER_KEY) {
|
||||
throw new IllegalArgumentException(Messages.ResourceManager_0);
|
||||
}
|
||||
Map<Image, Map<Image, Image>> cornerDecoratedImageMap = m_decoratedImageMap[corner];
|
||||
Map<Image, Map<Image, Image>> cornerDecoratedImageMap = decoratedImageMap[corner];
|
||||
if (cornerDecoratedImageMap == null) {
|
||||
cornerDecoratedImageMap = new HashMap<Image, Map<Image, Image>>();
|
||||
m_decoratedImageMap[corner] = cornerDecoratedImageMap;
|
||||
cornerDecoratedImageMap = new HashMap<>();
|
||||
decoratedImageMap[corner] = cornerDecoratedImageMap;
|
||||
}
|
||||
Map<Image, Image> decoratedMap = cornerDecoratedImageMap.get(baseImage);
|
||||
if (decoratedMap == null) {
|
||||
decoratedMap = new HashMap<Image, Image>();
|
||||
cornerDecoratedImageMap.put(baseImage, decoratedMap);
|
||||
}
|
||||
//
|
||||
Map<Image, Image> decoratedMap = cornerDecoratedImageMap.computeIfAbsent(baseImage, k -> new HashMap<Image, Image>());
|
||||
Image result = decoratedMap.get(decorator);
|
||||
if (result == null) {
|
||||
final Rectangle bib = baseImage.getBounds();
|
||||
@ -181,7 +168,7 @@ public class ResourceManager extends SWTResourceManager {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
private static ImageDataProvider getUnzoomedImageDataProvider(ImageData imageData) {
|
||||
return zoom -> zoom == 100 ? imageData : null;
|
||||
}
|
||||
@ -193,15 +180,13 @@ public class ResourceManager extends SWTResourceManager {
|
||||
public static void disposeImages() {
|
||||
SWTResourceManager.disposeImages();
|
||||
// dispose ImageDescriptor images
|
||||
{
|
||||
for (Iterator<Image> I = m_descriptorImageMap.values().iterator(); I.hasNext();) {
|
||||
I.next().dispose();
|
||||
}
|
||||
m_descriptorImageMap.clear();
|
||||
for (Iterator<Image> I = descriptorImageMap.values().iterator(); I.hasNext();) {
|
||||
I.next().dispose();
|
||||
}
|
||||
descriptorImageMap.clear();
|
||||
// dispose decorated images
|
||||
for (int i = 0; i < m_decoratedImageMap.length; i++) {
|
||||
Map<Image, Map<Image, Image>> cornerDecoratedImageMap = m_decoratedImageMap[i];
|
||||
for (int i = 0; i < decoratedImageMap.length; i++) {
|
||||
Map<Image, Map<Image, Image>> cornerDecoratedImageMap = decoratedImageMap[i];
|
||||
if (cornerDecoratedImageMap != null) {
|
||||
for (Map<Image, Image> decoratedMap : cornerDecoratedImageMap.values()) {
|
||||
for (Image image : decoratedMap.values()) {
|
||||
@ -213,12 +198,10 @@ public class ResourceManager extends SWTResourceManager {
|
||||
}
|
||||
}
|
||||
// dispose plugin images
|
||||
{
|
||||
for (Iterator<Image> I = m_URLImageMap.values().iterator(); I.hasNext();) {
|
||||
I.next().dispose();
|
||||
}
|
||||
m_URLImageMap.clear();
|
||||
for (Iterator<Image> I = urlImageMap.values().iterator(); I.hasNext();) {
|
||||
I.next().dispose();
|
||||
}
|
||||
urlImageMap.clear();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
@ -229,7 +212,7 @@ public class ResourceManager extends SWTResourceManager {
|
||||
/**
|
||||
* Maps URL to images.
|
||||
*/
|
||||
private static Map<String, Image> m_URLImageMap = new HashMap<String, Image>();
|
||||
private static Map<String, Image> urlImageMap = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Provider for plugin resources, used by WindowBuilder at design time.
|
||||
@ -242,29 +225,7 @@ public class ResourceManager extends SWTResourceManager {
|
||||
* Instance of {@link PluginResourceProvider}, used by WindowBuilder at design
|
||||
* time.
|
||||
*/
|
||||
private static PluginResourceProvider m_designTimePluginResourceProvider = null;
|
||||
|
||||
/**
|
||||
* Returns an {@link Image} based on a plugin and file path.
|
||||
*
|
||||
* @param plugin the plugin {@link Object} containing the image
|
||||
* @param name the path to the image within the plugin
|
||||
* @return the {@link Image} stored in the file at the specified path
|
||||
*
|
||||
* @deprecated Use {@link #getPluginImage(String, String)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public static Image getPluginImage(Object plugin, String name) {
|
||||
try {
|
||||
URL url = getPluginImageURL(plugin, name);
|
||||
if (url != null) {
|
||||
return getPluginImageFromUrl(url);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
// Ignore any exceptions
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private static PluginResourceProvider designTimePluginResourceProvider = null;
|
||||
|
||||
/**
|
||||
* Returns an {@link Image} based on a {@link Bundle} and resource entry path.
|
||||
@ -279,7 +240,7 @@ public class ResourceManager extends SWTResourceManager {
|
||||
if (url != null) {
|
||||
return getPluginImageFromUrl(url);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
} catch (Exception e) {
|
||||
// Ignore any exceptions
|
||||
}
|
||||
return null;
|
||||
@ -290,47 +251,19 @@ public class ResourceManager extends SWTResourceManager {
|
||||
*/
|
||||
private static Image getPluginImageFromUrl(URL url) {
|
||||
try {
|
||||
try {
|
||||
String key = url.toExternalForm();
|
||||
Image image = m_URLImageMap.get(key);
|
||||
if (image == null) {
|
||||
InputStream stream = url.openStream();
|
||||
try {
|
||||
image = getImage(stream);
|
||||
m_URLImageMap.put(key, image);
|
||||
} finally {
|
||||
stream.close();
|
||||
}
|
||||
String key = url.toExternalForm();
|
||||
Image image = urlImageMap.get(key);
|
||||
if (image == null) {
|
||||
InputStream stream = url.openStream();
|
||||
try {
|
||||
image = getImage(stream);
|
||||
urlImageMap.put(key, image);
|
||||
} finally {
|
||||
stream.close();
|
||||
}
|
||||
return image;
|
||||
} catch (Throwable e) {
|
||||
// Ignore any exceptions
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
// Ignore any exceptions
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an {@link ImageDescriptor} based on a plugin and file path.
|
||||
*
|
||||
* @param plugin the plugin {@link Object} containing the image.
|
||||
* @param name the path to th eimage within the plugin.
|
||||
* @return the {@link ImageDescriptor} stored in the file at the specified path.
|
||||
*
|
||||
* @deprecated Use {@link #getPluginImageDescriptor(String, String)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public static ImageDescriptor getPluginImageDescriptor(Object plugin, String name) {
|
||||
try {
|
||||
try {
|
||||
URL url = getPluginImageURL(plugin, name);
|
||||
return ImageDescriptor.createFromURL(url);
|
||||
} catch (Throwable e) {
|
||||
// Ignore any exceptions
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
return image;
|
||||
} catch (Exception e) {
|
||||
// Ignore any exceptions
|
||||
}
|
||||
return null;
|
||||
@ -351,7 +284,7 @@ public class ResourceManager extends SWTResourceManager {
|
||||
if (url != null) {
|
||||
return ImageDescriptor.createFromURL(url);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
} catch (Exception e) {
|
||||
// Ignore any exceptions
|
||||
}
|
||||
return null;
|
||||
@ -362,66 +295,18 @@ public class ResourceManager extends SWTResourceManager {
|
||||
*/
|
||||
private static URL getPluginImageURL(String symbolicName, String path) {
|
||||
// try runtime plugins
|
||||
{
|
||||
Bundle bundle = Platform.getBundle(symbolicName);
|
||||
if (bundle != null) {
|
||||
return bundle.getEntry(path);
|
||||
}
|
||||
Bundle bundle = Platform.getBundle(symbolicName);
|
||||
if (bundle != null) {
|
||||
return bundle.getEntry(path);
|
||||
}
|
||||
// try design time provider
|
||||
if (m_designTimePluginResourceProvider != null) {
|
||||
return m_designTimePluginResourceProvider.getEntry(symbolicName, path);
|
||||
if (designTimePluginResourceProvider != null) {
|
||||
return designTimePluginResourceProvider.getEntry(symbolicName, path);
|
||||
}
|
||||
// no such resource
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an {@link URL} based on a plugin and file path.
|
||||
*
|
||||
* @param plugin the plugin {@link Object} containing the file path.
|
||||
* @param name the file path.
|
||||
* @return the {@link URL} representing the file at the specified path.
|
||||
* @throws Exception
|
||||
*/
|
||||
private static URL getPluginImageURL(Object plugin, String name) throws Exception {
|
||||
// try to work with 'plugin' as with OSGI BundleContext
|
||||
try {
|
||||
Class<?> BundleClass = Class.forName("org.osgi.framework.Bundle"); //$NON-NLS-1$
|
||||
Class<?> BundleContextClass = Class.forName("org.osgi.framework.BundleContext"); //$NON-NLS-1$
|
||||
if (BundleContextClass.isAssignableFrom(plugin.getClass())) {
|
||||
Method getBundleMethod = BundleContextClass.getMethod("getBundle", new Class[0]); //$NON-NLS-1$
|
||||
Object bundle = getBundleMethod.invoke(plugin, new Object[0]);
|
||||
//
|
||||
Class<?> PathClass = Class.forName("org.eclipse.core.runtime.Path"); //$NON-NLS-1$
|
||||
Constructor<?> pathConstructor = PathClass.getConstructor(new Class[] { String.class });
|
||||
Object path = pathConstructor.newInstance(new Object[] { name });
|
||||
//
|
||||
Class<?> IPathClass = Class.forName("org.eclipse.core.runtime.IPath"); //$NON-NLS-1$
|
||||
Class<?> PlatformClass = Class.forName("org.eclipse.core.runtime.Platform"); //$NON-NLS-1$
|
||||
Method findMethod = PlatformClass.getMethod("find", new Class[] { BundleClass, IPathClass }); //$NON-NLS-1$
|
||||
return (URL) findMethod.invoke(null, new Object[] { bundle, path });
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
// Ignore any exceptions
|
||||
}
|
||||
// else work with 'plugin' as with usual Eclipse plugin
|
||||
{
|
||||
Class<?> PluginClass = Class.forName("org.eclipse.core.runtime.Plugin"); //$NON-NLS-1$
|
||||
if (PluginClass.isAssignableFrom(plugin.getClass())) {
|
||||
//
|
||||
Class<?> PathClass = Class.forName("org.eclipse.core.runtime.Path"); //$NON-NLS-1$
|
||||
Constructor<?> pathConstructor = PathClass.getConstructor(new Class[] { String.class });
|
||||
Object path = pathConstructor.newInstance(new Object[] { name });
|
||||
//
|
||||
Class<?> IPathClass = Class.forName("org.eclipse.core.runtime.IPath"); //$NON-NLS-1$
|
||||
Method findMethod = PluginClass.getMethod("find", new Class[] { IPathClass }); //$NON-NLS-1$
|
||||
return (URL) findMethod.invoke(plugin, new Object[] { path });
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// General
|
||||
|
@ -34,7 +34,7 @@
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="com.minres.scviewer.database.test"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms40m -Xmx512m"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms40m -Xmx2G"/>
|
||||
<stringAttribute key="pde.version" value="3.3"/>
|
||||
<stringAttribute key="product" value="com.minres.scviewer.e4.product"/>
|
||||
<booleanAttribute key="run_in_ui_thread" value="true"/>
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2015 MINRES Technologies GmbH and others.
|
||||
* Copyright (c) 2015-2021 MINRES Technologies GmbH and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
@ -71,10 +71,10 @@ public class DatabaseServicesTest {
|
||||
assertEquals(2, waveformDb.getChildNodes().size());
|
||||
IWaveform bus_data_wave = waves.get(0);
|
||||
Entry<Long, IEvent[]> bus_data_entry = bus_data_wave.getEvents().floorEntry(1400000000L);
|
||||
assertTrue("01111000".equals(bus_data_entry.getValue()[0].toString()));
|
||||
assertEquals("01111000", bus_data_entry.getValue()[0].toString());
|
||||
IWaveform rw_wave = waves.get(2);
|
||||
Entry<Long, IEvent[]> rw_entry = rw_wave.getEvents().floorEntry(2360000000L);
|
||||
assertTrue("1".equals(rw_entry.getValue()[0].toString()));
|
||||
assertEquals("1", rw_entry.getValue()[0].toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -107,6 +107,16 @@ public class DatabaseServicesTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTxTextLargeFile() throws Exception {
|
||||
File f = new File("inputs/hw_cfg7.txlog").getAbsoluteFile();
|
||||
assertTrue(f.exists());
|
||||
waveformDb.load(f);
|
||||
assertNotNull(waveformDb);
|
||||
// hw_cfg_2_gen.txlog: 7.5s (2G)
|
||||
// hw_cfg7.txlog: 48s(2G)
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTxTextTruncated() throws Exception {
|
||||
File f = new File("inputs/my_db_truncated.txlog").getAbsoluteFile();
|
||||
|
Loading…
Reference in New Issue
Block a user