Merge branch 'feature/database_refactor' into develop
This commit is contained in:
commit
2c66bf3edd
@ -2,7 +2,7 @@
|
||||
<feature
|
||||
id="com.minres.scviewer.database.feature"
|
||||
label="%featureName"
|
||||
version="1.0.0.qualifier"
|
||||
version="2.0.0.qualifier"
|
||||
provider-name="%providerName">
|
||||
|
||||
<description>
|
||||
|
@ -8,5 +8,5 @@
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
</project>
|
||||
|
@ -2,7 +2,7 @@
|
||||
<feature
|
||||
id="com.minres.scviewer.e4.feature"
|
||||
label="SCViewer Feature"
|
||||
version="1.0.0.qualifier"
|
||||
version="1.1.0.qualifier"
|
||||
provider-name="MINRES Technologies GmbH">
|
||||
|
||||
<description url="http://www.example.com/description">
|
||||
|
@ -8,5 +8,5 @@
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<version>1.1.0-SNAPSHOT</version>
|
||||
</project>
|
||||
|
@ -2,7 +2,7 @@
|
||||
<feature
|
||||
id="com.minres.scviewer.feature"
|
||||
label="%featureName"
|
||||
version="1.0.0.qualifier"
|
||||
version="1.1.0.qualifier"
|
||||
provider-name="%providerName">
|
||||
|
||||
<description>
|
||||
|
@ -8,5 +8,5 @@
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<version>1.1.0-SNAPSHOT</version>
|
||||
</project>
|
||||
|
@ -2,7 +2,7 @@
|
||||
<feature
|
||||
id="com.minres.scviewer.ui.feature"
|
||||
label="SCViewer UI"
|
||||
version="1.0.0.qualifier"
|
||||
version="1.1.0.qualifier"
|
||||
provider-name="MINRES Technologies GmbH">
|
||||
|
||||
<description url="http://www.example.com/description">
|
||||
|
@ -8,5 +8,5 @@
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<version>1.1.0-SNAPSHOT</version>
|
||||
</project>
|
||||
|
@ -1,11 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<site>
|
||||
<feature url="features/com.minres.scviewer.feature_1.0.0.qualifier.jar" id="com.minres.scviewer.feature" version="1.0.0.qualifier">
|
||||
<category name="com.minres.scviewer"/>
|
||||
</feature>
|
||||
<feature id="com.minres.scviewer.e4.feature">
|
||||
<category name="com.minres.scviewer.e4"/>
|
||||
</feature>
|
||||
<feature id="com.minres.scviewer.feature">
|
||||
<category name="com.minres.scviewer"/>
|
||||
</feature>
|
||||
<category-def name="com.minres.scviewer" label="SCViewer">
|
||||
<description>
|
||||
Viewer for SystemC Verification (SCV) library's transaction recording
|
||||
|
@ -13,7 +13,6 @@ package com.minres.scviewer.database.sqlite;
|
||||
import java.beans.IntrospectionException;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.sql.SQLException;
|
||||
@ -24,6 +23,7 @@ import java.util.List;
|
||||
import com.minres.scviewer.database.IWaveform;
|
||||
import com.minres.scviewer.database.IWaveformDb;
|
||||
import com.minres.scviewer.database.IWaveformDbLoader;
|
||||
import com.minres.scviewer.database.InputFormatException;
|
||||
import com.minres.scviewer.database.RelationType;
|
||||
import com.minres.scviewer.database.sqlite.db.IDatabase;
|
||||
import com.minres.scviewer.database.sqlite.db.SQLiteDatabase;
|
||||
@ -42,16 +42,13 @@ public class SQLiteDbLoader implements IWaveformDbLoader {
|
||||
|
||||
private ScvSimProps scvSimProps;
|
||||
|
||||
public SQLiteDbLoader() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getMaxTime() {
|
||||
SQLiteDatabaseSelectHandler<ScvTxEvent> handler = new SQLiteDatabaseSelectHandler<ScvTxEvent>(ScvTxEvent.class,
|
||||
SQLiteDatabaseSelectHandler<ScvTxEvent> handler = new SQLiteDatabaseSelectHandler<>(ScvTxEvent.class,
|
||||
database, "time = (SELECT MAX(time) FROM ScvTxEvent)");
|
||||
try {
|
||||
List<ScvTxEvent> event = handler.selectObjects();
|
||||
if(event.size()>0)
|
||||
if(!event.isEmpty())
|
||||
return event.get(0).getTime()*scvSimProps.getTime_resolution();
|
||||
} catch (SecurityException | IllegalArgumentException | InstantiationException | IllegalAccessException
|
||||
| InvocationTargetException | SQLException | IntrospectionException e) {
|
||||
@ -62,8 +59,8 @@ public class SQLiteDbLoader implements IWaveformDbLoader {
|
||||
|
||||
@Override
|
||||
public Collection<IWaveform> getAllWaves() {
|
||||
SQLiteDatabaseSelectHandler<ScvStream> handler = new SQLiteDatabaseSelectHandler<ScvStream>(ScvStream.class, database);
|
||||
List<IWaveform> streams=new ArrayList<IWaveform>();
|
||||
SQLiteDatabaseSelectHandler<ScvStream> handler = new SQLiteDatabaseSelectHandler<>(ScvStream.class, database);
|
||||
List<IWaveform> streams=new ArrayList<>();
|
||||
try {
|
||||
for(ScvStream scvStream:handler.selectObjects()){
|
||||
TxStream stream = new TxStream(database, db, scvStream);
|
||||
@ -72,7 +69,6 @@ public class SQLiteDbLoader implements IWaveformDbLoader {
|
||||
}
|
||||
} catch (SecurityException | IllegalArgumentException | InstantiationException | IllegalAccessException
|
||||
| InvocationTargetException | SQLException | IntrospectionException e) {
|
||||
// e.printStackTrace();
|
||||
}
|
||||
return streams;
|
||||
}
|
||||
@ -80,25 +76,21 @@ public class SQLiteDbLoader implements IWaveformDbLoader {
|
||||
private byte[] x = "SQLite format 3".getBytes();
|
||||
|
||||
@Override
|
||||
public boolean load(IWaveformDb db, File file) throws Exception {
|
||||
public boolean load(IWaveformDb db, File file) throws InputFormatException {
|
||||
if(file.isDirectory() || !file.exists()) return false;
|
||||
this.db=db;
|
||||
try {
|
||||
FileInputStream fis = new FileInputStream(file);
|
||||
try(FileInputStream fis = new FileInputStream(file)) {
|
||||
byte[] buffer = new byte[x.length];
|
||||
int read = fis.read(buffer, 0, x.length);
|
||||
fis.close();
|
||||
if (read == x.length)
|
||||
for (int i = 0; i < x.length; i++)
|
||||
if (buffer[i] != x[i]) return false;
|
||||
} catch(FileNotFoundException e) {
|
||||
return false;
|
||||
} catch(IOException e) { //if an I/O error occurs
|
||||
} catch(IOException e) {
|
||||
return false;
|
||||
}
|
||||
database=new SQLiteDatabase(file.getAbsolutePath());
|
||||
database.setData("TIMERESOLUTION", 1L);
|
||||
SQLiteDatabaseSelectHandler<ScvSimProps> handler = new SQLiteDatabaseSelectHandler<ScvSimProps>(ScvSimProps.class, database);
|
||||
SQLiteDatabaseSelectHandler<ScvSimProps> handler = new SQLiteDatabaseSelectHandler<>(ScvSimProps.class, database);
|
||||
try {
|
||||
for(ScvSimProps simProps:handler.selectObjects()){
|
||||
scvSimProps=simProps;
|
||||
|
@ -18,12 +18,7 @@ import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import com.minres.scviewer.database.AssociationType;
|
||||
import com.minres.scviewer.database.ITx;
|
||||
import com.minres.scviewer.database.ITxAttribute;
|
||||
import com.minres.scviewer.database.ITxEvent;
|
||||
import com.minres.scviewer.database.ITxGenerator;
|
||||
import com.minres.scviewer.database.ITxRelation;
|
||||
import com.minres.scviewer.database.ITxStream;
|
||||
import com.minres.scviewer.database.IWaveform;
|
||||
import com.minres.scviewer.database.sqlite.db.IDatabase;
|
||||
import com.minres.scviewer.database.sqlite.db.SQLiteDatabaseSelectHandler;
|
||||
import com.minres.scviewer.database.sqlite.tables.ScvStream;
|
||||
@ -31,6 +26,10 @@ import com.minres.scviewer.database.sqlite.tables.ScvTx;
|
||||
import com.minres.scviewer.database.sqlite.tables.ScvTxAttribute;
|
||||
import com.minres.scviewer.database.sqlite.tables.ScvTxEvent;
|
||||
import com.minres.scviewer.database.sqlite.tables.ScvTxRelation;
|
||||
import com.minres.scviewer.database.tx.ITx;
|
||||
import com.minres.scviewer.database.tx.ITxAttribute;
|
||||
import com.minres.scviewer.database.tx.ITxGenerator;
|
||||
import com.minres.scviewer.database.tx.ITxRelation;
|
||||
|
||||
public class Tx implements ITx {
|
||||
|
||||
@ -39,8 +38,10 @@ public class Tx implements ITx {
|
||||
private TxGenerator trGenerator;
|
||||
private ScvTx scvTx;
|
||||
private List<ITxAttribute> attributes;
|
||||
private Long begin, end;
|
||||
private List<ITxRelation> incoming, outgoing;
|
||||
private Long begin;
|
||||
private Long end;
|
||||
private List<ITxRelation> incoming;
|
||||
private List<ITxRelation> outgoing;
|
||||
|
||||
public Tx(IDatabase database, TxStream trStream, TxGenerator trGenerator, ScvTx scvTx) {
|
||||
this.database=database;
|
||||
@ -55,7 +56,7 @@ public class Tx implements ITx {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITxStream<ITxEvent> getStream() {
|
||||
public IWaveform getStream() {
|
||||
return trStream;
|
||||
}
|
||||
|
||||
@ -72,7 +73,7 @@ public class Tx implements ITx {
|
||||
@Override
|
||||
public Long getBeginTime() {
|
||||
if(begin==null){
|
||||
SQLiteDatabaseSelectHandler<ScvTxEvent> handler = new SQLiteDatabaseSelectHandler<ScvTxEvent>(ScvTxEvent.class,
|
||||
SQLiteDatabaseSelectHandler<ScvTxEvent> handler = new SQLiteDatabaseSelectHandler<>(ScvTxEvent.class,
|
||||
database, "tx="+scvTx.getId()+" AND type="+ AssociationType.BEGIN.ordinal());
|
||||
try {
|
||||
for(ScvTxEvent scvEvent:handler.selectObjects()){
|
||||
@ -88,7 +89,7 @@ public class Tx implements ITx {
|
||||
@Override
|
||||
public Long getEndTime() {
|
||||
if(end==null){
|
||||
SQLiteDatabaseSelectHandler<ScvTxEvent> handler = new SQLiteDatabaseSelectHandler<ScvTxEvent>(ScvTxEvent.class,
|
||||
SQLiteDatabaseSelectHandler<ScvTxEvent> handler = new SQLiteDatabaseSelectHandler<>(ScvTxEvent.class,
|
||||
database, "tx="+scvTx.getId()+" AND type="+ AssociationType.END.ordinal());
|
||||
try {
|
||||
for(ScvTxEvent scvEvent:handler.selectObjects()){
|
||||
@ -104,10 +105,10 @@ public class Tx implements ITx {
|
||||
@Override
|
||||
public List<ITxAttribute> getAttributes() {
|
||||
if(attributes==null){
|
||||
SQLiteDatabaseSelectHandler<ScvTxAttribute> handler = new SQLiteDatabaseSelectHandler<ScvTxAttribute>(
|
||||
SQLiteDatabaseSelectHandler<ScvTxAttribute> handler = new SQLiteDatabaseSelectHandler<>(
|
||||
ScvTxAttribute.class, database, "tx="+scvTx.getId());
|
||||
try {
|
||||
attributes = new ArrayList<ITxAttribute>();
|
||||
attributes = new ArrayList<>();
|
||||
for(ScvTxAttribute scvAttribute:handler.selectObjects()){
|
||||
attributes.add(new TxAttribute(this, scvAttribute));
|
||||
|
||||
@ -122,10 +123,10 @@ public class Tx implements ITx {
|
||||
@Override
|
||||
public Collection<ITxRelation> getIncomingRelations() {
|
||||
if(incoming==null){
|
||||
SQLiteDatabaseSelectHandler<ScvTxRelation> handler = new SQLiteDatabaseSelectHandler<ScvTxRelation>(
|
||||
SQLiteDatabaseSelectHandler<ScvTxRelation> handler = new SQLiteDatabaseSelectHandler<>(
|
||||
ScvTxRelation.class, database, "sink="+scvTx.getId());
|
||||
try {
|
||||
incoming = new ArrayList<ITxRelation>();
|
||||
incoming = new ArrayList<>();
|
||||
for(ScvTxRelation scvRelation:handler.selectObjects()){
|
||||
incoming.add(createRelation(scvRelation, false));
|
||||
}
|
||||
@ -139,10 +140,10 @@ public class Tx implements ITx {
|
||||
@Override
|
||||
public Collection<ITxRelation> getOutgoingRelations() {
|
||||
if(outgoing==null){
|
||||
SQLiteDatabaseSelectHandler<ScvTxRelation> handler = new SQLiteDatabaseSelectHandler<ScvTxRelation>(
|
||||
SQLiteDatabaseSelectHandler<ScvTxRelation> handler = new SQLiteDatabaseSelectHandler<>(
|
||||
ScvTxRelation.class, database, "src="+scvTx.getId());
|
||||
try {
|
||||
outgoing = new ArrayList<ITxRelation>();
|
||||
outgoing = new ArrayList<>();
|
||||
for(ScvTxRelation scvRelation:handler.selectObjects()){
|
||||
outgoing.add(createRelation(scvRelation, true));
|
||||
}
|
||||
@ -155,7 +156,7 @@ public class Tx implements ITx {
|
||||
|
||||
private ITxRelation createRelation(ScvTxRelation rel, boolean outgoing) {
|
||||
int otherId = outgoing?rel.getSink():rel.getSrc();
|
||||
SQLiteDatabaseSelectHandler<ScvTx> handler = new SQLiteDatabaseSelectHandler<ScvTx>(ScvTx.class, database,
|
||||
SQLiteDatabaseSelectHandler<ScvTx> handler = new SQLiteDatabaseSelectHandler<>(ScvTx.class, database,
|
||||
"id="+otherId);
|
||||
try {
|
||||
List<ScvTx> res = handler.selectObjects();
|
||||
|
@ -12,8 +12,8 @@ package com.minres.scviewer.database.sqlite;
|
||||
|
||||
import com.minres.scviewer.database.AssociationType;
|
||||
import com.minres.scviewer.database.DataType;
|
||||
import com.minres.scviewer.database.ITxAttribute;
|
||||
import com.minres.scviewer.database.sqlite.tables.ScvTxAttribute;
|
||||
import com.minres.scviewer.database.tx.ITxAttribute;
|
||||
|
||||
public class TxAttribute implements ITxAttribute{
|
||||
|
||||
|
@ -10,16 +10,18 @@
|
||||
*******************************************************************************/
|
||||
package com.minres.scviewer.database.sqlite;
|
||||
|
||||
import com.minres.scviewer.database.ITx;
|
||||
import com.minres.scviewer.database.ITxEvent;
|
||||
import com.minres.scviewer.database.IWaveformEvent;
|
||||
import com.minres.scviewer.database.EventKind;
|
||||
import com.minres.scviewer.database.IEvent;
|
||||
import com.minres.scviewer.database.WaveformType;
|
||||
import com.minres.scviewer.database.tx.ITx;
|
||||
import com.minres.scviewer.database.tx.ITxEvent;
|
||||
|
||||
public class TxEvent implements ITxEvent {
|
||||
|
||||
private final Type type;
|
||||
private final EventKind type;
|
||||
private ITx tx;
|
||||
|
||||
public TxEvent(Type type, ITx tx) {
|
||||
public TxEvent(EventKind type, ITx tx) {
|
||||
super();
|
||||
this.type = type;
|
||||
this.tx = tx;
|
||||
@ -27,26 +29,21 @@ public class TxEvent implements ITxEvent {
|
||||
|
||||
@Override
|
||||
public Long getTime() {
|
||||
return type==Type.BEGIN?tx.getBeginTime():tx.getEndTime();
|
||||
return type==EventKind.BEGIN?tx.getBeginTime():tx.getEndTime();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWaveformEvent duplicate() throws CloneNotSupportedException {
|
||||
public IEvent duplicate() throws CloneNotSupportedException {
|
||||
return new TxEvent(type, tx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(IWaveformEvent o) {
|
||||
return getTime().compareTo(o.getTime());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITx getTransaction() {
|
||||
return tx;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type getType() {
|
||||
public EventKind getKind() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@ -54,4 +51,9 @@ public class TxEvent implements ITxEvent {
|
||||
public String toString() {
|
||||
return type.toString()+"@"+getTime()+" of tx #"+tx.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public WaveformType getType() {
|
||||
return WaveformType.TRANSACTION;
|
||||
}
|
||||
}
|
||||
|
@ -10,21 +10,21 @@
|
||||
*******************************************************************************/
|
||||
package com.minres.scviewer.database.sqlite;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.minres.scviewer.database.ITx;
|
||||
import com.minres.scviewer.database.ITxEvent;
|
||||
import com.minres.scviewer.database.ITxGenerator;
|
||||
import com.minres.scviewer.database.ITxStream;
|
||||
import com.minres.scviewer.database.IWaveform;
|
||||
import com.minres.scviewer.database.sqlite.tables.ScvGenerator;
|
||||
import com.minres.scviewer.database.tx.ITx;
|
||||
import com.minres.scviewer.database.tx.ITxGenerator;
|
||||
|
||||
public class TxGenerator implements ITxGenerator {
|
||||
|
||||
private ITxStream<ITxEvent> stream;
|
||||
private IWaveform stream;
|
||||
|
||||
private ScvGenerator scvGenerator;
|
||||
|
||||
public TxGenerator(ITxStream<ITxEvent> stream, ScvGenerator scvGenerator) {
|
||||
public TxGenerator(IWaveform stream, ScvGenerator scvGenerator) {
|
||||
this.stream=stream;
|
||||
this.scvGenerator=scvGenerator;
|
||||
}
|
||||
@ -35,7 +35,7 @@ public class TxGenerator implements ITxGenerator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITxStream<ITxEvent> getStream() {
|
||||
public IWaveform getStream() {
|
||||
return stream;
|
||||
}
|
||||
|
||||
@ -46,7 +46,7 @@ public class TxGenerator implements ITxGenerator {
|
||||
|
||||
@Override
|
||||
public List<ITx> getTransactions() {
|
||||
return null;
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -10,14 +10,15 @@
|
||||
*******************************************************************************/
|
||||
package com.minres.scviewer.database.sqlite;
|
||||
|
||||
import com.minres.scviewer.database.ITxRelation;
|
||||
import com.minres.scviewer.database.ITx;
|
||||
import com.minres.scviewer.database.RelationType;
|
||||
import com.minres.scviewer.database.tx.ITx;
|
||||
import com.minres.scviewer.database.tx.ITxRelation;
|
||||
|
||||
public class TxRelation implements ITxRelation {
|
||||
|
||||
RelationType relationType;
|
||||
Tx source, target;
|
||||
Tx source;
|
||||
Tx target;
|
||||
|
||||
public TxRelation(RelationType relationType, Tx source, Tx target) {
|
||||
this.source = source;
|
||||
|
@ -14,48 +14,47 @@ import java.beans.IntrospectionException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.NavigableMap;
|
||||
import java.util.TreeMap;
|
||||
import java.util.Vector;
|
||||
|
||||
import com.minres.scviewer.database.EventKind;
|
||||
import com.minres.scviewer.database.HierNode;
|
||||
import com.minres.scviewer.database.ITx;
|
||||
import com.minres.scviewer.database.ITxEvent;
|
||||
import com.minres.scviewer.database.ITxGenerator;
|
||||
import com.minres.scviewer.database.ITxStream;
|
||||
import com.minres.scviewer.database.IEvent;
|
||||
import com.minres.scviewer.database.IWaveform;
|
||||
import com.minres.scviewer.database.IWaveformDb;
|
||||
import com.minres.scviewer.database.RelationType;
|
||||
import com.minres.scviewer.database.WaveformType;
|
||||
import com.minres.scviewer.database.sqlite.db.IDatabase;
|
||||
import com.minres.scviewer.database.sqlite.db.SQLiteDatabaseSelectHandler;
|
||||
import com.minres.scviewer.database.sqlite.tables.ScvGenerator;
|
||||
import com.minres.scviewer.database.sqlite.tables.ScvStream;
|
||||
import com.minres.scviewer.database.sqlite.tables.ScvTx;
|
||||
import com.minres.scviewer.database.tx.ITx;
|
||||
import com.minres.scviewer.database.tx.ITxGenerator;
|
||||
|
||||
public class TxStream extends HierNode implements ITxStream<ITxEvent> {
|
||||
public class TxStream extends HierNode implements IWaveform {
|
||||
|
||||
private IDatabase database;
|
||||
|
||||
private String fullName;
|
||||
|
||||
|
||||
private IWaveformDb db;
|
||||
|
||||
|
||||
private ScvStream scvStream;
|
||||
|
||||
|
||||
private TreeMap<Integer, TxGenerator> generators;
|
||||
|
||||
|
||||
private TreeMap<Integer, ITx> transactions;
|
||||
|
||||
|
||||
private Integer maxConcurrency;
|
||||
|
||||
private TreeMap<Long, List<ITxEvent>> events;
|
||||
|
||||
private TreeMap<Long, IEvent[]> events;
|
||||
|
||||
private List<RelationType> usedRelationsList;
|
||||
|
||||
|
||||
public TxStream(IDatabase database, IWaveformDb waveformDb, ScvStream scvStream) {
|
||||
super(scvStream.getName());
|
||||
this.database=database;
|
||||
@ -79,17 +78,11 @@ public class TxStream extends HierNode implements ITxStream<ITxEvent> {
|
||||
return (long) scvStream.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getKind() {
|
||||
return scvStream.getKind();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ITxGenerator> getGenerators() {
|
||||
if(generators==null){
|
||||
SQLiteDatabaseSelectHandler<ScvGenerator> handler = new SQLiteDatabaseSelectHandler<ScvGenerator>(
|
||||
SQLiteDatabaseSelectHandler<ScvGenerator> handler = new SQLiteDatabaseSelectHandler<>(
|
||||
ScvGenerator.class, database, "stream="+scvStream.getId());
|
||||
generators=new TreeMap<Integer, TxGenerator>();
|
||||
generators=new TreeMap<>();
|
||||
try {
|
||||
for(ScvGenerator scvGenerator:handler.selectObjects()){
|
||||
generators.put(scvGenerator.getId(), new TxGenerator(this, scvGenerator));
|
||||
@ -99,22 +92,20 @@ public class TxStream extends HierNode implements ITxStream<ITxEvent> {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return new ArrayList<ITxGenerator>(generators.values());
|
||||
return new ArrayList<>(generators.values());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxConcurrency() {
|
||||
public int getWidth() {
|
||||
if(maxConcurrency==null){
|
||||
java.sql.Connection connection=null;
|
||||
java.sql.Statement statement=null;
|
||||
java.sql.ResultSet resultSet=null;
|
||||
try {
|
||||
connection = database.createConnection();
|
||||
statement = connection.createStatement();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("SELECT MAX(concurrencyLevel) as concurrencyLevel FROM ScvTx where stream=");
|
||||
sb.append(scvStream.getId());
|
||||
resultSet = statement.executeQuery(sb.toString());
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("SELECT MAX(concurrencyLevel) as concurrencyLevel FROM ScvTx where stream=");
|
||||
sb.append(scvStream.getId());
|
||||
try(
|
||||
java.sql.Connection connection = database.createConnection();
|
||||
java.sql.Statement statement = connection.createStatement();
|
||||
java.sql.ResultSet resultSet = statement.executeQuery(sb.toString());
|
||||
) {
|
||||
while (resultSet.next()) {
|
||||
if(maxConcurrency==null) maxConcurrency=0;
|
||||
Object value = resultSet.getObject("concurrencyLevel");
|
||||
@ -123,12 +114,6 @@ public class TxStream extends HierNode implements ITxStream<ITxEvent> {
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
if(maxConcurrency==null) maxConcurrency=0;
|
||||
} finally {
|
||||
try{
|
||||
if(resultSet!=null) resultSet.close();
|
||||
if(statement!=null) statement.close();
|
||||
if(connection!=null) connection.close();
|
||||
} catch (SQLException e) { }
|
||||
}
|
||||
maxConcurrency+=1;
|
||||
}
|
||||
@ -136,12 +121,12 @@ public class TxStream extends HierNode implements ITxStream<ITxEvent> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NavigableMap<Long, List<ITxEvent>> getEvents(){
|
||||
public NavigableMap<Long, IEvent[]> getEvents(){
|
||||
if(events==null){
|
||||
events=new TreeMap<Long, List<ITxEvent>>();
|
||||
events=new TreeMap<>();
|
||||
for(Entry<Integer, ITx> entry:getTransactions().entrySet()){
|
||||
putEvent(new TxEvent(TxEvent.Type.BEGIN, entry.getValue()));
|
||||
putEvent(new TxEvent(TxEvent.Type.END, entry.getValue()));
|
||||
putEvent(new TxEvent(EventKind.BEGIN, entry.getValue()));
|
||||
putEvent(new TxEvent(EventKind.END, entry.getValue()));
|
||||
}
|
||||
}
|
||||
return events;
|
||||
@ -149,20 +134,22 @@ public class TxStream extends HierNode implements ITxStream<ITxEvent> {
|
||||
|
||||
private void putEvent(TxEvent ev){
|
||||
Long time = ev.getTime();
|
||||
if(!events.containsKey(time)){
|
||||
Vector<ITxEvent> vector=new Vector<ITxEvent>();
|
||||
vector.add(ev);
|
||||
events.put(time, vector);
|
||||
if(events.containsKey(time)) {
|
||||
IEvent[] oldV = events.get(time);
|
||||
IEvent[] newV = new IEvent[oldV.length+1];
|
||||
System.arraycopy(oldV, 0, newV, 0, oldV.length);
|
||||
newV[oldV.length]=ev;
|
||||
events.put(time, newV);
|
||||
} else {
|
||||
events.get(time).add(ev);
|
||||
events.put(time, new IEvent[] {ev});
|
||||
}
|
||||
}
|
||||
|
||||
protected Map<Integer, ITx> getTransactions() {
|
||||
if(transactions==null){
|
||||
if(generators==null) getGenerators();
|
||||
transactions = new TreeMap<Integer, ITx>();
|
||||
SQLiteDatabaseSelectHandler<ScvTx> handler = new SQLiteDatabaseSelectHandler<ScvTx>(ScvTx.class, database,
|
||||
transactions = new TreeMap<>();
|
||||
SQLiteDatabaseSelectHandler<ScvTx> handler = new SQLiteDatabaseSelectHandler<>(ScvTx.class, database,
|
||||
"stream="+scvStream.getId());
|
||||
try {
|
||||
for(ScvTx scvTx:handler.selectObjects()){
|
||||
@ -177,14 +164,14 @@ public class TxStream extends HierNode implements ITxStream<ITxEvent> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ITxEvent> getWaveformEventsAtTime(Long time) {
|
||||
public IEvent[] getEventsAtTime(Long time) {
|
||||
return getEvents().get(time);
|
||||
}
|
||||
|
||||
public void setRelationTypeList(List<RelationType> usedRelationsList){
|
||||
this.usedRelationsList=usedRelationsList;
|
||||
}
|
||||
|
||||
|
||||
public RelationType getRelationType(String name) {
|
||||
RelationType relType=RelationType.create(name);
|
||||
if(!usedRelationsList.contains(relType)) usedRelationsList.add(relType);
|
||||
@ -192,8 +179,22 @@ public class TxStream extends HierNode implements ITxStream<ITxEvent> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean equals(IWaveform other) {
|
||||
public boolean isSame(IWaveform other) {
|
||||
return(other instanceof TxStream && this.getId().equals(other.getId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEvent[] getEventsBeforeTime(Long time) {
|
||||
Entry<Long, IEvent[]> e = events.floorEntry(time);
|
||||
if(e==null)
|
||||
return new IEvent[]{};
|
||||
else
|
||||
return events.floorEntry(time).getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public WaveformType getType() {
|
||||
return WaveformType.TRANSACTION;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: Textual transaction database
|
||||
Bundle-SymbolicName: com.minres.scviewer.database.text
|
||||
Bundle-Version: 2.0.2.qualifier
|
||||
Bundle-Version: 2.1.0.qualifier
|
||||
Bundle-Vendor: MINRES Technologies GmbH
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
|
||||
Import-Package: org.osgi.framework;version="1.3.0"
|
||||
|
@ -2,7 +2,7 @@
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>com.minres.scviewer.database.text</artifactId>
|
||||
<version>2.0.2-SNAPSHOT</version>
|
||||
<version>2.1.0-SNAPSHOT</version>
|
||||
<parent>
|
||||
<groupId>com.minres.scviewer</groupId>
|
||||
<artifactId>com.minres.scviewer.parent</artifactId>
|
||||
|
@ -22,12 +22,12 @@ import groovy.io.FileType
|
||||
|
||||
import com.minres.scviewer.database.AssociationType
|
||||
import com.minres.scviewer.database.DataType
|
||||
import com.minres.scviewer.database.ITxGenerator
|
||||
import com.minres.scviewer.database.ITxStream
|
||||
import com.minres.scviewer.database.IWaveform
|
||||
import com.minres.scviewer.database.IWaveformDb
|
||||
import com.minres.scviewer.database.IWaveformDbLoader
|
||||
import com.minres.scviewer.database.InputFormatException
|
||||
import com.minres.scviewer.database.RelationType
|
||||
import com.minres.scviewer.database.tx.ITxGenerator
|
||||
|
||||
public class TextDbLoader implements IWaveformDbLoader{
|
||||
|
||||
@ -63,7 +63,7 @@ public class TextDbLoader implements IWaveformDbLoader{
|
||||
static final byte[] x = "scv_tr_stream".bytes
|
||||
|
||||
@Override
|
||||
boolean load(IWaveformDb db, File file) throws Exception {
|
||||
boolean load(IWaveformDb db, File file) throws InputFormatException {
|
||||
if(file.isDirectory() || !file.exists()) return false;
|
||||
this.db=db
|
||||
this.streams=[]
|
||||
@ -83,7 +83,7 @@ public class TextDbLoader implements IWaveformDbLoader{
|
||||
.make()
|
||||
// NPE here --->
|
||||
parseInput(gzipped?new GZIPInputStream(new FileInputStream(file)):new FileInputStream(file))
|
||||
streams.each{ TxStream stream -> stream.getMaxConcurrency() }
|
||||
streams.each{ TxStream stream -> stream.getWidth() }
|
||||
return true
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
@ -98,6 +98,9 @@ public class TextDbLoader implements IWaveformDbLoader{
|
||||
System.out.println("---->>> Exception "+e.toString()+" caught while loading database");
|
||||
//System.out.println("---->>> Exception "+e.toString()+" caught while loading database. StackTrace following... ");
|
||||
//e.printStackTrace()
|
||||
} catch(Error e) {
|
||||
System.out.println("---->>> Exception "+e.toString()+" caught while loading database. StackTrace following... ");
|
||||
e.printStackTrace()
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -163,7 +166,7 @@ public class TextDbLoader implements IWaveformDbLoader{
|
||||
case "scv_tr_generator":
|
||||
if ((matcher = line =~ /^scv_tr_generator\s+\(ID\s+(\d+),\s+name\s+"([^"]+)",\s+scv_tr_stream\s+(\d+),$/)) {
|
||||
def id = Integer.parseInt(matcher[0][1])
|
||||
ITxStream stream=streamsById[Integer.parseInt(matcher[0][3])]
|
||||
TxStream stream=streamsById[Integer.parseInt(matcher[0][3])] as TxStream
|
||||
generator=new TxGenerator(id, stream, matcher[0][2])
|
||||
stream.generators<<generator
|
||||
generatorsById[id]=generator
|
||||
|
@ -11,6 +11,9 @@
|
||||
package com.minres.scviewer.database.text
|
||||
|
||||
import com.minres.scviewer.database.*
|
||||
import com.minres.scviewer.database.tx.ITx
|
||||
import com.minres.scviewer.database.tx.ITxAttribute
|
||||
import com.minres.scviewer.database.tx.ITxRelation
|
||||
|
||||
class Tx implements ITx {
|
||||
|
||||
|
@ -12,8 +12,8 @@ package com.minres.scviewer.database.text
|
||||
|
||||
import com.minres.scviewer.database.AssociationType;
|
||||
import com.minres.scviewer.database.DataType;
|
||||
import com.minres.scviewer.database.ITxAttributeType;
|
||||
import com.minres.scviewer.database.ITxAttribute
|
||||
import com.minres.scviewer.database.tx.ITxAttribute
|
||||
import com.minres.scviewer.database.tx.ITxAttributeType
|
||||
|
||||
class TxAttribute implements ITxAttribute{
|
||||
|
||||
|
@ -12,7 +12,7 @@ package com.minres.scviewer.database.text
|
||||
|
||||
import com.minres.scviewer.database.AssociationType;
|
||||
import com.minres.scviewer.database.DataType;
|
||||
import com.minres.scviewer.database.ITxAttributeType;
|
||||
import com.minres.scviewer.database.tx.ITxAttributeType
|
||||
|
||||
class TxAttributeType implements ITxAttributeType {
|
||||
String name
|
||||
|
@ -12,11 +12,11 @@ package com.minres.scviewer.database.text
|
||||
|
||||
import com.minres.scviewer.database.AssociationType;
|
||||
import com.minres.scviewer.database.DataType
|
||||
import com.minres.scviewer.database.ITxAttributeType
|
||||
import com.minres.scviewer.database.ITxAttribute
|
||||
import com.minres.scviewer.database.tx.ITxAttribute
|
||||
import com.minres.scviewer.database.tx.ITxAttributeType
|
||||
|
||||
class TxAttributeTypeFactory {
|
||||
private static final instance = new TxAttributeTypeFactory()
|
||||
static final TxAttributeTypeFactory instance = new TxAttributeTypeFactory()
|
||||
|
||||
def attributes = [:]
|
||||
|
||||
|
@ -1,36 +0,0 @@
|
||||
package com.minres.scviewer.database.text;
|
||||
|
||||
import com.minres.scviewer.database.ITx
|
||||
import com.minres.scviewer.database.ITxEvent
|
||||
import com.minres.scviewer.database.IWaveformEvent
|
||||
|
||||
class TxEvent implements ITxEvent {
|
||||
|
||||
final ITxEvent.Type type;
|
||||
|
||||
final Tx transaction;
|
||||
|
||||
final Long time
|
||||
|
||||
TxEvent(ITxEvent.Type type, ITx transaction) {
|
||||
super();
|
||||
this.type = type;
|
||||
this.transaction = transaction;
|
||||
this.time = type==ITxEvent.Type.BEGIN?transaction.beginTime:transaction.endTime
|
||||
}
|
||||
|
||||
@Override
|
||||
IWaveformEvent duplicate() throws CloneNotSupportedException {
|
||||
new TxEvent(type, transaction, time)
|
||||
}
|
||||
|
||||
@Override
|
||||
int compareTo(IWaveformEvent o) {
|
||||
time.compareTo(o.time)
|
||||
}
|
||||
|
||||
@Override
|
||||
String toString() {
|
||||
type.toString()+"@"+time+" of tx #"+transaction.id;
|
||||
}
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
package com.minres.scviewer.database.text;
|
||||
|
||||
import com.minres.scviewer.database.EventKind;
|
||||
import com.minres.scviewer.database.WaveformType;
|
||||
import com.minres.scviewer.database.tx.ITx;
|
||||
import com.minres.scviewer.database.tx.ITxEvent;
|
||||
|
||||
class TxEvent implements ITxEvent {
|
||||
|
||||
final EventKind kind;
|
||||
|
||||
final ITx transaction;
|
||||
|
||||
final Long time;
|
||||
|
||||
TxEvent(EventKind kind, ITx transaction) {
|
||||
super();
|
||||
this.kind = kind;
|
||||
this.transaction = transaction;
|
||||
this.time = kind==EventKind.BEGIN?transaction.getBeginTime():transaction.getEndTime();
|
||||
}
|
||||
|
||||
public TxEvent(EventKind kind, ITx transaction, Long time) {
|
||||
super();
|
||||
this.kind = kind;
|
||||
this.transaction = transaction;
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
@Override
|
||||
public
|
||||
ITxEvent duplicate() throws CloneNotSupportedException {
|
||||
return new TxEvent(kind, transaction, time);
|
||||
}
|
||||
|
||||
@Override
|
||||
public
|
||||
String toString() {
|
||||
return kind.toString()+"@"+time+" of tx #"+transaction.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public WaveformType getType() {
|
||||
return WaveformType.TRANSACTION;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventKind getKind() {
|
||||
return kind;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITx getTransaction() {
|
||||
return transaction;
|
||||
}
|
||||
}
|
@ -13,17 +13,15 @@ package com.minres.scviewer.database.text
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.minres.scviewer.database.ITxAttributeType
|
||||
import com.minres.scviewer.database.ITxAttribute;
|
||||
import com.minres.scviewer.database.ITxEvent;
|
||||
import com.minres.scviewer.database.ITxGenerator;
|
||||
import com.minres.scviewer.database.ITxStream;
|
||||
import com.minres.scviewer.database.ITx;
|
||||
import com.minres.scviewer.database.IWaveformEvent;
|
||||
import com.minres.scviewer.database.IWaveform
|
||||
import com.minres.scviewer.database.tx.ITx
|
||||
import com.minres.scviewer.database.tx.ITxAttribute
|
||||
import com.minres.scviewer.database.tx.ITxAttributeType
|
||||
import com.minres.scviewer.database.tx.ITxGenerator
|
||||
|
||||
class TxGenerator implements ITxGenerator{
|
||||
Long id
|
||||
TxStream stream
|
||||
IWaveform stream
|
||||
String name
|
||||
Boolean active = false
|
||||
ArrayList<ITx> transactions=[]
|
||||
@ -39,7 +37,7 @@ class TxGenerator implements ITxGenerator{
|
||||
this.name=name
|
||||
}
|
||||
|
||||
ITxStream<? extends ITxEvent> getStream(){
|
||||
IWaveform getStream(){
|
||||
return stream;
|
||||
}
|
||||
|
||||
|
@ -1,16 +1,15 @@
|
||||
package com.minres.scviewer.database.text
|
||||
package com.minres.scviewer.database.text;
|
||||
|
||||
import com.minres.scviewer.database.ITxRelation
|
||||
import com.minres.scviewer.database.ITx;
|
||||
import com.minres.scviewer.database.RelationType;
|
||||
import com.minres.scviewer.database.tx.ITx;
|
||||
import com.minres.scviewer.database.tx.ITxRelation;
|
||||
|
||||
class TxRelation implements ITxRelation {
|
||||
Tx source
|
||||
final Tx source;
|
||||
|
||||
Tx target
|
||||
|
||||
RelationType relationType
|
||||
final Tx target;
|
||||
|
||||
final RelationType relationType;
|
||||
|
||||
public TxRelation(RelationType relationType, Tx source, Tx target) {
|
||||
this.source = source;
|
@ -16,20 +16,22 @@ import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.NavigableMap;
|
||||
import java.util.Map.Entry
|
||||
|
||||
import org.mapdb.Serializer
|
||||
|
||||
import com.minres.scviewer.database.ITxEvent;
|
||||
import com.minres.scviewer.database.IWaveform;
|
||||
import com.minres.scviewer.database.IWaveformDb
|
||||
import com.minres.scviewer.database.IWaveformEvent
|
||||
import com.minres.scviewer.database.ITxGenerator
|
||||
import com.minres.scviewer.database.WaveformType
|
||||
import com.minres.scviewer.database.tx.ITx
|
||||
import com.minres.scviewer.database.tx.ITxEvent
|
||||
import com.minres.scviewer.database.tx.ITxGenerator
|
||||
import com.minres.scviewer.database.EventKind
|
||||
import com.minres.scviewer.database.HierNode;
|
||||
import com.minres.scviewer.database.IEvent
|
||||
import com.minres.scviewer.database.IHierNode
|
||||
import com.minres.scviewer.database.ITxStream
|
||||
import com.minres.scviewer.database.ITx
|
||||
|
||||
class TxStream extends HierNode implements ITxStream {
|
||||
class TxStream extends HierNode implements IWaveform {
|
||||
|
||||
Long id
|
||||
|
||||
@ -37,20 +39,17 @@ class TxStream extends HierNode implements ITxStream {
|
||||
|
||||
String fullName
|
||||
|
||||
String kind
|
||||
|
||||
def generators = []
|
||||
|
||||
int maxConcurrency
|
||||
|
||||
private TreeMap<Long, List<ITxEvent>> events
|
||||
private TreeMap<Long, IEvent[]> events
|
||||
|
||||
TxStream(TextDbLoader loader, int id, String name, String kind){
|
||||
super(name)
|
||||
this.id=id
|
||||
this.database=loader.db
|
||||
this.fullName=name
|
||||
this.kind=kind
|
||||
this.maxConcurrency=0
|
||||
//events = new TreeMap<Long, List<ITxEvent>>()
|
||||
events = loader.mapDb.treeMap(name).keySerializer(Serializer.LONG).createOrOpen();
|
||||
@ -66,18 +65,18 @@ class TxStream extends HierNode implements ITxStream {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxConcurrency() {
|
||||
public int getWidth() {
|
||||
if(!maxConcurrency){
|
||||
generators.each {TxGenerator generator ->
|
||||
generator.transactions.each{ Tx tx ->
|
||||
putEvent(new TxEvent(ITxEvent.Type.BEGIN, tx))
|
||||
putEvent(new TxEvent(ITxEvent.Type.END, tx))
|
||||
putEvent(new TxEvent(EventKind.BEGIN, tx))
|
||||
putEvent(new TxEvent(EventKind.END, tx))
|
||||
}
|
||||
}
|
||||
def rowendtime = [0]
|
||||
events.keySet().each{long time ->
|
||||
def value=events.get(time)
|
||||
def starts=value.findAll{ITxEvent event ->event.type==ITxEvent.Type.BEGIN}
|
||||
def starts=value.findAll{IEvent event ->event.kind==EventKind.BEGIN}
|
||||
starts.each {ITxEvent event ->
|
||||
Tx tx = event.transaction
|
||||
def rowIdx = 0
|
||||
@ -96,24 +95,41 @@ class TxStream extends HierNode implements ITxStream {
|
||||
|
||||
private putEvent(ITxEvent event){
|
||||
if(!events.containsKey(event.time))
|
||||
events.put(event.time, [event])
|
||||
else
|
||||
events[event.time]<<event
|
||||
events.put(event.time, [event] as IEvent[])
|
||||
else {
|
||||
def entries = events[event.time] as List
|
||||
entries<<event
|
||||
events.put(event.time, entries as IEvent[])
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NavigableMap getEvents() {
|
||||
public NavigableMap<Long, IEvent[]> getEvents() {
|
||||
return events;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection getWaveformEventsAtTime(Long time) {
|
||||
public IEvent[] getEventsAtTime(Long time) {
|
||||
return events.get(time);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean equals(IWaveform other) {
|
||||
public boolean isSame(IWaveform other) {
|
||||
return(other instanceof TxStream && this.getId()==other.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEvent[] getEventsBeforeTime(Long time) {
|
||||
Entry<Long, IEvent[]> e = events.floorEntry(time);
|
||||
if(e==null)
|
||||
return null;
|
||||
else
|
||||
return events.floorEntry(time).getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public WaveformType getType() {
|
||||
return WaveformType.TRANSACTION;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: SWT widget
|
||||
Bundle-SymbolicName: com.minres.scviewer.database.ui.swt
|
||||
Bundle-Version: 2.3.1.qualifier
|
||||
Bundle-Version: 3.0.0.qualifier
|
||||
Bundle-Vendor: MINRES Technologies GmbH
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
|
||||
Require-Bundle: org.eclipse.swt;bundle-version="3.103.1",
|
||||
|
@ -8,5 +8,5 @@
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
<version>2.3.1-SNAPSHOT</version>
|
||||
<version>3.0.0-SNAPSHOT</version>
|
||||
</project>
|
||||
|
@ -0,0 +1,17 @@
|
||||
package com.minres.scviewer.database.ui;
|
||||
|
||||
import org.eclipse.swt.graphics.Color;
|
||||
import org.eclipse.swt.graphics.Font;
|
||||
|
||||
public interface IWaveformStyleProvider {
|
||||
|
||||
Font getNameFont();
|
||||
|
||||
Font getNameFontHighlite();
|
||||
|
||||
int getTrackHeight();
|
||||
|
||||
Color getColor(WaveformColors type);
|
||||
|
||||
Color[] computeColor(String name);
|
||||
}
|
@ -11,7 +11,6 @@
|
||||
package com.minres.scviewer.database.ui;
|
||||
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
@ -19,7 +18,6 @@ import org.eclipse.jface.viewers.ISelectionChangedListener;
|
||||
import org.eclipse.jface.viewers.ISelectionProvider;
|
||||
import org.eclipse.swt.events.DisposeListener;
|
||||
import org.eclipse.swt.graphics.Point;
|
||||
import org.eclipse.swt.graphics.RGB;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
|
||||
import com.minres.scviewer.database.IWaveform;
|
||||
@ -37,6 +35,8 @@ public interface IWaveformView extends PropertyChangeListener, ISelectionProvide
|
||||
|
||||
public void removeSelectionChangedListener(ISelectionChangedListener listener);
|
||||
|
||||
public void setStyleProvider(IWaveformStyleProvider styleProvider);
|
||||
|
||||
public void update();
|
||||
|
||||
public Control getControl();
|
||||
@ -103,8 +103,6 @@ public interface IWaveformView extends PropertyChangeListener, ISelectionProvide
|
||||
|
||||
public List<ICursor> getCursorList();
|
||||
|
||||
public void setColors(HashMap<WaveformColors, RGB> colourMap);
|
||||
|
||||
public long getBaselineTime();
|
||||
|
||||
public void setBaselineTime(Long scale);
|
||||
@ -114,4 +112,6 @@ public interface IWaveformView extends PropertyChangeListener, ISelectionProvide
|
||||
public void addDisposeListener( DisposeListener listener );
|
||||
|
||||
public void deleteSelectedTracks();
|
||||
|
||||
public TrackEntry addWaveform(IWaveform waveform, int pos);
|
||||
}
|
@ -14,4 +14,6 @@ import org.eclipse.swt.widgets.Composite;
|
||||
|
||||
public interface IWaveformViewFactory {
|
||||
public IWaveformView createPanel(Composite parent);
|
||||
|
||||
public IWaveformView createPanel(Composite parent, IWaveformStyleProvider styleProvider);
|
||||
}
|
||||
|
@ -11,66 +11,11 @@
|
||||
package com.minres.scviewer.database.ui;
|
||||
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
import com.minres.scviewer.database.ISignal;
|
||||
import com.minres.scviewer.database.ITxEvent;
|
||||
import com.minres.scviewer.database.ITxStream;
|
||||
import com.minres.scviewer.database.IWaveform;
|
||||
|
||||
public class TrackEntry {
|
||||
|
||||
// color info
|
||||
public static Color fallbackColor = new Color(200,0,0);
|
||||
public static Color highlightedFallbackColor = new Color(255,0,0);
|
||||
private Color[]signalColors;
|
||||
|
||||
// list of random colors
|
||||
private static Color[][] randomColors = {
|
||||
{ new Color( 170, 66, 37 ), new Color ( 190, 66, 37 ) },
|
||||
{ new Color( 96, 74, 110 ), new Color ( 96, 74, 130 ) },
|
||||
{ new Color( 133, 105, 128 ), new Color ( 153, 105, 128 ) },
|
||||
{ new Color( 0, 126, 135 ), new Color ( 0, 126, 155 ) },
|
||||
{ new Color( 243, 146, 75 ), new Color ( 255, 146, 75 ) },
|
||||
{ new Color( 206, 135, 163 ), new Color ( 226, 135, 163 ) },
|
||||
{ new Color( 124, 103, 74 ), new Color ( 144, 103, 74 ) },
|
||||
{ new Color( 194, 187, 169 ), new Color ( 214, 187, 169 ) },
|
||||
{ new Color( 104, 73, 71 ), new Color ( 124, 73, 71 ) },
|
||||
{ new Color( 75, 196, 213 ), new Color ( 75, 196, 233 ) },
|
||||
{ new Color( 206, 232, 229 ), new Color ( 206, 252, 229 ) },
|
||||
{ new Color( 169, 221, 199 ), new Color ( 169, 241, 199 ) },
|
||||
{ new Color( 100, 165, 197 ), new Color ( 100, 165, 217 ) },
|
||||
{ new Color( 150, 147, 178 ), new Color ( 150, 147, 198 ) },
|
||||
{ new Color( 200, 222, 182 ), new Color ( 200, 242, 182 ) },
|
||||
{ new Color( 147, 208, 197 ), new Color ( 147, 228, 197 ) }
|
||||
};
|
||||
|
||||
public static Color[] computeColor (String streamValue, Color fallback, Color highlightedFallback) {
|
||||
|
||||
Color[]result = new Color[2];
|
||||
|
||||
result[0] = fallback;
|
||||
result[1] = highlightedFallback;
|
||||
|
||||
// assign "random" color here, one name always results in the same color!
|
||||
if( streamValue!=null && randomColors.length > 0 ) {
|
||||
int index = Math.abs(streamValue.hashCode()) % randomColors.length;
|
||||
result[0] = randomColors[index][0];
|
||||
result[1] = randomColors[index][1];
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
public void setColor(Color changedColor, Color highlightColor) {
|
||||
signalColors[0] = changedColor;
|
||||
signalColors[1] = highlightColor;
|
||||
}
|
||||
|
||||
public Color[] getColors() {
|
||||
return signalColors;
|
||||
}
|
||||
IWaveformStyleProvider styleProvider;
|
||||
|
||||
public enum ValueDisplay {
|
||||
DEFAULT, SIGNED, UNSIGNED
|
||||
@ -95,32 +40,14 @@ public class TrackEntry {
|
||||
|
||||
public WaveDisplay waveDisplay = WaveDisplay.DEFAULT;
|
||||
|
||||
public TrackEntry(IWaveform waveform) {
|
||||
public TrackEntry(IWaveform waveform, IWaveformStyleProvider styleProvider) {
|
||||
this.waveform = waveform;
|
||||
this.styleProvider=styleProvider;
|
||||
vOffset=0;
|
||||
height=0;
|
||||
selected=false;
|
||||
signalColors = new Color[2];
|
||||
signalColors[0] = fallbackColor;
|
||||
signalColors[1] = highlightedFallbackColor;
|
||||
}
|
||||
|
||||
public boolean isStream(){
|
||||
return waveform instanceof ITxStream<?>;
|
||||
}
|
||||
|
||||
public ITxStream<? extends ITxEvent> getStream(){
|
||||
return (ITxStream<?>) waveform;
|
||||
}
|
||||
|
||||
public boolean isSignal(){
|
||||
return waveform instanceof ISignal<?>;
|
||||
}
|
||||
|
||||
public ISignal<?> getSignal(){
|
||||
return (ISignal<?>) waveform;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if(obj instanceof TrackEntry){
|
||||
|
@ -2,11 +2,13 @@ package com.minres.scviewer.database.ui.swt;
|
||||
|
||||
public class Constants {
|
||||
|
||||
public static final String[] unitString={"fs", "ps", "ns", "us", "ms"};//, "s"};
|
||||
public static final String[] UNIT_STRING={"fs", "ps", "ns", "us", "ms"};//, "s"};
|
||||
|
||||
public static final int[] unitMultiplier={1, 3, 10, 30, 100, 300};
|
||||
public static final int[] UNIT_MULTIPLIER={1, 3, 10, 30, 100, 300};
|
||||
|
||||
public static final String CONTENT_PROVIDER_TAG = "TOOLTIP_CONTENT_PROVIDER";
|
||||
public static final String HELP_PROVIDER_TAG = "TOOLTIP_HELP_PROVIDER";
|
||||
|
||||
private Constants() {}
|
||||
|
||||
}
|
||||
|
@ -16,12 +16,14 @@ import org.eclipse.core.runtime.Status;
|
||||
import org.osgi.framework.BundleContext;
|
||||
|
||||
public class DatabaseUiPlugin extends Plugin {
|
||||
|
||||
public void start(BundleContext context) throws Exception {
|
||||
getLog().log(new Status(IStatus.OK, "org.eclipse.e4.core", "Starting org.eclipse.e4.core bundle..."));
|
||||
}
|
||||
|
||||
public void stop(BundleContext context) throws Exception {
|
||||
getLog().log(new Status(IStatus.OK, "org.eclipse.e4.core", "Stopping org.eclipse.e4.core bundle..."));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start(BundleContext context) throws Exception {
|
||||
getLog().log(new Status(IStatus.OK, "org.eclipse.e4.core", "Starting org.eclipse.e4.core bundle..."));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop(BundleContext context) throws Exception {
|
||||
getLog().log(new Status(IStatus.OK, "org.eclipse.e4.core", "Stopping org.eclipse.e4.core bundle..."));
|
||||
}
|
||||
}
|
@ -0,0 +1,91 @@
|
||||
package com.minres.scviewer.database.ui.swt;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.graphics.Color;
|
||||
import org.eclipse.swt.graphics.Font;
|
||||
import org.eclipse.swt.graphics.RGB;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.wb.swt.SWTResourceManager;
|
||||
|
||||
import com.minres.scviewer.database.ui.IWaveformStyleProvider;
|
||||
import com.minres.scviewer.database.ui.WaveformColors;
|
||||
|
||||
public class DefaultWaveformStyleProvider implements IWaveformStyleProvider {
|
||||
|
||||
Composite parent;
|
||||
|
||||
private Font nameFont;
|
||||
|
||||
private Font nameFontB;
|
||||
|
||||
Color[] colors = new Color[WaveformColors.values().length];
|
||||
|
||||
public DefaultWaveformStyleProvider() {
|
||||
nameFont = Display.getCurrent().getSystemFont();
|
||||
nameFontB = SWTResourceManager.getBoldFont(nameFont);
|
||||
colors[WaveformColors.LINE.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED);
|
||||
colors[WaveformColors.LINE_HIGHLITE.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_CYAN);
|
||||
colors[WaveformColors.TRACK_BG_EVEN.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_BLACK);
|
||||
colors[WaveformColors.TRACK_BG_ODD.ordinal()] = SWTResourceManager.getColor(40, 40, 40);
|
||||
colors[WaveformColors.TRACK_BG_HIGHLITE.ordinal()] = SWTResourceManager.getColor(40, 40, 80);
|
||||
colors[WaveformColors.TX_BG.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GREEN);
|
||||
colors[WaveformColors.TX_BG_HIGHLITE.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_GREEN);
|
||||
colors[WaveformColors.TX_BORDER.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED);
|
||||
colors[WaveformColors.SIGNAL0.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GREEN);
|
||||
colors[WaveformColors.SIGNAL1.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GREEN);
|
||||
colors[WaveformColors.SIGNALZ.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_YELLOW);
|
||||
colors[WaveformColors.SIGNALX.ordinal()] = SWTResourceManager.getColor(255, 51, 51);
|
||||
colors[WaveformColors.SIGNALU.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_YELLOW);
|
||||
colors[WaveformColors.SIGNAL_TEXT.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_WHITE);
|
||||
colors[WaveformColors.SIGNAL_REAL.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_YELLOW);
|
||||
colors[WaveformColors.SIGNAL_NAN.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED);
|
||||
colors[WaveformColors.CURSOR.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED);
|
||||
colors[WaveformColors.CURSOR_DRAG.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GRAY);
|
||||
colors[WaveformColors.CURSOR_TEXT.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_WHITE);
|
||||
colors[WaveformColors.MARKER.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_GRAY);
|
||||
colors[WaveformColors.MARKER_TEXT.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_WHITE);
|
||||
colors[WaveformColors.REL_ARROW.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_MAGENTA);
|
||||
colors[WaveformColors.REL_ARROW_HIGHLITE.ordinal()] = SWTResourceManager.getColor(255, 128, 255);
|
||||
}
|
||||
/**
|
||||
* needs redraw() afterwards
|
||||
* @param colourMap
|
||||
*/
|
||||
public void initColors(Map<WaveformColors, RGB> colourMap) {
|
||||
Display d = parent.getDisplay();
|
||||
if (colourMap != null) {
|
||||
for (WaveformColors c : WaveformColors.values()) {
|
||||
if (colourMap.containsKey(c))
|
||||
colors[c.ordinal()] = new Color(d, colourMap.get(c));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Font getNameFont() {
|
||||
return nameFont;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Font getNameFontHighlite() {
|
||||
return nameFontB;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTrackHeight() {
|
||||
return 50;
|
||||
}
|
||||
@Override
|
||||
public Color getColor(WaveformColors type) {
|
||||
return colors[type.ordinal()];
|
||||
}
|
||||
@Override
|
||||
public Color[] computeColor(String name) {
|
||||
return new Color[] {SWTResourceManager.getColor( 200,0,0), SWTResourceManager.getColor( 255,0,0)};
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -12,6 +12,7 @@ package com.minres.scviewer.database.ui.swt;
|
||||
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
|
||||
import com.minres.scviewer.database.ui.IWaveformStyleProvider;
|
||||
import com.minres.scviewer.database.ui.IWaveformView;
|
||||
import com.minres.scviewer.database.ui.IWaveformViewFactory;
|
||||
import com.minres.scviewer.database.ui.swt.internal.WaveformView;
|
||||
@ -20,7 +21,12 @@ public class WaveformViewFactory implements IWaveformViewFactory {
|
||||
|
||||
@Override
|
||||
public IWaveformView createPanel(Composite parent) {
|
||||
return new WaveformView(parent);
|
||||
return new WaveformView(parent, new DefaultWaveformStyleProvider());
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWaveformView createPanel(Composite parent, IWaveformStyleProvider styleProvider) {
|
||||
return new WaveformView(parent, styleProvider);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -21,17 +21,16 @@ import org.eclipse.swt.graphics.Point;
|
||||
import org.eclipse.swt.graphics.Rectangle;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
|
||||
import com.minres.scviewer.database.ITx;
|
||||
import com.minres.scviewer.database.ITxRelation;
|
||||
import com.minres.scviewer.database.ITxStream;
|
||||
import com.minres.scviewer.database.RelationType;
|
||||
import com.minres.scviewer.database.tx.ITx;
|
||||
import com.minres.scviewer.database.tx.ITxRelation;
|
||||
import com.minres.scviewer.database.ui.WaveformColors;
|
||||
|
||||
public class ArrowPainter implements IPainter {
|
||||
|
||||
private final int xCtrlOffset = 50;
|
||||
private static final float X_CTRL_OFFSET = 50;
|
||||
|
||||
private final int yCtrlOffset = 30;
|
||||
private int yCtrlOffset = 30;
|
||||
|
||||
private WaveformCanvas waveCanvas;
|
||||
|
||||
@ -83,14 +82,13 @@ public class ArrowPainter implements IPainter {
|
||||
deferUpdate = false;
|
||||
iRect.clear();
|
||||
oRect.clear();
|
||||
ITxStream<?> stream = tx.getStream();
|
||||
IWaveformPainter painter = waveCanvas.wave2painterMap.get(stream);
|
||||
IWaveformPainter painter = waveCanvas.wave2painterMap.get(tx.getStream());
|
||||
if (painter == null) { // stream has been added but painter not yet
|
||||
// created
|
||||
deferUpdate = true;
|
||||
return;
|
||||
}
|
||||
int laneHeight = painter.getHeight() / stream.getMaxConcurrency();
|
||||
int laneHeight = painter.getHeight() / tx.getStream().getWidth();
|
||||
txRectangle = new Rectangle((int) (tx.getBeginTime() / scaleFactor),
|
||||
waveCanvas.rulerHeight + painter.getVerticalOffset() + laneHeight * tx.getConcurrencyIndex(),
|
||||
(int) ((tx.getEndTime() - tx.getBeginTime()) / scaleFactor), laneHeight);
|
||||
@ -102,13 +100,13 @@ public class ArrowPainter implements IPainter {
|
||||
for (ITxRelation iTxRelation : relations) {
|
||||
ITx otherTx = useTarget ? iTxRelation.getTarget() : iTxRelation.getSource();
|
||||
if (waveCanvas.wave2painterMap.containsKey(otherTx.getStream())) {
|
||||
ITxStream<?> stream = otherTx.getStream();
|
||||
IWaveformPainter painter = waveCanvas.wave2painterMap.get(stream);
|
||||
int laneHeight = painter.getHeight() / stream.getMaxConcurrency();
|
||||
Rectangle bb = new Rectangle((int) (otherTx.getBeginTime() / scaleFactor),
|
||||
waveCanvas.rulerHeight + painter.getVerticalOffset()
|
||||
+ laneHeight * otherTx.getConcurrencyIndex(),
|
||||
(int) ((otherTx.getEndTime() - otherTx.getBeginTime()) / scaleFactor), laneHeight);
|
||||
IWaveformPainter painter = waveCanvas.wave2painterMap.get(otherTx.getStream());
|
||||
int height = waveCanvas.styleProvider.getTrackHeight();
|
||||
Rectangle bb = new Rectangle(
|
||||
(int) (otherTx.getBeginTime() / scaleFactor),
|
||||
waveCanvas.rulerHeight + painter.getVerticalOffset() + height * otherTx.getConcurrencyIndex(),
|
||||
(int) ((otherTx.getEndTime() - otherTx.getBeginTime()) / scaleFactor),
|
||||
height);
|
||||
res.add(new LinkEntry(bb, iTxRelation.getRelationType()));
|
||||
}
|
||||
}
|
||||
@ -116,8 +114,9 @@ public class ArrowPainter implements IPainter {
|
||||
|
||||
@Override
|
||||
public void paintArea(Projection proj, Rectangle clientRect) {
|
||||
Color fgColor = waveCanvas.colors[WaveformColors.REL_ARROW.ordinal()];
|
||||
Color highliteColor = waveCanvas.colors[WaveformColors.REL_ARROW_HIGHLITE.ordinal()];
|
||||
yCtrlOffset = waveCanvas.styleProvider.getTrackHeight()/2;
|
||||
Color fgColor = waveCanvas.styleProvider.getColor(WaveformColors.REL_ARROW);
|
||||
Color highliteColor = waveCanvas.styleProvider.getColor(WaveformColors.REL_ARROW_HIGHLITE);
|
||||
|
||||
if(tx==null) return;
|
||||
if (!deferUpdate) {
|
||||
@ -152,10 +151,10 @@ public class ArrowPainter implements IPainter {
|
||||
path.moveTo(point1.x, point1.y);
|
||||
if (point1.y == point2.y) {
|
||||
Point center = new Point((point1.x + point2.x) / 2, point1.y - yCtrlOffset);
|
||||
path.cubicTo(point1.x + xCtrlOffset, point1.y, center.x - xCtrlOffset, center.y, center.x, center.y);
|
||||
path.cubicTo(center.x + xCtrlOffset, center.y, point2.x - xCtrlOffset, point2.y, point2.x, point2.y);
|
||||
path.cubicTo(point1.x + X_CTRL_OFFSET, point1.y, center.x - X_CTRL_OFFSET, center.y, center.x, center.y);
|
||||
path.cubicTo(center.x + X_CTRL_OFFSET, center.y, point2.x - X_CTRL_OFFSET, point2.y, point2.x, point2.y);
|
||||
} else
|
||||
path.cubicTo(point1.x + xCtrlOffset, point1.y, point2.x - xCtrlOffset, point2.y, point2.x, point2.y);
|
||||
path.cubicTo(point1.x + X_CTRL_OFFSET, point1.y, point2.x - X_CTRL_OFFSET, point2.y, point2.x, point2.y);
|
||||
|
||||
proj.setAntialias(SWT.ON);
|
||||
proj.setForeground(fgColor);
|
||||
@ -168,8 +167,8 @@ public class ArrowPainter implements IPainter {
|
||||
}
|
||||
|
||||
class LinkEntry {
|
||||
public Rectangle rectangle;
|
||||
public RelationType relationType;
|
||||
public final Rectangle rectangle;
|
||||
public final RelationType relationType;
|
||||
|
||||
public LinkEntry(Rectangle rectangle, RelationType relationType) {
|
||||
super();
|
||||
|
@ -63,7 +63,7 @@ public class CursorPainter implements IPainter, ICursor {
|
||||
|
||||
public void paintArea(Projection proj, Rectangle clientRect) {
|
||||
Rectangle area = proj.unProject(clientRect);
|
||||
if(this.waveCanvas.painterList.size()>0){
|
||||
if(!waveCanvas.painterList.isEmpty()){
|
||||
|
||||
long scaleFactor=waveCanvas.getScaleFactor();
|
||||
long beginPos = area.x;
|
||||
@ -75,15 +75,15 @@ public class CursorPainter implements IPainter, ICursor {
|
||||
int x = (int) (time/scaleFactor);
|
||||
// distance of marker from the top of Canvas' painting area
|
||||
int top = id<0?area.y:area.y+15;
|
||||
Color drawColor=waveCanvas.colors[id<0?WaveformColors.CURSOR.ordinal():WaveformColors.MARKER.ordinal()];
|
||||
Color dragColor = waveCanvas.colors[WaveformColors.CURSOR_DRAG.ordinal()];
|
||||
Color textColor=waveCanvas.colors[id<0?WaveformColors.CURSOR_TEXT.ordinal():WaveformColors.MARKER_TEXT.ordinal()];
|
||||
Color drawColor=waveCanvas.styleProvider.getColor(id<0?WaveformColors.CURSOR:WaveformColors.MARKER);
|
||||
Color dragColor = waveCanvas.styleProvider.getColor(WaveformColors.CURSOR_DRAG);
|
||||
Color textColor=waveCanvas.styleProvider.getColor(id<0?WaveformColors.CURSOR_TEXT:WaveformColors.MARKER_TEXT);
|
||||
if(x>=beginPos && x<=maxValX){
|
||||
proj.setForeground(isDragging?dragColor:drawColor);
|
||||
proj.drawLine(x, top, x, area.y+area.height);
|
||||
proj.setBackground(drawColor);
|
||||
proj.setForeground(textColor);
|
||||
Double dTime=new Double(time);
|
||||
double dTime=time;
|
||||
proj.drawText((dTime/waveCanvas.getScaleFactorPow10())+waveCanvas.getUnitStr(), x+1, top);
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ public class ObservableList<E> implements List<E> {
|
||||
public static final String CONTENT_PROPERTY = "content";
|
||||
|
||||
public ObservableList() {
|
||||
this(new ArrayList<E>());
|
||||
this(new ArrayList<>());
|
||||
}
|
||||
|
||||
public ObservableList(List<E> delegate) {
|
||||
@ -100,7 +100,7 @@ public class ObservableList<E> implements List<E> {
|
||||
|
||||
boolean success = this.delegate.addAll(c);
|
||||
if ((success) && (c != null)) {
|
||||
List<E> values = new ArrayList<E>();
|
||||
List<E> values = new ArrayList<>();
|
||||
for (Iterator<? extends E> i = c.iterator(); i.hasNext();) {
|
||||
values.add(i.next());
|
||||
}
|
||||
@ -118,7 +118,7 @@ public class ObservableList<E> implements List<E> {
|
||||
boolean success = this.delegate.addAll(index, c);
|
||||
|
||||
if ((success) && (c != null)) {
|
||||
List<E> values = new ArrayList<E>();
|
||||
List<E> values = new ArrayList<>();
|
||||
for (Iterator<? extends E> i = c.iterator(); i.hasNext();) {
|
||||
values.add(i.next());
|
||||
}
|
||||
@ -133,7 +133,7 @@ public class ObservableList<E> implements List<E> {
|
||||
|
||||
public void clear() {
|
||||
int oldSize = size();
|
||||
List<E> values = new ArrayList<E>();
|
||||
List<E> values = new ArrayList<>();
|
||||
values.addAll(this.delegate);
|
||||
this.delegate.clear();
|
||||
if (!(values.isEmpty())) {
|
||||
@ -215,14 +215,12 @@ public class ObservableList<E> implements List<E> {
|
||||
return false;
|
||||
}
|
||||
|
||||
List<E> values = new ArrayList<E>();
|
||||
if (c != null) {
|
||||
for (Iterator<?> i = c.iterator(); i.hasNext();) {
|
||||
@SuppressWarnings("unchecked")
|
||||
E element = (E) i.next();
|
||||
if (this.delegate.contains(element)) {
|
||||
values.add(element);
|
||||
}
|
||||
List<E> values = new ArrayList<>();
|
||||
for (Iterator<?> i = c.iterator(); i.hasNext();) {
|
||||
@SuppressWarnings("unchecked")
|
||||
E element = (E) i.next();
|
||||
if (this.delegate.contains(element)) {
|
||||
values.add(element);
|
||||
}
|
||||
}
|
||||
|
||||
@ -241,14 +239,12 @@ public class ObservableList<E> implements List<E> {
|
||||
return false;
|
||||
}
|
||||
|
||||
List<E> values = new ArrayList<E>();
|
||||
List<E> values = new ArrayList<>();
|
||||
Iterator<? extends E> i;
|
||||
if (c != null) {
|
||||
for (i = this.delegate.iterator(); i.hasNext();) {
|
||||
E element = i.next();
|
||||
if (!(c.contains(element))) {
|
||||
values.add(element);
|
||||
}
|
||||
for (i = this.delegate.iterator(); i.hasNext();) {
|
||||
E element = i.next();
|
||||
if (!(c.contains(element))) {
|
||||
values.add(element);
|
||||
}
|
||||
}
|
||||
|
||||
@ -327,7 +323,7 @@ public class ObservableList<E> implements List<E> {
|
||||
*/
|
||||
private static final long serialVersionUID = 7819626246672640599L;
|
||||
|
||||
private List<Object> values = new ArrayList<Object>();
|
||||
private List<Object> values = new ArrayList<>();
|
||||
|
||||
public MultiElementUpdatedEvent(Object source, List<?> values) {
|
||||
super(source, ObservableList.ChangeType.oldValue, ObservableList.ChangeType.newValue, 0,
|
||||
@ -336,7 +332,7 @@ public class ObservableList<E> implements List<E> {
|
||||
this.values.addAll(values);
|
||||
}
|
||||
|
||||
public List<?> getValues() {
|
||||
public List<Object> getValues() {
|
||||
return Collections.unmodifiableList(this.values);
|
||||
}
|
||||
}
|
||||
@ -347,7 +343,7 @@ public class ObservableList<E> implements List<E> {
|
||||
*/
|
||||
private static final long serialVersionUID = 7819626246672640599L;
|
||||
|
||||
private List<Object> values = new ArrayList<Object>();
|
||||
private List<Object> values = new ArrayList<>();
|
||||
|
||||
public MultiElementRemovedEvent(Object source, List<?> values) {
|
||||
super(source, ObservableList.ChangeType.oldValue, ObservableList.ChangeType.newValue, 0,
|
||||
@ -356,7 +352,7 @@ public class ObservableList<E> implements List<E> {
|
||||
this.values.addAll(values);
|
||||
}
|
||||
|
||||
public List<?> getValues() {
|
||||
public List<Object> getValues() {
|
||||
return Collections.unmodifiableList(this.values);
|
||||
}
|
||||
}
|
||||
@ -366,7 +362,7 @@ public class ObservableList<E> implements List<E> {
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -116376519087713082L;
|
||||
private List<Object> values = new ArrayList<Object>();
|
||||
private List<Object> values = new ArrayList<>();
|
||||
|
||||
public MultiElementAddedEvent(Object source, int index, List<?> values) {
|
||||
super(source, ObservableList.ChangeType.oldValue, ObservableList.ChangeType.newValue, index,
|
||||
@ -375,7 +371,7 @@ public class ObservableList<E> implements List<E> {
|
||||
this.values.addAll(values);
|
||||
}
|
||||
|
||||
public List<?> getValues() {
|
||||
public List<Object> getValues() {
|
||||
return Collections.unmodifiableList(this.values);
|
||||
}
|
||||
}
|
||||
@ -385,7 +381,7 @@ public class ObservableList<E> implements List<E> {
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -8654027608903811577L;
|
||||
private List<Object> values = new ArrayList<Object>();
|
||||
private List<Object> values = new ArrayList<>();
|
||||
|
||||
public ElementClearedEvent(Object source, List<?> values) {
|
||||
super(source, ObservableList.ChangeType.oldValue, ObservableList.ChangeType.newValue, 0,
|
||||
@ -394,7 +390,7 @@ public class ObservableList<E> implements List<E> {
|
||||
this.values.addAll(values);
|
||||
}
|
||||
|
||||
public List<?> getValues() {
|
||||
public List<Object> getValues() {
|
||||
return Collections.unmodifiableList(this.values);
|
||||
}
|
||||
}
|
||||
@ -432,7 +428,7 @@ public class ObservableList<E> implements List<E> {
|
||||
}
|
||||
}
|
||||
|
||||
public static abstract class ElementEvent extends PropertyChangeEvent {
|
||||
public abstract static class ElementEvent extends PropertyChangeEvent {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@ -441,7 +437,7 @@ public class ObservableList<E> implements List<E> {
|
||||
private final int index;
|
||||
|
||||
public ElementEvent(Object source, Object oldValue, Object newValue, int index, ObservableList.ChangeType type) {
|
||||
super(source, "content", oldValue, newValue);
|
||||
super(source, CONTENT_PROPERTY, oldValue, newValue);
|
||||
this.type = type;
|
||||
this.index = index;
|
||||
}
|
||||
@ -463,7 +459,7 @@ public class ObservableList<E> implements List<E> {
|
||||
}
|
||||
}
|
||||
|
||||
public static enum ChangeType {
|
||||
public enum ChangeType {
|
||||
ADDED, UPDATED, REMOVED, CLEARED, MULTI_ADD, MULTI_UPDATED, MULTI_REMOVE, NONE;
|
||||
|
||||
public static final Object oldValue;
|
||||
@ -483,9 +479,9 @@ public class ObservableList<E> implements List<E> {
|
||||
return MULTI_REMOVE;
|
||||
case 6:
|
||||
return NONE;
|
||||
case 1:
|
||||
default:
|
||||
return UPDATED;
|
||||
}
|
||||
return UPDATED;
|
||||
}
|
||||
|
||||
static {
|
||||
@ -554,6 +550,7 @@ public class ObservableList<E> implements List<E> {
|
||||
return this.iterDelegate.next();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
int oldSize = ObservableList.this.size();
|
||||
Object element = ObservableList.this.get(this.cursor);
|
||||
|
@ -14,8 +14,8 @@ import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.List;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
import com.minres.scviewer.database.ITx;
|
||||
import com.minres.scviewer.database.ITxRelation;
|
||||
import com.minres.scviewer.database.tx.ITx;
|
||||
import com.minres.scviewer.database.tx.ITxRelation;
|
||||
|
||||
class RelSelectionDialog extends Dialog {
|
||||
private java.util.List<ITxRelation> entries;
|
||||
@ -24,7 +24,7 @@ class RelSelectionDialog extends Dialog {
|
||||
|
||||
private ITxRelation selected = null;
|
||||
|
||||
public RelSelectionDialog(Shell shell, ArrayList<ITxRelation> candidates, boolean target) {
|
||||
public RelSelectionDialog(Shell shell, java.util.List<ITxRelation> candidates, boolean target) {
|
||||
super(shell);
|
||||
entries = candidates;
|
||||
entryTx = entries.stream().map(r->target?r.getTarget():r.getSource()).collect(Collectors.toCollection(ArrayList::new));
|
||||
|
@ -21,8 +21,8 @@ import org.eclipse.wb.swt.SWTResourceManager;
|
||||
public class RulerPainter implements IPainter {
|
||||
protected WaveformCanvas waveCanvas;
|
||||
|
||||
static final int rulerTickMinorC = 10;
|
||||
static final int rulerTickMajorC = 100;
|
||||
static final int RULER_TICK_MINOR = 10;
|
||||
static final int RULER_TICK_MAJOR = 100;
|
||||
|
||||
static final DecimalFormat df = new DecimalFormat("#.00####");
|
||||
|
||||
@ -47,8 +47,8 @@ public class RulerPainter implements IPainter {
|
||||
long startVal=startPos - proj.getTranslation().x*scaleFactor;
|
||||
long endPos=startPos+area.width*scaleFactor;
|
||||
|
||||
long rulerTickMinor = rulerTickMinorC*scaleFactor;
|
||||
long rulerTickMajor = rulerTickMajorC*scaleFactor;
|
||||
long rulerTickMinor = RULER_TICK_MINOR*scaleFactor;
|
||||
long rulerTickMajor = RULER_TICK_MAJOR*scaleFactor;
|
||||
|
||||
int minorTickY = waveCanvas.rulerHeight-5;
|
||||
int majorTickY = waveCanvas.rulerHeight-15;
|
||||
@ -68,13 +68,13 @@ public class RulerPainter implements IPainter {
|
||||
gc.drawLine(area.x, area.y+bottom, area.x+area.width, area.y+bottom);
|
||||
|
||||
for (long pos = startMinorIncrPos, tick = startMinorIncrVal; pos < endPos; pos+= rulerTickMinor, tick += rulerTickMinor) {
|
||||
int x0_pos = (int) (pos/scaleFactor);
|
||||
long x0_val = tick/scaleFactor;
|
||||
int x0Pos = (int) (pos/scaleFactor);
|
||||
long x0Val = tick/scaleFactor;
|
||||
if ((tick % rulerTickMajor) == 0) {
|
||||
gc.drawText(df.format(x0_val*unitMultiplier)+unit, x0_pos, area.y+textY);
|
||||
gc.drawLine(x0_pos, area.y+majorTickY, x0_pos,area.y+ bottom);
|
||||
gc.drawText(df.format(x0Val*unitMultiplier)+unit, x0Pos, area.y+textY);
|
||||
gc.drawLine(x0Pos, area.y+majorTickY, x0Pos,area.y+ bottom);
|
||||
} else {
|
||||
gc.drawLine(x0_pos, area.y+minorTickY, x0_pos, area.y+bottom);
|
||||
gc.drawLine(x0Pos, area.y+minorTickY, x0Pos, area.y+bottom);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,7 @@
|
||||
*******************************************************************************/
|
||||
package com.minres.scviewer.database.ui.swt.internal;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.NavigableMap;
|
||||
@ -24,26 +25,28 @@ import org.eclipse.swt.graphics.Point;
|
||||
import org.eclipse.swt.graphics.Rectangle;
|
||||
|
||||
import com.minres.scviewer.database.BitVector;
|
||||
import com.minres.scviewer.database.ISignal;
|
||||
import com.minres.scviewer.database.DoubleVal;
|
||||
import com.minres.scviewer.database.IEvent;
|
||||
import com.minres.scviewer.database.IWaveform;
|
||||
import com.minres.scviewer.database.ui.TrackEntry;
|
||||
import com.minres.scviewer.database.ui.WaveformColors;
|
||||
|
||||
public class SignalPainter extends TrackPainter {
|
||||
private class SignalChange {
|
||||
long time;
|
||||
Object value;
|
||||
IEvent value;
|
||||
boolean fromMap;
|
||||
|
||||
public SignalChange(Entry<Long, ?> entry) {
|
||||
public SignalChange(Entry<Long, IEvent[]> entry) {
|
||||
time = entry.getKey();
|
||||
value = entry.getValue();
|
||||
value = entry.getValue()[0];
|
||||
fromMap = true;
|
||||
}
|
||||
|
||||
public void set(Entry<Long, ?> entry, Long actTime) {
|
||||
public void set(Entry<Long, IEvent[]> entry, Long actTime) {
|
||||
if (entry != null) {
|
||||
time = entry.getKey();
|
||||
value = entry.getValue();
|
||||
value = entry.getValue()[0];
|
||||
fromMap = true;
|
||||
} else {
|
||||
time = actTime;
|
||||
@ -84,11 +87,11 @@ public class SignalPainter extends TrackPainter {
|
||||
}
|
||||
|
||||
public void paintArea(Projection proj, Rectangle area) {
|
||||
ISignal<?> signal = trackEntry.getSignal();
|
||||
IWaveform signal = trackEntry.waveform;
|
||||
if (trackEntry.selected)
|
||||
proj.setBackground(this.waveCanvas.colors[WaveformColors.TRACK_BG_HIGHLITE.ordinal()]);
|
||||
proj.setBackground(this.waveCanvas.styleProvider.getColor(WaveformColors.TRACK_BG_HIGHLITE));
|
||||
else
|
||||
proj.setBackground(this.waveCanvas.colors[even ? WaveformColors.TRACK_BG_EVEN.ordinal() : WaveformColors.TRACK_BG_ODD.ordinal()]);
|
||||
proj.setBackground(this.waveCanvas.styleProvider.getColor(even ? WaveformColors.TRACK_BG_EVEN : WaveformColors.TRACK_BG_ODD));
|
||||
proj.setFillRule(SWT.FILL_EVEN_ODD);
|
||||
proj.fillRectangle(area);
|
||||
|
||||
@ -97,8 +100,8 @@ public class SignalPainter extends TrackPainter {
|
||||
long beginTime = beginPos*scaleFactor;
|
||||
long endTime = beginTime + area.width*scaleFactor;
|
||||
|
||||
Entry<Long, ?> first = signal.getEvents().floorEntry(beginTime);
|
||||
Entry<Long, ?> last = signal.getEvents().floorEntry(endTime);
|
||||
Entry<Long, IEvent[]> first = signal.getEvents().floorEntry(beginTime);
|
||||
Entry<Long, IEvent[]> last = signal.getEvents().floorEntry(endTime);
|
||||
if (first == null) {
|
||||
if (last == null)
|
||||
return;
|
||||
@ -106,16 +109,16 @@ public class SignalPainter extends TrackPainter {
|
||||
} else if (last == null) {
|
||||
last = signal.getEvents().lastEntry();
|
||||
}
|
||||
proj.setForeground(this.waveCanvas.colors[WaveformColors.LINE.ordinal()]);
|
||||
proj.setForeground(this.waveCanvas.styleProvider.getColor(WaveformColors.LINE));
|
||||
proj.setLineStyle(SWT.LINE_SOLID);
|
||||
proj.setLineWidth(1);
|
||||
NavigableMap<Long, ?> entries = signal.getEvents().subMap(first.getKey(), false, last.getKey(), true);
|
||||
NavigableMap<Long, IEvent[]> entries = signal.getEvents().subMap(first.getKey(), false, last.getKey(), true);
|
||||
SignalChange left = new SignalChange(first);
|
||||
SignalChange right = new SignalChange(entries.size() > 0 ? entries.firstEntry() : first);
|
||||
maxPosX = area.x + area.width;
|
||||
yOffsetT = this.waveCanvas.getTrackHeight() / 5 + area.y;
|
||||
yOffsetM = this.waveCanvas.getTrackHeight() / 2 + area.y;
|
||||
yOffsetB = 4 * this.waveCanvas.getTrackHeight() / 5 + area.y;
|
||||
yOffsetT = this.waveCanvas.styleProvider.getTrackHeight() / 5 + area.y;
|
||||
yOffsetM = this.waveCanvas.styleProvider.getTrackHeight() / 2 + area.y;
|
||||
yOffsetB = 4 * this.waveCanvas.styleProvider.getTrackHeight() / 5 + area.y;
|
||||
int xSigChangeBeginVal = Math.max(area.x, (int) (left.time / this.waveCanvas.getScaleFactor()));
|
||||
int xSigChangeBeginPos = area.x;
|
||||
int xSigChangeEndPos = Math.max(area.x, getXPosEnd(right.time));
|
||||
@ -138,7 +141,7 @@ public class SignalPainter extends TrackPainter {
|
||||
|
||||
|
||||
SignalStencil stencil = getStencil(proj.getGC(), left, entries);
|
||||
do {
|
||||
if(stencil!=null) do {
|
||||
stencil.draw(proj, area, left.value, right.value, xSigChangeBeginPos, xSigChangeEndPos, multiple);
|
||||
if (right.time >= endTime)
|
||||
break;
|
||||
@ -150,7 +153,7 @@ public class SignalPainter extends TrackPainter {
|
||||
if (xSigChangeEndPos == xSigChangeBeginPos) {
|
||||
multiple = true;
|
||||
long eTime = (xSigChangeBeginPos + 1) * this.waveCanvas.getScaleFactor();
|
||||
Entry<Long, ?> entry = entries.floorEntry(eTime);
|
||||
Entry<Long, IEvent[]> entry = entries.floorEntry(eTime);
|
||||
if(entry!=null && entry.getKey()> right.time)
|
||||
right.set(entry, endTime);
|
||||
xSigChangeEndPos = getXPosEnd(eTime);
|
||||
@ -158,8 +161,8 @@ public class SignalPainter extends TrackPainter {
|
||||
} while (left.time < endTime);
|
||||
}
|
||||
|
||||
private SignalStencil getStencil(GC gc, SignalChange left, NavigableMap<Long, ?> entries) {
|
||||
Object val = left.value;
|
||||
private SignalStencil getStencil(GC gc, SignalChange left, NavigableMap<Long, IEvent[]> entries) {
|
||||
IEvent val = left.value;
|
||||
if(val instanceof BitVector) {
|
||||
BitVector bv = (BitVector) val;
|
||||
if(bv.getWidth()==1)
|
||||
@ -170,7 +173,7 @@ public class SignalPainter extends TrackPainter {
|
||||
return new MultiBitStencilAnalog(entries, left.value,
|
||||
trackEntry.waveDisplay==TrackEntry.WaveDisplay.CONTINOUS,
|
||||
trackEntry.valueDisplay==TrackEntry.ValueDisplay.SIGNED);
|
||||
} else if (val instanceof Double)
|
||||
} else if (val instanceof DoubleVal)
|
||||
return new RealStencil(entries, left.value, trackEntry.waveDisplay==TrackEntry.WaveDisplay.CONTINOUS);
|
||||
else
|
||||
return null;
|
||||
@ -178,7 +181,7 @@ public class SignalPainter extends TrackPainter {
|
||||
|
||||
private interface SignalStencil {
|
||||
|
||||
public void draw(Projection proj, Rectangle area, Object left, Object right, int xBegin, int xEnd, boolean multiple);
|
||||
public void draw(Projection proj, Rectangle area, IEvent left, IEvent right, int xBegin, int xEnd, boolean multiple);
|
||||
}
|
||||
|
||||
private class MultiBitStencil implements SignalStencil {
|
||||
@ -192,13 +195,13 @@ public class SignalPainter extends TrackPainter {
|
||||
tmpAwtFont = new java.awt.Font(fd.getName(), fd.getStyle(), height);
|
||||
}
|
||||
|
||||
public void draw(Projection proj, Rectangle area, Object left, Object right, int xBegin, int xEnd, boolean multiple) {
|
||||
Color colorBorder = waveCanvas.colors[WaveformColors.SIGNAL0.ordinal()];
|
||||
public void draw(Projection proj, Rectangle area, IEvent left, IEvent right, int xBegin, int xEnd, boolean multiple) {
|
||||
Color colorBorder = waveCanvas.styleProvider.getColor(WaveformColors.SIGNAL0);
|
||||
BitVector last = (BitVector) left;
|
||||
if (last.getValue().toString().contains("X")) {
|
||||
colorBorder = waveCanvas.colors[WaveformColors.SIGNALX.ordinal()];
|
||||
} else if (last.getValue().toString().contains("Z")) {
|
||||
colorBorder = waveCanvas.colors[WaveformColors.SIGNALZ.ordinal()];
|
||||
if (Arrays.toString(last.getValue()).contains("X")) {
|
||||
colorBorder = waveCanvas.styleProvider.getColor(WaveformColors.SIGNALX);
|
||||
} else if (Arrays.toString(last.getValue()).contains("Z")) {
|
||||
colorBorder = waveCanvas.styleProvider.getColor(WaveformColors.SIGNALZ);
|
||||
}
|
||||
int width = xEnd - xBegin;
|
||||
if (width > 1) {
|
||||
@ -212,8 +215,7 @@ public class SignalPainter extends TrackPainter {
|
||||
};
|
||||
proj.setForeground(colorBorder);
|
||||
proj.drawPolygon(points);
|
||||
proj.setForeground(waveCanvas.colors[WaveformColors.SIGNAL_TEXT.ordinal()]);
|
||||
//TODO: this code should be provided from a central location
|
||||
proj.setForeground(waveCanvas.styleProvider.getColor(WaveformColors.SIGNAL_TEXT));
|
||||
String label = null;
|
||||
switch(trackEntry.valueDisplay) {
|
||||
case SIGNED:
|
||||
@ -247,35 +249,39 @@ public class SignalPainter extends TrackPainter {
|
||||
private class MultiBitStencilAnalog implements SignalStencil {
|
||||
|
||||
final boolean continous;
|
||||
final boolean signed;
|
||||
private long maxVal;
|
||||
private long minVal;
|
||||
private long range;
|
||||
double yRange = (yOffsetB-yOffsetT);
|
||||
public MultiBitStencilAnalog(NavigableMap<Long, ?> entries, Object left, boolean continous, boolean signed) {
|
||||
public MultiBitStencilAnalog(NavigableMap<Long, IEvent[]> entries, Object left, boolean continous, boolean signed) {
|
||||
this.continous=continous;
|
||||
Collection<?> values = ((NavigableMap<Long, ?>) entries).values();
|
||||
minVal=((BitVector) left).toUnsignedValue();
|
||||
range=2;
|
||||
this.signed=signed;
|
||||
Collection<IEvent[]> values = entries.values();
|
||||
minVal=signed?((BitVector)left).toSignedValue():((BitVector)left).toUnsignedValue();
|
||||
if(!values.isEmpty()) {
|
||||
long maxVal=minVal;
|
||||
for (Object e : entries.values()) {
|
||||
long v = ((BitVector)e).toUnsignedValue();
|
||||
maxVal=Math.max(maxVal, v);
|
||||
minVal=Math.min(minVal, v);
|
||||
}
|
||||
maxVal=minVal;
|
||||
for (IEvent[] tp : entries.values())
|
||||
for(IEvent e: tp) {
|
||||
long v = signed?((BitVector)e).toSignedValue():((BitVector)e).toUnsignedValue();
|
||||
maxVal=Math.max(maxVal, v);
|
||||
minVal=Math.min(minVal, v);
|
||||
}
|
||||
if(maxVal==minVal) {
|
||||
maxVal--;
|
||||
minVal++;
|
||||
}
|
||||
range = maxVal-minVal;
|
||||
} else
|
||||
} else {
|
||||
minVal--;
|
||||
maxVal=minVal+2;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void draw(Projection proj, Rectangle area, Object left, Object right, int xBegin, int xEnd, boolean multiple) {
|
||||
long leftVal = ((BitVector) left).toUnsignedValue();
|
||||
long rightVal= ((BitVector) right).toUnsignedValue();
|
||||
proj.setForeground(waveCanvas.colors[WaveformColors.SIGNAL_REAL.ordinal()]);
|
||||
public void draw(Projection proj, Rectangle area, IEvent left, IEvent right, int xBegin, int xEnd, boolean multiple) {
|
||||
long leftVal = signed?((BitVector)left).toSignedValue():((BitVector)left).toUnsignedValue();
|
||||
long rightVal= signed?((BitVector)right).toSignedValue():((BitVector)right).toUnsignedValue();
|
||||
proj.setForeground(waveCanvas.styleProvider.getColor(WaveformColors.SIGNAL_REAL));
|
||||
long range = maxVal-minVal;
|
||||
int yOffsetLeft = (int) ((leftVal-minVal) * yRange / range);
|
||||
int yOffsetRight = (int) ((rightVal-minVal) * yRange / range);
|
||||
if(continous) {
|
||||
@ -298,26 +304,26 @@ public class SignalPainter extends TrackPainter {
|
||||
}
|
||||
|
||||
private class SingleBitStencil implements SignalStencil {
|
||||
public void draw(Projection proj, Rectangle area, Object left, Object right, int xBegin, int xEnd, boolean multiple) {
|
||||
public void draw(Projection proj, Rectangle area, IEvent left, IEvent right, int xBegin, int xEnd, boolean multiple) {
|
||||
if (multiple) {
|
||||
proj.setForeground(waveCanvas.colors[WaveformColors.SIGNALU.ordinal()]);
|
||||
proj.setForeground(waveCanvas.styleProvider.getColor(WaveformColors.SIGNALU));
|
||||
proj.drawLine(xBegin, yOffsetT, xBegin, yOffsetB);
|
||||
if(xEnd>xBegin)
|
||||
proj.drawLine(xEnd, yOffsetT, xEnd, yOffsetB);
|
||||
} else {
|
||||
Color color = waveCanvas.colors[WaveformColors.SIGNALX.ordinal()];
|
||||
Color color = waveCanvas.styleProvider.getColor(WaveformColors.SIGNALX);
|
||||
int yOffset = yOffsetM;
|
||||
switch (((BitVector) left).getValue()[0]) {
|
||||
case '1':
|
||||
color = waveCanvas.colors[WaveformColors.SIGNAL1.ordinal()];
|
||||
color = waveCanvas.styleProvider.getColor(WaveformColors.SIGNAL1);
|
||||
yOffset = yOffsetT;
|
||||
break;
|
||||
case '0':
|
||||
color = waveCanvas.colors[WaveformColors.SIGNAL0.ordinal()];
|
||||
color = waveCanvas.styleProvider.getColor(WaveformColors.SIGNAL0);
|
||||
yOffset = yOffsetB;
|
||||
break;
|
||||
case 'Z':
|
||||
color = waveCanvas.colors[WaveformColors.SIGNALZ.ordinal()];
|
||||
color = waveCanvas.styleProvider.getColor(WaveformColors.SIGNALZ);
|
||||
break;
|
||||
default:
|
||||
}
|
||||
@ -345,30 +351,32 @@ public class SignalPainter extends TrackPainter {
|
||||
|
||||
private class RealStencil implements SignalStencil {
|
||||
|
||||
double minVal, range;
|
||||
double minVal;
|
||||
double range;
|
||||
|
||||
final double scaleFactor = 1.05;
|
||||
|
||||
boolean continous=true;
|
||||
|
||||
public RealStencil(NavigableMap<Long, ?> entries, Object left, boolean continous) {
|
||||
public RealStencil(NavigableMap<Long, IEvent[]> entries, Object left, boolean continous) {
|
||||
this.continous=continous;
|
||||
Collection<?> values = ((NavigableMap<Long, ?>) entries).values();
|
||||
Collection<IEvent[]> values = entries.values();
|
||||
minVal=(Double) left;
|
||||
range=2.0;
|
||||
if(!values.isEmpty()) {
|
||||
double maxVal=minVal;
|
||||
for (Object e : entries.values()) {
|
||||
double v = ((Double)e);
|
||||
if(Double.isNaN(maxVal))
|
||||
maxVal=v;
|
||||
else if(!Double.isNaN(v))
|
||||
maxVal=Math.max(maxVal, v);
|
||||
if(Double.isNaN(minVal))
|
||||
minVal=v;
|
||||
else if(!Double.isNaN(v))
|
||||
minVal=Math.min(minVal, v);
|
||||
}
|
||||
for (IEvent[] val : entries.values())
|
||||
for(IEvent e:val) {
|
||||
double v = ((DoubleVal)e).value;
|
||||
if(Double.isNaN(maxVal))
|
||||
maxVal=v;
|
||||
else if(!Double.isNaN(v))
|
||||
maxVal=Math.max(maxVal, v);
|
||||
if(Double.isNaN(minVal))
|
||||
minVal=v;
|
||||
else if(!Double.isNaN(v))
|
||||
minVal=Math.min(minVal, v);
|
||||
}
|
||||
if(Double.isNaN(maxVal)){
|
||||
maxVal=minVal=0.0;
|
||||
}
|
||||
@ -378,11 +386,11 @@ public class SignalPainter extends TrackPainter {
|
||||
}
|
||||
}
|
||||
|
||||
public void draw(Projection proj, Rectangle area, Object left, Object right, int xBegin, int xEnd, boolean multiple) {
|
||||
double leftVal = (Double) left;
|
||||
double rightVal= (Double) right;
|
||||
public void draw(Projection proj, Rectangle area, IEvent left, IEvent right, int xBegin, int xEnd, boolean multiple) {
|
||||
double leftVal = ((DoubleVal) left).value;
|
||||
double rightVal= ((DoubleVal) right).value;
|
||||
if(Double.isNaN(leftVal)) {
|
||||
Color color = waveCanvas.colors[WaveformColors.SIGNAL_NAN.ordinal()];
|
||||
Color color = waveCanvas.styleProvider.getColor(WaveformColors.SIGNAL_NAN);
|
||||
int width = xEnd - xBegin;
|
||||
if (width > 1) {
|
||||
int[] points = {
|
||||
@ -400,7 +408,7 @@ public class SignalPainter extends TrackPainter {
|
||||
proj.drawLine(xEnd, yOffsetT, xEnd, yOffsetB);
|
||||
}
|
||||
} else {
|
||||
proj.setForeground(waveCanvas.colors[WaveformColors.SIGNAL_REAL.ordinal()]);
|
||||
proj.setForeground(waveCanvas.styleProvider.getColor(WaveformColors.SIGNAL_REAL));
|
||||
int yOffsetLeft = (int) ((leftVal-minVal) * (yOffsetB-yOffsetT) / range);
|
||||
int yOffsetRight = Double.isNaN(rightVal)?yOffsetLeft:(int) ((rightVal-minVal) * (yOffsetB-yOffsetT) / range);
|
||||
if(continous) {
|
||||
|
@ -11,19 +11,20 @@
|
||||
package com.minres.scviewer.database.ui.swt.internal;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.NavigableMap;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.graphics.GC;
|
||||
import org.eclipse.swt.graphics.Color;
|
||||
import org.eclipse.swt.graphics.Point;
|
||||
import org.eclipse.swt.graphics.Rectangle;
|
||||
|
||||
import com.minres.scviewer.database.ITx;
|
||||
import com.minres.scviewer.database.ITxEvent;
|
||||
import com.minres.scviewer.database.ITxStream;
|
||||
import com.minres.scviewer.database.EventKind;
|
||||
import com.minres.scviewer.database.IEvent;
|
||||
import com.minres.scviewer.database.IWaveform;
|
||||
import com.minres.scviewer.database.tx.ITx;
|
||||
import com.minres.scviewer.database.tx.ITxEvent;
|
||||
import com.minres.scviewer.database.ui.TrackEntry;
|
||||
import com.minres.scviewer.database.ui.WaveformColors;
|
||||
|
||||
@ -33,51 +34,36 @@ public class StreamPainter extends TrackPainter{
|
||||
*
|
||||
*/
|
||||
private final WaveformCanvas waveCanvas;
|
||||
private ITxStream<? extends ITxEvent> stream;
|
||||
private int txBase, txHeight;
|
||||
private boolean even;
|
||||
private IWaveform stream;
|
||||
private int txBase;
|
||||
private int txHeight;
|
||||
private TreeSet<ITx> seenTx;
|
||||
|
||||
public StreamPainter(WaveformCanvas waveCanvas, boolean even, TrackEntry trackEntry) {
|
||||
super(trackEntry, even);
|
||||
this.waveCanvas = waveCanvas;
|
||||
this.stream=trackEntry.getStream();
|
||||
this.seenTx=new TreeSet<ITx>();
|
||||
}
|
||||
|
||||
/*
|
||||
* convert java.awt.Color to org.eclipse.swt.graphics.Color
|
||||
*/
|
||||
static org.eclipse.swt.graphics.Color toSwtColor( GC gc, java.awt.Color awtColor ){
|
||||
return new org.eclipse.swt.graphics.Color( gc.getDevice(), awtColor.getRed(), awtColor.getGreen(), awtColor.getBlue() );
|
||||
}
|
||||
|
||||
static org.eclipse.swt.graphics.Color[] toSwtColors( GC gc, java.awt.Color[] awtColors ){
|
||||
org.eclipse.swt.graphics.Color[] swtColors = new org.eclipse.swt.graphics.Color[awtColors.length];
|
||||
for( int i=0; i<awtColors.length; i++ )
|
||||
swtColors[i] = toSwtColor( gc, awtColors[i] );
|
||||
return swtColors;
|
||||
this.stream=trackEntry.waveform;
|
||||
this.seenTx=new TreeSet<>();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void paintArea(Projection proj, Rectangle area) {
|
||||
if(stream.getEvents().size()==0) return;
|
||||
int trackHeight=trackEntry.height/stream.getMaxConcurrency();
|
||||
int trackHeight=trackEntry.height/stream.getWidth();
|
||||
txBase=trackHeight/5;
|
||||
txHeight=trackHeight*3/5;
|
||||
if(trackEntry.selected) {
|
||||
proj.setBackground(this.waveCanvas.colors[WaveformColors.TRACK_BG_HIGHLITE.ordinal()]);
|
||||
proj.setBackground(this.waveCanvas.styleProvider.getColor(WaveformColors.TRACK_BG_HIGHLITE));
|
||||
}
|
||||
else
|
||||
proj.setBackground(this.waveCanvas.colors[even?WaveformColors.TRACK_BG_EVEN.ordinal():WaveformColors.TRACK_BG_ODD.ordinal()]);
|
||||
proj.setBackground(this.waveCanvas.styleProvider.getColor(even?WaveformColors.TRACK_BG_EVEN:WaveformColors.TRACK_BG_ODD));
|
||||
proj.setFillRule(SWT.FILL_EVEN_ODD);
|
||||
proj.fillRectangle(area);
|
||||
|
||||
|
||||
long scaleFactor = this.waveCanvas.getScaleFactor();
|
||||
long beginPos = area.x;
|
||||
long beginTime = beginPos*scaleFactor;
|
||||
//long endPos = beginPos + area.width;
|
||||
long endTime = beginTime + area.width*scaleFactor;
|
||||
long endTime = beginTime + area.width*scaleFactor;
|
||||
|
||||
Entry<Long, ?> firstTx=stream.getEvents().floorEntry(beginTime);
|
||||
Entry<Long, ?> lastTx=stream.getEvents().ceilingEntry(endTime);
|
||||
@ -86,24 +72,25 @@ public class StreamPainter extends TrackPainter{
|
||||
proj.setFillRule(SWT.FILL_EVEN_ODD);
|
||||
proj.setLineStyle(SWT.LINE_SOLID);
|
||||
proj.setLineWidth(1);
|
||||
proj.setForeground(this.waveCanvas.colors[WaveformColors.LINE.ordinal()]);
|
||||
|
||||
for( int y1=area.y+trackHeight/2; y1<area.y+trackEntry.height; y1+=trackHeight)
|
||||
proj.drawLine(area.x, y1, area.x+area.width, y1);
|
||||
proj.setForeground(this.waveCanvas.styleProvider.getColor(WaveformColors.LINE));
|
||||
|
||||
for( int y1=area.y+trackHeight/2; y1<area.y+trackEntry.height; y1+=trackHeight)
|
||||
proj.drawLine(area.x, y1, area.x+area.width, y1);
|
||||
if(firstTx==lastTx) {
|
||||
for(ITxEvent txEvent:(Collection<? extends ITxEvent>)firstTx.getValue())
|
||||
drawTx(proj, area, txEvent.getTransaction(), false);
|
||||
}else{
|
||||
seenTx.clear();
|
||||
NavigableMap<Long,?> entries = stream.getEvents().subMap(firstTx.getKey(), true, lastTx.getKey(), true);
|
||||
NavigableMap<Long, IEvent[]> entries = stream.getEvents().subMap(firstTx.getKey(), true, lastTx.getKey(), true);
|
||||
boolean highlighed=false;
|
||||
proj.setForeground(this.waveCanvas.colors[WaveformColors.LINE.ordinal()]);
|
||||
|
||||
for(Entry<Long, ?> entry: entries.entrySet())
|
||||
for(ITxEvent txEvent:(Collection<? extends ITxEvent>)entry.getValue()){
|
||||
if(txEvent.getType()==ITxEvent.Type.BEGIN)
|
||||
proj.setForeground(this.waveCanvas.styleProvider.getColor(WaveformColors.LINE));
|
||||
|
||||
for(Entry<Long, IEvent[]> entry: entries.entrySet())
|
||||
for(IEvent evt:entry.getValue()){
|
||||
ITxEvent txEvent = (ITxEvent) evt;
|
||||
if(txEvent.getKind()==EventKind.BEGIN)
|
||||
seenTx.add(txEvent.getTransaction());
|
||||
if(txEvent.getType()==ITxEvent.Type.END){
|
||||
if(txEvent.getKind()==EventKind.END){
|
||||
ITx tx = txEvent.getTransaction();
|
||||
highlighed|=waveCanvas.currentSelection!=null && waveCanvas.currentSelection.equals(tx);
|
||||
drawTx(proj, area, tx, false);
|
||||
@ -114,20 +101,19 @@ public class StreamPainter extends TrackPainter{
|
||||
drawTx(proj, area, tx, false);
|
||||
}
|
||||
if(highlighed){
|
||||
proj.setForeground(this.waveCanvas.colors[WaveformColors.LINE_HIGHLITE.ordinal()]);
|
||||
drawTx(proj, area, waveCanvas.currentSelection, true);
|
||||
proj.setForeground(this.waveCanvas.styleProvider.getColor(WaveformColors.LINE_HIGHLITE));
|
||||
drawTx(proj, area, waveCanvas.currentSelection, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void drawTx(Projection proj, Rectangle area, ITx tx, boolean highlighted ) {
|
||||
// compute colors
|
||||
java.awt.Color[] fallbackColors = trackEntry.getColors();
|
||||
java.awt.Color[] transColor = TrackEntry.computeColor( tx.getGenerator().getName(), fallbackColors[0], fallbackColors[1] );
|
||||
|
||||
proj.setBackground( toSwtColor( proj.getGC(), transColor[highlighted?1:0] ) );
|
||||
|
||||
int offset = tx.getConcurrencyIndex()*this.waveCanvas.getTrackHeight();
|
||||
Color[] transColor = waveCanvas.styleProvider.computeColor( tx.getGenerator().getName());
|
||||
|
||||
proj.setBackground(transColor[highlighted?1:0]);
|
||||
|
||||
int offset = tx.getConcurrencyIndex()*this.waveCanvas.styleProvider.getTrackHeight();
|
||||
Rectangle bb = new Rectangle(
|
||||
(int)(tx.getBeginTime()/this.waveCanvas.getScaleFactor()), area.y+offset+txBase,
|
||||
(int)((tx.getEndTime()-tx.getBeginTime())/this.waveCanvas.getScaleFactor()), txHeight);
|
||||
@ -140,11 +126,11 @@ public class StreamPainter extends TrackPainter{
|
||||
bb.width = bb.width-(area.x-bb.x)+5;
|
||||
bb.x=area.x-5;
|
||||
}
|
||||
int bb_x2 = bb.x+bb.width;
|
||||
int area_x2 = area.x+area.width;
|
||||
if(bb_x2>area_x2){
|
||||
bb_x2=area_x2+5;
|
||||
bb.width= bb_x2-bb.x;
|
||||
int bbX2 = bb.x+bb.width;
|
||||
int areaX2 = area.x+area.width;
|
||||
if(bbX2>areaX2){
|
||||
bbX2=areaX2+5;
|
||||
bb.width= bbX2-bb.x;
|
||||
}
|
||||
int arc = bb.width<10?1:5;
|
||||
proj.fillRoundRectangle(bb.x, bb.y, bb.width, bb.height, arc, arc);
|
||||
@ -153,8 +139,8 @@ public class StreamPainter extends TrackPainter{
|
||||
}
|
||||
|
||||
public ITx getClicked(Point point) {
|
||||
int lane=point.y/waveCanvas.getTrackHeight();
|
||||
Entry<Long, List<ITxEvent>> firstTx=stream.getEvents().floorEntry(point.x*waveCanvas.getScaleFactor());
|
||||
int lane=point.y/waveCanvas.styleProvider.getTrackHeight();
|
||||
Entry<Long, IEvent[]> firstTx=stream.getEvents().floorEntry(point.x*waveCanvas.getScaleFactor());
|
||||
if(firstTx!=null){
|
||||
do {
|
||||
ITx tx = getTxFromEntry(lane, point.x, firstTx);
|
||||
@ -165,31 +151,35 @@ public class StreamPainter extends TrackPainter{
|
||||
return null;
|
||||
}
|
||||
|
||||
public ITxStream<? extends ITxEvent> getStream() {
|
||||
public IWaveform getStream() {
|
||||
return stream;
|
||||
}
|
||||
|
||||
public void setStream(ITxStream<? extends ITxEvent> stream) {
|
||||
public void setStream(IWaveform stream) {
|
||||
this.stream = stream;
|
||||
}
|
||||
|
||||
protected ITx getTxFromEntry(int lane, int offset, Entry<Long, List<ITxEvent>> firstTx) {
|
||||
long timePoint=offset*waveCanvas.getScaleFactor();
|
||||
for(ITxEvent evt:firstTx.getValue()){
|
||||
ITx tx=evt.getTransaction();
|
||||
if(evt.getType()==ITxEvent.Type.BEGIN && tx.getConcurrencyIndex()==lane && tx.getBeginTime()<=timePoint && tx.getEndTime()>=timePoint){
|
||||
return evt.getTransaction();
|
||||
protected ITx getTxFromEntry(int lane, int offset, Entry<Long, IEvent[]> firstTx) {
|
||||
long timePoint=offset*waveCanvas.getScaleFactor();
|
||||
for(IEvent evt:firstTx.getValue()){
|
||||
if(evt instanceof ITxEvent) {
|
||||
ITx tx=((ITxEvent)evt).getTransaction();
|
||||
if(evt.getKind()==EventKind.BEGIN && tx.getConcurrencyIndex()==lane && tx.getBeginTime()<=timePoint && tx.getEndTime()>=timePoint){
|
||||
return ((ITxEvent)evt).getTransaction();
|
||||
}
|
||||
}
|
||||
}
|
||||
// now with some fuzziness
|
||||
timePoint=(offset-5)*waveCanvas.getScaleFactor();
|
||||
long timePointHigh=(offset+5)*waveCanvas.getScaleFactor();
|
||||
for(ITxEvent evt:firstTx.getValue()){
|
||||
ITx tx=evt.getTransaction();
|
||||
if(evt.getType()==ITxEvent.Type.BEGIN && tx.getConcurrencyIndex()==lane && tx.getBeginTime()<=timePointHigh && tx.getEndTime()>=timePoint){
|
||||
return evt.getTransaction();
|
||||
}
|
||||
}
|
||||
timePoint=(offset-5)*waveCanvas.getScaleFactor();
|
||||
long timePointHigh=(offset+5)*waveCanvas.getScaleFactor();
|
||||
for(IEvent evt:firstTx.getValue()){
|
||||
if(evt instanceof ITxEvent) {
|
||||
ITx tx=((ITxEvent)evt).getTransaction();
|
||||
if(evt.getKind()==EventKind.BEGIN && tx.getConcurrencyIndex()==lane && tx.getBeginTime()<=timePointHigh && tx.getEndTime()>=timePoint){
|
||||
return ((ITxEvent)evt).getTransaction();
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ class ToolTipHandler {
|
||||
private Widget tipWidget; // widget this tooltip is hovering over
|
||||
private Point tipPosition; // the position being hovered over
|
||||
|
||||
private static final int hoverYOffset = 1;
|
||||
private static final int HOVER_YOFFSET = 1;
|
||||
|
||||
/**
|
||||
* Creates a new tooltip handler
|
||||
@ -45,56 +45,57 @@ class ToolTipHandler {
|
||||
*/
|
||||
public void activateHoverHelp(final Control control) {
|
||||
Listener listener = new Listener () {
|
||||
Shell tip = null;
|
||||
Shell shell = null;
|
||||
@Override
|
||||
public void handleEvent (Event event) {
|
||||
switch (event.type) {
|
||||
case SWT.KeyDown:{
|
||||
if (tip != null && tip.isVisible() && event.keyCode == SWT.F2) {
|
||||
tip.setFocus();
|
||||
break;
|
||||
}
|
||||
}
|
||||
case SWT.KeyDown:
|
||||
if (shell != null && shell.isVisible() && event.keyCode == SWT.F2)
|
||||
shell.setFocus();
|
||||
break;
|
||||
case SWT.Dispose:
|
||||
case SWT.MouseMove:
|
||||
case SWT.MouseDown: {
|
||||
if (tip != null){
|
||||
tip.dispose ();
|
||||
tip = null;
|
||||
case SWT.MouseDown:
|
||||
if (shell != null){
|
||||
shell.dispose ();
|
||||
shell = null;
|
||||
tipWidget=null;
|
||||
}
|
||||
break;
|
||||
case SWT.MouseHover:
|
||||
createHoverWindow(control, event);
|
||||
break;
|
||||
default:
|
||||
/* do nothing */
|
||||
}
|
||||
case SWT.MouseHover: {
|
||||
Object o = control.getData(Constants.CONTENT_PROVIDER_TAG);
|
||||
if(o != null && o instanceof ToolTipContentProvider) {
|
||||
ToolTipContentProvider provider = ((ToolTipContentProvider)o);
|
||||
Point pt = new Point (event.x, event.y);
|
||||
tipPosition = control.toDisplay(pt);
|
||||
if (tip != null && !tip.isDisposed ()) tip.dispose ();
|
||||
tip = new Shell (parentShell, SWT.NO_FOCUS | SWT.TOOL);
|
||||
tip.setBackground (display.getSystemColor (SWT.COLOR_INFO_BACKGROUND));
|
||||
GridLayout layout = new GridLayout(1, true);
|
||||
layout.verticalSpacing=0;
|
||||
layout.horizontalSpacing=0;
|
||||
layout.marginWidth = 0;
|
||||
layout.marginHeight = 0;
|
||||
tip.setLayout(layout);
|
||||
boolean visible = provider.createContent(tip, pt);
|
||||
tip.pack();
|
||||
tip.setSize(tip.computeSize(SWT.DEFAULT, SWT.DEFAULT));
|
||||
setHoverLocation(tip, tipPosition);
|
||||
tip.setVisible (visible);
|
||||
if(visible)
|
||||
tipWidget=event.widget;
|
||||
}
|
||||
}
|
||||
}
|
||||
private void createHoverWindow(final Control control, Event event) {
|
||||
Object o = control.getData(Constants.CONTENT_PROVIDER_TAG);
|
||||
if(o instanceof ToolTipContentProvider) {
|
||||
ToolTipContentProvider provider = ((ToolTipContentProvider)o);
|
||||
Point pt = new Point (event.x, event.y);
|
||||
tipPosition = control.toDisplay(pt);
|
||||
if (shell != null && !shell.isDisposed ()) shell.dispose ();
|
||||
shell = new Shell (parentShell, SWT.NO_FOCUS | SWT.TOOL);
|
||||
shell.setBackground (display.getSystemColor (SWT.COLOR_INFO_BACKGROUND));
|
||||
GridLayout layout = new GridLayout(1, true);
|
||||
layout.verticalSpacing=0;
|
||||
layout.horizontalSpacing=0;
|
||||
layout.marginWidth = 0;
|
||||
layout.marginHeight = 0;
|
||||
shell.setLayout(layout);
|
||||
boolean visible = provider.createContent(shell, pt);
|
||||
shell.pack();
|
||||
shell.setSize(shell.computeSize(SWT.DEFAULT, SWT.DEFAULT));
|
||||
setHoverLocation(shell, tipPosition);
|
||||
shell.setVisible (visible);
|
||||
if(visible)
|
||||
tipWidget=event.widget;
|
||||
}
|
||||
}
|
||||
};
|
||||
control.addListener (SWT.Dispose, listener);
|
||||
control.addListener (SWT.KeyDown, listener);
|
||||
//control.addListener (SWT.MouseMove, listener);
|
||||
control.addListener (SWT.MouseHover, listener);
|
||||
control.addListener (SWT.MouseDown, listener);
|
||||
|
||||
@ -119,11 +120,6 @@ class ToolTipHandler {
|
||||
helpShell.open();
|
||||
}
|
||||
});
|
||||
// control.addKeyListener(KeyListener.keyPressedAdapter( e-> {
|
||||
// if (e.keyCode == SWT.F2 && shell.isVisible()) {
|
||||
// shell.setFocus();
|
||||
// }
|
||||
// }));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -136,7 +132,7 @@ class ToolTipHandler {
|
||||
Rectangle displayBounds = shell.getDisplay().getBounds();
|
||||
Rectangle shellBounds = shell.getBounds();
|
||||
shellBounds.x = Math.max(Math.min(position.x, displayBounds.width - shellBounds.width), 0);
|
||||
shellBounds.y = Math.max(Math.min(position.y + hoverYOffset, displayBounds.height - shellBounds.height), 0);
|
||||
shellBounds.y = Math.max(Math.min(position.y + HOVER_YOFFSET, displayBounds.height - shellBounds.height), 0);
|
||||
shell.setBounds(shellBounds);
|
||||
}
|
||||
}
|
@ -25,7 +25,7 @@ public class TrackAreaPainter implements IPainter {
|
||||
*/
|
||||
private final WaveformCanvas waveCanvas;
|
||||
|
||||
TreeMap<Integer, IWaveformPainter> trackVerticalOffset;
|
||||
final TreeMap<Integer, IWaveformPainter> trackVerticalOffset;
|
||||
/**
|
||||
* @param txDisplay
|
||||
*/
|
||||
@ -36,7 +36,7 @@ public class TrackAreaPainter implements IPainter {
|
||||
|
||||
public void paintArea(Projection proj, Rectangle a) {
|
||||
Rectangle area = proj.unProject(new Rectangle(a.x, a.y+waveCanvas.rulerHeight, a.width, a.height-waveCanvas.rulerHeight));
|
||||
proj.setBackground(this.waveCanvas.colors[WaveformColors.TRACK_BG_EVEN.ordinal()]);
|
||||
proj.setBackground(this.waveCanvas.styleProvider.getColor(WaveformColors.TRACK_BG_EVEN));
|
||||
proj.setFillRule(SWT.FILL_EVEN_ODD);
|
||||
proj.fillRectangle(area);
|
||||
if(trackVerticalOffset.size()>0){
|
||||
@ -44,7 +44,7 @@ public class TrackAreaPainter implements IPainter {
|
||||
if(firstKey==null) firstKey=trackVerticalOffset.firstKey();
|
||||
Integer lastKey = trackVerticalOffset.floorKey(area.y+area.height);
|
||||
Rectangle subArea = new Rectangle(area.x, 0, area.width, 0);
|
||||
if(lastKey==firstKey){
|
||||
if(lastKey.equals(firstKey)){
|
||||
subArea.y=firstKey;
|
||||
IWaveformPainter p = trackVerticalOffset.get(firstKey);
|
||||
subArea.height=p.getHeight();
|
||||
@ -59,10 +59,6 @@ public class TrackAreaPainter implements IPainter {
|
||||
}
|
||||
}
|
||||
|
||||
public TreeMap<Integer, IWaveformPainter> getTrackVerticalOffset() {
|
||||
return trackVerticalOffset;
|
||||
}
|
||||
|
||||
public void addTrackPainter(IWaveformPainter trackPainter){
|
||||
trackVerticalOffset.put(trackPainter.getVerticalOffset()+waveCanvas.rulerHeight, trackPainter);
|
||||
|
||||
|
@ -20,39 +20,32 @@ import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.ControlAdapter;
|
||||
import org.eclipse.swt.events.ControlEvent;
|
||||
import org.eclipse.swt.events.PaintEvent;
|
||||
import org.eclipse.swt.events.PaintListener;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.graphics.Color;
|
||||
import org.eclipse.swt.graphics.GC;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
import org.eclipse.swt.graphics.Point;
|
||||
import org.eclipse.swt.graphics.RGB;
|
||||
import org.eclipse.swt.graphics.Rectangle;
|
||||
import org.eclipse.swt.widgets.Canvas;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Event;
|
||||
import org.eclipse.swt.widgets.ScrollBar;
|
||||
import org.eclipse.wb.swt.SWTResourceManager;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.minres.scviewer.database.ITx;
|
||||
import com.minres.scviewer.database.IWaveform;
|
||||
import com.minres.scviewer.database.RelationType;
|
||||
import com.minres.scviewer.database.tx.ITx;
|
||||
import com.minres.scviewer.database.ui.IWaveformStyleProvider;
|
||||
import com.minres.scviewer.database.ui.IWaveformView;
|
||||
import com.minres.scviewer.database.ui.TrackEntry;
|
||||
import com.minres.scviewer.database.ui.WaveformColors;
|
||||
import com.minres.scviewer.database.ui.swt.Constants;
|
||||
|
||||
public class WaveformCanvas extends Canvas {
|
||||
|
||||
Color[] colors = new Color[WaveformColors.values().length];
|
||||
|
||||
private boolean doubleBuffering = true;
|
||||
|
||||
private int trackHeight = 50;
|
||||
|
||||
IWaveformStyleProvider styleProvider;
|
||||
|
||||
private long scaleFactor = 1000000L; // 1ns
|
||||
|
||||
String unit="ns";
|
||||
@ -88,26 +81,23 @@ public class WaveformCanvas extends Canvas {
|
||||
* @param style
|
||||
* the style of this control.
|
||||
*/
|
||||
public WaveformCanvas(final Composite parent, int style) {
|
||||
public WaveformCanvas(final Composite parent, int style, IWaveformStyleProvider styleProvider) {
|
||||
super(parent, style | SWT.DOUBLE_BUFFERED | SWT.NO_BACKGROUND | SWT.V_SCROLL | SWT.H_SCROLL);
|
||||
this.styleProvider=styleProvider;
|
||||
addControlListener(new ControlAdapter() { /* resize listener. */
|
||||
public void controlResized(ControlEvent event) {
|
||||
@Override
|
||||
public void controlResized(ControlEvent event) {
|
||||
syncScrollBars();
|
||||
}
|
||||
});
|
||||
addPaintListener(new PaintListener() { /* paint listener. */
|
||||
public void paintControl(final PaintEvent event) {
|
||||
paint(event.gc);
|
||||
}
|
||||
});
|
||||
painterList = new LinkedList<IPainter>();
|
||||
addPaintListener((final PaintEvent event) -> paint(event.gc));
|
||||
painterList = new LinkedList<>();
|
||||
origin = new Point(0, 0);
|
||||
selectionListeners = new LinkedList<>();
|
||||
cursorPainters= new ArrayList<>();
|
||||
wave2painterMap=new HashMap<>();
|
||||
|
||||
initScrollBars();
|
||||
initColors(null);
|
||||
// order is important: it is bottom to top
|
||||
trackAreaPainter=new TrackAreaPainter(this);
|
||||
painterList.add(trackAreaPainter);
|
||||
@ -122,31 +112,6 @@ public class WaveformCanvas extends Canvas {
|
||||
painterList.add(marker);
|
||||
cursorPainters.add(marker);
|
||||
wave2painterMap=new HashMap<>();
|
||||
// fall back initialization
|
||||
colors[WaveformColors.LINE.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED);
|
||||
colors[WaveformColors.LINE_HIGHLITE.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_CYAN);
|
||||
colors[WaveformColors.TRACK_BG_EVEN.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_BLACK);
|
||||
colors[WaveformColors.TRACK_BG_ODD.ordinal()] = SWTResourceManager.getColor(40, 40, 40);
|
||||
colors[WaveformColors.TRACK_BG_HIGHLITE.ordinal()] = SWTResourceManager.getColor(40, 40, 80);
|
||||
colors[WaveformColors.TX_BG.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GREEN);
|
||||
colors[WaveformColors.TX_BG_HIGHLITE.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_GREEN);
|
||||
colors[WaveformColors.TX_BORDER.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED);
|
||||
colors[WaveformColors.SIGNAL0.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GREEN);
|
||||
colors[WaveformColors.SIGNAL1.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GREEN);
|
||||
colors[WaveformColors.SIGNALZ.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_YELLOW);
|
||||
colors[WaveformColors.SIGNALX.ordinal()] = SWTResourceManager.getColor(255, 51, 51);
|
||||
colors[WaveformColors.SIGNALU.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_YELLOW);
|
||||
colors[WaveformColors.SIGNAL_TEXT.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_WHITE);
|
||||
colors[WaveformColors.SIGNAL_REAL.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_YELLOW);
|
||||
colors[WaveformColors.SIGNAL_NAN.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED);
|
||||
colors[WaveformColors.CURSOR.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED);
|
||||
colors[WaveformColors.CURSOR_DRAG.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GRAY);
|
||||
colors[WaveformColors.CURSOR_TEXT.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_WHITE);
|
||||
colors[WaveformColors.MARKER.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_GRAY);
|
||||
colors[WaveformColors.MARKER_TEXT.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_WHITE);
|
||||
colors[WaveformColors.REL_ARROW.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_MAGENTA);
|
||||
colors[WaveformColors.REL_ARROW_HIGHLITE.ordinal()] = SWTResourceManager.getColor(255, 128, 255);
|
||||
|
||||
}
|
||||
|
||||
public void addCursoPainter(CursorPainter cursorPainter){
|
||||
@ -154,17 +119,6 @@ public class WaveformCanvas extends Canvas {
|
||||
cursorPainters.add(cursorPainter);
|
||||
}
|
||||
|
||||
public void initColors(HashMap<WaveformColors, RGB> colourMap) {
|
||||
Display d = getDisplay();
|
||||
if (colourMap != null) {
|
||||
for (WaveformColors c : WaveformColors.values()) {
|
||||
if (colourMap.containsKey(c))
|
||||
colors[c.ordinal()] = new Color(d, colourMap.get(c));
|
||||
}
|
||||
redraw();
|
||||
}
|
||||
}
|
||||
|
||||
public void setHighliteRelation(RelationType relationType){
|
||||
if(arrowPainter!=null){
|
||||
boolean redraw = arrowPainter.getHighlightType()!=relationType;
|
||||
@ -206,21 +160,12 @@ public class WaveformCanvas extends Canvas {
|
||||
syncScrollBars();
|
||||
}
|
||||
|
||||
public int getTrackHeight() {
|
||||
return trackHeight;
|
||||
}
|
||||
|
||||
public void setTrackHeight(int trackHeight) {
|
||||
this.trackHeight = trackHeight;
|
||||
syncScrollBars();
|
||||
}
|
||||
|
||||
public int getZoomLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
public int getMaxZoomLevel(){
|
||||
return Constants.unitMultiplier.length*Constants.unitString.length-1;
|
||||
return Constants.UNIT_MULTIPLIER.length*Constants.UNIT_STRING.length-1;
|
||||
}
|
||||
|
||||
public void setZoomLevel(int level) {
|
||||
@ -232,8 +177,8 @@ public class WaveformCanvas extends Canvas {
|
||||
//FIXME: keep center if zoom-out and cursor is not in view
|
||||
long oldScaleFactor=scaleFactor;
|
||||
if(level<0) level = 0;
|
||||
if(level<Constants.unitMultiplier.length*Constants.unitString.length){
|
||||
this.scaleFactor = (long) Math.pow(10, level/2);
|
||||
if(level<Constants.UNIT_MULTIPLIER.length*Constants.UNIT_STRING.length){
|
||||
this.scaleFactor = (long) Math.pow(10, level/2d);
|
||||
if(level%2==1) this.scaleFactor*=3;
|
||||
ITx tx = arrowPainter.getTx();
|
||||
arrowPainter.setTx(null);
|
||||
@ -264,17 +209,17 @@ public class WaveformCanvas extends Canvas {
|
||||
}
|
||||
|
||||
public long getScaleFactorPow10() {
|
||||
int scale = level/Constants.unitMultiplier.length;
|
||||
int scale = level/Constants.UNIT_MULTIPLIER.length;
|
||||
double res = Math.pow(1000, scale);
|
||||
return (long) res;
|
||||
}
|
||||
|
||||
public String getUnitStr(){
|
||||
return Constants.unitString[level/Constants.unitMultiplier.length];
|
||||
return Constants.UNIT_STRING[level/Constants.UNIT_MULTIPLIER.length];
|
||||
}
|
||||
|
||||
public int getUnitMultiplier(){
|
||||
return Constants.unitMultiplier[level%Constants.unitMultiplier.length];
|
||||
return Constants.UNIT_MULTIPLIER[level%Constants.UNIT_MULTIPLIER.length];
|
||||
}
|
||||
|
||||
public long getTimeForOffset(int xOffset){
|
||||
@ -296,7 +241,7 @@ public class WaveformCanvas extends Canvas {
|
||||
}
|
||||
|
||||
void clearAllWaveformPainter(boolean update) {
|
||||
trackAreaPainter.getTrackVerticalOffset().clear();
|
||||
trackAreaPainter.trackVerticalOffset.clear();
|
||||
wave2painterMap.clear();
|
||||
if(update) syncScrollBars();
|
||||
}
|
||||
@ -315,23 +260,15 @@ public class WaveformCanvas extends Canvas {
|
||||
return cursorPainters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispose the garbage here
|
||||
*/
|
||||
public void dispose() {
|
||||
for (WaveformColors c : WaveformColors.values())
|
||||
colors[c.ordinal()].dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
/* Initialize the scrollbar and register listeners. */
|
||||
private void initScrollBars() {
|
||||
ScrollBar horizontal = getHorizontalBar();
|
||||
horizontal.setEnabled(false);
|
||||
horizontal.setVisible(true);
|
||||
horizontal.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
if (painterList.size() == 0)
|
||||
if (painterList.isEmpty())
|
||||
return;
|
||||
setOrigin(-((ScrollBar) event.widget).getSelection(), origin.y);
|
||||
}
|
||||
@ -340,8 +277,9 @@ public class WaveformCanvas extends Canvas {
|
||||
vertical.setEnabled(false);
|
||||
vertical.setVisible(true);
|
||||
vertical.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
if (painterList.size() == 0)
|
||||
if (painterList.isEmpty())
|
||||
return;
|
||||
setOrigin(origin.x, -((ScrollBar) event.widget).getSelection());
|
||||
}
|
||||
@ -354,7 +292,7 @@ public class WaveformCanvas extends Canvas {
|
||||
* :<b> transform, image size, client area</b>.
|
||||
*/
|
||||
public void syncScrollBars() {
|
||||
if (painterList.size() == 0) {
|
||||
if (painterList.isEmpty()) {
|
||||
redraw();
|
||||
return;
|
||||
}
|
||||
@ -362,14 +300,14 @@ public class WaveformCanvas extends Canvas {
|
||||
long width = maxTime / scaleFactor;
|
||||
Rectangle clientArea=getClientArea();
|
||||
ScrollBar horizontal = getHorizontalBar();
|
||||
horizontal.setIncrement((int) (getClientArea().width / 100));
|
||||
horizontal.setIncrement(getClientArea().width / 100);
|
||||
horizontal.setPageIncrement(getClientArea().width);
|
||||
int clientWidthw = clientArea.width;
|
||||
if (width > clientWidthw) { /* image is wider than client area */
|
||||
horizontal.setMinimum(0);
|
||||
horizontal.setMaximum((int)width);
|
||||
horizontal.setEnabled(true);
|
||||
if (((int) -origin.x) > horizontal.getMaximum() - clientWidthw) {
|
||||
if (-origin.x > horizontal.getMaximum() - clientWidthw) {
|
||||
origin.x = -horizontal.getMaximum() + clientWidthw;
|
||||
}
|
||||
} else { /* image is narrower than client area */
|
||||
@ -379,18 +317,18 @@ public class WaveformCanvas extends Canvas {
|
||||
horizontal.setSelection(-origin.x);
|
||||
|
||||
ScrollBar vertical = getVerticalBar();
|
||||
vertical.setIncrement((int) (getClientArea().height / 100));
|
||||
vertical.setPageIncrement((int) (getClientArea().height));
|
||||
vertical.setIncrement(getClientArea().height / 100);
|
||||
vertical.setPageIncrement(getClientArea().height);
|
||||
int clientHeighth = clientArea.height;
|
||||
if (height > clientHeighth) { /* image is higher than client area */
|
||||
vertical.setMinimum(0);
|
||||
vertical.setMaximum(height);
|
||||
vertical.setEnabled(true);
|
||||
if (((int) -origin.y) > vertical.getMaximum() - clientHeighth) {
|
||||
if ( -origin.y > vertical.getMaximum() - clientHeighth) {
|
||||
origin.y = -vertical.getMaximum() + clientHeighth;
|
||||
}
|
||||
} else { /* image is less higher than client area */
|
||||
vertical.setMaximum((int) (clientHeighth));
|
||||
vertical.setMaximum(clientHeighth);
|
||||
vertical.setEnabled(false);
|
||||
}
|
||||
vertical.setThumb(clientHeighth);
|
||||
@ -405,10 +343,10 @@ public class WaveformCanvas extends Canvas {
|
||||
if(pt.x==0 || pt.y==0) return;
|
||||
Rectangle clientRect = getClientArea(); /* Canvas' painting area */
|
||||
GC thisGc = gc;
|
||||
Image d_backingImg = null;
|
||||
Image dBackingImg = null;
|
||||
if(doubleBuffering) {
|
||||
d_backingImg = new Image(getDisplay(), pt.x, pt.y);
|
||||
thisGc = new GC(d_backingImg);
|
||||
dBackingImg = new Image(getDisplay(), pt.x, pt.y);
|
||||
thisGc = new GC(dBackingImg);
|
||||
thisGc.setBackground(gc.getBackground());
|
||||
thisGc.setForeground(gc.getForeground());
|
||||
thisGc.setFont(gc.getFont());
|
||||
@ -416,7 +354,7 @@ public class WaveformCanvas extends Canvas {
|
||||
}
|
||||
Projection p = new Projection(thisGc);
|
||||
p.setTranslation(origin);
|
||||
if (painterList.size() > 0 ) {
|
||||
if (!painterList.isEmpty() ) {
|
||||
for (IPainter painter : painterList)
|
||||
painter.paintArea(p, clientRect);
|
||||
} else {
|
||||
@ -424,8 +362,8 @@ public class WaveformCanvas extends Canvas {
|
||||
initScrollBars();
|
||||
}
|
||||
if(doubleBuffering) {
|
||||
gc.drawImage(d_backingImg, 0, 0);
|
||||
d_backingImg.dispose();
|
||||
gc.drawImage(dBackingImg, 0, 0);
|
||||
if(dBackingImg!=null) dBackingImg.dispose();
|
||||
thisGc.dispose();
|
||||
}
|
||||
}
|
||||
@ -436,7 +374,7 @@ public class WaveformCanvas extends Canvas {
|
||||
if (p instanceof TrackAreaPainter) {
|
||||
int y = point.y - origin.y;
|
||||
int x = point.x - origin.x;
|
||||
Entry<Integer, IWaveformPainter> entry = trackAreaPainter.getTrackVerticalOffset().floorEntry(y);
|
||||
Entry<Integer, IWaveformPainter> entry = trackAreaPainter.trackVerticalOffset.floorEntry(y);
|
||||
if (entry != null) {
|
||||
if (entry.getValue() instanceof StreamPainter) {
|
||||
ITx tx = ((StreamPainter) entry.getValue()).getClicked(new Point(x, y - entry.getKey()));
|
||||
@ -457,9 +395,9 @@ public class WaveformCanvas extends Canvas {
|
||||
public List<Object> getEntriesAtPosition(IWaveform iWaveform, int i) {
|
||||
LinkedList<Object> result=new LinkedList<>();
|
||||
int x = i - origin.x;
|
||||
for(IPainter p: wave2painterMap.values()){
|
||||
for(IWaveformPainter p: wave2painterMap.values()){
|
||||
if (p instanceof StreamPainter && ((StreamPainter)p).getStream()==iWaveform) {
|
||||
result.add(((StreamPainter) p).getClicked(new Point(x, trackHeight/2)));
|
||||
result.add(((StreamPainter) p).getClicked(new Point(x, styleProvider.getTrackHeight()/2)));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@ -486,10 +424,10 @@ public class WaveformCanvas extends Canvas {
|
||||
}
|
||||
for (IWaveformPainter painter : wave2painterMap.values()) {
|
||||
if (painter instanceof StreamPainter && ((StreamPainter) painter).getStream() == tx.getStream()) {
|
||||
int top = painter.getVerticalOffset() + trackHeight * tx.getConcurrencyIndex();
|
||||
int bottom = top + trackHeight;
|
||||
int top = painter.getVerticalOffset() + styleProvider.getTrackHeight() * tx.getConcurrencyIndex();
|
||||
int bottom = top + styleProvider.getTrackHeight();
|
||||
if (top < -origin.y) {
|
||||
setOrigin(origin.x, -(top-trackHeight));
|
||||
setOrigin(origin.x, -(top-styleProvider.getTrackHeight()));
|
||||
} else if (bottom > (size.y - origin.y)) {
|
||||
setOrigin(origin.x, size.y - bottom);
|
||||
}
|
||||
@ -502,15 +440,14 @@ public class WaveformCanvas extends Canvas {
|
||||
TrackEntry te = painter.getTrackEntry();
|
||||
if(te.waveform == waveform) {
|
||||
Point size = getSize();
|
||||
//size.x -= getVerticalBar().getSize().x + 2;
|
||||
size.y -=+rulerHeight;
|
||||
ScrollBar sb = getHorizontalBar();
|
||||
if((sb.getStyle()&SWT.SCROLLBAR_OVERLAY)!=0 && sb.isVisible()) // TODO: check on other platform than MacOSX
|
||||
if((sb.getStyle()&SWT.SCROLLBAR_OVERLAY)!=0 && sb.isVisible())
|
||||
size.y-= getHorizontalBar().getSize().y;
|
||||
int top = te.vOffset;
|
||||
int bottom = top + trackHeight;
|
||||
int bottom = top + styleProvider.getTrackHeight();
|
||||
if (top < -origin.y) {
|
||||
setOrigin(origin.x, -(top-trackHeight));
|
||||
setOrigin(origin.x, -(top-styleProvider.getTrackHeight()));
|
||||
} else if (bottom > (size.y - origin.y)) {
|
||||
setOrigin(origin.x, size.y - bottom);
|
||||
}
|
||||
@ -569,4 +506,9 @@ public class WaveformCanvas extends Canvas {
|
||||
long getMinVisibleTime() {
|
||||
return origin.x * scaleFactor;
|
||||
}
|
||||
|
||||
public void setStyleProvider(IWaveformStyleProvider styleProvider) {
|
||||
this.styleProvider=styleProvider;
|
||||
redraw();
|
||||
}
|
||||
}
|
||||
|
@ -10,15 +10,14 @@
|
||||
*******************************************************************************/
|
||||
package com.minres.scviewer.database.ui.swt.internal;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.beans.PropertyChangeSupport;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
@ -56,10 +55,8 @@ import org.eclipse.swt.events.PaintEvent;
|
||||
import org.eclipse.swt.events.PaintListener;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.graphics.Font;
|
||||
import org.eclipse.swt.graphics.GC;
|
||||
import org.eclipse.swt.graphics.Point;
|
||||
import org.eclipse.swt.graphics.RGB;
|
||||
import org.eclipse.swt.graphics.Rectangle;
|
||||
import org.eclipse.swt.graphics.TextLayout;
|
||||
import org.eclipse.swt.layout.FillLayout;
|
||||
@ -78,23 +75,25 @@ import org.eclipse.wb.swt.SWTResourceManager;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.minres.scviewer.database.BitVector;
|
||||
import com.minres.scviewer.database.ISignal;
|
||||
import com.minres.scviewer.database.ITx;
|
||||
import com.minres.scviewer.database.ITxEvent;
|
||||
import com.minres.scviewer.database.ITxRelation;
|
||||
import com.minres.scviewer.database.ITxStream;
|
||||
import com.minres.scviewer.database.DoubleVal;
|
||||
import com.minres.scviewer.database.EventKind;
|
||||
import com.minres.scviewer.database.IEvent;
|
||||
import com.minres.scviewer.database.IWaveform;
|
||||
import com.minres.scviewer.database.RelationType;
|
||||
import com.minres.scviewer.database.WaveformType;
|
||||
import com.minres.scviewer.database.tx.ITx;
|
||||
import com.minres.scviewer.database.tx.ITxEvent;
|
||||
import com.minres.scviewer.database.tx.ITxRelation;
|
||||
import com.minres.scviewer.database.ui.GotoDirection;
|
||||
import com.minres.scviewer.database.ui.ICursor;
|
||||
import com.minres.scviewer.database.ui.IWaveformStyleProvider;
|
||||
import com.minres.scviewer.database.ui.IWaveformView;
|
||||
import com.minres.scviewer.database.ui.TrackEntry;
|
||||
import com.minres.scviewer.database.ui.WaveformColors;
|
||||
import com.minres.scviewer.database.ui.swt.Constants;
|
||||
|
||||
public class WaveformView implements IWaveformView {
|
||||
|
||||
private ListenerList<ISelectionChangedListener> selectionChangedListeners = new ListenerList<ISelectionChangedListener>();
|
||||
private ListenerList<ISelectionChangedListener> selectionChangedListeners = new ListenerList<>();
|
||||
|
||||
private PropertyChangeSupport pcs;
|
||||
|
||||
@ -110,9 +109,9 @@ public class WaveformView implements IWaveformView {
|
||||
|
||||
private Control namePaneHeader;
|
||||
|
||||
final private Canvas nameList;
|
||||
private final Canvas nameList;
|
||||
|
||||
final private Canvas valueList;
|
||||
private final Canvas valueList;
|
||||
|
||||
final WaveformCanvas waveformCanvas;
|
||||
|
||||
@ -126,11 +125,11 @@ public class WaveformView implements IWaveformView {
|
||||
|
||||
int selectedMarker = 0;
|
||||
|
||||
private int trackVerticalHeight;
|
||||
private int tracksVerticalHeight;
|
||||
|
||||
private TreeMap<Integer, TrackEntry> trackVerticalOffset;
|
||||
|
||||
private Font nameFont, nameFontB;
|
||||
|
||||
private IWaveformStyleProvider styleProvider;
|
||||
|
||||
protected TrackEntry lastClickedEntry;
|
||||
|
||||
@ -171,7 +170,8 @@ public class WaveformView implements IWaveformView {
|
||||
};
|
||||
|
||||
class WaveformMouseListener implements PaintListener, Listener {
|
||||
Point start, end;
|
||||
Point start;
|
||||
Point end;
|
||||
List<Object> initialSelected;
|
||||
boolean down=false;
|
||||
|
||||
@ -182,9 +182,9 @@ public class WaveformView implements IWaveformView {
|
||||
gc.setAlpha(128);
|
||||
int minX = Math.min(start.x, end.x);
|
||||
int width = Math.max(start.x, end.x) - minX;
|
||||
int y_top = waveformCanvas.getRulerHeight();
|
||||
int y_bottom = waveformCanvas.getSize().y;
|
||||
gc.fillRectangle(minX, y_top, width,y_bottom);
|
||||
int yTop = waveformCanvas.getRulerHeight();
|
||||
int yBottom = waveformCanvas.getSize().y;
|
||||
gc.fillRectangle(minX, yTop, width,yBottom);
|
||||
}
|
||||
}
|
||||
|
||||
@ -201,7 +201,7 @@ public class WaveformView implements IWaveformView {
|
||||
if(targetTimeRange==0) return;
|
||||
long relation = currentTimeRange/targetTimeRange;
|
||||
long i = 1;
|
||||
int level=0;//relation>0?0:0;
|
||||
int level=0;
|
||||
do {
|
||||
if(relation<0 ) {
|
||||
if(-relation<i) {
|
||||
@ -248,20 +248,15 @@ public class WaveformView implements IWaveformView {
|
||||
long time= waveformCanvas.getTimeForOffset(p.x);
|
||||
long scaling=5*waveformCanvas.getScaleFactor();
|
||||
for(Object o:waveformCanvas.getElementsAt(p)){
|
||||
Entry<Long, ?> floorEntry=null, ceilEntry=null;
|
||||
Entry<Long, IEvent[]> floorEntry=null;
|
||||
Entry<Long, IEvent[]> ceilEntry=null;
|
||||
if(o instanceof TrackEntry){
|
||||
TrackEntry entry = (TrackEntry) o;
|
||||
if(entry.waveform instanceof ISignal<?>){
|
||||
NavigableMap<Long, ?> map = ((ISignal<?>)entry.waveform).getEvents();
|
||||
floorEntry = map.floorEntry(time);
|
||||
ceilEntry = map.ceilingEntry(time);
|
||||
} else if (entry.waveform instanceof ITxStream<?>){
|
||||
NavigableMap<Long, ?> map = ((ITxStream<?>)entry.waveform).getEvents();
|
||||
floorEntry = map.floorEntry(time);
|
||||
ceilEntry = map.ceilingEntry(time);
|
||||
}
|
||||
NavigableMap<Long, IEvent[]> map = entry.waveform.getEvents();
|
||||
floorEntry = map.floorEntry(time);
|
||||
ceilEntry = map.ceilingEntry(time);
|
||||
} else if(o instanceof ITx){
|
||||
NavigableMap<Long, ?> map = ((ITx)o).getStream().getEvents();
|
||||
NavigableMap<Long, IEvent[]> map = ((ITx)o).getStream().getEvents();
|
||||
floorEntry = map.floorEntry(time);
|
||||
ceilEntry = map.ceilingEntry(time);
|
||||
}
|
||||
@ -300,9 +295,6 @@ public class WaveformView implements IWaveformView {
|
||||
case SWT.MouseUp:
|
||||
mouseUp(new MouseEvent(e));
|
||||
break;
|
||||
//case SWT.MouseDoubleClick:
|
||||
//mouseDoubleClick(new MouseEvent(e));
|
||||
//break;
|
||||
case SWT.MouseMove:
|
||||
if(down) {
|
||||
end=new Point(e.x, e.y);
|
||||
@ -315,17 +307,16 @@ public class WaveformView implements IWaveformView {
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
protected WaveformMouseListener waveformMouseListener = new WaveformMouseListener();
|
||||
|
||||
public WaveformView(Composite parent) {
|
||||
public WaveformView(Composite parent, IWaveformStyleProvider styleProvider) {
|
||||
this.styleProvider=styleProvider;
|
||||
|
||||
pcs=new PropertyChangeSupport(this);
|
||||
|
||||
trackVerticalOffset = new TreeMap<Integer, TrackEntry>();
|
||||
trackVerticalHeight=0;
|
||||
|
||||
nameFont = parent.getDisplay().getSystemFont();
|
||||
nameFontB = SWTResourceManager.getBoldFont(nameFont);
|
||||
trackVerticalOffset = new TreeMap<>();
|
||||
tracksVerticalHeight=0;
|
||||
|
||||
streams = new ObservableList<>();
|
||||
streams.addPropertyChangeListener("content", this);
|
||||
@ -344,7 +335,7 @@ public class WaveformView implements IWaveformView {
|
||||
rightSash.setBackground(SWTResourceManager.getColor(SWT.COLOR_GRAY));
|
||||
|
||||
Composite valuePane = new Composite(rightSash, SWT.NONE);
|
||||
waveformCanvas = new WaveformCanvas(rightSash, SWT.NONE);
|
||||
waveformCanvas = new WaveformCanvas(rightSash, SWT.NONE, styleProvider);
|
||||
|
||||
// create the name pane
|
||||
createTextPane(namePane, "Name");
|
||||
@ -371,14 +362,11 @@ public class WaveformView implements IWaveformView {
|
||||
return new Point(bounds.width, bounds.height);
|
||||
}
|
||||
};
|
||||
nameList.addListener(SWT.Paint, new Listener() {
|
||||
@Override
|
||||
public void handleEvent(Event event) {
|
||||
if(!trackVerticalOffset.isEmpty()) {
|
||||
GC gc = event.gc;
|
||||
Rectangle rect = ((Canvas) event.widget).getClientArea();
|
||||
paintNames(gc, rect);
|
||||
}
|
||||
nameList.addListener(SWT.Paint, (Event event) -> {
|
||||
if(!trackVerticalOffset.isEmpty()) {
|
||||
GC gc = event.gc;
|
||||
Rectangle rect = ((Canvas) event.widget).getClientArea();
|
||||
paintNames(gc, rect);
|
||||
}
|
||||
});
|
||||
nameList.addMouseListener(nameValueMouseListener);
|
||||
@ -406,14 +394,11 @@ public class WaveformView implements IWaveformView {
|
||||
return new Point(bounds.width, bounds.height);
|
||||
}
|
||||
};
|
||||
valueList.addListener(SWT.Paint, new Listener() {
|
||||
@Override
|
||||
public void handleEvent(Event event) {
|
||||
if(!trackVerticalOffset.isEmpty()) {
|
||||
GC gc = event.gc;
|
||||
Rectangle rect = ((Canvas) event.widget).getClientArea();
|
||||
paintValues(gc, rect);
|
||||
}
|
||||
valueList.addListener(SWT.Paint, (Event event) -> {
|
||||
if(!trackVerticalOffset.isEmpty()) {
|
||||
GC gc = event.gc;
|
||||
Rectangle rect = ((Canvas) event.widget).getClientArea();
|
||||
paintValues(gc, rect);
|
||||
}
|
||||
});
|
||||
valueList.addMouseListener(nameValueMouseListener);
|
||||
@ -423,11 +408,11 @@ public class WaveformView implements IWaveformView {
|
||||
waveformCanvas.addPaintListener(waveformMouseListener);
|
||||
waveformCanvas.addListener(SWT.MouseDown,waveformMouseListener);
|
||||
waveformCanvas.addListener(SWT.MouseUp,waveformMouseListener);
|
||||
//waveformCanvas.addListener(SWT.MouseDoubleClick,waveformMouseListener);
|
||||
waveformCanvas.addListener(SWT.MouseMove,waveformMouseListener);
|
||||
waveformCanvas.addListener(SWT.MouseWheel, waveformMouseListener);
|
||||
|
||||
nameListScrolled.getVerticalBar().addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
int y = ((ScrollBar) e.widget).getSelection();
|
||||
Point v = valueListScrolled.getOrigin();
|
||||
@ -437,6 +422,7 @@ public class WaveformView implements IWaveformView {
|
||||
}
|
||||
});
|
||||
valueListScrolled.getVerticalBar().addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
int y = ((ScrollBar) e.widget).getSelection();
|
||||
nameListScrolled.setOrigin(nameListScrolled.getOrigin().x, y);
|
||||
@ -444,6 +430,7 @@ public class WaveformView implements IWaveformView {
|
||||
}
|
||||
});
|
||||
waveformCanvas.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
int y = waveformCanvas.getVerticalBar().getSelection();
|
||||
nameListScrolled.setOrigin(nameListScrolled.getOrigin().x, y);
|
||||
@ -465,81 +452,73 @@ public class WaveformView implements IWaveformView {
|
||||
}
|
||||
|
||||
private void createTextPane(Composite namePane, String text) {
|
||||
GridLayout gl_namePane = new GridLayout(1, false);
|
||||
gl_namePane.verticalSpacing = 0;
|
||||
gl_namePane.marginWidth = 0;
|
||||
gl_namePane.horizontalSpacing = 0;
|
||||
gl_namePane.marginHeight = 0;
|
||||
namePane.setLayout(gl_namePane);
|
||||
GridLayout glNamePane = new GridLayout(1, false);
|
||||
glNamePane.verticalSpacing = 0;
|
||||
glNamePane.marginWidth = 0;
|
||||
glNamePane.horizontalSpacing = 0;
|
||||
glNamePane.marginHeight = 0;
|
||||
namePane.setLayout(glNamePane);
|
||||
|
||||
CLabel nameLabel = new CLabel(namePane, SWT.NONE);
|
||||
GridData gd_nameLabel = new GridData(SWT.CENTER, SWT.CENTER, true, false, 1, 1);
|
||||
gd_nameLabel.heightHint = waveformCanvas.getRulerHeight() - 2;
|
||||
nameLabel.setLayoutData(gd_nameLabel);
|
||||
GridData gdNameLabel = new GridData(SWT.CENTER, SWT.CENTER, true, false, 1, 1);
|
||||
gdNameLabel.heightHint = waveformCanvas.getRulerHeight() - 2;
|
||||
nameLabel.setLayoutData(gdNameLabel);
|
||||
nameLabel.setText(text);
|
||||
|
||||
Label nameSep = new Label(namePane, SWT.SEPARATOR | SWT.HORIZONTAL);
|
||||
nameSep.setBackground(SWTResourceManager.getColor(SWT.COLOR_DARK_GRAY));
|
||||
nameSep.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
|
||||
GridData gd_nameSep = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
|
||||
gd_nameSep.heightHint = 2;
|
||||
nameSep.setLayoutData(gd_nameSep);
|
||||
GridData gdNameSep = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
|
||||
gdNameSep.heightHint = 2;
|
||||
nameSep.setLayoutData(gdNameSep);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent pce) {
|
||||
if ("size".equals(pce.getPropertyName()) || "content".equals(pce.getPropertyName())) {
|
||||
if(revealSelected) {
|
||||
waveformCanvas.getDisplay().asyncExec(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
waveformCanvas.getDisplay().asyncExec(() ->{
|
||||
update();
|
||||
currentWaveformSelection.stream().forEach(e -> waveformCanvas.reveal(e.waveform));
|
||||
valueList.redraw();
|
||||
nameList.redraw();
|
||||
}
|
||||
});
|
||||
revealSelected=false;
|
||||
} else
|
||||
waveformCanvas.getDisplay().asyncExec(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
update();
|
||||
}
|
||||
});
|
||||
waveformCanvas.getDisplay().asyncExec(WaveformView.this::update);
|
||||
}
|
||||
}
|
||||
|
||||
public void update() {
|
||||
trackVerticalHeight = 0;
|
||||
tracksVerticalHeight = 0;
|
||||
int nameMaxWidth = 0;
|
||||
IWaveformPainter painter = null;
|
||||
trackVerticalOffset.clear();
|
||||
waveformCanvas.clearAllWaveformPainter(false);
|
||||
boolean even = true;
|
||||
TextLayout tl = new TextLayout(waveformCanvas.getDisplay());
|
||||
tl.setFont(nameFontB);
|
||||
tl.setFont(styleProvider.getNameFont());
|
||||
for (TrackEntry streamEntry : streams) {
|
||||
streamEntry.height = waveformCanvas.getTrackHeight();
|
||||
streamEntry.vOffset=trackVerticalHeight;
|
||||
if (streamEntry.isStream()) {
|
||||
streamEntry.height = styleProvider.getTrackHeight();
|
||||
streamEntry.vOffset=tracksVerticalHeight;
|
||||
if (streamEntry.waveform.getType()==WaveformType.TRANSACTION) {
|
||||
streamEntry.currentValue="";
|
||||
streamEntry.height *= streamEntry.getStream().getMaxConcurrency();
|
||||
streamEntry.height *= streamEntry.waveform.getWidth();
|
||||
painter = new StreamPainter(waveformCanvas, even, streamEntry);
|
||||
} else if (streamEntry.isSignal()) {
|
||||
} else if (streamEntry.waveform.getType()==WaveformType.SIGNAL) {
|
||||
streamEntry.currentValue="---";
|
||||
painter = new SignalPainter(waveformCanvas, even, streamEntry);
|
||||
}
|
||||
waveformCanvas.addWaveformPainter(painter, false);
|
||||
trackVerticalOffset.put(trackVerticalHeight, streamEntry);
|
||||
trackVerticalOffset.put(tracksVerticalHeight, streamEntry);
|
||||
tl.setText(streamEntry.waveform.getFullName());
|
||||
nameMaxWidth = Math.max(nameMaxWidth, tl.getBounds().width);
|
||||
trackVerticalHeight += streamEntry.height;
|
||||
tracksVerticalHeight += streamEntry.height;
|
||||
even = !even;
|
||||
}
|
||||
waveformCanvas.syncScrollBars();
|
||||
nameList.setSize(nameMaxWidth + 15, trackVerticalHeight);
|
||||
nameListScrolled.setMinSize(nameMaxWidth + 15, trackVerticalHeight);
|
||||
nameList.setSize(nameMaxWidth + 15, tracksVerticalHeight);
|
||||
nameListScrolled.setMinSize(nameMaxWidth + 15, tracksVerticalHeight);
|
||||
nameList.redraw();
|
||||
updateValueList();
|
||||
waveformCanvas.redraw();
|
||||
@ -551,7 +530,7 @@ public class WaveformView implements IWaveformView {
|
||||
|
||||
private int calculateValueWidth() {
|
||||
TextLayout tl = new TextLayout(waveformCanvas.getDisplay());
|
||||
tl.setFont(nameFontB);
|
||||
tl.setFont(styleProvider.getNameFontHighlite());
|
||||
int valueMaxWidth = 0;
|
||||
for (TrackEntry v : streams) {
|
||||
tl.setText(v.currentValue);
|
||||
@ -563,15 +542,13 @@ public class WaveformView implements IWaveformView {
|
||||
private void updateValueList(){
|
||||
final Long time = getCursorTime();
|
||||
for(TrackEntry entry:streams){
|
||||
if(entry.isSignal()){
|
||||
ISignal<?> signal = (ISignal<?>) entry.waveform;
|
||||
Object value = signal.getWaveformValueBeforeTime(time);
|
||||
if(value instanceof BitVector){
|
||||
BitVector bv = (BitVector) value;
|
||||
if(entry.waveform.getType() == WaveformType.SIGNAL){
|
||||
IEvent[] value = entry.waveform.getEventsBeforeTime(time);
|
||||
if(value[0] instanceof BitVector){
|
||||
BitVector bv = (BitVector) value[0];
|
||||
if(bv.getWidth()==1)
|
||||
entry.currentValue="b'"+bv;
|
||||
else {
|
||||
// TODO: same code resides in SignalPainter, fix it
|
||||
switch(entry.valueDisplay) {
|
||||
case SIGNED:
|
||||
entry.currentValue=Long.toString(bv.toSignedValue());
|
||||
@ -583,43 +560,44 @@ public class WaveformView implements IWaveformView {
|
||||
entry.currentValue="h'"+bv.toHexString();
|
||||
}
|
||||
}
|
||||
} else if(value instanceof Double){
|
||||
Double val = (Double) value;
|
||||
} else if(value[0] instanceof DoubleVal){
|
||||
Double val = ((DoubleVal) value[0]).value;
|
||||
if(val>0.001)
|
||||
entry.currentValue=String.format("%1$,.3f", val);
|
||||
else
|
||||
entry.currentValue=Double.toString(val);
|
||||
}
|
||||
} else if(entry.isStream()){
|
||||
ITxStream<?> stream = (ITxStream<?>) entry.waveform;
|
||||
ITx[] resultsList = new ITx[stream.getMaxConcurrency()];
|
||||
Entry<Long, List<ITxEvent>> firstTx=stream.getEvents().floorEntry(time);
|
||||
} else if(entry.waveform.getType() == WaveformType.TRANSACTION){
|
||||
ITx[] resultsList = new ITx[entry.waveform.getWidth()];
|
||||
Entry<Long, IEvent[]> firstTx=entry.waveform.getEvents().floorEntry(time);
|
||||
if(firstTx!=null){
|
||||
do {
|
||||
for(ITxEvent evt:firstTx.getValue()){
|
||||
ITx tx=evt.getTransaction();
|
||||
if(evt.getType()==ITxEvent.Type.BEGIN && tx.getBeginTime()<=time && tx.getEndTime()>=time){
|
||||
for(IEvent evt:firstTx.getValue()){
|
||||
if(evt instanceof ITxEvent) {
|
||||
ITx tx=((ITxEvent)evt).getTransaction();
|
||||
if(evt.getKind()==EventKind.BEGIN && tx.getBeginTime()<=time && tx.getEndTime()>=time){
|
||||
if(resultsList[tx.getConcurrencyIndex()]==null)
|
||||
resultsList[tx.getConcurrencyIndex()]= evt.getTransaction();
|
||||
resultsList[tx.getConcurrencyIndex()]= ((ITxEvent)evt).getTransaction();
|
||||
}
|
||||
}
|
||||
}
|
||||
firstTx=stream.getEvents().lowerEntry(firstTx.getKey());
|
||||
firstTx=entry.waveform.getEvents().lowerEntry(firstTx.getKey());
|
||||
}while(firstTx!=null && !isArrayFull(resultsList));
|
||||
entry.currentValue="";
|
||||
boolean separator=false;
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for(ITx o:resultsList){
|
||||
if(separator) entry.currentValue+="|";
|
||||
if(o!=null) entry.currentValue+=((ITx)o).getGenerator().getName();
|
||||
|
||||
if(separator) sb.append("|");
|
||||
if(o!=null) sb.append(o.getGenerator().getName());
|
||||
separator=true;
|
||||
}
|
||||
entry.currentValue=sb.toString();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
int width = calculateValueWidth();
|
||||
valueList.setSize(width, trackVerticalHeight);
|
||||
valueListScrolled.setMinSize(width, trackVerticalHeight);
|
||||
valueList.setSize(width, tracksVerticalHeight);
|
||||
valueListScrolled.setMinSize(width, tracksVerticalHeight);
|
||||
valueListScrolled.redraw();
|
||||
}
|
||||
|
||||
@ -688,7 +666,6 @@ public class WaveformView implements IWaveformView {
|
||||
if (currentTxSelection != null) {
|
||||
sel.add(currentTxSelection);
|
||||
}
|
||||
// sel.addAll(currentWaveformSelection.stream().map(e -> e.waveform).collect(Collectors.toList()));
|
||||
sel.addAll(currentWaveformSelection);
|
||||
return new StructuredSelection(sel.toArray());
|
||||
}
|
||||
@ -730,16 +707,10 @@ public class WaveformView implements IWaveformView {
|
||||
ITx txSel = (ITx) sel;
|
||||
TrackEntry trackEntry = getEntryForStream(txSel.getStream());
|
||||
if(trackEntry==null && addIfNeeded){
|
||||
trackEntry=new TrackEntry(txSel.getStream());
|
||||
// compute fallback colors
|
||||
Color fallbackColors[] = TrackEntry.computeColor(txSel.getStream().getName(), TrackEntry.fallbackColor, TrackEntry.highlightedFallbackColor);
|
||||
trackEntry.setColor(fallbackColors[0], fallbackColors[1]);
|
||||
trackEntry=new TrackEntry(txSel.getStream(), styleProvider);
|
||||
streams.add(trackEntry);
|
||||
}
|
||||
currentTxSelection = txSel;
|
||||
// if(trackEntry!=null) {
|
||||
// currentWaveformSelection.add((TrackEntry)sel);
|
||||
// }
|
||||
selectionChanged = true;
|
||||
} else if (sel instanceof TrackEntry && !currentWaveformSelection.contains(sel)) {
|
||||
currentWaveformSelection.add((TrackEntry)sel);
|
||||
@ -750,7 +721,7 @@ public class WaveformView implements IWaveformView {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (currentTxSelection != null || currentWaveformSelection.size() > 0)
|
||||
if (currentTxSelection != null || !currentWaveformSelection.isEmpty())
|
||||
selectionChanged = true;
|
||||
currentTxSelection = null;
|
||||
currentWaveformSelection.clear();
|
||||
@ -804,15 +775,14 @@ public class WaveformView implements IWaveformView {
|
||||
else if(currentWaveformSelection.size()!=1) return;
|
||||
if(selectedWaveform==null)
|
||||
selectedWaveform = currentWaveformSelection.get(1);
|
||||
if (selectedWaveform!=null && selectedWaveform.isStream() && currentTxSelection!=null) {
|
||||
if (selectedWaveform!=null && selectedWaveform.waveform.getType()==WaveformType.TRANSACTION && currentTxSelection!=null) {
|
||||
if(relationType.equals(IWaveformView.NEXT_PREV_IN_STREAM)){
|
||||
ITxStream<? extends ITxEvent> stream = selectedWaveform.getStream();
|
||||
ITx transaction = null;
|
||||
if (direction == GotoDirection.NEXT) {
|
||||
List<ITxEvent> thisEntryList = stream.getEvents().get(currentTxSelection.getBeginTime());
|
||||
ITxEvent[] thisEntryList = (ITxEvent[]) selectedWaveform.waveform.getEvents().get(currentTxSelection.getBeginTime());
|
||||
boolean meFound=false;
|
||||
for (ITxEvent evt : thisEntryList) {
|
||||
if (evt.getType() == ITxEvent.Type.BEGIN) {
|
||||
if (evt.getKind() == EventKind.BEGIN) {
|
||||
if(meFound){
|
||||
transaction = evt.getTransaction();
|
||||
break;
|
||||
@ -821,42 +791,42 @@ public class WaveformView implements IWaveformView {
|
||||
}
|
||||
}
|
||||
if (transaction == null){
|
||||
Entry<Long, List<ITxEvent>> entry = stream.getEvents().higherEntry(currentTxSelection.getBeginTime());
|
||||
Entry<Long, IEvent[]> entry = selectedWaveform.waveform.getEvents().higherEntry(currentTxSelection.getBeginTime());
|
||||
if (entry != null) do {
|
||||
for (ITxEvent evt : entry.getValue()) {
|
||||
if (evt.getType() == ITxEvent.Type.BEGIN) {
|
||||
transaction = evt.getTransaction();
|
||||
for (IEvent evt : entry.getValue()) {
|
||||
if (evt instanceof ITxEvent && evt.getKind() == EventKind.BEGIN) {
|
||||
transaction = ((ITxEvent)evt).getTransaction();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (transaction == null)
|
||||
entry = stream.getEvents().higherEntry(entry.getKey());
|
||||
entry = selectedWaveform.waveform.getEvents().higherEntry(entry.getKey());
|
||||
} while (entry != null && transaction == null);
|
||||
}
|
||||
} else if (direction == GotoDirection.PREV) {
|
||||
List<ITxEvent> thisEntryList = stream.getEvents().get(currentTxSelection.getBeginTime());
|
||||
IEvent[] thisEntryList = selectedWaveform.waveform.getEvents().get(currentTxSelection.getBeginTime());
|
||||
boolean meFound=false;
|
||||
for (ITxEvent evt : Lists.reverse(thisEntryList)) {
|
||||
if (evt.getType() == ITxEvent.Type.BEGIN) {
|
||||
for (IEvent evt : Lists.reverse(Arrays.asList(thisEntryList))) {
|
||||
if (evt instanceof ITxEvent && evt.getKind() == EventKind.BEGIN) {
|
||||
if(meFound){
|
||||
transaction = evt.getTransaction();
|
||||
transaction = ((ITxEvent)evt).getTransaction();
|
||||
break;
|
||||
}
|
||||
meFound|= evt.getTransaction().equals(currentTxSelection);
|
||||
meFound|= ((ITxEvent)evt).getTransaction().equals(currentTxSelection);
|
||||
}
|
||||
}
|
||||
if (transaction == null){
|
||||
Entry<Long, List<ITxEvent>> entry = stream.getEvents().lowerEntry(currentTxSelection.getBeginTime());
|
||||
Entry<Long, IEvent[]> entry = selectedWaveform.waveform.getEvents().lowerEntry(currentTxSelection.getBeginTime());
|
||||
if (entry != null)
|
||||
do {
|
||||
for (ITxEvent evt : Lists.reverse(entry.getValue())) {
|
||||
if (evt.getType() == ITxEvent.Type.BEGIN) {
|
||||
transaction = evt.getTransaction();
|
||||
for (IEvent evt : Lists.reverse(Arrays.asList(thisEntryList))) {
|
||||
if (evt instanceof ITxEvent && evt.getKind() == EventKind.BEGIN) {
|
||||
transaction = ((ITxEvent)evt).getTransaction();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (transaction == null)
|
||||
entry = stream.getEvents().lowerEntry(entry.getKey());
|
||||
entry = selectedWaveform.waveform.getEvents().lowerEntry(entry.getKey());
|
||||
} while (entry != null && transaction == null);
|
||||
}
|
||||
}
|
||||
@ -879,13 +849,12 @@ public class WaveformView implements IWaveformView {
|
||||
|
||||
private ITxRelation selectTxToNavigateTo(Collection<ITxRelation> rel, RelationType relationType, boolean target) {
|
||||
ArrayList<ITxRelation> candidates = rel.stream().filter(r -> relationType.equals(r.getRelationType())).collect(Collectors.toCollection(ArrayList::new));
|
||||
//new RelSelectionDialog(waveformCanvas.getShell(), candidates, target).open();
|
||||
switch (candidates.size()) {
|
||||
case 0: return null;
|
||||
case 1: return candidates.get(0);
|
||||
default:
|
||||
ArrayList<ITxRelation> visibleCandidates = candidates.stream().filter(r -> streamsVisible(r)).collect(Collectors.toCollection(ArrayList::new));
|
||||
if(visibleCandidates.size()==0) {
|
||||
ArrayList<ITxRelation> visibleCandidates = candidates.stream().filter(this::streamsVisible).collect(Collectors.toCollection(ArrayList::new));
|
||||
if(visibleCandidates.isEmpty()) {
|
||||
return new RelSelectionDialog(waveformCanvas.getShell(), candidates, target).open();
|
||||
} else if(visibleCandidates.size()==1) {
|
||||
return visibleCandidates.size()==1?visibleCandidates.get(0):null;
|
||||
@ -896,8 +865,8 @@ public class WaveformView implements IWaveformView {
|
||||
}
|
||||
|
||||
private boolean streamsVisible(ITxRelation relation) {
|
||||
final ITxStream<ITxEvent> src = relation.getSource().getStream();
|
||||
final ITxStream<ITxEvent> tgt = relation.getTarget().getStream();
|
||||
final IWaveform src = relation.getSource().getStream();
|
||||
final IWaveform tgt = relation.getTarget().getStream();
|
||||
return streams.stream().anyMatch(x -> x.waveform == src) && streams.stream().anyMatch(x -> x.waveform == tgt);
|
||||
}
|
||||
|
||||
@ -910,10 +879,8 @@ public class WaveformView implements IWaveformView {
|
||||
TrackEntry sel = currentWaveformSelection.get(0);
|
||||
long time = getCursorTime();
|
||||
NavigableMap<Long, ?> map=null;
|
||||
if(sel.isStream()){
|
||||
map=sel.getStream().getEvents();
|
||||
} else if(sel.isSignal()){
|
||||
map=sel.getSignal().getEvents();
|
||||
if(sel.waveform.getType()==WaveformType.TRANSACTION || sel.waveform.getType()==WaveformType.SIGNAL){
|
||||
map=sel.waveform.getEvents();
|
||||
}
|
||||
if(map!=null){
|
||||
Entry<Long, ?> entry=direction==GotoDirection.PREV?map.lowerEntry(time):map.higherEntry(time);
|
||||
@ -940,12 +907,12 @@ public class WaveformView implements IWaveformView {
|
||||
*/
|
||||
@Override
|
||||
public void deleteSelectedTracks() {
|
||||
List<TrackEntry> streams = getStreamList();
|
||||
List<TrackEntry> streamList = getStreamList();
|
||||
for (Object o : (IStructuredSelection)getSelection()) {
|
||||
if(o instanceof TrackEntry) {
|
||||
TrackEntry e = (TrackEntry) o;
|
||||
e.selected=false;
|
||||
streams.remove(e);
|
||||
streamList.remove(e);
|
||||
}
|
||||
}
|
||||
setSelection(new StructuredSelection());
|
||||
@ -956,7 +923,7 @@ public class WaveformView implements IWaveformView {
|
||||
*/
|
||||
@Override
|
||||
public void moveSelectedTrack(int i) {
|
||||
if(currentWaveformSelection.size()>0){
|
||||
if(!currentWaveformSelection.isEmpty()){
|
||||
int idx = streams.indexOf(currentWaveformSelection.get(0));
|
||||
for(Object o: currentWaveformSelection)
|
||||
streams.remove(o);
|
||||
@ -971,25 +938,25 @@ public class WaveformView implements IWaveformView {
|
||||
|
||||
|
||||
protected void paintNames(GC gc, Rectangle rect) {
|
||||
if (streams.size() > 0) {
|
||||
if (!streams.isEmpty()) {
|
||||
try {
|
||||
Integer firstKey = trackVerticalOffset.floorKey(rect.y);
|
||||
if (firstKey == null)
|
||||
firstKey = trackVerticalOffset.firstKey();
|
||||
Integer lastKey = trackVerticalOffset.floorKey(rect.y + rect.height);
|
||||
Rectangle subArea = new Rectangle(rect.x, 0, rect.width, waveformCanvas.getTrackHeight());
|
||||
if (lastKey == firstKey) {
|
||||
Rectangle subArea = new Rectangle(rect.x, 0, rect.width, styleProvider.getTrackHeight());
|
||||
if (lastKey.equals(firstKey)) {
|
||||
TrackEntry trackEntry=trackVerticalOffset.get(firstKey);
|
||||
IWaveform w = trackEntry.waveform;
|
||||
if (w instanceof ITxStream<?>)
|
||||
subArea.height *= ((ITxStream<?>) w).getMaxConcurrency();
|
||||
if (w.getType()==WaveformType.TRANSACTION)
|
||||
subArea.height *= w.getWidth();
|
||||
drawTextFormat(gc, subArea, firstKey, w.getFullName(), trackEntry.selected);
|
||||
} else {
|
||||
for (Entry<Integer, TrackEntry> entry : trackVerticalOffset.subMap(firstKey, true, lastKey, true).entrySet()) {
|
||||
IWaveform w = entry.getValue().waveform;
|
||||
subArea.height = waveformCanvas.getTrackHeight();
|
||||
if (w instanceof ITxStream<?>)
|
||||
subArea.height *= ((ITxStream<?>) w).getMaxConcurrency();
|
||||
subArea.height = styleProvider.getTrackHeight();
|
||||
if (w.getType()==WaveformType.TRANSACTION)
|
||||
subArea.height *= w.getWidth();
|
||||
drawTextFormat(gc, subArea, entry.getKey(), w.getFullName(), entry.getValue().selected);
|
||||
}
|
||||
}
|
||||
@ -998,26 +965,26 @@ public class WaveformView implements IWaveformView {
|
||||
}
|
||||
|
||||
protected void paintValues(GC gc, Rectangle rect) {
|
||||
if (streams.size() > 0) {
|
||||
if (!streams.isEmpty()) {
|
||||
try {
|
||||
Integer firstKey = trackVerticalOffset.floorKey(rect.y);
|
||||
if (firstKey == null)
|
||||
firstKey = trackVerticalOffset.firstKey();
|
||||
Integer lastKey = trackVerticalOffset.floorKey(rect.y + rect.height);
|
||||
Rectangle subArea = new Rectangle(rect.x, 0, rect.width, waveformCanvas.getTrackHeight());
|
||||
if (lastKey == firstKey) {
|
||||
Rectangle subArea = new Rectangle(rect.x, 0, rect.width, styleProvider.getTrackHeight());
|
||||
if (lastKey.equals(firstKey)) {
|
||||
TrackEntry trackEntry=trackVerticalOffset.get(firstKey);
|
||||
IWaveform w = trackEntry.waveform;
|
||||
if (w instanceof ITxStream<?>)
|
||||
subArea.height *= ((ITxStream<?>) w).getMaxConcurrency();
|
||||
if (w.getType()==WaveformType.TRANSACTION)
|
||||
subArea.height *= w.getWidth();
|
||||
drawValue(gc, subArea, firstKey, trackEntry.currentValue, trackEntry.selected);
|
||||
} else {
|
||||
for (Entry<Integer, TrackEntry> entry : trackVerticalOffset.subMap(firstKey, true, lastKey, true)
|
||||
.entrySet()) {
|
||||
IWaveform w = entry.getValue().waveform;
|
||||
subArea.height = waveformCanvas.getTrackHeight();
|
||||
if (w instanceof ITxStream<?>)
|
||||
subArea.height *= ((ITxStream<?>) w).getMaxConcurrency();
|
||||
subArea.height = styleProvider.getTrackHeight();
|
||||
if (w.getType()==WaveformType.TRANSACTION)
|
||||
subArea.height *= w.getWidth();
|
||||
drawValue(gc, subArea, entry.getKey(), entry.getValue().currentValue, entry.getValue().selected);
|
||||
}
|
||||
}
|
||||
@ -1027,10 +994,10 @@ public class WaveformView implements IWaveformView {
|
||||
|
||||
protected void drawValue(GC gc, Rectangle subArea, Integer yOffset, String value, boolean highlite) {
|
||||
int beginIndex=0;
|
||||
for(int offset=0; offset<subArea.height; offset+=waveformCanvas.getTrackHeight()){
|
||||
for(int offset=0; offset<subArea.height; offset+=styleProvider.getTrackHeight()){
|
||||
int endIndex=value.indexOf('|', beginIndex);
|
||||
String str = endIndex<0?value.substring(beginIndex):value.substring(beginIndex, endIndex);
|
||||
drawTextFormat(gc, new Rectangle(subArea.x, subArea.y, subArea.width, waveformCanvas.getTrackHeight()), yOffset+offset, str, highlite);
|
||||
drawTextFormat(gc, new Rectangle(subArea.x, subArea.y, subArea.width, styleProvider.getTrackHeight()), yOffset+offset, str, highlite);
|
||||
beginIndex=endIndex<0?beginIndex:endIndex+1;
|
||||
}
|
||||
}
|
||||
@ -1041,13 +1008,13 @@ public class WaveformView implements IWaveformView {
|
||||
gc.setBackground(SWTResourceManager.getColor(SWT.COLOR_LIST_SELECTION));
|
||||
gc.setForeground(SWTResourceManager.getColor(SWT.COLOR_LIST_SELECTION_TEXT));
|
||||
gc.fillRectangle(subArea.x, subArea.y + yOffset, subArea.width, subArea.height);
|
||||
gc.setFont(nameFontB);
|
||||
gc.setFont(styleProvider.getNameFontHighlite());
|
||||
} else {
|
||||
gc.setBackground(namePaneHeader.getBackground());
|
||||
gc.setForeground(namePaneHeader.getForeground());
|
||||
gc.setFont(nameFont);
|
||||
gc.setFont(styleProvider.getNameFont());
|
||||
}
|
||||
gc.drawText(value, subArea.x + 5, subArea.y + yOffset + (waveformCanvas.getTrackHeight() - size.y) / 2, true);
|
||||
gc.drawText(value, subArea.x + 5, subArea.y + yOffset + (styleProvider.getTrackHeight() - size.y) / 2, true);
|
||||
}
|
||||
|
||||
|
||||
@ -1146,13 +1113,14 @@ public class WaveformView implements IWaveformView {
|
||||
DragSource dragSource = new DragSource(canvas, DND.DROP_MOVE);
|
||||
dragSource.setTransfer(types);
|
||||
dragSource.addDragListener(new DragSourceAdapter() {
|
||||
@Override
|
||||
public void dragStart(DragSourceEvent event) {
|
||||
if (event.y < trackVerticalHeight) {
|
||||
if (event.y < tracksVerticalHeight) {
|
||||
event.doit = true;
|
||||
LocalSelectionTransfer.getTransfer().setSelection(new StructuredSelection(currentWaveformSelection));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dragSetData(DragSourceEvent event) {
|
||||
if (LocalSelectionTransfer.getTransfer().isSupportedType(event.dataType)) {
|
||||
event.data =getSelection();
|
||||
@ -1168,10 +1136,11 @@ public class WaveformView implements IWaveformView {
|
||||
|
||||
dropTarget.addDropListener(new DropTargetAdapter() {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void drop(DropTargetEvent event) {
|
||||
if (LocalSelectionTransfer.getTransfer().isSupportedType(event.currentDataType)){
|
||||
ISelection s = LocalSelectionTransfer.getTransfer().getSelection();
|
||||
if(s!=null && s instanceof IStructuredSelection){
|
||||
if(s instanceof IStructuredSelection){
|
||||
IStructuredSelection sel = (IStructuredSelection) s;
|
||||
for(Object o: sel.toList())
|
||||
streams.remove(o);
|
||||
@ -1188,7 +1157,7 @@ public class WaveformView implements IWaveformView {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dropAccept(DropTargetEvent event) {
|
||||
if (event.detail != DND.DROP_MOVE) {
|
||||
event.detail = DND.DROP_NONE;
|
||||
@ -1199,7 +1168,7 @@ public class WaveformView implements IWaveformView {
|
||||
|
||||
public TrackEntry getEntryForStream(IWaveform source) {
|
||||
for(TrackEntry trackEntry:streams)
|
||||
if(trackEntry.waveform.equals(source)) return trackEntry;
|
||||
if(trackEntry.waveform.isSame(source)) return trackEntry;
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -1212,6 +1181,7 @@ public class WaveformView implements IWaveformView {
|
||||
DragSource dragSource = new DragSource(canvas, DND.DROP_MOVE);
|
||||
dragSource.setTransfer(types);
|
||||
dragSource.addDragListener(new DragSourceAdapter() {
|
||||
@Override
|
||||
public void dragStart(DragSourceEvent event) {
|
||||
event.doit = false;
|
||||
List<Object> clicked = waveformCanvas.getElementsAt(new Point(event.x, event.y));
|
||||
@ -1224,13 +1194,22 @@ public class WaveformView implements IWaveformView {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dragSetData(DragSourceEvent event) {
|
||||
if (LocalSelectionTransfer.getTransfer().isSupportedType(event.dataType)) {
|
||||
event.data=waveformCanvas.getElementsAt(new Point(event.x, event.y));
|
||||
}
|
||||
}
|
||||
});
|
||||
// int style = SWT.MULTI | SWT.WRAP | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER;
|
||||
// final StyledText text = new StyledText(waveformCanvas, style);
|
||||
// text.setText("Dragging");
|
||||
// dragSource.setDragSourceEffect(new DragSourceEffect(text) {
|
||||
// @Override
|
||||
// public void dragStart(DragSourceEvent event) {
|
||||
// event.image = waveformCanvas.getDisplay().getSystemImage(SWT.ICON_WARNING);
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
private void createWaveformDropTarget(final Canvas canvas) {
|
||||
@ -1238,10 +1217,11 @@ public class WaveformView implements IWaveformView {
|
||||
DropTarget dropTarget = new DropTarget(canvas, DND.DROP_MOVE);
|
||||
dropTarget.setTransfer(types);
|
||||
dropTarget.addDropListener(new DropTargetAdapter() {
|
||||
@Override
|
||||
public void drop(DropTargetEvent event) {
|
||||
if (LocalSelectionTransfer.getTransfer().isSupportedType(event.currentDataType)){
|
||||
ISelection sel = LocalSelectionTransfer.getTransfer().getSelection();
|
||||
if(sel!=null && sel instanceof IStructuredSelection &&
|
||||
if(sel instanceof IStructuredSelection &&
|
||||
((IStructuredSelection)sel).getFirstElement() instanceof CursorPainter){
|
||||
CursorPainter painter = (CursorPainter)((IStructuredSelection)sel).getFirstElement();
|
||||
painter.setDragging(false);
|
||||
@ -1249,17 +1229,17 @@ public class WaveformView implements IWaveformView {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dropAccept(DropTargetEvent event) {
|
||||
Point offset = canvas.toControl(event.x, event.y);
|
||||
if (event.detail != DND.DROP_MOVE || offset.y > trackVerticalOffset.lastKey() + waveformCanvas.getTrackHeight()) {
|
||||
if (event.detail != DND.DROP_MOVE || offset.y > trackVerticalOffset.lastKey() + styleProvider.getTrackHeight()) {
|
||||
event.detail = DND.DROP_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dragOver(DropTargetEvent event){
|
||||
ISelection sel = LocalSelectionTransfer.getTransfer().getSelection();
|
||||
if(sel!=null && sel instanceof IStructuredSelection &&
|
||||
if(sel instanceof IStructuredSelection &&
|
||||
((IStructuredSelection)sel).getFirstElement() instanceof CursorPainter){
|
||||
updateWaveform(canvas, event, (CursorPainter) ((IStructuredSelection)sel).getFirstElement());
|
||||
}
|
||||
@ -1276,13 +1256,10 @@ public class WaveformView implements IWaveformView {
|
||||
pcs.firePropertyChange(MARKER_PROPERTY, oldVal, time);
|
||||
pcs.firePropertyChange(MARKER_PROPERTY+painter.id, oldVal, time);
|
||||
}
|
||||
canvas.getDisplay().asyncExec(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if(!canvas.isDisposed()){
|
||||
canvas.redraw();
|
||||
updateValueList();
|
||||
}
|
||||
canvas.getDisplay().asyncExec(() -> {
|
||||
if(!canvas.isDisposed()){
|
||||
canvas.redraw();
|
||||
updateValueList();
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -1340,8 +1317,8 @@ public class WaveformView implements IWaveformView {
|
||||
@Override
|
||||
public String getScaledTime(long time) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
Double dTime=new Double(time);
|
||||
Double scaledTime = dTime/waveformCanvas.getScaleFactorPow10();
|
||||
double dTime=time;
|
||||
double scaledTime = dTime/waveformCanvas.getScaleFactorPow10();
|
||||
return sb.append(df.format(scaledTime)).append(waveformCanvas.getUnitStr()).toString();
|
||||
}
|
||||
|
||||
@ -1350,21 +1327,16 @@ public class WaveformView implements IWaveformView {
|
||||
*/
|
||||
@Override
|
||||
public String[] getZoomLevels(){
|
||||
String[] res = new String[Constants.unitMultiplier.length*Constants.unitString.length];
|
||||
String[] res = new String[Constants.UNIT_MULTIPLIER.length*Constants.UNIT_STRING.length];
|
||||
int index=0;
|
||||
for(String unit:Constants.unitString){
|
||||
for(int factor:Constants.unitMultiplier){
|
||||
res[index++]= new Integer(factor).toString()+unit;
|
||||
for(String unit:Constants.UNIT_STRING){
|
||||
for(int factor:Constants.UNIT_MULTIPLIER){
|
||||
res[index++]= Integer.toString(factor)+unit;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColors(HashMap<WaveformColors, RGB> colourMap) {
|
||||
waveformCanvas.initColors(colourMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getBaselineTime() {
|
||||
return -waveformCanvas.getScaleFactorPow10()*waveformCanvas.getOrigin().x;
|
||||
@ -1388,18 +1360,33 @@ public class WaveformView implements IWaveformView {
|
||||
}
|
||||
|
||||
public void asyncUpdate(Widget widget) {
|
||||
widget.getDisplay().asyncExec(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
waveformCanvas.redraw();
|
||||
updateValueList();
|
||||
}
|
||||
widget.getDisplay().asyncExec(() -> {
|
||||
waveformCanvas.redraw();
|
||||
updateValueList();
|
||||
});
|
||||
}
|
||||
|
||||
/// probably not the way it should be done
|
||||
public void addDisposeListener( DisposeListener listener ) {
|
||||
@Override
|
||||
public void addDisposeListener(DisposeListener listener ) {
|
||||
waveformCanvas.addDisposeListener(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStyleProvider(IWaveformStyleProvider styleProvider) {
|
||||
this.styleProvider=styleProvider;
|
||||
waveformCanvas.setStyleProvider(styleProvider);
|
||||
update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TrackEntry addWaveform(IWaveform waveform, int idx) {
|
||||
TrackEntry e = new TrackEntry(waveform, styleProvider);
|
||||
if(idx<0)
|
||||
getStreamList().add(e);
|
||||
else
|
||||
getStreamList().add(idx, e);
|
||||
return e;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: VCD signal database
|
||||
Bundle-SymbolicName: com.minres.scviewer.database.vcd
|
||||
Bundle-Version: 2.0.2.qualifier
|
||||
Bundle-Version: 2.1.0.qualifier
|
||||
Bundle-Vendor: MINRES Technologies GmbH
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
|
||||
Require-Bundle: com.minres.scviewer.database;bundle-version="1.0.0",
|
||||
|
@ -1,7 +1,7 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>com.minres.scviewer.database.vcd</artifactId>
|
||||
<version>2.0.2-SNAPSHOT</version>
|
||||
<version>2.1.0-SNAPSHOT</version>
|
||||
<parent>
|
||||
<groupId>com.minres.scviewer</groupId>
|
||||
<artifactId>com.minres.scviewer.parent</artifactId>
|
||||
|
@ -14,17 +14,18 @@ import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.NavigableMap;
|
||||
import java.util.Stack;
|
||||
import java.util.TreeMap;
|
||||
import java.util.Vector;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
import com.minres.scviewer.database.BitVector;
|
||||
import com.minres.scviewer.database.ISignal;
|
||||
import com.minres.scviewer.database.DoubleVal;
|
||||
import com.minres.scviewer.database.IEvent;
|
||||
import com.minres.scviewer.database.IWaveform;
|
||||
import com.minres.scviewer.database.IWaveformDb;
|
||||
import com.minres.scviewer.database.IWaveformDbLoader;
|
||||
@ -36,39 +37,30 @@ import com.minres.scviewer.database.RelationType;
|
||||
*/
|
||||
public class VCDDbLoader implements IWaveformDbLoader, IVCDDatabaseBuilder {
|
||||
|
||||
|
||||
|
||||
/** The Constant TIME_RES. */
|
||||
private static final Long TIME_RES = 1000L; // ps;
|
||||
private static final Long TIME_RES = 1000L; // ps
|
||||
|
||||
/** The db. */
|
||||
private IWaveformDb db;
|
||||
|
||||
|
||||
/** The module stack. */
|
||||
private Stack<String> moduleStack;
|
||||
|
||||
private ArrayDeque<String> moduleStack;
|
||||
|
||||
/** The signals. */
|
||||
private List<IWaveform> signals;
|
||||
|
||||
|
||||
/** The max time. */
|
||||
private long maxTime;
|
||||
|
||||
/**
|
||||
* Instantiates a new VCD db.
|
||||
*/
|
||||
public VCDDbLoader() {
|
||||
}
|
||||
|
||||
private static boolean isGzipped(File f) {
|
||||
InputStream is = null;
|
||||
try {
|
||||
is = new FileInputStream(f);
|
||||
try (InputStream is = new FileInputStream(f)) {
|
||||
byte [] signature = new byte[2];
|
||||
int nread = is.read( signature ); //read the gzip signature
|
||||
return nread == 2 && signature[ 0 ] == (byte) 0x1f && signature[ 1 ] == (byte) 0x8b;
|
||||
} catch (IOException e) {
|
||||
}
|
||||
catch (IOException e) {
|
||||
return false;
|
||||
} finally {
|
||||
try { is.close();} catch (IOException e) { }
|
||||
}
|
||||
}
|
||||
|
||||
@ -78,25 +70,31 @@ public class VCDDbLoader implements IWaveformDbLoader, IVCDDatabaseBuilder {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public boolean load(IWaveformDb db, File file) throws Exception {
|
||||
public boolean load(IWaveformDb db, File file) throws InputFormatException {
|
||||
if(file.isDirectory() || !file.exists()) return false;
|
||||
this.db=db;
|
||||
this.maxTime=0;
|
||||
String name = file.getCanonicalFile().getName();
|
||||
if(!(name.endsWith(".vcd") ||
|
||||
name.endsWith(".vcdz") ||
|
||||
name.endsWith(".vcdgz") ||
|
||||
name.endsWith(".vcd.gz")) )
|
||||
return false;
|
||||
signals = new Vector<IWaveform>();
|
||||
moduleStack= new Stack<String>();
|
||||
FileInputStream fis = new FileInputStream(file);
|
||||
boolean res = new VCDFileParser(false).load(isGzipped(file)?new GZIPInputStream(fis):fis, this);
|
||||
moduleStack=null;
|
||||
boolean res = false;
|
||||
try {
|
||||
String name = file.getCanonicalFile().getName();
|
||||
if(!(name.endsWith(".vcd") ||
|
||||
name.endsWith(".vcdz") ||
|
||||
name.endsWith(".vcdgz") ||
|
||||
name.endsWith(".vcd.gz")) )
|
||||
return false;
|
||||
signals = new Vector<>();
|
||||
moduleStack= new ArrayDeque<>();
|
||||
FileInputStream fis = new FileInputStream(file);
|
||||
res = new VCDFileParser(false).load(isGzipped(file)?new GZIPInputStream(fis):fis, this);
|
||||
moduleStack=null;
|
||||
} catch(IOException e) {
|
||||
moduleStack=null;
|
||||
throw new InputFormatException();
|
||||
}
|
||||
if(!res) throw new InputFormatException();
|
||||
// calculate max time of database
|
||||
for(IWaveform waveform:signals) {
|
||||
NavigableMap<Long, ?> events =((ISignal<?>)waveform).getEvents();
|
||||
NavigableMap<Long, IEvent[]> events =waveform.getEvents();
|
||||
if(events.size()>0)
|
||||
maxTime= Math.max(maxTime, events.lastKey());
|
||||
}
|
||||
@ -108,8 +106,8 @@ public class VCDDbLoader implements IWaveformDbLoader, IVCDDatabaseBuilder {
|
||||
Object val = events.lastEntry().getValue();
|
||||
if(val instanceof BitVector) {
|
||||
((VCDSignal<BitVector>)s).addSignalChange(maxTime, (BitVector) val);
|
||||
} else if(val instanceof Double)
|
||||
((VCDSignal<Double>)s).addSignalChange(maxTime, (Double) val);
|
||||
} else if(val instanceof DoubleVal)
|
||||
((VCDSignal<DoubleVal>)s).addSignalChange(maxTime, (DoubleVal) val);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -158,12 +156,11 @@ public class VCDDbLoader implements IWaveformDbLoader, IVCDDatabaseBuilder {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Integer newNet(String name, int i, int width) {
|
||||
String netName = moduleStack.empty()? name: moduleStack.lastElement()+"."+name;
|
||||
String netName = moduleStack.isEmpty()? name: moduleStack.peek()+"."+name;
|
||||
int id = signals.size();
|
||||
assert(width>=0);
|
||||
if(width==0) {
|
||||
signals.add( i<0 ? new VCDSignal<Double>(db, id, netName, width) :
|
||||
new VCDSignal<Double>((VCDSignal<Double>)signals.get(i), id, netName));
|
||||
signals.add( i<0 ? new VCDSignal<DoubleVal>(db, id, netName, width) :
|
||||
new VCDSignal<DoubleVal>((VCDSignal<DoubleVal>)signals.get(i), id, netName));
|
||||
} else if(width>0){
|
||||
signals.add( i<0 ? new VCDSignal<BitVector>(db, id, netName, width) :
|
||||
new VCDSignal<BitVector>((VCDSignal<BitVector>)signals.get(i), id, netName));
|
||||
@ -188,22 +185,20 @@ public class VCDDbLoader implements IWaveformDbLoader, IVCDDatabaseBuilder {
|
||||
public void appendTransition(int signalId, long currentTime, BitVector value) {
|
||||
VCDSignal<BitVector> signal = (VCDSignal<BitVector>) signals.get(signalId);
|
||||
Long time = currentTime* TIME_RES;
|
||||
signal.getEvents().put(time, value);
|
||||
signal.addSignalChange(time, value);
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.minres.scviewer.database.vcd.ITraceBuilder#appendTransition(int, long, com.minres.scviewer.database.vcd.BitVector)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void appendTransition(int signalId, long currentTime, double value) {
|
||||
VCDSignal<?> signal = (VCDSignal<?>) signals.get(signalId);
|
||||
VCDSignal<DoubleVal> signal = (VCDSignal<DoubleVal>) signals.get(signalId);
|
||||
Long time = currentTime* TIME_RES;
|
||||
if(signal.getWidth()==0){
|
||||
((VCDSignal<Double>)signal).getEvents().put(time, value);
|
||||
}
|
||||
signal.addSignalChange(time, new DoubleVal(value));
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.minres.scviewer.database.IWaveformDbLoader#getAllRelationTypes()
|
||||
*/
|
||||
|
@ -11,6 +11,7 @@
|
||||
package com.minres.scviewer.database.vcd;
|
||||
|
||||
import java.io.*;
|
||||
import java.text.ParseException;
|
||||
import java.util.*;
|
||||
|
||||
import com.minres.scviewer.database.BitValue;
|
||||
@ -19,7 +20,7 @@ import com.minres.scviewer.database.BitVector;
|
||||
class VCDFileParser {
|
||||
private StreamTokenizer tokenizer;
|
||||
private IVCDDatabaseBuilder traceBuilder;
|
||||
private HashMap<String, Integer> nameToNetMap = new HashMap<String, Integer>();
|
||||
private HashMap<String, Integer> nameToNetMap = new HashMap<>();
|
||||
private long picoSecondsPerIncrement;
|
||||
private boolean stripNetWidth;
|
||||
private boolean replaceColon;
|
||||
@ -50,19 +51,19 @@ class VCDFileParser {
|
||||
}
|
||||
}
|
||||
|
||||
private void parseScope() throws Exception {
|
||||
private void parseScope() throws IOException, ParseException {
|
||||
nextToken(); // Scope type (ignore)
|
||||
nextToken();
|
||||
traceBuilder.enterModule(tokenizer.sval);
|
||||
match("$end");
|
||||
}
|
||||
|
||||
private void parseUpscope() throws Exception {
|
||||
private void parseUpscope() throws IOException, ParseException {
|
||||
match("$end");
|
||||
traceBuilder.exitModule();
|
||||
}
|
||||
|
||||
private void parseVar() throws Exception {
|
||||
private void parseVar() throws IOException {
|
||||
nextToken(); // type
|
||||
String type = tokenizer.sval;
|
||||
nextToken(); // size
|
||||
@ -72,11 +73,12 @@ class VCDFileParser {
|
||||
nextToken();
|
||||
String id = tokenizer.sval;
|
||||
nextToken();
|
||||
String netName = tokenizer.sval;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(tokenizer.sval);
|
||||
while (nextToken() && !tokenizer.sval.equals("$end")) {
|
||||
netName+=tokenizer.sval;
|
||||
sb.append(tokenizer.sval);
|
||||
}
|
||||
|
||||
String netName = sb.toString();
|
||||
Integer net = nameToNetMap.get(id);
|
||||
if (net == null) { // We've never seen this net before
|
||||
int openBracket = netName.indexOf('[');
|
||||
@ -86,9 +88,9 @@ class VCDFileParser {
|
||||
}
|
||||
if(replaceColon) {
|
||||
if (openBracket != -1) {
|
||||
netName = netName.substring(0, openBracket).replaceAll(":", ".")+netName.substring(openBracket);
|
||||
netName = netName.substring(0, openBracket).replace(":", ".")+netName.substring(openBracket);
|
||||
} else
|
||||
netName=netName.replaceAll(":", ".");
|
||||
netName=netName.replace(":", ".");
|
||||
}
|
||||
nameToNetMap.put(id, traceBuilder.newNet(netName, -1, width));
|
||||
} else {
|
||||
@ -97,25 +99,28 @@ class VCDFileParser {
|
||||
}
|
||||
}
|
||||
|
||||
private void parseComment() throws Exception {
|
||||
private void parseComment() throws IOException {
|
||||
nextToken();
|
||||
String s = tokenizer.sval;
|
||||
StringBuilder s = new StringBuilder();
|
||||
s.append(tokenizer.sval);
|
||||
nextToken();
|
||||
while(!tokenizer.sval.equals("$end")){
|
||||
s+=" "+tokenizer.sval;
|
||||
s.append(" ").append(tokenizer.sval);
|
||||
nextToken();
|
||||
}
|
||||
replaceColon|=s.contains("ARTERIS Architecture");
|
||||
replaceColon|=s.toString().contains("ARTERIS Architecture");
|
||||
}
|
||||
|
||||
private void parseTimescale() throws Exception {
|
||||
private void parseTimescale() throws IOException {
|
||||
nextToken();
|
||||
String s = tokenizer.sval;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(tokenizer.sval);
|
||||
nextToken();
|
||||
while(!tokenizer.sval.equals("$end")){
|
||||
s+=" "+tokenizer.sval;
|
||||
sb.append(" ").append(tokenizer.sval);
|
||||
nextToken();
|
||||
}
|
||||
String s = sb.toString();
|
||||
switch (s.charAt(s.length() - 2)){
|
||||
case 'p': // Nano-seconds
|
||||
picoSecondsPerIncrement = 1;
|
||||
@ -141,7 +146,7 @@ class VCDFileParser {
|
||||
picoSecondsPerIncrement *= Long.parseLong(s);
|
||||
}
|
||||
|
||||
private boolean parseDefinition() throws Exception {
|
||||
private boolean parseDefinition() throws IOException, ParseException {
|
||||
nextToken();
|
||||
if (tokenizer.sval.equals("$scope"))
|
||||
parseScope();
|
||||
@ -166,7 +171,7 @@ class VCDFileParser {
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean parseTransition() throws Exception {
|
||||
private boolean parseTransition() throws IOException {
|
||||
if (!nextToken()) return false;
|
||||
if (tokenizer.sval.charAt(0) == '#') { // If the line begins with a #, this is a timestamp.
|
||||
currentTime = Long.parseLong(tokenizer.sval.substring(1)) * picoSecondsPerIncrement;
|
||||
@ -179,19 +184,13 @@ class VCDFileParser {
|
||||
}
|
||||
if (tokenizer.sval.equals("$dumpvars") || tokenizer.sval.equals("$end"))
|
||||
return true;
|
||||
String value, id;
|
||||
if (tokenizer.sval.charAt(0) == 'b') {
|
||||
// Multiple value net. Value appears first, followed by space,
|
||||
// then identifier
|
||||
String value;
|
||||
String id;
|
||||
if (tokenizer.sval.charAt(0) == 'b' || tokenizer.sval.charAt(0) == 'r') {
|
||||
// Multiple value net. Value appears first, followed by space, then identifier
|
||||
value = tokenizer.sval.substring(1);
|
||||
nextToken();
|
||||
id = tokenizer.sval;
|
||||
}else if (tokenizer.sval.charAt(0) == 'r') {
|
||||
// Multiple value net. Value appears first, followed by space,
|
||||
// then identifier
|
||||
value = tokenizer.sval.substring(1);
|
||||
nextToken();
|
||||
id = tokenizer.sval;
|
||||
} else {
|
||||
// Single value net. identifier first, then value, no space.
|
||||
value = tokenizer.sval.substring(0, 1);
|
||||
@ -199,10 +198,8 @@ class VCDFileParser {
|
||||
}
|
||||
|
||||
Integer net = nameToNetMap.get(id);
|
||||
if (net == null) {
|
||||
System.out.println("unknown net " + id + " value " + value);
|
||||
if (net == null)
|
||||
return true;
|
||||
}
|
||||
|
||||
int netWidth = traceBuilder.getNetWidth(net);
|
||||
if(netWidth==0) {
|
||||
@ -253,14 +250,14 @@ class VCDFileParser {
|
||||
return true;
|
||||
}
|
||||
|
||||
private void match(String value) throws Exception {
|
||||
private void match(String value) throws ParseException, IOException {
|
||||
nextToken();
|
||||
if (!tokenizer.sval.equals(value))
|
||||
throw new Exception("Line "+tokenizer.lineno()+": parse error, expected "+value+" got "+tokenizer.sval);
|
||||
throw new ParseException("Line "+tokenizer.lineno()+": parse error, expected "+value+" got "+tokenizer.sval, tokenizer.lineno());
|
||||
}
|
||||
|
||||
private boolean nextToken() throws IOException {
|
||||
return tokenizer.nextToken() != StreamTokenizer.TT_EOF;
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
@ -15,26 +15,22 @@ import java.util.NavigableMap;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import com.minres.scviewer.database.HierNode;
|
||||
import com.minres.scviewer.database.ISignal;
|
||||
import com.minres.scviewer.database.IEvent;
|
||||
import com.minres.scviewer.database.IWaveform;
|
||||
import com.minres.scviewer.database.IWaveformDb;
|
||||
import com.minres.scviewer.database.IWaveformEvent;
|
||||
import com.minres.scviewer.database.WaveformType;
|
||||
|
||||
public class VCDSignal<T> extends HierNode implements ISignal<T> {
|
||||
public class VCDSignal<T extends IEvent> extends HierNode implements IWaveform {
|
||||
|
||||
private long id;
|
||||
|
||||
private String fullName;
|
||||
|
||||
private final String kind = "signal";
|
||||
|
||||
private final int width;
|
||||
|
||||
private final T dummy = null;
|
||||
|
||||
private IWaveformDb db;
|
||||
|
||||
private TreeMap<Long, T> values;
|
||||
private NavigableMap<Long, IEvent[]> values;
|
||||
|
||||
public VCDSignal(IWaveformDb db, String name) {
|
||||
this(db, 0, name, 1);
|
||||
@ -50,18 +46,16 @@ public class VCDSignal<T> extends HierNode implements ISignal<T> {
|
||||
fullName=name;
|
||||
this.id=id;
|
||||
this.width=width;
|
||||
this.values=new TreeMap<Long, T>();
|
||||
this.values=new TreeMap<>();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public VCDSignal(ISignal<T> other, int id, String name) {
|
||||
public VCDSignal(VCDSignal<T> o, int id, String name) {
|
||||
super(name);
|
||||
fullName=name;
|
||||
this.id=id;
|
||||
assert(other instanceof VCDSignal<?>);
|
||||
this.width=((VCDSignal<? extends IWaveformEvent>)other).width;
|
||||
this.values=((VCDSignal<T>)other).values;
|
||||
this.db=other.getDb();
|
||||
this.width=o.width;
|
||||
this.values=o.values;
|
||||
this.db=o.getDb();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -78,53 +72,55 @@ public class VCDSignal<T> extends HierNode implements ISignal<T> {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getKind() {
|
||||
return kind;
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWaveformDb getDb() {
|
||||
return db;
|
||||
}
|
||||
|
||||
public void addSignalChange(Long time, T value){
|
||||
values.put(time, value);
|
||||
if(values.containsKey(time)) {
|
||||
IEvent[] oldV = values.get(time);
|
||||
IEvent[] newV = new IEvent[oldV.length+1];
|
||||
System.arraycopy(oldV, 0, newV, 0, oldV.length);
|
||||
newV[oldV.length]=value;
|
||||
values.put(time, newV);
|
||||
} else {
|
||||
values.put(time, new IEvent[] {value});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NavigableMap<Long, T> getEvents() {
|
||||
public NavigableMap<Long, IEvent[]> getEvents() {
|
||||
return values;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T getWaveformValueAtTime(Long time) {
|
||||
public IEvent[] getEventsAtTime(Long time) {
|
||||
return values.get(time);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T getWaveformValueBeforeTime(Long time) {
|
||||
Entry<Long, T> e = values.floorEntry(time);
|
||||
public IEvent[] getEventsBeforeTime(Long time) {
|
||||
Entry<Long, IEvent[]> e = values.floorEntry(time);
|
||||
if(e==null)
|
||||
return null;
|
||||
return new IEvent[] {};
|
||||
else
|
||||
return values.floorEntry(time).getValue();
|
||||
return values.floorEntry(time).getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean equals(IWaveform other) {
|
||||
public boolean isSame(IWaveform other) {
|
||||
return( other instanceof VCDSignal<?> && this.getId().equals(other.getId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getType() {
|
||||
return dummy.getClass();
|
||||
public WaveformType getType() {
|
||||
return WaveformType.SIGNAL;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,11 +2,11 @@ Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: Waveform database
|
||||
Bundle-SymbolicName: com.minres.scviewer.database
|
||||
Bundle-Version: 1.0.0.qualifier
|
||||
Bundle-Version: 2.0.0.qualifier
|
||||
Bundle-Vendor: MINRES Technologies GmbH
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
|
||||
Export-Package: com.minres.scviewer.database,
|
||||
com.minres.scviewer.database.internal;x-internal:=true
|
||||
com.minres.scviewer.database.tx
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Service-Component: OSGI-INF/component.xml,OSGI-INF/component2.xml
|
||||
Automatic-Module-Name: com.minres.scviewer.database
|
||||
|
@ -8,5 +8,5 @@
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
</project>
|
||||
|
@ -10,12 +10,12 @@
|
||||
*******************************************************************************/
|
||||
package com.minres.scviewer.database;
|
||||
|
||||
public class BitVector {
|
||||
public class BitVector implements IEvent {
|
||||
|
||||
private final int width;
|
||||
|
||||
|
||||
private int[] packedValues;
|
||||
|
||||
|
||||
public BitVector(int netWidth) {
|
||||
this.width=netWidth;
|
||||
packedValues = new int[(netWidth+15)/16];
|
||||
@ -31,19 +31,19 @@ public class BitVector {
|
||||
}
|
||||
|
||||
public char[] getValue() {
|
||||
int bitOffset = 0;
|
||||
int wordOffset = 0;
|
||||
char[] res = new char[width];
|
||||
// Copy values out of packed array
|
||||
for (int i = 0; i < width; i++) {
|
||||
int currentWord = (packedValues[wordOffset] >> bitOffset)&3;
|
||||
res[width-i-1]=BitValue.fromInt(currentWord).toChar();
|
||||
bitOffset += 2;
|
||||
if (bitOffset == 32) {
|
||||
wordOffset++;
|
||||
bitOffset = 0;
|
||||
}
|
||||
}
|
||||
int bitOffset = 0;
|
||||
int wordOffset = 0;
|
||||
char[] res = new char[width];
|
||||
// Copy values out of packed array
|
||||
for (int i = 0; i < width; i++) {
|
||||
int currentWord = (packedValues[wordOffset] >> bitOffset)&3;
|
||||
res[width-i-1]=BitValue.fromInt(currentWord).toChar();
|
||||
bitOffset += 2;
|
||||
if (bitOffset == 32) {
|
||||
wordOffset++;
|
||||
bitOffset = 0;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -68,7 +68,7 @@ public class BitVector {
|
||||
public String toString(){
|
||||
return new String(getValue());
|
||||
}
|
||||
|
||||
|
||||
public String toHexString(){
|
||||
int resWidth=(width-1)/4+1;
|
||||
char[] value=getValue();
|
||||
@ -76,33 +76,34 @@ public class BitVector {
|
||||
for(int i=resWidth-1; i>=0; i--){
|
||||
int digit=0;
|
||||
for(int j=3; j>=0; j--){
|
||||
if((4*i+j)>=value.length) continue;
|
||||
BitValue val = BitValue.fromChar(value[4*i+j]);
|
||||
switch(val) {
|
||||
case X:
|
||||
case Z:
|
||||
res[i]=val.toChar();
|
||||
continue;
|
||||
case ONE:
|
||||
digit+=1<<(3-j);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
if((4*i+j)<value.length) {
|
||||
BitValue val = BitValue.fromChar(value[4*i+j]);
|
||||
switch(val) {
|
||||
case X:
|
||||
case Z:
|
||||
res[i]=val.toChar();
|
||||
continue;
|
||||
case ONE:
|
||||
digit+=1<<(3-j);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
res[i]=Character.forDigit(digit, 16); //((digit < 10) ? '0' + digit : 'a' + digit -10)
|
||||
}
|
||||
return new String(res);
|
||||
}
|
||||
|
||||
|
||||
public long toUnsignedValue() {
|
||||
long res = 0;
|
||||
int bitOffset = 0;
|
||||
int wordOffset = 0;
|
||||
int currentWord = 0;
|
||||
// Copy values out of packed array
|
||||
for (int i = 0; i < width; i++) {
|
||||
if(bitOffset==0) currentWord = packedValues[wordOffset];
|
||||
int bitOffset = 0;
|
||||
int wordOffset = 0;
|
||||
int currentWord = 0;
|
||||
// Copy values out of packed array
|
||||
for (int i = 0; i < width; i++) {
|
||||
if(bitOffset==0) currentWord = packedValues[wordOffset];
|
||||
switch (currentWord & 3) {
|
||||
case 1:
|
||||
res|=1<<i;
|
||||
@ -113,27 +114,27 @@ public class BitVector {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
bitOffset += 2;
|
||||
if (bitOffset == 32) {
|
||||
wordOffset++;
|
||||
bitOffset = 0;
|
||||
} else {
|
||||
currentWord >>= 2;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
bitOffset += 2;
|
||||
if (bitOffset == 32) {
|
||||
wordOffset++;
|
||||
bitOffset = 0;
|
||||
} else {
|
||||
currentWord >>= 2;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
public long toSignedValue() {
|
||||
long res = 0;
|
||||
int bitOffset = 0;
|
||||
int wordOffset = 0;
|
||||
int currentWord = 0;
|
||||
int lastVal=0;
|
||||
// Copy values out of packed array
|
||||
for (int i = 0; i < width; i++) {
|
||||
if(bitOffset==0) currentWord = packedValues[wordOffset];
|
||||
lastVal=0;
|
||||
int bitOffset = 0;
|
||||
int wordOffset = 0;
|
||||
int currentWord = 0;
|
||||
int lastVal=0;
|
||||
// Copy values out of packed array
|
||||
for (int i = 0; i < width; i++) {
|
||||
if(bitOffset==0) currentWord = packedValues[wordOffset];
|
||||
lastVal=0;
|
||||
switch (currentWord & 3) {
|
||||
case 1:
|
||||
res|=1<<i;
|
||||
@ -144,27 +145,32 @@ public class BitVector {
|
||||
return 0;
|
||||
default:
|
||||
}
|
||||
bitOffset += 2;
|
||||
if (bitOffset == 32) {
|
||||
wordOffset++;
|
||||
bitOffset = 0;
|
||||
} else {
|
||||
currentWord >>= 2;
|
||||
}
|
||||
}
|
||||
for(int i=width; i<64; i++) {
|
||||
if(bitOffset==0) currentWord = packedValues[wordOffset];
|
||||
res|=lastVal<<i;
|
||||
bitOffset += 2;
|
||||
if (bitOffset == 32) {
|
||||
wordOffset++;
|
||||
bitOffset = 0;
|
||||
} else {
|
||||
currentWord >>= 2;
|
||||
}
|
||||
|
||||
}
|
||||
bitOffset += 2;
|
||||
if (bitOffset == 32) {
|
||||
wordOffset++;
|
||||
bitOffset = 0;
|
||||
} else {
|
||||
currentWord >>= 2;
|
||||
}
|
||||
}
|
||||
if(lastVal!=0)
|
||||
res |= -1l<<width;
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventKind getKind() {
|
||||
return EventKind.SINGLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WaveformType getType() {
|
||||
return WaveformType.SIGNAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEvent duplicate() throws CloneNotSupportedException {
|
||||
return (IEvent)this.clone();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,4 +25,4 @@ public enum DataType {
|
||||
POINTER, // T*
|
||||
ARRAY, // T[N]
|
||||
STRING // string, std::string
|
||||
};
|
||||
}
|
||||
|
@ -0,0 +1,26 @@
|
||||
package com.minres.scviewer.database;
|
||||
|
||||
public class DoubleVal implements IEvent {
|
||||
|
||||
public final double value;
|
||||
|
||||
public DoubleVal(double value) {
|
||||
this.value=value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventKind getKind() {
|
||||
return EventKind.SINGLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WaveformType getType() {
|
||||
return WaveformType.SIGNAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEvent duplicate() throws CloneNotSupportedException {
|
||||
return (IEvent) clone();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
package com.minres.scviewer.database;
|
||||
|
||||
public enum EventKind {
|
||||
SINGLE, BEGIN, END
|
||||
}
|
@ -19,25 +19,26 @@ public class HierNode implements IHierNode {
|
||||
|
||||
protected String name;
|
||||
|
||||
protected String parentName;
|
||||
protected IHierNode parent = null;
|
||||
|
||||
protected ArrayList<IHierNode> childs;
|
||||
|
||||
protected PropertyChangeSupport pcs;
|
||||
|
||||
public HierNode() {
|
||||
childs = new ArrayList<IHierNode>();
|
||||
childs = new ArrayList<>();
|
||||
pcs=new PropertyChangeSupport(this);
|
||||
}
|
||||
|
||||
public HierNode(String name) {
|
||||
this(name, "");
|
||||
}
|
||||
|
||||
public HierNode(String name, String parentName) {
|
||||
this();
|
||||
this.name=name;
|
||||
this.parentName=parentName;
|
||||
}
|
||||
|
||||
public HierNode(String name, IHierNode parent) {
|
||||
this();
|
||||
this.name=name;
|
||||
this.parent=parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -53,8 +54,8 @@ public class HierNode implements IHierNode {
|
||||
|
||||
@Override
|
||||
public String getFullName() {
|
||||
if(parentName!=null && parentName.length()>0)
|
||||
return parentName+"."+name;
|
||||
if(parent!=null)
|
||||
return parent.getFullName()+"."+name;
|
||||
else
|
||||
return name;
|
||||
}
|
||||
@ -70,8 +71,8 @@ public class HierNode implements IHierNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setParentName(String name) {
|
||||
this.parentName=name;
|
||||
public void setParent(IHierNode parent) {
|
||||
this.parent=parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -81,7 +82,12 @@ public class HierNode implements IHierNode {
|
||||
|
||||
@Override
|
||||
public int compareTo(IHierNode o) {
|
||||
return name.compareTo(o.getName());
|
||||
return getFullName().compareTo(o.getFullName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDerivedWaveform deriveWaveform() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2015 MINRES Technologies GmbH and others.
|
||||
* Copyright (c) 2015, 2020 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
|
||||
@ -10,11 +10,10 @@
|
||||
*******************************************************************************/
|
||||
package com.minres.scviewer.database;
|
||||
|
||||
/**
|
||||
* The Interface IDerivedWaveform.
|
||||
*/
|
||||
public interface IDerivedWaveform extends IWaveform {
|
||||
|
||||
public interface IWaveformEvent extends Comparable<IWaveformEvent>{
|
||||
|
||||
public Long getTime();
|
||||
|
||||
public IWaveformEvent duplicate() throws CloneNotSupportedException;
|
||||
|
||||
void addSourceWaveform(IWaveform waveform);
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package com.minres.scviewer.database;
|
||||
|
||||
public interface IEvent {
|
||||
|
||||
public IEvent duplicate() throws CloneNotSupportedException;
|
||||
|
||||
public EventKind getKind();
|
||||
|
||||
public WaveformType getType();
|
||||
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2015 MINRES Technologies GmbH and others.
|
||||
* Copyright (c) 2015, 2020 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
|
||||
@ -13,6 +13,9 @@ package com.minres.scviewer.database;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The Interface IHierNode.
|
||||
*/
|
||||
public interface IHierNode extends Comparable<IHierNode>{
|
||||
|
||||
/**
|
||||
@ -33,14 +36,46 @@ public interface IHierNode extends Comparable<IHierNode>{
|
||||
*/
|
||||
public void removePropertyChangeListener(PropertyChangeListener l) ;
|
||||
|
||||
/**
|
||||
* Gets the full name.
|
||||
*
|
||||
* @return the full name
|
||||
*/
|
||||
public String getFullName();
|
||||
|
||||
/**
|
||||
* Gets the name.
|
||||
*
|
||||
* @return the name
|
||||
*/
|
||||
public String getName();
|
||||
|
||||
/**
|
||||
* Sets the name.
|
||||
*
|
||||
* @param name the new name
|
||||
*/
|
||||
public void setName(String name);
|
||||
|
||||
public void setParentName(String name);
|
||||
/**
|
||||
* Sets the parent.
|
||||
*
|
||||
* @param parent the new parent
|
||||
*/
|
||||
public void setParent(IHierNode parent);
|
||||
|
||||
/**
|
||||
* Gets the child nodes.
|
||||
*
|
||||
* @return the child nodes
|
||||
*/
|
||||
public List<IHierNode> getChildNodes();
|
||||
|
||||
/**
|
||||
* Derive waveform.
|
||||
*
|
||||
* @return the i derived waveform or null if none could be created
|
||||
*/
|
||||
public IDerivedWaveform deriveWaveform();
|
||||
|
||||
}
|
||||
|
@ -1,26 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2015 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* MINRES Technologies GmbH - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package com.minres.scviewer.database;
|
||||
|
||||
import java.util.NavigableMap;
|
||||
|
||||
|
||||
public interface ISignal<T> extends IWaveform{
|
||||
|
||||
public NavigableMap<Long, T> getEvents();
|
||||
|
||||
public T getWaveformValueAtTime(Long time);
|
||||
|
||||
public T getWaveformValueBeforeTime(Long time);
|
||||
|
||||
public Class<?> getType();
|
||||
}
|
||||
|
@ -1,27 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2015 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* MINRES Technologies GmbH - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package com.minres.scviewer.database;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.NavigableMap;
|
||||
|
||||
public interface ITxStream<T extends ITxEvent> extends IWaveform {
|
||||
|
||||
public List<ITxGenerator> getGenerators();
|
||||
|
||||
public int getMaxConcurrency();
|
||||
|
||||
public NavigableMap<Long, List<ITxEvent>> getEvents();
|
||||
|
||||
public Collection<T> getWaveformEventsAtTime(Long time);
|
||||
|
||||
}
|
@ -10,15 +10,24 @@
|
||||
*******************************************************************************/
|
||||
package com.minres.scviewer.database;
|
||||
|
||||
import java.util.NavigableMap;
|
||||
|
||||
public interface IWaveform extends IHierNode {
|
||||
|
||||
public Long getId();
|
||||
|
||||
public String getKind();
|
||||
|
||||
public IWaveformDb getDb();
|
||||
|
||||
public Boolean equals(IWaveform other);
|
||||
public boolean isSame(IWaveform other);
|
||||
|
||||
public NavigableMap<Long, IEvent[]> getEvents();
|
||||
|
||||
public IEvent[] getEventsAtTime(Long time);
|
||||
|
||||
public IEvent[] getEventsBeforeTime(Long time);
|
||||
|
||||
public WaveformType getType();
|
||||
|
||||
public int getWidth();
|
||||
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ import java.util.Collection;
|
||||
|
||||
public interface IWaveformDbLoader {
|
||||
|
||||
public boolean load(IWaveformDb db, File inp) throws Exception;
|
||||
public boolean load(IWaveformDb db, File inp) throws InputFormatException;
|
||||
|
||||
public Long getMaxTime();
|
||||
|
||||
|
@ -50,4 +50,9 @@ public class RelationType {
|
||||
public int hashCode() {
|
||||
return name.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return name.equals(obj);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,5 @@
|
||||
package com.minres.scviewer.database;
|
||||
|
||||
public enum WaveformType {
|
||||
SIGNAL, TRANSACTION, FILTER
|
||||
}
|
@ -12,10 +12,8 @@ package com.minres.scviewer.database.internal;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -25,17 +23,14 @@ import com.minres.scviewer.database.IHierNode;
|
||||
import com.minres.scviewer.database.IWaveform;
|
||||
import com.minres.scviewer.database.IWaveformDb;
|
||||
import com.minres.scviewer.database.IWaveformDbLoader;
|
||||
import com.minres.scviewer.database.InputFormatException;
|
||||
import com.minres.scviewer.database.RelationType;
|
||||
|
||||
public class WaveformDb extends HierNode implements IWaveformDb {
|
||||
|
||||
private static List<IWaveformDbLoader> loaders=new LinkedList<IWaveformDbLoader>();
|
||||
private static List<IWaveformDbLoader> loaders=new LinkedList<>();
|
||||
|
||||
private boolean loaded;
|
||||
|
||||
private List<IHierNode> childNodes;
|
||||
|
||||
private List<RelationType> relationTypes;
|
||||
|
||||
private Map<String, IWaveform> waveforms;
|
||||
@ -58,7 +53,7 @@ public class WaveformDb extends HierNode implements IWaveformDb {
|
||||
|
||||
public WaveformDb() {
|
||||
super();
|
||||
waveforms = new HashMap<String, IWaveform>();
|
||||
waveforms = new HashMap<>();
|
||||
relationTypes=new ArrayList<>();
|
||||
maxTime=0L;
|
||||
}
|
||||
@ -75,7 +70,7 @@ public class WaveformDb extends HierNode implements IWaveformDb {
|
||||
|
||||
@Override
|
||||
public List<IWaveform> getAllWaves() {
|
||||
return new ArrayList<IWaveform>(waveforms.values());
|
||||
return new ArrayList<>(waveforms.values());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -93,7 +88,7 @@ public class WaveformDb extends HierNode implements IWaveformDb {
|
||||
buildHierarchyNodes() ;
|
||||
relationTypes.addAll(loader.getAllRelationTypes());
|
||||
pcs.firePropertyChange("WAVEFORMS", null, waveforms);
|
||||
pcs.firePropertyChange("CHILDS", null, childNodes);
|
||||
pcs.firePropertyChange("CHILDS", null, childs);
|
||||
loaded = true;
|
||||
return true;
|
||||
}
|
||||
@ -116,7 +111,7 @@ public class WaveformDb extends HierNode implements IWaveformDb {
|
||||
@Override
|
||||
public void clear() {
|
||||
waveforms.clear();
|
||||
childNodes.clear();
|
||||
childs.clear();
|
||||
loaded=false;
|
||||
}
|
||||
|
||||
@ -124,62 +119,41 @@ public class WaveformDb extends HierNode implements IWaveformDb {
|
||||
return loaded;
|
||||
}
|
||||
|
||||
private void buildHierarchyNodes() throws InputFormatException{
|
||||
childNodes= new ArrayList<IHierNode>();
|
||||
private void buildHierarchyNodes() {
|
||||
for(IWaveform stream:getAllWaves()){
|
||||
//updateMaxTime(stream);
|
||||
String[] hier = stream.getName().split("\\.");
|
||||
IHierNode node = this;
|
||||
List<String> path=new LinkedList<String>();
|
||||
path.add(name);
|
||||
for(String name:hier){
|
||||
IHierNode n1 = null;
|
||||
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)) {
|
||||
n1=n;
|
||||
childNode=n;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(name.equals(hier[hier.length-1])){ //leaf
|
||||
if(n1!=null) {
|
||||
if(n1 instanceof HierNode){
|
||||
node.getChildNodes().remove(n1);
|
||||
stream.getChildNodes().addAll(n1.getChildNodes());
|
||||
Collections.sort(stream.getChildNodes());
|
||||
} else {
|
||||
throw new InputFormatException();
|
||||
}
|
||||
}
|
||||
stream.setName(name);
|
||||
stream.setParentName(join(path, "."));
|
||||
node.getChildNodes().add(stream);
|
||||
Collections.sort(node.getChildNodes());
|
||||
node=stream;
|
||||
} else { // intermediate
|
||||
if(n1 != null) {
|
||||
node=n1;
|
||||
} else {
|
||||
HierNode newNode = new HierNode(name, join(path, "."));
|
||||
node.getChildNodes().add(newNode);
|
||||
Collections.sort(node.getChildNodes());
|
||||
node=newNode;
|
||||
}
|
||||
if(childNode != null) {
|
||||
node = childNode;
|
||||
break;
|
||||
}
|
||||
path.add(name);
|
||||
HierNode newNode = new HierNode(name, node);
|
||||
node.getChildNodes().add(newNode);
|
||||
node=newNode;
|
||||
|
||||
}
|
||||
node.getChildNodes().add(stream);
|
||||
stream.setParent(node);
|
||||
stream.setName(hier[hier.length-1]);
|
||||
}
|
||||
sortRecursive(this);
|
||||
}
|
||||
|
||||
private static String join(Collection<?> col, String delim) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
Iterator<?> iter = col.iterator();
|
||||
if (iter.hasNext())
|
||||
sb.append(iter.next().toString());
|
||||
while (iter.hasNext()) {
|
||||
sb.append(delim);
|
||||
sb.append(iter.next().toString());
|
||||
}
|
||||
return sb.toString();
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -8,16 +8,18 @@
|
||||
* Contributors:
|
||||
* MINRES Technologies GmbH - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package com.minres.scviewer.database;
|
||||
package com.minres.scviewer.database.tx;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import com.minres.scviewer.database.IWaveform;
|
||||
|
||||
public interface ITx extends Comparable<ITx>{
|
||||
|
||||
public Long getId();
|
||||
|
||||
public ITxStream<ITxEvent> getStream();
|
||||
public IWaveform getStream();
|
||||
|
||||
public ITxGenerator getGenerator();
|
||||
|
@ -8,7 +8,7 @@
|
||||
* Contributors:
|
||||
* MINRES Technologies GmbH - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package com.minres.scviewer.database;
|
||||
package com.minres.scviewer.database.tx;
|
||||
|
||||
public interface ITxAttribute extends ITxAttributeType {
|
||||
public Object getValue();
|
@ -8,7 +8,10 @@
|
||||
* Contributors:
|
||||
* MINRES Technologies GmbH - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package com.minres.scviewer.database;
|
||||
package com.minres.scviewer.database.tx;
|
||||
|
||||
import com.minres.scviewer.database.AssociationType;
|
||||
import com.minres.scviewer.database.DataType;
|
||||
|
||||
public interface ITxAttributeType {
|
||||
public String getName();
|
@ -8,12 +8,13 @@
|
||||
* Contributors:
|
||||
* MINRES Technologies GmbH - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package com.minres.scviewer.database;
|
||||
package com.minres.scviewer.database.tx;
|
||||
|
||||
public interface ITxEvent extends IWaveformEvent {
|
||||
enum Type {BEGIN, END};
|
||||
import com.minres.scviewer.database.IEvent;
|
||||
|
||||
public interface ITxEvent extends IEvent {
|
||||
|
||||
public Long getTime();
|
||||
|
||||
public ITx getTransaction();
|
||||
|
||||
public Type getType();
|
||||
public ITx getTransaction();
|
||||
}
|
@ -8,13 +8,15 @@
|
||||
* Contributors:
|
||||
* MINRES Technologies GmbH - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package com.minres.scviewer.database;
|
||||
package com.minres.scviewer.database.tx;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.minres.scviewer.database.IWaveform;
|
||||
|
||||
public interface ITxGenerator {
|
||||
public Long getId();
|
||||
public ITxStream<ITxEvent> getStream();
|
||||
public IWaveform getStream();
|
||||
public String getName();
|
||||
public List<ITx> getTransactions();
|
||||
}
|
@ -8,7 +8,9 @@
|
||||
* Contributors:
|
||||
* MINRES Technologies GmbH - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package com.minres.scviewer.database;
|
||||
package com.minres.scviewer.database.tx;
|
||||
|
||||
import com.minres.scviewer.database.RelationType;
|
||||
|
||||
public interface ITxRelation {
|
||||
|
@ -2,7 +2,7 @@ Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: %Bundle-Name
|
||||
Bundle-SymbolicName: com.minres.scviewer.e4.application;singleton:=true
|
||||
Bundle-Version: 2.10.0.qualifier
|
||||
Bundle-Version: 2.11.0.qualifier
|
||||
Bundle-Vendor: %Bundle-Vendor
|
||||
Require-Bundle: javax.inject;bundle-version="1.0.0",
|
||||
org.eclipse.core.runtime;bundle-version="3.11.1",
|
||||
|
@ -70,7 +70,7 @@
|
||||
</count>
|
||||
<iterate
|
||||
operator="or">
|
||||
<instanceof value="com.minres.scviewer.database.ITx"/>
|
||||
<instanceof value="com.minres.scviewer.database.tx.ITx"/>
|
||||
</iterate>
|
||||
</and>
|
||||
</with>
|
||||
|
@ -1,7 +1,7 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>com.minres.scviewer.e4.application</artifactId>
|
||||
<version>2.10.0-SNAPSHOT</version>
|
||||
<version>2.11.0-SNAPSHOT</version>
|
||||
<parent>
|
||||
<groupId>com.minres.scviewer</groupId>
|
||||
<artifactId>com.minres.scviewer.parent</artifactId>
|
||||
|
@ -13,6 +13,7 @@ package com.minres.scviewer.e4.application;
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.e4.core.contexts.IEclipseContext;
|
||||
@ -30,8 +31,10 @@ import org.eclipse.e4.ui.workbench.modeling.EPartService;
|
||||
import org.eclipse.e4.ui.workbench.modeling.EPartService.PartState;
|
||||
import org.eclipse.equinox.app.IApplicationContext;
|
||||
import org.eclipse.osgi.service.datalocation.Location;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.osgi.service.event.Event;
|
||||
import org.osgi.service.event.EventHandler;
|
||||
import org.eclipse.e4.core.services.log.Logger;
|
||||
|
||||
import com.minres.scviewer.e4.application.options.Options;
|
||||
import com.minres.scviewer.e4.application.options.Options.Multiplicity;
|
||||
@ -45,6 +48,8 @@ import com.minres.scviewer.e4.application.options.Options.Separator;
|
||||
**/
|
||||
public class E4LifeCycle {
|
||||
|
||||
@Inject private Logger logger;
|
||||
|
||||
/**
|
||||
* Post construct.
|
||||
*
|
||||
@ -70,20 +75,10 @@ public class E4LifeCycle {
|
||||
.addOption("clearPersistedState", Multiplicity.ZERO_OR_ONE)
|
||||
.addOption("c", Separator.BLANK, Multiplicity.ZERO_OR_ONE);
|
||||
if (!opt.check(Options.DEFAULT_SET, true, false)) {
|
||||
System.err.println(opt.getCheckErrors());
|
||||
logger.error(opt.getCheckErrors());
|
||||
System.exit(1);
|
||||
}
|
||||
final String confFile =opt.getSet().isSet("c")?opt.getSet().getOption("c").getResultValue(0):"";
|
||||
|
||||
// react on the first view being created, at that time the UI is available
|
||||
// eventBroker.subscribe(UIEvents.UILifeCycle.ACTIVATE, new EventHandler() {
|
||||
// @Override
|
||||
// public void handleEvent(Event event) {
|
||||
// MPart part = (MPart) event.getProperty("ChangedElement"); //$NON-NLS-1$
|
||||
// if(part!=null){
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
eventBroker.subscribe(UIEvents.UILifeCycle.APP_STARTUP_COMPLETE, new EventHandler() {
|
||||
@Override
|
||||
public void handleEvent(Event event) {
|
||||
@ -93,19 +88,22 @@ public class E4LifeCycle {
|
||||
if(isLocked)
|
||||
instanceLocation.release();
|
||||
} catch (IOException e) { }
|
||||
if(opt.getSet().getData().size()>0) {
|
||||
MApplication app= workbenchContext.get(MApplication.class);
|
||||
EModelService modelService = workbenchContext.get(EModelService.class);
|
||||
EPartService partService= workbenchContext.get(EPartService.class);
|
||||
MPart part = partService .createPart("com.minres.scviewer.e4.application.partdescriptor.waveformviewer"); //$NON-NLS-1$
|
||||
part.setLabel(opt.getSet().getData().get(0));
|
||||
MPartStack partStack = (MPartStack)modelService.find("org.eclipse.editorss", app); //$NON-NLS-1$
|
||||
partStack.getChildren().add(part);
|
||||
partService.showPart(part, PartState.CREATE);
|
||||
partService.showPart(part, PartState.ACTIVATE);
|
||||
IEclipseContext ctx = part.getContext();
|
||||
ctx.modify("input", opt.getSet().getData());
|
||||
ctx.modify("config", confFile); //$NON-NLS-1$
|
||||
if(!opt.getSet().getData().isEmpty()) {
|
||||
Display.getCurrent().timerExec (100, () -> {
|
||||
MApplication app= workbenchContext.get(MApplication.class);
|
||||
EModelService modelService = workbenchContext.get(EModelService.class);
|
||||
EPartService partService= workbenchContext.get(EPartService.class);
|
||||
MPart part = partService .createPart("com.minres.scviewer.e4.application.partdescriptor.waveformviewer"); //$NON-NLS-1$
|
||||
part.setLabel(opt.getSet().getData().get(0));
|
||||
MPartStack partStack = (MPartStack)modelService.find("org.eclipse.editorss", app); //$NON-NLS-1$
|
||||
partStack.getChildren().add(part);
|
||||
partService.showPart(part, PartState.CREATE);
|
||||
partService.showPart(part, PartState.ACTIVATE);
|
||||
IEclipseContext ctx = part.getContext();
|
||||
ctx.modify("input", opt.getSet().getData());
|
||||
String confFile =opt.getSet().isSet("c")?opt.getSet().getOption("c").getResultValue(0):"";
|
||||
ctx.modify("config", confFile); //$NON-NLS-1$
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -118,6 +116,7 @@ public class E4LifeCycle {
|
||||
*/
|
||||
@PreSave
|
||||
void preSave(IEclipseContext workbenchContext) {
|
||||
/* nothing to be done here */
|
||||
}
|
||||
|
||||
/**
|
||||
@ -127,6 +126,7 @@ public class E4LifeCycle {
|
||||
*/
|
||||
@ProcessAdditions
|
||||
void processAdditions(IEclipseContext workbenchContext) {
|
||||
/* nothing to be done here */
|
||||
}
|
||||
|
||||
/**
|
||||
@ -136,5 +136,6 @@ public class E4LifeCycle {
|
||||
*/
|
||||
@ProcessRemovals
|
||||
void processRemovals(IEclipseContext workbenchContext) {
|
||||
/* nothing to be done here */
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ public class Messages extends NLS {
|
||||
public static String ResourceManager_0;
|
||||
public static String SCViewerPreferencesPage_0;
|
||||
public static String SCViewerPreferencesPage_1;
|
||||
public static String SCViewerPreferencesPage_2;
|
||||
public static String StatusBarControl_1;
|
||||
public static String StatusBarControl_2;
|
||||
public static String StatusBarControl_3;
|
||||
|
@ -29,8 +29,8 @@ import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.widgets.Combo;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
|
||||
import com.minres.scviewer.database.ITx;
|
||||
import com.minres.scviewer.database.RelationType;
|
||||
import com.minres.scviewer.database.tx.ITx;
|
||||
import com.minres.scviewer.e4.application.Messages;
|
||||
import com.minres.scviewer.e4.application.parts.PartListener;
|
||||
import com.minres.scviewer.e4.application.parts.WaveformViewer;
|
||||
|
@ -22,7 +22,8 @@ import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
|
||||
import com.minres.scviewer.database.BitVector;
|
||||
import com.minres.scviewer.database.ISignal;
|
||||
import com.minres.scviewer.database.DoubleVal;
|
||||
import com.minres.scviewer.database.WaveformType;
|
||||
import com.minres.scviewer.database.ui.TrackEntry;
|
||||
import com.minres.scviewer.e4.application.parts.WaveformViewer;
|
||||
|
||||
@ -31,16 +32,16 @@ public class WaveformPopupMenuContribution {
|
||||
|
||||
@Inject MPart activePart;
|
||||
|
||||
final TrackEntry nullEntry = new TrackEntry(null);
|
||||
final TrackEntry nullEntry = new TrackEntry(null, null);
|
||||
|
||||
private boolean selHasBitVector(ISelection sel, boolean checkForDouble) {
|
||||
if(!sel.isEmpty() && sel instanceof IStructuredSelection) {
|
||||
for(Object elem:(IStructuredSelection)sel) {
|
||||
if(elem instanceof TrackEntry) {
|
||||
TrackEntry e = (TrackEntry) elem;
|
||||
if(e.waveform instanceof ISignal<?>) {
|
||||
Object o = ((ISignal<?>) e.waveform).getEvents().firstEntry().getValue();
|
||||
if(checkForDouble && o instanceof Double)
|
||||
if(e.waveform.getType() == WaveformType.SIGNAL) {
|
||||
Object o = e.waveform.getEvents().firstEntry().getValue()[0];
|
||||
if(checkForDouble && o instanceof DoubleVal)
|
||||
return true;
|
||||
else if(o instanceof BitVector && ((BitVector)o).getWidth()>1)
|
||||
return true;
|
||||
|
@ -20,8 +20,8 @@ import org.eclipse.e4.ui.workbench.modeling.EPartService;
|
||||
import org.eclipse.e4.ui.workbench.modeling.ESelectionService;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
|
||||
import com.minres.scviewer.database.ITx;
|
||||
import com.minres.scviewer.database.IWaveform;
|
||||
import com.minres.scviewer.database.tx.ITx;
|
||||
import com.minres.scviewer.database.ui.TrackEntry;
|
||||
import com.minres.scviewer.e4.application.parts.WaveformViewer;
|
||||
|
||||
|
@ -20,8 +20,8 @@ import org.eclipse.e4.ui.workbench.modeling.EPartService;
|
||||
import org.eclipse.e4.ui.workbench.modeling.ESelectionService;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
|
||||
import com.minres.scviewer.database.ITx;
|
||||
import com.minres.scviewer.database.IWaveform;
|
||||
import com.minres.scviewer.database.tx.ITx;
|
||||
import com.minres.scviewer.database.ui.GotoDirection;
|
||||
import com.minres.scviewer.database.ui.TrackEntry;
|
||||
import com.minres.scviewer.e4.application.parts.WaveformViewer;
|
||||
|
@ -20,7 +20,7 @@ import org.eclipse.e4.ui.workbench.modeling.EPartService;
|
||||
import org.eclipse.e4.ui.workbench.modeling.ESelectionService;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
|
||||
import com.minres.scviewer.database.ITx;
|
||||
import com.minres.scviewer.database.tx.ITx;
|
||||
import com.minres.scviewer.database.ui.GotoDirection;
|
||||
import com.minres.scviewer.e4.application.parts.WaveformViewer;
|
||||
|
||||
|
@ -17,6 +17,7 @@ import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.jface.viewers.StructuredSelection;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
import com.minres.scviewer.database.WaveformType;
|
||||
import com.minres.scviewer.database.ui.TrackEntry;
|
||||
import com.minres.scviewer.e4.application.parts.WaveformViewer;
|
||||
public class SearchHandler {
|
||||
@ -31,7 +32,7 @@ public class SearchHandler {
|
||||
Object[] elem = ((StructuredSelection)sel).toArray();
|
||||
if(elem.length ==0) return false;
|
||||
TrackEntry e = findTrackEntry(elem);
|
||||
return e!=null && e.isStream();
|
||||
return e!=null && e.waveform.getType()==WaveformType.TRANSACTION;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -22,7 +22,7 @@ import org.eclipse.e4.ui.workbench.modeling.EPartService;
|
||||
*/
|
||||
@SuppressWarnings("restriction")
|
||||
public class ThemeSetHandler {
|
||||
final static String PARAMTER_ID = "com.minres.scviewer.e4.application.command.theme.parameter.id"; //$NON-NLS-1$
|
||||
static final String PARAMTER_ID = "com.minres.scviewer.e4.application.command.theme.parameter.id"; //$NON-NLS-1$
|
||||
|
||||
@CanExecute
|
||||
public boolean canExecute(EPartService partService) {
|
||||
|
@ -17,6 +17,7 @@ RelationTypeToolControl_1=Select
|
||||
ResourceManager_0=Wrong decorate corner
|
||||
SCViewerPreferencesPage_0=Check for changed database
|
||||
SCViewerPreferencesPage_1=Show hover window in waveform
|
||||
SCViewerPreferencesPage_2=Waveform track height
|
||||
StatusBarControl_1=Currently running:
|
||||
StatusBarControl_2=\nLast task:
|
||||
StatusBarControl_3=Currently running:
|
||||
|
@ -77,9 +77,9 @@ import org.eclipse.wb.swt.SWTResourceManager;
|
||||
|
||||
import com.minres.scviewer.database.HierNode;
|
||||
import com.minres.scviewer.database.IHierNode;
|
||||
import com.minres.scviewer.database.ITx;
|
||||
import com.minres.scviewer.database.IWaveform;
|
||||
import com.minres.scviewer.database.IWaveformDb;
|
||||
import com.minres.scviewer.database.tx.ITx;
|
||||
import com.minres.scviewer.e4.application.Messages;
|
||||
import com.minres.scviewer.e4.application.handlers.AddWaveformHandler;
|
||||
import com.minres.scviewer.e4.application.provider.TxDbContentProvider;
|
||||
|
@ -5,6 +5,7 @@ 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;
|
||||
@ -38,7 +39,7 @@ public class LoadingWaveformDb implements IWaveformDb {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setParentName(String name) {
|
||||
public void setParent(IHierNode name) {
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -85,4 +86,9 @@ public class LoadingWaveformDb implements IWaveformDb {
|
||||
public void clear() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDerivedWaveform deriveWaveform() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,181 +0,0 @@
|
||||
package com.minres.scviewer.e4.application.parts;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.eclipse.jface.dialogs.IDialogConstants;
|
||||
import org.eclipse.jface.dialogs.TitleAreaDialog;
|
||||
import org.eclipse.jface.viewers.ArrayContentProvider;
|
||||
import org.eclipse.jface.viewers.ComboViewer;
|
||||
import org.eclipse.jface.viewers.ISelectionChangedListener;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.jface.viewers.LabelProvider;
|
||||
import org.eclipse.jface.viewers.SelectionChangedEvent;
|
||||
import org.eclipse.jface.viewers.StructuredSelection;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
import org.eclipse.wb.swt.ResourceManager;
|
||||
|
||||
import com.minres.scviewer.database.DataType;
|
||||
import com.minres.scviewer.database.ITxEvent;
|
||||
import com.minres.scviewer.database.ITxStream;
|
||||
|
||||
public class SearchTxDialog extends TitleAreaDialog {
|
||||
private ComboViewer propNameComboViewer = null;
|
||||
|
||||
private Text propValueText = null;
|
||||
|
||||
private String propName="";
|
||||
private DataType propType=null;
|
||||
private String propValue="";
|
||||
|
||||
private ITxStream<? extends ITxEvent> stream;
|
||||
|
||||
private ConcurrentHashMap<String, DataType> propNames=new ConcurrentHashMap<String, DataType>();
|
||||
|
||||
/**
|
||||
* Create the dialog.
|
||||
* @param parentShell
|
||||
* @param iTxStream
|
||||
*/
|
||||
public SearchTxDialog(Shell parentShell, ITxStream<? extends ITxEvent> iTxStream) {
|
||||
super(parentShell);
|
||||
setShellStyle(SWT.BORDER | SWT.RESIZE | SWT.TITLE | SWT.APPLICATION_MODAL);
|
||||
stream=iTxStream;
|
||||
new Thread() {
|
||||
public void run() {
|
||||
stream.getEvents().values().parallelStream().forEach(evtLst -> {
|
||||
evtLst.forEach(evt -> {
|
||||
evt.getTransaction().getAttributes().stream().forEach(attr -> {
|
||||
propNames.put(attr.getName(), attr.getDataType());
|
||||
});
|
||||
});
|
||||
});
|
||||
parentShell.getDisplay().asyncExec(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (propNameComboViewer!=null) {
|
||||
propNameComboViewer.setInput(getEntries());
|
||||
propNameComboViewer.setSelection(new StructuredSelection(propNameComboViewer.getElementAt(0)));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}.run();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create contents of the dialog.
|
||||
* @param parent
|
||||
*/
|
||||
@Override
|
||||
protected Control createDialogArea(Composite parent) {
|
||||
setMessage("Specify property name and value to search for");
|
||||
setTitleImage(ResourceManager.getPluginImage("com.minres.scviewer.e4.application", "icons/Minres_logo.png"));
|
||||
setTitle("Search Tx in stream");
|
||||
final Composite area = (Composite) super.createDialogArea(parent);
|
||||
final GridLayout gridLayout = (GridLayout) area.getLayout();
|
||||
gridLayout.marginTop = 10;
|
||||
gridLayout.marginBottom = 10;
|
||||
final Composite container = new Composite(area, SWT.NONE);
|
||||
final GridLayout gl_container = new GridLayout(2, false);
|
||||
gl_container.horizontalSpacing = 2;
|
||||
container.setLayout(gl_container);
|
||||
container.setLayoutData(new GridData(GridData.FILL_BOTH));
|
||||
|
||||
final Label header = new Label(container, SWT.CENTER | SWT.WRAP);
|
||||
GridData gd_header = new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1);
|
||||
gd_header.verticalIndent = 10;
|
||||
header.setLayoutData(gd_header);
|
||||
header.setText("Stream: "+stream.getName());
|
||||
|
||||
final Label propNameLabel = new Label(container, SWT.NONE);
|
||||
propNameLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
|
||||
propNameLabel.setText("Property Name:");
|
||||
|
||||
propNameComboViewer = new ComboViewer(container, SWT.NONE);
|
||||
propNameComboViewer.getCombo().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
|
||||
propNameComboViewer.setContentProvider(ArrayContentProvider.getInstance());
|
||||
propNameComboViewer.setLabelProvider(new LabelProvider() {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public String getText(Object element) {
|
||||
Map.Entry<String, DataType> e = (Map.Entry<String, DataType>)element;
|
||||
return e.getKey()+" ("+e.getValue().name()+")";
|
||||
}
|
||||
|
||||
});
|
||||
propNameComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void selectionChanged(SelectionChangedEvent event) {
|
||||
IStructuredSelection sel = event.getStructuredSelection();
|
||||
Map.Entry<String, DataType> e = (Map.Entry<String, DataType>)sel.getFirstElement();
|
||||
propName=e.getKey();
|
||||
propType=e.getValue();
|
||||
}
|
||||
});
|
||||
propNameComboViewer.setInput(getEntries());
|
||||
propNameComboViewer.setSelection(new StructuredSelection(propNameComboViewer.getElementAt(0)));
|
||||
|
||||
final Label propValueLabel = new Label(container, SWT.NONE);
|
||||
propValueLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
|
||||
propValueLabel.setText("Property Value:");
|
||||
|
||||
propValueText = new Text(container, SWT.BORDER);
|
||||
propValueText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
|
||||
|
||||
return area;
|
||||
}
|
||||
|
||||
private List<Entry<String,DataType>> getEntries() {
|
||||
return propNames.entrySet().stream().sorted((e1,e2)->e1.getKey().compareTo(e2.getKey())).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create contents of the button bar.
|
||||
* @param parent
|
||||
*/
|
||||
@Override
|
||||
protected void createButtonsForButtonBar(Composite parent) {
|
||||
final Button okButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
|
||||
okButton.setImage(ResourceManager.getPluginImage("com.minres.scviewer.e4.application", "icons/tick.png"));
|
||||
final Button cancelButton = createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
|
||||
cancelButton.setImage(ResourceManager.getPluginImage("com.minres.scviewer.e4.application", "icons/cross.png"));
|
||||
}
|
||||
|
||||
protected void constrainShellSize() {
|
||||
super.constrainShellSize();
|
||||
getShell().setMinimumSize(getShell().computeSize(-1, -1));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void okPressed() {
|
||||
propValue=propValueText.getText();
|
||||
super.okPressed();
|
||||
}
|
||||
|
||||
public String getPropName() {
|
||||
return propName;
|
||||
}
|
||||
|
||||
public DataType getPropType() {
|
||||
return propType;
|
||||
}
|
||||
|
||||
public String getPropValue() {
|
||||
return propValue;
|
||||
}
|
||||
}
|
@ -57,7 +57,7 @@ import org.eclipse.swt.widgets.Text;
|
||||
import org.eclipse.swt.widgets.Tree;
|
||||
import org.eclipse.swt.widgets.TreeItem;
|
||||
|
||||
import com.minres.scviewer.database.ITx;
|
||||
import com.minres.scviewer.database.tx.ITx;
|
||||
import com.minres.scviewer.e4.application.Messages;
|
||||
import com.minres.scviewer.e4.application.parts.txTableTree.AttributeLabelProvider;
|
||||
import com.minres.scviewer.e4.application.parts.txTableTree.AbstractTransactionTreeContentProvider;
|
||||
|
@ -1,6 +1,8 @@
|
||||
package com.minres.scviewer.e4.application.parts;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
@ -10,8 +12,6 @@ import org.eclipse.core.databinding.observable.list.WritableList;
|
||||
import org.eclipse.jface.databinding.viewers.ObservableListContentProvider;
|
||||
import org.eclipse.jface.viewers.ComboViewer;
|
||||
import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider;
|
||||
import org.eclipse.jface.viewers.DoubleClickEvent;
|
||||
import org.eclipse.jface.viewers.IDoubleClickListener;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.jface.viewers.ISelectionChangedListener;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
@ -36,11 +36,13 @@ import org.eclipse.swt.widgets.TableColumn;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
|
||||
import com.minres.scviewer.database.DataType;
|
||||
import com.minres.scviewer.database.ITx;
|
||||
import com.minres.scviewer.database.ITxAttribute;
|
||||
import com.minres.scviewer.database.ITxEvent;
|
||||
import com.minres.scviewer.database.ITxEvent.Type;
|
||||
import com.minres.scviewer.database.ITxStream;
|
||||
import com.minres.scviewer.database.EventKind;
|
||||
import com.minres.scviewer.database.IEvent;
|
||||
import com.minres.scviewer.database.IWaveform;
|
||||
import com.minres.scviewer.database.WaveformType;
|
||||
import com.minres.scviewer.database.tx.ITx;
|
||||
import com.minres.scviewer.database.tx.ITxAttribute;
|
||||
import com.minres.scviewer.database.tx.ITxEvent;
|
||||
import com.minres.scviewer.database.ui.TrackEntry;
|
||||
import com.minres.scviewer.e4.application.parts.txTableTree.AbstractTransactionTreeContentProvider;
|
||||
import com.minres.scviewer.e4.application.parts.txTableTree.AttributeLabelProvider;
|
||||
@ -84,7 +86,7 @@ public class TransactionList extends Composite {
|
||||
|
||||
private AttributeLabelProvider valueLabelProvider = null;
|
||||
|
||||
private ITxStream<? extends ITxEvent> stream;
|
||||
private IWaveform stream;
|
||||
|
||||
private ObservableList<AttributeNameBean> attrNames = new WritableList<AttributeNameBean>();
|
||||
|
||||
@ -121,11 +123,14 @@ public class TransactionList extends Composite {
|
||||
searchPropComboViewer.setContentProvider(new ObservableListContentProvider<AttributeNameBean>());
|
||||
searchPropComboViewer.setInput(attrNames);
|
||||
Combo searchPropCombo = searchPropComboViewer.getCombo();
|
||||
searchPropCombo.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, false, 1, 1));
|
||||
GridData gd_searchProp = new GridData(SWT.LEFT, SWT.FILL, false, false, 1, 1);
|
||||
gd_searchProp.widthHint=100;
|
||||
searchPropCombo.setLayoutData(gd_searchProp);
|
||||
searchPropCombo.addSelectionListener(new SelectionListener() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
int idx = searchPropCombo.getSelectionIndex();
|
||||
if(idx<0) return;
|
||||
AttributeNameBean sel = attrNames.get(idx);
|
||||
txFilter.setSearchProp(sel.getName(), sel.getType());
|
||||
tableViewer.refresh();
|
||||
@ -133,6 +138,7 @@ public class TransactionList extends Composite {
|
||||
@Override
|
||||
public void widgetDefaultSelected(SelectionEvent e) {
|
||||
int idx = searchPropCombo.getSelectionIndex();
|
||||
if(idx<0) return;
|
||||
AttributeNameBean sel = attrNames.get(idx);
|
||||
txFilter.setSearchProp(sel.getName(), sel.getType());
|
||||
tableViewer.refresh();
|
||||
@ -166,11 +172,14 @@ public class TransactionList extends Composite {
|
||||
viewPropComboViewer.setContentProvider(new ObservableListContentProvider<AttributeNameBean>());
|
||||
viewPropComboViewer.setInput(attrNames);
|
||||
Combo viewPropCombo = viewPropComboViewer.getCombo();
|
||||
viewPropCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
|
||||
GridData gd_viewProp = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
|
||||
gd_viewProp.widthHint=100;
|
||||
viewPropCombo.setLayoutData(gd_viewProp);
|
||||
viewPropCombo.addSelectionListener(new SelectionListener() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
int idx = viewPropCombo.getSelectionIndex();
|
||||
if(idx<0) return;
|
||||
valueLabelProvider.setShowProp(attrNames.get(idx).getName());
|
||||
tableViewer.refresh(true);
|
||||
}
|
||||
@ -238,11 +247,11 @@ public class TransactionList extends Composite {
|
||||
}
|
||||
|
||||
public void setInput(TrackEntry trackEntry) {
|
||||
if(trackEntry==null || !trackEntry.isStream()) {
|
||||
if(trackEntry==null || trackEntry.waveform.getType()!=WaveformType.TRANSACTION) {
|
||||
attrNames.clear();
|
||||
tableViewer.setInput(emptyList);
|
||||
} else {
|
||||
stream=trackEntry.getStream();
|
||||
stream=trackEntry.waveform;
|
||||
tableViewer.setInput(emptyList);
|
||||
new Thread() {
|
||||
private ConcurrentHashMap<String, DataType> propNames=new ConcurrentHashMap<String, DataType>();
|
||||
@ -255,11 +264,12 @@ public class TransactionList extends Composite {
|
||||
}
|
||||
|
||||
public void run() {
|
||||
eventList = stream.getEvents().values().parallelStream()
|
||||
Collection<IEvent[]> values = stream.getEvents().values();
|
||||
eventList = values.parallelStream().map(Arrays::asList)
|
||||
.flatMap(List::stream)
|
||||
.filter(evt -> evt.getType()==Type.BEGIN)
|
||||
.filter(evt -> evt.getKind()==EventKind.BEGIN)
|
||||
.map(evt-> {
|
||||
ITx tx = evt.getTransaction();
|
||||
ITx tx = ((ITxEvent)evt).getTransaction();
|
||||
for(ITxAttribute attr: tx.getAttributes()) {
|
||||
propNames.put(attr.getName(), attr.getDataType());
|
||||
}
|
||||
|
@ -0,0 +1,142 @@
|
||||
package com.minres.scviewer.e4.application.parts;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.eclipse.core.runtime.preferences.DefaultScope;
|
||||
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
|
||||
import org.eclipse.jface.resource.StringConverter;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.graphics.Color;
|
||||
import org.eclipse.swt.graphics.Font;
|
||||
import org.eclipse.swt.graphics.RGB;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.wb.swt.SWTResourceManager;
|
||||
import org.osgi.service.prefs.Preferences;
|
||||
|
||||
import com.minres.scviewer.database.ui.IWaveformStyleProvider;
|
||||
import com.minres.scviewer.database.ui.WaveformColors;
|
||||
import com.minres.scviewer.e4.application.preferences.PreferenceConstants;
|
||||
|
||||
public class WaveformStyleProvider implements IWaveformStyleProvider {
|
||||
|
||||
private Composite parent;
|
||||
|
||||
private Font nameFont;
|
||||
|
||||
private Color[] colors = new Color[WaveformColors.values().length];
|
||||
|
||||
// list of random colors
|
||||
private static Color[][] randomColors;
|
||||
|
||||
private int trackHeigth=25;
|
||||
|
||||
public WaveformStyleProvider() {
|
||||
setupDefaults();
|
||||
}
|
||||
|
||||
private void setupDefaults() {
|
||||
Display display = Display.getCurrent();
|
||||
|
||||
nameFont = display.getSystemFont();
|
||||
colors[WaveformColors.LINE.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED);
|
||||
colors[WaveformColors.LINE_HIGHLITE.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_CYAN);
|
||||
colors[WaveformColors.TRACK_BG_EVEN.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_BLACK);
|
||||
colors[WaveformColors.TRACK_BG_ODD.ordinal()] = SWTResourceManager.getColor(40, 40, 40);
|
||||
colors[WaveformColors.TRACK_BG_HIGHLITE.ordinal()] = SWTResourceManager.getColor(40, 40, 80);
|
||||
colors[WaveformColors.TX_BG.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GREEN);
|
||||
colors[WaveformColors.TX_BG_HIGHLITE.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_GREEN);
|
||||
colors[WaveformColors.TX_BORDER.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED);
|
||||
colors[WaveformColors.SIGNAL0.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GREEN);
|
||||
colors[WaveformColors.SIGNAL1.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GREEN);
|
||||
colors[WaveformColors.SIGNALZ.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_YELLOW);
|
||||
colors[WaveformColors.SIGNALX.ordinal()] = SWTResourceManager.getColor(255, 51, 51);
|
||||
colors[WaveformColors.SIGNALU.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_YELLOW);
|
||||
colors[WaveformColors.SIGNAL_TEXT.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_WHITE);
|
||||
colors[WaveformColors.SIGNAL_REAL.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_YELLOW);
|
||||
colors[WaveformColors.SIGNAL_NAN.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED);
|
||||
colors[WaveformColors.CURSOR.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED);
|
||||
colors[WaveformColors.CURSOR_DRAG.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GRAY);
|
||||
colors[WaveformColors.CURSOR_TEXT.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_WHITE);
|
||||
colors[WaveformColors.MARKER.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_GRAY);
|
||||
colors[WaveformColors.MARKER_TEXT.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_WHITE);
|
||||
colors[WaveformColors.REL_ARROW.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_MAGENTA);
|
||||
colors[WaveformColors.REL_ARROW_HIGHLITE.ordinal()] = SWTResourceManager.getColor(255, 128, 255);
|
||||
randomColors = new Color[][] {
|
||||
{ SWTResourceManager.getColor( 170, 66, 37 ), SWTResourceManager.getColor( 190, 66, 37 ) },
|
||||
{ SWTResourceManager.getColor( 96, 74, 110 ), SWTResourceManager.getColor( 96, 74, 130 ) },
|
||||
{ SWTResourceManager.getColor( 133, 105, 128 ), SWTResourceManager.getColor( 153, 105, 128 ) },
|
||||
{ SWTResourceManager.getColor( 0, 126, 135 ), SWTResourceManager.getColor( 0, 126, 155 ) },
|
||||
{ SWTResourceManager.getColor( 243, 146, 75 ), SWTResourceManager.getColor( 255, 146, 75 ) },
|
||||
{ SWTResourceManager.getColor( 206, 135, 163 ), SWTResourceManager.getColor( 226, 135, 163 ) },
|
||||
{ SWTResourceManager.getColor( 124, 103, 74 ), SWTResourceManager.getColor( 144, 103, 74 ) },
|
||||
{ SWTResourceManager.getColor( 194, 187, 169 ), SWTResourceManager.getColor( 214, 187, 169 ) },
|
||||
{ SWTResourceManager.getColor( 104, 73, 71 ), SWTResourceManager.getColor( 124, 73, 71 ) },
|
||||
{ SWTResourceManager.getColor( 75, 196, 213 ), SWTResourceManager.getColor( 75, 196, 233 ) },
|
||||
{ SWTResourceManager.getColor( 206, 232, 229 ), SWTResourceManager.getColor( 206, 252, 229 ) },
|
||||
{ SWTResourceManager.getColor( 169, 221, 199 ), SWTResourceManager.getColor( 169, 241, 199 ) },
|
||||
{ SWTResourceManager.getColor( 100, 165, 197 ), SWTResourceManager.getColor( 100, 165, 217 ) },
|
||||
{ SWTResourceManager.getColor( 150, 147, 178 ), SWTResourceManager.getColor( 150, 147, 198 ) },
|
||||
{ SWTResourceManager.getColor( 200, 222, 182 ), SWTResourceManager.getColor( 200, 242, 182 ) },
|
||||
{ SWTResourceManager.getColor( 147, 208, 197 ), SWTResourceManager.getColor( 147, 228, 197 ) }
|
||||
};
|
||||
}
|
||||
|
||||
public WaveformStyleProvider(IEclipsePreferences store) {
|
||||
setupDefaults();
|
||||
Preferences defaultPrefs= store.parent().parent().node("/"+DefaultScope.SCOPE+"/"+PreferenceConstants.PREFERENCES_SCOPE);
|
||||
HashMap<WaveformColors, RGB> colorPref = new HashMap<>();
|
||||
for (WaveformColors c : WaveformColors.values()) {
|
||||
String key = c.name() + "_COLOR";
|
||||
String prefValue = store.get(key, defaultPrefs.get(key, "")); //$NON-NLS-1$
|
||||
RGB rgb = StringConverter.asRGB(prefValue);
|
||||
colorPref.put(c, rgb);
|
||||
}
|
||||
trackHeigth = store.getInt(PreferenceConstants.TRACK_HEIGHT, defaultPrefs.getInt(PreferenceConstants.TRACK_HEIGHT, 25)); //$NON-NLS-1$
|
||||
}
|
||||
/**
|
||||
* needs redraw() afterwards
|
||||
* @param colourMap
|
||||
*/
|
||||
public void initColors(HashMap<WaveformColors, RGB> colourMap) {
|
||||
Display d = parent.getDisplay();
|
||||
if (colourMap != null) {
|
||||
for (WaveformColors c : WaveformColors.values()) {
|
||||
if (colourMap.containsKey(c))
|
||||
colors[c.ordinal()] = new Color(d, colourMap.get(c));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Font getNameFont() {
|
||||
return nameFont;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Font getNameFontHighlite() {
|
||||
return nameFont;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTrackHeight() {
|
||||
return trackHeigth;
|
||||
}
|
||||
@Override
|
||||
public Color getColor(WaveformColors type) {
|
||||
return colors[type.ordinal()];
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color[] computeColor (String streamValue) {
|
||||
Color[] result = new Color[] {SWTResourceManager.getColor( 200,0,0), SWTResourceManager.getColor( 255,0,0)};
|
||||
// assign "random" color here, one name always results in the same color!
|
||||
if( streamValue!=null && randomColors.length > 0 ) {
|
||||
int index = Math.abs(streamValue.hashCode()) % randomColors.length;
|
||||
result[0] = randomColors[index][0];
|
||||
result[1] = randomColors[index][1];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
@ -37,7 +37,6 @@ import org.eclipse.core.runtime.OperationCanceledException;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.core.runtime.jobs.Job;
|
||||
import org.eclipse.core.runtime.jobs.JobGroup;
|
||||
import org.eclipse.core.runtime.preferences.DefaultScope;
|
||||
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
|
||||
import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener;
|
||||
import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent;
|
||||
@ -55,15 +54,12 @@ import org.eclipse.e4.ui.services.EMenuService;
|
||||
import org.eclipse.e4.ui.workbench.modeling.EPartService;
|
||||
import org.eclipse.e4.ui.workbench.modeling.ESelectionService;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.jface.resource.StringConverter;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.jface.viewers.ISelectionChangedListener;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.jface.viewers.SelectionChangedEvent;
|
||||
import org.eclipse.jface.viewers.StructuredSelection;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.custom.CTabFolder;
|
||||
import org.eclipse.swt.custom.CTabItem;
|
||||
import org.eclipse.swt.custom.SashForm;
|
||||
import org.eclipse.swt.events.DisposeEvent;
|
||||
import org.eclipse.swt.events.DisposeListener;
|
||||
@ -72,7 +68,6 @@ import org.eclipse.swt.events.PaintEvent;
|
||||
import org.eclipse.swt.events.PaintListener;
|
||||
import org.eclipse.swt.graphics.Font;
|
||||
import org.eclipse.swt.graphics.Point;
|
||||
import org.eclipse.swt.graphics.RGB;
|
||||
import org.eclipse.swt.graphics.Rectangle;
|
||||
import org.eclipse.swt.layout.FillLayout;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
@ -85,24 +80,23 @@ import org.eclipse.swt.widgets.Table;
|
||||
import org.eclipse.swt.widgets.TableColumn;
|
||||
import org.eclipse.swt.widgets.TableItem;
|
||||
import org.eclipse.swt.widgets.Widget;
|
||||
import org.osgi.service.prefs.Preferences;
|
||||
|
||||
import com.minres.scviewer.database.DataType;
|
||||
import com.minres.scviewer.database.ITx;
|
||||
import com.minres.scviewer.database.ITxAttribute;
|
||||
import com.minres.scviewer.database.ITxEvent;
|
||||
import com.minres.scviewer.database.ITxRelation;
|
||||
import com.minres.scviewer.database.IEvent;
|
||||
import com.minres.scviewer.database.IWaveform;
|
||||
import com.minres.scviewer.database.IWaveformDb;
|
||||
import com.minres.scviewer.database.IWaveformDbFactory;
|
||||
import com.minres.scviewer.database.RelationType;
|
||||
import com.minres.scviewer.database.tx.ITx;
|
||||
import com.minres.scviewer.database.tx.ITxAttribute;
|
||||
import com.minres.scviewer.database.tx.ITxEvent;
|
||||
import com.minres.scviewer.database.tx.ITxRelation;
|
||||
import com.minres.scviewer.database.ui.GotoDirection;
|
||||
import com.minres.scviewer.database.ui.ICursor;
|
||||
import com.minres.scviewer.database.ui.IWaveformView;
|
||||
import com.minres.scviewer.database.ui.TrackEntry;
|
||||
import com.minres.scviewer.database.ui.TrackEntry.ValueDisplay;
|
||||
import com.minres.scviewer.database.ui.TrackEntry.WaveDisplay;
|
||||
import com.minres.scviewer.database.ui.WaveformColors;
|
||||
import com.minres.scviewer.database.ui.swt.Constants;
|
||||
import com.minres.scviewer.database.ui.swt.ToolTipContentProvider;
|
||||
import com.minres.scviewer.database.ui.swt.ToolTipHelpTextProvider;
|
||||
@ -302,7 +296,6 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
||||
transactionList = ContextInjectionFactory.make(TransactionListView.class, ctx);
|
||||
|
||||
waveformPane.setMaxTime(0);
|
||||
setupColors();
|
||||
//set selection to empty selection when opening a new waveformPane
|
||||
selectionService.setSelection(new StructuredSelection());
|
||||
|
||||
@ -511,6 +504,7 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
||||
return false;
|
||||
}
|
||||
});
|
||||
waveformPane.setStyleProvider(new WaveformStyleProvider(store));
|
||||
}
|
||||
|
||||
@Inject
|
||||
@ -543,25 +537,9 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
||||
@Override
|
||||
public void preferenceChange(PreferenceChangeEvent event) {
|
||||
if (!PreferenceConstants.DATABASE_RELOAD.equals(event.getKey()) && !PreferenceConstants.SHOW_HOVER.equals(event.getKey())){
|
||||
setupColors();
|
||||
}
|
||||
waveformPane.setStyleProvider(new WaveformStyleProvider(store)); }
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup colors.
|
||||
*/
|
||||
protected void setupColors() {
|
||||
Preferences defaultPrefs= store.parent().parent().node("/"+DefaultScope.SCOPE+"/"+PreferenceConstants.PREFERENCES_SCOPE);
|
||||
HashMap<WaveformColors, RGB> colorPref = new HashMap<>();
|
||||
for (WaveformColors c : WaveformColors.values()) {
|
||||
String key = c.name() + "_COLOR";
|
||||
String prefValue = store.get(key, defaultPrefs.get(key, "")); //$NON-NLS-1$
|
||||
RGB rgb = StringConverter.asRGB(prefValue);
|
||||
colorPref.put(c, rgb);
|
||||
}
|
||||
waveformPane.setColors(colorPref);
|
||||
}
|
||||
|
||||
class DbLoadJob extends Job {
|
||||
final File file;
|
||||
public DbLoadJob(String name, final File file) {
|
||||
@ -790,7 +768,7 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
||||
// get transaction id
|
||||
persistedState.put(SELECTED_TX_ID, Long.toString(tx.getId()));
|
||||
//get TrackEntry name
|
||||
String name = te.getStream().getFullName();
|
||||
String name = te.waveform.getFullName();
|
||||
persistedState.put(SELECTED_TRACKENTRY_NAME, name);
|
||||
}
|
||||
}
|
||||
@ -823,7 +801,7 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
||||
for (int i = 0; i < waves; i++) {
|
||||
IWaveform waveform = database.getStreamByName(state.get(SHOWN_WAVEFORM + i));
|
||||
if (waveform != null) {
|
||||
TrackEntry t = new TrackEntry(waveform);
|
||||
TrackEntry t = waveformPane.addWaveform(waveform, -1);
|
||||
//check if t is selected
|
||||
boolean isSelected = Boolean.valueOf(state.get(SHOWN_WAVEFORM + i + WAVEFORM_SELECTED));
|
||||
if(isSelected) {
|
||||
@ -840,8 +818,6 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
||||
t.waveDisplay=WaveDisplay.valueOf(s);
|
||||
}
|
||||
}
|
||||
if (res.size() > 0)
|
||||
waveformPane.getStreamList().addAll(res);
|
||||
Integer cursorLength = state.containsKey(SHOWN_CURSOR+"S")?Integer.parseInt(state.get(SHOWN_CURSOR + "S")):0; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
List<ICursor> cursors = waveformPane.getCursorList();
|
||||
if (cursorLength == cursors.size()) {
|
||||
@ -874,11 +850,11 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
||||
if(te.waveform.getFullName().compareTo(trackentryName)==0) {
|
||||
boolean found = false;
|
||||
// TODO: find transaction by time? To avoid 3x for-loop
|
||||
for( List<ITxEvent> lev : te.getStream().getEvents().values() ) {
|
||||
for( IEvent[] lev : te.waveform.getEvents().values() ) {
|
||||
if(lev == null) continue;
|
||||
for(ITxEvent itxe : lev) {
|
||||
if(itxe == null) continue;
|
||||
ITx itx = itxe.getTransaction();
|
||||
for(IEvent itxe : lev) {
|
||||
if(itxe == null || !(itxe instanceof ITxEvent)) continue;
|
||||
ITx itx = ((ITxEvent)itxe).getTransaction();
|
||||
if(itx.getId() == txId) {
|
||||
found = true;
|
||||
ArrayList<Object> selectionList = new ArrayList<Object>();
|
||||
@ -1011,12 +987,10 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
||||
* @param insert the insert
|
||||
*/
|
||||
public void addStreamsToList(IWaveform[] iWaveforms, boolean insert) {
|
||||
List<TrackEntry> streams = new LinkedList<>();
|
||||
for (IWaveform stream : iWaveforms)
|
||||
streams.add(new TrackEntry(stream));
|
||||
IStructuredSelection selection = (IStructuredSelection) waveformPane.getSelection();
|
||||
if (selection.size() == 0) {
|
||||
waveformPane.getStreamList().addAll(streams);
|
||||
for (IWaveform waveform : iWaveforms)
|
||||
waveformPane.addWaveform(waveform, -1);
|
||||
} else {
|
||||
Object first = selection.getFirstElement();
|
||||
if(first instanceof ITx) {
|
||||
@ -1024,17 +998,21 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
||||
TrackEntry trackEntry = waveformPane.getEntryForStream(stream);
|
||||
if (insert) {
|
||||
int index = waveformPane.getStreamList().indexOf(trackEntry);
|
||||
waveformPane.getStreamList().addAll(index, streams);
|
||||
for (IWaveform waveform : iWaveforms)
|
||||
waveformPane.addWaveform(waveform, index++);
|
||||
} else {
|
||||
waveformPane.getStreamList().addAll(streams);
|
||||
for (IWaveform waveform : iWaveforms)
|
||||
waveformPane.addWaveform(waveform, -1);
|
||||
}
|
||||
} else if(first instanceof TrackEntry) {
|
||||
TrackEntry trackEntry = (TrackEntry) first;
|
||||
if (insert) {
|
||||
int index = waveformPane.getStreamList().indexOf(trackEntry);
|
||||
waveformPane.getStreamList().addAll(index, streams);
|
||||
for (IWaveform waveform : iWaveforms)
|
||||
waveformPane.addWaveform(waveform, index++);
|
||||
} else {
|
||||
waveformPane.getStreamList().addAll(streams);
|
||||
for (IWaveform waveform : iWaveforms)
|
||||
waveformPane.addWaveform(waveform, -1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1115,7 +1093,7 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
||||
|
||||
boolean foundZoom=false;
|
||||
//try to find existing zoomlevel where scaleFactor*clientAreaWidth >= maxTime, if one is found set it as new zoomlevel
|
||||
for (int level=0; level<Constants.unitMultiplier.length*Constants.unitString.length; level++){
|
||||
for (int level=0; level<Constants.UNIT_MULTIPLIER.length*Constants.UNIT_STRING.length; level++){
|
||||
long scaleFactor = (long) Math.pow(10, level/2);
|
||||
if(level%2==1) scaleFactor*=3;
|
||||
if(scaleFactor*clientAreaWidth >= maxTime) {
|
||||
@ -1125,7 +1103,7 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
||||
}
|
||||
}
|
||||
//if no zoom level is found, set biggest one available
|
||||
if(!foundZoom) setZoomLevel(Constants.unitMultiplier.length*Constants.unitString.length-1);
|
||||
if(!foundZoom) setZoomLevel(Constants.UNIT_MULTIPLIER.length*Constants.UNIT_STRING.length-1);
|
||||
|
||||
updateAll();
|
||||
}
|
||||
|
@ -5,8 +5,8 @@ import java.util.Vector;
|
||||
import org.eclipse.jface.viewers.ITreeContentProvider;
|
||||
import org.eclipse.jface.viewers.Viewer;
|
||||
|
||||
import com.minres.scviewer.database.ITx;
|
||||
import com.minres.scviewer.database.ITxRelation;
|
||||
import com.minres.scviewer.database.tx.ITx;
|
||||
import com.minres.scviewer.database.tx.ITxRelation;
|
||||
import com.minres.scviewer.e4.application.Messages;
|
||||
import com.minres.scviewer.e4.application.parts.WaveformViewer;
|
||||
|
||||
|
@ -8,9 +8,9 @@ import org.eclipse.jface.viewers.StyledString;
|
||||
import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
|
||||
|
||||
import com.minres.scviewer.database.DataType;
|
||||
import com.minres.scviewer.database.ITx;
|
||||
import com.minres.scviewer.database.ITxAttribute;
|
||||
import com.minres.scviewer.database.ITxRelation;
|
||||
import com.minres.scviewer.database.tx.ITx;
|
||||
import com.minres.scviewer.database.tx.ITxAttribute;
|
||||
import com.minres.scviewer.database.tx.ITxRelation;
|
||||
import com.minres.scviewer.e4.application.Messages;
|
||||
import com.minres.scviewer.e4.application.parts.WaveformViewer;
|
||||
|
||||
|
@ -5,7 +5,7 @@ import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.minres.scviewer.database.ITx;
|
||||
import com.minres.scviewer.database.tx.ITx;
|
||||
import com.minres.scviewer.e4.application.Messages;
|
||||
|
||||
/**
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user