Fixed bugs and enhanced functionality to allow E4 application

This commit is contained in:
Eyck Jentzsch 2015-10-22 00:02:58 +02:00
parent 1f338cbf3f
commit ef3ce7273a
25 changed files with 1066 additions and 727 deletions

View File

@ -11,7 +11,6 @@ Require-Bundle: com.minres.scviewer.database;bundle-version="1.0.0",
org.eclipse.osgi.services;bundle-version="3.4.0" org.eclipse.osgi.services;bundle-version="3.4.0"
Bundle-ClassPath: .,sqlite-jdbc-3.8.7.jar Bundle-ClassPath: .,sqlite-jdbc-3.8.7.jar
Service-Component: OSGI-INF/component.xml Service-Component: OSGI-INF/component.xml
Export-Package: com.minres.scviewer.database.sqlite
Bundle-ActivationPolicy: lazy Bundle-ActivationPolicy: lazy
Embed-Dependency: sqlite-jdbc Embed-Dependency: sqlite-jdbc
Embedded-Artifacts: sqlite-jdbc-3.8.7.jar;g="org.xerial"; Embedded-Artifacts: sqlite-jdbc-3.8.7.jar;g="org.xerial";

View File

@ -33,10 +33,6 @@ public class SQLiteDbLoader implements IWaveformDbLoader {
protected IDatabase database; protected IDatabase database;
protected List<IWaveform<? extends IWaveformEvent>> streams;
long timeResolution=1;
private RelationTypeFactory rtf = new RelationTypeFactory(); private RelationTypeFactory rtf = new RelationTypeFactory();
private IWaveformDb db; private IWaveformDb db;
@ -63,9 +59,8 @@ public class SQLiteDbLoader implements IWaveformDbLoader {
@Override @Override
public List<IWaveform<? extends IWaveformEvent>> getAllWaves() { public List<IWaveform<? extends IWaveformEvent>> getAllWaves() {
if(streams==null){
SQLiteDatabaseSelectHandler<ScvStream> handler = new SQLiteDatabaseSelectHandler<ScvStream>(ScvStream.class, database); 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 { try {
for(ScvStream scvStream:handler.selectObjects()){ for(ScvStream scvStream:handler.selectObjects()){
TxStream stream = new TxStream(database, db, scvStream); TxStream stream = new TxStream(database, db, scvStream);
@ -74,8 +69,7 @@ public class SQLiteDbLoader implements IWaveformDbLoader {
} }
} catch (SecurityException | IllegalArgumentException | InstantiationException | IllegalAccessException } catch (SecurityException | IllegalArgumentException | InstantiationException | IllegalAccessException
| InvocationTargetException | SQLException | IntrospectionException e) { | InvocationTargetException | SQLException | IntrospectionException e) {
// e.printStackTrace(); // e.printStackTrace();
}
} }
return streams; return streams;
} }
@ -85,7 +79,6 @@ public class SQLiteDbLoader implements IWaveformDbLoader {
@Override @Override
public boolean load(IWaveformDb db, File file) throws Exception { public boolean load(IWaveformDb db, File file) throws Exception {
this.db=db; this.db=db;
streams=null;
FileInputStream fis = new FileInputStream(file); FileInputStream fis = new FileInputStream(file);
byte[] buffer = new byte[x.length]; byte[] buffer = new byte[x.length];
int read = fis.read(buffer, 0, x.length); int read = fis.read(buffer, 0, x.length);

View File

@ -27,7 +27,9 @@ import com.minres.scviewer.database.ITx;
import com.minres.scviewer.database.ITxEvent; import com.minres.scviewer.database.ITxEvent;
import com.minres.scviewer.database.ITxGenerator; import com.minres.scviewer.database.ITxGenerator;
import com.minres.scviewer.database.ITxStream; import com.minres.scviewer.database.ITxStream;
import com.minres.scviewer.database.IWaveform;
import com.minres.scviewer.database.IWaveformDb; import com.minres.scviewer.database.IWaveformDb;
import com.minres.scviewer.database.IWaveformEvent;
import com.minres.scviewer.database.RelationType; import com.minres.scviewer.database.RelationType;
import com.minres.scviewer.database.sqlite.db.IDatabase; import com.minres.scviewer.database.sqlite.db.IDatabase;
import com.minres.scviewer.database.sqlite.db.SQLiteDatabaseSelectHandler; import com.minres.scviewer.database.sqlite.db.SQLiteDatabaseSelectHandler;
@ -189,4 +191,9 @@ public class TxStream extends HierNode implements ITxStream<ITxEvent> {
return null; return null;
} }
@Override
public Boolean equals(IWaveform<? extends IWaveformEvent> other) {
return(other instanceof TxStream && this.getId()==other.getId());
}
} }

View File

@ -13,9 +13,11 @@ package com.minres.scviewer.database.swt;
import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener; import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport; import java.beans.PropertyChangeSupport;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.NavigableMap;
import java.util.TreeMap; import java.util.TreeMap;
import java.util.Vector; import java.util.Vector;
@ -41,6 +43,7 @@ import org.eclipse.swt.dnd.DropTargetEvent;
import org.eclipse.swt.dnd.Transfer; import org.eclipse.swt.dnd.Transfer;
import org.eclipse.swt.events.ControlAdapter; import org.eclipse.swt.events.ControlAdapter;
import org.eclipse.swt.events.ControlEvent; import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseListener; import org.eclipse.swt.events.MouseListener;
import org.eclipse.swt.events.SelectionAdapter; 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.Event;
import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.ScrollBar; import org.eclipse.swt.widgets.ScrollBar;
import org.eclipse.wb.swt.SWTResourceManager; import org.eclipse.wb.swt.SWTResourceManager;
import swing2swt.layout.BorderLayout;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.minres.scviewer.database.ISignal; import com.minres.scviewer.database.ISignal;
import com.minres.scviewer.database.ISignalChange; 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.TrackPainter;
import com.minres.scviewer.database.swt.internal.WaveformCanvas; 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 ListenerList selectionChangedListeners = new ListenerList();
private PropertyChangeSupport pcs; private PropertyChangeSupport pcs;
@ -99,7 +103,7 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
private Canvas nameList; private Canvas nameList;
private Canvas valueList; private Canvas valueList;
WaveformCanvas trackList; WaveformCanvas waveformList;
private Composite top; private Composite top;
@ -113,6 +117,95 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
// private long maxTime=0; // private long maxTime=0;
private Font nameFont, nameFontB; 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) { public TxDisplay(Composite parent) {
pcs=new PropertyChangeSupport(this); pcs=new PropertyChangeSupport(this);
@ -139,8 +232,8 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
trackPane = new Composite(topSash, SWT.NONE); trackPane = new Composite(topSash, SWT.NONE);
trackPane.setLayout(new BorderLayout(0, 0)); trackPane.setLayout(new BorderLayout(0, 0));
trackList = new WaveformCanvas(trackPane, SWT.NONE); waveformList = new WaveformCanvas(trackPane, SWT.NONE);
trackList.setLayoutData(BorderLayout.CENTER); waveformList.setLayoutData(BorderLayout.CENTER);
SashForm leftSash = new SashForm(composite, SWT.SMOOTH); SashForm leftSash = new SashForm(composite, SWT.SMOOTH);
leftSash.setBackground(leftSash.getDisplay().getSystemColor(SWT.COLOR_GRAY)); leftSash.setBackground(leftSash.getDisplay().getSystemColor(SWT.COLOR_GRAY));
@ -175,7 +268,7 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
paintNames(gc, rect); paintNames(gc, rect);
} }
}); });
nameList.addMouseListener(this); nameList.addMouseListener(nameValueMouseListener);
nameListScrolled.setContent(nameList); nameListScrolled.setContent(nameList);
Composite valuePane = createTextPane(leftSash, "Value"); Composite valuePane = createTextPane(leftSash, "Value");
@ -207,39 +300,39 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
paintValues(gc, rect); paintValues(gc, rect);
} }
}); });
valueList.addMouseListener(this); valueList.addMouseListener(nameValueMouseListener);
valueListScrolled.setContent(valueList); valueListScrolled.setContent(valueList);
trackList.setStreams(streams); waveformList.setStreams(streams);
// order is important: it is bottom to top // order is important: it is bottom to top
trackList.addPainter(new TrackPainter(trackList)); waveformList.addPainter(new TrackPainter(waveformList));
trackList.addPainter(new RulerPainter( waveformList.addPainter(new RulerPainter(
trackList, trackList.getDisplay().getSystemColor(SWT.COLOR_BLACK), trackList.getDisplay().getSystemColor(SWT.COLOR_WHITE))); waveformList, waveformList.getDisplay().getSystemColor(SWT.COLOR_BLACK), waveformList.getDisplay().getSystemColor(SWT.COLOR_WHITE)));
CursorPainter cp = new CursorPainter(trackList, trackList.getScaleFactor() * 10); CursorPainter cp = new CursorPainter(waveformList, waveformList.getScaleFactor() * 10);
trackList.addPainter(cp); waveformList.addPainter(cp);
cursorPainters.add(cp); cursorPainters.add(cp);
trackList.setMaxTime(1); waveformList.setMaxTime(1);
trackList.addMouseListener(this); waveformList.addMouseListener(waveformMouseListener);
nameListScrolled.getVerticalBar().addSelectionListener(new SelectionAdapter() { nameListScrolled.getVerticalBar().addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
int y = ((ScrollBar) e.widget).getSelection(); int y = ((ScrollBar) e.widget).getSelection();
Point v = valueListScrolled.getOrigin(); Point v = valueListScrolled.getOrigin();
valueListScrolled.setOrigin(v.x, y); valueListScrolled.setOrigin(v.x, y);
Point t = trackList.getOrigin(); Point t = waveformList.getOrigin();
trackList.setOrigin(t.x, -y); waveformList.setOrigin(t.x, -y);
} }
}); });
valueListScrolled.getVerticalBar().addSelectionListener(new SelectionAdapter() { valueListScrolled.getVerticalBar().addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
int y = ((ScrollBar) e.widget).getSelection(); int y = ((ScrollBar) e.widget).getSelection();
nameListScrolled.setOrigin(nameListScrolled.getOrigin().x, y); nameListScrolled.setOrigin(nameListScrolled.getOrigin().x, y);
trackList.setOrigin(trackList.getOrigin().x, -y); waveformList.setOrigin(waveformList.getOrigin().x, -y);
} }
}); });
trackList.addSelectionListener(new SelectionAdapter() { waveformList.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
int y = trackList.getVerticalBar().getSelection(); int y = waveformList.getVerticalBar().getSelection();
nameListScrolled.setOrigin(nameListScrolled.getOrigin().x, y); nameListScrolled.setOrigin(nameListScrolled.getOrigin().x, y);
valueListScrolled.setOrigin(valueListScrolled.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 }); topSash.setWeights(new int[] { 30, 70 });
leftSash.setWeights(new int[] { 75, 25 }); leftSash.setWeights(new int[] { 75, 25 });
createWaveDragSource(nameList); createStreamDragSource(nameList);
createWaveDragSource(valueList); createStreamDragSource(valueList);
createWaveDropTarget(nameList); createStreamDropTarget(nameList);
createWaveDropTarget(valueList); createStreamDropTarget(valueList);
createTrackDragSource(trackList); createWaveformDragSource(waveformList);
createTrackDropTarget(trackList); createWaveformDropTarget(waveformList);
} }
private Composite createTextPane(SashForm leftSash, String text) { 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); CLabel nameLabel = new CLabel(namePane, SWT.NONE);
GridData gd_nameLabel = new GridData(SWT.CENTER, SWT.CENTER, true, false, 1, 1); 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.setLayoutData(gd_nameLabel);
nameLabel.setText(text); nameLabel.setText(text);
@ -288,27 +381,28 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
protected void updateTracklist() { protected void updateTracklist() {
int trackVerticalHeight = 0; trackVerticalHeight = 0;
int nameMaxWidth = 0; int nameMaxWidth = 0;
int previousHeight = trackVerticalOffset.size() == 0 ? 0 : trackVerticalOffset.lastKey(); int previousHeight = trackVerticalOffset.size() == 0 ? 0 : trackVerticalOffset.lastKey();
IWaveformPainter painter = null; IWaveformPainter painter = null;
trackVerticalOffset.clear(); trackVerticalOffset.clear();
actualValues.clear(); actualValues.clear();
trackList.clearAllWavefromPainter(); waveformList.clearAllWavefromPainter();
boolean even = true; boolean even = true;
TextLayout tl = new TextLayout(trackList.getDisplay()); TextLayout tl = new TextLayout(waveformList.getDisplay());
tl.setFont(nameFontB); tl.setFont(nameFontB);
for (IWaveform<? extends IWaveformEvent> waveform : streams) { for (IWaveform<? extends IWaveformEvent> waveform : streams) {
int height = trackList.getTrackHeight(); int height = waveformList.getTrackHeight();
if (waveform instanceof ITxStream<?>) { if (waveform instanceof ITxStream<?>) {
height *= ((ITxStream<? extends ITxEvent>) waveform).getMaxConcurrency(); ITxStream<? extends ITxEvent> stream = (ITxStream<? extends ITxEvent>) waveform;
painter = new StreamPainter(trackList, even, height, (ITxStream<? extends ITxEvent>) waveform); height *= stream.getMaxConcurrency();
actualValues.put(waveform, ""); painter = new StreamPainter(waveformList, even, height, (ITxStream<? extends ITxEvent>) waveform);
actualValues.put(stream, "");
} else if (waveform instanceof ISignal<?>) { } else if (waveform instanceof ISignal<?>) {
painter = new SignalPainter(trackList, even, height, (ISignal<?>) waveform); painter = new SignalPainter(waveformList, even, height, (ISignal<?>) waveform);
actualValues.put(waveform, "---"); actualValues.put(waveform, "---");
} }
trackList.addWavefromPainter(trackVerticalHeight, painter); waveformList.addWavefromPainter(trackVerticalHeight, painter);
trackVerticalOffset.put(trackVerticalHeight, waveform); trackVerticalOffset.put(trackVerticalHeight, waveform);
tl.setText(waveform.getFullName()); tl.setText(waveform.getFullName());
nameMaxWidth = Math.max(nameMaxWidth, tl.getBounds().width); nameMaxWidth = Math.max(nameMaxWidth, tl.getBounds().width);
@ -321,17 +415,21 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
valueListScrolled.setMinSize(calculateValueWidth(), trackVerticalHeight); valueListScrolled.setMinSize(calculateValueWidth(), trackVerticalHeight);
nameList.redraw(); nameList.redraw();
updateValueList(); updateValueList();
trackList.redraw(); waveformList.redraw();
top.layout(new Control[] { valueList, nameList, trackList }); top.layout(new Control[] { valueList, nameList, waveformList });
if (previousHeight > trackVerticalOffset.lastKey()) { if (trackVerticalOffset.isEmpty() || previousHeight > trackVerticalOffset.lastKey()) {
Point o = trackList.getOrigin(); Point o = waveformList.getOrigin();
trackList.setOrigin(o.x, o.y - (previousHeight - trackVerticalOffset.lastKey())); waveformList.setOrigin(o.x, o.y - (previousHeight - trackVerticalOffset.lastKey()));
} }
setSelection(new StructuredSelection()); 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() { private int calculateValueWidth() {
TextLayout tl = new TextLayout(trackList.getDisplay()); TextLayout tl = new TextLayout(waveformList.getDisplay());
tl.setFont(nameFontB); tl.setFont(nameFontB);
int valueMaxWidth = 0; int valueMaxWidth = 0;
for (String v : actualValues.values()) { for (String v : actualValues.values()) {
@ -342,7 +440,7 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
} }
private void updateValueList(){ private void updateValueList(){
final Long time = cursorPainters.get(0).getTime(); final Long time = getCursorTime();
for(Entry<IWaveform<? extends IWaveformEvent>, String> entry:actualValues.entrySet()){ for(Entry<IWaveform<? extends IWaveformEvent>, String> entry:actualValues.entrySet()){
if(entry.getKey() instanceof ISignal){ if(entry.getKey() instanceof ISignal){
ISignalChange event = ((ISignal<?>)entry.getKey()).getWaveformEventsBeforeTime(time); ISignalChange event = ((ISignal<?>)entry.getKey()).getWaveformEventsBeforeTime(time);
@ -351,14 +449,43 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
} else if(event instanceof ISignalChangeMulti){ } else if(event instanceof ISignalChangeMulti){
entry.setValue("h'"+((ISignalChangeMulti)event).getValue().toHexString()); entry.setValue("h'"+((ISignalChangeMulti)event).getValue().toHexString());
} }
} /*else if(entry instanceof ITxStream){ } else if(entry.getKey() instanceof ITxStream<?>){
Collection<?> events = ((ITxStream<?>)entry.getKey()).getWaveformEventsAtTime(time); 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(); valueList.redraw();
} }
private boolean isArrayFull(Object[] array){
for(Object o:array){
if(o==null) return false;
}
return true;
}
@Override @Override
public void addSelectionChangedListener(ISelectionChangedListener listener) { public void addSelectionChangedListener(ISelectionChangedListener listener) {
selectionChangedListeners.add(listener); selectionChangedListeners.add(listener);
@ -373,6 +500,18 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
return top; return top;
} }
public Control getNameControl() {
return nameList;
}
public Control getValueControl() {
return valueList;
}
public Control getWaveformControl() {
return waveformList;
}
@Override @Override
public ISelection getSelection() { public ISelection getSelection() {
if(currentCursorSelection != null){ if(currentCursorSelection != null){
@ -396,13 +535,13 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
currentWaveformSelection = null; currentWaveformSelection = null;
currentCursorSelection=null; currentCursorSelection=null;
} else { } else {
Object sel = ((IStructuredSelection) selection).getFirstElement(); for(Object sel:((IStructuredSelection) selection).toArray()){
if (sel instanceof ITx && currentTxSelection != sel) { if (sel instanceof ITx && currentTxSelection != sel && streams.contains(((ITx)sel).getStream())) {
currentTxSelection = (ITx) sel; currentTxSelection = (ITx) sel;
currentWaveformSelection = currentTxSelection.getStream(); currentWaveformSelection = currentTxSelection.getStream();
currentCursorSelection=null; currentCursorSelection=null;
selectionChanged = true; selectionChanged = true;
} else if (sel instanceof IWaveform<?> && currentWaveformSelection != sel) { } else if (sel instanceof IWaveform<?> && currentWaveformSelection != sel&& streams.contains(sel)) {
currentTxSelection = null; currentTxSelection = null;
currentWaveformSelection = (IWaveform<? extends IWaveformEvent>) sel; currentWaveformSelection = (IWaveform<? extends IWaveformEvent>) sel;
currentCursorSelection=null; currentCursorSelection=null;
@ -414,6 +553,7 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
selectionChanged = true; selectionChanged = true;
} }
} }
}
} else { } else {
if (currentTxSelection != null || currentWaveformSelection != null) if (currentTxSelection != null || currentWaveformSelection != null)
selectionChanged = true; selectionChanged = true;
@ -421,11 +561,8 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
currentWaveformSelection = null; currentWaveformSelection = null;
currentCursorSelection=null; currentCursorSelection=null;
} }
if (currentWaveformSelection != null && !streams.contains(currentWaveformSelection)) {
streams.add(currentWaveformSelection);
}
if (selectionChanged) { if (selectionChanged) {
trackList.setSelected(currentTxSelection, currentWaveformSelection); waveformList.setSelected(currentTxSelection, currentWaveformSelection);
nameList.setData(SELECTION, currentWaveformSelection); nameList.setData(SELECTION, currentWaveformSelection);
valueList.redraw(); valueList.redraw();
nameList.redraw(); nameList.redraw();
@ -450,7 +587,7 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
transaction = evt.getTransaction(); transaction = evt.getTransaction();
break; break;
} }
meFound|= evt.getTransaction().getId()==currentTxSelection.getId(); meFound|= evt.getTransaction().equals(currentTxSelection);
} }
} }
if (transaction == null){ if (transaction == null){
@ -475,7 +612,7 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
transaction = evt.getTransaction(); transaction = evt.getTransaction();
break; break;
} }
meFound|= evt.getTransaction().getId()==currentTxSelection.getId(); meFound|= evt.getTransaction().equals(currentTxSelection);
} }
} }
if (transaction == null){ if (transaction == null){
@ -499,49 +636,48 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
} }
} }
@Override public void moveCursor(GotoDirection direction) {
public void mouseDoubleClick(MouseEvent e) { long time = getCursorTime();
if (e.button == 1&& e.widget == trackList) { NavigableMap<Long, ?> map=null;
Object o = trackList.getClicked(new Point(e.x, e.y)); if(currentWaveformSelection instanceof ITxStream<?>){
if (o != null) map=((ITxStream<?>) currentWaveformSelection).getEvents();
setSelection(new StructuredSelection(o)); } 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() { public List<IWaveform<? extends IWaveformEvent>> getStreamList() {
return streams; 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) { protected void paintNames(GC gc, Rectangle rect) {
if (streams.size() > 0) { if (streams.size() > 0) {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@ -550,20 +686,20 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
if (firstKey == null) if (firstKey == null)
firstKey = trackVerticalOffset.firstKey(); firstKey = trackVerticalOffset.firstKey();
Integer lastKey = trackVerticalOffset.floorKey(rect.y + rect.height); 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) { if (lastKey == firstKey) {
IWaveform<? extends IWaveformEvent> w = trackVerticalOffset.get(firstKey); IWaveform<? extends IWaveformEvent> w = trackVerticalOffset.get(firstKey);
if (w instanceof ITxStream<?>) if (w instanceof ITxStream<?>)
subArea.height *= ((ITxStream<?>) w).getMaxConcurrency(); 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 { } else {
for (Entry<Integer, IWaveform<? extends IWaveformEvent>> entry : trackVerticalOffset.subMap(firstKey, true, lastKey, true) for (Entry<Integer, IWaveform<? extends IWaveformEvent>> entry : trackVerticalOffset.subMap(firstKey, true, lastKey, true)
.entrySet()) { .entrySet()) {
IWaveform<? extends IWaveformEvent> w = entry.getValue(); IWaveform<? extends IWaveformEvent> w = entry.getValue();
subArea.height = trackList.getTrackHeight(); subArea.height = waveformList.getTrackHeight();
if (w instanceof ITxStream<?>) if (w instanceof ITxStream<?>)
subArea.height *= ((ITxStream<?>) w).getMaxConcurrency(); 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) if (firstKey == null)
firstKey = trackVerticalOffset.firstKey(); firstKey = trackVerticalOffset.firstKey();
Integer lastKey = trackVerticalOffset.floorKey(rect.y + rect.height); 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) { if (lastKey == firstKey) {
IWaveform<? extends IWaveformEvent> w = trackVerticalOffset.get(firstKey); IWaveform<? extends IWaveformEvent> w = trackVerticalOffset.get(firstKey);
if (w instanceof ITxStream<?>) if (w instanceof ITxStream<?>)
subArea.height *= ((ITxStream<?>) w).getMaxConcurrency(); 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 { } else {
for (Entry<Integer, IWaveform<? extends IWaveformEvent>> entry : trackVerticalOffset.subMap(firstKey, true, lastKey, true) for (Entry<Integer, IWaveform<? extends IWaveformEvent>> entry : trackVerticalOffset.subMap(firstKey, true, lastKey, true)
.entrySet()) { .entrySet()) {
IWaveform<? extends IWaveformEvent> w = entry.getValue(); IWaveform<? extends IWaveformEvent> w = entry.getValue();
subArea.height = trackList.getTrackHeight(); subArea.height = waveformList.getTrackHeight();
if (w instanceof ITxStream<?>) if (w instanceof ITxStream<?>)
subArea.height *= ((ITxStream<?>) w).getMaxConcurrency(); 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) { protected void drawTextFormat(GC gc, Rectangle subArea, int yOffset, String value, boolean highlite) {
Point size = gc.textExtent(value); Point size = gc.textExtent(value);
if (highlite) { if (highlite) {
@ -608,23 +754,23 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
gc.setForeground(SWTResourceManager.getColor(SWT.COLOR_LIST_FOREGROUND)); gc.setForeground(SWTResourceManager.getColor(SWT.COLOR_LIST_FOREGROUND));
gc.setFont(nameFont); 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() { public long getMaxTime() {
return trackList.getMaxTime(); return waveformList.getMaxTime();
} }
public void setMaxTime(long maxTime) { public void setMaxTime(long maxTime) {
this.trackList.setMaxTime(maxTime); this.waveformList.setMaxTime(maxTime);
} }
public void setZoomLevel(int scale) { public void setZoomLevel(int scale) {
trackList.setZoomLevel(scale); waveformList.setZoomLevel(scale);
} }
public int getZoomLevel() { public int getZoomLevel() {
return trackList.getZoomLevel(); return waveformList.getZoomLevel();
} }
public void setCursorTime(long time){ public void setCursorTime(long time){
@ -637,7 +783,7 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
return cursorPainters.get(0).getTime(); return cursorPainters.get(0).getTime();
} }
private void createWaveDragSource(final Canvas canvas) { private void createStreamDragSource(final Canvas canvas) {
Transfer[] types = new Transfer[] { LocalSelectionTransfer.getTransfer() }; Transfer[] types = new Transfer[] { LocalSelectionTransfer.getTransfer() };
DragSource dragSource = new DragSource(canvas, DND.DROP_MOVE); DragSource dragSource = new DragSource(canvas, DND.DROP_MOVE);
dragSource.setTransfer(types); dragSource.setTransfer(types);
@ -647,7 +793,7 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
// event.data = // event.data =
// trackVerticalOffset.floorEntry(event.y).getValue().getFullName(); // trackVerticalOffset.floorEntry(event.y).getValue().getFullName();
event.doit = true; event.doit = true;
LocalSelectionTransfer.getTransfer().setSelection(getSelection()); LocalSelectionTransfer.getTransfer().setSelection(new StructuredSelection(currentWaveformSelection));
// System.out.println("dragStart at location "+new // System.out.println("dragStart at location "+new
// Point(event.x, event.y)); // 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() }; Transfer[] types = new Transfer[] { LocalSelectionTransfer.getTransfer() };
DropTarget dropTarget = new DropTarget(canvas, DND.DROP_MOVE); DropTarget dropTarget = new DropTarget(canvas, DND.DROP_MOVE);
dropTarget.setTransfer(types); dropTarget.setTransfer(types);
dropTarget.addDropListener(new DropTargetAdapter() { dropTarget.addDropListener(new DropTargetAdapter() {
@SuppressWarnings("unchecked")
public void drop(DropTargetEvent event) { public void drop(DropTargetEvent event) {
if (LocalSelectionTransfer.getTransfer().isSupportedType(event.currentDataType)){ if (LocalSelectionTransfer.getTransfer().isSupportedType(event.currentDataType)){
ISelection sel = LocalSelectionTransfer.getTransfer().getSelection(); ISelection sel = LocalSelectionTransfer.getTransfer().getSelection();
@ -676,16 +823,18 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
Point dropPoint = ((Canvas) tgt.getControl()).toControl(event.x, event.y); Point dropPoint = ((Canvas) tgt.getControl()).toControl(event.x, event.y);
Object target = trackVerticalOffset.floorEntry(dropPoint.y).getValue(); Object target = trackVerticalOffset.floorEntry(dropPoint.y).getValue();
if(source instanceof IWaveform<?> && target instanceof IWaveform<?>){ if(source instanceof IWaveform<?> && target instanceof IWaveform<?>){
// int srcIdx=streams.indexOf(source); // int srcIdx=streams.indexOf(source);
// int tgtIdx=streams.indexOf(target); // int tgtIdx=streams.indexOf(target);
// if(srcIdx<tgtIdx){ // if(srcIdx<tgtIdx){
// streams.rotate(srcIdx, tgtIdx, -1); // streams.rotate(srcIdx, tgtIdx, -1);
// } else { // } else {
// streams.rotate(tgtIdx, srcIdx+1, 1); // streams.rotate(tgtIdx, srcIdx+1, 1);
// } // }
int srcIdx=streams.indexOf(source);
streams.remove(source); streams.remove(source);
int tgtIdx=streams.indexOf(target); 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){ } else if(source instanceof CursorPainter){
((CursorPainter)source).setTime(0); ((CursorPainter)source).setTime(0);
updateValueList(); updateValueList();
@ -694,36 +843,42 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
} }
} }
public void dropAccept(DropTargetEvent 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; event.detail = DND.DROP_NONE;
} }
} }
}); });
} }
private void createTrackDragSource(final Canvas canvas) { private void createWaveformDragSource(final Canvas canvas) {
Transfer[] types = new Transfer[] { LocalSelectionTransfer.getTransfer() }; Transfer[] types = new Transfer[] { LocalSelectionTransfer.getTransfer() };
DragSource dragSource = new DragSource(canvas, DND.DROP_MOVE); DragSource dragSource = new DragSource(canvas, DND.DROP_MOVE);
dragSource.setTransfer(types); dragSource.setTransfer(types);
dragSource.addDragListener(new DragSourceAdapter() { dragSource.addDragListener(new DragSourceAdapter() {
public void dragStart(DragSourceEvent event) { 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; event.doit = true;
LocalSelectionTransfer.getTransfer().setSelection(getSelection()); return;
currentCursorSelection.setDragging(true); }
} }
} }
public void dragSetData(DragSourceEvent event) { public void dragSetData(DragSourceEvent event) {
if (LocalSelectionTransfer.getTransfer().isSupportedType(event.dataType)) { 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() }; Transfer[] types = new Transfer[] { LocalSelectionTransfer.getTransfer() };
DropTarget dropTarget = new DropTarget(canvas, DND.DROP_MOVE); DropTarget dropTarget = new DropTarget(canvas, DND.DROP_MOVE);
dropTarget.setTransfer(types); dropTarget.setTransfer(types);
@ -731,52 +886,45 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
public void drop(DropTargetEvent event) { public void drop(DropTargetEvent event) {
if (LocalSelectionTransfer.getTransfer().isSupportedType(event.currentDataType)){ if (LocalSelectionTransfer.getTransfer().isSupportedType(event.currentDataType)){
ISelection sel = LocalSelectionTransfer.getTransfer().getSelection(); ISelection sel = LocalSelectionTransfer.getTransfer().getSelection();
if(sel!=null && sel instanceof IStructuredSelection){ if(sel!=null && sel instanceof IStructuredSelection &&
Object selObject = ((IStructuredSelection)sel).getFirstElement(); ((IStructuredSelection)sel).getFirstElement() instanceof CursorPainter){
if(selObject instanceof CursorPainter){ ((CursorPainter)((IStructuredSelection)sel).getFirstElement()).setDragging(false);
CursorPainter painter = (CursorPainter) selObject; updateWaveform(canvas, event);
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();
}
});
}
} }
} }
} }
public void dropAccept(DropTargetEvent 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; event.detail = DND.DROP_NONE;
} }
if(currentCursorSelection!=null) currentCursorSelection.setDragging(false);
} }
public void dragOver(DropTargetEvent event){ public void dragOver(DropTargetEvent event){
ISelection sel = LocalSelectionTransfer.getTransfer().getSelection(); ISelection sel = LocalSelectionTransfer.getTransfer().getSelection();
if(sel!=null && sel instanceof IStructuredSelection){ if(sel!=null && sel instanceof IStructuredSelection &&
Object selObject = ((IStructuredSelection)sel).getFirstElement(); ((IStructuredSelection)sel).getFirstElement() instanceof CursorPainter){
if(selObject instanceof CursorPainter){ updateWaveform(canvas, event);
DropTarget tgt = (DropTarget) event.widget; }
Point dropPoint = ((Canvas) tgt.getControl()).toControl(event.x, event.y); }
setCursorTime(trackList.getTimeForOffset(dropPoint.x));
((Canvas) tgt.getControl()).redraw(); 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() { canvas.getDisplay().asyncExec(new Runnable() {
@Override @Override
public void run() { public void run() {
if(!canvas.isDisposed()){
canvas.redraw();
updateValueList(); updateValueList();
} }
});
}
}
} }
}); });
} }
});
}
public void addPropertyChangeListener(PropertyChangeListener listener) { public void addPropertyChangeListener(PropertyChangeListener listener) {
this.pcs.addPropertyChangeListener(listener); this.pcs.addPropertyChangeListener(listener);

View File

@ -42,7 +42,7 @@ public class SignalPainter implements IWaveformPainter {
} }
public void paintArea(GC gc, Rectangle area) { 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()]); gc.setBackground(this.waveCanvas.colors[WaveformCanvas.Colors.TRACK_BG_HIGHLITE.ordinal()]);
else else
gc.setBackground(this.waveCanvas.colors[even?WaveformCanvas.Colors.TRACK_BG_EVEN.ordinal():WaveformCanvas.Colors.TRACK_BG_ODD.ordinal()]); gc.setBackground(this.waveCanvas.colors[even?WaveformCanvas.Colors.TRACK_BG_EVEN.ordinal():WaveformCanvas.Colors.TRACK_BG_ODD.ordinal()]);

View File

@ -51,12 +51,12 @@ public class StreamPainter implements IWaveformPainter{
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void paintArea(GC gc, Rectangle area) { public void paintArea(GC gc, Rectangle area) {
if(stream.getEvents().size()==0) return; 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()]); gc.setBackground(this.waveCanvas.colors[WaveformCanvas.Colors.TRACK_BG_HIGHLITE.ordinal()]);
else else
gc.setBackground(this.waveCanvas.colors[even?WaveformCanvas.Colors.TRACK_BG_EVEN.ordinal():WaveformCanvas.Colors.TRACK_BG_ODD.ordinal()]); gc.setBackground(this.waveCanvas.colors[even?WaveformCanvas.Colors.TRACK_BG_EVEN.ordinal():WaveformCanvas.Colors.TRACK_BG_ODD.ordinal()]);
gc.setFillRule(SWT.FILL_EVEN_ODD); gc.setFillRule(SWT.FILL_EVEN_ODD);
gc.fillRectangle(0,0,area.width, area.height); gc.fillRectangle(area);
Entry<Long, ?> firstTx=stream.getEvents().floorEntry(area.x*waveCanvas.getScaleFactor()); Entry<Long, ?> firstTx=stream.getEvents().floorEntry(area.x*waveCanvas.getScaleFactor());
Entry<Long, ?> lastTx=stream.getEvents().ceilingEntry((area.x+area.width)*waveCanvas.getScaleFactor()); Entry<Long, ?> lastTx=stream.getEvents().ceilingEntry((area.x+area.width)*waveCanvas.getScaleFactor());
if(firstTx==null) firstTx = stream.getEvents().firstEntry(); if(firstTx==null) firstTx = stream.getEvents().firstEntry();
@ -82,7 +82,7 @@ public class StreamPainter implements IWaveformPainter{
seenTx.add(txEvent.getTransaction()); seenTx.add(txEvent.getTransaction());
if(txEvent.getType()==ITxEvent.Type.END){ if(txEvent.getType()==ITxEvent.Type.END){
ITx tx = txEvent.getTransaction(); 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); drawTx(gc, area, tx);
seenTx.remove(tx); seenTx.remove(tx);
} }

View File

@ -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)) { for (IPainter p : Lists.reverse(painterList)) {
if (p instanceof TrackPainter) { if (p instanceof TrackPainter) {
int y = point.y - origin.y; int y = point.y - origin.y;
@ -335,17 +336,28 @@ public class WaveformCanvas extends Canvas {
Entry<Integer, IWaveformPainter> entry = trackVerticalOffset.floorEntry(y); Entry<Integer, IWaveformPainter> entry = trackVerticalOffset.floorEntry(y);
if (entry != null) { if (entry != null) {
if (entry.getValue() instanceof StreamPainter) { 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) } else if (entry.getValue() instanceof SignalPainter)
return ((SignalPainter) entry.getValue()).getSignal(); result.add(((SignalPainter) entry.getValue()).getSignal());
} }
} else if (p instanceof CursorPainter) { } else if (p instanceof CursorPainter) {
if (Math.abs(point.x - ((CursorPainter) p).getTime()/scaleFactor) < 2) { if (Math.abs(point.x - origin.x - ((CursorPainter) p).getTime()/scaleFactor) < 2) {
return p; 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) { 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() { public int getRulerHeight() {
return rulerHeight; return rulerHeight;
} }

View File

@ -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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* MINRES Technologies GmbH - initial API and implementation * Google, Inc. - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.wb.swt; package org.eclipse.wb.swt;

View File

@ -21,7 +21,7 @@ import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import com.minres.scviewer.database.IWaveformDb; import com.minres.scviewer.database.IWaveformDb;
import com.minres.scviewer.database.WaveformDb; import com.minres.scviewer.database.internal.WaveformDb;
public class DatabaseServicesTest { public class DatabaseServicesTest {

View File

@ -14,5 +14,4 @@ Require-Bundle: com.minres.scviewer.database;bundle-version="1.0.0",
org.eclipse.osgi.services;bundle-version="3.4.0", org.eclipse.osgi.services;bundle-version="3.4.0",
com.google.guava;bundle-version="15.0.0" com.google.guava;bundle-version="15.0.0"
Service-Component: OSGI-INF/component.xml Service-Component: OSGI-INF/component.xml
Export-Package: com.minres.scviewer.database.text
Bundle-ActivationPolicy: lazy Bundle-ActivationPolicy: lazy

View File

@ -17,12 +17,13 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.NavigableMap; import java.util.NavigableMap;
import com.google.common.collect.TreeMultimap; import com.google.common.collect.TreeMultimap
import com.minres.scviewer.database.HierNode;
import com.minres.scviewer.database.ITxEvent; import com.minres.scviewer.database.ITxEvent;
import com.minres.scviewer.database.IWaveform; import com.minres.scviewer.database.IWaveform;
import com.minres.scviewer.database.IWaveformDb import com.minres.scviewer.database.IWaveformDb
import com.minres.scviewer.database.IWaveformEvent
import com.minres.scviewer.database.ITxGenerator import com.minres.scviewer.database.ITxGenerator
import com.minres.scviewer.database.HierNode;
import com.minres.scviewer.database.IHierNode import com.minres.scviewer.database.IHierNode
import com.minres.scviewer.database.ITxStream import com.minres.scviewer.database.ITxStream
import com.minres.scviewer.database.ITx import com.minres.scviewer.database.ITx
@ -107,4 +108,10 @@ class TxStream extends HierNode implements ITxStream {
public Collection getWaveformEventsAtTime(Long time) { public Collection getWaveformEventsAtTime(Long time) {
return events.get(time); return events.get(time);
} }
@Override
public Boolean equals(IWaveform<? extends IWaveformEvent> other) {
return(other instanceof TxStream && this.getId()==other.getId());
}
} }

View File

@ -109,6 +109,11 @@ public class VCDSignal<T extends ISignalChange> extends HierNode implements ISig
return values.floorEntry(time).getValue(); return values.floorEntry(time).getValue();
} }
@Override
public Boolean equals(IWaveform<? extends IWaveformEvent> other) {
return(other instanceof VCDSignal<?> && this.getId()==other.getId());
}
} }

View File

@ -7,7 +7,8 @@ Bundle-Vendor: MINRES Technologies GmbH
Bundle-RequiredExecutionEnvironment: JavaSE-1.7 Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Export-Package: com.minres.scviewer.database Export-Package: com.minres.scviewer.database
Bundle-ActivationPolicy: lazy 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", Require-Bundle: org.eclipse.equinox.ds;bundle-version="1.4.200",
org.eclipse.equinox.util;bundle-version="1.0.500", 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

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?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"> <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.WaveformDb"/> <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"/> <reference bind="bind" cardinality="1..n" interface="com.minres.scviewer.database.IWaveformDbLoader" name="IWaveformDbLoader" policy="dynamic" unbind="unbind"/>
</scr:component> </scr:component>

View File

@ -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>

View File

@ -19,6 +19,8 @@ public class HierNode implements IHierNode {
protected String name; protected String name;
protected String parentName;
protected ArrayList<IHierNode> childs; protected ArrayList<IHierNode> childs;
protected PropertyChangeSupport pcs; protected PropertyChangeSupport pcs;
@ -29,8 +31,13 @@ public class HierNode implements IHierNode {
} }
public HierNode(String name) { public HierNode(String name) {
this(name, "");
}
public HierNode(String name, String parentName) {
this(); this();
this.name=name; this.name=name;
this.parentName=parentName;
} }
@Override @Override
@ -46,6 +53,9 @@ public class HierNode implements IHierNode {
@Override @Override
public String getFullName() { public String getFullName() {
if(parentName!=null && parentName.length()>0)
return parentName+"."+name;
else
return name; return name;
} }
@ -59,6 +69,11 @@ public class HierNode implements IHierNode {
this.name=name; this.name=name;
} }
@Override
public void setParentName(String name) {
this.parentName=name;
}
@Override @Override
public List<IHierNode> getChildNodes() { public List<IHierNode> getChildNodes() {
return childs; return childs;

View File

@ -39,6 +39,8 @@ public interface IHierNode extends Comparable<IHierNode>{
public void setName(String name); public void setName(String name);
public void setParentName(String name);
public List<IHierNode> getChildNodes(); public List<IHierNode> getChildNodes();
} }

View File

@ -19,4 +19,6 @@ public interface IWaveform<T extends IWaveformEvent> extends IHierNode {
public IWaveformDb getDb(); public IWaveformDb getDb();
public Boolean equals(IWaveform<? extends IWaveformEvent> other);
} }

View File

@ -0,0 +1,6 @@
package com.minres.scviewer.database;
public interface IWaveformDbFactory {
IWaveformDb getDatabase();
}

View File

@ -8,7 +8,7 @@
* Contributors: * Contributors:
* MINRES Technologies GmbH - initial API and implementation * MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package com.minres.scviewer.database; package com.minres.scviewer.database.internal;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
@ -18,6 +18,17 @@ import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; 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 { public class WaveformDb extends HierNode implements IWaveformDb {
private static List<IWaveformDbLoader> loaders=new LinkedList<IWaveformDbLoader>(); private static List<IWaveformDbLoader> loaders=new LinkedList<IWaveformDbLoader>();
@ -29,11 +40,11 @@ public class WaveformDb extends HierNode implements IWaveformDb {
private Long maxTime; private Long maxTime;
public void bind(IWaveformDbLoader loader){ public synchronized void bind(IWaveformDbLoader loader){
loaders.add(loader); loaders.add(loader);
} }
public void unbind(IWaveformDbLoader loader){ public synchronized void unbind(IWaveformDbLoader loader){
loaders.remove(loader); loaders.remove(loader);
} }
@ -73,8 +84,8 @@ public class WaveformDb extends HierNode implements IWaveformDb {
if(loader.getMaxTime()>maxTime){ if(loader.getMaxTime()>maxTime){
maxTime=loader.getMaxTime(); maxTime=loader.getMaxTime();
} }
buildHierarchyNodes() ;
if(name==null) name=getFileBasename(inp.getName()); if(name==null) name=getFileBasename(inp.getName());
buildHierarchyNodes() ;
pcs.firePropertyChange("WAVEFORMS", null, waveforms); pcs.firePropertyChange("WAVEFORMS", null, waveforms);
pcs.firePropertyChange("CHILDS", null, childNodes); pcs.firePropertyChange("CHILDS", null, childNodes);
return true; return true;
@ -102,8 +113,10 @@ public class WaveformDb extends HierNode implements IWaveformDb {
childNodes= new ArrayList<IHierNode>(); childNodes= new ArrayList<IHierNode>();
for(IWaveform<?> stream:getAllWaves()){ for(IWaveform<?> stream:getAllWaves()){
updateMaxTime(stream); updateMaxTime(stream);
String[] hier = stream.getFullName().split("\\."); String[] hier = stream.getName().split("\\.");
IHierNode node = this; IHierNode node = this;
List<String> path=new LinkedList<String>();
path.add(name);
for(String name:hier){ for(String name:hier){
IHierNode n1 = null; IHierNode n1 = null;
for (IHierNode n : node.getChildNodes()) { for (IHierNode n : node.getChildNodes()) {
@ -123,6 +136,7 @@ public class WaveformDb extends HierNode implements IWaveformDb {
} }
} }
stream.setName(name); stream.setName(name);
stream.setParentName(Joiner.on(".").join(path));
node.getChildNodes().add(stream); node.getChildNodes().add(stream);
Collections.sort(node.getChildNodes()); Collections.sort(node.getChildNodes());
node=stream; node=stream;
@ -130,12 +144,13 @@ public class WaveformDb extends HierNode implements IWaveformDb {
if(n1 != null) { if(n1 != null) {
node=n1; node=n1;
} else { } else {
HierNode newNode = new HierNode(name); HierNode newNode = new HierNode(name, Joiner.on(".").join(path));
node.getChildNodes().add(newNode); node.getChildNodes().add(newNode);
Collections.sort(node.getChildNodes()); Collections.sort(node.getChildNodes());
node=newNode; node=newNode;
} }
} }
path.add(name);
} }
} }
} }

View File

@ -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();
}
}

View File

@ -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>

1
sqlite-jdbc.osgi/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/target/

17
sqlite-jdbc.osgi/.project Normal file
View File

@ -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>

48
sqlite-jdbc.osgi/pom.xml Normal file
View File

@ -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>