adapt ui to database API

This commit is contained in:
Eyck Jentzsch 2021-01-14 23:14:22 +01:00
parent 6530362b89
commit 16de83616a
10 changed files with 163 additions and 122 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -166,6 +166,8 @@ public class TxDbLabelProvider implements ILabelProvider {
public String getText(Object element) { public String getText(Object element) {
if(element instanceof IWaveformDb){ if(element instanceof IWaveformDb){
IWaveformDb db = (IWaveformDb) element; IWaveformDb db = (IWaveformDb) element;
if(db.getName()== null)
return "";
return db.getName()+(db.isLoaded()?"":" (loading)"); return db.getName()+(db.isLoaded()?"":" (loading)");
} else } else
return ((IHierNode)element).getName(); return ((IHierNode)element).getName();

View File

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

View File

@ -58,7 +58,7 @@
<!-- Bintray package name --> <!-- Bintray package name -->
<bintrayPackage>SCViewer</bintrayPackage> <bintrayPackage>SCViewer</bintrayPackage>
<!-- Bintray package version number --> <!-- Bintray package version number -->
<bintrayVersion>${parsedVersion.majorVersion}.${parsedVersion.minorVersion}</bintrayVersion> <bintrayVersion>${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}</bintrayVersion>
<!-- remove any preexisting files --> <!-- remove any preexisting files -->
<performDestroy>true</performDestroy> <performDestroy>true</performDestroy>
<!-- information used when creating the package --> <!-- information used when creating the package -->