Fixed bugs and enhanced functionality to allow E4 application
This commit is contained in:
parent
1f338cbf3f
commit
ef3ce7273a
|
@ -11,7 +11,6 @@ Require-Bundle: com.minres.scviewer.database;bundle-version="1.0.0",
|
|||
org.eclipse.osgi.services;bundle-version="3.4.0"
|
||||
Bundle-ClassPath: .,sqlite-jdbc-3.8.7.jar
|
||||
Service-Component: OSGI-INF/component.xml
|
||||
Export-Package: com.minres.scviewer.database.sqlite
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Embed-Dependency: sqlite-jdbc
|
||||
Embedded-Artifacts: sqlite-jdbc-3.8.7.jar;g="org.xerial";
|
||||
|
|
|
@ -33,10 +33,6 @@ public class SQLiteDbLoader implements IWaveformDbLoader {
|
|||
|
||||
protected IDatabase database;
|
||||
|
||||
protected List<IWaveform<? extends IWaveformEvent>> streams;
|
||||
|
||||
long timeResolution=1;
|
||||
|
||||
private RelationTypeFactory rtf = new RelationTypeFactory();
|
||||
|
||||
private IWaveformDb db;
|
||||
|
@ -63,9 +59,8 @@ public class SQLiteDbLoader implements IWaveformDbLoader {
|
|||
|
||||
@Override
|
||||
public List<IWaveform<? extends IWaveformEvent>> getAllWaves() {
|
||||
if(streams==null){
|
||||
SQLiteDatabaseSelectHandler<ScvStream> handler = new SQLiteDatabaseSelectHandler<ScvStream>(ScvStream.class, database);
|
||||
streams=new ArrayList<IWaveform<? extends IWaveformEvent>>();
|
||||
List<IWaveform<? extends IWaveformEvent>> streams=new ArrayList<IWaveform<? extends IWaveformEvent>>();
|
||||
try {
|
||||
for(ScvStream scvStream:handler.selectObjects()){
|
||||
TxStream stream = new TxStream(database, db, scvStream);
|
||||
|
@ -76,7 +71,6 @@ public class SQLiteDbLoader implements IWaveformDbLoader {
|
|||
| InvocationTargetException | SQLException | IntrospectionException e) {
|
||||
// e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return streams;
|
||||
}
|
||||
|
||||
|
@ -85,7 +79,6 @@ public class SQLiteDbLoader implements IWaveformDbLoader {
|
|||
@Override
|
||||
public boolean load(IWaveformDb db, File file) throws Exception {
|
||||
this.db=db;
|
||||
streams=null;
|
||||
FileInputStream fis = new FileInputStream(file);
|
||||
byte[] buffer = new byte[x.length];
|
||||
int read = fis.read(buffer, 0, x.length);
|
||||
|
|
|
@ -27,7 +27,9 @@ import com.minres.scviewer.database.ITx;
|
|||
import com.minres.scviewer.database.ITxEvent;
|
||||
import com.minres.scviewer.database.ITxGenerator;
|
||||
import com.minres.scviewer.database.ITxStream;
|
||||
import com.minres.scviewer.database.IWaveform;
|
||||
import com.minres.scviewer.database.IWaveformDb;
|
||||
import com.minres.scviewer.database.IWaveformEvent;
|
||||
import com.minres.scviewer.database.RelationType;
|
||||
import com.minres.scviewer.database.sqlite.db.IDatabase;
|
||||
import com.minres.scviewer.database.sqlite.db.SQLiteDatabaseSelectHandler;
|
||||
|
@ -189,4 +191,9 @@ public class TxStream extends HierNode implements ITxStream<ITxEvent> {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean equals(IWaveform<? extends IWaveformEvent> other) {
|
||||
return(other instanceof TxStream && this.getId()==other.getId());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,9 +13,11 @@ package com.minres.scviewer.database.swt;
|
|||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.beans.PropertyChangeSupport;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.NavigableMap;
|
||||
import java.util.TreeMap;
|
||||
import java.util.Vector;
|
||||
|
||||
|
@ -41,6 +43,7 @@ import org.eclipse.swt.dnd.DropTargetEvent;
|
|||
import org.eclipse.swt.dnd.Transfer;
|
||||
import org.eclipse.swt.events.ControlAdapter;
|
||||
import org.eclipse.swt.events.ControlEvent;
|
||||
import org.eclipse.swt.events.MouseAdapter;
|
||||
import org.eclipse.swt.events.MouseEvent;
|
||||
import org.eclipse.swt.events.MouseListener;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
|
@ -59,11 +62,10 @@ import org.eclipse.swt.widgets.Control;
|
|||
import org.eclipse.swt.widgets.Event;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Listener;
|
||||
import org.eclipse.swt.widgets.Menu;
|
||||
import org.eclipse.swt.widgets.ScrollBar;
|
||||
import org.eclipse.wb.swt.SWTResourceManager;
|
||||
|
||||
import swing2swt.layout.BorderLayout;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.minres.scviewer.database.ISignal;
|
||||
import com.minres.scviewer.database.ISignalChange;
|
||||
|
@ -83,7 +85,9 @@ import com.minres.scviewer.database.swt.internal.StreamPainter;
|
|||
import com.minres.scviewer.database.swt.internal.TrackPainter;
|
||||
import com.minres.scviewer.database.swt.internal.WaveformCanvas;
|
||||
|
||||
public class TxDisplay implements PropertyChangeListener, ISelectionProvider, MouseListener {
|
||||
import swing2swt.layout.BorderLayout;
|
||||
|
||||
public class TxDisplay implements PropertyChangeListener, ISelectionProvider {
|
||||
private ListenerList selectionChangedListeners = new ListenerList();
|
||||
private PropertyChangeSupport pcs;
|
||||
|
||||
|
@ -99,7 +103,7 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
|
|||
|
||||
private Canvas nameList;
|
||||
private Canvas valueList;
|
||||
WaveformCanvas trackList;
|
||||
WaveformCanvas waveformList;
|
||||
|
||||
private Composite top;
|
||||
|
||||
|
@ -113,6 +117,95 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
|
|||
// private long maxTime=0;
|
||||
private Font nameFont, nameFontB;
|
||||
|
||||
protected MouseListener nameValueMouseListener = new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseDown(MouseEvent e) {
|
||||
if ((e.button == 1 || e.button == 3)) {
|
||||
Entry<Integer, IWaveform<? extends IWaveformEvent>> entry = trackVerticalOffset.floorEntry(e.y);
|
||||
if (entry != null)
|
||||
setSelection(new StructuredSelection(entry.getValue()));
|
||||
}
|
||||
if (e.button == 3) {
|
||||
Menu topMenu= top.getMenu();
|
||||
if(topMenu!=null) topMenu.setVisible(true);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
protected MouseListener waveformMouseListener = new MouseAdapter(){
|
||||
Point start;
|
||||
List<Object> initialSelected;
|
||||
|
||||
@Override
|
||||
public void mouseDown(MouseEvent e) {
|
||||
start=new Point(e.x, e.y);
|
||||
if (e.button == 1) {
|
||||
initialSelected = waveformList.getClicked(start);
|
||||
} else if (e.button == 3) {
|
||||
List<Object> hitted = waveformList.getClicked(start);
|
||||
for(Object entry:hitted){
|
||||
if(entry instanceof IWaveform<?>){
|
||||
setSelection(new StructuredSelection(entry));
|
||||
break;
|
||||
}else if(entry instanceof ITx){
|
||||
setSelection(new StructuredSelection(((ITx)entry).getStream()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
Menu topMenu= top.getMenu();
|
||||
if(topMenu!=null) topMenu.setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseUp(MouseEvent e) {
|
||||
if (e.button == 1) {
|
||||
if(Math.abs(e.x-start.x)<3 && Math.abs(e.y-start.y)<3){
|
||||
long time= waveformList.getTimeForOffset(e.x);
|
||||
long scaling=5*waveformList.getScaleFactor();
|
||||
for(Object o:waveformList.getClicked(start)){
|
||||
Entry<Long, ?> floorEntry=null, ceilEntry=null;
|
||||
if(o instanceof ISignal<?>){
|
||||
NavigableMap<Long, ?> map = ((ISignal<?>)o).getEvents();
|
||||
floorEntry = map.floorEntry(time);
|
||||
ceilEntry = map.ceilingEntry(time);
|
||||
} else if (o instanceof ITxStream<?>){
|
||||
NavigableMap<Long, ?> map = ((ITxStream<?>)o).getEvents();
|
||||
floorEntry = map.floorEntry(time);
|
||||
ceilEntry = map.ceilingEntry(time);
|
||||
} else if(o instanceof ITx){
|
||||
NavigableMap<Long, ?> map = ((ITx)o).getStream().getEvents();
|
||||
floorEntry = map.floorEntry(time);
|
||||
ceilEntry = map.ceilingEntry(time);
|
||||
}
|
||||
if(floorEntry!=null && time-floorEntry.getKey()>scaling)
|
||||
floorEntry=null;
|
||||
if(ceilEntry!=null && ceilEntry.getKey()-time>scaling)
|
||||
ceilEntry=null;
|
||||
if(ceilEntry==null && floorEntry!=null){
|
||||
time=floorEntry.getKey();
|
||||
}else if(ceilEntry!=null && floorEntry==null){
|
||||
time=ceilEntry.getKey();
|
||||
}else if(ceilEntry!=null && floorEntry!=null){
|
||||
time=time-floorEntry.getKey()<ceilEntry.getKey()-time?floorEntry.getKey(): ceilEntry.getKey();
|
||||
}
|
||||
}
|
||||
// first set time
|
||||
setCursorTime(time);
|
||||
// then set selection and reveal
|
||||
setSelection(new StructuredSelection(initialSelected));
|
||||
e.widget.getDisplay().asyncExec(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
waveformList.redraw();
|
||||
updateValueList();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public TxDisplay(Composite parent) {
|
||||
pcs=new PropertyChangeSupport(this);
|
||||
|
||||
|
@ -139,8 +232,8 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
|
|||
trackPane = new Composite(topSash, SWT.NONE);
|
||||
trackPane.setLayout(new BorderLayout(0, 0));
|
||||
|
||||
trackList = new WaveformCanvas(trackPane, SWT.NONE);
|
||||
trackList.setLayoutData(BorderLayout.CENTER);
|
||||
waveformList = new WaveformCanvas(trackPane, SWT.NONE);
|
||||
waveformList.setLayoutData(BorderLayout.CENTER);
|
||||
|
||||
SashForm leftSash = new SashForm(composite, SWT.SMOOTH);
|
||||
leftSash.setBackground(leftSash.getDisplay().getSystemColor(SWT.COLOR_GRAY));
|
||||
|
@ -175,7 +268,7 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
|
|||
paintNames(gc, rect);
|
||||
}
|
||||
});
|
||||
nameList.addMouseListener(this);
|
||||
nameList.addMouseListener(nameValueMouseListener);
|
||||
nameListScrolled.setContent(nameList);
|
||||
|
||||
Composite valuePane = createTextPane(leftSash, "Value");
|
||||
|
@ -207,39 +300,39 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
|
|||
paintValues(gc, rect);
|
||||
}
|
||||
});
|
||||
valueList.addMouseListener(this);
|
||||
valueList.addMouseListener(nameValueMouseListener);
|
||||
valueListScrolled.setContent(valueList);
|
||||
|
||||
trackList.setStreams(streams);
|
||||
waveformList.setStreams(streams);
|
||||
// order is important: it is bottom to top
|
||||
trackList.addPainter(new TrackPainter(trackList));
|
||||
trackList.addPainter(new RulerPainter(
|
||||
trackList, trackList.getDisplay().getSystemColor(SWT.COLOR_BLACK), trackList.getDisplay().getSystemColor(SWT.COLOR_WHITE)));
|
||||
CursorPainter cp = new CursorPainter(trackList, trackList.getScaleFactor() * 10);
|
||||
trackList.addPainter(cp);
|
||||
waveformList.addPainter(new TrackPainter(waveformList));
|
||||
waveformList.addPainter(new RulerPainter(
|
||||
waveformList, waveformList.getDisplay().getSystemColor(SWT.COLOR_BLACK), waveformList.getDisplay().getSystemColor(SWT.COLOR_WHITE)));
|
||||
CursorPainter cp = new CursorPainter(waveformList, waveformList.getScaleFactor() * 10);
|
||||
waveformList.addPainter(cp);
|
||||
cursorPainters.add(cp);
|
||||
trackList.setMaxTime(1);
|
||||
trackList.addMouseListener(this);
|
||||
waveformList.setMaxTime(1);
|
||||
waveformList.addMouseListener(waveformMouseListener);
|
||||
|
||||
nameListScrolled.getVerticalBar().addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
int y = ((ScrollBar) e.widget).getSelection();
|
||||
Point v = valueListScrolled.getOrigin();
|
||||
valueListScrolled.setOrigin(v.x, y);
|
||||
Point t = trackList.getOrigin();
|
||||
trackList.setOrigin(t.x, -y);
|
||||
Point t = waveformList.getOrigin();
|
||||
waveformList.setOrigin(t.x, -y);
|
||||
}
|
||||
});
|
||||
valueListScrolled.getVerticalBar().addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
int y = ((ScrollBar) e.widget).getSelection();
|
||||
nameListScrolled.setOrigin(nameListScrolled.getOrigin().x, y);
|
||||
trackList.setOrigin(trackList.getOrigin().x, -y);
|
||||
waveformList.setOrigin(waveformList.getOrigin().x, -y);
|
||||
}
|
||||
});
|
||||
trackList.addSelectionListener(new SelectionAdapter() {
|
||||
waveformList.addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
int y = trackList.getVerticalBar().getSelection();
|
||||
int y = waveformList.getVerticalBar().getSelection();
|
||||
nameListScrolled.setOrigin(nameListScrolled.getOrigin().x, y);
|
||||
valueListScrolled.setOrigin(valueListScrolled.getOrigin().x, y);
|
||||
}
|
||||
|
@ -247,12 +340,12 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
|
|||
topSash.setWeights(new int[] { 30, 70 });
|
||||
leftSash.setWeights(new int[] { 75, 25 });
|
||||
|
||||
createWaveDragSource(nameList);
|
||||
createWaveDragSource(valueList);
|
||||
createWaveDropTarget(nameList);
|
||||
createWaveDropTarget(valueList);
|
||||
createTrackDragSource(trackList);
|
||||
createTrackDropTarget(trackList);
|
||||
createStreamDragSource(nameList);
|
||||
createStreamDragSource(valueList);
|
||||
createStreamDropTarget(nameList);
|
||||
createStreamDropTarget(valueList);
|
||||
createWaveformDragSource(waveformList);
|
||||
createWaveformDropTarget(waveformList);
|
||||
}
|
||||
|
||||
private Composite createTextPane(SashForm leftSash, String text) {
|
||||
|
@ -266,7 +359,7 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
|
|||
|
||||
CLabel nameLabel = new CLabel(namePane, SWT.NONE);
|
||||
GridData gd_nameLabel = new GridData(SWT.CENTER, SWT.CENTER, true, false, 1, 1);
|
||||
gd_nameLabel.heightHint = trackList.getRulerHeight() - 2;
|
||||
gd_nameLabel.heightHint = waveformList.getRulerHeight() - 2;
|
||||
nameLabel.setLayoutData(gd_nameLabel);
|
||||
nameLabel.setText(text);
|
||||
|
||||
|
@ -288,27 +381,28 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
|
|||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected void updateTracklist() {
|
||||
int trackVerticalHeight = 0;
|
||||
trackVerticalHeight = 0;
|
||||
int nameMaxWidth = 0;
|
||||
int previousHeight = trackVerticalOffset.size() == 0 ? 0 : trackVerticalOffset.lastKey();
|
||||
IWaveformPainter painter = null;
|
||||
trackVerticalOffset.clear();
|
||||
actualValues.clear();
|
||||
trackList.clearAllWavefromPainter();
|
||||
waveformList.clearAllWavefromPainter();
|
||||
boolean even = true;
|
||||
TextLayout tl = new TextLayout(trackList.getDisplay());
|
||||
TextLayout tl = new TextLayout(waveformList.getDisplay());
|
||||
tl.setFont(nameFontB);
|
||||
for (IWaveform<? extends IWaveformEvent> waveform : streams) {
|
||||
int height = trackList.getTrackHeight();
|
||||
int height = waveformList.getTrackHeight();
|
||||
if (waveform instanceof ITxStream<?>) {
|
||||
height *= ((ITxStream<? extends ITxEvent>) waveform).getMaxConcurrency();
|
||||
painter = new StreamPainter(trackList, even, height, (ITxStream<? extends ITxEvent>) waveform);
|
||||
actualValues.put(waveform, "");
|
||||
ITxStream<? extends ITxEvent> stream = (ITxStream<? extends ITxEvent>) waveform;
|
||||
height *= stream.getMaxConcurrency();
|
||||
painter = new StreamPainter(waveformList, even, height, (ITxStream<? extends ITxEvent>) waveform);
|
||||
actualValues.put(stream, "");
|
||||
} else if (waveform instanceof ISignal<?>) {
|
||||
painter = new SignalPainter(trackList, even, height, (ISignal<?>) waveform);
|
||||
painter = new SignalPainter(waveformList, even, height, (ISignal<?>) waveform);
|
||||
actualValues.put(waveform, "---");
|
||||
}
|
||||
trackList.addWavefromPainter(trackVerticalHeight, painter);
|
||||
waveformList.addWavefromPainter(trackVerticalHeight, painter);
|
||||
trackVerticalOffset.put(trackVerticalHeight, waveform);
|
||||
tl.setText(waveform.getFullName());
|
||||
nameMaxWidth = Math.max(nameMaxWidth, tl.getBounds().width);
|
||||
|
@ -321,17 +415,21 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
|
|||
valueListScrolled.setMinSize(calculateValueWidth(), trackVerticalHeight);
|
||||
nameList.redraw();
|
||||
updateValueList();
|
||||
trackList.redraw();
|
||||
top.layout(new Control[] { valueList, nameList, trackList });
|
||||
if (previousHeight > trackVerticalOffset.lastKey()) {
|
||||
Point o = trackList.getOrigin();
|
||||
trackList.setOrigin(o.x, o.y - (previousHeight - trackVerticalOffset.lastKey()));
|
||||
waveformList.redraw();
|
||||
top.layout(new Control[] { valueList, nameList, waveformList });
|
||||
if (trackVerticalOffset.isEmpty() || previousHeight > trackVerticalOffset.lastKey()) {
|
||||
Point o = waveformList.getOrigin();
|
||||
waveformList.setOrigin(o.x, o.y - (previousHeight - trackVerticalOffset.lastKey()));
|
||||
}
|
||||
setSelection(new StructuredSelection());
|
||||
/* System.out.println("updateTracklist() state:");
|
||||
for(Entry<Integer, IWaveform<? extends IWaveformEvent>> entry: trackVerticalOffset.entrySet()){
|
||||
System.out.println(" "+entry.getKey()+": " +entry.getValue().getFullName());
|
||||
}
|
||||
*/ }
|
||||
|
||||
private int calculateValueWidth() {
|
||||
TextLayout tl = new TextLayout(trackList.getDisplay());
|
||||
TextLayout tl = new TextLayout(waveformList.getDisplay());
|
||||
tl.setFont(nameFontB);
|
||||
int valueMaxWidth = 0;
|
||||
for (String v : actualValues.values()) {
|
||||
|
@ -342,7 +440,7 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
|
|||
}
|
||||
|
||||
private void updateValueList(){
|
||||
final Long time = cursorPainters.get(0).getTime();
|
||||
final Long time = getCursorTime();
|
||||
for(Entry<IWaveform<? extends IWaveformEvent>, String> entry:actualValues.entrySet()){
|
||||
if(entry.getKey() instanceof ISignal){
|
||||
ISignalChange event = ((ISignal<?>)entry.getKey()).getWaveformEventsBeforeTime(time);
|
||||
|
@ -351,14 +449,43 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
|
|||
} else if(event instanceof ISignalChangeMulti){
|
||||
entry.setValue("h'"+((ISignalChangeMulti)event).getValue().toHexString());
|
||||
}
|
||||
} /*else if(entry instanceof ITxStream){
|
||||
Collection<?> events = ((ITxStream<?>)entry.getKey()).getWaveformEventsAtTime(time);
|
||||
|
||||
}*/
|
||||
} else if(entry.getKey() instanceof ITxStream<?>){
|
||||
ITxStream<?> stream = (ITxStream<?>) entry.getKey();
|
||||
ITx[] resultsList = new ITx[stream.getMaxConcurrency()];
|
||||
Entry<Long, List<ITxEvent>> firstTx=stream.getEvents().floorEntry(time);
|
||||
if(firstTx!=null){
|
||||
do {
|
||||
for(ITxEvent evt:firstTx.getValue()){
|
||||
ITx tx=evt.getTransaction();
|
||||
if(evt.getType()==ITxEvent.Type.BEGIN && tx.getBeginTime()<=time && tx.getEndTime()>=time){
|
||||
if(resultsList[tx.getConcurrencyIndex()]==null)
|
||||
resultsList[tx.getConcurrencyIndex()]= evt.getTransaction();
|
||||
}
|
||||
}
|
||||
firstTx=stream.getEvents().lowerEntry(firstTx.getKey());
|
||||
}while(firstTx!=null && !isArrayFull(resultsList));
|
||||
String value=null;
|
||||
for(ITx o:resultsList){
|
||||
if(value==null)
|
||||
value=new String();
|
||||
else
|
||||
value+="|";
|
||||
if(o!=null) value+=((ITx)o).getGenerator().getName();
|
||||
}
|
||||
entry.setValue(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
valueList.redraw();
|
||||
}
|
||||
|
||||
private boolean isArrayFull(Object[] array){
|
||||
for(Object o:array){
|
||||
if(o==null) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSelectionChangedListener(ISelectionChangedListener listener) {
|
||||
selectionChangedListeners.add(listener);
|
||||
|
@ -373,6 +500,18 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
|
|||
return top;
|
||||
}
|
||||
|
||||
public Control getNameControl() {
|
||||
return nameList;
|
||||
}
|
||||
|
||||
public Control getValueControl() {
|
||||
return valueList;
|
||||
}
|
||||
|
||||
public Control getWaveformControl() {
|
||||
return waveformList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ISelection getSelection() {
|
||||
if(currentCursorSelection != null){
|
||||
|
@ -396,13 +535,13 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
|
|||
currentWaveformSelection = null;
|
||||
currentCursorSelection=null;
|
||||
} else {
|
||||
Object sel = ((IStructuredSelection) selection).getFirstElement();
|
||||
if (sel instanceof ITx && currentTxSelection != sel) {
|
||||
for(Object sel:((IStructuredSelection) selection).toArray()){
|
||||
if (sel instanceof ITx && currentTxSelection != sel && streams.contains(((ITx)sel).getStream())) {
|
||||
currentTxSelection = (ITx) sel;
|
||||
currentWaveformSelection = currentTxSelection.getStream();
|
||||
currentCursorSelection=null;
|
||||
selectionChanged = true;
|
||||
} else if (sel instanceof IWaveform<?> && currentWaveformSelection != sel) {
|
||||
} else if (sel instanceof IWaveform<?> && currentWaveformSelection != sel&& streams.contains(sel)) {
|
||||
currentTxSelection = null;
|
||||
currentWaveformSelection = (IWaveform<? extends IWaveformEvent>) sel;
|
||||
currentCursorSelection=null;
|
||||
|
@ -414,6 +553,7 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
|
|||
selectionChanged = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (currentTxSelection != null || currentWaveformSelection != null)
|
||||
selectionChanged = true;
|
||||
|
@ -421,11 +561,8 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
|
|||
currentWaveformSelection = null;
|
||||
currentCursorSelection=null;
|
||||
}
|
||||
if (currentWaveformSelection != null && !streams.contains(currentWaveformSelection)) {
|
||||
streams.add(currentWaveformSelection);
|
||||
}
|
||||
if (selectionChanged) {
|
||||
trackList.setSelected(currentTxSelection, currentWaveformSelection);
|
||||
waveformList.setSelected(currentTxSelection, currentWaveformSelection);
|
||||
nameList.setData(SELECTION, currentWaveformSelection);
|
||||
valueList.redraw();
|
||||
nameList.redraw();
|
||||
|
@ -450,7 +587,7 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
|
|||
transaction = evt.getTransaction();
|
||||
break;
|
||||
}
|
||||
meFound|= evt.getTransaction().getId()==currentTxSelection.getId();
|
||||
meFound|= evt.getTransaction().equals(currentTxSelection);
|
||||
}
|
||||
}
|
||||
if (transaction == null){
|
||||
|
@ -475,7 +612,7 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
|
|||
transaction = evt.getTransaction();
|
||||
break;
|
||||
}
|
||||
meFound|= evt.getTransaction().getId()==currentTxSelection.getId();
|
||||
meFound|= evt.getTransaction().equals(currentTxSelection);
|
||||
}
|
||||
}
|
||||
if (transaction == null){
|
||||
|
@ -499,49 +636,48 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseDoubleClick(MouseEvent e) {
|
||||
if (e.button == 1&& e.widget == trackList) {
|
||||
Object o = trackList.getClicked(new Point(e.x, e.y));
|
||||
if (o != null)
|
||||
setSelection(new StructuredSelection(o));
|
||||
public void moveCursor(GotoDirection direction) {
|
||||
long time = getCursorTime();
|
||||
NavigableMap<Long, ?> map=null;
|
||||
if(currentWaveformSelection instanceof ITxStream<?>){
|
||||
map=((ITxStream<?>) currentWaveformSelection).getEvents();
|
||||
} else if(currentWaveformSelection instanceof ISignal<?>){
|
||||
map=((ISignal<?>) currentWaveformSelection).getEvents();
|
||||
}
|
||||
if(map!=null){
|
||||
Entry<Long, ?> entry=direction==GotoDirection.PREV?map.lowerEntry(time):map.higherEntry(time);
|
||||
if(entry!=null) {
|
||||
time=entry.getKey();
|
||||
setCursorTime(time);
|
||||
waveformList.reveal(time);
|
||||
waveformList.redraw();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseDown(MouseEvent e) {
|
||||
if ((e.button == 1 || e.button == 3) && (e.widget == valueList || e.widget == nameList)) {
|
||||
Entry<Integer, IWaveform<? extends IWaveformEvent>> entry = trackVerticalOffset.floorEntry(e.y);
|
||||
if (entry != null)
|
||||
setSelection(new StructuredSelection(entry.getValue()));
|
||||
} else if (e.button == 1&& e.widget == trackList) {
|
||||
Object o = trackList.getClicked(new Point(e.x, e.y));
|
||||
if (o != null && o instanceof CursorPainter)
|
||||
setSelection(new StructuredSelection(o));
|
||||
|
||||
} else if (e.button == 3) {
|
||||
top.getMenu().setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseUp(MouseEvent e) {
|
||||
if (e.button == 1&& e.widget == trackList) {
|
||||
setCursorTime(trackList.getTimeForOffset(e.x));
|
||||
e.widget.getDisplay().asyncExec(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
trackList.redraw();
|
||||
updateValueList();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public List<IWaveform<? extends IWaveformEvent>> getStreamList() {
|
||||
return streams;
|
||||
}
|
||||
|
||||
public void moveSelected(int i) {
|
||||
if(currentWaveformSelection!=null){
|
||||
ITx selectedTx=currentTxSelection;
|
||||
IWaveform<? extends IWaveformEvent> selectedWaveform=currentWaveformSelection;
|
||||
int idx = streams.indexOf(currentWaveformSelection);
|
||||
int newIdx=idx+i;
|
||||
if(newIdx>=0 && newIdx<streams.size()){
|
||||
Collections.swap(streams,idx,newIdx);
|
||||
updateTracklist();
|
||||
if(selectedTx!=null){
|
||||
setSelection(new StructuredSelection(new Object[]{selectedTx, selectedWaveform}));
|
||||
} else
|
||||
setSelection(new StructuredSelection(selectedWaveform));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void paintNames(GC gc, Rectangle rect) {
|
||||
if (streams.size() > 0) {
|
||||
@SuppressWarnings("unchecked")
|
||||
|
@ -550,20 +686,20 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
|
|||
if (firstKey == null)
|
||||
firstKey = trackVerticalOffset.firstKey();
|
||||
Integer lastKey = trackVerticalOffset.floorKey(rect.y + rect.height);
|
||||
Rectangle subArea = new Rectangle(rect.x, 0, rect.width, trackList.getTrackHeight());
|
||||
Rectangle subArea = new Rectangle(rect.x, 0, rect.width, waveformList.getTrackHeight());
|
||||
if (lastKey == firstKey) {
|
||||
IWaveform<? extends IWaveformEvent> w = trackVerticalOffset.get(firstKey);
|
||||
if (w instanceof ITxStream<?>)
|
||||
subArea.height *= ((ITxStream<?>) w).getMaxConcurrency();
|
||||
drawTextFormat(gc, subArea, firstKey, w.getFullName(), wave != null && w.getId() == wave.getId());
|
||||
drawTextFormat(gc, subArea, firstKey, w.getFullName(), w.equals(wave));
|
||||
} else {
|
||||
for (Entry<Integer, IWaveform<? extends IWaveformEvent>> entry : trackVerticalOffset.subMap(firstKey, true, lastKey, true)
|
||||
.entrySet()) {
|
||||
IWaveform<? extends IWaveformEvent> w = entry.getValue();
|
||||
subArea.height = trackList.getTrackHeight();
|
||||
subArea.height = waveformList.getTrackHeight();
|
||||
if (w instanceof ITxStream<?>)
|
||||
subArea.height *= ((ITxStream<?>) w).getMaxConcurrency();
|
||||
drawTextFormat(gc, subArea, entry.getKey(), w.getFullName(), wave != null && w.getId() == wave.getId());
|
||||
drawTextFormat(gc, subArea, entry.getKey(), w.getFullName(), w.equals(wave));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -577,25 +713,35 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
|
|||
if (firstKey == null)
|
||||
firstKey = trackVerticalOffset.firstKey();
|
||||
Integer lastKey = trackVerticalOffset.floorKey(rect.y + rect.height);
|
||||
Rectangle subArea = new Rectangle(rect.x, 0, rect.width, trackList.getTrackHeight());
|
||||
Rectangle subArea = new Rectangle(rect.x, 0, rect.width, waveformList.getTrackHeight());
|
||||
if (lastKey == firstKey) {
|
||||
IWaveform<? extends IWaveformEvent> w = trackVerticalOffset.get(firstKey);
|
||||
if (w instanceof ITxStream<?>)
|
||||
subArea.height *= ((ITxStream<?>) w).getMaxConcurrency();
|
||||
drawTextFormat(gc, subArea, firstKey, actualValues.get(w), wave != null && w.getId() == wave.getId());
|
||||
drawValue(gc, subArea, firstKey, actualValues.get(w), w.equals(wave));
|
||||
} else {
|
||||
for (Entry<Integer, IWaveform<? extends IWaveformEvent>> entry : trackVerticalOffset.subMap(firstKey, true, lastKey, true)
|
||||
.entrySet()) {
|
||||
IWaveform<? extends IWaveformEvent> w = entry.getValue();
|
||||
subArea.height = trackList.getTrackHeight();
|
||||
subArea.height = waveformList.getTrackHeight();
|
||||
if (w instanceof ITxStream<?>)
|
||||
subArea.height *= ((ITxStream<?>) w).getMaxConcurrency();
|
||||
drawTextFormat(gc, subArea, entry.getKey(), actualValues.get(w), wave != null && w.getId() == wave.getId());
|
||||
drawValue(gc, subArea, entry.getKey(), actualValues.get(w), w.equals(wave));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void drawValue(GC gc, Rectangle subArea, Integer yOffset, String value, boolean highlite) {
|
||||
int beginIndex=0;
|
||||
for(int offset=0; offset<subArea.height; offset+=waveformList.getTrackHeight()){
|
||||
int endIndex=value.indexOf('|', beginIndex);
|
||||
String str = endIndex<0?value.substring(beginIndex):value.substring(beginIndex, endIndex);
|
||||
drawTextFormat(gc, new Rectangle(subArea.x, subArea.y, subArea.width, waveformList.getTrackHeight()), yOffset+offset, str, highlite);
|
||||
beginIndex=endIndex<0?beginIndex:endIndex+1;
|
||||
}
|
||||
}
|
||||
|
||||
protected void drawTextFormat(GC gc, Rectangle subArea, int yOffset, String value, boolean highlite) {
|
||||
Point size = gc.textExtent(value);
|
||||
if (highlite) {
|
||||
|
@ -608,23 +754,23 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
|
|||
gc.setForeground(SWTResourceManager.getColor(SWT.COLOR_LIST_FOREGROUND));
|
||||
gc.setFont(nameFont);
|
||||
}
|
||||
gc.drawText(value, subArea.x + 5, subArea.y + yOffset + (trackList.getTrackHeight() - size.y) / 2, true);
|
||||
gc.drawText(value, subArea.x + 5, subArea.y + yOffset + (waveformList.getTrackHeight() - size.y) / 2, true);
|
||||
}
|
||||
|
||||
public long getMaxTime() {
|
||||
return trackList.getMaxTime();
|
||||
return waveformList.getMaxTime();
|
||||
}
|
||||
|
||||
public void setMaxTime(long maxTime) {
|
||||
this.trackList.setMaxTime(maxTime);
|
||||
this.waveformList.setMaxTime(maxTime);
|
||||
}
|
||||
|
||||
public void setZoomLevel(int scale) {
|
||||
trackList.setZoomLevel(scale);
|
||||
waveformList.setZoomLevel(scale);
|
||||
}
|
||||
|
||||
public int getZoomLevel() {
|
||||
return trackList.getZoomLevel();
|
||||
return waveformList.getZoomLevel();
|
||||
}
|
||||
|
||||
public void setCursorTime(long time){
|
||||
|
@ -637,7 +783,7 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
|
|||
return cursorPainters.get(0).getTime();
|
||||
}
|
||||
|
||||
private void createWaveDragSource(final Canvas canvas) {
|
||||
private void createStreamDragSource(final Canvas canvas) {
|
||||
Transfer[] types = new Transfer[] { LocalSelectionTransfer.getTransfer() };
|
||||
DragSource dragSource = new DragSource(canvas, DND.DROP_MOVE);
|
||||
dragSource.setTransfer(types);
|
||||
|
@ -647,7 +793,7 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
|
|||
// event.data =
|
||||
// trackVerticalOffset.floorEntry(event.y).getValue().getFullName();
|
||||
event.doit = true;
|
||||
LocalSelectionTransfer.getTransfer().setSelection(getSelection());
|
||||
LocalSelectionTransfer.getTransfer().setSelection(new StructuredSelection(currentWaveformSelection));
|
||||
// System.out.println("dragStart at location "+new
|
||||
// Point(event.x, event.y));
|
||||
}
|
||||
|
@ -661,12 +807,13 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
|
|||
});
|
||||
}
|
||||
|
||||
private void createWaveDropTarget(final Canvas canvas) {
|
||||
private void createStreamDropTarget(final Canvas canvas) {
|
||||
Transfer[] types = new Transfer[] { LocalSelectionTransfer.getTransfer() };
|
||||
DropTarget dropTarget = new DropTarget(canvas, DND.DROP_MOVE);
|
||||
dropTarget.setTransfer(types);
|
||||
|
||||
dropTarget.addDropListener(new DropTargetAdapter() {
|
||||
@SuppressWarnings("unchecked")
|
||||
public void drop(DropTargetEvent event) {
|
||||
if (LocalSelectionTransfer.getTransfer().isSupportedType(event.currentDataType)){
|
||||
ISelection sel = LocalSelectionTransfer.getTransfer().getSelection();
|
||||
|
@ -683,9 +830,11 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
|
|||
// } else {
|
||||
// streams.rotate(tgtIdx, srcIdx+1, 1);
|
||||
// }
|
||||
int srcIdx=streams.indexOf(source);
|
||||
streams.remove(source);
|
||||
int tgtIdx=streams.indexOf(target);
|
||||
streams.add(tgtIdx, (IWaveform<? extends IWaveformEvent>) source);
|
||||
streams.add(srcIdx>tgtIdx?tgtIdx:tgtIdx+1, (IWaveform<? extends IWaveformEvent>) source);
|
||||
updateTracklist();
|
||||
} else if(source instanceof CursorPainter){
|
||||
((CursorPainter)source).setTime(0);
|
||||
updateValueList();
|
||||
|
@ -694,36 +843,42 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public void dropAccept(DropTargetEvent event) {
|
||||
if (event.detail != DND.DROP_MOVE || event.y > trackVerticalOffset.lastKey() + trackList.getTrackHeight()) {
|
||||
Point offset = canvas.toControl(event.x, event.y);
|
||||
if (event.detail != DND.DROP_MOVE || offset.y > trackVerticalOffset.lastKey() + waveformList.getTrackHeight()) {
|
||||
event.detail = DND.DROP_NONE;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void createTrackDragSource(final Canvas canvas) {
|
||||
private void createWaveformDragSource(final Canvas canvas) {
|
||||
Transfer[] types = new Transfer[] { LocalSelectionTransfer.getTransfer() };
|
||||
DragSource dragSource = new DragSource(canvas, DND.DROP_MOVE);
|
||||
dragSource.setTransfer(types);
|
||||
dragSource.addDragListener(new DragSourceAdapter() {
|
||||
public void dragStart(DragSourceEvent event) {
|
||||
if (currentCursorSelection!=null) {
|
||||
event.doit = false;
|
||||
for(Object o:waveformList.getClicked(new Point(event.x, event.y))){
|
||||
if(o instanceof CursorPainter){
|
||||
LocalSelectionTransfer.getTransfer().setSelection(new StructuredSelection(o));
|
||||
((CursorPainter)o).setDragging(true);
|
||||
event.doit = true;
|
||||
LocalSelectionTransfer.getTransfer().setSelection(getSelection());
|
||||
currentCursorSelection.setDragging(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void dragSetData(DragSourceEvent event) {
|
||||
if (LocalSelectionTransfer.getTransfer().isSupportedType(event.dataType)) {
|
||||
event.data =getSelection();
|
||||
event.data=waveformList.getClicked(new Point(event.x, event.y));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void createTrackDropTarget(final Canvas canvas) {
|
||||
private void createWaveformDropTarget(final Canvas canvas) {
|
||||
Transfer[] types = new Transfer[] { LocalSelectionTransfer.getTransfer() };
|
||||
DropTarget dropTarget = new DropTarget(canvas, DND.DROP_MOVE);
|
||||
dropTarget.setTransfer(types);
|
||||
|
@ -731,52 +886,45 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
|
|||
public void drop(DropTargetEvent event) {
|
||||
if (LocalSelectionTransfer.getTransfer().isSupportedType(event.currentDataType)){
|
||||
ISelection sel = LocalSelectionTransfer.getTransfer().getSelection();
|
||||
if(sel!=null && sel instanceof IStructuredSelection){
|
||||
Object selObject = ((IStructuredSelection)sel).getFirstElement();
|
||||
if(selObject instanceof CursorPainter){
|
||||
CursorPainter painter = (CursorPainter) selObject;
|
||||
DropTarget tgt = (DropTarget) event.widget;
|
||||
Point dropPoint = ((Canvas) tgt.getControl()).toControl(event.x, event.y);
|
||||
// painter.setTime(trackList.getTimeForOffset(dropPoint.x));
|
||||
setCursorTime(trackList.getTimeForOffset(dropPoint.x));
|
||||
((Canvas) tgt.getControl()).redraw();
|
||||
canvas.getDisplay().asyncExec(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
updateValueList();
|
||||
}
|
||||
});
|
||||
}
|
||||
if(sel!=null && sel instanceof IStructuredSelection &&
|
||||
((IStructuredSelection)sel).getFirstElement() instanceof CursorPainter){
|
||||
((CursorPainter)((IStructuredSelection)sel).getFirstElement()).setDragging(false);
|
||||
updateWaveform(canvas, event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void dropAccept(DropTargetEvent event) {
|
||||
if (event.detail != DND.DROP_MOVE || event.y > trackVerticalOffset.lastKey() + trackList.getTrackHeight()) {
|
||||
Point offset = canvas.toControl(event.x, event.y);
|
||||
if (event.detail != DND.DROP_MOVE || offset.y > trackVerticalOffset.lastKey() + waveformList.getTrackHeight()) {
|
||||
event.detail = DND.DROP_NONE;
|
||||
}
|
||||
if(currentCursorSelection!=null) currentCursorSelection.setDragging(false);
|
||||
}
|
||||
|
||||
public void dragOver(DropTargetEvent event){
|
||||
ISelection sel = LocalSelectionTransfer.getTransfer().getSelection();
|
||||
if(sel!=null && sel instanceof IStructuredSelection){
|
||||
Object selObject = ((IStructuredSelection)sel).getFirstElement();
|
||||
if(selObject instanceof CursorPainter){
|
||||
DropTarget tgt = (DropTarget) event.widget;
|
||||
Point dropPoint = ((Canvas) tgt.getControl()).toControl(event.x, event.y);
|
||||
setCursorTime(trackList.getTimeForOffset(dropPoint.x));
|
||||
((Canvas) tgt.getControl()).redraw();
|
||||
if(sel!=null && sel instanceof IStructuredSelection &&
|
||||
((IStructuredSelection)sel).getFirstElement() instanceof CursorPainter){
|
||||
updateWaveform(canvas, event);
|
||||
}
|
||||
}
|
||||
|
||||
protected void updateWaveform(final Canvas canvas, DropTargetEvent event) {
|
||||
Point dropPoint = canvas.toControl(event.x, event.y);
|
||||
setCursorTime(waveformList.getTimeForOffset(dropPoint.x));
|
||||
canvas.getDisplay().asyncExec(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if(!canvas.isDisposed()){
|
||||
canvas.redraw();
|
||||
updateValueList();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void addPropertyChangeListener(PropertyChangeListener listener) {
|
||||
this.pcs.addPropertyChangeListener(listener);
|
||||
|
|
|
@ -42,7 +42,7 @@ public class SignalPainter implements IWaveformPainter {
|
|||
}
|
||||
|
||||
public void paintArea(GC gc, Rectangle area) {
|
||||
if(waveCanvas.currentWaveformSelection!=null && waveCanvas.currentWaveformSelection.getId()==signal.getId())
|
||||
if(waveCanvas.currentWaveformSelection!=null && waveCanvas.currentWaveformSelection.equals(signal))
|
||||
gc.setBackground(this.waveCanvas.colors[WaveformCanvas.Colors.TRACK_BG_HIGHLITE.ordinal()]);
|
||||
else
|
||||
gc.setBackground(this.waveCanvas.colors[even?WaveformCanvas.Colors.TRACK_BG_EVEN.ordinal():WaveformCanvas.Colors.TRACK_BG_ODD.ordinal()]);
|
||||
|
|
|
@ -51,12 +51,12 @@ public class StreamPainter implements IWaveformPainter{
|
|||
@SuppressWarnings("unchecked")
|
||||
public void paintArea(GC gc, Rectangle area) {
|
||||
if(stream.getEvents().size()==0) return;
|
||||
if(waveCanvas.currentWaveformSelection!=null && waveCanvas.currentWaveformSelection.getId()==stream.getId())
|
||||
if(waveCanvas.currentWaveformSelection!=null && waveCanvas.currentWaveformSelection.equals(stream))
|
||||
gc.setBackground(this.waveCanvas.colors[WaveformCanvas.Colors.TRACK_BG_HIGHLITE.ordinal()]);
|
||||
else
|
||||
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.fillRectangle(0,0,area.width, area.height);
|
||||
gc.fillRectangle(area);
|
||||
Entry<Long, ?> firstTx=stream.getEvents().floorEntry(area.x*waveCanvas.getScaleFactor());
|
||||
Entry<Long, ?> lastTx=stream.getEvents().ceilingEntry((area.x+area.width)*waveCanvas.getScaleFactor());
|
||||
if(firstTx==null) firstTx = stream.getEvents().firstEntry();
|
||||
|
@ -82,7 +82,7 @@ public class StreamPainter implements IWaveformPainter{
|
|||
seenTx.add(txEvent.getTransaction());
|
||||
if(txEvent.getType()==ITxEvent.Type.END){
|
||||
ITx tx = txEvent.getTransaction();
|
||||
highlighed|=waveCanvas.currentSelection!=null && waveCanvas.currentSelection.getId()==tx.getId();
|
||||
highlighed|=waveCanvas.currentSelection!=null && waveCanvas.currentSelection.equals(tx);
|
||||
drawTx(gc, area, tx);
|
||||
seenTx.remove(tx);
|
||||
}
|
||||
|
|
|
@ -327,7 +327,8 @@ public class WaveformCanvas extends Canvas {
|
|||
}
|
||||
}
|
||||
|
||||
public Object getClicked(Point point) {
|
||||
public List<Object> getClicked(Point point) {
|
||||
LinkedList<Object> result=new LinkedList<>();
|
||||
for (IPainter p : Lists.reverse(painterList)) {
|
||||
if (p instanceof TrackPainter) {
|
||||
int y = point.y - origin.y;
|
||||
|
@ -335,17 +336,28 @@ public class WaveformCanvas extends Canvas {
|
|||
Entry<Integer, IWaveformPainter> entry = trackVerticalOffset.floorEntry(y);
|
||||
if (entry != null) {
|
||||
if (entry.getValue() instanceof StreamPainter) {
|
||||
return ((StreamPainter) entry.getValue()).getClicked(new Point(x, y - entry.getKey()));
|
||||
result.add(((StreamPainter) entry.getValue()).getClicked(new Point(x, y - entry.getKey())));
|
||||
} else if (entry.getValue() instanceof SignalPainter)
|
||||
return ((SignalPainter) entry.getValue()).getSignal();
|
||||
result.add(((SignalPainter) entry.getValue()).getSignal());
|
||||
}
|
||||
} else if (p instanceof CursorPainter) {
|
||||
if (Math.abs(point.x - ((CursorPainter) p).getTime()/scaleFactor) < 2) {
|
||||
return p;
|
||||
if (Math.abs(point.x - origin.x - ((CursorPainter) p).getTime()/scaleFactor) < 2) {
|
||||
result.add(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<Object> getEntriesAtPosition(IWaveform<? extends IWaveformEvent> iWaveform, int i) {
|
||||
LinkedList<Object> result=new LinkedList<>();
|
||||
int x = i - origin.x;
|
||||
for(IPainter p: trackVerticalOffset.values()){
|
||||
if (p instanceof StreamPainter && ((StreamPainter)p).getStream()==iWaveform) {
|
||||
result.add(((StreamPainter) p).getClicked(new Point(x, trackHeight/2)));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setSelected(ITx currentSelection, IWaveform<? extends IWaveformEvent> currentWaveformSelection) {
|
||||
|
@ -380,6 +392,18 @@ public class WaveformCanvas extends Canvas {
|
|||
}
|
||||
}
|
||||
|
||||
public void reveal(long time) {
|
||||
int scaledTime = (int) (time / scaleFactor);
|
||||
Point size = getSize();
|
||||
size.x -= getVerticalBar().getSize().x + 2;
|
||||
size.y -= getHorizontalBar().getSize().y;
|
||||
if (scaledTime < -origin.x) {
|
||||
setOrigin(-scaledTime+10, origin.y);
|
||||
} else if (scaledTime > (size.x - origin.x)) {
|
||||
setOrigin(size.x - scaledTime-30, origin.y);
|
||||
}
|
||||
}
|
||||
|
||||
public int getRulerHeight() {
|
||||
return rulerHeight;
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2014, 2015 MINRES Technologies GmbH and others.
|
||||
* Copyright (c) 2011 Google, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* MINRES Technologies GmbH - initial API and implementation
|
||||
* Google, Inc. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.wb.swt;
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ import org.junit.Before;
|
|||
import org.junit.Test;
|
||||
|
||||
import com.minres.scviewer.database.IWaveformDb;
|
||||
import com.minres.scviewer.database.WaveformDb;
|
||||
import com.minres.scviewer.database.internal.WaveformDb;
|
||||
|
||||
public class DatabaseServicesTest {
|
||||
|
||||
|
|
|
@ -14,5 +14,4 @@ Require-Bundle: com.minres.scviewer.database;bundle-version="1.0.0",
|
|||
org.eclipse.osgi.services;bundle-version="3.4.0",
|
||||
com.google.guava;bundle-version="15.0.0"
|
||||
Service-Component: OSGI-INF/component.xml
|
||||
Export-Package: com.minres.scviewer.database.text
|
||||
Bundle-ActivationPolicy: lazy
|
||||
|
|
|
@ -17,12 +17,13 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.NavigableMap;
|
||||
|
||||
import com.google.common.collect.TreeMultimap;
|
||||
import com.minres.scviewer.database.HierNode;
|
||||
import com.google.common.collect.TreeMultimap
|
||||
import com.minres.scviewer.database.ITxEvent;
|
||||
import com.minres.scviewer.database.IWaveform;
|
||||
import com.minres.scviewer.database.IWaveformDb
|
||||
import com.minres.scviewer.database.IWaveformEvent
|
||||
import com.minres.scviewer.database.ITxGenerator
|
||||
import com.minres.scviewer.database.HierNode;
|
||||
import com.minres.scviewer.database.IHierNode
|
||||
import com.minres.scviewer.database.ITxStream
|
||||
import com.minres.scviewer.database.ITx
|
||||
|
@ -107,4 +108,10 @@ class TxStream extends HierNode implements ITxStream {
|
|||
public Collection getWaveformEventsAtTime(Long time) {
|
||||
return events.get(time);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean equals(IWaveform<? extends IWaveformEvent> other) {
|
||||
return(other instanceof TxStream && this.getId()==other.getId());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -109,6 +109,11 @@ public class VCDSignal<T extends ISignalChange> extends HierNode implements ISig
|
|||
return values.floorEntry(time).getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean equals(IWaveform<? extends IWaveformEvent> other) {
|
||||
return(other instanceof VCDSignal<?> && this.getId()==other.getId());
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -7,7 +7,8 @@ Bundle-Vendor: MINRES Technologies GmbH
|
|||
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
|
||||
Export-Package: com.minres.scviewer.database
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Service-Component: OSGI-INF/component.xml
|
||||
Service-Component: OSGI-INF/component.xml,OSGI-INF/component2.xml
|
||||
Require-Bundle: org.eclipse.equinox.ds;bundle-version="1.4.200",
|
||||
org.eclipse.equinox.util;bundle-version="1.0.500",
|
||||
org.eclipse.osgi.services;bundle-version="3.4.0"
|
||||
org.eclipse.osgi.services;bundle-version="3.4.0",
|
||||
org.eclipse.wb.core.lib
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="com.minres.scviewer.database">
|
||||
<implementation class="com.minres.scviewer.database.WaveformDb"/>
|
||||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="com.minres.scviewer.database.loader">
|
||||
<implementation class="com.minres.scviewer.database.internal.WaveformDb"/>
|
||||
<reference bind="bind" cardinality="1..n" interface="com.minres.scviewer.database.IWaveformDbLoader" name="IWaveformDbLoader" policy="dynamic" unbind="unbind"/>
|
||||
</scr:component>
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="com.minres.scviewer.database">
|
||||
<implementation class="com.minres.scviewer.database.internal.WaveformDbFactory"/>
|
||||
<service>
|
||||
<provide interface="com.minres.scviewer.database.IWaveformDbFactory"/>
|
||||
</service>
|
||||
</scr:component>
|
|
@ -19,6 +19,8 @@ public class HierNode implements IHierNode {
|
|||
|
||||
protected String name;
|
||||
|
||||
protected String parentName;
|
||||
|
||||
protected ArrayList<IHierNode> childs;
|
||||
|
||||
protected PropertyChangeSupport pcs;
|
||||
|
@ -29,8 +31,13 @@ public class HierNode implements IHierNode {
|
|||
}
|
||||
|
||||
public HierNode(String name) {
|
||||
this(name, "");
|
||||
}
|
||||
|
||||
public HierNode(String name, String parentName) {
|
||||
this();
|
||||
this.name=name;
|
||||
this.parentName=parentName;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -46,6 +53,9 @@ public class HierNode implements IHierNode {
|
|||
|
||||
@Override
|
||||
public String getFullName() {
|
||||
if(parentName!=null && parentName.length()>0)
|
||||
return parentName+"."+name;
|
||||
else
|
||||
return name;
|
||||
}
|
||||
|
||||
|
@ -59,6 +69,11 @@ public class HierNode implements IHierNode {
|
|||
this.name=name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setParentName(String name) {
|
||||
this.parentName=name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IHierNode> getChildNodes() {
|
||||
return childs;
|
||||
|
|
|
@ -39,6 +39,8 @@ public interface IHierNode extends Comparable<IHierNode>{
|
|||
|
||||
public void setName(String name);
|
||||
|
||||
public void setParentName(String name);
|
||||
|
||||
public List<IHierNode> getChildNodes();
|
||||
|
||||
}
|
||||
|
|
|
@ -19,4 +19,6 @@ public interface IWaveform<T extends IWaveformEvent> extends IHierNode {
|
|||
|
||||
public IWaveformDb getDb();
|
||||
|
||||
public Boolean equals(IWaveform<? extends IWaveformEvent> other);
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
package com.minres.scviewer.database;
|
||||
|
||||
public interface IWaveformDbFactory {
|
||||
|
||||
IWaveformDb getDatabase();
|
||||
}
|
|
@ -8,7 +8,7 @@
|
|||
* Contributors:
|
||||
* MINRES Technologies GmbH - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package com.minres.scviewer.database;
|
||||
package com.minres.scviewer.database.internal;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
|
@ -18,6 +18,17 @@ import java.util.LinkedList;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.minres.scviewer.database.HierNode;
|
||||
import com.minres.scviewer.database.IHierNode;
|
||||
import com.minres.scviewer.database.ISignal;
|
||||
import com.minres.scviewer.database.ITxStream;
|
||||
import com.minres.scviewer.database.IWaveform;
|
||||
import com.minres.scviewer.database.IWaveformDb;
|
||||
import com.minres.scviewer.database.IWaveformDbLoader;
|
||||
import com.minres.scviewer.database.IWaveformEvent;
|
||||
import com.minres.scviewer.database.InputFormatException;
|
||||
|
||||
public class WaveformDb extends HierNode implements IWaveformDb {
|
||||
|
||||
private static List<IWaveformDbLoader> loaders=new LinkedList<IWaveformDbLoader>();
|
||||
|
@ -29,11 +40,11 @@ public class WaveformDb extends HierNode implements IWaveformDb {
|
|||
private Long maxTime;
|
||||
|
||||
|
||||
public void bind(IWaveformDbLoader loader){
|
||||
public synchronized void bind(IWaveformDbLoader loader){
|
||||
loaders.add(loader);
|
||||
}
|
||||
|
||||
public void unbind(IWaveformDbLoader loader){
|
||||
public synchronized void unbind(IWaveformDbLoader loader){
|
||||
loaders.remove(loader);
|
||||
}
|
||||
|
||||
|
@ -73,8 +84,8 @@ public class WaveformDb extends HierNode implements IWaveformDb {
|
|||
if(loader.getMaxTime()>maxTime){
|
||||
maxTime=loader.getMaxTime();
|
||||
}
|
||||
buildHierarchyNodes() ;
|
||||
if(name==null) name=getFileBasename(inp.getName());
|
||||
buildHierarchyNodes() ;
|
||||
pcs.firePropertyChange("WAVEFORMS", null, waveforms);
|
||||
pcs.firePropertyChange("CHILDS", null, childNodes);
|
||||
return true;
|
||||
|
@ -102,8 +113,10 @@ public class WaveformDb extends HierNode implements IWaveformDb {
|
|||
childNodes= new ArrayList<IHierNode>();
|
||||
for(IWaveform<?> stream:getAllWaves()){
|
||||
updateMaxTime(stream);
|
||||
String[] hier = stream.getFullName().split("\\.");
|
||||
String[] hier = stream.getName().split("\\.");
|
||||
IHierNode node = this;
|
||||
List<String> path=new LinkedList<String>();
|
||||
path.add(name);
|
||||
for(String name:hier){
|
||||
IHierNode n1 = null;
|
||||
for (IHierNode n : node.getChildNodes()) {
|
||||
|
@ -123,6 +136,7 @@ public class WaveformDb extends HierNode implements IWaveformDb {
|
|||
}
|
||||
}
|
||||
stream.setName(name);
|
||||
stream.setParentName(Joiner.on(".").join(path));
|
||||
node.getChildNodes().add(stream);
|
||||
Collections.sort(node.getChildNodes());
|
||||
node=stream;
|
||||
|
@ -130,12 +144,13 @@ public class WaveformDb extends HierNode implements IWaveformDb {
|
|||
if(n1 != null) {
|
||||
node=n1;
|
||||
} else {
|
||||
HierNode newNode = new HierNode(name);
|
||||
HierNode newNode = new HierNode(name, Joiner.on(".").join(path));
|
||||
node.getChildNodes().add(newNode);
|
||||
Collections.sort(node.getChildNodes());
|
||||
node=newNode;
|
||||
}
|
||||
}
|
||||
path.add(name);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package com.minres.scviewer.database.internal;
|
||||
|
||||
import com.minres.scviewer.database.IWaveformDb;
|
||||
import com.minres.scviewer.database.IWaveformDbFactory;
|
||||
|
||||
/**
|
||||
* @author eyck
|
||||
*
|
||||
*/
|
||||
public class WaveformDbFactory implements IWaveformDbFactory {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.minres.scviewer.database.IWaveformDbFactory#getDatabase()
|
||||
*/
|
||||
@Override
|
||||
public IWaveformDb getDatabase() {
|
||||
return new WaveformDb();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<project>
|
||||
<configuration id="cdt.managedbuild.config.gnu.macosx.exe.debug.133691581" name="Debug">
|
||||
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
|
||||
<provider-reference id="org.eclipse.cdt.ui.UserLanguageSettingsProvider" ref="shared-provider"/>
|
||||
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
|
||||
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
|
||||
<provider-reference id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetector" ref="shared-provider"/>
|
||||
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuildCommandParser" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser" keep-relative-paths="false" name="CDT GCC Build Output Parser" parameter="(gcc)|([gc]\+\+)|(clang)" prefer-non-shared="true"/>
|
||||
</extension>
|
||||
</configuration>
|
||||
<configuration id="cdt.managedbuild.config.macosx.exe.release.222902119" name="Release">
|
||||
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
|
||||
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
|
||||
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
|
||||
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
|
||||
<provider-reference id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetector" ref="shared-provider"/>
|
||||
</extension>
|
||||
</configuration>
|
||||
</project>
|
|
@ -0,0 +1 @@
|
|||
/target/
|
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>sqlite-jdbc.osgi</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
|
@ -0,0 +1,48 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>sqlite</groupId>
|
||||
<artifactId>sqlite-jdbc.osgi</artifactId>
|
||||
<version>3.8.7</version>
|
||||
<packaging>bundle</packaging>
|
||||
|
||||
<name>sqlite-jdbc.osgi-wrapped</name>
|
||||
<url>http://maven.apache.org</url>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.xerial</groupId>
|
||||
<artifactId>sqlite-jdbc</artifactId>
|
||||
<version>3.8.7</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>maven-bundle-plugin</artifactId>
|
||||
<version>2.3.7</version>
|
||||
<extensions>true</extensions>
|
||||
<configuration>
|
||||
<instructions>
|
||||
<Import-Package>*;resolution:=optional</Import-Package>
|
||||
<_exportcontents>*</_exportcontents>
|
||||
<Embed-Dependency>sqlite-jdbc</Embed-Dependency>
|
||||
</instructions>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
Loading…
Reference in New Issue