Added support for VCD Database
This commit is contained in:
@@ -13,7 +13,6 @@ package com.minres.scviewer.ui;
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
@@ -25,7 +24,6 @@ import org.eclipse.ui.IFileEditorInput;
|
||||
import org.eclipse.ui.PartInitException;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
import org.eclipse.ui.ide.FileStoreEditorInput;
|
||||
import org.eclipse.ui.internal.ide.dialogs.IFileStoreFilter;
|
||||
import org.eclipse.ui.part.EditorPart;
|
||||
import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
|
||||
import org.eclipse.ui.views.properties.IPropertySheetPage;
|
||||
@@ -33,12 +31,12 @@ import org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributo
|
||||
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
|
||||
import org.osgi.framework.BundleContext;
|
||||
import org.osgi.framework.FrameworkUtil;
|
||||
import org.osgi.framework.InvalidSyntaxException;
|
||||
import org.osgi.framework.ServiceReference;
|
||||
|
||||
import com.minres.scviewer.database.ITrDb;
|
||||
import com.minres.scviewer.database.ITrStream;
|
||||
import com.minres.scviewer.database.ITransactionDbFactory;
|
||||
import com.minres.scviewer.database.IWaveformDb;
|
||||
import com.minres.scviewer.database.ITxStream;
|
||||
import com.minres.scviewer.database.IWaveformDbFactory;
|
||||
import com.minres.scviewer.database.IWaveform;
|
||||
import com.minres.scviewer.ui.swt.TxDisplay;
|
||||
import com.minres.scviewer.ui.views.TxOutlinePage;
|
||||
|
||||
@@ -51,7 +49,7 @@ public class TxEditorPart extends EditorPart implements ITabbedPropertySheetPage
|
||||
private TxDisplay txDisplay;
|
||||
|
||||
/** This is the root of the editor's model. */
|
||||
private ITrDb database;
|
||||
private IWaveformDb database;
|
||||
|
||||
private Composite myParent;
|
||||
|
||||
@@ -85,7 +83,7 @@ public class TxEditorPart extends EditorPart implements ITabbedPropertySheetPage
|
||||
if(getEditorInput()!=null && ((TxEditorInput) getEditorInput()).getStreamNames().size()>0 && database!=null){
|
||||
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);
|
||||
IWaveform stream = database.getStreamByName(streamName);
|
||||
if(stream!=null)
|
||||
txDisplay.addStream(stream);
|
||||
}
|
||||
@@ -126,10 +124,10 @@ public class TxEditorPart extends EditorPart implements ITabbedPropertySheetPage
|
||||
protected void getTrDatabase(File file) {
|
||||
try {
|
||||
BundleContext context = FrameworkUtil.getBundle(this.getClass()).getBundleContext();
|
||||
ServiceReference<?>[] serviceReferences = context.getServiceReferences(ITransactionDbFactory.class.getName(), null);
|
||||
ServiceReference<?>[] serviceReferences = context.getServiceReferences(IWaveformDbFactory.class.getName(), null);
|
||||
if(serviceReferences!=null){
|
||||
for(ServiceReference<?> serviceReference:serviceReferences){
|
||||
database = ((ITransactionDbFactory) context.getService(serviceReference)).createDatabase(file);
|
||||
database = ((IWaveformDbFactory) context.getService(serviceReference)).createDatabase(file);
|
||||
if(database!=null){
|
||||
if(txDisplay !=null) database.addPropertyChangeListener(txDisplay);
|
||||
return;
|
||||
@@ -180,7 +178,7 @@ public class TxEditorPart extends EditorPart implements ITabbedPropertySheetPage
|
||||
return super.getAdapter(type);
|
||||
}
|
||||
|
||||
public ITrDb getModel() {
|
||||
public IWaveformDb getModel() {
|
||||
return database;
|
||||
}
|
||||
|
||||
@@ -202,38 +200,38 @@ public class TxEditorPart extends EditorPart implements ITabbedPropertySheetPage
|
||||
return false;
|
||||
}
|
||||
|
||||
public ITrDb getDatabase() {
|
||||
public IWaveformDb getDatabase() {
|
||||
return database;
|
||||
}
|
||||
|
||||
public void addStreamToList(ITrStream stream){
|
||||
if(getEditorInput() instanceof TxEditorInput && !((TxEditorInput) getEditorInput()).getStreamNames().contains(stream.getFullName())){
|
||||
((TxEditorInput) getEditorInput()).getStreamNames().add(stream.getFullName());
|
||||
txDisplay.addStream(stream);
|
||||
public void addStreamToList(IWaveform obj){
|
||||
if(getEditorInput() instanceof TxEditorInput && !((TxEditorInput) getEditorInput()).getStreamNames().contains(obj.getFullName())){
|
||||
((TxEditorInput) getEditorInput()).getStreamNames().add(obj.getFullName());
|
||||
txDisplay.addStream(obj);
|
||||
} else
|
||||
txDisplay.addStream(stream);
|
||||
txDisplay.addStream(obj);
|
||||
|
||||
}
|
||||
|
||||
public void addStreamsToList(ITrStream[] streams){
|
||||
for(ITrStream stream:streams)
|
||||
public void addStreamsToList(IWaveform[] iWaveforms){
|
||||
for(IWaveform stream:iWaveforms)
|
||||
addStreamToList(stream);
|
||||
}
|
||||
|
||||
public void removeStreamFromList(ITrStream stream){
|
||||
if(getEditorInput() instanceof TxEditorInput && ((TxEditorInput) getEditorInput()).getStreamNames().contains(stream.getFullName())){
|
||||
((TxEditorInput) getEditorInput()).getStreamNames().remove(stream.getFullName());
|
||||
txDisplay.removeStream(stream);
|
||||
public void removeStreamFromList(IWaveform obj){
|
||||
if(getEditorInput() instanceof TxEditorInput && ((TxEditorInput) getEditorInput()).getStreamNames().contains(obj.getFullName())){
|
||||
((TxEditorInput) getEditorInput()).getStreamNames().remove(obj.getFullName());
|
||||
txDisplay.removeStream(obj);
|
||||
} else
|
||||
txDisplay.removeStream(stream);
|
||||
txDisplay.removeStream(obj);
|
||||
}
|
||||
|
||||
public void removeStreamsFromList(ITrStream[] streams){
|
||||
for(ITrStream stream:streams)
|
||||
public void removeStreamsFromList(IWaveform[] iWaveforms){
|
||||
for(IWaveform stream:iWaveforms)
|
||||
removeStreamFromList(stream);
|
||||
}
|
||||
|
||||
public List<ITrStream> getStreamList(){
|
||||
public List<IWaveform> getStreamList(){
|
||||
return txDisplay.getStreamList();
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.eclipse.ui.plugin.AbstractUIPlugin;
|
||||
import org.eclipse.wb.swt.SWTResourceManager;
|
||||
import org.osgi.framework.BundleContext;
|
||||
|
||||
import com.minres.scviewer.database.ITransactionDbFactory;
|
||||
import com.minres.scviewer.database.IWaveformDbFactory;
|
||||
|
||||
/**
|
||||
* The activator class controls the plug-in life cycle
|
||||
@@ -133,21 +133,4 @@ public class TxEditorPlugin extends AbstractUIPlugin {
|
||||
return resourceBundle;
|
||||
}
|
||||
|
||||
private ITransactionDbFactory transactionDbFactory;
|
||||
private List<ITransactionDbFactory> factories= new ArrayList<ITransactionDbFactory>();
|
||||
public ITransactionDbFactory getTransactionDbFactory() {
|
||||
return transactionDbFactory;
|
||||
}
|
||||
|
||||
public void setTransactionDbFactory(ITransactionDbFactory transactionDbFactory) {
|
||||
factories.add( transactionDbFactory);
|
||||
System.out.println("Service bound");
|
||||
}
|
||||
|
||||
public void unsetTransactionDbFactory(ITransactionDbFactory transactionDbFactory) {
|
||||
factories.remove(transactionDbFactory);
|
||||
System.out.println("Service unbound");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.minres.scviewer.ui.adapter;
|
||||
import org.eclipse.core.runtime.IAdapterFactory;
|
||||
import org.eclipse.ui.views.properties.IPropertySource;
|
||||
|
||||
import com.minres.scviewer.database.ITransaction;
|
||||
import com.minres.scviewer.database.ITx;
|
||||
|
||||
public class AdapterFactory implements IAdapterFactory {
|
||||
|
||||
@@ -11,7 +11,7 @@ public class AdapterFactory implements IAdapterFactory {
|
||||
@Override
|
||||
public Object getAdapter(Object adaptableObject, Class adapterType) {
|
||||
if (adapterType == IPropertySource.class)
|
||||
return new ITransactionPropertySource((ITransaction) adaptableObject);
|
||||
return new ITransactionPropertySource((ITx) adaptableObject);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,11 +16,11 @@ import org.eclipse.ui.views.properties.IPropertyDescriptor;
|
||||
import org.eclipse.ui.views.properties.IPropertySource;
|
||||
import org.eclipse.ui.views.properties.PropertyDescriptor;
|
||||
|
||||
import com.minres.scviewer.database.ITransaction;
|
||||
import com.minres.scviewer.database.ITx;
|
||||
|
||||
public class ITransactionPropertySource implements IPropertySource {
|
||||
|
||||
private ITransaction iTransaction;
|
||||
private ITx iTransaction;
|
||||
|
||||
public final static String PROPERTY_ID = "ID";
|
||||
public final static String PROPERTY_BEGINTIME = "BEGINTIME";
|
||||
@@ -29,7 +29,7 @@ public class ITransactionPropertySource implements IPropertySource {
|
||||
|
||||
protected IPropertyDescriptor[] propertyDescriptors;
|
||||
|
||||
public ITransactionPropertySource(ITransaction iTransaction) {
|
||||
public ITransactionPropertySource(ITx iTransaction) {
|
||||
this.iTransaction=iTransaction;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.minres.scviewer.ui.swt;
|
||||
|
||||
public interface IWaveformWidget {
|
||||
|
||||
Transaction highlight(Object sel);
|
||||
|
||||
}
|
||||
@@ -70,9 +70,9 @@ public class Ruler extends Composite {
|
||||
int end=start+e.width;
|
||||
|
||||
gc.setBackground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
|
||||
gc.fillRectangle(new Rectangle(0, 0, e.width, height));
|
||||
gc.fillRectangle(new Rectangle(e.x, e.y, e.width, height));
|
||||
gc.setBackground(headerBgColor);
|
||||
gc.fillRectangle(new Rectangle(0, 0, e.width, height - 1));
|
||||
gc.fillRectangle(new Rectangle(e.x, e.y, e.width, height - 1));
|
||||
gc.setForeground(headerFgColor);
|
||||
gc.drawLine(0, bottom, e.width, bottom);
|
||||
|
||||
|
||||
@@ -0,0 +1,168 @@
|
||||
package com.minres.scviewer.ui.swt;
|
||||
|
||||
import java.util.NavigableSet;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
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.Canvas;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.wb.swt.SWTResourceManager;
|
||||
|
||||
import com.minres.scviewer.database.EventTime;
|
||||
import com.minres.scviewer.database.ISignal;
|
||||
import com.minres.scviewer.database.ISignalChange;
|
||||
import com.minres.scviewer.database.ISignalChangeMulti;
|
||||
import com.minres.scviewer.database.ISignalChangeSingle;
|
||||
import com.minres.scviewer.ui.TxEditorPlugin;
|
||||
|
||||
public class SignalWidget extends Canvas implements IWaveformWidget{
|
||||
|
||||
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 Color color0;
|
||||
private Color color1;
|
||||
private Color colorZ;
|
||||
private Color colorZdark;
|
||||
private Color colorX;
|
||||
private Color colorXdark;
|
||||
private Color colorC;
|
||||
private long length;
|
||||
ISignal<ISignalChange> signal;
|
||||
|
||||
public SignalWidget(Composite parent, int style) {
|
||||
super(parent, style);
|
||||
addPaintListener(new PaintListener() {
|
||||
public void paintControl(PaintEvent e) {
|
||||
SignalWidget.this.paintControl(e);
|
||||
}
|
||||
});
|
||||
TxEditorPlugin plugin=TxEditorPlugin.getDefault();
|
||||
lineColor=plugin.getColor(TxEditorPlugin.lineColor);
|
||||
trackBgColor=plugin.getColor(TxEditorPlugin.trackBgDarkColor);
|
||||
color0=SWTResourceManager.getColor(SWT.COLOR_DARK_GREEN);
|
||||
color1=SWTResourceManager.getColor(SWT.COLOR_GREEN);
|
||||
colorZ=SWTResourceManager.getColor(SWT.COLOR_GRAY);
|
||||
colorX=SWTResourceManager.getColor(SWT.COLOR_RED);
|
||||
colorZdark=SWTResourceManager.getColor(SWT.COLOR_DARK_GRAY);
|
||||
colorXdark=SWTResourceManager.getColor(SWT.COLOR_DARK_RED);
|
||||
colorC=SWTResourceManager.getColor(SWT.COLOR_BLUE);
|
||||
}
|
||||
|
||||
public void setTransactions(ISignal<ISignalChange> signal) {
|
||||
this.signal=signal;
|
||||
ISignalChange change = signal.getSignalChanges().last();
|
||||
length=(long) (change.getTime().getValue()/zoomFactor);
|
||||
layout(true,true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point computeSize (int wHint, int hHint, boolean changed) {
|
||||
return new Point((int) length, trackHeight);
|
||||
}
|
||||
|
||||
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));
|
||||
ISignalChange lastChange = null;
|
||||
NavigableSet<ISignalChange> visibleChanges = signal.getSignalChangesByTimes(
|
||||
new EventTime((long) (e.x*zoomFactor), "fs"),
|
||||
new EventTime((long) ((e.x+e.width)*zoomFactor), "fs"));
|
||||
for(ISignalChange actChange:visibleChanges){
|
||||
if(lastChange!=null){
|
||||
drawValues(e, gc, lastChange, actChange);
|
||||
}
|
||||
lastChange=actChange;
|
||||
}
|
||||
}
|
||||
|
||||
protected void drawValues(PaintEvent e, GC gc, ISignalChange lastChange, ISignalChange actChange) {
|
||||
if(lastChange instanceof ISignalChangeSingle){
|
||||
int yOffset = trackHeight/2;
|
||||
Color color = colorX;
|
||||
switch(((ISignalChangeSingle) lastChange).getValue()){
|
||||
case '1':
|
||||
color=color1;
|
||||
yOffset = trackHeight/3;
|
||||
break;
|
||||
case '0':
|
||||
color=color0;
|
||||
yOffset = 2*trackHeight/3;
|
||||
break;
|
||||
case 'Z':
|
||||
color=colorZ;
|
||||
break;
|
||||
default:
|
||||
}
|
||||
gc.setForeground(color);
|
||||
int endTime= (int)(actChange.getTime().getValue()/zoomFactor);
|
||||
gc.drawLine((int)(lastChange.getTime().getValue()/zoomFactor), yOffset,
|
||||
endTime, yOffset);
|
||||
int yNext = trackHeight/2;
|
||||
switch(((ISignalChangeSingle) actChange).getValue()){
|
||||
case '1':
|
||||
yNext = trackHeight/3;
|
||||
break;
|
||||
case '0':
|
||||
yNext = 2*trackHeight/3;
|
||||
break;
|
||||
default:
|
||||
}
|
||||
gc.setForeground(colorC);
|
||||
if(yOffset<yNext)
|
||||
gc.drawLine(endTime, yOffset, endTime, yNext);
|
||||
else
|
||||
gc.drawLine(endTime, yNext, endTime, yOffset);
|
||||
|
||||
} else if(lastChange instanceof ISignalChangeMulti){
|
||||
int yOffsetT = trackHeight/3;
|
||||
int yOffsetM = trackHeight/2;
|
||||
int yOffsetB = 2*trackHeight/3;
|
||||
Color color = color1;
|
||||
Color colorBorder = color0;
|
||||
ISignalChangeMulti last = (ISignalChangeMulti) lastChange;
|
||||
if(last.getValue().contains("X")){
|
||||
color=colorX;
|
||||
colorBorder=colorXdark;
|
||||
}else if(last.getValue().contains("Z")){
|
||||
color=colorZ;
|
||||
colorBorder=colorZdark;
|
||||
}
|
||||
int beginTime= (int)(lastChange.getTime().getValue()/zoomFactor);
|
||||
int endTime= (int)(actChange.getTime().getValue()/zoomFactor);
|
||||
int[] points = {
|
||||
beginTime,yOffsetM,
|
||||
beginTime+1,yOffsetT,
|
||||
endTime-1,yOffsetT,
|
||||
endTime,yOffsetM,
|
||||
endTime-1,yOffsetB,
|
||||
beginTime+1,yOffsetB
|
||||
};
|
||||
gc.setBackground(color);
|
||||
gc.fillPolygon(points);
|
||||
gc.setForeground(colorBorder);
|
||||
gc.drawPolygon(points);
|
||||
gc.drawText(last.getValue(), beginTime+1, yOffsetT+1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Transaction highlight(Object sel) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -21,10 +21,10 @@ import org.eclipse.swt.widgets.Event;
|
||||
import org.eclipse.swt.widgets.Layout;
|
||||
|
||||
import com.minres.scviewer.database.EventTime;
|
||||
import com.minres.scviewer.database.ITransaction;
|
||||
import com.minres.scviewer.database.ITx;
|
||||
import com.minres.scviewer.ui.TxEditorPlugin;
|
||||
|
||||
public class Track extends Composite implements MouseListener {
|
||||
public class Track extends Composite implements IWaveformWidget, MouseListener {
|
||||
|
||||
static final int trackHeight = 50;
|
||||
static final int trackInset = 2;
|
||||
@@ -34,9 +34,9 @@ public class Track extends Composite implements MouseListener {
|
||||
private Color lineColor;
|
||||
private Color trackBgColor;
|
||||
|
||||
private ITransaction highlightedTx=null;
|
||||
private ITx highlightedTx=null;
|
||||
|
||||
private HashMap<ITransaction, Transaction> transactionMap = new HashMap<ITransaction, Transaction>();
|
||||
private HashMap<ITx, Transaction> transactionMap = new HashMap<ITx, Transaction>();
|
||||
|
||||
class TrackLayoutData {
|
||||
protected int x, y;
|
||||
@@ -121,11 +121,11 @@ public class Track extends Composite implements MouseListener {
|
||||
}
|
||||
|
||||
|
||||
public void setTransactions(List<ITransaction> transactions) {
|
||||
Vector<ITransaction> rowendtime = new Vector<ITransaction>();
|
||||
for (ITransaction tx : transactions) {
|
||||
public void setTransactions(List<ITx> transactions) {
|
||||
Vector<ITx> rowendtime = new Vector<ITx>();
|
||||
for (ITx tx : transactions) {
|
||||
int rowIdx = 0;
|
||||
for (ITransaction lastTx : rowendtime) {
|
||||
for (ITx lastTx : rowendtime) {
|
||||
if((lastTx.getEndTime().getValue()-lastTx.getBeginTime().getValue())>0){
|
||||
if (lastTx.getEndTime().compareTo(tx.getBeginTime())<=0 )
|
||||
break;
|
||||
@@ -187,16 +187,19 @@ public class Track extends Composite implements MouseListener {
|
||||
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;
|
||||
public Transaction highlight(Object obj){
|
||||
if(obj instanceof ITx){
|
||||
ITx tx = (ITx) obj;
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -52,14 +52,17 @@ import org.eclipse.wb.swt.SWTResourceManager;
|
||||
|
||||
import swing2swt.layout.BorderLayout;
|
||||
|
||||
import com.minres.scviewer.database.ITrStream;
|
||||
import com.minres.scviewer.database.ITransaction;
|
||||
import com.minres.scviewer.database.ISignal;
|
||||
import com.minres.scviewer.database.ISignalChange;
|
||||
import com.minres.scviewer.database.ITxStream;
|
||||
import com.minres.scviewer.database.ITx;
|
||||
import com.minres.scviewer.database.IWaveform;
|
||||
|
||||
public class TxDisplay implements PropertyChangeListener, ISelectionProvider, MouseListener{
|
||||
|
||||
private ListenerList listeners = new ListenerList();
|
||||
private ITrStream currentStreamSelection;
|
||||
private ITransaction currentSelection;
|
||||
private ITxStream currentStreamSelection;
|
||||
private ITx currentSelection;
|
||||
private ScrolledComposite valueListScrolled;
|
||||
private ScrolledComposite nameListScrolled;
|
||||
private Composite nameList;
|
||||
@@ -67,10 +70,10 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
|
||||
private ScrolledComposite trackListScrolled;
|
||||
private Composite trackList;
|
||||
private Composite top;
|
||||
private ArrayList<ITrStream> streams=new ArrayList<ITrStream>();
|
||||
private ArrayList<IWaveform> streams=new ArrayList<IWaveform>();
|
||||
private Composite trackPane;
|
||||
private Ruler ruler;
|
||||
private HashMap<ITrStream, Track> trackMap = new HashMap<ITrStream, Track>();
|
||||
private HashMap<IWaveform, IWaveformWidget> trackMap = new HashMap<IWaveform, IWaveformWidget>();
|
||||
|
||||
public TxDisplay(Composite parent) {
|
||||
top = new Composite(parent, SWT.NONE);
|
||||
@@ -207,40 +210,63 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
|
||||
}
|
||||
|
||||
public void streamListChanged() {
|
||||
LinkedList<ITrStream>toAdd = new LinkedList<ITrStream>();
|
||||
LinkedList<IWaveform>toAdd = new LinkedList<IWaveform>();
|
||||
toAdd.addAll(streams);
|
||||
for(Control child:trackList.getChildren()){
|
||||
Track track = (Track) child;
|
||||
Control c = (Control)track.getData("NAMEWIDGET");
|
||||
ITrStream stream=(ITrStream) track.getData("STREAM");
|
||||
IWaveform stream=(IWaveform) child.getData("WAVEFORM");
|
||||
if(!streams.contains(stream)){
|
||||
track.setVisible(false);
|
||||
c.setVisible(false);
|
||||
child.setVisible(false);
|
||||
((Control)(child.getData("NAMEWIDGET"))).setVisible(false);
|
||||
((Control)(child.getData("VALUEWIDGET"))).setVisible(false);
|
||||
}else{
|
||||
toAdd.remove(stream);
|
||||
track.setVisible(true);
|
||||
c.setVisible(true);
|
||||
child.setVisible(true);
|
||||
((Control)(child.getData("NAMEWIDGET"))).setVisible(true);
|
||||
((Control)(child.getData("VALUEWIDGET"))).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);
|
||||
for(IWaveform wave: toAdd){
|
||||
if(wave instanceof ITxStream){
|
||||
ITxStream stream = (ITxStream) wave;
|
||||
Track track = new Track(trackList,SWT.NONE);
|
||||
track.setTransactions(stream.getTransactions());
|
||||
track.setData("WAVEFORM", 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);
|
||||
} else if(wave instanceof ISignal<?>){
|
||||
ISignal<ISignalChange> isignal = (ISignal<ISignalChange>) wave;
|
||||
SignalWidget signal = new SignalWidget(trackList, SWT.NONE);
|
||||
signal.setTransactions(isignal);
|
||||
signal.setData("WAVEFORM", isignal);
|
||||
signal.addMouseListener(this);
|
||||
Point trackSize = signal.computeSize(SWT.DEFAULT,SWT.DEFAULT);
|
||||
|
||||
Label trackName = new Label(nameList, SWT.NONE);
|
||||
trackName.setText(isignal.getFullName());
|
||||
RowData trackNamelayoutData = new RowData(SWT.DEFAULT, trackSize.y);
|
||||
trackName.setLayoutData(trackNamelayoutData);
|
||||
signal.setData("NAMEWIDGET", trackName);
|
||||
|
||||
Label trackValue = new Label(valueList, SWT.NONE);
|
||||
trackValue.setText("-");
|
||||
RowData trackValuelayoutData = new RowData(SWT.DEFAULT, trackSize.y);
|
||||
trackValue.setLayoutData(trackValuelayoutData);
|
||||
signal.setData("VALUEWIDGET", trackValue);
|
||||
trackMap.put(isignal, signal);
|
||||
}
|
||||
}
|
||||
recalculateNameBounds();
|
||||
recalculateValueBounds();
|
||||
@@ -276,9 +302,9 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent pce) {
|
||||
currentSelection=null;
|
||||
ITrStream str = (ITrStream)pce.getNewValue();
|
||||
if(str instanceof ITrStream)
|
||||
currentStreamSelection=(ITrStream)str;
|
||||
ITxStream str = (ITxStream)pce.getNewValue();
|
||||
if(str instanceof ITxStream)
|
||||
currentStreamSelection=(ITxStream)str;
|
||||
if(currentStreamSelection!=null)
|
||||
setSelection(getSelection());
|
||||
else
|
||||
@@ -309,15 +335,15 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
|
||||
public void setSelection(ISelection selection) {
|
||||
if(selection instanceof IStructuredSelection){
|
||||
Object sel =((IStructuredSelection)selection).getFirstElement();
|
||||
if(sel instanceof ITransaction && currentSelection!=sel){
|
||||
if(sel instanceof ITx && currentSelection!=sel){
|
||||
if(currentSelection!=null){
|
||||
ITrStream stream = currentSelection.getGenerator().getStream();
|
||||
if(trackMap.containsKey(stream)) trackMap.get(stream).highlightTransaction(null);
|
||||
ITxStream stream = currentSelection.getGenerator().getStream();
|
||||
if(trackMap.containsKey(stream)) trackMap.get(stream).highlight(null);
|
||||
}
|
||||
currentSelection=(ITransaction) sel;
|
||||
ITrStream stream = currentSelection.getGenerator().getStream();
|
||||
currentSelection=(ITx) sel;
|
||||
ITxStream stream = currentSelection.getGenerator().getStream();
|
||||
if(trackMap.containsKey(stream)){
|
||||
Transaction trans = trackMap.get(stream).highlightTransaction(currentSelection);
|
||||
Transaction trans = trackMap.get(stream).highlight(sel);
|
||||
trackListScrolled.showControl(trans);
|
||||
}
|
||||
Object[] list = listeners.getListeners();
|
||||
@@ -337,7 +363,7 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
|
||||
if(e.data!=null){
|
||||
StructuredSelection sel = new StructuredSelection(((Transaction)e.data).getData());
|
||||
setSelection(sel);
|
||||
}else{
|
||||
}else if(e.widget instanceof Track){
|
||||
StructuredSelection sel = new StructuredSelection(new Object[]{ ((Track)e.widget).getData()});
|
||||
setSelection(sel);
|
||||
}
|
||||
@@ -347,26 +373,26 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
|
||||
public void mouseUp(MouseEvent e) {
|
||||
}
|
||||
|
||||
public boolean addStream(ITrStream paramE){
|
||||
boolean res = streams.add(paramE);
|
||||
public boolean addStream(IWaveform stream){
|
||||
boolean res = streams.add(stream);
|
||||
streamListChanged();
|
||||
return res;
|
||||
}
|
||||
|
||||
public boolean addAllStreams(ITrStream[] streams) {
|
||||
public boolean addAllStreams(ITxStream[] streams) {
|
||||
boolean res = this.streams.addAll(Arrays.asList(streams));
|
||||
streamListChanged();
|
||||
return res;
|
||||
}
|
||||
|
||||
public boolean addAllStreams(Collection<? extends ITrStream> paramCollection){
|
||||
public boolean addAllStreams(Collection<? extends ITxStream> paramCollection){
|
||||
boolean res = streams.addAll(paramCollection);
|
||||
streamListChanged();
|
||||
return res;
|
||||
}
|
||||
|
||||
public boolean removeStream(ITrStream paramObject){
|
||||
boolean res = streams.remove(paramObject);
|
||||
public boolean removeStream(IWaveform obj){
|
||||
boolean res = streams.remove(obj);
|
||||
streamListChanged();
|
||||
return res;
|
||||
}
|
||||
@@ -377,11 +403,11 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
|
||||
return res;
|
||||
}
|
||||
|
||||
public List<ITrStream> getStreamList(){
|
||||
public List<IWaveform> getStreamList(){
|
||||
return Collections.unmodifiableList(streams);
|
||||
}
|
||||
|
||||
public boolean removeAllStreams(ITrStream[] streams) {
|
||||
public boolean removeAllStreams(ITxStream[] streams) {
|
||||
boolean res = this.streams.removeAll(Arrays.asList(streams));
|
||||
streamListChanged();
|
||||
return res;
|
||||
|
||||
@@ -35,9 +35,10 @@ import org.eclipse.ui.part.IPageSite;
|
||||
import org.eclipse.ui.views.contentoutline.ContentOutline;
|
||||
import org.eclipse.ui.views.contentoutline.ContentOutlinePage;
|
||||
|
||||
import com.minres.scviewer.database.ITrHierNode;
|
||||
import com.minres.scviewer.database.ITrStream;
|
||||
import com.minres.scviewer.database.ITransaction;
|
||||
import com.minres.scviewer.database.IHierNode;
|
||||
import com.minres.scviewer.database.ITxStream;
|
||||
import com.minres.scviewer.database.ITx;
|
||||
import com.minres.scviewer.database.IWaveform;
|
||||
import com.minres.scviewer.ui.TxEditorPart;
|
||||
import com.minres.scviewer.ui.views.provider.TxDbTreeContentProvider;
|
||||
import com.minres.scviewer.ui.views.provider.TxDbTreeLabelProvider;
|
||||
@@ -124,10 +125,10 @@ public class TxOutlinePage extends ContentOutlinePage implements ISelectionList
|
||||
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 to Wave", ISharedImages.IMG_OBJ_ADD, sel, obj instanceof IWaveform, 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));
|
||||
// menuMgr.add(makeStreamAction("Remove from Wave", ISharedImages.IMG_TOOL_DELETE, sel, obj instanceof IWaveform, true));
|
||||
// menuMgr.add(makeStreamAction("Remove all from Wave", ISharedImages.IMG_TOOL_DELETE, sel, true, true));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,8 +169,8 @@ public class TxOutlinePage extends ContentOutlinePage implements ISelectionList
|
||||
ISelection selection = anEvent.getSelection();
|
||||
if (!selection.isEmpty()) {
|
||||
Object tmp = ((IStructuredSelection) selection).getFirstElement();
|
||||
if (tmp instanceof ITrHierNode) {
|
||||
fireSelectionChanged(new StructuredSelection((ITrHierNode) tmp));
|
||||
if (tmp instanceof IHierNode) {
|
||||
fireSelectionChanged(new StructuredSelection((IHierNode) tmp));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -179,31 +180,31 @@ public class TxOutlinePage extends ContentOutlinePage implements ISelectionList
|
||||
public void run() {
|
||||
if(selection!=null)
|
||||
for(Object obj :selection.toArray()){
|
||||
if(obj instanceof ITrStream){
|
||||
if(obj instanceof IWaveform){
|
||||
if(remove)
|
||||
editor.removeStreamFromList((ITrStream) obj);
|
||||
editor.removeStreamFromList((IWaveform) obj);
|
||||
else
|
||||
editor.addStreamToList((ITrStream) obj);
|
||||
} else if(obj instanceof ITrHierNode){
|
||||
LinkedList<ITrHierNode> queue = new LinkedList<ITrHierNode>();
|
||||
LinkedList<ITrStream> streams = new LinkedList<ITrStream>();
|
||||
queue.add((ITrHierNode)obj);
|
||||
editor.addStreamToList((IWaveform) obj);
|
||||
} else if(obj instanceof IHierNode){
|
||||
LinkedList<IHierNode> queue = new LinkedList<IHierNode>();
|
||||
LinkedList<IWaveform> streams = new LinkedList<IWaveform>();
|
||||
queue.add((IHierNode)obj);
|
||||
while(queue.size()>0){
|
||||
ITrHierNode n = queue.poll();
|
||||
if(n instanceof ITrStream) streams.add((ITrStream) n);
|
||||
IHierNode n = queue.poll();
|
||||
if(n instanceof IWaveform) streams.add((IWaveform) n);
|
||||
queue.addAll(n.getChildNodes());
|
||||
}
|
||||
if(remove)
|
||||
editor.removeStreamsFromList(streams.toArray(new ITrStream[]{}));
|
||||
editor.removeStreamsFromList(streams.toArray(new IWaveform[]{}));
|
||||
else
|
||||
editor.addStreamsToList(streams.toArray(new ITrStream[]{}));
|
||||
editor.addStreamsToList(streams.toArray(new IWaveform[]{}));
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
action.setText(text);
|
||||
action.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(imgDescriptor));
|
||||
if(selection.getFirstElement() instanceof ITrStream && editor.getStreamList().contains(selection.getFirstElement()))
|
||||
if(selection.getFirstElement() instanceof IWaveform && editor.getStreamList().contains(selection.getFirstElement()))
|
||||
action.setEnabled(false);
|
||||
else
|
||||
action.setEnabled(true);
|
||||
|
||||
@@ -13,19 +13,19 @@ package com.minres.scviewer.ui.views.provider;
|
||||
import org.eclipse.jface.viewers.ITreeContentProvider;
|
||||
import org.eclipse.jface.viewers.Viewer;
|
||||
|
||||
import com.minres.scviewer.database.ITrDb;
|
||||
import com.minres.scviewer.database.ITrHierNode;
|
||||
import com.minres.scviewer.database.IWaveformDb;
|
||||
import com.minres.scviewer.database.IHierNode;
|
||||
|
||||
public class TxDbTreeContentProvider implements ITreeContentProvider {
|
||||
|
||||
private ITrDb database;
|
||||
private IWaveformDb database;
|
||||
|
||||
@Override
|
||||
public void dispose() { }
|
||||
|
||||
@Override
|
||||
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
|
||||
database=(ITrDb)newInput;
|
||||
database=(IWaveformDb)newInput;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -35,8 +35,8 @@ public class TxDbTreeContentProvider implements ITreeContentProvider {
|
||||
|
||||
@Override
|
||||
public Object[] getChildren(Object parentElement) {
|
||||
if(parentElement instanceof ITrHierNode){
|
||||
return ((ITrHierNode)parentElement).getChildNodes().toArray();
|
||||
if(parentElement instanceof IHierNode){
|
||||
return ((IHierNode)parentElement).getChildNodes().toArray();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -17,9 +17,10 @@ import org.eclipse.jface.viewers.ILabelProvider;
|
||||
import org.eclipse.jface.viewers.ILabelProviderListener;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
|
||||
import com.minres.scviewer.database.ITrDb;
|
||||
import com.minres.scviewer.database.ITrHierNode;
|
||||
import com.minres.scviewer.database.ITrStream;
|
||||
import com.minres.scviewer.database.ISignal;
|
||||
import com.minres.scviewer.database.IWaveformDb;
|
||||
import com.minres.scviewer.database.IHierNode;
|
||||
import com.minres.scviewer.database.ITxStream;
|
||||
import com.minres.scviewer.ui.TxEditorPlugin;
|
||||
|
||||
public class TxDbTreeLabelProvider implements ILabelProvider {
|
||||
@@ -28,6 +29,7 @@ public class TxDbTreeLabelProvider implements ILabelProvider {
|
||||
|
||||
private Image database;
|
||||
private Image stream;
|
||||
private Image signal;
|
||||
private Image folder;
|
||||
|
||||
|
||||
@@ -36,6 +38,7 @@ public class TxDbTreeLabelProvider implements ILabelProvider {
|
||||
database=TxEditorPlugin.createImage("database");
|
||||
stream=TxEditorPlugin.createImage("stream");
|
||||
folder=TxEditorPlugin.createImage("folder");
|
||||
signal=TxEditorPlugin.createImage("signal");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -48,6 +51,7 @@ public class TxDbTreeLabelProvider implements ILabelProvider {
|
||||
if(database!=null) database.dispose();
|
||||
if(stream!=null) stream.dispose();
|
||||
if(folder!=null) folder.dispose();
|
||||
if(signal!=null) signal.dispose();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -62,11 +66,13 @@ public class TxDbTreeLabelProvider implements ILabelProvider {
|
||||
|
||||
@Override
|
||||
public Image getImage(Object element) {
|
||||
if(element instanceof ITrDb){
|
||||
if(element instanceof IWaveformDb){
|
||||
return database;
|
||||
}else if(element instanceof ITrStream){
|
||||
}else if(element instanceof ITxStream){
|
||||
return stream;
|
||||
}else if(element instanceof ITrHierNode){
|
||||
}else if(element instanceof ISignal<?>){
|
||||
return signal;
|
||||
}else if(element instanceof IHierNode){
|
||||
return folder;
|
||||
} else
|
||||
return null;
|
||||
@@ -74,7 +80,7 @@ public class TxDbTreeLabelProvider implements ILabelProvider {
|
||||
|
||||
@Override
|
||||
public String getText(Object element) {
|
||||
return ((ITrHierNode)element).getName();
|
||||
return ((IHierNode)element).getName();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -44,8 +44,8 @@ import org.eclipse.ui.views.properties.tabbed.AbstractPropertySection;
|
||||
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
|
||||
|
||||
import com.minres.scviewer.database.AssociationType;
|
||||
import com.minres.scviewer.database.ITrAttribute;
|
||||
import com.minres.scviewer.database.ITransaction;
|
||||
import com.minres.scviewer.database.ITxAttribute;
|
||||
import com.minres.scviewer.database.ITx;
|
||||
|
||||
public class AttributeProperty extends AbstractPropertySection implements ISelectionProvider {
|
||||
|
||||
@@ -53,7 +53,7 @@ public class AttributeProperty extends AbstractPropertySection implements ISelec
|
||||
|
||||
private ListenerList listeners = new ListenerList();
|
||||
|
||||
private ITransaction iTr;
|
||||
private ITx iTr;
|
||||
|
||||
private ISelection currentSelection;
|
||||
|
||||
@@ -104,19 +104,19 @@ public class AttributeProperty extends AbstractPropertySection implements ISelec
|
||||
|
||||
treeViewer.setAutoExpandLevel(2);
|
||||
treeViewer.setContentProvider(new ITreeContentProvider() {
|
||||
TreeMap<String, List<ITrAttribute>> hier = new TreeMap<String, List<ITrAttribute>>();
|
||||
HashMap<ITrAttribute, String> parents = new HashMap<ITrAttribute, String>();
|
||||
TreeMap<String, List<ITxAttribute>> hier = new TreeMap<String, List<ITxAttribute>>();
|
||||
HashMap<ITxAttribute, String> parents = new HashMap<ITxAttribute, String>();
|
||||
|
||||
@Override
|
||||
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
|
||||
if (newInput instanceof ITransaction) {
|
||||
List<ITrAttribute> attributes = ((ITransaction)newInput).getAttributes();
|
||||
if (newInput instanceof ITx) {
|
||||
List<ITxAttribute> attributes = ((ITx)newInput).getAttributes();
|
||||
hier.clear();
|
||||
parents.clear();
|
||||
|
||||
String location="Begin";
|
||||
List<ITrAttribute> childs=new LinkedList<ITrAttribute>();
|
||||
for (ITrAttribute attr : attributes)
|
||||
List<ITxAttribute> childs=new LinkedList<ITxAttribute>();
|
||||
for (ITxAttribute attr : attributes)
|
||||
if (attr != null && attr.getType()==AssociationType.BEGIN){
|
||||
childs.add(attr);
|
||||
parents.put(attr, location);
|
||||
@@ -124,8 +124,8 @@ public class AttributeProperty extends AbstractPropertySection implements ISelec
|
||||
if(childs.size()>0) hier.put(location, childs);
|
||||
|
||||
location="Transaction";
|
||||
childs=new LinkedList<ITrAttribute>();
|
||||
for (ITrAttribute attr : attributes)
|
||||
childs=new LinkedList<ITxAttribute>();
|
||||
for (ITxAttribute attr : attributes)
|
||||
if (attr != null && attr.getType()==AssociationType.RECORD){
|
||||
childs.add(attr);
|
||||
parents.put(attr, location);
|
||||
@@ -133,8 +133,8 @@ public class AttributeProperty extends AbstractPropertySection implements ISelec
|
||||
if(childs.size()>0) hier.put(location, childs);
|
||||
|
||||
location="End";
|
||||
childs=new LinkedList<ITrAttribute>();
|
||||
for (ITrAttribute attr : attributes)
|
||||
childs=new LinkedList<ITxAttribute>();
|
||||
for (ITxAttribute attr : attributes)
|
||||
if (attr != null && attr.getType()==AssociationType.END){
|
||||
childs.add(attr);
|
||||
parents.put(attr, location);
|
||||
@@ -154,7 +154,7 @@ public class AttributeProperty extends AbstractPropertySection implements ISelec
|
||||
|
||||
@Override
|
||||
public Object getParent(Object element) {
|
||||
if (element instanceof ITrAttribute)
|
||||
if (element instanceof ITxAttribute)
|
||||
return parents.get(element);
|
||||
else
|
||||
return null;
|
||||
@@ -192,8 +192,8 @@ public class AttributeProperty extends AbstractPropertySection implements ISelec
|
||||
public String getColumnText(Object element, int columnIndex) {
|
||||
if (columnIndex == 0 && element instanceof String)
|
||||
return element.toString();
|
||||
else if(element instanceof ITrAttribute){
|
||||
ITrAttribute attr = (ITrAttribute)element;
|
||||
else if(element instanceof ITxAttribute){
|
||||
ITxAttribute attr = (ITxAttribute)element;
|
||||
if (columnIndex == 1 )
|
||||
return attr.getName();
|
||||
else if (columnIndex == 2 )
|
||||
@@ -235,8 +235,8 @@ public class AttributeProperty extends AbstractPropertySection implements ISelec
|
||||
currentSelection = null;
|
||||
Assert.isTrue(selection instanceof IStructuredSelection);
|
||||
Object input = ((IStructuredSelection) selection).getFirstElement();
|
||||
Assert.isTrue(input instanceof ITransaction);
|
||||
iTr = (ITransaction) input;
|
||||
Assert.isTrue(input instanceof ITx);
|
||||
iTr = (ITx) input;
|
||||
}
|
||||
|
||||
public void refresh() {
|
||||
|
||||
@@ -49,8 +49,8 @@ import org.eclipse.ui.PlatformUI;
|
||||
import org.eclipse.ui.views.properties.tabbed.AbstractPropertySection;
|
||||
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
|
||||
|
||||
import com.minres.scviewer.database.ITrRelation;
|
||||
import com.minres.scviewer.database.ITransaction;
|
||||
import com.minres.scviewer.database.ITxRelation;
|
||||
import com.minres.scviewer.database.ITx;
|
||||
import com.minres.scviewer.database.RelationType;
|
||||
|
||||
public class RelatedProperty extends AbstractPropertySection implements ISelectionProvider, ISelectionChangedListener {
|
||||
@@ -59,7 +59,7 @@ public class RelatedProperty extends AbstractPropertySection implements ISelecti
|
||||
|
||||
private ListenerList listeners = new ListenerList();
|
||||
|
||||
private ITransaction iTr;
|
||||
private ITx iTr;
|
||||
|
||||
private ISelection currentSelection;
|
||||
|
||||
@@ -105,26 +105,26 @@ public class RelatedProperty extends AbstractPropertySection implements ISelecti
|
||||
|
||||
treeViewer.setAutoExpandLevel(2);
|
||||
treeViewer.setContentProvider(new ITreeContentProvider() {
|
||||
TreeMap<String, Collection<ITrRelation>> hier = new TreeMap<String, Collection<ITrRelation>>();
|
||||
HashMap<ITrRelation, String> parents = new HashMap<ITrRelation, String>();
|
||||
TreeMap<String, Collection<ITxRelation>> hier = new TreeMap<String, Collection<ITxRelation>>();
|
||||
HashMap<ITxRelation, String> parents = new HashMap<ITxRelation, String>();
|
||||
|
||||
@Override
|
||||
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
|
||||
if (newInput instanceof ITransaction) {
|
||||
if (newInput instanceof ITx) {
|
||||
hier.clear();
|
||||
parents.clear();
|
||||
String relName = "incoming";
|
||||
Collection<ITrRelation> relSet = ((ITransaction)newInput).getIncomingRelations();
|
||||
Collection<ITxRelation> relSet = ((ITx)newInput).getIncomingRelations();
|
||||
if (relSet != null && relSet.size() > 0) {
|
||||
hier.put(relName, relSet);
|
||||
for (ITrRelation rel : relSet)
|
||||
for (ITxRelation rel : relSet)
|
||||
parents.put(rel, relName);
|
||||
}
|
||||
relName = "outgoing";
|
||||
relSet = ((ITransaction)newInput).getOutgoingRelations();
|
||||
relSet = ((ITx)newInput).getOutgoingRelations();
|
||||
if (relSet != null && relSet.size() > 0) {
|
||||
hier.put(relName, relSet);
|
||||
for (ITrRelation rel : relSet)
|
||||
for (ITxRelation rel : relSet)
|
||||
parents.put(rel, relName);
|
||||
}
|
||||
}
|
||||
@@ -141,7 +141,7 @@ public class RelatedProperty extends AbstractPropertySection implements ISelecti
|
||||
|
||||
@Override
|
||||
public Object getParent(Object element) {
|
||||
if (element instanceof ITransaction)
|
||||
if (element instanceof ITx)
|
||||
return parents.get(element);
|
||||
else
|
||||
return null;
|
||||
@@ -179,14 +179,14 @@ public class RelatedProperty extends AbstractPropertySection implements ISelecti
|
||||
public String getColumnText(Object element, int columnIndex) {
|
||||
if (columnIndex == 0 && element instanceof String)
|
||||
return element.toString();
|
||||
else if (columnIndex == 1 && element instanceof ITrRelation)
|
||||
return ((ITrRelation) element).getRelationType().getName();
|
||||
else if (columnIndex == 2 && element instanceof ITrRelation){
|
||||
ITrRelation rel = (ITrRelation) element;
|
||||
else if (columnIndex == 1 && element instanceof ITxRelation)
|
||||
return ((ITxRelation) element).getRelationType().getName();
|
||||
else if (columnIndex == 2 && element instanceof ITxRelation){
|
||||
ITxRelation rel = (ITxRelation) element;
|
||||
if(rel.getTarget()==iTr)
|
||||
return ((ITrRelation) element).getSource().getId().toString();
|
||||
return ((ITxRelation) element).getSource().getId().toString();
|
||||
else
|
||||
return ((ITrRelation) element).getTarget().getId().toString();
|
||||
return ((ITxRelation) element).getTarget().getId().toString();
|
||||
}
|
||||
else
|
||||
return null;
|
||||
@@ -217,13 +217,13 @@ public class RelatedProperty extends AbstractPropertySection implements ISelecti
|
||||
// }
|
||||
}
|
||||
|
||||
private Action makeTransactionAction(final Object obj, final ITransaction transaction) {
|
||||
private Action makeTransactionAction(final Object obj, final ITx transaction) {
|
||||
Action action = new Action() {
|
||||
public void run() {
|
||||
if(obj instanceof ITrRelation){
|
||||
if(obj instanceof ITxRelation){
|
||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
||||
ITransaction targetTransaction = ((ITrRelation)obj).getSource()==transaction?
|
||||
((ITrRelation)obj).getTarget():((ITrRelation)obj).getSource();
|
||||
ITx targetTransaction = ((ITxRelation)obj).getSource()==transaction?
|
||||
((ITxRelation)obj).getTarget():((ITxRelation)obj).getSource();
|
||||
for(IEditorReference editorRef: page.getEditorReferences()){
|
||||
IWorkbenchPart part =editorRef.getPart(false);
|
||||
if(editorRef.getPage().isPartVisible(part)){
|
||||
@@ -245,8 +245,8 @@ public class RelatedProperty extends AbstractPropertySection implements ISelecti
|
||||
currentSelection = null;
|
||||
Assert.isTrue(selection instanceof IStructuredSelection);
|
||||
Object input = ((IStructuredSelection) selection).getFirstElement();
|
||||
Assert.isTrue(input instanceof ITransaction);
|
||||
iTr = (ITransaction) input;
|
||||
Assert.isTrue(input instanceof ITx);
|
||||
iTr = (ITx) input;
|
||||
}
|
||||
|
||||
public void refresh() {
|
||||
|
||||
Reference in New Issue
Block a user