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"
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";

View File

@ -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,19 +59,17 @@ 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>>();
try {
for(ScvStream scvStream:handler.selectObjects()){
TxStream stream = new TxStream(database, db, scvStream);
stream.setRelationTypeFactory(rtf);
streams.add(stream);
}
} catch (SecurityException | IllegalArgumentException | InstantiationException | IllegalAccessException
| InvocationTargetException | SQLException | IntrospectionException e) {
// e.printStackTrace();
SQLiteDatabaseSelectHandler<ScvStream> handler = new SQLiteDatabaseSelectHandler<ScvStream>(ScvStream.class, database);
List<IWaveform<? extends IWaveformEvent>> streams=new ArrayList<IWaveform<? extends IWaveformEvent>>();
try {
for(ScvStream scvStream:handler.selectObjects()){
TxStream stream = new TxStream(database, db, scvStream);
stream.setRelationTypeFactory(rtf);
streams.add(stream);
}
} catch (SecurityException | IllegalArgumentException | InstantiationException | IllegalAccessException
| 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);

View File

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

View File

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

View File

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

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)) {
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;
}

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
* 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;

View File

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

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",
com.google.guava;bundle-version="15.0.0"
Service-Component: OSGI-INF/component.xml
Export-Package: com.minres.scviewer.database.text
Bundle-ActivationPolicy: lazy

View File

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

View File

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

View File

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

View File

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

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 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,7 +53,10 @@ public class HierNode implements IHierNode {
@Override
public String getFullName() {
return name;
if(parentName!=null && parentName.length()>0)
return parentName+"."+name;
else
return name;
}
@Override
@ -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;

View File

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

View File

@ -19,4 +19,6 @@ public interface IWaveform<T extends IWaveformEvent> extends IHierNode {
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:
* 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,16 +113,18 @@ 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()) {
if (n.getName().equals(name)) {
n1=n;
break;
}
}
for (IHierNode n : node.getChildNodes()) {
if (n.getName().equals(name)) {
n1=n;
break;
}
}
if(name == hier[hier.length-1]){ //leaf
if(n1!=null) {
if(n1 instanceof HierNode){
@ -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);
}
}
}

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>