refactor internal transaction representation
This commit is contained in:
@ -84,17 +84,20 @@ public class StreamPainter extends TrackPainter{
|
||||
NavigableMap<Long, IEvent[]> 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<Long, IEvent[]> entry: entries.entrySet())
|
||||
for(IEvent evt:entry.getValue()){
|
||||
ITxEvent txEvent = (ITxEvent) evt;
|
||||
if(txEvent.getKind()==EventKind.BEGIN)
|
||||
seenTx.add(txEvent.getTransaction());
|
||||
if(txEvent.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){
|
||||
|
@ -116,9 +116,9 @@ public class WaveformView implements IWaveformView {
|
||||
final WaveformCanvas waveformCanvas;
|
||||
|
||||
final ToolTipHandler toolTipHandler;
|
||||
|
||||
|
||||
private boolean revealSelected=false;
|
||||
|
||||
|
||||
private Composite top;
|
||||
|
||||
protected ObservableList<TrackEntry> streams;
|
||||
@ -128,13 +128,13 @@ public class WaveformView implements IWaveformView {
|
||||
private int tracksVerticalHeight;
|
||||
|
||||
private TreeMap<Integer, TrackEntry> 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 && 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);
|
||||
@ -754,12 +754,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)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -863,7 +863,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 +1175,7 @@ public class WaveformView implements IWaveformView {
|
||||
public List<Object> getElementsAt(Point pt){
|
||||
return waveformCanvas.getElementsAt(pt);
|
||||
}
|
||||
|
||||
|
||||
private void createWaveformDragSource(final Canvas canvas) {
|
||||
Transfer[] types = new Transfer[] { LocalSelectionTransfer.getTransfer() };
|
||||
DragSource dragSource = new DragSource(canvas, DND.DROP_MOVE);
|
||||
@ -1201,15 +1201,15 @@ public class WaveformView implements IWaveformView {
|
||||
}
|
||||
}
|
||||
});
|
||||
// int style = SWT.MULTI | SWT.WRAP | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER;
|
||||
// final StyledText text = new StyledText(waveformCanvas, style);
|
||||
// text.setText("Dragging");
|
||||
// dragSource.setDragSourceEffect(new DragSourceEffect(text) {
|
||||
// @Override
|
||||
// public void dragStart(DragSourceEvent event) {
|
||||
// event.image = waveformCanvas.getDisplay().getSystemImage(SWT.ICON_WARNING);
|
||||
// }
|
||||
// });
|
||||
// int style = SWT.MULTI | SWT.WRAP | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER;
|
||||
// final StyledText text = new StyledText(waveformCanvas, style);
|
||||
// text.setText("Dragging");
|
||||
// dragSource.setDragSourceEffect(new DragSourceEffect(text) {
|
||||
// @Override
|
||||
// public void dragStart(DragSourceEvent event) {
|
||||
// event.image = waveformCanvas.getDisplay().getSystemImage(SWT.ICON_WARNING);
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
private void createWaveformDropTarget(final Canvas canvas) {
|
||||
@ -1348,7 +1348,7 @@ public class WaveformView implements IWaveformView {
|
||||
origin.x=(int) (-time/waveformCanvas.getScaleFactorPow10());
|
||||
waveformCanvas.setOrigin(origin);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void scrollHorizontal(int percent) {
|
||||
if(percent<-100) percent=-100;
|
||||
@ -1365,7 +1365,7 @@ public class WaveformView implements IWaveformView {
|
||||
updateValueList();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/// probably not the way it should be done
|
||||
@Override
|
||||
public void addDisposeListener(DisposeListener listener ) {
|
||||
|
Reference in New Issue
Block a user