Reworked UI & renamed plugins

This commit is contained in:
Eyck Jentzsch 2015-01-01 23:17:32 +01:00
parent 8dcfdf9b8d
commit 2054426bcf
144 changed files with 2335 additions and 2637 deletions

View File

@ -0,0 +1 @@
/bin

View File

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

View File

@ -5,9 +5,8 @@ Bundle-SymbolicName: com.itjw.txviewer.database.text
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: com.itjw.txviewer.database.text.Activator
Bundle-Vendor: ITJW
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Import-Package: com.itjw.txviewer.database,
org.osgi.framework;version="1.3.0"
Require-Bundle: com.itjw.txviewer.database;bundle-version="1.0.0",
org.codehaus.groovy;bundle-version="1.8.6",
org.eclipse.ui.views;bundle-version="3.6.0"
org.codehaus.groovy;bundle-version="1.8.6"

View File

@ -13,9 +13,12 @@ package com.itjw.txviewer.database.text;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;
import java.util.Dictionary
import java.util.Hashtable
import com.itjw.txviewer.database.ITrDb;
import com.itjw.txviewer.database.ITransactionDbFactory;
public class Activator implements BundleActivator {
@ -33,7 +36,7 @@ public class Activator implements BundleActivator {
Activator.context = bundleContext;
Dictionary<String, ?> dict = new Hashtable<String, ?>();
dict.putAt(Constants.SERVICE_RANKING, 1);
context.registerService(ITrDb.class, new TrTextDb(), dict);
context.registerService(ITransactionDbFactory.class, new TrTextDbFactory(), dict);
}
/*

View File

@ -14,14 +14,16 @@ import com.itjw.txviewer.database.ITrAttrType;
class TrAttrType implements ITrAttrType {
String name
String type
String dataType
ITrAttrType.AttributeType type
static TrAttrType getAttrType(String name, String type){
TrAttrTypeFactory.instance.getAttrType(name, type)
static TrAttrType getAttrType(String name, String dataType, ITrAttrType.AttributeType type){
TrAttrTypeFactory.instance.getAttrType(name, dataType, type)
}
TrAttrType(String name, String type){
TrAttrType(String name, String dataType, ITrAttrType.AttributeType type){
this.name=name
this.dataType=dataType
this.type=type
}
}

View File

@ -22,13 +22,13 @@ class TrAttrTypeFactory {
TrAttrTypeFactory.metaClass.constructor = {-> instance }
}
ITrAttrType getAttrType(String name, String type){
def key = name+":"+type
ITrAttrType getAttrType(String name, String dataType, ITrAttrType.AttributeType type){
def key = name+":"+dataType
ITrAttrType res
if(attributes.containsKey(key)){
res=attributes[key]
} else {
res=new TrAttrType(name, type)
res=new TrAttrType(name, dataType, type)
attributes[key]=res
}
return res

View File

@ -10,16 +10,18 @@
*******************************************************************************/
package com.itjw.txviewer.database.text
import com.itjw.txviewer.database.ITrAttrType;
import com.itjw.txviewer.database.ITrAttribute
class TrAttribute implements ITrAttribute{
TrAttrType attributeType
def value
TrAttribute(String name, String type, value){
attributeType = TrAttrTypeFactory.instance.getAttrType(name, type)
switch(type){
TrAttribute(String name, String dataType, ITrAttrType.AttributeType type, value){
attributeType = TrAttrTypeFactory.instance.getAttrType(name, dataType, type)
switch(dataType){
case "STRING":
case "ENUMERATION":
this.value=value[1..-2]
@ -34,7 +36,7 @@ class TrAttribute implements ITrAttribute{
}
TrAttribute(TrAttrType other, value){
this(other.name, other.type, value)
this(other.name, other.dataType, other.type, value)
}
@Override
@ -43,8 +45,13 @@ class TrAttribute implements ITrAttribute{
}
@Override
public String getType() {
public ITrAttrType.AttributeType getType() {
return attributeType.getType();
}
@Override
public String getDataType() {
return attributeType.getDataType();
}
}

View File

@ -0,0 +1,36 @@
package com.itjw.txviewer.database.text
import com.itjw.txviewer.database.ITrRelation
import com.itjw.txviewer.database.ITransaction;
import com.itjw.txviewer.database.RelationType;
class TrRelation implements ITrRelation {
Transaction source
Transaction target
RelationType relationType
public TrRelation(RelationType relationType, Transaction source, Transaction target) {
this.source = source;
this.target = target;
this.relationType = relationType;
}
@Override
public RelationType getRelationType() {
return relationType;
}
@Override
public ITransaction getSource() {
return source;
}
@Override
public ITransaction getTarget() {
return target;
}
}

View File

@ -21,19 +21,27 @@ import com.itjw.txviewer.database.ITrStream
import com.itjw.txviewer.database.ITransaction
class TrStream extends TrHierNode implements ITrStream {
Long id;
TrTextDb database
String name;
String fullName;
String kind;
def generators = [];
def childs = []
private allTransactions;
TrTextDb database
String name;
String fullName;
String kind;
def generators = [];
def childs = []
private allTransactions;
public TrHierNode(String name){
this.name=name
}
@Override
public List<ITrHierNode> getChildNodes() {
return childs.sort{it.name};
@ -63,11 +71,11 @@ class TrStream extends TrHierNode implements ITrStream {
getTransactions().each{Transaction tx ->
def rowIdx = 0
for(rowIdx=0; rowendtime.size()<rowIdx || rowendtime[rowIdx]>tx.beginTime.value; rowIdx++);
if(rowendtime.size<=rowIdx){
rowendtime<<tx.endTime?.value?:tx.beginTime.value+1
} else {
rowendtime[rowIdx]=tx.endTime?.value?:tx.beginTime.value+1
}
if(rowendtime.size<=rowIdx){
rowendtime<<tx.endTime?.value?:tx.beginTime.value+1
} else {
rowendtime[rowIdx]=tx.endTime?.value?:tx.beginTime.value+1
}
}
return rowendtime.size()
}
@ -78,5 +86,4 @@ class TrStream extends TrHierNode implements ITrStream {
allTransactions=generators.transactions.flatten().sort{it.beginTime.value}
return allTransactions
}
}

View File

@ -17,18 +17,23 @@ import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import com.itjw.txviewer.database.ITrAttrType;
import com.itjw.txviewer.database.ITrAttribute;
import com.itjw.txviewer.database.ITrDb;
import com.itjw.txviewer.database.ITrGenerator;
import com.itjw.txviewer.database.ITrHierNode;
import com.itjw.txviewer.database.ITrStream;
import com.itjw.txviewer.database.InputFormatException;
import com.itjw.txviewer.database.EventTime
import com.itjw.txviewer.database.RelationType
public class TrTextDb extends TrHierNode implements ITrDb{
private EventTime maxTime;
def streams = []
def childs = []
def relationTypes=[:]
public String getFullName() {
return getName();
@ -39,6 +44,10 @@ public class TrTextDb extends TrHierNode implements ITrDb{
return maxTime;
}
public ITrStream getStreamByName(String name){
streams.find{ITrStream stream-> stream.fullName == name }
}
public List<ITrStream> getAllStreams() {
return new LinkedList<ITrStream>(streams);
}
@ -90,14 +99,14 @@ public class TrTextDb extends TrHierNode implements ITrDb{
streamsById[id]=stream
} else if ((matcher = line =~ /^scv_tr_generator\s+\(ID\s+(\d+),\s+name\s+"([^"]+)",\s+scv_tr_stream\s+(\d+),$/)) {
def id = Integer.parseInt(matcher[0][1])
TrStream stream=streamsById[Integer.parseInt(matcher[0][3])]
ITrStream stream=streamsById[Integer.parseInt(matcher[0][3])]
generator=new TrGenerator(id, stream, matcher[0][2])
stream.generators<<generator
generatorsById[id]=generator
} else if ((matcher = line =~ /^begin_attribute \(ID (\d+), name "([^"]+)", type "([^"]+)"\)$/)) {
generator.begin_attrs << TrAttrType.getAttrType(matcher[0][2], matcher[0][3])
generator.begin_attrs << TrAttrType.getAttrType(matcher[0][2], matcher[0][3], ITrAttrType.AttributeType.BEGIN)
} else if ((matcher = line =~ /^end_attribute \(ID (\d+), name "([^"]+)", type "([^"]+)"\)$/)) {
generator.end_attrs << TrAttrType.getAttrType(matcher[0][2], matcher[0][3])
generator.end_attrs << TrAttrType.getAttrType(matcher[0][2], matcher[0][3], ITrAttrType.AttributeType.END)
}
break;
case ")":
@ -106,7 +115,7 @@ public class TrTextDb extends TrHierNode implements ITrDb{
case "tx_begin"://matcher = line =~ /^tx_begin\s+(\d+)\s+(\d+)\s+(\d+)\s+([munpf]?s)/
def id = Integer.parseInt(tokens[1])
TrGenerator gen=generatorsById[Integer.parseInt(tokens[2])]
transaction = new Transaction(id, gen,new EventTime(Integer.parseInt(tokens[3]), tokens[4]))
transaction = new Transaction(id, gen.stream, gen, new EventTime(Integer.parseInt(tokens[3]), tokens[4]))
gen.transactions << transaction
transactionsById[id]= transaction
gen.begin_attrs_idx=0;
@ -124,59 +133,32 @@ public class TrTextDb extends TrHierNode implements ITrDb{
break
case "tx_record_attribute"://matcher = line =~ /^tx_record_attribute\s+(\d+)\s+"([^"]+)"\s+(\S+)\s*=\s*(.+)$/
def id = Integer.parseInt(tokens[1])
transactionsById[id].attributes.add(new TrAttribute(tokens[2][1..-2], tokens[3], tokens[5..-1].join(' ')))
transactionsById[id].attributes<<new TrAttribute(tokens[2][1..-2], tokens[3], ITrAttrType.AttributeType.UNSPECIFIED, tokens[5..-1].join(' '))
break
case "a"://matcher = line =~ /^a\s+(.+)$/
if(endTransaction){
transaction.end_attrs << new TrAttribute(transaction.generator.end_attrs[0], tokens[1])
transaction.attributes << new TrAttribute(transaction.generator.end_attrs[0], tokens[1])
} else {
transaction.begin_attrs << new TrAttribute(transaction.generator.begin_attrs[0], tokens[1])
transaction.attributes << new TrAttribute(transaction.generator.begin_attrs[0], tokens[1])
}
break
case "tx_relation"://matcher = line =~ /^tx_relation\s+\"(\S+)\"\s+(\d+)\s+(\d+)$/
Transaction tr1= transactionsById[Integer.parseInt(tokens[2])]
Transaction tr2= transactionsById[Integer.parseInt(tokens[3])]
switch(tokens[1][1..-2]){
case "CHILD":
tr1.child<<tr2
tr2.parent<<tr1
break
case "PARENT":
tr2.child<<tr1
tr1.parent<<tr2
break
case "PREDECESSOR":
tr2.succ<<tr1
tr1.pred<<tr2
break
case "SUCCESSOR":
tr1.succ<<tr2
tr2.pred<<tr1
break
default:
println "Relationship '${tokens[1]}' not yet implemented"
}
def relType=tokens[1][1..-2]
if(!relationTypes.containsKey(relType)) relationTypes[relType]=new RelationType(relType)
def rel = new TrRelation(relationTypes[relType], tr1, tr2)
tr1.outgoingRelations<<rel
tr2.incomingRelations<<rel
break
default:
println "Don't know what to do with: '$line'"
}
}
linkTransactions()
addHierarchyNodes()
}
def linkTransactions(){
streams.generators?.flatten().each {TrGenerator gen ->
def sortedTx = gen.transactions.sort{it.beginTime}
if(sortedTx.size()>1)
for(int i=1;i<sortedTx.size(); i++){
sortedTx[i].prev= sortedTx[i-1]
sortedTx[i-1].next = sortedTx[i]
}
}
}
def addHierarchyNodes(){
streams.each{ TrStream stream->
def hier = stream.fullName.split(/\./)

View File

@ -0,0 +1,13 @@
package com.itjw.txviewer.database.text
import com.itjw.txviewer.database.ITrDb
import com.itjw.txviewer.database.ITransactionDbFactory;
class TrTextDbFactory implements ITransactionDbFactory {
@Override
public ITrDb createDatabase() {
return new TrTextDb();
}
}

View File

@ -10,95 +10,43 @@
*******************************************************************************/
package com.itjw.txviewer.database.text
import java.util.Collection;
import java.util.Set
import com.itjw.txviewer.database.*
import org.eclipse.ui.views.properties.IPropertyDescriptor
import org.eclipse.ui.views.properties.IPropertySource
class Transaction implements IPropertySource, ITransaction {
Long id
TrGenerator generator
EventTime beginTime
EventTime endTime
ArrayList<ITrAttribute> begin_attrs = new ArrayList<ITrAttribute>()
ArrayList<ITrAttribute> end_attrs = new ArrayList<ITrAttribute>()
ArrayList<ITrAttribute> attributes = new ArrayList<ITrAttribute>()
Transaction prev, next
def pred =[]
def succ =[]
def parent =[]
def child =[]
import com.itjw.txviewer.database.*
class Transaction implements ITransaction {
Transaction(int id, TrGenerator generator, EventTime begin){
Long id
TrGenerator generator
TrStream stream
EventTime beginTime
EventTime endTime
ArrayList<ITrAttribute> attributes = new ArrayList<ITrAttribute>()
def incomingRelations =[]
def outgoingRelations =[]
Transaction(int id, TrStream stream, TrGenerator generator, EventTime begin){
this.id=id
this.generator=generator
this.beginTime=begin
}
@Override
List<ITrAttribute> getBeginAttrs() {
return begin_attrs
}
@Override
List<ITrAttribute> getEndAttrs() {
return end_attrs
public Collection<ITrRelation> getIncomingRelations() {
return incomingRelations;
}
@Override
public Collection<ITrRelation> getOutgoingRelations() {
return outgoingRelations;
}
List<ITrAttribute> getAttributes(){
return attributes
}
@Override
public Set<ITransaction> getNextInRelationship(RelationType rel) {
switch(rel){
case RelationType.PREDECESSOR:
return pred
break
case RelationType.SUCCESSOR:
return succ
break
case RelationType.PREVIOUS:
return [prev]
break
case RelationType.NEXT:
return[next]
break
case RelationType.PARENT:
return parent
break
case RelationType.CHILD:
return child
break
}
}
@Override
public Object getEditableValue() {
// TODO Auto-generated method stub
return null;
}
@Override
public IPropertyDescriptor[] getPropertyDescriptors() {
return null;
}
@Override
public Object getPropertyValue(Object id) {
return null;
}
@Override
public boolean isPropertySet(Object id) {
return false;
}
@Override
public void resetPropertyValue(Object id) {
}
@Override
public void setPropertyValue(Object id, Object value) {
}
}

1
com.itjw.txviewer.database/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/bin

View File

@ -4,7 +4,6 @@ Bundle-Name: Transaction Database
Bundle-SymbolicName: com.itjw.txviewer.database
Bundle-Version: 1.0.0.qualifier
Bundle-Vendor: ITJW
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Bundle-ActivationPolicy: lazy
Export-Package: com.itjw.txviewer.database
Require-Bundle: org.eclipse.ui.views

View File

@ -11,8 +11,11 @@
package com.itjw.txviewer.database;
public class EventTime implements Comparable<EventTime>{
public static final double NS = 1000000.0;
public static final double MS = 1000000000.0;
private long value; // unit is femto seconds
public EventTime(Long value, String unit){
@ -51,6 +54,8 @@ public class EventTime implements Comparable<EventTime>{
this.value=value*1000000000;
else if("ms".compareToIgnoreCase(unit)==0)
this.value=value*1000000000000L;
else if("s".compareToIgnoreCase(unit)==0)
this.value=value*1000000000000000L;
else {
System.err.print("Don't know what to do with "+unit+"\n");
}

View File

@ -11,6 +11,8 @@
package com.itjw.txviewer.database;
public interface ITrAttrType {
enum AttributeType {UNSPECIFIED, BEGIN, END};
public String getName();
public String getType();
public String getDataType();
public AttributeType getType();
}

View File

@ -18,6 +18,8 @@ public interface ITrDb extends ITrHierNode {
public EventTime getMaxTime();
public ITrStream getStreamByName(String name);
public List<ITrStream> getAllStreams();
public void load(InputStream inp) throws InputFormatException;

View File

@ -0,0 +1,10 @@
package com.itjw.txviewer.database;
public interface ITrRelation {
RelationType getRelationType();
ITransaction getSource();
ITransaction getTarget();
}

View File

@ -10,16 +10,25 @@
*******************************************************************************/
package com.itjw.txviewer.database;
import java.util.Collection;
import java.util.List;
import java.util.Set;
public interface ITransaction {
public Long getId();
public ITrStream getStream();
public ITrGenerator getGenerator();
public EventTime getBeginTime();
public EventTime getEndTime();
public List<ITrAttribute> getBeginAttrs();
public List<ITrAttribute> getEndAttrs();
public List<ITrAttribute> getAttributes();
public Set<ITransaction> getNextInRelationship(RelationType rel);
public Collection<ITrRelation> getIncomingRelations();
public Collection<ITrRelation> getOutgoingRelations();
}

View File

@ -0,0 +1,7 @@
package com.itjw.txviewer.database;
public interface ITransactionDbFactory {
ITrDb createDatabase();
}

View File

@ -10,6 +10,21 @@
*******************************************************************************/
package com.itjw.txviewer.database;
public enum RelationType {
PREDECESSOR, SUCCESSOR, PREVIOUS, NEXT, PARENT, CHILD;
public class RelationType {
private String name;
public RelationType(String name) {
super();
this.name = name;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}

View File

@ -46,7 +46,7 @@
unpack="false"/>
<plugin
id="com.itjw.txviewer.graph"
id="com.itjw.txviewer.ui"
download-size="0"
install-size="0"
version="0.0.0"

View File

@ -1,100 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="org.eclipse.ui.views">
<category
name="TxViewer"
id="com.itjw.txviewer.graph">
</category>
<view
category="com.itjw.txviewer.graph"
class="com.itjw.txviewer.graph.views.SelectionPropertiesView"
icon="icons/sample.gif"
id="com.itjw.txviewer.graph.views.SelectionPropertiesView"
name="Transaction Properties"
restorable="true">
</view>
</extension>
<extension
point="org.eclipse.help.contexts">
<contexts
file="contexts.xml">
</contexts>
</extension>
<extension
point="org.eclipse.ui.editors">
<editor
class="com.itjw.txviewer.graph.TxEditorPart"
extensions="txdb"
icon="icons/sample.gif"
id="com.itjw.txviewer.graph.TxEditorPart"
name="Wave Viewer">
</editor>
</extension>
<extension
point="org.eclipse.ui.views.properties.tabbed.propertyContributor">
<propertyContributor
contributorId="com.itjw.txviewer.graph.TxEditorPart">
<propertyCategory
category="Transaction"></propertyCategory>
</propertyContributor>
</extension>
<extension
point="org.eclipse.ui.views.properties.tabbed.propertyTabs">
<propertyTabs
contributorId="com.itjw.txviewer.graph.TxEditorPart">
<propertyTab
category="Transaction"
id="com.itjw.txviewer.graph.propertyTabTransaction"
label="Transaction">
</propertyTab>
<propertyTab
afterTab="com.itjw.txviewer.graph.propertyTabTransaction"
category="Transaction"
id="com.itjw.txviewer.graph.propertyTabAttributes"
label="Attributes">
</propertyTab>
<propertyTab
afterTab="com.itjw.txviewer.graph.propertyTabAttributes"
category="Transaction"
id="com.itjw.txviewer.graph.propertyTabRelated"
label="Related Tx">
</propertyTab>
</propertyTabs>
</extension>
<extension
point="org.eclipse.ui.views.properties.tabbed.propertySections">
<propertySections
contributorId="com.itjw.txviewer.graph.TxEditorPart">
<propertySection
class="org.eclipse.ui.views.properties.tabbed.AdvancedPropertySection"
id="com.itjw.txviewer.graph.propertySectionAll"
tab="com.itjw.txviewer.graph.propertyTabTransaction">
<input
type="com.itjw.txviewer.graph.data.ITransactionFacade">
</input>
</propertySection>
<propertySection
afterSection="com.itjw.txviewer.graph.propertySectionAll"
class="com.itjw.txviewer.graph.views.sections.AttributeProperty"
id="com.itjw.txviewer.graph.propertySectionAttributes"
tab="com.itjw.txviewer.graph.propertyTabAttributes">
<input
type="com.itjw.txviewer.graph.data.ITransactionFacade">
</input>
</propertySection>
<propertySection
afterSection="com.itjw.txviewer.graph.propertySectionAttributes"
class="com.itjw.txviewer.graph.views.sections.RelatedProperty"
id="com.itjw.txviewer.graph.propertySectionRelated"
tab="com.itjw.txviewer.graph.propertyTabRelated">
<input
type="com.itjw.txviewer.graph.data.ITransactionFacade">
</input>
</propertySection>
</propertySections>
</extension>
</plugin>

View File

@ -1,71 +0,0 @@
/*******************************************************************************
* Copyright (c) 2012 IT Just working.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IT Just working - initial API and implementation
*******************************************************************************/
package com.itjw.txviewer.graph;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.eclipse.jface.viewers.IStructuredSelection;
import com.itjw.txviewer.graph.data.ITrHierNodeFacade;
public class TrHierNodeSelection implements IStructuredSelection {
List<ITrHierNodeFacade> selection = new ArrayList<ITrHierNodeFacade>();
public TrHierNodeSelection(ITrHierNodeFacade node){
selection.add(node);
}
public TrHierNodeSelection(List<ITrHierNodeFacade> nodes){
selection.addAll(nodes);
}
public void add(ITrHierNodeFacade node){
selection.add(node);
}
public void addAll(List<ITrHierNodeFacade> nodes){
selection.addAll(nodes);
}
@Override
public boolean isEmpty() {
return selection.size()==0;
}
@Override
public Object getFirstElement() {
return selection.get(0);
}
@Override
public Iterator<ITrHierNodeFacade> iterator() {
return selection.iterator();
}
@Override
public int size() {
return selection.size();
}
@Override
public Object[] toArray() {
// TODO Auto-generated method stub
return selection.toArray();
}
@Override
public List<ITrHierNodeFacade> toList() {
return selection;
}
}

View File

@ -1,77 +0,0 @@
/*******************************************************************************
* Copyright (c) 2012 IT Just working.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IT Just working - initial API and implementation
*******************************************************************************/
package com.itjw.txviewer.graph;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.eclipse.jface.viewers.IStructuredSelection;
import com.itjw.txviewer.graph.data.ITrStreamFacade;
import com.itjw.txviewer.graph.data.ITransactionFacade;
public class TransactionSelection implements IStructuredSelection {
List<Object> selection = new ArrayList<Object>();
public TransactionSelection(ITransactionFacade node){
selection.add(node);
}
public TransactionSelection(List<ITransactionFacade> nodes){
selection.addAll(nodes);
}
public TransactionSelection(ITransactionFacade currentSelection, ITrStreamFacade currentStreamSelection) {
selection.add(currentSelection);
if(currentStreamSelection!=null)
selection.add(currentStreamSelection);
}
public void add(ITransactionFacade node){
selection.add(node);
}
public void addAll(List<ITransactionFacade> nodes){
selection.addAll(nodes);
}
@Override
public boolean isEmpty() {
return selection.size()==0;
}
@Override
public ITransactionFacade getFirstElement() {
return (ITransactionFacade)selection.get(0);
}
@Override
public Iterator<Object> iterator() {
return selection.iterator();
}
@Override
public int size() {
return selection.size();
}
@Override
public Object[] toArray() {
return selection.toArray();
}
@Override
public List<Object> toList() {
return selection;
}
}

View File

@ -1,25 +0,0 @@
/*******************************************************************************
* Copyright (c) 2012 IT Just working.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IT Just working - initial API and implementation
*******************************************************************************/
package com.itjw.txviewer.graph.actions;
import org.eclipse.jface.action.Action;
public class AddToWave extends Action {
public AddToWave() {
super("Add to wave");
// TODO Auto-generated constructor stub
}
public static final String ID = "com.itjw.txviewer.graph.action.AddToWave";
}

View File

@ -1,113 +0,0 @@
/*******************************************************************************
* Copyright (c) 2012 IT Just working.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IT Just working - initial API and implementation
*******************************************************************************/
package com.itjw.txviewer.graph.actions;
import java.util.LinkedList;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
import com.itjw.txviewer.database.ITrHierNode;
import com.itjw.txviewer.database.ITrStream;
import com.itjw.txviewer.database.ITransaction;
import com.itjw.txviewer.graph.TransactionSelection;
import com.itjw.txviewer.graph.TxEditorPlugin;
import com.itjw.txviewer.graph.data.ITransactionFacade;
public class TxActionFactory {
public static final int ADD_TO_WAVE = 0;
public static final int ADD_ALL_TO_WAVE = 1;
public static final int REMOVE_FROM_WAVE = 2;
public static final int REMOVE_ALL_FROM_WAVE = 3;
public static final int JUMP_TO_TX = 4;
private static TxActionFactory instance;
private TxActionFactory(){}
public static TxActionFactory getInstance() {
if(instance == null) instance=new TxActionFactory();
return instance;
}
public static Action getAction(int actionId, boolean enabled){
switch(actionId){
case ADD_TO_WAVE:
return getInstance().makeStreamAction("Add to Wave", ISharedImages.IMG_OBJ_ADD, enabled, false);
case ADD_ALL_TO_WAVE:
return getInstance().makeStreamAction("Add all to Wave", ISharedImages.IMG_OBJ_ADD, true, false);
case REMOVE_FROM_WAVE:
return getInstance().makeStreamAction("Remove from Wave", ISharedImages.IMG_TOOL_DELETE, enabled, true);
case REMOVE_ALL_FROM_WAVE:
return getInstance().makeStreamAction("Remove all from Wave", ISharedImages.IMG_TOOL_DELETE, true, true);
case JUMP_TO_TX:
return getInstance().makeTransactionAction("Jump to Transaction", ISharedImages.IMG_OBJ_ADD, true);
}
return null;
}
private Action makeStreamAction(String text, String imgDescriptor, boolean enabled, final boolean remove) {
Action action = new Action() {
public void run() {
ISelection selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection();
for(Object obj :((IStructuredSelection) selection).toArray()){
if(obj instanceof ITrStream){
if(remove)
TxEditorPlugin.getDefault().getOpenEditorPart().removeStreamFromList((ITrStream) obj);
else
TxEditorPlugin.getDefault().getOpenEditorPart().addStreamToList((ITrStream) obj);
} else if(obj instanceof ITrHierNode){
LinkedList<ITrHierNode> queue = new LinkedList<ITrHierNode>();
LinkedList<ITrStream> streams = new LinkedList<ITrStream>();
queue.add((ITrHierNode)obj);
while(queue.size()>0){
ITrHierNode n = queue.poll();
if(n instanceof ITrStream) streams.add((ITrStream) n);
queue.addAll(n.getChildNodes());
}
if(remove)
TxEditorPlugin.getDefault().getOpenEditorPart().removeStreamsFromList(streams.toArray(new ITrStream[]{}));
else
TxEditorPlugin.getDefault().getOpenEditorPart().addStreamsToList(streams.toArray(new ITrStream[]{}));
}
}
}
};
action.setText(text);
action.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(imgDescriptor));
action.setEnabled(enabled);
return action;
}
private Action makeTransactionAction(String text, String imgDescriptor, boolean enabled) {
Action action = new Action() {
public void run() {
ISelection selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection();
for(Object obj :((IStructuredSelection) selection).toArray()){
ISelection sel=null;
if(obj instanceof ITransactionFacade){
sel = new TransactionSelection((ITransactionFacade) obj);
} else if(obj instanceof ITransaction){
sel = new TransactionSelection(new ITransactionFacade( (ITransaction) obj));
}
if(sel!=null)
TxEditorPlugin.getDefault().getOpenEditorPart().setSelection(sel);
}
}
};
action.setText(text);
action.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(imgDescriptor));
action.setEnabled(enabled);
return action;
}
}

View File

@ -1,96 +0,0 @@
/*******************************************************************************
* Copyright (c) 2012 IT Just working.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IT Just working - initial API and implementation
*******************************************************************************/
package com.itjw.txviewer.graph.data;
import java.io.InputStream;
import java.util.Arrays;
import java.util.List;
import org.eclipse.ui.views.properties.IPropertyDescriptor;
import org.eclipse.ui.views.properties.PropertyDescriptor;
import org.osgi.framework.BundleContext;
import org.osgi.framework.FrameworkUtil;
import org.osgi.framework.ServiceReference;
import com.itjw.txviewer.database.EventTime;
import com.itjw.txviewer.database.ITrDb;
import com.itjw.txviewer.database.ITrStream;
import com.itjw.txviewer.database.InputFormatException;
public class ITrDbFacade extends ITrHierNodeFacade implements ITrDb {
protected final static String PROPERTY_DURATION = "DURATIONS";
protected final static String PROPERTY_STREAMS = "NR_OF_STREAMS";
public static final String DATABASE = "DATABASE";
public ITrDbFacade() {
super(null);
}
private ITrDb getDb(){
return (ITrDb)iTrHierNode;
}
@Override
public EventTime getMaxTime() {
return getDb().getMaxTime();
}
@Override
public List<ITrStream> getAllStreams() {
return getDb().getAllStreams();
}
@Override
public void load(InputStream input) throws InputFormatException {
BundleContext context = FrameworkUtil.getBundle(this.getClass()).getBundleContext();
ServiceReference<?> serviceReference = context.getServiceReference(ITrDb.class.getName());
ITrDb iTrDb = (ITrDb) context.getService(serviceReference);
iTrDb.load(input);
iTrHierNode=iTrDb;
firePropertyChange(DATABASE, null, getDb());
}
@Override
public void clear() {
firePropertyChange(DATABASE, getDb(), null);
getDb().clear();
}
@Override
public IPropertyDescriptor[] getPropertyDescriptors() {
if (propertyDescriptors == null) {
super.getPropertyDescriptors();
// Create a descriptor and set a category
PropertyDescriptor nrDescriptor = new PropertyDescriptor(PROPERTY_DURATION, "Duration");
nrDescriptor.setCategory("Hier Node");
PropertyDescriptor streamsDescriptor = new PropertyDescriptor(PROPERTY_STREAMS, "Stream count");
nrDescriptor.setCategory("Hier Node");
IPropertyDescriptor[] result = Arrays.copyOf(propertyDescriptors, propertyDescriptors.length + 2);
System.arraycopy(new IPropertyDescriptor[] {nrDescriptor, streamsDescriptor}, 0, result, propertyDescriptors.length, 2);
propertyDescriptors = result;
}
return propertyDescriptors;
}
@Override
public Object getPropertyValue(Object id) {
if (id.equals(PROPERTY_DURATION)) {
return getMaxTime().getValueNS();
} else if (id.equals(PROPERTY_STREAMS)) {
return getAllStreams().size();
} else {
return super.getPropertyValue(id);
}
}
}

View File

@ -1,160 +0,0 @@
/*******************************************************************************
* Copyright (c) 2012 IT Just working.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IT Just working - initial API and implementation
*******************************************************************************/
package com.itjw.txviewer.graph.data;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.ui.views.properties.IPropertyDescriptor;
import org.eclipse.ui.views.properties.IPropertySource;
import org.eclipse.ui.views.properties.PropertyDescriptor;
import com.itjw.txviewer.database.ITrHierNode;
import com.itjw.txviewer.database.ITrStream;
public class ITrHierNodeFacade implements ITrHierNode, IPropertySource {
protected final static String PROPERTY_NAME = "Name";
protected final static String PROPERTY_FULLNAME = "HierName";
private transient PropertyChangeSupport pcs = new PropertyChangeSupport(this);
protected ITrHierNode iTrHierNode;
protected ITrHierNodeFacade parent;
protected IPropertyDescriptor[] propertyDescriptors;
public ITrHierNodeFacade(ITrHierNode iTrHierNode) {
this.iTrHierNode = iTrHierNode;
}
public ITrHierNodeFacade(ITrHierNode iTrHierNode, ITrHierNodeFacade parent) {
this.iTrHierNode = iTrHierNode;
this.parent=parent;
}
@Override
public String getFullName() {
return iTrHierNode.getFullName();
}
@Override
public void setName(String name) {
iTrHierNode.setName(name);
}
@Override
public String getName() {
return iTrHierNode.getName();
}
@Override
public List<ITrHierNode> getChildNodes() {
ArrayList<ITrHierNode> res = new ArrayList<ITrHierNode>();
for(ITrHierNode node:iTrHierNode.getChildNodes()){
if(node instanceof ITrStream){
res.add(new ITrStreamFacade((ITrStream)node));
} else {
res.add(new ITrHierNodeFacade(node));
}
}
return res;
}
/**
* Attach a non-null PropertyChangeListener to this object.
*
* @param l
* a non-null PropertyChangeListener instance
* @throws IllegalArgumentException
* if the parameter is null
*/
public synchronized void addPropertyChangeListener(PropertyChangeListener l) {
if (l == null) {
throw new IllegalArgumentException();
}
pcs.addPropertyChangeListener(l);
}
/**
* Report a property change to registered listeners (for example edit
* parts).
*
* @param property
* the programmatic name of the property that changed
* @param oldValue
* the old value of this property
* @param newValue
* the new value of this property
*/
protected void firePropertyChange(String property, Object oldValue, Object newValue) {
if (pcs.hasListeners(property)) {
pcs.firePropertyChange(property, oldValue, newValue);
}
}
/**
* Remove a PropertyChangeListener from this component.
*
* @param l
* a PropertyChangeListener instance
*/
public synchronized void removePropertyChangeListener(PropertyChangeListener l) {
if (l != null) {
pcs.removePropertyChangeListener(l);
}
}
// IPropertySource methods
@Override
public Object getEditableValue() {
return null;
}
@Override
public IPropertyDescriptor[] getPropertyDescriptors() {
if (propertyDescriptors == null) {
// Create a descriptor and set a category
PropertyDescriptor nameDescriptor = new PropertyDescriptor(PROPERTY_NAME, "Name");
nameDescriptor.setCategory("Hier Node");
PropertyDescriptor fullnameDescriptor = new PropertyDescriptor(PROPERTY_FULLNAME, "Full name");
fullnameDescriptor.setCategory("Hier Node");
propertyDescriptors = new IPropertyDescriptor[] {nameDescriptor, fullnameDescriptor};
}
return propertyDescriptors;
}
@Override
public Object getPropertyValue(Object id) {
if (id.equals(PROPERTY_NAME)) {
return getName();
} else if(id.equals(PROPERTY_FULLNAME)){
return getFullName();
} else
return null;
}
@Override
public boolean isPropertySet(Object id) {
String curName = (String)getPropertyValue(id);
return curName!=null && curName.length()>0;
}
@Override
public void resetPropertyValue(Object id) {
}
@Override
public void setPropertyValue(Object id, Object value) {
}
}

View File

@ -1,112 +0,0 @@
/*******************************************************************************
* Copyright (c) 2012 IT Just working.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IT Just working - initial API and implementation
*******************************************************************************/
package com.itjw.txviewer.graph.data;
import java.util.Arrays;
import java.util.List;
import org.eclipse.ui.views.properties.IPropertyDescriptor;
import org.eclipse.ui.views.properties.PropertyDescriptor;
import com.itjw.txviewer.database.ITrDb;
import com.itjw.txviewer.database.ITrGenerator;
import com.itjw.txviewer.database.ITrStream;
import com.itjw.txviewer.database.ITransaction;
public class ITrStreamFacade extends ITrHierNodeFacade implements ITrStream {
protected final static String PROPERTY_NUMBER = "NR_OF_TRANSACTIONS";
private int height;
private ITrStream getStream(){
return (ITrStream)iTrHierNode;
}
public ITrStreamFacade(ITrStream iTrStream) {
super(iTrStream);
}
public ITrStreamFacade(ITrStream iTrStream, ITrHierNodeFacade parent) {
super(iTrStream, parent);
}
@Override
public Long getId() {
return getStream().getId();
}
@Override
public String getKind() {
return getStream().getKind();
}
@Override
public ITrDb getDb() {
// TODO Auto-generated method stub
return getStream().getDb();
}
@Override
public List<ITrGenerator> getGenerators() {
return getStream().getGenerators();
}
@Override
public List<ITransaction> getTransactions() {
return getStream().getTransactions();
}
@Override
public int getMaxConcurrrentTx() {
return getStream().getMaxConcurrrentTx();
}
@Override
public IPropertyDescriptor[] getPropertyDescriptors() {
if (propertyDescriptors == null) {
super.getPropertyDescriptors();
// Create a descriptor and set a category
PropertyDescriptor nrDescriptor = new PropertyDescriptor(PROPERTY_NUMBER, "# of transactions");
nrDescriptor.setCategory("Stream");
IPropertyDescriptor[] result = Arrays.copyOf(propertyDescriptors, propertyDescriptors.length + 1);
System.arraycopy(new IPropertyDescriptor[] {nrDescriptor}, 0, result, propertyDescriptors.length, 1);
propertyDescriptors = result;
}
return propertyDescriptors;
}
@Override
public Object getPropertyValue(Object id) {
if (id.equals(PROPERTY_NUMBER)) {
return getStream().getTransactions().size();
} else {
return super.getPropertyValue(id);
}
}
public int getHeight() {
return height;
}
public void setHeight(int height) {
this.height = height;
}
public double getMaxTimeNS() {
return getDb().getMaxTime().getValueNS();
}
public String getValueAtCursor(int i) {
return "-";
}
}

View File

@ -1,80 +0,0 @@
/*******************************************************************************
* Copyright (c) 2012 IT Just working.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IT Just working - initial API and implementation
*******************************************************************************/
package com.itjw.txviewer.graph.data;
import java.util.List;
import java.util.Set;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.ui.views.properties.IPropertySource;
import com.itjw.txviewer.database.EventTime;
import com.itjw.txviewer.database.ITrAttribute;
import com.itjw.txviewer.database.ITrGenerator;
import com.itjw.txviewer.database.ITransaction;
import com.itjw.txviewer.database.RelationType;
public class ITransactionFacade implements ITransaction, IAdaptable {
protected ITransaction iTransaction;
public ITransactionFacade(ITransaction iTransaction) {
this.iTransaction = iTransaction;
}
@Override
public Long getId() {
return iTransaction.getId();
}
@Override
public ITrGenerator getGenerator() {
return iTransaction.getGenerator();
}
@Override
public EventTime getBeginTime() {
return iTransaction.getBeginTime();
}
@Override
public EventTime getEndTime() {
return iTransaction.getEndTime();
}
@Override
public List<ITrAttribute> getBeginAttrs() {
return iTransaction.getBeginAttrs();
}
@Override
public List<ITrAttribute> getEndAttrs() {
return iTransaction.getEndAttrs();
}
@Override
public List<ITrAttribute> getAttributes() {
return iTransaction.getAttributes();
}
@Override
public Set<ITransaction> getNextInRelationship(RelationType rel) {
return iTransaction.getNextInRelationship(rel);
}
@SuppressWarnings("rawtypes")
@Override
public Object getAdapter(Class adapter) {
if (adapter == IPropertySource.class)
return new ITransactionProperties(this);
return null;
}
}

View File

@ -1,172 +0,0 @@
/*******************************************************************************
* Copyright (c) 2012 IT Just working.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IT Just working - initial API and implementation
*******************************************************************************/
package com.itjw.txviewer.graph.ui.swt;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.events.ControlAdapter;
import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.ScrollBar;
import com.itjw.txviewer.graph.TxEditorPlugin;
import com.itjw.txviewer.graph.data.ITrStreamFacade;
public abstract class ListPane extends Composite implements PaintListener {
public static final String SELECTION= "StreamSelected";
private TxEditorPlugin plugin;
private TxDisplay display;
ScrolledComposite scroll;
Composite frame;
private MouseAdapter mouseLabelListener;
private List<PropertyChangeListener> listeners = new ArrayList<PropertyChangeListener>();
public ListPane(Composite parent, TxDisplay txDisplay) {
super(parent, SWT.NONE);
FormLayout fl = new FormLayout();
fl.marginHeight = 0;
fl.marginWidth = 0;
this.setLayout(fl);
plugin=TxEditorPlugin.getDefault();
display=txDisplay;
Label header=new Label(this, SWT.NONE);
header.setText(getHeaderValue());
header.setAlignment(SWT.CENTER);
FormData fh = new FormData();
fh.top=fh.left=new FormAttachment(0);
fh.right=new FormAttachment(100);
fh.bottom=new FormAttachment(0, WaveImageCanvas.rulerHeight);
header.setLayoutData(fh);
header.setBackground(plugin.getColor(TxEditorPlugin.headerBgColor));
header.setForeground(plugin.getColor(TxEditorPlugin.headerFgColor));
scroll=new ScrolledComposite(this, SWT.H_SCROLL | SWT.V_SCROLL);
FormData fd = new FormData();
fd.top=new FormAttachment(0);
fd.bottom=new FormAttachment(100);
fd.left=new FormAttachment(0);
fd.right=new FormAttachment(100);
scroll.setLayoutData(fd);
scroll.setAlwaysShowScrollBars(true);
scroll.getHorizontalBar().setVisible(true);
scroll.getVerticalBar().setVisible(false);
frame = new Composite(scroll, SWT.NONE);
GridLayout gl = new GridLayout(1, false);
gl.marginHeight = 0;
gl.marginWidth = 0;
gl.verticalSpacing = 0;
frame.setLayout(gl);
scroll.setContent(frame);
scroll.setExpandVertical(true);
scroll.setExpandHorizontal(true);
scroll.addControlListener(new ControlAdapter() {
public void controlResized(ControlEvent e) {
updateSize();
}
});
scroll.pack();
mouseLabelListener = new MouseAdapter() {
@Override
public void mouseUp(MouseEvent e) {
fireStreamSelected(e.widget.getData());
}
};
}
public void scrollToY(int y){
if (scroll.getContent() == null) return;
Point location = scroll.getContent().getLocation ();
ScrollBar vBar = scroll.getVerticalBar ();
vBar.setSelection(y);
scroll.getContent().setLocation (location.x, -y);
}
public void streamListChanged() {
for(Control ctrl:frame.getChildren()) ctrl.dispose();
int trackIdx=0;
for(ITrStreamFacade str: display.getTxEditor().getStreamList()){
Label l = new Label(frame, SWT.NONE);
l.setText(getLabelValue(str));
l.setData(str);
formatLabel(l, str, trackIdx++);
l.addMouseListener(mouseLabelListener);
}
frame.pack(true);
frame.layout(true);
updateSize();
}
protected void formatLabel(Label l, ITrStreamFacade str, int trackIdx){
// GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
GridData gd = new GridData();
gd.verticalIndent=trackIdx==0?WaveImageCanvas.rulerHeight:0;
gd.verticalAlignment = SWT.CENTER;
gd.horizontalAlignment = SWT.FILL;
gd.heightHint=str.getHeight();
gd.grabExcessHorizontalSpace=true;
l.setLayoutData(gd);
l.setBackground(trackIdx%2==0?plugin.getColor(TxEditorPlugin.trackBgLightColor):plugin.getColor(TxEditorPlugin.trackBgDarkColor));
l.setSize(0,str.getHeight());
}
public void paintControl(PaintEvent e){
e.gc.setBackground(new Color(null, 255, 255, 255));
e.gc.fillRectangle(e.x, e.y, e.width, 20);
}
private void updateSize() {
Rectangle r = getClientArea();
Point p = frame.computeSize(SWT.DEFAULT, SWT.DEFAULT);
scroll.setMinSize(frame.computeSize(r.width>p.x?r.width:p.x, SWT.DEFAULT));
scroll.getVerticalBar().setVisible(false);
}
public void addLabelClickListener(PropertyChangeListener listener){
listeners.add(listener);
}
public void removePropertyChangeListener(PropertyChangeListener listener) {
listeners.remove(listener);
}
protected void fireStreamSelected(Object newValue) {
PropertyChangeEvent event = new PropertyChangeEvent(this, SELECTION, null, newValue);
for (int i = 0; i < listeners.size(); i++)
listeners.get(i).propertyChange(event);
}
abstract String getHeaderValue();
abstract String getLabelValue(ITrStreamFacade str);
}

Some files were not shown because too many files have changed in this diff Show More