Compare commits

...

50 Commits

Author SHA1 Message Date
9f902057ba Merge branch 'release/2.0.1' 2018-10-15 22:30:02 +02:00
42660c7a2e Fixed some warnings 2018-10-15 22:01:44 +02:00
97a806f9d9 Changed selection handling and fixed keycode handling 2018-10-15 21:55:35 +02:00
60185fbaee Version inconsitency fixes 2018-10-15 10:09:51 +02:00
5fb9a7dcdf Merge branch 'master' of https://git.minres.com/VP/SCViewer 2018-10-15 09:15:04 +02:00
3faa7205ae Merge branch 'release/2.0' into develop 2018-10-15 09:13:55 +02:00
3cbe5d56d9 Merge branch 'release/2.0' 2018-10-15 09:13:54 +02:00
5745ab4f2c Fixed cli options and NaN handling in VCD loader 2018-10-15 09:13:41 +02:00
4a17108ccc Moved commonly used constants to own class 2018-10-15 09:10:10 +02:00
408138c27c Merge branch 'develop' of https://git.minres.com/VP/SCViewer into develop 2018-10-15 07:50:31 +02:00
3211db8743 Merge branch 'release/2.0' 2018-10-14 21:29:23 +02:00
0c81988d8c Merge branch 'release/2.0' into develop 2018-10-14 21:29:23 +02:00
0107c423a3 Fixed warnings in Java files and MANIFESTS.MF, updated version numbers 2018-10-14 21:29:09 +02:00
5d41816eb6 Merge branch 'feature/add-keyboard-navigation' into develop 2018-10-14 20:44:41 +02:00
e41b7e25ed Updated reading/writing of scview files, added command line argument to
load config file
2018-10-14 20:44:17 +02:00
dba8b2731d Added keyboard navigation to scroll, move selection, move selected and
zoom
2018-10-14 17:30:37 +02:00
048fa93b53 Merge branch 'feature/Extend-waveform-configurability' into develop 2018-10-14 08:59:37 +02:00
6cc5597c25 Added handler and configurability of wavefrom view 2018-10-14 08:59:17 +02:00
694423be3b [WIP] extended application to configure waveform display 2018-10-11 15:23:07 +02:00
0634b9cfd5 Merge branch 'develop' of https://git.minres.com/VP/SCViewer.git into
develop

Conflicts:
	com.minres.scviewer.database.test/inputs/simple_system.vcd
	com.minres.scviewer.database.test/src/com/minres/scviewer/database/test/DatabaseServicesTest.java
	com.minres.scviewer.database.text/.settings/org.eclipse.jdt.groovy.core.prefs
	com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/SignalPainter.java
	com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/WaveformCanvas.java
	com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/WaveformViewer.java
	com.minres.scviewer.database.ui/src/com/minres/scviewer/database/ui/WaveformColors.java
	com.minres.scviewer.database.vcd/src/com/minres/scviewer/database/vcd/VCDDbLoader.java
	com.minres.scviewer.database.vcd/src/com/minres/scviewer/database/vcd/VCDFileParser.java
	com.minres.scviewer.e4.application/plugin.xml
	com.minres.scviewer.e4.product/scviewer.product
	com.minres.scviewer.target/neon.target
	com.minres.scviewer.target/photon.target
	com.minres.scviewer.ui/.settings/org.eclipse.jdt.groovy.core.prefs
2018-10-11 15:22:10 +02:00
c4b16338a8 Merge branch 'feature/real_signal_support' into develop 2018-10-11 14:53:07 +02:00
bda2a84532 Fixed #6 Implement right-click menue for signal names 2018-10-11 14:48:36 +02:00
9d4c951e7f Added support for real valued signals in waveform UI 2018-10-11 14:44:41 +02:00
8a89b21d34 Added database support to read real valued signals 2018-10-11 11:23:28 +02:00
e02df858fa Merge branch 'develop' of https://git.minres.com/VP/SCViewer into develop 2018-09-26 21:25:23 +02:00
0fbe22e2e0 Fixed NPE when concurrencyLevel is 0 2018-09-26 21:25:02 +02:00
021c2bceff Fixed ZoomFit and encoding issue 2018-09-17 17:06:57 +02:00
9862c14040 Additional files missing in the last commit 2018-09-17 16:38:27 +02:00
23131e7527 Fixed ZoomFit 2018-09-17 16:38:26 +02:00
0833bca1bd Fixed VCD parsing error 2018-09-17 16:38:25 +02:00
1cf00ec882 Updated to Photon platform 2018-09-17 16:38:24 +02:00
6c0bbd5f1f Added hierarchical VCD File 2018-09-17 16:32:07 +02:00
f13b091664 Update README.md 2018-09-17 16:26:49 +02:00
dff41eceb2 Updated version numbers 2018-09-17 16:26:49 +02:00
d267e64907 Fixed parsing bug 2018-09-17 16:26:49 +02:00
792dcd55f3 Fixed rendering of integral transaction attributes and updated version
numbers
2018-09-17 16:26:48 +02:00
2b33ea0c85 Fixed drawing issue for very long transactions 2018-08-27 23:46:06 +02:00
f69a6f2e89 Removed jdbm 2018-08-27 23:16:54 +02:00
0f133a3df6 Added UI support for real value signals 2018-08-27 23:13:19 +02:00
2f11d8ed7b Fixed VCD parsing error 2018-07-16 13:17:58 +02:00
7dd0a24df6 Updated to Photon platform 2018-07-16 13:17:43 +02:00
a052fe2324 Added hierarchical VCD File 2018-07-14 11:42:55 +02:00
4fc24453ae Merge branch 'develop'
* develop:
  Update README.md
2018-04-05 23:10:31 +02:00
b468fba441 Update README.md 2018-04-05 23:04:12 +02:00
f80021059e Update README.md 2017-11-01 19:02:01 +01:00
7c0822b4d2 Merge pull request #4 from Minres/develop
Develop
2017-10-14 19:06:53 +00:00
cdde384ed3 Updated version numbers 2017-10-14 20:59:30 +02:00
fce1bdb1e7 Fixed parsing bug 2017-10-14 20:46:22 +02:00
b68a7d3259 Merge pull request #3 from Minres/develop
Changes for 1.2.1 version
2017-10-13 08:03:11 +00:00
44b13c105d Fixed rendering of integral transaction attributes and updated version
numbers
2017-10-13 09:36:44 +02:00
76 changed files with 6517 additions and 437 deletions

View File

@ -6,6 +6,8 @@ created by the SystemC VCD trace implementation and the SystemC Verification Lib
For further description of the SCV please refer to For further description of the SCV please refer to
http://www.accellera.org/activities/committees/systemc-verification. http://www.accellera.org/activities/committees/systemc-verification.
> If you encounter issue when running on Linux please try running as `SWT_GTK3=0 scviewer` as there exist issues wiht GTK3.
The viewer is in early alpha stage and not yet ready for production use! The viewer is in early alpha stage and not yet ready for production use!
The plugins are structured as follows: The plugins are structured as follows:
@ -39,4 +41,4 @@ TODO
- add more tests - add more tests
- move to feature based product to allow automatic updates - move to feature based product to allow automatic updates
- improve graphics - improve graphics
- catch-up e3 plugin to functionality of e4 product - catch-up e3 plugin to functionality of e4 product

View File

@ -15,3 +15,4 @@ 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";
a="sqlite-jdbc";v="3.8.7" a="sqlite-jdbc";v="3.8.7"
Automatic-Module-Name: com.minres.scviewer.database.sqlite

View File

@ -4,7 +4,7 @@
<parent> <parent>
<groupId>com.minres.scviewer</groupId> <groupId>com.minres.scviewer</groupId>
<artifactId>com.minres.scviewer.parent</artifactId> <artifactId>com.minres.scviewer.parent</artifactId>
<version>1.0.0-SNAPSHOT</version> <version>2.0.0-SNAPSHOT</version>
<relativePath>../com.minres.scviewer.parent</relativePath> <relativePath>../com.minres.scviewer.parent</relativePath>
</parent> </parent>
<packaging>eclipse-plugin</packaging> <packaging>eclipse-plugin</packaging>
@ -15,4 +15,5 @@
<version>3.8.7</version> <version>3.8.7</version>
</dependency> </dependency>
</dependencies> </dependencies>
</project> <version>1.0.0-SNAPSHOT</version>
</project>

View File

@ -117,6 +117,7 @@ public class TxStream extends HierNode implements ITxStream<ITxEvent> {
sb.append(scvStream.getId()); sb.append(scvStream.getId());
resultSet = statement.executeQuery(sb.toString()); resultSet = statement.executeQuery(sb.toString());
while (resultSet.next()) { while (resultSet.next()) {
if(maxConcurrency==null) maxConcurrency=0;
Object value = resultSet.getObject("concurrencyLevel"); Object value = resultSet.getObject("concurrencyLevel");
if(value!=null) if(value!=null)
maxConcurrency=(Integer) value; maxConcurrency=(Integer) value;

View File

@ -11,7 +11,7 @@
<booleanAttribute key="clearws" value="true"/> <booleanAttribute key="clearws" value="true"/>
<booleanAttribute key="clearwslog" value="false"/> <booleanAttribute key="clearwslog" value="false"/>
<stringAttribute key="configLocation" value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/pde-junit"/> <stringAttribute key="configLocation" value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/pde-junit"/>
<booleanAttribute key="default" value="false"/> <booleanAttribute key="default" value="true"/>
<stringAttribute key="deselected_workspace_plugins" value="com.minres.scviewer.e4.application,com.minres.scviewer.ui"/> <stringAttribute key="deselected_workspace_plugins" value="com.minres.scviewer.e4.application,com.minres.scviewer.ui"/>
<booleanAttribute key="includeOptional" value="true"/> <booleanAttribute key="includeOptional" value="true"/>
<stringAttribute key="location" value="${workspace_loc}/../junit-workspace"/> <stringAttribute key="location" value="${workspace_loc}/../junit-workspace"/>
@ -35,8 +35,8 @@
<stringAttribute key="pde.version" value="3.3"/> <stringAttribute key="pde.version" value="3.3"/>
<stringAttribute key="product" value="com.minres.scviewer.e4.product"/> <stringAttribute key="product" value="com.minres.scviewer.e4.product"/>
<booleanAttribute key="run_in_ui_thread" value="true"/> <booleanAttribute key="run_in_ui_thread" value="true"/>
<stringAttribute key="selected_target_plugins" value="com.google.guava@default:default,javax.annotation@default:default,javax.inject@default:default,javax.servlet@default:default,javax.xml@default:default,org.apache.ant@default:default,org.apache.commons.jxpath@default:default,org.apache.felix.gogo.command@default:default,org.apache.felix.gogo.runtime@default:default,org.codehaus.groovy@default:default,org.eclipse.ant.core@default:default,org.eclipse.core.commands@default:default,org.eclipse.core.contenttype@default:default,org.eclipse.core.expressions@default:default,org.eclipse.core.filesystem@default:default,org.eclipse.core.jobs@default:default,org.eclipse.core.resources@default:default,org.eclipse.core.runtime@default:true,org.eclipse.core.variables@default:default,org.eclipse.e4.core.contexts@default:default,org.eclipse.e4.core.di.annotations@default:default,org.eclipse.e4.core.di.extensions@default:default,org.eclipse.e4.core.di@default:default,org.eclipse.e4.core.services@default:default,org.eclipse.e4.emf.xpath@default:default,org.eclipse.e4.ui.di@default:default,org.eclipse.e4.ui.model.workbench@default:default,org.eclipse.e4.ui.services@default:default,org.eclipse.emf.common@default:default,org.eclipse.emf.ecore@default:default,org.eclipse.equinox.app@default:default,org.eclipse.equinox.bidi@default:default,org.eclipse.equinox.common@2:true,org.eclipse.equinox.ds@1:true,org.eclipse.equinox.preferences@default:default,org.eclipse.equinox.registry@default:default,org.eclipse.equinox.util@default:default,org.eclipse.jface@default:default,org.eclipse.osgi.compatibility.state@default:false,org.eclipse.osgi.services@default:default,org.eclipse.osgi@-1:true,org.eclipse.swt@default:default,org.hamcrest.core@default:default,org.junit@default:default"/> <stringAttribute key="selected_target_plugins" value="com.google.guava@default:default,javax.annotation@default:default,javax.inject@default:default,javax.servlet@default:default,org.apache.ant@default:default,org.apache.commons.jxpath@default:default,org.apache.felix.gogo.command@default:default,org.apache.felix.gogo.runtime@default:default,org.codehaus.groovy@default:default,org.eclipse.ant.core@default:default,org.eclipse.core.commands@default:default,org.eclipse.core.contenttype@default:default,org.eclipse.core.expressions@default:default,org.eclipse.core.filesystem.macosx@default:false,org.eclipse.core.filesystem@default:default,org.eclipse.core.jobs@default:default,org.eclipse.core.resources@default:default,org.eclipse.core.runtime@default:true,org.eclipse.core.variables@default:default,org.eclipse.e4.core.contexts@default:default,org.eclipse.e4.core.di.annotations@default:default,org.eclipse.e4.core.di.extensions@default:default,org.eclipse.e4.core.di@default:default,org.eclipse.e4.core.services@default:default,org.eclipse.e4.emf.xpath@default:default,org.eclipse.e4.ui.di@default:default,org.eclipse.e4.ui.model.workbench@default:default,org.eclipse.e4.ui.services@default:default,org.eclipse.emf.common@default:default,org.eclipse.emf.ecore@default:default,org.eclipse.equinox.app@default:default,org.eclipse.equinox.bidi@default:default,org.eclipse.equinox.common@2:true,org.eclipse.equinox.ds@1:true,org.eclipse.equinox.preferences@default:default,org.eclipse.equinox.registry@default:default,org.eclipse.equinox.util@default:default,org.eclipse.jface@default:default,org.eclipse.osgi.compatibility.state@default:false,org.eclipse.osgi.services@default:default,org.eclipse.osgi@-1:true,org.eclipse.swt.cocoa.macosx.x86_64@default:false,org.eclipse.swt@default:default,org.hamcrest.core@default:default,org.junit@default:default"/>
<stringAttribute key="selected_workspace_plugins" value="com.minres.scviewer.database.binary@default:default,com.minres.scviewer.database.sqlite@default:true,com.minres.scviewer.database.test@default:default,com.minres.scviewer.database.text@default:true,com.minres.scviewer.database.ui.swt@default:default,com.minres.scviewer.database.ui@default:default,com.minres.scviewer.database.vcd@default:default,com.minres.scviewer.database@default:true,com.opcoach.e4.preferences@default:default"/> <stringAttribute key="selected_workspace_plugins" value="com.minres.scviewer.database.sqlite@default:true,com.minres.scviewer.database.test@default:default,com.minres.scviewer.database.text@default:true,com.minres.scviewer.database.ui.swt@default:default,com.minres.scviewer.database.ui@default:default,com.minres.scviewer.database.vcd@default:default,com.minres.scviewer.database@default:true,com.opcoach.e4.preferences@default:default"/>
<booleanAttribute key="show_selected_only" value="false"/> <booleanAttribute key="show_selected_only" value="false"/>
<booleanAttribute key="tracing" value="false"/> <booleanAttribute key="tracing" value="false"/>
<booleanAttribute key="useCustomFeatures" value="false"/> <booleanAttribute key="useCustomFeatures" value="false"/>

View File

@ -12,3 +12,4 @@ Require-Bundle: org.junit,
com.minres.scviewer.database.vcd;bundle-version="1.0.0" com.minres.scviewer.database.vcd;bundle-version="1.0.0"
Bundle-ActivationPolicy: lazy Bundle-ActivationPolicy: lazy
Service-Component: OSGI-INF/component.xml Service-Component: OSGI-INF/component.xml
Automatic-Module-Name: com.minres.scviewer.database.test

File diff suppressed because it is too large Load Diff

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>com.minres.scviewer</groupId> <groupId>com.minres.scviewer</groupId>
<artifactId>com.minres.scviewer.parent</artifactId> <artifactId>com.minres.scviewer.parent</artifactId>
<version>1.0.0-SNAPSHOT</version> <version>2.0.0-SNAPSHOT</version>
<relativePath>../com.minres.scviewer.parent</relativePath> <relativePath>../com.minres.scviewer.parent</relativePath>
</parent> </parent>
<packaging>eclipse-test-plugin</packaging> <packaging>eclipse-test-plugin</packaging>
@ -27,4 +27,5 @@
</plugin> </plugin>
</plugins> </plugins>
</build> </build>
</project> <version>1.0.0-SNAPSHOT</version>
</project>

View File

@ -86,5 +86,15 @@ public class DatabaseServicesTest {
assertEquals(1, waveformDb.getChildNodes().size()); assertEquals(1, waveformDb.getChildNodes().size());
} }
@Test
public void testHierarchicalVCD() throws Exception {
File f = new File("inputs/simple_system.vcd").getAbsoluteFile();
assertTrue(f.exists());
waveformDb.load(f);
assertNotNull(waveformDb);
assertEquals(779, waveformDb.getAllWaves().size());
assertEquals(1, waveformDb.getChildNodes().size());
}
} }

View File

@ -1,2 +1,2 @@
eclipse.preferences.version=1 eclipse.preferences.version=1
groovy.compiler.level=23 groovy.compiler.level=26

View File

@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2 Bundle-ManifestVersion: 2
Bundle-Name: Textual transaction database Bundle-Name: Textual transaction database
Bundle-SymbolicName: com.minres.scviewer.database.text Bundle-SymbolicName: com.minres.scviewer.database.text
Bundle-Version: 1.0.0.qualifier Bundle-Version: 1.0.1.qualifier
Bundle-Vendor: MINRES Technologies GmbH Bundle-Vendor: MINRES Technologies GmbH
Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Import-Package: com.minres.scviewer.database, Import-Package: com.minres.scviewer.database,
@ -15,3 +15,4 @@ Require-Bundle: com.minres.scviewer.database;bundle-version="1.0.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
Bundle-ActivationPolicy: lazy Bundle-ActivationPolicy: lazy
Automatic-Module-Name: com.minres.scviewer.database.text

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>com.minres.scviewer</groupId> <groupId>com.minres.scviewer</groupId>
<artifactId>com.minres.scviewer.parent</artifactId> <artifactId>com.minres.scviewer.parent</artifactId>
<version>1.0.0-SNAPSHOT</version> <version>2.0.0-SNAPSHOT</version>
<relativePath>../com.minres.scviewer.parent</relativePath> <relativePath>../com.minres.scviewer.parent</relativePath>
</parent> </parent>
<packaging>eclipse-plugin</packaging> <packaging>eclipse-plugin</packaging>
@ -39,4 +39,5 @@
</plugin> </plugin>
</plugins> </plugins>
</build> </build>
</project> <version>1.0.1-SNAPSHOT</version>
</project>

View File

@ -13,8 +13,6 @@ package com.minres.scviewer.database.text;
import java.nio.charset.CharsetDecoder; import java.nio.charset.CharsetDecoder;
import java.util.Collection; import java.util.Collection;
import java.util.zip.GZIPInputStream import java.util.zip.GZIPInputStream
import org.apache.jdbm.DB
import org.apache.jdbm.DBMaker
import groovy.io.FileType import groovy.io.FileType
import com.minres.scviewer.database.AssociationType import com.minres.scviewer.database.AssociationType
@ -32,8 +30,6 @@ public class TextDbLoader implements IWaveformDbLoader{
IWaveformDb db; IWaveformDb db;
DB backingDb;
def streams = [] def streams = []
def relationTypes=[:] def relationTypes=[:]
@ -65,20 +61,6 @@ public class TextDbLoader implements IWaveformDbLoader{
this.streams=[] this.streams=[]
def gzipped = isGzipped(file) def gzipped = isGzipped(file)
if(isTxfile(gzipped?new GZIPInputStream(new FileInputStream(file)):new FileInputStream(file))){ if(isTxfile(gzipped?new GZIPInputStream(new FileInputStream(file)):new FileInputStream(file))){
if(true) {
def parentDir=file.absoluteFile.parent
def filename=file.name
new File(parentDir).eachFileRecurse (FileType.FILES) { f -> if(f.name=~/^\.${filename}/) f.delete() }
this.backingDb = DBMaker.openFile(parentDir+File.separator+"."+filename+"_bdb")
.deleteFilesAfterClose()
.useRandomAccessFile()
.setMRUCacheSize(4096)
//.disableTransactions()
.disableLocking()
.make();
} else {
this.backingDb = DBMaker.openMemory().disableLocking().make()
}
parseInput(gzipped?new GZIPInputStream(new FileInputStream(file)):new FileInputStream(file)) parseInput(gzipped?new GZIPInputStream(new FileInputStream(file)):new FileInputStream(file))
calculateConcurrencyIndicees() calculateConcurrencyIndicees()
return true return true
@ -140,7 +122,7 @@ public class TextDbLoader implements IWaveformDbLoader{
case "end_attribute": case "end_attribute":
if ((matcher = line =~ /^scv_tr_stream\s+\(ID (\d+),\s+name\s+"([^"]+)",\s+kind\s+"([^"]+)"\)$/)) { if ((matcher = line =~ /^scv_tr_stream\s+\(ID (\d+),\s+name\s+"([^"]+)",\s+kind\s+"([^"]+)"\)$/)) {
def id = Integer.parseInt(matcher[0][1]) def id = Integer.parseInt(matcher[0][1])
def stream = new TxStream(db, id, matcher[0][2], matcher[0][3], backingDb) def stream = new TxStream(db, id, matcher[0][2], matcher[0][3])
streams<<stream streams<<stream
streamsById[id]=stream streamsById[id]=stream
} else if ((matcher = line =~ /^scv_tr_generator\s+\(ID\s+(\d+),\s+name\s+"([^"]+)",\s+scv_tr_stream\s+(\d+),$/)) { } else if ((matcher = line =~ /^scv_tr_generator\s+\(ID\s+(\d+),\s+name\s+"([^"]+)",\s+scv_tr_stream\s+(\d+),$/)) {
@ -183,9 +165,11 @@ public class TextDbLoader implements IWaveformDbLoader{
break break
case "a"://matcher = line =~ /^a\s+(.+)$/ case "a"://matcher = line =~ /^a\s+(.+)$/
if(endTransaction){ if(endTransaction){
transaction.attributes << new TxAttribute(transaction.generator.end_attrs[0], tokens[1]) transaction.attributes << new TxAttribute(transaction.generator.end_attrs[transaction.generator.end_attrs_idx], tokens[1])
transaction.generator.end_attrs_idx++
} else { } else {
transaction.attributes << new TxAttribute(transaction.generator.begin_attrs[0], tokens[1]) transaction.attributes << new TxAttribute(transaction.generator.begin_attrs[transaction.generator.begin_attrs_idx], tokens[1])
transaction.generator.begin_attrs_idx++
} }
break break
case "tx_relation"://matcher = line =~ /^tx_relation\s+\"(\S+)\"\s+(\d+)\s+(\d+)$/ case "tx_relation"://matcher = line =~ /^tx_relation\s+\"(\S+)\"\s+(\d+)\s+(\d+)$/
@ -202,9 +186,6 @@ public class TextDbLoader implements IWaveformDbLoader{
} }
lineCnt++ lineCnt++
if((lineCnt%1000) == 0) {
backingDb.commit()
}
} }
} }

View File

@ -43,15 +43,14 @@ class TxStream extends HierNode implements ITxStream {
private TreeMap<Long, List<ITxEvent>> events private TreeMap<Long, List<ITxEvent>> events
TxStream(IWaveformDb db, int id, String name, String kind, DB backingStore){ TxStream(IWaveformDb db, int id, String name, String kind){
super(name) super(name)
this.id=id this.id=id
this.database=db this.database=db
this.fullName=name this.fullName=name
this.kind=kind this.kind=kind
this.maxConcurrency=0 this.maxConcurrency=0
//events = new TreeMap<Long, List<ITxEvent>>() events = new TreeMap<Long, List<ITxEvent>>()
events=backingStore.createTreeMap("stream-"+name)
} }
List<ITxGenerator> getGenerators(){ List<ITxGenerator> getGenerators(){

View File

@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2 Bundle-ManifestVersion: 2
Bundle-Name: SWT widget Bundle-Name: SWT widget
Bundle-SymbolicName: com.minres.scviewer.database.ui.swt Bundle-SymbolicName: com.minres.scviewer.database.ui.swt
Bundle-Version: 1.1.0.qualifier Bundle-Version: 2.0.0.qualifier
Bundle-Vendor: MINRES Technologies GmbH Bundle-Vendor: MINRES Technologies GmbH
Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: org.eclipse.swt;bundle-version="3.103.1", Require-Bundle: org.eclipse.swt;bundle-version="3.103.1",
@ -17,3 +17,4 @@ Export-Package: com.minres.scviewer.database.swt
Bundle-ClassPath: . Bundle-ClassPath: .
Bundle-ActivationPolicy: lazy Bundle-ActivationPolicy: lazy
Bundle-Activator: com.minres.scviewer.database.swt.DatabaseUiPlugin Bundle-Activator: com.minres.scviewer.database.swt.DatabaseUiPlugin
Automatic-Module-Name: com.minres.scviewer.database.ui.swt

View File

@ -5,8 +5,7 @@
<parent> <parent>
<groupId>com.minres.scviewer</groupId> <groupId>com.minres.scviewer</groupId>
<artifactId>com.minres.scviewer.parent</artifactId> <artifactId>com.minres.scviewer.parent</artifactId>
<version>1.0.0-SNAPSHOT</version> <version>2.0.0-SNAPSHOT</version>
<relativePath>../com.minres.scviewer.parent</relativePath> <relativePath>../com.minres.scviewer.parent</relativePath>
</parent> </parent>
<version>1.1.0-SNAPSHOT</version>
</project> </project>

View File

@ -0,0 +1,9 @@
package com.minres.scviewer.database.swt;
public class Constants {
public final static String[] unitString={"fs", "ps", "ns", "us", "ms"};//, "s"};
public final static int[] unitMultiplier={1, 3, 10, 30, 100, 300};
}

View File

@ -10,6 +10,7 @@
*******************************************************************************/ *******************************************************************************/
package com.minres.scviewer.database.swt.internal; package com.minres.scviewer.database.swt.internal;
import java.util.Collection;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.NavigableMap; import java.util.NavigableMap;
@ -24,8 +25,9 @@ import org.eclipse.swt.graphics.Rectangle;
import com.minres.scviewer.database.ISignal; import com.minres.scviewer.database.ISignal;
import com.minres.scviewer.database.ISignalChange; import com.minres.scviewer.database.ISignalChange;
import com.minres.scviewer.database.ISignalChangeMulti; import com.minres.scviewer.database.ISignalChangeBit;
import com.minres.scviewer.database.ISignalChangeSingle; import com.minres.scviewer.database.ISignalChangeBitVector;
import com.minres.scviewer.database.ISignalChangeReal;
import com.minres.scviewer.database.ui.TrackEntry; import com.minres.scviewer.database.ui.TrackEntry;
import com.minres.scviewer.database.ui.WaveformColors; import com.minres.scviewer.database.ui.WaveformColors;
@ -65,7 +67,6 @@ public class SignalPainter extends TrackPainter {
private static final JPanel DUMMY_PANEL = new JPanel(); private static final JPanel DUMMY_PANEL = new JPanel();
private final WaveformCanvas waveCanvas; private final WaveformCanvas waveCanvas;
private ISignal<? extends ISignalChange> signal;
int yOffsetT; int yOffsetT;
int yOffsetM; int yOffsetM;
@ -75,7 +76,6 @@ public class SignalPainter extends TrackPainter {
public SignalPainter(WaveformCanvas txDisplay, boolean even, TrackEntry trackEntry) { public SignalPainter(WaveformCanvas txDisplay, boolean even, TrackEntry trackEntry) {
super(trackEntry, even); super(trackEntry, even);
this.waveCanvas = txDisplay; this.waveCanvas = txDisplay;
this.signal = trackEntry.getSignal();
} }
private int getXEnd(long time) { private int getXEnd(long time) {
@ -84,6 +84,7 @@ public class SignalPainter extends TrackPainter {
} }
public void paintArea(GC gc, Rectangle area) { public void paintArea(GC gc, Rectangle area) {
ISignal<? extends ISignalChange> signal = trackEntry.getSignal();
if (trackEntry.selected) if (trackEntry.selected)
gc.setBackground(this.waveCanvas.colors[WaveformColors.TRACK_BG_HIGHLITE.ordinal()]); gc.setBackground(this.waveCanvas.colors[WaveformColors.TRACK_BG_HIGHLITE.ordinal()]);
else else
@ -107,8 +108,6 @@ public class SignalPainter extends TrackPainter {
NavigableMap<Long, ? extends ISignalChange> entries = signal.getEvents().subMap(first.getKey(), false, last.getKey(), true); NavigableMap<Long, ? extends ISignalChange> entries = signal.getEvents().subMap(first.getKey(), false, last.getKey(), true);
SignalChange left = new SignalChange(first); SignalChange left = new SignalChange(first);
SignalChange right = new SignalChange(entries.size() > 0 ? entries.firstEntry() : first); SignalChange right = new SignalChange(entries.size() > 0 ? entries.firstEntry() : first);
SignalStencil stencil = left.value instanceof ISignalChangeSingle ? new SingleBitStencil() : new MultiBitStencil(gc);
maxX = area.x + area.width; maxX = area.x + area.width;
yOffsetT = this.waveCanvas.getTrackHeight() / 5 + area.y; yOffsetT = this.waveCanvas.getTrackHeight() / 5 + area.y;
yOffsetM = this.waveCanvas.getTrackHeight() / 2 + area.y; yOffsetM = this.waveCanvas.getTrackHeight() / 2 + area.y;
@ -122,7 +121,6 @@ public class SignalPainter extends TrackPainter {
// b) left to close to right // b) left to close to right
if (left.time == right.time) { if (left.time == right.time) {
right.time = endTime; right.time = endTime;
} else { } else {
multiple = true; multiple = true;
long eTime = (xBegin + 1) * this.waveCanvas.getScaleFactor(); long eTime = (xBegin + 1) * this.waveCanvas.getScaleFactor();
@ -132,6 +130,7 @@ public class SignalPainter extends TrackPainter {
xEnd = getXEnd(right.time); xEnd = getXEnd(right.time);
} }
SignalStencil stencil = getStencil(gc, left, entries);
do { do {
stencil.draw(gc, area, left.value, right.value, xBegin, xEnd, multiple); stencil.draw(gc, area, left.value, right.value, xBegin, xEnd, multiple);
if (right.time >= endTime) if (right.time >= endTime)
@ -144,12 +143,30 @@ public class SignalPainter extends TrackPainter {
if (xEnd == xBegin) { if (xEnd == xBegin) {
multiple = true; multiple = true;
long eTime = (xBegin + 1) * this.waveCanvas.getScaleFactor(); long eTime = (xBegin + 1) * this.waveCanvas.getScaleFactor();
right.set(entries.floorEntry(eTime), endTime); Entry<Long, ? extends ISignalChange> entry = entries.floorEntry(eTime);
if(entry!=null && entry.getKey()> right.time)
right.set(entry, endTime);
xEnd = getXEnd(eTime); xEnd = getXEnd(eTime);
} }
} while (left.time < endTime); } while (left.time < endTime);
} }
private SignalStencil getStencil(GC gc, SignalChange left, NavigableMap<Long, ? extends ISignalChange> entries) {
if(left.value instanceof ISignalChangeBit)
return new SingleBitStencil();
else if (left.value instanceof ISignalChangeBitVector)
if(trackEntry.waveDisplay==TrackEntry.WaveDisplay.DEFAULT)
return new MultiBitStencil(gc);
else
return new MultiBitStencilAnalog(entries, left.value,
trackEntry.waveDisplay==TrackEntry.WaveDisplay.CONTINOUS,
trackEntry.valueDisplay==TrackEntry.ValueDisplay.SIGNED);
else if (left.value instanceof ISignalChangeReal)
return new RealStencil(entries, left.value, trackEntry.waveDisplay==TrackEntry.WaveDisplay.CONTINOUS);
else
return null;
}
private interface SignalStencil { private interface SignalStencil {
public void draw(GC gc, Rectangle area, ISignalChange left, ISignalChange right, int xBegin, int xEnd, boolean multiple); public void draw(GC gc, Rectangle area, ISignalChange left, ISignalChange right, int xBegin, int xEnd, boolean multiple);
@ -168,7 +185,7 @@ public class SignalPainter extends TrackPainter {
public void draw(GC gc, Rectangle area, ISignalChange left, ISignalChange right, int xBegin, int xEnd, boolean multiple) { public void draw(GC gc, Rectangle area, ISignalChange left, ISignalChange right, int xBegin, int xEnd, boolean multiple) {
Color colorBorder = waveCanvas.colors[WaveformColors.SIGNAL0.ordinal()]; Color colorBorder = waveCanvas.colors[WaveformColors.SIGNAL0.ordinal()];
ISignalChangeMulti last = (ISignalChangeMulti) left; ISignalChangeBitVector last = (ISignalChangeBitVector) left;
if (last.getValue().toString().contains("X")) { if (last.getValue().toString().contains("X")) {
colorBorder = waveCanvas.colors[WaveformColors.SIGNALX.ordinal()]; colorBorder = waveCanvas.colors[WaveformColors.SIGNALX.ordinal()];
} else if (last.getValue().toString().contains("Z")) { } else if (last.getValue().toString().contains("Z")) {
@ -187,7 +204,18 @@ public class SignalPainter extends TrackPainter {
gc.setForeground(colorBorder); gc.setForeground(colorBorder);
gc.drawPolygon(points); gc.drawPolygon(points);
gc.setForeground(waveCanvas.colors[WaveformColors.SIGNAL_TEXT.ordinal()]); gc.setForeground(waveCanvas.colors[WaveformColors.SIGNAL_TEXT.ordinal()]);
String label = "h'" + last.getValue().toHexString(); //TODO: this code should be provided from a central location
String label = null;
switch(trackEntry.valueDisplay) {
case SIGNED:
label=Long.toString(last.getValue().toSignedValue());
break;
case UNSIGNED:
label=Long.toString(last.getValue().toUnsignedValue());
break;
default:
label="h'"+last.getValue().toHexString();
}
Point bb = getBoxWidth(gc, label); Point bb = getBoxWidth(gc, label);
if (xBegin < area.x) { if (xBegin < area.x) {
xBegin = area.x; xBegin = area.x;
@ -211,16 +239,71 @@ public class SignalPainter extends TrackPainter {
} }
private class MultiBitStencilAnalog implements SignalStencil {
final boolean continous;
private long minVal;
private long range;
@SuppressWarnings("unchecked")
public MultiBitStencilAnalog(NavigableMap<Long, ? extends ISignalChange> entries, ISignalChange left, boolean continous, boolean signed) {
this.continous=continous;
Collection<ISignalChangeBitVector> values = ((NavigableMap<Long, ISignalChangeBitVector>) entries).values();
minVal=((ISignalChangeBitVector) left).getValue().toUnsignedValue();
range=2;
if(!values.isEmpty()) {
long maxVal=minVal;
for (ISignalChange e : entries.values()) {
long v = ((ISignalChangeBitVector)e).getValue().toUnsignedValue();
maxVal=Math.max(maxVal, v);
minVal=Math.min(minVal, v);
}
if(maxVal==minVal) {
maxVal--;
minVal++;
}
range = maxVal-minVal;
} else
minVal--;
}
public void draw(GC gc, Rectangle area, ISignalChange left, ISignalChange right, int xBegin, int xEnd, boolean multiple) {
long leftVal = ((ISignalChangeBitVector) left).getValue().toUnsignedValue();
long rightVal= ((ISignalChangeBitVector) right).getValue().toUnsignedValue();
gc.setForeground(waveCanvas.colors[WaveformColors.SIGNAL_REAL.ordinal()]);
int yOffsetLeft = (int) ((leftVal-minVal) / range * (yOffsetB-yOffsetT));
int yOffsetRight = (int) ((rightVal-minVal) / range * (yOffsetB-yOffsetT));
if(continous) {
if (xEnd > maxX) {
gc.drawLine(xBegin, yOffsetB-yOffsetLeft, maxX, yOffsetB-yOffsetRight);
} else {
gc.drawLine(xBegin, yOffsetB-yOffsetLeft, xEnd, yOffsetB-yOffsetRight);
}
} else {
if (xEnd > maxX) {
gc.drawLine(xBegin, yOffsetB-yOffsetLeft, maxX, yOffsetB-yOffsetLeft);
} else {
gc.drawLine(xBegin, yOffsetB-yOffsetLeft, xEnd, yOffsetB-yOffsetLeft);
if(yOffsetRight!=yOffsetLeft) {
gc.drawLine(xEnd, yOffsetB-yOffsetLeft, xEnd, yOffsetB-yOffsetRight);
}
}
}
}
}
private class SingleBitStencil implements SignalStencil { private class SingleBitStencil implements SignalStencil {
public void draw(GC gc, Rectangle area, ISignalChange left, ISignalChange right, int xBegin, int xEnd, boolean multiple) { public void draw(GC gc, Rectangle area, ISignalChange left, ISignalChange right, int xBegin, int xEnd, boolean multiple) {
if (multiple) { if (multiple) {
gc.setForeground(waveCanvas.colors[WaveformColors.SIGNALU.ordinal()]); gc.setForeground(waveCanvas.colors[WaveformColors.SIGNALU.ordinal()]);
gc.drawLine(xBegin, yOffsetT, xBegin, yOffsetB); gc.drawLine(xBegin, yOffsetT, xBegin, yOffsetB);
gc.drawLine(xEnd, yOffsetT, xEnd, yOffsetB); if(xEnd>xBegin)
gc.drawLine(xEnd, yOffsetT, xEnd, yOffsetB);
} else { } else {
Color color = waveCanvas.colors[WaveformColors.SIGNALX.ordinal()]; Color color = waveCanvas.colors[WaveformColors.SIGNALX.ordinal()];
int yOffset = yOffsetM; int yOffset = yOffsetM;
switch (((ISignalChangeSingle) left).getValue()) { switch (((ISignalChangeBit) left).getValue()) {
case '1': case '1':
color = waveCanvas.colors[WaveformColors.SIGNAL1.ordinal()]; color = waveCanvas.colors[WaveformColors.SIGNAL1.ordinal()];
yOffset = yOffsetT; yOffset = yOffsetT;
@ -240,7 +323,7 @@ public class SignalPainter extends TrackPainter {
} else { } else {
gc.drawLine(xBegin, yOffset, xEnd, yOffset); gc.drawLine(xBegin, yOffset, xEnd, yOffset);
int yNext = yOffsetM; int yNext = yOffsetM;
switch (((ISignalChangeSingle) right).getValue()) { switch (((ISignalChangeBit) right).getValue()) {
case '1': case '1':
yNext = yOffsetT; yNext = yOffsetT;
break; break;
@ -254,11 +337,87 @@ public class SignalPainter extends TrackPainter {
} }
} }
} }
} }
public ISignal<? extends ISignalChange> getSignal() { private class RealStencil implements SignalStencil {
return signal;
double minVal, range;
final double scaleFactor = 1.05;
boolean continous=true;
@SuppressWarnings("unchecked")
public RealStencil(NavigableMap<Long, ? extends ISignalChange> entries, ISignalChange left, boolean continous) {
this.continous=continous;
Collection<ISignalChangeReal> values = ((NavigableMap<Long, ISignalChangeReal>) entries).values();
minVal=((ISignalChangeReal) left).getValue();
range=2.0;
if(!values.isEmpty()) {
double maxVal=minVal;
for (ISignalChange e : entries.values()) {
double v = ((ISignalChangeReal)e).getValue();
if(Double.isNaN(maxVal))
maxVal=v;
else if(!Double.isNaN(v))
maxVal=Math.max(maxVal, v);
if(Double.isNaN(minVal))
minVal=v;
else if(!Double.isNaN(v))
minVal=Math.min(minVal, v);
}
if(Double.isNaN(maxVal)){
maxVal=minVal=0.0;
}
range = (maxVal-minVal)*scaleFactor;
double avg = (maxVal+minVal)/2.0;
minVal=avg-(avg-minVal)*scaleFactor;
}
}
public void draw(GC gc, Rectangle area, ISignalChange left, ISignalChange right, int xBegin, int xEnd, boolean multiple) {
double leftVal = ((ISignalChangeReal) left).getValue();
double rightVal= ((ISignalChangeReal) right).getValue();
if(Double.isNaN(leftVal)) {
Color color = waveCanvas.colors[WaveformColors.SIGNAL_NAN.ordinal()];
int width = xEnd - xBegin;
if (width > 1) {
int[] points = {
xBegin, yOffsetT,
xEnd, yOffsetT,
xEnd, yOffsetB,
xBegin, yOffsetB
};
gc.setForeground(color);
gc.drawPolygon(points);
gc.setBackground(color);
gc.fillPolygon(points);
} else {
gc.setForeground(color);
gc.drawLine(xEnd, yOffsetT, xEnd, yOffsetB);
}
} else {
gc.setForeground(waveCanvas.colors[WaveformColors.SIGNAL_REAL.ordinal()]);
int yOffsetLeft = (int) ((leftVal-minVal) / range * (yOffsetB-yOffsetT));
int yOffsetRight = Double.isNaN(rightVal)?yOffsetLeft:(int) ((rightVal-minVal) / range * (yOffsetB-yOffsetT));
if(continous) {
if (xEnd > maxX) {
gc.drawLine(xBegin, yOffsetB-yOffsetLeft, maxX, yOffsetB-yOffsetRight);
} else {
gc.drawLine(xBegin, yOffsetB-yOffsetLeft, xEnd, yOffsetB-yOffsetRight);
}
} else {
if (xEnd > maxX) {
gc.drawLine(xBegin, yOffsetB-yOffsetLeft, maxX, yOffsetB-yOffsetLeft);
} else {
gc.drawLine(xBegin, yOffsetB-yOffsetLeft, xEnd, yOffsetB-yOffsetLeft);
if(yOffsetRight!=yOffsetLeft) {
gc.drawLine(xEnd, yOffsetB-yOffsetLeft, xEnd, yOffsetB-yOffsetRight);
}
}
}
}
}
} }
} }

View File

@ -110,6 +110,17 @@ public class StreamPainter extends TrackPainter{
gc.fillRectangle(bb); gc.fillRectangle(bb);
gc.drawRectangle(bb); gc.drawRectangle(bb);
} else { } else {
// adjusting drawing width to circumvent issues in canvas algos
if(bb.x < area.x) {
bb.width = bb.width-(area.x-bb.x)+5;
bb.x=area.x-5;
}
int bb_x2 = bb.x+bb.width;
int area_x2 = area.x+area.width;
if(bb_x2>area_x2){
bb_x2=area_x2+5;
bb.width= bb_x2-bb.x;
}
gc.fillRoundRectangle(bb.x, bb.y, bb.width, bb.height, 5, 5); gc.fillRoundRectangle(bb.x, bb.y, bb.width, bb.height, 5, 5);
gc.drawRoundRectangle(bb.x, bb.y, bb.width, bb.height, 5, 5); gc.drawRoundRectangle(bb.x, bb.y, bb.width, bb.height, 5, 5);
} }

View File

@ -41,7 +41,9 @@ import com.minres.scviewer.database.ITx;
import com.minres.scviewer.database.IWaveform; import com.minres.scviewer.database.IWaveform;
import com.minres.scviewer.database.IWaveformEvent; import com.minres.scviewer.database.IWaveformEvent;
import com.minres.scviewer.database.RelationType; import com.minres.scviewer.database.RelationType;
import com.minres.scviewer.database.swt.Constants;
import com.minres.scviewer.database.ui.IWaveformViewer; import com.minres.scviewer.database.ui.IWaveformViewer;
import com.minres.scviewer.database.ui.TrackEntry;
import com.minres.scviewer.database.ui.WaveformColors; import com.minres.scviewer.database.ui.WaveformColors;
public class WaveformCanvas extends Canvas { public class WaveformCanvas extends Canvas {
@ -55,11 +57,7 @@ public class WaveformCanvas extends Canvas {
String unit="ns"; String unit="ns";
private int level = 12; private int level = 12;
public final static String[] unitString={"fs", "ps", "ns", "µs", "ms"};//, "s"};
public final static int[] unitMultiplier={1, 3, 10, 30, 100, 300};
private long maxTime; private long maxTime;
protected Point origin; /* original size */ protected Point origin; /* original size */
@ -126,6 +124,31 @@ public class WaveformCanvas extends Canvas {
painterList.add(marker); painterList.add(marker);
cursorPainters.add(marker); cursorPainters.add(marker);
wave2painterMap=new HashMap<>(); wave2painterMap=new HashMap<>();
// fall back initialization
colors[WaveformColors.LINE.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED);
colors[WaveformColors.LINE_HIGHLITE.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_CYAN);
colors[WaveformColors.TRACK_BG_EVEN.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_BLACK);
colors[WaveformColors.TRACK_BG_ODD.ordinal()] = SWTResourceManager.getColor(40, 40, 40);
colors[WaveformColors.TRACK_BG_HIGHLITE.ordinal()] = SWTResourceManager.getColor(40, 40, 80);
colors[WaveformColors.TX_BG.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GREEN);
colors[WaveformColors.TX_BG_HIGHLITE.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_GREEN);
colors[WaveformColors.TX_BORDER.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED);
colors[WaveformColors.SIGNAL0.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GREEN);
colors[WaveformColors.SIGNAL1.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GREEN);
colors[WaveformColors.SIGNALZ.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_YELLOW);
colors[WaveformColors.SIGNALX.ordinal()] = SWTResourceManager.getColor(255, 51, 51);
colors[WaveformColors.SIGNALU.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_YELLOW);
colors[WaveformColors.SIGNAL_TEXT.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_WHITE);
colors[WaveformColors.SIGNAL_REAL.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_YELLOW);
colors[WaveformColors.SIGNAL_NAN.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED);
colors[WaveformColors.CURSOR.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED);
colors[WaveformColors.CURSOR_DRAG.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GRAY);
colors[WaveformColors.CURSOR_TEXT.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_WHITE);
colors[WaveformColors.MARKER.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_GRAY);
colors[WaveformColors.MARKER_TEXT.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_WHITE);
colors[WaveformColors.REL_ARROW.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_MAGENTA);
colors[WaveformColors.REL_ARROW_HIGHLITE.ordinal()] = SWTResourceManager.getColor(255, 128, 255);
} }
public void addCursoPainter(CursorPainter cursorPainter){ public void addCursoPainter(CursorPainter cursorPainter){
@ -137,33 +160,10 @@ public class WaveformCanvas extends Canvas {
Display d = getDisplay(); Display d = getDisplay();
if (colourMap != null) { if (colourMap != null) {
for (WaveformColors c : WaveformColors.values()) { for (WaveformColors c : WaveformColors.values()) {
if (colourMap.containsKey(c)) { if (colourMap.containsKey(c))
colors[c.ordinal()] = new Color(d, colourMap.get(c)); colors[c.ordinal()] = new Color(d, colourMap.get(c));
}
} }
redraw(); redraw();
} else {
colors[WaveformColors.LINE.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED);
colors[WaveformColors.LINE_HIGHLITE.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_CYAN);
colors[WaveformColors.TRACK_BG_EVEN.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_BLACK);
colors[WaveformColors.TRACK_BG_ODD.ordinal()] = SWTResourceManager.getColor(40, 40, 40);
colors[WaveformColors.TRACK_BG_HIGHLITE.ordinal()] = SWTResourceManager.getColor(40, 40, 80);
colors[WaveformColors.TX_BG.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GREEN);
colors[WaveformColors.TX_BG_HIGHLITE.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_GREEN);
colors[WaveformColors.TX_BORDER.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED);
colors[WaveformColors.SIGNAL0.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_GREEN);
colors[WaveformColors.SIGNAL1.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_GREEN);
colors[WaveformColors.SIGNALZ.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_YELLOW);
colors[WaveformColors.SIGNALX.ordinal()] = SWTResourceManager.getColor(255, 51, 51);
colors[WaveformColors.SIGNALU.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_YELLOW);
colors[WaveformColors.SIGNAL_TEXT.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_WHITE);
colors[WaveformColors.CURSOR.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED);
colors[WaveformColors.CURSOR_DRAG.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GRAY);
colors[WaveformColors.CURSOR_TEXT.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_WHITE);
colors[WaveformColors.MARKER.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_GRAY);
colors[WaveformColors.MARKER_TEXT.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_WHITE);
colors[WaveformColors.REL_ARROW.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_MAGENTA);
colors[WaveformColors.REL_ARROW_HIGHLITE.ordinal()] = SWTResourceManager.getColor(255, 128, 255);
} }
} }
@ -179,6 +179,9 @@ public class WaveformCanvas extends Canvas {
return origin; return origin;
} }
public int getWidth() {
return getClientArea().width;
}
public void setOrigin(Point origin) { public void setOrigin(Point origin) {
setOrigin(origin.x, origin.y); setOrigin(origin.x, origin.y);
} }
@ -219,12 +222,12 @@ public class WaveformCanvas extends Canvas {
} }
public int getMaxZoomLevel(){ public int getMaxZoomLevel(){
return unitMultiplier.length*unitString.length-1; return Constants.unitMultiplier.length*Constants.unitString.length-1;
} }
public void setZoomLevel(int level) { public void setZoomLevel(int level) {
long oldScaleFactor=scaleFactor; long oldScaleFactor=scaleFactor;
if(level<unitMultiplier.length*unitString.length){ if(level<Constants.unitMultiplier.length*Constants.unitString.length){
this.level = level; this.level = level;
this.scaleFactor = (long) Math.pow(10, level/2); this.scaleFactor = (long) Math.pow(10, level/2);
if(level%2==1) this.scaleFactor*=3; if(level%2==1) this.scaleFactor*=3;
@ -256,17 +259,17 @@ public class WaveformCanvas extends Canvas {
} }
public long getScaleFactorPow10() { public long getScaleFactorPow10() {
int scale = level/unitMultiplier.length; int scale = level/Constants.unitMultiplier.length;
double res = Math.pow(1000, scale); double res = Math.pow(1000, scale);
return (long) res; return (long) res;
} }
public String getUnitStr(){ public String getUnitStr(){
return unitString[level/unitMultiplier.length]; return Constants.unitString[level/Constants.unitMultiplier.length];
} }
public int getUnitMultiplier(){ public int getUnitMultiplier(){
return unitMultiplier[level%unitMultiplier.length]; return Constants.unitMultiplier[level%Constants.unitMultiplier.length];
} }
public long getTimeForOffset(int xOffset){ public long getTimeForOffset(int xOffset){
@ -284,15 +287,23 @@ public class WaveformCanvas extends Canvas {
} }
public void clearAllWaveformPainter() { public void clearAllWaveformPainter() {
clearAllWaveformPainter(true);
}
void clearAllWaveformPainter(boolean update) {
trackAreaPainter.getTrackVerticalOffset().clear(); trackAreaPainter.getTrackVerticalOffset().clear();
wave2painterMap.clear(); wave2painterMap.clear();
syncScrollBars(); if(update) syncScrollBars();
} }
public void addWaveformPainter(IWaveformPainter painter) { public void addWaveformPainter(IWaveformPainter painter) {
addWaveformPainter(painter, true);
}
void addWaveformPainter(IWaveformPainter painter, boolean update) {
trackAreaPainter.addTrackPainter(painter); trackAreaPainter.addTrackPainter(painter);
wave2painterMap.put(painter.getTrackEntry().waveform, painter); wave2painterMap.put(painter.getTrackEntry().waveform, painter);
syncScrollBars(); if(update) syncScrollBars();
} }
public List<CursorPainter> getCursorPainters() { public List<CursorPainter> getCursorPainters() {
@ -309,7 +320,7 @@ public class WaveformCanvas extends Canvas {
super.dispose(); super.dispose();
} }
/* Initalize the scrollbar and register listeners. */ /* Initialize the scrollbar and register listeners. */
private void initScrollBars() { private void initScrollBars() {
ScrollBar horizontal = getHorizontalBar(); ScrollBar horizontal = getHorizontalBar();
horizontal.setEnabled(false); horizontal.setEnabled(false);
@ -343,38 +354,41 @@ public class WaveformCanvas extends Canvas {
redraw(); redraw();
return; return;
} }
int height = trackAreaPainter.getHeight(); int height = trackAreaPainter.getHeight(); // incl. Ruler
int width = (int) (maxTime / scaleFactor); int width = (int) (maxTime / scaleFactor);
Rectangle clientArea=getClientArea();
ScrollBar horizontal = getHorizontalBar(); ScrollBar horizontal = getHorizontalBar();
horizontal.setIncrement((int) (getClientArea().width / 100)); horizontal.setIncrement((int) (getClientArea().width / 100));
horizontal.setPageIncrement(getClientArea().width); horizontal.setPageIncrement(getClientArea().width);
int cw = getClientArea().width; int clientWidthw = clientArea.width;
if (width > cw) { /* image is wider than client area */ if (width > clientWidthw) { /* image is wider than client area */
horizontal.setMinimum(0);
horizontal.setMaximum(width); horizontal.setMaximum(width);
horizontal.setEnabled(true); horizontal.setEnabled(true);
if (((int) -origin.x) > horizontal.getMaximum() - cw) if (((int) -origin.x) > horizontal.getMaximum() - clientWidthw)
origin.x = -horizontal.getMaximum() + cw; origin.x = -horizontal.getMaximum() + clientWidthw;
} else { /* image is narrower than client area */ } else { /* image is narrower than client area */
horizontal.setEnabled(false); horizontal.setEnabled(false);
} }
horizontal.setThumb(clientWidthw);
horizontal.setSelection(-origin.x); horizontal.setSelection(-origin.x);
horizontal.setThumb(cw);
ScrollBar vertical = getVerticalBar(); ScrollBar vertical = getVerticalBar();
vertical.setIncrement((int) (getClientArea().height / 100)); vertical.setIncrement((int) (getClientArea().height / 100));
vertical.setPageIncrement((int) (getClientArea().height)); vertical.setPageIncrement((int) (getClientArea().height));
int ch = getClientArea().height; int clientHeighth = clientArea.height;
if (height > ch) { /* image is higher than client area */ if (height > clientHeighth) { /* image is higher than client area */
vertical.setMinimum(0);
vertical.setMaximum(height); vertical.setMaximum(height);
vertical.setEnabled(true); vertical.setEnabled(true);
if (((int) -origin.y) > vertical.getMaximum() - ch) if (((int) -origin.y) > vertical.getMaximum() - clientHeighth)
origin.y = -vertical.getMaximum() + ch; origin.y = -vertical.getMaximum() + clientHeighth;
} else { /* image is less higher than client area */ } else { /* image is less higher than client area */
vertical.setMaximum((int) (ch)); vertical.setMaximum((int) (clientHeighth));
vertical.setEnabled(false); vertical.setEnabled(false);
} }
vertical.setThumb(clientHeighth);
vertical.setSelection(-origin.y); vertical.setSelection(-origin.y);
vertical.setThumb(ch);
redraw(); redraw();
fireSelectionEvent(); fireSelectionEvent();
@ -467,6 +481,27 @@ public class WaveformCanvas extends Canvas {
} }
} }
public void reveal(IWaveform<? extends IWaveformEvent> waveform) {
for (IWaveformPainter painter : wave2painterMap.values()) {
TrackEntry te = painter.getTrackEntry();
if(te.waveform == waveform) {
Point size = getSize();
//size.x -= getVerticalBar().getSize().x + 2;
size.y -=+rulerHeight;
ScrollBar sb = getHorizontalBar();
if((sb.getStyle()&SWT.SCROLLBAR_OVERLAY)!=0 && sb.isVisible()) // TODO: check on other platform than MacOSX
size.y-= getHorizontalBar().getSize().y;
int top = te.vOffset;
int bottom = top + trackHeight;
if (top < -origin.y) {
setOrigin(origin.x, -(top-trackHeight));
} else if (bottom > (size.y - origin.y)) {
setOrigin(origin.x, size.y - bottom);
}
}
}
}
public void reveal(long time) { public void reveal(long time) {
int scaledTime = (int) (time / scaleFactor); int scaledTime = (int) (time / scaleFactor);
Point size = getSize(); Point size = getSize();
@ -511,4 +546,11 @@ public class WaveformCanvas extends Canvas {
} }
} }
long getMaxVisibleTime() {
return (getClientArea().width+origin.x)*scaleFactor;
}
long getOriginTime() {
return origin.x * scaleFactor;
}
} }

View File

@ -66,13 +66,15 @@ 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.Menu;
import org.eclipse.swt.widgets.ScrollBar; import org.eclipse.swt.widgets.ScrollBar;
import org.eclipse.swt.widgets.Widget;
import org.eclipse.wb.swt.SWTResourceManager; import org.eclipse.wb.swt.SWTResourceManager;
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;
import com.minres.scviewer.database.ISignalChangeMulti; import com.minres.scviewer.database.ISignalChangeBitVector;
import com.minres.scviewer.database.ISignalChangeSingle; import com.minres.scviewer.database.ISignalChangeReal;
import com.minres.scviewer.database.ISignalChangeBit;
import com.minres.scviewer.database.ITx; import com.minres.scviewer.database.ITx;
import com.minres.scviewer.database.ITxEvent; import com.minres.scviewer.database.ITxEvent;
import com.minres.scviewer.database.ITxRelation; import com.minres.scviewer.database.ITxRelation;
@ -80,6 +82,7 @@ import com.minres.scviewer.database.ITxStream;
import com.minres.scviewer.database.IWaveform; import com.minres.scviewer.database.IWaveform;
import com.minres.scviewer.database.IWaveformEvent; import com.minres.scviewer.database.IWaveformEvent;
import com.minres.scviewer.database.RelationType; import com.minres.scviewer.database.RelationType;
import com.minres.scviewer.database.swt.Constants;
import com.minres.scviewer.database.ui.GotoDirection; import com.minres.scviewer.database.ui.GotoDirection;
import com.minres.scviewer.database.ui.ICursor; import com.minres.scviewer.database.ui.ICursor;
import com.minres.scviewer.database.ui.IWaveformViewer; import com.minres.scviewer.database.ui.IWaveformViewer;
@ -102,12 +105,14 @@ public class WaveformViewer implements IWaveformViewer {
private Control namePaneHeader; private Control namePaneHeader;
private Canvas nameList; final private Canvas nameList;
private Canvas valueList; final private Canvas valueList;
WaveformCanvas waveformCanvas; final WaveformCanvas waveformCanvas;
private boolean revealSelected=false;
private Composite top; private Composite top;
protected ObservableList<TrackEntry> streams; protected ObservableList<TrackEntry> streams;
@ -118,19 +123,16 @@ public class WaveformViewer implements IWaveformViewer {
private TreeMap<Integer, TrackEntry> trackVerticalOffset; private TreeMap<Integer, TrackEntry> trackVerticalOffset;
private HashMap<IWaveform<? extends IWaveformEvent>, String> actualValues;
private Font nameFont, nameFontB; private Font nameFont, nameFontB;
protected MouseListener nameValueMouseListener = new MouseAdapter() { protected MouseListener nameValueMouseListener = new MouseAdapter() {
@Override @Override
public void mouseDown(MouseEvent e) { public void mouseDown(MouseEvent e) {
if ((e.button == 1 || e.button == 3)) { if (e.button == 1) {
Entry<Integer, TrackEntry> entry = trackVerticalOffset.floorEntry(e.y); Entry<Integer, TrackEntry> entry = trackVerticalOffset.floorEntry(e.y);
if (entry != null) if (entry != null)
setSelection(new StructuredSelection(entry.getValue())); setSelection(new StructuredSelection(entry.getValue()));
} } else if (e.button == 3) {
if (e.button == 3) {
Menu topMenu= top.getMenu(); Menu topMenu= top.getMenu();
if(topMenu!=null) topMenu.setVisible(true); if(topMenu!=null) topMenu.setVisible(true);
} }
@ -144,12 +146,10 @@ public class WaveformViewer implements IWaveformViewer {
@Override @Override
public void mouseDown(MouseEvent e) { public void mouseDown(MouseEvent e) {
start=new Point(e.x, e.y); start=new Point(e.x, e.y);
if((e.stateMask&SWT.MODIFIER_MASK)!=0) return; //don't react on modifier
if (e.button == 1) { if (e.button == 1) {
initialSelected = waveformCanvas.getClicked(start); initialSelected = waveformCanvas.getClicked(start);
} else if (e.button == 3) { } else if (e.button == 3) {
List<Object> hitted = waveformCanvas.getClicked(start);
if(hitted!=null && hitted.size()>0)
setSelection(new StructuredSelection(hitted));
Menu topMenu= top.getMenu(); Menu topMenu= top.getMenu();
if(topMenu!=null) topMenu.setVisible(true); if(topMenu!=null) topMenu.setVisible(true);
} }
@ -157,29 +157,18 @@ public class WaveformViewer implements IWaveformViewer {
@Override @Override
public void mouseUp(MouseEvent e) { public void mouseUp(MouseEvent e) {
if (e.button == 1) { if((e.stateMask&SWT.MODIFIER_MASK&~SWT.SHIFT)!=0) return; //don't react on modifier
if (e.button == 1 && ((e.stateMask&SWT.SHIFT)==0)) {
if(Math.abs(e.x-start.x)<3 && Math.abs(e.y-start.y)<3){ if(Math.abs(e.x-start.x)<3 && Math.abs(e.y-start.y)<3){
// first set time // first set cursor time
setCursorTime(snapOffsetToEvent(e)); setCursorTime(snapOffsetToEvent(e));
// then set selection and reveal // then set selection and reveal
setSelection(new StructuredSelection(initialSelected)); setSelection(new StructuredSelection(initialSelected));
e.widget.getDisplay().asyncExec(new Runnable() { asyncUpdate(e.widget);
@Override
public void run() {
waveformCanvas.redraw();
updateValueList();
}
});
} }
}else if (e.button == 2) { }else if (e.button == 2 ||(e.button==1 && (e.stateMask&SWT.SHIFT)!=0)) {
setMarkerTime(snapOffsetToEvent(e), selectedMarker); setMarkerTime(snapOffsetToEvent(e), selectedMarker);
e.widget.getDisplay().asyncExec(new Runnable() { asyncUpdate(e.widget);
@Override
public void run() {
waveformCanvas.redraw();
updateValueList();
}
});
} }
} }
@ -225,13 +214,12 @@ public class WaveformViewer implements IWaveformViewer {
trackVerticalOffset = new TreeMap<Integer, TrackEntry>(); trackVerticalOffset = new TreeMap<Integer, TrackEntry>();
trackVerticalHeight=0; trackVerticalHeight=0;
actualValues = new HashMap<IWaveform<? extends IWaveformEvent>, String>();
nameFont = parent.getDisplay().getSystemFont(); nameFont = parent.getDisplay().getSystemFont();
nameFontB = SWTResourceManager.getBoldFont(nameFont); nameFontB = SWTResourceManager.getBoldFont(nameFont);
streams = new ObservableList<>(); streams = new ObservableList<>();
streams.addPropertyChangeListener(this); streams.addPropertyChangeListener("content", this);
top = new Composite(parent, SWT.NONE); top = new Composite(parent, SWT.NONE);
top.setLayout(new FillLayout(SWT.HORIZONTAL)); top.setLayout(new FillLayout(SWT.HORIZONTAL));
@ -273,9 +261,11 @@ public class WaveformViewer implements IWaveformViewer {
nameList.addListener(SWT.Paint, new Listener() { nameList.addListener(SWT.Paint, new Listener() {
@Override @Override
public void handleEvent(Event event) { public void handleEvent(Event event) {
GC gc = event.gc; if(!trackVerticalOffset.isEmpty()) {
Rectangle rect = ((Canvas) event.widget).getClientArea(); GC gc = event.gc;
paintNames(gc, rect); Rectangle rect = ((Canvas) event.widget).getClientArea();
paintNames(gc, rect);
}
} }
}); });
nameList.addMouseListener(nameValueMouseListener); nameList.addMouseListener(nameValueMouseListener);
@ -305,9 +295,11 @@ public class WaveformViewer implements IWaveformViewer {
valueList.addListener(SWT.Paint, new Listener() { valueList.addListener(SWT.Paint, new Listener() {
@Override @Override
public void handleEvent(Event event) { public void handleEvent(Event event) {
GC gc = event.gc; if(!trackVerticalOffset.isEmpty()) {
Rectangle rect = ((Canvas) event.widget).getClientArea(); GC gc = event.gc;
paintValues(gc, rect); Rectangle rect = ((Canvas) event.widget).getClientArea();
paintValues(gc, rect);
}
} }
}); });
valueList.addMouseListener(nameValueMouseListener); valueList.addMouseListener(nameValueMouseListener);
@ -315,7 +307,7 @@ public class WaveformViewer implements IWaveformViewer {
waveformCanvas.setMaxTime(1); waveformCanvas.setMaxTime(1);
waveformCanvas.addMouseListener(waveformMouseListener); waveformCanvas.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();
@ -377,23 +369,33 @@ public class WaveformViewer implements IWaveformViewer {
@Override @Override
public void propertyChange(PropertyChangeEvent pce) { public void propertyChange(PropertyChangeEvent pce) {
if ("size".equals(pce.getPropertyName()) || "content".equals(pce.getPropertyName())) { if ("size".equals(pce.getPropertyName()) || "content".equals(pce.getPropertyName())) {
waveformCanvas.getDisplay().asyncExec(new Runnable() { if(revealSelected) {
@Override waveformCanvas.getDisplay().asyncExec(new Runnable() {
public void run() { @Override
updateTracklist(); public void run() {
} update();
}); waveformCanvas.reveal(currentWaveformSelection.waveform);
valueList.redraw();
nameList.redraw();
}
});
revealSelected=false;
} else
waveformCanvas.getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
update();
}
});
} }
} }
protected void updateTracklist() { public void update() {
trackVerticalHeight = 0; trackVerticalHeight = 0;
int nameMaxWidth = 0; int nameMaxWidth = 0;
int previousHeight = trackVerticalOffset.size() == 0 ? 0 : trackVerticalOffset.lastKey();
IWaveformPainter painter = null; IWaveformPainter painter = null;
trackVerticalOffset.clear(); trackVerticalOffset.clear();
actualValues.clear(); waveformCanvas.clearAllWaveformPainter(false);
waveformCanvas.clearAllWaveformPainter();
boolean even = true; boolean even = true;
boolean clearSelection = true; boolean clearSelection = true;
TextLayout tl = new TextLayout(waveformCanvas.getDisplay()); TextLayout tl = new TextLayout(waveformCanvas.getDisplay());
@ -403,20 +405,21 @@ public class WaveformViewer implements IWaveformViewer {
streamEntry.vOffset=trackVerticalHeight; streamEntry.vOffset=trackVerticalHeight;
clearSelection &= currentWaveformSelection!=null && (streamEntry.waveform != currentWaveformSelection.waveform); clearSelection &= currentWaveformSelection!=null && (streamEntry.waveform != currentWaveformSelection.waveform);
if (streamEntry.isStream()) { if (streamEntry.isStream()) {
streamEntry.currentValue="";
streamEntry.height *= streamEntry.getStream().getMaxConcurrency(); streamEntry.height *= streamEntry.getStream().getMaxConcurrency();
painter = new StreamPainter(waveformCanvas, even, streamEntry); painter = new StreamPainter(waveformCanvas, even, streamEntry);
actualValues.put(streamEntry.waveform, "");
} else if (streamEntry.isSignal()) { } else if (streamEntry.isSignal()) {
streamEntry.currentValue="---";
painter = new SignalPainter(waveformCanvas, even, streamEntry); painter = new SignalPainter(waveformCanvas, even, streamEntry);
actualValues.put(streamEntry.waveform, "---");
} }
waveformCanvas.addWaveformPainter(painter); waveformCanvas.addWaveformPainter(painter, false);
trackVerticalOffset.put(trackVerticalHeight, streamEntry); trackVerticalOffset.put(trackVerticalHeight, streamEntry);
tl.setText(streamEntry.waveform.getFullName()); tl.setText(streamEntry.waveform.getFullName());
nameMaxWidth = Math.max(nameMaxWidth, tl.getBounds().width); nameMaxWidth = Math.max(nameMaxWidth, tl.getBounds().width);
trackVerticalHeight += streamEntry.height; trackVerticalHeight += streamEntry.height;
even = !even; even = !even;
} }
waveformCanvas.syncScrollBars();
nameList.setSize(nameMaxWidth + 15, trackVerticalHeight); nameList.setSize(nameMaxWidth + 15, trackVerticalHeight);
nameListScrolled.setMinSize(nameMaxWidth + 15, trackVerticalHeight); nameListScrolled.setMinSize(nameMaxWidth + 15, trackVerticalHeight);
valueList.setSize(calculateValueWidth(), trackVerticalHeight); valueList.setSize(calculateValueWidth(), trackVerticalHeight);
@ -427,23 +430,16 @@ public class WaveformViewer implements IWaveformViewer {
top.layout(new Control[] { valueList, nameList, waveformCanvas }); top.layout(new Control[] { valueList, nameList, waveformCanvas });
if (trackVerticalOffset.isEmpty()){ if (trackVerticalOffset.isEmpty()){
waveformCanvas.setOrigin(0, 0); waveformCanvas.setOrigin(0, 0);
}else if(previousHeight > trackVerticalOffset.lastKey()){
Point o = waveformCanvas.getOrigin();
waveformCanvas.setOrigin(o.x, o.y - (previousHeight - trackVerticalOffset.lastKey()));
} }
if(clearSelection) setSelection(new StructuredSelection()); if(clearSelection) 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(waveformCanvas.getDisplay()); TextLayout tl = new TextLayout(waveformCanvas.getDisplay());
tl.setFont(nameFontB); tl.setFont(nameFontB);
int valueMaxWidth = 0; int valueMaxWidth = 0;
for (String v : actualValues.values()) { for (TrackEntry v : streams) {
tl.setText(v); tl.setText(v.currentValue);
valueMaxWidth = Math.max(valueMaxWidth, tl.getBounds().width); valueMaxWidth = Math.max(valueMaxWidth, tl.getBounds().width);
} }
return valueMaxWidth + 15; return valueMaxWidth + 15;
@ -451,16 +447,32 @@ public class WaveformViewer implements IWaveformViewer {
private void updateValueList(){ private void updateValueList(){
final Long time = getCursorTime(); final Long time = getCursorTime();
for(Entry<IWaveform<? extends IWaveformEvent>, String> entry:actualValues.entrySet()){ for(TrackEntry entry:streams){
if(entry.getKey() instanceof ISignal){ if(entry.isSignal()){
ISignalChange event = ((ISignal<?>)entry.getKey()).getWaveformEventsBeforeTime(time); ISignalChange event = ((ISignal<?>)entry.waveform).getWaveformEventsBeforeTime(time);
if(event instanceof ISignalChangeSingle){ if(event instanceof ISignalChangeBit){
entry.setValue("b'"+((ISignalChangeSingle)event).getValue()); entry.currentValue="b'"+((ISignalChangeBit)event).getValue();
} else if(event instanceof ISignalChangeMulti){ } else if(event instanceof ISignalChangeBitVector){
entry.setValue("h'"+((ISignalChangeMulti)event).getValue().toHexString()); // TODO: same code resides in SignalPainter, fix it
switch(entry.valueDisplay) {
case SIGNED:
entry.currentValue=Long.toString(((ISignalChangeBitVector)event).getValue().toSignedValue());
break;
case UNSIGNED:
entry.currentValue=Long.toString(((ISignalChangeBitVector)event).getValue().toUnsignedValue());
break;
default:
entry.currentValue="h'"+((ISignalChangeBitVector)event).getValue().toHexString();
}
} else if(event instanceof ISignalChangeReal){
double val = ((ISignalChangeReal)event).getValue();
if(val>0.001)
entry.currentValue=String.format("%1$,.3f", val);
else
entry.currentValue=Double.toString(val);
} }
} else if(entry.getKey() instanceof ITxStream<?>){ } else if(entry.isStream()){
ITxStream<?> stream = (ITxStream<?>) entry.getKey(); ITxStream<?> stream = (ITxStream<?>) entry.waveform;
ITx[] resultsList = new ITx[stream.getMaxConcurrency()]; ITx[] resultsList = new ITx[stream.getMaxConcurrency()];
Entry<Long, List<ITxEvent>> firstTx=stream.getEvents().floorEntry(time); Entry<Long, List<ITxEvent>> firstTx=stream.getEvents().floorEntry(time);
if(firstTx!=null){ if(firstTx!=null){
@ -482,7 +494,7 @@ public class WaveformViewer implements IWaveformViewer {
value+="|"; value+="|";
if(o!=null) value+=((ITx)o).getGenerator().getName(); if(o!=null) value+=((ITx)o).getGenerator().getName();
} }
entry.setValue(value); entry.currentValue=value;
} }
} }
} }
@ -549,11 +561,13 @@ public class WaveformViewer implements IWaveformViewer {
*/ */
@Override @Override
public ISelection getSelection() { public ISelection getSelection() {
if (currentTxSelection != null) if (currentTxSelection != null) {
return new StructuredSelection(currentTxSelection); Object[] elem = {currentTxSelection, currentWaveformSelection};
else if (currentWaveformSelection != null) return new StructuredSelection(elem);
return new StructuredSelection(currentWaveformSelection.waveform); } else if (currentWaveformSelection != null) {
else Object[] elem = {currentWaveformSelection.waveform, currentWaveformSelection};
return new StructuredSelection(elem);
} else
return new StructuredSelection(); return new StructuredSelection();
} }
@ -593,6 +607,7 @@ public class WaveformViewer implements IWaveformViewer {
currentWaveformSelection = (TrackEntry) sel; currentWaveformSelection = (TrackEntry) sel;
if(currentTxSelection!=null && currentTxSelection.getStream()!=currentWaveformSelection) if(currentTxSelection!=null && currentTxSelection.getStream()!=currentWaveformSelection)
currentTxSelection=null; currentTxSelection=null;
selectionChanged = true; selectionChanged = true;
} }
} }
@ -605,6 +620,7 @@ public class WaveformViewer implements IWaveformViewer {
} }
if(currentWaveformSelection!=null) currentWaveformSelection.selected=true; if(currentWaveformSelection!=null) currentWaveformSelection.selected=true;
if (selectionChanged) { if (selectionChanged) {
if(currentWaveformSelection!=null) waveformCanvas.reveal(currentWaveformSelection.waveform);
waveformCanvas.setSelected(currentTxSelection); waveformCanvas.setSelected(currentTxSelection);
valueList.redraw(); valueList.redraw();
nameList.redraw(); nameList.redraw();
@ -628,7 +644,16 @@ public class WaveformViewer implements IWaveformViewer {
*/ */
@Override @Override
public void moveSelection(GotoDirection direction) { public void moveSelection(GotoDirection direction) {
moveSelection(direction, NEXT_PREV_IN_STREAM) ; if(direction==GotoDirection.NEXT || direction==GotoDirection.PREV)
moveSelection(direction, NEXT_PREV_IN_STREAM) ;
else {
int idx = streams.indexOf(currentWaveformSelection);
if(direction==GotoDirection.UP && idx>0) {
setSelection(new StructuredSelection(streams.get(idx-1)));
} else if(direction==GotoDirection.DOWN && idx<(streams.size()-1)) {
setSelection(new StructuredSelection(streams.get(idx+1)));
}
}
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -738,6 +763,7 @@ public class WaveformViewer implements IWaveformViewer {
setCursorTime(time); setCursorTime(time);
waveformCanvas.reveal(time); waveformCanvas.reveal(time);
waveformCanvas.redraw(); waveformCanvas.redraw();
updateValueList();
} }
} }
@ -757,17 +783,21 @@ public class WaveformViewer implements IWaveformViewer {
@Override @Override
public void moveSelectedTrack(int i) { public void moveSelectedTrack(int i) {
if(currentWaveformSelection!=null){ if(currentWaveformSelection!=null){
ITx selectedTx=currentTxSelection;
TrackEntry selectedWaveform=currentWaveformSelection;
int idx = streams.indexOf(currentWaveformSelection); int idx = streams.indexOf(currentWaveformSelection);
int newIdx=idx+i; int newIdx=idx+i;
if(newIdx>=0 && newIdx<streams.size()){ if(newIdx>=0 && newIdx<streams.size()){
Collections.swap(streams,idx,newIdx); Collections.swap(streams,idx,newIdx);
updateTracklist(); revealSelected=true;
if(selectedTx!=null){ // update();
setSelection(new StructuredSelection(new Object[]{selectedTx, selectedWaveform.waveform})); // ITx selectedTx=currentTxSelection;
} else // if(selectedTx!=null){
setSelection(new StructuredSelection(selectedWaveform.waveform)); // setSelection(new StructuredSelection(new Object[]{selectedTx, currentWaveformSelection.waveform}));
// } else {
// setSelection(new StructuredSelection(currentWaveformSelection.waveform));
// }
// waveformCanvas.reveal(currentWaveformSelection.waveform);
// valueList.redraw();
// nameList.redraw();
} }
} }
} }
@ -813,7 +843,7 @@ public class WaveformViewer implements IWaveformViewer {
IWaveform<? extends IWaveformEvent> w = trackEntry.waveform; IWaveform<? extends IWaveformEvent> w = trackEntry.waveform;
if (w instanceof ITxStream<?>) if (w instanceof ITxStream<?>)
subArea.height *= ((ITxStream<?>) w).getMaxConcurrency(); subArea.height *= ((ITxStream<?>) w).getMaxConcurrency();
drawValue(gc, subArea, firstKey, actualValues.get(w), trackEntry.selected); drawValue(gc, subArea, firstKey, trackEntry.currentValue, trackEntry.selected);
} else { } else {
for (Entry<Integer, TrackEntry> entry : trackVerticalOffset.subMap(firstKey, true, lastKey, true) for (Entry<Integer, TrackEntry> entry : trackVerticalOffset.subMap(firstKey, true, lastKey, true)
.entrySet()) { .entrySet()) {
@ -821,7 +851,7 @@ public class WaveformViewer implements IWaveformViewer {
subArea.height = waveformCanvas.getTrackHeight(); subArea.height = waveformCanvas.getTrackHeight();
if (w instanceof ITxStream<?>) if (w instanceof ITxStream<?>)
subArea.height *= ((ITxStream<?>) w).getMaxConcurrency(); subArea.height *= ((ITxStream<?>) w).getMaxConcurrency();
drawValue(gc, subArea, entry.getKey(), actualValues.get(w), entry.getValue().selected); drawValue(gc, subArea, entry.getKey(), entry.getValue().currentValue, entry.getValue().selected);
} }
} }
}catch(NoSuchElementException e){} }catch(NoSuchElementException e){}
@ -989,7 +1019,7 @@ public class WaveformViewer implements IWaveformViewer {
else else
streams.add(tgtIdx, srcWave); streams.add(tgtIdx, srcWave);
currentWaveformSelection=srcWave; currentWaveformSelection=srcWave;
updateTracklist(); update();
} else if(source instanceof CursorPainter){ } else if(source instanceof CursorPainter){
((CursorPainter)source).setTime(0); ((CursorPainter)source).setTime(0);
updateValueList(); updateValueList();
@ -1156,10 +1186,10 @@ public class WaveformViewer implements IWaveformViewer {
*/ */
@Override @Override
public String[] getZoomLevels(){ public String[] getZoomLevels(){
String[] res = new String[WaveformCanvas.unitMultiplier.length*WaveformCanvas.unitString.length]; String[] res = new String[Constants.unitMultiplier.length*Constants.unitString.length];
int index=0; int index=0;
for(String unit:WaveformCanvas.unitString){ for(String unit:Constants.unitString){
for(int factor:WaveformCanvas.unitMultiplier){ for(int factor:Constants.unitMultiplier){
res[index++]= new Integer(factor).toString()+unit; res[index++]= new Integer(factor).toString()+unit;
} }
} }
@ -1182,4 +1212,31 @@ public class WaveformViewer implements IWaveformViewer {
origin.x=(int) (-time/waveformCanvas.getScaleFactorPow10()); origin.x=(int) (-time/waveformCanvas.getScaleFactorPow10());
waveformCanvas.setOrigin(origin); waveformCanvas.setOrigin(origin);
} }
@Override
public void scrollHorizontal(int percent) {
if(percent<-100) percent=-100;
if(percent>100) percent=100;
int diff = (waveformCanvas.getWidth()*percent)/100;
// ScrollBar sb = waveformCanvas.getHorizontalBar();
// int x = sb.getSelection();
// System.out.println("Setting sb to "+ (x+diff));
// if((x+diff)>0)
// sb.setSelection(x+diff);
// else
// sb.setSelection(0);
Point o = waveformCanvas.getOrigin();
waveformCanvas.setOrigin(o.x-diff, o.y);
waveformCanvas.redraw();
}
public void asyncUpdate(Widget widget) {
widget.getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
waveformCanvas.redraw();
updateValueList();
}
});
}
} }

View File

@ -2,9 +2,10 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2 Bundle-ManifestVersion: 2
Bundle-Name: Database UI Bundle-Name: Database UI
Bundle-SymbolicName: com.minres.scviewer.database.ui Bundle-SymbolicName: com.minres.scviewer.database.ui
Bundle-Version: 1.0.0.qualifier Bundle-Version: 2.0.0.qualifier
Bundle-Vendor: MINRES Technologies GmbH Bundle-Vendor: MINRES Technologies GmbH
Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Export-Package: com.minres.scviewer.database.ui Export-Package: com.minres.scviewer.database.ui
Require-Bundle: com.minres.scviewer.database, Require-Bundle: com.minres.scviewer.database,
org.eclipse.jface org.eclipse.jface
Automatic-Module-Name: com.minres.scviewer.database.ui

View File

@ -1,12 +1,12 @@
<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"> <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> <modelVersion>4.0.0</modelVersion>
<artifactId>com.minres.scviewer.database.ui</artifactId> <artifactId>com.minres.scviewer.database.ui</artifactId>
<version>1.0.0-SNAPSHOT</version> <version>2.0.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging> <packaging>eclipse-plugin</packaging>
<parent> <parent>
<groupId>com.minres.scviewer</groupId> <groupId>com.minres.scviewer</groupId>
<artifactId>com.minres.scviewer.parent</artifactId> <artifactId>com.minres.scviewer.parent</artifactId>
<version>1.0.0-SNAPSHOT</version> <version>2.0.0-SNAPSHOT</version>
<relativePath>../com.minres.scviewer.parent</relativePath> <relativePath>../com.minres.scviewer.parent</relativePath>
</parent> </parent>
</project> </project>

View File

@ -34,6 +34,8 @@ public interface IWaveformViewer extends PropertyChangeListener, ISelectionProvi
public void addSelectionChangedListener(ISelectionChangedListener listener); public void addSelectionChangedListener(ISelectionChangedListener listener);
public void removeSelectionChangedListener(ISelectionChangedListener listener); public void removeSelectionChangedListener(ISelectionChangedListener listener);
public void update();
public Control getControl(); public Control getControl();
@ -100,4 +102,6 @@ public interface IWaveformViewer extends PropertyChangeListener, ISelectionProvi
public long getBaselineTime(); public long getBaselineTime();
public void setBaselineTime(Long scale); public void setBaselineTime(Long scale);
public void scrollHorizontal(int percent);
} }

View File

@ -17,7 +17,17 @@ import com.minres.scviewer.database.ITxStream;
import com.minres.scviewer.database.IWaveform; import com.minres.scviewer.database.IWaveform;
import com.minres.scviewer.database.IWaveformEvent; import com.minres.scviewer.database.IWaveformEvent;
public class TrackEntry { public class TrackEntry {
public enum ValueDisplay {
DEFAULT, SIGNED, UNSIGNED
}
public enum WaveDisplay {
DEFAULT, STEP_WISE, CONTINOUS
}
final public IWaveform<? extends IWaveformEvent> waveform; final public IWaveform<? extends IWaveformEvent> waveform;
public int vOffset; public int vOffset;
@ -26,6 +36,12 @@ public class TrackEntry {
public boolean selected; public boolean selected;
public String currentValue="";
public ValueDisplay valueDisplay = ValueDisplay.DEFAULT;
public WaveDisplay waveDisplay = WaveDisplay.DEFAULT;
public TrackEntry(IWaveform<? extends IWaveformEvent> waveform) { public TrackEntry(IWaveform<? extends IWaveformEvent> waveform) {
this.waveform = waveform; this.waveform = waveform;
vOffset=0; vOffset=0;

View File

@ -14,7 +14,7 @@ public enum WaveformColors {
LINE, LINE_HIGHLITE, LINE, LINE_HIGHLITE,
TRACK_BG_EVEN, TRACK_BG_ODD, TRACK_BG_HIGHLITE, TRACK_BG_EVEN, TRACK_BG_ODD, TRACK_BG_HIGHLITE,
TX_BG, TX_BG_HIGHLITE, TX_BORDER, TX_BG, TX_BG_HIGHLITE, TX_BORDER,
SIGNAL0, SIGNAL1, SIGNALZ, SIGNALX, SIGNALU, SIGNAL_TEXT, SIGNAL0, SIGNAL1, SIGNALZ, SIGNALX, SIGNALU, SIGNAL_TEXT, SIGNAL_REAL, SIGNAL_NAN,
CURSOR, CURSOR_DRAG, CURSOR_TEXT, CURSOR, CURSOR_DRAG, CURSOR_TEXT,
MARKER, MARKER_TEXT, REL_ARROW, REL_ARROW_HIGHLITE MARKER, MARKER_TEXT, REL_ARROW, REL_ARROW_HIGHLITE
} }

View File

@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2 Bundle-ManifestVersion: 2
Bundle-Name: VCD signal database Bundle-Name: VCD signal database
Bundle-SymbolicName: com.minres.scviewer.database.vcd Bundle-SymbolicName: com.minres.scviewer.database.vcd
Bundle-Version: 1.0.0.qualifier Bundle-Version: 2.0.0.qualifier
Bundle-Vendor: MINRES Technologies GmbH Bundle-Vendor: MINRES Technologies GmbH
Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: com.minres.scviewer.database;bundle-version="1.0.0", Require-Bundle: com.minres.scviewer.database;bundle-version="1.0.0",
@ -13,3 +13,4 @@ Require-Bundle: com.minres.scviewer.database;bundle-version="1.0.0",
Service-Component: OSGI-INF/component.xml Service-Component: OSGI-INF/component.xml
Bundle-ActivationPolicy: lazy Bundle-ActivationPolicy: lazy
Import-Package: com.google.common.collect Import-Package: com.google.common.collect
Automatic-Module-Name: com.minres.scviewer.database.vcd

View File

@ -4,8 +4,8 @@
<parent> <parent>
<groupId>com.minres.scviewer</groupId> <groupId>com.minres.scviewer</groupId>
<artifactId>com.minres.scviewer.parent</artifactId> <artifactId>com.minres.scviewer.parent</artifactId>
<version>1.0.0-SNAPSHOT</version> <version>2.0.0-SNAPSHOT</version>
<relativePath>../com.minres.scviewer.parent</relativePath> <relativePath>../com.minres.scviewer.parent</relativePath>
</parent> </parent>
<packaging>eclipse-plugin</packaging> <packaging>eclipse-plugin</packaging>
</project> </project>

View File

@ -34,34 +34,44 @@ public interface IVCDDatabaseBuilder {
* *
* @param netName the net name * @param netName the net name
* @param i the index of the net, -1 if a new one, otherwise the id if the referenced * @param i the index of the net, -1 if a new one, otherwise the id if the referenced
* @param width the width * @param width the width, -1 equals real, 0... is a bit vector
* @return the integer * @return the net id
*/ */
public Integer newNet(String netName, int i, int width) ; public Integer newNet(String netName, int i, int width) ;
/** /**
* Gets the net width. * Gets the net width.
* *
* @param intValue the int value * @param intValue the net id
* @return the net width * @return the net width, -1 means a real-valued net
*/ */
public int getNetWidth(int intValue); public int getNetWidth(int netId);
/** /**
* Append transition. * Append transition.
* *
* @param signalId the int value * @param netId the int value
* @param currentTime the current time in ps * @param currentTime the current time in ps
* @param decodedValues the decoded bit values * @param decodedValues the decoded bit values
*/ */
public void appendTransition(int signalId, long currentTime, BitVector decodedValues); public void appendTransition(int netId, long currentTime, char decodedValue);
/** /**
* Append transition. * Append transition.
* *
* @param signalId the int value * @param netId the int value
* @param currentTime the current time in ps * @param currentTime the current time in ps
* @param vValues the real values * @param decodedValues the decoded values
*/ */
public void appendTransition(int signalId, long currentTime, Double values); public void appendTransition(int netId, long currentTime, BitVector decodedValue);
/**
* Append transition.
*
* @param netId the int value
* @param currentTime the current time in ps
* @param decodedValue the decoded values
*/
public void appendTransition(int netId, long currentTime, double decodedValue);
} }

View File

@ -15,6 +15,7 @@ import java.io.FileInputStream;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.NavigableMap;
import java.util.Stack; import java.util.Stack;
import java.util.TreeMap; import java.util.TreeMap;
import java.util.Vector; import java.util.Vector;
@ -22,9 +23,9 @@ import java.util.Vector;
import com.minres.scviewer.database.BitVector; import com.minres.scviewer.database.BitVector;
import com.minres.scviewer.database.ISignal; import com.minres.scviewer.database.ISignal;
import com.minres.scviewer.database.ISignalChange; import com.minres.scviewer.database.ISignalChange;
import com.minres.scviewer.database.ISignalChangeMulti; import com.minres.scviewer.database.ISignalChangeBitVector;
import com.minres.scviewer.database.ISignalChangeReal; import com.minres.scviewer.database.ISignalChangeReal;
import com.minres.scviewer.database.ISignalChangeSingle; import com.minres.scviewer.database.ISignalChangeBit;
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.IWaveformDbLoader; import com.minres.scviewer.database.IWaveformDbLoader;
@ -69,6 +70,7 @@ public class VCDDbLoader implements IWaveformDbLoader, IVCDDatabaseBuilder {
@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;
this.maxTime=0;
FileInputStream fis = new FileInputStream(file); FileInputStream fis = new FileInputStream(file);
byte[] buffer = new byte[dateBytes.length]; byte[] buffer = new byte[dateBytes.length];
int read = fis.read(buffer, 0, dateBytes.length); int read = fis.read(buffer, 0, dateBytes.length);
@ -84,20 +86,25 @@ public class VCDDbLoader implements IWaveformDbLoader, IVCDDatabaseBuilder {
moduleStack=null; moduleStack=null;
if(!res) throw new InputFormatException(); if(!res) throw new InputFormatException();
// calculate max time of database // calculate max time of database
for(IWaveform<? extends IWaveformEvent> waveform:signals) for(IWaveform<? extends IWaveformEvent> waveform:signals) {
maxTime= Math.max(maxTime, ((ISignal<? extends ISignalChange>)waveform).getEvents().lastKey()); NavigableMap<Long, ? extends ISignalChange> events =((ISignal<? extends ISignalChange>)waveform).getEvents();
if(events.size()>0)
maxTime= Math.max(maxTime, events.lastKey());
}
// extend signals to hav a last value set at max time // extend signals to hav a last value set at max time
for(IWaveform<? extends IWaveformEvent> waveform:signals){ for(IWaveform<? extends IWaveformEvent> waveform:signals){
TreeMap<Long,? extends ISignalChange> events = ((VCDSignal<? extends ISignalChange>)waveform).values; TreeMap<Long,? extends ISignalChange> events = ((VCDSignal<? extends ISignalChange>)waveform).values;
if(events.lastKey()<maxTime){ if(events.size()>0 && events.lastKey()<maxTime){
ISignalChange x = events.lastEntry().getValue(); ISignalChange x = events.lastEntry().getValue();
if(x instanceof ISignalChangeSingle) if(x instanceof ISignalChangeBit)
((VCDSignal<ISignalChangeSingle>)waveform).values.put(maxTime, ((VCDSignal<ISignalChangeBit>)waveform).values.put(maxTime,
new VCDSignalChangeSingle(maxTime, ((ISignalChangeSingle)x).getValue())); new VCDSignalChangeBit(maxTime, ((ISignalChangeBit)x).getValue()));
else else if(x instanceof ISignalChangeBitVector)
if(x instanceof ISignalChangeMulti) ((VCDSignal<ISignalChangeBitVector>)waveform).values.put(maxTime,
((VCDSignal<ISignalChangeMulti>)waveform).values.put(maxTime, new VCDSignalChangeBitVector(maxTime, ((ISignalChangeBitVector)x).getValue()));
new VCDSignalChangeMulti(maxTime, ((ISignalChangeMulti)x).getValue())); else if(x instanceof ISignalChangeReal)
((VCDSignal<ISignalChangeReal>)waveform).values.put(maxTime,
new VCDSignalChangeReal(maxTime, ((ISignalChangeReal)x).getValue()));
} }
} }
return true; return true;
@ -124,9 +131,9 @@ public class VCDDbLoader implements IWaveformDbLoader, IVCDDatabaseBuilder {
*/ */
@Override @Override
public void enterModule(String tokenString) { public void enterModule(String tokenString) {
if(moduleStack.isEmpty()) if(moduleStack.isEmpty()) {
moduleStack.push(tokenString); if("SystemC".compareTo(tokenString)!=0) moduleStack.push(tokenString);
else } else
moduleStack.push(moduleStack.peek()+"."+tokenString); moduleStack.push(moduleStack.peek()+"."+tokenString);
} }
@ -144,15 +151,19 @@ public class VCDDbLoader implements IWaveformDbLoader, IVCDDatabaseBuilder {
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public Integer newNet(String netName, int i, int width) { public Integer newNet(String name, int i, int width) {
String netName = moduleStack.empty()? name: moduleStack.lastElement()+"."+name;
int id = signals.size(); int id = signals.size();
VCDSignal<? extends IWaveformEvent> signal; VCDSignal<? extends IWaveformEvent> signal;
if(width==1){ if(width<0) {
signal = i<0 ? new VCDSignal<ISignalChangeSingle>(db, id, netName) : signal = i<0 ? new VCDSignal<ISignalChangeReal>(db, id, netName, width) :
new VCDSignal<ISignalChangeSingle>((VCDSignal<ISignalChangeSingle>)signals.get(i), id, netName); new VCDSignal<ISignalChangeReal>((VCDSignal<ISignalChangeReal>)signals.get(i), id, netName);
} else if(width==1){
signal = i<0 ? new VCDSignal<ISignalChangeBit>(db, id, netName) :
new VCDSignal<ISignalChangeBit>((VCDSignal<ISignalChangeBit>)signals.get(i), id, netName);
} else { } else {
signal = i<0 ? new VCDSignal<ISignalChangeMulti>(db, id, netName, width) : signal = i<0 ? new VCDSignal<ISignalChangeBitVector>(db, id, netName, width) :
new VCDSignal<ISignalChangeMulti>((VCDSignal<VCDSignalChangeMulti>)signals.get(i), id, netName); new VCDSignal<ISignalChangeBitVector>((VCDSignal<VCDSignalChangeBitVector>)signals.get(i), id, netName);
}; };
signals.add(signal); signals.add(signal);
return id; return id;
@ -172,10 +183,12 @@ public class VCDDbLoader implements IWaveformDbLoader, IVCDDatabaseBuilder {
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public void appendTransition(int signalId, long currentTime, Double value) { public void appendTransition(int signalId, long currentTime, char decodedValues) {
VCDSignal<? extends IWaveformEvent> signal = (VCDSignal<? extends IWaveformEvent>) signals.get(signalId); VCDSignal<? extends IWaveformEvent> signal = (VCDSignal<? extends IWaveformEvent>) signals.get(signalId);
Long time = currentTime*TIME_RES; Long time = currentTime*TIME_RES;
((VCDSignal<ISignalChangeReal>)signal).values.put(time, new VCDSignalChangeReal(time, value)); if(signal.getWidth()==1){
((VCDSignal<ISignalChangeBit>)signal).values.put(time, new VCDSignalChangeBit(time, decodedValues));
}
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -185,11 +198,22 @@ public class VCDDbLoader implements IWaveformDbLoader, IVCDDatabaseBuilder {
@Override @Override
public void appendTransition(int signalId, long currentTime, BitVector decodedValues) { public void appendTransition(int signalId, long currentTime, BitVector decodedValues) {
VCDSignal<? extends IWaveformEvent> signal = (VCDSignal<? extends IWaveformEvent>) signals.get(signalId); VCDSignal<? extends IWaveformEvent> signal = (VCDSignal<? extends IWaveformEvent>) signals.get(signalId);
Long time = currentTime*TIME_RES; Long time = currentTime* TIME_RES;
if(signal.getWidth()==1){ if(signal.getWidth()>1){
((VCDSignal<ISignalChangeSingle>)signal).values.put(time, new VCDSignalChangeSingle(time, decodedValues.getValue()[0])); ((VCDSignal<VCDSignalChangeBitVector>)signal).values.put(time, new VCDSignalChangeBitVector(time, decodedValues));
} else { }
((VCDSignal<VCDSignalChangeMulti>)signal).values.put(time, new VCDSignalChangeMulti(time, decodedValues)); }
/* (non-Javadoc)
* @see com.minres.scviewer.database.vcd.ITraceBuilder#appendTransition(int, long, com.minres.scviewer.database.vcd.BitVector)
*/
@SuppressWarnings("unchecked")
@Override
public void appendTransition(int signalId, long currentTime, double decodedValue) {
VCDSignal<? extends IWaveformEvent> signal = (VCDSignal<? extends IWaveformEvent>) signals.get(signalId);
Long time = currentTime* TIME_RES;
if(signal.getWidth()<0){
((VCDSignal<ISignalChangeReal>)signal).values.put(time, new VCDSignalChangeReal(time, decodedValue));
} }
} }

View File

@ -61,9 +61,11 @@ class VCDFileParser {
private void parseVar() throws Exception { private void parseVar() throws Exception {
nextToken(); // type nextToken(); // type
String type = tokenizer.sval;
nextToken(); // size nextToken(); // size
int width = Integer.parseInt(tokenizer.sval); int width = Integer.parseInt(tokenizer.sval);
if("real".equals(type))
width*=-1;
nextToken(); nextToken();
String id = tokenizer.sval; String id = tokenizer.sval;
nextToken(); nextToken();
@ -147,14 +149,14 @@ class VCDFileParser {
if (tokenizer.sval.charAt(0) == '#') { // If the line begins with a #, this is a timestamp. if (tokenizer.sval.charAt(0) == '#') { // If the line begins with a #, this is a timestamp.
currentTime = Long.parseLong(tokenizer.sval.substring(1)) * picoSecondsPerIncrement; currentTime = Long.parseLong(tokenizer.sval.substring(1)) * picoSecondsPerIncrement;
} else { } else {
boolean isReal=false;
if(tokenizer.sval.equals("$comment")){ if(tokenizer.sval.equals("$comment")){
do { do {
if (!nextToken()) return false; if (!nextToken()) return false;
} while (!tokenizer.sval.equals("$end")); } while (!tokenizer.sval.equals("$end"));
return true; return true;
} }
if (tokenizer.sval.equals("$dumpvars") || tokenizer.sval.equals("$end")) return true; if (tokenizer.sval.equals("$dumpvars") || tokenizer.sval.equals("$end"))
return true;
String value, id; String value, id;
if (tokenizer.sval.charAt(0) == 'b') { if (tokenizer.sval.charAt(0) == 'b') {
// Multiple value net. Value appears first, followed by space, // Multiple value net. Value appears first, followed by space,
@ -162,13 +164,12 @@ class VCDFileParser {
value = tokenizer.sval.substring(1); value = tokenizer.sval.substring(1);
nextToken(); nextToken();
id = tokenizer.sval; id = tokenizer.sval;
} else if (tokenizer.sval.charAt(0) == 'r') { }else if (tokenizer.sval.charAt(0) == 'r') {
// real value net. Value appears first, followed by space, // Multiple value net. Value appears first, followed by space,
// then identifier // then identifier
value = tokenizer.sval.substring(1); value = tokenizer.sval.substring(1);
nextToken(); nextToken();
id = tokenizer.sval; id = tokenizer.sval;
isReal=true;
} else { } else {
// Single value net. identifier first, then value, no space. // Single value net. identifier first, then value, no space.
value = tokenizer.sval.substring(0, 1); value = tokenizer.sval.substring(0, 1);
@ -181,14 +182,13 @@ class VCDFileParser {
return true; return true;
} }
if(isReal) { int netWidth = traceBuilder.getNetWidth(net);
if("nan".equals(value)) { if(netWidth<0) {
if("nan".equals(value))
traceBuilder.appendTransition(net, currentTime, Double.NaN); traceBuilder.appendTransition(net, currentTime, Double.NaN);
} else { else
traceBuilder.appendTransition(net, currentTime, Double.parseDouble(value)); traceBuilder.appendTransition(net, currentTime, Double.parseDouble(value));
}
} else { } else {
int netWidth = traceBuilder.getNetWidth(net);
BitVector decodedValues = new BitVector(netWidth); BitVector decodedValues = new BitVector(netWidth);
if (value.equals("z") && netWidth > 1) { if (value.equals("z") && netWidth > 1) {
for (int i = 0; i < netWidth; i++) for (int i = 0; i < netWidth; i++)
@ -221,7 +221,10 @@ class VCDFileParser {
} }
} }
} }
traceBuilder.appendTransition(net, currentTime, decodedValues); if(netWidth==1)
traceBuilder.appendTransition(net, currentTime, decodedValues.getValue()[0]);
else
traceBuilder.appendTransition(net, currentTime, decodedValues);
} }
} }
return true; return true;

View File

@ -10,6 +10,7 @@
*******************************************************************************/ *******************************************************************************/
package com.minres.scviewer.database.vcd; package com.minres.scviewer.database.vcd;
import java.util.Map.Entry;
import java.util.NavigableMap; import java.util.NavigableMap;
import java.util.TreeMap; import java.util.TreeMap;
@ -106,7 +107,11 @@ public class VCDSignal<T extends ISignalChange> extends HierNode implements ISig
@Override @Override
public T getWaveformEventsBeforeTime(Long time) { public T getWaveformEventsBeforeTime(Long time) {
return values.floorEntry(time).getValue(); Entry<Long, T> e = values.floorEntry(time);
if(e==null)
return null;
else
return values.floorEntry(time).getValue();
} }
@Override @Override

View File

@ -10,14 +10,14 @@
*******************************************************************************/ *******************************************************************************/
package com.minres.scviewer.database.vcd; package com.minres.scviewer.database.vcd;
import com.minres.scviewer.database.ISignalChangeSingle; import com.minres.scviewer.database.ISignalChangeBit;
import com.minres.scviewer.database.SignalChange; import com.minres.scviewer.database.SignalChange;
public class VCDSignalChangeSingle extends SignalChange implements ISignalChangeSingle, Cloneable { public class VCDSignalChangeBit extends SignalChange implements ISignalChangeBit, Cloneable {
private char value; private char value;
public VCDSignalChangeSingle(Long time, char value) { public VCDSignalChangeBit(Long time, char value) {
super(time); super(time);
this.value=value; this.value=value;
} }

View File

@ -11,18 +11,18 @@
package com.minres.scviewer.database.vcd; package com.minres.scviewer.database.vcd;
import com.minres.scviewer.database.BitVector; import com.minres.scviewer.database.BitVector;
import com.minres.scviewer.database.ISignalChangeMulti; import com.minres.scviewer.database.ISignalChangeBitVector;
import com.minres.scviewer.database.SignalChange; import com.minres.scviewer.database.SignalChange;
public class VCDSignalChangeMulti extends SignalChange implements ISignalChangeMulti, Cloneable { public class VCDSignalChangeBitVector extends SignalChange implements ISignalChangeBitVector, Cloneable {
private BitVector value; private BitVector value;
public VCDSignalChangeMulti(Long time) { public VCDSignalChangeBitVector(Long time) {
super(time); super(time);
} }
public VCDSignalChangeMulti(Long time, BitVector decodedValues) { public VCDSignalChangeBitVector(Long time, BitVector decodedValues) {
super(time); super(time);
this.value=decodedValues; this.value=decodedValues;
} }

View File

@ -11,3 +11,4 @@ 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"
Automatic-Module-Name: com.minres.scviewer.database

View File

@ -4,8 +4,9 @@
<parent> <parent>
<groupId>com.minres.scviewer</groupId> <groupId>com.minres.scviewer</groupId>
<artifactId>com.minres.scviewer.parent</artifactId> <artifactId>com.minres.scviewer.parent</artifactId>
<version>1.0.0-SNAPSHOT</version> <version>2.0.0-SNAPSHOT</version>
<relativePath>../com.minres.scviewer.parent</relativePath> <relativePath>../com.minres.scviewer.parent</relativePath>
</parent> </parent>
<packaging>eclipse-plugin</packaging> <packaging>eclipse-plugin</packaging>
</project> <version>1.0.0-SNAPSHOT</version>
</project>

View File

@ -63,4 +63,49 @@ public class BitVector {
} }
return new String(res); return new String(res);
} }
public long toUnsignedValue() {
long res = 0;
for(char c:value) {
res<<=1;
switch (c) {
case VALUE_1:
res++;
break;
case VALUE_X:
case VALUE_Z:
return 0;
default:
break;
}
}
return res;
}
public long toSignedValue() {
Boolean negative=null;
long res = 0;
for(char c:value) {
if(negative == null) {
switch (c) {
case VALUE_1: negative=true; break;
case VALUE_0: negative=false; break;
case VALUE_X:
case VALUE_Z: return 0;
default:
}
} else {
res<<=1;
switch (c) {
case VALUE_1: if(!negative) res++; break;
case VALUE_0: if(negative) res++; break;
case VALUE_X:
case VALUE_Z: return 0;
default:
}
}
}
return negative?-1*(res+1):res;
}
} }

View File

@ -10,7 +10,7 @@
*******************************************************************************/ *******************************************************************************/
package com.minres.scviewer.database; package com.minres.scviewer.database;
public interface ISignalChangeSingle extends ISignalChange{ public interface ISignalChangeBit extends ISignalChange{
public char getValue(); public char getValue();

View File

@ -10,8 +10,7 @@
*******************************************************************************/ *******************************************************************************/
package com.minres.scviewer.database; package com.minres.scviewer.database;
public interface ISignalChangeBitVector extends ISignalChange {
public interface ISignalChangeMulti extends ISignalChange {
public BitVector getValue(); public BitVector getValue();

View File

@ -108,7 +108,7 @@
<parameters xmi:id="_cuGAkHcjEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.parameter.12" name="com.minres.scviewer.e4.application.command.navigateTransCommand.parameter.dir" value="prev"/> <parameters xmi:id="_cuGAkHcjEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.parameter.12" name="com.minres.scviewer.e4.application.command.navigateTransCommand.parameter.dir" value="prev"/>
</children> </children>
<children xsi:type="menu:ToolControl" xmi:id="_LtQhcIuKEeWid7xO48ZBXw" elementId="com.minres.scviewer.e4.application.toolcontrol.0" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.elements.RelationTypeToolControl"/> <children xsi:type="menu:ToolControl" xmi:id="_LtQhcIuKEeWid7xO48ZBXw" elementId="com.minres.scviewer.e4.application.toolcontrol.0" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.elements.RelationTypeToolControl"/>
<children xsi:type="menu:DirectToolItem" xmi:id="_Z7ZQkIuJEeWid7xO48ZBXw" elementId="com.minres.scviewer.e4.application.directtoolitem.nextprevinstream" toBeRendered="false" visible="false" label="Next/Prev in stream" enabled="false"> <children xsi:type="menu:DirectToolItem" xmi:id="_Z7ZQkIuJEeWid7xO48ZBXw" elementId="com.minres.scviewer.e4.application.directtoolitem.nextprevinstream" toBeRendered="false" visible="false" label="Next/Prev in stream">
<menu xmi:id="_aPyMMIuJEeWid7xO48ZBXw" elementId="com.minres.scviewer.e4.application.menu.2"> <menu xmi:id="_aPyMMIuJEeWid7xO48ZBXw" elementId="com.minres.scviewer.e4.application.menu.2">
<children xsi:type="menu:DynamicMenuContribution" xmi:id="_cnNWkIuJEeWid7xO48ZBXw" elementId="com.minres.scviewer.e4.application.dynamicmenucontribution.2" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.parts.NavigateContribution"/> <children xsi:type="menu:DynamicMenuContribution" xmi:id="_cnNWkIuJEeWid7xO48ZBXw" elementId="com.minres.scviewer.e4.application.dynamicmenucontribution.2" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.parts.NavigateContribution"/>
</menu> </menu>
@ -142,7 +142,7 @@
</children> </children>
</trimBars> </trimBars>
</children> </children>
<children xsi:type="basic:Dialog" xmi:id="_8BTkQIytEeWid7xO48ZBXw" elementId="com.minres.scviewer.e4.application.dialog.aboutscviewer" toBeRendered="false" visible="false" selectedElement="__VNlAIytEeWid7xO48ZBXw" label="About SCViewer" y="600"> <children xsi:type="basic:Window" xmi:id="_8BTkQIytEeWid7xO48ZBXw" elementId="com.minres.scviewer.e4.application.dialog.aboutscviewer" toBeRendered="false" visible="false" selectedElement="__VNlAIytEeWid7xO48ZBXw" label="About SCViewer" x="200" y="200">
<children xsi:type="basic:Part" xmi:id="__VNlAIytEeWid7xO48ZBXw" elementId="com.minres.scviewer.e4.application.part.0" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.parts.AboutDialog"/> <children xsi:type="basic:Part" xmi:id="__VNlAIytEeWid7xO48ZBXw" elementId="com.minres.scviewer.e4.application.part.0" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.parts.AboutDialog"/>
</children> </children>
<handlers xmi:id="_95PfvXNmEeWBq8z1Dv39LA" elementId="com.minres.scviewer.e4.application.handler.quitCommand" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.handlers.QuitHandler" command="_95PfvHNmEeWBq8z1Dv39LA"/> <handlers xmi:id="_95PfvXNmEeWBq8z1Dv39LA" elementId="com.minres.scviewer.e4.application.handler.quitCommand" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.handlers.QuitHandler" command="_95PfvHNmEeWBq8z1Dv39LA"/>
@ -171,6 +171,8 @@
<handlers xmi:id="_297tsHXHEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.handler.deletewaveformCommand" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.handlers.DeleteWaveformHandler" command="_WUZ2wHXHEeWwZ-9vrAR2UQ"/> <handlers xmi:id="_297tsHXHEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.handler.deletewaveformCommand" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.handlers.DeleteWaveformHandler" command="_WUZ2wHXHEeWwZ-9vrAR2UQ"/>
<handlers xmi:id="_2Ai4YHXHEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.handler.movewaveformupCommand" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.handlers.MoveWaveformHandler" command="_N_sOkHXHEeWwZ-9vrAR2UQ"/> <handlers xmi:id="_2Ai4YHXHEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.handler.movewaveformupCommand" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.handlers.MoveWaveformHandler" command="_N_sOkHXHEeWwZ-9vrAR2UQ"/>
<handlers xmi:id="_Du1NAHcrEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.handler.zoomCommand" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.handlers.ZoomHandler" command="_693GoHcqEeWwZ-9vrAR2UQ"/> <handlers xmi:id="_Du1NAHcrEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.handler.zoomCommand" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.handlers.ZoomHandler" command="_693GoHcqEeWwZ-9vrAR2UQ"/>
<handlers xmi:id="_bxt4QM3rEei6rfTGo88R-w" elementId="com.minres.scviewer.e4.application.handler.changeWaveDisplay" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.handlers.ChangeWaveformDisplay" command="_FZunYM2PEei6rfTGo88R-w"/>
<handlers xmi:id="_bxw7kM3rEei6rfTGo88R-w" elementId="com.minres.scviewer.e4.application.handler.changeValueDisplay" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.handlers.ChangeValueDisplay" command="_4C_asM3ZEei6rfTGo88R-w"/>
<menus xsi:type="menu:PopupMenu" xmi:id="_TwzrsHWSEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.popupmenu.namecontext" label="Name Menu"> <menus xsi:type="menu:PopupMenu" xmi:id="_TwzrsHWSEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.popupmenu.namecontext" label="Name Menu">
<children xsi:type="menu:HandledMenuItem" xmi:id="_Vco7YHWSEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.handledmenuitem.moveup" label="Move up" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/up_blue.png" tooltip="Move stream/waveform in list up" command="_N_sOkHXHEeWwZ-9vrAR2UQ"> <children xsi:type="menu:HandledMenuItem" xmi:id="_Vco7YHWSEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.handledmenuitem.moveup" label="Move up" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/up_blue.png" tooltip="Move stream/waveform in list up" command="_N_sOkHXHEeWwZ-9vrAR2UQ">
<visibleWhen xsi:type="ui:CoreExpression" xmi:id="_elFdcHr_EeWVM_sKoXvptg" coreExpressionId="com.minres.scviewer.e4.application.oneWaveSeleted"/> <visibleWhen xsi:type="ui:CoreExpression" xmi:id="_elFdcHr_EeWVM_sKoXvptg" coreExpressionId="com.minres.scviewer.e4.application.oneWaveSeleted"/>
@ -204,40 +206,51 @@
<children xsi:type="menu:HandledMenuItem" xmi:id="_4ZeEQHabEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.handledmenuitem.previouschange" label="Previous Tx" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/reverse_green.png" command="_Gn3lEHXKEeWwZ-9vrAR2UQ"> <children xsi:type="menu:HandledMenuItem" xmi:id="_4ZeEQHabEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.handledmenuitem.previouschange" label="Previous Tx" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/reverse_green.png" command="_Gn3lEHXKEeWwZ-9vrAR2UQ">
<parameters xmi:id="_4ZeEQXabEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.parameter.5" name="com.minres.scviewer.e4.application.command.navigateTransCommand.parameter.dir" value="prev"/> <parameters xmi:id="_4ZeEQXabEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.parameter.5" name="com.minres.scviewer.e4.application.command.navigateTransCommand.parameter.dir" value="prev"/>
</children> </children>
<children xsi:type="menu:MenuSeparator" xmi:id="__Ubd4M1eEei6rfTGo88R-w" elementId="com.minres.scviewer.e4.application.menuseparator.0"/>
<children xsi:type="menu:Menu" xmi:id="_mAA6sM1bEei6rfTGo88R-w" elementId="com.minres.scviewer.e4.application.menu.view" label="View">
<visibleWhen xsi:type="ui:ImperativeExpression" xmi:id="_psvR0M1gEei6rfTGo88R-w" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.elements.WaveformPopupMenuContribution"/>
<children xsi:type="menu:DynamicMenuContribution" xmi:id="_IQZZQM3hEei6rfTGo88R-w" elementId="com.minres.scviewer.e4.application.dynamicmenucontribution.0" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.elements.WaveformPopupMenuContribution"/>
</children>
</menus> </menus>
</descriptors> </descriptors>
<commands xmi:id="_95PfvHNmEeWBq8z1Dv39LA" elementId="org.eclipse.ui.file.exit" commandName="quitCommand"/> <commands xmi:id="_95PfvHNmEeWBq8z1Dv39LA" elementId="org.eclipse.ui.file.exit" commandName="Quit Command"/>
<commands xmi:id="_95PfwHNmEeWBq8z1Dv39LA" elementId="com.minres.scviewer.e4.application.open" commandName="openCommand"/> <commands xmi:id="_95PfwHNmEeWBq8z1Dv39LA" elementId="com.minres.scviewer.e4.application.open" commandName="Open Command"/>
<commands xmi:id="_95Pfw3NmEeWBq8z1Dv39LA" elementId="org.eclipse.ui.file.save" commandName="saveCommand"/> <commands xmi:id="_95Pfw3NmEeWBq8z1Dv39LA" elementId="org.eclipse.ui.file.save" commandName="Save Command"/>
<commands xmi:id="_95PfxnNmEeWBq8z1Dv39LA" elementId="org.eclipse.ui.help.aboutAction" commandName="aboutCommand"/> <commands xmi:id="_95PfxnNmEeWBq8z1Dv39LA" elementId="org.eclipse.ui.help.aboutAction" commandName="About Command"/>
<commands xmi:id="_N_sOkHXHEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.command.movewaveformupCommand" commandName="moveWaveformCommand"> <commands xmi:id="_N_sOkHXHEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.command.movewaveformupCommand" commandName="Move Waveform Command">
<parameters xmi:id="_lMv-EHZWEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.command.movewaveformupCommand.parameter.dir" name="direction" optional="false"/> <parameters xmi:id="_lMv-EHZWEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.command.movewaveformupCommand.parameter.dir" name="direction" optional="false"/>
</commands> </commands>
<commands xmi:id="_WUZ2wHXHEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.command.deletewaveformCommand" commandName="deleteWaveformCommand"/> <commands xmi:id="_WUZ2wHXHEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.command.deletewaveformCommand" commandName="Delete Waveform Command"/>
<commands xmi:id="_bV-TMHXHEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.command.selectallCommand" commandName="selectAllCommand"/> <commands xmi:id="_bV-TMHXHEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.command.selectallCommand" commandName="Select All Command"/>
<commands xmi:id="_Gn3lEHXKEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.command.navigateTransCommand" commandName="navigateTransCommand" description="Navigate to related transaction"> <commands xmi:id="_Gn3lEHXKEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.command.navigateTransCommand" commandName="Navigate Transaction Command" description="Navigate to related transaction">
<parameters xmi:id="_howw0HXQEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.command.navigateTransCommand.parameter.dir" name="direction" optional="false"/> <parameters xmi:id="_howw0HXQEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.command.navigateTransCommand.parameter.dir" name="direction" optional="false"/>
</commands> </commands>
<commands xmi:id="_79rx4HabEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.command.navigateEventCommand" commandName="navigateEventCommand"> <commands xmi:id="_79rx4HabEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.command.navigateEventCommand" commandName="Navigate Event Command">
<parameters xmi:id="_79rx4XabEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.command.navigateEventCommand.parameter.dir" name="direction" optional="false"/> <parameters xmi:id="_79rx4XabEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.command.navigateEventCommand.parameter.dir" name="direction" optional="false"/>
</commands> </commands>
<commands xmi:id="_693GoHcqEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.command.zoomcommand" commandName="zoomCommand"> <commands xmi:id="_693GoHcqEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.command.zoomcommand" commandName="Zoom Command">
<parameters xmi:id="_8tbm0HcqEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.command.zoomcommand.parameter.level" name="level" optional="false"/> <parameters xmi:id="_8tbm0HcqEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.command.zoomcommand.parameter.level" name="level" optional="false"/>
</commands> </commands>
<commands xmi:id="_2PehEHr9EeWVM_sKoXvptg" elementId="com.minres.scviewer.e4.application.command.addwaveform" commandName="addWaveformCommand"> <commands xmi:id="_2PehEHr9EeWVM_sKoXvptg" elementId="com.minres.scviewer.e4.application.command.addwaveform" commandName="Add Waveform Command">
<parameters xmi:id="_6KsZcHr9EeWVM_sKoXvptg" elementId="com.minres.scviewer.e4.application.command.addwaveform.where" name="where" optional="false"/> <parameters xmi:id="_6KsZcHr9EeWVM_sKoXvptg" elementId="com.minres.scviewer.e4.application.command.addwaveform.where" name="where" optional="false"/>
<parameters xmi:id="_7T1TcHwIEeWv0Y5uF2QN5w" elementId="com.minres.scviewer.e4.application.command.addwaveform.all" name="all" typeId="" optional="false"/> <parameters xmi:id="_7T1TcHwIEeWv0Y5uF2QN5w" elementId="com.minres.scviewer.e4.application.command.addwaveform.all" name="all" typeId="" optional="false"/>
</commands> </commands>
<commands xmi:id="_AxH6sIl_EeWxJ_wPkM6yGQ" elementId="org.eclipse.ui.window.preferences" commandName="Preferences"/> <commands xmi:id="_AxH6sIl_EeWxJ_wPkM6yGQ" elementId="org.eclipse.ui.window.preferences" commandName="Preferences"/>
<commands xmi:id="_KlGlsIoNEeWxJ_wPkM6yGQ" elementId="com.minres.scviewer.e4.application.command.set_them" commandName="Set Theme"> <commands xmi:id="_KlGlsIoNEeWxJ_wPkM6yGQ" elementId="com.minres.scviewer.e4.application.command.set_them" commandName="Set Theme Command">
<parameters xmi:id="_O8Z9IIoNEeWxJ_wPkM6yGQ" elementId="com.minres.scviewer.e4.application.command.theme.parameter.id" name="themeId" optional="false"/> <parameters xmi:id="_O8Z9IIoNEeWxJ_wPkM6yGQ" elementId="com.minres.scviewer.e4.application.command.theme.parameter.id" name="themeId" optional="false"/>
</commands> </commands>
<commands xmi:id="_E9lUgIt2EeWid7xO48ZBXw" elementId="com.minres.scviewer.e4.application.command.setrelationtype" commandName="SetRelationType"> <commands xmi:id="_E9lUgIt2EeWid7xO48ZBXw" elementId="com.minres.scviewer.e4.application.command.setrelationtype" commandName="Set Relation Type Command">
<parameters xmi:id="_xnW7IIt_EeWid7xO48ZBXw" elementId="com.minres.scviewer.e4.application.commandparameter.relationName" name="relationName" optional="false"/> <parameters xmi:id="_xnW7IIt_EeWid7xO48ZBXw" elementId="com.minres.scviewer.e4.application.commandparameter.relationName" name="relationName" optional="false"/>
</commands> </commands>
<commands xmi:id="_7-AIMJebEeW09eyIbHsdvg" elementId="com.minres.scviewer.e4.application.command.loadStoreSettings" commandName="loadStoreSettings"> <commands xmi:id="_7-AIMJebEeW09eyIbHsdvg" elementId="com.minres.scviewer.e4.application.command.loadStoreSettings" commandName="Load-Store Settings Command">
<parameters xmi:id="_wxY3EJehEeW09eyIbHsdvg" elementId="com.minres.scviewer.e4.application.commandparameter.loadStore" name="loadStore"/> <parameters xmi:id="_wxY3EJehEeW09eyIbHsdvg" elementId="com.minres.scviewer.e4.application.commandparameter.loadStore" name="loadStore"/>
</commands> </commands>
<commands xmi:id="_FZunYM2PEei6rfTGo88R-w" elementId="com.minres.scviewer.e4.application.command.changewavedisplay" commandName="Change Waveform Display Command">
<parameters xmi:id="_P6PYwM2PEei6rfTGo88R-w" elementId="com.minres.scviewer.e4.application.commandparameter.changewavedisplay" name="Type" optional="false"/>
</commands>
<commands xmi:id="_4C_asM3ZEei6rfTGo88R-w" elementId="com.minres.scviewer.e4.application.command.changevaluedisplay" commandName="Change Value Display Command">
<parameters xmi:id="_4C_asc3ZEei6rfTGo88R-w" elementId="com.minres.scviewer.e4.application.commandparameter.changevaluedisplay" name="Type" optional="false"/>
</commands>
<addons xmi:id="_95PfsnNmEeWBq8z1Dv39LA" elementId="org.eclipse.e4.core.commands.service" contributionURI="bundleclass://org.eclipse.e4.core.commands/org.eclipse.e4.core.commands.CommandServiceAddon"/> <addons xmi:id="_95PfsnNmEeWBq8z1Dv39LA" elementId="org.eclipse.e4.core.commands.service" contributionURI="bundleclass://org.eclipse.e4.core.commands/org.eclipse.e4.core.commands.CommandServiceAddon"/>
<addons xmi:id="_95Pfs3NmEeWBq8z1Dv39LA" elementId="org.eclipse.e4.ui.contexts.service" contributionURI="bundleclass://org.eclipse.e4.ui.services/org.eclipse.e4.ui.services.ContextServiceAddon"/> <addons xmi:id="_95Pfs3NmEeWBq8z1Dv39LA" elementId="org.eclipse.e4.ui.contexts.service" contributionURI="bundleclass://org.eclipse.e4.ui.services/org.eclipse.e4.ui.services.ContextServiceAddon"/>
<addons xmi:id="_95PftHNmEeWBq8z1Dv39LA" elementId="org.eclipse.e4.ui.bindings.service" contributionURI="bundleclass://org.eclipse.e4.ui.bindings/org.eclipse.e4.ui.bindings.BindingServiceAddon"/> <addons xmi:id="_95PftHNmEeWBq8z1Dv39LA" elementId="org.eclipse.e4.ui.bindings.service" contributionURI="bundleclass://org.eclipse.e4.ui.bindings/org.eclipse.e4.ui.bindings.BindingServiceAddon"/>

View File

@ -2,36 +2,37 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2 Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name Bundle-Name: %Bundle-Name
Bundle-SymbolicName: com.minres.scviewer.e4.application;singleton:=true Bundle-SymbolicName: com.minres.scviewer.e4.application;singleton:=true
Bundle-Version: 1.1.0.qualifier Bundle-Version: 2.0.0.qualifier
Bundle-Vendor: %Bundle-Vendor Bundle-Vendor: %Bundle-Vendor
Require-Bundle: javax.inject;bundle-version="1.0.0", Require-Bundle: javax.inject;bundle-version="1.0.0",
org.eclipse.core.runtime;bundle-version="3.11.1", org.eclipse.core.runtime;bundle-version="3.11.1",
org.eclipse.swt;bundle-version="3.104.1", org.eclipse.swt;bundle-version="3.104.1",
org.eclipse.e4.ui.model.workbench;bundle-version="1.1.100", org.eclipse.e4.ui.model.workbench;bundle-version="1.1.100",
org.eclipse.jface;bundle-version="3.11.0", org.eclipse.jface;bundle-version="3.11.0",
org.eclipse.e4.ui.services;bundle-version="1.2.0", org.eclipse.e4.ui.services;bundle-version="1.2.0",
org.eclipse.e4.ui.workbench;bundle-version="1.3.0", org.eclipse.e4.ui.workbench;bundle-version="1.3.0",
org.eclipse.e4.core.di;bundle-version="1.5.0", org.eclipse.e4.core.di;bundle-version="1.5.0",
org.eclipse.e4.ui.di;bundle-version="1.1.0", org.eclipse.e4.ui.di;bundle-version="1.1.0",
org.eclipse.e4.core.contexts;bundle-version="1.4.0", org.eclipse.e4.core.contexts;bundle-version="1.4.0",
com.minres.scviewer.database.ui.swt;bundle-version="1.0.0", com.minres.scviewer.database.ui.swt;bundle-version="1.0.0",
com.minres.scviewer.database.ui, com.minres.scviewer.database.ui,
com.minres.scviewer.database;bundle-version="1.0.0", com.minres.scviewer.database;bundle-version="1.0.0",
org.eclipse.equinox.ds;bundle-version="1.4.300", org.eclipse.equinox.ds;bundle-version="1.4.300",
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.5.0", org.eclipse.osgi.services;bundle-version="3.5.0",
org.eclipse.e4.core.services;bundle-version="2.0.0", org.eclipse.e4.core.services;bundle-version="2.0.0",
org.eclipse.osgi.services;bundle-version="3.5.0", org.eclipse.osgi.services;bundle-version="3.5.0",
org.eclipse.core.jobs, org.eclipse.core.jobs,
org.eclipse.osgi, org.eclipse.osgi,
com.google.guava, com.google.guava,
org.eclipse.equinox.preferences, org.eclipse.equinox.preferences,
org.eclipse.core.expressions, org.eclipse.core.expressions,
org.eclipse.e4.core.commands;bundle-version="0.11.0", org.eclipse.e4.core.commands;bundle-version="0.11.0",
org.eclipse.e4.ui.workbench.addons.swt, org.eclipse.e4.ui.workbench.addons.swt,
com.opcoach.e4.preferences, com.opcoach.e4.preferences,
org.eclipse.e4.core.di.extensions, org.eclipse.e4.core.di.extensions,
org.eclipse.e4.ui.css.swt.theme;bundle-version="0.10.0" org.eclipse.e4.ui.css.swt.theme;bundle-version="0.10.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Import-Package: com.minres.scviewer.database, Import-Package: com.minres.scviewer.database,
javax.inject;version="1.0.0" javax.inject;version="1.0.0"
Automatic-Module-Name: com.minres.scviewer.e4.application

View File

@ -7,7 +7,7 @@
<product <product
application="org.eclipse.e4.ui.workbench.swt.E4Application" application="org.eclipse.e4.ui.workbench.swt.E4Application"
description="%product.description" description="%product.description"
name="%product.name"> name="SCViewer">
<property <property
name="lifeCycleURI" name="lifeCycleURI"
value="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.E4LifeCycle"> value="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.E4LifeCycle">
@ -16,10 +16,6 @@
name="appName" name="appName"
value="SCViewer"> value="SCViewer">
</property> </property>
<property
name="windowImages"
value="icons/SCViewer_16x32.png,icons/SCViewer_32x32.png,icons/SCViewer_48x32.png,icons/SCViewer_64x32.png,icons/SCViewer_128x32.png,icons/SCViewer_256x32.png">
</property>
<property <property
name="applicationCSS" name="applicationCSS"
value="platform:/plugin/com.minres.scviewer.e4.application/css/default.css"> value="platform:/plugin/com.minres.scviewer.e4.application/css/default.css">

View File

@ -4,9 +4,8 @@
<parent> <parent>
<groupId>com.minres.scviewer</groupId> <groupId>com.minres.scviewer</groupId>
<artifactId>com.minres.scviewer.parent</artifactId> <artifactId>com.minres.scviewer.parent</artifactId>
<version>1.0.0-SNAPSHOT</version> <version>2.0.0-SNAPSHOT</version>
<relativePath>../com.minres.scviewer.parent</relativePath> <relativePath>../com.minres.scviewer.parent</relativePath>
</parent> </parent>
<packaging>eclipse-plugin</packaging> <packaging>eclipse-plugin</packaging>
<version>1.1.0-SNAPSHOT</version>
</project> </project>

View File

@ -33,6 +33,10 @@ import org.eclipse.equinox.app.IApplicationContext;
import org.osgi.service.event.Event; import org.osgi.service.event.Event;
import org.osgi.service.event.EventHandler; import org.osgi.service.event.EventHandler;
import com.minres.scviewer.e4.application.options.Options;
import com.minres.scviewer.e4.application.options.Options.Multiplicity;
import com.minres.scviewer.e4.application.options.Options.Separator;
/** /**
* This implementation contains e4 LifeCycle annotated methods.<br /> * This implementation contains e4 LifeCycle annotated methods.<br />
* There is a corresponding entry in <em>plugin.xml</em> (under the * There is a corresponding entry in <em>plugin.xml</em> (under the
@ -59,7 +63,17 @@ public class E4LifeCycle {
*/ */
@PostContextCreate @PostContextCreate
void postContextCreate(IApplicationContext appContext, final IEventBroker eventBroker) { void postContextCreate(IApplicationContext appContext, final IEventBroker eventBroker) {
final String[] args = (String[])appContext.getArguments().get(IApplicationContext.APPLICATION_ARGS); final String[] args = (String[])appContext.getArguments().get(IApplicationContext.APPLICATION_ARGS);
Options opt = new Options(args, 0, 1);
opt.getSet()
.addOption("clearPersistedState", Multiplicity.ZERO_OR_ONE)
.addOption("c", Separator.BLANK, Multiplicity.ZERO_OR_ONE);
if (!opt.check(Options.DEFAULT_SET, true, false)) {
System.err.println(opt.getCheckErrors());
System.exit(1);
}
final String confFile =opt.getSet().isSet("c")?opt.getSet().getOption("c").getResultValue(0):"";
// react on the first view being created, at that time the UI is available // react on the first view being created, at that time the UI is available
eventBroker.subscribe(UIEvents.UILifeCycle.ACTIVATE, new EventHandler() { eventBroker.subscribe(UIEvents.UILifeCycle.ACTIVATE, new EventHandler() {
@Override @Override
@ -68,9 +82,10 @@ public class E4LifeCycle {
if(part!=null){ if(part!=null){
IEclipseContext ctx = part.getContext(); IEclipseContext ctx = part.getContext();
OpenViewHandler openViewHandler= new OpenViewHandler(); OpenViewHandler openViewHandler= new OpenViewHandler();
if(confFile.length()>0) openViewHandler.setConfigFile(confFile);
ContextInjectionFactory.inject(openViewHandler, ctx); ContextInjectionFactory.inject(openViewHandler, ctx);
eventBroker.unsubscribe(this); eventBroker.unsubscribe(this);
for(String name:args){ for(String name:opt.getSet().getData()){
if(new File(name).exists()) openViewHandler.openViewForFile(name); if(new File(name).exists()) openViewHandler.openViewForFile(name);
} }
} }
@ -136,6 +151,7 @@ public class E4LifeCycle {
/** The part service. */ /** The part service. */
@Inject EPartService partService; @Inject EPartService partService;
String confFile="";
/** /**
* Open view for file. * Open view for file.
* *
@ -150,7 +166,13 @@ public class E4LifeCycle {
partService.showPart(part, PartState.ACTIVATE); partService.showPart(part, PartState.ACTIVATE);
IEclipseContext ctx=part.getContext(); IEclipseContext ctx=part.getContext();
ctx.modify("input", file); //$NON-NLS-1$ ctx.modify("input", file); //$NON-NLS-1$
ctx.declareModifiable("input"); //$NON-NLS-1$ //ctx.declareModifiable("input"); //$NON-NLS-1$
ctx.modify("config", confFile); //$NON-NLS-1$
//ctx.declareModifiable("config"); //$NON-NLS-1$
}
public void setConfigFile(String confFile) {
this.confFile=confFile;
} }
} }
} }

View File

@ -32,7 +32,7 @@ import com.minres.scviewer.e4.application.parts.WaveformViewer;
/** /**
* The Class NavigateContribution. Currently not used in Application.e4xmi * The Class NavigateContribution. Currently not used in Application.e4xmi
*/ */
public class NavigateContribution { public class NavigateToolbarContribution {
/** The part service. */ /** The part service. */
@Inject EPartService partService; @Inject EPartService partService;

View File

@ -0,0 +1,131 @@
package com.minres.scviewer.e4.application.elements;
import java.util.Iterator;
import java.util.List;
import javax.inject.Inject;
import org.eclipse.e4.core.di.annotations.Evaluate;
import org.eclipse.e4.ui.di.AboutToHide;
import org.eclipse.e4.ui.di.AboutToShow;
import org.eclipse.e4.ui.model.application.MApplication;
import org.eclipse.e4.ui.model.application.commands.MCommand;
import org.eclipse.e4.ui.model.application.commands.MCommandsFactory;
import org.eclipse.e4.ui.model.application.commands.MParameter;
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
import org.eclipse.e4.ui.model.application.ui.menu.ItemType;
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
import org.eclipse.e4.ui.model.application.ui.menu.MMenuElement;
import org.eclipse.e4.ui.model.application.ui.menu.MMenuFactory;
import org.eclipse.e4.ui.workbench.modeling.EModelService;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import com.minres.scviewer.database.ISignal;
import com.minres.scviewer.database.ISignalChange;
import com.minres.scviewer.database.ISignalChangeBitVector;
import com.minres.scviewer.database.ISignalChangeReal;
import com.minres.scviewer.database.ui.TrackEntry;
import com.minres.scviewer.e4.application.parts.WaveformViewer;
public class WaveformPopupMenuContribution {
int counter=0;
@Inject MPart activePart;
final TrackEntry nullEntry = new TrackEntry(null);
@Evaluate
public boolean evaluate() {
Object obj = activePart.getObject();
if(obj instanceof WaveformViewer){
WaveformViewer wfv = (WaveformViewer)obj;
ISelection sel = wfv.getSelection();
if(!sel.isEmpty() && sel instanceof IStructuredSelection) {
Object selected = ((IStructuredSelection)sel).getFirstElement();
if(selected instanceof ISignal<?>) {
ISignalChange s = (ISignalChange) ((ISignal<?>) selected).getEvents().firstEntry().getValue();
if((s instanceof ISignalChangeReal) || (s instanceof ISignalChangeBitVector)) {
return true;
}
}
}
}
return false;
}
@AboutToShow
public void aboutToShow(List<MMenuElement> items, MApplication application, EModelService modelService) {
Object obj = activePart.getObject();
if(obj instanceof WaveformViewer){
WaveformViewer wfv = (WaveformViewer)obj;
ISelection sel = wfv.getSelection();
if(!sel.isEmpty() && sel instanceof IStructuredSelection) {
Iterator<?> it = ((IStructuredSelection)sel).iterator();
Object first = it.next();
Object second=null;
if(it.hasNext()) second=it.next();
if(first instanceof ISignal<?>) {
ISignalChange s = (ISignalChange) ((ISignal<?>) first).getEvents().firstEntry().getValue();
//com.minres.scviewer.e4.application.menu.mulitvaluesettings
if((s instanceof ISignalChangeReal) || (s instanceof ISignalChangeBitVector)) {
TrackEntry entry=nullEntry;
if(second instanceof TrackEntry)
entry=(TrackEntry)second;
if(s instanceof ISignalChangeBitVector) {
addValueMenuItem(items, application, modelService, "hex", TrackEntry.ValueDisplay.DEFAULT, entry.valueDisplay);
addValueMenuItem(items, application, modelService, "unsigned", TrackEntry.ValueDisplay.UNSIGNED, entry.valueDisplay);
addValueMenuItem(items, application, modelService, "signed", TrackEntry.ValueDisplay.SIGNED, entry.valueDisplay);
items.add(MMenuFactory.INSTANCE.createMenuSeparator());
addWaveMenuItem(items, application, modelService, "bit vector", TrackEntry.WaveDisplay.DEFAULT, entry.waveDisplay);
}
addWaveMenuItem(items, application, modelService, "analog step-wise", TrackEntry.WaveDisplay.STEP_WISE, entry.waveDisplay);
addWaveMenuItem(items, application, modelService, "analog continous", TrackEntry.WaveDisplay.CONTINOUS, entry.waveDisplay);
}
}
}
}
}
private void addValueMenuItem(List<MMenuElement> items, MApplication application, EModelService modelService,
String label, TrackEntry.ValueDisplay value, TrackEntry.ValueDisplay actual) {
MHandledMenuItem item = MMenuFactory.INSTANCE.createHandledMenuItem();
item.setType(ItemType.RADIO);
item.setSelected(value==actual);
item.setLabel("Show as "+label);
item.setContributorURI("platform:/plugin/com.minres.scviewer.e4.application");
List<MCommand> cmds = modelService.findElements(application, "com.minres.scviewer.e4.application.command.changevaluedisplay", MCommand.class, null);
if(cmds.size()!=1) System.err.println("No command found!");
else item.setCommand(cmds.get(0));
MParameter param = MCommandsFactory.INSTANCE.createParameter();
param.setName("com.minres.scviewer.e4.application.commandparameter.changevaluedisplay");
param.setValue(value.toString());
item.getParameters().add(param);
items.add(item);
}
private void addWaveMenuItem(List<MMenuElement> items, MApplication application, EModelService modelService,
String label, TrackEntry.WaveDisplay value, TrackEntry.WaveDisplay actual) {
MHandledMenuItem item = MMenuFactory.INSTANCE.createHandledMenuItem();
item.setType(ItemType.RADIO);
item.setSelected(value==actual);
item.setLabel("Render "+label);
item.setContributorURI("platform:/plugin/com.minres.scviewer.e4.application");
List<MCommand> cmds = modelService.findElements(application, "com.minres.scviewer.e4.application.command.changewavedisplay", MCommand.class, null);
if(cmds.size()!=1) System.err.println("No command found!");
else item.setCommand(cmds.get(0));
MParameter param = MCommandsFactory.INSTANCE.createParameter();
param.setName("com.minres.scviewer.e4.application.commandparameter.changewavedisplay");
param.setValue(value.toString());
item.getParameters().add(param);
items.add(item);
}
@AboutToHide
public void aboutToHide(List<MMenuElement> items) {
}
}

View File

@ -12,16 +12,17 @@ package com.minres.scviewer.e4.application.handlers;
import org.eclipse.e4.core.di.annotations.Execute; import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.e4.ui.model.application.MApplication; import org.eclipse.e4.ui.model.application.MApplication;
import org.eclipse.e4.ui.model.application.ui.basic.MDialog;
import org.eclipse.e4.ui.model.application.ui.basic.MWindow; import org.eclipse.e4.ui.model.application.ui.basic.MWindow;
import org.eclipse.e4.ui.workbench.modeling.EModelService; import org.eclipse.e4.ui.workbench.modeling.EModelService;
import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Shell;
public class AboutHandler { public class AboutHandler {
static final String DIALOG_ID="com.minres.scviewer.e4.application.dialog.aboutscviewer";
@Execute @Execute
public void execute(Shell shell, MApplication app, MWindow window, EModelService ms /*@Named("mdialog01.dialog.0") MDialog dialog*/) { public void execute(Shell shell, MApplication app, MWindow window, EModelService ms /*@Named("mdialog01.dialog.0") MDialog dialog*/) {
MDialog dialog = (MDialog) ms.find("com.minres.scviewer.e4.application.dialog.aboutscviewer", app); //$NON-NLS-1$ MWindow dialog = (MWindow) ms.find(DIALOG_ID, app); //$NON-NLS-1$
dialog.setToBeRendered(true); dialog.setToBeRendered(true);
dialog.setToBeRendered(false); dialog.setToBeRendered(false);
} }

View File

@ -0,0 +1,51 @@
package com.minres.scviewer.e4.application.handlers;
import java.util.Iterator;
import javax.inject.Named;
import org.eclipse.e4.core.di.annotations.CanExecute;
import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
import org.eclipse.e4.ui.workbench.modeling.EPartService;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import com.minres.scviewer.database.ui.TrackEntry;
import com.minres.scviewer.e4.application.parts.WaveformViewer;
public class ChangeValueDisplay {
static final String PARAMETER_ID="com.minres.scviewer.e4.application.commandparameter.changevaluedisplay"; //$NON-NLS-1$
@CanExecute
public boolean canExecute(EPartService partService) {
MPart part = partService.getActivePart();
if(part==null) return false;
return (part.getObject() instanceof WaveformViewer);
}
@Execute
public void execute(@Named(PARAMETER_ID) String param, EPartService partService) {
MPart part = partService.getActivePart();
Object obj = part.getObject();
if(obj instanceof WaveformViewer){
WaveformViewer wfv = (WaveformViewer)obj;
ISelection sel = wfv.getSelection();
if(!sel.isEmpty() && sel instanceof IStructuredSelection) {
Iterator<?> it = ((IStructuredSelection)sel).iterator();
it.next();
if(it.hasNext()) {
Object second = it.next();
if(second instanceof TrackEntry) {
TrackEntry.ValueDisplay val = TrackEntry.ValueDisplay.valueOf(param);
((TrackEntry)second).valueDisplay=val;
wfv.update();
}
}
}
}
}
}

View File

@ -0,0 +1,51 @@
package com.minres.scviewer.e4.application.handlers;
import java.util.Iterator;
import javax.inject.Named;
import org.eclipse.e4.core.di.annotations.CanExecute;
import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
import org.eclipse.e4.ui.workbench.modeling.EPartService;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import com.minres.scviewer.database.ui.TrackEntry;
import com.minres.scviewer.e4.application.parts.WaveformViewer;
public class ChangeWaveformDisplay {
static final String PARAMETER_ID="com.minres.scviewer.e4.application.commandparameter.changewavedisplay"; //$NON-NLS-1$
@CanExecute
public boolean canExecute(EPartService partService) {
MPart part = partService.getActivePart();
if(part==null) return false;
return (part.getObject() instanceof WaveformViewer);
}
@Execute
public void execute(@Named(PARAMETER_ID) String param, EPartService partService) {
MPart part = partService.getActivePart();
Object obj = part.getObject();
if(obj instanceof WaveformViewer){
WaveformViewer wfv = (WaveformViewer)obj;
ISelection sel = wfv.getSelection();
if(!sel.isEmpty() && sel instanceof IStructuredSelection) {
Iterator<?> it = ((IStructuredSelection)sel).iterator();
it.next();
if(it.hasNext()) {
Object second = it.next();
if(second instanceof TrackEntry) {
TrackEntry.WaveDisplay val= TrackEntry.WaveDisplay.valueOf(param);
((TrackEntry)second).waveDisplay=val;
wfv.update();
}
}
}
}
}
}

View File

@ -30,31 +30,20 @@ public class OpenHandler {
@Execute @Execute
public void execute(Shell shell, MApplication app, EModelService modelService, EPartService partService){ public void execute(Shell shell, MApplication app, EModelService modelService, EPartService partService){
FileDialog dialog = new FileDialog(shell, SWT.OPEN | SWT.MULTI); FileDialog dialog = new FileDialog(shell, SWT.OPEN | SWT.MULTI);
// dialog.setFilterExtensions (new String []{"vcd", "txdb", "txlog"});
dialog.setFilterExtensions (new String []{Messages.OpenHandler_0}); dialog.setFilterExtensions (new String []{Messages.OpenHandler_0});
dialog.open(); dialog.open();
String path = dialog.getFilterPath(); String path = dialog.getFilterPath();
for(String fileName: dialog.getFileNames()){ for(String fileName: dialog.getFileNames()){
File file = new File(path+File.separator+fileName); File file = new File(path+File.separator+fileName);
if(file.exists()){ if(file.exists()){
// MPart part = MBasicFactory.INSTANCE.createPart();
// part.setLabel(fileName);
// part.setContributionURI("bundleclass://com.minres.scviewer.e4.application/"+ WaveformViewerPart.class.getName());
MPart part = partService .createPart("com.minres.scviewer.e4.application.partdescriptor.waveformviewer"); //$NON-NLS-1$ MPart part = partService .createPart("com.minres.scviewer.e4.application.partdescriptor.waveformviewer"); //$NON-NLS-1$
part.setLabel(file.getName()); part.setLabel(file.getName());
MPartStack partStack = (MPartStack)modelService.find("org.eclipse.editorss", app); //$NON-NLS-1$ MPartStack partStack = (MPartStack)modelService.find("org.eclipse.editorss", app); //$NON-NLS-1$
partStack.getChildren().add(part); partStack.getChildren().add(part);
partService.showPart(part, PartState.ACTIVATE); partService.showPart(part, PartState.ACTIVATE);
// Object o = part.getObject();
// if(o instanceof WaveformViewerPart)
// ((WaveformViewerPart)o).setPartInput(file);
IEclipseContext ctx=part.getContext(); IEclipseContext ctx=part.getContext();
ctx.modify("input", file); //$NON-NLS-1$ ctx.modify("input", file); //$NON-NLS-1$
ctx.declareModifiable("input"); //$NON-NLS-1$ ctx.modify("config", ""); //$NON-NLS-1$
} }
} }
} }

View File

@ -1,5 +1,5 @@
AboutDialog_0=\nSCViewer - a SystemC waveform viewer\n\nVersion: 1.2\n AboutDialog_0=\nSCViewer - a SystemC waveform viewer\n\nVersion: 2.0\n
AboutDialog_1=\nCopyright (c) 2015,2016,2017 MINRES Technologies GmbH and others.\n\nAll rights reserved. MINRES and the MINRES logo are trademarks of MINRES Technologies GmbH, http://www.minres.com/. 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\n\nParts of the software are governed by the Apache License Version 2.0 available at http://www.apache.org/licenses/. These are namely org.apache.jdbm and org.sqlite JDBC driver\n\nSources code is hosted at GitHub: https://github.com/minres/SCViewer\n AboutDialog_1=\nCopyright (c) 2015, 2018 MINRES Technologies GmbH and others.\n\nAll rights reserved. MINRES and the MINRES logo are trademarks of MINRES Technologies GmbH, http://www.minres.com/. 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\n\nParts of the software are governed by the Apache License Version 2.0 available at http://www.apache.org/licenses/. These are namely org.apache.jdbm and org.sqlite JDBC driver\n\nSources code is hosted at GitHub: https://github.com/minres/SCViewer\n
DesignBrowser_12=Append all after DesignBrowser_12=Append all after
DesignBrowser_16=Insert all before DesignBrowser_16=Insert all before
DesignBrowser_2=Enter text to filter waveforms DesignBrowser_2=Enter text to filter waveforms

View File

@ -0,0 +1,275 @@
package com.minres.scviewer.e4.application.options;
/**
* This class holds all the data for an option. This includes the prefix, the key, the separator
* (for value options), the multiplicity, and all the other settings describing the option. The class
* is designed to be only a data container from a user perspective, i. e. the user has read-access to
* any data determined by the {@link Options#check()}, but not access to any of the other methods
* which are used internally for the operation of the actual check.
*/
public class OptionData {
private final static String CLASS = "OptionData";
private Options.Prefix prefix = null;
private String key = null;
private boolean detail = false;
private Options.Separator separator = null;
private boolean value = false;
private Options.Multiplicity multiplicity = null;
private java.util.regex.Pattern pattern = null;
private int counter = 0;
private java.util.ArrayList<String> values = null;
private java.util.ArrayList<String> details = null;
/**
* The constructor
*/
OptionData(Options.Prefix prefix,
String key,
boolean detail,
Options.Separator separator,
boolean value,
Options.Multiplicity multiplicity) {
if (prefix == null) throw new IllegalArgumentException(CLASS + ": prefix may not be null");
if (key == null) throw new IllegalArgumentException(CLASS + ": key may not be null");
if (separator == null) throw new IllegalArgumentException(CLASS + ": separator may not be null");
if (multiplicity == null) throw new IllegalArgumentException(CLASS + ": multiplicity may not be null");
//.... The data describing the option
this.prefix = prefix;
this.key = key;
this.detail = detail;
this.separator = separator;
this.value = value;
this.multiplicity = multiplicity;
//.... Create the pattern to match this option
if (value) {
if (separator == Options.Separator.BLANK) {
if (detail) {
pattern = java.util.regex.Pattern.compile(prefix.getName() + key + "((\\w|\\.)+)$");
} else {
pattern = java.util.regex.Pattern.compile(prefix.getName() + key + "$");
}
} else {
if (detail) {
pattern = java.util.regex.Pattern.compile(prefix.getName() + key + "((\\w|\\.)+)" + separator.getName() + "(.+)$");
} else {
pattern = java.util.regex.Pattern.compile(prefix.getName() + key + separator.getName() + "(.+)$");
}
}
} else {
pattern = java.util.regex.Pattern.compile(prefix.getName() + key + "$");
}
//.... Structures to hold result data
if (value) {
values = new java.util.ArrayList<String>();
if (detail)
details = new java.util.ArrayList<String>();
}
}
/**
* Getter method for <code>prefix</code> property
* <p>
* @return The value for the <code>prefix</code> property
*/
Options.Prefix getPrefix() {
return prefix;
}
/**
* Getter method for <code>key</code> property
* <p>
* @return The value for the <code>key</code> property
*/
String getKey() {
return key;
}
/**
* Getter method for <code>detail</code> property
* <p>
* @return The value for the <code>detail</code> property
*/
boolean useDetail() {
return detail;
}
/**
* Getter method for <code>separator</code> property
* <p>
* @return The value for the <code>separator</code> property
*/
Options.Separator getSeparator() {
return separator;
}
/**
* Getter method for <code>value</code> property
* <p>
* @return The value for the <code>value</code> property
*/
boolean useValue() {
return value;
}
/**
* Getter method for <code>multiplicity</code> property
* <p>
* @return The value for the <code>multiplicity</code> property
*/
Options.Multiplicity getMultiplicity() {
return multiplicity;
}
/**
* Getter method for <code>pattern</code> property
* <p>
* @return The value for the <code>pattern</code> property
*/
java.util.regex.Pattern getPattern() {
return pattern;
}
/**
* Get the number of results found for this option, which is number of times the key matched
* <p>
* @return The number of results
*/
public int getResultCount() {
if (value) {
return values.size();
} else {
return counter;
}
}
/**
* Get the value with the given index. The index can range between 0 and {@link #getResultCount()}<code> - 1</code>.
* However, only for value options, a non-<code>null</code> value will be returned. Non-value options always
* return <code>null</code>.
* <p>
* @param index The index for the desired value
* <p>
* @return The option value with the given index
* <p>
* @throws IllegalArgumentException If the value for <code>index</code> is out of bounds
*/
public String getResultValue(int index) {
if (!value) return null;
if (index < 0 || index >= getResultCount()) throw new IllegalArgumentException(CLASS + ": illegal value for index");
return values.get(index);
}
/**
* Get the detail with the given index. The index can range between 0 and {@link #getResultCount()}<code> - 1</code>.
* However, only for value options which take details, a non-<code>null</code> detail will be returned. Non-value options
* and value options which do not take details always return <code>null</code>.
* <p>
* @param index The index for the desired value
* <p>
* @return The option detail with the given index
* <p>
* @throws IllegalArgumentException If the value for <code>index</code> is out of bounds
*/
public String getResultDetail(int index) {
if (!detail) return null;
if (index < 0 || index >= getResultCount()) throw new IllegalArgumentException(CLASS + ": illegal value for index");
return details.get(index);
}
/**
* Store the data for a match found
*/
void addResult(String valueData, String detailData) {
if (value) {
if (valueData == null) throw new IllegalArgumentException(CLASS + ": valueData may not be null");
values.add(valueData);
if (detail) {
if (detailData == null) throw new IllegalArgumentException(CLASS + ": detailData may not be null");
details.add(detailData);
}
}
counter++;
}
/**
* This is the overloaded {@link Object#toString()} method, and it is provided mainly for debugging
* purposes.
* <p>
* @return A string representing the instance
*/
public String toString() {
StringBuffer sb = new StringBuffer();
sb.append("Prefix : ");
sb.append(prefix);
sb.append('\n');
sb.append("Key : ");
sb.append(key);
sb.append('\n');
sb.append("Detail : ");
sb.append(detail);
sb.append('\n');
sb.append("Separator : ");
sb.append(separator);
sb.append('\n');
sb.append("Value : ");
sb.append(value);
sb.append('\n');
sb.append("Multiplicity: ");
sb.append(multiplicity);
sb.append('\n');
sb.append("Pattern : ");
sb.append(pattern);
sb.append('\n');
sb.append("Results : ");
sb.append(counter);
sb.append('\n');
if (value) {
if (detail) {
for (int i = 0; i < values.size(); i++) {
sb.append(details.get(i));
sb.append(" / ");
sb.append(values.get(i));
sb.append('\n');
}
} else {
for (int i = 0; i < values.size(); i++) {
sb.append(values.get(i));
sb.append('\n');
}
}
}
return sb.toString();
}
}

View File

@ -0,0 +1,276 @@
package com.minres.scviewer.e4.application.options;
/**
* This class holds the information for a <i>set</i> of options. A set can hold any number of
* <code>OptionData</code> instances which are checked together to determine success or failure.
* <p>
* The approach to use this class looks like this:
* <p>
* <ol>
* <li> The user uses any of the <code>Options.addSet()</code> (e. g. {@link Options#addSet(String)}) to create
* any number of sets required (or just relies on the default set, if only one set is required)
* <li> The user adds all required option definitions to each set
* <li> Using any of the <code>Options.check()</code> methods, each set can be checked whether the options
* that were specified on the command line satisfy its requirements
* <li> If the check was successful for a given set, several data items are available from this class:
* <ul>
* <li> All options defined for the set (through with e. g. values, details, and multiplicity are available)
* <li> All data items found (these are the items on the command line which do not start with the prefix,
* i. e. non-option arguments)
* <li> All unmatched arguments on the command line (these are the items on the command line which start
* with the prefix, but do not match to one of the options).
* Programs can elect to ignore these, or react with an error
* </ul>
* </ol>
*/
public class OptionSet {
private final static String CLASS = "OptionSet";
private java.util.ArrayList<OptionData> options = new java.util.ArrayList<OptionData>();
private java.util.HashMap<String, OptionData> keys = new java.util.HashMap<String, OptionData>();
private java.util.ArrayList<String> unmatched = new java.util.ArrayList<String>();
private java.util.ArrayList<String> data = new java.util.ArrayList<String>();
private String setName = null;
private int minData = 0;
private int maxData = 0;
private Options.Prefix prefix = null;
private Options.Multiplicity defaultMultiplicity = null;
/**
* Constructor
*/
OptionSet(Options.Prefix prefix, Options.Multiplicity defaultMultiplicity, String setName, int minData, int maxData) {
if (setName == null) throw new IllegalArgumentException(CLASS + ": setName may not be null");
if (minData < 0) throw new IllegalArgumentException(CLASS + ": minData must be >= 0");
if (maxData < minData) throw new IllegalArgumentException(CLASS + ": maxData must be >= minData");
this.prefix = prefix;
this.defaultMultiplicity = defaultMultiplicity;
this.setName = setName;
this.minData = minData;
this.maxData = maxData;
}
/**
* Get a list of all the options defined for this set
* <p>
* @return A list of {@link OptionData} instances defined for this set
*/
public java.util.ArrayList<OptionData> getOptionData() {
return options;
}
/**
* Get the data for a specific option, identified by its key name (which is unique)
* <p>
* @param key The key for the option
* <p>
* @return The {@link OptionData} instance
* <p>
* @throws IllegalArgumentException If the <code>key</code> is <code>null</code> or unknown in this set
*/
public OptionData getOption(String key) {
if (key == null) throw new IllegalArgumentException(CLASS + ": key may not be null");
if (!keys.containsKey(key)) throw new IllegalArgumentException(CLASS + ": unknown key: " + key);
return keys.get(key);
}
/**
* Check whether a specific option is set, i. e. whether it was specified at least once on the command line.
* <p>
* @param key The key for the option
* <p>
* @return <code>true</code> or <code>false</code>, depending on the outcome of the check
* <p>
* @throws IllegalArgumentException If the <code>key</code> is <code>null</code> or unknown in this set
*/
public boolean isSet(String key) {
if (key == null) throw new IllegalArgumentException(CLASS + ": key may not be null");
if (!keys.containsKey(key)) throw new IllegalArgumentException(CLASS + ": unknown key: " + key);
return keys.get(key).getResultCount() > 0 ? true : false;
}
/**
* Getter method for <code>setName</code> property
* <p>
* @return The value for the <code>setName</code> property
*/
public String getSetName() {
return setName;
}
/**
* Getter method for <code>minData</code> property
* <p>
* @return The value for the <code>minData</code> property
*/
public int getMinData() {
return minData;
}
/**
* Getter method for <code>maxData</code> property
* <p>
* @return The value for the <code>maxData</code> property
*/
public int getMaxData() {
return maxData;
}
/**
* Return the data items found (these are the items on the command line which do not start with the prefix, i. e. non-option arguments)
* <p>
* @return A list of strings with all data items found
*/
public java.util.ArrayList<String> getData() {
return data;
}
/**
* Return all unmatched items found (these are the items on the command line which start with the prefix, but do not
* match to one of the options)
* <p>
* @return A list of strings with all unmatched items found
*/
public java.util.ArrayList<String> getUnmatched() {
return unmatched;
}
/**
* Add a non-value option with the given key, and the default prefix and multiplicity
* <p>
* @param key The key for the option
* <p>
* @return The set instance itself (to support invocation chaining for <code>addOption()</code> methods)
* <p>
* @throws IllegalArgumentException If the <code>key</code> is <code>null</code> or a key with this name has already been defined
*/
public OptionSet addOption(String key) {
return addOption(key, defaultMultiplicity);
}
/**
* Add a non-value option with the given key and multiplicity, and the default prefix
* <p>
* @param key The key for the option
* @param multiplicity The multiplicity for the option
* <p>
* @return The set instance itself (to support invocation chaining for <code>addOption()</code> methods)
* <p>
* @throws IllegalArgumentException If the <code>key</code> is <code>null</code> or a key with this name has already been defined
* or if <code>multiplicity</code> is <code>null</code>
*/
public OptionSet addOption(String key, Options.Multiplicity multiplicity) {
return addOption(key, false, Options.Separator.NONE, false, multiplicity);
}
/**
* Add a value option with the given key and separator, no details, and the default prefix and multiplicity
* <p>
* @param key The key for the option
* @param separator The separator for the option
* <p>
* @return The set instance itself (to support invocation chaining for <code>addOption()</code> methods)
* <p>
* @throws IllegalArgumentException If the <code>key</code> is <code>null</code> or a key with this name has already been defined
* or if <code>separator</code> is <code>null</code>
*/
public OptionSet addOption(String key, Options.Separator separator) {
return addOption(key, false, separator, true, defaultMultiplicity);
}
/**
* Add a value option with the given key, separator, and multiplicity, no details, and the default prefix
* <p>
* @param key The key for the option
* @param separator The separator for the option
* @param multiplicity The multiplicity for the option
* <p>
* @return The set instance itself (to support invocation chaining for <code>addOption()</code> methods)
* <p>
* @throws IllegalArgumentException If the <code>key</code> is <code>null</code> or a key with this name has already been defined
* or if <code>separator</code> or <code>multiplicity</code> are <code>null</code>
*/
public OptionSet addOption(String key, Options.Separator separator, Options.Multiplicity multiplicity) {
return addOption(key, false, separator, true, multiplicity);
}
/**
*
* Add a value option with the given key and separator, possibly details, and the default prefix and multiplicity
* <p>
* @param key The key for the option
* @param details A boolean indicating whether details are expected for the option
* @param separator The separator for the option
* <p>
* @return The set instance itself (to support invocation chaining for <code>addOption()</code> methods)
* <p>
* @throws IllegalArgumentException If the <code>key</code> is <code>null</code> or a key with this name has already been defined
* or if <code>separator</code> is <code>null</code>
*/
public OptionSet addOption(String key, boolean details, Options.Separator separator) {
return addOption(key, details, separator, true, defaultMultiplicity);
}
/**
* Add a value option with the given key, separator, and multiplicity, possibly details, and the default prefix
* <p>
* @param key The key for the option
* @param details A boolean indicating whether details are expected for the option
* @param separator The separator for the option
* @param multiplicity The multiplicity for the option
* <p>
* @return The set instance itself (to support invocation chaining for <code>addOption()</code> methods)
* <p>
* @throws IllegalArgumentException If the <code>key</code> is <code>null</code> or a key with this name has already been defined
* or if <code>separator</code> or <code>multiplicity</code> are <code>null</code>
*/
public OptionSet addOption(String key, boolean details, Options.Separator separator, Options.Multiplicity multiplicity) {
return addOption(key, details, separator, true, multiplicity);
}
/**
* The master method to add an option. Since there are combinations which are not
* acceptable (like a NONE separator and a true value), this method is not public.
* Internally, we only supply acceptable combinations.
*/
OptionSet addOption(String key,
boolean details,
Options.Separator separator,
boolean value,
Options.Multiplicity multiplicity) {
if (key == null) throw new IllegalArgumentException(CLASS + ": key may not be null");
if (multiplicity == null) throw new IllegalArgumentException(CLASS + ": multiplicity may not be null");
if (separator == null) throw new IllegalArgumentException(CLASS + ": separator may not be null");
if (keys.containsKey(key)) throw new IllegalArgumentException(CLASS + ": the key "
+ key + " has already been defined for this OptionSet");
OptionData od = new OptionData(prefix, key, details, separator, value, multiplicity);
options.add(od);
keys.put(key, od);
return this;
}
}

View File

@ -0,0 +1,768 @@
package com.minres.scviewer.e4.application.options;
/**
* The central class for option processing. Sets are identified by their name, but there is also
* an anonymous default set, which is very convenient if an application requieres only one set.
*/
public class Options {
private final static String CLASS = "Options";
/**
* The name used internally for the default set
*/
public final static String DEFAULT_SET = "DEFAULT_OPTION_SET";
/**
* An enum encapsulating the possible separators between value options and their actual values.
*/
public enum Separator {
/**
* Separate option and value by ":"
*/
COLON(':'),
/**
* Separate option and value by "="
*/
EQUALS('='),
/**
* Separate option and value by blank space
*/
BLANK(' '), // Or, more precisely, whitespace (as allowed by the CLI)
/**
* This is just a placeholder in case no separator is required (i. e. for non-value options)
*/
NONE('D'); // NONE is a placeholder in case no separator is required, 'D' is just an arbitrary dummy value
private char c;
private Separator(char c) {
this.c = c;
}
/**
* Return the actual separator character
* <p>
* @return The actual separator character
*/
char getName() {
return c;
}
}
/**
* An enum encapsulating the possible prefixes identifying options (and separating them from command line data items)
*/
public enum Prefix {
/**
* Options start with a "-" (typically on Unix platforms)
*/
DASH('-'),
/**
* Options start with a "/" (typically on Windows platforms)
*/
SLASH('/');
private char c;
private Prefix(char c) {
this.c = c;
}
/**
* Return the actual prefix character
* <p>
* @return The actual prefix character
*/
char getName() {
return c;
}
}
/**
* An enum encapsulating the possible multiplicities for options
*/
public enum Multiplicity {
/**
* Option needs to occur exactly once
*/
ONCE,
/**
* Option needs to occur at least once
*/
ONCE_OR_MORE,
/**
* Option needs to occur either once or not at all
*/
ZERO_OR_ONE,
/**
* Option can occur any number of times
*/
ZERO_OR_MORE;
}
private java.util.HashMap<String, OptionSet> optionSets = new java.util.HashMap<String, OptionSet>();
private Prefix prefix = null;
private Multiplicity defaultMultiplicity = null;
private String[] arguments = null;
private int defaultMinData = 0;
private int defaultMaxData = 0;
private StringBuffer checkErrors = null;
/**
* Constructor
* <p>
* @param args The command line arguments to check
* @param prefix The prefix to use for all command line options. It can only be set here for all options at
* the same time
* @param defaultMultiplicity The default multiplicity to use for all options (can be overridden when adding an option)
* @param defMinData The default minimum number of data items for all sets (can be overridden when adding a set)
* @param defMaxData The default maximum number of data items for all sets (can be overridden when adding a set)
* <p>
* @throws IllegalArgumentException If either <code>args</code>, <code>prefix</code>, or <code>defaultMultiplicity</code>
* is <code>null</code> - or if the data range values don't make sense
*/
public Options(String args[], Prefix prefix, Multiplicity defaultMultiplicity, int defMinData, int defMaxData) {
if (args == null) throw new IllegalArgumentException(CLASS + ": args may not be null");
if (prefix == null) throw new IllegalArgumentException(CLASS + ": prefix may not be null");
if (defaultMultiplicity == null) throw new IllegalArgumentException(CLASS + ": defaultMultiplicity may not be null");
if (defMinData < 0) throw new IllegalArgumentException(CLASS + ": defMinData must be >= 0");
if (defMaxData < defMinData) throw new IllegalArgumentException(CLASS + ": defMaxData must be >= defMinData");
arguments = new String[args.length];
int i = 0;
for (String s : args)
arguments[i++] = s;
this.prefix = prefix;
this.defaultMultiplicity = defaultMultiplicity;
this.defaultMinData = defMinData;
this.defaultMaxData = defMaxData;
}
/**
* Constructor
* <p>
* @param args The command line arguments to check
* @param prefix The prefix to use for all command line options. It can only be set here for all options at
* the same time
* @param defaultMultiplicity The default multiplicity to use for all options (can be overridden when adding an option)
* @param data The default minimum and maximum number of data items for all sets (can be overridden when adding a set)
* <p>
* @throws IllegalArgumentException If either <code>args</code>, <code>prefix</code>, or <code>defaultMultiplicity</code>
* is <code>null</code> - or if the data range value doesn't make sense
*/
public Options(String args[], Prefix prefix, Multiplicity defaultMultiplicity, int data) {
this(args, prefix, defaultMultiplicity, data, data);
}
/**
* Constructor. The default number of data items is set to 0.
* <p>
* @param args The command line arguments to check
* @param prefix The prefix to use for all command line options. It can only be set here for all options at
* the same time
* @param defaultMultiplicity The default multiplicity to use for all options (can be overridden when adding an option)
* <p>
* @throws IllegalArgumentException If either <code>args</code>, <code>prefix</code>, or <code>defaultMultiplicity</code>
* is <code>null</code>
*/
public Options(String args[], Prefix prefix, Multiplicity defaultMultiplicity) {
this(args, prefix, defaultMultiplicity, 0, 0);
}
/**
* Constructor. The prefix is set to {@link Prefix#DASH}.
* <p>
* @param args The command line arguments to check
* @param defaultMultiplicity The default multiplicity to use for all options (can be overridden when adding an option)
* @param defMinData The default minimum number of data items for all sets (can be overridden when adding a set)
* @param defMaxData The default maximum number of data items for all sets (can be overridden when adding a set)
* <p>
* @throws IllegalArgumentException If either <code>args</code> or <code>defaultMultiplicity</code>
* is <code>null</code> - or if the data range values don't make sense
*/
public Options(String args[], Multiplicity defaultMultiplicity, int defMinData, int defMaxData) {
this(args, Prefix.DASH, defaultMultiplicity, defMinData, defMaxData);
}
/**
* Constructor. The prefix is set to {@link Prefix#DASH}.
* <p>
* @param args The command line arguments to check
* @param defaultMultiplicity The default multiplicity to use for all options (can be overridden when adding an option)
* @param data The default minimum and maximum number of data items for all sets (can be overridden when adding a set)
* <p>
* @throws IllegalArgumentException If either <code>args</code> or <code>defaultMultiplicity</code>
* is <code>null</code> - or if the data range value doesn't make sense
*/
public Options(String args[], Multiplicity defaultMultiplicity, int data) {
this(args, Prefix.DASH, defaultMultiplicity, data, data);
}
/**
* Constructor. The prefix is set to {@link Prefix#DASH}, and the default number of data items is set to 0.
* <p>
* @param args The command line arguments to check
* @param defaultMultiplicity The default multiplicity to use for all options (can be overridden when adding an option)
* <p>
* @throws IllegalArgumentException If either <code>args</code> or <code>defaultMultiplicity</code>
* is <code>null</code>
*/
public Options(String args[], Multiplicity defaultMultiplicity) {
this(args, Prefix.DASH, defaultMultiplicity, 0, 0);
}
/**
* Constructor. The prefix is set to {@link Prefix#DASH}, the default number of data items is set to 0, and
* the multiplicity is set to {@link Multiplicity#ONCE}.
* <p>
* @param args The command line arguments to check
* <p>
* @throws IllegalArgumentException If <code>args</code> is <code>null</code>
*/
public Options(String args[]) {
this(args, Prefix.DASH, Multiplicity.ONCE);
}
/**
* Constructor. The prefix is set to {@link Prefix#DASH}, and
* the multiplicity is set to {@link Multiplicity#ONCE}.
* <p>
* @param args The command line arguments to check
* @param data The default minimum and maximum number of data items for all sets (can be overridden when adding a set)
* <p>
* @throws IllegalArgumentException If <code>args</code> is <code>null</code> - or if the data range value doesn't make sense
*/
public Options(String args[], int data) {
this(args, Prefix.DASH, Multiplicity.ONCE, data, data);
}
/**
* Constructor. The prefix is set to {@link Prefix#DASH}, and
* the multiplicity is set to {@link Multiplicity#ONCE}.
* <p>
* @param args The command line arguments to check
* @param defMinData The default minimum number of data items for all sets (can be overridden when adding a set)
* @param defMaxData The default maximum number of data items for all sets (can be overridden when adding a set)
* <p>
* @throws IllegalArgumentException If <code>args</code> is <code>null</code> - or if the data range values don't make sense
*/
public Options(String args[], int defMinData, int defMaxData) {
this(args, Prefix.DASH, Multiplicity.ONCE, defMinData, defMaxData);
}
/**
* Constructor. The default number of data items is set to 0, and
* the multiplicity is set to {@link Multiplicity#ONCE}.
* <p>
* @param args The command line arguments to check
* @param prefix The prefix to use for all command line options. It can only be set here for all options at
* the same time
* <p>
* @throws IllegalArgumentException If either <code>args</code> or <code>prefix</code> is <code>null</code>
*/
public Options(String args[], Prefix prefix) {
this(args, prefix, Multiplicity.ONCE, 0, 0);
}
/**
* Constructor. The multiplicity is set to {@link Multiplicity#ONCE}.
* <p>
* @param args The command line arguments to check
* @param prefix The prefix to use for all command line options. It can only be set here for all options at
* @param data The default minimum and maximum number of data items for all sets (can be overridden when adding a set)
* <p>
* @throws IllegalArgumentException If either <code>args</code> or <code>prefix</code> is <code>null</code>
* - or if the data range value doesn't make sense
*/
public Options(String args[], Prefix prefix, int data) {
this(args, prefix, Multiplicity.ONCE, data, data);
}
/**
* Constructor. The multiplicity is set to {@link Multiplicity#ONCE}.
* <p>
* @param args The command line arguments to check
* @param prefix The prefix to use for all command line options. It can only be set here for all options at
* the same time
* @param defMinData The default minimum number of data items for all sets (can be overridden when adding a set)
* @param defMaxData The default maximum number of data items for all sets (can be overridden when adding a set)
* <p>
* @throws IllegalArgumentException If either <code>args</code> or <code>prefix</code> is <code>null</code>
* - or if the data range values don't make sense
*/
public Options(String args[], Prefix prefix, int defMinData, int defMaxData) {
this(args, prefix, Multiplicity.ONCE, defMinData, defMaxData);
}
/**
* Return the (first) matching set. This invocation does not ignore unmatched options and requires that
* data items are the last ones on the command line.
* <p>
* @return The first set which matches (i. e. the <code>check()</code> method returns <code>true</code>) - or
* <code>null</code>, if no set matches.
*/
public OptionSet getMatchingSet() {
return getMatchingSet(false, true);
}
/**
* Return the (first) matching set.
* <p>
* @param ignoreUnmatched A boolean to select whether unmatched options can be ignored in the checks or not
* @param requireDataLast A boolean to indicate whether the data items have to be the last ones on the command line or not
* <p>
* @return The first set which matches (i. e. the <code>check()</code> method returns <code>true</code>) - or
* <code>null</code>, if no set matches.
*/
public OptionSet getMatchingSet(boolean ignoreUnmatched, boolean requireDataLast) {
for (String setName : optionSets.keySet())
if (check(setName, ignoreUnmatched, requireDataLast))
return optionSets.get(setName);
return null;
}
/**
* Add an option set.
* <p>
* @param setName The name for the set. This must be a unique identifier
* @param minData The minimum number of data items for this set
* @param maxData The maximum number of data items for this set
* <p>
* @return The new <code>Optionset</code> instance created. This is useful to allow chaining of <code>addOption()</code>
* calls right after this method
*/
public OptionSet addSet(String setName, int minData, int maxData) {
if (setName == null) throw new IllegalArgumentException(CLASS + ": setName may not be null");
if (optionSets.containsKey(setName)) throw new IllegalArgumentException(CLASS + ": a set with the name "
+ setName + " has already been defined");
OptionSet os = new OptionSet(prefix, defaultMultiplicity, setName, minData, maxData);
optionSets.put(setName, os);
return os;
}
/**
* Add an option set.
* <p>
* @param setName The name for the set. This must be a unique identifier
* @param data The minimum and maximum number of data items for this set
* <p>
* @return The new <code>Optionset</code> instance created. This is useful to allow chaining of <code>addOption()</code>
* calls right after this method
*/
public OptionSet addSet(String setName, int data) {
return addSet(setName, data, data);
}
/**
* Add an option set. The defaults for the number of data items are used.
* <p>
* @param setName The name for the set. This must be a unique identifier
* <p>
* @return The new <code>Optionset</code> instance created. This is useful to allow chaining of <code>addOption()</code>
* calls right after this method
*/
public OptionSet addSet(String setName) {
return addSet(setName, defaultMinData, defaultMaxData);
}
/**
* Return an option set - or <code>null</code>, if no set with the given name exists
* <p>
* @param setName The name for the set to retrieve
* <p>
* @return The set to retrieve (or <code>null</code>, if no set with the given name exists)
*/
public OptionSet getSet(String setName) {
return optionSets.get(setName);
}
/**
* This returns the (anonymous) default set
* <p>
* @return The default set
*/
public OptionSet getSet() {
if (getSet(DEFAULT_SET) == null)
addSet(DEFAULT_SET, defaultMinData, defaultMaxData);
return getSet(DEFAULT_SET);
}
/**
* The error messages collected during the last option check (invocation of any of the <code>check()</code> methods). This
* is useful to determine what was wrong with the command line arguments provided
* <p>
* @return A string with all collected error messages
*/
public String getCheckErrors() {
return checkErrors.toString();
}
/**
* Run the checks for the default set. <code>ignoreUnmatched</code> is set to <code>false</code>, and
* <code>requireDataLast</code> is set to <code>true</code>.
* <p>
* @return A boolean indicating whether all checks were successful or not
*/
public boolean check() {
return check(DEFAULT_SET, false, true);
}
/**
* Run the checks for the default set.
* <p>
* @param ignoreUnmatched A boolean to select whether unmatched options can be ignored in the checks or not
* @param requireDataLast A boolean to indicate whether the data items have to be the last ones on the command line or not
* <p>
* @return A boolean indicating whether all checks were successful or not
*/
public boolean check(boolean ignoreUnmatched, boolean requireDataLast) {
return check(DEFAULT_SET, ignoreUnmatched, requireDataLast);
}
/**
* Run the checks for the given set. <code>ignoreUnmatched</code> is set to <code>false</code>, and
* <code>requireDataLast</code> is set to <code>true</code>.
* <p>
* @param setName The name for the set to check
* <p>
* @return A boolean indicating whether all checks were successful or not
* <p>
* @throws IllegalArgumentException If either <code>setName</code> is <code>null</code>, or the set is unknown.
*/
public boolean check(String setName) {
return check(setName, false, true);
}
/**
* Run the checks for the given set.
* <p>
* @param setName The name for the set to check
* @param ignoreUnmatched A boolean to select whether unmatched options can be ignored in the checks or not
* @param requireDataLast A boolean to indicate whether the data items have to be the last ones on the command line or not
* <p>
* @return A boolean indicating whether all checks were successful or not
* <p>
* @throws IllegalArgumentException If either <code>setName</code> is <code>null</code>, or the set is unknown.
*/
public boolean check(String setName, boolean ignoreUnmatched, boolean requireDataLast) {
if (setName == null) throw new IllegalArgumentException(CLASS + ": setName may not be null");
if (optionSets.get(setName) == null) throw new IllegalArgumentException(CLASS + ": Unknown OptionSet: " + setName);
checkErrors = new StringBuffer();
checkErrors.append("Checking set ");
checkErrors.append(setName);
checkErrors.append('\n');
//.... Access the data for the set to use
OptionSet set = optionSets.get(setName);
java.util.ArrayList<OptionData> options = set.getOptionData();
java.util.ArrayList<String> data = set.getData();
java.util.ArrayList<String> unmatched = set.getUnmatched();
//.... Catch some trivial cases
if (options.size() == 0) { // No options have been defined at all
if (arguments.length == 0) { // No arguments have been given: in this case, this is a success
return true;
} else {
checkErrors.append("No options have been defined, nothing to check\n");
return false;
}
} else if (arguments.length == 0) { // Options have been defined, but no arguments given
checkErrors.append("Options have been defined, but no arguments have been given; nothing to check\n");
return false;
}
//.... Parse all the arguments given
int ipos = 0;
int offset = 0;
java.util.regex.Matcher m = null;
String value = null;
String detail = null;
String next = null;
String key = null;
String pre = Character.toString(prefix.getName());
boolean add = true;
boolean[] matched = new boolean[arguments.length];
for (int i = 0; i < matched.length; i++) // Initially, we assume there was no match at all
matched[i] = false;
while (true) {
value = null;
detail = null;
offset = 0;
add = true;
key = arguments[ipos];
for (OptionData optionData : options) { // For each argument, we may need to check all defined options
m = optionData.getPattern().matcher(key);
if (m.lookingAt()) {
if (optionData.useValue()) { // The code section for value options
if (optionData.useDetail()) {
detail = m.group(1);
offset = 2; // required for correct Matcher.group access below
}
if (optionData.getSeparator() == Separator.BLANK) { // In this case, the next argument must be the value
if (ipos + 1 == arguments.length) { // The last argument, thus no value follows it: Error
checkErrors.append("At end of arguments - no value found following argument ");
checkErrors.append(key);
checkErrors.append('\n');
add = false;
} else {
next = arguments[ipos + 1];
if (next.startsWith(pre)) { // The next one is an argument, not a value: Error
checkErrors.append("No value found following argument ");
checkErrors.append(key);
checkErrors.append('\n');
add = false;
} else {
value = next;
matched[ipos++] = true; // Mark the key and the value
matched[ipos] = true;
}
}
} else { // The value follows the separator in this case
value = m.group(1 + offset);
matched[ipos] = true;
}
} else { // Simple, non-value options
matched[ipos] = true;
}
if (add) optionData.addResult(value, detail); // Store the result
break; // No need to check more options, we have a match
}
}
ipos++; // Advance to the next argument to check
if (ipos >= arguments.length) break; // Terminating condition for the check loop
}
//.... Identify unmatched arguments and actual (non-option) data
int first = -1; // Required later for requireDataLast
for (int i = 0; i < matched.length; i++) { // Assemble the list of unmatched options
if (!matched[i]) {
if (arguments[i].startsWith(pre)) { // This is an unmatched option
unmatched.add(arguments[i]);
checkErrors.append("No matching option found for argument ");
checkErrors.append(arguments[i]);
checkErrors.append('\n');
} else { // This is actual data
if (first < 0) first = i;
data.add(arguments[i]);
}
}
}
//.... Checks to determine overall success; start with multiplicity of options
boolean err = true;
for (OptionData optionData : options) {
key = optionData.getKey();
err = false; // Local check result for one option
switch (optionData.getMultiplicity()) {
case ONCE: if (optionData.getResultCount() != 1) err = true; break;
case ONCE_OR_MORE: if (optionData.getResultCount() == 0) err = true; break;
case ZERO_OR_ONE: if (optionData.getResultCount() > 1) err = true; break;
case ZERO_OR_MORE: break;
}
if (err) {
checkErrors.append("Wrong number of occurences found for argument ");
checkErrors.append(prefix.getName());
checkErrors.append(key);
checkErrors.append('\n');
return false;
}
}
//.... Check range for data
if (data.size() < set.getMinData() || data.size() > set.getMaxData()) {
checkErrors.append("Invalid number of data arguments: ");
checkErrors.append(data.size());
checkErrors.append(" (allowed range: ");
checkErrors.append(set.getMinData());
checkErrors.append(" ... ");
checkErrors.append(set.getMaxData());
checkErrors.append(")\n");
return false;
}
//.... Check for location of the data in the list of command line arguments
if (requireDataLast) {
if (first + data.size() != arguments.length) {
checkErrors.append("Invalid data specification: data arguments are not the last ones on the command line\n");
return false;
}
}
//.... Check for unmatched arguments
if (!ignoreUnmatched && unmatched.size() > 0) return false; // Don't accept unmatched arguments
//.... If we made it to here, all checks were successful
return true;
}
/**
* Add the given non-value option to <i>all</i> known sets.
* See {@link OptionSet#addOption(String)} for details.
*/
public void addOptionAllSets(String key) {
for (String setName : optionSets.keySet())
optionSets.get(setName).addOption(key, defaultMultiplicity);
}
/**
* Add the given non-value option to <i>all</i> known sets.
* See {@link OptionSet#addOption(String, Options.Multiplicity)} for details.
*/
public void addOptionAllSets(String key, Multiplicity multiplicity) {
for (String setName : optionSets.keySet())
optionSets.get(setName).addOption(key, false, Separator.NONE, false, multiplicity);
}
/**
* Add the given value option to <i>all</i> known sets.
* See {@link OptionSet#addOption(String, Options.Separator)} for details.
*/
public void addOptionAllSets(String key, Separator separator) {
for (String setName : optionSets.keySet())
optionSets.get(setName).addOption(key, false, separator, true, defaultMultiplicity);
}
/**
* Add the given value option to <i>all</i> known sets.
* See {@link OptionSet#addOption(String, Options.Separator, Options.Multiplicity)} for details.
*/
public void addOptionAllSets(String key, Separator separator, Multiplicity multiplicity) {
for (String setName : optionSets.keySet())
optionSets.get(setName).addOption(key, false, separator, true, multiplicity);
}
/**
* Add the given value option to <i>all</i> known sets.
* See {@link OptionSet#addOption(String, boolean, Options.Separator)} for details.
*/
public void addOptionAllSets(String key, boolean details, Separator separator) {
for (String setName : optionSets.keySet())
optionSets.get(setName).addOption(key, details, separator, true, defaultMultiplicity);
}
/**
* Add the given value option to <i>all</i> known sets.
* See {@link OptionSet#addOption(String, boolean, Options.Separator, Options.Multiplicity)} for details.
*/
public void addOptionAllSets(String key, boolean details, Separator separator, Multiplicity multiplicity) {
for (String setName : optionSets.keySet())
optionSets.get(setName).addOption(key, details, separator, true, multiplicity);
}
/**
* This is the overloaded {@link Object#toString()} method, and it is provided mainly for debugging
* purposes.
* <p>
* @return A string representing the instance
*/
public String toString() {
StringBuffer sb = new StringBuffer();
for (OptionSet set : optionSets.values()) {
sb.append("Set: ");
sb.append(set.getSetName());
sb.append('\n');
for (OptionData data : set.getOptionData()) {
sb.append(data.toString());
sb.append('\n');
}
}
return sb.toString();
}
}

View File

@ -133,7 +133,7 @@ public class AboutDialog extends Dialog {
// links are activated on mouse down when the control key is held down // links are activated on mouse down when the control key is held down
// if ((event.stateMask & SWT.MOD1) != 0) { // if ((event.stateMask & SWT.MOD1) != 0) {
try { try {
int offset = ((StyledText)event.widget).getOffsetAtLocation(new Point (event.x, event.y)); int offset = ((StyledText)event.widget).getOffsetAtPoint(new Point (event.x, event.y));
StyleRange style = ((StyledText)event.widget).getStyleRangeAtOffset(offset); StyleRange style = ((StyledText)event.widget).getStyleRangeAtOffset(offset);
if (style != null && style.underline && style.underlineStyle == SWT.UNDERLINE_LINK) { if (style != null && style.underline && style.underlineStyle == SWT.UNDERLINE_LINK) {
Desktop.getDesktop().browse(new java.net.URI(style.data.toString())); Desktop.getDesktop().browse(new java.net.URI(style.data.toString()));

View File

@ -55,6 +55,7 @@ import org.eclipse.swt.widgets.Tree;
import com.minres.scviewer.database.ITx; import com.minres.scviewer.database.ITx;
import com.minres.scviewer.database.ITxAttribute; import com.minres.scviewer.database.ITxAttribute;
import com.minres.scviewer.database.ITxRelation; import com.minres.scviewer.database.ITxRelation;
import com.minres.scviewer.database.DataType;
import com.minres.scviewer.e4.application.Messages; import com.minres.scviewer.e4.application.Messages;
import com.minres.scviewer.e4.application.provider.TxPropertiesLabelProvider; import com.minres.scviewer.e4.application.provider.TxPropertiesLabelProvider;
@ -579,7 +580,13 @@ PROPS, /** The attrs. */
default: default:
if (element instanceof ITxAttribute) { if (element instanceof ITxAttribute) {
ITxAttribute attribute = (ITxAttribute) element; ITxAttribute attribute = (ITxAttribute) element;
return new StyledString(attribute.getValue().toString()); String value = attribute.getValue().toString();
if((DataType.UNSIGNED == attribute.getDataType() || DataType.INTEGER==attribute.getDataType()) && !"0".equals(value)) {
try {
value = attribute.getValue().toString() + " [0x"+Long.toHexString(Long.parseLong(attribute.getValue().toString()))+"]";
} catch(NumberFormatException e) { }
}
return new StyledString(value);
}else if(element instanceof Object[]){ }else if(element instanceof Object[]){
Object[] elements = (Object[]) element; Object[] elements = (Object[]) element;
return new StyledString(elements[field].toString()); return new StyledString(elements[field].toString());

View File

@ -14,10 +14,12 @@ import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener; import java.beans.PropertyChangeListener;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -55,9 +57,17 @@ import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseTrackListener;
import org.eclipse.swt.events.MouseWheelListener;
import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import com.minres.scviewer.database.ITx; import com.minres.scviewer.database.ITx;
import com.minres.scviewer.database.ITxRelation; import com.minres.scviewer.database.ITxRelation;
@ -66,11 +76,14 @@ import com.minres.scviewer.database.IWaveformDb;
import com.minres.scviewer.database.IWaveformDbFactory; import com.minres.scviewer.database.IWaveformDbFactory;
import com.minres.scviewer.database.IWaveformEvent; import com.minres.scviewer.database.IWaveformEvent;
import com.minres.scviewer.database.RelationType; import com.minres.scviewer.database.RelationType;
import com.minres.scviewer.database.swt.Constants;
import com.minres.scviewer.database.swt.WaveformViewerFactory; import com.minres.scviewer.database.swt.WaveformViewerFactory;
import com.minres.scviewer.database.ui.GotoDirection; import com.minres.scviewer.database.ui.GotoDirection;
import com.minres.scviewer.database.ui.ICursor; import com.minres.scviewer.database.ui.ICursor;
import com.minres.scviewer.database.ui.IWaveformViewer; import com.minres.scviewer.database.ui.IWaveformViewer;
import com.minres.scviewer.database.ui.TrackEntry; import com.minres.scviewer.database.ui.TrackEntry;
import com.minres.scviewer.database.ui.TrackEntry.ValueDisplay;
import com.minres.scviewer.database.ui.TrackEntry.WaveDisplay;
import com.minres.scviewer.database.ui.WaveformColors; import com.minres.scviewer.database.ui.WaveformColors;
import com.minres.scviewer.e4.application.Messages; import com.minres.scviewer.e4.application.Messages;
import com.minres.scviewer.e4.application.internal.status.WaveStatusBarControl; import com.minres.scviewer.e4.application.internal.status.WaveStatusBarControl;
@ -98,6 +111,10 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
/** The Constant SHOWN_WAVEFORM. */ /** The Constant SHOWN_WAVEFORM. */
protected static final String SHOWN_WAVEFORM = "SHOWN_WAVEFORM"; //$NON-NLS-1$ protected static final String SHOWN_WAVEFORM = "SHOWN_WAVEFORM"; //$NON-NLS-1$
protected static final String VALUE_DISPLAY = ".VALUE_DISPLAY"; //$NON-NLS-1$
protected static final String WAVE_DISPLAY = ".WAVE_DISPLAY"; //$NON-NLS-1$
/** The Constant SHOWN_CURSOR. */ /** The Constant SHOWN_CURSOR. */
protected static final String SHOWN_CURSOR = "SHOWN_CURSOR"; //$NON-NLS-1$ protected static final String SHOWN_CURSOR = "SHOWN_CURSOR"; //$NON-NLS-1$
@ -137,7 +154,7 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
@Inject @Inject
ESelectionService selectionService; ESelectionService selectionService;
/** The e part service. */ /** The part service. */
@Inject @Inject
EPartService ePartService; EPartService ePartService;
@ -232,6 +249,102 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
selectionService.setSelection(event.getSelection()); selectionService.setSelection(event.getSelection());
} }
}); });
waveformPane.getWaveformControl().addMouseTrackListener(new MouseTrackListener() {
@Override
public void mouseHover(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mouseExit(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mouseEnter(MouseEvent e) {
// TODO Auto-generated method stub
}
});
waveformPane.getWaveformControl().addMouseWheelListener(new MouseWheelListener() {
@Override
public void mouseScrolled(MouseEvent e) {
// TODO Auto-generated method stub
}
});
waveformPane.getWaveformControl().addListener(SWT.KeyDown, new Listener() {
@SuppressWarnings("null")
@Override
public void handleEvent(Event e) {
if(e==null) { // dummy to take out logging
String string = e.type == SWT.KeyDown ? "DOWN:" : "UP :";
string += " stateMask=0x" + Integer.toHexString (e.stateMask) + ","; // SWT.CTRL, SWT.ALT, SWT.SHIFT, SWT.COMMAND
string += " keyCode=0x" + Integer.toHexString (e.keyCode) + ",";
string += " character=0x" + Integer.toHexString (e.character) ;
if (e.keyLocation != 0) {
string += " location="+e.keyLocation;
}
System.out.println (string);
}
if((e.stateMask&SWT.MOD3)!=0) { // Alt key
} else if((e.stateMask&SWT.MOD1)!=0) { //Ctrl/Cmd
int zoomlevel = waveformPane.getZoomLevel();
switch(e.keyCode) {
case '+':
case SWT.KEYPAD_ADD:
if(zoomlevel>0)
waveformPane.setZoomLevel(zoomlevel-1);
return;
case '-':
case SWT.KEYPAD_SUBTRACT:
if(zoomlevel<waveformPane.getZoomLevels().length-1)
waveformPane.setZoomLevel(zoomlevel+1);
return;
case SWT.ARROW_UP:
waveformPane.moveSelectedTrack(-1);
return;
case SWT.ARROW_DOWN:
waveformPane.moveSelectedTrack(1);
return;
}
} else if((e.stateMask&SWT.MOD2)!=0) { //Shift
switch(e.keyCode) {
case SWT.ARROW_LEFT:
waveformPane.scrollHorizontal(-100);
return;
case SWT.ARROW_RIGHT:
waveformPane.scrollHorizontal(100);
return;
}
} else {
switch(e.keyCode) {
case SWT.ARROW_LEFT:
waveformPane.scrollHorizontal(-10);
return;
case SWT.ARROW_RIGHT:
waveformPane.scrollHorizontal(10);
return;
case SWT.ARROW_UP:
waveformPane.moveSelection(GotoDirection.UP);
return;
case SWT.ARROW_DOWN:
waveformPane.moveSelection(GotoDirection.DOWN);
return;
case SWT.HOME: return; //TODO: should be handled
case SWT.END: return; //TODO: should be handled
}
}
}
});
zoomLevel = waveformPane.getZoomLevels(); zoomLevel = waveformPane.getZoomLevels();
setupColors(); setupColors();
checkForUpdates = prefs.getBoolean(PreferenceConstants.DATABASE_RELOAD, true); checkForUpdates = prefs.getBoolean(PreferenceConstants.DATABASE_RELOAD, true);
@ -245,10 +358,12 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
if (filesToLoad.size() > 0) if (filesToLoad.size() > 0)
loadDatabase(persistedState); loadDatabase(persistedState);
eventBroker.post(WaveStatusBarControl.ZOOM_LEVEL, zoomLevel[waveformPane.getZoomLevel()]); eventBroker.post(WaveStatusBarControl.ZOOM_LEVEL, zoomLevel[waveformPane.getZoomLevel()]);
// menuService.registerContextMenu(waveformPane.getNameControl(),
// "com.minres.scviewer.e4.application.popupmenu.namecontext"); //$NON-NLS-1$
menuService.registerContextMenu(waveformPane.getNameControl(), menuService.registerContextMenu(waveformPane.getNameControl(),
"com.minres.scviewer.e4.application.popupmenu.namecontext"); //$NON-NLS-1$ "com.minres.scviewer.e4.application.popupmenu.wavecontext"); //$NON-NLS-1$
menuService.registerContextMenu(waveformPane.getValueControl(), menuService.registerContextMenu(waveformPane.getValueControl(),
"com.minres.scviewer.e4.application.popupmenu.namecontext"); //$NON-NLS-1$ "com.minres.scviewer.e4.application.popupmenu.wavecontext"); //$NON-NLS-1$
menuService.registerContextMenu(waveformPane.getWaveformControl(), menuService.registerContextMenu(waveformPane.getWaveformControl(),
"com.minres.scviewer.e4.application.popupmenu.wavecontext"); //$NON-NLS-1$ "com.minres.scviewer.e4.application.popupmenu.wavecontext"); //$NON-NLS-1$
ePartService.addPartListener(new PartListener() { ePartService.addPartListener(new PartListener() {
@ -380,7 +495,7 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
*/ */
@Inject @Inject
@Optional @Optional
public void setPartInput(@Named("input") Object partInput) { public void setPartInput(@Named("input") Object partInput, @Named("config") Object partConfig) {
if (partInput instanceof File) { if (partInput instanceof File) {
filesToLoad = new ArrayList<File>(); filesToLoad = new ArrayList<File>();
File file = (File) partInput; File file = (File) partInput;
@ -404,6 +519,9 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
} }
if (filesToLoad.size() > 0) if (filesToLoad.size() > 0)
loadDatabase(persistedState); loadDatabase(persistedState);
if(partConfig instanceof String) {
loadState((String) partConfig);
}
} }
} }
@ -412,7 +530,7 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
*/ */
@Focus @Focus
public void setFocus() { public void setFocus() {
myParent.setFocus(); waveformPane.getWaveformControl().setFocus();
} }
/** /**
@ -459,12 +577,13 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
FileInputStream in = new FileInputStream(fileName); FileInputStream in = new FileInputStream(fileName);
props.load(in); props.load(in);
in.close(); in.close();
@SuppressWarnings({ "unchecked", "rawtypes" })
HashMap<String, String> propMap = new HashMap<String, String>((Map) props);
restoreWaveformViewerState(propMap);
} catch(FileNotFoundException e) {
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
@SuppressWarnings({ "unchecked", "rawtypes" })
HashMap<String, String> propMap = new HashMap<String, String>((Map) props);
restoreWaveformViewerState(propMap);
} }
/** /**
@ -478,6 +597,8 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
index = 0; index = 0;
for (TrackEntry trackEntry : waveformPane.getStreamList()) { for (TrackEntry trackEntry : waveformPane.getStreamList()) {
persistedState.put(SHOWN_WAVEFORM + index, trackEntry.waveform.getFullName()); persistedState.put(SHOWN_WAVEFORM + index, trackEntry.waveform.getFullName());
persistedState.put(SHOWN_WAVEFORM + index + VALUE_DISPLAY, trackEntry.valueDisplay.toString());
persistedState.put(SHOWN_WAVEFORM + index + WAVE_DISPLAY, trackEntry.waveDisplay.toString());
index++; index++;
} }
List<ICursor> cursors = waveformPane.getCursorList(); List<ICursor> cursors = waveformPane.getCursorList();
@ -501,8 +622,16 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
List<TrackEntry> res = new LinkedList<>(); List<TrackEntry> res = new LinkedList<>();
for (int i = 0; i < waves; i++) { for (int i = 0; i < waves; i++) {
IWaveform<? extends IWaveformEvent> waveform = database.getStreamByName(state.get(SHOWN_WAVEFORM + i)); IWaveform<? extends IWaveformEvent> waveform = database.getStreamByName(state.get(SHOWN_WAVEFORM + i));
if (waveform != null) if (waveform != null) {
res.add(new TrackEntry(waveform)); TrackEntry t = new TrackEntry(waveform);
res.add(t);
String v = state.get(SHOWN_WAVEFORM + i + VALUE_DISPLAY);
if(v!=null)
t.valueDisplay=ValueDisplay.valueOf(v);
String s = state.get(SHOWN_WAVEFORM + i + WAVE_DISPLAY);
if(s!=null)
t.waveDisplay=WaveDisplay.valueOf(s);
}
} }
if (res.size() > 0) if (res.size() > 0)
waveformPane.getStreamList().addAll(res); waveformPane.getStreamList().addAll(res);
@ -658,6 +787,7 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
index++; index++;
waveformPane.getStreamList().addAll(index, streams); waveformPane.getStreamList().addAll(index, streams);
} }
setFocus();
} }
/** /**
@ -667,7 +797,24 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
*/ */
public void removeStreamFromList(IWaveform<? extends IWaveformEvent> stream) { public void removeStreamFromList(IWaveform<? extends IWaveformEvent> stream) {
TrackEntry trackEntry = waveformPane.getEntryForStream(stream); TrackEntry trackEntry = waveformPane.getEntryForStream(stream);
waveformPane.getStreamList().remove(trackEntry); List<TrackEntry> streams = waveformPane.getStreamList();
ISelection sel = waveformPane.getSelection();
TrackEntry newSelection=null;
if(sel instanceof IStructuredSelection && ((IStructuredSelection) sel).size()==2) {
Iterator<?> it = ((IStructuredSelection)sel).iterator();
it.next();
int idx = streams.indexOf(it.next());
if(idx==streams.size()-1)
newSelection=streams.get(idx-1);
else
newSelection=streams.get(idx+1);
}
waveformPane.setSelection(new StructuredSelection());
streams.remove(trackEntry);
if(newSelection!=null) {
Object[] o = {newSelection};
waveformPane.setSelection(new StructuredSelection(o));
}
} }
/** /**
@ -724,6 +871,7 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
* @param level the new zoom level * @param level the new zoom level
*/ */
public void setZoomLevel(Integer level) { public void setZoomLevel(Integer level) {
//System.out.println("setZoomLevel() - ZoomLevel: " + level);
if (level < 0) if (level < 0)
level = 0; level = 0;
if (level > zoomLevel.length - 1) if (level > zoomLevel.length - 1)
@ -736,7 +884,28 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
* Sets the zoom fit. * Sets the zoom fit.
*/ */
public void setZoomFit() { public void setZoomFit() {
waveformPane.setZoomLevel(6);
//actual max time of signal
long maxTime = waveformPane.getMaxTime();
//get area actually capable of displaying data, i.e. area of the receiver which is capable of displaying data
Rectangle clientArea = myParent.getClientArea();
long clientAreaWidth = clientArea.width;
boolean foundZoom=false;
//try to find existing zoomlevel where scaleFactor*clientAreaWidth >= maxTime, if one is found set it as new zoomlevel
for (int level=0; level<Constants.unitMultiplier.length*Constants.unitString.length; level++){
long scaleFactor = (long) Math.pow(10, level/2);
if(level%2==1) scaleFactor*=3;
if(scaleFactor*clientAreaWidth >= maxTime) {
setZoomLevel(level);
foundZoom=true;
break;
}
}
//if no zoom level is found, set biggest one available
if(!foundZoom) setZoomLevel(Constants.unitMultiplier.length*Constants.unitString.length-1);
updateAll(); updateAll();
} }
@ -878,5 +1047,9 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
if(navigationRelationType!=relationType) waveformPane.setHighliteRelation(relationType); if(navigationRelationType!=relationType) waveformPane.setHighliteRelation(relationType);
navigationRelationType=relationType; navigationRelationType=relationType;
} }
public void update() {
waveformPane.update();
}
} }

View File

@ -41,12 +41,15 @@ public class DefaultValuesInitializer extends AbstractPreferenceInitializer {
colors[WaveformColors.TX_BG.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GREEN); colors[WaveformColors.TX_BG.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GREEN);
colors[WaveformColors.TX_BG_HIGHLITE.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_GREEN); colors[WaveformColors.TX_BG_HIGHLITE.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_GREEN);
colors[WaveformColors.TX_BORDER.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED); colors[WaveformColors.TX_BORDER.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED);
colors[WaveformColors.SIGNAL0.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_GREEN); colors[WaveformColors.SIGNAL0.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GREEN);
colors[WaveformColors.SIGNAL1.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_GREEN); colors[WaveformColors.SIGNAL1.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GREEN);
colors[WaveformColors.SIGNALZ.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_YELLOW); colors[WaveformColors.SIGNALZ.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_YELLOW);
colors[WaveformColors.SIGNALX.ordinal()] = SWTResourceManager.getColor(255, 51, 51); colors[WaveformColors.SIGNALX.ordinal()] = SWTResourceManager.getColor(255, 51, 51);
colors[WaveformColors.SIGNALU.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_YELLOW); colors[WaveformColors.SIGNALU.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_YELLOW);
colors[WaveformColors.SIGNAL_REAL.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_YELLOW);
colors[WaveformColors.SIGNAL_NAN.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED);
colors[WaveformColors.SIGNAL_TEXT.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_WHITE); colors[WaveformColors.SIGNAL_TEXT.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_WHITE);
colors[WaveformColors.SIGNAL_REAL.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_YELLOW);
colors[WaveformColors.CURSOR.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED); colors[WaveformColors.CURSOR.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED);
colors[WaveformColors.CURSOR_DRAG.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GRAY); colors[WaveformColors.CURSOR_DRAG.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GRAY);
colors[WaveformColors.CURSOR_TEXT.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_WHITE); colors[WaveformColors.CURSOR_TEXT.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_WHITE);

View File

@ -20,7 +20,7 @@ import org.eclipse.wb.swt.ResourceManager;
import com.minres.scviewer.database.IHierNode; import com.minres.scviewer.database.IHierNode;
import com.minres.scviewer.database.ISignal; import com.minres.scviewer.database.ISignal;
import com.minres.scviewer.database.ISignalChangeMulti; import com.minres.scviewer.database.ISignalChangeBitVector;
import com.minres.scviewer.database.ITxStream; import com.minres.scviewer.database.ITxStream;
import com.minres.scviewer.database.IWaveformDb; import com.minres.scviewer.database.IWaveformDb;
import com.minres.scviewer.e4.application.parts.LoadingWaveformDb; import com.minres.scviewer.e4.application.parts.LoadingWaveformDb;
@ -101,7 +101,7 @@ public class TxDbLabelProvider implements ILabelProvider {
return stream; return stream;
}else if(element instanceof ISignal<?>){ }else if(element instanceof ISignal<?>){
Object o = ((ISignal<?>)element).getEvents().firstEntry().getValue(); Object o = ((ISignal<?>)element).getEvents().firstEntry().getValue();
if(o instanceof ISignalChangeMulti) if(o instanceof ISignalChangeBitVector)
return wave; return wave;
else else
return signal; return signal;

View File

@ -147,15 +147,15 @@ public class ResourceManager extends SWTResourceManager {
CompositeImageDescriptor compositImageDesc = new CompositeImageDescriptor() { CompositeImageDescriptor compositImageDesc = new CompositeImageDescriptor() {
@Override @Override
protected void drawCompositeImage(int width, int height) { protected void drawCompositeImage(int width, int height) {
drawImage(baseImage.getImageData(), 0, 0); drawImage(createCachedImageDataProvider(baseImage), 0, 0);
if (corner == TOP_LEFT) { if (corner == TOP_LEFT) {
drawImage(decorator.getImageData(), 0, 0); drawImage(createCachedImageDataProvider(decorator), 0, 0);
} else if (corner == TOP_RIGHT) { } else if (corner == TOP_RIGHT) {
drawImage(decorator.getImageData(), bib.width - dib.width, 0); drawImage(createCachedImageDataProvider(decorator), bib.width - dib.width, 0);
} else if (corner == BOTTOM_LEFT) { } else if (corner == BOTTOM_LEFT) {
drawImage(decorator.getImageData(), 0, bib.height - dib.height); drawImage(createCachedImageDataProvider(decorator), 0, bib.height - dib.height);
} else if (corner == BOTTOM_RIGHT) { } else if (corner == BOTTOM_RIGHT) {
drawImage(decorator.getImageData(), bib.width - dib.width, bib.height - dib.height); drawImage(createCachedImageDataProvider(decorator), bib.width - dib.width, bib.height - dib.height);
} }
} }
@Override @Override

View File

@ -1,34 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.pde.ui.RuntimeWorkbench">
<booleanAttribute key="append.args" value="true"/>
<stringAttribute key="application" value="org.eclipse.e4.ui.workbench.swt.E4Application"/>
<booleanAttribute key="askclear" value="true"/>
<booleanAttribute key="automaticAdd" value="false"/>
<booleanAttribute key="automaticValidate" value="false"/>
<stringAttribute key="bootstrap" value=""/>
<stringAttribute key="checked" value="[NONE]"/>
<booleanAttribute key="clearConfig" value="false"/>
<booleanAttribute key="clearws" value="false"/>
<booleanAttribute key="clearwslog" value="false"/>
<stringAttribute key="configLocation" value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/SCViewer (restart)"/>
<booleanAttribute key="default" value="false"/>
<booleanAttribute key="includeOptional" value="true"/>
<stringAttribute key="location" value="${workspace_loc}/../runtime-com.minres.scviewer.e4.application.product"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/>
<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog -clearPersistedState -data @none"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms40m -Xmx4G -Xdock:icon=../Resources/Eclipse.icns -XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts"/>
<stringAttribute key="pde.version" value="3.3"/>
<stringAttribute key="product" value="com.minres.scviewer.e4.application.product"/>
<stringAttribute key="productFile" value="/com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.product"/>
<stringAttribute key="selected_target_plugins" value="com.google.guava@default:default,com.ibm.icu@default:default,javax.annotation@default:default,javax.inject@default:default,javax.servlet@default:default,javax.xml@default:default,org.apache.ant@default:default,org.apache.batik.css@default:default,org.apache.batik.util.gui@default:default,org.apache.batik.util@default:default,org.apache.commons.jxpath@default:default,org.apache.felix.gogo.command@default:default,org.apache.felix.gogo.runtime@default:default,org.codehaus.groovy@default:default,org.eclipse.ant.core@default:default,org.eclipse.core.commands@default:default,org.eclipse.core.contenttype@default:default,org.eclipse.core.databinding.observable@default:default,org.eclipse.core.databinding.property@default:default,org.eclipse.core.databinding@default:default,org.eclipse.core.expressions@default:default,org.eclipse.core.filesystem.macosx@default:false,org.eclipse.core.filesystem@default:default,org.eclipse.core.jobs@default:default,org.eclipse.core.resources@default:default,org.eclipse.core.runtime@default:true,org.eclipse.core.variables@default:default,org.eclipse.e4.core.commands@default:default,org.eclipse.e4.core.contexts@default:default,org.eclipse.e4.core.di.annotations@default:default,org.eclipse.e4.core.di.extensions@default:default,org.eclipse.e4.core.di@default:default,org.eclipse.e4.core.services@default:default,org.eclipse.e4.emf.xpath@default:default,org.eclipse.e4.ui.bindings@default:default,org.eclipse.e4.ui.css.core@default:default,org.eclipse.e4.ui.css.swt.theme@default:default,org.eclipse.e4.ui.css.swt@default:default,org.eclipse.e4.ui.di@default:default,org.eclipse.e4.ui.model.workbench@default:default,org.eclipse.e4.ui.services@default:default,org.eclipse.e4.ui.widgets@default:default,org.eclipse.e4.ui.workbench.addons.swt@default:default,org.eclipse.e4.ui.workbench.renderers.swt.cocoa@default:false,org.eclipse.e4.ui.workbench.renderers.swt@default:default,org.eclipse.e4.ui.workbench.swt@default:default,org.eclipse.e4.ui.workbench3@default:default,org.eclipse.e4.ui.workbench@default:default,org.eclipse.emf.common@default:default,org.eclipse.emf.ecore.change@default:default,org.eclipse.emf.ecore.xmi@default:default,org.eclipse.emf.ecore@default:default,org.eclipse.equinox.app@default:default,org.eclipse.equinox.bidi@default:default,org.eclipse.equinox.common@2:true,org.eclipse.equinox.ds@1:true,org.eclipse.equinox.event@default:default,org.eclipse.equinox.preferences@default:default,org.eclipse.equinox.registry@default:default,org.eclipse.equinox.util@default:default,org.eclipse.jface.databinding@default:default,org.eclipse.jface@default:default,org.eclipse.osgi.compatibility.state@default:false,org.eclipse.osgi.services@default:default,org.eclipse.osgi@-1:true,org.eclipse.swt.cocoa.macosx.x86_64@default:false,org.eclipse.swt@default:default,org.hamcrest.core@default:default,org.junit@default:default,org.w3c.css.sac@default:default,org.w3c.dom.events@default:default,org.w3c.dom.smil@default:default,org.w3c.dom.svg@default:default"/>
<stringAttribute key="selected_workspace_plugins" value="com.minres.scviewer.database.sqlite@default:default,com.minres.scviewer.database.text@default:default,com.minres.scviewer.database.ui.swt@default:default,com.minres.scviewer.database.ui@default:default,com.minres.scviewer.database.vcd@default:default,com.minres.scviewer.database@default:default,com.minres.scviewer.e4.application@default:default,com.opcoach.e4.preferences@default:default"/>
<booleanAttribute key="show_selected_only" value="false"/>
<booleanAttribute key="tracing" value="false"/>
<booleanAttribute key="useCustomFeatures" value="false"/>
<booleanAttribute key="useDefaultConfig" value="true"/>
<booleanAttribute key="useDefaultConfigArea" value="true"/>
<booleanAttribute key="useProduct" value="true"/>
<booleanAttribute key="usefeatures" value="false"/>
</launchConfiguration>

View File

@ -6,11 +6,10 @@
<parent> <parent>
<groupId>com.minres.scviewer</groupId> <groupId>com.minres.scviewer</groupId>
<artifactId>com.minres.scviewer.parent</artifactId> <artifactId>com.minres.scviewer.parent</artifactId>
<version>1.0.0-SNAPSHOT</version> <version>2.0.0-SNAPSHOT</version>
<relativePath>../com.minres.scviewer.parent</relativePath> <relativePath>../com.minres.scviewer.parent</relativePath>
</parent> </parent>
<artifactId>com.minres.scviewer.e4.product</artifactId> <artifactId>com.minres.scviewer.e4.product</artifactId>
<version>1.2.0-SNAPSHOT</version>
<packaging>eclipse-repository</packaging> <packaging>eclipse-repository</packaging>
<groupId>com.minres.scviewer</groupId> <groupId>com.minres.scviewer</groupId>
<build> <build>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<?pde version="3.5"?> <?pde version="3.5"?>
<product name="SCViewer" uid="scviewer" id="com.minres.scviewer.e4.application.product" application="org.eclipse.e4.ui.workbench.swt.E4Application" version="1.2.0.qualifier" useFeatures="false" includeLaunchers="true"> <product name="SCViewer" uid="scviewer" id="com.minres.scviewer.e4.application.product" application="org.eclipse.e4.ui.workbench.swt.E4Application" version="2.0.0.qualifier" useFeatures="false" includeLaunchers="true">
<configIni use="default"> <configIni use="default">
</configIni> </configIni>
@ -9,6 +9,8 @@
<launcherArgs> <launcherArgs>
<programArgs>-clearPersistedState -data @none <programArgs>-clearPersistedState -data @none
</programArgs> </programArgs>
<vmArgs>-Xmx2G
</vmArgs>
<vmArgsMac>-XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts <vmArgsMac>-XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts
</vmArgsMac> </vmArgsMac>
</launcherArgs> </launcherArgs>
@ -32,6 +34,9 @@
</launcher> </launcher>
<vm> <vm>
<linux include="false">org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8</linux>
<macos include="false">org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8</macos>
<windows include="false">org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8</windows>
</vm> </vm>
<license> <license>
@ -39,6 +44,7 @@
</license> </license>
<plugins> <plugins>
<plugin id="com.google.guava"/>
<plugin id="com.ibm.icu"/> <plugin id="com.ibm.icu"/>
<plugin id="com.minres.scviewer.database"/> <plugin id="com.minres.scviewer.database"/>
<plugin id="com.minres.scviewer.database.sqlite"/> <plugin id="com.minres.scviewer.database.sqlite"/>
@ -50,12 +56,16 @@
<plugin id="com.opcoach.e4.preferences"/> <plugin id="com.opcoach.e4.preferences"/>
<plugin id="javax.annotation"/> <plugin id="javax.annotation"/>
<plugin id="javax.inject"/> <plugin id="javax.inject"/>
<plugin id="javax.xml"/> <plugin id="org.apache.batik.constants"/>
<plugin id="org.apache.batik.css"/> <plugin id="org.apache.batik.css"/>
<plugin id="org.apache.batik.i18n"/>
<plugin id="org.apache.batik.util"/> <plugin id="org.apache.batik.util"/>
<plugin id="org.apache.batik.util.gui"/> <plugin id="org.apache.commons.io"/>
<plugin id="org.apache.commons.jxpath"/> <plugin id="org.apache.commons.jxpath"/>
<plugin id="org.apache.commons.logging"/> <plugin id="org.apache.commons.logging"/>
<plugin id="org.apache.felix.scr"/>
<plugin id="org.apache.xmlgraphics"/>
<plugin id="org.codehaus.groovy"/>
<plugin id="org.eclipse.core.commands"/> <plugin id="org.eclipse.core.commands"/>
<plugin id="org.eclipse.core.contenttype"/> <plugin id="org.eclipse.core.contenttype"/>
<plugin id="org.eclipse.core.databinding"/> <plugin id="org.eclipse.core.databinding"/>
@ -64,15 +74,19 @@
<plugin id="org.eclipse.core.databinding.property"/> <plugin id="org.eclipse.core.databinding.property"/>
<plugin id="org.eclipse.core.expressions"/> <plugin id="org.eclipse.core.expressions"/>
<plugin id="org.eclipse.core.filesystem"/> <plugin id="org.eclipse.core.filesystem"/>
<plugin id="org.eclipse.core.filesystem.linux.x86_64" fragment="true"/>
<plugin id="org.eclipse.core.filesystem.macosx" fragment="true"/> <plugin id="org.eclipse.core.filesystem.macosx" fragment="true"/>
<plugin id="org.eclipse.core.filesystem.win32.x86_64" fragment="true"/>
<plugin id="org.eclipse.core.jobs"/> <plugin id="org.eclipse.core.jobs"/>
<plugin id="org.eclipse.core.resources"/> <plugin id="org.eclipse.core.resources"/>
<plugin id="org.eclipse.core.resources.win32.x86_64" fragment="true"/>
<plugin id="org.eclipse.core.runtime"/> <plugin id="org.eclipse.core.runtime"/>
<plugin id="org.eclipse.e4.core.commands"/> <plugin id="org.eclipse.e4.core.commands"/>
<plugin id="org.eclipse.e4.core.contexts"/> <plugin id="org.eclipse.e4.core.contexts"/>
<plugin id="org.eclipse.e4.core.di"/> <plugin id="org.eclipse.e4.core.di"/>
<plugin id="org.eclipse.e4.core.di.annotations"/> <plugin id="org.eclipse.e4.core.di.annotations"/>
<plugin id="org.eclipse.e4.core.di.extensions"/> <plugin id="org.eclipse.e4.core.di.extensions"/>
<plugin id="org.eclipse.e4.core.di.extensions.supplier"/>
<plugin id="org.eclipse.e4.core.services"/> <plugin id="org.eclipse.e4.core.services"/>
<plugin id="org.eclipse.e4.emf.xpath"/> <plugin id="org.eclipse.e4.emf.xpath"/>
<plugin id="org.eclipse.e4.ui.bindings"/> <plugin id="org.eclipse.e4.ui.bindings"/>
@ -82,8 +96,10 @@
<plugin id="org.eclipse.e4.ui.di"/> <plugin id="org.eclipse.e4.ui.di"/>
<plugin id="org.eclipse.e4.ui.model.workbench"/> <plugin id="org.eclipse.e4.ui.model.workbench"/>
<plugin id="org.eclipse.e4.ui.services"/> <plugin id="org.eclipse.e4.ui.services"/>
<plugin id="org.eclipse.e4.ui.swt.gtk" fragment="true"/>
<plugin id="org.eclipse.e4.ui.widgets"/> <plugin id="org.eclipse.e4.ui.widgets"/>
<plugin id="org.eclipse.e4.ui.workbench"/> <plugin id="org.eclipse.e4.ui.workbench"/>
<plugin id="org.eclipse.e4.ui.workbench.addons.swt"/>
<plugin id="org.eclipse.e4.ui.workbench.renderers.swt"/> <plugin id="org.eclipse.e4.ui.workbench.renderers.swt"/>
<plugin id="org.eclipse.e4.ui.workbench.renderers.swt.cocoa" fragment="true"/> <plugin id="org.eclipse.e4.ui.workbench.renderers.swt.cocoa" fragment="true"/>
<plugin id="org.eclipse.e4.ui.workbench.swt"/> <plugin id="org.eclipse.e4.ui.workbench.swt"/>
@ -105,8 +121,12 @@
<plugin id="org.eclipse.osgi"/> <plugin id="org.eclipse.osgi"/>
<plugin id="org.eclipse.osgi.compatibility.state" fragment="true"/> <plugin id="org.eclipse.osgi.compatibility.state" fragment="true"/>
<plugin id="org.eclipse.osgi.services"/> <plugin id="org.eclipse.osgi.services"/>
<plugin id="org.eclipse.osgi.util"/>
<plugin id="org.eclipse.pde.ds.lib"/>
<plugin id="org.eclipse.swt"/> <plugin id="org.eclipse.swt"/>
<plugin id="org.eclipse.swt.cocoa.macosx.x86_64" fragment="true"/> <plugin id="org.eclipse.swt.cocoa.macosx.x86_64" fragment="true"/>
<plugin id="org.eclipse.swt.gtk.linux.x86_64" fragment="true"/>
<plugin id="org.eclipse.swt.win32.win32.x86_64" fragment="true"/>
<plugin id="org.w3c.css.sac"/> <plugin id="org.w3c.css.sac"/>
<plugin id="org.w3c.dom.events"/> <plugin id="org.w3c.dom.events"/>
<plugin id="org.w3c.dom.smil"/> <plugin id="org.w3c.dom.smil"/>

View File

@ -5,7 +5,8 @@
<parent> <parent>
<groupId>com.minres.scviewer</groupId> <groupId>com.minres.scviewer</groupId>
<artifactId>com.minres.scviewer.parent</artifactId> <artifactId>com.minres.scviewer.parent</artifactId>
<version>1.0.0-SNAPSHOT</version> <version>2.0.0-SNAPSHOT</version>
<relativePath>../com.minres.scviewer.parent</relativePath> <relativePath>../com.minres.scviewer.parent</relativePath>
</parent> </parent>
</project> <version>1.0.0-SNAPSHOT</version>
</project>

View File

@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>com.minres.scviewer</groupId> <groupId>com.minres.scviewer</groupId>
<artifactId>com.minres.scviewer.parent</artifactId> <artifactId>com.minres.scviewer.parent</artifactId>
<version>1.0.0-SNAPSHOT</version> <version>2.0.0-SNAPSHOT</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<modules> <modules>
<module>../com.minres.scviewer.target</module> <module>../com.minres.scviewer.target</module>
@ -34,12 +34,12 @@
<repository> <repository>
<id>mars</id> <id>mars</id>
<layout>p2</layout> <layout>p2</layout>
<url>http://download.eclipse.org/releases/neon</url> <url>http://download.eclipse.org/releases/photon</url>
</repository> </repository>
<repository> <repository>
<id>GRECLIPSE</id> <id>GRECLIPSE</id>
<layout>p2</layout> <layout>p2</layout>
<url>http://dist.springsource.org/snapshot/GRECLIPSE/e4.6</url> <url>http://dist.springsource.org/snapshot/GRECLIPSE/e4.8</url>
</repository> </repository>
</repositories> </repositories>

View File

@ -1,5 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <?xml version="1.0" encoding="UTF-8" standalone="no"?><?pde version="3.8"?><target name="Neon Platform" sequenceNumber="138">
<?pde version="3.8"?><target name="Neon Platform" sequenceNumber="138">
<locations> <locations>
<location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="true" type="InstallableUnit"> <location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="true" type="InstallableUnit">
<unit id="org.eclipse.equinox.executable.feature.group" version="3.6.300.v20161122-1740"/> <unit id="org.eclipse.equinox.executable.feature.group" version="3.6.300.v20161122-1740"/>
@ -9,7 +8,7 @@
<repository location="http://download.eclipse.org/releases/neon"/> <repository location="http://download.eclipse.org/releases/neon"/>
</location> </location>
<location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="true" type="InstallableUnit"> <location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="true" type="InstallableUnit">
<unit id="org.codehaus.groovy24.feature.feature.group" version="2.9.2.xx-201701211811-e46"/> <unit id="org.codehaus.groovy24.feature.feature.group" version="2.9.3.xx-201806261157-e46"/>
<repository location="http://dist.springsource.org/snapshot/GRECLIPSE/e4.6"/> <repository location="http://dist.springsource.org/snapshot/GRECLIPSE/e4.6"/>
</location> </location>
</locations> </locations>
@ -17,8 +16,7 @@
<arch>x86_64</arch> <arch>x86_64</arch>
<nl>de_DE</nl> <nl>de_DE</nl>
</environment> </environment>
<targetJRE path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.launching.macosx.MacOSXType/Java SE 7 [1.7.0_45]"/>
<launcherArgs> <launcherArgs>
<vmArgs>-Dosgi.requiredJavaVersion=1.6 -XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts -XX:MaxPermSize=256m -Xdock:icon=../Resources/Eclipse.icns -XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts -Xms40m -Xmx512m -Xdock:icon=../Resources/Eclipse.icns -XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts</vmArgs> <vmArgs>-Dosgi.requiredJavaVersion=1.7 -XX:MaxPermSize=256 -Xms40m -Xmx2G </vmArgs>
</launcherArgs> </launcherArgs>
</target> </target>

View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?><?pde version="3.8"?><target name="Photon Platform" sequenceNumber="138">
<locations>
<location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="true" type="InstallableUnit">
<unit id="org.eclipse.equinox.executable.feature.group" version="0.0.0"/>
<unit id="org.eclipse.platform.sdk" version="0.0.0"/>
<unit id="org.eclipse.sdk.feature.group" version="0.0.0"/>
<unit id="org.eclipse.rcp.sdk.id" version="0.0.0"/>
<unit id="org.eclipse.rcptt.core.feature.group" version="0.0.0"/>
<unit id="org.eclipse.e4.rcp.feature.group" version="0.0.0"/>
<unit id="org.eclipse.platform.feature.group" version="0.0.0"/>
<repository location="http://download.eclipse.org/releases/photon"/>
</location>
<location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="true" type="InstallableUnit">
<unit id="org.codehaus.groovy24.feature.feature.group" version="0.0.0"/>
<repository location="http://dist.springsource.org/snapshot/GRECLIPSE/e4.8/"/>
</location>
</locations>
<environment>
<arch>x86_64</arch>
<nl>de_DE</nl>
</environment>
<targetJRE path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.launching.macosx.MacOSXType/Java SE 7 [1.7.0_45]"/>
<launcherArgs>
<vmArgs>-Dosgi.requiredJavaVersion=1.6 -XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts -Xdock:icon=../Resources/Eclipse.icns -Xms40m -Xmx2G</vmArgs>
</launcherArgs>
</target>

View File

@ -4,7 +4,7 @@
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>neon</artifactId> <artifactId>photon</artifactId>
<packaging>eclipse-target-definition</packaging> <packaging>eclipse-target-definition</packaging>
<name>SCViewer Target Definition</name> <name>SCViewer Target Definition</name>
@ -12,7 +12,7 @@
<parent> <parent>
<groupId>com.minres.scviewer</groupId> <groupId>com.minres.scviewer</groupId>
<artifactId>com.minres.scviewer.parent</artifactId> <artifactId>com.minres.scviewer.parent</artifactId>
<version>1.0.0-SNAPSHOT</version> <version>2.0.0-SNAPSHOT</version>
<relativePath>../com.minres.scviewer.parent</relativePath> <relativePath>../com.minres.scviewer.parent</relativePath>
</parent> </parent>

View File

@ -1,2 +1,3 @@
eclipse.preferences.version=1 eclipse.preferences.version=1
groovy.compiler.level=23 groovy.compiler.level=26
groovy.script.filters=**/*.dsld,y,**/*.gradle,n

View File

@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2 Bundle-ManifestVersion: 2
Bundle-Name: SCViewer Bundle-Name: SCViewer
Bundle-SymbolicName: com.minres.scviewer.ui;singleton:=true Bundle-SymbolicName: com.minres.scviewer.ui;singleton:=true
Bundle-Version: 1.0.0.qualifier Bundle-Version: 1.0.1.qualifier
Bundle-Activator: com.minres.scviewer.ui.TxEditorPlugin Bundle-Activator: com.minres.scviewer.ui.TxEditorPlugin
Bundle-Vendor: MINRES Technologies GmbH Bundle-Vendor: MINRES Technologies GmbH
Require-Bundle: com.minres.scviewer.database;bundle-version="1.0.0", Require-Bundle: com.minres.scviewer.database;bundle-version="1.0.0",
@ -23,3 +23,4 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy Bundle-ActivationPolicy: lazy
Import-Package: com.google.common.collect Import-Package: com.google.common.collect
Service-Component: OSGI-INF/component.xml Service-Component: OSGI-INF/component.xml
Automatic-Module-Name: com.minres.scviewer.ui

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.ui"> <scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="com.minres.scviewer.ui">
<implementation class="com.minres.scviewer.ui.TxEditorPart"/> <implementation class="com.minres.scviewer.ui.TxEditorPart"/>
<reference bind="bind" cardinality="1..1" interface="com.minres.scviewer.database.IWaveformDbFactory" name="IWaveformDbFactory" policy="static" unbind="unbin"/> <reference bind="bind" cardinality="1..1" interface="com.minres.scviewer.database.IWaveformDbFactory" name="IWaveformDbFactory" policy="static" unbind="unbind"/>
</scr:component> </scr:component>

View File

@ -4,8 +4,9 @@
<parent> <parent>
<groupId>com.minres.scviewer</groupId> <groupId>com.minres.scviewer</groupId>
<artifactId>com.minres.scviewer.parent</artifactId> <artifactId>com.minres.scviewer.parent</artifactId>
<version>1.0.0-SNAPSHOT</version> <version>2.0.0-SNAPSHOT</version>
<relativePath>../com.minres.scviewer.parent</relativePath> <relativePath>../com.minres.scviewer.parent</relativePath>
</parent> </parent>
<packaging>eclipse-plugin</packaging> <packaging>eclipse-plugin</packaging>
</project> <version>1.0.1-SNAPSHOT</version>
</project>

View File

@ -347,12 +347,18 @@ public class TxEditorPart extends EditorPart implements ITabbedPropertySheetPage
addStreamToList(stream); addStreamToList(stream);
} }
public void removeStreamFromList(IWaveform<? extends IWaveformEvent> obj){ public void removeStreamFromList(IWaveform<? extends IWaveformEvent> waveform){
if(getEditorInput() instanceof TxEditorInput && ((TxEditorInput) getEditorInput()).getStreamNames().contains(obj.getFullName())){ if(getEditorInput() instanceof TxEditorInput && ((TxEditorInput) getEditorInput()).getStreamNames().contains(waveform.getFullName())){
((TxEditorInput) getEditorInput()).getStreamNames().remove(obj.getFullName()); ((TxEditorInput) getEditorInput()).getStreamNames().remove(waveform.getFullName());
txDisplay.getStreamList().remove(obj); }
} else TrackEntry entry=null;
txDisplay.getStreamList().remove(obj); for(TrackEntry e:txDisplay.getStreamList()) {
if(e.waveform==waveform) {
entry=e;
break;
}
}
txDisplay.getStreamList().remove(entry);
} }
public void removeStreamsFromList(IWaveform<? extends IWaveformEvent>[] iWaveforms){ public void removeStreamsFromList(IWaveform<? extends IWaveformEvent>[] iWaveforms){

View File

@ -44,6 +44,7 @@ import org.eclipse.ui.views.properties.tabbed.AbstractPropertySection;
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage; import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
import com.minres.scviewer.database.AssociationType; import com.minres.scviewer.database.AssociationType;
import com.minres.scviewer.database.DataType;
import com.minres.scviewer.database.ITxAttribute; import com.minres.scviewer.database.ITxAttribute;
import com.minres.scviewer.database.ITx; import com.minres.scviewer.database.ITx;
@ -199,12 +200,13 @@ public class AttributeProperty extends AbstractPropertySection implements ISelec
else if (columnIndex == 2 ) else if (columnIndex == 2 )
return attr.getDataType().name(); return attr.getDataType().name();
else if (columnIndex == 3){ else if (columnIndex == 3){
if("UNSIGNED".equals(attr.getType()) && (attr.getName().contains("addr")||attr.getName().contains("data"))) String value = attr.getValue().toString();
if((DataType.UNSIGNED == attr.getDataType() || DataType.INTEGER==attr.getDataType()) && !"0".equals(value)) {
try { try {
return "0x"+Long.toHexString(Long.parseLong(attr.getValue().toString())); value = attr.getValue().toString() + "(0x"+Long.toHexString(Long.parseLong(attr.getValue().toString()))+")";
} catch(NumberFormatException e) { } catch(NumberFormatException e) { }
} }
return attr.getValue().toString(); return value;
} }
} }
return null; return null;

View File

@ -6,7 +6,7 @@
<parent> <parent>
<groupId>com.minres.scviewer</groupId> <groupId>com.minres.scviewer</groupId>
<artifactId>com.minres.scviewer.parent</artifactId> <artifactId>com.minres.scviewer.parent</artifactId>
<version>1.0.0-SNAPSHOT</version> <version>2.0.0-SNAPSHOT</version>
<relativePath>../com.minres.scviewer.parent</relativePath> <relativePath>../com.minres.scviewer.parent</relativePath>
</parent> </parent>
<!-- <build> <!-- <build>

View File

@ -16,3 +16,4 @@ Require-Bundle: javax.inject,
Export-Package: com.opcoach.e4.preferences, Export-Package: com.opcoach.e4.preferences,
com.opcoach.e4.preferences.handlers com.opcoach.e4.preferences.handlers
Bundle-ActivationPolicy: lazy Bundle-ActivationPolicy: lazy
Automatic-Module-Name: com.opcoach.e4.preferences