- Fixed navigation and selection issue
- added some null checking - corrected direction of releations
This commit is contained in:
parent
54fb59db04
commit
af1f21cac9
|
@ -85,6 +85,7 @@ public class SQLiteDbLoader implements IWaveformDbLoader {
|
||||||
@Override
|
@Override
|
||||||
public boolean load(IWaveformDb db, File file) throws Exception {
|
public boolean load(IWaveformDb db, File file) throws Exception {
|
||||||
this.db=db;
|
this.db=db;
|
||||||
|
streams=null;
|
||||||
FileInputStream fis = new FileInputStream(file);
|
FileInputStream fis = new FileInputStream(file);
|
||||||
byte[] buffer = new byte[x.length];
|
byte[] buffer = new byte[x.length];
|
||||||
int read = fis.read(buffer, 0, x.length);
|
int read = fis.read(buffer, 0, x.length);
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package com.minres.scviewer.database.swt;
|
package com.minres.scviewer.database.swt;
|
||||||
|
|
||||||
import java.awt.PageAttributes.OriginType;
|
|
||||||
import java.beans.PropertyChangeEvent;
|
import java.beans.PropertyChangeEvent;
|
||||||
import java.beans.PropertyChangeListener;
|
import java.beans.PropertyChangeListener;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -60,11 +59,11 @@ import org.eclipse.swt.widgets.Event;
|
||||||
import org.eclipse.swt.widgets.Label;
|
import org.eclipse.swt.widgets.Label;
|
||||||
import org.eclipse.swt.widgets.Listener;
|
import org.eclipse.swt.widgets.Listener;
|
||||||
import org.eclipse.swt.widgets.ScrollBar;
|
import org.eclipse.swt.widgets.ScrollBar;
|
||||||
import org.eclipse.swt.widgets.Text;
|
|
||||||
import org.eclipse.wb.swt.SWTResourceManager;
|
import org.eclipse.wb.swt.SWTResourceManager;
|
||||||
|
|
||||||
import swing2swt.layout.BorderLayout;
|
import swing2swt.layout.BorderLayout;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
import com.minres.scviewer.database.ISignal;
|
import com.minres.scviewer.database.ISignal;
|
||||||
import com.minres.scviewer.database.ITx;
|
import com.minres.scviewer.database.ITx;
|
||||||
import com.minres.scviewer.database.ITxEvent;
|
import com.minres.scviewer.database.ITxEvent;
|
||||||
|
@ -213,15 +212,17 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
|
||||||
nameListScrolled.getVerticalBar().addSelectionListener(new SelectionAdapter() {
|
nameListScrolled.getVerticalBar().addSelectionListener(new SelectionAdapter() {
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent e) {
|
||||||
int y = ((ScrollBar) e.widget).getSelection();
|
int y = ((ScrollBar) e.widget).getSelection();
|
||||||
valueListScrolled.setOrigin(valueListScrolled.getOrigin().x, y);
|
Point v = valueListScrolled.getOrigin();
|
||||||
trackList.setOrigin(trackList.getOrigin().x, y);
|
valueListScrolled.setOrigin(v.x, y);
|
||||||
|
Point t = trackList.getOrigin();
|
||||||
|
trackList.setOrigin(t.x, -y);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
valueListScrolled.getVerticalBar().addSelectionListener(new SelectionAdapter() {
|
valueListScrolled.getVerticalBar().addSelectionListener(new SelectionAdapter() {
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent e) {
|
||||||
int y = ((ScrollBar) e.widget).getSelection();
|
int y = ((ScrollBar) e.widget).getSelection();
|
||||||
nameListScrolled.setOrigin(nameListScrolled.getOrigin().x, y);
|
nameListScrolled.setOrigin(nameListScrolled.getOrigin().x, y);
|
||||||
trackList.setOrigin(trackList.getOrigin().x, y);
|
trackList.setOrigin(trackList.getOrigin().x, -y);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
trackList.addSelectionListener(new SelectionAdapter() {
|
trackList.addSelectionListener(new SelectionAdapter() {
|
||||||
|
@ -355,6 +356,11 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
|
||||||
public void setSelection(ISelection selection) {
|
public void setSelection(ISelection selection) {
|
||||||
boolean selectionChanged = false;
|
boolean selectionChanged = false;
|
||||||
if (selection instanceof IStructuredSelection) {
|
if (selection instanceof IStructuredSelection) {
|
||||||
|
if(((IStructuredSelection) selection).size()==0){
|
||||||
|
selectionChanged = currentSelection!=null||currentWaveformSelection!=null;
|
||||||
|
currentSelection = null;
|
||||||
|
currentWaveformSelection = null;
|
||||||
|
} else {
|
||||||
Object sel = ((IStructuredSelection) selection).getFirstElement();
|
Object sel = ((IStructuredSelection) selection).getFirstElement();
|
||||||
if (sel instanceof ITx && currentSelection != sel) {
|
if (sel instanceof ITx && currentSelection != sel) {
|
||||||
currentSelection = (ITx) sel;
|
currentSelection = (ITx) sel;
|
||||||
|
@ -365,6 +371,7 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
|
||||||
currentWaveformSelection = (IWaveform<? extends IWaveformEvent>) sel;
|
currentWaveformSelection = (IWaveform<? extends IWaveformEvent>) sel;
|
||||||
selectionChanged = true;
|
selectionChanged = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (currentSelection != null || currentWaveformSelection != null)
|
if (currentSelection != null || currentWaveformSelection != null)
|
||||||
selectionChanged = true;
|
selectionChanged = true;
|
||||||
|
@ -392,9 +399,20 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
|
||||||
ITxStream<ITxEvent> stream = (ITxStream<ITxEvent>) currentWaveformSelection;
|
ITxStream<ITxEvent> stream = (ITxStream<ITxEvent>) currentWaveformSelection;
|
||||||
ITx transaction = null;
|
ITx transaction = null;
|
||||||
if (direction == GotoDirection.NEXT) {
|
if (direction == GotoDirection.NEXT) {
|
||||||
|
List<ITxEvent> thisEntryList = stream.getEvents().get(currentSelection.getBeginTime());
|
||||||
|
boolean meFound=false;
|
||||||
|
for (ITxEvent evt : thisEntryList) {
|
||||||
|
if (evt.getType() == ITxEvent.Type.BEGIN) {
|
||||||
|
if(meFound){
|
||||||
|
transaction = evt.getTransaction();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
meFound|= evt.getTransaction().getId()==currentSelection.getId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (transaction == null){
|
||||||
Entry<Long, List<ITxEvent>> entry = stream.getEvents().higherEntry(currentSelection.getBeginTime());
|
Entry<Long, List<ITxEvent>> entry = stream.getEvents().higherEntry(currentSelection.getBeginTime());
|
||||||
if (entry != null)
|
if (entry != null) do {
|
||||||
do {
|
|
||||||
for (ITxEvent evt : entry.getValue()) {
|
for (ITxEvent evt : entry.getValue()) {
|
||||||
if (evt.getType() == ITxEvent.Type.BEGIN) {
|
if (evt.getType() == ITxEvent.Type.BEGIN) {
|
||||||
transaction = evt.getTransaction();
|
transaction = evt.getTransaction();
|
||||||
|
@ -404,13 +422,24 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
|
||||||
if (transaction == null)
|
if (transaction == null)
|
||||||
entry = stream.getEvents().higherEntry(entry.getKey());
|
entry = stream.getEvents().higherEntry(entry.getKey());
|
||||||
} while (entry != null && transaction == null);
|
} while (entry != null && transaction == null);
|
||||||
|
}
|
||||||
} else if (direction == GotoDirection.PREV) {
|
} else if (direction == GotoDirection.PREV) {
|
||||||
|
List<ITxEvent> thisEntryList = stream.getEvents().get(currentSelection.getBeginTime());
|
||||||
|
boolean meFound=false;
|
||||||
|
for (ITxEvent evt : Lists.reverse(thisEntryList)) {
|
||||||
|
if (evt.getType() == ITxEvent.Type.BEGIN) {
|
||||||
|
if(meFound){
|
||||||
|
transaction = evt.getTransaction();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
meFound|= evt.getTransaction().getId()==currentSelection.getId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (transaction == null){
|
||||||
Entry<Long, List<ITxEvent>> entry = stream.getEvents().lowerEntry(currentSelection.getBeginTime());
|
Entry<Long, List<ITxEvent>> entry = stream.getEvents().lowerEntry(currentSelection.getBeginTime());
|
||||||
if (entry != null)
|
if (entry != null)
|
||||||
do {
|
do {
|
||||||
System.out.println(currentSelection.getBeginTime() + " -> " + entry.getKey());
|
for (ITxEvent evt : Lists.reverse(entry.getValue())) {
|
||||||
for (ITxEvent evt : entry.getValue()) {
|
|
||||||
System.out.println("\t-> " + evt.toString());
|
|
||||||
if (evt.getType() == ITxEvent.Type.BEGIN) {
|
if (evt.getType() == ITxEvent.Type.BEGIN) {
|
||||||
transaction = evt.getTransaction();
|
transaction = evt.getTransaction();
|
||||||
break;
|
break;
|
||||||
|
@ -420,6 +449,7 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
|
||||||
entry = stream.getEvents().lowerEntry(entry.getKey());
|
entry = stream.getEvents().lowerEntry(entry.getKey());
|
||||||
} while (entry != null && transaction == null);
|
} while (entry != null && transaction == null);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (transaction != null) {
|
if (transaction != null) {
|
||||||
setSelection(new StructuredSelection(transaction));
|
setSelection(new StructuredSelection(transaction));
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,6 +63,9 @@ public class SignalPainter implements IWaveformPainter {
|
||||||
if(left.getValue() instanceof ISignalChangeSingle){
|
if(left.getValue() instanceof ISignalChangeSingle){
|
||||||
NavigableMap<Long, ? extends ISignalChange> entries=signal.getEvents().subMap(firstChange.getKey(), false, lastTx.getKey(), true);
|
NavigableMap<Long, ? extends ISignalChange> entries=signal.getEvents().subMap(firstChange.getKey(), false, lastTx.getKey(), true);
|
||||||
for(Entry<Long, ? extends ISignalChange> right:entries.entrySet()){
|
for(Entry<Long, ? extends ISignalChange> right:entries.entrySet()){
|
||||||
|
int xEnd= (int)(right.getKey()/this.waveCanvas.getScaleFactor());
|
||||||
|
int xBegin= (int)(left.getKey()/this.waveCanvas.getScaleFactor());
|
||||||
|
if(xEnd>xBegin){
|
||||||
int yOffset = this.waveCanvas.getTrackHeight()/2;
|
int yOffset = this.waveCanvas.getTrackHeight()/2;
|
||||||
Color color = this.waveCanvas.colors[WaveformCanvas.Colors.SIGNALX.ordinal()];
|
Color color = this.waveCanvas.colors[WaveformCanvas.Colors.SIGNALX.ordinal()];
|
||||||
switch(((ISignalChangeSingle) left.getValue()).getValue()){
|
switch(((ISignalChangeSingle) left.getValue()).getValue()){
|
||||||
|
@ -81,8 +84,7 @@ public class SignalPainter implements IWaveformPainter {
|
||||||
}
|
}
|
||||||
yOffset+=area.y;
|
yOffset+=area.y;
|
||||||
gc.setForeground(color);
|
gc.setForeground(color);
|
||||||
int xEnd= (int)(right.getKey()/this.waveCanvas.getScaleFactor());
|
gc.drawLine(xBegin, yOffset, xEnd, yOffset);
|
||||||
gc.drawLine((int)(left.getKey()/this.waveCanvas.getScaleFactor()), yOffset, xEnd, yOffset);
|
|
||||||
int yNext = this.waveCanvas.getTrackHeight()/2;
|
int yNext = this.waveCanvas.getTrackHeight()/2;
|
||||||
switch(((ISignalChangeSingle) right.getValue()).getValue()){
|
switch(((ISignalChangeSingle) right.getValue()).getValue()){
|
||||||
case '1':
|
case '1':
|
||||||
|
@ -94,6 +96,7 @@ public class SignalPainter implements IWaveformPainter {
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
gc.drawLine(xEnd, yOffset, xEnd, yNext);
|
gc.drawLine(xEnd, yOffset, xEnd, yNext);
|
||||||
|
}
|
||||||
left=right;
|
left=right;
|
||||||
}
|
}
|
||||||
} else if(left.getValue() instanceof ISignalChangeMulti){
|
} else if(left.getValue() instanceof ISignalChangeMulti){
|
||||||
|
|
|
@ -56,7 +56,7 @@ public class StreamPainter implements IWaveformPainter{
|
||||||
else
|
else
|
||||||
gc.setBackground(this.waveCanvas.colors[even?WaveformCanvas.Colors.TRACK_BG_EVEN.ordinal():WaveformCanvas.Colors.TRACK_BG_ODD.ordinal()]);
|
gc.setBackground(this.waveCanvas.colors[even?WaveformCanvas.Colors.TRACK_BG_EVEN.ordinal():WaveformCanvas.Colors.TRACK_BG_ODD.ordinal()]);
|
||||||
gc.setFillRule(SWT.FILL_EVEN_ODD);
|
gc.setFillRule(SWT.FILL_EVEN_ODD);
|
||||||
gc.fillRectangle(area);
|
gc.fillRectangle(0,0,area.width, area.height);
|
||||||
Entry<Long, ?> firstTx=stream.getEvents().floorEntry(area.x*waveCanvas.getScaleFactor());
|
Entry<Long, ?> firstTx=stream.getEvents().floorEntry(area.x*waveCanvas.getScaleFactor());
|
||||||
Entry<Long, ?> lastTx=stream.getEvents().ceilingEntry((area.x+area.width)*waveCanvas.getScaleFactor());
|
Entry<Long, ?> lastTx=stream.getEvents().ceilingEntry((area.x+area.width)*waveCanvas.getScaleFactor());
|
||||||
if(firstTx==null) firstTx = stream.getEvents().firstEntry();
|
if(firstTx==null) firstTx = stream.getEvents().firstEntry();
|
||||||
|
@ -125,7 +125,7 @@ public class StreamPainter implements IWaveformPainter{
|
||||||
Entry<Long, List<ITxEvent>> firstTx=stream.getEvents().floorEntry(point.x*waveCanvas.getScaleFactor());
|
Entry<Long, List<ITxEvent>> firstTx=stream.getEvents().floorEntry(point.x*waveCanvas.getScaleFactor());
|
||||||
if(firstTx!=null){
|
if(firstTx!=null){
|
||||||
do {
|
do {
|
||||||
ITx tx = getTxFromEntry(lane, firstTx);
|
ITx tx = getTxFromEntry(lane, point.x, firstTx);
|
||||||
if(tx!=null) return tx;
|
if(tx!=null) return tx;
|
||||||
firstTx=stream.getEvents().lowerEntry(firstTx.getKey());
|
firstTx=stream.getEvents().lowerEntry(firstTx.getKey());
|
||||||
}while(firstTx!=null);
|
}while(firstTx!=null);
|
||||||
|
@ -141,9 +141,20 @@ public class StreamPainter implements IWaveformPainter{
|
||||||
this.stream = stream;
|
this.stream = stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ITx getTxFromEntry(int lane, Entry<Long, List<ITxEvent>> firstTx) {
|
protected ITx getTxFromEntry(int lane, int offset, Entry<Long, List<ITxEvent>> firstTx) {
|
||||||
|
long timePoint=offset*waveCanvas.getScaleFactor();
|
||||||
for(ITxEvent evt:firstTx.getValue()){
|
for(ITxEvent evt:firstTx.getValue()){
|
||||||
if(evt.getType()==ITxEvent.Type.BEGIN && evt.getTransaction().getConcurrencyIndex()==lane){
|
ITx tx=evt.getTransaction();
|
||||||
|
if(evt.getType()==ITxEvent.Type.BEGIN && tx.getConcurrencyIndex()==lane && tx.getBeginTime()<=timePoint && tx.getEndTime()>=timePoint){
|
||||||
|
return evt.getTransaction();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// now with some fuzziness
|
||||||
|
timePoint=(offset-5)*waveCanvas.getScaleFactor();
|
||||||
|
long timePointHigh=(offset+5)*waveCanvas.getScaleFactor();
|
||||||
|
for(ITxEvent evt:firstTx.getValue()){
|
||||||
|
ITx tx=evt.getTransaction();
|
||||||
|
if(evt.getType()==ITxEvent.Type.BEGIN && tx.getConcurrencyIndex()==lane && tx.getBeginTime()<=timePointHigh && tx.getEndTime()>=timePoint){
|
||||||
return evt.getTransaction();
|
return evt.getTransaction();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -295,14 +295,7 @@ public class WaveformCanvas extends Canvas {
|
||||||
vertical.setThumb(ch);
|
vertical.setThumb(ch);
|
||||||
ruler.setScaleFactor(scaleFactor);
|
ruler.setScaleFactor(scaleFactor);
|
||||||
redraw();
|
redraw();
|
||||||
Event e = new Event();
|
fireSelectionEvent();
|
||||||
e.widget = this;
|
|
||||||
SelectionEvent ev = new SelectionEvent(e);
|
|
||||||
ev.x = origin.x;
|
|
||||||
ev.y = origin.y;
|
|
||||||
for (SelectionAdapter a : selectionListeners) {
|
|
||||||
a.widgetSelected(ev);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -386,4 +379,21 @@ public class WaveformCanvas extends Canvas {
|
||||||
public void removeSelectionListener(SelectionAdapter selectionAdapter) {
|
public void removeSelectionListener(SelectionAdapter selectionAdapter) {
|
||||||
selectionListeners.remove(selectionAdapter);
|
selectionListeners.remove(selectionAdapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
protected void fireSelectionEvent() {
|
||||||
|
Event e = new Event();
|
||||||
|
e.widget = this;
|
||||||
|
e.detail=SWT.SELECTED;
|
||||||
|
e.type=SWT.Selection;
|
||||||
|
SelectionEvent ev = new SelectionEvent(e);
|
||||||
|
ev.x = origin.x;
|
||||||
|
ev.y = origin.y;
|
||||||
|
for (SelectionAdapter a : selectionListeners) {
|
||||||
|
a.widgetSelected(ev);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -142,8 +142,8 @@ public class TextDbLoader implements IWaveformDbLoader{
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
case "tx_relation"://matcher = line =~ /^tx_relation\s+\"(\S+)\"\s+(\d+)\s+(\d+)$/
|
case "tx_relation"://matcher = line =~ /^tx_relation\s+\"(\S+)\"\s+(\d+)\s+(\d+)$/
|
||||||
Tx tr1= transactionsById[Integer.parseInt(tokens[2])]
|
Tx tr2= transactionsById[Integer.parseInt(tokens[2])]
|
||||||
Tx tr2= transactionsById[Integer.parseInt(tokens[3])]
|
Tx tr1= transactionsById[Integer.parseInt(tokens[3])]
|
||||||
def relType=tokens[1][1..-2]
|
def relType=tokens[1][1..-2]
|
||||||
if(!relationTypes.containsKey(relType)) relationTypes[relType]=new RelationType(relType)
|
if(!relationTypes.containsKey(relType)) relationTypes[relType]=new RelationType(relType)
|
||||||
def rel = new TxRelation(relationTypes[relType], tr1, tr2)
|
def rel = new TxRelation(relationTypes[relType], tr1, tr2)
|
||||||
|
|
|
@ -37,6 +37,7 @@ class Tx implements ITx {
|
||||||
this.stream=stream
|
this.stream=stream
|
||||||
this.generator=generator
|
this.generator=generator
|
||||||
this.beginTime=begin
|
this.beginTime=begin
|
||||||
|
this.endTime=begin
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -142,9 +142,9 @@ public class WaveformDb extends HierNode implements IWaveformDb {
|
||||||
|
|
||||||
private void updateMaxTime(IWaveform<?> waveform) {
|
private void updateMaxTime(IWaveform<?> waveform) {
|
||||||
Long last=0L;
|
Long last=0L;
|
||||||
if(waveform instanceof ITxStream<?>)
|
if(waveform instanceof ITxStream<?> && ((ITxStream<?>)waveform).getEvents().lastEntry()!=null)
|
||||||
last=((ITxStream<?>)waveform).getEvents().lastEntry().getKey();
|
last=((ITxStream<?>)waveform).getEvents().lastEntry().getKey();
|
||||||
else if(waveform instanceof ISignal<?>)
|
else if(waveform instanceof ISignal<?> && ((ISignal<?>)waveform).getEvents().lastEntry()!=null)
|
||||||
last=((ISignal<?>)waveform).getEvents().lastEntry().getKey();
|
last=((ISignal<?>)waveform).getEvents().lastEntry().getKey();
|
||||||
if(last>maxTime)
|
if(last>maxTime)
|
||||||
maxTime=last;
|
maxTime=last;
|
||||||
|
|
|
@ -358,7 +358,7 @@ static void relationCb(const scv_tr_handle& tr_1, const scv_tr_handle& tr_2, voi
|
||||||
if (tr_1.get_scv_tr_stream().get_scv_tr_db()->get_recording() == false) return;
|
if (tr_1.get_scv_tr_stream().get_scv_tr_db()->get_recording() == false) return;
|
||||||
try {
|
try {
|
||||||
queryBuilder.str("");
|
queryBuilder.str("");
|
||||||
queryBuilder << "INSERT INTO " TX_RELATION_TABLE " (name,src,sink)"
|
queryBuilder << "INSERT INTO " TX_RELATION_TABLE " (name,sink,src)"
|
||||||
<< "values ('" << tr_1.get_scv_tr_stream().get_scv_tr_db()->get_relation_name(relation_handle) << "',"
|
<< "values ('" << tr_1.get_scv_tr_stream().get_scv_tr_db()->get_relation_name(relation_handle) << "',"
|
||||||
<< tr_1.get_id() << ","<< tr_2.get_id() << ");";
|
<< tr_1.get_id() << ","<< tr_2.get_id() << ");";
|
||||||
db.exec(queryBuilder.str().c_str());
|
db.exec(queryBuilder.str().c_str());
|
||||||
|
|
Loading…
Reference in New Issue