diff --git a/com.minres.scviewer.target/com.minres.scviewer.target.target b/com.minres.scviewer.target/com.minres.scviewer.target.target
index 3de7c9e..146343c 100644
--- a/com.minres.scviewer.target/com.minres.scviewer.target.target
+++ b/com.minres.scviewer.target/com.minres.scviewer.target.target
@@ -31,6 +31,11 @@
+
+
+
+
+
diff --git a/features/com.minres.scviewer.database.feature/feature.xml b/features/com.minres.scviewer.database.feature/feature.xml
index cf69f50..eed494e 100644
--- a/features/com.minres.scviewer.database.feature/feature.xml
+++ b/features/com.minres.scviewer.database.feature/feature.xml
@@ -58,12 +58,6 @@ http://www.eclipse.org/legal/epl-v10.html
version="0.0.0"
unpack="false"/>
-
-
2.0.0-SNAPSHOT
../..
- 2.0.0-SNAPSHOT
diff --git a/plugins/com.minres.scviewer.database.sqlite/src/com/minres/scviewer/database/sqlite/SQLiteDbLoader.java b/plugins/com.minres.scviewer.database.sqlite/src/com/minres/scviewer/database/sqlite/SQLiteDbLoader.java
index c2470ae..0b09965 100644
--- a/plugins/com.minres.scviewer.database.sqlite/src/com/minres/scviewer/database/sqlite/SQLiteDbLoader.java
+++ b/plugins/com.minres.scviewer.database.sqlite/src/com/minres/scviewer/database/sqlite/SQLiteDbLoader.java
@@ -37,8 +37,6 @@ public class SQLiteDbLoader implements IWaveformDbLoader {
protected IDatabase database;
private List usedRelationsList = new ArrayList<>();
-
- private IWaveformDb db;
private ScvSimProps scvSimProps;
@@ -63,7 +61,7 @@ public class SQLiteDbLoader implements IWaveformDbLoader {
List streams=new ArrayList<>();
try {
for(ScvStream scvStream:handler.selectObjects()){
- TxStream stream = new TxStream(database, db, scvStream);
+ TxStream stream = new TxStream(database, scvStream);
stream.setRelationTypeList(usedRelationsList);
streams.add(stream);
}
@@ -77,8 +75,8 @@ public class SQLiteDbLoader implements IWaveformDbLoader {
@Override
public boolean load(IWaveformDb db, File file) throws InputFormatException {
+ dispose();
if(file.isDirectory() || !file.exists()) return false;
- this.db=db;
try(FileInputStream fis = new FileInputStream(file)) {
byte[] buffer = new byte[x.length];
int read = fis.read(buffer, 0, x.length);
@@ -88,7 +86,7 @@ public class SQLiteDbLoader implements IWaveformDbLoader {
} catch(IOException e) {
return false;
}
- database=new SQLiteDatabase(file.getAbsolutePath());
+ database=new SQLiteDatabase(file.getAbsolutePath(), db);
database.setData("TIMERESOLUTION", 1L);
SQLiteDatabaseSelectHandler handler = new SQLiteDatabaseSelectHandler<>(ScvSimProps.class, database);
try {
@@ -103,7 +101,12 @@ public class SQLiteDbLoader implements IWaveformDbLoader {
}
return false;
}
-
+
+ public void dispose() {
+ database=null;
+ usedRelationsList=null;
+ }
+
@Override
public Collection getAllRelationTypes(){
return usedRelationsList;
diff --git a/plugins/com.minres.scviewer.database.sqlite/src/com/minres/scviewer/database/sqlite/Tx.java b/plugins/com.minres.scviewer.database.sqlite/src/com/minres/scviewer/database/sqlite/Tx.java
index f2ab703..62f35e1 100644
--- a/plugins/com.minres.scviewer.database.sqlite/src/com/minres/scviewer/database/sqlite/Tx.java
+++ b/plugins/com.minres.scviewer.database.sqlite/src/com/minres/scviewer/database/sqlite/Tx.java
@@ -164,7 +164,7 @@ public class Tx implements ITx {
List streams = new SQLiteDatabaseSelectHandler(ScvStream.class, database,
"id="+res.get(0).getStream()).selectObjects();
if(streams.size()!=1) return null;
- TxStream tgtStream = (TxStream) trStream.getDb().getStreamByName(streams.get(0).getName());
+ TxStream tgtStream = (TxStream) database.getWaveformDb().getStreamByName(streams.get(0).getName());
Tx that = (Tx) tgtStream.getTransactions().get(otherId);
if(outgoing)
return new TxRelation(trStream.getRelationType(rel.getName()), this, that);
diff --git a/plugins/com.minres.scviewer.database.sqlite/src/com/minres/scviewer/database/sqlite/TxGenerator.java b/plugins/com.minres.scviewer.database.sqlite/src/com/minres/scviewer/database/sqlite/TxGenerator.java
index 5ceca40..08cc6f3 100644
--- a/plugins/com.minres.scviewer.database.sqlite/src/com/minres/scviewer/database/sqlite/TxGenerator.java
+++ b/plugins/com.minres.scviewer.database.sqlite/src/com/minres/scviewer/database/sqlite/TxGenerator.java
@@ -10,12 +10,8 @@
*******************************************************************************/
package com.minres.scviewer.database.sqlite;
-import java.util.ArrayList;
-import java.util.List;
-
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 {
@@ -44,9 +40,4 @@ public class TxGenerator implements ITxGenerator {
return scvGenerator.getName();
}
- @Override
- public List getTransactions() {
- return new ArrayList<>();
- }
-
}
diff --git a/plugins/com.minres.scviewer.database.sqlite/src/com/minres/scviewer/database/sqlite/TxStream.java b/plugins/com.minres.scviewer.database.sqlite/src/com/minres/scviewer/database/sqlite/TxStream.java
index c6df2a1..324825b 100644
--- a/plugins/com.minres.scviewer.database.sqlite/src/com/minres/scviewer/database/sqlite/TxStream.java
+++ b/plugins/com.minres.scviewer.database.sqlite/src/com/minres/scviewer/database/sqlite/TxStream.java
@@ -24,8 +24,8 @@ import com.minres.scviewer.database.EventKind;
import com.minres.scviewer.database.HierNode;
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.RelationTypeFactory;
import com.minres.scviewer.database.WaveformType;
import com.minres.scviewer.database.sqlite.db.IDatabase;
import com.minres.scviewer.database.sqlite.db.SQLiteDatabaseSelectHandler;
@@ -41,8 +41,6 @@ public class TxStream extends HierNode implements IWaveform {
private String fullName;
- private IWaveformDb db;
-
private ScvStream scvStream;
private TreeMap generators;
@@ -55,17 +53,11 @@ public class TxStream extends HierNode implements IWaveform {
private List usedRelationsList;
- public TxStream(IDatabase database, IWaveformDb waveformDb, ScvStream scvStream) {
+ public TxStream(IDatabase database, ScvStream scvStream) {
super(scvStream.getName());
this.database=database;
fullName=scvStream.getName();
this.scvStream=scvStream;
- db=waveformDb;
- }
-
- @Override
- public IWaveformDb getDb() {
- return db;
}
@Override
@@ -173,7 +165,7 @@ public class TxStream extends HierNode implements IWaveform {
}
public RelationType getRelationType(String name) {
- RelationType relType=RelationType.create(name);
+ RelationType relType=RelationTypeFactory.create(name);
if(!usedRelationsList.contains(relType)) usedRelationsList.add(relType);
return relType;
}
diff --git a/plugins/com.minres.scviewer.database.sqlite/src/com/minres/scviewer/database/sqlite/db/IDatabase.java b/plugins/com.minres.scviewer.database.sqlite/src/com/minres/scviewer/database/sqlite/db/IDatabase.java
index ca8e70f..92d2405 100644
--- a/plugins/com.minres.scviewer.database.sqlite/src/com/minres/scviewer/database/sqlite/db/IDatabase.java
+++ b/plugins/com.minres.scviewer.database.sqlite/src/com/minres/scviewer/database/sqlite/db/IDatabase.java
@@ -16,6 +16,8 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
+import com.minres.scviewer.database.IWaveformDb;
+
/**
*
* Creates a connection to a database.
@@ -58,4 +60,6 @@ public interface IDatabase {
public void setData(String name, Object value);
public Object getData(String name);
+
+ public IWaveformDb getWaveformDb();
}
\ No newline at end of file
diff --git a/plugins/com.minres.scviewer.database.sqlite/src/com/minres/scviewer/database/sqlite/db/SQLiteDatabase.java b/plugins/com.minres.scviewer.database.sqlite/src/com/minres/scviewer/database/sqlite/db/SQLiteDatabase.java
index c14787f..4d89c33 100644
--- a/plugins/com.minres.scviewer.database.sqlite/src/com/minres/scviewer/database/sqlite/db/SQLiteDatabase.java
+++ b/plugins/com.minres.scviewer.database.sqlite/src/com/minres/scviewer/database/sqlite/db/SQLiteDatabase.java
@@ -20,10 +20,14 @@ import java.sql.SQLException;
import java.sql.Statement;
import java.util.HashMap;
+import com.minres.scviewer.database.IWaveformDb;
+
public class SQLiteDatabase implements IDatabase {
protected String dbFileName;
+ protected IWaveformDb waveformDb;
+
protected HashMap props;
static {
@@ -39,9 +43,10 @@ public class SQLiteDatabase implements IDatabase {
}
}
- public SQLiteDatabase(String dbFileName) {
+ public SQLiteDatabase(String dbFileName, IWaveformDb waveformDb) {
super();
this.dbFileName = dbFileName;
+ this.waveformDb = waveformDb;
props = new HashMap();
}
@@ -89,4 +94,9 @@ public class SQLiteDatabase implements IDatabase {
return props.get(name);
}
+ @Override
+ public IWaveformDb getWaveformDb() {
+ return waveformDb;
+ }
+
}
diff --git a/plugins/com.minres.scviewer.database.text/.classpath b/plugins/com.minres.scviewer.database.text/.classpath
index 289f0a4..384de53 100644
--- a/plugins/com.minres.scviewer.database.text/.classpath
+++ b/plugins/com.minres.scviewer.database.text/.classpath
@@ -11,10 +11,7 @@
-
-
-
-
+
diff --git a/plugins/com.minres.scviewer.database.text/.project b/plugins/com.minres.scviewer.database.text/.project
index e6c7553..fb8e0fc 100644
--- a/plugins/com.minres.scviewer.database.text/.project
+++ b/plugins/com.minres.scviewer.database.text/.project
@@ -33,7 +33,6 @@
org.eclipse.m2e.core.maven2Nature
- org.eclipse.jdt.groovy.core.groovyNature
org.eclipse.pde.PluginNature
org.eclipse.jdt.core.javanature
diff --git a/plugins/com.minres.scviewer.database.text/META-INF/MANIFEST.MF b/plugins/com.minres.scviewer.database.text/META-INF/MANIFEST.MF
index ffdda45..f623ab1 100644
--- a/plugins/com.minres.scviewer.database.text/META-INF/MANIFEST.MF
+++ b/plugins/com.minres.scviewer.database.text/META-INF/MANIFEST.MF
@@ -7,17 +7,14 @@ Bundle-Vendor: MINRES Technologies GmbH
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Import-Package: org.osgi.framework;version="1.3.0"
Require-Bundle: com.minres.scviewer.database,
- org.codehaus.groovy;bundle-version="2.5.8",
org.eclipse.osgi.services;bundle-version="3.4.0",
- com.google.guava;bundle-version="15.0.0"
+ com.google.guava;bundle-version="15.0.0",
+ org.eclipse.collections;bundle-version="10.4.0"
Service-Component: OSGI-INF/component.xml
Bundle-ActivationPolicy: lazy
Automatic-Module-Name: com.minres.scviewer.database.text
-Bundle-ClassPath: lib/mapdb-3.0.7.jar,
- .,
- lib/eclipse-collections-9.2.0.jar,
- lib/eclipse-collections-api-9.2.0.jar,
- lib/eclipse-collections-forkjoin-9.2.0.jar,
+Bundle-ClassPath: .,
+ lib/mapdb-3.0.7.jar,
lib/kotlin-stdlib-1.2.42.jar,
lib/lz4-1.3.0.jar,
lib/elsa-3.0.0-M5.jar
diff --git a/plugins/com.minres.scviewer.database.text/build.properties b/plugins/com.minres.scviewer.database.text/build.properties
index 5a2fc62..391d9fb 100644
--- a/plugins/com.minres.scviewer.database.text/build.properties
+++ b/plugins/com.minres.scviewer.database.text/build.properties
@@ -13,9 +13,6 @@ bin.includes = META-INF/,\
OSGI-INF/,\
lib/,\
lib/mapdb-3.0.7.jar,\
- lib/eclipse-collections-9.2.0.jar,\
- lib/eclipse-collections-api-9.2.0.jar,\
- lib/eclipse-collections-forkjoin-9.2.0.jar,\
lib/kotlin-stdlib-1.2.42.jar,\
lib/lz4-1.3.0.jar,\
lib/elsa-3.0.0-M5.jar
diff --git a/plugins/com.minres.scviewer.database.text/lib/eclipse-collections-9.2.0.jar b/plugins/com.minres.scviewer.database.text/lib/eclipse-collections-9.2.0.jar
deleted file mode 100755
index 694343e..0000000
Binary files a/plugins/com.minres.scviewer.database.text/lib/eclipse-collections-9.2.0.jar and /dev/null differ
diff --git a/plugins/com.minres.scviewer.database.text/lib/eclipse-collections-api-9.2.0.jar b/plugins/com.minres.scviewer.database.text/lib/eclipse-collections-api-9.2.0.jar
deleted file mode 100755
index e585e77..0000000
Binary files a/plugins/com.minres.scviewer.database.text/lib/eclipse-collections-api-9.2.0.jar and /dev/null differ
diff --git a/plugins/com.minres.scviewer.database.text/lib/eclipse-collections-forkjoin-9.2.0.jar b/plugins/com.minres.scviewer.database.text/lib/eclipse-collections-forkjoin-9.2.0.jar
deleted file mode 100755
index 2ccffc1..0000000
Binary files a/plugins/com.minres.scviewer.database.text/lib/eclipse-collections-forkjoin-9.2.0.jar and /dev/null differ
diff --git a/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/ScvRelation.java b/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/ScvRelation.java
new file mode 100644
index 0000000..de07918
--- /dev/null
+++ b/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/ScvRelation.java
@@ -0,0 +1,25 @@
+package com.minres.scviewer.database.text;
+
+import java.io.Serializable;
+
+import com.minres.scviewer.database.RelationType;
+
+class ScvRelation implements Serializable {
+ /**
+ *
+ */
+ private static final long serialVersionUID = -347668857680574140L;
+
+ final long source;
+
+ final long target;
+
+ final RelationType relationType;
+
+ public ScvRelation(RelationType relationType, long source, long target) {
+ this.source = source;
+ this.target = target;
+ this.relationType = relationType;
+ }
+
+}
diff --git a/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/ScvTx.java b/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/ScvTx.java
new file mode 100644
index 0000000..92498f2
--- /dev/null
+++ b/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/ScvTx.java
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2012 IT Just working.
+ * 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:
+ * IT Just working - initial API and implementation
+ *******************************************************************************/
+package com.minres.scviewer.database.text;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+import com.minres.scviewer.database.tx.ITxAttribute;
+
+class ScvTx implements Serializable{
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -855200240003328221L;
+
+ final long id;
+
+ final long generatorId;
+
+ final long streamId;
+
+ long beginTime;
+
+ long endTime;
+
+ final List attributes = new ArrayList<>();
+
+ ScvTx(long id, long streamId, long generatorId, long begin){
+ this.id=id;
+ this.streamId=streamId;
+ this.generatorId=generatorId;
+ this.beginTime=begin;
+ this.endTime=begin;
+ }
+
+ Long getId() {return id;}
+}
diff --git a/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TextDbLoader.groovy b/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TextDbLoader.groovy
deleted file mode 100644
index 0f07966..0000000
--- a/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TextDbLoader.groovy
+++ /dev/null
@@ -1,245 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 IT Just working.
- * 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:
- * IT Just working - initial API and implementation
- *******************************************************************************/
-package com.minres.scviewer.database.text;
-
-import java.nio.charset.CharsetDecoder;
-import java.util.Collection;
-import java.util.zip.GZIPInputStream
-
-import org.codehaus.groovy.ast.stmt.CatchStatement
-import org.mapdb.DB
-import org.mapdb.DBMaker
-
-import groovy.io.FileType
-
-import com.minres.scviewer.database.AssociationType
-import com.minres.scviewer.database.DataType
-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{
-
- private Long maxTime;
-
- IWaveformDb db;
-
- def streams = []
-
- def relationTypes=[:]
-
- DB mapDb
-
- public TextDbLoader() {
- }
-
- @Override
- public Long getMaxTime() {
- return maxTime;
- }
-
- @Override
- public Collection getAllWaves() {
- return streams;
- }
-
- public Map getGeneratorsById() {
- TreeMap res = new TreeMap();
- streams.each{TxStream stream -> stream.generators.each{res.put(it.id, id)} }
- return res;
- }
-
- static final byte[] x = "scv_tr_stream".bytes
-
- @Override
- boolean load(IWaveformDb db, File file) throws InputFormatException {
- if(file.isDirectory() || !file.exists()) return false;
- this.db=db
- this.streams=[]
- try {
- def gzipped = isGzipped(file)
- if(isTxfile(gzipped?new GZIPInputStream(new FileInputStream(file)):new FileInputStream(file))){
- def mapDbFile = File.createTempFile("."+file.name, null /*"tmp"*/, null /*file.parentFile*/)
- mapDbFile.delete()
- mapDbFile.deleteOnExit()
- this.mapDb = DBMaker
- .fileDB(mapDbFile)
- .fileMmapEnableIfSupported()
- .fileMmapPreclearDisable()
- .cleanerHackEnable()
- .allocateStartSize(64*1024*1024)
- .allocateIncrement(64*1024*1024)
- .make()
- // NPE here --->
- parseInput(gzipped?new GZIPInputStream(new FileInputStream(file)):new FileInputStream(file))
- streams.each{ TxStream stream -> stream.getWidth() }
- return true
- }
- } catch (IndexOutOfBoundsException e) {
- return false
- } catch (IllegalArgumentException e) {
- return false
- } catch (NumberFormatException e) {
- return false
- } catch(EOFException e) {
- return true;
- } catch(Exception e) {
- 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;
- }
-
- private static boolean isTxfile(InputStream istream) {
- byte[] buffer = new byte[x.size()]
- def readCnt = istream.read(buffer, 0, x.size())
- istream.close()
- if(readCnt==x.size()){
- for(int i=0; i
- def tokens = line.split(/\s+/) as ArrayList
- switch(tokens[0]){
- case "scv_tr_stream":
- if ((matcher = line =~ /^scv_tr_stream\s+\(ID (\d+),\s+name\s+"([^"]+)",\s+kind\s+"([^"]+)"\)$/)) {
- def id = Integer.parseInt(matcher[0][1])
- def stream = new TxStream(this, id, matcher[0][2], matcher[0][3])
- streams<transaction.beginTime?maxTime:transaction.beginTime
- endTransaction=false
- break
- case "tx_end"://matcher = line =~ /^tx_end\s+(\d+)\s+(\d+)\s+(\d+)\s+([munpf]?s)/
- def id = Integer.parseInt(tokens[1])
- transaction = transactionsById[id]
- assert Integer.parseInt(tokens[2])==transaction.generator.id
- transaction.endTime = Long.parseLong(tokens[3])*stringToScale(tokens[4])
- transaction.generator.end_attrs_idx=0;
- maxTime = maxTime>transaction.endTime?maxTime:transaction.endTime
- endTransaction=true
- break
- case "tx_record_attribute"://matcher = line =~ /^tx_record_attribute\s+(\d+)\s+"([^"]+)"\s+(\S+)\s*=\s*(.+)$/
- def id = Integer.parseInt(tokens[1])
- def name = tokens[2][1..-2]
- def type = tokens[3] as DataType
- def remaining = tokens.size()>5?tokens[5..-1].join(' '):""
- transactionsById[id].attributes< getAllRelationTypes(){
- return relationTypes.values();
- }
-
-}
-
diff --git a/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TextDbLoader.java b/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TextDbLoader.java
new file mode 100644
index 0000000..e8cdd75
--- /dev/null
+++ b/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TextDbLoader.java
@@ -0,0 +1,385 @@
+/*******************************************************************************
+ * Copyright (c) 2012 IT Just working.
+ * 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:
+ * IT Just working - initial API and implementation
+ *******************************************************************************/
+package com.minres.scviewer.database.text;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.zip.GZIPInputStream;
+
+import org.eclipse.collections.impl.map.mutable.UnifiedMap;
+import org.mapdb.DB;
+import org.mapdb.DB.TreeMapSink;
+import org.mapdb.DBMaker;
+import org.mapdb.Serializer;
+
+import com.google.common.collect.HashMultimap;
+import com.minres.scviewer.database.AssociationType;
+import com.minres.scviewer.database.DataType;
+import com.minres.scviewer.database.EventKind;
+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.RelationTypeFactory;
+import com.minres.scviewer.database.tx.ITx;
+
+public class TextDbLoader implements IWaveformDbLoader{
+
+ private Long maxTime=0L;
+
+ DB mapDb=null;
+
+ final List attrValues = new ArrayList<>();
+
+ final Map relationTypes = UnifiedMap.newMap();
+
+ final Map txStreams = UnifiedMap.newMap();
+
+ final Map txGenerators = UnifiedMap.newMap();
+
+ Map transactions = null;
+
+ final Map attributeTypes = UnifiedMap.newMap();
+
+ final HashMultimap relationsIn = HashMultimap.create();
+
+ final HashMultimap relationsOut = HashMultimap.create();
+
+ HashMap txCache = new HashMap<>();
+
+ List threads = new ArrayList<>();
+
+ @Override
+ public Long getMaxTime() {
+ return maxTime;
+ }
+
+ @Override
+ public Collection getAllWaves() {
+ return new ArrayList<>(txStreams.values());
+ }
+
+ static final byte[] x = "scv_tr_stream".getBytes();
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public boolean load(IWaveformDb db, File file) throws InputFormatException {
+ dispose();
+ if(file.isDirectory() || !file.exists()) return false;
+ TextDbParser parser = new TextDbParser(this);
+ boolean gzipped = isGzipped(file);
+ try {
+ if(!isTxfile(gzipped?new GZIPInputStream(new FileInputStream(file)):new FileInputStream(file)))
+ return false;
+ } catch(Exception e) {
+ throw new InputFormatException();
+ }
+
+ if(file.length() < 75000000*(gzipped?1:10) || "memory".equals(System.getProperty("ScvBackingDB", "file")))
+ mapDb = DBMaker
+ .memoryDirectDB()
+ .allocateStartSize(512l*1024l*1024l)
+ .allocateIncrement(128l*1024l*1024l)
+ .cleanerHackEnable()
+ .make();
+ else {
+ File mapDbFile;
+ try {
+ mapDbFile = File.createTempFile("."+file.getName(), ".mapdb", null /*file.parentFile*/);
+ Files.delete(Paths.get(mapDbFile.getPath()));
+ } catch (IOException e1) {
+ return false;
+ }
+ mapDb = DBMaker
+ .fileDB(mapDbFile)
+ .fileMmapEnable() // Always enable mmap
+ .fileMmapEnableIfSupported()
+ .fileMmapPreclearDisable()
+ .allocateStartSize(512l*1024l*1024l)
+ .allocateIncrement(128l*1024l*1024l)
+ .cleanerHackEnable()
+ .make();
+ mapDbFile.deleteOnExit();
+ }
+ try {
+ parser.txSink = mapDb.treeMap("transactions", Serializer.LONG,Serializer.JAVA).createFromSink();
+ parser.parseInput(gzipped?new GZIPInputStream(new FileInputStream(file)):new FileInputStream(file));
+ transactions = parser.txSink.create();
+ } catch(IllegalArgumentException|ArrayIndexOutOfBoundsException e) {
+ } catch(Exception e) {
+ System.out.println("---->>> Exception "+e.toString()+" caught while loading database");
+ e.printStackTrace();
+ return false;
+ }
+ for(TxStream stream:txStreams.values()) {
+ 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();
+ }
+ return true;
+ }
+
+ @Override
+ public void dispose() {
+ attrValues.clear();
+ relationTypes.clear();
+ txStreams.clear();
+ txGenerators.clear();
+ transactions = null;
+ attributeTypes.clear();
+ relationsIn.clear();
+ relationsOut.clear();
+ if(mapDb!=null) {
+ mapDb.close();
+ mapDb=null;
+ }
+ }
+
+ private static boolean isTxfile(InputStream istream) {
+ byte[] buffer = new byte[x.length];
+ try {
+ int readCnt = istream.read(buffer, 0, x.length);
+ istream.close();
+ if(readCnt==x.length){
+ for(int i=0; i getAllRelationTypes(){
+ return relationTypes.values();
+ }
+
+ static class TextDbParser {
+ static final Pattern scv_tr_stream = Pattern.compile("^scv_tr_stream\\s+\\(ID (\\d+),\\s+name\\s+\"([^\"]+)\",\\s+kind\\s+\"([^\"]+)\"\\)$");
+ static final Pattern scv_tr_generator = Pattern.compile("^scv_tr_generator\\s+\\(ID\\s+(\\d+),\\s+name\\s+\"([^\"]+)\",\\s+scv_tr_stream\\s+(\\d+),$");
+ static final Pattern begin_attribute = Pattern.compile("^begin_attribute \\(ID (\\d+), name \"([^\"]+)\", type \"([^\"]+)\"\\)$");
+ static final Pattern end_attribute = Pattern.compile("^end_attribute \\(ID (\\d+), name \"([^\"]+)\", type \"([^\"]+)\"\\)$");
+
+ final TextDbLoader loader;
+
+ HashMap transactionById = new HashMap<>();
+
+ TreeMapSink txSink;
+
+ BufferedReader reader = null;
+
+ TxGenerator generator=null;
+
+ Map attrValueLut = new HashMap<>();
+
+ public TextDbParser(TextDbLoader loader) {
+ super();
+ this.loader = loader;
+ }
+
+ void parseInput(InputStream inputStream) throws IOException{
+ reader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8));
+ String curLine = reader.readLine();
+ String nextLine = null;
+ while((nextLine=reader.readLine())!=null && curLine!=null) {
+ curLine=parseLine(curLine, nextLine);
+ }
+ if(curLine!=null)
+ parseLine(curLine, nextLine);
+ }
+
+ private TxAttributeType getAttrType(String name, DataType dataType, AssociationType type){
+ String key =name+"-"+dataType.toString();
+ TxAttributeType res;
+ if(loader.attributeTypes.containsKey(key)){
+ res=loader.attributeTypes.get(key);
+ } else {
+ res=new TxAttributeType(name, dataType, type);
+ loader.attributeTypes.put(key, res);
+ }
+ return res;
+ }
+
+ private String parseLine(String curLine, String nextLine) throws IOException{
+ String[] tokens = curLine.split("\\s+");
+ if("tx_record_attribute".equals(tokens[0])){
+ Long id = Long.parseLong(tokens[1]);
+ String name = tokens[2].substring(1, tokens[2].length());
+ DataType type = DataType.valueOf(tokens[3]);
+ String remaining = tokens.length>5?String.join(" ", Arrays.copyOfRange(tokens, 5, tokens.length)):"";
+ TxAttributeType attrType = getAttrType(name, type, AssociationType.RECORD);
+ transactionById.get(id).attributes.add(new TxAttribute(attrType, getAttrString(attrType, remaining)));
+ } else if("tx_begin".equals(tokens[0])){
+ Long id = Long.parseLong(tokens[1]);
+ Long genId = Long.parseLong(tokens[2]);
+ TxGenerator gen=loader.txGenerators.get(genId);
+ ScvTx scvTx = new ScvTx(id, gen.stream.getId(), genId, Long.parseLong(tokens[3])*stringToScale(tokens[4]));
+ 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') {
+ int idx=0;
+ while(nextLine!=null && nextLine.charAt(0)=='a') {
+ String[] attrTokens=nextLine.split("\\s+");
+ TxAttributeType attrType = gen.beginAttrs.get(idx);
+ TxAttribute attr = new TxAttribute(attrType, getAttrString(attrType, attrTokens[1]));
+ scvTx.attributes.add(attr);
+ idx++;
+ nextLine=reader.readLine();
+ }
+ }
+ txSink.put(id, scvTx);
+ transactionById.put(id, scvTx);
+ } else if("tx_end".equals(tokens[0])){
+ Long id = Long.parseLong(tokens[1]);
+ ScvTx scvTx = transactionById.get(id);
+ assert Long.parseLong(tokens[2])==scvTx.generatorId;
+ scvTx.endTime=Long.parseLong(tokens[3])*stringToScale(tokens[4]);
+ loader.maxTime = loader.maxTime>scvTx.endTime?loader.maxTime:scvTx.endTime;
+ TxGenerator gen = loader.txGenerators.get(scvTx.generatorId);
+ TxStream stream = loader.txStreams.get(gen.stream.getId());
+ if(scvTx.beginTime==scvTx.endTime)
+ stream.addEvent(new TxEvent(loader, EventKind.SINGLE, id, scvTx.beginTime));
+ else {
+ stream.addEvent(new TxEvent(loader, EventKind.BEGIN, id, scvTx.beginTime));
+ stream.addEvent(new TxEvent(loader, EventKind.END, id, scvTx.endTime));
+ }
+ stream.setConcurrency(stream.getConcurrency()-1);
+ if(nextLine!=null && nextLine.charAt(0)=='a') {
+ int idx=0;
+ while(nextLine!=null && nextLine.charAt(0)=='a') {
+ String[] attrTokens=nextLine.split("\\s+");
+ TxAttributeType attrType = gen.endAttrs.get(idx);
+ TxAttribute attr = new TxAttribute(attrType, getAttrString(attrType, attrTokens[1]));
+ scvTx.attributes.add(attr);
+ idx++;
+ nextLine=reader.readLine();
+ }
+ }
+ } else if("tx_relation".equals(tokens[0])){
+ Long tr2= Long.parseLong(tokens[2]);
+ Long tr1= Long.parseLong(tokens[3]);
+ String relType=tokens[1].substring(1, tokens[1].length()-1);
+ if(!loader.relationTypes.containsKey(relType))
+ loader.relationTypes.put(relType, RelationTypeFactory.create(relType));
+ ScvRelation rel = new ScvRelation(loader.relationTypes.get(relType), tr1, tr2);
+ loader.relationsOut.put(tr1, rel);
+ loader.relationsIn.put(tr2, rel);
+ } else if("scv_tr_stream".equals(tokens[0])){
+ Matcher matcher = scv_tr_stream.matcher(curLine);
+ if (matcher.matches()) {
+ Long id = Long.parseLong(matcher.group(1));
+ TxStream stream = new TxStream(loader, id, matcher.group(2), matcher.group(3));
+ loader.txStreams.put(id, stream);
+ }
+ } else if("scv_tr_generator".equals(tokens[0])){
+ Matcher matcher = scv_tr_generator.matcher(curLine);
+ if ((matcher.matches())) {
+ Long id = Long.parseLong(matcher.group(1));
+ TxStream stream=loader.txStreams.get(Long.parseLong(matcher.group(3)));
+ generator=new TxGenerator(id, stream, matcher.group(2));
+ loader.txGenerators.put(id, generator);
+ }
+ } else if("begin_attribute".equals(tokens[0])){
+ Matcher matcher = begin_attribute.matcher(curLine);
+ if ((matcher.matches())) {
+ TxAttributeType attrType = getAttrType(matcher.group(2), DataType.valueOf(matcher.group(3)), AssociationType.BEGIN);
+ generator.beginAttrs.add(attrType);
+ }
+ } else if("end_attribute".equals(tokens[0])){
+ Matcher matcher = end_attribute.matcher(curLine);
+ if ((matcher.matches())) {
+ TxAttributeType attrType = getAttrType(matcher.group(2), DataType.valueOf(matcher.group(3)), AssociationType.END);
+ generator.endAttrs.add(attrType);
+ }
+ } else if(")".equals(tokens[0])){
+ generator=null;
+ } else if("a".equals(tokens[0])){//matcher = line =~ /^a\s+(.+)$/
+ System.out.println("Don't know what to do with: '"+curLine+"'");
+ } else
+ System.out.println("Don't know what to do with: '"+curLine+"'");
+ return nextLine;
+ }
+
+ private String getAttrString(TxAttributeType attrType, String string) {
+ String value;
+ switch(attrType.getDataType()){
+ case STRING:
+ case ENUMERATION:
+ value=string.substring(1, string.length()-1);
+ break;
+ default:
+ value=string;
+ }
+ if(attrValueLut.containsKey(value)){
+ return loader.attrValues.get(attrValueLut.get(value));
+ } else {
+ attrValueLut.put(value, loader.attrValues.size());
+ loader.attrValues.add(value);
+ return value;
+ }
+ }
+
+ private long stringToScale(String scale){
+ String cmp = scale.trim();
+ if("fs".equals(cmp)) return 1L;
+ if("ps".equals(cmp)) return 1000L;
+ if("ns".equals(cmp)) return 1000000L;
+ if("us".equals(cmp)) return 1000000000L;
+ if("ms".equals(cmp)) return 1000000000000L;
+ if("s".equals(cmp) ) return 1000000000000000L;
+ return 1L;
+ }
+ }
+
+ 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;
+ }
+
+}
+
diff --git a/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/Tx.groovy b/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/Tx.groovy
deleted file mode 100644
index 32fa2a6..0000000
--- a/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/Tx.groovy
+++ /dev/null
@@ -1,70 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 IT Just working.
- * 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:
- * IT Just working - initial API and implementation
- *******************************************************************************/
-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 {
-
- Long id
-
- TxGenerator generator
-
- TxStream stream
-
- int concurrencyIndex
-
- Long beginTime
-
- Long endTime
-
- ArrayList attributes = new ArrayList()
-
- def incomingRelations =[]
-
- def outgoingRelations =[]
-
- Tx(int id, TxStream stream, TxGenerator generator, Long begin){
- this.id=id
- this.stream=stream
- this.generator=generator
- this.beginTime=begin
- this.endTime=begin
- }
-
- @Override
- public Collection getIncomingRelations() {
- return incomingRelations;
- }
-
- @Override
- public Collection getOutgoingRelations() {
- return outgoingRelations;
- }
-
- @Override
- public int compareTo(ITx o) {
- def res =beginTime.compareTo(o.beginTime)
- if(res!=0)
- return res
- else
- return id.compareTo(o.id)
- }
-
- @Override
- public String toString() {
- return "tx#"+getId()+"["+getBeginTime()/1000000+"ns - "+getEndTime()/1000000+"ns]";
- }
-
-}
diff --git a/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/Tx.java b/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/Tx.java
new file mode 100644
index 0000000..cf24abc
--- /dev/null
+++ b/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/Tx.java
@@ -0,0 +1,132 @@
+/*******************************************************************************
+ * Copyright (c) 2012 IT Just working.
+ * 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:
+ * IT Just working - initial API and implementation
+ *******************************************************************************/
+package com.minres.scviewer.database.text;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+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.ITxGenerator;
+import com.minres.scviewer.database.tx.ITxRelation;
+
+class Tx implements ITx {
+
+ private final TextDbLoader loader;
+
+ private long id;
+
+ long beginTime=-1;
+
+ long endTime=-1;
+
+ private int concurrencyIndex;
+
+ public Tx(TextDbLoader loader, ScvTx scvTx) {
+ this.loader=loader;
+ id=scvTx.id;
+ }
+
+ public Tx(TextDbLoader loader, long txId) {
+ this.loader=loader;
+ id=txId;
+ }
+
+ @Override
+ public Collection getIncomingRelations() {
+ Set rels = loader.relationsIn.get(id);
+ return rels.stream().map(rel -> new TxRelation(loader, rel)).collect(Collectors.toList());
+ }
+
+ @Override
+ public Collection getOutgoingRelations() {
+ Set rels = loader.relationsOut.get(id);
+ return rels.stream().map(rel -> new TxRelation(loader, rel)).collect(Collectors.toList());
+ }
+
+ @Override
+ public int compareTo(ITx o) {
+ int res =getBeginTime().compareTo(o.getBeginTime());
+ if(res!=0)
+ return res;
+ else
+ return getId().compareTo(o.getId());
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ return this.getScvTx().equals(((Tx) obj).getScvTx());
+ }
+
+ @Override
+ public int hashCode() {
+ return getScvTx().hashCode();
+ }
+
+ @Override
+ public String toString() {
+ return "tx#"+getId()+"["+getBeginTime()/1000000+"ns - "+getEndTime()/1000000+"ns]";
+ }
+
+ @Override
+ public Long getId() {
+ return getScvTx().id;
+ }
+
+ @Override
+ public IWaveform getStream() {
+ return loader.txStreams.get(getScvTx().streamId);
+ }
+
+ @Override
+ public ITxGenerator getGenerator() {
+ return loader.txGenerators.get(getScvTx().generatorId);
+ }
+
+ @Override
+ public Long getBeginTime() {
+ if(beginTime<0) beginTime=getScvTx().beginTime;
+ return beginTime;
+ }
+
+ @Override
+ public Long getEndTime() {
+ if(endTime<0) endTime=getScvTx().endTime;
+ return endTime;
+ }
+
+ void setEndTime(Long time) {
+ getScvTx().endTime=time;
+ }
+
+ @Override
+ public int getConcurrencyIndex() {
+ return concurrencyIndex;
+ }
+
+ void setConcurrencyIndex(int idx) {
+ concurrencyIndex=idx;
+ }
+
+ @Override
+ public List getAttributes() {
+ return getScvTx().attributes;
+ }
+
+ private ScvTx getScvTx() {
+ return loader.transactions.get(id);
+ }
+}
diff --git a/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxAttribute.groovy b/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxAttribute.java
similarity index 51%
rename from plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxAttribute.groovy
rename to plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxAttribute.java
index bc4a884..26e316c 100644
--- a/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxAttribute.groovy
+++ b/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxAttribute.java
@@ -8,37 +8,28 @@
* Contributors:
* IT Just working - initial API and implementation
*******************************************************************************/
-package com.minres.scviewer.database.text
+package com.minres.scviewer.database.text;
+
+import java.io.Serializable;
import com.minres.scviewer.database.AssociationType;
import com.minres.scviewer.database.DataType;
-import com.minres.scviewer.database.tx.ITxAttribute
-import com.minres.scviewer.database.tx.ITxAttributeType
+import com.minres.scviewer.database.tx.ITxAttribute;
-class TxAttribute implements ITxAttribute{
+public class TxAttribute implements ITxAttribute, Serializable {
- TxAttributeType attributeType
+ /**
+ *
+ */
+ private static final long serialVersionUID = 4767726016651807152L;
- def value
-
- TxAttribute(String name, DataType dataType, AssociationType type, value){
- attributeType = TxAttributeTypeFactory.instance.getAttrType(name, dataType, type)
- switch(dataType){
- case DataType.STRING:
- case DataType.ENUMERATION:
- this.value=value[1..-2]
- break;
- default:
- this.value=value
- }
- }
+ private final TxAttributeType attributeType;
- TxAttribute(TxAttributeType other){
- attributeType=other
- }
+ private final String value;
- TxAttribute(TxAttributeType other, value){
- this(other.name, other.dataType, other.type, value)
+ TxAttribute(TxAttributeType type, String value){
+ this.attributeType=type;
+ this.value=value;
}
@Override
@@ -48,12 +39,17 @@ class TxAttribute implements ITxAttribute{
@Override
public AssociationType getType() {
- attributeType.type;
+ return attributeType.getType();
}
@Override
public DataType getDataType() {
- attributeType.dataType;
+ return attributeType.getDataType();
+ }
+
+ @Override
+ public Object getValue() {
+ return value;
}
}
diff --git a/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxAttributeType.groovy b/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxAttributeType.java
similarity index 53%
rename from plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxAttributeType.groovy
rename to plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxAttributeType.java
index 6a7c0b6..67c72aa 100644
--- a/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxAttributeType.groovy
+++ b/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxAttributeType.java
@@ -8,24 +8,44 @@
* Contributors:
* IT Just working - initial API and implementation
*******************************************************************************/
-package com.minres.scviewer.database.text
+package com.minres.scviewer.database.text;
+
+import java.io.Serializable;
import com.minres.scviewer.database.AssociationType;
import com.minres.scviewer.database.DataType;
-import com.minres.scviewer.database.tx.ITxAttributeType
+import com.minres.scviewer.database.tx.ITxAttributeType;
-class TxAttributeType implements ITxAttributeType {
- String name
- DataType dataType
- AssociationType type
+class TxAttributeType implements ITxAttributeType, Serializable {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 7159721937208946828L;
- static TxAttributeType getAttrType(String name, DataType dataType, AssociationType type){
- TxAttributeTypeFactory.instance.getAttrType(name, dataType, type)
- }
+ private String name;
+
+ private DataType dataType;
+
+ private AssociationType type;
TxAttributeType(String name, DataType dataType, AssociationType type){
- this.name=name
- this.dataType=dataType
- this.type=type
+ this.name=name;
+ this.dataType=dataType;
+ this.type=type;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public DataType getDataType() {
+ return dataType;
+ }
+
+ @Override
+ public AssociationType getType() {
+ return type;
}
}
diff --git a/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxAttributeTypeFactory.groovy b/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxAttributeTypeFactory.groovy
deleted file mode 100644
index 18647d9..0000000
--- a/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxAttributeTypeFactory.groovy
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 IT Just working.
- * 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:
- * IT Just working - initial API and implementation
- *******************************************************************************/
-package com.minres.scviewer.database.text
-
-import com.minres.scviewer.database.AssociationType;
-import com.minres.scviewer.database.DataType
-import com.minres.scviewer.database.tx.ITxAttribute
-import com.minres.scviewer.database.tx.ITxAttributeType
-
-class TxAttributeTypeFactory {
- static final TxAttributeTypeFactory instance = new TxAttributeTypeFactory()
-
- def attributes = [:]
-
- private TxAttributeTypeFactory() {
- TxAttributeTypeFactory.metaClass.constructor = {-> instance }
- }
-
- ITxAttributeType getAttrType(String name, DataType dataType, AssociationType type){
- def key = name+":"+dataType.toString()
- ITxAttributeType res
- if(attributes.containsKey(key)){
- res=attributes[key]
- } else {
- res=new TxAttributeType(name, dataType, type)
- attributes[key]=res
- }
- return res
- }
-}
diff --git a/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxEvent.java b/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxEvent.java
index 75b3aef..c4c977d 100644
--- a/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxEvent.java
+++ b/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxEvent.java
@@ -7,21 +7,16 @@ import com.minres.scviewer.database.tx.ITxEvent;
class TxEvent implements ITxEvent {
+ final TextDbLoader loader;
+
final EventKind kind;
- final ITx transaction;
+ final Long 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();
+ TxEvent(TextDbLoader loader, EventKind kind, Long transaction, Long time) {
+ this.loader=loader;
this.kind = kind;
this.transaction = transaction;
this.time = time;
@@ -30,13 +25,13 @@ class TxEvent implements ITxEvent {
@Override
public
ITxEvent duplicate() throws CloneNotSupportedException {
- return new TxEvent(kind, transaction, time);
+ return new TxEvent(loader, kind, transaction, time);
}
@Override
public
String toString() {
- return kind.toString()+"@"+time+" of tx #"+transaction.getId();
+ return kind.toString()+"@"+time+" of tx #"+transaction;
}
@Override
@@ -56,6 +51,6 @@ class TxEvent implements ITxEvent {
@Override
public ITx getTransaction() {
- return transaction;
+ return loader.getTransaction(transaction);
}
}
diff --git a/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxGenerator.groovy b/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxGenerator.groovy
deleted file mode 100644
index f51a70c..0000000
--- a/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxGenerator.groovy
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 IT Just working.
- * 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:
- * IT Just working - initial API and implementation
- *******************************************************************************/
-package com.minres.scviewer.database.text
-
-import java.util.ArrayList;
-import java.util.List;
-
-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
- IWaveform stream
- String name
- Boolean active = false
- ArrayList transactions=[]
-
- ArrayList begin_attrs = []
- int begin_attrs_idx = 0
- ArrayList end_attrs= []
- int end_attrs_idx = 0
-
- TxGenerator(int id, TxStream stream, name){
- this.id=id
- this.stream=stream
- this.name=name
- }
-
- IWaveform getStream(){
- return stream;
- }
-
- List getTransactions(){
- return transactions
- }
-
- Boolean isActive() {return active};
-
-}
diff --git a/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxGenerator.java b/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxGenerator.java
new file mode 100644
index 0000000..662fd80
--- /dev/null
+++ b/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxGenerator.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2012 IT Just working.
+ * 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:
+ * IT Just working - initial API and implementation
+ *******************************************************************************/
+package com.minres.scviewer.database.text;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.minres.scviewer.database.HierNode;
+import com.minres.scviewer.database.IWaveform;
+import com.minres.scviewer.database.tx.ITxGenerator;
+
+class TxGenerator extends HierNode implements ITxGenerator {
+
+ Long id;
+
+ IWaveform stream;
+
+ Boolean active = false;
+
+ List beginAttrs = new ArrayList<>();
+
+ List endAttrs= new ArrayList<>();
+
+ TxGenerator(Long id, TxStream stream, String name){
+ super(name, stream);
+ this.id=id;
+ this.stream=stream;
+ }
+
+ @Override
+ public Long getId() {
+ return id;
+ }
+
+ @Override
+ public IWaveform getStream(){
+ return stream;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ public List getBeginAttrs() {
+ return beginAttrs;
+ }
+
+ public List getEndAttrs() {
+ return endAttrs;
+ }
+
+ Boolean isActive() {return active;}
+
+}
diff --git a/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxRelation.java b/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxRelation.java
index 6990b4f..943fb05 100644
--- a/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxRelation.java
+++ b/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxRelation.java
@@ -5,31 +5,29 @@ import com.minres.scviewer.database.tx.ITx;
import com.minres.scviewer.database.tx.ITxRelation;
class TxRelation implements ITxRelation {
- final Tx source;
+
+ final TextDbLoader loader;
- final Tx target;
+ final ScvRelation scvRelation;
- final RelationType relationType;
-
- public TxRelation(RelationType relationType, Tx source, Tx target) {
- this.source = source;
- this.target = target;
- this.relationType = relationType;
+ public TxRelation(TextDbLoader loader, ScvRelation scvRelation) {
+ this.loader = loader;
+ this.scvRelation = scvRelation;
}
@Override
public RelationType getRelationType() {
- return relationType;
+ return scvRelation.relationType;
}
@Override
public ITx getSource() {
- return source;
+ return loader.getTransaction(scvRelation.source);
}
@Override
public ITx getTarget() {
- return target;
+ return loader.getTransaction(scvRelation.target);
}
}
diff --git a/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxStream.groovy b/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxStream.groovy
deleted file mode 100644
index 619e334..0000000
--- a/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxStream.groovy
+++ /dev/null
@@ -1,135 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 IT Just working.
- * 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:
- * IT Just working - initial API and implementation
- *******************************************************************************/
-package com.minres.scviewer.database.text
-
-import java.beans.PropertyChangeListener;
-import java.util.Collection;
-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.IWaveform;
-import com.minres.scviewer.database.IWaveformDb
-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
-
-class TxStream extends HierNode implements IWaveform {
-
- Long id
-
- IWaveformDb database
-
- String fullName
-
- def generators = []
-
- int maxConcurrency
-
- private TreeMap events
-
- TxStream(TextDbLoader loader, int id, String name, String kind){
- super(name)
- this.id=id
- this.database=loader.db
- this.fullName=name
- this.maxConcurrency=0
- //events = new TreeMap>()
- events = loader.mapDb.treeMap(name).keySerializer(Serializer.LONG).createOrOpen();
- }
-
- List getGenerators(){
- return generators as List
- }
-
- @Override
- public IWaveformDb getDb() {
- return database
- }
-
- @Override
- public int getWidth() {
- if(!maxConcurrency){
- generators.each {TxGenerator generator ->
- generator.transactions.each{ Tx 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{IEvent event ->event.kind==EventKind.BEGIN}
- starts.each {ITxEvent event ->
- Tx tx = event.transaction
- def rowIdx = 0
- for(rowIdx=0; rowIdxtx.beginTime; rowIdx++);
- if(rowendtime.size<=rowIdx)
- rowendtime< getEvents() {
- return events;
- }
-
- @Override
- public IEvent[] getEventsAtTime(Long time) {
- return events.get(time);
- }
-
- @Override
- public boolean isSame(IWaveform other) {
- return(other instanceof TxStream && this.getId()==other.getId());
- }
-
- @Override
- public IEvent[] getEventsBeforeTime(Long time) {
- Entry e = events.floorEntry(time);
- if(e==null)
- return null;
- else
- return events.floorEntry(time).getValue();
- }
-
- @Override
- public WaveformType getType() {
- return WaveformType.TRANSACTION;
- }
-
-}
diff --git a/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxStream.java b/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxStream.java
new file mode 100644
index 0000000..344a545
--- /dev/null
+++ b/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TxStream.java
@@ -0,0 +1,138 @@
+/*******************************************************************************
+ * Copyright (c) 2012 IT Just working.
+ * 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:
+ * IT Just working - initial API and implementation
+ *******************************************************************************/
+package com.minres.scviewer.database.text;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map.Entry;
+import java.util.NavigableMap;
+import java.util.TreeMap;
+
+import com.minres.scviewer.database.EventKind;
+import com.minres.scviewer.database.HierNode;
+import com.minres.scviewer.database.IEvent;
+import com.minres.scviewer.database.IWaveform;
+import com.minres.scviewer.database.WaveformType;
+import com.minres.scviewer.database.tx.ITxEvent;
+import com.minres.scviewer.database.tx.ITxGenerator;
+
+class TxStream extends HierNode implements IWaveform {
+
+ private Long id;
+
+ private TextDbLoader loader;
+
+ final String kind;
+
+ private int maxConcurrency = 0;
+
+ private int concurrency = 0;
+
+ boolean concurrencyCalculated = false;
+
+ void setConcurrency(int concurrency) {
+ this.concurrency = concurrency;
+ if(concurrency>maxConcurrency)
+ maxConcurrency = concurrency;
+ }
+
+ int getConcurrency() {
+ return this.concurrency;
+ }
+
+ TreeMap events = new TreeMap<>();
+
+ TxStream(TextDbLoader loader, Long id, String name, String kind){
+ super(name);
+ this.id=id;
+ this.loader=loader;
+ this.kind=kind;
+ }
+
+ List getGenerators(){
+ return new ArrayList<>(loader.txGenerators.values());
+ }
+
+ @Override
+ public int getWidth() {
+ return maxConcurrency;
+ }
+
+ public void addEvent(ITxEvent evt) {
+ if(!events.containsKey(evt.getTime()))
+ events.put(evt.getTime(), new IEvent[] {evt});
+ else {
+ IEvent[] evts = events.get(evt.getTime());
+ IEvent[] newEvts = Arrays.copyOf(evts, evts.length+1);
+ newEvts[evts.length]=evt;
+ events.put(evt.getTime(), newEvts);
+ }
+ }
+
+ @Override
+ public NavigableMap getEvents() {
+ if(!concurrencyCalculated) calculateConcurrency();
+ return events;
+ }
+
+ @Override
+ public IEvent[] getEventsAtTime(Long time) {
+ if(!concurrencyCalculated) calculateConcurrency();
+ return events.get(time);
+ }
+
+ @Override
+ public boolean isSame(IWaveform other) {
+ return(other instanceof TxStream && this.getId().equals(other.getId()));
+ }
+
+ @Override
+ public IEvent[] getEventsBeforeTime(Long time) {
+ if(!concurrencyCalculated)
+ calculateConcurrency();
+ Entry e = events.floorEntry(time);
+ if(e==null)
+ return new IEvent[] {};
+ else
+ return events.floorEntry(time).getValue();
+ }
+
+ @Override
+ public WaveformType getType() {
+ return WaveformType.TRANSACTION;
+ }
+
+ @Override
+ public Long getId() {
+ return id;
+ }
+
+ synchronized void calculateConcurrency() {
+ if(concurrencyCalculated) return;
+ ArrayList rowendtime = new ArrayList<>();
+ events.entrySet().stream().forEach( entry -> {
+ IEvent[] values = entry.getValue();
+ Arrays.asList(values).stream().filter(e->e.getKind()==EventKind.BEGIN).forEach(evt -> {
+ Tx tx = (Tx) ((TxEvent)evt).getTransaction();
+ int rowIdx = 0;
+ for(; rowIdxtx.getBeginTime(); rowIdx++);
+ if(rowendtime.size()<=rowIdx)
+ rowendtime.add(tx.getEndTime());
+ else
+ rowendtime.set(rowIdx, tx.getEndTime());
+ tx.setConcurrencyIndex(rowIdx);
+ });
+ });
+ concurrencyCalculated=true;
+ }
+
+}
diff --git a/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/IWaveformView.java b/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/IWaveformView.java
index 9830894..d166cc0 100644
--- a/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/IWaveformView.java
+++ b/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/IWaveformView.java
@@ -22,6 +22,7 @@ import org.eclipse.swt.widgets.Control;
import com.minres.scviewer.database.IWaveform;
import com.minres.scviewer.database.RelationType;
+import com.minres.scviewer.database.RelationTypeFactory;
public interface IWaveformView extends PropertyChangeListener, ISelectionProvider{
@@ -29,7 +30,7 @@ public interface IWaveformView extends PropertyChangeListener, ISelectionProvide
String MARKER_PROPERTY = "marker_time";
- public static final RelationType NEXT_PREV_IN_STREAM = RelationType.create("Prev/Next in stream");
+ public static final RelationType NEXT_PREV_IN_STREAM = RelationTypeFactory.create("Prev/Next in stream");
public void addSelectionChangedListener(ISelectionChangedListener listener);
diff --git a/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/StreamPainter.java b/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/StreamPainter.java
index 2b06b4b..6ca51b5 100644
--- a/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/StreamPainter.java
+++ b/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/StreamPainter.java
@@ -84,17 +84,20 @@ public class StreamPainter extends TrackPainter{
NavigableMap entries = stream.getEvents().subMap(firstTx.getKey(), true, lastTx.getKey(), true);
boolean highlighed=false;
proj.setForeground(this.waveCanvas.styleProvider.getColor(WaveformColors.LINE));
-
+ long selectedId=waveCanvas.currentSelection!=null? waveCanvas.currentSelection.getId():-1;
for(Entry entry: entries.entrySet())
for(IEvent evt:entry.getValue()){
- ITxEvent txEvent = (ITxEvent) evt;
- if(txEvent.getKind()==EventKind.BEGIN)
- seenTx.add(txEvent.getTransaction());
- if(txEvent.getKind()==EventKind.END){
- ITx tx = txEvent.getTransaction();
- highlighed|=waveCanvas.currentSelection!=null && waveCanvas.currentSelection.equals(tx);
- drawTx(proj, area, tx, false);
+ ITx tx = ((ITxEvent) evt).getTransaction();
+ highlighed|=selectedId==tx.getId();
+ switch(evt.getKind()) {
+ case BEGIN:
+ seenTx.add(tx);
+ break;
+ case END:
seenTx.remove(tx);
+ case SINGLE:
+ drawTx(proj, area, tx, false);
+ break;
}
}
for(ITx tx:seenTx){
@@ -164,7 +167,8 @@ public class StreamPainter extends TrackPainter{
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){
+ if((evt.getKind()==EventKind.BEGIN || evt.getKind()==EventKind.SINGLE)&&
+ tx.getConcurrencyIndex()==lane && tx.getBeginTime()<=timePoint && tx.getEndTime()>=timePoint){
return ((ITxEvent)evt).getTransaction();
}
}
@@ -175,7 +179,8 @@ public class StreamPainter extends TrackPainter{
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){
+ if((evt.getKind()==EventKind.BEGIN || evt.getKind()==EventKind.SINGLE) &&
+ tx.getConcurrencyIndex()==lane && tx.getBeginTime()<=timePointHigh && tx.getEndTime()>=timePoint){
return ((ITxEvent)evt).getTransaction();
}
}
diff --git a/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/WaveformView.java b/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/WaveformView.java
index 205ad87..145ac77 100644
--- a/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/WaveformView.java
+++ b/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/WaveformView.java
@@ -116,9 +116,9 @@ public class WaveformView implements IWaveformView {
final WaveformCanvas waveformCanvas;
final ToolTipHandler toolTipHandler;
-
+
private boolean revealSelected=false;
-
+
private Composite top;
protected ObservableList streams;
@@ -128,13 +128,13 @@ public class WaveformView implements IWaveformView {
private int tracksVerticalHeight;
private TreeMap trackVerticalOffset;
-
+
private IWaveformStyleProvider styleProvider;
protected TrackEntry lastClickedEntry;
protected MouseListener nameValueMouseListener = new MouseAdapter() {
-
+
@Override
public void mouseDown(MouseEvent e) {
if (e.button == 1) {
@@ -146,7 +146,7 @@ public class WaveformView implements IWaveformView {
if(topMenu!=null) topMenu.setVisible(true);
}
}
-
+
@Override
public void mouseUp(MouseEvent e) {
if (e.button == 1) {
@@ -168,7 +168,7 @@ public class WaveformView implements IWaveformView {
}
}
};
-
+
class WaveformMouseListener implements PaintListener, Listener {
Point start;
Point end;
@@ -178,13 +178,13 @@ public class WaveformView implements IWaveformView {
@Override
public void paintControl(PaintEvent e) {
if(down) {
- GC gc = e.gc;
- gc.setAlpha(128);
- int minX = Math.min(start.x, end.x);
- int width = Math.max(start.x, end.x) - minX;
- int yTop = waveformCanvas.getRulerHeight();
- int yBottom = waveformCanvas.getSize().y;
- gc.fillRectangle(minX, yTop, width,yBottom);
+ GC gc = e.gc;
+ gc.setAlpha(128);
+ int minX = Math.min(start.x, end.x);
+ int width = Math.max(start.x, end.x) - minX;
+ int yTop = waveformCanvas.getRulerHeight();
+ int yBottom = waveformCanvas.getSize().y;
+ gc.fillRectangle(minX, yTop, width,yBottom);
}
}
@@ -243,7 +243,7 @@ public class WaveformView implements IWaveformView {
asyncUpdate(e.widget);
}
}
-
+
protected long snapOffsetToEvent(Point p) {
long time= waveformCanvas.getTimeForOffset(p.x);
long scaling=5*waveformCanvas.getScaleFactor();
@@ -304,7 +304,7 @@ public class WaveformView implements IWaveformView {
default:
break;
}
-
+
}
}
@@ -312,7 +312,7 @@ public class WaveformView implements IWaveformView {
public WaveformView(Composite parent, IWaveformStyleProvider styleProvider) {
this.styleProvider=styleProvider;
-
+
pcs=new PropertyChangeSupport(this);
trackVerticalOffset = new TreeMap<>();
@@ -326,7 +326,7 @@ public class WaveformView implements IWaveformView {
SashForm topSash = new SashForm(top, SWT.SMOOTH);
topSash.setBackground(topSash.getDisplay().getSystemColor(SWT.COLOR_GRAY));
-
+
Composite namePane = new Composite(topSash, SWT.NONE);
Composite rightPane = new Composite(topSash, SWT.NONE);
rightPane.setLayout(new FillLayout(SWT.HORIZONTAL));
@@ -339,7 +339,7 @@ public class WaveformView implements IWaveformView {
// create the name pane
createTextPane(namePane, "Name");
-
+
namePaneHeader= namePane.getChildren()[0];
namePane.setBackground(SWTResourceManager.getColor(SWT.COLOR_WIDGET_BACKGROUND));
@@ -373,7 +373,7 @@ public class WaveformView implements IWaveformView {
nameListScrolled.setContent(nameList);
createTextPane(valuePane, "Value");
-
+
valuePane.setBackground(SWTResourceManager.getColor(SWT.COLOR_WIDGET_BACKGROUND));
valueListScrolled = new ScrolledComposite(valuePane, SWT.H_SCROLL | SWT.V_SCROLL);
valueListScrolled.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
@@ -410,7 +410,7 @@ public class WaveformView implements IWaveformView {
waveformCanvas.addListener(SWT.MouseUp,waveformMouseListener);
waveformCanvas.addListener(SWT.MouseMove,waveformMouseListener);
waveformCanvas.addListener(SWT.MouseWheel, waveformMouseListener);
-
+
nameListScrolled.getVerticalBar().addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
@@ -446,7 +446,7 @@ public class WaveformView implements IWaveformView {
createStreamDropTarget(valueList);
createWaveformDragSource(waveformCanvas);
createWaveformDropTarget(waveformCanvas);
-
+
toolTipHandler = new ToolTipHandler(parent.getShell());
toolTipHandler.activateHoverHelp(waveformCanvas);
}
@@ -478,10 +478,10 @@ public class WaveformView implements IWaveformView {
if ("size".equals(pce.getPropertyName()) || "content".equals(pce.getPropertyName())) {
if(revealSelected) {
waveformCanvas.getDisplay().asyncExec(() ->{
- update();
- currentWaveformSelection.stream().forEach(e -> waveformCanvas.reveal(e.waveform));
- valueList.redraw();
- nameList.redraw();
+ update();
+ currentWaveformSelection.stream().forEach(e -> waveformCanvas.reveal(e.waveform));
+ valueList.redraw();
+ nameList.redraw();
});
revealSelected=false;
} else
@@ -574,11 +574,11 @@ public class WaveformView implements IWaveformView {
do {
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()]= ((ITxEvent)evt).getTransaction();
- }
+ ITx tx=((ITxEvent)evt).getTransaction();
+ if((evt.getKind()==EventKind.BEGIN || evt.getKind()==EventKind.SINGLE) && tx.getBeginTime()<=time && tx.getEndTime()>=time){
+ if(resultsList[tx.getConcurrencyIndex()]==null)
+ resultsList[tx.getConcurrencyIndex()]= ((ITxEvent)evt).getTransaction();
+ }
}
}
firstTx=entry.waveform.getEvents().lowerEntry(firstTx.getKey());
@@ -600,8 +600,8 @@ public class WaveformView implements IWaveformView {
valueListScrolled.setMinSize(width, tracksVerticalHeight);
valueListScrolled.redraw();
}
-
-
+
+
private boolean isArrayFull(Object[] array){
for(Object o:array){
if(o==null) return false;
@@ -691,7 +691,7 @@ public class WaveformView implements IWaveformView {
public void addToSelection(ISelection selection, boolean showIfNeeded) {
setSelection(selection, true, showIfNeeded);
}
-
+
public void setSelection(ISelection selection, boolean add, boolean addIfNeeded) {
boolean selectionChanged = false;
currentWaveformSelection.forEach(e->e.selected=false);
@@ -703,7 +703,7 @@ public class WaveformView implements IWaveformView {
} else {
if(!add) currentWaveformSelection.clear();
for(Object sel:((IStructuredSelection) selection).toArray()){
- if (sel instanceof ITx && currentTxSelection != sel){
+ if (sel instanceof ITx){
ITx txSel = (ITx) sel;
TrackEntry trackEntry = getEntryForStream(txSel.getStream());
if(trackEntry==null && addIfNeeded){
@@ -711,6 +711,8 @@ public class WaveformView implements IWaveformView {
streams.add(trackEntry);
}
currentTxSelection = txSel;
+ currentWaveformSelection.clear();
+ currentWaveformSelection.add(trackEntry);
selectionChanged = true;
} else if (sel instanceof TrackEntry && !currentWaveformSelection.contains(sel)) {
currentWaveformSelection.add((TrackEntry)sel);
@@ -754,12 +756,12 @@ public class WaveformView implements IWaveformView {
moveSelection(direction, NEXT_PREV_IN_STREAM) ;
else {
if(currentWaveformSelection.size()==1) {
- int idx = streams.indexOf(currentWaveformSelection.get(0));
- if(direction==GotoDirection.UP && idx>0) {
- setSelection(new StructuredSelection(streams.get(idx-1)));
- } else if(direction==GotoDirection.DOWN && idx<(streams.size()-1)) {
- setSelection(new StructuredSelection(streams.get(idx+1)));
- }
+ int idx = streams.indexOf(currentWaveformSelection.get(0));
+ if(direction==GotoDirection.UP && idx>0) {
+ setSelection(new StructuredSelection(streams.get(idx-1)));
+ } else if(direction==GotoDirection.DOWN && idx<(streams.size()-1)) {
+ setSelection(new StructuredSelection(streams.get(idx+1)));
+ }
}
}
}
@@ -769,32 +771,29 @@ public class WaveformView implements IWaveformView {
*/
@Override
public void moveSelection(GotoDirection direction, RelationType relationType) {
- TrackEntry selectedWaveform=null;
- if(currentTxSelection!=null)
- selectedWaveform = getEntryForStream(currentTxSelection.getStream());
- else if(currentWaveformSelection.size()!=1) return;
- if(selectedWaveform==null)
- selectedWaveform = currentWaveformSelection.get(1);
- if (selectedWaveform!=null && selectedWaveform.waveform.getType()==WaveformType.TRANSACTION && currentTxSelection!=null) {
+ if(currentWaveformSelection.size() !=1 && currentTxSelection==null) return;
+ TrackEntry selectedWaveform=currentWaveformSelection.size() == 1?
+ currentWaveformSelection.get(0) : getEntryForStream(currentTxSelection.getStream());
+ if(selectedWaveform.waveform.getType()==WaveformType.TRANSACTION && currentTxSelection!=null) {
if(relationType.equals(IWaveformView.NEXT_PREV_IN_STREAM)){
ITx transaction = null;
if (direction == GotoDirection.NEXT) {
- ITxEvent[] thisEntryList = (ITxEvent[]) selectedWaveform.waveform.getEvents().get(currentTxSelection.getBeginTime());
+ IEvent[] eventsList = selectedWaveform.waveform.getEvents().get(currentTxSelection.getBeginTime());
boolean meFound=false;
- for (ITxEvent evt : thisEntryList) {
- if (evt.getKind() == EventKind.BEGIN) {
+ for (IEvent evt : eventsList) {
+ if (evt instanceof ITxEvent && evt.getKind() == EventKind.BEGIN || evt.getKind()==EventKind.SINGLE) {
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 entry = selectedWaveform.waveform.getEvents().higherEntry(currentTxSelection.getBeginTime());
if (entry != null) do {
for (IEvent evt : entry.getValue()) {
- if (evt instanceof ITxEvent && evt.getKind() == EventKind.BEGIN) {
+ if (evt instanceof ITxEvent && (evt.getKind() == EventKind.BEGIN || evt.getKind()==EventKind.SINGLE)) {
transaction = ((ITxEvent)evt).getTransaction();
break;
}
@@ -804,10 +803,10 @@ public class WaveformView implements IWaveformView {
} while (entry != null && transaction == null);
}
} else if (direction == GotoDirection.PREV) {
- IEvent[] thisEntryList = selectedWaveform.waveform.getEvents().get(currentTxSelection.getBeginTime());
+ IEvent[] eventsList = selectedWaveform.waveform.getEvents().get(currentTxSelection.getBeginTime());
boolean meFound=false;
- for (IEvent evt : Lists.reverse(Arrays.asList(thisEntryList))) {
- if (evt instanceof ITxEvent && evt.getKind() == EventKind.BEGIN) {
+ for (IEvent evt : Lists.reverse(Arrays.asList(eventsList))) {
+ if (evt instanceof ITxEvent && (evt.getKind() == EventKind.BEGIN || evt.getKind()==EventKind.SINGLE)) {
if(meFound){
transaction = ((ITxEvent)evt).getTransaction();
break;
@@ -817,31 +816,33 @@ public class WaveformView implements IWaveformView {
}
if (transaction == null){
Entry entry = selectedWaveform.waveform.getEvents().lowerEntry(currentTxSelection.getBeginTime());
- if (entry != null)
- do {
- for (IEvent evt : Lists.reverse(Arrays.asList(thisEntryList))) {
- if (evt instanceof ITxEvent && evt.getKind() == EventKind.BEGIN) {
- transaction = ((ITxEvent)evt).getTransaction();
- break;
- }
+ if (entry != null) do {
+ for (IEvent evt : Lists.reverse(Arrays.asList(entry.getValue()))) {
+ if (evt instanceof ITxEvent && (evt.getKind() == EventKind.BEGIN || evt.getKind()==EventKind.SINGLE)) {
+ transaction = ((ITxEvent)evt).getTransaction();
+ break;
}
- if (transaction == null)
- entry = selectedWaveform.waveform.getEvents().lowerEntry(entry.getKey());
- } while (entry != null && transaction == null);
+ }
+ if (transaction == null)
+ entry = selectedWaveform.waveform.getEvents().lowerEntry(entry.getKey());
+ } while (entry != null && transaction == null);
}
}
if (transaction != null) {
setSelection(new StructuredSelection(transaction));
}
} else {
+ ITxRelation tx = null;
if (direction == GotoDirection.NEXT) {
Collection outRel=currentTxSelection.getOutgoingRelations();
- ITxRelation tx = selectTxToNavigateTo(outRel, relationType, true);
- if(tx!=null) setSelection(new StructuredSelection(tx.getTarget()), true);
+ tx = selectTxToNavigateTo(outRel, relationType, true);
+ if(tx!=null)
+ setSelection(new StructuredSelection(tx.getTarget()), true);
} else if (direction == GotoDirection.PREV) {
Collection inRel=currentTxSelection.getIncomingRelations();
- ITxRelation tx = selectTxToNavigateTo(inRel, relationType, false);
- if(tx!=null) setSelection(new StructuredSelection(tx.getSource()), true);
+ tx = selectTxToNavigateTo(inRel, relationType, false);
+ if(tx!=null)
+ setSelection(new StructuredSelection(tx.getSource()), true);
}
}
}
@@ -863,7 +864,7 @@ public class WaveformView implements IWaveformView {
}
}
}
-
+
private boolean streamsVisible(ITxRelation relation) {
final IWaveform src = relation.getSource().getStream();
final IWaveform tgt = relation.getTarget().getStream();
@@ -1175,7 +1176,7 @@ public class WaveformView implements IWaveformView {
public List