diff --git a/com.itjw.txviewer.database.text/.gitignore b/com.itjw.txviewer.database.text/.gitignore new file mode 100644 index 0000000..5e56e04 --- /dev/null +++ b/com.itjw.txviewer.database.text/.gitignore @@ -0,0 +1 @@ +/bin diff --git a/com.itjw.txviewer.database.text/.settings/org.eclipse.jdt.groovy.core.prefs b/com.itjw.txviewer.database.text/.settings/org.eclipse.jdt.groovy.core.prefs new file mode 100644 index 0000000..a7f72ec --- /dev/null +++ b/com.itjw.txviewer.database.text/.settings/org.eclipse.jdt.groovy.core.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +groovy.compiler.level=23 diff --git a/com.itjw.txviewer.database.text/META-INF/MANIFEST.MF b/com.itjw.txviewer.database.text/META-INF/MANIFEST.MF index 83a6192..71e863d 100644 --- a/com.itjw.txviewer.database.text/META-INF/MANIFEST.MF +++ b/com.itjw.txviewer.database.text/META-INF/MANIFEST.MF @@ -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" diff --git a/com.itjw.txviewer.database.text/src/com/itjw/txviewer/database/text/Activator.groovy b/com.itjw.txviewer.database.text/src/com/itjw/txviewer/database/text/Activator.groovy index fa88304..2668eff 100644 --- a/com.itjw.txviewer.database.text/src/com/itjw/txviewer/database/text/Activator.groovy +++ b/com.itjw.txviewer.database.text/src/com/itjw/txviewer/database/text/Activator.groovy @@ -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 dict = new Hashtable(); dict.putAt(Constants.SERVICE_RANKING, 1); - context.registerService(ITrDb.class, new TrTextDb(), dict); + context.registerService(ITransactionDbFactory.class, new TrTextDbFactory(), dict); } /* diff --git a/com.itjw.txviewer.database.text/src/com/itjw/txviewer/database/text/TrAttrType.groovy b/com.itjw.txviewer.database.text/src/com/itjw/txviewer/database/text/TrAttrType.groovy index c2d41b8..93d87d4 100644 --- a/com.itjw.txviewer.database.text/src/com/itjw/txviewer/database/text/TrAttrType.groovy +++ b/com.itjw.txviewer.database.text/src/com/itjw/txviewer/database/text/TrAttrType.groovy @@ -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 } } diff --git a/com.itjw.txviewer.database.text/src/com/itjw/txviewer/database/text/TrAttrTypeFactory.groovy b/com.itjw.txviewer.database.text/src/com/itjw/txviewer/database/text/TrAttrTypeFactory.groovy index 9e5b836..6a97e75 100644 --- a/com.itjw.txviewer.database.text/src/com/itjw/txviewer/database/text/TrAttrTypeFactory.groovy +++ b/com.itjw.txviewer.database.text/src/com/itjw/txviewer/database/text/TrAttrTypeFactory.groovy @@ -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 diff --git a/com.itjw.txviewer.database.text/src/com/itjw/txviewer/database/text/TrAttribute.groovy b/com.itjw.txviewer.database.text/src/com/itjw/txviewer/database/text/TrAttribute.groovy index 08c0710..d6d04e1 100644 --- a/com.itjw.txviewer.database.text/src/com/itjw/txviewer/database/text/TrAttribute.groovy +++ b/com.itjw.txviewer.database.text/src/com/itjw/txviewer/database/text/TrAttribute.groovy @@ -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(); + } + } diff --git a/com.itjw.txviewer.database.text/src/com/itjw/txviewer/database/text/TrRelation.groovy b/com.itjw.txviewer.database.text/src/com/itjw/txviewer/database/text/TrRelation.groovy new file mode 100644 index 0000000..b7e27e6 --- /dev/null +++ b/com.itjw.txviewer.database.text/src/com/itjw/txviewer/database/text/TrRelation.groovy @@ -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; + } + +} diff --git a/com.itjw.txviewer.database.text/src/com/itjw/txviewer/database/text/TrStream.groovy b/com.itjw.txviewer.database.text/src/com/itjw/txviewer/database/text/TrStream.groovy index c223d83..a629c04 100644 --- a/com.itjw.txviewer.database.text/src/com/itjw/txviewer/database/text/TrStream.groovy +++ b/com.itjw.txviewer.database.text/src/com/itjw/txviewer/database/text/TrStream.groovy @@ -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 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()tx.beginTime.value; rowIdx++); - if(rowendtime.size<=rowIdx){ - rowendtime< stream.fullName == name } + } + public List getAllStreams() { return new LinkedList(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< - def sortedTx = gen.transactions.sort{it.beginTime} - if(sortedTx.size()>1) - for(int i=1;i def hier = stream.fullName.split(/\./) diff --git a/com.itjw.txviewer.database.text/src/com/itjw/txviewer/database/text/TrTextDbFactory.groovy b/com.itjw.txviewer.database.text/src/com/itjw/txviewer/database/text/TrTextDbFactory.groovy new file mode 100644 index 0000000..fd8706c --- /dev/null +++ b/com.itjw.txviewer.database.text/src/com/itjw/txviewer/database/text/TrTextDbFactory.groovy @@ -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(); + } + +} diff --git a/com.itjw.txviewer.database.text/src/com/itjw/txviewer/database/text/Transaction.groovy b/com.itjw.txviewer.database.text/src/com/itjw/txviewer/database/text/Transaction.groovy index 9d0ea30..58646cd 100644 --- a/com.itjw.txviewer.database.text/src/com/itjw/txviewer/database/text/Transaction.groovy +++ b/com.itjw.txviewer.database.text/src/com/itjw/txviewer/database/text/Transaction.groovy @@ -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 begin_attrs = new ArrayList() - ArrayList end_attrs = new ArrayList() - ArrayList attributes = new ArrayList() - 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 attributes = new ArrayList() + + def incomingRelations =[] + + def outgoingRelations =[] + + Transaction(int id, TrStream stream, TrGenerator generator, EventTime begin){ this.id=id this.generator=generator this.beginTime=begin } - - @Override - List getBeginAttrs() { - return begin_attrs - } @Override - List getEndAttrs() { - return end_attrs + public Collection getIncomingRelations() { + return incomingRelations; + } + + @Override + public Collection getOutgoingRelations() { + return outgoingRelations; } - List getAttributes(){ - return attributes - } - - @Override - public Set 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) { - } } diff --git a/com.itjw.txviewer.database/.gitignore b/com.itjw.txviewer.database/.gitignore new file mode 100644 index 0000000..5e56e04 --- /dev/null +++ b/com.itjw.txviewer.database/.gitignore @@ -0,0 +1 @@ +/bin diff --git a/com.itjw.txviewer.database/META-INF/MANIFEST.MF b/com.itjw.txviewer.database/META-INF/MANIFEST.MF index aa871f2..cb39807 100644 --- a/com.itjw.txviewer.database/META-INF/MANIFEST.MF +++ b/com.itjw.txviewer.database/META-INF/MANIFEST.MF @@ -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 diff --git a/com.itjw.txviewer.database/bin/com/itjw/txviewer/database/EventTime.class b/com.itjw.txviewer.database/bin/com/itjw/txviewer/database/EventTime.class deleted file mode 100644 index 996c14d..0000000 Binary files a/com.itjw.txviewer.database/bin/com/itjw/txviewer/database/EventTime.class and /dev/null differ diff --git a/com.itjw.txviewer.database/bin/com/itjw/txviewer/database/ITrAttrType.class b/com.itjw.txviewer.database/bin/com/itjw/txviewer/database/ITrAttrType.class deleted file mode 100644 index 94fb32a..0000000 Binary files a/com.itjw.txviewer.database/bin/com/itjw/txviewer/database/ITrAttrType.class and /dev/null differ diff --git a/com.itjw.txviewer.database/bin/com/itjw/txviewer/database/ITrAttribute.class b/com.itjw.txviewer.database/bin/com/itjw/txviewer/database/ITrAttribute.class deleted file mode 100644 index c4ac760..0000000 Binary files a/com.itjw.txviewer.database/bin/com/itjw/txviewer/database/ITrAttribute.class and /dev/null differ diff --git a/com.itjw.txviewer.database/bin/com/itjw/txviewer/database/ITrDb.class b/com.itjw.txviewer.database/bin/com/itjw/txviewer/database/ITrDb.class deleted file mode 100644 index 5b8cd3e..0000000 Binary files a/com.itjw.txviewer.database/bin/com/itjw/txviewer/database/ITrDb.class and /dev/null differ diff --git a/com.itjw.txviewer.database/bin/com/itjw/txviewer/database/ITrGenerator.class b/com.itjw.txviewer.database/bin/com/itjw/txviewer/database/ITrGenerator.class deleted file mode 100644 index d15efb4..0000000 Binary files a/com.itjw.txviewer.database/bin/com/itjw/txviewer/database/ITrGenerator.class and /dev/null differ diff --git a/com.itjw.txviewer.database/bin/com/itjw/txviewer/database/ITrHierNode.class b/com.itjw.txviewer.database/bin/com/itjw/txviewer/database/ITrHierNode.class deleted file mode 100644 index 9214e20..0000000 Binary files a/com.itjw.txviewer.database/bin/com/itjw/txviewer/database/ITrHierNode.class and /dev/null differ diff --git a/com.itjw.txviewer.database/bin/com/itjw/txviewer/database/ITrStream.class b/com.itjw.txviewer.database/bin/com/itjw/txviewer/database/ITrStream.class deleted file mode 100644 index bd07ac1..0000000 Binary files a/com.itjw.txviewer.database/bin/com/itjw/txviewer/database/ITrStream.class and /dev/null differ diff --git a/com.itjw.txviewer.database/bin/com/itjw/txviewer/database/ITransaction.class b/com.itjw.txviewer.database/bin/com/itjw/txviewer/database/ITransaction.class deleted file mode 100644 index 03917c9..0000000 Binary files a/com.itjw.txviewer.database/bin/com/itjw/txviewer/database/ITransaction.class and /dev/null differ diff --git a/com.itjw.txviewer.database/bin/com/itjw/txviewer/database/InputFormatException.class b/com.itjw.txviewer.database/bin/com/itjw/txviewer/database/InputFormatException.class deleted file mode 100644 index 6745841..0000000 Binary files a/com.itjw.txviewer.database/bin/com/itjw/txviewer/database/InputFormatException.class and /dev/null differ diff --git a/com.itjw.txviewer.database/bin/com/itjw/txviewer/database/RelationType.class b/com.itjw.txviewer.database/bin/com/itjw/txviewer/database/RelationType.class deleted file mode 100644 index c4e81c3..0000000 Binary files a/com.itjw.txviewer.database/bin/com/itjw/txviewer/database/RelationType.class and /dev/null differ diff --git a/com.itjw.txviewer.database/src/com/itjw/txviewer/database/EventTime.java b/com.itjw.txviewer.database/src/com/itjw/txviewer/database/EventTime.java index 2f3a05f..43826e3 100644 --- a/com.itjw.txviewer.database/src/com/itjw/txviewer/database/EventTime.java +++ b/com.itjw.txviewer.database/src/com/itjw/txviewer/database/EventTime.java @@ -11,8 +11,11 @@ package com.itjw.txviewer.database; public class EventTime implements Comparable{ + 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{ 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"); } diff --git a/com.itjw.txviewer.database/src/com/itjw/txviewer/database/ITrAttrType.java b/com.itjw.txviewer.database/src/com/itjw/txviewer/database/ITrAttrType.java index e509ee4..1efbc1e 100644 --- a/com.itjw.txviewer.database/src/com/itjw/txviewer/database/ITrAttrType.java +++ b/com.itjw.txviewer.database/src/com/itjw/txviewer/database/ITrAttrType.java @@ -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(); } diff --git a/com.itjw.txviewer.database/src/com/itjw/txviewer/database/ITrDb.java b/com.itjw.txviewer.database/src/com/itjw/txviewer/database/ITrDb.java index de6813a..4b6e22c 100644 --- a/com.itjw.txviewer.database/src/com/itjw/txviewer/database/ITrDb.java +++ b/com.itjw.txviewer.database/src/com/itjw/txviewer/database/ITrDb.java @@ -18,6 +18,8 @@ public interface ITrDb extends ITrHierNode { public EventTime getMaxTime(); + public ITrStream getStreamByName(String name); + public List getAllStreams(); public void load(InputStream inp) throws InputFormatException; diff --git a/com.itjw.txviewer.database/src/com/itjw/txviewer/database/ITrRelation.java b/com.itjw.txviewer.database/src/com/itjw/txviewer/database/ITrRelation.java new file mode 100644 index 0000000..5b28b80 --- /dev/null +++ b/com.itjw.txviewer.database/src/com/itjw/txviewer/database/ITrRelation.java @@ -0,0 +1,10 @@ +package com.itjw.txviewer.database; + +public interface ITrRelation { + + RelationType getRelationType(); + + ITransaction getSource(); + + ITransaction getTarget(); +} diff --git a/com.itjw.txviewer.database/src/com/itjw/txviewer/database/ITransaction.java b/com.itjw.txviewer.database/src/com/itjw/txviewer/database/ITransaction.java index dd9d892..d41dbf5 100644 --- a/com.itjw.txviewer.database/src/com/itjw/txviewer/database/ITransaction.java +++ b/com.itjw.txviewer.database/src/com/itjw/txviewer/database/ITransaction.java @@ -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 getBeginAttrs(); - public List getEndAttrs(); + public List getAttributes(); - public Set getNextInRelationship(RelationType rel); + + public Collection getIncomingRelations(); + + public Collection getOutgoingRelations(); } diff --git a/com.itjw.txviewer.database/src/com/itjw/txviewer/database/ITransactionDbFactory.java b/com.itjw.txviewer.database/src/com/itjw/txviewer/database/ITransactionDbFactory.java new file mode 100644 index 0000000..85cc103 --- /dev/null +++ b/com.itjw.txviewer.database/src/com/itjw/txviewer/database/ITransactionDbFactory.java @@ -0,0 +1,7 @@ +package com.itjw.txviewer.database; + +public interface ITransactionDbFactory { + + ITrDb createDatabase(); + +} diff --git a/com.itjw.txviewer.database/src/com/itjw/txviewer/database/RelationType.java b/com.itjw.txviewer.database/src/com/itjw/txviewer/database/RelationType.java index aa7a572..2187490 100644 --- a/com.itjw.txviewer.database/src/com/itjw/txviewer/database/RelationType.java +++ b/com.itjw.txviewer.database/src/com/itjw/txviewer/database/RelationType.java @@ -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; + } + } diff --git a/com.itjw.txviewer.feature/feature.xml b/com.itjw.txviewer.feature/feature.xml index 191bbd7..fd70436 100644 --- a/com.itjw.txviewer.feature/feature.xml +++ b/com.itjw.txviewer.feature/feature.xml @@ -46,7 +46,7 @@ unpack="false"/> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/TrHierNodeSelection.java b/com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/TrHierNodeSelection.java deleted file mode 100644 index 72c0842..0000000 --- a/com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/TrHierNodeSelection.java +++ /dev/null @@ -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 selection = new ArrayList(); - - public TrHierNodeSelection(ITrHierNodeFacade node){ - selection.add(node); - } - - public TrHierNodeSelection(List nodes){ - selection.addAll(nodes); - } - - public void add(ITrHierNodeFacade node){ - selection.add(node); - } - - public void addAll(List nodes){ - selection.addAll(nodes); - } - - @Override - public boolean isEmpty() { - return selection.size()==0; - } - - @Override - public Object getFirstElement() { - return selection.get(0); - } - - @Override - public Iterator 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 toList() { - return selection; - } - -} diff --git a/com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/TransactionSelection.java b/com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/TransactionSelection.java deleted file mode 100644 index 78376a4..0000000 --- a/com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/TransactionSelection.java +++ /dev/null @@ -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 selection = new ArrayList(); - - public TransactionSelection(ITransactionFacade node){ - selection.add(node); - } - - public TransactionSelection(List 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 nodes){ - selection.addAll(nodes); - } - - @Override - public boolean isEmpty() { - return selection.size()==0; - } - - @Override - public ITransactionFacade getFirstElement() { - return (ITransactionFacade)selection.get(0); - } - - @Override - public Iterator iterator() { - return selection.iterator(); - } - - @Override - public int size() { - return selection.size(); - } - - @Override - public Object[] toArray() { - return selection.toArray(); - } - - @Override - public List toList() { - return selection; - } - -} diff --git a/com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/actions/AddToWave.java b/com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/actions/AddToWave.java deleted file mode 100644 index 932b540..0000000 --- a/com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/actions/AddToWave.java +++ /dev/null @@ -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"; - - -} diff --git a/com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/actions/TxActionFactory.java b/com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/actions/TxActionFactory.java deleted file mode 100644 index 1d5362a..0000000 --- a/com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/actions/TxActionFactory.java +++ /dev/null @@ -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 queue = new LinkedList(); - LinkedList streams = new LinkedList(); - 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; - } -} diff --git a/com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/data/ITrDbFacade.java b/com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/data/ITrDbFacade.java deleted file mode 100644 index 18f24e7..0000000 --- a/com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/data/ITrDbFacade.java +++ /dev/null @@ -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 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); - } - } - -} diff --git a/com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/data/ITrHierNodeFacade.java b/com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/data/ITrHierNodeFacade.java deleted file mode 100644 index 75f3930..0000000 --- a/com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/data/ITrHierNodeFacade.java +++ /dev/null @@ -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 getChildNodes() { - ArrayList res = new ArrayList(); - 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) { - } - -} diff --git a/com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/data/ITrStreamFacade.java b/com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/data/ITrStreamFacade.java deleted file mode 100644 index 92c757b..0000000 --- a/com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/data/ITrStreamFacade.java +++ /dev/null @@ -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 getGenerators() { - return getStream().getGenerators(); - } - - @Override - public List 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 "-"; - } - -} diff --git a/com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/data/ITransactionFacade.java b/com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/data/ITransactionFacade.java deleted file mode 100644 index d38ca4e..0000000 --- a/com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/data/ITransactionFacade.java +++ /dev/null @@ -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 getBeginAttrs() { - return iTransaction.getBeginAttrs(); - } - - @Override - public List getEndAttrs() { - return iTransaction.getEndAttrs(); - } - - @Override - public List getAttributes() { - return iTransaction.getAttributes(); - } - - @Override - public Set 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; - } -} diff --git a/com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/ui/swt/ListPane.java b/com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/ui/swt/ListPane.java deleted file mode 100644 index 04c8f83..0000000 --- a/com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/ui/swt/ListPane.java +++ /dev/null @@ -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 listeners = new ArrayList(); - - 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); - -} \ No newline at end of file diff --git a/com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/ui/swt/NameListPane.java b/com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/ui/swt/NameListPane.java deleted file mode 100644 index 5a717af..0000000 --- a/com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/ui/swt/NameListPane.java +++ /dev/null @@ -1,33 +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 org.eclipse.swt.widgets.Composite; - -import com.itjw.txviewer.graph.data.ITrStreamFacade; - -public class NameListPane extends ListPane { - - public NameListPane(Composite parent, TxDisplay txDisplay) { - super(parent, txDisplay); - } - - @Override - String getLabelValue(ITrStreamFacade str) { - return str.getFullName(); - } - - @Override - String getHeaderValue() { - return "Name"; - } - -} diff --git a/com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/ui/swt/SWTImageCanvas.java b/com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/ui/swt/SWTImageCanvas.java deleted file mode 100644 index 94059fa..0000000 --- a/com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/ui/swt/SWTImageCanvas.java +++ /dev/null @@ -1,386 +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.awt.geom.AffineTransform; -import java.awt.geom.Point2D; - -import org.eclipse.swt.events.ControlAdapter; -import org.eclipse.swt.events.ControlEvent; -import org.eclipse.swt.events.PaintEvent; -import org.eclipse.swt.events.PaintListener; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.graphics.GC; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.widgets.Canvas; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.ScrollBar; - -public class SWTImageCanvas extends Canvas { - /* zooming rates in x and y direction are equal.*/ - final float ZOOMIN_RATE = 1.1f; /* zoomin rate */ - final float ZOOMOUT_RATE = 0.9f; /* zoomout rate */ - protected Image sourceImage; /* original image */ - private Image screenImage; /* screen image */ - private AffineTransform transform = new AffineTransform(); - protected boolean center; - - - /** - * Constructor for ScrollableCanvas. - * @param parent the parent of this control. - * @param style the style of this control. - */ - public SWTImageCanvas(final Composite parent, int style) { - super( parent, style ); - center=true; - addControlListener(new ControlAdapter() { /* resize listener. */ - public void controlResized(ControlEvent event) { - syncScrollBars(); - } - }); - addPaintListener(new PaintListener() { /* paint listener. */ - public void paintControl(final PaintEvent event) { - paint(event.gc); - } - }); - initScrollBars(); - } - - /** - * Dispose the garbage here - */ - public void dispose() { - if (sourceImage != null && !sourceImage.isDisposed()) { - sourceImage.dispose(); - } - if (screenImage != null && !screenImage.isDisposed()) { - screenImage.dispose(); - } - } - - /* Paint function */ - private void paint(GC gc) { - Rectangle clientRect = getClientArea(); /* Canvas' painting area */ - if (sourceImage != null) { - Rectangle imageRect = inverseTransformRect(transform, clientRect); - int gap = 2; /* find a better start point to render */ - imageRect.x -= gap; imageRect.y -= gap; - imageRect.width += 2 * gap; imageRect.height += 2 * gap; - - Rectangle imageBound = sourceImage.getBounds(); - imageRect = imageRect.intersection(imageBound); - Rectangle destRect = transformRect(transform, imageRect); - - if (screenImage != null) screenImage.dispose(); - screenImage = new Image(getDisplay(), clientRect.width, clientRect.height); - GC newGC = new GC(screenImage); - newGC.setClipping(clientRect); - newGC.drawImage(sourceImage, - imageRect.x, imageRect.y, imageRect.width, imageRect.height, - destRect.x, destRect.y, destRect.width, destRect.height); - newGC.dispose(); - - gc.drawImage(screenImage, 0, 0); - - postImagePaint(gc); - } else { - gc.setClipping(clientRect); - gc.fillRectangle(clientRect); - initScrollBars(); - } - } - - protected void postImagePaint(GC gc){ - // do nothing, to be overridden by childs - } - - /* Initalize the scrollbar and register listeners. */ - private void initScrollBars() { - ScrollBar horizontal = getHorizontalBar(); - horizontal.setEnabled(false); - horizontal.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent event) { - scrollHorizontally((ScrollBar) event.widget); - } - }); - ScrollBar vertical = getVerticalBar(); - vertical.setEnabled(false); - vertical.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent event) { - scrollVertically((ScrollBar) event.widget); - } - }); - } - - /* Scroll horizontally */ - private void scrollHorizontally(ScrollBar scrollBar) { - if (sourceImage == null) return; - - AffineTransform af = transform; - double tx = af.getTranslateX(); - double select = -scrollBar.getSelection(); - af.preConcatenate(AffineTransform.getTranslateInstance(select - tx, 0)); - transform = af; - syncScrollBars(); - } - - /* Scroll vertically */ - private void scrollVertically(ScrollBar scrollBar) { - if (sourceImage == null) return; - - AffineTransform af = transform; - double ty = af.getTranslateY(); - double select = -scrollBar.getSelection(); - af.preConcatenate(AffineTransform.getTranslateInstance(0, select - ty)); - transform = af; - syncScrollBars(); - } - - public void scrollToY(int y){ - ScrollBar vBar = getVerticalBar(); - vBar.setSelection(y); - scrollVertically(vBar); - } - - public void scrollToX(int x){ - ScrollBar hBar = getHorizontalBar(); - hBar.setSelection(x); - scrollHorizontally(hBar); - } - - /** - * Source image getter. - * @return sourceImage. - */ - public Image getSourceImage() { - return sourceImage; - } - - /** - * Source image setter. - * @return sourceImage. - */ - public void setSourceImage(Image sourceImage) { - if(this.sourceImage!=null) this.sourceImage.dispose(); - this.sourceImage=sourceImage; - } - - public AffineTransform getTransform() { - return transform; - } - - /** - * Synchronize the scrollbar with the image. If the transform is out - * of range, it will correct it. This function considers only following - * factors : transform, image size, client area. - */ - public void syncScrollBars() { - if (sourceImage == null) { - redraw(); - return; - } - - AffineTransform af = transform; - double sx = af.getScaleX(), sy = af.getScaleY(); - double tx = af.getTranslateX(), ty = af.getTranslateY(); - if (tx > 0) tx = 0; - if (ty > 0) ty = 0; - - ScrollBar horizontal = getHorizontalBar(); - horizontal.setIncrement((int) (getClientArea().width / 100)); - horizontal.setPageIncrement(getClientArea().width); - Rectangle imageBound = sourceImage.getBounds(); - int cw = getClientArea().width, ch = getClientArea().height; - if (imageBound.width * sx > cw) { /* image is wider than client area */ - horizontal.setMaximum((int) (imageBound.width * sx)); - horizontal.setEnabled(true); - if (((int) - tx) > horizontal.getMaximum() - cw) - tx = -horizontal.getMaximum() + cw; - } else { /* image is narrower than client area */ - horizontal.setEnabled(false); - tx = center?((cw - imageBound.width * sx) / 2):0; //center or put left if too small. - } - horizontal.setSelection((int) (-tx)); - horizontal.setThumb((int) (getClientArea().width)); - - ScrollBar vertical = getVerticalBar(); - vertical.setIncrement((int) (getClientArea().height / 100)); - vertical.setPageIncrement((int) (getClientArea().height)); - if (imageBound.height * sy > ch) { /* image is higher than client area */ - vertical.setMaximum((int) (imageBound.height * sy)); - vertical.setEnabled(true); - if (((int) - ty) > vertical.getMaximum() - ch) - ty = -vertical.getMaximum() + ch; - } else { /* image is less higher than client area */ - vertical.setEnabled(false); - ty = center?((ch - imageBound.height * sy) / 2):0; //center or put top if too small. - } - vertical.setSelection((int) (-ty)); - vertical.setThumb((int) (getClientArea().height)); - - /* update transform. */ - af = AffineTransform.getScaleInstance(sx, sy); - af.preConcatenate(AffineTransform.getTranslateInstance(tx, ty)); - transform = af; - - redraw(); - } - - /** - * Fit the image onto the canvas - */ - public void fitCanvas() { - if (sourceImage == null) return; - Rectangle imageBound = sourceImage.getBounds(); - Rectangle destRect = getClientArea(); - double sx = (double) destRect.width / (double) imageBound.width; - double sy = (double) destRect.height / (double) imageBound.height; - double s = Math.min(sx, sy); - double dx = 0.5 * destRect.width; - double dy = 0.5 * destRect.height; - centerZoom(dx, dy, s, new AffineTransform()); - } - - /** - * Show the image with the original size - */ - public void resetTransform() { - if (sourceImage == null) return; - transform = new AffineTransform(); - syncScrollBars(); - } - - /** - * Perform a zooming operation centered on the given point - * (dx, dy) and using the given scale factor. - * The given AffineTransform instance is preconcatenated. - * @param dx center x - * @param dy center y - * @param scale zoom rate - * @param af original affinetransform - */ - public void centerZoom(double dx, double dy, double scale, AffineTransform af) { - af.preConcatenate(AffineTransform.getTranslateInstance(-dx, -dy)); - af.preConcatenate(AffineTransform.getScaleInstance(scale, scale)); - af.preConcatenate(AffineTransform.getTranslateInstance(dx, dy)); - transform = af; - syncScrollBars(); - } - - /** - * Zoom in around the center of client Area. - */ - public void zoomIn() { - if (sourceImage == null) return; - Rectangle rect = getClientArea(); - int w = rect.width, h = rect.height; - double dx = ((double) w) / 2; - double dy = ((double) h) / 2; - centerZoom(dx, dy, ZOOMIN_RATE, transform); - } - - /** - * Zoom out around the center of client Area. - */ - public void zoomOut() { - if (sourceImage == null) return; - Rectangle rect = getClientArea(); - int w = rect.width, h = rect.height; - double dx = ((double) w) / 2; - double dy = ((double) h) / 2; - centerZoom(dx, dy, ZOOMOUT_RATE, transform); - } - - /** - * Given an arbitrary rectangle, get the rectangle with the given transform. - * The result rectangle is positive width and positive height. - * @param af AffineTransform - * @param src source rectangle - * @return rectangle after transform with positive width and height - */ - protected static Rectangle transformRect(AffineTransform af, Rectangle src){ - Rectangle dest= new Rectangle(0,0,0,0); - src=absRect(src); - Point p1=new Point(src.x,src.y); - p1=transformPoint(af,p1); - dest.x=p1.x; dest.y=p1.y; - dest.width=(int)(src.width*af.getScaleX()); - dest.height=(int)(src.height*af.getScaleY()); - return dest; - } - - /** - * Given an arbitrary rectangle, get the rectangle with the inverse given transform. - * The result rectangle is positive width and positive height. - * @param af AffineTransform - * @param src source rectangle - * @return rectangle after transform with positive width and height - */ - protected static Rectangle inverseTransformRect(AffineTransform af, Rectangle src){ - Rectangle dest= new Rectangle(0,0,0,0); - src=absRect(src); - Point p1=new Point(src.x,src.y); - p1=inverseTransformPoint(af,p1); - dest.x=p1.x; dest.y=p1.y; - dest.width=(int)(src.width/af.getScaleX()); - dest.height=(int)(src.height/af.getScaleY()); - return dest; - } - /** - * Given an arbitrary point, get the point with the given transform. - * @param af affine transform - * @param pt point to be transformed - * @return point after tranform - */ - protected static Point transformPoint(AffineTransform af, Point pt) { - Point2D src = new Point2D.Float(pt.x, pt.y); - Point2D dest= af.transform(src, null); - Point point=new Point((int)Math.floor(dest.getX()), (int)Math.floor(dest.getY())); - return point; - } - - /** - * Given an arbitrary point, get the point with the inverse given transform. - * @param af AffineTransform - * @param pt source point - * @return point after transform - */ - protected static Point inverseTransformPoint(AffineTransform af, Point pt){ - Point2D src=new Point2D.Float(pt.x,pt.y); - try{ - Point2D dest= af.inverseTransform(src, null); - return new Point((int)Math.floor(dest.getX()), (int)Math.floor(dest.getY())); - }catch (Exception e){ - e.printStackTrace(); - return new Point(0,0); - } - } - - /** - * Given arbitrary rectangle, return a rectangle with upper-left - * start and positive width and height. - * @param src source rectangle - * @return result rectangle with positive width and height - */ - protected static Rectangle absRect(Rectangle src){ - Rectangle dest= new Rectangle(0,0,0,0); - if(src.width<0) { dest.x=src.x+src.width+1; dest.width=-src.width; } - else{ dest.x=src.x; dest.width=src.width; } - if(src.height<0) { dest.y=src.y+src.height+1; dest.height=-src.height; } - else{ dest.y=src.y; dest.height=src.height; } - return dest; - } - -} diff --git a/com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/ui/swt/TxDisplay.java b/com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/ui/swt/TxDisplay.java deleted file mode 100644 index cb32baf..0000000 --- a/com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/ui/swt/TxDisplay.java +++ /dev/null @@ -1,180 +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 org.eclipse.core.runtime.ListenerList; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.SashForm; -import org.eclipse.swt.events.MouseAdapter; -import org.eclipse.swt.events.MouseEvent; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.ScrollBar; -import org.eclipse.ui.IWorkbenchPartSite; - -import com.itjw.txviewer.database.ITrStream; -import com.itjw.txviewer.database.ITransaction; -import com.itjw.txviewer.graph.TrHierNodeSelection; -import com.itjw.txviewer.graph.TransactionSelection; -import com.itjw.txviewer.graph.TxEditorPart; -import com.itjw.txviewer.graph.data.ITrDbFacade; -import com.itjw.txviewer.graph.data.ITrStreamFacade; -import com.itjw.txviewer.graph.data.ITransactionFacade; - -public class TxDisplay implements PropertyChangeListener, ISelectionProvider{ - - private TxEditorPart txEditor; - private SashForm sashFormTop; - private ListPane txNamePane; - private ListPane txValuePane; - private WaveImageCanvas waveImageCanvas; - - private ListenerList listeners = new ListenerList(); - private ITrStreamFacade currentStreamSelection; - private ITransactionFacade currentSelection; - - public TxDisplay(Composite parent, TxEditorPart txEditorPart, IWorkbenchPartSite site) { - txEditor = txEditorPart; - sashFormTop = new SashForm(parent, SWT.HORIZONTAL+SWT.BORDER); - sashFormTop.setLayoutData(new GridData(GridData.FILL_BOTH)); - final SashForm sashFormLeft = new SashForm(sashFormTop, SWT.HORIZONTAL); - txNamePane = new NameListPane(sashFormLeft, this); - txNamePane.addLabelClickListener(this); - txValuePane = new ValueListPane(sashFormLeft, this); - txValuePane.addLabelClickListener(this); - waveImageCanvas = new WaveImageCanvas(sashFormTop, SWT.DOUBLE_BUFFERED|SWT.H_SCROLL|SWT.V_SCROLL); - waveImageCanvas.addMouseListener(new MouseAdapter() { - @Override - public void mouseUp(MouseEvent e) { - currentSelection = waveImageCanvas.getTransactionAtPos(new Point(e.x, e.y)); - waveImageCanvas.setCurrentSelection(currentSelection); - if(currentSelection!=null || currentStreamSelection!=null) - setSelection(getSelection()); - else - setSelection(StructuredSelection.EMPTY); - } - }); - txNamePane.scroll.getVerticalBar().addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - int y = ((ScrollBar) e.widget).getSelection(); - txValuePane.scrollToY(y); - waveImageCanvas.scrollToY(y); - } - }); - txValuePane.scroll.getVerticalBar().addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - int y = ((ScrollBar) e.widget).getSelection(); - txNamePane.scrollToY(y); - waveImageCanvas.scrollToY(y); - } - }); - waveImageCanvas.getVerticalBar().addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - int y = ((ScrollBar) e.widget).getSelection(); - txNamePane.scrollToY(y); - txValuePane.scrollToY(y); - } - }); - - sashFormTop.setWeights(new int[] {30, 70}); - sashFormLeft.setWeights(new int[] {75, 25}); - - if(txEditor.getModel()!= null) - streamListChanged(); - } - - public TxEditorPart getTxEditor() { - return txEditor; - } - - public void streamListChanged() { - waveImageCanvas.setWaveformList(getTxEditor().getStreamList()); - txNamePane.streamListChanged(); - txValuePane.streamListChanged(); - sashFormTop.redraw(); - } - - public void addSelectionListener(SelectionListener listener) { - waveImageCanvas.addSelectionListener(listener); - } - - @Override - public void propertyChange(PropertyChangeEvent pce) { - if(pce.getPropertyName().equals(ITrDbFacade.DATABASE)){ - streamListChanged(); - }else if(pce.getPropertyName().equals(ListPane.SELECTION)){ - currentSelection=null; - ITrStream str = (ITrStream)pce.getNewValue(); - if(str instanceof ITrStreamFacade) - currentStreamSelection=(ITrStreamFacade)str; - else - currentStreamSelection=new ITrStreamFacade(str); - if(currentStreamSelection!=null) - setSelection(getSelection()); - else - setSelection(StructuredSelection.EMPTY); - } - - } - - @Override - public void addSelectionChangedListener(ISelectionChangedListener listener) { - listeners.add(listener); - } - - @Override - public ISelection getSelection() { - if(currentSelection!=null) - return new TransactionSelection(currentSelection); - else if(currentStreamSelection!=null) - return new TrHierNodeSelection(currentStreamSelection); - else - return null; - } - - @Override - public void removeSelectionChangedListener(ISelectionChangedListener listener) { - listeners.remove(listener); - } - - @Override - public void setSelection(ISelection selection) { - if(selection instanceof TransactionSelection){ - ITransaction tr =((TransactionSelection)selection).getFirstElement(); - currentSelection = (tr instanceof ITransactionFacade)?(ITransactionFacade)tr:new ITransactionFacade(tr); - } - Object[] list = listeners.getListeners(); - for (int i = 0; i < list.length; i++) { - ((ISelectionChangedListener) list[i]).selectionChanged(new SelectionChangedEvent(this, selection)); - } - if(waveImageCanvas.getCurrentSelection()!=currentSelection) - waveImageCanvas.setCurrentSelection(currentSelection); - waveImageCanvas.getDisplay().asyncExec(new Runnable() { - @Override - public void run() { - waveImageCanvas.redraw(); - } - }); - } - -} diff --git a/com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/ui/swt/ValueListPane.java b/com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/ui/swt/ValueListPane.java deleted file mode 100644 index 1ab6f92..0000000 --- a/com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/ui/swt/ValueListPane.java +++ /dev/null @@ -1,40 +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 org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; - -import com.itjw.txviewer.graph.data.ITrStreamFacade; - -public class ValueListPane extends ListPane { - - public ValueListPane(Composite parent, TxDisplay txDisplay) { - super(parent, txDisplay); - } - - @Override - String getLabelValue(ITrStreamFacade str) { - return str.getValueAtCursor(0); - } - - @Override - String getHeaderValue() { - return "Value"; - } - - protected void formatLabel(Label l, ITrStreamFacade str, int trackIdx){ - super.formatLabel(l, str, trackIdx); - l.setAlignment(SWT.CENTER); - } - -} diff --git a/com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/ui/swt/WaveImageCanvas.java b/com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/ui/swt/WaveImageCanvas.java deleted file mode 100644 index 101fda0..0000000 --- a/com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/ui/swt/WaveImageCanvas.java +++ /dev/null @@ -1,223 +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.util.Iterator; -import java.util.LinkedList; -import java.util.TreeMap; -import java.util.Vector; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.graphics.GC; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.TypedListener; - -import com.itjw.txviewer.database.ITransaction; -import com.itjw.txviewer.graph.TxEditorPlugin; -import com.itjw.txviewer.graph.data.ITrStreamFacade; -import com.itjw.txviewer.graph.data.ITransactionFacade; - -public class WaveImageCanvas extends SWTImageCanvas{ - - static final int rulerHeight = 20; - static final int rulerTickMinor = 10; - static final int rulerTickMajor = 100; - static final int trackHeight = 50; - static final int trackInset =2; - static final int txHeight = trackHeight-2*trackInset; - - private TxEditorPlugin plugin; - private Rectangle size = new Rectangle(0,0,0,0); - private TreeMap loc2str; - private TreeMap strId2bb; - - private ITransactionFacade currentSelection; - - public WaveImageCanvas(final Composite parent) { - this(parent, SWT.NONE); - } - - public WaveImageCanvas(final Composite parent, int style) { - super(parent, style | SWT.V_SCROLL | SWT.H_SCROLL | SWT.NO_BACKGROUND); - plugin=TxEditorPlugin.getDefault(); - loc2str=new TreeMap(); - strId2bb=new TreeMap(); - center=false; - } - - public void setWaveformList(LinkedList linkedList){ - double maxTime=1.0; - int height=rulerHeight; - for(ITrStreamFacade str:linkedList){ - maxTime = Math.max(maxTime, str.getDb().getMaxTime().getValueNS()); - int strHeight=str.getMaxConcurrrentTx(); - str.setHeight(strHeight*trackHeight); - height+=str.getHeight(); - } - size = new Rectangle(0,0,(int) Math.ceil(maxTime),height); - Image buffer = new Image(getDisplay(), size); - GC gc = new GC(buffer); - gc.setAntialias(SWT.ON); - int trackOffset=rulerHeight; - int trackIdx=0; - Vector rowendtime = new Vector(); - loc2str.clear(); - strId2bb.clear(); - for(ITrStreamFacade str:linkedList){ - loc2str.put(trackOffset, str); - rowendtime.clear(); - rowendtime.add(0); - drawTrack(gc, new Rectangle(0, trackOffset, size.width, trackHeight), trackIdx); - for(ITransaction tx: str.getTransactions()){ - int rowIdx=0; - Integer beginTime = (int)(tx.getBeginTime().getValueNS()); - Integer endTime = (int)(tx.getEndTime().getValueNS()); - for(rowIdx=0; rowendtime.size()beginTime; rowIdx++); - if(rowendtime.size()<=rowIdx){ - rowendtime.add(endTime!=null?endTime:beginTime+1); - drawTrack(gc, new Rectangle(0, trackOffset+rowIdx*trackHeight, size.width, trackHeight), trackIdx); - } else { - rowendtime.set(rowIdx, endTime!=null?endTime:beginTime+1); - } - int width = endTime!=null?endTime-beginTime:1; - Rectangle bb = new Rectangle(beginTime, trackOffset+rowIdx*trackHeight+trackInset, width, txHeight); - strId2bb.put(tx.getId(), bb); - drawTx(gc, bb); - } - trackOffset+=rowendtime.size()*trackHeight; - trackIdx++; - } - gc.dispose(); - setSourceImage(buffer); - redraw(); - syncScrollBars(); - } - - private void drawTx(GC gc, Rectangle bb){ - gc.setForeground(plugin.getColor(TxEditorPlugin.lineColor)); - gc.setFillRule(SWT.FILL_EVEN_ODD); - gc.setBackground(plugin.getColor(TxEditorPlugin.txBgColor)); - gc.setLineWidth(1); - gc.setLineStyle(SWT.LINE_SOLID); - if(bb.width<8){ - gc.fillRectangle(bb); - gc.drawRectangle(bb); - } else { - gc.fillRoundRectangle(bb.x, bb.y, bb.width, bb.height, 4, 4); - gc.drawRoundRectangle(bb.x, bb.y, bb.width, bb.height, 4, 4); - } - } - - private void drawHighliteTx(GC gc, Rectangle bb){ - gc.setForeground(plugin.getColor(TxEditorPlugin.highliteLineColor)); - gc.setFillRule(SWT.FILL_EVEN_ODD); - gc.setBackground(plugin.getColor(TxEditorPlugin.txHighliteBgColor)); - gc.setLineWidth(1); - gc.setLineStyle(SWT.LINE_SOLID); - if(bb.width<10){ - gc.fillRectangle(bb); - gc.drawRectangle(bb); - } else { - gc.fillRoundRectangle(bb.x, bb.y, bb.width, bb.height, 5, 5); - gc.drawRoundRectangle(bb.x, bb.y, bb.width, bb.height, 5, 5); - } - } - - private void drawTrack(GC gc, Rectangle bb, int trackIdx){ - gc.setForeground(plugin.getColor(TxEditorPlugin.lineColor)); - gc.setFillRule(SWT.FILL_EVEN_ODD); - gc.setBackground(trackIdx%2==0? - plugin.getColor(TxEditorPlugin.trackBgLightColor): - plugin.getColor(TxEditorPlugin.trackBgDarkColor)); - gc.setLineWidth(1); - gc.setLineStyle(SWT.LINE_SOLID); - gc.fillRectangle(bb); - gc.drawLine(bb.x, bb.y+bb.height/2, bb.width, bb.y+bb.height/2); - } - - protected void postImagePaint(GC gc){ - Rectangle imageRect = inverseTransformRect(getTransform(), getClientArea()); - if(currentSelection!=null){ - Rectangle bb = strId2bb.get(currentSelection.getId()); - if(bb != null) { - drawHighliteTx(gc, new Rectangle(bb.x-imageRect.x, bb.y-imageRect.y, bb.width, bb.height)); - } else - System.err.print("No bounding box for transaction "+currentSelection.getId()+" found!"); - } - drawRuler(gc, imageRect); - } - - private void drawRuler(GC gc, Rectangle clientRect) { - int startMinorIncr = ((int)(clientRect.x/rulerTickMinor))*rulerTickMinor; - gc.setBackground(getDisplay().getSystemColor (SWT.COLOR_WIDGET_BACKGROUND)); - gc.fillRectangle(new Rectangle(-clientRect.x, 0, clientRect.width, rulerHeight)); - gc.setBackground(plugin.getColor(TxEditorPlugin.headerBgColor)); - gc.fillRectangle(new Rectangle(-clientRect.x, 0, clientRect.width, rulerHeight-1)); - gc.setForeground(plugin.getColor(TxEditorPlugin.headerFgColor)); - gc.drawLine(-clientRect.x, rulerHeight-2, clientRect.width+clientRect.x, rulerHeight-2); - for(int x=startMinorIncr; x<(clientRect.x+clientRect.width); x+=rulerTickMinor){ - if((x%rulerTickMajor)==0){ - gc.drawLine(x-clientRect.x, 10, x-clientRect.x, rulerHeight-2); - gc.drawText(Integer.toString(x), x-clientRect.x, 0); - }else{ - gc.drawLine(x-clientRect.x, 15, x-clientRect.x, rulerHeight-2); - } - } - } - - private ITransaction getTrAtTime(ITrStreamFacade str, double t){ - ITransaction res=null; - Iterator iter = str.getTransactions().iterator(); - while(iter.hasNext()){ - res = iter.next(); - if(res.getEndTime().getValueNS()>=t) break; - } - if(res!=null && res.getBeginTime().getValueNS()-10 { - private A first; - private B second; - - public Pair(A first, B second) { - super(); - this.first = first; - this.second = second; - } - - public int hashCode() { - int hashFirst = first != null ? first.hashCode() : 0; - int hashSecond = second != null ? second.hashCode() : 0; - - return (hashFirst + hashSecond) * hashSecond + hashFirst; - } - - @SuppressWarnings("unchecked") - public boolean equals(Object other) { - if (other instanceof Pair) { - Pair otherPair = (Pair)other; - return - (( this.first == otherPair.first || - ( this.first != null && otherPair.first != null && - this.first.equals(otherPair.first))) && - ( this.second == otherPair.second || - ( this.second != null && otherPair.second != null && - this.second.equals(otherPair.second))) ); - } - - return false; - } - - public String toString() - { - return "(" + first + ", " + second + ")"; - } - - public A getFirst() { - return first; - } - - public void setFirst(A first) { - this.first = first; - } - - public B getSecond() { - return second; - } - - public void setSecond(B second) { - this.second = second; - } -} diff --git a/com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/views/TxDbView.java b/com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/views/TxDbView.java deleted file mode 100644 index 91e0f13..0000000 --- a/com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/views/TxDbView.java +++ /dev/null @@ -1,304 +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.views; - -import java.util.ArrayList; - -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.part.*; -import org.eclipse.jface.viewers.*; -import org.eclipse.swt.graphics.Image; -import org.eclipse.jface.action.*; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.ui.*; -import org.eclipse.swt.widgets.Menu; -import org.eclipse.swt.SWT; -import org.eclipse.core.runtime.IAdaptable; - - -/** - * This sample class demonstrates how to plug-in a new - * workbench view. The view shows data obtained from the - * model. The sample creates a dummy model on the fly, - * but a real implementation would connect to the model - * available either in this or another plug-in (e.g. the workspace). - * The view is connected to the model using a content provider. - *

- * The view uses a label provider to define how model - * objects should be presented in the view. Each - * view can present the same model objects using - * different labels and icons, if needed. Alternatively, - * a single label provider can be shared between views - * in order to ensure that objects of the same type are - * presented in the same way everywhere. - *

- */ - -public class TxDbView extends ViewPart { - - /** - * The ID of the view as specified by the extension. - */ - public static final String ID = "com.itjw.txviewer.graph.views.TxDbView"; - - private TreeViewer viewer; - private DrillDownAdapter drillDownAdapter; - private Action action1; - private Action action2; - private Action doubleClickAction; - - /* - * The content provider class is responsible for - * providing objects to the view. It can wrap - * existing objects in adapters or simply return - * objects as-is. These objects may be sensitive - * to the current input of the view, or ignore - * it and always show the same content - * (like Task List, for example). - */ - - class TreeObject implements IAdaptable { - private String name; - private TreeParent parent; - - public TreeObject(String name) { - this.name = name; - } - public String getName() { - return name; - } - public void setParent(TreeParent parent) { - this.parent = parent; - } - public TreeParent getParent() { - return parent; - } - public String toString() { - return getName(); - } - @SuppressWarnings("rawtypes") - public Object getAdapter(Class key) { - return null; - } - } - - class TreeParent extends TreeObject { - private ArrayList children; - public TreeParent(String name) { - super(name); - children = new ArrayList(); - } - public void addChild(TreeObject child) { - children.add(child); - child.setParent(this); - } - public void removeChild(TreeObject child) { - children.remove(child); - child.setParent(null); - } - public TreeObject [] getChildren() { - return children.toArray(new TreeObject[children.size()]); - } - public boolean hasChildren() { - return children.size()>0; - } - } - - class ViewContentProvider implements IStructuredContentProvider, - ITreeContentProvider { - private TreeParent invisibleRoot; - - public void inputChanged(Viewer v, Object oldInput, Object newInput) { - } - public void dispose() { - } - public Object[] getElements(Object parent) { - if (parent.equals(getViewSite())) { - if (invisibleRoot==null) initialize(); - return getChildren(invisibleRoot); - } - return getChildren(parent); - } - public Object getParent(Object child) { - if (child instanceof TreeObject) { - return ((TreeObject)child).getParent(); - } - return null; - } - public Object [] getChildren(Object parent) { - if (parent instanceof TreeParent) { - return ((TreeParent)parent).getChildren(); - } - return new Object[0]; - } - public boolean hasChildren(Object parent) { - if (parent instanceof TreeParent) - return ((TreeParent)parent).hasChildren(); - return false; - } -/* - * We will set up a dummy model to initialize tree heararchy. - * In a real code, you will connect to a real model and - * expose its hierarchy. - */ - private void initialize() { - TreeObject to1 = new TreeObject("Leaf 1"); - TreeObject to2 = new TreeObject("Leaf 2"); - TreeObject to3 = new TreeObject("Leaf 3"); - TreeParent p1 = new TreeParent("Parent 1"); - p1.addChild(to1); - p1.addChild(to2); - p1.addChild(to3); - - TreeObject to4 = new TreeObject("Leaf 4"); - TreeParent p2 = new TreeParent("Parent 2"); - p2.addChild(to4); - - TreeParent root = new TreeParent("Root"); - root.addChild(p1); - root.addChild(p2); - - invisibleRoot = new TreeParent(""); - invisibleRoot.addChild(root); - } - } - class ViewLabelProvider extends LabelProvider { - - public String getText(Object obj) { - return obj.toString(); - } - public Image getImage(Object obj) { - String imageKey = ISharedImages.IMG_OBJ_ELEMENT; - if (obj instanceof TreeParent) - imageKey = ISharedImages.IMG_OBJ_FOLDER; - return PlatformUI.getWorkbench().getSharedImages().getImage(imageKey); - } - } - class NameSorter extends ViewerSorter { - } - - /** - * The constructor. - */ - public TxDbView() { - } - - /** - * This is a callback that will allow us - * to create the viewer and initialize it. - */ - public void createPartControl(Composite parent) { - viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); - drillDownAdapter = new DrillDownAdapter(viewer); - viewer.setContentProvider(new ViewContentProvider()); - viewer.setLabelProvider(new ViewLabelProvider()); - viewer.setSorter(new NameSorter()); - viewer.setInput(getViewSite()); - - // Create the help context id for the viewer's control - PlatformUI.getWorkbench().getHelpSystem().setHelp(viewer.getControl(), "com.itjw.txviewer.graph.viewer"); - makeActions(); - hookContextMenu(); - hookDoubleClickAction(); - contributeToActionBars(); - } - - private void hookContextMenu() { - MenuManager menuMgr = new MenuManager("#PopupMenu"); - menuMgr.setRemoveAllWhenShown(true); - menuMgr.addMenuListener(new IMenuListener() { - public void menuAboutToShow(IMenuManager manager) { - TxDbView.this.fillContextMenu(manager); - } - }); - Menu menu = menuMgr.createContextMenu(viewer.getControl()); - viewer.getControl().setMenu(menu); - getSite().registerContextMenu(menuMgr, viewer); - } - - private void contributeToActionBars() { - IActionBars bars = getViewSite().getActionBars(); - fillLocalPullDown(bars.getMenuManager()); - fillLocalToolBar(bars.getToolBarManager()); - } - - private void fillLocalPullDown(IMenuManager manager) { - manager.add(action1); - manager.add(new Separator()); - manager.add(action2); - } - - private void fillContextMenu(IMenuManager manager) { - manager.add(action1); - manager.add(action2); - manager.add(new Separator()); - drillDownAdapter.addNavigationActions(manager); - // Other plug-ins can contribute there actions here - manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); - } - - private void fillLocalToolBar(IToolBarManager manager) { - manager.add(action1); - manager.add(action2); - manager.add(new Separator()); - drillDownAdapter.addNavigationActions(manager); - } - - private void makeActions() { - action1 = new Action() { - public void run() { - showMessage("Action 1 executed"); - } - }; - action1.setText("Action 1"); - action1.setToolTipText("Action 1 tooltip"); - action1.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages(). - getImageDescriptor(ISharedImages.IMG_OBJS_INFO_TSK)); - - action2 = new Action() { - public void run() { - showMessage("Action 2 executed"); - } - }; - action2.setText("Action 2"); - action2.setToolTipText("Action 2 tooltip"); - action2.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages(). - getImageDescriptor(ISharedImages.IMG_OBJS_INFO_TSK)); - doubleClickAction = new Action() { - public void run() { - ISelection selection = viewer.getSelection(); - Object obj = ((IStructuredSelection)selection).getFirstElement(); - showMessage("Double-click detected on "+obj.toString()); - } - }; - } - - private void hookDoubleClickAction() { - viewer.addDoubleClickListener(new IDoubleClickListener() { - public void doubleClick(DoubleClickEvent event) { - doubleClickAction.run(); - } - }); - } - private void showMessage(String message) { - MessageDialog.openInformation( - viewer.getControl().getShell(), - "Transaction Database View", - message); - } - - /** - * Passing the focus request to the viewer's control. - */ - public void setFocus() { - viewer.getControl().setFocus(); - } -} \ No newline at end of file diff --git a/com.itjw.txviewer.graph/.classpath b/com.itjw.txviewer.ui/.classpath similarity index 83% rename from com.itjw.txviewer.graph/.classpath rename to com.itjw.txviewer.ui/.classpath index 8586d88..a8ac72c 100644 --- a/com.itjw.txviewer.graph/.classpath +++ b/com.itjw.txviewer.ui/.classpath @@ -3,6 +3,6 @@ - + diff --git a/com.itjw.txviewer.ui/.gitignore b/com.itjw.txviewer.ui/.gitignore new file mode 100644 index 0000000..5e56e04 --- /dev/null +++ b/com.itjw.txviewer.ui/.gitignore @@ -0,0 +1 @@ +/bin diff --git a/com.itjw.txviewer.graph/.project b/com.itjw.txviewer.ui/.project similarity index 94% rename from com.itjw.txviewer.graph/.project rename to com.itjw.txviewer.ui/.project index 28dd19b..a9813dd 100644 --- a/com.itjw.txviewer.graph/.project +++ b/com.itjw.txviewer.ui/.project @@ -1,6 +1,6 @@ - com.itjw.txviewer.graph + com.itjw.txviewer.ui diff --git a/com.itjw.txviewer.ui/.settings/org.eclipse.jdt.groovy.core.prefs b/com.itjw.txviewer.ui/.settings/org.eclipse.jdt.groovy.core.prefs new file mode 100644 index 0000000..a7f72ec --- /dev/null +++ b/com.itjw.txviewer.ui/.settings/org.eclipse.jdt.groovy.core.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +groovy.compiler.level=23 diff --git a/com.itjw.txviewer.graph/META-INF/MANIFEST.MF b/com.itjw.txviewer.ui/META-INF/MANIFEST.MF similarity index 59% rename from com.itjw.txviewer.graph/META-INF/MANIFEST.MF rename to com.itjw.txviewer.ui/META-INF/MANIFEST.MF index 6d500d7..578261a 100644 --- a/com.itjw.txviewer.graph/META-INF/MANIFEST.MF +++ b/com.itjw.txviewer.ui/META-INF/MANIFEST.MF @@ -1,9 +1,9 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Graph -Bundle-SymbolicName: com.itjw.txviewer.graph; singleton:=true +Bundle-SymbolicName: com.itjw.txviewer.ui;singleton:=true Bundle-Version: 1.0.0.qualifier -Bundle-Activator: com.itjw.txviewer.graph.TxEditorPlugin +Bundle-Activator: com.itjw.txviewer.ui.TxEditorPlugin Bundle-Vendor: ITJW Require-Bundle: org.eclipse.ui, org.eclipse.core.runtime, @@ -12,8 +12,12 @@ Require-Bundle: org.eclipse.ui, org.eclipse.ui.editors, org.eclipse.ui.ide, org.eclipse.gef, - org.eclipse.ui.views.properties.tabbed -Bundle-RequiredExecutionEnvironment: JavaSE-1.6 + org.eclipse.ui.views.properties.tabbed, + org.eclipse.swt, + org.eclipse.osgi +Bundle-RequiredExecutionEnvironment: JavaSE-1.7 Bundle-ActivationPolicy: lazy Import-Package: com.itjw.txviewer.database, org.eclipse.ui.views.contentoutline +Bundle-ClassPath: ., + swing2swt.jar diff --git a/com.itjw.txviewer.graph/build.properties b/com.itjw.txviewer.ui/build.properties similarity index 75% rename from com.itjw.txviewer.graph/build.properties rename to com.itjw.txviewer.ui/build.properties index c4166fb..02d6e35 100644 --- a/com.itjw.txviewer.graph/build.properties +++ b/com.itjw.txviewer.ui/build.properties @@ -5,4 +5,5 @@ bin.includes = plugin.xml,\ .,\ icons/,\ contexts.xml,\ - res/ + res/,\ + swing2swt.jar diff --git a/com.itjw.txviewer.graph/contexts.xml b/com.itjw.txviewer.ui/contexts.xml similarity index 100% rename from com.itjw.txviewer.graph/contexts.xml rename to com.itjw.txviewer.ui/contexts.xml diff --git a/com.itjw.txviewer.graph/icons/sample.gif b/com.itjw.txviewer.ui/icons/sample.gif similarity index 100% rename from com.itjw.txviewer.graph/icons/sample.gif rename to com.itjw.txviewer.ui/icons/sample.gif diff --git a/com.itjw.txviewer.ui/plugin.xml b/com.itjw.txviewer.ui/plugin.xml new file mode 100644 index 0000000..6d036a9 --- /dev/null +++ b/com.itjw.txviewer.ui/plugin.xml @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/com.itjw.txviewer.graph/res/images/database.png b/com.itjw.txviewer.ui/res/images/database.png similarity index 100% rename from com.itjw.txviewer.graph/res/images/database.png rename to com.itjw.txviewer.ui/res/images/database.png diff --git a/com.itjw.txviewer.graph/res/images/folder.png b/com.itjw.txviewer.ui/res/images/folder.png similarity index 100% rename from com.itjw.txviewer.graph/res/images/folder.png rename to com.itjw.txviewer.ui/res/images/folder.png diff --git a/com.itjw.txviewer.graph/res/images/stream.png b/com.itjw.txviewer.ui/res/images/stream.png similarity index 100% rename from com.itjw.txviewer.graph/res/images/stream.png rename to com.itjw.txviewer.ui/res/images/stream.png diff --git a/com.itjw.txviewer.ui/src/com/itjw/txviewer/ui/TxEditorActionBarContributor.java b/com.itjw.txviewer.ui/src/com/itjw/txviewer/ui/TxEditorActionBarContributor.java new file mode 100644 index 0000000..0871350 --- /dev/null +++ b/com.itjw.txviewer.ui/src/com/itjw/txviewer/ui/TxEditorActionBarContributor.java @@ -0,0 +1,11 @@ +package com.itjw.txviewer.ui; + +import org.eclipse.ui.part.EditorActionBarContributor; + +public class TxEditorActionBarContributor extends EditorActionBarContributor { + + public TxEditorActionBarContributor() { + // TODO Auto-generated constructor stub + } + +} diff --git a/com.itjw.txviewer.ui/src/com/itjw/txviewer/ui/TxEditorInput.java b/com.itjw.txviewer.ui/src/com/itjw/txviewer/ui/TxEditorInput.java new file mode 100644 index 0000000..916bf09 --- /dev/null +++ b/com.itjw.txviewer.ui/src/com/itjw/txviewer/ui/TxEditorInput.java @@ -0,0 +1,32 @@ +package com.itjw.txviewer.ui; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; + +import org.eclipse.core.resources.IFile; +import org.eclipse.ui.IMemento; +import org.eclipse.ui.part.FileEditorInput; + +public class TxEditorInput extends FileEditorInput { + + private ArrayList streamNames; + + public TxEditorInput(IFile file) { + super(file); + streamNames=new ArrayList(); + } + + public String getFactoryId(){ + return TxEditorInputFactory.getFactoryId(); + } + + public void saveState(IMemento memento) { + TxEditorInputFactory.saveState(memento, this); + } + + public List getStreamNames() { + return streamNames; + } + +} diff --git a/com.itjw.txviewer.ui/src/com/itjw/txviewer/ui/TxEditorInputFactory.java b/com.itjw.txviewer.ui/src/com/itjw/txviewer/ui/TxEditorInputFactory.java new file mode 100644 index 0000000..ce41a44 --- /dev/null +++ b/com.itjw.txviewer.ui/src/com/itjw/txviewer/ui/TxEditorInputFactory.java @@ -0,0 +1,99 @@ +package com.itjw.txviewer.ui; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.Path; +import org.eclipse.ui.IElementFactory; +import org.eclipse.ui.IMemento; + +public class TxEditorInputFactory implements IElementFactory { + + /** + * Factory id. The workbench plug-in registers a factory by this name + * with the "org.eclipse.ui.elementFactories" extension point. + */ + private static final String ID_FACTORY = "com.itjw.txviewer.ui.TxEditorInputFactory"; //$NON-NLS-1$ + + /** + * Tag for the IFile.fullPath of the file resource. + */ + private static final String TAG_PATH = "path"; //$NON-NLS-1$ + + private static final String STREAMLIST_PATH = "stream_list"; //$NON-NLS-1$ + + /** + * Creates a new factory. + */ + public TxEditorInputFactory() { + } + + /* (non-Javadoc) + * Method declared on IElementFactory. + */ + @SuppressWarnings("unchecked") + public IAdaptable createElement(IMemento memento) { + // Get the file name. + String fileName = memento.getString(TAG_PATH); + if (fileName == null) { + return null; + } + + // Get a handle to the IFile...which can be a handle + // to a resource that does not exist in workspace + IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(fileName)); + if (file != null) { + TxEditorInput tei = new TxEditorInput(file); + String listData = memento.getString(STREAMLIST_PATH); + if (listData != null) { + try { + ByteArrayInputStream bais = new ByteArrayInputStream(javax.xml.bind.DatatypeConverter.parseHexBinary(listData)); + ObjectInputStream ois = new ObjectInputStream(bais); + Object obj = ois.readObject(); + if(obj instanceof List) + tei.getStreamNames().addAll((List)obj); + } catch (Exception e) { + } + } + return tei; + } + return null; + } + + /** + * Returns the element factory id for this class. + * + * @return the element factory id + */ + public static String getFactoryId() { + return ID_FACTORY; + } + + /** + * Saves the state of the given file editor input into the given memento. + * + * @param memento the storage area for element state + * @param input the file editor input + */ + public static void saveState(IMemento memento, TxEditorInput input) { + IFile file = input.getFile(); + memento.putString(TAG_PATH, file.getFullPath().toString()); + try { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + ObjectOutputStream oos = new ObjectOutputStream(baos); + oos.writeObject(input.getStreamNames()); + memento.putString(STREAMLIST_PATH, javax.xml.bind.DatatypeConverter.printHexBinary(baos.toByteArray())); + } catch (IOException e) { + } + } +} diff --git a/com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/TxEditorPart.java b/com.itjw.txviewer.ui/src/com/itjw/txviewer/ui/TxEditorPart.java similarity index 53% rename from com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/TxEditorPart.java rename to com.itjw.txviewer.ui/src/com/itjw/txviewer/ui/TxEditorPart.java index d3cda33..520880b 100644 --- a/com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/TxEditorPart.java +++ b/com.itjw.txviewer.ui/src/com/itjw/txviewer/ui/TxEditorPart.java @@ -8,16 +8,14 @@ * Contributors: * IT Just working - initial API and implementation *******************************************************************************/ -package com.itjw.txviewer.graph; +package com.itjw.txviewer.ui; -import java.util.LinkedList; +import java.util.List; import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.gef.ui.actions.ActionRegistry; -import org.eclipse.gef.ui.parts.SelectionSynchronizer; import org.eclipse.jface.action.Action; +import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.viewers.ISelection; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Event; @@ -26,38 +24,36 @@ import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorSite; import org.eclipse.ui.IFileEditorInput; import org.eclipse.ui.PartInitException; +import org.eclipse.ui.ide.FileStoreEditorInput; import org.eclipse.ui.part.EditorPart; import org.eclipse.ui.views.contentoutline.IContentOutlinePage; import org.eclipse.ui.views.properties.IPropertySheetPage; import org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor; import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage; +import org.osgi.framework.BundleContext; +import org.osgi.framework.FrameworkUtil; +import org.osgi.framework.ServiceReference; import com.itjw.txviewer.database.ITrDb; import com.itjw.txviewer.database.ITrStream; -import com.itjw.txviewer.database.InputFormatException; -import com.itjw.txviewer.graph.actions.AddToWave; -import com.itjw.txviewer.graph.data.ITrDbFacade; -import com.itjw.txviewer.graph.data.ITrStreamFacade; -import com.itjw.txviewer.graph.ui.swt.TxDisplay; +import com.itjw.txviewer.database.ITransactionDbFactory; +import com.itjw.txviewer.ui.swt.TxDisplay; +import com.itjw.txviewer.ui.views.TxOutlinePage; public class TxEditorPart extends EditorPart implements ITabbedPropertySheetPageContributor { - public static final String ID = "com.itjw.txviewer.graph.TxEditorPart"; //$NON-NLS-1$ + public static final String ID = "com.itjw.txviewer.ui.TxEditorPart"; //$NON-NLS-1$ + + public static final String WAVE_ACTION_ID = "com.itjw.txviewer.ui.action.AddToWave"; private TxDisplay txDisplay; - + /** This is the root of the editor's model. */ private ITrDb database; - private LinkedList streamList; - - private SelectionSynchronizer synchronizer; - - private ActionRegistry actionRegistry; + private Composite myParent; public TxEditorPart() { - streamList = new LinkedList(); - } /** @@ -66,9 +62,10 @@ public class TxEditorPart extends EditorPart implements ITabbedPropertySheetPage */ @Override public void createPartControl(Composite parent) { + myParent=parent; /** Add handlers for global actions (delete, etc) */ IActionBars actionBars = getEditorSite().getActionBars(); - actionBars.setGlobalActionHandler(AddToWave.ID, new Action() { + actionBars.setGlobalActionHandler(WAVE_ACTION_ID, new Action() { @Override public void runWithEvent(Event event) { System.out.println("AddToWave with event"); @@ -80,9 +77,16 @@ public class TxEditorPart extends EditorPart implements ITabbedPropertySheetPage } }); - txDisplay = new TxDisplay(parent, this, getSite()); - TxEditorPlugin.getDefault().editorOpened(this); + txDisplay = new TxDisplay(parent); getSite().setSelectionProvider(txDisplay); + if(getEditorInput()!=null && ((TxEditorInput) getEditorInput()).getStreamNames().size()>0){ + if(MessageDialog.openConfirm(parent.getShell(), "Confirm", "Do you want the restore last state of the wave form?")) + for(String streamName:((TxEditorInput) getEditorInput()).getStreamNames()){ + ITrStream stream = database.getStreamByName(streamName); + if(stream!=null) + txDisplay.addStream(stream); + } + } } @@ -93,41 +97,52 @@ public class TxEditorPart extends EditorPart implements ITabbedPropertySheetPage */ protected void setInput(IEditorInput input) { super.setInput(input); - try { - IFile file = ((IFileEditorInput) input).getFile(); - database = new ITrDbFacade(); - if(txDisplay !=null) database.addPropertyChangeListener(txDisplay); - database.load(file.getContents()); - setPartName(((IFileEditorInput) input).getFile().getName()); -// for(ITrStream stream: database.getAllStreams()) -// streamList.add(new TxStreamAdapter(stream)); - } catch (InputFormatException e) { - handleLoadException(e); - } catch (CoreException e) { - e.printStackTrace(); + if(input instanceof IFileEditorInput){ + if(!(input instanceof TxEditorInput)) + super.setInput(new TxEditorInput(((IFileEditorInput)input).getFile())); + try { + IFile file = ((IFileEditorInput) input).getFile(); + getTrDatabase(); + database.load(file.getContents()); + setPartName(((IFileEditorInput) input).getFile().getName()); + } catch (Exception e) { + handleLoadException(e); + } + } else if(input instanceof FileStoreEditorInput){ + try { + getTrDatabase(); + database.load(((FileStoreEditorInput) input).getURI().toURL().openStream()); + setPartName(((FileStoreEditorInput) input).getName()); + } catch (Exception e) { + handleLoadException(e); + } } } + protected void getTrDatabase() { + BundleContext context = FrameworkUtil.getBundle(this.getClass()).getBundleContext(); + ServiceReference serviceReference = context.getServiceReference(ITransactionDbFactory.class.getName()); + database = ((ITransactionDbFactory) context.getService(serviceReference)).createDatabase(); + if(txDisplay !=null) database.addPropertyChangeListener(txDisplay); + } + private void handleLoadException(Exception e) { System.err.println("** Load failed. Using default model. **"); e.printStackTrace(); database = null; } - @Override public void setFocus() { - // Set the focus + myParent.setFocus(); } @Override public void doSave(IProgressMonitor monitor) { - // Do the Save operation } @Override public void doSaveAs() { - // Do the Save As operation } @SuppressWarnings("rawtypes") @@ -140,24 +155,10 @@ public class TxEditorPart extends EditorPart implements ITabbedPropertySheetPage return super.getAdapter(type); } - public SelectionSynchronizer getSelectionSynchronizer() { - if (synchronizer == null) - synchronizer = new SelectionSynchronizer(); - return synchronizer; - } - - public ActionRegistry getActionRegistry() { - if (actionRegistry == null) - actionRegistry = new ActionRegistry(); - return actionRegistry; - } - public ITrDb getModel() { return database; } - - @Override public void init(IEditorSite site, IEditorInput input) throws PartInitException { @@ -176,37 +177,48 @@ public class TxEditorPart extends EditorPart implements ITabbedPropertySheetPage return false; } - public LinkedList getStreamList() { - return streamList; - } - public ITrDb getDatabase() { return database; } public void addStreamToList(ITrStream stream){ - if(stream instanceof ITrStreamFacade) - streamList.add((ITrStreamFacade)stream); - else - streamList.add(new ITrStreamFacade(stream)); - txDisplay.streamListChanged(); + if(getEditorInput() instanceof TxEditorInput && !((TxEditorInput) getEditorInput()).getStreamNames().contains(stream.getFullName())){ + ((TxEditorInput) getEditorInput()).getStreamNames().add(stream.getFullName()); + txDisplay.addStream(stream); + } else + txDisplay.addStream(stream); + } public void addStreamsToList(ITrStream[] streams){ - for(ITrStream stream: streams) addStreamToList(stream); - txDisplay.streamListChanged(); + for(ITrStream stream:streams) + addStreamToList(stream); } public void removeStreamFromList(ITrStream stream){ - txDisplay.streamListChanged(); + if(getEditorInput() instanceof TxEditorInput && ((TxEditorInput) getEditorInput()).getStreamNames().contains(stream.getFullName())){ + ((TxEditorInput) getEditorInput()).getStreamNames().remove(stream.getFullName()); + txDisplay.removeStream(stream); + } else + txDisplay.removeStream(stream); } public void removeStreamsFromList(ITrStream[] streams){ - txDisplay.streamListChanged(); + for(ITrStream stream:streams) + removeStreamFromList(stream); } - public void setSelection(ISelection selection){ - txDisplay.setSelection(selection); + public List getStreamList(){ + return txDisplay.getStreamList(); + } + + public void setSelection(final ISelection selection){ + myParent.getDisplay().asyncExec(new Runnable() { + @Override + public void run() { + txDisplay.setSelection(selection); + } + }); } @Override diff --git a/com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/TxEditorPlugin.java b/com.itjw.txviewer.ui/src/com/itjw/txviewer/ui/TxEditorPlugin.java similarity index 88% rename from com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/TxEditorPlugin.java rename to com.itjw.txviewer.ui/src/com/itjw/txviewer/ui/TxEditorPlugin.java index 4364eff..ae33433 100644 --- a/com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/TxEditorPlugin.java +++ b/com.itjw.txviewer.ui/src/com/itjw/txviewer/ui/TxEditorPlugin.java @@ -8,7 +8,7 @@ * Contributors: * IT Just working - initial API and implementation *******************************************************************************/ -package com.itjw.txviewer.graph; +package com.itjw.txviewer.ui; import java.io.File; import java.util.MissingResourceException; @@ -19,6 +19,7 @@ import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Image; import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.eclipse.wb.swt.SWTResourceManager; import org.osgi.framework.BundleContext; /** @@ -36,7 +37,7 @@ public class TxEditorPlugin extends AbstractUIPlugin { public static final int headerFgColor=7; // The plug-in ID - public static final String PLUGIN_ID = "com.itjw.txviewer.graph"; //$NON-NLS-1$ + public static final String PLUGIN_ID = "com.itjw.txviewer.ui"; //$NON-NLS-1$ // The shared instance private static TxEditorPlugin plugin; @@ -72,6 +73,7 @@ public class TxEditorPlugin extends AbstractUIPlugin { */ public void stop(BundleContext context) throws Exception { plugin = null; + SWTResourceManager.dispose(); super.stop(context); } @@ -112,13 +114,13 @@ public class TxEditorPlugin extends AbstractUIPlugin { case txHighliteBgColor: return ColorConstants.darkGreen; case trackBgLightColor: - return new Color(null, 220, 220, 220); + return SWTResourceManager.getColor(220, 220, 220); case trackBgDarkColor: - return new Color(null, 200, 200, 200); + return SWTResourceManager.getColor(200, 200, 200); case headerBgColor: - return new Color(null, 255, 255, 255); + return SWTResourceManager.getColor(255, 255, 255); case headerFgColor: - return new Color(null, 55, 55, 55); + return SWTResourceManager.getColor(55, 55, 55); default: break; } @@ -129,11 +131,4 @@ public class TxEditorPlugin extends AbstractUIPlugin { return resourceBundle; } - public void editorOpened(TxEditorPart txEditorPart) { - openedTxEditorPart=txEditorPart; - } - - public TxEditorPart getOpenEditorPart(){ - return openedTxEditorPart; - } } diff --git a/com.itjw.txviewer.ui/src/com/itjw/txviewer/ui/adapter/AdapterFactory.java b/com.itjw.txviewer.ui/src/com/itjw/txviewer/ui/adapter/AdapterFactory.java new file mode 100644 index 0000000..5b44154 --- /dev/null +++ b/com.itjw.txviewer.ui/src/com/itjw/txviewer/ui/adapter/AdapterFactory.java @@ -0,0 +1,24 @@ +package com.itjw.txviewer.ui.adapter; + +import org.eclipse.core.runtime.IAdapterFactory; +import org.eclipse.ui.views.properties.IPropertySource; + +import com.itjw.txviewer.database.ITransaction; + +public class AdapterFactory implements IAdapterFactory { + + @SuppressWarnings("rawtypes") + @Override + public Object getAdapter(Object adaptableObject, Class adapterType) { + if (adapterType == IPropertySource.class) + return new ITransactionPropertySource((ITransaction) adaptableObject); + return null; + } + + @SuppressWarnings("rawtypes") + @Override + public Class[] getAdapterList() { + return new Class[]{IPropertySource.class}; + } + +} diff --git a/com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/data/ITransactionProperties.java b/com.itjw.txviewer.ui/src/com/itjw/txviewer/ui/adapter/ITransactionPropertySource.java similarity index 56% rename from com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/data/ITransactionProperties.java rename to com.itjw.txviewer.ui/src/com/itjw/txviewer/ui/adapter/ITransactionPropertySource.java index 774b4bd..699ec03 100644 --- a/com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/data/ITransactionProperties.java +++ b/com.itjw.txviewer.ui/src/com/itjw/txviewer/ui/adapter/ITransactionPropertySource.java @@ -8,29 +8,28 @@ * Contributors: * IT Just working - initial API and implementation *******************************************************************************/ -package com.itjw.txviewer.graph.data; +package com.itjw.txviewer.ui.adapter; 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.ITrAttribute; import com.itjw.txviewer.database.ITransaction; -public class ITransactionProperties implements IPropertySource { +public class ITransactionPropertySource implements IPropertySource { private ITransaction iTransaction; public final static String PROPERTY_ID = "ID"; public final static String PROPERTY_BEGINTIME = "BEGINTIME"; public final static String PROPERTY_ENDTIME = "ENDTIME"; + public final static String PROPERTY_NAME = "NAME"; protected IPropertyDescriptor[] propertyDescriptors; - public ITransactionProperties(ITransaction iTransaction) { + public ITransactionPropertySource(ITransaction iTransaction) { this.iTransaction=iTransaction; } @@ -42,33 +41,21 @@ public class ITransactionProperties implements IPropertySource { @Override public IPropertyDescriptor[] getPropertyDescriptors() { if (propertyDescriptors == null) { - ArrayList idDescriptor=new ArrayList(); + ArrayList descriptor=new ArrayList(); // Create a descriptor and set a category - PropertyDescriptor nameDescriptor = new PropertyDescriptor(PROPERTY_ID, "Id"); - nameDescriptor.setCategory("Attributes"); - idDescriptor.add(nameDescriptor); + PropertyDescriptor idDescriptor = new PropertyDescriptor(PROPERTY_ID, "Id"); + idDescriptor.setCategory("Attributes"); + descriptor.add(idDescriptor); PropertyDescriptor begTimeDescriptor = new PropertyDescriptor(PROPERTY_BEGINTIME, "Begin time"); begTimeDescriptor.setCategory("Attributes"); - idDescriptor.add(begTimeDescriptor); + descriptor.add(begTimeDescriptor); PropertyDescriptor endTimeDescriptor = new PropertyDescriptor(PROPERTY_ENDTIME, "End time"); endTimeDescriptor.setCategory("Attributes"); - idDescriptor.add(endTimeDescriptor); -// for(ITrAttribute attr:iTransaction.getBeginAttrs()){ -// PropertyDescriptor descr = new PropertyDescriptor("BEGIN_"+attr.getName(), attr.getName()); -// descr.setCategory("Begin attributes"); -// idDescriptor.add(descr); -// } -// for(ITrAttribute attr:iTransaction.getEndAttrs()){ -// PropertyDescriptor descr = new PropertyDescriptor("END_"+attr.getName(), attr.getName()); -// descr.setCategory("End attributes"); -// idDescriptor.add(descr); -// } -// for(ITrAttribute attr:iTransaction.getAttributes()){ -// PropertyDescriptor descr = new PropertyDescriptor("REC_"+attr.getName(), attr.getName()); -// descr.setCategory("Recorded attributes"); -// idDescriptor.add(descr); -// } - propertyDescriptors = idDescriptor.toArray(new IPropertyDescriptor[idDescriptor.size()]); + descriptor.add(endTimeDescriptor); + PropertyDescriptor nameDescriptor = new PropertyDescriptor(PROPERTY_NAME, "Name"); + nameDescriptor.setCategory("Attributes"); + descriptor.add(nameDescriptor); + propertyDescriptors = descriptor.toArray(new IPropertyDescriptor[descriptor.size()]); } return propertyDescriptors; } @@ -81,21 +68,8 @@ public class ITransactionProperties implements IPropertySource { return iTransaction.getBeginTime();//.getValueNS(); } else if(id.equals(PROPERTY_ENDTIME)){ return iTransaction.getEndTime();//.getValueNS(); - } else if(id instanceof String){ - String strId=(String)id; - List set; - if(strId.startsWith("BEGIN_")){ - set=iTransaction.getBeginAttrs(); - } else if(strId.startsWith("END_")){ - set=iTransaction.getEndAttrs(); - } else { - set=iTransaction.getAttributes(); - } - for(ITrAttribute attr:set){ - if(strId.endsWith("_"+attr.getName())){ - return attr.getValue(); - } - } + } else if(id.equals(PROPERTY_NAME)){ + return iTransaction.getGenerator().getName(); } return null; } diff --git a/com.itjw.txviewer.ui/src/com/itjw/txviewer/ui/swt/Ruler.java b/com.itjw.txviewer.ui/src/com/itjw/txviewer/ui/swt/Ruler.java new file mode 100644 index 0000000..fdaf19d --- /dev/null +++ b/com.itjw.txviewer.ui/src/com/itjw/txviewer/ui/swt/Ruler.java @@ -0,0 +1,99 @@ +package com.itjw.txviewer.ui.swt; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.DisposeEvent; +import org.eclipse.swt.events.DisposeListener; +import org.eclipse.swt.events.PaintEvent; +import org.eclipse.swt.events.PaintListener; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.GC; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.widgets.Composite; + +import com.itjw.txviewer.ui.TxEditorPlugin; + +public class Ruler extends Composite { + + static final int height = 20; + static final int rulerTickMinor = 10; + static final int rulerTickMajor = 100; + + private int length; + private int start; + + private TxEditorPlugin plugin; + private Color headerBgColor; + private Color headerFgColor; + + Ruler(Composite parent, int style, int lenght) { + super(parent, style | SWT.DOUBLE_BUFFERED); + this.length=lenght; + headerBgColor=getDisplay().getSystemColor(SWT.COLOR_WHITE); + headerFgColor=getDisplay().getSystemColor(SWT.COLOR_BLACK); + plugin=TxEditorPlugin.getDefault(); + if(plugin!=null){ + headerBgColor=plugin.getColor(TxEditorPlugin.headerBgColor); + headerFgColor=plugin.getColor(TxEditorPlugin.headerFgColor); + } + addDisposeListener(new DisposeListener() { + public void widgetDisposed(DisposeEvent e) { + Ruler.this.widgetDisposed(e); + } + }); + addPaintListener(new PaintListener() { + public void paintControl(PaintEvent e) { + Ruler.this.paintControl(e); + } + }); + } + + public int getLength() { + return length; + } + + public void setLength(int length) { + this.length = length; + layout(true); + redraw(); + } + + protected void widgetDisposed(DisposeEvent e) { + } + + void paintControl(PaintEvent e) { + GC gc = e.gc; + int startMinorIncr = start; + int modulo = start % rulerTickMinor; + startMinorIncr+=rulerTickMinor-modulo; + int bottom=height - 2; + int end=start+e.width; + + gc.setBackground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND)); + gc.fillRectangle(new Rectangle(0, 0, e.width, height)); + gc.setBackground(headerBgColor); + gc.fillRectangle(new Rectangle(0, 0, e.width, height - 1)); + gc.setForeground(headerFgColor); + gc.drawLine(0, bottom, e.width, bottom); + + for (int tick = startMinorIncr; tick < end; tick += rulerTickMinor) { + int x0 = tick-start; + if ((tick % rulerTickMajor) == 0) { + gc.drawLine(x0, 10, x0, bottom); + gc.drawText(Integer.toString(tick), x0, 0); + } else { + gc.drawLine(x0, 15, x0, bottom); + } + } + } + + @Override + public Point computeSize(int wHint, int hHint, boolean changed) { + return new Point(0, height); + } + + public void setStartPoint(int start) { + this.start=start; + redraw(); + } +} diff --git a/com.itjw.txviewer.ui/src/com/itjw/txviewer/ui/swt/Track.java b/com.itjw.txviewer.ui/src/com/itjw/txviewer/ui/swt/Track.java new file mode 100644 index 0000000..4740b2e --- /dev/null +++ b/com.itjw.txviewer.ui/src/com/itjw/txviewer/ui/swt/Track.java @@ -0,0 +1,203 @@ +package com.itjw.txviewer.ui.swt; + +import java.util.HashMap; +import java.util.List; +import java.util.Vector; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.DisposeEvent; +import org.eclipse.swt.events.DisposeListener; +import org.eclipse.swt.events.MouseEvent; +import org.eclipse.swt.events.MouseListener; +import org.eclipse.swt.events.PaintEvent; +import org.eclipse.swt.events.PaintListener; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.GC; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Layout; + +import com.itjw.txviewer.database.EventTime; +import com.itjw.txviewer.database.ITransaction; +import com.itjw.txviewer.ui.TxEditorPlugin; + +public class Track extends Composite implements MouseListener { + + static final int trackHeight = 50; + static final int trackInset = 2; + static final int txHeight = trackHeight - 2 * trackInset; + + static double zoomFactor = EventTime.NS; + private Color lineColor; + private Color trackBgColor; + + private ITransaction highlightedTx=null; + + private HashMap transactionMap = new HashMap(); + + class TrackLayoutData { + protected int x, y; + TrackLayoutData(int x, int y){ + this.x=x; + this.y=y; + } + public int getX() { + return x; + } + public int getY() { + return y; + } + + } + + class TrackLayout extends Layout { + Point extent; // the cached sizes + + protected Point computeSize(Composite composite, int wHint, int hHint, boolean changed) { + if (changed || extent == null) { + extent=new Point(0, 0); + for(Control child:composite.getChildren()){ + Point cExtent = child.computeSize(SWT.DEFAULT, SWT.DEFAULT, false); + TrackLayoutData dat = (TrackLayoutData) child.getLayoutData(); + extent.x=Math.max(extent.x, dat.x+cExtent.x); + extent.y=Math.max(extent.y, dat.y+cExtent.y); + } + } + return extent; + } + + protected void layout(Composite composite, boolean changed) { + if(extent==null){ + extent=new Point(0, 0); + changed=true; + } + for(Control child:composite.getChildren()){ + Point cExtent = child.computeSize(SWT.DEFAULT, SWT.DEFAULT, false); + TrackLayoutData dat = (TrackLayoutData) child.getLayoutData(); + if(changed){ + extent.x=Math.max(extent.x, dat.x+cExtent.x); + extent.y=Math.max(extent.y, dat.y+cExtent.y); + } + child.setBounds(dat.x, dat.y, cExtent.x, cExtent.y); + } + } + } + + Track(Composite parent, int style) { + super(parent, style); + setLayout(new TrackLayout()); + addDisposeListener(new DisposeListener() { + public void widgetDisposed(DisposeEvent e) { + Track.this.widgetDisposed(e); + } + }); + addPaintListener(new PaintListener() { + public void paintControl(PaintEvent e) { + Track.this.paintControl(e); + } + }); + TxEditorPlugin plugin=TxEditorPlugin.getDefault(); + lineColor=plugin.getColor(TxEditorPlugin.lineColor); + trackBgColor=plugin.getColor(TxEditorPlugin.trackBgLightColor); + } + + + protected void widgetDisposed(DisposeEvent e) { + } + + void paintControl(PaintEvent e) { + GC gc = e.gc; + gc.setForeground(lineColor); + gc.setFillRule(SWT.FILL_EVEN_ODD); + gc.setBackground(trackBgColor); + gc.setLineWidth(1); + gc.setLineStyle(SWT.LINE_SOLID); + gc.fillRectangle(new Rectangle(e.x, e.y, e.width, e.height)); + for(int offset=e.y+trackHeight/2; offset transactions) { + Vector rowendtime = new Vector(); + for (ITransaction tx : transactions) { + int rowIdx = 0; + for (ITransaction lastTx : rowendtime) { + if((lastTx.getEndTime().getValue()-lastTx.getBeginTime().getValue())>0){ + if (lastTx.getEndTime().compareTo(tx.getBeginTime())<=0 ) + break; + } else { + if (lastTx.getEndTime().compareTo(tx.getBeginTime())<0 ) + break; + } + rowIdx++; + } + if (rowendtime.size() <= rowIdx) { + rowendtime.add(tx); + } else { + rowendtime.set(rowIdx, tx); + } + int width = (int) ((tx.getEndTime().getValue()-tx.getBeginTime().getValue())/zoomFactor); + if(width==0) width=1; + Transaction t = new Transaction(this, SWT.NONE, width); + t.setLayoutData(new Track.TrackLayoutData((int) (tx.getBeginTime().getValue()/zoomFactor), rowIdx*trackHeight)); + t.setData(tx); + t.addMouseListener(this); + transactionMap.put(tx, t); + } + layout(true,true); + } + + + @Override + public void mouseDoubleClick(MouseEvent e) { + Event event = new Event(); + event.type = SWT.MouseDoubleClick; + event.display=e.display; + event.data = e.widget; + event.button=e.button; + event.time=e.time; + this.notifyListeners(SWT.MouseDoubleClick, event); + } + + + @Override + public void mouseDown(MouseEvent e) { + Event event = new Event(); + event.type = SWT.MouseDown; + event.display=e.display; + event.data = e.widget; + event.button=e.button; + event.time=e.time; + this.notifyListeners(SWT.MouseDown, event); + } + + + @Override + public void mouseUp(MouseEvent e) { + Event event = new Event(); + event.type = SWT.MouseUp; + event.display=e.display; + event.data = e.widget; + event.button=e.button; + event.time=e.time; + this.notifyListeners(SWT.MouseUp, event); + } + + public Transaction highlightTransaction(ITransaction tx){ + if(highlightedTx!=null){ + transactionMap.get(highlightedTx).highlight(false); + highlightedTx=null; + } + if(tx!=null && transactionMap.containsKey(tx)){ + Transaction trans = transactionMap.get(tx); + trans.highlight(true); + highlightedTx=tx; + return trans; + } + return null; + } +} diff --git a/com.itjw.txviewer.ui/src/com/itjw/txviewer/ui/swt/Transaction.java b/com.itjw.txviewer.ui/src/com/itjw/txviewer/ui/swt/Transaction.java new file mode 100644 index 0000000..1ff4c86 --- /dev/null +++ b/com.itjw.txviewer.ui/src/com/itjw/txviewer/ui/swt/Transaction.java @@ -0,0 +1,75 @@ +package com.itjw.txviewer.ui.swt; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.DisposeEvent; +import org.eclipse.swt.events.DisposeListener; +import org.eclipse.swt.events.PaintEvent; +import org.eclipse.swt.events.PaintListener; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.GC; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.widgets.Composite; + +import com.itjw.txviewer.ui.TxEditorPlugin; + +public class Transaction extends Composite { + + public static int height = 50; + public static Color lineColor; + public static Color txBgColor; + public static Color highliteLineColor; + public static Color txHighliteBgColor; + private int length; + private boolean highlighted=false; + + Transaction(Composite parent, int style, int lenght) { + super(parent, style); + this.length=lenght; + addDisposeListener(new DisposeListener() { + public void widgetDisposed(DisposeEvent e) { + Transaction.this.widgetDisposed(e); + } + }); + addPaintListener(new PaintListener() { + public void paintControl(PaintEvent e) { + Transaction.this.paintControl(e); + } + }); + TxEditorPlugin plugin=TxEditorPlugin.getDefault(); + lineColor=plugin.getColor(TxEditorPlugin.lineColor); + txBgColor=plugin.getColor(TxEditorPlugin.txBgColor); + highliteLineColor=plugin.getColor(TxEditorPlugin.highliteLineColor); + txHighliteBgColor=plugin.getColor(TxEditorPlugin.txHighliteBgColor); + } + + protected void widgetDisposed(DisposeEvent e) { + } + + void paintControl(PaintEvent e) { + GC gc = e.gc; + gc.setForeground(highlighted?highliteLineColor:lineColor); + gc.setFillRule(SWT.FILL_EVEN_ODD); + gc.setBackground(highlighted?txHighliteBgColor:txBgColor); + gc.setLineWidth(1); + gc.setLineStyle(SWT.LINE_SOLID); + Rectangle bb = new Rectangle(0, 0, length-1, height-1); + if(bb.width<8){ + gc.fillRectangle(bb); + gc.drawRectangle(bb); + } else { + gc.fillRoundRectangle(bb.x, bb.y, bb.width, bb.height, 4, 4); + gc.drawRoundRectangle(bb.x, bb.y, bb.width, bb.height, 4, 4); + } + } + + @Override + public Point computeSize(int wHint, int hHint, boolean changed) { + return new Point(length, height); + } + + public void highlight(boolean highlight) { + highlighted=highlight; + redraw(); + } +} diff --git a/com.itjw.txviewer.ui/src/com/itjw/txviewer/ui/swt/TxDisplay.java b/com.itjw.txviewer.ui/src/com/itjw/txviewer/ui/swt/TxDisplay.java new file mode 100644 index 0000000..d19eb55 --- /dev/null +++ b/com.itjw.txviewer.ui/src/com/itjw/txviewer/ui/swt/TxDisplay.java @@ -0,0 +1,390 @@ +/******************************************************************************* + * 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.ui.swt; + +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; + +import org.eclipse.core.runtime.ListenerList; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.ISelectionProvider; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.CLabel; +import org.eclipse.swt.custom.SashForm; +import org.eclipse.swt.custom.ScrolledComposite; +import org.eclipse.swt.events.ControlAdapter; +import org.eclipse.swt.events.ControlEvent; +import org.eclipse.swt.events.MouseEvent; +import org.eclipse.swt.events.MouseListener; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.layout.RowData; +import org.eclipse.swt.layout.RowLayout; +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 org.eclipse.wb.swt.SWTResourceManager; + +import swing2swt.layout.BorderLayout; + +import com.itjw.txviewer.database.ITrStream; +import com.itjw.txviewer.database.ITransaction; + +public class TxDisplay implements PropertyChangeListener, ISelectionProvider, MouseListener{ + + private ListenerList listeners = new ListenerList(); + private ITrStream currentStreamSelection; + private ITransaction currentSelection; + private ScrolledComposite valueListScrolled; + private ScrolledComposite nameListScrolled; + private Composite nameList; + private Composite valueList; + private ScrolledComposite trackListScrolled; + private Composite trackList; + private Composite top; + private ArrayList streams=new ArrayList(); + private Composite trackPane; + private Ruler ruler; + private HashMap trackMap = new HashMap(); + + public TxDisplay(Composite parent) { + top = new Composite(parent, SWT.NONE); + top.setLayout(new FillLayout(SWT.HORIZONTAL)); + + SashForm topSash = new SashForm(top, SWT.SMOOTH); + topSash.setBackground(topSash.getDisplay().getSystemColor( SWT.COLOR_GRAY)); + + Composite composite = new Composite(topSash, SWT.NONE); + composite.setLayout(new FillLayout(SWT.HORIZONTAL)); + + SashForm leftSash = new SashForm(composite, SWT.SMOOTH); + leftSash.setBackground(leftSash.getDisplay().getSystemColor( SWT.COLOR_GRAY)); +// leftSash.addControlListener(new ControlAdapter() { +// public void controlResized(ControlEvent e) { +// recalculateNameBounds(); +// recalculateValueBounds(); +// } +// }); + Composite namePane = createTextPane(leftSash, "Name"); + namePane.setBackground(namePane.getDisplay().getSystemColor( SWT.COLOR_WIDGET_BACKGROUND)); + namePane.addControlListener(new ControlAdapter() { + public void controlResized(ControlEvent e) { + recalculateNameBounds(); + } + }); + + nameListScrolled = new ScrolledComposite(namePane, SWT.H_SCROLL | SWT.V_SCROLL); + nameListScrolled.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, true, 1, 1)); + nameListScrolled.setExpandHorizontal(true); + nameListScrolled.setExpandVertical(true); + nameList = new Composite(nameListScrolled, SWT.NONE); + nameList.setLayout(createScrolledLayoutData(false)); + + nameListScrolled.setContent(nameList); + + Composite valuePane = createTextPane(leftSash, "Value"); + valuePane.setBackground(valuePane.getDisplay().getSystemColor( SWT.COLOR_WIDGET_BACKGROUND)); + valuePane.addControlListener(new ControlAdapter() { + public void controlResized(ControlEvent e) { + recalculateValueBounds(); + } + }); + valueListScrolled = new ScrolledComposite(valuePane, SWT.H_SCROLL | SWT.V_SCROLL); + valueListScrolled.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, true, 1, 1)); + valueListScrolled.setExpandHorizontal(true); + valueListScrolled.setExpandVertical(true); + valueList = new Composite(valueListScrolled, SWT.NONE); + valueList.setLayout(createScrolledLayoutData(true)); + valueListScrolled.setContent(valueList); + + + trackPane = new Composite(topSash, SWT.NONE); + trackPane.setLayout(new BorderLayout(0, 0)); + ruler = new Ruler(trackPane, SWT.NONE, 0); + ruler.setLayoutData(BorderLayout.NORTH); + + trackListScrolled = new ScrolledComposite(trackPane, SWT.H_SCROLL | SWT.V_SCROLL); + trackListScrolled.setExpandVertical(true); + trackListScrolled.setExpandHorizontal(true); + trackList = new Composite(trackListScrolled, SWT.NONE); + trackList.setLayout(createScrolledLayoutData(false)); + trackListScrolled.setContent(trackList); + nameListScrolled.getVerticalBar().addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + int y = ((ScrollBar) e.widget).getSelection(); + valueListScrolled.setOrigin(valueListScrolled.getOrigin().x, y); + trackListScrolled.setOrigin(trackListScrolled.getOrigin().x, y); + } + }); + valueListScrolled.getVerticalBar().addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + int y = ((ScrollBar) e.widget).getSelection(); + nameListScrolled.setOrigin(nameListScrolled.getOrigin().x, y); + trackListScrolled.setOrigin(trackListScrolled.getOrigin().x, y); + } + }); + trackListScrolled.getVerticalBar().addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + int y = ((ScrollBar) e.widget).getSelection(); + nameListScrolled.setOrigin(nameListScrolled.getOrigin().x, y); + valueListScrolled.setOrigin(valueListScrolled.getOrigin().x, y); + } + }); + trackListScrolled.getHorizontalBar().addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + int x = ((ScrollBar) e.widget).getSelection(); + ruler.setStartPoint(x); + } + }); + + topSash.setWeights(new int[] {30, 70}); + leftSash.setWeights(new int[] {75, 25}); + + top.layout(true, true); + streamListChanged(); + } + + protected RowLayout createScrolledLayoutData(boolean center) { + RowLayout nameListLayout = new RowLayout(SWT.VERTICAL); + nameListLayout.spacing = 4; + nameListLayout.marginTop = 0; + nameListLayout.marginRight = 0; + nameListLayout.marginLeft = 0; + nameListLayout.marginBottom = 0; + nameListLayout.fill = true; + nameListLayout.wrap = false; + nameListLayout.center=center; + return nameListLayout; + } + + private Composite createTextPane(SashForm leftSash, String text) { + Composite namePane = new Composite(leftSash, SWT.NONE); + GridLayout gl_namePane = new GridLayout(1, false); + gl_namePane.verticalSpacing = 0; + gl_namePane.marginWidth = 0; + gl_namePane.horizontalSpacing = 0; + gl_namePane.marginHeight = 0; + namePane.setLayout(gl_namePane); + + CLabel nameLabel = new CLabel(namePane, SWT.NONE); + GridData gd_nameLabel = new GridData(SWT.CENTER, SWT.CENTER, true, false, 1, 1); + gd_nameLabel.heightHint = Ruler.height-2; + nameLabel.setLayoutData(gd_nameLabel); + nameLabel.setText(text); + + Label nameSep = new Label(namePane, SWT.SEPARATOR | SWT.HORIZONTAL); + nameSep.setBackground(SWTResourceManager.getColor(SWT.COLOR_DARK_GRAY)); + nameSep.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK)); + GridData gd_nameSep = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1); + gd_nameSep.heightHint = 2; + nameSep.setLayoutData(gd_nameSep); + return namePane; + } + + public void streamListChanged() { + LinkedListtoAdd = new LinkedList(); + toAdd.addAll(streams); + for(Control child:trackList.getChildren()){ + Track track = (Track) child; + Control c = (Control)track.getData("NAMEWIDGET"); + ITrStream stream=(ITrStream) track.getData("STREAM"); + if(!streams.contains(stream)){ + track.setVisible(false); + c.setVisible(false); + }else{ + toAdd.remove(stream); + track.setVisible(true); + c.setVisible(true); + } + } + for(ITrStream stream: toAdd){ + Track track = new Track(trackList,SWT.NONE); + track.setTransactions(stream.getTransactions()); + track.setData("STREAM", stream); + track.addMouseListener(this); + Point trackSize = track.computeSize(SWT.DEFAULT,SWT.DEFAULT); + + Label trackName = new Label(nameList, SWT.NONE); + trackName.setText(stream.getFullName()); + RowData trackNamelayoutData = new RowData(SWT.DEFAULT, trackSize.y); + trackName.setLayoutData(trackNamelayoutData); + track.setData("NAMEWIDGET", trackName); + + Label trackValue = new Label(valueList, SWT.NONE); + trackValue.setText("-"); + RowData trackValuelayoutData = new RowData(SWT.DEFAULT, trackSize.y); + trackValue.setLayoutData(trackValuelayoutData); + track.setData("VALUEWIDGET", trackValue); + trackMap.put(stream, track); + } + recalculateNameBounds(); + recalculateValueBounds(); + Point trackSize=trackList.computeSize(SWT.DEFAULT, SWT.DEFAULT); + trackListScrolled.setMinSize(trackSize); + top.layout(true, true); + } + + protected void recalculateValueBounds() { + if(streams.size()>0){ + Rectangle bounds = valueListScrolled.getParent().getBounds(); + Point size = valueList.computeSize(SWT.DEFAULT, SWT.DEFAULT); +// System.out.println("Value calc: "+bounds+" / "+size); + int corr = (int) (2.35*valueListScrolled.getHorizontalBar().getSize().y); + valueListScrolled.setMinSize(Math.max(bounds.width, size.x), Math.max(bounds.height-corr, size.y)); + valueListScrolled.setAlwaysShowScrollBars(true); + valueListScrolled.getVerticalBar().setVisible(false); + } + } + + protected void recalculateNameBounds() { + if(streams.size()>0){ + Rectangle bounds = nameListScrolled.getParent().getBounds(); + Point size = nameList.computeSize(SWT.DEFAULT, SWT.DEFAULT); +// System.out.println("Name calc: "+bounds+" / "+size); + int corr = (int) (2.35*valueListScrolled.getHorizontalBar().getSize().y); + nameListScrolled.setMinSize(Math.max(bounds.width, size.x), Math.max(bounds.height-corr, size.y)); + nameListScrolled.setAlwaysShowScrollBars(true); + nameListScrolled.getVerticalBar().setVisible(false); + } + } + + @Override + public void propertyChange(PropertyChangeEvent pce) { + currentSelection=null; + ITrStream str = (ITrStream)pce.getNewValue(); + if(str instanceof ITrStream) + currentStreamSelection=(ITrStream)str; + if(currentStreamSelection!=null) + setSelection(getSelection()); + else + setSelection(StructuredSelection.EMPTY); + } + + @Override + public void addSelectionChangedListener(ISelectionChangedListener listener) { + listeners.add(listener); + } + + @Override + public ISelection getSelection() { + if(currentSelection!=null) + return new StructuredSelection(currentSelection); + else if(currentStreamSelection!=null) + return new StructuredSelection(currentStreamSelection); + else + return null; + } + + @Override + public void removeSelectionChangedListener(ISelectionChangedListener listener) { + listeners.remove(listener); + } + + @Override + public void setSelection(ISelection selection) { + if(selection instanceof IStructuredSelection){ + Object sel =((IStructuredSelection)selection).getFirstElement(); + if(sel instanceof ITransaction && currentSelection!=sel){ + if(currentSelection!=null){ + ITrStream stream = currentSelection.getGenerator().getStream(); + if(trackMap.containsKey(stream)) trackMap.get(stream).highlightTransaction(null); + } + currentSelection=(ITransaction) sel; + ITrStream stream = currentSelection.getGenerator().getStream(); + if(trackMap.containsKey(stream)){ + Transaction trans = trackMap.get(stream).highlightTransaction(currentSelection); + trackListScrolled.showControl(trans); + } + Object[] list = listeners.getListeners(); + for (int i = 0; i < list.length; i++) { + ((ISelectionChangedListener) list[i]).selectionChanged(new SelectionChangedEvent(this, selection)); + } + } + } + } + + @Override + public void mouseDoubleClick(MouseEvent e) { + } + + @Override + public void mouseDown(MouseEvent e) { + if(e.data!=null){ + StructuredSelection sel = new StructuredSelection(((Transaction)e.data).getData()); + setSelection(sel); + }else{ + StructuredSelection sel = new StructuredSelection(new Object[]{ ((Track)e.widget).getData()}); + setSelection(sel); + } + } + + @Override + public void mouseUp(MouseEvent e) { + } + + public boolean addStream(ITrStream paramE){ + boolean res = streams.add(paramE); + streamListChanged(); + return res; + } + + public boolean addAllStreams(ITrStream[] streams) { + boolean res = this.streams.addAll(Arrays.asList(streams)); + streamListChanged(); + return res; + } + + public boolean addAllStreams(Collection paramCollection){ + boolean res = streams.addAll(paramCollection); + streamListChanged(); + return res; + } + + public boolean removeStream(ITrStream paramObject){ + boolean res = streams.remove(paramObject); + streamListChanged(); + return res; + } + + public boolean removeAllStreams(Collection paramCollection){ + boolean res = streams.removeAll(paramCollection); + streamListChanged(); + return res; + } + + public List getStreamList(){ + return Collections.unmodifiableList(streams); + } + + public boolean removeAllStreams(ITrStream[] streams) { + boolean res = this.streams.removeAll(Arrays.asList(streams)); + streamListChanged(); + return res; + } + +} diff --git a/com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/views/SelectionTableView.java b/com.itjw.txviewer.ui/src/com/itjw/txviewer/ui/views/SelectionTableView.java similarity index 98% rename from com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/views/SelectionTableView.java rename to com.itjw.txviewer.ui/src/com/itjw/txviewer/ui/views/SelectionTableView.java index c4b2344..bbb2e0b 100644 --- a/com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/views/SelectionTableView.java +++ b/com.itjw.txviewer.ui/src/com/itjw/txviewer/ui/views/SelectionTableView.java @@ -8,7 +8,7 @@ * Contributors: * IT Just working - initial API and implementation *******************************************************************************/ -package com.itjw.txviewer.graph.views; +package com.itjw.txviewer.ui.views; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.Document; diff --git a/com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/views/SelectionPropertiesView.java b/com.itjw.txviewer.ui/src/com/itjw/txviewer/ui/views/TransactionPropertySheet.java similarity index 74% rename from com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/views/SelectionPropertiesView.java rename to com.itjw.txviewer.ui/src/com/itjw/txviewer/ui/views/TransactionPropertySheet.java index 8dddcf0..fea67e5 100644 --- a/com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/views/SelectionPropertiesView.java +++ b/com.itjw.txviewer.ui/src/com/itjw/txviewer/ui/views/TransactionPropertySheet.java @@ -8,14 +8,20 @@ * Contributors: * IT Just working - initial API and implementation *******************************************************************************/ -package com.itjw.txviewer.graph.views; +package com.itjw.txviewer.ui.views; import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.views.properties.PropertySheet; -public class SelectionPropertiesView extends PropertySheet { +public class TransactionPropertySheet extends PropertySheet { + + + public TransactionPropertySheet() { + super(); + } + @Override protected boolean isImportant(IWorkbenchPart part) { - return part.getSite().getId().equals("com.itjw.txviewer.graph.TxEditorPart"); + return part.getSite().getId().equals("com.itjw.txviewer.ui.TxEditorPart"); } } diff --git a/com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/TxOutlinePage.java b/com.itjw.txviewer.ui/src/com/itjw/txviewer/ui/views/TxOutlinePage.java similarity index 58% rename from com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/TxOutlinePage.java rename to com.itjw.txviewer.ui/src/com/itjw/txviewer/ui/views/TxOutlinePage.java index 6166943..f862136 100644 --- a/com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/TxOutlinePage.java +++ b/com.itjw.txviewer.ui/src/com/itjw/txviewer/ui/views/TxOutlinePage.java @@ -8,8 +8,11 @@ * Contributors: * IT Just working - initial API and implementation *******************************************************************************/ -package com.itjw.txviewer.graph; +package com.itjw.txviewer.ui.views; +import java.util.LinkedList; + +import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IMenuListener; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.MenuManager; @@ -24,23 +27,31 @@ import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Menu; import org.eclipse.ui.IActionBars; import org.eclipse.ui.ISelectionListener; +import org.eclipse.ui.ISharedImages; import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.PlatformUI; import org.eclipse.ui.actions.ActionFactory; import org.eclipse.ui.part.IPageSite; import org.eclipse.ui.views.contentoutline.ContentOutline; import org.eclipse.ui.views.contentoutline.ContentOutlinePage; +import com.itjw.txviewer.database.ITrHierNode; import com.itjw.txviewer.database.ITrStream; -import com.itjw.txviewer.graph.actions.TxActionFactory; -import com.itjw.txviewer.graph.data.ITrHierNodeFacade; -import com.itjw.txviewer.graph.views.provider.TxDbTreeContentProvider; -import com.itjw.txviewer.graph.views.provider.TxDbTreeLabelProvider; +import com.itjw.txviewer.database.ITransaction; +import com.itjw.txviewer.ui.TxEditorPart; +import com.itjw.txviewer.ui.views.provider.TxDbTreeContentProvider; +import com.itjw.txviewer.ui.views.provider.TxDbTreeLabelProvider; /** * Creates an outline pagebook for this editor. */ public class TxOutlinePage extends ContentOutlinePage implements ISelectionListener, ISelectionProvider { + 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; + private TxEditorPart editor; public TxOutlinePage(TxEditorPart editor) { @@ -72,7 +83,7 @@ public class TxOutlinePage extends ContentOutlinePage implements ISelectionList }); Menu menu = menuMgr.createContextMenu(contentOutlineViewer.getControl()); contentOutlineViewer.getTree().setMenu(menu); - getSite().registerContextMenu("com.itjw.txviewer.graph.outline.contextmenu", menuMgr, contentOutlineViewer); + getSite().registerContextMenu("com.itjw.txviewer.ui.outline.contextmenu", menuMgr, contentOutlineViewer); // add me as selection listener getSite().getPage().addSelectionListener((ISelectionListener) this); //getSite().getPage().addSelectionListener("SampleViewId",(ISelectionListener)this); @@ -104,30 +115,32 @@ public class TxOutlinePage extends ContentOutlinePage implements ISelectionList public void init(IPageSite pageSite) { super.init(pageSite); IActionBars bars = pageSite.getActionBars(); - String id = ActionFactory.PASTE.getId(); - bars.setGlobalActionHandler(id, editor.getActionRegistry().getAction(id)); - id = ActionFactory.DELETE.getId(); - bars.setGlobalActionHandler(id, editor.getActionRegistry().getAction(id)); } private void fillContextMenu(IMenuManager menuMgr) { // initalize the context menu getTreeViewer().getSelection(); ISelection selection = getTreeViewer().getSelection(); - Object obj = ((IStructuredSelection) selection).getFirstElement(); - menuMgr.add(TxActionFactory.getAction(TxActionFactory.ADD_TO_WAVE, obj instanceof ITrStream)); - menuMgr.add(TxActionFactory.getAction(TxActionFactory.ADD_ALL_TO_WAVE, true)); - menuMgr.add(TxActionFactory.getAction(TxActionFactory.REMOVE_FROM_WAVE, obj instanceof ITrStream)); - menuMgr.add(TxActionFactory.getAction(TxActionFactory.REMOVE_ALL_FROM_WAVE, true)); + if(selection instanceof IStructuredSelection){ + IStructuredSelection sel = (IStructuredSelection) selection; + Object obj = sel.getFirstElement(); + menuMgr.add(makeStreamAction("Add to Wave", ISharedImages.IMG_OBJ_ADD, sel, obj instanceof ITrStream, false)); + menuMgr.add(makeStreamAction("Add all to Wave", ISharedImages.IMG_OBJ_ADD, sel, true, false)); + menuMgr.add(makeStreamAction("Remove from Wave", ISharedImages.IMG_TOOL_DELETE, sel, obj instanceof ITrStream,true)); + menuMgr.add(makeStreamAction("Remove all from Wave", ISharedImages.IMG_TOOL_DELETE, sel, true, true)); + } } //ISelectionListener methods @Override public void selectionChanged(IWorkbenchPart part, ISelection selection) { - if(!(part instanceof ContentOutline) && selection instanceof TrHierNodeSelection){ - System.out.println("Something selected"); - } +// if(!(part instanceof ContentOutline) && selection instanceof IStructuredSelection){ +// if(((IStructuredSelection)selection).getFirstElement() instanceof ITransaction){ +// System.out.println("Transaction with id "+((ITransaction)((IStructuredSelection)selection).getFirstElement()).getId() +" selected"); +// } else if(((IStructuredSelection)selection).getFirstElement() != null) +// System.out.println("Something else selected"); +// } } /** @@ -155,10 +168,46 @@ public class TxOutlinePage extends ContentOutlinePage implements ISelectionList ISelection selection = anEvent.getSelection(); if (!selection.isEmpty()) { Object tmp = ((IStructuredSelection) selection).getFirstElement(); - if (tmp instanceof ITrHierNodeFacade) { - fireSelectionChanged(new TrHierNodeSelection((ITrHierNodeFacade) tmp)); + if (tmp instanceof ITrHierNode) { + fireSelectionChanged(new StructuredSelection((ITrHierNode) tmp)); } } } + private Action makeStreamAction(String text, String imgDescriptor, final IStructuredSelection selection, boolean enabled, final boolean remove) { + Action action = new Action() { + public void run() { + if(selection!=null) + for(Object obj :selection.toArray()){ + if(obj instanceof ITrStream){ + if(remove) + editor.removeStreamFromList((ITrStream) obj); + else + editor.addStreamToList((ITrStream) obj); + } else if(obj instanceof ITrHierNode){ + LinkedList queue = new LinkedList(); + LinkedList streams = new LinkedList(); + 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) + editor.removeStreamsFromList(streams.toArray(new ITrStream[]{})); + else + editor.addStreamsToList(streams.toArray(new ITrStream[]{})); + } + } + } + }; + action.setText(text); + action.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(imgDescriptor)); + if(selection.getFirstElement() instanceof ITrStream && editor.getStreamList().contains(selection.getFirstElement())) + action.setEnabled(false); + else + action.setEnabled(true); + return action; + } + } diff --git a/com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/views/provider/TxDbTreeContentProvider.java b/com.itjw.txviewer.ui/src/com/itjw/txviewer/ui/views/provider/TxDbTreeContentProvider.java similarity index 96% rename from com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/views/provider/TxDbTreeContentProvider.java rename to com.itjw.txviewer.ui/src/com/itjw/txviewer/ui/views/provider/TxDbTreeContentProvider.java index 3bee0b1..dfbd3bf 100644 --- a/com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/views/provider/TxDbTreeContentProvider.java +++ b/com.itjw.txviewer.ui/src/com/itjw/txviewer/ui/views/provider/TxDbTreeContentProvider.java @@ -8,7 +8,7 @@ * Contributors: * IT Just working - initial API and implementation *******************************************************************************/ -package com.itjw.txviewer.graph.views.provider; +package com.itjw.txviewer.ui.views.provider; import org.eclipse.jface.viewers.ITreeContentProvider; import org.eclipse.jface.viewers.Viewer; diff --git a/com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/views/provider/TxDbTreeLabelProvider.java b/com.itjw.txviewer.ui/src/com/itjw/txviewer/ui/views/provider/TxDbTreeLabelProvider.java similarity index 95% rename from com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/views/provider/TxDbTreeLabelProvider.java rename to com.itjw.txviewer.ui/src/com/itjw/txviewer/ui/views/provider/TxDbTreeLabelProvider.java index 18a205d..467dfa0 100644 --- a/com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/views/provider/TxDbTreeLabelProvider.java +++ b/com.itjw.txviewer.ui/src/com/itjw/txviewer/ui/views/provider/TxDbTreeLabelProvider.java @@ -8,7 +8,7 @@ * Contributors: * IT Just working - initial API and implementation *******************************************************************************/ -package com.itjw.txviewer.graph.views.provider; +package com.itjw.txviewer.ui.views.provider; import java.util.ArrayList; import java.util.List; @@ -20,7 +20,7 @@ import org.eclipse.swt.graphics.Image; import com.itjw.txviewer.database.ITrDb; import com.itjw.txviewer.database.ITrHierNode; import com.itjw.txviewer.database.ITrStream; -import com.itjw.txviewer.graph.TxEditorPlugin; +import com.itjw.txviewer.ui.TxEditorPlugin; public class TxDbTreeLabelProvider implements ILabelProvider { diff --git a/com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/views/sections/AttributeProperty.java b/com.itjw.txviewer.ui/src/com/itjw/txviewer/ui/views/sections/AttributeProperty.java similarity index 81% rename from com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/views/sections/AttributeProperty.java rename to com.itjw.txviewer.ui/src/com/itjw/txviewer/ui/views/sections/AttributeProperty.java index c9b5e37..e67dff0 100644 --- a/com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/views/sections/AttributeProperty.java +++ b/com.itjw.txviewer.ui/src/com/itjw/txviewer/ui/views/sections/AttributeProperty.java @@ -8,9 +8,10 @@ * Contributors: * IT Just working - initial API and implementation *******************************************************************************/ -package com.itjw.txviewer.graph.views.sections; +package com.itjw.txviewer.ui.views.sections; import java.util.HashMap; +import java.util.LinkedList; import java.util.List; import java.util.TreeMap; @@ -42,8 +43,9 @@ import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.views.properties.tabbed.AbstractPropertySection; import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage; +import com.itjw.txviewer.database.ITrAttrType; import com.itjw.txviewer.database.ITrAttribute; -import com.itjw.txviewer.graph.data.ITransactionFacade; +import com.itjw.txviewer.database.ITransaction; public class AttributeProperty extends AbstractPropertySection implements ISelectionProvider { @@ -51,7 +53,7 @@ public class AttributeProperty extends AbstractPropertySection implements ISelec private ListenerList listeners = new ListenerList(); - private ITransactionFacade iTr; + private ITransaction iTr; private ISelection currentSelection; @@ -107,33 +109,37 @@ public class AttributeProperty extends AbstractPropertySection implements ISelec @Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - if (newInput instanceof String) { + if (newInput instanceof ITransaction) { + List attributes = ((ITransaction)newInput).getAttributes(); hier.clear(); parents.clear(); + String location="Begin"; - List txSet = iTr.getBeginAttrs(); - if (txSet != null && txSet.size() > 0) { - hier.put(location, txSet); - for (ITrAttribute tr : txSet) - if (tr != null) - parents.put(tr, location); - } - location="Recorded"; - txSet = iTr.getAttributes(); - if (txSet != null && txSet.size() > 0) { - hier.put(location, txSet); - for (ITrAttribute tr : txSet) - if (tr != null) - parents.put(tr, location); - } + List childs=new LinkedList(); + for (ITrAttribute attr : attributes) + if (attr != null && attr.getType()==ITrAttrType.AttributeType.BEGIN){ + childs.add(attr); + parents.put(attr, location); + } + if(childs.size()>0) hier.put(location, childs); + + location="Transaction"; + childs=new LinkedList(); + for (ITrAttribute attr : attributes) + if (attr != null && attr.getType()==ITrAttrType.AttributeType.UNSPECIFIED){ + childs.add(attr); + parents.put(attr, location); + } + if(childs.size()>0) hier.put(location, childs); + location="End"; - txSet = iTr.getEndAttrs(); - if (txSet != null && txSet.size() > 0) { - hier.put(location, txSet); - for (ITrAttribute tr : txSet) - if (tr != null) - parents.put(tr, location); - } + childs=new LinkedList(); + for (ITrAttribute attr : attributes) + if (attr != null && attr.getType()==ITrAttrType.AttributeType.END){ + childs.add(attr); + parents.put(attr, location); + } + if(childs.size()>0) hier.put(location, childs); } } @@ -191,12 +197,13 @@ public class AttributeProperty extends AbstractPropertySection implements ISelec if (columnIndex == 1 ) return attr.getName(); else if (columnIndex == 2 ) - return attr.getType(); + return attr.getDataType(); else if (columnIndex == 3){ - if("UNSIGNED".equals(attr.getType()) && - (attr.getName().contains("addr")||attr.getName().contains("data"))) - return "0x"+Long.toHexString(Long.parseLong(attr.getValue().toString())); - else + if("UNSIGNED".equals(attr.getType()) && (attr.getName().contains("addr")||attr.getName().contains("data"))) + try { + return "0x"+Long.toHexString(Long.parseLong(attr.getValue().toString())); + } catch(NumberFormatException e) { + } return attr.getValue().toString(); } } @@ -228,12 +235,12 @@ public class AttributeProperty extends AbstractPropertySection implements ISelec currentSelection = null; Assert.isTrue(selection instanceof IStructuredSelection); Object input = ((IStructuredSelection) selection).getFirstElement(); - Assert.isTrue(input instanceof ITransactionFacade); - iTr = (ITransactionFacade) input; + Assert.isTrue(input instanceof ITransaction); + iTr = (ITransaction) input; } public void refresh() { - treeViewer.setInput("All"); + treeViewer.setInput(iTr); } @Override diff --git a/com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/views/sections/RelatedProperty.java b/com.itjw.txviewer.ui/src/com/itjw/txviewer/ui/views/sections/RelatedProperty.java similarity index 62% rename from com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/views/sections/RelatedProperty.java rename to com.itjw.txviewer.ui/src/com/itjw/txviewer/ui/views/sections/RelatedProperty.java index 0732578..b7ec901 100644 --- a/com.itjw.txviewer.graph/src/com/itjw/txviewer/graph/views/sections/RelatedProperty.java +++ b/com.itjw.txviewer.ui/src/com/itjw/txviewer/ui/views/sections/RelatedProperty.java @@ -8,14 +8,16 @@ * Contributors: * IT Just working - initial API and implementation *******************************************************************************/ -package com.itjw.txviewer.graph.views.sections; +package com.itjw.txviewer.ui.views.sections; +import java.util.Collection; import java.util.HashMap; import java.util.Set; import java.util.TreeMap; import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.ListenerList; +import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IMenuListener; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.MenuManager; @@ -27,6 +29,7 @@ import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.ITableLabelProvider; import org.eclipse.jface.viewers.ITreeContentProvider; import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.jface.viewers.Viewer; import org.eclipse.swt.SWT; @@ -38,23 +41,25 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Menu; import org.eclipse.swt.widgets.Tree; import org.eclipse.swt.widgets.TreeColumn; +import org.eclipse.ui.IEditorReference; +import org.eclipse.ui.ISharedImages; +import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.PlatformUI; import org.eclipse.ui.views.properties.tabbed.AbstractPropertySection; import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage; +import com.itjw.txviewer.database.ITrRelation; import com.itjw.txviewer.database.ITransaction; import com.itjw.txviewer.database.RelationType; -import com.itjw.txviewer.graph.TransactionSelection; -import com.itjw.txviewer.graph.actions.TxActionFactory; -import com.itjw.txviewer.graph.data.ITransactionFacade; public class RelatedProperty extends AbstractPropertySection implements ISelectionProvider, ISelectionChangedListener { - private final String[] titles = { "Relation", "Tx Id" }; + private final String[] titles = { "Relation type", "Relation Name", "Tx Id" }; private ListenerList listeners = new ListenerList(); - private ITransactionFacade iTr; + private ITransaction iTr; private ISelection currentSelection; @@ -75,10 +80,14 @@ public class RelatedProperty extends AbstractPropertySection implements ISelecti column1.setAlignment(SWT.LEFT); column1.setText(titles[0]); column1.setWidth(150); - TreeColumn column2 = new TreeColumn(tree, SWT.RIGHT); + TreeColumn column2 = new TreeColumn(tree, SWT.LEFT); column2.setAlignment(SWT.LEFT); column2.setText(titles[1]); column2.setWidth(150); + TreeColumn column3 = new TreeColumn(tree, SWT.RIGHT); + column3.setAlignment(SWT.LEFT); + column3.setText(titles[2]); + column3.setWidth(150); Object layoutData = parent.getLayoutData(); if (layoutData instanceof GridData) { @@ -96,25 +105,27 @@ public class RelatedProperty extends AbstractPropertySection implements ISelecti treeViewer.setAutoExpandLevel(2); treeViewer.setContentProvider(new ITreeContentProvider() { - TreeMap> hier = new TreeMap>(); - HashMap parents = new HashMap(); + TreeMap> hier = new TreeMap>(); + HashMap parents = new HashMap(); @Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - if (newInput instanceof RelationType[]) { + if (newInput instanceof ITransaction) { hier.clear(); parents.clear(); - for (RelationType rel : (RelationType[]) newInput) { - Set txSet = iTr.getNextInRelationship(rel); - if (txSet != null && txSet.size() > 0) { - boolean hasChilds=false; - for (ITransaction tr : txSet) - if (tr != null){ - parents.put(tr, rel); - hasChilds=true; - } - if(hasChilds) hier.put(rel, txSet); - } + String relName = "incoming"; + Collection relSet = ((ITransaction)newInput).getIncomingRelations(); + if (relSet != null && relSet.size() > 0) { + hier.put(relName, relSet); + for (ITrRelation rel : relSet) + parents.put(rel, relName); + } + relName = "outgoing"; + relSet = ((ITransaction)newInput).getOutgoingRelations(); + if (relSet != null && relSet.size() > 0) { + hier.put(relName, relSet); + for (ITrRelation rel : relSet) + parents.put(rel, relName); } } } @@ -143,8 +154,8 @@ public class RelatedProperty extends AbstractPropertySection implements ISelecti @Override public Object[] getChildren(Object parentElement) { - if (parentElement instanceof RelationType) - return hier.get((RelationType) parentElement).toArray(); + if (parentElement instanceof String) + return hier.get((String) parentElement).toArray(); else return null; } @@ -166,10 +177,17 @@ public class RelatedProperty extends AbstractPropertySection implements ISelecti @Override public String getColumnText(Object element, int columnIndex) { - if (columnIndex == 0 && element instanceof RelationType) + if (columnIndex == 0 && element instanceof String) return element.toString(); - else if (columnIndex == 1 && element instanceof ITransaction) - return ((ITransaction) element).getId().toString(); + else if (columnIndex == 1 && element instanceof ITrRelation) + return ((ITrRelation) element).getRelationType().getName(); + else if (columnIndex == 2 && element instanceof ITrRelation){ + ITrRelation rel = (ITrRelation) element; + if(rel.getTarget()==iTr) + return ((ITrRelation) element).getSource().getId().toString(); + else + return ((ITrRelation) element).getTarget().getId().toString(); + } else return null; } @@ -184,23 +202,42 @@ public class RelatedProperty extends AbstractPropertySection implements ISelecti menuMgr.setRemoveAllWhenShown(true); menuMgr.addMenuListener(new IMenuListener() { public void menuAboutToShow(IMenuManager mgr) { - fillContextMenu(mgr); + ISelection selection = treeViewer.getSelection(); + if (selection instanceof IStructuredSelection) { + Object obj = ((IStructuredSelection) selection).getFirstElement(); + mgr.add(makeTransactionAction(obj, iTr)); + } } }); Menu menu = menuMgr.createContextMenu(treeViewer.getControl()); treeViewer.getControl().setMenu(menu); - aTabbedPropertySheetPage.getSite().setSelectionProvider(this); - getPart().getSite().setSelectionProvider(this); - +// aTabbedPropertySheetPage.getSite().setSelectionProvider(this); +// if(getPart()!=null){ +// getPart().getSite().setSelectionProvider(this); +// } } - private void fillContextMenu(IMenuManager menuMgr) { - // initalize the context menu - ISelection selection = treeViewer.getSelection(); - if (selection instanceof IStructuredSelection) { - Object obj = ((IStructuredSelection) selection).getFirstElement(); - menuMgr.add(TxActionFactory.getAction(TxActionFactory.JUMP_TO_TX, obj instanceof ITransaction)); - } + private Action makeTransactionAction(final Object obj, final ITransaction transaction) { + Action action = new Action() { + public void run() { + if(obj instanceof ITrRelation){ + IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); + ITransaction targetTransaction = ((ITrRelation)obj).getSource()==transaction? + ((ITrRelation)obj).getTarget():((ITrRelation)obj).getSource(); + for(IEditorReference editorRef: page.getEditorReferences()){ + IWorkbenchPart part =editorRef.getPart(false); + if(editorRef.getPage().isPartVisible(part)){ + part.getSite().getSelectionProvider().setSelection(new StructuredSelection(targetTransaction)); + part.setFocus(); + } + } + } + } + }; + action.setText("Jump to Transaction"); + action.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_OBJ_ADD)); + action.setEnabled(true); + return action; } public void setInput(IWorkbenchPart part, ISelection selection) { @@ -208,12 +245,12 @@ public class RelatedProperty extends AbstractPropertySection implements ISelecti currentSelection = null; Assert.isTrue(selection instanceof IStructuredSelection); Object input = ((IStructuredSelection) selection).getFirstElement(); - Assert.isTrue(input instanceof ITransactionFacade); - iTr = (ITransactionFacade) input; + Assert.isTrue(input instanceof ITransaction); + iTr = (ITransaction) input; } public void refresh() { - treeViewer.setInput(RelationType.values()); + treeViewer.setInput(iTr); } public void aboutToBeShown() { @@ -245,16 +282,14 @@ public class RelatedProperty extends AbstractPropertySection implements ISelecti @Override public void selectionChanged(SelectionChangedEvent event) { - ISelection selection = event.getSelection(); - if(selection instanceof IStructuredSelection){ - IStructuredSelection treeSelection =(IStructuredSelection)selection; - Object elem = treeSelection.getFirstElement(); - if(elem instanceof ITransactionFacade){ - currentSelection = new TransactionSelection((ITransactionFacade)elem); - } else if(elem instanceof ITransaction){ - currentSelection = new TransactionSelection(new ITransactionFacade((ITransaction)elem)); - } - } +// ISelection selection = event.getSelection(); +// if(selection instanceof IStructuredSelection){ +// IStructuredSelection treeSelection =(IStructuredSelection)selection; +// Object elem = treeSelection.getFirstElement(); +// if(elem instanceof ITransaction){ +// currentSelection = new StructuredSelection(elem); +// } +// } } } diff --git a/com.itjw.txviewer.ui/src/org/eclipse/wb/swt/SWTResourceManager.java b/com.itjw.txviewer.ui/src/org/eclipse/wb/swt/SWTResourceManager.java new file mode 100644 index 0000000..429964e --- /dev/null +++ b/com.itjw.txviewer.ui/src/org/eclipse/wb/swt/SWTResourceManager.java @@ -0,0 +1,447 @@ +/******************************************************************************* + * Copyright (c) 2011 Google, Inc. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Google, Inc. - initial API and implementation + *******************************************************************************/ +package org.eclipse.wb.swt; + +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.Cursor; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.FontData; +import org.eclipse.swt.graphics.GC; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.ImageData; +import org.eclipse.swt.graphics.RGB; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.widgets.Display; + +/** + * Utility class for managing OS resources associated with SWT controls such as colors, fonts, images, etc. + *

+ * !!! IMPORTANT !!! Application code must explicitly invoke the dispose() method to release the + * operating system resources managed by cached objects when those objects and OS resources are no longer + * needed (e.g. on application shutdown) + *

+ * This class may be freely distributed as part of any application or plugin. + *

+ * @author scheglov_ke + * @author Dan Rubel + */ +public class SWTResourceManager { + //////////////////////////////////////////////////////////////////////////// + // + // Color + // + //////////////////////////////////////////////////////////////////////////// + private static Map m_colorMap = new HashMap(); + /** + * Returns the system {@link Color} matching the specific ID. + * + * @param systemColorID + * the ID value for the color + * @return the system {@link Color} matching the specific ID + */ + public static Color getColor(int systemColorID) { + Display display = Display.getCurrent(); + return display.getSystemColor(systemColorID); + } + /** + * Returns a {@link Color} given its red, green and blue component values. + * + * @param r + * the red component of the color + * @param g + * the green component of the color + * @param b + * the blue component of the color + * @return the {@link Color} matching the given red, green and blue component values + */ + public static Color getColor(int r, int g, int b) { + return getColor(new RGB(r, g, b)); + } + /** + * Returns a {@link Color} given its RGB value. + * + * @param rgb + * the {@link RGB} value of the color + * @return the {@link Color} matching the RGB value + */ + public static Color getColor(RGB rgb) { + Color color = m_colorMap.get(rgb); + if (color == null) { + Display display = Display.getCurrent(); + color = new Color(display, rgb); + m_colorMap.put(rgb, color); + } + return color; + } + /** + * Dispose of all the cached {@link Color}'s. + */ + public static void disposeColors() { + for (Color color : m_colorMap.values()) { + color.dispose(); + } + m_colorMap.clear(); + } + //////////////////////////////////////////////////////////////////////////// + // + // Image + // + //////////////////////////////////////////////////////////////////////////// + /** + * Maps image paths to images. + */ + private static Map m_imageMap = new HashMap(); + /** + * Returns an {@link Image} encoded by the specified {@link InputStream}. + * + * @param stream + * the {@link InputStream} encoding the image data + * @return the {@link Image} encoded by the specified input stream + */ + protected static Image getImage(InputStream stream) throws IOException { + try { + Display display = Display.getCurrent(); + ImageData data = new ImageData(stream); + if (data.transparentPixel > 0) { + return new Image(display, data, data.getTransparencyMask()); + } + return new Image(display, data); + } finally { + stream.close(); + } + } + /** + * Returns an {@link Image} stored in the file at the specified path. + * + * @param path + * the path to the image file + * @return the {@link Image} stored in the file at the specified path + */ + public static Image getImage(String path) { + Image image = m_imageMap.get(path); + if (image == null) { + try { + image = getImage(new FileInputStream(path)); + m_imageMap.put(path, image); + } catch (Exception e) { + image = getMissingImage(); + m_imageMap.put(path, image); + } + } + return image; + } + /** + * Returns an {@link Image} stored in the file at the specified path relative to the specified class. + * + * @param clazz + * the {@link Class} relative to which to find the image + * @param path + * the path to the image file, if starts with '/' + * @return the {@link Image} stored in the file at the specified path + */ + public static Image getImage(Class clazz, String path) { + String key = clazz.getName() + '|' + path; + Image image = m_imageMap.get(key); + if (image == null) { + try { + image = getImage(clazz.getResourceAsStream(path)); + m_imageMap.put(key, image); + } catch (Exception e) { + image = getMissingImage(); + m_imageMap.put(key, image); + } + } + return image; + } + private static final int MISSING_IMAGE_SIZE = 10; + /** + * @return the small {@link Image} that can be used as placeholder for missing image. + */ + private static Image getMissingImage() { + Image image = new Image(Display.getCurrent(), MISSING_IMAGE_SIZE, MISSING_IMAGE_SIZE); + // + GC gc = new GC(image); + gc.setBackground(getColor(SWT.COLOR_RED)); + gc.fillRectangle(0, 0, MISSING_IMAGE_SIZE, MISSING_IMAGE_SIZE); + gc.dispose(); + // + return image; + } + /** + * Style constant for placing decorator image in top left corner of base image. + */ + public static final int TOP_LEFT = 1; + /** + * Style constant for placing decorator image in top right corner of base image. + */ + public static final int TOP_RIGHT = 2; + /** + * Style constant for placing decorator image in bottom left corner of base image. + */ + public static final int BOTTOM_LEFT = 3; + /** + * Style constant for placing decorator image in bottom right corner of base image. + */ + public static final int BOTTOM_RIGHT = 4; + /** + * Internal value. + */ + protected static final int LAST_CORNER_KEY = 5; + /** + * Maps images to decorated images. + */ + @SuppressWarnings("unchecked") + private static Map>[] m_decoratedImageMap = new Map[LAST_CORNER_KEY]; + /** + * Returns an {@link Image} composed of a base image decorated by another image. + * + * @param baseImage + * the base {@link Image} that should be decorated + * @param decorator + * the {@link Image} to decorate the base image + * @return {@link Image} The resulting decorated image + */ + public static Image decorateImage(Image baseImage, Image decorator) { + return decorateImage(baseImage, decorator, BOTTOM_RIGHT); + } + /** + * Returns an {@link Image} composed of a base image decorated by another image. + * + * @param baseImage + * the base {@link Image} that should be decorated + * @param decorator + * the {@link Image} to decorate the base image + * @param corner + * the corner to place decorator image + * @return the resulting decorated {@link Image} + */ + public static Image decorateImage(final Image baseImage, final Image decorator, final int corner) { + if (corner <= 0 || corner >= LAST_CORNER_KEY) { + throw new IllegalArgumentException("Wrong decorate corner"); + } + Map> cornerDecoratedImageMap = m_decoratedImageMap[corner]; + if (cornerDecoratedImageMap == null) { + cornerDecoratedImageMap = new HashMap>(); + m_decoratedImageMap[corner] = cornerDecoratedImageMap; + } + Map decoratedMap = cornerDecoratedImageMap.get(baseImage); + if (decoratedMap == null) { + decoratedMap = new HashMap(); + cornerDecoratedImageMap.put(baseImage, decoratedMap); + } + // + Image result = decoratedMap.get(decorator); + if (result == null) { + Rectangle bib = baseImage.getBounds(); + Rectangle dib = decorator.getBounds(); + // + result = new Image(Display.getCurrent(), bib.width, bib.height); + // + GC gc = new GC(result); + gc.drawImage(baseImage, 0, 0); + if (corner == TOP_LEFT) { + gc.drawImage(decorator, 0, 0); + } else if (corner == TOP_RIGHT) { + gc.drawImage(decorator, bib.width - dib.width, 0); + } else if (corner == BOTTOM_LEFT) { + gc.drawImage(decorator, 0, bib.height - dib.height); + } else if (corner == BOTTOM_RIGHT) { + gc.drawImage(decorator, bib.width - dib.width, bib.height - dib.height); + } + gc.dispose(); + // + decoratedMap.put(decorator, result); + } + return result; + } + /** + * Dispose all of the cached {@link Image}'s. + */ + public static void disposeImages() { + // dispose loaded images + { + for (Image image : m_imageMap.values()) { + image.dispose(); + } + m_imageMap.clear(); + } + // dispose decorated images + for (int i = 0; i < m_decoratedImageMap.length; i++) { + Map> cornerDecoratedImageMap = m_decoratedImageMap[i]; + if (cornerDecoratedImageMap != null) { + for (Map decoratedMap : cornerDecoratedImageMap.values()) { + for (Image image : decoratedMap.values()) { + image.dispose(); + } + decoratedMap.clear(); + } + cornerDecoratedImageMap.clear(); + } + } + } + //////////////////////////////////////////////////////////////////////////// + // + // Font + // + //////////////////////////////////////////////////////////////////////////// + /** + * Maps font names to fonts. + */ + private static Map m_fontMap = new HashMap(); + /** + * Maps fonts to their bold versions. + */ + private static Map m_fontToBoldFontMap = new HashMap(); + /** + * Returns a {@link Font} based on its name, height and style. + * + * @param name + * the name of the font + * @param height + * the height of the font + * @param style + * the style of the font + * @return {@link Font} The font matching the name, height and style + */ + public static Font getFont(String name, int height, int style) { + return getFont(name, height, style, false, false); + } + /** + * Returns a {@link Font} based on its name, height and style. Windows-specific strikeout and underline + * flags are also supported. + * + * @param name + * the name of the font + * @param size + * the size of the font + * @param style + * the style of the font + * @param strikeout + * the strikeout flag (warning: Windows only) + * @param underline + * the underline flag (warning: Windows only) + * @return {@link Font} The font matching the name, height, style, strikeout and underline + */ + public static Font getFont(String name, int size, int style, boolean strikeout, boolean underline) { + String fontName = name + '|' + size + '|' + style + '|' + strikeout + '|' + underline; + Font font = m_fontMap.get(fontName); + if (font == null) { + FontData fontData = new FontData(name, size, style); + if (strikeout || underline) { + try { + Class logFontClass = Class.forName("org.eclipse.swt.internal.win32.LOGFONT"); //$NON-NLS-1$ + Object logFont = FontData.class.getField("data").get(fontData); //$NON-NLS-1$ + if (logFont != null && logFontClass != null) { + if (strikeout) { + logFontClass.getField("lfStrikeOut").set(logFont, Byte.valueOf((byte) 1)); //$NON-NLS-1$ + } + if (underline) { + logFontClass.getField("lfUnderline").set(logFont, Byte.valueOf((byte) 1)); //$NON-NLS-1$ + } + } + } catch (Throwable e) { + System.err.println("Unable to set underline or strikeout" + " (probably on a non-Windows platform). " + e); //$NON-NLS-1$ //$NON-NLS-2$ + } + } + font = new Font(Display.getCurrent(), fontData); + m_fontMap.put(fontName, font); + } + return font; + } + /** + * Returns a bold version of the given {@link Font}. + * + * @param baseFont + * the {@link Font} for which a bold version is desired + * @return the bold version of the given {@link Font} + */ + public static Font getBoldFont(Font baseFont) { + Font font = m_fontToBoldFontMap.get(baseFont); + if (font == null) { + FontData fontDatas[] = baseFont.getFontData(); + FontData data = fontDatas[0]; + font = new Font(Display.getCurrent(), data.getName(), data.getHeight(), SWT.BOLD); + m_fontToBoldFontMap.put(baseFont, font); + } + return font; + } + /** + * Dispose all of the cached {@link Font}'s. + */ + public static void disposeFonts() { + // clear fonts + for (Font font : m_fontMap.values()) { + font.dispose(); + } + m_fontMap.clear(); + // clear bold fonts + for (Font font : m_fontToBoldFontMap.values()) { + font.dispose(); + } + m_fontToBoldFontMap.clear(); + } + //////////////////////////////////////////////////////////////////////////// + // + // Cursor + // + //////////////////////////////////////////////////////////////////////////// + /** + * Maps IDs to cursors. + */ + private static Map m_idToCursorMap = new HashMap(); + /** + * Returns the system cursor matching the specific ID. + * + * @param id + * int The ID value for the cursor + * @return Cursor The system cursor matching the specific ID + */ + public static Cursor getCursor(int id) { + Integer key = Integer.valueOf(id); + Cursor cursor = m_idToCursorMap.get(key); + if (cursor == null) { + cursor = new Cursor(Display.getDefault(), id); + m_idToCursorMap.put(key, cursor); + } + return cursor; + } + /** + * Dispose all of the cached cursors. + */ + public static void disposeCursors() { + for (Cursor cursor : m_idToCursorMap.values()) { + cursor.dispose(); + } + m_idToCursorMap.clear(); + } + //////////////////////////////////////////////////////////////////////////// + // + // General + // + //////////////////////////////////////////////////////////////////////////// + /** + * Dispose of cached objects and their underlying OS resources. This should only be called when the cached + * objects are no longer needed (e.g. on application shutdown). + */ + public static void dispose() { + disposeColors(); + disposeImages(); + disposeFonts(); + disposeCursors(); + } +} \ No newline at end of file diff --git a/com.itjw.txviewer.ui/swing2swt.jar b/com.itjw.txviewer.ui/swing2swt.jar new file mode 100644 index 0000000..ee261b5 Binary files /dev/null and b/com.itjw.txviewer.ui/swing2swt.jar differ diff --git a/com.itjw.txviewer.updateSite/.project b/com.itjw.txviewer.updateSite/.project new file mode 100644 index 0000000..6c15ff0 --- /dev/null +++ b/com.itjw.txviewer.updateSite/.project @@ -0,0 +1,17 @@ + + + com.itjw.txviewer.updateSite + + + + + + org.eclipse.pde.UpdateSiteBuilder + + + + + + org.eclipse.pde.UpdateSiteNature + + diff --git a/com.itjw.txviewer.updateSite/index.html b/com.itjw.txviewer.updateSite/index.html new file mode 100644 index 0000000..5808011 --- /dev/null +++ b/com.itjw.txviewer.updateSite/index.html @@ -0,0 +1,60 @@ + + +com.itjw.txviewer.updateSite + + + + + + +

+ + diff --git a/com.itjw.txviewer.updateSite/site.xml b/com.itjw.txviewer.updateSite/site.xml new file mode 100644 index 0000000..2ed993d --- /dev/null +++ b/com.itjw.txviewer.updateSite/site.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/com.itjw.txviewer.updateSite/web/site.css b/com.itjw.txviewer.updateSite/web/site.css new file mode 100644 index 0000000..62c6f9f --- /dev/null +++ b/com.itjw.txviewer.updateSite/web/site.css @@ -0,0 +1,12 @@ + diff --git a/com.itjw.txviewer.updateSite/web/site.xsl b/com.itjw.txviewer.updateSite/web/site.xsl new file mode 100644 index 0000000..f459714 --- /dev/null +++ b/com.itjw.txviewer.updateSite/web/site.xsl @@ -0,0 +1,214 @@ + + + + + + + + com.itjw.txviewer.updateSite + + + +

com.itjw.txviewer.updateSite

+

+ + + + + + + + + + + + + + + + dark-row + + + light-row + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + dark-row + + + light-row + + + + + + + + + + + + + + + dark-row + + + light-row + + + + + + + + +
+ + + +
+ + + +
+
+ ( - ) +
+
+ + - + +
+
+
+ + + + + + + + + + + + + + + + + + + + + +
Operating Systems:
Windows Systems:
Languages:
Architecture:
+


+ Uncategorized +
+ + + +
+
+ ( - ) +
+
+ + - + +
+

+
+ + + + + + + + + + + + + + + + + + + + + +
Operating Systems:
Windows Systems:
Languages:
Architecture:
+
+ + + +
+
+ ( - ) +
+
+ + - + +
+

+
+ + + + + + + + + + + + + + + + + + + + + +
Operating Systems:
Windows Systems:
Languages:
Architecture:
+
+ + +
+
+