Merge branch 'release/2.12.0'

This commit is contained in:
Eyck Jentzsch 2021-01-15 16:50:33 +01:00
commit 5604c3ee5e
54 changed files with 479 additions and 470 deletions

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>com.minres.scviewer</groupId> <groupId>com.minres.scviewer</groupId>
<artifactId>com.minres.scviewer.parent</artifactId> <artifactId>com.minres.scviewer.parent</artifactId>
<version>2.11.2-SNAPSHOT</version> <version>2.12.0-SNAPSHOT</version>
<relativePath>../..</relativePath> <relativePath>../..</relativePath>
</parent> </parent>
<version>3.0.0-SNAPSHOT</version> <version>3.0.0-SNAPSHOT</version>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>com.minres.scviewer</groupId> <groupId>com.minres.scviewer</groupId>
<artifactId>com.minres.scviewer.parent</artifactId> <artifactId>com.minres.scviewer.parent</artifactId>
<version>2.11.2-SNAPSHOT</version> <version>2.12.0-SNAPSHOT</version>
<relativePath>../..</relativePath> <relativePath>../..</relativePath>
</parent> </parent>
<version>1.1.0-SNAPSHOT</version> <version>1.1.0-SNAPSHOT</version>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>com.minres.scviewer</groupId> <groupId>com.minres.scviewer</groupId>
<artifactId>com.minres.scviewer.parent</artifactId> <artifactId>com.minres.scviewer.parent</artifactId>
<version>2.11.2-SNAPSHOT</version> <version>2.12.0-SNAPSHOT</version>
<relativePath>../..</relativePath> <relativePath>../..</relativePath>
</parent> </parent>
<version>1.0.0-SNAPSHOT</version> <version>1.0.0-SNAPSHOT</version>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>com.minres.scviewer</groupId> <groupId>com.minres.scviewer</groupId>
<artifactId>com.minres.scviewer.parent</artifactId> <artifactId>com.minres.scviewer.parent</artifactId>
<version>2.11.2-SNAPSHOT</version> <version>2.12.0-SNAPSHOT</version>
<relativePath>../..</relativePath> <relativePath>../..</relativePath>
</parent> </parent>
<version>1.1.0-SNAPSHOT</version> <version>1.1.0-SNAPSHOT</version>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>com.minres.scviewer</groupId> <groupId>com.minres.scviewer</groupId>
<artifactId>com.minres.scviewer.parent</artifactId> <artifactId>com.minres.scviewer.parent</artifactId>
<version>2.11.2-SNAPSHOT</version> <version>2.12.0-SNAPSHOT</version>
<relativePath>../..</relativePath> <relativePath>../..</relativePath>
</parent> </parent>
<version>1.1.0-SNAPSHOT</version> <version>1.1.0-SNAPSHOT</version>

View File

@ -4,7 +4,7 @@
<parent> <parent>
<groupId>com.minres.scviewer</groupId> <groupId>com.minres.scviewer</groupId>
<artifactId>com.minres.scviewer.parent</artifactId> <artifactId>com.minres.scviewer.parent</artifactId>
<version>2.11.2-SNAPSHOT</version> <version>2.12.0-SNAPSHOT</version>
<relativePath>../..</relativePath> <relativePath>../..</relativePath>
</parent> </parent>
<packaging>eclipse-plugin</packaging> <packaging>eclipse-plugin</packaging>

View File

@ -39,14 +39,14 @@ abstract class AbstractTxStream extends HierNode implements IWaveform {
private List<RelationType> usedRelationsList; private List<RelationType> usedRelationsList;
public AbstractTxStream(IDatabase database, String name, long streamId) { protected AbstractTxStream(IDatabase database, String name, long streamId) {
super(name); super(name);
this.database=database; this.database=database;
this.streamId=streamId; this.streamId=streamId;
} }
@Override @Override
public int getWidth() { public int getRowCount() {
if(maxConcurrency==null){ if(maxConcurrency==null){
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("SELECT MAX(concurrencyLevel) as concurrencyLevel FROM ScvTx where stream="); sb.append("SELECT MAX(concurrencyLevel) as concurrencyLevel FROM ScvTx where stream=");
@ -126,4 +126,11 @@ abstract class AbstractTxStream extends HierNode implements IWaveform {
return WaveformType.TRANSACTION; return WaveformType.TRANSACTION;
} }
/**
* Calculate concurrency.
*/
public void calculateConcurrency() {
}
} }

View File

@ -99,7 +99,6 @@ public class SQLiteDbLoader implements IWaveformDbLoader {
@Override @Override
public void load(IWaveformDb db, File file) throws InputFormatException { public void load(IWaveformDb db, File file) throws InputFormatException {
dispose();
database=new SQLiteDatabase(file.getAbsolutePath(), db); database=new SQLiteDatabase(file.getAbsolutePath(), db);
database.setData("TIMERESOLUTION", 1L); database.setData("TIMERESOLUTION", 1L);
SQLiteDatabaseSelectHandler<ScvSimProps> handler = new SQLiteDatabaseSelectHandler<>(ScvSimProps.class, database); SQLiteDatabaseSelectHandler<ScvSimProps> handler = new SQLiteDatabaseSelectHandler<>(ScvSimProps.class, database);

View File

@ -28,7 +28,6 @@ import com.minres.scviewer.database.sqlite.tables.ScvTxEvent;
import com.minres.scviewer.database.sqlite.tables.ScvTxRelation; import com.minres.scviewer.database.sqlite.tables.ScvTxRelation;
import com.minres.scviewer.database.tx.ITx; import com.minres.scviewer.database.tx.ITx;
import com.minres.scviewer.database.tx.ITxAttribute; import com.minres.scviewer.database.tx.ITxAttribute;
import com.minres.scviewer.database.tx.ITxGenerator;
import com.minres.scviewer.database.tx.ITxRelation; import com.minres.scviewer.database.tx.ITxRelation;
public class Tx implements ITx { public class Tx implements ITx {
@ -61,12 +60,11 @@ public class Tx implements ITx {
} }
@Override @Override
public ITxGenerator getGenerator() { public IWaveform getGenerator() {
return trGenerator; return trGenerator;
} }
@Override int getConcurrencyIndex() {
public int getConcurrencyIndex() {
return scvTx.getConcurrencyLevel(); return scvTx.getConcurrencyLevel();
} }

View File

@ -56,4 +56,10 @@ public class TxEvent implements ITxEvent {
public WaveformType getType() { public WaveformType getType() {
return WaveformType.TRANSACTION; return WaveformType.TRANSACTION;
} }
@Override
public int getRowIndex() {
return ((Tx)tx).getConcurrencyIndex();
}
} }

View File

@ -22,9 +22,8 @@ import com.minres.scviewer.database.sqlite.db.SQLiteDatabaseSelectHandler;
import com.minres.scviewer.database.sqlite.tables.ScvGenerator; import com.minres.scviewer.database.sqlite.tables.ScvGenerator;
import com.minres.scviewer.database.sqlite.tables.ScvTx; import com.minres.scviewer.database.sqlite.tables.ScvTx;
import com.minres.scviewer.database.tx.ITx; import com.minres.scviewer.database.tx.ITx;
import com.minres.scviewer.database.tx.ITxGenerator;
public class TxGenerator extends AbstractTxStream implements ITxGenerator { public class TxGenerator extends AbstractTxStream {
private TxStream stream; private TxStream stream;
@ -44,11 +43,6 @@ public class TxGenerator extends AbstractTxStream implements ITxGenerator {
return (long) scvGenerator.getId(); return (long) scvGenerator.getId();
} }
@Override
public IWaveform getStream() {
return stream;
}
@Override @Override
public String getName() { public String getName() {
return scvGenerator.getName(); return scvGenerator.getName();

View File

@ -26,7 +26,6 @@ import com.minres.scviewer.database.sqlite.tables.ScvGenerator;
import com.minres.scviewer.database.sqlite.tables.ScvStream; import com.minres.scviewer.database.sqlite.tables.ScvStream;
import com.minres.scviewer.database.sqlite.tables.ScvTx; import com.minres.scviewer.database.sqlite.tables.ScvTx;
import com.minres.scviewer.database.tx.ITx; import com.minres.scviewer.database.tx.ITx;
import com.minres.scviewer.database.tx.ITxGenerator;
public class TxStream extends AbstractTxStream { public class TxStream extends AbstractTxStream {
@ -54,7 +53,7 @@ public class TxStream extends AbstractTxStream {
return (long) scvStream.getId(); return (long) scvStream.getId();
} }
public List<ITxGenerator> getGenerators() { public List<IWaveform> getGenerators() {
if(generators==null){ if(generators==null){
SQLiteDatabaseSelectHandler<ScvGenerator> handler = new SQLiteDatabaseSelectHandler<>( SQLiteDatabaseSelectHandler<ScvGenerator> handler = new SQLiteDatabaseSelectHandler<>(
ScvGenerator.class, database, "stream="+scvStream.getId()); ScvGenerator.class, database, "stream="+scvStream.getId());

View File

@ -6,7 +6,7 @@
<parent> <parent>
<groupId>com.minres.scviewer</groupId> <groupId>com.minres.scviewer</groupId>
<artifactId>com.minres.scviewer.parent</artifactId> <artifactId>com.minres.scviewer.parent</artifactId>
<version>2.11.2-SNAPSHOT</version> <version>2.12.0-SNAPSHOT</version>
<relativePath>../..</relativePath> <relativePath>../..</relativePath>
</parent> </parent>
<packaging>eclipse-plugin</packaging> <packaging>eclipse-plugin</packaging>

View File

@ -13,15 +13,16 @@ package com.minres.scviewer.database.text;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.NavigableMap; import java.util.NavigableMap;
import java.util.TreeMap; import java.util.TreeMap;
import com.minres.scviewer.database.EventKind;
import com.minres.scviewer.database.HierNode; import com.minres.scviewer.database.HierNode;
import com.minres.scviewer.database.IEvent; import com.minres.scviewer.database.IEvent;
import com.minres.scviewer.database.IWaveform; import com.minres.scviewer.database.IWaveform;
import com.minres.scviewer.database.WaveformType; 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.ITxEvent;
/** /**
@ -38,8 +39,8 @@ abstract class AbstractTxStream extends HierNode implements IWaveform {
/** The events. */ /** The events. */
TreeMap<Long, IEvent[]> events = new TreeMap<>(); TreeMap<Long, IEvent[]> events = new TreeMap<>();
/** The concurrency calculated. */ /** The max concurrency. */
boolean concurrencyCalculated = false; private int rowCount = -1;
/** /**
* Instantiates a new abstract tx stream. * Instantiates a new abstract tx stream.
@ -48,7 +49,7 @@ abstract class AbstractTxStream extends HierNode implements IWaveform {
* @param id the id * @param id the id
* @param name the name * @param name the name
*/ */
public AbstractTxStream(TextDbLoader loader, Long id, String name) { protected AbstractTxStream(TextDbLoader loader, Long id, String name) {
super(name); super(name);
this.loader = loader; this.loader = loader;
this.id = id; this.id = id;
@ -77,8 +78,6 @@ abstract class AbstractTxStream extends HierNode implements IWaveform {
*/ */
@Override @Override
public NavigableMap<Long, IEvent[]> getEvents() { public NavigableMap<Long, IEvent[]> getEvents() {
if (!concurrencyCalculated)
calculateConcurrency();
return events; return events;
} }
@ -90,8 +89,6 @@ abstract class AbstractTxStream extends HierNode implements IWaveform {
*/ */
@Override @Override
public IEvent[] getEventsAtTime(Long time) { public IEvent[] getEventsAtTime(Long time) {
if (!concurrencyCalculated)
calculateConcurrency();
return events.get(time); return events.get(time);
} }
@ -103,8 +100,6 @@ abstract class AbstractTxStream extends HierNode implements IWaveform {
*/ */
@Override @Override
public IEvent[] getEventsBeforeTime(Long time) { public IEvent[] getEventsBeforeTime(Long time) {
if (!concurrencyCalculated)
calculateConcurrency();
Entry<Long, IEvent[]> e = events.floorEntry(time); Entry<Long, IEvent[]> e = events.floorEntry(time);
if (e == null) if (e == null)
return new IEvent[] {}; return new IEvent[] {};
@ -132,28 +127,59 @@ abstract class AbstractTxStream extends HierNode implements IWaveform {
return id; return id;
} }
/**
* Gets the width.
*
* @return the width
*/
@Override
public int getRowCount() {
if (rowCount<0)
calculateConcurrency();
return rowCount;
}
/** /**
* Calculate concurrency. * Calculate concurrency.
*/ */
synchronized void calculateConcurrency() { void calculateConcurrency() {
if (concurrencyCalculated) if (rowCount>=0)
return; return;
ArrayList<Long> rowendtime = new ArrayList<>(); ArrayList<Long> rowEndTime = new ArrayList<>();
events.entrySet().stream().forEach(entry -> { HashMap<Long, Integer> rowByTxId = new HashMap<>();
IEvent[] values = entry.getValue(); for(Entry<Long, IEvent[]> entry: events.entrySet()) {
Arrays.asList(values).stream().filter(e -> e.getKind() == EventKind.BEGIN).forEach(evt -> { for(IEvent evt:entry.getValue()) {
Tx tx = (Tx) ((TxEvent) evt).getTransaction(); TxEvent txEvt = (TxEvent) evt;
ITx tx = txEvt.getTransaction();
int rowIdx = 0; int rowIdx = 0;
for (; rowIdx < rowendtime.size() && rowendtime.get(rowIdx) > tx.getBeginTime(); rowIdx++) switch(evt.getKind()) {
; case END:
if (rowendtime.size() <= rowIdx) Long txId = txEvt.getTransaction().getId();
rowendtime.add(tx.getEndTime()); txEvt.setConcurrencyIndex(rowByTxId.get(txId));
else rowByTxId.remove(txId);
rowendtime.set(rowIdx, tx.getEndTime()); break;
tx.setConcurrencyIndex(rowIdx); case SINGLE:
}); for (; rowIdx < rowEndTime.size() && rowEndTime.get(rowIdx)>tx.getBeginTime(); rowIdx++);
}); if (rowEndTime.size() <= rowIdx)
concurrencyCalculated = true; rowEndTime.add(tx.getEndTime());
else
rowEndTime.set(rowIdx, tx.getEndTime());
((TxEvent) evt).setConcurrencyIndex(rowIdx);
break;
case BEGIN:
for (; rowIdx < rowEndTime.size() && rowEndTime.get(rowIdx)>tx.getBeginTime(); rowIdx++);
if (rowEndTime.size() <= rowIdx)
rowEndTime.add(tx.getEndTime());
else
rowEndTime.set(rowIdx, tx.getEndTime());
((TxEvent) evt).setConcurrencyIndex(rowIdx);
rowByTxId.put(tx.getId(), rowIdx);
break;
}
}
}
rowCount=rowEndTime.size()>0?rowEndTime.size():1;
getChildNodes().parallelStream().forEach(c -> ((TxGenerator)c).calculateConcurrency());
} }
} }

View File

@ -28,14 +28,13 @@ import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.zip.GZIPInputStream; import java.util.zip.GZIPInputStream;
import org.eclipse.collections.impl.map.mutable.UnifiedMap; import org.eclipse.collections.impl.map.mutable.UnifiedMap;
import org.mapdb.DB; import org.mapdb.DB;
import org.mapdb.DB.HashMapMaker;
import org.mapdb.DB.TreeMapSink;
import org.mapdb.DBMaker; import org.mapdb.DBMaker;
import org.mapdb.HTreeMap; import org.mapdb.HTreeMap;
import org.mapdb.Serializer; import org.mapdb.Serializer;
@ -106,6 +105,26 @@ public class TextDbLoader implements IWaveformDbLoader {
/** The Constant x. */ /** The Constant x. */
static final byte[] x = "scv_tr_stream".getBytes(); static final byte[] x = "scv_tr_stream".getBytes();
/**
* Adds the property change listener.
*
* @param l the l
*/
@Override
public void addPropertyChangeListener(PropertyChangeListener l) {
pcs.addPropertyChangeListener(l);
}
/**
* Removes the property change listener.
*
* @param l the l
*/
@Override
public void removePropertyChangeListener(PropertyChangeListener l) {
pcs.removePropertyChangeListener(l);
}
/** /**
* Gets the max time. * Gets the max time.
* *
@ -116,8 +135,29 @@ public class TextDbLoader implements IWaveformDbLoader {
return maxTime; return maxTime;
} }
/**
* Gets the transaction.
*
* @param txId the tx id
* @return the transaction
*/
public ITx getTransaction(long txId) {
if (txCache.containsKey(txId))
return txCache.get(txId);
if(transactions.containsKey(txId)) {
Tx tx = new Tx(this, transactions.get(txId));
txCache.put(txId, tx);
return tx;
} else {
throw new IllegalArgumentException();
}
}
public ScvTx getScvTx(long id) { public ScvTx getScvTx(long id) {
return transactions.get(id); if(transactions.containsKey(id))
return transactions.get(id);
else
throw new IllegalArgumentException();
} }
/** /**
@ -130,6 +170,15 @@ public class TextDbLoader implements IWaveformDbLoader {
return new ArrayList<>(txStreams.values()); return new ArrayList<>(txStreams.values());
} }
/**
* Gets the all relation types.
*
* @return the all relation types
*/
public Collection<RelationType> getAllRelationTypes() {
return relationTypes.values();
}
/** /**
* Can load. * Can load.
* *
@ -156,6 +205,22 @@ public class TextDbLoader implements IWaveformDbLoader {
return false; return false;
} }
/**
* Checks if is gzipped.
*
* @param f the f
* @return true, if is gzipped
*/
private static boolean isGzipped(File 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) {
return false;
}
}
/** /**
* Load. * Load.
* *
@ -188,28 +253,14 @@ public class TextDbLoader implements IWaveformDbLoader {
TextDbParser parser = new TextDbParser(this); TextDbParser parser = new TextDbParser(this);
try { try {
// parser.txSink = mapDb.treeMap("transactions", Serializer.LONG, Serializer.JAVA).createFromSink();
parser.txSink = mapDb.hashMap("transactions", Serializer.LONG, Serializer.JAVA).create(); parser.txSink = mapDb.hashMap("transactions", Serializer.LONG, Serializer.JAVA).create();
parser.parseInput(gzipped ? new GZIPInputStream(new FileInputStream(file)) : new FileInputStream(file)); parser.parseInput(gzipped ? new GZIPInputStream(new FileInputStream(file)) : new FileInputStream(file));
// transactions = parser.txSink.create();
transactions = parser.txSink; transactions = parser.txSink;
} catch (IllegalArgumentException | ArrayIndexOutOfBoundsException e) { } catch (IllegalArgumentException | ArrayIndexOutOfBoundsException e) {
} catch (Exception e) { } catch (Exception e) {
throw new InputFormatException(e.toString()); throw new InputFormatException(e.toString());
} }
for (TxStream stream : txStreams.values()) { txStreams.values().parallelStream().forEach(TxStream::calculateConcurrency);
Thread t = new Thread() {
@Override
public void run() {
try {
stream.calculateConcurrency();
} catch (Exception e) {
/* don't let exceptions bubble up */ }
}
};
threads.add(t);
t.start();
}
} }
/** /**
@ -231,31 +282,6 @@ public class TextDbLoader implements IWaveformDbLoader {
} }
} }
/**
* Checks if is gzipped.
*
* @param f the f
* @return true, if is gzipped
*/
private static boolean isGzipped(File 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) {
return false;
}
}
/**
* Gets the all relation types.
*
* @return the all relation types
*/
public Collection<RelationType> getAllRelationTypes() {
return relationTypes.values();
}
/** /**
* The Class TextDbParser. * The Class TextDbParser.
*/ */
@ -321,6 +347,11 @@ public class TextDbLoader implements IWaveformDbLoader {
} }
if (curLine != null) if (curLine != null)
parseLine(curLine, nextLine); parseLine(curLine, nextLine);
for(Entry<Long, ScvTx> e: transactionById.entrySet()) {
ScvTx scvTx = e.getValue();
scvTx.endTime=loader.maxTime;
txSink.put(e.getKey(), scvTx);
}
} }
/** /**
@ -368,8 +399,6 @@ public class TextDbLoader implements IWaveformDbLoader {
ScvTx scvTx = new ScvTx(id, gen.stream.getId(), genId, ScvTx scvTx = new ScvTx(id, gen.stream.getId(), genId,
Long.parseLong(tokens[3]) * stringToScale(tokens[4])); Long.parseLong(tokens[3]) * stringToScale(tokens[4]));
loader.maxTime = loader.maxTime > scvTx.beginTime ? loader.maxTime : scvTx.beginTime; loader.maxTime = loader.maxTime > scvTx.beginTime ? loader.maxTime : scvTx.beginTime;
TxStream stream = loader.txStreams.get(gen.stream.getId());
stream.setConcurrency(stream.getConcurrency() + 1);
if (nextLine != null && nextLine.charAt(0) == 'a') { if (nextLine != null && nextLine.charAt(0) == 'a') {
int idx = 0; int idx = 0;
while (nextLine != null && nextLine.charAt(0) == 'a') { while (nextLine != null && nextLine.charAt(0) == 'a') {
@ -391,18 +420,14 @@ public class TextDbLoader implements IWaveformDbLoader {
TxGenerator gen = loader.txGenerators.get(scvTx.generatorId); TxGenerator gen = loader.txGenerators.get(scvTx.generatorId);
TxStream stream = loader.txStreams.get(gen.stream.getId()); TxStream stream = loader.txStreams.get(gen.stream.getId());
if (scvTx.beginTime == scvTx.endTime) { if (scvTx.beginTime == scvTx.endTime) {
TxEvent evt = new TxEvent(loader, EventKind.SINGLE, id, scvTx.beginTime); stream.addEvent(new TxEvent(loader, EventKind.SINGLE, id, scvTx.beginTime));
stream.addEvent(evt); gen.addEvent(new TxEvent(loader, EventKind.SINGLE, id, scvTx.beginTime));
gen.addEvent(evt);
} else { } else {
TxEvent begEvt = new TxEvent(loader, EventKind.BEGIN, id, scvTx.beginTime); stream.addEvent(new TxEvent(loader, EventKind.BEGIN, id, scvTx.beginTime));
stream.addEvent(begEvt); gen.addEvent(new TxEvent(loader, EventKind.BEGIN, id, scvTx.beginTime));
gen.addEvent(begEvt); stream.addEvent(new TxEvent(loader, EventKind.END, id, scvTx.endTime));
TxEvent endEvt = new TxEvent(loader, EventKind.END, id, scvTx.endTime); gen.addEvent(new TxEvent(loader, EventKind.END, id, scvTx.endTime));
stream.addEvent(endEvt);
gen.addEvent(endEvt);
} }
stream.setConcurrency(stream.getConcurrency() - 1);
if (nextLine != null && nextLine.charAt(0) == 'a') { if (nextLine != null && nextLine.charAt(0) == 'a') {
int idx = 0; int idx = 0;
while (nextLine != null && nextLine.charAt(0) == 'a') { while (nextLine != null && nextLine.charAt(0) == 'a') {
@ -521,38 +546,4 @@ public class TextDbLoader implements IWaveformDbLoader {
} }
/**
* Gets the transaction.
*
* @param txId the tx id
* @return the transaction
*/
public ITx getTransaction(long txId) {
if (txCache.containsKey(txId))
return txCache.get(txId);
Tx tx = new Tx(this, txId);
txCache.put(txId, tx);
return tx;
}
/**
* Adds the property change listener.
*
* @param l the l
*/
@Override
public void addPropertyChangeListener(PropertyChangeListener l) {
pcs.addPropertyChangeListener(l);
}
/**
* Removes the property change listener.
*
* @param l the l
*/
@Override
public void removePropertyChangeListener(PropertyChangeListener l) {
pcs.removePropertyChangeListener(l);
}
} }

View File

@ -19,7 +19,6 @@ import java.util.stream.Collectors;
import com.minres.scviewer.database.IWaveform; import com.minres.scviewer.database.IWaveform;
import com.minres.scviewer.database.tx.ITx; import com.minres.scviewer.database.tx.ITx;
import com.minres.scviewer.database.tx.ITxAttribute; import com.minres.scviewer.database.tx.ITxAttribute;
import com.minres.scviewer.database.tx.ITxGenerator;
import com.minres.scviewer.database.tx.ITxRelation; import com.minres.scviewer.database.tx.ITxRelation;
/** /**
@ -30,8 +29,14 @@ class Tx implements ITx {
/** The loader. */ /** The loader. */
private final TextDbLoader loader; private final TextDbLoader loader;
private ScvTx scvTx =null;
/** The id. */ /** The id. */
private long id; private final long id;
private final long generatorId;
private final long streamId;
/** The begin time. */ /** The begin time. */
long beginTime = -1; long beginTime = -1;
@ -39,9 +44,6 @@ class Tx implements ITx {
/** The end time. */ /** The end time. */
long endTime = -1; long endTime = -1;
/** The concurrency index. */
private int concurrencyIndex;
/** /**
* Instantiates a new tx. * Instantiates a new tx.
* *
@ -51,6 +53,10 @@ class Tx implements ITx {
public Tx(TextDbLoader loader, ScvTx scvTx) { public Tx(TextDbLoader loader, ScvTx scvTx) {
this.loader = loader; this.loader = loader;
id = scvTx.id; id = scvTx.id;
generatorId=scvTx.generatorId;
streamId=scvTx.streamId;
beginTime=scvTx.beginTime;
endTime=scvTx.endTime;
} }
/** /**
@ -59,9 +65,11 @@ class Tx implements ITx {
* @param loader the loader * @param loader the loader
* @param txId the tx id * @param txId the tx id
*/ */
public Tx(TextDbLoader loader, long txId) { public Tx(TextDbLoader loader, long id, long generatorId, long streamId) {
this.loader = loader; this.loader = loader;
id = txId; this.id = id;
this.generatorId=generatorId;
this.streamId = streamId;
} }
/** /**
@ -113,7 +121,7 @@ class Tx implements ITx {
return true; return true;
if (obj == null || getClass() != obj.getClass()) if (obj == null || getClass() != obj.getClass())
return false; return false;
return this.loader.getScvTx(id).equals(((Tx) obj).loader.getScvTx(id)); return this.getScvTx().equals(((Tx) obj).getScvTx());
} }
/** /**
@ -123,7 +131,7 @@ class Tx implements ITx {
*/ */
@Override @Override
public int hashCode() { public int hashCode() {
return loader.getScvTx(id).hashCode(); return getScvTx().hashCode();
} }
/** /**
@ -143,7 +151,7 @@ class Tx implements ITx {
*/ */
@Override @Override
public Long getId() { public Long getId() {
return loader.getScvTx(id).id; return getScvTx().id;
} }
/** /**
@ -153,7 +161,7 @@ class Tx implements ITx {
*/ */
@Override @Override
public IWaveform getStream() { public IWaveform getStream() {
return loader.txStreams.get(loader.getScvTx(id).streamId); return loader.txStreams.get(streamId);
} }
/** /**
@ -162,8 +170,8 @@ class Tx implements ITx {
* @return the generator * @return the generator
*/ */
@Override @Override
public ITxGenerator getGenerator() { public IWaveform getGenerator() {
return loader.txGenerators.get(loader.getScvTx(id).generatorId); return loader.txGenerators.get(generatorId);
} }
/** /**
@ -173,8 +181,11 @@ class Tx implements ITx {
*/ */
@Override @Override
public Long getBeginTime() { public Long getBeginTime() {
if (beginTime < 0) if (beginTime < 0) {
beginTime = loader.getScvTx(id).beginTime; ScvTx tx = scvTx==null?loader.getScvTx(id):getScvTx();
beginTime = tx.beginTime;
endTime = tx.endTime;
}
return beginTime; return beginTime;
} }
@ -185,8 +196,11 @@ class Tx implements ITx {
*/ */
@Override @Override
public Long getEndTime() { public Long getEndTime() {
if (endTime < 0) if (endTime < 0) {
endTime = loader.getScvTx(id).endTime; ScvTx tx = scvTx==null?loader.getScvTx(id):getScvTx();
beginTime = tx.beginTime;
endTime = tx.endTime;
}
return endTime; return endTime;
} }
@ -196,26 +210,7 @@ class Tx implements ITx {
* @param time the new end time * @param time the new end time
*/ */
void setEndTime(Long time) { void setEndTime(Long time) {
loader.getScvTx(id).endTime = time; getScvTx().endTime = time;
}
/**
* Gets the concurrency index.
*
* @return the concurrency index
*/
@Override
public int getConcurrencyIndex() {
return concurrencyIndex;
}
/**
* Sets the concurrency index.
*
* @param idx the new concurrency index
*/
void setConcurrencyIndex(int idx) {
concurrencyIndex = idx;
} }
/** /**
@ -225,7 +220,12 @@ class Tx implements ITx {
*/ */
@Override @Override
public List<ITxAttribute> getAttributes() { public List<ITxAttribute> getAttributes() {
return loader.getScvTx(id).attributes; return getScvTx().attributes;
} }
private ScvTx getScvTx() {
if(scvTx==null)
scvTx=loader.getScvTx(id);
return scvTx;
}
} }

View File

@ -32,6 +32,7 @@ class TxEvent implements ITxEvent {
/** The time. */ /** The time. */
final long time; final long time;
private int concurrencyIdx=-1;
/** /**
* Instantiates a new tx event. * Instantiates a new tx event.
* *
@ -107,4 +108,13 @@ class TxEvent implements ITxEvent {
public ITx getTransaction() { public ITx getTransaction() {
return loader.getTransaction(transaction); return loader.getTransaction(transaction);
} }
@Override
public int getRowIndex() {
return concurrencyIdx;
}
public void setConcurrencyIndex(int idx) {
concurrencyIdx=idx;
}
} }

View File

@ -15,12 +15,11 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import com.minres.scviewer.database.IWaveform; import com.minres.scviewer.database.IWaveform;
import com.minres.scviewer.database.tx.ITxGenerator;
/** /**
* The Class TxGenerator. * The Class TxGenerator.
*/ */
class TxGenerator extends AbstractTxStream implements ITxGenerator { class TxGenerator extends AbstractTxStream {
/** The stream. */ /** The stream. */
TxStream stream; TxStream stream;
@ -45,16 +44,6 @@ class TxGenerator extends AbstractTxStream implements ITxGenerator {
stream.addChild(this); stream.addChild(this);
} }
/**
* Gets the stream.
*
* @return the stream
*/
@Override
public IWaveform getStream() {
return stream;
}
/** /**
* Checks if is same. * Checks if is same.
* *
@ -94,13 +83,4 @@ class TxGenerator extends AbstractTxStream implements ITxGenerator {
return stream.getKind(); return stream.getKind();
} }
/**
* Gets the width.
*
* @return the width
*/
@Override
public int getWidth() {
return stream.getWidth();
}
} }

View File

@ -55,40 +55,4 @@ class TxStream extends AbstractTxStream {
return kind; return kind;
} }
/** The max concurrency. */
private int maxConcurrency = 0;
/** The concurrency. */
private int concurrency = 0;
/**
* Sets the concurrency.
*
* @param concurrency the new concurrency
*/
void setConcurrency(int concurrency) {
this.concurrency = concurrency;
if (concurrency > maxConcurrency)
maxConcurrency = concurrency;
}
/**
* Gets the concurrency.
*
* @return the concurrency
*/
int getConcurrency() {
return this.concurrency;
}
/**
* Gets the width.
*
* @return the width
*/
@Override
public int getWidth() {
return maxConcurrency;
}
} }

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>com.minres.scviewer</groupId> <groupId>com.minres.scviewer</groupId>
<artifactId>com.minres.scviewer.parent</artifactId> <artifactId>com.minres.scviewer.parent</artifactId>
<version>2.11.2-SNAPSHOT</version> <version>2.12.0-SNAPSHOT</version>
<relativePath>../..</relativePath> <relativePath>../..</relativePath>
</parent> </parent>
<version>3.0.0-SNAPSHOT</version> <version>3.0.0-SNAPSHOT</version>

View File

@ -10,9 +10,11 @@
*******************************************************************************/ *******************************************************************************/
package com.minres.scviewer.database.ui.swt.internal; package com.minres.scviewer.database.ui.swt.internal;
import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Optional;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Color;
@ -21,8 +23,12 @@ import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Display;
import com.minres.scviewer.database.IEvent;
import com.minres.scviewer.database.IHierNode;
import com.minres.scviewer.database.IWaveform;
import com.minres.scviewer.database.RelationType; import com.minres.scviewer.database.RelationType;
import com.minres.scviewer.database.tx.ITx; 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.tx.ITxRelation;
import com.minres.scviewer.database.ui.WaveformColors; import com.minres.scviewer.database.ui.WaveformColors;
@ -78,6 +84,12 @@ public class ArrowPainter implements IPainter {
} }
} }
private int getConcurrencyIndex(ITx tx) {
IEvent[] eventList = tx.getStream().getEvents().floorEntry(tx.getBeginTime()).getValue();
Optional<Integer> res = Arrays.stream(eventList).map(e -> ((ITxEvent)e).getRowIndex()).findFirst();
return res.isPresent()? res.get():0;
}
protected void calculateGeometries() { protected void calculateGeometries() {
deferUpdate = false; deferUpdate = false;
iRect.clear(); iRect.clear();
@ -88,9 +100,9 @@ public class ArrowPainter implements IPainter {
deferUpdate = true; deferUpdate = true;
return; return;
} }
int laneHeight = painter.getHeight() / tx.getStream().getWidth(); int laneHeight = painter.getHeight() / tx.getStream().getRowCount();
txRectangle = new Rectangle((int) (tx.getBeginTime() / scaleFactor), txRectangle = new Rectangle((int) (tx.getBeginTime() / scaleFactor),
waveCanvas.rulerHeight + painter.getVerticalOffset() + laneHeight * tx.getConcurrencyIndex(), waveCanvas.rulerHeight + painter.getVerticalOffset() + laneHeight * getConcurrencyIndex(tx),
(int) ((tx.getEndTime() - tx.getBeginTime()) / scaleFactor), laneHeight); (int) ((tx.getEndTime() - tx.getBeginTime()) / scaleFactor), laneHeight);
deriveGeom(tx.getIncomingRelations(), iRect, false); deriveGeom(tx.getIncomingRelations(), iRect, false);
deriveGeom(tx.getOutgoingRelations(), oRect, true); deriveGeom(tx.getOutgoingRelations(), oRect, true);
@ -99,19 +111,48 @@ public class ArrowPainter implements IPainter {
protected void deriveGeom(Collection<ITxRelation> relations, List<LinkEntry> res, boolean useTarget) { protected void deriveGeom(Collection<ITxRelation> relations, List<LinkEntry> res, boolean useTarget) {
for (ITxRelation iTxRelation : relations) { for (ITxRelation iTxRelation : relations) {
ITx otherTx = useTarget ? iTxRelation.getTarget() : iTxRelation.getSource(); ITx otherTx = useTarget ? iTxRelation.getTarget() : iTxRelation.getSource();
if (waveCanvas.wave2painterMap.containsKey(otherTx.getStream())) { Rectangle bb = createLinkEntry(otherTx, otherTx.getStream());
IWaveformPainter painter = waveCanvas.wave2painterMap.get(otherTx.getStream()); if(bb!=null){
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())); res.add(new LinkEntry(bb, iTxRelation.getRelationType()));
return;
} else {
for(IHierNode gen:otherTx.getStream().getChildNodes()) {
if(gen instanceof IWaveform) {
bb = createLinkEntry(otherTx, (IWaveform) gen);
if(bb!=null){
res.add(new LinkEntry(bb, iTxRelation.getRelationType()));
return;
}
}
}
} }
} }
} }
private Rectangle createLinkEntry(ITx otherTx, IWaveform iWaveform) {
if (waveCanvas.wave2painterMap.containsKey(iWaveform)) {
IWaveformPainter painter = waveCanvas.wave2painterMap.get(otherTx.getStream());
if(painter==null) {
for(IHierNode gen:otherTx.getStream().getChildNodes()) {
if(gen instanceof IWaveform) {
painter = waveCanvas.wave2painterMap.get(gen);
if(painter!=null)
break;
}
}
}
if(painter!=null) {
int height = waveCanvas.styleProvider.getTrackHeight();
return new Rectangle(
(int) (otherTx.getBeginTime() / scaleFactor),
waveCanvas.rulerHeight + painter.getVerticalOffset() + height * getConcurrencyIndex(otherTx),
(int) ((otherTx.getEndTime() - otherTx.getBeginTime()) / scaleFactor),
height);
}
}
return null;
}
@Override @Override
public void paintArea(Projection proj, Rectangle clientRect) { public void paintArea(Projection proj, Rectangle clientRect) {
yCtrlOffset = waveCanvas.styleProvider.getTrackHeight()/2; yCtrlOffset = waveCanvas.styleProvider.getTrackHeight()/2;

View File

@ -10,10 +10,9 @@
*******************************************************************************/ *******************************************************************************/
package com.minres.scviewer.database.ui.swt.internal; package com.minres.scviewer.database.ui.swt.internal;
import java.util.Collection;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.NavigableMap; import java.util.NavigableMap;
import java.util.TreeSet; import java.util.TreeMap;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Color;
@ -37,19 +36,18 @@ public class StreamPainter extends TrackPainter{
private IWaveform stream; private IWaveform stream;
private int txBase; private int txBase;
private int txHeight; private int txHeight;
private TreeSet<ITx> seenTx; private TreeMap<ITx, ITxEvent> seenTx;
public StreamPainter(WaveformCanvas waveCanvas, boolean even, TrackEntry trackEntry) { public StreamPainter(WaveformCanvas waveCanvas, boolean even, TrackEntry trackEntry) {
super(trackEntry, even); super(trackEntry, even);
this.waveCanvas = waveCanvas; this.waveCanvas = waveCanvas;
this.stream=trackEntry.waveform; this.stream=trackEntry.waveform;
this.seenTx=new TreeSet<>(); this.seenTx=new TreeMap<>();
} }
@SuppressWarnings("unchecked")
public void paintArea(Projection proj, Rectangle area) { public void paintArea(Projection proj, Rectangle area) {
if(stream.getEvents().size()==0) return; if(stream.getEvents().size()==0) return;
int trackHeight=trackEntry.height/stream.getWidth(); int trackHeight=trackEntry.height/stream.getRowCount();
txBase=trackHeight/5; txBase=trackHeight/5;
txHeight=trackHeight*3/5; txHeight=trackHeight*3/5;
if(trackEntry.selected) { if(trackEntry.selected) {
@ -65,8 +63,8 @@ public class StreamPainter extends TrackPainter{
long beginTime = beginPos*scaleFactor; long beginTime = beginPos*scaleFactor;
long endTime = beginTime + area.width*scaleFactor; long endTime = beginTime + area.width*scaleFactor;
Entry<Long, ?> firstTx=stream.getEvents().floorEntry(beginTime); Entry<Long, IEvent[]> firstTx=stream.getEvents().floorEntry(beginTime);
Entry<Long, ?> lastTx=stream.getEvents().ceilingEntry(endTime); Entry<Long, IEvent[]> lastTx=stream.getEvents().ceilingEntry(endTime);
if(firstTx==null) firstTx = stream.getEvents().firstEntry(); if(firstTx==null) firstTx = stream.getEvents().firstEntry();
if(lastTx==null) lastTx=stream.getEvents().lastEntry(); if(lastTx==null) lastTx=stream.getEvents().lastEntry();
proj.setFillRule(SWT.FILL_EVEN_ODD); proj.setFillRule(SWT.FILL_EVEN_ODD);
@ -77,46 +75,51 @@ public class StreamPainter extends TrackPainter{
for( int y1=area.y+trackHeight/2; y1<area.y+trackEntry.height; y1+=trackHeight) 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.drawLine(area.x, y1, area.x+area.width, y1);
if(firstTx==lastTx) { if(firstTx==lastTx) {
for(ITxEvent txEvent:(Collection<? extends ITxEvent>)firstTx.getValue()) for(IEvent txEvent: firstTx.getValue())
drawTx(proj, area, txEvent.getTransaction(), false); drawTx(proj, area, ((ITxEvent)txEvent).getTransaction(), ((ITxEvent)txEvent).getRowIndex(), false);
}else{ }else{
seenTx.clear(); seenTx.clear();
NavigableMap<Long, IEvent[]> 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; ITxEvent highlighed=null;
proj.setForeground(this.waveCanvas.styleProvider.getColor(WaveformColors.LINE)); proj.setForeground(this.waveCanvas.styleProvider.getColor(WaveformColors.LINE));
long selectedId=waveCanvas.currentSelection!=null? waveCanvas.currentSelection.getId():-1; long selectedId=waveCanvas.currentSelection!=null? waveCanvas.currentSelection.getId():-1;
for(Entry<Long, IEvent[]> entry: entries.entrySet()) for(Entry<Long, IEvent[]> entry: entries.entrySet())
for(IEvent evt:entry.getValue()){ for(IEvent e:entry.getValue()){
ITx tx = ((ITxEvent) evt).getTransaction(); ITxEvent evt = (ITxEvent) e;
highlighed|=selectedId==tx.getId(); ITx tx = evt.getTransaction();
if(selectedId==tx.getId())
highlighed=evt;
switch(evt.getKind()) { switch(evt.getKind()) {
case BEGIN: case BEGIN:
seenTx.add(tx); seenTx.put(tx, evt);
break; break;
case END: case END:
drawTx(proj, area, tx, evt.getRowIndex(), false);
seenTx.remove(tx); seenTx.remove(tx);
break;
case SINGLE: case SINGLE:
drawTx(proj, area, tx, false); drawTx(proj, area, tx, evt.getRowIndex(), false);
break; break;
} }
} }
for(ITx tx:seenTx){ seenTx.entrySet().stream().forEach(e -> {
drawTx(proj, area, tx, false); drawTx(proj, area, e.getKey(), e.getValue().getRowIndex(), false);
} });
if(highlighed){
if(highlighed!=null){
proj.setForeground(this.waveCanvas.styleProvider.getColor(WaveformColors.LINE_HIGHLITE)); proj.setForeground(this.waveCanvas.styleProvider.getColor(WaveformColors.LINE_HIGHLITE));
drawTx(proj, area, waveCanvas.currentSelection, true); drawTx(proj, area, highlighed.getTransaction(), highlighed.getRowIndex(), true);
} }
} }
} }
protected void drawTx(Projection proj, Rectangle area, ITx tx, boolean highlighted ) { protected void drawTx(Projection proj, Rectangle area, ITx tx, int concurrencyIndex, boolean highlighted ) {
// compute colors // compute colors
Color[] transColor = waveCanvas.styleProvider.computeColor( tx.getGenerator().getName()); Color[] transColor = waveCanvas.styleProvider.computeColor( tx.getGenerator().getName());
proj.setBackground(transColor[highlighted?1:0]); proj.setBackground(transColor[highlighted?1:0]);
int offset = tx.getConcurrencyIndex()*this.waveCanvas.styleProvider.getTrackHeight(); int offset = concurrencyIndex*this.waveCanvas.styleProvider.getTrackHeight();
Rectangle bb = new Rectangle( Rectangle bb = new Rectangle(
(int)(tx.getBeginTime()/this.waveCanvas.getScaleFactor()), area.y+offset+txBase, (int)(tx.getBeginTime()/this.waveCanvas.getScaleFactor()), area.y+offset+txBase,
(int)((tx.getEndTime()-tx.getBeginTime())/this.waveCanvas.getScaleFactor()), txHeight); (int)((tx.getEndTime()-tx.getBeginTime())/this.waveCanvas.getScaleFactor()), txHeight);
@ -164,24 +167,18 @@ public class StreamPainter extends TrackPainter{
protected ITx getTxFromEntry(int lane, int offset, Entry<Long, IEvent[]> firstTx) { protected ITx getTxFromEntry(int lane, int offset, Entry<Long, IEvent[]> firstTx) {
long timePoint=offset*waveCanvas.getScaleFactor(); long timePoint=offset*waveCanvas.getScaleFactor();
for(IEvent evt:firstTx.getValue()){ long timePointLow=(offset-5)*waveCanvas.getScaleFactor();
if(evt instanceof ITxEvent) {
ITx tx=((ITxEvent)evt).getTransaction();
if((evt.getKind()==EventKind.BEGIN || evt.getKind()==EventKind.SINGLE)&&
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(); long timePointHigh=(offset+5)*waveCanvas.getScaleFactor();
for(IEvent evt:firstTx.getValue()){ for(IEvent e:firstTx.getValue()){
if(evt instanceof ITxEvent) { if(e instanceof ITxEvent) {
ITx tx=((ITxEvent)evt).getTransaction(); ITxEvent evt = (ITxEvent) e;
if((evt.getKind()==EventKind.BEGIN || evt.getKind()==EventKind.SINGLE) && ITx tx=evt.getTransaction();
tx.getConcurrencyIndex()==lane && tx.getBeginTime()<=timePointHigh && tx.getEndTime()>=timePoint){ if(
return ((ITxEvent)evt).getTransaction(); (evt.getKind()==EventKind.SINGLE && evt.getTime()==timePoint) ||
(evt.getKind()==EventKind.SINGLE && evt.getTime()>timePointLow && evt.getTime()<timePointHigh) ||
(evt.getKind()==EventKind.BEGIN && evt.getRowIndex()==lane && evt.getTime()<=timePoint && tx.getEndTime()>=timePoint)
){
return tx;
} }
} }
} }

View File

@ -11,10 +11,12 @@
package com.minres.scviewer.database.ui.swt.internal; package com.minres.scviewer.database.ui.swt.internal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Optional;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ControlAdapter; import org.eclipse.swt.events.ControlAdapter;
@ -32,9 +34,11 @@ import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.ScrollBar; import org.eclipse.swt.widgets.ScrollBar;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.minres.scviewer.database.IEvent;
import com.minres.scviewer.database.IWaveform; import com.minres.scviewer.database.IWaveform;
import com.minres.scviewer.database.RelationType; import com.minres.scviewer.database.RelationType;
import com.minres.scviewer.database.tx.ITx; import com.minres.scviewer.database.tx.ITx;
import com.minres.scviewer.database.tx.ITxEvent;
import com.minres.scviewer.database.ui.IWaveformStyleProvider; import com.minres.scviewer.database.ui.IWaveformStyleProvider;
import com.minres.scviewer.database.ui.IWaveformView; import com.minres.scviewer.database.ui.IWaveformView;
import com.minres.scviewer.database.ui.TrackEntry; import com.minres.scviewer.database.ui.TrackEntry;
@ -424,13 +428,17 @@ public class WaveformCanvas extends Canvas {
} }
for (IWaveformPainter painter : wave2painterMap.values()) { for (IWaveformPainter painter : wave2painterMap.values()) {
if (painter instanceof StreamPainter && ((StreamPainter) painter).getStream() == tx.getStream()) { if (painter instanceof StreamPainter && ((StreamPainter) painter).getStream() == tx.getStream()) {
int top = painter.getVerticalOffset() + styleProvider.getTrackHeight() * tx.getConcurrencyIndex(); Entry<Long, IEvent[]> entry = tx.getStream().getEvents().floorEntry(tx.getBeginTime());
int bottom = top + styleProvider.getTrackHeight(); Optional<IEvent> res = Arrays.stream(entry.getValue()).filter(e -> ((ITxEvent)e).getTransaction().equals(tx)).findFirst();
if (top < -origin.y) { if(res.isPresent()) {
setOrigin(origin.x, -(top-styleProvider.getTrackHeight())); int top = painter.getVerticalOffset() + styleProvider.getTrackHeight() * ((ITxEvent)res.get()).getRowIndex();
} else if (bottom > (size.y - origin.y)) { int bottom = top + styleProvider.getTrackHeight();
setOrigin(origin.x, size.y - bottom); if (top < -origin.y) {
} setOrigin(origin.x, -(top-styleProvider.getTrackHeight()));
} else if (bottom > (size.y - origin.y)) {
setOrigin(origin.x, size.y - bottom);
}
}
} }
} }
} }

View File

@ -514,7 +514,7 @@ public class WaveformView implements IWaveformView {
streamEntry.vOffset = tracksVerticalHeight; streamEntry.vOffset = tracksVerticalHeight;
if (streamEntry.waveform.getType() == WaveformType.TRANSACTION) { if (streamEntry.waveform.getType() == WaveformType.TRANSACTION) {
streamEntry.currentValue = ""; streamEntry.currentValue = "";
streamEntry.height *= streamEntry.waveform.getWidth(); streamEntry.height *= streamEntry.waveform.getRowCount();
painter = new StreamPainter(waveformCanvas, even, streamEntry); painter = new StreamPainter(waveformCanvas, even, streamEntry);
} else if (streamEntry.waveform.getType() == WaveformType.SIGNAL) { } else if (streamEntry.waveform.getType() == WaveformType.SIGNAL) {
streamEntry.currentValue = "---"; streamEntry.currentValue = "---";
@ -579,17 +579,18 @@ public class WaveformView implements IWaveformView {
entry.currentValue = Double.toString(val); entry.currentValue = Double.toString(val);
} }
} else if (entry.waveform.getType() == WaveformType.TRANSACTION) { } else if (entry.waveform.getType() == WaveformType.TRANSACTION) {
ITx[] resultsList = new ITx[entry.waveform.getWidth()]; ITx[] resultsList = new ITx[entry.waveform.getRowCount()];
Entry<Long, IEvent[]> firstTx = entry.waveform.getEvents().floorEntry(time); Entry<Long, IEvent[]> firstTx = entry.waveform.getEvents().floorEntry(time);
if (firstTx != null) { if (firstTx != null) {
do { do {
for (IEvent evt : firstTx.getValue()) { for (IEvent e : firstTx.getValue()) {
if (evt instanceof ITxEvent) { if (e instanceof ITxEvent) {
ITx tx = ((ITxEvent) evt).getTransaction(); ITxEvent evt = ((ITxEvent) e);
ITx tx = evt.getTransaction();
if ((evt.getKind() == EventKind.BEGIN || evt.getKind() == EventKind.SINGLE) if ((evt.getKind() == EventKind.BEGIN || evt.getKind() == EventKind.SINGLE)
&& tx.getBeginTime() <= time && tx.getEndTime() >= time && tx.getBeginTime() <= time && tx.getEndTime() >= time
&& resultsList[tx.getConcurrencyIndex()] == null) && resultsList[evt.getRowIndex()] == null)
resultsList[tx.getConcurrencyIndex()] = ((ITxEvent) evt).getTransaction(); resultsList[evt.getRowIndex()] = evt.getTransaction();
} }
} }
firstTx = entry.waveform.getEvents().lowerEntry(firstTx.getKey()); firstTx = entry.waveform.getEvents().lowerEntry(firstTx.getKey());
@ -1036,7 +1037,7 @@ public class WaveformView implements IWaveformView {
TrackEntry trackEntry = trackVerticalOffset.get(firstKey); TrackEntry trackEntry = trackVerticalOffset.get(firstKey);
IWaveform w = trackEntry.waveform; IWaveform w = trackEntry.waveform;
if (w.getType() == WaveformType.TRANSACTION) if (w.getType() == WaveformType.TRANSACTION)
subArea.height *= w.getWidth(); subArea.height *= w.getRowCount();
drawTextFormat(gc, subArea, firstKey, w.getFullName(), trackEntry.selected); drawTextFormat(gc, subArea, firstKey, w.getFullName(), trackEntry.selected);
} else { } else {
for (Entry<Integer, TrackEntry> entry : trackVerticalOffset.subMap(firstKey, true, lastKey, true) for (Entry<Integer, TrackEntry> entry : trackVerticalOffset.subMap(firstKey, true, lastKey, true)
@ -1044,7 +1045,7 @@ public class WaveformView implements IWaveformView {
IWaveform w = entry.getValue().waveform; IWaveform w = entry.getValue().waveform;
subArea.height = styleProvider.getTrackHeight(); subArea.height = styleProvider.getTrackHeight();
if (w.getType() == WaveformType.TRANSACTION) if (w.getType() == WaveformType.TRANSACTION)
subArea.height *= w.getWidth(); subArea.height *= w.getRowCount();
drawTextFormat(gc, subArea, entry.getKey(), w.getFullName(), entry.getValue().selected); drawTextFormat(gc, subArea, entry.getKey(), w.getFullName(), entry.getValue().selected);
} }
} }
@ -1065,7 +1066,7 @@ public class WaveformView implements IWaveformView {
TrackEntry trackEntry = trackVerticalOffset.get(firstKey); TrackEntry trackEntry = trackVerticalOffset.get(firstKey);
IWaveform w = trackEntry.waveform; IWaveform w = trackEntry.waveform;
if (w.getType() == WaveformType.TRANSACTION) if (w.getType() == WaveformType.TRANSACTION)
subArea.height *= w.getWidth(); subArea.height *= w.getRowCount();
drawValue(gc, subArea, firstKey, trackEntry.currentValue, trackEntry.selected); drawValue(gc, subArea, firstKey, trackEntry.currentValue, trackEntry.selected);
} else { } else {
for (Entry<Integer, TrackEntry> entry : trackVerticalOffset.subMap(firstKey, true, lastKey, true) for (Entry<Integer, TrackEntry> entry : trackVerticalOffset.subMap(firstKey, true, lastKey, true)
@ -1073,7 +1074,7 @@ public class WaveformView implements IWaveformView {
IWaveform w = entry.getValue().waveform; IWaveform w = entry.getValue().waveform;
subArea.height = styleProvider.getTrackHeight(); subArea.height = styleProvider.getTrackHeight();
if (w.getType() == WaveformType.TRANSACTION) if (w.getType() == WaveformType.TRANSACTION)
subArea.height *= w.getWidth(); subArea.height *= w.getRowCount();
drawValue(gc, subArea, entry.getKey(), entry.getValue().currentValue, drawValue(gc, subArea, entry.getKey(), entry.getValue().currentValue,
entry.getValue().selected); entry.getValue().selected);
} }

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>com.minres.scviewer</groupId> <groupId>com.minres.scviewer</groupId>
<artifactId>com.minres.scviewer.parent</artifactId> <artifactId>com.minres.scviewer.parent</artifactId>
<version>2.11.2-SNAPSHOT</version> <version>2.12.0-SNAPSHOT</version>
<relativePath>../..</relativePath> <relativePath>../..</relativePath>
</parent> </parent>
<packaging>eclipse-plugin</packaging> <packaging>eclipse-plugin</packaging>

View File

@ -204,7 +204,7 @@ public class VCDDbLoader implements IWaveformDbLoader, IVCDDatabaseBuilder {
@Override @Override
public int getNetWidth(int intValue) { public int getNetWidth(int intValue) {
VCDSignal<?> signal = (VCDSignal<?>) signals.get(intValue); VCDSignal<?> signal = (VCDSignal<?>) signals.get(intValue);
return signal.getWidth(); return signal.getRowCount();
} }
/* (non-Javadoc) /* (non-Javadoc)

View File

@ -109,7 +109,7 @@ public class VCDSignal<T extends IEvent> extends HierNode implements IWaveform {
} }
@Override @Override
public int getWidth() { public int getRowCount() {
return width; return width;
} }

View File

@ -4,7 +4,7 @@
<parent> <parent>
<groupId>com.minres.scviewer</groupId> <groupId>com.minres.scviewer</groupId>
<artifactId>com.minres.scviewer.parent</artifactId> <artifactId>com.minres.scviewer.parent</artifactId>
<version>2.11.2-SNAPSHOT</version> <version>2.12.0-SNAPSHOT</version>
<relativePath>../..</relativePath> <relativePath>../..</relativePath>
</parent> </parent>
<packaging>eclipse-plugin</packaging> <packaging>eclipse-plugin</packaging>

View File

@ -12,6 +12,7 @@ package com.minres.scviewer.database;
import java.util.NavigableMap; import java.util.NavigableMap;
// TODO: Auto-generated Javadoc
/** /**
* The Interface IWaveform. * The Interface IWaveform.
* *
@ -76,6 +77,6 @@ public interface IWaveform extends IHierNode {
* *
* @return the width * @return the width
*/ */
public int getWidth(); public int getRowCount();
} }

View File

@ -123,31 +123,31 @@ public class WaveformDb extends HierNode implements IWaveformDb, PropertyChangeL
*/ */
@Override @Override
public boolean load(File inp) { public boolean load(File inp) {
boolean retval = true;
for (IWaveformDbLoader loader : loaders) { for (IWaveformDbLoader loader : loaders) {
if (loader.canLoad(inp)) { if (loader.canLoad(inp)) {
loader.addPropertyChangeListener(this);
try { try {
loader.addPropertyChangeListener(this);
loader.load(this, inp); loader.load(this, inp);
loader.removePropertyChangeListener(this);
for (IWaveform w : loader.getAllWaves()) {
waveforms.put(w.getFullName(), w);
}
if (loader.getMaxTime() > maxTime) {
maxTime = loader.getMaxTime();
}
if (name == null)
name = getFileBasename(inp.getName());
buildHierarchyNodes();
relationTypes.addAll(loader.getAllRelationTypes());
pcs.firePropertyChange(IHierNode.LOADING_FINISHED, null, null);
loaded = true;
return true;
} catch (Exception e) { } catch (Exception e) {
return false; retval=false;
} }
loader.removePropertyChangeListener(this);
for (IWaveform w : loader.getAllWaves()) {
waveforms.put(w.getFullName(), w);
}
if (loader.getMaxTime() > maxTime) {
maxTime = loader.getMaxTime();
}
if (name == null)
name = getFileBasename(inp.getName());
buildHierarchyNodes();
relationTypes.addAll(loader.getAllRelationTypes());
} }
} }
return false; pcs.firePropertyChange(IHierNode.LOADING_FINISHED, null, null);
loaded = true;
return retval;
} }
/** /**

View File

@ -39,7 +39,7 @@ public interface ITx extends Comparable<ITx> {
* *
* @return the generator * @return the generator
*/ */
public ITxGenerator getGenerator(); public IWaveform getGenerator();
/** /**
* Gets the begin time. * Gets the begin time.
@ -55,13 +55,6 @@ public interface ITx extends Comparable<ITx> {
*/ */
public Long getEndTime(); public Long getEndTime();
/**
* Gets the concurrency index.
*
* @return the concurrency index
*/
public int getConcurrencyIndex();
/** /**
* Gets the attributes. * Gets the attributes.
* *

View File

@ -30,4 +30,12 @@ public interface ITxEvent extends IEvent {
* @return the transaction * @return the transaction
*/ */
public ITx getTransaction(); public ITx getTransaction();
/**
* Gets the concurrency index.
*
* @return the concurrency index
*/
public int getRowIndex();
} }

View File

@ -1,27 +0,0 @@
/*******************************************************************************
* Copyright (c) 2015-2021 MINRES Technologies GmbH and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/
package com.minres.scviewer.database.tx;
import com.minres.scviewer.database.IWaveform;
/**
* The Interface ITxGenerator.
*/
public interface ITxGenerator extends IWaveform {
/**
* Gets the stream.
*
* @return the stream
*/
public IWaveform getStream();
}

View File

@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2 Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name Bundle-Name: %Bundle-Name
Bundle-SymbolicName: com.minres.scviewer.e4.application;singleton:=true Bundle-SymbolicName: com.minres.scviewer.e4.application;singleton:=true
Bundle-Version: 2.11.2.qualifier Bundle-Version: 2.12.0.qualifier
Bundle-Vendor: %Bundle-Vendor Bundle-Vendor: %Bundle-Vendor
Require-Bundle: javax.inject;bundle-version="1.0.0", Require-Bundle: javax.inject;bundle-version="1.0.0",
org.eclipse.core.runtime;bundle-version="3.11.1", org.eclipse.core.runtime;bundle-version="3.11.1",

Binary file not shown.

After

Width:  |  Height:  |  Size: 700 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 444 B

After

Width:  |  Height:  |  Size: 536 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 688 B

View File

@ -3,11 +3,10 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 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> <modelVersion>4.0.0</modelVersion>
<artifactId>com.minres.scviewer.e4.application</artifactId> <artifactId>com.minres.scviewer.e4.application</artifactId>
<version>2.11.2-SNAPSHOT</version>
<parent> <parent>
<groupId>com.minres.scviewer</groupId> <groupId>com.minres.scviewer</groupId>
<artifactId>com.minres.scviewer.parent</artifactId> <artifactId>com.minres.scviewer.parent</artifactId>
<version>2.11.2-SNAPSHOT</version> <version>2.12.0-SNAPSHOT</version>
<relativePath>../..</relativePath> <relativePath>../..</relativePath>
</parent> </parent>
<packaging>eclipse-plugin</packaging> <packaging>eclipse-plugin</packaging>

View File

@ -482,6 +482,7 @@ public class HeapStatus extends Composite {
}); });
} }
}; };
t.setDaemon(true);
t.start(); t.start();
} }

View File

@ -206,7 +206,7 @@ public class DesignBrowser {
updateButtons(); updateButtons();
} }
}); });
treeViewer.setLabelProvider(new TxDbLabelProvider()); treeViewer.setLabelProvider(new TxDbLabelProvider(true));
treeViewer.addFilter(treeAttributeFilter); treeViewer.addFilter(treeAttributeFilter);
treeViewer.setUseHashlookup(true); treeViewer.setUseHashlookup(true);
treeViewer.setAutoExpandLevel(2); treeViewer.setAutoExpandLevel(2);
@ -252,7 +252,7 @@ public class DesignBrowser {
updateButtons(); updateButtons();
} }
}); });
txTableViewer.setLabelProvider(new TxDbLabelProvider()); txTableViewer.setLabelProvider(new TxDbLabelProvider(false));
txTableViewer.getTable().setLayoutData(new GridData(GridData.FILL_BOTH)); txTableViewer.getTable().setLayoutData(new GridData(GridData.FILL_BOTH));
txTableViewer.addFilter(tableAttributeFilter); txTableViewer.addFilter(tableAttributeFilter);
txTableViewer.addDoubleClickListener(event -> { txTableViewer.addDoubleClickListener(event -> {

View File

@ -37,7 +37,6 @@ import com.minres.scviewer.database.IEvent;
import com.minres.scviewer.database.IWaveform; import com.minres.scviewer.database.IWaveform;
import com.minres.scviewer.database.WaveformType; import com.minres.scviewer.database.WaveformType;
import com.minres.scviewer.database.tx.ITx; 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.ITxEvent;
import com.minres.scviewer.database.ui.TrackEntry; import com.minres.scviewer.database.ui.TrackEntry;
import com.minres.scviewer.e4.application.parts.txTableTree.AbstractTransactionTreeContentProvider; import com.minres.scviewer.e4.application.parts.txTableTree.AbstractTransactionTreeContentProvider;
@ -78,6 +77,8 @@ public class TransactionList extends Composite {
private TableViewer tableViewer = null; private TableViewer tableViewer = null;
Thread updateThread = null;
private TableColumn valueColumn = null; private TableColumn valueColumn = null;
private AttributeLabelProvider valueLabelProvider = null; private AttributeLabelProvider valueLabelProvider = null;
@ -86,8 +87,6 @@ public class TransactionList extends Composite {
private ObservableList<AttributeNameBean> attrNames = new WritableList<>(); private ObservableList<AttributeNameBean> attrNames = new WritableList<>();
private List<ITx> eventList = new ArrayList<>();
private List<ITx> emptyList = new ArrayList<>(); private List<ITx> emptyList = new ArrayList<>();
TxFilter txFilter; TxFilter txFilter;
@ -244,56 +243,48 @@ public class TransactionList extends Composite {
} else if(stream != trackEntry.waveform) { } else if(stream != trackEntry.waveform) {
stream=trackEntry.waveform; stream=trackEntry.waveform;
tableViewer.setInput(emptyList); tableViewer.setInput(emptyList);
new Thread() { try{
private ConcurrentHashMap<String, DataType> propNames=new ConcurrentHashMap<>(); if(updateThread!=null)
updateThread.interrupt();
private List<AttributeNameBean> getEntries() { }catch(SecurityException e){}
return propNames.entrySet().stream() updateThread = new Thread(()-> {
.sorted((e1,e2)->e1.getKey().compareTo(e2.getKey())) final ConcurrentHashMap<String, DataType> propNames=new ConcurrentHashMap<>();
.map(e -> new AttributeNameBean(e.getKey(), e.getValue())) Collection<IEvent[]> values = stream.getEvents().values();
.collect(Collectors.toList()); final List<ITx> txList = values.parallelStream().map(Arrays::asList)
} .flatMap(List::stream)
.filter(evt -> evt.getKind()==EventKind.BEGIN || evt.getKind()==EventKind.SINGLE)
@Override .map(evt-> {
public void run() { ITx tx = ((ITxEvent)evt).getTransaction();
Collection<IEvent[]> values = stream.getEvents().values(); tx.getAttributes().forEach(attr -> propNames.put(attr.getName(), attr.getDataType()));
eventList = values.parallelStream().map(Arrays::asList) return tx;
.flatMap(List::stream) })
.filter(evt -> evt.getKind()==EventKind.BEGIN || evt.getKind()==EventKind.SINGLE) .sorted((t1, t2)-> t1.getBeginTime().compareTo(t2.getBeginTime()))
.map(evt-> { .collect(Collectors.toList());
ITx tx = ((ITxEvent)evt).getTransaction(); final List<AttributeNameBean> newAttrNames=propNames.entrySet().stream()
for(ITxAttribute attr: tx.getAttributes()) { .sorted((e1,e2)->e1.getKey().compareTo(e2.getKey()))
propNames.put(attr.getName(), attr.getDataType()); .map(e -> new AttributeNameBean(e.getKey(), e.getValue()))
} .collect(Collectors.toList());
return tx; getDisplay().asyncExec(() -> {
}) tableViewer.setInput(txList);
.sorted((t1, t2)-> t1.getBeginTime().compareTo(t2.getBeginTime())) attrNames.clear();
.collect(Collectors.toList()); attrNames.addAll(newAttrNames);
getDisplay().asyncExec(new Runnable() { if(!attrNames.isEmpty())
@Override txFilter.setSearchProp(attrNames.get(0).getName(), attrNames.get(0).getType());
public void run() { if (searchPropComboViewer!=null)
tableViewer.setInput(eventList); searchPropComboViewer.refresh();
attrNames.clear(); if (viewPropComboViewer!=null)
attrNames.addAll(getEntries()); viewPropComboViewer.refresh();
if(!attrNames.isEmpty()) });
txFilter.setSearchProp(attrNames.get(0).getName(), attrNames.get(0).getType()); updateThread=null;
if (searchPropComboViewer!=null) { });
searchPropComboViewer.setInput(attrNames); updateThread.start();
Object sel = searchPropComboViewer.getElementAt(0);
if(sel!=null) searchPropComboViewer.setSelection(new StructuredSelection(sel));
}
tableViewer.refresh(true);
}
});
}
}.start();
} }
} }
public void setSearchProps(String propName, DataType type, String propValue) { public void setSearchProps(String propName, DataType type, String propValue) {
for(int i=0; i<attrNames.size(); ++i) { for(int i=0; i<searchPropComboViewer.getCombo().getItemCount(); ++i) {
AttributeNameBean e = attrNames.get(i); String itemName = searchPropComboViewer.getCombo().getItem(i);
if(propName.equals(e.getName()) && type.equals(e.getType())) { if(propName.equals(itemName)) {
searchPropComboViewer.getCombo().select(i); searchPropComboViewer.getCombo().select(i);
break; break;
} }

View File

@ -52,12 +52,17 @@ public class TxDbLabelProvider implements ILabelProvider {
/** /**
* Instantiates a new tx db label provider. * Instantiates a new tx db label provider.
*/ */
public TxDbLabelProvider() { public TxDbLabelProvider(boolean isTree) {
super(); super();
loadinDatabase=ResourceManager.getPluginImage(Constants.PLUGIN_ID, "icons/database_go.png"); //$NON-NLS-1$ //$NON-NLS-2$ loadinDatabase=ResourceManager.getPluginImage(Constants.PLUGIN_ID, "icons/database_go.png"); //$NON-NLS-1$ //$NON-NLS-2$
database=ResourceManager.getPluginImage(Constants.PLUGIN_ID, "icons/database.png"); //$NON-NLS-1$ //$NON-NLS-2$ database=ResourceManager.getPluginImage(Constants.PLUGIN_ID, "icons/database.png"); //$NON-NLS-1$ //$NON-NLS-2$
stream=ResourceManager.getPluginImage(Constants.PLUGIN_ID, "icons/stream.png"); //$NON-NLS-1$ //$NON-NLS-2$
folder=ResourceManager.getPluginImage(Constants.PLUGIN_ID, "icons/folder.png"); //$NON-NLS-1$ //$NON-NLS-2$ folder=ResourceManager.getPluginImage(Constants.PLUGIN_ID, "icons/folder.png"); //$NON-NLS-1$ //$NON-NLS-2$
if(isTree) {
stream=ResourceManager.getPluginImage(Constants.PLUGIN_ID, "icons/stream_hier.png"); //$NON-NLS-1$ //$NON-NLS-2$
} else {
stream=ResourceManager.getPluginImage(Constants.PLUGIN_ID, "icons/stream.png"); //$NON-NLS-1$ //$NON-NLS-2$
}
signal=ResourceManager.getPluginImage(Constants.PLUGIN_ID, "icons/signal.png"); //$NON-NLS-1$ //$NON-NLS-2$ signal=ResourceManager.getPluginImage(Constants.PLUGIN_ID, "icons/signal.png"); //$NON-NLS-1$ //$NON-NLS-2$
wave=ResourceManager.getPluginImage(Constants.PLUGIN_ID, "icons/wave.png"); //$NON-NLS-1$ //$NON-NLS-2$ wave=ResourceManager.getPluginImage(Constants.PLUGIN_ID, "icons/wave.png"); //$NON-NLS-1$ //$NON-NLS-2$
} }
@ -134,7 +139,7 @@ public class TxDbLabelProvider implements ILabelProvider {
case FILTER: case FILTER:
break; break;
case SIGNAL: case SIGNAL:
if(((IWaveform) element).getWidth()==1) if(((IWaveform) element).getRowCount()==1)
return signal; return signal;
else else
return wave; return wave;
@ -159,7 +164,13 @@ public class TxDbLabelProvider implements ILabelProvider {
*/ */
@Override @Override
public String getText(Object element) { public String getText(Object element) {
return ((IHierNode)element).getName(); if(element instanceof IWaveformDb){
IWaveformDb db = (IWaveformDb) element;
if(db.getName()== null)
return "";
return db.getName()+(db.isLoaded()?"":" (loading)");
} else
return ((IHierNode)element).getName();
} }
} }

View File

@ -4,7 +4,7 @@
<parent> <parent>
<groupId>com.minres.scviewer</groupId> <groupId>com.minres.scviewer</groupId>
<artifactId>com.minres.scviewer.parent</artifactId> <artifactId>com.minres.scviewer.parent</artifactId>
<version>2.11.2-SNAPSHOT</version> <version>2.12.0-SNAPSHOT</version>
<relativePath>../..</relativePath> <relativePath>../..</relativePath>
</parent> </parent>
<packaging>eclipse-plugin</packaging> <packaging>eclipse-plugin</packaging>

View File

@ -77,7 +77,7 @@ public class TxDbTreeLabelProvider implements ILabelProvider {
case FILTER: case FILTER:
break; break;
case SIGNAL: case SIGNAL:
if(((IWaveform) element).getWidth()==1) if(((IWaveform) element).getRowCount()==1)
return signal; return signal;
else else
return wave; return wave;

17
pom.xml
View File

@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>com.minres.scviewer</groupId> <groupId>com.minres.scviewer</groupId>
<artifactId>com.minres.scviewer.parent</artifactId> <artifactId>com.minres.scviewer.parent</artifactId>
<version>2.11.2-SNAPSHOT</version> <version>2.12.0-SNAPSHOT</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<modules> <modules>
<module>releng/com.minres.scviewer.target</module> <module>releng/com.minres.scviewer.target</module>
@ -34,6 +34,19 @@
<build> <build>
<plugins> <plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<id>parse-version</id>
<goals>
<goal>parse-version</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin> <plugin>
<groupId>org.eclipse.tycho</groupId> <groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-maven-plugin</artifactId> <artifactId>tycho-maven-plugin</artifactId>
@ -55,7 +68,7 @@
<artifact> <artifact>
<groupId>com.minres.scviewer</groupId> <groupId>com.minres.scviewer</groupId>
<artifactId>com.minres.scviewer.target</artifactId> <artifactId>com.minres.scviewer.target</artifactId>
<version>2.11.2-SNAPSHOT</version> <version>2.12.0-SNAPSHOT</version>
</artifact> </artifact>
</target> </target>
<environments> <environments>

View File

@ -6,11 +6,11 @@
<parent> <parent>
<groupId>com.minres.scviewer</groupId> <groupId>com.minres.scviewer</groupId>
<artifactId>com.minres.scviewer.parent</artifactId> <artifactId>com.minres.scviewer.parent</artifactId>
<version>2.11.2-SNAPSHOT</version> <version>2.12.0-SNAPSHOT</version>
<relativePath>../..</relativePath> <relativePath>../..</relativePath>
</parent> </parent>
<artifactId>com.minres.scviewer.e4.product</artifactId> <artifactId>com.minres.scviewer.e4.product</artifactId>
<version>2.11.2-SNAPSHOT</version> <version>2.12.0-SNAPSHOT</version>
<packaging>eclipse-repository</packaging> <packaging>eclipse-repository</packaging>
<groupId>com.minres.scviewer</groupId> <groupId>com.minres.scviewer</groupId>
<build> <build>
@ -46,7 +46,7 @@
<products> <products>
<product> <product>
<id>product</id> <id>product</id>
<archiveFileName>SCViewer-${project.version}</archiveFileName> <archiveFileName>SCViewer-${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}</archiveFileName>
<rootFolders> <rootFolders>
<macosx>SCViewer.app</macosx> <macosx>SCViewer.app</macosx>
</rootFolders> </rootFolders>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<?pde version="3.5"?> <?pde version="3.5"?>
<product name="SCViewer" uid="product" id="com.minres.scviewer.e4.application.product" application="org.eclipse.e4.ui.workbench.swt.E4Application" version="2.11.2.qualifier" useFeatures="true" includeLaunchers="true"> <product name="SCViewer" uid="product" id="com.minres.scviewer.e4.application.product" application="org.eclipse.e4.ui.workbench.swt.E4Application" version="2.12.0.qualifier" useFeatures="true" includeLaunchers="true">
<configIni use="default"> <configIni use="default">
</configIni> </configIni>
@ -9,7 +9,7 @@
<launcherArgs> <launcherArgs>
<programArgs>-clearPersistedState <programArgs>-clearPersistedState
</programArgs> </programArgs>
<vmArgs>-Xmx1G -Dosgi.instance.area=@user.home/.scviewer -Dosgi.instance.area.default=@user.home/.scviewer <vmArgs>-Xmx2G -Dosgi.instance.area=@user.home/.scviewer -Dosgi.instance.area.default=@user.home/.scviewer
</vmArgs> </vmArgs>
<vmArgsMac>-XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts <vmArgsMac>-XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts
</vmArgsMac> </vmArgsMac>

View File

@ -12,7 +12,7 @@
<parent> <parent>
<groupId>com.minres.scviewer</groupId> <groupId>com.minres.scviewer</groupId>
<artifactId>com.minres.scviewer.parent</artifactId> <artifactId>com.minres.scviewer.parent</artifactId>
<version>2.11.2-SNAPSHOT</version> <version>2.12.0-SNAPSHOT</version>
<relativePath>../..</relativePath> <relativePath>../..</relativePath>
</parent> </parent>

View File

@ -3,12 +3,11 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 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> <modelVersion>4.0.0</modelVersion>
<artifactId>com.minres.scviewer.updateSite</artifactId> <artifactId>com.minres.scviewer.updateSite</artifactId>
<version>2.11.2-SNAPSHOT</version>
<packaging>eclipse-repository</packaging> <packaging>eclipse-repository</packaging>
<parent> <parent>
<groupId>com.minres.scviewer</groupId> <groupId>com.minres.scviewer</groupId>
<artifactId>com.minres.scviewer.parent</artifactId> <artifactId>com.minres.scviewer.parent</artifactId>
<version>2.11.2-SNAPSHOT</version> <version>2.12.0-SNAPSHOT</version>
<relativePath>../..</relativePath> <relativePath>../..</relativePath>
</parent> </parent>
<build> <build>
@ -22,19 +21,6 @@
<finalName>${project.artifactId}-${qualifiedVersion}</finalName> <finalName>${project.artifactId}-${qualifiedVersion}</finalName>
</configuration> </configuration>
</plugin> </plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<id>parse-version</id>
<goals>
<goal>parse-version</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins> </plugins>
</build> </build>
<profiles> <profiles>
@ -59,7 +45,7 @@
<!-- Bintray package name --> <!-- Bintray package name -->
<bintrayPackage>SCViewer</bintrayPackage> <bintrayPackage>SCViewer</bintrayPackage>
<!-- Bintray package version number --> <!-- Bintray package version number -->
<bintrayVersion>${parsedVersion.majorVersion}.${parsedVersion.minorVersion}</bintrayVersion> <bintrayVersion>${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}</bintrayVersion>
<!-- remove any preexisting files --> <!-- remove any preexisting files -->
<performDestroy>true</performDestroy> <performDestroy>true</performDestroy>
<!-- information used when creating the package --> <!-- information used when creating the package -->

View File

@ -19,18 +19,18 @@
<booleanAttribute key="includeOptional" value="true"/> <booleanAttribute key="includeOptional" value="true"/>
<stringAttribute key="location" value="${workspace_loc}/../junit-workspace"/> <stringAttribute key="location" value="${workspace_loc}/../junit-workspace"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS"> <listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/com.minres.scviewer.database.test"/> <listEntry value="/com.minres.scviewer.database.test/src/com/minres/scviewer/database/test/DatabaseServicesTest.java"/>
</listAttribute> </listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES"> <listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/> <listEntry value="1"/>
</listAttribute> </listAttribute>
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value="=com.minres.scviewer.database.test"/> <stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/> <booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/> <stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/> <stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/> <booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/>
<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> <stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value=""/> <stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="com.minres.scviewer.database.test.DatabaseServicesTest"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog"/> <stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="com.minres.scviewer.database.test"/> <stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="com.minres.scviewer.database.test"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/> <stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="com.minres.scviewer.database.test"> <scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="com.minres.scviewer.database.test">
<implementation class="com.minres.scviewer.database.test.DatabaseServicesTest"/> <implementation class="com.minres.scviewer.database.test.TestWaveformDbFactory"/>
<reference bind="setFactory" cardinality="1..1" interface="com.minres.scviewer.database.IWaveformDbFactory" name="IWaveformDbFactory" policy="static" unbind="unsetFactory"/> <reference bind="setFactory" cardinality="1..1" interface="com.minres.scviewer.database.IWaveformDbFactory" name="IWaveformDbFactory" policy="static" unbind="unsetFactory"/>
</scr:component> </scr:component>

View File

@ -6,7 +6,7 @@
<parent> <parent>
<groupId>com.minres.scviewer</groupId> <groupId>com.minres.scviewer</groupId>
<artifactId>com.minres.scviewer.parent</artifactId> <artifactId>com.minres.scviewer.parent</artifactId>
<version>2.11.2-SNAPSHOT</version> <version>2.12.0-SNAPSHOT</version>
<relativePath>../..</relativePath> <relativePath>../..</relativePath>
</parent> </parent>
<packaging>eclipse-test-plugin</packaging> <packaging>eclipse-test-plugin</packaging>

View File

@ -25,28 +25,15 @@ import org.junit.Test;
import com.minres.scviewer.database.IEvent; import com.minres.scviewer.database.IEvent;
import com.minres.scviewer.database.IWaveform; import com.minres.scviewer.database.IWaveform;
import com.minres.scviewer.database.IWaveformDb; import com.minres.scviewer.database.IWaveformDb;
import com.minres.scviewer.database.IWaveformDbFactory;
public class DatabaseServicesTest { public class DatabaseServicesTest {
private static IWaveformDbFactory waveformDbFactory;
private IWaveformDb waveformDb; private IWaveformDb waveformDb;
public synchronized void setFactory(IWaveformDbFactory service) {
waveformDbFactory = service;
}
public synchronized void unsetFactory(IWaveformDbFactory service) {
if (waveformDbFactory == service) {
waveformDbFactory = null;
}
}
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
waveformDb=waveformDbFactory.getDatabase(); waveformDb=TestWaveformDbFactory.getDatabase();
} }
@After @After
@ -91,11 +78,11 @@ public class DatabaseServicesTest {
assertEquals(1, waveformDb.getChildNodes().size()); assertEquals(1, waveformDb.getChildNodes().size());
for(IWaveform w:waveforms) { for(IWaveform w:waveforms) {
if(w.getId().equals(1l)) { if(w.getId().equals(1l)) {
assertEquals(2, w.getWidth()); assertEquals(2, w.getRowCount());
} else if(w.getId().equals(2l)) { } else if(w.getId().equals(2l)) {
assertEquals(1, w.getWidth()); assertEquals(1, w.getRowCount());
} else if(w.getId().equals(3l)) { } else if(w.getId().equals(3l)) {
assertEquals(1, w.getWidth()); assertEquals(1, w.getRowCount());
} }
} }
} }

View File

@ -0,0 +1,25 @@
package com.minres.scviewer.database.test;
import com.minres.scviewer.database.IWaveformDb;
import com.minres.scviewer.database.IWaveformDbFactory;
public class TestWaveformDbFactory {
private static IWaveformDbFactory waveformDbFactory;
public synchronized void setFactory(IWaveformDbFactory service) {
waveformDbFactory = service;
}
public synchronized void unsetFactory(IWaveformDbFactory service) {
if (waveformDbFactory == service) {
waveformDbFactory = null;
}
}
public static IWaveformDb getDatabase() throws Exception {
return waveformDbFactory.getDatabase();
}
}